oolong-engine 0.0.1 → 0.0.2

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 (342) hide show
  1. package/README.md +152 -4
  2. package/dist/ability/checkbox/CheckboxWorker.d.ts +6 -0
  3. package/dist/ability/copyPaste/copy/CopyWorker.d.ts +1 -0
  4. package/dist/ability/copyPaste/duplicate/DuplicateWorker.d.ts +9 -0
  5. package/dist/ability/create/CreateWorker.d.ts +10 -0
  6. package/dist/ability/create/handler/AbsCreateHandler.d.ts +15 -0
  7. package/dist/ability/create/handler/CheckboxCreateHandler.d.ts +7 -0
  8. package/dist/ability/create/handler/CheckboxTextCreateHandler.d.ts +7 -0
  9. package/dist/ability/create/handler/LineCreateHandler.d.ts +8 -0
  10. package/dist/ability/create/handler/SectionCreateHandler.d.ts +7 -0
  11. package/dist/ability/create/handler/ShapeCreateHandler.d.ts +8 -0
  12. package/dist/ability/create/handler/SlideCreateHandler.d.ts +7 -0
  13. package/dist/ability/delete/DeleteWorker.d.ts +1 -0
  14. package/dist/ability/group/GroupWorker.d.ts +2 -0
  15. package/dist/ability/index.d.ts +2 -0
  16. package/dist/ability/line/BatchLineTextWorker.d.ts +8 -0
  17. package/dist/ability/line/LayoutWorker.d.ts +5 -1
  18. package/dist/ability/line/LineTextWorker.d.ts +7 -0
  19. package/dist/ability/line/handler/CurveLayoutHandler.d.ts +2 -0
  20. package/dist/ability/quickCreate/QuickCreateWorker.d.ts +22 -0
  21. package/dist/ability/resize/WindowResizeWorker.d.ts +6 -0
  22. package/dist/ability/slide/SlideCoverInfo.d.ts +6 -0
  23. package/dist/ability/slide/SlidePlayWorker.d.ts +6 -0
  24. package/dist/ability/svg/CreateSvgWorker.d.ts +3 -2
  25. package/dist/ability/svg/GenSvgBitmapWorker.d.ts +2 -1
  26. package/dist/ability/text/CacheOfflineCanvas.d.ts +8 -0
  27. package/dist/ability/text/TextUtils.d.ts +8 -0
  28. package/dist/ability/textInput/TextDeleteInputWorker.d.ts +37 -0
  29. package/dist/ability/textInput/TextInputWorker.d.ts +72 -0
  30. package/dist/ability/textInput/TextLineBreakWorker.d.ts +12 -0
  31. package/dist/ability/textInput/TextParagraphStyleWorker.d.ts +8 -0
  32. package/dist/ability/textInput/textFont/AbsTextFontWorker.d.ts +13 -0
  33. package/dist/ability/textInput/textFont/TextFontBgColorWorker.d.ts +6 -0
  34. package/dist/ability/textInput/textFont/TextFontBoldWorker.d.ts +6 -0
  35. package/dist/ability/textInput/textFont/TextFontColorWorker.d.ts +6 -0
  36. package/dist/ability/textInput/textFont/TextFontItalicWorker.d.ts +6 -0
  37. package/dist/ability/textInput/textFont/TextFontSizeWorker.d.ts +14 -0
  38. package/dist/ability/textInput/textFont/TextFontStrikethroughWorker.d.ts +6 -0
  39. package/dist/ability/textInput/textFont/TextUnderLineWorker.d.ts +6 -0
  40. package/dist/ability/textInput/textParagraphPrefix/TextNormalWorker.d.ts +14 -0
  41. package/dist/ability/textInput/textParagraphPrefix/TextOrderWorker.d.ts +15 -0
  42. package/dist/ability/textInput/textParagraphPrefix/TextParaPrefixWorker.d.ts +8 -0
  43. package/dist/ability/textInput/textParagraphPrefix/TextQuoteWorker.d.ts +15 -0
  44. package/dist/ability/textInput/textParagraphPrefix/TextUnOrderWorker.d.ts +15 -0
  45. package/dist/action/ActionManager.d.ts +2 -1
  46. package/dist/action/executor/ExecutorContext.d.ts +4 -0
  47. package/dist/action/executor/ExecutorManager.d.ts +7 -2
  48. package/dist/action/executor/beforeInterceptor/AbsInterceptor.d.ts +6 -0
  49. package/dist/action/executor/beforeInterceptor/slide/SlideCoverInsertInterceptor.d.ts +9 -0
  50. package/dist/action/executor/beforeInterceptor/slide/SlideCoverUpdateInterceptor.d.ts +13 -0
  51. package/dist/action/render/RenderManager.d.ts +15 -9
  52. package/dist/action/render/export/ExportWorker.d.ts +2 -0
  53. package/dist/action/render/zoom/ZoomWorker.d.ts +8 -7
  54. package/dist/app/AppEventContext.d.ts +20 -3
  55. package/dist/app/OolongApp.d.ts +4 -0
  56. package/dist/app/ai-api/OolongAIAPI.d.ts +11 -0
  57. package/dist/app/ai-api/module/AINodeAPI.d.ts +380 -0
  58. package/dist/app/ai-api/module/AIViewportAPI.d.ts +59 -0
  59. package/dist/app/ai-api/module/SelectAPI.d.ts +51 -0
  60. package/dist/app/api/OolongAPI.d.ts +22 -1
  61. package/dist/app/api/module/{createAPI.d.ts → CreateAPI.d.ts} +16 -0
  62. package/dist/app/api/module/SwitchAPI.d.ts +10 -0
  63. package/dist/app/api/module/align/AlignAPI.d.ts +19 -0
  64. package/dist/app/api/module/propChange/PropChangeAPI.d.ts +5 -0
  65. package/dist/app/api/module/propChange/fontsize/AbsFontSizeChangeHandler.d.ts +6 -0
  66. package/dist/app/api/module/propChange/fontsize/CheckboxTextFontSizeChangeHandler.d.ts +7 -0
  67. package/dist/app/api/module/propChange/fontsize/NormalFontSizeChangeHandler.d.ts +7 -0
  68. package/dist/app/api/module/slide/SlideAPI.d.ts +25 -0
  69. package/dist/app/api/module/text/TextAPI.d.ts +38 -0
  70. package/dist/app/docModeManager/DocModeManager.d.ts +12 -0
  71. package/dist/app/docModeManager/DocModeSwitchContext.d.ts +4 -0
  72. package/dist/app/docModeManager/switchHandler/AbsSwitchHandler.d.ts +5 -0
  73. package/dist/app/docModeManager/switchHandler/board/BoardToSlideEditHandler.d.ts +8 -0
  74. package/dist/app/docModeManager/switchHandler/board/BoardToSlidePlayHandler.d.ts +6 -0
  75. package/dist/app/docModeManager/switchHandler/slide-edit/SlideEditToBoardHandler.d.ts +6 -0
  76. package/dist/app/docModeManager/switchHandler/slide-edit/SlideEditToSlidePlayHandler.d.ts +5 -0
  77. package/dist/app/docModeManager/switchHandler/slide-play/SlidePlayToBoardHandler.d.ts +6 -0
  78. package/dist/app/docModeManager/switchHandler/slide-play/SlidePlayToSlideEditHandler.d.ts +5 -0
  79. package/dist/app/docState/DocMode.d.ts +5 -0
  80. package/dist/app/docState/DocState.d.ts +11 -0
  81. package/dist/app/docState/SlideStatus.d.ts +7 -0
  82. package/dist/app/index.d.ts +2 -0
  83. package/dist/application/GMLRender.d.ts +2 -1
  84. package/dist/application/nodeManager/NodeManager.d.ts +1 -0
  85. package/dist/asyncRender/AsyncRenderNodeManager.d.ts +3 -4
  86. package/dist/auxiliary/AuxiliaryManager.d.ts +2 -1
  87. package/dist/auxiliary/AuxiliaryStyleConst.d.ts +1 -0
  88. package/dist/auxiliary/graphics/AuxiliaryType.d.ts +13 -1
  89. package/dist/auxiliary/graphics/group/SelectGroup.d.ts +1 -0
  90. package/dist/auxiliary/graphics/hover/HoverFocusCopy.d.ts +10 -0
  91. package/dist/auxiliary/graphics/hover/HoverInsertHorizonSlide.d.ts +11 -0
  92. package/dist/auxiliary/graphics/hover/HoverInsertSlide.d.ts +11 -0
  93. package/dist/auxiliary/graphics/hover/HoverSlideGapInsertPoint.d.ts +12 -0
  94. package/dist/auxiliary/graphics/hover/HoverSlidePlaceHolder.d.ts +10 -0
  95. package/dist/auxiliary/graphics/select/SelectCurveControlPoint.d.ts +15 -0
  96. package/dist/auxiliary/graphics/select/SelectCurveEnd.d.ts +15 -0
  97. package/dist/auxiliary/graphics/select/SelectLineTextRect.d.ts +2 -0
  98. package/dist/auxiliary/graphics/select/SelectParentGroupBound.d.ts +10 -0
  99. package/dist/auxiliary/graphics/select/SelectSlideGapInsertPoint.d.ts +10 -0
  100. package/dist/common/detect/DetectorEnum.d.ts +5 -1
  101. package/dist/common/paste/PasteData.d.ts +2 -0
  102. package/dist/config/ShapeCategoryType.d.ts +3 -1
  103. package/dist/config/defaultBorderConfig.d.ts +2 -0
  104. package/dist/config/defaultColorConfig.d.ts +2 -0
  105. package/dist/cursor/CursorManager.d.ts +19 -2
  106. package/dist/cursor/CursorStyle.d.ts +0 -1
  107. package/dist/engine.js +21041 -16095
  108. package/dist/engine.umd.cjs +34 -31
  109. package/dist/graphics/OolongNode.d.ts +7 -2
  110. package/dist/graphics/OolongSVGNode.d.ts +2 -0
  111. package/dist/graphics/OolongSection.d.ts +1 -0
  112. package/dist/graphics/OolongSlideContainer.d.ts +17 -0
  113. package/dist/graphics/base/NodeConnectEndType.d.ts +2 -1
  114. package/dist/graphics/base/ShapeType.d.ts +9 -9
  115. package/dist/graphics/drawer/AbsDrawer.d.ts +5 -1
  116. package/dist/graphics/drawer/CloudDrawer.d.ts +10 -0
  117. package/dist/graphics/drawer/CrossDrawer.d.ts +13 -0
  118. package/dist/graphics/drawer/EllipseDrawer.d.ts +2 -2
  119. package/dist/graphics/drawer/HexagonDrawer.d.ts +12 -0
  120. package/dist/graphics/drawer/LingxingDrawer.d.ts +3 -2
  121. package/dist/graphics/drawer/OctagonDrawer.d.ts +13 -0
  122. package/dist/graphics/drawer/ParallelogramDrawer.d.ts +12 -0
  123. package/dist/graphics/drawer/PentagonDrawer.d.ts +13 -0
  124. package/dist/graphics/drawer/PureTextDrawer.d.ts +2 -0
  125. package/dist/graphics/drawer/RoundRectDrawer.d.ts +2 -2
  126. package/dist/graphics/drawer/StarDrawer.d.ts +13 -0
  127. package/dist/graphics/drawer/TrapezoidDrawer.d.ts +12 -0
  128. package/dist/graphics/drawer/Triangle2Drawer.d.ts +6 -0
  129. package/dist/graphics/drawer/TriangleDrawer.d.ts +2 -1
  130. package/dist/graphics/index.d.ts +5 -0
  131. package/dist/graphics/line/OolongLine.d.ts +9 -3
  132. package/dist/graphics/line/arrow/CircleArrowDrawer.d.ts +5 -0
  133. package/dist/graphics/line/arrow/EmptyCircleArrowDrawer.d.ts +5 -0
  134. package/dist/graphics/node/GraphicNode.d.ts +2 -0
  135. package/dist/graphics/props/BaseProps.d.ts +1 -1
  136. package/dist/graphics/props/LineTextRectProps.d.ts +4 -1
  137. package/dist/graphics/props/PropType.d.ts +6 -1
  138. package/dist/graphics/props/SlideProps.d.ts +12 -0
  139. package/dist/graphics/props/SvgProps.d.ts +2 -0
  140. package/dist/graphics/props/TextParagraphProps.d.ts +11 -0
  141. package/dist/graphics/props/TextParagraphQuoteProps.d.ts +11 -0
  142. package/dist/graphics/props/TextProps.d.ts +5 -3
  143. package/dist/graphics/props/widget/CheckSizeProps.d.ts +11 -0
  144. package/dist/graphics/props/widget/CheckStatusProps.d.ts +11 -0
  145. package/dist/graphics/utils/GraphicUtils.d.ts +70 -3
  146. package/dist/graphics/widget/OolongWidget.d.ts +10 -0
  147. package/dist/graphics/widget/checkbox/OolongCheckbox.d.ts +16 -0
  148. package/dist/graphics/widget/checkbox/OolongCheckboxText.d.ts +22 -0
  149. package/dist/idl/NodeType.d.ts +3 -0
  150. package/dist/idl/capInfo/ICapInfo.d.ts +10 -0
  151. package/dist/idl/capInfo/ICheckSizeProps.d.ts +3 -0
  152. package/dist/idl/capInfo/ICheckStatusProps.d.ts +3 -0
  153. package/dist/idl/capInfo/ILineTextRectProps.d.ts +4 -1
  154. package/dist/idl/capInfo/ISlideProps.d.ts +4 -0
  155. package/dist/idl/capInfo/ISlideRow.d.ts +3 -0
  156. package/dist/idl/capInfo/ISvgProps.d.ts +2 -0
  157. package/dist/idl/capInfo/ITextParagraphProps.d.ts +8 -0
  158. package/dist/idl/capInfo/ITextParagraphQuoteProps.d.ts +7 -0
  159. package/dist/idl/capInfo/ITextProps.d.ts +1 -0
  160. package/dist/idl/capInfo/TransitionEnum.d.ts +3 -0
  161. package/dist/idl/common/LineArrowType.d.ts +3 -1
  162. package/dist/idl/common/RotateType.d.ts +6 -0
  163. package/dist/index.d.ts +2 -0
  164. package/dist/input/index.d.ts +2 -0
  165. package/dist/plugin-copy-paste/copy-paste/copy/CopyTextHandler.d.ts +38 -0
  166. package/dist/plugin-copy-paste/copy-paste/paste/oolongData/IOolongDataHandler.d.ts +4 -3
  167. package/dist/plugin-copy-paste/copy-paste/paste/oolongData/pasteNode/PasteNodeHandler.d.ts +8 -3
  168. package/dist/plugin-copy-paste/copy-paste/paste/oolongData/pasteNode/posHandler/AbsPastePosHandler.d.ts +8 -0
  169. package/dist/plugin-copy-paste/copy-paste/paste/oolongData/pasteNode/posHandler/EmptyPlacePosHandler.d.ts +9 -0
  170. package/dist/plugin-copy-paste/copy-paste/paste/oolongData/pasteNode/posHandler/NormalPastePosHandler.d.ts +9 -0
  171. package/dist/plugin-copy-paste/copy-paste/paste/oolongData/pasteNode/posHandler/PosPasteType.d.ts +4 -0
  172. package/dist/plugin-copy-paste/copy-paste/utils/CopyPasteUtils.d.ts +5 -0
  173. package/dist/plugin-copy-paste/index.d.ts +4 -0
  174. package/dist/plugin-hotkey/hotkey/common/ShiftKey.d.ts +8 -0
  175. package/dist/plugin-hotkey/hotkey/config/KeyCodeConfig.d.ts +2 -0
  176. package/dist/plugin-hotkey/hotkey/normal/EnterHotKey.d.ts +8 -0
  177. package/dist/plugin-hotkey/hotkey/normal/move/ArrowDownKey.d.ts +14 -0
  178. package/dist/plugin-hotkey/hotkey/normal/move/ArrowLeftKey.d.ts +14 -0
  179. package/dist/plugin-hotkey/hotkey/normal/move/ArrowMoveWorker.d.ts +23 -0
  180. package/dist/plugin-hotkey/hotkey/normal/move/ArrowRightKey.d.ts +14 -0
  181. package/dist/plugin-hotkey/hotkey/normal/move/ArrowUpKey.d.ts +14 -0
  182. package/dist/plugin-hotkey/hotkey/text/AbsArrowKey.d.ts +1 -1
  183. package/dist/plugin-hotkey/hotkey/text/ArrowRightKey.d.ts +3 -2
  184. package/dist/plugin-hotkey/hotkey/text/EnterHotKey.d.ts +7 -3
  185. package/dist/plugin-hotkey/hotkey/text/EscKey.d.ts +7 -0
  186. package/dist/plugin-hotkey/hotkey/text/TabKey.d.ts +7 -0
  187. package/dist/plugin-input/InputEventPlugin.d.ts +2 -2
  188. package/dist/plugin-input/common/ICompositionRecord.d.ts +1 -1
  189. package/dist/plugin-input/handler/AbsInputHandler.d.ts +2 -0
  190. package/dist/plugin-input/handler/InputCompositionHandler.d.ts +1 -1
  191. package/dist/plugin-input/handler/InputNormalHandler.d.ts +1 -1
  192. package/dist/plugin-pointer/PointerEventPlugin.d.ts +5 -0
  193. package/dist/plugin-pointer/interact/InteractiveManager.d.ts +1 -1
  194. package/dist/plugin-pointer/interact/InteractiveUtils.d.ts +21 -4
  195. package/dist/plugin-pointer/interact/align/AlignWorker.d.ts +3 -3
  196. package/dist/plugin-pointer/interact/align/common/AlignHorizonHandler.d.ts +1 -0
  197. package/dist/plugin-pointer/interact/align/common/AlignVerticalHandler.d.ts +1 -0
  198. package/dist/plugin-pointer/interact/basic/constants.d.ts +2 -0
  199. package/dist/plugin-pointer/interact/config/InteractConfig.d.ts +3 -1
  200. package/dist/plugin-pointer/interact/default/click/handler/AnchorQuickCreateHandler.d.ts +21 -0
  201. package/dist/plugin-pointer/interact/default/click/handler/ClickInsertEmptySlideHandler.d.ts +7 -0
  202. package/dist/plugin-pointer/interact/default/click/handler/ClickInsertSlideHandler.d.ts +11 -0
  203. package/dist/plugin-pointer/interact/default/click/handler/ClickTextHandler.d.ts +2 -1
  204. package/dist/plugin-pointer/interact/default/click/handler/widget/CheckboxHandler.d.ts +11 -0
  205. package/dist/plugin-pointer/interact/default/connectAnchor/ConnectAnchorProcessor.d.ts +2 -2
  206. package/dist/plugin-pointer/interact/default/create/CreateColorConfig.d.ts +0 -2
  207. package/dist/plugin-pointer/interact/default/create/CreateLineMainMode.d.ts +7 -0
  208. package/dist/plugin-pointer/interact/default/create/CreateTextMode.d.ts +1 -1
  209. package/dist/plugin-pointer/interact/default/create/RectCreateDragProcessor.d.ts +1 -0
  210. package/dist/plugin-pointer/interact/default/create/base/AbsCreateDragProcessor.d.ts +1 -0
  211. package/dist/plugin-pointer/interact/default/create/line/handler/AbsLineCreateHandler.d.ts +2 -2
  212. package/dist/plugin-pointer/interact/default/create/normal/CreateNormalMode.d.ts +2 -1
  213. package/dist/plugin-pointer/interact/default/create/normal/grab/handler/AbsCreateUpHandler.d.ts +1 -1
  214. package/dist/plugin-pointer/interact/default/create/normal/grab/handler/CreateUpCheckboxHandler.d.ts +11 -0
  215. package/dist/plugin-pointer/interact/default/create/normal/grab/handler/CreateUpCheckboxTextHandler.d.ts +11 -0
  216. package/dist/plugin-pointer/interact/default/create/normal/grab/handler/CreateUpLineHandler.d.ts +11 -0
  217. package/dist/plugin-pointer/interact/default/create/normal/grab/handler/CreateUpSectionHandler.d.ts +0 -2
  218. package/dist/plugin-pointer/interact/default/create/normal/grab/handler/CreateUpShapeHandler.d.ts +0 -2
  219. package/dist/plugin-pointer/interact/default/create/normal/grab/handler/CreateUpSlideHandler.d.ts +11 -0
  220. package/dist/plugin-pointer/interact/default/create/normal/hover/CreateHoverNodeProcessor.d.ts +2 -2
  221. package/dist/plugin-pointer/interact/default/create/normal/hover/CreateLineMoveProcessor.d.ts +3 -3
  222. package/dist/plugin-pointer/interact/default/curveControlPoint/BezierCurve.d.ts +42 -0
  223. package/dist/plugin-pointer/interact/default/curveControlPoint/BezierWorker.d.ts +34 -0
  224. package/dist/plugin-pointer/interact/default/curveControlPoint/CurveControlPointMode.d.ts +7 -0
  225. package/dist/plugin-pointer/interact/default/curveControlPoint/CurveControlPointProcessor.d.ts +20 -0
  226. package/dist/plugin-pointer/interact/default/curveControlPoint/utils.d.ts +5 -0
  227. package/dist/plugin-pointer/interact/default/curveEndPoint/CurveEndPointMode.d.ts +7 -0
  228. package/dist/plugin-pointer/interact/default/curveEndPoint/CurveEndProcessor.d.ts +16 -0
  229. package/dist/plugin-pointer/interact/default/dbClick/handler/DBClickTextHandler.d.ts +2 -1
  230. package/dist/plugin-pointer/interact/default/dbClick/handler/DbCheckboxHandler.d.ts +11 -0
  231. package/dist/plugin-pointer/interact/default/drag/DragProcessor.d.ts +2 -0
  232. package/dist/plugin-pointer/interact/default/dragLineText/DragLineTextMode.d.ts +7 -0
  233. package/dist/plugin-pointer/interact/default/dragLineText/DragLineTextProcessor.d.ts +15 -0
  234. package/dist/plugin-pointer/interact/default/dragLineText/handler/AbsLineIntersectHandler.d.ts +10 -0
  235. package/dist/plugin-pointer/interact/default/dragLineText/handler/CurveLineIntersectHandler.d.ts +12 -0
  236. package/dist/plugin-pointer/interact/default/dragLineText/handler/LineShapeIntersectResult.d.ts +5 -0
  237. package/dist/plugin-pointer/interact/default/dragLineText/handler/PolyLineIntersectHandler.d.ts +18 -0
  238. package/dist/plugin-pointer/interact/default/dragLineText/handler/SimpleLineIntersectHandler.d.ts +12 -0
  239. package/dist/plugin-pointer/interact/default/dragSelectText/DragSelectTextProcessor.d.ts +2 -2
  240. package/dist/plugin-pointer/interact/default/dragSlide/DragSlideMode.d.ts +7 -0
  241. package/dist/plugin-pointer/interact/default/dragSlide/DragSlideProcessor.d.ts +55 -0
  242. package/dist/plugin-pointer/interact/default/group/GroupMode.d.ts +1 -1
  243. package/dist/plugin-pointer/interact/default/group/GroupProcessor.d.ts +2 -0
  244. package/dist/plugin-pointer/interact/default/group/handler/AbsGroupHandler.d.ts +8 -0
  245. package/dist/plugin-pointer/interact/default/group/handler/CmdGroupHandler.d.ts +9 -0
  246. package/dist/plugin-pointer/interact/default/group/handler/NormalGroupHandler.d.ts +9 -0
  247. package/dist/plugin-pointer/interact/default/lineControlPoint/LineControlPointProcessor.d.ts +2 -0
  248. package/dist/plugin-pointer/interact/default/lineEnd/DragLineEndProcessor.d.ts +6 -2
  249. package/dist/plugin-pointer/interact/default/lineEnd/handler/DragCurveLineEndHandler.d.ts +14 -0
  250. package/dist/plugin-pointer/interact/default/normal/cursor/handler/CurveControlPointCursorHandler.d.ts +9 -0
  251. package/dist/plugin-pointer/interact/default/normal/cursor/handler/CurveEndPointCursorHandler.d.ts +9 -0
  252. package/dist/plugin-pointer/interact/default/normal/cursor/handler/HoverSlideCursorHandler.d.ts +7 -0
  253. package/dist/plugin-pointer/interact/default/normal/cursor/handler/LineTextCursorHandler.d.ts +9 -0
  254. package/dist/plugin-pointer/interact/default/normal/cursor/handler/NormalCursorHandler.d.ts +2 -2
  255. package/dist/plugin-pointer/interact/default/normal/cursor/handler/RotateCursorHandler.d.ts +2 -2
  256. package/dist/plugin-pointer/interact/default/normal/cursor/handler/SlideGapInsertHandler.d.ts +7 -0
  257. package/dist/plugin-pointer/interact/default/normal/cursor/handler/StretchCursorHandler.d.ts +2 -2
  258. package/dist/plugin-pointer/interact/default/rotate/RotateMode.d.ts +2 -2
  259. package/dist/plugin-pointer/interact/default/stretch/AbsStretchProcessor.d.ts +4 -0
  260. package/dist/plugin-pointer/interact/default/stretch/SingleStretchMode.d.ts +4 -4
  261. package/dist/plugin-pointer/interact/default/stretch/SingleStretchProcessorV2.d.ts +5 -3
  262. package/dist/plugin-pointer/interact/default/stretch/StretchMode.d.ts +2 -2
  263. package/dist/plugin-pointer/interact/default/stretch/StretchProcessorV2.d.ts +4 -1
  264. package/dist/plugin-pointer/interact/default/stretch/handler/AbsStretchHandler.d.ts +2 -1
  265. package/dist/plugin-pointer/interact/default/stretch/handler/CheckboxTextStretchHandler.d.ts +10 -0
  266. package/dist/plugin-pointer/interact/default/stretch/handler/SingleStretchSectionHandler.d.ts +11 -0
  267. package/dist/plugin-pointer/interact/default/stretch/handler/{SingleStretchNodeHandler.d.ts → StretchSlideContainerHandler.d.ts} +1 -1
  268. package/dist/plugin-pointer/interact/default/stretch/handler/TextStretchHandler.d.ts +10 -0
  269. package/dist/plugin-pointer/interact/detector/DetectorResult.d.ts +10 -0
  270. package/dist/plugin-pointer/interact/detector/RotateDetector.d.ts +3 -0
  271. package/dist/plugin-pointer/interact/detector/dragText/DragLineTextDetector.d.ts +9 -0
  272. package/dist/plugin-pointer/interact/detector/line/CurveControlPointDetector.d.ts +16 -0
  273. package/dist/plugin-pointer/interact/detector/line/CurveEndPointDetector.d.ts +10 -0
  274. package/dist/plugin-pointer/interact/detector/slide/EmptySlideContainerAddDetector.d.ts +12 -0
  275. package/dist/plugin-pointer/interact/detector/slide/SlideGapDetector.d.ts +15 -0
  276. package/dist/plugin-pointer/interact/detector/stretch/StretchDetector.d.ts +1 -0
  277. package/dist/plugin-pointer/interact/playSlide/PlayNormalMode.d.ts +8 -0
  278. package/dist/plugin-pointer/interact/playSlide/PlaySlideMode.d.ts +7 -0
  279. package/dist/plugin-pointer/interact/utils/RectUtils.d.ts +1 -1
  280. package/dist/plugin-pointer/interact/viewOnly/normal/ViewOnlyHoverProcessor.d.ts +9 -0
  281. package/dist/plugin-pointer/mobile/TouchScrollZoomWorker.d.ts +37 -0
  282. package/dist/plugin-resize/WindowResizePlugin.d.ts +0 -3
  283. package/dist/plugin-wheel/WheelEventPlugin.d.ts +3 -3
  284. package/dist/preview/IPreviewConnectInfo.d.ts +6 -0
  285. package/dist/preview/PreviewQuickCreateManager.d.ts +2 -0
  286. package/dist/preview/previewCreate/handler/AbsPreviewHandler.d.ts +3 -1
  287. package/dist/preview/previewCreate/handler/PreviewCheckboxHandler.d.ts +7 -0
  288. package/dist/preview/previewCreate/handler/PreviewCheckboxTextHandler.d.ts +7 -0
  289. package/dist/preview/previewCreate/handler/PreviewSectionHandler.d.ts +0 -3
  290. package/dist/preview/previewCreate/handler/PreviewShapeHandler.d.ts +0 -3
  291. package/dist/preview/previewCreate/handler/PreviewSlideHandler.d.ts +7 -0
  292. package/dist/preview/previewCreate/handler/previewLine/PreviewLineHandler.d.ts +12 -0
  293. package/dist/preview/previewCreate/handler/previewLine/helper/AbsLineHelper.d.ts +6 -0
  294. package/dist/preview/previewCreate/handler/previewLine/helper/CurveLineHelper.d.ts +5 -0
  295. package/dist/preview/previewCreate/handler/previewLine/helper/PolyLineHelper.d.ts +5 -0
  296. package/dist/preview/previewCreate/handler/previewLine/helper/RoundPolyLineHelper.d.ts +5 -0
  297. package/dist/preview/previewCreate/handler/previewLine/helper/SimpleLineHelper.d.ts +7 -0
  298. package/dist/renderText/RenderText.d.ts +42 -11
  299. package/dist/renderText/TextBlock.d.ts +54 -0
  300. package/dist/renderText/TextConstants.d.ts +3 -0
  301. package/dist/renderText/TextLine.d.ts +25 -11
  302. package/dist/renderText/TextParagraph.d.ts +12 -3
  303. package/dist/renderText/TypesettingCtx.d.ts +6 -0
  304. package/dist/renderText/editInfo/EditTextWorker.d.ts +7 -1
  305. package/dist/renderText/editInfo/baseprops/OolongLineModifyWorker.d.ts +6 -0
  306. package/dist/renderText/editInfo/baseprops/OolongNodeModifyWorker.d.ts +10 -0
  307. package/dist/renderText/linebreak/CharacterLineBreakWorker.d.ts +6 -0
  308. package/dist/renderText/measure/TextBlockMeasureWorker.d.ts +5 -0
  309. package/dist/renderText/paraStyle/IParagraphStyleProp.d.ts +9 -0
  310. package/dist/renderText/paraStyle/ITextQuoteInfo.d.ts +8 -0
  311. package/dist/renderText/paraStyle/PrefixDrawer.d.ts +28 -0
  312. package/dist/renderText/paraStyle/TextQuoteLineWorker.d.ts +14 -0
  313. package/dist/renderText/richText/ITextBlock.d.ts +30 -0
  314. package/dist/renderText/richText/RichTextHelper.d.ts +31 -0
  315. package/dist/renderText/richText/RichTextParagraph.d.ts +5 -0
  316. package/dist/renderText/richText/RichTextWord.d.ts +4 -0
  317. package/dist/renderText/selection/TextSelectionDeleteWorker.d.ts +2 -2
  318. package/dist/renderText/split/GraphemeSplit.d.ts +1 -0
  319. package/dist/renderText/split/IntlSplit.d.ts +1 -0
  320. package/dist/renderText/split/LinebreakSplit.d.ts +9 -0
  321. package/dist/resource-manager/AbsResourceInstance.d.ts +2 -1
  322. package/dist/resource-manager/IResourceInfo.d.ts +3 -0
  323. package/dist/resource-manager/NormalResourceInstance.d.ts +2 -1
  324. package/dist/resource-manager/ResourceEnumType.d.ts +4 -0
  325. package/dist/resource-manager/ResourceManager.d.ts +7 -2
  326. package/dist/resource-manager/index.d.ts +1 -0
  327. package/dist/select/SelectManager.d.ts +3 -1
  328. package/dist/select/status/SelectStatusContext.d.ts +2 -0
  329. package/dist/select/status/readOnly/ReadOnlyMultiStatusHandler.d.ts +8 -0
  330. package/dist/select/status/readOnly/ReadOnlySingleStatusHandler.d.ts +11 -0
  331. package/dist/select/status/single/SingleCurveStatusHandler.d.ts +7 -0
  332. package/dist/select/status/single/SingleSlideContainerStatusHandler.d.ts +7 -0
  333. package/dist/select/status/single/SingleSlideEditStatusHandler.d.ts +8 -0
  334. package/dist/select/status/single/SingleSlideStatusHandler.d.ts +7 -0
  335. package/dist/slide/SlideCoverManager.d.ts +13 -0
  336. package/dist/slide/SlideManager.d.ts +47 -0
  337. package/dist/slot/SlotKeyType.d.ts +4 -1
  338. package/dist/tool/ToolEnum.d.ts +3 -1
  339. package/dist/tool/WidgetEnum.d.ts +4 -0
  340. package/dist/tool/index.d.ts +1 -0
  341. package/dist/utils/MobileUtils.d.ts +6 -0
  342. package/package.json +5 -33
@@ -1,27 +1,31 @@
1
- (function(P,Kt){typeof exports=="object"&&typeof module<"u"?Kt(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],Kt):(P=typeof globalThis<"u"?globalThis:P||self,Kt(P.engine={},P.React))})(this,function(P,Kt){"use strict";var Wg=Object.defineProperty;var Gg=(P,Kt,xn)=>Kt in P?Wg(P,Kt,{enumerable:!0,configurable:!0,writable:!0,value:xn}):P[Kt]=xn;var g=(P,Kt,xn)=>Gg(P,typeof Kt!="symbol"?Kt+"":Kt,xn);var xn=document.createElement("style");xn.textContent=`.canvas-container .auxiliary-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:2;pointer-events:none}.canvas-container .content-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:1}.canvas-container .page-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:0}.normal-container,.normal-container .normal-canvas{width:100%;height:100%}.canvas-input{position:absolute;border:none;outline:none;-webkit-user-select:none;user-select:none;width:1px;z-index:3;opacity:0;pointer-events:none}@keyframes van-cursor-flicker{0%{opacity:1}50%{opacity:0}to{opacity:1}}.render-input{position:absolute;background-color:#000;width:1px;height:12px;z-index:4;pointer-events:none;animation:.6s van-cursor-flicker infinite}
2
- /*$vite$:1*/`,document.head.appendChild(xn);class El{constructor(e){g(this,"ctx");this.ctx=e,e.actionManager.addNetworkPlugin(this)}onEnable(e){return!0}}const Il={default:"default",rotate:`url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.9082%203.85059C14.0928%203.85261%2016.1881%204.7106%2017.7334%206.23828C19.2787%207.7661%2020.1483%209.83859%2020.1504%2012L20.1396%2012.4043C20.0368%2014.4183%2019.1819%2016.3285%2017.7334%2017.7607C16.2848%2019.1931%2014.3533%2020.0379%2012.3174%2020.1396L11.9092%2020.1504C10.3162%2020.1491%208.75743%2019.6911%207.42188%2018.832C6.08627%2017.9729%205.03078%2016.7489%204.38379%2015.3086V15.3076L4.29785%2015.1328L4.23047%2014.9922L4.37402%2014.9297L5.4707%2014.4541L5.60547%2014.3955L5.66699%2014.5293L5.74512%2014.7002V14.7012C6.27672%2015.8811%207.1437%2016.8836%208.24023%2017.5869C9.33678%2018.2902%2010.6165%2018.664%2011.9238%2018.6631C13.7117%2018.6611%2015.4257%2017.9583%2016.6895%2016.709C17.9531%2015.4596%2018.664%2013.7661%2018.666%2012L18.6572%2011.6699C18.5727%2010.0241%2017.8741%208.46224%2016.6895%207.29102C15.5048%206.11991%2013.9246%205.4294%2012.2588%205.3457L11.9238%205.33691C10.2576%205.32911%208.65157%205.93764%207.41797%207.03809L8.37988%207.81738C8.47241%207.89286%208.54347%207.99116%208.58594%208.10254C8.62839%208.21416%208.64053%208.33534%208.62109%208.45312C8.60162%208.57095%208.55163%208.68212%208.47559%208.77441C8.39959%208.86659%208.30039%208.93712%208.18848%208.97949H8.1875L4.76953%2010.2441L4.76855%2010.2451C4.54271%2010.3263%204.28941%2010.2846%204.10254%2010.1348C4.00925%2010.0601%203.93741%209.96188%203.89453%209.85059C3.85169%209.73932%203.83987%209.61856%203.85938%209.50098L4.45801%205.94336C4.47668%205.82506%204.52762%205.71411%204.60449%205.62207C4.68015%205.5316%204.77874%205.46232%204.88965%205.42188C5.00155%205.37708%205.1242%205.36412%205.24316%205.38379C5.36053%205.40323%205.46998%205.45444%205.56055%205.53125H5.56152L6.24902%206.08789C7.77116%204.64779%209.79863%203.84478%2011.9082%203.85059Z'%20fill='black'%20stroke='black'%20stroke-width='0.3'/%3e%3c/svg%3e") 12 12,auto`};class qo{constructor(){g(this,"currentCursor","default")}setCursor(e){if(this.currentCursor!==e){const t=Il[e];t?document.body.style.cursor=t:document.body.style.cursor=e,this.currentCursor=e}}}let m=class Nl{constructor(e=0,t=0){g(this,"x");g(this,"y");this.x=e,this.y=t}clone(){return new Nl(this.x,this.y)}};var $o=(l=>(l.LEFT="LEFT",l.TOP="TOP",l.RIGHT="RIGHT",l.BOTTOM="BOTTOM",l))($o||{});class kl extends m{constructor(t,n,s,r){super(t.x,t.y);g(this,"xPos");g(this,"yPos");g(this,"nodeSide");this.xPos=n,this.yPos=s,this.nodeSide=r}}class Bl extends m{constructor(){super(...arguments);g(this,"isHorizon",!0)}}const Un="ROOT",Qo="ROOT";var A=(l=>(l[l.Shape=0]="Shape",l[l.Line=1]="Line",l[l.SVG=2]="SVG",l[l.IMG=3]="IMG",l[l.Section=4]="Section",l[l.Group=5]="Group",l[l.ROOT=99]="ROOT",l))(A||{}),Ee=(l=>(l[l.None=0]="None",l[l.Solid=1]="Solid",l[l.Dash1=2]="Dash1",l[l.Dash2=3]="Dash2",l))(Ee||{}),we=(l=>(l[l.None=0]="None",l[l.Arrow=1]="Arrow",l[l.Triangle=2]="Triangle",l[l.EmptyTriangle=3]="EmptyTriangle",l[l.Diamond=4]="Diamond",l[l.EmptyDiamond=5]="EmptyDiamond",l))(we||{}),xe=(l=>(l[l.Top=0]="Top",l[l.Middle=1]="Middle",l[l.Bottom=2]="Bottom",l))(xe||{}),le=(l=>(l[l.fix=0]="fix",l[l.autoHeight=1]="autoHeight",l[l.autoWidth=2]="autoWidth",l))(le||{}),R=(l=>(l[l.Base=0]="Base",l[l.Color=1]="Color",l[l.Border=2]="Border",l[l.Text=3]="Text",l[l.Shape=4]="Shape",l[l.Line=5]="Line",l[l.Arrow=6]="Arrow",l[l.Connect=7]="Connect",l[l.LineTextRect=8]="LineTextRect",l[l.Svg=9]="Svg",l[l.Image=10]="Image",l[l.Crop=11]="Crop",l))(R||{});class Pe{}class ps extends Pe{constructor(){super(...arguments);g(this,"type",R.Image);g(this,"url","")}static from(t){const n=new ps;return n.url=t.url,n}clone(){const t=new ps;return t.url=this.url,t}update(t){const{url:n}=t;n!==void 0&&(this.url=n)}}class gt extends Pe{constructor(){super(...arguments);g(this,"type",R.Base);g(this,"x",0);g(this,"y",0);g(this,"width",100);g(this,"height",100);g(this,"angle",0)}static create(t){const n=new gt;return n.update(t),n}static from(t){const n=new gt;return n.x=t.x,n.y=t.y,n.width=t.width,n.height=t.height,n.angle=t.angle,n}update(t){const{x:n,y:s,height:r,width:o,angle:i}=t;n!==void 0&&(this.x=n),s!==void 0&&(this.y=s),r!==void 0&&(this.height=r),o!==void 0&&(this.width=o),i!==void 0&&(this.angle=i)}clone(){const t=new gt;return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.angle=this.angle,t}}class Ot extends Pe{constructor(){super(...arguments);g(this,"type",R.Border);g(this,"color","#000000");g(this,"alpha",1);g(this,"width",2);g(this,"dashType",Ee.Solid)}static create(t){const n=new Ot;return n.update(t),n}static from(t){const n=new Ot;return n.color=t.color,n.alpha=t.alpha,n.width=t.width,n.dashType=t.dashType,n}update(t){const{color:n,alpha:s,width:r,dashType:o}=t;n!==void 0&&(this.color=n),s!==void 0&&(this.alpha=s),r!==void 0&&(this.width=r),o!==void 0&&(this.dashType=o)}clone(){const t=new Ot;return t.color=this.color,t.alpha=this.alpha,t.width=this.width,t.dashType=this.dashType,t}}class Z{constructor(){g(this,"a",1);g(this,"b",0);g(this,"c",0);g(this,"d",1);g(this,"e",0);g(this,"f",0)}static generateMatrix(){return new Z}setTransform(e,t,n,s,r,o){this.a=e,this.b=t,this.c=n,this.d=s,this.e=r,this.f=o}rotate(e){const t=e/180*Math.PI;return this.rotate2(t),this}rotate2(e){return this.a=Math.cos(e),this.c=-Math.sin(e),this.b=Math.sin(e),this.d=Math.cos(e),this}scale(e,t){return this.a=e,this.d=t,this}translate(e,t){return this.e=e,this.f=t,this}crossProduct(e){const t=new Z;return t.a=this.a*e.a+this.c*e.b,t.b=this.b*e.a+this.d*e.b,t.c=this.a*e.c+this.c*e.d,t.d=this.b*e.c+this.d*e.d,t.e=this.a*e.e+this.c*e.f+this.e,t.f=this.b*e.e+this.d*e.f+this.f,t}crossPoint(e){return new m(this.a*e.x+this.c*e.y+this.e,this.b*e.x+this.d*e.y+this.f)}inverseMatrix(){const{a:e,b:t,c:n,d:s,e:r,f:o}=this,i=e*s-t*n;if(Math.abs(i)<1e-4)throw new Error("该仿射变换不可逆");const a=s/i,c=-t/i,h=-n/i,d=e/i,u=(n*o-s*r)/i,p=(t*r-e*o)/i,f=Z.generateMatrix();return f.a=a,f.b=c,f.c=h,f.d=d,f.e=u,f.f=p,f}clone(){const e=new Z;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.e=this.e,e.f=this.f,e}}class Ol{constructor(e,t,n){g(this,"p0");g(this,"p1");g(this,"p2");this.p0=e,this.p1=t,this.p2=n}xStationaryPoint(){return(this.p0.x-this.p1.x)/(this.p0.x-2*this.p1.x+this.p2.x)}dxdt(e){return 2*e*(this.p0.x-2*this.p1.x+this.p2.x)-2*(this.p0.x-this.p1.x)}xValue(e){const t=1-e;return t*t*this.p0.x+2*e*t*this.p1.x+e*e*this.p2.x}yValue(e){const t=1-e;return t*t*this.p0.y+2*e*t*this.p1.y+e*e*this.p2.y}newtonSolveX(e,t,n){let r=.5*(t+n),o=0;for(;;){o++;const i=this.xValue(r)-e,a=this.dxdt(r),c=r-i/a;if(Math.abs(c-r)<.01)return c;if(o>20)return null;r=c}return null}solve(e,t=6){const n=this.xStationaryPoint();if(n<0||n>1)return this.monotonicSolve(e,0,1,t);let s=this.monotonicSolve(e,0,n,t);return s?!0:(s=this.monotonicSolve(e,n,1,t),s)}monotonicSolve(e,t,n,s){const r=this.xValue(t),o=this.xValue(n),i=e.x,a=e.y;if((i-r)*(i-o)>0)return!1;const c=this.newtonSolveX(i,t,n);return c===null?(console.warn("newton 迭代求解贝塞尔曲线出错."),!1):Math.abs(a-this.yValue(c))<s}}class Ws{constructor(e){g(this,"prev",null);g(this,"next",null);g(this,"data",null);this.data=e}breakOff(){this.prev=null,this.next=null}toString(){return this.data?this.data.toString():""}add(e){const t=this.next;this.next=e,e.prev=this,e.next=t,t&&(t.prev=e)}pushAdd(e){this.next=e,e.prev=this}removeSelf(){const e=this.next,t=this.prev;this.next=null,this.prev=null,e.prev=t,t.next=e}getIndex(){let e=this.prev,t=0;for(;e&&e.data;)t++,e=e.prev;return t}static generateLink(){const e=new Ws(null),t=new Ws(null);return e.add(t),e}}class D{constructor(e=0,t=0,n=100,s=100){g(this,"x");g(this,"y");g(this,"width");g(this,"height");this.x=e,this.y=t,this.width=n,this.height=s}clone(){return new D(this.x,this.y,this.width,this.height)}static baseProps2Rect(e){const{x:t,y:n,width:s,height:r}=e;return new D(t,n,s,r)}static rectNode2Rect(e){const{minY:t,minX:n,maxY:s,maxX:r}=e;return new D(n,t,r-n,s-t)}static toRectNode(e){const{x:t,y:n,width:s,height:r}=e;return{minX:t,minY:n,maxX:t+s,maxY:n+r}}}var Gs=(l=>(l[l.Image=0]="Image",l[l.SVG=1]="SVG",l))(Gs||{});class ne{constructor(){g(this,"result",null)}detect(e,t){return this.result?!0:this.onDetect(e,t)}reset(){this.result=null}}var W=(l=>(l[l.Node=0]="Node",l[l.Stretch=1]="Stretch",l[l.HoverNode=2]="HoverNode",l[l.ParagraphHead=3]="ParagraphHead",l[l.PolyControlPoint=4]="PolyControlPoint",l[l.CurveControlPoint=5]="CurveControlPoint",l[l.LineEndPoint=6]="LineEndPoint",l[l.ConnectorPoint=7]="ConnectorPoint",l[l.Rotate=8]="Rotate",l[l.SingleStretch=9]="SingleStretch",l[l.ExpandShape=10]="ExpandShape",l[l.NodeEdge=11]="NodeEdge",l[l.BufferNode=12]="BufferNode",l[l.BufferHoverNode=13]="BufferHoverNode",l[l.HoverNodeAnchor=14]="HoverNodeAnchor",l[l.HoverConnectAnchor=15]="HoverConnectAnchor",l[l.HoverOnContainer=16]="HoverOnContainer",l[l.Image=17]="Image",l[l.ImageOriginBounds=18]="ImageOriginBounds",l))(W||{}),yt=(l=>(l.pointerDown="pointerdown",l.pointermove="pointermove",l.pointermoveOutside="pointermoveOutside",l.pointerup="pointerup",l.unknown="unknown",l))(yt||{}),G=(l=>(l[l.TOP=0]="TOP",l[l.LEFT=1]="LEFT",l[l.BOTTOM=2]="BOTTOM",l[l.RIGHT=3]="RIGHT",l[l.TOP_LEFT=4]="TOP_LEFT",l[l.TOP_RIGHT=5]="TOP_RIGHT",l[l.BOTTOM_LEFT=6]="BOTTOM_LEFT",l[l.BOTTOM_RIGHT=7]="BOTTOM_RIGHT",l))(G||{});class Jt extends Pe{constructor(){super(...arguments);g(this,"type",R.Color);g(this,"color","#ffccff");g(this,"alpha",1)}static create(t){const n=new Jt;return n.update(t),n}static from(t){const n=new Jt;return n.color=t.color,n.alpha=t.alpha,n}update(t){const{color:n,alpha:s}=t;n!==void 0&&(this.color=n),s!==void 0&&(this.alpha=s)}clone(){const t=new Jt;return t.color=this.color,t.alpha=this.alpha,t}}class se extends Pe{constructor(){super(...arguments);g(this,"type",R.Text);g(this,"text","");g(this,"fontSize",14);g(this,"fontFamily","Noto Sans");g(this,"fontColor","#000000");g(this,"fontBgColor","");g(this,"bold",!1);g(this,"italic",!1);g(this,"underline",!1);g(this,"strikethrough",!1);g(this,"verticalAlign",xe.Middle);g(this,"horizonAlign",xe.Middle);g(this,"sizeMode",le.fix)}static create(t){const n=new se;return n.update(t),n}static from(t){const n=new se;return n.text=t.text,n.fontSize=t.fontSize,n.fontFamily=t.fontFamily,n.fontColor=t.fontColor,n.fontBgColor=t.fontBgColor,n.bold=t.bold,n.italic=t.italic,n.underline=t.underline,n.strikethrough=t.strikethrough,n.verticalAlign=t.verticalAlign,n.horizonAlign=t.horizonAlign,n.sizeMode=t.sizeMode,n}update(t){const{sizeMode:n,verticalAlign:s,horizonAlign:r,fontFamily:o,fontSize:i,text:a,bold:c,italic:h,fontColor:d,fontBgColor:u,underline:p,strikethrough:f}=t;a!==void 0&&(this.text=a),o!==void 0&&(this.fontFamily=o),i!==void 0&&(this.fontSize=i),d!==void 0&&(this.fontColor=d),u!==void 0&&(this.fontBgColor=u),c!==void 0&&(this.bold=c),h!==void 0&&(this.italic=h),p!==void 0&&(this.underline=p),f!==void 0&&(this.strikethrough=f),s!==void 0&&(this.verticalAlign=s),r!==void 0&&(this.horizonAlign=r),n!==void 0&&(this.sizeMode=n)}clone(){const t=new se;return t.text=this.text,t.fontFamily=this.fontFamily,t.fontSize=this.fontSize,t.fontColor=this.fontColor,t.fontBgColor=this.fontBgColor,t.bold=this.bold,t.italic=this.italic,t.underline=this.underline,t.strikethrough=this.strikethrough,t.horizonAlign=this.horizonAlign,t.verticalAlign=this.verticalAlign,t.sizeMode=this.sizeMode,t}}class jt extends Pe{constructor(t=1){super();g(this,"type",R.Shape);g(this,"shapeCode",1);this.shapeCode=t}static from(t){const n=new jt;return n.shapeCode=t.shapeCode,n}update(t){const{shapeCode:n}=t;n!==void 0&&(this.shapeCode=n)}clone(){const t=new jt;return t.shapeCode=this.shapeCode,t}}class he extends Pe{constructor(){super(...arguments);g(this,"type",R.Line);g(this,"points",[]);g(this,"auto",!0)}static create(t,n=!0){const s=new he;return s.auto=n,s.points=t,s}static from(t){const n=new he;return n.points=t.points,n.auto=t.auto,n}clone(){const t=new he,n=[];for(const s of this.points)n.push(T.cloneIPoint(s));return t.points=n,t.auto=this.auto,t}update(t){const{points:n,auto:s}=t;n!==void 0&&(this.points=n),s!==void 0&&(this.auto=s)}}class Pn extends Pe{constructor(){super(...arguments);g(this,"type",R.Connect);g(this,"start",null);g(this,"end",null)}static from(t){const n=new Pn;return n.start=t.start,n.end=t.end,n}clone(){const t=new Pn;return t.start=this.start,t.end=this.end,t}update(t){const{start:n,end:s}=t;n!==void 0&&(this.start=n),s!==void 0&&(this.end=s)}}class Ie extends Pe{constructor(){super(...arguments);g(this,"type",R.Arrow);g(this,"lArrow",we.None);g(this,"rArrow",we.None)}static create(t){const n=new Ie;return n.update(t),n}static from(t){const n=new Ie;return n.lArrow=t.lArrow,n.rArrow=t.rArrow,n}clone(){const t=new Ie;return t.rArrow=this.rArrow,t.lArrow=this.lArrow,t}update(t){const{lArrow:n,rArrow:s}=t;n!==void 0&&(this.lArrow=n),s!==void 0&&(this.rArrow=s)}}var Mt=(l=>(l[l.Top=0]="Top",l[l.Right=1]="Right",l[l.Bottom=2]="Bottom",l[l.Left=3]="Left",l))(Mt||{});class bn extends Pe{constructor(){super(...arguments);g(this,"type",R.LineTextRect);g(this,"width",20);g(this,"height",20);g(this,"t",.5)}static from(t){const n=new bn;return n.width=t.width,n.height=t.height,n.t=t.t,n}update(t){const{t:n,height:s,width:r}=t;n!==void 0&&(this.t=n),s!==void 0&&(this.height=s),r!==void 0&&(this.width=r)}clone(){const t=new bn;return t.width=this.width,t.height=this.height,t.t=this.t,t}}var N=(l=>(l[l.HoverBounds=0]="HoverBounds",l[l.HoverLine=1]="HoverLine",l[l.SelectLine=2]="SelectLine",l[l.MultiSelectBound=3]="MultiSelectBound",l[l.TextSelection=4]="TextSelection",l[l.SelectGroup=5]="SelectGroup",l[l.SelectRect=6]="SelectRect",l[l.HighLightLine=7]="HighLightLine",l[l.AlignLine=8]="AlignLine",l[l.AlignStretchLine=9]="AlignStretchLine",l[l.SingleSelectBound=10]="SingleSelectBound",l[l.RotateLine=11]="RotateLine",l[l.HighlightRects=12]="HighlightRects",l[l.CreateRectBound=13]="CreateRectBound",l[l.ExpandShape=14]="ExpandShape",l[l.SelectLineEnd=15]="SelectLineEnd",l[l.HoverConnectPoint=16]="HoverConnectPoint",l[l.HoverConnectAnchorPoint=17]="HoverConnectAnchorPoint",l[l.HoverAnchorPoint=18]="HoverAnchorPoint",l[l.SelectPolyLineControlPoint=19]="SelectPolyLineControlPoint",l[l.SelectLineTextRect=20]="SelectLineTextRect",l[l.PlaceHolder=21]="PlaceHolder",l[l.SelectConnectAnchor=22]="SelectConnectAnchor",l[l.HoverConnectAnchor=23]="HoverConnectAnchor",l[l.PreviewGraphics=24]="PreviewGraphics",l[l.HoverContainer=25]="HoverContainer",l[l.CropBounds=26]="CropBounds",l[l.CropOriginImg=27]="CropOriginImg",l[l.StretchRect=28]="StretchRect",l[l.HoverSize=29]="HoverSize",l))(N||{});class Ct{constructor(){g(this,"prop")}update(e){this.prop=e}}const sn="#FFFFFF",Or="#000000",vn="#647ee5",re="#545DE7",Dr="#32a8f2",Zo="#3370FF",Jo=8,ti=18,ei=5,Hr=11,ni="#B7BEF5",si="#DADEFA";class ri extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverBounds)}draw(t,n){const{node:s,transform:r}=this.prop;t.save(),t.strokeStyle=vn,t.lineWidth=2/n,t.globalAlpha=1;const{x:o,y:i,width:a,height:c}=s.baseProps,{a:h,b:d,c:u,d:p,e:f,f:y}=r;t.transform(h,d,u,p,f,y),t.beginPath(),t.strokeRect(0,0,a,c),t.restore()}}class oi extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.SingleSelectBound)}draw(t,n){const{x:s,y:r,width:o,height:i,transform:a}=this.prop;t.save(),t.strokeStyle=re,t.lineWidth=1/n,t.globalAlpha=1;const{a:c,b:h,c:d,d:u,e:p,f}=a;t.transform(c,h,d,u,p,f),t.beginPath(),t.strokeRect(s,r,o,i),t.restore()}}class ii extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.MultiSelectBound)}draw(t,n){const{rect:s}=this.prop;t.save(),t.strokeStyle=re,t.lineWidth=1/n,t.globalAlpha=1;const{x:r,y:o,width:i,height:a}=s;t.beginPath(),t.strokeRect(r,o,i,a),t.restore()}}class ai extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HighlightRects)}draw(t,n){const{rects:s}=this.prop;for(const r of s){t.save(),t.strokeStyle=re,t.lineWidth=1/n,t.globalAlpha=1;const{x:o,y:i,width:a,height:c}=r;t.beginPath(),t.strokeRect(o,i,a,c),t.restore()}}}class ci extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.SelectGroup)}draw(t,n){const{rect:s}=this.prop;t.save(),t.beginPath(),t.strokeStyle=Dr,t.fillStyle=Dr,t.rect(s.x,s.y,s.width,s.height),t.lineWidth=1/n,t.stroke(),t.globalAlpha=.2,t.fill(),t.restore()}}class li extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.TextSelection)}draw(t){const{selectionList:n,node:s}=this.prop;if(n.length===0)return;t.save(),t.fillStyle=Zo,t.globalAlpha=.5;const{a:r,b:o,c:i,d:a,e:c,f:h}=s.transform;t.transform(r,o,i,a,c,h);for(const d of n)t.fillRect(d.x,d.y,d.width,d.height);t.restore()}}class hi{static computeStretchRects(e,t){const n=Jo/t,s=.5*n;return[new D(e.x-s,e.y-s,n,n),new D(e.x+e.width-s,e.y-s,n,n),new D(e.x+e.width-s,e.y+e.height-s,n,n),new D(e.x-s,e.y+e.height-s,n,n)]}}class di extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.StretchRect)}draw(t,n){const{rect:s,transform:r}=this.prop,o=hi.computeStretchRects(s,n);t.save();const{a:i,b:a,c,d:h,e:d,f:u}=r;t.transform(i,a,c,h,d,u),t.strokeStyle=re,t.fillStyle=sn,t.lineWidth=1/n,t.globalAlpha=1,t.beginPath();for(const p of o)t.roundRect(p.x,p.y,p.width,p.height,1/n),t.fill(),t.stroke();t.restore()}}class ui extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.CreateRectBound)}draw(t,n){const{rect:s,transform:r}=this.prop;t.save();const{a:o,b:i,c:a,d:c,e:h,f:d}=r;t.transform(o,i,a,c,h,d),t.strokeStyle=re,t.lineWidth=1/n,t.globalAlpha=1;const{width:u,height:p}=s;t.beginPath(),t.strokeRect(0,0,u,p),t.restore()}}class pi extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.ExpandShape)}draw(t,n){const{rect:s,transform:r}=this.prop,{width:o,height:i}=s,a=1.5/n,c=Z.generateMatrix().scale(a,a),h=Z.generateMatrix().translate(.5*o-.5*a*14,i-.5*a*8),d=r.crossProduct(h.crossProduct(c));t.save(),t.beginPath();const{a:u,b:p,c:f,d:y,e:w,f:b}=d;t.transform(u,p,f,y,w,b),t.fillStyle=re,t.roundRect(0,0,14,7.58333,2),t.fill(),t.beginPath(),t.fillStyle=sn,t.rect(1.75,2.91666,2.33333,2.33333),t.rect(5.83333,2.91666,2.33333,2.33333),t.rect(9.91667,2.91666,2.33333,2.33333),t.fill(),t.restore()}}class fi extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.AlignLine)}draw(t,n){const{lines:s}=this.prop;t.save(),t.beginPath(),t.strokeStyle=re,t.lineWidth=1/n,t.globalAlpha=1,t.setLineDash([4,2]);for(const r of s){const{start:o,end:i}=r;t.moveTo(o.x,o.y),t.lineTo(i.x,i.y)}t.stroke(),t.restore()}}class gi extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.AlignStretchLine)}draw(t,n){const s=10/n,{alignInfo:r}=this.prop,{width:o,height:i}=r;t.save(),t.beginPath(),t.strokeStyle=re,t.lineWidth=1/n,t.globalAlpha=1,o&&this.drawWidth(t,o,s),i&&this.drawHeight(t,i,s),t.restore()}drawWidth(t,n,s){const{lines:r}=n;for(const o of r){const{line:i,transform:a}=o,{start:c,end:h}=i;t.save();const{a:d,b:u,c:p,d:f,e:y,f:w}=a;t.transform(d,u,p,f,y,w);const b={x:c.x,y:c.y},x={x:c.x,y:c.y+2*s};t.moveTo(b.x,b.y),t.lineTo(x.x,x.y);const v={x:h.x,y:h.y},C={x:h.x,y:h.y+2*s};t.moveTo(v.x,v.y),t.lineTo(C.x,C.y),t.moveTo(c.x,c.y+s),t.lineTo(h.x,h.y+s),t.stroke(),t.restore()}}drawHeight(t,n,s){const{lines:r}=n;for(const o of r){const{line:i,transform:a}=o,{start:c,end:h}=i;t.save();const{a:d,b:u,c:p,d:f,e:y,f:w}=a;t.transform(d,u,p,f,y,w);const b={x:c.x,y:c.y},x={x:c.x+2*s,y:c.y};t.moveTo(b.x,b.y),t.lineTo(x.x,x.y);const v={x:h.x,y:h.y},C={x:h.x+2*s,y:h.y};t.moveTo(v.x,v.y),t.lineTo(C.x,C.y),t.moveTo(c.x+s,c.y),t.lineTo(h.x+s,h.y),t.stroke(),t.restore()}}}class Dl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.SingleSelectBound)}draw(t,n){const{start:s,end:r,transform:o}=this.prop,i=5/n;t.save();const{a,b:c,c:h,d,e:u,f:p}=o;t.transform(a,c,h,d,u,p),t.strokeStyle=re,t.fillStyle=sn,t.lineWidth=2/n,t.globalAlpha=1,t.beginPath(),t.arc(s.x,s.y,i,0,2*Math.PI),t.fill(),t.stroke(),t.beginPath(),t.arc(r.x,r.y,i,0,2*Math.PI),t.fill(),t.stroke(),t.restore()}}class Hl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverLine)}draw(t,n){const{node:s,transform:r}=this.prop;t.save();const{a:o,b:i,c:a,d:c,e:h,f:d}=r;t.transform(o,i,a,c,h,d),t.strokeStyle=vn,t.lineWidth=2/n,t.globalAlpha=1,t.beginPath(),s.drawer.draw(s,t),t.restore()}}class zl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.SelectLine)}draw(t,n){const{node:s}=this.prop;t.save();const{a:r,b:o,c:i,d:a,e:c,f:h}=s.globalTransform();t.transform(r,o,i,a,c,h),t.strokeStyle=re,t.lineWidth=2/n,t.globalAlpha=1,t.beginPath(),s.drawer.draw(s,t),t.restore()}}class Xl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverConnectPoint)}draw(t,n){const{point:s}=this.prop,r=4/n;t.save(),t.fillStyle=vn,t.strokeStyle=vn,t.lineWidth=2/n,t.globalAlpha=1,t.beginPath(),t.arc(s.x,s.y,r,0,2*Math.PI),t.fill(),t.restore()}}class Yl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverConnectAnchorPoint)}draw(t,n){const{node:s}=this.prop;if(!s.canBeConnected())return;const r=5/n,{width:o,height:i}=s.baseProps,{a,b:c,c:h,d,e:u,f:p}=s.transform,f=s.getConnectAnchor(),y=[];for(const w of f)y.push(new m(w.x*o,w.y*i));t.save(),t.transform(a,c,h,d,u,p),t.fillStyle=sn,t.strokeStyle=re;for(const w of y)t.beginPath(),t.arc(w.x,w.y,r,0,2*Math.PI),t.fill(),t.stroke();t.restore()}}class Fl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverConnectAnchorPoint)}draw(t,n){const{node:s,localPoint:r}=this.prop;if(!s.canBeConnected())return;const o=6/n,{a:i,b:a,c,d:h,e:d,f:u}=s.transform;t.save(),t.transform(i,a,c,h,d,u),t.fillStyle=vn,t.beginPath(),t.arc(r.x,r.y,o,0,2*Math.PI),t.fill(),t.stroke(),t.restore()}}const M=22;class Vl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.SelectPolyLineControlPoint)}draw(t,n){const{points:s,transform:r}=this.prop;t.save(),t.fillStyle=re,t.strokeStyle=sn,t.lineWidth=2/n,t.globalAlpha=1;const{a:o,b:i,c:a,d:c,e:h,f:d}=r;t.transform(o,i,a,c,h,d);for(let u=0;u<s.length-1;u++){const p=s[u],f=s[u+1];if(T.distance(p,f)<(M+6)/n)continue;const w=T.judgeHorizon(p,f),b=.5*(p.x+f.x),x=.5*(p.y+f.y);if(t.beginPath(),w){const v=new m(b-6/n,x);t.roundRect(v.x,v.y-2/n,12/n,4/n,2/n)}else{const v=new m(b,x-6/n);t.roundRect(v.x-2/n,v.y,4/n,12/n,2/n)}t.stroke(),t.fill()}t.restore()}}class Wl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.SelectLineTextRect)}draw(t,n){const{node:r}=this.prop,o=r.getTextContentRect();t.save(),t.strokeStyle=re,t.lineWidth=2/n,t.globalAlpha=1,t.beginPath(),t.strokeRect(o.x-2,o.y-2,o.width+2*2,o.height+2*2),t.restore()}}const yi="输入文本";class Gl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.PlaceHolder)}draw(t,n){const{node:s}=this.prop,r=s.shapeType!==_.PureText,o=s.renderText,i=o.paragraphs[0],a=i.lines[0],c=o.x+i.x+a.x,h=o.y+i.y+a.y,{fontSize:d,fontFamily:u,bold:p,italic:f}=o.textProps;t.save();const{a:y,b:w,c:b,d:x,e:v,f:C}=s.globalTransform();t.transform(y,w,b,x,v,C),t.textAlign="left",t.textBaseline="alphabetic",t.fillStyle="#000000",t.globalAlpha=.5,t.font=T.calcFont(d,u,p,f);const E=t.measureText(yi),k=E.fontBoundingBoxAscent,I=E.width,V=r?c-.5*I:c;t.fillText(yi,V,h+k),t.restore()}}class Ul extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.SelectConnectAnchor)}draw(t,n){const{node:s}=this.prop,r=ei/n,o=T.computeNodeConnectAnchor(s,n);t.save(),t.fillStyle=ni,t.globalAlpha=1;const{a:i,b:a,c,d:h,e:d,f:u}=s.globalTransform();t.transform(i,a,c,h,d,u);for(const p of o)t.beginPath(),t.arc(p.x,p.y,r,0,2*Math.PI),t.fill();t.restore()}}class _l extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverConnectAnchor)}draw(t,n){const{point:s}=this.prop,r=Hr/n;t.save(),t.strokeStyle=re,t.fillStyle=si,t.globalAlpha=1,t.lineWidth=2/n,t.beginPath(),t.arc(s.x,s.y,r,0,2*Math.PI),t.fill(),t.stroke(),t.restore()}}class Kl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.PreviewGraphics)}draw(t,n){const{previewNodes:s}=this.prop;for(const r of s)r.drawOnGLCtx(t)}}class jl extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverContainer)}draw(t,n){const{node:s}=this.prop;t.save(),t.strokeStyle=vn,t.lineWidth=2/n,t.globalAlpha=1;const{width:r,height:o}=s.baseProps,{a:i,b:a,c,d:h,e:d,f:u}=s.globalTransform();t.transform(i,a,c,h,d,u),t.beginPath(),t.strokeRect(0,0,r,o),t.restore()}}class ql extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.CropBounds)}draw(t,n){const{node:s,transform:r}=this.prop,o=12/n;t.save(),t.strokeStyle=Or,t.lineWidth=2/n,t.globalAlpha=1;const{width:i,height:a}=s.baseProps,{a:c,b:h,c:d,d:u,e:p,f}=r;t.transform(c,h,d,u,p,f),t.beginPath(),t.moveTo(0,o),t.lineTo(0,0),t.lineTo(o,0),t.moveTo(i-o,0),t.lineTo(i,0),t.lineTo(i,o),t.moveTo(i-o,a),t.lineTo(i,a),t.lineTo(i,a-o),t.moveTo(0,a-o),t.lineTo(0,a),t.lineTo(o,a),t.moveTo(.5*i-.5*o,0),t.lineTo(.5*i+.5*o,0),t.moveTo(.5*i-.5*o,a),t.lineTo(.5*i+.5*o,a),t.moveTo(0,.5*a-.5*o),t.lineTo(0,.5*a+.5*o),t.moveTo(i,.5*a-.5*o),t.lineTo(i,.5*a+.5*o),t.stroke(),t.beginPath(),t.setLineDash([2,2]),t.lineWidth=1/n,t.strokeRect(0,0,i,a),t.restore()}}class $l extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.CropOriginImg)}draw(t,n){const{imgBitmap:s,transform:r,x:o,y:i,width:a,height:c}=this.prop;t.save();const{a:h,b:d,c:u,d:p,e:f,f:y}=r;t.transform(h,d,u,p,f,y),t.globalAlpha=.4,t.drawImage(s,o,i,a,c),t.restore()}}class Ql extends Ct{constructor(){super(...arguments);g(this,"auxiliaryType",N.HoverSize)}draw(t,n){const{rect:s,transform:r}=this.prop,{width:o,height:i}=s,a=Math.round(o),c=Math.round(i),h=`${a}x${c}`,d=12/n,u="Noto Sans",p=T.measureTextByFont(t,h,d,"Noto Sans",!1,!1);t.save();const f=Z.generateMatrix().translate(o-p.width,i),{a:y,b:w,c:b,d:x,e:v,f:C}=r.crossProduct(f);t.transform(y,w,b,x,v,C),t.fillStyle=re,t.globalAlpha=1,t.fillRect(0,0,p.width,p.height),t.fillStyle=sn,t.font=T.calcFont(d,u),t.textAlign="left",t.textBaseline="top",t.fillText(h,0,2/n),t.restore()}}class zr{static create(e){const t=this.constructorMap[e];return t?new t:(console.error("缺少对应构造函数"),null)}}g(zr,"constructorMap",{[N.HoverBounds]:ri,[N.SingleSelectBound]:oi,[N.MultiSelectBound]:ii,[N.HighlightRects]:ai,[N.SelectGroup]:ci,[N.TextSelection]:li,[N.StretchRect]:di,[N.CreateRectBound]:ui,[N.ExpandShape]:pi,[N.AlignLine]:fi,[N.AlignStretchLine]:gi,[N.SelectLineEnd]:Dl,[N.HoverLine]:Hl,[N.SelectLine]:zl,[N.HoverConnectPoint]:Xl,[N.HoverConnectAnchorPoint]:Yl,[N.HoverAnchorPoint]:Fl,[N.SelectPolyLineControlPoint]:Vl,[N.SelectLineTextRect]:Wl,[N.PlaceHolder]:Gl,[N.SelectConnectAnchor]:Ul,[N.HoverConnectAnchor]:_l,[N.PreviewGraphics]:Kl,[N.HoverContainer]:jl,[N.CropBounds]:ql,[N.CropOriginImg]:$l,[N.HoverSize]:Ql});class mi{constructor(){g(this,"isWorking",!1);g(this,"idList",[]);g(this,"originX",0);g(this,"originY",0)}startWorking(e,t,n){this.idList=e,this.originX=t,this.originY=n,this.isWorking=!0}selectChange(e){if(!this.isWorking)return;e.size!==this.idList.length&&this.stopWork();const t=new Set(this.idList);for(const n of e)t.has(n.id)||this.stopWork(),t.delete(n.id);t.size!==0&&this.stopWork()}stopWork(){this.idList=[],this.isWorking=!1}}class rn{}const Zl=new Set([A.Shape,A.SVG,A.IMG,A.Group,A.Section]);class wi extends rn{enable(e){return e.length===1&&Zl.has(e[0].type)}handle(e,t){const n=e[0],s=n.globalTransform().clone(),{width:r,height:o}=n.baseProps;t.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:r,height:o,transform:s});const i=D.baseProps2Rect(n.baseProps);if(t.addOrUpdate(N.StretchRect,{transform:s,rect:new D(0,0,i.width,i.height)}),n.canBeConnected()&&t.addOrUpdate(N.SelectConnectAnchor,{node:n}),n instanceof qe&&n.shapeType!==_.PureText){const c=n.drawer.fullTextNodeHeight(n);n.baseProps.height<c&&t.addOrUpdate(N.ExpandShape,{transform:s,rect:i})}}}class xi extends rn{enable(e){return e.length>1}handle(e,t){const n=[],s=[];e.forEach(i=>{const a=i.getBounds();n.push(a),s.push(D.rectNode2Rect(a))});const r=T.getBounds(n),o=D.rectNode2Rect(r);t.addOrUpdate(N.MultiSelectBound,{rect:o}),t.addOrUpdate(N.HighlightRects,{rects:s}),t.addOrUpdate(N.StretchRect,{rect:new D(0,0,o.width,o.height),transform:Z.generateMatrix().translate(o.x,o.y)})}}var te=(l=>(l[l.Scale=0]="Scale",l[l.Focus=1]="Focus",l[l.FocusPropsChange=2]="FocusPropsChange",l[l.ToolChange=3]="ToolChange",l[l.QuickCreate=4]="QuickCreate",l[l.ClickImg=5]="ClickImg",l[l.ImgUrls=6]="ImgUrls",l[l.ContextMenu=7]="ContextMenu",l[l.ExitCrop=8]="ExitCrop",l))(te||{});class Pi{constructor(){g(this,"slotMap",new Map);g(this,"slotCallBack",new Map);g(this,"tickerRun",()=>{for(const[e,t]of this.slotMap){const n=this.slotCallBack.get(e);n&&n(t)}this.slotMap.clear(),requestAnimationFrame(this.tickerRun)})}start(){this.tickerRun()}addSlotState(e,t){this.slotMap.set(e,t)}registerSlotCallback(e,t){this.slotCallBack.set(e,t)}}class Jl extends rn{enable(e){return e.length===1&&e[0].type===A.Line}handle(e,t){const n=e[0],s=n.points,r=n.globalTransform();t.addOrUpdate(N.SelectLineEnd,{start:s[0],end:s[s.length-1],transform:r}),t.addOrUpdate(N.SelectLine,{node:n})}}class th extends rn{enable(e){if(e.length!==1)return!1;const t=e[0];return t.type!==A.Line?!1:!!t.isPolyLine()}handle(e,t){const n=e[0],s=n.points,r=n.globalTransform();t.addOrUpdate(N.SelectLineEnd,{start:s[0],end:s[s.length-1],transform:r}),t.addOrUpdate(N.SelectPolyLineControlPoint,{points:n.points,transform:r})}}class eh extends rn{enable(e,t){if(e.length!==1)return!1;const n=e[0];if(n.type!==A.Line)return!1;const s=t.inputManager.editTextInfo;if(!s)return!1;const r=n;return s.node.id===r.id}handle(e,t){const n=e[0];t.addOrUpdate(N.SelectLineTextRect,{node:n})}}class nh extends rn{enable(e){return e.length===1&&e[0].type===A.Group}handle(e,t){const n=e[0],s=n.nameGlobalTransform().clone(),{width:r,height:o}=n.baseProps;t.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:r,height:o,transform:s});const i=D.baseProps2Rect(n.baseProps);t.addOrUpdate(N.StretchRect,{transform:s,rect:new D(0,0,i.width,i.height)})}}const sh=new Set([A.SVG,A.IMG]);class rh extends rn{enable(e,t){if(e.length!==1)return!1;const n=e[0];return!(!sh.has(n.type)||!t.cropManager.duringCrop||!n.imgBitmap)}handle(e,t){const n=e[0],s=n.globalTransform().clone();t.addOrUpdate(N.CropBounds,{node:n,transform:s});const{cropType:r,cropInfo:o}=n.cropProps,{x:i,y:a,width:c,height:h}=n.baseProps;if(r===0||!o){t.addOrUpdate(N.SingleSelectBound,{x:0,y:0,width:c,height:h,transform:s});const d=new D(0,0,c,h);t.addOrUpdate(N.StretchRect,{transform:s,rect:d})}else{const d=n.getOriginImageRect();t.addOrUpdate(N.SingleSelectBound,{x:d.x,y:d.y,width:d.width,height:d.height,transform:s}),t.addOrUpdate(N.StretchRect,{transform:s,rect:d}),t.addOrUpdate(N.CropOriginImg,{x:d.x,y:d.y,width:d.width,height:d.height,transform:s,imgBitmap:n.imgBitmap})}}}class bi{constructor(e,t,n){g(this,"selectNodes",new Set);g(this,"optionHelper");g(this,"auxiliaryManager");g(this,"inputManager");g(this,"cropManager");g(this,"statusHandlers",[new nh,new eh,new th,new Jl,new rh,new wi,new xi]);this.auxiliaryManager=t,this.optionHelper=new mi,this.cropManager=n}register(e){this.inputManager=e}refreshSelectStatus(){this.auxiliaryManager.removeSelectGraphics();const e=[...this.selectNodes],t=this.selectStatusContext();for(const n of this.statusHandlers)if(n.enable(e,t)){n.handle(e,this.auxiliaryManager);return}}selectStatusContext(){return{inputManager:this.inputManager,cropManager:this.cropManager}}getSelectNodes(){return[...this.selectNodes]}getSelectBounds(){const e=[];for(const t of this.selectNodes)e.push(t.getRectNode());return T.getBounds(e,"selectBounds")}set(e){this.selectNodes=e,this.optionHelper.selectChange(e),this.auxiliaryManager.slotManager.addSlotState(te.Focus,[...e]),this.auxiliaryManager.slotManager.addSlotState(te.FocusPropsChange,!0),this.refreshSelectStatus()}startOptWorking(e,t,n){this.optionHelper.startWorking(e,t,n)}include(e){return this.selectNodes.has(e)}}class vi{constructor(e,t,n){g(this,"gmlRender");g(this,"selectManager");g(this,"graphicMap");g(this,"slotManager");this.gmlRender=e,this.slotManager=t,this.selectManager=new bi(e,this,n),this.graphicMap=new Map}start(){}addOrUpdate(e,t){const n=this.graphicMap.get(e);if(n){n.update(t);return}const s=zr.create(e);s&&(this.graphicMap.set(e,s),s.update(t))}remove(e){this.graphicMap.delete(e)}redraw(){const e=this.gmlRender.getViewPortBounds();this.gmlRender.glCtx.clearRect(e.minX,e.minY,e.maxX-e.minX,e.maxY-e.minY);const t=this.gmlRender.getScale(),n=[...this.graphicMap.values()];n.sort((s,r)=>s.auxiliaryType-r.auxiliaryType);for(const s of n)s.draw(this.gmlRender.glCtx,t)}removeHoverGraphics(){this.remove(N.HoverBounds),this.remove(N.HoverLine),this.remove(N.HoverConnectPoint),this.remove(N.HoverConnectAnchorPoint),this.remove(N.HoverAnchorPoint),this.remove(N.HoverConnectAnchor),this.remove(N.PreviewGraphics),this.remove(N.HoverContainer),this.remove(N.HoverSize)}removeSelectGraphics(){this.remove(N.SingleSelectBound),this.remove(N.MultiSelectBound),this.remove(N.HighlightRects),this.remove(N.TextSelection),this.remove(N.StretchRect),this.remove(N.ExpandShape),this.remove(N.SelectLineEnd),this.remove(N.SelectLine),this.remove(N.SelectPolyLineControlPoint),this.remove(N.SelectLineTextRect),this.remove(N.SelectConnectAnchor),this.remove(N.CropBounds),this.remove(N.CropOriginImg)}removeAlignGraphics(){this.remove(N.AlignLine),this.remove(N.AlignStretchLine)}}class oh{}class fs extends Pe{constructor(){super(...arguments);g(this,"type",R.Svg);g(this,"url","")}static from(t){const n=new fs;return n.url=t.url,n}clone(){const t=new fs;return t.url=this.url,t}update(t){const{url:n}=t;n!==void 0&&(this.url=n)}}var de=(l=>(l[l.None=0]="None",l[l.Rect=1]="Rect",l[l.RoundRect=2]="RoundRect",l[l.Circle=3]="Circle",l))(de||{});class Mn extends Pe{constructor(){super(...arguments);g(this,"type",R.Crop);g(this,"cropType",de.None);g(this,"cropInfo")}static from(t){const n=new Mn;return n.cropType=t.cropType||de.None,n.cropInfo=t.cropInfo,n}clone(){const t=new Mn;return t.cropType=this.cropType,this.cropInfo&&(t.cropInfo={imgX:this.cropInfo.imgX,imgY:this.cropInfo.imgY,imgWidth:this.cropInfo.imgWidth,imgHeight:this.cropInfo.imgHeight}),t}update(t){const{cropInfo:n,cropType:s}=t;n!==void 0&&(this.cropInfo=n),s!==void 0&&(this.cropType=s)}}class T{static makeSortGraphic(e){const t=[e];let n=e.parent;for(;n&&n.id!==Un;)t.unshift(n),n=n.parent;return{graphics:t}}static sortGraphics(e){const t=e.map(this.makeSortGraphic);return t.sort((n,s)=>{const r=Math.min(n.graphics.length,s.graphics.length);for(let o=0;o<r;o++){const i=n.graphics[o],a=s.graphics[o];if(i!==a)return i.zIndex>a.zIndex?1:-1}return n.graphics.length-s.graphics.length}),t.map(n=>n.graphics[n.graphics.length-1])}static setDashLine(e,t){e.dashType===Ee.Dash1?t.setLineDash([4,2]):e.dashType===Ee.Dash2&&t.setLineDash([2,2])}static convertPropsToCapInfo(e){const t={},n=e.get(R.Base);n&&(t.baseProps=n);const s=e.get(R.Color);s&&(t.colorProps=s);const r=e.get(R.Border);r&&(t.borderProps=r);const o=e.get(R.Text);o&&(t.textProps=o);const i=e.get(R.Shape);i&&(t.shapeProps=i);const a=e.get(R.Line);a&&(t.lineProps=a);const c=e.get(R.Connect);c&&(t.connectProps=c);const h=e.get(R.Arrow);h&&(t.arrowProps=h);const d=e.get(R.LineTextRect);d&&(t.lineTextRectProps=d);const u=e.get(R.Svg);u&&(t.svgProps=u);const p=e.get(R.Image);p&&(t.imageProps=p);const f=e.get(R.Crop);return f&&(t.cropProps=f),t}static convertCapInfoToProps(e){const t=[],{baseProps:n,borderProps:s,shapeProps:r,colorProps:o,textProps:i,lineProps:a,connectProps:c,arrowProps:h,lineTextRectProps:d,svgProps:u,imageProps:p,cropProps:f}=e;return s&&t.push(Ot.from(s)),o&&t.push(Jt.from(o)),i&&t.push(se.from(i)),n&&t.push(gt.from(n)),r&&t.push(jt.from(r)),a&&t.push(he.from(a)),c&&t.push(Pn.from(c)),h&&t.push(Ie.from(h)),d&&t.push(bn.from(d)),u&&t.push(fs.from(u)),p&&t.push(ps.from(p)),f&&t.push(Mn.from(f)),t}static centerPoint(e){const t=e.baseProps;return new m(t.x+.5*t.width,t.y+.5*t.height)}static topPoint(e){const t=e.baseProps;return new m(t.x+.5*t.width,t.y)}static rightPoint(e){const t=e.baseProps;return new m(t.x+t.width,t.y+.5*t.height)}static bottomPoint(e){const t=e.baseProps;return new m(t.x+.5*t.width,t.y+t.height)}static leftPoint(e){const t=e.baseProps;return new m(t.x,t.y+.5*t.height)}static topLeft(e){const t=e.baseProps;return new m(t.x,t.y)}static topRight(e){const t=e.baseProps;return new m(t.x+t.width,t.x+t.width)}static bottomLeft(e){const t=e.baseProps;return new m(t.x,t.y+t.height)}static bottomRight(e){const t=e.baseProps;return new m(t.x+t.width,t.y+t.height)}static middleInsertPoint(e,t,n){const s=new m(e.x,t.y);n.push(e,s,t)}static doubleMiddleInsertPoint(e,t,n){const s=new m(.5*(e.x+t.x),e.y),r=new m(.5*(e.x+t.x),t.y);n.push(e,s,r,t)}static rectContains(e,t){return e.x>t.x&&e.x<t.x+t.width&&e.y>t.y&&e.y<t.y+t.height}static rectContains2(e,t){return e.x>=t.minX&&e.x<=t.maxX&&e.y>=t.minY&&e.y<=t.maxY}static circleContains(e,t,n=2){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)<n*n}static overlapRect(e,t){return!(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}static containRect(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&e.maxX>=t.maxX&&e.maxY>=t.maxY}static distance(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))}static lineAngle(e,t){if(Math.abs(e.x-t.x)<.001)return t.y>e.y?Math.PI*.5:-Math.PI*.5;const n=(t.y-e.y)/(t.x-e.x);let s=Math.atan(n);return t.x<e.x&&(s+=Math.PI),s}static basicGetArrowPoint(e,t,n,s){const r=T.lineAngle(e,t),o=Z.generateMatrix().translate(e.x,e.y).rotate2(r),i=o.crossPoint(n),a=o.crossPoint(s);return{a:i,b:a}}static getLArrowPoint(e,t,n=5){const s=new m(Math.sqrt(3)*.5*n,.5*n),r=new m(Math.sqrt(3)*.5*n,-.5*n);return T.basicGetArrowPoint(e,t,s,r)}static getRArrowPoint(e,t,n=5){const s=T.distance(e,t),r=new m(s-Math.sqrt(3)*.5*n,.5*n),o=new m(s-Math.sqrt(3)*.5*n,-.5*n);return T.basicGetArrowPoint(e,t,r,o)}static getNodeBounds(e){const t=[];e.forEach(s=>t.push(s.getBounds()));const n=this.getBounds(t);return D.rectNode2Rect(n)}static cloneIRectNode(e){return{minX:e.minX,maxX:e.maxX,minY:e.minY,maxY:e.maxY}}static cloneIPoint(e){return{x:e.x,y:e.y}}static getBoundsByBaseProps(e){const{x:t,y:n,width:s,height:r,angle:o}=e,i=Z.generateMatrix().rotate(o),a=Z.generateMatrix().translate(t,n),c=[new m(0,0),new m(0,r),new m(s,0),new m(s,r)],h=a.crossProduct(i),d=c.map(u=>h.crossPoint(u));return this.getBoundsByPoints(d)}static getBoundsByBasePropsList(e){const t=[];for(const n of e){const{x:s,y:r,width:o,height:i,angle:a}=n,c=Z.generateMatrix().rotate(a),d=Z.generateMatrix().translate(s,r).crossProduct(c),p=[new m(0,0),new m(0,i),new m(o,0),new m(o,i)].map(f=>d.crossPoint(f));t.push(...p)}return this.getBoundsByPoints(t)}static getBounds(e,t="getBounds"){const n=[],s=[];for(const r of e)n.push(r.maxX,r.minX),s.push(r.maxY,r.minY);return{id:t,minX:Math.min(...n),maxX:Math.max(...n),minY:Math.min(...s),maxY:Math.max(...s)}}static getBoundsByPoints(e){const t=[],n=[];for(const s of e)t.push(s.x),n.push(s.y);return{id:"getBounds",minX:Math.min(...t),maxX:Math.max(...t),minY:Math.min(...n),maxY:Math.max(...n)}}static calcFont(e,t,n=!1,s=!1){let r=`${e.toString()}px ${t}`;return n?r=`700 ${r}`:r=`400 ${r}`,s&&(r=`italic ${r}`),r}static calcFontByTextProps(e){const{fontSize:t,fontFamily:n,bold:s,italic:r}=e;return this.calcFont(t,n,s,r)}static measureText(e,t){const n=e.measureText(t),s=n.width,r=n.fontBoundingBoxDescent+n.fontBoundingBoxAscent,o=n.fontBoundingBoxAscent;return{width:s,height:r,boxAscent:o}}static measureTextByFont(e,t,n,s,r,o){e.save(),e.font=this.calcFont(n,s,r,o);const i=e.measureText(t);e.restore();const a=i.width,c=i.fontBoundingBoxDescent+i.fontBoundingBoxAscent,h=i.fontBoundingBoxAscent;return{width:a,height:c,boxAscent:h}}static judgeHorizon(e,t,n=.01){return Math.abs(e.y-t.y)<n}static judgeVertical(e,t,n=.01){return Math.abs(e.x-t.x)<n}static computePolyLinePoints(e,t){const n=[],s=new m(t.x-e.x,t.y-e.y);if(Math.abs(s.x)<.001||Math.abs(s.y)<.001)n.push(e,t);else if(Math.abs(s.x)>Math.abs(s.y)){const r=new m(e.x+.5*s.x,e.y),o=new m(t.x-.5*s.x,t.y);n.push(e,r,o,t)}else{const r=new m(e.x,e.y+.5*s.y),o=new m(t.x,t.y-.5*s.y);n.push(e,r,o,t)}return n}static normalizeAngle(e){let t=e%360;return t<0&&(t+=360),t}static computeOriginNodeConnectEnd(e){const{x:t,y:n}=e,s=Math.atan2(n-.5,t-.5)/Math.PI*180,r=this.normalizeAngle(s);if(r<45||r>315)return Mt.Right;if(Math.abs(r-90)<45)return Mt.Bottom;if(Math.abs(r-180)<45)return Mt.Left;if(Math.abs(r-270)<45)return Mt.Top;throw new Error("没有正确的end type")}static computeNodeConnectEnd(e,t){const{x:n,y:s}=e,r=Math.atan2(s-.5,n-.5)/Math.PI*180+t,o=this.normalizeAngle(r);if(o<45||o>315)return Mt.Right;if(Math.abs(o-90)<45)return Mt.Bottom;if(Math.abs(o-180)<45)return Mt.Left;if(Math.abs(o-270)<45)return Mt.Top;throw new Error("没有正确的end type")}static inDistance(e,t,n){return Math.abs(e-t-.5*n)<.5*n}static dealWithEndPolyPointsInUp(e,t,n){if(e.length<4)return e;const s=e.length;if(n){const a=e[s-1],c=e[s-2],h=e[s-3];return T.distance(c,h)<3/t&&(T.judgeHorizon(a,c)?a.y=h.y:a.x=h.x,e.splice(s-3,2)),e}const r=e[0],o=e[1],i=e[2];return T.distance(i,o)<3/t&&(T.judgeHorizon(r,o)?r.y=i.y:r.x=i.x,e.splice(1,2)),e}static dealWithEndPolyPoints(e,t,n){if(e.length<4)return e;const s=e.length;if(n){const a=e[s-1],c=e[s-2],h=e[s-3];return T.distance(c,h)<3/t&&(T.judgeHorizon(a,c)?(c.y=h.y,a.y=h.y):(c.x=h.x,a.x=h.x)),e}const r=e[0],o=e[1],i=e[2];return T.distance(i,o)<3/t&&(T.judgeHorizon(r,o)?(o.y=i.y,r.y=i.y):(o.x=i.x,r.x=i.x)),e}static dealWithPolyPoints(e,t){if(e.length===0)return[];const n=[e[0]];for(let s=1;s<e.length-1;s++){const r=e[s],o=e[s+1];if(T.distance(r,o)<3/t){const i=e[s+2],a=e[s-1];T.judgeHorizon(a,r)?a.y=i.y:a.x=i.x,s=s+1}else n.push(r)}return n.push(e[e.length-1]),n}static computePointByT(e,t){const n=e.points;if(e.isPolyLine()){let s=0;for(let o=0;o<n.length-1;o++){const i=n[o],a=n[o+1],c=T.distance(i,a);s+=c}const r=t*s;s=0;for(let o=0;o<n.length-1;o++){const i=n[o],a=n[o+1],c=T.distance(i,a);if(r>s&&r<=s+c)if(T.judgeHorizon(i,a)){const d=a.x>i.x?1:-1;return new m(i.x+(r-s)*d,i.y)}else{const d=a.y>i.y?1:-1;return new m(i.x,i.y+(r-s)*d)}s+=c}}return T.centerPoint(e)}static computeNodeConnectAnchor(e,t){const{width:n,height:s}=e.baseProps,r=ti/t;return[{x:.5*n,y:-r},{x:n+r,y:.5*s},{x:.5*n,y:s+r},{x:-r,y:.5*s}]}static computeSelectNode(e,t){const n=new Set(e.getSelectNodes());let s=t.parent;for(;s;)n.has(s)&&n.delete(s),s=s.parent;return this.filterChildInSet(n,t),n.add(t),n}static filterChildInSet(e,t){const n=t.children;if(n.size!==0)for(const s of n)e.has(s)&&e.delete(s),this.filterChildInSet(e,s)}static computeSelectNodes(e){const t=new Set(e);for(const n of e)this.filterChildInSet(t,n);return[...t]}static filterToGroupNodes(e){const t=[];for(const n of e)if(n.type!==A.Section){if(n.type===A.Line){const s=n,{start:r,end:o}=s.connectProps;if(r&&o){const i=e.find(c=>c.id===r.objectId),a=e.find(c=>c.id===o.objectId);i&&a&&t.push(n);continue}if(r&&!o){e.find(a=>a.id===r.objectId)&&t.push(n);continue}if(o&&!r){e.find(a=>a.id===o.objectId)&&t.push(n);continue}t.push(n);continue}t.push(n)}return t}static detectRectBounds(e,t,n){const{x:s,y:r,width:o,height:i}=e;return T.circleContains(new m(s,r),t,n)?{type:G.TOP_LEFT}:T.circleContains(new m(s+o,r),t,n)?{type:G.TOP_RIGHT}:T.circleContains(new m(s+o,r+i),t,n)?{type:G.BOTTOM_RIGHT}:T.circleContains(new m(s,r+i),t,n)?{type:G.BOTTOM_LEFT}:T.rectContains(t,new D(s,r-.5*n,o,n))?{type:G.TOP}:T.rectContains(t,new D(s+o-.5*n,r,n,i))?{type:G.RIGHT}:T.rectContains(t,new D(s,r+i-.5*n,o,n))?{type:G.BOTTOM}:T.rectContains(t,new D(s-.5*n,r,n,i))?{type:G.LEFT}:null}}class Sn{constructor(e,t){g(this,"type",A.Shape);g(this,"id");g(this,"parent",null);g(this,"children",new Set);g(this,"zIndex",0);g(this,"graphicContext");g(this,"props",new Map);g(this,"transform",Z.generateMatrix());this.id=e,this.graphicContext=t}get baseProps(){return this.props.get(R.Base)}get globalBaseProps(){const e=this.baseProps.clone(),t=this.globalPos;return e.x=t.x,e.y=t.y,e}get pos(){const e=this.baseProps;return new m(e.x,e.y)}get globalPos(){return this.globalTransform().crossPoint(new m)}setParent(e){this.parent=e,e.children.add(this)}updateProps(e){for(const t of e){if(t.type===void 0)continue;const n=this.props.get(t.type);n&&n.update(t)}}getProp(e){const t=this.props.get(e);return t||null}updateTransformMatrix(){const e=this.baseProps,t=Z.generateMatrix().rotate(e.angle),n=Z.generateMatrix().translate(e.x,e.y);this.transform=n.crossProduct(t)}contains(e,t=1){const{width:n,height:s}=this.baseProps,r=this.toLocal(e);return T.rectContains(r,new D(0,0,n,s))}canBeConnected(){return!0}getConnectAnchor(){return[]}borderContains(e,t){return null}draw(){return this.drawOnGLCtx(this.graphicContext)}globalTransform(){const e=[this];let t=this.parent;for(;t;)e.push(t),t=t.parent;let n=Z.generateMatrix();for(const s of e.reverse())n=n.crossProduct(s.transform);return n}getRectNode(){const{width:e,height:t}=this.baseProps,n=this.getProp(R.Border),s=n?n.width:0,r=[new m(-s,-s),new m(e+s,-s),new m(e+s,t+s),new m(-s,t+s)],o=[];for(const a of r)o.push(this.toGlobal(a));const i=T.getBoundsByPoints(o);return i.id=this.id,i}getBounds(){const e=this.baseProps,t={id:this.id,minX:0,minY:0,maxX:e.width,maxY:e.height},n=[new m(t.minX,t.minY),new m(t.maxX,t.minY),new m(t.maxX,t.maxY),new m(t.minX,t.maxY)],s=[];for(const o of n)s.push(this.toGlobal(o));const r=T.getBoundsByPoints(s);return r.id=this.id,r}getStretchMinSize(){return{x:10,y:10}}overlapRect(e){return T.overlapRect(e,this.getBounds())}toLocal(e){return this.globalTransform().inverseMatrix().crossPoint(e)}toGlobal(e){return this.globalTransform().crossPoint(e)}modifyPosInEditing(e){return!1}resetFromEditing(){}serializeTo(){const e=T.convertPropsToCapInfo(this.props);return{type:this.type,zIndex:this.zIndex,id:this.id,parentId:"",capInfo:e,children:[]}}}class ih{fallbackDraw(e,t){const{width:n,height:s}=e.baseProps;t.save();const{a:r,b:o,c:i,d:a,e:c,f:h}=e.globalTransform();t.transform(r,o,i,a,c,h),t.beginPath();let d=!1;const u=n/3,p=s/3;for(let f=0;f<3;f++)for(let y=0;y<3;y++){const w=d?sn:Or,b=u*f,x=p*y;t.fillStyle=w,t.fillRect(b,x,u,p),d=!d}t.restore()}}class at{constructor(e=0,t=0){this.x=e,this.y=t}clone(){return new this.constructor(this.x,this.y)}add(e){return new this.constructor(this.x+e.x,this.y+e.y)}subtract(e){return new this.constructor(this.x-e.x,this.y-e.y)}multiply(e){return new this.constructor(this.x*e,this.y*e)}divide(e){return new this.constructor(this.x/e,this.y/e)}equals(e){return this.x===e.x&&this.y===e.y}precisionEquals(e,t){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t}lerp(e,t){const n=1-t;return new this.constructor(this.x*n+e.x*t,this.y*n+e.y*t)}distanceFrom(e){const t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}min(e){return new this.constructor(Math.min(this.x,e.x),Math.min(this.y,e.y))}max(e){return new this.constructor(Math.max(this.x,e.x),Math.max(this.y,e.y))}transform(e){return new this.constructor(e.a*this.x+e.c*this.y+e.e,e.b*this.x+e.d*this.y+e.f)}toString(){return`point(${this.x},${this.y})`}}class qt{constructor(e=0,t=0){this.x=e,this.y=t}static fromPoints(e,t){return new qt(t.x-e.x,t.y-e.y)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitude(){return this.x*this.x+this.y*this.y}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}determinant(e){return this.x*e.y-this.y*e.x}unit(){return this.divide(this.length())}add(e){return new this.constructor(this.x+e.x,this.y+e.y)}subtract(e){return new this.constructor(this.x-e.x,this.y-e.y)}multiply(e){return new this.constructor(this.x*e,this.y*e)}divide(e){return new this.constructor(this.x/e,this.y/e)}angleBetween(e){let t=this.dot(e)/(this.length()*e.length());t=Math.max(-1,Math.min(t,1));const n=Math.acos(t);return this.cross(e)<0?-n:n}perp(){return new this.constructor(-this.y,this.x)}perpendicular(e){return this.subtract(this.project(e))}project(e){const t=this.dot(e)/e.dot(e);return e.multiply(t)}transform(e){return new this.constructor(e.a*this.x+e.c*this.y,e.b*this.x+e.d*this.y)}equals(e){return this.x===e.x&&this.y===e.y}precisionEquals(e,t){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t}toString(){return`vector(${this.x},${this.y})`}}class oe{constructor(e=1,t=0,n=0,s=1,r=0,o=0){this.a=e,this.b=t,this.c=n,this.d=s,this.e=r,this.f=o}static translation(e,t){return new oe(1,0,0,1,e,t)}static scaling(e){return new oe(e,0,0,e,0,0)}static scalingAt(e,t){return new oe(e,0,0,e,t.x-t.x*e,t.y-t.y*e)}static nonUniformScaling(e,t){return new oe(e,0,0,t,0,0)}static nonUniformScalingAt(e,t,n){return new oe(e,0,0,t,n.x-n.x*e,n.y-n.y*t)}static rotation(e){const t=Math.cos(e),n=Math.sin(e);return new oe(t,n,-n,t,0,0)}static rotationAt(e,t){const n=Math.cos(e),s=Math.sin(e);return new oe(n,s,-s,n,t.x-t.x*n+t.y*s,t.y-t.y*n-t.x*s)}static rotationFromVector(e){const t=e.unit(),n=t.x,s=t.y;return new oe(n,s,-s,n,0,0)}static xFlip(){return new oe(-1,0,0,1,0,0)}static yFlip(){return new oe(1,0,0,-1,0,0)}static xSkew(e){const t=Math.tan(e);return new oe(1,0,t,1,0,0)}static ySkew(e){const t=Math.tan(e);return new oe(1,t,0,1,0,0)}multiply(e){return this.isIdentity()?e:e.isIdentity()?this:new this.constructor(this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.e+this.c*e.f+this.e,this.b*e.e+this.d*e.f+this.f)}inverse(){if(this.isIdentity())return this;const e=this.a*this.d-this.b*this.c;if(e===0)throw new Error("Matrix is not invertible");const t=1/e,n=this.f*this.c-this.e*this.d,s=this.e*this.b-this.f*this.a;return new this.constructor(this.d*t,-this.b*t,-this.c*t,this.a*t,n*t,s*t)}translate(e,t){return new this.constructor(this.a,this.b,this.c,this.d,this.a*e+this.c*t+this.e,this.b*e+this.d*t+this.f)}scale(e){return new this.constructor(this.a*e,this.b*e,this.c*e,this.d*e,this.e,this.f)}scaleAt(e,t){const n=t.x-e*t.x,s=t.y-e*t.y;return new this.constructor(this.a*e,this.b*e,this.c*e,this.d*e,this.a*n+this.c*s+this.e,this.b*n+this.d*s+this.f)}scaleNonUniform(e,t){return new this.constructor(this.a*e,this.b*e,this.c*t,this.d*t,this.e,this.f)}scaleNonUniformAt(e,t,n){const s=n.x-e*n.x,r=n.y-t*n.y;return new this.constructor(this.a*e,this.b*e,this.c*t,this.d*t,this.a*s+this.c*r+this.e,this.b*s+this.d*r+this.f)}rotate(e){const t=Math.cos(e),n=Math.sin(e);return new this.constructor(this.a*t+this.c*n,this.b*t+this.d*n,this.a*-n+this.c*t,this.b*-n+this.d*t,this.e,this.f)}rotateAt(e,t){const n=Math.cos(e),s=Math.sin(e),r=t.x,o=t.y,i=this.a*n+this.c*s,a=this.b*n+this.d*s,c=this.c*n-this.a*s,h=this.d*n-this.b*s;return new this.constructor(i,a,c,h,(this.a-i)*r+(this.c-c)*o+this.e,(this.b-a)*r+(this.d-h)*o+this.f)}rotateFromVector(e){const t=e.unit(),n=t.x,s=t.y;return new this.constructor(this.a*n+this.c*s,this.b*n+this.d*s,this.a*-s+this.c*n,this.b*-s+this.d*n,this.e,this.f)}flipX(){return new this.constructor(-this.a,-this.b,this.c,this.d,this.e,this.f)}flipY(){return new this.constructor(this.a,this.b,-this.c,-this.d,this.e,this.f)}skewX(e){const t=Math.tan(e);return new this.constructor(this.a,this.b,this.c+this.a*t,this.d+this.b*t,this.e,this.f)}skewY(e){const t=Math.tan(e);return new this.constructor(this.a+this.c*t,this.b+this.d*t,this.c,this.d,this.e,this.f)}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0}isInvertible(){return this.a*this.d-this.b*this.c!==0}getScale(){return{scaleX:Math.sqrt(this.a*this.a+this.c*this.c),scaleY:Math.sqrt(this.b*this.b+this.d*this.d)}}getDecomposition(){const e=(this.a+this.d)*.5,t=(this.a-this.d)*.5,n=(this.b+this.c)*.5,s=(this.b-this.c)*.5,r=Math.sqrt(e*e+s*s),o=Math.sqrt(t*t+n*n),i=r+o,a=r-o,c=Math.atan2(n,t),h=Math.atan2(s,e),d=(h-c)*.5,u=(h+c)*.5;return{translation:this.constructor.translation(this.e,this.f),rotation:this.constructor.rotation(u),scale:this.constructor.nonUniformScaling(i,a),rotation0:this.constructor.rotation(d)}}equals(e){return this.a===e.a&&this.b===e.b&&this.c===e.c&&this.d===e.d&&this.e===e.e&&this.f===e.f}precisionEquals(e,t){return Math.abs(this.a-e.a)<t&&Math.abs(this.b-e.b)<t&&Math.abs(this.c-e.c)<t&&Math.abs(this.d-e.d)<t&&Math.abs(this.e-e.e)<t&&Math.abs(this.f-e.f)<t}toString(){return`matrix(${this.a},${this.b},${this.c},${this.d},${this.e},${this.f})`}}oe.IDENTITY=new oe,oe.IDENTITY.isIdentity=()=>!0;function fe(l){return typeof l=="number"?l?l<0?-1:1:l===l?l:NaN:NaN}class Dt{constructor(...e){this.coefs=[];for(let t=e.length-1;t>=0;t--)this.coefs.push(e[t]);this._variable="t",this._s=0}static interpolate(e,t,n,s,r){if(e.constructor!==Array||t.constructor!==Array)throw new TypeError("xs and ys must be arrays");if(isNaN(n)||isNaN(s)||isNaN(r))throw new TypeError("n, offset, and x must be numbers");let o,i,a=0;const c=new Array(n),h=new Array(n);let d=0,u=Math.abs(r-e[s]);for(o=0;o<n;o++){const p=Math.abs(r-e[s+o]);p<u&&(d=o,u=p),c[o]=h[o]=t[s+o]}i=t[s+d],d--;for(let p=1;p<n;p++){for(o=0;o<n-p;o++){const f=e[s+o]-r,y=e[s+o+p]-r,w=c[o+1]-h[o];let b=f-y;if(b===0)throw new RangeError("Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)");b=w/b,h[o]=y*b,c[o]=f*b}a=2*(d+1)<n-p?c[d+1]:h[d--],i+=a}return{y:i,dy:a}}static newtonSecantBisection(e,t,n,s,r,o){let i,a=0,c,h=0,d,u,p,f,y;i=e;const w=Math.pow(10,-14),b=typeof r=="number"&&typeof o=="number";if(b){if(r>o)throw new RangeError("Min must be greater than max");if(f=t(r),y=t(o),fe(f)===fe(y))throw new RangeError("Y values of bounds must be of opposite sign")}const x=function(){return Math.abs(d)<=w*Math.abs(i)||h===i-d-i};for(let v=0;v<s;v++){if(c=n(i),c===0){if(a===0)throw new RangeError("df(x) is zero");c=a}if(a=c,p=t(i),d=p/c,u=i-d,x())break;if(b){if(fe(p)===fe(y))o=i,y=p;else if(fe(p)===fe(f))r=i,f=p;else{i=u;break}if(u<r||u>o){if(fe(f)===fe(y))break;const C=50,E=.25,k=y-f,I=o-r;if(k===0?d=i-(r+I*.5):Math.abs(k/Math.min(f,y))>C?d=i-(r+I*(.5+(Math.abs(f)<Math.abs(y)?-E:E))):d=i-(r-f/k*I),u=i-d,x())break}}h=i-u,i=u}return i}clone(){const e=new Dt;return e.coefs=this.coefs.slice(),e}eval(e){if(isNaN(e))throw new TypeError(`Parameter must be a number. Found '${e}'`);let t=0;for(let n=this.coefs.length-1;n>=0;n--)t=t*e+this.coefs[n];return t}add(e){const t=new Dt,n=this.getDegree(),s=e.getDegree(),r=Math.max(n,s);for(let o=0;o<=r;o++){const i=o<=n?this.coefs[o]:0,a=o<=s?e.coefs[o]:0;t.coefs[o]=i+a}return t}multiply(e){const t=new Dt;for(let n=0;n<=this.getDegree()+e.getDegree();n++)t.coefs.push(0);for(let n=0;n<=this.getDegree();n++)for(let s=0;s<=e.getDegree();s++)t.coefs[n+s]+=this.coefs[n]*e.coefs[s];return t}divideEqualsScalar(e){for(let t=0;t<this.coefs.length;t++)this.coefs[t]/=e}simplifyEquals(e=1e-12){for(let t=this.getDegree();t>=0&&Math.abs(this.coefs[t])<=e;t--)this.coefs.pop()}removeZerosEquals(e=1e-15){const t=this.coefs,n=10*e*Math.abs(t.reduce((s,r)=>Math.abs(r)>Math.abs(s)?r:s));for(let s=0;s<t.length-1;s++)Math.abs(t[s])<n&&(t[s]=0);return this}monicEquals(){const e=this.coefs;return e[e.length-1]!==1&&this.divideEqualsScalar(e[e.length-1]),this}toString(){const e=[],t=[];for(let s=this.coefs.length-1;s>=0;s--){let r=Math.round(this.coefs[s]*1e3)/1e3;if(r!==0){const o=r<0?" - ":" + ";r=Math.abs(r),s>0&&(r===1?r=this._variable:r+=this._variable),s>1&&(r+="^"+s),t.push(o),e.push(r)}}t[0]=t[0]===" + "?"":"-";let n="";for(let s=0;s<e.length;s++)n+=t[s]+e[s];return n}bisection(e,t,n=1e-6,s=15){let r=this.eval(e),o=this.eval(t),i;if(Math.abs(r)<=n)i=e;else if(Math.abs(o)<=n)i=t;else if(r*o<=0){const a=Math.log(t-e),c=Math.LN10*s,h=Math.ceil((a+c)/Math.LN2);for(let d=0;d<h;d++){i=.5*(e+t);const u=this.eval(i);if(Math.abs(u)<=n)break;u*r<0?(t=i,o=u):(e=i,r=u)}}return i}trapezoid(e,t,n){if(isNaN(e)||isNaN(t)||isNaN(n))throw new TypeError("Parameters must be numbers");const s=t-e;if(n===1){const r=this.eval(e),o=this.eval(t);this._s=.5*s*(r+o)}else{const r=1<<n-2,o=s/r;let i=e+.5*o,a=0;for(let c=0;c<r;c++)a+=this.eval(i),i+=o;this._s=.5*(this._s+s*a/r)}if(isNaN(this._s))throw new TypeError("this._s is NaN");return this._s}simpson(e,t){if(isNaN(e)||isNaN(t))throw new TypeError("Parameters must be numbers");const n=t-e;let s=.5*n*(this.eval(e)+this.eval(t)),r=s,o=4*s/3,i=o,a=s;const c=1e-7;let h=1;for(let d=2;d<=20;d++){const u=n/h;let p=e+.5*u,f=0;for(let y=1;y<=h;y++)f+=this.eval(p),p+=u;if(r=.5*(r+n*f/h),s=r,o=(4*s-a)/3,Math.abs(o-i)<c*Math.abs(i))break;i=o,a=s,h<<=1}return o}romberg(e,t){if(isNaN(e)||isNaN(t))throw new TypeError("Parameters must be numbers");const n=20,s=3,r=1e-6,o=new Array(n+1),i=new Array(n+1);let a={y:0,dy:0};i[0]=1;for(let c=1;c<=n&&(o[c-1]=this.trapezoid(e,t,c),!(c>=s&&(a=Dt.interpolate(i,o,s,c-s,0),Math.abs(a.dy)<=r*a.y)));c++)o[c]=o[c-1],i[c]=.25*i[c-1];return a.y}zeroErrorEstimate(e){const t=this,n=1e-15;if(typeof e>"u"){const o=t.bounds();e=Math.max(Math.abs(o.minX),Math.abs(o.maxX))}if(e<.001)return 2*Math.abs(t.eval(n));const s=t.coefs.length-1,r=t.coefs[s];return 10*n*t.coefs.reduce((o,i,a)=>{const c=i/r*Math.pow(e,a);return c>o?c:o},0)}boundsUpperRealFujiwara(){let e=this.coefs;const t=e.length-1,n=e[t];n!==1&&(e=this.coefs.map(c=>c/n));const s=e.map((c,h)=>h<t?Math.pow(Math.abs(h===0?c/2:c),1/(t-h)):c);let r;const o=function(c,h,d){return r(d)&&(c.max<h?(c.nearmax=c.max,c.max=h):c.nearmax<h&&(c.nearmax=h)),c};r=function(c){return c<t&&e[c]<0};const i=s.reduce(o,{max:0,nearmax:0});return r=function(c){return c<t&&(t%2===c%2?e[c]<0:e[c]>0)},{negX:-2*s.reduce(o,{max:0,nearmax:0}).max,posX:2*i.max}}boundsLowerRealFujiwara(){const e=new Dt;e.coefs=this.coefs.slice().reverse();const t=e.boundsUpperRealFujiwara();return t.negX=1/t.negX,t.posX=1/t.posX,t}bounds(){const e=this.boundsUpperRealFujiwara(),t={minX:e.negX,maxX:e.posX};return e.negX===0&&e.posX===0||(e.negX===0?t.minX=this.boundsLowerRealFujiwara().posX:e.posX===0&&(t.maxX=this.boundsLowerRealFujiwara().negX),t.minX>t.maxX&&(t.minX=t.maxX=0)),t}boundUpperAbsRouche(){const e=this.coefs,t=e.length-1;return 1+e.reduce((s,r,o)=>o!==t?(r=Math.abs(r),s<r?r:s):s,0)/Math.abs(e[t])}boundLowerAbsRouche(){const e=this.coefs,t=e.reduce((n,s,r)=>r!==0?(s=Math.abs(s),n<s?s:n):n,0);return Math.abs(e[0])/(Math.abs(e[0])+t)}boundsRealLaguerre(){const e=this.coefs,t=e.length-1,n=-e[t-1]/(t*e[t]),s=e[t-1]*e[t-1]-2*t/(t-1)*e[t]*e[t-2];let r=(t-1)/(t*e[t])*Math.sqrt(s);return r<0&&(r=-r),{minX:n-r,maxX:n+r}}countRootsDescartes(){const e=this.coefs,t=e.length-1,n=e.reduce((s,r,o)=>(s.prev_a!==0&&r!==0&&(s.prev_a<0==r>0&&s.pos++,o%2===0!=s.prev_a<0==(o%2===1!=r>0)&&s.neg++),s.prev_a=r,s),{pos:0,neg:0,prev_a:0});return{maxRealPos:n.pos,maxRealNeg:n.neg,minComplex:t-(n.pos+n.neg)}}getDegree(){return this.coefs.length-1}getDerivative(){const e=new Dt;for(let t=1;t<this.coefs.length;t++)e.coefs.push(t*this.coefs[t]);return e}getRoots(){let e;switch(this.simplifyEquals(),this.getDegree()){case 0:e=[];break;case 1:e=this.getLinearRoot();break;case 2:e=this.getQuadraticRoots();break;case 3:e=this.getCubicRoots();break;case 4:e=this.getQuarticRoots();break;default:e=[]}return e}getRootsInInterval(e,t){const n=[];function s(r){typeof r=="number"&&n.push(r)}if(this.getDegree()===0)throw new RangeError("Unexpected empty polynomial");if(this.getDegree()===1)s(this.bisection(e,t));else{const o=this.getDerivative().getRootsInInterval(e,t);if(o.length>0){s(this.bisection(e,o[0]));for(let i=0;i<=o.length-2;i++)s(this.bisection(o[i],o[i+1]));s(this.bisection(o[o.length-1],t))}else s(this.bisection(e,t))}return n}getLinearRoot(){const e=[],t=this.coefs[1];return t!==0&&e.push(-this.coefs[0]/t),e}getQuadraticRoots(){const e=[];if(this.getDegree()===2){const t=this.coefs[2],n=this.coefs[1]/t,s=this.coefs[0]/t,r=n*n-4*s;if(r>0){const o=Math.sqrt(r);e.push(.5*(-n+o)),e.push(.5*(-n-o))}else r===0&&e.push(.5*-n)}return e}getCubicRoots(){const e=[];if(this.getDegree()===3){const t=this.coefs[3],n=this.coefs[2]/t,s=this.coefs[1]/t,r=this.coefs[0]/t,o=(3*s-n*n)/3,i=(2*n*n*n-9*s*n+27*r)/27,a=n/3;let c=i*i/4+o*o*o/27;const h=i/2,d=this.zeroErrorEstimate();if(Math.abs(c)<=d&&(c=0),c>0){const u=Math.sqrt(c);let p,f=-h+u;f>=0?p=Math.pow(f,1/3):p=-Math.pow(-f,1/3),f=-h-u,f>=0?p+=Math.pow(f,1/3):p-=Math.pow(-f,1/3),e.push(p-a)}else if(c<0){const u=Math.sqrt(-o/3),p=Math.atan2(Math.sqrt(-c),-h)/3,f=Math.cos(p),y=Math.sin(p),w=Math.sqrt(3);e.push(2*u*f-a),e.push(-u*(f+w*y)-a),e.push(-u*(f-w*y)-a)}else{let u;h>=0?u=-Math.pow(h,1/3):u=Math.pow(-h,1/3),e.push(2*u-a),e.push(-u-a)}}return e}getQuarticRoots(){let e=[];const t=this.getDegree();if(t===4){const n=new Dt;n.coefs=this.coefs.slice(),n.divideEqualsScalar(n.coefs[t]);const s=1e-15;Math.abs(n.coefs[0])<10*s*Math.abs(n.coefs[3])&&(n.coefs[0]=0);const r=n.getDerivative(),o=r.getRoots().sort((x,v)=>x-v),i=[],a=o.length-1,c=this.bounds(),h=Math.max(Math.abs(c.minX),Math.abs(c.maxX)),d=this.zeroErrorEstimate(h);for(let x=0;x<=a;x++)i.push(n.eval(o[x]));for(let x=0;x<=a;x++)Math.abs(i[x])<d&&(i[x]=0);let u=0;const p=Math.max(.1*(c.maxX-c.minX)/t,s),f=[],y=[];if(a>-1){for(i[0]!==0?fe(i[0])!==fe(n.eval(o[0]-p)-i[0])&&(f.push(o[0]-p),y.push([c.minX,o[0]])):(e.push(o[0],o[0]),u++);u<a;u++)i[u+1]===0?(e.push(o[u+1],o[u+1]),u++):fe(i[u])!==fe(i[u+1])&&(f.push((o[u]+o[u+1])/2),y.push([o[u],o[u+1]]));i[a]!==0&&fe(i[a])!==fe(n.eval(o[a]+p)-i[a])&&(f.push(o[a]+p),y.push([o[a],c.maxX]))}const w=function(x){return n.eval(x)},b=function(x){return r.eval(x)};if(f.length>0)for(u=0;u<f.length;u++)f[u]=Dt.newtonSecantBisection(f[u],w,b,32,y[u][0],y[u][1]);e=e.concat(f)}return e}}class ie{constructor(e,t){this.type=e,this.text=t}typeis(e){return this.type===e}}ie.UNDEFINED=0,ie.COMMAND=1,ie.NUMBER=2,ie.EOD=3;class ah{constructor(e){e==null&&(e=""),this.setPathData(e)}setPathData(e){if(typeof e!="string")throw new TypeError("The first parameter must be a string");this._pathData=e}getNextToken(){let e=null,t=this._pathData;for(;e===null;)if(t===null||t==="")e=new ie(ie.EOD,"");else if(t.match(/^([ \t\r\n,]+)/))t=t.substr(RegExp.$1.length);else if(t.match(/^([AaCcHhLlMmQqSsTtVvZz])/))e=new ie(ie.COMMAND,RegExp.$1),t=t.substr(RegExp.$1.length);else if(t.match(/^(([-+]?\d+(\.\d*)?|[-+]?\.\d+)([eE][-+]?\d+)?)/))e=new ie(ie.NUMBER,RegExp.$1),t=t.substr(RegExp.$1.length);else throw new SyntaxError(`Unrecognized path data: ${t}`);return this._pathData=t,e}}const Xr="BOP";let Yr=class Br{constructor(){this._lexer=new ah,this._handler=null}parseData(e){if(typeof e!="string")throw new TypeError(`The first parameter must be a string: ${e}`);this._handler!==null&&typeof this._handler.beginParse=="function"&&this._handler.beginParse();const t=this._lexer;t.setPathData(e);let n=Xr,s=null,r=t.getNextToken();for(;r.typeis(ie.EOD)===!1;){let o;const i=[];switch(r.type){case ie.COMMAND:if(n===Xr&&r.text!=="M"&&r.text!=="m")throw new SyntaxError(`New paths must begin with a moveto command. Found '${r.text}'`);n=r.text,o=Br.PARAMCOUNT[r.text.toUpperCase()],r=t.getNextToken();break;case ie.NUMBER:if(n===Xr)throw new SyntaxError(`New paths must begin with a moveto command. Found '${r.text}'`);o=Br.PARAMCOUNT[n.toUpperCase()];break;default:throw new SyntaxError(`Unrecognized command type: ${r.type}`)}for(let a=0;a<o;a++){switch(r.type){case ie.COMMAND:throw new SyntaxError(`Parameter must be a number. Found '${r.text}'`);case ie.NUMBER:i[a]=parseFloat(r.text);break;case ie.EOD:throw new SyntaxError("Unexpected end of string");default:throw new SyntaxError(`Unrecognized parameter type. Found type '${r.type}'`)}r=t.getNextToken()}if(this._handler!==null){const a=this._handler,c=Br.METHODNAME[n];(n==="a"||n==="A")&&(i[3]=i[3]!==0,i[4]=i[4]!==0),a!==null&&typeof a[c]=="function"&&a[c](...i)}switch(n){case"M":n="L";break;case"m":n="l";break;case"Z":case"z":n="BOP";break}if(r===s)throw new SyntaxError(`Parser stalled on '${r.text}'`);s=r}this._handler!==null&&typeof this._handler.endParse=="function"&&this._handler.endParse()}setHandler(e){this._handler=e}};Yr.PARAMCOUNT={A:7,C:6,H:1,L:2,M:2,Q:4,S:4,T:2,V:1,Z:0},Yr.METHODNAME={A:"arcAbs",a:"arcRel",C:"curvetoCubicAbs",c:"curvetoCubicRel",H:"linetoHorizontalAbs",h:"linetoHorizontalRel",L:"linetoAbs",l:"linetoRel",M:"movetoAbs",m:"movetoRel",Q:"curvetoQuadraticAbs",q:"curvetoQuadraticRel",S:"curvetoCubicSmoothAbs",s:"curvetoCubicSmoothRel",T:"curvetoQuadraticSmoothAbs",t:"curvetoQuadraticSmoothRel",V:"linetoVerticalAbs",v:"linetoVerticalRel",Z:"closePath",z:"closePath"};const ch=2*Math.PI;function Mi(l,e,t,n,s,r,o){s=s*Math.PI/180;const i=Math.cos(s),a=Math.sin(s),c=1e-6,h=l.subtract(e).multiply(.5),d=h.x*i+h.y*a,u=h.x*-a+h.y*i;t=Math.abs(t),n=Math.abs(n);const p=d*d,f=u*u,y=p/(t*t)+f/(n*n);if(y>1){const ht=Math.sqrt(y);t*=ht,n*=ht}const w=t*t,b=n*n,x=w*f,v=b*p;let C=(w*b-x-v)/(x+v);Math.abs(C)<c&&(C=0);let E=Math.sqrt(C);r===o&&(E=-E);const k=l.add(e).multiply(.5),I=E*t*u/n,V=E*-n*d/t,U=(d-I)/t,J=(d+I)/t,j=(u-V)/n,st=(u+V)/n,tt=new qt(1,0).angleBetween(new qt(U,j));let it=new qt(U,j).angleBetween(new qt(-J,-st));return o===!1&&(it-=ch),[I*i-V*a+k.x,I*a+V*i+k.y,t,n,tt,tt+it]}class lh{constructor(e){this.shapeCreator=e,this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}beginParse(){this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}addShape(e){this.shapes.push(e)}arcAbs(e,t,n,s,r,o,i){if(e===0||t===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,o,i));else{const a=Mi(new at(this.lastX,this.lastY),new at(o,i),e,t,n,s,r);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="A",this.lastX=o,this.lastY=i}arcRel(e,t,n,s,r,o,i){if(e===0||t===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+o,this.lastY+i));else{const a=Mi(new at(this.lastX,this.lastY),new at(this.lastX+o,this.lastY+i),e,t,n,s,r);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="a",this.lastX+=o,this.lastY+=i}curvetoCubicAbs(e,t,n,s,r,o){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,e,t,n,s,r,o)),this.lastX=r,this.lastY=o,this.lastCommand="C"}curvetoCubicRel(e,t,n,s,r,o){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,this.lastX+e,this.lastY+t,this.lastX+n,this.lastY+s,this.lastX+r,this.lastY+o)),this.lastX+=r,this.lastY+=o,this.lastCommand="c"}linetoHorizontalAbs(e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,e,this.lastY)),this.lastX=e,this.lastCommand="H"}linetoHorizontalRel(e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+e,this.lastY)),this.lastX+=e,this.lastCommand="h"}linetoAbs(e,t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,e,t)),this.lastX=e,this.lastY=t,this.lastCommand="L"}linetoRel(e,t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+e,this.lastY+t)),this.lastX+=e,this.lastY+=t,this.lastCommand="l"}movetoAbs(e,t){this.firstX=e,this.firstY=t,this.lastX=e,this.lastY=t,this.lastCommand="M"}movetoRel(e,t){this.firstX+=e,this.firstY+=t,this.lastX+=e,this.lastY+=t,this.lastCommand="m"}curvetoQuadraticAbs(e,t,n,s){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,e,t,n,s)),this.lastX=n,this.lastY=s,this.lastCommand="Q"}curvetoQuadraticRel(e,t,n,s){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,this.lastX+e,this.lastY+t,this.lastX+n,this.lastY+s)),this.lastX+=n,this.lastY+=s,this.lastCommand="q"}curvetoCubicSmoothAbs(e,t,n,s){let r,o;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];r=2*this.lastX-i.x,o=2*this.lastY-i.y}else r=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,r,o,e,t,n,s)),this.lastX=n,this.lastY=s,this.lastCommand="S"}curvetoCubicSmoothRel(e,t,n,s){let r,o;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];r=2*this.lastX-i.x,o=2*this.lastY-i.y}else r=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,r,o,this.lastX+e,this.lastY+t,this.lastX+n,this.lastY+s)),this.lastX+=n,this.lastY+=s,this.lastCommand="s"}curvetoQuadraticSmoothAbs(e,t){let n,s;if(this.lastCommand.match(/^[QqTt]$/)){const r=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-r.x,s=2*this.lastY-r.y}else n=this.lastX,s=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,s,e,t)),this.lastX=e,this.lastY=t,this.lastCommand="T"}curvetoQuadraticSmoothRel(e,t){let n,s;if(this.lastCommand.match(/^[QqTt]$/)){const r=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-r.x,s=2*this.lastY-r.y}else n=this.lastX,s=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,s,this.lastX+e,this.lastY+t)),this.lastX+=e,this.lastY+=t,this.lastCommand="t"}linetoVerticalAbs(e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,e)),this.lastY=e,this.lastCommand="V"}linetoVerticalRel(e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,this.lastY+e)),this.lastY+=e,this.lastCommand="v"}closePath(){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.firstX,this.firstY)),this.lastX=this.firstX,this.lastY=this.firstY,this.lastCommand="z"}}const Tn=Math.PI*.5,Si=new Yr;function _e(l,e){const t=[];for(const[n,s]of l){let r=null;if(s==="Point2D")r=Fr(n,e);else if(s==="Number")r=Ti(n,e);else if(s==="Array<Point2D>"||s==="Point2D[]"){const o=[];for(;e.length>0;)o.push(Fr(n,e));o.length>0&&(r=o)}else if(s==="Optional<Number>"||s==="Number?")r=Ti(n,e),r===null&&(r=void 0);else throw new TypeError(`Unrecognized value type: ${s}`);if(r!==null)t.push(r);else throw new TypeError(`Unable to extract value for ${n}`)}return t}function Ti(l,e){let t=null;if(e.length>0){const n=e[0],s=typeof n;if(s==="number")return e.shift();if(s==="object"){for(const r of l)if(r in n&&typeof n[r]=="number"){t=n[r];break}}}return t}function Fr(l,e){let t=null;if(e.length>0){const n=e[0],s=typeof n;if(s==="number"){if(e.length>1){const r=e.shift(),o=e.shift();t=new at(r,o)}}else if(Array.isArray(n)&&n.length>1)if(n.length===2){const[r,o]=e.shift();t=new at(r,o)}else throw new TypeError(`Unhandled array of length ${n.length}`);else if(s==="object"){if("x"in n&&"y"in n)t=new at(n.x,n.y),e.shift();else for(const r of l)if(Array.isArray(r)){if(r.every(o=>o in n)){t=new at(n[r[0]],n[r[1]]);break}}else if(r in n){t=Fr([],[n[r]]);break}}}return t}class K{constructor(e,t){this.name=e,this.args=t}static arc(...e){const n=_e([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"],[["startRadians"],"Number"],[["endRadians"],"Number"]],e);return new K(K.ARC,n)}static quadraticBezier(...e){const n=_e([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"]],e);return new K(K.QUADRATIC_BEZIER,n)}static cubicBezier(...e){const n=_e([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"],[["p4",["p4x","p4y"]],"Point2D"]],e);return new K(K.CUBIC_BEZIER,n)}static circle(...e){const n=_e([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radius","r"],"Number"]],e);return new K(K.CIRCLE,n)}static ellipse(...e){const n=_e([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"]],e);return new K(K.ELLIPSE,n)}static line(...e){const n=_e([[["p1",["p1x","p1y"],["x1","y1"]],"Point2D"],[["p2",["p2x","p2y"],["x2","y2"]],"Point2D"]],e);return new K(K.LINE,n)}static path(...e){return Si.parseData(e[0]),new K(K.PATH,Ci.shapes)}static polygon(...e){const n=_e([[[],"Array<Point2D>"]],e.length===1&&Array.isArray(e[0])?e[0]:e);return new K(K.POLYGON,n)}static polyline(...e){const n=_e([[[],"Array<Point2D>"]],e.length===1&&Array.isArray(e[0])?e[0]:e);return new K(K.POLYLINE,n)}static rectangle(...e){const n=_e([[["topLeft",["x","y"],["left","top"]],"Point2D"],[["size",["width","height"],["w","h"]],"Point2D"],[["radiusX","rx"],"Optional<Number>"],[["radiusY","ry"],"Optional<Number>"]],e),s=n[0],r=n[1];n[1]=new at(s.x+r.x,s.y+r.y);const o=new K(K.RECTANGLE,n);let i=o.args.pop(),a=o.args.pop();if(a=a===void 0?0:a,i=i===void 0?0:i,a===0&&i===0)return o;const{x:c,y:h}=o.args[0],{x:d,y:u}=o.args[1],p=d-c,f=u-h;a===0&&(a=i),i===0&&(i=a),a>p*.5&&(a=p*.5),i>f*.5&&(i=f*.5);const y=c,w=h,b=c+a,x=h+i,v=d-a,C=u-i,E=d,k=u,I=[K.arc(b,x,a,i,2*Tn,3*Tn),K.line(b,w,v,w),K.arc(v,x,a,i,3*Tn,4*Tn),K.line(E,x,E,C),K.arc(v,C,a,i,0,Tn),K.line(v,k,b,k),K.arc(b,C,a,i,Tn,2*Tn),K.line(y,C,y,x)];return new K(K.PATH,I)}}K.ARC="Arc",K.QUADRATIC_BEZIER="Bezier2",K.CUBIC_BEZIER="Bezier3",K.CIRCLE="Circle",K.ELLIPSE="Ellipse",K.LINE="Line",K.PATH="Path",K.POLYGON="Polygon",K.POLYLINE="Polyline",K.RECTANGLE="Rectangle";const Ci=new lh(K);Si.setHandler(Ci);const gs=2*Math.PI,hh=new qt(1,0);function Li(l){return l==null}function dh(l,e){const t=l[0]*e[1]-e[0]*l[1],n=l[0]*e[2]-e[0]*l[2],s=l[0]*e[3]-e[0]*l[3],r=l[0]*e[4]-e[0]*l[4],o=l[0]*e[5]-e[0]*l[5],i=l[1]*e[2]-e[1]*l[2],a=l[1]*e[4]-e[1]*l[4],c=l[1]*e[5]-e[1]*l[5],h=l[2]*e[3]-e[2]*l[3],d=l[3]*e[4]-e[3]*l[4],u=l[3]*e[5]-e[3]*l[5],p=c+d,f=a-h;return new Dt(t*i-n*n,t*f+s*i-2*n*r,t*p+s*f-r*r-2*n*o,t*u+s*p-2*r*o,s*u-o*o)}function uh(l){const e=l%gs;return e<0?e+gs:e}function ph(l,e,t,n,s,r){if(l.points.length===0)return l;const o=new O("No Intersection");r<s&&([s,r]=[r,s]),(s<0||r<0)&&(s+=gs,r+=gs);for(const i of l.points){let a=uh(hh.angleBetween(qt.fromPoints(e,i)));a<s&&(a+=gs),s<=a&&a<=r&&o.appendPoint(i)}return o.points.length>0&&(o.status="Intersection"),o}function Ke(l){const e=l.slice();return e.push(l[0]),e}class O{constructor(e){this.init(e)}init(e){this.status=e,this.points=[]}static intersect(e,t){let n;if(!Li(e)&&!Li(t))if(e.name==="Path")n=O.intersectPathShape(e,t);else if(t.name==="Path")n=O.intersectPathShape(t,e);else if(e.name==="Arc")n=O.intersectArcShape(e,t);else if(t.name==="Arc")n=O.intersectArcShape(t,e);else{let s,r;if(e.name<t.name?(s="intersect"+e.name+t.name,r=e.args.concat(t.args)):(s="intersect"+t.name+e.name,r=t.args.concat(e.args)),!(s in O))throw new TypeError("Intersection not available: "+s);n=O[s].apply(null,r)}else n=new O("No Intersection");return n}static intersectPathShape(e,t){const n=new O("No Intersection");for(const s of e.args){const r=O.intersect(s,t);n.appendPoints(r.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectArcShape(e,t){const[n,s,r,o,i]=e.args,a=new K(K.ELLIPSE,[n,s,r]),c=O.intersect(a,t);return ph(c,n,s,r,o,i)}static intersectBezier2Bezier2(e,t,n,s,r,o){let i,a;const c=new O("No Intersection");i=t.multiply(-2);const h=e.add(i.add(n));i=e.multiply(-2),a=t.multiply(2);const d=i.add(a),u=new at(e.x,e.y);i=r.multiply(-2);const p=s.add(i.add(o));i=s.multiply(-2),a=r.multiply(2);const f=i.add(a),y=new at(s.x,s.y);i=h.x*d.y-d.x*h.y,a=p.x*d.y-d.x*p.y;const w=f.x*d.y-d.x*f.y,b=d.x*(u.y-y.y)+d.y*(-u.x+y.x),x=p.x*h.y-h.x*p.y,v=f.x*h.y-h.x*f.y,C=h.x*(u.y-y.y)+h.y*(-u.x+y.x),k=new Dt(-x*x,-2*x*v,i*a-v*v-2*x*C,i*w-2*v*C,i*b-C*C).getRoots();for(const I of k)if(0<=I&&I<=1){const V=new Dt(h.x,d.x,u.x-y.x-I*f.x-I*I*p.x);V.simplifyEquals();const U=V.getRoots(),J=new Dt(h.y,d.y,u.y-y.y-I*f.y-I*I*p.y);J.simplifyEquals();const j=J.getRoots();if(U.length>0&&j.length>0){t:for(const tt of U)if(0<=tt&&tt<=1){for(let it=0;it<j.length;it++)if(Math.abs(tt-j[it])<1e-4){c.points.push(p.multiply(I*I).add(f.multiply(I).add(y)));break t}}}}return c.points.length>0&&(c.status="Intersection"),c}static intersectBezier2Bezier3(e,t,n,s,r,o,i){let a,c,h,d;const u=new O("No Intersection");a=t.multiply(-2);const p=e.add(a.add(n));a=e.multiply(-2),c=t.multiply(2);const f=a.add(c),y=new at(e.x,e.y);a=s.multiply(-1),c=r.multiply(3),h=o.multiply(-3),d=a.add(c.add(h.add(i)));const w=new at(d.x,d.y);a=s.multiply(3),c=r.multiply(-6),h=o.multiply(3),d=a.add(c.add(h));const b=new at(d.x,d.y);a=s.multiply(-3),c=r.multiply(3),h=a.add(c);const x=new at(h.x,h.y),v=new at(s.x,s.y),C=y.x*y.x,E=y.y*y.y,k=f.x*f.x,I=f.y*f.y,V=p.x*p.x,U=p.y*p.y,J=v.x*v.x,j=v.y*v.y,st=x.x*x.x,tt=x.y*x.y,it=b.x*b.x,ht=b.y*b.y,xt=w.x*w.x,mt=w.y*w.y,ot=new Dt(-2*p.x*p.y*w.x*w.y+V*mt+U*xt,-2*p.x*p.y*b.x*w.y-2*p.x*p.y*b.y*w.x+2*U*b.x*w.x+2*V*b.y*w.y,-2*p.x*x.x*p.y*w.y-2*p.x*p.y*x.y*w.x-2*p.x*p.y*b.x*b.y+2*x.x*U*w.x+U*it+V*(2*x.y*w.y+ht),2*y.x*p.x*p.y*w.y+2*y.y*p.x*p.y*w.x+f.x*f.y*p.x*w.y+f.x*f.y*p.y*w.x-2*v.x*p.x*p.y*w.y-2*p.x*v.y*p.y*w.x-2*p.x*x.x*p.y*b.y-2*p.x*p.y*x.y*b.x-2*y.x*U*w.x-2*y.y*V*w.y+2*v.x*U*w.x+2*x.x*U*b.x-I*p.x*w.x-k*p.y*w.y+V*(2*v.y*w.y+2*x.y*b.y),2*y.x*p.x*p.y*b.y+2*y.y*p.x*p.y*b.x+f.x*f.y*p.x*b.y+f.x*f.y*p.y*b.x-2*v.x*p.x*p.y*b.y-2*p.x*v.y*p.y*b.x-2*p.x*x.x*p.y*x.y-2*y.x*U*b.x-2*y.y*V*b.y+2*v.x*U*b.x-I*p.x*b.x-k*p.y*b.y+st*U+V*(2*v.y*b.y+tt),2*y.x*p.x*p.y*x.y+2*y.y*p.x*x.x*p.y+f.x*f.y*p.x*x.y+f.x*f.y*x.x*p.y-2*v.x*p.x*p.y*x.y-2*p.x*v.y*x.x*p.y-2*y.x*x.x*U-2*y.y*V*x.y+2*v.x*x.x*U-I*p.x*x.x-k*p.y*x.y+2*V*v.y*x.y,-2*y.x*y.y*p.x*p.y-y.x*f.x*f.y*p.y-y.y*f.x*f.y*p.x+2*y.x*p.x*v.y*p.y+2*y.y*v.x*p.x*p.y+f.x*v.x*f.y*p.y+f.x*f.y*p.x*v.y-2*v.x*p.x*v.y*p.y-2*y.x*v.x*U+y.x*I*p.x+y.y*k*p.y-2*y.y*V*v.y-v.x*I*p.x-k*v.y*p.y+C*U+E*V+J*U+V*j).getRootsInInterval(0,1);for(const q of ot){const B=new Dt(p.x,f.x,y.x-v.x-q*x.x-q*q*b.x-q*q*q*w.x).getRoots(),H=new Dt(p.y,f.y,y.y-v.y-q*x.y-q*q*b.y-q*q*q*w.y).getRoots();if(B.length>0&&H.length>0){t:for(const X of B)if(0<=X&&X<=1){for(let Ft=0;Ft<H.length;Ft++)if(Math.abs(X-H[Ft])<1e-4){u.points.push(w.multiply(q*q*q).add(b.multiply(q*q).add(x.multiply(q).add(v))));break t}}}}return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier2Circle(e,t,n,s,r){return O.intersectBezier2Ellipse(e,t,n,s,r,r)}static intersectBezier2Ellipse(e,t,n,s,r,o){let i;const a=new O("No Intersection");i=t.multiply(-2);const c=e.add(i.add(n));i=e.multiply(-2);const h=t.multiply(2),d=i.add(h),u=new at(e.x,e.y),p=r*r,f=o*o,y=new Dt(f*c.x*c.x+p*c.y*c.y,2*(f*c.x*d.x+p*c.y*d.y),f*(2*c.x*u.x+d.x*d.x)+p*(2*c.y*u.y+d.y*d.y)-2*(f*s.x*c.x+p*s.y*c.y),2*(f*d.x*(u.x-s.x)+p*d.y*(u.y-s.y)),f*(u.x*u.x+s.x*s.x)+p*(u.y*u.y+s.y*s.y)-2*(f*s.x*u.x+p*s.y*u.y)-p*f).getRoots();for(const w of y)0<=w&&w<=1&&a.points.push(c.multiply(w*w).add(d.multiply(w).add(u)));return a.points.length>0&&(a.status="Intersection"),a}static intersectBezier2Line(e,t,n,s,r){let o;const i=s.min(r),a=s.max(r),c=new O("No Intersection");o=t.multiply(-2);const h=e.add(o.add(n));o=e.multiply(-2);const d=t.multiply(2),u=o.add(d),p=new at(e.x,e.y),f=new qt(s.y-r.y,r.x-s.x),y=s.x*r.y-r.x*s.y,w=new Dt(f.dot(h),f.dot(u),f.dot(p)+y).getRoots();for(const b of w)if(0<=b&&b<=1){const x=e.lerp(t,b),v=t.lerp(n,b),C=x.lerp(v,b);s.x===r.x?i.y<=C.y&&C.y<=a.y&&(c.status="Intersection",c.appendPoint(C)):s.y===r.y?i.x<=C.x&&C.x<=a.x&&(c.status="Intersection",c.appendPoint(C)):i.x<=C.x&&C.x<=a.x&&i.y<=C.y&&C.y<=a.y&&(c.status="Intersection",c.appendPoint(C))}return c}static intersectBezier2Polygon(e,t,n,s){return O.intersectBezier2Polyline(e,t,n,Ke(s))}static intersectBezier2Polyline(e,t,n,s){const r=new O("No Intersection"),{length:o}=s;for(let i=0;i<o-1;i++){const a=s[i],c=s[i+1],h=O.intersectBezier2Line(e,t,n,a,c);r.appendPoints(h.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectBezier2Rectangle(e,t,n,s,r){const o=s.min(r),i=s.max(r),a=new at(i.x,o.y),c=new at(o.x,i.y),h=O.intersectBezier2Line(e,t,n,o,a),d=O.intersectBezier2Line(e,t,n,a,i),u=O.intersectBezier2Line(e,t,n,i,c),p=O.intersectBezier2Line(e,t,n,c,o),f=new O("No Intersection");return f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.appendPoints(p.points),f.points.length>0&&(f.status="Intersection"),f}static intersectBezier3Bezier3(e,t,n,s,r,o,i,a){let c,h,d,u;const p=new O("No Intersection");c=e.multiply(-1),h=t.multiply(3),d=n.multiply(-3),u=c.add(h.add(d.add(s)));const f=new at(u.x,u.y);c=e.multiply(3),h=t.multiply(-6),d=n.multiply(3),u=c.add(h.add(d));const y=new at(u.x,u.y);c=e.multiply(-3),h=t.multiply(3),d=c.add(h);const w=new at(d.x,d.y),b=new at(e.x,e.y);c=r.multiply(-1),h=o.multiply(3),d=i.multiply(-3),u=c.add(h.add(d.add(a)));const x=new at(u.x,u.y);c=r.multiply(3),h=o.multiply(-6),d=i.multiply(3),u=c.add(h.add(d));const v=new at(u.x,u.y);c=r.multiply(-3),h=o.multiply(3),d=c.add(h);const C=new at(d.x,d.y),E=new at(r.x,r.y);c=f.x*y.y-y.x*f.y,h=f.x*w.y-w.x*f.y;const k=f.x*b.y-b.x*f.y+E.x*f.y-f.x*E.y,I=C.x*f.y-f.x*C.y,V=v.x*f.y-f.x*v.y,U=x.x*f.y-f.x*x.y;u=f.x*w.y-w.x*f.y;const J=f.x*b.y+y.x*w.y-w.x*y.y-b.x*f.y+E.x*f.y-f.x*E.y,j=C.x*f.y-f.x*C.y,st=v.x*f.y-f.x*v.y,tt=x.x*f.y-f.x*x.y,it=y.x*b.y-b.x*y.y+E.x*y.y-y.x*E.y,ht=C.x*y.y-y.x*C.y,xt=v.x*y.y-y.x*v.y,mt=x.x*y.y-y.x*x.y,ut=f.x*b.y-b.x*f.y+E.x*f.y-f.x*E.y,ot=C.x*f.y-f.x*C.y,q=v.x*f.y-f.x*v.y,B=x.x*f.y-f.x*x.y,H=y.x*b.y-b.x*y.y+E.x*y.y-y.x*E.y,z=C.x*y.y-y.x*C.y,X=v.x*y.y-y.x*v.y,Ft=x.x*y.y-y.x*x.y,ye=w.x*b.y-b.x*w.y+E.x*w.y-w.x*E.y,Se=C.x*w.y-w.x*C.y,Me=v.x*w.y-w.x*v.y,Te=x.x*w.y-w.x*x.y,Ce=new Dt(-U*tt*B,-U*tt*q-U*st*B-V*tt*B,-U*tt*ot-U*st*q-V*tt*q-U*j*B-V*st*B-I*tt*B,-U*tt*ut-U*st*ot-V*tt*ot-U*j*q-V*st*q-I*tt*q-U*J*B-V*j*B-I*st*B-k*tt*B+h*mt*B+U*u*Ft-c*mt*Ft+c*tt*Te,-U*st*ut-V*tt*ut-U*j*ot-V*st*ot-I*tt*ot-U*J*q-V*j*q-I*st*q-k*tt*q+h*mt*q-V*J*B-I*j*B-k*st*B+h*xt*B+U*u*X-c*mt*X+V*u*Ft-c*xt*Ft+c*tt*Me+c*st*Te,-U*j*ut-V*st*ut-I*tt*ut-U*J*ot-V*j*ot-I*st*ot-k*tt*ot+h*mt*ot-V*J*q-I*j*q-k*st*q+h*xt*q-I*J*B-k*j*B+h*ht*B+U*u*z-c*mt*z+V*u*X-c*xt*X+I*u*Ft-c*ht*Ft+c*tt*Se+c*st*Me+c*j*Te,-U*J*ut-V*j*ut-I*st*ut-k*tt*ut+h*mt*ut-V*J*ot-I*j*ot-k*st*ot+h*xt*ot-I*J*q-k*j*q+h*ht*q-k*J*B+h*it*B+U*u*H-c*mt*H+V*u*z-c*xt*z+I*u*X-c*ht*X+k*u*Ft-c*it*Ft+c*tt*ye+c*st*Se+c*j*Me-h*u*Te+c*J*Te,-V*J*ut-I*j*ut-k*st*ut+h*xt*ut-I*J*ot-k*j*ot+h*ht*ot-k*J*q+h*it*q+V*u*H-c*xt*H+I*u*z-c*ht*z+k*u*X-c*it*X+c*st*ye+c*j*Se-h*u*Me+c*J*Me,-I*J*ut-k*j*ut+h*ht*ut-k*J*ot+h*it*ot+I*u*H-c*ht*H+k*u*z-c*it*z+c*j*ye-h*u*Se+c*J*Se,-k*J*ut+h*it*ut+k*u*H-c*it*H-h*u*ye+c*J*ye);Ce.simplifyEquals();const zn=Ce.getRootsInInterval(0,1);for(const Bt of zn){const mn=new Dt(f.x,y.x,w.x,b.x-E.x-Bt*C.x-Bt*Bt*v.x-Bt*Bt*Bt*x.x);mn.simplifyEquals();const Le=mn.getRoots(),Ae=new Dt(f.y,y.y,w.y,b.y-E.y-Bt*C.y-Bt*Bt*v.y-Bt*Bt*Bt*x.y);Ae.simplifyEquals();const Re=Ae.getRoots();if(Le.length>0&&Re.length>0){t:for(const tn of Le)if(0<=tn&&tn<=1){for(let ze=0;ze<Re.length;ze++)if(Math.abs(tn-Re[ze])<1e-4){p.points.push(x.multiply(Bt*Bt*Bt).add(v.multiply(Bt*Bt).add(C.multiply(Bt).add(E))));break t}}}}return p.points.length>0&&(p.status="Intersection"),p}static intersectBezier3Circle(e,t,n,s,r,o){return O.intersectBezier3Ellipse(e,t,n,s,r,o,o)}static intersectBezier3Ellipse(e,t,n,s,r,o,i){let a,c,h,d;const u=new O("No Intersection");a=e.multiply(-1),c=t.multiply(3),h=n.multiply(-3),d=a.add(c.add(h.add(s)));const p=new at(d.x,d.y);a=e.multiply(3),c=t.multiply(-6),h=n.multiply(3),d=a.add(c.add(h));const f=new at(d.x,d.y);a=e.multiply(-3),c=t.multiply(3),h=a.add(c);const y=new at(h.x,h.y),w=new at(e.x,e.y),b=o*o,x=i*i,C=new Dt(p.x*p.x*x+p.y*p.y*b,2*(p.x*f.x*x+p.y*f.y*b),2*(p.x*y.x*x+p.y*y.y*b)+f.x*f.x*x+f.y*f.y*b,2*p.x*x*(w.x-r.x)+2*p.y*b*(w.y-r.y)+2*(f.x*y.x*x+f.y*y.y*b),2*f.x*x*(w.x-r.x)+2*f.y*b*(w.y-r.y)+y.x*y.x*x+y.y*y.y*b,2*y.x*x*(w.x-r.x)+2*y.y*b*(w.y-r.y),w.x*w.x*x-2*w.y*r.y*b-2*w.x*r.x*x+w.y*w.y*b+r.x*r.x*x+r.y*r.y*b-b*x).getRootsInInterval(0,1);for(const E of C)u.points.push(p.multiply(E*E*E).add(f.multiply(E*E).add(y.multiply(E).add(w))));return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier3Line(e,t,n,s,r,o){let i,a,c,h;const d=r.min(o),u=r.max(o),p=new O("No Intersection");i=e.multiply(-1),a=t.multiply(3),c=n.multiply(-3),h=i.add(a.add(c.add(s)));const f=new qt(h.x,h.y);i=e.multiply(3),a=t.multiply(-6),c=n.multiply(3),h=i.add(a.add(c));const y=new qt(h.x,h.y);i=e.multiply(-3),a=t.multiply(3),c=i.add(a);const w=new qt(c.x,c.y),b=new qt(e.x,e.y),x=new qt(r.y-o.y,o.x-r.x),v=r.x*o.y-o.x*r.y,C=new Dt(x.dot(f),x.dot(y),x.dot(w),x.dot(b)+v).getRoots();for(const E of C)if(0<=E&&E<=1){const k=e.lerp(t,E),I=t.lerp(n,E),V=n.lerp(s,E),U=k.lerp(I,E),J=I.lerp(V,E),j=U.lerp(J,E);r.x===o.x?d.y<=j.y&&j.y<=u.y&&(p.status="Intersection",p.appendPoint(j)):r.y===o.y?d.x<=j.x&&j.x<=u.x&&(p.status="Intersection",p.appendPoint(j)):d.x<=j.x&&j.x<=u.x&&d.y<=j.y&&j.y<=u.y&&(p.status="Intersection",p.appendPoint(j))}return p}static intersectBezier3Polygon(e,t,n,s,r){return O.intersectBezier3Polyline(e,t,n,s,Ke(r))}static intersectBezier3Polyline(e,t,n,s,r){const o=new O("No Intersection"),{length:i}=r;for(let a=0;a<i-1;a++){const c=r[a],h=r[a+1],d=O.intersectBezier3Line(e,t,n,s,c,h);o.appendPoints(d.points)}return o.points.length>0&&(o.status="Intersection"),o}static intersectBezier3Rectangle(e,t,n,s,r,o){const i=r.min(o),a=r.max(o),c=new at(a.x,i.y),h=new at(i.x,a.y),d=O.intersectBezier3Line(e,t,n,s,i,c),u=O.intersectBezier3Line(e,t,n,s,c,a),p=O.intersectBezier3Line(e,t,n,s,a,h),f=O.intersectBezier3Line(e,t,n,s,h,i),y=new O("No Intersection");return y.appendPoints(d.points),y.appendPoints(u.points),y.appendPoints(p.points),y.appendPoints(f.points),y.points.length>0&&(y.status="Intersection"),y}static intersectCircleCircle(e,t,n,s){let r;const o=t+s,i=Math.abs(t-s),a=e.distanceFrom(n);if(a>o)r=new O("Outside");else if(a<i)r=new O("Inside");else{r=new O("Intersection");const c=(t*t-s*s+a*a)/(2*a),h=Math.sqrt(t*t-c*c),d=e.lerp(n,c/a),u=h/a;r.points.push(new at(d.x-u*(n.y-e.y),d.y+u*(n.x-e.x))),r.points.push(new at(d.x+u*(n.y-e.y),d.y-u*(n.x-e.x)))}return r}static intersectCircleEllipse(e,t,n,s,r){return O.intersectEllipseEllipse(e,t,t,n,s,r)}static intersectCircleLine(e,t,n,s){let r;const o=(s.x-n.x)*(s.x-n.x)+(s.y-n.y)*(s.y-n.y),i=2*((s.x-n.x)*(n.x-e.x)+(s.y-n.y)*(n.y-e.y)),a=e.x*e.x+e.y*e.y+n.x*n.x+n.y*n.y-2*(e.x*n.x+e.y*n.y)-t*t,c=i*i-4*o*a;if(c<0)r=new O("Outside");else if(c===0)r=new O("Tangent");else{const h=Math.sqrt(c),d=(-i+h)/(2*o),u=(-i-h)/(2*o);(d<0||d>1)&&(u<0||u>1)?d<0&&u<0||d>1&&u>1?r=new O("Outside"):r=new O("Inside"):(r=new O("Intersection"),0<=d&&d<=1&&r.points.push(n.lerp(s,d)),0<=u&&u<=1&&r.points.push(n.lerp(s,u)))}return r}static intersectCirclePolygon(e,t,n){return O.intersectCirclePolyline(e,t,Ke(n))}static intersectCirclePolyline(e,t,n){const s=new O("No Intersection"),{length:r}=n;let o;for(let i=0;i<r-1;i++){const a=n[i],c=n[i+1];o=O.intersectCircleLine(e,t,a,c),s.appendPoints(o.points)}return s.points.length>0?s.status="Intersection":s.status=o.status,s}static intersectCircleRectangle(e,t,n,s){const r=n.min(s),o=n.max(s),i=new at(o.x,r.y),a=new at(r.x,o.y),c=O.intersectCircleLine(e,t,r,i),h=O.intersectCircleLine(e,t,i,o),d=O.intersectCircleLine(e,t,o,a),u=O.intersectCircleLine(e,t,a,r),p=new O("No Intersection");return p.appendPoints(c.points),p.appendPoints(h.points),p.appendPoints(d.points),p.appendPoints(u.points),p.points.length>0?p.status="Intersection":p.status=c.status,p}static intersectEllipseEllipse(e,t,n,s,r,o){const i=[n*n,0,t*t,-2*n*n*e.x,-2*t*t*e.y,n*n*e.x*e.x+t*t*e.y*e.y-t*t*n*n],a=[o*o,0,r*r,-2*o*o*s.x,-2*r*r*s.y,o*o*s.x*s.x+r*r*s.y*s.y-r*r*o*o],h=dh(i,a).getRoots(),d=.001,u=(i[0]*i[0]+2*i[1]*i[1]+i[2]*i[2])*d,p=(a[0]*a[0]+2*a[1]*a[1]+a[2]*a[2])*d,f=new O("No Intersection");for(let y=0;y<h.length;y++){const b=new Dt(i[0],i[3]+h[y]*i[1],i[5]+h[y]*(i[4]+h[y]*i[2])).getRoots();for(let x=0;x<b.length;x++){let v=(i[0]*b[x]+i[1]*h[y]+i[3])*b[x]+(i[2]*h[y]+i[4])*h[y]+i[5];Math.abs(v)<u&&(v=(a[0]*b[x]+a[1]*h[y]+a[3])*b[x]+(a[2]*h[y]+a[4])*h[y]+a[5],Math.abs(v)<p&&f.appendPoint(new at(b[x],h[y])))}}return f.points.length>0&&(f.status="Intersection"),f}static intersectEllipseLine(e,t,n,s,r){let o;const i=new qt(s.x,s.y),a=qt.fromPoints(s,r),c=new qt(e.x,e.y),h=i.subtract(c),d=new qt(a.x/(t*t),a.y/(n*n)),u=new qt(h.x/(t*t),h.y/(n*n)),p=a.dot(d),f=a.dot(u);e=h.dot(u)-1;const y=f*f-p*e;if(y<0)o=new O("Outside");else if(y>0){const w=Math.sqrt(y),b=(-f-w)/p,x=(-f+w)/p;(b<0||1<b)&&(x<0||1<x)?b<0&&x<0||b>1&&x>1?o=new O("Outside"):o=new O("Inside"):(o=new O("Intersection"),0<=b&&b<=1&&o.appendPoint(s.lerp(r,b)),0<=x&&x<=1&&o.appendPoint(s.lerp(r,x)))}else{const w=-f/p;0<=w&&w<=1?(o=new O("Intersection"),o.appendPoint(s.lerp(r,w))):o=new O("Outside")}return o}static intersectEllipsePolygon(e,t,n,s){return O.intersectEllipsePolyline(e,t,n,Ke(s))}static intersectEllipsePolyline(e,t,n,s){const r=new O("No Intersection"),{length:o}=s;for(let i=0;i<o-1;i++){const a=s[i],c=s[i+1],h=O.intersectEllipseLine(e,t,n,a,c);r.appendPoints(h.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectEllipseRectangle(e,t,n,s,r){const o=s.min(r),i=s.max(r),a=new at(i.x,o.y),c=new at(o.x,i.y),h=O.intersectEllipseLine(e,t,n,o,a),d=O.intersectEllipseLine(e,t,n,a,i),u=O.intersectEllipseLine(e,t,n,i,c),p=O.intersectEllipseLine(e,t,n,c,o),f=new O("No Intersection");return f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.appendPoints(p.points),f.points.length>0&&(f.status="Intersection"),f}static intersectLineLine(e,t,n,s){let r;const o=(s.x-n.x)*(e.y-n.y)-(s.y-n.y)*(e.x-n.x),i=(t.x-e.x)*(e.y-n.y)-(t.y-e.y)*(e.x-n.x),a=(s.y-n.y)*(t.x-e.x)-(s.x-n.x)*(t.y-e.y);if(a!==0){const c=o/a,h=i/a;0<=c&&c<=1&&0<=h&&h<=1?(r=new O("Intersection"),r.points.push(new at(e.x+c*(t.x-e.x),e.y+c*(t.y-e.y)))):r=new O("No Intersection")}else o===0||i===0?r=new O("Coincident"):r=new O("Parallel");return r}static intersectLinePolygon(e,t,n){return O.intersectLinePolyline(e,t,Ke(n))}static intersectLinePolyline(e,t,n){const s=new O("No Intersection"),{length:r}=n;for(let o=0;o<r-1;o++){const i=n[o],a=n[o+1],c=O.intersectLineLine(e,t,i,a);s.appendPoints(c.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectLineRectangle(e,t,n,s){const r=n.min(s),o=n.max(s),i=new at(o.x,r.y),a=new at(r.x,o.y),c=O.intersectLineLine(r,i,e,t),h=O.intersectLineLine(i,o,e,t),d=O.intersectLineLine(o,a,e,t),u=O.intersectLineLine(a,r,e,t),p=new O("No Intersection");return p.appendPoints(c.points),p.appendPoints(h.points),p.appendPoints(d.points),p.appendPoints(u.points),p.points.length>0&&(p.status="Intersection"),p}static intersectPolygonPolygon(e,t){return O.intersectPolylinePolyline(Ke(e),Ke(t))}static intersectPolygonPolyline(e,t){return O.intersectPolylinePolyline(Ke(e),t)}static intersectPolygonRectangle(e,t,n){return O.intersectPolylineRectangle(Ke(e),t,n)}static intersectPolylinePolyline(e,t){const n=new O("No Intersection"),{length:s}=e;for(let r=0;r<s-1;r++){const o=e[r],i=e[r+1],a=O.intersectLinePolyline(o,i,t);n.appendPoints(a.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectPolylineRectangle(e,t,n){const s=t.min(n),r=t.max(n),o=new at(r.x,s.y),i=new at(s.x,r.y),a=O.intersectLinePolyline(s,o,e),c=O.intersectLinePolyline(o,r,e),h=O.intersectLinePolyline(r,i,e),d=O.intersectLinePolyline(i,s,e),u=new O("No Intersection");return u.appendPoints(a.points),u.appendPoints(c.points),u.appendPoints(h.points),u.appendPoints(d.points),u.points.length>0&&(u.status="Intersection"),u}static intersectRectangleRectangle(e,t,n,s){const r=e.min(t),o=e.max(t),i=new at(o.x,r.y),a=new at(r.x,o.y),c=O.intersectLineRectangle(r,i,n,s),h=O.intersectLineRectangle(i,o,n,s),d=O.intersectLineRectangle(o,a,n,s),u=O.intersectLineRectangle(a,r,n,s),p=new O("No Intersection");return p.appendPoints(c.points),p.appendPoints(h.points),p.appendPoints(d.points),p.appendPoints(u.points),p.points.length>0&&(p.status="Intersection"),p}static intersectRayRay(e,t,n,s){let r;const o=(s.x-n.x)*(e.y-n.y)-(s.y-n.y)*(e.x-n.x),i=(t.x-e.x)*(e.y-n.y)-(t.y-e.y)*(e.x-n.x),a=(s.y-n.y)*(t.x-e.x)-(s.x-n.x)*(t.y-e.y);if(a!==0){const c=o/a;r=new O("Intersection"),r.points.push(new at(e.x+c*(t.x-e.x),e.y+c*(t.y-e.y)))}else o===0||i===0?r=new O("Coincident"):r=new O("Parallel");return r}appendPoint(e){this.points.push(e)}appendPoints(e){this.points=this.points.concat(e)}}class _n extends Sn{constructor(){super(...arguments);g(this,"imgBitmap",null);g(this,"fallbackDrawer",new ih);g(this,"broken",!1)}setBroken(t=!0){this.broken=t}setImageBitmap(t){this.imgBitmap=t}get borderProps(){return this.props.get(R.Border)}get cropProps(){return this.props.get(R.Crop)}updateProps(t){super.updateProps(t),t.find(s=>s.type===R.Base)&&this.updateTransformMatrix()}drawOnGLCtx(t){if(!this.imgBitmap){this.broken&&this.fallbackDrawer.fallbackDraw(this,t);return}t.save();const{a:n,b:s,c:r,d:o,e:i,f:a}=this.globalTransform();t.transform(n,s,r,o,i,a),this.clipDrawImage(t,this.imgBitmap),this.clipDrawBorder(t),t.restore()}clipDrawBorder(t){const n=this.borderProps,s=this.cropProps,r=this.baseProps;if(n.color!==""&&n.dashType!==Ee.None){if(T.setDashLine(n,t),t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,s.cropType===de.Circle){const o=.5*Math.min(r.width,r.height);t.beginPath(),t.arc(.5*r.width,.5*r.height,o,0,2*Math.PI),t.stroke();return}if(s.cropType===de.RoundRect){t.beginPath(),t.roundRect(0,0,r.width,r.height,10),t.stroke();return}t.strokeRect(0,0,r.width,r.height)}}clipDrawImage(t,n){const s=this.cropProps,r=this.baseProps;if(s.cropType===de.None)t.drawImage(n,0,0,r.width,r.height);else{if(t.save(),s.cropType===de.RoundRect&&(t.beginPath(),t.roundRect(0,0,r.width,r.height,10),t.clip()),s.cropType===de.Circle){const b=.5*Math.min(r.width,r.height);t.beginPath(),t.arc(.5*r.width,.5*r.height,b,0,2*Math.PI),t.clip()}const{imgX:o,imgY:i,imgWidth:a,imgHeight:c}=s.cropInfo,h=this.getImgSize(),d=a/h.imgWidth,u=c/h.imgHeight,p=-o/d,f=-i/u,y=r.width/d,w=r.height/u;t.drawImage(n,p,f,y,w,0,0,r.width,r.height),t.restore()}}getImgSize(){if(!this.imgBitmap){console.warn("img bitmap不存在,已经降级处理");const{width:s,height:r}=this.baseProps;return{imgWidth:s,imgHeight:r}}const t=this.imgBitmap.width,n=this.imgBitmap.height;return{imgWidth:t,imgHeight:n}}getOriginImageRect(){const{cropType:t,cropInfo:n}=this.cropProps;if(t===de.None||!n){const a=this.baseProps;return new D(0,0,a.width,a.height)}const{imgX:s,imgY:r,imgWidth:o,imgHeight:i}=n;return new D(s,r,o,i)}getTextContentRect(){return this.baseProps}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}borderContains(t,n){const s=this.toLocal(t),{width:r,height:o}=this.baseProps,i=K.rectangle({top:0,left:0,width:r,height:o}),a=K.line({x:s.x-n,y:s.y},{x:s.x+n,y:s.y}),c=K.line({x:s.x,y:s.y-n},{x:s.x,y:s.y+n});for(const h of[a,c]){const d=O.intersect(i,h);if(d.points.length>0)return d.points[0]}return null}}class ys extends _n{constructor(t,n){super(t,n);g(this,"type",A.IMG);this.props.set(R.Base,new gt),this.props.set(R.Border,new Ot),this.props.set(R.Image,new ps),this.props.set(R.Crop,new Mn)}get imgSrc(){return this.getProp(R.Image).url}static load(t,n,s,r,o,i){const a=new ys(t,i);return a.type=n,a.zIndex=s,a.setParent(o),a.updateProps(r),a}}class fh{draw(e,t){const n=e.getDrawPoints();if(n.length<2){console.error("line has no point!");return}const s=n[0],r=n.length>1?n[n.length-1]:{...s};t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(r.x,r.y),t.stroke()}textContentBounds(e){const t=e.baseProps;return{x:t.x,y:t.y,width:t.width,height:t.height}}borderContains(e,t,n){return null}getConnectAnchor(){return[]}}var Lt=(l=>(l[l.Line=0]="Line",l[l.PolyLine=1]="PolyLine",l[l.RoundPolyLine=2]="RoundPolyLine",l[l.Curve=3]="Curve",l))(Lt||{});class Ai{static lineContainsPoint(e,t,n){const s=e.shapeType,r=[...e.points];return s===Lt.Line?this.simpleLineContains(r,t,n):e.isPolyLine()?this.polyLineContains(r,t,n):s===Lt.Curve?this.curveLineContains(r,t,n):!1}static overlapRectNode(e,t){const n=e.shapeType,s=[...e.points],r=K.rectangle({top:t.minY,left:t.minX,width:t.maxX-t.minX,height:t.maxY-t.minY});if(n===Lt.Line){const o=K.line(s[0],s[s.length-1]);if(O.intersect(r,o).points.length>0)return!0}if(e.isPolyLine()){const o=K.polyline(s);if(O.intersect(r,o).points.length>0)return!0}if(n===Lt.Curve)for(let o=0;o<s.length-2;o=o+3){const i=s[o],a=s[o+1],c=s[o+2],h=s[o+3],d=K.cubicBezier(i,a,c,h);if(O.intersect(r,d).points.length>0)return!0}return!1}static curveLineContains(e,t,n){for(let s=0;s<e.length-2;s=s+3){const r=e[s],o=e[s+1],i=e[s+2],a=e[s+3],c=K.cubicBezier(r,o,i,a),h=K.circle(t,n);if(O.intersect(h,c).points.length>0)return!0}return!1}static polyLineContains(e,t,n){const s=K.polyline(e),r=K.circle(t,n);return O.intersect(r,s).points.length>0}static simpleLineContains(e,t,n){const s=K.line(e[0],e[e.length-1]),r=K.circle(t,n);return O.intersect(r,s).points.length>0}}class gh{constructor(){g(this,"radius",8)}draw(e,t){const n=e.getDrawPoints();if(n.length<2)return;t.save(),t.beginPath();const s=n[0];t.moveTo(s.x,s.y);for(const r of n)t.lineTo(r.x,r.y);t.stroke(),t.restore()}textContentBounds(e){const t=e.baseProps;return new D(t.x,t.y,t.width,t.height)}borderContains(e,t,n){return null}getConnectAnchor(){return[]}}class yh{draw(e,t){const n=e.getDrawPoints();if(!(n.length<3)){t.save(),t.beginPath();for(let s=1;s<n.length-2;s=s+3){const r=n[s-1],o=n[s],i=n[s+1],a=n[s+2];t.moveTo(r.x,r.y),t.bezierCurveTo(o.x,o.y,i.x,i.y,a.x,a.y)}t.stroke(),t.restore()}}textContentBounds(e){const t=e.baseProps;return{x:t.x,y:t.y,width:t.width,height:t.height}}borderContains(e,t,n){return null}getConnectAnchor(){return[]}}class mh{constructor(){g(this,"radius",8)}draw(e,t){const n=e.getDrawPoints();n.length<2||(t.save(),t.beginPath(),e.points.length===2?(t.moveTo(n[0].x,n[0].y),t.lineTo(n[1].x,n[1].y),t.stroke()):this.acrPolyDraw(t,n),t.restore())}textContentBounds(e){const t=e.baseProps;return new D(t.x,t.y,t.width,t.height)}acrPolyDraw(e,t){const n=t[t.length-1],s=this.dealArcPoly(t);for(const r of s)e.moveTo(r.p0.x,r.p0.y),e.lineTo(r.p1.x,r.p1.y),e.arcTo(r.arcDraw.a.x,r.arcDraw.a.y,r.arcDraw.b.x,r.arcDraw.b.y,r.arcDraw.r);e.lineTo(n.x,n.y),e.stroke()}dealArcPoly(e){const t=[];let n=e[0];for(let s=0;s<e.length-2;s=s+1){const r=n,o=e[s+1],i=e[s+2];if(T.judgeHorizon(r,o)){const c=.5*Math.abs(r.x-o.x),h=.5*Math.abs(o.y-i.y),d=c>h?h:c,u=this.radius<d?this.radius:d,p=u,f=o.x>r.x?1:-1,y=i.y>o.y?1:-1;n=new m(o.x,o.y+y*p);const w={p0:r,p1:new m(o.x-f*p,o.y),arcDraw:{a:o,b:n,r:u}};t.push(w)}else{const c=.5*Math.abs(r.y-o.y),h=.5*Math.abs(o.x-i.x),d=c>h?h:c,u=this.radius<d?this.radius:d,p=u,f=o.y>r.y?1:-1,y=i.x>o.x?1:-1;n=new m(o.x+y*p,o.y);const w={p0:r,p1:new m(o.x,o.y-f*p),arcDraw:{a:o,b:n,r:u}};t.push(w)}}return t}borderContains(e,t,n){return null}getConnectAnchor(){return[]}}class Ht{constructor(e,t,n){g(this,"paragraphIndex");g(this,"lineIndex");g(this,"charIndex");this.paragraphIndex=e,this.lineIndex=t,this.charIndex=n}static head(){return new Ht(0,0,-1)}clone(){return new Ht(this.paragraphIndex,this.lineIndex,this.charIndex)}equal(e){return this.paragraphIndex===e.paragraphIndex&&this.lineIndex===e.lineIndex&&this.charIndex===e.charIndex}greaterThan(e){return this.paragraphIndex>e.paragraphIndex?!0:this.paragraphIndex<e.paragraphIndex?!1:this.lineIndex>e.lineIndex?!0:this.lineIndex<e.lineIndex?!1:this.charIndex>e.charIndex?!0:!(this.charIndex<e.charIndex)}}class Vr{constructor(){g(this,"lines",[]);g(this,"index",0);g(this,"x",0);g(this,"y",0);g(this,"width",0);g(this,"height",0)}addLine(e){e.y=this.height,e.index=this.lines.length,this.lines.push(e),this.width=Math.max(e.width,this.width),this.height=this.height+e.height}contains(e){return T.rectContains2(e,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}headCursorPosition(){return new Ht(this.index,0,-1)}tailCursorPosition(){if(this.lines.length===0)return new Ht(this.index,-1,-1);const e=this.lines.length-1,t=this.lines[e];return t.characters.length===0?new Ht(this.index,e,-1):new Ht(this.index,e,t.characters.length-1)}detect(e){const{x:t,y:n}=e;if(n<0||t<0||n>this.height||this.lines.length===0)return null;for(let s=0;s<this.lines.length;s++){const r=this.lines[s];if(n>=r.y&&n<r.y+r.height){const o=new m(e.x-r.x,e.y-r.y),i=r.detect(o);return{lineIndex:r.index,charIndex:i}}}return null}getLine(e){return e<0||this.lines.length===0?null:e>this.lines.length-1?(console.warn("index 超出该段最大数目,fall back处理"),this.lines[this.lines.length-1]):this.lines[e]}draw(e,t){for(const n of this.lines){const s=new m(t.x+this.x,t.y+this.y);n.draw(e,s)}}alignHorizon(e,t){for(const n of this.lines)e===xe.Bottom&&(n.x=t-n.width),e===xe.Middle&&(n.x=.5*t-.5*n.width)}toString(){let e="";for(const t of this.lines)e+=t.toString();return e+`
3
- `}}class Ri{constructor(){g(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"word"}))}split(e){return Array.from(this.segmentWorker.segment(e)).map(n=>n.segment)}}class Ni{constructor(){g(this,"characters",[]);g(this,"width",0)}addCharacter(e){this.characters.push(e),this.width=this.width+e.width}}class Ei{constructor(e,t,n,s,r,o){g(this,"charText");g(this,"index",0);g(this,"x");g(this,"y");g(this,"width");g(this,"height");g(this,"boxAscent");this.charText=e,this.x=t,this.y=n,this.width=s,this.height=r,this.boxAscent=o}contains(e){return T.rectContains2(e,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}toString(){return this.charText}}class Ii{measure(e,t,n){const s=[];e.font=T.calcFontByTextProps(n);for(const r of t){const o=new Ni;for(const i of[...r]){const{width:a,height:c,boxAscent:h}=T.measureText(e,i),d=new Ei(i,0,0,a,c,h);o.addCharacter(d)}s.push(o)}return s}}class ms{constructor(e){g(this,"characters",[]);g(this,"index",0);g(this,"x",0);g(this,"y",0);g(this,"width",0);g(this,"height",0);g(this,"boxAscent",0);g(this,"textProps");this.textProps=e}contains(e){return T.rectContains2(e,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}detect(e){const{x:t,y:n}=e;if(n<0||t<0)return-1;if(n>this.height)return this.characters.length-1;if(t>this.width)return this.characters.length-1;if(this.characters.length===0)return-1;for(let s=0;s<this.characters.length;s++){const r=this.characters[s],o=r.x+.5*r.width;if(t<o)return s-1}return this.characters.length-1}addCharacter(e){e.x=this.width,e.index=this.characters.length,this.characters.push(e),this.width=this.width+e.width,this.height=Math.max(this.height,e.height),this.boxAscent=Math.max(e.boxAscent,this.boxAscent)}getCharacter(e){return e<0||this.characters.length===0?null:e>this.characters.length-1?(console.warn("index 超出该行最大字符数目,fall back处理"),this.characters[this.characters.length-1]):this.characters[e]}draw(e,t){const{fontBgColor:n,underline:s,strikethrough:r,fontColor:o}=this.textProps,i=t.x+this.x,a=t.y+this.y+this.boxAscent;n&&(e.save(),e.fillStyle=n,e.fillRect(i,a-this.boxAscent,this.width,this.height),e.restore()),e.fillText(this.toString(),i,a),s&&(e.strokeStyle=o,e.lineWidth=1,e.beginPath(),e.moveTo(i,a),e.lineTo(i+this.width,a),e.stroke()),r&&(e.strokeStyle=o,e.lineWidth=1,e.beginPath(),e.moveTo(i,a-.4*this.boxAscent),e.lineTo(i+this.width,a-.4*this.boxAscent),e.stroke())}toString(){let e="";for(const t of this.characters)e+=t.toString();return e}}class Wr{constructor(){g(this,"paragraphs",[]);g(this,"x",0);g(this,"y",0);g(this,"width",0);g(this,"height",0);g(this,"textProps",new se);g(this,"rect",new D);g(this,"splitWorker",new Ri);g(this,"measureWorker",new Ii)}draw(e,t){const{fontSize:n,fontFamily:s,fontColor:r,bold:o,italic:i}=this.textProps,a=T.calcFont(n,s,o,i);e.save(),e.textAlign="left",e.textBaseline="alphabetic",e.font=a,e.fillStyle=r,e.globalAlpha=1;for(const c of this.paragraphs){const h=new m(t.x+this.x,t.y+this.y);c.draw(e,h)}e.restore()}contains(e){return T.rectContains2(e,{minX:this.rect.x,maxX:this.rect.x+this.rect.width,minY:this.rect.y,maxY:this.rect.y+this.rect.height})}detect(e){let{x:t,y:n}=e;if(this.paragraphs.length===0)return new Ht(-1,-1,-1);if(n<this.y)return this.headTextCursorPosition();if(t<this.x)return this.headTextCursorPosition();if(n>this.y+this.height)return this.tailTextCursorPosition();if(t>this.x+this.rect.width)return this.tailTextCursorPosition();t=t-this.x,n=n-this.y;for(const s of this.paragraphs){const r=new m(t-s.x,n-s.y),o=s.detect(r);if(o)return new Ht(s.index,o.lineIndex,o.charIndex)}return this.tailTextCursorPosition()}headTextCursorPosition(){return Ht.head()}tailTextCursorPosition(){const e=this.paragraphs[this.paragraphs.length-1],t=e.lines[e.lines.length-1],n=t.characters.length===0?-1:t.characters.length-1;return new Ht(e.index,t.index,n)}addParagraph(e){e.y=this.height,e.index=this.paragraphs.length,this.paragraphs.push(e),this.width=Math.max(e.width,this.width),this.height=this.height+e.height}getParagraph(e){return e<0||this.paragraphs.length===0?null:e>this.paragraphs.length-1?(console.warn("index 超出该文本最大段落数目,fall back处理"),this.paragraphs[this.paragraphs.length-1]):this.paragraphs[e]}getPosByCursorPosition(e){const t=this.textProps,n=new m(this.x,this.y),{charIndex:s,lineIndex:r,paragraphIndex:o}=e,i=this.getParagraph(o);if(i===null)return{relativePos:n,height:t.fontSize};n.x+=i.x,n.y+=i.y;const a=i.getLine(r);if(a===null)return{relativePos:n,height:t.fontSize};n.x+=a.x,n.y+=a.y;const c=a.getCharacter(s);return c===null?{relativePos:n,height:a.height}:(n.x+=c.x+c.width,n.y+=c.y,{relativePos:n,height:c.height})}reset(){this.paragraphs=[],this.x=0,this.y=0,this.width=0,this.height=0}typesetting(e,t=this.textProps,n){this.reset(),this.rect=n,this.x=0,this.y=0,this.textProps=t;const{text:s,sizeMode:r}=t,o=r===le.autoWidth,i=s.split(`
4
- `);for(const a of i){const c=this.typesettingParagraph(e,a,n.width,o);this.addParagraph(c)}this.alignVertical(n),this.alignHorizon(n)}typesettingParagraph(e,t,n,s){if(t===""){const c=new Vr,h=new ms(this.textProps),{fontSize:d,fontFamily:u,bold:p,italic:f}=this.textProps,{height:y}=T.measureTextByFont(e,"1",d,u,p,f);return h.height=y,c.addLine(h),c}const r=this.splitWorker.split(t),o=this.measureWorker.measure(e,r,this.textProps),i=new Vr;let a=new ms(this.textProps);for(const c of o)if(s)c.characters.forEach(h=>a.addCharacter(h));else if(a.width+c.width<n)c.characters.forEach(h=>a.addCharacter(h));else if(c.width>n)for(const h of c.characters)a.width+h.width<n||(i.addLine(a),a=new ms(this.textProps)),a.addCharacter(h);else i.addLine(a),a=new ms(this.textProps),c.characters.forEach(h=>a.addCharacter(h));return i.addLine(a),i}alignVertical(e){const t=this.textProps.verticalAlign;if(t===xe.Top){this.y=e.y;return}if(t===xe.Bottom){this.y=e.y+e.height-this.height;return}if(t===xe.Middle){this.y=e.y+.5*e.height-.5*this.height;return}}alignHorizon(e){this.x=this.rect.x;const t=this.textProps.horizonAlign;for(const n of this.paragraphs)n.alignHorizon(t,e.width)}modifyPosInEditing(e,t){const n=new m;let s=!1;const{relativePos:r,height:o}=this.getPosByCursorPosition(t);return r.x<e.x&&(n.x=e.x-r.x,s=!0),r.x>e.x+e.width&&(n.x=-(r.x-(e.x+e.width)),s=!0),r.y<e.y&&(n.y=e.y-r.y,s=!0),r.y+o>e.y+e.height&&(n.y=-(r.y+o-(e.y+e.height)),s=!0),s&&(this.x+=n.x,this.y+=n.y),s}resetFromEditing(e){this.alignVertical(e),this.x=e.x}isEmptyText(){return this.textProps.text===""}}const wh="pingfang",Wt=5,xh=2,Ph=5,bh=50,vh="main_text_id",Mh=14,Sh=10;class ki{checkValid(e,t){const{paragraphIndex:n,lineIndex:s,charIndex:r}=t;if(n<0||s<0||r<-1||n>e.paragraphs.length-1)return console.warn("警告,光标位置异常,",t),null;const o=e.paragraphs[n];if(s>o.lines.length-1)return console.warn("警告,光标位置异常,",t),null;const i=o.lines[s];return r>i.characters.length-1?(console.warn("警告,光标位置异常,",t),null):{paragraph:o,line:i}}moveRight(e,t){const{paragraphIndex:n,lineIndex:s,charIndex:r}=t,o=this.checkValid(e,t);if(!o)return t;const{paragraph:i,line:a}=o;return t.equal(e.tailTextCursorPosition())?t:s===i.lines.length-1&&r===a.characters.length-1?new Ht(n+1,0,-1):r===a.characters.length-1?new Ht(n,s+1,-1):new Ht(n,s,r+1)}moveLeft(e,t){const{paragraphIndex:n,lineIndex:s,charIndex:r}=t,o=this.checkValid(e,t);if(!o)return t;const{paragraph:i,line:a}=o;if(t.equal(e.headTextCursorPosition()))return t;if(s===0&&r===-1)return e.paragraphs[n-1].tailCursorPosition();if(r===-1){const c=i.lines[s-1];return c.characters.length>0?new Ht(n,s-1,c.characters.length-2):new Ht(n,s-1,-1)}return new Ht(n,s,r-1)}moveUp(e,t){const{paragraphIndex:n,lineIndex:s,charIndex:r}=t,o=this.checkValid(e,t);if(!o)return t;const{paragraph:i,line:a}=o;if(n===0&&s===0)return t;const{relativePos:c,height:h}=e.getPosByCursorPosition(t),d=new m(c.x,c.y-1);return e.detect(d)}moveDown(e,t){const{paragraphIndex:n,lineIndex:s,charIndex:r}=t,o=this.checkValid(e,t);if(!o)return t;const{paragraph:i}=o;if(n===e.paragraphs.length-1&&s===i.lines.length-1)return t;const{relativePos:a,height:c}=e.getPosByCursorPosition(t),h=new m(a.x,a.y+c+1);return e.detect(h)}}class on{exec(e,t){const n=e.data;e.reverseLog=this.reverseLog(n,t),this.execData(n,t)}}var zt=(l=>(l[l.Start=0]="Start",l[l.End=1]="End",l[l.AddNode=2]="AddNode",l[l.RemoveNode=3]="RemoveNode",l[l.UpdateNode=4]="UpdateNode",l[l.SelectNode=5]="SelectNode",l[l.TextFocus=6]="TextFocus",l))(zt||{});class Bi{constructor(){g(this,"streaming",!1)}}class an{constructor(e,t){g(this,"meta",new Bi);g(this,"data");g(this,"reverseLog",null);this.data=e,t&&(this.meta=t)}reverse(){if(this.reverseLog===null)throw new Error("缺少对应逆消息");return this.reverseLog}}class Fe extends an{constructor(){super(...arguments);g(this,"type",zt.RemoveNode)}static create(t){return new Fe({idList:t})}clone(){const t=JSON.parse(JSON.stringify(this.data));return new Fe(t,this.meta)}}let Gr=class{},Oi=class extends Gr{handle(e,t,n){const s=t.find(i=>i.type===R.Connect);if(!s)return;const{start:r,end:o}=s;if(r!==void 0)if(r!==null){const i=n.nodeManager.getNode(r.objectId)||null;n.nodeManager.addLink(e,i,!0)}else n.nodeManager.addLink(e,null,!0);if(o!==void 0)if(o!==null){const i=n.nodeManager.getNode(o.objectId)||null;n.nodeManager.addLink(e,i,!1)}else n.nodeManager.addLink(e,null,!1)}};class Th extends Gr{handle(e,t,n){if(!t.find(o=>o.type===R.Image)||e.type!==A.IMG)return;const r=e;n.asyncRenderNodeManager.addRenderNode(r)}}let Ch=class extends Gr{handle(e,t,n){const s=t.find(o=>o.type===R.Svg);if(!s||e.type!==A.SVG)return;const r=e;n.resourceManager.loadSvgUrl(s.url).then(o=>{const i=$n.trimSvgCode(o);r.setSvgCode(i.svgCode),n.asyncRenderNodeManager.addRenderNode(r)}).catch(o=>{console.error("加载图片出现问题",o),r.setBroken(),n.renderManager.dirtyDraw(e.getBounds())})}};class Di extends on{constructor(){super(...arguments);g(this,"type",zt.AddNode);g(this,"handlers",[new Oi,new Th,new Ch])}execData(t,n){const s=t.nodes;for(const r of s)this.execNodeInfo(r,n);n.renderManager.addContentRenderTask()}execNodeInfo(t,n){const s=n.gmlRender.glCtx,r=n.nodeManager.getParentNode(t.parentId),o=Ge.getInstance().create(t.id,t.type,t.zIndex,t.props,r,s);n.nodeManager.addNode(o);for(const i of this.handlers)i.handle(o,t.props,n)}reverseLog(t,n){const s=t.nodes.map(r=>r.id);return new Fe({idList:s})}}class Yt extends an{constructor(){super(...arguments);g(this,"type",zt.AddNode)}static create(t){return new Yt({nodes:[t]})}clone(){const t=JSON.parse(JSON.stringify(this.data));return new Yt(t,this.meta)}}class Hi extends on{constructor(){super(...arguments);g(this,"type",zt.RemoveNode)}execData(t,n){for(const s of t.idList)n.nodeManager.getNode(s)&&n.nodeManager.removeNode(s);n.renderManager.addContentRenderTask(),n.renderManager.addAuxiliaryDrawTask()}reverseLog(t,n){var r;const s=[];for(const o of t.idList){const i=n.nodeManager.getNode(o);if(!i){console.error("错误,生成逆消息时节点不存在:",o);continue}const a=[...i.props.values()];s.push({id:i.id,type:i.type,zIndex:i.zIndex,parentId:((r=i.parent)==null?void 0:r.id)||Un,props:a})}return new Yt({nodes:s})}}class ct extends an{constructor(){super(...arguments);g(this,"type",zt.UpdateNode)}static create(t,n,s){const r={id:t,props:n};return new ct({infos:[r]},s)}clone(){const t=JSON.parse(JSON.stringify(this.data));return new ct(t,this.meta)}}class zi extends on{constructor(){super(...arguments);g(this,"type",zt.UpdateNode);g(this,"handlers",[new Oi])}execData(t,n){for(const s of t.infos)this.execNodeInfo(s,n);n.renderManager.addContentRenderTask()}execNodeInfo(t,n){const{id:s,zIndex:r,props:o,parentId:i}=t,a=n.nodeManager.getNode(s);if(!a){console.error("错误:节点不存在:",s);return}if(this.removeIndexNode(a,n),r!==void 0&&(a.zIndex=r),this.changeParent(a,n,i),o.length>0){a.updateProps(o);for(const c of this.handlers)c.handle(a,o,n)}this.addIndexNode(a,n),n.auxiliaryManager.selectManager.include(a)&&(n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(te.FocusPropsChange,!0))}changeParent(t,n,s){if(s===void 0||s===t.parent.id)return;const r=n.nodeManager.getNode(s);r&&(t.parent.children.delete(t),r.children.add(t),t.parent=r)}removeIndexNode(t,n){n.nodeManager.removeIndexNode(t.getRectNode());for(const s of t.children)this.removeIndexNode(s,n)}addIndexNode(t,n){n.nodeManager.addIndexNode(t.getRectNode());for(const s of t.children)this.addIndexNode(s,n)}reverseLog(t,n){const s=[];for(const r of t.infos){const o=n.nodeManager.getNode(r.id);if(!o)continue;const i=o.serializeTo(),a=T.convertCapInfoToProps(i.capInfo);s.push({id:o.id,zIndex:o.zIndex,props:a})}return new ct({infos:s})}}class Pt extends an{constructor(){super(...arguments);g(this,"type",zt.SelectNode)}static create(t){return new Pt({idList:t})}clone(){const t=JSON.parse(JSON.stringify(this.data));return new Pt(t,this.meta)}}class Xi extends on{constructor(){super(...arguments);g(this,"type",zt.SelectNode)}execData(t,n){const s=t.idList,r=new Set;s.forEach(o=>{const i=n.nodeManager.getNode(o);i&&r.add(i)}),n.auxiliaryManager.selectManager.set(r),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(te.FocusPropsChange,!0)}reverseLog(t,n){const r=n.auxiliaryManager.selectManager.getSelectNodes().map(o=>o.id);return new Pt({idList:r})}}class et extends an{constructor(){super(null);g(this,"type",zt.End)}clone(){return new et}}class Yi extends on{constructor(){super(...arguments);g(this,"type",zt.Start)}execData(t,n){}reverseLog(t,n){return new et}}class nt extends an{constructor(){super(null);g(this,"type",zt.Start)}clone(){return new nt}}class Fi extends on{constructor(){super(...arguments);g(this,"type",zt.End)}execData(t,n){}reverseLog(t,n){return new nt}}var be=(l=>(l[l.Focus=0]="Focus",l[l.Selection=1]="Selection",l[l.Blur=2]="Blur",l[l.Empty=3]="Empty",l))(be||{});class lt extends an{constructor(){super(...arguments);g(this,"type",zt.TextFocus)}static focus(t,n=Ht.head()){return new lt({focusType:be.Focus,focus:{id:t,textCursorPosition:n}})}static selection(t,n,s){return new lt({focusType:be.Selection,selection:{id:t,start:n,end:s}})}static blur(t){return new lt({blur:{id:t},focusType:be.Blur})}static empty(){return new lt({focusType:be.Empty})}clone(){const t=JSON.parse(JSON.stringify(this.data));return new lt(t,this.meta)}}class Vi extends on{constructor(){super(...arguments);g(this,"type",zt.TextFocus)}checkValidNode(t,n){const s=n.nodeManager.getNode(t);if(!s)throw new Error("错误:节点不存在:"+t);const r=s.renderText;return{node:s,renderText:r}}execData(t,n){var a;const{focusType:s,blur:r,selection:o,focus:i}=t;if(s===be.Empty){n.auxiliaryManager.remove(N.TextSelection);return}if(n.renderManager.addAuxiliaryDrawTask(),s===be.Focus){n.auxiliaryManager.remove(N.TextSelection);const{id:c,textCursorPosition:h}=i,{node:d,renderText:u}=this.checkValidNode(c,n);d.modifyPosInEditing(h)&&n.renderManager.addContentRenderTask(),n.inputManager.focus({node:d,renderText:u,textCursorPosition:h}),u.isEmptyText()?d.type===A.Shape&&n.auxiliaryManager.addOrUpdate(N.PlaceHolder,{node:d}):n.auxiliaryManager.remove(N.PlaceHolder),n.auxiliaryManager.selectManager.refreshSelectStatus();return}if(s===be.Selection){const{id:c,start:h,end:d}=o,{node:u,renderText:p}=this.checkValidNode(c,n);n.inputManager.selection(u,p,h,d);const f=(a=n.inputManager.selectionManager.selectionInfo)==null?void 0:a.selectionList;f&&(n.auxiliaryManager.addOrUpdate(N.TextSelection,{selectionList:f,node:u}),n.renderManager.addAuxiliaryDrawTask()),n.auxiliaryManager.remove(N.PlaceHolder);return}if(s===be.Blur){n.inputManager.blur(),n.auxiliaryManager.remove(N.PlaceHolder);return}}reverseLog(t,n){const{focusType:s}=t,r=n.inputManager.editTextInfo,o=n.inputManager.selectionManager.selectionInfo;if(s===be.Focus){const i=t.focus.id;return r?o?lt.selection(r.node.id,o.start,o.end):lt.focus(r.node.id,r.textCursorPosition):lt.blur(i)}if(s===be.Blur)return r?o?lt.selection(r.node.id,o.start,o.end):lt.focus(r.node.id,r.textCursorPosition):(console.warn("选中消息不符合预期,已容错处理"),lt.empty());if(s===be.Selection){const i=t.selection.id;return r?o?lt.selection(r.node.id,o.start,o.end):lt.focus(r.node.id,r.textCursorPosition):lt.blur(i)}return lt.empty()}}const Wi=[new Di,new Hi,new zi,new Xi,new Vi,new Yi,new Fi];class Gi{constructor(e){g(this,"executors",new Map);for(const t of e)this.executors.set(t.type,t)}exec(e,t,n=null){const s=this.executors.get(e.type);if(!s){console.error("缺乏对应的消息处理器,已忽略该消息");return}s.exec(e,t)}}class Ui{constructor(){g(this,"undoStack",[]);g(this,"redoStack",[])}add(e){const t=e.reverse();this.undoStack.push(t),this.redoStack=[]}undo(e,t){const n=this.undoStack.pop()||null;if(!n)return null;for(const s of n.actionLogs)e.exec(s,t);return this.redoStack.push(n.reverse()),n}redo(e,t){const n=this.redoStack.pop()||null;if(!n)return null;for(const s of n.actionLogs)e.exec(s,t);return this.undoStack.push(n.reverse()),n}}class Us{constructor(e=[]){g(this,"actionLogs",[]);this.actionLogs=e}reverse(){const e=new Us;for(let t=this.actionLogs.length-1;t>-1;t--){const n=this.actionLogs[t];e.actionLogs.push(n.reverse())}return e}}class _i{constructor(){g(this,"cacheLogs",[]);g(this,"duringGroup",!1)}add(e){e.type===zt.Start&&(this.duringGroup=!0),this.cacheLogs.push(e),e.type===zt.End&&(this.duringGroup=!1)}getActionGroup(){if(this.duringGroup)return null;const e=new Us(this.cacheLogs);return this.cacheLogs=[],e}}const Ki=new Set([zt.Start,zt.End,zt.SelectNode,zt.TextFocus]);class ji{constructor(e,t,n,s,r,o,i,a,c,h,d){g(this,"execCtx");g(this,"executor");g(this,"undoManager");g(this,"networkPlugin",null);g(this,"actionCache");g(this,"renderManager");g(this,"docState");this.executor=new Gi(Wi),this.undoManager=new Ui,this.renderManager=o,this.execCtx={inputManager:t,nodeManager:e,gmlRender:n,auxiliaryManager:s,toolManager:r,renderManager:this.renderManager,resourceManager:i,idGenerator:c,slotManager:h,asyncRenderNodeManager:d},this.actionCache=new _i,this.docState=a}addNetworkPlugin(e){this.networkPlugin=e}execAction(e){var n;this.dealDocSeq(e),this.executor.exec(e,this.execCtx),Ki.has(e.type)||(n=this.networkPlugin)==null||n.addMessage(e),this.actionCache.add(e);const t=this.actionCache.getActionGroup();t&&this.undoManager.add(t)}dealDocSeq(e){Ki.has(e.type)||this.docState.seq++}undo(){var t;const e=this.undoManager.undo(this.executor,this.execCtx);e&&((t=this.networkPlugin)==null||t.addActionGroup(e))}redo(){var t;const e=this.undoManager.redo(this.executor,this.execCtx);e&&((t=this.networkPlugin)==null||t.addActionGroup(e))}}function Lh(l){return l.type===zt.AddNode?{addNodeData:{data:l.data.nodes.map(n=>{const s=n.props,r=new Map;s.forEach(a=>r.set(a.type,a));const o=T.convertPropsToCapInfo(r);return{id:n.id,type:n.type,zIndex:n.zIndex,parentId:n.parentId,capInfo:o}})}}:l.type===zt.UpdateNode?{updateNodeData:{data:l.data.infos.map(n=>{const s=n.props,r=new Map;s.forEach(a=>r.set(a.type,a));const o=T.convertPropsToCapInfo(r);return{id:n.id,zIndex:n.zIndex,parentId:n.parentId,capInfo:o}})}}:l instanceof Fe?{removeNodeData:{data:l.data.idList}}:null}function Ah(l){const{updateNodeData:e,addNodeData:t,removeNodeData:n}=l;if(t){const s=[];for(const r of t.data)s.push({id:r.id,parentId:r.parentId,zIndex:r.zIndex,type:r.type,props:T.convertCapInfoToProps(r.capInfo)});return new Yt({nodes:s})}if(e){const s=[];for(const r of e.data)s.push({id:r.id,zIndex:r.zIndex,parentId:r.parentId,props:T.convertCapInfoToProps(r.capInfo)});return new ct({infos:s})}if(n)return Fe.create(n.data);throw new Error("类型转换错误!")}const Ur=.04,_r=4,qi=70;class Rh{zoomScale(e,t,n,s){const r=n.getScale();let o=e;r*e>_r&&(o=_r/r),r*e<Ur&&(o=Ur/r),this.zoomToScale(o,t,n.gmlRender),this.zoomToScale(o,t,n.auxiliaryManager.gmlRender);const i=n.getScale();if(i!==r)for(const[a,c]of n.nodeManager.nodeMap)c.type===A.SVG&&s.addRenderNode(c);n.slotManager.addSlotState(te.Scale,i),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}zoomToSelect(e,t){if(e.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const s=e.auxiliaryManager.selectManager.getSelectBounds();this.zoomToBounds(s,e,t)}zoomToFit(e,t){if(e.nodeManager.nodeMap.size===0)return;const s=e.nodeManager.getNodeBounds();this.zoomToBounds(s,e,t)}zoomTo100(e,t){if(e.nodeManager.nodeMap.size===0)return;const s=e.getScale(),r=e.nodeManager.getNodeBounds(),o=e.gmlRender.canvas.getBoundingClientRect(),i=window.devicePixelRatio,a=1*i,c=new m(.5*i*o.width,.5*i*o.height),h=new m(.5*(r.minX+r.maxX),.5*(r.minY+r.maxY)),d=new m(-h.x*a+c.x,-h.y*a+c.y);this.zoomToMatrix(a,d.x,d.y,e.gmlRender),this.zoomToMatrix(a,d.x,d.y,e.auxiliaryManager.gmlRender);const u=e.getScale();if(u!==s)for(const[p,f]of e.nodeManager.nodeMap)f.type===A.SVG&&t.addRenderNode(f);e.slotManager.addSlotState(te.Scale,u),e.addContentRenderTask(),e.addAuxiliaryDrawTask()}zoomToBounds(e,t,n){const s=D.rectNode2Rect(e),r=t.getScale(),o=t.gmlRender.canvas.getBoundingClientRect(),i=window.devicePixelRatio,a=o.width-qi*i,c=o.height-qi*2*i,h=a/s.width,d=c/s.height,u=Math.min(h,d)*i,p=new m(.5*i*o.width,.5*i*o.height),f=new m(.5*(e.minX+e.maxX),.5*(e.minY+e.maxY)),y=new m(-f.x*u+p.x,-f.y*u+p.y);this.zoomToMatrix(u,y.x,y.y,t.gmlRender),this.zoomToMatrix(u,y.x,y.y,t.auxiliaryManager.gmlRender);const w=t.getScale();if(w!==r)for(const[b,x]of t.nodeManager.nodeMap)x.type===A.SVG&&n.addRenderNode(x);t.slotManager.addSlotState(te.Scale,w),t.addContentRenderTask(),t.addAuxiliaryDrawTask()}zoomToScale(e,t,n){n.scale(e,e,t);const s=n.glCtx,{a:r,b:o,c:i,d:a,e:c,f:h}=n.globalTransform;s.setTransform(r,o,i,a,c,h)}zoomToMatrix(e,t,n,s){const r=e,o=e,i=t,a=n;s.setTransform(r,0,0,o,i,a)}}class Nh{exportToOfflineCanvas(e,t,n,s){const r=D.rectNode2Rect(e),o=document.createElement("canvas");o.width=n*r.width,o.height=n*r.height;const i=o.getContext("2d");i.scale(n,n),i.translate(-r.x,-r.y);let a=t.searchNodesByRectNode(e);a=T.sortGraphics(a),i.save(),s&&(i.fillStyle=s,i.fillRect(r.x,r.y,r.width,r.height)),i.restore();for(const c of a)c.drawOnGLCtx(i);return o}}class $i{constructor(e,t,n,s){g(this,"gmlRender");g(this,"nodeManager");g(this,"auxiliaryManager");g(this,"slotManager");g(this,"zoomWorker",new Rh);g(this,"exportWorker",new Nh);g(this,"contentDraw",!1);g(this,"auxiliaryDraw",!1);g(this,"tickerRun",()=>{if(this.contentDraw){const e=this.gmlRender.getViewPortBounds(),t=this.nodeManager.tree.search(e),n=new Set;for(const r of t){const o=this.nodeManager.nodeMap.get(r.id);o&&n.add(o)}let s=[...n];s=T.sortGraphics(s),this.gmlRender.dirtyDraw(e,s),this.contentDraw=!1}this.auxiliaryDraw&&(this.auxiliaryManager.redraw(),this.auxiliaryDraw=!1),requestAnimationFrame(this.tickerRun)});this.gmlRender=e,this.nodeManager=t,this.auxiliaryManager=n,this.slotManager=s}getScale(){return this.gmlRender.getScale()}zoomScale(e,t,n){this.zoomWorker.zoomScale(e,t,this,n)}zoomToFit(e){this.zoomWorker.zoomToFit(this,e)}zoomToSelect(e){this.zoomWorker.zoomToSelect(this,e)}zoomTo100(e){this.zoomWorker.zoomTo100(this,e)}exportOfflineCanvas(e,t,n){return this.exportWorker.exportToOfflineCanvas(e,this.nodeManager,t,n)}scroll(e,t){this.scrollTo(e,t,this.gmlRender),this.scrollTo(e,t,this.auxiliaryManager.gmlRender),this.addContentRenderTask(),this.addAuxiliaryDrawTask()}start(){this.tickerRun()}addAuxiliaryDrawTask(){this.auxiliaryDraw=!0}addContentRenderTask(){this.contentDraw=!0}dirtyDraw(e){const t=this.nodeManager.tree.search(e),n=new Set;for(const r of t){const o=this.nodeManager.nodeMap.get(r.id);o&&n.add(o)}let s=[...n];s=T.sortGraphics(s),this.gmlRender.dirtyDraw(e,s)}async drawAsyncNodes(e){const t=[];for(const s of e)t.push(s.getRectNode());const n=T.getBounds(t);this.dirtyDraw(n)}scrollTo(e,t,n){const s=n.getScale();n.translation(-e/s,-t/s);const r=n.glCtx,{a:o,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;r.setTransform(o,i,a,c,h,d)}}class Kr{handle(e,t){const n=this.layoutToPoints(e,t);return this.getUpdateNodeData(e.id,n)}getNodePos(e,{x:t,y:n}){const s=new m,{width:r,height:o}=e.baseProps;return s.x=t*r,s.y=n*o,e.toGlobal(s)}getUpdateNodeData(e,t){return{infos:[{id:e,props:[{type:R.Line,points:t}]}]}}}class Qi extends Kr{enable(e){return e.shapeType===Lt.Line}layoutToPoints(e,t){const{start:n,end:s}=e.connectProps,r=e.globalLinePoints;let o=r[0],i=r[r.length-1];if(n){const d=t.nodeManager.getNode(n.objectId);d&&(o=this.getNodePos(d,n))}if(s){const d=t.nodeManager.getNode(s.objectId);d&&(i=this.getNodePos(d,s))}const a=[o,i],c=e.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}layoutToPointsPro(e,t){return[e.point,t.point]}}class Zi extends Kr{enable(e){return e.shapeType===Lt.Curve}handle(e,t){const{start:n,end:s}=e.connectProps,r=e.globalLinePoints;let o=r[0],i=r[r.length-1];if(n){const d=t.nodeManager.getNode(n.objectId);d&&(o=this.getNodePos(d,n))}if(s){const d=t.nodeManager.getNode(s.objectId);d&&(i=this.getNodePos(d,s))}const a=this.computeLinePoints(o,i),c=e.globalTransform().inverseMatrix(),h=a.map(d=>c.crossPoint(d));return this.getUpdateNodeData(e.id,h)}computeLinePoints(e,t){const n=[],s=new m(t.x-e.x,t.y-e.y);if(Math.abs(s.x)>Math.abs(s.y)){const r=new m(e.x+.5*s.x,e.y),o=new m(t.x-.5*s.x,t.y);n.push(e,r,o,t)}else{const r=new m(e.x,e.y+.5*s.y),o=new m(t.x,t.y-.5*s.y);n.push(e,r,o,t)}return n}layoutToPoints(e,t){const{start:n,end:s}=e.connectProps,r=e.points,o=r[0],i=r[r.length-1];return this.computeLinePoints(o,i)}layoutToPointsPro(e,t){return this.computeLinePoints(e.point,t.point)}}class ws{constructor(e){g(this,"startPoint");this.startPoint=e}}class L{static computeZLinePoints(e,t,n){if(n){const o=new m(e.x,.5*(e.y+t.y)),i=new m(t.x,.5*(e.y+t.y));return[e,o,i,t]}const s=new m(.5*(e.x+t.x),e.y),r=new m(.5*(e.x+t.x),t.y);return[e,s,r,t]}static computeLLinePoints(e,t,n){if(n){const r=new m(e.x,t.y);return[e,r,t]}const s=new m(t.x,e.y);return[e,s,t]}}class Eh extends ws{constructor(t,n){super(t);g(this,"rect");this.rect=n}bottom(t,n){const s=this.startPoint;if(t.y<s.y)return Math.abs(s.x-t.x)<.01?[s,t]:L.computeZLinePoints(s,t,!0);const r=new m(.5*(s.x+t.x),s.y-M);if(Math.abs(r.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width||Math.abs(r.x-n.x-.5*n.width)<.5*n.width)if(s.x>t.x){const c=new m(Math.min(this.rect.x-M,n.x-M),Math.min(n.y-M,this.rect.y-M)),h=new m(t.x,Math.max(this.rect.y+this.rect.height+M,n.y+n.height+M)),d=L.computeLLinePoints(s,c,!0),u=L.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,t]}else{const c=new m(n.x+n.width+M,Math.min(n.y-M,this.rect.y-M)),h=new m(t.x,Math.max(this.rect.y+this.rect.height+M,n.y+n.height+M)),d=L.computeLLinePoints(s,c,!0),u=L.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,t]}const o=new m(t.x,t.y+M),i=L.computeLLinePoints(s,r,!0),a=L.computeLLinePoints(r,o,!0);return a.shift(),[...i,...a,t]}left(t,n){const s=this.startPoint;if(t.y<s.y&&t.x>s.x)return L.computeLLinePoints(s,t,!0);if(t.y<s.y){const a=new m(Math.min(this.rect.x-M,n.x-M),.5*(s.y+t.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new m(Math.min(this.rect.x-M,n.x-M),Math.min(this.rect.y-M,n.y-M)),u=L.computeLLinePoints(s,d,!0),p=L.computeLLinePoints(d,t,!0);return p.shift(),[...u,...p]}const c=L.computeLLinePoints(s,a,!0),h=L.computeLLinePoints(a,t,!0);return h.shift(),[...c,...h]}if(t.x>this.rect.x+this.rect.width+M){const a=new m(.5*(this.rect.x+this.rect.width+n.x),this.rect.y-M),c=L.computeLLinePoints(s,a,!0),h=L.computeLLinePoints(a,t,!0);return h.shift(),[...c,...h]}const r=new m(Math.min(this.rect.x-M,n.x-M),this.rect.y-M),o=L.computeLLinePoints(s,r,!0),i=L.computeLLinePoints(r,t,!0);return i.shift(),[...o,...i]}right(t,n){const s=this.startPoint;if(t.y<s.y&&t.x<s.x)return L.computeLLinePoints(s,t,!0);if(t.y<s.y){const a=new m(Math.max(this.rect.x+this.rect.width+M,n.x+n.width+M),.5*(s.y+t.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new m(Math.min(this.rect.x+this.rect.width+M,n.x+n.width+M),Math.min(this.rect.y-M,n.y-M)),u=L.computeLLinePoints(s,d,!0),p=L.computeLLinePoints(d,t,!0);return p.shift(),[...u,...p]}const c=L.computeLLinePoints(s,a,!0),h=L.computeLLinePoints(a,t,!0);return h.shift(),[...c,...h]}if(t.x<this.rect.x-M){const a=new m(.5*(this.rect.x+n.x),this.rect.y-M),c=L.computeLLinePoints(s,a,!0),h=L.computeLLinePoints(a,t,!0);return h.shift(),[...c,...h]}const r=new m(Math.min(this.rect.x+this.rect.width+M,n.x+n.width+M),this.rect.y-M),o=L.computeLLinePoints(s,r,!0),i=L.computeLLinePoints(r,t,!0);return i.shift(),[...o,...i]}top(t,n){const s=this.startPoint;if(t.y>this.rect.y+this.rect.height+M&&Math.abs(t.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width){if(t.x>s.x){const d=new m(this.rect.x+this.rect.width+M,this.rect.y-M),u=new m(t.x,n.y-M),p=L.computeLLinePoints(s,d,!0),f=L.computeLLinePoints(d,u,!0);return f.shift(),[...p,...f,t]}const i=new m(this.rect.x-M,this.rect.y-M),a=new m(t.x,n.y-M),c=L.computeLLinePoints(s,i,!0),h=L.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,t]}if(n.y+n.height<this.rect.y){if(t.x>s.x){const d=new m(n.x-M,this.rect.y-M),u=new m(t.x,n.y-M),p=L.computeLLinePoints(s,d,!0),f=L.computeLLinePoints(d,u,!0);return f.shift(),[...p,...f,t]}const i=new m(n.x+n.width+M,this.rect.y-M),a=new m(t.x,n.y-M),c=L.computeLLinePoints(s,i,!0),h=L.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,t]}const r=new m(t.x,Math.min(this.rect.y-M,n.y-M));return[...L.computeLLinePoints(s,r,!0),t]}toPoint(t){if(T.rectContains(t,new D(this.rect.x-M,this.rect.y,2*M,this.rect.height))){const o=new m(this.rect.x-M,this.rect.y-M),i=L.computeLLinePoints(this.startPoint,o,!0),a=L.computeLLinePoints(o,t,!0);return a.shift(),[...i,...a]}if(T.rectContains(t,new D(this.rect.x+this.rect.width-M,this.rect.y,2*M,this.rect.height))){const o=new m(this.rect.x+this.rect.width+M,this.rect.y-M),i=L.computeLLinePoints(this.startPoint,o,!0),a=L.computeLLinePoints(o,t,!0);return a.shift(),[...i,...a]}if(T.rectContains(t,new D(this.rect.x,this.rect.y+this.rect.height-M,this.rect.width,2*M))){const o=new m(this.rect.x-M,this.rect.y-M),i=new m(t.x,this.rect.y+this.rect.height+M),a=L.computeLLinePoints(this.startPoint,o,!0),c=L.computeLLinePoints(o,i,!0);return c.shift(),[...a,...c,t]}if(T.rectContains(t,new D(this.rect.x,this.rect.y-M,this.rect.width,2*M))){const o=new m(t.x,this.rect.y-M);return[...L.computeLLinePoints(this.startPoint,o,!0),t]}if(t.y<this.startPoint.y)return L.computeZLinePoints(this.startPoint,t,!0);if(t.x<this.rect.x||t.x>this.rect.x+this.rect.width)return[...L.computeLLinePoints(this.startPoint,new m(t.x,this.rect.y-M),!0),t];if(t.x<this.rect.x+.5*this.rect.width){const o=new m(this.rect.x-M,this.rect.y-M),i=L.computeLLinePoints(this.startPoint,o,!0),a=L.computeLLinePoints(o,t,!0);return a.shift(),[...i,...a]}const n=new m(this.rect.x+this.rect.width+M,this.rect.y-M),s=L.computeLLinePoints(this.startPoint,n,!0),r=L.computeLLinePoints(n,t,!0);return r.shift(),[...s,...r]}}class Ji extends ws{bottom(e,t){const n=this.startPoint;if(e.y<n.y)return L.computeZLinePoints(n,e,!0);if(T.inDistance(n.x,t.x,t.width))if(n.x<t.x+.5*t.width){const o=new m(t.x-M,t.y+t.height+M),i=L.computeLLinePoints(n,o,!1),a=L.computeLLinePoints(o,e,!1);return a.shift(),[...i,...a]}else{const o=new m(t.x+t.width+M,t.y+t.height+M),i=L.computeLLinePoints(n,o,!1),a=L.computeLLinePoints(o,e,!1);return a.shift(),[...i,...a]}const s=new m(e.x,t.y+t.height+M);return[...L.computeLLinePoints(n,s,!0),e]}left(e,t){const n=this.startPoint;if(e.x>n.x)return L.computeZLinePoints(n,e,!1);if(T.inDistance(n.y,t.y,t.height))if(n.y<t.y+.5*t.height){const o=new m(t.x-M,t.y-M),i=L.computeLLinePoints(n,o,!0),a=L.computeLLinePoints(o,e,!0);return a.shift(),[...i,...a]}else{const o=new m(t.x-M,t.y+t.height+M),i=L.computeLLinePoints(n,o,!0),a=L.computeLLinePoints(o,e,!0);return a.shift(),[...i,...a]}const s=new m(t.x-M,e.y);return[...L.computeLLinePoints(n,s,!1),e]}right(e,t){const n=this.startPoint;if(e.x<n.x)return L.computeZLinePoints(n,e,!1);if(T.inDistance(n.y,t.y,t.height))if(n.y<t.y+.5*t.height){const o=new m(t.x+t.width+M,t.y-M),i=L.computeLLinePoints(n,o,!0),a=L.computeLLinePoints(o,e,!0);return a.shift(),[...i,...a]}else{const o=new m(t.x+t.width+M,t.y+t.height+M),i=L.computeLLinePoints(n,o,!0),a=L.computeLLinePoints(o,e,!0);return a.shift(),[...i,...a]}const s=new m(t.x+t.width+M,e.y);return[...L.computeLLinePoints(n,s,!1),e]}toPoint(e){return T.computePolyLinePoints(this.startPoint,e)}top(e,t){const n=this.startPoint;if(e.y>n.y)return L.computeZLinePoints(n,e,!0);if(T.inDistance(n.x,t.x,t.width))if(n.x<t.x+.5*t.width){const o=new m(t.x-M,t.y-M),i=L.computeLLinePoints(n,o,!1),a=L.computeLLinePoints(o,e,!1);return a.shift(),[...i,...a]}else{const o=new m(t.x+t.width+M,t.y-M),i=L.computeLLinePoints(n,o,!1),a=L.computeLLinePoints(o,e,!1);return a.shift(),[...i,...a]}const s=new m(e.x,t.y-M);return[...L.computeLLinePoints(n,s,!0),e]}}class Ih extends ws{constructor(t,n){super(t);g(this,"rect");this.rect=n}bottom(t,n){const s=this.startPoint;if(t.y+M<this.rect.y&&T.inDistance(t.x,this.rect.x,this.rect.width))if(t.x>this.rect.x+.5*this.rect.width){const i=new m(this.rect.x+this.rect.width+M,this.rect.y+this.rect.height+M),a=new m(t.x,n.y+n.height+M),c=L.computeLLinePoints(s,i,!0),h=L.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,t]}else{const i=new m(this.rect.x-M,this.rect.y+this.rect.height+M),a=new m(t.x,n.y+n.height+M),c=L.computeLLinePoints(s,i,!0),h=L.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,t]}if(s.y+M<n.y&&T.inDistance(s.x,n.x,n.width)){if(s.x<n.x+.5*n.width){const d=new m(n.x-M,this.rect.y+this.rect.height+M),u=new m(t.x,n.y+n.height+M),p=L.computeLLinePoints(s,d,!0),f=L.computeLLinePoints(d,u,!0);return f.shift(),[...p,...f,t]}const i=new m(n.x+n.width+M,this.rect.y+this.rect.height+M),a=new m(t.x,n.y+n.height+M),c=L.computeLLinePoints(s,i,!0),h=L.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,t]}const r=new m(t.x,Math.max(n.y+n.height+M,this.rect.y+this.rect.height+M));return[...L.computeLLinePoints(s,r,!0),t]}left(t,n){const s=this.startPoint;if(t.x>s.x&&t.y>s.y)return L.computeLLinePoints(s,t,!0);if(t.x>this.rect.x+this.rect.width+M&&t.y<s.y){const a=new m(this.rect.x+this.rect.width+M,this.rect.y+this.rect.height+M),c=L.computeLLinePoints(s,a,!0),h=L.computeLLinePoints(a,t,!0);return h.shift(),[...c,...h]}if(t.x<this.rect.x+this.rect.width+M){const a=new m(Math.min(n.x-M,this.rect.x-M),Math.max(n.y+n.height+M,this.rect.y+this.rect.height+M)),c=L.computeLLinePoints(s,a,!0),h=L.computeLLinePoints(a,t,!0);return h.shift(),[...c,...h]}const r=new m(n.x-M,n.y-M),o=L.computeLLinePoints(s,r,!0),i=L.computeLLinePoints(r,t,!0);return i.shift(),[...o,...i]}right(t,n){const s=this.startPoint;if(t.x<s.x&&t.y>s.y)return L.computeLLinePoints(s,t,!0);if(n.x+n.width>this.rect.x-M){if(n.y<this.rect.y+this.rect.height+M){const a=new m(Math.max(n.x+n.width+M,this.rect.x+this.rect.width+M),Math.max(this.rect.y+this.rect.height+M,n.y+n.height+M)),c=L.computeLLinePoints(s,a,!0),h=L.computeLLinePoints(a,t,!0);return h.shift(),[...c,...h]}const r=new m(n.x+n.width+M,this.rect.y+this.rect.height+M),o=L.computeLLinePoints(s,r,!0),i=L.computeLLinePoints(r,t,!0);return i.shift(),[...o,...i]}if(t.y<this.rect.y+this.rect.height+M){const r=new m(this.rect.x-M,this.rect.y+this.rect.height+M),o=L.computeLLinePoints(s,r,!0),i=L.computeLLinePoints(r,t,!0);return i.shift(),[...o,...i]}return L.computeLLinePoints(s,t,!0)}toPoint(t){const n=this.startPoint;if(t.y>n.y)return L.computeZLinePoints(n,t,!0);if(T.inDistance(t.x,this.rect.x,this.rect.width))if(t.x<this.rect.x+.5*this.rect.width){const o=new m(this.rect.x-M,this.rect.y+this.rect.height+M),i=L.computeLLinePoints(n,o,!0),a=L.computeLLinePoints(o,t,!0);return a.shift(),[...i,...a]}else{const o=new m(this.rect.x+this.rect.width+M,this.rect.y+this.rect.height+M),i=L.computeLLinePoints(n,o,!0),a=L.computeLLinePoints(o,t,!0);return a.shift(),[...i,...a]}const s=new m(n.x,this.rect.y+this.rect.height+M),r=L.computeLLinePoints(s,t,!1);return[n,...r]}top(t,n){const s=this.startPoint;if(t.y>s.y)return L.computeZLinePoints(s,t,!0);if(n.x+n.width+M<this.rect.x){const c=new m(n.x+n.width+M,this.rect.y+this.rect.height+M),h=new m(t.x,n.y-M),d=L.computeLLinePoints(s,c,!0),u=L.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,t]}if(n.x+n.width<s.x){const c=new m(n.x+-M,this.rect.y+this.rect.height+M),h=new m(t.x,n.y-M),d=L.computeLLinePoints(s,c,!0),u=L.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,t]}if(n.x>this.rect.x+this.rect.width+M){const c=new m(n.x-M,this.rect.y+this.rect.height+M),h=new m(t.x,n.y-M),d=L.computeLLinePoints(s,c,!0),u=L.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,t]}const r=new m(Math.max(n.x+n.width+M,this.rect.x+this.rect.width+M),this.rect.y+this.rect.height+M),o=new m(t.x,n.y-M),i=L.computeLLinePoints(s,r,!0),a=L.computeLLinePoints(r,o,!0);return a.shift(),[...i,...a,t]}}class kh extends ws{constructor(t,n){super(t);g(this,"rect");this.rect=n}bottom(t,n){const s=this.startPoint;if(t.y<s.y){if(t.x<s.x)return L.computeLLinePoints(s,t,!1);const a=new m(this.rect.x-M,n.y+n.height+M),c=L.computeLLinePoints(s,a,!1),h=L.computeLLinePoints(a,t,!1);return h.shift(),[...c,...h]}if(t.y>s.y&&t.x<s.x){const a=new m(this.rect.x-M,t.y+M),c=L.computeLLinePoints(s,a,!1),h=L.computeLLinePoints(a,t,!1);return h.shift(),[...c,...h]}const r=new m(this.rect.x-M,t.y+M),o=L.computeLLinePoints(s,r,!1),i=L.computeLLinePoints(r,t,!1);return i.shift(),[...o,...i]}left(t,n){const s=this.startPoint;if(t.y<this.rect.y){const i=new m(Math.min(this.rect.x-M,n.x-M),t.y);return[...L.computeLLinePoints(s,i,!1),t]}if(t.y>this.rect.y+this.rect.height){const i=new m(Math.min(this.rect.x-M,n.x-M),t.y);return[...L.computeLLinePoints(s,i,!1),t]}if(t.y<this.rect.y+this.rect.height&&t.x>this.rect.x+this.rect.width){const i=new m(this.rect.x-M,this.rect.y-M),a=new m(n.x-M,t.y),c=L.computeLLinePoints(s,i,!1),h=L.computeLLinePoints(i,a,!1);return h.shift(),[...c,...h,t]}const r=new m(Math.min(this.rect.x-M,n.x-M),t.y);return[...L.computeLLinePoints(s,r,!1),t]}right(t,n){const s=this.startPoint;if(t.x<s.x)return L.computeZLinePoints(s,t,!1);if(t.y<s.y){const c=new m(this.rect.x-M,n.y+n.height+M),h=new m(n.x+n.width+M,t.y),d=L.computeLLinePoints(s,c,!1),u=L.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,t]}const r=new m(this.rect.x-M,n.y-M),o=new m(n.x+n.width+M,t.y),i=L.computeLLinePoints(s,r,!1),a=L.computeLLinePoints(r,o,!1);return a.shift(),[...i,...a,t]}toPoint(t){const n=this.startPoint;if(t.x>n.x&&t.y<this.rect.y){const o=new m(this.rect.x-M,t.y);return[...L.computeLLinePoints(n,o,!1),t]}if(t.x>n.x&&t.y>this.rect.y&&t.y<n.y){const o=new m(this.rect.x-M,this.rect.y-M),i=L.computeLLinePoints(n,o,!1),a=L.computeLLinePoints(o,t,!1);return a.shift(),[...i,...a]}if(t.x>n.x&&t.y>n.y&&t.y<this.rect.y+this.rect.height){const o=new m(this.rect.x-M,this.rect.y+this.rect.height+M),i=L.computeLLinePoints(n,o,!1),a=L.computeLLinePoints(o,t,!1);return a.shift(),[...i,...a]}if(t.x<n.x)return L.computeZLinePoints(n,t,!1);const s=new m(this.rect.x-M,t.y);return[...L.computeLLinePoints(n,s,!1),t]}top(t,n){const s=this.startPoint;if(t.x>s.x&&t.y<this.rect.y+this.rect.height+M){const r=new m(this.rect.x-M,Math.min(this.rect.y-M,n.y-M)),o=L.computeLLinePoints(s,r,!1),i=L.computeLLinePoints(r,t,!1);return i.shift(),[...o,...i]}if(t.y<s.y+2&&t.x<s.x){const r=new m(this.rect.x-M,n.y-M),o=L.computeLLinePoints(s,r,!1),i=L.computeLLinePoints(r,t,!1);return i.shift(),[...o,...i]}if(t.x>s.x&&t.y>this.rect.y+this.rect.height+M){const r=new m(this.rect.x-M,this.rect.y+this.rect.height+M),o=L.computeLLinePoints(s,r,!1),i=L.computeLLinePoints(r,t,!1);return i.shift(),[...o,...i]}return L.computeLLinePoints(s,t,!1)}}class Bh extends ws{constructor(t,n){super(t);g(this,"rect");this.rect=n}bottom(t,n){const s=this.startPoint;if(t.x>s.x){if(t.y<s.y)return L.computeLLinePoints(s,t,!1);const a=new m(this.rect.x+this.rect.width+M,n.y+n.height+M),c=L.computeLLinePoints(s,a,!1),h=L.computeLLinePoints(a,t,!1);return h.shift(),[...c,...h]}if(t.y<this.rect.y){const a=new m(this.rect.x+this.rect.width+M,n.y+n.height+M),c=L.computeLLinePoints(s,a,!1),h=L.computeLLinePoints(a,t,!1);return h.shift(),[...c,...h]}const r=new m(this.rect.x+this.rect.width+M,Math.max(n.y+n.height+M,this.rect.y+this.rect.height+M)),o=L.computeLLinePoints(s,r,!1),i=L.computeLLinePoints(r,t,!1);return i.shift(),[...o,...i]}left(t,n){const s=this.startPoint;if(t.x>s.x)return L.computeZLinePoints(s,t,!1);if(t.y<this.rect.y){const c=new m(this.rect.x+this.rect.width+M,n.y+n.height+M),h=new m(n.x-M,t.y),d=L.computeLLinePoints(s,c,!1),u=L.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,t]}if(t.y>this.rect.y+this.rect.height){const c=new m(this.rect.x+this.rect.width+M,n.y-M),h=new m(n.x-M,t.y),d=L.computeLLinePoints(s,c,!1),u=L.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,t]}if(t.y<this.rect.y+.5*this.rect.height){const c=new m(this.rect.x+this.rect.width+M,Math.min(n.y-M,this.rect.y-M)),h=new m(n.x-M,t.y),d=L.computeLLinePoints(s,c,!1),u=L.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,t]}const r=new m(this.rect.x+this.rect.width+M,Math.max(n.y+n.height+M,this.rect.y+this.rect.height+M)),o=new m(n.x-M,t.y),i=L.computeLLinePoints(s,r,!1),a=L.computeLLinePoints(r,o,!1);return a.shift(),[...i,...a,t]}right(t,n){const s=this.startPoint;if(t.y<this.rect.y||t.y>this.rect.y+this.rect.height){const c=new m(Math.max(n.x+n.width+M,this.rect.x+this.rect.width+M),t.y);return[...L.computeLLinePoints(s,c,!1),t]}if(t.y<this.rect.y+.5*this.rect.height){const c=new m(this.rect.x+this.rect.width+M,this.rect.y-M),h=new m(n.x+n.width+M,t.y),d=L.computeLLinePoints(s,c,!1),u=L.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,t]}const r=new m(this.rect.x+this.rect.width+M,this.rect.y+this.rect.height+M),o=new m(n.x+n.width+M,t.y),i=L.computeLLinePoints(s,r,!1),a=L.computeLLinePoints(r,o,!1);return a.shift(),[...i,...a,t]}toPoint(t){const n=this.startPoint;if(t.x>n.x)return L.computeZLinePoints(n,t,!1);if(t.y<this.rect.y||t.y>this.rect.y+this.rect.height){const i=new m(this.rect.x+this.rect.width+M,t.y);return[...L.computeLLinePoints(n,i,!1),t]}if(t.y<this.rect.y+.5*this.rect.height){const i=new m(this.rect.x+this.rect.width+M,this.rect.y-M),a=L.computeLLinePoints(n,i,!1),c=L.computeLLinePoints(i,t,!1);return c.shift(),[...a,...c]}const s=new m(this.rect.x+this.rect.width+M,this.rect.y+this.rect.height+M),r=L.computeLLinePoints(n,s,!1),o=L.computeLLinePoints(s,t,!1);return o.shift(),[...r,...o]}top(t,n){const s=this.startPoint;if(t.y>s.y&&t.x>s.x)return L.computeLLinePoints(s,t,!1);if(t.y>this.rect.y+this.rect.height){const a=new m(this.rect.x+this.rect.width+M,this.rect.y+this.rect.height+M),c=L.computeLLinePoints(s,a,!1),h=L.computeLLinePoints(a,t,!1);return h.shift(),[...c,...h]}if(n.x<this.rect.x+this.rect.width+M){const a=new m(Math.max(this.rect.x+this.rect.width+M,n.x+n.width+M),Math.min(n.y-M,this.rect.y-M)),c=L.computeLLinePoints(s,a,!1),h=L.computeLLinePoints(a,t,!1);return h.shift(),[...c,...h]}const r=new m(this.rect.x+this.rect.width+M,n.y-M),o=L.computeLLinePoints(s,r,!1),i=L.computeLLinePoints(r,t,!1);return i.shift(),[...o,...i]}}class $t{static mockPointermoveEvent(e){return{pointerId:1,width:1,height:1,pressure:.5,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,type:"pointermove",pointerType:"mouse",isPrimary:!0,bubbles:!0,cancelable:!0,composed:!0,clientX:e.x,clientY:e.y}}static getNodePos(e,{x:t,y:n}){const s=new m,{width:r,height:o}=e.baseProps;return s.x=t*r,s.y=n*o,e.toGlobal(s)}static computeConnectInfo(e,t,n,s=!1){const r=e.globalLinePoints,o={point:s?r[r.length-1]:r[0]};if(t){const i=n.nodeManager.getNode(t.objectId);i&&(o.nodeConnect={rect:D.rectNode2Rect(i.getBounds()),endType:T.computeNodeConnectEnd(t,i.baseProps.angle)},o.point=this.getNodePos(i,t))}return o}static computeLinePoints(e,t,n,s,r){const o=s.detect(W.NodeEdge,n),a={point:r.alignLineEndAndDrawAlignLines(n,s)};return o&&(a.point=new m(o.point.x,o.point.y),a.nodeConnect={rect:D.rectNode2Rect(o.node.getBounds()),endType:T.computeNodeConnectEnd(o.relativePos,o.node.baseProps.angle)}),t.layoutToPointsPro(e,a)}static trimAngle(e){const t=Math.floor(e/360);return e-t*360}static calculateAngle(e,t){return Math.abs(e.x-t.x)<.01?t.y>e.y?90:-90:Math.atan2(t.y-e.y,t.x-e.x)/Math.PI*180}static calculateAngle2(e,t){return Math.abs(e.x-t.x)<.01?t.y>e.y?.5*Math.PI:-.5*Math.PI:Math.atan2(t.y-e.y,t.x-e.x)}static trimPoint(e){return new m(Math.floor(e.x),Math.floor(e.y))}static overlapHorizonVertical(e,t,n){if($t.judgeHorizon(e,t)){if(e.y<n.minY||e.y>n.maxY)return!1;const r=e.x>t.x?t.x:e.x,o=e.x<t.x?t.x:e.x;if(r>n.maxX||o<n.minX)return!1}else{if(e.x<n.minX||e.x>n.maxX)return!1;const r=e.y>t.y?t.y:e.y,o=e.y<t.y?t.y:e.y;if(r>n.maxY||o<n.minY)return!1}return!0}static overlapHorizon(e,t,n,s,r){const o=s.y>r.y?r.y:s.y,i=s.y<r.y?r.y:s.y;if(o>n||i<n)return!1;const a=s.x>r.x?r.x:s.x,c=s.x<r.x?r.x:s.x;return!(a>t||c<e)}static overlapVertical(e,t,n,s,r){const o=s.x>r.x?r.x:s.x,i=s.x<r.x?r.x:s.x;if(o>n||i<n)return!1;const a=s.y>r.y?r.y:s.y,c=s.y<r.y?r.y:s.y;return!(a>t||c<e)}static overlapSimpleLine(e,t,n){if(this.overlapHorizon(n.minX,n.maxX,n.minY,e,t)||this.overlapHorizon(n.minX,n.maxX,n.maxY,e,t)||this.overlapVertical(n.minY,n.maxY,n.maxX,e,t)||this.overlapVertical(n.minY,n.maxY,n.minX,e,t))return!0;const s=e.x>t.x?t.x:e.x,r=e.x<t.x?t.x:e.x,o=e.y>t.y?t.y:e.y,i=e.y<t.y?t.y:e.y;return r<=n.maxX&&s>=n.minX&&i<=n.maxY&&o>=n.minY}static overlapPolyLine(e,t){for(let n=0;n<e.length-1;n++){const s=e[n],r=e[n+1];if(this.overlapHorizonVertical(s,r,t))return!0}return!1}static interactRect(e,t){return{minX:Math.max(e.minX,t.minX),maxX:Math.min(e.maxX,t.maxX),minY:Math.max(e.minY,t.minY),maxY:Math.min(e.maxY,t.maxY)}}static needDrawByDelete(e,t,n,s,r){const o=e.nodeManager.tree.search(t),i=new Set;for(const c of o){const h=e.nodeManager.nodeMap.get(c.id);h&&i.add(h)}r||i.add(s);const a=[...i];return a.sort((c,h)=>c.zIndex-h.zIndex),a}static layout(e,t){const n=[];return T.doubleMiddleInsertPoint(e,t,n),n}static judgeHorizon(e,t,n=.01){return Math.abs(e.y-t.y)<n}static judgeVertical(e,t,n=.01){return Math.abs(e.x-t.x)<n}static getOfflineCanvas(e,t,n){const s=D.rectNode2Rect(e),r=document.createElement("canvas");r.width=n*s.width,r.height=n*s.height;const o=r.getContext("2d");o.scale(n,n),o.translate(-s.x,-s.y);const i=t.searchNodesByRectNode(e);for(const a of i)a.drawOnGLCtx(o);return r}}class ta{constructor(e){g(this,"modes",[]);g(this,"currentMode");this.modes=e.modes,this.currentMode=e.modes[e.modes.length-1]}onEvent(e,t){this.reset(e,t);const n=this.convertInteractiveEvent(e,t);this.detect(n,t),this.currentMode.work(n,t),this.afterOnEvent(n,t)}refreshEvent(e){const t=e.lastInteractiveEvent.originEvent,n=new m(t.clientX,t.clientY),s=$t.mockPointermoveEvent(n);s.target=e.gmlRender.canvas,this.onEvent(s,e)}detect(e,t){if(this.currentMode.canBeExit(e,t)){for(const n of this.modes)if(n.canBeEnable(e,t)){this.currentMode=n;return}}}reset(e,t){var n;t.reset();for(const[s,r]of t.detectors)r.reset();e.type!==((n=t.lastInteractiveEvent)==null?void 0:n.type)&&(t.lastDiffTypeEvent=t.lastInteractiveEvent)}afterOnEvent(e,t){this.record(e,t)}record(e,t){t.lastInteractiveEvent=e}convertInteractiveEvent(e,t){const n=t.gmlRender.canvas.getBoundingClientRect(),s=new m(e.clientX-n.x,e.clientY-n.y),r=t.gmlRender.transformToGlobal(s);return{clientPoint:new m(e.clientX,e.clientY),globalPoint:r,type:this.convertEventType(e,t),originEvent:e}}convertEventType(e,t){const n=e.type;return n==="pointerdown"?yt.pointerDown:n==="pointermove"?e.target!=t.gmlRender.canvas?yt.pointermoveOutside:yt.pointermove:n==="pointerup"?yt.pointerup:yt.unknown}}class _s{constructor(e,t){g(this,"eventCtx");g(this,"interactiveManager");g(this,"onContextMenu",e=>{e.preventDefault()});g(this,"onPointerDown",e=>{this.triggerEvent(e)});g(this,"onPointerMove",e=>{this.triggerEvent(e)});g(this,"onPointerUp",e=>{this.triggerEvent(e)});this.eventCtx=e,this.interactiveManager=new ta(t)}start(){document.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("contextmenu",this.onContextMenu)}stop(){document.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("contextmenu",this.onContextMenu)}triggerEvent(e){this.onEnable(e)&&(this.interactiveManager.onEvent(e,this.eventCtx),this.afterEvent())}onEnable(e){return!(e.type!=="pointermove"&&e.target!==this.eventCtx.gmlRender.canvas)}afterEvent(){}}const jr=8,Ks=8,js=500;var It=(l=>(l[l.width=0]="width",l[l.height=1]="height",l[l.both=2]="both",l))(It||{});const Cn=new Set([A.Line,A.Group]);class Ln{}class ea extends Ln{align(e,t,n,s,r,o){const i={minX:s.minX,maxX:s.maxX,minY:n.minY-o,maxY:n.minY+o},a=e.nodeManager.searchNodesByRectNode(i),c=[];for(const p of a){if(t.has(p)||Cn.has(p.type))continue;const f=p.getBounds();if(Math.abs(n.minY-f.minY)<o){let y;n.minX<f.minX?y={start:new m(n.minX,f.minY),end:new m(f.minX,f.minY)}:y={start:new m(f.maxX,f.minY),end:new m(n.minX,f.minY)},c.push({line:y,dx:0,dy:f.minY-n.minY})}if(Math.abs(n.minY-f.maxY)<o){let y;n.minX<f.minX?y={start:new m(n.minX,f.maxY),end:new m(f.minX,f.maxY)}:y={start:new m(f.maxX,f.maxY),end:new m(n.minX,f.maxY)},c.push({line:y,dx:0,dy:f.maxY-n.minY})}}if(c.length===0)return;const h=c.map(p=>p.dy),d=Math.min(...h),u={dx:0,dy:d,lines:[]};for(const p of c)Math.abs(p.dy-d)<.01&&u.lines.push(p.line);r.top=u}}class na extends Ln{align(e,t,n,s,r,o=2){const i={minX:s.minX,maxX:s.maxX,minY:n.maxY-o,maxY:n.maxY+o},a=e.nodeManager.searchNodesByRectNode(i),c=[];for(const p of a){if(t.has(p)||Cn.has(p.type))continue;const f=p.getBounds();if(Math.abs(n.maxY-f.minY)<o){let y;n.minX<f.minX?y={start:new m(n.minX,f.minY),end:new m(f.minX,f.minY)}:y={start:new m(f.maxX,f.minY),end:new m(n.minX,f.minY)},c.push({line:y,dx:0,dy:f.minY-n.maxY})}if(Math.abs(n.maxY-f.maxY)<o){let y;n.minX<f.minX?y={start:new m(n.minX,f.maxY),end:new m(f.minX,f.maxY)}:y={start:new m(f.maxX,f.maxY),end:new m(n.minX,f.maxY)},c.push({line:y,dx:0,dy:f.maxY-n.maxY})}}if(c.length===0)return;const h=c.map(p=>p.dy),d=Math.min(...h),u={dx:0,dy:d,lines:[]};for(const p of c)Math.abs(p.dy-d)<.01&&u.lines.push(p.line);r.bottom=u}}class sa extends Ln{align(e,t,n,s,r,o){const i={minX:n.minX-o,maxX:n.minX+o,minY:s.minY,maxY:s.maxY},a=e.nodeManager.searchNodesByRectNode(i),c=[];for(const p of a){if(t.has(p)||Cn.has(p.type))continue;const f=p.getBounds();if(Math.abs(n.minX-f.minX)<o){let y;n.minY<f.minY?y={start:new m(f.minX,n.maxY),end:new m(f.minX,f.minY)}:y={start:new m(f.minX,f.maxY),end:new m(f.minX,n.minY)},c.push({line:y,dy:0,dx:f.minX-n.minX})}if(Math.abs(n.minX-f.maxX)<o){let y;n.minX<f.minX?y={start:new m(f.maxX,n.maxY),end:new m(f.maxX,f.minY)}:y={start:new m(f.maxX,f.maxY),end:new m(f.maxX,n.minY)},c.push({line:y,dy:0,dx:f.maxX-n.minX})}}if(c.length===0)return;const h=c.map(p=>p.dx),d=Math.min(...h),u={dy:0,dx:d,lines:[]};for(const p of c)Math.abs(p.dx-d)<.01&&u.lines.push(p.line);r.left=u}}class ra extends Ln{align(e,t,n,s,r,o){const i={minX:n.maxX-o,maxX:n.maxX+o,minY:s.minY,maxY:s.maxY},a=e.nodeManager.searchNodesByRectNode(i),c=[];for(const p of a){if(t.has(p)||Cn.has(p.type))continue;const f=p.getBounds();if(Math.abs(n.maxX-f.minX)<o){let y;n.minY<f.minY?y={start:new m(f.minX,n.maxY),end:new m(f.minX,f.minY)}:y={start:new m(f.minX,f.maxY),end:new m(f.minX,n.minY)},c.push({line:y,dy:0,dx:f.minX-n.maxX})}if(Math.abs(n.maxX-f.maxX)<o){let y;n.maxX<f.minX?y={start:new m(f.maxX,n.maxY),end:new m(f.maxX,f.minY)}:y={start:new m(f.maxX,f.maxY),end:new m(f.maxX,n.minY)},c.push({line:y,dy:0,dx:f.maxX-n.maxX})}}if(c.length===0)return;const h=c.map(p=>p.dx),d=Math.min(...h),u={dy:0,dx:d,lines:[]};for(const p of c)Math.abs(p.dx-d)<.01&&u.lines.push(p.line);r.right=u}}class Oh extends Ln{align(e,t,n,s,r,o){const i=.5*(n.minY+n.maxY),a={minX:s.minX,maxX:s.maxX,minY:i-o,maxY:i+o},c=e.nodeManager.searchNodesByRectNode(a),h=[];for(const f of c){if(t.has(f)||Cn.has(f.type))continue;const y=f.getBounds(),w=.5*(y.minY+y.maxY);if(Math.abs(i-w)<o){const b=Math.min(n.minX,n.maxX,y.maxX,y.minX),x=Math.max(n.minX,n.maxX,y.maxX,y.minX),v={start:new m(b,w),end:new m(x,w)};h.push({line:v,dx:0,dy:w-i})}}if(h.length===0)return;const d=h.map(f=>f.dy),u=Math.min(...d),p={dx:0,dy:u,lines:[]};for(const f of h)Math.abs(f.dy-u)<.01&&p.lines.push(f.line);r.horizonMid=p}}class Dh extends Ln{align(e,t,n,s,r,o){const i=.5*(n.minX+n.maxX),a={minX:i-o,maxX:i+o,minY:s.minY,maxY:s.maxY},c=e.nodeManager.searchNodesByRectNode(a),h=[];for(const f of c){if(t.has(f)||Cn.has(f.type))continue;const y=f.getBounds(),w=.5*(y.minX+y.maxX);if(Math.abs(i-w)<o){const b=Math.min(n.minY,n.maxY,y.maxY,y.minY),x=Math.max(n.minY,n.maxY,y.maxY,y.minY),v={start:new m(w,b),end:new m(w,x)};h.push({line:v,dx:w-i,dy:0})}}if(h.length===0)return;const d=h.map(f=>f.dx),u=Math.min(...d),p={dx:u,dy:0,lines:[]};for(const f of h)Math.abs(f.dx-u)<.01&&p.lines.push(f.line);r.verticalMid=p}}class oa{constructor(){g(this,"handlers",[new ea,new Oh,new na,new sa,new Dh,new ra])}align(e,t,n){const s=n.gmlRender.getViewPortBounds(),r=jr/n.gmlRender.getScale(),o=new Set;for(const a of t)this.computeFilterSet(a,o);const i={};for(const a of this.handlers)a.align(n,o,e,s,i,r);return this.dealAlignTopBottom(i),this.dealAlignLeftRight(i),i}computeFilterSet(e,t){t.add(e);const n=e.children;for(const s of n)this.computeFilterSet(s,t)}dealAlignTopBottom(e){const{top:t,bottom:n,horizonMid:s}=e,r=[t,s,n].map(i=>i==null?void 0:i.dy).filter(i=>i!==void 0);if(r.length===0)return;const o=Math.min(...r);for(const i of["top","bottom","horizonMid"]){const a=e[i];a&&Math.abs(o-a.dy)>.01&&(e[i]=void 0)}}dealAlignLeftRight(e){const{left:t,right:n,verticalMid:s}=e,r=[t,n,s].map(i=>i==null?void 0:i.dx).filter(i=>i!==void 0);if(r.length===0)return;const o=Math.min(...r);for(const i of["left","right","verticalMid"]){const a=e[i];a&&Math.abs(o-a.dx)>.01&&(e[i]=void 0)}if(t&&n){if(Math.abs(t.dx-n.dx)<.01)return;t.dx<n.dx?e.right=void 0:e.left=void 0}}}const qr=new Set([A.Group,A.Line]);class $r{}class ia extends $r{enable(e){return e===It.both||e===It.width}align(e,t,n,s,r,o,i,a){const c=n.maxX-n.minX,h=this.searchNodes(e,c,r,n,s,o,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),p=[];for(const y of h)Math.abs(y.dt-u)<.01&&p.push(y.info);const f={dt:u,sideSize:c,lines:p};t.width=f}searchNodes(e,t,n,s,r,o,i,a){let c=200;const h={minX:s.minX-c,maxX:s.maxX+c,minY:s.minY-c,maxY:s.maxY+c},d=[];for(;d.length===0&&!(c>i||T.containRect(h,o));){const u=this.searchNodesForOffset(e,t,n,h,r,o,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(e,t,n,s,r,o,i,a){const c=e.nodeManager.searchNodesByRectNode(o),h=[];for(const d of c){if(r.has(d)||qr.has(d.type))continue;const{width:u,height:p,angle:f}=d.baseProps,y=f%360;if(!(Math.abs(y)>30)&&Math.abs(u-t)<a){const w={x:0,y:p},b={x:u,y:p};h.push({dt:u-t,sideSize:u,info:{line:{start:w,end:b},transform:d.globalTransform().clone()}})}}return h}}class aa extends $r{enable(e){return e===It.both||e===It.height}align(e,t,n,s,r,o,i,a){const c=n.maxY-n.minY,h=this.searchNodes(e,c,r,n,s,o,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),p=[];for(const y of h)Math.abs(y.dt-u)<.01&&p.push(y.info);const f={dt:u,sideSize:c,lines:p};t.height=f}searchNodes(e,t,n,s,r,o,i,a){let c=200;const h={minX:s.minX-c,maxX:s.maxX+c,minY:s.minY-c,maxY:s.maxY+c},d=[];for(;d.length===0&&!(c>i||T.containRect(h,o));){const u=this.searchNodesForOffset(e,t,n,h,r,o,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(e,t,n,s,r,o,i,a){const c=e.nodeManager.searchNodesByRectNode(o),h=[];for(const d of c){if(r.has(d)||qr.has(d.type))continue;const{width:u,height:p,angle:f}=d.baseProps,y=f%360;if(!(Math.abs(y)>30)&&Math.abs(p-t)<a){const w={x:u,y:0},b={x:u,y:p};h.push({dt:p-t,sideSize:p,info:{line:{start:w,end:b},transform:d.transform.clone()}})}}return h}}class ca{constructor(){g(this,"handlers",[new ia,new aa])}align(e,t,n,s,r,o,i){const a={};for(const c of this.handlers)c.enable(s)&&c.align(e,a,t,n,s,r,o,i);return a}}class la{}class Hh extends la{align(e,t,n,s,r,o){const i={minX:s.minX,maxX:s.maxX,minY:n.y-o,maxY:n.y+o},a=e.nodeManager.searchNodesByRectNode(i),c=[];for(const p of a){if(t.has(p)||p.type===A.Line||p.type===A.Group)continue;const f=p.getBounds(),y=[f.minY,f.maxY];for(const w of y)if(Math.abs(n.y-w)<o){const b=Math.min(n.x,f.minX,f.maxX),x=Math.max(n.x,f.minX,f.maxX),v={start:new m(b,w),end:new m(x,w)};c.push({line:v,dx:0,dy:w-n.y})}}if(c.length===0)return;const h=c.map(p=>p.dy),d=Math.min(...h),u={dx:0,dy:d,lines:[]};for(const p of c)Math.abs(p.dy-d)<.01&&u.lines.push(p.line);r.horizon=u}}class zh extends la{align(e,t,n,s,r,o){const i={minY:s.minY,maxY:s.maxY,minX:n.x-o,maxX:n.x+o},a=e.nodeManager.searchNodesByRectNode(i),c=[];for(const p of a){if(t.has(p)||p.type===A.Line||p.type===A.Group)continue;const f=p.getBounds(),y=[f.minX,f.maxX];for(const w of y)if(Math.abs(n.x-w)<o){const b=Math.min(n.y,f.minY,f.maxY),x=Math.max(n.y,f.minY,f.maxY),v={start:new m(w,b),end:new m(w,x)};c.push({line:v,dx:w-n.x,dy:0})}}if(c.length===0)return;const h=c.map(p=>p.dx),d=Math.min(...h),u={dx:d,dy:0,lines:[]};for(const p of c)Math.abs(p.dx-d)<.01&&u.lines.push(p.line);r.vertical=u}}class Xh{constructor(){g(this,"handlers",[new Hh,new zh])}align(e,t,n){const s=n.gmlRender.getViewPortBounds(),r=jr/n.gmlRender.getScale(),o={};for(const i of this.handlers)i.align(n,t,e,s,o,r);return o}}class xs{static addAllParentToSet(e,t){let n=e.parent;for(;n&&n.type===A.Group;)t.add(n),n=n.parent}static findHoverNode(e,t){if(e.parent.type!==A.Group)return e;const n=new Set;for(const r of t)n.add(r.parent);let s=e.parent;if(n.has(s))return e;for(;s;){const r=s.parent;if(n.has(r))return s;if(r.type!==A.Group)break;s=r}return s}static flattenNodes(e){const t=new Set;for(const n of e)this.flattenGroupNodes(n,t);return[...t]}static flattenGroupNodes(e,t){if(e.type!==A.Group){t.add(e);return}const s=e.children;for(const r of s)this.flattenGroupNodes(r,t)}}class cn{constructor(){g(this,"alignMoveWorker",new oa);g(this,"alignStretchWorker",new ca);g(this,"alignLineEndWorker",new Xh)}alignLineEnd(e,t,n){return this.alignLineEndWorker.align(e,t,n)}alignMove(e,t,n){const s=new Set;for(const r of t)this.addChildrenToFilterSet(r,s);return this.alignMoveWorker.align(e,s,n)}alignStretch(e,t,n,s,r,o,i){const a=D.toRectNode(t),c=new Set(n);for(const d of[...n])xs.addAllParentToSet(d,c);return this.alignStretchWorker.align(e,a,c,s,r,o,i)}alignLineEndAndDrawAlignLines(e,t,n=t.getSelectNodes()){const s=e.globalPoint.clone(),r=this.alignLineEnd(s,n,t),o=[];return r.horizon&&(o.push(...r.horizon.lines),s.y+=r.horizon.dy),r.vertical&&(o.push(...r.vertical.lines),s.x+=r.vertical.dx),t.addOrUpdate(N.AlignLine,{lines:o}),s}drawAlignLines(e,t){const{top:n,bottom:s,horizonMid:r,right:o,left:i,verticalMid:a}=e,c=[],h=new m;return n&&(h.y=n.dy,c.push(...n.lines)),r&&(h.y=r.dy,c.push(...r.lines)),s&&(h.y=s.dy,c.push(...s.lines)),i&&(h.x=i.dx,c.push(...i.lines)),a&&(h.x=a.dx,c.push(...a.lines)),o&&(h.x=o.dx,c.push(...o.lines)),t.addOrUpdate(N.AlignLine,{lines:c}),h}addChildrenToFilterSet(e,t){t.add(e);const n=e.children;for(const s of n)this.addChildrenToFilterSet(s,t)}}class ee{}class Ve{constructor(e){g(this,"processors",[]);this.processors=e}work(e,t){for(const n of this.processors)n.allowEventTypeSet.has(e.type)&&n.process(e,t)}stop(e,t){for(const n of this.processors)n.stop&&n.stop(e,t)}isStreaming(){return!1}}class ln extends Ve{constructor(t){super(t);g(this,"deltaDistance",1);g(this,"locked",!1)}clickEnable(t,n){return!0}canBeEnable(t,n){if(t.type!==yt.pointerDown)return!1;const s=this.clickEnable(t,n);return s&&(this.locked=!0),s}work(t,n){t.type===yt.pointerup&&(this.locked=!1),T.distance(n.lastDiffTypeEvent.globalPoint,t.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),super.work(t,n)}canBeExit(t,n){const s=!this.locked;return s&&this.stop(t,n),s}}class We{constructor(){g(this,"downHandlers",[]);g(this,"upHandlers",[]);g(this,"hasWorking",!1);g(this,"allowEventTypeSet",new Set([yt.pointerDown,yt.pointerup]))}registerDownHandler(e){this.downHandlers.push(e)}registerUpHandler(e){this.upHandlers.push(e)}process(e,t){this.downProcess(e,t),this.upProcess(e,t)}stop(e,t){this.hasWorking=!1}downProcess(e,t){if(e.type===yt.pointerDown){for(const n of this.downHandlers)if(n.enable(e,t)){this.hasWorking=!0,n.handle(e,t);return}}}upProcess(e,t){if(e.type===yt.pointerup){if(this.hasWorking){this.hasWorking=!1;return}for(const n of this.upHandlers)if(n.enable(e,t)){n.handle(e,t);return}}}}class Qr extends Ve{constructor(t){super(t);g(this,"deltaDistance",1);g(this,"locked",!1);g(this,"firstPointerDown",!1)}canBeEnable(t,n){return t.type===yt.pointerDown?this.firstPointerDown?(this.locked=!0,!0):(this.firstPointerDown=!0,setTimeout(()=>{this.firstPointerDown=!1},300),!1):!1}work(t,n){this.firstPointerDown&&t.type===yt.pointerup&&(this.locked=!1),t.type===yt.pointermove&&T.distance(n.lastInteractiveEvent.globalPoint,t.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),this.firstPointerDown||(this.locked=!1),super.work(t,n)}canBeExit(t,n){const s=!this.locked;return s&&this.stop(t,n),s}}class ae extends Ve{constructor(t,n=[]){super(n);g(this,"streamProcessor");g(this,"deltaDistance",1);g(this,"locked",!1);this.streamProcessor=t}onDown(t,n){}canBeEnable(t,n){var i;if(t.type===yt.pointerDown&&this.onDown(t,n),!(((i=n.lastDiffTypeEvent)==null?void 0:i.type)===yt.pointerDown&&t.type===yt.pointermove))return!1;const r=n.lastDiffTypeEvent.globalPoint;if(T.distance(r,t.globalPoint)<this.deltaDistance/n.gmlRender.getScale())return!1;const o=this.streamEnable(n.lastDiffTypeEvent,n);if(o){this.locked=!0;for(const a of this.streamProcessor)a.onStart(n.lastDiffTypeEvent,n)}return o}work(t,n){if(t.type===yt.pointermove)for(const s of this.streamProcessor)s.onMove(t,n);if(t.type===yt.pointerup){for(const s of this.streamProcessor)s.onUp(t,n);this.locked=!1}super.work(t,n)}canBeExit(t,n){const s=!this.locked;return s&&this.stop(t,n),s}isStreaming(){return this.locked}}class Kn{constructor(e){g(this,"currentSubMode");g(this,"subModes",[]);this.subModes=e,this.currentSubMode=e[e.length-1]}canBeExit(e,t){return this.currentSubMode.canBeExit(e,t)}work(e,t){this.detect(e,t),this.currentSubMode.work(e,t)}detect(e,t){if(this.currentSubMode.canBeExit(e,t)){for(const n of this.subModes)if(n.canBeEnable(e,t)){this.currentSubMode=n;return}}}}class qs extends Ve{constructor(t,n=[]){super(n);g(this,"streamProcessor");g(this,"locked",!1);this.streamProcessor=t}canBeEnable(t,n){if(t.type!==yt.pointerDown)return!1;const s=this.streamEnable(t,n);return s&&(this.locked=!0),s}work(t,n){if(t.type===yt.pointerDown)for(const s of this.streamProcessor)s.onStart(t,n);if(t.type===yt.pointermove)for(const s of this.streamProcessor)s.onMove(t,n);if(t.type===yt.pointerup){for(const s of this.streamProcessor)s.onUp(t,n);this.locked=!1}super.work(t,n)}canBeExit(t,n){const s=!this.locked;return s&&this.stop(t,n),s}isStreaming(){return this.locked}}class ge{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointerDown,yt.pointermove,yt.pointerup]))}process(e,t){}}const Yh=5;class ha{}class da extends ne{onDetect(e,t){if(t.detect(W.Stretch,e)||t.detect(W.Rotate,e)||t.detect(W.LineEndPoint,e))return!1;const o=e.globalPoint,i=t.nodeManager.searchNodes(o.x,o.y);let a=[];for(const c of i)c.type!==A.Group&&c.contains(e.globalPoint,t.gmlRender.getScale())&&a.push(c);return a.length===0?(this.result=null,!1):(a=T.sortGraphics(a),a.reverse(),this.result=a,!0)}}class ua extends ne{onDetect(e,t){const n=t.detect(W.Node,e);if(!n)return!1;const s=n[0];if(n.length===1&&t.auxiliaryManager.selectManager.include(s))return!1;if(e.originEvent.metaKey)return this.result=s,!0;const r=t.getSelectNodes(),o=xs.findHoverNode(s,r);return o?(this.result=o,!0):(this.result=s,!0)}}const Ar=class Ar extends ne{computeLocalPoint(e,t,n){if(e.length===1){const i=e[0],a=i.baseProps,c=i.toLocal(t.globalPoint),h=D.baseProps2Rect(a);return{localPoint:c,rect:h}}const s=n.auxiliaryManager.selectManager.getSelectBounds(),r=D.rectNode2Rect(s);return{localPoint:new m(t.globalPoint.x-r.x,t.globalPoint.y-r.y),rect:r}}onDetect(e,t){const n=t.auxiliaryManager.selectManager.selectNodes;if(n.size===0)return!1;const s=xs.flattenNodes([...n]),r=t.gmlRender.getScale(),o=Ar.HOT_DISTANCE/r,{rect:i,localPoint:a}=this.computeLocalPoint(s,e,t),c=new D(0,0,i.width,i.height),h=T.detectRectBounds(c,a,o);return h?(this.result={nodes:s,type:h.type},!0):!1}};g(Ar,"HOT_DISTANCE",8);let $s=Ar;class pa extends ge{constructor(){super(...arguments);g(this,"start",null)}onStart(t,n){const{renderText:s,node:r}=n.inputManager.editTextInfo,o=r.toLocal(t.globalPoint),i=s.detect(o);n.setCursor("text"),this.start=i,n.execAction(new nt)}onMove(t,n){const{renderText:s,node:r}=n.inputManager.editTextInfo,o=r.toLocal(t.globalPoint),i=s.detect(o);n.execAction(lt.selection(r.id,this.start,i))}onUp(t,n){const{renderText:s,node:r}=n.inputManager.editTextInfo,o=r.toLocal(t.globalPoint),i=s.detect(o);this.start.equal(i)?n.execAction(lt.focus(r.id,this.start)):n.execAction(lt.selection(r.id,this.start,i)),n.execAction(new et)}}class fa extends ae{constructor(){super([new pa])}streamEnable(e,t){const n=t.inputManager.editTextInfo;if(!n)return!1;const{node:s,renderText:r}=n,o=s.getTextContentRect(),i=s.toLocal(e.globalPoint);return!!T.rectContains(i,o)}}class Zr{constructor(){g(this,"parentGroupSet",new Set)}start(e){this.parentGroupSet.clear();for(const t of e)xs.addAllParentToSet(t,this.parentGroupSet)}work(e,t){if(this.parentGroupSet.size===0)return;const n=T.sortGraphics([...this.parentGroupSet]).reverse(),s=[];for(const r of n){const o=r.computeBasePropsByChildren();s.push({id:r.id,props:[o]})}e.execAction(new ct({infos:s},{streaming:t}))}}class Ps{}class Fh extends Ps{enable(e){return!(!(e instanceof _n)||e.cropProps.cropType===de.None||!e.cropProps.cropInfo)}handle(e,t,n,s,r){const o=this.handleCropProp(e,t,n,s,r);return[{id:e.id,props:[o]}]}handleCropProp(e,t,n,s,r){const o=t.crop,i=t.crop.globalImgPos,a=o.originCropProps,c=a.cropType,h=r.crossPoint(new m(i.x,i.y)),d=e.toLocal(h);return{type:R.Crop,cropInfo:{imgX:d.x,imgY:d.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*s},cropType:c}}}class Qs extends ge{constructor(){super(...arguments);g(this,"minStretchSize",new m(0,0));g(this,"originPos",new m(0,0));g(this,"originStretchRect");g(this,"propsMap",new Map);g(this,"originTransform",Z.generateMatrix());g(this,"viewBounds");g(this,"target",null);g(this,"alignWorker",new cn);g(this,"alignType",It.width);g(this,"originWidthHeightRatio",1);g(this,"isUniform",!1);g(this,"relatedLines",new Set);g(this,"layoutWorker",new Ms);g(this,"cropStretchHandler",new Fh);g(this,"groupBaseWorker",new Zr)}recordNodePropInfo(t){const{x:n,y:s,width:r,height:o}=t.globalBaseProps,i=this.originTransform.crossPoint({x:n,y:s}),a={x:i.x,y:i.y,width:r,height:o};if(t instanceof _n){const c=t.cropProps,h=t.getOriginImageRect().clone(),d=t.toGlobal({x:h.x,y:h.y}),u={originCropProps:c.clone(),originImgRect:h,originTransform:t.globalTransform().inverseMatrix().clone(),globalImgPos:this.originTransform.crossPoint(d)};a.crop=u}return a}computeAnchorPoint(t,n){const{width:s,height:r}=n;switch(t.type){case G.TOP:return this.alignType=It.height,{x:.5*s,y:r};case G.RIGHT:return this.alignType=It.width,{x:0,y:.5*r};case G.BOTTOM:return this.alignType=It.height,{x:.5*s,y:0};case G.LEFT:return this.alignType=It.width,{x:s,y:.5*r};case G.TOP_LEFT:return this.alignType=It.both,{x:s,y:r};case G.TOP_RIGHT:return this.alignType=It.both,{x:0,y:r};case G.BOTTOM_RIGHT:return this.alignType=It.both,{x:0,y:0};case G.BOTTOM_LEFT:default:return this.alignType=It.both,{x:s,y:0}}}judgeUniform(t){this.isUniform=!1;const n=this.target.nodes;for(const s of n){if(Math.abs(s.baseProps.angle)>.1){this.isUniform=!0;return}if(s.type===A.SVG||s.type===A.IMG){this.isUniform=!0;return}}}computeStretchRect(t,n){switch(this.target.type){case G.BOTTOM:t.height+=n.y;break;case G.LEFT:t.x+=n.x,t.width-=n.x;break;case G.RIGHT:t.width+=n.x;break;case G.TOP:t.y+=n.y,t.height-=n.y;break;case G.BOTTOM_LEFT:t.height+=n.y,t.x+=n.x,t.width-=n.x;break;case G.BOTTOM_RIGHT:t.height+=n.y,t.width+=n.x;break;case G.TOP_LEFT:t.y+=n.y,t.height-=n.y,t.x+=n.x,t.width-=n.x;break;case G.TOP_RIGHT:t.y+=n.y,t.height-=n.y,t.width+=n.x;break}t.width<this.minStretchSize.x&&(t.width=this.minStretchSize.x),t.height<this.minStretchSize.y&&(t.height=this.minStretchSize.y)}computeTarget(t,n){this.target=n.detect(W.Stretch,t)}onStart(t,n){this.computeTarget(t,n),this.originStretchRect=this.getStretchRect(n),this.originWidthHeightRatio=this.originStretchRect.width/this.originStretchRect.height,this.computeOriginTransform(n),this.minStretchSize=this.getMiniSize(n),this.judgeUniform(n),this.originPos=this.originTransform.crossPoint(n.lastDiffTypeEvent.globalPoint),this.recordPropsMap(n),this.relatedLines.clear();for(const r of this.target.nodes)this.layoutWorker.collectNodeLinks(r,n,this.relatedLines);this.groupBaseWorker.start(this.target.nodes),this.viewBounds=n.gmlRender.getViewPortBounds(),n.actionManager.execAction(new nt);const s=[];if(this.target.type===G.BOTTOM||this.target.type===G.BOTTOM_LEFT||this.target.type===G.BOTTOM_RIGHT)for(const r of this.target.nodes)s.push({id:r.id,props:[{type:R.Text,sizeMode:le.fix}]});n.actionManager.execAction(new ct({infos:s})),n.inputManager.editTextInfo&&n.execAction(lt.blur(n.inputManager.editTextInfo.node.id))}onMove(t,n){n.auxiliaryManager.removeAlignGraphics(),this.stretchNode(t,n,!0)}onUp(t,n){this.stretchNode(t,n,!1),n.actionManager.execAction(new et),n.auxiliaryManager.removeAlignGraphics()}alignStretchGlobalPoint(t,n){const s=new Set(this.target.nodes);return this.alignWorker.alignLineEndAndDrawAlignLines(t,n,s)}stretchNode(t,n,s){const r=this.alignStretchGlobalPoint(t,n),o=this.originTransform.crossPoint(r),i=new m(o.x-this.originPos.x,o.y-this.originPos.y),a=this.originStretchRect.clone();this.computeStretchRect(a,i);const c=n.gmlRender.getScale(),h=new Set(this.target.nodes),d=this.alignWorker.alignStretch(n,a,h,this.alignType,this.viewBounds,js/c,Ks/c);this.drawAlignLine(a,d,n);const{sx:u,sy:p}=this.computeScale(a),f=Z.generateMatrix().scale(u,p),y=this.originTransform.inverseMatrix().crossProduct(f),w=[],b=[],x=[];for(const[v,C]of this.propsMap){for(const E of this.handlers)if(E.enable(v)){const k=E.handle(v,C,u,p,y);w.push(...k);break}v.type===A.SVG&&b.push(v),this.cropStretchHandler.enable(v)&&x.push(v)}n.execAction(new ct({infos:w},{streaming:s})),this.afterStretchNode(n,u,p,y,s,x,b),this.layoutWorker.work([...this.relatedLines],n,s),this.groupBaseWorker.work(n,s)}afterStretchNode(t,n,s,r,o,i,a){if(i.length>0){const c=[];i.forEach(h=>{c.push(...this.cropStretchHandler.handle(h,this.propsMap.get(h),n,s,r))}),t.execAction(new ct({infos:c},{streaming:o}))}if(t.asyncRenderNodeManager.batchAddRenderNode(a),this.target.type===G.BOTTOM_RIGHT){const c=[...this.target.nodes],h=c[0];if(c.length===1)t.addOrUpdate(N.HoverSize,{rect:D.baseProps2Rect(h.baseProps),transform:h.globalTransform().clone()});else{const d=t.auxiliaryManager.selectManager.getSelectBounds();t.addOrUpdate(N.HoverSize,{rect:D.rectNode2Rect(d),transform:Z.generateMatrix().translate(d.minX,d.minY)})}}}computeScale(t){let n=t.width/this.originStretchRect.width,s=t.height/this.originStretchRect.height;if(!this.isUniform)return{sx:n,sy:s};const r=this.target.type;if(r===G.BOTTOM||r===G.TOP)return n=s,{sx:n,sy:s};if(r===G.LEFT||r===G.RIGHT)return s=n,{sx:n,sy:s};const o=t.width/t.height;return o>this.originWidthHeightRatio?s=n:o<this.originWidthHeightRatio&&(n=s),{sx:n,sy:s}}}class Vh extends Ps{enable(e){return!0}handle(e,t,n,s,r){const o=r.crossPoint({x:t.x,y:t.y}),i=e.parent.toLocal(o);return[{id:e.id,props:[{type:R.Base,x:i.x,y:i.y,width:t.width*n,height:t.height*s}]}]}}class ga extends Qs{constructor(){super(...arguments);g(this,"handlers",[new Vh])}getStretchRect(t){const n=[...t.getSelectNodes()];return D.baseProps2Rect(n[0].baseProps)}getMiniSize(t){return[...t.getSelectNodes()][0].getStretchMinSize()}recordPropsMap(t){this.propsMap.clear();const n=this.target.nodes;for(const s of n){const r=this.recordNodePropInfo(s);this.propsMap.set(s,r)}}judgeUniform(t){this.isUniform=!1;const n=this.target.nodes[0];if(n.type===A.SVG||n.type===A.IMG){this.isUniform=!0;return}}computeOriginTransform(t){const n=this.target,s=[...t.getSelectNodes()][0],{x:r,y:o,width:i,height:a,angle:c}=s.globalBaseProps,h=Z.generateMatrix().rotate(-c),d=Z.generateMatrix().translate(-r,-o),u=this.computeAnchorPoint(n,new D(0,0,i,a)),f=Z.generateMatrix().translate(-u.x,-u.y).crossProduct(h.crossProduct(d));this.originTransform=f}drawAlignLine(t,n,s){const r=this.target.nodes[0],o=r.baseProps,{width:i,height:a}=n,c=r.globalTransform().clone();if(i){t.width+=i.dt;const h={transform:c,line:{start:new m(0,o.height),end:new m(o.width,o.height)}};i.lines.push(h)}if(a){t.height+=a.dt;const h={transform:c,line:{start:new m(o.width,0),end:new m(o.width,o.height)}};a.lines.push(h)}s.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}}class ya extends ae{constructor(){super([new ga])}streamEnable(e,t){const n=t.detect(W.Stretch,e);return n?n.nodes.length===1:!1}}class Jr{handleChangeRelation(e,t,n){if(e.parent===t)return[];if(e.parent.type===A.Group)return[];const s=e.globalPos,r=t.toLocal(s);return[{id:e.id,props:[{type:R.Base,x:r.x,y:r.y}],parentId:t.id,zIndex:n}]}}class Wh extends Jr{enable(e){return e.type===A.Line}handle(e,t){const n=e.baseProps.clone();n.x+=t.x,n.y+=t.y;const s=e.getProp(R.Line).clone();for(const r of s.points)r.x+=t.x,r.y+=t.y;return[{id:e.id,props:[n,s]}]}handleChangeRelation(e,t,n){if(e.parent===t)return[];const s=e.globalLinePoints,r=t.globalTransform().inverseMatrix(),o=s.map(a=>r.crossPoint(a)),i=T.getBoundsByPoints(o);return[{id:e.id,props:[{type:R.Base,x:i.minX,y:i.minY},{type:R.Line,points:o}],parentId:t.id,zIndex:n}]}}class Gh extends Jr{enable(e){return!0}handle(e,t){const n=e.baseProps.clone();return n.x+=t.x,n.y+=t.y,[{id:e.id,props:[n]}]}}class to{work(e){const t=e.getSelectNodes();if(t.size===0)return null;const n=D.rectNode2Rect(e.auxiliaryManager.selectManager.getSelectBounds()),s=[],r=[];for(const o of t){const i=this.makeupPasteDO(o,!0,r);s.push(i)}return{meta:{docId:e.docState.docId},nodes:s,bounds:n,resources:r}}makeupPasteDO(e,t=!1,n){const{id:s,zIndex:r,capInfo:o,type:i}=e.serializeTo(),a={id:s,type:i,zIndex:r,capInfo:o,children:[]};if(this.collectResourceInfo(e,n),t){const u=e.globalPos;a.capInfo.baseProps.x=u.x,a.capInfo.baseProps.y=u.y}const c=e.children;if(c.size===0)return a;const h=[],d=t&&e.type===A.Group;for(const u of c)h.push(this.makeupPasteDO(u,d,n));return a.children=h,a}collectResourceInfo(e,t){if(e.type===A.IMG){const n=e;t.push({type:Gs.Image,fileKey:n.imgSrc})}if(e.type===A.SVG){const n=e;t.push({type:Gs.SVG,fileKey:n.svgUrl})}}}class bs{}class ma extends bs{handle(e,t){const n=e.find(s=>s.type===R.Base);n&&(n.x+=t.x,n.y+=t.y)}}class wa extends bs{handle(e,t,n){const s=e.find(i=>i.type===R.Connect);if(!s)return;const{start:r,end:o}=s;if(r){const i=n.get(r.objectId);i?r.objectId=i:s.start=null}if(o){const i=n.get(o.objectId);i?o.objectId=i:s.end=null}}}class xa extends bs{handle(e,t){const n=e.find(s=>s.type===R.Line);if(n)for(const s of n.points)s.x+=t.x,s.y+=t.y}}var An=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function eo(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}function Uh(l){if(l.__esModule)return l;var e=l.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(l).forEach(function(n){var s=Object.getOwnPropertyDescriptor(l,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return l[n]}})}),t}var Pa={exports:{}};function _h(l){throw new Error('Could not dynamically require "'+l+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var no={exports:{}};const Kh=Uh(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ba;function jh(){return ba||(ba=1,function(l,e){(function(t,n){l.exports=n()})(An,function(){var t=t||function(n,s){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof An<"u"&&An.crypto&&(r=An.crypto),!r&&typeof _h=="function")try{r=Kh}catch{}var o=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function x(){}return function(v){var C;return x.prototype=v,C=new x,x.prototype=null,C}}(),a={},c=a.lib={},h=c.Base=function(){return{extend:function(x){var v=i(this);return x&&v.mixIn(x),(!v.hasOwnProperty("init")||this.init===v.init)&&(v.init=function(){v.$super.init.apply(this,arguments)}),v.init.prototype=v,v.$super=this,v},create:function(){var x=this.extend();return x.init.apply(x,arguments),x},init:function(){},mixIn:function(x){for(var v in x)x.hasOwnProperty(v)&&(this[v]=x[v]);x.hasOwnProperty("toString")&&(this.toString=x.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=c.WordArray=h.extend({init:function(x,v){x=this.words=x||[],v!=s?this.sigBytes=v:this.sigBytes=x.length*4},toString:function(x){return(x||p).stringify(this)},concat:function(x){var v=this.words,C=x.words,E=this.sigBytes,k=x.sigBytes;if(this.clamp(),E%4)for(var I=0;I<k;I++){var V=C[I>>>2]>>>24-I%4*8&255;v[E+I>>>2]|=V<<24-(E+I)%4*8}else for(var U=0;U<k;U+=4)v[E+U>>>2]=C[U>>>2];return this.sigBytes+=k,this},clamp:function(){var x=this.words,v=this.sigBytes;x[v>>>2]&=4294967295<<32-v%4*8,x.length=n.ceil(v/4)},clone:function(){var x=h.clone.call(this);return x.words=this.words.slice(0),x},random:function(x){for(var v=[],C=0;C<x;C+=4)v.push(o());return new d.init(v,x)}}),u=a.enc={},p=u.Hex={stringify:function(x){for(var v=x.words,C=x.sigBytes,E=[],k=0;k<C;k++){var I=v[k>>>2]>>>24-k%4*8&255;E.push((I>>>4).toString(16)),E.push((I&15).toString(16))}return E.join("")},parse:function(x){for(var v=x.length,C=[],E=0;E<v;E+=2)C[E>>>3]|=parseInt(x.substr(E,2),16)<<24-E%8*4;return new d.init(C,v/2)}},f=u.Latin1={stringify:function(x){for(var v=x.words,C=x.sigBytes,E=[],k=0;k<C;k++){var I=v[k>>>2]>>>24-k%4*8&255;E.push(String.fromCharCode(I))}return E.join("")},parse:function(x){for(var v=x.length,C=[],E=0;E<v;E++)C[E>>>2]|=(x.charCodeAt(E)&255)<<24-E%4*8;return new d.init(C,v)}},y=u.Utf8={stringify:function(x){try{return decodeURIComponent(escape(f.stringify(x)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(x){return f.parse(unescape(encodeURIComponent(x)))}},w=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(x){typeof x=="string"&&(x=y.parse(x)),this._data.concat(x),this._nDataBytes+=x.sigBytes},_process:function(x){var v,C=this._data,E=C.words,k=C.sigBytes,I=this.blockSize,V=I*4,U=k/V;x?U=n.ceil(U):U=n.max((U|0)-this._minBufferSize,0);var J=U*I,j=n.min(J*4,k);if(J){for(var st=0;st<J;st+=I)this._doProcessBlock(E,st);v=E.splice(0,J),C.sigBytes-=j}return new d.init(v,j)},clone:function(){var x=h.clone.call(this);return x._data=this._data.clone(),x},_minBufferSize:0});c.Hasher=w.extend({cfg:h.extend(),init:function(x){this.cfg=this.cfg.extend(x),this.reset()},reset:function(){w.reset.call(this),this._doReset()},update:function(x){return this._append(x),this._process(),this},finalize:function(x){x&&this._append(x);var v=this._doFinalize();return v},blockSize:16,_createHelper:function(x){return function(v,C){return new x.init(C).finalize(v)}},_createHmacHelper:function(x){return function(v,C){return new b.HMAC.init(x,C).finalize(v)}}});var b=a.algo={};return a}(Math);return t})}(no)),no.exports}(function(l,e){(function(t,n){l.exports=n(jh())})(An,function(t){return function(n){var s=t,r=s.lib,o=r.WordArray,i=r.Hasher,a=s.algo,c=[];(function(){for(var y=0;y<64;y++)c[y]=n.abs(n.sin(y+1))*4294967296|0})();var h=a.MD5=i.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(y,w){for(var b=0;b<16;b++){var x=w+b,v=y[x];y[x]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360}var C=this._hash.words,E=y[w+0],k=y[w+1],I=y[w+2],V=y[w+3],U=y[w+4],J=y[w+5],j=y[w+6],st=y[w+7],tt=y[w+8],it=y[w+9],ht=y[w+10],xt=y[w+11],mt=y[w+12],ut=y[w+13],ot=y[w+14],q=y[w+15],B=C[0],H=C[1],z=C[2],X=C[3];B=d(B,H,z,X,E,7,c[0]),X=d(X,B,H,z,k,12,c[1]),z=d(z,X,B,H,I,17,c[2]),H=d(H,z,X,B,V,22,c[3]),B=d(B,H,z,X,U,7,c[4]),X=d(X,B,H,z,J,12,c[5]),z=d(z,X,B,H,j,17,c[6]),H=d(H,z,X,B,st,22,c[7]),B=d(B,H,z,X,tt,7,c[8]),X=d(X,B,H,z,it,12,c[9]),z=d(z,X,B,H,ht,17,c[10]),H=d(H,z,X,B,xt,22,c[11]),B=d(B,H,z,X,mt,7,c[12]),X=d(X,B,H,z,ut,12,c[13]),z=d(z,X,B,H,ot,17,c[14]),H=d(H,z,X,B,q,22,c[15]),B=u(B,H,z,X,k,5,c[16]),X=u(X,B,H,z,j,9,c[17]),z=u(z,X,B,H,xt,14,c[18]),H=u(H,z,X,B,E,20,c[19]),B=u(B,H,z,X,J,5,c[20]),X=u(X,B,H,z,ht,9,c[21]),z=u(z,X,B,H,q,14,c[22]),H=u(H,z,X,B,U,20,c[23]),B=u(B,H,z,X,it,5,c[24]),X=u(X,B,H,z,ot,9,c[25]),z=u(z,X,B,H,V,14,c[26]),H=u(H,z,X,B,tt,20,c[27]),B=u(B,H,z,X,ut,5,c[28]),X=u(X,B,H,z,I,9,c[29]),z=u(z,X,B,H,st,14,c[30]),H=u(H,z,X,B,mt,20,c[31]),B=p(B,H,z,X,J,4,c[32]),X=p(X,B,H,z,tt,11,c[33]),z=p(z,X,B,H,xt,16,c[34]),H=p(H,z,X,B,ot,23,c[35]),B=p(B,H,z,X,k,4,c[36]),X=p(X,B,H,z,U,11,c[37]),z=p(z,X,B,H,st,16,c[38]),H=p(H,z,X,B,ht,23,c[39]),B=p(B,H,z,X,ut,4,c[40]),X=p(X,B,H,z,E,11,c[41]),z=p(z,X,B,H,V,16,c[42]),H=p(H,z,X,B,j,23,c[43]),B=p(B,H,z,X,it,4,c[44]),X=p(X,B,H,z,mt,11,c[45]),z=p(z,X,B,H,q,16,c[46]),H=p(H,z,X,B,I,23,c[47]),B=f(B,H,z,X,E,6,c[48]),X=f(X,B,H,z,st,10,c[49]),z=f(z,X,B,H,ot,15,c[50]),H=f(H,z,X,B,J,21,c[51]),B=f(B,H,z,X,mt,6,c[52]),X=f(X,B,H,z,V,10,c[53]),z=f(z,X,B,H,ht,15,c[54]),H=f(H,z,X,B,k,21,c[55]),B=f(B,H,z,X,tt,6,c[56]),X=f(X,B,H,z,q,10,c[57]),z=f(z,X,B,H,j,15,c[58]),H=f(H,z,X,B,ut,21,c[59]),B=f(B,H,z,X,U,6,c[60]),X=f(X,B,H,z,xt,10,c[61]),z=f(z,X,B,H,I,15,c[62]),H=f(H,z,X,B,it,21,c[63]),C[0]=C[0]+B|0,C[1]=C[1]+H|0,C[2]=C[2]+z|0,C[3]=C[3]+X|0},_doFinalize:function(){var y=this._data,w=y.words,b=this._nDataBytes*8,x=y.sigBytes*8;w[x>>>5]|=128<<24-x%32;var v=n.floor(b/4294967296),C=b;w[(x+64>>>9<<4)+15]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,w[(x+64>>>9<<4)+14]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360,y.sigBytes=(w.length+1)*4,this._process();for(var E=this._hash,k=E.words,I=0;I<4;I++){var V=k[I];k[I]=(V<<8|V>>>24)&16711935|(V<<24|V>>>8)&4278255360}return E},clone:function(){var y=i.clone.call(this);return y._hash=this._hash.clone(),y}});function d(y,w,b,x,v,C,E){var k=y+(w&b|~w&x)+v+E;return(k<<C|k>>>32-C)+w}function u(y,w,b,x,v,C,E){var k=y+(w&x|b&~x)+v+E;return(k<<C|k>>>32-C)+w}function p(y,w,b,x,v,C,E){var k=y+(w^b^x)+v+E;return(k<<C|k>>>32-C)+w}function f(y,w,b,x,v,C,E){var k=y+(b^(w|~x))+v+E;return(k<<C|k>>>32-C)+w}s.MD5=i._createHelper(h),s.HmacMD5=i._createHmacHelper(h)}(Math),t.MD5})})(Pa);var qh=Pa.exports;const $h=eo(qh);class Qt{constructor(){g(this,"prefix","001");g(this,"map",new Map);g(this,"zIndex",0)}setPrefix(e){this.prefix=e}genId(e){const t=(this.map.get(e)||0)+1;return this.map.set(e,t),Qt.type2NodePrefix(e)+this.prefix+":"+t}static genImgFileName(e,t){const n="img:"+e+"|"+t;return $h(n).toString()}loadNode(e){this.loadNodeId(e.id)}loadNodeId(e){const t=Qt.nodePrefix2Type(e[0]),n=e.split(":");try{const s=parseInt(n[1]),r=this.map.get(t);r!==void 0?r<s&&this.map.set(t,s):this.map.set(t,s)}catch(s){console.error("id错误",s)}}static genZIndex(e){return e.children.size===0?1:[...e.children].sort((n,s)=>s.zIndex-n.zIndex)[0].zIndex+1}static type2NodePrefix(e){switch(e){case A.Shape:return"a";case A.Line:return"c";case A.SVG:return"d";case A.IMG:return"e";case A.Section:return"f";case A.Group:return"g";default:return"x"}}static nodePrefix2Type(e){return e==="a"?A.Shape:e==="c"?A.Line:e==="d"?A.SVG:e==="e"?A.IMG:e==="f"?A.Section:e==="g"?A.Group:A.Shape}}class va{work(e,t,n,s){const r=new Map;this.recordIdMap(t,e,r);const o=[],i=[];for(const c of t){const h=this.convertToAddNodeInfo(e,c,r,n,o,Un,s);i.push(h)}return{addNodeData:{nodes:o},nextFocusIds:i}}convertToAddNodeInfo(e,t,n,s,r,o,i){const a=n.get(t.id),c=this.convertToProps(t.capInfo,s,n,i),h={id:a,type:t.type,zIndex:Qt.genZIndex(e.nodeManager.root),parentId:o,props:c};r.push(h);const d=new m;t.type===A.Group&&(d.x=s.x,d.y=s.y);for(const u of t.children)this.convertToAddNodeInfo(e,u,n,d,r,a,i);return a}convertToProps(e,t,n,s){const r=T.convertCapInfoToProps(e);for(const o of this.propsHandler)o.handle(r,t,n,s);return r}recordIdMap(e,t,n){for(const s of e){const r=t.idGenerator.genId(s.type);n.set(s.id,r);const o=s.children;this.recordIdMap(o,t,n)}}}class Ma extends va{constructor(){super(...arguments);g(this,"propsHandler",[new ma,new wa,new xa])}}class Sa{constructor(){g(this,"copyWorker",new to);g(this,"pasteWorker",new Ma)}work(e,t){const n=this.copyWorker.work(e);if(!n)return;let s;t?s=t:s=new m(20,20);const r=n.nodes,o=JSON.parse(JSON.stringify(r)),{addNodeData:i,nextFocusIds:a}=this.pasteWorker.work(e,o,s);e.execAction(new Yt(i)),e.execAction(Pt.create(a))}}class Qh extends Jr{enable(e){return e.type===A.Group}handle(e,t,n){const s=[],r=e.baseProps.clone();r.x+=t.x,r.y+=t.y,s.push({id:e.id,props:[r]});for(const o of e.children)s.push(...n.handle(o,t));return s}handleChangeRelation(e,t,n){if(e.parent===t)return[];if(e.parent.type===A.Group)return[];const s=e.globalPos,r=t.toLocal(s),o=[];o.push({id:e.id,props:[{type:R.Base,x:r.x,y:r.y}],parentId:t.id,zIndex:n});for(const i of e.children)this.handlePosChange(i,t,o);return o}handlePosChange(e,t,n){if(e.type===A.Line){const r=e.globalLinePoints.map(a=>t.toLocal(a)),o=D.rectNode2Rect(T.getBoundsByPoints(r)),i={id:e.id,props:[{type:R.Line,points:r},{type:R.Base,x:o.x,y:o.y,width:o.width,height:o.height}]};n.push(i)}else{const s=e.globalPos,r=t.toLocal(s),o={id:e.id,props:[{type:R.Base,x:r.x,y:r.y}]};n.push(o)}if(e.type===A.Group)for(const s of e.children)this.handlePosChange(s,t,n)}}class Zh{constructor(e){g(this,"handlers");this.handlers=e}handle(e,t){for(const n of this.handlers)if(n.enable(e))return n.handle(e,t,this);return[]}handleRelation(e,t,n){for(const s of this.handlers)if(s.enable(e))return s.handleChangeRelation(e,t,n);return[]}}class Ta extends ge{constructor(){super(...arguments);g(this,"moveRect",null);g(this,"lastPos",new m(0,0));g(this,"lastMoveRectPos",new m);g(this,"targetNodes",[]);g(this,"alignWorker",new cn);g(this,"layoutWorker",new Ms);g(this,"duplicateWorker",new Sa);g(this,"groupBaseWorker",new Zr);g(this,"handlerCtx",new Zh([new Wh,new Qh,new Gh]))}computeMoveNodes(t,n){t.originEvent.altKey&&this.duplicateWorker.work(n,new m);const s=n.getSelectNodes(),r=this.recordNodeMap(s),o=[];for(const i of s){if(i.type===A.Line){const a=i,{start:c,end:h}=a.connectProps;if(c&&h||!c&&h&&!r.has(h.objectId)||!h&&c&&!r.has(c.objectId))continue}o.push(i)}return o}recordNodeMap(t){const n=new Map;for(const s of t)n.set(s.id,s);return n}onStart(t,n){n.actionManager.execAction(new nt),this.targetNodes=this.computeMoveNodes(t,n),this.lastPos=t.globalPoint.clone(),this.moveRect=n.auxiliaryManager.selectManager.getSelectBounds(),this.lastMoveRectPos=new m(this.moveRect.minX,this.moveRect.minY),n.inputManager.editTextInfo&&n.execAction(lt.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.targetNodes)}onMove(t,n){n.auxiliaryManager.removeAlignGraphics(),this.moveNode(t.globalPoint,n,!0);const s=this.hoverOnContainer(t,n);s&&n.addOrUpdate(N.HoverContainer,{node:s})}judgeLinkLineRelation(t,n,s){const{start:r,end:o}=t.connectProps;let i=null,a=null;return r&&(i=n.nodeManager.getNode(r.objectId)),o&&(a=n.nodeManager.getNode(o.objectId)),i?!!(!a||s.has(a)):a?!!s.has(a):!1}onUp(t,n){this.moveNode(t.globalPoint,n,!1),this.changeNodesRelation(t,n),n.actionManager.execAction(new et),n.auxiliaryManager.removeAlignGraphics()}changeNodesRelation(t,n){const s=this.hoverOnContainer(t,n)||n.nodeManager.root,r=n.getSelectNodes(),o=new Set(r),i=new Set;for(const u of r)n.nodeManager.getNodeLinks(u).forEach(f=>i.add(f));for(const u of i)this.judgeLinkLineRelation(u,n,r)&&o.add(u);const a=[],c=Math.max(...[...s.children].map(u=>u.zIndex));let h=1;const d=T.sortGraphics([...o]);for(const u of d){if(u.parent===s)continue;const p=this.handlerCtx.handleRelation(u,s,c+h);a.push(...p),h++}console.log("update nodes:",a.map(u=>u.id)),a.length>0&&n.execAction(new ct({infos:a}))}moveNode(t,n,s){const r=new m(t.x-this.lastPos.x,t.y-this.lastPos.y),o=T.cloneIRectNode(this.moveRect);this.moveRectChange(this.moveRect,r);const i=this.alignWorker.alignMove(this.moveRect,n.getSelectNodes(),n),a=this.alignWorker.drawAlignLines(i,n),c=this.checkAlign(i);r.x+=a.x,r.y+=a.y,this.moveRectChange(o,r);const h=c?o:this.moveRect,d=new m(h.minX,h.minY),u={x:d.x-this.lastMoveRectPos.x,y:d.y-this.lastMoveRectPos.y},p=[],f=new Set;for(const y of this.targetNodes){const w=this.handlerCtx.handle(y,u);p.push(...w),this.layoutWorker.collectNodeLinks(y,n,f)}n.execAction(new ct({infos:p},{streaming:s})),this.groupBaseWorker.work(n,s),this.layoutWorker.work([...f],n,s),this.lastPos=t,this.lastMoveRectPos=d}hoverOnContainer(t,n){const s=n.detect(W.HoverOnContainer,t);return s||null}moveRectChange(t,n){t.minX+=n.x,t.maxX+=n.x,t.minY+=n.y,t.maxY+=n.y}checkAlign(t){const{top:n,bottom:s,right:r,left:o,horizonMid:i,verticalMid:a}=t;return n!==void 0||s!==void 0||r!==void 0||o!==void 0||i!==void 0||a!==void 0}}class Ca extends ae{constructor(){super([new Ta])}streamEnable(e,t){if(t.auxiliaryManager.selectManager.selectNodes.size===0)return!1;const s=t.auxiliaryManager.selectManager.getSelectBounds(),r=D.rectNode2Rect(s);if(r.width<.1||r.height<.1){const i=K.line({x:r.x,y:r.y},{x:s.maxX,y:s.maxY}),a=K.circle(e.globalPoint,4/t.gmlRender.getScale());return O.intersect(i,a).points.length>0}return T.rectContains2(e.globalPoint,s)}}class La extends ge{constructor(){super(...arguments);g(this,"startPoint",null)}onStart(t,n){this.startPoint=t.globalPoint,n.actionManager.execAction(new nt),n.inputManager.editTextInfo&&n.execAction(lt.blur(n.inputManager.editTextInfo.node.id)),n.actionManager.execAction(Pt.create([]))}onMove(t,n){if(!this.startPoint)return;const s=Math.min(t.globalPoint.x,this.startPoint.x),r=Math.max(t.globalPoint.x,this.startPoint.x),o=Math.min(t.globalPoint.y,this.startPoint.y),i=Math.max(t.globalPoint.y,this.startPoint.y),a={id:"group-rect",minX:s,maxX:r,minY:o,maxY:i},c=D.rectNode2Rect(a);n.addOrUpdate(N.SelectGroup,{rect:c});const h=n.nodeManager.searchNodes(s,o,r,i),d=new Set;for(const f of h){if(f.type===A.Section){T.containRect(a,f.getBounds())&&d.add(f);continue}f.overlapRect(a)&&d.add(f)}const p=T.computeSelectNodes(d).map(f=>f.id);n.actionManager.execAction(Pt.create(p))}onUp(t,n){n.actionManager.execAction(new et),n.removeAuxGraphic(N.SelectGroup),this.startPoint=null}}class so extends ae{constructor(){super([new La])}streamEnable(e,t){return!0}}class ro extends ee{constructor(){super(...arguments);g(this,"node",null)}enable(t,n){if(!t.originEvent.shiftKey&&!t.originEvent.metaKey)return!1;if(t.originEvent.metaKey){const r=n.detect(W.Node,t);if(r&&r.length>0)return this.node=r[0],!0}const s=n.detect(W.HoverNode,t);return s?(this.node=s,!0):!1}handle(t,n){if(!this.node)return;const r=[...T.computeSelectNode(n,this.node)].map(o=>o.id);n.actionManager.execAction(new nt),n.actionManager.execAction(Pt.create([...r])),n.actionManager.execAction(new et)}}class Aa extends ee{constructor(){super(...arguments);g(this,"node",null)}enable(t,n){const s=n.auxiliaryManager.selectManager.getSelectBounds();if(n.getSelectNodes().size>1&&T.rectContains2(t.globalPoint,s))return!1;const r=n.detect(W.HoverNode,t);return r?n.auxiliaryManager.selectManager.include(r)||!this.canEnable(r)?!1:(this.node=r,!0):!1}handle(t,n){this.node&&(n.actionManager.execAction(new nt),n.inputManager.editTextInfo&&n.execAction(lt.blur(n.inputManager.editTextInfo.node.id)),n.actionManager.execAction(Pt.create([this.node.id])),n.actionManager.execAction(new et),this.node.type===A.IMG&&n.setCursor("zoom-in"))}}class oo extends Aa{constructor(){super(...arguments);g(this,"node",null)}canEnable(t){return t.type!==A.Section}}class Ra extends ee{constructor(){super(...arguments);g(this,"res",null)}enable(t,n){const s=n.detect(W.Node,t);if(s){const r=s[0];if(n.auxiliaryManager.selectManager.include(r)){const o=r.toLocal(t.globalPoint);if(r instanceof qe&&r.renderText.contains(o))return this.res={node:r,relativePos:o},!0;if(r instanceof dn)return this.res={node:r,relativePos:o},!0}}return!1}handle(t,n){if(!this.res)return;const{node:s,relativePos:r}=this.res,o=s.renderText.detect(r);this.shiftTextClick(t,n,o)||(n.execAction(new nt),n.execAction(lt.focus(s.id,o)),n.execAction(new et))}shiftTextClick(t,n,s){if(!t.originEvent.shiftKey)return!1;const r=n.inputManager.editTextInfo,{node:o}=this.res;return r&&!n.inputManager.selectionManager.selectionInfo&&!r.textCursorPosition.equal(s)?(n.execAction(new nt),n.execAction(lt.selection(o.id,s,r.textCursorPosition)),n.execAction(new et),!0):!1}}class io extends ee{constructor(){super(...arguments);g(this,"node",null)}enable(t,n){if(!t.originEvent.shiftKey&&!t.originEvent.metaKey)return!1;const s=n.detect(W.Node,t);if(s){const r=s[0];if(n.auxiliaryManager.selectManager.include(r))return this.node=r,!0}return!1}handle(t,n){if(!this.node)return;const s=n.getSelectNodes(),r=new Set;s.forEach(o=>r.add(o.id)),r.delete(this.node.id),n.actionManager.execAction(new nt),n.actionManager.execAction(Pt.create([...r])),n.actionManager.execAction(new et)}}class ao extends ee{enable(e,t){return!t.detect(W.Node,e)}handle(e,t){if(t.getSelectNodes().size===0){t.slotManager.addSlotState(te.QuickCreate,{show:!1});return}if(t.execAction(new nt),t.inputManager.editTextInfo){const n=t.inputManager.editTextInfo.node;if(t.execAction(lt.blur(t.inputManager.editTextInfo.node.id)),n.type===A.Shape&&n.shapeType===_.PureText){const s=n.getProp(R.Text);if(s&&s.text===""){t.execAction(Pt.create([])),t.execAction(Fe.create([n.id])),t.execAction(new et);return}}}t.execAction(Pt.create([])),t.execAction(new et)}}class Na extends ee{constructor(){super(...arguments);g(this,"res",null);g(this,"layoutWorker",new Ms)}enable(t,n){const s=n.detect(W.ExpandShape,t);return s?(this.res=s,!0):!1}handle(t,n){const{node:s,realHeight:r}=this.res,o={infos:[{id:s.id,props:[{height:r,type:R.Base},{type:R.Text,sizeMode:le.autoHeight}]}]};n.execAction(new nt),n.execAction(new ct(o));const i=[...n.nodeManager.getNodeLinks(s)];this.layoutWorker.work(i,n,!1),n.execAction(new et)}}class Ea extends Aa{constructor(){super(...arguments);g(this,"node",null)}canEnable(t){return t.type===A.Section}}class Jh extends ee{constructor(){super(...arguments);g(this,"node")}enable(t,n){const s=n.detect(W.Image,t);return s?(this.node=s,!0):!1}handle(t,n){const s=this.getFileKey(this.node),r={nodeId:this.node.id,fileKey:s,blobUrl:n.resourceManager.getBlobUrl(s)};n.slotManager.addSlotState(te.ClickImg,r)}getFileKey(t){return t.type===A.SVG?t.svgUrl:t.type===A.IMG?t.imgSrc:""}}class Ia extends We{constructor(){super(),this.registerDownHandler(new Na),this.registerDownHandler(new ro),this.registerDownHandler(new oo),this.registerUpHandler(new Ra),this.registerUpHandler(new io),this.registerUpHandler(new Ea),this.registerUpHandler(new Jh),this.registerUpHandler(new ao)}}class ka extends ln{constructor(){super([new Ia])}}class td{}class ed extends td{enable(e){return e.type===A.Line}handle(e,t){t.addOrUpdate(N.HoverLine,{node:e,transform:e.globalTransform()})}}class nd{enable(e){return!0}handle(e,t){t.addOrUpdate(N.HoverBounds,{node:e,transform:e.globalTransform()})}}class sd{enable(e){return e.type===A.Group}handle(e,t){const n=e;if(t.auxiliaryManager.selectManager.include(e))return;const s=n.nameGlobalTransform();t.addOrUpdate(N.HoverBounds,{node:e,transform:s})}}class rd{enable(e){return e.type===A.Section}handle(e,t){}}class co{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]));g(this,"handlers",[new ed,new sd,new rd,new nd])}process(e,t){const n=t.detect(W.HoverConnectAnchor,e);if(n){n.node.type===A.Shape&&t.previewManager.quickCreateManager.enterQuickPreview(n.node,n.relative,t),t.addOrUpdate(N.HoverConnectAnchor,{point:n.globalPoint});return}t.previewManager.quickCreateManager.exitQuickPreview(t),this.hoverSizer(e,t);const s=t.detect(W.HoverNode,e);if(s){for(const r of this.handlers)if(r.enable(s)){r.handle(s,t);return}}}hoverSizer(e,t){const n=t.detect(W.Stretch,e);if(!n)return;const s=n.nodes,r=s[0];if(n.type===G.BOTTOM_RIGHT)if(s.length===1)t.addOrUpdate(N.HoverSize,{rect:D.baseProps2Rect(r.baseProps),transform:r.globalTransform().clone()});else{const o=t.auxiliaryManager.selectManager.getSelectBounds();t.addOrUpdate(N.HoverSize,{rect:D.rectNode2Rect(o),transform:Z.generateMatrix().translate(o.minX,o.minY)})}}}var ft=(l=>(l[l.DEFAULT=0]="DEFAULT",l[l.TEXT=1]="TEXT",l[l.SHAPE=2]="SHAPE",l[l.LINE=3]="LINE",l[l.SECTION=4]="SECTION",l[l.STICKY=5]="STICKY",l[l.HandTool=6]="HandTool",l[l.Resource=7]="Resource",l))(ft||{});class Ba{constructor(e,t,n,s){g(this,"nodeManager");g(this,"inputManager");g(this,"slotManager");g(this,"cursorManager");g(this,"currentTool",ft.DEFAULT);g(this,"shapeType",0);g(this,"grab",!1);g(this,"creatingLine",null);this.nodeManager=e,this.inputManager=t,this.slotManager=n,this.cursorManager=s}setCurrentTool(e,t=0,n=!1){this.currentTool=e,this.shapeType=t,this.grab=n,this.slotManager.addSlotState(te.ToolChange,{tool:e,shapeType:t}),e===ft.DEFAULT&&this.cursorManager.setCursor("default")}resetTool(){this.creatingLine||this.setCurrentTool(ft.DEFAULT)}setInCreatingLine(e){this.creatingLine=e}}class ke{}class Oa extends ke{constructor(){super(...arguments);g(this,"cursorMap",new Map([[ft.SHAPE,"crosshair"],[ft.SECTION,"crosshair"],[ft.TEXT,"text"],[ft.LINE,"crosshair"]]))}enable(t,n){return this.cursorMap.has(n.toolManager.currentTool)}handle(t,n){if(n.toolManager.grab){n.setCursor("grabbing");return}const s=this.cursorMap.get(n.toolManager.currentTool);n.setCursor(s)}}class od extends ke{enable(e,t){return!!t.detect(W.ExpandShape,e)}handle(e,t){t.setCursor("pointer")}}class id extends ke{enable(e,t){const n=t.inputManager.editTextInfo;if(!n)return!1;const{node:s}=n,r=s.getTextContentRect(),o=s.toLocal(e.globalPoint);return!!T.rectContains(o,r)}handle(e,t){t.setCursor("text")}}class Da extends ke{enable(e,t){return!!t.detect(W.Stretch,e)}handle(e,t){const n=t.detect(W.Stretch,e);n.type===G.BOTTOM||n.type===G.TOP?t.setCursor("ns-resize"):n.type===G.RIGHT||n.type===G.LEFT?t.setCursor("ew-resize"):n.type===G.TOP_LEFT||n.type===G.BOTTOM_RIGHT?t.setCursor("nwse-resize"):(n.type===G.TOP_RIGHT||n.type===G.BOTTOM_LEFT)&&t.setCursor("nesw-resize")}}class ad extends ke{enable(e,t){return!!t.detect(W.HoverNode,e)}handle(e,t){t.setCursor("default")}}class lo extends ke{enable(e,t){return!0}handle(e,t){t.setCursor("default")}}class Zs{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]))}process(e,t){for(const n of this.handlers)if(n.enable(e,t)){n.handle(e,t);return}}}class cd extends ke{enable(e,t){return!!t.detect(W.LineEndPoint,e)}handle(e,t){t.setCursor("move")}}class ld extends ke{constructor(){super(...arguments);g(this,"res",null)}enable(t,n){const s=n.detect(W.PolyControlPoint,t);return s?(this.res=s,!0):!1}handle(t,n){if(!this.res)return;const{isHorizon:s}=this.res;s?n.setCursor("ns-resize"):n.setCursor("ew-resize")}}class hd extends ke{enable(e,t){return!!t.detect(W.Rotate,e)}handle(e,t){t.setCursor("rotate")}}class dd extends ke{enable(e,t){return!!t.detect(W.Image,e)}handle(e,t){t.setCursor("zoom-in")}}class Ha extends Zs{constructor(){super(...arguments);g(this,"handlers",[new Oa,new ld,new od,new cd,new id,new Da,new hd,new ad,new dd,new lo])}}class za extends Ve{constructor(){super([new co,new Ha])}canBeEnable(e,t){return!0}canBeExit(e,t){return!0}}class ud extends Ps{enable(e){return e.type===A.Line}handle(e,t,n,s,r){const i=e.parent.globalTransform().inverseMatrix().crossProduct(r),a=[];for(const h of t.points){const d=i.crossPoint(h);a.push(d)}const c=D.rectNode2Rect(T.getBoundsByPoints(a));return[{id:e.id,props:[{type:R.Line,points:a},{type:R.Base,x:c.x,y:c.y,width:c.width,height:c.height}]}]}}class pd extends Ps{enable(e){return!0}handle(e,t,n,s,r){const o=r.crossPoint({x:t.x,y:t.y}),i=e.parent.toLocal(o);return[{id:e.id,props:[{type:R.Base,x:i.x,y:i.y,width:t.width*n,height:t.height*s}]}]}}class Xa extends Qs{constructor(){super(...arguments);g(this,"handlers",[new ud,new pd])}computeOriginTransform(t){const n=this.target,{x:s,y:r}=this.originStretchRect,o=Z.generateMatrix().translate(-s,-r),i=this.computeAnchorPoint(n,this.originStretchRect),c=Z.generateMatrix().translate(-i.x,-i.y).crossProduct(o);this.originTransform=c}recordPropsMap(t){this.propsMap.clear();for(const n of this.target.nodes){const s=this.recordNodePropInfo(n);if(n.type===A.Line){const o=n.globalLinePoints.map(i=>this.originTransform.crossPoint(i));s.points=o}this.propsMap.set(n,s)}}drawAlignLine(t,n,s){const r=s.auxiliaryManager.selectManager.getSelectBounds(),o=D.rectNode2Rect(r),i=Z.generateMatrix().translate(r.minX,r.minY),{width:a,height:c}=n;if(a){t.width+=a.dt;const h={transform:i,line:{start:new m(0,o.height),end:new m(o.width,o.height)}};a.lines.push(h)}if(c){t.height+=c.dt;const h={transform:i,line:{start:new m(o.width,0),end:new m(o.width,o.height)}};c.lines.push(h)}s.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}getMiniSize(t){const n=[],s=[],{width:r,height:o}=this.originStretchRect,i=this.target.nodes;if([...i].filter(d=>d.type===A.Line).length===i.length)return{x:10,y:10};for(const d of i){if(d.type===A.Line)continue;const u=d.getStretchMinSize();n.push(u.x/r),s.push(u.y/o)}const c=Math.max(...n),h=Math.max(...s);return{x:c*r,y:h*o}}getStretchRect(t){const n=t.auxiliaryManager.selectManager.getSelectBounds();return D.rectNode2Rect(n)}}class Ya extends ae{constructor(){super([new Xa])}streamEnable(e,t){const n=t.detect(W.Stretch,e);return n?n.nodes.length>1:!1}}class Fa{}class fd extends Fa{constructor(){super(...arguments);g(this,"polylineHandler",new En)}enable(t){return t.isPolyLine()}handleMove(t,n,s){const{line:r}=n,o=this.handle(t,n,s),i=T.dealWithEndPolyPoints(o,s.gmlRender.getScale(),!n.isStart),a=r.globalTransform().inverseMatrix(),c=i.map(u=>a.crossPoint(u)),h=D.rectNode2Rect(T.getBoundsByPoints(c));return{id:r.id,props:[{type:R.Line,points:c},gt.create({x:h.x,y:h.y,width:h.width,height:h.height})]}}handleUp(t,n,s,r){const{line:o}=n,i=this.handle(t,n,s),a=T.dealWithEndPolyPointsInUp(i,s.gmlRender.getScale(),!n.isStart),c=o.globalTransform().inverseMatrix(),h=a.map(p=>c.crossPoint(p)),d=D.rectNode2Rect(T.getBoundsByPoints(h));return{id:o.id,props:[{type:R.Line,points:h},gt.create({x:d.x,y:d.y,width:d.width,height:d.height}),r]}}handle(t,n,s){const{line:r}=n,o=r.lineProps;let i=[];return o.auto?i=this.autoLayoutLine(t,n,s):i=this.editLine(t,n,s),i}autoLayoutLine(t,n,s){const{line:r,isStart:o}=n,i=r.connectProps;if(o){const a=t,c=$t.computeConnectInfo(r,i.end,s,!0);return this.polylineHandler.layoutToPointsPro(a,c)}else{const a=t,c=$t.computeConnectInfo(r,i.start,s,!1);return this.polylineHandler.layoutToPointsPro(c,a)}}editLine(t,n,s){const{line:r,isStart:o}=n,i=[...r.globalLinePoints];if(i.length===2)return this.autoLayoutLine(t,n,s);const a=t.point;if(o){const c=i[0],h=i[1],d=T.judgeHorizon(c,h);if(i.length>3){const u=i[2];T.distance(h,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}c.x=a.x,c.y=a.y,d?h.y=c.y:h.x=c.x}else{const c=i[i.length-2],h=i[i.length-1],d=T.judgeHorizon(c,h);if(i.length>3){const u=i[i.length-3];T.distance(c,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}h.x=a.x,h.y=a.y,d?c.y=h.y:c.x=h.x}return i}}class gd extends Fa{enable(e){const t=e.shapeType;return t===Lt.Line||t===Lt.Curve}handle(e,t,n){const{line:s,isStart:r}=t,o=[...s.globalLinePoints];return r?(o.shift(),o.unshift(e.point)):(o.pop(),o.push(e.point)),o}handleMove(e,t,n){const{line:s}=t,r=this.handle(e,t,n),o=s.globalTransform().inverseMatrix(),i=r.map(c=>o.crossPoint(c)),a=D.rectNode2Rect(T.getBoundsByPoints(i));return{id:s.id,props:[{type:R.Line,points:i},gt.create({x:a.x,y:a.y,width:a.width,height:a.height})]}}handleUp(e,t,n,s){const{line:r}=t,o=this.handle(e,t,n),i=r.globalTransform().inverseMatrix(),a=o.map(h=>i.crossPoint(h)),c=D.rectNode2Rect(T.getBoundsByPoints(a));return{id:r.id,props:[{type:R.Line,points:a},gt.create({x:c.x,y:c.y,width:c.width,height:c.height}),s]}}}class Va extends ge{constructor(){super(...arguments);g(this,"res",null);g(this,"connectEndProp");g(this,"alignWorker",new cn);g(this,"handlers",[new fd,new gd]);g(this,"currentHandler",null)}selectHandler(){const{line:t,isStart:n}=this.res;for(const s of this.handlers)s.enable(t)&&(this.currentHandler=s)}computeConnectProp(t,n){const s=n.detect(W.LineEndPoint,t);if(!s)return;this.res=s;const r=s.line.connectProps;if(s.isStart){const o=$t.computeConnectInfo(s.line,r.end,n,!0);this.connectEndProp={isStart:!1,connectInfo:o}}}onStart(t,n){this.computeConnectProp(t,n),this.selectHandler(),n.execAction(new nt),this.removeConnectInfoAndSendMsg(t,n)}onMove(t,n){if(!this.res)return;const s=this.getConnectInfo(t,n),r=this.currentHandler.handleMove(s,this.res,n);n.execAction(new ct({infos:[r]},{streaming:!0}))}onUp(t,n){if(!this.res)return;const s=this.addConnectInfoAndSendMsg(t,n),r=this.getConnectInfo(t,n),o=this.currentHandler.handleUp(r,this.res,n,s);n.execAction(new ct({infos:[o]},{streaming:!1}))}getConnectInfo(t,n){const r={point:this.alignWorker.alignLineEndAndDrawAlignLines(t,n)},o=n.detect(W.NodeEdge,t);return o&&(r.point=new m(o.point.x,o.point.y),r.nodeConnect={rect:D.rectNode2Rect(o.node.getBounds()),endType:T.computeNodeConnectEnd(o.relativePos,o.node.baseProps.angle)}),r}addConnectInfoAndSendMsg(t,n){const{line:s,isStart:r}=this.res,o=s.connectProps.clone(),i=r?"start":"end",a=n.detect(W.NodeEdge,t);return a?o[i]={objectId:a.node.id,x:a.relativePos.x,y:a.relativePos.y}:o[i]=null,o}removeConnectInfoAndSendMsg(t,n){const{line:s,isStart:r}=this.res,o=s.connectProps.clone(),i=r?"start":"end";o[i]=null;const a={id:s.id,props:[o]};n.execAction(new ct({infos:[a]}))}}class Js{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]))}process(e,t){if(t.toolManager.currentTool!==ft.LINE)return;const s=t.detect(W.BufferNode,e);if(!s)return;const r=s.filter(o=>o.canBeConnected());r.length!==0&&(t.auxiliaryManager.selectManager.include(r[0])||r[0].canBeConnected()&&t.addOrUpdate(N.HoverConnectAnchorPoint,{node:r[0]}))}}class tr{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]))}process(e,t){if(t.toolManager.currentTool!==ft.LINE)return;const s=t.detect(W.HoverConnectAnchor,e);if(s){t.addOrUpdate(N.HoverConnectAnchor,{point:s.globalPoint});return}const r=t.detect(W.HoverNodeAnchor,e);r&&t.addOrUpdate(N.HoverAnchorPoint,{node:r.node,localPoint:r.localPoint})}}class er{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]))}process(e,t){if(t.toolManager.currentTool!==ft.LINE)return;const s=t.detect(W.NodeEdge,e);s&&t.addOrUpdate(N.HoverConnectPoint,{point:s.point})}}class yd extends ae{constructor(){super([new Va],[new Js,new tr,new er])}streamEnable(e,t){return!!t.detect(W.LineEndPoint,e)}}class nr{setPointValue(e,t,n,s){e?(t.y=s.y,n.y=s.y):(t.x=s.x,n.x=s.x)}}class md extends nr{enable(e){const{rIndex:t,lIndex:n,line:s}=e,r=[...s.points];return n>0&&t<r.length-1}handle(e,t,n){const{rIndex:s,lIndex:r,line:o,isHorizon:i}=e,a=[...o.points],c=o.toLocal(t.globalPoint),h=a[r],d=a[s],u=a[s+1],p=a[r-1],f=n.gmlRender.getScale();return T.distance(p,h)<3/f&&(i?Math.abs(c.y-p.y)<6/f:Math.abs(c.x-p.x)<6/f)?i?c.y=p.y:c.x=p.x:T.distance(d,u)<3/f&&(i?Math.abs(c.y-u.y)<6/f:Math.abs(c.x-u.x)<6/f)&&(i?c.y=u.y:c.x=u.x),this.setPointValue(i,h,d,c),a}setPointValue(e,t,n,s){e?(t.y=s.y,n.y=s.y):(t.x=s.x,n.x=s.x)}}class wd extends nr{enable(e){const{rIndex:t,lIndex:n,line:s}=e,r=[...s.points];return n===0&&t===1&&r.length===2}handle(e,t){const{rIndex:n,lIndex:s,line:r,isHorizon:o}=e,i=[...r.points],{start:a,end:c}=r.connectProps,h=i[s],d=i[n],u=r.toLocal(t.globalPoint);if(!a&&!c)return this.setPointValue(o,h,d,u),i;if(c&&!a){if(o){const w=d.x>h.x?1:-1,b=new m(d.x-w*M,d.y),x=new m(d.x-w*M,u.y);return i.splice(s+1,0,b,x),e.lIndex=s+2,e.rIndex=n+2,i}const p=d.y>h.y?1:-1,f=new m(d.x,d.y-p*M),y=new m(u.x,d.y-p*M);return i.splice(s+1,0,f,y),e.lIndex=s+2,e.rIndex=n+2,i}if(a&&!c){if(o){const w=d.x>h.x?1:-1,b=new m(h.x+w*M,h.y),x=new m(h.x+w*M,u.y);return i.splice(s+1,0,b,x),e.lIndex=s+2,e.rIndex=n+2,i}const p=d.y>h.y?1:-1,f=new m(h.x,h.y-p*M),y=new m(u.x,h.y-p*M);return i.splice(s+1,0,f,y),e.lIndex=s+2,e.rIndex=n+2,i}if(a&&c){if(o){const x=d.x>h.x?1:-1,v=new m(h.x+x*M,h.y),C=new m(h.x+x*M,u.y),E=new m(d.x-x*M,d.y),k=new m(d.x-x*M,u.y);return i.splice(s+1,0,v,C,E,k),e.lIndex=s+4,e.rIndex=n+4,i}const p=d.y>h.y?1:-1,f=new m(h.x,h.y-p*M),y=new m(u.x,h.y-p*M),w=new m(d.x,d.y-p*M),b=new m(u.x,d.y-p*M);return i.splice(s+1,0,f,y,w,b),e.lIndex=s+4,e.rIndex=n+4,i}return[]}}class xd extends nr{enable(e){const{lIndex:t}=e;return t===0}handle(e,t){const{rIndex:n,lIndex:s,line:r,isHorizon:o}=e,i=[...r.points],{start:a,end:c}=r.connectProps,h=i[s],d=i[n],u=r.toLocal(t.globalPoint);if(!a)return this.setPointValue(o,h,d,u),i;if(o){const w=d.x>h.x?1:-1,b=new m(h.x+w*M,h.y),x=new m(h.x+w*M,u.y);return i.splice(s+1,0,b,x),e.lIndex=s+2,e.rIndex=n+2,i}const p=d.y<h.y?1:-1,f=new m(h.x,h.y-p*M),y=new m(u.x,h.y-p*M);return i.splice(s+1,0,f,y),e.lIndex=s+2,e.rIndex=n+2,i}}class Pd extends nr{enable(e){const{rIndex:t,line:n}=e;return t===n.points.length-1}handle(e,t){const{rIndex:n,lIndex:s,line:r,isHorizon:o}=e,i=[...r.points],{end:a}=r.connectProps,c=i[s],h=i[n],d=r.toLocal(t.globalPoint);if(!a)return this.setPointValue(o,c,h,d),i;if(o){const y=h.x<c.x?1:-1,w=new m(h.x+y*M,h.y),b=new m(h.x+y*M,d.y);return i.splice(s+1,0,b,w),c.y=d.y,i}const u=h.y>c.y?1:-1,p=new m(h.x,h.y-u*M),f=new m(d.x,h.y-u*M);return i.splice(s+1,0,f,p),c.x=d.x,i}}class bd extends ge{constructor(){super(...arguments);g(this,"res");g(this,"handlers",[new md,new wd,new xd,new Pd])}onStart(t,n){this.res=n.detect(W.PolyControlPoint,t),n.execAction(new nt)}onMove(t,n){const{line:s}=this.res,r=this.computeLinePoints(t,n),o=D.rectNode2Rect(T.getBoundsByPoints(r)),i={infos:[{id:s.id,props:[{type:R.Line,points:r,auto:!1},gt.create({x:o.x,y:o.y,width:o.width,height:o.height})]}]};n.execAction(new ct(i,{streaming:!0}))}onUp(t,n){const{line:s}=this.res,r=n.gmlRender.getScale(),o=this.computeLinePoints(t,n),i=T.dealWithPolyPoints(o,r),a=D.rectNode2Rect(T.getBoundsByPoints(i)),c={infos:[{id:s.id,props:[{type:R.Line,points:i,auto:!1},gt.create({x:a.x,y:a.y,width:a.width,height:a.height})]}]};n.execAction(new ct(c,{streaming:!1})),n.execAction(new et)}computeLinePoints(t,n){for(const s of this.handlers)if(s.enable(this.res))return s.handle(this.res,t,n);return[]}}class vd extends ae{constructor(){super([new bd],[])}streamEnable(e,t){return!!t.detect(W.PolyControlPoint,e)}}class Md extends ge{constructor(){super(...arguments);g(this,"startConnectInfo",{point:new m});g(this,"target",null);g(this,"layoutHandler",new En);g(this,"alignWorker",new cn)}onStart(t,n){this.startConnectInfo.point=t.globalPoint;const r=[new jt(Lt.RoundPolyLine)],{node:o,relative:i}=n.detect(W.HoverConnectAnchor,t),a={type:R.Connect,start:{objectId:o.id,x:i.x,y:i.y}};r.push(a);const c=$t.getNodePos(o,i);this.startConnectInfo={point:new m(c.x,c.y),nodeConnect:{rect:D.rectNode2Rect(o.getBounds()),endType:T.computeNodeConnectEnd(i,o.baseProps.angle)}};const h={point:t.globalPoint.clone()},d=this.layoutHandler.layoutToPointsPro(this.startConnectInfo,h),u=he.create(d),p=D.rectNode2Rect(T.getBoundsByPoints(d)),f=gt.create({x:p.x,y:p.y,width:p.width,height:p.height});r.push(u,f,new Ot,Ie.create({rArrow:we.Arrow}),se.create({sizeMode:le.autoWidth}),new bn);const y=n.idGenerator.genId(A.Line),w={id:y,type:A.Line,zIndex:Qt.genZIndex(n.nodeManager.root),parentId:"",props:r};n.actionManager.execAction(new nt);const b=Yt.create(w);n.actionManager.execAction(b),this.target=n.nodeManager.nodeMap.get(y),n.actionManager.execAction(Pt.create([this.target.id])),n.setCursor("crosshair")}onMove(t,n){const s=$t.computeLinePoints(this.startConnectInfo,this.layoutHandler,t,n,this.alignWorker),r=T.dealWithEndPolyPoints(s,n.gmlRender.getScale(),!0),o=D.rectNode2Rect(T.getBoundsByPoints(r)),i=[he.create(r),gt.create({x:o.x,y:o.y,width:o.width,height:o.height})],a={infos:[{id:this.target.id,props:i}]};n.actionManager.execAction(new ct(a,{streaming:!0}))}onUp(t,n){const s=[],r=n.detect(W.NodeEdge,t);if(r){const h=this.target.connectProps.clone();h.end={objectId:r.node.id,x:r.relativePos.x,y:r.relativePos.y},s.push(h)}const o=$t.computeLinePoints(this.startConnectInfo,this.layoutHandler,t,n,this.alignWorker),i=T.dealWithEndPolyPointsInUp(o,n.gmlRender.getScale(),!0),a=D.rectNode2Rect(T.getBoundsByPoints(i));s.push(he.create(i),gt.create({x:a.x,y:a.y,width:a.width,height:a.height}));const c={infos:[{id:this.target.id,props:s}]};if(n.actionManager.execAction(new ct(c,{streaming:!1})),!r){n.execAction(Pt.create([]));const h={clientPoint:t.clientPoint,show:!0,lineId:this.target.id};n.slotManager.addSlotState(te.QuickCreate,h)}n.execAction(new et),n.setCursor("default")}}class Sd extends ae{constructor(){super([new Md],[new Js,new tr,new er])}streamEnable(e,t){return!!t.detect(W.HoverConnectAnchor,e)}}class ho{}const Td=new Set([A.Shape,A.SVG,A.IMG]);class Cd extends ho{enable(e){return Td.has(e.type)}handle(e,t,n,s){const r=e.baseProps,o=new m(0,0),i=e.toGlobal(o),a=t.crossPoint(i),h=e.parent.globalTransform().inverseMatrix().crossPoint(a);s.push({id:e.id,props:[{type:R.Base,x:h.x,y:h.y,angle:r.angle+n}]})}}class Ld extends ho{enable(e){return e.type===A.Line}handle(e,t,n,s){const{start:r,end:o}=e.connectProps;if(r||o)return;const i=e.lineProps,a=[],c=[];for(const u of i.points){const p=t.crossPoint(u);a.push(p)}c.push({type:R.Line,points:a});const h=T.getBoundsByPoints(a),d={type:R.Base,x:h.minX,y:h.minY,width:h.maxX-h.minX,height:h.maxY-h.minY};c.push(d),s.push({id:e.id,props:c})}}class Ad extends ho{constructor(){super(...arguments);g(this,"layoutHandler",new En)}enable(t){return t.type!==A.Line?!1:t.isPolyLine()}handle(t,n,s,r){const{start:o,end:i}=t.connectProps;if(o||i)return;const a=t.lineProps,c=[],h=a.points[0],d=a.points[a.points.length-1],u=n.crossPoint(h),p=n.crossPoint(d),f=this.layoutHandler.layoutToPointsPro({point:u},{point:p});c.push({type:R.Line,points:f});const y=T.getBoundsByPoints(f),w={type:R.Base,x:y.minX,y:y.minY,width:y.maxX-y.minX,height:y.maxY-y.minY};c.push(w),r.push({id:t.id,props:c})}}class Wa extends ge{constructor(){super(...arguments);g(this,"rotateInfo",null);g(this,"lastAngle",0);g(this,"originAngle",0);g(this,"originNodeAngle",0);g(this,"matrix",Z.generateMatrix());g(this,"reverseMatrix",Z.generateMatrix());g(this,"layoutWorker",new Ms);g(this,"groupBaseWorker",new Zr);g(this,"handlers",[new Cd,new Ad,new Ld])}onStart(t,n){this.rotateInfo=n.detect(W.Rotate,t);const s=$t.trimPoint(t.globalPoint),r=this.rotateInfo.rotateCenter,o=this.rotateInfo.nodes;o.length===1?this.originNodeAngle=o[0].baseProps.angle:this.originNodeAngle=0,this.lastAngle=$t.calculateAngle(r,s),this.originAngle=this.lastAngle;const i=Z.generateMatrix().translate(-r.x,-r.y);this.matrix=i,this.reverseMatrix=i.inverseMatrix(),n.actionManager.execAction(new nt),n.inputManager.editTextInfo&&n.execAction(lt.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.rotateInfo.nodes)}onMove(t,n){this.rotateNode(t,n,!0),this.removeAuxiliaryGraphics(n)}onUp(t,n){this.rotateNode(t,n,!1),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.setCursor("default"),n.actionManager.execAction(new et),this.rotateInfo=null}removeAuxiliaryGraphics(t){t.removeAuxGraphic(N.HighlightRects),t.removeAuxGraphic(N.MultiSelectBound),t.removeAuxGraphic(N.SingleSelectBound),t.removeAuxGraphic(N.StretchRect),t.removeAuxGraphic(N.ExpandShape),t.removeAuxGraphic(N.SelectConnectAnchor)}rotateNode(t,n,s){const r=$t.trimPoint(t.globalPoint),o=this.rotateInfo.rotateCenter;let i=$t.calculateAngle(o,r);i=this.computeDeltaAngle(t,i);const a=i-this.lastAngle,c=Z.generateMatrix().rotate(a),h=this.reverseMatrix.crossProduct(c).crossProduct(this.matrix),d=[],u=new Set;for(const p of this.rotateInfo.nodes){for(const f of this.handlers)if(f.enable(p)){f.handle(p,h,a,d);break}this.layoutWorker.collectNodeLinks(p,n,u)}n.execAction(new ct({infos:d},{streaming:s})),this.lastAngle=i,this.layoutWorker.work([...u],n,s),this.groupBaseWorker.work(n,s)}computeDeltaAngle(t,n){if(t.originEvent.ctrlKey)return n;let s=n-this.originAngle+this.originNodeAngle;const r=$t.trimAngle(s),o=7.5;return Math.abs(r)<o?(s+=0-r,s+this.originAngle-this.originNodeAngle):Math.abs(r-90)<o?(s+=90-r,s+this.originAngle-this.originNodeAngle):Math.abs(r-180)<o?(s+=180-r,s+this.originAngle-this.originNodeAngle):Math.abs(r-270)<o?(s+=270-r,s+this.originAngle-this.originNodeAngle):Math.abs(r-360)<o?(s+=360-r,s+this.originAngle-this.originNodeAngle):n}}class Ga extends ae{constructor(){super([new Wa])}streamEnable(e,t){return!!t.detect(W.Rotate,e)}}const Rn=100,je=50;class Ua{computeEndNodeRelative(e,t){const n=e.drawer.getConnectAnchor(),s=T.computeOriginNodeConnectEnd(t);let r;return s===Mt.Top?r=n[Mt.Bottom]:s===Mt.Bottom?r=n[Mt.Top]:s===Mt.Left?r=n[Mt.Right]:r=n[Mt.Left],r}computePreviewNodePos(e,t,n){const s=T.computeNodeConnectEnd(t,e.baseProps.angle);return s===Mt.Top?this.findTopPlace(e,s,n):s===Mt.Bottom?this.findBottomPlace(e,s,n):s===Mt.Left?this.findLeftPlace(e,s,n):this.findRightPlace(e,s,n)}findTopPlace(e,t,n){const s=e.globalBaseProps;for(let r=0;r<20;r++){const o=s.clone();o.y=s.y-s.height-Rn;const i=r%2,a=Math.ceil(r/2);i?o.x-=a*(s.width+je):o.x+=a*(s.width+je);const c=T.getBoundsByBaseProps(o);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==A.Line&&d.type!==A.Section).length===0)return{x:o.x,y:o.y}}return{x:s.x,y:s.y-s.height-je}}findBottomPlace(e,t,n){const s=e.globalBaseProps;for(let r=0;r<20;r++){const o=s.clone();o.y=s.y+s.height+Rn;const i=r%2,a=Math.ceil(r/2);i?o.x-=a*(s.width+je):o.x+=a*(s.width+je);const c=T.getBoundsByBaseProps(o);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==A.Line&&d.type!==A.Section).length===0)return{x:o.x,y:o.y}}return{x:s.x,y:s.y+s.height+Rn}}findRightPlace(e,t,n){const s=e.globalBaseProps;for(let r=0;r<20;r++){const o=s.clone();o.x=s.x+s.width+Rn;const i=r%2,a=Math.ceil(r/2);i?o.y-=a*(s.width+je):o.y+=a*(s.width+je);const c=T.getBoundsByBaseProps(o);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==A.Line&&d.type!==A.Section).length===0)return{x:o.x,y:o.y}}return{x:s.x+s.width+Rn,y:s.y}}findLeftPlace(e,t,n){const s=e.globalBaseProps;for(let r=0;r<20;r++){const o=s.clone();o.x=s.x-s.width-Rn;const i=r%2,a=Math.ceil(r/2);i?o.y-=a*(s.width+je):o.y+=a*(s.width+je);const c=T.getBoundsByBaseProps(o);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==A.Line&&d.type!==A.Section).length===0)return{x:o.x,y:o.y}}return{x:s.x-s.width-Rn,y:s.y}}}class Rd extends ee{constructor(){super(...arguments);g(this,"createWorker",new Ua);g(this,"layoutHandler",new En)}enable(t,n){const s=n.detect(W.HoverConnectAnchor,t);return s?s.node.type===A.Shape:!1}isParentRoot(t,n,s){const r=t.parent;if(r===s.nodeManager.root)return!0;const o=t.getBounds(),i=t.globalPos,a=n.x-i.x,c=n.y-i.y,h={minX:o.minX+a,minY:o.minY+c,maxX:o.maxX+a,maxY:o.maxY+c},d=r.getBounds();return!(T.containRect(d,h)||T.overlapRect(d,h))}handle(t,n){const s=n.detect(W.HoverConnectAnchor,t),r=s.node,o=s.relative,i=r.baseProps,a=r.toGlobal({x:o.x*i.width,y:o.y*i.height}),c=this.createWorker.computePreviewNodePos(r,o,n),h=this.createWorker.computeEndNodeRelative(r,o),d=this.isParentRoot(r,c,n),u=this.makeupNodeProps(r,c,d),p=n.idGenerator.genId(A.Shape);n.execAction(new nt),n.execAction(Yt.create({id:p,zIndex:Qt.genZIndex(n.nodeManager.root),type:A.Shape,props:u,parentId:d?"":r.parent.id}));const f=n.nodeManager.getNode(p),y=f.baseProps,w=f.toGlobal({x:h.x*y.width,y:h.y*y.height}),b={point:a,nodeConnect:{rect:D.rectNode2Rect(r.getBounds()),endType:T.computeNodeConnectEnd(o,r.baseProps.angle)}},x={point:w,nodeConnect:{rect:D.rectNode2Rect(f.getBounds()),endType:T.computeNodeConnectEnd(h,f.baseProps.angle)}},v=this.makeupLineProps(b,x,r.parent,d);v.push({type:R.Connect,start:{objectId:r.id,x:o.x,y:o.y},end:{objectId:p,x:h.x,y:h.y}});const C=n.idGenerator.genId(A.Line);if(n.execAction(Yt.create({id:C,zIndex:Qt.genZIndex(n.nodeManager.root),type:A.Line,props:v,parentId:d?"":r.parent.id})),n.execAction(Pt.create([p])),f.type===A.Shape&&f.shapeType===_.PureText){const E=f.renderText;n.execAction(lt.selection(p,E.headTextCursorPosition(),E.tailTextCursorPosition()))}else n.execAction(lt.focus(p));n.execAction(new et)}makeupNodeProps(t,n,s){const r=t.baseProps,o=t.shapeType;let i=n;s||(i=t.parent.globalTransform().inverseMatrix().crossPoint(i));const a=i.x,c=i.y,h=t.colorProps,d=t.borderProps,u=[{type:R.Base,x:a,y:c,width:r.width,height:r.height,angle:r.angle},Jt.create({...h}),Ot.create({...d}),new jt(o)];if(t.type===A.Shape&&t.shapeType===_.PureText){const p=t.textProps;u.push(p.clone())}return u}makeupLineProps(t,n,s,r){let o=this.layoutHandler.layoutToPointsPro(t,n);if(!r){const c=s.globalTransform().inverseMatrix();o=o.map(h=>c.crossPoint(h))}const i=D.rectNode2Rect(T.getBoundsByPoints(o));return[he.create(o),gt.create({x:i.x,y:i.y,width:i.width,height:i.height}),Ie.create({rArrow:we.Arrow}),new jt(Lt.RoundPolyLine)]}}class Nd extends We{constructor(){super(),this.registerUpHandler(new Rd)}}class Ed extends ln{constructor(){super([new Nd])}clickEnable(e,t){return!!t.detect(W.HoverConnectAnchor,e)}}class _a extends ee{constructor(){super(...arguments);g(this,"group",null)}enable(t,n){const s=[...n.getSelectNodes()];if(s.length!==1)return!1;const r=s[0];if(r.type!==A.Group)return!1;const o=r;return o.contains(t.globalPoint)?(this.group=o,!0):!1}handle(t,n){if(this.group){for(const s of this.group.children)if(s.contains(t.globalPoint)){n.execAction(new nt),n.execAction(Pt.create([s.id])),n.execAction(new et);return}}}}class Id extends ee{constructor(){super(...arguments);g(this,"res",null)}enable(t,n){const s=n.detect(W.Node,t);if(s){const r=s[0];if(n.auxiliaryManager.selectManager.include(r)){const o=r.toLocal(t.globalPoint);if(r instanceof qe&&r.renderText.contains(o))return this.res={node:r,relativePos:o},!0;if(r instanceof dn)return this.res={node:r,relativePos:o},!0}}return!1}handle(t,n){if(!this.res)return;const{node:s,relativePos:r}=this.res;if(s.textProps.text===""){const i=s.renderText.detect(r);n.execAction(new nt),n.execAction(lt.focus(s.id,i)),n.execAction(new et);return}n.execAction(new nt),n.execAction(lt.selection(s.id,Ht.head(),s.renderText.tailTextCursorPosition())),n.execAction(new et)}}class kd extends We{constructor(){super(),this.registerDownHandler(new _a),this.registerDownHandler(new Id)}}class Bd extends Qr{constructor(){super([new kd])}}class Od extends ee{constructor(){super(...arguments);g(this,"node",null)}enable(t,n){return!0}handle(t,n){if(n.getSelectNodes().size>0){const o=n.auxiliaryManager.selectManager.getSelectBounds();if(T.rectContains2(t.globalPoint,o)){const i={clientPoint:t.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(te.ContextMenu,i);return}}const s=n.detect(W.Node,t);if(s&&s.length>0){const o=s[0];n.auxiliaryManager.selectManager.include(o)||(n.execAction(new nt),n.execAction(Pt.create([o.id])),n.execAction(new et))}else n.execAction(new nt),n.execAction(Pt.create([])),n.execAction(new et);const r={clientPoint:t.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(te.ContextMenu,r)}}class Dd extends We{constructor(){super(),this.registerUpHandler(new Od)}}class Hd extends ln{constructor(){super([new Dd])}canBeEnable(e,t){return e.originEvent.button===2}}class Ka extends ge{constructor(){super(...arguments);g(this,"lastPoint",null)}onStart(t,n){this.lastPoint=t.clientPoint,n.setCursor("grabbing")}onMove(t,n){if(!this.lastPoint)return;n.setCursor("grabbing");const s=t.clientPoint,r=s.x-this.lastPoint.x,o=s.y-this.lastPoint.y;n.renderManager.scroll(-r,-o),this.lastPoint=s}onUp(t,n){n.setCursor("grab")}}class zd extends ae{constructor(){super([new Ka])}streamEnable(e,t){return e.originEvent.button===2}}class ja extends Kn{constructor(){super([new zd,new Ed,new Sd,new vd,new yd,new fa,new ya,new Ya,new Ga,new Ca,new so,new Bd,new Hd,new ka,new za])}canBeEnable(e,t){return!0}}class qa extends ne{onDetect(e,t){const n=t.getSelectNodes();if(n.size!==1)return!1;const s=[...n][0];if(s.type!==A.Shape)return!1;const r=s,o=r.getTextContentRect();if(r.renderText.height<o.height)return!1;const i=t.gmlRender.getScale(),a=r.toLocal(e.globalPoint),{width:c,height:h}=r.baseProps,d=new D(.5*c-.5*21/i,h-.5*12/i,21/i,12/i);return T.rectContains(a,d)?(this.result={node:r,realHeight:r.drawer.fullTextNodeHeight(r)},!0):!1}}class $a extends ne{onDetect(e,t){const n=t.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const s=[...n][0];if(s.type!==A.Line)return!1;const r=s,i=8/t.gmlRender.getScale(),a=r.points,c=a[0],h=a[a.length-1],d=r.toLocal(e.globalPoint);let u=T.circleContains(d,c,i);return u?(this.result={detectPoint:c,isStart:!0,line:r},!0):(u=T.circleContains(d,h,i),u?(this.result={detectPoint:h,isStart:!1,line:r},!0):!1)}}const Xd=12;class Yd extends ne{onDetect(e,t){const n=t.detect(W.HoverConnectAnchor,e);if(n){const u=$t.getNodePos(n.node,n.relative);return this.result={node:n.node,point:u,relativePos:n.relative},!0}const s=t.detect(W.HoverNodeAnchor,e);if(s){const u=$t.getNodePos(s.node,s.ratio);return this.result={node:s.node,point:u,relativePos:s.ratio},!0}const r=t.detect(W.BufferNode,e);if(!r)return!1;const o=r.filter(u=>u.canBeConnected());if(o.length===0)return!1;const i=o[0];if(!i.canBeConnected())return!1;const a=t.renderManager.getScale(),{width:c,height:h}=i.baseProps,d=i.borderContains(e.globalPoint,Xd/a);return d?(this.result={node:i,point:i.toGlobal(d),relativePos:new m(d.x/c,d.y/h)},!0):!1}}class sr extends ge{constructor(){super(...arguments);g(this,"startPos",new m);g(this,"target",null);g(this,"viewBounds");g(this,"alignWorker",new cn)}nodeType(){return A.Shape}autoFocus(){return!0}onStart(t,n){n.previewManager.resetPreviewNode(n),n.alignPoint?(this.startPos=n.alignPoint,n.alignPoint=null):this.startPos=t.globalPoint;const s=n.detect(W.HoverOnContainer,t);let r=n.nodeManager.root,o=new m(this.startPos.x,this.startPos.y);s&&(o=s.toLocal(this.startPos),r=s);const i=this.nodeType(),a=n.idGenerator.genId(i),c=this.makeupDefaultProps(n,o),h={id:a,type:i,zIndex:Qt.genZIndex(r),parentId:r.id,props:c};n.actionManager.execAction(new nt);const d=Yt.create(h);n.actionManager.execAction(d),this.target=n.nodeManager.nodeMap.get(a);const u=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(N.CreateRectBound,{rect:u,transform:this.target.globalTransform()}),n.auxiliaryManager.removeAlignGraphics(),this.viewBounds=n.gmlRender.getViewPortBounds()}onMove(t,n){if(!this.target)return;n.auxiliaryManager.removeAlignGraphics();const s=this.target.baseProps.clone(),r=new Set([this.target]),o=this.alignWorker.alignLineEndAndDrawAlignLines(t,n,r);this.computeRectBounds(o,s);const i=n.gmlRender.getScale(),a=D.baseProps2Rect(s),c=new Set(n.getSelectNodes());c.add(this.target);const h=this.alignWorker.alignStretch(n,a,c,It.both,this.viewBounds,js/i,Ks/i);this.drawAlignLine(a,h,n);const d=new m(a.x,a.y),u=this.target.parent.toLocal(d),p={type:R.Base,x:u.x,y:u.y,width:a.width,height:a.height},f=ct.create(this.target.id,[p],{streaming:!0});n.actionManager.execAction(f);const y=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(N.CreateRectBound,{rect:y,transform:this.target.globalTransform()})}onUp(t,n){if(!this.target)return;const s=this.target.baseProps.clone(),r=new Set([this.target]),o=this.alignWorker.alignLineEndAndDrawAlignLines(t,n,r);this.computeRectBounds(o,s);const i=n.gmlRender.getScale(),a=D.baseProps2Rect(s),c=new Set(n.getSelectNodes());c.add(this.target);const h=this.alignWorker.alignStretch(n,a,c,It.both,this.viewBounds,js/i,Ks/i);this.drawAlignLine(a,h,n);const d=new m(a.x,a.y),u=this.target.parent.toLocal(d),p={type:R.Base,x:u.x,y:u.y,width:a.width,height:a.height},{width:f,height:y}=this.computeMiniSize(),w=this.computeDefaultSize(n);(T.distance(this.startPos,t.globalPoint)<5/i||p.width<f||p.height<y)&&(p.width=w.width,p.height=w.height);const b=ct.create(this.target.id,[p]);n.actionManager.execAction(b),n.actionManager.execAction(Pt.create([this.target.id])),this.autoFocus()&&n.actionManager.execAction(lt.focus(this.target.id)),n.actionManager.execAction(new et),this.target=null,n.toolManager.resetTool(),n.removeAuxGraphic(N.CreateRectBound),n.auxiliaryManager.removeAlignGraphics(),n.setCursor("default")}computeRectBounds(t,n){this.target&&(t.x>=this.startPos.x&&t.y>=n.y?(n.x=this.startPos.x,n.y=this.startPos.y,n.width=t.x-this.startPos.x,n.height=t.y-this.startPos.y):t.x>this.startPos.x&&t.y<n.y?(n.x=this.startPos.x,n.y=t.y,n.width=t.x-this.startPos.x,n.height=this.startPos.y-t.y):t.x<this.startPos.x&&t.y>n.y?(n.x=t.x,n.y=this.startPos.y,n.width=this.startPos.x-t.x,n.height=t.y-this.startPos.y):t.x<=this.startPos.x&&t.y<=n.y?(n.x=t.x,n.y=t.y,n.width=this.startPos.x-t.x,n.height=this.startPos.y-t.y):(n.x=t.x,n.y=t.y,n.width=t.x-this.startPos.x,n.height=t.y-this.startPos.y))}drawAlignLine(t,n,s){const r=this.target,o=r.baseProps,{width:i,height:a}=n;if(i){t.width+=i.dt;const c={transform:r.transform.clone(),line:{start:new m(0,o.height),end:new m(o.width,o.height)}};i.lines.push(c)}if(a){t.height+=a.dt;const c={transform:r.transform.clone(),line:{start:new m(o.width,0),end:new m(o.width,o.height)}};a.lines.push(c)}s.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}}var _=(l=>(l[l.PureText=0]="PureText",l[l.Rect=1]="Rect",l[l.Ellipse=2]="Ellipse",l[l.Babianxing=3]="Babianxing",l[l.DoubleArrow=4]="DoubleArrow",l[l.LeftArrow=5]="LeftArrow",l[l.LeftKuohao=6]="LeftKuohao",l[l.Lingxing=7]="Lingxing",l[l.LiuBianXing=8]="LiuBianXing",l[l.LiuCheng=9]="LiuCheng",l[l.LiuCheng2=10]="LiuCheng2",l[l.PingXingsiBianXing=11]="PingXingsiBianXing",l[l.Qipao=12]="Qipao",l[l.Qipao2=13]="Qipao2",l[l.RightArrow=14]="RightArrow",l[l.RightKuohao=15]="RightKuohao",l[l.RoundRect=16]="RoundRect",l[l.RoundRect2=17]="RoundRect2",l[l.Shizi=18]="Shizi",l[l.Tixing=19]="Tixing",l[l.Triangle=20]="Triangle",l[l.Triangle2=21]="Triangle2",l[l.Wubianxing=22]="Wubianxing",l[l.WuJiaoxing=23]="WuJiaoxing",l[l.YuanZhu=24]="YuanZhu",l[l.Yunduo=25]="Yunduo",l))(_||{}),Tt=(l=>(l[l.Decision=0]="Decision",l[l.Step=1]="Step",l[l.Data=2]="Data",l[l.Status=3]="Status",l[l.Operation=4]="Operation",l[l.Others=5]="Others",l[l.Section=6]="Section",l[l.Resource=7]="Resource",l))(Tt||{});const rr={[_.PureText]:Tt.Operation,[_.Rect]:Tt.Operation,[_.RoundRect]:Tt.Step,[_.Triangle]:Tt.Operation,[_.Lingxing]:Tt.Decision,[_.Ellipse]:Tt.Status},Nn={[Tt.Status]:"#F2F3F5",[Tt.Data]:"#F0FBEF",[Tt.Operation]:"#E1EAFF",[Tt.Step]:"#E0E2FA",[Tt.Decision]:"#FEEAD2",[Tt.Others]:"#FEF1F1",[Tt.Section]:"#F4F2F3",[Tt.Resource]:""},hn={[Tt.Status]:"#DEE0E3",[Tt.Data]:"#8EE085",[Tt.Operation]:"#82A7FC",[Tt.Step]:"#7B83EA",[Tt.Decision]:"#FFBA6B",[Tt.Others]:"#F98E8B",[Tt.Section]:"#C0A9BD",[Tt.Resource]:""};class Qa extends sr{constructor(){super(...arguments);g(this,"startPos",new m);g(this,"target",null)}computeDefaultSize(){return{height:100,width:100}}computeMiniSize(){return{height:5,width:5}}makeupDefaultProps(t,n){const s=t.toolManager.shapeType,r=rr[s],o=Nn[r],i=hn[r];return[gt.create({x:n.x,y:n.y}),se.create({type:R.Text,fontSize:16,text:"",sizeMode:le.autoHeight}),Jt.create({color:o}),Ot.create({color:i}),new jt(s)]}}class Za extends qs{constructor(){super([new Qa])}streamEnable(e,t){return t.toolManager.currentTool==ft.SHAPE}}class uo{constructor(){g(this,"alignWorker",new cn)}computeLinePoints(e,t,n){return $t.computeLinePoints(e,this.layoutHandler,t,n,this.alignWorker)}alignLinePointsInMove(e,t){return e}alignLinePointsInUp(e,t){return e}computeDownProps(e,t,n,s){const o=[new jt(t.toolManager.shapeType)],i=t.detect(W.NodeEdge,t.lastDiffTypeEvent);if(i){const y={type:R.Connect,start:{objectId:i.node.id,x:i.relativePos.x,y:i.relativePos.y}};e.point=new m(i.point.x,i.point.y),e.nodeConnect={rect:D.rectNode2Rect(i.node.getBounds()),endType:T.computeNodeConnectEnd(i.relativePos,i.node.baseProps.angle)},o.push(y)}else o.push(new Pn);const a={point:new m(e.point.x+1,e.point.y+1)},c=this.layoutHandler.layoutToPointsPro(e,a),h=s.globalTransform().inverseMatrix(),d=c.map(y=>h.crossPoint(y)),u=he.create(d),p=D.rectNode2Rect(T.getBoundsByPoints(d)),f=gt.create({x:p.x,y:p.y,width:p.width,height:p.height});return o.push(u,f,new Ot,Ie.create({rArrow:we.Arrow}),se.create({sizeMode:le.autoWidth}),new bn),o}computeMoveProps(e,t,n,s){const r=this.computeLinePoints(e,t,n),o=this.alignLinePointsInMove(r,n),i=s.parent.globalTransform().inverseMatrix(),a=o.map(u=>i.crossPoint(u)),c=D.rectNode2Rect(T.getBoundsByPoints(a)),h=[he.create(a),gt.create({x:c.x,y:c.y,width:c.width,height:c.height})],d={infos:[{id:s.id,props:h}]};n.actionManager.execAction(new ct(d,{streaming:!0}))}computeUpProps(e,t,n,s){const r=[],o=n.detect(W.NodeEdge,t);if(o){const p=s.connectProps.clone();p.end={objectId:o.node.id,x:o.relativePos.x,y:o.relativePos.y},r.push(p)}const i=this.computeLinePoints(e,t,n),a=this.alignLinePointsInUp(i,n),c=s.parent.globalTransform().inverseMatrix(),h=a.map(p=>c.crossPoint(p)),d=D.rectNode2Rect(T.getBoundsByPoints(h));r.push(he.create(h),gt.create({x:d.x,y:d.y,width:d.width,height:d.height}));const u={infos:[{id:s.id,props:r}]};n.actionManager.execAction(new ct(u,{streaming:!1}))}}class or extends uo{constructor(){super(...arguments);g(this,"layoutHandler",new Qi)}enable(t){return t===Lt.Line}}class ir extends uo{constructor(){super(...arguments);g(this,"layoutHandler",new Zi)}enable(t){return t===Lt.Curve}}class ar extends uo{constructor(){super(...arguments);g(this,"layoutHandler",new En)}enable(t){return t===Lt.RoundPolyLine||t===Lt.PolyLine}alignLinePointsInMove(t,n){return T.dealWithEndPolyPoints(t,n.gmlRender.getScale(),!0)}alignLinePointsInUp(t,n){return T.dealWithEndPolyPointsInUp(t,n.gmlRender.getScale(),!0)}}class Ja extends ge{constructor(){super(...arguments);g(this,"startConnectInfo",{point:new m});g(this,"target",null);g(this,"shapeType",Lt.Line);g(this,"currentHandler",null);g(this,"handlers",[new or,new ir,new ar])}selectHandler(){for(const t of this.handlers)if(t.enable(this.shapeType)){this.currentHandler=t;return}throw new Error("类型错误:没有合适的handler处理")}onStart(t,n){this.startConnectInfo.point=t.globalPoint,this.shapeType=n.toolManager.shapeType,this.selectHandler();const s=n.detect(W.HoverOnContainer,t);let r=n.nodeManager.root;s&&(r=s);const o=this.currentHandler.computeDownProps(this.startConnectInfo,n,t,r),i=n.idGenerator.genId(A.Line),a={id:i,type:A.Line,zIndex:Qt.genZIndex(n.nodeManager.root),parentId:r.id,props:o};n.actionManager.execAction(new nt);const c=Yt.create(a);n.actionManager.execAction(c),this.target=n.nodeManager.nodeMap.get(i),n.actionManager.execAction(Pt.create([this.target.id]))}onMove(t,n){this.currentHandler.computeMoveProps(this.startConnectInfo,t,n,this.target)}onUp(t,n){this.currentHandler.computeUpProps(this.startConnectInfo,t,n,this.target),n.execAction(new et),n.setCursor("default"),n.toolManager.resetTool()}}class tc extends ae{constructor(){super([new Ja],[new Js,new tr,new er])}streamEnable(e,t){return t.toolManager.currentTool==ft.LINE}}class ec extends sr{computeDefaultSize(){return{height:0,width:0}}computeMiniSize(){return{height:0,width:0}}makeupDefaultProps(e,t){return[gt.create({x:t.x,y:t.y}),se.create({type:R.Text,fontSize:16,text:"",horizonAlign:xe.Top,verticalAlign:xe.Top}),new jt(_.PureText)]}}class nc extends ae{constructor(){super([new ec])}streamEnable(e,t){return t.toolManager.currentTool==ft.TEXT}}class Fd extends Zs{constructor(){super(...arguments);g(this,"handlers",[new Oa])}}class Vd{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]));g(this,"handlers",[new or,new ir,new ar])}process(e,t){const n=t.toolManager.creatingLine;if(!n)return;const s=this.getStartConnectInfo(n,t);for(const r of this.handlers)r.enable(n.shapeType)&&r.computeMoveProps(s,e,t,n)}getStartConnectInfo(e,t){const n=e.points,{start:s}=e.connectProps,r={point:n[0]};if(s){const o=t.nodeManager.getNode(s.objectId);o&&(r.nodeConnect={endType:T.computeNodeConnectEnd(s,o.baseProps.angle),rect:D.rectNode2Rect(o.getBounds())})}return r}}class Wd{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]));g(this,"alignWorker",new cn)}process(e,t){const n=t.previewManager.createManager;if(!n.previewGraphics)return;const s=t.toolManager.grab;t.auxiliaryManager.removeAlignGraphics();const{rectNode:r,delta:o}=this.computeMoveRect(n.previewGraphics,e.globalPoint,s),i=this.alignWorker.alignMove(r,t.getSelectNodes(),t),a=this.alignWorker.drawAlignLines(i,t),c=new m(r.minX+a.x,r.minY+a.y);t.alignPoint=c,t.previewManager.updatePos(c),t.addOrUpdate(N.PreviewGraphics,{previewNodes:[n.previewGraphics]})}computeMoveRect(e,t,n){const s=e.getBounds(),r=D.rectNode2Rect(s),o=n?r.x+.5*r.width:r.x,i=n?r.y+.5*r.height:r.y,a=new m(t.x-o,t.y-i);return s.minX+=a.x,s.maxX+=a.x,s.minY+=a.y,s.maxY+=a.y,{rectNode:s,delta:a}}}class po{handle(e,t,n){this.makeupAddNodeInfo(e,t,n).then(s=>{const r=s.id;e.actionManager.execAction(new nt);const o=Yt.create(s);e.actionManager.execAction(o),e.actionManager.execAction(Pt.create([r])),this.autoFocus()&&e.actionManager.execAction(lt.focus(r)),e.actionManager.execAction(new et),e.toolManager.resetTool(),e.previewManager.resetPreviewNode(e),e.auxiliaryManager.removeAlignGraphics()})}detectParentContainer(e,t){const n=e.detect(W.HoverOnContainer,t);let s=e.nodeManager.root;return n&&(s=n),s}}class Gd extends po{enable(e){return e===ft.SHAPE}async makeupAddNodeInfo(e,t,n){const s=e.toolManager.shapeType,r=this.detectParentContainer(e,n),o=this.makeupShapeDefaultProps(s,t,r);return{id:e.idGenerator.genId(A.Shape),type:A.Shape,zIndex:Qt.genZIndex(e.nodeManager.root),parentId:r.id,props:o}}makeupShapeDefaultProps(e,t,n){const s=rr[e]??Tt.Others,r=Nn[s],o=hn[s],i=n.toLocal(t);return[gt.create({x:i.x,y:i.y}),se.create({type:R.Text,fontSize:16,text:"",sizeMode:le.autoHeight}),Jt.create({color:r}),Ot.create({color:o}),new jt(e)]}autoFocus(){return!0}}var jn=(l=>(l[l.A4=0]="A4",l[l.S16_9=1]="S16_9",l[l.S4_3=2]="S4_3",l[l.S1_1=3]="S1_1",l))(jn||{});const cr={[jn.A4]:{width:595,height:842},[jn.S16_9]:{width:860,height:540},[jn.S4_3]:{width:860,height:720},[jn.S1_1]:{width:600,height:600}};class Ud extends po{enable(e){return e===ft.SECTION}async makeupAddNodeInfo(e,t,n){const s=this.detectParentContainer(e,n),r=this.makeupShapeDefaultProps(t,e,s);return{id:e.idGenerator.genId(A.Section),type:A.Section,zIndex:Qt.genZIndex(e.nodeManager.root),parentId:s.id,props:r}}makeupShapeDefaultProps(e,t,n){const s=t.toolManager.shapeType,r=cr[s],o=Tt.Section,i=Nn[o],a=hn[o],c=n.toLocal(e);return[gt.create({x:c.x,y:c.y,width:r.width,height:r.height}),Jt.create({color:i}),Ot.create({color:a})]}autoFocus(){return!1}}const _d="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let lr=(l=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(l|=0));for(;l--;)e+=_d[t[l]&63];return e};class fo{async addSvgNodeBySvgCode(e,t,n){const s=n.docState.docId,r=lr(10),o=`${s}/${r}`,i=await n.resourceManager.uploadSvgString(o,e),a=this.computeAddSvgNode(e,i,t,n);return{url:i,addNodeInfo:a}}computeAddSvgNode(e,t,n,s){const r=$n.trimSvgCode(e),o=[{type:R.Base,x:n.x,y:n.y,width:r.width,height:r.height},{type:R.Svg,url:t},{type:R.Border,dashType:Ee.None}];return{id:s.idGenerator.genId(A.SVG),type:A.SVG,zIndex:Qt.genZIndex(s.nodeManager.root),parentId:"",props:o}}}class Kd extends po{constructor(){super(...arguments);g(this,"svgWorker",new fo)}autoFocus(){return!1}enable(t){return t===ft.Resource}async makeupAddNodeInfo(t,n,s){const o=this.detectParentContainer(t,s).toLocal(n),i=t.previewManager.previewResourceManager.previewSvgCode;i===""&&console.error("出现错误,svg code为空");const{addNodeInfo:a}=await this.svgWorker.addSvgNodeBySvgCode(i,o,t);return a}}class jd{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointerup]));g(this,"startPos",new m);g(this,"handlers",[new Kd,new Gd,new Ud])}process(e,t){t.toolManager.grab&&(t.alignPoint?(this.startPos=t.alignPoint,t.alignPoint=null):this.startPos=e.globalPoint,this.handleCreateUp(this.startPos,t,e))}handleCreateUp(e,t,n){for(const s of this.handlers)if(s.enable(t.toolManager.currentTool)){s.handle(t,e,n);return}}}class qd extends Ve{constructor(){super([new Fd,new Js,new tr,new er,new Vd,new Wd,new jd])}canBeEnable(e,t){return!0}canBeExit(e,t){return!0}}class $d extends ee{constructor(){super(...arguments);g(this,"handlers",[new or,new ir,new ar])}enable(t,n){return!n.toolManager.creatingLine}handle(t,n){const s=n.idGenerator.genId(A.Line),r=this.makeupLineProps(t,n);if(!r)return;const o={id:s,type:A.Line,zIndex:Qt.genZIndex(n.nodeManager.root),parentId:"",props:r};n.actionManager.execAction(new nt);const i=Yt.create(o);n.actionManager.execAction(i);const a=n.nodeManager.getNode(s);n.toolManager.setInCreatingLine(a)}makeupLineProps(t,n){const s={point:t.globalPoint},o=n.detect(W.HoverOnContainer,t)??n.nodeManager.root;for(const i of this.handlers)if(i.enable(n.toolManager.shapeType))return i.computeDownProps(s,n,t,o);return null}}class Qd extends ee{constructor(){super(...arguments);g(this,"handlers",[new or,new ir,new ar])}enable(t,n){return n.previewManager.resetPreviewNode(n),n.auxiliaryManager.removeAlignGraphics(),!!n.toolManager.creatingLine}handle(t,n){const s=n.toolManager.creatingLine,r=this.getStartConnectInfo(s,n);for(const o of this.handlers)o.enable(s.shapeType)&&o.computeUpProps(r,t,n,s);n.execAction(new et),n.toolManager.setInCreatingLine(null),n.toolManager.resetTool(),n.setCursor("default")}getStartConnectInfo(t,n){const s=t.points,{start:r}=t.connectProps,o={point:s[0]};if(r){const i=n.nodeManager.getNode(r.objectId);i&&(o.nodeConnect={endType:T.computeNodeConnectEnd(r,i.baseProps.angle),rect:D.rectNode2Rect(i.getBounds())})}return o}}class Zd extends We{constructor(){super(),this.registerDownHandler(new Qd),this.registerUpHandler(new $d)}}class Jd extends ln{constructor(){super([new Zd])}clickEnable(e,t){return t.toolManager.currentTool===ft.LINE}}class tu extends ee{constructor(){super(...arguments);g(this,"res",null)}enable(t,n){return n.toolManager.currentTool===ft.TEXT}handle(t,n){const s=n.idGenerator.genId(A.Shape),r=n.detect(W.HoverOnContainer,t);let o=n.nodeManager.root,i=t.globalPoint.clone();r&&(i=r.toLocal(i),o=r);const a=this.makeupDefaultProps(i),c={id:s,type:A.Shape,zIndex:Qt.genZIndex(n.nodeManager.root),parentId:o.id,props:a};n.actionManager.execAction(new nt);const h=Yt.create(c);n.actionManager.execAction(h),n.actionManager.execAction(Pt.create([s])),n.actionManager.execAction(lt.focus(s)),n.actionManager.execAction(new et),n.toolManager.resetTool()}makeupDefaultProps(t){return[gt.create({x:t.x,y:t.y,height:22,width:64}),se.create({type:R.Text,fontSize:16,text:"",horizonAlign:xe.Top,verticalAlign:xe.Top,sizeMode:le.autoWidth}),new jt(_.PureText)]}}class eu extends ee{constructor(){super(...arguments);g(this,"res",null)}enable(t,n){const s=n.detect(W.Node,t);if(s){const r=s[0],o=r.toLocal(t.globalPoint);if(r instanceof qe&&r.renderText.contains(o))return this.res={node:r,relativePos:o},!0;if(r instanceof dn)return this.res={node:r,relativePos:o},!0}return!1}handle(t,n){if(!this.res)return;n.toolManager.resetTool();const{node:s,relativePos:r}=this.res,o=s.renderText.detect(r);n.execAction(new nt),n.execAction(Pt.create([s.id])),n.execAction(lt.focus(s.id,o)),n.execAction(new et)}}class nu extends We{constructor(){super(),this.registerUpHandler(new eu),this.registerUpHandler(new tu)}}class su extends ln{constructor(){super([new nu])}clickEnable(e,t){return t.toolManager.currentTool===ft.TEXT}}class ru extends sr{constructor(){super(...arguments);g(this,"startPos",new m);g(this,"target",null)}computeDefaultSize(t){const n=t.toolManager.shapeType,s=cr[n];return{width:s.width,height:s.height}}computeMiniSize(){return{height:5,width:5}}nodeType(){return A.Section}autoFocus(){return!1}makeupDefaultProps(t,n){const s=t.toolManager.shapeType,r=Tt.Section,o=Nn[r],i=hn[r],a=cr[s];return[gt.create({x:n.x,y:n.y,width:a.width,height:a.height}),Jt.create({color:o}),Ot.create({color:i})]}}class ou extends qs{constructor(){super([new ru])}streamEnable(e,t){return t.toolManager.currentTool==ft.SECTION}}const iu=new Set([ft.SHAPE,ft.LINE,ft.TEXT,ft.SECTION,ft.Resource]);class au extends Kn{constructor(){super([new Jd,new su,new ou,new Za,new tc,new nc,new qd])}canBeEnable(e,t){return iu.has(t.toolManager.currentTool)}}const hr=12;class cu extends ne{onDetect(e,t){const n=e.globalPoint,s=t.nodeManager.searchNodes(n.x-hr,n.y-hr,n.x+hr,n.y+hr);if(s.length===0)return this.result=null,!1;const r=T.sortGraphics(s);return r.reverse(),this.result=r,!0}}class lu extends ne{onDetect(e,t){const n=t.detect(W.BufferNode,e);if(!n)return!1;const s=n[0];return t.auxiliaryManager.selectManager.include(s)?!1:(this.result=s,!0)}}const hu=12;class du extends ne{onDetect(e,t){const n=t.detect(W.BufferNode,e);if(!n)return!1;const s=n.filter(u=>u.canBeConnected());if(s.length===0)return!1;const r=s[0];if(!r.canBeConnected()||t.auxiliaryManager.selectManager.include(r))return!1;const o=t.renderManager.getScale(),i=hu/o,{width:a,height:c}=r.baseProps,h=r.toLocal(e.globalPoint),d=r.getConnectAnchor();for(const u of d){const p=new m(u.x*a,u.y*c);if(T.circleContains(h,p,i))return this.result={node:r,ratio:u,localPoint:p},!0}return!1}}class sc extends ne{onDetect(e,t){const n=t.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const s=[...n][0];if(s.type!==A.Line)return!1;const r=s,o=t.gmlRender.getScale(),i=r.points;for(let a=0;a<i.length-1;a++){const c=i[a],h=i[a+1];if(T.distance(c,h)<(M+6)/o)continue;const u=T.judgeHorizon(c,h),p=.5*(c.x+h.x),f=.5*(c.y+h.y);let y;if(u){const x=new m(p-8/o,f);y=new D(x.x,x.y-4/o,16/o,8/o)}else{const x=new m(p,f-8/o);y=new D(x.x-4/o,x.y,8/o,16/o)}const w=r.toLocal(e.globalPoint);if(T.rectContains(w,y))return this.result={isHorizon:u,line:r,point:new m(p,f),lIndex:a,rIndex:a+1},!0}return!1}}const uu=[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)];class pu extends ne{onDetect(e,t){const n=t.getSelectNodes();if(n.size!==1)return!1;const s=[...n][0];if(!s.canBeConnected())return!1;const r=t.renderManager.getScale(),o=T.computeNodeConnectAnchor(s,r),i=Hr/r;for(let a=0;a<o.length;a++){const c=o[a],h=s.toLocal(e.globalPoint);let d=uu[a];if(T.circleContains(h,c,i))return s.type===A.Shape&&(d=s.drawer.getConnectAnchor()[a]),this.result={node:s,localPoint:c,globalPoint:s.toGlobal(c),relative:d},!0}return!1}}const Rr=class Rr extends ne{onDetect(e,t){const n=xs.flattenNodes([...t.getSelectNodes()]);if(n.length===0)return!1;const s=t.auxiliaryManager.selectManager.getSelectBounds();if(T.rectContains2(e.globalPoint,s))return!1;const r=t.gmlRender.getScale(),o=Rr.HOT_DISTANCE/r;let i=Z.generateMatrix(),a,c,h;if(n.length===1){const d=n[0];if(d.type===A.Line||d.type===A.Section)return!1;const u=d.baseProps;i=d.globalTransform().clone();const p=new m(.5*u.width,.5*u.height);a=i.crossPoint(p),c=new D(0,0,u.width,u.height),h=i.inverseMatrix().crossPoint(e.globalPoint)}else{const d=t.auxiliaryManager.selectManager.getSelectBounds();c=D.rectNode2Rect(d),a=new m(.5*(d.minX+d.maxX),.5*(d.minY+d.maxY)),h=new m(e.globalPoint.x-c.x,e.globalPoint.y-c.y)}return T.circleContains({x:0,y:0},h,o)?(this.result={rotateCenter:a,nodes:n},!0):T.circleContains({x:c.width,y:0},h,o)?(this.result={rotateCenter:a,nodes:n},!0):T.circleContains({x:c.width,y:c.height},h,o)?(this.result={rotateCenter:a,nodes:n},!0):T.circleContains({x:0,y:c.height},h,o)?(this.result={rotateCenter:a,nodes:n},!0):!1}};g(Rr,"HOT_DISTANCE",16);let dr=Rr;class fu extends ne{onDetect(e,t){const n=t.detect(W.Node,e);if(!n)return!1;const s=t.getSelectNodes();for(const r of n)if(!s.has(r)&&r.type===A.Section)return this.result=r,!0;return!1}}class gu extends We{constructor(){super(),this.registerDownHandler(new ro),this.registerDownHandler(new oo),this.registerUpHandler(new io),this.registerUpHandler(new Ea),this.registerUpHandler(new ao)}}class yu extends ln{constructor(){super([new gu])}}class mu extends We{constructor(){super(),this.registerDownHandler(new _a)}}class wu extends Qr{constructor(){super([new mu])}}class xu extends Zs{constructor(){super(...arguments);g(this,"handlers",[new lo])}}class Pu extends Ve{constructor(){super([new co,new xu])}canBeEnable(e,t){return!0}canBeExit(e,t){return!0}}class bu extends Kn{constructor(){super([new so,new wu,new yu,new Pu])}canBeEnable(e,t){return!t.docState.canEdit()}}class vu extends ne{onDetect(e,t){const n=[...t.getSelectNodes()];if(n.length!==1)return!1;const s=n[0];if(s.type!==A.IMG)return!1;const r=t.detect(W.Node,e);return r&&t.auxiliaryManager.selectManager.include(r[0])?(this.result=s,!0):!1}}class Mu extends qs{constructor(){super([new Ka])}streamEnable(e,t){return!0}}class Su{constructor(){g(this,"allowEventTypeSet",new Set([yt.pointermove]))}process(e,t){t.setCursor("grab")}}class Tu extends Ve{constructor(){super([new Su])}canBeEnable(e,t){return!0}canBeExit(e,t){return!0}}class Cu extends Kn{constructor(){super([new Mu,new Tu])}canBeEnable(e,t){return t.toolManager.currentTool===ft.HandTool}}class Lu extends ke{enable(e,t){return!!t.detect(W.ImageOriginBounds,e)}handle(e,t){const n=t.detect(W.ImageOriginBounds,e);n.type===G.BOTTOM||n.type===G.TOP?t.setCursor("ns-resize"):n.type===G.RIGHT||n.type===G.LEFT?t.setCursor("ew-resize"):n.type===G.TOP_LEFT||n.type===G.BOTTOM_RIGHT?t.setCursor("nwse-resize"):(n.type===G.TOP_RIGHT||n.type===G.BOTTOM_LEFT)&&t.setCursor("nesw-resize")}}class Au extends Zs{constructor(){super(...arguments);g(this,"handlers",[new Da,new Lu,new lo])}}class Ru extends Ve{constructor(){super([new Au])}canBeEnable(e,t){return!0}canBeExit(e,t){return!0}}class Nu extends ge{constructor(){super(...arguments);g(this,"limitBounds");g(this,"imgNode");g(this,"lastPoint");g(this,"stretchRect");g(this,"transform");g(this,"stretchType")}onStart(t,n){const s=n.detect(W.Stretch,t);this.stretchType=s.type;const r=[...n.getSelectNodes()][0];this.imgNode=r;const o=r.getOriginImageRect().clone(),i=r.toGlobal({x:o.x,y:o.y}),a=this.imgNode.globalBaseProps;this.limitBounds=new D(i.x,i.y,o.width,o.height);const c=Z.generateMatrix().rotate(a.angle),d=Z.generateMatrix().translate(i.x,i.y).crossProduct(c);this.transform=d.inverseMatrix(),this.lastPoint=this.transform.crossPoint(t.globalPoint);const u=new m(a.x,a.y),p=this.transform.crossPoint(u);this.stretchRect=new D(p.x,p.y,a.width,a.height),n.execAction(new nt)}onCropNode(t,n,s){const r=this.transform.crossPoint(t.globalPoint),o=new m(r.x-this.lastPoint.x,r.y-this.lastPoint.y);this.lastPoint=r;const i=this.stretchRect;switch(this.stretchType){case G.TOP:i.y=i.y+o.y,i.height=i.height-o.y;break;case G.BOTTOM:i.height=i.height+o.y;break;case G.LEFT:i.x=i.x+o.x,i.width=i.width-o.x;break;case G.RIGHT:i.width=i.width+o.x;break;case G.TOP_LEFT:i.y=i.y+o.y,i.height=i.height-o.y,i.x=i.x+o.x,i.width=i.width-o.x;break;case G.TOP_RIGHT:i.y=i.y+o.y,i.height=i.height-o.y,i.width=i.width+o.x;break;case G.BOTTOM_LEFT:i.x=i.x+o.x,i.width=i.width-o.x,i.height=i.height+o.y;break;case G.BOTTOM_RIGHT:i.width=i.width+o.x,i.height=i.height+o.y;break}const a=this.modifyStretchRect(i),c=new m(a.x,a.y),h=this.transform.inverseMatrix().crossPoint(c),d=this.imgNode.parent.toLocal(h),u=[{type:R.Base,x:d.x,y:d.y,width:a.width,height:a.height}];n.execAction(ct.create(this.imgNode.id,u,{streaming:s}));const p=this.imgNode.toLocal(new m(this.limitBounds.x,this.limitBounds.y));n.execAction(ct.create(this.imgNode.id,[{type:R.Crop,cropInfo:{imgX:p.x,imgY:p.y,imgWidth:this.limitBounds.width,imgHeight:this.limitBounds.height}}],{streaming:s}))}onMove(t,n){this.onCropNode(t,n,!0)}modifyStretchRect(t){const n=new D(t.x,t.y,t.width,t.height);return n.width<10&&(n.width=10),n.height<10&&(n.height=10),t.x<0?(n.x=0,n.width=t.x+t.width):t.x+t.width>this.limitBounds.width&&(n.width=this.limitBounds.width-t.x),t.y<0?(n.y=0,n.height=t.y+t.height):t.y+t.height>this.limitBounds.height&&(n.height=this.limitBounds.height-t.y),n}onUp(t,n){this.onCropNode(t,n,!1),n.execAction(new et)}}class Eu extends ae{constructor(){super([new Nu])}streamEnable(e,t){return!!t.detect(W.Stretch,e)}}class Iu extends Ps{enable(e){return e.type===A.IMG}handle(e,t,n,s,r){const o=t.crop,i=t.crop.globalImgPos,a=o.originCropProps,c=a.cropType,h=o.originTransform,d=r.crossPoint(i),u=h.crossPoint(d);return[{id:e.id,props:[{type:R.Crop,cropInfo:{imgX:u.x,imgY:u.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*s},cropType:c}]}]}}class ku extends Qs{constructor(){super(...arguments);g(this,"handlers",[new Iu])}computeAnchorPoint(t,n){const s=this.target.nodes[0],{x:r,y:o,width:i,height:a}=s.getOriginImageRect();switch(t.type){case G.TOP:return this.alignType=It.height,{x:r,y:o+a};case G.RIGHT:return this.alignType=It.width,{x:r,y:o};case G.BOTTOM:return this.alignType=It.height,{x:r,y:o};case G.LEFT:return this.alignType=It.width,{x:r+i,y:o};case G.TOP_LEFT:return this.alignType=It.both,{x:r+i,y:o+a};case G.TOP_RIGHT:return this.alignType=It.both,{x:r,y:o+a};case G.BOTTOM_RIGHT:return this.alignType=It.both,{x:r,y:o};case G.BOTTOM_LEFT:default:return this.alignType=It.both,{x:r+i,y:o}}}judgeUniform(t){this.isUniform=!0}computeTarget(t,n){const s=n.detect(W.ImageOriginBounds,t);this.target={type:s.type,nodes:[...n.getSelectNodes()]}}alignStretchGlobalPoint(t,n){const s=[...n.getSelectNodes()][0],r=s.toLocal(t.globalPoint),o=s.baseProps,i=t.globalPoint.clone(),a=this.target.type;return r.x>0&&(a===G.LEFT||a===G.BOTTOM_LEFT||a===G.TOP_LEFT)&&(i.x=s.toGlobal({x:0,y:0}).x),r.x<o.width&&(a===G.RIGHT||a===G.BOTTOM_RIGHT||a===G.TOP_RIGHT)&&(i.x=s.toGlobal({x:o.width,y:0}).x),r.y>0&&(a===G.TOP||a===G.TOP_RIGHT||a===G.TOP_LEFT)&&(i.y=s.toGlobal({x:0,y:0}).y),r.y<o.height&&(a===G.BOTTOM||a===G.BOTTOM_RIGHT||a===G.BOTTOM_LEFT)&&(i.y=s.toGlobal({x:0,y:o.height}).y),i}computeOriginTransform(t){const n=this.target,s=[...t.getSelectNodes()][0],{x:r,y:o,angle:i}=s.globalBaseProps,a=Z.generateMatrix().rotate(-i),c=Z.generateMatrix().translate(-r,-o),h=this.computeAnchorPoint(n,D.baseProps2Rect(s.baseProps)),u=Z.generateMatrix().translate(-h.x,-h.y).crossProduct(a.crossProduct(c));this.originTransform=u}drawAlignLine(t,n,s){const r=this.target.nodes[0],o=r.baseProps,{width:i,height:a}=n,c=r.globalTransform().clone();if(i){t.width+=i.dt;const h={transform:c,line:{start:new m(0,o.height),end:new m(o.width,o.height)}};i.lines.push(h)}if(a){t.height+=a.dt;const h={transform:c,line:{start:new m(o.width,0),end:new m(o.width,o.height)}};a.lines.push(h)}s.addOrUpdate(N.AlignStretchLine,{alignInfo:n})}getMiniSize(t){const n=this.target.type,s=this.target.nodes[0],r=s.baseProps,{x:o,y:i,width:a,height:c}=s.getOriginImageRect(),h=a/c;switch(n){case G.BOTTOM:case G.RIGHT:case G.BOTTOM_RIGHT:{const d=r.width-o,u=r.height-i,p=u*h;return d>p?new m(d,d/h):new m(p,u)}case G.LEFT:case G.BOTTOM_LEFT:{const d=a+o,u=r.height-i,p=u*h;return d>p?new m(d,d/h):new m(p,u)}case G.TOP_LEFT:{const d=a+o,u=c+i,p=u*h;return d>p?new m(d,d/h):new m(p,u)}case G.TOP:case G.TOP_RIGHT:{const d=r.width-o,u=c+i,p=u*h;return d>p?new m(d,d/h):new m(p,u)}default:return new m(r.width,r.height)}}getStretchRect(t){const n=[...t.getSelectNodes()][0],s=D.baseProps2Rect(n.baseProps),r=n.getOriginImageRect();return s.width=r.width,s.height=r.height,s.x=s.x-r.x,s.y=s.y-r.y,s}recordPropsMap(t){this.propsMap.clear();const n=this.target.nodes;for(const s of n){const r=this.recordNodePropInfo(s);this.propsMap.set(s,r)}}afterStretchNode(t,n,s,r,o,i,a){t.asyncRenderNodeManager.batchAddRenderNode(a)}}class Bu extends ae{constructor(){super([new ku])}streamEnable(e,t){return!!t.detect(W.ImageOriginBounds,e)}}class Ou extends ge{constructor(){super(...arguments);g(this,"lastPoint");g(this,"originImgRect");g(this,"imgNode");g(this,"limitBounds");g(this,"transform");g(this,"dragRect")}onStart(t,n){this.imgNode=[...n.getSelectNodes()][0],this.originImgRect=this.imgNode.getOriginImageRect().clone();const s=this.imgNode.globalBaseProps,r=this.imgNode.toGlobal({x:this.originImgRect.x,y:this.originImgRect.y});this.limitBounds=new D(r.x,r.y,this.originImgRect.width,this.originImgRect.height);const o=Z.generateMatrix().rotate(s.angle),a=Z.generateMatrix().translate(r.x,r.y).crossProduct(o);this.transform=a.inverseMatrix();const c=this.transform.crossPoint({x:s.x,y:s.y});this.dragRect=new D(c.x,c.y,s.width,s.height),this.lastPoint=this.transform.crossPoint(t.globalPoint),n.execAction(new nt)}onMove(t,n){this.dragCrop(t,n,!0)}onUp(t,n){this.dragCrop(t,n,!1),n.execAction(new et)}dragCrop(t,n,s){const r=this.imgNode.cropProps.cropInfo,o=this.modifyCropBasePos(t,n),i=this.imgNode.parent.toLocal(o),a=[{type:R.Base,x:i.x,y:i.y}];n.execAction(new ct({infos:[{id:this.imgNode.id,props:a}]},{streaming:s}));const c=this.imgNode.toLocal(this.limitBounds),h={imgX:c.x,imgY:c.y,imgWidth:r.imgWidth,imgHeight:r.imgHeight},d=[{type:R.Crop,cropInfo:h}];n.execAction(new ct({infos:[{id:this.imgNode.id,props:d}]},{streaming:s}))}modifyCropBasePos(t,n){const s=t.globalPoint,r=this.transform.crossPoint(s),o=r.x-this.lastPoint.x,i=r.y-this.lastPoint.y,a=this.dragRect;a.x+=o,a.y+=i;const c=this.imgNode.baseProps,h=new m(a.x,a.y);a.x+a.width>this.limitBounds.width?h.x=this.limitBounds.width-c.width:a.x<0&&(h.x=0),a.y<0?h.y=0:a.y+a.height>this.limitBounds.height&&(h.y=this.limitBounds.height-c.height);const d=this.transform.inverseMatrix().crossPoint(h);return this.lastPoint=r,d}}class Du extends ae{constructor(){super([new Ou])}streamEnable(e,t){const n=[...t.getSelectNodes()];return n.length!==1||!t.cropManager.duringCrop?!1:!!n[0].contains(e.globalPoint)}}class vs{intoCrop(e){const t=e.getSelectNodes();if(t.size!==1)return;const n=[...t][0];if(!(n instanceof _n)||e.cropManager.duringCrop)return;e.cropManager.intoCrop(),e.auxiliaryManager.selectManager.refreshSelectStatus(),e.renderManager.addAuxiliaryDrawTask();const r=n.cropProps;if(!r.cropInfo||r.cropType===de.None){const{width:o,height:i}=n.baseProps;e.execAction(new nt),e.execAction(ct.create(n.id,[{cropType:de.Rect,cropInfo:{imgX:0,imgY:0,imgWidth:o,imgHeight:i},type:R.Crop}])),e.execAction(new et)}}exitCrop(e){if(e.cropManager.duringCrop){e.cropManager.exitCrop(),e.auxiliaryManager.selectManager.refreshSelectStatus(),e.renderManager.addAuxiliaryDrawTask();return}}resetCrop(e){const t=e.getSelectNodes();if(t.size!==1)return;const n=[...t][0];if(!(n instanceof _n)||!e.cropManager.duringCrop)return;const r=n.cropProps;if(!r.cropInfo||r.cropType===de.None)return;const o=n.getOriginImageRect(),i=new m(o.x,o.y),a=n.toGlobal(i),c=n.parent.toLocal(a);e.execAction(new nt),e.execAction(ct.create(n.id,[{cropType:de.None,type:R.Crop},{type:R.Base,x:c.x,y:c.y,width:o.width,height:o.height}])),e.execAction(new et),e.cropManager.exitCrop(),e.auxiliaryManager.selectManager.refreshSelectStatus()}}class Hu extends ee{constructor(){super(...arguments);g(this,"worker",new vs)}enable(t,n){const s=[...n.getSelectNodes()];if(s.length!==1)return!1;const r=s[0],o=r.toLocal(t.globalPoint),i=r.getOriginImageRect();return n.detect(W.ImageOriginBounds,t)?!1:!T.rectContains(o,i)}handle(t,n){this.worker.exitCrop(n),n.auxiliaryManager.slotManager.addSlotState(te.ExitCrop,!0)}}class zu extends We{constructor(){super(),this.registerDownHandler(new Hu)}}class Xu extends ln{constructor(){super([new zu])}}class Yu extends Kn{constructor(){super([new Eu,new Bu,new Du,new Xu,new Ru])}canBeEnable(e,t){return t.cropManager.duringCrop}}class Fu extends ne{onDetect(e,t){const n=t.getSelectNodes();if(n.size!==1)return!1;const s=[...n][0];if(s.type!==A.IMG||!t.cropManager.duringCrop)return!1;const r=s,{cropType:o,cropInfo:i}=r.cropProps;if(o===de.None||!i)return!1;const a=8/t.renderManager.getScale(),c=r.getOriginImageRect(),h=s.toLocal(e.globalPoint),d=T.detectRectBounds(c,h,a);return d?(this.result={type:d.type},!0):!1}}class go extends ha{constructor(){super(...arguments);g(this,"detectors",new Map([[W.Node,new da],[W.HoverNode,new ua],[W.PolyControlPoint,new sc],[W.Rotate,new dr],[W.Stretch,new $s],[W.ExpandShape,new qa],[W.LineEndPoint,new $a],[W.NodeEdge,new Yd],[W.BufferNode,new cu],[W.BufferHoverNode,new lu],[W.HoverNodeAnchor,new du],[W.HoverConnectAnchor,new pu],[W.HoverOnContainer,new fu],[W.Image,new vu],[W.ImageOriginBounds,new Fu]]));g(this,"modes",[new Cu,new bu,new Yu,new au,new ja])}}const Vu={[_.Ellipse]:"#F2F3F5",[_.LiuBianXing]:"#F2F3F5",[_.Yunduo]:"#F2F3F5",[_.YuanZhu]:"#F0FBEF",[_.PingXingsiBianXing]:"#F0FBEF",[_.Tixing]:"#E1EAFF",[_.Triangle]:"#E1EAFF",[_.Triangle2]:"#E1EAFF",[_.RightArrow]:"#E1EAFF",[_.DoubleArrow]:"#E1EAFF",[_.LeftArrow]:"#E1EAFF",[_.RoundRect]:"#E0E2FA",[_.RoundRect2]:"#E0E2FA",[_.Rect]:"#E0E2FA",[_.LiuCheng]:"#E0E2FA",[_.LiuCheng2]:"#E0E2FA",[_.Lingxing]:"#FEEAD2",[_.WuJiaoxing]:"#FEEAD2",[_.Qipao]:"#FEF1F1",[_.Qipao2]:"#FEF1F1",[_.Shizi]:"#FEF1F1",[_.RightKuohao]:"#FEF1F1",[_.LeftKuohao]:"#FEF1F1"},Wu={[_.Ellipse]:"#DEE0E3",[_.LiuBianXing]:"#DEE0E3",[_.Yunduo]:"#DEE0E3",[_.YuanZhu]:"#8EE085",[_.PingXingsiBianXing]:"#8EE085",[_.Tixing]:"#82A7FC",[_.Triangle]:"#82A7FC",[_.Triangle2]:"#82A7FC",[_.RightArrow]:"#82A7FC",[_.DoubleArrow]:"#82A7FC",[_.LeftArrow]:"#82A7FC",[_.RoundRect]:"#7B83EA",[_.RoundRect2]:"#7B83EA",[_.Rect]:"#7B83EA",[_.LiuCheng]:"#7B83EA",[_.LiuCheng2]:"#7B83EA",[_.Lingxing]:"#FFBA6B",[_.WuJiaoxing]:"#FFBA6B",[_.Qipao]:"#F98E8B",[_.Qipao2]:"#F98E8B",[_.Shizi]:"#F98E8B",[_.RightKuohao]:"#F98E8B",[_.LeftKuohao]:"#F98E8B"},Gu=(l,{x:e,y:t,width:n,height:s})=>l.x>=e&&l.x<=e+n&&l.y>=t&&l.y<=t+s;class En extends Kr{enable(e){return e.isPolyLine()}layoutToPoints(e,t){const n=e.lineProps,{start:s,end:r}=e.connectProps,o=[...e.globalLinePoints];if(!n.auto&&o.length>2){if(s){const c=o[0],h=o[1],d=T.judgeHorizon(c,h),u=t.nodeManager.getNode(s.objectId);if(u){const p=this.getNodePos(u,s);c.x=p.x,c.y=p.y}d?h.y=c.y:h.x=c.x}if(r){const c=o[o.length-2],h=o[o.length-1],d=T.judgeHorizon(c,h),u=t.nodeManager.getNode(r.objectId);if(u){const p=this.getNodePos(u,r);h.x=p.x,h.y=p.y}d?c.y=h.y:c.x=h.x}const i=e.globalTransform().inverseMatrix();return o.map(c=>i.crossPoint(c))}else{const i=this.getLayoutHandler(e,s,t),a=this.computeLayout(i,e,r,t),c=e.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}}layoutToPointsPro(e,t){const n=this.getLayoutHandlerV2(e);return this.computePointsV2(n,t)}getLayoutHandlerV2({point:e,nodeConnect:t}){if(!t)return new Ji(e);const{rect:n,endType:s}=t;switch(s){case Mt.Top:return new Eh(e,n);case Mt.Bottom:return new Ih(e,n);case Mt.Left:return new kh(e,n);case Mt.Right:return new Bh(e,n);default:return new Ji(e)}}computePointsV2(e,{point:t,nodeConnect:n}){if(!n)return e.toPoint(t);const{rect:s,endType:r}=n;switch(r){case Mt.Right:return e.right(t,s);case Mt.Left:return e.left(t,s);case Mt.Bottom:return e.bottom(t,s);case Mt.Top:return e.top(t,s);default:return e.toPoint(t)}}getLayoutHandler(e,t,n){const s={point:e.globalLinePoints[0]};if(t){const r=n.nodeManager.getNode(t.objectId);r&&(s.nodeConnect={rect:D.rectNode2Rect(r.getBounds()),endType:T.computeNodeConnectEnd(t,r.baseProps.angle)},s.point=this.getNodePos(r,t))}return this.getLayoutHandlerV2(s)}computeLayout(e,t,n,s){const r=$t.computeConnectInfo(t,n,s,!0);return this.computePointsV2(e,r)}}class Ms{constructor(){g(this,"handlers",[new Qi,new Zi,new En])}work(e,t,n){for(const s of e)this.handleAndMsg(s,t,n)}layoutToPoints(e,t){for(const n of this.handlers)if(n.enable(e))return n.layoutToPoints(e,t);return[]}handleAndMsg(e,t,n){for(const s of this.handlers)if(s.enable(e)){const r=s.handle(e,t);t.execAction(new ct(r,{streaming:n}));return}}collectNodeLinks(e,t,n){t.nodeManager.getNodeLinks(e).forEach(r=>n.add(r));for(const r of e.children){if(r.type===A.Line){const o=r,{start:i,end:a}=o.connectProps;(i||a)&&n.add(o)}this.collectNodeLinks(r,t,n)}}}class qn{constructor(){g(this,"prevStringBuilder",{text:""});g(this,"nextStringBuilder",{text:""});g(this,"currentbuilder",this.prevStringBuilder);g(this,"layoutWorker",new Ms)}switchCurrentBuilder(e,t){return this.currentbuilder===this.nextStringBuilder?!1:e.equal(t)?(this.currentbuilder=this.nextStringBuilder,!0):!1}splitText(e,t){this.prevStringBuilder={text:""},this.nextStringBuilder={text:""},this.currentbuilder=this.prevStringBuilder;let n=-1,s=0;for(let r=0;r<e.paragraphs.length;r++){const o=e.paragraphs[r];for(let i=0;i<o.lines.length;i++){const a=o.lines[i];this.switchCurrentBuilder(t,new Ht(r,i,-1))&&(s=n);for(let h=0;h<a.characters.length;h++){const d=a.characters[h];this.currentbuilder.text+=d.charText,n++,this.switchCurrentBuilder(t,new Ht(r,i,h))&&(s=n)}}r<e.paragraphs.length-1&&(this.currentbuilder.text+=`
5
- `,n++)}return{prev:this.prevStringBuilder.text,next:this.nextStringBuilder.text,index:s}}getTextCursorPosByIndex(e,t){let n=-1;for(let s=0;s<e.paragraphs.length;s++){const r=e.paragraphs[s];for(let o=0;o<r.lines.length;o++){const i=r.lines[o];if(n===t)return new Ht(s,o,-1);for(let a=0;a<i.characters.length;a++)if(n++,n===t)return new Ht(s,o,a)}s<e.paragraphs.length-1&&n++}return e.tailTextCursorPosition()}modifyBaseProps(e,t,n){let s=!1;if(e.textProps.sizeMode===le.autoWidth){const r=t.getTextContentRect(),{width:o,height:i}=t.baseProps,a=o-r.width,c=e.height+(i-r.height)+.2;n.execAction(ct.create(t.id,[{type:R.Base,width:e.width+a,height:c}])),s=!0}else if(e.textProps.sizeMode===le.autoHeight){const{height:r}=t.baseProps,o=t.drawer.fullTextNodeHeight(t);if(r>o)return;n.execAction(ct.create(t.id,[{type:R.Base,height:o}])),s=!0}if(s){const r=new Set;this.layoutWorker.collectNodeLinks(t,n,r),this.layoutWorker.work([...r],n,!1)}}}class ur{constructor(){g(this,"editTextWorker",new qn)}work(e,t,n){n.execAction(lt.selection(e.node.id,t.start,t.end));const{node:s,renderText:r}=e,o=this.editTextWorker.splitText(r,t.start),i=this.editTextWorker.splitText(r,t.end),a={type:R.Text,text:o.prev+i.next};n.execAction(ct.create(s.id,[a]));const c=this.editTextWorker.getTextCursorPosByIndex(r,o.index);n.execAction(lt.focus(s.id,c))}}class pr{}class yo extends pr{enable(e,t){return e.paragraphIndex===t.paragraphIndex&&e.lineIndex===t.lineIndex}handle(e,t,n){const s=e.paragraphs[t.paragraphIndex],r=s.lines[t.lineIndex],o=r.getCharacter(n.charIndex);let i=0,a=0;if(t.charIndex>-1){const h=r.getCharacter(t.charIndex);i=h.x+h.width,a=h.y}const c=new D(i,a,o.x+o.width-i,r.height);return c.x+=r.x+s.x+e.x,c.y+=r.y+s.y+e.y,[c]}}class mo extends pr{enable(e,t){return e.paragraphIndex===t.paragraphIndex&&e.lineIndex!==t.lineIndex}handle(e,t,n){const s=[],r=e.paragraphs[t.paragraphIndex],o=r.lines[t.lineIndex],i=r.lines[n.lineIndex];let a=0,c=0;const h=o.getCharacter(t.charIndex);a=h===null?0:h.x+h.width,c=h===null?0:h.y;const d=o.width-a;if(a+=o.x+r.x+e.x,c+=o.y+r.y+e.y,s.push(new D(a,c,d,o.height)),t.lineIndex+1===n.lineIndex&&n.charIndex===-1)return s;for(let p=t.lineIndex+1;p<n.lineIndex;p++){const f=r.lines[p];a=f.x+r.x+e.x,c=f.y+r.y+e.y,s.push(new D(a,c,f.width,f.height))}const u=i.getCharacter(n.charIndex);return u&&(a=i.x+r.x+e.x,c=i.y+r.y+e.y,s.push(new D(a,c,u.x+u.width,i.height))),s}}class rc extends pr{constructor(){super(...arguments);g(this,"handlers",[new yo,new mo])}enable(t,n){return t.paragraphIndex!==n.paragraphIndex}handleSamePara(t,n,s){for(const r of this.handlers)if(r.enable(n,s))return r.handle(t,n,s);return[]}handle(t,n,s){const r=[],o=t.paragraphs[n.paragraphIndex],i=t.paragraphs[s.paragraphIndex],a=this.handleSamePara(t,n,o.tailCursorPosition());r.push(...a);for(let h=n.paragraphIndex+1;h<s.paragraphIndex;h++){const d=t.paragraphs[h];for(const u of d.lines)r.push(new D(t.x+d.x+u.x,t.y+d.y+u.y,u.width,u.height))}const c=this.handleSamePara(t,i.headCursorPosition(),s);return r.push(...c),r}}class oc{constructor(){g(this,"handlers",[new yo,new mo,new rc])}handleTextSelection(e,t,n){for(const s of this.handlers)if(s.enable(t,n))return s.handle(e,t,n);return[]}computeTextSelection(e,t,n){return t.equal(n)?[]:this.handleTextSelection(e,t,n)}}class wo{constructor(){g(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"grapheme"}))}split(e){return Array.from(this.segmentWorker.segment(e)).map(n=>n.segment)}}const Nt=16,Et=16,ic=[{x:0,y:0},{x:Nt,y:0},{x:Nt,y:Et},{x:0,y:Et}];class Ss{}class Uu extends Ss{drawOnGLCtx(e,t){const n=t.borderProps;e.strokeStyle=n.color,e.lineWidth=n.width,e.globalAlpha=n.alpha,e.moveTo(0,.5*Et),e.lineTo(Nt,.5*Et),e.moveTo(.5*Nt,0),e.lineTo(Nt,.5*Et),e.lineTo(.5*Nt,Et),e.stroke()}}class _u extends Ss{drawOnGLCtx(e,t){const n=t.borderProps;e.fillStyle=n.color,e.strokeStyle=n.color,e.lineWidth=n.width,e.globalAlpha=n.alpha,e.moveTo(0,.5*Et),e.lineTo(.5*Nt,.5*Et),e.stroke(),e.beginPath(),e.moveTo(.5*Nt,0),e.lineTo(Nt,.5*Et),e.lineTo(.5*Nt,Et),e.closePath(),e.fill(),e.stroke()}}class Ku extends Ss{drawOnGLCtx(e,t){const n=t.borderProps;e.strokeStyle=n.color,e.lineWidth=2,e.globalAlpha=n.alpha,e.moveTo(0,.5*Et),e.lineTo(.5*Nt,.5*Et),e.stroke(),e.beginPath(),e.moveTo(.5*Nt,0),e.lineTo(Nt,.5*Et),e.lineTo(.5*Nt,Et),e.closePath(),e.stroke()}}class ju extends Ss{drawOnGLCtx(e,t){const n=t.borderProps;e.fillStyle=n.color,e.lineWidth=n.width,e.globalAlpha=n.alpha,e.moveTo(0,.5*Et),e.lineTo(.5*Nt,.3*Et),e.lineTo(Nt,.5*Et),e.lineTo(.5*Nt,.7*Et),e.closePath(),e.fill()}}class qu extends Ss{drawOnGLCtx(e,t){const n=t.borderProps;e.strokeStyle=n.color,e.lineWidth=2,e.globalAlpha=n.alpha,e.moveTo(0,.5*Et),e.lineTo(.5*Nt,.3*Et),e.lineTo(Nt,.5*Et),e.lineTo(.5*Nt,.7*Et),e.closePath(),e.stroke()}}const yn=class yn extends Sn{constructor(t,n){super(t,n);g(this,"type",A.Line);g(this,"renderText");g(this,"inEditing",!1);g(this,"rArrowMatrix",Z.generateMatrix());g(this,"lArrowMatrix",Z.generateMatrix());this.props.set(R.Base,new gt),this.props.set(R.Border,new Ot),this.props.set(R.Shape,new jt),this.props.set(R.Line,new he),this.props.set(R.Arrow,new Ie),this.props.set(R.Connect,new Pn),this.props.set(R.Text,se.create({sizeMode:le.autoWidth})),this.props.set(R.LineTextRect,new bn),this.renderText=new Wr}get borderProps(){return this.props.get(R.Border)}get textProps(){return this.props.get(R.Text)}get arrowProps(){return this.props.get(R.Arrow)}get shapeType(){return this.props.get(R.Shape).shapeCode}get lineProps(){return this.props.get(R.Line)}get globalLinePoints(){const t=this.lineProps.points,n=this.globalTransform();return t.map(r=>n.crossPoint(r))}get connectProps(){return this.props.get(R.Connect)}get points(){return this.lineProps.points}get lineTextRect(){return this.props.get(R.LineTextRect)}get drawer(){const t=this.shapeType;let n=yn.drawerMap.get(t);return n||(console.error("取不到drawer,使用line兜底!"),n=yn.drawerMap.get(Lt.Line)),n}canBeConnected(){return!1}getStretchMinSize(){return new m(10,10)}drawWithTextClip(t){const s=this.getTextContentRect();s.x-=2,s.y-=2,s.width+=2*2,s.height+=2*2;const r=D.rectNode2Rect(this.getRectNode());let o=new m(r.x,r.y);o=this.toLocal(o),t.save(),t.beginPath(),t.rect(o.x,o.y,r.width,r.height),t.rect(s.x,s.y,s.width,s.height),t.clip("evenodd"),this.drawCore(t),t.restore()}drawCore(t){const n=this.borderProps;T.setDashLine(n,t),t.save(),t.strokeStyle=n.color,t.globalAlpha=n.alpha,t.lineWidth=n.width,this.drawer.draw(this,t),t.restore(),t.beginPath(),this.drawArrow(t)}drawOnGLCtx(t){const n=this.textProps.text!==""||this.inEditing;t.save();const{a:s,b:r,c:o,d:i,e:a,f:c}=this.globalTransform();t.transform(s,r,o,i,a,c),n?this.drawWithTextClip(t):this.drawCore(t),this.drawText(t),t.restore()}drawText(t){t.save(),t.beginPath();const n=new m;this.renderText.draw(t,n),t.restore()}updateProps(t){super.updateProps(t),this.updateLArrowMatrix(),this.updateRArrowMatrix();const n=t.find(i=>i.type===R.Text),s=t.find(i=>i.type===R.Base),r=t.find(i=>i.type===R.Line),o=t.find(i=>i.type===R.LineTextRect);if(n||s||r||o){const i=this.getTextContentRect();this.renderText.typesetting(this.graphicContext,this.textProps,i)}}getArrowDrawer(t){const n=yn.arrowDrawerMap.get(t);return n||null}draw(){this.drawOnGLCtx(this.graphicContext)}getBounds(){const t=[...this.points],n=this.globalTransform(),s=t.map(o=>n.crossPoint(o));return T.getBoundsByPoints(s)}getRectNode(){const t=[...this.points],{lArrow:n,rArrow:s}=this.arrowProps;if(n)for(const c of ic)t.push(this.lArrowMatrix.crossPoint(c));if(s)for(const c of ic)t.push(this.rArrowMatrix.crossPoint(c));const r=this.globalTransform(),o=t.map(c=>r.crossPoint(c)),i=T.getBoundsByPoints(o),a=this.borderProps;return i.minX=i.minX-a.width,i.minY=i.minY-a.width,i.maxX=i.maxX+2*a.width,i.maxY=i.maxY+2*a.width,i.id=this.id,i}updateRArrowMatrix(){const{rArrow:t}=this.arrowProps;if(!t)return;const n=this.points,s=n[n.length-1],r=new m(Nt,.5*Et);let o=0;if(this.isPolyLine()){const u=n[n.length-2],p=s;T.judgeHorizon(u,p)?o=p.x>u.x?0:180:o=p.y>u.y?90:-90}else{const u=n[n.length-2];o=T.lineAngle(u,s)/Math.PI*180}const i=Z.generateMatrix().translate(-.5*Nt,-.5*Nt),a=Z.generateMatrix().rotate(o),c=i.crossProduct(a),h=c.crossPoint(r),d=Z.generateMatrix().translate(s.x-h.x,s.y-h.y);this.rArrowMatrix=d.crossProduct(c)}updateLArrowMatrix(){const{lArrow:t}=this.arrowProps;if(!t)return;const n=this.points,s=n[0],r=new m(Nt,.5*Et);let o=0;if(this.isPolyLine()){const u=s,p=n[1];T.judgeHorizon(u,p)?o=p.x>u.x?180:0:o=p.y>u.y?-90:90}else{const u=n[1];o=T.lineAngle(u,s)/Math.PI*180}const i=Z.generateMatrix().translate(-.5*Nt,-.5*Nt),a=Z.generateMatrix().rotate(o),c=i.crossProduct(a),h=c.crossPoint(r),d=Z.generateMatrix().translate(s.x-h.x,s.y-h.y);this.lArrowMatrix=d.crossProduct(c)}drawArrow(t){if(this.points.length===0){console.error("line has no point!");return}const s=this.arrowProps;if(s.rArrow){const r=this.getArrowDrawer(s.rArrow);if(r){t.save();const{a:o,b:i,c:a,d:c,e:h,f:d}=this.rArrowMatrix;t.transform(o,i,a,c,h,d),r.drawOnGLCtx(t,this),t.restore()}}if(s.lArrow){const r=this.getArrowDrawer(s.lArrow);if(r){t.save();const{a:o,b:i,c:a,d:c,e:h,f:d}=this.lArrowMatrix;t.transform(o,i,a,c,h,d),r.drawOnGLCtx(t,this),t.restore()}}}getRArrowPoint(t,n,s=5){const r=T.distance(t,n),o=new m(r-Math.sqrt(3)*.5*s,.5*s),i=new m(r-Math.sqrt(3)*.5*s,-.5*s);return this.basicGetArrowPoint(t,n,o,i)}basicGetArrowPoint(t,n,s,r){const o=T.lineAngle(t,n),i=Z.generateMatrix().translate(t.x,t.y).rotate2(o),a=i.crossPoint(s),c=i.crossPoint(r);return{a,b:c}}static load(t,n,s,r,o,i){const a=new yn(t,i);return a.type=n,a.zIndex=s,a.setParent(o),a.updateProps(r),a}contains(t,n){const s=this.toLocal(t),r=this.getTextContentRect();if(T.rectContains(s,r))return!0;const o=8/n;return Ai.lineContainsPoint(this,s,o)}overlapRect(t){const n=this.getBounds();return T.containRect(t,n)?!0:Ai.overlapRectNode(this,t)}getTextContentRect(){const{t}=this.lineTextRect,{height:n}=this.renderText,r=this.textProps.text===""?20:this.renderText.width,o=T.computePointByT(this,t),i=o.x-.5*r,a=o.y-.5*n;return new D(i,a,r,n)}isPolyLine(){const t=this.shapeType;return t===Lt.PolyLine||t===Lt.RoundPolyLine}modifyPosInEditing(){return this.inEditing=!0,!0}resetFromEditing(){this.inEditing=!1}getDrawPoints(){const{lArrow:t,rArrow:n}=this.arrowProps,s=[...this.points];if(t){const r=new m(0,.5*Et),o=this.lArrowMatrix.crossPoint(r);s.shift(),s.unshift(o)}if(n){const r=new m(0,.5*Et),o=this.rArrowMatrix.crossPoint(r);s.pop(),s.push(o)}return s}};g(yn,"arrowDrawerMap",new Map([[we.Arrow,new Uu],[we.Triangle,new _u],[we.EmptyTriangle,new Ku],[we.Diamond,new ju],[we.EmptyDiamond,new qu]])),g(yn,"drawerMap",new Map([[Lt.Curve,new yh],[Lt.RoundPolyLine,new mh],[Lt.PolyLine,new gh],[Lt.Line,new fh]]));let dn=yn;class In{fullTextNodeHeight(e){return e.renderText.height+2*Wt}textContentBounds(e){const t=e.baseProps;return{x:Wt,y:Wt,width:t.width-2*Wt,height:t.height-2*Wt}}borderContains(e,t,n){const{width:s,height:r}=e.baseProps,o=K.rectangle({top:0,left:0,width:s,height:r}),i=K.line({x:t.x-n,y:t.y},{x:t.x+n,y:t.y}),a=K.line({x:t.x,y:t.y-n},{x:t.x,y:t.y+n});for(const c of[i,a]){const h=O.intersect(o,c);if(h.points.length>0)return h.points[0]}return null}getConnectAnchor(){return[new m(.5,0),new m(1,.5),new m(.5,1),new m(0,.5)]}}class $u extends In{draw(e,t){}textContentBounds(e){const t=e.baseProps;return{x:2,y:2,width:t.width-4,height:t.height-4}}}class Qu extends In{draw(e,t){const n=e.colorProps,s=e.baseProps,r=e.borderProps;n.color!==""&&(t.fillStyle=n.color,t.globalAlpha=n.alpha,t.fillRect(0,0,s.width,s.height)),r.color!==""&&r.dashType!==Ee.None&&(T.setDashLine(r,t),t.strokeStyle=r.color,t.lineWidth=r.width,t.globalAlpha=r.alpha,t.strokeRect(0,0,s.width,s.height))}}class Zu extends In{textContentBounds(e){const t=e.baseProps,n=t.width/4,s=-t.height/(t.width/2),r=t.height,o=s*n+r,i={x:n,y:o,width:t.width/2,height:t.height-o};return{x:i.x+Wt,y:i.y+Wt,width:i.width-Wt*2,height:i.height-Wt*2}}fullTextNodeHeight(e){return(e.renderText.height+Wt)*2}draw(e,t){const n=e.colorProps,{width:s,height:r}=e.baseProps,o=e.borderProps;t.fillStyle=n.color,t.globalAlpha=n.alpha,t.strokeStyle=o.color,t.lineWidth=o.width,t.globalAlpha=o.alpha,t.lineJoin="round",t.lineCap="round",t.beginPath(),t.moveTo(0,r),t.lineTo(.5*s,0),t.lineTo(s,r),t.closePath(),n.color!==""&&t.fill(),o.color!==""&&Math.abs(o.alpha)>.001&&(T.setDashLine(o,t),t.stroke())}borderContains(e,t,n){const{width:s,height:r}=e.baseProps,o=K.polygon([{x:0,y:r},{x:.5*s,y:0},{x:s,y:r}]),i=K.line({x:t.x-n,y:t.y},{x:t.x+n,y:t.y}),a=K.line({x:t.x,y:t.y-n},{x:t.x,y:t.y+n});for(const c of[i,a]){const h=O.intersect(o,c);if(h.points.length>0)return h.points[0]}return null}getConnectAnchor(){return[new m(.5,0),new m(.75,.5),new m(.5,1),new m(.25,.5)]}}class Ju extends In{draw(e,t){const n=e.colorProps,{width:s,height:r}=e.baseProps,o=e.borderProps;t.fillStyle=n.color,t.globalAlpha=n.alpha,t.strokeStyle=o.color,t.lineWidth=o.width,t.globalAlpha=o.alpha,t.lineJoin="round",t.lineCap="round",t.beginPath(),t.moveTo(0,.5*r),t.lineTo(.5*s,0),t.lineTo(s,.5*r),t.lineTo(.5*s,r),t.closePath(),n.color!==""&&t.fill(),o.color!==""&&Math.abs(o.alpha)>.001&&t.stroke()}textContentBounds(e){const t=e.baseProps,n={x:0,y:t.height/2},s={x:t.width/2,y:0},r=(n.y-s.y)/(n.x-s.x),o=n.y,i=.25*t.width,a=r*i+o,c={x:i,y:a,with:t.width-i*2,height:t.height-a*2};return{x:c.x+Wt,y:c.y+Wt,width:c.with-Wt*2,height:c.height-Wt*2}}borderContains(e,t,n){const{width:s,height:r}=e.baseProps,o=K.polygon([{x:0,y:.5*r},{x:.5*s,y:0},{x:s,y:.5*r},{x:.5*s,y:r}]),i=K.line({x:t.x-n,y:t.y},{x:t.x+n,y:t.y}),a=K.line({x:t.x,y:t.y-n},{x:t.x,y:t.y+n});for(const c of[i,a]){const h=O.intersect(o,c);if(h.points.length>0)return h.points[0]}return null}}class tp extends In{draw(e,t){const n=e.baseProps,s=e.colorProps,r=e.borderProps;t.beginPath(),t.fillStyle=s.color,t.globalAlpha=s.alpha,t.strokeStyle=r.color,t.lineWidth=r.width,t.globalAlpha=r.alpha,t.roundRect(0,0,n.width,n.height,10),s.color!==""&&t.fill(),r.color!==""&&Math.abs(r.alpha)>.001&&t.stroke()}borderContains(e,t,n){const{width:s,height:r}=e.baseProps,o=K.rectangle({top:0,left:0,width:s,height:r}),i=K.line({x:t.x-n,y:t.y},{x:t.x+n,y:t.y}),a=K.line({x:t.x,y:t.y-n},{x:t.x,y:t.y+n});for(const c of[i,a]){const h=O.intersect(o,c);if(h.points.length>0)return h.points[0]}return null}}class ep extends In{draw(e,t){const n=e.colorProps,{width:s,height:r}=e.baseProps,o=e.borderProps;t.fillStyle=n.color,t.globalAlpha=n.alpha,t.strokeStyle=o.color,t.lineWidth=o.width,t.globalAlpha=o.alpha,t.lineJoin="round",t.lineCap="round",t.beginPath(),t.ellipse(.5*s,.5*r,.5*s,.5*r,0,0,2*Math.PI,!1),n.color!==""&&t.fill(),o.color!==""&&Math.abs(o.alpha)>.001&&(T.setDashLine(o,t),t.stroke())}textContentBounds(e){const t=e.baseProps,n=t.width*Math.sqrt(2)/2,s=(t.width-n)/2,r=Math.max(t.width,t.height)/2,o=Math.min(t.width,t.height)/2,i=(1-(n/2)**2/r**2)*o**2,a={x:s,y:t.height/2-Math.sqrt(i),width:n,height:2*Math.sqrt(i)};return{x:a.x+Wt,y:a.y+Wt,width:a.width-Wt*2,height:a.height-Wt*2}}fullTextNodeHeight(e){return(e.renderText.height+Wt)*2}borderContains(e,t,n){const{width:s,height:r}=e.baseProps,o=K.ellipse({centerX:.5*s,centerY:.5*r,radiusX:.5*s,radiusY:.5*r}),i=K.line({x:t.x-n,y:t.y},{x:t.x+n,y:t.y}),a=K.line({x:t.x,y:t.y-n},{x:t.x,y:t.y+n});for(const c of[i,a]){const h=O.intersect(o,c);if(h.points.length>0)return h.points[0]}return null}}const Ue=class Ue extends Sn{constructor(t,n){super(t,n);g(this,"type",A.Shape);g(this,"transform",Z.generateMatrix());g(this,"renderText");this.props.set(R.Base,new gt),this.props.set(R.Shape,new jt),this.props.set(R.Color,new Jt),this.props.set(R.Border,new Ot),this.props.set(R.Text,new se),this.renderText=new Wr}get borderProps(){return this.props.get(R.Border)}get colorProps(){return this.props.get(R.Color)}get textProps(){return this.props.get(R.Text)}get shapeType(){return this.props.get(R.Shape).shapeCode}get drawer(){const t=Ue.drawerMap.get(this.shapeType);return t||Ue.drawerMap.get(_.RoundRect)}borderContains(t,n){const s=this.toLocal(t);return this.drawer.borderContains(this,s,n)}updateProps(t){super.updateProps(t);const n=t.find(r=>r.type===R.Text),s=t.find(r=>r.type===R.Base);if(s&&this.updateTransformMatrix(),n||s){const r=this.drawer.textContentBounds(this);this.renderText.typesetting(this.graphicContext,this.textProps,r)}}modifyPosInEditing(t){if(this.shapeType===_.PureText)return!1;const n=this.drawer.textContentBounds(this);return this.renderText.modifyPosInEditing(n,t)}resetFromEditing(){const t=this.drawer.textContentBounds(this);return this.renderText.resetFromEditing(t)}contains(t){const{width:n,height:s}=this.baseProps,r=this.toLocal(t);return T.rectContains(r,new D(0,0,n,s))}drawOnGLCtx(t){const n=this.shapeType;let s=Ue.drawerMap.get(n);s||(console.error("取不到drawer,使用rect兜底!"),s=Ue.drawerMap.get(_.Rect)),t.save(),t.beginPath();const{a:r,b:o,c:i,d:a,e:c,f:h}=this.globalTransform();t.transform(r,o,i,a,c,h),s.draw(this,t),this.drawText(t),t.restore()}drawText(t){const{x:n,y:s,width:r,height:o}=this.getTextContentRect();t.save(),t.beginPath(),t.rect(n,s,r,o),t.clip();const i=new m;this.renderText.draw(t,i),t.restore()}getStretchMinSize(){return new m(20,20)}draw(){this.drawOnGLCtx(this.graphicContext)}getTextContentRect(){const t=this.shapeType;let n=Ue.drawerMap.get(t);return n||(console.error("取不到drawer,使用rect兜底!"),n=Ue.drawerMap.get(_.Rect)),n.textContentBounds(this)}getConnectAnchor(){return this.drawer.getConnectAnchor()}static load(t,n,s,r,o,i){const a=new Ue(t,i);return a.type=n,a.zIndex=s,a.setParent(o),a.updateProps(r),a}};g(Ue,"drawerMap",new Map([[_.PureText,new $u],[_.Ellipse,new ep],[_.Rect,new Qu],[_.RoundRect,new tp],[_.Triangle,new Zu],[_.Lingxing,new Ju]]));let qe=Ue;class Ts extends _n{constructor(t,n){super(t,n);g(this,"type",A.SVG);g(this,"imgBitmap",null);g(this,"svgCode","");this.props.set(R.Base,new gt),this.props.set(R.Border,new Ot),this.props.set(R.Svg,new fs),this.props.set(R.Crop,new Mn)}get svgUrl(){return this.props.get(R.Svg).url}setSvgCode(t){this.svgCode=t}static load(t,n,s,r,o,i){const a=new Ts(t,i);return a.type=n,a.zIndex=s,a.setParent(o),a.updateProps(r),a}}class $n{static getNumFromString(e){try{const t=e.match(/(\d+)/);return t&&t[1]?parseInt(t[1],10):100}catch{return console.error("从字符串中获取num出错:",e),100}}static trimSvgCode(e){const n=new DOMParser().parseFromString(e,"image/svg+xml").documentElement,s=n.getAttribute("width"),r=n.getAttribute("height");n.removeAttribute("width"),n.removeAttribute("height");const o=n.style.width,i=n.style.height;n.style.removeProperty("width"),n.style.removeProperty("height");let a=100,c=100;return s!==null?a=this.getNumFromString(s):o!==""&&(a=this.getNumFromString(o)),r!==null?c=this.getNumFromString(r):i!==""&&(c=this.getNumFromString(i)),{svgCode:n.outerHTML,width:a,height:c}}}class xo extends Sn{constructor(t,n){super(t,n);g(this,"type",A.Section);this.props.set(R.Base,new gt),this.props.set(R.Border,new Ot),this.props.set(R.Color,new Jt)}get borderProps(){return this.props.get(R.Border)}get colorProps(){return this.props.get(R.Color)}updateProps(t){super.updateProps(t),t.find(s=>s.type===R.Base)&&this.updateTransformMatrix()}drawOnGLCtx(t){t.save();const n=this.baseProps,{a:s,b:r,c:o,d:i,e:a,f:c}=this.globalTransform();t.transform(s,r,o,i,a,c);const h=this.colorProps,d=this.borderProps;t.beginPath(),t.roundRect(0,0,n.width,n.height,6),h.color!==""&&(t.fillStyle=h.color,t.globalAlpha=h.alpha,t.fill()),d.color!==""&&d.dashType!==Ee.None&&(T.setDashLine(d,t),t.strokeStyle=d.color,t.lineWidth=d.width,t.globalAlpha=d.alpha,t.stroke()),t.restore()}static load(t,n,s,r,o,i){const a=new xo(t,i);return a.type=n,a.zIndex=s,a.setParent(o),a.updateProps(r),a}getTextContentRect(){return this.baseProps}}class Po extends Sn{constructor(t,n){super(t,n);g(this,"type",A.Group);this.props.set(R.Base,new gt)}get globalPos(){return this.nameGlobalTransform().crossPoint(new m)}computeBasePropsByChildren(){const t=[];for(const r of this.children)t.push(r.baseProps);const n=T.getBoundsByBasePropsList(t),s=D.rectNode2Rect(n);return gt.create({x:s.x,y:s.y,width:s.width,height:s.height})}drawOnGLCtx(t){}getTextContentRect(){return this.baseProps}canBeConnected(){return!1}transToLocalPoint(t){return this.nameGlobalTransform().inverseMatrix().crossPoint(t)}contains(t,n=1){const{width:s,height:r}=this.baseProps,o=this.transToLocalPoint(t);return T.rectContains(o,new D(0,0,s,r))}toGlobal(t){return this.nameGlobalTransform().crossPoint(t)}nameGlobalTransform(){const t=this.selfTransform();return this.globalTransform().crossProduct(t)}selfTransform(){const{x:t,y:n}=this.baseProps;return Z.generateMatrix().translate(t,n)}updateTransformMatrix(){}static load(t,n,s,r,o,i){const a=new Po(t,i);return a.type=n,a.zIndex=s,a.setParent(o),a.updateProps(r),a}}const Nr=class Nr{static getInstance(){return this.instance||(this.instance=new Nr),this.instance}create(e,t,n,s,r,o){switch(t){case A.Line:return dn.load(e,t,n,s,r,o);case A.SVG:return Ts.load(e,t,n,s,r,o);case A.IMG:return ys.load(e,t,n,s,r,o);case A.Section:return xo.load(e,t,n,s,r,o);case A.Group:return Po.load(e,t,n,s,r,o);case A.Shape:default:return qe.load(e,t,n,s,r,o)}}createByNodeInfo(e,t,n){const s=T.convertCapInfoToProps(e.capInfo);return this.create(e.id,e.type,e.zIndex,s,t,n)}};g(Nr,"instance",null);let Ge=Nr;class bo extends Sn{constructor(t){const s=document.createElement("canvas").getContext("2d");super(t,s);g(this,"type",A.ROOT);g(this,"transform",Z.generateMatrix())}updateProps(t){}drawOnGLCtx(t){}getTextContentRect(){return new D}toGlobal(t){return t}toLocal(t){return t}}const fr=800;class ac{static async getImageSize(e){return new Promise((t,n)=>{const s=URL.createObjectURL(e),r=new Image;r.crossOrigin="anonymous",r.onload=()=>{let o=r.naturalWidth*.5,i=r.naturalHeight*.5;URL.revokeObjectURL(s);const a=o/i;o>i&&o>fr?(o=fr,i=o/a):i>o&&i>fr&&(i=fr,o=i*a),t({width:o,height:i})},r.onerror=()=>{URL.revokeObjectURL(s),n(new Error("无法加载图片"))},r.src=s})}}class cc{constructor(e,t,n,s,r,o,i,a,c,h,d,u,p,f,y,w){g(this,"nodeManager");g(this,"gmlRender");g(this,"detectors");g(this,"toolManager");g(this,"inputManager");g(this,"actionManager");g(this,"renderManager");g(this,"auxiliaryManager");g(this,"lastInteractiveEvent",null);g(this,"lastDiffTypeEvent",null);g(this,"docState");g(this,"idGenerator");g(this,"cursorManager");g(this,"previewManager");g(this,"resourceManager");g(this,"slotManager");g(this,"asyncRenderNodeManager");g(this,"cropManager");g(this,"alignPoint",null);this.nodeManager=e,this.gmlRender=t,this.detectors=n,this.toolManager=s,this.inputManager=r,this.actionManager=o,this.renderManager=i,this.auxiliaryManager=a,this.cursorManager=new qo,this.docState=c,this.idGenerator=h,this.cursorManager=d,this.previewManager=u,this.resourceManager=p,this.slotManager=f,this.asyncRenderNodeManager=y,this.cropManager=w}detect(e,t){const n=this.detectors.get(e);return!n||!n.detect(t,this)?null:n.result}addOrUpdate(e,t){this.auxiliaryManager.addOrUpdate(e,t),this.renderManager.addAuxiliaryDrawTask()}removeAuxGraphic(e){this.auxiliaryManager.remove(e),this.renderManager.addAuxiliaryDrawTask()}setCursor(e){this.cursorManager.setCursor(e)}getSelectNodes(){return this.auxiliaryManager.selectManager.selectNodes}execAction(e){this.actionManager.execAction(e)}reset(){this.auxiliaryManager.removeHoverGraphics(),this.auxiliaryManager.removeAlignGraphics(),this.renderManager.addAuxiliaryDrawTask()}inSelect(e){if(this.auxiliaryManager.selectManager.selectNodes.size===0)return!1;const t=this.auxiliaryManager.selectManager.getSelectBounds();return T.rectContains2(e,t)}refreshEvent(){}zoomScale(e,t){this.renderManager.zoomScale(e,t,this.asyncRenderNodeManager)}}class lc{addImageNode(e,t,n,s,r){const o=[{type:R.Base,x:s.x,y:s.y,width:t,height:n},{type:R.Image,url:e},{type:R.Border,dashType:Ee.None}],i=r.idGenerator.genId(A.IMG),a={id:i,type:A.IMG,zIndex:Qt.genZIndex(r.nodeManager.root),parentId:"",props:o};r.execAction(new nt);const c=Yt.create(a);r.execAction(c),r.execAction(Pt.create([i])),r.execAction(new et)}}class np{constructor(e){g(this,"app");this.app=e}addSvgNodeBySvgCode(e){const t=this.app.docState.docId,n=lr(10),s=`${t}/${n}`;this.app.resourceManager.uploadSvgString(s,e).then(r=>{this.addSvgNode(e,r)})}addSvgNode(e,t){const n=this.app.appContext,s=n.renderManager.gmlRender.getViewPortBounds(),r=new m(.5*(s.minX+s.maxX),.5*(s.minY+s.maxY)),i=new fo().computeAddSvgNode(e,t,r,this.app.appContext),a=i.id;n.execAction(new nt);const c=Yt.create(i);n.execAction(c),n.execAction(Pt.create([a])),n.execAction(new et)}addImageNode(e,t,n){const s=new lc,r=this.app.appContext,o=r.renderManager.gmlRender.getViewPortBounds(),i=new m(.5*(o.minX+o.maxX),.5*(o.minY+o.maxY));s.addImageNode(e,t,n,i,r)}quickCreateNode(e,t){const n=this.app.nodeManager.getNode(t);if(!n||n.type!==A.Line)return;const s=n,{start:r}=s.connectProps;if(!r)return;const o=this.app.nodeManager.getNode(r.objectId);if(!o)return;const i=o.baseProps,c=s.lineProps.points,h=c[c.length-1],d=c[c.length-2],u=qe.drawerMap.get(e).getConnectAnchor(),p=T.judgeHorizon(d,h);let f;p?h.x>d.x?f=u[Mt.Left]:f=u[Mt.Right]:h.y>d.y?f=u[Mt.Top]:f=u[Mt.Bottom];const y=i.width*f.x,w=i.height*f.y,b=h.x-y,x=h.y-w,v=this.app.appContext,C=rr[e],E=Nn[C],k=hn[C],I=[{type:R.Base,x:b,y:x,width:i.width,height:i.height},Jt.create({color:E}),Ot.create({color:k}),new jt(e)],V=v.idGenerator.genId(A.Shape),U={id:V,type:A.Shape,zIndex:Qt.genZIndex(this.app.nodeManager.root),parentId:"",props:I};v.execAction(new nt);const J=Yt.create(U);v.execAction(J);const j=s.connectProps.clone();j.end={objectId:V,x:f.x,y:f.y},v.execAction(ct.create(t,[j])),v.execAction(Pt.create([V])),v.execAction(lt.focus(V)),v.execAction(new et)}}class gr{group(e,t){const n=T.filterToGroupNodes(e);if(n.length<2)return;t.execAction(new nt);const s=t.idGenerator.genId(A.Group),r=[],o=T.sortGraphics(n),i=o[o.length-1].parent;for(const b of o)r.push(b.getBounds());const a=T.getBounds(r),c=D.rectNode2Rect(a),h=new m(c.x,c.y),d=i.toLocal(h),u={id:s,parentId:i.id,type:A.Group,zIndex:Qt.genZIndex(i),props:[gt.create({x:d.x,y:d.y,width:c.width,height:c.height})]};t.execAction(new Yt({nodes:[u]}));const p=t.nodeManager.getNode(s),f=[];let y=1;const w=p.globalTransform().inverseMatrix();for(const b of o){const x=b.globalPos,v=w.crossPoint(x);f.push({id:b.id,parentId:s,props:[{type:R.Base,x:v.x,y:v.y}],zIndex:y}),y++}t.execAction(new ct({infos:f})),t.execAction(Pt.create([p.id])),t.execAction(new et)}unGroup(e,t){t.execAction(new nt);const n=e.parent,s=[...e.children];s.sort((c,h)=>c.zIndex-h.zIndex);const r=[];let o=1;const i=Math.max(...[...n.children].map(c=>c.zIndex)),a=[];for(const c of s){const h=c.globalPos,d=n.toLocal(h);r.push({id:c.id,parentId:n.id,props:[{type:R.Base,x:d.x,y:d.y}],zIndex:i+o}),o++,a.push(c.id)}t.execAction(new ct({infos:r})),t.execAction(Fe.create([e.id])),t.execAction(Pt.create(a)),t.execAction(new et)}}class sp{constructor(e){g(this,"app");this.app=e}rotateImageAngle(e,t){const n=this.getNodeIdByBlobUrl(e);n&&this.rotateImage(n,t)}rotateImage(e,t){const n=this.app.appContext,s=n.nodeManager.getNode(e);if(!s)return;const{angle:r}=s.baseProps,o=s.globalPos,i=D.rectNode2Rect(s.getBounds()),a=new m(i.x+.5*i.width,i.y+.5*i.height),c=Z.generateMatrix().translate(a.x,a.y),h=Z.generateMatrix().rotate(t),u=c.crossProduct(h).crossProduct(c.inverseMatrix()).crossPoint(o);let p;s.parent.type===A.Group?p=s.parent.globalTransform().inverseMatrix().crossPoint(u):p=s.parent.toLocal(u),n.execAction(new nt),n.execAction(ct.create(e,[{type:R.Base,x:p.x,y:p.y,angle:r+t}])),n.execAction(new et)}getNodeIdByBlobUrl(e){const t=this.app.appContext;for(const[n,s]of t.resourceManager.nodeResourceMap)if(s.blobUrl===e)return n;return""}}const rs=class rs{static encode(e){const t=encodeURI(e),n=btoa(t);return`<html>
1
+ (function(T,st){typeof exports=="object"&&typeof module<"u"?st(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],st):(T=typeof globalThis<"u"?globalThis:T||self,st(T.engine={},T.React))})(this,function(T,st){"use strict";var Ux=Object.defineProperty;var _x=(T,st,bn)=>st in T?Ux(T,st,{enumerable:!0,configurable:!0,writable:!0,value:bn}):T[st]=bn;var p=(T,st,bn)=>_x(T,typeof st!="symbol"?st+"":st,bn);var bn=document.createElement("style");bn.textContent=`.canvas-container .auxiliary-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:2;pointer-events:none}.canvas-container .content-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:1}.canvas-container .page-canvas{position:absolute;left:0;top:0;width:100%;height:100%;z-index:0}.normal-container,.normal-container .normal-canvas{width:100%;height:100%}.canvas-input{position:absolute;border:none;outline:none;-webkit-user-select:none;user-select:none;width:1px;z-index:3;opacity:0;pointer-events:none}@keyframes van-cursor-flicker{0%{opacity:1}50%{opacity:0}to{opacity:1}}.render-input{position:absolute;background-color:#000;width:1px;height:12px;z-index:4;pointer-events:none;animation:.6s van-cursor-flicker infinite}
2
+ /*$vite$:1*/`,document.head.appendChild(bn);class Xl{constructor(t){p(this,"ctx");this.ctx=t,t.actionManager.addNetworkPlugin(this)}onEnable(t){return!0}}class ln{exec(t,e){const n=t.data;t.reverseLog=this.reverseLog(n,e),this.execData(n,e)}}var Xe=(l=>(l[l.Start=0]="Start",l[l.End=1]="End",l[l.AddNode=2]="AddNode",l[l.RemoveNode=3]="RemoveNode",l[l.UpdateNode=4]="UpdateNode",l[l.SelectNode=5]="SelectNode",l[l.TextFocus=6]="TextFocus",l))(Xe||{});class P{constructor(t=0,e=0){p(this,"x");p(this,"y");this.x=t,this.y=e}clone(){return new P(this.x,this.y)}}var Or=(l=>(l.LEFT="LEFT",l.TOP="TOP",l.RIGHT="RIGHT",l.BOTTOM="BOTTOM",l))(Or||{});class zl extends P{constructor(e,n,o,s){super(e.x,e.y);p(this,"xPos");p(this,"yPos");p(this,"nodeSide");this.xPos=n,this.yPos=o,this.nodeSide=s}}class Wl extends P{constructor(){super(...arguments);p(this,"isHorizon",!0)}}const Sn="ROOT",Xr="ROOT";var v=(l=>(l[l.Shape=0]="Shape",l[l.Line=1]="Line",l[l.SVG=2]="SVG",l[l.IMG=3]="IMG",l[l.Section=4]="Section",l[l.Group=5]="Group",l[l.Checkbox=6]="Checkbox",l[l.CheckboxText=7]="CheckboxText",l[l.SlideContainer=8]="SlideContainer",l[l.ROOT=99]="ROOT",l))(v||{}),et=(l=>(l[l.None=0]="None",l[l.Solid=1]="Solid",l[l.Dash1=2]="Dash1",l[l.Dash2=3]="Dash2",l))(et||{}),it=(l=>(l[l.None=0]="None",l[l.Arrow=1]="Arrow",l[l.Triangle=2]="Triangle",l[l.EmptyTriangle=3]="EmptyTriangle",l[l.Diamond=4]="Diamond",l[l.EmptyDiamond=5]="EmptyDiamond",l[l.Circle=6]="Circle",l[l.EmptyCircle=7]="EmptyCircle",l))(it||{}),at=(l=>(l[l.Top=0]="Top",l[l.Middle=1]="Middle",l[l.Bottom=2]="Bottom",l))(at||{}),We=(l=>(l[l.fix=0]="fix",l[l.autoHeight=1]="autoHeight",l[l.autoWidth=2]="autoWidth",l))(We||{}),I=(l=>(l[l.Base=0]="Base",l[l.Color=1]="Color",l[l.Border=2]="Border",l[l.Text=3]="Text",l[l.Shape=4]="Shape",l[l.Line=5]="Line",l[l.Arrow=6]="Arrow",l[l.Connect=7]="Connect",l[l.LineTextRect=8]="LineTextRect",l[l.Svg=9]="Svg",l[l.Image=10]="Image",l[l.Crop=11]="Crop",l[l.CheckStatus=12]="CheckStatus",l[l.CheckSize=13]="CheckSize",l[l.TextParagraph=14]="TextParagraph",l[l.TextParagraphQuote=15]="TextParagraphQuote",l[l.Slide=16]="Slide",l))(I||{});class ct{}class oo extends ct{constructor(){super(...arguments);p(this,"type",I.Image);p(this,"url","")}static from(e){const n=new oo;return n.url=e.url,n}clone(){const e=new oo;return e.url=this.url,e}update(e){const{url:n}=e;n!==void 0&&(this.url=n)}}class ie extends ct{constructor(){super(...arguments);p(this,"type",I.Base);p(this,"x",0);p(this,"y",0);p(this,"width",100);p(this,"height",100);p(this,"angle",0)}static create(e){const n=new ie;return n.update(e),n}static from(e){const n=new ie;return n.x=e.x,n.y=e.y,n.width=e.width,n.height=e.height,n.angle=e.angle,n}update(e){const{x:n,y:o,height:s,width:r,angle:i}=e;n!==void 0&&(this.x=n),o!==void 0&&(this.y=o),s!==void 0&&(this.height=s),r!==void 0&&(this.width=r),i!==void 0&&(this.angle=i)}clone(){const e=new ie;return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e.angle=this.angle,e}}class Ae extends ct{constructor(){super(...arguments);p(this,"type",I.Border);p(this,"color","#000000");p(this,"alpha",1);p(this,"width",2);p(this,"dashType",et.Solid)}static create(e){const n=new Ae;return n.update(e),n}static from(e){const n=new Ae;return n.color=e.color,n.alpha=e.alpha,n.width=e.width,n.dashType=e.dashType,n}update(e){const{color:n,alpha:o,width:s,dashType:r}=e;n!==void 0&&(this.color=n),o!==void 0&&(this.alpha=o),s!==void 0&&(this.width=s),r!==void 0&&(this.dashType=r)}clone(){const e=new Ae;return e.color=this.color,e.alpha=this.alpha,e.width=this.width,e.dashType=this.dashType,e}}class re{constructor(){p(this,"a",1);p(this,"b",0);p(this,"c",0);p(this,"d",1);p(this,"e",0);p(this,"f",0)}static generateMatrix(){return new re}setTransform(t,e,n,o,s,r){this.a=t,this.b=e,this.c=n,this.d=o,this.e=s,this.f=r}rotate(t){const e=t/180*Math.PI;return this.rotate2(e),this}rotate2(t){return this.a=Math.cos(t),this.c=-Math.sin(t),this.b=Math.sin(t),this.d=Math.cos(t),this}scale(t,e){return this.a=t,this.d=e,this}translate(t,e){return this.e=t,this.f=e,this}crossProduct(t){const e=new re;return e.a=this.a*t.a+this.c*t.b,e.b=this.b*t.a+this.d*t.b,e.c=this.a*t.c+this.c*t.d,e.d=this.b*t.c+this.d*t.d,e.e=this.a*t.e+this.c*t.f+this.e,e.f=this.b*t.e+this.d*t.f+this.f,e}crossPoint(t){return new P(this.a*t.x+this.c*t.y+this.e,this.b*t.x+this.d*t.y+this.f)}inverseMatrix(){const{a:t,b:e,c:n,d:o,e:s,f:r}=this,i=t*o-e*n;if(Math.abs(i)<1e-4)throw new Error("该仿射变换不可逆");const a=o/i,c=-e/i,h=-n/i,d=t/i,u=(n*r-o*s)/i,f=(e*s-t*r)/i,g=re.generateMatrix();return g.a=a,g.b=c,g.c=h,g.d=d,g.e=u,g.f=f,g}clone(){const t=new re;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.e=this.e,t.f=this.f,t}}class Fl{constructor(t,e,n){p(this,"p0");p(this,"p1");p(this,"p2");this.p0=t,this.p1=e,this.p2=n}xStationaryPoint(){return(this.p0.x-this.p1.x)/(this.p0.x-2*this.p1.x+this.p2.x)}dxdt(t){return 2*t*(this.p0.x-2*this.p1.x+this.p2.x)-2*(this.p0.x-this.p1.x)}xValue(t){const e=1-t;return e*e*this.p0.x+2*t*e*this.p1.x+t*t*this.p2.x}yValue(t){const e=1-t;return e*e*this.p0.y+2*t*e*this.p1.y+t*t*this.p2.y}newtonSolveX(t,e,n){let s=.5*(e+n),r=0;for(;;){r++;const i=this.xValue(s)-t,a=this.dxdt(s),c=s-i/a;if(Math.abs(c-s)<.01)return c;if(r>20)return null;s=c}return null}solve(t,e=6){const n=this.xStationaryPoint();if(n<0||n>1)return this.monotonicSolve(t,0,1,e);let o=this.monotonicSolve(t,0,n,e);return o?!0:(o=this.monotonicSolve(t,n,1,e),o)}monotonicSolve(t,e,n,o){const s=this.xValue(e),r=this.xValue(n),i=t.x,a=t.y;if((i-s)*(i-r)>0)return!1;const c=this.newtonSolveX(i,e,n);return c===null?(console.warn("newton 迭代求解贝塞尔曲线出错."),!1):Math.abs(a-this.yValue(c))<o}}class Bo{constructor(t){p(this,"prev",null);p(this,"next",null);p(this,"data",null);this.data=t}breakOff(){this.prev=null,this.next=null}toString(){return this.data?this.data.toString():""}add(t){const e=this.next;this.next=t,t.prev=this,t.next=e,e&&(e.prev=t)}pushAdd(t){this.next=t,t.prev=this}removeSelf(){const t=this.next,e=this.prev;this.next=null,this.prev=null,t.prev=e,e.next=t}getIndex(){let t=this.prev,e=0;for(;t&&t.data;)e++,t=t.prev;return e}static generateLink(){const t=new Bo(null),e=new Bo(null);return t.add(e),t}}class D{constructor(t=0,e=0,n=100,o=100){p(this,"x");p(this,"y");p(this,"width");p(this,"height");this.x=t,this.y=e,this.width=n,this.height=o}clone(){return new D(this.x,this.y,this.width,this.height)}static baseProps2Rect(t){const{x:e,y:n,width:o,height:s}=t;return new D(e,n,o,s)}static rectNode2Rect(t){const{minY:e,minX:n,maxY:o,maxX:s}=t;return new D(n,e,s-n,o-e)}static toRectNode(t){const{x:e,y:n,width:o,height:s}=t;return{minX:e,minY:n,maxX:e+o,maxY:n+s}}}var zn=(l=>(l[l.Image=0]="Image",l[l.SVG=1]="SVG",l))(zn||{});class Ke{constructor(){p(this,"result",null)}detect(t,e){return this.result?!0:this.onDetect(t,e)}reset(){this.result=null}}var F=(l=>(l[l.Node=0]="Node",l[l.Stretch=1]="Stretch",l[l.HoverNode=2]="HoverNode",l[l.ParagraphHead=3]="ParagraphHead",l[l.PolyControlPoint=4]="PolyControlPoint",l[l.CurveControlPoint=5]="CurveControlPoint",l[l.LineEndPoint=6]="LineEndPoint",l[l.ConnectorPoint=7]="ConnectorPoint",l[l.Rotate=8]="Rotate",l[l.SingleStretch=9]="SingleStretch",l[l.ExpandShape=10]="ExpandShape",l[l.NodeEdge=11]="NodeEdge",l[l.BufferNode=12]="BufferNode",l[l.BufferHoverNode=13]="BufferHoverNode",l[l.HoverNodeAnchor=14]="HoverNodeAnchor",l[l.HoverConnectAnchor=15]="HoverConnectAnchor",l[l.HoverOnContainer=16]="HoverOnContainer",l[l.Image=17]="Image",l[l.ImageOriginBounds=18]="ImageOriginBounds",l[l.CurveEndPoint=19]="CurveEndPoint",l[l.DragLineText=20]="DragLineText",l[l.SlideGap=21]="SlideGap",l[l.EmptySlideContainer=22]="EmptySlideContainer",l))(F||{}),be=(l=>(l.pointerDown="pointerdown",l.pointermove="pointermove",l.pointermoveOutside="pointermoveOutside",l.pointerup="pointerup",l.unknown="unknown",l))(be||{}),V=(l=>(l[l.TOP=0]="TOP",l[l.LEFT=1]="LEFT",l[l.BOTTOM=2]="BOTTOM",l[l.RIGHT=3]="RIGHT",l[l.TOP_LEFT=4]="TOP_LEFT",l[l.TOP_RIGHT=5]="TOP_RIGHT",l[l.BOTTOM_LEFT=6]="BOTTOM_LEFT",l[l.BOTTOM_RIGHT=7]="BOTTOM_RIGHT",l))(V||{});class tt extends ct{constructor(){super(...arguments);p(this,"type",I.Color);p(this,"color","#ffccff");p(this,"alpha",1)}static create(e){const n=new tt;return n.update(e),n}static from(e){const n=new tt;return n.color=e.color,n.alpha=e.alpha,n}update(e){const{color:n,alpha:o}=e;n!==void 0&&(this.color=n),o!==void 0&&(this.alpha=o)}clone(){const e=new tt;return e.color=this.color,e.alpha=this.alpha,e}}class Ge extends ct{constructor(){super(...arguments);p(this,"type",I.Text);p(this,"text","");p(this,"richText","");p(this,"fontSize",14);p(this,"fontFamily","Noto Sans");p(this,"fontColor","#000000");p(this,"fontBgColor","");p(this,"bold",!1);p(this,"italic",!1);p(this,"underline",!1);p(this,"strikethrough",!1);p(this,"verticalAlign",at.Middle);p(this,"horizonAlign",at.Middle);p(this,"sizeMode",We.fix)}static create(e){const n=new Ge;return n.update(e),n}static from(e){const n=new Ge;return n.text=e.text,n.fontSize=e.fontSize,n.fontFamily=e.fontFamily,n.fontColor=e.fontColor,n.fontBgColor=e.fontBgColor,n.bold=e.bold,n.italic=e.italic,n.underline=e.underline,n.strikethrough=e.strikethrough,n.verticalAlign=e.verticalAlign,n.horizonAlign=e.horizonAlign,n.sizeMode=e.sizeMode,n.richText=e.richText,!e.richText&&e.text&&(n.richText=this.dealTextToRichText(e.text)),n}update(e){const{sizeMode:n,verticalAlign:o,horizonAlign:s,fontFamily:r,fontSize:i,text:a,bold:c,italic:h,fontColor:d,fontBgColor:u,underline:f,strikethrough:g,richText:y}=e;a!==void 0&&(this.text=a),r!==void 0&&(this.fontFamily=r),i!==void 0&&(this.fontSize=i),d!==void 0&&(this.fontColor=d),u!==void 0&&(this.fontBgColor=u.trim()),c!==void 0&&(this.bold=c),h!==void 0&&(this.italic=h),f!==void 0&&(this.underline=f),g!==void 0&&(this.strikethrough=g),o!==void 0&&(this.verticalAlign=o),s!==void 0&&(this.horizonAlign=s),n!==void 0&&(this.sizeMode=n),y!==void 0&&(this.richText=y)}clone(){const e=new Ge;return e.text=this.text,e.fontFamily=this.fontFamily,e.fontSize=this.fontSize,e.fontColor=this.fontColor,e.fontBgColor=this.fontBgColor,e.bold=this.bold,e.italic=this.italic,e.underline=this.underline,e.strikethrough=this.strikethrough,e.horizonAlign=this.horizonAlign,e.verticalAlign=this.verticalAlign,e.sizeMode=this.sizeMode,e.richText=this.richText,e}static dealTextToRichText(e){const n=e.split(`
3
+ `);let o="<root>";for(const s of n)o=o+"<p>"+s+"</p>";return o+="</root>",o}}class Oe extends ct{constructor(e=1){super();p(this,"type",I.Shape);p(this,"shapeCode",1);this.shapeCode=e}static from(e){const n=new Oe;return n.shapeCode=e.shapeCode,n}update(e){const{shapeCode:n}=e;n!==void 0&&(this.shapeCode=n)}clone(){const e=new Oe;return e.shapeCode=this.shapeCode,e}}class je extends ct{constructor(){super(...arguments);p(this,"type",I.Line);p(this,"points",[]);p(this,"auto",!0)}static create(e,n=!0){const o=new je;return o.auto=n,o.points=e,o}static from(e){const n=new je;return n.points=e.points,n.auto=e.auto,n}clone(){const e=new je,n=[];for(const o of this.points)n.push(S.cloneIPoint(o));return e.points=n,e.auto=this.auto,e}update(e){const{points:n,auto:o}=e;n!==void 0&&(this.points=n),o!==void 0&&(this.auto=o)}}class Rt extends ct{constructor(){super(...arguments);p(this,"type",I.Connect);p(this,"start",null);p(this,"end",null)}static from(e){const n=new Rt;return n.start=e.start,n.end=e.end,n}clone(){const e=new Rt;return e.start=this.start,e.end=this.end,e}update(e){const{start:n,end:o}=e;n!==void 0&&(this.start=n),o!==void 0&&(this.end=o)}}class lt extends ct{constructor(){super(...arguments);p(this,"type",I.Arrow);p(this,"lArrow",it.None);p(this,"rArrow",it.None)}static create(e){const n=new lt;return n.update(e),n}static from(e){const n=new lt;return n.lArrow=e.lArrow,n.rArrow=e.rArrow,n}clone(){const e=new lt;return e.rArrow=this.rArrow,e.lArrow=this.lArrow,e}update(e){const{lArrow:n,rArrow:o}=e;n!==void 0&&(this.lArrow=n),o!==void 0&&(this.rArrow=o)}}var de=(l=>(l[l.Top=0]="Top",l[l.Right=1]="Right",l[l.Bottom=2]="Bottom",l[l.Left=3]="Left",l))(de||{});class Et extends ct{constructor(){super(...arguments);p(this,"type",I.LineTextRect);p(this,"width",20);p(this,"height",20);p(this,"x",0);p(this,"y",0);p(this,"point",{x:0,y:0})}static from(e){const n=new Et;return n.width=e.width,n.height=e.height,n.x=e.x,n.y=e.y,n.point=e.point,n}update(e){const{x:n,y:o,point:s,height:r,width:i}=e;n!==void 0&&(this.x=n),o!==void 0&&(this.y=o),r!==void 0&&(this.height=r),i!==void 0&&(this.width=i),s!==void 0&&(this.point=s)}clone(){const e=new Et;return e.width=this.width,e.height=this.height,e.x=this.x,e.y=this.y,e.point=this.point,e}}var k=(l=>(l[l.HoverBounds=0]="HoverBounds",l[l.HoverLine=1]="HoverLine",l[l.SelectLine=2]="SelectLine",l[l.MultiSelectBound=3]="MultiSelectBound",l[l.TextSelection=4]="TextSelection",l[l.SelectGroup=5]="SelectGroup",l[l.SelectRect=6]="SelectRect",l[l.HighLightLine=7]="HighLightLine",l[l.AlignLine=8]="AlignLine",l[l.AlignStretchLine=9]="AlignStretchLine",l[l.SingleSelectBound=10]="SingleSelectBound",l[l.RotateLine=11]="RotateLine",l[l.HighlightRects=12]="HighlightRects",l[l.CreateRectBound=13]="CreateRectBound",l[l.ExpandShape=14]="ExpandShape",l[l.SelectLineEnd=15]="SelectLineEnd",l[l.HoverConnectPoint=16]="HoverConnectPoint",l[l.HoverConnectAnchorPoint=17]="HoverConnectAnchorPoint",l[l.HoverAnchorPoint=18]="HoverAnchorPoint",l[l.SelectPolyLineControlPoint=19]="SelectPolyLineControlPoint",l[l.SelectLineTextRect=20]="SelectLineTextRect",l[l.PlaceHolder=21]="PlaceHolder",l[l.SelectConnectAnchor=22]="SelectConnectAnchor",l[l.HoverConnectAnchor=23]="HoverConnectAnchor",l[l.PreviewGraphics=24]="PreviewGraphics",l[l.HoverContainer=25]="HoverContainer",l[l.CropBounds=26]="CropBounds",l[l.CropOriginImg=27]="CropOriginImg",l[l.StretchRect=28]="StretchRect",l[l.HoverSize=29]="HoverSize",l[l.SelectCurveControlPoint=30]="SelectCurveControlPoint",l[l.SelectCurveEnd=31]="SelectCurveEnd",l[l.SelectParentGroupBound=32]="SelectParentGroupBound",l[l.SelectSlideGapInsertPoint=33]="SelectSlideGapInsertPoint",l[l.HoverSlidePlaceHolder=34]="HoverSlidePlaceHolder",l[l.HoverInsertSlide=35]="HoverInsertSlide",l[l.HoverInsertHorizonSlide=36]="HoverInsertHorizonSlide",l[l.HoverSlideGapInsertPoint=37]="HoverSlideGapInsertPoint",l[l.HoverFocusCopy=38]="HoverFocusCopy",l))(k||{});class Me{constructor(){p(this,"prop")}update(t){this.prop=t}}const Ht="#FFFFFF",bs="#000000",Gt="#647ee5",Qe="#545DE7",Ss="#32a8f2",zr="#3370FF",Wr=8,Fr=18,Yr=5,Ms=11,Gr="#CCCCCC",Ur="#B7BEF5",_r="#DADEFA";class $r extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverBounds)}draw(e,n){const{node:o,transform:s}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1;const{x:r,y:i,width:a,height:c}=o.baseProps,{a:h,b:d,c:u,d:f,e:g,f:y}=s;e.transform(h,d,u,f,g,y),e.beginPath(),e.strokeRect(0,0,a,c),e.restore()}}class jr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SingleSelectBound)}draw(e,n){const{x:o,y:s,width:r,height:i,transform:a}=this.prop;e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{a:c,b:h,c:d,d:u,e:f,f:g}=a;e.transform(c,h,d,u,f,g),e.beginPath(),e.strokeRect(o,s,r,i),e.restore()}}class Vr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.MultiSelectBound)}draw(e,n){const{rect:o}=this.prop;e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{x:s,y:r,width:i,height:a}=o;e.beginPath(),e.strokeRect(s,r,i,a),e.restore()}}class Kr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HighlightRects)}draw(e,n){const{rects:o}=this.prop;for(const s of o){e.save(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{x:r,y:i,width:a,height:c}=s;e.beginPath(),e.strokeRect(r,i,a,c),e.restore()}}}class Qr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectGroup)}draw(e,n){const{rect:o,isPrecise:s}=this.prop;e.save(),e.beginPath(),e.strokeStyle=Ss,e.fillStyle=Ss,s&&e.setLineDash([2,2]),e.rect(o.x,o.y,o.width,o.height),e.lineWidth=1/n,e.stroke(),e.globalAlpha=.2,e.fill(),e.restore()}}class Zr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.TextSelection)}draw(e){const{selectionList:n,node:o}=this.prop;if(n.length===0)return;e.save(),e.fillStyle=zr,e.globalAlpha=.5;const{a:s,b:r,c:i,d:a,e:c,f:h}=o.globalTransform();e.transform(s,r,i,a,c,h);for(const d of n)e.fillRect(d.x,d.y,d.width,d.height);e.restore()}}class qr{static computeStretchRects(t,e){const n=Wr/e,o=.5*n;return[new D(t.x-o,t.y-o,n,n),new D(t.x+t.width-o,t.y-o,n,n),new D(t.x+t.width-o,t.y+t.height-o,n,n),new D(t.x-o,t.y+t.height-o,n,n)]}}class Jr extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.StretchRect)}draw(e,n){const{rect:o,transform:s}=this.prop,r=qr.computeStretchRects(o,n);e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=1/n,e.globalAlpha=1,e.beginPath();for(const f of r)e.roundRect(f.x,f.y,f.width,f.height,1/n),e.fill(),e.stroke();e.restore()}}class ei extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.CreateRectBound)}draw(e,n){const{rect:o,transform:s}=this.prop;e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1;const{width:u,height:f}=o;e.beginPath(),e.strokeRect(0,0,u,f),e.restore()}}class ti extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.ExpandShape)}draw(e,n){const{rect:o,transform:s}=this.prop,{width:r,height:i}=o,a=1.5/n,c=re.generateMatrix().scale(a,a),h=re.generateMatrix().translate(.5*r-.5*a*14,i-.5*a*8),d=s.crossProduct(h.crossProduct(c));e.save(),e.beginPath();const{a:u,b:f,c:g,d:y,e:m,f:b}=d;e.transform(u,f,g,y,m,b),e.fillStyle=Qe,e.roundRect(0,0,14,7.58333,2),e.fill(),e.beginPath(),e.fillStyle=Ht,e.rect(1.75,2.91666,2.33333,2.33333),e.rect(5.83333,2.91666,2.33333,2.33333),e.rect(9.91667,2.91666,2.33333,2.33333),e.fill(),e.restore()}}class ni extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.AlignLine)}draw(e,n){const{lines:o}=this.prop;e.save(),e.beginPath(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1,e.setLineDash([4,2]);for(const s of o){const{start:r,end:i}=s;e.moveTo(r.x,r.y),e.lineTo(i.x,i.y)}e.stroke(),e.restore()}}class oi extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.AlignStretchLine)}draw(e,n){const o=10/n,{alignInfo:s}=this.prop,{width:r,height:i}=s;e.save(),e.beginPath(),e.strokeStyle=Qe,e.lineWidth=1/n,e.globalAlpha=1,r&&this.drawWidth(e,r,o),i&&this.drawHeight(e,i,o),e.restore()}drawWidth(e,n,o){const{lines:s}=n;for(const r of s){const{line:i,transform:a}=r,{start:c,end:h}=i;e.save();const{a:d,b:u,c:f,d:g,e:y,f:m}=a;e.transform(d,u,f,g,y,m);const b={x:c.x,y:c.y},w={x:c.x,y:c.y+2*o};e.moveTo(b.x,b.y),e.lineTo(w.x,w.y);const L={x:h.x,y:h.y},B={x:h.x,y:h.y+2*o};e.moveTo(L.x,L.y),e.lineTo(B.x,B.y),e.moveTo(c.x,c.y+o),e.lineTo(h.x,h.y+o),e.stroke(),e.restore()}}drawHeight(e,n,o){const{lines:s}=n;for(const r of s){const{line:i,transform:a}=r,{start:c,end:h}=i;e.save();const{a:d,b:u,c:f,d:g,e:y,f:m}=a;e.transform(d,u,f,g,y,m);const b={x:c.x,y:c.y},w={x:c.x+2*o,y:c.y};e.moveTo(b.x,b.y),e.lineTo(w.x,w.y);const L={x:h.x,y:h.y},B={x:h.x+2*o,y:h.y};e.moveTo(L.x,L.y),e.lineTo(B.x,B.y),e.moveTo(c.x+o,c.y),e.lineTo(h.x+o,h.y),e.stroke(),e.restore()}}}class Yl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SingleSelectBound)}draw(e,n){const{start:o,end:s,transform:r}=this.prop,i=5/n;e.save();const{a,b:c,c:h,d,e:u,f}=r;e.transform(a,c,h,d,u,f),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,i,0,2*Math.PI),e.fill(),e.stroke(),e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}class Gl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverLine)}draw(e,n){const{node:o,transform:s}=this.prop;e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),o.drawer.draw(o,e),e.restore()}}class Ul extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectLine)}draw(e,n){const{node:o}=this.prop;e.save();const{a:s,b:r,c:i,d:a,e:c,f:h}=o.globalTransform();e.transform(s,r,i,a,c,h),e.strokeStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),o.drawer.draw(o,e),e.restore()}}class _l extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectPoint)}draw(e,n){const{point:o}=this.prop,s=4/n;e.save(),e.fillStyle=Gt,e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill(),e.restore()}}class $l extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectAnchorPoint)}draw(e,n){const{node:o}=this.prop;if(!o.canQuickCreate())return;const s=5/n,{width:r,height:i}=o.baseProps,{a,b:c,c:h,d,e:u,f}=o.globalTransform(),g=o.getConnectAnchor(),y=[];for(const m of g)y.push(new P(m.x*r,m.y*i));e.save(),e.transform(a,c,h,d,u,f),e.fillStyle=Ht,e.strokeStyle=Qe;for(const m of y)e.beginPath(),e.arc(m.x,m.y,s,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class jl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectAnchorPoint)}draw(e,n){const{node:o,localPoint:s}=this.prop;if(!o.canBeConnected())return;const r=6/n,{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.save(),e.transform(i,a,c,h,d,u),e.fillStyle=Gt,e.beginPath(),e.arc(s.x,s.y,r,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}const A=22;class Vl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectPolyLineControlPoint)}draw(e,n){const{points:o,transform:s}=this.prop;e.save(),e.fillStyle=Qe,e.strokeStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1;const{a:r,b:i,c:a,d:c,e:h,f:d}=s;e.transform(r,i,a,c,h,d);for(let u=0;u<o.length-1;u++){const f=o[u],g=o[u+1];if(S.distance(f,g)<(A+6)/n)continue;const m=S.judgeHorizon(f,g),b=.5*(f.x+g.x),w=.5*(f.y+g.y);if(e.beginPath(),m){const L=new P(b-6/n,w);e.roundRect(L.x,L.y-2/n,12/n,4/n,2/n)}else{const L=new P(b,w-6/n);e.roundRect(L.x-2/n,L.y,4/n,12/n,2/n)}e.stroke(),e.fill()}e.restore()}}class Kl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectLineTextRect)}draw(e,n){const{node:s,transform:r}=this.prop,i=s.getTextContentRect();e.save();const{a,b:c,c:h,d,e:u,f}=r;e.transform(a,c,h,d,u,f),e.strokeStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1,e.beginPath(),e.strokeRect(i.x-2,i.y-2,i.width+2*2,i.height+2*2),e.restore()}}const si="输入文本";class Ql extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.PlaceHolder)}draw(e,n){const{node:o}=this.prop,s=o.shapeType!==K.PureText,r=o.renderText,i=r.paragraphs[0],a=i.lines[0],c=r.x+i.x+a.x,h=r.y+i.y+a.y,{fontSize:d,fontFamily:u,bold:f,italic:g}=r.textProps;e.save();const{a:y,b:m,c:b,d:w,e:L,f:B}=o.globalTransform();e.transform(y,m,b,w,L,B),e.textAlign="left",e.textBaseline="alphabetic",e.fillStyle="#000000",e.globalAlpha=.5,e.font=S.calcFont(d,u,f,g);const H=e.measureText(si),E=H.fontBoundingBoxAscent,X=H.width,$=s?c-.5*X:c;e.fillText(si,$,h+E),e.restore()}}class Zl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectConnectAnchor)}draw(e,n){const{node:o}=this.prop,s=Yr/n,r=S.computeNodeConnectAnchor(o,n);e.save(),e.fillStyle=Ur,e.globalAlpha=1;const{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.transform(i,a,c,h,d,u);for(const f of r)e.beginPath(),e.arc(f.x,f.y,s,0,2*Math.PI),e.fill();e.restore()}}class ql extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverConnectAnchor)}draw(e,n){const{point:o}=this.prop,s=Ms/n;e.save(),e.strokeStyle=Qe,e.fillStyle=_r,e.globalAlpha=1,e.lineWidth=2/n,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill(),e.stroke(),e.restore()}}class Jl extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.PreviewGraphics)}draw(e,n){const{previewNodes:o}=this.prop;for(const s of o)s.drawOnGLCtx(e)}}class eh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverContainer)}draw(e,n){const{node:o}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1;const{width:s,height:r}=o.baseProps,{a:i,b:a,c,d:h,e:d,f:u}=o.globalTransform();e.transform(i,a,c,h,d,u),e.beginPath(),e.strokeRect(0,0,s,r),e.restore()}}class th extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.CropBounds)}draw(e,n){const{node:o,transform:s}=this.prop,r=12/n;e.save(),e.strokeStyle=bs,e.lineWidth=2/n,e.globalAlpha=1;const{width:i,height:a}=o.baseProps,{a:c,b:h,c:d,d:u,e:f,f:g}=s;e.transform(c,h,d,u,f,g),e.beginPath(),e.moveTo(0,r),e.lineTo(0,0),e.lineTo(r,0),e.moveTo(i-r,0),e.lineTo(i,0),e.lineTo(i,r),e.moveTo(i-r,a),e.lineTo(i,a),e.lineTo(i,a-r),e.moveTo(0,a-r),e.lineTo(0,a),e.lineTo(r,a),e.moveTo(.5*i-.5*r,0),e.lineTo(.5*i+.5*r,0),e.moveTo(.5*i-.5*r,a),e.lineTo(.5*i+.5*r,a),e.moveTo(0,.5*a-.5*r),e.lineTo(0,.5*a+.5*r),e.moveTo(i,.5*a-.5*r),e.lineTo(i,.5*a+.5*r),e.stroke(),e.beginPath(),e.setLineDash([2,2]),e.lineWidth=1/n,e.strokeRect(0,0,i,a),e.restore()}}class nh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.CropOriginImg)}draw(e,n){const{imgBitmap:o,transform:s,x:r,y:i,width:a,height:c}=this.prop;e.save();const{a:h,b:d,c:u,d:f,e:g,f:y}=s;e.transform(h,d,u,f,g,y),e.globalAlpha=.4,e.drawImage(o,r,i,a,c),e.restore()}}class oh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverSize)}draw(e,n){const{rect:o,transform:s}=this.prop,{width:r,height:i}=o,a=Math.round(r),c=Math.round(i),h=`${a}x${c}`,d=12/n,u="Noto Sans",f=S.measureTextByFont(e,h,d,"Noto Sans",!1,!1);e.save();const g=re.generateMatrix().translate(r-f.width,i),{a:y,b:m,c:b,d:w,e:L,f:B}=s.crossProduct(g);e.transform(y,m,b,w,L,B),e.fillStyle=Qe,e.globalAlpha=1,e.fillRect(0,0,f.width,f.height),e.fillStyle=Ht,e.font=S.calcFont(d,u),e.textAlign="left",e.textBaseline="top",e.fillText(h,0,2/n),e.restore()}}class sh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SingleSelectBound)}draw(e,n){const{points:o,transform:s}=this.prop,r=5/n;e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Qe,e.lineWidth=2/n,e.globalAlpha=1;for(const f of o)e.beginPath(),e.arc(f.x,f.y,r,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class rh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectCurveEnd)}draw(e,n){const{points:o,transform:s}=this.prop,r=5/n;e.save();const{a:i,b:a,c,d:h,e:d,f:u}=s;e.transform(i,a,c,h,d,u),e.strokeStyle=Qe,e.fillStyle=Ht,e.lineWidth=2/n,e.globalAlpha=1;for(const f of o)e.beginPath(),e.arc(f.x,f.y,r,0,2*Math.PI),e.fill(),e.stroke();e.restore()}}class ih extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectParentGroupBound)}draw(e,n){const{node:o}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=1/n,e.globalAlpha=1;const{width:s,height:r}=o.baseProps,{a:i,b:a,c,d:h,e:d,f:u}=o.nameGlobalTransform();e.transform(i,a,c,h,d,u),e.beginPath(),e.strokeRect(0,0,s,r),e.restore()}}class ah extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverSlidePlaceHolder)}draw(e,n){const{baseProps:o}=this.prop;e.save(),e.fillStyle=Gr,e.lineWidth=2/n,e.globalAlpha=.5;const{x:s,y:r,width:i,height:a}=o;e.beginPath(),e.roundRect(s,r,i,a,10),e.fill(),e.restore()}}class ch extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverFocusCopy)}draw(e,n){const{nodes:o}=this.prop;e.save();for(const s of o)s.drawOnGLCtx(e);e.restore()}}class lh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverInsertSlide)}draw(e,n){const{x:o,y1:s,y0:r}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.moveTo(o,r),e.lineTo(o,s),e.stroke(),e.restore()}}class hh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverInsertHorizonSlide)}draw(e,n){const{x0:o,x1:s,y:r}=this.prop;e.save(),e.strokeStyle=Gt,e.lineWidth=2/n,e.globalAlpha=1,e.moveTo(o,r),e.lineTo(s,r),e.stroke(),e.restore()}}class dh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.HoverSlideGapInsertPoint)}draw(e,n){const{point:o}=this.prop,s=10/n;e.save(),e.fillStyle=Qe,e.globalAlpha=1,e.beginPath(),e.arc(o.x,o.y,s,0,2*Math.PI),e.fill();const r=6/n;e.strokeStyle=Ht,e.lineWidth=2.5/n,e.lineCap="square",e.beginPath(),e.moveTo(o.x-r,o.y),e.lineTo(o.x+r,o.y),e.moveTo(o.x,o.y-r),e.lineTo(o.x,o.y+r),e.stroke(),e.restore()}}class uh extends Me{constructor(){super(...arguments);p(this,"auxiliaryType",k.SelectSlideGapInsertPoint)}draw(e,n){const{points:o}=this.prop,s=6/n;e.save(),e.fillStyle=Qe,e.globalAlpha=.9,e.beginPath();for(const r of o){e.beginPath(),e.arc(r.x,r.y,s,0,2*Math.PI),e.fill();const i=3.6/n;e.strokeStyle=Ht,e.lineWidth=1.5/n,e.lineCap="square",e.beginPath(),e.moveTo(r.x-i,r.y),e.lineTo(r.x+i,r.y),e.moveTo(r.x,r.y-i),e.lineTo(r.x,r.y+i),e.stroke()}e.restore()}}class vs{static create(t){const e=this.constructorMap[t];return e?new e:(console.error("缺少对应构造函数"),null)}}p(vs,"constructorMap",{[k.HoverBounds]:$r,[k.SingleSelectBound]:jr,[k.MultiSelectBound]:Vr,[k.HighlightRects]:Kr,[k.SelectGroup]:Qr,[k.TextSelection]:Zr,[k.StretchRect]:Jr,[k.CreateRectBound]:ei,[k.ExpandShape]:ti,[k.AlignLine]:ni,[k.AlignStretchLine]:oi,[k.SelectLineEnd]:Yl,[k.HoverLine]:Gl,[k.SelectLine]:Ul,[k.HoverConnectPoint]:_l,[k.HoverConnectAnchorPoint]:$l,[k.HoverAnchorPoint]:jl,[k.SelectPolyLineControlPoint]:Vl,[k.SelectLineTextRect]:Kl,[k.PlaceHolder]:Ql,[k.SelectConnectAnchor]:Zl,[k.HoverConnectAnchor]:ql,[k.PreviewGraphics]:Jl,[k.HoverContainer]:eh,[k.CropBounds]:th,[k.CropOriginImg]:nh,[k.HoverSize]:oh,[k.SelectCurveControlPoint]:sh,[k.SelectCurveEnd]:rh,[k.SelectParentGroupBound]:ih,[k.HoverSlidePlaceHolder]:ah,[k.HoverFocusCopy]:ch,[k.HoverInsertSlide]:lh,[k.HoverInsertHorizonSlide]:hh,[k.HoverSlideGapInsertPoint]:dh,[k.SelectSlideGapInsertPoint]:uh});class ri{constructor(){p(this,"isWorking",!1);p(this,"idList",[]);p(this,"originX",0);p(this,"originY",0)}startWorking(t,e,n){this.idList=t,this.originX=e,this.originY=n,this.isWorking=!0}selectChange(t){if(!this.isWorking)return;t.size!==this.idList.length&&this.stopWork();const e=new Set(this.idList);for(const n of t)e.has(n.id)||this.stopWork(),e.delete(n.id);e.size!==0&&this.stopWork()}stopWork(){this.idList=[],this.isWorking=!1}}class bt{}const ph=new Set([v.Shape,v.SVG,v.IMG,v.Group,v.Section,v.Checkbox,v.CheckboxText]);class ii extends bt{enable(t){return t.length===1&&ph.has(t[0].type)}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:n.parent});const i=D.baseProps2Rect(n.baseProps);if(t.filter(c=>S.judgeNodeCanBeStretch(c)).length>0&&e.addOrUpdate(k.StretchRect,{transform:o,rect:new D(0,0,i.width,i.height)}),n.canQuickCreate()&&e.addOrUpdate(k.SelectConnectAnchor,{node:n}),n instanceof vt&&n.shapeType!==K.PureText){const h=n.drawer.fullTextNodeHeight(n);n.baseProps.height<h&&e.addOrUpdate(k.ExpandShape,{transform:o,rect:i})}}}class ai extends bt{enable(t){return t.length>1}handle(t,e){const n=[],o=[];t.forEach(i=>{const a=i.getBounds();n.push(a),o.push(D.rectNode2Rect(a))});const s=S.getBounds(n),r=D.rectNode2Rect(s);e.addOrUpdate(k.MultiSelectBound,{rect:r}),e.addOrUpdate(k.HighlightRects,{rects:o}),e.addOrUpdate(k.StretchRect,{rect:new D(0,0,r.width,r.height),transform:re.generateMatrix().translate(r.x,r.y)})}}var ze=(l=>(l[l.Scale=0]="Scale",l[l.Focus=1]="Focus",l[l.FocusPropsChange=2]="FocusPropsChange",l[l.ToolChange=3]="ToolChange",l[l.QuickCreate=4]="QuickCreate",l[l.ClickImg=5]="ClickImg",l[l.ImgUrls=6]="ImgUrls",l[l.ContextMenu=7]="ContextMenu",l[l.ExitCrop=8]="ExitCrop",l[l.DocMode=9]="DocMode",l[l.SlideCovers=10]="SlideCovers",l[l.SlideIndex=11]="SlideIndex",l))(ze||{});class ci{constructor(){p(this,"slotMap",new Map);p(this,"slotCallBack",new Map);p(this,"tickerRun",()=>{for(const[t,e]of this.slotMap){const n=this.slotCallBack.get(t);n&&n(e)}this.slotMap.clear(),requestAnimationFrame(this.tickerRun)})}start(){this.tickerRun()}addSlotState(t,e){this.slotMap.set(t,e)}registerSlotCallback(t,e){this.slotCallBack.set(t,e)}}class fh extends bt{enable(t){return t.length===1&&t[0].type===v.Line}handle(t,e){const n=t[0],o=n.points,s=n.globalTransform();e.addOrUpdate(k.SelectLineEnd,{start:o[0],end:o[o.length-1],transform:s})}}class gh extends bt{enable(t){if(t.length!==1)return!1;const e=t[0];return e.type!==v.Line?!1:!!e.isPolyLine()}handle(t,e){const n=t[0],o=n.points,s=n.globalTransform();e.addOrUpdate(k.SelectLineEnd,{start:o[0],end:o[o.length-1],transform:s}),e.addOrUpdate(k.SelectPolyLineControlPoint,{points:n.points,transform:s})}}class yh extends bt{enable(t,e){if(t.length!==1)return!1;const n=t[0];if(n.type!==v.Line)return!1;const o=e.inputManager.editTextInfo;if(!o)return!1;const s=n;return o.node.id===s.id}handle(t,e){const n=t[0];e.addOrUpdate(k.SelectLineTextRect,{node:n,transform:n.globalTransform()})}}class xh extends bt{enable(t){return t.length===1&&t[0].type===v.Group}handle(t,e){const n=t[0],o=n.nameGlobalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:n.parent});const i=D.baseProps2Rect(n.baseProps);e.addOrUpdate(k.StretchRect,{transform:o,rect:new D(0,0,i.width,i.height)})}}const wh=new Set([v.SVG,v.IMG]);class Ph extends bt{enable(t,e){if(t.length!==1)return!1;const n=t[0];return!(!wh.has(n.type)||!e.cropManager.duringCrop||!n.imgBitmap)}handle(t,e){const n=t[0],o=n.globalTransform().clone();e.addOrUpdate(k.CropBounds,{node:n,transform:o});const{cropType:s,cropInfo:r}=n.cropProps,{x:i,y:a,width:c,height:h}=n.baseProps;if(s===0||!r){e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:c,height:h,transform:o});const d=new D(0,0,c,h);e.addOrUpdate(k.StretchRect,{transform:o,rect:d})}else{const d=n.getOriginImageRect();e.addOrUpdate(k.SingleSelectBound,{x:d.x,y:d.y,width:d.width,height:d.height,transform:o}),e.addOrUpdate(k.StretchRect,{transform:o,rect:d}),e.addOrUpdate(k.CropOriginImg,{x:d.x,y:d.y,width:d.width,height:d.height,transform:o,imgBitmap:n.imgBitmap})}}}class mh extends bt{enable(t){return t.length===1&&t[0].type===v.Line&&t[0].shapeType===he.Curve}handle(t,e){const n=t[0],o=n.globalTransform();e.addOrUpdate(k.SelectCurveEnd,{points:S.computeCurveEndPoints(n),transform:o}),e.addOrUpdate(k.SelectCurveControlPoint,{points:S.computeCurveControlPoints(n),transform:o})}}const bh=new Set([v.Shape,v.SVG,v.IMG,v.Group,v.Section,v.Checkbox,v.CheckboxText]);class Sh extends bt{enable(t,e){return!e.docState.userPermission.canEdit&&t.length===1}handle(t,e){const n=t[0];if(n.type===v.Group){this.handleGroup(n,e);return}if(n instanceof Ct){this.handleLine(n,e);return}if(bh.has(n.type)){this.handleNormalNode(n,e);return}}handleNormalNode(t,e){const n=t.globalTransform().clone(),{width:o,height:s}=t.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:o,height:s,transform:n}),t.parent&&t.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:t.parent})}handleLine(t,e){e.addOrUpdate(k.SelectLine,{node:t})}handleGroup(t,e){const n=t.nameGlobalTransform().clone(),{width:o,height:s}=t.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:o,height:s,transform:n}),t.parent&&t.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:t.parent})}}class Mh extends bt{enable(t,e){return!e.docState.userPermission.canEdit&&t.length>1}handle(t,e){const n=[],o=[];t.forEach(i=>{const a=i.getBounds();n.push(a),o.push(D.rectNode2Rect(a))});const s=S.getBounds(n),r=D.rectNode2Rect(s);e.addOrUpdate(k.MultiSelectBound,{rect:r}),e.addOrUpdate(k.HighlightRects,{rects:o})}}class vh extends bt{enable(t){return t.length===1&&t[0].type===v.SlideContainer}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{width:s,height:r}=n.baseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:s,height:r,transform:o}),n.parent&&n.parent.type===v.Group&&e.addOrUpdate(k.SelectParentGroupBound,{node:n.parent})}}const Ih=5,nt=50,xt=40;class Th extends bt{enable(t){var e;return t.length===1&&((e=t[0].parent)==null?void 0:e.type)===v.SlideContainer}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{x:s,y:r,height:i,width:a}=n.globalBaseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:a,height:i,transform:o});const c=[{x:s-nt/2,y:r+i/2},{x:s+a+nt/2,y:r+i/2}];e.addOrUpdate(k.SelectSlideGapInsertPoint,{points:c})}}var ue=(l=>(l[l.BOARD=0]="BOARD",l[l.SLIDE_EDIT=1]="SLIDE_EDIT",l[l.SLIDE_PLAY=2]="SLIDE_PLAY",l))(ue||{});class Lh extends bt{enable(t,e){var n;return t.length===1&&((n=t[0].parent)==null?void 0:n.type)===v.SlideContainer&&e.docState.docMode===ue.SLIDE_EDIT}handle(t,e){const n=t[0],o=n.globalTransform().clone(),{x:s,y:r,height:i,width:a}=n.globalBaseProps;e.addOrUpdate(k.SingleSelectBound,{x:0,y:0,width:a,height:i,transform:o})}}class li{constructor(t,e,n,o){p(this,"selectNodes",new Set);p(this,"optionHelper");p(this,"auxiliaryManager");p(this,"inputManager");p(this,"cropManager");p(this,"docState");p(this,"statusHandlers",[new Sh,new Mh,new vh,new xh,new yh,new gh,new mh,new fh,new Ph,new Lh,new Th,new ii,new ai]);this.auxiliaryManager=e,this.optionHelper=new ri,this.cropManager=n,this.docState=o}register(t){this.inputManager=t}refreshSelectStatus(){this.auxiliaryManager.removeSelectGraphics();const t=[...this.selectNodes],e=this.selectStatusContext();for(const n of this.statusHandlers)if(n.enable(t,e)){n.handle(t,this.auxiliaryManager);return}}selectStatusContext(){return{inputManager:this.inputManager,cropManager:this.cropManager,docState:this.docState}}getSelectNodes(){return[...this.selectNodes]}getSelectBounds(){const t=[];for(const e of this.selectNodes)t.push(e.getBounds());return S.getBounds(t,"selectBounds")}set(t){this.selectNodes=t,this.optionHelper.selectChange(t),this.auxiliaryManager.slotManager.addSlotState(ze.Focus,[...t]),this.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0),this.refreshSelectStatus()}startOptWorking(t,e,n){this.optionHelper.startWorking(t,e,n)}include(t){return this.selectNodes.has(t)}}class hi{constructor(t,e,n,o){p(this,"gmlRender");p(this,"selectManager");p(this,"graphicMap");p(this,"slotManager");this.gmlRender=t,this.slotManager=e,this.selectManager=new li(t,this,n,o),this.graphicMap=new Map}start(){}addOrUpdate(t,e){const n=this.graphicMap.get(t);if(n){n.update(e);return}const o=vs.create(t);o&&(this.graphicMap.set(t,o),o.update(e))}remove(t){this.graphicMap.delete(t)}redraw(){const t=this.gmlRender.getViewPortBounds();this.gmlRender.glCtx.clearRect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY);const e=this.gmlRender.getScale(),n=[...this.graphicMap.values()];n.sort((o,s)=>o.auxiliaryType-s.auxiliaryType);for(const o of n)o.draw(this.gmlRender.glCtx,e)}removeHoverGraphics(){this.remove(k.HoverBounds),this.remove(k.HoverLine),this.remove(k.HoverConnectPoint),this.remove(k.HoverConnectAnchorPoint),this.remove(k.HoverAnchorPoint),this.remove(k.HoverConnectAnchor),this.remove(k.PreviewGraphics),this.remove(k.HoverContainer),this.remove(k.HoverSize),this.remove(k.HoverSlidePlaceHolder),this.remove(k.HoverFocusCopy),this.remove(k.HoverInsertSlide),this.remove(k.HoverInsertHorizonSlide),this.remove(k.HoverSlideGapInsertPoint),this.removeAlignGraphics()}removeSelectGraphics(){this.remove(k.SingleSelectBound),this.remove(k.MultiSelectBound),this.remove(k.HighlightRects),this.remove(k.TextSelection),this.remove(k.StretchRect),this.remove(k.ExpandShape),this.remove(k.SelectLineEnd),this.remove(k.SelectLine),this.remove(k.SelectPolyLineControlPoint),this.remove(k.SelectCurveControlPoint),this.remove(k.SelectCurveEnd),this.remove(k.SelectLineTextRect),this.remove(k.SelectConnectAnchor),this.remove(k.CropBounds),this.remove(k.CropOriginImg),this.remove(k.SelectParentGroupBound),this.remove(k.SelectSlideGapInsertPoint)}removeAlignGraphics(){this.remove(k.AlignLine),this.remove(k.AlignStretchLine)}}class Ch{}class Wn extends ct{constructor(){super(...arguments);p(this,"type",I.Svg);p(this,"useCode",!1);p(this,"url","");p(this,"code","")}static from(e){const n=new Wn;return n.url=e.url,n.code=e.code,n.useCode=e.useCode,n}clone(){const e=new Wn;return e.url=this.url,e.code=this.code,e.useCode=this.useCode,e}update(e){const{url:n,code:o,useCode:s}=e;n!==void 0&&(this.url=n),o!==void 0&&(this.code=o),s!==void 0&&(this.useCode=s)}}var wt=(l=>(l[l.None=0]="None",l[l.Rect=1]="Rect",l[l.RoundRect=2]="RoundRect",l[l.Circle=3]="Circle",l))(wt||{});class Mn extends ct{constructor(){super(...arguments);p(this,"type",I.Crop);p(this,"cropType",wt.None);p(this,"cropInfo")}static from(e){const n=new Mn;return n.cropType=e.cropType||wt.None,n.cropInfo=e.cropInfo,n}clone(){const e=new Mn;return e.cropType=this.cropType,this.cropInfo&&(e.cropInfo={imgX:this.cropInfo.imgX,imgY:this.cropInfo.imgY,imgWidth:this.cropInfo.imgWidth,imgHeight:this.cropInfo.imgHeight}),e}update(e){const{cropInfo:n,cropType:o}=e;n!==void 0&&(this.cropInfo=n),o!==void 0&&(this.cropType=o)}}class Qt extends ct{constructor(){super(...arguments);p(this,"type",I.CheckStatus);p(this,"checkStatus",!1)}static create(e){const n=new Qt;return n.update(e),n}static from(e){const n=new Qt;return n.checkStatus=e.checkStatus,n}clone(){const e=new Qt;return e.checkStatus=this.checkStatus,e}update(e){const{checkStatus:n}=e;n!==void 0&&(this.checkStatus=n)}}class vn extends ct{constructor(){super(...arguments);p(this,"type",I.CheckSize);p(this,"size",16)}static create(e){const n=new vn;return n.update(e),n}static from(e){const n=new vn;return n.size=e.size,n}clone(){const e=new vn;return e.size=this.size,e}update(e){const{size:n}=e;n!==void 0&&(this.size=n)}}var Pe=(l=>(l[l.Decision=0]="Decision",l[l.Step=1]="Step",l[l.Data=2]="Data",l[l.Status=3]="Status",l[l.Operation=4]="Operation",l[l.Others=5]="Others",l[l.Section=6]="Section",l[l.Resource=7]="Resource",l[l.Line=8]="Line",l[l.Check=9]="Check",l))(Pe||{}),K=(l=>(l[l.PureText=0]="PureText",l[l.Rect=1]="Rect",l[l.Ellipse=2]="Ellipse",l[l.Octagon=3]="Octagon",l[l.DoubleArrow=4]="DoubleArrow",l[l.LeftArrow=5]="LeftArrow",l[l.LeftKuohao=6]="LeftKuohao",l[l.Diamond=7]="Diamond",l[l.Hexagon=8]="Hexagon",l[l.LiuCheng=9]="LiuCheng",l[l.LiuCheng2=10]="LiuCheng2",l[l.Parallelogram=11]="Parallelogram",l[l.Qipao=12]="Qipao",l[l.Qipao2=13]="Qipao2",l[l.RightArrow=14]="RightArrow",l[l.RightKuohao=15]="RightKuohao",l[l.RoundRect=16]="RoundRect",l[l.RoundRect2=17]="RoundRect2",l[l.Cross=18]="Cross",l[l.Trapezoid=19]="Trapezoid",l[l.Triangle=20]="Triangle",l[l.Triangle2=21]="Triangle2",l[l.Pentagon=22]="Pentagon",l[l.Star=23]="Star",l[l.YuanZhu=24]="YuanZhu",l[l.Cloud=25]="Cloud",l))(K||{});const Is={[K.PureText]:Pe.Operation,[K.Rect]:Pe.Operation,[K.RoundRect]:Pe.Step,[K.Triangle]:Pe.Operation,[K.Diamond]:Pe.Decision,[K.Ellipse]:Pe.Status,[K.Parallelogram]:Pe.Operation,[K.Trapezoid]:Pe.Step,[K.Cross]:Pe.Operation,[K.Pentagon]:Pe.Operation,[K.Hexagon]:Pe.Decision,[K.Octagon]:Pe.Operation,[K.Star]:Pe.Decision};var Zt=(l=>(l[l.TOP_RIGHT=0]="TOP_RIGHT",l[l.TOP_LEFT=1]="TOP_LEFT",l[l.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",l[l.BOTTOM_LEFT=3]="BOTTOM_LEFT",l))(Zt||{});class qt extends ct{constructor(){super(...arguments);p(this,"type",I.TextParagraph);p(this,"paragraphStyles",[])}static create(e){const n=new qt;return n.update(e),n}static from(e){const n=new qt;return n.paragraphStyles=e.paragraphStyles,n}clone(){const e=new qt;return e.paragraphStyles=JSON.parse(JSON.stringify(this.paragraphStyles)),e}update(e){const{paragraphStyles:n}=e;n!==void 0&&(this.paragraphStyles=n)}}class Dt extends ct{constructor(){super(...arguments);p(this,"paraQuoteStyles",[]);p(this,"type",I.TextParagraphQuote)}static create(e){const n=new Dt;return n.update(e),n}static from(e){const n=new Dt;return n.paraQuoteStyles=e.paraQuoteStyles,n}clone(){const e=new Dt;return e.paraQuoteStyles=JSON.parse(JSON.stringify(this.paraQuoteStyles)),e}update(e){const{paraQuoteStyles:n}=e;n!==void 0&&(this.paraQuoteStyles=n)}}var he=(l=>(l[l.Line=0]="Line",l[l.PolyLine=1]="PolyLine",l[l.RoundPolyLine=2]="RoundPolyLine",l[l.Curve=3]="Curve",l))(he||{});class di{constructor(t,e,n,o){p(this,"p0");p(this,"p1");p(this,"p2");p(this,"p3");this.p0=t,this.p1=e,this.p2=n,this.p3=o}getPos(t){if(t<0||t>1)throw new Error(`非法的t值:${t}`);const e=1-t,n=e*e*e*this.p0.x+3*t*e*e*this.p1.x+3*t*t*e*this.p2.x+t*t*t*this.p3.x,o=e*e*e*this.p0.y+3*t*e*e*this.p1.y+3*t*t*e*this.p2.y+t*t*t*this.p3.y;return new P(n,o)}getHalfTPos(){return this.getPos(.5)}getDerivative(t){const e=1-t,n=3*e*e*(this.p1.x-this.p0.x)+6*e*t*(this.p2.x-this.p1.x)+3*t*t*(this.p3.x-this.p2.x),o=3*e*e*(this.p1.y-this.p0.y)+6*e*t*(this.p2.y-this.p1.y)+3*t*t*(this.p3.y-this.p2.y);return new P(n,o)}getDistanceSquared(t,e){const n=this.getPos(e),o=n.x-t.x,s=n.y-t.y;return o*o+s*s}getTValueByPoint(t,e=1,n=50){let o=0,s=1/0;const r=20;for(let a=0;a<=r;a++){const c=a/r,h=this.getDistanceSquared(t,c);h<s&&(s=h,o=c)}if(Math.sqrt(s)<e)return o;let i=o;for(let a=0;a<n;a++){const c=this.getPos(i),h=this.getDerivative(i),d=c.x-t.x,u=c.y-t.y,f=d*h.x+u*h.y;if(Math.abs(f)<e)return Math.max(0,Math.min(1,i));const g=1-i,y=6*g*(this.p2.x-2*this.p1.x+this.p0.x)+6*i*(this.p3.x-2*this.p2.x+this.p1.x),m=6*g*(this.p2.y-2*this.p1.y+this.p0.y)+6*i*(this.p3.y-2*this.p2.y+this.p1.y),b=h.x*h.x+h.y*h.y+d*y+u*m;if(Math.abs(b)<1e-10)break;const w=i-f/b;if(i=Math.max(0,Math.min(1,w)),Math.abs(w-i)<e&&i===w)break}return i}getApproximateLength(t=10){let e=0,n=this.getPos(0);for(let o=1;o<=t;o++){const s=o/t,r=this.getPos(s),i=r.x-n.x,a=r.y-n.y;e+=Math.sqrt(i*i+a*a),n=r}return e}getTValueByDistance(t,e=20){if(t<=0)return 0;let n=0,o=this.getPos(0);for(let s=1;s<=e;s++){const r=s/e,i=this.getPos(r),a=i.x-o.x,c=i.y-o.y,h=Math.sqrt(a*a+c*c);if(n+h>=t){const u=(t-n)/h,f=(s-1)/e;return f+u*(r-f)}n+=h,o=i}return 1}}var Jt=(l=>(l.Windows="Windows",l.MacOS="MacOS",l.Linux="Linux",l.Android="Android",l.IOS="ios",l.Unknown="unknown",l))(Jt||{});class ui{static getOS(){const t=navigator.userAgent;return t.includes("Win")?Jt.Windows:t.includes("Mac")?Jt.MacOS:t.includes("Linux")?Jt.Linux:/Android/.test(t)?Jt.Android:/iPhone|iPad|iPod/.test(t)?Jt.IOS:Jt.Unknown}}class St extends ct{constructor(){super(...arguments);p(this,"type",I.Slide);p(this,"children",[])}static create(e){const n=new St;return n.update(e),n}static from(e){const n=new St;return n.children=e.children,n}clone(){const e=new St;return e.children=this.children,e}update(e){const{children:n}=e;n!==void 0&&(this.children=n)}}class S{static computeShapeCategory(t,e=0){return t===v.Shape?Is[e]??Pe.Others:t===v.CheckboxText||t===v.Checkbox?Pe.Check:t===v.Line?Pe.Line:t===v.Section?Pe.Section:t===v.SVG?Pe.Resource:Pe.Others}static makeSortGraphic(t){const e=[t];let n=t.parent;for(;n&&n.id!==Sn;)e.unshift(n),n=n.parent;return{graphics:e}}static sortGraphics(t){const e=t.map(this.makeSortGraphic);return e.sort((n,o)=>{const s=Math.min(n.graphics.length,o.graphics.length);for(let r=0;r<s;r++){const i=n.graphics[r],a=o.graphics[r];if(i!==a)return i.zIndex>a.zIndex?1:-1}return n.graphics.length-o.graphics.length}),e.map(n=>n.graphics[n.graphics.length-1])}static setDashLine(t,e){t.dashType===et.Dash1?e.setLineDash([4,2]):t.dashType===et.Dash2&&e.setLineDash([2,2])}static convertPropsToCapInfo(t){const e={},n=t.get(I.Base);n&&(e.baseProps=n);const o=t.get(I.Color);o&&(e.colorProps=o);const s=t.get(I.Border);s&&(e.borderProps=s);const r=t.get(I.Text);r&&(e.textProps=r);const i=t.get(I.Shape);i&&(e.shapeProps=i);const a=t.get(I.Line);a&&(e.lineProps=a);const c=t.get(I.Connect);c&&(e.connectProps=c);const h=t.get(I.Arrow);h&&(e.arrowProps=h);const d=t.get(I.LineTextRect);d&&(e.lineTextRectProps=d);const u=t.get(I.Svg);u&&(e.svgProps=u);const f=t.get(I.Image);f&&(e.imageProps=f);const g=t.get(I.Crop);g&&(e.cropProps=g);const y=t.get(I.CheckStatus);y&&(e.checkStatusProps=y);const m=t.get(I.CheckSize);y&&(e.checkSizeProps=m);const b=t.get(I.TextParagraph);b&&(e.textParagraphProps=b);const w=t.get(I.TextParagraphQuote);w&&(e.textParagraphQuoteProps=w);const L=t.get(I.Slide);return L&&(e.slideProps=L),e}static convertCapInfoToProps(t){const e=[],{baseProps:n,borderProps:o,shapeProps:s,colorProps:r,textProps:i,lineProps:a,connectProps:c,arrowProps:h,lineTextRectProps:d,svgProps:u,imageProps:f,cropProps:g,checkStatusProps:y,checkSizeProps:m,textParagraphProps:b,textParagraphQuoteProps:w,slideProps:L}=t;return o&&e.push(Ae.from(o)),r&&e.push(tt.from(r)),i&&e.push(Ge.from(i)),n&&e.push(ie.from(n)),s&&e.push(Oe.from(s)),a&&e.push(je.from(a)),c&&e.push(Rt.from(c)),h&&e.push(lt.from(h)),d&&e.push(Et.from(d)),u&&e.push(Wn.from(u)),f&&e.push(oo.from(f)),g&&e.push(Mn.from(g)),y&&e.push(Qt.from(y)),m&&e.push(vn.from(m)),b&&e.push(qt.from(b)),w&&e.push(Dt.from(w)),L&&e.push(St.from(L)),e}static centerPoint(t){const e=t.baseProps;return new P(e.x+.5*e.width,e.y+.5*e.height)}static topPoint(t){const e=t.baseProps;return new P(e.x+.5*e.width,e.y)}static rightPoint(t){const e=t.baseProps;return new P(e.x+e.width,e.y+.5*e.height)}static bottomPoint(t){const e=t.baseProps;return new P(e.x+.5*e.width,e.y+e.height)}static leftPoint(t){const e=t.baseProps;return new P(e.x,e.y+.5*e.height)}static topLeft(t){const e=t.baseProps;return new P(e.x,e.y)}static topRight(t){const e=t.baseProps;return new P(e.x+e.width,e.x+e.width)}static bottomLeft(t){const e=t.baseProps;return new P(e.x,e.y+e.height)}static bottomRight(t){const e=t.baseProps;return new P(e.x+e.width,e.y+e.height)}static middleInsertPoint(t,e,n){const o=new P(t.x,e.y);n.push(t,o,e)}static doubleMiddleInsertPoint(t,e,n){const o=new P(.5*(t.x+e.x),t.y),s=new P(.5*(t.x+e.x),e.y);n.push(t,o,s,e)}static rectContains(t,e){return t.x>e.x&&t.x<e.x+e.width&&t.y>e.y&&t.y<e.y+e.height}static rectContains2(t,e){return t.x>=e.minX&&t.x<=e.maxX&&t.y>=e.minY&&t.y<=e.maxY}static circleContains(t,e,n=2){return(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)<n*n}static overlapRect(t,e){return!(t.maxX<e.minX||t.minX>e.maxX||t.maxY<e.minY||t.minY>e.maxY)}static containRect(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&t.maxX>=e.maxX&&t.maxY>=e.maxY}static distance(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}static lineAngle(t,e){if(Math.abs(t.x-e.x)<.001)return e.y>t.y?Math.PI*.5:-Math.PI*.5;const n=(e.y-t.y)/(e.x-t.x);let o=Math.atan(n);return e.x<t.x&&(o+=Math.PI),o}static basicGetArrowPoint(t,e,n,o){const s=S.lineAngle(t,e),r=re.generateMatrix().translate(t.x,t.y).rotate2(s),i=r.crossPoint(n),a=r.crossPoint(o);return{a:i,b:a}}static getLArrowPoint(t,e,n=5){const o=new P(Math.sqrt(3)*.5*n,.5*n),s=new P(Math.sqrt(3)*.5*n,-.5*n);return S.basicGetArrowPoint(t,e,o,s)}static getRArrowPoint(t,e,n=5){const o=S.distance(t,e),s=new P(o-Math.sqrt(3)*.5*n,.5*n),r=new P(o-Math.sqrt(3)*.5*n,-.5*n);return S.basicGetArrowPoint(t,e,s,r)}static getNodeBounds(t){const e=[];t.forEach(o=>e.push(o.getBounds()));const n=this.getBounds(e);return D.rectNode2Rect(n)}static cloneIRectNode(t){return{minX:t.minX,maxX:t.maxX,minY:t.minY,maxY:t.maxY}}static cloneIPoint(t){return{x:t.x,y:t.y}}static getBoundsByBaseProps(t){const{x:e,y:n,width:o,height:s,angle:r}=t,i=re.generateMatrix().rotate(r),a=re.generateMatrix().translate(e,n),c=[new P(0,0),new P(0,s),new P(o,0),new P(o,s)],h=a.crossProduct(i),d=c.map(u=>h.crossPoint(u));return this.getBoundsByPoints(d)}static getBoundsByBasePropsList(t){const e=[];for(const n of t){const{x:o,y:s,width:r,height:i}=n,a=n.angle??0,c=re.generateMatrix().rotate(a),d=re.generateMatrix().translate(o,s).crossProduct(c),f=[new P(0,0),new P(0,i),new P(r,0),new P(r,i)].map(g=>d.crossPoint(g));e.push(...f)}return this.getBoundsByPoints(e)}static getBounds(t,e="getBounds"){const n=[],o=[];for(const s of t)n.push(s.maxX,s.minX),o.push(s.maxY,s.minY);return{id:e,minX:Math.min(...n),maxX:Math.max(...n),minY:Math.min(...o),maxY:Math.max(...o)}}static getBoundsByPoints(t){const e=[],n=[];for(const o of t)e.push(o.x),n.push(o.y);return{id:"getBounds",minX:Math.min(...e),maxX:Math.max(...e),minY:Math.min(...n),maxY:Math.max(...n)}}static calcFont(t,e,n=!1,o=!1){let s=`${t.toString()}px ${e}`;return n?s=`700 ${s}`:s=`400 ${s}`,o&&(s=`italic ${s}`),s}static calcFontByTextProps(t){const{fontSize:e,fontFamily:n,bold:o,italic:s}=t;return this.calcFont(e,n,o,s)}static measureText(t,e){const n=t.measureText(e),o=n.width,s=n.fontBoundingBoxDescent+n.fontBoundingBoxAscent,r=n.fontBoundingBoxAscent;return{width:o,height:s,boxAscent:r}}static measureTextByFont(t,e,n,o,s,r){t.save(),t.font=this.calcFont(n,o,s,r);const i=t.measureText(e);t.restore();const a=i.width,c=i.fontBoundingBoxDescent+i.fontBoundingBoxAscent,h=i.fontBoundingBoxAscent;return{width:a,height:c,boxAscent:h}}static judgeHorizon(t,e,n=.01){return Math.abs(t.y-e.y)<n}static judgeVertical(t,e,n=.01){return Math.abs(t.x-e.x)<n}static computePolyLinePoints(t,e){const n=[],o=new P(e.x-t.x,e.y-t.y);if(Math.abs(o.x)<.001||Math.abs(o.y)<.001)n.push(t,e);else if(Math.abs(o.x)>Math.abs(o.y)){const s=new P(t.x+.5*o.x,t.y),r=new P(e.x-.5*o.x,e.y);n.push(t,s,r,e)}else{const s=new P(t.x,t.y+.5*o.y),r=new P(e.x,e.y-.5*o.y);n.push(t,s,r,e)}return n}static normalizeAngle(t){let e=t%360;return e<0&&(e+=360),e}static computeOriginNodeConnectEnd(t){const{x:e,y:n}=t,o=Math.atan2(n-.5,e-.5)/Math.PI*180,s=this.normalizeAngle(o);if(s<45||s>315)return de.Right;if(Math.abs(s-90)<45)return de.Bottom;if(Math.abs(s-180)<45)return de.Left;if(Math.abs(s-270)<45)return de.Top;throw new Error("没有正确的end type")}static computeNodeConnectEnd(t,e){const{x:n,y:o}=t,s=Math.atan2(o-.5,n-.5)/Math.PI*180+e,r=this.normalizeAngle(s);if(r<45||r>315)return de.Right;if(Math.abs(r-90)<45)return de.Bottom;if(Math.abs(r-180)<45)return de.Left;if(Math.abs(r-270)<45)return de.Top;throw new Error("没有正确的end type")}static inDistance(t,e,n){return Math.abs(t-e-.5*n)<.5*n}static dealWithEndPolyPointsInUp(t,e,n){if(t.length<4)return t;const o=t.length;if(n){const a=t[o-1],c=t[o-2],h=t[o-3];return S.distance(c,h)<3/e&&(S.judgeHorizon(a,c)?a.y=h.y:a.x=h.x,t.splice(o-3,2)),t}const s=t[0],r=t[1],i=t[2];return S.distance(i,r)<3/e&&(S.judgeHorizon(s,r)?s.y=i.y:s.x=i.x,t.splice(1,2)),t}static dealWithEndPolyPoints(t,e,n){if(t.length<4)return t;const o=t.length;if(n){const a=t[o-1],c=t[o-2],h=t[o-3];return S.distance(c,h)<3/e&&(S.judgeHorizon(a,c)?(c.y=h.y,a.y=h.y):(c.x=h.x,a.x=h.x)),t}const s=t[0],r=t[1],i=t[2];return S.distance(i,r)<3/e&&(S.judgeHorizon(s,r)?(r.y=i.y,s.y=i.y):(r.x=i.x,s.x=i.x)),t}static dealWithPolyPoints(t,e){if(t.length===0)return[];const n=[t[0]];for(let o=1;o<t.length-1;o++){const s=t[o],r=t[o+1];if(S.distance(s,r)<3/e){const i=t[o+2],a=t[o-1];S.judgeHorizon(a,s)?a.y=i.y:a.x=i.x,o=o+1}else n.push(s)}return n.push(t[t.length-1]),n}static computePointByT(t,e){const n=t.points;if(t.isPolyLine()){let a=0;for(let h=0;h<n.length-1;h++){const d=n[h],u=n[h+1],f=S.distance(d,u);a+=f}const c=e*a;a=0;for(let h=0;h<n.length-1;h++){const d=n[h],u=n[h+1],f=S.distance(d,u);if(c>a&&c<=a+f)if(S.judgeHorizon(d,u)){const y=u.x>d.x?1:-1;return new P(d.x+(c-a)*y,d.y)}else{const y=u.y>d.y?1:-1;return new P(d.x,d.y+(c-a)*y)}a+=f}}else if(t.shapeType===he.Curve){const a=S.computeBezierCurves(t);let c=0;const h=[];for(const u of a){const f=u.getApproximateLength();c+=f,h.push(f)}c=e*c;for(let u=0;u<a.length;u++){const f=a[u],g=h[u];if(c>g){c-=g;continue}const y=f.getTValueByDistance(c);return f.getPos(y)}}const o=n[0],s=n[n.length-1],r=o.x+(s.x-o.x)*e,i=o.y+(s.y-o.y)*e;return new P(r,i)}static computeNodeConnectAnchor(t,e){const{width:n,height:o}=t.baseProps,s=Fr/e;return[{x:.5*n,y:-s},{x:n+s,y:.5*o},{x:.5*n,y:o+s},{x:-s,y:.5*o}]}static computeSelectNode(t,e){const n=new Set(t.getSelectNodes());let o=e.parent;for(;o;)n.has(o)&&n.delete(o),o=o.parent;return this.filterChildInSet(n,e),n.add(e),n}static filterChildInSet(t,e){const n=e.children;if(n.size!==0)for(const o of n)t.has(o)&&t.delete(o),this.filterChildInSet(t,o)}static computeSelectNodes(t){const e=new Set(t);for(const n of t)this.filterChildInSet(e,n);return[...e]}static filterToGroupNodes(t){const e=[];for(const n of t)if(n.type!==v.Section){if(n.type===v.Line){const o=n,{start:s,end:r}=o.connectProps;if(s&&r){const i=t.find(c=>c.id===s.objectId),a=t.find(c=>c.id===r.objectId);i&&a&&e.push(n);continue}if(s&&!r){t.find(a=>a.id===s.objectId)&&e.push(n);continue}if(r&&!s){t.find(a=>a.id===r.objectId)&&e.push(n);continue}e.push(n);continue}e.push(n)}return e}static detectRectBounds(t,e,n){const{x:o,y:s,width:r,height:i}=t;return S.circleContains(new P(o,s),e,n)?{type:V.TOP_LEFT}:S.circleContains(new P(o+r,s),e,n)?{type:V.TOP_RIGHT}:S.circleContains(new P(o+r,s+i),e,n)?{type:V.BOTTOM_RIGHT}:S.circleContains(new P(o,s+i),e,n)?{type:V.BOTTOM_LEFT}:S.rectContains(e,new D(o,s-.5*n,r,n))?{type:V.TOP}:S.rectContains(e,new D(o+r-.5*n,s,n,i))?{type:V.RIGHT}:S.rectContains(e,new D(o,s+i-.5*n,r,n))?{type:V.BOTTOM}:S.rectContains(e,new D(o-.5*n,s,n,i))?{type:V.LEFT}:null}static computeShiftPoint(t,e){if(S.distance(t,e)<.1)return new P(e.x,t.y);let n=Math.atan2(e.y-t.y,e.x-t.x)*180/Math.PI;return n=(n+360)%360,n<45||n>=315?new P(e.x,t.y):n>45&&n<=135?new P(t.x,e.y):n>135&&n<225?new P(e.x,t.y):new P(t.x,e.y)}static dealWithShiftLineInteractEvent(t,e,n=!0){if(!t.originEvent.shiftKey)return t;const o=e.globalLinePoints,s=n?o[0]:o[o.length-1],r=S.computeShiftPoint(s,t.globalPoint);return{clientPoint:t.clientPoint,globalPoint:r,type:t.type,originEvent:t.originEvent}}static getMockEventModifierInit(t){return{shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,ctrlKey:t.ctrlKey}}static judgeParentInset(t,e){let n=t;for(;n;){if(e.has(n))return!0;n=n.parent}return!1}static judgeSlideSectionChildren(t,e){let n=t;for(;n!=null&&n.parent;){if(n.parent.id===e.id)return n;n=n.parent}return null}static filterContainerFromNodes(t){const e=t.filter(o=>o.type===v.Section);return new Set(e)}static judgeEndNode(t,e,n,o,s){if(!n)return;const r=o.nodeManager.getNode(n.objectId);r&&!S.judgeParentInset(r,s)&&e.add(t)}static getViewportBoundCenter(t){const e=t.renderManager.gmlRender.getViewPortBounds();return new P(.5*(e.minX+e.maxX),.5*(e.minY+e.maxY))}static computeRotateAngle(t,e){let n=0;return t.length===1&&(n=n+t[0].baseProps.angle),n=n+e,Math.round(n)}static computeRotateDeltaAngle(t){let e=0;switch(t){case Zt.BOTTOM_LEFT:e=90;break;case Zt.BOTTOM_RIGHT:e=0;break;case Zt.TOP_LEFT:e=180;break;case Zt.TOP_RIGHT:e=-90;break}return e}static computeRelationChangeUpdateNodeInfo(t,e,n,o){if(t.type===v.Line){const i=t.globalLinePoints.map(c=>e.toLocal(c)),a=D.rectNode2Rect(S.getBoundsByPoints(i));return{id:t.id,props:[{type:I.Line,points:i},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})],zIndex:n,parentId:o}}const s=e.toLocal(t.globalPos);return{id:t.id,zIndex:n,parentId:o,props:[{type:I.Base,x:s.x,y:s.y}]}}static computeStretchAngle(t,e){let n=0;return t.length===1&&(n=n+t[0].baseProps.angle),e===V.TOP_RIGHT||e===V.BOTTOM_LEFT?n=n-45:e===V.TOP_LEFT||e===V.BOTTOM_RIGHT?n=n+45:(e===V.TOP||e===V.BOTTOM)&&(n=n+90),Math.round(n)}static correctZIndex(t){if(t.length===0)return t;const e=new Map;if(t.forEach((s,r)=>{const i=s.zIndex;e.has(i)||e.set(i,[]),e.get(i).push(r)}),!Array.from(e.values()).some(s=>s.length>1))return t;const o=t.map(s=>({...s}));return e.forEach((s,r)=>{if(s.length>1){const i=s[0];let a=.1,c=0;i===0?(c=r-1,a=(r-c)/(s.length+1)):(c=o[i-1].zIndex<r?o[i-1].zIndex:r-1,a=(r-c)/(s.length+1)),s.forEach((h,d)=>{o[h].zIndex=(d+1)*a+c})}}),o}static judgeLineBreak(t,e,n,o){let s=-1;for(const r of t){const i=e.characters.slice(0,r);let a=0;if(i.forEach(c=>{a+=c.width}),n.width+a<o)s=r;else return s>0?s:-1}return s>-1?s:-1}static getParaStyle(t,e){const n=t.paragraphStyles;for(const o of n)if(o.paraIndex===e)return o;return null}static computeNotUnOrderParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.orderIndex===-1&&o.delete(s.paraIndex);return o}static computeNotOrderParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.orderIndex>-1&&o.delete(s.paraIndex);return o}static computeNotNormalParas(t){const n=t.paragraphProps.paragraphStyles,o=new Set;for(const s of n)o.add(s.paraIndex);return o}static computeNotQuoteParas(t){const n=t.paragraphQuoteProps.paraQuoteStyles,o=new Set;for(let s=0;s<t.paragraphs.length;s++)o.add(s);for(const s of n)s.quote&&o.delete(s.paraIndex);return o}static drawControlPoints(t,e){t.save(),t.beginPath(),t.strokeStyle="#cc2626",t.lineWidth=1;const n=e.globalLinePoints;t.moveTo(n[0].x,n[0].y);for(let o=1;o<n.length;o++){const s=n[o];t.lineTo(s.x,s.y)}t.stroke(),t.fillStyle="#000000";for(let o=1;o<n.length-2;o=o+3){const s=n[o],r=n[o+1];t.beginPath(),t.arc(s.x,s.y,5,0,2*Math.PI),t.fill(),t.stroke(),t.beginPath(),t.arc(r.x,r.y,5,0,2*Math.PI),t.fill(),t.stroke()}t.restore()}static computeBezierCurves(t){if(t.shapeType!==he.Curve)return[];const e=t.points,n=[];for(let o=1;o<e.length-2;o=o+3){const s=e[o-1],r=e[o],i=e[o+1],a=e[o+2],c=new di(s,r,i,a);n.push(c)}return n}static computeBezierCurvesByPoints(t){const e=[];for(let n=1;n<t.length-2;n=n+3){const o=t[n-1],s=t[n],r=t[n+1],i=t[n+2],a=new di(o,s,r,i);e.push(a)}return e}static computeCurveControlPoints(t){const e=this.computeBezierCurves(t),n=[];for(const o of e)n.push(o.getHalfTPos());return n}static computeCurveEndPoints(t){if(t.shapeType!==he.Curve)return[];const e=t.points,n=[];for(let o=1;o<e.length-2;o=o+3){const s=e[o-1],r=e[o+2];n.push(s),n.push(r)}return n}static pressMeta(t){return ui.getOS()===Jt.MacOS?t.originEvent.metaKey:t.originEvent.ctrlKey}static getAllChildren(t,e){const n=t.children;for(const o of n)e.add(o),this.getAllChildren(o,e)}static judgeNodeCanBeStretch(t){var e;return!(t.type===v.SlideContainer||t.type===v.Section&&((e=t.parent)==null?void 0:e.type)===v.SlideContainer)}static getSlideContainerChildNode(t,e,n){const o=t.getChildIdByIndex(e);if(!o)return null;const s=n.nodeManager.getNode(o);return s||null}static filterSlideContainerNodes(t,e){const n=t.docState.docMode,o=t.docState.slideStatus,s=o.slideContainer;if(n===ue.SLIDE_EDIT&&s){const r=this.getSlideContainerChildNode(s,o.currentIndex,t);if(!r)return e;const i=new Set;S.getAllChildren(r,i);const a=[];for(const c of e)i.has(c)&&a.push(c);return a}return e}static getSlideInfo(t,{renderManager:e,nodeManager:n}){return new Promise((o,s)=>{const r=t.getBounds(),i=r.maxX-r.minX,a=r.maxY-r.minY,c=new Set([t]);S.getAllChildren(t,c),e.exportWorker.exportToOfflineCanvasByFilterNodes(r,n,1,"",c).toBlob(d=>{if(d){const u=URL.createObjectURL(d),f={id:t.id,blobUrl:u,width:i,height:a};o(f)}else console.error("导出图片错误"),s("导出图片错误")})})}}class en{constructor(t,e){p(this,"type",v.Shape);p(this,"id");p(this,"parent",null);p(this,"children",new Set);p(this,"zIndex",0);p(this,"graphicContext");p(this,"props",new Map);p(this,"transform",re.generateMatrix());this.id=t,this.graphicContext=e}get baseProps(){return this.props.get(I.Base)}get globalBaseProps(){const t=this.baseProps.clone(),e=this.globalPos;return t.x=e.x,t.y=e.y,t}get pos(){const t=this.baseProps;return new P(t.x,t.y)}get globalPos(){return this.globalTransform().crossPoint(new P)}setParent(t){this.parent=t,t.children.add(this)}updateProps(t){for(const e of t){if(e.type===void 0)continue;const n=this.props.get(e.type);n&&n.update(e)}}getProp(t){const e=this.props.get(t);return e||null}updateTransformMatrix(){const t=this.baseProps,e=re.generateMatrix().rotate(t.angle),n=re.generateMatrix().translate(t.x,t.y);this.transform=n.crossProduct(e)}contains(t,e=1){const{width:n,height:o}=this.baseProps,s=this.toLocal(t);return S.rectContains(s,new D(0,0,n,o))}canQuickCreate(){return!!this.canBeConnected()}canBeConnected(){return!0}getConnectAnchor(){return[]}borderContains(t,e){return null}draw(){return this.drawOnGLCtx(this.graphicContext)}globalTransform(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;let n=re.generateMatrix();for(const o of t.reverse())n=n.crossProduct(o.transform);return n}getRectNode(){const{width:t,height:e}=this.baseProps,n=this.getProp(I.Border),o=n?n.width:0,s=[new P(-o,-o),new P(t+o,-o),new P(t+o,e+o),new P(-o,e+o)],r=[];for(const a of s)r.push(this.toGlobal(a));const i=S.getBoundsByPoints(r);return i.id=this.id,i}getBounds(){const t=this.baseProps,e={id:this.id,minX:0,minY:0,maxX:t.width,maxY:t.height},n=[new P(e.minX,e.minY),new P(e.maxX,e.minY),new P(e.maxX,e.maxY),new P(e.minX,e.maxY)],o=[];for(const r of n)o.push(this.toGlobal(r));const s=S.getBoundsByPoints(o);return s.id=this.id,s}getStretchMinSize(){return{x:10,y:10}}overlapRect(t){return S.overlapRect(t,this.getBounds())}isEmptyText(){return!0}toLocal(t){return this.globalTransform().inverseMatrix().crossPoint(t)}toGlobal(t){return this.globalTransform().crossPoint(t)}modifyPosInEditing(t){return!1}resetFromEditing(){}serializeTo(){const t=S.convertPropsToCapInfo(this.props),e=JSON.parse(JSON.stringify(t));return{type:this.type,zIndex:this.zIndex,id:this.id,parentId:"",capInfo:e,children:[]}}}class Ah{fallbackDraw(t,e){const{width:n,height:o}=t.baseProps;e.save();const{a:s,b:r,c:i,d:a,e:c,f:h}=t.globalTransform();e.transform(s,r,i,a,c,h),e.beginPath();let d=!1;const u=n/3,f=o/3;for(let g=0;g<3;g++)for(let y=0;y<3;y++){const m=d?Ht:bs,b=u*g,w=f*y;e.fillStyle=m,e.fillRect(b,w,u,f),d=!d}e.restore()}}class ge{constructor(t=0,e=0){this.x=t,this.y=e}clone(){return new this.constructor(this.x,this.y)}add(t){return new this.constructor(this.x+t.x,this.y+t.y)}subtract(t){return new this.constructor(this.x-t.x,this.y-t.y)}multiply(t){return new this.constructor(this.x*t,this.y*t)}divide(t){return new this.constructor(this.x/t,this.y/t)}equals(t){return this.x===t.x&&this.y===t.y}precisionEquals(t,e){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e}lerp(t,e){const n=1-e;return new this.constructor(this.x*n+t.x*e,this.y*n+t.y*e)}distanceFrom(t){const e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}min(t){return new this.constructor(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new this.constructor(Math.max(this.x,t.x),Math.max(this.y,t.y))}transform(t){return new this.constructor(t.a*this.x+t.c*this.y+t.e,t.b*this.x+t.d*this.y+t.f)}toString(){return`point(${this.x},${this.y})`}}class rt{constructor(t=0,e=0){this.x=t,this.y=e}static fromPoints(t,e){return new rt(e.x-t.x,e.y-t.y)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}magnitude(){return this.x*this.x+this.y*this.y}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}determinant(t){return this.x*t.y-this.y*t.x}unit(){return this.divide(this.length())}add(t){return new this.constructor(this.x+t.x,this.y+t.y)}subtract(t){return new this.constructor(this.x-t.x,this.y-t.y)}multiply(t){return new this.constructor(this.x*t,this.y*t)}divide(t){return new this.constructor(this.x/t,this.y/t)}angleBetween(t){let e=this.dot(t)/(this.length()*t.length());e=Math.max(-1,Math.min(e,1));const n=Math.acos(e);return this.cross(t)<0?-n:n}perp(){return new this.constructor(-this.y,this.x)}perpendicular(t){return this.subtract(this.project(t))}project(t){const e=this.dot(t)/t.dot(t);return t.multiply(e)}transform(t){return new this.constructor(t.a*this.x+t.c*this.y,t.b*this.x+t.d*this.y)}equals(t){return this.x===t.x&&this.y===t.y}precisionEquals(t,e){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e}toString(){return`vector(${this.x},${this.y})`}}class pt{constructor(t=1,e=0,n=0,o=1,s=0,r=0){this.a=t,this.b=e,this.c=n,this.d=o,this.e=s,this.f=r}static translation(t,e){return new pt(1,0,0,1,t,e)}static scaling(t){return new pt(t,0,0,t,0,0)}static scalingAt(t,e){return new pt(t,0,0,t,e.x-e.x*t,e.y-e.y*t)}static nonUniformScaling(t,e){return new pt(t,0,0,e,0,0)}static nonUniformScalingAt(t,e,n){return new pt(t,0,0,e,n.x-n.x*t,n.y-n.y*e)}static rotation(t){const e=Math.cos(t),n=Math.sin(t);return new pt(e,n,-n,e,0,0)}static rotationAt(t,e){const n=Math.cos(t),o=Math.sin(t);return new pt(n,o,-o,n,e.x-e.x*n+e.y*o,e.y-e.y*n-e.x*o)}static rotationFromVector(t){const e=t.unit(),n=e.x,o=e.y;return new pt(n,o,-o,n,0,0)}static xFlip(){return new pt(-1,0,0,1,0,0)}static yFlip(){return new pt(1,0,0,-1,0,0)}static xSkew(t){const e=Math.tan(t);return new pt(1,0,e,1,0,0)}static ySkew(t){const e=Math.tan(t);return new pt(1,e,0,1,0,0)}multiply(t){return this.isIdentity()?t:t.isIdentity()?this:new this.constructor(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f)}inverse(){if(this.isIdentity())return this;const t=this.a*this.d-this.b*this.c;if(t===0)throw new Error("Matrix is not invertible");const e=1/t,n=this.f*this.c-this.e*this.d,o=this.e*this.b-this.f*this.a;return new this.constructor(this.d*e,-this.b*e,-this.c*e,this.a*e,n*e,o*e)}translate(t,e){return new this.constructor(this.a,this.b,this.c,this.d,this.a*t+this.c*e+this.e,this.b*t+this.d*e+this.f)}scale(t){return new this.constructor(this.a*t,this.b*t,this.c*t,this.d*t,this.e,this.f)}scaleAt(t,e){const n=e.x-t*e.x,o=e.y-t*e.y;return new this.constructor(this.a*t,this.b*t,this.c*t,this.d*t,this.a*n+this.c*o+this.e,this.b*n+this.d*o+this.f)}scaleNonUniform(t,e){return new this.constructor(this.a*t,this.b*t,this.c*e,this.d*e,this.e,this.f)}scaleNonUniformAt(t,e,n){const o=n.x-t*n.x,s=n.y-e*n.y;return new this.constructor(this.a*t,this.b*t,this.c*e,this.d*e,this.a*o+this.c*s+this.e,this.b*o+this.d*s+this.f)}rotate(t){const e=Math.cos(t),n=Math.sin(t);return new this.constructor(this.a*e+this.c*n,this.b*e+this.d*n,this.a*-n+this.c*e,this.b*-n+this.d*e,this.e,this.f)}rotateAt(t,e){const n=Math.cos(t),o=Math.sin(t),s=e.x,r=e.y,i=this.a*n+this.c*o,a=this.b*n+this.d*o,c=this.c*n-this.a*o,h=this.d*n-this.b*o;return new this.constructor(i,a,c,h,(this.a-i)*s+(this.c-c)*r+this.e,(this.b-a)*s+(this.d-h)*r+this.f)}rotateFromVector(t){const e=t.unit(),n=e.x,o=e.y;return new this.constructor(this.a*n+this.c*o,this.b*n+this.d*o,this.a*-o+this.c*n,this.b*-o+this.d*n,this.e,this.f)}flipX(){return new this.constructor(-this.a,-this.b,this.c,this.d,this.e,this.f)}flipY(){return new this.constructor(this.a,this.b,-this.c,-this.d,this.e,this.f)}skewX(t){const e=Math.tan(t);return new this.constructor(this.a,this.b,this.c+this.a*e,this.d+this.b*e,this.e,this.f)}skewY(t){const e=Math.tan(t);return new this.constructor(this.a+this.c*e,this.b+this.d*e,this.c,this.d,this.e,this.f)}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0}isInvertible(){return this.a*this.d-this.b*this.c!==0}getScale(){return{scaleX:Math.sqrt(this.a*this.a+this.c*this.c),scaleY:Math.sqrt(this.b*this.b+this.d*this.d)}}getDecomposition(){const t=(this.a+this.d)*.5,e=(this.a-this.d)*.5,n=(this.b+this.c)*.5,o=(this.b-this.c)*.5,s=Math.sqrt(t*t+o*o),r=Math.sqrt(e*e+n*n),i=s+r,a=s-r,c=Math.atan2(n,e),h=Math.atan2(o,t),d=(h-c)*.5,u=(h+c)*.5;return{translation:this.constructor.translation(this.e,this.f),rotation:this.constructor.rotation(u),scale:this.constructor.nonUniformScaling(i,a),rotation0:this.constructor.rotation(d)}}equals(t){return this.a===t.a&&this.b===t.b&&this.c===t.c&&this.d===t.d&&this.e===t.e&&this.f===t.f}precisionEquals(t,e){return Math.abs(this.a-t.a)<e&&Math.abs(this.b-t.b)<e&&Math.abs(this.c-t.c)<e&&Math.abs(this.d-t.d)<e&&Math.abs(this.e-t.e)<e&&Math.abs(this.f-t.f)<e}toString(){return`matrix(${this.a},${this.b},${this.c},${this.d},${this.e},${this.f})`}}pt.IDENTITY=new pt,pt.IDENTITY.isIdentity=()=>!0;function Mt(l){return typeof l=="number"?l?l<0?-1:1:l===l?l:NaN:NaN}class Ue{constructor(...t){this.coefs=[];for(let e=t.length-1;e>=0;e--)this.coefs.push(t[e]);this._variable="t",this._s=0}static interpolate(t,e,n,o,s){if(t.constructor!==Array||e.constructor!==Array)throw new TypeError("xs and ys must be arrays");if(isNaN(n)||isNaN(o)||isNaN(s))throw new TypeError("n, offset, and x must be numbers");let r,i,a=0;const c=new Array(n),h=new Array(n);let d=0,u=Math.abs(s-t[o]);for(r=0;r<n;r++){const f=Math.abs(s-t[o+r]);f<u&&(d=r,u=f),c[r]=h[r]=e[o+r]}i=e[o+d],d--;for(let f=1;f<n;f++){for(r=0;r<n-f;r++){const g=t[o+r]-s,y=t[o+r+f]-s,m=c[r+1]-h[r];let b=g-y;if(b===0)throw new RangeError("Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)");b=m/b,h[r]=y*b,c[r]=g*b}a=2*(d+1)<n-f?c[d+1]:h[d--],i+=a}return{y:i,dy:a}}static newtonSecantBisection(t,e,n,o,s,r){let i,a=0,c,h=0,d,u,f,g,y;i=t;const m=Math.pow(10,-14),b=typeof s=="number"&&typeof r=="number";if(b){if(s>r)throw new RangeError("Min must be greater than max");if(g=e(s),y=e(r),Mt(g)===Mt(y))throw new RangeError("Y values of bounds must be of opposite sign")}const w=function(){return Math.abs(d)<=m*Math.abs(i)||h===i-d-i};for(let L=0;L<o;L++){if(c=n(i),c===0){if(a===0)throw new RangeError("df(x) is zero");c=a}if(a=c,f=e(i),d=f/c,u=i-d,w())break;if(b){if(Mt(f)===Mt(y))r=i,y=f;else if(Mt(f)===Mt(g))s=i,g=f;else{i=u;break}if(u<s||u>r){if(Mt(g)===Mt(y))break;const B=50,H=.25,E=y-g,X=r-s;if(E===0?d=i-(s+X*.5):Math.abs(E/Math.min(g,y))>B?d=i-(s+X*(.5+(Math.abs(g)<Math.abs(y)?-H:H))):d=i-(s-g/E*X),u=i-d,w())break}}h=i-u,i=u}return i}clone(){const t=new Ue;return t.coefs=this.coefs.slice(),t}eval(t){if(isNaN(t))throw new TypeError(`Parameter must be a number. Found '${t}'`);let e=0;for(let n=this.coefs.length-1;n>=0;n--)e=e*t+this.coefs[n];return e}add(t){const e=new Ue,n=this.getDegree(),o=t.getDegree(),s=Math.max(n,o);for(let r=0;r<=s;r++){const i=r<=n?this.coefs[r]:0,a=r<=o?t.coefs[r]:0;e.coefs[r]=i+a}return e}multiply(t){const e=new Ue;for(let n=0;n<=this.getDegree()+t.getDegree();n++)e.coefs.push(0);for(let n=0;n<=this.getDegree();n++)for(let o=0;o<=t.getDegree();o++)e.coefs[n+o]+=this.coefs[n]*t.coefs[o];return e}divideEqualsScalar(t){for(let e=0;e<this.coefs.length;e++)this.coefs[e]/=t}simplifyEquals(t=1e-12){for(let e=this.getDegree();e>=0&&Math.abs(this.coefs[e])<=t;e--)this.coefs.pop()}removeZerosEquals(t=1e-15){const e=this.coefs,n=10*t*Math.abs(e.reduce((o,s)=>Math.abs(s)>Math.abs(o)?s:o));for(let o=0;o<e.length-1;o++)Math.abs(e[o])<n&&(e[o]=0);return this}monicEquals(){const t=this.coefs;return t[t.length-1]!==1&&this.divideEqualsScalar(t[t.length-1]),this}toString(){const t=[],e=[];for(let o=this.coefs.length-1;o>=0;o--){let s=Math.round(this.coefs[o]*1e3)/1e3;if(s!==0){const r=s<0?" - ":" + ";s=Math.abs(s),o>0&&(s===1?s=this._variable:s+=this._variable),o>1&&(s+="^"+o),e.push(r),t.push(s)}}e[0]=e[0]===" + "?"":"-";let n="";for(let o=0;o<t.length;o++)n+=e[o]+t[o];return n}bisection(t,e,n=1e-6,o=15){let s=this.eval(t),r=this.eval(e),i;if(Math.abs(s)<=n)i=t;else if(Math.abs(r)<=n)i=e;else if(s*r<=0){const a=Math.log(e-t),c=Math.LN10*o,h=Math.ceil((a+c)/Math.LN2);for(let d=0;d<h;d++){i=.5*(t+e);const u=this.eval(i);if(Math.abs(u)<=n)break;u*s<0?(e=i,r=u):(t=i,s=u)}}return i}trapezoid(t,e,n){if(isNaN(t)||isNaN(e)||isNaN(n))throw new TypeError("Parameters must be numbers");const o=e-t;if(n===1){const s=this.eval(t),r=this.eval(e);this._s=.5*o*(s+r)}else{const s=1<<n-2,r=o/s;let i=t+.5*r,a=0;for(let c=0;c<s;c++)a+=this.eval(i),i+=r;this._s=.5*(this._s+o*a/s)}if(isNaN(this._s))throw new TypeError("this._s is NaN");return this._s}simpson(t,e){if(isNaN(t)||isNaN(e))throw new TypeError("Parameters must be numbers");const n=e-t;let o=.5*n*(this.eval(t)+this.eval(e)),s=o,r=4*o/3,i=r,a=o;const c=1e-7;let h=1;for(let d=2;d<=20;d++){const u=n/h;let f=t+.5*u,g=0;for(let y=1;y<=h;y++)g+=this.eval(f),f+=u;if(s=.5*(s+n*g/h),o=s,r=(4*o-a)/3,Math.abs(r-i)<c*Math.abs(i))break;i=r,a=o,h<<=1}return r}romberg(t,e){if(isNaN(t)||isNaN(e))throw new TypeError("Parameters must be numbers");const n=20,o=3,s=1e-6,r=new Array(n+1),i=new Array(n+1);let a={y:0,dy:0};i[0]=1;for(let c=1;c<=n&&(r[c-1]=this.trapezoid(t,e,c),!(c>=o&&(a=Ue.interpolate(i,r,o,c-o,0),Math.abs(a.dy)<=s*a.y)));c++)r[c]=r[c-1],i[c]=.25*i[c-1];return a.y}zeroErrorEstimate(t){const e=this,n=1e-15;if(typeof t>"u"){const r=e.bounds();t=Math.max(Math.abs(r.minX),Math.abs(r.maxX))}if(t<.001)return 2*Math.abs(e.eval(n));const o=e.coefs.length-1,s=e.coefs[o];return 10*n*e.coefs.reduce((r,i,a)=>{const c=i/s*Math.pow(t,a);return c>r?c:r},0)}boundsUpperRealFujiwara(){let t=this.coefs;const e=t.length-1,n=t[e];n!==1&&(t=this.coefs.map(c=>c/n));const o=t.map((c,h)=>h<e?Math.pow(Math.abs(h===0?c/2:c),1/(e-h)):c);let s;const r=function(c,h,d){return s(d)&&(c.max<h?(c.nearmax=c.max,c.max=h):c.nearmax<h&&(c.nearmax=h)),c};s=function(c){return c<e&&t[c]<0};const i=o.reduce(r,{max:0,nearmax:0});return s=function(c){return c<e&&(e%2===c%2?t[c]<0:t[c]>0)},{negX:-2*o.reduce(r,{max:0,nearmax:0}).max,posX:2*i.max}}boundsLowerRealFujiwara(){const t=new Ue;t.coefs=this.coefs.slice().reverse();const e=t.boundsUpperRealFujiwara();return e.negX=1/e.negX,e.posX=1/e.posX,e}bounds(){const t=this.boundsUpperRealFujiwara(),e={minX:t.negX,maxX:t.posX};return t.negX===0&&t.posX===0||(t.negX===0?e.minX=this.boundsLowerRealFujiwara().posX:t.posX===0&&(e.maxX=this.boundsLowerRealFujiwara().negX),e.minX>e.maxX&&(e.minX=e.maxX=0)),e}boundUpperAbsRouche(){const t=this.coefs,e=t.length-1;return 1+t.reduce((o,s,r)=>r!==e?(s=Math.abs(s),o<s?s:o):o,0)/Math.abs(t[e])}boundLowerAbsRouche(){const t=this.coefs,e=t.reduce((n,o,s)=>s!==0?(o=Math.abs(o),n<o?o:n):n,0);return Math.abs(t[0])/(Math.abs(t[0])+e)}boundsRealLaguerre(){const t=this.coefs,e=t.length-1,n=-t[e-1]/(e*t[e]),o=t[e-1]*t[e-1]-2*e/(e-1)*t[e]*t[e-2];let s=(e-1)/(e*t[e])*Math.sqrt(o);return s<0&&(s=-s),{minX:n-s,maxX:n+s}}countRootsDescartes(){const t=this.coefs,e=t.length-1,n=t.reduce((o,s,r)=>(o.prev_a!==0&&s!==0&&(o.prev_a<0==s>0&&o.pos++,r%2===0!=o.prev_a<0==(r%2===1!=s>0)&&o.neg++),o.prev_a=s,o),{pos:0,neg:0,prev_a:0});return{maxRealPos:n.pos,maxRealNeg:n.neg,minComplex:e-(n.pos+n.neg)}}getDegree(){return this.coefs.length-1}getDerivative(){const t=new Ue;for(let e=1;e<this.coefs.length;e++)t.coefs.push(e*this.coefs[e]);return t}getRoots(){let t;switch(this.simplifyEquals(),this.getDegree()){case 0:t=[];break;case 1:t=this.getLinearRoot();break;case 2:t=this.getQuadraticRoots();break;case 3:t=this.getCubicRoots();break;case 4:t=this.getQuarticRoots();break;default:t=[]}return t}getRootsInInterval(t,e){const n=[];function o(s){typeof s=="number"&&n.push(s)}if(this.getDegree()===0)throw new RangeError("Unexpected empty polynomial");if(this.getDegree()===1)o(this.bisection(t,e));else{const r=this.getDerivative().getRootsInInterval(t,e);if(r.length>0){o(this.bisection(t,r[0]));for(let i=0;i<=r.length-2;i++)o(this.bisection(r[i],r[i+1]));o(this.bisection(r[r.length-1],e))}else o(this.bisection(t,e))}return n}getLinearRoot(){const t=[],e=this.coefs[1];return e!==0&&t.push(-this.coefs[0]/e),t}getQuadraticRoots(){const t=[];if(this.getDegree()===2){const e=this.coefs[2],n=this.coefs[1]/e,o=this.coefs[0]/e,s=n*n-4*o;if(s>0){const r=Math.sqrt(s);t.push(.5*(-n+r)),t.push(.5*(-n-r))}else s===0&&t.push(.5*-n)}return t}getCubicRoots(){const t=[];if(this.getDegree()===3){const e=this.coefs[3],n=this.coefs[2]/e,o=this.coefs[1]/e,s=this.coefs[0]/e,r=(3*o-n*n)/3,i=(2*n*n*n-9*o*n+27*s)/27,a=n/3;let c=i*i/4+r*r*r/27;const h=i/2,d=this.zeroErrorEstimate();if(Math.abs(c)<=d&&(c=0),c>0){const u=Math.sqrt(c);let f,g=-h+u;g>=0?f=Math.pow(g,1/3):f=-Math.pow(-g,1/3),g=-h-u,g>=0?f+=Math.pow(g,1/3):f-=Math.pow(-g,1/3),t.push(f-a)}else if(c<0){const u=Math.sqrt(-r/3),f=Math.atan2(Math.sqrt(-c),-h)/3,g=Math.cos(f),y=Math.sin(f),m=Math.sqrt(3);t.push(2*u*g-a),t.push(-u*(g+m*y)-a),t.push(-u*(g-m*y)-a)}else{let u;h>=0?u=-Math.pow(h,1/3):u=Math.pow(-h,1/3),t.push(2*u-a),t.push(-u-a)}}return t}getQuarticRoots(){let t=[];const e=this.getDegree();if(e===4){const n=new Ue;n.coefs=this.coefs.slice(),n.divideEqualsScalar(n.coefs[e]);const o=1e-15;Math.abs(n.coefs[0])<10*o*Math.abs(n.coefs[3])&&(n.coefs[0]=0);const s=n.getDerivative(),r=s.getRoots().sort((w,L)=>w-L),i=[],a=r.length-1,c=this.bounds(),h=Math.max(Math.abs(c.minX),Math.abs(c.maxX)),d=this.zeroErrorEstimate(h);for(let w=0;w<=a;w++)i.push(n.eval(r[w]));for(let w=0;w<=a;w++)Math.abs(i[w])<d&&(i[w]=0);let u=0;const f=Math.max(.1*(c.maxX-c.minX)/e,o),g=[],y=[];if(a>-1){for(i[0]!==0?Mt(i[0])!==Mt(n.eval(r[0]-f)-i[0])&&(g.push(r[0]-f),y.push([c.minX,r[0]])):(t.push(r[0],r[0]),u++);u<a;u++)i[u+1]===0?(t.push(r[u+1],r[u+1]),u++):Mt(i[u])!==Mt(i[u+1])&&(g.push((r[u]+r[u+1])/2),y.push([r[u],r[u+1]]));i[a]!==0&&Mt(i[a])!==Mt(n.eval(r[a]+f)-i[a])&&(g.push(r[a]+f),y.push([r[a],c.maxX]))}const m=function(w){return n.eval(w)},b=function(w){return s.eval(w)};if(g.length>0)for(u=0;u<g.length;u++)g[u]=Ue.newtonSecantBisection(g[u],m,b,32,y[u][0],y[u][1]);t=t.concat(g)}return t}}class ft{constructor(t,e){this.type=t,this.text=e}typeis(t){return this.type===t}}ft.UNDEFINED=0,ft.COMMAND=1,ft.NUMBER=2,ft.EOD=3;class Nh{constructor(t){t==null&&(t=""),this.setPathData(t)}setPathData(t){if(typeof t!="string")throw new TypeError("The first parameter must be a string");this._pathData=t}getNextToken(){let t=null,e=this._pathData;for(;t===null;)if(e===null||e==="")t=new ft(ft.EOD,"");else if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([AaCcHhLlMmQqSsTtVvZz])/))t=new ft(ft.COMMAND,RegExp.$1),e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?\d+(\.\d*)?|[-+]?\.\d+)([eE][-+]?\d+)?)/))t=new ft(ft.NUMBER,RegExp.$1),e=e.substr(RegExp.$1.length);else throw new SyntaxError(`Unrecognized path data: ${e}`);return this._pathData=e,t}}const Ts="BOP";class In{constructor(){this._lexer=new Nh,this._handler=null}parseData(t){if(typeof t!="string")throw new TypeError(`The first parameter must be a string: ${t}`);this._handler!==null&&typeof this._handler.beginParse=="function"&&this._handler.beginParse();const e=this._lexer;e.setPathData(t);let n=Ts,o=null,s=e.getNextToken();for(;s.typeis(ft.EOD)===!1;){let r;const i=[];switch(s.type){case ft.COMMAND:if(n===Ts&&s.text!=="M"&&s.text!=="m")throw new SyntaxError(`New paths must begin with a moveto command. Found '${s.text}'`);n=s.text,r=In.PARAMCOUNT[s.text.toUpperCase()],s=e.getNextToken();break;case ft.NUMBER:if(n===Ts)throw new SyntaxError(`New paths must begin with a moveto command. Found '${s.text}'`);r=In.PARAMCOUNT[n.toUpperCase()];break;default:throw new SyntaxError(`Unrecognized command type: ${s.type}`)}for(let a=0;a<r;a++){switch(s.type){case ft.COMMAND:throw new SyntaxError(`Parameter must be a number. Found '${s.text}'`);case ft.NUMBER:i[a]=parseFloat(s.text);break;case ft.EOD:throw new SyntaxError("Unexpected end of string");default:throw new SyntaxError(`Unrecognized parameter type. Found type '${s.type}'`)}s=e.getNextToken()}if(this._handler!==null){const a=this._handler,c=In.METHODNAME[n];(n==="a"||n==="A")&&(i[3]=i[3]!==0,i[4]=i[4]!==0),a!==null&&typeof a[c]=="function"&&a[c](...i)}switch(n){case"M":n="L";break;case"m":n="l";break;case"Z":case"z":n="BOP";break}if(s===o)throw new SyntaxError(`Parser stalled on '${s.text}'`);o=s}this._handler!==null&&typeof this._handler.endParse=="function"&&this._handler.endParse()}setHandler(t){this._handler=t}}In.PARAMCOUNT={A:7,C:6,H:1,L:2,M:2,Q:4,S:4,T:2,V:1,Z:0},In.METHODNAME={A:"arcAbs",a:"arcRel",C:"curvetoCubicAbs",c:"curvetoCubicRel",H:"linetoHorizontalAbs",h:"linetoHorizontalRel",L:"linetoAbs",l:"linetoRel",M:"movetoAbs",m:"movetoRel",Q:"curvetoQuadraticAbs",q:"curvetoQuadraticRel",S:"curvetoCubicSmoothAbs",s:"curvetoCubicSmoothRel",T:"curvetoQuadraticSmoothAbs",t:"curvetoQuadraticSmoothRel",V:"linetoVerticalAbs",v:"linetoVerticalRel",Z:"closePath",z:"closePath"};const kh=2*Math.PI;function pi(l,t,e,n,o,s,r){o=o*Math.PI/180;const i=Math.cos(o),a=Math.sin(o),c=1e-6,h=l.subtract(t).multiply(.5),d=h.x*i+h.y*a,u=h.x*-a+h.y*i;e=Math.abs(e),n=Math.abs(n);const f=d*d,g=u*u,y=f/(e*e)+g/(n*n);if(y>1){const pe=Math.sqrt(y);e*=pe,n*=pe}const m=e*e,b=n*n,w=m*g,L=b*f;let B=(m*b-w-L)/(w+L);Math.abs(B)<c&&(B=0);let H=Math.sqrt(B);s===r&&(H=-H);const E=l.add(t).multiply(.5),X=H*e*u/n,$=H*-n*d/e,Z=(d-X)/e,se=(d+X)/e,ne=(u-$)/n,ae=(u+$)/n,te=new rt(1,0).angleBetween(new rt(Z,ne));let ce=new rt(Z,ne).angleBetween(new rt(-se,-ae));return r===!1&&(ce-=kh),[X*i-$*a+E.x,X*a+$*i+E.y,e,n,te,te+ce]}class Bh{constructor(t){this.shapeCreator=t,this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}beginParse(){this.shapes=[],this.firstX=null,this.firstY=null,this.lastX=null,this.lastY=null,this.lastCommand=null}addShape(t){this.shapes.push(t)}arcAbs(t,e,n,o,s,r,i){if(t===0||e===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,r,i));else{const a=pi(new ge(this.lastX,this.lastY),new ge(r,i),t,e,n,o,s);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="A",this.lastX=r,this.lastY=i}arcRel(t,e,n,o,s,r,i){if(t===0||e===0)this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+r,this.lastY+i));else{const a=pi(new ge(this.lastX,this.lastY),new ge(this.lastX+r,this.lastY+i),t,e,n,o,s);this.addShape(this.shapeCreator.arc(...a))}this.lastCommand="a",this.lastX+=r,this.lastY+=i}curvetoCubicAbs(t,e,n,o,s,r){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,t,e,n,o,s,r)),this.lastX=s,this.lastY=r,this.lastCommand="C"}curvetoCubicRel(t,e,n,o,s,r){this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o,this.lastX+s,this.lastY+r)),this.lastX+=s,this.lastY+=r,this.lastCommand="c"}linetoHorizontalAbs(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,t,this.lastY)),this.lastX=t,this.lastCommand="H"}linetoHorizontalRel(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+t,this.lastY)),this.lastX+=t,this.lastCommand="h"}linetoAbs(t,e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,t,e)),this.lastX=t,this.lastY=e,this.lastCommand="L"}linetoRel(t,e){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX+t,this.lastY+e)),this.lastX+=t,this.lastY+=e,this.lastCommand="l"}movetoAbs(t,e){this.firstX=t,this.firstY=e,this.lastX=t,this.lastY=e,this.lastCommand="M"}movetoRel(t,e){this.firstX+=t,this.firstY+=e,this.lastX+=t,this.lastY+=e,this.lastCommand="m"}curvetoQuadraticAbs(t,e,n,o){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,t,e,n,o)),this.lastX=n,this.lastY=o,this.lastCommand="Q"}curvetoQuadraticRel(t,e,n,o){this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o)),this.lastX+=n,this.lastY+=o,this.lastCommand="q"}curvetoCubicSmoothAbs(t,e,n,o){let s,r;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];s=2*this.lastX-i.x,r=2*this.lastY-i.y}else s=this.lastX,r=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,s,r,t,e,n,o)),this.lastX=n,this.lastY=o,this.lastCommand="S"}curvetoCubicSmoothRel(t,e,n,o){let s,r;if(this.lastCommand.match(/^[SsCc]$/)){const i=this.shapes[this.shapes.length-1].args[2];s=2*this.lastX-i.x,r=2*this.lastY-i.y}else s=this.lastX,r=this.lastY;this.addShape(this.shapeCreator.cubicBezier(this.lastX,this.lastY,s,r,this.lastX+t,this.lastY+e,this.lastX+n,this.lastY+o)),this.lastX+=n,this.lastY+=o,this.lastCommand="s"}curvetoQuadraticSmoothAbs(t,e){let n,o;if(this.lastCommand.match(/^[QqTt]$/)){const s=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-s.x,o=2*this.lastY-s.y}else n=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,o,t,e)),this.lastX=t,this.lastY=e,this.lastCommand="T"}curvetoQuadraticSmoothRel(t,e){let n,o;if(this.lastCommand.match(/^[QqTt]$/)){const s=this.shapes[this.shapes.length-1].args[1];n=2*this.lastX-s.x,o=2*this.lastY-s.y}else n=this.lastX,o=this.lastY;this.addShape(this.shapeCreator.quadraticBezier(this.lastX,this.lastY,n,o,this.lastX+t,this.lastY+e)),this.lastX+=t,this.lastY+=e,this.lastCommand="t"}linetoVerticalAbs(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,t)),this.lastY=t,this.lastCommand="V"}linetoVerticalRel(t){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.lastX,this.lastY+t)),this.lastY+=t,this.lastCommand="v"}closePath(){this.addShape(this.shapeCreator.line(this.lastX,this.lastY,this.firstX,this.firstY)),this.lastX=this.firstX,this.lastY=this.firstY,this.lastCommand="z"}}const Tn=Math.PI*.5,fi=new In;function tn(l,t){const e=[];for(const[n,o]of l){let s=null;if(o==="Point2D")s=Ls(n,t);else if(o==="Number")s=gi(n,t);else if(o==="Array<Point2D>"||o==="Point2D[]"){const r=[];for(;t.length>0;)r.push(Ls(n,t));r.length>0&&(s=r)}else if(o==="Optional<Number>"||o==="Number?")s=gi(n,t),s===null&&(s=void 0);else throw new TypeError(`Unrecognized value type: ${o}`);if(s!==null)e.push(s);else throw new TypeError(`Unable to extract value for ${n}`)}return e}function gi(l,t){let e=null;if(t.length>0){const n=t[0],o=typeof n;if(o==="number")return t.shift();if(o==="object"){for(const s of l)if(s in n&&typeof n[s]=="number"){e=n[s];break}}}return e}function Ls(l,t){let e=null;if(t.length>0){const n=t[0],o=typeof n;if(o==="number"){if(t.length>1){const s=t.shift(),r=t.shift();e=new ge(s,r)}}else if(Array.isArray(n)&&n.length>1)if(n.length===2){const[s,r]=t.shift();e=new ge(s,r)}else throw new TypeError(`Unhandled array of length ${n.length}`);else if(o==="object"){if("x"in n&&"y"in n)e=new ge(n.x,n.y),t.shift();else for(const s of l)if(Array.isArray(s)){if(s.every(r=>r in n)){e=new ge(n[s[0]],n[s[1]]);break}}else if(s in n){e=Ls([],[n[s]]);break}}}return e}class q{constructor(t,e){this.name=t,this.args=e}static arc(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"],[["startRadians"],"Number"],[["endRadians"],"Number"]],t);return new q(q.ARC,n)}static quadraticBezier(...t){const n=tn([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"]],t);return new q(q.QUADRATIC_BEZIER,n)}static cubicBezier(...t){const n=tn([[["p1",["p1x","p1y"]],"Point2D"],[["p2",["p2x","p2y"]],"Point2D"],[["p3",["p3x","p3y"]],"Point2D"],[["p4",["p4x","p4y"]],"Point2D"]],t);return new q(q.CUBIC_BEZIER,n)}static circle(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radius","r"],"Number"]],t);return new q(q.CIRCLE,n)}static ellipse(...t){const n=tn([[["center",["centerX","centerY"],["cx","cy"]],"Point2D"],[["radiusX","rx"],"Number"],[["radiusY","ry"],"Number"]],t);return new q(q.ELLIPSE,n)}static line(...t){const n=tn([[["p1",["p1x","p1y"],["x1","y1"]],"Point2D"],[["p2",["p2x","p2y"],["x2","y2"]],"Point2D"]],t);return new q(q.LINE,n)}static path(...t){return fi.parseData(t[0]),new q(q.PATH,yi.shapes)}static polygon(...t){const n=tn([[[],"Array<Point2D>"]],t.length===1&&Array.isArray(t[0])?t[0]:t);return new q(q.POLYGON,n)}static polyline(...t){const n=tn([[[],"Array<Point2D>"]],t.length===1&&Array.isArray(t[0])?t[0]:t);return new q(q.POLYLINE,n)}static rectangle(...t){const n=tn([[["topLeft",["x","y"],["left","top"]],"Point2D"],[["size",["width","height"],["w","h"]],"Point2D"],[["radiusX","rx"],"Optional<Number>"],[["radiusY","ry"],"Optional<Number>"]],t),o=n[0],s=n[1];n[1]=new ge(o.x+s.x,o.y+s.y);const r=new q(q.RECTANGLE,n);let i=r.args.pop(),a=r.args.pop();if(a=a===void 0?0:a,i=i===void 0?0:i,a===0&&i===0)return r;const{x:c,y:h}=r.args[0],{x:d,y:u}=r.args[1],f=d-c,g=u-h;a===0&&(a=i),i===0&&(i=a),a>f*.5&&(a=f*.5),i>g*.5&&(i=g*.5);const y=c,m=h,b=c+a,w=h+i,L=d-a,B=u-i,H=d,E=u,X=[q.arc(b,w,a,i,2*Tn,3*Tn),q.line(b,m,L,m),q.arc(L,w,a,i,3*Tn,4*Tn),q.line(H,w,H,B),q.arc(L,B,a,i,0,Tn),q.line(L,E,b,E),q.arc(b,B,a,i,Tn,2*Tn),q.line(y,B,y,w)];return new q(q.PATH,X)}}q.ARC="Arc",q.QUADRATIC_BEZIER="Bezier2",q.CUBIC_BEZIER="Bezier3",q.CIRCLE="Circle",q.ELLIPSE="Ellipse",q.LINE="Line",q.PATH="Path",q.POLYGON="Polygon",q.POLYLINE="Polyline",q.RECTANGLE="Rectangle";const yi=new Bh(q);fi.setHandler(yi);const so=2*Math.PI,Rh=new rt(1,0);function xi(l){return l==null}function Eh(l,t){const e=l[0]*t[1]-t[0]*l[1],n=l[0]*t[2]-t[0]*l[2],o=l[0]*t[3]-t[0]*l[3],s=l[0]*t[4]-t[0]*l[4],r=l[0]*t[5]-t[0]*l[5],i=l[1]*t[2]-t[1]*l[2],a=l[1]*t[4]-t[1]*l[4],c=l[1]*t[5]-t[1]*l[5],h=l[2]*t[3]-t[2]*l[3],d=l[3]*t[4]-t[3]*l[4],u=l[3]*t[5]-t[3]*l[5],f=c+d,g=a-h;return new Ue(e*i-n*n,e*g+o*i-2*n*s,e*f+o*g-s*s-2*n*r,e*u+o*f-2*s*r,o*u-r*r)}function Hh(l){const t=l%so;return t<0?t+so:t}function Dh(l,t,e,n,o,s){if(l.points.length===0)return l;const r=new Y("No Intersection");s<o&&([o,s]=[s,o]),(o<0||s<0)&&(o+=so,s+=so);for(const i of l.points){let a=Hh(Rh.angleBetween(rt.fromPoints(t,i)));a<o&&(a+=so),o<=a&&a<=s&&r.appendPoint(i)}return r.points.length>0&&(r.status="Intersection"),r}function nn(l){const t=l.slice();return t.push(l[0]),t}class Y{constructor(t){this.init(t)}init(t){this.status=t,this.points=[]}static intersect(t,e){let n;if(!xi(t)&&!xi(e))if(t.name==="Path")n=Y.intersectPathShape(t,e);else if(e.name==="Path")n=Y.intersectPathShape(e,t);else if(t.name==="Arc")n=Y.intersectArcShape(t,e);else if(e.name==="Arc")n=Y.intersectArcShape(e,t);else{let o,s;if(t.name<e.name?(o="intersect"+t.name+e.name,s=t.args.concat(e.args)):(o="intersect"+e.name+t.name,s=e.args.concat(t.args)),!(o in Y))throw new TypeError("Intersection not available: "+o);n=Y[o].apply(null,s)}else n=new Y("No Intersection");return n}static intersectPathShape(t,e){const n=new Y("No Intersection");for(const o of t.args){const s=Y.intersect(o,e);n.appendPoints(s.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectArcShape(t,e){const[n,o,s,r,i]=t.args,a=new q(q.ELLIPSE,[n,o,s]),c=Y.intersect(a,e);return Dh(c,n,o,s,r,i)}static intersectBezier2Bezier2(t,e,n,o,s,r){let i,a;const c=new Y("No Intersection");i=e.multiply(-2);const h=t.add(i.add(n));i=t.multiply(-2),a=e.multiply(2);const d=i.add(a),u=new ge(t.x,t.y);i=s.multiply(-2);const f=o.add(i.add(r));i=o.multiply(-2),a=s.multiply(2);const g=i.add(a),y=new ge(o.x,o.y);i=h.x*d.y-d.x*h.y,a=f.x*d.y-d.x*f.y;const m=g.x*d.y-d.x*g.y,b=d.x*(u.y-y.y)+d.y*(-u.x+y.x),w=f.x*h.y-h.x*f.y,L=g.x*h.y-h.x*g.y,B=h.x*(u.y-y.y)+h.y*(-u.x+y.x),E=new Ue(-w*w,-2*w*L,i*a-L*L-2*w*B,i*m-2*L*B,i*b-B*B).getRoots();for(const X of E)if(0<=X&&X<=1){const $=new Ue(h.x,d.x,u.x-y.x-X*g.x-X*X*f.x);$.simplifyEquals();const Z=$.getRoots(),se=new Ue(h.y,d.y,u.y-y.y-X*g.y-X*X*f.y);se.simplifyEquals();const ne=se.getRoots();if(Z.length>0&&ne.length>0){e:for(const te of Z)if(0<=te&&te<=1){for(let ce=0;ce<ne.length;ce++)if(Math.abs(te-ne[ce])<1e-4){c.points.push(f.multiply(X*X).add(g.multiply(X).add(y)));break e}}}}return c.points.length>0&&(c.status="Intersection"),c}static intersectBezier2Bezier3(t,e,n,o,s,r,i){let a,c,h,d;const u=new Y("No Intersection");a=e.multiply(-2);const f=t.add(a.add(n));a=t.multiply(-2),c=e.multiply(2);const g=a.add(c),y=new ge(t.x,t.y);a=o.multiply(-1),c=s.multiply(3),h=r.multiply(-3),d=a.add(c.add(h.add(i)));const m=new ge(d.x,d.y);a=o.multiply(3),c=s.multiply(-6),h=r.multiply(3),d=a.add(c.add(h));const b=new ge(d.x,d.y);a=o.multiply(-3),c=s.multiply(3),h=a.add(c);const w=new ge(h.x,h.y),L=new ge(o.x,o.y),B=y.x*y.x,H=y.y*y.y,E=g.x*g.x,X=g.y*g.y,$=f.x*f.x,Z=f.y*f.y,se=L.x*L.x,ne=L.y*L.y,ae=w.x*w.x,te=w.y*w.y,ce=b.x*b.x,pe=b.y*b.y,Be=m.x*m.x,Re=m.y*m.y,Te=new Ue(-2*f.x*f.y*m.x*m.y+$*Re+Z*Be,-2*f.x*f.y*b.x*m.y-2*f.x*f.y*b.y*m.x+2*Z*b.x*m.x+2*$*b.y*m.y,-2*f.x*w.x*f.y*m.y-2*f.x*f.y*w.y*m.x-2*f.x*f.y*b.x*b.y+2*w.x*Z*m.x+Z*ce+$*(2*w.y*m.y+pe),2*y.x*f.x*f.y*m.y+2*y.y*f.x*f.y*m.x+g.x*g.y*f.x*m.y+g.x*g.y*f.y*m.x-2*L.x*f.x*f.y*m.y-2*f.x*L.y*f.y*m.x-2*f.x*w.x*f.y*b.y-2*f.x*f.y*w.y*b.x-2*y.x*Z*m.x-2*y.y*$*m.y+2*L.x*Z*m.x+2*w.x*Z*b.x-X*f.x*m.x-E*f.y*m.y+$*(2*L.y*m.y+2*w.y*b.y),2*y.x*f.x*f.y*b.y+2*y.y*f.x*f.y*b.x+g.x*g.y*f.x*b.y+g.x*g.y*f.y*b.x-2*L.x*f.x*f.y*b.y-2*f.x*L.y*f.y*b.x-2*f.x*w.x*f.y*w.y-2*y.x*Z*b.x-2*y.y*$*b.y+2*L.x*Z*b.x-X*f.x*b.x-E*f.y*b.y+ae*Z+$*(2*L.y*b.y+te),2*y.x*f.x*f.y*w.y+2*y.y*f.x*w.x*f.y+g.x*g.y*f.x*w.y+g.x*g.y*w.x*f.y-2*L.x*f.x*f.y*w.y-2*f.x*L.y*w.x*f.y-2*y.x*w.x*Z-2*y.y*$*w.y+2*L.x*w.x*Z-X*f.x*w.x-E*f.y*w.y+2*$*L.y*w.y,-2*y.x*y.y*f.x*f.y-y.x*g.x*g.y*f.y-y.y*g.x*g.y*f.x+2*y.x*f.x*L.y*f.y+2*y.y*L.x*f.x*f.y+g.x*L.x*g.y*f.y+g.x*g.y*f.x*L.y-2*L.x*f.x*L.y*f.y-2*y.x*L.x*Z+y.x*X*f.x+y.y*E*f.y-2*y.y*$*L.y-L.x*X*f.x-E*L.y*f.y+B*Z+H*$+se*Z+$*ne).getRootsInInterval(0,1);for(const fe of Te){const O=new Ue(f.x,g.x,y.x-L.x-fe*w.x-fe*fe*b.x-fe*fe*fe*m.x).getRoots(),G=new Ue(f.y,g.y,y.y-L.y-fe*w.y-fe*fe*b.y-fe*fe*fe*m.y).getRoots();if(O.length>0&&G.length>0){e:for(const _ of O)if(0<=_&&_<=1){for(let Ve=0;Ve<G.length;Ve++)if(Math.abs(_-G[Ve])<1e-4){u.points.push(m.multiply(fe*fe*fe).add(b.multiply(fe*fe).add(w.multiply(fe).add(L))));break e}}}}return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier2Circle(t,e,n,o,s){return Y.intersectBezier2Ellipse(t,e,n,o,s,s)}static intersectBezier2Ellipse(t,e,n,o,s,r){let i;const a=new Y("No Intersection");i=e.multiply(-2);const c=t.add(i.add(n));i=t.multiply(-2);const h=e.multiply(2),d=i.add(h),u=new ge(t.x,t.y),f=s*s,g=r*r,y=new Ue(g*c.x*c.x+f*c.y*c.y,2*(g*c.x*d.x+f*c.y*d.y),g*(2*c.x*u.x+d.x*d.x)+f*(2*c.y*u.y+d.y*d.y)-2*(g*o.x*c.x+f*o.y*c.y),2*(g*d.x*(u.x-o.x)+f*d.y*(u.y-o.y)),g*(u.x*u.x+o.x*o.x)+f*(u.y*u.y+o.y*o.y)-2*(g*o.x*u.x+f*o.y*u.y)-f*g).getRoots();for(const m of y)0<=m&&m<=1&&a.points.push(c.multiply(m*m).add(d.multiply(m).add(u)));return a.points.length>0&&(a.status="Intersection"),a}static intersectBezier2Line(t,e,n,o,s){let r;const i=o.min(s),a=o.max(s),c=new Y("No Intersection");r=e.multiply(-2);const h=t.add(r.add(n));r=t.multiply(-2);const d=e.multiply(2),u=r.add(d),f=new ge(t.x,t.y),g=new rt(o.y-s.y,s.x-o.x),y=o.x*s.y-s.x*o.y,m=new Ue(g.dot(h),g.dot(u),g.dot(f)+y).getRoots();for(const b of m)if(0<=b&&b<=1){const w=t.lerp(e,b),L=e.lerp(n,b),B=w.lerp(L,b);o.x===s.x?i.y<=B.y&&B.y<=a.y&&(c.status="Intersection",c.appendPoint(B)):o.y===s.y?i.x<=B.x&&B.x<=a.x&&(c.status="Intersection",c.appendPoint(B)):i.x<=B.x&&B.x<=a.x&&i.y<=B.y&&B.y<=a.y&&(c.status="Intersection",c.appendPoint(B))}return c}static intersectBezier2Polygon(t,e,n,o){return Y.intersectBezier2Polyline(t,e,n,nn(o))}static intersectBezier2Polyline(t,e,n,o){const s=new Y("No Intersection"),{length:r}=o;for(let i=0;i<r-1;i++){const a=o[i],c=o[i+1],h=Y.intersectBezier2Line(t,e,n,a,c);s.appendPoints(h.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectBezier2Rectangle(t,e,n,o,s){const r=o.min(s),i=o.max(s),a=new ge(i.x,r.y),c=new ge(r.x,i.y),h=Y.intersectBezier2Line(t,e,n,r,a),d=Y.intersectBezier2Line(t,e,n,a,i),u=Y.intersectBezier2Line(t,e,n,i,c),f=Y.intersectBezier2Line(t,e,n,c,r),g=new Y("No Intersection");return g.appendPoints(h.points),g.appendPoints(d.points),g.appendPoints(u.points),g.appendPoints(f.points),g.points.length>0&&(g.status="Intersection"),g}static intersectBezier3Bezier3(t,e,n,o,s,r,i,a){let c,h,d,u;const f=new Y("No Intersection");c=t.multiply(-1),h=e.multiply(3),d=n.multiply(-3),u=c.add(h.add(d.add(o)));const g=new ge(u.x,u.y);c=t.multiply(3),h=e.multiply(-6),d=n.multiply(3),u=c.add(h.add(d));const y=new ge(u.x,u.y);c=t.multiply(-3),h=e.multiply(3),d=c.add(h);const m=new ge(d.x,d.y),b=new ge(t.x,t.y);c=s.multiply(-1),h=r.multiply(3),d=i.multiply(-3),u=c.add(h.add(d.add(a)));const w=new ge(u.x,u.y);c=s.multiply(3),h=r.multiply(-6),d=i.multiply(3),u=c.add(h.add(d));const L=new ge(u.x,u.y);c=s.multiply(-3),h=r.multiply(3),d=c.add(h);const B=new ge(d.x,d.y),H=new ge(s.x,s.y);c=g.x*y.y-y.x*g.y,h=g.x*m.y-m.x*g.y;const E=g.x*b.y-b.x*g.y+H.x*g.y-g.x*H.y,X=B.x*g.y-g.x*B.y,$=L.x*g.y-g.x*L.y,Z=w.x*g.y-g.x*w.y;u=g.x*m.y-m.x*g.y;const se=g.x*b.y+y.x*m.y-m.x*y.y-b.x*g.y+H.x*g.y-g.x*H.y,ne=B.x*g.y-g.x*B.y,ae=L.x*g.y-g.x*L.y,te=w.x*g.y-g.x*w.y,ce=y.x*b.y-b.x*y.y+H.x*y.y-y.x*H.y,pe=B.x*y.y-y.x*B.y,Be=L.x*y.y-y.x*L.y,Re=w.x*y.y-y.x*w.y,Se=g.x*b.y-b.x*g.y+H.x*g.y-g.x*H.y,Te=B.x*g.y-g.x*B.y,fe=L.x*g.y-g.x*L.y,O=w.x*g.y-g.x*w.y,G=y.x*b.y-b.x*y.y+H.x*y.y-y.x*H.y,j=B.x*y.y-y.x*B.y,_=L.x*y.y-y.x*L.y,Ve=w.x*y.y-y.x*w.y,ut=m.x*b.y-b.x*m.y+H.x*m.y-m.x*H.y,yt=B.x*m.y-m.x*B.y,kt=L.x*m.y-m.x*L.y,Ft=w.x*m.y-m.x*w.y,cn=new Ue(-Z*te*O,-Z*te*fe-Z*ae*O-$*te*O,-Z*te*Te-Z*ae*fe-$*te*fe-Z*ne*O-$*ae*O-X*te*O,-Z*te*Se-Z*ae*Te-$*te*Te-Z*ne*fe-$*ae*fe-X*te*fe-Z*se*O-$*ne*O-X*ae*O-E*te*O+h*Re*O+Z*u*Ve-c*Re*Ve+c*te*Ft,-Z*ae*Se-$*te*Se-Z*ne*Te-$*ae*Te-X*te*Te-Z*se*fe-$*ne*fe-X*ae*fe-E*te*fe+h*Re*fe-$*se*O-X*ne*O-E*ae*O+h*Be*O+Z*u*_-c*Re*_+$*u*Ve-c*Be*Ve+c*te*kt+c*ae*Ft,-Z*ne*Se-$*ae*Se-X*te*Se-Z*se*Te-$*ne*Te-X*ae*Te-E*te*Te+h*Re*Te-$*se*fe-X*ne*fe-E*ae*fe+h*Be*fe-X*se*O-E*ne*O+h*pe*O+Z*u*j-c*Re*j+$*u*_-c*Be*_+X*u*Ve-c*pe*Ve+c*te*yt+c*ae*kt+c*ne*Ft,-Z*se*Se-$*ne*Se-X*ae*Se-E*te*Se+h*Re*Se-$*se*Te-X*ne*Te-E*ae*Te+h*Be*Te-X*se*fe-E*ne*fe+h*pe*fe-E*se*O+h*ce*O+Z*u*G-c*Re*G+$*u*j-c*Be*j+X*u*_-c*pe*_+E*u*Ve-c*ce*Ve+c*te*ut+c*ae*yt+c*ne*kt-h*u*Ft+c*se*Ft,-$*se*Se-X*ne*Se-E*ae*Se+h*Be*Se-X*se*Te-E*ne*Te+h*pe*Te-E*se*fe+h*ce*fe+$*u*G-c*Be*G+X*u*j-c*pe*j+E*u*_-c*ce*_+c*ae*ut+c*ne*yt-h*u*kt+c*se*kt,-X*se*Se-E*ne*Se+h*pe*Se-E*se*Te+h*ce*Te+X*u*G-c*pe*G+E*u*j-c*ce*j+c*ne*ut-h*u*yt+c*se*yt,-E*se*Se+h*ce*Se+E*u*G-c*ce*G-h*u*ut+c*se*ut);cn.simplifyEquals();const On=cn.getRootsInInterval(0,1);for(const $e of On){const qn=new Ue(g.x,y.x,m.x,b.x-H.x-$e*B.x-$e*$e*L.x-$e*$e*$e*w.x);qn.simplifyEquals();const Jn=qn.getRoots(),Pn=new Ue(g.y,y.y,m.y,b.y-H.y-$e*B.y-$e*$e*L.y-$e*$e*$e*w.y);Pn.simplifyEquals();const Yt=Pn.getRoots();if(Jn.length>0&&Yt.length>0){e:for(const eo of Jn)if(0<=eo&&eo<=1){for(let mn=0;mn<Yt.length;mn++)if(Math.abs(eo-Yt[mn])<1e-4){f.points.push(w.multiply($e*$e*$e).add(L.multiply($e*$e).add(B.multiply($e).add(H))));break e}}}}return f.points.length>0&&(f.status="Intersection"),f}static intersectBezier3Circle(t,e,n,o,s,r){return Y.intersectBezier3Ellipse(t,e,n,o,s,r,r)}static intersectBezier3Ellipse(t,e,n,o,s,r,i){let a,c,h,d;const u=new Y("No Intersection");a=t.multiply(-1),c=e.multiply(3),h=n.multiply(-3),d=a.add(c.add(h.add(o)));const f=new ge(d.x,d.y);a=t.multiply(3),c=e.multiply(-6),h=n.multiply(3),d=a.add(c.add(h));const g=new ge(d.x,d.y);a=t.multiply(-3),c=e.multiply(3),h=a.add(c);const y=new ge(h.x,h.y),m=new ge(t.x,t.y),b=r*r,w=i*i,B=new Ue(f.x*f.x*w+f.y*f.y*b,2*(f.x*g.x*w+f.y*g.y*b),2*(f.x*y.x*w+f.y*y.y*b)+g.x*g.x*w+g.y*g.y*b,2*f.x*w*(m.x-s.x)+2*f.y*b*(m.y-s.y)+2*(g.x*y.x*w+g.y*y.y*b),2*g.x*w*(m.x-s.x)+2*g.y*b*(m.y-s.y)+y.x*y.x*w+y.y*y.y*b,2*y.x*w*(m.x-s.x)+2*y.y*b*(m.y-s.y),m.x*m.x*w-2*m.y*s.y*b-2*m.x*s.x*w+m.y*m.y*b+s.x*s.x*w+s.y*s.y*b-b*w).getRootsInInterval(0,1);for(const H of B)u.points.push(f.multiply(H*H*H).add(g.multiply(H*H).add(y.multiply(H).add(m))));return u.points.length>0&&(u.status="Intersection"),u}static intersectBezier3Line(t,e,n,o,s,r){let i,a,c,h;const d=s.min(r),u=s.max(r),f=new Y("No Intersection");i=t.multiply(-1),a=e.multiply(3),c=n.multiply(-3),h=i.add(a.add(c.add(o)));const g=new rt(h.x,h.y);i=t.multiply(3),a=e.multiply(-6),c=n.multiply(3),h=i.add(a.add(c));const y=new rt(h.x,h.y);i=t.multiply(-3),a=e.multiply(3),c=i.add(a);const m=new rt(c.x,c.y),b=new rt(t.x,t.y),w=new rt(s.y-r.y,r.x-s.x),L=s.x*r.y-r.x*s.y,B=new Ue(w.dot(g),w.dot(y),w.dot(m),w.dot(b)+L).getRoots();for(const H of B)if(0<=H&&H<=1){const E=t.lerp(e,H),X=e.lerp(n,H),$=n.lerp(o,H),Z=E.lerp(X,H),se=X.lerp($,H),ne=Z.lerp(se,H);s.x===r.x?d.y<=ne.y&&ne.y<=u.y&&(f.status="Intersection",f.appendPoint(ne)):s.y===r.y?d.x<=ne.x&&ne.x<=u.x&&(f.status="Intersection",f.appendPoint(ne)):d.x<=ne.x&&ne.x<=u.x&&d.y<=ne.y&&ne.y<=u.y&&(f.status="Intersection",f.appendPoint(ne))}return f}static intersectBezier3Polygon(t,e,n,o,s){return Y.intersectBezier3Polyline(t,e,n,o,nn(s))}static intersectBezier3Polyline(t,e,n,o,s){const r=new Y("No Intersection"),{length:i}=s;for(let a=0;a<i-1;a++){const c=s[a],h=s[a+1],d=Y.intersectBezier3Line(t,e,n,o,c,h);r.appendPoints(d.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectBezier3Rectangle(t,e,n,o,s,r){const i=s.min(r),a=s.max(r),c=new ge(a.x,i.y),h=new ge(i.x,a.y),d=Y.intersectBezier3Line(t,e,n,o,i,c),u=Y.intersectBezier3Line(t,e,n,o,c,a),f=Y.intersectBezier3Line(t,e,n,o,a,h),g=Y.intersectBezier3Line(t,e,n,o,h,i),y=new Y("No Intersection");return y.appendPoints(d.points),y.appendPoints(u.points),y.appendPoints(f.points),y.appendPoints(g.points),y.points.length>0&&(y.status="Intersection"),y}static intersectCircleCircle(t,e,n,o){let s;const r=e+o,i=Math.abs(e-o),a=t.distanceFrom(n);if(a>r)s=new Y("Outside");else if(a<i)s=new Y("Inside");else{s=new Y("Intersection");const c=(e*e-o*o+a*a)/(2*a),h=Math.sqrt(e*e-c*c),d=t.lerp(n,c/a),u=h/a;s.points.push(new ge(d.x-u*(n.y-t.y),d.y+u*(n.x-t.x))),s.points.push(new ge(d.x+u*(n.y-t.y),d.y-u*(n.x-t.x)))}return s}static intersectCircleEllipse(t,e,n,o,s){return Y.intersectEllipseEllipse(t,e,e,n,o,s)}static intersectCircleLine(t,e,n,o){let s;const r=(o.x-n.x)*(o.x-n.x)+(o.y-n.y)*(o.y-n.y),i=2*((o.x-n.x)*(n.x-t.x)+(o.y-n.y)*(n.y-t.y)),a=t.x*t.x+t.y*t.y+n.x*n.x+n.y*n.y-2*(t.x*n.x+t.y*n.y)-e*e,c=i*i-4*r*a;if(c<0)s=new Y("Outside");else if(c===0)s=new Y("Tangent");else{const h=Math.sqrt(c),d=(-i+h)/(2*r),u=(-i-h)/(2*r);(d<0||d>1)&&(u<0||u>1)?d<0&&u<0||d>1&&u>1?s=new Y("Outside"):s=new Y("Inside"):(s=new Y("Intersection"),0<=d&&d<=1&&s.points.push(n.lerp(o,d)),0<=u&&u<=1&&s.points.push(n.lerp(o,u)))}return s}static intersectCirclePolygon(t,e,n){return Y.intersectCirclePolyline(t,e,nn(n))}static intersectCirclePolyline(t,e,n){const o=new Y("No Intersection"),{length:s}=n;let r;for(let i=0;i<s-1;i++){const a=n[i],c=n[i+1];r=Y.intersectCircleLine(t,e,a,c),o.appendPoints(r.points)}return o.points.length>0?o.status="Intersection":o.status=r.status,o}static intersectCircleRectangle(t,e,n,o){const s=n.min(o),r=n.max(o),i=new ge(r.x,s.y),a=new ge(s.x,r.y),c=Y.intersectCircleLine(t,e,s,i),h=Y.intersectCircleLine(t,e,i,r),d=Y.intersectCircleLine(t,e,r,a),u=Y.intersectCircleLine(t,e,a,s),f=new Y("No Intersection");return f.appendPoints(c.points),f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0?f.status="Intersection":f.status=c.status,f}static intersectEllipseEllipse(t,e,n,o,s,r){const i=[n*n,0,e*e,-2*n*n*t.x,-2*e*e*t.y,n*n*t.x*t.x+e*e*t.y*t.y-e*e*n*n],a=[r*r,0,s*s,-2*r*r*o.x,-2*s*s*o.y,r*r*o.x*o.x+s*s*o.y*o.y-s*s*r*r],h=Eh(i,a).getRoots(),d=.001,u=(i[0]*i[0]+2*i[1]*i[1]+i[2]*i[2])*d,f=(a[0]*a[0]+2*a[1]*a[1]+a[2]*a[2])*d,g=new Y("No Intersection");for(let y=0;y<h.length;y++){const b=new Ue(i[0],i[3]+h[y]*i[1],i[5]+h[y]*(i[4]+h[y]*i[2])).getRoots();for(let w=0;w<b.length;w++){let L=(i[0]*b[w]+i[1]*h[y]+i[3])*b[w]+(i[2]*h[y]+i[4])*h[y]+i[5];Math.abs(L)<u&&(L=(a[0]*b[w]+a[1]*h[y]+a[3])*b[w]+(a[2]*h[y]+a[4])*h[y]+a[5],Math.abs(L)<f&&g.appendPoint(new ge(b[w],h[y])))}}return g.points.length>0&&(g.status="Intersection"),g}static intersectEllipseLine(t,e,n,o,s){let r;const i=new rt(o.x,o.y),a=rt.fromPoints(o,s),c=new rt(t.x,t.y),h=i.subtract(c),d=new rt(a.x/(e*e),a.y/(n*n)),u=new rt(h.x/(e*e),h.y/(n*n)),f=a.dot(d),g=a.dot(u);t=h.dot(u)-1;const y=g*g-f*t;if(y<0)r=new Y("Outside");else if(y>0){const m=Math.sqrt(y),b=(-g-m)/f,w=(-g+m)/f;(b<0||1<b)&&(w<0||1<w)?b<0&&w<0||b>1&&w>1?r=new Y("Outside"):r=new Y("Inside"):(r=new Y("Intersection"),0<=b&&b<=1&&r.appendPoint(o.lerp(s,b)),0<=w&&w<=1&&r.appendPoint(o.lerp(s,w)))}else{const m=-g/f;0<=m&&m<=1?(r=new Y("Intersection"),r.appendPoint(o.lerp(s,m))):r=new Y("Outside")}return r}static intersectEllipsePolygon(t,e,n,o){return Y.intersectEllipsePolyline(t,e,n,nn(o))}static intersectEllipsePolyline(t,e,n,o){const s=new Y("No Intersection"),{length:r}=o;for(let i=0;i<r-1;i++){const a=o[i],c=o[i+1],h=Y.intersectEllipseLine(t,e,n,a,c);s.appendPoints(h.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectEllipseRectangle(t,e,n,o,s){const r=o.min(s),i=o.max(s),a=new ge(i.x,r.y),c=new ge(r.x,i.y),h=Y.intersectEllipseLine(t,e,n,r,a),d=Y.intersectEllipseLine(t,e,n,a,i),u=Y.intersectEllipseLine(t,e,n,i,c),f=Y.intersectEllipseLine(t,e,n,c,r),g=new Y("No Intersection");return g.appendPoints(h.points),g.appendPoints(d.points),g.appendPoints(u.points),g.appendPoints(f.points),g.points.length>0&&(g.status="Intersection"),g}static intersectLineLine(t,e,n,o){let s;const r=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),i=(e.x-t.x)*(t.y-n.y)-(e.y-t.y)*(t.x-n.x),a=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y);if(a!==0){const c=r/a,h=i/a;0<=c&&c<=1&&0<=h&&h<=1?(s=new Y("Intersection"),s.points.push(new ge(t.x+c*(e.x-t.x),t.y+c*(e.y-t.y)))):s=new Y("No Intersection")}else r===0||i===0?s=new Y("Coincident"):s=new Y("Parallel");return s}static intersectLinePolygon(t,e,n){return Y.intersectLinePolyline(t,e,nn(n))}static intersectLinePolyline(t,e,n){const o=new Y("No Intersection"),{length:s}=n;for(let r=0;r<s-1;r++){const i=n[r],a=n[r+1],c=Y.intersectLineLine(t,e,i,a);o.appendPoints(c.points)}return o.points.length>0&&(o.status="Intersection"),o}static intersectLineRectangle(t,e,n,o){const s=n.min(o),r=n.max(o),i=new ge(r.x,s.y),a=new ge(s.x,r.y),c=Y.intersectLineLine(s,i,t,e),h=Y.intersectLineLine(i,r,t,e),d=Y.intersectLineLine(r,a,t,e),u=Y.intersectLineLine(a,s,t,e),f=new Y("No Intersection");return f.appendPoints(c.points),f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0&&(f.status="Intersection"),f}static intersectPolygonPolygon(t,e){return Y.intersectPolylinePolyline(nn(t),nn(e))}static intersectPolygonPolyline(t,e){return Y.intersectPolylinePolyline(nn(t),e)}static intersectPolygonRectangle(t,e,n){return Y.intersectPolylineRectangle(nn(t),e,n)}static intersectPolylinePolyline(t,e){const n=new Y("No Intersection"),{length:o}=t;for(let s=0;s<o-1;s++){const r=t[s],i=t[s+1],a=Y.intersectLinePolyline(r,i,e);n.appendPoints(a.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectPolylineRectangle(t,e,n){const o=e.min(n),s=e.max(n),r=new ge(s.x,o.y),i=new ge(o.x,s.y),a=Y.intersectLinePolyline(o,r,t),c=Y.intersectLinePolyline(r,s,t),h=Y.intersectLinePolyline(s,i,t),d=Y.intersectLinePolyline(i,o,t),u=new Y("No Intersection");return u.appendPoints(a.points),u.appendPoints(c.points),u.appendPoints(h.points),u.appendPoints(d.points),u.points.length>0&&(u.status="Intersection"),u}static intersectRectangleRectangle(t,e,n,o){const s=t.min(e),r=t.max(e),i=new ge(r.x,s.y),a=new ge(s.x,r.y),c=Y.intersectLineRectangle(s,i,n,o),h=Y.intersectLineRectangle(i,r,n,o),d=Y.intersectLineRectangle(r,a,n,o),u=Y.intersectLineRectangle(a,s,n,o),f=new Y("No Intersection");return f.appendPoints(c.points),f.appendPoints(h.points),f.appendPoints(d.points),f.appendPoints(u.points),f.points.length>0&&(f.status="Intersection"),f}static intersectRayRay(t,e,n,o){let s;const r=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),i=(e.x-t.x)*(t.y-n.y)-(e.y-t.y)*(t.x-n.x),a=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y);if(a!==0){const c=r/a;s=new Y("Intersection"),s.points.push(new ge(t.x+c*(e.x-t.x),t.y+c*(e.y-t.y)))}else r===0||i===0?s=new Y("Coincident"):s=new Y("Parallel");return s}appendPoint(t){this.points.push(t)}appendPoints(t){this.points=this.points.concat(t)}}class Fn extends en{constructor(){super(...arguments);p(this,"imgBitmap",null);p(this,"fallbackDrawer",new Ah);p(this,"broken",!1)}setBroken(e=!0){this.broken=e}setImageBitmap(e){this.imgBitmap=e}get borderProps(){return this.props.get(I.Border)}get cropProps(){return this.props.get(I.Crop)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){if(!this.imgBitmap){this.broken&&this.fallbackDrawer.fallbackDraw(this,e);return}e.save();const{a:n,b:o,c:s,d:r,e:i,f:a}=this.globalTransform();e.transform(n,o,s,r,i,a),this.clipDrawImage(e,this.imgBitmap),this.clipDrawBorder(e),e.restore()}clipDrawBorder(e){const n=this.borderProps,o=this.cropProps,s=this.baseProps;if(n.color!==""&&n.dashType!==et.None){if(S.setDashLine(n,e),e.strokeStyle=n.color,e.lineWidth=n.width,e.globalAlpha=n.alpha,o.cropType===wt.Circle){const r=.5*Math.min(s.width,s.height);e.beginPath(),e.arc(.5*s.width,.5*s.height,r,0,2*Math.PI),e.stroke();return}if(o.cropType===wt.RoundRect){e.beginPath(),e.roundRect(0,0,s.width,s.height,10),e.stroke();return}e.strokeRect(0,0,s.width,s.height)}}clipDrawImage(e,n){const o=this.cropProps,s=this.baseProps;if(o.cropType===wt.None)e.drawImage(n,0,0,s.width,s.height);else{if(e.save(),o.cropType===wt.RoundRect&&(e.beginPath(),e.roundRect(0,0,s.width,s.height,10),e.clip()),o.cropType===wt.Circle){const b=.5*Math.min(s.width,s.height);e.beginPath(),e.arc(.5*s.width,.5*s.height,b,0,2*Math.PI),e.clip()}const{imgX:r,imgY:i,imgWidth:a,imgHeight:c}=o.cropInfo,h=this.getImgSize(),d=a/h.imgWidth,u=c/h.imgHeight,f=-r/d,g=-i/u,y=s.width/d,m=s.height/u;e.drawImage(n,f,g,y,m,0,0,s.width,s.height),e.restore()}}getImgSize(){if(!this.imgBitmap){console.warn("img bitmap不存在,已经降级处理");const{width:o,height:s}=this.baseProps;return{imgWidth:o,imgHeight:s}}const e=this.imgBitmap.width,n=this.imgBitmap.height;return{imgWidth:e,imgHeight:n}}getOriginImageRect(){const{cropType:e,cropInfo:n}=this.cropProps;if(e===wt.None||!n){const a=this.baseProps;return new D(0,0,a.width,a.height)}const{imgX:o,imgY:s,imgWidth:r,imgHeight:i}=n;return new D(o,s,r,i)}getTextContentRect(){return this.baseProps}getConnectAnchor(){return[new P(.5,0),new P(1,.5),new P(.5,1),new P(0,.5)]}borderContains(e,n){const o=this.toLocal(e),{width:s,height:r}=this.baseProps,i=q.rectangle({top:0,left:0,width:s,height:r}),a=q.line({x:o.x-n,y:o.y},{x:o.x+n,y:o.y}),c=q.line({x:o.x,y:o.y-n},{x:o.x,y:o.y+n});for(const h of[a,c]){const d=Y.intersect(i,h);if(d.points.length>0)return d.points[0]}return null}}class ro extends Fn{constructor(e,n){super(e,n);p(this,"type",v.IMG);this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Image,new oo),this.props.set(I.Crop,new Mn)}get imgSrc(){return this.getProp(I.Image).url}static load(e,n,o,s,r,i){const a=new ro(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class Oh{draw(t,e){const n=t.getDrawPoints();if(n.length<2){console.error("line has no point!");return}const o=n[0],s=n.length>1?n[n.length-1]:{...o};e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.stroke()}textContentBounds(t){const e=t.baseProps;return{x:e.x,y:e.y,width:e.width,height:e.height}}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class wi{static lineContainsPoint(t,e,n){const o=t.shapeType,s=[...t.points];return o===he.Line?this.simpleLineContains(s,e,n):t.isPolyLine()?this.polyLineContains(s,e,n):o===he.Curve?this.curveLineContains(s,e,n):!1}static overlapRectNode(t,e){const n=t.shapeType,o=[...t.points],s=q.rectangle({top:e.minY,left:e.minX,width:e.maxX-e.minX,height:e.maxY-e.minY});if(n===he.Line){const r=q.line(o[0],o[o.length-1]);if(Y.intersect(s,r).points.length>0)return!0}if(t.isPolyLine()){const r=q.polyline(o);if(Y.intersect(s,r).points.length>0)return!0}if(n===he.Curve)for(let r=0;r<o.length-2;r=r+3){const i=o[r],a=o[r+1],c=o[r+2],h=o[r+3],d=q.cubicBezier(i,a,c,h);if(Y.intersect(s,d).points.length>0)return!0}return!1}static curveLineContains(t,e,n){for(let o=0;o<t.length-2;o=o+3){const s=t[o],r=t[o+1],i=t[o+2],a=t[o+3],c=q.cubicBezier(s,r,i,a),h=q.circle(e,n);if(Y.intersect(h,c).points.length>0)return!0}return!1}static polyLineContains(t,e,n){const o=q.polyline(t),s=q.circle(e,n);return Y.intersect(s,o).points.length>0}static simpleLineContains(t,e,n){const o=q.line(t[0],t[t.length-1]),s=q.circle(e,n);return Y.intersect(s,o).points.length>0}}class Xh{constructor(){p(this,"radius",8)}draw(t,e){const n=t.getDrawPoints();if(n.length<2)return;e.save(),e.beginPath();const o=n[0];e.moveTo(o.x,o.y);for(const s of n)e.lineTo(s.x,s.y);e.stroke(),e.restore()}textContentBounds(t){const e=t.baseProps;return new D(e.x,e.y,e.width,e.height)}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class zh{draw(t,e){const n=t.getDrawPoints();if(!(n.length<3)){e.save(),e.beginPath();for(let o=1;o<n.length-2;o=o+3){const s=n[o-1],r=n[o],i=n[o+1],a=n[o+2];e.moveTo(s.x,s.y),e.bezierCurveTo(r.x,r.y,i.x,i.y,a.x,a.y)}e.stroke(),e.restore()}}textContentBounds(t){const e=t.baseProps;return{x:e.x,y:e.y,width:e.width,height:e.height}}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Wh{constructor(){p(this,"radius",8)}draw(t,e){const n=t.getDrawPoints();n.length<2||(e.save(),e.beginPath(),t.points.length===2?(e.moveTo(n[0].x,n[0].y),e.lineTo(n[1].x,n[1].y),e.stroke()):this.acrPolyDraw(e,n),e.restore())}textContentBounds(t){const e=t.baseProps;return new D(e.x,e.y,e.width,e.height)}acrPolyDraw(t,e){const n=e[e.length-1],o=this.dealArcPoly(e);for(const s of o)t.moveTo(s.p0.x,s.p0.y),t.lineTo(s.p1.x,s.p1.y),t.arcTo(s.arcDraw.a.x,s.arcDraw.a.y,s.arcDraw.b.x,s.arcDraw.b.y,s.arcDraw.r);t.lineTo(n.x,n.y),t.stroke()}dealArcPoly(t){const e=[];let n=t[0];for(let o=0;o<t.length-2;o=o+1){const s=n,r=t[o+1],i=t[o+2];if(S.judgeHorizon(s,r)){const c=.5*Math.abs(s.x-r.x),h=.5*Math.abs(r.y-i.y),d=c>h?h:c,u=this.radius<d?this.radius:d,f=u,g=r.x>s.x?1:-1,y=i.y>r.y?1:-1;n=new P(r.x,r.y+y*f);const m={p0:s,p1:new P(r.x-g*f,r.y),arcDraw:{a:r,b:n,r:u}};e.push(m)}else{const c=.5*Math.abs(s.y-r.y),h=.5*Math.abs(r.x-i.x),d=c>h?h:c,u=this.radius<d?this.radius:d,f=u,g=r.y>s.y?1:-1,y=i.x>r.x?1:-1;n=new P(r.x+y*f,r.y);const m={p0:s,p1:new P(r.x,r.y-g*f),arcDraw:{a:r,b:n,r:u}};e.push(m)}}return e}borderContains(t,e,n){return null}getConnectAnchor(){return[]}}class Fe{constructor(t,e,n){p(this,"paragraphIndex");p(this,"lineIndex");p(this,"charIndex");this.paragraphIndex=t,this.lineIndex=e,this.charIndex=n}static head(){return new Fe(0,0,-1)}clone(){return new Fe(this.paragraphIndex,this.lineIndex,this.charIndex)}equal(t){return this.paragraphIndex===t.paragraphIndex&&this.lineIndex===t.lineIndex&&this.charIndex===t.charIndex}greaterThan(t){return this.paragraphIndex>t.paragraphIndex?!0:this.paragraphIndex<t.paragraphIndex?!1:this.lineIndex>t.lineIndex?!0:this.lineIndex<t.lineIndex?!1:this.charIndex>t.charIndex?!0:!(this.charIndex<t.charIndex)}}class Cs{constructor(){p(this,"lines",[]);p(this,"index",0);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"paragraphStyle",null)}addLine(t){t.y=this.height,t.index=this.lines.length,this.lines.push(t),this.width=Math.max(t.width,this.width),this.height=this.height+t.height}contains(t){return S.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}headCursorPosition(){return new Fe(this.index,0,-1)}tailCursorPosition(){if(this.lines.length===0)return new Fe(this.index,-1,-1);const t=this.lines.length-1,n=this.lines[t].getCharLength();return n===0?new Fe(this.index,t,-1):new Fe(this.index,t,n-1)}detect(t){const{x:e,y:n}=t;if(n<0||n>this.height||this.lines.length===0)return null;for(let o=0;o<this.lines.length;o++){const s=this.lines[o];if(n>=s.y&&n<s.y+s.height){const r=new P(t.x-s.x,t.y-s.y),i=s.detect(r);return{lineIndex:s.index,charIndex:i}}}return null}getLine(t){return t<0||this.lines.length===0?null:t>this.lines.length-1?(console.warn("index 超出该段最大数目,fall back处理"),this.lines[this.lines.length-1]):this.lines[t]}draw(t,e){for(const n of this.lines){const o=new P(e.x+this.x,e.y+this.y);n.draw(t,o)}}alignHorizon(t,e){for(const n of this.lines)t===at.Bottom&&(n.x=e-n.width),t===at.Middle&&(n.x=.5*e-.5*n.width)}toString(){let t="";for(const e of this.lines)t+=e.toString();return t+`
4
+ `}toRichTextXML(t){let e="<p>";for(const n of this.lines)e+=n.toRichTextXML(t);return e+"</p>"}prevToRichTextXML(t,e){let n="";for(let o=0;o<t;o++){const s=this.lines[o];n+=s.toRichTextXML(e)}return n}nextToRichTextXML(t,e){let n="";for(let o=t+1;o<this.lines.length;o++){const s=this.lines[o];n+=s.toRichTextXML(e)}return n}}class Yn{constructor(){p(this,"textBlocks",[]);p(this,"index",0);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"boxAscent",0)}contains(t){return S.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}getCharLength(){let t=0;return this.textBlocks.forEach(e=>t+=e.characters.length),t}detect(t){const{x:e,y:n}=t;if(n<0||e<0)return-1;const o=this.getCharLength();if(n>this.height||e>this.width)return o-1;if(o===0)return-1;let s=0;for(let r=0;r<this.textBlocks.length;r++){const i=this.textBlocks[r];for(let a=0;a<i.characters.length;a++){const c=i.characters[a],h=i.x+c.x+.5*c.width;if(e<h)return s-1;s++}}return o-1}addTextBlock(t){if(this.textBlocks.length>0){const e=this.textBlocks[this.textBlocks.length-1];if(e.fontSize===t.fontSize&&e.fontFamily===t.fontFamily&&e.fontColor===t.fontColor&&e.fontBgColor===t.fontBgColor&&e.bold===t.bold&&e.italic===t.italic&&e.underline===t.underline&&e.strikethrough===t.strikethrough){for(const n of t.characters)e.addCharacter(n);e.text+=t.text,this.width=this.width+t.width,this.height=Math.max(this.height,e.height),this.boxAscent=Math.max(e.height,this.boxAscent);return}}t.x=this.width,t.y=0,this.textBlocks.push(t),this.width=this.width+t.width,this.height=Math.max(this.height,t.height),this.boxAscent=Math.max(t.height,this.boxAscent)}getBlockIndex(t){const e=this.getCharLength();if(t<0||e===0)return this.textBlocks.length>0?{textBlock:this.textBlocks[0],charIndex:-1,blockIndex:0}:null;if(t>e-1){console.warn("index 超出该行最大字符数目,fall back处理");const o=this.textBlocks[this.textBlocks.length-1];return{textBlock:o,charIndex:o.characters.length-1,blockIndex:this.textBlocks.length-1}}let n=0;for(let o=0;o<this.textBlocks.length;o++){const s=this.textBlocks[o];if(t-n<s.characters.length)return{textBlock:s,charIndex:t-n,blockIndex:o};n+=s.characters.length}return null}getCharacter(t){const e=this.getCharLength();if(t<0||e===0)return null;if(t>e-1){console.warn("index 超出该行最大字符数目,fall back处理");const o=this.textBlocks[this.textBlocks.length-1];return{character:o.characters[o.characters.length-1],textBlock:o,charIndex:o.characters.length-1,blockIndex:this.textBlocks.length-1}}let n=0;for(let o=0;o<this.textBlocks.length;o++){const s=this.textBlocks[o];if(t-n<s.characters.length)return{character:s.characters[t-n],textBlock:s,charIndex:t-n,blockIndex:o};n+=s.characters.length}return null}draw(t,e){const n=e.x+this.x,o=e.y+this.y,s=new P(n,o);for(const r of this.textBlocks)r.draw(t,s,this.height)}toString(){let t="";for(const e of this.textBlocks)t+=e.toString();return t}toRichTextXML(t){let e="";for(const n of this.textBlocks)e+=n.toRichTextXML(t);return e}prevToRichTextXML(t,e){let n="";for(let o=0;o<t;o++){const s=this.textBlocks[o];n+=s.toRichTextXML(e)}return n}nextToRichTextXML(t,e){let n="";for(let o=t+1;o<this.textBlocks.length;o++){const s=this.textBlocks[o];n+=s.toRichTextXML(e)}return n}}class Pi{constructor(){p(this,"parser",new DOMParser)}parseBooleanAttribute(t){if(t!=null){if(typeof t=="boolean")return t;if(typeof t=="string"){const e=t.toLowerCase().trim();if(e==="true")return!0;if(e==="false")return!1}}}parse(t,e){const n=[],o=this.parseRichText(t);for(const s of o){const r=this.computeTextBlocks(s,e);n.push({textBlocks:r})}return n}escapeXmlText(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}preprocessXmlString(t){return t.replace(/>([^<>]+)</g,(e,n)=>{if(/[&<>"']/.test(n)){const o=[];let s=n.replace(/&(?:amp|lt|gt|quot|apos);/g,r=>(o.push(r),`__ENTITY_${o.length-1}__`));return s=this.escapeXmlText(s),s=s.replace(/__ENTITY_(\d+)__/g,(r,i)=>o[parseInt(i)]),`>${s}<`}return e})}parseRichText(t){if(!t)return[{textBlocks:[]}];const e=this.preprocessXmlString(t),n=this.parser.parseFromString(e,"text/xml"),o=n.querySelector("parsererror");if(o)return console.error("解析富文本样式失败:",o,t),[{textBlocks:[t]}];const s=[],r=n.documentElement;for(const i of r.childNodes){const a=this.flattenNodes(i);s.push({textBlocks:a})}return s}flattenNodes(t){const e=[];for(const n of t.childNodes)if(n.nodeType===Node.TEXT_NODE){const o=n.textContent;o&&e.push(o)}else if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.tagName.toLowerCase()==="style"){const r=o.textContent||"",i={text:""};o.childNodes.length>0?i.text=this.flattenNodes(o):i.text=r;const a=o.getAttribute("color");a&&(i.fontColor=a);const c=o.getAttribute("bg-color");c&&(i.fontBgColor=c);const h=o.getAttribute("bold"),d=this.parseBooleanAttribute(h);d!==void 0&&(i.bold=d);const u=o.getAttribute("italic"),f=this.parseBooleanAttribute(u);f!==void 0&&(i.italic=f);const g=o.getAttribute("font-size");g&&(i.fontSize=parseFloat(g));const y=o.getAttribute("underline"),m=this.parseBooleanAttribute(y);m!==void 0&&(i.underline=m);const b=o.getAttribute("strikethrough"),w=this.parseBooleanAttribute(b);w!==void 0&&(i.strikethrough=w),e.push(i)}}return e}computeTextBlocks(t,e){const n=[];for(const o of t.textBlocks)this.makeupTextBlock(o,e,n);return n}makeupTextBlock(t,e,n){if(typeof t=="string"){n.push(this.makeupTextBlockOfText(t,e));return}const o=t.text;if(typeof o=="string"){n.push(this.makeupTextBlockOfCacheTextBlock(t,e));return}if(!(o instanceof Array))return;const s={...e,...this.computeTextProps(t,e)};for(const r of o)this.makeupTextBlock(r,s,n)}makeupTextBlockOfText(t,e){return{text:t,fontSize:e.fontSize,fontFamily:e.fontFamily,fontColor:e.fontColor,fontBgColor:e.fontBgColor,bold:e.bold,italic:e.italic,underline:e.underline,strikethrough:e.strikethrough}}makeupTextBlockOfCacheTextBlock(t,e){return{...this.computeTextProps(t,e),text:t.text}}computeTextProps(t,e){return{text:"",fontSize:t.fontSize!==void 0?t.fontSize:e.fontSize,fontFamily:t.fontFamily!==void 0?t.fontFamily:e.fontFamily,fontColor:t.fontColor!==void 0?t.fontColor:e.fontColor,fontBgColor:t.fontBgColor!==void 0?t.fontBgColor:e.fontBgColor,bold:t.bold!==void 0?t.bold:e.bold,italic:t.italic!==void 0?t.italic:e.italic,underline:t.underline!==void 0?t.underline:e.underline,strikethrough:t.strikethrough!==void 0?t.strikethrough:e.strikethrough}}}class As{constructor(t,e,n,o,s,r){p(this,"charText");p(this,"index",0);p(this,"x");p(this,"y");p(this,"width");p(this,"height");p(this,"boxAscent");this.charText=t,this.x=e,this.y=n,this.width=o,this.height=s,this.boxAscent=r}contains(t){return S.rectContains2(t,{minX:this.x,maxX:this.x+this.width,minY:this.y,maxY:this.y+this.height})}toString(){return this.charText}}class Ro{constructor(){p(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"grapheme"}))}split(t){return Array.from(this.segmentWorker.segment(t)).map(n=>n.segment)}}const Eo=new Ro;class Fh{measureParagraphs(t,e){for(const n of e)this.measure(t,n)}measure(t,e){for(const n of e.textBlocks){const{fontSize:o,fontFamily:s,italic:r,bold:i,text:a}=n;t.font=S.calcFont(o,s,i,r);const c=Eo.split(a),h=[];for(const d of c){const{width:u,height:f,boxAscent:g}=S.measureText(t,d),y=new As(d,0,0,u,f,g);h.push(y)}n.characters=h}}}var io=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ns(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}function Yh(l){if(l.__esModule)return l;var t=l.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(l).forEach(function(n){var o=Object.getOwnPropertyDescriptor(l,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return l[n]}})}),e}var ks=0,mi=-3;function ao(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Gh(l,t){this.source=l,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new ao,this.dtree=new ao}var bi=new ao,Si=new ao,Bs=new Uint8Array(30),Rs=new Uint16Array(30),Mi=new Uint8Array(30),vi=new Uint16Array(30),Uh=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ii=new ao,Ut=new Uint8Array(320);function Ti(l,t,e,n){var o,s;for(o=0;o<e;++o)l[o]=0;for(o=0;o<30-e;++o)l[o+e]=o/e|0;for(s=n,o=0;o<30;++o)t[o]=s,s+=1<<l[o]}function _h(l,t){var e;for(e=0;e<7;++e)l.table[e]=0;for(l.table[7]=24,l.table[8]=152,l.table[9]=112,e=0;e<24;++e)l.trans[e]=256+e;for(e=0;e<144;++e)l.trans[24+e]=e;for(e=0;e<8;++e)l.trans[168+e]=280+e;for(e=0;e<112;++e)l.trans[176+e]=144+e;for(e=0;e<5;++e)t.table[e]=0;for(t.table[5]=32,e=0;e<32;++e)t.trans[e]=e}var Li=new Uint16Array(16);function Es(l,t,e,n){var o,s;for(o=0;o<16;++o)l.table[o]=0;for(o=0;o<n;++o)l.table[t[e+o]]++;for(l.table[0]=0,s=0,o=0;o<16;++o)Li[o]=s,s+=l.table[o];for(o=0;o<n;++o)t[e+o]&&(l.trans[Li[t[e+o]]++]=o)}function $h(l){l.bitcount--||(l.tag=l.source[l.sourceIndex++],l.bitcount=7);var t=l.tag&1;return l.tag>>>=1,t}function _t(l,t,e){if(!t)return e;for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var n=l.tag&65535>>>16-t;return l.tag>>>=t,l.bitcount-=t,n+e}function Hs(l,t){for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var e=0,n=0,o=0,s=l.tag;do n=2*n+(s&1),s>>>=1,++o,e+=t.table[o],n-=t.table[o];while(n>=0);return l.tag=s,l.bitcount-=o,t.trans[e+n]}function jh(l,t,e){var n,o,s,r,i,a;for(n=_t(l,5,257),o=_t(l,5,1),s=_t(l,4,4),r=0;r<19;++r)Ut[r]=0;for(r=0;r<s;++r){var c=_t(l,3,0);Ut[Uh[r]]=c}for(Es(Ii,Ut,0,19),i=0;i<n+o;){var h=Hs(l,Ii);switch(h){case 16:var d=Ut[i-1];for(a=_t(l,2,3);a;--a)Ut[i++]=d;break;case 17:for(a=_t(l,3,3);a;--a)Ut[i++]=0;break;case 18:for(a=_t(l,7,11);a;--a)Ut[i++]=0;break;default:Ut[i++]=h;break}}Es(t,Ut,0,n),Es(e,Ut,n,o)}function Ci(l,t,e){for(;;){var n=Hs(l,t);if(n===256)return ks;if(n<256)l.dest[l.destLen++]=n;else{var o,s,r,i;for(n-=257,o=_t(l,Bs[n],Rs[n]),s=Hs(l,e),r=l.destLen-_t(l,Mi[s],vi[s]),i=r;i<r+o;++i)l.dest[l.destLen++]=l.dest[i]}}}function Vh(l){for(var t,e,n;l.bitcount>8;)l.sourceIndex--,l.bitcount-=8;if(t=l.source[l.sourceIndex+1],t=256*t+l.source[l.sourceIndex],e=l.source[l.sourceIndex+3],e=256*e+l.source[l.sourceIndex+2],t!==(~e&65535))return mi;for(l.sourceIndex+=4,n=t;n;--n)l.dest[l.destLen++]=l.source[l.sourceIndex++];return l.bitcount=0,ks}function Kh(l,t){var e=new Gh(l,t),n,o,s;do{switch(n=$h(e),o=_t(e,2,0),o){case 0:s=Vh(e);break;case 1:s=Ci(e,bi,Si);break;case 2:jh(e,e.ltree,e.dtree),s=Ci(e,e.ltree,e.dtree);break;default:s=mi}if(s!==ks)throw new Error("Data error")}while(!n);return e.destLen<e.dest.length?typeof e.dest.slice=="function"?e.dest.slice(0,e.destLen):e.dest.subarray(0,e.destLen):e.dest}_h(bi,Si),Ti(Bs,Rs,4,3),Ti(Mi,vi,2,1),Bs[28]=0,Rs[28]=258;var Qh=Kh;const Zh=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,Ai=(l,t,e)=>{let n=l[t];l[t]=l[e],l[e]=n},qh=l=>{const t=l.length;for(let e=0;e<t;e+=4)Ai(l,e,e+3),Ai(l,e+1,e+2)};var Jh={swap32LE:l=>{Zh&&qh(l)}};const Ni=Qh,{swap32LE:ed}=Jh,Ds=11,Ln=5,td=Ds-Ln,nd=65536>>Ds,od=(1<<td)-1,Ho=2,Os=(1<<Ln)-1,ki=65536>>Ln,sd=1024>>Ln,rd=ki+sd+32,id=1<<Ho;class ad{constructor(t){const e=typeof t.readUInt32BE=="function"&&typeof t.slice=="function";if(e||t instanceof Uint8Array){let n;if(e)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),n=t.readUInt32LE(8),t=t.slice(12);else{const o=new DataView(t.buffer);this.highStart=o.getUint32(0,!0),this.errorValue=o.getUint32(4,!0),n=o.getUint32(8,!0),t=t.subarray(12)}t=Ni(t,new Uint8Array(n)),t=Ni(t,new Uint8Array(n)),ed(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let e;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(e=(this.data[t>>Ln]<<Ho)+(t&Os),this.data[e]):t<=65535?(e=(this.data[ki+(t-55296>>Ln)]<<Ho)+(t&Os),this.data[e]):t<this.highStart?(e=this.data[rd-nd+(t>>Ds)],e=this.data[e+(t>>Ln&od)],e=(e<<Ho)+(t&Os),this.data[e]):this.data[this.data.length-id]}}var cd=ad;const ld=Ns(cd);var Bi={};(function(l){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){var n=typeof Uint8Array<"u"?Uint8Array:Array,o=43,s=47,r=48,i=97,a=65,c=45,h=95;function d(g){var y=g.charCodeAt(0);if(y===o||y===c)return 62;if(y===s||y===h)return 63;if(y<r)return-1;if(y<r+10)return y-r+26+26;if(y<a+26)return y-a;if(y<i+26)return y-i+26}function u(g){var y,m,b,w,L,B;if(g.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var H=g.length;L=g.charAt(H-2)==="="?2:g.charAt(H-1)==="="?1:0,B=new n(g.length*3/4-L),b=L>0?g.length-4:g.length;var E=0;function X($){B[E++]=$}for(y=0,m=0;y<b;y+=4,m+=3)w=d(g.charAt(y))<<18|d(g.charAt(y+1))<<12|d(g.charAt(y+2))<<6|d(g.charAt(y+3)),X((w&16711680)>>16),X((w&65280)>>8),X(w&255);return L===2?(w=d(g.charAt(y))<<2|d(g.charAt(y+1))>>4,X(w&255)):L===1&&(w=d(g.charAt(y))<<10|d(g.charAt(y+1))<<4|d(g.charAt(y+2))>>2,X(w>>8&255),X(w&255)),B}function f(g){var y,m=g.length%3,b="",w,L;function B(E){return t.charAt(E)}function H(E){return B(E>>18&63)+B(E>>12&63)+B(E>>6&63)+B(E&63)}for(y=0,L=g.length-m;y<L;y+=3)w=(g[y]<<16)+(g[y+1]<<8)+g[y+2],b+=H(w);switch(m){case 1:w=g[g.length-1],b+=B(w>>2),b+=B(w<<4&63),b+="==";break;case 2:w=(g[g.length-2]<<8)+g[g.length-1],b+=B(w>>10),b+=B(w>>4&63),b+=B(w<<2&63),b+="=";break}return b}e.toByteArray=u,e.fromByteArray=f})(l)})(Bi);const hd=Ns(Bi);var Ri={};const dd=5,Ei=12,ud=13,pd=16,fd=17,gd=22,Hi=28,Di=31,yd=33,Do=34,xd=35,Xs=36,zs=37,Oi=38,wd=39,Pd=40,co=41,md=42,x=0,M=1,Ee=2,Xi=3,C=4,bd=[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,Xi,C,C,C,C,C,C,C,C,C,C,C],[x,C,C,M,M,C,C,C,C,M,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,C,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[C,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,M],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,M],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,M,x,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,x,x,M,M,M,M,M,M,M,x,x,C,Ee,C,M,M,M,M,M,x,M,M,M,x],[M,C,C,M,M,M,C,C,C,x,x,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,x,M,C,C,C,x,x,M,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,x,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,C,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,C,x,x,x,x,x,x,x,x,x,x,x,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,M,M,M,M,M,M,C,Ee,C,M,M,M,M,M,M,M,M,M,M],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,M,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,M,M,M,M,x,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,M,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,M,x,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,x,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,M,x,x,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,M,M,x],[x,C,C,M,M,M,C,C,C,x,M,x,x,x,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[M,C,C,M,M,M,C,C,C,M,M,M,M,M,x,M,M,M,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x],[x,C,C,M,M,x,C,C,C,x,x,x,x,x,x,x,x,x,x,x,C,Ee,C,x,x,x,x,x,x,x,x,M,x]],Sd=hd.toByteArray("AAgOAAAAAAAQ4QAAAQ0P8vDtnQuMXUUZx+eyu7d7797d9m5bHoWltKVUlsjLWE0VJNigQoMVqkStEoNQQUl5GIo1KKmogEgqkKbBRki72lYabZMGKoGAjQRtJJDaCCIRiiigREBQS3z+xzOTnZ3O+3HOhd5NfpkzZx7fN9988zivu2M9hGwB28F94DnwEngd/Asc1EtIs9c/bIPDwCxwLDgezHcodyo4w5C+CCwBS8FnwSXgCnA1uFbI93XwbXAbWAfWgx+CzWAb+An4KfgFeAzsYWWfYuFz4CXwGvgb+Dfo6yNkEEwGh4CZYB44FpwI3g1OY+kfBItZOo2fB84Hy8DF4HJwNbiWpV8PVoO1LH4n2NRXyN+KcAd4kNVP9XsY4aPgcfAbsBfs6SniL4K/sPjfEf6HlanXCRkCw2BGvUh/keWfXS/CY+pFXs7x9XHmM94LTmWIeU2cgbxnS/k/B3kf86jDhU8L9V2E40vAFWAlWFUfb++NOL4F3C7JX4/4GiE+hvgWsF0oS7mXldspnN+F493gyXrh9xTav0cg3EvzgVfBG6wsmVSEkxBOBgdPGpd7JI6PnqRvJ68/xlbHof53gPeA94OzwLngk+ACsAwsByvASrAK3MB0Ws3CtQjvBJvAVrADPMDSHkb4CNijaccTwvnf4fiPEs8Lxy+D18A/QU8/xjgYBjPAbDAKTgYLwOngTHAO+EQ/8wuEF4EvsPiVCFf2+9tsFStzA8LVHuXXBsi6QyqzUYiPMR/7Mc7dAx7oL8bzw/3u/Bw8Bp4Az4AXwCtgHzsmDXP5fiF9iiVvly5d0sHngar16NKlS5cuXbp06fLmYlqHXrcd3ph4P0THUY3iXh49novju4S0tzfs5d+JPKewfAsRntZb3K9ZhOMlrO6lCC8An28U9+OuovcPcPxlVu5rCL/VmHh/iHIrzn3fIPu7SN8Axmg+8AOwEWwCm7tp3bRuWjetm5Y8bSu4B9zbKO6ZVsnORrVU3f4uXTqZ2H3sLoyx3eDXjfDndE9qyj6L838CfwVvgFpzYnof4oNgOhgBc8Fos9DrZIQLmtXPP1MmF6wGj4H+KXoWguvADkXaPil+YpuQy8Am8Ey7ODdtmJDF4HowBp4De6HDTNjhfHAHeBr0DBBy0kDxfPbcgSIusgrcWhtnJ8vL+TPix7UIOQtcBq4C28Cr4KRBnANbwSuDE+s50JgyNNFuXbp06XIgsXjIvPafjvXozKY+fVFz/z0LT1uCtKVSWbrOLWPnztG8e0Xfy7ol8XtZJi7WtG+5od2UFXQ/A12vUeS7jp27yVKHjdsU9lXB869TyNvAzt0lpP2oWbwLdjiO78bx/Sz+EMJHwK9Y/LcIfw+eZ3F67/Hl5vh9xX80J+rwX8SvRDhpgL17iPAQMHNArfPrqHPewLheI+AERV6efwV418B4nOZ/H+IfYHV8GOF5LJ3eAz0fx8sM9S0fUNud39O9CulfGZhY5huI3wzWgNvBelbHZoTbNPVpfYjKQpkHwUNgl0LWblbnk0LbbDxr0OMFpL3iqWdu9nWYPlVAWkXY39LnGdCkDbeqv1YNbfcMQ3t9oe8lzm6NH9N1ZB6Ln4BwfkJZJk7RyFnYKt6b/JDQXx9p5X+eFdqOjzM9P9MB/lUlFzr20aXIdzlY4dmn9F3YqtvoO76/2hp/D/xA5Zue88nNyL8GbFbs075X0tyUig3Qd2MCnf//HjnzpbsR3g9+1kHzzVjdnE71/qVBX9rGPUh/ysNWe1neFzvIDi5zAufV1sT0N0poR22wkFUfTOPfA4N2mbZ5fSrqOHSw+IbkSBbOGSzSRgf91/GTUWYBOB2cIZQ/G8cfBZ8CFwrnL8XxF8FKcA24jqXdiPA7Qr61OF7H4mMItwzuv2/YLth1ISt3Hzu3k4W7EH5JqPdRHD/O4k+z8A8IX5Lq3y7Z4nXE9xn6kX6vQ4bKfy+ok+hH+xf3hq9dnTTHhjKd2GmDuWA242iHMq4cC7A8kJ7i8o1+skSa7Jieo38HCWnoNjKFhdSFBxzpZ7QE6lI8N4S14aASZcryaV/WWHw66f6NHuCoxuQxmvM56GX9QMd8Q4D65ywGP+ZzRJuM+zQvx/MOS2VFeqQ4IXnH26zM9Xe6/E6D+4foAzzuajPZp8Qyw5ayZVDWuH0z0BtYRkeIDqH9KO9VbH1btd/lhNqCzvl8zeLnG0S/hnU6baHfpiuO6yy0rd+DHURo/zYF5H26j03rQsip2ndzz82u1z9N4VjWKWeb68Tedpt95HRVXp7H1R6p+/Wt4FPy/PpWwscOLRJ+PVWF/+W0iVyGzs18TIvXkOJ1Wxm66vSXz+vylenrZcj1ub439W+K8RNCGTJi2p/TJ1K23VaXr35tRpnzmjxequgfcfyk6B/TGBVlyedsNgpdd/h+W1U3P99QyFPNo1X3TwpM/WLTIWYfoBqXrv6iskHZ/RFr79R6hIyHBrH3f1nrUVnjP8SnZZ+rYtzr9Exld5MNbPNErusAPg+77u/eDOPftU9yj39TH7rezxd1LvsZQJlzkWlOirG/79zjMj/mtHUKu7vKy+3/LnXr9okyKedjX5/0He9iP/j63LwOQdarEVlfy8OO/Lqw023j6xcqmwxLiOd6heM2i9cV9LJy8jMJ23yQ+rpbfu7EQ/pXE8KYvUSqvVnb4XzZa6LrHMXHR+zcLvqWbm/Bn0/HzIs6fWPHoat8XfnDKmZGxRxeMbn2UqZ5Q94nmcZRbqqUXbZ8+lcjE+cPX11t814orvvAXNcG8vqj2vvk1MGn3anlj0bIT72v47bvE+Lc98T9b6r7AKn6j+8Duf7D0nnZx/j7Zjn0j9nbpSTndaLr9WNLivP+iN23xF7L+fqv6ZouFyb78jxVXvv5jJ9YUs9/sddO8h7KNg5jrhfaJGztT6G7KF+1d6yCmD5Kdb2fan60rSc552fZr3zeQ9DpnPp+Si5cx5Ktv2QfSzF/mMbWdOm46rFI4XstnU9xeqX4NKb7TKEdcr6pZOK3ID1k/LvFHkVczEuZLEDr499YqvqBym1aEHWgcvoYOtv0M91qQl5TfpO/in6rWx8OVpT1Wedkv3f5xom3T/xeR/6Gx6V86PWAOB4bBpqWdN+yTcVxjIyGRz/FrDGu6w/3d7kPm8StX8RyPu+uuvpNju/vTLJV37GpvoM0oZPnW87VLnL/5pDno1NoW1R6yedU6TyUv3u19a3KFnIbTLYz+ZCLP4T0tU1uivFgso0pnsJ/UtXvarNY28Xq5cvkBDrQP/E5ZaiuQwwfmTlsOiQRU1fMuqrDd/3ISSuwjOwXOfTyGUMpZIXq4GpLn3pUcdfzch2x7XO1u2uZHOPb1G6b3Xg9PH1IIWeEpJlPQtqos2EKW8b0u8rnuP1UeVLoXJb9be0uG9nnbchjU+XTszT5VeNBThPHnc5OKj1U9aj0GTHIVaGy1YhEWT4ixns00DT+XEzWn/7VAsIc63Cov3OdyhwjrnaqQqZvWKXdypRdlq+k8msZ031U+Rm4fA+3TtyeR9hwfW9G9yxDN0fZMN33F+9TE6md4hwoxumfaUzI9fN3PFT3xVV2msrQ3UsnChm6Nulk8TndpS28D3zX9tTIPsF/z7Am5OkTjm1tI1JZW74+4VgsZ0N3L1yXV3WeP5uR7TGHHdvC3JQlxybfpd22tDlk/2eofRK8TzrN/qnar/K/OUTth6I/+jAnEptNbPvFHP2gs40N3+dfMWtwqvVct7/wfd8gtQ7imifial9ZJ9/3IHLYU6eDj3+4PhsNhX+vwvcWLnu6kGfEMe8DuciPfUfGZB8X/7HJy/Gefe5n+VRGFd/wyP2ta7/LO4yh/sbLV/k9lev6kfO9Dt/5U67b1/6u/epqB1U9Me23jfHY9sscAg4tkbLl+e4/U36rJ9ddxfd6sg5vq5ice42Wpk/pb9FOJ36/W9tpv4kbC79nUbZceX8Zu6/qJ+P3WvhvA8v3reh7Jbn2d6rrNC7XNZTLma4Ba0JI9efX2uLzF5scG/w9UNU1ZxW+ymUfzELeTllXlQ1rUuhzjS5fp9c964iFBOqeSz63bU065nZKdU+mDEz3qHIjjifquw0pnb/raRtvrnsYcb46ihT3taoYz6brdNW9l6rWRnE/navdPn1XlR1km7hcz1WlH/elKuSOSvLLuE8U6m8uzwRdfcGl73VyTHuyMvzJ1Sa2cWDTP/Z63Kc94n2B1PYr24dz1JlyHLlcP+S4B6vD1c9EW4q2LWstCvUjeVy63k/LMYdUNd5D1xQfvVTzX1VjkMsUv88N8VH5fReVn/Fjn++/h6X6Q8a6b1/q3g/i/ewi0/Scs8zxXeV6mWIOUPlPzBgdFerW+bZrm2P18dnjuK6HunEp+rHvPMXbr+sHVb/lnL+pTP57jPw9Cvk3PW178JD9qChfzuvTf7Htl38L1QUf/VKu9SFjwWbTWPvFEvu7Uq76y7+31g6QlYPc669pbsm9Xur2LWI9Pu8ypfDXqm3A2z8s1FWGn4ntL9NfQu2oSlftX9uetvTtv7J8Ql4zxfXGZ3zk8PeQ9w59x2uMfqI8/q5eKh/l9cb2rwsu9rSNl06ZP2Pmxtz+rNMx93yno0n2/82rVH7rQ+y9P15H6FyRun9ViH81ATmffI7nJ5r8uXXW6enbP6b/B8/l5OifVHYLnb9S39s2zcc+Ph+rh8+eQgVPS72elzGWY/tUtbbabBpDiI7yN1q6/4th2y+ErAc5+9BVvu/7KamJbWNZeuqI/R4tRf+YyD1HmOZM1bMV3/14Sn10c0Xu+Sj1nOXb5jL73ncdy02uvlXZNde65dOHYl7Vs4KYuS6FzWLn2zJlpZqPXPVPOa5yzKOyn1VhT9lmMfdbfH7D11Wf2PXN5h9y+dD287+qxgSnaYmnIrRtIb8pJe6/Uv9OVer6Whn0zfGO/BEloZI9ojmfAlUflClDd178bTmVHVTpZXOkAlk/lb42UujmI89HH5V+cl7XtowY6vTxLVWok6UrGzoGTHN+bB+6ri05687VNpvfuvRfaP2uMlNQth1D5JjGelm/8yn+9p3p/7qk9gnfeddXZmq/Sm333PJT659Kv1zjNbZ9uv2Oi//67CV8/N1nj1DmviyXDNVeJkaeaX8UsyesYg8cu2+NvdaPfb+lLDu5tvt/"),Md=new ld(Sd),zi=function(l){switch(l){case yd:return Ei;case wd:case Pd:case md:return Ei;case xd:return dd;default:return l}},Wi=function(l){switch(l){case zs:case Oi:return Do;case co:return gd;default:return l}};class Ws{constructor(t,e=!1){this.position=t,this.required=e}}class vd{nextCodePoint(){const t=this.string.charCodeAt(this.pos++),e=this.string.charCodeAt(this.pos);return 55296<=t&&t<=56319&&56320<=e&&e<=57343?(this.pos++,(t-55296)*1024+(e-56320)+65536):t}nextCharClass(){return zi(Md.get(this.nextCodePoint()))}getSimpleBreak(){switch(this.nextClass){case co:return!1;case Do:case zs:case Oi:return this.curClass=Do,!1;case Xs:return this.curClass=Xs,!1}return null}getPairTableBreak(t){let e=!1;switch(bd[this.curClass][this.nextClass]){case x:e=!0;break;case M:e=t===co;break;case Ee:if(e=t===co,!e)return e=!1,e;break;case Xi:if(t!==co)return e;break}return this.LB8a&&(e=!1),this.LB21a&&(this.curClass===pd||this.curClass===fd)?(e=!1,this.LB21a=!1):this.LB21a=this.curClass===ud,this.curClass===Hi?(this.LB30a++,this.LB30a==2&&this.nextClass===Hi&&(e=!0,this.LB30a=0)):this.LB30a=0,this.curClass=this.nextClass,e}nextBreak(){if(this.curClass==null){let t=this.nextCharClass();this.curClass=Wi(t),this.nextClass=t,this.LB8a=t===Di,this.LB30a=0}for(;this.pos<this.string.length;){this.lastPos=this.pos;const t=this.nextClass;if(this.nextClass=this.nextCharClass(),this.curClass===Do||this.curClass===Xs&&this.nextClass!==zs)return this.curClass=Wi(zi(this.nextClass)),new Ws(this.lastPos,!0);let e=this.getSimpleBreak();if(e===null&&(e=this.getPairTableBreak(t)),this.LB8a=this.nextClass===Di,e)return new Ws(this.lastPos)}return this.lastPos<this.string.length?(this.lastPos=this.string.length,new Ws(this.string.length)):null}constructor(t){this.string=t,this.pos=0,this.lastPos=0,this.curClass=null,this.nextClass=null,this.LB8a=!1,this.LB21a=!1,this.LB30a=0}}Ri=vd;class Id{split(t){const e=new Ri(t);let n=0,o;const s=[];for(;o=e.nextBreak();){const r=t.slice(n,o.position);s.push(r),o.required,n=o.position}return s}}const Fi=new Id;class hn{constructor(){p(this,"text");p(this,"characters",[]);p(this,"fontSize");p(this,"fontFamily");p(this,"fontColor");p(this,"fontBgColor");p(this,"bold");p(this,"italic");p(this,"underline");p(this,"strikethrough");p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);this.text="",this.characters=[],this.fontSize=14,this.fontFamily="Noto Sans",this.fontColor="#000000",this.fontBgColor="",this.bold=!1,this.italic=!1,this.underline=!1,this.strikethrough=!1}static create(t){const e=new hn;e.fontSize=t.fontSize,e.fontFamily=t.fontFamily,e.fontColor=t.fontColor,e.fontBgColor=t.fontBgColor,e.bold=t.bold,e.italic=t.italic,e.underline=t.underline,e.strikethrough=t.strikethrough;const n=t.characters||[];let o="";for(const s of n)e.addCharacter(s),o+=s.charText;return e.text=o,e}static createByStyleAndCharacter(t,e=[]){const n=new hn;n.fontSize=t.fontSize,n.fontFamily=t.fontFamily,n.fontColor=t.fontColor,n.fontBgColor=t.fontBgColor,n.bold=t.bold,n.italic=t.italic,n.underline=t.underline,n.strikethrough=t.strikethrough;let o="";for(const s of e)n.addCharacter(s),o+=s.charText;return n.text=o,n}addCharacter(t){t.x=this.width,t.index=this.characters.length,this.characters.push(t),this.width=this.width+t.width,this.height=Math.max(this.height,t.height)}draw(t,e,n){const{fontBgColor:o,underline:s,strikethrough:r,fontColor:i,fontSize:a,fontFamily:c,bold:h,italic:d}=this,u=e.x+this.x,f=e.y+this.y;if(o&&(t.save(),t.fillStyle=o,t.fillRect(u,f,this.width,n),t.restore()),t.save(),t.fillStyle=i,t.font=S.calcFont(a,c,h,d),t.textAlign="left",t.textBaseline="bottom",t.fillText(this.text,u,f+n),t.restore(),s){const g=.08333333333333333*a;t.strokeStyle=i,t.lineWidth=g,t.beginPath(),t.moveTo(u,f+n-g),t.lineTo(u+this.width,f+n-g),t.stroke()}r&&(t.strokeStyle=i,t.lineWidth=1/12*a,t.beginPath(),t.moveTo(u,f+n-.4*this.height),t.lineTo(u+this.width,f+n-.4*this.height),t.stroke())}computeLineBreakPoint(t){const e=Fi.split(this.text);let n=0;const o=[];for(let s=0;s<e.length-1;s++){const r=e[s],i=Eo.split(r);n+=i.length,o.push(n)}if(!t)o.push(this.characters.length);else{const s=Fi.split(this.text+t.text);let r=0;for(const i of s){const a=Eo.split(i);if(r+=a.length,r===this.characters.length)return o.push(this.characters.length),o;if(r>this.characters.length)return o}}return o}toString(){let t="";for(const e of this.characters)t+=e.toString();return t}toRichTextXML(t){return`<style ${this.computeStyle(t)}>${this.text}</style>`}computeStyle(t){let e="";return this.fontColor!==t.fontColor&&(e+=`color='${this.fontColor}' `),this.fontBgColor!==t.fontBgColor&&(e+=`bg-color='${this.fontBgColor}' `),this.fontSize!==t.fontSize&&(e+=`font-size='${this.fontSize}' `),this.bold!==t.bold&&(e+=`bold=${this.bold?"'true'":"'false'"} `),this.italic!==t.italic&&(e+=`italic=${this.italic?"'true'":"'false'"} `),this.underline!==t.underline&&(e+=`underline=${this.underline?"'true'":"'false'"} `),this.strikethrough!==t.strikethrough&&(e+=`strikethrough=${this.strikethrough?"'true'":"'false'"} `),e}getPrevText(t){let e="";for(let n=0;n<t+1;n++)e+=this.characters[n].charText;return e}getNextText(t){let e="";const n=Math.max(t+1,0);for(let o=n;o<this.characters.length;o++)e+=this.characters[o].charText;return e}insertTextToRichTextXML(t,e,n){const o=this.getPrevText(e)+t+this.getNextText(e);return`<style ${this.computeStyle(n)}>${o}</style>`}}class Td{work(t,e,n){let o=[],s=n.line.width;for(const r of t.characters)if(s+r.width<e)o.push(r),s+=r.width;else{if(o.length>0){const i=hn.createByStyleAndCharacter(t,o);n.line.addTextBlock(i)}n.paragraph.addLine(n.line),o=[],n.line=new Yn,o.push(r),s=r.width}if(o.length>0){const r=hn.createByStyleAndCharacter(t,o);n.line.addTextBlock(r)}}}const Ld=new Td;class lo{checkValid(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e;if(n<0||o<0||s<-1||n>t.paragraphs.length-1)return console.warn("警告,光标位置异常,",e),null;const r=t.paragraphs[n];if(o>r.lines.length-1)return console.warn("警告,光标位置异常,",e),null;const i=r.lines[o],a=i.getCharLength();return s>a-1?(console.warn("警告,光标位置异常,",e),null):{paragraph:r,line:i}}moveRight(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(e.equal(t.tailTextCursorPosition()))return e;const c=a.getCharLength();return o===i.lines.length-1&&s===c-1?new Fe(n+1,0,-1):s===c-1?new Fe(n,o+1,-1):new Fe(n,o,s+1)}moveLeft(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(e.equal(t.headTextCursorPosition()))return e;if(o===0&&s===-1)return t.paragraphs[n-1].tailCursorPosition();if(s===-1){const h=i.lines[o-1].getCharLength();return h>0?new Fe(n,o-1,h-2):new Fe(n,o-1,-1)}return new Fe(n,o,s-1)}moveUp(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i,line:a}=r;if(n===0&&o===0)return e;const{relativePos:c,height:h}=t.getPosByCursorPosition(e),d=new P(c.x,c.y-1);return t.detect(d)}moveDown(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=this.checkValid(t,e);if(!r)return e;const{paragraph:i}=r;if(n===t.paragraphs.length-1&&o===i.lines.length-1)return e;const{relativePos:a,height:c}=t.getPosByCursorPosition(e),h=new P(a.x,a.y+c+1);return t.detect(h)}}const Cd="pingfang",le=5,Ad=2,Nd=5,kd=50,Bd="main_text_id",Rd=14,Ed=10,Yi=8,Oo=2,Gi=.4;class Hd{computeStyle(t,e,n,o,s){if(!s){t.paragraphStyle=null;return}const r=this.firstLineHeight(t),i=this.computePrefixToken(s.orderIndex,s.level),a={level:s.level,orderIndex:s.orderIndex,paraIndex:s.paraIndex,width:n,lineHeight:r,prefixToken:i,color:o};t.paragraphStyle=a}computePrefixToken(t,e){switch(e%3){case 0:return t.toString();case 1:return this.numberToLetter(t);case 2:return this.numberToRoman(t);default:return t.toString()}}numberToLetter(t){if(t<1)return"a";const e=(t-1)%26+97;return String.fromCharCode(e)}numberToRoman(t){if(t<1)return"I";const e=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n="",o=t;for(const[s,r]of e)for(;o>=s;)n+=r,o-=s;return n}computeParagraphX(t,e,n){let o=0;if(n&&(o+=Yi),!e)return o;const{level:s}=e;return o+(s+1)*t}computePrefixWidth(t,e){const{fontSize:n,fontFamily:o,bold:s,italic:r}=e;t.font=S.calcFont(n,o,s,r);const{width:i,height:a}=S.measureText(t,"aaa"),c=S.measureText(t,"aa");return{width:i,height:a,prefixWidth:c.width}}draw(t,e,n){if(!e.paragraphStyle)return;const o=e.paragraphStyle.width,s=e.paragraphStyle.lineHeight,r=this.firstLineX(e),i=n.x+e.x+r-o,a=n.y+e.y+s;if(e.paragraphStyle.orderIndex>=0){t.fillText(e.paragraphStyle.prefixToken+".",i,a);return}const c=e.paragraphStyle.color||"#000000";t.strokeStyle=c,t.lineWidth=1,t.beginPath();const h=e.paragraphStyle.level%3,d=.1*o;switch(h){case 1:t.arc(i+.5*o,a-.5*s+d,d,0,Math.PI*2),t.stroke();return;case 2:t.rect(i+.5*o,a-.5*s,2*d,2*d),t.fill(),t.stroke();return;case 0:default:t.arc(i+.5*o,a-.5*s+d,d,0,Math.PI*2),t.fill(),t.stroke();return}}firstLineHeight(t){if(t.lines.length===0)return 20;const e=t.lines[0];return e.height<.1?20:e.height}firstLineX(t){if(t.lines.length===0)return 0;const e=t.lines[0];return e.height<.1?0:e.x}}class Dd{constructor(){p(this,"textQuoteInfo",null);p(this,"paraStyleMap",new Map)}reset(){this.textQuoteInfo=null,this.paraStyleMap.clear()}getQuoteStyle(t){return this.paraStyleMap.get(t)}work(t,e){t.paraQuoteStyles.forEach(s=>this.paraStyleMap.set(s.paraIndex,s));let n=null;const o=[];for(let s=0;s<e.paragraphs.length;s++){const r=e.paragraphs[s],i=this.paraStyleMap.get(s);i&&i.quote?n?n.y1=r.y+r.height:n={x:0,y0:r.y,y1:r.y+r.height}:n&&(o.push(n),n=null)}n&&o.push(n),o.length>0&&(this.textQuoteInfo={quoteLines:o})}draw(t,e){if(this.textQuoteInfo){t.lineWidth=Oo,t.strokeStyle="#8F959E",t.lineCap="round",t.globalAlpha=1,t.beginPath();for(const n of this.textQuoteInfo.quoteLines){const{x:o,y1:s,y0:r}=n;t.moveTo(e.x+o+Oo,e.y+r),t.lineTo(e.x+o+Oo,e.y+s)}t.stroke()}}}class ho{constructor(){p(this,"paragraphs",[]);p(this,"x",0);p(this,"y",0);p(this,"width",0);p(this,"height",0);p(this,"textProps",new Ge);p(this,"paragraphProps",new qt);p(this,"paragraphQuoteProps",new Dt);p(this,"rect",new D);p(this,"prefixDrawer",new Hd);p(this,"textBlockMeasureWorker",new Fh);p(this,"richTextHelper",new Pi);p(this,"cursorMoveWorker",new lo);p(this,"textQuoteLineWorker",new Dd)}draw(t,e,n=1){t.save();for(let d=0;d<this.paragraphs.length;d++){const u=this.paragraphs[d],f=new P(e.x+this.x,e.y+this.y),g=this.textQuoteLineWorker.getQuoteStyle(d);g&&g.quote?t.globalAlpha=Gi*n:t.globalAlpha=n,u.draw(t,f)}const{fontSize:o,fontColor:s,fontFamily:r,bold:i,italic:a}=this.textProps,c=e.x+this.x,h=e.y+this.y;t.globalAlpha=n,t.textBaseline="bottom",t.textAlign="left",t.fillStyle=s,t.font=S.calcFont(o,r,i,a);for(const d of this.paragraphs)this.prefixDrawer.draw(t,d,{x:c,y:h});this.textQuoteLineWorker.draw(t,{x:c,y:h}),t.restore()}contains(t){return S.rectContains2(t,{minX:this.rect.x,maxX:this.rect.x+this.rect.width,minY:this.rect.y,maxY:this.rect.y+this.rect.height})}detect(t){let{x:e,y:n}=t;if(this.paragraphs.length===0)return new Fe(-1,-1,-1);if(n<this.y)return this.headTextCursorPosition();if(e<this.x)return this.headTextCursorPosition();if(n>this.y+this.height)return this.tailTextCursorPosition();if(e>this.x+this.rect.width)return this.tailTextCursorPosition();e=e-this.x,n=n-this.y;for(const o of this.paragraphs){const s=new P(e-o.x,n-o.y),r=o.detect(s);if(r)return new Fe(o.index,r.lineIndex,r.charIndex)}return this.tailTextCursorPosition()}headTextCursorPosition(){return Fe.head()}tailTextCursorPosition(){const t=this.paragraphs[this.paragraphs.length-1],e=t.lines[t.lines.length-1],n=e.getCharLength(),o=n===0?-1:n-1;return new Fe(t.index,e.index,o)}addParagraph(t){t.y=this.height,t.index=this.paragraphs.length,this.paragraphs.push(t),this.width=Math.max(t.x+t.width,this.width),this.height=this.height+t.height}getParagraph(t){return t<0||this.paragraphs.length===0?null:t>this.paragraphs.length-1?(console.warn("index 超出该文本最大段落数目,fall back处理"),this.paragraphs[this.paragraphs.length-1]):this.paragraphs[t]}getPosByCursorPosition(t){const e=this.textProps,n=new P(this.x,this.y),{charIndex:o,lineIndex:s,paragraphIndex:r}=t,i=this.getParagraph(r);if(i===null)return{relativePos:n,height:e.fontSize};n.x+=i.x,n.y+=i.y;const a=i.getLine(s);if(a===null)return{relativePos:n,height:e.fontSize};n.x+=a.x,n.y+=a.y;const c=a.getCharacter(o);if(c===null)return{relativePos:n,height:a.height};const{character:h,textBlock:d}=c;return n.x+=d.x+h.x+h.width,n.y+=h.y,{relativePos:n,height:a.height}}reset(){this.paragraphs=[],this.x=0,this.y=0,this.width=0,this.height=0,this.textQuoteLineWorker.reset()}computeParagraphMap(){const t=new Map;for(const e of this.paragraphProps.paragraphStyles)t.set(e.paraIndex,e);return t}computeParagraphQuoteMap(){const t=new Map;for(const e of this.paragraphQuoteProps.paraQuoteStyles)t.set(e.paraIndex,e);return t}typesetting(t,e=this.textProps,n,o=this.paragraphProps,s=this.paragraphQuoteProps){this.reset(),this.rect=n,this.x=0,this.y=0,this.textProps=e,this.paragraphProps=o,this.paragraphQuoteProps=s;const r=this.computeParagraphMap(),i=this.computeParagraphQuoteMap(),{sizeMode:a}=e,c=a===We.autoWidth,h=this.richTextHelper.parse(e.richText,e);this.textBlockMeasureWorker.measureParagraphs(t,h);const{width:d,prefixWidth:u}=this.prefixDrawer.computePrefixWidth(t,this.textProps);for(let f=0;f<h.length;f++){const g=h[f],y=r.get(f),m=i.get(f),b=this.prefixDrawer.computeParagraphX(d,y,m),w=this.typesettingParagraph(t,g,n.width-b,c);w.x=b,this.prefixDrawer.computeStyle(w,b,u,e.fontColor,y),this.addParagraph(w)}this.alignVertical(n),this.alignHorizon(n),this.textQuoteLineWorker.work(this.paragraphQuoteProps,this)}typesettingParagraph(t,e,n,o){if(e.textBlocks.length===0){const c=new Cs,h=new Yn,{fontSize:d,fontFamily:u,bold:f,italic:g}=this.textProps,{height:y}=S.measureTextByFont(t,"1",d,u,f,g);return h.height=y,c.addLine(h),c}const s=new Cs,r=new Yn,i={paragraph:s,line:r};for(let c=0;c<e.textBlocks.length;c++){const h=e.textBlocks[c],d=c===e.textBlocks.length-1?null:e.textBlocks[c+1],u=hn.create(h);if(u.characters.length===0){const{fontSize:f,fontFamily:g,bold:y,italic:m}=u,{height:b}=S.measureTextByFont(t,"1",f,g,y,m);u.height=b}this.lineAddTextBlock(u,d,n,o,i)}const a=i.paragraph.lines;return(a.length===0||i.line!==a[a.length-1])&&i.paragraph.addLine(i.line),s}lineAddTextBlock(t,e,n,o,s){if(o)s.line.addTextBlock(t);else if(s.line.width+t.width<n)s.line.addTextBlock(t);else{const r=t.computeLineBreakPoint(e),i=S.judgeLineBreak(r,t,s.line,n);if(r.length===0||i<0)s.line.textBlocks.length>0&&(s.paragraph.addLine(s.line),s.line=new Yn),Ld.work(t,n,s);else{const a=t.characters.slice(0,i),c=hn.createByStyleAndCharacter(t,a);s.line.addTextBlock(c),s.paragraph.addLine(s.line),s.line=new Yn;const h=t.characters.slice(i,t.characters.length),d=hn.createByStyleAndCharacter(t,h);this.lineAddTextBlock(d,e,n,o,s);return}}}alignVertical(t){const e=this.textProps.verticalAlign;if(e===at.Top){this.y=t.y;return}if(e===at.Bottom){this.y=t.y+t.height-this.height;return}if(e===at.Middle){this.y=t.y+.5*t.height-.5*this.height;return}}alignHorizon(t){this.x=this.rect.x;let e=this.textProps.horizonAlign;this.textProps.sizeMode===We.autoWidth&&(e=at.Top);for(const n of this.paragraphs)n.alignHorizon(e,t.width-n.x)}modifyPosInEditing(t,e){const n=new P;let o=!1;const{relativePos:s,height:r}=this.getPosByCursorPosition(e);return s.x<t.x&&(n.x=t.x-s.x,o=!0),s.x>t.x+t.width&&(n.x=-(s.x-(t.x+t.width)),o=!0),s.y<t.y&&(n.y=t.y-s.y,o=!0),s.y+r>t.y+t.height&&(n.y=-(s.y+r-(t.y+t.height)),o=!0),o&&(this.x+=n.x,this.y+=n.y),o}resetFromEditing(t){this.alignVertical(t),this.x=t.x}isEmptyText(){if(this.paragraphs.length!==1)return!1;const t=this.paragraphs[0];return t.lines.length===0||t.lines.length===1&&t.lines[0].toString()===""}toRichTextXML(){let t="<root>";for(const e of this.paragraphs)t+=e.toRichTextXML(this.textProps);return t+"</root>"}toString(){let t="";for(const e of this.paragraphs)t+=e.toString();return t}prevParagraphToXML(t){let e="";for(let n=0;n<t;n++)e+=this.paragraphs[n].toRichTextXML(this.textProps);return e}nextParagraphToXML(t){let e="";for(let n=t+1;n<this.paragraphs.length;n++)e+=this.paragraphs[n].toRichTextXML(this.textProps);return e}nextCursorPos(t,e){let n=t;for(let o=0;o<e;o++)n=this.cursorMoveWorker.moveRight(this,n);return n}prevCursorPos(t,e){let n=t;for(let o=0;o<e;o++)n=this.cursorMoveWorker.moveLeft(this,n);return n}getTextCursorPosByIndex(t){let e=-1;for(let n=0;n<this.paragraphs.length;n++){const o=this.paragraphs[n];for(let s=0;s<o.lines.length;s++){const i=o.lines[s].getCharLength();if(e===t)return new Fe(n,s,-1);for(let a=0;a<i;a++)if(e++,e===t)return new Fe(n,s,a)}n<this.paragraphs.length-1&&e++}return this.tailTextCursorPosition()}getIndexByTextCursorPos(t){const{paragraphIndex:e,lineIndex:n,charIndex:o}=t;if(e<0||e>=this.paragraphs.length)return-1;let s=0;for(let c=0;c<e;c++){const h=this.paragraphs[c];for(let d=0;d<h.lines.length;d++){const u=h.lines[d];s+=u.getCharLength()}s++}const r=this.paragraphs[e];if(n<0||n>=r.lines.length)return s-1;for(let c=0;c<n;c++){const h=r.lines[c];s+=h.getCharLength()}const i=r.lines[n];if(o===-1)return s-1;const a=i.getCharLength();return o>=a?s+a-1:s+o}}class Ui{constructor(){p(this,"characters",[]);p(this,"width",0)}addCharacter(t){this.characters.push(t),this.width=this.width+t.width}}class Fs{handle(t,e){const n=this.layoutToPoints(t,e);return this.getUpdateNodeData(t.id,n)}getNodePos(t,{x:e,y:n}){const o=new P,{width:s,height:r}=t.baseProps;return o.x=e*s,o.y=n*r,t.toGlobal(o)}getUpdateNodeData(t,e){return{infos:[{id:t,props:[{type:I.Line,points:e}]}]}}}class Xo extends Fs{enable(t){return t.shapeType===he.Line}layoutToPoints(t,e){const{start:n,end:o}=t.connectProps,s=t.globalLinePoints;let r=s[0],i=s[s.length-1];if(n){const d=e.nodeManager.getNode(n.objectId);d&&(r=this.getNodePos(d,n))}if(o){const d=e.nodeManager.getNode(o.objectId);d&&(i=this.getNodePos(d,o))}const a=[r,i],c=t.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}layoutToPointsPro(t,e){return[t.point,e.point]}}function Od(l,t,e){return(t.x-l.x)*(e.y-l.y)-(t.y-l.y)*(e.x-l.x)}function Xd(l){if(l.length!==4)return!1;const t=[];for(let e=0;e<4;e++){const n=l[e],o=l[(e+1)%4],s=l[(e+2)%4],r=Od(n,o,s);if(r===0)return!1;t.push(Math.sign(r))}return t.every(e=>e===t[0])}class zo{splitCurve(t){const e=t.getHalfTPos();return this.computeCurveControlPoint(t.p0,e,t.p3)}computeCurvePointsForLine(t,e,n=t.points){const{start:o,end:s}=t.connectProps,r=this.computeConnectEndInfo(o,e),i=this.computeConnectEndInfo(s,e);return this.computeCurvePoints(n,r,i)}computeConnectEndInfo(t,e){let n;if(t){const o=this.computeEndType(t,e);o&&(n=this.computeEndDirection(o.endType,o.nodeAngle))}return n}computeEndDirection(t,e){let n=0;switch(t){case de.Top:n=-.5*Math.PI;break;case de.Left:n=Math.PI;break;case de.Bottom:n=.5*Math.PI;break;default:case de.Right:n=0;break}const o=e/180*Math.PI;n+=o;const s=Math.cos(n),r=Math.sin(n);return{direction:{x:s,y:r}}}computeEndType(t,e){if(t){const n=e.getNode(t.objectId);if(n)return{endType:S.computeNodeConnectEnd(t,0),nodeAngle:n.baseProps.angle}}return null}computeCurvePoints(t,e,n){const o=S.computeBezierCurvesByPoints(t),s=o[0],r=s.p0;let i=new P(r.x,r.y);if(e){const f=.4*S.distance(r,s.p3),g=Math.sqrt(e.direction.x*e.direction.x+e.direction.y*e.direction.y);i=new P(r.x+f*(e.direction.x/g),r.y+f*(e.direction.y/g))}const a=[r,i];for(let u=1;u<o.length;u++){const f=o[u],g=f.p0,y=f.p3,{lP:m,midPoint:b,rP:w}=this.computeCurveControlPoint(i,g,y);a.push(m,b,w),i=w}const c=o[o.length-1],h=c.p3;let d=new P(h.x,h.y);if(n){const f=.4*S.distance(h,c.p0),g=Math.sqrt(n.direction.x*n.direction.x+n.direction.y*n.direction.y);d=new P(h.x+f*(n.direction.x/g),h.y+f*(n.direction.y/g))}return a.push(d,h),a}computeCurveControlPoint(t,e,n){const o=S.distance(t,e),s=S.distance(e,n),r=S.lineAngle(e,t),i=S.lineAngle(e,n),a=r-i,c=i+.5*a,h=c+.5*Math.PI,d=c-.5*Math.PI,u=e.x+.4*o*Math.cos(h),f=e.y+.4*o*Math.sin(h),g=e.x+.4*s*Math.cos(d),y=e.y+.4*s*Math.sin(d),m=new P(u,f),b=new P(g,y);return Xd([n,t,m,b])?{lP:m,midPoint:e,rP:b}:{lP:b,midPoint:e,rP:m}}}class uo extends Fs{constructor(){super(...arguments);p(this,"bezierWorker",new zo)}enable(e){return e.shapeType===he.Curve}handle(e,n){const{start:o,end:s}=e.connectProps,r=[...e.globalLinePoints];let i=r[0],a=r[r.length-1];if(o){const u=n.nodeManager.getNode(o.objectId);u&&(i=this.getNodePos(u,o),r.splice(0,1,i))}if(s){const u=n.nodeManager.getNode(s.objectId);u&&(a=this.getNodePos(u,s),r.splice(r.length-1,1,a))}const c=this.bezierWorker.computeCurvePointsForLine(e,n.nodeManager,r),h=e.globalTransform().inverseMatrix(),d=c.map(u=>h.crossPoint(u));return this.getUpdateNodeData(e.id,d)}computeLinePoints(e,n){const o=[],s=new P(n.x-e.x,n.y-e.y);if(Math.abs(s.x)>Math.abs(s.y)){const r=new P(e.x+.5*s.x,e.y),i=new P(n.x-.5*s.x,n.y);o.push(e,r,i,n)}else{const r=new P(e.x,e.y+.5*s.y),i=new P(n.x,n.y-.5*s.y);o.push(e,r,i,n)}return o}layoutToPoints(e,n){const{start:o,end:s}=e.connectProps,r=e.points,i=r[0],a=r[r.length-1];return this.computeLinePoints(i,a)}layoutToPointsPro(e,n){return this.computeLinePoints(e.point,n.point)}}class po{constructor(t){p(this,"startPoint");this.startPoint=t}}class R{static computeZLinePoints(t,e,n){if(n){const r=new P(t.x,.5*(t.y+e.y)),i=new P(e.x,.5*(t.y+e.y));return[t,r,i,e]}const o=new P(.5*(t.x+e.x),t.y),s=new P(.5*(t.x+e.x),e.y);return[t,o,s,e]}static computeLLinePoints(t,e,n){if(n){const s=new P(t.x,e.y);return[t,s,e]}const o=new P(e.x,t.y);return[t,o,e]}}class zd extends po{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y<o.y)return Math.abs(o.x-e.x)<.01?[o,e]:R.computeZLinePoints(o,e,!0);const s=new P(.5*(o.x+e.x),o.y-A);if(Math.abs(s.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width||Math.abs(s.x-n.x-.5*n.width)<.5*n.width)if(o.x>e.x){const c=new P(Math.min(this.rect.x-A,n.x-A),Math.min(n.y-A,this.rect.y-A)),h=new P(e.x,Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}else{const c=new P(n.x+n.width+A,Math.min(n.y-A,this.rect.y-A)),h=new P(e.x,Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}const r=new P(e.x,e.y+A),i=R.computeLLinePoints(o,s,!0),a=R.computeLLinePoints(s,r,!0);return a.shift(),[...i,...a,e]}left(e,n){const o=this.startPoint;if(e.y<o.y&&e.x>o.x)return R.computeLLinePoints(o,e,!0);if(e.y<o.y){const a=new P(Math.min(this.rect.x-A,n.x-A),.5*(o.y+e.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new P(Math.min(this.rect.x-A,n.x-A),Math.min(this.rect.y-A,n.y-A)),u=R.computeLLinePoints(o,d,!0),f=R.computeLLinePoints(d,e,!0);return f.shift(),[...u,...f]}const c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x>this.rect.x+this.rect.width+A){const a=new P(.5*(this.rect.x+this.rect.width+n.x),this.rect.y-A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new P(Math.min(this.rect.x-A,n.x-A),this.rect.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}right(e,n){const o=this.startPoint;if(e.y<o.y&&e.x<o.x)return R.computeLLinePoints(o,e,!0);if(e.y<o.y){const a=new P(Math.max(this.rect.x+this.rect.width+A,n.x+n.width+A),.5*(o.y+e.y));if(Math.abs(a.y-this.rect.y-.5*this.rect.height)<.5*this.rect.height||Math.abs(a.y-n.y-.5*n.height)<.5*n.height){const d=new P(Math.min(this.rect.x+this.rect.width+A,n.x+n.width+A),Math.min(this.rect.y-A,n.y-A)),u=R.computeLLinePoints(o,d,!0),f=R.computeLLinePoints(d,e,!0);return f.shift(),[...u,...f]}const c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x<this.rect.x-A){const a=new P(.5*(this.rect.x+n.x),this.rect.y-A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new P(Math.min(this.rect.x+this.rect.width+A,n.x+n.width+A),this.rect.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}top(e,n){const o=this.startPoint;if(e.y>this.rect.y+this.rect.height+A&&Math.abs(e.x-this.rect.x-.5*this.rect.width)<.5*this.rect.width){if(e.x>o.x){const d=new P(this.rect.x+this.rect.width+A,this.rect.y-A),u=new P(e.x,n.y-A),f=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,u,!0);return g.shift(),[...f,...g,e]}const i=new P(this.rect.x-A,this.rect.y-A),a=new P(e.x,n.y-A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}if(n.y+n.height<this.rect.y){if(e.x>o.x){const d=new P(n.x-A,this.rect.y-A),u=new P(e.x,n.y-A),f=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,u,!0);return g.shift(),[...f,...g,e]}const i=new P(n.x+n.width+A,this.rect.y-A),a=new P(e.x,n.y-A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}const s=new P(e.x,Math.min(this.rect.y-A,n.y-A));return[...R.computeLLinePoints(o,s,!0),e]}toPoint(e){if(S.rectContains(e,new D(this.rect.x-A,this.rect.y,2*A,this.rect.height))){const r=new P(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}if(S.rectContains(e,new D(this.rect.x+this.rect.width-A,this.rect.y,2*A,this.rect.height))){const r=new P(this.rect.x+this.rect.width+A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}if(S.rectContains(e,new D(this.rect.x,this.rect.y+this.rect.height-A,this.rect.width,2*A))){const r=new P(this.rect.x-A,this.rect.y-A),i=new P(e.x,this.rect.y+this.rect.height+A),a=R.computeLLinePoints(this.startPoint,r,!0),c=R.computeLLinePoints(r,i,!0);return c.shift(),[...a,...c,e]}if(S.rectContains(e,new D(this.rect.x,this.rect.y-A,this.rect.width,2*A))){const r=new P(e.x,this.rect.y-A);return[...R.computeLLinePoints(this.startPoint,r,!0),e]}if(e.y<this.startPoint.y)return R.computeZLinePoints(this.startPoint,e,!0);if(e.x<this.rect.x||e.x>this.rect.x+this.rect.width)return[...R.computeLLinePoints(this.startPoint,new P(e.x,this.rect.y-A),!0),e];if(e.x<this.rect.x+.5*this.rect.width){const r=new P(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(this.startPoint,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}const n=new P(this.rect.x+this.rect.width+A,this.rect.y-A),o=R.computeLLinePoints(this.startPoint,n,!0),s=R.computeLLinePoints(n,e,!0);return s.shift(),[...o,...s]}}class _i extends po{bottom(t,e){const n=this.startPoint;if(t.y<n.y)return R.computeZLinePoints(n,t,!0);if(S.inDistance(n.x,e.x,e.width))if(n.x<e.x+.5*e.width){const r=new P(e.x-A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}else{const r=new P(e.x+e.width+A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}const o=new P(t.x,e.y+e.height+A);return[...R.computeLLinePoints(n,o,!0),t]}left(t,e){const n=this.startPoint;if(t.x>n.x)return R.computeZLinePoints(n,t,!1);if(S.inDistance(n.y,e.y,e.height))if(n.y<e.y+.5*e.height){const r=new P(e.x-A,e.y-A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}else{const r=new P(e.x-A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}const o=new P(e.x-A,t.y);return[...R.computeLLinePoints(n,o,!1),t]}right(t,e){const n=this.startPoint;if(t.x<n.x)return R.computeZLinePoints(n,t,!1);if(S.inDistance(n.y,e.y,e.height))if(n.y<e.y+.5*e.height){const r=new P(e.x+e.width+A,e.y-A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}else{const r=new P(e.x+e.width+A,e.y+e.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,t,!0);return a.shift(),[...i,...a]}const o=new P(e.x+e.width+A,t.y);return[...R.computeLLinePoints(n,o,!1),t]}toPoint(t){return S.computePolyLinePoints(this.startPoint,t)}top(t,e){const n=this.startPoint;if(t.y>n.y)return R.computeZLinePoints(n,t,!0);if(S.inDistance(n.x,e.x,e.width))if(n.x<e.x+.5*e.width){const r=new P(e.x-A,e.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}else{const r=new P(e.x+e.width+A,e.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,t,!1);return a.shift(),[...i,...a]}const o=new P(t.x,e.y-A);return[...R.computeLLinePoints(n,o,!0),t]}}class Wd extends po{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y+A<this.rect.y&&S.inDistance(e.x,this.rect.x,this.rect.width))if(e.x>this.rect.x+.5*this.rect.width){const i=new P(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),a=new P(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}else{const i=new P(this.rect.x-A,this.rect.y+this.rect.height+A),a=new P(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}if(o.y+A<n.y&&S.inDistance(o.x,n.x,n.width)){if(o.x<n.x+.5*n.width){const d=new P(n.x-A,this.rect.y+this.rect.height+A),u=new P(e.x,n.y+n.height+A),f=R.computeLLinePoints(o,d,!0),g=R.computeLLinePoints(d,u,!0);return g.shift(),[...f,...g,e]}const i=new P(n.x+n.width+A,this.rect.y+this.rect.height+A),a=new P(e.x,n.y+n.height+A),c=R.computeLLinePoints(o,i,!0),h=R.computeLLinePoints(i,a,!0);return h.shift(),[...c,...h,e]}const s=new P(e.x,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A));return[...R.computeLLinePoints(o,s,!0),e]}left(e,n){const o=this.startPoint;if(e.x>o.x&&e.y>o.y)return R.computeLLinePoints(o,e,!0);if(e.x>this.rect.x+this.rect.width+A&&e.y<o.y){const a=new P(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}if(e.x<this.rect.x+this.rect.width+A){const a=new P(Math.min(n.x-A,this.rect.x-A),Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new P(n.x-A,n.y-A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}right(e,n){const o=this.startPoint;if(e.x<o.x&&e.y>o.y)return R.computeLLinePoints(o,e,!0);if(n.x+n.width>this.rect.x-A){if(n.y<this.rect.y+this.rect.height+A){const a=new P(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),Math.max(this.rect.y+this.rect.height+A,n.y+n.height+A)),c=R.computeLLinePoints(o,a,!0),h=R.computeLLinePoints(a,e,!0);return h.shift(),[...c,...h]}const s=new P(n.x+n.width+A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}if(e.y<this.rect.y+this.rect.height+A){const s=new P(this.rect.x-A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!0),i=R.computeLLinePoints(s,e,!0);return i.shift(),[...r,...i]}return R.computeLLinePoints(o,e,!0)}toPoint(e){const n=this.startPoint;if(e.y>n.y)return R.computeZLinePoints(n,e,!0);if(S.inDistance(e.x,this.rect.x,this.rect.width))if(e.x<this.rect.x+.5*this.rect.width){const r=new P(this.rect.x-A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}else{const r=new P(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!0),a=R.computeLLinePoints(r,e,!0);return a.shift(),[...i,...a]}const o=new P(n.x,this.rect.y+this.rect.height+A),s=R.computeLLinePoints(o,e,!1);return[n,...s]}top(e,n){const o=this.startPoint;if(e.y>o.y)return R.computeZLinePoints(o,e,!0);if(n.x+n.width+A<this.rect.x){const c=new P(n.x+n.width+A,this.rect.y+this.rect.height+A),h=new P(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}if(n.x+n.width<o.x){const c=new P(n.x+-A,this.rect.y+this.rect.height+A),h=new P(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}if(n.x>this.rect.x+this.rect.width+A){const c=new P(n.x-A,this.rect.y+this.rect.height+A),h=new P(e.x,n.y-A),d=R.computeLLinePoints(o,c,!0),u=R.computeLLinePoints(c,h,!0);return u.shift(),[...d,...u,e]}const s=new P(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),this.rect.y+this.rect.height+A),r=new P(e.x,n.y-A),i=R.computeLLinePoints(o,s,!0),a=R.computeLLinePoints(s,r,!0);return a.shift(),[...i,...a,e]}}class Fd extends po{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.y<o.y){if(e.x<o.x)return R.computeLLinePoints(o,e,!1);const a=new P(this.rect.x-A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(e.y>o.y&&e.x<o.x){const a=new P(this.rect.x-A,e.y+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new P(this.rect.x-A,e.y+A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}left(e,n){const o=this.startPoint;if(e.y<this.rect.y){const i=new P(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,i,!1),e]}if(e.y>this.rect.y+this.rect.height){const i=new P(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,i,!1),e]}if(e.y<this.rect.y+this.rect.height&&e.x>this.rect.x+this.rect.width){const i=new P(this.rect.x-A,this.rect.y-A),a=new P(n.x-A,e.y),c=R.computeLLinePoints(o,i,!1),h=R.computeLLinePoints(i,a,!1);return h.shift(),[...c,...h,e]}const s=new P(Math.min(this.rect.x-A,n.x-A),e.y);return[...R.computeLLinePoints(o,s,!1),e]}right(e,n){const o=this.startPoint;if(e.x<o.x)return R.computeZLinePoints(o,e,!1);if(e.y<o.y){const c=new P(this.rect.x-A,n.y+n.height+A),h=new P(n.x+n.width+A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new P(this.rect.x-A,n.y-A),r=new P(n.x+n.width+A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}toPoint(e){const n=this.startPoint;if(e.x>n.x&&e.y<this.rect.y){const r=new P(this.rect.x-A,e.y);return[...R.computeLLinePoints(n,r,!1),e]}if(e.x>n.x&&e.y>this.rect.y&&e.y<n.y){const r=new P(this.rect.x-A,this.rect.y-A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,e,!1);return a.shift(),[...i,...a]}if(e.x>n.x&&e.y>n.y&&e.y<this.rect.y+this.rect.height){const r=new P(this.rect.x-A,this.rect.y+this.rect.height+A),i=R.computeLLinePoints(n,r,!1),a=R.computeLLinePoints(r,e,!1);return a.shift(),[...i,...a]}if(e.x<n.x)return R.computeZLinePoints(n,e,!1);const o=new P(this.rect.x-A,e.y);return[...R.computeLLinePoints(n,o,!1),e]}top(e,n){const o=this.startPoint;if(e.x>o.x&&e.y<this.rect.y+this.rect.height+A){const s=new P(this.rect.x-A,Math.min(this.rect.y-A,n.y-A)),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}if(e.y<o.y+2&&e.x<o.x){const s=new P(this.rect.x-A,n.y-A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}if(e.x>o.x&&e.y>this.rect.y+this.rect.height+A){const s=new P(this.rect.x-A,this.rect.y+this.rect.height+A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}return R.computeLLinePoints(o,e,!1)}}class Yd extends po{constructor(e,n){super(e);p(this,"rect");this.rect=n}bottom(e,n){const o=this.startPoint;if(e.x>o.x){if(e.y<o.y)return R.computeLLinePoints(o,e,!1);const a=new P(this.rect.x+this.rect.width+A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(e.y<this.rect.y){const a=new P(this.rect.x+this.rect.width+A,n.y+n.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new P(this.rect.x+this.rect.width+A,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}left(e,n){const o=this.startPoint;if(e.x>o.x)return R.computeZLinePoints(o,e,!1);if(e.y<this.rect.y){const c=new P(this.rect.x+this.rect.width+A,n.y+n.height+A),h=new P(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}if(e.y>this.rect.y+this.rect.height){const c=new P(this.rect.x+this.rect.width+A,n.y-A),h=new P(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}if(e.y<this.rect.y+.5*this.rect.height){const c=new P(this.rect.x+this.rect.width+A,Math.min(n.y-A,this.rect.y-A)),h=new P(n.x-A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new P(this.rect.x+this.rect.width+A,Math.max(n.y+n.height+A,this.rect.y+this.rect.height+A)),r=new P(n.x-A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}right(e,n){const o=this.startPoint;if(e.y<this.rect.y||e.y>this.rect.y+this.rect.height){const c=new P(Math.max(n.x+n.width+A,this.rect.x+this.rect.width+A),e.y);return[...R.computeLLinePoints(o,c,!1),e]}if(e.y<this.rect.y+.5*this.rect.height){const c=new P(this.rect.x+this.rect.width+A,this.rect.y-A),h=new P(n.x+n.width+A,e.y),d=R.computeLLinePoints(o,c,!1),u=R.computeLLinePoints(c,h,!1);return u.shift(),[...d,...u,e]}const s=new P(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),r=new P(n.x+n.width+A,e.y),i=R.computeLLinePoints(o,s,!1),a=R.computeLLinePoints(s,r,!1);return a.shift(),[...i,...a,e]}toPoint(e){const n=this.startPoint;if(e.x>n.x)return R.computeZLinePoints(n,e,!1);if(e.y<this.rect.y||e.y>this.rect.y+this.rect.height){const i=new P(this.rect.x+this.rect.width+A,e.y);return[...R.computeLLinePoints(n,i,!1),e]}if(e.y<this.rect.y+.5*this.rect.height){const i=new P(this.rect.x+this.rect.width+A,this.rect.y-A),a=R.computeLLinePoints(n,i,!1),c=R.computeLLinePoints(i,e,!1);return c.shift(),[...a,...c]}const o=new P(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),s=R.computeLLinePoints(n,o,!1),r=R.computeLLinePoints(o,e,!1);return r.shift(),[...s,...r]}top(e,n){const o=this.startPoint;if(e.y>o.y&&e.x>o.x)return R.computeLLinePoints(o,e,!1);if(e.y>this.rect.y+this.rect.height){const a=new P(this.rect.x+this.rect.width+A,this.rect.y+this.rect.height+A),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}if(n.x<this.rect.x+this.rect.width+A){const a=new P(Math.max(this.rect.x+this.rect.width+A,n.x+n.width+A),Math.min(n.y-A,this.rect.y-A)),c=R.computeLLinePoints(o,a,!1),h=R.computeLLinePoints(a,e,!1);return h.shift(),[...c,...h]}const s=new P(this.rect.x+this.rect.width+A,n.y-A),r=R.computeLLinePoints(o,s,!1),i=R.computeLLinePoints(s,e,!1);return i.shift(),[...r,...i]}}class Ze{static mockPointermoveEvent(t,e){return{pointerId:1,width:1,height:1,pressure:.5,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,type:"pointermove",pointerType:"mouse",isPrimary:!0,bubbles:!0,cancelable:!0,composed:!0,clientX:t.x,clientY:t.y,...e}}static getNodePos(t,{x:e,y:n}){const o=new P,{width:s,height:r}=t.baseProps;return o.x=e*s,o.y=n*r,t.toGlobal(o)}static computeConnectInfo(t,e,n,o=!1){const s=t.globalLinePoints,r={point:o?s[s.length-1]:s[0]};if(e){const i=n.nodeManager.getNode(e.objectId);i&&(r.nodeConnect={rect:D.rectNode2Rect(i.getBounds()),endType:S.computeNodeConnectEnd(e,i.baseProps.angle)},r.point=this.getNodePos(i,e))}return r}static computeLinePoints(t,e,n,o,s){const r=o.detect(F.NodeEdge,n),i=!S.pressMeta(n),c={point:s.alignLineEndAndDrawAlignLines(n,o,o.getSelectNodes(),i)};return r&&(c.point=new P(r.point.x,r.point.y),c.nodeConnect={rect:D.rectNode2Rect(r.node.getBounds()),endType:S.computeNodeConnectEnd(r.relativePos,r.node.baseProps.angle)}),e.layoutToPointsPro(t,c)}static trimAngle(t){const e=Math.floor(t/360);return t-e*360}static calculateAngle(t,e){return Math.abs(t.x-e.x)<.01?e.y>t.y?90:-90:Math.atan2(e.y-t.y,e.x-t.x)/Math.PI*180}static calculateAngle2(t,e){return Math.abs(t.x-e.x)<.01?e.y>t.y?.5*Math.PI:-.5*Math.PI:Math.atan2(e.y-t.y,e.x-t.x)}static trimPoint(t){return new P(Math.floor(t.x),Math.floor(t.y))}static overlapHorizonVertical(t,e,n){if(Ze.judgeHorizon(t,e)){if(t.y<n.minY||t.y>n.maxY)return!1;const s=t.x>e.x?e.x:t.x,r=t.x<e.x?e.x:t.x;if(s>n.maxX||r<n.minX)return!1}else{if(t.x<n.minX||t.x>n.maxX)return!1;const s=t.y>e.y?e.y:t.y,r=t.y<e.y?e.y:t.y;if(s>n.maxY||r<n.minY)return!1}return!0}static overlapHorizon(t,e,n,o,s){const r=o.y>s.y?s.y:o.y,i=o.y<s.y?s.y:o.y;if(r>n||i<n)return!1;const a=o.x>s.x?s.x:o.x,c=o.x<s.x?s.x:o.x;return!(a>e||c<t)}static overlapVertical(t,e,n,o,s){const r=o.x>s.x?s.x:o.x,i=o.x<s.x?s.x:o.x;if(r>n||i<n)return!1;const a=o.y>s.y?s.y:o.y,c=o.y<s.y?s.y:o.y;return!(a>e||c<t)}static overlapSimpleLine(t,e,n){if(this.overlapHorizon(n.minX,n.maxX,n.minY,t,e)||this.overlapHorizon(n.minX,n.maxX,n.maxY,t,e)||this.overlapVertical(n.minY,n.maxY,n.maxX,t,e)||this.overlapVertical(n.minY,n.maxY,n.minX,t,e))return!0;const o=t.x>e.x?e.x:t.x,s=t.x<e.x?e.x:t.x,r=t.y>e.y?e.y:t.y,i=t.y<e.y?e.y:t.y;return s<=n.maxX&&o>=n.minX&&i<=n.maxY&&r>=n.minY}static overlapPolyLine(t,e){for(let n=0;n<t.length-1;n++){const o=t[n],s=t[n+1];if(this.overlapHorizonVertical(o,s,e))return!0}return!1}static interactRect(t,e){return{minX:Math.max(t.minX,e.minX),maxX:Math.min(t.maxX,e.maxX),minY:Math.max(t.minY,e.minY),maxY:Math.min(t.maxY,e.maxY)}}static needDrawByDelete(t,e,n,o,s){const r=t.nodeManager.tree.search(e),i=new Set;for(const c of r){const h=t.nodeManager.nodeMap.get(c.id);h&&i.add(h)}s||i.add(o);const a=[...i];return a.sort((c,h)=>c.zIndex-h.zIndex),a}static layout(t,e){const n=[];return S.doubleMiddleInsertPoint(t,e,n),n}static judgeHorizon(t,e,n=.01){return Math.abs(t.y-e.y)<n}static judgeVertical(t,e,n=.01){return Math.abs(t.x-e.x)<n}static getOfflineCanvas(t,e,n){const o=D.rectNode2Rect(t),s=document.createElement("canvas");s.width=n*o.width,s.height=n*o.height;const r=s.getContext("2d");r.scale(n,n),r.translate(-o.x,-o.y);const i=e.searchNodesByRectNode(t);for(const a of i)a.drawOnGLCtx(r);return s}}class $i{constructor(t){p(this,"modes",[]);p(this,"currentMode");this.modes=t.modes,this.currentMode=t.modes[t.modes.length-1]}onEvent(t,e){this.reset(t,e);const n=this.convertInteractiveEvent(t,e);this.detect(n,e),this.currentMode.work(n,e),this.afterOnEvent(n,e)}refreshEvent(t,e){const n=t.lastInteractiveEvent.originEvent,o=new P(n.clientX,n.clientY),s=Ze.mockPointermoveEvent(o,e);s.target=t.gmlRender.canvas,this.onEvent(s,t)}detect(t,e){if(this.currentMode.canBeExit(t,e)){for(const n of this.modes)if(n.canBeEnable(t,e)){this.currentMode=n;return}}}reset(t,e){var n;e.reset();for(const[o,s]of e.detectors)s.reset();t.type!==((n=e.lastInteractiveEvent)==null?void 0:n.type)&&(e.lastDiffTypeEvent=e.lastInteractiveEvent)}afterOnEvent(t,e){this.record(t,e)}record(t,e){e.lastInteractiveEvent=t}convertInteractiveEvent(t,e){const n=e.gmlRender.canvas.getBoundingClientRect(),o=new P(t.clientX-n.x,t.clientY-n.y),s=e.gmlRender.transformToGlobal(o);return{clientPoint:new P(t.clientX,t.clientY),globalPoint:s,type:this.convertEventType(t,e),originEvent:t}}convertEventType(t,e){const n=t.type;return n==="pointerdown"?be.pointerDown:n==="pointermove"?t.target!=e.gmlRender.canvas?be.pointermoveOutside:be.pointermove:n==="pointerup"?be.pointerup:be.unknown}}class Gd{constructor(){p(this,"isWorking",!1);p(this,"initialTouchInfo",null);p(this,"lastTouchInfo",null);p(this,"SCALE_THRESHOLD",10);p(this,"MOVE_THRESHOLD",5)}enable(t){return t.touches.length===2}start(t,e){this.enable(t)&&(this.isWorking=!0,this.initialTouchInfo=this.getTouchInfo(t),this.lastTouchInfo=this.initialTouchInfo)}move(t,e){if(!this.isWorking||!this.lastTouchInfo)return;const n=this.getTouchInfo(t),o=e.renderManager.gmlRender.transformToGlobal(this.lastTouchInfo.centerPoint),s=n.distance/this.lastTouchInfo.distance;this.handleZoom(s,o,e);const r=n.centerPoint.x-this.lastTouchInfo.centerPoint.x,i=n.centerPoint.y-this.lastTouchInfo.centerPoint.y;this.handleScroll(r,i,e),this.lastTouchInfo=n}stop(t,e){this.isWorking=!1,this.initialTouchInfo=null,this.lastTouchInfo=null}getTouchInfo(t){const e=new P(t.touches[0].clientX,t.touches[0].clientY),n=new P(t.touches[1].clientX,t.touches[1].clientY),o=new P((e.x+n.x)/2,(e.y+n.y)/2),s=n.x-e.x,r=n.y-e.y,i=Math.sqrt(s*s+r*r);return{centerPoint:o,distance:i,touch1:e,touch2:n}}handleZoom(t,e,n){n.renderManager.zoomScale(t,e)}handleScroll(t,e,n){n.renderManager.scroll(-t,-e)}}class Wo{constructor(t,e){p(this,"eventCtx");p(this,"interactiveManager");p(this,"touchScrollZoomWorker");p(this,"onContextMenu",t=>{t.preventDefault()});p(this,"onTouchStart",t=>{if(this.touchScrollZoomWorker.enable(t)){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.start(t,this.eventCtx);return}});p(this,"onTouchMove",t=>{if(this.touchScrollZoomWorker.isWorking){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.move(t,this.eventCtx);return}t.preventDefault()});p(this,"onTouchEnd",t=>{if(this.touchScrollZoomWorker.isWorking){t.preventDefault(),t.stopPropagation(),this.touchScrollZoomWorker.stop(t,this.eventCtx);return}});p(this,"onPointerDown",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});p(this,"onPointerMove",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});p(this,"onPointerUp",t=>{this.touchScrollZoomWorker.isWorking||this.triggerEvent(t)});this.eventCtx=t,this.interactiveManager=new $i(e),this.touchScrollZoomWorker=new Gd}start(){document.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("contextmenu",this.onContextMenu);const t=this.eventCtx.renderManager.gmlRender.canvas;t&&(t.addEventListener("touchstart",this.onTouchStart),t.addEventListener("touchmove",this.onTouchMove),t.addEventListener("touchend",this.onTouchEnd))}stop(){document.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("contextmenu",this.onContextMenu);const t=this.eventCtx.renderManager.gmlRender.canvas;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchmove",this.onTouchMove),t.removeEventListener("touchend",this.onTouchEnd))}triggerEvent(t){this.onEnable(t)&&(this.interactiveManager.onEvent(t,this.eventCtx),this.afterEvent())}onEnable(t){return t.type!=="pointermove"&&t.target!==this.eventCtx.gmlRender.canvas?(this.eventCtx.inputManager.blur(),!1):!0}afterEvent(){}}const Ys=8,Gs=8,Us=500;var _e=(l=>(l[l.width=0]="width",l[l.height=1]="height",l[l.both=2]="both",l))(_e||{});const Cn=new Set([v.Line,v.Group]);class An{}class ji extends An{align(t,e,n,o,s,r){const i={minX:o.minX,maxX:o.maxX,minY:n.minY-r,maxY:n.minY+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.minY-y.minY)<r){const m=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new P(m,y.minY),end:new P(b,y.minY)};h.push({line:w,dx:0,dy:y.minY-n.minY})}if(Math.abs(n.minY-y.maxY)<r){const m=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new P(m,y.maxY),end:new P(b,y.maxY)};h.push({line:w,dx:0,dy:y.maxY-n.minY})}}if(h.length===0)return;const d=h.map(g=>g.dy),u=Math.min(...d),f={dx:0,dy:u,lines:[]};for(const g of h)Math.abs(g.dy-u)<.01&&f.lines.push(g.line);s.top=f}}class Vi extends An{align(t,e,n,o,s,r=2){const i={minX:o.minX,maxX:o.maxX,minY:n.maxY-r,maxY:n.maxY+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.maxY-y.minY)<r){const m=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new P(m,y.minY),end:new P(b,y.minY)};h.push({line:w,dx:0,dy:y.minY-n.maxY})}if(Math.abs(n.maxY-y.maxY)<r){const m=Math.min(n.minX,y.minX),b=Math.max(n.maxX,y.maxX),w={start:new P(m,y.maxY),end:new P(b,y.maxY)};h.push({line:w,dx:0,dy:y.maxY-n.maxY})}}if(h.length===0)return;const d=h.map(g=>g.dy),u=Math.min(...d),f={dx:0,dy:u,lines:[]};for(const g of h)Math.abs(g.dy-u)<.01&&f.lines.push(g.line);s.bottom=f}}class Ki extends An{align(t,e,n,o,s,r){const i={minX:n.minX-r,maxX:n.minX+r,minY:o.minY,maxY:o.maxY},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.minX-y.minX)<r){const m=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new P(y.minX,m),end:new P(y.minX,b)};h.push({line:w,dy:0,dx:y.minX-n.minX})}if(Math.abs(n.minX-y.maxX)<r){const m=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new P(y.maxX,m),end:new P(y.maxX,b)};h.push({line:w,dy:0,dx:y.maxX-n.minX})}}if(h.length===0)return;const d=h.map(g=>g.dx),u=Math.min(...d),f={dy:0,dx:u,lines:[]};for(const g of h)Math.abs(g.dx-u)<.01&&f.lines.push(g.line);s.left=f}}class Qi extends An{align(t,e,n,o,s,r){const i={minX:n.maxX-r,maxX:n.maxX+r,minY:o.minY,maxY:o.maxY},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(e.has(g)||Cn.has(g.type))continue;const y=g.getBounds();if(Math.abs(n.maxX-y.minX)<r){const m=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new P(y.minX,m),end:new P(y.minX,b)};h.push({line:w,dy:0,dx:y.minX-n.maxX})}if(Math.abs(n.maxX-y.maxX)<r){const m=Math.min(n.minY,y.minY),b=Math.max(n.maxY,y.maxY),w={start:new P(y.maxX,m),end:new P(y.maxX,b)};h.push({line:w,dy:0,dx:y.maxX-n.maxX})}}if(h.length===0)return;const d=h.map(g=>g.dx),u=Math.min(...d),f={dy:0,dx:u,lines:[]};for(const g of h)Math.abs(g.dx-u)<.01&&f.lines.push(g.line);s.right=f}}class Ud extends An{align(t,e,n,o,s,r){const i=.5*(n.minY+n.maxY),a={minX:o.minX,maxX:o.maxX,minY:i-r,maxY:i+r},c=t.nodeManager.searchNodesByRectNode(a),h=S.filterSlideContainerNodes(t,c),d=[];for(const y of h){if(e.has(y)||Cn.has(y.type))continue;const m=y.getBounds(),b=.5*(m.minY+m.maxY);if(Math.abs(i-b)<r){const w=Math.min(n.minX,n.maxX,m.maxX,m.minX),L=Math.max(n.minX,n.maxX,m.maxX,m.minX),B={start:new P(w,b),end:new P(L,b)};d.push({line:B,dx:0,dy:b-i})}}if(d.length===0)return;const u=d.map(y=>y.dy),f=Math.min(...u),g={dx:0,dy:f,lines:[]};for(const y of d)Math.abs(y.dy-f)<.01&&g.lines.push(y.line);s.horizonMid=g}}class _d extends An{align(t,e,n,o,s,r){const i=.5*(n.minX+n.maxX),a={minX:i-r,maxX:i+r,minY:o.minY,maxY:o.maxY},c=t.nodeManager.searchNodesByRectNode(a),h=S.filterSlideContainerNodes(t,c),d=[];for(const y of h){if(e.has(y)||Cn.has(y.type))continue;const m=y.getBounds(),b=.5*(m.minX+m.maxX);if(Math.abs(i-b)<r){const w=Math.min(n.minY,n.maxY,m.maxY,m.minY),L=Math.max(n.minY,n.maxY,m.maxY,m.minY),B={start:new P(b,w),end:new P(b,L)};d.push({line:B,dx:b-i,dy:0})}}if(d.length===0)return;const u=d.map(y=>y.dx),f=Math.min(...u),g={dx:f,dy:0,lines:[]};for(const y of d)Math.abs(y.dx-f)<.01&&g.lines.push(y.line);s.verticalMid=g}}class Zi{constructor(){p(this,"handlers",[new ji,new Ud,new Vi,new Ki,new _d,new Qi])}align(t,e,n){const o=n.gmlRender.getViewPortBounds(),s=Ys/n.gmlRender.getScale(),r=new Set;for(const a of e)this.computeFilterSet(a,r);const i={};for(const a of this.handlers)a.align(n,r,t,o,i,s);return this.dealAlignTopBottom(i),this.dealAlignLeftRight(i),i}computeFilterSet(t,e){e.add(t);const n=t.children;for(const o of n)this.computeFilterSet(o,e)}dealAlignTopBottom(t){const{top:e,bottom:n,horizonMid:o}=t,s=[e,o,n].map(i=>i==null?void 0:i.dy).filter(i=>i!==void 0);if(s.length===0)return;const r=Math.min(...s);for(const i of["top","bottom","horizonMid"]){const a=t[i];a&&Math.abs(r-a.dy)>.01&&(t[i]=void 0)}}dealAlignLeftRight(t){const{left:e,right:n,verticalMid:o}=t,s=[e,n,o].map(i=>i==null?void 0:i.dx).filter(i=>i!==void 0);if(s.length===0)return;const r=Math.min(...s);for(const i of["left","right","verticalMid"]){const a=t[i];a&&Math.abs(r-a.dx)>.01&&(t[i]=void 0)}if(e&&n){if(Math.abs(e.dx-n.dx)<.01)return;e.dx<n.dx?t.right=void 0:t.left=void 0}}}const _s=new Set([v.Group,v.Line]);class $s{}class qi extends $s{enable(t){return t===_e.both||t===_e.width}align(t,e,n,o,s,r,i,a){const c=n.maxX-n.minX,h=this.searchNodes(t,c,s,n,o,r,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),f=[];for(const y of h)Math.abs(y.dt-u)<.01&&f.push(y.info);const g={dt:u,sideSize:c,lines:f};e.width=g}searchNodes(t,e,n,o,s,r,i,a){let c=200;const h={minX:o.minX-c,maxX:o.maxX+c,minY:o.minY-c,maxY:o.maxY+c},d=[];for(;d.length===0&&!(c>i||S.containRect(h,r));){const u=this.searchNodesForOffset(t,e,n,h,s,r,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(t,e,n,o,s,r,i,a){const c=t.nodeManager.searchNodesByRectNode(r),h=S.filterSlideContainerNodes(t,c),d=[];for(const u of h){if(s.has(u)||_s.has(u.type))continue;const{width:f,height:g,angle:y}=u.baseProps,m=y%360;if(!(Math.abs(m)>30)&&Math.abs(f-e)<a){const b={x:0,y:g},w={x:f,y:g};d.push({dt:f-e,sideSize:f,info:{line:{start:b,end:w},transform:u.globalTransform().clone()}})}}return d}}class Ji extends $s{enable(t){return t===_e.both||t===_e.height}align(t,e,n,o,s,r,i,a){const c=n.maxY-n.minY,h=this.searchNodes(t,c,s,n,o,r,i,a);if(h.length===0)return;const d=h.map(y=>y.dt),u=Math.min(...d),f=[];for(const y of h)Math.abs(y.dt-u)<.01&&f.push(y.info);const g={dt:u,sideSize:c,lines:f};e.height=g}searchNodes(t,e,n,o,s,r,i,a){let c=200;const h={minX:o.minX-c,maxX:o.maxX+c,minY:o.minY-c,maxY:o.maxY+c},d=[];for(;d.length===0&&!(c>i||S.containRect(h,r));){const u=this.searchNodesForOffset(t,e,n,h,s,r,c,a);d.push(...u),c=2*c}return d}searchNodesForOffset(t,e,n,o,s,r,i,a){const c=t.nodeManager.searchNodesByRectNode(r),h=S.filterSlideContainerNodes(t,c),d=[];for(const u of h){if(s.has(u)||_s.has(u.type))continue;const{width:f,height:g,angle:y}=u.baseProps,m=y%360;if(!(Math.abs(m)>30)&&Math.abs(g-e)<a){const b={x:f,y:0},w={x:f,y:g};d.push({dt:g-e,sideSize:g,info:{line:{start:b,end:w},transform:u.transform.clone()}})}}return d}}class ea{constructor(){p(this,"handlers",[new qi,new Ji])}align(t,e,n,o,s,r,i){const a={};for(const c of this.handlers)c.enable(o)&&c.align(t,a,e,n,o,s,r,i);return a}}class ta{}class $d extends ta{align(t,e,n,o,s,r){const i={minX:o.minX,maxX:o.maxX,minY:n.y-r,maxY:n.y+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(this.skipNodeAlign(e,g))continue;const y=g.getBounds(),m=[y.minY,y.maxY];for(const b of m)if(Math.abs(n.y-b)<r){const w=Math.min(n.x,y.minX,y.maxX),L=Math.max(n.x,y.minX,y.maxX),B={start:new P(w,b),end:new P(L,b)};h.push({line:B,dx:0,dy:b-n.y})}}if(h.length===0)return;const d=h.map(g=>g.dy),u=Math.min(...d),f={dx:0,dy:u,lines:[]};for(const g of h)Math.abs(g.dy-u)<.01&&f.lines.push(g.line);s.horizon=f}skipNodeAlign(t,e){if(t.has(e))return!0;if(e.type===v.Line){const n=e;if(n.shapeType!==he.Line)return!0;const o=n.points;return!S.judgeHorizon(o[0],o[o.length-1])}return e.type===v.Group}}class jd extends ta{align(t,e,n,o,s,r){const i={minY:o.minY,maxY:o.maxY,minX:n.x-r,maxX:n.x+r},a=t.nodeManager.searchNodesByRectNode(i),c=S.filterSlideContainerNodes(t,a),h=[];for(const g of c){if(this.skipNodeAlign(e,g))continue;const y=g.getBounds(),m=[y.minX,y.maxX];for(const b of m)if(Math.abs(n.x-b)<r){const w=Math.min(n.y,y.minY,y.maxY),L=Math.max(n.y,y.minY,y.maxY),B={start:new P(b,w),end:new P(b,L)};h.push({line:B,dx:b-n.x,dy:0})}}if(h.length===0)return;const d=h.map(g=>g.dx),u=Math.min(...d),f={dx:u,dy:0,lines:[]};for(const g of h)Math.abs(g.dx-u)<.01&&f.lines.push(g.line);s.vertical=f}skipNodeAlign(t,e){if(t.has(e))return!0;if(e.type===v.Line){const n=e;if(n.shapeType!==he.Line)return!0;const o=n.points;return!S.judgeVertical(o[0],o[o.length-1])}return e.type===v.Group}}class Vd{constructor(){p(this,"handlers",[new $d,new jd])}align(t,e,n){const o=n.gmlRender.getViewPortBounds(),s=Ys/n.gmlRender.getScale(),r={};for(const i of this.handlers)i.align(n,e,t,o,r,s);return r}}class $t{static addAllParentToSet(t,e){let n=t.parent;for(;n&&n.type===v.Group;)e.add(n),n=n.parent}static findHoverNode(t,e){if(t.parent.type!==v.Group)return t;const n=new Set;for(const s of e)n.add(s.parent);let o=t.parent;if(n.has(o))return t;for(;o;){const s=o.parent;if(n.has(s))return o;if(s.type!==v.Group)break;o=s}return o}static flattenNodes(t){const e=new Set;for(const n of t)this.flattenGroupNodes(n,e);return[...e]}static flattenGroupNodes(t,e){if(t.type!==v.Group){e.add(t);return}const o=t.children;for(const s of o)this.flattenGroupNodes(s,e)}}class dn{constructor(){p(this,"alignMoveWorker",new Zi);p(this,"alignStretchWorker",new ea);p(this,"alignLineEndWorker",new Vd)}alignLineEnd(t,e,n,o){return o?this.alignLineEndWorker.align(t,e,n):{}}alignMove(t,e,n,o){if(!o)return{};const s=new Set;for(const r of e)this.addChildrenToFilterSet(r,s);return this.alignMoveWorker.align(t,s,n)}alignStretch(t,e,n,o,s,r,i){const a=D.toRectNode(e),c=new Set(n);for(const d of[...n])$t.addAllParentToSet(d,c);return this.alignStretchWorker.align(t,a,c,o,s,r,i)}alignLineEndAndDrawAlignLines(t,e,n=e.getSelectNodes(),o=!0){const s=t.globalPoint.clone(),r=this.alignLineEnd(s,n,e,o),i=[];return r.horizon&&(i.push(...r.horizon.lines),s.y+=r.horizon.dy),r.vertical&&(i.push(...r.vertical.lines),s.x+=r.vertical.dx),e.addOrUpdate(k.AlignLine,{lines:i}),s}drawAlignLines(t,e){const{top:n,bottom:o,horizonMid:s,right:r,left:i,verticalMid:a}=t,c=[],h=new P;return n&&(h.y=n.dy,c.push(...n.lines)),s&&(h.y=s.dy,c.push(...s.lines)),o&&(h.y=o.dy,c.push(...o.lines)),i&&(h.x=i.dx,c.push(...i.lines)),a&&(h.x=a.dx,c.push(...a.lines)),r&&(h.x=r.dx,c.push(...r.lines)),e.addOrUpdate(k.AlignLine,{lines:c}),h}addChildrenToFilterSet(t,e){e.add(t);const n=t.children;for(const o of n)this.addChildrenToFilterSet(o,e)}}class qe{}class Ot{constructor(t){p(this,"processors",[]);this.processors=t}work(t,e){for(const n of this.processors)n.allowEventTypeSet.has(t.type)&&n.process(t,e)}stop(t,e){for(const n of this.processors)n.stop&&n.stop(t,e)}isStreaming(){return!1}}class un extends Ot{constructor(e){super(e);p(this,"deltaDistance",1);p(this,"locked",!1)}clickEnable(e,n){return!0}canBeEnable(e,n){if(e.type!==be.pointerDown)return!1;const o=this.clickEnable(e,n);return o&&(this.locked=!0),o}work(e,n){e.type===be.pointerup&&(this.locked=!1),e.type!==be.pointerDown&&n.lastDiffTypeEvent&&S.distance(n.lastDiffTypeEvent.globalPoint,e.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}}class jt{constructor(){p(this,"downHandlers",[]);p(this,"upHandlers",[]);p(this,"hasWorking",!1);p(this,"allowEventTypeSet",new Set([be.pointerDown,be.pointerup]))}registerDownHandler(t){this.downHandlers.push(t)}registerUpHandler(t){this.upHandlers.push(t)}process(t,e){this.downProcess(t,e),this.upProcess(t,e)}stop(t,e){this.hasWorking=!1}downProcess(t,e){if(t.type===be.pointerDown){for(const n of this.downHandlers)if(n.enable(t,e)){this.hasWorking=!0,n.handle(t,e);return}}}upProcess(t,e){if(t.type===be.pointerup){if(this.hasWorking){this.hasWorking=!1;return}for(const n of this.upHandlers)if(n.enable(t,e)){n.handle(t,e);return}}}}class js extends Ot{constructor(e){super(e);p(this,"deltaDistance",1);p(this,"locked",!1);p(this,"firstPointerDown",!1)}canBeEnable(e,n){return e.type===be.pointerDown?this.firstPointerDown?(this.locked=!0,!0):(this.firstPointerDown=!0,setTimeout(()=>{this.firstPointerDown=!1},300),!1):!1}work(e,n){this.firstPointerDown&&e.type===be.pointerup&&(this.locked=!1),e.type===be.pointermove&&S.distance(n.lastInteractiveEvent.globalPoint,e.globalPoint)>this.deltaDistance/n.gmlRender.getScale()&&(this.locked=!1),this.firstPointerDown||(this.locked=!1),super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}}class dt extends Ot{constructor(e,n=[]){super(n);p(this,"streamProcessor");p(this,"deltaDistance",1);p(this,"locked",!1);this.streamProcessor=e}onDown(e,n){}canBeEnable(e,n){var i;if(e.type===be.pointerDown&&this.onDown(e,n),!(((i=n.lastDiffTypeEvent)==null?void 0:i.type)===be.pointerDown&&e.type===be.pointermove))return!1;const s=n.lastDiffTypeEvent.globalPoint;if(S.distance(s,e.globalPoint)<this.deltaDistance/n.gmlRender.getScale())return!1;const r=this.streamEnable(n.lastDiffTypeEvent,n);if(r){this.locked=!0;for(const a of this.streamProcessor)a.onStart(n.lastDiffTypeEvent,n)}return r}work(e,n){if(e.type===be.pointermove)for(const o of this.streamProcessor)o.onMove(e,n);if(e.type===be.pointerup){for(const o of this.streamProcessor)o.onUp(e,n);this.locked=!1}super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}isStreaming(){return this.locked}}class pn{constructor(t){p(this,"currentSubMode");p(this,"subModes",[]);this.subModes=t,this.currentSubMode=t[t.length-1]}canBeExit(t,e){return this.currentSubMode.canBeExit(t,e)}work(t,e){this.detect(t,e),this.currentSubMode.work(t,e)}detect(t,e){if(this.currentSubMode.canBeExit(t,e)){for(const n of this.subModes)if(n.canBeEnable(t,e)){this.currentSubMode=n;return}}}}class Nn extends Ot{constructor(e,n=[]){super(n);p(this,"streamProcessor");p(this,"locked",!1);this.streamProcessor=e}canBeEnable(e,n){if(e.type!==be.pointerDown)return!1;const o=this.streamEnable(e,n);return o&&(this.locked=!0),o}work(e,n){if(e.type===be.pointerDown)for(const o of this.streamProcessor)o.onStart(e,n);if(e.type===be.pointermove)for(const o of this.streamProcessor)o.onMove(e,n);if(e.type===be.pointerup){for(const o of this.streamProcessor)o.onUp(e,n);this.locked=!1}super.work(e,n)}canBeExit(e,n){const o=!this.locked;return o&&this.stop(e,n),o}isStreaming(){return this.locked}}class ht{constructor(){p(this,"allowEventTypeSet",new Set([be.pointerDown,be.pointermove,be.pointerup]))}process(t,e){}}class na{}class oa extends Ke{onDetect(t,e){if(e.detect(F.Stretch,t)||e.detect(F.Rotate,t)||e.detect(F.LineEndPoint,t))return!1;const r=t.globalPoint;let i=e.nodeManager.searchNodes(r.x,r.y);i=S.filterSlideContainerNodes(e,i);let a=[];for(const c of i)c.type!==v.Group&&c.contains(t.globalPoint,e.gmlRender.getScale())&&a.push(c);return a.length===0?(this.result=null,!1):(a=S.sortGraphics(a),a.reverse(),this.result=a,!0)}}class sa extends Ke{onDetect(t,e){const n=e.detect(F.Node,t);if(!n)return!1;const o=n[0];if(n.length===1&&e.auxiliaryManager.selectManager.include(o))return!1;if(t.originEvent.metaKey)return this.result=o,!0;const s=e.getSelectNodes(),r=$t.findHoverNode(o,s);return r?(this.result=r,!0):(this.result=o,!0)}}const ys=class ys extends Ke{computeLocalPoint(t,e,n){if(t.length===1){const i=t[0],a=i.baseProps,c=i.toLocal(e.globalPoint),h=D.baseProps2Rect(a);return{localPoint:c,rect:h}}const o=n.auxiliaryManager.selectManager.getSelectBounds(),s=D.rectNode2Rect(o);return{localPoint:new P(e.globalPoint.x-s.x,e.globalPoint.y-s.y),rect:s}}onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size===0||e.detect(F.ExpandShape,t))return!1;const s=$t.flattenNodes([...n]),r=e.gmlRender.getScale(),i=ys.HOT_DISTANCE/r,{rect:a,localPoint:c}=this.computeLocalPoint(s,t,e),h=new D(0,0,a.width,a.height),d=S.detectRectBounds(h,c,i);return d?(this.result={nodes:s,type:d.type,angle:S.computeStretchAngle(s,d.type)},!0):!1}};p(ys,"HOT_DISTANCE",8);let Fo=ys;class ra extends ht{constructor(){super(...arguments);p(this,"start",null)}onStart(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);n.setCursor("text"),this.start=i,n.execAction(new W)}onMove(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);this.start.equal(i)?n.execAction(ee.focus(s.id,this.start)):n.execAction(ee.selection(s.id,this.start,i))}onUp(e,n){const{renderText:o,node:s}=n.inputManager.editTextInfo,r=s.toLocal(e.globalPoint),i=o.detect(r);this.start.equal(i)?n.execAction(ee.focus(s.id,this.start)):n.execAction(ee.selection(s.id,this.start,i)),n.execAction(new z)}}class ia extends dt{constructor(){super([new ra])}streamEnable(t,e){const n=e.inputManager.editTextInfo;if(!n)return!1;const{node:o,renderText:s}=n,r=o.getTextContentRect(),i=o.toLocal(t.globalPoint);return!!S.rectContains(i,r)}}class on{constructor(){p(this,"parentGroupSet",new Set)}start(t){this.parentGroupSet.clear();for(const e of t)$t.addAllParentToSet(e,this.parentGroupSet)}work(t,e){if(this.parentGroupSet.size===0)return;const n=S.sortGraphics([...this.parentGroupSet]).reverse();for(const o of n){const s=o.computeBasePropsByChildren();t.execAction(new U({infos:[{id:o.id,props:[s]}]},{streaming:e}))}}}class fn{}class Kd extends fn{enable(t){return!(!(t instanceof Fn)||t.cropProps.cropType===wt.None||!t.cropProps.cropInfo)}handle(t,e,n,o,s){const r=this.handleCropProp(t,e,n,o,s);return[{id:t.id,props:[r]}]}handleCropProp(t,e,n,o,s){const r=e.crop,i=e.crop.globalImgPos,a=r.originCropProps,c=a.cropType,h=s.crossPoint(new P(i.x,i.y)),d=t.toLocal(h);return{type:I.Crop,cropInfo:{imgX:d.x,imgY:d.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*o},cropType:c}}}class Qd extends en{updateProps(t){super.updateProps(t),t.find(n=>n.type===I.Base)&&this.updateTransformMatrix()}getTextContentRect(){return this.baseProps}getConnectAnchor(){return[new P(.5,0),new P(1,.5),new P(.5,1),new P(0,.5)]}borderContains(t,e){const n=this.toLocal(t),{width:o,height:s}=this.baseProps,r=q.rectangle({top:0,left:0,width:o,height:s}),i=q.line({x:n.x-e,y:n.y},{x:n.x+e,y:n.y}),a=q.line({x:n.x,y:n.y-e},{x:n.x,y:n.y+e});for(const c of[i,a]){const h=Y.intersect(r,c);if(h.points.length>0)return h.points[0]}return null}}class Yo extends Qd{get checkStatus(){return this.getProp(I.CheckStatus).checkStatus}constructor(t,e){super(t,e),this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.CheckStatus,new Qt),this.props.set(I.Color,new tt),this.props.set(I.Shape,new Oe)}drawOnGLCtx(t){this.drawCheckboxBorder(t),this.drawCheckboxIcon(t)}drawCheckboxBorder(t){const e=this.getProp(I.Border),n=this.baseProps;if(e.color!==""&&e.alpha!==0&&e.dashType!==et.None){const{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();t.save(),t.transform(o,s,r,i,a,c),t.beginPath(),t.roundRect(0,0,n.width,n.height,4),t.lineWidth=e.width,t.strokeStyle=e.color,t.globalAlpha=e.alpha,S.setDashLine(e,t),t.stroke(),t.restore()}}drawCheckboxIcon(t){if(!this.checkStatus)return;const e=this.getProp(I.Color),n=this.baseProps;if(e.color!==""&&e.alpha!==0){t.save();const o=re.generateMatrix().scale(n.width/16,n.height/16),{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform().crossProduct(o);t.transform(s,r,i,a,c,h),t.fillStyle=e.color,t.globalAlpha=e.alpha,t.scale(1,1),t.beginPath();const d=new Path2D("M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z");t.fill(d),t.restore()}}checkboxContain(t){return this.contains(t)}canQuickCreate(){return!1}canBeConnected(){return!0}static load(t,e,n,o,s,r){const i=new Yo(t,r);return i.type=e,i.zIndex=n,i.setParent(s),i.updateProps(o),i}}const aa=1;class Gn extends Yo{constructor(e,n){super(e,n);p(this,"renderText");p(this,"checkboxTopPadding",aa);this.props.set(I.Text,new Ge),this.props.set(I.CheckSize,new vn),this.renderText=new ho}get textProps(){return this.props.get(I.Text)}get chickSize(){return this.props.get(I.CheckSize).size}updateProps(e){super.updateProps(e);const n=e.find(r=>r.type===I.Text),o=e.find(r=>r.type===I.Base),s=e.find(r=>r.type===I.CheckSize);if(n||o||s){const r=this.getTextContentRect();if(this.renderText.typesetting(this.graphicContext,this.textProps,r),this.baseProps.height=this.renderText.height+2*le,this.renderText.rect.height=this.renderText.height+2*le,this.renderText.paragraphs.length>0){const i=this.renderText.paragraphs[0];if(i.lines.length>0){const a=i.lines[0];this.checkboxTopPadding=.5*(a.height-this.chickSize)}}}}drawOnGLCtx(e){super.drawOnGLCtx(e),this.drawText(e)}drawCheckboxBorder(e){const n=this.getProp(I.Border);if(n.color!==""&&n.alpha!==0&&n.dashType!==et.None){const o=this.chickSize,{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.save(),e.transform(s,r,i,a,c,h),e.beginPath(),e.roundRect(0,le+this.checkboxTopPadding,o,o,4),e.lineWidth=n.width,e.strokeStyle=n.color,e.globalAlpha=n.alpha,S.setDashLine(n,e),e.stroke(),e.restore()}}drawCheckboxIcon(e){if(!this.checkStatus)return;const n=this.getProp(I.Color);if(n.color!==""&&n.alpha!==0){e.save();const o=this.chickSize,s=re.generateMatrix().scale(o/16,o/16),r=re.generateMatrix().translate(0,this.checkboxTopPadding+le),{a:i,b:a,c,d:h,e:d,f:u}=this.globalTransform().crossProduct(r).crossProduct(s);e.transform(i,a,c,h,d,u),e.fillStyle=n.color,e.globalAlpha=n.alpha,e.scale(1,1),e.beginPath();const f=new Path2D("M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z");e.fill(f),e.restore()}}drawText(e){const{alpha:n}=this.getProp(I.Color);e.save(),e.beginPath();const o=this.globalPos;this.renderText.draw(e,new P(o.x,o.y),n),e.restore()}checkboxContain(e){const{height:n}=this.baseProps,o=this.toLocal(e);return S.rectContains(o,new D(0,0,n,n))}getTextContentRect(){const{width:e,height:n}=this.baseProps,o=this.chickSize;return{x:o+le,y:le,width:e-2*le-o-aa,height:n-2*le}}static load(e,n,o,s,r,i){const a=new Gn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class Go extends ht{constructor(){super(...arguments);p(this,"minStretchSize",new P(0,0));p(this,"originPos",new P(0,0));p(this,"originStretchRect");p(this,"propsMap",new Map);p(this,"originTransform",re.generateMatrix());p(this,"viewBounds");p(this,"target",null);p(this,"alignWorker",new dn);p(this,"alignType",_e.width);p(this,"originWidthHeightRatio",1);p(this,"isUniform",!1);p(this,"relatedLines",new Set);p(this,"layoutWorker",new Rn);p(this,"cropStretchHandler",new Kd);p(this,"groupBaseWorker",new on)}recordNodePropInfo(e){const{x:n,y:o,width:s,height:r}=e.globalBaseProps,i=this.originTransform.crossPoint({x:n,y:o}),a={x:i.x,y:i.y,width:s,height:r};if(e instanceof Fn){const c=e.cropProps,h=e.getOriginImageRect().clone(),d=e.toGlobal({x:h.x,y:h.y}),u={originCropProps:c.clone(),originImgRect:h,originTransform:e.globalTransform().inverseMatrix().clone(),globalImgPos:this.originTransform.crossPoint(d)};a.crop=u}return e instanceof vt&&e.shapeType===K.PureText&&(a.fontSize=e.textProps.fontSize),e instanceof Gn&&(a.fontSize=e.textProps.fontSize,a.checkSize=e.chickSize),a}computeAnchorPoint(e,n){const{width:o,height:s}=n;switch(e.type){case V.TOP:return this.alignType=_e.height,{x:.5*o,y:s};case V.RIGHT:return this.alignType=_e.width,{x:0,y:.5*s};case V.BOTTOM:return this.alignType=_e.height,{x:.5*o,y:0};case V.LEFT:return this.alignType=_e.width,{x:o,y:.5*s};case V.TOP_LEFT:return this.alignType=_e.both,{x:o,y:s};case V.TOP_RIGHT:return this.alignType=_e.both,{x:0,y:s};case V.BOTTOM_RIGHT:return this.alignType=_e.both,{x:0,y:0};case V.BOTTOM_LEFT:default:return this.alignType=_e.both,{x:o,y:0}}}judgeUniform(e){this.isUniform=!1;const n=this.target.nodes;for(const o of n){if(Math.abs(o.baseProps.angle)>.1){this.isUniform=!0;return}if(o.type===v.SVG||o.type===v.IMG||o.type===v.Checkbox){this.isUniform=!0;return}if(o.type===v.Shape&&o.shapeType===K.PureText&&(this.target.type===V.TOP||this.target.type===V.TOP_LEFT||this.target.type===V.BOTTOM_LEFT||this.target.type===V.BOTTOM||this.target.type===V.BOTTOM_RIGHT||this.target.type===V.TOP_RIGHT)){this.isUniform=!0;return}if(o.type===v.CheckboxText&&(this.target.type===V.TOP||this.target.type===V.TOP_LEFT||this.target.type===V.BOTTOM_LEFT||this.target.type===V.BOTTOM||this.target.type===V.BOTTOM_RIGHT||this.target.type===V.TOP_RIGHT)){this.isUniform=!0;return}}}computeStretchRect(e,n){switch(this.target.type){case V.BOTTOM:e.height+=n.y;break;case V.LEFT:e.x+=n.x,e.width-=n.x;break;case V.RIGHT:e.width+=n.x;break;case V.TOP:e.y+=n.y,e.height-=n.y;break;case V.BOTTOM_LEFT:e.height+=n.y,e.x+=n.x,e.width-=n.x;break;case V.BOTTOM_RIGHT:e.height+=n.y,e.width+=n.x;break;case V.TOP_LEFT:e.y+=n.y,e.height-=n.y,e.x+=n.x,e.width-=n.x;break;case V.TOP_RIGHT:e.y+=n.y,e.height-=n.y,e.width+=n.x;break}e.width<this.minStretchSize.x&&(e.width=this.minStretchSize.x),e.height<this.minStretchSize.y&&(e.height=this.minStretchSize.y)}computeTarget(e,n){this.target=n.detect(F.Stretch,e)}onStart(e,n){this.computeTarget(e,n),this.originStretchRect=this.getStretchRect(n),this.originWidthHeightRatio=this.originStretchRect.width/this.originStretchRect.height,this.computeOriginTransform(n),this.minStretchSize=this.getMiniSize(n),this.judgeUniform(n),this.originPos=this.originTransform.crossPoint(e.globalPoint),this.recordPropsMap(n),this.relatedLines.clear(),this.batchCollectNodeLinks(this.target.nodes,n,this.relatedLines),this.groupBaseWorker.start(this.target.nodes),this.viewBounds=n.gmlRender.getViewPortBounds(),n.actionManager.execAction(new W);const o=[];for(const s of this.target.nodes)(s.type===v.CheckboxText||s instanceof vt&&s.shapeType===K.PureText)&&(this.target.type===V.RIGHT||this.target.type===V.LEFT)&&o.push({id:s.id,props:[{type:I.Text,sizeMode:We.autoHeight}]}),s instanceof vt&&this.target.type!==V.RIGHT&&this.target.type!==V.LEFT&&o.push({id:s.id,props:[{type:I.Text,sizeMode:We.fix}]});n.actionManager.execAction(new U({infos:o})),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id))}onMove(e,n){n.auxiliaryManager.removeAlignGraphics(),this.stretchNode(e,n,!0)}onUp(e,n){this.stretchNode(e,n,!1),n.actionManager.execAction(new z),n.auxiliaryManager.removeAlignGraphics()}alignStretchGlobalPoint(e,n){const o=new Set(this.target.nodes),s=!S.pressMeta(e);return this.alignWorker.alignLineEndAndDrawAlignLines(e,n,o,s)}stretchNode(e,n,o){const s=this.alignStretchGlobalPoint(e,n),r=this.originTransform.crossPoint(s),i=new P(r.x-this.originPos.x,r.y-this.originPos.y),a=this.originStretchRect.clone();this.computeStretchRect(a,i);const c=n.gmlRender.getScale(),h=new Set(this.target.nodes),d=this.alignWorker.alignStretch(n,a,h,this.alignType,this.viewBounds,Us/c,Gs/c);this.drawAlignLine(a,d,n);const{sx:u,sy:f}=this.computeScale(a),g=re.generateMatrix().scale(u,f),y=this.originTransform.inverseMatrix().crossProduct(g),m=[],b=[],w=[];for(const[L,B]of this.propsMap){for(const H of this.handlers)if(H.enable(L)){const E=H.handle(L,B,u,f,y,n,this.isUniform);m.push(...E);break}L.type===v.SVG&&b.push(L),this.cropStretchHandler.enable(L)&&w.push(L)}n.execAction(new U({infos:m},{streaming:o})),this.afterStretchNode(n,u,f,y,o,w,b),this.layoutWorker.work([...this.relatedLines],n,o),this.groupBaseWorker.work(n,o)}afterStretchNode(e,n,o,s,r,i,a){if(i.length>0){const c=[];i.forEach(h=>{c.push(...this.cropStretchHandler.handle(h,this.propsMap.get(h),n,o,s))}),e.execAction(new U({infos:c},{streaming:r}))}if(r||e.asyncRenderNodeManager.batchAddRenderNode(a),this.target.type===V.BOTTOM_RIGHT){const c=[...this.target.nodes],h=c[0];if(c.length===1)e.addOrUpdate(k.HoverSize,{rect:D.baseProps2Rect(h.baseProps),transform:h.globalTransform().clone()});else{const d=e.auxiliaryManager.selectManager.getSelectBounds();e.addOrUpdate(k.HoverSize,{rect:D.rectNode2Rect(d),transform:re.generateMatrix().translate(d.minX,d.minY)})}}}computeScale(e){let n=e.width/this.originStretchRect.width,o=e.height/this.originStretchRect.height;if(!this.isUniform)return{sx:n,sy:o};const s=this.target.type;if(s===V.BOTTOM||s===V.TOP)return n=o,{sx:n,sy:o};if(s===V.LEFT||s===V.RIGHT)return o=n,{sx:n,sy:o};const r=e.width/e.height;return r>this.originWidthHeightRatio?o=n:r<this.originWidthHeightRatio&&(n=o),{sx:n,sy:o}}batchCollectNodeLinks(e,n,o){const s=n.getSelectNodes();for(const r of e)this.collectNodeLinks(r,n,s,o)}collectNodeLinks(e,n,o,s){const r=n.nodeManager.getNodeLinks(e);for(const i of r)o.has(i)||s.add(i);for(const i of e.children)i.type===v.Line&&this.collectNodeLinks(i,n,o,s)}}class Zd extends fn{enable(t){return t.type===v.Section}handle(t,e,n,o,s,r){const i=s.crossPoint({x:e.x,y:e.y}),a=t.baseProps,c=t.parent.toLocal(i),h=new P(c.x-a.x,c.y-a.y),d=[{id:t.id,props:[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}]}];if(t.type===v.Section&&t.children.size>0){const u=t,f=this.computeSectionChildren(u,r);for(const g of f){const y=g.baseProps;if(g.type===v.Line){const m=g.points.map(w=>new P(w.x,w.y));for(const w of m)w.x-=h.x,w.y-=h.y;const b=D.rectNode2Rect(S.getBoundsByPoints(m));d.push({id:g.id,props:[{type:I.Line,points:m},{type:I.Base,x:b.x,y:b.y,width:b.width,height:b.height}]})}else d.push({id:g.id,props:[{type:I.Base,x:y.x-h.x,y:y.y-h.y}]})}}return d}computeSectionChildren(t,e){const n=t.children,o=new Set;for(const s of n)s.type===v.Group?$t.flattenGroupNodes(s,o):o.add(s);return o}}class ca extends fn{enable(t){return!0}handle(t,e,n,o,s){const r=s.crossPoint({x:e.x,y:e.y}),i=t.parent.toLocal(r);return[{id:t.id,props:[{type:I.Base,x:i.x,y:i.y,width:e.width*n,height:e.height*o}]}]}}class la extends fn{enable(t){return t.type!==v.Shape?!1:t.shapeType===K.PureText}handle(t,e,n,o,s,r,i){const a=s.crossPoint({x:e.x,y:e.y}),c=t.parent.toLocal(a),d=[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}],u=t.getProp(I.Text);if(i&&u){const f=e.fontSize*o,g={type:I.Text,fontSize:f};d.push(g)}return[{id:t.id,props:d}]}}class ha extends fn{enable(t){return t.type===v.CheckboxText}handle(t,e,n,o,s,r,i){const a=s.crossPoint({x:e.x,y:e.y}),c=t.parent.toLocal(a),d=[{type:I.Base,x:c.x,y:c.y,width:e.width*n,height:e.height*o}],u=t.getProp(I.Text);if(i&&u){const f=e.fontSize*o,g={type:I.Text,fontSize:f};d.push(g);const y=e.checkSize*n;d.push({type:I.CheckSize,size:y})}return[{id:t.id,props:d}]}}class da extends Go{constructor(){super(...arguments);p(this,"handlers",[new Zd,new la,new ha,new ca])}getStretchRect(e){const n=[...e.getSelectNodes()];return D.baseProps2Rect(n[0].baseProps)}getMiniSize(e){return[...e.getSelectNodes()][0].getStretchMinSize()}recordPropsMap(e){this.propsMap.clear();const n=this.target.nodes;for(const o of n){const s=this.recordNodePropInfo(o);this.propsMap.set(o,s)}}computeOriginTransform(e){const n=this.target,o=[...e.getSelectNodes()][0],{x:s,y:r,width:i,height:a,angle:c}=o.globalBaseProps,h=re.generateMatrix().rotate(-c),d=re.generateMatrix().translate(-s,-r),u=this.computeAnchorPoint(n,new D(0,0,i,a)),g=re.generateMatrix().translate(-u.x,-u.y).crossProduct(h.crossProduct(d));this.originTransform=g}drawAlignLine(e,n,o){const s=this.target.nodes[0],r=s.baseProps,{width:i,height:a}=n,c=s.globalTransform().clone();if(i){e.width+=i.dt;const h={transform:c,line:{start:new P(0,r.height),end:new P(r.width,r.height)}};i.lines.push(h)}if(a){e.height+=a.dt;const h={transform:c,line:{start:new P(r.width,0),end:new P(r.width,r.height)}};a.lines.push(h)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}}class ua extends Nn{constructor(){super([new da])}streamEnable(t,e){if(e.getSelectNodes().size===0)return!1;const n=e.detect(F.Stretch,t);return n?n.nodes.filter(s=>S.judgeNodeCanBeStretch(s)).length===1:!1}}class Vs{handleChangeRelation(t,e,n){if(t.parent===e)return[];if(t.parent.type===v.Group)return[];const o=t.globalPos,s=e.toLocal(o);return[{id:t.id,props:[{type:I.Base,x:s.x,y:s.y}],parentId:e.id,zIndex:n}]}}class pa extends Vs{enable(t){return t.type===v.Line}handle(t,e){const n=t.baseProps.clone();n.x+=e.x,n.y+=e.y;const o=t.getProp(I.Line).clone();for(const s of o.points)s.x+=e.x,s.y+=e.y;return[{id:t.id,props:[n,o]}]}handleChangeRelation(t,e,n){if(t.parent===e)return[];const o=t.globalLinePoints,s=e.globalTransform().inverseMatrix(),r=o.map(a=>s.crossPoint(a)),i=S.getBoundsByPoints(r);return[{id:t.id,props:[{type:I.Base,x:i.minX,y:i.minY},{type:I.Line,points:r}],parentId:e.id,zIndex:n}]}}class fa extends Vs{enable(t){return!0}handle(t,e){const n=t.baseProps.clone();return n.x+=e.x,n.y+=e.y,[{id:t.id,props:[n]}]}}var fo=(l=>(l[l.Resource=0]="Resource",l[l.Template=1]="Template",l))(fo||{});class Ks{work(t){const e=t.getSelectNodes();return e.size===0?null:this.copyByIds([...e].map(n=>n.id),t)}copyByIds(t,e){const n=[];if(t.forEach(i=>{const a=e.nodeManager.getNode(i);a&&n.push(a)}),n.length===0)return null;const o=D.rectNode2Rect(e.auxiliaryManager.selectManager.getSelectBounds()),s=[],r=[];for(const i of n){const a=this.makeupPasteDO(i,!0,r);s.push(a)}return s.sort((i,a)=>i.zIndex-a.zIndex),{meta:{docId:e.docState.docId,resourceType:fo.Resource},nodes:s,bounds:o,resources:r}}makeupPasteDO(t,e=!1,n){const{id:o,zIndex:s,capInfo:r,type:i}=t.serializeTo(),a={id:o,type:i,zIndex:s,capInfo:r,children:[]};if(this.collectResourceInfo(t,n),e){const u=t.globalPos;a.capInfo.baseProps.x=u.x,a.capInfo.baseProps.y=u.y,t instanceof Ct&&(a.capInfo.lineProps.points=[...t.globalLinePoints])}const c=t.children;if(c.size===0)return a;const h=[],d=e&&t.type===v.Group;for(const u of c)h.push(this.makeupPasteDO(u,d,n));return h.sort((u,f)=>u.zIndex-f.zIndex),a.children=h,a}collectResourceInfo(t,e){if(t.type===v.IMG){const n=t;e.push({type:zn.Image,fileKey:n.imgSrc})}if(t.type===v.SVG){const n=t;n.svgProps.useCode||e.push({type:zn.SVG,fileKey:n.svgUrl})}}}let go=class{};class ga extends go{handle(t,e){const n=t.find(o=>o.type===I.Base);n&&(n.x+=e.x,n.y+=e.y)}}let ya=class extends go{handle(t,e,n){const o=t.find(i=>i.type===I.Connect);if(!o)return;const{start:s,end:r}=o;if(s){const i=n.get(s.objectId);i?s.objectId=i:o.start=null}if(r){const i=n.get(r.objectId);i?r.objectId=i:o.end=null}}};class xa extends go{handle(t,e){const n=t.find(o=>o.type===I.Line);if(n)for(const o of n.points)o.x+=e.x,o.y+=e.y}}var wa={exports:{}};function qd(l){throw new Error('Could not dynamically require "'+l+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qs={exports:{}};const Jd=Yh(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Pa;function eu(){return Pa||(Pa=1,function(l,t){(function(e,n){l.exports=n()})(io,function(){var e=e||function(n,o){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof io<"u"&&io.crypto&&(s=io.crypto),!s&&typeof qd=="function")try{s=Jd}catch{}var r=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function w(){}return function(L){var B;return w.prototype=L,B=new w,w.prototype=null,B}}(),a={},c=a.lib={},h=c.Base=function(){return{extend:function(w){var L=i(this);return w&&L.mixIn(w),(!L.hasOwnProperty("init")||this.init===L.init)&&(L.init=function(){L.$super.init.apply(this,arguments)}),L.init.prototype=L,L.$super=this,L},create:function(){var w=this.extend();return w.init.apply(w,arguments),w},init:function(){},mixIn:function(w){for(var L in w)w.hasOwnProperty(L)&&(this[L]=w[L]);w.hasOwnProperty("toString")&&(this.toString=w.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=c.WordArray=h.extend({init:function(w,L){w=this.words=w||[],L!=o?this.sigBytes=L:this.sigBytes=w.length*4},toString:function(w){return(w||f).stringify(this)},concat:function(w){var L=this.words,B=w.words,H=this.sigBytes,E=w.sigBytes;if(this.clamp(),H%4)for(var X=0;X<E;X++){var $=B[X>>>2]>>>24-X%4*8&255;L[H+X>>>2]|=$<<24-(H+X)%4*8}else for(var Z=0;Z<E;Z+=4)L[H+Z>>>2]=B[Z>>>2];return this.sigBytes+=E,this},clamp:function(){var w=this.words,L=this.sigBytes;w[L>>>2]&=4294967295<<32-L%4*8,w.length=n.ceil(L/4)},clone:function(){var w=h.clone.call(this);return w.words=this.words.slice(0),w},random:function(w){for(var L=[],B=0;B<w;B+=4)L.push(r());return new d.init(L,w)}}),u=a.enc={},f=u.Hex={stringify:function(w){for(var L=w.words,B=w.sigBytes,H=[],E=0;E<B;E++){var X=L[E>>>2]>>>24-E%4*8&255;H.push((X>>>4).toString(16)),H.push((X&15).toString(16))}return H.join("")},parse:function(w){for(var L=w.length,B=[],H=0;H<L;H+=2)B[H>>>3]|=parseInt(w.substr(H,2),16)<<24-H%8*4;return new d.init(B,L/2)}},g=u.Latin1={stringify:function(w){for(var L=w.words,B=w.sigBytes,H=[],E=0;E<B;E++){var X=L[E>>>2]>>>24-E%4*8&255;H.push(String.fromCharCode(X))}return H.join("")},parse:function(w){for(var L=w.length,B=[],H=0;H<L;H++)B[H>>>2]|=(w.charCodeAt(H)&255)<<24-H%4*8;return new d.init(B,L)}},y=u.Utf8={stringify:function(w){try{return decodeURIComponent(escape(g.stringify(w)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(w){return g.parse(unescape(encodeURIComponent(w)))}},m=c.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(w){typeof w=="string"&&(w=y.parse(w)),this._data.concat(w),this._nDataBytes+=w.sigBytes},_process:function(w){var L,B=this._data,H=B.words,E=B.sigBytes,X=this.blockSize,$=X*4,Z=E/$;w?Z=n.ceil(Z):Z=n.max((Z|0)-this._minBufferSize,0);var se=Z*X,ne=n.min(se*4,E);if(se){for(var ae=0;ae<se;ae+=X)this._doProcessBlock(H,ae);L=H.splice(0,se),B.sigBytes-=ne}return new d.init(L,ne)},clone:function(){var w=h.clone.call(this);return w._data=this._data.clone(),w},_minBufferSize:0});c.Hasher=m.extend({cfg:h.extend(),init:function(w){this.cfg=this.cfg.extend(w),this.reset()},reset:function(){m.reset.call(this),this._doReset()},update:function(w){return this._append(w),this._process(),this},finalize:function(w){w&&this._append(w);var L=this._doFinalize();return L},blockSize:16,_createHelper:function(w){return function(L,B){return new w.init(B).finalize(L)}},_createHmacHelper:function(w){return function(L,B){return new b.HMAC.init(w,B).finalize(L)}}});var b=a.algo={};return a}(Math);return e})}(Qs)),Qs.exports}(function(l,t){(function(e,n){l.exports=n(eu())})(io,function(e){return function(n){var o=e,s=o.lib,r=s.WordArray,i=s.Hasher,a=o.algo,c=[];(function(){for(var y=0;y<64;y++)c[y]=n.abs(n.sin(y+1))*4294967296|0})();var h=a.MD5=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(y,m){for(var b=0;b<16;b++){var w=m+b,L=y[w];y[w]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360}var B=this._hash.words,H=y[m+0],E=y[m+1],X=y[m+2],$=y[m+3],Z=y[m+4],se=y[m+5],ne=y[m+6],ae=y[m+7],te=y[m+8],ce=y[m+9],pe=y[m+10],Be=y[m+11],Re=y[m+12],Se=y[m+13],Te=y[m+14],fe=y[m+15],O=B[0],G=B[1],j=B[2],_=B[3];O=d(O,G,j,_,H,7,c[0]),_=d(_,O,G,j,E,12,c[1]),j=d(j,_,O,G,X,17,c[2]),G=d(G,j,_,O,$,22,c[3]),O=d(O,G,j,_,Z,7,c[4]),_=d(_,O,G,j,se,12,c[5]),j=d(j,_,O,G,ne,17,c[6]),G=d(G,j,_,O,ae,22,c[7]),O=d(O,G,j,_,te,7,c[8]),_=d(_,O,G,j,ce,12,c[9]),j=d(j,_,O,G,pe,17,c[10]),G=d(G,j,_,O,Be,22,c[11]),O=d(O,G,j,_,Re,7,c[12]),_=d(_,O,G,j,Se,12,c[13]),j=d(j,_,O,G,Te,17,c[14]),G=d(G,j,_,O,fe,22,c[15]),O=u(O,G,j,_,E,5,c[16]),_=u(_,O,G,j,ne,9,c[17]),j=u(j,_,O,G,Be,14,c[18]),G=u(G,j,_,O,H,20,c[19]),O=u(O,G,j,_,se,5,c[20]),_=u(_,O,G,j,pe,9,c[21]),j=u(j,_,O,G,fe,14,c[22]),G=u(G,j,_,O,Z,20,c[23]),O=u(O,G,j,_,ce,5,c[24]),_=u(_,O,G,j,Te,9,c[25]),j=u(j,_,O,G,$,14,c[26]),G=u(G,j,_,O,te,20,c[27]),O=u(O,G,j,_,Se,5,c[28]),_=u(_,O,G,j,X,9,c[29]),j=u(j,_,O,G,ae,14,c[30]),G=u(G,j,_,O,Re,20,c[31]),O=f(O,G,j,_,se,4,c[32]),_=f(_,O,G,j,te,11,c[33]),j=f(j,_,O,G,Be,16,c[34]),G=f(G,j,_,O,Te,23,c[35]),O=f(O,G,j,_,E,4,c[36]),_=f(_,O,G,j,Z,11,c[37]),j=f(j,_,O,G,ae,16,c[38]),G=f(G,j,_,O,pe,23,c[39]),O=f(O,G,j,_,Se,4,c[40]),_=f(_,O,G,j,H,11,c[41]),j=f(j,_,O,G,$,16,c[42]),G=f(G,j,_,O,ne,23,c[43]),O=f(O,G,j,_,ce,4,c[44]),_=f(_,O,G,j,Re,11,c[45]),j=f(j,_,O,G,fe,16,c[46]),G=f(G,j,_,O,X,23,c[47]),O=g(O,G,j,_,H,6,c[48]),_=g(_,O,G,j,ae,10,c[49]),j=g(j,_,O,G,Te,15,c[50]),G=g(G,j,_,O,se,21,c[51]),O=g(O,G,j,_,Re,6,c[52]),_=g(_,O,G,j,$,10,c[53]),j=g(j,_,O,G,pe,15,c[54]),G=g(G,j,_,O,E,21,c[55]),O=g(O,G,j,_,te,6,c[56]),_=g(_,O,G,j,fe,10,c[57]),j=g(j,_,O,G,ne,15,c[58]),G=g(G,j,_,O,Se,21,c[59]),O=g(O,G,j,_,Z,6,c[60]),_=g(_,O,G,j,Be,10,c[61]),j=g(j,_,O,G,X,15,c[62]),G=g(G,j,_,O,ce,21,c[63]),B[0]=B[0]+O|0,B[1]=B[1]+G|0,B[2]=B[2]+j|0,B[3]=B[3]+_|0},_doFinalize:function(){var y=this._data,m=y.words,b=this._nDataBytes*8,w=y.sigBytes*8;m[w>>>5]|=128<<24-w%32;var L=n.floor(b/4294967296),B=b;m[(w+64>>>9<<4)+15]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360,m[(w+64>>>9<<4)+14]=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360,y.sigBytes=(m.length+1)*4,this._process();for(var H=this._hash,E=H.words,X=0;X<4;X++){var $=E[X];E[X]=($<<8|$>>>24)&16711935|($<<24|$>>>8)&4278255360}return H},clone:function(){var y=i.clone.call(this);return y._hash=this._hash.clone(),y}});function d(y,m,b,w,L,B,H){var E=y+(m&b|~m&w)+L+H;return(E<<B|E>>>32-B)+m}function u(y,m,b,w,L,B,H){var E=y+(m&w|b&~w)+L+H;return(E<<B|E>>>32-B)+m}function f(y,m,b,w,L,B,H){var E=y+(m^b^w)+L+H;return(E<<B|E>>>32-B)+m}function g(y,m,b,w,L,B,H){var E=y+(b^(m|~w))+L+H;return(E<<B|E>>>32-B)+m}o.MD5=i._createHelper(h),o.HmacMD5=i._createHmacHelper(h)}(Math),e.MD5})})(wa);var tu=wa.exports;const nu=Ns(tu);class ve{constructor(){p(this,"prefix","001");p(this,"map",new Map);p(this,"zIndex",0)}setPrefix(t){this.prefix=t}genId(t){const e=(this.map.get(t)||0)+1;return this.map.set(t,e),ve.type2NodePrefix(t)+this.prefix+":"+e}static genImgFileName(t,e){const n="img:"+t+"|"+e;return nu(n).toString()}loadNode(t){this.loadNodeId(t.id)}loadNodeId(t){const e=ve.nodePrefix2Type(t[0]),n=t.split(":");try{const o=parseInt(n[1]),s=this.map.get(e);s!==void 0?s<o&&this.map.set(e,o):this.map.set(e,o)}catch(o){console.error("id错误",o)}}static genZIndex(t){return t.children.size===0?1:[...t.children].sort((n,o)=>o.zIndex-n.zIndex)[0].zIndex+1}static type2NodePrefix(t){switch(t){case v.Shape:return"a";case v.Line:return"c";case v.SVG:return"d";case v.IMG:return"e";case v.Section:return"f";case v.Group:return"g";case v.Checkbox:return"i";case v.CheckboxText:return"j";case v.SlideContainer:return"k";default:return"x"}}static nodePrefix2Type(t){return t==="a"?v.Shape:t==="c"?v.Line:t==="d"?v.SVG:t==="e"?v.IMG:t==="f"?v.Section:t==="g"?v.Group:t==="i"?v.Checkbox:t==="j"?v.CheckboxText:t==="k"?v.SlideContainer:v.Shape}}class ma{work(t,e,n,o){const s=new Map;this.recordIdMap(e,t,s);const r=[],i=[];let a=ve.genZIndex(t.nodeManager.root);for(const h of e){const d=this.convertToAddNodeInfo(t,h,s,n,r,Sn,a,o);a++,i.push(d)}return{addNodeData:{nodes:r},nextFocusIds:i}}convertToAddNodeInfo(t,e,n,o,s,r,i,a){const c=n.get(e.id),h=this.convertToProps(e.capInfo,o,n,a),d={id:c,type:e.type,zIndex:i,parentId:r,props:h};s.push(d);const u=new P;e.type===v.Group&&(u.x=o.x,u.y=o.y);for(const f of e.children)this.convertToAddNodeInfo(t,f,n,u,s,c,f.zIndex,a);return c}convertToProps(t,e,n,o){const s=S.convertCapInfoToProps(t);for(const r of this.propsHandler)r.handle(s,e,n,o);return s}recordIdMap(t,e,n){for(const o of t){const s=e.idGenerator.genId(o.type);n.set(o.id,s);const r=o.children;this.recordIdMap(r,e,n)}}}class ba extends ma{constructor(){super(...arguments);p(this,"propsHandler",[new ga,new ya,new xa])}}class Zs{constructor(){p(this,"copyWorker",new Ks);p(this,"pasteWorker",new ba)}work(t,e){var d;const n=this.copyWorker.work(t);if(!n)return;let o;e?o=e:o=new P(20,20);const s=n.nodes,r=JSON.parse(JSON.stringify(s)),{addNodeData:i,nextFocusIds:a}=this.pasteWorker.work(t,r,o),c=[...t.getSelectNodes()];c.length===1&&((d=c[0].parent)==null?void 0:d.type)===v.SlideContainer?(i.nodes[0].parentId=c[0].parent.id,i.nodes[0].zIndex=ve.genZIndex(c[0].parent),t.execAction(new Le(i)),this.handleSlideContainerDuplicate(t,c[0],a[0])):t.execAction(new Le(i)),t.execAction(xe.create(a))}duplicateByIds(t,e,n){var u;const o=this.copyWorker.copyByIds(t,e);if(!o)return;let s;n?s=n:s=new P(20,20);const r=o.nodes,i=JSON.parse(JSON.stringify(r)),{addNodeData:a,nextFocusIds:c}=this.pasteWorker.work(e,i,s),h=[];t.forEach(f=>{const g=e.nodeManager.getNode(f);g&&h.push(g)}),h.length===1&&((u=h[0].parent)==null?void 0:u.type)===v.SlideContainer?(a.nodes[0].parentId=h[0].parent.id,a.nodes[0].zIndex=ve.genZIndex(h[0].parent),e.execAction(new Le(a)),this.handleSlideContainerDuplicate(e,h[0],c[0])):e.execAction(new Le(a)),e.execAction(xe.create(c))}handleSlideContainerDuplicate(t,e,n){const o=e.parent,s=o.slideProps.children,r=this.getNodePosition(o,e.id);if(!r)return;const{rowIndex:i,colIndex:a}=r,c=s.map((g,y)=>{if(y===i){const m=[...g.ids];return m.splice(a+1,0,n),{ids:m}}return{ids:[...g.ids]}}),h=[{id:o.id,props:[St.create({children:c})]}],d=c[i],u=t.nodeManager.getNode(e.id);if(u){let g=u.baseProps.x+u.baseProps.width+nt;const y=u.baseProps.y;for(let m=a+1;m<d.ids.length;m++){const b=d.ids[m],w=t.nodeManager.getNode(b);w&&(h.push({id:b,props:[ie.create({x:g,y,width:w.baseProps.width,height:w.baseProps.height})]}),g+=w.baseProps.width+nt)}}t.execAction(new U({infos:h}));const f=[];for(const g of c)for(const y of g.ids){const m=t.nodeManager.getNode(y);m&&f.push(m.baseProps)}if(f.length>0){const g=S.getBoundsByBasePropsList(f),y=g.maxX-g.minX+2*nt,m=g.maxY-g.minY+2*xt;t.execAction(U.create(o.id,[{type:I.Base,width:y,height:m}]))}}getNodePosition(t,e){const n=t.slideProps.children;for(let o=0;o<n.length;o++){const s=n[o];for(let r=0;r<s.ids.length;r++)if(s.ids[r]===e)return{rowIndex:o,colIndex:r}}return null}}class Sa extends Vs{enable(t){return t.type===v.Group}handle(t,e,n){const o=[],s=t.baseProps.clone();s.x+=e.x,s.y+=e.y,o.push({id:t.id,props:[s]});for(const r of t.children)o.push(...n.handle(r,e));return o}handleChangeRelation(t,e,n){if(t.parent===e)return[];if(t.parent.type===v.Group)return[];const o=t.globalPos,s=e.toLocal(o),r=[];r.push({id:t.id,props:[{type:I.Base,x:s.x,y:s.y}],parentId:e.id,zIndex:n});for(const i of t.children)this.handlePosChange(i,e,r);return r}handlePosChange(t,e,n){if(t.type===v.Line){const s=t.globalLinePoints.map(a=>e.toLocal(a)),r=D.rectNode2Rect(S.getBoundsByPoints(s)),i={id:t.id,props:[{type:I.Line,points:s},{type:I.Base,x:r.x,y:r.y,width:r.width,height:r.height}]};n.push(i)}else{const o=t.globalPos,s=e.toLocal(o),r={id:t.id,props:[{type:I.Base,x:s.x,y:s.y}]};n.push(r)}if(t.type===v.Group)for(const o of t.children)this.handlePosChange(o,e,n)}}class Ma{constructor(t){p(this,"handlers");this.handlers=t}handle(t,e){for(const n of this.handlers)if(n.enable(t))return n.handle(t,e,this);return[]}handleRelation(t,e,n){for(const o of this.handlers)if(o.enable(t))return o.handleChangeRelation(t,e,n);return[]}}class va extends ht{constructor(){super(...arguments);p(this,"moveRect",null);p(this,"lastPos",new P(0,0));p(this,"lastMoveRectPos",new P);p(this,"targetNodes",[]);p(this,"alignWorker",new dn);p(this,"layoutWorker",new Rn);p(this,"duplicateWorker",new Zs);p(this,"groupBaseWorker",new on);p(this,"handlerCtx",new Ma([new pa,new Sa,new fa]))}computeMoveNodes(e,n){e.originEvent.altKey&&this.duplicateWorker.work(n,new P);const o=n.getSelectNodes(),s=this.recordNodeMap(o),r=[];for(const i of o)if(i.type===v.Line){const a=i,{start:c,end:h}=a.connectProps;if(c&&h&&s.has(c.objectId)&&s.has(h.objectId)){r.push(i);continue}if(!c&&h&&s.has(h.objectId)){r.push(i);continue}if(!h&&c&&s.has(c.objectId)){r.push(i);continue}!h&&!c&&r.push(i)}else r.push(i);return r}recordNodeMap(e){const n=new Map;for(const o of e)n.set(o.id,o);return n}onStart(e,n){n.actionManager.execAction(new W),this.targetNodes=this.computeMoveNodes(e,n),this.targetNodes.length!==0&&(this.lastPos=e.globalPoint.clone(),this.moveRect=n.auxiliaryManager.selectManager.getSelectBounds(),this.lastMoveRectPos=new P(this.moveRect.minX,this.moveRect.minY),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.targetNodes))}onMove(e,n){if(n.auxiliaryManager.removeAlignGraphics(),this.targetNodes.length===0)return;this.moveNode(e,n,!0);const o=this.hoverOnContainer(e,n);o&&n.addOrUpdate(k.HoverContainer,{node:o})}judgeLinkLineRelation(e,n,o){const{start:s,end:r}=e.connectProps;let i=null,a=null;return s&&(i=n.nodeManager.getNode(s.objectId)),r&&(a=n.nodeManager.getNode(r.objectId)),i?!!(!a||o.has(a)):a?!!o.has(a):!1}onUp(e,n){this.targetNodes.length!==0&&(this.moveNode(e,n,!1),this.changeNodesRelation(e,n),n.actionManager.execAction(new z),n.auxiliaryManager.removeAlignGraphics())}changeNodesRelation(e,n){const o=this.hoverOnContainer(e,n)||n.nodeManager.root,s=n.getSelectNodes(),r=new Set;for(const u of s)u.type!==v.SlideContainer&&r.add(u);const i=new Set;for(const u of s)n.nodeManager.getNodeLinks(u).forEach(g=>i.add(g));for(const u of i)this.judgeLinkLineRelation(u,n,s)&&r.add(u);const a=[],c=o.children.size===0?0:Math.max(...[...o.children].map(u=>u.zIndex));let h=1;const d=S.sortGraphics([...r]);for(const u of d){if(u.parent===o)continue;const f=this.handlerCtx.handleRelation(u,o,c+h);a.push(...f),h++}a.length>0&&n.execAction(new U({infos:a}))}moveNode(e,n,o){const s=e.globalPoint,r=!S.pressMeta(e),i=new P(s.x-this.lastPos.x,s.y-this.lastPos.y);this.moveRectChange(this.moveRect,i);const a=this.alignWorker.alignMove(this.moveRect,n.getSelectNodes(),n,r),c=this.alignWorker.drawAlignLines(a,n),h=this.checkAlign(a),d=S.cloneIRectNode(this.moveRect),u={x:0,y:0};if(h){const y=d.minX+c.x,m=d.minY+c.y;u.x=y-this.lastMoveRectPos.x,u.y=m-this.lastMoveRectPos.y,this.lastMoveRectPos.x=y,this.lastMoveRectPos.y=m}else u.x=i.x,u.y=i.y,this.lastMoveRectPos.x+=i.x,this.lastMoveRectPos.y+=i.y;const f=[];for(const y of this.targetNodes){const m=this.handlerCtx.handle(y,u);f.push(...m)}const g=new Set;this.batchCollectNodeLinks(this.targetNodes,n,g),n.execAction(new U({infos:f},{streaming:o})),this.groupBaseWorker.work(n,o),this.layoutWorker.work([...g],n,o),this.lastPos=s}hoverOnContainer(e,n){const o=n.detect(F.HoverOnContainer,e);return o||null}moveRectChange(e,n){e.minX+=n.x,e.maxX+=n.x,e.minY+=n.y,e.maxY+=n.y}checkAlign(e){const{top:n,bottom:o,right:s,left:r,horizonMid:i,verticalMid:a}=e;return n!==void 0||o!==void 0||s!==void 0||r!==void 0||i!==void 0||a!==void 0}batchCollectNodeLinks(e,n,o){const s=n.getSelectNodes();for(const r of e)this.collectNodeLinks(r,n,s,o)}collectNodeLinks(e,n,o,s){const r=n.nodeManager.getNodeLinks(e);for(const i of r)o.has(i)||s.add(i);for(const i of e.children)i.type!==v.Line&&this.collectNodeLinks(i,n,o,s)}}class Ia extends dt{constructor(){super([new va])}streamEnable(t,e){if(e.auxiliaryManager.selectManager.selectNodes.size===0)return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds(),s=D.rectNode2Rect(o);if(s.width<.1||s.height<.1){const i=q.line({x:s.x,y:s.y},{x:o.maxX,y:o.maxY}),a=q.circle(t.globalPoint,4/e.gmlRender.getScale());return Y.intersect(i,a).points.length>0}return S.rectContains2(t.globalPoint,o)}}class Ta{}class ou extends Ta{enable(t){return t.originEvent.metaKey}handle(t,e,n){for(const o of e)S.containRect(t,o.getBounds())&&n.add(o)}drawGroupRect(t,e){t.addOrUpdate(k.SelectGroup,{rect:e,isPrecise:!0})}}class su extends Ta{enable(t){return!0}handle(t,e,n){for(const o of e){if(o.type===v.Section||o.type===v.SlideContainer){S.containRect(t,o.getBounds())&&n.add(o);continue}o.overlapRect(t)&&n.add(o)}}drawGroupRect(t,e){t.addOrUpdate(k.SelectGroup,{rect:e})}}class La extends ht{constructor(){super(...arguments);p(this,"startPoint",null);p(this,"handlers",[new ou,new su])}onStart(e,n){this.startPoint=e.globalPoint,n.actionManager.execAction(new W),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),n.actionManager.execAction(xe.create([]))}onMove(e,n){if(!this.startPoint)return;const o=Math.min(e.globalPoint.x,this.startPoint.x),s=Math.max(e.globalPoint.x,this.startPoint.x),r=Math.min(e.globalPoint.y,this.startPoint.y),i=Math.max(e.globalPoint.y,this.startPoint.y),a={id:"group-rect",minX:o,maxX:s,minY:r,maxY:i},c=D.rectNode2Rect(a),h=n.nodeManager.searchNodes(o,r,s,i),d=new Set;for(const y of this.handlers)if(y.enable(e)){y.handle(a,h,d),y.drawGroupRect(n,c);break}const u=S.computeSelectNodes(d),g=S.filterSlideContainerNodes(n,u).map(y=>y.id);n.actionManager.execAction(xe.create(g))}onUp(e,n){n.actionManager.execAction(new z),n.removeAuxGraphic(k.SelectGroup),this.startPoint=null}}class qs extends dt{constructor(){super([new La])}streamEnable(t,e){if(t.originEvent.metaKey)return!0;const n=e.detect(F.Node,t);if(n&&n.length>0&&e.auxiliaryManager.selectManager.include(n[0])&&n[0].contains(t.globalPoint))return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds();return!S.rectContains2(t.globalPoint,o)}}class yo{moveForward(t){const e=t.getSelectNodes();if(e.size===0)return;t.execAction(new W);const n=S.sortGraphics([...e]).reverse();for(const o of n){const s=this.moveNodeForward(o);s&&t.execAction(s)}t.execAction(new z)}moveBackward(t){const e=t.getSelectNodes();if(e.size===0)return;t.execAction(new W);const n=S.sortGraphics([...e]);for(const o of n){const s=this.moveNodeBackward(o);s&&t.execAction(s)}t.execAction(new z)}moveToUp(t){const e=t.getSelectNodes();if(e.size===0)return;const n=new Map;for(const o of e){const s=o.parent,r=n.get(s);r?r.push(o):n.set(s,[o])}t.execAction(new W);for(const[o,s]of n){const r=this.moveNodesToUp(s,o);r&&t.execAction(r)}t.execAction(new z)}moveToBack(t){const e=t.getSelectNodes();if(e.size===0)return;const n=new Map;for(const o of e){const s=o.parent,r=n.get(s);r?r.push(o):n.set(s,[o])}t.execAction(new W);for(const[o,s]of n){const r=this.moveNodesToBack(s,o);r&&t.execAction(r)}t.execAction(new z)}moveNodesToUp(t,e){if(t.length===0)return null;const n=S.sortGraphics(t),o=new Set(t),s=e.children,r=[];for(const d of s)o.has(d)||r.push(d);const i=S.sortGraphics(r),a=i[i.length-1].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a+h,props:[]}),h++;return new U({infos:c})}moveNodesToBack(t,e){if(t.length===0)return null;const n=S.sortGraphics(t).reverse(),o=new Set(t),s=e.children,r=[];for(const d of s)o.has(d)||r.push(d);const a=S.sortGraphics(r)[0].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a-h,props:[]}),h++;return new U({infos:c})}moveNodeForward(t){const e=t.parent;if(!e)return null;let n=[...e.children];n=S.sortGraphics(n);const o=n.indexOf(t);if(o<0&&console.error("排序时发生错误",o,t.id),o===n.length-1)return null;if(o===n.length-2){const a=n[o+1],c=[{id:t.id,zIndex:a.zIndex+1,props:[]}];return new U({infos:c})}const s=n[o+1],r=n[o+2],i=[{id:t.id,zIndex:.5*(s.zIndex+r.zIndex),props:[]}];return new U({infos:i})}moveNodeBackward(t){const e=t.parent;if(!e)return null;let n=[...e.children];n=S.sortGraphics(n);const o=n.indexOf(t);if(o<0&&console.error("排序时发生错误",o,t.id),o===0)return null;if(o===1){const a=n[o-1],c=[{id:t.id,zIndex:a.zIndex-1,props:[]}];return new U({infos:c})}const s=n[o-1],r=n[o-2],i=[{id:t.id,zIndex:.5*(s.zIndex+r.zIndex),props:[]}];return new U({infos:i})}}const xs=class xs{constructor(){p(this,"offlineCanvas");p(this,"ctx");this.offlineCanvas=document.createElement("canvas"),this.ctx=this.offlineCanvas.getContext("2d")}static getInstance(){return this.instance||(this.instance=new xs),this.instance}getCanvasCtx(){return this.ctx}};p(xs,"instance",null);let Js=xs;class sn{static dealWithAIDocumentInfo(t){if(t.nodes)for(const e of t.nodes)this.dealNodeInfo(e)}static dealNodeInfo(t){sn.dealNodeSizeForFullText(t);const e=t.children;for(const n of e)this.dealNodeInfo(n)}static dealNodeSizeForFullText(t){var e,n;try{if(t.type!==v.Shape||!((e=t.capInfo)!=null&&e.shapeProps)||!t.capInfo.textProps)return;const o=t.capInfo.shapeProps.shapeCode;if(o!==K.Rect&&o!==K.RoundRect){t.capInfo.textProps.sizeMode=We.fix;return}if(!t.capInfo.textProps.text){t.capInfo.textProps.sizeMode=We.fix;return}if(!t.capInfo.baseProps)return;const s=Js.getInstance().getCanvasCtx(),r=new ho,i=new Ge;i.update(((n=t.capInfo)==null?void 0:n.textProps)||{});const a={x:le,y:le,width:t.capInfo.baseProps.width-2*le,height:t.capInfo.baseProps.height-2*le};r.typesetting(s,i,a);const c=r.height+2*le,h=r.width+2*le;t.capInfo.baseProps.height=c,h>t.capInfo.baseProps.width&&(t.capInfo.baseProps.width=h),t.capInfo.textProps.sizeMode=We.fix}catch{console.error("处理失败,忽略node",t)}}static blurText(t){const e=t.inputManager.editTextInfo;e&&t.execAction(ee.blur(e.node.id))}}class er extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){const o=n.auxiliaryManager.selectManager.getSelectBounds();if(S.rectContains2(e.globalPoint,o)||!e.originEvent.shiftKey)return!1;if(e.originEvent.metaKey){const r=n.detect(F.Node,e);if(r&&r.length>0)return this.node=r[0],!0}const s=n.detect(F.HoverNode,e);return s?(this.node=s,!0):!1}handle(e,n){if(!this.node)return;const s=[...S.computeSelectNode(n,this.node)].map(r=>r.id);n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([...s])),n.actionManager.execAction(new z)}}class Ca extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){const o=n.auxiliaryManager.selectManager.getSelectBounds();if(n.getSelectNodes().size>1&&S.rectContains2(e.globalPoint,o))return!1;const s=n.detect(F.HoverNode,e);return s?n.auxiliaryManager.selectManager.include(s)||!this.canEnable(s)?!1:(this.node=s,!0):!1}handle(e,n){this.node&&(n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([this.node.id])),n.actionManager.execAction(new z),this.node.type===v.IMG&&n.setCursor("zoom-in"))}}class tr extends Ca{constructor(){super(...arguments);p(this,"node",null)}canEnable(e){return e.type!==v.Section}}class Aa extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){if(n.getSelectNodes().size!==1)return!1;const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s)){const r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0;if(s instanceof Gn&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0}}return!1}handle(e,n){if(!this.res)return;const{node:o,relativePos:s}=this.res,r=o.renderText.detect(s);this.shiftTextClick(e,n,r)||(n.execAction(new W),n.execAction(ee.focus(o.id,r)),n.execAction(new z))}shiftTextClick(e,n,o){if(!e.originEvent.shiftKey)return!1;const s=n.inputManager.editTextInfo,{node:r}=this.res;return s&&!n.inputManager.selectionManager.selectionInfo&&!s.textCursorPosition.equal(o)?(n.execAction(new W),n.execAction(ee.selection(r.id,o,s.textCursorPosition)),n.execAction(new z),!0):!1}}class nr extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){if(!e.originEvent.shiftKey)return!1;const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s))return this.node=s,!0}return!1}handle(e,n){if(!this.node)return;const o=n.getSelectNodes(),s=new Set;o.forEach(r=>s.add(r.id)),s.delete(this.node.id),n.actionManager.execAction(new W),sn.blurText(n),n.actionManager.execAction(xe.create([...s])),n.actionManager.execAction(new z)}}class or extends qe{enable(t,e){return!e.detect(F.Node,t)}handle(t,e){if(e.getSelectNodes().size===0){e.slotManager.addSlotState(ze.QuickCreate,{show:!1});return}if(e.execAction(new W),e.inputManager.editTextInfo){const n=e.inputManager.editTextInfo.node;if(e.execAction(ee.blur(e.inputManager.editTextInfo.node.id)),n.type===v.Shape&&n.shapeType===K.PureText&&n.getProp(I.Text)&&n.isEmptyText()){e.execAction(xe.create([])),e.execAction(At.create([n.id])),e.execAction(new z);return}}e.execAction(xe.create([])),e.execAction(new z)}}class Na extends qe{constructor(){super(...arguments);p(this,"res",null);p(this,"layoutWorker",new Rn)}enable(e,n){const o=n.detect(F.ExpandShape,e);return o?(this.res=o,!0):!1}handle(e,n){const{node:o,realHeight:s}=this.res,r={infos:[{id:o.id,props:[{height:s,type:I.Base},{type:I.Text,sizeMode:We.autoHeight}]}]};n.execAction(new W),sn.blurText(n),n.execAction(new U(r));const i=[...n.nodeManager.getNodeLinks(o)];this.layoutWorker.work(i,n,!1),n.execAction(new z)}}class ka extends Ca{constructor(){super(...arguments);p(this,"node",null)}canEnable(e){return e.type===v.Section}}class ru extends qe{constructor(){super(...arguments);p(this,"node")}enable(e,n){const o=n.detect(F.Image,e);return o?(this.node=o,!0):!1}handle(e,n){const o=this.getFileKey(this.node),s={nodeId:this.node.id,fileKey:o,blobUrl:n.resourceManager.getBlobUrl(o)};n.slotManager.addSlotState(ze.ClickImg,s)}getFileKey(e){return e.type===v.SVG?e.svgUrl:e.type===v.IMG?e.imgSrc:""}}class Ba{checkbox(t,e,n){const o=t.checkStatus;n.execAction(new W),sn.blurText(n),n.execAction(U.create(t.id,[{type:I.CheckStatus,checkStatus:!o}])),t.type===v.CheckboxText&&n.execAction(U.create(t.id,[{type:I.Text,strikethrough:!o}])),n.execAction(new z)}}const iu=new Set([v.Checkbox,v.CheckboxText]);class au extends qe{constructor(){super(...arguments);p(this,"node",null);p(this,"checkboxWorker",new Ba)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];return iu.has(s.type)&&s.checkboxContain(e.globalPoint)?(this.node=s,!0):!1}handle(e,n){this.node&&this.checkboxWorker.checkbox(this.node,e,n)}}class cu extends qe{enable(t,e){return!!e.detect(F.SlideGap,t)}handle(t,e){const n=e.detect(F.SlideGap,t);if(!n)return;const{slideContainer:o,i:s,j:r}=n,i=o.slideProps.children,a=i[s];if(!a||!a.ids||a.ids.length===0)return;const c=this.getGlobalIndex(i,s,r>0?r-1:0),h=r>0;e.execAction(new W);const d=e.slideManager.insertSlide(o,c,h,e);d&&e.execAction(xe.create([d.id])),e.execAction(new z)}getGlobalIndex(t,e,n){let o=0;for(let s=0;s<e;s++)o+=t[s].ids.length;return o+n}}var kn=(l=>(l[l.A4=0]="A4",l[l.S16_9=1]="S16_9",l[l.S4_3=2]="S4_3",l[l.S1_1=3]="S1_1",l))(kn||{});const Uo={[kn.A4]:{width:595,height:842},[kn.S16_9]:{width:860,height:540},[kn.S4_3]:{width:860,height:720},[kn.S1_1]:{width:600,height:600}};class lu extends qe{enable(t,e){return!!e.detect(F.EmptySlideContainer,t)}handle(t,e){const n=e.detect(F.EmptySlideContainer,t);if(!n)return;const{slideContainer:o,rect:s}=n;e.execAction(new W);const r=Uo[kn.S16_9],i=r.width,a=r.height,d=[ie.create({x:nt,y:xt,width:i,height:a}),tt.create({color:"#F4F2F3"}),Ae.create({color:"#C0A9BD"})],u=e.idGenerator.genId(v.Section),f={id:u,type:v.Section,zIndex:ve.genZIndex(o),parentId:o.id,props:d};e.execAction(Le.create(f));const g=[{ids:[u]}],y=[{id:o.id,props:[St.create({children:g})]}],m=i+2*nt,b=a+2*xt;y.push({id:o.id,props:[{type:I.Base,width:m,height:b}]}),e.execAction(new U({infos:y})),e.execAction(xe.create([u])),e.execAction(new z)}}class Ra extends jt{constructor(){super(),this.registerDownHandler(new lu),this.registerDownHandler(new cu),this.registerDownHandler(new Na),this.registerDownHandler(new er),this.registerDownHandler(new tr),this.registerUpHandler(new nr),this.registerUpHandler(new ka),this.registerUpHandler(new Aa),this.registerUpHandler(new au),this.registerUpHandler(new ru),this.registerUpHandler(new or)}}class Ea extends un{constructor(){super([new Ra])}}class hu{}class Ha extends hu{enable(t){return t.type===v.Line}handle(t,e){e.addOrUpdate(k.HoverLine,{node:t,transform:t.globalTransform()})}}class Da{enable(t){return!0}handle(t,e){e.addOrUpdate(k.HoverBounds,{node:t,transform:t.globalTransform()})}}class Oa{enable(t){return t.type===v.Group}handle(t,e){const n=t;if(e.auxiliaryManager.selectManager.include(t))return;const o=n.nameGlobalTransform();e.addOrUpdate(k.HoverBounds,{node:t,transform:o})}}class Xa{enable(t){return t.type===v.Section}handle(t,e){}}class za{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new Ha,new Oa,new Xa,new Da])}process(t,e){const n=e.detect(F.EmptySlideContainer,t);if(n){const i=n.slideContainer,a=n.rect;e.addOrUpdate(k.HoverSlideGapInsertPoint,{point:{x:i.globalBaseProps.x+i.globalBaseProps.width/2,y:i.globalBaseProps.y+i.globalBaseProps.height/2}});const c=ie.create({x:a.x,y:a.y,width:a.width,height:a.height});e.addOrUpdate(k.HoverSlidePlaceHolder,{baseProps:c});return}const o=e.detect(F.SlideGap,t);if(o){e.addOrUpdate(k.HoverSlideGapInsertPoint,{point:o.point});return}const s=e.detect(F.HoverConnectAnchor,t);if(s){s.node.type===v.Shape&&e.previewManager.quickCreateManager.enterQuickPreview(s.node,s.relative,e),e.addOrUpdate(k.HoverConnectAnchor,{point:s.globalPoint});return}e.previewManager.quickCreateManager.exitQuickPreview(e),this.hoverSizer(t,e);const r=e.detect(F.HoverNode,t);if(r){for(const i of this.handlers)if(i.enable(r)){i.handle(r,e);return}}}hoverSizer(t,e){const n=e.detect(F.Stretch,t);if(!n)return;const o=n.nodes,s=o[0];if(n.type===V.BOTTOM_RIGHT)if(o.length===1)e.addOrUpdate(k.HoverSize,{rect:D.baseProps2Rect(s.baseProps),transform:s.globalTransform().clone()});else{const r=e.auxiliaryManager.selectManager.getSelectBounds();e.addOrUpdate(k.HoverSize,{rect:D.rectNode2Rect(r),transform:re.generateMatrix().translate(r.minX,r.minY)})}}}var ye=(l=>(l[l.DEFAULT=0]="DEFAULT",l[l.TEXT=1]="TEXT",l[l.SHAPE=2]="SHAPE",l[l.LINE=3]="LINE",l[l.SECTION=4]="SECTION",l[l.STICKY=5]="STICKY",l[l.HandTool=6]="HandTool",l[l.Resource=7]="Resource",l[l.Widget=8]="Widget",l[l.SlideContainer=9]="SlideContainer",l))(ye||{});class Wa{constructor(t,e,n,o){p(this,"nodeManager");p(this,"inputManager");p(this,"slotManager");p(this,"cursorManager");p(this,"currentTool",ye.DEFAULT);p(this,"shapeType",0);p(this,"grab",!1);p(this,"creatingLine",null);this.nodeManager=t,this.inputManager=e,this.slotManager=n,this.cursorManager=o}setCurrentTool(t,e=0,n=!1){this.currentTool=t,this.shapeType=e,this.grab=n,this.slotManager.addSlotState(ze.ToolChange,{tool:t,shapeType:e}),t===ye.DEFAULT&&this.cursorManager.setCursor("default")}resetTool(){this.creatingLine||this.setCurrentTool(ye.DEFAULT)}setInCreatingLine(t){this.creatingLine=t}}var Un=(l=>(l[l.Checkbox=0]="Checkbox",l[l.CheckboxText=1]="CheckboxText",l))(Un||{});class gt{}class Fa extends gt{constructor(){super(...arguments);p(this,"cursorMap",new Map([[ye.SHAPE,"crosshair"],[ye.SECTION,"crosshair"],[ye.TEXT,"text"],[ye.LINE,"crosshair"]]))}enable(e,n){return this.cursorMap.has(n.toolManager.currentTool)}handle(e,n){if(n.toolManager.grab){n.setCursor("grabbing");return}const o=this.cursorMap.get(n.toolManager.currentTool);n.setCursor(o)}}class du extends gt{enable(t,e){return!!e.detect(F.ExpandShape,t)}handle(t,e){e.setCursor("pointer")}}class uu extends gt{enable(t,e){const n=e.inputManager.editTextInfo;if(!n)return!1;const{node:o}=n,s=o.getTextContentRect(),r=o.toLocal(t.globalPoint);return!!S.rectContains(r,s)}handle(t,e){e.setCursor("text")}}class Ya extends gt{enable(t,e){const n=e.detect(F.Stretch,t);return n?n.nodes.filter(s=>S.judgeNodeCanBeStretch(s)).length>0:!1}handle(t,e){const n=e.detect(F.Stretch,t);e.setCursor("stretch",n.angle)}}class pu extends gt{enable(t,e){return!!e.detect(F.HoverNode,t)}handle(t,e){e.setCursor("default")}}class sr extends gt{enable(t,e){return!0}handle(t,e){e.setCursor("default")}}class _o{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){for(const n of this.handlers)if(n.enable(t,e)){n.handle(t,e);return}}}class fu extends gt{enable(t,e){return!!e.detect(F.LineEndPoint,t)}handle(t,e){e.setCursor("move")}}class gu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.PolyControlPoint,e);return o?(this.res=o,!0):!1}handle(e,n){if(!this.res)return;const{isHorizon:o}=this.res;o?n.setCursor("ns-resize"):n.setCursor("ew-resize")}}class yu extends gt{enable(t,e){return!!e.detect(F.Rotate,t)}handle(t,e){const n=e.detect(F.Rotate,t);e.setCursor("rotate",n.cursorAngle)}}class xu extends gt{enable(t,e){return!!e.detect(F.Image,t)}handle(t,e){e.setCursor("zoom-in")}}class wu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.CurveControlPoint,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class Pu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.CurveEndPoint,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class mu extends gt{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.DragLineText,e);return o?(this.res=o,!0):!1}handle(e,n){this.res&&n.setCursor("move")}}class bu extends gt{enable(t,e){var o;const n=e.detect(F.HoverNode,t);return n?!!(((o=n.parent)==null?void 0:o.type)===v.SlideContainer&&e.auxiliaryManager.selectManager.include(n)):!1}handle(t,e){e.setCursor("move")}}class Su extends gt{enable(t,e){return!!e.detect(F.SlideGap,t)}handle(t,e){e.setCursor("pointer")}}class Ga extends _o{constructor(){super(...arguments);p(this,"handlers",[new Fa,new gu,new Pu,new wu,new mu,new du,new fu,new uu,new Ya,new yu,new Su,new bu,new pu,new xu,new sr])}}class Ua extends Ot{constructor(){super([new za,new Ga])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Mu extends fn{enable(t){return t.type===v.Line}handle(t,e,n,o,s){const i=t.parent.globalTransform().inverseMatrix().crossProduct(s),a=[];for(const h of e.points){const d=i.crossPoint(h);a.push(d)}const c=D.rectNode2Rect(S.getBoundsByPoints(a));return[{id:t.id,props:[{type:I.Line,points:a},{type:I.Base,x:c.x,y:c.y,width:c.width,height:c.height}]}]}}class vu extends fn{enable(t){return t.type===v.SlideContainer}handle(t,e,n,o,s){return[]}}class _a extends Go{constructor(){super(...arguments);p(this,"handlers",[new Mu,new la,new ha,new vu,new ca])}computeOriginTransform(e){const n=this.target,{x:o,y:s}=this.originStretchRect,r=re.generateMatrix().translate(-o,-s),i=this.computeAnchorPoint(n,this.originStretchRect),c=re.generateMatrix().translate(-i.x,-i.y).crossProduct(r);this.originTransform=c}recordPropsMap(e){this.propsMap.clear();for(const n of this.target.nodes){const o=this.recordNodePropInfo(n);if(n.type===v.Line){const r=n.globalLinePoints.map(i=>this.originTransform.crossPoint(i));o.points=r}this.propsMap.set(n,o)}}drawAlignLine(e,n,o){const s=o.auxiliaryManager.selectManager.getSelectBounds(),r=D.rectNode2Rect(s),i=re.generateMatrix().translate(s.minX,s.minY),{width:a,height:c}=n;if(a){e.width+=a.dt;const h={transform:i,line:{start:new P(0,r.height),end:new P(r.width,r.height)}};a.lines.push(h)}if(c){e.height+=c.dt;const h={transform:i,line:{start:new P(r.width,0),end:new P(r.width,r.height)}};c.lines.push(h)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}getMiniSize(e){const n=[],o=[],{width:s,height:r}=this.originStretchRect,i=this.target.nodes;if([...i].filter(d=>d.type===v.Line).length===i.length)return{x:10,y:10};for(const d of i){if(d.type===v.Line)continue;const u=d.getStretchMinSize();n.push(u.x/s),o.push(u.y/r)}const c=Math.max(...n),h=Math.max(...o);return{x:c*s,y:h*r}}getStretchRect(e){const n=e.auxiliaryManager.selectManager.getSelectBounds();return D.rectNode2Rect(n)}}class $a extends Nn{constructor(){super([new _a])}streamEnable(t,e){if(e.getSelectNodes().size===0)return!1;const n=e.detect(F.Stretch,t);if(!n)return!1;const o=n.nodes,s=o.filter(r=>S.judgeNodeCanBeStretch(r));return o.length>1&&s.length>0}}class rr{}class Iu extends rr{constructor(){super(...arguments);p(this,"polylineHandler",new Vt)}enable(e){return e.isPolyLine()}handleMove(e,n,o){const{line:s}=n,r=this.handle(e,n,o),i=S.dealWithEndPolyPoints(r,o.gmlRender.getScale(),!n.isStart),a=s.globalTransform().inverseMatrix(),c=i.map(u=>a.crossPoint(u)),h=D.rectNode2Rect(S.getBoundsByPoints(c));return{id:s.id,props:[{type:I.Line,points:c},ie.create({x:h.x,y:h.y,width:h.width,height:h.height})]}}handleUp(e,n,o,s){const{line:r}=n,i=this.handle(e,n,o),a=S.dealWithEndPolyPointsInUp(i,o.gmlRender.getScale(),!n.isStart),c=r.globalTransform().inverseMatrix(),h=a.map(f=>c.crossPoint(f)),d=D.rectNode2Rect(S.getBoundsByPoints(h));return{id:r.id,props:[{type:I.Line,points:h},ie.create({x:d.x,y:d.y,width:d.width,height:d.height}),s]}}handle(e,n,o){const{line:s}=n,r=s.lineProps;let i=[];return r.auto?i=this.autoLayoutLine(e,n,o):i=this.editLine(e,n,o),i}autoLayoutLine(e,n,o){const{line:s,isStart:r}=n,i=s.connectProps;if(r){const a=e,c=Ze.computeConnectInfo(s,i.end,o,!0);return this.polylineHandler.layoutToPointsPro(a,c)}else{const a=e,c=Ze.computeConnectInfo(s,i.start,o,!1);return this.polylineHandler.layoutToPointsPro(c,a)}}editLine(e,n,o){const{line:s,isStart:r}=n,i=[...s.globalLinePoints];if(i.length===2)return this.autoLayoutLine(e,n,o);const a=e.point;if(r){const c=i[0],h=i[1],d=S.judgeHorizon(c,h);if(i.length>3){const u=i[2];S.distance(h,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}c.x=a.x,c.y=a.y,d?h.y=c.y:h.x=c.x}else{const c=i[i.length-2],h=i[i.length-1],d=S.judgeHorizon(c,h);if(i.length>3){const u=i[i.length-3];S.distance(c,u)<3&&(d?Math.abs(a.y-u.y)<6:Math.abs(a.x-u.x)<6)&&(d?a.y=u.y:a.x=u.x)}h.x=a.x,h.y=a.y,d?c.y=h.y:c.x=h.x}return i}}class Tu extends rr{enable(t){return t.shapeType===he.Line}handle(t,e,n){const{line:o,isStart:s}=e,r=[...o.globalLinePoints];return s?(r.shift(),r.unshift(t.point)):(r.pop(),r.push(t.point)),r}handleMove(t,e,n){const{line:o}=e,s=this.handle(t,e,n),r=o.globalTransform().inverseMatrix(),i=s.map(c=>r.crossPoint(c)),a=D.rectNode2Rect(S.getBoundsByPoints(i));return{id:o.id,props:[{type:I.Line,points:i},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})]}}handleUp(t,e,n,o){const{line:s}=e,r=this.handle(t,e,n),i=s.globalTransform().inverseMatrix(),a=r.map(h=>i.crossPoint(h)),c=D.rectNode2Rect(S.getBoundsByPoints(a));return{id:s.id,props:[{type:I.Line,points:a},ie.create({x:c.x,y:c.y,width:c.width,height:c.height}),o]}}}class Lu extends rr{constructor(){super(...arguments);p(this,"bezierWorker",new zo)}enable(e){return e.shapeType===he.Curve}handle(e,n,o){const{line:s,isStart:r}=n,i=[...s.globalLinePoints],{start:a,end:c}=s.connectProps;if(r){i.shift(),i.unshift(e.point);let h;e.endTypeInfo&&(h=this.bezierWorker.computeConnectEndInfo(e.endTypeInfo,o.nodeManager));const d=this.bezierWorker.computeConnectEndInfo(c,o.nodeManager);return this.bezierWorker.computeCurvePoints(i,h,d)}else{i.pop(),i.push(e.point);let h;e.endTypeInfo&&(h=this.bezierWorker.computeConnectEndInfo(e.endTypeInfo,o.nodeManager));const d=this.bezierWorker.computeConnectEndInfo(a,o.nodeManager);return this.bezierWorker.computeCurvePoints(i,d,h)}}handleMove(e,n,o){const{line:s}=n,r=this.handle(e,n,o),i=s.globalTransform().inverseMatrix(),a=r.map(h=>i.crossPoint(h)),c=D.rectNode2Rect(S.getBoundsByPoints(a));return{id:s.id,props:[{type:I.Line,points:a},ie.create({x:c.x,y:c.y,width:c.width,height:c.height})]}}handleUp(e,n,o,s){const{line:r}=n,i=this.handle(e,n,o),a=r.globalTransform().inverseMatrix(),c=i.map(d=>a.crossPoint(d)),h=D.rectNode2Rect(S.getBoundsByPoints(c));return{id:r.id,props:[{type:I.Line,points:c},ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),s]}}}class _n{constructor(){p(this,"t",.5)}init(t){if(t.renderText.isEmptyText())return;const e=t.getLineLength(),n=t.points,{point:o}=t.lineTextRect,s=t.baseProps,r=new P(o.x+s.x,o.y+s.y);if(t.shapeType===he.Line){const i=S.distance(n[0],r);this.t=i/e;return}if(t.isPolyLine()){let i=0;for(let a=0;a<n.length;a++){const c=n[a],h=n[a+1],d=q.circle(r,1),u=q.line(c,h);if(Y.intersect(d,u).points.length>0){const g=S.distance(r,c);this.t=(g+i)/e;return}i+=S.distance(c,h)}return}if(t.shapeType===he.Curve){const i=S.computeBezierCurves(t);let a=0;for(let c=0;c<i.length;c++){const h=i[c],d=q.circle(r,1),{p0:u,p1:f,p2:g,p3:y}=h,m=q.cubicBezier(u,f,g,y),b=Y.intersect(d,m),w=h.getApproximateLength();if(b.points.length>0){const L=h.getTValueByPoint(r);this.t=(L*w+a)/e;return}a+=w}}}work(t,e,n){if(t.renderText.isEmptyText())return;const{width:o,height:s}=t.lineTextRect,r=S.computePointByT(t,this.t),i=t.baseProps,a=new P(r.x-i.x,r.y-i.y);e.execAction(U.create(t.id,[{type:I.LineTextRect,point:a,x:a.x-.5*o,y:a.y-.5*s}],{streaming:n}))}}class ja extends ht{constructor(){super(...arguments);p(this,"res",null);p(this,"connectEndProp");p(this,"alignWorker",new dn);p(this,"groupBaseWorker",new on);p(this,"lineTextWorker",new _n);p(this,"handlers",[new Iu,new Lu,new Tu]);p(this,"currentHandler",null)}selectHandler(){const{line:e,isStart:n}=this.res;for(const o of this.handlers)o.enable(e)&&(this.currentHandler=o)}computeConnectProp(e,n){const o=n.detect(F.LineEndPoint,e);if(!o)return;this.res=o;const s=o.line.connectProps;if(o.isStart){const r=Ze.computeConnectInfo(o.line,s.end,n,!0);this.connectEndProp={isStart:!1,connectInfo:r}}}onStart(e,n){this.computeConnectProp(e,n),this.selectHandler(),n.execAction(new W),this.removeConnectInfoAndSendMsg(e,n),this.groupBaseWorker.start([this.res.line]),this.lineTextWorker.init(this.res.line)}onMove(e,n){if(!this.res)return;const o=this.getConnectInfo(e,n),s=this.currentHandler.handleMove(o,this.res,n);n.execAction(new U({infos:[s]},{streaming:!0})),this.lineTextWorker.work(this.res.line,n,!0),this.groupBaseWorker.work(n,!0)}onUp(e,n){if(!this.res)return;const o=this.addConnectInfoAndSendMsg(e,n),s=this.getConnectInfo(e,n),r=this.currentHandler.handleUp(s,this.res,n,o);n.execAction(new U({infos:[r]},{streaming:!1})),this.lineTextWorker.work(this.res.line,n,!1),this.groupBaseWorker.work(n,!1),n.execAction(new z)}getConnectInfo(e,n){const o=this.res.line,s=this.res.isStart,r=S.dealWithShiftLineInteractEvent(e,o,!s),i=!S.pressMeta(e),c={point:this.alignWorker.alignLineEndAndDrawAlignLines(r,n,n.getSelectNodes(),i)},h=n.detect(F.NodeEdge,r);return h&&(c.point=new P(h.point.x,h.point.y),c.nodeConnect={rect:D.rectNode2Rect(h.node.getBounds()),endType:S.computeNodeConnectEnd(h.relativePos,h.node.baseProps.angle)},c.endTypeInfo=this.computeEndType(e,n)||void 0),c}computeEndType(e,n){const o=n.detect(F.NodeEdge,e);return o?{objectId:o.node.id,x:o.relativePos.x,y:o.relativePos.y}:null}addConnectInfoAndSendMsg(e,n){const{line:o,isStart:s}=this.res,r=o.connectProps.clone(),i=s?"start":"end",a=this.computeEndType(e,n);return a?r[i]=a:r[i]=null,r}removeConnectInfoAndSendMsg(e,n){const{line:o,isStart:s}=this.res,r=o.connectProps.clone(),i=s?"start":"end";r[i]=null;const a={id:o.id,props:[r]};n.execAction(new U({infos:[a]}))}}class $o{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){const n=e.detect(F.BufferNode,t);if(!n)return;const o=n.filter(s=>s.canBeConnected());o.length!==0&&(e.auxiliaryManager.selectManager.include(o[0])||o[0].canBeConnected()&&e.addOrUpdate(k.HoverConnectAnchorPoint,{node:o[0]}))}}class jo{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){const n=e.detect(F.HoverConnectAnchor,t);if(n){e.addOrUpdate(k.HoverConnectAnchor,{point:n.globalPoint});return}const o=e.detect(F.HoverNodeAnchor,t);o&&e.addOrUpdate(k.HoverAnchorPoint,{node:o.node,localPoint:o.localPoint})}}class Vo{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){if(e.toolManager.currentTool!==ye.LINE)return;const o=e.detect(F.NodeEdge,t);o&&e.addOrUpdate(k.HoverConnectPoint,{point:o.point})}}class Cu extends dt{constructor(){super([new ja],[new $o,new jo,new Vo])}streamEnable(t,e){return!!e.detect(F.LineEndPoint,t)}}class Ko{setPointValue(t,e,n,o){t?(e.y=o.y,n.y=o.y):(e.x=o.x,n.x=o.x)}}class Au extends Ko{enable(t){const{rIndex:e,lIndex:n,line:o}=t,s=[...o.points];return n>0&&e<s.length-1}handle(t,e,n){const{rIndex:o,lIndex:s,line:r,isHorizon:i}=t,a=[...r.points],c=r.toLocal(e.globalPoint),h=a[s],d=a[o],u=a[o+1],f=a[s-1],g=n.gmlRender.getScale();return S.distance(f,h)<3/g&&(i?Math.abs(c.y-f.y)<6/g:Math.abs(c.x-f.x)<6/g)?i?c.y=f.y:c.x=f.x:S.distance(d,u)<3/g&&(i?Math.abs(c.y-u.y)<6/g:Math.abs(c.x-u.x)<6/g)&&(i?c.y=u.y:c.x=u.x),this.setPointValue(i,h,d,c),a}setPointValue(t,e,n,o){t?(e.y=o.y,n.y=o.y):(e.x=o.x,n.x=o.x)}}class Nu extends Ko{enable(t){const{rIndex:e,lIndex:n,line:o}=t,s=[...o.points];return n===0&&e===1&&s.length===2}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{start:a,end:c}=s.connectProps,h=i[o],d=i[n],u=s.toLocal(e.globalPoint);if(!a&&!c)return this.setPointValue(r,h,d,u),i;if(c&&!a){if(r){const m=d.x>h.x?1:-1,b=new P(d.x-m*A,d.y),w=new P(d.x-m*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const f=d.y>h.y?1:-1,g=new P(d.x,d.y-f*A),y=new P(u.x,d.y-f*A);return i.splice(o+1,0,g,y),t.lIndex=o+2,t.rIndex=n+2,i}if(a&&!c){if(r){const m=d.x>h.x?1:-1,b=new P(h.x+m*A,h.y),w=new P(h.x+m*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const f=d.y>h.y?1:-1,g=new P(h.x,h.y-f*A),y=new P(u.x,h.y-f*A);return i.splice(o+1,0,g,y),t.lIndex=o+2,t.rIndex=n+2,i}if(a&&c){if(r){const w=d.x>h.x?1:-1,L=new P(h.x+w*A,h.y),B=new P(h.x+w*A,u.y),H=new P(d.x-w*A,d.y),E=new P(d.x-w*A,u.y);return i.splice(o+1,0,L,B,H,E),t.lIndex=o+4,t.rIndex=n+4,i}const f=d.y>h.y?1:-1,g=new P(h.x,h.y-f*A),y=new P(u.x,h.y-f*A),m=new P(d.x,d.y-f*A),b=new P(u.x,d.y-f*A);return i.splice(o+1,0,g,y,m,b),t.lIndex=o+4,t.rIndex=n+4,i}return[]}}class ku extends Ko{enable(t){const{lIndex:e}=t;return e===0}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{start:a,end:c}=s.connectProps,h=i[o],d=i[n],u=s.toLocal(e.globalPoint);if(!a)return this.setPointValue(r,h,d,u),i;if(r){const m=d.x>h.x?1:-1,b=new P(h.x+m*A,h.y),w=new P(h.x+m*A,u.y);return i.splice(o+1,0,b,w),t.lIndex=o+2,t.rIndex=n+2,i}const f=d.y<h.y?1:-1,g=new P(h.x,h.y-f*A),y=new P(u.x,h.y-f*A);return i.splice(o+1,0,g,y),t.lIndex=o+2,t.rIndex=n+2,i}}class Bu extends Ko{enable(t){const{rIndex:e,line:n}=t;return e===n.points.length-1}handle(t,e){const{rIndex:n,lIndex:o,line:s,isHorizon:r}=t,i=[...s.points],{end:a}=s.connectProps,c=i[o],h=i[n],d=s.toLocal(e.globalPoint);if(!a)return this.setPointValue(r,c,h,d),i;if(r){const y=h.x<c.x?1:-1,m=new P(h.x+y*A,h.y),b=new P(h.x+y*A,d.y);return i.splice(o+1,0,b,m),c.y=d.y,i}const u=h.y>c.y?1:-1,f=new P(h.x,h.y-u*A),g=new P(d.x,h.y-u*A);return i.splice(o+1,0,g,f),c.x=d.x,i}}class Ru extends ht{constructor(){super(...arguments);p(this,"res");p(this,"handlers",[new Au,new Nu,new ku,new Bu]);p(this,"lineTextWorker",new _n)}onStart(e,n){this.res=n.detect(F.PolyControlPoint,e),n.execAction(new W),this.lineTextWorker.init(this.res.line)}onMove(e,n){const{line:o}=this.res,s=this.computeLinePoints(e,n),r=D.rectNode2Rect(S.getBoundsByPoints(s)),i={infos:[{id:o.id,props:[{type:I.Line,points:s,auto:!1},ie.create({x:r.x,y:r.y,width:r.width,height:r.height})]}]};n.execAction(new U(i,{streaming:!0})),this.lineTextWorker.work(this.res.line,n,!0)}onUp(e,n){const{line:o}=this.res,s=n.gmlRender.getScale(),r=this.computeLinePoints(e,n),i=S.dealWithPolyPoints(r,s),a=D.rectNode2Rect(S.getBoundsByPoints(i)),c={infos:[{id:o.id,props:[{type:I.Line,points:i,auto:!1},ie.create({x:a.x,y:a.y,width:a.width,height:a.height})]}]};n.execAction(new U(c,{streaming:!1})),this.lineTextWorker.work(this.res.line,n,!1),n.execAction(new z)}computeLinePoints(e,n){for(const o of this.handlers)if(o.enable(this.res))return o.handle(this.res,e,n);return[]}}class Eu extends dt{constructor(){super([new Ru],[])}streamEnable(t,e){return!!e.detect(F.PolyControlPoint,t)}}class Hu extends ht{constructor(){super(...arguments);p(this,"startConnectInfo",{point:new P});p(this,"target",null);p(this,"layoutHandler",new Vt);p(this,"alignWorker",new dn)}onStart(e,n){this.startConnectInfo.point=e.globalPoint;const s=[new Oe(he.RoundPolyLine)],{node:r,relative:i}=n.detect(F.HoverConnectAnchor,e),a={type:I.Connect,start:{objectId:r.id,x:i.x,y:i.y}};s.push(a);const c=Ze.getNodePos(r,i);this.startConnectInfo={point:new P(c.x,c.y),nodeConnect:{rect:D.rectNode2Rect(r.getBounds()),endType:S.computeNodeConnectEnd(i,r.baseProps.angle)}};const h={point:e.globalPoint.clone()},d=this.layoutHandler.layoutToPointsPro(this.startConnectInfo,h),u=je.create(d),f=D.rectNode2Rect(S.getBoundsByPoints(d)),g=ie.create({x:f.x,y:f.y,width:f.width,height:f.height});s.push(u,g,new Ae,lt.create({rArrow:it.Arrow}),Ge.create({sizeMode:We.autoWidth}),new Et);const y=n.idGenerator.genId(v.Line),m={id:y,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:"",props:s};n.actionManager.execAction(new W);const b=Le.create(m);n.actionManager.execAction(b),this.target=n.nodeManager.nodeMap.get(y),n.actionManager.execAction(xe.create([this.target.id])),n.setCursor("crosshair")}onMove(e,n){const o=S.dealWithShiftLineInteractEvent(e,this.target),s=Ze.computeLinePoints(this.startConnectInfo,this.layoutHandler,o,n,this.alignWorker),r=S.dealWithEndPolyPoints(s,n.gmlRender.getScale(),!0),i=D.rectNode2Rect(S.getBoundsByPoints(r)),a=[je.create(r),ie.create({x:i.x,y:i.y,width:i.width,height:i.height})],c={infos:[{id:this.target.id,props:a}]};n.actionManager.execAction(new U(c,{streaming:!0}))}onUp(e,n){const o=S.dealWithShiftLineInteractEvent(e,this.target),s=[],r=n.detect(F.NodeEdge,o);if(r){const d=this.target.connectProps.clone();d.end={objectId:r.node.id,x:r.relativePos.x,y:r.relativePos.y},s.push(d)}const i=Ze.computeLinePoints(this.startConnectInfo,this.layoutHandler,o,n,this.alignWorker),a=S.dealWithEndPolyPointsInUp(i,n.gmlRender.getScale(),!0),c=D.rectNode2Rect(S.getBoundsByPoints(a));s.push(je.create(a),ie.create({x:c.x,y:c.y,width:c.width,height:c.height}));const h={infos:[{id:this.target.id,props:s}]};if(n.actionManager.execAction(new U(h,{streaming:!1})),!r){n.execAction(xe.create([]));const d={clientPoint:o.clientPoint,show:!0,lineId:this.target.id};n.slotManager.addSlotState(ze.QuickCreate,d)}n.execAction(new z),n.setCursor("default")}}class Du extends dt{constructor(){super([new Hu],[new $o,new jo,new Vo])}streamEnable(t,e){return!!e.detect(F.HoverConnectAnchor,t)}}class ir{}const Ou=new Set([v.Shape,v.SVG,v.IMG]);class Xu extends ir{enable(t){return Ou.has(t.type)}handle(t,e,n,o){const s=t.baseProps,r=new P(0,0),i=t.toGlobal(r),a=e.crossPoint(i),h=t.parent.globalTransform().inverseMatrix().crossPoint(a);o.push({id:t.id,props:[{type:I.Base,x:h.x,y:h.y,angle:s.angle+n}]})}}class zu extends ir{enable(t){return t.type===v.Line}handle(t,e,n,o){const{start:s,end:r}=t.connectProps;if(s||r)return;const i=t.lineProps,a=[],c=[];for(const u of i.points){const f=e.crossPoint(u);a.push(f)}c.push({type:I.Line,points:a});const h=S.getBoundsByPoints(a),d={type:I.Base,x:h.minX,y:h.minY,width:h.maxX-h.minX,height:h.maxY-h.minY};c.push(d),o.push({id:t.id,props:c})}}class Wu extends ir{constructor(){super(...arguments);p(this,"layoutHandler",new Vt)}enable(e){return e.type!==v.Line?!1:e.isPolyLine()}handle(e,n,o,s){const{start:r,end:i}=e.connectProps;if(r||i)return;const a=e.lineProps,c=[],h=a.points[0],d=a.points[a.points.length-1],u=n.crossPoint(h),f=n.crossPoint(d),g=this.layoutHandler.layoutToPointsPro({point:u},{point:f});c.push({type:I.Line,points:g});const y=S.getBoundsByPoints(g),m={type:I.Base,x:y.minX,y:y.minY,width:y.maxX-y.minX,height:y.maxY-y.minY};c.push(m),s.push({id:e.id,props:c})}}class Va extends ht{constructor(){super(...arguments);p(this,"rotateInfo",null);p(this,"lastAngle",0);p(this,"originAngle",0);p(this,"originNodeAngle",0);p(this,"matrix",re.generateMatrix());p(this,"reverseMatrix",re.generateMatrix());p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on);p(this,"handlers",[new Xu,new Wu,new zu])}onStart(e,n){this.rotateInfo=n.detect(F.Rotate,e);const o=Ze.trimPoint(e.globalPoint),s=this.rotateInfo.rotateCenter,r=this.rotateInfo.nodes;r.length===1?this.originNodeAngle=r[0].baseProps.angle:this.originNodeAngle=0,this.lastAngle=Ze.calculateAngle(s,o),this.originAngle=this.lastAngle;const i=re.generateMatrix().translate(-s.x,-s.y);this.matrix=i,this.reverseMatrix=i.inverseMatrix(),n.actionManager.execAction(new W),n.inputManager.editTextInfo&&n.execAction(ee.blur(n.inputManager.editTextInfo.node.id)),this.groupBaseWorker.start(this.rotateInfo.nodes)}onMove(e,n){this.rotateNode(e,n,!0),this.removeAuxiliaryGraphics(n)}onUp(e,n){this.rotateNode(e,n,!1),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.setCursor("default"),n.actionManager.execAction(new z),this.rotateInfo=null}removeAuxiliaryGraphics(e){e.removeAuxGraphic(k.HighlightRects),e.removeAuxGraphic(k.MultiSelectBound),e.removeAuxGraphic(k.SingleSelectBound),e.removeAuxGraphic(k.StretchRect),e.removeAuxGraphic(k.ExpandShape),e.removeAuxGraphic(k.SelectConnectAnchor)}rotateNode(e,n,o){const s=Ze.trimPoint(e.globalPoint),r=this.rotateInfo.rotateCenter;let i=Ze.calculateAngle(r,s);i=this.computeDeltaAngle(e,i);const a=i-this.lastAngle,c=re.generateMatrix().rotate(a),h=this.reverseMatrix.crossProduct(c).crossProduct(this.matrix),d=[],u=new Set;for(const f of this.rotateInfo.nodes){for(const g of this.handlers)if(g.enable(f)){g.handle(f,h,a,d);break}this.layoutWorker.collectNodeLinks(f,n,u)}if(n.execAction(new U({infos:d},{streaming:o})),this.lastAngle=i,this.rotateInfo.nodes.length===1){const f=S.computeRotateDeltaAngle(this.rotateInfo.rotateType),g=S.computeRotateAngle(this.rotateInfo.nodes,f);n.setCursor("rotate",g)}this.layoutWorker.work([...u],n,o),this.groupBaseWorker.work(n,o)}computeDeltaAngle(e,n){if(e.originEvent.ctrlKey)return n;let o=n-this.originAngle+this.originNodeAngle;const s=Ze.trimAngle(o),r=7.5;return Math.abs(s)<r?(o+=0-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-90)<r?(o+=90-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-180)<r?(o+=180-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-270)<r?(o+=270-s,o+this.originAngle-this.originNodeAngle):Math.abs(s-360)<r?(o+=360-s,o+this.originAngle-this.originNodeAngle):n}}class Ka extends Nn{constructor(){super([new Va])}streamEnable(t,e){return e.getSelectNodes().size===0?!1:!!e.detect(F.Rotate,t)}}const Xt=100,rn=50;class Qa{computeEndNodeRelative(t,e){const n=t.drawer.getConnectAnchor(),o=S.computeOriginNodeConnectEnd(e);let s;return o===de.Top?s=n[de.Bottom]:o===de.Bottom?s=n[de.Top]:o===de.Left?s=n[de.Right]:s=n[de.Left],s}judgeQuickCreateMode(t,e,n){const o=S.computeNodeConnectEnd(e,t.baseProps.angle),s=t.globalBaseProps,r=s.clone();o===de.Top?r.y=s.y-s.height-Xt:o===de.Bottom?r.y=s.y+s.height+Xt:o===de.Left?r.x=s.x-s.width-Xt:r.x=s.x+s.width+Xt;const i=S.getBoundsByBaseProps(r),a=n.nodeManager.searchNodesByRectNode(i).filter(h=>h.type!==v.Line&&h.type!==v.Section),c=S.sortGraphics(a);return c.length===0?null:c[c.length-1]}computePreviewNodePos(t,e,n){const o=S.computeNodeConnectEnd(e,t.baseProps.angle);return o===de.Top?this.findTopPlace(t,o,n):o===de.Bottom?this.findBottomPlace(t,o,n):o===de.Left?this.findLeftPlace(t,o,n):this.findRightPlace(t,o,n)}findTopPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.y=o.y-o.height-Xt;const i=s%2,a=Math.ceil(s/2);i?r.x-=a*(o.width+rn):r.x+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x,y:o.y-o.height-rn}}findBottomPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.y=o.y+o.height+Xt;const i=s%2,a=Math.ceil(s/2);i?r.x-=a*(o.width+rn):r.x+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x,y:o.y+o.height+Xt}}findRightPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.x=o.x+o.width+Xt;const i=s%2,a=Math.ceil(s/2);i?r.y-=a*(o.width+rn):r.y+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x+o.width+Xt,y:o.y}}findLeftPlace(t,e,n){const o=t.globalBaseProps;for(let s=0;s<20;s++){const r=o.clone();r.x=o.x-o.width-Xt;const i=s%2,a=Math.ceil(s/2);i?r.y-=a*(o.width+rn):r.y+=a*(o.width+rn);const c=S.getBoundsByBaseProps(r);if(n.nodeManager.searchNodesByRectNode(c).filter(d=>d.type!==v.Line&&d.type!==v.Section).length===0)return{x:r.x,y:r.y}}return{x:o.x-o.width-Xt,y:o.y}}}class Fu extends qe{constructor(){super(...arguments);p(this,"createWorker",new Qa);p(this,"layoutHandler",new Vt)}enable(e,n){const o=n.detect(F.HoverConnectAnchor,e);return o?o.node.type===v.Shape:!1}isParentRoot(e,n,o){const s=e.parent;if(s===o.nodeManager.root)return!0;const r=e.getBounds(),i=e.globalPos,a=n.x-i.x,c=n.y-i.y,h={minX:r.minX+a,minY:r.minY+c,maxX:r.maxX+a,maxY:r.maxY+c},d=s.getBounds();return!(S.containRect(d,h)||S.overlapRect(d,h))}handle(e,n){const o=n.detect(F.HoverConnectAnchor,e),s=o.node,r=o.relative,i=this.createWorker.judgeQuickCreateMode(s,r,n);if(i){this.handleCreateLineAndLink(i,e,n);return}this.handleCreateNode(e,n)}handleCreateLine(e,n,o,s){const r=o.globalPos,i=this.createWorker.computeEndNodeRelative(e,n),a=e.baseProps,c=e.toGlobal({x:n.x*a.width,y:n.y*a.height}),h=this.isParentRoot(e,r,s),d=o.id,u=o.baseProps,f=o.toGlobal({x:i.x*u.width,y:i.y*u.height}),g={point:c,nodeConnect:{rect:D.rectNode2Rect(e.getBounds()),endType:S.computeNodeConnectEnd(n,e.baseProps.angle)}},y={point:f,nodeConnect:{rect:D.rectNode2Rect(o.getBounds()),endType:S.computeNodeConnectEnd(i,o.baseProps.angle)}},m=this.makeupLineProps(g,y,e.parent,h);m.push({type:I.Connect,start:{objectId:e.id,x:n.x,y:n.y},end:{objectId:d,x:i.x,y:i.y}});const b=s.idGenerator.genId(v.Line);return s.execAction(Le.create({id:b,zIndex:ve.genZIndex(s.nodeManager.root),type:v.Line,props:m,parentId:h?"":e.parent.id})),b}handleCreateLineAndLink(e,n,o){const s=o.detect(F.HoverConnectAnchor,n),r=s.node,i=s.relative;o.execAction(new W);const a=this.handleCreateLine(r,i,e,o);o.execAction(xe.create([a])),sn.blurText(o),o.execAction(new z)}handleCreateNode(e,n){const o=n.detect(F.HoverConnectAnchor,e),s=o.node,r=o.relative,i=this.createWorker.computePreviewNodePos(s,r,n),a=this.isParentRoot(s,i,n),c=this.makeupNodeProps(s,i,a),h=n.idGenerator.genId(v.Shape);n.execAction(new W),n.execAction(Le.create({id:h,zIndex:ve.genZIndex(n.nodeManager.root),type:v.Shape,props:c,parentId:a?"":s.parent.id}));const d=n.nodeManager.getNode(h);if(this.handleCreateLine(s,r,d,n),n.execAction(xe.create([h])),d.type===v.Shape&&d.shapeType===K.PureText){const u=d.renderText;n.execAction(ee.selection(h,u.headTextCursorPosition(),u.tailTextCursorPosition()))}else n.execAction(ee.focus(h));n.execAction(new z)}makeupNodeProps(e,n,o){const s=e.baseProps,r=e.shapeType;let i=n;o||(i=e.parent.globalTransform().inverseMatrix().crossPoint(i));const a=i.x,c=i.y,h=e.colorProps,d=e.borderProps,u=[{type:I.Base,x:a,y:c,width:s.width,height:s.height,angle:s.angle},tt.create({...h}),Ae.create({...d}),new Oe(r)];if(e.type===v.Shape&&e.shapeType===K.PureText){const f=e.textProps;u.push(f.clone());const g=e.paragraphProps;u.push(g.clone())}return u}makeupLineProps(e,n,o,s){let r=this.layoutHandler.layoutToPointsPro(e,n);if(!s){const c=o.globalTransform().inverseMatrix();r=r.map(h=>c.crossPoint(h))}const i=D.rectNode2Rect(S.getBoundsByPoints(r));return[je.create(r),ie.create({x:i.x,y:i.y,width:i.width,height:i.height}),lt.create({rArrow:it.Arrow}),new Oe(he.RoundPolyLine)]}}class Yu extends jt{constructor(){super(),this.registerUpHandler(new Fu)}}class Gu extends un{constructor(){super([new Yu])}clickEnable(t,e){return!!e.detect(F.HoverConnectAnchor,t)}}class Za extends qe{constructor(){super(...arguments);p(this,"group",null)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];if(s.type!==v.Group)return!1;const r=s;return r.contains(e.globalPoint)?(this.group=r,!0):!1}handle(e,n){if(this.group){for(const o of this.group.children)if(o.contains(e.globalPoint)){n.execAction(new W),n.execAction(xe.create([o.id])),n.execAction(new z);return}}}}class Uu extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.Node,e);if(o){const s=o[0];if(n.auxiliaryManager.selectManager.include(s)){const r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0;if(s instanceof Gn&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0}}return!1}handle(e,n){if(!this.res)return;const{node:o,relativePos:s}=this.res;if(o.isEmptyText()){const r=o.renderText.detect(s);if(n.execAction(new W),o instanceof Ct&&o.renderText.isEmptyText()){const{height:a}=o.renderText,c=o.baseProps,h=S.computePointByT(o,.5),d=h.x-.5*20,u=h.y-.5*a,f=new D(d,u,20,a);n.execAction(U.create(o.id,[{type:I.LineTextRect,x:f.x-c.x,y:f.y-c.y,width:f.width,height:f.height,point:{x:h.x-c.x,y:h.y-c.y}}]))}n.execAction(ee.focus(o.id,r)),n.execAction(new z);return}n.execAction(new W),n.execAction(ee.selection(o.id,Fe.head(),o.renderText.tailTextCursorPosition())),n.execAction(new z)}}const _u=new Set([v.Checkbox,v.CheckboxText]);class $u extends qe{constructor(){super(...arguments);p(this,"node",null);p(this,"checkboxWorker",new Ba)}enable(e,n){const o=n.detect(F.Node,e);if(!o)return!1;const s=o[0];return _u.has(s.type)&&s.checkboxContain(e.globalPoint)?(this.node=s,!0):!1}handle(e,n){this.node&&this.checkboxWorker.checkbox(this.node,e,n)}}class ju extends jt{constructor(){super(),this.registerDownHandler(new Za),this.registerDownHandler(new Uu),this.registerDownHandler(new $u)}}class Vu extends js{constructor(){super([new ju])}}class Ku extends qe{constructor(){super(...arguments);p(this,"node",null)}enable(e,n){return!0}handle(e,n){if(n.getSelectNodes().size>0){const r=n.auxiliaryManager.selectManager.getSelectBounds();if(S.rectContains2(e.globalPoint,r)){const i={clientPoint:e.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(ze.ContextMenu,i);return}}const o=n.detect(F.Node,e);if(o&&o.length>0){const r=o[0];n.auxiliaryManager.selectManager.include(r)||(n.execAction(new W),n.execAction(xe.create([r.id])),n.execAction(new z))}else n.execAction(new W),n.execAction(xe.create([])),n.execAction(new z);const s={clientPoint:e.clientPoint,show:!0,hasFocus:n.getSelectNodes().size>0};n.slotManager.addSlotState(ze.ContextMenu,s)}}class Qu extends jt{constructor(){super(),this.registerUpHandler(new Ku)}}class Zu extends un{constructor(){super([new Qu])}canBeEnable(t,e){return t.originEvent.button===2}}class qa extends ht{constructor(){super(...arguments);p(this,"lastPoint",null)}onStart(e,n){this.lastPoint=e.clientPoint,n.setCursor("grabbing")}onMove(e,n){if(!this.lastPoint)return;n.setCursor("grabbing");const o=e.clientPoint,s=o.x-this.lastPoint.x,r=o.y-this.lastPoint.y;n.renderManager.scroll(-s,-r),this.lastPoint=o}onUp(e,n){n.setCursor("grab")}}class qu extends dt{constructor(){super([new qa])}streamEnable(t,e){return t.originEvent.button===2}}class Ju extends ht{constructor(){super(...arguments);p(this,"line");p(this,"bezierWorker",new zo);p(this,"startPoint");p(this,"endPoint");p(this,"leftPoints",[]);p(this,"rightPoints",[]);p(this,"lineTextWorker",new _n)}onStart(e,n){const{line:o,lPoint:s,rPoint:r,curve:i,index:a}=n.detect(F.CurveControlPoint,e);this.line=o,this.startPoint=s,this.endPoint=r;const{lP:c,rP:h,midPoint:d}=this.bezierWorker.splitCurve(i),u=JSON.parse(JSON.stringify(o.points));this.leftPoints=u.slice(0,a),this.rightPoints=u.slice(a+4);const g=.4*S.distance(this.startPoint,e.globalPoint),y=new P(this.startPoint.x+g,this.startPoint.y),m=i.p3,w=.4*S.distance(m,d),L=new P(m.x-w,m.y),B=[...this.leftPoints,s,y,c,d,h,L,r,...this.rightPoints];this.lineTextWorker.init(o),n.execAction(new W);const H=this.bezierWorker.computeCurvePointsForLine(o,n.nodeManager,B);n.execAction(U.create(this.line.id,[{type:I.Line,points:H}]))}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){const s=e.globalPoint,i=.4*S.distance(this.startPoint,s),a=new P(this.startPoint.x+i,this.startPoint.y),c=this.endPoint,d=.4*S.distance(c,e.globalPoint),u=new P(c.x-d,c.y),{lP:f,rP:g,midPoint:y}=this.bezierWorker.computeCurveControlPoint(a,s,u),m=this.startPoint,b=this.endPoint,w=[...this.leftPoints,m,a,f,y,g,u,b,...this.rightPoints],L=this.bezierWorker.computeCurvePointsForLine(this.line,n.nodeManager,w);n.execAction(U.create(this.line.id,[{type:I.Line,points:L}],{streaming:o})),this.lineTextWorker.work(this.line,n,o)}}class ep extends dt{constructor(){super([new Ju],[])}streamEnable(t,e){return!!e.detect(F.CurveControlPoint,t)}}class tp extends ht{constructor(){super(...arguments);p(this,"line");p(this,"dragIndex");p(this,"bezierWorker",new zo);p(this,"lineTextWorker",new _n)}onStart(e,n){const{line:o,index:s}=n.detect(F.CurveEndPoint,e);this.line=o,this.dragIndex=s,n.execAction(new W),this.lineTextWorker.init(o)}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){const s=this.line,r=[...s.points];r.splice(this.dragIndex,1,e.globalPoint);const i=this.bezierWorker.computeCurvePointsForLine(s,n.nodeManager,r);n.execAction(U.create(this.line.id,[{type:I.Line,points:i}],{streaming:o})),this.lineTextWorker.work(s,n,o)}}class np extends dt{constructor(){super([new tp],[])}streamEnable(t,e){return!!e.detect(F.CurveEndPoint,t)}}class ar{init(t){}dealWithPoint(t,e){t.x<e.minX&&(t.x=e.minX),t.y<e.minY&&(t.y=e.minY),t.x>e.maxX&&(t.x=e.maxX),t.y>e.maxY&&(t.y=e.maxY)}}class op extends ar{constructor(){super(...arguments);p(this,"lineShapes",[])}init(e){const n=[],o=e.globalLinePoints;for(let s=0;s<o.length-1;s++){const r=o[s],i=o[s+1],a=q.line(r,i),c=S.judgeHorizon(r,i);n.push({isHorizon:c,shapeInfo:a})}this.lineShapes=n}enable(e){return e.isPolyLine()}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c=this.lineShapes,h={x:n.x,y:n.y};this.dealWithPoint(h,o);const d=10,u=q.line({x:s-d,y:h.y},{x:i+d,y:h.y}),f=q.line({x:h.x,y:r-d},{x:h.x,y:a+d}),g=[];for(const b of c)if(b.isHorizon){const w=Y.intersect(b.shapeInfo,f);if(w.points.length>0){const L=w.points[0],B=S.distance(L,h);g.push({point:L,distance:B})}}else{const w=Y.intersect(b.shapeInfo,u);if(w.points.length>0){const L=w.points[0],B=S.distance(L,h);g.push({point:L,distance:B})}}if(g.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const y=Math.min(...g.map(b=>b.distance));return g.find(b=>b.distance-y<.1)??null}dealWithPoint(e,n){e.x<n.minX&&(e.x=n.minX),e.y<n.minY&&(e.y=n.minY),e.x>n.maxX&&(e.x=n.maxX),e.y>n.maxY&&(e.y=n.maxY)}}class sp extends ar{constructor(){super(...arguments);p(this,"lineShape")}init(e){const n=e.globalLinePoints,o=n[0],s=n[n.length-1],r=q.line({x:o.x,y:o.y},{x:s.x,y:s.y});this.lineShape=r}enable(e){return e.shapeType===he.Line}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c={x:n.x,y:n.y};this.dealWithPoint(c,o);const h=10,d=q.line({x:s-h,y:c.y},{x:i+h,y:c.y}),u=q.line({x:c.x,y:r-h},{x:c.x,y:a+h}),f=[];if(this.intersectLine(d,c,f),this.intersectLine(u,c,f),f.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const g=Math.min(...f.map(m=>m.distance));return f.find(m=>m.distance-g<.1)??null}intersectLine(e,n,o){const s=Y.intersect(this.lineShape,e);if(s.points.length>0){const r=s.points[0],i=S.distance(r,n);o.push({point:r,distance:i})}}}class rp extends ar{constructor(){super(...arguments);p(this,"lineShapes",[])}init(e){const n=S.computeBezierCurves(e),o=[];for(const s of n){const r=q.cubicBezier(s.p0,s.p1,s.p2,s.p3);o.push(r)}this.lineShapes=o}enable(e){return e.shapeType===he.Curve}handle(e,n){const o=e.getBounds(),{minX:s,minY:r,maxX:i,maxY:a}=o,c={x:n.x,y:n.y};this.dealWithPoint(c,o);const h=10,d=q.line({x:s-h,y:c.y},{x:i+h,y:c.y}),u=q.line({x:c.x,y:r-h},{x:c.x,y:a+h}),f=[];for(const m of this.lineShapes)this.intersectLine(m,d,c,f),this.intersectLine(m,u,c,f);if(f.length===0)return console.warn("探测结果出现问题,兜底容错"),null;const g=Math.min(...f.map(m=>m.distance));return f.find(m=>m.distance-g<.1)??null}intersectLine(e,n,o,s){const r=Y.intersect(e,n);if(r.points.length>0){const i=r.points[0],a=S.distance(i,o);s.push({point:i,distance:a})}}}class ip extends ht{constructor(){super(...arguments);p(this,"line");p(this,"intersectHandlers",[new op,new rp,new sp]);p(this,"currentHandler",null)}onStart(e,n){const{line:o}=n.detect(F.DragLineText,e);this.line=o,this.selectHandler(o),n.execAction(new W)}onMove(e,n){this.onWork(e,n,!0)}onUp(e,n){this.onWork(e,n,!1),n.execAction(new z)}onWork(e,n,o){if(!this.currentHandler)return;const s=e.globalPoint,r=this.currentHandler.handle(this.line,s);if(!r)return;const{width:i,height:a}=this.line.lineTextRect,c=this.line.baseProps,h=r.point,d=h.x-.5*i-c.x,u=h.y-.5*a-c.y;n.execAction(U.create(this.line.id,[{type:I.LineTextRect,x:d,y:u,point:{x:h.x-c.x,y:h.y-c.y}}],{streaming:o}))}selectHandler(e){for(const n of this.intersectHandlers)if(n.enable(e)){n.init(e),this.currentHandler=n;return}}}class ap extends dt{constructor(){super([new ip])}streamEnable(t,e){return!!e.detect(F.DragLineText,t)}}class cp extends ht{constructor(){super(...arguments);p(this,"originPos");p(this,"originNodePos");p(this,"dragNode");p(this,"originDragNodes",[]);p(this,"originBaseProps");p(this,"rowNodes",[]);p(this,"rowIds",[]);p(this,"rowIndex",0);p(this,"targetRowIndex",0);p(this,"isInsertNewRow",!1);p(this,"originIndex",0);p(this,"insertIndex",0)}computeRowNodes(e){const o=this.dragNode.parent.slideProps.children;this.rowNodes=[],this.rowIds=[];let s=-1,r=-1;for(let i=0;i<o.length;i++){const a=o[i],c=[];for(const h of a.ids){const d=e.nodeManager.getNode(h);d&&(c.push(d),d.id===this.dragNode.id&&(s=i,r=c.length-1))}this.rowNodes.push(c.map(h=>h.baseProps.clone())),this.rowIds.push(c.map(h=>h.id))}if(s===-1){this.rowIndex=0,this.originIndex=0;return}this.rowIndex=s,this.originIndex=r}onStart(e,n){const s=[...n.getSelectNodes()][0],r=s.pos;this.dragNode=s,this.originNodePos=new P(r.x,r.y),this.originPos=e.globalPoint,this.originBaseProps=s.globalBaseProps.clone();const i=new Set;S.getAllChildren(s,i);const a=S.sortGraphics([s,...i]);this.originDragNodes=a,this.computeRowNodes(n),n.execAction(new W)}onMove(e,n){const o=e.globalPoint,s=this.originPos,r=o.x-s.x,i=o.y-s.y;n.addOrUpdate(k.HoverSlidePlaceHolder,{baseProps:this.originBaseProps}),n.addOrUpdate(k.HoverFocusCopy,{nodes:this.originDragNodes});const a=this.originNodePos.x+r,c=this.originNodePos.y+i,h=this.dragNode.parent.globalPos,d=o.x-h.x,u=o.y-h.y;this.determineTargetRow(u),this.showInsertIndicator(d,h,n),n.execAction(U.create(this.dragNode.id,[{type:I.Base,x:a,y:c}],{streaming:!0}))}relayoutRow(e,n,o,s,r){let i=n;for(const a of e){const c=s.nodeManager.getNode(a);c&&(r.push({id:a,props:[{type:I.Base,x:i,y:o}]}),i+=c.baseProps.width+nt)}}handleInsertNewRow(e,n){const o=[],s=[...this.rowIds[this.rowIndex]];s.splice(this.originIndex,1);const r=this.targetRowIndex,i=r===0,a=r===this.rowNodes.length;s.length===0?(e.splice(this.rowIndex,1),this.rowIndex<this.targetRowIndex&&this.targetRowIndex--):e[this.rowIndex].ids=s,e.splice(this.targetRowIndex,0,{ids:[this.dragNode.id]});const c=this.dragNode.baseProps;let h,d;if(i){h=this.rowNodes[0][0].x,d=this.rowNodes[0][0].y;const u=c.height+xt;for(let f=0;f<this.rowNodes.length;f++){const g=this.rowIds[f].filter(m=>m!==this.dragNode.id),y=this.rowNodes[f][0].y+u;this.relayoutRow(g,this.rowNodes[f][0].x,y,n,o)}}else if(a){const u=this.rowNodes.length-1,f=this.rowNodes[u];h=f[0].x,d=f[0].y+f[0].height+xt,s.length>0&&this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o)}else{const u=this.rowNodes[r-1];this.rowNodes[r],h=u[0].x,d=u[0].y+u[0].height+xt;const f=c.height+xt;for(let g=0;g<this.rowNodes.length;g++){const y=this.rowIds[g].filter(b=>b!==this.dragNode.id);if(y.length===0)continue;let m;g<r?m=this.rowNodes[g][0].y:m=this.rowNodes[g][0].y+f,this.relayoutRow(y,this.rowNodes[g][0].x,m,n,o)}}return o.push({id:this.dragNode.id,props:[{type:I.Base,x:h,y:d}]}),o}determineTargetRow(e){var a,c,h;if(this.isInsertNewRow=!1,this.rowNodes.length===0){this.targetRowIndex=0;return}const n=((a=this.rowNodes[0][0])==null?void 0:a.y)??0;if(e<n){this.isInsertNewRow=!0,this.targetRowIndex=0,this.insertIndex=0;return}const o=this.rowNodes.length-1,s=this.rowNodes[o],r=((c=s[0])==null?void 0:c.y)??0,i=((h=s[0])==null?void 0:h.height)??0;if(e>r+i){this.isInsertNewRow=!0,this.targetRowIndex=this.rowNodes.length,this.insertIndex=0;return}for(let d=0;d<this.rowNodes.length;d++){const u=this.rowNodes[d];if(u.length===0)continue;const f=u[0].y,g=u[0].height;if(e>=f&&e<=f+g){this.targetRowIndex=d;return}if(d<this.rowNodes.length-1){const y=this.rowNodes[d+1];if(y.length===0)continue;const m=y[0].y,b=f+g,w=m;if(e>b&&e<w){this.isInsertNewRow=!0,this.targetRowIndex=d+1,this.insertIndex=0;return}}}this.targetRowIndex=this.rowIndex}showInsertIndicator(e,n,o){this.isInsertNewRow?this.showNewRowIndicator(n,o):this.showExistingRowIndicator(e,n,o)}showNewRowIndicator(e,n){const o=this.targetRowIndex===0,s=this.targetRowIndex===this.rowNodes.length;let r,i;if(o)r=this.rowNodes[0],i=r[0].y+e.y-.5*xt;else if(s)r=this.rowNodes[this.rowNodes.length-1],i=r[0].y+r[0].height+e.y+.5*xt;else{const u=this.rowNodes[this.targetRowIndex-1],f=this.rowNodes[this.targetRowIndex],g=u[u.length-1].x+u[u.length-1].width-u[0].x,y=f[f.length-1].x+f[f.length-1].width-f[0].x;r=g>=y?u:f;const m=u[0].y+u[0].height,b=f[0].y;i=(m+b)/2+e.y}const a=r[0],c=r[r.length-1],h=a.x+e.x,d=c.x+c.width+e.x;n.addOrUpdate(k.HoverInsertHorizonSlide,{x0:h,x1:d,y:i})}showExistingRowIndicator(e,n,o){const s=this.rowNodes[this.targetRowIndex]||[];for(let r=0;r<s.length;r++){const i=s[r],a=i.x+.5*i.width;if(e<a){this.insertIndex=r,o.addOrUpdate(k.HoverInsertSlide,{x:i.x-.5*nt+n.x,y0:i.y+n.y,y1:i.y+i.height+n.y});return}if(r===s.length-1){this.insertIndex=s.length,o.addOrUpdate(k.HoverInsertSlide,{x:i.x+i.width+.5*nt+n.x,y0:i.y+n.y,y1:i.y+i.height+n.y});return}}}handleSameRowDrag(e,n){const o=[],s=[...this.rowIds[this.rowIndex]];return this.insertIndex<this.originIndex?(s.splice(this.originIndex,1),s.splice(this.insertIndex,0,this.dragNode.id)):(s.splice(this.insertIndex,0,this.dragNode.id),s.splice(this.originIndex,1)),e[this.rowIndex].ids=s,this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o),o}handleCrossRowDrag(e,n){const o=[],s=[...this.rowIds[this.rowIndex]],r=[...this.rowIds[this.targetRowIndex]];if(s.splice(this.originIndex,1),e[this.rowIndex].ids=s,r.splice(this.insertIndex,0,this.dragNode.id),e[this.targetRowIndex].ids=r,s.length===0){const a=this.rowNodes[this.rowIndex][0].height+xt;for(let c=0;c<this.rowNodes.length;c++){if(c===this.rowIndex)continue;const h=c===this.targetRowIndex?r:this.rowIds[c],d=c>this.rowIndex?this.rowNodes[c][0].y-a:this.rowNodes[c][0].y;this.relayoutRow(h,this.rowNodes[c][0].x,d,n,o)}}else this.relayoutRow(s,this.rowNodes[this.rowIndex][0].x,this.rowNodes[this.rowIndex][0].y,n,o),this.relayoutRow(r,this.rowNodes[this.targetRowIndex][0].x,this.rowNodes[this.targetRowIndex][0].y,n,o);return o}onUp(e,n){const o=!this.isInsertNewRow&&this.targetRowIndex===this.rowIndex,s=o&&(this.insertIndex===this.originIndex||this.insertIndex===this.originIndex+1),r=this.rowIds[this.rowIndex].length===1,i=this.isInsertNewRow&&r&&(this.targetRowIndex===this.rowIndex||this.targetRowIndex===this.rowIndex+1);if(s||i){n.execAction(U.create(this.dragNode.id,[{type:I.Base,x:this.originNodePos.x,y:this.originNodePos.y}],{streaming:!1})),n.execAction(new z);return}const c=this.dragNode.parent.slideProps.children.map(g=>({ids:[...g.ids]}));let h;this.isInsertNewRow?h=this.handleInsertNewRow(c,n):o?h=this.handleSameRowDrag(c,n):h=this.handleCrossRowDrag(c,n);const d=c.filter(g=>g.ids.length>0);h.unshift({id:this.dragNode.parent.id,props:[{type:I.Slide,children:d}]}),n.execAction(new U({infos:h}));const u=this.dragNode.parent,f=[];for(const g of d)for(const y of g.ids){const m=n.nodeManager.getNode(y);m&&f.push(m.baseProps)}if(f.length>0){const g=S.getBoundsByBasePropsList(f),y=g.maxX-g.minX,m=g.maxY-g.minY;n.execAction(U.create(u.id,[{type:I.Base,width:y+2*nt,height:m+2*xt}]))}n.execAction(new z)}}class lp extends dt{constructor(){super([new cp])}streamEnable(t,e){var i;const o=[...e.auxiliaryManager.selectManager.getSelectNodes()];if(o.length!==1)return!1;const s=o[0];return((i=s.parent)==null?void 0:i.type)!==v.SlideContainer?!1:S.rectContains2(t.globalPoint,s.getRectNode())}}class Ja extends pn{constructor(){super([new qu,new Gu,new Du,new Eu,new ep,new Cu,new np,new ap,new ia,new qs,new ua,new $a,new Ka,new lp,new Ia,new Vu,new Zu,new Ea,new Ua])}canBeEnable(t,e){return!0}}class ec extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Shape)return!1;const s=o;if(s.isEmptyText())return!1;const r=s.getTextContentRect();if(s.renderText.height<r.height)return!1;const i=e.gmlRender.getScale(),a=s.toLocal(t.globalPoint),{width:c,height:h}=s.baseProps,d=new D(.5*c-.5*21/i,h-.5*12/i,21/i,12/i);return S.rectContains(a,d)?(this.result={node:s,realHeight:s.drawer.fullTextNodeHeight(s)},!0):!1}}class tc extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o,i=8/e.gmlRender.getScale(),a=s.points,c=a[0],h=a[a.length-1],d=s.toLocal(t.globalPoint);let u=S.circleContains(d,c,i);return u?(this.result={detectPoint:c,isStart:!0,line:s},!0):(u=S.circleContains(d,h,i),u?(this.result={detectPoint:h,isStart:!1,line:s},!0):!1)}}const hp=12;class dp extends Ke{onDetect(t,e){const n=e.detect(F.HoverConnectAnchor,t);if(n){const u=Ze.getNodePos(n.node,n.relative);return this.result={node:n.node,point:u,relativePos:n.relative},!0}const o=e.detect(F.HoverNodeAnchor,t);if(o){const u=Ze.getNodePos(o.node,o.ratio);return this.result={node:o.node,point:u,relativePos:o.ratio},!0}const s=e.detect(F.BufferNode,t);if(!s)return!1;const r=s.filter(u=>u.canBeConnected());if(r.length===0)return!1;const i=r[0];if(!i.canBeConnected())return!1;const a=e.renderManager.getScale(),{width:c,height:h}=i.baseProps,d=i.borderContains(t.globalPoint,hp/a);return d?(this.result={node:i,point:i.toGlobal(d),relativePos:new P(d.x/c,d.y/h)},!0):!1}}class Qo extends ht{constructor(){super(...arguments);p(this,"startPos",new P);p(this,"target",null);p(this,"viewBounds");p(this,"alignWorker",new dn)}nodeType(){return v.Shape}autoFocus(){return!0}onStart(e,n){n.previewManager.resetPreviewNode(n),n.alignPoint?(this.startPos=n.alignPoint,n.alignPoint=null):this.startPos=e.globalPoint;const o=n.detect(F.HoverOnContainer,e);let s=n.nodeManager.root,r=new P(this.startPos.x,this.startPos.y);o&&(r=o.toLocal(this.startPos),s=o);const i=this.nodeType(),a=n.idGenerator.genId(i),c=this.makeupDefaultProps(n,r);console.log("njx debug,props:",c);const h={id:a,type:i,zIndex:ve.genZIndex(s),parentId:s.id,props:c};n.actionManager.execAction(new W);const d=Le.create(h);n.actionManager.execAction(d),this.target=n.nodeManager.nodeMap.get(a);const u=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(k.CreateRectBound,{rect:u,transform:this.target.globalTransform()}),n.auxiliaryManager.removeAlignGraphics(),this.viewBounds=n.gmlRender.getViewPortBounds()}onMove(e,n){if(!this.target)return;n.auxiliaryManager.removeAlignGraphics();const o=this.target.baseProps.clone(),s=new Set([this.target]),r=!S.pressMeta(e),i=this.alignWorker.alignLineEndAndDrawAlignLines(e,n,s,r);this.computeRectBounds(i,o);const a=n.gmlRender.getScale(),c=D.baseProps2Rect(o),h=new Set(n.getSelectNodes());h.add(this.target);const d=this.alignWorker.alignStretch(n,c,h,_e.both,this.viewBounds,Us/a,Gs/a);this.drawAlignLine(c,d,n);const u=new P(c.x,c.y),f=this.target.parent.toLocal(u),g={type:I.Base,x:f.x,y:f.y,width:c.width,height:c.height},y=U.create(this.target.id,[g],{streaming:!0});n.actionManager.execAction(y);const m=D.baseProps2Rect(this.target.baseProps);n.addOrUpdate(k.CreateRectBound,{rect:m,transform:this.target.globalTransform()})}onUp(e,n){if(!this.target)return;const o=n.renderManager.getScale(),s=this.target.baseProps,r={type:I.Base,x:s.x,y:s.y,width:s.width,height:s.height},{width:i,height:a}=this.computeMiniSize(),c=this.computeDefaultSize(n);let h=!1;S.distance(this.startPos,e.globalPoint)<Math.max(9,9/o)?(r.width=c.width,r.height=c.height,h=!0):(r.width<i||r.height<a)&&(r.width=c.width,r.height=c.height);const d=[r];this.dealWithUpUpdateProps(h,d);const u=U.create(this.target.id,d);n.actionManager.execAction(u),n.actionManager.execAction(xe.create([this.target.id])),this.autoFocus()&&n.actionManager.execAction(ee.focus(this.target.id)),n.actionManager.execAction(new z),this.target=null,n.toolManager.resetTool(),n.removeAuxGraphic(k.CreateRectBound),n.auxiliaryManager.removeAlignGraphics(),n.setCursor("default")}dealWithUpUpdateProps(e,n){}computeRectBounds(e,n,o=10,s=10){if(!this.target)return;const r=Math.max(Math.abs(e.x-this.startPos.x),o),i=Math.max(Math.abs(e.y-this.startPos.y),s);n.width=r,n.height=i,e.x>=this.startPos.x&&e.y>=this.startPos.y?(n.x=this.startPos.x,n.y=this.startPos.y):e.x>this.startPos.x&&e.y<this.startPos.y?(n.x=this.startPos.x,n.y=this.startPos.y-i):e.x<this.startPos.x&&e.y>this.startPos.y?(n.x=this.startPos.x-r,n.y=this.startPos.y):e.x<=this.startPos.x&&e.y<=this.startPos.y?(n.x=this.startPos.x-r,n.y=this.startPos.y-i):(n.x=this.startPos.x-r,n.y=this.startPos.y-i)}drawAlignLine(e,n,o){const s=this.target,r=s.baseProps,{width:i,height:a}=n;if(i){e.width+=i.dt;const c={transform:s.transform.clone(),line:{start:new P(0,r.height),end:new P(r.width,r.height)}};i.lines.push(c)}if(a){e.height+=a.dt;const c={transform:s.transform.clone(),line:{start:new P(r.width,0),end:new P(r.width,r.height)}};a.lines.push(c)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}}class nc extends Qo{constructor(){super(...arguments);p(this,"startPos",new P);p(this,"target",null)}computeDefaultSize(){return{width:100,height:100}}computeMiniSize(){return{height:5,width:5}}makeupDefaultProps(e,n){return e.createWorker.makeupDefaultProps(v.Shape,e,e.toolManager.shapeType,n)}dealWithUpUpdateProps(e,n){e||n.push({type:I.Text,sizeMode:We.fix})}}class oc extends Nn{constructor(){super([new nc])}streamEnable(t,e){return e.toolManager.currentTool==ye.SHAPE}}class sc extends Qo{computeDefaultSize(){return{height:0,width:0}}computeMiniSize(){return{height:0,width:0}}makeupDefaultProps(t,e){return[ie.create({x:e.x,y:e.y}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p></p></root>",horizonAlign:at.Top,verticalAlign:at.Top}),new Oe(K.PureText)]}}class rc extends dt{constructor(){super([new sc])}streamEnable(t,e){return e.toolManager.currentTool==ye.TEXT}}class ic extends Ot{constructor(t){super(t)}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class up extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){return n.toolManager.currentTool===ye.TEXT}handle(e,n){const o=n.idGenerator.genId(v.Shape),s=n.detect(F.HoverOnContainer,e);let r=n.nodeManager.root,i=e.globalPoint.clone();s&&(i=s.toLocal(i),r=s);const a=this.makeupDefaultProps(i),c={id:o,type:v.Shape,zIndex:ve.genZIndex(n.nodeManager.root),parentId:r.id,props:a};n.actionManager.execAction(new W);const h=Le.create(c);n.actionManager.execAction(h),n.actionManager.execAction(xe.create([o])),n.actionManager.execAction(ee.focus(o)),n.actionManager.execAction(new z),n.toolManager.resetTool()}makeupDefaultProps(e){return[ie.create({x:e.x,y:e.y,height:22,width:64}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p></p></root>",horizonAlign:at.Top,verticalAlign:at.Top,sizeMode:We.autoWidth}),new Oe(K.PureText)]}}class pp extends qe{constructor(){super(...arguments);p(this,"res",null)}enable(e,n){const o=n.detect(F.Node,e);if(o){const s=o[0],r=s.toLocal(e.globalPoint);if(s instanceof vt&&s.renderText.contains(r))return this.res={node:s,relativePos:r},!0;if(s instanceof Ct)return this.res={node:s,relativePos:r},!0}return!1}handle(e,n){if(!this.res)return;n.toolManager.resetTool();const{node:o,relativePos:s}=this.res,r=o.renderText.detect(s);n.execAction(new W),n.execAction(xe.create([o.id])),n.execAction(ee.focus(o.id,r)),n.execAction(new z)}}class fp extends jt{constructor(){super(),this.registerUpHandler(new up),this.registerUpHandler(new pp)}}class gp extends un{constructor(){super([new fp])}clickEnable(t,e){return e.toolManager.currentTool===ye.TEXT}}class yp extends Qo{constructor(){super(...arguments);p(this,"startPos",new P);p(this,"target",null)}computeDefaultSize(e){const n=e.toolManager.shapeType,o=Uo[n];return{width:o.width,height:o.height}}computeMiniSize(){return{height:5,width:5}}nodeType(){return v.Section}autoFocus(){return!1}makeupDefaultProps(e,n){return e.createWorker.makeupDefaultProps(v.Section,e,e.toolManager.shapeType,n)}}class xp extends Nn{constructor(){super([new yp])}streamEnable(t,e){return e.toolManager.currentTool==ye.SECTION}}class ac extends _o{constructor(){super(...arguments);p(this,"handlers",[new Fa])}}class cc{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"alignWorker",new dn)}process(t,e){const n=e.previewManager.createManager;if(!n.previewGraphics)return;const o=e.toolManager.grab;e.auxiliaryManager.removeAlignGraphics();const{rectNode:s,delta:r}=this.computeMoveRect(n.previewGraphics,t.globalPoint,o),i=this.alignWorker.alignMove(s,e.getSelectNodes(),e,!0),a=this.alignWorker.drawAlignLines(i,e),c=new P(s.minX+a.x,s.minY+a.y);e.alignPoint=c,e.previewManager.updatePos(c),e.addOrUpdate(k.PreviewGraphics,{previewNodes:[n.previewGraphics]})}computeMoveRect(t,e,n){const o=t.getBounds(),s=D.rectNode2Rect(o),r=n?s.x+.5*s.width:s.x,i=n?s.y+.5*s.height:s.y,a=new P(e.x-r,e.y-i);return o.minX+=a.x,o.maxX+=a.x,o.minY+=a.y,o.maxY+=a.y,{rectNode:o,delta:a}}}class Bn{handle(t,e,n){this.makeupAddNodeInfo(t,e,n).then(o=>{const s=o.id;t.actionManager.execAction(new W);const r=Le.create(o);t.actionManager.execAction(r),t.actionManager.execAction(xe.create([s])),this.autoFocus()&&t.actionManager.execAction(ee.focus(s)),t.actionManager.execAction(new z),t.toolManager.resetTool(),t.previewManager.resetPreviewNode(t),t.auxiliaryManager.removeAlignGraphics()})}detectParentContainer(t,e){const n=t.detect(F.HoverOnContainer,e);let o=t.nodeManager.root;return n&&(o=n),o}}class wp extends Bn{enable(t){return t===ye.SHAPE}async makeupAddNodeInfo(t,e,n){const o=t.toolManager.shapeType,s=this.detectParentContainer(t,n),r=t.createWorker.makeupDefaultProps(v.Shape,t,o,e,s);return{id:t.idGenerator.genId(v.Shape),type:v.Shape,zIndex:ve.genZIndex(s),parentId:s.id,props:r}}autoFocus(){return!0}}class Pp extends Bn{enable(t){return t===ye.SECTION}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.toolManager.shapeType,r=t.createWorker.makeupDefaultProps(v.Section,t,s,e,o);return{id:t.idGenerator.genId(v.Section),type:v.Section,zIndex:ve.genZIndex(o),parentId:o.id,props:r}}autoFocus(){return!1}}const mp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Zo=(l=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(l|=0));for(;l--;)t+=mp[e[l]&63];return t};class cr{async addSvgNodeBySvgCode(t,e,n,o=n.nodeManager.root){const s=n.docState.docId,r=Zo(10),i=`${s}/${r}`,a=await n.resourceManager.uploadSvgString(i,t),c=this.computeAddSvgNode(t,a,e,n,o);return{url:a,addNodeInfo:c}}computeAddSvgNode(t,e,n,o,s=o.nodeManager.root){const r=yn.trimSvgCode(t),i=[{type:I.Base,x:n.x,y:n.y,width:r.width,height:r.height},{type:I.Svg,url:e},{type:I.Border,dashType:et.None}];return{id:o.idGenerator.genId(v.SVG),type:v.SVG,zIndex:ve.genZIndex(s),parentId:s.id,props:i}}}class bp extends Bn{constructor(){super(...arguments);p(this,"svgWorker",new cr)}autoFocus(){return!1}enable(e){return e===ye.Resource}async makeupAddNodeInfo(e,n,o){const s=this.detectParentContainer(e,o),r=s.toLocal(n),i=e.previewManager.previewResourceManager.previewSvgCode;i===""&&console.error("出现错误,svg code为空");const{addNodeInfo:a}=await this.svgWorker.addSvgNodeBySvgCode(i,r,e,s);return a}}class Sp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.Widget&&e===Un.Checkbox}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.Checkbox,t,0,e,o);return{id:t.idGenerator.genId(v.Checkbox),type:v.Checkbox,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class Mp extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.Widget&&e===Un.CheckboxText}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.CheckboxText,t,0,e,o);return{id:t.idGenerator.genId(v.CheckboxText),type:v.CheckboxText,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class vp extends Bn{enable(t){return t===ye.LINE}async makeupAddNodeInfo(t,e,n){const o=t.toolManager.shapeType,s=this.detectParentContainer(t,n),r=t.createWorker.makeupDefaultProps(v.Line,t,o,e,s);return{id:t.idGenerator.genId(v.Line),type:v.Line,zIndex:ve.genZIndex(s),parentId:s.id,props:r}}autoFocus(){return!1}}class Ip extends Bn{autoFocus(){return!1}enable(t,e){return t===ye.SlideContainer}async makeupAddNodeInfo(t,e,n){const o=this.detectParentContainer(t,n),s=t.createWorker.makeupDefaultProps(v.SlideContainer,t,0,e,o);return{id:t.idGenerator.genId(v.SlideContainer),type:v.SlideContainer,zIndex:ve.genZIndex(o),parentId:o.id,props:s}}}class lc{constructor(){p(this,"allowEventTypeSet",new Set([be.pointerup]));p(this,"startPos",new P);p(this,"handlers",[new bp,new wp,new Pp,new vp,new Sp,new Mp,new Ip])}process(t,e){e.toolManager.grab&&(e.alignPoint?(this.startPos=e.alignPoint,e.alignPoint=null):this.startPos=t.globalPoint,this.handleCreateUp(this.startPos,e,t))}handleCreateUp(t,e,n){for(const o of this.handlers)if(o.enable(e.toolManager.currentTool,e.toolManager.shapeType)){o.handle(e,t,n);return}}}const Tp=new Set([ye.SHAPE,ye.TEXT,ye.SECTION,ye.Resource,ye.Widget,ye.SlideContainer]);class Lp extends pn{constructor(){super([new gp,new xp,new oc,new rc,new ic([new ac,new cc,new lc])])}canBeEnable(t,e){return Tp.has(e.toolManager.currentTool)}}const qo=12;class Cp extends Ke{onDetect(t,e){const n=t.globalPoint,o=e.nodeManager.searchNodes(n.x-qo,n.y-qo,n.x+qo,n.y+qo);if(o.length===0)return this.result=null,!1;const s=S.sortGraphics(o);return s.reverse(),this.result=s,!0}}class Ap extends Ke{onDetect(t,e){const n=e.detect(F.BufferNode,t);if(!n)return!1;const o=n[0];return e.auxiliaryManager.selectManager.include(o)?!1:(this.result=o,!0)}}const Np=12;class kp extends Ke{onDetect(t,e){const n=e.detect(F.BufferNode,t);if(!n)return!1;const o=n.filter(u=>u.canBeConnected());if(o.length===0)return!1;const s=o[0];if(!s.canBeConnected()||e.auxiliaryManager.selectManager.include(s))return!1;const r=e.renderManager.getScale(),i=Np/r,{width:a,height:c}=s.baseProps,h=s.toLocal(t.globalPoint),d=s.getConnectAnchor();for(const u of d){const f=new P(u.x*a,u.y*c);if(S.circleContains(h,f,i))return this.result={node:s,ratio:u,localPoint:f},!0}return!1}}class hc extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(!s.isPolyLine())return!1;const r=e.gmlRender.getScale(),i=s.points;for(let a=0;a<i.length-1;a++){const c=i[a],h=i[a+1];if(S.distance(c,h)<(A+6)/r)continue;const u=S.judgeHorizon(c,h),f=.5*(c.x+h.x),g=.5*(c.y+h.y);let y;if(u){const w=new P(f-8/r,g);y=new D(w.x,w.y-4/r,16/r,8/r)}else{const w=new P(f,g-8/r);y=new D(w.x-4/r,w.y,8/r,16/r)}const m=s.toLocal(t.globalPoint);if(S.rectContains(m,y))return this.result={isHorizon:u,line:s,point:new P(f,g),lIndex:a,rIndex:a+1},!0}return!1}}const Bp=[new P(.5,0),new P(1,.5),new P(.5,1),new P(0,.5)];class Rp extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(!o.canQuickCreate())return!1;const s=e.renderManager.getScale(),r=S.computeNodeConnectAnchor(o,s),i=Ms/s;for(let a=0;a<r.length;a++){const c=r[a],h=o.toLocal(t.globalPoint);let d=Bp[a];if(S.circleContains(h,c,i))return o.type===v.Shape&&(d=o.drawer.getConnectAnchor()[a]),this.result={node:o,localPoint:c,globalPoint:o.toGlobal(c),relative:d},!0}return!1}}const Ep=new Set([v.Checkbox,v.Group,v.CheckboxText,v.Section,v.Line]),ws=class ws extends Ke{onDetect(t,e){const n=$t.flattenNodes([...e.getSelectNodes()]);if(n.length===0)return!1;const o=e.auxiliaryManager.selectManager.getSelectBounds();if(S.rectContains2(t.globalPoint,o)||e.detect(F.Stretch,t))return!1;const s=e.gmlRender.getScale(),r=ws.HOT_DISTANCE/s;let i=re.generateMatrix(),a,c,h;if(n.length===1){const d=n[0];if(Ep.has(d.type))return!1;const u=d.baseProps;i=d.globalTransform().clone();const f=new P(.5*u.width,.5*u.height);a=i.crossPoint(f),c=new D(0,0,u.width,u.height),h=i.inverseMatrix().crossPoint(t.globalPoint)}else{const d=e.auxiliaryManager.selectManager.getSelectBounds();c=D.rectNode2Rect(d),a=new P(.5*(d.minX+d.maxX),.5*(d.minY+d.maxY)),h=new P(t.globalPoint.x-c.x,t.globalPoint.y-c.y)}return S.circleContains({x:0,y:0},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,180),rotateType:Zt.TOP_LEFT},!0):S.circleContains({x:c.width,y:0},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,-90),rotateType:Zt.TOP_RIGHT},!0):S.circleContains({x:c.width,y:c.height},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,0),rotateType:Zt.BOTTOM_RIGHT},!0):S.circleContains({x:0,y:c.height},h,r)?(this.result={rotateCenter:a,nodes:n,cursorAngle:S.computeRotateAngle(n,90),rotateType:Zt.BOTTOM_LEFT},!0):!1}};p(ws,"HOT_DISTANCE",16);let Jo=ws;class Hp extends Ke{onDetect(t,e){const n=e.detect(F.Node,t),o=e.docState.docMode===ue.SLIDE_EDIT;if(!n){if(o){const r=S.getSlideContainerChildNode(e.docState.slideStatus.slideContainer,e.docState.slideStatus.currentIndex,e);return this.result=r,!0}return!1}const s=e.getSelectNodes();for(const r of n)if(!s.has(r)&&r.type===v.Section)return this.result=r,!0;if(o){const r=S.getSlideContainerChildNode(e.docState.slideStatus.slideContainer,e.docState.slideStatus.currentIndex,e);return this.result=r,!0}return!1}}class Dp extends jt{constructor(){super(),this.registerDownHandler(new er),this.registerDownHandler(new tr),this.registerUpHandler(new nr),this.registerUpHandler(new ka),this.registerUpHandler(new or)}}class Op extends un{constructor(){super([new Dp])}}class Xp extends jt{constructor(){super(),this.registerDownHandler(new Za)}}class zp extends js{constructor(){super([new Xp])}}class Wp extends _o{constructor(){super(...arguments);p(this,"handlers",[new sr])}}class Fp{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new Ha,new Oa,new Xa,new Da])}process(t,e){const n=e.detect(F.HoverNode,t);if(n){for(const o of this.handlers)if(o.enable(n)){o.handle(n,e);return}}}}class Yp extends Ot{constructor(){super([new Fp,new Wp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Gp extends pn{constructor(){super([new qs,new zp,new Op,new Yp])}canBeEnable(t,e){return!e.docState.canEdit()}}class Up extends Ke{onDetect(t,e){const n=[...e.getSelectNodes()];if(n.length!==1)return!1;const o=n[0];if(o.type!==v.IMG)return!1;const s=e.detect(F.Node,t);return s&&e.auxiliaryManager.selectManager.include(s[0])?(this.result=o,!0):!1}}class _p extends Nn{constructor(){super([new qa])}streamEnable(t,e){return!0}}class $p{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]))}process(t,e){e.setCursor("grab")}}class jp extends Ot{constructor(){super([new $p])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Vp extends pn{constructor(){super([new _p,new jp])}canBeEnable(t,e){return e.toolManager.currentTool===ye.HandTool}}class Kp extends gt{enable(t,e){return!!e.detect(F.ImageOriginBounds,t)}handle(t,e){const n=e.detect(F.ImageOriginBounds,t);n.type===V.BOTTOM||n.type===V.TOP?e.setCursor("ns-resize"):n.type===V.RIGHT||n.type===V.LEFT?e.setCursor("ew-resize"):n.type===V.TOP_LEFT||n.type===V.BOTTOM_RIGHT?e.setCursor("nwse-resize"):(n.type===V.TOP_RIGHT||n.type===V.BOTTOM_LEFT)&&e.setCursor("nesw-resize")}}class Qp extends _o{constructor(){super(...arguments);p(this,"handlers",[new Ya,new Kp,new sr])}}class Zp extends Ot{constructor(){super([new Qp])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class qp extends ht{constructor(){super(...arguments);p(this,"limitBounds");p(this,"imgNode");p(this,"lastPoint");p(this,"stretchRect");p(this,"transform");p(this,"stretchType")}onStart(e,n){const o=n.detect(F.Stretch,e);this.stretchType=o.type;const s=[...n.getSelectNodes()][0];this.imgNode=s;const r=s.getOriginImageRect().clone(),i=s.toGlobal({x:r.x,y:r.y}),a=this.imgNode.globalBaseProps;this.limitBounds=new D(i.x,i.y,r.width,r.height);const c=re.generateMatrix().rotate(a.angle),d=re.generateMatrix().translate(i.x,i.y).crossProduct(c);this.transform=d.inverseMatrix(),this.lastPoint=this.transform.crossPoint(e.globalPoint);const u=new P(a.x,a.y),f=this.transform.crossPoint(u);this.stretchRect=new D(f.x,f.y,a.width,a.height),n.execAction(new W)}onCropNode(e,n,o){const s=this.transform.crossPoint(e.globalPoint),r=new P(s.x-this.lastPoint.x,s.y-this.lastPoint.y);this.lastPoint=s;const i=this.stretchRect;switch(this.stretchType){case V.TOP:i.y=i.y+r.y,i.height=i.height-r.y;break;case V.BOTTOM:i.height=i.height+r.y;break;case V.LEFT:i.x=i.x+r.x,i.width=i.width-r.x;break;case V.RIGHT:i.width=i.width+r.x;break;case V.TOP_LEFT:i.y=i.y+r.y,i.height=i.height-r.y,i.x=i.x+r.x,i.width=i.width-r.x;break;case V.TOP_RIGHT:i.y=i.y+r.y,i.height=i.height-r.y,i.width=i.width+r.x;break;case V.BOTTOM_LEFT:i.x=i.x+r.x,i.width=i.width-r.x,i.height=i.height+r.y;break;case V.BOTTOM_RIGHT:i.width=i.width+r.x,i.height=i.height+r.y;break}const a=this.modifyStretchRect(i),c=new P(a.x,a.y),h=this.transform.inverseMatrix().crossPoint(c),d=this.imgNode.parent.toLocal(h),u=[{type:I.Base,x:d.x,y:d.y,width:a.width,height:a.height}];n.execAction(U.create(this.imgNode.id,u,{streaming:o}));const f=this.imgNode.toLocal(new P(this.limitBounds.x,this.limitBounds.y));n.execAction(U.create(this.imgNode.id,[{type:I.Crop,cropInfo:{imgX:f.x,imgY:f.y,imgWidth:this.limitBounds.width,imgHeight:this.limitBounds.height}}],{streaming:o}))}onMove(e,n){this.onCropNode(e,n,!0)}modifyStretchRect(e){const n=new D(e.x,e.y,e.width,e.height);return n.width<10&&(n.width=10),n.height<10&&(n.height=10),e.x<0?(n.x=0,n.width=e.x+e.width):e.x+e.width>this.limitBounds.width&&(n.width=this.limitBounds.width-e.x),e.y<0?(n.y=0,n.height=e.y+e.height):e.y+e.height>this.limitBounds.height&&(n.height=this.limitBounds.height-e.y),n}onUp(e,n){this.onCropNode(e,n,!1),n.execAction(new z)}}class Jp extends dt{constructor(){super([new qp])}streamEnable(t,e){return!!e.detect(F.Stretch,t)}}class ef extends fn{enable(t){return t.type===v.IMG}handle(t,e,n,o,s){const r=e.crop,i=e.crop.globalImgPos,a=r.originCropProps,c=a.cropType,h=r.originTransform,d=s.crossPoint(i),u=h.crossPoint(d);return[{id:t.id,props:[{type:I.Crop,cropInfo:{imgX:u.x,imgY:u.y,imgWidth:a.cropInfo.imgWidth*n,imgHeight:a.cropInfo.imgHeight*o},cropType:c}]}]}}class tf extends Go{constructor(){super(...arguments);p(this,"handlers",[new ef])}computeAnchorPoint(e,n){const o=this.target.nodes[0],{x:s,y:r,width:i,height:a}=o.getOriginImageRect();switch(e.type){case V.TOP:return this.alignType=_e.height,{x:s,y:r+a};case V.RIGHT:return this.alignType=_e.width,{x:s,y:r};case V.BOTTOM:return this.alignType=_e.height,{x:s,y:r};case V.LEFT:return this.alignType=_e.width,{x:s+i,y:r};case V.TOP_LEFT:return this.alignType=_e.both,{x:s+i,y:r+a};case V.TOP_RIGHT:return this.alignType=_e.both,{x:s,y:r+a};case V.BOTTOM_RIGHT:return this.alignType=_e.both,{x:s,y:r};case V.BOTTOM_LEFT:default:return this.alignType=_e.both,{x:s+i,y:r}}}judgeUniform(e){this.isUniform=!0}computeTarget(e,n){const o=n.detect(F.ImageOriginBounds,e),s=[...n.getSelectNodes()];this.target={type:o.type,nodes:s,angle:S.computeStretchAngle(s,o.type)}}alignStretchGlobalPoint(e,n){const o=[...n.getSelectNodes()][0],s=o.toLocal(e.globalPoint),r=o.baseProps,i=e.globalPoint.clone(),a=this.target.type;return s.x>0&&(a===V.LEFT||a===V.BOTTOM_LEFT||a===V.TOP_LEFT)&&(i.x=o.toGlobal({x:0,y:0}).x),s.x<r.width&&(a===V.RIGHT||a===V.BOTTOM_RIGHT||a===V.TOP_RIGHT)&&(i.x=o.toGlobal({x:r.width,y:0}).x),s.y>0&&(a===V.TOP||a===V.TOP_RIGHT||a===V.TOP_LEFT)&&(i.y=o.toGlobal({x:0,y:0}).y),s.y<r.height&&(a===V.BOTTOM||a===V.BOTTOM_RIGHT||a===V.BOTTOM_LEFT)&&(i.y=o.toGlobal({x:0,y:r.height}).y),i}computeOriginTransform(e){const n=this.target,o=[...e.getSelectNodes()][0],{x:s,y:r,angle:i}=o.globalBaseProps,a=re.generateMatrix().rotate(-i),c=re.generateMatrix().translate(-s,-r),h=this.computeAnchorPoint(n,D.baseProps2Rect(o.baseProps)),u=re.generateMatrix().translate(-h.x,-h.y).crossProduct(a.crossProduct(c));this.originTransform=u}drawAlignLine(e,n,o){const s=this.target.nodes[0],r=s.baseProps,{width:i,height:a}=n,c=s.globalTransform().clone();if(i){e.width+=i.dt;const h={transform:c,line:{start:new P(0,r.height),end:new P(r.width,r.height)}};i.lines.push(h)}if(a){e.height+=a.dt;const h={transform:c,line:{start:new P(r.width,0),end:new P(r.width,r.height)}};a.lines.push(h)}o.addOrUpdate(k.AlignStretchLine,{alignInfo:n})}getMiniSize(e){const n=this.target.type,o=this.target.nodes[0],s=o.baseProps,{x:r,y:i,width:a,height:c}=o.getOriginImageRect(),h=a/c;switch(n){case V.BOTTOM:case V.RIGHT:case V.BOTTOM_RIGHT:{const d=s.width-r,u=s.height-i,f=u*h;return d>f?new P(d,d/h):new P(f,u)}case V.LEFT:case V.BOTTOM_LEFT:{const d=a+r,u=s.height-i,f=u*h;return d>f?new P(d,d/h):new P(f,u)}case V.TOP_LEFT:{const d=a+r,u=c+i,f=u*h;return d>f?new P(d,d/h):new P(f,u)}case V.TOP:case V.TOP_RIGHT:{const d=s.width-r,u=c+i,f=u*h;return d>f?new P(d,d/h):new P(f,u)}default:return new P(s.width,s.height)}}getStretchRect(e){const n=[...e.getSelectNodes()][0],o=D.baseProps2Rect(n.baseProps),s=n.getOriginImageRect();return o.width=s.width,o.height=s.height,o.x=o.x-s.x,o.y=o.y-s.y,o}recordPropsMap(e){this.propsMap.clear();const n=this.target.nodes;for(const o of n){const s=this.recordNodePropInfo(o);this.propsMap.set(o,s)}}afterStretchNode(e,n,o,s,r,i,a){e.asyncRenderNodeManager.batchAddRenderNode(a)}}class nf extends dt{constructor(){super([new tf])}streamEnable(t,e){return!!e.detect(F.ImageOriginBounds,t)}}class of extends ht{constructor(){super(...arguments);p(this,"lastPoint");p(this,"originImgRect");p(this,"imgNode");p(this,"limitBounds");p(this,"transform");p(this,"dragRect")}onStart(e,n){this.imgNode=[...n.getSelectNodes()][0],this.originImgRect=this.imgNode.getOriginImageRect().clone();const o=this.imgNode.globalBaseProps,s=this.imgNode.toGlobal({x:this.originImgRect.x,y:this.originImgRect.y});this.limitBounds=new D(s.x,s.y,this.originImgRect.width,this.originImgRect.height);const r=re.generateMatrix().rotate(o.angle),a=re.generateMatrix().translate(s.x,s.y).crossProduct(r);this.transform=a.inverseMatrix();const c=this.transform.crossPoint({x:o.x,y:o.y});this.dragRect=new D(c.x,c.y,o.width,o.height),this.lastPoint=this.transform.crossPoint(e.globalPoint),n.execAction(new W)}onMove(e,n){this.dragCrop(e,n,!0)}onUp(e,n){this.dragCrop(e,n,!1),n.execAction(new z)}dragCrop(e,n,o){const s=this.imgNode.cropProps.cropInfo,r=this.modifyCropBasePos(e,n),i=this.imgNode.parent.toLocal(r),a=[{type:I.Base,x:i.x,y:i.y}];n.execAction(new U({infos:[{id:this.imgNode.id,props:a}]},{streaming:o}));const c=this.imgNode.toLocal(this.limitBounds),h={imgX:c.x,imgY:c.y,imgWidth:s.imgWidth,imgHeight:s.imgHeight},d=[{type:I.Crop,cropInfo:h}];n.execAction(new U({infos:[{id:this.imgNode.id,props:d}]},{streaming:o}))}modifyCropBasePos(e,n){const o=e.globalPoint,s=this.transform.crossPoint(o),r=s.x-this.lastPoint.x,i=s.y-this.lastPoint.y,a=this.dragRect;a.x+=r,a.y+=i;const c=this.imgNode.baseProps,h=new P(a.x,a.y);a.x+a.width>this.limitBounds.width?h.x=this.limitBounds.width-c.width:a.x<0&&(h.x=0),a.y<0?h.y=0:a.y+a.height>this.limitBounds.height&&(h.y=this.limitBounds.height-c.height);const d=this.transform.inverseMatrix().crossPoint(h);return this.lastPoint=s,d}}class sf extends dt{constructor(){super([new of])}streamEnable(t,e){const n=[...e.getSelectNodes()];return n.length!==1||!e.cropManager.duringCrop?!1:!!n[0].contains(t.globalPoint)}}class xo{intoCrop(t){const e=t.getSelectNodes();if(e.size!==1)return;const n=[...e][0];if(!(n instanceof Fn)||t.cropManager.duringCrop)return;t.cropManager.intoCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus(),t.renderManager.addAuxiliaryDrawTask();const s=n.cropProps;if(!s.cropInfo||s.cropType===wt.None){const{width:r,height:i}=n.baseProps;t.execAction(new W),t.execAction(U.create(n.id,[{cropType:wt.Rect,cropInfo:{imgX:0,imgY:0,imgWidth:r,imgHeight:i},type:I.Crop}])),t.execAction(new z)}}exitCrop(t){if(t.cropManager.duringCrop){t.cropManager.exitCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus(),t.renderManager.addAuxiliaryDrawTask();return}}resetCrop(t){const e=t.getSelectNodes();if(e.size!==1)return;const n=[...e][0];if(!(n instanceof Fn)||!t.cropManager.duringCrop)return;const s=n.cropProps;if(!s.cropInfo||s.cropType===wt.None)return;const r=n.getOriginImageRect(),i=new P(r.x,r.y),a=n.toGlobal(i),c=n.parent.toLocal(a);t.execAction(new W),t.execAction(U.create(n.id,[{cropType:wt.None,type:I.Crop},{type:I.Base,x:c.x,y:c.y,width:r.width,height:r.height}])),t.execAction(new z),t.cropManager.exitCrop(),t.auxiliaryManager.selectManager.refreshSelectStatus()}}class rf extends qe{constructor(){super(...arguments);p(this,"worker",new xo)}enable(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return!1;const s=o[0],r=s.toLocal(e.globalPoint),i=s.getOriginImageRect();return n.detect(F.ImageOriginBounds,e)?!1:!S.rectContains(r,i)}handle(e,n){this.worker.exitCrop(n),n.auxiliaryManager.slotManager.addSlotState(ze.ExitCrop,!0)}}class af extends jt{constructor(){super(),this.registerDownHandler(new rf)}}class cf extends un{constructor(){super([new af])}}class lf extends pn{constructor(){super([new Jp,new nf,new sf,new cf,new Zp])}canBeEnable(t,e){return e.cropManager.duringCrop}}class hf extends Ke{onDetect(t,e){const n=e.getSelectNodes();if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.IMG||!e.cropManager.duringCrop)return!1;const s=o,{cropType:r,cropInfo:i}=s.cropProps;if(r===wt.None||!i)return!1;const a=8/e.renderManager.getScale(),c=s.getOriginImageRect(),h=o.toLocal(t.globalPoint),d=S.detectRectBounds(c,h,a);return d?(this.result={type:d.type},!0):!1}}class lr{constructor(){p(this,"alignWorker",new dn)}computeLinePoints(t,e,n){return Ze.computeLinePoints(t,this.layoutHandler,e,n,this.alignWorker)}alignLinePointsInMove(t,e){return t}alignLinePointsInUp(t,e){return t}computeDownProps(t,e,n,o){const r=[new Oe(e.toolManager.shapeType)],i=e.detect(F.NodeEdge,e.lastDiffTypeEvent);if(i){const y={type:I.Connect,start:{objectId:i.node.id,x:i.relativePos.x,y:i.relativePos.y}};t.point=new P(i.point.x,i.point.y),t.nodeConnect={rect:D.rectNode2Rect(i.node.getBounds()),endType:S.computeNodeConnectEnd(i.relativePos,i.node.baseProps.angle)},r.push(y)}else r.push(new Rt);const a={point:new P(t.point.x+1,t.point.y+1)},c=this.layoutHandler.layoutToPointsPro(t,a),h=o.globalTransform().inverseMatrix(),d=c.map(y=>h.crossPoint(y)),u=je.create(d),f=D.rectNode2Rect(S.getBoundsByPoints(d)),g=ie.create({x:f.x,y:f.y,width:f.width,height:f.height});return r.push(u,g,new Ae,lt.create({rArrow:it.Arrow}),Ge.create({sizeMode:We.autoWidth}),new Et),r}computeMoveProps(t,e,n,o){const s=S.dealWithShiftLineInteractEvent(e,o),r=this.computeLinePoints(t,s,n),i=this.alignLinePointsInMove(r,n),a=o.parent.globalTransform().inverseMatrix(),c=i.map(f=>a.crossPoint(f)),h=D.rectNode2Rect(S.getBoundsByPoints(c)),d=[je.create(c),ie.create({x:h.x,y:h.y,width:h.width,height:h.height})],u={infos:[{id:o.id,props:d}]};n.actionManager.execAction(new U(u,{streaming:!0}))}computeUpProps(t,e,n,o){const s=S.dealWithShiftLineInteractEvent(e,o),r=[],i=n.detect(F.NodeEdge,s);if(i){const g=o.connectProps.clone();g.end={objectId:i.node.id,x:i.relativePos.x,y:i.relativePos.y},r.push(g)}const a=this.computeLinePoints(t,s,n),c=this.alignLinePointsInUp(a,n),h=o.parent.globalTransform().inverseMatrix(),d=c.map(g=>h.crossPoint(g)),u=D.rectNode2Rect(S.getBoundsByPoints(d));r.push(je.create(d),ie.create({x:u.x,y:u.y,width:u.width,height:u.height}));const f={infos:[{id:o.id,props:r}]};n.actionManager.execAction(new U(f,{streaming:!1}))}}let es=class extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new Xo)}enable(e){return e===he.Line}};class ts extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new uo)}enable(e){return e===he.Curve}}class ns extends lr{constructor(){super(...arguments);p(this,"layoutHandler",new Vt)}enable(e){return e===he.RoundPolyLine||e===he.PolyLine}alignLinePointsInMove(e,n){return S.dealWithEndPolyPoints(e,n.gmlRender.getScale(),!0)}alignLinePointsInUp(e,n){return S.dealWithEndPolyPointsInUp(e,n.gmlRender.getScale(),!0)}}class dc extends ht{constructor(){super(...arguments);p(this,"startConnectInfo",{point:new P});p(this,"target",null);p(this,"shapeType",he.Line);p(this,"currentHandler",null);p(this,"handlers",[new es,new ts,new ns])}selectHandler(){for(const e of this.handlers)if(e.enable(this.shapeType)){this.currentHandler=e;return}throw new Error("类型错误:没有合适的handler处理")}onStart(e,n){this.startConnectInfo.point=e.globalPoint,this.shapeType=n.toolManager.shapeType,this.selectHandler();const o=n.detect(F.HoverOnContainer,e);let s=n.nodeManager.root;o&&(s=o);const r=this.currentHandler.computeDownProps(this.startConnectInfo,n,e,s),i=n.idGenerator.genId(v.Line),a={id:i,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:s.id,props:r};n.actionManager.execAction(new W);const c=Le.create(a);n.actionManager.execAction(c),this.target=n.nodeManager.nodeMap.get(i),n.actionManager.execAction(xe.create([this.target.id]))}onMove(e,n){this.currentHandler.computeMoveProps(this.startConnectInfo,e,n,this.target)}onUp(e,n){this.currentHandler.computeUpProps(this.startConnectInfo,e,n,this.target),n.execAction(new z),n.setCursor("default"),n.toolManager.resetTool()}}class uc extends dt{constructor(){super([new dc],[new $o,new jo,new Vo])}streamEnable(t,e){return e.toolManager.currentTool==ye.LINE}}class df extends qe{constructor(){super(...arguments);p(this,"handlers",[new es,new ts,new ns])}enable(e,n){return!n.toolManager.creatingLine}handle(e,n){const o=n.idGenerator.genId(v.Line),s=this.makeupLineProps(e,n);if(!s)return;const r={id:o,type:v.Line,zIndex:ve.genZIndex(n.nodeManager.root),parentId:"",props:s};n.actionManager.execAction(new W);const i=Le.create(r);n.actionManager.execAction(i);const a=n.nodeManager.getNode(o);n.toolManager.setInCreatingLine(a)}makeupLineProps(e,n){const o={point:e.globalPoint},r=n.detect(F.HoverOnContainer,e)??n.nodeManager.root;for(const i of this.handlers)if(i.enable(n.toolManager.shapeType))return i.computeDownProps(o,n,e,r);return null}}class uf extends qe{constructor(){super(...arguments);p(this,"handlers",[new es,new ts,new ns])}enable(e,n){return n.previewManager.resetPreviewNode(n),n.auxiliaryManager.removeAlignGraphics(),!!n.toolManager.creatingLine}handle(e,n){const o=n.toolManager.creatingLine,s=this.getStartConnectInfo(o,n);for(const r of this.handlers)r.enable(o.shapeType)&&r.computeUpProps(s,e,n,o);n.execAction(new z),n.toolManager.setInCreatingLine(null),n.toolManager.resetTool(),n.setCursor("default")}getStartConnectInfo(e,n){const o=e.points,{start:s}=e.connectProps,r={point:o[0]};if(s){const i=n.nodeManager.getNode(s.objectId);i&&(r.nodeConnect={endType:S.computeNodeConnectEnd(s,i.baseProps.angle),rect:D.rectNode2Rect(i.getBounds())})}return r}}class pf extends jt{constructor(){super(),this.registerDownHandler(new uf),this.registerUpHandler(new df)}}class ff extends un{constructor(){super([new pf])}clickEnable(t,e){return e.toolManager.currentTool===ye.LINE}}class gf{constructor(){p(this,"allowEventTypeSet",new Set([be.pointermove]));p(this,"handlers",[new es,new ts,new ns])}process(t,e){const n=e.toolManager.creatingLine;if(!n)return;const o=this.getStartConnectInfo(n,e);for(const s of this.handlers)s.enable(n.shapeType)&&s.computeMoveProps(o,t,e,n)}getStartConnectInfo(t,e){const n=t.points,{start:o}=t.connectProps,s={point:n[0]};if(o){const r=e.nodeManager.getNode(o.objectId);r&&(s.nodeConnect={endType:S.computeNodeConnectEnd(o,r.baseProps.angle),rect:D.rectNode2Rect(r.getBounds())})}return s}}const yf=new Set([ye.LINE]);class xf extends pn{constructor(){super([new ff,new uc,new ic([new ac,new $o,new jo,new Vo,new gf,new cc,new lc])])}canBeEnable(t,e){return yf.has(e.toolManager.currentTool)}}class wf extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.shapeType!==he.Curve)return!1;const r=e.gmlRender.getScale(),i=S.computeBezierCurves(s);let a=0;for(const c of i){const h=c.getHalfTPos();if(S.circleContains(h,t.globalPoint,8/r))return this.result={line:s,midPoint:new P(h.x,h.y),lPoint:c.p0,rPoint:c.p3,curve:c,index:a},!0;a=a+3}return!1}}class Pf extends Ke{onDetect(t,e){const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.shapeType!==he.Curve)return!1;const r=e.gmlRender.getScale(),i=S.computeBezierCurves(s);let a=0;for(const c of i){const h=[c.p0,c.p3];let d=0;for(const u of h){if(S.circleContains(u,t.globalPoint,8/r))return this.result={line:s,index:a+d},!0;d=d+3}a+=3}return!1}}class mf extends Ke{onDetect(t,e){if(e.inputManager.editTextInfo)return!1;const n=e.auxiliaryManager.selectManager.selectNodes;if(n.size!==1)return!1;const o=[...n][0];if(o.type!==v.Line)return!1;const s=o;if(s.renderText.isEmptyText())return!1;const r=s.toLocal(t.globalPoint),i=s.getTextContentRect();return S.rectContains(r,i)?(this.result={line:s},!0):!1}}class bf extends Ot{constructor(){super([])}canBeEnable(t,e){return!0}canBeExit(t,e){return!0}}class Sf extends pn{constructor(){super([new bf])}canBeEnable(t,e){return e.docState.docMode===ue.SLIDE_PLAY}}class Mf extends Ke{onDetect(t,e){var u;const n=[...e.getSelectNodes()];if(n.length!==1)return!1;const o=n[0];if(((u=o.parent)==null?void 0:u.type)!==v.SlideContainer||e.docState.docMode===ue.SLIDE_EDIT)return!1;const r=o.parent,i=this.getRowColIndex(r,o.id);if(!i)return!1;const{x:a,y:c,height:h,width:d}=o.globalBaseProps;return S.rectContains(t.globalPoint,new D(a-nt,c,nt,h))?(this.result={slideContainer:r,i:i.i,j:i.j,point:{x:a-nt/2,y:c+h/2}},!0):S.rectContains(t.globalPoint,new D(a+d,c,nt,h))?(this.result={slideContainer:r,i:i.i,j:i.j+1,point:{x:a+d+nt/2,y:c+h/2}},!0):!1}getRowColIndex(t,e){const n=t.slideProps.children;let o=0,s=0;for(const r of n){s=0;for(const i of r.ids){if(e===i)return{i:o,j:s};s++}o++}return null}}class vf extends Ke{onDetect(t,e){const n=e.detect(F.Node,t);if(!n)return!1;const o=n[0];if(o.type!==v.SlideContainer||!e.auxiliaryManager.selectManager.include(o))return!1;const s=o;if(s.slideProps.children.length!==0)return!1;const{x:i,y:a,height:c,width:h}=o.globalBaseProps,d=new D(i+nt,a+xt,h-2*nt,c-2*xt);return S.rectContains(t.globalPoint,d)?(this.result={slideContainer:s,rect:d},!0):!1}getRowColIndex(t,e){const n=t.slideProps.children;let o=0,s=0;for(const r of n){s=0;for(const i of r.ids){if(e===i)return{i:o,j:s};s++}o++}return null}}class hr extends na{constructor(){super(...arguments);p(this,"detectors",new Map([[F.Node,new oa],[F.HoverNode,new sa],[F.PolyControlPoint,new hc],[F.CurveControlPoint,new wf],[F.Rotate,new Jo],[F.Stretch,new Fo],[F.ExpandShape,new ec],[F.LineEndPoint,new tc],[F.NodeEdge,new dp],[F.BufferNode,new Cp],[F.BufferHoverNode,new Ap],[F.HoverNodeAnchor,new kp],[F.HoverConnectAnchor,new Rp],[F.HoverOnContainer,new Hp],[F.Image,new Up],[F.ImageOriginBounds,new hf],[F.CurveEndPoint,new Pf],[F.DragLineText,new mf],[F.SlideGap,new Mf],[F.EmptySlideContainer,new vf]]));p(this,"modes",[new Sf,new Vp,new Gp,new lf,new xf,new Lp,new Ja])}}const If={[K.Ellipse]:"#F2F3F5",[K.Hexagon]:"#F2F3F5",[K.Cloud]:"#F2F3F5",[K.YuanZhu]:"#F0FBEF",[K.Parallelogram]:"#F0FBEF",[K.Trapezoid]:"#E1EAFF",[K.Triangle]:"#E1EAFF",[K.Triangle2]:"#E1EAFF",[K.RightArrow]:"#E1EAFF",[K.DoubleArrow]:"#E1EAFF",[K.LeftArrow]:"#E1EAFF",[K.RoundRect]:"#E0E2FA",[K.RoundRect2]:"#E0E2FA",[K.Rect]:"#E0E2FA",[K.LiuCheng]:"#E0E2FA",[K.LiuCheng2]:"#E0E2FA",[K.Diamond]:"#FEEAD2",[K.Star]:"#FEEAD2",[K.Qipao]:"#FEF1F1",[K.Qipao2]:"#FEF1F1",[K.RightKuohao]:"#FEF1F1",[K.LeftKuohao]:"#FEF1F1"},Tf={[K.Ellipse]:"#DEE0E3",[K.Hexagon]:"#DEE0E3",[K.Cloud]:"#DEE0E3",[K.YuanZhu]:"#8EE085",[K.Parallelogram]:"#8EE085",[K.Trapezoid]:"#82A7FC",[K.Triangle]:"#82A7FC",[K.Triangle2]:"#82A7FC",[K.RightArrow]:"#82A7FC",[K.DoubleArrow]:"#82A7FC",[K.LeftArrow]:"#82A7FC",[K.RoundRect]:"#7B83EA",[K.RoundRect2]:"#7B83EA",[K.Rect]:"#7B83EA",[K.LiuCheng]:"#7B83EA",[K.LiuCheng2]:"#7B83EA",[K.Diamond]:"#FFBA6B",[K.Star]:"#FFBA6B",[K.Qipao]:"#F98E8B",[K.Qipao2]:"#F98E8B",[K.RightKuohao]:"#F98E8B",[K.LeftKuohao]:"#F98E8B"},Lf=(l,{x:t,y:e,width:n,height:o})=>l.x>=t&&l.x<=t+n&&l.y>=e&&l.y<=e+o;class Vt extends Fs{enable(t){return t.isPolyLine()}layoutToPoints(t,e){const n=t.lineProps,{start:o,end:s}=t.connectProps,r=[...t.globalLinePoints];if(!n.auto&&r.length>2){if(o){const c=r[0],h=r[1],d=S.judgeHorizon(c,h),u=e.nodeManager.getNode(o.objectId);if(u){const f=this.getNodePos(u,o);c.x=f.x,c.y=f.y}d?h.y=c.y:h.x=c.x}if(s){const c=r[r.length-2],h=r[r.length-1],d=S.judgeHorizon(c,h),u=e.nodeManager.getNode(s.objectId);if(u){const f=this.getNodePos(u,s);h.x=f.x,h.y=f.y}d?c.y=h.y:c.x=h.x}const i=t.globalTransform().inverseMatrix();return r.map(c=>i.crossPoint(c))}else{const i=this.getLayoutHandler(t,o,e),a=this.computeLayout(i,t,s,e),c=t.globalTransform().inverseMatrix();return a.map(d=>c.crossPoint(d))}}layoutToPointsPro(t,e){const n=this.getLayoutHandlerV2(t);return this.computePointsV2(n,e)}getLayoutHandlerV2({point:t,nodeConnect:e}){if(!e)return new _i(t);const{rect:n,endType:o}=e;switch(o){case de.Top:return new zd(t,n);case de.Bottom:return new Wd(t,n);case de.Left:return new Fd(t,n);case de.Right:return new Yd(t,n);default:return new _i(t)}}computePointsV2(t,{point:e,nodeConnect:n}){if(!n)return t.toPoint(e);const{rect:o,endType:s}=n;switch(s){case de.Right:return t.right(e,o);case de.Left:return t.left(e,o);case de.Bottom:return t.bottom(e,o);case de.Top:return t.top(e,o);default:return t.toPoint(e)}}getLayoutHandler(t,e,n){const o={point:t.globalLinePoints[0]};if(e){const s=n.nodeManager.getNode(e.objectId);s&&(o.nodeConnect={rect:D.rectNode2Rect(s.getBounds()),endType:S.computeNodeConnectEnd(e,s.baseProps.angle)},o.point=this.getNodePos(s,e))}return this.getLayoutHandlerV2(o)}computeLayout(t,e,n,o){const s=Ze.computeConnectInfo(e,n,o,!0);return this.computePointsV2(t,s)}}class Cf{constructor(){p(this,"workerMap",new Map)}init(t){this.workerMap.clear();for(const e of t){const n=new _n;n.init(e),this.workerMap.set(e,n)}}work(t,e,n){for(const o of t){const s=this.workerMap.get(o);s&&s.work(o,e,n)}}}class Rn{constructor(){p(this,"handlers",[new Xo,new uo,new Vt]);p(this,"batchLineTextWorker",new Cf)}work(t,e,n){this.batchLineTextWorker.init(t);for(const o of t)this.handleAndMsg(o,e,n);this.batchLineTextWorker.work(t,e,n)}layoutToPoints(t,e){for(const n of this.handlers)if(n.enable(t))return n.layoutToPoints(t,e);return[]}handleAndMsg(t,e,n){for(const o of this.handlers)if(o.enable(t)){const s=o.handle(t,e);e.execAction(new U(s,{streaming:n}));return}}batchCollectNodeLinks(t,e,n){const o=new Set(t);for(const s of t)this.collectNodeLinks(s,e,n,o)}collectNodeLinks(t,e,n,o=new Set){const s=e.nodeManager.getNodeLinks(t);for(const r of s){const{start:i,end:a}=r.connectProps;S.judgeEndNode(r,n,i,e,o),S.judgeEndNode(r,n,a,e,o)}for(const r of t.children){if(r.type===v.Line){const i=r,{start:a,end:c}=i.connectProps;S.judgeEndNode(i,n,a,e,o),S.judgeEndNode(i,n,c,e,o)}this.collectNodeLinks(r,e,n,o)}}judgeEndNode(t,e,n,o,s){if(!n)return;const r=o.nodeManager.getNode(n.objectId);r&&!S.judgeParentInset(r,s)&&e.add(t)}}class Af{constructor(){p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on)}work(t,e,n){let o=!1;if(this.groupBaseWorker.start([e]),t.textProps.sizeMode===We.autoWidth){const s=e.getTextContentRect(),{width:r,height:i}=e.baseProps,a=r-s.width,c=t.height+(i-s.height)+.2;n.execAction(U.create(e.id,[{type:I.Base,width:t.width+a,height:c}])),o=!0}else if(t.textProps.sizeMode===We.autoHeight&&e instanceof vt){let s=e.drawer.fullTextNodeHeight(e);s<100&&(s=100),n.execAction(U.create(e.id,[{type:I.Base,height:s}])),o=!0}if(o){const s=new Set;this.groupBaseWorker.work(n,!1),this.layoutWorker.collectNodeLinks(e,n,s),this.layoutWorker.work([...s],n,!1)}}}class Nf{work(t,e,n){const o=e.lineTextRect,s=new P(o.point.x,o.point.y),r=t.width,i=t.height;n.execAction(U.create(e.id,[{type:I.LineTextRect,x:s.x-.5*r,y:s.y-.5*i,width:r,height:i}]))}}class wo{constructor(){p(this,"prevStringBuilder",{text:""});p(this,"nextStringBuilder",{text:""});p(this,"currentbuilder",this.prevStringBuilder);p(this,"layoutWorker",new Rn);p(this,"groupBaseWorker",new on);p(this,"nodeModifyBaseWorker",new Af);p(this,"lineModifyWorker",new Nf)}switchCurrentBuilder(t,e){return this.currentbuilder===this.nextStringBuilder?!1:t.equal(e)?(this.currentbuilder=this.nextStringBuilder,!0):!1}splitText(t,e){this.prevStringBuilder={text:""},this.nextStringBuilder={text:""},this.currentbuilder=this.prevStringBuilder;let n=-1,o=0;for(let s=0;s<t.paragraphs.length;s++){const r=t.paragraphs[s];for(let i=0;i<r.lines.length;i++){const a=r.lines[i];this.switchCurrentBuilder(e,new Fe(s,i,-1))&&(o=n);const h=a.getCharLength();for(let d=0;d<h;d++){const{character:u}=a.getCharacter(d);this.currentbuilder.text+=u.charText,n++,this.switchCurrentBuilder(e,new Fe(s,i,d))&&(o=n)}}s<t.paragraphs.length-1&&(this.currentbuilder.text+=`
5
+ `,n++)}return{prev:this.prevStringBuilder.text,next:this.nextStringBuilder.text,index:o}}editText(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,i=t.prevParagraphToXML(o),a=t.nextParagraphToXML(o),c=t.getParagraph(o),h=c.prevToRichTextXML(s,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(s),f=u.getBlockIndex(r);if(f){const{textBlock:g,blockIndex:y,charIndex:m}=f,b=u.prevToRichTextXML(y,t.textProps),w=u.nextToRichTextXML(y,t.textProps),L=g.insertTextToRichTextXML(n,m,t.textProps);return`<root>${i}<p>${h}${b}${L}${w}${d}</p>${a}</root>`}return`<root>${i}<p>${h}${n}${d}</p>${a}</root>`}modifyBaseProps(t,e,n){e.type===v.Shape?this.nodeModifyBaseWorker.work(t,e,n):e.type===v.Line&&this.lineModifyWorker.work(t,e,n)}}class kf{measure(t,e,n){const o=[];t.font=S.calcFontByTextProps(n);for(const s of e){const r=new Ui;for(const i of[...s]){const{width:a,height:c,boxAscent:h}=S.measureText(t,i),d=new As(i,0,0,a,c,h);r.addCharacter(d)}o.push(r)}return o}}class pc{constructor(){p(this,"streaming",!1)}}class gn{constructor(t,e){p(this,"meta",new pc);p(this,"data");p(this,"reverseLog",null);this.data=t,e&&(this.meta=e)}reverse(){if(this.reverseLog===null)throw new Error("缺少对应逆消息");return this.reverseLog}}var Lt=(l=>(l[l.Focus=0]="Focus",l[l.Selection=1]="Selection",l[l.Blur=2]="Blur",l[l.Empty=3]="Empty",l))(Lt||{});class ee extends gn{constructor(){super(...arguments);p(this,"type",Xe.TextFocus)}static focus(e,n=Fe.head()){return new ee({focusType:Lt.Focus,focus:{id:e,textCursorPosition:n}})}static selection(e,n,o){return new ee({focusType:Lt.Selection,selection:{id:e,start:n,end:o}})}static blur(e){return new ee({blur:{id:e},focusType:Lt.Blur})}static empty(){return new ee({focusType:Lt.Empty})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new ee(e,this.meta)}}class fc{constructor(){p(this,"cursorMoveWorker",new lo)}work(t,e,n=1){const{node:o,renderText:s,textCursorPosition:r}=t,{updateTextProps:i}=this.computeUpdateTextProps(t,n);let a=r;for(let c=0;c<n;c++)a=this.cursorMoveWorker.moveLeft(s,a);e.execAction(new W),e.execAction(U.create(o.id,[i])),e.execAction(ee.focus(o.id,a)),e.execAction(new z)}computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.deleteText(n,o,e);return{updateTextProps:{type:I.Text,richText:s}}}deleteText(t,e,n){if(n<=0)return t.toRichTextXML();const o=t.prevCursorPos(e,n),s=e;return this.deleteTextByCursorPos(t,o,s)}deleteTextByCursorPos(t,e,n){return e.equal(n)?t.toRichTextXML():this.generateDeletedXML(t,e,n)}generateDeletedXML(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,{paragraphIndex:i,lineIndex:a,charIndex:c}=n;return o===i?this.deleteSameParagraph(t,o,s,r,a,c):this.deleteCrossParagraph(t,o,s,r,i,a,c)}deleteSameParagraph(t,e,n,o,s,r){const i=t.prevParagraphToXML(e),a=t.nextParagraphToXML(e),c=t.getParagraph(e);if(n===s){const se=c.prevToRichTextXML(n,t.textProps),ne=c.nextToRichTextXML(s,t.textProps),ae=c.getLine(n),te=ae.getBlockIndex(o),ce=ae.getBlockIndex(r);if(!te||!ce)return`<root>${i}<p>${se}${ne}</p>${a}</root>`;const{blockIndex:pe,charIndex:Be}=te,{blockIndex:Re,charIndex:Se}=ce;if(pe===Re){const Ft=ae.prevToRichTextXML(pe,t.textProps),cn=ae.nextToRichTextXML(Re,t.textProps),On=te.textBlock,$e=On.getPrevText(Be),qn=On.getNextText(Se),Jn=$e+qn,Yt=`<style ${On.computeStyle(t.textProps)}>${Jn}</style>`;return`<root>${i}<p>${se}${Ft}${Yt}${cn}${ne}</p>${a}</root>`}const Te=ae.prevToRichTextXML(pe,t.textProps),fe=ae.nextToRichTextXML(Re,t.textProps),O=te.textBlock,G=ce.textBlock,j=O.getPrevText(Be),_=O.computeStyle(t.textProps),Ve=j?`<style ${_}>${j}</style>`:"",ut=G.getNextText(Se),yt=G.computeStyle(t.textProps),kt=ut?`<style ${yt}>${ut}</style>`:"";return`<root>${i}<p>${se}${Te}${Ve}${kt}${fe}${ne}</p>${a}</root>`}const h=c.prevToRichTextXML(n,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(n),f=c.getLine(s),g=u.getBlockIndex(o),y=f.getBlockIndex(r);if(!g||!y)return`<root>${i}<p>${h}${d}</p>${a}</root>`;const m=u.prevToRichTextXML(g.blockIndex,t.textProps),b=g.textBlock,w=b.getPrevText(g.charIndex),L=b.computeStyle(t.textProps),B=w?`<style ${L}>${w}</style>`:"",H=f.nextToRichTextXML(y.blockIndex,t.textProps),E=y.textBlock,X=E.getNextText(y.charIndex),$=E.computeStyle(t.textProps),Z=X?`<style ${$}>${X}</style>`:"";return`<root>${i}<p>${h}${m}${B}${Z}${H}${d}</p>${a}</root>`}deleteCrossParagraph(t,e,n,o,s,r,i){const a=t.prevParagraphToXML(e),c=t.nextParagraphToXML(s),h=t.getParagraph(e),d=t.getParagraph(s),u=h.prevToRichTextXML(n,t.textProps),f=h.getLine(n),g=f.getBlockIndex(o);let y="";if(g){const B=f.prevToRichTextXML(g.blockIndex,t.textProps),H=g.textBlock,E=H.getPrevText(g.charIndex),X=H.computeStyle(t.textProps),$=E?`<style ${X}>${E}</style>`:"";y=`${B}${$}`}const m=d.nextToRichTextXML(r,t.textProps),b=d.getLine(r),w=b.getBlockIndex(i);let L="";if(w){const B=b.nextToRichTextXML(w.blockIndex,t.textProps),H=w.textBlock,E=H.getNextText(w.charIndex),X=H.computeStyle(t.textProps);L=`${E?`<style ${X}>${E}</style>`:""}${B}`}return`<root>${a}<p>${u}${y}${L}${m}</p>${c}</root>`}}class os{constructor(){p(this,"deleteInputWorker",new fc)}work(t,e,n){n.execAction(ee.selection(t.node.id,e.start,e.end));const{node:o,renderText:s}=t,r=e.start;n.execAction(ee.focus(o.id,r));const i=this.deleteInputWorker.deleteTextByCursorPos(s,e.start,e.end),a={type:I.Text,richText:i};n.execAction(U.create(o.id,[a])),n.execAction(ee.focus(o.id,r))}}class ss{}class dr extends ss{enable(t,e){return t.paragraphIndex===e.paragraphIndex&&t.lineIndex===e.lineIndex}handle(t,e,n){const o=t.paragraphs[e.paragraphIndex],s=o.lines[e.lineIndex],r=s.getCharacter(n.charIndex);let i=0,a=0;if(e.charIndex>-1){const h=s.getCharacter(e.charIndex);i=h.textBlock.x+h.character.x+h.character.width,a=h.character.y}const c=new D(i,a,r.textBlock.x+r.character.x+r.character.width-i,s.height);return c.x+=s.x+o.x+t.x,c.y+=s.y+o.y+t.y,[c]}}class ur extends ss{enable(t,e){return t.paragraphIndex===e.paragraphIndex&&t.lineIndex!==e.lineIndex}handle(t,e,n){const o=[],s=t.paragraphs[e.paragraphIndex],r=s.lines[e.lineIndex],i=s.lines[n.lineIndex];let a=0,c=0;const h=r.getCharacter(e.charIndex);a=h===null?0:h.textBlock.x+h.character.x+h.character.width,c=h===null?0:h.character.y;const d=r.width-a;if(a+=r.x+s.x+t.x,c+=r.y+s.y+t.y,o.push(new D(a,c,d,r.height)),e.lineIndex+1===n.lineIndex&&n.charIndex===-1)return o;for(let f=e.lineIndex+1;f<n.lineIndex;f++){const g=s.lines[f];a=g.x+s.x+t.x,c=g.y+s.y+t.y,o.push(new D(a,c,g.width,g.height))}const u=i.getCharacter(n.charIndex);return u&&(a=i.x+s.x+t.x,c=i.y+s.y+t.y,o.push(new D(a,c,u.textBlock.x+u.character.x+u.character.width,i.height))),o}}class gc extends ss{constructor(){super(...arguments);p(this,"handlers",[new dr,new ur])}enable(e,n){return e.paragraphIndex!==n.paragraphIndex}handleSamePara(e,n,o){for(const s of this.handlers)if(s.enable(n,o))return s.handle(e,n,o);return[]}handle(e,n,o){const s=[],r=e.paragraphs[n.paragraphIndex],i=e.paragraphs[o.paragraphIndex],a=this.handleSamePara(e,n,r.tailCursorPosition());s.push(...a);for(let h=n.paragraphIndex+1;h<o.paragraphIndex;h++){const d=e.paragraphs[h];for(const u of d.lines)s.push(new D(e.x+d.x+u.x,e.y+d.y+u.y,u.width,u.height))}const c=this.handleSamePara(e,i.headCursorPosition(),o);return s.push(...c),s}}class yc{constructor(){p(this,"handlers",[new dr,new ur,new gc])}handleTextSelection(t,e,n){for(const o of this.handlers)if(o.enable(e,n))return o.handle(t,e,n);return[]}computeTextSelection(t,e,n){return e.equal(n)?[]:this.handleTextSelection(t,e,n)}}class xc{constructor(){p(this,"segmentWorker",new Intl.Segmenter("en",{granularity:"word"}))}split(t){return Array.from(this.segmentWorker.segment(t)).map(n=>n.segment)}}const Bf=new xc,He=16,Ne=16,wc=[{x:0,y:0},{x:He,y:0},{x:He,y:Ne},{x:0,y:Ne}];class En{}class Rf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(He,.5*Ne),t.moveTo(.5*He,0),t.lineTo(He,.5*Ne),t.lineTo(.5*He,Ne),t.stroke()}}class Ef extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.5*Ne),t.stroke(),t.beginPath(),t.moveTo(.5*He,0),t.lineTo(He,.5*Ne),t.lineTo(.5*He,Ne),t.closePath(),t.fill(),t.stroke()}}class Hf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.5*Ne),t.stroke(),t.beginPath(),t.moveTo(.5*He,0),t.lineTo(He,.5*Ne),t.lineTo(.5*He,Ne),t.closePath(),t.stroke()}}class Df extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.3*Ne),t.lineTo(He,.5*Ne),t.lineTo(.5*He,.7*Ne),t.closePath(),t.fill()}}class Of extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha,t.moveTo(0,.5*Ne),t.lineTo(.5*He,.3*Ne),t.lineTo(He,.5*Ne),t.lineTo(.5*He,.7*Ne),t.closePath(),t.stroke()}}class Xf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.fillStyle=n.color,t.strokeStyle=n.color,t.lineWidth=n.width,t.globalAlpha=n.alpha;const o=Math.min(He,Ne)*.3;t.moveTo(0,.5*Ne),t.lineTo(He-o,.5*Ne),t.stroke(),t.beginPath();const s=He,r=.5*Ne;t.arc(s,r,o,0,2*Math.PI),t.fill(),t.stroke()}}class zf extends En{drawOnGLCtx(t,e){const n=e.borderProps;t.strokeStyle=n.color,t.lineWidth=2,t.globalAlpha=n.alpha;const o=Math.min(He,Ne)*.3;t.moveTo(0,.5*Ne),t.lineTo(He-o,.5*Ne),t.stroke(),t.beginPath();const s=He,r=.5*Ne;t.arc(s,r,o,0,2*Math.PI),t.stroke()}}const wn=class wn extends en{constructor(e,n){super(e,n);p(this,"type",v.Line);p(this,"renderText");p(this,"inEditing",!1);p(this,"rArrowMatrix",re.generateMatrix());p(this,"lArrowMatrix",re.generateMatrix());this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Shape,new Oe),this.props.set(I.Line,new je),this.props.set(I.Arrow,new lt),this.props.set(I.Connect,new Rt),this.props.set(I.Text,Ge.create({sizeMode:We.autoWidth})),this.props.set(I.LineTextRect,new Et),this.props.set(I.TextParagraph,new qt),this.props.set(I.TextParagraphQuote,new Dt),this.renderText=new ho}get globalPos(){const e=this.pos;return this.globalTransform().crossPoint(e)}get borderProps(){return this.props.get(I.Border)}get textProps(){return this.props.get(I.Text)}get paragraphProps(){return this.props.get(I.TextParagraph)}get paragraphQuoteProps(){return this.props.get(I.TextParagraphQuote)}get arrowProps(){return this.props.get(I.Arrow)}get shapeType(){return this.props.get(I.Shape).shapeCode}get lineProps(){return this.props.get(I.Line)}get globalLinePoints(){const e=this.lineProps.points,n=this.globalTransform();return e.map(s=>n.crossPoint(s))}get connectProps(){return this.props.get(I.Connect)}get points(){return this.lineProps.points}get lineTextRect(){return this.props.get(I.LineTextRect)}get drawer(){const e=this.shapeType;let n=wn.drawerMap.get(e);return n||(console.error("取不到drawer,使用line兜底!"),n=wn.drawerMap.get(he.Line)),n}canBeConnected(){return!1}getStretchMinSize(){return new P(10,10)}drawWithTextClip(e){const o=this.getTextContentRect();o.x-=2,o.y-=2,o.width+=2*2,o.height+=2*2;const s=D.rectNode2Rect(this.getRectNode());let r=new P(s.x,s.y);r=this.toLocal(r),e.save(),e.beginPath(),e.rect(r.x,r.y,s.width,s.height),e.rect(o.x,o.y,o.width,o.height),e.clip("evenodd"),this.drawCore(e),e.restore()}drawCore(e){const n=this.borderProps;S.setDashLine(n,e),e.save(),e.strokeStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=n.width,this.drawer.draw(this,e),e.restore(),e.beginPath(),this.drawArrow(e)}drawOnGLCtx(e){const n=!this.isEmptyText()||this.inEditing;e.save();const{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();e.transform(o,s,r,i,a,c),n?this.drawWithTextClip(e):this.drawCore(e),this.drawText(e),e.restore()}drawText(e){const{alpha:n}=this.borderProps;e.save(),e.beginPath();const o=new P;this.renderText.draw(e,o,n),e.restore()}isEmptyText(){return this.renderText.isEmptyText()}updateProps(e){super.updateProps(e),this.updateLArrowMatrix(),this.updateRArrowMatrix();const n=e.find(c=>c.type===I.Text),o=e.find(c=>c.type===I.Base),s=e.find(c=>c.type===I.Line),r=e.find(c=>c.type===I.LineTextRect),i=e.find(c=>c.type===I.TextParagraph),a=e.find(c=>c.type===I.TextParagraphQuote);if(n||o||s||r||i||a){const c=this.getTextContentRect();this.renderText.typesetting(this.graphicContext,this.textProps,c,this.paragraphProps,this.paragraphQuoteProps)}}getArrowDrawer(e){const n=wn.arrowDrawerMap.get(e);return n||null}draw(){this.drawOnGLCtx(this.graphicContext)}getBounds(){const e=[...this.points],n=this.globalTransform(),o=e.map(r=>n.crossPoint(r));return S.getBoundsByPoints(o)}getRectNode(){const e=[...this.points],{lArrow:n,rArrow:o}=this.arrowProps;if(n)for(const c of wc)e.push(this.lArrowMatrix.crossPoint(c));if(o)for(const c of wc)e.push(this.rArrowMatrix.crossPoint(c));const s=this.globalTransform(),r=e.map(c=>s.crossPoint(c)),i=S.getBoundsByPoints(r),a=this.borderProps;return i.minX=i.minX-a.width,i.minY=i.minY-a.width,i.maxX=i.maxX+2*a.width,i.maxY=i.maxY+2*a.width,i.id=this.id,i}updateRArrowMatrix(){const{rArrow:e}=this.arrowProps;if(!e)return;const n=this.points,o=n[n.length-1],s=new P(He,.5*Ne);let r=0;if(this.isPolyLine()){const u=n[n.length-2],f=o;S.judgeHorizon(u,f)?r=f.x>u.x?0:180:r=f.y>u.y?90:-90}else if(this.shapeType===he.Curve){const u=n[n.length-1],f=n[n.length-2],g=n[n.length-3];S.distance(u,f)>.1?r=S.lineAngle(f,u)/Math.PI*180:r=S.lineAngle(g,u)/Math.PI*180}else{const u=n[n.length-2];r=S.lineAngle(u,o)/Math.PI*180}const i=re.generateMatrix().translate(-.5*He,-.5*He),a=re.generateMatrix().rotate(r),c=i.crossProduct(a),h=c.crossPoint(s),d=re.generateMatrix().translate(o.x-h.x,o.y-h.y);this.rArrowMatrix=d.crossProduct(c)}updateLArrowMatrix(){const{lArrow:e}=this.arrowProps;if(!e)return;const n=this.points,o=n[0],s=new P(He,.5*Ne);let r=0;if(this.isPolyLine()){const u=o,f=n[1];S.judgeHorizon(u,f)?r=f.x>u.x?180:0:r=f.y>u.y?-90:90}else if(this.shapeType===he.Curve){const u=n[0],f=n[1],g=n[2];S.distance(u,f)>.1?r=S.lineAngle(f,u)/Math.PI*180:r=S.lineAngle(g,u)/Math.PI*180}else{const u=n[1];r=S.lineAngle(u,o)/Math.PI*180}const i=re.generateMatrix().translate(-.5*He,-.5*He),a=re.generateMatrix().rotate(r),c=i.crossProduct(a),h=c.crossPoint(s),d=re.generateMatrix().translate(o.x-h.x,o.y-h.y);this.lArrowMatrix=d.crossProduct(c)}drawArrow(e){if(this.points.length===0){console.error("line has no point!");return}const o=this.arrowProps;if(o.rArrow){const s=this.getArrowDrawer(o.rArrow);if(s){e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=this.rArrowMatrix;e.transform(r,i,a,c,h,d),s.drawOnGLCtx(e,this),e.restore()}}if(o.lArrow){const s=this.getArrowDrawer(o.lArrow);if(s){e.save();const{a:r,b:i,c:a,d:c,e:h,f:d}=this.lArrowMatrix;e.transform(r,i,a,c,h,d),s.drawOnGLCtx(e,this),e.restore()}}}getRArrowPoint(e,n,o=5){const s=S.distance(e,n),r=new P(s-Math.sqrt(3)*.5*o,.5*o),i=new P(s-Math.sqrt(3)*.5*o,-.5*o);return this.basicGetArrowPoint(e,n,r,i)}basicGetArrowPoint(e,n,o,s){const r=S.lineAngle(e,n),i=re.generateMatrix().translate(e.x,e.y).rotate2(r),a=i.crossPoint(o),c=i.crossPoint(s);return{a,b:c}}static load(e,n,o,s,r,i){const a=new wn(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}contains(e,n=1){const o=this.toLocal(e),s=this.getTextContentRect();if(S.rectContains(o,s))return!0;const r=8/n;return wi.lineContainsPoint(this,o,r)}overlapRect(e){const n=this.getBounds();return S.containRect(e,n)?!0:wi.overlapRectNode(this,e)}getTextContentRect(){const e=this.baseProps,{x:n,y:o,width:s,height:r}=this.lineTextRect;return new D(n+e.x,o+e.y,s,r)}isPolyLine(){const e=this.shapeType;return e===he.PolyLine||e===he.RoundPolyLine}modifyPosInEditing(){return this.inEditing=!0,!0}resetFromEditing(){this.inEditing=!1}getDrawPoints(){const{lArrow:e,rArrow:n}=this.arrowProps,o=[...this.points];if(e){const s=new P(0,.5*Ne),r=this.lArrowMatrix.crossPoint(s);o.shift(),o.unshift(r)}if(n){const s=new P(0,.5*Ne),r=this.rArrowMatrix.crossPoint(s);o.pop(),o.push(r)}return o}getLineLength(){const e=this.points;if(this.isPolyLine()){let s=0;for(let r=0;r<e.length-1;r++){const i=e[r],a=e[r+1],c=S.distance(i,a);s+=c}return s}if(this.shapeType===he.Curve){const s=S.computeBezierCurves(this);let r=0;for(const i of s){const a=i.getApproximateLength();r+=a}return r}const n=e[0],o=e[e.length-1];return S.distance(n,o)}};p(wn,"arrowDrawerMap",new Map([[it.Arrow,new Rf],[it.Triangle,new Ef],[it.EmptyTriangle,new Hf],[it.Diamond,new Df],[it.EmptyDiamond,new Of],[it.Circle,new Xf],[it.EmptyCircle,new zf]])),p(wn,"drawerMap",new Map([[he.Curve,new zh],[he.RoundPolyLine,new Wh],[he.PolyLine,new Xh],[he.Line,new Oh]]));let Ct=wn;class Pt{buildPath(t,e){}draw(t,e){const n=t.colorProps,o=t.borderProps;e.lineJoin="round",e.lineCap="round",this.buildPath(t,e),n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fill()),o.color!==""&&o.dashType!==et.None&&(S.setDashLine(o,e),e.strokeStyle=o.color,e.lineWidth=o.width,e.globalAlpha=o.alpha,e.stroke())}getTextPadding(t){const e=t.textProps.fontSize;return e>10?le:e<4?0:1}fullTextNodeHeight(t){const e=this.getTextPadding(t);return t.renderText.height+2*e}textContentBounds(t){const e=t.baseProps,n=this.getTextPadding(t);return{x:n,y:n,width:e.width-2*n+2,height:e.height-2*n}}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.rectangle({top:0,left:0,width:e,height:n})}borderContains(t,e,n){const o=this.nodeShapeInfo(t),s=q.line({x:e.x-n,y:e.y},{x:e.x+n,y:e.y}),r=q.line({x:e.x,y:e.y-n},{x:e.x,y:e.y+n});for(const i of[s,r]){const a=Y.intersect(o,i);if(a.points.length>0)return a.points[0]}return null}getConnectAnchor(){return[new P(.5,0),new P(1,.5),new P(.5,1),new P(0,.5)]}}class Wf extends Pt{draw(t,e){}textContentBounds(t){const e=t.baseProps,n=this.getTextPadding(t);return{x:n,y:n,width:e.width-2*n,height:e.height-2*n}}fullTextNodeHeight(t){const e=this.getTextPadding(t);return t.renderText.height+2*e}getTextPadding(t){const e=t.textProps.fontSize;return e>10?2:e<4?0:1}}class Ff extends Pt{draw(t,e){const n=t.colorProps,o=t.baseProps,s=t.borderProps;n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fillRect(0,0,o.width,o.height)),s.color!==""&&s.dashType!==et.None&&(S.setDashLine(s,e),e.strokeStyle=s.color,e.lineWidth=s.width,e.globalAlpha=s.alpha,e.strokeRect(0,0,o.width,o.height))}}class Yf extends Pt{textContentBounds(t){const e=t.baseProps,n=e.width/4,o=-e.height/(e.width/2),s=e.height,r=o*n+s,i={x:n,y:r,width:e.width/2,height:e.height-r};return{x:i.x+le,y:i.y+le,width:i.width-le*2,height:i.height-le*2}}fullTextNodeHeight(t){return(t.renderText.height+le)*2}draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(0,s),e.lineTo(.5*o,0),e.lineTo(o,s),e.closePath(),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(S.setDashLine(r,e),e.globalAlpha=r.alpha,e.strokeStyle=r.color,e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:n},{x:.5*e,y:0},{x:e,y:n}])}getConnectAnchor(){return[new P(.5,0),new P(.75,.5),new P(.5,1),new P(.25,.5)]}}class Gf extends Pt{draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(0,.5*s),e.lineTo(.5*o,0),e.lineTo(o,.5*s),e.lineTo(.5*o,s),e.closePath(),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(e.strokeStyle=r.color,e.globalAlpha=r.alpha,S.setDashLine(r,e),e.stroke())}fullTextNodeHeight(t){return(t.renderText.height+le)*2}textContentBounds(t){const e=t.baseProps,n={x:0,y:e.height/2},o={x:e.width/2,y:0},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.25*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height-a*2};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:.5*n},{x:.5*e,y:0},{x:e,y:.5*n},{x:.5*e,y:n}])}}class Uf extends Pt{draw(t,e){const n=t.baseProps,o=t.colorProps,s=t.borderProps;e.beginPath(),e.fillStyle=o.color,e.roundRect(0,0,n.width,n.height,10),o.color!==""&&(e.globalAlpha=o.alpha,e.fill()),s.color!==""&&s.dashType!==et.None&&Math.abs(s.alpha)>.001&&(e.strokeStyle=s.color,e.lineWidth=s.width,e.globalAlpha=s.alpha,S.setDashLine(s,e),e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.rectangle({top:0,left:0,width:e,height:n})}}class _f extends Pt{draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.fillStyle=n.color,e.globalAlpha=n.alpha,e.lineWidth=r.width,e.lineJoin="round",e.lineCap="round",e.beginPath(),e.ellipse(.5*o,.5*s,.5*o,.5*s,0,0,2*Math.PI,!1),n.color!==""&&e.fill(),r.color!==""&&r.dashType!==et.None&&Math.abs(r.alpha)>.001&&(e.strokeStyle=r.color,e.globalAlpha=r.alpha,S.setDashLine(r,e),e.stroke())}textContentBounds(t){const e=t.baseProps,n=e.width*Math.sqrt(2)/2,o=(e.width-n)/2,s=Math.max(e.width,e.height)/2,r=Math.min(e.width,e.height)/2,i=(1-(n/2)**2/s**2)*r**2,a={x:o,y:e.height/2-Math.sqrt(i),width:n,height:2*Math.sqrt(i)},c=this.getTextPadding(t);return{x:a.x+c,y:a.y+c,width:a.width-c*2,height:a.height-c*2}}fullTextNodeHeight(t){const e=this.getTextPadding(t);return(t.renderText.height+e)*2}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.ellipse({centerX:.5*e,centerY:.5*n,radiusX:.5*e,radiusY:.5*n})}}class $f extends Pt{textContentBounds(t){const e=t.baseProps;return{x:.16*e.width+le,y:le,width:(1-.16*2)*e.width-2*le,height:e.height-2*le}}buildPath(t,e){const n=t.baseProps;e.beginPath(),e.moveTo(.16*n.width,0),e.lineTo(n.width,0),e.lineTo(.84*n.width,n.height),e.lineTo(0,n.height),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.16*e,y:0},{x:e,y:0},{x:.84*e,y:n},{x:0,y:n}])}getConnectAnchor(){return[new P(.5,0),new P(.92,.5),new P(.5,1),new P(.08,.5)]}}class jf extends Pt{textContentBounds(t){const e=t.baseProps;return{x:.2*e.width,y:le,width:.6*e.width,height:e.height-2*le}}draw(t,e){const n=t.colorProps,{width:o,height:s}=t.baseProps,r=t.borderProps;e.lineJoin="round",e.lineCap="round",e.beginPath(),e.moveTo(.2*o,0),e.lineTo(.8*o,0),e.lineTo(o,s),e.lineTo(0,s),e.closePath(),n.color!==""&&(e.fillStyle=n.color,e.globalAlpha=n.alpha,e.fill()),r.color!==""&&r.dashType!==et.None&&(S.setDashLine(r,e),e.strokeStyle=r.color,e.lineWidth=r.width,e.globalAlpha=r.alpha,e.stroke())}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.2*e,y:0},{x:.8*e,y:0},{x:e,y:n},{x:0,y:n}])}getConnectAnchor(){return[new P(.5,0),new P(.9,.5),new P(.5,1),new P(.1,.5)]}}class Vf extends Pt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.5*n,0),e.lineTo(n,.38196601125010515*o),e.lineTo(.8090169943749473*n,o),e.lineTo(.1909830056250526*n,o),e.lineTo(0,.381966011250105*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.5*e,y:0},{x:e,y:.38196601125010515*n},{x:.8090169943749473*e,y:n},{x:.1909830056250526*e,y:n},{x:0,y:.381966011250105*n}])}textContentBounds(t){const e=t.baseProps,n={x:0,y:e.height*.38196601125010515},o={x:e.width/2,y:0},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.1909830056250526*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height-a};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}fullTextNodeHeight(t){const e=t.renderText.height,n=t.baseProps,o={x:0,y:n.height*.38196601125010515},s={x:n.width/2,y:0},r=(o.y-s.y)/(o.x-s.x),i=o.y,a=.1909830056250526*n.width,c=r*a+i;return e+2*le+c}getConnectAnchor(){return super.getConnectAnchor()}}class Kf extends Pt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(n,.5*o),e.lineTo(.75*n,o),e.lineTo(.25*n,o),e.lineTo(0,.5*o),e.lineTo(.25*n,0),e.lineTo(.75*n,0),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:e,y:.5*n},{x:.75*e,y:n},{x:.25*e,y:n},{x:0,y:.5*n},{x:.25*e,y:0},{x:.75*e,y:0}])}textContentBounds(t){const e=t.baseProps;return{x:.25*e.width+le,y:le,width:.5*e.width-2*le,height:e.height-2*le}}getConnectAnchor(){return super.getConnectAnchor()}}class Qf extends Pt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.7071067811865476*n,0),e.lineTo(n,.2928932188134524*o),e.lineTo(n,.7071067811865476*o),e.lineTo(.7071067811865476*n,o),e.lineTo(.2928932188134525*n,o),e.lineTo(0,.7071067811865476*o),e.lineTo(0,.29289321881345254*o),e.lineTo(.29289321881345215*n,0),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.7071067811865476*e,y:0},{x:e,y:.2928932188134524*n},{x:e,y:.7071067811865476*n},{x:.7071067811865476*e,y:n},{x:.2928932188134525*e,y:n},{x:0,y:.7071067811865476*n},{x:0,y:.29289321881345254*n},{x:.29289321881345215*e,y:0}])}textContentBounds(t){const e=t.baseProps,n={x:.064625*e.width,y:.064625*e.height,width:e.width*(1-.064625*2),height:e.height*(1-.064625*2)};return{x:n.x+le,y:n.y+le,width:n.width-le*2,height:n.height-le*2}}fullTextNodeHeight(t){return(t.renderText.height+2*le)/(1-.064625*2)}getConnectAnchor(){return super.getConnectAnchor()}}const Zf="M19.1498 8.12942L18.9895 8.95084L19.7971 9.17031C21.3773 9.59972 22.4731 10.9487 22.4731 12.4833C22.4731 13.901 21.5408 15.1571 20.1512 15.6818L19.5155 15.9218L19.5722 16.5988C19.5788 16.6767 19.5821 16.7556 19.5821 16.8356C19.5821 18.3711 18.3424 19.6106 16.8195 19.6106C16.2161 19.6106 15.66 19.4173 15.206 19.0884L14.4417 18.5348L13.925 19.3244C13.4292 20.082 12.5786 20.5777 11.6143 20.5777C10.5661 20.5777 9.65135 19.9913 9.18244 19.1206L8.73358 18.2873L7.92388 18.7776C7.45803 19.0596 6.90757 19.2236 6.31413 19.2236C4.61055 19.2236 3.26243 17.8766 3.26243 16.2551C3.26243 15.774 3.37941 15.3216 3.58718 14.9209L4.05462 14.0194L3.1035 13.6636C2.19708 13.3246 1.52704 12.4149 1.52704 11.323C1.52704 9.96428 2.55686 8.90054 3.79171 8.84083L4.78871 8.79263L4.63791 7.80592C4.62047 7.69176 4.61134 7.57433 4.61134 7.45418C4.61134 6.18576 5.63529 5.16272 6.89198 5.16272C7.18142 5.16272 7.45628 5.21645 7.70869 5.31377L8.44216 5.59655L8.82102 4.90778C9.30983 4.01913 10.2497 3.42222 11.3256 3.42222C12.5174 3.42222 13.5428 4.15533 13.9715 5.20352L14.3964 6.24229L15.3181 5.60191C15.717 5.32477 16.1997 5.16272 16.7227 5.16272C18.0858 5.16272 19.1961 6.27235 19.1961 7.6476C19.1961 7.81325 19.1801 7.97425 19.1498 8.12942Z";class qf extends Pt{constructor(){super(...arguments);p(this,"path2D",new Path2D(Zf))}textContentBounds(e){const n=e.baseProps;return{x:.2*n.width,y:.2*n.height,width:.6*n.width,height:.6*n.height}}draw(e,n){const o=e.colorProps,s=e.borderProps,{width:r,height:i}=e.baseProps,a=new Path2D;a.addPath(this.path2D,new DOMMatrix().scale(r/24,i/24)),n.lineJoin="round",n.lineCap="round",o.color!==""&&(n.fillStyle=o.color,n.globalAlpha=o.alpha,n.fill(a)),s.color!==""&&s.dashType!==et.None&&(S.setDashLine(s,n),n.strokeStyle=s.color,n.lineWidth=s.width,n.globalAlpha=s.alpha,n.stroke(a))}borderContains(e,n,o){const{width:s,height:r}=e.baseProps,i=e.borderProps,a=new Path2D;a.addPath(this.path2D,new DOMMatrix().scale(s/24,r/24));const c=e.graphicContext;return c.lineWidth=i.width,c.isPointInStroke(a,n.x,n.y)?n:null}}const Ie=.3;class Jf extends Pt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(0,Ie*o),e.lineTo(Ie*n,Ie*o),e.lineTo(Ie*n,0),e.lineTo((1-Ie)*n,0),e.lineTo((1-Ie)*n,Ie*o),e.lineTo(n,Ie*o),e.lineTo(n,(1-Ie)*o),e.lineTo((1-Ie)*n,(1-Ie)*o),e.lineTo((1-Ie)*n,o),e.lineTo(Ie*n,o),e.lineTo(Ie*n,(1-Ie)*o),e.lineTo(0,(1-Ie)*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:0,y:Ie*n},{x:Ie*e,y:Ie*n},{x:Ie*e,y:0},{x:(1-Ie)*e,y:0},{x:(1-Ie)*e,y:Ie*n},{x:e,y:Ie*n},{x:e,y:(1-Ie)*n},{x:(1-Ie)*e,y:(1-Ie)*n},{x:(1-Ie)*e,y:n},{x:Ie*e,y:n},{x:Ie*e,y:(1-Ie)*n},{x:0,y:(1-Ie)*n}])}textContentBounds(t){const e=t.baseProps;return{x:e.width*Ie+le,y:e.height*Ie+le,width:e.width*(1-Ie*2)-le*2,height:e.height*(1-Ie*2)-le*2}}fullTextNodeHeight(t){return(t.renderText.height+2*le)/(1-Ie*2)}getConnectAnchor(){return super.getConnectAnchor()}}class eg extends Pt{buildPath(t,e){const{width:n,height:o}=t.baseProps;e.beginPath(),e.moveTo(.45331701407562014*n,.04068531978415023*o),e.lineTo(.47241283626581937*n,0),e.lineTo(.5275866431283414*n,0),e.lineTo(.5466824653185405*n,.04068531978415023*o),e.lineTo(.6561866975837122*n,.2739844955129827*o),e.lineTo(.6637719246641702*n,.29014093296241683*o),e.lineTo(.6784321851024475*n,.3013390437841371*o),e.lineTo(.6953883172925998*n,.3039298761896317*o),e.lineTo(.9402500678089105*n,.3413412114782689*o),e.lineTo(.9829501587587509*n,.3478650949789417*o),e.lineTo(n,.40304112159559813*o),e.lineTo(.9691020434299804*n,.4347080674349939*o),e.lineTo(.7919190520392391*n,.616307190723145*o),e.lineTo(.779648372403934*n,.6288863854576189*o),e.lineTo(.7740466535716944*n,.647005242973332*o),e.lineTo(.7769464280973055*n,.6647628181337468*o),e.lineTo(.8187719012369075*n,.9211802328191082*o),e.lineTo(.8260655890472862*n,.9658971352498816*o),e.lineTo(.7814288443747758*n,o),e.lineTo(.7432371999943775*n,.9788868781153761*o),e.lineTo(.5242235294056399*n,.8578189712649151*o),e.lineTo(.509058281303118*n,.849438315417013*o),e.lineTo(.49094119809104253*n,.849438315417013*o),e.lineTo(.4757759499885207*n,.8578189712649151*o),e.lineTo(.2567643618231409*n,.9788868781153761*o),e.lineTo(.21857115562522422*n,o),e.lineTo(.1739323285293562*n,.9658971352498816*o),e.lineTo(.18122705755141377*n,.9211802328191082*o),e.lineTo(.22305409250853406*n,.6647628181337468*o),e.lineTo(.22595074339910845*n,.647005242973332*o),e.lineTo(.2203516275960661*n,.6288863854576189*o),e.lineTo(.20808146856660034*n,.616307190723145*o),e.lineTo(.030898997781698512*n,.4347080674349939*o),e.lineTo(0,.40304112159559813*o),e.lineTo(.017050361847088705*n,.3478650949789417*o),e.lineTo(.059751494008607714*n,.3413412114782689*o),e.lineTo(.3046116827074003*n,.3039298761896317*o),e.lineTo(.3215683355033921*n,.3013390437841371*o),e.lineTo(.33622703412415095*n,.29014093296241683*o),e.lineTo(.34381017878125136*n,.2739844955129827*o),e.lineTo(.45331701407562014*n,.04068531978415023*o),e.closePath()}nodeShapeInfo(t){const{width:e,height:n}=t.baseProps;return q.polygon([{x:.45331701407562014*e,y:.04068531978415023*n},{x:.47241283626581937*e,y:0},{x:.5275866431283414*e,y:0},{x:.5466824653185405*e,y:.04068531978415023*n},{x:.6561866975837122*e,y:.2739844955129827*n},{x:.6637719246641702*e,y:.29014093296241683*n},{x:.6784321851024475*e,y:.3013390437841371*n},{x:.6953883172925998*e,y:.3039298761896317*n},{x:.9402500678089105*e,y:.3413412114782689*n},{x:.9829501587587509*e,y:.3478650949789417*n},{x:e,y:.40304112159559813*n},{x:.9691020434299804*e,y:.4347080674349939*n},{x:.7919190520392391*e,y:.616307190723145*n},{x:.779648372403934*e,y:.6288863854576189*n},{x:.7740466535716944*e,y:.647005242973332*n},{x:.7769464280973055*e,y:.6647628181337468*n},{x:.8187719012369075*e,y:.9211802328191082*n},{x:.8260655890472862*e,y:.9658971352498816*n},{x:.7814288443747758*e,y:n},{x:.7432371999943775*e,y:.9788868781153761*n},{x:.5242235294056399*e,y:.8578189712649151*n},{x:.509058281303118*e,y:.849438315417013*n},{x:.49094119809104253*e,y:.849438315417013*n},{x:.4757759499885207*e,y:.8578189712649151*n},{x:.2567643618231409*e,y:.9788868781153761*n},{x:.21857115562522422*e,y:n},{x:.1739323285293562*e,y:.9658971352498816*n},{x:.18122705755141377*e,y:.9211802328191082*n},{x:.22305409250853406*e,y:.6647628181337468*n},{x:.22595074339910845*e,y:.647005242973332*n},{x:.2203516275960661*e,y:.6288863854576189*n},{x:.20808146856660034*e,y:.616307190723145*n},{x:.030898997781698512*e,y:.4347080674349939*n},{x:0,y:.40304112159559813*n},{x:.017050361847088705*e,y:.3478650949789417*n},{x:.059751494008607714*e,y:.3413412114782689*n},{x:.3046116827074003*e,y:.3039298761896317*n},{x:.3215683355033921*e,y:.3013390437841371*n},{x:.33622703412415095*e,y:.29014093296241683*n},{x:.34381017878125136*e,y:.2739844955129827*n},{x:.45331701407562014*e,y:.04068531978415023*n}])}textContentBounds(t){const e=t.baseProps,n={x:e.width*.059751494008607714,y:e.height*.3413412114782689},o={x:e.width*.3046116827074003,y:e.height*.3039298761896317},s=(n.y-o.y)/(n.x-o.x),r=n.y,i=.22595074339910845*e.width,a=s*i+r,c={x:i,y:a,with:e.width-i*2,height:e.height*.849438315417013-a};return{x:c.x+le,y:c.y+le,width:c.with-le*2,height:c.height-le*2}}fullTextNodeHeight(t){const e=t.baseProps;return e.width*.059751494008607714,e.height*.3413412114782689,e.width*.3046116827074003,e.height*.3039298761896317,(t.renderText.height+2*le)/.849438315417013}getConnectAnchor(){return super.getConnectAnchor()}}const Wt=class Wt extends en{constructor(e,n){super(e,n);p(this,"type",v.Shape);p(this,"transform",re.generateMatrix());p(this,"renderText");this.props.set(I.Base,new ie),this.props.set(I.Shape,new Oe),this.props.set(I.Color,new tt),this.props.set(I.Border,new Ae),this.props.set(I.Text,new Ge),this.props.set(I.TextParagraph,new qt),this.props.set(I.TextParagraphQuote,new Dt),this.renderText=new ho}validShapeCode(e){return!!Wt.drawerMap.get(e)}get borderProps(){return this.props.get(I.Border)}get colorProps(){return this.props.get(I.Color)}get textProps(){return this.props.get(I.Text)}get paragraphProps(){return this.props.get(I.TextParagraph)}get paragraphQuoteProps(){return this.props.get(I.TextParagraphQuote)}get shapeType(){return this.props.get(I.Shape).shapeCode}get drawer(){const e=Wt.drawerMap.get(this.shapeType);return e||Wt.drawerMap.get(K.RoundRect)}borderContains(e,n){const o=this.toLocal(e);return this.drawer.borderContains(this,o,n)}updateProps(e){super.updateProps(e);const n=e.find(i=>i.type===I.Text),o=e.find(i=>i.type===I.TextParagraph),s=e.find(i=>i.type===I.TextParagraphQuote),r=e.find(i=>i.type===I.Base);if(r&&this.updateTransformMatrix(),n||r||o||s){const i=this.drawer.textContentBounds(this);this.shapeType===K.PureText&&this.textProps.sizeMode!==We.fix&&this.textProps.verticalAlign!==at.Top&&(this.textProps.verticalAlign=at.Top),this.renderText.typesetting(this.graphicContext,this.textProps,i,this.paragraphProps,this.paragraphQuoteProps),this.shapeType===K.PureText&&this.textProps.sizeMode!==We.fix&&(this.baseProps.height=this.renderText.y+this.renderText.height,this.renderText.rect.height=this.renderText.height+4,this.textProps.sizeMode===We.autoWidth&&(this.baseProps.width=this.renderText.width+4))}}modifyPosInEditing(e){if(this.shapeType===K.PureText)return!1;const n=this.drawer.textContentBounds(this);return this.renderText.modifyPosInEditing(n,e)}resetFromEditing(){const e=this.drawer.textContentBounds(this);return this.renderText.resetFromEditing(e)}contains(e){const{width:n,height:o}=this.baseProps,s=this.toLocal(e);return S.rectContains(s,new D(0,0,n,o))}drawOnGLCtx(e){const n=this.shapeType;let o=Wt.drawerMap.get(n);o||(console.error("取不到drawer,使用rect兜底!"),o=Wt.drawerMap.get(K.Rect)),e.save(),e.beginPath();const{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.transform(s,r,i,a,c,h),o.draw(this,e),this.drawText(e),e.restore()}drawText(e){if(this.shapeType===K.PureText){const a=new P;this.renderText.draw(e,a,1);return}const{x:n,y:o,width:s,height:r}=this.getTextContentRect();e.save(),e.beginPath(),e.rect(n,o,s,r),e.clip();const i=new P;this.renderText.draw(e,i,1),e.restore()}getStretchMinSize(){return new P(20,20)}draw(){this.drawOnGLCtx(this.graphicContext)}getTextContentRect(){const e=this.shapeType;let n=Wt.drawerMap.get(e);return n||(console.error("取不到drawer,使用rect兜底!"),n=Wt.drawerMap.get(K.Rect)),n.textContentBounds(this)}isEmptyText(){return this.renderText.isEmptyText()}getConnectAnchor(){return this.drawer.getConnectAnchor()}static load(e,n,o,s,r,i){const a=new Wt(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}};p(Wt,"drawerMap",new Map([[K.PureText,new Wf],[K.Ellipse,new _f],[K.Rect,new Ff],[K.RoundRect,new Uf],[K.Triangle,new Yf],[K.Diamond,new Gf],[K.Parallelogram,new $f],[K.Octagon,new Qf],[K.Hexagon,new Kf],[K.Trapezoid,new jf],[K.Pentagon,new Vf],[K.Star,new eg],[K.Cloud,new qf],[K.Cross,new Jf]]));let vt=Wt;class Po extends Fn{constructor(e,n){super(e,n);p(this,"type",v.SVG);p(this,"imgBitmap",null);p(this,"svgCode","");this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Svg,new Wn),this.props.set(I.Crop,new Mn)}get svgUrl(){return this.props.get(I.Svg).url}get svgProps(){return this.props.get(I.Svg)}setSvgCode(e){this.svgCode=e}static load(e,n,o,s,r,i){const a=new Po(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class yn{static getNumFromString(t){try{const e=t.match(/(\d+)/);return e&&e[1]?parseInt(e[1],10):100}catch{return console.error("从字符串中获取num出错:",t),100}}static trimSvgCode(t){const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,o=n.getAttribute("width"),s=n.getAttribute("height");n.removeAttribute("width"),n.removeAttribute("height");const r=n.style.width,i=n.style.height;n.style.removeProperty("width"),n.style.removeProperty("height");let a=100,c=100;return o!==null?a=this.getNumFromString(o):r!==""&&(a=this.getNumFromString(r)),s!==null?c=this.getNumFromString(s):i!==""&&(c=this.getNumFromString(i)),n.getAttribute("viewBox")||n.setAttribute("viewBox",`0 0 ${a} ${c}`),{svgCode:n.outerHTML,width:a,height:c}}}class mo extends en{constructor(e,n){super(e,n);p(this,"type",v.Group);this.props.set(I.Base,new ie)}get globalPos(){return this.nameGlobalTransform().crossPoint(new P)}computeBasePropsByChildren(){const e=[];for(const s of this.children)e.push(s.baseProps);const n=S.getBoundsByBasePropsList(e),o=D.rectNode2Rect(n);return ie.create({x:o.x,y:o.y,width:o.width,height:o.height})}drawOnGLCtx(e){}getTextContentRect(){return this.baseProps}canBeConnected(){return!1}transToLocalPoint(e){return this.nameGlobalTransform().inverseMatrix().crossPoint(e)}contains(e,n=1){const{width:o,height:s}=this.baseProps,r=this.transToLocalPoint(e);return S.rectContains(r,new D(0,0,o,s))}toGlobal(e){return this.nameGlobalTransform().crossPoint(e)}nameGlobalTransform(){const e=this.selfTransform();return this.globalTransform().crossProduct(e)}selfTransform(){const{x:e,y:n}=this.baseProps;return re.generateMatrix().translate(e,n)}updateTransformMatrix(){}static load(e,n,o,s,r,i){const a=new mo(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}}class rs extends en{constructor(e,n){super(e,n);p(this,"type",v.Section);this.props.set(I.Base,new ie),this.props.set(I.Border,new Ae),this.props.set(I.Color,new tt),this.props.set(I.Slide,new St)}get borderProps(){return this.props.get(I.Border)}get colorProps(){return this.props.get(I.Color)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){e.save();const n=this.baseProps,{a:o,b:s,c:r,d:i,e:a,f:c}=this.globalTransform();e.transform(o,s,r,i,a,c);const h=this.colorProps,d=this.borderProps;e.beginPath(),e.roundRect(0,0,n.width,n.height,6),h.color!==""&&(e.fillStyle=h.color,e.globalAlpha=h.alpha,e.fill()),d.color!==""&&d.dashType!==et.None&&(S.setDashLine(d,e),e.strokeStyle=d.color,e.lineWidth=d.width,e.globalAlpha=d.alpha,e.stroke()),e.restore()}static load(e,n,o,s,r,i){const a=new rs(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}canQuickCreate(){return!1}getTextContentRect(){return this.baseProps}}class bo extends en{constructor(e,n){super(e,n);p(this,"type",v.SlideContainer);this.props.set(I.Base,new ie),this.props.set(I.Slide,new St)}get slideProps(){return this.props.get(I.Slide)}updateProps(e){super.updateProps(e),e.find(o=>o.type===I.Base)&&this.updateTransformMatrix()}drawOnGLCtx(e){const{width:n,height:o}=this.baseProps,{a:s,b:r,c:i,d:a,e:c,f:h}=this.globalTransform();e.save(),e.transform(s,r,i,a,c,h),e.shadowColor="rgba(0, 0, 0, 0.1)",e.shadowBlur=15,e.shadowOffsetX=0,e.shadowOffsetY=6,e.fillStyle="rgba(255, 255, 255, 0.6)",e.beginPath(),e.roundRect(0,0,n,o,8),e.fill(),e.shadowColor="transparent",e.fillStyle="rgba(240, 242, 245, 0.5)",e.fill(),e.strokeStyle="rgba(0, 0, 0, 0.1)",e.lineWidth=1,e.stroke(),e.restore()}canQuickCreate(){return!1}getTextContentRect(){return this.baseProps}static load(e,n,o,s,r,i){const a=new bo(e,i);return a.type=n,a.zIndex=o,a.setParent(r),a.updateProps(s),a}getChildIdByIndex(e){const n=this.slideProps.children;let o=0;for(let s=0;s<n.length;s++){if(e<o+n[s].ids.length){const r=e-o;return n[s].ids[r]}o+=n[s].ids.length}return null}getTotalCount(){return this.slideProps.children.reduce((n,o)=>n+o.ids.length,0)}}const Ps=class Ps{static getInstance(){return this.instance||(this.instance=new Ps),this.instance}create(t,e,n,o,s,r){switch(e){case v.Line:return Ct.load(t,e,n,o,s,r);case v.SVG:return Po.load(t,e,n,o,s,r);case v.IMG:return ro.load(t,e,n,o,s,r);case v.Section:return rs.load(t,e,n,o,s,r);case v.Group:return mo.load(t,e,n,o,s,r);case v.Checkbox:return Yo.load(t,e,n,o,s,r);case v.CheckboxText:return Gn.load(t,e,n,o,s,r);case v.SlideContainer:return bo.load(t,e,n,o,s,r);case v.Shape:default:return vt.load(t,e,n,o,s,r)}}createByNodeInfo(t,e,n){const o=S.convertCapInfoToProps(t.capInfo);return this.create(t.id,t.type,t.zIndex,o,e,n)}};p(Ps,"instance",null);let It=Ps;class pr extends en{constructor(e){const o=document.createElement("canvas").getContext("2d");super(e,o);p(this,"type",v.ROOT);p(this,"transform",re.generateMatrix())}updateProps(e){}drawOnGLCtx(e){}getTextContentRect(){return new D}toGlobal(e){return e}toLocal(e){return e}}const is=800;class Pc{static async getImageSize(t){return new Promise((e,n)=>{const o=URL.createObjectURL(t),s=new Image;s.crossOrigin="anonymous",s.onload=()=>{let r=s.naturalWidth*.5,i=s.naturalHeight*.5;URL.revokeObjectURL(o);const a=r/i;r>i&&r>is?(r=is,i=r/a):i>r&&i>is&&(i=is,r=i*a),e({width:r,height:i})},s.onerror=()=>{URL.revokeObjectURL(o),n(new Error("无法加载图片"))},s.src=o})}}class At extends gn{constructor(){super(...arguments);p(this,"type",Xe.RemoveNode)}static create(e){return new At({idList:e})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new At(e,this.meta)}}class fr{}class mc extends fr{handle(t,e,n){const o=e.find(i=>i.type===I.Connect);if(!o)return;const{start:s,end:r}=o;if(s!==void 0)if(s!==null){const i=n.nodeManager.getNode(s.objectId)||null;n.nodeManager.addLink(t,i,!0)}else n.nodeManager.addLink(t,null,!0);if(r!==void 0)if(r!==null){const i=n.nodeManager.getNode(r.objectId)||null;n.nodeManager.addLink(t,i,!1)}else n.nodeManager.addLink(t,null,!1)}}class tg extends fr{handle(t,e,n){if(!e.find(r=>r.type===I.Image)||t.type!==v.IMG)return;const s=t;n.asyncRenderNodeManager.addRenderNode(s)}}let ng=class extends fr{handle(t,e,n){const o=e.find(r=>r.type===I.Svg);if(!o||t.type!==v.SVG)return;const s=t;if(s.svgProps.useCode){const r=yn.trimSvgCode(s.svgProps.code);s.setSvgCode(r.svgCode),n.asyncRenderNodeManager.addRenderNode(s);return}n.resourceManager.loadSvgUrl(o.url).then(r=>{const i=yn.trimSvgCode(r);s.setSvgCode(i.svgCode),n.asyncRenderNodeManager.addRenderNode(s)}).catch(r=>{console.error("加载图片出现问题",r),s.setBroken(),n.renderManager.dirtyDraw(t.getBounds())})}};class bc extends ln{constructor(){super(...arguments);p(this,"type",Xe.AddNode);p(this,"handlers",[new mc,new tg,new ng])}execData(e,n){const o=e.nodes;for(const s of o)this.execNodeInfo(s,n);n.renderManager.addContentRenderTask()}execNodeInfo(e,n){const o=n.gmlRender.glCtx,s=n.nodeManager.getParentNode(e.parentId),r=It.getInstance().create(e.id,e.type,e.zIndex,e.props,s,o);n.nodeManager.addNode(r);for(const i of this.handlers)i.handle(r,e.props,n)}reverseLog(e,n){const o=e.nodes.map(s=>s.id);return new At({idList:o})}}class Le extends gn{constructor(){super(...arguments);p(this,"type",Xe.AddNode)}static create(e){return new Le({nodes:[e]})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new Le(e,this.meta)}}class Sc extends ln{constructor(){super(...arguments);p(this,"type",Xe.RemoveNode)}execData(e,n){for(const o of e.idList)n.nodeManager.getNode(o)&&n.nodeManager.removeNode(o);n.renderManager.addContentRenderTask(),n.renderManager.addAuxiliaryDrawTask()}reverseLog(e,n){var s;const o=[];for(const r of e.idList){const i=n.nodeManager.getNode(r);if(!i){console.error("错误,生成逆消息时节点不存在:",r);continue}const a=[...i.props.values()];o.push({id:i.id,type:i.type,zIndex:i.zIndex,parentId:((s=i.parent)==null?void 0:s.id)||Sn,props:a})}return new Le({nodes:o})}}class U extends gn{constructor(){super(...arguments);p(this,"type",Xe.UpdateNode)}static create(e,n,o){const s={id:e,props:n};return new U({infos:[s]},o)}clone(){const e=JSON.parse(JSON.stringify(this.data));return new U(e,this.meta)}}class Mc extends ln{constructor(){super(...arguments);p(this,"type",Xe.UpdateNode);p(this,"handlers",[new mc])}execData(e,n){for(const o of e.infos)this.execNodeInfo(o,n);n.renderManager.addContentRenderTask()}execNodeInfo(e,n){const{id:o,zIndex:s,props:r,parentId:i}=e,a=n.nodeManager.getNode(o);if(!a){console.error("错误:节点不存在:",o);return}if(this.removeIndexNode(a,n),s!==void 0&&(a.zIndex=s),this.changeParent(a,n,i),r.length>0){a.updateProps(r);for(const c of this.handlers)c.handle(a,r,n)}this.addIndexNode(a,n),n.auxiliaryManager.selectManager.include(a)&&(n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0))}changeParent(e,n,o){if(o===void 0||o===e.parent.id)return;const s=n.nodeManager.getNode(o);s&&(e.parent.children.delete(e),s.children.add(e),e.parent=s)}removeIndexNode(e,n){n.nodeManager.removeIndexNode(e.getRectNode());for(const o of e.children)this.removeIndexNode(o,n)}addIndexNode(e,n){n.nodeManager.addIndexNode(e.getRectNode());for(const o of e.children)this.addIndexNode(o,n)}reverseLog(e,n){const o=[];for(const s of e.infos){const r=n.nodeManager.getNode(s.id);if(!r)continue;const i=r.parent?r.parent.id:n.nodeManager.root.id,a=r.serializeTo(),c=S.convertCapInfoToProps(a.capInfo);o.push({id:r.id,zIndex:r.zIndex,props:c,parentId:i})}return new U({infos:o})}}class xe extends gn{constructor(){super(...arguments);p(this,"type",Xe.SelectNode)}static create(e){return new xe({idList:e})}clone(){const e=JSON.parse(JSON.stringify(this.data));return new xe(e,this.meta)}}class vc extends ln{constructor(){super(...arguments);p(this,"type",Xe.SelectNode)}execData(e,n){const o=e.idList,s=new Set;o.forEach(r=>{const i=n.nodeManager.getNode(r);i&&s.add(i)}),n.auxiliaryManager.selectManager.set(s),n.renderManager.addAuxiliaryDrawTask(),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0)}reverseLog(e,n){const s=n.auxiliaryManager.selectManager.getSelectNodes().map(r=>r.id);return new xe({idList:s})}}class z extends gn{constructor(){super(null);p(this,"type",Xe.End)}clone(){return new z}}class Ic extends ln{constructor(){super(...arguments);p(this,"type",Xe.Start)}execData(e,n){}reverseLog(e,n){return new z}}class W extends gn{constructor(){super(null);p(this,"type",Xe.Start)}clone(){return new W}}class Tc extends ln{constructor(){super(...arguments);p(this,"type",Xe.End)}execData(e,n){}reverseLog(e,n){return new W}}class Lc extends ln{constructor(){super(...arguments);p(this,"type",Xe.TextFocus)}checkValidNode(e,n){const o=n.nodeManager.getNode(e);if(!o)throw new Error("错误:节点不存在:"+e);const s=o.renderText;return{node:o,renderText:s}}execData(e,n){var a;const{focusType:o,blur:s,selection:r,focus:i}=e;if(o===Lt.Empty){n.auxiliaryManager.remove(k.TextSelection);return}if(n.renderManager.addAuxiliaryDrawTask(),o===Lt.Focus){n.auxiliaryManager.remove(k.TextSelection);const{id:c,textCursorPosition:h}=i,{node:d,renderText:u}=this.checkValidNode(c,n);d.modifyPosInEditing(h)&&n.renderManager.addContentRenderTask(),n.inputManager.focus({node:d,renderText:u,textCursorPosition:h}),u.isEmptyText()?d.type===v.Shape&&n.auxiliaryManager.addOrUpdate(k.PlaceHolder,{node:d}):n.auxiliaryManager.remove(k.PlaceHolder),n.auxiliaryManager.selectManager.refreshSelectStatus();return}if(o===Lt.Selection){const{id:c,start:h,end:d}=r,{node:u,renderText:f}=this.checkValidNode(c,n);n.inputManager.selection(u,f,h,d);const g=(a=n.inputManager.selectionManager.selectionInfo)==null?void 0:a.selectionList;g&&(n.auxiliaryManager.addOrUpdate(k.TextSelection,{selectionList:g,node:u}),n.renderManager.addAuxiliaryDrawTask()),n.auxiliaryManager.remove(k.PlaceHolder),n.auxiliaryManager.slotManager.addSlotState(ze.FocusPropsChange,!0);return}if(o===Lt.Blur){n.inputManager.blur(),n.auxiliaryManager.remove(k.PlaceHolder);return}}reverseLog(e,n){const{focusType:o}=e,s=n.inputManager.editTextInfo,r=n.inputManager.selectionManager.selectionInfo;if(o===Lt.Focus){const i=e.focus.id;return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):ee.blur(i)}if(o===Lt.Blur)return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):(console.warn("选中消息不符合预期,已容错处理"),ee.empty());if(o===Lt.Selection){const i=e.selection.id;return s?r?ee.selection(s.node.id,r.start,r.end):ee.focus(s.node.id,s.textCursorPosition):ee.blur(i)}return ee.empty()}}const Cc=[new bc,new Sc,new Mc,new vc,new Lc,new Ic,new Tc];class Ac{}class og extends Ac{constructor(){super(...arguments);p(this,"slideContainer",null)}enable(e,n){if(e.meta.streaming||n.docState.docMode!==ue.SLIDE_EDIT)return!1;const o=n.docState.slideStatus.slideContainer;return o?(this.slideContainer=o,!0):!1}handle(e,n){this.slideContainer&&(this.handleUpdateLog(e,n,this.slideContainer),this.handleAddLog(e,n,this.slideContainer),this.handleRemoveLog(e,n,this.slideContainer))}handleUpdateLog(e,n,o){var s;if(e.type===Xe.UpdateNode){const r=e.data;for(const i of r.infos){const a=n.nodeManager.getNode(i.id);if(!a)continue;if(((s=a.parent)==null?void 0:s.id)===o.id&&this.judgeOnlyPosChange(i.props,a)){this.judgeSlideEditCurrent(a,n)&&(console.log("协同端正在更新此幻灯片位置,触发器重置视图"),setTimeout(()=>{n.slideManager.refocusSlide(n,50)},10));continue}if(a.id===o.id){const h=n.renderManager.getScale(),d=this.judgeOnlyPosChange(i.props,a);if(d){n.renderManager.scroll(d.x*h,d.y*h);continue}}const c=S.judgeSlideSectionChildren(a,o);c&&n.slideManager.slideCoverManager.updateSlideCover(c)}}}judgeSlideEditCurrent(e,n){const o=n.docState.slideStatus;return o.slideContainer?o.slideContainer.getChildIdByIndex(o.currentIndex)===e.id:!1}judgeOnlyPosChange(e,n){if(e.length!==1)return null;const o=e[0];if(o.type!==I.Base)return null;const s=n.baseProps,r=o.width===void 0||Math.abs(o.width-s.width)<.1;if(!(o.height===void 0||Math.abs(o.height-s.height)<.1)||!r)return null;if(o.x!==void 0||o.y!==void 0){const a=new P;return o.x!==void 0&&(a.x=o.x-s.x),o.y!==void 0&&(a.y=o.y-s.y),a}return null}handleAddLog(e,n,o){if(e.type===Xe.AddNode){const s=e.data;for(const r of s.nodes){const i=n.nodeManager.getNode(r.parentId);if(!i)continue;const a=S.judgeSlideSectionChildren(i,o);a&&n.slideManager.slideCoverManager.updateSlideCover(a)}}}handleRemoveLog(e,n,o){if(e.type===Xe.RemoveNode){const s=e.data;for(const r of s.idList){const i=n.nodeManager.getNode(r);if(!i)continue;const a=S.judgeSlideSectionChildren(i,o);a&&n.slideManager.slideCoverManager.updateSlideCover(a)}}}}class sg extends Ac{constructor(){super(...arguments);p(this,"slideContainer",null)}enable(e,n){if(e.meta.streaming||n.docState.docMode!==ue.SLIDE_EDIT)return!1;const o=n.docState.slideStatus.slideContainer;return o?(this.slideContainer=o,!0):!1}handle(e,n){this.slideContainer&&this.handleUpdateLog(e,n,this.slideContainer)}handleUpdateLog(e,n,o){if(e.type===Xe.UpdateNode){const s=e.data;for(const r of s.infos){const i=n.nodeManager.getNode(r.id);!i||i.id!==o.id||!r.props.find(c=>c.type===I.Slide)||n.slideManager.slideCoverManager.updateSlideContainerCover(o)}}}}class Nc{constructor(t){p(this,"executors",new Map);p(this,"ctx");p(this,"beforeInterceptors",[new og,new sg]);p(this,"afterInterceptors",[]);for(const e of t)this.executors.set(e.type,e)}init(t){this.ctx=t}exec(t,e){const n=this.executors.get(t.type);if(!n){console.error("缺乏对应的消息处理器,已忽略该消息");return}for(const o of this.beforeInterceptors)o.enable(t,this.ctx)&&o.handle(t,this.ctx);n.exec(t,e);for(const o of this.afterInterceptors)o.enable(t,this.ctx)&&o.handle(t,this.ctx)}}class kc{constructor(){p(this,"undoStack",[]);p(this,"redoStack",[])}add(t){const e=t.reverse();this.undoStack.push(e),this.redoStack=[]}undo(t,e){const n=this.undoStack.pop()||null;if(!n)return null;for(const o of n.actionLogs)t.exec(o,e);return this.redoStack.push(n.reverse()),n}redo(t,e){const n=this.redoStack.pop()||null;if(!n)return null;for(const o of n.actionLogs)t.exec(o,e);return this.undoStack.push(n.reverse()),n}}class as{constructor(t=[]){p(this,"actionLogs",[]);this.actionLogs=t}reverse(){const t=new as;for(let e=this.actionLogs.length-1;e>-1;e--){const n=this.actionLogs[e];t.actionLogs.push(n.reverse())}return t}}class Bc{constructor(){p(this,"cacheLogs",[]);p(this,"duringGroup",!1)}add(t){t.type===Xe.Start&&(this.duringGroup=!0),this.cacheLogs.push(t),t.type===Xe.End&&(this.duringGroup=!1)}getActionGroup(){if(this.duringGroup)return null;const t=new as(this.cacheLogs);return this.cacheLogs=[],t}}const Rc=new Set([Xe.Start,Xe.End,Xe.SelectNode,Xe.TextFocus]);class Ec{constructor(t,e,n,o,s,r,i,a,c,h,d,u){p(this,"execCtx");p(this,"executor");p(this,"undoManager");p(this,"networkPlugin",null);p(this,"actionCache");p(this,"renderManager");p(this,"docState");this.executor=new Nc(Cc),this.undoManager=new kc,this.renderManager=r,this.execCtx={inputManager:e,nodeManager:t,gmlRender:n,auxiliaryManager:o,toolManager:s,renderManager:this.renderManager,resourceManager:i,idGenerator:c,slotManager:h,asyncRenderNodeManager:d,docState:a,slideManager:u},this.actionCache=new Bc,this.docState=a}addNetworkPlugin(t){this.networkPlugin=t}execAction(t){var n;this.dealDocSeq(t),this.executor.exec(t,this.execCtx),Rc.has(t.type)||(n=this.networkPlugin)==null||n.addMessage(t),this.actionCache.add(t);const e=this.actionCache.getActionGroup();e&&this.undoManager.add(e)}dealDocSeq(t){Rc.has(t.type)||this.docState.seq++}undo(){var e;const t=this.undoManager.undo(this.executor,this.execCtx);t&&((e=this.networkPlugin)==null||e.addActionGroup(t))}redo(){var e;const t=this.undoManager.redo(this.executor,this.execCtx);t&&((e=this.networkPlugin)==null||e.addActionGroup(t))}}function rg(l){return l.type===Xe.AddNode?{addNodeData:{data:l.data.nodes.map(n=>{const o=n.props,s=new Map;o.forEach(a=>s.set(a.type,a));const r=S.convertPropsToCapInfo(s);return{id:n.id,type:n.type,zIndex:n.zIndex,parentId:n.parentId,capInfo:r}})}}:l.type===Xe.UpdateNode?{updateNodeData:{data:l.data.infos.map(n=>{const o=n.props,s=new Map;o.forEach(a=>s.set(a.type,a));const r=S.convertPropsToCapInfo(s);return{id:n.id,zIndex:n.zIndex,parentId:n.parentId,capInfo:r}})}}:l instanceof At?{removeNodeData:{data:l.data.idList}}:null}function ig(l){const{updateNodeData:t,addNodeData:e,removeNodeData:n}=l;if(e){const o=[];for(const s of e.data)o.push({id:s.id,parentId:s.parentId,zIndex:s.zIndex,type:s.type,props:S.convertCapInfoToProps(s.capInfo)});return new Le({nodes:o})}if(t){const o=[];for(const s of t.data)o.push({id:s.id,zIndex:s.zIndex,parentId:s.parentId,props:S.convertCapInfoToProps(s.capInfo)});return new U({infos:o})}if(n)return At.create(n.data);throw new Error("类型转换错误!")}const gr=.04,yr=4;class Hc{static isMobile(){const t=navigator.userAgent||navigator.vendor||window.opera;if(/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i.test(t.toLowerCase()))return!0;const n="ontouchstart"in window||navigator.maxTouchPoints>0,o=window.innerWidth<768;return n&&o}}const ag=70,cg=10;class lg{zoomScale(t,e,n){const o=n.getScale();let s=t;o*t>yr&&(s=yr/o),o*t<gr&&(s=gr/o),this.zoomToScale(s,e,n.gmlRender),this.zoomToScale(s,e,n.auxiliaryManager.gmlRender);const r=n.getScale();n.slotManager.addSlotState(ze.Scale,r),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}zoomToSelect(t){if(t.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const n=t.auxiliaryManager.selectManager.getSelectBounds();this.zoomToBounds(n,t)}zoomToFit(t){if(t.nodeManager.nodeMap.size===0)return;const n=t.nodeManager.getNodeBounds();this.zoomToBounds(n,t)}zoomTo100(t){if(t.nodeManager.nodeMap.size===0)return;const n=t.nodeManager.getNodeBounds(),o=t.gmlRender.canvas.getBoundingClientRect(),s=window.devicePixelRatio,r=1*s,i=new P(.5*s*o.width,.5*s*o.height),a=new P(.5*(n.minX+n.maxX),.5*(n.minY+n.maxY)),c=new P(-a.x*r+i.x,-a.y*r+i.y);this.zoomToMatrix(r,c.x,c.y,t.gmlRender),this.zoomToMatrix(r,c.x,c.y,t.auxiliaryManager.gmlRender);const h=t.getScale();t.slotManager.addSlotState(ze.Scale,h),t.addContentRenderTask(),t.addAuxiliaryDrawTask()}zoomToBounds(t,e,n){const o=Hc.isMobile()?cg:ag,s=n!==void 0?n:o,r=D.rectNode2Rect(t),i=e.gmlRender.canvas.getBoundingClientRect(),a=window.devicePixelRatio,c=i.width-s*2*a,h=i.height-s*2*a,d=c/r.width,u=h/r.height,f=Math.min(d,u)*a,g=new P(.5*a*i.width,.5*a*i.height),y=new P(.5*(t.minX+t.maxX),.5*(t.minY+t.maxY)),m=new P(-y.x*f+g.x,-y.y*f+g.y);this.zoomToMatrix(f,m.x,m.y,e.gmlRender),this.zoomToMatrix(f,m.x,m.y,e.auxiliaryManager.gmlRender);const b=e.getScale();e.slotManager.addSlotState(ze.Scale,b),e.addContentRenderTask(),e.addAuxiliaryDrawTask()}zoomToScale(t,e,n){n.scale(t,t,e);const o=n.glCtx,{a:s,b:r,c:i,d:a,e:c,f:h}=n.globalTransform;o.setTransform(s,r,i,a,c,h)}zoomToMatrix(t,e,n,o){const s=t,r=t,i=e,a=n;o.setTransform(s,0,0,r,i,a)}}class hg{exportToOfflineCanvas(t,e,n,o){const s=D.rectNode2Rect(t),r=document.createElement("canvas");r.width=n*s.width,r.height=n*s.height;const i=r.getContext("2d");i.scale(n,n),i.translate(-s.x,-s.y);let a=e.searchNodesByRectNode(t);a=S.sortGraphics(a),i.save(),o&&(i.fillStyle=o,i.fillRect(s.x,s.y,s.width,s.height)),i.restore();for(const c of a)c.drawOnGLCtx(i);return r}exportToOfflineCanvasByFilterNodes(t,e,n,o,s){const r=D.rectNode2Rect(t),i=document.createElement("canvas");i.width=n*r.width,i.height=n*r.height;const a=i.getContext("2d");a.scale(n,n),a.translate(-r.x,-r.y);let c=e.searchNodesByRectNode(t);c=S.sortGraphics(c),a.save(),o&&(a.fillStyle=o,a.fillRect(r.x,r.y,r.width,r.height)),a.restore();for(const h of c)s.has(h)&&h.drawOnGLCtx(a);return i}}class Dc{constructor(t,e,n,o){p(this,"gmlRender");p(this,"nodeManager");p(this,"auxiliaryManager");p(this,"slotManager");p(this,"zoomWorker",new lg);p(this,"exportWorker",new hg);p(this,"contentDraw",!1);p(this,"auxiliaryDraw",!1);p(this,"focusId");p(this,"tickerRun",()=>{if(this.contentDraw){const t=this.judgeFocusNode();t?this.auxiliaryManager.selectManager.docState.docMode===ue.SLIDE_PLAY?this.drawInPlayingMode(t):this.drawInFocusMode(t):this.drawInNormalMode()}this.auxiliaryDraw&&(this.auxiliaryManager.redraw(),this.auxiliaryDraw=!1),requestAnimationFrame(this.tickerRun)});p(this,"drawInNormalMode",()=>{const t=this.gmlRender.getViewPortBounds(),e=this.nodeManager.tree.search(t),n=new Set;for(const s of e){const r=this.nodeManager.nodeMap.get(s.id);r&&n.add(r)}let o=[...n];o=S.sortGraphics(o),this.gmlRender.dirtyDraw(t,o),this.contentDraw=!1});p(this,"drawInFocusMode",t=>{const e=this.gmlRender.getViewPortBounds(),n=new Set;S.getAllChildren(t,n);const o=S.sortGraphics([t,...n]);this.gmlRender.dirtyDraw(e,o),this.contentDraw=!1});p(this,"drawInPlayingMode",t=>{this.gmlRender.getViewPortBounds();const e=t.getBounds(),n=new Set;S.getAllChildren(t,n);const o=S.sortGraphics([t,...n]);this.gmlRender.dirtyDraw(e,o),this.contentDraw=!1});this.gmlRender=t,this.nodeManager=e,this.auxiliaryManager=n,this.slotManager=o}getScale(){return this.gmlRender.getScale()}zoomScale(t,e){this.zoomWorker.zoomScale(t,e,this)}zoomToFit(){this.zoomWorker.zoomToFit(this)}zoomToSelect(){this.zoomWorker.zoomToSelect(this)}zoomTo100(){this.zoomWorker.zoomTo100(this)}exportOfflineCanvas(t,e,n){return this.exportWorker.exportToOfflineCanvas(t,this.nodeManager,e,n)}scroll(t,e){this.scrollTo(t,e,this.gmlRender),this.scrollTo(t,e,this.auxiliaryManager.gmlRender),this.addContentRenderTask(),this.addAuxiliaryDrawTask()}start(){this.tickerRun()}addAuxiliaryDrawTask(){this.auxiliaryDraw=!0}addContentRenderTask(){this.contentDraw=!0}dirtyDraw(t){const e=this.nodeManager.tree.search(t),n=new Set;for(const r of e){const i=this.nodeManager.nodeMap.get(r.id);i&&n.add(i)}let o=[...n];o=S.sortGraphics(o);const s=this.judgeFocusNode();if(s){const r=new Set([s]);S.getAllChildren(s,r),o=o.filter(i=>r.has(i))}console.log("njx debug:====>",o.map(r=>r.id)),this.gmlRender.dirtyDraw(t,o)}judgeFocusNode(){if(this.focusId){const t=this.nodeManager.nodeMap.get(this.focusId);if(t)return t}return null}scrollTo(t,e,n){const o=n.getScale();n.translation(-t/o,-e/o);const s=n.glCtx,{a:r,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;s.setTransform(r,i,a,c,h,d)}}const dg={default:"default"};class Oc{constructor(){p(this,"currentCursor","default");p(this,"currentAngle")}resetCursor(){this.currentCursor=null}setCursor(t,e){if(this.currentCursor!==null){const o=e!==void 0?`${t}-${e}`:t;if((this.currentAngle!==void 0?`${this.currentCursor}-${this.currentAngle}`:this.currentCursor)===o)return}if(t==="stretch"&&e!==void 0){const o=this.generateRotatedStretchCursorSvg(e),r=`url("data:image/svg+xml,${encodeURIComponent(o)}") 16 16, auto`;document.body.style.cursor=r,this.currentCursor=t,this.currentAngle=e;return}if(t==="rotate"&&e!==void 0){const o=this.generateRotatedRotateCursorSvg(e),r=`url("data:image/svg+xml,${encodeURIComponent(o)}") 16 16, auto`;document.body.style.cursor=r,this.currentCursor=t,this.currentAngle=e;return}const n=dg[t];n?document.body.style.cursor=n:document.body.style.cursor=t,this.currentCursor=t,this.currentAngle=void 0}generateRotatedStretchCursorSvg(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
6
+ <g transform="rotate(${t} 16 16)">
7
+ <mask id="path-1-outside-1_0_11070" maskUnits="userSpaceOnUse" x="5" y="10" width="22" height="12" fill="black">
8
+ <rect fill="white" x="5" y="10" width="22" height="12"/>
9
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7 16L10 19V16.5H22V19L25 16L22 13V15.5L10 15.5V13L7 16Z"/>
10
+ </mask>
11
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7 16L10 19V16.5H22V19L25 16L22 13V15.5L10 15.5V13L7 16Z" fill="black"/>
12
+ <path d="M10 19H11V21.4142L9.29289 19.7071L10 19ZM7 16L6.29289 16.7071L5.58579 16L6.29289 15.2929L7 16ZM10 16.5H9V15.5H10V16.5ZM22 16.5V15.5H23V16.5H22ZM22 19L22.7072 19.7071L21 21.4142V19H22ZM25 16L25.7072 15.2929L26.4143 16L25.7072 16.7071L25 16ZM22 13H21V10.5858L22.7072 12.2929L22 13ZM22 15.5H23V16.5H22V15.5ZM10 15.5V16.5H9V15.5H10ZM10 13L9.29289 12.2929L11 10.5858V13H10ZM9.29289 19.7071L6.29289 16.7071L7.70711 15.2929L10.7071 18.2929L9.29289 19.7071ZM11 16.5V19H9V16.5H11ZM22 17.5H10V15.5L22 15.5V17.5ZM23 16.5V19H21V16.5H23ZM21.2929 18.2929L24.2929 15.2929L25.7072 16.7071L22.7072 19.7071L21.2929 18.2929ZM24.2929 16.7071L21.2929 13.7071L22.7072 12.2929L25.7072 15.2929L24.2929 16.7071ZM23 13V15.5H21V13H23ZM10 14.5L22 14.5V16.5H10V14.5ZM11 13V15.5H9V13H11ZM6.29289 15.2929L9.29289 12.2929L10.7071 13.7071L7.70711 16.7071L6.29289 15.2929Z" fill="white" mask="url(#path-1-outside-1_0_11070)"/>
13
+ </g>
14
+ </svg>`}generateRotatedRotateCursorSvg(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
15
+ <g transform="rotate(${t} 16 16)">
16
+ <path d="M22.0001 11L19.0001 8L16.0001 11H18.5001C18.5001 15.1421 15.1422 18.5 11.0001 18.5L11 16L8 19L11 22L11 19.5C15.6944 19.5 19.5001 15.6944 19.5001 11L22.0001 11Z" fill="black"/>
17
+ <g filter="url(#filter0_d_0_11302)">
18
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M18.9997 6.58594L24.4139 12.0002L20.4477 12.0002C19.9824 16.4482 16.4477 19.9828 11.9997 20.4481L11.9997 24.4144L6.58545 19.0002L11.9996 13.586L11.9997 17.4237C14.7888 16.993 16.9926 14.7893 17.4233 12.0002H13.5855L18.9997 6.58594ZM18.4336 12.0002C18.4107 12.1726 18.3818 12.3431 18.3473 12.5117C17.7134 15.6096 15.1695 18.0117 11.9997 18.4341C11.6727 18.4776 11.339 18.5001 11.0001 18.5002L10.9997 16.0002L7.99966 19.0002L10.9997 22.0002L10.9997 19.5002C11.2931 19.5002 11.5831 19.4853 11.8688 19.4563C15.1163 19.1265 17.8234 16.9685 18.9447 14.0277C19.3033 13.0872 19.4997 12.0666 19.4997 11.0002L21.9997 11.0002L18.9997 8.00015L15.9997 11.0002H18.4997C18.4997 11.3392 18.4772 11.673 18.4336 12.0002Z" fill="white"/>
19
+ </g>
20
+ </g>
21
+ </svg>`}}class $n{makeupDefaultProps(t,e,n,o){return this.makeupProps(t,e,n,1,o)}makePreviewProps(t,e,n){return this.makeupProps(t,e,n,.5)}}const So={[Pe.Status]:"#F2F3F5",[Pe.Data]:"#F0FBEF",[Pe.Operation]:"#E1EAFF",[Pe.Step]:"#E0E2FA",[Pe.Decision]:"#FEEAD2",[Pe.Others]:"#FEF1F1",[Pe.Section]:"#F4F2F3",[Pe.Line]:"",[Pe.Check]:"#B4B9F3",[Pe.Resource]:""},an={[Pe.Status]:"#DEE0E3",[Pe.Data]:"#8EE085",[Pe.Operation]:"#82A7FC",[Pe.Step]:"#7B83EA",[Pe.Decision]:"#FFBA6B",[Pe.Others]:"#F98E8B",[Pe.Section]:"#C0A9BD",[Pe.Resource]:"",[Pe.Line]:"#000000",[Pe.Check]:"#7B83EA"};class ug extends $n{makeupProps(t,e,n,o,s){const r=Is[e],i=So[r],a=an[r],c=s?s.toLocal(n):n,{width:h,height:d}=this.computeDefaultSize();return[ie.create({x:c.x,y:c.y,width:h,height:d}),Ge.create({type:I.Text,fontSize:16,richText:"",sizeMode:We.autoHeight}),tt.create({color:i,alpha:o}),Ae.create({color:a,alpha:o}),new Oe(e)]}computeDefaultSize(){return{height:100,width:100}}}class pg extends $n{makeupProps(t,e,n,o,s){const r=Uo[e],i=Pe.Section,a=So[i],c=an[i],h=s?s.toLocal(n):n;return[ie.create({x:h.x,y:h.y,width:r.width,height:r.height}),tt.create({color:a,alpha:o}),Ae.create({color:c,alpha:o})]}}class fg extends $n{makeupProps(t,e,n,o,s){const r=S.computeShapeCategory(v.Line,e),i=an[r],a=s?s.toLocal(n):n,c=this.makeupLinePoints(a,e),h=D.rectNode2Rect(S.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(e),je.create(c),Ae.create({color:i,alpha:o}),lt.create({rArrow:it.Arrow})]}makeupLinePoints(t,e){return e===he.PolyLine||e===he.RoundPolyLine||e===he.Curve?[{x:t.x,y:t.y+100},{x:t.x+.5*100,y:t.y+100},{x:t.x+.5*100,y:t.y},{x:t.x+100,y:t.y}]:[{x:t.x,y:t.y+100},{x:t.x+100,y:t.y}]}}class gg extends $n{makeupProps(t,e,n,o,s){const a=s?s.toLocal(n):n,c=S.computeShapeCategory(v.CheckboxText),h=an[c],d=So[c];return[ie.create({x:a.x,y:a.y,width:16,height:16}),tt.create({color:d,alpha:o}),Ae.create({color:h,alpha:o}),Qt.create({checkStatus:!0})]}}class yg extends $n{makeupProps(t,e,n,o,s){const a=s?s.toLocal(n):n,c=S.computeShapeCategory(v.CheckboxText),h=an[c],d=So[c];return[ie.create({x:a.x,y:a.y,width:102,height:32}),tt.create({color:d,alpha:o}),Ae.create({color:h,alpha:o}),Ge.create({type:I.Text,fontSize:16,richText:"<root><p>Checkbox</p></root>",sizeMode:We.autoWidth,horizonAlign:at.Top,verticalAlign:at.Top}),new Qt]}}class xg extends $n{makeupProps(t,e,n,o,s){Pe.Section;const r=s?s.toLocal(n):n;return[ie.create({x:r.x,y:r.y,width:200,height:180})]}}class wg{constructor(){p(this,"creatorMap",new Map([[v.Shape,new ug],[v.Section,new pg],[v.Line,new fg],[v.Checkbox,new gg],[v.CheckboxText,new yg],[v.SlideContainer,new xg]]))}getCreateHandler(t){return this.creatorMap.get(t)}makeupDefaultProps(t,e,n,o,s){const r=this.getCreateHandler(t);if(!r)throw new Error(`No create handler found for shape type: ${t}`);return r.makeupDefaultProps(e,n,o,s)}makeupPreviewProps(t,e,n,o){const s=this.getCreateHandler(t);if(!s)throw new Error(`No create handler found for shape type: ${t}`);return s.makePreviewProps(e,n,o)}}class Pg{constructor(){p(this,"prevDevicePixelRatio",window.devicePixelRatio)}resize(t){const e=window.devicePixelRatio;this.resizeCanvas(t.gmlRender,e),this.resizeCanvas(t.auxiliaryManager.gmlRender,e),t.renderManager.addAuxiliaryDrawTask(),t.renderManager.addContentRenderTask(),this.prevDevicePixelRatio=e}resizeCanvas(t,e){t.canvas.width=e*t.canvas.clientWidth,t.canvas.height=e*t.canvas.clientHeight;const n=t.glCtx;if(Math.abs(this.prevDevicePixelRatio-e)>.001){const h=t.transformToGlobal(new P);t.scale(e/this.prevDevicePixelRatio,e/this.prevDevicePixelRatio,h)}const{a:o,b:s,c:r,d:i,e:a,f:c}=t.globalTransform;n.setTransform(o,s,r,i,a,c)}}class jn{}class mg extends jn{handle(t,e){t.docState.resetSlideCovers();const n=t.docState;n.docMode=ue.SLIDE_EDIT,n.slideStatus.slideContainer=e,n.slideStatus.currentIndex=0,t.slotManager.addSlotState(ze.DocMode,{docMode:ue.SLIDE_EDIT});const s=n.slideStatus.slideContainer.slideProps.children[0].ids[0];t.focus(s,0,50),this.generateSlideCover(n.slideStatus,t)}async generateSlideCover(t,e){const n=t.slideContainer;if(!n)return;const o=n.slideProps.children;for(const s of o)for(const r of s.ids){const i=e.nodeManager.getNode(r);if(!i)continue;const a=await S.getSlideInfo(i,e);e.docState.slideStatus.slideCoverList.push(a),e.slotManager.addSlotState(ze.SlideCovers,{covers:e.docState.slideStatus.slideCoverList})}}}class bg extends jn{handle(t,e){const n=t.docState;n.docMode=ue.SLIDE_PLAY,n.slideStatus.slideContainer=e,n.slideStatus.currentIndex=0,t.docState.changePermission({canEdit:!1}),t.slotManager.addSlotState(ze.DocMode,{docMode:ue.SLIDE_PLAY});const s=n.slideStatus.slideContainer.slideProps.children[0].ids[0];t.focus(s)}}class Sg extends jn{handle(t){t.docState.resetSlideCovers();const e=t.docState;e.docMode=ue.SLIDE_EDIT,t.docState.changePermission({canEdit:!0}),t.slotManager.addSlotState(ze.DocMode,{docMode:ue.SLIDE_EDIT});const n=e.slideStatus.slideContainer;if(!n)return"";const o=e.slideStatus.currentIndex,s=n.getChildIdByIndex(o)||"";setTimeout(()=>{t.focus(s,0,50)},100)}}class Mg extends jn{handle(t,e){const n=t.docState;n.docMode=ue.BOARD,n.slideStatus.slideContainer=null,n.slideStatus.currentIndex=0,t.docState.changePermission({canEdit:!0}),t.slotManager.addSlotState(ze.DocMode,{docMode:ue.BOARD}),t.focus()}}class vg extends jn{handle(t){const e=t.docState;e.docMode=ue.SLIDE_PLAY,e.slideStatus.currentIndex=0,t.slotManager.addSlotState(ze.DocMode,{docMode:ue.SLIDE_PLAY}),t.docState.changePermission({canEdit:!1});const n=e.slideStatus.slideContainer;if(!n)return"";const o=n.getChildIdByIndex(0)||"";t.focus(o),t.docState.resetSlideCovers()}}class Ig extends jn{handle(t,e){const n=t.docState;n.docMode=ue.BOARD,n.slideStatus.slideContainer=null,n.slideStatus.currentIndex=0,t.slotManager.addSlotState(ze.DocMode,{docMode:ue.BOARD}),t.focus(),t.docState.resetSlideCovers()}}class Tg{constructor(){p(this,"currentMode",ue.BOARD);p(this,"prevMode",ue.BOARD);p(this,"switchHandlerMap",new Map);const t=new Map([[ue.SLIDE_EDIT,new mg],[ue.SLIDE_PLAY,new bg]]),e=new Map([[ue.SLIDE_EDIT,new Sg],[ue.BOARD,new Mg]]),n=new Map([[ue.SLIDE_PLAY,new vg],[ue.BOARD,new Ig]]);this.switchHandlerMap.set(ue.BOARD,t),this.switchHandlerMap.set(ue.SLIDE_PLAY,e),this.switchHandlerMap.set(ue.SLIDE_EDIT,n)}switchMode(t,e,n){if(this.prevMode=this.currentMode,this.currentMode=t,this.prevMode===this.currentMode)return;const o=this.switchHandlerMap.get(this.prevMode),s=o==null?void 0:o.get(this.currentMode);s&&n.slideContainer&&s.handle(e,n.slideContainer)}backToPrevMode(t,e){const n=this.prevMode;n!==this.currentMode&&this.switchMode(n,t,e)}}class Xc{constructor(t,e,n,o,s,r,i,a,c,h,d,u,f,g,y,m,b){p(this,"nodeManager");p(this,"gmlRender");p(this,"detectors");p(this,"toolManager");p(this,"inputManager");p(this,"actionManager");p(this,"renderManager");p(this,"auxiliaryManager");p(this,"lastInteractiveEvent",null);p(this,"lastDiffTypeEvent",null);p(this,"docState");p(this,"idGenerator");p(this,"cursorManager");p(this,"previewManager");p(this,"resourceManager");p(this,"slotManager");p(this,"asyncRenderNodeManager");p(this,"cropManager");p(this,"slideManager");p(this,"docModeManager");p(this,"alignPoint",null);p(this,"createWorker",new wg);p(this,"resizeWorker",new Pg);this.nodeManager=t,this.gmlRender=e,this.detectors=n,this.toolManager=o,this.inputManager=s,this.actionManager=r,this.renderManager=i,this.auxiliaryManager=a,this.cursorManager=new Oc,this.docState=c,this.idGenerator=h,this.cursorManager=d,this.previewManager=u,this.resourceManager=f,this.slotManager=g,this.asyncRenderNodeManager=y,this.cropManager=m,this.slideManager=b,this.docModeManager=new Tg}detect(t,e){const n=this.detectors.get(t);return!n||!n.detect(e,this)?null:n.result}resize(){this.resizeWorker.resize(this)}addOrUpdate(t,e){this.auxiliaryManager.addOrUpdate(t,e),this.renderManager.addAuxiliaryDrawTask()}removeAuxGraphic(t){this.auxiliaryManager.remove(t),this.renderManager.addAuxiliaryDrawTask()}setCursor(t,e){this.cursorManager.setCursor(t,e)}getSelectNodes(){return this.auxiliaryManager.selectManager.selectNodes}execAction(t){this.actionManager.execAction(t)}reset(){this.auxiliaryManager.removeHoverGraphics(),this.auxiliaryManager.removeAlignGraphics(),this.renderManager.addAuxiliaryDrawTask()}inSelect(t){if(this.auxiliaryManager.selectManager.selectNodes.size===0)return!1;const e=this.auxiliaryManager.selectManager.getSelectBounds();return S.rectContains2(t,e)}refreshEvent(t){}refreshAllSvgNode(){for(const[t,e]of this.nodeManager.nodeMap)e.type===v.SVG&&this.asyncRenderNodeManager.addRenderNode(e)}zoomScale(t,e){this.renderManager.zoomScale(t,e)}focus(t,e=0,n=0){if(t){this.renderManager.focusId=t;const o=this.nodeManager.getNode(t);if(o&&o.id!==Sn){const s=new Set;S.getAllChildren(o,s);const r=o.getBounds();r.maxY+=e,r.maxX+=e,r.minX-=e,r.minX-=e,this.renderManager.zoomWorker.zoomToBounds(r,this.renderManager,n)}}else{const o=this.docState.slideStatus.slideContainer;o?(this.execAction(new W),this.execAction(xe.create([o.id])),this.execAction(new z),this.renderManager.zoomToSelect()):this.renderManager.zoomToFit(),this.renderManager.focusId=void 0}this.renderManager.addContentRenderTask(),this.renderManager.addAuxiliaryDrawTask()}}class zc{addImageNode(t,e,n,o,s){const r=[{type:I.Base,x:o.x,y:o.y,width:e,height:n},{type:I.Image,url:t},{type:I.Border,dashType:et.None}],i=s.idGenerator.genId(v.IMG),a={id:i,type:v.IMG,zIndex:ve.genZIndex(s.nodeManager.root),parentId:"",props:r};s.execAction(new W);const c=Le.create(a);s.execAction(c),s.execAction(xe.create([i])),s.execAction(new z)}}const Qn=class Qn{static encode(t){const e=encodeURI(t),n=btoa(e);return`<html>
6
22
  <head><meta charset="utf-8"></head>
7
23
  <body>
8
- <div style="white-space: pre-wrap" data-info=${rs.oolongLeft}${n}${rs.oolongRight}/>
24
+ <div style="white-space: pre-wrap" data-info=${Qn.oolongLeft}${n}${Qn.oolongRight}/>
9
25
  </body>
10
- </html>`}static decode(e){const t=e.indexOf(this.oolongLeft),n=e.indexOf(this.oolongRight);if(t<0||n<0||t===n)return null;const s=e.slice(t+this.oolongLeft.length,n),r=atob(s);return decodeURI(r)}};g(rs,"oolongLeft","start--oolong--"),g(rs,"oolongRight","--oolong--end");let kn=rs;class rp{constructor(){g(this,"copyWorker",new to)}copy(e,t){if(!e.clipboardData)return!1;const n=this.copyWorker.work(t);if(!n)return!1;e.preventDefault();const s=JSON.stringify(n),r=kn.encode(s);return e.clipboardData.setData("text/html",r),!0}}class op extends bs{handle(e,t,n,s){const r=e.find(a=>a.type===R.Image);if(!r)return;const o=r.url,i=s.get(o);i?r.url=i:(console.error("复制图片时该图片资源失效!",i),r.url="")}}class ip extends bs{handle(e,t,n,s){const r=e.find(a=>a.type===R.Svg);if(!r)return;const o=r.url,i=s.get(o);i?r.url=i:(console.error("复制svg时该svg资源失效!",i),r.url="")}}class ap extends va{constructor(){super(...arguments);g(this,"propsHandler",[new ma,new wa,new xa,new op,new ip])}}class vo{constructor(){g(this,"pasteWorker",new Ma);g(this,"crossPagePasteWorker",new ap)}handle(e,t){const n=t.docState.docId;return e.meta.docId!==n?this.handleCrossPaste(e,t):this.handlePaste(e,t)}handlePaste(e,t){return!e.nodes||e.nodes.length===0?!1:(this.normalPaste(e,t,this.pasteWorker),!0)}handleCrossPaste(e,t){return!e.nodes||e.nodes.length===0?!1:(this.pasteResourceInfo(e.resources,e.meta.docId,t).then(n=>{n||console.error("复制图片资源时出现错误!"),this.normalPaste(e,t,this.crossPagePasteWorker,n==null?void 0:n.resourceMap)}),!0)}normalPaste(e,t,n,s){const r=e.nodes,o=e.bounds,i=t.lastInteractiveEvent.globalPoint,a=new m(i.x-o.x,i.y-o.y);t.execAction(new nt);const{addNodeData:c,nextFocusIds:h}=n.work(t,r,a,s);t.execAction(new Yt(c)),t.execAction(Pt.create(h)),t.execAction(new et)}async pasteResourceInfo(e,t,n){return e.length===0?void 0:await n.resourceManager.copyImage(e,t,n.docState.docId)}}class cp{constructor(){g(this,"handlers",[new vo])}paste(e,t){const n=e.clipboardData,s=n==null?void 0:n.getData("text/html");if(!s)return!1;const r=kn.decode(s);if(r===null)return!1;const o=JSON.parse(r);for(const i of this.handlers)if(i.handle(o,t))return!0;return!1}}class lp{paste(e,t){const n=e.clipboardData,s=n==null?void 0:n.getData("text/plain");if(!s)return!1;const r=this.getSvgCode(s);if(r===null)return!1;const o=t.docState.docId,i=lr(10),a=`${o}/${i}`,c=$n.trimSvgCode(r);return t.resourceManager.uploadSvgString(a,c.svgCode).then(h=>{this.addSvgNode(t,c,h)}),!0}addSvgNode(e,t,n){var c;const s=((c=e.lastInteractiveEvent)==null?void 0:c.globalPoint)||new m,r=[{type:R.Base,x:s.x,y:s.y,width:t.width,height:t.height},{type:R.Svg,url:n},{type:R.Border,dashType:Ee.None}],o=e.idGenerator.genId(A.SVG),i={id:o,type:A.SVG,zIndex:Qt.genZIndex(e.nodeManager.root),parentId:"",props:r};e.execAction(new nt);const a=Yt.create(i);e.execAction(a),e.execAction(Pt.create([o])),e.execAction(new et)}getSvgCode(e){const t=e.indexOf("<svg"),n=e.indexOf("svg>");return t<0||n<0||t===n?null:e.slice(t,n+4)}}class hp{constructor(){g(this,"worker",new lc)}paste(e,t){if(!e.clipboardData)return!1;const n=e.clipboardData.items;for(let s=0;s<n.length;s++){const r=n[s];if(r.type.startsWith("image/")){const o=r.getAsFile();return o?(this.pasteImg(o,t),!0):!1}}return!1}async pasteImg(e,t){const n=lr(10),s=`${t.docState.docId}/${n}`,r=await t.resourceManager.uploadFileBlob(s,e),{width:o,height:i}=await ac.getImageSize(e),a=t.lastInteractiveEvent.globalPoint;this.worker.addImageNode(r,o,i,a,t)}}class hc{constructor(e){g(this,"eventCtx");g(this,"pasteHandlers");g(this,"copyHandlers");this.eventCtx=e,this.pasteHandlers=[new hp,new cp,new lp],this.copyHandlers=[new rp]}paste(e){for(const t of this.pasteHandlers)if(t.paste(e,this.eventCtx))return}copy(e){for(const t of this.copyHandlers)if(t.copy(e,this.eventCtx))return}cut(e){console.log(e)}}class dc{constructor(e){g(this,"eventCtx");g(this,"copyPasteManager");g(this,"onCopy",e=>{this.onEnable()&&this.copyPasteManager.copy(e)});g(this,"onPaste",e=>{this.onEnable()&&this.copyPasteManager.paste(e)});g(this,"onCut",e=>{this.onEnable()&&this.copyPasteManager.cut(e)});this.eventCtx=e,this.copyPasteManager=new hc(e)}start(){document.addEventListener("copy",this.onCopy),document.addEventListener("paste",this.onPaste),document.addEventListener("cut",this.onCut)}stop(){document.removeEventListener("copy",this.onCopy),document.removeEventListener("paste",this.onPaste),document.removeEventListener("cut",this.onCut)}onEnable(){return this.eventCtx.docState.canEdit()}}class dp{constructor(e){g(this,"app");this.app=e}async copySelectNodes(){const t=new to().work(this.app.appContext);if(!t)return!1;const n=JSON.stringify(t),s=kn.encode(n),r=new Blob([s],{type:"text/html"}),o=new ClipboardItem({"text/html":r});await navigator.clipboard.write([o])}copySelectNodesAsPng(e=2,t=""){const s=this.app.appContext.auxiliaryManager.selectManager.getSelectBounds(),r=this.app.renderManager.exportOfflineCanvas(s,e,t);return new Promise(o=>{r.toBlob(async i=>{if(!i){console.error("转化为图片时候出现错误.");return}const a=new ClipboardItem({[i.type]:i});await navigator.clipboard.write([a]),o()})})}async pasteNodes(){try{const e=this.app.appContext,t=await navigator.clipboard.read();for(const n of t)if(n.types.includes("text/html")){const r=await(await n.getType("text/html")).text();if(!r)return;const o=kn.decode(r);if(o===null)return;const i=JSON.parse(o);new vo().handle(i,e);return}console.log("剪贴板中没有可用的文本数据")}catch(e){console.error("读取剪贴板失败:",e),alert("粘贴失败,请检查权限或使用 Ctrl+V")}}}class Mo{work(e){const t=[...e.getSelectNodes()];if(t.length===0)return;const n=new Set;for(const s of t)n.add(s.id),e.nodeManager.getNodeLinks(s).forEach(o=>n.add(o.id)),this.addAllChildren(s,n);e.actionManager.execAction(new nt),e.actionManager.execAction(Pt.create([])),e.actionManager.execAction(Fe.create([...n])),e.actionManager.execAction(new et)}addAllChildren(e,t){t.add(e.id);for(const n of e.children)this.addAllChildren(n,t)}}class up{constructor(e){g(this,"app");this.app=e}intoCrop(){new vs().intoCrop(this.app.appContext)}exitCrop(){new vs().exitCrop(this.app.appContext)}resetCrop(){new vs().resetCrop(this.app.appContext)}}class uc{constructor(e){g(this,"app");g(this,"create");g(this,"image");g(this,"copyPaste");g(this,"crop");this.app=e,this.create=new np(e),this.image=new sp(e),this.copyPaste=new dp(e),this.crop=new up(e)}zoomScale(e,t){this.app.renderManager.zoomScale(e,t,this.app.asyncRenderNodeManager)}zoomToFit(){this.app.renderManager.zoomToFit(this.app.asyncRenderNodeManager)}zoomToSelect(){this.app.renderManager.zoomToSelect(this.app.asyncRenderNodeManager)}zoomTo100(){this.app.renderManager.zoomTo100(this.app.asyncRenderNodeManager)}exportOfflineCanvas(e,t,n=""){return this.app.renderManager.exportOfflineCanvas(e,t,n)}exportAllNodesImg(e,t=""){const n=this.app.nodeManager.getNodeBounds();return this.app.renderManager.exportOfflineCanvas(n,e,t)}scroll(e,t){this.app.renderManager.scroll(e,t)}registerCallback(e,t){this.app.slotManager.registerSlotCallback(e,t)}changePermission({canEdit:e}){this.app.docState.userPermission.canEdit=e}getBounds(){const e=this.app.renderManager.gmlRender.getViewPortBounds();return D.rectNode2Rect(e)}getScale(){return this.app.renderManager.getScale()}transformToClientPos(e){return this.app.gmlRender.transformToLocal(e)}getFocusList(){return this.app.auxiliaryManager.selectManager.getSelectNodes()}setPrefix(e){this.app.idGenerator.setPrefix(e)}clearFocus(){if(this.app.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const e=this.app.appContext;if(e.execAction(new nt),e.inputManager.editTextInfo){const{node:t}=e.inputManager.editTextInfo;e.execAction(lt.blur(t.id))}e.execAction(Pt.create([])),e.execAction(new et)}makeGroup(){const e=[...this.app.appContext.getSelectNodes()];new gr().group(e,this.app.appContext)}makeUnGroup(){const e=[...this.app.appContext.getSelectNodes()];if(e.length!==1)return;const t=e[0];if(t.type!==A.Group)return;const n=t;new gr().unGroup(n,this.app.appContext)}getImageBlobUrl(e){return this.app.resourceManager.getBlobUrl(e)}deleteSelectNodes(){new Mo().work(this.app.appContext)}}class pp{constructor(e){g(this,"renderDom",null);g(this,"inputDom",null);g(this,"isFocusing",!1);g(this,"cursorManager");this.cursorManager=e}init(e,t){this.inputDom=e,this.renderDom=t}focus(){setTimeout(()=>{this.inputDom.focus()},100),this.isFocusing=!0,this.cursorManager.setCursor("text")}blur(){this.isFocusing=!1,this.inputDom.blur(),this.renderDom.style.display="none"}hideRenderDom(){this.renderDom.style.display="none"}updateCursor(e,t,n,s){const r=t.globalTransform.crossPoint(e),o=t.canvas.getBoundingClientRect(),i=window.devicePixelRatio;let a=r.x/i+o.x,c=r.y/i+o.y;a>o.width&&(a=0),c>o.height&&(c=0),this.renderDom.style.left=a+"px",this.renderDom.style.top=c+"px",this.inputDom.style.left=a+"px",this.inputDom.style.top=c+"px",this.renderDom.style.transform=`rotate(${s}deg)`,this.renderDom.style.transformOrigin="top left",this.renderDom.style.display="unset",this.renderDom.style.height=n*t.getScale()+"px"}}class fp{constructor(){g(this,"selectionInfo",null);g(this,"selectionWorker",new oc)}clear(){this.selectionInfo=null}generateSelect(e,t,n){const s=this.selectionWorker.computeTextSelection(e,t,n);return s.length===0?[]:(this.selectionInfo={start:t,end:n,selectionList:s},s)}}class gp{constructor(e,t){g(this,"renderInput");g(this,"editTextInfo",null);g(this,"selectionManager",new fp);g(this,"renderManager");this.renderInput=new pp(t),this.renderManager=e}init(e,t){var n;(n=this.renderInput)==null||n.init(e,t),this.renderInput.hideRenderDom()}isEdit(){return this.editTextInfo!==null}hasSelection(){return this.selectionManager.selectionInfo!==null}checkNeedReFocusInputDom(e){return!this.editTextInfo||this.editTextInfo.node.id!==e.node.id||!this.editTextInfo.textCursorPosition.equal(e.textCursorPosition)}focus(e){const t=this.checkNeedReFocusInputDom(e);this.editTextInfo=e;const{node:n,renderText:s,textCursorPosition:r}=e,{relativePos:o,height:i}=s.getPosByCursorPosition(r),a=n.toGlobal(o);t&&(this.renderInput.focus(),console.log("njx debug:===>focus")),this.renderInput.updateCursor(a,this.renderManager.gmlRender,i,n.baseProps.angle),this.selectionManager.clear()}selection(e,t,n,s){let r=n,o=s;s.greaterThan(n)||(r=s,o=n),this.editTextInfo={node:e,renderText:t,textCursorPosition:r};const i=this.selectionManager.generateSelect(t,r,o);return this.renderInput.focus(),this.renderInput.hideRenderDom(),i}refreshCursor(){if(!this.editTextInfo)return;const{node:e,renderText:t,textCursorPosition:n}=this.editTextInfo,{relativePos:s,height:r}=t.getPosByCursorPosition(n),o=e.toGlobal(s);this.renderInput.updateCursor(o,this.renderManager.gmlRender,r,e.baseProps.angle)}updateCursorPos(e){this.editTextInfo&&(this.editTextInfo.textCursorPosition=e,this.refreshCursor())}blur(){var e;console.log("====>blur"),this.selectionManager.selectionInfo&&this.selectionManager.clear(),this.editTextInfo&&(this.editTextInfo.node.resetFromEditing(),this.renderManager.addContentRenderTask(),(e=this.renderInput)==null||e.blur(),this.editTextInfo=null)}}class yp{constructor(e,t){g(this,"docState");g(this,"nodeManager");this.docState=t,this.nodeManager=e}serializeTo(){const e=[],t=this.nodeManager;for(const[s,r]of t.nodeMap)e.push(r.serializeTo());return{documentId:"",nodes:e}}deSerialize(e){return JSON.parse(e)}}class pc{constructor(){g(this,"canEdit",!0)}}class fc{constructor(){g(this,"seq",0);g(this,"savedSeq",-1);g(this,"backgroundColor","#EEEEEE");g(this,"userid","");g(this,"sessionId","");g(this,"docId","");g(this,"userPermission",new pc)}load(e){this.backgroundColor=e.backgroundColor,this.seq=e.seq,this.savedSeq=e.savedSeq}canEdit(){return this.userPermission.canEdit}changePermission({canEdit:e}){this.userPermission.canEdit=e}}function mp(){return{backgroundColor:"#EEEEEE",seq:0,savedSeq:0}}class gc{}class So{constructor(){g(this,"globalTransform",Z.generateMatrix());g(this,"canvas",null);g(this,"glCtx",null);this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}init(e){this.canvas=e;const t=this.canvas.getContext("2d");this.glCtx=t;const{a:n,b:s,c:r,d:o,e:i,f:a}=this.globalTransform;t.transform(n,s,r,o,i,a)}setTransform(e,t,n,s,r,o){this.globalTransform.setTransform(e,t,n,s,r,o),this.glCtx.setTransform(e,t,n,s,r,o)}reset(){if(!this.canvas){console.error("Error! The canvas is null!");return}const e=this.canvas.getContext("2d"),{a:t,b:n,c:s,d:r,e:o,f:i}=this.globalTransform;e.setTransform(t,n,s,r,o,i)}scale(e,t,n){if(!n){this.globalTransform.a*=e,this.globalTransform.d*=t;return}const s=Z.generateMatrix().translate(-n.x,-n.y),r=Z.generateMatrix().scale(e,e),i=Z.generateMatrix().translate(n.x,n.y).crossProduct(r).crossProduct(s);this.globalTransform=this.globalTransform.crossProduct(i)}translation(e,t){const n=Z.generateMatrix().translate(e,t);this.globalTransform=this.globalTransform.crossProduct(n)}resetTransform(){this.globalTransform=Z.generateMatrix(),this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}transformToLocal(e){const{a:t,b:n,c:s,d:r,e:o,f:i}=this.globalTransform;return e.x=t*e.x+s*e.y+o,e.y=n*e.x+r*e.y+i,e.x=e.x/window.devicePixelRatio,e.y=e.y/window.devicePixelRatio,e}transformToGlobal(e){const t=new m(e.x,e.y);t.x=t.x*window.devicePixelRatio,t.y=t.y*window.devicePixelRatio;const{a:n,d:s,e:r,f:o}=this.globalTransform;return t.x=t.x/n-r/n,t.y=t.y/s-o/s,t}dirtyDraw(e,t){const n=this.canvas.getContext("2d");n.clearRect(e.minX,e.minY,e.maxX-e.minX,e.maxY-e.minY),n.save(),n.beginPath(),n.rect(e.minX,e.minY,e.maxX-e.minX,e.maxY-e.minY),n.clip();for(const s of t)s.draw();n.restore()}getViewPortBounds(){const e=this.canvas.getBoundingClientRect(),t=new m(e.width,e.height),n=this.transformToGlobal(new m(0,0)),s=this.transformToGlobal(t);return{id:"rect",minX:n.x,minY:n.y,maxX:s.x,maxY:s.y}}getGlobalPoint(e){const t=this.canvas.getBoundingClientRect(),n=new m(e.clientX-t.x,e.clientY-t.y);return this.transformToGlobal(n)}getScale(){const e=window.devicePixelRatio;return this.globalTransform.a/e}scaleToCenter(e){const t=this.getScale(),n=e/t,s=this.getViewPortBounds(),r=new m(.5*(s.minX+s.maxX),.5*(s.minY+s.maxY));this.scale(n,n,r)}}function wp(l,e,t,n,s){yc(l,e,t||0,n||l.length-1,s||xp)}function yc(l,e,t,n,s){for(;n>t;){if(n-t>600){var r=n-t+1,o=e-t+1,i=Math.log(r),a=.5*Math.exp(2*i/3),c=.5*Math.sqrt(i*a*(r-a)/r)*(o-r/2<0?-1:1),h=Math.max(t,Math.floor(e-o*a/r+c)),d=Math.min(n,Math.floor(e+(r-o)*a/r+c));yc(l,e,h,d,s)}var u=l[e],p=t,f=n;for(Cs(l,t,e),s(l[n],u)>0&&Cs(l,t,n);p<f;){for(Cs(l,p,f),p++,f--;s(l[p],u)<0;)p++;for(;s(l[f],u)>0;)f--}s(l[t],u)===0?Cs(l,t,f):(f++,Cs(l,f,n)),f<=e&&(t=f+1),e<=f&&(n=f-1)}}function Cs(l,e,t){var n=l[e];l[e]=l[t],l[t]=n}function xp(l,e){return l<e?-1:l>e?1:0}class Pp{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!mr(e,t))return n;const s=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){const i=t.children[o],a=t.leaf?s(i):i;mr(e,a)&&(t.leaf?n.push(i):Co(e,a)?this._all(i,n):r.push(i))}t=r.pop()}return n}collides(e){let t=this.data;if(!mr(e,t))return!1;const n=[];for(;t;){for(let s=0;s<t.children.length;s++){const r=t.children[s],o=t.leaf?this.toBBox(r):r;if(mr(e,o)){if(t.leaf||Co(e,o))return!0;n.push(r)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let n=0;n<e.length;n++)this.insert(e[n]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const n=this.data;this.data=t,t=n}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Zn([]),this}remove(e,t){if(!e)return this;let n=this.data;const s=this.toBBox(e),r=[],o=[];let i,a,c;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],i=o.pop(),c=!0),n.leaf){const h=bp(e,n.children,t);if(h!==-1)return n.children.splice(h,1),r.push(n),this._condense(r),this}!c&&!n.leaf&&Co(n,s)?(r.push(n),o.push(i),i=0,a=n,n=n.children[0]):a?(i++,n=a.children[i],c=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,s){const r=n-t+1;let o=this._maxEntries,i;if(r<=o)return i=Zn(e.slice(t,n+1)),Qn(i,this.toBBox),i;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),i=Zn([]),i.leaf=!1,i.height=s;const a=Math.ceil(r/o),c=a*Math.ceil(Math.sqrt(o));mc(e,t,n,c,this.compareMinX);for(let h=t;h<=n;h+=c){const d=Math.min(h+c-1,n);mc(e,h,d,a,this.compareMinY);for(let u=h;u<=d;u+=a){const p=Math.min(u+a-1,d);i.children.push(this._build(e,u,p,s-1))}}return Qn(i,this.toBBox),i}_chooseSubtree(e,t,n,s){for(;s.push(t),!(t.leaf||s.length-1===n);){let r=1/0,o=1/0,i;for(let a=0;a<t.children.length;a++){const c=t.children[a],h=To(c),d=Sp(e,c)-h;d<o?(o=d,r=h<r?h:r,i=c):d===o&&h<r&&(r=h,i=c)}t=i||t.children[0]}return t}_insert(e,t,n){const s=n?e:this.toBBox(e),r=[],o=this._chooseSubtree(s,this.data,t,r);for(o.children.push(e),As(o,s);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(s,r,t)}_split(e,t){const n=e[t],s=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,s);const o=this._chooseSplitIndex(n,r,s),i=Zn(n.children.splice(o,n.children.length-o));i.height=n.height,i.leaf=n.leaf,Qn(n,this.toBBox),Qn(i,this.toBBox),t?e[t-1].children.push(i):this._splitRoot(n,i)}_splitRoot(e,t){this.data=Zn([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Qn(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let s,r=1/0,o=1/0;for(let i=t;i<=n-t;i++){const a=Ls(e,0,i,this.toBBox),c=Ls(e,i,n,this.toBBox),h=Tp(a,c),d=To(a)+To(c);h<r?(r=h,s=i,o=d<o?d:o):h===r&&d<o&&(o=d,s=i)}return s||n-t}_chooseSplitAxis(e,t,n){const s=e.leaf?this.compareMinX:vp,r=e.leaf?this.compareMinY:Mp,o=this._allDistMargin(e,t,n,s),i=this._allDistMargin(e,t,n,r);o<i&&e.children.sort(s)}_allDistMargin(e,t,n,s){e.children.sort(s);const r=this.toBBox,o=Ls(e,0,t,r),i=Ls(e,n-t,n,r);let a=yr(o)+yr(i);for(let c=t;c<n-t;c++){const h=e.children[c];As(o,e.leaf?r(h):h),a+=yr(o)}for(let c=n-t-1;c>=t;c--){const h=e.children[c];As(i,e.leaf?r(h):h),a+=yr(i)}return a}_adjustParentBBoxes(e,t,n){for(let s=n;s>=0;s--)As(t[s],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():Qn(e[t],this.toBBox)}}function bp(l,e,t){if(!t)return e.indexOf(l);for(let n=0;n<e.length;n++)if(t(l,e[n]))return n;return-1}function Qn(l,e){Ls(l,0,l.children.length,e,l)}function Ls(l,e,t,n,s){s||(s=Zn(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=e;r<t;r++){const o=l.children[r];As(s,l.leaf?n(o):o)}return s}function As(l,e){return l.minX=Math.min(l.minX,e.minX),l.minY=Math.min(l.minY,e.minY),l.maxX=Math.max(l.maxX,e.maxX),l.maxY=Math.max(l.maxY,e.maxY),l}function vp(l,e){return l.minX-e.minX}function Mp(l,e){return l.minY-e.minY}function To(l){return(l.maxX-l.minX)*(l.maxY-l.minY)}function yr(l){return l.maxX-l.minX+(l.maxY-l.minY)}function Sp(l,e){return(Math.max(e.maxX,l.maxX)-Math.min(e.minX,l.minX))*(Math.max(e.maxY,l.maxY)-Math.min(e.minY,l.minY))}function Tp(l,e){const t=Math.max(l.minX,e.minX),n=Math.max(l.minY,e.minY),s=Math.min(l.maxX,e.maxX),r=Math.min(l.maxY,e.maxY);return Math.max(0,s-t)*Math.max(0,r-n)}function Co(l,e){return l.minX<=e.minX&&l.minY<=e.minY&&e.maxX<=l.maxX&&e.maxY<=l.maxY}function mr(l,e){return e.minX<=l.maxX&&e.minY<=l.maxY&&e.maxX>=l.minX&&e.maxY>=l.minY}function Zn(l){return{children:l,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function mc(l,e,t,n,s){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=n)continue;const o=e+Math.ceil((t-e)/n/2)*n;wp(l,o,e,t,s),r.push(e,o,o,t)}}class wc extends gc{constructor(){super();g(this,"root");g(this,"previewRoot");g(this,"nodeMap");g(this,"tree");g(this,"linkMap");this.nodeMap=new Map,this.tree=new Pp,this.root=new bo(Un),this.previewRoot=new bo(Qo),this.linkMap=new Map}clear(){this.tree.clear(),this.nodeMap.clear()}searchNodesByRectNode(t){const{minY:n,minX:s,maxY:r,maxX:o}=t;return this.searchNodes(s,n,o,r)}searchNodes(t,n,s=t,r=n){const o={id:"pointer",minX:t,minY:n,maxX:s,maxY:r},i=this.tree.search(o),a=[];for(const c of i){const h=this.nodeMap.get(c.id);h&&a.push(h)}return a}getParentNode(t){const n=this.nodeMap.get(t);return n||this.root}getNode(t){if(t===Un)return this.root;const n=this.nodeMap.get(t);return n||null}addNode(t){this.nodeMap.set(t.id,t),this.addIndexNode(t.getRectNode())}removeNode(t){const n=this.getNode(t);if(!n){console.warn("警告:删除节点不存在:",t);return}this.nodeMap.delete(t),this.removeIndexNode(n.getRectNode()),n.type===A.Line&&this.linkMap.delete(n)}removeIndexNode(t){this.tree.remove(t,(n,s)=>n.id===s.id)}addIndexNode(t){this.tree.insert(t)}getNodeBounds(){const t=[];for(const[n,s]of this.nodeMap)t.push(s.getRectNode());return T.getBounds(t,"all-node-bounds")}addLink(t,n,s=!0){const r=this.linkMap.get(t);if(r){s?r.startNode=n:r.endNode=n,this.checkLinkLine(t);return}const o={startNode:null,endNode:null};s?o.startNode=n:o.endNode=n,this.linkMap.set(t,o),this.checkLinkLine(t)}checkLinkLine(t){const n=this.linkMap.get(t);n&&n.endNode===null&&n.startNode===null&&this.linkMap.delete(t)}getNodeLinks(t){const n=new Set;if(t.type===A.Line)return n;for(const[s,r]of this.linkMap){if(!s.getProp(R.Connect))continue;const{startNode:i,endNode:a}=r;i===t&&n.add(s),a===t&&n.add(s)}return n}}const os=class os{constructor(){g(this,"previewGraphics",[]);g(this,"createWorker",new Ua);g(this,"layoutHandler",new En);g(this,"inQuickPreview",!1)}enterQuickPreview(e,t,n){if(this.inQuickPreview){this.previewGraphics.length>0&&n.addOrUpdate(N.PreviewGraphics,{previewNodes:this.previewGraphics});return}this.inQuickPreview=!0,this.resetPreviewNode(n);const s=e.baseProps,r=e.toGlobal({x:t.x*s.width,y:t.y*s.height}),o=this.createWorker.computePreviewNodePos(e,t,n),i=this.createWorker.computeEndNodeRelative(e,t),a=this.makeupNodeProps(e,o),c=Ge.getInstance().create(os.PREVIEW_ID,A.Shape,0,a,n.nodeManager.previewRoot,n.gmlRender.glCtx);this.previewGraphics.push(c);const h=c.baseProps,d=c.toGlobal({x:i.x*h.width,y:i.y*h.height}),u={point:r,nodeConnect:{rect:D.rectNode2Rect(e.getBounds()),endType:T.computeNodeConnectEnd(t,e.baseProps.angle)}},p={point:d,nodeConnect:{rect:D.rectNode2Rect(c.getBounds()),endType:T.computeNodeConnectEnd(i,c.baseProps.angle)}},f=this.makeupLineProps(u,p),y=Ge.getInstance().create(os.PREVIEW_LINE_ID,A.Line,0,f,n.nodeManager.previewRoot,n.gmlRender.glCtx);this.previewGraphics.push(y),n.addOrUpdate(N.PreviewGraphics,{previewNodes:this.previewGraphics})}exitQuickPreview(e){this.resetPreviewNode(e),this.inQuickPreview=!1}resetPreviewNode(e){this.previewGraphics=[],e.nodeManager.previewRoot.children.clear()}makeupNodeProps(e,t){const n=e.baseProps,s=e.shapeType,r=t.x,o=t.y,i=e.colorProps,a=e.borderProps,c=[{type:R.Base,x:r,y:o,width:n.width,height:n.height,angle:n.angle},Jt.create({...i,alpha:.5}),Ot.create({...a,alpha:.5}),new jt(s)];if(e.type===A.Shape&&e.shapeType===_.PureText){const h=e.textProps;c.push(h.clone())}return c}makeupLineProps(e,t){const n=this.layoutHandler.layoutToPointsPro(e,t),s=D.rectNode2Rect(T.getBoundsByPoints(n));return[he.create(n),gt.create({x:s.x,y:s.y,width:s.width,height:s.height}),Ie.create({rArrow:we.Arrow}),new jt(Lt.RoundPolyLine),Ot.create({alpha:.5})]}};g(os,"PREVIEW_ID","quick_preview"),g(os,"PREVIEW_LINE_ID","quick_preview_line");let wr=os;class Lo{}class Cp extends Lo{enable(e){return e===ft.SHAPE}async handle(e,t){var a;const n=t.toolManager.shapeType,s=t.toolManager.grab,r=((a=t.lastInteractiveEvent)==null?void 0:a.globalPoint)||new m,o=this.makeupShapeDefaultProps(n,r,s);return Ge.getInstance().create(e,A.Shape,0,o,t.nodeManager.previewRoot,t.gmlRender.glCtx)}makeupShapeDefaultProps(e,t,n){const s=rr[e]??Tt.Others,r=Nn[s],o=hn[s],i=100,a=100,c=n?t.x-.5*i:t.x,h=n?t.y-.5*a:t.y;return[gt.create({x:c,y:h,width:i,height:a}),se.create({type:R.Text,fontSize:16,text:"",sizeMode:le.autoHeight}),Jt.create({color:r,alpha:.5}),Ot.create({color:o,alpha:.5}),new jt(e)]}}class Lp extends Lo{enable(e){return e===ft.SECTION}async handle(e,t){var a;const n=t.toolManager.grab,s=t.toolManager.shapeType,r=((a=t.lastInteractiveEvent)==null?void 0:a.globalPoint)||new m,o=this.makeupShapeDefaultProps(r,n,s);return Ge.getInstance().create(e,A.Section,0,o,t.nodeManager.previewRoot,t.gmlRender.glCtx)}makeupShapeDefaultProps(e,t,n){const s=Tt.Section,r=Nn[s],o=hn[s],i=cr[n],a=i.width,c=i.height,h=t?e.x-.5*a:e.x,d=t?e.y-.5*c:e.y;return[gt.create({x:h,y:d,width:a,height:c}),Jt.create({color:r,alpha:.5}),Ot.create({color:o,alpha:.5})]}}var xr={exports:{}},Rs={exports:{}};(function(){var l,e,t,n,s,r;typeof performance<"u"&&performance!==null&&performance.now?Rs.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(Rs.exports=function(){return(l()-s)/1e6},e=process.hrtime,l=function(){var o;return o=e(),o[0]*1e9+o[1]},n=l(),r=process.uptime()*1e9,s=n-r):Date.now?(Rs.exports=function(){return Date.now()-t},t=Date.now()):(Rs.exports=function(){return new Date().getTime()-t},t=new Date().getTime())}).call(An);for(var Ap=Rs.exports,Rp=Ap,$e=typeof window>"u"?An:window,Pr=["moz","webkit"],Jn="AnimationFrame",ts=$e["request"+Jn],Ns=$e["cancel"+Jn]||$e["cancelRequest"+Jn],Es=0;!ts&&Es<Pr.length;Es++)ts=$e[Pr[Es]+"Request"+Jn],Ns=$e[Pr[Es]+"Cancel"+Jn]||$e[Pr[Es]+"CancelRequest"+Jn];if(!ts||!Ns){var Ao=0,xc=0,Bn=[],Np=1e3/60;ts=function(l){if(Bn.length===0){var e=Rp(),t=Math.max(0,Np-(e-Ao));Ao=t+e,setTimeout(function(){var n=Bn.slice(0);Bn.length=0;for(var s=0;s<n.length;s++)if(!n[s].cancelled)try{n[s].callback(Ao)}catch(r){setTimeout(function(){throw r},0)}},Math.round(t))}return Bn.push({handle:++xc,callback:l,cancelled:!1}),xc},Ns=function(l){for(var e=0;e<Bn.length;e++)Bn[e].handle===l&&(Bn[e].cancelled=!0)}}xr.exports=function(l){return ts.call($e,l)},xr.exports.cancel=function(){Ns.apply($e,arguments)},xr.exports.polyfill=function(l){l||(l=$e),l.requestAnimationFrame=ts,l.cancelAnimationFrame=Ns};var Ep=xr.exports;const Ro=eo(Ep);var Ip=function(l){this.ok=!1,this.alpha=1,l.charAt(0)=="#"&&(l=l.substr(1,6)),l=l.replace(/ /g,""),l=l.toLowerCase();var e={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};l=e[l]||l;for(var t=[{re:/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*((?:\d?\.)?\d)\)$/,example:["rgba(123, 234, 45, 0.8)","rgba(255,234,245,1.0)"],process:function(a){return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),parseFloat(a[4])]}},{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(a){return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3])]}},{re:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,example:["#00ff00","336699"],process:function(a){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16)]}},{re:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,example:["#fb0","f0f"],process:function(a){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)]}}],n=0;n<t.length;n++){var s=t[n].re,r=t[n].process,o=s.exec(l);if(o){var i=r(o);this.r=i[0],this.g=i[1],this.b=i[2],i.length>3&&(this.alpha=i[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var a=this.r.toString(16),c=this.g.toString(16),h=this.b.toString(16);return a.length==1&&(a="0"+a),c.length==1&&(c="0"+c),h.length==1&&(h="0"+h),"#"+a+c+h},this.getHelpXML=function(){for(var a=new Array,c=0;c<t.length;c++)for(var h=t[c].example,d=0;d<h.length;d++)a[a.length]=h[d];for(var u in e)a[a.length]=u;var p=document.createElement("ul");p.setAttribute("id","rgbcolor-examples");for(var c=0;c<a.length;c++)try{var f=document.createElement("li"),y=new RGBColor(a[c]),w=document.createElement("div");w.style.cssText="margin: 3px; border: 1px solid black; background:"+y.toHex()+"; color:"+y.toHex(),w.appendChild(document.createTextNode("test"));var b=document.createTextNode(" "+a[c]+" -> "+y.toRGB()+" -> "+y.toHex());f.appendChild(w),f.appendChild(b),p.appendChild(f)}catch{}return p}};const No=eo(Ip);/*! *****************************************************************************
11
- Copyright (c) Microsoft Corporation.
12
-
13
- Permission to use, copy, modify, and/or distribute this software for any
14
- purpose with or without fee is hereby granted.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
- PERFORMANCE OF THIS SOFTWARE.
23
- ***************************************************************************** */var Pc=function(l,e){return(Pc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])})(l,e)};function bc(l,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=l}Pc(l,e),l.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function kp(l){var e="";Array.isArray(l)||(l=[l]);for(var t=0;t<l.length;t++){var n=l[t];if(n.type===Y.CLOSE_PATH)e+="z";else if(n.type===Y.HORIZ_LINE_TO)e+=(n.relative?"h":"H")+n.x;else if(n.type===Y.VERT_LINE_TO)e+=(n.relative?"v":"V")+n.y;else if(n.type===Y.MOVE_TO)e+=(n.relative?"m":"M")+n.x+" "+n.y;else if(n.type===Y.LINE_TO)e+=(n.relative?"l":"L")+n.x+" "+n.y;else if(n.type===Y.CURVE_TO)e+=(n.relative?"c":"C")+n.x1+" "+n.y1+" "+n.x2+" "+n.y2+" "+n.x+" "+n.y;else if(n.type===Y.SMOOTH_CURVE_TO)e+=(n.relative?"s":"S")+n.x2+" "+n.y2+" "+n.x+" "+n.y;else if(n.type===Y.QUAD_TO)e+=(n.relative?"q":"Q")+n.x1+" "+n.y1+" "+n.x+" "+n.y;else if(n.type===Y.SMOOTH_QUAD_TO)e+=(n.relative?"t":"T")+n.x+" "+n.y;else{if(n.type!==Y.ARC)throw new Error('Unexpected command type "'+n.type+'" at index '+t+".");e+=(n.relative?"a":"A")+n.rX+" "+n.rY+" "+n.xRot+" "+ +n.lArcFlag+" "+ +n.sweepFlag+" "+n.x+" "+n.y}}return e}function Eo(l,e){var t=l[0],n=l[1];return[t*Math.cos(e)-n*Math.sin(e),t*Math.sin(e)+n*Math.cos(e)]}function Be(){for(var l=[],e=0;e<arguments.length;e++)l[e]=arguments[e];for(var t=0;t<l.length;t++)if(typeof l[t]!="number")throw new Error("assertNumbers arguments["+t+"] is not a number. "+typeof l[t]+" == typeof "+l[t]);return!0}var un=Math.PI;function Io(l,e,t){l.lArcFlag=l.lArcFlag===0?0:1,l.sweepFlag=l.sweepFlag===0?0:1;var n=l.rX,s=l.rY,r=l.x,o=l.y;n=Math.abs(l.rX),s=Math.abs(l.rY);var i=Eo([(e-r)/2,(t-o)/2],-l.xRot/180*un),a=i[0],c=i[1],h=Math.pow(a,2)/Math.pow(n,2)+Math.pow(c,2)/Math.pow(s,2);1<h&&(n*=Math.sqrt(h),s*=Math.sqrt(h)),l.rX=n,l.rY=s;var d=Math.pow(n,2)*Math.pow(c,2)+Math.pow(s,2)*Math.pow(a,2),u=(l.lArcFlag!==l.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(n,2)*Math.pow(s,2)-d)/d)),p=n*c/s*u,f=-s*a/n*u,y=Eo([p,f],l.xRot/180*un);l.cX=y[0]+(e+r)/2,l.cY=y[1]+(t+o)/2,l.phi1=Math.atan2((c-f)/s,(a-p)/n),l.phi2=Math.atan2((-c-f)/s,(-a-p)/n),l.sweepFlag===0&&l.phi2>l.phi1&&(l.phi2-=2*un),l.sweepFlag===1&&l.phi2<l.phi1&&(l.phi2+=2*un),l.phi1*=180/un,l.phi2*=180/un}function vc(l,e,t){Be(l,e,t);var n=l*l+e*e-t*t;if(0>n)return[];if(n===0)return[[l*t/(l*l+e*e),e*t/(l*l+e*e)]];var s=Math.sqrt(n);return[[(l*t+e*s)/(l*l+e*e),(e*t-l*s)/(l*l+e*e)],[(l*t-e*s)/(l*l+e*e),(e*t+l*s)/(l*l+e*e)]]}var Gt,Qe=Math.PI/180;function Mc(l,e,t){return(1-t)*l+t*e}function Sc(l,e,t,n){return l+Math.cos(n/180*un)*e+Math.sin(n/180*un)*t}function Tc(l,e,t,n){var s=1e-6,r=e-l,o=t-e,i=3*r+3*(n-t)-6*o,a=6*(o-r),c=3*r;return Math.abs(i)<s?[-c/a]:function(h,d,u){var p=h*h/4-d;if(p<-u)return[];if(p<=u)return[-h/2];var f=Math.sqrt(p);return[-h/2-f,-h/2+f]}(a/i,c/i,s)}function Cc(l,e,t,n,s){var r=1-s;return l*(r*r*r)+e*(3*r*r*s)+t*(3*r*s*s)+n*(s*s*s)}(function(l){function e(){return s(function(i,a,c){return i.relative&&(i.x1!==void 0&&(i.x1+=a),i.y1!==void 0&&(i.y1+=c),i.x2!==void 0&&(i.x2+=a),i.y2!==void 0&&(i.y2+=c),i.x!==void 0&&(i.x+=a),i.y!==void 0&&(i.y+=c),i.relative=!1),i})}function t(){var i=NaN,a=NaN,c=NaN,h=NaN;return s(function(d,u,p){return d.type&Y.SMOOTH_CURVE_TO&&(d.type=Y.CURVE_TO,i=isNaN(i)?u:i,a=isNaN(a)?p:a,d.x1=d.relative?u-i:2*u-i,d.y1=d.relative?p-a:2*p-a),d.type&Y.CURVE_TO?(i=d.relative?u+d.x2:d.x2,a=d.relative?p+d.y2:d.y2):(i=NaN,a=NaN),d.type&Y.SMOOTH_QUAD_TO&&(d.type=Y.QUAD_TO,c=isNaN(c)?u:c,h=isNaN(h)?p:h,d.x1=d.relative?u-c:2*u-c,d.y1=d.relative?p-h:2*p-h),d.type&Y.QUAD_TO?(c=d.relative?u+d.x1:d.x1,h=d.relative?p+d.y1:d.y1):(c=NaN,h=NaN),d})}function n(){var i=NaN,a=NaN;return s(function(c,h,d){if(c.type&Y.SMOOTH_QUAD_TO&&(c.type=Y.QUAD_TO,i=isNaN(i)?h:i,a=isNaN(a)?d:a,c.x1=c.relative?h-i:2*h-i,c.y1=c.relative?d-a:2*d-a),c.type&Y.QUAD_TO){i=c.relative?h+c.x1:c.x1,a=c.relative?d+c.y1:c.y1;var u=c.x1,p=c.y1;c.type=Y.CURVE_TO,c.x1=((c.relative?0:h)+2*u)/3,c.y1=((c.relative?0:d)+2*p)/3,c.x2=(c.x+2*u)/3,c.y2=(c.y+2*p)/3}else i=NaN,a=NaN;return c})}function s(i){var a=0,c=0,h=NaN,d=NaN;return function(u){if(isNaN(h)&&!(u.type&Y.MOVE_TO))throw new Error("path must start with moveto");var p=i(u,a,c,h,d);return u.type&Y.CLOSE_PATH&&(a=h,c=d),u.x!==void 0&&(a=u.relative?a+u.x:u.x),u.y!==void 0&&(c=u.relative?c+u.y:u.y),u.type&Y.MOVE_TO&&(h=a,d=c),p}}function r(i,a,c,h,d,u){return Be(i,a,c,h,d,u),s(function(p,f,y,w){var b=p.x1,x=p.x2,v=p.relative&&!isNaN(w),C=p.x!==void 0?p.x:v?0:f,E=p.y!==void 0?p.y:v?0:y;function k(H){return H*H}p.type&Y.HORIZ_LINE_TO&&a!==0&&(p.type=Y.LINE_TO,p.y=p.relative?0:y),p.type&Y.VERT_LINE_TO&&c!==0&&(p.type=Y.LINE_TO,p.x=p.relative?0:f),p.x!==void 0&&(p.x=p.x*i+E*c+(v?0:d)),p.y!==void 0&&(p.y=C*a+p.y*h+(v?0:u)),p.x1!==void 0&&(p.x1=p.x1*i+p.y1*c+(v?0:d)),p.y1!==void 0&&(p.y1=b*a+p.y1*h+(v?0:u)),p.x2!==void 0&&(p.x2=p.x2*i+p.y2*c+(v?0:d)),p.y2!==void 0&&(p.y2=x*a+p.y2*h+(v?0:u));var I=i*h-a*c;if(p.xRot!==void 0&&(i!==1||a!==0||c!==0||h!==1))if(I===0)delete p.rX,delete p.rY,delete p.xRot,delete p.lArcFlag,delete p.sweepFlag,p.type=Y.LINE_TO;else{var V=p.xRot*Math.PI/180,U=Math.sin(V),J=Math.cos(V),j=1/k(p.rX),st=1/k(p.rY),tt=k(J)*j+k(U)*st,it=2*U*J*(j-st),ht=k(U)*j+k(J)*st,xt=tt*h*h-it*a*h+ht*a*a,mt=it*(i*h+a*c)-2*(tt*c*h+ht*i*a),ut=tt*c*c-it*i*c+ht*i*i,ot=(Math.atan2(mt,xt-ut)+Math.PI)%Math.PI/2,q=Math.sin(ot),B=Math.cos(ot);p.rX=Math.abs(I)/Math.sqrt(xt*k(B)+mt*q*B+ut*k(q)),p.rY=Math.abs(I)/Math.sqrt(xt*k(q)-mt*q*B+ut*k(B)),p.xRot=180*ot/Math.PI}return p.sweepFlag!==void 0&&0>I&&(p.sweepFlag=+!p.sweepFlag),p})}function o(){return function(i){var a={};for(var c in i)a[c]=i[c];return a}}l.ROUND=function(i){function a(c){return Math.round(c*i)/i}return i===void 0&&(i=1e13),Be(i),function(c){return c.x1!==void 0&&(c.x1=a(c.x1)),c.y1!==void 0&&(c.y1=a(c.y1)),c.x2!==void 0&&(c.x2=a(c.x2)),c.y2!==void 0&&(c.y2=a(c.y2)),c.x!==void 0&&(c.x=a(c.x)),c.y!==void 0&&(c.y=a(c.y)),c.rX!==void 0&&(c.rX=a(c.rX)),c.rY!==void 0&&(c.rY=a(c.rY)),c}},l.TO_ABS=e,l.TO_REL=function(){return s(function(i,a,c){return i.relative||(i.x1!==void 0&&(i.x1-=a),i.y1!==void 0&&(i.y1-=c),i.x2!==void 0&&(i.x2-=a),i.y2!==void 0&&(i.y2-=c),i.x!==void 0&&(i.x-=a),i.y!==void 0&&(i.y-=c),i.relative=!0),i})},l.NORMALIZE_HVZ=function(i,a,c){return i===void 0&&(i=!0),a===void 0&&(a=!0),c===void 0&&(c=!0),s(function(h,d,u,p,f){if(isNaN(p)&&!(h.type&Y.MOVE_TO))throw new Error("path must start with moveto");return a&&h.type&Y.HORIZ_LINE_TO&&(h.type=Y.LINE_TO,h.y=h.relative?0:u),c&&h.type&Y.VERT_LINE_TO&&(h.type=Y.LINE_TO,h.x=h.relative?0:d),i&&h.type&Y.CLOSE_PATH&&(h.type=Y.LINE_TO,h.x=h.relative?p-d:p,h.y=h.relative?f-u:f),h.type&Y.ARC&&(h.rX===0||h.rY===0)&&(h.type=Y.LINE_TO,delete h.rX,delete h.rY,delete h.xRot,delete h.lArcFlag,delete h.sweepFlag),h})},l.NORMALIZE_ST=t,l.QT_TO_C=n,l.INFO=s,l.SANITIZE=function(i){i===void 0&&(i=0),Be(i);var a=NaN,c=NaN,h=NaN,d=NaN;return s(function(u,p,f,y,w){var b=Math.abs,x=!1,v=0,C=0;if(u.type&Y.SMOOTH_CURVE_TO&&(v=isNaN(a)?0:p-a,C=isNaN(c)?0:f-c),u.type&(Y.CURVE_TO|Y.SMOOTH_CURVE_TO)?(a=u.relative?p+u.x2:u.x2,c=u.relative?f+u.y2:u.y2):(a=NaN,c=NaN),u.type&Y.SMOOTH_QUAD_TO?(h=isNaN(h)?p:2*p-h,d=isNaN(d)?f:2*f-d):u.type&Y.QUAD_TO?(h=u.relative?p+u.x1:u.x1,d=u.relative?f+u.y1:u.y2):(h=NaN,d=NaN),u.type&Y.LINE_COMMANDS||u.type&Y.ARC&&(u.rX===0||u.rY===0||!u.lArcFlag)||u.type&Y.CURVE_TO||u.type&Y.SMOOTH_CURVE_TO||u.type&Y.QUAD_TO||u.type&Y.SMOOTH_QUAD_TO){var E=u.x===void 0?0:u.relative?u.x:u.x-p,k=u.y===void 0?0:u.relative?u.y:u.y-f;v=isNaN(h)?u.x1===void 0?v:u.relative?u.x:u.x1-p:h-p,C=isNaN(d)?u.y1===void 0?C:u.relative?u.y:u.y1-f:d-f;var I=u.x2===void 0?0:u.relative?u.x:u.x2-p,V=u.y2===void 0?0:u.relative?u.y:u.y2-f;b(E)<=i&&b(k)<=i&&b(v)<=i&&b(C)<=i&&b(I)<=i&&b(V)<=i&&(x=!0)}return u.type&Y.CLOSE_PATH&&b(p-y)<=i&&b(f-w)<=i&&(x=!0),x?[]:u})},l.MATRIX=r,l.ROTATE=function(i,a,c){a===void 0&&(a=0),c===void 0&&(c=0),Be(i,a,c);var h=Math.sin(i),d=Math.cos(i);return r(d,h,-h,d,a-a*d+c*h,c-a*h-c*d)},l.TRANSLATE=function(i,a){return a===void 0&&(a=0),Be(i,a),r(1,0,0,1,i,a)},l.SCALE=function(i,a){return a===void 0&&(a=i),Be(i,a),r(i,0,0,a,0,0)},l.SKEW_X=function(i){return Be(i),r(1,0,Math.atan(i),1,0,0)},l.SKEW_Y=function(i){return Be(i),r(1,Math.atan(i),0,1,0,0)},l.X_AXIS_SYMMETRY=function(i){return i===void 0&&(i=0),Be(i),r(-1,0,0,1,i,0)},l.Y_AXIS_SYMMETRY=function(i){return i===void 0&&(i=0),Be(i),r(1,0,0,-1,0,i)},l.A_TO_C=function(){return s(function(i,a,c){return Y.ARC===i.type?function(h,d,u){var p,f,y,w;h.cX||Io(h,d,u);for(var b=Math.min(h.phi1,h.phi2),x=Math.max(h.phi1,h.phi2)-b,v=Math.ceil(x/90),C=new Array(v),E=d,k=u,I=0;I<v;I++){var V=Mc(h.phi1,h.phi2,I/v),U=Mc(h.phi1,h.phi2,(I+1)/v),J=U-V,j=4/3*Math.tan(J*Qe/4),st=[Math.cos(V*Qe)-j*Math.sin(V*Qe),Math.sin(V*Qe)+j*Math.cos(V*Qe)],tt=st[0],it=st[1],ht=[Math.cos(U*Qe),Math.sin(U*Qe)],xt=ht[0],mt=ht[1],ut=[xt+j*Math.sin(U*Qe),mt-j*Math.cos(U*Qe)],ot=ut[0],q=ut[1];C[I]={relative:h.relative,type:Y.CURVE_TO};var B=function(H,z){var X=Eo([H*h.rX,z*h.rY],h.xRot),Ft=X[0],ye=X[1];return[h.cX+Ft,h.cY+ye]};p=B(tt,it),C[I].x1=p[0],C[I].y1=p[1],f=B(ot,q),C[I].x2=f[0],C[I].y2=f[1],y=B(xt,mt),C[I].x=y[0],C[I].y=y[1],h.relative&&(C[I].x1-=E,C[I].y1-=k,C[I].x2-=E,C[I].y2-=k,C[I].x-=E,C[I].y-=k),E=(w=[C[I].x,C[I].y])[0],k=w[1]}return C}(i,i.relative?0:a,i.relative?0:c):i})},l.ANNOTATE_ARCS=function(){return s(function(i,a,c){return i.relative&&(a=0,c=0),Y.ARC===i.type&&Io(i,a,c),i})},l.CLONE=o,l.CALCULATE_BOUNDS=function(){var i=function(u){var p={};for(var f in u)p[f]=u[f];return p},a=e(),c=n(),h=t(),d=s(function(u,p,f){var y=h(c(a(i(u))));function w(q){q>d.maxX&&(d.maxX=q),q<d.minX&&(d.minX=q)}function b(q){q>d.maxY&&(d.maxY=q),q<d.minY&&(d.minY=q)}if(y.type&Y.DRAWING_COMMANDS&&(w(p),b(f)),y.type&Y.HORIZ_LINE_TO&&w(y.x),y.type&Y.VERT_LINE_TO&&b(y.y),y.type&Y.LINE_TO&&(w(y.x),b(y.y)),y.type&Y.CURVE_TO){w(y.x),b(y.y);for(var x=0,v=Tc(p,y.x1,y.x2,y.x);x<v.length;x++)0<(ot=v[x])&&1>ot&&w(Cc(p,y.x1,y.x2,y.x,ot));for(var C=0,E=Tc(f,y.y1,y.y2,y.y);C<E.length;C++)0<(ot=E[C])&&1>ot&&b(Cc(f,y.y1,y.y2,y.y,ot))}if(y.type&Y.ARC){w(y.x),b(y.y),Io(y,p,f);for(var k=y.xRot/180*Math.PI,I=Math.cos(k)*y.rX,V=Math.sin(k)*y.rX,U=-Math.sin(k)*y.rY,J=Math.cos(k)*y.rY,j=y.phi1<y.phi2?[y.phi1,y.phi2]:-180>y.phi2?[y.phi2+360,y.phi1+360]:[y.phi2,y.phi1],st=j[0],tt=j[1],it=function(q){var B=q[0],H=q[1],z=180*Math.atan2(H,B)/Math.PI;return z<st?z+360:z},ht=0,xt=vc(U,-I,0).map(it);ht<xt.length;ht++)(ot=xt[ht])>st&&ot<tt&&w(Sc(y.cX,I,U,ot));for(var mt=0,ut=vc(J,-V,0).map(it);mt<ut.length;mt++){var ot;(ot=ut[mt])>st&&ot<tt&&b(Sc(y.cY,V,J,ot))}}return u});return d.minX=1/0,d.maxX=-1/0,d.minY=1/0,d.maxY=-1/0,d}})(Gt||(Gt={}));var Oe,Lc=function(){function l(){}return l.prototype.round=function(e){return this.transform(Gt.ROUND(e))},l.prototype.toAbs=function(){return this.transform(Gt.TO_ABS())},l.prototype.toRel=function(){return this.transform(Gt.TO_REL())},l.prototype.normalizeHVZ=function(e,t,n){return this.transform(Gt.NORMALIZE_HVZ(e,t,n))},l.prototype.normalizeST=function(){return this.transform(Gt.NORMALIZE_ST())},l.prototype.qtToC=function(){return this.transform(Gt.QT_TO_C())},l.prototype.aToC=function(){return this.transform(Gt.A_TO_C())},l.prototype.sanitize=function(e){return this.transform(Gt.SANITIZE(e))},l.prototype.translate=function(e,t){return this.transform(Gt.TRANSLATE(e,t))},l.prototype.scale=function(e,t){return this.transform(Gt.SCALE(e,t))},l.prototype.rotate=function(e,t,n){return this.transform(Gt.ROTATE(e,t,n))},l.prototype.matrix=function(e,t,n,s,r,o){return this.transform(Gt.MATRIX(e,t,n,s,r,o))},l.prototype.skewX=function(e){return this.transform(Gt.SKEW_X(e))},l.prototype.skewY=function(e){return this.transform(Gt.SKEW_Y(e))},l.prototype.xSymmetry=function(e){return this.transform(Gt.X_AXIS_SYMMETRY(e))},l.prototype.ySymmetry=function(e){return this.transform(Gt.Y_AXIS_SYMMETRY(e))},l.prototype.annotateArcs=function(){return this.transform(Gt.ANNOTATE_ARCS())},l}(),Bp=function(l){return l===" "||l===" "||l==="\r"||l===`
24
- `},Ac=function(l){return 48<=l.charCodeAt(0)&&l.charCodeAt(0)<=57},Op=function(l){function e(){var t=l.call(this)||this;return t.curNumber="",t.curCommandType=-1,t.curCommandRelative=!1,t.canParseCommandOrComma=!0,t.curNumberHasExp=!1,t.curNumberHasExpDigits=!1,t.curNumberHasDecimal=!1,t.curArgs=[],t}return bc(e,l),e.prototype.finish=function(t){if(t===void 0&&(t=[]),this.parse(" ",t),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t},e.prototype.parse=function(t,n){var s=this;n===void 0&&(n=[]);for(var r=function(d){n.push(d),s.curArgs.length=0,s.canParseCommandOrComma=!0},o=0;o<t.length;o++){var i=t[o],a=!(this.curCommandType!==Y.ARC||this.curArgs.length!==3&&this.curArgs.length!==4||this.curNumber.length!==1||this.curNumber!=="0"&&this.curNumber!=="1"),c=Ac(i)&&(this.curNumber==="0"&&i==="0"||a);if(!Ac(i)||c)if(i!=="e"&&i!=="E")if(i!=="-"&&i!=="+"||!this.curNumberHasExp||this.curNumberHasExpDigits)if(i!=="."||this.curNumberHasExp||this.curNumberHasDecimal||a){if(this.curNumber&&this.curCommandType!==-1){var h=Number(this.curNumber);if(isNaN(h))throw new SyntaxError("Invalid number ending at "+o);if(this.curCommandType===Y.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>h)throw new SyntaxError('Expected positive number, got "'+h+'" at index "'+o+'"')}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+o+'"')}this.curArgs.push(h),this.curArgs.length===Dp[this.curCommandType]&&(Y.HORIZ_LINE_TO===this.curCommandType?r({type:Y.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):Y.VERT_LINE_TO===this.curCommandType?r({type:Y.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===Y.MOVE_TO||this.curCommandType===Y.LINE_TO||this.curCommandType===Y.SMOOTH_QUAD_TO?(r({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),Y.MOVE_TO===this.curCommandType&&(this.curCommandType=Y.LINE_TO)):this.curCommandType===Y.CURVE_TO?r({type:Y.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===Y.SMOOTH_CURVE_TO?r({type:Y.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===Y.QUAD_TO?r({type:Y.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===Y.ARC&&r({type:Y.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!Bp(i))if(i===","&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if(i!=="+"&&i!=="-"&&i!==".")if(c)this.curNumber=i,this.curNumberHasDecimal=!1;else{if(this.curArgs.length!==0)throw new SyntaxError("Unterminated command at index "+o+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+i+'" at index '+o+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,i!=="z"&&i!=="Z")if(i==="h"||i==="H")this.curCommandType=Y.HORIZ_LINE_TO,this.curCommandRelative=i==="h";else if(i==="v"||i==="V")this.curCommandType=Y.VERT_LINE_TO,this.curCommandRelative=i==="v";else if(i==="m"||i==="M")this.curCommandType=Y.MOVE_TO,this.curCommandRelative=i==="m";else if(i==="l"||i==="L")this.curCommandType=Y.LINE_TO,this.curCommandRelative=i==="l";else if(i==="c"||i==="C")this.curCommandType=Y.CURVE_TO,this.curCommandRelative=i==="c";else if(i==="s"||i==="S")this.curCommandType=Y.SMOOTH_CURVE_TO,this.curCommandRelative=i==="s";else if(i==="q"||i==="Q")this.curCommandType=Y.QUAD_TO,this.curCommandRelative=i==="q";else if(i==="t"||i==="T")this.curCommandType=Y.SMOOTH_QUAD_TO,this.curCommandRelative=i==="t";else{if(i!=="a"&&i!=="A")throw new SyntaxError('Unexpected character "'+i+'" at index '+o+".");this.curCommandType=Y.ARC,this.curCommandRelative=i==="a"}else n.push({type:Y.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=i,this.curNumberHasDecimal=i==="."}else this.curNumber+=i,this.curNumberHasDecimal=!0;else this.curNumber+=i;else this.curNumber+=i,this.curNumberHasExp=!0;else this.curNumber+=i,this.curNumberHasExpDigits=this.curNumberHasExp}return n},e.prototype.transform=function(t){return Object.create(this,{parse:{value:function(n,s){s===void 0&&(s=[]);for(var r=0,o=Object.getPrototypeOf(this).parse.call(this,n);r<o.length;r++){var i=o[r],a=t(i);Array.isArray(a)?s.push.apply(s,a):s.push(a)}return s}}})},e}(Lc),Y=function(l){function e(t){var n=l.call(this)||this;return n.commands=typeof t=="string"?e.parse(t):t,n}return bc(e,l),e.prototype.encode=function(){return e.encode(this.commands)},e.prototype.getBounds=function(){var t=Gt.CALCULATE_BOUNDS();return this.transform(t),t},e.prototype.transform=function(t){for(var n=[],s=0,r=this.commands;s<r.length;s++){var o=t(r[s]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return this.commands=n,this},e.encode=function(t){return kp(t)},e.parse=function(t){var n=new Op,s=[];return n.parse(t,s),n.finish(s),s},e.CLOSE_PATH=1,e.MOVE_TO=2,e.HORIZ_LINE_TO=4,e.VERT_LINE_TO=8,e.LINE_TO=16,e.CURVE_TO=32,e.SMOOTH_CURVE_TO=64,e.QUAD_TO=128,e.SMOOTH_QUAD_TO=256,e.ARC=512,e.LINE_COMMANDS=e.LINE_TO|e.HORIZ_LINE_TO|e.VERT_LINE_TO,e.DRAWING_COMMANDS=e.HORIZ_LINE_TO|e.VERT_LINE_TO|e.LINE_TO|e.CURVE_TO|e.SMOOTH_CURVE_TO|e.QUAD_TO|e.SMOOTH_QUAD_TO|e.ARC,e}(Lc),Dp=((Oe={})[Y.MOVE_TO]=2,Oe[Y.LINE_TO]=2,Oe[Y.HORIZ_LINE_TO]=1,Oe[Y.VERT_LINE_TO]=1,Oe[Y.CLOSE_PATH]=0,Oe[Y.QUAD_TO]=4,Oe[Y.SMOOTH_QUAD_TO]=2,Oe[Y.CURVE_TO]=6,Oe[Y.SMOOTH_CURVE_TO]=4,Oe[Y.ARC]=7,Oe);function br(l){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?br=function(e){return typeof e}:br=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},br(l)}function Hp(l,e){if(!(l instanceof e))throw new TypeError("Cannot call a class as a function")}var zp=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Xp=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Yp(l,e,t,n,s){if(typeof l=="string"&&(l=document.getElementById(l)),!l||br(l)!=="object"||!("getContext"in l))throw new TypeError("Expecting canvas with `getContext` method in processCanvasRGB(A) calls!");var r=l.getContext("2d");try{return r.getImageData(e,t,n,s)}catch(o){throw new Error("unable to access image data: "+o)}}function Fp(l,e,t,n,s,r){if(!(isNaN(r)||r<1)){r|=0;var o=Yp(l,e,t,n,s);o=Vp(o,e,t,n,s,r),l.getContext("2d").putImageData(o,e,t)}}function Vp(l,e,t,n,s,r){for(var o=l.data,i=2*r+1,a=n-1,c=s-1,h=r+1,d=h*(h+1)/2,u=new Rc,p=u,f,y=1;y<i;y++)p=p.next=new Rc,y===h&&(f=p);p.next=u;for(var w=null,b=null,x=0,v=0,C=zp[r],E=Xp[r],k=0;k<s;k++){p=u;for(var I=o[v],V=o[v+1],U=o[v+2],J=o[v+3],j=0;j<h;j++)p.r=I,p.g=V,p.b=U,p.a=J,p=p.next;for(var st=0,tt=0,it=0,ht=0,xt=h*I,mt=h*V,ut=h*U,ot=h*J,q=d*I,B=d*V,H=d*U,z=d*J,X=1;X<h;X++){var Ft=v+((a<X?a:X)<<2),ye=o[Ft],Se=o[Ft+1],Me=o[Ft+2],Te=o[Ft+3],Ce=h-X;q+=(p.r=ye)*Ce,B+=(p.g=Se)*Ce,H+=(p.b=Me)*Ce,z+=(p.a=Te)*Ce,st+=ye,tt+=Se,it+=Me,ht+=Te,p=p.next}w=u,b=f;for(var zn=0;zn<n;zn++){var Bt=z*C>>>E;if(o[v+3]=Bt,Bt!==0){var mn=255/Bt;o[v]=(q*C>>>E)*mn,o[v+1]=(B*C>>>E)*mn,o[v+2]=(H*C>>>E)*mn}else o[v]=o[v+1]=o[v+2]=0;q-=xt,B-=mt,H-=ut,z-=ot,xt-=w.r,mt-=w.g,ut-=w.b,ot-=w.a;var Le=zn+r+1;Le=x+(Le<a?Le:a)<<2,st+=w.r=o[Le],tt+=w.g=o[Le+1],it+=w.b=o[Le+2],ht+=w.a=o[Le+3],q+=st,B+=tt,H+=it,z+=ht,w=w.next;var Ae=b,Re=Ae.r,is=Ae.g,tn=Ae.b,ze=Ae.a;xt+=Re,mt+=is,ut+=tn,ot+=ze,st-=Re,tt-=is,it-=tn,ht-=ze,b=b.next,v+=4}x+=n}for(var wn=0;wn<n;wn++){v=wn<<2;var en=o[v],Xe=o[v+1],nn=o[v+2],ce=o[v+3],as=h*en,cs=h*Xe,ls=h*nn,Xs=h*ce,Xn=d*en,Yn=d*Xe,hs=d*nn,ds=d*ce;p=u;for(var Ir=0;Ir<h;Ir++)p.r=en,p.g=Xe,p.b=nn,p.a=ce,p=p.next;for(var kr=n,Ys=0,Fs=0,Vs=0,Fn=0,Vn=1;Vn<=r;Vn++){v=kr+wn<<2;var Ye=h-Vn;Xn+=(p.r=en=o[v])*Ye,Yn+=(p.g=Xe=o[v+1])*Ye,hs+=(p.b=nn=o[v+2])*Ye,ds+=(p.a=ce=o[v+3])*Ye,Fn+=en,Ys+=Xe,Fs+=nn,Vs+=ce,p=p.next,Vn<c&&(kr+=n)}v=wn,w=u,b=f;for(var Wn=0;Wn<s;Wn++){var Zt=v<<2;o[Zt+3]=ce=ds*C>>>E,ce>0?(ce=255/ce,o[Zt]=(Xn*C>>>E)*ce,o[Zt+1]=(Yn*C>>>E)*ce,o[Zt+2]=(hs*C>>>E)*ce):o[Zt]=o[Zt+1]=o[Zt+2]=0,Xn-=as,Yn-=cs,hs-=ls,ds-=Xs,as-=w.r,cs-=w.g,ls-=w.b,Xs-=w.a,Zt=wn+((Zt=Wn+h)<c?Zt:c)*n<<2,Xn+=Fn+=w.r=o[Zt],Yn+=Ys+=w.g=o[Zt+1],hs+=Fs+=w.b=o[Zt+2],ds+=Vs+=w.a=o[Zt+3],w=w.next,as+=en=b.r,cs+=Xe=b.g,ls+=nn=b.b,Xs+=ce=b.a,Fn-=en,Ys-=Xe,Fs-=nn,Vs-=ce,b=b.next,v+=n}}return l}var Rc=function l(){Hp(this,l),this.r=0,this.g=0,this.b=0,this.a=0,this.next=null};function es(l){return l.replace(/(?!\u3000)\s+/gm," ")}function Wp(l){return l.replace(/^[\n \t]+/,"")}function Gp(l){return l.replace(/[\n \t]+$/,"")}function ve(l){const e=l.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return e?e.map(parseFloat):[]}function Up(l){const e=ve(l);return[e[0]||0,e[1]||0,e[2]||0,e[3]||0,e[4]||0,e[5]||0]}const _p=/^[A-Z-]+$/;function Kp(l){return _p.test(l)?l.toLowerCase():l}function Nc(l){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(l);return e&&(e[2]||e[3]||e[4])||""}function jp(l){if(!l.startsWith("rgb"))return l;let e=3;return l.replace(/\d+(\.\d+)?/g,(n,s)=>e--&&s?String(Math.round(parseFloat(n))):n)}const qp=/(\[[^\]]+\])/g,$p=/(#[^\s+>~.[:]+)/g,Qp=/(\.[^\s+>~.[:]+)/g,Zp=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,Jp=/(:[\w-]+\([^)]*\))/gi,tf=/(:[^\s+>~.[:]+)/g,ef=/([^\s+>~.[:]+)/g;function On(l,e){const t=e.exec(l);return t?[l.replace(e," "),t.length]:[l,0]}function nf(l){const e=[0,0,0];let t=l.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),n=0;return[t,n]=On(t,qp),e[1]+=n,[t,n]=On(t,$p),e[0]+=n,[t,n]=On(t,Qp),e[1]+=n,[t,n]=On(t,Zp),e[2]+=n,[t,n]=On(t,Jp),e[1]+=n,[t,n]=On(t,tf),e[1]+=n,t=t.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[t,n]=On(t,ef),e[2]+=n,e.join("")}const ns=1e-8;function Ec(l){return Math.sqrt(Math.pow(l[0],2)+Math.pow(l[1],2))}function ko(l,e){return(l[0]*e[0]+l[1]*e[1])/(Ec(l)*Ec(e))}function Ic(l,e){return(l[0]*e[1]<l[1]*e[0]?-1:1)*Math.acos(ko(l,e))}function kc(l){return l*l*l}function Bc(l){return 3*l*l*(1-l)}function Oc(l){return 3*l*(1-l)*(1-l)}function Dc(l){return(1-l)*(1-l)*(1-l)}function Hc(l){return l*l}function zc(l){return 2*l*(1-l)}function Xc(l){return(1-l)*(1-l)}class rt{static empty(e){return new rt(e,"EMPTY","")}split(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:" ";const{document:t,name:n}=this;return es(this.getString()).trim().split(e).map(s=>new rt(t,n,s))}hasValue(e){const t=this.value;return t!==null&&t!==""&&(e||t!==0)&&typeof t<"u"}isString(e){const{value:t}=this,n=typeof t=="string";return!n||!e?n:e.test(t)}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const e=this.getString();switch(!0){case e.endsWith("px"):case/^[0-9]+$/.test(e):return!0;default:return!1}}setValue(e){return this.value=e,this}getValue(e){return typeof e>"u"||this.hasValue()?this.value:e}getNumber(e){if(!this.hasValue())return typeof e>"u"?0:parseFloat(e);const{value:t}=this;let n=parseFloat(t);return this.isString(/%$/)&&(n/=100),n}getString(e){return typeof e>"u"||this.hasValue()?typeof this.value>"u"?"":String(this.value):String(e)}getColor(e){let t=this.getString(e);return this.isNormalizedColor||(this.isNormalizedColor=!0,t=jp(t),this.value=t),t}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!this.hasValue())return 0;const[n,s]=typeof e=="boolean"?[void 0,e]:[e],{viewPort:r}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(r.computeSize("x"),r.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(r.computeSize("x"),r.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*r.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*r.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return this.getNumber()*15;case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case(this.isString(/%$/)&&s):return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*r.computeSize(n);default:{const o=this.getNumber();return t&&o<1?o*r.computeSize(n):o}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():this.getNumber()*1e3:0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const e=this.getString(),t=/#([^)'"]+)/.exec(e),n=(t==null?void 0:t[1])||e;return this.document.definitions.get(n)}getFillStyleDefinition(e,t){let n=this.getDefinition();if(!n)return null;if(typeof n.createGradient=="function"&&"getBoundingBox"in e)return n.createGradient(this.document.ctx,e,t);if(typeof n.createPattern=="function"){if(n.getHrefAttribute().hasValue()){const s=n.getAttribute("patternTransform");n=n.getHrefAttribute().getDefinition(),n&&s.hasValue()&&n.getAttribute("patternTransform",!0).setValue(s.value)}if(n)return n.createPattern(this.document.ctx,e,t)}return null}getTextBaseline(){if(!this.hasValue())return null;const e=this.getString();return rt.textBaselineMapping[e]||null}addOpacity(e){let t=this.getColor();const n=t.length;let s=0;for(let r=0;r<n&&(t[r]===","&&s++,s!==3);r++);if(e.hasValue()&&this.isString()&&s!==3){const r=new No(t);r.ok&&(r.alpha=e.getNumber(),t=r.toRGBA())}return new rt(this.document,this.name,t)}constructor(e,t,n){this.document=e,this.name=t,this.value=n,this.isNormalizedColor=!1}}rt.textBaselineMapping={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};class Is{clear(){this.viewPorts=[]}setCurrent(e,t){this.viewPorts.push({width:e,height:t})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[e]=this.viewPorts;return e||Yc()}getCurrent(){const{viewPorts:e}=this,t=e[e.length-1];return t||Yc()}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(e){return typeof e=="number"?e:e==="x"?this.width:e==="y"?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}constructor(){this.viewPorts=[]}}Is.DEFAULT_VIEWPORT_WIDTH=800,Is.DEFAULT_VIEWPORT_HEIGHT=600;function Yc(){return{width:Is.DEFAULT_VIEWPORT_WIDTH,height:Is.DEFAULT_VIEWPORT_HEIGHT}}class Xt{static parse(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const[n=t,s=t]=ve(e);return new Xt(n,s)}static parseScale(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;const[n=t,s=n]=ve(e);return new Xt(n,s)}static parsePath(e){const t=ve(e),n=t.length,s=[];for(let r=0;r<n;r+=2)s.push(new Xt(t[r],t[r+1]));return s}angleTo(e){return Math.atan2(e.y-this.y,e.x-this.x)}applyTransform(e){const{x:t,y:n}=this,s=t*e[0]+n*e[2]+e[4],r=t*e[1]+n*e[3]+e[5];this.x=s,this.y=r}constructor(e,t){this.x=e,this.y=t}}class sf{isWorking(){return this.working}start(){if(this.working)return;const{screen:e,onClick:t,onMouseMove:n}=this,s=e.ctx.canvas;s.onclick=t,s.onmousemove=n,this.working=!0}stop(){if(!this.working)return;const e=this.screen.ctx.canvas;this.working=!1,e.onclick=null,e.onmousemove=null}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(!this.working)return;const{screen:e,events:t,eventElements:n}=this,{style:s}=e.ctx.canvas;let r;s&&(s.cursor=""),t.forEach((o,i)=>{let{run:a}=o;for(r=n[i];r;)a(r),r=r.parent}),this.events=[],this.eventElements=[]}checkPath(e,t){if(!this.working||!t)return;const{events:n,eventElements:s}=this;n.forEach((r,o)=>{let{x:i,y:a}=r;!s[o]&&t.isPointInPath&&t.isPointInPath(i,a)&&(s[o]=e)})}checkBoundingBox(e,t){if(!this.working||!t)return;const{events:n,eventElements:s}=this;n.forEach((r,o)=>{let{x:i,y:a}=r;!s[o]&&t.isPointInBox(i,a)&&(s[o]=e)})}mapXY(e,t){const{window:n,ctx:s}=this.screen,r=new Xt(e,t);let o=s.canvas;for(;o;)r.x-=o.offsetLeft,r.y-=o.offsetTop,o=o.offsetParent;return n!=null&&n.scrollX&&(r.x+=n.scrollX),n!=null&&n.scrollY&&(r.y+=n.scrollY),r}onClick(e){const{x:t,y:n}=this.mapXY(e.clientX,e.clientY);this.events.push({type:"onclick",x:t,y:n,run(s){s.onClick&&s.onClick()}})}onMouseMove(e){const{x:t,y:n}=this.mapXY(e.clientX,e.clientY);this.events.push({type:"onmousemove",x:t,y:n,run(s){s.onMouseMove&&s.onMouseMove()}})}constructor(e){this.screen=e,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}const Fc=typeof window<"u"?window:null,Vc=typeof fetch<"u"?fetch.bind(void 0):void 0;class Ze{wait(e){this.waits.push(e)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const e=this.waits.every(t=>t());return e&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=e,e}setDefaults(e){e.strokeStyle="rgba(0,0,0,0)",e.lineCap="butt",e.lineJoin="miter",e.miterLimit=4}setViewBox(e){let{document:t,ctx:n,aspectRatio:s,width:r,desiredWidth:o,height:i,desiredHeight:a,minX:c=0,minY:h=0,refX:d,refY:u,clip:p=!1,clipX:f=0,clipY:y=0}=e;const w=es(s).replace(/^defer\s/,""),[b,x]=w.split(" "),v=b||"xMidYMid",C=x||"meet",E=r/o,k=i/a,I=Math.min(E,k),V=Math.max(E,k);let U=o,J=a;C==="meet"&&(U*=I,J*=I),C==="slice"&&(U*=V,J*=V);const j=new rt(t,"refX",d),st=new rt(t,"refY",u),tt=j.hasValue()&&st.hasValue();if(tt&&n.translate(-I*j.getPixels("x"),-I*st.getPixels("y")),p){const it=I*f,ht=I*y;n.beginPath(),n.moveTo(it,ht),n.lineTo(r,ht),n.lineTo(r,i),n.lineTo(it,i),n.closePath(),n.clip()}if(!tt){const it=C==="meet"&&I===k,ht=C==="slice"&&V===k,xt=C==="meet"&&I===E,mt=C==="slice"&&V===E;v.startsWith("xMid")&&(it||ht)&&n.translate(r/2-U/2,0),v.endsWith("YMid")&&(xt||mt)&&n.translate(0,i/2-J/2),v.startsWith("xMax")&&(it||ht)&&n.translate(r-U,0),v.endsWith("YMax")&&(xt||mt)&&n.translate(0,i-J)}switch(!0){case v==="none":n.scale(E,k);break;case C==="meet":n.scale(I,I);break;case C==="slice":n.scale(V,V);break}n.translate(-c,-h)}start(e){let{enableRedraw:t=!1,ignoreMouse:n=!1,ignoreAnimation:s=!1,ignoreDimensions:r=!1,ignoreClear:o=!1,forceRedraw:i,scaleWidth:a,scaleHeight:c,offsetX:h,offsetY:d}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{mouse:u}=this,p=1e3/Ze.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=p,this.readyPromise=new Promise(x=>{this.resolveReady=x}),this.isReady()&&this.render(e,r,o,a,c,h,d),!t)return;let f=Date.now(),y=f,w=0;const b=()=>{f=Date.now(),w=f-y,w>=p&&(y=f-w%p,this.shouldUpdate(s,i)&&(this.render(e,r,o,a,c,h,d),u.runEvents())),this.intervalId=Ro(b)};n||u.start(),this.intervalId=Ro(b)}stop(){this.intervalId&&(Ro.cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(e,t){if(!e){const{frameDuration:n}=this;if(this.animations.reduce((r,o)=>o.update(n)||r,!1))return!0}return!!(typeof t=="function"&&t()||!this.isReadyLock&&this.isReady()||this.mouse.hasEvents())}render(e,t,n,s,r,o,i){const{viewPort:a,ctx:c,isFirstRender:h}=this,d=c.canvas;a.clear(),d.width&&d.height&&a.setCurrent(d.width,d.height);const u=e.getStyle("width"),p=e.getStyle("height");!t&&(h||typeof s!="number"&&typeof r!="number")&&(u.hasValue()&&(d.width=u.getPixels("x"),d.style&&(d.style.width="".concat(d.width,"px"))),p.hasValue()&&(d.height=p.getPixels("y"),d.style&&(d.style.height="".concat(d.height,"px"))));let f=d.clientWidth||d.width,y=d.clientHeight||d.height;if(t&&u.hasValue()&&p.hasValue()&&(f=u.getPixels("x"),y=p.getPixels("y")),a.setCurrent(f,y),typeof o=="number"&&e.getAttribute("x",!0).setValue(o),typeof i=="number"&&e.getAttribute("y",!0).setValue(i),typeof s=="number"||typeof r=="number"){const w=ve(e.getAttribute("viewBox").getString());let b=0,x=0;if(typeof s=="number"){const C=e.getStyle("width");C.hasValue()?b=C.getPixels("x")/s:w[2]&&!isNaN(w[2])&&(b=w[2]/s)}if(typeof r=="number"){const C=e.getStyle("height");C.hasValue()?x=C.getPixels("y")/r:w[3]&&!isNaN(w[3])&&(x=w[3]/r)}b||(b=x),x||(x=b),e.getAttribute("width",!0).setValue(s),e.getAttribute("height",!0).setValue(r);const v=e.getStyle("transform",!0,!0);v.setValue("".concat(v.getString()," scale(").concat(1/b,", ").concat(1/x,")"))}n||c.clearRect(0,0,f,y),e.render(c),h&&(this.isFirstRender=!1)}constructor(e,{fetch:t=Vc,window:n=Fc}={}){if(this.ctx=e,this.viewPort=new Is,this.mouse=new sf(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=n,!t)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=t}}Ze.defaultWindow=Fc,Ze.defaultFetch=Vc,Ze.FRAMERATE=30,Ze.MAX_VIRTUAL_PIXELS=3e4;const{defaultFetch:rf}=Ze,of=typeof DOMParser<"u"?DOMParser:void 0;class Bo{async parse(e){return e.startsWith("<")?this.parseFromString(e):this.load(e)}parseFromString(e){const t=new this.DOMParser;try{return this.checkDocument(t.parseFromString(e,"image/svg+xml"))}catch{return this.checkDocument(t.parseFromString(e,"text/xml"))}}checkDocument(e){const t=e.getElementsByTagName("parsererror")[0];if(t)throw new Error(t.textContent||"Unknown parse error");return e}async load(e){const n=await(await this.fetch(e)).text();return this.parseFromString(n)}constructor({fetch:e=rf,DOMParser:t=of}={}){if(!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!t)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=e,this.DOMParser=t}}class af{apply(e){const{x:t,y:n}=this.point;e.translate(t||0,n||0)}unapply(e){const{x:t,y:n}=this.point;e.translate(-1*t||0,-1*n||0)}applyToPoint(e){const{x:t,y:n}=this.point;e.applyTransform([1,0,0,1,t||0,n||0])}constructor(e,t){this.type="translate",this.point=Xt.parse(t)}}class cf{apply(e){const{cx:t,cy:n,originX:s,originY:r,angle:o}=this,i=t+s.getPixels("x"),a=n+r.getPixels("y");e.translate(i,a),e.rotate(o.getRadians()),e.translate(-i,-a)}unapply(e){const{cx:t,cy:n,originX:s,originY:r,angle:o}=this,i=t+s.getPixels("x"),a=n+r.getPixels("y");e.translate(i,a),e.rotate(-1*o.getRadians()),e.translate(-i,-a)}applyToPoint(e){const{cx:t,cy:n,angle:s}=this,r=s.getRadians();e.applyTransform([1,0,0,1,t||0,n||0]),e.applyTransform([Math.cos(r),Math.sin(r),-Math.sin(r),Math.cos(r),0,0]),e.applyTransform([1,0,0,1,-t||0,-n||0])}constructor(e,t,n){this.type="rotate";const s=ve(t);this.angle=new rt(e,"angle",s[0]),this.originX=n[0],this.originY=n[1],this.cx=s[1]||0,this.cy=s[2]||0}}class lf{apply(e){const{scale:{x:t,y:n},originX:s,originY:r}=this,o=s.getPixels("x"),i=r.getPixels("y");e.translate(o,i),e.scale(t,n||t),e.translate(-o,-i)}unapply(e){const{scale:{x:t,y:n},originX:s,originY:r}=this,o=s.getPixels("x"),i=r.getPixels("y");e.translate(o,i),e.scale(1/t,1/n||t),e.translate(-o,-i)}applyToPoint(e){const{x:t,y:n}=this.scale;e.applyTransform([t||0,0,0,n||0,0,0])}constructor(e,t,n){this.type="scale";const s=Xt.parseScale(t);(s.x===0||s.y===0)&&(s.x=ns,s.y=ns),this.scale=s,this.originX=n[0],this.originY=n[1]}}class Wc{apply(e){const{originX:t,originY:n,matrix:s}=this,r=t.getPixels("x"),o=n.getPixels("y");e.translate(r,o),e.transform(s[0],s[1],s[2],s[3],s[4],s[5]),e.translate(-r,-o)}unapply(e){const{originX:t,originY:n,matrix:s}=this,r=s[0],o=s[2],i=s[4],a=s[1],c=s[3],h=s[5],d=0,u=0,p=1,f=1/(r*(c*p-h*u)-o*(a*p-h*d)+i*(a*u-c*d)),y=t.getPixels("x"),w=n.getPixels("y");e.translate(y,w),e.transform(f*(c*p-h*u),f*(h*d-a*p),f*(i*u-o*p),f*(r*p-i*d),f*(o*h-i*c),f*(i*a-r*h)),e.translate(-y,-w)}applyToPoint(e){e.applyTransform(this.matrix)}constructor(e,t,n){this.type="matrix",this.matrix=Up(t),this.originX=n[0],this.originY=n[1]}}class Gc extends Wc{constructor(e,t,n){super(e,t,n),this.type="skew",this.angle=new rt(e,"angle",t)}}class hf extends Gc{constructor(e,t,n){super(e,t,n),this.type="skewX",this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}}class df extends Gc{constructor(e,t,n){super(e,t,n),this.type="skewY",this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}function uf(l){return es(l).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}function pf(l){const[e="",t=""]=l.split("(");return[e.trim(),t.trim().replace(")","")]}class Dn{static fromElement(e,t){const n=t.getStyle("transform",!1,!0);if(n.hasValue()){const[s,r=s]=t.getStyle("transform-origin",!1,!0).split();if(s&&r){const o=[s,r];return new Dn(e,n.getString(),o)}}return null}apply(e){this.transforms.forEach(t=>t.apply(e))}unapply(e){this.transforms.forEach(t=>t.unapply(e))}applyToPoint(e){this.transforms.forEach(t=>t.applyToPoint(e))}constructor(e,t,n){this.document=e,this.transforms=[],uf(t).forEach(r=>{if(r==="none")return;const[o,i]=pf(r),a=Dn.transformTypes[o];a&&this.transforms.push(new a(this.document,i,n))})}}Dn.transformTypes={translate:af,rotate:cf,scale:lf,matrix:Wc,skewX:hf,skewY:df};class kt{getAttribute(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const n=this.attributes.get(e);if(!n&&t){const s=new rt(this.document,e,"");return this.attributes.set(e,s),s}return n||rt.empty(this.document)}getHrefAttribute(){let e;for(const[t,n]of this.attributes)if(t==="href"||t.endsWith(":href")){e=n;break}return e||rt.empty(this.document)}getStyle(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const s=this.styles.get(e);if(s)return s;const r=this.getAttribute(e);if(r.hasValue())return this.styles.set(e,r),r;if(!n){const{parent:o}=this;if(o){const i=o.getStyle(e);if(i.hasValue())return i}}if(t){const o=new rt(this.document,e,"");return this.styles.set(e,o),o}return rt.empty(this.document)}render(e){if(!(this.getStyle("display").getString()==="none"||this.getStyle("visibility").getString()==="hidden")){if(e.save(),this.getStyle("mask").hasValue()){const t=this.getStyle("mask").getDefinition();t&&(this.applyEffects(e),t.apply(e,this))}else if(this.getStyle("filter").getValue("none")!=="none"){const t=this.getStyle("filter").getDefinition();t&&(this.applyEffects(e),t.apply(e,this))}else this.setContext(e),this.renderChildren(e),this.clearContext(e);e.restore()}}setContext(e){}applyEffects(e){const t=Dn.fromElement(this.document,this);t&&t.apply(e);const n=this.getStyle("clip-path",!1,!0);if(n.hasValue()){const s=n.getDefinition();s&&s.apply(e)}}clearContext(e){}renderChildren(e){this.children.forEach(t=>{t.render(e)})}addChild(e){const t=e instanceof kt?e:this.document.createElement(e);t.parent=this,kt.ignoreChildTypes.includes(t.type)||this.children.push(t)}matchesSelector(e){var t;const{node:n}=this;if(typeof n.matches=="function")return n.matches(e);const s=(t=n.getAttribute)===null||t===void 0?void 0:t.call(n,"class");return!s||s===""?!1:s.split(" ").some(r=>".".concat(r)===e)}addStylesFromStyleDefinition(){const{styles:e,stylesSpecificity:t}=this.document;for(const[n,s]of e)if(!n.startsWith("@")&&this.matchesSelector(n)){const r=t.get(n);if(s)for(const[o,i]of s){let a=this.stylesSpecificity.get(o);typeof a>"u"&&(a="000"),r&&r>=a&&(i&&this.styles.set(o,i),this.stylesSpecificity.set(o,r))}}}removeStyles(e,t){return t.reduce((s,r)=>{const o=e.getStyle(r);if(!o.hasValue())return s;const i=o.getString();return o.setValue(""),[...s,[r,i]]},[])}restoreStyles(e,t){t.forEach(n=>{let[s,r]=n;e.getStyle(s,!0).setValue(r)})}isFirstChild(){var e;return((e=this.parent)===null||e===void 0?void 0:e.children.indexOf(this))===0}constructor(e,t,n=!1){if(this.document=e,this.node=t,this.captureTextNodes=n,this.type="",this.attributes=new Map,this.styles=new Map,this.stylesSpecificity=new Map,this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!t||t.nodeType!==1)return;Array.from(t.attributes).forEach(o=>{const i=Kp(o.nodeName);this.attributes.set(i,new rt(e,i,o.value))}),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()&&this.getAttribute("style").getString().split(";").map(i=>i.trim()).forEach(i=>{if(!i)return;const[a,c]=i.split(":").map(h=>h.trim());a&&this.styles.set(a,new rt(e,a,c))});const{definitions:s}=e,r=this.getAttribute("id");r.hasValue()&&(s.has(r.getString())||s.set(r.getString(),this)),Array.from(t.childNodes).forEach(o=>{if(o.nodeType===1)this.addChild(o);else if(n&&(o.nodeType===3||o.nodeType===4)){const i=e.createTextNode(o);i.getText().length>0&&this.addChild(i)}})}}kt.ignoreChildTypes=["title"];class ff extends kt{constructor(e,t,n){super(e,t,n)}}function gf(l){const e=l.trim();return/^('|")/.test(e)?e:'"'.concat(e,'"')}function yf(l){return typeof process>"u"?l:l.trim().split(",").map(gf).join(",")}function mf(l){if(!l)return"";const e=l.trim().toLowerCase();switch(e){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return e;default:return/^oblique\s+(-|)\d+deg$/.test(e)?e:""}}function wf(l){if(!l)return"";const e=l.trim().toLowerCase();switch(e){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return e;default:return/^[\d.]+$/.test(e)?e:""}}class ue{static parse(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n="",s="",r="",o="",i="";const a=es(e).trim().split(" "),c={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return a.forEach(h=>{switch(!0){case(!c.fontStyle&&ue.styles.includes(h)):h!=="inherit"&&(n=h),c.fontStyle=!0;break;case(!c.fontVariant&&ue.variants.includes(h)):h!=="inherit"&&(s=h),c.fontStyle=!0,c.fontVariant=!0;break;case(!c.fontWeight&&ue.weights.includes(h)):h!=="inherit"&&(r=h),c.fontStyle=!0,c.fontVariant=!0,c.fontWeight=!0;break;case!c.fontSize:h!=="inherit"&&(o=h.split("/")[0]||""),c.fontStyle=!0,c.fontVariant=!0,c.fontWeight=!0,c.fontSize=!0;break;default:h!=="inherit"&&(i+=h)}}),new ue(n,s,r,o,i,t)}toString(){return[mf(this.fontStyle),this.fontVariant,wf(this.fontWeight),this.fontSize,yf(this.fontFamily)].join(" ").trim()}constructor(e,t,n,s,r,o){const i=o?typeof o=="string"?ue.parse(o):o:{};this.fontFamily=r||i.fontFamily,this.fontSize=s||i.fontSize,this.fontStyle=e||i.fontStyle,this.fontWeight=n||i.fontWeight,this.fontVariant=t||i.fontVariant}}ue.styles="normal|italic|oblique|inherit",ue.variants="normal|small-caps|inherit",ue.weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";class De{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(e,t){typeof e<"u"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=e,this.x2=e),e<this.x1&&(this.x1=e),e>this.x2&&(this.x2=e)),typeof t<"u"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),t<this.y1&&(this.y1=t),t>this.y2&&(this.y2=t))}addX(e){this.addPoint(e,0)}addY(e){this.addPoint(0,e)}addBoundingBox(e){if(!e)return;const{x1:t,y1:n,x2:s,y2:r}=e;this.addPoint(t,n),this.addPoint(s,r)}sumCubic(e,t,n,s,r){return Math.pow(1-e,3)*t+3*Math.pow(1-e,2)*e*n+3*(1-e)*Math.pow(e,2)*s+Math.pow(e,3)*r}bezierCurveAdd(e,t,n,s,r){const o=6*t-12*n+6*s,i=-3*t+9*n-9*s+3*r,a=3*n-3*t;if(i===0){if(o===0)return;const u=-a/o;0<u&&u<1&&(e?this.addX(this.sumCubic(u,t,n,s,r)):this.addY(this.sumCubic(u,t,n,s,r)));return}const c=Math.pow(o,2)-4*a*i;if(c<0)return;const h=(-o+Math.sqrt(c))/(2*i);0<h&&h<1&&(e?this.addX(this.sumCubic(h,t,n,s,r)):this.addY(this.sumCubic(h,t,n,s,r)));const d=(-o-Math.sqrt(c))/(2*i);0<d&&d<1&&(e?this.addX(this.sumCubic(d,t,n,s,r)):this.addY(this.sumCubic(d,t,n,s,r)))}addBezierCurve(e,t,n,s,r,o,i,a){this.addPoint(e,t),this.addPoint(i,a),this.bezierCurveAdd(!0,e,n,r,i),this.bezierCurveAdd(!1,t,s,o,a)}addQuadraticCurve(e,t,n,s,r,o){const i=e+.6666666666666666*(n-e),a=t+2/3*(s-t),c=i+1/3*(r-e),h=a+1/3*(o-t);this.addBezierCurve(e,t,i,c,a,h,r,o)}isPointInBox(e,t){const{x1:n,y1:s,x2:r,y2:o}=this;return n<=e&&e<=r&&s<=t&&t<=o}constructor(e=Number.NaN,t=Number.NaN,n=Number.NaN,s=Number.NaN){this.x1=e,this.y1=t,this.x2=n,this.y2=s,this.addPoint(e,t),this.addPoint(n,s)}}class Hn extends kt{calculateOpacity(){let e=1,t=this;for(;t;){const n=t.getStyle("opacity",!1,!0);n.hasValue(!0)&&(e*=n.getNumber()),t=t.parent}return e}setContext(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t){const n=this.getStyle("fill"),s=this.getStyle("fill-opacity"),r=this.getStyle("stroke"),o=this.getStyle("stroke-opacity");if(n.isUrlDefinition()){const p=n.getFillStyleDefinition(this,s);p&&(e.fillStyle=p)}else if(n.hasValue()){n.getString()==="currentColor"&&n.setValue(this.getStyle("color").getColor());const p=n.getColor();p!=="inherit"&&(e.fillStyle=p==="none"?"rgba(0,0,0,0)":p)}if(s.hasValue()){const p=new rt(this.document,"fill",e.fillStyle).addOpacity(s).getColor();e.fillStyle=p}if(r.isUrlDefinition()){const p=r.getFillStyleDefinition(this,o);p&&(e.strokeStyle=p)}else if(r.hasValue()){r.getString()==="currentColor"&&r.setValue(this.getStyle("color").getColor());const p=r.getString();p!=="inherit"&&(e.strokeStyle=p==="none"?"rgba(0,0,0,0)":p)}if(o.hasValue()){const p=new rt(this.document,"stroke",e.strokeStyle).addOpacity(o).getString();e.strokeStyle=p}const i=this.getStyle("stroke-width");if(i.hasValue()){const p=i.getPixels();e.lineWidth=p||ns}const a=this.getStyle("stroke-linecap"),c=this.getStyle("stroke-linejoin"),h=this.getStyle("stroke-miterlimit"),d=this.getStyle("stroke-dasharray"),u=this.getStyle("stroke-dashoffset");if(a.hasValue()&&(e.lineCap=a.getString()),c.hasValue()&&(e.lineJoin=c.getString()),h.hasValue()&&(e.miterLimit=h.getNumber()),d.hasValue()&&d.getString()!=="none"){const p=ve(d.getString());typeof e.setLineDash<"u"?e.setLineDash(p):typeof e.webkitLineDash<"u"?e.webkitLineDash=p:typeof e.mozDash<"u"&&!(p.length===1&&p[0]===0)&&(e.mozDash=p);const f=u.getPixels();typeof e.lineDashOffset<"u"?e.lineDashOffset=f:typeof e.webkitLineDashOffset<"u"?e.webkitLineDashOffset=f:typeof e.mozDashOffset<"u"&&(e.mozDashOffset=f)}}if(this.modifiedEmSizeStack=!1,typeof e.font<"u"){const n=this.getStyle("font"),s=this.getStyle("font-style"),r=this.getStyle("font-variant"),o=this.getStyle("font-weight"),i=this.getStyle("font-size"),a=this.getStyle("font-family"),c=new ue(s.getString(),r.getString(),o.getString(),i.hasValue()?"".concat(i.getPixels(!0),"px"):"",a.getString(),ue.parse(n.getString(),e.font));s.setValue(c.fontStyle),r.setValue(c.fontVariant),o.setValue(c.fontWeight),i.setValue(c.fontSize),a.setValue(c.fontFamily),e.font=c.toString(),i.isPixels()&&(this.document.emSize=i.getPixels(),this.modifiedEmSizeStack=!0)}t||(this.applyEffects(e),e.globalAlpha=this.calculateOpacity())}clearContext(e){super.clearContext(e),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...e){super(...e),this.modifiedEmSizeStack=!1}}class pn extends Hn{setContext(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;super.setContext(e,t);const n=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();n&&(e.textBaseline=n)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(e){if(this.type!=="text")return this.getTElementBoundingBox(e);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(e);let t=null;return this.children.forEach((n,s)=>{const r=this.getChildBoundingBox(e,this,this,s);t?t.addBoundingBox(r):t=r}),t}getFontSize(){const{document:e,parent:t}=this,n=ue.parse(e.ctx.font).fontSize;return t.getStyle("font-size").getNumber(n)}getTElementBoundingBox(e){const t=this.getFontSize();return new De(this.x,this.y-t,this.x+this.measureText(e),this.y)}getGlyph(e,t,n){const s=t[n];let r;if(e.isArabic){var o;const i=t.length,a=t[n-1],c=t[n+1];let h="isolated";(n===0||a===" ")&&n<i-1&&c!==" "&&(h="terminal"),n>0&&a!==" "&&n<i-1&&c!==" "&&(h="medial"),n>0&&a!==" "&&(n===i-1||c===" ")&&(h="initial"),r=((o=e.arabicGlyphs.get(s))===null||o===void 0?void 0:o.get(h))||e.glyphs.get(s)}else r=e.glyphs.get(s);return r||(r=e.missingGlyph),r}getText(){return""}getTextFromNode(e){const t=e||this.node,n=Array.from(t.parentNode.childNodes),s=n.indexOf(t),r=n.length-1;let o=es(t.textContent||"");return s===0&&(o=Wp(o)),s===r&&(o=Gp(o)),o}renderChildren(e){if(this.type!=="text"){this.renderTElementChildren(e);return}this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(e),this.children.forEach((n,s)=>{this.renderChild(e,this,this,s)});const{mouse:t}=this.document.screen;t.isWorking()&&t.checkBoundingBox(this,this.getBoundingBox(e))}renderTElementChildren(e){const{document:t,parent:n}=this,s=this.getText(),r=n.getStyle("font-family").getDefinition();if(r){const{unitsPerEm:a}=r.fontFace,c=ue.parse(t.ctx.font),h=n.getStyle("font-size").getNumber(c.fontSize),d=n.getStyle("font-style").getString(c.fontStyle),u=h/a,p=r.isRTL?s.split("").reverse().join(""):s,f=ve(n.getAttribute("dx").getString()),y=p.length;for(let w=0;w<y;w++){const b=this.getGlyph(r,p,w);e.translate(this.x,this.y),e.scale(u,-u);const x=e.lineWidth;e.lineWidth=e.lineWidth*a/h,d==="italic"&&e.transform(1,0,.4,1,0,0),b.render(e),d==="italic"&&e.transform(1,0,-.4,1,0,0),e.lineWidth=x,e.scale(1/u,-1/u),e.translate(-this.x,-this.y),this.x+=h*(b.horizAdvX||r.horizAdvX)/a,typeof f[w]<"u"&&!isNaN(f[w])&&(this.x+=f[w])}return}const{x:o,y:i}=this;e.fillStyle&&e.fillText(s,o,i),e.strokeStyle&&e.strokeText(s,o,i)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const e=this.leafTexts[this.textChunkStart],t=e.getStyle("text-anchor").getString("start"),n=!1;let s=0;t==="start"&&!n||t==="end"&&n?s=e.x-this.minX:t==="end"&&!n||t==="start"&&n?s=e.x-this.maxX:s=e.x-(this.minX+this.maxX)/2;for(let r=this.textChunkStart;r<this.leafTexts.length;r++)this.leafTexts[r].x+=s;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(e){this.children.forEach((t,n)=>{this.adjustChildCoordinatesRecursiveCore(e,this,this,n)}),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(e,t,n,s){const r=n.children[s];r.children.length>0?r.children.forEach((o,i)=>{t.adjustChildCoordinatesRecursiveCore(e,t,r,i)}):this.adjustChildCoordinates(e,t,n,s)}adjustChildCoordinates(e,t,n,s){const r=n.children[s];if(typeof r.measureText!="function")return r;e.save(),r.setContext(e,!0);const o=r.getAttribute("x"),i=r.getAttribute("y"),a=r.getAttribute("dx"),c=r.getAttribute("dy"),h=r.getStyle("font-family").getDefinition(),d=!!(h!=null&&h.isRTL);s===0&&(o.hasValue()||o.setValue(r.getInheritedAttribute("x")),i.hasValue()||i.setValue(r.getInheritedAttribute("y")),a.hasValue()||a.setValue(r.getInheritedAttribute("dx")),c.hasValue()||c.setValue(r.getInheritedAttribute("dy")));const u=r.measureText(e);return d&&(t.x-=u),o.hasValue()?(t.applyAnchoring(),r.x=o.getPixels("x"),a.hasValue()&&(r.x+=a.getPixels("x"))):(a.hasValue()&&(t.x+=a.getPixels("x")),r.x=t.x),t.x=r.x,d||(t.x+=u),i.hasValue()?(r.y=i.getPixels("y"),c.hasValue()&&(r.y+=c.getPixels("y"))):(c.hasValue()&&(t.y+=c.getPixels("y")),r.y=t.y),t.y=r.y,t.leafTexts.push(r),t.minX=Math.min(t.minX,r.x,r.x+u),t.maxX=Math.max(t.maxX,r.x,r.x+u),r.clearContext(e),e.restore(),r}getChildBoundingBox(e,t,n,s){const r=n.children[s];if(typeof r.getBoundingBox!="function")return null;const o=r.getBoundingBox(e);return o&&r.children.forEach((i,a)=>{const c=t.getChildBoundingBox(e,t,r,a);o.addBoundingBox(c)}),o}renderChild(e,t,n,s){const r=n.children[s];r.render(e),r.children.forEach((o,i)=>{t.renderChild(e,t,r,i)})}measureText(e){const{measureCache:t}=this;if(~t)return t;const n=this.getText(),s=this.measureTargetText(e,n);return this.measureCache=s,s}measureTargetText(e,t){if(!t.length)return 0;const{parent:n}=this,s=n.getStyle("font-family").getDefinition();if(s){const o=this.getFontSize(),i=s.isRTL?t.split("").reverse().join(""):t,a=ve(n.getAttribute("dx").getString()),c=i.length;let h=0;for(let d=0;d<c;d++){const u=this.getGlyph(s,i,d);h+=(u.horizAdvX||s.horizAdvX)*o/s.fontFace.unitsPerEm,typeof a[d]<"u"&&!isNaN(a[d])&&(h+=a[d])}return h}if(!e.measureText)return t.length*10;e.save(),this.setContext(e,!0);const{width:r}=e.measureText(t);return this.clearContext(e),e.restore(),r}getInheritedAttribute(e){let t=this;for(;t instanceof pn&&t.isFirstChild()&&t.parent;){const n=t.parent.getAttribute(e);if(n.hasValue(!0))return n.getString("0");t=t.parent}return null}constructor(e,t,n){super(e,t,new.target===pn?!0:n),this.type="text",this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.measureCache=-1}}class vr extends pn{getText(){return this.text}constructor(e,t,n){super(e,t,new.target===vr?!0:n),this.type="tspan",this.text=this.children.length>0?"":this.getTextFromNode()}}class xf extends vr{constructor(...e){super(...e),this.type="textNode"}}class pt extends Y{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new Xt(0,0),this.control=new Xt(0,0),this.current=new Xt(0,0),this.points=[],this.angles=[]}isEnd(){const{i:e,commands:t}=this;return e>=t.length-1}next(){const e=this.commands[++this.i];return this.previousCommand=this.command,this.command=e,e}getPoint(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"x",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"y";const n=new Xt(this.command[e],this.command[t]);return this.makeAbsolute(n)}getAsControlPoint(e,t){const n=this.getPoint(e,t);return this.control=n,n}getAsCurrentPoint(e,t){const n=this.getPoint(e,t);return this.current=n,n}getReflectedControlPoint(){const e=this.previousCommand.type;if(e!==Y.CURVE_TO&&e!==Y.SMOOTH_CURVE_TO&&e!==Y.QUAD_TO&&e!==Y.SMOOTH_QUAD_TO)return this.current;const{current:{x:t,y:n},control:{x:s,y:r}}=this;return new Xt(2*t-s,2*n-r)}makeAbsolute(e){if(this.command.relative){const{x:t,y:n}=this.current;e.x+=t,e.y+=n}return e}addMarker(e,t,n){const{points:s,angles:r}=this;n&&r.length>0&&!r[r.length-1]&&(r[r.length-1]=s[s.length-1].angleTo(n)),this.addMarkerAngle(e,t?t.angleTo(e):null)}addMarkerAngle(e,t){this.points.push(e),this.angles.push(t)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:e}=this,t=e.length;for(let n=0;n<t;n++)if(!e[n]){for(let s=n+1;s<t;s++)if(e[s]){e[n]=e[s];break}}return e}constructor(e){super(e.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),this.control=new Xt(0,0),this.start=new Xt(0,0),this.current=new Xt(0,0),this.command=null,this.commands=this.commands,this.i=-1,this.previousCommand=null,this.points=[],this.angles=[]}}class At extends Hn{path(e){const{pathParser:t}=this,n=new De;for(t.reset(),e&&e.beginPath();!t.isEnd();)switch(t.next().type){case pt.MOVE_TO:this.pathM(e,n);break;case pt.LINE_TO:this.pathL(e,n);break;case pt.HORIZ_LINE_TO:this.pathH(e,n);break;case pt.VERT_LINE_TO:this.pathV(e,n);break;case pt.CURVE_TO:this.pathC(e,n);break;case pt.SMOOTH_CURVE_TO:this.pathS(e,n);break;case pt.QUAD_TO:this.pathQ(e,n);break;case pt.SMOOTH_QUAD_TO:this.pathT(e,n);break;case pt.ARC:this.pathA(e,n);break;case pt.CLOSE_PATH:this.pathZ(e,n);break}return n}getBoundingBox(e){return this.path()}getMarkers(){const{pathParser:e}=this,t=e.getMarkerPoints(),n=e.getMarkerAngles();return t.map((r,o)=>[r,n[o]])}renderChildren(e){this.path(e),this.document.screen.mouse.checkPath(this,e);const t=this.getStyle("fill-rule");e.fillStyle!==""&&(t.getString("inherit")!=="inherit"?e.fill(t.getString()):e.fill()),e.strokeStyle!==""&&(this.getAttribute("vector-effect").getString()==="non-scaling-stroke"?(e.save(),e.setTransform(1,0,0,1,0,0),e.stroke(),e.restore()):e.stroke());const n=this.getMarkers();if(n){const s=n.length-1,r=this.getStyle("marker-start"),o=this.getStyle("marker-mid"),i=this.getStyle("marker-end");if(r.isUrlDefinition()){const a=r.getDefinition(),[c,h]=n[0];a.render(e,c,h)}if(o.isUrlDefinition()){const a=o.getDefinition();for(let c=1;c<s;c++){const[h,d]=n[c];a.render(e,h,d)}}if(i.isUrlDefinition()){const a=i.getDefinition(),[c,h]=n[s];a.render(e,c,h)}}}static pathM(e){const t=e.getAsCurrentPoint();return e.start=e.current,{point:t}}pathM(e,t){const{pathParser:n}=this,{point:s}=At.pathM(n),{x:r,y:o}=s;n.addMarker(s),t.addPoint(r,o),e&&e.moveTo(r,o)}static pathL(e){const{current:t}=e,n=e.getAsCurrentPoint();return{current:t,point:n}}pathL(e,t){const{pathParser:n}=this,{current:s,point:r}=At.pathL(n),{x:o,y:i}=r;n.addMarker(r,s),t.addPoint(o,i),e&&e.lineTo(o,i)}static pathH(e){const{current:t,command:n}=e,s=new Xt((n.relative?t.x:0)+n.x,t.y);return e.current=s,{current:t,point:s}}pathH(e,t){const{pathParser:n}=this,{current:s,point:r}=At.pathH(n),{x:o,y:i}=r;n.addMarker(r,s),t.addPoint(o,i),e&&e.lineTo(o,i)}static pathV(e){const{current:t,command:n}=e,s=new Xt(t.x,(n.relative?t.y:0)+n.y);return e.current=s,{current:t,point:s}}pathV(e,t){const{pathParser:n}=this,{current:s,point:r}=At.pathV(n),{x:o,y:i}=r;n.addMarker(r,s),t.addPoint(o,i),e&&e.lineTo(o,i)}static pathC(e){const{current:t}=e,n=e.getPoint("x1","y1"),s=e.getAsControlPoint("x2","y2"),r=e.getAsCurrentPoint();return{current:t,point:n,controlPoint:s,currentPoint:r}}pathC(e,t){const{pathParser:n}=this,{current:s,point:r,controlPoint:o,currentPoint:i}=At.pathC(n);n.addMarker(i,o,r),t.addBezierCurve(s.x,s.y,r.x,r.y,o.x,o.y,i.x,i.y),e&&e.bezierCurveTo(r.x,r.y,o.x,o.y,i.x,i.y)}static pathS(e){const{current:t}=e,n=e.getReflectedControlPoint(),s=e.getAsControlPoint("x2","y2"),r=e.getAsCurrentPoint();return{current:t,point:n,controlPoint:s,currentPoint:r}}pathS(e,t){const{pathParser:n}=this,{current:s,point:r,controlPoint:o,currentPoint:i}=At.pathS(n);n.addMarker(i,o,r),t.addBezierCurve(s.x,s.y,r.x,r.y,o.x,o.y,i.x,i.y),e&&e.bezierCurveTo(r.x,r.y,o.x,o.y,i.x,i.y)}static pathQ(e){const{current:t}=e,n=e.getAsControlPoint("x1","y1"),s=e.getAsCurrentPoint();return{current:t,controlPoint:n,currentPoint:s}}pathQ(e,t){const{pathParser:n}=this,{current:s,controlPoint:r,currentPoint:o}=At.pathQ(n);n.addMarker(o,r,r),t.addQuadraticCurve(s.x,s.y,r.x,r.y,o.x,o.y),e&&e.quadraticCurveTo(r.x,r.y,o.x,o.y)}static pathT(e){const{current:t}=e,n=e.getReflectedControlPoint();e.control=n;const s=e.getAsCurrentPoint();return{current:t,controlPoint:n,currentPoint:s}}pathT(e,t){const{pathParser:n}=this,{current:s,controlPoint:r,currentPoint:o}=At.pathT(n);n.addMarker(o,r,r),t.addQuadraticCurve(s.x,s.y,r.x,r.y,o.x,o.y),e&&e.quadraticCurveTo(r.x,r.y,o.x,o.y)}static pathA(e){const{current:t,command:n}=e;let{rX:s,rY:r,xRot:o,lArcFlag:i,sweepFlag:a}=n;const c=o*(Math.PI/180),h=e.getAsCurrentPoint(),d=new Xt(Math.cos(c)*(t.x-h.x)/2+Math.sin(c)*(t.y-h.y)/2,-Math.sin(c)*(t.x-h.x)/2+Math.cos(c)*(t.y-h.y)/2),u=Math.pow(d.x,2)/Math.pow(s,2)+Math.pow(d.y,2)/Math.pow(r,2);u>1&&(s*=Math.sqrt(u),r*=Math.sqrt(u));let p=(i===a?-1:1)*Math.sqrt((Math.pow(s,2)*Math.pow(r,2)-Math.pow(s,2)*Math.pow(d.y,2)-Math.pow(r,2)*Math.pow(d.x,2))/(Math.pow(s,2)*Math.pow(d.y,2)+Math.pow(r,2)*Math.pow(d.x,2)));isNaN(p)&&(p=0);const f=new Xt(p*s*d.y/r,p*-r*d.x/s),y=new Xt((t.x+h.x)/2+Math.cos(c)*f.x-Math.sin(c)*f.y,(t.y+h.y)/2+Math.sin(c)*f.x+Math.cos(c)*f.y),w=Ic([1,0],[(d.x-f.x)/s,(d.y-f.y)/r]),b=[(d.x-f.x)/s,(d.y-f.y)/r],x=[(-d.x-f.x)/s,(-d.y-f.y)/r];let v=Ic(b,x);return ko(b,x)<=-1&&(v=Math.PI),ko(b,x)>=1&&(v=0),{currentPoint:h,rX:s,rY:r,sweepFlag:a,xAxisRotation:c,centp:y,a1:w,ad:v}}pathA(e,t){const{pathParser:n}=this,{currentPoint:s,rX:r,rY:o,sweepFlag:i,xAxisRotation:a,centp:c,a1:h,ad:d}=At.pathA(n),u=1-i?1:-1,p=h+u*(d/2),f=new Xt(c.x+r*Math.cos(p),c.y+o*Math.sin(p));if(n.addMarkerAngle(f,p-u*Math.PI/2),n.addMarkerAngle(s,p-u*Math.PI),t.addPoint(s.x,s.y),e&&!isNaN(h)&&!isNaN(d)){const y=r>o?r:o,w=r>o?1:r/o,b=r>o?o/r:1;e.translate(c.x,c.y),e.rotate(a),e.scale(w,b),e.arc(0,0,y,h,h+d,!!(1-i)),e.scale(1/w,1/b),e.rotate(-a),e.translate(-c.x,-c.y)}}static pathZ(e){e.current=e.start}pathZ(e,t){At.pathZ(this.pathParser),e&&t.x1!==t.x2&&t.y1!==t.y2&&e.closePath()}constructor(e,t,n){super(e,t,n),this.type="path",this.pathParser=new pt(this.getAttribute("d").getString())}}class ks extends Hn{setContext(e){var t;const{document:n}=this,{screen:s,window:r}=n,o=e.canvas;if(s.setDefaults(e),"style"in o&&typeof e.font<"u"&&r&&typeof r.getComputedStyle<"u"){e.font=r.getComputedStyle(o).getPropertyValue("font");const x=new rt(n,"fontSize",ue.parse(e.font).fontSize);x.hasValue()&&(n.rootEmSize=x.getPixels("y"),n.emSize=n.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:i,height:a}=s.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const c=this.getAttribute("refX"),h=this.getAttribute("refY"),d=this.getAttribute("viewBox"),u=d.hasValue()?ve(d.getString()):null,p=!this.root&&this.getStyle("overflow").getValue("hidden")!=="visible";let f=0,y=0,w=0,b=0;u&&(f=u[0],y=u[1]),this.root||(i=this.getStyle("width").getPixels("x"),a=this.getStyle("height").getPixels("y"),this.type==="marker"&&(w=f,b=y,f=0,y=0)),s.viewPort.setCurrent(i,a),this.node&&(!this.parent||((t=this.node.parentNode)===null||t===void 0?void 0:t.nodeName)==="foreignObject")&&this.getStyle("transform",!1,!0).hasValue()&&!this.getStyle("transform-origin",!1,!0).hasValue()&&this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(e),e.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),u&&(i=u[2],a=u[3]),n.setViewBox({ctx:e,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:s.viewPort.width,desiredWidth:i,height:s.viewPort.height,desiredHeight:a,minX:f,minY:y,refX:c.getValue(),refY:h.getValue(),clip:p,clipX:w,clipY:b}),u&&(s.viewPort.removeCurrent(),s.viewPort.setCurrent(i,a))}clearContext(e){super.clearContext(e),this.document.screen.viewPort.removeCurrent()}resize(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const s=this.getAttribute("width",!0),r=this.getAttribute("height",!0),o=this.getAttribute("viewBox"),i=this.getAttribute("style"),a=s.getNumber(0),c=r.getNumber(0);if(n)if(typeof n=="string")this.getAttribute("preserveAspectRatio",!0).setValue(n);else{const h=this.getAttribute("preserveAspectRatio");h.hasValue()&&h.setValue(h.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(s.setValue(e),r.setValue(t),o.hasValue()||o.setValue("0 0 ".concat(a||e," ").concat(c||t)),i.hasValue()){const h=this.getStyle("width"),d=this.getStyle("height");h.hasValue()&&h.setValue("".concat(e,"px")),d.hasValue()&&d.setValue("".concat(t,"px"))}}constructor(...e){super(...e),this.type="svg",this.root=!1}}class Uc extends At{path(e){const t=this.getAttribute("x").getPixels("x"),n=this.getAttribute("y").getPixels("y"),s=this.getStyle("width",!1,!0).getPixels("x"),r=this.getStyle("height",!1,!0).getPixels("y"),o=this.getAttribute("rx"),i=this.getAttribute("ry");let a=o.getPixels("x"),c=i.getPixels("y");if(o.hasValue()&&!i.hasValue()&&(c=a),i.hasValue()&&!o.hasValue()&&(a=c),a=Math.min(a,s/2),c=Math.min(c,r/2),e){const h=4*((Math.sqrt(2)-1)/3);e.beginPath(),r>0&&s>0&&(e.moveTo(t+a,n),e.lineTo(t+s-a,n),e.bezierCurveTo(t+s-a+h*a,n,t+s,n+c-h*c,t+s,n+c),e.lineTo(t+s,n+r-c),e.bezierCurveTo(t+s,n+r-c+h*c,t+s-a+h*a,n+r,t+s-a,n+r),e.lineTo(t+a,n+r),e.bezierCurveTo(t+a-h*a,n+r,t,n+r-c+h*c,t,n+r-c),e.lineTo(t,n+c),e.bezierCurveTo(t,n+c-h*c,t+a-h*a,n,t+a,n),e.closePath())}return new De(t,n,t+s,n+r)}getMarkers(){return null}constructor(...e){super(...e),this.type="rect"}}class Pf extends At{path(e){const t=this.getAttribute("cx").getPixels("x"),n=this.getAttribute("cy").getPixels("y"),s=this.getAttribute("r").getPixels();return e&&s>0&&(e.beginPath(),e.arc(t,n,s,0,Math.PI*2,!1),e.closePath()),new De(t-s,n-s,t+s,n+s)}getMarkers(){return null}constructor(...e){super(...e),this.type="circle"}}class bf extends At{path(e){const t=4*((Math.sqrt(2)-1)/3),n=this.getAttribute("rx").getPixels("x"),s=this.getAttribute("ry").getPixels("y"),r=this.getAttribute("cx").getPixels("x"),o=this.getAttribute("cy").getPixels("y");return e&&n>0&&s>0&&(e.beginPath(),e.moveTo(r+n,o),e.bezierCurveTo(r+n,o+t*s,r+t*n,o+s,r,o+s),e.bezierCurveTo(r-t*n,o+s,r-n,o+t*s,r-n,o),e.bezierCurveTo(r-n,o-t*s,r-t*n,o-s,r,o-s),e.bezierCurveTo(r+t*n,o-s,r+n,o-t*s,r+n,o),e.closePath()),new De(r-n,o-s,r+n,o+s)}getMarkers(){return null}constructor(...e){super(...e),this.type="ellipse"}}class vf extends At{getPoints(){return[new Xt(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new Xt(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(e){const[{x:t,y:n},{x:s,y:r}]=this.getPoints();return e&&(e.beginPath(),e.moveTo(t,n),e.lineTo(s,r)),new De(t,n,s,r)}getMarkers(){const[e,t]=this.getPoints(),n=e.angleTo(t);return[[e,n],[t,n]]}constructor(...e){super(...e),this.type="line"}}class _c extends At{path(e){const{points:t}=this,[{x:n,y:s}]=t,r=new De(n,s);return e&&(e.beginPath(),e.moveTo(n,s)),t.forEach(o=>{let{x:i,y:a}=o;r.addPoint(i,a),e&&e.lineTo(i,a)}),r}getMarkers(){const{points:e}=this,t=e.length-1,n=[];return e.forEach((s,r)=>{r!==t&&n.push([s,s.angleTo(e[r+1])])}),n.length>0&&n.push([e[e.length-1],n[n.length-1][1]]),n}constructor(e,t,n){super(e,t,n),this.type="polyline",this.points=[],this.points=Xt.parsePath(this.getAttribute("points").getString())}}class Mf extends _c{path(e){const t=super.path(e),[{x:n,y:s}]=this.points;return e&&(e.lineTo(n,s),e.closePath()),t}constructor(...e){super(...e),this.type="polygon"}}class Sf extends kt{createPattern(e,t,n){const s=this.getStyle("width").getPixels("x",!0),r=this.getStyle("height").getPixels("y",!0),o=new ks(this.document,null);o.attributes.set("viewBox",new rt(this.document,"viewBox",this.getAttribute("viewBox").getValue())),o.attributes.set("width",new rt(this.document,"width","".concat(s,"px"))),o.attributes.set("height",new rt(this.document,"height","".concat(r,"px"))),o.attributes.set("transform",new rt(this.document,"transform",this.getAttribute("patternTransform").getValue())),o.children=this.children;const i=this.document.createCanvas(s,r),a=i.getContext("2d"),c=this.getAttribute("x"),h=this.getAttribute("y");c.hasValue()&&h.hasValue()&&a.translate(c.getPixels("x",!0),h.getPixels("y",!0)),n.hasValue()?this.styles.set("fill-opacity",n):this.styles.delete("fill-opacity");for(let u=-1;u<=1;u++)for(let p=-1;p<=1;p++)a.save(),o.attributes.set("x",new rt(this.document,"x",u*i.width)),o.attributes.set("y",new rt(this.document,"y",p*i.height)),o.render(a),a.restore();return e.createPattern(i,"repeat")}constructor(...e){super(...e),this.type="pattern"}}class Tf extends kt{render(e,t,n){if(!t)return;const{x:s,y:r}=t,o=this.getAttribute("orient").getString("auto"),i=this.getAttribute("markerUnits").getString("strokeWidth");e.translate(s,r),o==="auto"&&e.rotate(n),i==="strokeWidth"&&e.scale(e.lineWidth,e.lineWidth),e.save();const a=new ks(this.document);a.type=this.type,a.attributes.set("viewBox",new rt(this.document,"viewBox",this.getAttribute("viewBox").getValue())),a.attributes.set("refX",new rt(this.document,"refX",this.getAttribute("refX").getValue())),a.attributes.set("refY",new rt(this.document,"refY",this.getAttribute("refY").getValue())),a.attributes.set("width",new rt(this.document,"width",this.getAttribute("markerWidth").getValue())),a.attributes.set("height",new rt(this.document,"height",this.getAttribute("markerHeight").getValue())),a.attributes.set("overflow",new rt(this.document,"overflow",this.getAttribute("overflow").getValue())),a.attributes.set("fill",new rt(this.document,"fill",this.getAttribute("fill").getColor("black"))),a.attributes.set("stroke",new rt(this.document,"stroke",this.getAttribute("stroke").getValue("none"))),a.children=this.children,a.render(e),e.restore(),i==="strokeWidth"&&e.scale(1/e.lineWidth,1/e.lineWidth),o==="auto"&&e.rotate(-n),e.translate(-s,-r)}constructor(...e){super(...e),this.type="marker"}}class Cf extends kt{render(){}constructor(...e){super(...e),this.type="defs"}}class Oo extends Hn{getBoundingBox(e){const t=new De;return this.children.forEach(n=>{t.addBoundingBox(n.getBoundingBox(e))}),t}constructor(...e){super(...e),this.type="g"}}class Kc extends kt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(e,t,n){let s=this;this.getHrefAttribute().hasValue()&&(s=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(s));const{stops:r}=s,o=this.getGradient(e,t);if(!o)return this.addParentOpacity(n,r[r.length-1].color);if(r.forEach(i=>{o.addColorStop(i.offset,this.addParentOpacity(n,i.color))}),this.getAttribute("gradientTransform").hasValue()){const{document:i}=this,{MAX_VIRTUAL_PIXELS:a}=Ze,{viewPort:c}=i.screen,h=c.getRoot(),d=new Uc(i);d.attributes.set("x",new rt(i,"x",-a/3)),d.attributes.set("y",new rt(i,"y",-a/3)),d.attributes.set("width",new rt(i,"width",a)),d.attributes.set("height",new rt(i,"height",a));const u=new Oo(i);u.attributes.set("transform",new rt(i,"transform",this.getAttribute("gradientTransform").getValue())),u.children=[d];const p=new ks(i);p.attributes.set("x",new rt(i,"x",0)),p.attributes.set("y",new rt(i,"y",0)),p.attributes.set("width",new rt(i,"width",h.width)),p.attributes.set("height",new rt(i,"height",h.height)),p.children=[u];const f=i.createCanvas(h.width,h.height),y=f.getContext("2d");return y.fillStyle=o,p.render(y),y.createPattern(f,"no-repeat")}return o}inheritStopContainer(e){this.attributesToInherit.forEach(t=>{!this.getAttribute(t).hasValue()&&e.getAttribute(t).hasValue()&&this.getAttribute(t,!0).setValue(e.getAttribute(t).getValue())})}addParentOpacity(e,t){return e.hasValue()?new rt(this.document,"color",t).addOpacity(e).getColor():t}constructor(e,t,n){super(e,t,n),this.attributesToInherit=["gradientUnits"],this.stops=[];const{stops:s,children:r}=this;r.forEach(o=>{o.type==="stop"&&s.push(o)})}}class Lf extends Kc{getGradient(e,t){const n=this.getGradientUnits()==="objectBoundingBox",s=n?t.getBoundingBox(e):null;if(n&&!s)return null;!this.getAttribute("x1").hasValue()&&!this.getAttribute("y1").hasValue()&&!this.getAttribute("x2").hasValue()&&!this.getAttribute("y2").hasValue()&&(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const r=n?s.x+s.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),o=n?s.y+s.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),i=n?s.x+s.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),a=n?s.y+s.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return r===i&&o===a?null:e.createLinearGradient(r,o,i,a)}constructor(e,t,n){super(e,t,n),this.type="linearGradient",this.attributesToInherit.push("x1","y1","x2","y2")}}class Af extends Kc{getGradient(e,t){const n=this.getGradientUnits()==="objectBoundingBox",s=t.getBoundingBox(e);if(n&&!s)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const r=n?s.x+s.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),o=n?s.y+s.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let i=r,a=o;this.getAttribute("fx").hasValue()&&(i=n?s.x+s.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(a=n?s.y+s.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const c=n?(s.width+s.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),h=this.getAttribute("fr").getPixels();return e.createRadialGradient(i,a,h,r,o,c)}constructor(e,t,n){super(e,t,n),this.type="radialGradient",this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}}class Rf extends kt{constructor(e,t,n){super(e,t,n),this.type="stop";const s=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),r=this.getStyle("stop-opacity");let o=this.getStyle("stop-color",!0);o.getString()===""&&o.setValue("#000"),r.hasValue()&&(o=o.addOpacity(r)),this.offset=s,this.color=o.getColor()}}class Do extends kt{getProperty(){const e=this.getAttribute("attributeType").getString(),t=this.getAttribute("attributeName").getString();return e==="CSS"?this.parent.getStyle(t,!0):this.parent.getAttribute(t,!0)}calcValue(){const{initialUnits:e}=this,{progress:t,from:n,to:s}=this.getProgress();let r=n.getNumber()+(s.getNumber()-n.getNumber())*t;return e==="%"&&(r*=100),"".concat(r).concat(e)}update(e){const{parent:t}=this,n=this.getProperty();if(this.initialValue||(this.initialValue=n.getString(),this.initialUnits=n.getUnits()),this.duration>this.maxDuration){const r=this.getAttribute("fill").getString("remove");if(this.getAttribute("repeatCount").getString()==="indefinite"||this.getAttribute("repeatDur").getString()==="indefinite")this.duration=0;else if(r==="freeze"&&!this.frozen)this.frozen=!0,t&&n&&(t.animationFrozen=!0,t.animationFrozenValue=n.getString());else if(r==="remove"&&!this.removed)return this.removed=!0,t&&n&&n.setValue(t.animationFrozen?t.animationFrozenValue:this.initialValue),!0;return!1}this.duration+=e;let s=!1;if(this.begin<this.duration){let r=this.calcValue();const o=this.getAttribute("type");if(o.hasValue()){const i=o.getString();r="".concat(i,"(").concat(r,")")}n.setValue(r),s=!0}return s}getProgress(){const{document:e,values:t}=this;let n=(this.duration-this.begin)/(this.maxDuration-this.begin),s,r;if(t.hasValue()){const o=n*(t.getValue().length-1),i=Math.floor(o),a=Math.ceil(o);let c;c=t.getValue()[i],s=new rt(e,"from",c?parseFloat(c):0),c=t.getValue()[a],r=new rt(e,"to",c?parseFloat(c):0),n=(o-i)/(a-i)}else s=this.from,r=this.to;return{progress:n,from:s,to:r}}constructor(e,t,n){super(e,t,n),this.type="animate",this.duration=0,this.initialUnits="",this.removed=!1,this.frozen=!1,e.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new rt(e,"values",null);const s=this.getAttribute("values");s.hasValue()&&this.values.setValue(s.getString().split(";"))}}class Nf extends Do{calcValue(){const{progress:e,from:t,to:n}=this.getProgress(),s=new No(t.getColor()),r=new No(n.getColor());if(s.ok&&r.ok){const o=s.r+(r.r-s.r)*e,i=s.g+(r.g-s.g)*e,a=s.b+(r.b-s.b)*e;return"rgb(".concat(Math.floor(o),", ").concat(Math.floor(i),", ").concat(Math.floor(a),")")}return this.getAttribute("from").getColor()}constructor(...e){super(...e),this.type="animateColor"}}class Ef extends Do{calcValue(){const{progress:e,from:t,to:n}=this.getProgress(),s=ve(t.getString()),r=ve(n.getString());return s.map((i,a)=>{const c=r[a];return i+(c-i)*e}).join(" ")}constructor(...e){super(...e),this.type="animateTransform"}}class jc extends kt{constructor(e,t,n){super(e,t,n),this.type="font-face",this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}class Ho extends At{constructor(e,t,n){super(e,t,n),this.type="glyph",this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}class qc extends Ho{constructor(...e){super(...e),this.type="missing-glyph",this.horizAdvX=0}}class If extends kt{render(){}constructor(e,t,n){super(e,t,n),this.type="font",this.isArabic=!1,this.glyphs=new Map,this.arabicGlyphs=new Map,this.isRTL=!1,this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:s}=e,{children:r}=this;for(const o of r)if(o instanceof jc){this.fontFace=o;const i=o.getStyle("font-family");i.hasValue()&&s.set(i.getString(),this)}else if(o instanceof qc)this.missingGlyph=o;else if(o instanceof Ho)if(o.arabicForm){this.isRTL=!0,this.isArabic=!0;let i=this.arabicGlyphs.get(o.unicode);typeof i>"u"&&(i=new Map,this.arabicGlyphs.set(o.unicode,i)),i.set(o.arabicForm,o)}else this.glyphs.set(o.unicode,o)}}class kf extends pn{getText(){const e=this.getHrefAttribute().getDefinition();if(e){const t=e.children[0];if(t)return t.getText()}return""}constructor(...e){super(...e),this.type="tref"}}class Bf extends pn{getText(){return this.text}renderChildren(e){if(this.hasText){super.renderChildren(e);const{document:t,x:n,y:s}=this,{mouse:r}=t.screen,o=new rt(t,"fontSize",ue.parse(t.ctx.font).fontSize);r.isWorking()&&r.checkBoundingBox(this,new De(n,s-o.getPixels("y"),n+this.measureText(e),s))}else if(this.children.length>0){const t=new Oo(this.document);t.children=this.children,t.parent=this,t.render(e)}}onClick(){const{window:e}=this.document;e&&e.open(this.getHrefAttribute().getString())}onMouseMove(){const e=this.document.ctx;e.canvas.style.cursor="pointer"}constructor(e,t,n){super(e,t,n),this.type="a";const{childNodes:s}=t,r=s[0],o=s.length>0&&Array.from(s).every(i=>i.nodeType===3);this.hasText=o,this.text=o?this.getTextFromNode(r):""}}class Of extends pn{getText(){return this.text}path(e){const{dataArray:t}=this;e&&e.beginPath(),t.forEach(n=>{let{type:s,points:r}=n;switch(s){case pt.LINE_TO:e&&e.lineTo(r[0],r[1]);break;case pt.MOVE_TO:e&&e.moveTo(r[0],r[1]);break;case pt.CURVE_TO:e&&e.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case pt.QUAD_TO:e&&e.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case pt.ARC:{const[o,i,a,c,h,d,u,p]=r,f=a>c?a:c,y=a>c?1:a/c,w=a>c?c/a:1;e&&(e.translate(o,i),e.rotate(u),e.scale(y,w),e.arc(0,0,f,h,h+d,!!(1-p)),e.scale(1/y,1/w),e.rotate(-u),e.translate(-o,-i));break}case pt.CLOSE_PATH:e&&e.closePath();break}})}renderChildren(e){this.setTextData(e),e.save();const t=this.parent.getStyle("text-decoration").getString(),n=this.getFontSize(),{glyphInfo:s}=this,r=e.fillStyle;t==="underline"&&e.beginPath(),s.forEach((o,i)=>{const{p0:a,p1:c,rotation:h,text:d}=o;e.save(),e.translate(a.x,a.y),e.rotate(h),e.fillStyle&&e.fillText(d,0,0),e.strokeStyle&&e.strokeText(d,0,0),e.restore(),t==="underline"&&(i===0&&e.moveTo(a.x,a.y+n/8),e.lineTo(c.x,c.y+n/5))}),t==="underline"&&(e.lineWidth=n/20,e.strokeStyle=r,e.stroke(),e.closePath()),e.restore()}getLetterSpacingAt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.letterSpacingCache[e]||0}findSegmentToFitChar(e,t,n,s,r,o,i,a,c){let h=o,d=this.measureText(e,a);a===" "&&t==="justify"&&n<s&&(d+=(s-n)/r),c>-1&&(h+=this.getLetterSpacingAt(c));const u=this.textHeight/20,p=this.getEquidistantPointOnPath(h,u,0),f=this.getEquidistantPointOnPath(h+d,u,0),y={p0:p,p1:f},w=p&&f?Math.atan2(f.y-p.y,f.x-p.x):0;if(i){const b=Math.cos(Math.PI/2+w)*i,x=Math.cos(-w)*i;y.p0={...p,x:p.x+b,y:p.y+x},y.p1={...f,x:f.x+b,y:f.y+x}}return h+=d,{offset:h,segment:y,rotation:w}}measureText(e,t){const{measuresCache:n}=this,s=t||this.getText();if(n.has(s))return n.get(s);const r=this.measureTargetText(e,s);return n.set(s,r),r}setTextData(e){if(this.glyphInfo)return;const t=this.getText(),n=t.split(""),s=t.split(" ").length-1,r=this.parent.getAttribute("dx").split().map(v=>v.getPixels("x")),o=this.parent.getAttribute("dy").getPixels("y"),i=this.parent.getStyle("text-anchor").getString("start"),a=this.getStyle("letter-spacing"),c=this.parent.getStyle("letter-spacing");let h=0;!a.hasValue()||a.getValue()==="inherit"?h=c.getPixels():a.hasValue()&&a.getValue()!=="initial"&&a.getValue()!=="unset"&&(h=a.getPixels());const d=[],u=t.length;this.letterSpacingCache=d;for(let v=0;v<u;v++)d.push(typeof r[v]<"u"?r[v]:h);const p=d.reduce((v,C,E)=>E===0?0:v+C||0,0),f=this.measureText(e),y=Math.max(f+p,0);this.textWidth=f,this.textHeight=this.getFontSize(),this.glyphInfo=[];const w=this.getPathLength(),b=this.getStyle("startOffset").getNumber(0)*w;let x=0;(i==="middle"||i==="center")&&(x=-y/2),(i==="end"||i==="right")&&(x=-y),x+=b,n.forEach((v,C)=>{const{offset:E,segment:k,rotation:I}=this.findSegmentToFitChar(e,i,y,w,s,x,o,v,C);x=E,!(!k.p0||!k.p1)&&this.glyphInfo.push({text:n[C],p0:k.p0,p1:k.p1,rotation:I})})}parsePathData(e){if(this.pathLength=-1,!e)return[];const t=[],{pathParser:n}=e;for(n.reset();!n.isEnd();){const{current:s}=n,r=s?s.x:0,o=s?s.y:0,i=n.next();let a=i.type,c=[];switch(i.type){case pt.MOVE_TO:this.pathM(n,c);break;case pt.LINE_TO:a=this.pathL(n,c);break;case pt.HORIZ_LINE_TO:a=this.pathH(n,c);break;case pt.VERT_LINE_TO:a=this.pathV(n,c);break;case pt.CURVE_TO:this.pathC(n,c);break;case pt.SMOOTH_CURVE_TO:a=this.pathS(n,c);break;case pt.QUAD_TO:this.pathQ(n,c);break;case pt.SMOOTH_QUAD_TO:a=this.pathT(n,c);break;case pt.ARC:c=this.pathA(n);break;case pt.CLOSE_PATH:At.pathZ(n);break}i.type!==pt.CLOSE_PATH?t.push({type:a,points:c,start:{x:r,y:o},pathLength:this.calcLength(r,o,a,c)}):t.push({type:pt.CLOSE_PATH,points:[],pathLength:0})}return t}pathM(e,t){const{x:n,y:s}=At.pathM(e).point;t.push(n,s)}pathL(e,t){const{x:n,y:s}=At.pathL(e).point;return t.push(n,s),pt.LINE_TO}pathH(e,t){const{x:n,y:s}=At.pathH(e).point;return t.push(n,s),pt.LINE_TO}pathV(e,t){const{x:n,y:s}=At.pathV(e).point;return t.push(n,s),pt.LINE_TO}pathC(e,t){const{point:n,controlPoint:s,currentPoint:r}=At.pathC(e);t.push(n.x,n.y,s.x,s.y,r.x,r.y)}pathS(e,t){const{point:n,controlPoint:s,currentPoint:r}=At.pathS(e);return t.push(n.x,n.y,s.x,s.y,r.x,r.y),pt.CURVE_TO}pathQ(e,t){const{controlPoint:n,currentPoint:s}=At.pathQ(e);t.push(n.x,n.y,s.x,s.y)}pathT(e,t){const{controlPoint:n,currentPoint:s}=At.pathT(e);return t.push(n.x,n.y,s.x,s.y),pt.QUAD_TO}pathA(e){let{rX:t,rY:n,sweepFlag:s,xAxisRotation:r,centp:o,a1:i,ad:a}=At.pathA(e);return s===0&&a>0&&(a-=2*Math.PI),s===1&&a<0&&(a+=2*Math.PI),[o.x,o.y,t,n,i,a,r,s]}calcLength(e,t,n,s){let r=0,o=null,i=null,a=0;switch(n){case pt.LINE_TO:return this.getLineLength(e,t,s[0],s[1]);case pt.CURVE_TO:for(r=0,o=this.getPointOnCubicBezier(0,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),a=.01;a<=1;a+=.01)i=this.getPointOnCubicBezier(a,e,t,s[0],s[1],s[2],s[3],s[4],s[5]),r+=this.getLineLength(o.x,o.y,i.x,i.y),o=i;return r;case pt.QUAD_TO:for(r=0,o=this.getPointOnQuadraticBezier(0,e,t,s[0],s[1],s[2],s[3]),a=.01;a<=1;a+=.01)i=this.getPointOnQuadraticBezier(a,e,t,s[0],s[1],s[2],s[3]),r+=this.getLineLength(o.x,o.y,i.x,i.y),o=i;return r;case pt.ARC:{r=0;const c=s[4],h=s[5],d=s[4]+h;let u=Math.PI/180;if(Math.abs(c-d)<u&&(u=Math.abs(c-d)),o=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],c,0),h<0)for(a=c-u;a>d;a-=u)i=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],a,0),r+=this.getLineLength(o.x,o.y,i.x,i.y),o=i;else for(a=c+u;a<d;a+=u)i=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],a,0),r+=this.getLineLength(o.x,o.y,i.x,i.y),o=i;return i=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),r+=this.getLineLength(o.x,o.y,i.x,i.y),r}}return 0}getPointOnLine(e,t,n,s,r){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:t,i=arguments.length>6&&arguments[6]!==void 0?arguments[6]:n;const a=(r-n)/(s-t+ns);let c=Math.sqrt(e*e/(1+a*a));s<t&&(c*=-1);let h=a*c,d=null;if(s===t)d={x:o,y:i+h};else if((i-n)/(o-t+ns)===a)d={x:o+c,y:i+h};else{let u=0,p=0;const f=this.getLineLength(t,n,s,r);if(f<ns)return null;let y=(o-t)*(s-t)+(i-n)*(r-n);y/=f*f,u=t+y*(s-t),p=n+y*(r-n);const w=this.getLineLength(o,i,u,p),b=Math.sqrt(e*e-w*w);c=Math.sqrt(b*b/(1+a*a)),s<t&&(c*=-1),h=a*c,d={x:u+c,y:p+h}}return d}getPointOnPath(e){const t=this.getPathLength();let n=0,s=null;if(e<-5e-5||e-5e-5>t)return null;const{dataArray:r}=this;for(const o of r){if(o&&(o.pathLength<5e-5||n+o.pathLength+5e-5<e)){n+=o.pathLength;continue}const i=e-n;let a=0;switch(o.type){case pt.LINE_TO:s=this.getPointOnLine(i,o.start.x,o.start.y,o.points[0],o.points[1],o.start.x,o.start.y);break;case pt.ARC:{const c=o.points[4],h=o.points[5],d=o.points[4]+h;if(a=c+i/o.pathLength*h,h<0&&a<d||h>=0&&a>d)break;s=this.getPointOnEllipticalArc(o.points[0],o.points[1],o.points[2],o.points[3],a,o.points[6]);break}case pt.CURVE_TO:a=i/o.pathLength,a>1&&(a=1),s=this.getPointOnCubicBezier(a,o.start.x,o.start.y,o.points[0],o.points[1],o.points[2],o.points[3],o.points[4],o.points[5]);break;case pt.QUAD_TO:a=i/o.pathLength,a>1&&(a=1),s=this.getPointOnQuadraticBezier(a,o.start.x,o.start.y,o.points[0],o.points[1],o.points[2],o.points[3]);break}if(s)return s;break}return null}getLineLength(e,t,n,s){return Math.sqrt((n-e)*(n-e)+(s-t)*(s-t))}getPathLength(){return this.pathLength===-1&&(this.pathLength=this.dataArray.reduce((e,t)=>t.pathLength>0?e+t.pathLength:e,0)),this.pathLength}getPointOnCubicBezier(e,t,n,s,r,o,i,a,c){const h=a*kc(e)+o*Bc(e)+s*Oc(e)+t*Dc(e),d=c*kc(e)+i*Bc(e)+r*Oc(e)+n*Dc(e);return{x:h,y:d}}getPointOnQuadraticBezier(e,t,n,s,r,o,i){const a=o*Hc(e)+s*zc(e)+t*Xc(e),c=i*Hc(e)+r*zc(e)+n*Xc(e);return{x:a,y:c}}getPointOnEllipticalArc(e,t,n,s,r,o){const i=Math.cos(o),a=Math.sin(o),c={x:n*Math.cos(r),y:s*Math.sin(r)};return{x:e+(c.x*i-c.y*a),y:t+(c.x*a+c.y*i)}}buildEquidistantCache(e,t){const n=this.getPathLength(),s=t||.25,r=e||n/100;if(!this.equidistantCache||this.equidistantCache.step!==r||this.equidistantCache.precision!==s){this.equidistantCache={step:r,precision:s,points:[]};let o=0;for(let i=0;i<=n;i+=s){const a=this.getPointOnPath(i),c=this.getPointOnPath(i+s);!a||!c||(o+=this.getLineLength(a.x,a.y,c.x,c.y),o>=r&&(this.equidistantCache.points.push({x:a.x,y:a.y,distance:i}),o-=r))}}}getEquidistantPointOnPath(e,t,n){if(this.buildEquidistantCache(t,n),e<0||e-this.getPathLength()>5e-5)return null;const s=Math.round(e/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[s]||null}constructor(e,t,n){super(e,t,n),this.type="textPath",this.textWidth=0,this.textHeight=0,this.pathLength=-1,this.glyphInfo=null,this.letterSpacingCache=[],this.measuresCache=new Map([["",0]]);const s=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(s)}}const Df=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;class Hf extends Hn{async loadImage(e){try{const t=await this.document.createImage(e);this.image=t}catch(t){console.error('Error while loading image "'.concat(e,'":'),t)}this.loaded=!0}async loadSvg(e){const t=Df.exec(e);if(t){const n=t[5];n&&(t[4]==="base64"?this.image=atob(n):this.image=decodeURIComponent(n))}else try{const s=await(await this.document.fetch(e)).text();this.image=s}catch(n){console.error('Error while loading image "'.concat(e,'":'),n)}this.loaded=!0}renderChildren(e){const{document:t,image:n,loaded:s}=this,r=this.getAttribute("x").getPixels("x"),o=this.getAttribute("y").getPixels("y"),i=this.getStyle("width").getPixels("x"),a=this.getStyle("height").getPixels("y");if(!(!s||!n||!i||!a)){if(e.save(),e.translate(r,o),typeof n=="string"){const c=t.canvg.forkString(e,n,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:i,scaleHeight:a}),{documentElement:h}=c.document;h&&(h.parent=this),c.render()}else t.setViewBox({ctx:e,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:i,desiredWidth:n.width,height:a,desiredHeight:n.height}),this.loaded&&(!("complete"in n)||n.complete)&&e.drawImage(n,0,0);e.restore()}}getBoundingBox(){const e=this.getAttribute("x").getPixels("x"),t=this.getAttribute("y").getPixels("y"),n=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");return new De(e,t,e+n,t+s)}constructor(e,t,n){super(e,t,n),this.type="image",this.loaded=!1;const s=this.getHrefAttribute().getString();if(!s)return;const r=s.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(s);e.images.push(this),r?this.loadSvg(s):this.loadImage(s)}}class zf extends Hn{render(e){}constructor(...e){super(...e),this.type="symbol"}}class Xf{async load(e,t){try{const{document:n}=this,r=(await n.canvg.parser.load(t)).getElementsByTagName("font");Array.from(r).forEach(o=>{const i=n.createElement(o);n.definitions.set(e,i)})}catch(n){console.error('Error while loading font "'.concat(t,'":'),n)}this.loaded=!0}constructor(e){this.document=e,this.loaded=!1,e.fonts.push(this)}}class $c extends kt{constructor(e,t,n){super(e,t,n),this.type="style",es(Array.from(t.childNodes).map(o=>o.textContent).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach(o=>{const i=o.trim();if(!i)return;const a=i.split("{"),c=a[0].split(","),h=a[1].split(";");c.forEach(d=>{const u=d.trim();if(!u)return;const p=e.styles.get(u)||new Map;if(h.forEach(f=>{const y=f.indexOf(":"),w=f.substr(0,y).trim(),b=f.substr(y+1,f.length-y).trim();w&&b&&p.set(w,new rt(e,w,b))}),e.styles.set(u,p),e.stylesSpecificity.set(u,nf(u)),u==="@font-face"){const f=p.get("font-family").getString().replace(/"|'/g,"");p.get("src").getString().split(",").forEach(w=>{if(w.indexOf('format("svg")')>0){const b=Nc(w);b&&new Xf(e).load(f,b)}})}})})}}$c.parseExternalUrl=Nc;class Yf extends Hn{setContext(e){super.setContext(e);const t=this.getAttribute("x"),n=this.getAttribute("y");t.hasValue()&&e.translate(t.getPixels("x"),0),n.hasValue()&&e.translate(0,n.getPixels("y"))}path(e){const{element:t}=this;t&&t.path(e)}renderChildren(e){const{document:t,element:n}=this;if(n){let s=n;if(n.type==="symbol"&&(s=new ks(t),s.attributes.set("viewBox",new rt(t,"viewBox",n.getAttribute("viewBox").getString())),s.attributes.set("preserveAspectRatio",new rt(t,"preserveAspectRatio",n.getAttribute("preserveAspectRatio").getString())),s.attributes.set("overflow",new rt(t,"overflow",n.getAttribute("overflow").getString())),s.children=n.children,n.styles.set("opacity",new rt(t,"opacity",this.calculateOpacity()))),s.type==="svg"){const o=this.getStyle("width",!1,!0),i=this.getStyle("height",!1,!0);o.hasValue()&&s.attributes.set("width",new rt(t,"width",o.getString())),i.hasValue()&&s.attributes.set("height",new rt(t,"height",i.getString()))}const r=s.parent;s.parent=this,s.render(e),s.parent=r}}getBoundingBox(e){const{element:t}=this;return t?t.getBoundingBox(e):null}elementTransform(){const{document:e,element:t}=this;return t?Dn.fromElement(e,t):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...e){super(...e),this.type="use"}}function Mr(l,e,t,n,s,r){return l[t*n*4+e*4+r]}function Sr(l,e,t,n,s,r,o){l[t*n*4+e*4+r]=o}function Ut(l,e,t){return l[e]*t}function Je(l,e,t,n){return e+Math.cos(l)*t+Math.sin(l)*n}class Qc extends kt{apply(e,t,n,s,r){const{includeOpacity:o,matrix:i}=this,a=e.getImageData(0,0,s,r);for(let c=0;c<r;c++)for(let h=0;h<s;h++){const d=Mr(a.data,h,c,s,r,0),u=Mr(a.data,h,c,s,r,1),p=Mr(a.data,h,c,s,r,2),f=Mr(a.data,h,c,s,r,3);let y=Ut(i,0,d)+Ut(i,1,u)+Ut(i,2,p)+Ut(i,3,f)+Ut(i,4,1),w=Ut(i,5,d)+Ut(i,6,u)+Ut(i,7,p)+Ut(i,8,f)+Ut(i,9,1),b=Ut(i,10,d)+Ut(i,11,u)+Ut(i,12,p)+Ut(i,13,f)+Ut(i,14,1),x=Ut(i,15,d)+Ut(i,16,u)+Ut(i,17,p)+Ut(i,18,f)+Ut(i,19,1);o&&(y=0,w=0,b=0,x*=f/255),Sr(a.data,h,c,s,r,0,y),Sr(a.data,h,c,s,r,1,w),Sr(a.data,h,c,s,r,2,b),Sr(a.data,h,c,s,r,3,x)}e.clearRect(0,0,s,r),e.putImageData(a,0,0)}constructor(e,t,n){super(e,t,n),this.type="feColorMatrix";let s=ve(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const r=s[0];s=[.213+.787*r,.715-.715*r,.072-.072*r,0,0,.213-.213*r,.715+.285*r,.072-.072*r,0,0,.213-.213*r,.715-.715*r,.072+.928*r,0,0,0,0,0,1,0,0,0,0,0,1];break}case"hueRotate":{const r=s[0]*Math.PI/180;s=[Je(r,.213,.787,-.213),Je(r,.715,-.715,-.715),Je(r,.072,-.072,.928),0,0,Je(r,.213,-.213,.143),Je(r,.715,.285,.14),Je(r,.072,-.072,-.283),0,0,Je(r,.213,-.213,-.787),Je(r,.715,-.715,.715),Je(r,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1];break}this.matrix=s,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}class Tr extends kt{apply(e,t){const{document:n}=this;let s=this.getAttribute("x").getPixels("x"),r=this.getAttribute("y").getPixels("y"),o=this.getStyle("width").getPixels("x"),i=this.getStyle("height").getPixels("y");if(!o&&!i){const p=new De;this.children.forEach(f=>{p.addBoundingBox(f.getBoundingBox(e))}),s=Math.floor(p.x1),r=Math.floor(p.y1),o=Math.floor(p.width),i=Math.floor(p.height)}const a=this.removeStyles(t,Tr.ignoreStyles),c=n.createCanvas(s+o,r+i),h=c.getContext("2d");n.screen.setDefaults(h),this.renderChildren(h),new Qc(n,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(h,0,0,s+o,r+i);const d=n.createCanvas(s+o,r+i),u=d.getContext("2d");n.screen.setDefaults(u),t.render(u),u.globalCompositeOperation="destination-in",u.fillStyle=h.createPattern(c,"no-repeat"),u.fillRect(0,0,s+o,r+i),e.fillStyle=u.createPattern(d,"no-repeat"),e.fillRect(0,0,s+o,r+i),this.restoreStyles(t,a)}render(e){}constructor(...e){super(...e),this.type="mask"}}Tr.ignoreStyles=["mask","transform","clip-path"];const Zc=()=>{};class Ff extends kt{apply(e){const{document:t}=this,n=Reflect.getPrototypeOf(e),{beginPath:s,closePath:r}=e;n&&(n.beginPath=Zc,n.closePath=Zc),Reflect.apply(s,e,[]),this.children.forEach(o=>{if(!("path"in o))return;let i="elementTransform"in o?o.elementTransform():null;i||(i=Dn.fromElement(t,o)),i&&i.apply(e),o.path(e),n&&(n.closePath=r),i&&i.unapply(e)}),Reflect.apply(r,e,[]),e.clip(),n&&(n.beginPath=s,n.closePath=r)}render(e){}constructor(...e){super(...e),this.type="clipPath"}}class Cr extends kt{apply(e,t){const{document:n,children:s}=this,r="getBoundingBox"in t?t.getBoundingBox(e):null;if(!r)return;let o=0,i=0;s.forEach(b=>{const x=b.extraFilterDistance||0;o=Math.max(o,x),i=Math.max(i,x)});const a=Math.floor(r.width),c=Math.floor(r.height),h=a+2*o,d=c+2*i;if(h<1||d<1)return;const u=Math.floor(r.x),p=Math.floor(r.y),f=this.removeStyles(t,Cr.ignoreStyles),y=n.createCanvas(h,d),w=y.getContext("2d");n.screen.setDefaults(w),w.translate(-u+o,-p+i),t.render(w),s.forEach(b=>{typeof b.apply=="function"&&b.apply(w,0,0,h,d)}),e.drawImage(y,0,0,h,d,u-o,p-i,h,d),this.restoreStyles(t,f)}render(e){}constructor(...e){super(...e),this.type="filter"}}Cr.ignoreStyles=["filter","transform","clip-path"];class Vf extends kt{apply(e,t,n,s,r){}constructor(e,t,n){super(e,t,n),this.type="feDropShadow",this.addStylesFromStyleDefinition()}}class Wf extends kt{apply(e,t,n,s,r){}constructor(...e){super(...e),this.type="feMorphology"}}class Gf extends kt{apply(e,t,n,s,r){}constructor(...e){super(...e),this.type="feComposite"}}class Uf extends kt{apply(e,t,n,s,r){const{document:o,blurRadius:i}=this,a=o.window?o.window.document.body:null,c=e.canvas;c.id=o.getUniqueId(),a&&(c.style.display="none",a.appendChild(c)),Fp(c,t,n,s,r,i),a&&a.removeChild(c)}constructor(e,t,n){super(e,t,n),this.type="feGaussianBlur",this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}class _f extends kt{constructor(...e){super(...e),this.type="title"}}class Kf extends kt{constructor(...e){super(...e),this.type="desc"}}const jf={svg:ks,rect:Uc,circle:Pf,ellipse:bf,line:vf,polyline:_c,polygon:Mf,path:At,pattern:Sf,marker:Tf,defs:Cf,linearGradient:Lf,radialGradient:Af,stop:Rf,animate:Do,animateColor:Nf,animateTransform:Ef,font:If,"font-face":jc,"missing-glyph":qc,glyph:Ho,text:pn,tspan:vr,tref:kf,a:Bf,textPath:Of,image:Hf,g:Oo,symbol:zf,style:$c,use:Yf,mask:Tr,clipPath:Ff,filter:Cr,feDropShadow:Vf,feMorphology:Wf,feComposite:Gf,feColorMatrix:Qc,feGaussianBlur:Uf,title:_f,desc:Kf};function qf(l,e){const t=document.createElement("canvas");return t.width=l,t.height=e,t}async function $f(l){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const t=document.createElement("img");return e&&(t.crossOrigin="Anonymous"),new Promise((n,s)=>{t.onload=()=>{n(t)},t.onerror=(r,o,i,a,c)=>{s(c)},t.src=l})}const zo=12;class fn{bindCreateImage(e,t){return typeof t=="boolean"?(n,s)=>e(n,typeof s=="boolean"?s:t):e}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:e}=this;return e[e.length-1]||zo}set emSize(e){const{emSizeStack:t}=this;t.push(e)}popEmSize(){const{emSizeStack:e}=this;e.pop()}getUniqueId(){return"canvg".concat(++this.uniqueId)}isImagesLoaded(){return this.images.every(e=>e.loaded)}isFontsLoaded(){return this.fonts.every(e=>e.loaded)}createDocumentElement(e){const t=this.createElement(e.documentElement);return t.root=!0,t.addStylesFromStyleDefinition(),this.documentElement=t,t}createElement(e){const t=e.nodeName.replace(/^[^:]+:/,""),n=fn.elementTypes[t];return n?new n(this,e):new ff(this,e)}createTextNode(e){return new xf(this,e)}setViewBox(e){this.screen.setViewBox({document:this,...e})}constructor(e,{rootEmSize:t=zo,emSize:n=zo,createCanvas:s=fn.createCanvas,createImage:r=fn.createImage,anonymousCrossOrigin:o}={}){this.canvg=e,this.definitions=new Map,this.styles=new Map,this.stylesSpecificity=new Map,this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=e.screen,this.rootEmSize=t,this.emSize=n,this.createCanvas=s,this.createImage=this.bindCreateImage(r,o),this.screen.wait(()=>this.isImagesLoaded()),this.screen.wait(()=>this.isFontsLoaded())}}fn.createCanvas=qf,fn.createImage=$f,fn.elementTypes=jf;class ss{static async from(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=await new Bo(n).parse(t);return new ss(e,r,n)}static fromString(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=new Bo(n).parseFromString(t);return new ss(e,r,n)}fork(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return ss.from(e,t,{...this.options,...n})}forkString(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return ss.fromString(e,t,{...this.options,...n})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...e}),await this.ready(),this.stop()}start(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{documentElement:t,screen:n,options:s}=this;n.start(t,{enableRedraw:!0,...s,...e})}stop(){this.screen.stop()}resize(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.documentElement.resize(e,t,n)}constructor(e,t,n={}){this.parser=new Bo(n),this.screen=new Ze(e,n),this.options=n;const s=new fn(this,n),r=s.createDocumentElement(t);this.document=s,this.documentElement=r}}class Jc{async work(e,t,n){const s=n.getScale();try{const r=e.baseProps,o=s*r.width,i=s*r.height,a=new OffscreenCanvas(2*o,2*i),c=a.getContext("2d");await(await ss.from(c,t)).render();const d=a.transferToImageBitmap();e.setImageBitmap(d)}catch(r){console.error("加载svg图片出现问题",r),e.setBroken()}n.dirtyDraw(e.getBounds())}}class Qf extends Lo{constructor(){super(...arguments);g(this,"svgWorker",new fo)}enable(t){return t===ft.Resource}async handle(t,n){const s=new m(0,0),r=n.previewManager.previewResourceManager.previewSvgCode;r===""&&console.error("出现错误,svg code为空");const{addNodeInfo:o}=await this.svgWorker.addSvgNodeBySvgCode(r,s,n),i=Ge.getInstance().create(wr.PREVIEW_ID,A.SVG,0,o.props,n.nodeManager.previewRoot,n.gmlRender.glCtx),a=$n.trimSvgCode(r);return i.setSvgCode(a.svgCode),await new Jc().work(i,a.svgCode,n.renderManager),i}makeupShapeDefaultProps(t,n,s){const r=Tt.Resource,o=hn[r],i=100,a=100,c=s?n.x-.5*i:n.x,h=s?n.y-.5*a:n.y;return[gt.create({x:c,y:h,width:i,height:a}),Ot.create({color:o,alpha:.5})]}}const Er=class Er{constructor(){g(this,"previewGraphics",null);g(this,"handlers",[new Cp,new Lp,new Qf])}addPreviewNode(e){const t=e.toolManager.currentTool;for(const n of this.handlers)if(n.enable(t)){n.handle(Er.PREVIEW_ID,e).then(s=>{this.previewGraphics=s});return}}updatePos(e){if(!this.previewGraphics)return;const t={type:R.Base,x:e.x,y:e.y};this.previewGraphics.updateProps([t])}resetPreviewNode(e){this.previewGraphics=null,e.nodeManager.previewRoot.children.clear()}};g(Er,"PREVIEW_ID","create_preview");let Xo=Er;class Zf{constructor(){g(this,"previewSvgCode","");g(this,"previewSvgResourceUrl","")}setPreviewSvgCode(e){this.previewSvgCode=e}setPreviewResourceUrl(e){this.previewSvgResourceUrl=e}}class Jf{constructor(){g(this,"createManager",new Xo);g(this,"quickCreateManager",new wr);g(this,"previewResourceManager",new Zf)}addPreviewNode(e){this.createManager.addPreviewNode(e)}updatePos(e){this.createManager.updatePos(e)}resetPreviewNode(e){this.createManager.resetPreviewNode(e)}}class tl{}class el extends tl{async downloadAsImageBitmap(e){const n=await(await fetch(e)).blob();return{imageBitmap:await createImageBitmap(n),blobUrl:e}}async uploadBlobImg(e,t){return Promise.resolve("")}async downloadSvgCode(e){return Promise.resolve("")}async uploadSvgFile(e,t){return Promise.resolve(void 0)}async deleteMultipleImages(e){return Promise.resolve(void 0)}async uploadSvgString(e,t){return Promise.resolve("")}async copyImage(e,t,n){throw new Error("该方法没有被实现")}}class nl{constructor(){g(this,"resourceMap",new Map);g(this,"nodeResourceMap",new Map);g(this,"svgMap",new Map);g(this,"instance",new el)}loadResourceInstance(e){this.instance=e}getBlobUrl(e){var t;return((t=this.resourceMap.get(e))==null?void 0:t.blobUrl)||""}getImgUrls(){return[...this.nodeResourceMap.values()].map(e=>e.blobUrl)}addNodeResourceInfo(e,t){this.nodeResourceMap.set(e,t)}async loadImgUrl(e){if(this.resourceMap.has(e))return this.resourceMap.get(e);const t=await this.instance.downloadAsImageBitmap(e);return this.resourceMap.set(e,t),t}async uploadFileBlob(e,t){return await this.instance.uploadBlobImg(e,t)}async loadSvgUrl(e){return await this.instance.downloadSvgCode(e)}async uploadSvgFile(e,t){return await this.instance.uploadSvgFile(e,t)}async uploadSvgString(e,t){const n=this.svgMap.get(t);if(n)return n;const s=await this.instance.uploadSvgString(e,t);return this.svgMap.set(t,s),s}async deleteMultipleImages(e){if(e.length!==0)return await this.instance.deleteMultipleImages(e)}async copyImage(e,t,n){return await this.instance.copyImage(e,t,n)}}var Bs=(l=>(l[l.Img=0]="Img",l[l.Svg=1]="Svg",l))(Bs||{});class tg{constructor(e,t,n){g(this,"tasks",new Map);g(this,"onRendering",!1);g(this,"resourceManager");g(this,"nodeManager");g(this,"renderManager");this.resourceManager=e,this.nodeManager=t,this.renderManager=n}batchAddRenderNode(e){e.forEach(t=>this.addRenderNode(t))}addRenderNode(e){if(e.type===A.IMG){const t=e;this.tasks.set(e.id,{type:Bs.Img,nodeId:e.id,url:t.imgSrc})}if(e.type===A.SVG){const t=e;t.svgCode!==""&&this.tasks.set(e.id,{type:Bs.Svg,nodeId:e.id,svgCode:t.svgCode})}this.render()}start(){}render(){this.tasks.size!==0&&(this.onRendering||(this.genAndRender().then(()=>{this.onRendering=!1,this.render(),this.renderManager.slotManager.addSlotState(te.ImgUrls,this.resourceManager.getImgUrls())}).catch(e=>{console.error("渲染出现问题:",e),this.onRendering=!1}),this.tasks.clear()))}async genAndRender(){const e=[];for(const t of[...this.tasks.values()])t.type===Bs.Svg&&e.push(this.genSvgTexture(t)),t.type===Bs.Img&&e.push(this.genImgTexture(t));return Promise.all(e)}async genImgTexture(e){const{nodeId:t,url:n}=e,s=this.nodeManager.getNode(t);if(!s||s.type!==A.IMG)return;const r=s;try{const o=await this.resourceManager.loadImgUrl(n);r.setImageBitmap(o.imageBitmap),this.resourceManager.addNodeResourceInfo(r.id,o)}catch(o){console.error("加载图片出现问题",o),r.setBroken()}this.renderManager.dirtyDraw(s.getBounds())}async genSvgTexture(e){const{svgCode:t,nodeId:n}=e,s=this.nodeManager.getNode(n);if(!s||s.type!==A.SVG)return;const r=s;await new Jc().work(r,t,this.renderManager)}}class eg{constructor(){g(this,"duringCrop",!1)}intoCrop(){this.duringCrop=!0}exitCrop(){this.duringCrop=!1}}class Yo{constructor(e){g(this,"inputManager");g(this,"cursorManager");g(this,"toolManager");g(this,"gmlRender");g(this,"auxGMLRender");g(this,"nodeManager");g(this,"serializeManager");g(this,"actionManager");g(this,"renderManager");g(this,"auxiliaryManager");g(this,"previewManager");g(this,"asyncRenderNodeManager");g(this,"docState");g(this,"idGenerator");g(this,"slotManager");g(this,"resourceManager");g(this,"cropManager");g(this,"appContext");g(this,"plugins",[]);g(this,"api");this.docState=new fc,this.idGenerator=new Qt,this.gmlRender=new So,this.auxGMLRender=new So,this.cursorManager=new qo,this.nodeManager=new wc,this.slotManager=new Pi,this.resourceManager=new nl,this.cropManager=new eg,this.auxiliaryManager=new vi(this.auxGMLRender,this.slotManager,this.cropManager),this.renderManager=new $i(this.gmlRender,this.nodeManager,this.auxiliaryManager,this.slotManager),this.inputManager=new gp(this.renderManager,this.cursorManager),this.previewManager=new Jf,this.toolManager=new Ba(this.nodeManager,this.inputManager,this.slotManager,this.cursorManager),this.asyncRenderNodeManager=new tg(this.resourceManager,this.nodeManager,this.renderManager),this.actionManager=new ji(this.nodeManager,this.inputManager,this.gmlRender,this.auxiliaryManager,this.toolManager,this.renderManager,this.resourceManager,this.docState,this.idGenerator,this.slotManager,this.asyncRenderNodeManager),this.serializeManager=new yp(this.nodeManager,this.docState),this.appContext=new cc(this.nodeManager,this.gmlRender,e.detectors,this.toolManager,this.inputManager,this.actionManager,this.renderManager,this.auxiliaryManager,this.docState,this.idGenerator,this.cursorManager,this.previewManager,this.resourceManager,this.slotManager,this.asyncRenderNodeManager,this.cropManager),this.api=new uc(this),this.auxiliaryManager.selectManager.register(this.inputManager),this.appContext.refreshEvent=()=>{const t=this.getPlugin(_s);t&&t.interactiveManager.refreshEvent(this.appContext)}}registerPlugin(e){this.plugins.push(e)}getPlugin(e){for(const t of this.plugins)if(t instanceof e)return t;return null}start(){this.slotManager.start(),this.auxiliaryManager.start(),this.renderManager.start(),this.asyncRenderNodeManager.start();for(const e of this.plugins)e.start()}stop(){for(const e of this.plugins)e.stop()}load(e){return this.loadDocumentInfo(e)}loadDocumentInfo(e){const t=mp();this.docState.load(t);try{const n=this.initData(e);this.afterInit(n),this.renderManager.zoomToFit(this.asyncRenderNodeManager),this.renderManager.addContentRenderTask()}catch(n){console.error("初始化过程中出现错误;",n)}return this.docState.seq}initData(e){this.nodeManager.clear(),this.gmlRender.reset();const t=this.gmlRender.canvas.getContext("2d");let n=[];for(const s of e.nodes){const r=this.nodeManager.root;this.initNode(s,r,t,n)}return n=T.sortGraphics(n),n}initNode(e,t,n,s){this.idGenerator.loadNode(e);const r=Ge.getInstance().createByNodeInfo(e,t,n);this.nodeManager.addNode(r),s.push(r);const o=e.children??[];for(const i of o)this.initNode(i,r,n,s);return r}async afterInit(e){for(const t of e){if(t instanceof dn){const{start:n,end:s}=t.connectProps;if(n){const r=this.nodeManager.getNode(n.objectId)||null;this.nodeManager.addLink(t,r,!0)}if(s){const r=this.nodeManager.getNode(s.objectId)||null;this.nodeManager.addLink(t,r,!1)}}if(t instanceof ys&&this.asyncRenderNodeManager.addRenderNode(t),t instanceof Ts){const n=t.svgUrl;try{const s=await this.resourceManager.loadSvgUrl(n),r=$n.trimSvgCode(s);t.setSvgCode(r.svgCode),this.asyncRenderNodeManager.addRenderNode(t)}catch(s){console.error("加载svg图片出现问题",s),t.setBroken()}}}}}class Os{moveForward(e){const t=e.getSelectNodes();if(t.size===0)return;e.execAction(new nt);const n=T.sortGraphics([...t]).reverse();for(const s of n){const r=this.moveNodeForward(s);r&&e.execAction(r)}e.execAction(new et)}moveBackward(e){const t=e.getSelectNodes();if(t.size===0)return;e.execAction(new nt);const n=T.sortGraphics([...t]);for(const s of n){const r=this.moveNodeBackward(s);r&&e.execAction(r)}e.execAction(new et)}moveToUp(e){const t=e.getSelectNodes();if(t.size===0)return;const n=new Map;for(const s of t){const r=s.parent,o=n.get(r);o?o.push(s):n.set(r,[s])}e.execAction(new nt);for(const[s,r]of n){const o=this.moveNodesToUp(r,s);o&&e.execAction(o)}e.execAction(new et)}moveToBack(e){const t=e.getSelectNodes();if(t.size===0)return;const n=new Map;for(const s of t){const r=s.parent,o=n.get(r);o?o.push(s):n.set(r,[s])}e.execAction(new nt);for(const[s,r]of n){const o=this.moveNodesToBack(r,s);o&&e.execAction(o)}e.execAction(new et)}moveNodesToUp(e,t){if(e.length===0)return null;const n=T.sortGraphics(e),s=new Set(e),r=t.children,o=[];for(const d of r)s.has(d)||o.push(d);const i=T.sortGraphics(o),a=i[i.length-1].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a+h,props:[]}),h++;return new ct({infos:c})}moveNodesToBack(e,t){if(e.length===0)return null;const n=T.sortGraphics(e).reverse(),s=new Set(e),r=t.children,o=[];for(const d of r)s.has(d)||o.push(d);const a=T.sortGraphics(o)[0].zIndex,c=[];let h=1;for(const d of n)c.push({id:d.id,zIndex:a-h,props:[]}),h++;return new ct({infos:c})}moveNodeForward(e){const t=e.parent;if(!t)return null;let n=[...t.children];n=T.sortGraphics(n);const s=n.indexOf(e);if(s<0&&console.error("排序时发生错误",s,e.id),s===n.length-1)return null;if(s===n.length-2){const a=n[s+1],c=[{id:e.id,zIndex:a.zIndex+1,props:[]}];return new ct({infos:c})}const r=n[s+1],o=n[s+2],i=[{id:e.id,zIndex:.5*(r.zIndex+o.zIndex),props:[]}];return new ct({infos:i})}moveNodeBackward(e){const t=e.parent;if(!t)return null;let n=[...t.children];n=T.sortGraphics(n);const s=n.indexOf(e);if(s<0&&console.error("排序时发生错误",s,e.id),s===0)return null;if(s===1){const a=n[s-1],c=[{id:e.id,zIndex:a.zIndex-1,props:[]}];return new ct({infos:c})}const r=n[s-1],o=n[s-2],i=[{id:e.id,zIndex:.5*(r.zIndex+o.zIndex),props:[]}];return new ct({infos:i})}}const ng={width:595,height:942};var Fo={exports:{}},Ds={};/**
26
+ </html>`}static decode(t){const e=t.indexOf(this.oolongLeft),n=t.indexOf(this.oolongRight);if(e<0||n<0||e===n)return null;const o=t.slice(e+this.oolongLeft.length,n),s=atob(o);return decodeURI(s)}static convertDocumentInfoToPasteData(t,e){const n={docId:t.documentId,resourceType:e},o=[],s=[],r=new Map,i=S.correctZIndex(t.nodes);for(const h of i){const d=this.convertToPasteDO(h,r);o.push(d),h.capInfo.baseProps&&s.push(h.capInfo.baseProps)}const a=S.getBoundsByBasePropsList(s),c=D.rectNode2Rect(a);return{meta:n,bounds:c,nodes:o,resources:[...r.values()]}}static convertToPasteDO(t,e){var r,i;const n={id:t.id,type:t.type,zIndex:t.zIndex,capInfo:t.capInfo,children:[]};(r=t.capInfo.imageProps)!=null&&r.url&&e.set(t.capInfo.imageProps.url,{type:zn.Image,fileKey:t.capInfo.imageProps.url}),(i=t.capInfo.svgProps)!=null&&i.url&&e.set(t.capInfo.svgProps.url,{type:zn.SVG,fileKey:t.capInfo.svgProps.url});const o=t.children||[],s=S.correctZIndex(o);for(const a of s){const c=this.convertToPasteDO(a,e);n.children.push(c)}return n}};p(Qn,"oolongLeft","start--oolong--"),p(Qn,"oolongRight","--oolong--end");let xn=Qn;class Lg{constructor(){p(this,"copyWorker",new Ks)}copy(t,e){if(!t.clipboardData)return!1;const n=this.copyWorker.work(e);if(!n)return!1;t.preventDefault();const o=JSON.stringify(n),s=xn.encode(o);return t.clipboardData.setData("text/html",s),!0}}class Cg{copy(t,e){if(!t.clipboardData)return!1;const n=e.inputManager.selectionManager.selectionInfo;if(!n)return!1;const o=e.inputManager.editTextInfo;if(!o)return!1;const{renderText:s}=o,{start:r,end:i}=n,a=this.extractPlainText(s,r,i);return a?(t.preventDefault(),t.clipboardData.setData("text/plain",a),!0):!1}extractPlainText(t,e,n){let o="";if(e.paragraphIndex===n.paragraphIndex){const s=t.paragraphs[e.paragraphIndex];o=this.extractTextFromParagraph(s,e,n)}else{const s=t.paragraphs[e.paragraphIndex],r=this.extractTextFromParagraph(s,e,s.tailCursorPosition());o+=r,r.endsWith(`
27
+ `)||(o+=`
28
+ `);for(let c=e.paragraphIndex+1;c<n.paragraphIndex;c++){const h=t.paragraphs[c];o+=h.toString()}const i=t.paragraphs[n.paragraphIndex],a=this.extractTextFromParagraph(i,new Fe(n.paragraphIndex,0,-1),n);o+=a}return o}extractTextFromParagraph(t,e,n){let o="";if(e.lineIndex===n.lineIndex){const s=t.lines[e.lineIndex];o=this.extractTextFromLine(s,e.charIndex,n.charIndex)}else{const s=t.lines[e.lineIndex],r=s.getCharLength();o+=this.extractTextFromLine(s,e.charIndex,r-1);for(let a=e.lineIndex+1;a<n.lineIndex;a++){const c=t.lines[a];o+=c.toString()}const i=t.lines[n.lineIndex];o+=this.extractTextFromLine(i,-1,n.charIndex)}return o}extractTextFromLine(t,e,n){let o="",s=0;const r=e+1,i=n;for(const a of t.textBlocks){const c=a.characters.length;if(s+c-1<r){s+=c;continue}if(s>i)break;const d=Math.max(0,r-s),u=Math.min(c-1,i-s);for(let f=d;f<=u&&f<a.characters.length;f++)o+=a.characters[f].charText;s+=c}return o}}class Ag extends go{handle(t,e,n,o){const s=t.find(a=>a.type===I.Image);if(!s)return;const r=s.url,i=o.get(r);i?s.url=i:(console.error("复制图片时该图片资源失效!",i),s.url="")}}class Ng extends go{handle(t,e,n,o){const s=t.find(a=>a.type===I.Svg);if(!s||s.useCode)return;const r=s.url,i=o.get(r);i?s.url=i:(console.error("复制svg时该svg资源失效!",i),s.url="")}}class kg extends ma{constructor(){super(...arguments);p(this,"propsHandler",[new ga,new ya,new xa,new Ag,new Ng])}}class xr{}var Kt=(l=>(l[l.Normal=0]="Normal",l[l.EmptyPlace=1]="EmptyPlace",l))(Kt||{});class Wc extends xr{constructor(){super(...arguments);p(this,"posPasteType",Kt.Normal)}handlePos(e,n){return n.lastInteractiveEvent.globalPoint}}class Fc extends xr{constructor(){super(...arguments);p(this,"posPasteType",Kt.EmptyPlace)}handlePos(e,n){const o=e.bounds,s=20,r=n.renderManager.gmlRender.getViewPortBounds(),i=n.nodeManager.searchNodesByRectNode(r);if(i.length===0){const y=.5*(r.minX+r.maxX)-.5*o.width,m=.5*(r.minY+r.maxY)-.5*o.height;return new P(y,m)}const a=i.map(y=>y.globalPos),c=Math.min(...a.map(y=>y.x)),h=Math.min(...a.map(y=>y.y));let d=c;const u=h,f=o.width+2*s,g=o.height+2*s;for(let y=0;y<10;y++){if(n.nodeManager.searchNodes(d,u,d+f,u+g).length===0)return{x:d+s,y:u+s};d+=f}return new P(c,h)}}class cs{constructor(){p(this,"pasteWorker",new ba);p(this,"crossPagePasteWorker",new kg);p(this,"pastePosHandlerMap",new Map([[Kt.Normal,new Wc],[Kt.EmptyPlace,new Fc]]))}handle(t,e,n=Kt.Normal){const o=e.docState.docId;return t.meta.docId!==o?this.handleCrossPaste(t,e,n):this.handlePaste(t,e,n)}handlePaste(t,e,n){return!t.nodes||t.nodes.length===0?!1:(this.normalPaste(t,e,this.pasteWorker,n),!0)}handleCrossPaste(t,e,n){return!t.nodes||t.nodes.length===0?!1:(this.asyncHandleCrossPaste(t,e,n),!0)}async asyncHandleCrossPaste(t,e,n){if(!t.nodes||t.nodes.length===0)return!1;const o=await this.pasteResourceInfo(t.resources,e,t.meta.resourceType);return o||console.error("复制图片资源时出现错误!"),this.normalPaste(t,e,this.crossPagePasteWorker,n,o==null?void 0:o.resourceMap),!0}normalPaste(t,e,n,o,s){const r=t.nodes,i=t.bounds,a=this.computePastePos(o,t,e),c=new P(a.x-i.x,a.y-i.y);e.execAction(new W);const{addNodeData:h,nextFocusIds:d}=n.work(e,r,c,s);e.execAction(new Le(h)),e.execAction(xe.create(d)),e.execAction(new z)}computePastePos(t,e,n){const o=this.pastePosHandlerMap.get(t);return o?o.handlePos(e,n):this.pastePosHandlerMap.get(Kt.Normal).handlePos(e,n)}async pasteResourceInfo(t,e,n){return t.length===0?{failedList:[],resourceMap:new Map}:await e.resourceManager.copyImage(t,e.docState.docId,n)}}class Bg{constructor(){p(this,"handlers",[new cs])}paste(t,e){const n=t.clipboardData,o=n==null?void 0:n.getData("text/html");if(!o)return!1;const s=xn.decode(o);if(s===null)return!1;const r=JSON.parse(s);for(const i of this.handlers)if(i.handle(r,e,Kt.Normal))return!0;return!1}}class Rg{paste(t,e){const n=t.clipboardData,o=n==null?void 0:n.getData("text/plain");if(!o)return!1;const s=this.getSvgCode(o);if(s===null)return!1;const r=e.docState.docId,i=Zo(10),a=`${r}/${i}`,c=yn.trimSvgCode(s);return e.resourceManager.uploadSvgString(a,c.svgCode).then(h=>{this.addSvgNode(e,c,h)}),!0}addSvgNode(t,e,n){var c;const o=((c=t.lastInteractiveEvent)==null?void 0:c.globalPoint)||new P,s=[{type:I.Base,x:o.x,y:o.y,width:e.width,height:e.height},{type:I.Svg,url:n},{type:I.Border,dashType:et.None}],r=t.idGenerator.genId(v.SVG),i={id:r,type:v.SVG,zIndex:ve.genZIndex(t.nodeManager.root),parentId:"",props:s};t.execAction(new W);const a=Le.create(i);t.execAction(a),t.execAction(xe.create([r])),t.execAction(new z)}getSvgCode(t){const e=t.indexOf("<svg"),n=t.indexOf("svg>");return e<0||n<0||e===n?null:t.slice(e,n+4)}}class Eg{constructor(){p(this,"worker",new zc)}paste(t,e){if(!t.clipboardData)return!1;const n=t.clipboardData.items;for(let o=0;o<n.length;o++){const s=n[o];if(s.type.startsWith("image/")){const r=s.getAsFile();return r?(this.pasteImg(r,e),!0):!1}}return!1}async pasteImg(t,e){const n=Zo(10),o=`${e.docState.docId}/${n}`,s=await e.resourceManager.uploadFileBlob(o,t),{width:r,height:i}=await Pc.getImageSize(t),a=e.lastInteractiveEvent.globalPoint;this.worker.addImageNode(s,r,i,a,e)}}class Yc{constructor(t){p(this,"eventCtx");p(this,"pasteHandlers");p(this,"copyHandlers");this.eventCtx=t,this.pasteHandlers=[new Eg,new Bg,new Rg],this.copyHandlers=[new Cg,new Lg]}paste(t){for(const e of this.pasteHandlers)if(e.paste(t,this.eventCtx))return}copy(t){for(const e of this.copyHandlers)if(e.copy(t,this.eventCtx))return}cut(t){console.log(t)}}class Gc{constructor(t){p(this,"eventCtx");p(this,"copyPasteManager");p(this,"onCopy",t=>{this.onEnable()&&this.copyPasteManager.copy(t)});p(this,"onPaste",t=>{this.onEnable()&&this.eventCtx.docState.canEdit()&&this.copyPasteManager.paste(t)});p(this,"onCut",t=>{this.onEnable()&&this.eventCtx.docState.canEdit()&&this.copyPasteManager.cut(t)});this.eventCtx=t,this.copyPasteManager=new Yc(t)}start(){document.addEventListener("copy",this.onCopy),document.addEventListener("paste",this.onPaste),document.addEventListener("cut",this.onCut)}stop(){document.removeEventListener("copy",this.onCopy),document.removeEventListener("paste",this.onPaste),document.removeEventListener("cut",this.onCut)}onEnable(){return this.eventCtx.docState.canEdit()}}const Hg=new Set([v.Shape]);class Dg{constructor(t){p(this,"app");this.app=t}addTemplateNodes(t){const e=xn.convertDocumentInfoToPasteData(t,fo.Template),n=new cs,o=this.app.appContext;n.asyncHandleCrossPaste(e,o,Kt.EmptyPlace).then(s=>{if(s)o.renderManager.zoomToSelect();else throw console.error("应用模版时出现错误"),new Error("应用模版时出现错误")})}addNode(t,e){const n=this.app.appContext,o=S.getViewportBoundCenter(n),s=100,r=100,i=new P(o.x-s/2,o.y-r/2),a=n.createWorker.makeupDefaultProps(t,n,e,i),c=n.idGenerator.genId(t);n.execAction(new W),n.execAction(Le.create({id:c,props:a,parentId:"",type:t,zIndex:ve.genZIndex(n.nodeManager.root)})),n.execAction(xe.create([c])),Hg.has(t)&&n.execAction(ee.focus(c)),n.execAction(new z)}addSvgNodeBySvgCode(t){const e=this.app.docState.docId,n=Zo(10),o=`${e}/${n}`;this.app.resourceManager.uploadSvgString(o,t).then(s=>{this.addSvgNode(t,s)})}addSvgNode(t,e){const n=this.app.appContext,o=n.renderManager.gmlRender.getViewPortBounds(),s=new P(.5*(o.minX+o.maxX),.5*(o.minY+o.maxY)),i=new cr().computeAddSvgNode(t,e,s,this.app.appContext),a=i.id;n.execAction(new W);const c=Le.create(i);n.execAction(c),n.execAction(xe.create([a])),n.execAction(new z)}addImageNode(t,e,n){const o=new zc,s=this.app.appContext,r=s.renderManager.gmlRender.getViewPortBounds(),i=new P(.5*(r.minX+r.maxX),.5*(r.minY+r.maxY));o.addImageNode(t,e,n,i,s)}quickCreateNode(t,e){const n=this.app.nodeManager.getNode(e);if(!n||n.type!==v.Line)return;const o=n,{start:s}=o.connectProps;if(!s)return;const r=this.app.nodeManager.getNode(s.objectId);if(!r)return;const i=r.baseProps,c=o.lineProps.points,h=c[c.length-1],d=c[c.length-2],u=vt.drawerMap.get(t).getConnectAnchor(),f=S.judgeHorizon(d,h);let g;f?h.x>d.x?g=u[de.Left]:g=u[de.Right]:h.y>d.y?g=u[de.Top]:g=u[de.Bottom];const y=i.width*g.x,m=i.height*g.y,b=h.x-y,w=h.y-m,L=this.app.appContext,B=Is[t],H=So[B],E=an[B],X=[{type:I.Base,x:b,y:w,width:i.width,height:i.height},tt.create({color:H}),Ae.create({color:E}),new Oe(t)],$=L.idGenerator.genId(v.Shape),Z={id:$,type:v.Shape,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:X};L.execAction(new W);const se=Le.create(Z);L.execAction(se);const ne=o.connectProps.clone();ne.end={objectId:$,x:g.x,y:g.y},L.execAction(U.create(e,[ne])),L.execAction(xe.create([$])),L.execAction(ee.focus($)),L.execAction(new z)}makeupToSlidesBySelective(){this.makeupToSlides([...this.app.appContext.getSelectNodes()])}makeupToSlides(t){const e=t.filter($=>!(!($ instanceof rs)||$.parent&&$.parent.type===v.SlideContainer)),n=this.app.appContext;n.execAction(new W),n.execAction(xe.create([]));const o=nt,s=xt,r=this.sortSectionsByPosition(e),i=e.length,a=Math.ceil(Math.sqrt(i)),c=[];for(let $=0;$<r.length;$+=a){const Z=r.slice($,$+a);c.push({ids:Z})}const h=n.idGenerator.genId(v.SlideContainer),d=[ie.create({x:0,y:0,width:100,height:100}),St.create({children:c})],u={id:h,type:v.SlideContainer,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:d};n.execAction(Le.create(u));const f=[];let g=0,y=0,m=1/0,b=1/0,w=-1/0,L=-1/0;c.flatMap($=>$.ids).forEach(($,Z)=>{const se=e.find(Re=>Re.id===$);if(!se)return;Z===0&&(g=se.baseProps.x-o,y=se.baseProps.y-s);const ne=Math.floor(Z/a),ae=Z%a,te=se.baseProps,ce=ae*(te.width+o)+o,pe=ne*(te.height+s)+s;m=Math.min(m,ce),b=Math.min(b,pe),w=Math.max(w,ce+te.width),L=Math.max(L,pe+te.height);const Be=ie.create({x:ce,y:pe,width:te.width,height:te.height,angle:te.angle});f.push({id:$,parentId:h,props:[Be]})}),f.length>0&&n.execAction(new U({infos:f}));const H=w-m+2*o,E=L-b+2*s,X=ie.create({x:g,y,width:H,height:E});n.execAction(U.create(h,[X])),n.execAction(xe.create([h])),n.execAction(new z)}sortSectionsByPosition(t){if(t.length===0)return[];const e=t.map(s=>({id:s.id,x:s.baseProps.x,y:s.baseProps.y,yMin:s.baseProps.y,yMax:s.baseProps.y+s.baseProps.height}));e.sort((s,r)=>s.y!==r.y?s.y-r.y:s.x-r.x);const n=[],o=[...e];for(;o.length>0;){const s=o.shift(),r=[s];let i=0;for(;i<o.length;){const a=o[i];a.y>=s.yMin&&a.y<=s.yMax?(r.push(a),o.splice(i,1)):i++}r.sort((a,c)=>a.x-c.x),n.push(...r.map(a=>a.id))}return n}}class ls{constructor(){p(this,"groupBaseWorker",new on)}group(t,e){const n=S.filterToGroupNodes(t);if(n.length<2)return;e.execAction(new W);const o=e.idGenerator.genId(v.Group),s=[],r=S.sortGraphics(n),i=r[r.length-1].parent;for(const b of r)s.push(b.getBounds());const a=S.getBounds(s),c=D.rectNode2Rect(a),h=new P(c.x,c.y),d=i.toLocal(h),u={id:o,parentId:i.id,type:v.Group,zIndex:ve.genZIndex(i),props:[ie.create({x:d.x,y:d.y,width:c.width,height:c.height})]};e.execAction(new Le({nodes:[u]}));const f=e.nodeManager.getNode(o),g=[];let y=1;const m=$t.flattenNodes(r);this.groupBaseWorker.start(m);for(const b of r){if(b.type===v.Group){const w=$t.flattenNodes([b]);for(const L of w)g.push(S.computeRelationChangeUpdateNodeInfo(L,f))}g.push(S.computeRelationChangeUpdateNodeInfo(b,f,y,o)),y++}e.execAction(new U({infos:g})),this.groupBaseWorker.work(e,!1),e.execAction(xe.create([f.id])),e.execAction(new z)}unGroup(t,e){e.execAction(new W);const n=t.parent,o=[...t.children];o.sort((c,h)=>c.zIndex-h.zIndex);const s=[];let r=1;const i=Math.max(...[...n.children].map(c=>c.zIndex)),a=[];for(const c of o){if(c.type===v.Group){const h=$t.flattenNodes([c]);for(const d of h)s.push(S.computeRelationChangeUpdateNodeInfo(d,t))}s.push(S.computeRelationChangeUpdateNodeInfo(c,t,i+r,n.id)),r++,a.push(c.id)}e.execAction(new U({infos:s})),e.execAction(At.create([t.id])),e.execAction(xe.create(a)),e.execAction(new z)}}class Og{constructor(t){p(this,"app");this.app=t}rotateImageAngle(t,e){const n=this.getNodeIdByBlobUrl(t);n&&this.rotateImage(n,e)}rotateImage(t,e){const n=this.app.appContext,o=n.nodeManager.getNode(t);if(!o)return;const{angle:s}=o.baseProps,r=o.globalPos,i=D.rectNode2Rect(o.getBounds()),a=new P(i.x+.5*i.width,i.y+.5*i.height),c=re.generateMatrix().translate(a.x,a.y),h=re.generateMatrix().rotate(e),u=c.crossProduct(h).crossProduct(c.inverseMatrix()).crossPoint(r);let f;o.parent.type===v.Group?f=o.parent.globalTransform().inverseMatrix().crossPoint(u):f=o.parent.toLocal(u),n.execAction(new W),n.execAction(U.create(t,[{type:I.Base,x:f.x,y:f.y,angle:s+e}])),n.execAction(new z)}getNodeIdByBlobUrl(t){const e=this.app.appContext;for(const[n,o]of e.resourceManager.nodeResourceMap)if(o.blobUrl===t)return n;return""}}class Xg{constructor(t){p(this,"app");this.app=t}async copySelectNodes(){const e=new Ks().work(this.app.appContext);if(!e)return!1;const n=JSON.stringify(e),o=xn.encode(n),s=new Blob([o],{type:"text/html"}),r=new ClipboardItem({"text/html":s});await navigator.clipboard.write([r])}copySelectNodesAsPng(t=2,e=""){const o=this.app.appContext.auxiliaryManager.selectManager.getSelectBounds(),s=this.app.renderManager.exportOfflineCanvas(o,t,e);return new Promise(r=>{s.toBlob(async i=>{if(!i){console.error("转化为图片时候出现错误.");return}const a=new ClipboardItem({[i.type]:i});await navigator.clipboard.write([a]),r()})})}async pasteNodes(){try{const t=this.app.appContext,e=await navigator.clipboard.read();for(const n of e)if(n.types.includes("text/html")){const s=await(await n.getType("text/html")).text();if(!s)return;const r=xn.decode(s);if(r===null)return;const i=JSON.parse(r);new cs().handle(i,t);return}console.log("剪贴板中没有可用的文本数据")}catch(t){console.error("读取剪贴板失败:",t),alert("粘贴失败,请检查权限或使用 Ctrl+V")}}}class Mo{work(t){const e=[...t.getSelectNodes()];e.length!==0&&this.deleteByIds(t,e.map(n=>n.id))}deleteByIds(t,e){var r;if(e.length===0)return;const n=[];e.forEach(i=>{const a=t.nodeManager.getNode(i);a&&n.push(a)});const o=new Set,s=new Set;for(const i of n)o.add(i.id),t.nodeManager.getNodeLinks(i).forEach(c=>o.add(c.id)),this.addAllChildren(i,o),((r=i.parent)==null?void 0:r.type)===v.SlideContainer&&s.add(i.parent);t.actionManager.execAction(new W),t.actionManager.execAction(xe.create([])),t.actionManager.execAction(At.create([...o])),s.size>0&&t.slideManager.updateSlideContainers(s,o,t),t.actionManager.execAction(new z)}addAllChildren(t,e){e.add(t.id);for(const n of t.children)this.addAllChildren(n,e)}}class zg{constructor(t){p(this,"app");this.app=t}intoCrop(){new xo().intoCrop(this.app.appContext)}exitCrop(){new xo().exitCrop(this.app.appContext)}resetCrop(){new xo().resetCrop(this.app.appContext)}}class Wg{constructor(t){p(this,"app");p(this,"lineTextWorker",new _n);this.app=t}switchShape(t){const e=this.app.appContext,n=[...e.getSelectNodes()];if(new Set(n.map(s=>s.type)).size===1&&n[0].type===v.Shape&&n[0].validShapeCode(t)){const r=[];for(const i of n)t!==i.shapeType&&r.push({id:i.id,props:[{type:I.Shape,shapeCode:t}]});r.length>0&&(e.execAction(new W),e.execAction(new U({infos:r})),e.execAction(new z))}}switchLineShape(t){const e=this.app.appContext,n=[...e.getSelectNodes()];if(new Set(n.map(s=>s.type)).size===1&&n[0].type===v.Line){const s=[];for(const r of n){const i=r;if(this.lineTextWorker.init(i),t===i.shapeType)continue;const a=[{type:I.Shape,shapeCode:t}],c=i.points;if(t===he.Line)a.push({type:I.Line,points:[c[0],c[c.length-1]]});else if(t===he.Curve){const h=new uo;this.modifyLinePoints(i,e,h,a)}else if(t===he.PolyLine||t===he.RoundPolyLine){const h=new Vt;this.modifyLinePoints(i,e,h,a)}else continue;s.push({id:i.id,props:a})}s.length>0&&(e.execAction(new W),s.forEach(r=>{e.execAction(new U({infos:[r]})),this.lineTextWorker.work(this.app.nodeManager.getNode(r.id),e,!1)}),e.execAction(new z))}}modifyLinePoints(t,e,n,o){const{start:s,end:r}=t.connectProps,i=Ze.computeConnectInfo(t,s,e,!1),a=Ze.computeConnectInfo(t,r,e,!0),c=n.layoutToPointsPro(i,a);o.push({type:I.Line,points:c});const h=D.rectNode2Rect(S.getBoundsByPoints(c)),d=ie.create({x:h.x,y:h.y,width:h.width,height:h.height});o.push(d)}}class Fg{constructor(t){p(this,"app");this.app=t}}class Yg{constructor(t){p(this,"app");p(this,"groupBaseWorker",new on);this.app=t}alignLeft(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(s=>s.globalBaseProps.x)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:n,y:r.y}),a=s.baseProps,c=i.x-a.x;this.dealNodePos(s,o,c,0)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignRight(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.max(...e.map(s=>{const r=s.globalBaseProps;return r.x+r.width})),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:n-s.baseProps.width,y:r.y}),a=s.baseProps,c=i.x-a.x;this.dealNodePos(s,o,c,0)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignHorizontalCenter(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(i=>i.globalPos.x)),o=Math.max(...e.map(i=>i.globalBaseProps.x+i.baseProps.width)),s=(n+o)/2,r=[];for(const i of e){const a=i.globalPos,c=i.parent.toLocal({x:s-i.baseProps.width/2,y:a.y}),h=i.baseProps,d=c.x-h.x;this.dealNodePos(i,r,d,0)}t.execAction(new W),t.execAction(new U({infos:r})),t.execAction(new z)}dealNodePos(t,e,n,o){const s=t.baseProps,r=s.x+n,i=s.y+o;if(t instanceof Ct){const a=t.points,c=[];for(const h of a)c.push({x:h.x+n,y:h.y+o});e.push({id:t.id,props:[{type:I.Base,x:r,y:i},{type:I.Line,points:c}]})}else e.push({id:t.id,props:[{type:I.Base,x:r,y:i}]});if(t.type===v.Group){const a={x:n,y:o};this.computeGroupChildrenAction(t,a,e)}}alignTop(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(s=>s.globalBaseProps.y)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:r.x,y:n}),a=s.baseProps,c=i.y-a.y;this.dealNodePos(s,o,0,c)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignBottom(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.max(...e.map(s=>s.globalBaseProps.y+s.baseProps.height)),o=[];for(const s of e){const r=s.globalPos,i=s.parent.toLocal({x:r.x,y:n-s.baseProps.height}),a=s.baseProps,c=i.y-a.y;this.dealNodePos(s,o,0,c)}t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z)}alignVerticalCenter(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<2)return;const n=Math.min(...e.map(i=>i.globalPos.y)),o=Math.max(...e.map(i=>i.globalPos.y+i.baseProps.height)),s=(n+o)/2,r=[];for(const i of e){const a=i.globalPos,c=i.parent.toLocal({x:a.x,y:s-i.baseProps.height/2}),h=i.baseProps,d=c.y-h.y;this.dealNodePos(i,r,0,d)}t.execAction(new W),t.execAction(new U({infos:r})),t.execAction(new z)}distributeHorizontal(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<3)return;const n=[...e].sort((f,g)=>f.globalPos.x-g.globalPos.x),o=n[0],s=n[n.length-1],r=o.globalPos.x,i=s.globalPos.x+s.baseProps.width,a=n.reduce((f,g)=>f+g.baseProps.width,0),h=(i-r-a)/(e.length-1),d=[];let u=r;for(let f=0;f<n.length;f++){const g=n[f],y=g.globalPos,m=g.parent.toLocal({x:u,y:y.y}),b=g.baseProps,w=m.x-b.x;this.dealNodePos(g,d,w,0),u+=g.baseProps.width+h}t.execAction(new W),t.execAction(new U({infos:d})),t.execAction(new z)}distributeVertical(){const t=this.app.appContext,e=this.getAlignNodes();if(e.length<3)return;const n=[...e].sort((f,g)=>f.globalPos.y-g.globalPos.y),o=n[0],s=n[n.length-1],r=o.globalPos.y,i=s.globalPos.y+s.baseProps.height,a=n.reduce((f,g)=>f+g.baseProps.height,0),h=(i-r-a)/(e.length-1),d=[];let u=r;for(let f=0;f<n.length;f++){const g=n[f],y=g.globalPos,m=g.parent.toLocal({x:y.x,y:u}),b=g.baseProps,w=m.y-b.y;this.dealNodePos(g,d,0,w),u+=g.baseProps.height+h}t.execAction(new W),t.execAction(new U({infos:d})),t.execAction(new z)}getAlignNodes(){return[...this.app.appContext.getSelectNodes()].filter(o=>{if(o.type!==v.Line)return!0;const s=o,{start:r,end:i}=s.connectProps;return!r&&!i})}getLayoutNodes(t){return t instanceof mo?$t.flattenNodes([t]):[t]}computeGroupChildrenAction(t,e,n){if(t.type===v.Group)for(const o of t.children){if(o.type===v.Line){const s=o.points,r=[];for(const c of s)r.push({x:c.x+e.x,y:c.y+e.y});const{x:i,y:a}=o.baseProps;n.push({id:o.id,props:[{type:I.Base,x:i+e.x,y:a+e.y},{type:I.Line,points:r}]})}else{const{x:s,y:r}=o.baseProps;n.push({id:o.id,props:[{type:I.Base,x:s+e.x,y:r+e.y}]})}this.computeGroupChildrenAction(o,e,n)}}}class Gg{batchNodesToUnOrderByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toUnOrderByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toUnOrderBySelection(t,e,n){const{start:o,end:s}=e,r=t.getProp(I.TextParagraph).clone(),i=o.paragraphIndex,a=s.paragraphIndex;for(let d=i;d<=a;d++)this.toUnOrderWithPara(d,r);const h=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:r.paragraphStyles}]}];h.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:h})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toUnOrderByEditing(t,e,n){const{textCursorPosition:o}=e,s=t.getProp(I.TextParagraph).clone(),r=o.paragraphIndex;this.toUnOrderWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:s.paragraphStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toUnOrderWithPara(t,e){const n=e.paragraphStyles.findIndex(s=>s.paraIndex===t),o=S.getParaStyle(e,t-1);if(n<0)e.paragraphStyles.push({paraIndex:t,level:o?o.level:0,orderIndex:-1});else{const s=e.paragraphStyles[n];s.orderIndex!==-1?s.orderIndex=-1:e.paragraphStyles.splice(n,1)}}toUnOrderByNotEditing(t){const e=t.getProp(I.TextParagraph).clone(),n=t.renderText,o=e.paragraphStyles,s=S.computeNotUnOrderParas(n);if(s.size===0)return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]};for(const r of s){const i=S.getParaStyle(e,r);if(i)i.orderIndex=-1;else{const a={level:0,orderIndex:-1,paraIndex:r};o.push(a)}}return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:o}]}}}class Ug{batchNodesToOrderByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toOrderByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toOrderBySelection(t,e,n){const{start:o,end:s}=e,r=t.getProp(I.TextParagraph).clone(),i=o.paragraphIndex,a=s.paragraphIndex;for(let d=i;d<=a;d++)this.toOrderWithPara(d,r);const h=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:r.paragraphStyles}]}];h.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:h})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toOrderByEditing(t,e,n){const{textCursorPosition:o}=e,s=t.getProp(I.TextParagraph).clone(),r=o.paragraphIndex;this.toOrderWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:s.paragraphStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toOrderWithPara(t,e){const n=e.paragraphStyles.findIndex(s=>s.paraIndex===t),o=S.getParaStyle(e,t-1);if(n<0){const s=o&&o.orderIndex>0?o.orderIndex+1:1,r=o?o.level:0;e.paragraphStyles.push({paraIndex:t,level:r,orderIndex:s})}else{const s=e.paragraphStyles[n];if(s.orderIndex>0)e.paragraphStyles.splice(n,1);else{const r=o&&o.orderIndex>0?o.orderIndex+1:1;s.orderIndex=r}}}toOrderByNotEditing(t){const e=t.getProp(I.TextParagraph).clone(),n=t.renderText,o=e.paragraphStyles,s=S.computeNotOrderParas(n);if(s.size===0)return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]};const r=[...s].sort((i,a)=>i-a);for(const i of r){const a=o.findIndex(h=>h.paraIndex===i),c=o.findIndex(h=>h.paraIndex===i-1);if(a>-1){const h=o[a];if(c>-1){const d=o[c];h.orderIndex=d.orderIndex+1,h.level=d.level}else h.orderIndex=1,h.level=0}else if(c>-1){const h=o[c],d={level:h.level,orderIndex:h.orderIndex+1,paraIndex:i};o.push(d)}else{const h={level:0,orderIndex:1,paraIndex:i};o.push(h)}}return{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:o}]}}}class _g{batchNodesToQuoteByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n)o.push(this.toQuoteByNotEditing(s));o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toQuoteBySelection(t,e,n){var u;const{start:o,end:s}=e,r=((u=t.getProp(I.TextParagraphQuote))==null?void 0:u.clone())||new Dt,i=o.paragraphIndex,a=s.paragraphIndex;let c=!1;for(let f=i;f<=a;f++)if(r.paraQuoteStyles.findIndex(y=>y.paraIndex===f)<0){c=!0;break}if(c)for(let f=i;f<=a;f++)r.paraQuoteStyles.findIndex(y=>y.paraIndex===f)<0&&r.paraQuoteStyles.push({paraIndex:f,quote:!0});else for(let f=i;f<=a;f++){const g=r.paraQuoteStyles.findIndex(y=>y.paraIndex===f);g>=0&&r.paraQuoteStyles.splice(g,1)}const d=[{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:r.paraQuoteStyles}]}];d.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:d})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toQuoteByEditing(t,e,n){var c;const{textCursorPosition:o}=e,s=((c=t.getProp(I.TextParagraphQuote))==null?void 0:c.clone())||new Dt,r=o.paragraphIndex;this.toQuoteWithPara(r,s);const a=[{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:s.paraQuoteStyles}]}];a.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:a})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toQuoteWithPara(t,e){const n=e.paraQuoteStyles.findIndex(o=>o.paraIndex===t);if(n<0)e.paraQuoteStyles.push({paraIndex:t,quote:!0});else{const o=e.paraQuoteStyles[n];o.quote?e.paraQuoteStyles.splice(n,1):o.quote=!0}}toQuoteByNotEditing(t){const e=t.renderText;if(S.computeNotQuoteParas(e).size===0)return{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:[]}]};const o=[];for(let s=0;s<e.paragraphs.length;s++)o.push({paraIndex:s,quote:!0});return{id:t.id,props:[{type:I.TextParagraphQuote,paraQuoteStyles:o}]}}}class $g{batchNodesToNormalByNotEditing(t){const n=[...t.getSelectNodes()].filter(s=>s.type===v.Shape||s.type===v.Line),o=[];for(const s of n){const r=this.toNormalByNotEditing(s);r&&o.push(r)}o.length>0&&(t.execAction(new W),t.execAction(new U({infos:o})),t.execAction(new z))}toNormalBySelection(t,e,n){var d;const{start:o,end:s}=e,r=(d=t.getProp(I.TextParagraph))==null?void 0:d.clone(),i=o.paragraphIndex,a=s.paragraphIndex,c=[],h=[];if(r){for(let u=i;u<=a;u++){const f=r.paragraphStyles.findIndex(g=>g.paraIndex===u);f>=0&&r.paragraphStyles.splice(f,1)}h.push({type:I.TextParagraph,paragraphStyles:r.paragraphStyles})}if(h.length>0){const u={id:t.id,props:h};c.push(u)}c.length>0&&(n.execAction(new W),n.execAction(ee.selection(t.id,o,s)),n.execAction(new U({infos:c})),n.execAction(ee.selection(t.id,o,s)),n.execAction(new z))}toNormalByEditing(t,e,n){var c;const{textCursorPosition:o}=e,s=(c=t.getProp(I.TextParagraph))==null?void 0:c.clone(),r=o.paragraphIndex,i=[],a=[];if(s){const h=s.paragraphStyles.findIndex(d=>d.paraIndex===r);h>=0&&s.paragraphStyles.splice(h,1),a.push({type:I.TextParagraph,paragraphStyles:s.paragraphStyles})}if(a.length>0){const h={id:t.id,props:a};i.push(h)}i.length>0&&(n.execAction(new W),n.execAction(ee.focus(t.id,o)),n.execAction(new U({infos:i})),n.execAction(ee.focus(t.id,o)),n.execAction(new z))}toNormalByNotEditing(t){const e=t.renderText;return S.computeNotNormalParas(e).size===0?null:{id:t.id,props:[{type:I.TextParagraph,paragraphStyles:[]}]}}}class wr{work(t,e,n){const{node:o,renderText:s,textCursorPosition:r}=t,{updateTextProps:i}=this.computeUpdateTextProps(t,n);e.execAction(new W),e.execAction(U.create(o.id,[i]));const a=s.nextCursorPos(r,n.length);e.execAction(ee.focus(o.id,a)),e.execAction(new z)}computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.editText(n,o,e);return{updateTextProps:{type:I.Text,richText:s}}}editText(t,e,n){const{paragraphIndex:o,lineIndex:s,charIndex:r}=e,i=t.prevParagraphToXML(o),a=t.nextParagraphToXML(o),c=t.getParagraph(o),h=c.prevToRichTextXML(s,t.textProps),d=c.nextToRichTextXML(s,t.textProps),u=c.getLine(s),f=u.getBlockIndex(r);if(f){const{textBlock:g,blockIndex:y,charIndex:m}=f,b=u.prevToRichTextXML(y,t.textProps),w=u.nextToRichTextXML(y,t.textProps),L=g.insertTextToRichTextXML(n,m,t.textProps);return`<root>${i}<p>${h}${b}${L}${w}${d}</p>${a}</root>`}return`<root>${i}<p>${h}${n}${d}</p>${a}</root>`}getEditTextPrevNext(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=t.prevParagraphToXML(n),i=t.nextParagraphToXML(n),a=t.getParagraph(n),c=a.prevToRichTextXML(o,t.textProps),h=a.nextToRichTextXML(o,t.textProps),d=a.getLine(o),u=d.getBlockIndex(s);if(u){const{textBlock:y,blockIndex:m,charIndex:b}=u,w=d.prevToRichTextXML(m,t.textProps),L=d.nextToRichTextXML(m,t.textProps),B=y.getPrevText(b),H=y.getNextText(b),E=y.computeStyle(t.textProps),X=`<root>${r}<p>${c}${w}<style ${E}>${B}`,$=`${H}</style>${L}${h}</p>${i}</root>`;return{prev:X,next:$}}const f=`<root>${r}<p>${c}`,g=`${h}</p>${i}</root>`;return{prev:f,next:g}}applyStyleToSelection(t,e,n,o){const{start:s,end:r}=this.normalizeSelection(e,n);return s.paragraphIndex===r.paragraphIndex&&s.lineIndex===r.lineIndex?this.applyStyleSameLine(t,s,r,o):s.paragraphIndex===r.paragraphIndex?this.applyStyleSameParagraph(t,s,r,o):this.applyStyleDifferentParagraphs(t,s,r,o)}normalizeSelection(t,e){const n=this.getCursorPosition(t),o=this.getCursorPosition(e);return n<=o?{start:t,end:e}:{start:e,end:t}}getCursorPosition(t){return t.paragraphIndex*1e6+t.lineIndex*1e3+(t.charIndex+1)}generateStyleString(t){return Object.entries(t).map(([e,n])=>`${e}='${n}'`).join(" ")}mergeStyles(t,e){const n={};if(t.trim()){const s=/(\S+)=['"]([^'"]*)['"]/g;let r;for(;(r=s.exec(t))!==null;)n[r[1]]=r[2]}const o={...n,...e};return Object.entries(o).map(([s,r])=>`${s}='${r}'`).join(" ")}applyStyleSameLine(t,e,n,o){const{paragraphIndex:s,lineIndex:r}=e,i=e.charIndex+1,a=n.charIndex,c=t.prevParagraphToXML(s),h=t.nextParagraphToXML(s),d=t.getParagraph(s),u=d.prevToRichTextXML(r,t.textProps),f=d.nextToRichTextXML(r,t.textProps),g=d.getLine(r),y=this.buildSelectionXMLInLine(g,i,a,o,t.textProps);return`<root>${c}<p>${u}${y}${f}</p>${h}</root>`}buildSelectionXMLInLine(t,e,n,o,s){let r="",i=0;const a=e===-1?0:e,c=n===-1?0:n;for(let h=0;h<t.textBlocks.length;h++){const d=t.textBlocks[h],u=d.characters.length;if(i+u-1<a){r+=d.toRichTextXML(s),i+=u;continue}if(i>c){r+=d.toRichTextXML(s),i+=u;continue}const g=Math.max(0,a-i),y=Math.min(u-1,c-i);if(g>0){const L=d.getPrevText(g-1),B=d.computeStyle(s);r+=`<style ${B}>${L}</style>`}const m=this.getTextRange(d,g,y),b=d.computeStyle(s),w=this.mergeStyles(b,o);if(r+=`<style ${w}>${m}</style>`,y<u-1){const L=d.getNextText(y),B=d.computeStyle(s);r+=`<style ${B}>${L}</style>`}i+=u}return r}getTextRange(t,e,n){let o="";for(let s=e;s<=n;s++)o+=t.characters[s].charText;return o}applyStyleSameParagraph(t,e,n,o){const{paragraphIndex:s}=e,r=t.prevParagraphToXML(s),i=t.nextParagraphToXML(s),a=t.getParagraph(s);let c="";c+=a.prevToRichTextXML(e.lineIndex,t.textProps);const h=a.getLine(e.lineIndex);c+=this.buildSelectionXMLInLine(h,e.charIndex+1,h.getCharLength()-1,o,t.textProps);for(let u=e.lineIndex+1;u<n.lineIndex;u++){const f=a.getLine(u);c+=this.buildSelectionXMLInLine(f,-1,f.getCharLength()-1,o,t.textProps)}const d=a.getLine(n.lineIndex);return c+=this.buildSelectionXMLInLine(d,-1,n.charIndex,o,t.textProps),c+=a.nextToRichTextXML(n.lineIndex,t.textProps),`<root>${r}<p>${c}</p>${i}</root>`}applyStyleDifferentParagraphs(t,e,n,o){let s="<root>";s+=t.prevParagraphToXML(e.paragraphIndex);const r=t.getParagraph(e.paragraphIndex);let i="";i+=r.prevToRichTextXML(e.lineIndex,t.textProps);const a=r.getLine(e.lineIndex);i+=this.buildSelectionXMLInLine(a,e.charIndex+1,a.getCharLength()-1,o,t.textProps);for(let u=e.lineIndex+1;u<r.lines.length;u++){const f=r.getLine(u);i+=this.buildSelectionXMLInLine(f,-1,f.getCharLength()-1,o,t.textProps)}s+=`<p>${i}</p>`;for(let u=e.paragraphIndex+1;u<n.paragraphIndex;u++){const f=t.getParagraph(u);let g="";for(const y of f.lines)g+=this.buildSelectionXMLInLine(y,-1,y.getCharLength()-1,o,t.textProps);s+=`<p>${g}</p>`}const c=t.getParagraph(n.paragraphIndex);let h="";for(let u=0;u<n.lineIndex;u++){const f=c.getLine(u);h+=this.buildSelectionXMLInLine(f,-1,f.getCharLength()-1,o,t.textProps)}const d=c.getLine(n.lineIndex);return h+=this.buildSelectionXMLInLine(d,-1,n.charIndex,o,t.textProps),h+=c.nextToRichTextXML(n.lineIndex,t.textProps),s+=`<p>${h}</p>`,s+=t.nextParagraphToXML(n.paragraphIndex),s+="</root>",s}}class Hn{constructor(){p(this,"inputWorker",new wr)}changeFontProp(t,e){if(e.getSelectNodes().size===0)return;const o=e.inputManager.selectionManager.selectionInfo,s=e.inputManager.editTextInfo;if(s&&o){this.changeFontPropBySelection(t,s,o,e);return}this.changeFontPropForWhole(t,e)}changeFontPropForWhole(t,e){const o=[...e.getSelectNodes()].filter(r=>r.getProp(I.Text)!==null),s=[];for(const r of o)s.push({id:r.id,props:[this.textProp(t)]});s.length>0&&(e.execAction(new W),e.execAction(new U({infos:s})),e.execAction(new z))}changeFontPropBySelection(t,e,n,o){const{renderText:s,node:r}=e,{start:i,end:a}=n,c=this.inputWorker.applyStyleToSelection(s,i,a,this.richStyle(t));o.execAction(new W),o.execAction(ee.selection(r.id,i,a)),o.execAction(U.create(r.id,[{type:I.Text,richText:c}])),o.execAction(ee.selection(r.id,i,a)),o.execAction(new z)}}class jg extends Hn{richStyle(t){return{color:t}}textProp(t){return{type:I.Text,fontColor:t}}}class Vg extends Hn{richStyle(t){return{"bg-color":t}}textProp(t){return{type:I.Text,fontBgColor:t}}}class Kg extends Hn{richStyle(t){return{bold:t}}textProp(t){return{type:I.Text,bold:t}}}class Qg extends Hn{richStyle(t){return{italic:t}}textProp(t){let e=t;return typeof t=="string"&&(e=t.trim().toLowerCase()==="true"),{type:I.Text,italic:e}}}class Zg extends Hn{richStyle(t){return{underline:t}}textProp(t){return{type:I.Text,underline:t}}}class qg extends Hn{richStyle(t){return{strikethrough:t}}textProp(t){return{type:I.Text,strikethrough:t}}}class Uc{}class Jg extends Uc{enable(t){return t.type===v.CheckboxText}handle(t,e){return{id:t.id,props:[{type:I.Text,fontSize:e},{type:I.CheckSize,size:e}]}}}class ey extends Uc{enable(t){return!0}handle(t,e){return{id:t.id,props:[{type:I.Text,fontSize:e}]}}}v.Line,v.Shape,v.CheckboxText;class ty extends Hn{constructor(){super(...arguments);p(this,"editTextWorker",new wo);p(this,"fontSizeHandlers",[new Jg,new ey])}richStyle(e){return{"font-size":e}}textProp(e){return{type:I.Text,fontSize:e}}changeFontPropBySelection(e,n,o,s){const{renderText:r,node:i}=n,{start:a,end:c}=o,h=this.inputWorker.applyStyleToSelection(r,a,c,this.richStyle(e));s.execAction(new W),s.execAction(ee.selection(i.id,a,c)),s.execAction(U.create(i.id,[{type:I.Text,richText:h}])),r&&(r.textProps.sizeMode===We.autoWidth||r.textProps.sizeMode===We.autoHeight)&&this.editTextWorker.modifyBaseProps(i.renderText,i,s),s.execAction(ee.selection(i.id,a,c)),s.execAction(new z)}changeFontPropForWhole(e,n){const s=[...n.getSelectNodes()].filter(a=>a.getProp(I.Text)!==null),r=[],i=new Set;for(const a of s){const c=a.renderText;c&&(c.textProps.sizeMode===We.autoWidth||c.textProps.sizeMode===We.autoHeight)&&i.add(a);for(const h of this.fontSizeHandlers)if(h.enable(a)){r.push(h.handle(a,e));break}}if(r.length!==0){n.execAction(new W),n.execAction(new U({infos:r}));for(const a of i)this.editTextWorker.modifyBaseProps(a.renderText,a,n);n.execAction(new z)}}}class ny{constructor(t){p(this,"app");p(this,"textUnOrderWorker",new Gg);p(this,"textOrderWorker",new Ug);p(this,"textQuoteWorker",new _g);p(this,"textNormalWorker",new $g);p(this,"textFontColorWorker",new jg);p(this,"textFontBgColorWorker",new Vg);p(this,"textFontBoldWorker",new Kg);p(this,"textFontItalicWorker",new Qg);p(this,"textUnderLineWorker",new Zg);p(this,"textFontStrikethroughWorker",new qg);p(this,"textFontSizeWorker",new ty);this.app=t}addUnOrderList(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textUnOrderWorker.batchNodesToUnOrderByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textUnOrderWorker.toUnOrderByEditing(n,e,t);return}this.textUnOrderWorker.toUnOrderBySelection(n,o,t)}addOrderList(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textOrderWorker.batchNodesToOrderByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textOrderWorker.toOrderByEditing(n,e,t);return}this.textOrderWorker.toOrderBySelection(n,o,t)}addQuote(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textQuoteWorker.batchNodesToQuoteByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textQuoteWorker.toQuoteByEditing(n,e,t);return}this.textQuoteWorker.toQuoteBySelection(n,o,t)}toNormal(){const t=this.app.appContext,e=t.inputManager.editTextInfo;if(e===null)return this.textNormalWorker.batchNodesToNormalByNotEditing(t);const{node:n}=e,o=t.inputManager.selectionManager.selectionInfo;if(o===null){this.textNormalWorker.toNormalByEditing(n,e,t);return}this.textNormalWorker.toNormalBySelection(n,o,t)}changeTextColor(t){const e=this.app.appContext;this.textFontColorWorker.changeFontProp(t,e)}changeTextBgColor(t){const e=this.app.appContext;this.textFontBgColorWorker.changeFontProp(t,e)}changeTextBold(t){const e=this.app.appContext;this.textFontBoldWorker.changeFontProp(t,e)}changeTextItalic(t){const e=this.app.appContext;this.textFontItalicWorker.changeFontProp(t,e)}changeTextUnderLine(t){const e=this.app.appContext;this.textUnderLineWorker.changeFontProp(t,e)}changeTextStrikethrough(t){const e=this.app.appContext;this.textFontStrikethroughWorker.changeFontProp(t,e)}changeTextFontSize(t){const e=this.app.appContext;this.textFontSizeWorker.changeFontProp(t,e)}}class _c{getTotalCount(t){return t.reduce((e,n)=>e+n.ids.length,0)}playToNext(t){if(t.docMode!==ue.SLIDE_PLAY||!t.slideStatus.slideContainer)return null;const e=t.slideStatus.slideContainer.slideProps.children,n=t.slideStatus.currentIndex+1,o=this.getTotalCount(e);return n<o?(t.slideStatus.currentIndex=n,t.slideStatus.slideContainer.getChildIdByIndex(n)):null}playToPrev(t){if(t.docMode!==ue.SLIDE_PLAY||!t.slideStatus.slideContainer)return null;const e=t.slideStatus.currentIndex-1;return e>=0?(t.slideStatus.currentIndex=e,t.slideStatus.slideContainer.getChildIdByIndex(e)):null}}class oy{constructor(t){p(this,"app");p(this,"slidePlayWorker");p(this,"duplicateWorker",new Zs);this.app=t,this.slidePlayWorker=new _c}createEmptySlideContainer(){const t=this.app.appContext,e=S.getViewportBoundCenter(t),n=800,o=600,s=t.idGenerator.genId(v.SlideContainer),r=[ie.create({x:e.x-n/2,y:e.y-o/2,width:n,height:o}),St.create({children:[]})],i={id:s,type:v.SlideContainer,zIndex:ve.genZIndex(this.app.nodeManager.root),parentId:"",props:r};t.execAction(new W),t.execAction(Le.create(i)),t.execAction(xe.create([s])),t.execAction(new z)}refocusSlide(t=0){const e=this.app.appContext;e.slideManager.refocusSlide(e,t)}enterEditing(){const t=this.app.appContext;t.slideManager.enterEditing(t)}exitEditing(){const t=this.app.appContext;t.slideManager.exitEditing(t)}jumpToWhenEditing(t){const e=this.app.appContext;e.slideManager.jumpToWhenEditing(t,e)}enterPlayFromEdit(){const t=this.app.appContext;t.slideManager.enterPlayBySlideContainer(t,t.docState.slideStatus.slideContainer)}enterPlay(){const t=this.app.appContext;t.slideManager.enterPlay(t)}playToNext(){const t=this.app.appContext;t.slideManager.playToNext(t)}playToPrev(){const t=this.app.appContext;t.slideManager.playToPrev(t)}exitPlay(){const t=this.app.appContext;t.slideManager.exitPlay(t)}unGroupSlideContainerBySelective(){const t=this.app.appContext;t.slideManager.unGroupSlideContainerBySelective(t)}unGroupSlideContainer(t){const e=this.app.appContext;e.slideManager.unGroupSlideContainer(t,e)}async insertSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==ue.SLIDE_EDIT)return;const o=e.docState.slideStatus.slideContainer;o&&(e.execAction(new W),t===0?e.slideManager.insertSlide(o,0,!1,e):e.slideManager.insertSlide(o,t-1,!0,e),e.execAction(xe.create([])),e.slideManager.jumpToWhenEditing(t,e),e.execAction(new z))}deleteSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==ue.SLIDE_EDIT)return;const n=e.docState.slideStatus.slideContainer;if(!n)return;const o=n.getChildIdByIndex(t);if(!o)return;new Mo().deleteByIds(this.app.appContext,[o]);const r=n.getTotalCount();t===r-1?e.slideManager.jumpToWhenEditing(t-1,e):e.slideManager.jumpToWhenEditing(t+1,e)}duplicateSlideByEditingMode(t){const e=this.app.appContext;if(e.docState.docMode!==ue.SLIDE_EDIT)return;const n=e.docState.slideStatus.slideContainer;if(!n)return;const o=n.getChildIdByIndex(t);o&&(this.duplicateWorker.duplicateByIds([o],e),e.slideManager.jumpToWhenEditing(t+1,e))}}class $c{constructor(t){p(this,"app");p(this,"create");p(this,"image");p(this,"copyPaste");p(this,"crop");p(this,"switch");p(this,"propChangeAPI");p(this,"align");p(this,"text");p(this,"slide");this.app=t,this.create=new Dg(t),this.image=new Og(t),this.copyPaste=new Xg(t),this.crop=new zg(t),this.switch=new Wg(t),this.propChangeAPI=new Fg(t),this.align=new Yg(t),this.text=new ny(t),this.slide=new oy(t)}resizeCanvas(){this.app.appContext.resize()}focus(t,e=0,n=0){this.app.appContext.focus(t,e,n)}resetCursor(){this.app.cursorManager.resetCursor()}zoomScale(t,e){this.app.renderManager.zoomScale(t,e),this.app.appContext.refreshAllSvgNode()}zoomToFit(){this.app.renderManager.zoomToFit(),this.app.appContext.refreshAllSvgNode()}zoomToSelect(){this.app.renderManager.zoomToSelect(),this.app.appContext.refreshAllSvgNode()}zoomTo100(){this.app.renderManager.zoomTo100(),this.app.appContext.refreshAllSvgNode()}exportCoverCanvas(t,e=""){const n=this.app.nodeManager.getNodeBounds(),o=n.maxX-n.minX,s=n.maxY-n.minY,r=1280;let i=n;const a=1.5;if(o>r||s>r){const c=(n.minX+n.maxX)/2,h=(n.minY+n.maxY)/2,d=o>r?r:o,u=d/a;i={id:"cover-export-bounds",minX:c-d/2,minY:h-u/2,maxX:c+d/2,maxY:h+u/2}}return this.app.renderManager.exportOfflineCanvas(i,t,e)}exportOfflineCanvas(t,e,n=""){return this.app.renderManager.exportOfflineCanvas(t,e,n)}exportAllNodesImg(t,e=""){const n=this.app.nodeManager.getNodeBounds();return this.app.renderManager.exportOfflineCanvas(n,t,e)}scroll(t,e){this.app.renderManager.scroll(t,e)}registerCallback(t,e){this.app.slotManager.registerSlotCallback(t,e)}changePermission({canEdit:t}){this.app.docState.userPermission.canEdit=t}getBounds(){const t=this.app.renderManager.gmlRender.getViewPortBounds();return D.rectNode2Rect(t)}getScale(){return this.app.renderManager.getScale()}transformToClientPos(t){return this.app.gmlRender.transformToLocal(t)}getFocusList(){return this.app.auxiliaryManager.selectManager.getSelectNodes()}setPrefix(t){this.app.idGenerator.setPrefix(t)}clearFocus(){if(this.app.auxiliaryManager.selectManager.getSelectNodes().length===0)return;const t=this.app.appContext;if(t.execAction(new W),t.inputManager.editTextInfo){const{node:e}=t.inputManager.editTextInfo;t.execAction(ee.blur(e.id))}t.execAction(xe.create([])),t.execAction(new z)}makeGroup(){const t=[...this.app.appContext.getSelectNodes()];new ls().group(t,this.app.appContext)}makeUnGroup(){const t=[...this.app.appContext.getSelectNodes()];if(t.length!==1)return;const e=t[0];if(e.type!==v.Group)return;const n=e;new ls().unGroup(n,this.app.appContext)}getImageBlobUrl(t){return this.app.resourceManager.getBlobUrl(t)}deleteSelectNodes(){new Mo().work(this.app.appContext)}deleteByIds(t){new Mo().deleteByIds(this.app.appContext,t)}}class sy{constructor(t){p(this,"app");p(this,"textHelper",new Pi);this.app=t}getCtx(){return this.app.appContext}computeRichText(t){if(!t)return Ge.dealTextToRichText("");const e=t.trim();if(e.startsWith("<root>")||e.startsWith("<root "))return t;const n=this.textHelper.escapeXmlText(t);return Ge.dealTextToRichText(n)}addNode(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};const n=e.idGenerator.genId(v.Shape),o=e.nodeManager.root,s=Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize,fontColor:t.fontColor,bold:t.bold,italic:t.italic,underline:t.underline,strikethrough:t.strikethrough,verticalAlign:t.verticalAlign,horizonAlign:t.horizonAlign}),r=[ie.create({x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle??0}),tt.create({color:t.color??"#FFFFFF",alpha:t.alpha??1}),Ae.create({color:t.borderColor??"#000000",alpha:1,width:2,dashType:t.dashType??1}),s,new Oe(t.shapeCode??1)],i={id:n,parentId:o.id,type:v.Shape,zIndex:t.zIndex??ve.genZIndex(o),props:r};return e.execAction(new W),e.execAction(new Le({nodes:[i]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addNode 失败:",e),{code:500,msg:`添加节点失败: ${e instanceof Error?e.message:String(e)}`}}}deleteNode(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};const n=[],o=[];for(const s of t.ids)e.nodeManager.nodeMap.has(s)?n.push(s):o.push(s);return n.length===0?{code:404,msg:`所有节点都不存在: ${o.join(", ")}`}:(e.execAction(new W),e.execAction(At.create(n)),e.execAction(new z),o.length>0?{code:200,msg:`部分节点删除成功,以下节点不存在: ${o.join(", ")}`}:{code:200})}catch(e){return console.error("[AINodeAPI] deleteNode 失败:",e),{code:500,msg:`删除节点失败: ${e instanceof Error?e.message:String(e)}`}}}updateNode(t){try{const e=this.getCtx();if(!t.id)return{code:400,msg:"缺少必需参数: id"};if(!e.nodeManager.nodeMap.has(t.id))return{code:404,msg:`节点不存在: ${t.id}`};const n=[],o={};t.x!==void 0&&(o.x=t.x),t.y!==void 0&&(o.y=t.y),t.width!==void 0&&(o.width=t.width),t.height!==void 0&&(o.height=t.height),t.angle!==void 0&&(o.angle=t.angle),Object.keys(o).length>0&&(o.type=I.Base,n.push(o)),t.zIndex!==void 0&&(o.type=I.Base);const s={};t.color!==void 0&&(s.color=t.color),t.alpha!==void 0&&(s.alpha=t.alpha),Object.keys(s).length>0&&(s.type=I.Color,n.push(s));const r={};if(t.borderColor!==void 0&&(r.color=t.borderColor),t.borderWidth!==void 0&&(r.width=t.borderWidth),t.borderAlpha!==void 0&&(r.alpha=t.borderAlpha),t.dashType!==void 0&&(r.dashType=t.dashType),Object.keys(r).length>0&&(r.type=I.Border,n.push(r)),(t.text!==void 0||t.fontSize!==void 0||t.fontColor!==void 0)&&n.push({type:I.Text,richText:t.text!==void 0?this.computeRichText(t.text??""):void 0,fontSize:t.fontSize,fontColor:t.fontColor}),t.shapeCode!==void 0&&n.push(new Oe(t.shapeCode)),n.length===0)return{code:400,msg:"没有提供任何更新属性"};if(e.execAction(new W),t.zIndex!==void 0){const i=e.nodeManager.getNode(t.id);i&&(i.zIndex=t.zIndex)}return e.execAction(U.create(t.id,n)),e.execAction(new z),{code:200}}catch(e){return console.error("[AINodeAPI] updateNode 失败:",e),{code:500,msg:`更新节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchUpdateNode(t){try{const e=this.getCtx();if(!t.nodes||!Array.isArray(t.nodes))return{code:400,msg:"缺少必需参数: nodes (数组)"};if(t.nodes.length===0)return{code:400,msg:"nodes 数组不能为空"};const n=[];let o=0;e.execAction(new W);for(let s=0;s<t.nodes.length;s++){const r=t.nodes[s];try{if(!r.id){n.push({index:s,id:r.id,error:"缺少必需参数: id"});continue}if(!e.nodeManager.nodeMap.has(r.id)){n.push({index:s,id:r.id,error:`节点不存在: ${r.id}`});continue}const i=[],a={};r.x!==void 0&&(a.x=r.x),r.y!==void 0&&(a.y=r.y),r.width!==void 0&&(a.width=r.width),r.height!==void 0&&(a.height=r.height),r.angle!==void 0&&(a.angle=r.angle),Object.keys(a).length>0&&(a.type=I.Base,i.push(a));const c={};r.color!==void 0&&(c.color=r.color),r.alpha!==void 0&&(c.alpha=r.alpha),Object.keys(c).length>0&&(c.type=I.Color,i.push(c));const h={};r.borderColor!==void 0&&(h.color=r.borderColor),r.borderWidth!==void 0&&(h.width=r.borderWidth),r.borderAlpha!==void 0&&(h.alpha=r.borderAlpha),r.dashType!==void 0&&(h.dashType=r.dashType),Object.keys(h).length>0&&(h.type=I.Border,i.push(h));const d={};let u=!1;if(r.text!==void 0&&(d.richText=this.computeRichText(r.text),u=!0),r.fontSize!==void 0&&(d.fontSize=r.fontSize,u=!0),r.fontColor!==void 0&&(d.fontColor=r.fontColor,u=!0),r.bold!==void 0&&(d.bold=r.bold,u=!0),r.italic!==void 0&&(d.italic=r.italic,u=!0),r.underline!==void 0&&(d.underline=r.underline,u=!0),r.strikethrough!==void 0&&(d.strikethrough=r.strikethrough,u=!0),r.verticalAlign!==void 0&&(d.verticalAlign=r.verticalAlign,u=!0),r.horizonAlign!==void 0&&(d.horizonAlign=r.horizonAlign,u=!0),u&&(d.type=I.Text,i.push(d)),r.shapeCode!==void 0&&i.push(new Oe(r.shapeCode)),i.length===0){n.push({index:s,id:r.id,error:"没有提供任何更新属性"});continue}if(r.zIndex!==void 0){const f=e.nodeManager.getNode(r.id);f&&(f.zIndex=r.zIndex)}e.execAction(U.create(r.id,i)),o++}catch(i){n.push({index:s,id:r.id,error:i instanceof Error?i.message:String(i)})}}return e.execAction(new z),n.length===0?{code:200,successCount:o}:o===0?{code:500,msg:"所有节点更新失败",errorCount:n.length,errors:n}:{code:206,successCount:o,errorCount:n.length,errors:n}}catch(e){return console.error("[AINodeAPI] batchUpdateNode 失败:",e),{code:500,msg:`批量更新节点失败: ${e instanceof Error?e.message:String(e)}`}}}selectNode(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};const n=t.x,o=t.y,s=t.x+t.width,r=t.y+t.height,i=e.nodeManager.searchNodes(n,o,s,r),a=[];for(const c of i){if(c===e.nodeManager.root)continue;const h=c.getBounds(),d=c.getProp(I.Base);let u="";(c.type===v.Shape||c.type===v.Line||c.type===v.CheckboxText)&&(u=c.renderText.toString()),a.push({id:c.id,text:u,x:(d==null?void 0:d.x)??h.minX,y:(d==null?void 0:d.y)??h.minY,width:(d==null?void 0:d.width)??h.maxX-h.minX,height:(d==null?void 0:d.height)??h.maxY-h.minY})}return{code:200,nodes:a,count:a.length}}catch(e){return console.error("[AINodeAPI] selectNode 失败:",e),{code:500,msg:`查询节点失败: ${e instanceof Error?e.message:String(e)}`}}}selectNodeDetail(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};if(!t.ids.every(s=>typeof s=="string"))return{code:400,msg:"参数 ids 数组中的所有元素必须是字符串"};const n=[],o=[];for(const s of t.ids){const r=e.nodeManager.nodeMap.get(s);if(!r||r===e.nodeManager.root){o.push(s);continue}const i=r.getBounds(),a=r.getProp(I.Base),c=r.getProp(I.Color),h=r.getProp(I.Border),d=r.getProp(I.Text),u=r.getProp(I.Shape);let f="";(r.type===v.Shape||r.type===v.Line||r.type===v.CheckboxText)&&(f=r.renderText.toString()),n.push({id:r.id,type:r.type,x:(a==null?void 0:a.x)??i.minX,y:(a==null?void 0:a.y)??i.minY,width:(a==null?void 0:a.width)??i.maxX-i.minX,height:(a==null?void 0:a.height)??i.maxY-i.minY,angle:(a==null?void 0:a.angle)??0,zIndex:r.zIndex,color:(c==null?void 0:c.color)??"#FFFFFF",alpha:(c==null?void 0:c.alpha)??1,borderColor:(h==null?void 0:h.color)??"#000000",dashType:(h==null?void 0:h.dashType)??1,text:f,fontSize:d==null?void 0:d.fontSize,fontColor:d==null?void 0:d.fontColor,shapeCode:(u==null?void 0:u.shapeCode)??1})}return o.length>0?{code:200,nodes:n,count:n.length,msg:`部分节点查询成功,以下节点不存在: ${o.join(", ")}`}:{code:200,nodes:n,count:n.length}}catch(e){return console.error("[AINodeAPI] selectNodeDetail 失败:",e),{code:500,msg:`查询节点详细信息失败: ${e instanceof Error?e.message:String(e)}`}}}computeTextNodeSize(t){try{const e=this.getCtx();if(!t.ids||!Array.isArray(t.ids)||t.ids.length===0)return{code:400,msg:"缺少必需参数: ids (非空数组)"};if(!t.ids.every(i=>typeof i=="string"))return{code:400,msg:"参数 ids 数组中的所有元素必须是字符串"};const n=[],o=[],s=[];for(const i of t.ids){const a=e.nodeManager.getNode(i);if(!a||a===e.nodeManager.root){o.push(i);continue}if(!(a instanceof vt)){s.push(i);continue}const c=a.drawer.fullTextNodeHeight(a),h=a.renderText.width+2*le;n.push({id:i,width:h,height:c})}const r=[];return o.length>0&&r.push(`以下节点不存在: ${o.join(", ")}`),s.length>0&&r.push(`以下节点不是文字节点: ${s.join(", ")}`),n.length===0?{code:404,msg:r.join("; ")}:{code:200,nodes:n,count:n.length,msg:r.length>0?r.join("; "):void 0}}catch(e){return console.error("[AINodeAPI] computeTextNodeSize 失败:",e),{code:500,msg:`计算文字节点尺寸失败: ${e instanceof Error?e.message:String(e)}`}}}addLine(t){try{const e=this.getCtx();if(!t.points||!Array.isArray(t.points))return{code:400,msg:"缺少必需参数: points"};if(t.points.length<2)return{code:400,msg:"points 数组至少需要2个点(起点和终点)"};for(let u=0;u<t.points.length;u++){const f=t.points[u];if(typeof f.x!="number"||typeof f.y!="number"||isNaN(f.x)||isNaN(f.y))return{code:400,msg:`points[${u}] 必须包含有效的 x 和 y 坐标`}}const n=e.idGenerator.genId(v.Line),o=e.nodeManager.root;let s=t.points[0].x,r=t.points[0].y,i=t.points[0].x,a=t.points[0].y;for(const u of t.points)s=Math.min(s,u.x),r=Math.min(r,u.y),i=Math.max(i,u.x),a=Math.max(a,u.y);const c=[ie.create({x:s,y:r,width:i-s,height:a-r,angle:0}),Ae.create({color:t.borderColor??"#000000",alpha:1,width:t.borderWidth??2,dashType:t.dashType??1}),Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize??14,fontColor:t.fontColor??"#000000"}),new Oe(t.shapeCode??0),je.create(t.points,!0),new Rt,lt.create({lArrow:t.lArrow??0,rArrow:t.rArrow??0})],h=new Et;h.width=20,h.height=20,h.point={x:t.points[Math.floor(t.points.length/2)].x,y:t.points[Math.floor(t.points.length/2)].y},c.push(h);const d={id:n,parentId:o.id,type:v.Line,zIndex:t.zIndex??ve.genZIndex(o),props:c};return e.execAction(new W),e.execAction(new Le({nodes:[d]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addLine 失败:",e),{code:500,msg:`添加连线失败: ${e instanceof Error?e.message:String(e)}`}}}addSvg(t){try{const e=this.getCtx();if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)return{code:400,msg:"缺少必需参数: x, y, width, height"};if(!t.svgCode||typeof t.svgCode!="string")return{code:400,msg:"缺少必需参数: svgCode"};if(!t.svgCode.includes('xmlns="http://www.w3.org/2000/svg"')&&!t.svgCode.includes("xmlns='http://www.w3.org/2000/svg'"))return{code:400,msg:'SVG 代码必须包含 xmlns="http://www.w3.org/2000/svg" 属性'};const n=e.idGenerator.genId(v.SVG),o=e.nodeManager.root,s=new Wn;s.url="",s.useCode=!0,s.code=t.svgCode;const r=[ie.create({x:t.x,y:t.y,width:t.width,height:t.height,angle:t.angle??0}),Ae.create({color:t.borderColor??"",alpha:1,width:t.borderWidth??2,dashType:t.dashType??0}),s],i={id:n,parentId:o.id,type:v.SVG,zIndex:ve.genZIndex(o),props:r};return e.execAction(new W),e.execAction(new Le({nodes:[i]})),e.execAction(new z),{code:200,id:n}}catch(e){return console.error("[AINodeAPI] addSvg 失败:",e),{code:500,msg:`添加SVG节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchAddNodes(t){try{const e=this.getCtx();if(!t.nodes||!Array.isArray(t.nodes))return{code:400,msg:"缺少必需参数: nodes"};if(t.nodes.length===0)return{code:400,msg:"nodes 数组不能为空"};for(let r=0;r<t.nodes.length;r++){const i=t.nodes[r];if(i.x===void 0||i.y===void 0||i.width===void 0||i.height===void 0)return{code:400,msg:`nodes[${r}] 缺少必需参数: x, y, width, height`}}const n=e.nodeManager.root,o=[],s=[];for(const r of t.nodes){const i=e.idGenerator.genId(v.Shape);s.push(i);const a=Ge.create({richText:this.computeRichText(r.text??""),fontSize:r.fontSize,fontColor:r.fontColor,bold:r.bold,italic:r.italic,underline:r.underline,strikethrough:r.strikethrough,verticalAlign:r.verticalAlign,horizonAlign:r.horizonAlign}),c=[ie.create({x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle??0}),tt.create({color:r.color??"#FFFFFF",alpha:r.alpha??1}),Ae.create({color:r.borderColor??"#000000",alpha:1,width:2,dashType:r.dashType??1}),a,new Oe(r.shapeCode??1)],h={id:i,parentId:n.id,type:v.Shape,zIndex:r.zIndex??ve.genZIndex(n),props:c};o.push(h)}return e.execAction(new W),e.execAction(new Le({nodes:o})),e.execAction(new z),{code:200,ids:s,count:s.length}}catch(e){return console.error("[AINodeAPI] batchAddNodes 失败:",e),{code:500,msg:`批量添加节点失败: ${e instanceof Error?e.message:String(e)}`}}}batchAddLines(t){try{const e=this.getCtx();if(!t.lines||!Array.isArray(t.lines))return{code:400,msg:"缺少必需参数: lines"};if(t.lines.length===0)return{code:400,msg:"lines 数组不能为空"};for(let r=0;r<t.lines.length;r++){const i=t.lines[r];if(!i.points||!Array.isArray(i.points))return{code:400,msg:`lines[${r}] 缺少必需参数: points`};if(i.points.length<2)return{code:400,msg:`lines[${r}].points 数组至少需要2个点(起点和终点)`};for(let a=0;a<i.points.length;a++){const c=i.points[a];if(typeof c.x!="number"||typeof c.y!="number"||isNaN(c.x)||isNaN(c.y))return{code:400,msg:`lines[${r}].points[${a}] 必须包含有效的 x 和 y 坐标`}}}const n=e.nodeManager.root,o=[],s=[];for(const r of t.lines){const i=e.idGenerator.genId(v.Line);s.push(i);let a=r.points[0].x,c=r.points[0].y,h=r.points[0].x,d=r.points[0].y;for(const y of r.points)a=Math.min(a,y.x),c=Math.min(c,y.y),h=Math.max(h,y.x),d=Math.max(d,y.y);const u=[ie.create({x:a,y:c,width:h-a,height:d-c,angle:0}),Ae.create({color:r.borderColor??"#000000",alpha:1,width:r.borderWidth??2,dashType:r.dashType??1}),Ge.create({richText:this.computeRichText(r.text??""),fontSize:r.fontSize??14,fontColor:r.fontColor??"#000000"}),new Oe(r.shapeCode??0),je.create(r.points,!0),new Rt,lt.create({lArrow:r.lArrow??0,rArrow:r.rArrow??0})],f=new Et;f.width=20,f.height=20,f.point={x:r.points[Math.floor(r.points.length/2)].x,y:r.points[Math.floor(r.points.length/2)].y},u.push(f);const g={id:i,parentId:n.id,type:v.Line,zIndex:r.zIndex??ve.genZIndex(n),props:u};o.push(g)}return e.execAction(new W),e.execAction(new Le({nodes:o})),e.execAction(new z),{code:200,ids:s,count:s.length}}catch(e){return console.error("[AINodeAPI] batchAddLines 失败:",e),{code:500,msg:`批量添加连线失败: ${e instanceof Error?e.message:String(e)}`}}}connectLine(t){try{const e=this.getCtx();if(!t.startInfo&&!t.startPoint)return{code:400,msg:"必须提供 startInfo 或 startPoint 中的一个"};if(!t.endInfo&&!t.endPoint)return{code:400,msg:"必须提供 endInfo 或 endPoint 中的一个"};let n=null;if(t.startInfo){if(n=e.nodeManager.getNode(t.startInfo.id),!n)return{code:404,msg:`起始节点不存在: ${t.startInfo.id}`};if(![0,1,2,3].includes(t.startInfo.endType))return{code:400,msg:"startInfo.endType 必须是 0, 1, 2 或 3"}}let o=null;if(t.endInfo){if(o=e.nodeManager.getNode(t.endInfo.id),!o)return{code:404,msg:`终止节点不存在: ${t.endInfo.id}`};if(![0,1,2,3].includes(t.endInfo.endType))return{code:400,msg:"endInfo.endType 必须是 0, 1, 2 或 3"}}if(t.startPoint&&(typeof t.startPoint.x!="number"||typeof t.startPoint.y!="number"||isNaN(t.startPoint.x)||isNaN(t.startPoint.y)))return{code:400,msg:"startPoint 必须包含有效的 x 和 y 坐标"};if(t.endPoint&&(typeof t.endPoint.x!="number"||typeof t.endPoint.y!="number"||isNaN(t.endPoint.x)||isNaN(t.endPoint.y)))return{code:400,msg:"endPoint 必须包含有效的 x 和 y 坐标"};const s=(E,X)=>{const $=E.props.get(I.Base);if(!$)throw new Error("节点缺少 BaseProps");const{x:Z,y:se,width:ne,height:ae}=$;switch(X){case 0:return{x:Z+ne/2,y:se};case 1:return{x:Z+ne,y:se+ae/2};case 2:return{x:Z+ne/2,y:se+ae};case 3:return{x:Z,y:se+ae/2};default:return{x:Z+ne/2,y:se+ae/2}}};let r,i;if(t.startInfo&&n){const E=s(n,t.startInfo.endType);r=E.x,i=E.y}else if(t.startPoint)r=t.startPoint.x,i=t.startPoint.y;else return{code:400,msg:"无法计算起点坐标"};let a,c;if(t.endInfo&&o){const E=s(o,t.endInfo.endType);a=E.x,c=E.y}else if(t.endPoint)a=t.endPoint.x,c=t.endPoint.y;else return{code:400,msg:"无法计算终点坐标"};const h=t.shapeCode??0;let d;const u={point:{x:r,y:i}};if(t.startInfo&&n){const E=D.rectNode2Rect(n.getBounds()),X=[de.Top,de.Right,de.Bottom,de.Left];u.nodeConnect={rect:E,endType:X[t.startInfo.endType]}}const f={point:{x:a,y:c}};if(t.endInfo&&o){const E=D.rectNode2Rect(o.getBounds()),X=[de.Top,de.Right,de.Bottom,de.Left];f.nodeConnect={rect:E,endType:X[t.endInfo.endType]}}h===0?d=new Xo().layoutToPointsPro(u,f):h===3?d=new uo().layoutToPointsPro(u,f):d=new Vt().layoutToPointsPro(u,f);const g=e.idGenerator.genId(v.Line),y=e.nodeManager.root,m=S.getBoundsByPoints(d),w=[{type:I.Base,x:m.minX,y:m.minY,width:m.maxX-m.minX,height:m.maxY-m.minY},Ae.create({color:t.borderColor??"#000000",alpha:1,width:t.borderWidth??2,dashType:t.dashType??1}),Ge.create({richText:this.computeRichText(t.text??""),fontSize:t.fontSize??14,fontColor:t.fontColor??"#000000"}),new Oe(t.shapeCode??0),je.create(d,!0),lt.create({lArrow:t.lArrow??0,rArrow:t.rArrow??0})],L=new Rt;if(t.startInfo&&n){const X=n.drawer.getConnectAnchor()[t.startInfo.endType];L.start={objectId:t.startInfo.id,x:X.x,y:X.y}}else L.start=null;if(t.endInfo&&o){const X=o.drawer.getConnectAnchor()[t.endInfo.endType];L.end={objectId:t.endInfo.id,x:X.x,y:X.y}}else L.end=null;w.push(L);const B=new Et;B.width=20,B.height=20,B.point={x:(r+a)/2,y:(i+c)/2},w.push(B);const H={id:g,parentId:y.id,type:v.Line,zIndex:t.zIndex??ve.genZIndex(y),props:w};return e.execAction(new W),e.execAction(new Le({nodes:[H]})),e.execAction(new z),{code:200,id:g}}catch(e){return console.error("[AINodeAPI] connectLine 失败:",e),console.error("[AINodeAPI] connectLine 失败:",e),{code:500,msg:`创建连接线失败: ${e instanceof Error?e.message:String(e)}`}}}batchConnectLine(t){var e,n,o,s,r,i,a,c,h;try{const d=this.getCtx();if(!t.connections||!Array.isArray(t.connections))return{code:400,msg:"connections 参数必须是一个数组"};if(t.connections.length===0)return{code:400,msg:"connections 数组不能为空"};const u=[];let f=0,g=0;d.execAction(new W);for(let y=0;y<t.connections.length;y++){const m=t.connections[y],b={startInfo:m.startInfo,endInfo:m.endInfo,startPoint:m.startPoint,endPoint:m.endPoint,zIndex:m.zIndex??((e=t.defaultStyle)==null?void 0:e.zIndex),shapeCode:m.shapeCode??((n=t.defaultStyle)==null?void 0:n.shapeCode)??0,borderColor:m.borderColor??((o=t.defaultStyle)==null?void 0:o.borderColor)??"#000000",borderWidth:m.borderWidth??((s=t.defaultStyle)==null?void 0:s.borderWidth)??2,dashType:m.dashType??((r=t.defaultStyle)==null?void 0:r.dashType)??1,lArrow:m.lArrow??((i=t.defaultStyle)==null?void 0:i.lArrow)??0,rArrow:m.rArrow??((a=t.defaultStyle)==null?void 0:a.rArrow)??0,text:m.text??"",fontSize:m.fontSize??((c=t.defaultStyle)==null?void 0:c.fontSize)??14,fontColor:m.fontColor??((h=t.defaultStyle)==null?void 0:h.fontColor)??"#000000",textPosition:m.textPosition??.5};try{if(!b.startInfo&&!b.startPoint)throw new Error(`连接 ${y}: 必须提供 startInfo 或 startPoint 中的一个`);if(!b.endInfo&&!b.endPoint)throw new Error(`连接 ${y}: 必须提供 endInfo 或 endPoint 中的一个`);let w=null;if(b.startInfo){if(w=d.nodeManager.getNode(b.startInfo.id),!w)throw new Error(`连接 ${y}: 起始节点不存在: ${b.startInfo.id}`);if(![0,1,2,3].includes(b.startInfo.endType))throw new Error(`连接 ${y}: startInfo.endType 必须是 0, 1, 2 或 3`)}let L=null;if(b.endInfo){if(L=d.nodeManager.getNode(b.endInfo.id),!L)throw new Error(`连接 ${y}: 终止节点不存在: ${b.endInfo.id}`);if(![0,1,2,3].includes(b.endInfo.endType))throw new Error(`连接 ${y}: endInfo.endType 必须是 0, 1, 2 或 3`)}if(b.startPoint&&(typeof b.startPoint.x!="number"||typeof b.startPoint.y!="number"||isNaN(b.startPoint.x)||isNaN(b.startPoint.y)))throw new Error(`连接 ${y}: startPoint 必须包含有效的 x 和 y 坐标`);if(b.endPoint&&(typeof b.endPoint.x!="number"||typeof b.endPoint.y!="number"||isNaN(b.endPoint.x)||isNaN(b.endPoint.y)))throw new Error(`连接 ${y}: endPoint 必须包含有效的 x 和 y 坐标`);const B=(O,G)=>{const j=O.props.get(I.Base);if(!j)throw new Error("节点缺少 BaseProps");const{x:_,y:Ve,width:ut,height:yt}=j;switch(G){case 0:return{x:_+ut/2,y:Ve};case 1:return{x:_+ut,y:Ve+yt/2};case 2:return{x:_+ut/2,y:Ve+yt};case 3:return{x:_,y:Ve+yt/2};default:return{x:_+ut/2,y:Ve+yt/2}}};let H,E;if(b.startInfo&&w){const O=B(w,b.startInfo.endType);H=O.x,E=O.y}else if(b.startPoint)H=b.startPoint.x,E=b.startPoint.y;else throw new Error(`连接 ${y}: 无法计算起点坐标`);let X,$;if(b.endInfo&&L){const O=B(L,b.endInfo.endType);X=O.x,$=O.y}else if(b.endPoint)X=b.endPoint.x,$=b.endPoint.y;else throw new Error(`连接 ${y}: 无法计算终点坐标`);const Z=b.shapeCode;let se;const ne={point:{x:H,y:E}};if(b.startInfo&&w){const O=D.rectNode2Rect(w.getBounds()),G=[de.Top,de.Right,de.Bottom,de.Left];ne.nodeConnect={rect:O,endType:G[b.startInfo.endType]}}const ae={point:{x:X,y:$}};if(b.endInfo&&L){const O=D.rectNode2Rect(L.getBounds()),G=[de.Top,de.Right,de.Bottom,de.Left];ae.nodeConnect={rect:O,endType:G[b.endInfo.endType]}}Z===0?se=new Xo().layoutToPointsPro(ne,ae):Z===3?se=new uo().layoutToPointsPro(ne,ae):se=new Vt().layoutToPointsPro(ne,ae);const te=d.idGenerator.genId(v.Line),ce=d.nodeManager.root,pe=S.getBoundsByPoints(se),Re=[{type:I.Base,x:pe.minX,y:pe.minY,width:pe.maxX-pe.minX,height:pe.maxY-pe.minY},Ae.create({color:b.borderColor,alpha:1,width:b.borderWidth,dashType:b.dashType}),Ge.create({richText:this.computeRichText(b.text),fontSize:b.fontSize,fontColor:b.fontColor}),new Oe(b.shapeCode),je.create(se,!0),lt.create({lArrow:b.lArrow,rArrow:b.rArrow})],Se=new Rt;if(b.startInfo&&w){const G=w.drawer.getConnectAnchor()[b.startInfo.endType];Se.start={objectId:b.startInfo.id,x:G.x,y:G.y}}else Se.start=null;if(b.endInfo&&L){const G=L.drawer.getConnectAnchor()[b.endInfo.endType];Se.end={objectId:b.endInfo.id,x:G.x,y:G.y}}else Se.end=null;Re.push(Se);const Te=new Et;Te.width=20,Te.height=20,Te.point={x:(H+X)/2,y:(E+$)/2},Re.push(Te);const fe={id:te,parentId:ce.id,type:v.Line,zIndex:b.zIndex??ve.genZIndex(ce),props:Re};d.execAction(new Le({nodes:[fe]})),u.push({index:y,success:!0,id:te}),f++}catch(w){const L=w instanceof Error?w.message:String(w);console.error(`[AINodeAPI] 批量连接线 - 连接 ${y} 失败:`,w),u.push({index:y,success:!1,error:L}),g++}}return d.execAction(new z),{code:200,successCount:f,failedCount:g,results:u}}catch(d){return console.error("[AINodeAPI] batchConnectLine 失败:",d),{code:500,msg:`批量创建连接线失败: ${d instanceof Error?d.message:String(d)}`}}}}class ry{constructor(t){p(this,"app");this.app=t}getCtx(){return this.app.appContext}getViewportBounds(){try{const e=this.getCtx().gmlRender.getViewPortBounds();return{code:200,bounds:{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY,width:e.maxX-e.minX,height:e.maxY-e.minY}}}catch(t){return console.error("[AIViewportAPI] getViewportBounds 失败:",t),{code:500,msg:`获取视口边界失败: ${t instanceof Error?t.message:String(t)}`}}}zoomToBounds(t,e,n,o){try{const s=this.getCtx();if(t>=n||e>=o)return{code:400,msg:"无效的边界参数:minX 必须小于 maxX,minY 必须小于 maxY"};const r={minX:t,minY:e,maxX:n,maxY:o,id:"temp-zoom-bounds"};return s.renderManager.zoomWorker.zoomToBounds(r,s.renderManager),{code:200}}catch(s){return console.error("[AIViewportAPI] zoomToBounds 失败:",s),{code:500,msg:`缩放到指定边界失败: ${s instanceof Error?s.message:String(s)}`}}}zoomToFit(){try{const t=this.getCtx();return t.renderManager.nodeManager.nodeMap.size===0?{code:400,msg:"画布中没有节点,无法执行适配缩放"}:(t.renderManager.zoomWorker.zoomToFit(t.renderManager),{code:200})}catch(t){return console.error("[AIViewportAPI] zoomToFit 失败:",t),{code:500,msg:`缩放适配所有节点失败: ${t instanceof Error?t.message:String(t)}`}}}zoomToSelect(){try{const t=this.getCtx();return t.renderManager.auxiliaryManager.selectManager.getSelectNodes().length===0?{code:400,msg:"当前没有选中任何节点,无法执行缩放"}:(t.renderManager.zoomWorker.zoomToSelect(t.renderManager),{code:200})}catch(t){return console.error("[AIViewportAPI] zoomToSelect 失败:",t),{code:500,msg:`缩放到选中节点失败: ${t instanceof Error?t.message:String(t)}`}}}}class iy{constructor(t){p(this,"app");this.app=t}getCtx(){return this.app.appContext}getSelectedNodes(){try{const t=this.getCtx(),e=t.getSelectNodes();if(!e||e.size===0)return{code:200,nodes:[],count:0};const n=[];for(const o of e){if(o===t.nodeManager.root)continue;const s=o.getBounds(),r=o.getProp(I.Base);let i="";(o.type===v.Shape||o.type===v.Line||o.type===v.CheckboxText)&&(i=o.renderText.toString()),n.push({id:o.id,text:i,x:(r==null?void 0:r.x)??s.minX,y:(r==null?void 0:r.y)??s.minY,width:(r==null?void 0:r.width)??s.maxX-s.minX,height:(r==null?void 0:r.height)??s.maxY-s.minY})}return{code:200,nodes:n,count:n.length}}catch(t){return console.error("[SelectAPI] getSelectedNodes 失败:",t),{code:500,msg:`获取选中节点信息失败: ${t instanceof Error?t.message:String(t)}`}}}selectAllNodes(){try{const t=this.getCtx(),e=[];for(const[n,o]of t.nodeManager.nodeMap){if(o===t.nodeManager.root)continue;const s=o.getBounds(),r=o.getProp(I.Base);let i="";(o.type===v.Shape||o.type===v.Line||o.type===v.CheckboxText)&&(i=o.renderText.toString()),e.push({id:o.id,text:i,x:(r==null?void 0:r.x)??s.minX,y:(r==null?void 0:r.y)??s.minY,width:(r==null?void 0:r.width)??s.maxX-s.minX,height:(r==null?void 0:r.height)??s.maxY-s.minY})}return{code:200,nodes:e,count:e.length}}catch(t){return console.error("[SelectAPI] selectAllNodes 失败:",t),{code:500,msg:`获取所有节点信息失败: ${t instanceof Error?t.message:String(t)}`}}}}class jc{constructor(t){p(this,"app");p(this,"node");p(this,"viewport");p(this,"select");this.app=t,this.node=new sy(t),this.viewport=new ry(t),this.select=new iy(t)}}class ay{constructor(t){p(this,"renderDom",null);p(this,"inputDom",null);p(this,"isFocusing",!1);p(this,"cursorManager");this.cursorManager=t}init(t,e){this.inputDom=t,this.renderDom=e}focus(){setTimeout(()=>{this.inputDom.focus(),console.log("njx debug ======>i am focus")},100),this.isFocusing=!0,this.cursorManager.setCursor("text")}blur(){this.isFocusing=!1,this.inputDom.blur(),this.renderDom.style.display="none"}hideRenderDom(){this.renderDom.style.display="none"}updateCursor(t,e,n,o){const s=e.globalTransform.crossPoint(t),r=e.canvas.getBoundingClientRect(),i=window.devicePixelRatio;let a=s.x/i+r.x,c=s.y/i+r.y;a>r.width&&(a=0),c>r.height&&(c=0),this.renderDom.style.left=a+"px",this.renderDom.style.top=c+"px",this.inputDom.style.left=a+"px",this.inputDom.style.top=c+"px",this.renderDom.style.transform=`rotate(${o}deg)`,this.renderDom.style.transformOrigin="top left",this.renderDom.style.display="unset",this.renderDom.style.height=n*e.getScale()+"px"}}class cy{constructor(){p(this,"selectionInfo",null);p(this,"selectionWorker",new yc)}clear(){this.selectionInfo=null}generateSelect(t,e,n){const o=this.selectionWorker.computeTextSelection(t,e,n);return o.length===0?[]:(this.selectionInfo={start:e,end:n,selectionList:o},o)}}class ly{constructor(t,e){p(this,"renderInput");p(this,"editTextInfo",null);p(this,"selectionManager",new cy);p(this,"renderManager");this.renderInput=new ay(e),this.renderManager=t}init(t,e){var n;(n=this.renderInput)==null||n.init(t,e),this.renderInput.hideRenderDom()}isEdit(){return this.editTextInfo!==null}hasSelection(){return this.selectionManager.selectionInfo!==null}checkNeedReFocusInputDom(t){return!this.editTextInfo||this.editTextInfo.node.id!==t.node.id||!this.editTextInfo.textCursorPosition.equal(t.textCursorPosition)}focus(t){this.checkNeedReFocusInputDom(t),this.editTextInfo=t;const{node:e,renderText:n,textCursorPosition:o}=t,{relativePos:s,height:r}=n.getPosByCursorPosition(o),i=e.toGlobal(s);this.renderInput.focus(),console.log("njx debug:===>focus"),this.renderInput.updateCursor(i,this.renderManager.gmlRender,r,e.baseProps.angle),this.selectionManager.clear()}selection(t,e,n,o){let s=n,r=o;o.greaterThan(n)||(s=o,r=n),this.editTextInfo={node:t,renderText:e,textCursorPosition:s};const i=this.selectionManager.generateSelect(e,s,r);return this.renderInput.focus(),this.renderInput.hideRenderDom(),i}refreshCursor(){if(!this.editTextInfo)return;const{node:t,renderText:e,textCursorPosition:n}=this.editTextInfo,{relativePos:o,height:s}=e.getPosByCursorPosition(n),r=t.toGlobal(o);this.renderInput.updateCursor(r,this.renderManager.gmlRender,s,t.baseProps.angle)}updateCursorPos(t){this.editTextInfo&&(this.editTextInfo.textCursorPosition=t,this.refreshCursor())}blur(){var t;console.log("====>blur"),this.selectionManager.selectionInfo&&this.selectionManager.clear(),this.editTextInfo&&(this.editTextInfo.node.resetFromEditing(),this.renderManager.addContentRenderTask(),(t=this.renderInput)==null||t.blur(),this.editTextInfo=null)}}class hy{constructor(t,e){p(this,"docState");p(this,"nodeManager");this.docState=e,this.nodeManager=t}serializeTo(){const t=[],e=this.nodeManager;for(const[o,s]of e.nodeMap)t.push(s.serializeTo());return{documentId:"",nodes:t}}deSerialize(t){return JSON.parse(t)}}class Vc{constructor(){p(this,"canEdit",!0)}}class Kc{constructor(){p(this,"seq",0);p(this,"savedSeq",-1);p(this,"backgroundColor","#EEEEEE");p(this,"userid","");p(this,"sessionId","");p(this,"docId","");p(this,"userPermission",new Vc);p(this,"docMode",ue.BOARD);p(this,"slideStatus",{slideContainer:null,currentIndex:0,slideCoverList:[]})}load(t){this.backgroundColor=t.backgroundColor,this.seq=t.seq,this.savedSeq=t.savedSeq}canEdit(){return this.userPermission.canEdit}changePermission({canEdit:t}){this.userPermission.canEdit=t}resetSlideCovers(){if(this.slideStatus.slideCoverList.length!==0){for(const t of this.slideStatus.slideCoverList)URL.revokeObjectURL(t.blobUrl);this.slideStatus.slideCoverList=[]}}}function dy(){return{backgroundColor:"#EEEEEE",seq:0,savedSeq:0}}class Qc{}class Pr{constructor(){p(this,"globalTransform",re.generateMatrix());p(this,"canvas",null);p(this,"glCtx",null);this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}init(t){this.canvas=t;const e=this.canvas.getContext("2d");this.glCtx=e;const{a:n,b:o,c:s,d:r,e:i,f:a}=this.globalTransform;e.transform(n,o,s,r,i,a)}setTransform(t,e,n,o,s,r){this.globalTransform.setTransform(t,e,n,o,s,r),this.glCtx.setTransform(t,e,n,o,s,r)}reset(){if(!this.canvas){console.error("Error! The canvas is null!");return}const t=this.canvas.getContext("2d"),{a:e,b:n,c:o,d:s,e:r,f:i}=this.globalTransform;t.setTransform(e,n,o,s,r,i)}scale(t,e,n){if(!n){this.globalTransform.a*=t,this.globalTransform.d*=e;return}const o=re.generateMatrix().translate(-n.x,-n.y),s=re.generateMatrix().scale(t,t),i=re.generateMatrix().translate(n.x,n.y).crossProduct(s).crossProduct(o);this.globalTransform=this.globalTransform.crossProduct(i)}translation(t,e){const n=re.generateMatrix().translate(t,e);this.globalTransform=this.globalTransform.crossProduct(n)}resetTransform(){this.globalTransform=re.generateMatrix(),this.globalTransform.a=window.devicePixelRatio,this.globalTransform.d=window.devicePixelRatio}transformToLocal(t){const{a:e,b:n,c:o,d:s,e:r,f:i}=this.globalTransform;return t.x=e*t.x+o*t.y+r,t.y=n*t.x+s*t.y+i,t.x=t.x/window.devicePixelRatio,t.y=t.y/window.devicePixelRatio,t}transformToGlobal(t){const e=new P(t.x,t.y);e.x=e.x*window.devicePixelRatio,e.y=e.y*window.devicePixelRatio;const{a:n,d:o,e:s,f:r}=this.globalTransform;return e.x=e.x/n-s/n,e.y=e.y/o-r/o,e}dirtyDraw(t,e){const n=this.canvas.getContext("2d");n.clearRect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY),n.save(),n.beginPath(),n.rect(t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY),n.clip();for(const o of e)o.draw();n.restore()}getViewPortBounds(){const t=this.canvas.getBoundingClientRect(),e=new P(t.width,t.height),n=this.transformToGlobal(new P(0,0)),o=this.transformToGlobal(e);return{id:"rect",minX:n.x,minY:n.y,maxX:o.x,maxY:o.y}}getGlobalPoint(t){const e=this.canvas.getBoundingClientRect(),n=new P(t.clientX-e.x,t.clientY-e.y);return this.transformToGlobal(n)}getScale(){const t=window.devicePixelRatio;return this.globalTransform.a/t}scaleToCenter(t){const e=this.getScale(),n=t/e,o=this.getViewPortBounds(),s=new P(.5*(o.minX+o.maxX),.5*(o.minY+o.maxY));this.scale(n,n,s)}}function uy(l,t,e,n,o){Zc(l,t,e||0,n||l.length-1,o||py)}function Zc(l,t,e,n,o){for(;n>e;){if(n-e>600){var s=n-e+1,r=t-e+1,i=Math.log(s),a=.5*Math.exp(2*i/3),c=.5*Math.sqrt(i*a*(s-a)/s)*(r-s/2<0?-1:1),h=Math.max(e,Math.floor(t-r*a/s+c)),d=Math.min(n,Math.floor(t+(s-r)*a/s+c));Zc(l,t,h,d,o)}var u=l[t],f=e,g=n;for(vo(l,e,t),o(l[n],u)>0&&vo(l,e,n);f<g;){for(vo(l,f,g),f++,g--;o(l[f],u)<0;)f++;for(;o(l[g],u)>0;)g--}o(l[e],u)===0?vo(l,e,g):(g++,vo(l,g,n)),g<=t&&(e=g+1),t<=g&&(n=g-1)}}function vo(l,t,e){var n=l[t];l[t]=l[e],l[e]=n}function py(l,t){return l<t?-1:l>t?1:0}class fy{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!ds(t,e))return n;const o=this.toBBox,s=[];for(;e;){for(let r=0;r<e.children.length;r++){const i=e.children[r],a=e.leaf?o(i):i;ds(t,a)&&(e.leaf?n.push(i):br(t,a)?this._all(i,n):s.push(i))}e=s.pop()}return n}collides(t){let e=this.data;if(!ds(t,e))return!1;const n=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],r=e.leaf?this.toBBox(s):s;if(ds(t,r)){if(e.leaf||br(t,r))return!0;n.push(s)}}e=n.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let n=0;n<t.length;n++)this.insert(t[n]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const n=this.data;this.data=e,e=n}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Kn([]),this}remove(t,e){if(!t)return this;let n=this.data;const o=this.toBBox(t),s=[],r=[];let i,a,c;for(;n||s.length;){if(n||(n=s.pop(),a=s[s.length-1],i=r.pop(),c=!0),n.leaf){const h=gy(t,n.children,e);if(h!==-1)return n.children.splice(h,1),s.push(n),this._condense(s),this}!c&&!n.leaf&&br(n,o)?(s.push(n),r.push(i),i=0,a=n,n=n.children[0]):a?(i++,n=a.children[i],c=!1):n=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,o){const s=n-e+1;let r=this._maxEntries,i;if(s<=r)return i=Kn(t.slice(e,n+1)),Vn(i,this.toBBox),i;o||(o=Math.ceil(Math.log(s)/Math.log(r)),r=Math.ceil(s/Math.pow(r,o-1))),i=Kn([]),i.leaf=!1,i.height=o;const a=Math.ceil(s/r),c=a*Math.ceil(Math.sqrt(r));qc(t,e,n,c,this.compareMinX);for(let h=e;h<=n;h+=c){const d=Math.min(h+c-1,n);qc(t,h,d,a,this.compareMinY);for(let u=h;u<=d;u+=a){const f=Math.min(u+a-1,d);i.children.push(this._build(t,u,f,o-1))}}return Vn(i,this.toBBox),i}_chooseSubtree(t,e,n,o){for(;o.push(e),!(e.leaf||o.length-1===n);){let s=1/0,r=1/0,i;for(let a=0;a<e.children.length;a++){const c=e.children[a],h=mr(c),d=wy(t,c)-h;d<r?(r=d,s=h<s?h:s,i=c):d===r&&h<s&&(s=h,i=c)}e=i||e.children[0]}return e}_insert(t,e,n){const o=n?t:this.toBBox(t),s=[],r=this._chooseSubtree(o,this.data,e,s);for(r.children.push(t),To(r,o);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(o,s,e)}_split(t,e){const n=t[e],o=n.children.length,s=this._minEntries;this._chooseSplitAxis(n,s,o);const r=this._chooseSplitIndex(n,s,o),i=Kn(n.children.splice(r,n.children.length-r));i.height=n.height,i.leaf=n.leaf,Vn(n,this.toBBox),Vn(i,this.toBBox),e?t[e-1].children.push(i):this._splitRoot(n,i)}_splitRoot(t,e){this.data=Kn([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Vn(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let o,s=1/0,r=1/0;for(let i=e;i<=n-e;i++){const a=Io(t,0,i,this.toBBox),c=Io(t,i,n,this.toBBox),h=Py(a,c),d=mr(a)+mr(c);h<s?(s=h,o=i,r=d<r?d:r):h===s&&d<r&&(r=d,o=i)}return o||n-e}_chooseSplitAxis(t,e,n){const o=t.leaf?this.compareMinX:yy,s=t.leaf?this.compareMinY:xy,r=this._allDistMargin(t,e,n,o),i=this._allDistMargin(t,e,n,s);r<i&&t.children.sort(o)}_allDistMargin(t,e,n,o){t.children.sort(o);const s=this.toBBox,r=Io(t,0,e,s),i=Io(t,n-e,n,s);let a=hs(r)+hs(i);for(let c=e;c<n-e;c++){const h=t.children[c];To(r,t.leaf?s(h):h),a+=hs(r)}for(let c=n-e-1;c>=e;c--){const h=t.children[c];To(i,t.leaf?s(h):h),a+=hs(i)}return a}_adjustParentBBoxes(t,e,n){for(let o=n;o>=0;o--)To(e[o],t)}_condense(t){for(let e=t.length-1,n;e>=0;e--)t[e].children.length===0?e>0?(n=t[e-1].children,n.splice(n.indexOf(t[e]),1)):this.clear():Vn(t[e],this.toBBox)}}function gy(l,t,e){if(!e)return t.indexOf(l);for(let n=0;n<t.length;n++)if(e(l,t[n]))return n;return-1}function Vn(l,t){Io(l,0,l.children.length,t,l)}function Io(l,t,e,n,o){o||(o=Kn(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let s=t;s<e;s++){const r=l.children[s];To(o,l.leaf?n(r):r)}return o}function To(l,t){return l.minX=Math.min(l.minX,t.minX),l.minY=Math.min(l.minY,t.minY),l.maxX=Math.max(l.maxX,t.maxX),l.maxY=Math.max(l.maxY,t.maxY),l}function yy(l,t){return l.minX-t.minX}function xy(l,t){return l.minY-t.minY}function mr(l){return(l.maxX-l.minX)*(l.maxY-l.minY)}function hs(l){return l.maxX-l.minX+(l.maxY-l.minY)}function wy(l,t){return(Math.max(t.maxX,l.maxX)-Math.min(t.minX,l.minX))*(Math.max(t.maxY,l.maxY)-Math.min(t.minY,l.minY))}function Py(l,t){const e=Math.max(l.minX,t.minX),n=Math.max(l.minY,t.minY),o=Math.min(l.maxX,t.maxX),s=Math.min(l.maxY,t.maxY);return Math.max(0,o-e)*Math.max(0,s-n)}function br(l,t){return l.minX<=t.minX&&l.minY<=t.minY&&t.maxX<=l.maxX&&t.maxY<=l.maxY}function ds(l,t){return t.minX<=l.maxX&&t.minY<=l.maxY&&t.maxX>=l.minX&&t.maxY>=l.minY}function Kn(l){return{children:l,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function qc(l,t,e,n,o){const s=[t,e];for(;s.length;){if(e=s.pop(),t=s.pop(),e-t<=n)continue;const r=t+Math.ceil((e-t)/n/2)*n;uy(l,r,t,e,o),s.push(t,r,r,e)}}class Jc extends Qc{constructor(){super();p(this,"root");p(this,"previewRoot");p(this,"nodeMap");p(this,"tree");p(this,"linkMap");this.nodeMap=new Map,this.tree=new fy,this.root=new pr(Sn),this.previewRoot=new pr(Xr),this.linkMap=new Map}clear(){this.tree.clear(),this.nodeMap.clear()}searchNodesByRectNode(e){const{minY:n,minX:o,maxY:s,maxX:r}=e;return this.searchNodes(o,n,r,s)}searchNodes(e,n,o=e,s=n){const r={id:"pointer",minX:e,minY:n,maxX:o,maxY:s},i=this.tree.search(r),a=[];for(const c of i){const h=this.nodeMap.get(c.id);h&&a.push(h)}return a}getParentNode(e){const n=this.nodeMap.get(e);return n||this.root}getNode(e){if(e===Sn||e==="")return this.root;const n=this.nodeMap.get(e);return n||null}addNode(e){this.nodeMap.set(e.id,e),this.addIndexNode(e.getRectNode())}removeNode(e){const n=this.getNode(e);if(!n){console.warn("警告:删除节点不存在:",e);return}this.nodeMap.delete(e),this.removeIndexNode(n.getRectNode()),n.type===v.Line&&this.linkMap.delete(n),this.deleteNodeFromParent(n)}deleteNodeFromParent(e){var o;const n=(o=e.parent)==null?void 0:o.id;if(n)if(n===this.root.id)this.root.children.delete(e);else{const s=this.nodeMap.get(n);s&&s.children.delete(e)}}removeIndexNode(e){this.tree.remove(e,(n,o)=>n.id===o.id)}addIndexNode(e){this.tree.insert(e)}getNodeBounds(){const e=[];for(const[n,o]of this.nodeMap)e.push(o.getRectNode());return S.getBounds(e,"all-node-bounds")}addLink(e,n,o=!0){const s=this.linkMap.get(e);if(s){o?s.startNode=n:s.endNode=n,this.checkLinkLine(e);return}const r={startNode:null,endNode:null};o?r.startNode=n:r.endNode=n,this.linkMap.set(e,r),this.checkLinkLine(e)}checkLinkLine(e){const n=this.linkMap.get(e);n&&n.endNode===null&&n.startNode===null&&this.linkMap.delete(e)}getNodeLinks(e){const n=new Set;if(e.type===v.Line)return n;for(const[o,s]of this.linkMap){if(!o.getProp(I.Connect))continue;const{startNode:i,endNode:a}=s;i===e&&n.add(o),a===e&&n.add(o)}return n}}const Zn=class Zn{constructor(){p(this,"previewGraphics",[]);p(this,"createWorker",new Qa);p(this,"layoutHandler",new Vt);p(this,"inQuickPreview",!1)}enterQuickPreview(t,e,n){if(this.inQuickPreview){this.previewGraphics.length>0&&n.addOrUpdate(k.PreviewGraphics,{previewNodes:this.previewGraphics});return}this.inQuickPreview=!0,this.resetPreviewNode(n);const o=this.createWorker.judgeQuickCreateMode(t,e,n);if(o){this.computeDrawLine(o,t,e,n);return}this.computeDrawLineAndNode(t,e,n)}computeDrawLine(t,e,n,o){const s=e.baseProps,r=e.toGlobal({x:n.x*s.width,y:n.y*s.height}),i=this.createWorker.computeEndNodeRelative(e,n),a=t.baseProps,c=t.toGlobal({x:i.x*a.width,y:i.y*a.height}),h={point:r,nodeConnect:{rect:D.rectNode2Rect(e.getBounds()),endType:S.computeNodeConnectEnd(n,e.baseProps.angle)}},d={point:c,nodeConnect:{rect:D.rectNode2Rect(t.getBounds()),endType:S.computeNodeConnectEnd(i,t.baseProps.angle)}},u=this.makeupLineProps(h,d),f=It.getInstance().create(Zn.PREVIEW_LINE_ID,v.Line,0,u,o.nodeManager.previewRoot,o.gmlRender.glCtx);this.previewGraphics.push(f)}computeDrawLineAndNode(t,e,n){const o=this.createWorker.computePreviewNodePos(t,e,n),s=this.makeupNodeProps(t,o),r=It.getInstance().create(Zn.PREVIEW_ID,v.Shape,0,s,n.nodeManager.previewRoot,n.gmlRender.glCtx);this.previewGraphics.push(r),this.computeDrawLine(r,t,e,n),n.addOrUpdate(k.PreviewGraphics,{previewNodes:this.previewGraphics})}exitQuickPreview(t){this.resetPreviewNode(t),this.inQuickPreview=!1}resetPreviewNode(t){this.previewGraphics=[],t.nodeManager.previewRoot.children.clear()}makeupNodeProps(t,e){const n=t.baseProps,o=t.shapeType,s=e.x,r=e.y,i=t.colorProps,a=t.borderProps,c=[{type:I.Base,x:s,y:r,width:n.width,height:n.height,angle:n.angle},tt.create({...i,alpha:.5}),Ae.create({...a,alpha:.5}),new Oe(o)];if(t.type===v.Shape&&t.shapeType===K.PureText){const h=t.textProps;c.push(h.clone());const d=t.paragraphProps;c.push(d.clone())}return c}makeupLineProps(t,e){const n=this.layoutHandler.layoutToPointsPro(t,e),o=D.rectNode2Rect(S.getBoundsByPoints(n));return[je.create(n),ie.create({x:o.x,y:o.y,width:o.width,height:o.height}),lt.create({rArrow:it.Arrow}),new Oe(he.RoundPolyLine),Ae.create({alpha:.5})]}};p(Zn,"PREVIEW_ID","quick_preview"),p(Zn,"PREVIEW_LINE_ID","quick_preview_line");let us=Zn;class Dn{computePreviewPos(t,e,n){var a;t.toolManager.shapeType;const o=t.toolManager.grab,s=((a=t.lastInteractiveEvent)==null?void 0:a.globalPoint)||new P,r=o?s.x-.5*e:s.x,i=o?s.y-.5*n:s.y;return new P(r,i)}}class my extends Dn{enable(t){return t===ye.SHAPE}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,100,100),s=e.createWorker.makeupPreviewProps(v.Shape,e,n,o);return It.getInstance().create(t,v.Shape,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class by extends Dn{enable(t){return t===ye.SECTION}async handle(t,e){const n=e.toolManager.shapeType,o=Uo[n],s=this.computePreviewPos(e,o.width,o.height),r=e.createWorker.makeupPreviewProps(v.Section,e,n,s);return It.getInstance().create(t,v.Section,0,r,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class el{async work(t,e,n,o){const s=n.getScale();try{const r=t.baseProps,i=s*r.width,a=s*r.height;let c;const h=o.getSVGBlobUrl(e,i,a);if(h)c=h.imageBitmap;else{const d=new Blob([e],{type:"image/svg+xml"}),u=URL.createObjectURL(d),f=new Image;f.width=2*i,f.height=2*a,await new Promise((b,w)=>{f.onload=b,f.onerror=w,f.src=u});const g=new OffscreenCanvas(2*i,2*a);g.getContext("2d").drawImage(f,0,0,2*i,2*a);const m=g.transferToImageBitmap();c=m,o.setSvgInfo(e,{imageBitmap:m},i,a),URL.revokeObjectURL(u)}t.setImageBitmap(c)}catch(r){console.error("加载svg图片出现问题",r),t.setBroken()}n.dirtyDraw(t.getBounds())}}class Sy extends Dn{constructor(){super(...arguments);p(this,"svgWorker",new cr)}enable(e){return e===ye.Resource}async handle(e,n){const o=new P(0,0),s=n.previewManager.previewResourceManager.previewSvgCode;s===""&&console.error("出现错误,svg code为空");const{addNodeInfo:r}=await this.svgWorker.addSvgNodeBySvgCode(s,o,n),i=It.getInstance().create(us.PREVIEW_ID,v.SVG,0,r.props,n.nodeManager.previewRoot,n.gmlRender.glCtx),a=yn.trimSvgCode(s);return i.setSvgCode(a.svgCode),await new el().work(i,a.svgCode,n.renderManager,n.resourceManager),i}makeupShapeDefaultProps(e,n,o){const s=Pe.Resource,r=an[s],i=100,a=100,c=o?n.x-.5*i:n.x,h=o?n.y-.5*a:n.y;return[ie.create({x:c,y:h,width:i,height:a}),Ae.create({color:r,alpha:.5})]}}class My extends Dn{enable(t,e){return t===ye.Widget&&e===Un.Checkbox}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,16,16),s=e.createWorker.makeupPreviewProps(v.Checkbox,e,n,o);return It.getInstance().create(t,v.Checkbox,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class vy extends Dn{enable(t,e){return t===ye.Widget&&e===Un.CheckboxText}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,102,32),s=e.createWorker.makeupPreviewProps(v.CheckboxText,e,n,o);return It.getInstance().create(t,v.CheckboxText,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}class ps{makeupLineDefaultProps(t,e){const s=e.x,r=e.y,i=S.computeShapeCategory(v.Line,t),a=an[i],c=this.makeupLinePoints(s,r,100,-100),h=D.rectNode2Rect(S.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(t),je.create(c),Ae.create({color:a,alpha:.5}),lt.create({rArrow:it.Arrow})]}}class Iy extends ps{makeupLineDefaultProps(t,e){const s=e.x,r=e.y,i=S.computeShapeCategory(v.Line,t),a=an[i],c=[{x:s,y:r},{x:s+100,y:r+-100}],h=D.rectNode2Rect(S.getBoundsByPoints(c));return[ie.create({x:h.x,y:h.y,width:h.width,height:h.height}),new Oe(t),je.create(c),Ae.create({color:a,alpha:.5}),lt.create({rArrow:it.Arrow})]}makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+n,y:e+o}]}}class Ty extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Ly extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Cy extends ps{makeupLinePoints(t,e,n,o){return[{x:t,y:e},{x:t+.5*n,y:e},{x:t+.5*n,y:e+o},{x:t+n,y:e+o}]}}class Ay extends Dn{constructor(){super(...arguments);p(this,"helpers",new Map([[he.Line,new Iy],[he.Curve,new Ty],[he.PolyLine,new Ly],[he.RoundPolyLine,new Cy]]))}enable(e){return e===ye.LINE}async handle(e,n){var a;const o=n.toolManager.shapeType,s=((a=n.lastInteractiveEvent)==null?void 0:a.globalPoint)||new P,r=this.makeupLineDefaultProps(o,s);return It.getInstance().create(e,v.Line,0,r,n.nodeManager.previewRoot,n.gmlRender.glCtx)}makeupLineDefaultProps(e,n){const o=this.helpers.get(e);return o?o.makeupLineDefaultProps(e,n):this.helpers.get(he.Line).makeupLineDefaultProps(e,n)}}class Ny extends Dn{enable(t,e){return t===ye.SlideContainer}async handle(t,e){const n=e.toolManager.shapeType,o=this.computePreviewPos(e,200,180),s=e.createWorker.makeupPreviewProps(v.SlideContainer,e,n,o);return It.getInstance().create(t,v.SlideContainer,0,s,e.nodeManager.previewRoot,e.gmlRender.glCtx)}}const ms=class ms{constructor(){p(this,"previewGraphics",null);p(this,"handlers",[new my,new by,new Sy,new Ay,new My,new vy,new Ny])}addPreviewNode(t){const e=t.toolManager.currentTool,n=t.toolManager.shapeType;for(const o of this.handlers)if(o.enable(e,n)){o.handle(ms.PREVIEW_ID,t).then(s=>{this.previewGraphics=s});return}}updatePos(t){if(!this.previewGraphics)return;if(this.previewGraphics.type===v.Line){const n=this.previewGraphics.pos,o={x:t.x-n.x,y:t.y-n.y},s=this.previewGraphics.points;for(const a of s)a.x+=o.x,a.y+=o.y;const r={type:I.Line,points:s},i={type:I.Base,x:t.x,y:t.y};this.previewGraphics.updateProps([i,r]);return}const e={type:I.Base,x:t.x,y:t.y};this.previewGraphics.updateProps([e])}resetPreviewNode(t){this.previewGraphics=null,t.nodeManager.previewRoot.children.clear()}};p(ms,"PREVIEW_ID","create_preview");let Sr=ms;class ky{constructor(){p(this,"previewSvgCode","");p(this,"previewSvgResourceUrl","")}setPreviewSvgCode(t){this.previewSvgCode=t}setPreviewResourceUrl(t){this.previewSvgResourceUrl=t}}class By{constructor(){p(this,"createManager",new Sr);p(this,"quickCreateManager",new us);p(this,"previewResourceManager",new ky)}addPreviewNode(t){this.createManager.addPreviewNode(t)}updatePos(t){this.createManager.updatePos(t)}resetPreviewNode(t){this.createManager.resetPreviewNode(t)}}class tl{}class nl extends tl{async downloadAsImageBitmap(t){const n=await(await fetch(t)).blob();return{imageBitmap:await createImageBitmap(n),blobUrl:t}}async uploadBlobImg(t,e){return Promise.resolve("")}async downloadSvgCode(t){return Promise.resolve("")}async uploadSvgFile(t,e){return Promise.resolve(void 0)}async deleteMultipleImages(t){return Promise.resolve(void 0)}async uploadSvgString(t,e){return Promise.resolve("")}async copyImage(t,e,n){throw new Error("该方法没有被实现")}}class ol{constructor(){p(this,"resourceMap",new Map);p(this,"nodeResourceMap",new Map);p(this,"svgMap",new Map);p(this,"svgBlobMap",new Map);p(this,"instance",new nl)}loadResourceInstance(t){this.instance=t}makeSvgBlobUrlKey(t,e,n){const o=Math.round(e/10),s=Math.round(n/10);return o+"-"+s+"-"+t}setSvgInfo(t,e,n,o){this.svgBlobMap.set(this.makeSvgBlobUrlKey(t,n,o),e)}getSVGBlobUrl(t,e,n){return this.svgBlobMap.get(this.makeSvgBlobUrlKey(t,e,n))}getBlobUrl(t){var e;return((e=this.resourceMap.get(t))==null?void 0:e.blobUrl)||""}getImgUrls(){return[...this.nodeResourceMap.values()].map(t=>t.blobUrl)}addNodeResourceInfo(t,e){this.nodeResourceMap.set(t,e)}async loadImgUrl(t){if(this.resourceMap.has(t))return this.resourceMap.get(t);const e=await this.instance.downloadAsImageBitmap(t);return this.resourceMap.set(t,e),e}async uploadFileBlob(t,e){return await this.instance.uploadBlobImg(t,e)}async loadSvgUrl(t){return await this.instance.downloadSvgCode(t)}async uploadSvgFile(t,e){return await this.instance.uploadSvgFile(t,e)}async uploadSvgString(t,e){const n=this.svgMap.get(e);if(n)return n;const o=await this.instance.uploadSvgString(t,e);return this.svgMap.set(e,o),o}async deleteMultipleImages(t){if(t.length!==0)return await this.instance.deleteMultipleImages(t)}async copyImage(t,e,n=fo.Resource){return await this.instance.copyImage(t,e,n)}}var Lo=(l=>(l[l.Img=0]="Img",l[l.Svg=1]="Svg",l))(Lo||{});class Ry{constructor(t,e,n){p(this,"tasks",[]);p(this,"resourceManager");p(this,"nodeManager");p(this,"renderManager");p(this,"tickerRun",async()=>{this.tasks.length>0&&await this.onTicker(),requestAnimationFrame(this.tickerRun)});p(this,"onTicker",async()=>{const t=this.tasks.pop();t&&(t.type===Lo.Svg&&await this.genSvgTexture(t),t.type===Lo.Img&&(await this.genImgTexture(t),this.renderManager.slotManager.addSlotState(ze.ImgUrls,this.resourceManager.getImgUrls())))});this.resourceManager=t,this.nodeManager=e,this.renderManager=n}batchAddRenderNode(t){t.forEach(e=>this.addRenderNode(e))}addRenderNode(t){if(t.type===v.IMG){const e=t;this.tasks.push({type:Lo.Img,nodeId:t.id,url:e.imgSrc})}if(t.type===v.SVG){const e=t;e.svgCode!==""&&this.tasks.push({type:Lo.Svg,nodeId:t.id,svgCode:e.svgCode})}}start(){this.tickerRun()}async genImgTexture(t){const{nodeId:e,url:n}=t,o=this.nodeManager.getNode(e);if(!o||o.type!==v.IMG)return;const s=o;try{const r=await this.resourceManager.loadImgUrl(n);s.setImageBitmap(r.imageBitmap),this.resourceManager.addNodeResourceInfo(s.id,r)}catch(r){console.error("加载图片出现问题",r),s.setBroken()}this.renderManager.dirtyDraw(o.getBounds())}async genSvgTexture(t){const{svgCode:e,nodeId:n}=t,o=this.nodeManager.getNode(n);if(!o||o.type!==v.SVG)return;const s=o;await new el().work(s,e,this.renderManager,this.resourceManager)}}class Ey{constructor(){p(this,"duringCrop",!1)}intoCrop(){this.duringCrop=!0}exitCrop(){this.duringCrop=!1}}class Hy{constructor(){p(this,"slideSet",new Set);p(this,"slideContainerSet",new Set);p(this,"appCtx");p(this,"tickerRun",()=>{for(const t of this.slideContainerSet)this.appCtx.slideManager.updateSlideContainerCover(this.appCtx);this.slideContainerSet.clear();for(const t of this.slideSet)this.appCtx.slideManager.updateSlideCover(t,this.appCtx);this.slideSet.clear(),requestAnimationFrame(this.tickerRun)})}init(t){this.appCtx=t}start(){this.tickerRun()}updateSlideCover(t){this.slideSet.add(t)}updateSlideContainerCover(t){this.slideContainerSet.add(t)}}const Nt=50,Co=40;class Dy{constructor(){p(this,"slidePlayWorker");p(this,"slideCoverManager");this.slidePlayWorker=new _c,this.slideCoverManager=new Hy}init(t){this.slideCoverManager.init(t)}start(){this.slideCoverManager.start()}enterEditing(t){const e=[...t.getSelectNodes()];if(e.length!==1)return;const n=e[0];n instanceof bo&&(t.execAction(new W),t.execAction(xe.create([])),t.execAction(new z),t.docModeManager.switchMode(ue.SLIDE_EDIT,t,{slideContainer:n}))}exitEditing(t){t.docState.docMode!==ue.BOARD&&t.docModeManager.switchMode(ue.BOARD,t,{slideContainer:t.docState.slideStatus.slideContainer||void 0})}jumpTo(t,e){if(t.docMode!==ue.SLIDE_EDIT||!t.slideStatus.slideContainer)return null;const n=t.slideStatus.slideContainer.slideProps.children,o=t.slideStatus.slideContainer.getTotalCount();return e<o&&e>-1?(t.slideStatus.currentIndex=e,this.getChildIdByIndex(n,e)):null}jumpToWhenEditing(t,e){const n=this.jumpTo(e.docState,t);n&&(e.focus(n,0,50),e.slotManager.addSlotState(ze.SlideIndex,{index:t}))}enterPlayBySlideContainer(t,e){t.execAction(new W),t.execAction(xe.create([])),t.execAction(new z),t.docState.changePermission({canEdit:!1}),t.docModeManager.switchMode(ue.SLIDE_PLAY,t,{slideContainer:e})}enterPlay(t){const e=[...t.getSelectNodes()];if(e.length!==1)return;const n=e[0];n instanceof bo&&this.enterPlayBySlideContainer(t,n)}playToNext(t){const e=this.slidePlayWorker.playToNext(t.docState);e&&t.focus(e)}playToPrev(t){const e=this.slidePlayWorker.playToPrev(t.docState);e&&t.focus(e)}insertSlide(t,e,n,o){var ne,ae;const s=t.slideProps.children,r=t.getTotalCount();if(e<0||e>=r)return null;const{rowIndex:i,colIndex:a}=this.getRowColByIndex(s,e);if(i===-1)return null;const c=s[i];if(!c||!c.ids||c.ids.length===0)return null;const h=n?a+1:a,d=c.ids[a],u=o.nodeManager.getNode(d);if(!u)return null;const f=u.baseProps,g=(ne=u.getProp(I.Color))==null?void 0:ne.color,y=(ae=u.getProp(I.Border))==null?void 0:ae.color,m=f.width,b=f.height;let w;if(h===0)w=Nt;else{const te=c.ids[h-1],ce=o.nodeManager.getNode(te);ce?w=ce.baseProps.x+ce.baseProps.width+Nt:w=u.baseProps.x+u.baseProps.width+Nt}const L=u.baseProps.y,B=[ie.create({x:w,y:L,width:m,height:b})];g!==void 0&&B.push(tt.create({color:g})),y!==void 0&&B.push(Ae.create({color:y}));const H=o.idGenerator.genId(v.Section),E={id:H,type:v.Section,zIndex:ve.genZIndex(t),parentId:t.id,props:B};o.execAction(Le.create(E));const X=s.map((te,ce)=>{if(ce===i){const pe=[...te.ids];return pe.splice(h,0,H),{ids:pe}}return{ids:[...te.ids]}}),$=[{id:t.id,props:[St.create({children:X})]}];if(h===0){let te=Nt;const ce=X[i];for(let pe=0;pe<ce.ids.length;pe++){const Be=ce.ids[pe],Re=o.nodeManager.getNode(Be);Re&&($.push({id:Be,props:[ie.create({x:te,y:L,width:Re.baseProps.width,height:Re.baseProps.height})]}),te+=Re.baseProps.width+Nt)}}else if(h<c.ids.length+1){let te=w+m+Nt;for(let ce=h;ce<c.ids.length;ce++){const pe=c.ids[ce],Be=o.nodeManager.getNode(pe);Be&&($.push({id:pe,props:[ie.create({x:te,y:Be.baseProps.y,width:Be.baseProps.width,height:Be.baseProps.height})]}),te+=Be.baseProps.width+Nt)}}o.execAction(new U({infos:$}));const Z=[];for(const te of X)for(const ce of te.ids){const pe=o.nodeManager.getNode(ce);pe&&Z.push(pe.baseProps)}if(Z.length>0){const te=S.getBoundsByBasePropsList(Z),ce=te.maxX-te.minX+2*Nt,pe=te.maxY-te.minY+2*Co;o.execAction(U.create(t.id,[{type:I.Base,width:ce,height:pe}]))}return o.nodeManager.getNode(H)}exitPlay(t){t.docState.docMode===ue.SLIDE_PLAY&&t.docModeManager.backToPrevMode(t,{slideContainer:t.docState.slideStatus.slideContainer||void 0})}refocusSlide(t,e=0){if(t.docState.docMode===ue.BOARD)return;const{currentIndex:o,slideContainer:s}=t.docState.slideStatus;if(!s)return;const r=s.getChildIdByIndex(o);r&&t.focus(r,0,e)}unGroupSlideContainerBySelective(t){const n=[...t.getSelectNodes()].filter(o=>o.type===v.SlideContainer);for(const o of n)this.unGroupSlideContainer(o,t)}unGroupSlideContainer(t,e){const n=t.globalBaseProps,o=n.x,s=n.y,r=Array.from(t.children);if(r.length===0)return;e.execAction(new W);const i=r.map(c=>{const h=c.baseProps,d=o+h.x,u=s+h.y;return{id:c.id,parentId:"",props:[ie.create({x:d,y:u,width:h.width,height:h.height,angle:h.angle})]}});i.length>0&&e.execAction(new U({infos:i})),e.execAction(At.create([t.id]));const a=r.map(c=>c.id);e.execAction(xe.create(a)),e.execAction(new z)}getChildIdByIndex(t,e){let n=0;for(let o=0;o<t.length;o++){if(e<n+t[o].ids.length){const s=e-n;return t[o].ids[s]}n+=t[o].ids.length}return null}getRowColByIndex(t,e){let n=0;for(let o=0;o<t.length;o++){if(e<n+t[o].ids.length){const s=e-n;return{rowIndex:o,colIndex:s}}n+=t[o].ids.length}return{rowIndex:-1,colIndex:-1}}updateSlideCover(t,e){S.getSlideInfo(t,e).then(n=>{const o=e.docState.slideStatus.slideCoverList.findIndex(s=>s.id===t.id);if(o>-1){const s=e.docState.slideStatus.slideCoverList[o];URL.revokeObjectURL(s.blobUrl),e.docState.slideStatus.slideCoverList.splice(o,1,n),e.slotManager.addSlotState(ze.SlideCovers,{covers:e.docState.slideStatus.slideCoverList})}else URL.revokeObjectURL(n.blobUrl)})}async updateSlideContainerCover(t){const e=t.docState.slideStatus.slideContainer;if(!e)return;const n=t.docState.slideStatus.slideCoverList,o=new Map;n.forEach(i=>o.set(i.id,i));const s=e.slideProps.children,r=[];for(const i of s)for(const a of i.ids){const c=o.get(a);if(c)r.push(c),o.delete(a);else{const h=t.nodeManager.getNode(a);if(h){const d=await S.getSlideInfo(h,t);r.push(d)}}}for(const i of o.values())URL.revokeObjectURL(i.blobUrl);t.docState.slideStatus.slideCoverList=r,t.slotManager.addSlotState(ze.SlideCovers,{covers:t.docState.slideStatus.slideCoverList})}updateSlideContainers(t,e,n){for(const o of t){const s=o.slideProps.children,r=[];for(const h of s){const d=h.ids.filter(u=>!e.has(u));d.length>0&&r.push({ids:d})}if(r.length===0){n.actionManager.execAction(U.create(o.id,[St.create({children:[]}),{type:I.Base,width:100+2*Nt,height:100+2*Co}]));continue}const i=[];let a=Co;for(let h=0;h<r.length;h++){const d=r[h];let u=Nt,f=0;for(const g of d.ids){const y=n.nodeManager.getNode(g);y&&(i.push({id:g,props:[ie.create({x:u,y:a,width:y.baseProps.width,height:y.baseProps.height})]}),u+=y.baseProps.width+Nt,f=Math.max(f,y.baseProps.height))}a+=f+Co}i.unshift({id:o.id,props:[St.create({children:r})]}),n.actionManager.execAction(new U({infos:i}));const c=[];for(const h of r)for(const d of h.ids){const u=n.nodeManager.getNode(d);u&&c.push(u.baseProps)}if(c.length>0){const h=S.getBoundsByBasePropsList(c),d=h.maxX-h.minX+2*Nt,u=h.maxY-h.minY+2*Co;n.actionManager.execAction(U.create(o.id,[{type:I.Base,width:d,height:u}]))}}}}class Mr{constructor(t){p(this,"inputManager");p(this,"cursorManager");p(this,"toolManager");p(this,"gmlRender");p(this,"auxGMLRender");p(this,"nodeManager");p(this,"serializeManager");p(this,"actionManager");p(this,"renderManager");p(this,"auxiliaryManager");p(this,"previewManager");p(this,"asyncRenderNodeManager");p(this,"docState");p(this,"idGenerator");p(this,"slotManager");p(this,"resourceManager");p(this,"cropManager");p(this,"slideManager");p(this,"appContext");p(this,"plugins",[]);p(this,"api");p(this,"aiAPI");this.docState=new Kc,this.idGenerator=new ve,this.gmlRender=new Pr,this.auxGMLRender=new Pr,this.cursorManager=new Oc,this.nodeManager=new Jc,this.slotManager=new ci,this.resourceManager=new ol,this.cropManager=new Ey,this.slideManager=new Dy,this.auxiliaryManager=new hi(this.auxGMLRender,this.slotManager,this.cropManager,this.docState),this.renderManager=new Dc(this.gmlRender,this.nodeManager,this.auxiliaryManager,this.slotManager),this.inputManager=new ly(this.renderManager,this.cursorManager),this.previewManager=new By,this.toolManager=new Wa(this.nodeManager,this.inputManager,this.slotManager,this.cursorManager),this.asyncRenderNodeManager=new Ry(this.resourceManager,this.nodeManager,this.renderManager),this.actionManager=new Ec(this.nodeManager,this.inputManager,this.gmlRender,this.auxiliaryManager,this.toolManager,this.renderManager,this.resourceManager,this.docState,this.idGenerator,this.slotManager,this.asyncRenderNodeManager,this.slideManager),this.serializeManager=new hy(this.nodeManager,this.docState),this.appContext=new Xc(this.nodeManager,this.gmlRender,t.detectors,this.toolManager,this.inputManager,this.actionManager,this.renderManager,this.auxiliaryManager,this.docState,this.idGenerator,this.cursorManager,this.previewManager,this.resourceManager,this.slotManager,this.asyncRenderNodeManager,this.cropManager,this.slideManager),this.api=new $c(this),this.aiAPI=new jc(this),this.slideManager.init(this.appContext),this.actionManager.executor.init(this.appContext),this.auxiliaryManager.selectManager.register(this.inputManager),this.appContext.refreshEvent=e=>{const n=this.getPlugin(Wo);n&&n.interactiveManager.refreshEvent(this.appContext,e)}}registerPlugin(t){this.plugins.push(t)}getPlugin(t){for(const e of this.plugins)if(e instanceof t)return e;return null}start(){this.slotManager.start(),this.auxiliaryManager.start(),this.renderManager.start(),this.asyncRenderNodeManager.start(),this.slideManager.start();for(const t of this.plugins)t.start()}stop(){for(const t of this.plugins)t.stop()}load(t){return this.loadDocumentInfo(t)}loadDocumentInfo(t){const e=dy();this.docState.load(e);try{const n=this.initData(t);this.afterInit(n),this.renderManager.zoomToFit(),this.renderManager.addContentRenderTask()}catch(n){console.error("初始化过程中出现错误;",n)}return this.docState.seq}initData(t){this.nodeManager.clear(),this.gmlRender.reset();const e=this.gmlRender.canvas.getContext("2d");let n=[];const o=S.correctZIndex(t.nodes);for(const s of o){const r=this.nodeManager.root;this.initNode(s,r,e,n)}return n=S.sortGraphics(n),n}initNode(t,e,n,o){this.idGenerator.loadNode(t);const s=It.getInstance().createByNodeInfo(t,e,n);this.nodeManager.addNode(s),o.push(s);const r=t.children??[],i=S.correctZIndex(r);for(const a of i)this.initNode(a,s,n,o);return s}async afterInit(t){for(const e of t){if(e instanceof Ct){const{start:n,end:o}=e.connectProps;if(n){const s=this.nodeManager.getNode(n.objectId)||null;this.nodeManager.addLink(e,s,!0)}if(o){const s=this.nodeManager.getNode(o.objectId)||null;this.nodeManager.addLink(e,s,!1)}}if(e instanceof ro&&this.asyncRenderNodeManager.addRenderNode(e),e instanceof Po)try{let n="";if(e.svgProps.useCode)n=yn.trimSvgCode(e.svgProps.code).svgCode;else{const s=e.svgUrl;n=await this.resourceManager.loadSvgUrl(s)}const o=yn.trimSvgCode(n);e.setSvgCode(o.svgCode),this.asyncRenderNodeManager.addRenderNode(e)}catch(n){console.error("加载svg图片出现问题",n),e.setBroken()}}}}const Oy={width:595,height:942};var vr={exports:{}},Ao={};/**
25
29
  * @license React
26
30
  * react-jsx-runtime.production.min.js
27
31
  *
@@ -29,7 +33,7 @@
29
33
  *
30
34
  * This source code is licensed under the MIT license found in the
31
35
  * LICENSE file in the root directory of this source tree.
32
- */var sl;function sg(){if(sl)return Ds;sl=1;var l=Kt,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(i,a,c){var h,d={},u=null,p=null;c!==void 0&&(u=""+c),a.key!==void 0&&(u=""+a.key),a.ref!==void 0&&(p=a.ref);for(h in a)n.call(a,h)&&!r.hasOwnProperty(h)&&(d[h]=a[h]);if(i&&i.defaultProps)for(h in a=i.defaultProps,a)d[h]===void 0&&(d[h]=a[h]);return{$$typeof:e,type:i,key:u,ref:p,props:d,_owner:s.current}}return Ds.Fragment=t,Ds.jsx=o,Ds.jsxs=o,Ds}var Hs={};/**
36
+ */var sl;function Xy(){if(sl)return Ao;sl=1;var l=st,t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function r(i,a,c){var h,d={},u=null,f=null;c!==void 0&&(u=""+c),a.key!==void 0&&(u=""+a.key),a.ref!==void 0&&(f=a.ref);for(h in a)n.call(a,h)&&!s.hasOwnProperty(h)&&(d[h]=a[h]);if(i&&i.defaultProps)for(h in a=i.defaultProps,a)d[h]===void 0&&(d[h]=a[h]);return{$$typeof:t,type:i,key:u,ref:f,props:d,_owner:o.current}}return Ao.Fragment=e,Ao.jsx=r,Ao.jsxs=r,Ao}var No={};/**
33
37
  * @license React
34
38
  * react-jsx-runtime.development.js
35
39
  *
@@ -37,18 +41,17 @@
37
41
  *
38
42
  * This source code is licensed under the MIT license found in the
39
43
  * LICENSE file in the root directory of this source tree.
40
- */var rl;function rg(){return rl||(rl=1,process.env.NODE_ENV!=="production"&&function(){var l=Kt,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),f=Symbol.iterator,y="@@iterator";function w(S){if(S===null||typeof S!="object")return null;var F=f&&S[f]||S[y];return typeof F=="function"?F:null}var b=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(S){{for(var F=arguments.length,$=new Array(F>1?F-1:0),dt=1;dt<F;dt++)$[dt-1]=arguments[dt];v("error",S,$)}}function v(S,F,$){{var dt=b.ReactDebugCurrentFrame,St=dt.getStackAddendum();St!==""&&(F+="%s",$=$.concat([St]));var Rt=$.map(function(bt){return String(bt)});Rt.unshift("Warning: "+F),Function.prototype.apply.call(console[S],console,Rt)}}var C=!1,E=!1,k=!1,I=!1,V=!1,U;U=Symbol.for("react.module.reference");function J(S){return!!(typeof S=="string"||typeof S=="function"||S===n||S===r||V||S===s||S===c||S===h||I||S===p||C||E||k||typeof S=="object"&&S!==null&&(S.$$typeof===u||S.$$typeof===d||S.$$typeof===o||S.$$typeof===i||S.$$typeof===a||S.$$typeof===U||S.getModuleId!==void 0))}function j(S,F,$){var dt=S.displayName;if(dt)return dt;var St=F.displayName||F.name||"";return St!==""?$+"("+St+")":$}function st(S){return S.displayName||"Context"}function tt(S){if(S==null)return null;if(typeof S.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof S=="function")return S.displayName||S.name||null;if(typeof S=="string")return S;switch(S){case n:return"Fragment";case t:return"Portal";case r:return"Profiler";case s:return"StrictMode";case c:return"Suspense";case h:return"SuspenseList"}if(typeof S=="object")switch(S.$$typeof){case i:var F=S;return st(F)+".Consumer";case o:var $=S;return st($._context)+".Provider";case a:return j(S,S.render,"ForwardRef");case d:var dt=S.displayName||null;return dt!==null?dt:tt(S.type)||"Memo";case u:{var St=S,Rt=St._payload,bt=St._init;try{return tt(bt(Rt))}catch{return null}}}return null}var it=Object.assign,ht=0,xt,mt,ut,ot,q,B,H;function z(){}z.__reactDisabledLog=!0;function X(){{if(ht===0){xt=console.log,mt=console.info,ut=console.warn,ot=console.error,q=console.group,B=console.groupCollapsed,H=console.groupEnd;var S={configurable:!0,enumerable:!0,value:z,writable:!0};Object.defineProperties(console,{info:S,log:S,warn:S,error:S,group:S,groupCollapsed:S,groupEnd:S})}ht++}}function Ft(){{if(ht--,ht===0){var S={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:it({},S,{value:xt}),info:it({},S,{value:mt}),warn:it({},S,{value:ut}),error:it({},S,{value:ot}),group:it({},S,{value:q}),groupCollapsed:it({},S,{value:B}),groupEnd:it({},S,{value:H})})}ht<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=b.ReactCurrentDispatcher,Se;function Me(S,F,$){{if(Se===void 0)try{throw Error()}catch(St){var dt=St.stack.trim().match(/\n( *(at )?)/);Se=dt&&dt[1]||""}return`
41
- `+Se+S}}var Te=!1,Ce;{var zn=typeof WeakMap=="function"?WeakMap:Map;Ce=new zn}function Bt(S,F){if(!S||Te)return"";{var $=Ce.get(S);if($!==void 0)return $}var dt;Te=!0;var St=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Rt;Rt=ye.current,ye.current=null,X();try{if(F){var bt=function(){throw Error()};if(Object.defineProperty(bt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(bt,[])}catch(me){dt=me}Reflect.construct(S,[],bt)}else{try{bt.call()}catch(me){dt=me}S.call(bt.prototype)}}else{try{throw Error()}catch(me){dt=me}S()}}catch(me){if(me&&dt&&typeof me.stack=="string"){for(var wt=me.stack.split(`
42
- `),pe=dt.stack.split(`
43
- `),Vt=wt.length-1,_t=pe.length-1;Vt>=1&&_t>=0&&wt[Vt]!==pe[_t];)_t--;for(;Vt>=1&&_t>=0;Vt--,_t--)if(wt[Vt]!==pe[_t]){if(Vt!==1||_t!==1)do if(Vt--,_t--,_t<0||wt[Vt]!==pe[_t]){var Ne=`
44
- `+wt[Vt].replace(" at new "," at ");return S.displayName&&Ne.includes("<anonymous>")&&(Ne=Ne.replace("<anonymous>",S.displayName)),typeof S=="function"&&Ce.set(S,Ne),Ne}while(Vt>=1&&_t>=0);break}}}finally{Te=!1,ye.current=Rt,Ft(),Error.prepareStackTrace=St}var us=S?S.displayName||S.name:"",Gn=us?Me(us):"";return typeof S=="function"&&Ce.set(S,Gn),Gn}function mn(S,F,$){return Bt(S,!1)}function Le(S){var F=S.prototype;return!!(F&&F.isReactComponent)}function Ae(S,F,$){if(S==null)return"";if(typeof S=="function")return Bt(S,Le(S));if(typeof S=="string")return Me(S);switch(S){case c:return Me("Suspense");case h:return Me("SuspenseList")}if(typeof S=="object")switch(S.$$typeof){case a:return mn(S.render);case d:return Ae(S.type,F,$);case u:{var dt=S,St=dt._payload,Rt=dt._init;try{return Ae(Rt(St),F,$)}catch{}}}return""}var Re=Object.prototype.hasOwnProperty,is={},tn=b.ReactDebugCurrentFrame;function ze(S){if(S){var F=S._owner,$=Ae(S.type,S._source,F?F.type:null);tn.setExtraStackFrame($)}else tn.setExtraStackFrame(null)}function wn(S,F,$,dt,St){{var Rt=Function.call.bind(Re);for(var bt in S)if(Rt(S,bt)){var wt=void 0;try{if(typeof S[bt]!="function"){var pe=Error((dt||"React class")+": "+$+" type `"+bt+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[bt]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw pe.name="Invariant Violation",pe}wt=S[bt](F,bt,dt,$,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Vt){wt=Vt}wt&&!(wt instanceof Error)&&(ze(St),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",dt||"React class",$,bt,typeof wt),ze(null)),wt instanceof Error&&!(wt.message in is)&&(is[wt.message]=!0,ze(St),x("Failed %s type: %s",$,wt.message),ze(null))}}}var en=Array.isArray;function Xe(S){return en(S)}function nn(S){{var F=typeof Symbol=="function"&&Symbol.toStringTag,$=F&&S[Symbol.toStringTag]||S.constructor.name||"Object";return $}}function ce(S){try{return as(S),!1}catch{return!0}}function as(S){return""+S}function cs(S){if(ce(S))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",nn(S)),as(S)}var ls=b.ReactCurrentOwner,Xs={key:!0,ref:!0,__self:!0,__source:!0},Xn,Yn;function hs(S){if(Re.call(S,"ref")){var F=Object.getOwnPropertyDescriptor(S,"ref").get;if(F&&F.isReactWarning)return!1}return S.ref!==void 0}function ds(S){if(Re.call(S,"key")){var F=Object.getOwnPropertyDescriptor(S,"key").get;if(F&&F.isReactWarning)return!1}return S.key!==void 0}function Ir(S,F){typeof S.ref=="string"&&ls.current}function kr(S,F){{var $=function(){Xn||(Xn=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};$.isReactWarning=!0,Object.defineProperty(S,"key",{get:$,configurable:!0})}}function Ys(S,F){{var $=function(){Yn||(Yn=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};$.isReactWarning=!0,Object.defineProperty(S,"ref",{get:$,configurable:!0})}}var Fs=function(S,F,$,dt,St,Rt,bt){var wt={$$typeof:e,type:S,key:F,ref:$,props:bt,_owner:Rt};return wt._store={},Object.defineProperty(wt._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(wt,"_self",{configurable:!1,enumerable:!1,writable:!1,value:dt}),Object.defineProperty(wt,"_source",{configurable:!1,enumerable:!1,writable:!1,value:St}),Object.freeze&&(Object.freeze(wt.props),Object.freeze(wt)),wt};function Vs(S,F,$,dt,St){{var Rt,bt={},wt=null,pe=null;$!==void 0&&(cs($),wt=""+$),ds(F)&&(cs(F.key),wt=""+F.key),hs(F)&&(pe=F.ref,Ir(F,St));for(Rt in F)Re.call(F,Rt)&&!Xs.hasOwnProperty(Rt)&&(bt[Rt]=F[Rt]);if(S&&S.defaultProps){var Vt=S.defaultProps;for(Rt in Vt)bt[Rt]===void 0&&(bt[Rt]=Vt[Rt])}if(wt||pe){var _t=typeof S=="function"?S.displayName||S.name||"Unknown":S;wt&&kr(bt,_t),pe&&Ys(bt,_t)}return Fs(S,wt,pe,St,dt,ls.current,bt)}}var Fn=b.ReactCurrentOwner,Vn=b.ReactDebugCurrentFrame;function Ye(S){if(S){var F=S._owner,$=Ae(S.type,S._source,F?F.type:null);Vn.setExtraStackFrame($)}else Vn.setExtraStackFrame(null)}var Wn;Wn=!1;function Zt(S){return typeof S=="object"&&S!==null&&S.$$typeof===e}function Sl(){{if(Fn.current){var S=tt(Fn.current.type);if(S)return`
44
+ */var rl;function zy(){return rl||(rl=1,process.env.NODE_ENV!=="production"&&function(){var l=st,t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),g=Symbol.iterator,y="@@iterator";function m(N){if(N===null||typeof N!="object")return null;var Q=g&&N[g]||N[y];return typeof Q=="function"?Q:null}var b=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(N){{for(var Q=arguments.length,oe=new Array(Q>1?Q-1:0),we=1;we<Q;we++)oe[we-1]=arguments[we];L("error",N,oe)}}function L(N,Q,oe){{var we=b.ReactDebugCurrentFrame,De=we.getStackAddendum();De!==""&&(Q+="%s",oe=oe.concat([De]));var Ye=oe.map(function(ke){return String(ke)});Ye.unshift("Warning: "+Q),Function.prototype.apply.call(console[N],console,Ye)}}var B=!1,H=!1,E=!1,X=!1,$=!1,Z;Z=Symbol.for("react.module.reference");function se(N){return!!(typeof N=="string"||typeof N=="function"||N===n||N===s||$||N===o||N===c||N===h||X||N===f||B||H||E||typeof N=="object"&&N!==null&&(N.$$typeof===u||N.$$typeof===d||N.$$typeof===r||N.$$typeof===i||N.$$typeof===a||N.$$typeof===Z||N.getModuleId!==void 0))}function ne(N,Q,oe){var we=N.displayName;if(we)return we;var De=Q.displayName||Q.name||"";return De!==""?oe+"("+De+")":oe}function ae(N){return N.displayName||"Context"}function te(N){if(N==null)return null;if(typeof N.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof N=="function")return N.displayName||N.name||null;if(typeof N=="string")return N;switch(N){case n:return"Fragment";case e:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case h:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case i:var Q=N;return ae(Q)+".Consumer";case r:var oe=N;return ae(oe._context)+".Provider";case a:return ne(N,N.render,"ForwardRef");case d:var we=N.displayName||null;return we!==null?we:te(N.type)||"Memo";case u:{var De=N,Ye=De._payload,ke=De._init;try{return te(ke(Ye))}catch{return null}}}return null}var ce=Object.assign,pe=0,Be,Re,Se,Te,fe,O,G;function j(){}j.__reactDisabledLog=!0;function _(){{if(pe===0){Be=console.log,Re=console.info,Se=console.warn,Te=console.error,fe=console.group,O=console.groupCollapsed,G=console.groupEnd;var N={configurable:!0,enumerable:!0,value:j,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}pe++}}function Ve(){{if(pe--,pe===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:ce({},N,{value:Be}),info:ce({},N,{value:Re}),warn:ce({},N,{value:Se}),error:ce({},N,{value:Te}),group:ce({},N,{value:fe}),groupCollapsed:ce({},N,{value:O}),groupEnd:ce({},N,{value:G})})}pe<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ut=b.ReactCurrentDispatcher,yt;function kt(N,Q,oe){{if(yt===void 0)try{throw Error()}catch(De){var we=De.stack.trim().match(/\n( *(at )?)/);yt=we&&we[1]||""}return`
45
+ `+yt+N}}var Ft=!1,cn;{var On=typeof WeakMap=="function"?WeakMap:Map;cn=new On}function $e(N,Q){if(!N||Ft)return"";{var oe=cn.get(N);if(oe!==void 0)return oe}var we;Ft=!0;var De=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ye;Ye=ut.current,ut.current=null,_();try{if(Q){var ke=function(){throw Error()};if(Object.defineProperty(ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ke,[])}catch(Tt){we=Tt}Reflect.construct(N,[],ke)}else{try{ke.call()}catch(Tt){we=Tt}N.call(ke.prototype)}}else{try{throw Error()}catch(Tt){we=Tt}N()}}catch(Tt){if(Tt&&we&&typeof Tt.stack=="string"){for(var Ce=Tt.stack.split(`
46
+ `),mt=we.stack.split(`
47
+ `),Je=Ce.length-1,ot=mt.length-1;Je>=1&&ot>=0&&Ce[Je]!==mt[ot];)ot--;for(;Je>=1&&ot>=0;Je--,ot--)if(Ce[Je]!==mt[ot]){if(Je!==1||ot!==1)do if(Je--,ot--,ot<0||Ce[Je]!==mt[ot]){var Bt=`
48
+ `+Ce[Je].replace(" at new "," at ");return N.displayName&&Bt.includes("<anonymous>")&&(Bt=Bt.replace("<anonymous>",N.displayName)),typeof N=="function"&&cn.set(N,Bt),Bt}while(Je>=1&&ot>=0);break}}}finally{Ft=!1,ut.current=Ye,Ve(),Error.prepareStackTrace=De}var no=N?N.displayName||N.name:"",Xn=no?kt(no):"";return typeof N=="function"&&cn.set(N,Xn),Xn}function qn(N,Q,oe){return $e(N,!1)}function Jn(N){var Q=N.prototype;return!!(Q&&Q.isReactComponent)}function Pn(N,Q,oe){if(N==null)return"";if(typeof N=="function")return $e(N,Jn(N));if(typeof N=="string")return kt(N);switch(N){case c:return kt("Suspense");case h:return kt("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case a:return qn(N.render);case d:return Pn(N.type,Q,oe);case u:{var we=N,De=we._payload,Ye=we._init;try{return Pn(Ye(De),Q,oe)}catch{}}}return""}var Yt=Object.prototype.hasOwnProperty,kr={},eo=b.ReactDebugCurrentFrame;function mn(N){if(N){var Q=N._owner,oe=Pn(N.type,N._source,Q?Q.type:null);eo.setExtraStackFrame(oe)}else eo.setExtraStackFrame(null)}function Sx(N,Q,oe,we,De){{var Ye=Function.call.bind(Yt);for(var ke in N)if(Ye(N,ke)){var Ce=void 0;try{if(typeof N[ke]!="function"){var mt=Error((we||"React class")+": "+oe+" type `"+ke+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[ke]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw mt.name="Invariant Violation",mt}Ce=N[ke](Q,ke,we,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Je){Ce=Je}Ce&&!(Ce instanceof Error)&&(mn(De),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",we||"React class",oe,ke,typeof Ce),mn(null)),Ce instanceof Error&&!(Ce.message in kr)&&(kr[Ce.message]=!0,mn(De),w("Failed %s type: %s",oe,Ce.message),mn(null))}}}var Mx=Array.isArray;function Br(N){return Mx(N)}function vx(N){{var Q=typeof Symbol=="function"&&Symbol.toStringTag,oe=Q&&N[Symbol.toStringTag]||N.constructor.name||"Object";return oe}}function Ix(N){try{return Tl(N),!1}catch{return!0}}function Tl(N){return""+N}function Ll(N){if(Ix(N))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",vx(N)),Tl(N)}var Cl=b.ReactCurrentOwner,Tx={key:!0,ref:!0,__self:!0,__source:!0},Al,Nl;function Lx(N){if(Yt.call(N,"ref")){var Q=Object.getOwnPropertyDescriptor(N,"ref").get;if(Q&&Q.isReactWarning)return!1}return N.ref!==void 0}function Cx(N){if(Yt.call(N,"key")){var Q=Object.getOwnPropertyDescriptor(N,"key").get;if(Q&&Q.isReactWarning)return!1}return N.key!==void 0}function Ax(N,Q){typeof N.ref=="string"&&Cl.current}function Nx(N,Q){{var oe=function(){Al||(Al=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};oe.isReactWarning=!0,Object.defineProperty(N,"key",{get:oe,configurable:!0})}}function kx(N,Q){{var oe=function(){Nl||(Nl=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};oe.isReactWarning=!0,Object.defineProperty(N,"ref",{get:oe,configurable:!0})}}var Bx=function(N,Q,oe,we,De,Ye,ke){var Ce={$$typeof:t,type:N,key:Q,ref:oe,props:ke,_owner:Ye};return Ce._store={},Object.defineProperty(Ce._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ce,"_self",{configurable:!1,enumerable:!1,writable:!1,value:we}),Object.defineProperty(Ce,"_source",{configurable:!1,enumerable:!1,writable:!1,value:De}),Object.freeze&&(Object.freeze(Ce.props),Object.freeze(Ce)),Ce};function Rx(N,Q,oe,we,De){{var Ye,ke={},Ce=null,mt=null;oe!==void 0&&(Ll(oe),Ce=""+oe),Cx(Q)&&(Ll(Q.key),Ce=""+Q.key),Lx(Q)&&(mt=Q.ref,Ax(Q,De));for(Ye in Q)Yt.call(Q,Ye)&&!Tx.hasOwnProperty(Ye)&&(ke[Ye]=Q[Ye]);if(N&&N.defaultProps){var Je=N.defaultProps;for(Ye in Je)ke[Ye]===void 0&&(ke[Ye]=Je[Ye])}if(Ce||mt){var ot=typeof N=="function"?N.displayName||N.name||"Unknown":N;Ce&&Nx(ke,ot),mt&&kx(ke,ot)}return Bx(N,Ce,mt,De,we,Cl.current,ke)}}var Rr=b.ReactCurrentOwner,kl=b.ReactDebugCurrentFrame;function to(N){if(N){var Q=N._owner,oe=Pn(N.type,N._source,Q?Q.type:null);kl.setExtraStackFrame(oe)}else kl.setExtraStackFrame(null)}var Er;Er=!1;function Hr(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function Bl(){{if(Rr.current){var N=te(Rr.current.type);if(N)return`
45
49
 
46
- Check the render method of \``+S+"`."}return""}}function kg(S){return""}var Tl={};function Bg(S){{var F=Sl();if(!F){var $=typeof S=="string"?S:S.displayName||S.name;$&&(F=`
50
+ Check the render method of \``+N+"`."}return""}}function Ex(N){return""}var Rl={};function Hx(N){{var Q=Bl();if(!Q){var oe=typeof N=="string"?N:N.displayName||N.name;oe&&(Q=`
47
51
 
48
- Check the top-level render call using <`+$+">.")}return F}}function Cl(S,F){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var $=Bg(F);if(Tl[$])return;Tl[$]=!0;var dt="";S&&S._owner&&S._owner!==Fn.current&&(dt=" It was passed a child from "+tt(S._owner.type)+"."),Ye(S),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',$,dt),Ye(null)}}function Ll(S,F){{if(typeof S!="object")return;if(Xe(S))for(var $=0;$<S.length;$++){var dt=S[$];Zt(dt)&&Cl(dt,F)}else if(Zt(S))S._store&&(S._store.validated=!0);else if(S){var St=w(S);if(typeof St=="function"&&St!==S.entries)for(var Rt=St.call(S),bt;!(bt=Rt.next()).done;)Zt(bt.value)&&Cl(bt.value,F)}}}function Og(S){{var F=S.type;if(F==null||typeof F=="string")return;var $;if(typeof F=="function")$=F.propTypes;else if(typeof F=="object"&&(F.$$typeof===a||F.$$typeof===d))$=F.propTypes;else return;if($){var dt=tt(F);wn($,S.props,"prop",dt,S)}else if(F.PropTypes!==void 0&&!Wn){Wn=!0;var St=tt(F);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",St||"Unknown")}typeof F.getDefaultProps=="function"&&!F.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Dg(S){{for(var F=Object.keys(S.props),$=0;$<F.length;$++){var dt=F[$];if(dt!=="children"&&dt!=="key"){Ye(S),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",dt),Ye(null);break}}S.ref!==null&&(Ye(S),x("Invalid attribute `ref` supplied to `React.Fragment`."),Ye(null))}}var Al={};function Rl(S,F,$,dt,St,Rt){{var bt=J(S);if(!bt){var wt="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(wt+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var pe=kg();pe?wt+=pe:wt+=Sl();var Vt;S===null?Vt="null":Xe(S)?Vt="array":S!==void 0&&S.$$typeof===e?(Vt="<"+(tt(S.type)||"Unknown")+" />",wt=" Did you accidentally export a JSX literal instead of a component?"):Vt=typeof S,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Vt,wt)}var _t=Vs(S,F,$,St,Rt);if(_t==null)return _t;if(bt){var Ne=F.children;if(Ne!==void 0)if(dt)if(Xe(Ne)){for(var us=0;us<Ne.length;us++)Ll(Ne[us],S);Object.freeze&&Object.freeze(Ne)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ll(Ne,S)}if(Re.call(F,"key")){var Gn=tt(S),me=Object.keys(F).filter(function(Vg){return Vg!=="key"}),jo=me.length>0?"{key: someKey, "+me.join(": ..., ")+": ...}":"{key: someKey}";if(!Al[Gn+jo]){var Fg=me.length>0?"{"+me.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
52
+ Check the top-level render call using <`+oe+">.")}return Q}}function El(N,Q){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var oe=Hx(Q);if(Rl[oe])return;Rl[oe]=!0;var we="";N&&N._owner&&N._owner!==Rr.current&&(we=" It was passed a child from "+te(N._owner.type)+"."),to(N),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',oe,we),to(null)}}function Hl(N,Q){{if(typeof N!="object")return;if(Br(N))for(var oe=0;oe<N.length;oe++){var we=N[oe];Hr(we)&&El(we,Q)}else if(Hr(N))N._store&&(N._store.validated=!0);else if(N){var De=m(N);if(typeof De=="function"&&De!==N.entries)for(var Ye=De.call(N),ke;!(ke=Ye.next()).done;)Hr(ke.value)&&El(ke.value,Q)}}}function Dx(N){{var Q=N.type;if(Q==null||typeof Q=="string")return;var oe;if(typeof Q=="function")oe=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===a||Q.$$typeof===d))oe=Q.propTypes;else return;if(oe){var we=te(Q);Sx(oe,N.props,"prop",we,N)}else if(Q.PropTypes!==void 0&&!Er){Er=!0;var De=te(Q);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",De||"Unknown")}typeof Q.getDefaultProps=="function"&&!Q.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ox(N){{for(var Q=Object.keys(N.props),oe=0;oe<Q.length;oe++){var we=Q[oe];if(we!=="children"&&we!=="key"){to(N),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",we),to(null);break}}N.ref!==null&&(to(N),w("Invalid attribute `ref` supplied to `React.Fragment`."),to(null))}}var Dl={};function Ol(N,Q,oe,we,De,Ye){{var ke=se(N);if(!ke){var Ce="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Ce+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var mt=Ex();mt?Ce+=mt:Ce+=Bl();var Je;N===null?Je="null":Br(N)?Je="array":N!==void 0&&N.$$typeof===t?(Je="<"+(te(N.type)||"Unknown")+" />",Ce=" Did you accidentally export a JSX literal instead of a component?"):Je=typeof N,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Je,Ce)}var ot=Rx(N,Q,oe,De,Ye);if(ot==null)return ot;if(ke){var Bt=Q.children;if(Bt!==void 0)if(we)if(Br(Bt)){for(var no=0;no<Bt.length;no++)Hl(Bt[no],N);Object.freeze&&Object.freeze(Bt)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Hl(Bt,N)}if(Yt.call(Q,"key")){var Xn=te(N),Tt=Object.keys(Q).filter(function(Gx){return Gx!=="key"}),Dr=Tt.length>0?"{key: someKey, "+Tt.join(": ..., ")+": ...}":"{key: someKey}";if(!Dl[Xn+Dr]){var Yx=Tt.length>0?"{"+Tt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
49
53
  let props = %s;
50
54
  <%s {...props} />
51
55
  React keys must be passed directly to JSX without using spread:
52
56
  let props = %s;
53
- <%s key={someKey} {...props} />`,jo,Gn,Fg,Gn),Al[Gn+jo]=!0}}return S===n?Dg(_t):Og(_t),_t}}function Hg(S,F,$){return Rl(S,F,$,!0)}function zg(S,F,$){return Rl(S,F,$,!1)}var Xg=zg,Yg=Hg;Hs.Fragment=n,Hs.jsx=Xg,Hs.jsxs=Yg}()),Hs}process.env.NODE_ENV==="production"?Fo.exports=sg():Fo.exports=rg();var He=Fo.exports;const Vo=({gmlRender:l})=>{const e=Kt.useRef(null),t=()=>{const n=window.devicePixelRatio;e.current.width=n*e.current.clientWidth,e.current.height=n*e.current.clientHeight};return Kt.useEffect(()=>(t(),l.init(e.current),window.addEventListener("resize",t,!1),()=>{window.removeEventListener("resize",t,!1)}),[e]),He.jsx("div",{className:"normal-container",children:He.jsx("canvas",{ref:e,className:"normal-canvas"})})},og=({gmlRender:l,auxiliaryGmlRender:e})=>He.jsxs("div",{className:"canvas-container",children:[He.jsx("div",{className:"auxiliary-canvas",children:He.jsx(Vo,{gmlRender:e})}),He.jsx("div",{className:"content-canvas",children:He.jsx(Vo,{gmlRender:l})})]}),ig=({inputManager:l})=>{const e=Kt.useRef(null),t=Kt.useRef(null);return Kt.useEffect(()=>{e.current&&l.init(e.current,t.current)},[e]),He.jsxs(He.Fragment,{children:[He.jsx("div",{ref:t,className:"render-input"}),He.jsx("input",{ref:e,className:"canvas-input"})]})};class Lr{constructor(){g(this,"editTextWorker",new qn);g(this,"selectionDeleteWorker",new ur)}computeNextCursorIndex(e,t){return e+t.length}handle(e,t,n,s){const{node:r,renderText:o,textCursorPosition:i}=e;t.execAction(new nt);const a=t.inputManager.selectionManager.selectionInfo;if(a){this.selectionDeleteWorker.work(e,a,t);const{renderText:p,textCursorPosition:f}=t.inputManager.editTextInfo,{prev:y,next:w,index:b}=this.editTextWorker.splitText(p,f);s.prev=y,s.next=w,s.splitIndex=b}else t.execAction(lt.focus(r.id,i));const{updateTextProps:c,index:h}=this.computeUpdateTextProps(e,n,s);t.execAction(ct.create(r.id,[c])),this.editTextWorker.modifyBaseProps(o,r,t);const d=this.computeNextCursorIndex(h,n),u=this.editTextWorker.getTextCursorPosByIndex(o,d);t.execAction(lt.focus(r.id,u)),t.execAction(new et)}}class ol extends Lr{computeUpdateTextProps(e,t){const{renderText:n,textCursorPosition:s}=e,{prev:r,next:o,index:i}=this.editTextWorker.splitText(n,s);return{updateTextProps:{type:R.Text,text:r+t+o},index:i}}}class il extends Lr{computeUpdateTextProps(e,t,n){const{prev:s,next:r,splitIndex:o}=n;return{updateTextProps:{type:R.Text,text:s+t+r},index:o}}}class al extends Lr{constructor(){super(...arguments);g(this,"graphemeSplit",new wo)}computeUpdateTextProps(t,n,s){const{prev:r,next:o,splitIndex:i}=s;return{updateTextProps:{type:R.Text,text:r+n+o},index:i}}computeNextCursorIndex(t,n){const s=this.graphemeSplit.split(n).length;return t+s}}class cl{constructor(e){g(this,"eventCtx");g(this,"duringComposition",!1);g(this,"compositionRecord",{prev:"",next:"",splitIndex:0});g(this,"editTextWorker",new qn);g(this,"normalInputHandler",new ol);g(this,"compositionInputHandler",new il);g(this,"compositionEndHandler",new al);g(this,"compositionEnd",e=>{if(!this.onEnable()||!this.duringComposition)return;const t=this.eventCtx.inputManager.editTextInfo;if(!t)return;const n=e.data;this.compositionEndHandler.handle(t,this.eventCtx,n,this.compositionRecord),this.duringComposition=!1});g(this,"compositionStart",e=>{if(!this.onEnable())return;const t=this.eventCtx.inputManager.editTextInfo;if(!t)return;this.duringComposition=!0;const{renderText:n,textCursorPosition:s}=t,{prev:r,next:o,index:i}=this.editTextWorker.splitText(n,s);this.compositionRecord={prev:r,next:o,splitIndex:i}});g(this,"onKeyDown",e=>{if(!this.onEnable()||!e.data)return;const t=e.data;if(t==="")return;const n=this.eventCtx.inputManager.editTextInfo;if(n){if(this.duringComposition){this.compositionInputHandler.handle(n,this.eventCtx,t,this.compositionRecord);return}this.normalInputHandler.handle(n,this.eventCtx,t,this.compositionRecord)}});this.eventCtx=e}onEnable(){return this.eventCtx.docState.canEdit()}start(){var t;const e=(t=this.eventCtx.inputManager.renderInput)==null?void 0:t.inputDom;if(!e){console.error("input dom is not exist");return}e.addEventListener("input",this.onKeyDown),e.addEventListener("compositionstart",this.compositionStart),e.addEventListener("compositionend",this.compositionEnd)}stop(){var t;const e=(t=this.eventCtx.inputManager.renderInput)==null?void 0:t.inputDom;if(!e){console.error("input dom is not exist");return}e.removeEventListener("input",this.onKeyDown),e.removeEventListener("compositionstart",this.compositionStart),e.removeEventListener("compositionend",this.compositionEnd)}}class Wo{constructor(e){g(this,"eventCtx");g(this,"timer");g(this,"onWheel",e=>{if(!this.onEnable(e))return;const t=this.eventCtx;if(e.target===t.gmlRender.canvas&&e.preventDefault(),e.ctrlKey){const n=new m(e.clientX,e.clientY),s=t.gmlRender.transformToGlobal(n),r=e.deltaY,o=2*Math.abs(r)/100,i=r>0?1-o:1+o;this.eventCtx.renderManager.zoomScale(i,s,this.eventCtx.asyncRenderNodeManager)}else this.eventCtx.renderManager.scroll(e.deltaX,e.deltaY);this.eventCtx.inputManager.refreshCursor(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.generateImgAndDraw()},300)});this.eventCtx=e}start(){document.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){document.removeEventListener("wheel",this.onWheel)}generateImgAndDraw(){}onEnable(e){return!0}}class ag{static scroll(e,t,n){const s=n.getScale();n.translation(-e/s,-t/s);const r=n.glCtx,{a:o,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;r.setTransform(o,i,a,c,h,d)}static zoomScale(e,t,n){const s=2*Math.abs(e)/100,r=e>0?1-s:1+s;t.scale(r,r,n);const o=t.glCtx,{a:i,b:a,c,d:h,e:d,f:u}=t.globalTransform;o.setTransform(i,a,c,h,d,u)}static zoomRedraw(e,t,n){const s=e.canvas.getContext("2d"),{a:r,b:o,c:i,d:a,e:c,f:h}=e.globalTransform;s.setTransform(r,o,i,a,c,h),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}static zoomToFit(e,t,n,s){const r=e.canvas.getContext("2d"),{a:o,b:i,c:a,d:c,e:h,f:d}=s;e.globalTransform.a=o,e.globalTransform.b=i,e.globalTransform.c=a,e.globalTransform.d=c,e.globalTransform.e=h,e.globalTransform.f=d,r.setTransform(o,i,a,c,h,d),n.renderManager.addContentRenderTask()}}class Go{constructor(e){g(this,"eventCtx");g(this,"prevDevicePixelRatio",window.devicePixelRatio);g(this,"onResize",()=>{const e=window.devicePixelRatio;this.resizeCanvas(this.eventCtx.gmlRender,e),this.resizeCanvas(this.eventCtx.auxiliaryManager.gmlRender,e),this.eventCtx.renderManager.addAuxiliaryDrawTask(),this.eventCtx.renderManager.addContentRenderTask(),this.prevDevicePixelRatio=e});this.eventCtx=e}start(){window.addEventListener("resize",this.onResize)}stop(){window.removeEventListener("resize",this.onResize)}resizeCanvas(e,t){e.canvas.width=t*e.canvas.clientWidth,e.canvas.height=t*e.canvas.clientHeight;const n=e.glCtx;if(Math.abs(this.prevDevicePixelRatio-t)>.001){const h=e.transformToGlobal(new m);e.scale(t/this.prevDevicePixelRatio,t/this.prevDevicePixelRatio,h)}const{a:s,b:r,c:o,d:i,e:a,f:c}=e.globalTransform;n.setTransform(s,r,o,i,a,c)}onEnable(e){return!0}}var gn=(l=>(l.Windows="Windows",l.MacOS="MacOS",l.Linux="Linux",l.Android="Android",l.IOS="ios",l.Unknown="unknown",l))(gn||{});class cg{static getOS(){const e=navigator.userAgent;return e.includes("Win")?gn.Windows:e.includes("Mac")?gn.MacOS:e.includes("Linux")?gn.Linux:/Android/.test(e)?gn.Android:/iPhone|iPad|iPod/.test(e)?gn.IOS:gn.Unknown}}class Uo{constructor(e){g(this,"keyMap",new Map);this.keyMap=e}getKey(e){const t=this.keyMap.get(e.code);if(!t)return null;const s=cg.getOS()===gn.MacOS;for(const r of t)if(r.enable(e,s))return r;return null}}class vt{keyDown(e,t){this.work(e,t)}keyUp(e,t){}shouldPreventDefault(){return!0}isPressMetaKey(e,t){return t?e.metaKey:e.ctrlKey}}var Q=(l=>(l.Enter="Enter",l.Escape="Escape",l.Backspace="Backspace",l.Delete="Delete",l.Space="Space",l.ArrowLeft="ArrowLeft",l.ArrowRight="ArrowRight",l.ArrowUp="ArrowUp",l.ArrowDown="ArrowDown",l.Digit1="Digit1",l.Digit2="Digit2",l.Digit3="Digit3",l.Digit4="Digit4",l.Digit5="Digit5",l.Digit6="Digit6",l.Digit7="Digit7",l.Digit8="Digit8",l.Digit9="Digit9",l.Digit0="Digit0",l.KeyA="KeyA",l.KeyB="KeyB",l.KeyC="KeyC",l.KeyD="KeyD",l.KeyE="KeyE",l.KeyF="KeyF",l.KeyG="KeyG",l.KeyH="KeyH",l.KeyI="KeyI",l.KeyJ="KeyJ",l.KeyK="KeyK",l.KeyL="KeyL",l.KeyM="KeyM",l.KeyN="KeyN",l.KeyO="KeyO",l.KeyP="KeyP",l.KeyQ="KeyQ",l.KeyR="KeyR",l.KeyS="KeyS",l.KeyT="KeyT",l.KeyU="KeyU",l.KeyV="KeyV",l.KeyW="KeyW",l.KeyX="KeyX",l.KeyY="KeyY",l.KeyZ="KeyZ",l.Tab="Tab",l.BracketRight="BracketRight",l.BracketLeft="BracketLeft",l))(Q||{});class ll extends vt{constructor(){super(...arguments);g(this,"type",Q.Enter);g(this,"editTextWorker",new qn);g(this,"selectionDeleteWorker",new ur)}enable(t){return!0}work(t,n){const s=n.inputManager.editTextInfo;if(!s)return;const{node:r,renderText:o}=s;let i=s.textCursorPosition;const a=n.inputManager.selectionManager.selectionInfo;n.execAction(new nt),a?(this.selectionDeleteWorker.work(s,a,n),i=n.inputManager.editTextInfo.textCursorPosition):n.execAction(lt.focus(r.id,i));const{prev:c,next:h,index:d}=this.editTextWorker.splitText(o,i),u={type:R.Text,text:c+`
54
- `+h};n.execAction(ct.create(r.id,[u])),this.editTextWorker.modifyBaseProps(o,r,n);const p=d+1,f=this.editTextWorker.getTextCursorPosByIndex(o,p);n.execAction(lt.focus(r.id,f)),n.execAction(new et)}}class hl extends vt{constructor(){super(...arguments);g(this,"type",Q.Backspace);g(this,"editTextWorker",new qn);g(this,"graphemeSplit",new wo);g(this,"selectionDeleteWorker",new ur)}enable(t){return!0}work(t,n){const s=n.inputManager.editTextInfo;if(!s)return;const r=n.inputManager.selectionManager.selectionInfo;if(r){n.execAction(new nt),this.selectionDeleteWorker.work(s,r,n),n.execAction(new et);return}const{node:o,renderText:i,textCursorPosition:a}=s,{prev:c,next:h,index:d}=this.editTextWorker.splitText(i,a);if(d===-1)return;const u=this.graphemeSplit.split(c);u.pop();let p="";u.forEach(b=>p+=b);const f={type:R.Text,text:p+h};n.execAction(new nt),n.execAction(lt.focus(o.id,a)),n.execAction(ct.create(o.id,[f])),this.editTextWorker.modifyBaseProps(i,o,n);const y=d-1,w=this.editTextWorker.getTextCursorPosByIndex(i,y);n.execAction(lt.focus(o.id,w)),n.execAction(new et)}}class zs extends vt{constructor(){super(...arguments);g(this,"cursorMoveWorker",new ki)}enable(t){return!0}work(t,n){const s=n.inputManager.editTextInfo;if(!s)return;const{renderText:r,textCursorPosition:o,node:i}=s,a=this.moveCursor(r,o);n.execAction(new nt),n.execAction(lt.focus(i.id,a)),n.execAction(new et)}}class dl extends zs{constructor(){super(...arguments);g(this,"type",Q.ArrowRight)}moveCursor(t,n){return this.cursorMoveWorker.moveRight(t,n)}}class ul extends zs{constructor(){super(...arguments);g(this,"type",Q.ArrowLeft)}moveCursor(t,n){return this.cursorMoveWorker.moveLeft(t,n)}}class pl extends zs{constructor(){super(...arguments);g(this,"type",Q.ArrowRight)}moveCursor(t,n){return this.cursorMoveWorker.moveUp(t,n)}}class fl extends zs{constructor(){super(...arguments);g(this,"type",Q.ArrowDown)}moveCursor(t,n){return this.cursorMoveWorker.moveDown(t,n)}}class _o extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyZ)}work(t,n){n.actionManager.redo()}enable(t,n){return t.shiftKey&&this.isPressMetaKey(t,n)}}class Ko extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyZ)}work(t,n){n.actionManager.undo()}enable(t,n){return this.isPressMetaKey(t,n)}}let lg=class extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyA)}enable(t,n){return this.isPressMetaKey(t,n)}work(t,n){const s=n.inputManager.editTextInfo;if(!s)return;const{node:r,textCursorPosition:o,renderText:i}=s;n.execAction(new nt),n.execAction(lt.selection(r.id,i.headTextCursorPosition(),i.tailTextCursorPosition())),n.execAction(new et)}};const gl=new Map([[Q.Enter,[new ll]],[Q.Backspace,[new hl]],[Q.ArrowRight,[new dl]],[Q.ArrowLeft,[new ul]],[Q.ArrowUp,[new pl]],[Q.ArrowDown,[new fl]],[Q.KeyA,[new lg]],[Q.KeyZ,[new _o,new Ko]]]);class yl extends vt{constructor(){super(...arguments);g(this,"type",Q.Delete);g(this,"worker",new Mo)}work(t,n){this.worker.work(n)}enable(t){return!0}}class ml extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyR)}work(t,n){n.toolManager.setCurrentTool(ft.SHAPE,_.RoundRect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(t){return!0}}class wl extends vt{constructor(){super(...arguments);g(this,"type",Q.Escape)}enable(t){return!0}work(t,n){if(n.cropManager.duringCrop){n.cropManager.exitCrop(),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask();return}n.previewManager.resetPreviewNode(n),n.toolManager.setCurrentTool(ft.DEFAULT),n.setCursor("default"),n.refreshEvent()}}class xl extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyT)}work(t,n){n.toolManager.setCurrentTool(ft.TEXT,_.PureText),n.setCursor("text")}enable(t){return!0}}class Pl extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyR)}work(t,n){n.toolManager.setCurrentTool(ft.LINE,Lt.Line),n.setCursor("crosshair")}enable(t){return!0}}class hg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyC)}enable(t){return!0}work(t,n){n.toolManager.setCurrentTool(ft.LINE,Lt.Curve),n.setCursor("crosshair")}}class dg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyA)}enable(t){return!0}work(t,n){n.toolManager.setCurrentTool(ft.LINE,Lt.RoundPolyLine),n.setCursor("crosshair")}}class ug extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyS)}work(t,n){n.toolManager.setCurrentTool(ft.SHAPE,_.Rect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(t){return!0}}class pg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyC)}enable(t,n){return this.isPressMetaKey(t,n)}work(t,n){}shouldPreventDefault(){return!1}}class fg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyV)}enable(t,n){return this.isPressMetaKey(t,n)}work(t,n){}shouldPreventDefault(){return!1}}class gg extends vt{constructor(){super(...arguments);g(this,"duplicateWorker",new Sa);g(this,"type",Q.KeyD)}enable(t,n){return this.isPressMetaKey(t,n)}work(t,n){t.preventDefault(),n.execAction(new nt),this.duplicateWorker.work(n),n.execAction(new et)}}class yg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyA)}enable(t,n){return this.isPressMetaKey(t,n)}work(t,n){const s=[...n.nodeManager.root.children];if(s.length===0)return;const r=s.map(o=>o.id);n.execAction(new nt),n.execAction(Pt.create(r)),n.execAction(new et)}}class mg extends vt{constructor(){super(...arguments);g(this,"type",Q.BracketLeft);g(this,"moveLayerWorker",new Os)}enable(t,n){return this.isPressMetaKey(t,n)}work(t,n){this.moveLayerWorker.moveBackward(n)}}class wg extends vt{constructor(){super(...arguments);g(this,"type",Q.BracketRight);g(this,"moveLayerWorker",new Os)}enable(t,n){return this.isPressMetaKey(t,n)}work(t,n){this.moveLayerWorker.moveForward(n)}}class xg extends vt{constructor(){super(...arguments);g(this,"type",Q.BracketLeft);g(this,"moveLayerWorker",new Os)}enable(t,n){return t.altKey&&this.isPressMetaKey(t,n)}work(t,n){this.moveLayerWorker.moveToBack(n)}}class Pg extends vt{constructor(){super(...arguments);g(this,"type",Q.BracketRight);g(this,"moveLayerWorker",new Os)}enable(t,n){return t.altKey&&this.isPressMetaKey(t,n)}work(t,n){this.moveLayerWorker.moveToUp(n)}}class bg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyF)}work(t,n){n.toolManager.setCurrentTool(ft.SECTION),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(t){return!0}}class vg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyG);g(this,"worker",new gr)}work(t,n){const s=[...n.getSelectNodes()];this.worker.group(s,n)}enable(t,n){return this.isPressMetaKey(t,n)}}class Mg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyG);g(this,"worker",new gr)}work(t,n){const s=[...n.getSelectNodes()];if(s.length!==1)return;const r=s[0];if(r.type!==A.Group)return;const o=r;this.worker.unGroup(o,n)}enable(t,n){return this.isPressMetaKey(t,n)&&t.shiftKey}}class Sg extends vt{constructor(){super(...arguments);g(this,"type",Q.Space)}enable(t){return!0}work(t,n){n.toolManager.setCurrentTool(ft.HandTool),n.refreshEvent()}keyUp(t,n){n.toolManager.resetTool(),n.refreshEvent()}}class Tg extends vt{constructor(){super(...arguments);g(this,"type",Q.Backspace);g(this,"worker",new Mo)}work(t,n){this.worker.work(n)}enable(t){return!0}}class Cg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyC);g(this,"worker",new vs)}enable(t,n){return this.isPressMetaKey(t,n)&&t.shiftKey}work(t,n){const s=n.getSelectNodes();s.size!==1||[...s][0].type!==A.IMG||(t.preventDefault(),this.worker.intoCrop(n))}}class Lg extends vt{constructor(){super(...arguments);g(this,"type",Q.KeyH)}work(t,n){n.toolManager.setCurrentTool(ft.HandTool),n.setCursor("grab"),n.refreshEvent()}enable(t){return!0}}class Ag extends vt{constructor(){super(...arguments);g(this,"type",Q.Digit1)}work(t,n){n.renderManager.zoomToFit(n.asyncRenderNodeManager)}enable(t){return t.shiftKey}}class Rg extends vt{constructor(){super(...arguments);g(this,"type",Q.Digit2)}work(t,n){n.renderManager.zoomToSelect(n.asyncRenderNodeManager)}enable(t){return t.shiftKey}}class Ng extends vt{constructor(){super(...arguments);g(this,"type",Q.Digit3)}work(t,n){n.renderManager.zoomTo100(n.asyncRenderNodeManager)}enable(t){return t.shiftKey}}const bl=new Map([[Q.Delete,[new yl]],[Q.Backspace,[new Tg]],[Q.Digit1,[new Ag]],[Q.Digit2,[new Rg]],[Q.Digit3,[new Ng]],[Q.KeyA,[new yg,new dg]],[Q.KeyC,[new Cg,new pg,new hg]],[Q.KeyD,[new gg]],[Q.KeyF,[new bg]],[Q.KeyV,[new fg]],[Q.KeyL,[new Pl]],[Q.KeyS,[new ug]],[Q.KeyR,[new ml]],[Q.KeyT,[new xl]],[Q.KeyH,[new Lg]],[Q.KeyZ,[new _o,new Ko]],[Q.KeyG,[new Mg,new vg]],[Q.Escape,[new wl]],[Q.Space,[new Sg]],[Q.BracketLeft,[new xg,new mg]],[Q.BracketRight,[new Pg,new wg]]]);class vl{constructor(e){g(this,"textConfig");g(this,"normalConfig");g(this,"context");this.context=e,this.textConfig=new Uo(gl),this.normalConfig=new Uo(bl)}keyDown(e,t){const n=this.getHotKey(e);n&&(n.shouldPreventDefault()&&(e.preventDefault(),e.stopPropagation()),n.keyDown(e,t))}keyUp(e,t){const n=this.getHotKey(e);n&&(n.shouldPreventDefault()&&(e.preventDefault(),e.stopPropagation()),n.keyUp(e,t))}getHotKey(e){return this.context.inputManager.isEdit()?this.textConfig.getKey(e):this.normalConfig.getKey(e)}}class Ml{constructor(e){g(this,"eventCtx");g(this,"hotKeyManager");g(this,"onKeyDown",e=>{this.onEnable(e)&&this.hotKeyManager.keyDown(e,this.eventCtx)});g(this,"onKeyUp",e=>{this.onEnable(e)&&this.hotKeyManager.keyUp(e,this.eventCtx)});this.eventCtx=e,this.hotKeyManager=new vl(e)}start(){document.addEventListener("keydown",this.onKeyDown,!0),document.addEventListener("keyup",this.onKeyUp,!0)}stop(){document.removeEventListener("keydown",this.onKeyDown,!0),document.removeEventListener("keyup",this.onKeyUp,!0)}onEnable(e){return this.eventCtx.docState.canEdit()?e.target===this.eventCtx.inputManager.renderInput.inputDom?!0:!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement):!1}}class Eg{constructor(e){g(this,"ctx");this.ctx=e,e.actionManager.addNetworkPlugin(this)}addMessage(e){}addActionGroup(e){}initWebsocket(){}start(){}stop(){}onEnable(e){return!0}}class Ig{static getOolongApp(){const e=new go,t=new Yo(e),n=t.appContext,s=new _s(n,e),r=new Wo(n),o=new cl(n),i=new Ml(n),a=new Go(n),c=new dc(n);return t.registerPlugin(s),t.registerPlugin(r),t.registerPlugin(o),t.registerPlugin(i),t.registerPlugin(a),t.registerPlugin(c),t}static getReadOnlyApp(){const e=new go,t=new Yo(e),n=t.appContext,s=new _s(n,e),r=new Wo(n),o=new Go(n);return t.registerPlugin(s),t.registerPlugin(r),t.registerPlugin(o),t}}P.ANCHOR_COLOR=ni,P.ANCHOR_HOVER_RADIUS=Hr,P.ANCHOR_OFFSET=ti,P.ANCHOR_RADIUS=ei,P.AbsActionExecutor=on,P.AbsActionLog=an,P.AbsAlignHandler=Ln,P.AbsAlignSideHandler=$r,P.AbsArrowKey=zs,P.AbsAuxGraphic=Ct,P.AbsCreateDragProcessor=sr,P.AbsDetector=ne,P.AbsDrawer=In,P.AbsInputHandler=Lr,P.AbsInteractConfig=ha,P.AbsMainMode=Kn,P.AbsNetworkPlugin=El,P.AbsNodeManager=gc,P.AbsProps=Pe,P.AbsResourceInstance=tl,P.AbsStatusHandler=rn,P.AbsStretchProcessor=Qs,P.AbsSubMode=Ve,P.AbsTextSelectionHandler=pr,P.ActionCache=_i,P.ActionLogGroup=Us,P.ActionManager=ji,P.ActionMeta=Bi,P.ActionType=zt,P.AddExecutor=Di,P.AddNodeLog=Yt,P.AffineMatrix=Z,P.AlignBottomHandler=na,P.AlignHeightSideHandler=aa,P.AlignLeftHandler=sa,P.AlignLine=fi,P.AlignMoveWorker=oa,P.AlignRightHandler=ra,P.AlignStretchLine=gi,P.AlignStretchWorker=ca,P.AlignTopHandler=ea,P.AlignWidthSideHandler=ia,P.AlignWorker=cn,P.AppEventContext=cc,P.AppStage=Ig,P.ArrowDownKey=fl,P.ArrowLeftKey=ul,P.ArrowProps=Ie,P.ArrowRightKey=dl,P.ArrowUpKey=pl,P.AuxGraphicFactory=zr,P.AuxUtils=hi,P.AuxiliaryManager=vi,P.AuxiliaryType=N,P.BLOCK_COLOR=Or,P.BaseProps=gt,P.BorderProps=Ot,P.CanvasConfig=ng,P.CanvasContainer=og,P.CanvasInput=ig,P.CanvasRender=So,P.ClearFocusNodeHandler=ao,P.ClickExpandShapeHandler=Na,P.ClickHandler=ee,P.ClickMode=ln,P.ClickProcessor=We,P.ClickTextHandler=Ra,P.CollaborationManager=oh,P.ColorProps=Jt,P.ConnectProps=Pn,P.ConnectorPoint=kl,P.ControlPoint=Bl,P.CopyPasteManager=hc,P.CopyPastePlugin=dc,P.CopyPasteUtils=kn,P.CreateLineMode=tc,P.CreateRectBound=ui,P.CreateRectMode=Za,P.CreateTextMode=nc,P.CropProps=Mn,P.CursorProcessor=Ha,P.DHPCanvas=Vo,P.DbClickMode=Qr,P.DefaultBorderColorShape=Wu,P.DefaultClickMode=ka,P.DefaultClickProcessor=Ia,P.DefaultColorShape=Vu,P.DefaultFont=wh,P.DefaultLineHeight=Mh,P.DefaultMode=ja,P.DeleteKey=yl,P.DetectorEnum=W,P.DiffParaHandler=rc,P.DocState=fc,P.DownAndMoveStreamMode=ae,P.DragLineEndProcessor=Va,P.DragMode=Ca,P.DragProcessor=Ta,P.DragSelectTextMode=fa,P.DragSelectTextProcessor=pa,P.EditTextWorker=qn,P.EmptyNetworkPlugin=Eg,P.EndExecutor=Fi,P.EndLog=et,P.EnterHotKey=ll,P.EscKey=wl,P.ExecutorManager=Gi,P.ExpandDetector=qa,P.ExpandShapeButton=pi,P.FocusEnum=be,P.FocusNodeHandler=oo,P.GraphemeSplit=wo,P.GraphicNode=Sn,P.GraphicUtils=T,P.GroupMode=so,P.GroupProcessor=La,P.HOVER_ANCHOR_COLOR=si,P.HOVER_BOUND_COLOR=vn,P.HighlightRects=ai,P.HotKey=vt,P.HotKeyConfig=Uo,P.HotKeyManager=vl,P.HoverBound=ri,P.HoverNodeDetector=ua,P.HoverProcessor=co,P.ImageUtils=ac,P.InputCompositionEndHandler=al,P.InputCompositionHandler=il,P.InputEventPlugin=cl,P.InputNormalHandler=ol,P.InteractConfig=go,P.InteractiveEventType=yt,P.InteractiveManager=ta,P.InteractiveUtils=$t,P.IntlSplit=Ri,P.KeyCode=Q,P.KeyEventPlugin=Ml,P.LKey=Pl,P.LineArrowType=we,P.LineCreateDragProcessor=Ja,P.LineDashType=Ee,P.LineEndPointDetector=$a,P.LineProps=he,P.LineShapeType=Lt,P.LineSpacing=xh,P.LinkNode=Ws,P.MAX_SCALE=_r,P.MIN_SCALE=Ur,P.MOVE_ALIGN_BUFFER=jr,P.MainTextId=vh,P.MeasureWorker=Ii,P.MoveLayerWorker=Os,P.MultiSelectBound=ii,P.MultiSelectHandler=xi,P.NodeDetector=da,P.NodeFactory=Ge,P.NodeManager=wc,P.NodeSideEnum=$o,P.NodeTextPadding=Wt,P.NodeType=A,P.NormalMode=za,P.NormalResourceInstance=el,P.OolongAPI=uc,P.OolongApp=Yo,P.OolongImgNode=ys,P.OolongLine=dn,P.OolongNode=qe,P.OolongSVGNode=Ts,P.OolongSVGUtils=$n,P.OptionHelper=mi,P.PREVIEW_ROOT_ID=Qo,P.ParagraphSpacing=Ph,P.PasteNodeHandler=vo,P.Permission=pc,P.Point=m,P.PointerEventPlugin=_s,P.PolyLineControlPointDetector=sc,P.PropType=R,P.QuadBezierCurve=Ol,P.RKey=ml,P.ROOT_ID=Un,P.Rect=D,P.RectCreateDragProcessor=Qa,P.RedoKey=_o,P.RemoveExecutor=Hi,P.RemoveNodeLog=Fe,P.RenderManager=$i,P.RenderText=Wr,P.ResourceManager=nl,P.ResourceType=Gs,P.RootNode=bo,P.RotateDetector=dr,P.RotateMode=Ga,P.RotateProcessor=Wa,P.SELECT_BOUND_COLOR=re,P.SELECT_GROUP_COLOR=Dr,P.STRETCH_ALIGN_BUFFER=Ks,P.STRETCH_ALIGN_OFFSET=js,P.STRETCH_WIDTH=Jo,P.SameParaDiffLineHandler=mo,P.SameParaSameLineHandler=yo,P.SectionType=jn,P.SelectGroup=ci,P.SelectManager=bi,P.SelectNodeExecutor=Xi,P.SelectNodeLog=Pt,P.ShapeProps=jt,P.ShapeType=_,P.ShiftDownNodeHandler=ro,P.ShiftUpClickHandler=io,P.SingleSelectBound=oi,P.SingleStatusHandler=wi,P.SingleStretchMode=ya,P.SingleStretchProcessorV2=ga,P.SlotKeyType=te,P.SlotManager=Pi,P.StartExecutor=Yi,P.StartLog=nt,P.StreamMode=qs,P.StreamProcessor=ge,P.StretchAlignType=It,P.StretchDetector=$s,P.StretchHotBuffer=Yh,P.StretchMode=Ya,P.StretchProcessorV2=Xa,P.StretchRect=di,P.StretchType=G,P.TEXT_SELECTION_COLOR=Zo,P.TKey=xl,P.TextAlignType=xe,P.TextCharacter=Ei,P.TextCreateDragProcessor=ec,P.TextCursorMoveWorker=ki,P.TextCursorPosition=Ht,P.TextDeleteKey=hl,P.TextFocusExecutor=Vi,P.TextFocusLog=lt,P.TextLine=ms,P.TextParagraph=Vr,P.TextProps=se,P.TextSelection=li,P.TextSelectionDeleteWorker=ur,P.TextSelectionWorker=oc,P.TextSizeMode=le,P.TextWord=Ni,P.ToolEnum=ft,P.ToolManager=Ba,P.UndoKey=Ko,P.UndoRedoManager=Ui,P.UpdateExecutor=zi,P.UpdateNodeLog=ct,P.VisibleBuffer=Sh,P.WHITE_COLOR=sn,P.WheelEventPlugin=Wo,P.WheelUtils=ag,P.WindowResizePlugin=Go,P.actionExecutors=Wi,P.convertAction2MsgData=Lh,P.convertActionData2Log=Ah,P.disableAlignNodeType=Cn,P.disableAlignSideSet=qr,P.isContains=Gu,P.limitLineWidth=bh,P.normalKeyMap=bl,P.textKeyMap=gl,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
57
+ <%s key={someKey} {...props} />`,Dr,Xn,Yx,Xn),Dl[Xn+Dr]=!0}}return N===n?Ox(ot):Dx(ot),ot}}function Xx(N,Q,oe){return Ol(N,Q,oe,!0)}function zx(N,Q,oe){return Ol(N,Q,oe,!1)}var Wx=zx,Fx=Xx;No.Fragment=n,No.jsx=Wx,No.jsxs=Fx}()),No}process.env.NODE_ENV==="production"?vr.exports=Xy():vr.exports=zy();var zt=vr.exports;const Ir=({gmlRender:l})=>{const t=st.useRef(null),e=()=>{const n=window.devicePixelRatio;t.current.width=n*t.current.clientWidth,t.current.height=n*t.current.clientHeight};return st.useEffect(()=>(e(),l.init(t.current),window.addEventListener("resize",e,!1),()=>{window.removeEventListener("resize",e,!1)}),[t]),zt.jsx("div",{className:"normal-container",children:zt.jsx("canvas",{ref:t,className:"normal-canvas"})})},Wy=({gmlRender:l,auxiliaryGmlRender:t})=>zt.jsxs("div",{className:"canvas-container",children:[zt.jsx("div",{className:"auxiliary-canvas",children:zt.jsx(Ir,{gmlRender:t})}),zt.jsx("div",{className:"content-canvas",children:zt.jsx(Ir,{gmlRender:l})})]}),Fy=({inputManager:l})=>{const t=st.useRef(null),e=st.useRef(null);return st.useEffect(()=>{t.current&&l.init(t.current,e.current)},[t]),zt.jsxs(zt.Fragment,{children:[zt.jsx("div",{ref:e,className:"render-input"}),zt.jsx("input",{ref:t,className:"canvas-input"})]})};class fs{constructor(){p(this,"editTextWorker",new wo);p(this,"textInputWorker",new wr);p(this,"selectionDeleteWorker",new os)}computeNextCursorIndex(t,e){return t+e.length}handle(t,e,n,o){const{node:s,renderText:r,textCursorPosition:i}=t;e.execAction(new W);const a=e.inputManager.selectionManager.selectionInfo;if(a){this.selectionDeleteWorker.work(t,a,e);const{renderText:f,textCursorPosition:g}=e.inputManager.editTextInfo,{prev:y,next:m}=this.textInputWorker.getEditTextPrevNext(f,g),b=f.getIndexByTextCursorPos(g);o.prev=y,o.next=m,o.index=b}else e.execAction(ee.focus(s.id,i));const{updateTextProps:c,index:h}=this.computeUpdateTextProps(t,n,o);e.execAction(U.create(s.id,[c])),this.editTextWorker.modifyBaseProps(r,s,e);const d=this.computeNextCursorIndex(h,n),u=r.getTextCursorPosByIndex(d);e.execAction(ee.focus(s.id,u)),e.execAction(new z)}}class il extends fs{computeUpdateTextProps(t,e){const{renderText:n,textCursorPosition:o}=t,s=this.editTextWorker.editText(n,o,e),r=n.getIndexByTextCursorPos(o);return{updateTextProps:{type:I.Text,richText:s},index:r}}}class al extends fs{computeUpdateTextProps(t,e,n){const{prev:o,next:s,index:r}=n;return{updateTextProps:{type:I.Text,richText:o+e+s},index:r}}}class cl extends fs{constructor(){super(...arguments);p(this,"graphemeSplit",new Ro)}computeUpdateTextProps(e,n,o){const{prev:s,next:r,index:i}=o;return{updateTextProps:{type:I.Text,richText:s+n+r},index:i}}computeNextCursorIndex(e,n){const o=this.graphemeSplit.split(n).length;return e+o}}class ll{constructor(t){p(this,"eventCtx");p(this,"duringComposition",!1);p(this,"compositionRecord",{prev:"",next:"",index:0});p(this,"textInputWorker",new wr);p(this,"normalInputHandler",new il);p(this,"compositionInputHandler",new al);p(this,"compositionEndHandler",new cl);p(this,"compositionEnd",t=>{if(!this.onEnable()||!this.duringComposition)return;const e=this.eventCtx.inputManager.editTextInfo;if(!e)return;const n=t.data;this.compositionEndHandler.handle(e,this.eventCtx,n,this.compositionRecord),this.duringComposition=!1});p(this,"compositionStart",t=>{if(!this.onEnable())return;const e=this.eventCtx.inputManager.editTextInfo;if(!e)return;this.duringComposition=!0;const{renderText:n,textCursorPosition:o}=e,{prev:s,next:r}=this.textInputWorker.getEditTextPrevNext(n,o),i=n.getIndexByTextCursorPos(o);this.compositionRecord={prev:s,next:r,index:i}});p(this,"onKeyDown",t=>{if(!this.onEnable()||!t.data)return;const e=t.data;if(e==="")return;const n=this.eventCtx.inputManager.editTextInfo;if(n){if(this.duringComposition){this.compositionInputHandler.handle(n,this.eventCtx,e,this.compositionRecord);return}this.normalInputHandler.handle(n,this.eventCtx,e,this.compositionRecord)}});this.eventCtx=t}onEnable(){return this.eventCtx.docState.canEdit()}start(){var e;const t=(e=this.eventCtx.inputManager.renderInput)==null?void 0:e.inputDom;if(!t){console.error("input dom is not exist");return}t.addEventListener("input",this.onKeyDown),t.addEventListener("compositionstart",this.compositionStart),t.addEventListener("compositionend",this.compositionEnd)}stop(){var e;const t=(e=this.eventCtx.inputManager.renderInput)==null?void 0:e.inputDom;if(!t){console.error("input dom is not exist");return}t.removeEventListener("input",this.onKeyDown),t.removeEventListener("compositionstart",this.compositionStart),t.removeEventListener("compositionend",this.compositionEnd)}}class Tr{constructor(t){p(this,"eventCtx");p(this,"svgRedrawTimer",null);p(this,"onWheel",t=>{if(!this.onEnable(t))return;const e=this.eventCtx;if(t.target===e.gmlRender.canvas&&t.preventDefault(),t.ctrlKey){const n=e.gmlRender.canvas.getBoundingClientRect(),o=new P(t.clientX-n.x,t.clientY-n.y),s=e.gmlRender.transformToGlobal(o),r=t.deltaY,i=2*Math.abs(r)/100,a=r>0?1-i:1+i;this.eventCtx.renderManager.zoomScale(a,s),this.scaleRedrawSvg(e)}else this.eventCtx.renderManager.scroll(t.deltaX,t.deltaY);this.eventCtx.inputManager.refreshCursor(),this.eventCtx.refreshEvent()});this.eventCtx=t}start(){if(!this.eventCtx.renderManager.gmlRender.canvas){console.error("canvas 不存在,无法注册画布滚动时间");return}this.eventCtx.renderManager.gmlRender.canvas.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){if(!this.eventCtx.renderManager.gmlRender.canvas){console.error("canvas 不存在,无法注册画布滚动时间");return}this.eventCtx.renderManager.gmlRender.canvas.removeEventListener("wheel",this.onWheel)}onEnable(t){return!0}scaleRedrawSvg(t){this.svgRedrawTimer&&(clearTimeout(this.svgRedrawTimer),this.svgRedrawTimer=null),this.svgRedrawTimer=setTimeout(()=>{for(const[e,n]of t.nodeManager.nodeMap)n.type===v.SVG&&t.asyncRenderNodeManager.addRenderNode(n)},100)}}class Yy{static scroll(t,e,n){const o=n.getScale();n.translation(-t/o,-e/o);const s=n.glCtx,{a:r,b:i,c:a,d:c,e:h,f:d}=n.globalTransform;s.setTransform(r,i,a,c,h,d)}static zoomScale(t,e,n){const o=2*Math.abs(t)/100,s=t>0?1-o:1+o;e.scale(s,s,n);const r=e.glCtx,{a:i,b:a,c,d:h,e:d,f:u}=e.globalTransform;r.setTransform(i,a,c,h,d,u)}static zoomRedraw(t,e,n){const o=t.canvas.getContext("2d"),{a:s,b:r,c:i,d:a,e:c,f:h}=t.globalTransform;o.setTransform(s,r,i,a,c,h),n.addContentRenderTask(),n.addAuxiliaryDrawTask()}static zoomToFit(t,e,n,o){const s=t.canvas.getContext("2d"),{a:r,b:i,c:a,d:c,e:h,f:d}=o;t.globalTransform.a=r,t.globalTransform.b=i,t.globalTransform.c=a,t.globalTransform.d=c,t.globalTransform.e=h,t.globalTransform.f=d,s.setTransform(r,i,a,c,h,d),n.renderManager.addContentRenderTask()}}class Lr{constructor(t){p(this,"eventCtx");p(this,"onResize",()=>{this.eventCtx.resizeWorker.resize(this.eventCtx)});this.eventCtx=t}start(){window.addEventListener("resize",this.onResize)}stop(){window.removeEventListener("resize",this.onResize)}onEnable(t){return!0}}class Cr{constructor(t){p(this,"keyMap",new Map);this.keyMap=t}getKey(t){const e=this.keyMap.get(t.code);if(!e)return null;const o=ui.getOS()===Jt.MacOS;for(const s of e)if(s.enable(t,o))return s;return null}}class me{keyDown(t,e){this.work(t,e)}keyUp(t,e){}shouldPreventDefault(){return!0}isPressMetaKey(t,e){return e?t.metaKey:t.ctrlKey}}var J=(l=>(l.Enter="Enter",l.Escape="Escape",l.Backspace="Backspace",l.Delete="Delete",l.Space="Space",l.ArrowLeft="ArrowLeft",l.ArrowRight="ArrowRight",l.ArrowUp="ArrowUp",l.ArrowDown="ArrowDown",l.Digit1="Digit1",l.Digit2="Digit2",l.Digit3="Digit3",l.Digit4="Digit4",l.Digit5="Digit5",l.Digit6="Digit6",l.Digit7="Digit7",l.Digit8="Digit8",l.Digit9="Digit9",l.Digit0="Digit0",l.KeyA="KeyA",l.KeyB="KeyB",l.KeyC="KeyC",l.KeyD="KeyD",l.KeyE="KeyE",l.KeyF="KeyF",l.KeyG="KeyG",l.KeyH="KeyH",l.KeyI="KeyI",l.KeyJ="KeyJ",l.KeyK="KeyK",l.KeyL="KeyL",l.KeyM="KeyM",l.KeyN="KeyN",l.KeyO="KeyO",l.KeyP="KeyP",l.KeyQ="KeyQ",l.KeyR="KeyR",l.KeyS="KeyS",l.KeyT="KeyT",l.KeyU="KeyU",l.KeyV="KeyV",l.KeyW="KeyW",l.KeyX="KeyX",l.KeyY="KeyY",l.KeyZ="KeyZ",l.Tab="Tab",l.ShiftLeft="ShiftLeft",l.ShiftRight="ShiftRight",l.BracketRight="BracketRight",l.BracketLeft="BracketLeft",l))(J||{});class Gy{constructor(){p(this,"cursorMoveWorker",new lo)}work(t,e){const{node:n,renderText:o,textCursorPosition:s}=t,{updateTextProps:r}=this.computeUpdateTextProps(t);e.execAction(new W),e.execAction(U.create(n.id,[r]));const i=this.cursorMoveWorker.moveRight(o,s);e.execAction(ee.focus(n.id,i)),e.execAction(new z)}computeUpdateTextProps(t){const{renderText:e,textCursorPosition:n}=t,o=this.lineBreak(e,n);return{updateTextProps:{type:I.Text,richText:o}}}lineBreak(t,e){const{paragraphIndex:n,lineIndex:o,charIndex:s}=e,r=t.prevParagraphToXML(n),i=t.nextParagraphToXML(n),a=t.getParagraph(n);if(!a)return"<root><p></p><p></p></root>";const c=a.getLine(o);if(!c){const Z=a.toRichTextXML(t.textProps);return`<root>${r}${Z}<p></p>${i}</root>`}const h=a.prevToRichTextXML(o,t.textProps),d=a.nextToRichTextXML(o,t.textProps),u=c.getBlockIndex(s);if(!u){const Z=`<p>${h}</p>`,se=`<p>${d}</p>`;return`<root>${r}${Z}${se}${i}</root>`}const{textBlock:f,blockIndex:g,charIndex:y}=u,m=c.prevToRichTextXML(g,t.textProps),b=c.nextToRichTextXML(g,t.textProps),w=f.getPrevText(y),L=f.getNextText(y),B=f.computeStyle(t.textProps),H=w?`<style ${B}>${w}</style>`:"",E=L?`<style ${B}>${L}</style>`:"",X=`<p>${h}${m}${H}</p>`,$=`<p>${E}${b}${d}</p>`;return`<root>${r}${X}${$}${i}</root>`}}class Uy{addParagraph(t,e,n){const o=t.getProp(I.TextParagraph).clone(),s=o.paragraphStyles;for(const i of s)i.paraIndex>e&&i.paraIndex++;const r=S.getParaStyle(o,e);if(r){const i={level:r.level,orderIndex:r.orderIndex,paraIndex:e+1};s.push(i),n.execAction(U.create(t.id,[{type:I.TextParagraph,paragraphStyles:s}]))}}}let hl=class extends me{constructor(){super(...arguments);p(this,"styleWorker",new Uy);p(this,"type",J.Enter);p(this,"editTextWorker",new wo);p(this,"selectionDeleteWorker",new os);p(this,"lineBreakWorker",new Gy)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,renderText:r}=o;let i=o.textCursorPosition;const a=n.inputManager.selectionManager.selectionInfo;n.execAction(new W),a?(this.selectionDeleteWorker.work(o,a,n),i=n.inputManager.editTextInfo.textCursorPosition):n.execAction(ee.focus(s.id,i));const c=i.paragraphIndex;this.styleWorker.addParagraph(s,c,n);const h=this.lineBreakWorker.lineBreak(r,i),d=r.getIndexByTextCursorPos(i),u={type:I.Text,richText:h};n.execAction(U.create(s.id,[u])),this.editTextWorker.modifyBaseProps(r,s,n);const f=d+1,g=r.getTextCursorPosByIndex(f);n.execAction(ee.focus(s.id,g)),n.execAction(new z)}};class dl extends me{constructor(){super(...arguments);p(this,"type",J.Backspace);p(this,"editTextWorker",new wo);p(this,"graphemeSplit",new Ro);p(this,"selectionDeleteWorker",new os)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const s=n.inputManager.selectionManager.selectionInfo;if(s){n.execAction(new W),this.selectionDeleteWorker.work(o,s,n),n.execAction(new z);return}const{node:r,renderText:i,textCursorPosition:a}=o,c=a.paragraphIndex;if(a.lineIndex===0&&a.charIndex===-1){const m=r.getProp(I.TextParagraph).clone(),b=S.getParaStyle(m,c),w=m.paragraphStyles;if(b){if(b.level>0){b.level--,n.execAction(new W),n.execAction(U.create(r.id,[{type:I.TextParagraph,paragraphStyles:w}])),n.execAction(ee.focus(r.id,a)),n.execAction(new z);return}const L=w.findIndex(B=>B===b);w.splice(L,1),n.execAction(new W),n.execAction(U.create(r.id,[{type:I.TextParagraph,paragraphStyles:w}])),n.execAction(ee.focus(r.id,a)),n.execAction(new z);return}}const d=new fc().deleteText(i,a,1),u={type:I.Text,richText:d},f=i.getIndexByTextCursorPos(a);n.execAction(new W),n.execAction(ee.focus(r.id,a)),n.execAction(U.create(r.id,[u])),this.editTextWorker.modifyBaseProps(i,r,n);const g=f-1,y=i.getTextCursorPosByIndex(g);n.execAction(ee.focus(r.id,y)),n.execAction(new z)}}class ko extends me{constructor(){super(...arguments);p(this,"cursorMoveWorker",new lo)}enable(e){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{renderText:s,textCursorPosition:r,node:i}=o,a=this.moveCursor(s,r,n);n.execAction(new W),n.execAction(ee.focus(i.id,a)),n.execAction(new z)}}let ul=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowRight)}moveCursor(e,n,o){const s=o.inputManager.selectionManager.selectionInfo;if(s){const{end:r}=s;return r}return this.cursorMoveWorker.moveRight(e,n)}},pl=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowLeft)}moveCursor(e,n){return this.cursorMoveWorker.moveLeft(e,n)}},fl=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowRight)}moveCursor(e,n){return this.cursorMoveWorker.moveUp(e,n)}},gl=class extends ko{constructor(){super(...arguments);p(this,"type",J.ArrowDown)}moveCursor(e,n){return this.cursorMoveWorker.moveDown(e,n)}};class Ar extends me{constructor(){super(...arguments);p(this,"type",J.KeyZ)}work(e,n){n.actionManager.redo()}enable(e,n){return e.shiftKey&&this.isPressMetaKey(e,n)}}class Nr extends me{constructor(){super(...arguments);p(this,"type",J.KeyZ)}work(e,n){n.actionManager.undo()}enable(e,n){return this.isPressMetaKey(e,n)}}let _y=class extends me{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,textCursorPosition:r,renderText:i}=o;n.execAction(new W),n.execAction(ee.selection(s.id,i.headTextCursorPosition(),i.tailTextCursorPosition())),n.execAction(new z)}};class $y extends me{constructor(){super(...arguments);p(this,"type",J.Tab)}enable(e,n){return!0}work(e,n){const o=n.inputManager.editTextInfo;if(!o)return;const{node:s,textCursorPosition:r}=o,i=r.paragraphIndex,a=s.getProp(I.TextParagraph).clone(),c=S.getParaStyle(a,i);if(!c)return;c.level++;const h=a.paragraphStyles;n.execAction(new W),n.execAction(ee.focus(s.id,r)),n.execAction(U.create(s.id,[{type:I.TextParagraph,paragraphStyles:h}])),n.execAction(ee.focus(s.id,r)),n.execAction(new z)}}let jy=class extends me{constructor(){super(...arguments);p(this,"type",J.Escape)}enable(e){return!0}work(e,n){const{editTextInfo:o}=n.inputManager;o&&(n.execAction(new W),n.execAction(ee.blur(o.node.id)),n.execAction(new z),n.auxiliaryManager.selectManager.refreshSelectStatus())}};const yl=new Map([[J.Enter,[new hl]],[J.Escape,[new jy]],[J.Backspace,[new dl]],[J.ArrowRight,[new ul]],[J.ArrowLeft,[new pl]],[J.ArrowUp,[new fl]],[J.ArrowDown,[new gl]],[J.KeyA,[new _y]],[J.KeyZ,[new Ar,new Nr]],[J.Tab,[new $y]]]);class xl extends me{constructor(){super(...arguments);p(this,"type",J.Delete);p(this,"worker",new Mo)}work(e,n){this.worker.work(n)}enable(e){return!0}}class wl extends me{constructor(){super(...arguments);p(this,"type",J.KeyR)}work(e,n){n.toolManager.setCurrentTool(ye.SHAPE,K.RoundRect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class Pl extends me{constructor(){super(...arguments);p(this,"type",J.Escape)}enable(e){return!0}work(e,n){if(n.cropManager.duringCrop){n.cropManager.exitCrop(),n.auxiliaryManager.selectManager.refreshSelectStatus(),n.renderManager.addAuxiliaryDrawTask();return}n.previewManager.resetPreviewNode(n),n.toolManager.setCurrentTool(ye.DEFAULT),n.setCursor("default"),n.refreshEvent()}}class ml extends me{constructor(){super(...arguments);p(this,"type",J.KeyT)}work(e,n){n.toolManager.setCurrentTool(ye.TEXT,K.PureText),n.setCursor("text")}enable(e){return!0}}class bl extends me{constructor(){super(...arguments);p(this,"type",J.KeyR)}work(e,n){n.toolManager.setCurrentTool(ye.LINE,he.Line),n.setCursor("crosshair")}enable(e){return!0}}class Vy extends me{constructor(){super(...arguments);p(this,"type",J.KeyC)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.LINE,he.Curve),n.setCursor("crosshair")}}class Ky extends me{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.LINE,he.RoundPolyLine),n.setCursor("crosshair")}}class Qy extends me{constructor(){super(...arguments);p(this,"type",J.KeyS)}work(e,n){n.toolManager.setCurrentTool(ye.SHAPE,K.Rect),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class Zy extends me{constructor(){super(...arguments);p(this,"type",J.KeyC)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){}shouldPreventDefault(){return!1}}class qy extends me{constructor(){super(...arguments);p(this,"type",J.KeyV)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){}shouldPreventDefault(){return!1}}class Jy extends me{constructor(){super(...arguments);p(this,"duplicateWorker",new Zs);p(this,"type",J.KeyD)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){e.preventDefault(),n.execAction(new W),this.duplicateWorker.work(n),n.execAction(new z)}}class ex extends me{constructor(){super(...arguments);p(this,"type",J.KeyA)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){const o=[...n.nodeManager.root.children];if(o.length===0)return;const s=o.map(r=>r.id);n.execAction(new W),n.execAction(xe.create(s)),n.execAction(new z)}}class tx extends me{constructor(){super(...arguments);p(this,"type",J.BracketLeft);p(this,"moveLayerWorker",new yo)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveBackward(n)}}class nx extends me{constructor(){super(...arguments);p(this,"type",J.BracketRight);p(this,"moveLayerWorker",new yo)}enable(e,n){return this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveForward(n)}}class ox extends me{constructor(){super(...arguments);p(this,"type",J.BracketLeft);p(this,"moveLayerWorker",new yo)}enable(e,n){return e.altKey&&this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveToBack(n)}}class sx extends me{constructor(){super(...arguments);p(this,"type",J.BracketRight);p(this,"moveLayerWorker",new yo)}enable(e,n){return e.altKey&&this.isPressMetaKey(e,n)}work(e,n){this.moveLayerWorker.moveToUp(n)}}class rx extends me{constructor(){super(...arguments);p(this,"type",J.KeyF)}work(e,n){n.toolManager.setCurrentTool(ye.SECTION),n.setCursor("crosshair"),n.previewManager.addPreviewNode(n),n.refreshEvent()}enable(e){return!0}}class ix extends me{constructor(){super(...arguments);p(this,"type",J.KeyG);p(this,"worker",new ls)}work(e,n){const o=[...n.getSelectNodes()];this.worker.group(o,n)}enable(e,n){return this.isPressMetaKey(e,n)}}class ax extends me{constructor(){super(...arguments);p(this,"type",J.KeyG);p(this,"worker",new ls)}work(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return;const s=o[0];if(s.type!==v.Group)return;const r=s;this.worker.unGroup(r,n)}enable(e,n){return this.isPressMetaKey(e,n)&&e.shiftKey}}class cx extends me{constructor(){super(...arguments);p(this,"type",J.Space)}enable(e){return!0}work(e,n){n.toolManager.setCurrentTool(ye.HandTool),n.refreshEvent()}keyUp(e,n){n.toolManager.resetTool(),n.refreshEvent()}}class lx extends me{constructor(){super(...arguments);p(this,"type",J.Backspace);p(this,"worker",new Mo)}work(e,n){this.worker.work(n)}enable(e){return!0}}class hx extends me{constructor(){super(...arguments);p(this,"type",J.KeyC);p(this,"worker",new xo)}enable(e,n){return this.isPressMetaKey(e,n)&&e.shiftKey}work(e,n){const o=n.getSelectNodes();o.size!==1||[...o][0].type!==v.IMG||(e.preventDefault(),this.worker.intoCrop(n))}}class dx extends me{constructor(){super(...arguments);p(this,"type",J.KeyH)}work(e,n){n.toolManager.setCurrentTool(ye.HandTool),n.setCursor("grab"),n.refreshEvent()}enable(e){return!0}}class ux extends me{constructor(){super(...arguments);p(this,"type",J.Digit1)}work(e,n){n.renderManager.zoomToFit(),n.refreshAllSvgNode()}enable(e){return e.shiftKey}}class px extends me{constructor(){super(...arguments);p(this,"type",J.Digit2)}work(e,n){n.renderManager.zoomToSelect()}enable(e){return e.shiftKey}}class fx extends me{constructor(){super(...arguments);p(this,"type",J.Digit3)}work(e,n){n.renderManager.zoomTo100()}enable(e){return e.shiftKey}}class Sl extends me{constructor(){super(...arguments);p(this,"type",J.ShiftLeft)}enable(e,n){return!0}work(e,n){const o=S.getMockEventModifierInit(e);n.refreshEvent(o)}keyUp(e,n){this.work(e,n)}}class gs{constructor(){p(this,"groupBaseWorker",new on);p(this,"layoutWorker",new Rn);p(this,"handlerCtx",new Ma([new pa,new Sa,new fa]))}work(t,e,n){const o=this.computeMoveNodes(t);if(o.length===0)return;this.groupBaseWorker.start(o);const s=new Set;this.batchCollectNodeLinks(o,t,s),t.execAction(new W);const r={x:e,y:n},i=[];for(const a of o){const c=this.handlerCtx.handle(a,r);i.push(...c)}t.execAction(new U({infos:i})),this.groupBaseWorker.work(t,!1),this.layoutWorker.work([...s],t,!1),t.execAction(new z)}batchCollectNodeLinks(t,e,n){const o=e.getSelectNodes();for(const s of t)this.collectNodeLinks(s,e,o,n)}collectNodeLinks(t,e,n,o){const s=e.nodeManager.getNodeLinks(t);for(const r of s)n.has(r)||o.add(r);for(const r of t.children)r.type!==v.Line&&this.collectNodeLinks(r,e,n,o)}computeMoveNodes(t){const e=t.getSelectNodes(),n=new Map;e.forEach(s=>n.set(s.id,s));const o=[];for(const s of e)if(s.type===v.Line){const r=s,{start:i,end:a}=r.connectProps;if(i&&a&&n.has(i.objectId)&&n.has(a.objectId)){o.push(s);continue}if(!i&&a&&n.has(a.objectId)){o.push(s);continue}if(!a&&i&&n.has(i.objectId)){o.push(s);continue}!a&&!i&&o.push(s)}else o.push(s);return o}}class gx extends me{constructor(){super(...arguments);p(this,"type",J.ArrowRight);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex+1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,s,0)}}class yx extends me{constructor(){super(...arguments);p(this,"type",J.ArrowLeft);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex-1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,-s,0)}}class xx extends me{constructor(){super(...arguments);p(this,"type",J.ArrowUp);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex-1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,0,-s)}}class wx extends me{constructor(){super(...arguments);p(this,"type",J.ArrowDown);p(this,"worker",new gs)}enable(e,n){return!0}work(e,n){const o=n.docState.docMode;if((o===ue.SLIDE_EDIT||o===ue.SLIDE_PLAY)&&n.getSelectNodes().size===0){const i=n.docState.slideStatus.currentIndex+1;n.slideManager.jumpToWhenEditing(i,n);return}const s=e.shiftKey?15:1;this.worker.work(n,0,s)}}class Px extends me{constructor(){super(...arguments);p(this,"type",J.Enter)}enable(e){return!0}work(e,n){const o=[...n.getSelectNodes()];if(o.length!==1)return;const s=o[0];if(s.type===v.SlideContainer||s.type===v.Section){const i=[...s.children].map(a=>a.id);n.execAction(new W),n.execAction(xe.create(i)),n.execAction(new z);return}(s.type===v.Shape||s.type===v.CheckboxText)&&this.focusSelectionText(s,n)}focusSelectionText(e,n){if(e.isEmptyText()){n.execAction(new W);const o=Fe.head();n.execAction(ee.focus(e.id,o)),n.execAction(new z);return}n.execAction(new W),n.execAction(ee.selection(e.id,Fe.head(),e.renderText.tailTextCursorPosition())),n.execAction(new z)}}const Ml=new Map([[J.Delete,[new xl]],[J.Backspace,[new lx]],[J.ArrowRight,[new gx]],[J.ArrowLeft,[new yx]],[J.ArrowUp,[new xx]],[J.ArrowDown,[new wx]],[J.Digit1,[new ux]],[J.Digit2,[new px]],[J.Digit3,[new fx]],[J.KeyA,[new ex,new Ky]],[J.KeyC,[new hx,new Zy,new Vy]],[J.KeyD,[new Jy]],[J.KeyF,[new rx]],[J.KeyV,[new qy]],[J.KeyL,[new bl]],[J.KeyS,[new Qy]],[J.KeyR,[new wl]],[J.KeyT,[new ml]],[J.KeyH,[new dx]],[J.KeyZ,[new Ar,new Nr]],[J.KeyG,[new ax,new ix]],[J.Escape,[new Pl]],[J.Space,[new cx]],[J.ShiftLeft,[new Sl]],[J.ShiftRight,[new Sl]],[J.BracketLeft,[new ox,new tx]],[J.BracketRight,[new sx,new nx]],[J.Enter,[new Px]]]);class vl{constructor(t){p(this,"textConfig");p(this,"normalConfig");p(this,"context");this.context=t,this.textConfig=new Cr(yl),this.normalConfig=new Cr(Ml)}keyDown(t,e){const n=this.getHotKey(t);n&&(n.shouldPreventDefault()&&(t.preventDefault(),t.stopPropagation()),n.keyDown(t,e))}keyUp(t,e){const n=this.getHotKey(t);n&&(n.shouldPreventDefault()&&(t.preventDefault(),t.stopPropagation()),n.keyUp(t,e))}getHotKey(t){return this.context.inputManager.isEdit()?this.textConfig.getKey(t):this.normalConfig.getKey(t)}}class Il{constructor(t){p(this,"eventCtx");p(this,"hotKeyManager");p(this,"onKeyDown",t=>{this.onEnable(t)&&this.hotKeyManager.keyDown(t,this.eventCtx)});p(this,"onKeyUp",t=>{this.onEnable(t)&&this.hotKeyManager.keyUp(t,this.eventCtx)});this.eventCtx=t,this.hotKeyManager=new vl(t)}start(){document.addEventListener("keydown",this.onKeyDown,!0),document.addEventListener("keyup",this.onKeyUp,!0)}stop(){document.removeEventListener("keydown",this.onKeyDown,!0),document.removeEventListener("keyup",this.onKeyUp,!0)}onEnable(t){return this.eventCtx.docState.canEdit()?t.target===this.eventCtx.inputManager.renderInput.inputDom?!0:!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement):!1}}class mx{constructor(t){p(this,"ctx");this.ctx=t,t.actionManager.addNetworkPlugin(this)}addMessage(t){}addActionGroup(t){}initWebsocket(){}start(){}stop(){}onEnable(t){return!0}}class bx{static getOolongApp(){const t=new hr,e=new Mr(t),n=e.appContext,o=new Wo(n,t),s=new Tr(n),r=new ll(n),i=new Il(n),a=new Lr(n),c=new Gc(n);return e.registerPlugin(o),e.registerPlugin(s),e.registerPlugin(r),e.registerPlugin(i),e.registerPlugin(a),e.registerPlugin(c),e}static getReadOnlyApp(){const t=new hr,e=new Mr(t),n=e.appContext,o=new Wo(n,t),s=new Tr(n),r=new Lr(n);return e.registerPlugin(o),e.registerPlugin(s),e.registerPlugin(r),e}}T.ANCHOR_COLOR=Ur,T.ANCHOR_HOVER_RADIUS=Ms,T.ANCHOR_OFFSET=Fr,T.ANCHOR_RADIUS=Yr,T.AbsActionExecutor=ln,T.AbsActionLog=gn,T.AbsAlignHandler=An,T.AbsAlignSideHandler=$s,T.AbsArrowKey=ko,T.AbsAuxGraphic=Me,T.AbsCreateDragProcessor=Qo,T.AbsDetector=Ke,T.AbsDrawer=Pt,T.AbsInputHandler=fs,T.AbsInteractConfig=na,T.AbsMainMode=pn,T.AbsNetworkPlugin=Xl,T.AbsNodeManager=Qc,T.AbsPastePosHandler=xr,T.AbsProps=ct,T.AbsResourceInstance=tl,T.AbsStatusHandler=bt,T.AbsStretchProcessor=Go,T.AbsSubMode=Ot,T.AbsTextSelectionHandler=ss,T.ActionCache=Bc,T.ActionLogGroup=as,T.ActionManager=Ec,T.ActionMeta=pc,T.ActionType=Xe,T.AddExecutor=bc,T.AddNodeLog=Le,T.AffineMatrix=re,T.AlignBottomHandler=Vi,T.AlignHeightSideHandler=Ji,T.AlignLeftHandler=Ki,T.AlignLine=ni,T.AlignMoveWorker=Zi,T.AlignRightHandler=Qi,T.AlignStretchLine=oi,T.AlignStretchWorker=ea,T.AlignTopHandler=ji,T.AlignWidthSideHandler=qi,T.AlignWorker=dn,T.AppEventContext=Xc,T.AppStage=bx,T.ArrowDownKey=gl,T.ArrowLeftKey=pl,T.ArrowProps=lt,T.ArrowRightKey=ul,T.ArrowUpKey=fl,T.AuxGraphicFactory=vs,T.AuxUtils=qr,T.AuxiliaryManager=hi,T.AuxiliaryType=k,T.BLOCK_COLOR=bs,T.BaseProps=ie,T.BorderProps=Ae,T.CanvasConfig=Oy,T.CanvasContainer=Wy,T.CanvasInput=Fy,T.CanvasRender=Pr,T.CheckSizeProps=vn,T.CheckStatusProps=Qt,T.ClearFocusNodeHandler=or,T.ClickExpandShapeHandler=Na,T.ClickHandler=qe,T.ClickMode=un,T.ClickProcessor=jt,T.ClickTextHandler=Aa,T.CollaborationManager=Ch,T.ColorProps=tt,T.ConnectProps=Rt,T.ConnectorPoint=zl,T.ControlPoint=Wl,T.CopyPasteManager=Yc,T.CopyPastePlugin=Gc,T.CopyPasteUtils=xn,T.CreateLineMode=uc,T.CreateRectBound=ei,T.CreateRectMode=oc,T.CreateTextMode=rc,T.CropProps=Mn,T.CursorProcessor=Ga,T.DHPCanvas=Ir,T.DbClickMode=js,T.DefaultBorderColorShape=Tf,T.DefaultClickMode=Ea,T.DefaultClickProcessor=Ra,T.DefaultColorShape=If,T.DefaultFont=Cd,T.DefaultLineHeight=Rd,T.DefaultMode=Ja,T.DeleteKey=xl,T.DetectorEnum=F,T.DiffParaHandler=gc,T.DocMode=ue,T.DocState=Kc,T.DownAndMoveStreamMode=dt,T.DragLineEndProcessor=ja,T.DragMode=Ia,T.DragProcessor=va,T.DragSelectTextMode=ia,T.DragSelectTextProcessor=ra,T.EditTextWorker=wo,T.EmptyNetworkPlugin=mx,T.EmptyPlacePosHandler=Fc,T.EndExecutor=Tc,T.EndLog=z,T.EnterHotKey=hl,T.EscKey=Pl,T.ExecutorManager=Nc,T.ExpandDetector=ec,T.ExpandShapeButton=ti,T.FocusEnum=Lt,T.FocusNodeHandler=tr,T.GRAY_COLOR=Gr,T.GraphemeSplit=Ro,T.GraphicNode=en,T.GraphicUtils=S,T.GroupMode=qs,T.GroupProcessor=La,T.HOVER_ANCHOR_COLOR=_r,T.HOVER_BOUND_COLOR=Gt,T.HighlightRects=Kr,T.HotKey=me,T.HotKeyConfig=Cr,T.HotKeyManager=vl,T.HoverBound=$r,T.HoverNodeDetector=sa,T.HoverProcessor=za,T.ImageUtils=Pc,T.InputCompositionEndHandler=cl,T.InputCompositionHandler=al,T.InputEventPlugin=ll,T.InputNormalHandler=il,T.InteractConfig=hr,T.InteractiveEventType=be,T.InteractiveManager=$i,T.InteractiveUtils=Ze,T.IntlSplit=xc,T.KeyCode=J,T.KeyEventPlugin=Il,T.LKey=bl,T.LineArrowType=it,T.LineCreateDragProcessor=dc,T.LineDashType=et,T.LineEndPointDetector=tc,T.LineProps=je,T.LineShapeType=he,T.LineSpacing=Ad,T.LinkNode=Bo,T.MAX_SCALE=yr,T.MIN_SCALE=gr,T.MOVE_ALIGN_BUFFER=Ys,T.MainTextId=Bd,T.MeasureWorker=kf,T.MobileUtils=Hc,T.MoveLayerWorker=yo,T.MultiSelectBound=Vr,T.MultiSelectHandler=ai,T.NodeDetector=oa,T.NodeFactory=It,T.NodeManager=Jc,T.NodeSideEnum=Or,T.NodeTextPadding=le,T.NodeType=v,T.NormalMode=Ua,T.NormalPastePosHandler=Wc,T.NormalResourceInstance=nl,T.OolongAIAPI=jc,T.OolongAPI=$c,T.OolongApp=Mr,T.OolongGroup=mo,T.OolongImgNode=ro,T.OolongLine=Ct,T.OolongNode=vt,T.OolongSVGNode=Po,T.OolongSVGUtils=yn,T.OptionHelper=ri,T.PREVIEW_ROOT_ID=Xr,T.ParagraphSpacing=Nd,T.PasteNodeHandler=cs,T.Permission=Vc,T.Point=P,T.PointerEventPlugin=Wo,T.PolyLineControlPointDetector=hc,T.PosPasteType=Kt,T.PropType=I,T.QuadBezierCurve=Fl,T.RKey=wl,T.ROOT_ID=Sn,T.Rect=D,T.RectCreateDragProcessor=nc,T.RedoKey=Ar,T.RemoveExecutor=Sc,T.RemoveNodeLog=At,T.RenderManager=Dc,T.RenderText=ho,T.ResourceEnumType=fo,T.ResourceManager=ol,T.ResourceType=zn,T.RootNode=pr,T.RotateDetector=Jo,T.RotateMode=Ka,T.RotateProcessor=Va,T.SELECT_BOUND_COLOR=Qe,T.SELECT_GROUP_COLOR=Ss,T.SLIDE_X_GAP=nt,T.SLIDE_Y_GAP=xt,T.STRETCH_ALIGN_BUFFER=Gs,T.STRETCH_ALIGN_OFFSET=Us,T.STRETCH_WIDTH=Wr,T.SameParaDiffLineHandler=ur,T.SameParaSameLineHandler=dr,T.SectionType=kn,T.SelectGroup=Qr,T.SelectManager=li,T.SelectNodeExecutor=vc,T.SelectNodeLog=xe,T.ShapeProps=Oe,T.ShapeType=K,T.ShiftDownNodeHandler=er,T.ShiftUpClickHandler=nr,T.SingleSelectBound=jr,T.SingleStatusHandler=ii,T.SingleStretchMode=ua,T.SingleStretchProcessorV2=da,T.SlotKeyType=ze,T.SlotManager=ci,T.StartExecutor=Ic,T.StartLog=W,T.StreamMode=Nn,T.StreamProcessor=ht,T.StretchAlignType=_e,T.StretchDetector=Fo,T.StretchHotBuffer=Ih,T.StretchMode=$a,T.StretchProcessorV2=_a,T.StretchRect=Jr,T.StretchType=V,T.TEXT_QUOTE_ALPHA=Gi,T.TEXT_QUOTE_LINE_WIDTH=Oo,T.TEXT_QUOTE_PADDING=Yi,T.TEXT_SELECTION_COLOR=zr,T.TKey=ml,T.TextAlignType=at,T.TextCharacter=As,T.TextCreateDragProcessor=sc,T.TextCursorMoveWorker=lo,T.TextCursorPosition=Fe,T.TextDeleteKey=dl,T.TextFocusExecutor=Lc,T.TextFocusLog=ee,T.TextLine=Yn,T.TextParagraph=Cs,T.TextParagraphProps=qt,T.TextParagraphQuoteProps=Dt,T.TextProps=Ge,T.TextSelection=Zr,T.TextSelectionDeleteWorker=os,T.TextSelectionWorker=yc,T.TextSizeMode=We,T.TextUtils=sn,T.TextWord=Ui,T.ToolEnum=ye,T.ToolManager=Wa,T.UndoKey=Nr,T.UndoRedoManager=kc,T.UpdateExecutor=Mc,T.UpdateNodeLog=U,T.VisibleBuffer=Ed,T.WHITE_COLOR=Ht,T.WheelEventPlugin=Tr,T.WheelUtils=Yy,T.WidgetEnum=Un,T.WindowResizePlugin=Lr,T.actionExecutors=Cc,T.convertAction2MsgData=rg,T.convertActionData2Log=ig,T.disableAlignNodeType=Cn,T.disableAlignSideSet=_s,T.graphemeSplitter=Eo,T.intlSplitter=Bf,T.isContains=Lf,T.limitLineWidth=kd,T.normalKeyMap=Ml,T.textKeyMap=yl,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});