@antv/g6 5.0.0-beta.34 → 5.0.0-beta.36

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 (959) hide show
  1. package/LICENSE +21 -0
  2. package/dist/g6.min.js +2 -2
  3. package/dist/lib/animations/types.d.ts +7 -8
  4. package/dist/lib/behaviors/base-behavior.d.ts +2 -1
  5. package/dist/lib/behaviors/brush-select.d.ts +139 -53
  6. package/dist/lib/behaviors/click-element.d.ts +40 -17
  7. package/dist/lib/behaviors/collapse-expand.d.ts +17 -1
  8. package/dist/lib/behaviors/create-edge.d.ts +25 -4
  9. package/dist/lib/behaviors/drag-canvas.d.ts +34 -8
  10. package/dist/lib/behaviors/drag-element-force.d.ts +44 -4
  11. package/dist/lib/behaviors/drag-element.d.ts +107 -27
  12. package/dist/lib/behaviors/focus-element.d.ts +18 -6
  13. package/dist/lib/behaviors/hover-element.d.ts +28 -6
  14. package/dist/lib/behaviors/index.d.ts +2 -0
  15. package/dist/lib/behaviors/lasso-select.d.ts +36 -14
  16. package/dist/lib/behaviors/scroll-canvas.d.ts +85 -0
  17. package/dist/lib/behaviors/types.d.ts +2 -2
  18. package/dist/lib/behaviors/zoom-canvas.d.ts +42 -15
  19. package/dist/lib/constants/change.d.ts +50 -1
  20. package/dist/lib/constants/element.d.ts +3 -2
  21. package/dist/lib/constants/events/canvas.d.ts +90 -18
  22. package/dist/lib/constants/events/common.d.ts +100 -20
  23. package/dist/lib/constants/events/container.d.ts +10 -2
  24. package/dist/lib/constants/events/edge.d.ts +70 -14
  25. package/dist/lib/constants/events/graph.d.ts +143 -27
  26. package/dist/lib/constants/events/history.d.ts +38 -0
  27. package/dist/lib/constants/events/index.d.ts +1 -0
  28. package/dist/lib/constants/events/node.d.ts +85 -17
  29. package/dist/lib/constants/registry.d.ts +50 -10
  30. package/dist/lib/elements/combos/base-combo.d.ts +33 -23
  31. package/dist/lib/elements/combos/circle.d.ts +14 -2
  32. package/dist/lib/elements/combos/rect.d.ts +12 -2
  33. package/dist/lib/elements/edges/base-edge.d.ts +63 -32
  34. package/dist/lib/elements/edges/cubic-horizontal.d.ts +18 -0
  35. package/dist/lib/elements/edges/cubic-vertical.d.ts +18 -0
  36. package/dist/lib/elements/edges/cubic.d.ts +19 -1
  37. package/dist/lib/elements/edges/line.d.ts +12 -2
  38. package/dist/lib/elements/edges/polyline.d.ts +21 -0
  39. package/dist/lib/elements/edges/quadratic.d.ts +15 -0
  40. package/dist/lib/elements/nodes/base-node.d.ts +67 -67
  41. package/dist/lib/elements/nodes/circle.d.ts +10 -2
  42. package/dist/lib/elements/nodes/diamond.d.ts +12 -4
  43. package/dist/lib/elements/nodes/donut.d.ts +20 -20
  44. package/dist/lib/elements/nodes/ellipse.d.ts +12 -1
  45. package/dist/lib/elements/nodes/hexagon.d.ts +17 -7
  46. package/dist/lib/elements/nodes/html.d.ts +16 -3
  47. package/dist/lib/elements/nodes/image.d.ts +22 -2
  48. package/dist/lib/elements/nodes/rect.d.ts +10 -2
  49. package/dist/lib/elements/nodes/star.d.ts +18 -9
  50. package/dist/lib/elements/nodes/triangle.d.ts +17 -7
  51. package/dist/lib/elements/shapes/badge.d.ts +3 -2
  52. package/dist/lib/elements/shapes/base-shape.d.ts +2 -3
  53. package/dist/lib/elements/shapes/contour.d.ts +66 -0
  54. package/dist/lib/elements/shapes/icon.d.ts +3 -2
  55. package/dist/lib/elements/shapes/index.d.ts +3 -0
  56. package/dist/lib/elements/shapes/label.d.ts +14 -5
  57. package/dist/lib/elements/shapes/polygon.d.ts +29 -0
  58. package/dist/lib/exports.d.ts +25 -23
  59. package/dist/lib/layouts/base-layout.d.ts +10 -0
  60. package/dist/lib/layouts/index.d.ts +1 -0
  61. package/dist/lib/layouts/types.d.ts +11 -4
  62. package/dist/lib/plugins/base-plugin.d.ts +2 -1
  63. package/dist/lib/plugins/bubble-sets.d.ts +116 -0
  64. package/dist/lib/plugins/camera-setting.d.ts +26 -10
  65. package/dist/lib/plugins/contextmenu.d.ts +64 -40
  66. package/dist/lib/plugins/grid-line.d.ts +86 -10
  67. package/dist/lib/plugins/history/index.d.ts +48 -10
  68. package/dist/lib/plugins/history/utils.d.ts +1 -11
  69. package/dist/lib/plugins/hull/index.d.ts +71 -15
  70. package/dist/lib/plugins/index.d.ts +4 -0
  71. package/dist/lib/plugins/legend.d.ts +95 -15
  72. package/dist/lib/plugins/timebar.d.ts +234 -0
  73. package/dist/lib/plugins/toolbar/index.d.ts +35 -28
  74. package/dist/lib/plugins/toolbar/util.d.ts +9 -10
  75. package/dist/lib/plugins/tooltip.d.ts +95 -20
  76. package/dist/lib/plugins/watermark.d.ts +173 -33
  77. package/dist/lib/registry/index.d.ts +1 -1
  78. package/dist/lib/registry/types.d.ts +2 -2
  79. package/dist/lib/runtime/behavior.d.ts +5 -1
  80. package/dist/lib/runtime/data.d.ts +15 -9
  81. package/dist/lib/runtime/element.d.ts +5 -10
  82. package/dist/lib/runtime/graph.d.ts +529 -41
  83. package/dist/lib/runtime/layout.d.ts +5 -17
  84. package/dist/lib/runtime/types.d.ts +3 -3
  85. package/dist/lib/runtime/viewport.d.ts +2 -2
  86. package/dist/lib/spec/behavior.d.ts +20 -2
  87. package/dist/lib/spec/canvas.d.ts +15 -4
  88. package/dist/lib/spec/data.d.ts +93 -2
  89. package/dist/lib/spec/element/combo.d.ts +5 -13
  90. package/dist/lib/spec/element/edge.d.ts +1 -8
  91. package/dist/lib/spec/element/node.d.ts +1 -14
  92. package/{lib/spec/spec.d.ts → dist/lib/spec/graph.d.ts} +13 -5
  93. package/dist/lib/spec/index.d.ts +1 -1
  94. package/dist/lib/spec/plugin.d.ts +22 -2
  95. package/dist/lib/spec/theme.d.ts +1 -4
  96. package/dist/lib/spec/viewport.d.ts +20 -24
  97. package/dist/lib/themes/types.d.ts +0 -1
  98. package/dist/lib/transforms/process-parallel-edges.d.ts +1 -1
  99. package/dist/lib/types/combo.d.ts +23 -0
  100. package/dist/lib/types/data.d.ts +2 -2
  101. package/dist/lib/types/edge.d.ts +73 -9
  102. package/dist/lib/types/element.d.ts +3 -0
  103. package/dist/lib/types/event.d.ts +14 -2
  104. package/dist/lib/types/history.d.ts +51 -0
  105. package/dist/lib/types/index.d.ts +2 -0
  106. package/dist/lib/types/layout.d.ts +9 -0
  107. package/dist/lib/types/node.d.ts +111 -7
  108. package/dist/lib/types/point.d.ts +1 -2
  109. package/dist/lib/types/prefix.d.ts +11 -1
  110. package/dist/lib/types/viewport.d.ts +5 -7
  111. package/dist/lib/utils/animation.d.ts +5 -19
  112. package/dist/lib/utils/bbox.d.ts +1 -2
  113. package/dist/lib/utils/data.d.ts +2 -2
  114. package/dist/lib/utils/dom.d.ts +6 -0
  115. package/dist/lib/utils/edge.d.ts +11 -2
  116. package/dist/lib/utils/element.d.ts +8 -10
  117. package/dist/lib/utils/event/events.d.ts +1 -1
  118. package/dist/lib/utils/event/index.d.ts +1 -1
  119. package/dist/lib/utils/layout.d.ts +45 -0
  120. package/dist/lib/utils/palette.d.ts +1 -1
  121. package/dist/lib/utils/point.d.ts +11 -2
  122. package/dist/lib/utils/relation.d.ts +2 -2
  123. package/dist/lib/utils/transform.d.ts +10 -0
  124. package/dist/lib/utils/visibility.d.ts +1 -1
  125. package/dist/lib/utils/watermark.d.ts +1 -1
  126. package/esm/animations/executor.js +23 -11
  127. package/esm/animations/executor.js.map +1 -1
  128. package/esm/animations/types.d.ts +7 -8
  129. package/esm/behaviors/base-behavior.d.ts +2 -1
  130. package/esm/behaviors/brush-select.d.ts +139 -53
  131. package/esm/behaviors/brush-select.js +187 -113
  132. package/esm/behaviors/brush-select.js.map +1 -1
  133. package/esm/behaviors/click-element.d.ts +40 -17
  134. package/esm/behaviors/click-element.js +9 -0
  135. package/esm/behaviors/click-element.js.map +1 -1
  136. package/esm/behaviors/collapse-expand.d.ts +17 -1
  137. package/esm/behaviors/collapse-expand.js +11 -2
  138. package/esm/behaviors/collapse-expand.js.map +1 -1
  139. package/esm/behaviors/create-edge.d.ts +25 -4
  140. package/esm/behaviors/create-edge.js +14 -0
  141. package/esm/behaviors/create-edge.js.map +1 -1
  142. package/esm/behaviors/drag-canvas.d.ts +34 -8
  143. package/esm/behaviors/drag-canvas.js +24 -0
  144. package/esm/behaviors/drag-canvas.js.map +1 -1
  145. package/esm/behaviors/drag-element-force.d.ts +44 -4
  146. package/esm/behaviors/drag-element-force.js +47 -8
  147. package/esm/behaviors/drag-element-force.js.map +1 -1
  148. package/esm/behaviors/drag-element.d.ts +107 -27
  149. package/esm/behaviors/drag-element.js +73 -0
  150. package/esm/behaviors/drag-element.js.map +1 -1
  151. package/esm/behaviors/focus-element.d.ts +18 -6
  152. package/esm/behaviors/focus-element.js +16 -15
  153. package/esm/behaviors/focus-element.js.map +1 -1
  154. package/esm/behaviors/hover-element.d.ts +28 -6
  155. package/esm/behaviors/hover-element.js +9 -0
  156. package/esm/behaviors/hover-element.js.map +1 -1
  157. package/esm/behaviors/index.d.ts +2 -0
  158. package/esm/behaviors/index.js +1 -0
  159. package/esm/behaviors/index.js.map +1 -1
  160. package/esm/behaviors/lasso-select.d.ts +36 -14
  161. package/esm/behaviors/lasso-select.js +43 -56
  162. package/esm/behaviors/lasso-select.js.map +1 -1
  163. package/esm/behaviors/scroll-canvas.d.ts +85 -0
  164. package/esm/behaviors/scroll-canvas.js +101 -0
  165. package/esm/behaviors/scroll-canvas.js.map +1 -0
  166. package/esm/behaviors/types.d.ts +2 -2
  167. package/esm/behaviors/zoom-canvas.d.ts +42 -15
  168. package/esm/behaviors/zoom-canvas.js +26 -1
  169. package/esm/behaviors/zoom-canvas.js.map +1 -1
  170. package/esm/constants/change.d.ts +50 -1
  171. package/esm/constants/change.js +50 -1
  172. package/esm/constants/change.js.map +1 -1
  173. package/esm/constants/element.d.ts +3 -2
  174. package/esm/constants/element.js +3 -2
  175. package/esm/constants/element.js.map +1 -1
  176. package/esm/constants/events/canvas.d.ts +90 -18
  177. package/esm/constants/events/canvas.js +90 -18
  178. package/esm/constants/events/canvas.js.map +1 -1
  179. package/esm/constants/events/common.d.ts +100 -20
  180. package/esm/constants/events/common.js +100 -20
  181. package/esm/constants/events/common.js.map +1 -1
  182. package/esm/constants/events/container.d.ts +10 -2
  183. package/esm/constants/events/container.js +10 -2
  184. package/esm/constants/events/container.js.map +1 -1
  185. package/esm/constants/events/edge.d.ts +70 -14
  186. package/esm/constants/events/edge.js +70 -14
  187. package/esm/constants/events/edge.js.map +1 -1
  188. package/esm/constants/events/graph.d.ts +143 -27
  189. package/esm/constants/events/graph.js +142 -26
  190. package/esm/constants/events/graph.js.map +1 -1
  191. package/esm/constants/events/history.d.ts +38 -0
  192. package/esm/constants/events/history.js +40 -0
  193. package/esm/constants/events/history.js.map +1 -0
  194. package/esm/constants/events/index.d.ts +1 -0
  195. package/esm/constants/events/index.js +1 -0
  196. package/esm/constants/events/index.js.map +1 -1
  197. package/esm/constants/events/node.d.ts +85 -17
  198. package/esm/constants/events/node.js +85 -17
  199. package/esm/constants/events/node.js.map +1 -1
  200. package/esm/constants/registry.d.ts +50 -10
  201. package/esm/constants/registry.js +50 -10
  202. package/esm/constants/registry.js.map +1 -1
  203. package/esm/elements/combos/base-combo.d.ts +33 -23
  204. package/esm/elements/combos/base-combo.js +11 -1
  205. package/esm/elements/combos/base-combo.js.map +1 -1
  206. package/esm/elements/combos/circle.d.ts +14 -2
  207. package/esm/elements/combos/circle.js +10 -0
  208. package/esm/elements/combos/circle.js.map +1 -1
  209. package/esm/elements/combos/rect.d.ts +12 -2
  210. package/esm/elements/combos/rect.js +8 -5
  211. package/esm/elements/combos/rect.js.map +1 -1
  212. package/esm/elements/edges/base-edge.d.ts +63 -32
  213. package/esm/elements/edges/base-edge.js +10 -8
  214. package/esm/elements/edges/base-edge.js.map +1 -1
  215. package/esm/elements/edges/cubic-horizontal.d.ts +18 -0
  216. package/esm/elements/edges/cubic-horizontal.js +9 -0
  217. package/esm/elements/edges/cubic-horizontal.js.map +1 -1
  218. package/esm/elements/edges/cubic-vertical.d.ts +18 -0
  219. package/esm/elements/edges/cubic-vertical.js +9 -0
  220. package/esm/elements/edges/cubic-vertical.js.map +1 -1
  221. package/esm/elements/edges/cubic.d.ts +19 -1
  222. package/esm/elements/edges/cubic.js +8 -0
  223. package/esm/elements/edges/cubic.js.map +1 -1
  224. package/esm/elements/edges/line.d.ts +12 -2
  225. package/esm/elements/edges/line.js +5 -1
  226. package/esm/elements/edges/line.js.map +1 -1
  227. package/esm/elements/edges/polyline.d.ts +21 -0
  228. package/esm/elements/edges/polyline.js +5 -0
  229. package/esm/elements/edges/polyline.js.map +1 -1
  230. package/esm/elements/edges/quadratic.d.ts +15 -0
  231. package/esm/elements/edges/quadratic.js +5 -0
  232. package/esm/elements/edges/quadratic.js.map +1 -1
  233. package/esm/elements/nodes/base-node.d.ts +67 -67
  234. package/esm/elements/nodes/base-node.js +21 -7
  235. package/esm/elements/nodes/base-node.js.map +1 -1
  236. package/esm/elements/nodes/circle.d.ts +10 -2
  237. package/esm/elements/nodes/circle.js +3 -1
  238. package/esm/elements/nodes/circle.js.map +1 -1
  239. package/esm/elements/nodes/diamond.d.ts +12 -4
  240. package/esm/elements/nodes/diamond.js +4 -2
  241. package/esm/elements/nodes/diamond.js.map +1 -1
  242. package/esm/elements/nodes/donut.d.ts +20 -20
  243. package/esm/elements/nodes/donut.js +20 -7
  244. package/esm/elements/nodes/donut.js.map +1 -1
  245. package/esm/elements/nodes/ellipse.d.ts +12 -1
  246. package/esm/elements/nodes/ellipse.js +5 -0
  247. package/esm/elements/nodes/ellipse.js.map +1 -1
  248. package/esm/elements/nodes/hexagon.d.ts +17 -7
  249. package/esm/elements/nodes/hexagon.js +6 -1
  250. package/esm/elements/nodes/hexagon.js.map +1 -1
  251. package/esm/elements/nodes/html.d.ts +16 -3
  252. package/esm/elements/nodes/html.js +4 -1
  253. package/esm/elements/nodes/html.js.map +1 -1
  254. package/esm/elements/nodes/image.d.ts +22 -2
  255. package/esm/elements/nodes/image.js +10 -3
  256. package/esm/elements/nodes/image.js.map +1 -1
  257. package/esm/elements/nodes/rect.d.ts +10 -2
  258. package/esm/elements/nodes/rect.js +5 -2
  259. package/esm/elements/nodes/rect.js.map +1 -1
  260. package/esm/elements/nodes/star.d.ts +18 -9
  261. package/esm/elements/nodes/star.js +6 -1
  262. package/esm/elements/nodes/star.js.map +1 -1
  263. package/esm/elements/nodes/triangle.d.ts +17 -7
  264. package/esm/elements/nodes/triangle.js +6 -1
  265. package/esm/elements/nodes/triangle.js.map +1 -1
  266. package/esm/elements/shapes/badge.d.ts +3 -2
  267. package/esm/elements/shapes/base-shape.d.ts +2 -3
  268. package/esm/elements/shapes/base-shape.js +34 -5
  269. package/esm/elements/shapes/base-shape.js.map +1 -1
  270. package/esm/elements/shapes/contour.d.ts +66 -0
  271. package/esm/elements/shapes/contour.js +36 -0
  272. package/esm/elements/shapes/contour.js.map +1 -0
  273. package/esm/elements/shapes/icon.d.ts +3 -2
  274. package/esm/elements/shapes/icon.js +4 -1
  275. package/esm/elements/shapes/icon.js.map +1 -1
  276. package/esm/elements/shapes/index.d.ts +3 -0
  277. package/esm/elements/shapes/index.js +1 -0
  278. package/esm/elements/shapes/index.js.map +1 -1
  279. package/esm/elements/shapes/label.d.ts +14 -5
  280. package/esm/elements/shapes/label.js +2 -1
  281. package/esm/elements/shapes/label.js.map +1 -1
  282. package/esm/elements/shapes/polygon.d.ts +29 -0
  283. package/esm/elements/{nodes → shapes}/polygon.js +1 -1
  284. package/esm/elements/shapes/polygon.js.map +1 -0
  285. package/esm/exports.d.ts +25 -23
  286. package/esm/exports.js +8 -18
  287. package/esm/exports.js.map +1 -1
  288. package/esm/layouts/base-layout.d.ts +10 -0
  289. package/esm/layouts/base-layout.js +9 -0
  290. package/esm/layouts/base-layout.js.map +1 -0
  291. package/esm/layouts/index.d.ts +1 -0
  292. package/esm/layouts/index.js +1 -0
  293. package/esm/layouts/index.js.map +1 -1
  294. package/esm/layouts/types.d.ts +11 -4
  295. package/esm/plugins/base-plugin.d.ts +2 -1
  296. package/esm/plugins/bubble-sets.d.ts +116 -0
  297. package/esm/plugins/bubble-sets.js +279 -0
  298. package/esm/plugins/bubble-sets.js.map +1 -0
  299. package/esm/plugins/camera-setting.d.ts +26 -10
  300. package/esm/plugins/camera-setting.js +7 -0
  301. package/esm/plugins/camera-setting.js.map +1 -1
  302. package/esm/plugins/contextmenu.d.ts +64 -40
  303. package/esm/plugins/contextmenu.js +44 -34
  304. package/esm/plugins/contextmenu.js.map +1 -1
  305. package/esm/plugins/grid-line.d.ts +86 -10
  306. package/esm/plugins/grid-line.js +26 -7
  307. package/esm/plugins/grid-line.js.map +1 -1
  308. package/esm/plugins/history/index.d.ts +48 -10
  309. package/esm/plugins/history/index.js +38 -11
  310. package/esm/plugins/history/index.js.map +1 -1
  311. package/esm/plugins/history/utils.d.ts +1 -11
  312. package/esm/plugins/history/utils.js +6 -2
  313. package/esm/plugins/history/utils.js.map +1 -1
  314. package/esm/plugins/hull/index.d.ts +71 -15
  315. package/esm/plugins/hull/index.js +72 -21
  316. package/esm/plugins/hull/index.js.map +1 -1
  317. package/esm/plugins/index.d.ts +4 -0
  318. package/esm/plugins/index.js +2 -0
  319. package/esm/plugins/index.js.map +1 -1
  320. package/esm/plugins/legend.d.ts +95 -15
  321. package/esm/plugins/legend.js +66 -16
  322. package/esm/plugins/legend.js.map +1 -1
  323. package/esm/plugins/timebar.d.ts +234 -0
  324. package/esm/plugins/timebar.js +261 -0
  325. package/esm/plugins/timebar.js.map +1 -0
  326. package/esm/plugins/toolbar/index.d.ts +35 -28
  327. package/esm/plugins/toolbar/index.js +11 -8
  328. package/esm/plugins/toolbar/index.js.map +1 -1
  329. package/esm/plugins/toolbar/util.d.ts +9 -10
  330. package/esm/plugins/toolbar/util.js +2 -1
  331. package/esm/plugins/toolbar/util.js.map +1 -1
  332. package/esm/plugins/tooltip.d.ts +95 -20
  333. package/esm/plugins/tooltip.js +99 -36
  334. package/esm/plugins/tooltip.js.map +1 -1
  335. package/esm/plugins/watermark.d.ts +173 -33
  336. package/esm/plugins/watermark.js +23 -9
  337. package/esm/plugins/watermark.js.map +1 -1
  338. package/esm/registry/build-in.js +10 -7
  339. package/esm/registry/build-in.js.map +1 -1
  340. package/esm/registry/index.d.ts +1 -1
  341. package/esm/registry/index.js +1 -1
  342. package/esm/registry/types.d.ts +2 -2
  343. package/esm/runtime/behavior.d.ts +5 -1
  344. package/esm/runtime/behavior.js +5 -1
  345. package/esm/runtime/behavior.js.map +1 -1
  346. package/esm/runtime/canvas.js +2 -2
  347. package/esm/runtime/canvas.js.map +1 -1
  348. package/esm/runtime/data.d.ts +15 -9
  349. package/esm/runtime/data.js +47 -33
  350. package/esm/runtime/data.js.map +1 -1
  351. package/esm/runtime/element.d.ts +5 -10
  352. package/esm/runtime/element.js +37 -31
  353. package/esm/runtime/element.js.map +1 -1
  354. package/esm/runtime/graph.d.ts +529 -41
  355. package/esm/runtime/graph.js +412 -36
  356. package/esm/runtime/graph.js.map +1 -1
  357. package/esm/runtime/layout.d.ts +5 -17
  358. package/esm/runtime/layout.js +38 -130
  359. package/esm/runtime/layout.js.map +1 -1
  360. package/esm/runtime/types.d.ts +3 -3
  361. package/esm/runtime/viewport.d.ts +2 -2
  362. package/esm/runtime/viewport.js +2 -2
  363. package/esm/spec/behavior.d.ts +20 -2
  364. package/esm/spec/canvas.d.ts +15 -4
  365. package/esm/spec/data.d.ts +93 -2
  366. package/esm/spec/element/combo.d.ts +5 -13
  367. package/esm/spec/element/edge.d.ts +1 -8
  368. package/esm/spec/element/node.d.ts +1 -14
  369. package/esm/spec/{spec.d.ts → graph.d.ts} +13 -5
  370. package/esm/spec/graph.js +2 -0
  371. package/esm/spec/graph.js.map +1 -0
  372. package/esm/spec/index.d.ts +1 -1
  373. package/esm/spec/plugin.d.ts +22 -2
  374. package/esm/spec/theme.d.ts +1 -4
  375. package/esm/spec/viewport.d.ts +20 -24
  376. package/esm/themes/base.js +25 -16
  377. package/esm/themes/base.js.map +1 -1
  378. package/esm/themes/types.d.ts +0 -1
  379. package/esm/transforms/arrange-draw-order.js +17 -12
  380. package/esm/transforms/arrange-draw-order.js.map +1 -1
  381. package/esm/transforms/collapse-expand-combo.js +29 -20
  382. package/esm/transforms/collapse-expand-combo.js.map +1 -1
  383. package/esm/transforms/process-parallel-edges.d.ts +1 -1
  384. package/esm/types/combo.d.ts +23 -0
  385. package/esm/types/combo.js +2 -0
  386. package/esm/types/combo.js.map +1 -0
  387. package/esm/types/data.d.ts +2 -2
  388. package/esm/types/edge.d.ts +73 -9
  389. package/esm/types/element.d.ts +3 -0
  390. package/esm/types/event.d.ts +14 -2
  391. package/esm/types/history.d.ts +51 -0
  392. package/esm/types/history.js +2 -0
  393. package/esm/types/history.js.map +1 -0
  394. package/esm/types/index.d.ts +2 -0
  395. package/esm/types/layout.d.ts +9 -0
  396. package/esm/types/layout.js +2 -0
  397. package/esm/types/layout.js.map +1 -0
  398. package/esm/types/node.d.ts +111 -7
  399. package/esm/types/point.d.ts +1 -2
  400. package/esm/types/prefix.d.ts +11 -1
  401. package/esm/types/viewport.d.ts +5 -7
  402. package/esm/utils/animation.d.ts +5 -19
  403. package/esm/utils/animation.js +1 -36
  404. package/esm/utils/animation.js.map +1 -1
  405. package/esm/utils/bbox.d.ts +1 -2
  406. package/esm/utils/bbox.js.map +1 -1
  407. package/esm/utils/change.js +8 -1
  408. package/esm/utils/change.js.map +1 -1
  409. package/esm/utils/data.d.ts +2 -2
  410. package/esm/utils/data.js +2 -2
  411. package/esm/utils/dom.d.ts +6 -0
  412. package/esm/utils/dom.js +14 -0
  413. package/esm/utils/dom.js.map +1 -1
  414. package/esm/utils/edge.d.ts +11 -2
  415. package/esm/utils/edge.js +28 -4
  416. package/esm/utils/edge.js.map +1 -1
  417. package/esm/utils/element.d.ts +8 -10
  418. package/esm/utils/element.js +7 -6
  419. package/esm/utils/element.js.map +1 -1
  420. package/esm/utils/event/events.d.ts +1 -1
  421. package/esm/utils/event/events.js.map +1 -1
  422. package/esm/utils/event/index.d.ts +1 -1
  423. package/esm/utils/event/index.js +1 -1
  424. package/esm/utils/id.js +1 -1
  425. package/esm/utils/id.js.map +1 -1
  426. package/esm/utils/layout.d.ts +45 -0
  427. package/esm/utils/layout.js +167 -1
  428. package/esm/utils/layout.js.map +1 -1
  429. package/esm/utils/palette.d.ts +1 -1
  430. package/esm/utils/palette.js +1 -1
  431. package/esm/utils/point.d.ts +11 -2
  432. package/esm/utils/point.js +30 -28
  433. package/esm/utils/point.js.map +1 -1
  434. package/esm/utils/polygon.js +3 -6
  435. package/esm/utils/polygon.js.map +1 -1
  436. package/esm/utils/prefix.js +15 -2
  437. package/esm/utils/prefix.js.map +1 -1
  438. package/esm/utils/relation.d.ts +2 -2
  439. package/esm/utils/relation.js +2 -2
  440. package/esm/utils/symbol.js +27 -15
  441. package/esm/utils/symbol.js.map +1 -1
  442. package/esm/utils/transform.d.ts +10 -0
  443. package/esm/utils/transform.js +19 -0
  444. package/esm/utils/transform.js.map +1 -0
  445. package/esm/utils/tree.js +2 -2
  446. package/esm/utils/tree.js.map +1 -1
  447. package/esm/utils/visibility.d.ts +1 -1
  448. package/esm/utils/visibility.js +1 -1
  449. package/esm/utils/watermark.d.ts +1 -1
  450. package/esm/utils/watermark.js +1 -1
  451. package/lib/animations/executor.js +22 -10
  452. package/lib/animations/executor.js.map +1 -1
  453. package/lib/animations/types.d.ts +7 -8
  454. package/lib/behaviors/base-behavior.d.ts +2 -1
  455. package/lib/behaviors/brush-select.d.ts +139 -53
  456. package/lib/behaviors/brush-select.js +188 -113
  457. package/lib/behaviors/brush-select.js.map +1 -1
  458. package/lib/behaviors/click-element.d.ts +40 -17
  459. package/lib/behaviors/click-element.js +9 -0
  460. package/lib/behaviors/click-element.js.map +1 -1
  461. package/lib/behaviors/collapse-expand.d.ts +17 -1
  462. package/lib/behaviors/collapse-expand.js +11 -2
  463. package/lib/behaviors/collapse-expand.js.map +1 -1
  464. package/lib/behaviors/create-edge.d.ts +25 -4
  465. package/lib/behaviors/create-edge.js +14 -0
  466. package/lib/behaviors/create-edge.js.map +1 -1
  467. package/lib/behaviors/drag-canvas.d.ts +34 -8
  468. package/lib/behaviors/drag-canvas.js +24 -0
  469. package/lib/behaviors/drag-canvas.js.map +1 -1
  470. package/lib/behaviors/drag-element-force.d.ts +44 -4
  471. package/lib/behaviors/drag-element-force.js +47 -8
  472. package/lib/behaviors/drag-element-force.js.map +1 -1
  473. package/lib/behaviors/drag-element.d.ts +107 -27
  474. package/lib/behaviors/drag-element.js +73 -0
  475. package/lib/behaviors/drag-element.js.map +1 -1
  476. package/lib/behaviors/focus-element.d.ts +18 -6
  477. package/lib/behaviors/focus-element.js +16 -15
  478. package/lib/behaviors/focus-element.js.map +1 -1
  479. package/lib/behaviors/hover-element.d.ts +28 -6
  480. package/lib/behaviors/hover-element.js +9 -0
  481. package/lib/behaviors/hover-element.js.map +1 -1
  482. package/lib/behaviors/index.d.ts +2 -0
  483. package/lib/behaviors/index.js +3 -1
  484. package/lib/behaviors/index.js.map +1 -1
  485. package/lib/behaviors/lasso-select.d.ts +36 -14
  486. package/lib/behaviors/lasso-select.js +42 -55
  487. package/lib/behaviors/lasso-select.js.map +1 -1
  488. package/lib/behaviors/scroll-canvas.d.ts +85 -0
  489. package/lib/behaviors/scroll-canvas.js +105 -0
  490. package/lib/behaviors/scroll-canvas.js.map +1 -0
  491. package/lib/behaviors/types.d.ts +2 -2
  492. package/lib/behaviors/zoom-canvas.d.ts +42 -15
  493. package/lib/behaviors/zoom-canvas.js +26 -1
  494. package/lib/behaviors/zoom-canvas.js.map +1 -1
  495. package/lib/constants/change.d.ts +50 -1
  496. package/lib/constants/change.js +50 -1
  497. package/lib/constants/change.js.map +1 -1
  498. package/lib/constants/element.d.ts +3 -2
  499. package/lib/constants/element.js +3 -2
  500. package/lib/constants/element.js.map +1 -1
  501. package/lib/constants/events/canvas.d.ts +90 -18
  502. package/lib/constants/events/canvas.js +90 -18
  503. package/lib/constants/events/canvas.js.map +1 -1
  504. package/lib/constants/events/common.d.ts +100 -20
  505. package/lib/constants/events/common.js +100 -20
  506. package/lib/constants/events/common.js.map +1 -1
  507. package/lib/constants/events/container.d.ts +10 -2
  508. package/lib/constants/events/container.js +10 -2
  509. package/lib/constants/events/container.js.map +1 -1
  510. package/lib/constants/events/edge.d.ts +70 -14
  511. package/lib/constants/events/edge.js +70 -14
  512. package/lib/constants/events/edge.js.map +1 -1
  513. package/lib/constants/events/graph.d.ts +143 -27
  514. package/lib/constants/events/graph.js +142 -26
  515. package/lib/constants/events/graph.js.map +1 -1
  516. package/lib/constants/events/history.d.ts +38 -0
  517. package/lib/constants/events/history.js +43 -0
  518. package/lib/constants/events/history.js.map +1 -0
  519. package/lib/constants/events/index.d.ts +1 -0
  520. package/lib/constants/events/index.js +3 -1
  521. package/lib/constants/events/index.js.map +1 -1
  522. package/lib/constants/events/node.d.ts +85 -17
  523. package/lib/constants/events/node.js +85 -17
  524. package/lib/constants/events/node.js.map +1 -1
  525. package/lib/constants/registry.d.ts +50 -10
  526. package/lib/constants/registry.js +50 -10
  527. package/lib/constants/registry.js.map +1 -1
  528. package/lib/elements/combos/base-combo.d.ts +33 -23
  529. package/lib/elements/combos/base-combo.js +11 -1
  530. package/lib/elements/combos/base-combo.js.map +1 -1
  531. package/lib/elements/combos/circle.d.ts +14 -2
  532. package/lib/elements/combos/circle.js +10 -0
  533. package/lib/elements/combos/circle.js.map +1 -1
  534. package/lib/elements/combos/rect.d.ts +12 -2
  535. package/lib/elements/combos/rect.js +8 -5
  536. package/lib/elements/combos/rect.js.map +1 -1
  537. package/lib/elements/edges/base-edge.d.ts +63 -32
  538. package/lib/elements/edges/base-edge.js +10 -8
  539. package/lib/elements/edges/base-edge.js.map +1 -1
  540. package/lib/elements/edges/cubic-horizontal.d.ts +18 -0
  541. package/lib/elements/edges/cubic-horizontal.js +9 -0
  542. package/lib/elements/edges/cubic-horizontal.js.map +1 -1
  543. package/lib/elements/edges/cubic-vertical.d.ts +18 -0
  544. package/lib/elements/edges/cubic-vertical.js +9 -0
  545. package/lib/elements/edges/cubic-vertical.js.map +1 -1
  546. package/lib/elements/edges/cubic.d.ts +19 -1
  547. package/lib/elements/edges/cubic.js +8 -0
  548. package/lib/elements/edges/cubic.js.map +1 -1
  549. package/lib/elements/edges/line.d.ts +12 -2
  550. package/lib/elements/edges/line.js +5 -1
  551. package/lib/elements/edges/line.js.map +1 -1
  552. package/lib/elements/edges/polyline.d.ts +21 -0
  553. package/lib/elements/edges/polyline.js +5 -0
  554. package/lib/elements/edges/polyline.js.map +1 -1
  555. package/lib/elements/edges/quadratic.d.ts +15 -0
  556. package/lib/elements/edges/quadratic.js +5 -0
  557. package/lib/elements/edges/quadratic.js.map +1 -1
  558. package/lib/elements/nodes/base-node.d.ts +67 -67
  559. package/lib/elements/nodes/base-node.js +21 -7
  560. package/lib/elements/nodes/base-node.js.map +1 -1
  561. package/lib/elements/nodes/circle.d.ts +10 -2
  562. package/lib/elements/nodes/circle.js +3 -1
  563. package/lib/elements/nodes/circle.js.map +1 -1
  564. package/lib/elements/nodes/diamond.d.ts +12 -4
  565. package/lib/elements/nodes/diamond.js +4 -2
  566. package/lib/elements/nodes/diamond.js.map +1 -1
  567. package/lib/elements/nodes/donut.d.ts +20 -20
  568. package/lib/elements/nodes/donut.js +20 -7
  569. package/lib/elements/nodes/donut.js.map +1 -1
  570. package/lib/elements/nodes/ellipse.d.ts +12 -1
  571. package/lib/elements/nodes/ellipse.js +5 -0
  572. package/lib/elements/nodes/ellipse.js.map +1 -1
  573. package/lib/elements/nodes/hexagon.d.ts +17 -7
  574. package/lib/elements/nodes/hexagon.js +6 -1
  575. package/lib/elements/nodes/hexagon.js.map +1 -1
  576. package/lib/elements/nodes/html.d.ts +16 -3
  577. package/lib/elements/nodes/html.js +4 -1
  578. package/lib/elements/nodes/html.js.map +1 -1
  579. package/lib/elements/nodes/image.d.ts +22 -2
  580. package/lib/elements/nodes/image.js +10 -3
  581. package/lib/elements/nodes/image.js.map +1 -1
  582. package/lib/elements/nodes/rect.d.ts +10 -2
  583. package/lib/elements/nodes/rect.js +5 -2
  584. package/lib/elements/nodes/rect.js.map +1 -1
  585. package/lib/elements/nodes/star.d.ts +18 -9
  586. package/lib/elements/nodes/star.js +6 -1
  587. package/lib/elements/nodes/star.js.map +1 -1
  588. package/lib/elements/nodes/triangle.d.ts +17 -7
  589. package/lib/elements/nodes/triangle.js +6 -1
  590. package/lib/elements/nodes/triangle.js.map +1 -1
  591. package/lib/elements/shapes/badge.d.ts +3 -2
  592. package/lib/elements/shapes/base-shape.d.ts +2 -3
  593. package/lib/elements/shapes/base-shape.js +33 -4
  594. package/lib/elements/shapes/base-shape.js.map +1 -1
  595. package/lib/elements/shapes/contour.d.ts +66 -0
  596. package/lib/elements/shapes/contour.js +40 -0
  597. package/lib/elements/shapes/contour.js.map +1 -0
  598. package/lib/elements/shapes/icon.d.ts +3 -2
  599. package/lib/elements/shapes/icon.js +4 -1
  600. package/lib/elements/shapes/icon.js.map +1 -1
  601. package/lib/elements/shapes/index.d.ts +3 -0
  602. package/lib/elements/shapes/index.js +3 -1
  603. package/lib/elements/shapes/index.js.map +1 -1
  604. package/lib/elements/shapes/label.d.ts +14 -5
  605. package/lib/elements/shapes/label.js +2 -1
  606. package/lib/elements/shapes/label.js.map +1 -1
  607. package/lib/elements/shapes/polygon.d.ts +29 -0
  608. package/lib/elements/{nodes → shapes}/polygon.js +1 -1
  609. package/lib/elements/shapes/polygon.js.map +1 -0
  610. package/lib/exports.d.ts +25 -23
  611. package/lib/exports.js +51 -17
  612. package/lib/exports.js.map +1 -1
  613. package/lib/layouts/base-layout.d.ts +10 -0
  614. package/lib/layouts/base-layout.js +13 -0
  615. package/lib/layouts/base-layout.js.map +1 -0
  616. package/lib/layouts/index.d.ts +1 -0
  617. package/lib/layouts/index.js +3 -1
  618. package/lib/layouts/index.js.map +1 -1
  619. package/lib/layouts/types.d.ts +11 -4
  620. package/lib/plugins/base-plugin.d.ts +2 -1
  621. package/lib/plugins/bubble-sets.d.ts +116 -0
  622. package/lib/plugins/bubble-sets.js +283 -0
  623. package/lib/plugins/bubble-sets.js.map +1 -0
  624. package/lib/plugins/camera-setting.d.ts +26 -10
  625. package/lib/plugins/camera-setting.js +7 -0
  626. package/lib/plugins/camera-setting.js.map +1 -1
  627. package/lib/plugins/contextmenu.d.ts +64 -40
  628. package/lib/plugins/contextmenu.js +44 -34
  629. package/lib/plugins/contextmenu.js.map +1 -1
  630. package/lib/plugins/grid-line.d.ts +86 -10
  631. package/lib/plugins/grid-line.js +25 -6
  632. package/lib/plugins/grid-line.js.map +1 -1
  633. package/lib/plugins/history/index.d.ts +48 -10
  634. package/lib/plugins/history/index.js +44 -17
  635. package/lib/plugins/history/index.js.map +1 -1
  636. package/lib/plugins/history/utils.d.ts +1 -11
  637. package/lib/plugins/history/utils.js +6 -2
  638. package/lib/plugins/history/utils.js.map +1 -1
  639. package/lib/plugins/hull/index.d.ts +71 -15
  640. package/lib/plugins/hull/index.js +72 -21
  641. package/lib/plugins/hull/index.js.map +1 -1
  642. package/lib/plugins/index.d.ts +4 -0
  643. package/lib/plugins/index.js +5 -1
  644. package/lib/plugins/index.js.map +1 -1
  645. package/lib/plugins/legend.d.ts +95 -15
  646. package/lib/plugins/legend.js +66 -16
  647. package/lib/plugins/legend.js.map +1 -1
  648. package/lib/plugins/timebar.d.ts +234 -0
  649. package/lib/plugins/timebar.js +265 -0
  650. package/lib/plugins/timebar.js.map +1 -0
  651. package/lib/plugins/toolbar/index.d.ts +35 -28
  652. package/lib/plugins/toolbar/index.js +11 -8
  653. package/lib/plugins/toolbar/index.js.map +1 -1
  654. package/lib/plugins/toolbar/util.d.ts +9 -10
  655. package/lib/plugins/toolbar/util.js +2 -1
  656. package/lib/plugins/toolbar/util.js.map +1 -1
  657. package/lib/plugins/tooltip.d.ts +95 -20
  658. package/lib/plugins/tooltip.js +99 -36
  659. package/lib/plugins/tooltip.js.map +1 -1
  660. package/lib/plugins/watermark.d.ts +173 -33
  661. package/lib/plugins/watermark.js +22 -8
  662. package/lib/plugins/watermark.js.map +1 -1
  663. package/lib/registry/build-in.js +8 -5
  664. package/lib/registry/build-in.js.map +1 -1
  665. package/lib/registry/index.d.ts +1 -1
  666. package/lib/registry/index.js +1 -1
  667. package/lib/registry/types.d.ts +2 -2
  668. package/lib/runtime/behavior.d.ts +5 -1
  669. package/lib/runtime/behavior.js +5 -1
  670. package/lib/runtime/behavior.js.map +1 -1
  671. package/lib/runtime/canvas.js +2 -2
  672. package/lib/runtime/canvas.js.map +1 -1
  673. package/lib/runtime/data.d.ts +15 -9
  674. package/lib/runtime/data.js +47 -33
  675. package/lib/runtime/data.js.map +1 -1
  676. package/lib/runtime/element.d.ts +5 -10
  677. package/lib/runtime/element.js +35 -29
  678. package/lib/runtime/element.js.map +1 -1
  679. package/lib/runtime/graph.d.ts +529 -41
  680. package/lib/runtime/graph.js +412 -36
  681. package/lib/runtime/graph.js.map +1 -1
  682. package/lib/runtime/layout.d.ts +5 -17
  683. package/lib/runtime/layout.js +36 -128
  684. package/lib/runtime/layout.js.map +1 -1
  685. package/lib/runtime/types.d.ts +3 -3
  686. package/lib/runtime/viewport.d.ts +2 -2
  687. package/lib/runtime/viewport.js +2 -2
  688. package/lib/spec/behavior.d.ts +20 -2
  689. package/lib/spec/canvas.d.ts +15 -4
  690. package/lib/spec/data.d.ts +93 -2
  691. package/lib/spec/element/combo.d.ts +5 -13
  692. package/lib/spec/element/edge.d.ts +1 -8
  693. package/lib/spec/element/node.d.ts +1 -14
  694. package/{dist/lib/spec/spec.d.ts → lib/spec/graph.d.ts} +13 -5
  695. package/lib/spec/{spec.js → graph.js} +1 -1
  696. package/lib/spec/graph.js.map +1 -0
  697. package/lib/spec/index.d.ts +1 -1
  698. package/lib/spec/plugin.d.ts +22 -2
  699. package/lib/spec/theme.d.ts +1 -4
  700. package/lib/spec/viewport.d.ts +20 -24
  701. package/lib/themes/base.js +25 -16
  702. package/lib/themes/base.js.map +1 -1
  703. package/lib/themes/types.d.ts +0 -1
  704. package/lib/transforms/arrange-draw-order.js +17 -12
  705. package/lib/transforms/arrange-draw-order.js.map +1 -1
  706. package/lib/transforms/collapse-expand-combo.js +29 -20
  707. package/lib/transforms/collapse-expand-combo.js.map +1 -1
  708. package/lib/transforms/process-parallel-edges.d.ts +1 -1
  709. package/lib/types/combo.d.ts +23 -0
  710. package/lib/types/combo.js +3 -0
  711. package/lib/types/combo.js.map +1 -0
  712. package/lib/types/data.d.ts +2 -2
  713. package/lib/types/edge.d.ts +73 -9
  714. package/lib/types/element.d.ts +3 -0
  715. package/lib/types/event.d.ts +14 -2
  716. package/lib/types/history.d.ts +51 -0
  717. package/lib/types/history.js +3 -0
  718. package/lib/types/history.js.map +1 -0
  719. package/lib/types/index.d.ts +2 -0
  720. package/lib/types/layout.d.ts +9 -0
  721. package/lib/types/layout.js +3 -0
  722. package/lib/types/layout.js.map +1 -0
  723. package/lib/types/node.d.ts +111 -7
  724. package/lib/types/point.d.ts +1 -2
  725. package/lib/types/prefix.d.ts +11 -1
  726. package/lib/types/viewport.d.ts +5 -7
  727. package/lib/utils/animation.d.ts +5 -19
  728. package/lib/utils/animation.js +2 -38
  729. package/lib/utils/animation.js.map +1 -1
  730. package/lib/utils/bbox.d.ts +1 -2
  731. package/lib/utils/bbox.js.map +1 -1
  732. package/lib/utils/change.js +8 -1
  733. package/lib/utils/change.js.map +1 -1
  734. package/lib/utils/data.d.ts +2 -2
  735. package/lib/utils/data.js +2 -2
  736. package/lib/utils/dom.d.ts +6 -0
  737. package/lib/utils/dom.js +16 -1
  738. package/lib/utils/dom.js.map +1 -1
  739. package/lib/utils/edge.d.ts +11 -2
  740. package/lib/utils/edge.js +30 -5
  741. package/lib/utils/edge.js.map +1 -1
  742. package/lib/utils/element.d.ts +8 -10
  743. package/lib/utils/element.js +9 -8
  744. package/lib/utils/element.js.map +1 -1
  745. package/lib/utils/event/events.d.ts +1 -1
  746. package/lib/utils/event/events.js.map +1 -1
  747. package/lib/utils/event/index.d.ts +1 -1
  748. package/lib/utils/event/index.js +1 -1
  749. package/lib/utils/id.js +1 -1
  750. package/lib/utils/id.js.map +1 -1
  751. package/lib/utils/layout.d.ts +45 -0
  752. package/lib/utils/layout.js +171 -1
  753. package/lib/utils/layout.js.map +1 -1
  754. package/lib/utils/palette.d.ts +1 -1
  755. package/lib/utils/palette.js +1 -1
  756. package/lib/utils/point.d.ts +11 -2
  757. package/lib/utils/point.js +32 -29
  758. package/lib/utils/point.js.map +1 -1
  759. package/lib/utils/polygon.js +3 -6
  760. package/lib/utils/polygon.js.map +1 -1
  761. package/lib/utils/prefix.js +15 -2
  762. package/lib/utils/prefix.js.map +1 -1
  763. package/lib/utils/relation.d.ts +2 -2
  764. package/lib/utils/relation.js +2 -2
  765. package/lib/utils/symbol.js +27 -15
  766. package/lib/utils/symbol.js.map +1 -1
  767. package/lib/utils/transform.d.ts +10 -0
  768. package/lib/utils/transform.js +23 -0
  769. package/lib/utils/transform.js.map +1 -0
  770. package/lib/utils/tree.js +2 -2
  771. package/lib/utils/tree.js.map +1 -1
  772. package/lib/utils/visibility.d.ts +1 -1
  773. package/lib/utils/visibility.js +1 -1
  774. package/lib/utils/watermark.d.ts +1 -1
  775. package/lib/utils/watermark.js +3 -3
  776. package/package.json +34 -34
  777. package/src/animations/executor.ts +34 -13
  778. package/src/animations/types.ts +7 -8
  779. package/src/behaviors/base-behavior.ts +1 -1
  780. package/src/behaviors/brush-select.ts +252 -163
  781. package/src/behaviors/click-element.ts +40 -17
  782. package/src/behaviors/collapse-expand.ts +19 -3
  783. package/src/behaviors/create-edge.ts +26 -7
  784. package/src/behaviors/drag-canvas.ts +38 -8
  785. package/src/behaviors/drag-element-force.ts +51 -13
  786. package/src/behaviors/drag-element.ts +108 -28
  787. package/src/behaviors/focus-element.ts +24 -25
  788. package/src/behaviors/hover-element.ts +28 -6
  789. package/src/behaviors/index.ts +2 -0
  790. package/src/behaviors/lasso-select.ts +52 -72
  791. package/src/behaviors/scroll-canvas.ts +167 -0
  792. package/src/behaviors/types.ts +2 -3
  793. package/src/behaviors/zoom-canvas.ts +53 -16
  794. package/src/constants/change.ts +50 -1
  795. package/src/constants/element.ts +3 -2
  796. package/src/constants/events/canvas.ts +90 -18
  797. package/src/constants/events/common.ts +100 -20
  798. package/src/constants/events/container.ts +10 -2
  799. package/src/constants/events/edge.ts +70 -14
  800. package/src/constants/events/graph.ts +142 -26
  801. package/src/constants/events/history.ts +38 -0
  802. package/src/constants/events/index.ts +1 -0
  803. package/src/constants/events/node.ts +85 -17
  804. package/src/constants/registry.ts +50 -10
  805. package/src/elements/combos/base-combo.ts +67 -59
  806. package/src/elements/combos/circle.ts +18 -2
  807. package/src/elements/combos/rect.ts +14 -7
  808. package/src/elements/edges/base-edge.ts +132 -112
  809. package/src/elements/edges/cubic-horizontal.ts +18 -0
  810. package/src/elements/edges/cubic-vertical.ts +18 -0
  811. package/src/elements/edges/cubic.ts +19 -1
  812. package/src/elements/edges/line.ts +11 -2
  813. package/src/elements/edges/polyline.ts +23 -2
  814. package/src/elements/edges/quadratic.ts +15 -0
  815. package/src/elements/nodes/base-node.ts +169 -167
  816. package/src/elements/nodes/circle.ts +9 -2
  817. package/src/elements/nodes/diamond.ts +11 -4
  818. package/src/elements/nodes/donut.ts +36 -28
  819. package/src/elements/nodes/ellipse.ts +12 -2
  820. package/src/elements/nodes/hexagon.ts +17 -7
  821. package/src/elements/nodes/html.ts +16 -3
  822. package/src/elements/nodes/image.ts +28 -6
  823. package/src/elements/nodes/rect.ts +11 -3
  824. package/src/elements/nodes/star.ts +18 -9
  825. package/src/elements/nodes/triangle.ts +17 -7
  826. package/src/elements/shapes/badge.ts +1 -1
  827. package/src/elements/shapes/base-shape.ts +39 -11
  828. package/src/elements/shapes/contour.ts +106 -0
  829. package/src/elements/shapes/icon.ts +5 -3
  830. package/src/elements/shapes/index.ts +3 -0
  831. package/src/elements/shapes/label.ts +18 -9
  832. package/src/elements/{nodes → shapes}/polygon.ts +22 -13
  833. package/src/exports.ts +148 -26
  834. package/src/layouts/base-layout.ts +18 -0
  835. package/src/layouts/index.ts +1 -0
  836. package/src/layouts/types.ts +14 -4
  837. package/src/plugins/base-plugin.ts +1 -1
  838. package/src/plugins/bubble-sets.ts +333 -0
  839. package/src/plugins/camera-setting.ts +26 -11
  840. package/src/plugins/contextmenu.ts +83 -59
  841. package/src/plugins/grid-line.ts +91 -17
  842. package/src/plugins/history/index.ts +51 -17
  843. package/src/plugins/history/utils.ts +7 -15
  844. package/src/plugins/hull/index.ts +92 -29
  845. package/src/plugins/index.ts +4 -0
  846. package/src/plugins/legend.ts +123 -39
  847. package/src/plugins/timebar.ts +460 -0
  848. package/src/plugins/toolbar/index.ts +35 -29
  849. package/src/plugins/toolbar/util.ts +9 -11
  850. package/src/plugins/tooltip.ts +126 -52
  851. package/src/plugins/watermark.ts +177 -36
  852. package/src/registry/build-in.ts +21 -6
  853. package/src/registry/index.ts +1 -1
  854. package/src/registry/types.ts +2 -2
  855. package/src/runtime/behavior.ts +5 -1
  856. package/src/runtime/canvas.ts +2 -2
  857. package/src/runtime/data.ts +45 -30
  858. package/src/runtime/element.ts +42 -33
  859. package/src/runtime/graph.ts +545 -50
  860. package/src/runtime/layout.ts +53 -176
  861. package/src/runtime/types.ts +3 -3
  862. package/src/runtime/viewport.ts +2 -2
  863. package/src/spec/behavior.ts +20 -2
  864. package/src/spec/canvas.ts +15 -4
  865. package/src/spec/data.ts +93 -2
  866. package/src/spec/element/combo.ts +5 -13
  867. package/src/spec/element/edge.ts +1 -8
  868. package/src/spec/element/node.ts +1 -14
  869. package/src/spec/{spec.ts → graph.ts} +13 -5
  870. package/src/spec/index.ts +1 -1
  871. package/src/spec/plugin.ts +22 -2
  872. package/src/spec/theme.ts +1 -5
  873. package/src/spec/viewport.ts +12 -21
  874. package/src/themes/base.ts +25 -16
  875. package/src/themes/types.ts +0 -2
  876. package/src/transforms/arrange-draw-order.ts +20 -14
  877. package/src/transforms/collapse-expand-combo.ts +32 -18
  878. package/src/transforms/process-parallel-edges.ts +1 -1
  879. package/src/types/combo.ts +24 -0
  880. package/src/types/data.ts +2 -2
  881. package/src/types/edge.ts +86 -10
  882. package/src/types/element.ts +3 -0
  883. package/src/types/event.ts +14 -2
  884. package/src/types/history.ts +53 -0
  885. package/src/types/index.ts +2 -0
  886. package/src/types/layout.ts +12 -0
  887. package/src/types/node.ts +122 -7
  888. package/src/types/point.ts +1 -3
  889. package/src/types/prefix.ts +11 -1
  890. package/src/types/viewport.ts +5 -7
  891. package/src/utils/animation.ts +4 -48
  892. package/src/utils/bbox.ts +1 -2
  893. package/src/utils/change.ts +6 -1
  894. package/src/utils/data.ts +2 -2
  895. package/src/utils/dom.ts +14 -0
  896. package/src/utils/edge.ts +31 -6
  897. package/src/utils/element.ts +23 -14
  898. package/src/utils/event/events.ts +3 -1
  899. package/src/utils/event/index.ts +1 -1
  900. package/src/utils/id.ts +1 -1
  901. package/src/utils/layout.ts +203 -1
  902. package/src/utils/palette.ts +1 -1
  903. package/src/utils/point.ts +28 -31
  904. package/src/utils/polygon.ts +3 -6
  905. package/src/utils/prefix.ts +16 -2
  906. package/src/utils/relation.ts +2 -2
  907. package/src/utils/symbol.ts +27 -15
  908. package/src/utils/transform.ts +17 -0
  909. package/src/utils/tree.ts +3 -3
  910. package/src/utils/visibility.ts +1 -1
  911. package/src/utils/watermark.ts +1 -1
  912. package/dist/lib/elements/nodes/polygon.d.ts +0 -18
  913. package/dist/lib/plugins/history/events.d.ts +0 -21
  914. package/dist/lib/plugins/hull/shape.d.ts +0 -49
  915. package/dist/lib/utils/behaviors/brush.d.ts +0 -18
  916. package/dist/lib/utils/behaviors/lasso.d.ts +0 -12
  917. package/dist/lib/utils/behaviors/utils.d.ts +0 -21
  918. package/esm/elements/nodes/polygon.d.ts +0 -18
  919. package/esm/elements/nodes/polygon.js.map +0 -1
  920. package/esm/plugins/history/events.d.ts +0 -21
  921. package/esm/plugins/history/events.js +0 -16
  922. package/esm/plugins/history/events.js.map +0 -1
  923. package/esm/plugins/hull/shape.d.ts +0 -49
  924. package/esm/plugins/hull/shape.js +0 -35
  925. package/esm/plugins/hull/shape.js.map +0 -1
  926. package/esm/spec/spec.js +0 -2
  927. package/esm/spec/spec.js.map +0 -1
  928. package/esm/utils/behaviors/brush.d.ts +0 -18
  929. package/esm/utils/behaviors/brush.js +0 -25
  930. package/esm/utils/behaviors/brush.js.map +0 -1
  931. package/esm/utils/behaviors/lasso.d.ts +0 -12
  932. package/esm/utils/behaviors/lasso.js +0 -112
  933. package/esm/utils/behaviors/lasso.js.map +0 -1
  934. package/esm/utils/behaviors/utils.d.ts +0 -21
  935. package/esm/utils/behaviors/utils.js +0 -42
  936. package/esm/utils/behaviors/utils.js.map +0 -1
  937. package/lib/elements/nodes/polygon.d.ts +0 -18
  938. package/lib/elements/nodes/polygon.js.map +0 -1
  939. package/lib/plugins/history/events.d.ts +0 -21
  940. package/lib/plugins/history/events.js +0 -19
  941. package/lib/plugins/history/events.js.map +0 -1
  942. package/lib/plugins/hull/shape.d.ts +0 -49
  943. package/lib/plugins/hull/shape.js +0 -39
  944. package/lib/plugins/hull/shape.js.map +0 -1
  945. package/lib/spec/spec.js.map +0 -1
  946. package/lib/utils/behaviors/brush.d.ts +0 -18
  947. package/lib/utils/behaviors/brush.js +0 -30
  948. package/lib/utils/behaviors/brush.js.map +0 -1
  949. package/lib/utils/behaviors/lasso.d.ts +0 -12
  950. package/lib/utils/behaviors/lasso.js +0 -116
  951. package/lib/utils/behaviors/lasso.js.map +0 -1
  952. package/lib/utils/behaviors/utils.d.ts +0 -21
  953. package/lib/utils/behaviors/utils.js +0 -47
  954. package/lib/utils/behaviors/utils.js.map +0 -1
  955. package/src/plugins/history/events.ts +0 -25
  956. package/src/plugins/hull/shape.ts +0 -96
  957. package/src/utils/behaviors/brush.ts +0 -28
  958. package/src/utils/behaviors/lasso.ts +0 -126
  959. package/src/utils/behaviors/utils.ts +0 -47
package/dist/g6.min.js CHANGED
@@ -1,6 +1,6 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).G6V5={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null,n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function a(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function c(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function l(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function h(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function p(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var g={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],s]:t._events[c].push(s):(t._events[c]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},s.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},s.prototype.emit=function(t,e,r,i,o,a){var s=n?n+t:t;if(!this._events[s])return!1;var c,u,l=this._events[s],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,i),!0;case 5:return l.fn.call(l.context,e,r,i,o),!0;case 6:return l.fn.call(l.context,e,r,i,o,a),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(t,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,e);break;case 3:l[u].fn.call(l[u].context,e,r);break;case 4:l[u].fn.call(l[u].context,e,r,i);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},s.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},s.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},s.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var c=0,u=[],l=s.length;c<l;c++)(s[c].fn!==e||i&&!s[c].once||r&&s[c].context!==r)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,t.exports=s}(g);var m=f(g.exports),v=1e-6,y="undefined"!=typeof Float32Array?Float32Array:Array;function b(){var t=new y(9);return y!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function x(){var t=new y(16);return y!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function E(t){var e=new y(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function w(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function M(t,e,n,r,i,o,a,s,c,u,l,h,d,f,p,g,m){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=u,t[9]=l,t[10]=h,t[11]=d,t[12]=f,t[13]=p,t[14]=g,t[15]=m,t}function N(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function S(t,e){if(t===e){var n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function C(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],u=e[7],l=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],v=e[15],y=n*s-r*a,b=n*c-i*a,x=n*u-o*a,E=r*c-i*s,w=r*u-o*s,M=i*u-o*c,N=l*g-h*p,S=l*m-d*p,C=l*v-f*p,T=h*m-d*g,P=h*v-f*g,k=d*v-f*m,A=y*k-b*P+x*T+E*C-w*S+M*N;return A?(A=1/A,t[0]=(s*k-c*P+u*T)*A,t[1]=(i*P-r*k-o*T)*A,t[2]=(g*M-m*w+v*E)*A,t[3]=(d*w-h*M-f*E)*A,t[4]=(c*C-a*k-u*S)*A,t[5]=(n*k-i*C+o*S)*A,t[6]=(m*x-p*M-v*b)*A,t[7]=(l*M-d*x+f*b)*A,t[8]=(a*P-s*C+u*N)*A,t[9]=(r*C-n*P-o*N)*A,t[10]=(p*w-g*x+v*y)*A,t[11]=(h*x-l*w-f*y)*A,t[12]=(s*S-a*T-c*N)*A,t[13]=(n*T-r*S+i*N)*A,t[14]=(g*b-p*E-m*y)*A,t[15]=(l*E-h*b+d*y)*A,t):null}function T(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],c=t[7],u=t[8],l=t[9],h=t[10],d=t[11],f=t[12],p=t[13],g=t[14],m=t[15];return(e*a-n*o)*(h*m-d*g)-(e*s-r*o)*(l*m-d*p)+(e*c-i*o)*(l*g-h*p)+(n*s-r*a)*(u*m-d*f)-(n*c-i*a)*(u*g-h*f)+(r*c-i*s)*(u*p-l*f)}function P(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],u=e[6],l=e[7],h=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],v=e[14],y=e[15],b=n[0],x=n[1],E=n[2],w=n[3];return t[0]=b*r+x*s+E*h+w*g,t[1]=b*i+x*c+E*d+w*m,t[2]=b*o+x*u+E*f+w*v,t[3]=b*a+x*l+E*p+w*y,b=n[4],x=n[5],E=n[6],w=n[7],t[4]=b*r+x*s+E*h+w*g,t[5]=b*i+x*c+E*d+w*m,t[6]=b*o+x*u+E*f+w*v,t[7]=b*a+x*l+E*p+w*y,b=n[8],x=n[9],E=n[10],w=n[11],t[8]=b*r+x*s+E*h+w*g,t[9]=b*i+x*c+E*d+w*m,t[10]=b*o+x*u+E*f+w*v,t[11]=b*a+x*l+E*p+w*y,b=n[12],x=n[13],E=n[14],w=n[15],t[12]=b*r+x*s+E*h+w*g,t[13]=b*i+x*c+E*d+w*m,t[14]=b*o+x*u+E*f+w*v,t[15]=b*a+x*l+E*p+w*y,t}function k(t,e,n){var r,i,o,a,s,c,u,l,h,d,f,p,g=n[0],m=n[1],v=n[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*v+e[12],t[13]=e[1]*g+e[5]*m+e[9]*v+e[13],t[14]=e[2]*g+e[6]*m+e[10]*v+e[14],t[15]=e[3]*g+e[7]*m+e[11]*v+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],u=e[6],l=e[7],h=e[8],d=e[9],f=e[10],p=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=u,t[7]=l,t[8]=h,t[9]=d,t[10]=f,t[11]=p,t[12]=r*g+s*m+h*v+e[12],t[13]=i*g+c*m+d*v+e[13],t[14]=o*g+u*m+f*v+e[14],t[15]=a*g+l*m+p*v+e[15]),t}function A(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function O(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],c=e[7],u=e[8],l=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+u*r,t[5]=a*i+l*r,t[6]=s*i+h*r,t[7]=c*i+d*r,t[8]=u*i-o*r,t[9]=l*i-a*r,t[10]=h*i-s*r,t[11]=d*i-c*r,t}function _(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],c=e[3],u=e[8],l=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-u*r,t[1]=a*i-l*r,t[2]=s*i-h*r,t[3]=c*i-d*r,t[8]=o*r+u*i,t[9]=a*r+l*i,t[10]=s*r+h*i,t[11]=c*r+d*i,t}function R(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function D(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function I(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=r+r,c=i+i,u=o+o,l=r*s,h=r*c,d=r*u,f=i*c,p=i*u,g=o*u,m=a*s,v=a*c,y=a*u;return t[0]=1-(f+g),t[1]=h+y,t[2]=d-v,t[3]=0,t[4]=h-y,t[5]=1-(l+g),t[6]=p+m,t[7]=0,t[8]=d+v,t[9]=p-m,t[10]=1-(l+f),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function L(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function j(t,e){var n=e[0],r=e[1],i=e[2],o=e[4],a=e[5],s=e[6],c=e[8],u=e[9],l=e[10];return t[0]=Math.hypot(n,r,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(c,u,l),t}function z(t,e){var n=new y(3);j(n,e);var r=1/n[0],i=1/n[1],o=1/n[2],a=e[0]*r,s=e[1]*i,c=e[2]*o,u=e[4]*r,l=e[5]*i,h=e[6]*o,d=e[8]*r,f=e[9]*i,p=e[10]*o,g=a+l+p,m=0;return g>0?(m=2*Math.sqrt(g+1),t[3]=.25*m,t[0]=(h-f)/m,t[1]=(d-c)/m,t[2]=(s-u)/m):a>l&&a>p?(m=2*Math.sqrt(1+a-l-p),t[3]=(h-f)/m,t[0]=.25*m,t[1]=(s+u)/m,t[2]=(d+c)/m):l>p?(m=2*Math.sqrt(1+l-a-p),t[3]=(d-c)/m,t[0]=(s+u)/m,t[1]=.25*m,t[2]=(h+f)/m):(m=2*Math.sqrt(1+p-a-l),t[3]=(s-u)/m,t[0]=(d+c)/m,t[1]=(h+f)/m,t[2]=.25*m),t}function B(t,e,n,r,i){var o=e[0],a=e[1],s=e[2],c=e[3],u=o+o,l=a+a,h=s+s,d=o*u,f=o*l,p=o*h,g=a*l,m=a*h,v=s*h,y=c*u,b=c*l,x=c*h,E=r[0],w=r[1],M=r[2],N=i[0],S=i[1],C=i[2],T=(1-(g+v))*E,P=(f+x)*E,k=(p-b)*E,A=(f-x)*w,O=(1-(d+v))*w,_=(m+y)*w,R=(p+b)*M,D=(m-y)*M,I=(1-(d+g))*M;return t[0]=T,t[1]=P,t[2]=k,t[3]=0,t[4]=A,t[5]=O,t[6]=_,t[7]=0,t[8]=R,t[9]=D,t[10]=I,t[11]=0,t[12]=n[0]+N-(T*N+A*S+R*C),t[13]=n[1]+S-(P*N+O*S+D*C),t[14]=n[2]+C-(k*N+_*S+I*C),t[15]=1,t}function F(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,s=r+r,c=i+i,u=n*a,l=r*a,h=r*s,d=i*a,f=i*s,p=i*c,g=o*a,m=o*s,v=o*c;return t[0]=1-h-p,t[1]=l+v,t[2]=d-m,t[3]=0,t[4]=l-v,t[5]=1-u-p,t[6]=f+g,t[7]=0,t[8]=d+m,t[9]=f-g,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function G(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=(i+r)*o,t[14]=2*i*r*o):(t[10]=-1,t[14]=-2*r),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var V=G;function W(t,e,n,r,i,o,a){var s=1/(e-n),c=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*c,t[14]=(a+o)*u,t[15]=1,t}var U=W;function H(t,e,n,r,i,o,a){var s=1/(e-n),c=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*c,t[14]=o*u,t[15]=1,t}function $(t,e,n,r){var i,o,a,s,c,u,l,h,d,f,p=e[0],g=e[1],m=e[2],y=r[0],b=r[1],x=r[2],E=n[0],w=n[1],M=n[2];return Math.abs(p-E)<v&&Math.abs(g-w)<v&&Math.abs(m-M)<v?N(t):(l=p-E,h=g-w,d=m-M,i=b*(d*=f=1/Math.hypot(l,h,d))-x*(h*=f),o=x*(l*=f)-y*d,a=y*h-b*l,(f=Math.hypot(i,o,a))?(i*=f=1/f,o*=f,a*=f):(i=0,o=0,a=0),s=h*a-d*o,c=d*i-l*a,u=l*o-h*i,(f=Math.hypot(s,c,u))?(s*=f=1/f,c*=f,u*=f):(s=0,c=0,u=0),t[0]=i,t[1]=s,t[2]=l,t[3]=0,t[4]=o,t[5]=c,t[6]=h,t[7]=0,t[8]=a,t[9]=u,t[10]=d,t[11]=0,t[12]=-(i*p+o*g+a*m),t[13]=-(s*p+c*g+u*m),t[14]=-(l*p+h*g+d*m),t[15]=1,t)}function q(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}var Y=P,K=q,X=Object.freeze({__proto__:null,add:function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t},adjoint:function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],u=e[7],l=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],v=e[15];return t[0]=s*(d*v-f*m)-h*(c*v-u*m)+g*(c*f-u*d),t[1]=-(r*(d*v-f*m)-h*(i*v-o*m)+g*(i*f-o*d)),t[2]=r*(c*v-u*m)-s*(i*v-o*m)+g*(i*u-o*c),t[3]=-(r*(c*f-u*d)-s*(i*f-o*d)+h*(i*u-o*c)),t[4]=-(a*(d*v-f*m)-l*(c*v-u*m)+p*(c*f-u*d)),t[5]=n*(d*v-f*m)-l*(i*v-o*m)+p*(i*f-o*d),t[6]=-(n*(c*v-u*m)-a*(i*v-o*m)+p*(i*u-o*c)),t[7]=n*(c*f-u*d)-a*(i*f-o*d)+l*(i*u-o*c),t[8]=a*(h*v-f*g)-l*(s*v-u*g)+p*(s*f-u*h),t[9]=-(n*(h*v-f*g)-l*(r*v-o*g)+p*(r*f-o*h)),t[10]=n*(s*v-u*g)-a*(r*v-o*g)+p*(r*u-o*s),t[11]=-(n*(s*f-u*h)-a*(r*f-o*h)+l*(r*u-o*s)),t[12]=-(a*(h*m-d*g)-l*(s*m-c*g)+p*(s*d-c*h)),t[13]=n*(h*m-d*g)-l*(r*m-i*g)+p*(r*d-i*h),t[14]=-(n*(s*m-c*g)-a*(r*m-i*g)+p*(r*c-i*s)),t[15]=n*(s*d-c*h)-a*(r*d-i*h)+l*(r*c-i*s),t},clone:E,copy:w,create:x,determinant:T,equals:function(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],u=t[7],l=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],m=t[14],y=t[15],b=e[0],x=e[1],E=e[2],w=e[3],M=e[4],N=e[5],S=e[6],C=e[7],T=e[8],P=e[9],k=e[10],A=e[11],O=e[12],_=e[13],R=e[14],D=e[15];return Math.abs(n-b)<=v*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-x)<=v*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(i-E)<=v*Math.max(1,Math.abs(i),Math.abs(E))&&Math.abs(o-w)<=v*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(a-M)<=v*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(s-N)<=v*Math.max(1,Math.abs(s),Math.abs(N))&&Math.abs(c-S)<=v*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(u-C)<=v*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(l-T)<=v*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(h-P)<=v*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(d-k)<=v*Math.max(1,Math.abs(d),Math.abs(k))&&Math.abs(f-A)<=v*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(p-O)<=v*Math.max(1,Math.abs(p),Math.abs(O))&&Math.abs(g-_)<=v*Math.max(1,Math.abs(g),Math.abs(_))&&Math.abs(m-R)<=v*Math.max(1,Math.abs(m),Math.abs(R))&&Math.abs(y-D)<=v*Math.max(1,Math.abs(y),Math.abs(D))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},fromQuat:F,fromQuat2:function(t,e){var n=new y(3),r=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],c=e[5],u=e[6],l=e[7],h=r*r+i*i+o*o+a*a;return h>0?(n[0]=2*(s*a+l*r+c*o-u*i)/h,n[1]=2*(c*a+l*i+u*r-s*o)/h,n[2]=2*(u*a+l*o+s*i-c*r)/h):(n[0]=2*(s*a+l*r+c*o-u*i),n[1]=2*(c*a+l*i+u*r-s*o),n[2]=2*(u*a+l*o+s*i-c*r)),I(t,e,n),t},fromRotation:function(t,e,n){var r,i,o,a=n[0],s=n[1],c=n[2],u=Math.hypot(a,s,c);return u<v?null:(a*=u=1/u,s*=u,c*=u,r=Math.sin(e),o=1-(i=Math.cos(e)),t[0]=a*a*o+i,t[1]=s*a*o+c*r,t[2]=c*a*o-s*r,t[3]=0,t[4]=a*s*o-c*r,t[5]=s*s*o+i,t[6]=c*s*o+a*r,t[7]=0,t[8]=a*c*o+s*r,t[9]=s*c*o-a*r,t[10]=c*c*o+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},fromRotationTranslation:I,fromRotationTranslationScale:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=e[3],c=i+i,u=o+o,l=a+a,h=i*c,d=i*u,f=i*l,p=o*u,g=o*l,m=a*l,v=s*c,y=s*u,b=s*l,x=r[0],E=r[1],w=r[2];return t[0]=(1-(p+m))*x,t[1]=(d+b)*x,t[2]=(f-y)*x,t[3]=0,t[4]=(d-b)*E,t[5]=(1-(h+m))*E,t[6]=(g+v)*E,t[7]=0,t[8]=(f+y)*w,t[9]=(g-v)*w,t[10]=(1-(h+p))*w,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:B,fromScaling:D,fromTranslation:R,fromValues:function(t,e,n,r,i,o,a,s,c,u,l,h,d,f,p,g){var m=new y(16);return m[0]=t,m[1]=e,m[2]=n,m[3]=r,m[4]=i,m[5]=o,m[6]=a,m[7]=s,m[8]=c,m[9]=u,m[10]=l,m[11]=h,m[12]=d,m[13]=f,m[14]=p,m[15]=g,m},fromXRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromYRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},fromZRotation:function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},frustum:function(t,e,n,r,i,o,a){var s=1/(n-e),c=1/(i-r),u=1/(o-a);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*c,t[6]=0,t[7]=0,t[8]=(n+e)*s,t[9]=(i+r)*c,t[10]=(a+o)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*u,t[15]=0,t},getRotation:z,getScaling:j,getTranslation:L,identity:N,invert:C,lookAt:$,mul:Y,multiply:P,multiplyScalar:function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12]*n,t[13]=e[13]*n,t[14]=e[14]*n,t[15]=e[15]*n,t},multiplyScalarAndAdd:function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t[9]=e[9]+n[9]*r,t[10]=e[10]+n[10]*r,t[11]=e[11]+n[11]*r,t[12]=e[12]+n[12]*r,t[13]=e[13]+n[13]*r,t[14]=e[14]+n[14]*r,t[15]=e[15]+n[15]*r,t},ortho:U,orthoNO:W,orthoZO:H,perspective:V,perspectiveFromFieldOfView:function(t,e,n,r){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),c=2/(a+s),u=2/(i+o);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(a-s)*c*.5,t[9]=(i-o)*u*.5,t[10]=r/(n-r),t[11]=-1,t[12]=0,t[13]=0,t[14]=r*n/(n-r),t[15]=0,t},perspectiveNO:G,perspectiveZO:function(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=i*o,t[14]=i*r*o):(t[10]=-1,t[14]=-r),t},rotate:function(t,e,n,r){var i,o,a,s,c,u,l,h,d,f,p,g,m,y,b,x,E,w,M,N,S,C,T,P,k=r[0],A=r[1],O=r[2],_=Math.hypot(k,A,O);return _<v?null:(k*=_=1/_,A*=_,O*=_,i=Math.sin(n),a=1-(o=Math.cos(n)),s=e[0],c=e[1],u=e[2],l=e[3],h=e[4],d=e[5],f=e[6],p=e[7],g=e[8],m=e[9],y=e[10],b=e[11],x=k*k*a+o,E=A*k*a+O*i,w=O*k*a-A*i,M=k*A*a-O*i,N=A*A*a+o,S=O*A*a+k*i,C=k*O*a+A*i,T=A*O*a-k*i,P=O*O*a+o,t[0]=s*x+h*E+g*w,t[1]=c*x+d*E+m*w,t[2]=u*x+f*E+y*w,t[3]=l*x+p*E+b*w,t[4]=s*M+h*N+g*S,t[5]=c*M+d*N+m*S,t[6]=u*M+f*N+y*S,t[7]=l*M+p*N+b*S,t[8]=s*C+h*T+g*P,t[9]=c*C+d*T+m*P,t[10]=u*C+f*T+y*P,t[11]=l*C+p*T+b*P,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:O,rotateY:_,rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],c=e[3],u=e[4],l=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+u*r,t[1]=a*i+l*r,t[2]=s*i+h*r,t[3]=c*i+d*r,t[4]=u*i-o*r,t[5]=l*i-a*r,t[6]=h*i-s*r,t[7]=d*i-c*r,t},scale:A,set:M,str:function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},sub:K,subtract:q,targetTo:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=r[0],c=r[1],u=r[2],l=i-n[0],h=o-n[1],d=a-n[2],f=l*l+h*h+d*d;f>0&&(l*=f=1/Math.sqrt(f),h*=f,d*=f);var p=c*d-u*h,g=u*l-s*d,m=s*h-c*l;return(f=p*p+g*g+m*m)>0&&(p*=f=1/Math.sqrt(f),g*=f,m*=f),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=h*m-d*g,t[5]=d*p-l*m,t[6]=l*g-h*p,t[7]=0,t[8]=l,t[9]=h,t[10]=d,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t},translate:k,transpose:S});function Z(){var t=new y(3);return y!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Q(t){var e=new y(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function J(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function tt(t,e,n){var r=new y(3);return r[0]=t,r[1]=e,r[2]=n,r}function et(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function nt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function rt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function it(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function ot(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function at(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function st(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ct(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],c=n[2];return t[0]=i*c-o*s,t[1]=o*a-r*c,t[2]=r*s-i*a,t}function ut(t,e,n,r){var i=e[0],o=e[1],a=e[2];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t[2]=a+r*(n[2]-a),t}function lt(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,t[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,t[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,t}function ht(t,e){var n=t[0],r=t[1],i=t[2],o=e[0],a=e[1],s=e[2];return Math.abs(n-o)<=v*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=v*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=v*Math.max(1,Math.abs(i),Math.abs(s))}var dt=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.hypot(n,r,i)},ft=J;function pt(){var t=new y(4);return y!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function gt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}function mt(){var t=new y(4);return y!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function vt(t,e,n){n*=.5;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function yt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=n[0],c=n[1],u=n[2],l=n[3];return t[0]=r*l+a*s+i*u-o*c,t[1]=i*l+a*c+o*s-r*u,t[2]=o*l+a*u+r*c-i*s,t[3]=a*l-r*s-i*c-o*u,t}function bt(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return t[0]=-n*s,t[1]=-r*s,t[2]=-i*s,t[3]=o*s,t}function xt(t,e,n,r){var i=.5*Math.PI/180;e*=i,n*=i,r*=i;var o=Math.sin(e),a=Math.cos(e),s=Math.sin(n),c=Math.cos(n),u=Math.sin(r),l=Math.cos(r);return t[0]=o*c*l-a*s*u,t[1]=a*s*l+o*c*u,t[2]=a*c*u-o*s*l,t[3]=a*c*l+o*s*u,t}Z(),function(){var t=pt()}();var Et=function(t,e,n,r){var i=new y(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i},wt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Mt=yt,Nt=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=n*a,t[1]=r*a,t[2]=i*a,t[3]=o*a,t};Z(),tt(1,0,0),tt(0,1,0),mt(),mt(),b(),function(){var t,e=(t=new y(2),y!=Float32Array&&(t[0]=0,t[1]=0),t)}();var St=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Ct=function(t,e){return!!St(t)&&t.indexOf(e)>-1},Tt=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!St(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n}(t,(function(t){return!Ct(e,t)}))},Pt=function(t){return"function"==typeof t},kt=function(t){return null==t},At={}.toString,Ot=function(t,e){return At.call(t)==="[object "+e+"]"},_t=function(t){return Array.isArray?Array.isArray(t):Ot(t,"Array")},Rt=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Dt(t,e){if(t)if(_t(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(Rt(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var It=function(t){return"object"==typeof t&&null!==t},Lt=function(t){if(!It(t)||!Ot(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},jt=function(t){if(_t(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},zt=function(t){if(_t(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},Bt=function(t){return Ot(t,"String")},Ft=Object.prototype.hasOwnProperty;function Gt(t,e){if(!e||!_t(t))return{};for(var n,r={},i=Pt(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),Ft.call(r,n)?r[n].push(a):r[n]=[a]}return r}var Vt=function(t,e,n){return t<e?e:t>n?n:t},Wt=function(t){return Ot(t,"Number")},Ut=1e-5;function Ht(t,e,n){return void 0===n&&(n=Ut),Math.abs(t-e)<n}var $t=function(t,e){return(t%e+e)%e},qt=function(t){return kt(t)?"":t.toString()},Yt=function(t){var e=qt(t);return e.charAt(0).toLowerCase()+e.substring(1)};var Kt={}.toString,Xt=function(t){return Ot(t,"Boolean")},Zt=Object.prototype,Qt=function(t){return void 0===t},Jt=function(t){if("object"!=typeof t||null===t)return t;var e;if(_t(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Jt(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Jt(t[i]):e[i]=t[i];return e};function te(t,e,n){var r;return function(){var i=this,o=arguments,a=n&&!r;clearTimeout(r),r=setTimeout((function(){r=null,n||t.apply(i,o)}),e),a&&t.apply(i,o)}}function ee(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function ne(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(ee(e,i)){var o=e[i];null!==o&&Lt(o)?(Lt(t[i])||(t[i]={}),n<r?ne(t[i],o,n+1,r):t[i]=e[i]):_t(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var re=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)ne(t,e[r]);return t},ie=Object.prototype.hasOwnProperty;function oe(t){if(kt(t))return!0;if(St(t))return!t.length;var e=function(t){return Kt.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Zt)}(t))return!Object.keys(t).length;for(var n in t)if(ie.call(t,n))return!1;return!0}var ae=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(Bt(t)||Bt(e))return!1;if(St(t)||St(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=ae(t[r],e[r]));r++);return n}if(It(t)||It(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=ae(t[i[r]],e[i[r]]));r++);return n}return!1},se=function(t,e,n){for(var r=0,i=Bt(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},ce=function(t,e,n){var r=t,i=Bt(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Rt(r[t])||(r[t]=Wt(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},ue=Object.prototype.hasOwnProperty,le=function(t,e){if(null===t||!Lt(t))return{};var n={};return Dt(e,(function(e){ue.call(t,e)&&(n[e]=t[e])})),n},he=function(t,e){return function(t,e,n){if(!_t(t)&&!Lt(t))return t;var r=n;return Dt(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},de={},fe=function(){},pe={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function ge(t,e,n){if(t[n].length>7){t[n].shift();for(var r=t[n],i=n;r.length;)e[n]="A",t.splice(i+=1,0,["C"].concat(r.splice(0,6)));t.splice(n,1)}}var me={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function ve(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return me[e]===t.length-1&&"achlmqstvz".includes(e)}))}function ye(t){return ve(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function be(t){return ye(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function xe(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=me[n]&&("m"===n&&r.length>2?(t.segments.push([e].concat(r.splice(0,2))),n="l",e="m"===e?"l":"L"):t.segments.push([e].concat(r.splice(0,me[n]))),me[n]););}function Ee(t){var e=t.index,n=t.pathValue,r=n.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='[path-util]: invalid Arc flag "'+n[e]+'", expecting 0 or 1 at index '+e)}function we(t){return t>=48&&t<=57||43===t||45===t||46===t}function Me(t){return t>=48&&t<=57}function Ne(t){var e,n=t.max,r=t.pathValue,i=t.index,o=i,a=!1,s=!1,c=!1,u=!1;if(o>=n)t.err="[path-util]: Invalid path value at index "+o+', "pathValue" is missing param';else if(43!==(e=r.charCodeAt(o))&&45!==e||(o+=1,e=r.charCodeAt(o)),Me(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&Me(e))return void(t.err="[path-util]: Invalid path value at index "+i+', "'+r[i]+'" illegal number');for(;o<n&&Me(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(u=!0,o+=1;Me(r.charCodeAt(o));)o+=1,c=!0;e=r.charCodeAt(o)}if(101===e||69===e){if(u&&!s&&!c)return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid float exponent');if(o+=1,43!==(e=r.charCodeAt(o))&&45!==e||(o+=1),!(o<n&&Me(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid integer exponent');for(;o<n&&Me(r.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" is not a number'}function Se(t){for(var e,n=t.pathValue,r=t.max;t.index<r&&(10===(e=n.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e));)t.index+=1}function Ce(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=me[n[r].toLowerCase()];if(t.segmentStart=r,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(i))if(t.index+=1,Se(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?Ne(t):Ee(t),t.err.length)return;t.data.push(t.param),Se(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,Se(t))}if(t.index>=t.max)break;if(!we(n.charCodeAt(t.index)))break}xe(t)}else xe(t);else t.err='[path-util]: Invalid path value "'+n[r]+'" is not a path command'}var Te=function(t){this.pathValue=t,this.segments=[],this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""};function Pe(t){if(ye(t))return[].concat(t);var e=function(t){if(ve(t))return[].concat(t);var e=new Te(t);for(Se(e);e.index<e.max&&!e.err.length;)Ce(e);return e.err?e.err:e.segments}(t),n=0,r=0,i=0,o=0;return e.map((function(t){var e,a=t.slice(1).map(Number),s=t[0],c=s.toUpperCase();if("M"===s)return n=a[0],r=a[1],i=n,o=r,["M",n,r];if(s!==c)switch(c){case"A":e=[c,a[0],a[1],a[2],a[3],a[4],a[5]+n,a[6]+r];break;case"V":e=[c,a[0]+r];break;case"H":e=[c,a[0]+n];break;default:var u=a.map((function(t,e){return t+(e%2?r:n)}));e=[c].concat(u)}else e=[c].concat(a);var l=e.length;switch(c){case"Z":n=i,r=o;break;case"H":n=e[1];break;case"V":r=e[1];break;default:n=e[l-2],r=e[l-1],"M"===c&&(i=n,o=r)}return e}))}function ke(t,e){var n=t[0],r=e.x1,i=e.y1,o=e.x2,a=e.y2,s=t.slice(1).map(Number),c=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)c=["L",t[1],i];else if("V"===n)c=["L",r,t[1]];else if("S"===n){var u=2*r-o,l=2*i-a;e.x1=u,e.y1=l,c=["C",u,l].concat(s)}else if("T"===n){var h=2*r-e.qx,d=2*i-e.qy;e.qx=h,e.qy=d,c=["Q",h,d].concat(s)}else if("Q"===n){var f=s[0],p=s[1];e.qx=f,e.qy=p}return c}function Ae(t){if(be(t))return[].concat(t);for(var e=Pe(t),n=i({},pe),r=0;r<e.length;r+=1){e[r]=ke(e[r],n);var o=e[r],a=o.length;n.x1=+o[a-2],n.y1=+o[a-1],n.x2=+o[a-4]||n.x1,n.y2=+o[a-3]||n.y1}return e}function Oe(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function _e(t,e,n,r,i,o,a,s,c,u){var l,h,d,f,p,g=t,m=e,v=n,y=r,b=s,x=c,E=120*Math.PI/180,w=Math.PI/180*(+i||0),M=[];if(u)h=u[0],d=u[1],f=u[2],p=u[3];else{g=(l=Oe(g,m,-w)).x,m=l.y;var N=(g-(b=(l=Oe(b,x,-w)).x))/2,S=(m-(x=l.y))/2,C=N*N/(v*v)+S*S/(y*y);C>1&&(v*=C=Math.sqrt(C),y*=C);var T=v*v,P=y*y,k=(o===a?-1:1)*Math.sqrt(Math.abs((T*P-T*S*S-P*N*N)/(T*S*S+P*N*N)));f=k*v*S/y+(g+b)/2,p=k*-y*N/v+(m+x)/2,h=Math.asin(((m-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),d=Math.asin(((x-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),h=g<f?Math.PI-h:h,d=b<f?Math.PI-d:d,h<0&&(h=2*Math.PI+h),d<0&&(d=2*Math.PI+d),a&&h>d&&(h-=2*Math.PI),!a&&d>h&&(d-=2*Math.PI)}var A=d-h;if(Math.abs(A)>E){var O=d,_=b,R=x;d=h+E*(a&&d>h?1:-1),M=_e(b=f+v*Math.cos(d),x=p+y*Math.sin(d),v,y,i,0,a,_,R,[d,O,f,p])}A=d-h;var D=Math.cos(h),I=Math.sin(h),L=Math.cos(d),j=Math.sin(d),z=Math.tan(A/4),B=4/3*v*z,F=4/3*y*z,G=[g,m],V=[g+B*I,m-F*D],W=[b+B*j,x-F*L],U=[b,x];if(V[0]=2*G[0]-V[0],V[1]=2*G[1]-V[1],u)return V.concat(W,U,M);for(var H=[],$=0,q=(M=V.concat(W,U,M)).length;$<q;$+=1)H[$]=$%2?Oe(M[$-1],M[$],w).y:Oe(M[$],M[$+1],w).x;return H}function Re(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var De=function(t,e,n,r){return l(l([],Re([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function Ie(t,e){var n,r,i,o,a,s,c,u,l,h=t[0],d=t.slice(1).map(Number),f=d[0],p=d[1],g=e.x1,m=e.y1,v=e.x,y=e.y;switch("TQ".includes(h)||(e.qx=null,e.qy=null),h){case"M":return e.x=f,e.y=p,t;case"A":return n=[g,m].concat(d),["C"].concat(_e(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9]));case"Q":return e.qx=f,e.qy=p,n=[g,m].concat(d),["C"].concat((r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],c=n[5],[(u=1/3)*r+(l=2/3)*o,u*i+l*a,u*s+l*o,u*c+l*a,s,c]));case"L":return["C"].concat(De(g,m,f,p));case"Z":return g===v&&m===y?["C",g,m,v,y,v,y]:["C"].concat(De(g,m,v,y))}return t}function Le(t,e){if(void 0===e&&(e=!1),function(t){return be(t)&&t.every((function(t){var e=t[0];return"MC".includes(e)}))}(t)){var n=[].concat(t);return e?[n,[]]:n}for(var r,o,a=Ae(t),s=i({},pe),c=[],u="",l=a.length,h=[],d=0;d<l;d+=1){a[d]&&(u=a[d][0]),c[d]=u;var f=Ie(a[d],s);a[d]=f,ge(a,c,d),l=a.length,"Z"===u&&h.push(d),o=(r=a[d]).length,s.x1=+r[o-2],s.y1=+r[o-1],s.x2=+r[o-4]||s.x1,s.y2=+r[o-3]||s.y1}return e?[a,h]:a}function je(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function ze(t,e,n,r,i){var o=je([t,e],[n,r]),a={x:0,y:0};if("number"==typeof i)if(i<=0)a={x:t,y:e};else if(i>=o)a={x:n,y:r};else{var s=Re([t,e],[n,r],i/o);a={x:s[0],y:s[1]}}return{length:o,point:a,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function Be(t,e){var n=t.x,r=t.y,i=e.x,o=e.y,a=n*i+r*o,s=Math.sqrt((Math.pow(n,2)+Math.pow(r,2))*(Math.pow(i,2)+Math.pow(o,2)));return(n*o-r*i<0?-1:1)*Math.acos(a/s)}function Fe(t,e,n,r,i,o,a,s,c,u){var l=Math.abs,h=Math.sin,d=Math.cos,f=Math.sqrt,p=Math.PI,g=l(n),m=l(r),v=(i%360+360)%360*(p/180);if(t===s&&e===c)return{x:t,y:e};if(0===g||0===m)return ze(t,e,s,c,u).point;var y=(t-s)/2,b=(e-c)/2,x={x:d(v)*y+h(v)*b,y:-h(v)*y+d(v)*b},E=Math.pow(x.x,2)/Math.pow(g,2)+Math.pow(x.y,2)/Math.pow(m,2);E>1&&(g*=f(E),m*=f(E));var w=(Math.pow(g,2)*Math.pow(m,2)-Math.pow(g,2)*Math.pow(x.y,2)-Math.pow(m,2)*Math.pow(x.x,2))/(Math.pow(g,2)*Math.pow(x.y,2)+Math.pow(m,2)*Math.pow(x.x,2)),M=(o!==a?1:-1)*f(w=w<0?0:w),N=M*(g*x.y/m),S=M*(-m*x.x/g),C=d(v)*N-h(v)*S+(t+s)/2,T=h(v)*N+d(v)*S+(e+c)/2,P={x:(x.x-N)/g,y:(x.y-S)/m},k=Be({x:1,y:0},P),A=Be(P,{x:(-x.x-N)/g,y:(-x.y-S)/m});!a&&A>0?A-=2*p:a&&A<0&&(A+=2*p);var O=k+(A%=2*p)*u,_=g*d(O),R=m*h(O);return{x:d(v)*_-h(v)*R+C,y:h(v)*_+d(v)*R+T}}function Ge(t,e,n,r,i,o,a,s,c,u,l){var h,d=l.bbox,f=void 0===d||d,p=l.length,g=void 0===p||p,m=l.sampleSize,v=void 0===m?30:m,y="number"==typeof u,b=t,x=e,E=0,w=[b,x,E],M=[b,x],N={x:0,y:0},S=[{x:b,y:x}];y&&u<=0&&(N={x:b,y:x});for(var C=0;C<=v;C+=1){if(b=(h=Fe(t,e,n,r,i,o,a,s,c,C/v)).x,x=h.y,f&&S.push({x:b,y:x}),g&&(E+=je(M,[b,x])),M=[b,x],y&&E>=u&&u>w[2]){var T=(E-u)/(E-w[2]);N={x:M[0]*(1-T)+w[0]*T,y:M[1]*(1-T)+w[1]*T}}w=[b,x,E]}return y&&u>=E&&(N={x:s,y:c}),{length:E,point:N,min:{x:Math.min.apply(null,S.map((function(t){return t.x}))),y:Math.min.apply(null,S.map((function(t){return t.y})))},max:{x:Math.max.apply(null,S.map((function(t){return t.x}))),y:Math.max.apply(null,S.map((function(t){return t.y})))}}}function Ve(t,e,n,r,i,o,a,s,c){var u=1-c;return{x:Math.pow(u,3)*t+3*Math.pow(u,2)*c*n+3*u*Math.pow(c,2)*i+Math.pow(c,3)*a,y:Math.pow(u,3)*e+3*Math.pow(u,2)*c*r+3*u*Math.pow(c,2)*o+Math.pow(c,3)*s}}function We(t,e,n,r,i,o,a,s,c,u){var l,h=u.bbox,d=void 0===h||h,f=u.length,p=void 0===f||f,g=u.sampleSize,m=void 0===g?10:g,v="number"==typeof c,y=t,b=e,x=0,E=[y,b,x],w=[y,b],M={x:0,y:0},N=[{x:y,y:b}];v&&c<=0&&(M={x:y,y:b});for(var S=0;S<=m;S+=1){if(y=(l=Ve(t,e,n,r,i,o,a,s,S/m)).x,b=l.y,d&&N.push({x:y,y:b}),p&&(x+=je(w,[y,b])),w=[y,b],v&&x>=c&&c>E[2]){var C=(x-c)/(x-E[2]);M={x:w[0]*(1-C)+E[0]*C,y:w[1]*(1-C)+E[1]*C}}E=[y,b,x]}return v&&c>=x&&(M={x:a,y:s}),{length:x,point:M,min:{x:Math.min.apply(null,N.map((function(t){return t.x}))),y:Math.min.apply(null,N.map((function(t){return t.y})))},max:{x:Math.max.apply(null,N.map((function(t){return t.x}))),y:Math.max.apply(null,N.map((function(t){return t.y})))}}}function Ue(t,e,n,r,i,o,a){var s=1-a;return{x:Math.pow(s,2)*t+2*s*a*n+Math.pow(a,2)*i,y:Math.pow(s,2)*e+2*s*a*r+Math.pow(a,2)*o}}function He(t,e,n,r,i,o,a,s){var c,u=s.bbox,l=void 0===u||u,h=s.length,d=void 0===h||h,f=s.sampleSize,p=void 0===f?10:f,g="number"==typeof a,m=t,v=e,y=0,b=[m,v,y],x=[m,v],E={x:0,y:0},w=[{x:m,y:v}];g&&a<=0&&(E={x:m,y:v});for(var M=0;M<=p;M+=1){if(m=(c=Ue(t,e,n,r,i,o,M/p)).x,v=c.y,l&&w.push({x:m,y:v}),d&&(y+=je(x,[m,v])),x=[m,v],g&&y>=a&&a>b[2]){var N=(y-a)/(y-b[2]);E={x:x[0]*(1-N)+b[0]*N,y:x[1]*(1-N)+b[1]*N}}b=[m,v,y]}return g&&a>=y&&(E={x:i,y:o}),{length:y,point:E,min:{x:Math.min.apply(null,w.map((function(t){return t.x}))),y:Math.min.apply(null,w.map((function(t){return t.y})))},max:{x:Math.max.apply(null,w.map((function(t){return t.x}))),y:Math.max.apply(null,w.map((function(t){return t.y})))}}}function $e(t,e,n){for(var r,i,o,a,s,c,u,l,h,d=Ae(t),f="number"==typeof e,p=[],g=0,m=0,v=0,y=0,b=[],x=[],E=0,w={x:0,y:0},M=w,N=w,S=w,C=0,T=0,P=d.length;T<P;T+=1)p=(u="M"===(l=(h=d[T])[0]))?p:[g,m].concat(h.slice(1)),u?(M=w={x:v=h[1],y:y=h[2]},E=0,f&&e<.001&&(S=w)):"L"===l?(E=(r=ze(p[0],p[1],p[2],p[3],(e||0)-C)).length,w=r.min,M=r.max,N=r.point):"A"===l?(E=(i=Ge(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-C,n||{})).length,w=i.min,M=i.max,N=i.point):"C"===l?(E=(o=We(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-C,n||{})).length,w=o.min,M=o.max,N=o.point):"Q"===l?(E=(a=He(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-C,n||{})).length,w=a.min,M=a.max,N=a.point):"Z"===l&&(E=(s=ze((p=[g,m,v,y])[0],p[1],p[2],p[3],(e||0)-C)).length,w=s.min,M=s.max,N=s.point),f&&C<e&&C+E>=e&&(S=N),x.push(M),b.push(w),C+=E,g=(c="Z"!==l?h.slice(-2):[v,y])[0],m=c[1];return f&&e>=C&&(S={x:g,y:m}),{length:C,point:S,min:{x:Math.min.apply(null,b.map((function(t){return t.x}))),y:Math.min.apply(null,b.map((function(t){return t.y})))},max:{x:Math.max.apply(null,x.map((function(t){return t.x}))),y:Math.max.apply(null,x.map((function(t){return t.y})))}}}function qe(t,e){var n=t.length-1,r=[],i=0,o=function(t){var e=t.length,n=e-1;return t.map((function(r,i){return t.map((function(r,o){var a,s=i+o;return 0===o||t[s]&&"M"===t[s][0]?(a=t[s],["M"].concat(a.slice(-2))):(s>=e&&(s-=n),t[s])}))}))}(t);return o.forEach((function(o,a){t.slice(1).forEach((function(r,o){i+=je(t[(a+o)%n].slice(-2),e[o%n].slice(-2))})),r[a]=i,i=0})),o[r.indexOf(Math.min.apply(null,r))]}function Ye(t){return function(t){var e=0,n=0,r=0;return Le(t).map((function(t){var i;if("M"===t[0])return e=t[1],n=t[2],0;var o=t.slice(1),a=o[0],s=o[1],c=o[2],u=o[3],l=o[4],h=o[5];return r=function(t,e,n,r,i,o,a,s){return 3*((s-e)*(n+i)-(a-t)*(r+o)+r*(t-i)-n*(e-o)+s*(i+t/3)-a*(o+e/3))/20}(e,n,a,s,c,u,l,h),i=t.slice(-2),e=i[0],n=i[1],r})).reduce((function(t,e){return t+e}),0)}(t)>=0}function Ke(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?We(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],{bbox:!1}).length:0;return{s:t,ss:e?i?function(t,e){void 0===e&&(e=.5);var n=t.slice(0,2),r=t.slice(2,4),i=t.slice(4,6),o=t.slice(6,8),a=Re(n,r,e),s=Re(r,i,e),c=Re(i,o,e),u=Re(a,s,e),l=Re(s,c,e),h=Re(u,l,e);return[["C"].concat(a,u,h),["C"].concat(l,c,o)]}(r):[t,t]:[t],l:i}}))}function Xe(t,e,n){var r=Ke(t),i=Ke(e),o=r.length,a=i.length,s=r.filter((function(t){return t.l})).length,c=i.filter((function(t){return t.l})).length,u=r.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/s||0,l=i.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/c||0,h=n||Math.max(o,a),d=[u,l],f=[h-o,h-a],p=0,g=[r,i].map((function(t,e){return t.l===h?t.map((function(t){return t.s})):t.map((function(t,n){return p=n&&f[e]&&t.l>=d[e],f[e]-=p?1:0,p?t.ss:[t.s]})).flat()}));return g[0].length===g[1].length?g:Xe(g[0],g[1],h)}function Ze(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function Qe(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Je(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function tn(){}var en=.7,nn=1/en,rn="\\s*([+-]?\\d+)\\s*",on="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",an="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sn=/^#([0-9a-f]{3,8})$/,cn=new RegExp("^rgb\\("+[rn,rn,rn]+"\\)$"),un=new RegExp("^rgb\\("+[an,an,an]+"\\)$"),ln=new RegExp("^rgba\\("+[rn,rn,rn,on]+"\\)$"),hn=new RegExp("^rgba\\("+[an,an,an,on]+"\\)$"),dn=new RegExp("^hsl\\("+[on,an,an]+"\\)$"),fn=new RegExp("^hsla\\("+[on,an,an,on]+"\\)$"),pn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function gn(){return this.rgb().formatHex()}function mn(){return this.rgb().formatRgb()}function vn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=sn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?yn(e):3===n?new xn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?bn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?bn(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=cn.exec(t))?new xn(e[1],e[2],e[3],1):(e=un.exec(t))?new xn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=ln.exec(t))?bn(e[1],e[2],e[3],e[4]):(e=hn.exec(t))?bn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=dn.exec(t))?Nn(e[1],e[2]/100,e[3]/100,1):(e=fn.exec(t))?Nn(e[1],e[2]/100,e[3]/100,e[4]):pn.hasOwnProperty(t)?yn(pn[t]):"transparent"===t?new xn(NaN,NaN,NaN,0):null}function yn(t){return new xn(t>>16&255,t>>8&255,255&t,1)}function bn(t,e,n,r){return r<=0&&(t=e=n=NaN),new xn(t,e,n,r)}function xn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function En(){return"#"+Mn(this.r)+Mn(this.g)+Mn(this.b)}function wn(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function Mn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Nn(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Cn(t,e,n,r)}function Sn(t){if(t instanceof Cn)return new Cn(t.h,t.s,t.l,t.opacity);if(t instanceof tn||(t=vn(t)),!t)return new Cn;if(t instanceof Cn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,c=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n<r):n===o?(r-e)/s+2:(e-n)/s+4,s/=c<.5?o+i:2-o-i,a*=60):s=c>0&&c<1?0:a,new Cn(a,s,c,t.opacity)}function Cn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Tn(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function Pn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function kn(t,e){var n=Math.min.apply(Math,l([],u(t),!1)),r=Math.min.apply(Math,l([],u(e),!1));return{x:n,y:r,width:Math.max.apply(Math,l([],u(t),!1))-n,height:Math.max.apply(Math,l([],u(e),!1))-r}}function An(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function On(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function _n(t,e,n,r,i,o,a){for(var s=function(t,e,n){return Math.atan(-e/t*Math.tan(n))}(n,r,i),c=1/0,u=-1/0,l=[o,a],h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var d=s+h;o<a?o<d&&d<a&&l.push(d):a<d&&d<o&&l.push(d)}for(h=0;h<l.length;h++){var f=An(t,0,n,r,i,l[h]);f<c&&(c=f),f>u&&(u=f)}var p=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,r,i),g=1/0,m=-1/0,v=[o,a];for(h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var y=p+h;o<a?o<y&&y<a&&v.push(y):a<y&&y<o&&v.push(y)}for(h=0;h<v.length;h++){var b=On(0,e,n,r,i,v[h]);b<g&&(g=b),b>m&&(m=b)}return{x:c,y:g,width:u-c,height:m-g}}Qe(tn,vn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:gn,formatHex:gn,formatHsl:function(){return Sn(this).formatHsl()},formatRgb:mn,toString:mn}),Qe(xn,(function(t,e,n,r){return 1===arguments.length?((i=t)instanceof tn||(i=vn(i)),i?new xn((i=i.rgb()).r,i.g,i.b,i.opacity):new xn):new xn(t,e,n,null==r?1:r);var i}),Je(tn,{brighter:function(t){return t=null==t?nn:Math.pow(nn,t),new xn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?en:Math.pow(en,t),new xn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:En,formatHex:En,formatRgb:wn,toString:wn})),Qe(Cn,(function(t,e,n,r){return 1===arguments.length?Sn(t):new Cn(t,e,n,null==r?1:r)}),Je(tn,{brighter:function(t){return t=null==t?nn:Math.pow(nn,t),new Cn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?en:Math.pow(en,t),new Cn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new xn(Tn(t>=240?t-240:t+120,i,r),Tn(t,i,r),Tn(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var Rn=1e-4;function Dn(t,e,n,r,i,o){var a=-1,s=1/0,c=[n,r],h=20;o&&o>200&&(h=o/10);for(var d=1/h,f=d/10,p=0;p<=h;p++){var g=p*d,m=[i.apply(void 0,l([],u(t.concat([g])),!1)),i.apply(void 0,l([],u(e.concat([g])),!1))];(x=Pn(c[0],c[1],m[0],m[1]))<s&&(a=g,s=x)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var v=t.length;return{x:t[v-1],y:e[v-1]}}s=1/0;for(p=0;p<32&&!(f<Rn);p++){var y=a-f,b=a+f,x=(m=[i.apply(void 0,l([],u(t.concat([y])),!1)),i.apply(void 0,l([],u(e.concat([y])),!1))],Pn(c[0],c[1],m[0],m[1]));if(y>=0&&x<s)a=y,s=x;else{var E=[i.apply(void 0,l([],u(t.concat([b])),!1)),i.apply(void 0,l([],u(e.concat([b])),!1))],w=Pn(c[0],c[1],E[0],E[1]);b<=1&&w<s?(a=b,s=w):f*=.5}}return{x:i.apply(void 0,l([],u(t.concat([a])),!1)),y:i.apply(void 0,l([],u(e.concat([a])),!1))}}function In(t,e,n,r){return Pn(t,e,n,r)}function Ln(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function jn(t,e,n,r,i,o){var a=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((i-t)*(i-t)+(o-e)*(o-e));var s=[-a[1],a[0]];!function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s);var c=[i-t,o-e];return Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}(c,s))}function zn(t,e,n,r,i){var o=1-i;return o*o*o*t+3*e*i*o*o+3*n*i*i*o+r*i*i*i}function Bn(t,e,n,r){var i,o,a,s=-3*t+9*e-9*n+3*r,c=6*t-12*e+6*n,u=3*e-3*t,l=[];if(Ht(s,0))Ht(c,0)||(i=-u/c)>=0&&i<=1&&l.push(i);else{var h=c*c-4*s*u;Ht(h,0)?l.push(-c/(2*s)):h>0&&(o=(-c-(a=Math.sqrt(h)))/(2*s),(i=(-c+a)/(2*s))>=0&&i<=1&&l.push(i),o>=0&&o<=1&&l.push(o))}return l}function Fn(t,e,n,r,i,o,a,s){for(var c=[t,a],u=[e,s],l=Bn(t,n,i,a),h=Bn(e,r,o,s),d=0;d<l.length;d++)c.push(zn(t,n,i,a,l[d]));for(d=0;d<h.length;d++)u.push(zn(e,r,o,s,h[d]));return kn(c,u)}function Gn(t,e,n,r,i,o,a,s,c,u,l){var h=function(t,e,n,r,i,o,a,s,c,u,l){return Dn([t,n,i,a],[e,r,o,s],c,u,zn,l)}(t,e,n,r,i,o,a,s,c,u,l);return Pn(h.x,h.y,c,u)}function Vn(t){return function(t){if(t.length<2)return 0;for(var e=0,n=0;n<t.length-1;n++){var r=t[n],i=t[n+1];e+=Pn(r[0],r[1],i[0],i[1])}return e}(t)}function Wn(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function Un(t,e,n){var r=t+n-2*e;if(Ht(r,0))return[.5];var i=(t-e)/r;return i<=1&&i>=0?[i]:[]}function Hn(t,e,n,r,i,o){var a=Un(t,n,i)[0],s=Un(e,r,o)[0],c=[t,i],u=[e,o];return void 0!==a&&c.push(Wn(t,n,i,a)),void 0!==s&&u.push(Wn(e,r,o,s)),kn(c,u)}function $n(t,e,n,r,i,o,a,s){var c=function(t,e,n,r,i,o,a,s){return Dn([t,n,i],[e,r,o],a,s,Wn)}(t,e,n,r,i,o,a,s);return Pn(c.x,c.y,a,s)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var qn={exports:{}};!function(t,e){t.exports=function(){function t(t,n,i,o,a){e(t,n,i||0,o||t.length-1,a||r)}function e(t,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,c=r-i+1,u=Math.log(s),l=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*l*(s-l)/s)*(c-s/2<0?-1:1);e(t,r,Math.max(i,Math.floor(r-c*l/s+h)),Math.min(o,Math.floor(r+(s-c)*l/s+h)),a)}var d=t[r],f=i,p=o;for(n(t,i,r),a(t[o],d)>0&&n(t,i,o);f<p;){for(n(t,f,p),f++,p--;a(t[f],d)<0;)f++;for(;a(t[p],d)>0;)p--}0===a(t[i],d)?n(t,i,p):n(t,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}function n(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function r(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r<e.length;r++)if(n(t,e[r]))return r;return-1}function a(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,r,i){i||(i=v(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var o=e;o<n;o++){var a=t.children[o];c(i,t.leaf?r(a):a)}return i}function c(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function u(t,e){return t.minX-e.minX}function l(t,e){return t.minY-e.minY}function h(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function d(t){return t.maxX-t.minX+(t.maxY-t.minY)}function f(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function p(t,e){var n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}function g(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function m(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function v(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(e,n,r,i,o){for(var a=[n,r];a.length;)if(!((r=a.pop())-(n=a.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;t(e,s,n,r,o),a.push(n,s,s,r)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!m(t,e))return n;for(var r=this.toBBox,i=[];e;){for(var o=0;o<e.children.length;o++){var a=e.children[o],s=e.leaf?r(a):a;m(t,s)&&(e.leaf?n.push(a):g(t,s)?this._all(a,n):i.push(a))}e=i.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!m(t,e))return!1;for(var n=[];e;){for(var r=0;r<e.children.length;r++){var i=e.children[r],o=e.leaf?this.toBBox(i):i;if(m(t,o)){if(e.leaf||g(t,o))return!0;n.push(i)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=v([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,r,i,a=this.data,s=this.toBBox(t),c=[],u=[];a||c.length;){if(a||(a=c.pop(),r=c[c.length-1],n=u.pop(),i=!0),a.leaf){var l=o(t,a.children,e);if(-1!==l)return a.children.splice(l,1),c.push(a),this._condense(c),this}i||a.leaf||!g(a,s)?r?(n++,a=r.children[n],i=!1):a=null:(c.push(a),u.push(n),n=0,r=a,a=a.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,r){var i,o=n-e+1,s=this._maxEntries;if(o<=s)return a(i=v(t.slice(e,n+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,r-1))),(i=v([])).leaf=!1,i.height=r;var c=Math.ceil(o/s),u=c*Math.ceil(Math.sqrt(s));y(t,e,n,u,this.compareMinX);for(var l=e;l<=n;l+=u){var h=Math.min(l+u-1,n);y(t,l,h,c,this.compareMinY);for(var d=l;d<=h;d+=c){var f=Math.min(d+c-1,h);i.children.push(this._build(t,d,f,r-1))}}return a(i,this.toBBox),i},i.prototype._chooseSubtree=function(t,e,n,r){for(;r.push(e),!e.leaf&&r.length-1!==n;){for(var i=1/0,o=1/0,a=void 0,s=0;s<e.children.length;s++){var c=e.children[s],u=h(c),l=f(t,c)-u;l<o?(o=l,i=u<i?u:i,a=c):l===o&&u<i&&(i=u,a=c)}e=a||e.children[0]}return e},i.prototype._insert=function(t,e,n){var r=n?t:this.toBBox(t),i=[],o=this._chooseSubtree(r,this.data,e,i);for(o.children.push(t),c(o,r);e>=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)},i.prototype._split=function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=v(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,a(n,this.toBBox),a(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},i.prototype._splitRoot=function(t,e){this.data=v([t,e]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var r,i=1/0,o=1/0,a=e;a<=n-e;a++){var c=s(t,0,a,this.toBBox),u=s(t,a,n,this.toBBox),l=p(c,u),d=h(c)+h(u);l<i?(i=l,r=a,o=d<o?d:o):l===i&&d<o&&(o=d,r=a)}return r||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var r=t.leaf?this.compareMinX:u,i=t.leaf?this.compareMinY:l;this._allDistMargin(t,e,n,r)<this._allDistMargin(t,e,n,i)&&t.children.sort(r)},i.prototype._allDistMargin=function(t,e,n,r){t.children.sort(r);for(var i=this.toBBox,o=s(t,0,e,i),a=s(t,n-e,n,i),u=d(o)+d(a),l=e;l<n-e;l++){var h=t.children[l];c(o,t.leaf?i(h):h),u+=d(o)}for(var f=n-e-1;f>=e;f--){var p=t.children[f];c(a,t.leaf?i(p):p),u+=d(a)}return u},i.prototype._adjustParentBBoxes=function(t,e,n){for(var r=n;r>=0;r--)c(e[r],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():a(t[e],this.toBBox)},i}()}(qn);var Yn,Kn,Xn=qn.exports;!function(t){t.GROUP="g",t.CIRCLE="circle",t.ELLIPSE="ellipse",t.IMAGE="image",t.RECT="rect",t.LINE="line",t.POLYLINE="polyline",t.POLYGON="polygon",t.TEXT="text",t.PATH="path",t.HTML="html",t.MESH="mesh"}(Yn||(Yn={})),function(t){t[t.ZERO=0]="ZERO",t[t.NEGATIVE_ONE=1]="NEGATIVE_ONE"}(Kn||(Kn={}));var Zn=function(){function t(){this.plugins=[]}return t.prototype.addRenderingPlugin=function(t){this.plugins.push(t),this.context.renderingPlugins.push(t)},t.prototype.removeAllRenderingPlugins=function(){var t=this;this.plugins.forEach((function(e){var n=t.context.renderingPlugins.indexOf(e);n>=0&&t.context.renderingPlugins.splice(n,1)}))},t}(),Qn=function(){function t(t){this.clipSpaceNearZ=Kn.NEGATIVE_ONE,this.plugins=[],this.config=i({enableDirtyCheck:!0,enableCulling:!1,enableAutoRendering:!0,enableDirtyRectangleRendering:!0,enableDirtyRectangleRenderingDebug:!1,enableSizeAttenuation:!0},t)}return t.prototype.registerPlugin=function(t){-1===this.plugins.findIndex((function(e){return e===t}))&&this.plugins.push(t)},t.prototype.unregisterPlugin=function(t){var e=this.plugins.findIndex((function(e){return e===t}));e>-1&&this.plugins.splice(e,1)},t.prototype.getPlugins=function(){return this.plugins},t.prototype.getPlugin=function(t){return this.plugins.find((function(e){return e.name===t}))},t.prototype.getConfig=function(){return this.config},t.prototype.setConfig=function(t){Object.assign(this.config,t)},t}();function Jn(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function tr(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function er(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function nr(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function rr(t){return void 0===t?0:t>360||t<-360?t%360:t}function ir(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Array.isArray(t)&&3===t.length?Q(t):Wt(t)?tt(t,e,n):tt(t[0],t[1]||e,t[2]||n)}function or(t){return t*(Math.PI/180)}function ar(t){return t*(180/Math.PI)}function sr(t,e){return 16===e.length?function(t,e){var n,r,i=.5*Math.PI,o=u(j(Z(),e),3),a=o[0],s=o[1],c=o[2],l=Math.asin(-e[2]/a);return l<i?l>-i?(n=Math.atan2(e[6]/s,e[10]/c),r=Math.atan2(e[1]/a,e[0]/a)):(r=0,n=-Math.atan2(e[4]/s,e[5]/s)):(r=0,n=Math.atan2(e[4]/s,e[5]/s)),t[0]=n,t[1]=l,t[2]=r,t}(t,e):function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=r*r,s=i*i,c=o*o,u=n*n+a+s+c,l=n*o-r*i;return l>.499995*u?(t[0]=Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):l<-.499995*u?(t[0]=-Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):(t[0]=Math.asin(2*(n*i-o*r)),t[1]=Math.atan2(2*(n*o+r*i),1-2*(s+c)),t[2]=Math.atan2(2*(n*r+i*o),1-2*(a+s))),t}(t,e)}function cr(t,e,n,r,i){var o,a,s,c,u,l,h,d,f,p,g=Math.cos(t),m=Math.sin(t);return o=r*g,a=i*m,s=0,c=-r*m,u=i*g,l=0,h=e,d=n,f=1,(p=new y(9))[0]=o,p[1]=a,p[2]=s,p[3]=c,p[4]=u,p[5]=l,p[6]=h,p[7]=d,p[8]=f,p}function ur(t){var e=t[0],n=t[1],r=t[3],i=t[4],o=Math.sqrt(e*e+n*n),a=Math.sqrt(r*r+i*i);e*i-n*r<0&&(e<i?o=-o:a=-a),o&&(e*=1/o,n*=1/o),a&&(r*=1/a,i*=1/a);var s=ar(Math.atan2(n,e));return[t[6],t[7],o,a,s]}var lr=x(),hr=x(),dr=pt(),fr=[Z(),Z(),Z()],pr=Z();function gr(t,e,n,r,i){t[0]=e[0]*r+n[0]*i,t[1]=e[1]*r+n[1]*i,t[2]=e[2]*r+n[2]*i}var mr,vr=function(){function t(){this.center=[0,0,0],this.halfExtents=[0,0,0],this.min=[0,0,0],this.max=[0,0,0]}return t.isEmpty=function(t){return!t||0===t.halfExtents[0]&&0===t.halfExtents[1]&&0===t.halfExtents[2]},t.prototype.update=function(t,e){Jn(this.center,t),Jn(this.halfExtents,e),tr(this.min,this.center,this.halfExtents),er(this.max,this.center,this.halfExtents)},t.prototype.setMinMax=function(t,e){er(this.center,e,t),nr(this.center,this.center,.5),tr(this.halfExtents,e,t),nr(this.halfExtents,this.halfExtents,.5),Jn(this.min,t),Jn(this.max,e)},t.prototype.getMin=function(){return this.min},t.prototype.getMax=function(){return this.max},t.prototype.add=function(e){if(!t.isEmpty(e))if(t.isEmpty(this))this.setMinMax(e.getMin(),e.getMax());else{var n=this.center,r=n[0],i=n[1],o=n[2],a=this.halfExtents,s=a[0],c=a[1],u=a[2],l=r-s,h=r+s,d=i-c,f=i+c,p=o-u,g=o+u,m=e.center,v=m[0],y=m[1],b=m[2],x=e.halfExtents,E=x[0],w=x[1],M=x[2],N=v-E,S=v+E,C=y-w,T=y+w,P=b-M,k=b+M;N<l&&(l=N),S>h&&(h=S),C<d&&(d=C),T>f&&(f=T),P<p&&(p=P),k>g&&(g=k),n[0]=.5*(l+h),n[1]=.5*(d+f),n[2]=.5*(p+g),a[0]=.5*(h-l),a[1]=.5*(f-d),a[2]=.5*(g-p),this.min[0]=l,this.min[1]=d,this.min[2]=p,this.max[0]=h,this.max[1]=f,this.max[2]=g}},t.prototype.setFromTransformedAABB=function(t,e){var n=this.center,r=this.halfExtents,i=t.center,o=t.halfExtents,a=e[0],s=e[4],c=e[8],u=e[1],l=e[5],h=e[9],d=e[2],f=e[6],p=e[10],g=Math.abs(a),m=Math.abs(s),v=Math.abs(c),y=Math.abs(u),b=Math.abs(l),x=Math.abs(h),E=Math.abs(d),w=Math.abs(f),M=Math.abs(p);n[0]=e[12]+a*i[0]+s*i[1]+c*i[2],n[1]=e[13]+u*i[0]+l*i[1]+h*i[2],n[2]=e[14]+d*i[0]+f*i[1]+p*i[2],r[0]=g*o[0]+m*o[1]+v*o[2],r[1]=y*o[0]+b*o[1]+x*o[2],r[2]=E*o[0]+w*o[1]+M*o[2],tr(this.min,n,r),er(this.max,n,r)},t.prototype.intersects=function(t){var e=this.getMax(),n=this.getMin(),r=t.getMax(),i=t.getMin();return n[0]<=r[0]&&e[0]>=i[0]&&n[1]<=r[1]&&e[1]>=i[1]&&n[2]<=r[2]&&e[2]>=i[2]},t.prototype.intersection=function(e){if(!this.intersects(e))return null;var n=new t,r=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}([0,0,0],this.getMin(),e.getMin()),i=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}([0,0,0],this.getMax(),e.getMax());return n.setMinMax(r,i),n},t.prototype.getNegativeFarPoint=function(t){return 273===t.pnVertexFlag?Jn([0,0,0],this.min):272===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:257===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:256===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:17===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:16===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:1===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:[this.max[0],this.max[1],this.max[2]]},t.prototype.getPositiveFarPoint=function(t){return 273===t.pnVertexFlag?Jn([0,0,0],this.max):272===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:257===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:256===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:17===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:16===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:1===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:[this.min[0],this.min[1],this.min[2]]},t}(),yr=function(){function t(t,e){this.distance=t||0,this.normal=e||tt(0,1,0),this.updatePNVertexFlag()}return t.prototype.updatePNVertexFlag=function(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0)},t.prototype.distanceToPoint=function(t){return st(t,this.normal)-this.distance},t.prototype.normalize=function(){var t=1/ft(this.normal);ot(this.normal,this.normal,t),this.distance*=t},t.prototype.intersectsLine=function(t,e,n){var r=this.distanceToPoint(t),i=r/(r-this.distanceToPoint(e)),o=i>=0&&i<=1;return o&&n&&ut(n,t,e,i),o},t}();!function(t){t[t.OUTSIDE=4294967295]="OUTSIDE",t[t.INSIDE=0]="INSIDE",t[t.INDETERMINATE=2147483647]="INDETERMINATE"}(mr||(mr={}));var br,xr,Er,wr=function(){function t(t){if(this.planes=[],t)this.planes=t;else for(var e=0;e<6;e++)this.planes.push(new yr)}return t.prototype.extractFromVPMatrix=function(t){var e=u(t,16),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],l=e[7],h=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],v=e[14],y=e[15];nt(this.planes[0].normal,o-n,l-a,p-h),this.planes[0].distance=y-g,nt(this.planes[1].normal,o+n,l+a,p+h),this.planes[1].distance=y+g,nt(this.planes[2].normal,o+r,l+s,p+d),this.planes[2].distance=y+m,nt(this.planes[3].normal,o-r,l-s,p-d),this.planes[3].distance=y-m,nt(this.planes[4].normal,o-i,l-c,p-f),this.planes[4].distance=y-v,nt(this.planes[5].normal,o+i,l+c,p+f),this.planes[5].distance=y+v,this.planes.forEach((function(t){t.normalize(),t.updatePNVertexFlag()}))},t}(),Mr=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}return t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t}(),Nr=function(){function t(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r,this.left=t,this.right=t+n,this.top=e,this.bottom=e+r}return t.prototype.toJSON=function(){},t}(),Sr="Method not implemented.",Cr="Use document.documentElement instead.";!function(t){t[t.ORBITING=0]="ORBITING",t[t.EXPLORING=1]="EXPLORING",t[t.TRACKING=2]="TRACKING"}(br||(br={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ROTATIONAL=1]="ROTATIONAL",t[t.TRANSLATIONAL=2]="TRANSLATIONAL",t[t.CINEMATIC=3]="CINEMATIC"}(xr||(xr={})),function(t){t[t.ORTHOGRAPHIC=0]="ORTHOGRAPHIC",t[t.PERSPECTIVE=1]="PERSPECTIVE"}(Er||(Er={}));var Tr,Pr,kr,Ar,Or,_r="updated",Rr=2e-4,Dr=function(){function t(){this.clipSpaceNearZ=Kn.NEGATIVE_ONE,this.eventEmitter=new m,this.matrix=x(),this.right=tt(1,0,0),this.up=tt(0,1,0),this.forward=tt(0,0,1),this.position=tt(0,0,1),this.focalPoint=tt(0,0,0),this.distanceVector=tt(0,0,-1),this.distance=1,this.azimuth=0,this.elevation=0,this.roll=0,this.relAzimuth=0,this.relElevation=0,this.relRoll=0,this.dollyingStep=0,this.maxDistance=1/0,this.minDistance=-1/0,this.zoom=1,this.rotateWorld=!1,this.fov=30,this.near=.1,this.far=1e3,this.aspect=1,this.projectionMatrix=x(),this.projectionMatrixInverse=x(),this.jitteredProjectionMatrix=void 0,this.enableUpdate=!0,this.type=br.EXPLORING,this.trackingMode=xr.DEFAULT,this.projectionMode=Er.PERSPECTIVE,this.frustum=new wr,this.orthoMatrix=x()}return t.prototype.isOrtho=function(){return this.projectionMode===Er.ORTHOGRAPHIC},t.prototype.getProjectionMode=function(){return this.projectionMode},t.prototype.getPerspective=function(){return this.jitteredProjectionMatrix||this.projectionMatrix},t.prototype.getPerspectiveInverse=function(){return this.projectionMatrixInverse},t.prototype.getFrustum=function(){return this.frustum},t.prototype.getPosition=function(){return this.position},t.prototype.getFocalPoint=function(){return this.focalPoint},t.prototype.getDollyingStep=function(){return this.dollyingStep},t.prototype.getNear=function(){return this.near},t.prototype.getFar=function(){return this.far},t.prototype.getZoom=function(){return this.zoom},t.prototype.getOrthoMatrix=function(){return this.orthoMatrix},t.prototype.getView=function(){return this.view},t.prototype.setEnableUpdate=function(t){this.enableUpdate=t},t.prototype.setType=function(t,e){return this.type=t,this.type===br.EXPLORING?this.setWorldRotation(!0):this.setWorldRotation(!1),this._getAngles(),this.type===br.TRACKING&&void 0!==e&&this.setTrackingMode(e),this},t.prototype.setProjectionMode=function(t){return this.projectionMode=t,this},t.prototype.setTrackingMode=function(t){if(this.type!==br.TRACKING)throw new Error("Impossible to set a tracking mode if the camera is not of tracking type");return this.trackingMode=t,this},t.prototype.setWorldRotation=function(t){return this.rotateWorld=t,this._getAngles(),this},t.prototype.getViewTransform=function(){return C(x(),this.matrix)},t.prototype.getWorldTransform=function(){return this.matrix},t.prototype.jitterProjectionMatrix=function(t,e){var n=R(x(),[t,e,0]);this.jitteredProjectionMatrix=P(x(),n,this.projectionMatrix)},t.prototype.clearJitterProjectionMatrix=function(){this.jitteredProjectionMatrix=void 0},t.prototype.setMatrix=function(t){return this.matrix=t,this._update(),this},t.prototype.setFov=function(t){return this.setPerspective(this.near,this.far,t,this.aspect),this},t.prototype.setAspect=function(t){return this.setPerspective(this.near,this.far,this.fov,t),this},t.prototype.setNear=function(t){return this.projectionMode===Er.PERSPECTIVE?this.setPerspective(t,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,t,this.far),this},t.prototype.setFar=function(t){return this.projectionMode===Er.PERSPECTIVE?this.setPerspective(this.near,t,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,t),this},t.prototype.setViewOffset=function(t,e,n,r,i,o){return this.aspect=t/e,void 0===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.projectionMode===Er.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.clearViewOffset=function(){return void 0!==this.view&&(this.view.enabled=!1),this.projectionMode===Er.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.setZoom=function(t){return this.zoom=t,this.projectionMode===Er.ORTHOGRAPHIC?this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far):this.projectionMode===Er.PERSPECTIVE&&this.setPerspective(this.near,this.far,this.fov,this.aspect),this},t.prototype.setZoomByViewportPoint=function(t,e){var n=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),r=n.x,i=n.y,o=this.roll;this.rotate(0,0,-o),this.setPosition(r,i),this.setFocalPoint(r,i),this.setZoom(t),this.rotate(0,0,o);var a=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),s=tt(a.x-r,a.y-i,0),c=st(s,this.right)/J(this.right),u=st(s,this.up)/J(this.up);return this.pan(-c,-u),this},t.prototype.setPerspective=function(t,e,n,r){var i;this.projectionMode=Er.PERSPECTIVE,this.fov=n,this.near=t,this.far=e,this.aspect=r;var o=this.near*Math.tan(or(.5*this.fov))/this.zoom,a=2*o,s=this.aspect*a,c=-.5*s;if(null===(i=this.view)||void 0===i?void 0:i.enabled){var u=this.view.fullWidth,l=this.view.fullHeight;c+=this.view.offsetX*s/u,o-=this.view.offsetY*a/l,s*=this.view.width/u,a*=this.view.height/l}return function(t,e,n,r,i,o,a,s){void 0===s&&(s=!1);var c,u,l=2*o/(n-e),h=2*o/(r-i),d=(n+e)/(n-e),f=(r+i)/(r-i);s?(c=-a/(a-o),u=-a*o/(a-o)):(c=-(a+o)/(a-o),u=-2*a*o/(a-o)),t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=h,t[6]=0,t[7]=0,t[8]=d,t[9]=f,t[10]=c,t[11]=-1,t[12]=0,t[13]=0,t[14]=u,t[15]=0}(this.projectionMatrix,c,c+s,o,o-a,t,this.far,this.clipSpaceNearZ===Kn.ZERO),A(this.projectionMatrix,this.projectionMatrix,tt(1,-1,1)),C(this.projectionMatrixInverse,this.projectionMatrix),this.triggerUpdate(),this},t.prototype.setOrthographic=function(t,e,n,r,i,o){var a;this.projectionMode=Er.ORTHOGRAPHIC,this.rright=e,this.left=t,this.top=n,this.bottom=r,this.near=i,this.far=o;var s=(this.rright-this.left)/(2*this.zoom),c=(this.top-this.bottom)/(2*this.zoom),u=(this.rright+this.left)/2,l=(this.top+this.bottom)/2,h=u-s,d=u+s,f=l+c,p=l-c;if(null===(a=this.view)||void 0===a?void 0:a.enabled){var g=(this.rright-this.left)/this.view.fullWidth/this.zoom,m=(this.top-this.bottom)/this.view.fullHeight/this.zoom;d=(h+=g*this.view.offsetX)+g*this.view.width,p=(f-=m*this.view.offsetY)-m*this.view.height}return this.clipSpaceNearZ===Kn.NEGATIVE_ONE?U(this.projectionMatrix,h,d,p,f,i,o):H(this.projectionMatrix,h,d,p,f,i,o),A(this.projectionMatrix,this.projectionMatrix,tt(1,-1,1)),C(this.projectionMatrixInverse,this.projectionMatrix),this._getOrthoMatrix(),this.triggerUpdate(),this},t.prototype.setPosition=function(t,e,n){void 0===e&&(e=this.position[1]),void 0===n&&(n=this.position[2]);var r=ir(t,e,n);return this._setPosition(r),this.setFocalPoint(this.focalPoint),this.triggerUpdate(),this},t.prototype.setFocalPoint=function(t,e,n){void 0===e&&(e=this.focalPoint[1]),void 0===n&&(n=this.focalPoint[2]);var r=tt(0,1,0);if(this.focalPoint=ir(t,e,n),this.trackingMode===xr.CINEMATIC){var i=it(Z(),this.focalPoint,this.position);t=i[0],e=i[1],n=i[2];var o=J(i),a=ar(Math.asin(e/o)),s=90+ar(Math.atan2(n,t)),c=x();_(c,c,or(s)),O(c,c,or(a)),r=lt(Z(),[0,1,0],c)}return C(this.matrix,$(x(),this.position,this.focalPoint,r)),this._getAxes(),this._getDistance(),this._getAngles(),this.triggerUpdate(),this},t.prototype.getDistance=function(){return this.distance},t.prototype.getDistanceVector=function(){return this.distanceVector},t.prototype.setDistance=function(t){if(this.distance===t||t<0)return this;this.distance=t,this.distance<Rr&&(this.distance=Rr),this.dollyingStep=this.distance/100;var e=Z();t=this.distance;var n=this.forward,r=this.focalPoint;return e[0]=t*n[0]+r[0],e[1]=t*n[1]+r[1],e[2]=t*n[2]+r[2],this._setPosition(e),this.triggerUpdate(),this},t.prototype.setMaxDistance=function(t){return this.maxDistance=t,this},t.prototype.setMinDistance=function(t){return this.minDistance=t,this},t.prototype.setAzimuth=function(t){return this.azimuth=rr(t),this.computeMatrix(),this._getAxes(),this.type===br.ORBITING||this.type===br.EXPLORING?this._getPosition():this.type===br.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getAzimuth=function(){return this.azimuth},t.prototype.setElevation=function(t){return this.elevation=rr(t),this.computeMatrix(),this._getAxes(),this.type===br.ORBITING||this.type===br.EXPLORING?this._getPosition():this.type===br.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getElevation=function(){return this.elevation},t.prototype.setRoll=function(t){return this.roll=rr(t),this.computeMatrix(),this._getAxes(),this.type===br.ORBITING||this.type===br.EXPLORING?this._getPosition():this.type===br.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getRoll=function(){return this.roll},t.prototype._update=function(){this._getAxes(),this._getPosition(),this._getDistance(),this._getAngles(),this._getOrthoMatrix(),this.triggerUpdate()},t.prototype.computeMatrix=function(){var t=vt(mt(),[0,0,1],or(this.roll));N(this.matrix);var e=vt(mt(),[1,0,0],or((this.rotateWorld&&this.type!==br.TRACKING||this.type===br.TRACKING?1:-1)*this.elevation)),n=vt(mt(),[0,1,0],or((this.rotateWorld&&this.type!==br.TRACKING||this.type===br.TRACKING?1:-1)*this.azimuth)),r=yt(mt(),n,e);r=yt(mt(),r,t);var i=F(x(),r);this.type===br.ORBITING||this.type===br.EXPLORING?(k(this.matrix,this.matrix,this.focalPoint),P(this.matrix,this.matrix,i),k(this.matrix,this.matrix,[0,0,this.distance])):this.type===br.TRACKING&&(k(this.matrix,this.matrix,this.position),P(this.matrix,this.matrix,i))},t.prototype._setPosition=function(t,e,n){this.position=ir(t,e,n);var r=this.matrix;r[12]=this.position[0],r[13]=this.position[1],r[14]=this.position[2],r[15]=1,this._getOrthoMatrix()},t.prototype._getAxes=function(){et(this.right,ir(gt(pt(),[1,0,0,0],this.matrix))),et(this.up,ir(gt(pt(),[0,1,0,0],this.matrix))),et(this.forward,ir(gt(pt(),[0,0,1,0],this.matrix))),at(this.right,this.right),at(this.up,this.up),at(this.forward,this.forward)},t.prototype._getAngles=function(){var t=this.distanceVector[0],e=this.distanceVector[1],n=this.distanceVector[2],r=J(this.distanceVector);if(0===r)return this.elevation=0,void(this.azimuth=0);this.type===br.TRACKING||this.rotateWorld?(this.elevation=ar(Math.asin(e/r)),this.azimuth=ar(Math.atan2(-t,-n))):(this.elevation=-ar(Math.asin(e/r)),this.azimuth=-ar(Math.atan2(-t,-n)))},t.prototype._getPosition=function(){et(this.position,ir(gt(pt(),[0,0,0,1],this.matrix))),this._getDistance()},t.prototype._getFocalPoint=function(){!function(t,e,n){var r=e[0],i=e[1],o=e[2];t[0]=r*n[0]+i*n[3]+o*n[6],t[1]=r*n[1]+i*n[4]+o*n[7],t[2]=r*n[2]+i*n[5]+o*n[8]}(this.distanceVector,[0,0,-this.distance],function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(b(),this.matrix)),rt(this.focalPoint,this.position,this.distanceVector),this._getDistance()},t.prototype._getDistance=function(){this.distanceVector=it(Z(),this.focalPoint,this.position),this.distance=J(this.distanceVector),this.dollyingStep=this.distance/100},t.prototype._getOrthoMatrix=function(){if(this.projectionMode===Er.ORTHOGRAPHIC){var t=this.position,e=vt(mt(),[0,0,1],-this.roll*Math.PI/180);B(this.orthoMatrix,e,tt((this.rright-this.left)/2-t[0],(this.top-this.bottom)/2-t[1],0),tt(this.zoom,this.zoom,1),t)}},t.prototype.triggerUpdate=function(){if(this.enableUpdate){var t=this.getViewTransform(),e=P(x(),this.getPerspective(),t);this.getFrustum().extractFromVPMatrix(e),this.eventEmitter.emit(_r)}},t.prototype.rotate=function(t,e,n){throw new Error(Sr)},t.prototype.pan=function(t,e){throw new Error(Sr)},t.prototype.dolly=function(t){throw new Error(Sr)},t.prototype.createLandmark=function(t,e){throw new Error(Sr)},t.prototype.gotoLandmark=function(t,e){throw new Error(Sr)},t.prototype.cancelLandmarkAnimation=function(){throw new Error(Sr)},t}();function Ir(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return n.cache=a.set(o,s)||a,s};return n.cache=new(Ir.Cache||Map),n}Ir.Cache=Map,function(t){t[t.kUnknown=0]="kUnknown",t[t.kNumber=1]="kNumber",t[t.kPercentage=2]="kPercentage",t[t.kEms=3]="kEms",t[t.kPixels=4]="kPixels",t[t.kRems=5]="kRems",t[t.kDegrees=6]="kDegrees",t[t.kRadians=7]="kRadians",t[t.kGradians=8]="kGradians",t[t.kTurns=9]="kTurns",t[t.kMilliseconds=10]="kMilliseconds",t[t.kSeconds=11]="kSeconds",t[t.kInteger=12]="kInteger"}(Tr||(Tr={})),function(t){t[t.kUNumber=0]="kUNumber",t[t.kUPercent=1]="kUPercent",t[t.kULength=2]="kULength",t[t.kUAngle=3]="kUAngle",t[t.kUTime=4]="kUTime",t[t.kUOther=5]="kUOther"}(Pr||(Pr={})),function(t){t[t.kAll=0]="kAll",t[t.kNonNegative=1]="kNonNegative",t[t.kInteger=2]="kInteger",t[t.kNonNegativeInteger=3]="kNonNegativeInteger",t[t.kPositiveInteger=4]="kPositiveInteger"}(kr||(kr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Ar||(Ar={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Or||(Or={}));var Lr,jr=[{name:"em",unit_type:Tr.kEms},{name:"px",unit_type:Tr.kPixels},{name:"deg",unit_type:Tr.kDegrees},{name:"rad",unit_type:Tr.kRadians},{name:"grad",unit_type:Tr.kGradians},{name:"ms",unit_type:Tr.kMilliseconds},{name:"s",unit_type:Tr.kSeconds},{name:"rem",unit_type:Tr.kRems},{name:"turn",unit_type:Tr.kTurns}];!function(t){t[t.kUnknownType=0]="kUnknownType",t[t.kUnparsedType=1]="kUnparsedType",t[t.kKeywordType=2]="kKeywordType",t[t.kUnitType=3]="kUnitType",t[t.kSumType=4]="kSumType",t[t.kProductType=5]="kProductType",t[t.kNegateType=6]="kNegateType",t[t.kInvertType=7]="kInvertType",t[t.kMinType=8]="kMinType",t[t.kMaxType=9]="kMaxType",t[t.kClampType=10]="kClampType",t[t.kTransformType=11]="kTransformType",t[t.kPositionType=12]="kPositionType",t[t.kURLImageType=13]="kURLImageType",t[t.kColorType=14]="kColorType",t[t.kUnsupportedColorType=15]="kUnsupportedColorType"}(Lr||(Lr={}));var zr,Br=function(t){return t?"number"===t?Tr.kNumber:"percent"===t||"%"===t?Tr.kPercentage:function(t){return jr.find((function(e){return e.name===t})).unit_type}(t):Tr.kUnknown},Fr=function(t){var e=1;switch(t){case Tr.kPixels:case Tr.kDegrees:case Tr.kSeconds:break;case Tr.kMilliseconds:e=.001;break;case Tr.kRadians:e=180/Math.PI;break;case Tr.kGradians:e=.9;break;case Tr.kTurns:e=360}return e},Gr=function(t){switch(t){case Tr.kNumber:case Tr.kInteger:return"";case Tr.kPercentage:return"%";case Tr.kEms:return"em";case Tr.kRems:return"rem";case Tr.kPixels:return"px";case Tr.kDegrees:return"deg";case Tr.kRadians:return"rad";case Tr.kGradians:return"grad";case Tr.kMilliseconds:return"ms";case Tr.kSeconds:return"s";case Tr.kTurns:return"turn"}return""},Vr=function(){function t(){}return t.isAngle=function(t){return t===Tr.kDegrees||t===Tr.kRadians||t===Tr.kGradians||t===Tr.kTurns},t.isLength=function(t){return t>=Tr.kEms&&t<Tr.kDegrees},t.isRelativeUnit=function(t){return t===Tr.kPercentage||t===Tr.kEms||t===Tr.kRems},t.isTime=function(t){return t===Tr.kSeconds||t===Tr.kMilliseconds},t.prototype.toString=function(){return this.buildCSSText(Ar.kNo,Or.kNo,"")},t.prototype.isNumericValue=function(){return this.getType()>=Lr.kUnitType&&this.getType()<=Lr.kClampType},t}(),Wr=function(t){function e(e){var n=t.call(this)||this;return n.colorSpace=e,n}return r(e,t),e.prototype.getType=function(){return Lr.kColorType},e.prototype.to=function(t){return this},e}(Vr);!function(t){t[t.Constant=0]="Constant",t[t.LinearGradient=1]="LinearGradient",t[t.RadialGradient=2]="RadialGradient"}(zr||(zr={}));var Ur=function(t){function e(e,n){var r=t.call(this)||this;return r.type=e,r.value=n,r}return r(e,t),e.prototype.clone=function(){return new e(this.type,this.value)},e.prototype.buildCSSText=function(t,e,n){return n},e.prototype.getType=function(){return Lr.kColorType},e}(Vr),Hr=function(t){function e(e){var n=t.call(this)||this;return n.value=e,n}return r(e,t),e.prototype.clone=function(){return new e(this.value)},e.prototype.getType=function(){return Lr.kKeywordType},e.prototype.buildCSSText=function(t,e,n){return n+this.value},e}(Vr),$r=Ir((function(t){return void 0===t&&(t=""),t.replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()}))})),qr=function(t){return t.split("").map((function(t,e){return t.toUpperCase()===t?"".concat(0!==e?"-":"").concat(t.toLowerCase()):t})).join("")};function Yr(t){return"function"==typeof t}var Kr={d:{alias:"path"},strokeDasharray:{alias:"lineDash"},strokeWidth:{alias:"lineWidth"},textAnchor:{alias:"textAlign"},src:{alias:"img"}},Xr=Ir((function(t){var e=$r(t),n=Kr[e];return e=(null==n?void 0:n.alias)||e})),Zr=function(t,e){void 0===e&&(e="");var n="";return Number.isFinite(t)?(!function(t){if(!t)throw new Error}(Number.isNaN(t)),n="NaN"):n=t>0?"infinity":"-infinity",n+e},Qr=function(t){return function(t){switch(t){case Pr.kUNumber:return Tr.kNumber;case Pr.kULength:return Tr.kPixels;case Pr.kUPercent:return Tr.kPercentage;case Pr.kUTime:return Tr.kSeconds;case Pr.kUAngle:return Tr.kDegrees;default:return Tr.kUnknown}}(function(t){switch(t){case Tr.kNumber:case Tr.kInteger:return Pr.kUNumber;case Tr.kPercentage:return Pr.kUPercent;case Tr.kPixels:return Pr.kULength;case Tr.kMilliseconds:case Tr.kSeconds:return Pr.kUTime;case Tr.kDegrees:case Tr.kRadians:case Tr.kGradians:case Tr.kTurns:return Pr.kUAngle;default:return Pr.kUOther}}(t))},Jr=function(t){function e(e,n){void 0===n&&(n=Tr.kNumber);var r,i=t.call(this)||this;return r="string"==typeof n?Br(n):n,i.unit=r,i.value=e,i}return r(e,t),e.prototype.clone=function(){return new e(this.value,this.unit)},e.prototype.equals=function(t){var e=t;return this.value===e.value&&this.unit===e.unit},e.prototype.getType=function(){return Lr.kUnitType},e.prototype.convertTo=function(t){if(this.unit===t)return new e(this.value,this.unit);var n=Qr(this.unit);if(n!==Qr(t)||n===Tr.kUnknown)return null;var r=Fr(this.unit)/Fr(t);return new e(this.value*r,t)},e.prototype.buildCSSText=function(t,e,n){var r;switch(this.unit){case Tr.kUnknown:break;case Tr.kInteger:r=Number(this.value).toFixed(0);break;case Tr.kNumber:case Tr.kPercentage:case Tr.kEms:case Tr.kRems:case Tr.kPixels:case Tr.kDegrees:case Tr.kRadians:case Tr.kGradians:case Tr.kMilliseconds:case Tr.kSeconds:case Tr.kTurns:var i=this.value,o=Gr(this.unit);if(i<-999999||i>999999){var a=Gr(this.unit);r=!Number.isFinite(i)||Number.isNaN(i)?Zr(i,a):i+(a||"")}else r="".concat(i).concat(o)}return n+=r},e}(Vr),ti=new Jr(0,"px");new Jr(1,"px");var ei,ni,ri=new Jr(0,"deg"),ii=function(t){function e(e,n,r,i,o){void 0===i&&(i=1),void 0===o&&(o=!1);var a=t.call(this,"rgb")||this;return a.r=e,a.g=n,a.b=r,a.alpha=i,a.isNone=o,a}return r(e,t),e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.alpha)},e.prototype.buildCSSText=function(t,e,n){return n+"rgba(".concat(this.r,",").concat(this.g,",").concat(this.b,",").concat(this.alpha,")")},e}(Wr),oi=new Hr("unset"),ai=new Hr("initial"),si=new Hr("inherit"),ci={"":oi,unset:oi,initial:ai,inherit:si},ui=function(t){return ci[t]||(ci[t]=new Hr(t)),ci[t]},li=new ii(0,0,0,0,!0),hi=new ii(0,0,0,0),di=Ir((function(t,e,n,r){return new ii(t,e,n,r)}),(function(t,e,n,r){return"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")")})),fi=function(t,e){return void 0===e&&(e=Tr.kNumber),new Jr(t,e)},pi=new Jr(50,"%");!function(t){t[t.Standard=0]="Standard"}(ei||(ei={})),function(t){t[t.ADDED=0]="ADDED",t[t.REMOVED=1]="REMOVED",t[t.Z_INDEX_CHANGED=2]="Z_INDEX_CHANGED"}(ni||(ni={}));var gi,mi={absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Nr(0,0,0,0)};function vi(t){var e=t.type,n=t.value;return"hex"===e?"#".concat(n):"literal"===e?n:"rgb"===e?"rgb(".concat(n.join(","),")"):"rgba(".concat(n.join(","),")")}!function(t){t.COORDINATE="<coordinate>",t.COLOR="<color>",t.PAINT="<paint>",t.NUMBER="<number>",t.ANGLE="<angle>",t.OPACITY_VALUE="<opacity-value>",t.SHADOW_BLUR="<shadow-blur>",t.LENGTH="<length>",t.PERCENTAGE="<percentage>",t.LENGTH_PERCENTAGE="<length> | <percentage>",t.LENGTH_PERCENTAGE_12="[<length> | <percentage>]{1,2}",t.LENGTH_PERCENTAGE_14="[<length> | <percentage>]{1,4}",t.LIST_OF_POINTS="<list-of-points>",t.PATH="<path>",t.FILTER="<filter>",t.Z_INDEX="<z-index>",t.OFFSET_DISTANCE="<offset-distance>",t.DEFINED_PATH="<defined-path>",t.MARKER="<marker>",t.TRANSFORM="<transform>",t.TRANSFORM_ORIGIN="<transform-origin>",t.TEXT="<text>",t.TEXT_TRANSFORM="<text-transform>"}(gi||(gi={}));var yi=function(){var t={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},e="";function n(t){throw new Error(e+": "+t)}function r(){var t=f(i);return e.length>0&&n("Invalid input not EOF"),t}function i(){return o("linear-gradient",t.linearGradient,s)||o("repeating-linear-gradient",t.repeatingLinearGradient,s)||o("radial-gradient",t.radialGradient,c)||o("repeating-radial-gradient",t.repeatingRadialGradient,c)||o("conic-gradient",t.conicGradient,c)}function o(e,r,i){return a(r,(function(r){var o=i();return o&&(b(t.comma)||n("Missing comma before color stops")),{type:e,orientation:o,colorStops:f(p)}}))}function a(e,r){var i=b(e);if(i){b(t.startCall)||n("Missing (");var o=r(i);return b(t.endCall)||n("Missing )"),o}}function s(){return y("directional",t.sideOrCorner,1)||y("angular",t.angleValue,1)}function c(){var n,r,i=u();return i&&((n=[]).push(i),r=e,b(t.comma)&&((i=u())?n.push(i):e=r)),n}function u(){var t=function(){var t=y("shape",/^(circle)/i,0);t&&(t.style=v()||l());return t}()||function(){var t=y("shape",/^(ellipse)/i,0);t&&(t.style=m()||l());return t}();if(t)t.at=h();else{var e=l();if(e){t=e;var n=h();n&&(t.at=n)}else{var r=d();r&&(t={type:"default-radial",at:r})}}return t}function l(){return y("extent-keyword",t.extentKeywords,1)}function h(){if(y("position",/^at/,0)){var t=d();return t||n("Missing positioning value"),t}}function d(){var t={x:m(),y:m()};if(t.x||t.y)return{type:"position",value:t}}function f(e){var r=e(),i=[];if(r)for(i.push(r);b(t.comma);)(r=e())?i.push(r):n("One extra comma");return i}function p(){var e=y("hex",t.hexColor,1)||a(t.rgbaColor,(function(){return{type:"rgba",value:f(g)}}))||a(t.rgbColor,(function(){return{type:"rgb",value:f(g)}}))||y("literal",t.literalColor,0);return e||n("Expected color definition"),e.length=m(),e}function g(){return b(t.number)[1]}function m(){return y("%",t.percentageValue,1)||y("position-keyword",t.positionKeywords,1)||v()}function v(){return y("px",t.pixelValue,1)||y("em",t.emValue,1)}function y(t,e,n){var r=b(e);if(r)return{type:t,value:r[n]}}function b(t){var n=/^[\n\r\t\s]+/.exec(e);n&&x(n[0].length);var r=t.exec(e);return r&&x(r[0].length),r}function x(t){e=e.substring(t)}return function(t){return e=t,r()}}();var bi=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,xi=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,Ei=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,wi=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;var Mi={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45},Ni=Ir((function(t){var e;return e="angular"===t.type?Number(t.value):Mi[t.value]||0,fi(e,"deg")})),Si=Ir((function(t){var e=50,n=50,r="%",i="%";if("position"===(null==t?void 0:t.type)){var o=t.value,a=o.x,s=o.y;"position-keyword"===(null==a?void 0:a.type)&&("left"===a.value?e=0:"center"===a.value?e=50:"right"===a.value?e=100:"top"===a.value?n=0:"bottom"===a.value&&(n=100)),"position-keyword"===(null==s?void 0:s.type)&&("left"===s.value?e=0:"center"===s.value?n=50:"right"===s.value?e=100:"top"===s.value?n=0:"bottom"===s.value&&(n=100)),"px"!==(null==a?void 0:a.type)&&"%"!==(null==a?void 0:a.type)&&"em"!==(null==a?void 0:a.type)||(r=null==a?void 0:a.type,e=Number(a.value)),"px"!==(null==s?void 0:s.type)&&"%"!==(null==s?void 0:s.type)&&"em"!==(null==s?void 0:s.type)||(i=null==s?void 0:s.type,n=Number(s.value))}return{cx:fi(e,r),cy:fi(n,i)}})),Ci=Ir((function(t){var e;if(t.indexOf("linear")>-1||t.indexOf("radial")>-1)return yi(t).map((function(t){var e=t.type,n=t.orientation,r=t.colorStops;!function(t){var e,n,r,i=t.length;t[i-1].length=null!==(e=t[i-1].length)&&void 0!==e?e:{type:"%",value:"100"},i>1&&(t[0].length=null!==(n=t[0].length)&&void 0!==n?n:{type:"%",value:"0"});for(var o=0,a=Number(t[0].length.value),s=1;s<i;s++){var c=null===(r=t[s].length)||void 0===r?void 0:r.value;if(!kt(c)&&!kt(a)){for(var u=1;u<s-o;u++)t[o+u].length={type:"%",value:"".concat(a+(Number(c)-a)*u/(s-o))};o=s,a=Number(c)}}}(r);var i=r.map((function(t){return{offset:fi(Number(t.length.value),"%"),color:vi(t)}}));if("linear-gradient"===e)return new Ur(zr.LinearGradient,{angle:n?Ni(n):ri,steps:i});if("radial-gradient"===e&&(n||(n=[{type:"shape",value:"circle"}]),"shape"===n[0].type&&"circle"===n[0].value)){var o=Si(n[0].at),a=o.cx,s=o.cy,c=void 0;if(n[0].style){var u=n[0].style,l=u.type,h=u.value;c="extent-keyword"===l?ui(h):fi(h,l)}return new Ur(zr.RadialGradient,{cx:a,cy:s,size:c,steps:i})}}));var n=t[0];if("("===t[1]||"("===t[2])if("l"===n){var r=bi.exec(t);if(r){var i=(null===(e=r[2].match(wi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return[new Ur(zr.LinearGradient,{angle:fi(parseFloat(r[1]),"deg"),steps:i.map((function(t){var e=u(t,2),n=e[0],r=e[1];return{offset:fi(100*Number(n),"%"),color:r}}))})]}}else if("r"===n){var o=function(t){var e,n=xi.exec(t);if(n){var r=(null===(e=n[4].match(wi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return{cx:fi(50,"%"),cy:fi(50,"%"),steps:r.map((function(t){var e=u(t,2),n=e[0],r=e[1];return{offset:fi(100*Number(n),"%"),color:r}}))}}return null}(t);if(o){if(!Bt(o))return[new Ur(zr.RadialGradient,o)];t=o}}else if("p"===n)return function(t){var e=Ei.exec(t);if(e){var n=e[1],r=e[2];switch(n){case"a":n="repeat";break;case"x":n="repeat-x";break;case"y":n="repeat-y";break;default:n="no-repeat"}return{image:r,repetition:n}}return null}(t)}));function Ti(t){return t&&!!t.image}function Pi(t){return t&&!kt(t.r)&&!kt(t.g)&&!kt(t.b)}var ki=Ir((function(t){if(Ti(t))return i({repetition:"repeat"},t);if(kt(t)&&(t=""),"transparent"===t)return hi;"currentColor"===t&&(t="black");var e=Ci(t);if(e)return e;var n=vn(t),r=[0,0,0,0];return null!==n&&(r[0]=n.r||0,r[1]=n.g||0,r[2]=n.b||0,r[3]=n.opacity),di.apply(void 0,l([],u(r),!1))}));function Ai(t,e){if(Pi(t)&&Pi(e))return[[Number(t.r),Number(t.g),Number(t.b),Number(t.alpha)],[Number(e.r),Number(e.g),Number(e.b),Number(e.alpha)],function(t){var e=t.slice();if(e[3])for(var n=0;n<3;n++)e[n]=Math.round(Vt(e[n],0,255));return e[3]=Vt(e[3],0,1),"rgba(".concat(e.join(","),")")}]}function Oi(t,e){if(kt(e))return fi(0,"px");if(e="".concat(e).trim().toLowerCase(),isFinite(Number(e))){if("px".search(t)>=0)return fi(Number(e),"px");if("deg".search(t)>=0)return fi(Number(e),"deg")}var n=[];e=e.replace(t,(function(t){return n.push(t),"U"+t}));var r="U("+t.source+")";return n.map((function(t){return fi(Number(e.replace(new RegExp("U"+t,"g"),"").replace(new RegExp(r,"g"),"*0")),t)}))[0]}var _i=function(t){return Oi(new RegExp("px","g"),t)},Ri=Ir(_i);Ir((function(t){return Oi(new RegExp("%","g"),t)}));var Di=function(t){return Wt(t)||isFinite(Number(t))?fi(Number(t)||0,"px"):Oi(new RegExp("px|%|em|rem","g"),t)},Ii=Ir(Di),Li=function(t){return Oi(new RegExp("deg|rad|grad|turn","g"),t)},ji=Ir(Li);function zi(t,e,n,r,i){void 0===i&&(i=0);var o="",a=t.value||0,s=e.value||0,c=Qr(t.unit),u=t.convertTo(c),l=e.convertTo(c);return u&&l?(a=u.value,s=l.value,o=Gr(t.unit)):(Jr.isLength(t.unit)||Jr.isLength(e.unit))&&(a=Vi(t,i,n),s=Vi(e,i,n),o="px"),[a,s,function(t){return r&&(t=Math.max(t,0)),t+o}]}function Bi(t){var e=0;return t.unit===Tr.kDegrees?e=t.value:t.unit===Tr.kRadians?e=ar(Number(t.value)):t.unit===Tr.kTurns&&(e=360*Number(t.value)),e}function Fi(t,e){var n;return Array.isArray(t)?n=t.map((function(t){return Number(t)})):Bt(t)?n=t.split(" ").map((function(t){return Number(t)})):Wt(t)&&(n=[t]),2===e?1===n.length?[n[0],n[0]]:[n[0],n[1]]:1===n.length?[n[0],n[0],n[0],n[0]]:2===n.length?[n[0],n[1],n[0],n[1]]:3===n.length?[n[0],n[1],n[2],n[1]]:[n[0],n[1],n[2],n[3]]}function Gi(t){return Bt(t)?t.split(" ").map((function(t){return Ii(t)})):t.map((function(t){return Ii(t.toString())}))}function Vi(t,e,n){if(0===t.value)return 0;if(t.unit===Tr.kPixels)return Number(t.value);if(t.unit===Tr.kPercentage&&n){var r=n.nodeName===Yn.GROUP?n.getLocalBounds():n.geometry.contentBounds;return t.value/100*r.halfExtents[e]*2}return 0}var Wi=["blur","brightness","drop-shadow","contrast","grayscale","sepia","saturate","hue-rotate","invert"];function Ui(t){if(void 0===t&&(t=""),"none"===(t=t.toLowerCase().trim()))return[];for(var e,n=/\s*([\w-]+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];if(i=e.index+e[0].length,Wi.indexOf(e[1])>-1&&r.push({name:e[1],params:e[2].split(" ").map((function(t){return Oi(/deg|rad|grad|turn|px|%/g,t)||ki(t)}))}),n.lastIndex===t.length)return r}return[]}function Hi(t){return t.toString()}var $i=function(t){return"number"==typeof t?fi(t):/^\s*[-+]?(\d*\.)?\d+\s*$/.test(t)?fi(Number(t)):fi(0)},qi=Ir($i);function Yi(t,e){return[t,e,Hi]}function Ki(t,e){return function(n,r){return[n,r,function(n){return Hi(Vt(n,t,e))}]}}function Xi(t,e){if(t.length===e.length)return[t,e,function(t){return t}]}function Zi(t){var e;return 0===t.parsedStyle.path.totalLength&&(t.parsedStyle.path.totalLength=$e(t.parsedStyle.path.absolutePath,void 0,i(i({},e),{bbox:!1,length:!0})).length),t.parsedStyle.path.totalLength}function Qi(t,e){return t[0]===e[0]&&t[1]===e[1]}function Ji(t,e){var n=t.prePoint,r=t.currentPoint,i=t.nextPoint,o=Math.pow(r[0]-n[0],2)+Math.pow(r[1]-n[1],2),a=Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2),s=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2),c=Math.acos((o+a-s)/(2*Math.sqrt(o)*Math.sqrt(a)));if(!c||0===Math.sin(c)||Ht(c,0))return{xExtra:0,yExtra:0};var u=Math.abs(Math.atan2(i[1]-r[1],i[0]-r[0])),l=Math.abs(Math.atan2(i[0]-r[0],i[1]-r[1]));return u=u>Math.PI/2?Math.PI-u:u,l=l>Math.PI/2?Math.PI-l:l,{xExtra:Math.cos(c/2-u)*(e/2*(1/Math.sin(c/2)))-e/2||0,yExtra:Math.cos(l-c/2)*(e/2*(1/Math.sin(c/2)))-e/2||0}}function to(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}Ir((function(t){return Bt(t)?t.split(" ").map(qi):t.map(qi)}));var eo=function(t,e){var n=t.x*e.x+t.y*e.y,r=Math.sqrt((Math.pow(t.x,2)+Math.pow(t.y,2))*(Math.pow(e.x,2)+Math.pow(e.y,2)));return(t.x*e.y-t.y*e.x<0?-1:1)*Math.acos(n/r)},no=function(t,e,n,r,i,o,a,s){e=Math.abs(e),n=Math.abs(n);var c=or(r=$t(r,360));if(t.x===a.x&&t.y===a.y)return{x:t.x,y:t.y,ellipticalArcAngle:0};if(0===e||0===n)return{x:0,y:0,ellipticalArcAngle:0};var u=(t.x-a.x)/2,l=(t.y-a.y)/2,h={x:Math.cos(c)*u+Math.sin(c)*l,y:-Math.sin(c)*u+Math.cos(c)*l},d=Math.pow(h.x,2)/Math.pow(e,2)+Math.pow(h.y,2)/Math.pow(n,2);d>1&&(e=Math.sqrt(d)*e,n=Math.sqrt(d)*n);var f=(Math.pow(e,2)*Math.pow(n,2)-Math.pow(e,2)*Math.pow(h.y,2)-Math.pow(n,2)*Math.pow(h.x,2))/(Math.pow(e,2)*Math.pow(h.y,2)+Math.pow(n,2)*Math.pow(h.x,2));f=f<0?0:f;var p=(i!==o?1:-1)*Math.sqrt(f),g=p*(e*h.y/n),m=p*(-n*h.x/e),v={x:Math.cos(c)*g-Math.sin(c)*m+(t.x+a.x)/2,y:Math.sin(c)*g+Math.cos(c)*m+(t.y+a.y)/2},y={x:(h.x-g)/e,y:(h.y-m)/n},b=eo({x:1,y:0},y),x=eo(y,{x:(-h.x-g)/e,y:(-h.y-m)/n});!o&&x>0?x-=2*Math.PI:o&&x<0&&(x+=2*Math.PI);var E=b+(x%=2*Math.PI)*s,w=e*Math.cos(E),M=n*Math.sin(E);return{x:Math.cos(c)*w-Math.sin(c)*M+v.x,y:Math.sin(c)*w+Math.cos(c)*M+v.y,ellipticalArcStartAngle:b,ellipticalArcEndAngle:b+x,ellipticalArcAngle:E,ellipticalArcCenter:v,resultantRx:e,resultantRy:n}};function ro(t,e,n){void 0===n&&(n=!0);var r=t.arcParams,i=r.rx,o=void 0===i?0:i,a=r.ry,s=void 0===a?0:a,c=r.xRotation,u=r.arcFlag,l=r.sweepFlag,h=no({x:t.prePoint[0],y:t.prePoint[1]},o,s,c,!!u,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},e),d=no({x:t.prePoint[0],y:t.prePoint[1]},o,s,c,!!u,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},n?e+.005:e-.005),f=d.x-h.x,p=d.y-h.y,g=Math.sqrt(f*f+p*p);return{x:-f/g,y:-p/g}}function io(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function oo(t,e){return io(t)*io(e)?(t[0]*e[0]+t[1]*e[1])/(io(t)*io(e)):1}function ao(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(oo(t,e))}function so(t,e){var n=e[1],r=e[2],i=$t(or(e[3]),2*Math.PI),o=e[4],a=e[5],s=t[0],c=t[1],u=e[6],l=e[7],h=Math.cos(i)*(s-u)/2+Math.sin(i)*(c-l)/2,d=-1*Math.sin(i)*(s-u)/2+Math.cos(i)*(c-l)/2,f=h*h/(n*n)+d*d/(r*r);f>1&&(n*=Math.sqrt(f),r*=Math.sqrt(f));var p=n*n*(d*d)+r*r*(h*h),g=p?Math.sqrt((n*n*(r*r)-p)/p):1;o===a&&(g*=-1),isNaN(g)&&(g=0);var m=r?g*n*d/r:0,v=n?g*-r*h/n:0,y=(s+u)/2+Math.cos(i)*m-Math.sin(i)*v,b=(c+l)/2+Math.sin(i)*m+Math.cos(i)*v,x=[(h-m)/n,(d-v)/r],E=[(-1*h-m)/n,(-1*d-v)/r],w=ao([1,0],x),M=ao(x,E);return oo(x,E)<=-1&&(M=Math.PI),oo(x,E)>=1&&(M=0),0===a&&M>0&&(M-=2*Math.PI),1===a&&M<0&&(M+=2*Math.PI),{cx:y,cy:b,rx:Qi(t,[u,l])?0:n,ry:Qi(t,[u,l])?0:r,startAngle:w,endAngle:w+M,xRotation:i,arcFlag:o,sweepFlag:a}}var co=function(t){if(""===t||Array.isArray(t)&&0===t.length)return{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:{x:0,y:0,width:0,height:0}};var e;try{e=Ae(t)}catch(n){e=Ae(""),console.error("[g]: Invalid SVG Path definition: ".concat(t))}!function(t){for(var e=0;e<t.length;e++){var n=t[e-1],r=t[e];if("M"===r[0]&&n){var i=n[0],o=[r[1],r[2]],a=void 0;"L"===i||"M"===i?a=[n[1],n[2]]:"C"!==i&&"A"!==i&&"Q"!==i||(a=[n[n.length-2],n[n.length-1]]),a&&Qi(o,a)&&(t.splice(e,1),e--)}}}(e);var n=function(t){for(var e=!1,n=t.length,r=0;r<n;r++){var i=t[r][0];if("C"===i||"A"===i||"Q"===i){e=!0;break}}return e}(e),r=function(t){for(var e=[],n=[],r=[],i=0;i<t.length;i++){var o=t[i],a=o[0];"M"===a?(r.length&&(n.push(r),r=[]),r.push([o[1],o[2]])):"Z"===a?r.length&&(e.push(r),r=[]):r.push([o[1],o[2]])}return r.length>0&&n.push(r),{polygons:e,polylines:n}}(e),i=r.polygons,o=r.polylines,a=function(t){for(var e=[],n=null,r=null,i=null,o=0,a=t.length,s=0;s<a;s++){var c=t[s];r=t[s+1];var u=c[0],l={command:u,prePoint:n,params:c,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(u){case"M":i=[c[1],c[2]],o=s;break;case"A":var h=so(n,c);l.arcParams=h}if("Z"===u)n=i,r=t[o+1];else{var d=c.length;n=[c[d-2],c[d-1]]}r&&"Z"===r[0]&&(r=t[o],e[o]&&(e[o].prePoint=n)),l.currentPoint=n,e[o]&&Qi(n,e[o].currentPoint)&&(e[o].prePoint=l.prePoint);var f=r?[r[r.length-2],r[r.length-1]]:null;l.nextPoint=f;var p=l.prePoint;if(["L","H","V"].includes(u))l.startTangent=[p[0]-n[0],p[1]-n[1]],l.endTangent=[n[0]-p[0],n[1]-p[1]];else if("Q"===u){var g=[c[1],c[2]];l.startTangent=[p[0]-g[0],p[1]-g[1]],l.endTangent=[n[0]-g[0],n[1]-g[1]]}else if("T"===u)g=to((y=e[s-1]).currentPoint,p),"Q"===y.command?(l.command="Q",l.startTangent=[p[0]-g[0],p[1]-g[1]],l.endTangent=[n[0]-g[0],n[1]-g[1]]):(l.command="TL",l.startTangent=[p[0]-n[0],p[1]-n[1]],l.endTangent=[n[0]-p[0],n[1]-p[1]]);else if("C"===u){var m=[c[1],c[2]],v=[c[3],c[4]];l.startTangent=[p[0]-m[0],p[1]-m[1]],l.endTangent=[n[0]-v[0],n[1]-v[1]],0===l.startTangent[0]&&0===l.startTangent[1]&&(l.startTangent=[m[0]-v[0],m[1]-v[1]]),0===l.endTangent[0]&&0===l.endTangent[1]&&(l.endTangent=[v[0]-m[0],v[1]-m[1]])}else if("S"===u){var y;m=to((y=e[s-1]).currentPoint,p),v=[c[1],c[2]],"C"===y.command?(l.command="C",l.startTangent=[p[0]-m[0],p[1]-m[1]],l.endTangent=[n[0]-v[0],n[1]-v[1]]):(l.command="SQ",l.startTangent=[p[0]-v[0],p[1]-v[1]],l.endTangent=[n[0]-v[0],n[1]-v[1]])}else if("A"===u){var b=ro(l,0),x=b.x,E=b.y,w=ro(l,1,!1),M=w.x,N=w.y;l.startTangent=[x,E],l.endTangent=[M,N]}e.push(l)}return e}(e),s=function(t,e){for(var n=[],r=[],i=[],o=0;o<t.length;o++){var a=(g=t[o]).currentPoint,s=g.params,c=g.prePoint,u=void 0;switch(g.command){case"Q":u=Hn(c[0],c[1],s[1],s[2],s[3],s[4]);break;case"C":u=Fn(c[0],c[1],s[1],s[2],s[3],s[4],s[5],s[6]);break;case"A":var l=g.arcParams;u=_n(l.cx,l.cy,l.rx,l.ry,l.xRotation,l.startAngle,l.endAngle);break;default:n.push(a[0]),r.push(a[1])}u&&(g.box=u,n.push(u.x,u.x+u.width),r.push(u.y,u.y+u.height)),e&&("L"===g.command||"M"===g.command)&&g.prePoint&&g.nextPoint&&i.push(g)}n=n.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0})),r=r.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0}));var h=zt(n),d=zt(r),f=jt(n),p=jt(r);if(0===i.length)return{x:h,y:d,width:f-h,height:p-d};for(o=0;o<i.length;o++){var g;(a=(g=i[o]).currentPoint)[0]===h?h-=Ji(g,e).xExtra:a[0]===f&&(f+=Ji(g,e).xExtra),a[1]===d?d-=Ji(g,e).yExtra:a[1]===p&&(p+=Ji(g,e).yExtra)}return{x:h,y:d,width:f-h,height:p-d}}(a,0),c=s.x,u=s.y,l=s.width,h=s.height;return{absolutePath:e,hasArc:n,segments:a,polygons:i,polylines:o,totalLength:0,rect:{x:Number.isFinite(c)?c:0,y:Number.isFinite(u)?u:0,width:Number.isFinite(l)?l:0,height:Number.isFinite(h)?h:0}}},uo=Ir(co);function lo(t){return Bt(t)?uo(t):co(t)}function ho(t,e,n){var r=t.curve,i=e.curve;r&&0!==r.length||(r=Le(t.absolutePath,!1),t.curve=r),i&&0!==i.length||(i=Le(e.absolutePath,!1),e.curve=i);var o=[r,i];r.length!==i.length&&(o=Xe(r,i));var a,s,c=Ye(o[0])!==Ye(o[1])?(a=o[0],s=a.slice(1).map((function(t,e,n){return e?n[e-1].slice(-2).concat(t.slice(1)):a[0].slice(1).concat(t.slice(1))})).map((function(t){return t.map((function(e,n){return t[t.length-n-2*(1-n%2)]}))})).reverse(),[["M"].concat(s[0].slice(0,2))].concat(s.map((function(t){return["C"].concat(t.slice(2))})))):o[0].map((function(t){return Array.isArray(t)?[].concat(t):t}));return[c,qe(o[1],c),function(t){return t}]}function fo(t,e){var n;n=Bt(t)?t.split(" ").map((function(t){var e=u(t.split(","),2),n=e[0],r=e[1];return[Number(n),Number(r)]})):t;var r,i,o=[],a=0,s=Vn(n);n.forEach((function(t,e){n[e+1]&&((r=[0,0])[0]=a/s,i=In(t[0],t[1],n[e+1][0],n[e+1][1]),a+=i,r[1]=a/s,o.push(r))}));var c=Math.min.apply(Math,l([],u(n.map((function(t){return t[0]}))),!1)),h=Math.min.apply(Math,l([],u(n.map((function(t){return t[1]}))),!1));return e&&(e.parsedStyle.defX=c,e.parsedStyle.defY=h),{points:n,totalLength:s,segments:o}}function po(t,e){return[t.points,e.points,function(t){return t}]}var go=null;function mo(t){return function(e){var n=0;return t.map((function(t){return t===go?e[n++]:t}))}}function vo(t){return t}var yo={matrix:["NNNNNN",[go,go,0,0,go,go,0,0,0,0,1,0,go,go,0,1],vo],matrix3d:["NNNNNNNNNNNNNNNN",vo],rotate:["A"],rotatex:["A"],rotatey:["A"],rotatez:["A"],rotate3d:["NNNA"],perspective:["L"],scale:["Nn",mo([go,go,new Jr(1)]),vo],scalex:["N",mo([go,new Jr(1),new Jr(1)]),mo([go,new Jr(1)])],scaley:["N",mo([new Jr(1),go,new Jr(1)]),mo([new Jr(1),go])],scalez:["N",mo([new Jr(1),new Jr(1),go])],scale3d:["NNN",vo],skew:["Aa",null,vo],skewx:["A",null,mo([go,ri])],skewy:["A",null,mo([ri,go])],translate:["Tt",mo([go,go,ti]),vo],translatex:["T",mo([go,ti,ti]),mo([go,ti])],translatey:["T",mo([ti,go,ti]),mo([ti,go])],translatez:["L",mo([ti,ti,go])],translate3d:["TTL",vo]};function bo(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=yo[o];if(!a)return[];var s=e[2].split(","),c=a[0];if(c.length<s.length)return[];for(var u=[],l=0;l<c.length;l++){var h=s[l],d=c[l],f=void 0;if(void 0===(f=h?{A:function(t){return"0"===t.trim()?ri:ji(t)},N:qi,T:Ii,L:Ri}[d.toUpperCase()](h):{a:ri,n:u[0],t:ti}[d]))return[];u.push(f)}if(r.push({t:o,d:u}),n.lastIndex===t.length)return r}return[]}function xo(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=yo[o];if(!a)return[];var s=e[2].split(","),c=a[0];if(c.length<s.length)return[];for(var u=[],l=0;l<c.length;l++){var h=s[l],d=c[l],f=void 0;if(void 0===(f=h?{A:function(t){return"0"===t.trim()?ri:Li(t)},N:$i,T:Di,L:_i}[d.toUpperCase()](h):{a:ri,n:u[0],t:ti}[d]))return[];u.push(f)}if(r.push({t:o,d:u}),n.lastIndex===t.length)return r}return[]}function Eo(t){var e,n,r,i;switch(t.t){case"rotatex":return i=or(Bi(t.d[0])),[1,0,0,0,0,Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1];case"rotatey":return i=or(Bi(t.d[0])),[Math.cos(i),0,-Math.sin(i),0,0,1,0,0,Math.sin(i),0,Math.cos(i),0,0,0,0,1];case"rotate":case"rotatez":return i=or(Bi(t.d[0])),[Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1,0,0,0,0,1];case"rotate3d":e=t.d[0].value,n=t.d[1].value,r=t.d[2].value,i=or(Bi(t.d[3]));var o=e*e+n*n+r*r;if(0===o)e=1,n=0,r=0;else if(1!==o){var a=Math.sqrt(o);e/=a,n/=a,r/=a}var s=Math.sin(i/2),c=s*Math.cos(i/2),u=s*s;return[1-2*(n*n+r*r)*u,2*(e*n*u+r*c),2*(e*r*u-n*c),0,2*(e*n*u-r*c),1-2*(e*e+r*r)*u,2*(n*r*u+e*c),0,2*(e*r*u+n*c),2*(n*r*u-e*c),1-2*(e*e+n*n)*u,0,0,0,0,1];case"scale":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,1,0,0,0,0,1];case"scalex":return[t.d[0].value,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"scaley":return[1,0,0,0,0,t.d[0].value,0,0,0,0,1,0,0,0,0,1];case"scalez":return[1,0,0,0,0,1,0,0,0,0,t.d[0].value,0,0,0,0,1];case"scale3d":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,t.d[2].value,0,0,0,0,1];case"skew":var l=or(Bi(t.d[0])),h=or(Bi(t.d[1]));return[1,Math.tan(h),0,0,Math.tan(l),1,0,0,0,0,1,0,0,0,0,1];case"skewx":return i=or(Bi(t.d[0])),[1,0,0,0,Math.tan(i),1,0,0,0,0,1,0,0,0,0,1];case"skewy":return i=or(Bi(t.d[0])),[1,Math.tan(i),0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"translate":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Vi(t.d[0],0,null)||0,n=Vi(t.d[1],0,null)||0,0,1];case"translatex":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Vi(t.d[0],0,null)||0,0,0,1];case"translatey":return[1,0,0,0,0,1,0,0,0,0,1,0,0,n=Vi(t.d[0],0,null)||0,0,1];case"translatez":return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,r=Vi(t.d[0],0,null)||0,1];case"translate3d":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Vi(t.d[0],0,null)||0,n=Vi(t.d[1],0,null)||0,r=Vi(t.d[2],0,null)||0,1];case"perspective":var d=Vi(t.d[0],0,null)||0;return[1,0,0,0,0,1,0,0,0,0,1,d?-1/d:0,0,0,0,1];case"matrix":return[t.d[0].value,t.d[1].value,0,0,t.d[2].value,t.d[3].value,0,0,0,0,1,0,t.d[4].value,t.d[5].value,0,1];case"matrix3d":return t.d.map((function(t){return t.value}))}}function wo(t,e){return[t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12]*e[3],t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13]*e[3],t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14]*e[3],t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15]*e[3],t[0]*e[4]+t[4]*e[5]+t[8]*e[6]+t[12]*e[7],t[1]*e[4]+t[5]*e[5]+t[9]*e[6]+t[13]*e[7],t[2]*e[4]+t[6]*e[5]+t[10]*e[6]+t[14]*e[7],t[3]*e[4]+t[7]*e[5]+t[11]*e[6]+t[15]*e[7],t[0]*e[8]+t[4]*e[9]+t[8]*e[10]+t[12]*e[11],t[1]*e[8]+t[5]*e[9]+t[9]*e[10]+t[13]*e[11],t[2]*e[8]+t[6]*e[9]+t[10]*e[10]+t[14]*e[11],t[3]*e[8]+t[7]*e[9]+t[11]*e[10]+t[15]*e[11],t[0]*e[12]+t[4]*e[13]+t[8]*e[14]+t[12]*e[15],t[1]*e[12]+t[5]*e[13]+t[9]*e[14]+t[13]*e[15],t[2]*e[12]+t[6]*e[13]+t[10]*e[14]+t[14]*e[15],t[3]*e[12]+t[7]*e[13]+t[11]*e[14]+t[15]*e[15]]}function Mo(t){var e=[0,0,0],n=[1,1,1],r=[0,0,0],i=[0,0,0,1],o=[0,0,0,1];return function(t,e,n,r,i,o){if(!function(t,e){var n=e[15];if(0===n)return!1;for(var r=1/n,i=0;i<16;i++)t[i]=e[i]*r;return!0}(lr,t))return!1;if(w(hr,lr),hr[3]=0,hr[7]=0,hr[11]=0,hr[15]=1,Math.abs(T(hr))<1e-8)return!1;var a,s,c=lr[3],u=lr[7],l=lr[11],h=lr[12],d=lr[13],f=lr[14],p=lr[15];if(0!==c||0!==u||0!==l){if(dr[0]=c,dr[1]=u,dr[2]=l,dr[3]=p,!C(hr,hr))return!1;S(hr,hr),gt(i,dr,hr)}else i[0]=i[1]=i[2]=0,i[3]=1;if(e[0]=h,e[1]=d,e[2]=f,s=lr,(a=fr)[0][0]=s[0],a[0][1]=s[1],a[0][2]=s[2],a[1][0]=s[4],a[1][1]=s[5],a[1][2]=s[6],a[2][0]=s[8],a[2][1]=s[9],a[2][2]=s[10],n[0]=J(fr[0]),at(fr[0],fr[0]),r[0]=st(fr[0],fr[1]),gr(fr[1],fr[1],fr[0],1,-r[0]),n[1]=J(fr[1]),at(fr[1],fr[1]),r[0]/=n[1],r[1]=st(fr[0],fr[2]),gr(fr[2],fr[2],fr[0],1,-r[1]),r[2]=st(fr[1],fr[2]),gr(fr[2],fr[2],fr[1],1,-r[2]),n[2]=J(fr[2]),at(fr[2],fr[2]),r[1]/=n[2],r[2]/=n[2],ct(pr,fr[1],fr[2]),st(fr[0],pr)<0)for(var g=0;g<3;g++)n[g]*=-1,fr[g][0]*=-1,fr[g][1]*=-1,fr[g][2]*=-1;o[0]=.5*Math.sqrt(Math.max(1+fr[0][0]-fr[1][1]-fr[2][2],0)),o[1]=.5*Math.sqrt(Math.max(1-fr[0][0]+fr[1][1]-fr[2][2],0)),o[2]=.5*Math.sqrt(Math.max(1-fr[0][0]-fr[1][1]+fr[2][2],0)),o[3]=.5*Math.sqrt(Math.max(1+fr[0][0]+fr[1][1]+fr[2][2],0)),fr[2][1]>fr[1][2]&&(o[0]=-o[0]),fr[0][2]>fr[2][0]&&(o[1]=-o[1]),fr[1][0]>fr[0][1]&&(o[2]=-o[2])}(function(t){return 0===t.length?[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]:t.map(Eo).reduce(wo)}(t),e,n,r,i,o),[[e,n,r,o,i]]}var No=function(){function t(t,e){for(var n=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],r=0;r<4;r++)for(var i=0;i<4;i++)for(var o=0;o<4;o++)n[r][i]+=e[r][o]*t[o][i];return n}return function(e,n,r,i,o){for(var a=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],s=0;s<4;s++)a[s][3]=o[s];for(s=0;s<3;s++)for(var c=0;c<3;c++)a[3][s]+=e[c]*a[c][s];var u=i[0],l=i[1],h=i[2],d=i[3],f=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];f[0][0]=1-2*(l*l+h*h),f[0][1]=2*(u*l-h*d),f[0][2]=2*(u*h+l*d),f[1][0]=2*(u*l+h*d),f[1][1]=1-2*(u*u+h*h),f[1][2]=2*(l*h-u*d),f[2][0]=2*(u*h-l*d),f[2][1]=2*(l*h+u*d),f[2][2]=1-2*(u*u+l*l),a=t(a,f);var p=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(r[2]&&(p[2][1]=r[2],a=t(a,p)),r[1]&&(p[2][1]=0,p[2][0]=r[0],a=t(a,p)),r[0]&&(p[2][0]=0,p[1][0]=r[0],a=t(a,p)),s=0;s<3;s++)for(c=0;c<3;c++)a[s][c]*=n[s];return function(t){return 0==t[0][2]&&0==t[0][3]&&0==t[1][2]&&0==t[1][3]&&0==t[2][0]&&0==t[2][1]&&1==t[2][2]&&0==t[2][3]&&0==t[3][2]&&1==t[3][3]}(a)?[a[0][0],a[0][1],a[1][0],a[1][1],a[3][0],a[3][1]]:a[0].concat(a[1],a[2],a[3])}}();function So(t){return t.toFixed(6).replace(".000000","")}function Co(t,e){var n,r;return t.decompositionPair!==e&&(t.decompositionPair=e,n=Mo(t)),e.decompositionPair!==t&&(e.decompositionPair=t,r=Mo(e)),null===n[0]||null===r[0]?[[!1],[!0],function(n){return n?e[0].d:t[0].d}]:(n[0].push(0),r[0].push(1),[n,r,function(t){var e=function(t,e,n){var r=function(t,e){for(var n=0,r=0;r<t.length;r++)n+=t[r]*e[r];return n}(t,e);r=Vt(r,-1,1);var i=[];if(1===r)i=t;else for(var o=Math.acos(r),a=1*Math.sin(n*o)/Math.sqrt(1-r*r),s=0;s<4;s++)i.push(t[s]*(Math.cos(n*o)-r*a)+e[s]*a);return i}(n[0][3],r[0][3],t[5]);return No(t[0],t[1],t[2],e,t[4]).map(So).join(",")}])}function To(t){return t.replace(/[xy]/,"")}function Po(t){return t.replace(/(x|y|z|3d)?$/,"3d")}function ko(t,e,n){var r=!1;if(!t.length||!e.length){t.length||(r=!0,t=e,e=[]);for(var i=function(n){var r=t[n],i=r.t,o=r.d,a="scale"===i.substring(0,5)?1:0;e.push({t:i,d:o.map((function(t){return"number"==typeof t?fi(a):fi(a,t.unit)}))})},o=0;o<t.length;o++)i(o)}var a,s,c=[],u=[],l=[];if(t.length!==e.length)c=[(y=Co(t,e))[0]],u=[y[1]],l=[["matrix",[y[2]]]];else for(o=0;o<t.length;o++){var h=t[o].t,d=e[o].t,f=t[o].d,p=e[o].d,g=yo[h],m=yo[d],v=void 0;if(s=d,"perspective"===(a=h)&&"perspective"===s||!("matrix"!==a&&"matrix3d"!==a||"matrix"!==s&&"matrix3d"!==s)){var y=Co([t[o]],[e[o]]);c.push(y[0]),u.push(y[1]),l.push(["matrix",[y[2]]])}else{if(h===d)v=h;else if(g[2]&&m[2]&&To(h)===To(d))v=To(h),f=g[2](f),p=m[2](p);else{if(!g[1]||!m[1]||Po(h)!==Po(d)){c=[(y=Co(t,e))[0]],u=[y[1]],l=[["matrix",[y[2]]]];break}v=Po(h),f=g[1](f),p=m[1](p)}for(var b=[],x=[],E=[],w=0;w<f.length;w++){y=zi(f[w],p[w],n,!1,w);b[w]=y[0],x[w]=y[1],E.push(y[2])}c.push(b),u.push(x),l.push([v,E])}}if(r){var M=c;c=u,u=M}return[c,u,function(t){return t.map((function(t,e){var n=t.map((function(t,n){return l[e][1][n](t)})).join(",");return"matrix"===l[e][0]&&16===n.split(",").length&&(l[e][0]="matrix3d"),"matrix3d"===l[e][0]&&6===n.split(",").length&&(l[e][0]="matrix"),l[e][0]+"("+n+")"})).join(" ")}]}var Ao=Ir((function(t){if(Bt(t)){if("text-anchor"===t)return[fi(0,"px"),fi(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Ii(_o(e[0])),Ii(_o(e[1]))]}return[fi(t[0]||0,"px"),fi(t[1]||0,"px")]})),Oo=function(t){if(Bt(t)){if("text-anchor"===t)return[fi(0,"px"),fi(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Di(_o(e[0])),Di(_o(e[1]))]}return[fi(t[0]||0,"px"),fi(t[1]||0,"px")]};function _o(t){return"center"===t?"50%":"left"===t||"top"===t?"0":"right"===t||"bottom"===t?"100%":t}var Ro=[{n:"display",k:["none"]},{n:"opacity",int:!0,inh:!0,d:"1",syntax:gi.OPACITY_VALUE},{n:"fillOpacity",int:!0,inh:!0,d:"1",syntax:gi.OPACITY_VALUE},{n:"strokeOpacity",int:!0,inh:!0,d:"1",syntax:gi.OPACITY_VALUE},{n:"fill",int:!0,k:["none"],d:"none",syntax:gi.PAINT},{n:"fillRule",k:["nonzero","evenodd"],d:"nonzero"},{n:"stroke",int:!0,k:["none"],d:"none",syntax:gi.PAINT,l:!0},{n:"shadowType",k:["inner","outer","both"],d:"outer",l:!0},{n:"shadowColor",int:!0,syntax:gi.COLOR},{n:"shadowOffsetX",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"shadowOffsetY",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"shadowBlur",int:!0,l:!0,d:"0",syntax:gi.SHADOW_BLUR},{n:"lineWidth",int:!0,inh:!0,d:"1",l:!0,a:["strokeWidth"],syntax:gi.LENGTH_PERCENTAGE},{n:"increasedLineWidthForHitTesting",inh:!0,d:"0",l:!0,syntax:gi.LENGTH_PERCENTAGE},{n:"lineJoin",inh:!0,l:!0,a:["strokeLinejoin"],k:["miter","bevel","round"],d:"miter"},{n:"lineCap",inh:!0,l:!0,a:["strokeLinecap"],k:["butt","round","square"],d:"butt"},{n:"lineDash",int:!0,inh:!0,k:["none"],a:["strokeDasharray"],syntax:gi.LENGTH_PERCENTAGE_12},{n:"lineDashOffset",int:!0,inh:!0,d:"0",a:["strokeDashoffset"],syntax:gi.LENGTH_PERCENTAGE},{n:"offsetPath",syntax:gi.DEFINED_PATH},{n:"offsetDistance",int:!0,syntax:gi.OFFSET_DISTANCE},{n:"dx",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"dy",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"zIndex",ind:!0,int:!0,d:"0",k:["auto"],syntax:gi.Z_INDEX},{n:"visibility",k:["visible","hidden"],ind:!0,inh:!0,int:!0,d:"visible"},{n:"pointerEvents",inh:!0,k:["none","auto","stroke","fill","painted","visible","visiblestroke","visiblefill","visiblepainted","all"],d:"auto"},{n:"filter",ind:!0,l:!0,k:["none"],d:"none",syntax:gi.FILTER},{n:"clipPath",syntax:gi.DEFINED_PATH},{n:"textPath",syntax:gi.DEFINED_PATH},{n:"textPathSide",k:["left","right"],d:"left"},{n:"textPathStartOffset",l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"transform",p:100,int:!0,k:["none"],d:"none",syntax:gi.TRANSFORM},{n:"transformOrigin",p:100,d:function(t){return t===Yn.CIRCLE||t===Yn.ELLIPSE?"center":t===Yn.TEXT?"text-anchor":"left top"},l:!0,syntax:gi.TRANSFORM_ORIGIN},{n:"anchor",p:99,d:function(t){return t===Yn.CIRCLE||t===Yn.ELLIPSE?"0.5 0.5":"0 0"},l:!0,syntax:gi.LENGTH_PERCENTAGE_12},{n:"cx",int:!0,d:"0",syntax:gi.COORDINATE},{n:"cy",int:!0,d:"0",syntax:gi.COORDINATE},{n:"cz",int:!0,d:"0",syntax:gi.COORDINATE},{n:"r",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"rx",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"ry",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"x",int:!0,d:"0",syntax:gi.COORDINATE},{n:"y",int:!0,d:"0",syntax:gi.COORDINATE},{n:"z",int:!0,d:"0",syntax:gi.COORDINATE},{n:"width",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"height",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:gi.LENGTH_PERCENTAGE},{n:"radius",int:!0,l:!0,d:"0",syntax:gi.LENGTH_PERCENTAGE_14},{n:"x1",int:!0,l:!0,syntax:gi.COORDINATE},{n:"y1",int:!0,l:!0,syntax:gi.COORDINATE},{n:"z1",int:!0,l:!0,syntax:gi.COORDINATE},{n:"x2",int:!0,l:!0,syntax:gi.COORDINATE},{n:"y2",int:!0,l:!0,syntax:gi.COORDINATE},{n:"z2",int:!0,l:!0,syntax:gi.COORDINATE},{n:"path",int:!0,l:!0,d:"",a:["d"],syntax:gi.PATH,p:50},{n:"points",int:!0,l:!0,syntax:gi.LIST_OF_POINTS,p:50},{n:"text",l:!0,d:"",syntax:gi.TEXT,p:50},{n:"textTransform",l:!0,inh:!0,k:["capitalize","uppercase","lowercase","none"],d:"none",syntax:gi.TEXT_TRANSFORM,p:51},{n:"font",l:!0},{n:"fontSize",int:!0,inh:!0,d:"16px",l:!0,syntax:gi.LENGTH_PERCENTAGE},{n:"fontFamily",l:!0,inh:!0,d:"sans-serif"},{n:"fontStyle",l:!0,inh:!0,k:["normal","italic","oblique"],d:"normal"},{n:"fontWeight",l:!0,inh:!0,k:["normal","bold","bolder","lighter"],d:"normal"},{n:"fontVariant",l:!0,inh:!0,k:["normal","small-caps"],d:"normal"},{n:"lineHeight",l:!0,syntax:gi.LENGTH,int:!0,d:"0"},{n:"letterSpacing",l:!0,syntax:gi.LENGTH,int:!0,d:"0"},{n:"miterLimit",l:!0,syntax:gi.NUMBER,d:function(t){return t===Yn.PATH||t===Yn.POLYGON||t===Yn.POLYLINE?"4":"10"}},{n:"wordWrap",l:!0},{n:"wordWrapWidth",l:!0},{n:"maxLines",l:!0},{n:"textOverflow",l:!0,d:"clip"},{n:"leading",l:!0},{n:"textBaseline",l:!0,inh:!0,k:["top","hanging","middle","alphabetic","ideographic","bottom"],d:"alphabetic"},{n:"textAlign",l:!0,inh:!0,k:["start","center","middle","end","left","right"],d:"start"},{n:"markerStart",syntax:gi.MARKER},{n:"markerEnd",syntax:gi.MARKER},{n:"markerMid",syntax:gi.MARKER},{n:"markerStartOffset",syntax:gi.LENGTH,l:!0,int:!0,d:"0"},{n:"markerEndOffset",syntax:gi.LENGTH,l:!0,int:!0,d:"0"}],Do=Ro.filter((function(t){return!!t.l})).map((function(t){return t.n})),Io={},Lo=new WeakMap,jo=function(){function t(t){var e=this;this.runtime=t,Ro.forEach((function(t){e.registerMetadata(t)}))}return t.prototype.registerMetadata=function(t){l([t.n],u(t.a||[]),!1).forEach((function(e){Io[e]=t}))},t.prototype.unregisterMetadata=function(t){delete Io[t]},t.prototype.getPropertySyntax=function(t){return this.runtime.CSSPropertySyntaxFactory[t]},t.prototype.processProperties=function(t,e,n){var r=this;if(void 0===n&&(n={skipUpdateAttribute:!1,skipParse:!1,forceUpdateGeometry:!1,usedAttributes:[],memoize:!0}),!this.runtime.enableCSSParsing){Object.assign(t.attributes,e);var o=Object.keys(e),a=t.parsedStyle.clipPath,s=t.parsedStyle.offsetPath;t.parsedStyle=Object.assign(t.parsedStyle,e);var c=!!n.forceUpdateGeometry;if(!c)for(var u=0;u<Do.length;u++)if(Do[u]in e){c=!0;break}return e.fill&&(t.parsedStyle.fill=ki(e.fill)),e.stroke&&(t.parsedStyle.stroke=ki(e.stroke)),e.shadowColor&&(t.parsedStyle.shadowColor=ki(e.shadowColor)),e.filter&&(t.parsedStyle.filter=Ui(e.filter)),kt(e.radius)||(t.parsedStyle.radius=Fi(e.radius,4)),kt(e.lineDash)||(t.parsedStyle.lineDash=Fi(e.lineDash,2)),e.points&&(t.parsedStyle.points=fo(e.points,t)),""===e.path&&(t.parsedStyle.path=i({},mi)),e.path&&(t.parsedStyle.path=lo(e.path),t.parsedStyle.defX=t.parsedStyle.path.rect.x,t.parsedStyle.defY=t.parsedStyle.path.rect.y),e.textTransform&&this.runtime.CSSPropertySyntaxFactory["<text-transform>"].calculator(null,null,{value:e.textTransform},t,null),e.clipPath&&this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("clipPath",a,e.clipPath,t,this.runtime),e.offsetPath&&this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("offsetPath",s,e.offsetPath,t,this.runtime),e.anchor&&(t.parsedStyle.anchor=Fi(e.anchor,2)),e.transform&&(t.parsedStyle.transform=bo(e.transform)),e.transformOrigin&&(t.parsedStyle.transformOrigin=Ao(e.transformOrigin)),e.markerStart&&(t.parsedStyle.markerStart=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerStart,e.markerStart,null,null)),e.markerEnd&&(t.parsedStyle.markerEnd=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerEnd,e.markerEnd,null,null)),e.markerMid&&(t.parsedStyle.markerMid=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator("",e.markerMid,e.markerMid,null,null)),(t.nodeName!==Yn.CIRCLE&&t.nodeName!==Yn.ELLIPSE||kt(e.cx)&&kt(e.cy))&&(t.nodeName!==Yn.RECT&&t.nodeName!==Yn.IMAGE&&t.nodeName!==Yn.GROUP&&t.nodeName!==Yn.HTML&&t.nodeName!==Yn.TEXT&&t.nodeName!==Yn.MESH||kt(e.x)&&kt(e.y)&&kt(e.z))&&(t.nodeName!==Yn.LINE||kt(e.x1)&&kt(e.y1)&&kt(e.z1)&&kt(e.x2)&&kt(e.y2)&&kt(e.z2))||this.runtime.CSSPropertySyntaxFactory["<coordinate>"].postProcessor(t,o),kt(e.zIndex)||this.runtime.CSSPropertySyntaxFactory["<z-index>"].postProcessor(t,o),e.path&&this.runtime.CSSPropertySyntaxFactory["<path>"].postProcessor(t,o),e.points&&this.runtime.CSSPropertySyntaxFactory["<list-of-points>"].postProcessor(t,o),kt(e.offsetDistance)||this.runtime.CSSPropertySyntaxFactory["<offset-distance>"].postProcessor(t,o),e.transform&&this.runtime.CSSPropertySyntaxFactory["<transform>"].postProcessor(t,o),void(c&&this.updateGeometry(t))}var l=n.skipUpdateAttribute,h=n.skipParse,d=n.forceUpdateGeometry,f=n.usedAttributes,p=n.memoize,g=d,m=Object.keys(e);m.forEach((function(n){var r;l||(t.attributes[n]=e[n]),!g&&(null===(r=Io[n])||void 0===r?void 0:r.l)&&(g=!0)})),h||m.forEach((function(e){t.computedStyle[e]=r.parseProperty(e,t.attributes[e],t,p)})),(null==f?void 0:f.length)&&(m=Array.from(new Set(m.concat(f)))),m.forEach((function(e){e in t.computedStyle&&(t.parsedStyle[e]=r.computeProperty(e,t.computedStyle[e],t,p))})),g&&this.updateGeometry(t),m.forEach((function(e){e in t.parsedStyle&&r.postProcessProperty(e,t,m)})),this.runtime.enableCSSParsing&&t.children.length&&m.forEach((function(e){e in t.parsedStyle&&r.isPropertyInheritable(e)&&t.children.forEach((function(t){t.internalSetAttribute(e,null,{skipUpdateAttribute:!0,skipParse:!0})}))}))},t.prototype.parseProperty=function(t,e,n,r){var i=Io[t],o=e;if((""===e||kt(e))&&(e="unset"),"unset"===e||"initial"===e||"inherit"===e)o=ui(e);else if(i){var a=i.k,s=i.syntax,c=s&&this.getPropertySyntax(s);a&&a.indexOf(e)>-1?o=ui(e):c&&(!r&&c.parserUnmemoize?o=c.parserUnmemoize(e,n):c.parser&&(o=c.parser(e,n)))}return o},t.prototype.computeProperty=function(t,e,n,r){var i=Io[t],o="g-root"===n.id,a=e;if(i){var s=i.syntax,c=i.inh,u=i.d;if(e instanceof Hr){var l=e.value;if("unset"===l&&(l=c&&!o?"inherit":"initial"),"initial"===l)kt(u)||(e=this.parseProperty(t,Yr(u)?u(n.nodeName):u,n,r));else if("inherit"===l){var h=this.tryToResolveProperty(n,t,{inherited:!0});return kt(h)?void this.addUnresolveProperty(n,t):h}}var d=s&&this.getPropertySyntax(s);if(d&&d.calculator){var f=n.parsedStyle[t];a=d.calculator(t,f,e,n,this.runtime)}else a=e instanceof Hr?e.value:e}return a},t.prototype.postProcessProperty=function(t,e,n){var r=Io[t];if(r&&r.syntax){var i=r.syntax&&this.getPropertySyntax(r.syntax);i&&i.postProcessor&&i.postProcessor(e,n)}},t.prototype.addUnresolveProperty=function(t,e){var n=Lo.get(t);n||(Lo.set(t,[]),n=Lo.get(t)),-1===n.indexOf(e)&&n.push(e)},t.prototype.tryToResolveProperty=function(t,e,n){if(void 0===n&&(n={}),n.inherited&&t.parentElement&&function(t,e){var n=Lo.get(t);return!n||0===n.length||n.includes(e)}(t.parentElement,e)){var r=t.parentElement.parsedStyle[e];if("unset"===r||"initial"===r||"inherit"===r)return;return r}},t.prototype.recalc=function(t){var e=Lo.get(t);if(e&&e.length){var n={};e.forEach((function(e){n[e]=t.attributes[e]})),this.processProperties(t,n),Lo.delete(t)}},t.prototype.updateGeometry=function(t){var e=t.nodeName,n=this.runtime.geometryUpdaterFactory[e];if(n){var r=t.geometry;r.contentBounds||(r.contentBounds=new vr),r.renderBounds||(r.renderBounds=new vr);var i=t.parsedStyle,o=n.update(i,t),a=o.width,s=o.height,c=o.depth,u=void 0===c?0:c,l=o.offsetX,h=void 0===l?0:l,d=o.offsetY,f=void 0===d?0:d,p=o.offsetZ,g=void 0===p?0:p,m=[Math.abs(a)/2,Math.abs(s)/2,u/2],v=i,y=v.stroke,b=v.lineWidth,x=v.increasedLineWidthForHitTesting,E=v.shadowType,w=v.shadowColor,M=v.filter,N=void 0===M?[]:M,S=v.transformOrigin,C=i.anchor;e===Yn.TEXT?delete i.anchor:e===Yn.MESH&&(i.anchor[2]=.5);var T=[(1-2*(C&&C[0]||0))*a/2+h,(1-2*(C&&C[1]||0))*s/2+f,(1-2*(C&&C[2]||0))*m[2]+g];r.contentBounds.update(T,m);var P=e===Yn.POLYLINE||e===Yn.POLYGON||e===Yn.PATH?Math.SQRT2:.5;if(y&&!y.isNone){var k=((b||0)+(x||0))*P;m[0]+=k,m[1]+=k}if(r.renderBounds.update(T,m),w&&E&&"inner"!==E){var A=r.renderBounds,O=A.min,_=A.max,R=i,D=R.shadowBlur||0,I=R.shadowOffsetX||0,L=R.shadowOffsetY||0,j=O[0]-D+I,z=_[0]+D+I,B=O[1]-D+L,F=_[1]+D+L;O[0]=Math.min(O[0],j),_[0]=Math.max(_[0],z),O[1]=Math.min(O[1],B),_[1]=Math.max(_[1],F),r.renderBounds.setMinMax(O,_)}N.forEach((function(t){var e=t.name,n=t.params;if("blur"===e){var i=n[0].value;r.renderBounds.update(r.renderBounds.center,er(r.renderBounds.halfExtents,r.renderBounds.halfExtents,[i,i,0]))}else if("drop-shadow"===e){var o=n[0].value,a=n[1].value,s=n[2].value,c=r.renderBounds,u=c.min,l=c.max,h=u[0]-s+o,d=l[0]+s+o,f=u[1]-s+a,p=l[1]+s+a;u[0]=Math.min(u[0],h),l[0]=Math.max(l[0],d),u[1]=Math.min(u[1],f),l[1]=Math.max(l[1],p),r.renderBounds.setMinMax(u,l)}})),C=i.anchor;var G=a<0,V=s<0,W=(G?-1:1)*(S?Vi(S[0],0,t):0),U=(V?-1:1)*(S?Vi(S[1],1,t):0);W-=(G?-1:1)*(C&&C[0]||0)*r.contentBounds.halfExtents[0]*2,U-=(V?-1:1)*(C&&C[1]||0)*r.contentBounds.halfExtents[1]*2,t.setOrigin(W,U),this.runtime.sceneGraphService.dirtifyToRoot(t)}},t.prototype.updateSizeAttenuation=function(t,e){t.style.isSizeAttenuation?(t.style.rawLineWidth||(t.style.rawLineWidth=t.style.lineWidth),t.style.lineWidth=t.style.rawLineWidth/e,t.nodeName===Yn.CIRCLE&&(t.style.rawR||(t.style.rawR=t.style.r),t.style.r=t.style.rawR/e)):(t.style.rawLineWidth&&(t.style.lineWidth=t.style.rawLineWidth,delete t.style.rawLineWidth),t.nodeName===Yn.CIRCLE&&t.style.rawR&&(t.style.r=t.style.rawR,delete t.style.rawR))},t.prototype.isPropertyInheritable=function(t){var e=Io[t];return!!e&&e.inh},t}(),zo=function(){function t(){this.parser=ji,this.parserUnmemoize=Li,this.parserWithCSSDisabled=null,this.mixer=Yi}return t.prototype.calculator=function(t,e,n,r){return Bi(n)},t}(),Bo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r,i){return n instanceof Hr&&(n=null),i.sceneGraphService.updateDisplayObjectDependency(t,e,n,r),"clipPath"===t&&r.forEach((function(t){0===t.childNodes.length&&i.sceneGraphService.dirtifyToRoot(t)})),n},t}(),Fo=function(){function t(){this.parser=ki,this.parserWithCSSDisabled=ki,this.mixer=Ai}return t.prototype.calculator=function(t,e,n,r){return n instanceof Hr?"none"===n.value?li:hi:n},t}(),Go=function(){function t(){this.parser=Ui}return t.prototype.calculator=function(t,e,n){return n instanceof Hr?[]:n},t}();function Vo(t){var e=t.parsedStyle.fontSize;return kt(e)?null:e}var Wo=function(){function t(){this.parser=Ii,this.parserUnmemoize=Di,this.parserWithCSSDisabled=null,this.mixer=Yi}return t.prototype.calculator=function(t,e,n,r,i){var o;if(Wt(n))return n;if(!Jr.isRelativeUnit(n.unit))return n.value;var a=i.styleValueRegistry;if(n.unit===Tr.kPercentage)return 0;if(n.unit===Tr.kEms){if(r.parentNode){if(s=Vo(r.parentNode))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}if(n.unit===Tr.kRems){if(null===(o=null==r?void 0:r.ownerDocument)||void 0===o?void 0:o.documentElement){var s;if(s=Vo(r.ownerDocument.documentElement))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}},t}(),Uo=function(){function t(){this.mixer=Xi}return t.prototype.parser=function(t){var e=Gi(Wt(t)?[t]:t);return 1===e.length?[e[0],e[0]]:[e[0],e[1]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),Ho=function(){function t(){this.mixer=Xi}return t.prototype.parser=function(t){var e=Gi(Wt(t)?[t]:t);return 1===e.length?[e[0],e[0],e[0],e[0]]:2===e.length?[e[0],e[1],e[0],e[1]]:3===e.length?[e[0],e[1],e[2],e[1]]:[e[0],e[1],e[2],e[3]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),$o=x();function qo(t,e){var n=e.parsedStyle.defX||0,r=e.parsedStyle.defY||0;return e.resetLocalTransform(),e.setLocalPosition(n,r),t.forEach((function(t){var i=t.t,o=t.d;if("scale"===i){var a=(null==o?void 0:o.map((function(t){return t.value})))||[1,1];e.scaleLocal(a[0],a[1],1)}else if("scalex"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(a[0],1,1)}else if("scaley"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(1,a[0],1)}else if("scalez"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1];e.scaleLocal(1,1,a[0])}else if("scale3d"===i){a=(null==o?void 0:o.map((function(t){return t.value})))||[1,1,1];e.scaleLocal(a[0],a[1],a[2])}else if("translate"===i){var s=o||[ti,ti];e.translateLocal(s[0].value,s[1].value,0)}else if("translatex"===i){s=o||[ti];e.translateLocal(s[0].value,0,0)}else if("translatey"===i){s=o||[ti];e.translateLocal(0,s[0].value,0)}else if("translatez"===i){s=o||[ti];e.translateLocal(0,0,s[0].value)}else if("translate3d"===i){s=o||[ti,ti,ti];e.translateLocal(s[0].value,s[1].value,s[2].value)}else if("rotate"===i){var c=o||[ri];e.rotateLocal(0,0,Bi(c[0]))}else if("rotatex"===i){c=o||[ri];e.rotateLocal(Bi(c[0]),0,0)}else if("rotatey"===i){c=o||[ri];e.rotateLocal(0,Bi(c[0]),0)}else if("rotatez"===i){c=o||[ri];e.rotateLocal(0,0,Bi(c[0]))}else if("rotate3d"===i);else if("skew"===i){var h=(null==o?void 0:o.map((function(t){return t.value})))||[0,0];e.setLocalSkew(or(h[0]),or(h[1]))}else if("skewx"===i){h=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(or(h[0]),e.getLocalSkew()[1])}else if("skewy"===i){h=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(e.getLocalSkew()[0],or(h[0]))}else if("matrix"===i){var d=u(o.map((function(t){return t.value})),6),f=d[0],p=d[1],g=d[2],m=d[3],v=d[4],y=d[5];e.setLocalTransform(M($o,f,p,0,0,g,m,0,0,0,0,1,0,v+n,y+r,0,1))}else"matrix3d"===i&&(M.apply(X,l([$o],u(o.map((function(t){return t.value}))),!1)),$o[12]+=n,$o[13]+=r,e.setLocalTransform($o))})),e.getLocalTransform()}var Yo=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.postProcessor=function(t,e){var n,r,i;switch(t.nodeName){case Yn.CIRCLE:case Yn.ELLIPSE:var o=t.parsedStyle,a=o.cx,s=o.cy,c=o.cz;kt(a)||(n=a),kt(s)||(r=s),kt(c)||(i=c);break;case Yn.LINE:var l=t.parsedStyle,h=l.x1,d=l.x2,f=l.y1,p=l.y2;n=Math.min(h,d),r=Math.min(f,p),i=0;break;case Yn.RECT:case Yn.IMAGE:case Yn.GROUP:case Yn.HTML:case Yn.TEXT:case Yn.MESH:kt(t.parsedStyle.x)||(n=t.parsedStyle.x),kt(t.parsedStyle.y)||(r=t.parsedStyle.y),kt(t.parsedStyle.z)||(i=t.parsedStyle.z)}if(t.nodeName!==Yn.PATH&&t.nodeName!==Yn.POLYLINE&&t.nodeName!==Yn.POLYGON&&(t.parsedStyle.defX=n||0,t.parsedStyle.defY=r||0),(!kt(n)||!kt(r)||!kt(i))&&-1===e.indexOf("transform")){var g=t.parsedStyle.transform;if(g&&g.length)qo(g,t);else{var m=u(t.getLocalPosition(),3),v=m[0],y=m[1],b=m[2];t.setLocalPosition(kt(n)?v:n,kt(r)?y:r,kt(i)?b:i)}}},e}(Wo),Ko=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){n instanceof Hr&&(n=null);var i=null==n?void 0:n.cloneNode(!0);return i&&(i.style.isMarker=!0),i},t}(),Xo=function(){function t(){this.mixer=Yi,this.parser=qi,this.parserUnmemoize=$i,this.parserWithCSSDisabled=null}return t.prototype.calculator=function(t,e,n){return n.value},t}(),Zo=function(){function t(){this.parser=qi,this.parserUnmemoize=$i,this.parserWithCSSDisabled=null,this.mixer=Ki(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t.prototype.postProcessor=function(t){var e=t.parsedStyle,n=e.offsetPath,r=e.offsetDistance;if(n){var i=n.nodeName;if(i===Yn.LINE||i===Yn.PATH||i===Yn.POLYLINE){var o=n.getPoint(r);o&&(t.parsedStyle.defX=o.x,t.parsedStyle.defY=o.y,t.setLocalPosition(o.x,o.y))}}},t}(),Qo=function(){function t(){this.parser=qi,this.parserUnmemoize=$i,this.parserWithCSSDisabled=null,this.mixer=Ki(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t}(),Jo=function(){function t(){this.parser=lo,this.parserWithCSSDisabled=lo,this.mixer=ho}return t.prototype.calculator=function(t,e,n){return n instanceof Hr&&"unset"===n.value?{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Nr(0,0,0,0)}:n},t.prototype.postProcessor=function(t,e){if(t.parsedStyle.defX=t.parsedStyle.path.rect.x,t.parsedStyle.defY=t.parsedStyle.path.rect.y,t.nodeName===Yn.PATH&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=void 0===r?0:r,o=n.defY,a=void 0===o?0:o;t.setLocalPosition(i,a)}},t}(),ta=function(){function t(){this.parser=fo,this.mixer=po}return t.prototype.postProcessor=function(t,e){if((t.nodeName===Yn.POLYGON||t.nodeName===Yn.POLYLINE)&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=n.defY;t.setLocalPosition(r,i)}},t}(),ea=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.mixer=Ki(0,1/0),e}return r(e,t),e}(Wo),na=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){return n instanceof Hr?"unset"===n.value?"":n.value:"".concat(n)},t.prototype.postProcessor=function(t){t.nodeValue="".concat(t.parsedStyle.text)||""},t}(),ra=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){var i=r.getAttribute("text");if(i){var o=i;"capitalize"===n.value?o=i.charAt(0).toUpperCase()+i.slice(1):"lowercase"===n.value?o=i.toLowerCase():"uppercase"===n.value&&(o=i.toUpperCase()),r.parsedStyle.text=o}return n.value},t}(),ia={},oa=0;var aa="undefined"!=typeof window&&void 0!==window.document;function sa(t){return!!t.getAttribute}function ca(t,e){var n=Number(t.parsedStyle.zIndex),r=Number(e.parsedStyle.zIndex);if(n===r){var i=t.parentNode;if(i){var o=i.childNodes||[];return o.indexOf(t)-o.indexOf(e)}}return n-r}function ua(t){var e,n=t;do{if(null===(e=n.parsedStyle)||void 0===e?void 0:e.clipPath)return n;n=n.parentElement}while(null!==n);return null}function la(t,e){if(aa)return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}var ha={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},da="object"==typeof performance&&performance.now?performance:Date;function fa(t,e,n){var r=!1,i=!1,o=!!e&&!e.isNone,a=!!n&&!n.isNone;return"visiblepainted"===t||"painted"===t||"auto"===t?(r=o,i=a):"visiblefill"===t||"fill"===t?r=!0:"visiblestroke"===t||"stroke"===t?i=!0:"visible"!==t&&"all"!==t||(r=!0,i=!0),[r,i]}var pa=1,ga="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},ma=Date.now(),va={},ya=Date.now(),ba=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=Date.now(),n=e-ya,r=n>16?0:16-n,i=pa++;return va[i]=t,Object.keys(va).length>1||setTimeout((function(){ya=e;var t=va;va={},Object.keys(t).forEach((function(e){return t[e](ga.performance&&"function"==typeof ga.performance.now?ga.performance.now():Date.now()-ma)}))}),r),i},xa=function(t){delete va[t]},Ea=function(t){return"string"!=typeof t?ba:""===t?ga.requestAnimationFrame:ga[t+"RequestAnimationFrame"]},wa=function(t,e){for(var n=0;void 0!==t[n];){if(e(t[n]))return t[n];n+=1}}(["","webkit","moz","ms","o"],(function(t){return!!Ea(t)})),Ma=Ea(wa),Na=function(t){return"string"!=typeof t?xa:""===t?ga.cancelAnimationFrame:ga[t+"CancelAnimationFrame"]||ga[t+"CancelRequestAnimationFrame"]}(wa);ga.requestAnimationFrame=Ma,ga.cancelAnimationFrame=Na;var Sa=function(){function t(){this.callbacks=[]}return t.prototype.getCallbacksNum=function(){return this.callbacks.length},t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Promise.all(this.callbacks.map((function(e){return e.apply(void 0,l([],u(t),!1))})))},t}(),Ca=function(){function t(){this.callbacks=[]}return t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a(this,void 0,void 0,(function(){var e,n,r;return s(this,(function(i){switch(i.label){case 0:return this.callbacks.length?[4,(r=this.callbacks)[0].apply(r,l([],u(t),!1))]:[3,6];case 1:e=i.sent(),n=0,i.label=2;case 2:return n<this.callbacks.length-1?[4,(0,this.callbacks[n])(e)]:[3,5];case 3:e=i.sent(),i.label=4;case 4:return n++,[3,2];case 5:return[2,e];case 6:return[2,null]}}))}))},t}(),Ta=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){var t=arguments;this.callbacks.forEach((function(e){e.apply(void 0,t)}))},t}(),Pa=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){if(this.callbacks.length){for(var t=arguments,e=this.callbacks[0].apply(void 0,t),n=0;n<this.callbacks.length-1;n++){e=(0,this.callbacks[n])(e)}return e}return null},t}(),ka=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Aa=/([\"\'])[^\'\"]+\1/;var Oa=function(){function t(){this.parser=bo,this.parserUnmemoize=xo,this.parserWithCSSDisabled=xo,this.mixer=ko}return t.prototype.calculator=function(t,e,n,r){return n instanceof Hr?[]:n},t.prototype.postProcessor=function(t){qo(t.parsedStyle.transform,t)},t}(),_a=function(){this.parser=Ao,this.parserUnmemoize=Oo},Ra=function(){function t(){this.parser=qi,this.parserUnmemoize=$i}return t.prototype.calculator=function(t,e,n,r){return n.value},t.prototype.postProcessor=function(t){if(t.parentNode){var e=t.parentNode,n=e.renderable,r=e.sortable;n&&(n.dirty=!0),r&&(r.dirty=!0,r.dirtyReason=ni.Z_INDEX_CHANGED)}},t}(),Da=function(){function t(){}return t.prototype.update=function(t,e){var n=t.r;return{width:2*n,height:2*n}},t}(),Ia=function(){function t(){}return t.prototype.update=function(t,e){return{width:2*t.rx,height:2*t.ry}},t}(),La=function(){function t(){}return t.prototype.update=function(t){var e=t.x1,n=t.y1,r=t.x2,i=t.y2,o=Math.min(e,r),a=Math.max(e,r),s=Math.min(n,i);return{width:a-o,height:Math.max(n,i)-s}},t}(),ja=function(){function t(){}return t.prototype.update=function(t){var e=t.path.rect;return{width:e.width,height:e.height}},t}(),za=function(){function t(){}return t.prototype.update=function(t){if(t.points&&_t(t.points.points)){var e=t.points.points,n=Math.min.apply(Math,l([],u(e.map((function(t){return t[0]}))),!1)),r=Math.max.apply(Math,l([],u(e.map((function(t){return t[0]}))),!1)),i=Math.min.apply(Math,l([],u(e.map((function(t){return t[1]}))),!1)),o=Math.max.apply(Math,l([],u(e.map((function(t){return t[1]}))),!1));return{width:r-n,height:o-i}}return{width:0,height:0}},t}(),Ba=function(){function t(){}return t.prototype.update=function(t,e){var n=t.img,r=t.width,i=void 0===r?0:r,o=t.height,a=i,s=void 0===o?0:o;return n&&!Bt(n)&&(a||(a=n.width,t.width=a),s||(s=n.height,t.height=s)),{width:a,height:s}},t}(),Fa=function(){function t(t){this.globalRuntime=t}return t.prototype.isReadyToMeasure=function(t,e){var n=t.text,r=t.textAlign,i=t.textBaseline,o=t.fontSize,a=t.fontStyle,s=t.fontWeight,c=t.fontVariant,u=t.lineWidth;return n&&o&&a&&s&&c&&r&&i&&!kt(u)},t.prototype.update=function(t,e){var n,r,i=t.text,o=t.textAlign,a=t.lineWidth,s=t.textBaseline,c=t.dx,u=t.dy;if(!this.isReadyToMeasure(t,e))return t.metrics={font:"",width:0,height:0,lines:[],lineWidths:[],lineHeight:0,maxLineWidth:0,fontProperties:{ascent:0,descent:0,fontSize:0},lineMetrics:[]},{width:0,height:0,x:0,y:0,offsetX:0,offsetY:0};var l=((null===(r=null===(n=null==e?void 0:e.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===r?void 0:r.getConfig())||{}).offscreenCanvas,h=this.globalRuntime.textService.measureText(i,t,l);t.metrics=h;var d=h.width,f=h.height,p=h.lineHeight,g=h.fontProperties,m=[d/2,f/2,0],v=[0,1],y=0;"center"===o||"middle"===o?(y=a/2,v=[.5,1]):"right"!==o&&"end"!==o||(y=a,v=[1,1]);var b=0;return"middle"===s?b=m[1]:"top"===s||"hanging"===s?b=2*m[1]:"alphabetic"===s?b=this.globalRuntime.enableCSSParsing?p-g.ascent:0:"bottom"!==s&&"ideographic"!==s||(b=0),c&&(y+=c),u&&(b+=u),t.anchor=[v[0],v[1],0],{width:2*m[0],height:2*m[1],offsetX:y,offsetY:b}},t}();var Ga,Va=function(){function t(e){this.eventPhase=t.prototype.NONE,this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.defaultPrevented=!1,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Mr,this.page=new Mr,this.canvas=new Mr,this.viewport=new Mr,this.composed=!1,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this.type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerX",{get:function(){return this.layer.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerY",{get:function(){return this.layer.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageX",{get:function(){return this.page.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageY",{get:function(){return this.page.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasX",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasY",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportX",{get:function(){return this.viewport.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportY",{get:function(){return this.viewport.y},enumerable:!1,configurable:!0}),t.prototype.composedPath=function(){return!this.manager||this.path&&this.path[0]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path},Object.defineProperty(t.prototype,"propagationPath",{get:function(){return this.composedPath()},enumerable:!1,configurable:!0}),t.prototype.preventDefault=function(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0},t.prototype.stopImmediatePropagation=function(){this.propagationImmediatelyStopped=!0},t.prototype.stopPropagation=function(){this.propagationStopped=!0},t.prototype.initEvent=function(){},t.prototype.initUIEvent=function(){},t.prototype.clone=function(){throw new Error(Sr)},t}(),Wa=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.client=new Mr,e.movement=new Mr,e.offset=new Mr,e.global=new Mr,e.screen=new Mr,e}return r(e,t),Object.defineProperty(e.prototype,"clientX",{get:function(){return this.client.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clientY",{get:function(){return this.client.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementX",{get:function(){return this.movement.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementY",{get:function(){return this.movement.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetX",{get:function(){return this.offset.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetY",{get:function(){return this.offset.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalX",{get:function(){return this.global.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalY",{get:function(){return this.global.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenX",{get:function(){return this.screen.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenY",{get:function(){return this.screen.y},enumerable:!1,configurable:!0}),e.prototype.getModifierState=function(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)},e.prototype.initMouseEvent=function(){throw new Error(Sr)},e}(Va),Ua=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.width=0,e.height=0,e.isPrimary=!1,e}return r(e,t),e.prototype.getCoalescedEvents=function(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]},e.prototype.getPredictedEvents=function(){throw new Error("getPredictedEvents is not supported!")},e.prototype.clone=function(){return this.manager.clonePointerEvent(this)},e}(Wa),Ha=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.clone=function(){return this.manager.cloneWheelEvent(this)},e}(Wa),$a=function(t){function e(e,n){var r=t.call(this,null)||this;return r.type=e,r.detail=n,Object.assign(r,n),r}return r(e,t),e}(Va),qa=function(){function t(){this.emitter=new m}return t.prototype.on=function(t,e,n){return this.addEventListener(t,e,n),this},t.prototype.addEventListener=function(t,e,n){var r=Xt(n)&&n||Rt(n)&&n.capture,i=Rt(n)&&n.once,o=Yr(e)?void 0:e,a=!1,s="";if(t.indexOf(":")>-1){var c=u(t.split(":"),2),h=c[0];t=c[1],s=h,a=!0}if(t=r?"".concat(t,"capture"):t,e=Yr(e)?e:e.handleEvent,a){var d=e;e=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];(null===(t=e[0].target)||void 0===t?void 0:t.name)===s&&d.apply(void 0,l([],u(e),!1))}}return i?this.emitter.once(t,e,o):this.emitter.on(t,e,o),this},t.prototype.off=function(t,e,n){return t?this.removeEventListener(t,e,n):this.removeAllEventListeners(),this},t.prototype.removeAllEventListeners=function(){this.emitter.removeAllListeners()},t.prototype.removeEventListener=function(t,e,n){var r=Xt(n)&&n||Rt(n)&&n.capture,i=Yr(e)?void 0:e;return t=r?"".concat(t,"capture"):t,e=Yr(e)?e:null==e?void 0:e.handleEvent,this.emitter.off(t,e,i),this},t.prototype.emit=function(t,e){this.dispatchEvent(new $a(t,e))},t.prototype.dispatchEvent=function(t,e){var n,r,i;if(void 0===e&&(e=!1),!t.type)throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");if(i=this.document?this:this.defaultView?this.defaultView:null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView){if(t.manager=i.getEventService()||null,!t.manager)return!1;t.defaultPrevented=!1,t.path=[],e||(t.target=this),null===(r=t.manager)||void 0===r||r.dispatchEvent(t,t.type,e)}return!t.defaultPrevented},t}(),Ya=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.shadow=!1,e.ownerDocument=null,e.isConnected=!1,e.baseURI="",e.childNodes=[],e.nodeType=0,e.nodeName="",e.nodeValue=null,e.parentNode=null,e}return r(e,t),e.isNode=function(t){return!!t.childNodes},Object.defineProperty(e.prototype,"textContent",{get:function(){var t,e,n="";this.nodeName===Yn.TEXT&&(n+=this.style.text);try{for(var r=c(this.childNodes),i=r.next();!i.done;i=r.next()){var o=i.value;o.nodeName===Yn.TEXT?n+=o.nodeValue:n+=o.textContent}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return n},set:function(t){var e=this;this.childNodes.slice().forEach((function(t){e.removeChild(t)})),this.nodeName===Yn.TEXT&&(this.style.text="".concat(t))},enumerable:!1,configurable:!0}),e.prototype.getRootNode=function(t){return void 0===t&&(t={}),this.parentNode?this.parentNode.getRootNode(t):t.composed&&this.host?this.host.getRootNode(t):this},e.prototype.hasChildNodes=function(){return this.childNodes.length>0},e.prototype.isDefaultNamespace=function(t){throw new Error(Sr)},e.prototype.lookupNamespaceURI=function(t){throw new Error(Sr)},e.prototype.lookupPrefix=function(t){throw new Error(Sr)},e.prototype.normalize=function(){throw new Error(Sr)},e.prototype.isEqualNode=function(t){return this===t},e.prototype.isSameNode=function(t){return this.isEqualNode(t)},Object.defineProperty(e.prototype,"parent",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstChild",{get:function(){return this.childNodes.length>0?this.childNodes[0]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null},enumerable:!1,configurable:!0}),e.prototype.compareDocumentPosition=function(t){var n;if(t===this)return 0;for(var r=t,i=this,o=[r],a=[i];null!==(n=r.parentNode)&&void 0!==n?n:i.parentNode;)r=r.parentNode?(o.push(r.parentNode),r.parentNode):r,i=i.parentNode?(a.push(i.parentNode),i.parentNode):i;if(r!==i)return e.DOCUMENT_POSITION_DISCONNECTED|e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|e.DOCUMENT_POSITION_PRECEDING;var s=o.length>a.length?o:a,c=s===o?a:o;if(s[s.length-c.length]===c[0])return s===o?e.DOCUMENT_POSITION_CONTAINED_BY|e.DOCUMENT_POSITION_FOLLOWING:e.DOCUMENT_POSITION_CONTAINS|e.DOCUMENT_POSITION_PRECEDING;for(var u=s.length-c.length,l=c.length-1;l>=0;l--){var h=c[l],d=s[u+l];if(d!==h){var f=h.parentNode.childNodes;return f.indexOf(h)<f.indexOf(d)?c===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING:s===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING}}return e.DOCUMENT_POSITION_FOLLOWING},e.prototype.contain=function(t){return this.contains(t)},e.prototype.contains=function(t){for(var e=t;e&&this!==e;)e=e.parentNode;return!!e},e.prototype.getAncestor=function(t){for(var e=this;t>0&&e;)e=e.parentNode,t--;return e},e.prototype.forEach=function(t,e){void 0===e&&(e=!1),t(this)||(e?this.childNodes.slice():this.childNodes).forEach((function(e){e.forEach(t)}))},e.DOCUMENT_POSITION_DISCONNECTED=1,e.DOCUMENT_POSITION_PRECEDING=2,e.DOCUMENT_POSITION_FOLLOWING=4,e.DOCUMENT_POSITION_CONTAINS=8,e.DOCUMENT_POSITION_CONTAINED_BY=16,e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,e}(qa),Ka=function(){function t(t,e){var n=this;this.globalRuntime=t,this.context=e,this.emitter=new m,this.nativeHTMLMap=new WeakMap,this.cursor="default",this.mappingTable={},this.mappingState={trackingData:{}},this.eventPool=new Map,this.tmpMatrix=x(),this.tmpVec3=Z(),this.onPointerDown=function(t){var e=n.createPointerEvent(t);if(n.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)n.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){var r=2===e.button;n.dispatchEvent(e,r?"rightdown":"mousedown")}n.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),n.freeEvent(e)},this.onPointerUp=function(t){var e,r=da.now(),i=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);if(n.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)n.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){var o=2===i.button;n.dispatchEvent(i,o?"rightup":"mouseup")}var a=n.trackingData(t.pointerId),s=n.findMountedTarget(a.pressTargetsByButton[t.button]),c=s;if(s&&!i.composedPath().includes(s)){for(var u=s;u&&!i.composedPath().includes(u);){if(i.currentTarget=u,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)n.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){o=2===i.button;n.notifyTarget(i,o?"rightupoutside":"mouseupoutside")}Ya.isNode(u)&&(u=u.parentNode)}delete a.pressTargetsByButton[t.button],c=u}if(c){var l=n.clonePointerEvent(i,"click");l.target=c,l.path=[],a.clicksByButton[t.button]||(a.clicksByButton[t.button]={clickCount:0,target:l.target,timeStamp:r});var h=a.clicksByButton[t.button];h.target===l.target&&r-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=l.target,h.timeStamp=r,l.detail=h.clickCount,(null===(e=i.detail)||void 0===e?void 0:e.preventClick)||(n.context.config.useNativeClickEvent||"mouse"!==l.pointerType&&"touch"!==l.pointerType||n.dispatchEvent(l,"click"),n.dispatchEvent(l,"pointertap")),n.freeEvent(l)}n.freeEvent(i)},this.onPointerMove=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0),r="mouse"===e.pointerType||"pen"===e.pointerType,i=n.trackingData(t.pointerId),o=n.findMountedTarget(i.overTargets);if(i.overTargets&&o!==e.target){var a="mousemove"===t.type?"mouseout":"pointerout",s=n.createPointerEvent(t,a,o||void 0);if(n.dispatchEvent(s,"pointerout"),r&&n.dispatchEvent(s,"mouseout"),!e.composedPath().includes(o)){var c=n.createPointerEvent(t,"pointerleave",o||void 0);for(c.eventPhase=c.AT_TARGET;c.target&&!e.composedPath().includes(c.target);)c.currentTarget=c.target,n.notifyTarget(c),r&&n.notifyTarget(c,"mouseleave"),Ya.isNode(c.target)&&(c.target=c.target.parentNode);n.freeEvent(c)}n.freeEvent(s)}if(o!==e.target){var u="mousemove"===t.type?"mouseover":"pointerover",l=n.clonePointerEvent(e,u);n.dispatchEvent(l,"pointerover"),r&&n.dispatchEvent(l,"mouseover");for(var h=o&&Ya.isNode(o)&&o.parentNode;h&&h!==(Ya.isNode(n.rootTarget)&&n.rootTarget.parentNode)&&h!==e.target;)h=h.parentNode;if(!h||h===(Ya.isNode(n.rootTarget)&&n.rootTarget.parentNode)){var d=n.clonePointerEvent(e,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==o&&d.target!==(Ya.isNode(n.rootTarget)&&n.rootTarget.parentNode);)d.currentTarget=d.target,n.notifyTarget(d),r&&n.notifyTarget(d,"mouseenter"),Ya.isNode(d.target)&&(d.target=d.target.parentNode);n.freeEvent(d)}n.freeEvent(l)}n.dispatchEvent(e,"pointermove"),"touch"===e.pointerType&&n.dispatchEvent(e,"touchmove"),r&&(n.dispatchEvent(e,"mousemove"),n.cursor=n.getCursor(e.target)),i.overTargets=e.composedPath(),n.freeEvent(e)},this.onPointerOut=function(t){var e=n.trackingData(t.pointerId);if(e.overTargets){var r="mouse"===t.pointerType||"pen"===t.pointerType,i=n.findMountedTarget(e.overTargets),o=n.createPointerEvent(t,"pointerout",i||void 0);n.dispatchEvent(o),r&&n.dispatchEvent(o,"mouseout");var a=n.createPointerEvent(t,"pointerleave",i||void 0);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==(Ya.isNode(n.rootTarget)&&n.rootTarget.parentNode);)a.currentTarget=a.target,n.notifyTarget(a),r&&n.notifyTarget(a,"mouseleave"),Ya.isNode(a.target)&&(a.target=a.target.parentNode);e.overTargets=null,n.freeEvent(o),n.freeEvent(a)}n.cursor=null},this.onPointerOver=function(t){var e=n.trackingData(t.pointerId),r=n.createPointerEvent(t),i="mouse"===r.pointerType||"pen"===r.pointerType;n.dispatchEvent(r,"pointerover"),i&&n.dispatchEvent(r,"mouseover"),"mouse"===r.pointerType&&(n.cursor=n.getCursor(r.target));var o=n.clonePointerEvent(r,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==(Ya.isNode(n.rootTarget)&&n.rootTarget.parentNode);)o.currentTarget=o.target,n.notifyTarget(o),i&&n.notifyTarget(o,"mouseenter"),Ya.isNode(o.target)&&(o.target=o.target.parentNode);e.overTargets=r.composedPath(),n.freeEvent(r),n.freeEvent(o)},this.onPointerUpOutside=function(t){var e=n.trackingData(t.pointerId),r=n.findMountedTarget(e.pressTargetsByButton[t.button]),i=n.createPointerEvent(t);if(r){for(var o=r;o;)i.currentTarget=o,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType||"mouse"!==i.pointerType&&"pen"!==i.pointerType||n.notifyTarget(i,2===i.button?"rightupoutside":"mouseupoutside"),Ya.isNode(o)&&(o=o.parentNode);delete e.pressTargetsByButton[t.button]}n.freeEvent(i)},this.onWheel=function(t){var e=n.createWheelEvent(t);n.dispatchEvent(e),n.freeEvent(e)},this.onClick=function(t){if(n.context.config.useNativeClickEvent){var e=n.createPointerEvent(t);n.dispatchEvent(e),n.freeEvent(e)}},this.onPointerCancel=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);n.dispatchEvent(e),n.freeEvent(e)}}return t.prototype.init=function(){this.rootTarget=this.context.renderingContext.root.parentNode,this.addEventMapping("pointerdown",this.onPointerDown),this.addEventMapping("pointerup",this.onPointerUp),this.addEventMapping("pointermove",this.onPointerMove),this.addEventMapping("pointerout",this.onPointerOut),this.addEventMapping("pointerleave",this.onPointerOut),this.addEventMapping("pointercancel",this.onPointerCancel),this.addEventMapping("pointerover",this.onPointerOver),this.addEventMapping("pointerupoutside",this.onPointerUpOutside),this.addEventMapping("wheel",this.onWheel),this.addEventMapping("click",this.onClick)},t.prototype.destroy=function(){this.emitter.removeAllListeners(),this.mappingTable={},this.mappingState={},this.eventPool.clear()},t.prototype.client2Viewport=function(t){var e=this.context.contextService.getBoundingClientRect();return new Mr(t.x-((null==e?void 0:e.left)||0),t.y-((null==e?void 0:e.top)||0))},t.prototype.viewport2Client=function(t){var e=this.context.contextService.getBoundingClientRect();return new Mr(t.x+((null==e?void 0:e.left)||0),t.y+((null==e?void 0:e.top)||0))},t.prototype.viewport2Canvas=function(t){var e=t.x,n=t.y,r=this.rootTarget.defaultView.getCamera(),i=this.context.config,o=i.width,a=i.height,s=r.getPerspectiveInverse(),c=r.getWorldTransform(),u=P(this.tmpMatrix,c,s),l=nt(this.tmpVec3,e/o*2-1,2*(1-n/a)-1,0);return lt(l,l,u),new Mr(l[0],l[1])},t.prototype.canvas2Viewport=function(t){var e=this.rootTarget.defaultView.getCamera(),n=e.getPerspective(),r=e.getViewTransform(),i=P(this.tmpMatrix,n,r),o=nt(this.tmpVec3,t.x,t.y,0);lt(this.tmpVec3,this.tmpVec3,i);var a=this.context.config,s=a.width,c=a.height;return new Mr((o[0]+1)/2*s,(1-(o[1]+1)/2)*c)},t.prototype.setPickHandler=function(t){this.pickHandler=t},t.prototype.addEventMapping=function(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((function(t,e){return t.priority-e.priority}))},t.prototype.mapEvent=function(t){if(this.rootTarget){var e=this.mappingTable[t.type];if(e)for(var n=0,r=e.length;n<r;n++)e[n].fn(t);else console.warn("[EventService]: Event mapping not defined for ".concat(t.type))}},t.prototype.dispatchEvent=function(t,e,n){if(n){t.eventPhase=t.AT_TARGET;var r=this.rootTarget.defaultView||null;t.currentTarget=r,this.notifyListeners(t,e)}else t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e);this.emitter.emit(e||t.type,t)},t.prototype.propagate=function(t,e){if(t.target){var n=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(var r=n.length-1;r>=1;r--)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){var i=n.indexOf(t.currentTarget);t.eventPhase=t.BUBBLING_PHASE;for(r=i+1;r<n.length;r++)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}},t.prototype.propagationPath=function(t){var e=[t],n=this.rootTarget.defaultView||null;if(n&&n===t)return e.unshift(n.document),e;for(var r=0;r<2048&&t!==this.rootTarget;r++)Ya.isNode(t)&&t.parentNode&&(e.push(t.parentNode),t=t.parentNode);return n&&e.push(n),e},t.prototype.hitTest=function(t){var e=t.viewportX,n=t.viewportY,r=this.context.config,i=r.width,o=r.height,a=r.disableHitTesting;return e<0||n<0||e>i||n>o?null:!a&&this.pickHandler(t)||this.rootTarget||null},t.prototype.isNativeEventFromCanvas=function(t,e){var n=null==e?void 0:e.target;if((null==n?void 0:n.shadowRoot)&&(n=e.composedPath()[0]),n){if(n===t)return!0;if(t&&t.contains)return t.contains(n)}return!!(null==e?void 0:e.composedPath)&&e.composedPath().indexOf(t)>-1},t.prototype.getExistedHTML=function(t){var e,n;if(t.nativeEvent.composedPath)try{for(var r=c(t.nativeEvent.composedPath()),i=r.next();!i.done;i=r.next()){var o=i.value,a=this.nativeHTMLMap.get(o);if(a)return a}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return null},t.prototype.pickTarget=function(t){return this.hitTest({clientX:t.clientX,clientY:t.clientY,viewportX:t.viewportX,viewportY:t.viewportY,x:t.canvasX,y:t.canvasY})},t.prototype.createPointerEvent=function(t,e,n,r){var i=this.allocateEvent(Ua);this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.nativeEvent=t.nativeEvent,i.originalEvent=t;var o=this.getExistedHTML(i),a=this.context.contextService.getDomElement();return i.target=null!=n?n:o||this.isNativeEventFromCanvas(a,i.nativeEvent)&&this.pickTarget(i)||r,"string"==typeof e&&(i.type=e),i},t.prototype.createWheelEvent=function(t){var e=this.allocateEvent(Ha);this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t;var n=this.getExistedHTML(e),r=this.context.contextService.getDomElement();return e.target=n||this.isNativeEventFromCanvas(r,e.nativeEvent)&&this.pickTarget(e),e},t.prototype.trackingData=function(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]},t.prototype.cloneWheelEvent=function(t){var e=this.allocateEvent(Ha);return e.nativeEvent=t.nativeEvent,e.originalEvent=t.originalEvent,this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.target=t.target,e.path=t.composedPath().slice(),e.type=t.type,e},t.prototype.clonePointerEvent=function(t,e){var n=this.allocateEvent(Ua);return n.nativeEvent=t.nativeEvent,n.originalEvent=t.originalEvent,this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.target=t.target,n.path=t.composedPath().slice(),n.type=null!=e?e:n.type,n},t.prototype.copyPointerData=function(t,e){e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist},t.prototype.copyMouseData=function(t,e){e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.shiftKey=t.shiftKey,e.client.copyFrom(t.client),e.movement.copyFrom(t.movement),e.canvas.copyFrom(t.canvas),e.screen.copyFrom(t.screen),e.global.copyFrom(t.global),e.offset.copyFrom(t.offset)},t.prototype.copyWheelData=function(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ},t.prototype.copyData=function(t,e){e.isTrusted=t.isTrusted,e.timeStamp=da.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.page.copyFrom(t.page),e.viewport.copyFrom(t.viewport)},t.prototype.allocateEvent=function(t){this.eventPool.has(t)||this.eventPool.set(t,[]);var e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=[],e.target=null,e},t.prototype.freeEvent=function(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");var e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)},t.prototype.notifyTarget=function(t,e){e=null!=e?e:t.type;var n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?"".concat(e,"capture"):e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)},t.prototype.notifyListeners=function(t,e){var n=t.currentTarget.emitter,r=n._events[e];if(r)if("fn"in r)r.once&&n.removeListener(e,r.fn,void 0,!0),r.fn.call(t.currentTarget||r.context,t);else for(var i=0;i<r.length&&!t.propagationImmediatelyStopped;i++)r[i].once&&n.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(t.currentTarget||r[i].context,t)},t.prototype.findMountedTarget=function(t){if(!t)return null;for(var e=t[t.length-1],n=t.length-2;n>=0;n--){var r=t[n];if(!(r===this.rootTarget||Ya.isNode(r)&&r.parentNode===e))break;e=t[n]}return e},t.prototype.getCursor=function(t){for(var e=t;e;){var n=sa(e)&&e.getAttribute("cursor");if(n)return n;e=Ya.isNode(e)&&e.parentNode}},t}(),Xa=function(){function t(){}return t.prototype.getOrCreateCanvas=function(t,e){if(this.canvas)return this.canvas;if(t||fs.offscreenCanvas)this.canvas=t||fs.offscreenCanvas,this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e));else try{this.canvas=new window.OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e)),this.context&&this.context.measureText||(this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"))}catch(t){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e))}return this.canvas.width=10,this.canvas.height=10,this.canvas},t.prototype.getOrCreateContext=function(t,e){return this.context||this.getOrCreateCanvas(t,e),this.context},t}();!function(t){t[t.CAMERA_CHANGED=0]="CAMERA_CHANGED",t[t.DISPLAY_OBJECT_CHANGED=1]="DISPLAY_OBJECT_CHANGED",t[t.NONE=2]="NONE"}(Ga||(Ga={}));var Za,Qa=function(){function t(t,e){this.globalRuntime=t,this.context=e,this.inited=!1,this.stats={total:0,rendered:0},this.zIndexCounter=0,this.hooks={init:new Ta,initAsync:new Sa,dirtycheck:new Pa,cull:new Pa,beginFrame:new Ta,beforeRender:new Ta,render:new Ta,afterRender:new Ta,endFrame:new Ta,destroy:new Ta,pick:new Ca,pickSync:new Pa,pointerDown:new Ta,pointerUp:new Ta,pointerMove:new Ta,pointerOut:new Ta,pointerOver:new Ta,pointerWheel:new Ta,pointerCancel:new Ta,click:new Ta}}return t.prototype.init=function(t){var e=this,n=i(i({},this.globalRuntime),this.context);this.context.renderingPlugins.forEach((function(t){t.apply(n,e.globalRuntime)})),this.hooks.init.call(),0===this.hooks.initAsync.getCallbacksNum()?(this.inited=!0,t()):this.hooks.initAsync.promise().then((function(){e.inited=!0,t()}))},t.prototype.getStats=function(){return this.stats},t.prototype.disableDirtyRectangleRendering=function(){return!this.context.config.renderer.getConfig().enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has(Ga.CAMERA_CHANGED)},t.prototype.render=function(t,e){var n=this;this.stats.total=0,this.stats.rendered=0,this.zIndexCounter=0;var r=this.context.renderingContext;if(this.globalRuntime.sceneGraphService.syncHierarchy(r.root),this.globalRuntime.sceneGraphService.triggerPendingEvents(),r.renderReasons.size&&this.inited){r.dirtyRectangleRenderingDisabled=this.disableDirtyRectangleRendering();var i=1===r.renderReasons.size&&r.renderReasons.has(Ga.CAMERA_CHANGED),o=!t.disableRenderHooks||!(t.disableRenderHooks&&i);o&&this.renderDisplayObject(r.root,t,r),this.hooks.beginFrame.call(),o&&r.renderListCurrentFrame.forEach((function(t){n.hooks.beforeRender.call(t),n.hooks.render.call(t),n.hooks.afterRender.call(t)})),this.hooks.endFrame.call(),r.renderListCurrentFrame=[],r.renderReasons.clear(),e()}},t.prototype.renderDisplayObject=function(t,e,n){var r=this,i=e.renderer.getConfig(),o=i.enableDirtyCheck,a=i.enableCulling;this.globalRuntime.enableCSSParsing&&this.globalRuntime.styleValueRegistry.recalc(t);var s=t.renderable,c=o?s.dirty||n.dirtyRectangleRenderingDisabled?t:null:t;if(c){var u=a?this.hooks.cull.call(c,this.context.camera):c;u&&(this.stats.rendered++,n.renderListCurrentFrame.push(u))}t.renderable.dirty=!1,t.sortable.renderOrder=this.zIndexCounter++,this.stats.total++;var l=t.sortable;l.dirty&&(this.sort(t,l),l.dirty=!1,l.dirtyChildren=[],l.dirtyReason=void 0),(l.sorted||t.childNodes).forEach((function(t){r.renderDisplayObject(t,e,n)}))},t.prototype.sort=function(t,e){e.sorted&&e.dirtyReason!==ni.Z_INDEX_CHANGED?e.dirtyChildren.forEach((function(n){if(-1===t.childNodes.indexOf(n)){var r=e.sorted.indexOf(n);r>=0&&e.sorted.splice(r,1)}else if(0===e.sorted.length)e.sorted.push(n);else{var i=function(t,e){for(var n=0,r=t.length;n<r;){var i=n+r>>>1;ca(t[i],e)<0?n=i+1:r=i}return n}(e.sorted,n);e.sorted.splice(i,0,n)}})):e.sorted=t.childNodes.slice().sort(ca)},t.prototype.destroy=function(){this.inited=!1,this.hooks.destroy.call(),this.globalRuntime.sceneGraphService.clearPendingEvents()},t.prototype.dirtify=function(){this.context.renderingContext.renderReasons.add(Ga.DISPLAY_OBJECT_CHANGED)},t}(),Ja=/\[\s*(.*)=(.*)\s*\]/,ts=function(){function t(){}return t.prototype.selectOne=function(t,e){var n=this;if(t.startsWith("."))return e.find((function(e){return((null==e?void 0:e.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.find((function(e){return e.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.find((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):null}return e.find((function(n){return e!==n&&n.nodeName===t}))},t.prototype.selectAll=function(t,e){var n=this;if(t.startsWith("."))return e.findAll((function(r){return e!==r&&((null==r?void 0:r.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.findAll((function(r){return e!==r&&r.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.findAll((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):[]}return e.findAll((function(n){return e!==n&&n.nodeName===t}))},t.prototype.is=function(t,e){if(t.startsWith("."))return e.className===this.getIdOrClassname(t);if(t.startsWith("#"))return e.id===this.getIdOrClassname(t);if(t.startsWith("[")){var n=this.getAttribute(t),r=n.name,i=n.value;return"name"===r?e.name===i:this.attributeToString(e,r)===i}return e.nodeName===t},t.prototype.getIdOrClassname=function(t){return t.substring(1)},t.prototype.getAttribute=function(t){var e=t.match(Ja),n="",r="";return e&&e.length>2&&(n=e[1].replace(/"/g,""),r=e[2].replace(/"/g,"")),{name:n,value:r}},t.prototype.attributeToString=function(t,e){if(!t.getAttribute)return"";var n=t.getAttribute(e);return kt(n)?"":n.toString?n.toString():""},t}(),es=function(t){function e(e,n,r,i,o,a,s,c){var u=t.call(this,null)||this;return u.relatedNode=n,u.prevValue=r,u.newValue=i,u.attrName=o,u.attrChange=a,u.prevParsedValue=s,u.newParsedValue=c,u.type=e,u}return r(e,t),e.ADDITION=2,e.MODIFICATION=1,e.REMOVAL=3,e}(Va);function ns(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0)}!function(t){t.REPARENT="reparent",t.DESTROY="destroy",t.ATTR_MODIFIED="DOMAttrModified",t.INSERTED="DOMNodeInserted",t.REMOVED="removed",t.MOUNTED="DOMNodeInsertedIntoDocument",t.UNMOUNTED="DOMNodeRemovedFromDocument",t.BOUNDS_CHANGED="bounds-changed",t.CULLED="culled"}(Za||(Za={}));var rs,is,os,as=new es(Za.REPARENT,null,"","","",0,"",""),ss=function(){function t(t){var e,n,r,i,o,a,s,c,u=this;this.runtime=t,this.pendingEvents=[],this.boundsChangedEvent=new $a(Za.BOUNDS_CHANGED),this.rotate=(e=mt(),function(t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof n&&(n=tt(n,r,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){var a=mt();xt(a,n[0],n[1],n[2]);var s=u.getRotation(t),c=u.getRotation(t.parentNode);wt(e,c),bt(e,e),yt(a,e,a),yt(o.localRotation,a,s),Nt(o.localRotation,o.localRotation),u.dirtifyLocal(t,o)}else u.rotateLocal(t,n)}),this.rotateLocal=(n=mt(),function(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof e&&(e=tt(e,r,i));var o=t.transformable;xt(n,e[0],e[1],e[2]),Mt(o.localRotation,o.localRotation,n),u.dirtifyLocal(t,o)}),this.setEulerAngles=(r=mt(),function(t,e,n,i){void 0===n&&(n=0),void 0===i&&(i=0),"number"==typeof e&&(e=tt(e,n,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){xt(o.localRotation,e[0],e[1],e[2]);var a=u.getRotation(t.parentNode);wt(r,bt(mt(),a)),Mt(o.localRotation,o.localRotation,r),u.dirtifyLocal(t,o)}else u.setLocalEulerAngles(t,e)}),this.translateLocal=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=tt(e,n,r));var i=t.transformable;ht(e,Z())||(function(t,e,n){var r=n[0],i=n[1],o=n[2],a=n[3],s=e[0],c=e[1],u=e[2],l=i*u-o*c,h=o*s-r*u,d=r*c-i*s,f=i*d-o*h,p=o*l-r*d,g=r*h-i*l,m=2*a;l*=m,h*=m,d*=m,f*=2,p*=2,g*=2,t[0]=s+l+f,t[1]=c+h+p,t[2]=u+d+g}(e,e,i.localRotation),rt(i.localPosition,i.localPosition,e),u.dirtifyLocal(t,i))},this.setPosition=(i=x(),o=Z(),function(t,e){var n=t.transformable;if(o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,!ht(u.getPosition(t),o)){if(et(n.position,o),null!==t.parentNode&&t.parentNode.transformable){var r=t.parentNode.transformable;w(i,r.worldTransform),C(i,i),lt(n.localPosition,o,i)}else et(n.localPosition,o);u.dirtifyLocal(t,n)}}),this.setLocalPosition=function(){var t=Z();return function(e,n){var r=e.transformable;t[0]=n[0],t[1]=n[1],t[2]=n[2]||0,ht(r.localPosition,t)||(et(r.localPosition,t),u.dirtifyLocal(e,r))}}(),this.translate=(a=Z(),s=Z(),c=Z(),function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=nt(s,e,n,r)),ht(e,a)||(rt(c,u.getPosition(t),e),u.setPosition(t,c))}),this.setRotation=function(){var t=mt();return function(e,n,r,i,o){var a=e.transformable;if("number"==typeof n&&(n=Et(n,r,i,o)),null!==e.parentNode&&e.parentNode.transformable){var s=u.getRotation(e.parentNode);wt(t,s),bt(t,t),yt(a.localRotation,t,n),Nt(a.localRotation,a.localRotation),u.dirtifyLocal(e,a)}else u.setLocalRotation(e,n)}},this.displayObjectDependencyMap=new WeakMap,this.calcLocalTransform=function(){var t=x(),e=Z(),n=Et(0,0,0,1);return function(r){if(0!==r.localSkew[0]||0!==r.localSkew[1]){if(B(r.localTransform,r.localRotation,r.localPosition,tt(1,1,1),r.origin),0!==r.localSkew[0]||0!==r.localSkew[1]){var i=N(t);i[4]=Math.tan(r.localSkew[0]),i[1]=Math.tan(r.localSkew[1]),P(r.localTransform,r.localTransform,i)}var o=B(t,n,e,r.localScale,r.origin);P(r.localTransform,r.localTransform,o)}else B(r.localTransform,r.localRotation,r.localPosition,r.localScale,r.origin)}}()}return t.prototype.matches=function(t,e){return this.runtime.sceneGraphSelector.is(t,e)},t.prototype.querySelector=function(t,e){return this.runtime.sceneGraphSelector.selectOne(t,e)},t.prototype.querySelectorAll=function(t,e){return this.runtime.sceneGraphSelector.selectAll(t,e)},t.prototype.attach=function(t,e,n){var r,i,o=!1;t.parentNode&&(o=t.parentNode!==e,this.detach(t)),t.parentNode=e,kt(n)?t.parentNode.childNodes.push(t):t.parentNode.childNodes.splice(n,0,t);var a=e.sortable;((null===(r=null==a?void 0:a.sorted)||void 0===r?void 0:r.length)||(null===(i=t.style)||void 0===i?void 0:i.zIndex))&&(-1===a.dirtyChildren.indexOf(t)&&a.dirtyChildren.push(t),a.dirty=!0,a.dirtyReason=ni.ADDED);var s=t.transformable;s&&this.dirtifyWorld(t,s),s.frozen&&this.unfreezeParentToRoot(t),o&&t.dispatchEvent(as)},t.prototype.detach=function(t){var e,n;if(t.parentNode){var r=t.transformable,i=t.parentNode.sortable;((null===(e=null==i?void 0:i.sorted)||void 0===e?void 0:e.length)||(null===(n=t.style)||void 0===n?void 0:n.zIndex))&&(-1===i.dirtyChildren.indexOf(t)&&i.dirtyChildren.push(t),i.dirty=!0,i.dirtyReason=ni.REMOVED);var o=t.parentNode.childNodes.indexOf(t);o>-1&&t.parentNode.childNodes.splice(o,1),r&&this.dirtifyWorld(t,r),t.parentNode=null}},t.prototype.getOrigin=function(t){return t.transformable.origin},t.prototype.setOrigin=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=[e,n,r]);var i=t.transformable;if(e[0]!==i.origin[0]||e[1]!==i.origin[1]||e[2]!==i.origin[2]){var o=i.origin;o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,this.dirtifyLocal(t,i)}},t.prototype.setLocalEulerAngles=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=tt(e,n,r));var i=t.transformable;xt(i.localRotation,e[0],e[1],e[2]),this.dirtifyLocal(t,i)},t.prototype.scaleLocal=function(t,e){var n=t.transformable;!function(t,e,n){t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2]}(n.localScale,n.localScale,tt(e[0],e[1],e[2]||1)),this.dirtifyLocal(t,n)},t.prototype.setLocalScale=function(t,e){var n=t.transformable,r=tt(e[0],e[1],e[2]||n.localScale[2]);ht(r,n.localScale)||(et(n.localScale,r),this.dirtifyLocal(t,n))},t.prototype.setLocalRotation=function(t,e,n,r,i){"number"==typeof e&&(e=Et(e,n,r,i));var o=t.transformable;wt(o.localRotation,e),this.dirtifyLocal(t,o)},t.prototype.setLocalSkew=function(t,e,n){"number"==typeof e&&(e=function(t,e){var n=new y(2);return n[0]=t,n[1]=e,n}(e,n));var r=t.transformable;!function(t,e){t[0]=e[0],t[1]=e[1]}(r.localSkew,e),this.dirtifyLocal(t,r)},t.prototype.dirtifyLocal=function(t,e){e.localDirtyFlag||(e.localDirtyFlag=!0,e.dirtyFlag||this.dirtifyWorld(t,e))},t.prototype.dirtifyWorld=function(t,e){e.dirtyFlag||this.unfreezeParentToRoot(t),this.dirtifyWorldInternal(t,e),this.dirtifyToRoot(t,!0)},t.prototype.triggerPendingEvents=function(){var t=this,e=new Set,n=function(n,r){n.isConnected&&!e.has(n.entity)&&(t.boundsChangedEvent.detail=r,t.boundsChangedEvent.target=n,n.isMutationObserved?n.dispatchEvent(t.boundsChangedEvent):n.ownerDocument.defaultView.dispatchEvent(t.boundsChangedEvent,!0),e.add(n.entity))};this.pendingEvents.forEach((function(t){var e=u(t,2),r=e[0],i=e[1];i.affectChildren?r.forEach((function(t){n(t,i)})):n(r,i)})),this.clearPendingEvents(),e.clear()},t.prototype.clearPendingEvents=function(){this.pendingEvents=[]},t.prototype.dirtifyToRoot=function(t,e){void 0===e&&(e=!1);var n=t;for(n.renderable&&(n.renderable.dirty=!0);n;)ns(n),n=n.parentNode;e&&t.forEach((function(t){ns(t)})),this.informDependentDisplayObjects(t),this.pendingEvents.push([t,{affectChildren:e}])},t.prototype.updateDisplayObjectDependency=function(t,e,n,r){if(e&&e!==n){var i=this.displayObjectDependencyMap.get(e);if(i&&i[t]){var o=i[t].indexOf(r);i[t].splice(o,1)}}if(n){var a=this.displayObjectDependencyMap.get(n);a||(this.displayObjectDependencyMap.set(n,{}),a=this.displayObjectDependencyMap.get(n)),a[t]||(a[t]=[]),a[t].push(r)}},t.prototype.informDependentDisplayObjects=function(t){var e=this,n=this.displayObjectDependencyMap.get(t);n&&Object.keys(n).forEach((function(t){n[t].forEach((function(n){e.dirtifyToRoot(n,!0),n.dispatchEvent(new es(Za.ATTR_MODIFIED,n,e,e,t,es.MODIFICATION,e,e)),n.isCustomElement&&n.isConnected&&n.attributeChangedCallback&&n.attributeChangedCallback(t,e,e)}))}))},t.prototype.getPosition=function(t){var e=t.transformable;return L(e.position,this.getWorldTransform(t,e))},t.prototype.getRotation=function(t){var e=t.transformable;return z(e.rotation,this.getWorldTransform(t,e))},t.prototype.getScale=function(t){var e=t.transformable;return j(e.scaling,this.getWorldTransform(t,e))},t.prototype.getWorldTransform=function(t,e){return void 0===e&&(e=t.transformable),e.localDirtyFlag||e.dirtyFlag?(t.parentNode&&t.parentNode.transformable&&this.getWorldTransform(t.parentNode),this.sync(t,e),e.worldTransform):e.worldTransform},t.prototype.getLocalPosition=function(t){return t.transformable.localPosition},t.prototype.getLocalRotation=function(t){return t.transformable.localRotation},t.prototype.getLocalScale=function(t){return t.transformable.localScale},t.prototype.getLocalSkew=function(t){return t.transformable.localSkew},t.prototype.getLocalTransform=function(t){var e=t.transformable;return e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.localTransform},t.prototype.setLocalTransform=function(t,e){var n=L(Z(),e),r=z(mt(),e),i=j(Z(),e);this.setLocalScale(t,i),this.setLocalPosition(t,n),this.setLocalRotation(t,r)},t.prototype.resetLocalTransform=function(t){this.setLocalScale(t,[1,1,1]),this.setLocalPosition(t,[0,0,0]),this.setLocalEulerAngles(t,[0,0,0]),this.setLocalSkew(t,[0,0])},t.prototype.getTransformedGeometryBounds=function(t,e,n){void 0===e&&(e=!1);var r=this.getGeometryBounds(t,e);if(vr.isEmpty(r))return null;var i=n||new vr;return i.setFromTransformedAABB(r,this.getWorldTransform(t)),i},t.prototype.getGeometryBounds=function(t,e){void 0===e&&(e=!1);var n=t.geometry;return(e?n.renderBounds:n.contentBounds||null)||new vr},t.prototype.getBounds=function(t,e){var n=this;void 0===e&&(e=!1);var r=t.renderable;if(!r.boundsDirty&&!e&&r.bounds)return r.bounds;if(!r.renderBoundsDirty&&e&&r.renderBounds)return r.renderBounds;var i=e?r.renderBounds:r.bounds,o=this.getTransformedGeometryBounds(t,e,i);if(t.childNodes.forEach((function(t){var r=n.getBounds(t,e);r&&(o?o.add(r):(o=i||new vr).update(r.center,r.halfExtents))})),o||(o=new vr),e){var a=ua(t);if(a){var s=a.parsedStyle.clipPath.getBounds(e);o?s&&(o=s.intersection(o)):o.update(s.center,s.halfExtents)}}return e?(r.renderBounds=o,r.renderBoundsDirty=!1):(r.bounds=o,r.boundsDirty=!1),o},t.prototype.getLocalBounds=function(t){if(t.parentNode){var e=x();t.parentNode.transformable&&(e=C(x(),this.getWorldTransform(t.parentNode)));var n=this.getBounds(t);if(!vr.isEmpty(n)){var r=new vr;return r.setFromTransformedAABB(n,e),r}}return this.getBounds(t)},t.prototype.getBoundingClientRect=function(t){var e,n,r,i=this.getGeometryBounds(t);vr.isEmpty(i)||(r=new vr).setFromTransformedAABB(i,this.getWorldTransform(t));var o=null===(n=null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0===n?void 0:n.getContextService().getBoundingClientRect();if(r){var a=u(r.getMin(),2),s=a[0],c=a[1],l=u(r.getMax(),2),h=l[0],d=l[1];return new Nr(s+((null==o?void 0:o.left)||0),c+((null==o?void 0:o.top)||0),h-s,d-c)}return new Nr((null==o?void 0:o.left)||0,(null==o?void 0:o.top)||0,0,0)},t.prototype.dirtifyWorldInternal=function(t,e){var n=this;if(!e.dirtyFlag){e.dirtyFlag=!0,e.frozen=!1,t.childNodes.forEach((function(t){var e=t.transformable;e.dirtyFlag||n.dirtifyWorldInternal(t,e)}));var r=t.renderable;r&&(r.renderBoundsDirty=!0,r.boundsDirty=!0,r.dirty=!0)}},t.prototype.syncHierarchy=function(t){var e=t.transformable;if(!e.frozen){e.frozen=!0,(e.localDirtyFlag||e.dirtyFlag)&&this.sync(t,e);for(var n=t.childNodes,r=0;r<n.length;r++)this.syncHierarchy(n[r])}},t.prototype.sync=function(t,e){if(e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.dirtyFlag){var n=t.parentNode,r=n&&n.transformable;null!==n&&r?P(e.worldTransform,r.worldTransform,e.localTransform):w(e.worldTransform,e.localTransform),e.dirtyFlag=!1}},t.prototype.unfreezeParentToRoot=function(t){for(var e=t.parentNode;e;){var n=e.transformable;n&&(n.frozen=!1),e=e.parentNode}},t}(),cs={MetricsString:"|ÉqÅ",BaselineSymbol:"M",BaselineMultiplier:1.4,HeightMultiplier:2,Newlines:[10,13],BreakingSpaces:[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288]},us=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,ls=new RegExp("".concat(/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/.source,"|").concat(/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹓﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/.source,"|").concat(/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/.source,"|").concat(/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/.source)),hs=new RegExp("".concat(/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/.source,"|").concat(/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/.source,"|").concat(/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/.source,"|").concat(/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/.source)),ds=function(){function t(t){var e=this;this.runtime=t,this.fontMetricsCache={},this.shouldBreakByKinsokuShorui=function(t,n){return!e.isBreakingSpace(n)&&!(!t||!hs.exec(n)&&!ls.exec(t))},this.trimByKinsokuShorui=function(t){var e=l([],u(t),!1),n=e[e.length-2];if(!n)return t;var r=n[n.length-1];return e[e.length-2]=n.slice(0,-1),e[e.length-1]=r+e[e.length-1],e}}return t.prototype.measureFont=function(t,e){if(this.fontMetricsCache[t])return this.fontMetricsCache[t];var n={ascent:0,descent:0,fontSize:0},r=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(e),i=this.runtime.offscreenCanvasCreator.getOrCreateContext(e,{willReadFrequently:!0});i.font=t;var o=cs.MetricsString+cs.BaselineSymbol,a=Math.ceil(i.measureText(o).width),s=Math.ceil(i.measureText(cs.BaselineSymbol).width),c=cs.HeightMultiplier*s;s=s*cs.BaselineMultiplier|0,r.width=a,r.height=c,i.fillStyle="#f00",i.fillRect(0,0,a,c),i.font=t,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(o,0,s);var u=i.getImageData(0,0,a||1,c||1).data,l=u.length,h=4*a,d=0,f=0,p=!1;for(d=0;d<s;++d){for(var g=0;g<h;g+=4)if(255!==u[f+g]){p=!0;break}if(p)break;f+=h}for(n.ascent=s-d,f=l-h,p=!1,d=c;d>s;--d){for(g=0;g<h;g+=4)if(255!==u[f+g]){p=!0;break}if(p)break;f-=h}return n.descent=d-s,n.fontSize=n.ascent+n.descent,this.fontMetricsCache[t]=n,n},t.prototype.measureText=function(t,e,n){var r=e.fontSize,i=e.wordWrap,o=e.lineHeight,a=e.lineWidth,s=e.textBaseline,c=e.textAlign,u=e.letterSpacing,l=e.textPath;e.textPathSide,e.textPathStartOffset;var h=e.leading,d=void 0===h?0:h,f=function(t){for(var e=t.fontSize,n=t.fontFamily,r=t.fontStyle,i=t.fontVariant,o=t.fontWeight,a=Wt(e)&&"".concat(e,"px")||"16px",s=n.split(","),c=s.length-1;c>=0;c--){var u=s[c].trim();!Aa.test(u)&&ka.indexOf(u)<0&&(u='"'.concat(u,'"')),s[c]=u}return"".concat(r," ").concat(i," ").concat(o," ").concat(a," ").concat(s.join(","))}(e),p=this.measureFont(f,n);0===p.fontSize&&(p.fontSize=r,p.ascent=r);var g=this.runtime.offscreenCanvasCreator.getOrCreateContext(n);g.font=f,e.isOverflowing=!1;var m=(i?this.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),v=new Array(m.length),y=0;if(!l){for(M=0;M<m.length;M++){var b=g.measureText(m[M]).width+(m[M].length-1)*u;v[M]=b,y=Math.max(y,b)}N=y+a;var x=o||p.fontSize+a,E=Math.max(x,p.fontSize+a)+(m.length-1)*(x+d),w=0;return"middle"===s?w=-E/2:"bottom"===s||"alphabetic"===s||"ideographic"===s?w=-E:"top"!==s&&"hanging"!==s||(w=0),{font:f,width:N,height:E,lines:m,lineWidths:v,lineHeight:x+=d,maxLineWidth:y,fontProperties:p,lineMetrics:v.map((function(t,e){var n=0;return"center"===c||"middle"===c?n-=t/2:"right"!==c&&"end"!==c||(n-=t),new Nr(n-a/2,w+e*x,t+a,x)}))}}l.getTotalLength();for(var M=0;M<m.length;M++)var N=g.measureText(m[M]).width+(m[M].length-1)*u},t.prototype.setGraphemeOnPath=function(){},t.prototype.wordWrap=function(t,e,n){var r=this,i=e.wordWrapWidth,o=void 0===i?0:i,a=e.letterSpacing,s=e.maxLines,c=void 0===s?1/0:s,u=e.textOverflow,l=this.runtime.offscreenCanvasCreator.getOrCreateContext(n),h=o+a,d="";"ellipsis"===u?d="...":u&&"clip"!==u&&(d=u);for(var f=[],p=0,g=0,m={},v=function(t){return r.getFromCache(t,a,m,l)},y=Array.from(d).reduce((function(t,e){return t+v(e)}),0),b=Array.from(t),x=0;x<b.length;x++){var E=b[x],w=t[x-1],M=t[x+1],N=v(E);if(this.isNewline(E)){if(++p>=c){e.isOverflowing=!0;break}g=0,f[p]=""}else{if(g>0&&g+N>h){if(p+1>=c){if(e.isOverflowing=!0,y>0&&y<=h){for(var S=f[p].length,C=0,T=S,P=0;P<S;P++){var k=v(f[p][P]);if(C+k+y>h){T=P;break}C+=k}f[p]=(f[p]||"").slice(0,T)+d}break}if(g=0,f[++p]="",this.isBreakingSpace(E))continue;this.canBreakInLastChar(E)||(f=this.trimToBreakable(f),g=this.sumTextWidthByCache(f[p]||"",m)),this.shouldBreakByKinsokuShorui(E,M)&&(f=this.trimByKinsokuShorui(f),g+=v(w||""))}g+=N,f[p]=(f[p]||"")+E}}return f.join("\n")},t.prototype.isBreakingSpace=function(t){return"string"==typeof t&&cs.BreakingSpaces.indexOf(t.charCodeAt(0))>=0},t.prototype.isNewline=function(t){return"string"==typeof t&&cs.Newlines.indexOf(t.charCodeAt(0))>=0},t.prototype.trimToBreakable=function(t){var e=l([],u(t),!1),n=e[e.length-2],r=this.findBreakableIndex(n);if(-1===r||!n)return e;var i=n.slice(r,r+1),o=r+1,a=r+(this.isBreakingSpace(i)?0:1);return e[e.length-1]+=n.slice(o,n.length),e[e.length-2]=n.slice(0,a),e},t.prototype.canBreakInLastChar=function(t){return!t||!us.test(t)},t.prototype.sumTextWidthByCache=function(t,e){return t.split("").reduce((function(t,n){if(!e[n])throw Error("cannot count the word without cache");return t+e[n]}),0)},t.prototype.findBreakableIndex=function(t){for(var e=t.length-1;e>=0;e--)if(!us.test(t[e]))return e;return-1},t.prototype.getFromCache=function(t,e,n,r){var i=n[t];if("number"!=typeof i){var o=t.length*e;i=r.measureText(t).width+o,n[t]=i}return i},t}(),fs={},ps=(is=new Ba,os=new za,(rs={})[Yn.CIRCLE]=new Da,rs[Yn.ELLIPSE]=new Ia,rs[Yn.RECT]=is,rs[Yn.IMAGE]=is,rs[Yn.GROUP]=is,rs[Yn.LINE]=new La,rs[Yn.TEXT]=new Fa(fs),rs[Yn.POLYLINE]=os,rs[Yn.POLYGON]=os,rs[Yn.PATH]=new ja,rs[Yn.HTML]=null,rs[Yn.MESH]=null,rs),gs=function(){var t,e=new Fo,n=new Wo;return(t={})[gi.PERCENTAGE]=null,t[gi.NUMBER]=new Xo,t[gi.ANGLE]=new zo,t[gi.DEFINED_PATH]=new Bo,t[gi.PAINT]=e,t[gi.COLOR]=e,t[gi.FILTER]=new Go,t[gi.LENGTH]=n,t[gi.LENGTH_PERCENTAGE]=n,t[gi.LENGTH_PERCENTAGE_12]=new Uo,t[gi.LENGTH_PERCENTAGE_14]=new Ho,t[gi.COORDINATE]=new Yo,t[gi.OFFSET_DISTANCE]=new Zo,t[gi.OPACITY_VALUE]=new Qo,t[gi.PATH]=new Jo,t[gi.LIST_OF_POINTS]=new ta,t[gi.SHADOW_BLUR]=new ea,t[gi.TEXT]=new na,t[gi.TEXT_TRANSFORM]=new ra,t[gi.TRANSFORM]=new Oa,t[gi.TRANSFORM_ORIGIN]=new _a,t[gi.Z_INDEX]=new Ra,t[gi.MARKER]=new Ko,t}();fs.CameraContribution=Dr,fs.AnimationTimeline=null,fs.EasingFunction=null,fs.offscreenCanvasCreator=new Xa,fs.sceneGraphSelector=new ts,fs.sceneGraphService=new ss(fs),fs.textService=new ds(fs),fs.geometryUpdaterFactory=ps,fs.CSSPropertySyntaxFactory=gs,fs.styleValueRegistry=new jo(fs),fs.layoutRegistry=null,fs.globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},fs.enableCSSParsing=!0,fs.enableDataset=!1,fs.enableStyleSyntax=!0,fs.enableSizeAttenuation=!1;var ms=0,vs=new es(Za.INSERTED,null,"","","",0,"",""),ys=new es(Za.REMOVED,null,"","","",0,"",""),bs=new $a(Za.DESTROY),xs=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.entity=ms++,e.renderable={bounds:void 0,boundsDirty:!0,renderBounds:void 0,renderBoundsDirty:!0,dirtyRenderBounds:void 0,dirty:!1},e.cullable={strategy:ei.Standard,visibilityPlaneMask:-1,visible:!0,enable:!0},e.transformable={dirtyFlag:!1,localDirtyFlag:!1,frozen:!1,localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],origin:[0,0,0]},e.sortable={dirty:!1,sorted:void 0,renderOrder:0,dirtyChildren:[],dirtyReason:void 0},e.geometry={contentBounds:void 0,renderBounds:void 0},e.rBushNode={aabb:void 0},e.namespaceURI="g",e.scrollLeft=0,e.scrollTop=0,e.clientTop=0,e.clientLeft=0,e.destroyed=!1,e.style={},e.computedStyle=fs.enableCSSParsing?{anchor:oi,opacity:oi,fillOpacity:oi,strokeOpacity:oi,fill:oi,stroke:oi,transform:oi,transformOrigin:oi,visibility:oi,pointerEvents:oi,lineWidth:oi,lineCap:oi,lineJoin:oi,increasedLineWidthForHitTesting:oi,fontSize:oi,fontFamily:oi,fontStyle:oi,fontWeight:oi,fontVariant:oi,textAlign:oi,textBaseline:oi,textTransform:oi,zIndex:oi,filter:oi,shadowType:oi}:null,e.parsedStyle={},e.attributes={},e}return r(e,t),Object.defineProperty(e.prototype,"className",{get:function(){return this.getAttribute("class")||""},set:function(t){this.setAttribute("class",t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"classList",{get:function(){return this.className.split(" ").filter((function(t){return""!==t}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tagName",{get:function(){return this.nodeName},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t+1]||null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t-1]||null}return null},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(t){throw new Error(Sr)},e.prototype.appendChild=function(t,e){var n;if(t.destroyed)throw new Error("Cannot append a destroyed element.");return fs.sceneGraphService.attach(t,this,e),(null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView)&&this.ownerDocument.defaultView.mountChildren(t),vs.relatedNode=this,t.dispatchEvent(vs),t},e.prototype.insertBefore=function(t,e){if(e){t.parentElement&&t.parentElement.removeChild(t);var n=this.childNodes.indexOf(e);-1===n?this.appendChild(t):this.appendChild(t,n)}else this.appendChild(t);return t},e.prototype.replaceChild=function(t,e){var n=this.childNodes.indexOf(e);return this.removeChild(e),this.appendChild(t,n),e},e.prototype.removeChild=function(t){var e;return ys.relatedNode=this,t.dispatchEvent(ys),(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)&&t.ownerDocument.defaultView.unmountChildren(t),fs.sceneGraphService.detach(t),t},e.prototype.removeChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];this.removeChild(e)}},e.prototype.destroyChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];e.childNodes.length&&e.destroyChildren(),e.destroy()}},e.prototype.matches=function(t){return fs.sceneGraphService.matches(t,this)},e.prototype.getElementById=function(t){return fs.sceneGraphService.querySelector("#".concat(t),this)},e.prototype.getElementsByName=function(t){return fs.sceneGraphService.querySelectorAll('[name="'.concat(t,'"]'),this)},e.prototype.getElementsByClassName=function(t){return fs.sceneGraphService.querySelectorAll(".".concat(t),this)},e.prototype.getElementsByTagName=function(t){return fs.sceneGraphService.querySelectorAll(t,this)},e.prototype.querySelector=function(t){return fs.sceneGraphService.querySelector(t,this)},e.prototype.querySelectorAll=function(t){return fs.sceneGraphService.querySelectorAll(t,this)},e.prototype.closest=function(t){var e=this;do{if(fs.sceneGraphService.matches(t,e))return e;e=e.parentElement}while(null!==e);return null},e.prototype.find=function(t){var e=this,n=null;return this.forEach((function(r){return!(r===e||!t(r))&&(n=r,!0)})),n},e.prototype.findAll=function(t){var e=this,n=[];return this.forEach((function(r){r!==e&&t(r)&&n.push(r)})),n},e.prototype.after=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this);e.forEach((function(e,n){var i;return null===(i=t.parentNode)||void 0===i?void 0:i.appendChild(e,r+n+1)}))}},e.prototype.before=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this),i=u(e),o=i[0],a=i.slice(1);this.parentNode.appendChild(o,r),(t=o).after.apply(t,l([],u(a),!1))}},e.prototype.replaceWith=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.after.apply(this,l([],u(t),!1)),this.remove()},e.prototype.append=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e){return t.appendChild(e)}))},e.prototype.prepend=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e,n){return t.appendChild(e,n)}))},e.prototype.replaceChildren=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(;this.childNodes.length&&this.firstChild;)this.removeChild(this.firstChild);this.append.apply(this,l([],u(t),!1))},e.prototype.remove=function(){return this.parentNode?this.parentNode.removeChild(this):this},e.prototype.destroy=function(){this.dispatchEvent(bs),this.remove(),this.emitter.removeAllListeners(),this.destroyed=!0},e.prototype.getGeometryBounds=function(){return fs.sceneGraphService.getGeometryBounds(this)},e.prototype.getRenderBounds=function(){return fs.sceneGraphService.getBounds(this,!0)},e.prototype.getBounds=function(){return fs.sceneGraphService.getBounds(this)},e.prototype.getLocalBounds=function(){return fs.sceneGraphService.getLocalBounds(this)},e.prototype.getBoundingClientRect=function(){return fs.sceneGraphService.getBoundingClientRect(this)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.computedStyleMap=function(){return new Map(Object.entries(this.computedStyle))},e.prototype.getAttributeNames=function(){return Object.keys(this.attributes)},e.prototype.getAttribute=function(t){if(function(t){return"symbol"==typeof t}(t))return fs.enableCSSParsing?null:void 0;var e=this.attributes[t];if(void 0===e){var n=Xr(t);return e=this.attributes[n],fs.enableCSSParsing&&kt(e)?null:e}return e},e.prototype.hasAttribute=function(t){return this.getAttributeNames().includes(t)},e.prototype.hasAttributes=function(){return!!this.getAttributeNames().length},e.prototype.removeAttribute=function(t){this.setAttribute(t,null),delete this.attributes[t]},e.prototype.setAttribute=function(t,e,n){this.attributes[t]=e},e.prototype.getAttributeNS=function(t,e){throw new Error(Sr)},e.prototype.getAttributeNode=function(t){throw new Error(Sr)},e.prototype.getAttributeNodeNS=function(t,e){throw new Error(Sr)},e.prototype.hasAttributeNS=function(t,e){throw new Error(Sr)},e.prototype.removeAttributeNS=function(t,e){throw new Error(Sr)},e.prototype.removeAttributeNode=function(t){throw new Error(Sr)},e.prototype.setAttributeNS=function(t,e,n){throw new Error(Sr)},e.prototype.setAttributeNode=function(t){throw new Error(Sr)},e.prototype.setAttributeNodeNS=function(t){throw new Error(Sr)},e.prototype.toggleAttribute=function(t,e){throw new Error(Sr)},e}(Ya);function Es(t){return!!(null==t?void 0:t.nodeName)}var ws,Ms=new es(Za.ATTR_MODIFIED,null,null,null,null,es.MODIFICATION,null,null),Ns={anchor:"",opacity:"",fillOpacity:"",strokeOpacity:"",fill:"",stroke:"",transform:"",transformOrigin:"",visibility:"",pointerEvents:"",lineWidth:"",lineCap:"",lineJoin:"",increasedLineWidthForHitTesting:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",zIndex:"",filter:"",shadowType:""},Ss={anchor:[0,0],fill:li,stroke:li,transform:[],zIndex:0,filter:[],shadowType:"outer",miterLimit:10},Cs=i(i({},Ss),{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:"visible",pointerEvents:"auto",lineWidth:1,lineCap:"butt",lineJoin:"miter",increasedLineWidthForHitTesting:0,fillRule:"nonzero"}),Ts=l(l([],u(["opacity","fillOpacity","strokeOpacity","transformOrigin","visibility","pointerEvents","lineWidth","lineCap","lineJoin","increasedLineWidthForHitTesting"]),!1),["fontSize","fontFamily","fontStyle","fontWeight","fontVariant","textAlign","textBaseline","textTransform"],!1),Ps="data-",ks=function(t){function e(e){var n,r=t.call(this)||this;r.isCustomElement=!1,r.isMutationObserved=!1,r.activeAnimations=[],r.getClip=function(){return this.style.clipPath||null},r.config=e,r.config.interactive=null!==(n=r.config.capture)&&void 0!==n?n:r.config.interactive,r.id=r.config.id||"",r.name=r.config.name||"",(r.config.className||r.config.class)&&(r.className=r.config.className||r.config.class),r.nodeName=r.config.type||Yn.GROUP,r.config.style=r.config.style||r.config.attrs||{},Object.assign(r.config.style,r.config.attrs),null!=r.config.visible&&(r.config.style.visibility=!1===r.config.visible?"hidden":"visible"),null!=r.config.interactive&&(r.config.style.pointerEvents=!1===r.config.interactive?"none":"auto"),Object.assign(r.parsedStyle,fs.enableCSSParsing?Ss:Cs,r.config.initialParsedStyle),fs.enableCSSParsing&&Object.assign(r.attributes,Ns),r.initAttributes(r.config.style);var i=fs.globalThis.Proxy?fs.globalThis.Proxy:function(){};return fs.enableDataset&&(r.dataset=new i({},{get:function(t,e){var n="".concat(Ps).concat(qr(e));return void 0!==t[n]?t[n]:r.getAttribute(n)},set:function(t,e,n){return r.setAttribute("".concat(Ps).concat(qr(e)),n),!0}})),fs.enableStyleSyntax&&(r.style=new i({setProperty:function(t,e){r.setAttribute(t,e)},getPropertyValue:function(t){return r.getAttribute(t)},removeProperty:function(t){r.removeAttribute(t)},item:function(){return""}},{get:function(t,e){return void 0!==t[e]?t[e]:r.getAttribute(e)},set:function(t,e,n){return r.setAttribute(e,n),!0}})),r}return r(e,t),e.prototype.destroy=function(){t.prototype.destroy.call(this),this.getAnimations().forEach((function(t){t.cancel()}))},e.prototype.cloneNode=function(t,e){var n=i({},this.attributes);for(var r in n){var o=n[r];Es(o)&&"clipPath"!==r&&"offsetPath"!==r&&"textPath"!==r&&(n[r]=o.cloneNode(t)),e&&(n[r]=e(r,o))}var a=new this.constructor({id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:n});return a.setLocalTransform(this.getLocalTransform()),t&&this.children.forEach((function(e){if(!e.style.isMarker){var n=e.cloneNode(t);a.appendChild(n)}})),a},e.prototype.initAttributes=function(t){void 0===t&&(t={});var e=this.renderable,n={forceUpdateGeometry:!0};fs.enableCSSParsing&&(n.usedAttributes=Ts);var r={};for(var i in t){r[Xr(i)]=t[i]}fs.styleValueRegistry.processProperties(this,r,n),e.dirty=!0},e.prototype.setAttribute=function(e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=!0);var o=Xr(e);Qt(n)||(r||n!==this.attributes[o])&&(this.internalSetAttribute(o,n,{memoize:i}),t.prototype.setAttribute.call(this,o,n))},e.prototype.internalSetAttribute=function(t,e,n){var r;void 0===n&&(n={});var i=this.renderable,o=this.attributes[t],a=this.parsedStyle[t];fs.styleValueRegistry.processProperties(this,((r={})[t]=e,r),n),i.dirty=!0;var s=this.parsedStyle[t];this.isConnected&&(Ms.relatedNode=this,Ms.prevValue=o,Ms.newValue=e,Ms.attrName=t,Ms.prevParsedValue=a,Ms.newParsedValue=s,this.isMutationObserved?this.dispatchEvent(Ms):(Ms.target=this,this.ownerDocument.defaultView.dispatchEvent(Ms,!0))),(this.isCustomElement&&this.isConnected||!this.isCustomElement)&&this.attributeChangedCallback&&this.attributeChangedCallback(t,o,e,a,s)},e.prototype.getBBox=function(){var t=this.getBounds(),e=u(t.getMin(),2),n=e[0],r=e[1],i=u(t.getMax(),2),o=i[0],a=i[1];return new Nr(n,r,o-n,a-r)},e.prototype.setOrigin=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),fs.sceneGraphService.setOrigin(this,ir(t,e,n)),this},e.prototype.getOrigin=function(){return fs.sceneGraphService.getOrigin(this)},e.prototype.setPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),fs.sceneGraphService.setPosition(this,ir(t,e,n)),this},e.prototype.setLocalPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),fs.sceneGraphService.setLocalPosition(this,ir(t,e,n)),this},e.prototype.translate=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),fs.sceneGraphService.translate(this,ir(t,e,n)),this},e.prototype.translateLocal=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),fs.sceneGraphService.translateLocal(this,ir(t,e,n)),this},e.prototype.getPosition=function(){return fs.sceneGraphService.getPosition(this)},e.prototype.getLocalPosition=function(){return fs.sceneGraphService.getLocalPosition(this)},e.prototype.scale=function(t,e,n){return this.scaleLocal(t,e,n)},e.prototype.scaleLocal=function(t,e,n){return"number"==typeof t&&(t=ir(t,e=e||t,n=n||t)),fs.sceneGraphService.scaleLocal(this,t),this},e.prototype.setLocalScale=function(t,e,n){return"number"==typeof t&&(t=ir(t,e=e||t,n=n||t)),fs.sceneGraphService.setLocalScale(this,t),this},e.prototype.getLocalScale=function(){return fs.sceneGraphService.getLocalScale(this)},e.prototype.getScale=function(){return fs.sceneGraphService.getScale(this)},e.prototype.getEulerAngles=function(){return ar(u(sr(Z(),fs.sceneGraphService.getWorldTransform(this)),3)[2])},e.prototype.getLocalEulerAngles=function(){return ar(u(sr(Z(),fs.sceneGraphService.getLocalRotation(this)),3)[2])},e.prototype.setEulerAngles=function(t){return fs.sceneGraphService.setEulerAngles(this,0,0,t),this},e.prototype.setLocalEulerAngles=function(t){return fs.sceneGraphService.setLocalEulerAngles(this,0,0,t),this},e.prototype.rotateLocal=function(t,e,n){return kt(e)&&kt(n)?fs.sceneGraphService.rotateLocal(this,0,0,t):fs.sceneGraphService.rotateLocal(this,t,e,n),this},e.prototype.rotate=function(t,e,n){return kt(e)&&kt(n)?fs.sceneGraphService.rotate(this,0,0,t):fs.sceneGraphService.rotate(this,t,e,n),this},e.prototype.setRotation=function(t,e,n,r){return fs.sceneGraphService.setRotation(this,t,e,n,r),this},e.prototype.setLocalRotation=function(t,e,n,r){return fs.sceneGraphService.setLocalRotation(this,t,e,n,r),this},e.prototype.setLocalSkew=function(t,e){return fs.sceneGraphService.setLocalSkew(this,t,e),this},e.prototype.getRotation=function(){return fs.sceneGraphService.getRotation(this)},e.prototype.getLocalRotation=function(){return fs.sceneGraphService.getLocalRotation(this)},e.prototype.getLocalSkew=function(){return fs.sceneGraphService.getLocalSkew(this)},e.prototype.getLocalTransform=function(){return fs.sceneGraphService.getLocalTransform(this)},e.prototype.getWorldTransform=function(){return fs.sceneGraphService.getWorldTransform(this)},e.prototype.setLocalTransform=function(t){return fs.sceneGraphService.setLocalTransform(this,t),this},e.prototype.resetLocalTransform=function(){fs.sceneGraphService.resetLocalTransform(this)},e.prototype.getAnimations=function(){return this.activeAnimations},e.prototype.animate=function(t,e){var n,r=null===(n=this.ownerDocument)||void 0===n?void 0:n.timeline;return r?r.play(this,t,e):null},e.prototype.isVisible=function(){var t;return"visible"===(null===(t=this.parsedStyle)||void 0===t?void 0:t.visibility)},Object.defineProperty(e.prototype,"interactive",{get:function(){return this.isInteractive()},set:function(t){this.style.pointerEvents=t?"auto":"none"},enumerable:!1,configurable:!0}),e.prototype.isInteractive=function(){var t;return"none"!==(null===(t=this.parsedStyle)||void 0===t?void 0:t.pointerEvents)},e.prototype.isCulled=function(){return!(!this.cullable||!this.cullable.enable||this.cullable.visible)},e.prototype.toFront=function(){return this.parentNode&&(this.style.zIndex=Math.max.apply(Math,l([],u(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))+1),this},e.prototype.toBack=function(){return this.parentNode&&(this.style.zIndex=Math.min.apply(Math,l([],u(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))-1),this},e.prototype.getConfig=function(){return this.config},e.prototype.attr=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=u(e,2),i=r[0],o=r[1];return i?Rt(i)?(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),this):2===e.length?(this.setAttribute(i,o),this):this.attributes[i]:this.attributes},e.prototype.getMatrix=function(t){var e=t||this.getWorldTransform(),n=u(L(Z(),e),2),r=n[0],i=n[1],o=u(j(Z(),e),2),a=o[0],s=o[1],c=z(mt(),e),l=u(sr(Z(),c),3),h=l[0],d=l[2];return cr(h||d,r,i,a,s)},e.prototype.getLocalMatrix=function(){return this.getMatrix(this.getLocalTransform())},e.prototype.setMatrix=function(t){var e=u(ur(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setEulerAngles(a).setPosition(n,r).setLocalScale(i,o)},e.prototype.setLocalMatrix=function(t){var e=u(ur(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setLocalEulerAngles(a).setLocalPosition(n,r).setLocalScale(i,o)},e.prototype.show=function(){fs.enableCSSParsing?this.style.visibility="visible":this.forEach((function(t){t.style.visibility="visible"}))},e.prototype.hide=function(){fs.enableCSSParsing?this.style.visibility="hidden":this.forEach((function(t){t.style.visibility="hidden"}))},e.prototype.getCount=function(){return this.childElementCount},e.prototype.getParent=function(){return this.parentElement},e.prototype.getChildren=function(){return this.children},e.prototype.getFirst=function(){return this.firstElementChild},e.prototype.getLast=function(){return this.lastElementChild},e.prototype.getChildByIndex=function(t){return this.children[t]||null},e.prototype.add=function(t,e){return this.appendChild(t,e)},e.prototype.setClip=function(t){this.style.clipPath=t},e.prototype.set=function(t,e){this.config[t]=e},e.prototype.get=function(t){return this.config[t]},e.prototype.moveTo=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.move=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.setZIndex=function(t){return this.style.zIndex=t,this},e}(xs),As=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Yn.CIRCLE,style:fs.enableCSSParsing?i({cx:"",cy:"",r:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:fs.enableCSSParsing?null:[pi,pi]}},r))||this}return r(e,t),e}(ks),Os=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({style:fs.enableCSSParsing?i({x:"",y:""},r):i({},r)},a))||this).isCustomElement=!0,n}return r(e,t),e}(ks),_s=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Yn.ELLIPSE,style:fs.enableCSSParsing?i({cx:"",cy:"",rx:"",ry:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:fs.enableCSSParsing?null:[pi,pi]}},r))||this}return r(e,t),e}(ks),Rs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Yn.GROUP,style:fs.enableCSSParsing?i({x:"",y:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(ks),Ds=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({type:Yn.HTML,style:fs.enableCSSParsing?i({x:"",y:"",width:"auto",height:"auto",innerHTML:""},r):i({},r)},a))||this).cullable.enable=!1,n}return r(e,t),e.prototype.getDomElement=function(){return this.parsedStyle.$el},e.prototype.getBoundingClientRect=function(){if(this.parsedStyle.$el)return this.parsedStyle.$el.getBoundingClientRect();var t=this.parsedStyle,e=t.x,n=t.y,r=t.width,i=t.height;return new Nr(e,n,r,i)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.getBounds=function(){var t,e,n=this.getBoundingClientRect(),r=null===(e=null===(t=this.ownerDocument)||void 0===t?void 0:t.defaultView)||void 0===e?void 0:e.getContextService().getBoundingClientRect(),i=new vr,o=n.left-((null==r?void 0:r.left)||0),a=n.top-((null==r?void 0:r.top)||0);return i.setMinMax([o,a,0],[o+n.width,a+n.height,0]),i},e.prototype.getLocalBounds=function(){if(this.parentNode){var t=C(x(),this.parentNode.getWorldTransform()),e=this.getBounds();if(!vr.isEmpty(e)){var n=new vr;return n.setFromTransformedAABB(e,t),n}}return this.getBounds()},e}(ks),Is=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Yn.IMAGE,style:fs.enableCSSParsing?i({x:"",y:"",img:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(ks),Ls=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:Yn.LINE,style:i({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0},r)},a))||this).markerStartAngle=0,n.markerEndAngle=0;var s=n.parsedStyle,c=s.markerStart,u=s.markerEnd;return c&&Es(c)&&(n.markerStartAngle=c.getLocalEulerAngles(),n.appendChild(c)),u&&Es(u)&&(n.markerEndAngle=u.getLocalEulerAngles(),n.appendChild(u)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"x1"===t||"y1"===t||"x2"===t||"y2"===t||"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Es(r)&&(this.markerStartAngle=0,r.remove()),i&&Es(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t&&(r&&Es(r)&&(this.markerEndAngle=0,r.remove()),i&&Es(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1)))},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.x1,s=e.x2,c=e.y1,u=e.y2,l=e.defX,h=e.defY,d=t?n:r;if(d&&Es(d)){var f,p,g,m,v,y,b;t?(m=a-l,v=c-h,p=s-a,g=u-c,y=i||0,b=this.markerStartAngle):(m=s-l,v=u-h,p=a-s,g=c-u,y=o||0,b=this.markerEndAngle),f=Math.atan2(g,p),d.setLocalEulerAngles(180*f/Math.PI+b),d.setLocalPosition(m+Math.cos(f)*y,v+Math.sin(f)*y)}},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.x1,i=n.y1,o=n.x2,a=n.y2,s=n.defX,c=n.defY,u=Ln(r,i,o,a,t),l=u.x,h=u.y,d=lt(Z(),tt(l-s,h-c,0),e?this.getWorldTransform():this.getLocalTransform());return new Mr(d[0],d[1])},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getTotalLength=function(){var t=this.parsedStyle;return In(t.x1,t.y1,t.x2,t.y2)},e}(ks),js=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:Yn.PATH,style:fs.enableCSSParsing?i({path:"",miterLimit:""},r):i({},r),initialParsedStyle:fs.enableCSSParsing?null:{miterLimit:4,path:i({},mi)}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,c=s.markerStart,u=s.markerEnd,l=s.markerMid;return c&&Es(c)&&(n.markerStartAngle=c.getLocalEulerAngles(),n.appendChild(c)),l&&Es(l)&&n.placeMarkerMid(l),u&&Es(u)&&(n.markerEndAngle=u.getLocalEulerAngles(),n.appendChild(u)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"path"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Es(r)&&(this.markerStartAngle=0,r.remove()),i&&Es(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&Es(r)&&(this.markerEndAngle=0,r.remove()),i&&Es(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.defX,s=e.defY,c=t?n:r;if(c&&Es(c)){var l,h,d,f,p,g,m;if(t){var v=u(this.getStartTangent(),2),y=v[0];f=(b=v[1])[0]-a,p=b[1]-s,h=y[0]-b[0],d=y[1]-b[1],g=i||0,m=this.markerStartAngle}else{var b,x=u(this.getEndTangent(),2);y=x[0];f=(b=x[1])[0]-a,p=b[1]-s,h=y[0]-b[0],d=y[1]-b[1],g=o||0,m=this.markerEndAngle}l=Math.atan2(d,h),c.setLocalEulerAngles(180*l/Math.PI+m),c.setLocalPosition(f+Math.cos(l)*g,p+Math.sin(l)*g)}},e.prototype.placeMarkerMid=function(t){var e=this.parsedStyle,n=e.path.segments,r=e.defX,i=e.defY;if(this.markerMidList.forEach((function(t){t.remove()})),t&&Es(t))for(var o=1;o<n.length-1;o++){var a=u(n[o].currentPoint,2),s=a[0],c=a[1],l=1===o?t:t.cloneNode(!0);this.markerMidList.push(l),this.appendChild(l),l.setLocalPosition(s-r,c-i)}},e.prototype.getTotalLength=function(){return Zi(this)},e.prototype.getPointAtLength=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.defX,o=n.defY,a=function(t,e,n){return $e(t,e,i(i({},n),{bbox:!1,length:!0})).point}(n.path.absolutePath,t),s=a.x,c=a.y,u=lt(Z(),tt(s-r,c-o,0),e?this.getWorldTransform():this.getLocalTransform());return new Mr(u[0],u[1])},e.prototype.getPoint=function(t,e){return void 0===e&&(e=!1),this.getPointAtLength(t*Zi(this),e)},e.prototype.getStartTangent=function(){var t=this.parsedStyle.path.segments,e=[];if(t.length>1){var n=t[0].currentPoint,r=t[1].currentPoint,i=t[1].startTangent;e=[],i?(e.push([n[0]-i[0],n[1]-i[1]]),e.push([n[0],n[1]])):(e.push([r[0],r[1]]),e.push([n[0],n[1]]))}return e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.path.segments,e=t.length,n=[];if(e>1){var r=t[e-2].currentPoint,i=t[e-1].currentPoint,o=t[e-1].endTangent;n=[],o?(n.push([i[0]-o[0],i[1]-o[1]]),n.push([i[0],i[1]])):(n.push([r[0],r[1]]),n.push([i[0],i[1]]))}return n},e}(ks),zs=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:Yn.POLYGON,style:fs.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!0},r):i({},r),initialParsedStyle:fs.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!0}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,c=s.markerStart,u=s.markerEnd,l=s.markerMid;return c&&Es(c)&&(n.markerStartAngle=c.getLocalEulerAngles(),n.appendChild(c)),l&&Es(l)&&n.placeMarkerMid(l),u&&Es(u)&&(n.markerEndAngle=u.getLocalEulerAngles(),n.appendChild(u)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"points"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Es(r)&&(this.markerStartAngle=0,r.remove()),i&&Es(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&Es(r)&&(this.markerEndAngle=0,r.remove()),i&&Es(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.points,s=e.defX,c=e.defY,u=(a||{}).points,l=t?n:r;if(l&&Es(l)&&u){var h,d,f,p,g,m,v;if(p=u[0][0]-s,g=u[0][1]-c,t)d=u[1][0]-u[0][0],f=u[1][1]-u[0][1],m=i||0,v=this.markerStartAngle;else{var y=u.length;this.parsedStyle.isClosed?(d=u[y-1][0]-u[0][0],f=u[y-1][1]-u[0][1]):(p=u[y-1][0]-s,g=u[y-1][1]-c,d=u[y-2][0]-u[y-1][0],f=u[y-2][1]-u[y-1][1]),m=o||0,v=this.markerEndAngle}h=Math.atan2(f,d),l.setLocalEulerAngles(180*h/Math.PI+v),l.setLocalPosition(p+Math.cos(h)*m,g+Math.sin(h)*m)}},e.prototype.placeMarkerMid=function(t){var e=this.parsedStyle,n=e.points,r=e.defX,i=e.defY,o=(n||{}).points;if(this.markerMidList.forEach((function(t){t.remove()})),this.markerMidList=[],t&&Es(t)&&o)for(var a=1;a<(this.parsedStyle.isClosed?o.length:o.length-1);a++){var s=o[a][0]-r,c=o[a][1]-i,u=1===a?t:t.cloneNode(!0);this.markerMidList.push(u),this.appendChild(u),u.setLocalPosition(s,c)}},e}(ks),Bs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Yn.POLYLINE,style:fs.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!1},n):i({},n),initialParsedStyle:fs.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!1}},r))||this}return r(e,t),e.prototype.getTotalLength=function(){return this.parsedStyle.points.totalLength},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=n.defX,i=n.defY,o=n.points,a=o.points,s=o.segments,c=0,u=0;s.forEach((function(e,n){t>=e[0]&&t<=e[1]&&(c=(t-e[0])/(e[1]-e[0]),u=n)}));var l=Ln(a[u][0],a[u][1],a[u+1][0],a[u+1][1],c),h=l.x,d=l.y,f=lt(Z(),tt(h-r,d-i,0),e?this.getWorldTransform():this.getLocalTransform());return new Mr(f[0],f[1])},e.prototype.getStartTangent=function(){var t=this.parsedStyle.points.points,e=[];return e.push([t[1][0],t[1][1]]),e.push([t[0][0],t[0][1]]),e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.points.points,e=t.length-1,n=[];return n.push([t[e-1][0],t[e-1][1]]),n.push([t[e][0],t[e][1]]),n},e}(zs),Fs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Yn.RECT,style:fs.enableCSSParsing?i({x:"",y:"",width:"",height:"",radius:""},n):i({},n)},r))||this}return r(e,t),e}(ks),Gs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Yn.TEXT,style:fs.enableCSSParsing?i({x:"",y:"",text:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",fill:"black",letterSpacing:"",lineHeight:"",miterLimit:"",wordWrap:!1,wordWrapWidth:0,leading:0,dx:"",dy:""},n):i({fill:"black"},n),initialParsedStyle:fs.enableCSSParsing?{}:{x:0,y:0,fontSize:16,fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",fontVariant:"normal",lineHeight:0,letterSpacing:0,textBaseline:"alphabetic",textAlign:"start",wordWrap:!1,wordWrapWidth:0,leading:0,dx:0,dy:0}},r))||this}return r(e,t),e.prototype.getComputedTextLength=function(){var t;return(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.maxLineWidth)||0},e.prototype.getLineBoundingRects=function(){var t;return(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.lineMetrics)||[]},e.prototype.isOverflowing=function(){return!!this.parsedStyle.isOverflowing},e}(ks),Vs=function(){function t(){this.registry={},this.define(Yn.CIRCLE,As),this.define(Yn.ELLIPSE,_s),this.define(Yn.RECT,Fs),this.define(Yn.IMAGE,Is),this.define(Yn.LINE,Ls),this.define(Yn.GROUP,Rs),this.define(Yn.PATH,js),this.define(Yn.POLYGON,zs),this.define(Yn.POLYLINE,Bs),this.define(Yn.TEXT,Gs),this.define(Yn.HTML,Ds)}return t.prototype.define=function(t,e){this.registry[t]=e},t.prototype.get=function(t){return this.registry[t]},t}(),Ws=function(t){function e(){var e=t.call(this)||this;e.defaultView=null,e.ownerDocument=null,e.nodeName="document";try{e.timeline=new fs.AnimationTimeline(e)}catch(t){}var n={};return Ro.forEach((function(t){var e=t.n,r=t.inh,i=t.d;r&&i&&(n[e]=Yr(i)?i(Yn.GROUP):i)})),e.documentElement=new Rs({id:"g-root",style:n}),e.documentElement.ownerDocument=e,e.documentElement.parentNode=e,e.childNodes=[e.documentElement],e}return r(e,t),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),e.prototype.createElement=function(t,e){if("svg"===t)return this.documentElement;var n=this.defaultView.customElements.get(t);n||(console.warn("Unsupported tagName: ",t),n="tspan"===t?Gs:Rs);var r=new n(e);return r.ownerDocument=this,r},e.prototype.createElementNS=function(t,e,n){return this.createElement(e,n)},e.prototype.cloneNode=function(t){throw new Error(Sr)},e.prototype.destroy=function(){try{this.documentElement.destroyChildren(),this.timeline.destroy()}catch(t){}},e.prototype.elementsFromBBox=function(t,e,n,r){var i=this.defaultView.context.rBushRoot.search({minX:t,minY:e,maxX:n,maxY:r}),o=[];return i.forEach((function(t){var e=t.displayObject,n=e.parsedStyle.pointerEvents,r=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(n);(!r||r&&e.isVisible())&&!e.isCulled()&&e.isInteractive()&&o.push(e)})),o.sort((function(t,e){return e.sortable.renderOrder-t.sortable.renderOrder})),o},e.prototype.elementFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return null;var c=this.defaultView.viewport2Client({x:r,y:i}),u=c.x,l=c.y,h=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:u,clientY:l},picked:[]}).picked;return h&&h[0]||this.documentElement},e.prototype.elementFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,c=o.height,r<0||i<0||r>a||i>c?[2,null]:(u=this.defaultView.viewport2Client({x:r,y:i}),l=u.x,h=u.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:l,clientY:h},picked:[]})]);case 1:return[2,(d=s.sent().picked)&&d[0]||this.documentElement]}}))}))},e.prototype.elementsFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return[];var c=this.defaultView.viewport2Client({x:r,y:i}),u=c.x,l=c.y,h=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:u,clientY:l},picked:[]}).picked;return h[h.length-1]!==this.documentElement&&h.push(this.documentElement),h},e.prototype.elementsFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,c=o.height,r<0||i<0||r>a||i>c?[2,[]]:(u=this.defaultView.viewport2Client({x:r,y:i}),l=u.x,h=u.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:l,clientY:h},picked:[]})]);case 1:return(d=s.sent().picked)[d.length-1]!==this.documentElement&&d.push(this.documentElement),[2,d]}}))}))},e.prototype.appendChild=function(t,e){throw new Error(Cr)},e.prototype.insertBefore=function(t,e){throw new Error(Cr)},e.prototype.removeChild=function(t,e){throw new Error(Cr)},e.prototype.replaceChild=function(t,e,n){throw new Error(Cr)},e.prototype.append=function(){throw new Error(Cr)},e.prototype.prepend=function(){throw new Error(Cr)},e.prototype.getElementById=function(t){return this.documentElement.getElementById(t)},e.prototype.getElementsByName=function(t){return this.documentElement.getElementsByName(t)},e.prototype.getElementsByTagName=function(t){return this.documentElement.getElementsByTagName(t)},e.prototype.getElementsByClassName=function(t){return this.documentElement.getElementsByClassName(t)},e.prototype.querySelector=function(t){return this.documentElement.querySelector(t)},e.prototype.querySelectorAll=function(t){return this.documentElement.querySelectorAll(t)},e.prototype.find=function(t){return this.documentElement.find(t)},e.prototype.findAll=function(t){return this.documentElement.findAll(t)},e}(Ya),Us=function(){function t(t){this.strategies=t}return t.prototype.apply=function(e){var n=e.camera,r=e.renderingService,i=e.renderingContext,o=this.strategies;r.hooks.cull.tap(t.tag,(function(t){if(t){var e=t.cullable;return 0===o.length?e.visible=i.unculledEntities.indexOf(t.entity)>-1:e.visible=o.every((function(e){return e.isVisible(n,t)})),!t.isCulled()&&t.isVisible()?t:(t.dispatchEvent(new $a(Za.CULLED)),null)}return t})),r.hooks.afterRender.tap(t.tag,(function(t){t.cullable.visibilityPlaneMask=-1}))},t.tag="Culling",t}(),Hs=function(){function t(){var t=this;this.autoPreventDefault=!1,this.rootPointerEvent=new Ua(null),this.rootWheelEvent=new Ha(null),this.onPointerMove=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView;if(!a.supportsTouchEvents||"touch"!==e.pointerType){var s=t.normalizeToPointerEvent(e,a);try{for(var u=c(s),l=u.next();!l.done;l=u.next()){var h=l.value,d=t.bootstrapEvent(t.rootPointerEvent,h,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}},this.onClick=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView,s=t.normalizeToPointerEvent(e,a);try{for(var u=c(s),l=u.next();!l.done;l=u.next()){var h=l.value,d=t.bootstrapEvent(t.rootPointerEvent,h,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}}return t.prototype.apply=function(e){var n=this;this.context=e;var r=e.renderingService,i=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler((function(t){return n.context.renderingService.hooks.pickSync.call({position:t,picked:[],topmost:!0}).picked[0]||null})),r.hooks.pointerWheel.tap(t.tag,(function(t){var e=n.normalizeWheelEvent(t);n.context.eventService.mapEvent(e)})),r.hooks.pointerDown.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.normalizeToPointerEvent(t,i);if(n.autoPreventDefault&&o[0].isNormalized)(t.cancelable||!("cancelable"in t))&&t.preventDefault();try{for(var a=c(o),s=a.next();!s.done;s=a.next()){var u=s.value,l=n.bootstrapEvent(n.rootPointerEvent,u,i,t);n.context.eventService.mapEvent(l)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerUp.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.context.contextService.getDomElement(),a=n.context.eventService.isNativeEventFromCanvas(o,t)?"":"outside",s=n.normalizeToPointerEvent(t,i);try{for(var u=c(s),l=u.next();!l.done;l=u.next()){var h=l.value,d=n.bootstrapEvent(n.rootPointerEvent,h,i,t);d.type+=a,n.context.eventService.mapEvent(d)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerMove.tap(t.tag,this.onPointerMove),r.hooks.pointerOver.tap(t.tag,this.onPointerMove),r.hooks.pointerOut.tap(t.tag,this.onPointerMove),r.hooks.click.tap(t.tag,this.onClick),r.hooks.pointerCancel.tap(t.tag,(function(t){var e,r,o=n.normalizeToPointerEvent(t,i);try{for(var a=c(o),s=a.next();!s.done;s=a.next()){var u=s.value,l=n.bootstrapEvent(n.rootPointerEvent,u,i,t);n.context.eventService.mapEvent(l)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}))},t.prototype.getViewportXY=function(t){var e,n,r=t.offsetX,i=t.offsetY,o=t.clientX,a=t.clientY;if(!this.context.config.supportsCSSTransform||kt(r)||kt(i)){var s=this.context.eventService.client2Viewport(new Mr(o,a));e=s.x,n=s.y}else e=r,n=i;return{x:e,y:n}},t.prototype.bootstrapEvent=function(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);var i=this.getViewportXY(e),o=i.x,a=i.y;t.viewport.x=o,t.viewport.y=a;var s=this.context.eventService.viewport2Canvas(t.viewport),c=s.x,u=s.y;return t.canvas.x=c,t.canvas.y=u,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=ha[t.type]||t.type),t},t.prototype.normalizeWheelEvent=function(t){var e=this.rootWheelEvent;this.transferMouseData(e,t),e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ;var n=this.getViewportXY(t),r=n.x,i=n.y;e.viewport.x=r,e.viewport.y=i;var o=this.context.eventService.viewport2Canvas(e.viewport),a=o.x,s=o.y;return e.canvas.x=a,e.canvas.y=s,e.global.copyFrom(e.canvas),e.offset.copyFrom(e.canvas),e.nativeEvent=t,e.type=t.type,e},t.prototype.transferMouseData=function(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=da.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null},t.prototype.setCursor=function(t){this.context.contextService.applyCursorStyle(t||this.context.config.cursor||"default")},t.prototype.normalizeToPointerEvent=function(t,e){var n=[];if(e.isTouchEvent(t))for(var r=0;r<t.changedTouches.length;r++){var i=t.changedTouches[r];Qt(i.button)&&(i.button=0),Qt(i.buttons)&&(i.buttons=1),Qt(i.isPrimary)&&(i.isPrimary=1===t.touches.length&&"touchstart"===t.type),Qt(i.width)&&(i.width=i.radiusX||1),Qt(i.height)&&(i.height=i.radiusY||1),Qt(i.tiltX)&&(i.tiltX=0),Qt(i.tiltY)&&(i.tiltY=0),Qt(i.pointerType)&&(i.pointerType="touch"),Qt(i.pointerId)&&(i.pointerId=i.identifier||0),Qt(i.pressure)&&(i.pressure=i.force||.5),Qt(i.twist)&&(i.twist=0),Qt(i.tangentialPressure)&&(i.tangentialPressure=0),i.isNormalized=!0,i.type=t.type,n.push(i)}else if(e.isMouseEvent(t)){var o=t;Qt(o.isPrimary)&&(o.isPrimary=!0),Qt(o.width)&&(o.width=1),Qt(o.height)&&(o.height=1),Qt(o.tiltX)&&(o.tiltX=0),Qt(o.tiltY)&&(o.tiltY=0),Qt(o.pointerType)&&(o.pointerType="mouse"),Qt(o.pointerId)&&(o.pointerId=1),Qt(o.pressure)&&(o.pressure=.5),Qt(o.twist)&&(o.twist=0),Qt(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,n.push(o)}else n.push(t);return n},t.tag="Event",t}(),$s=[Yn.CIRCLE,Yn.ELLIPSE,Yn.IMAGE,Yn.RECT,Yn.LINE,Yn.POLYLINE,Yn.POLYGON,Yn.TEXT,Yn.PATH,Yn.HTML],qs=function(){function t(){}return t.prototype.isVisible=function(t,e){var n,r,i=e.cullable;if(!i.enable)return!0;var o=e.getRenderBounds();if(vr.isEmpty(o))return!1;var a=t.getFrustum(),s=null===(r=null===(n=e.parentNode)||void 0===n?void 0:n.cullable)||void 0===r?void 0:r.visibilityPlaneMask;return i.visibilityPlaneMask=this.computeVisibilityWithPlaneMask(e,o,s||mr.INDETERMINATE,a.planes),i.visible=i.visibilityPlaneMask!==mr.OUTSIDE,i.visible},t.prototype.computeVisibilityWithPlaneMask=function(t,e,n,r){if(n===mr.OUTSIDE||n===mr.INSIDE)return n;for(var i=mr.INSIDE,o=$s.indexOf(t.nodeName)>-1,a=0,s=r.length;a<s;++a){var c=1<<a;if(n&c&&(!o||4!==a&&5!==a)){var u=r[a],l=u.normal,h=u.distance;if(st(l,e.getPositiveFarPoint(r[a]))+h<0)return mr.OUTSIDE;st(l,e.getNegativeFarPoint(r[a]))+h<0&&(i|=c)}}return i},t}(),Ys=function(){function t(){this.toSync=new Set}return t.prototype.apply=function(e){var n=this,r=e.renderingService,i=e.renderingContext,o=e.rBushRoot,a=i.root.ownerDocument.defaultView;this.rBush=o;var s=function(t){t.target.renderable.dirty=!0,r.dirtify()},c=function(t){var e=t.detail.affectChildren,i=t.target;e&&i.forEach((function(t){n.toSync.add(t)}));for(var o=i;o;)o.renderable&&n.toSync.add(o),o=o.parentElement;r.dirtify()},u=function(t){var e=t.target;fs.enableSizeAttenuation&&fs.styleValueRegistry.updateSizeAttenuation(e,a.getCamera().getZoom()),fs.enableCSSParsing&&fs.styleValueRegistry.recalc(e),fs.sceneGraphService.dirtifyToRoot(e),r.dirtify()},l=function(t){var e=t.target,i=e.rBushNode;i.aabb&&n.rBush.remove(i.aabb),n.toSync.delete(e),fs.sceneGraphService.dirtifyToRoot(e),r.dirtify()};r.hooks.init.tap(t.tag,(function(){a.addEventListener(Za.MOUNTED,u),a.addEventListener(Za.UNMOUNTED,l),a.addEventListener(Za.ATTR_MODIFIED,s),a.addEventListener(Za.BOUNDS_CHANGED,c)})),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener(Za.MOUNTED,u),a.removeEventListener(Za.UNMOUNTED,l),a.removeEventListener(Za.ATTR_MODIFIED,s),a.removeEventListener(Za.BOUNDS_CHANGED,c),n.toSync.clear()})),r.hooks.endFrame.tap(t.tag,(function(){n.syncRTree()}))},t.prototype.syncRTree=function(){var t=this,e=[];Array.from(this.toSync).filter((function(t){return t.isConnected})).forEach((function(n){var r=n.rBushNode;r&&r.aabb&&t.rBush.remove(r.aabb);var i=n.getRenderBounds();if(i){var o=u(i.getMin(),2),a=o[0],s=o[1],c=u(i.getMax(),2),l=c[0],h=c[1];r.aabb||(r.aabb={}),r.aabb.displayObject=n,r.aabb.minX=a,r.aabb.minY=s,r.aabb.maxX=l,r.aabb.maxY=h}r.aabb&&(isNaN(r.aabb.maxX)||isNaN(r.aabb.maxX)||isNaN(r.aabb.minX)||isNaN(r.aabb.minY)||e.push(r.aabb))})),this.rBush.load(e),e.length=0,this.toSync.clear()},t.tag="Prepare",t}();!function(t){t.READY="ready",t.BEFORE_RENDER="beforerender",t.RERENDER="rerender",t.AFTER_RENDER="afterrender",t.BEFORE_DESTROY="beforedestroy",t.AFTER_DESTROY="afterdestroy",t.RESIZE="resize",t.DIRTY_RECTANGLE="dirtyrectangle",t.RENDERER_CHANGED="rendererchanged"}(ws||(ws={}));var Ks=new $a(Za.MOUNTED),Xs=new $a(Za.UNMOUNTED),Zs=new $a(ws.BEFORE_RENDER),Qs=new $a(ws.RERENDER),Js=new $a(ws.AFTER_RENDER),tc=function(t){function e(e){var n=t.call(this)||this;n.Element=ks,n.inited=!1,n.context={},n.document=new Ws,n.document.defaultView=n,n.customElements=new Vs;var r=e.container,i=e.canvas,o=e.offscreenCanvas,a=e.width,s=e.height,c=e.devicePixelRatio,u=e.renderer,l=e.background,h=e.cursor,d=e.document,f=e.requestAnimationFrame,p=e.cancelAnimationFrame,g=e.createImage,m=e.supportsPointerEvents,v=e.supportsTouchEvents,y=e.supportsCSSTransform,b=e.supportsMutipleCanvasesInOneContainer,x=e.useNativeClickEvent,E=e.alwaysTriggerPointerEventOnCanvas,w=e.isTouchEvent,M=e.isMouseEvent;b||function(t,e){if(t){var n="string"==typeof t?t:t.id||oa++;ia[n]&&ia[n].destroy(),ia[n]=e}}(r,n);var N=a,S=s,C=c;return i&&(C=(C=c||aa&&window.devicePixelRatio||1)>=1?Math.ceil(C):1,N=a||function(t){var e=la(t,"width");return"auto"===e?t.offsetWidth:parseFloat(e)}(i)||i.width/C,S=s||function(t){var e=la(t,"height");return"auto"===e?t.offsetHeight:parseFloat(e)}(i)||i.height/C),o&&(fs.offscreenCanvas=o),n.devicePixelRatio=C,n.requestAnimationFrame=null!=f?f:Ma.bind(fs.globalThis),n.cancelAnimationFrame=null!=p?p:Na.bind(fs.globalThis),n.supportsTouchEvents=null!=v?v:"ontouchstart"in fs.globalThis,n.supportsPointerEvents=null!=m?m:!!fs.globalThis.PointerEvent,n.isTouchEvent=null!=w?w:function(t){return n.supportsTouchEvents&&t instanceof fs.globalThis.TouchEvent},n.isMouseEvent=null!=M?M:function(t){return!fs.globalThis.MouseEvent||t instanceof fs.globalThis.MouseEvent&&(!n.supportsPointerEvents||!(t instanceof fs.globalThis.PointerEvent))},n.initRenderingContext({container:r,canvas:i,width:N,height:S,renderer:u,offscreenCanvas:o,devicePixelRatio:C,cursor:h||"default",background:l||"transparent",createImage:g,document:d,supportsCSSTransform:y,useNativeClickEvent:x,alwaysTriggerPointerEventOnCanvas:E}),n.initDefaultCamera(N,S,u.clipSpaceNearZ),n.initRenderer(u,!0),n}return r(e,t),e.prototype.initRenderingContext=function(t){this.context.config=t,this.context.renderingContext={root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set,force:!1,dirty:!1}},e.prototype.initDefaultCamera=function(t,e,n){var r=this,i=new fs.CameraContribution;i.clipSpaceNearZ=n,i.setType(br.EXPLORING,xr.DEFAULT).setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0).setOrthographic(t/-2,t/2,e/2,e/-2,.1,1e3),i.canvas=this,i.eventEmitter.on(_r,(function(){r.context.renderingContext.renderReasons.add(Ga.CAMERA_CHANGED),fs.enableSizeAttenuation&&r.getConfig().renderer.getConfig().enableSizeAttenuation&&r.updateSizeAttenuation()})),this.context.camera=i},e.prototype.updateSizeAttenuation=function(){var t=this.getCamera().getZoom();this.document.documentElement.forEach((function(e){fs.styleValueRegistry.updateSizeAttenuation(e,t)}))},e.prototype.getConfig=function(){return this.context.config},e.prototype.getRoot=function(){return this.document.documentElement},e.prototype.getCamera=function(){return this.context.camera},e.prototype.getContextService=function(){return this.context.contextService},e.prototype.getEventService=function(){return this.context.eventService},e.prototype.getRenderingService=function(){return this.context.renderingService},e.prototype.getRenderingContext=function(){return this.context.renderingContext},e.prototype.getStats=function(){return this.getRenderingService().getStats()},Object.defineProperty(e.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(this.readyPromise=new Promise((function(e){t.resolveReadyPromise=function(){e(t)}})),this.inited&&this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),e.prototype.destroy=function(t,e){(void 0===t&&(t=!0),void 0===e&&(e=!1),e||this.dispatchEvent(new $a(ws.BEFORE_DESTROY)),this.frameId)&&(this.getConfig().cancelAnimationFrame||cancelAnimationFrame)(this.frameId);var n=this.getRoot();this.unmountChildren(n),t&&(this.document.destroy(),this.getEventService().destroy()),this.getRenderingService().destroy(),this.getContextService().destroy(),t&&this.context.rBushRoot&&(this.context.rBushRoot.clear(),this.context.rBushRoot=null,this.context.renderingContext.root=null),e||this.dispatchEvent(new $a(ws.AFTER_DESTROY))},e.prototype.changeSize=function(t,e){this.resize(t,e)},e.prototype.resize=function(t,e){var n=this.context.config;n.width=t,n.height=e,this.getContextService().resize(t,e);var r=this.context.camera,i=r.getProjectionMode();r.setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0),i===Er.ORTHOGRAPHIC?r.setOrthographic(t/-2,t/2,e/2,e/-2,r.getNear(),r.getFar()):r.setAspect(t/e),this.dispatchEvent(new $a(ws.RESIZE,{width:t,height:e}))},e.prototype.appendChild=function(t,e){return this.document.documentElement.appendChild(t,e)},e.prototype.insertBefore=function(t,e){return this.document.documentElement.insertBefore(t,e)},e.prototype.removeChild=function(t){return this.document.documentElement.removeChild(t)},e.prototype.removeChildren=function(){this.document.documentElement.removeChildren()},e.prototype.destroyChildren=function(){this.document.documentElement.destroyChildren()},e.prototype.render=function(){var t=this;this.dispatchEvent(Zs),this.getRenderingService().render(this.getConfig(),(function(){t.dispatchEvent(Qs)})),this.dispatchEvent(Js)},e.prototype.run=function(){var t=this,e=function(){t.render(),t.frameId=t.requestAnimationFrame(e)};e()},e.prototype.initRenderer=function(t,e){var n=this;if(void 0===e&&(e=!1),!t)throw new Error("Renderer is required.");this.inited=!1,this.readyPromise=void 0,this.context.rBushRoot=new Xn,this.context.renderingPlugins=[],this.context.renderingPlugins.push(new Hs,new Ys,new Us([new qs])),this.loadRendererContainerModule(t),this.context.contextService=new this.context.ContextService(i(i({},fs),this.context)),this.context.renderingService=new Qa(fs,this.context),this.context.eventService=new Ka(fs,this.context),this.context.eventService.init(),this.context.contextService.init?(this.context.contextService.init(),this.initRenderingService(t,e,!0)):this.context.contextService.initAsync().then((function(){n.initRenderingService(t,e)}))},e.prototype.initRenderingService=function(t,e,n){var r=this;void 0===e&&(e=!1),void 0===n&&(n=!1),this.context.renderingService.init((function(){r.inited=!0,e?(n?r.requestAnimationFrame((function(){r.dispatchEvent(new $a(ws.READY))})):r.dispatchEvent(new $a(ws.READY)),r.readyPromise&&r.resolveReadyPromise()):r.dispatchEvent(new $a(ws.RENDERER_CHANGED)),e||r.getRoot().forEach((function(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0,e.dirty=!0)})),r.mountChildren(r.getRoot()),t.getConfig().enableAutoRendering&&r.run()}))},e.prototype.loadRendererContainerModule=function(t){var e=this;t.getPlugins().forEach((function(t){t.context=e.context,t.init(fs)}))},e.prototype.setRenderer=function(t){var e=this.getConfig();if(e.renderer!==t){var n=e.renderer;e.renderer=t,this.destroy(!1,!0),l([],u(null==n?void 0:n.getPlugins()),!1).reverse().forEach((function(t){t.destroy(fs)})),this.initRenderer(t)}},e.prototype.setCursor=function(t){this.getConfig().cursor=t,this.getContextService().applyCursorStyle(t)},e.prototype.unmountChildren=function(t){var e=this;t.childNodes.forEach((function(t){e.unmountChildren(t)})),this.inited&&(t.isMutationObserved?t.dispatchEvent(Xs):(Xs.target=t,this.dispatchEvent(Xs,!0)),t!==this.document.documentElement&&(t.ownerDocument=null),t.isConnected=!1),t.isCustomElement&&t.disconnectedCallback&&t.disconnectedCallback()},e.prototype.mountChildren=function(t){var e=this;this.inited?t.isConnected||(t.ownerDocument=this.document,t.isConnected=!0,t.isMutationObserved?t.dispatchEvent(Ks):(Ks.target=t,this.dispatchEvent(Ks,!0))):console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.","appended child: ",t.nodeName),t.childNodes.forEach((function(t){e.mountChildren(t)})),t.isCustomElement&&t.connectedCallback&&t.connectedCallback()},e.prototype.client2Viewport=function(t){return this.getEventService().client2Viewport(t)},e.prototype.viewport2Client=function(t){return this.getEventService().viewport2Client(t)},e.prototype.viewport2Canvas=function(t){return this.getEventService().viewport2Canvas(t)},e.prototype.canvas2Viewport=function(t){return this.getEventService().canvas2Viewport(t)},e.prototype.getPointByClient=function(t,e){return this.client2Viewport({x:t,y:e})},e.prototype.getClientByPoint=function(t,e){return this.viewport2Client({x:t,y:e})},e}(qa),ec=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.landmarks=[],e}return r(e,t),e.prototype.rotate=function(t,e,n){if(this.relElevation=rr(e),this.relAzimuth=rr(t),this.relRoll=rr(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===br.EXPLORING){var r=vt(mt(),[1,0,0],or((this.rotateWorld?1:-1)*this.relElevation)),i=vt(mt(),[0,1,0],or((this.rotateWorld?1:-1)*this.relAzimuth)),o=vt(mt(),[0,0,1],or(this.relRoll)),a=yt(mt(),i,r);a=yt(mt(),a,o);var s=F(x(),a);k(this.matrix,this.matrix,[0,0,-this.distance]),P(this.matrix,this.matrix,s),k(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===br.ORBITING||this.type===br.EXPLORING?this._getPosition():this.type===br.TRACKING&&this._getFocalPoint(),this._update(),this},e.prototype.pan=function(t,e){var n=ir(t,e,0),r=Q(this.position);return rt(r,r,ot(Z(),this.right,n[0])),rt(r,r,ot(Z(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this},e.prototype.dolly=function(t){var e=this.forward,n=Q(this.position),r=this.dollyingStep,i=this.distance+t*this.dollyingStep;return r=Math.max(Math.min(i,this.maxDistance),this.minDistance)-this.distance,n[0]+=r*e[0],n[1]+=r*e[1],n[2]+=r*e[2],this._setPosition(n),this.type===br.ORBITING||this.type===br.EXPLORING?this._getDistance():this.type===br.TRACKING&&rt(this.focalPoint,n,this.distanceVector),this.triggerUpdate(),this},e.prototype.cancelLandmarkAnimation=function(){void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID)},e.prototype.createLandmark=function(t,e){var n,r,i,o;void 0===e&&(e={});var a=e.position,s=void 0===a?this.position:a,c=e.focalPoint,u=void 0===c?this.focalPoint:c,l=e.roll,h=e.zoom,d=new fs.CameraContribution;d.setType(this.type,void 0),d.setPosition(s[0],null!==(n=s[1])&&void 0!==n?n:this.position[1],null!==(r=s[2])&&void 0!==r?r:this.position[2]),d.setFocalPoint(u[0],null!==(i=u[1])&&void 0!==i?i:this.focalPoint[1],null!==(o=u[2])&&void 0!==o?o:this.focalPoint[2]),d.setRoll(null!=l?l:this.roll),d.setZoom(null!=h?h:this.zoom);var f={name:t,matrix:E(d.getWorldTransform()),right:Q(d.right),up:Q(d.up),forward:Q(d.forward),position:Q(d.getPosition()),focalPoint:Q(d.getFocalPoint()),distanceVector:Q(d.getDistanceVector()),distance:d.getDistance(),dollyingStep:d.getDollyingStep(),azimuth:d.getAzimuth(),elevation:d.getElevation(),roll:d.getRoll(),relAzimuth:d.relAzimuth,relElevation:d.relElevation,relRoll:d.relRoll,zoom:d.getZoom()};return this.landmarks.push(f),f},e.prototype.gotoLandmark=function(t,e){var n=this;void 0===e&&(e={});var r=Bt(t)?this.landmarks.find((function(e){return e.name===t})):t;if(r){var i=Wt(e)?{duration:e}:e,o=i.easing,a=void 0===o?"linear":o,s=i.duration,c=void 0===s?100:s,u=i.easingFunction,l=void 0===u?void 0:u,h=i.onfinish,d=void 0===h?void 0:h,f=i.onframe,p=void 0===f?void 0:f;if(0===c)return this.syncFromLandmark(r),void(d&&d());this.cancelLandmarkAnimation();var g,m=r.position,v=r.focalPoint,y=r.zoom,b=r.roll,x=l||fs.EasingFunction(a),E=function(){n.setFocalPoint(v),n.setPosition(m),n.setRoll(b),n.setZoom(y),n.computeMatrix(),n.triggerUpdate(),d&&d()},w=function(t){void 0===g&&(g=t);var e=t-g;if(e>c)E();else{var r,i,o=x(e/c),a=Z(),s=Z();ut(a,n.focalPoint,v,o),ut(s,n.position,m,o),i=n.roll*(1-o)+b*o,r=n.zoom*(1-o)+y*o,n.setFocalPoint(a),n.setPosition(s),n.setRoll(i),n.setZoom(r),dt(a,v)+dt(s,m)<=.01&&null==y&&null==b?E():(n.computeMatrix(),n.triggerUpdate(),e<c&&(p&&p(o),n.landmarkAnimationID=n.canvas.requestAnimationFrame(w)))}};this.canvas.requestAnimationFrame(w)}},e.prototype.syncFromLandmark=function(t){this.matrix=w(this.matrix,t.matrix),this.right=et(this.right,t.right),this.up=et(this.up,t.up),this.forward=et(this.forward,t.forward),this.position=et(this.position,t.position),this.focalPoint=et(this.focalPoint,t.focalPoint),this.distanceVector=et(this.distanceVector,t.distanceVector),this.azimuth=t.azimuth,this.elevation=t.elevation,this.roll=t.roll,this.relAzimuth=t.relAzimuth,this.relElevation=t.relElevation,this.relRoll=t.relRoll,this.dollyingStep=t.dollyingStep,this.distance=t.distance,this.zoom=t.zoom},e}(Dr);fs.CameraContribution=ec;var nc=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return r(e,t),e}(Va),rc=0,ic=function(){function t(t,e){var n;this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=t,t.animation=this,this.timeline=e,this.id="".concat(rc++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(n=this.effect)||void 0===n?void 0:n.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}return Object.defineProperty(t.prototype,"pending",{get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playState",{get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"finished",{get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentTime",{get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){var e;t=Number(t),isNaN(t)||(this.timeline.restart(),this._paused||null===this._startTime||(this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate),this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startTime",{get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isFinished",{get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalDuration",{get:function(){return this._totalDuration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_needsTick",{get:function(){return this.pending||"running"===this.playState||!this._finishedFlag},enumerable:!1,configurable:!0}),t.prototype.updatePromises=function(){var t=this.oldPlayState,e=this.pending?"pending":this.playState;return this.readyPromise&&e!==t&&("idle"===e?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===t?this.resolveReadyPromise():"pending"===e&&(this.readyPromise=void 0)),this.finishedPromise&&e!==t&&("idle"===e?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===e?this.resolveFinishedPromise():"finished"===t&&(this.finishedPromise=void 0)),this.oldPlayState=e,this.readyPromise||this.finishedPromise},t.prototype.play=function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()},t.prototype.pause=function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()},t.prototype.finish=function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())},t.prototype.cancel=function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new nc(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}},t.prototype.reverse=function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()},t.prototype.updatePlaybackRate=function(t){this.playbackRate=t},t.prototype.targetAnimations=function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()},t.prototype.markTarget=function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)},t.prototype.unmarkTarget=function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)},t.prototype.tick=function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))},t.prototype.rewind=function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}},t.prototype.persist=function(){throw new Error(Sr)},t.prototype.addEventListener=function(t,e,n){throw new Error(Sr)},t.prototype.removeEventListener=function(t,e,n){throw new Error(Sr)},t.prototype.dispatchEvent=function(t){throw new Error(Sr)},t.prototype.commitStyles=function(){throw new Error(Sr)},t.prototype.ensureAlive=function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!!(null===(t=this.effect)||void 0===t?void 0:t.update(-1)):this._inEffect=!!(null===(e=this.effect)||void 0===e?void 0:e.update(this.currentTime)),this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))},t.prototype.tickCurrentTime=function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())},t.prototype.fireEvents=function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new nc(null,this,this.currentTime,t);setTimeout((function(){e.onfinish&&e.onfinish(n)}))}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new nc(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}},t}(),oc=.1,ac="function"==typeof Float32Array,sc=function(t,e){return 1-3*e+3*t},cc=function(t,e){return 3*e-6*t},uc=function(t){return 3*t},lc=function(t,e,n){return((sc(e,n)*t+cc(e,n))*t+uc(e))*t},hc=function(t,e,n){return 3*sc(e,n)*t*t+2*cc(e,n)*t+uc(e)},dc=function(t,e,n,r){if(!(0<=t&&t<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=ac?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=lc(o*oc,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=oc;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*oc,s=hc(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=hc(e,n,r);if(0===o)return e;e-=(lc(e,n,r)-t)/o}return e}(e,a,t,n):0===s?a:function(t,e,n,r,i){var o,a,s=0;do{(o=lc(a=e+(n-e)/2,r,i)-t)>0?n=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,r,r+oc,t,n)};return function(t){return 0===t||1===t?t:lc(a(t),e,r)}},fc=function(t){return Math.pow(t,2)},pc=function(t){return Math.pow(t,3)},gc=function(t){return Math.pow(t,4)},mc=function(t){return Math.pow(t,5)},vc=function(t){return Math.pow(t,6)},yc=function(t){return 1-Math.cos(t*Math.PI/2)},bc=function(t){return 1-Math.sqrt(1-t*t)},xc=function(t){return t*t*(3*t-2)},Ec=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},wc=function(t,e){void 0===e&&(e=[]);var n=u(e,2),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?.5:o,s=Vt(Number(i),1,10),c=Vt(Number(a),.1,2);return 0===t||1===t?t:-s*Math.pow(2,10*(t-1))*Math.sin((t-1-c/(2*Math.PI)*Math.asin(1/s))*(2*Math.PI)/c)},Mc=function(t,e,n){void 0===e&&(e=[]);var r=u(e,4),i=r[0],o=void 0===i?1:i,a=r[1],s=void 0===a?100:a,c=r[2],l=void 0===c?10:c,h=r[3],d=void 0===h?0:h;o=Vt(o,.1,1e3),s=Vt(s,.1,1e3),l=Vt(l,.1,1e3),d=Vt(d,.1,1e3);var f=Math.sqrt(s/o),p=l/(2*Math.sqrt(s*o)),g=p<1?f*Math.sqrt(1-p*p):0,m=p<1?(p*f-d)/g:-d+f,v=n?n*t/1e3:t;return v=p<1?Math.exp(-v*p*f)*(1*Math.cos(g*v)+m*Math.sin(g*v)):(1+m*v)*Math.exp(-v*f),0===t||1===t?t:1-v},Nc=function(t,e){void 0===e&&(e=[]);var n=u(e,2),r=n[0],i=void 0===r?10:r;return("start"==n[1]?Math.ceil:Math.floor)(Vt(t,0,1)*i)/i},Sc=function(t,e){void 0===e&&(e=[]);var n=u(e,4),r=n[0],i=n[1],o=n[2],a=n[3];return dc(r,i,o,a)(t)},Cc=dc(.42,0,1,1),Tc=function(t){return function(e,n,r){return void 0===n&&(n=[]),1-t(1-e,n,r)}},Pc=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},kc=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Ac={steps:Nc,"step-start":function(t){return Nc(t,[1,"start"])},"step-end":function(t){return Nc(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Sc,ease:function(t){return Sc(t,[.25,.1,.25,1])},in:Cc,out:Tc(Cc),"in-out":Pc(Cc),"out-in":kc(Cc),"in-quad":fc,"out-quad":Tc(fc),"in-out-quad":Pc(fc),"out-in-quad":kc(fc),"in-cubic":pc,"out-cubic":Tc(pc),"in-out-cubic":Pc(pc),"out-in-cubic":kc(pc),"in-quart":gc,"out-quart":Tc(gc),"in-out-quart":Pc(gc),"out-in-quart":kc(gc),"in-quint":mc,"out-quint":Tc(mc),"in-out-quint":Pc(mc),"out-in-quint":kc(mc),"in-expo":vc,"out-expo":Tc(vc),"in-out-expo":Pc(vc),"out-in-expo":kc(vc),"in-sine":yc,"out-sine":Tc(yc),"in-out-sine":Pc(yc),"out-in-sine":kc(yc),"in-circ":bc,"out-circ":Tc(bc),"in-out-circ":Pc(bc),"out-in-circ":kc(bc),"in-back":xc,"out-back":Tc(xc),"in-out-back":Pc(xc),"out-in-back":kc(xc),"in-bounce":Ec,"out-bounce":Tc(Ec),"in-out-bounce":Pc(Ec),"out-in-bounce":kc(Ec),"in-elastic":wc,"out-elastic":Tc(wc),"in-out-elastic":Pc(wc),"out-in-elastic":kc(wc),spring:Mc,"spring-in":Mc,"spring-out":Tc(Mc),"spring-in-out":Pc(Mc),"spring-out-in":kc(Mc)},Oc=function(t){return Ac[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,(function(t){return"-".concat(t.toLowerCase())}))).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Ac.linear},_c=function(t){return t},Rc=1,Dc=.5,Ic=0;function Lc(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var jc="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",zc=new RegExp("cubic-bezier\\("+jc+","+jc+","+jc+","+jc+"\\)"),Bc=/steps\(\s*(\d+)\s*\)/,Fc=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Gc(t){var e=zc.exec(t);if(e)return dc.apply(void 0,l([],u(e.slice(1).map(Number)),!1));var n=Bc.exec(t);if(n)return Lc(Number(n[1]),Ic);var r=Fc.exec(t);return r?Lc(Number(r[1]),{start:Rc,middle:Dc,end:Ic}[r[2]]):Oc(t)}function Vc(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}var Wc=0,Uc=1,Hc=2,$c=3;function qc(t,e,n){var r=function(t,e,n){if(null===e)return Wc;var r=n.endTime;return e<Math.min(n.delay,r)?Uc:e>=Math.min(n.delay+t+n.endDelay,r)?Hc:$c}(t,e,n),i=function(t,e,n,r,i){switch(r){case Uc:return"backwards"===e||"both"===e?0:null;case $c:return n-i;case Hc:return"forwards"===e||"both"===e?t:null;case Wc:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,a=function(t,e,n,r,i){var o=i;return 0===t?e!==Uc&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var a=t===1/0?e%1:t%1;return 0!==a||n!==Hc||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),c=function(t,e,n,r){return t===Hc&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),u=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,c,s);return n.currentIteration=c,n.progress=u,n.easingFunction(u)}function Yc(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Kc(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Gc(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,c=i[a].computedOffset,u=i[s].computedOffset,l=c,h=u;0===o&&(l=-1/0,0===u&&(s=a)),o===i.length-2&&(h=1/0,1===c&&(a=s)),n.push({applyFrom:l,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:Zc(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:n.easingFunction(r/i);t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Kc(n)&&t.setAttribute(n,null)}}function Kc(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Xc=function(t,e,n){return function(r){var i=Qc(t,e,r);return!fs.enableCSSParsing&&Wt(i)?i:n(i)}};function Zc(t,e,n,r){var i=Io[t];if(i&&i.syntax&&i.int){var o=fs.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=void 0,s=void 0;if(fs.enableCSSParsing){var c=fs.styleValueRegistry.parseProperty(t,e,r,!1),h=fs.styleValueRegistry.parseProperty(t,n,r,!1);a=fs.styleValueRegistry.computeProperty(t,c,r,!1),s=fs.styleValueRegistry.computeProperty(t,h,r,!1)}else{var d=o.parserWithCSSDisabled;a=d?d(e,r):e,s=d?d(n,r):n}var f=o.mixer(a,s,r);if(f){var p=Xc.apply(void 0,l([],u(f),!1));return function(t){return 0===t?e:1===t?n:p(t)}}}}return Xc(!1,!0,(function(t){return t?n:e}))}function Qc(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(Qc(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments "+t+":"+e)}var Jc=function(){function t(){this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=_c,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}return Object.defineProperty(t.prototype,"easing",{get:function(){return this._easing},set:function(t){this.easingFunction=Gc(t),this._easing=t},enumerable:!1,configurable:!0}),t}();function tu(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in(null==e?void 0:e.composite)&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n})),r=!0,i=-1/0,o=0;o<n.length;o++){var a=n[o].offset;if(kt(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=0&&Number(t.offset)<=1})),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),a=1;a<r;a++){var s=n[a].computedOffset;if(!kt(s)&&!kt(o)){for(var c=1;c<a-i;c++)n[i+c].computedOffset=o+(Number(s)-o)*c/(a-i);i=a,o=Number(s)}}}(),n}var eu="backwards|forwards|both|none".split("|"),nu="reverse|alternate|alternate-reverse".split("|");function ru(t,e){return function(t,e){var n=new Jc;return e&&(n.fill="both",n.duration="auto"),"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(e){if(void 0!==t[e]&&null!==t[e]&&"auto"!==t[e]){if(("number"==typeof n[e]||"duration"===e)&&("number"!=typeof t[e]||isNaN(t[e])))return;if("fill"===e&&-1===eu.indexOf(t[e]))return;if("direction"===e&&-1===nu.indexOf(t[e]))return;n[e]=t[e]}})):n.duration=t,n}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}),e)}var iu=function(){function t(t,e,n){var r=this;this.composite="replace",this.iterationComposite="replace",this.target=t,this.timing=ru(n,!1),this.timing.effect=this,this.timing.activeDuration=Vc(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=tu(e,this.timing),this.interpolations=Yc(this.normalizedKeyframes,this.timing,this.target);var i=fs.globalThis.Proxy;this.computedTiming=i?new i(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?r.animation&&r.animation.currentTime||null:"currentIteration"===e?r.animation&&"running"===r.animation.playState?t.currentIteration||0:null:"progress"===e?r.animation&&"running"===r.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}return t.prototype.applyInterpolations=function(){this.interpolations(this.target,Number(this.timeFraction))},t.prototype.update=function(t){return null!==t&&(this.timeFraction=qc(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)},t.prototype.getKeyframes=function(){return this.normalizedKeyframes},t.prototype.setKeyframes=function(t){this.normalizedKeyframes=tu(t)},t.prototype.getComputedTiming=function(){return this.computedTiming},t.prototype.getTiming=function(){return this.timing},t.prototype.updateTiming=function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))},t}();function ou(t,e){return Number(t.id)-Number(e.id)}var au=function(){function t(t){var e=this;this.document=t,this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){e.currentTime=t,e.discardAnimations(),0===e.animations.length?e.timelineTicking=!1:e.requestAnimationFrame(e.webAnimationsNextTick)},this.processRafCallbacks=function(t){var n=e.rafCallbacks;e.rafCallbacks=[],t<Number(e.currentTime)&&(t=Number(e.currentTime)),e.animations.sort(ou),e.animations=e.tick(t,!0,e.animations)[0],n.forEach((function(e){e[1](t)})),e.applyPendingEffects()}}return t.prototype.getAnimations=function(){return this.discardAnimations(),this.animations.slice()},t.prototype.isTicking=function(){return this.inTick},t.prototype.play=function(t,e,n){var r=new iu(t,e,n),i=new ic(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i},t.prototype.applyDirtiedAnimation=function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(ou),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}},t.prototype.restart=function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame},t.prototype.destroy=function(){this.document.defaultView.cancelAnimationFrame(this.frameId)},t.prototype.applyPendingEffects=function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]},t.prototype.updateAnimationsPromises=function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))},t.prototype.discardAnimations=function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))},t.prototype.restartWebAnimationsNextTick=function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))},t.prototype.rAF=function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e},t.prototype.requestAnimationFrame=function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))},t.prototype.tick=function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],c=[],h=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?c.push(n):h.push(n)})),(r=this.pendingEffects).push.apply(r,l([],u(a),!1)),(i=this.pendingEffects).push.apply(i,l([],u(s),!1)),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[c,h]},t}();fs.EasingFunction=Gc,fs.AnimationTimeline=au;const su={duration:500},cu={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var uu,lu,hu,du,fu,pu,gu;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(uu||(uu={})),function(t){t.DRAW="draw",t.TRANSFORM="transform"}(lu||(lu={})),t.CanvasEvent=void 0,function(t){t.CLICK="click",t.DBLCLICK="dblclick",t.POINTER_OVER="pointerover",t.POINTER_LEAVE="pointerleave",t.POINTER_ENTER="pointerenter",t.POINTER_MOVE="pointermove",t.POINTER_OUT="pointerout",t.POINTER_DOWN="pointerdown",t.POINTER_UP="pointerup",t.CONTEXT_MENU="contextmenu",t.DRAG_START="dragstart",t.DRAG="drag",t.DRAG_END="dragend",t.DRAG_ENTER="dragenter",t.DRAG_OVER="dragover",t.DRAG_LEAVE="dragleave",t.DROP="drop",t.WHEEL="wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.NodeEvent=void 0,(hu=t.NodeEvent||(t.NodeEvent={})).CLICK="click",hu.DBLCLICK="dblclick",hu.POINTER_OVER="pointerover",hu.POINTER_LEAVE="pointerleave",hu.POINTER_ENTER="pointerenter",hu.POINTER_MOVE="pointermove",hu.POINTER_OUT="pointerout",hu.POINTER_DOWN="pointerdown",hu.POINTER_UP="pointerup",hu.CONTEXT_MENU="contextmenu",hu.DRAG_START="dragstart",hu.DRAG="drag",hu.DRAG_END="dragend",hu.DRAG_ENTER="dragenter",hu.DRAG_OVER="dragover",hu.DRAG_LEAVE="dragleave",hu.DROP="drop",t.CommonEvent=void 0,(du=t.CommonEvent||(t.CommonEvent={})).CLICK="click",du.DBLCLICK="dblclick",du.POINTER_OVER="pointerover",du.POINTER_LEAVE="pointerleave",du.POINTER_ENTER="pointerenter",du.POINTER_MOVE="pointermove",du.POINTER_OUT="pointerout",du.POINTER_DOWN="pointerdown",du.POINTER_UP="pointerup",du.CONTEXT_MENU="contextmenu",du.DRAG_START="dragstart",du.DRAG="drag",du.DRAG_END="dragend",du.DRAG_ENTER="dragenter",du.DRAG_OVER="dragover",du.DRAG_LEAVE="dragleave",du.DROP="drop",du.KEY_DOWN="keydown",du.KEY_UP="keyup",du.WHEEL="wheel",t.ContainerEvent=void 0,(fu=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",fu.KEY_UP="keyup",t.EdgeEvent=void 0,(pu=t.EdgeEvent||(t.EdgeEvent={})).CLICK="click",pu.DBLCLICK="dblclick",pu.POINTER_OVER="pointerover",pu.POINTER_LEAVE="pointerleave",pu.POINTER_ENTER="pointerenter",pu.POINTER_MOVE="pointermove",pu.POINTER_OUT="pointerout",pu.POINTER_DOWN="pointerdown",pu.POINTER_UP="pointerup",pu.CONTEXT_MENU="contextmenu",pu.DRAG_ENTER="dragenter",pu.DRAG_OVER="dragover",pu.DRAG_LEAVE="dragleave",pu.DROP="drop",t.GraphEvent=void 0,(gu=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",gu.AFTER_CANVAS_INIT="aftercanvasinit",gu.BEFORE_SIZE_CHANGE="beforesizechange",gu.AFTER_SIZE_CHANGE="aftersizechange",gu.BEFORE_ELEMENT_CREATE="beforeelementcreate",gu.AFTER_ELEMENT_CREATE="afterelementcreate",gu.BEFORE_ELEMENT_UPDATE="beforeelementupdate",gu.AFTER_ELEMENT_UPDATE="afterelementupdate",gu.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",gu.AFTER_ELEMENT_DESTROY="afterelementdestroy",gu.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",gu.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",gu.BEFORE_DRAW="beforedraw",gu.AFTER_DRAW="afterdraw",gu.BEFORE_RENDER="beforerender",gu.AFTER_RENDER="afterrender",gu.BEFORE_ANIMATE="beforeanimate",gu.AFTER_ANIMATE="afteranimate",gu.BEFORE_LAYOUT="beforelayout",gu.AFTER_LAYOUT="afterlayout",gu.BEFORE_TRANSFORM="beforetransform",gu.AFTER_TRANSFORM="aftertransform",gu.BEFORE_ELEMENT_STATE_CHANGE="beforeelementstatechange",gu.AFTER_ELEMENT_STATE_CHANGE="afterelementstatechange",gu.BATCH_START="batchstart",gu.BATCH_END="batchend";const mu="combo",vu="tree";var yu;function bu(t){return"source"in t&&"target"in t}function xu(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Eu(t,e,n){return t>=e&&t<=n}function wu(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function Mu(t){return t.max[0]-t.min[0]}function Nu(t){return t.max[1]-t.min[1]}function Su(t){return[Mu(t),Nu(t)]}function Cu(t,e){const n=xu(t)?function(t){const[e,n,r=0]=t,i=new vr;return i.setMinMax([e,n,r],[e,n,r]),i}(t):t.getKey().getBounds();return e?Tu(n,e):n}function Tu(t,e){const[n,r,i,o]=wu(e),[a,s,c]=t.min,[u,l,h]=t.max,d=new vr;return d.setMinMax([a-o,s-n,c],[u+r,l+i,h]),d}function Pu(t){if(0===t.length)return new vr;if(1===t.length)return t[0];const e=new vr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function ku(t,e){return Eu(t[0],e.min[0],e.max[0])&&Eu(t[1],e.min[1],e.max[1])}function Au(t,e){const[n,r]=e,[i,o]=t.min,[a,s]=t.max,c=n-i,u=a-n,l=r-o,h=s-r,d=Math.min(c,u,l,h);return d===c?"left":d===u?"right":d===l?"top":d===h?"bottom":"left"}function Ou(t,e){const n=Jt(e);if(ku(e,t)){switch(Au(t,e)){case"left":n[0]=t.min[0];break;case"right":n[0]=t.max[0];break;case"top":n[1]=t.min[1];break;case"bottom":n[1]=t.max[1]}}else{const[r,i]=e,[o,a]=t.min,[s,c]=t.max;n[0]=Eu(r,o,s)?r:r<o?o:s,n[1]=Eu(i,a,c)?i:i<a?a:c}return n}function _u(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Ru(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}function Du(t,e="center"){const n=function(t){if(Array.isArray(t))return Eu(t[0],0,1)&&Eu(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}(e);return Ru(t,n)}function Iu(t,e){const n=function(t){const e="string"==typeof t?t.split(" ").map((t=>parseFloat(t))):t.slice(0,2);return Eu(e[0],0,1)&&Eu(e[1],0,1)?e:[.5,.5]}(e);return Ru(t,n)}function Lu(t=0){if(Wt(t))return Array(3).fill(t);const[e,n=e,r=e]=t;return[e,n,r]}function ju(t,e,n){if(Array.isArray(t))return t;const[r,i]=Lu(n),[o,a]=Lu(e),s=o/2/r,c=a/2/i;switch(t){case"top":return[.5,c];case"bottom":return[.5,1-c];case"left":return[s,.5];case"right":return[1-s,.5];case"top-left":case"left-top":return[s,c];case"top-right":case"right-top":return[1-s,c];case"bottom-left":case"left-bottom":return[s,1-c];case"bottom-right":case"right-bottom":return[1-s,1-c];default:return[.5,.5]}}function zu(t,e,n){if(Array.isArray(t))return t;const r=Lu(n)[0],i=r/2,o=Lu(e)[0]/2,a=o/r;switch(t){case"top":return[.5,a];case"bottom":return[.5,1-a];case"left":return[a,.5];case"right":return[1-a,.5]}const s=(i-o)*(Math.sqrt(2)/2)/r;switch(t){case"top-left":case"left-top":return[.5-s,.5-s];case"top-right":case"right-top":return[.5+s,.5-s];case"bottom-left":case"left-bottom":return[.5-s,.5+s];case"bottom-right":case"right-bottom":return[.5+s,.5+s];default:return[.5,.5]}}function Bu(t,e,n,r,i=ju){const o=i(t,n,r),[a,s]=Lu(r),c=new vr;return c.setMinMax([e[0]-a/2,e[1]-s/2,0],[e[0]+a/2,e[1]+s/2,0]),Iu(c,o)}function Fu(t){if(Bt(t.id)||Wt(t.id))return t.id;if(bu(t))return`${t.source}-${t.target}`;throw new Error("The data does not have available id.")}function Gu(t){return t.style?.parentId}function Vu(t,e){const n={nodes:(t.nodes||[]).map(Fu),edges:(t.edges||[]).map(Fu),combos:(t.combos||[]).map(Fu)};return e?Object.values(n).flat():n}function Wu(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Uu(t,e){return Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Wu(n,e)&&(t[function(t,e,n=!0){if(!e)return t;if(!Wu(t,e))return t;const r=t.slice(e.length);return n?Yt(r):r}(n,e)]=r),t)),{})}function Hu(t,e){const n=e.length;return Object.keys(t).reduce(((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r}),{})}function $u(t,e){const n=Bt(e)?[e]:e;return Object.entries(t).reduce(((t,[e,r])=>(n.find((t=>e.startsWith(t)))||(t[e]=r),t)),{})}t.ExtensionCategory=void 0,(yu=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",yu.EDGE="edge",yu.COMBO="combo",yu.THEME="theme",yu.PALETTE="palette",yu.LAYOUT="layout",yu.BEHAVIOR="behavior",yu.PLUGIN="plugin",yu.ANIMATION="animation",yu.TRANSFORM="transform";const qu=[0,0,0];function Yu(t,e){return t.map(((t,n)=>t+e[n]))}function Ku(t,e){return t.map(((t,n)=>t-e[n]))}function Xu(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Zu(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function Qu(t,e){return t.map((t=>t*e))}function Ju(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+(n-e[r]||0)**2),0))}function tl(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function el(t){const e=t.reduce(((t,e)=>t+e**2),0);return t.map((t=>t/Math.sqrt(e)))}function nl(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(Xu(t,e).reduce(((t,e)=>t+e),0)/(Ju(t,qu)*Ju(e,qu)));return n&&r<0&&(i=2*Math.PI-i),i}function rl(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function il(t){return[t[0],t[1]]}function ol(t){return 2===t.length?[t[0],t[1],0]:t}function al(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function sl(t){const e=Bt(t)?uz("palette",t):t;if(!Pt(e))return e}function cl(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=ol(t),r=ol(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(Ku(n,r),Ku(i,o)).every((t=>0===t))}function ul(t,e,n=!1){if(cl(t,e))return;const[r,i]=t,[o,a]=e,s=((r[0]-o[0])*(o[1]-a[1])-(r[1]-o[1])*(o[0]-a[0]))/((r[0]-i[0])*(o[1]-a[1])-(r[1]-i[1])*(o[0]-a[0])),c=a[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(a[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(a[1]-o[1]);return n||Eu(s,0,1)&&Eu(c,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function ll(t){return[t.x,t.y]}function hl(t){return{x:t[0],y:t[1]}}function dl(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function fl(t,e,n,r=!1){const i=el(r?Ku(t,e):Ku(e,t)),o=[i[0]*n,i[1]*n];return Yu(il(t),o)}function pl(t,e){return t[1]===e[1]}function gl(t,e,n){return cl([t,e],[e,n])}function ml(t,e,n,r=!0){for(let i=0;i<n.length;i++){let o=n[i],a=n[(i+1)%n.length];r&&(o=Yu(e,o),a=Yu(e,a));const s=ul([e,t],[o,a]);if(s)return{point:s,line:[o,a]}}return{point:e,line:void 0}}function vl(t,e){const[n,r]=t;let i=!1;const o=e.length;if(o<=2)return!1;const a=t=>Math.abs(t)<1e-6?0:t<0?-1:1;for(let s=0;s<o;s++){const c=e[s],u=e[(s+1)%o];if(gl(c,u,t))return!0;a(c[1]-r)>0!=a(u[1]-r)>0&&a(n-(r-c[1])*(c[0]-u[0])/(c[1]-u[1])-c[0])<0&&(i=!i)}return i}function yl(t,e){const n=e.center,r=Ku(t,e.center),i=Math.atan2(r[1],r[0]);if(isNaN(i))return n;const o=Mu(e)/2,a=Nu(e)/2;return[n[0]+o*Math.cos(i),n[1]+a*Math.sin(i)]}function bl(t,e){return Ju(t,xl(t,e))}function xl(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,c=i-n,u=o-r;if(0===c&&0===u)return[n,r];let l=((a-n)*c+(s-r)*u)/(c*c+u*u);l>1?l=1:l<0&&(l=0);return[n+l*c,r+l*u]}function El(t,e=!0){const n=function(t){return Zu(t.reduce(((t,e)=>Yu(t,e)),[0,0]),t.length)}(t);return t.sort((([t,r],[i,o])=>{const a=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-a:a-s}))}function wl(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function Ml(t,e,n=1,r=!1){const i=r?n:1;return wl((t.max[0]-t.min[0])*i,e)}const Nl="cachedStyle",Sl=t=>`__${t}__`;function Cl(t,e){const n=Array.isArray(e)?e:[e];se(t,Nl)||ce(t,Nl,{}),n.forEach((e=>{ce(se(t,Nl),Sl(e),t.attributes[e])}))}function Tl(t,e){return se(t,[Nl,Sl(e)])}function Pl(t,e){return Sl(e)in(se(t,Nl)||{})}function kl(t){const e=[],n=t=>{t.children&&t.children.length&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}const Al="visibility";class Ol extends Os{constructor(t){super(t),this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}shapeMap={};animateMap={};upsert(t,e,n,r){const i=this.shapeMap[t];if(!1!==n){if(!i){const i=new e({style:n});return i.id=t,r.appendChild(i),this.shapeMap[t]=i,i}return Vh(i,n),i}i&&(r.removeChild(i),delete this.shapeMap[t])}update(t={}){this.attr(re({},this.attributes,t)),this.render(this.attributes,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){const{x:e,y:n,z:r,className:i,transform:o,transformOrigin:a,context:s,zIndex:c,...u}=t;return u}animate(t,e){const n=[],r=super.animate(t,e);if(r&&n.push(r),Array.isArray(t)&&t.length>0){const r=["anchor","transform","transformOrigin","x","y","z","zIndex"];Object.keys(t[0]).some((t=>!r.includes(t)))&&Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${r[0].toUpperCase()}${r.slice(1)}Style`];if("function"==typeof o){const r=t.map((t=>o.call(this,{...this.attributes,...t}))),a=i.animate(Uh(r),e);a&&n.push(a)}}))}return Wh(n)}setVisibility(){const{visibility:t}=this.attributes;!function(t,e){[t,...kl(t)].forEach((n=>{Pl(n,Al)||Cl(n,Al);const r=Tl(n,Al);t!==n&&"hidden"===r||(n.style.visibility=e)}))}(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}class _l extends Ol{static defaultStyleProps={padding:0,fontSize:12,wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};constructor(t){super(re({},{style:_l.defaultStyleProps},t))}isTextStyle(t){return Wu(t,"label")}isBackgroundStyle(t){return Wu(t,"background")}getTextStyle(t){const{padding:e,...n}=this.getGraphicStyle(t);return $u(n,"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Uu(e,"background"),{min:[a,s],halfExtents:[c,u]}=this.shapeMap.text.getGeometryBounds(),[l,h,d,f]=wu(i);Object.assign(o,{x:a-f,y:s-l,width:n?Math.min(2*c,r):2*c+f+h,height:2*u+l+d});const{radius:p}=o;if("string"==typeof p&&p.endsWith("%")){const t=Number(p.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Gs,this.getTextStyle(t),e),this.upsert("background",Fs,this.getBackgroundStyle(t),e)}}class Rl extends Ol{static defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};constructor(t){super(re({},{style:Rl.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",_l,this.getBadgeStyle(t),e)}connectedCallback(){this.upsert("label",_l,this.getBadgeStyle(this.parsedAttributes),this)}}class Dl extends Ol{constructor(t){super(t)}isGImage(){return!!this.getAttribute("src")}getIconStyle(t=this.attributes){const e=this.getGraphicStyle(t);return this.isGImage()?{anchor:[.5,.5],...e}:{textBaseline:"middle",textAlign:"center",...e}}render(t=this.attributes,e=this){this.upsert("icon",this.isGImage()?Is:Gs,this.getIconStyle(t),e)}connectedCallback(){this.upsert("icon",this.isGImage()?Is:Gs,this.getIconStyle(this.attributes),this)}}class Il extends Ol{type="node";static defaultStyleProps={x:0,y:0,size:24,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};constructor(t){super(re({},{style:Il.defaultStyleProps},t))}get parsedAttributes(){return this.attributes}getSize(t=this.attributes){const{size:e}=t;return Lu(e)}getKeyStyle(t){const{color:e,fill:n,...r}=this.getGraphicStyle(t);return Object.assign({fill:e||n},$u(r,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||oe(t.labelText))return!1;const{placement:e,maxWidth:n,...r}=Uu(this.getGraphicStyle(t),"label"),i=this.getKey().getLocalBounds();return Object.assign(Gh(i,e),{wordWrapWidth:Ml(i,n)},r)}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,...n}=this.getKeyStyle(t);return{...n,stroke:e,...Uu(this.getGraphicStyle(t),"halo")}}getIconStyle(t){if(!1===t.icon||oe(t.iconText||t.iconSrc))return!1;const e=Uu(this.getGraphicStyle(t),"icon"),n=this.getKey(),[r,i]=Du(n.getLocalBounds(),"center");return{x:r,y:i,...e}}getBadgesStyle(t){const e=Hu(this.shapeMap,"badge-"),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.badge||oe(t.badges))return n;const{badges:r=[],badgePalette:i,...o}=t,a=sl(i),s=Uu(this.getGraphicStyle(o),"badge");return r.forEach(((t,e)=>{n[e]={backgroundFill:a?a[e%a?.length]:void 0,...s,...this.getBadgeStyle(t)}})),n}getBadgeStyle(t){const e=this.getKey(),{placement:n="top",...r}=t;return{...Gh(e.getLocalBounds(),n,!0),...r}}getPortsStyle(t){const e=this.getPorts(),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.port||oe(t.ports))return n;const r=Uu(this.getGraphicStyle(t),"port"),{ports:i=[]}=t;return i.forEach(((e,i)=>{const o=e.key||i,a={...r,...e};if(Dh(a))n[o]=!1;else{const[r,i]=this.getPortXY(t,e);n[o]={cx:r,cy:i,...a}}})),n}getPortXY(t,e){const{placement:n="left"}=e;return _h(this.getKey().getLocalBounds(),n)}getKey(){return this.shapeMap.key}getPorts(){return Hu(this.shapeMap,"port-")}getCenter(){return this.getKey().getBounds().center}getIntersectPoint(t){const e=this.getKey().getBounds();return ml(t,Du(n=e,"center"),[Du(n,"left-top"),Du(n,"right-top"),Du(n,"right-bottom"),Du(n,"left-bottom")],!1).point;var n}drawHaloShape(t,e){const n=this.getKey();this.upsert("halo",n.constructor,this.getHaloStyle(t),e)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{this.upsert(`badge-${t}`,Rl,n[t],e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{this.upsert(`port-${t}`,As,n[t],e)}))}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawHaloShape(t,e),this.upsert("icon",Dl,this.getIconStyle(t),e),this.drawBadgeShapes(t,e),this.upsert("label",_l,this.getLabelStyle(t),e),this.drawPortShapes(t,e))}onCreate(){}onUpdate(){}onDestroy(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawBadgeShapes(this.parsedAttributes,this)}),n}}const Ll=.8,jl=["node","edge","combo"];class zl extends Il{static defaultStyleProps={size:24};constructor(t){super(re({},{style:zl.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",As,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),r:Math.min(...this.getSize(t))/2}}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getKeyStyle(t),r=2*n*Ll;return!!e&&{width:r,height:r,...e}}getIntersectPoint(t){return yl(t,this.getKey().getBounds())}}class Bl extends Il{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",zs,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),points:this.getPoints(t)}}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return ml(t,[+(this.attributes?.x||0),+(this.attributes?.y||0)],e).point}}class Fl extends Bl{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return ml(t,[this.attributes.x,this.attributes.y],e).point}}class Gl extends zl{static defaultStyleProps={innerRadius:"50%",donuts:[],colors:"tableau"};constructor(t){super(re({},{style:Gl.defaultStyleProps},t))}drawDonutShape(t,e){const{donuts:n,innerRadius:r=0,size:i}=t;if(!n?.length)return;const o=n.map((t=>Wt(t)?{value:t}:t)),a=Uu(this.getGraphicStyle(t),"donut"),s=sl(t.colors);if(!s)return;const c=o.reduce(((t,e)=>t+(e.value??0)),0);let u=0;o.forEach(((t,n)=>{const{value:l=0,color:h=s[n%s.length],...d}=t,f=Lu(i)[0]/2,p=Bt(r)?f*parseInt(r)/100:r,g=360*(0===c?1/o.length:l/c);this.upsert(`round${n}`,js,{...a,path:Wl(f,p,u,u+g),fill:h,...d},e),u+=g}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}const Vl=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],Wl=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[a,s]=[i/360*2*Math.PI,o/360*2*Math.PI],c=[Vl(t,e,r,a),Vl(t,e,n,a),Vl(t,e,n,s),Vl(t,e,r,s)],u=s-a>Math.PI?1:0;return[["M",c[0][0],c[0][1]],["L",c[1][0],c[1][1]],["A",n,n,0,u,1,c[2][0],c[2][1]],["L",c[3][0],c[3][1]],["A",r,r,0,u,0,c[0][0],c[0][1]],["Z"]]})(i,o,t,e,n,r)};class Ul extends Il{static defaultStyleProps={size:[80,40]};constructor(t){super(re({},{style:Ul.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",_s,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return{...e,rx:n/2,ry:r/2}}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getKeyStyle(t),i=2*Math.min(+n,+r)*Ll;return!!e&&{width:i,height:i,...e}}getIntersectPoint(t){return yl(t,this.getKey().getBounds())}}class Hl extends Bl{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*Ll;return!!e&&{width:n,height:n,...e}}}class $l extends Il{static defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};constructor(t){super({...t,style:Object.assign({},$l.defaultStyleProps,t.style)})}rootPointerEvent=new Ua(null);get eventService(){return this.attributes.context.canvas.context.eventService}get events(){return[t.NodeEvent.CLICK,t.NodeEvent.POINTER_DOWN,t.NodeEvent.POINTER_MOVE,t.NodeEvent.POINTER_UP,t.NodeEvent.POINTER_OVER,t.NodeEvent.POINTER_LEAVE]}getDomElement(){return this.getKey().getDomElement()}getKeyStyle(t){const e=le(t,["innerHTML","pointerEvents","cursor"]),[n,r]=this.getSize(t);return{...e,width:n,height:r}}drawKeyShape(t,e){return this.upsert("key",Ds,this.getKeyStyle(t),e)}connectedCallback(){const t=this.getDomElement();this.events.forEach((e=>{t.addEventListener(e,this.forwardEvents)}))}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}onDestroy(){const t=this.getDomElement();this.events.forEach((e=>{t.removeEventListener(e,this.forwardEvents)}))}forwardEvents=t=>{const e=this.attributes.context.canvas.main,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach((r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);e.context.eventService.mapEvent(i)}))};normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];Qt(r.button)&&(r.button=0),Qt(r.buttons)&&(r.buttons=1),Qt(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),Qt(r.width)&&(r.width=r.radiusX||1),Qt(r.height)&&(r.height=r.radiusY||1),Qt(r.tiltX)&&(r.tiltX=0),Qt(r.tiltY)&&(r.tiltY=0),Qt(r.pointerType)&&(r.pointerType="touch"),Qt(r.pointerId)&&(r.pointerId=r.identifier||0),Qt(r.pressure)&&(r.pressure=r.force||.5),Qt(r.twist)&&(r.twist=0),Qt(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;Qt(e.isPrimary)&&(e.isPrimary=!0),Qt(e.width)&&(e.width=1),Qt(e.height)&&(e.height=1),Qt(e.tiltX)&&(e.tiltX=0),Qt(e.tiltY)&&(e.tiltY=0),Qt(e.pointerType)&&(e.pointerType="mouse"),Qt(e.pointerId)&&(e.pointerId=1),Qt(e.pressure)&&(e.pressure=.5),Qt(e.twist)&&(e.twist=0),Qt(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}bootstrapEvent(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const{x:a,y:s}=this.attributes.context.canvas.viewport2Canvas(t.viewport);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if(!this.attributes.context?.canvas.main.context.config.supportsCSSTransform||kt(r)||kt(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}}let ql=class t extends Il{static defaultStyleProps={size:50};constructor(e){super(re({},{style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t);return{...super.getKeyStyle(t),width:e,height:n,anchor:[.5,.5]}}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,stroke:n,...r}=this.getKeyStyle(t),i=Uu(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Yu(this.getSize(t),[o,o]);return{...r,...i,width:a,height:s,fill:"transparent"}}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&{width:n*Ll,height:r*Ll,...e}}drawKeyShape(t,e){return this.upsert("key",Is,this.getKeyStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Fs,this.getHaloStyle(t),e)}};class Yl extends Il{static defaultStyleProps={size:[48,24],anchor:[.5,.5]};constructor(t){super(re({},{style:Yl.defaultStyleProps},t))}getKeyStyle(t){const[e,n]=this.getSize(t);return{...super.getKeyStyle(t),width:e,height:n}}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getKeyStyle(t);return!!e&&{width:n*Ll,height:r*Ll,...e}}drawKeyShape(t,e){return this.upsert("key",Fs,this.getKeyStyle(t),e)}}class Kl extends Bl{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*Ll;return!!e&&{width:n,height:n,...e}}getPortXY(t,e){const{placement:n="top"}=e;return _h(this.getKey().getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}}class Xl extends Bl{static defaultStyleProps={size:40,direction:"up"};constructor(t){super(re({},{style:Xl.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getKey().getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return _h(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||oe(n||r))return!1;const o=Uu(this.getGraphicStyle(t),"icon"),a=this.getKey().getLocalBounds(),[s,c]=function(t,e){const{center:n}=t,[r,i]=Su(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),u=2*function(t,e){let[n,r]=Su(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(r**2-(Math.sqrt((n/2)**2+r**2)-n/2)**2)/(2*r)}(a,i)*Ll;return{x:s,y:c,width:u,height:u,...o}}}class Zl extends Il{type="combo";static defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedOrigin:[.5,.5],collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};constructor(t){super(re({},{style:Zl.defaultStyleProps},t))}calculatePosition(t){const{x:e=0,y:n=0,collapsed:r,childrenNode:i=[],childrenData:o=[]}=t;if(i.length<o.length){if(o.length>0&&r){return Zu(o.reduce(((t,e)=>Yu(t,_u(e))),[0,0,0]),o.length)}return[+e,+n,0]}return o.length?r?this.getCollapsedOriginPosition(t):this.getContentBBox(t).center:[+e,+n,0]}getCollapsedOriginPosition(t){return Bu(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t))}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=wu(e);return Yu(Lu(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Lu(t.collapsedSize)}getExpandedKeySize(t){if(!oe(t.size))return Lu(t.size);const e=this.getContentBBox(t);return[Mu(e),Nu(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=Pu(e.map((t=>t.getBounds())));return n?Tu(r,n):r}drawCollapsedMarkerShape(t,e){this.upsert("collapsed-marker",Dl,this.getCollapsedMarkerStyle(t),e)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const{type:e,...n}=Uu(this.getGraphicStyle(t),"collapsedMarker"),r=this.getKey(),[i,o]=Du(r.getLocalBounds(),"center"),a={...n,x:i,y:o};if(e){const n=this.getCollapsedMarkerText(e,t);Object.assign(a,{text:n})}return a}getCollapsedMarkerText(t,e){const{context:n,childrenData:r=[]}=e;if(!n)return"";const{model:i}=n;return"descendant-count"===t?i.getDescendantsData(this.id).length.toString():"child-count"===t?r.length.toString():"node-count"===t?i.getDescendantsData(this.id).filter((t=>"node"===i.getElementType(Fu(t)))).length.toString():Pt(t)?t(r):""}getComboZIndex(t){return(t.context?.model.getAncestorsData(this.id,mu)||[]).length}getComboStyle(t){const{zIndex:e=this.getComboZIndex(t)}=t,[n,r]=this.calculatePosition(t);return{x:n,y:r,zIndex:e}}render(t,e=this){super.render(t,e);const n=this.getComboStyle(t);Object.assign(this.style,n),t.context?.model.syncComboDatum({id:this.id,style:n}),this.drawCollapsedMarkerShape(t,e)}onCreate(){}onUpdate(){}onDestroy(){}}class Ql extends Zl{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",As,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),r=Uu(n,"collapsed"),[i]=this.getKeySize(t);return{...n,...e&&r,r:i/2}}getCollapsedKeySize(t){const[e,n]=Lu(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){if(!oe(t.size)){const[e,n]=Lu(t.size),r=Math.sqrt(e**2+n**2)/2;return[2*r,2*r,0]}const e=this.getContentBBox(t),[n,r]=Su(e),i=Math.sqrt(n**2+r**2)/2;return[2*i,2*i,0]}getCollapsedOriginPosition(t){return Bu(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t),zu)}}class Jl extends Zl{static defaultStyleProps={anchor:[.5,.5]};constructor(t){super(re({},{style:Jl.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Fs,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),n=Uu(e,"collapsed"),[r,i]=this.getKeySize(t);return{...e,...t.collapsed&&n,width:r,height:i}}}const th={N:"S",S:"N",W:"E",E:"W"},eh={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function nh(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function rh(t,e){return"N"===e||"S"===e?Nu(t):Mu(t)}function ih(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=nh(t,r),a=nh(t,i),s=n?th[n]:null,c=o===n||o!==s&&a!==n?r:i;return{points:[c],direction:nh(c,e)}}function oh(t,e,n){const r=uh(t,e,n);return{points:[r],direction:nh(r,e)}}function ah(t,e,n,r){const i=[[e[0],t[1]],[t[0],e[1]]],o=i.filter((t=>function(t,e){return!ku(t,e)}(t,n))),a=o.filter((e=>nh(e,t)!==r));if(a.length>0){const n=a.find((e=>nh(t,e)===r))||a[0];return{points:[n],direction:nh(n,e)}}{const a=fl(e,Tt(i,o)[0],rh(n,r)/2);return{points:[uh(a,t,n),a],direction:nh(a,e)}}}function sh(t,e,n,r){let i=oh(t,e,n);const o=ol(i.points[0]);if(ku(o,r)){i=oh(e,t,r);const a=ol(i.points[0]);if(ku(a,n)){const s=fl(t,a,rh(n,nh(t,a))/2),c=fl(e,o,rh(r,nh(e,o))/2),u=[(s[0]+c[0])/2,(s[1]+c[1])/2],l=oh(t,u,n),h=ah(u,e,r,l.direction);i.points=[l.points[0],h.points[0]],i.direction=h.direction}}return i}function ch(t,e,n,r,i){const o=.01,a=Pu([n,r]),s=Ju(e,a.center)>Ju(t,a.center),[c,u]=s?[e,t]:[t,e],l=Nu(a)+Mu(a);let h;if(i){const t=[c[0]+l*Math.cos(eh[i]),c[1]+l*Math.sin(eh[i])];h=fl(Ou(a,t),t,o)}else h=fl(Ou(a,c),c,-.01);let d=uh(h,u,a),f=[dl(h,2),dl(d,2)];if(ae(dl(h),dl(d))){const t=nl(Ku(h,c),[1,0,0])+Math.PI/2;d=[u[0]+l*Math.cos(t),u[1]+l*Math.sin(t),0],d=dl(fl(Ou(a,d),u,-.01),2);f=[h,uh(h,d,a),d]}return{points:s?f.reverse():f,direction:nh(s?h:d,e)}}function uh(t,e,n){let r=[t[0],e[1]];return ku(r,n)&&(r=[e[0],t[1]]),r}function lh(t,e,n,r,i){const[o,a]=ll(t.getPoint(e));let s=n,c=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),c=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+c]}function hh(t,e,n,r){if(ae(t,e))return t;const i=Ku(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=el(rl(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function dh(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function fh(t,e=0,n=!1){const r=t[0],i=t[t.length-1],o=t.slice(1,t.length-1),a=[["M",r[0],r[1]]];return o.forEach(((t,n)=>{const s=o[n-1]||r,c=o[n+1]||i;if(!gl(s,t,c)&&e){const[n,r]=function(t,e,n,r){const i=tl(t,e),o=tl(n,e),a=Math.min(r,Math.min(i,o)/2),s=[e[0]-a/i*(e[0]-t[0]),e[1]-a/i*(e[1]-t[1])],c=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,c]}(s,t,c,e);a.push(["L",n[0],n[1]],["Q",t[0],t[1],r[0],r[1]],["L",r[0],r[1]])}else a.push(["L",t[0],t[1]])})),a.push(["L",i[0],i[1]]),n&&a.push(["Z"]),a}const ph=t=>{const e=Math.PI/2,n=Nu(t)/2,r=Mu(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}};function gh(t,e,n,r,i){const o=Cu(t),a=t.getCenter();let s=r&&Ih(r),c=i&&Ih(i);if(!s||!c){const r=ph(o),i=r[e][0],u=r[e][1],[l,h]=Su(o),d=Math.max(l,h),f=Yu(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Yu(a,[d*Math.cos(u),d*Math.sin(u),0]);s=Fh(t,f),c=Fh(t,p),n||([s,c]=[c,s])}return[s,c]}function mh(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[c,u]=gh(t,e,n,a,s);const l=function(t,e,n,r){const i=t.getCenter();if(ae(e,n)){const t=Ku(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Yu(e,o),Yu(n,Xu(o,[1,-1,1]))]}return[fl(i,e,Ju(i,e)+r),fl(i,n,Ju(i,n)+r)]}(t,c,u,r);return a&&(c=Bh(a,l[0])),s&&(u=Bh(s,l[l.length-1])),dh(c,u,l)}function vh(t,e,n,r,i,o,a){const s=Rh(t),c=s[o||a],u=s[a||o];let[l,h]=gh(t,n,r,c,u);const d=function(t,e,n,r){const i=[],o=Cu(t);if(ae(e,n)){switch(Au(o,e)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=Au(o,e),a=Au(o,n);if(t===a){let o,a;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":a=Math.min(e[1],n[1])-r,i.push([e[0],a]),i.push([n[0],a]);break;case"bottom":a=Math.max(e[1],n[1])+r,i.push([e[0],a]),i.push([n[0],a])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),c=s(t,e),u=s(a,n),l=uh(c,u,o);i.push(c,l,u)}}return i}(t,l,h,i);return c&&(l=Bh(c,d[0])),u&&(h=Bh(u,d[d.length-1])),fh([l,...d,h],e)}function yh(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach((o=>{e(o).forEach((e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)}))})),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}const bh=(t,e)=>[["M",0,0],["L",t,-e/2],["L",t,e/2],["Z"]];var xh=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",0,0],["A",n,n,0,1,0,2*n,0],["A",n,n,0,1,0,0,0],["Z"]]},diamond:(t,e)=>[["M",0,0],["L",t/2,-e/2],["L",t,0],["L",t/2,e/2],["Z"]],rect:(t,e)=>[["M",0,-e/2],["L",t,-e/2],["L",t,e/2],["L",0,e/2],["Z"]],simple:(t,e)=>[["M",t,-e/2],["L",0,0],["L",t,e/2]],triangle:bh,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",0,0],["L",n,-e/2],["L",n,e/2],["Z"],["M",i,-e/2],["L",i+r,-e/2],["L",i+r,e/2],["L",i,e/2],["Z"]]},vee:(t,e)=>[["M",0,0],["L",t,-e/2],["L",2*t/3,0],["L",t,e/2],["Z"]]});class Eh extends Ol{type="edge";static defaultStyleProps={isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,startArrow:!1,startArrowAnchor:"0.5 0.5",startArrowSize:8,startArrowLineDash:0,startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"triangle",endArrow:!1,endArrowAnchor:"0.5 0.5",endArrowSize:8,endArrowLineDash:0,endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"triangle",loopPlacement:"top",loopClockwise:!0};constructor(t){super(re({},{style:Eh.defaultStyleProps},t))}getKeyStyle(t){const{sourceNode:e,targetNode:n,color:r,stroke:i,...o}=this.getGraphicStyle(t);var a,s;return{path:(s=n,(a=e)&&s&&a===s?this.getLoopPath(t):this.getKeyPath(t)),...$u(o,["halo","label","startArrow","endArrow"]),stroke:r||i}}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r}=t,i=Cu(e),o=Math.max(Mu(i),Nu(i)),{placement:a,clockwise:s,dist:c=o}=Uu(this.getGraphicStyle(t),"loop");return mh(e,a,s,c,n,r)}getEndpoints(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=Lh(e,n,r,i);return[zh(o||e,a||n),zh(a||n,o||e)]}getHaloStyle(t){if(!1===t.halo)return!1;return{...this.getKeyStyle(t),...Uu(this.getGraphicStyle(t),"halo")}}getLabelStyle(t){if(!1===t.label||oe(t.labelText))return!1;const e=Uu(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a,...s}=e,c=function(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=ll(t.getPoint(o)),s=ll(t.getPoint(o+.01));let c="start"===e?"left":"end"===e?"right":"center";if(pl(a,s)||!n){const[e,n]=lh(t,o,r,i);return{x:e,y:n,textAlign:c}}let u=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(c="center"===c?c:"left"===c?"right":"left",r*=-1,u+=Math.PI);const[l,h]=lh(t,o,r,i,u);return{x:l,y:h,textAlign:c,transform:`rotate(${u/Math.PI*180}deg)`}}(this.shapeMap.key,n,o,r,i),u=this.shapeMap.key.getLocalBounds(),l=function(t,e,n=1){return wl(Ju(t[0],t[1])*n,e)}([u.min,u.max],a);return Object.assign({wordWrapWidth:l},c,s)}drawArrow(t,e){const n="start"===e,r=t["start"===e?"startArrow":"endArrow"],i=this.shapeMap.key;if(r){const e=this.getArrowStyle(t,n),r=oe(e.src)?js:Is,[o,a,s]=n?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],c=i.style[o];c?c.attr(e):i.style[o]=new r({style:e}),i.style[a]=t[s]||e.width/2+ +e.lineWidth}else{const t=n?"markerStart":"markerEnd";i.style[t]?.destroy(),i.style[t]=null}}getArrowStyle(t,e){const n=this.getKeyStyle(t),r=e?"startArrow":"endArrow",{size:i,type:o,...a}=Uu(this.getGraphicStyle(t),r),[s,c]=Lu(i),u=(Pt(o)?o:xh[o]||bh)(s,c);return{...n,width:s,height:c,...u&&{path:u,fill:"simple"===o?"":n.stroke},...a}}drawLabelShape(t,e){this.upsert("label",_l,this.getLabelStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",js,this.getHaloStyle(t),e)}drawKeyShape(t,e){return this.upsert("key",js,this.getKeyStyle(t),e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawArrow(t,"start"),this.drawArrow(t,"end"),this.drawLabelShape(t,e),this.drawHaloShape(t,e))}onCreate(){}onUpdate(){}onDestroy(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawLabelShape(this.parsedAttributes,this)}),n}}class wh extends Eh{static defaultStyleProps={curvePosition:.5,curveOffset:20};constructor(t){super(re({},{style:wh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,a=this.getControlPoints(e,n,function(t){return Wt(t)?[t,1-t]:t}(i),function(t){return Wt(t)?[t,-t]:t}(o),r);return dh(e,n,a)}getControlPoints(t,e,n,r,i){return 2===i?.length?i:[hh(t,e,n[0],r[0]),hh(t,e,n[1],r[1])]}}class Mh extends wh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(re({},{style:Mh.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}class Nh extends wh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(re({},{style:Nh.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}class Sh extends Eh{static defaultStyleProps={};constructor(t){super(re({},{style:Sh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}}class Ch extends Eh{static defaultStyleProps={radius:0,controlPoints:[],router:!1,routerName:"orth",routerPadding:10};constructor(t){super(re({},{style:Ch.defaultStyleProps},t))}getKeyPath(t){const{sourceNode:e,targetNode:n,radius:r}=t,{sourcePoint:i,targetPoint:o,sourcePort:a,targetPort:s}=this.getEndpointsAndPorts(t),c=this.getControlPoints(t,i,o),u=zh(a||e,c[0]||s||n),l=zh(s||n,c[c.length-1]||a||e);return fh([u,...c,l],r)}getEndpointsAndPorts(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=Lh(e,n,r,i);return{sourcePoint:o?Ih(o):e.getCenter(),targetPoint:a?Ih(a):n.getCenter(),sourcePort:o,targetPort:a}}getControlPoints(t,e,n){const{controlPoints:r,sourceNode:i,targetNode:o,router:a,routerPadding:s}=t;if(!a)return[...r];return function(t,e,n,r,i,o){const a=[t,...i,e];let s=null;const c=[];for(let t=0,e=a.length;t<e-1;t++){const i=t+1,h=a[t],d=a[i],f=pl(u=h,l=d)||function(t,e){return t[0]===e[0]}(u,l);let p=null;0===t?i===e-1?n.intersects(r)?p=ch(h,d,n,r):f||(p=sh(h,d,n,r)):ku(d,n)?p=ch(h,d,n,Cu(d,o),s):f||(p=oh(h,d,n)):i===e-1?ku(h,r)?p=ch(h,d,Cu(h,o),r,s):f||(p=ah(h,d,r,s)):f||(p=ih(h,d,s)),p?(c.push(...p.points),s=p.direction):s=nh(h,d),i<e-1&&c.push(d)}var u,l;return c}(e,n,Cu(i,s),Cu(o,s),r,s)}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r,radius:i}=t,o=Cu(e),a=Math.max(Mu(o),Nu(o))/4,{placement:s,clockwise:c,dist:u=a}=Uu(this.getGraphicStyle(t),"loop");return vh(e,i,s,c,u,n,r)}}class Th extends Eh{static defaultStyleProps={curvePosition:.5,curveOffset:30};constructor(t){super(re({},{style:Th.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||hh(r,i,e,n))}}function Ph(t){return t instanceof Il&&"node"===t.type}function kh(t){return t instanceof Eh}function Ah(t){return t instanceof Zl}const Oh={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function _h(t,e,n=Oh,r=!0){const i=[.5,.5],o=Bt(e)?se(n,e.toLocaleLowerCase(),i):e;if(!r&&Bt(e))return o;const[a,s]=o||i;return[t.min[0]+Mu(t)*a,t.min[1]+Nu(t)*s]}function Rh(t){const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{const{key:i,placement:o}=n;Dh(n)&&(e[i||r]||=Du(t.getKey().getBounds(),o))})),e}function Dh(t){const{r:e}=t;return!e||0===Number(e)}function Ih(t){return xu(t)?t:t.getPosition()}function Lh(t,e,n,r){return[jh(t,e,n,r),jh(e,t,r,n)]}function jh(t,e,n,r){const i=Rh(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Ih(t))),s=function(t,e){const n=Rh(t);if(e)return[Ih(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Ih(t))):[t.getCenter()]}(e,r),[c]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Ju(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Ih(t)===c))}function zh(t,e){return Ph(t)?Fh(t,e):Bh(t,e)}function Bh(t,e){if(xu(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return yl(xu(e)?e:Ph(e)?e.getCenter():e.getPosition(),t.getBounds())}function Fh(t,e){const n=xu(e)?e:Ph(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Gh(t,e="bottom",n=!1){const r=e.split("-"),[i,o]=Du(t,e),a=r.includes("left")?"right":r.includes("right")?"left":"center";let s=r.includes("top")?"bottom":r.includes("bottom")?"top":"middle";return n&&(s="top"===s?"bottom":"bottom"===s?"top":s),{x:i,y:o,textBaseline:s,textAlign:a}}function Vh(t,e){"update"in t?t.update(e):t.attr(e)}function Wh(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map((t=>t.finished))]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach((t=>t[e]?.(...n)))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function Uh(t){const e=t.reduce(((t,e)=>(Object.entries(e).forEach((([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)})),t)),{});return Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>kt(t)))||r.every((t=>!Ph(t)&&ae(t,r[0]))))&&delete e[n]})),Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[])}function Hh(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function $h(t,e){return e.before?.(),t?(e.beforeAnimate?.(t),t.finished.then((()=>{e.afterAnimate?.(t),e.after?.()}))):e.after?.(),t||null}function qh(t,e){const{animation:n}=t;if(!n||!1===e)return!1;const r={...su};return Rt(n)&&Object.assign(r,n),Rt(e)&&Object.assign(r,e),r}const Yh=(t,e,n,r)=>{if(!e)return null;const{animationsFilter:i=(()=>!0)}=r,o=(Bt(e)?uz("animation",e)||[]:e).filter(i);if(0===o.length)return null;const{originalStyle:a,modifiedStyle:s,states:c}=r,u=e=>{if(e){const n=t.getElementById(e),r=`get${function(t){var e=qt(t);return e.charAt(0).toUpperCase()+e.substring(1)}(e)}Style`,i=t?.[r]?.bind(t)||(t=>t);return{shape:n,fromStyle:i?.({...t.attributes,...a})||{},toStyle:{...n.attributes}}}return{shape:t,fromStyle:a,toStyle:{...t.attributes,...s}}};let l;const h=o.map((({fields:t,shape:e,states:r,...i})=>{if(void 0===r||r?.some((t=>c.includes(t)))){const{shape:r,fromStyle:o,toStyle:a}=u(e);if(!r)return null;const s=[{},{}];t.forEach((t=>{Object.assign(s[0],{[t]:o[t]??Hh(t)}),Object.assign(s[1],{[t]:a[t]??Hh(t)})}));const c=function(t,e,n){if(0===e.length)return null;const r=["opacity"],i=e.some((t=>Object.keys(t).some((t=>r.includes(t)))));if(!i)return t.animate(e,n);const o=e.map((t=>{const e={};return Object.entries(t).forEach((([t,n])=>{r.includes(t)&&(e[t]=n)})),e})),a=kl(t);return Wh(t.animate(e,n),a.map((t=>t.animate(o,n))))}(r,Uh(s),{...cu,...n,...i});return void 0===e&&(l=c),c}return null})).filter(Boolean),d=l||h?.[0];return d?Wh(d,h.filter((t=>t!==d))):null};function Kh(t,e,n){const r=new Map(t.map((t=>[n(t),t]))),i=new Map(e.map((t=>[n(t),t]))),o=new Set(r.keys()),a=new Set(i.keys()),s=[],c=[],u=[],l=[];return a.forEach((t=>{o.has(t)?ae(r.get(t),i.get(t))?l.push(i.get(t)):c.push(i.get(t)):s.push(i.get(t))})),o.forEach((t=>{a.has(t)||u.push(r.get(t))})),{enter:s,exit:u,keep:l,update:c}}class Xh{context;extensions=[];extensionMap={};constructor(t){this.context=t}setExtensions(t){const e=function(t,e){const n={},r=e=>(e in n||(n[e]=0),`${t}-${e}-${n[e]++}`);return e.map((t=>"string"==typeof t?{type:t,key:r(t)}:t.key?t:{...t,key:r(t.type)}))}(this.category,t),{enter:n,update:r,exit:i,keep:o}=Kh(this.extensions,e,(t=>t.key));this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=uz(e,r);if(!i)return;const o=new i(this.context,t);this.extensionMap[n]=o}createExtensions(t){t.forEach((t=>this.createExtension(t)))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach((t=>this.updateExtension(t)))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),this.context={},this.extensions=[],this.extensionMap={}}}class Zh{context;options;events=[];destroyed=!1;constructor(t,e){this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class Qh extends Zh{}function Jh(t,e,n){const r=t.getElementRenderBounds(e);return!!r&&vl(r.center,n)}function td(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}const ed=(t,e)=>{const n={},r=t.getData();return Object.values(r).forEach((r=>{r.map((r=>{const i=t.getElementState(r.id);n[r.id]=Pt(e)?e(r.id,i):i}))})),n},nd=t=>t.map((t=>Bt(t)?t.toLocaleLowerCase():t));class rd{map=new Map;emitter;recordKey=new Set;constructor(t){this.emitter=t,this.bindEvents()}bind(t,e){0!==t.length&&this.map.set(t,e)}unbind(t,e){this.map.forEach(((n,r)=>{ae(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=nd(Array.from(this.recordKey)).sort(),n=nd(t).sort();return ae(e,n)}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),e.on(t.CommonEvent.KEY_UP,this.onKeyUp),e.on(t.CommonEvent.WHEEL,this.onWheel),e.on(t.CommonEvent.DRAG,this.onDrag)}onKeyDown=t=>{t?.key&&(this.recordKey.add(t.key),this.trigger(t))};onKeyUp=t=>{t?.key&&this.recordKey.delete(t.key)};trigger(t){this.map.forEach(((e,n)=>{this.match(n)&&e(t)}))}triggerExtendKey(t,e){this.map.forEach(((n,r)=>{r.includes(t)&&ae(Array.from(this.recordKey),r.filter((e=>e!==t)))&&n(e)}))}onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)};onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)};destroy(){this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag)}}const id={lineWidth:1,color:"#EEF6FF",stroke:"#DDEEFE",fillOpacity:.4,zIndex:2};class od extends Qh{static defaultOptions={enable:!0,trigger:["drag"],immediately:!1,state:"selected",mode:"default",animation:!1,enableElements:["node","combo","edge"],style:{size:0,type:"rect",...id,pointerEvents:"none"}};startPoint;endPoint;rectShape;shortcut;selectElementFn=Jh;constructor(t,e){super(t,Object.assign({},od.defaultOptions,e)),this.shortcut=new rd(t.graph),"lasso-select"!==e.type&&this.bindEvents()}pointerDown=async t=>{if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{style:e,trigger:n}=this.options,r=Array.isArray(n)?n:[n];if("canvas"!==t.targetType&&r.includes("drag"))return;const{canvas:i}=this.context;this.rectShape=new Fs({id:"g6-brush-select-rect-id",style:{...od.defaultOptions.style,fill:e.color||id.color,...e,pointerEvents:"none"}}),i.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]};pointerMove=async t=>{if(!this.startPoint)return;const{immediately:e,mode:n}=this.options;this.endPoint=[t.canvas.x,t.canvas.y],this.rectShape?.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),e&&"default"===n&&this.updateElementState(td(this.startPoint,this.endPoint))};pointerUp=async t=>{if(!this.startPoint)return;if(!this.endPoint)return void await this.clearBrush();const e=td(this.startPoint,[t.canvas.x,t.canvas.y]);this.updateElementState(e),await this.clearBrush()};clearSelected=()=>{if(this.endPoint)return;const{graph:t}=this.context,e=ed(t,(()=>[]));t.setElementState(e,this.options.animation)};updateElementState=t=>{const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,a=this.getPointsSelectIds(e,t,n);let s=(t,e)=>a.includes(t)?[r]:[];switch(i){case"union":s=(t,e)=>a.includes(t)?[r]:e;break;case"diff":s=(t,e)=>a.includes(t)?e.includes(r)?[]:[r]:e;break;case"intersect":s=(t,e)=>a.includes(t)?e.includes(r)?[r]:[]:e}let c=ed(e,s);n.includes("edge")&&((t,e,n)=>{t.getEdgeData().forEach((({id:t,target:r,source:i})=>{t&&(e[r].includes(n)&&e[i].includes(n)?e[t]=[n]:e[t]=[])}))})(e,c,r),Pt(o)&&(c=o(c)),e.setElementState(c,this.options.animation)};clearBrush=async()=>{this.rectShape?.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0};getPointsSelectIds=(t,e,n)=>{const r=[],i=[];return n.includes("node")&&t.getNodeData().forEach((n=>{const{id:i}=n;"hidden"!==t.getElementVisibility(i)&&this.selectElementFn(t,i,e)&&r.push(i)})),n.includes("combo")&&t.getComboData().forEach((n=>{const{id:r}=n;"hidden"!==t.getElementVisibility(r)&&this.selectElementFn(t,r,e)&&i.push(r)})),[...r,...i]};isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return!(0!==e.length&&!e.includes("drag"))||this.shortcut?.match(e)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),e.on(t.CommonEvent.POINTER_DOWN,this.pointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.pointerMove),e.on(t.CommonEvent.POINTER_UP,this.pointerUp),e.on(`canvas:${t.CommonEvent.CLICK}`,this.clearSelected)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.pointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.pointerMove),e.off(t.CommonEvent.POINTER_UP,this.pointerUp),e.off(`canvas:${t.CommonEvent.CLICK}`,this.clearSelected)}destroy(){this.unbindEvents(),super.destroy()}}function ad(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)ad(t,e,n,r,i+1);"BT"===r&&e(t,i)}function sd(t,e,n,r){if("combo"===e||"node"===e)return cd(t,n,r);const i=t.getEdgeData(n);if(!i)return[];const o=cd(t,i.source,r-1),a=cd(t,i.target,r-1);return Array.from(new Set([...o,...a,n]))}function cd(t,e,n){const r=new Set,i=new Set,o=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,((e,r)=>{r>n||(o.add(e),t.getRelatedEdgesData(e).forEach((t=>{const e=Fu(t);!i.has(e)&&r<n&&(o.add(e),i.add(e))})))}),(e=>t.getRelatedEdgesData(e).map((t=>t.source===e?t.target:t.source)).filter((t=>!r.has(t)&&(r.add(t),!0))))),Array.from(o)}class ud extends Qh{selectedElementIds=[];shortcut;static defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],selectedState:"selected",unselectedState:void 0,degree:0};constructor(t,e){super(t,Object.assign({},ud.defaultOptions,e)),this.shortcut=new rd(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),jl.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickElement)})),e.on(`canvas:${t.CommonEvent.CLICK}`,this.onClickCanvas)}onClickElement=t=>{this.validate(t)&&(this.updateElementsState(t,!1),this.updateElementsState(t,!0))};onClickCanvas=t=>{this.validate(t)&&(this.updateElementsState(t,!1),this.selectedElementIds=[])};updateElementsState=(t,e)=>{if(!this.options.selectedState&&!this.options.unselectedState)return;const{graph:n}=this.context,{targetType:r,target:i}=t;if(e)if(this.selectedElementIds.includes(i.id))this.selectedElementIds=this.selectedElementIds.filter((t=>t!==i.id));else{const t=sd(n,r,i.id,this.options.degree);this.options.multiple&&this.shortcut.match(this.options.trigger)?this.selectedElementIds.push(...t):this.selectedElementIds=t}if(!this.selectedElementIds.length)return;const o={};if(this.options.selectedState&&Object.assign(o,this.getElementsState(this.selectedElementIds,this.options.selectedState,e)),this.options.unselectedState){const t=Vu(n.getData(),!0).filter((t=>!this.selectedElementIds.includes(t)));Object.assign(o,this.getElementsState(t,this.options.unselectedState,e))}n.setElementState(o,this.options.animation)};getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t),a=n?[...o,e]:o.filter((t=>t!==e));i[t]=a})),i};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;jl.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickElement)})),e.off(`canvas:${t.CommonEvent.CLICK}`,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}class ld extends Qh{static defaultOptions={enable:!0,animation:!0};constructor(t,e){super(t,Object.assign({},ld.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),e.on(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}unbindEvents(){const{graph:e}=this.context;e.off(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}onCollapseExpand=async t=>{if(!this.validate(t))return;const{target:e}=t;if(!(Ph(n=e)||kh(n)||Ah(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,a=i.getComboData([r])[0];if(!a)return!1;const{onCollapse:s,onExpand:c,animation:u}=this.options,l=a.style?.collapsed;l?(await o.expand(r,u),c?.(r)):(await o.collapse(r,u),s?.(r))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}const hd="g6-create-edge-assist-node-id";class dd extends Qh{static defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};source;constructor(t,e){super(t,Object.assign({},dd.defaultOptions,e)),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(`node:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.on(`combo:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.on(`canvas:${t.CommonEvent.CLICK}`,this.cancelEdge),e.on(`edge:${t.CommonEvent.CLICK}`,this.cancelEdge)):(e.on(`node:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.on(`combo:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}drop=async t=>{const{targetType:e}=t;["combo","node"].includes(e)&&this.source?await this.handleCreateEdge(t):await this.cancelEdge()};handleCreateEdge=async t=>{if(!this.validate(t))return;const{graph:e,canvas:n}=this.context,{style:r}=this.options;if(this.source)return this.createEdge(t),void await this.cancelEdge();n.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0],e.addNodeData([{id:hd,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}]}}]),e.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:hd,style:{pointerEvents:"none",...r}}])};updateAssistEdge=async t=>{if(!this.source)return;const{model:e,element:n}=this.context;e.translateNodeTo(hd,[t.canvas.x,t.canvas.y]),await n.draw({animation:!1,silence:!0})};createEdge=t=>{const{graph:e}=this.context,{style:n,onFinish:r,onCreate:i}=this.options,o=t.target?.id;if(void 0===o||void 0===this.source)return;const a=this.getSelectedNodeIDs([t.target.id])?.[0];var s;const c=i({id:`${this.source}-${a}-${de[s=s||"g"]?de[s]+=1:de[s]=1,s+de[s]}`,source:this.source,target:a,style:n});e.addEdgeData([c]),r(c)};cancelEdge=async()=>{if(!this.source)return;const{graph:t,element:e,canvas:n}=this.context;n.setCursor("default"),t.removeNodeData([hd]),this.source=void 0,await e.draw({animation:!1,silence:!0})};getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(`node:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.off(`combo:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.off(`canvas:${t.CommonEvent.CLICK}`,this.cancelEdge),e.off(`edge:${t.CommonEvent.CLICK}`,this.cancelEdge),e.off(`node:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.off(`combo:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}class fd extends Qh{static defaultOptions={enable:!0,sensitivity:10};shortcut;defaultCursor;constructor(t,e){super(t,Object.assign({},fd.defaultOptions,e)),this.shortcut=new rd(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default",t.canvas.setCursor("grab")}bindEvents(){const{trigger:e}=this.options;this.shortcut.unbindAll();const{graph:n}=this.context;if(Rt(e)){n.off(t.CanvasEvent.DRAG,this.onDrag);const{up:r=[],down:i=[],left:o=[],right:a=[]}=e;this.shortcut.bind(r,(t=>this.onTranslate([0,1],t))),this.shortcut.bind(i,(t=>this.onTranslate([0,-1],t))),this.shortcut.bind(o,(t=>this.onTranslate([1,0],t))),this.shortcut.bind(a,(t=>this.onTranslate([-1,0],t)))}else n.on(t.CanvasEvent.DRAG,this.onDrag)}onDrag=t=>{this.validate(t)&&"canvas"===t.targetType&&(this.translate([t.movement.x,t.movement.y],!1),this.options.onFinish?.())};async onTranslate(t,e){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;await this.translate(Xu(t,r),this.options.animation),this.options.onFinish?.()}async translate(t,e){await this.context.graph.translateBy(t,e)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}destroy(){this.shortcut.destroy(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}class pd extends Qh{static defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),dropEffect:"move",state:"selected",hideEdge:"none",shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5]};enable=!1;enableElements=["node","combo"];target=[];shadow;shadowOrigin=[0,0];hiddenEdges=[];get animation(){return!!this.options.shadow&&this.options.animation}constructor(t,e){super(t,Object.assign({},pd.defaultOptions,e)),this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),this.enableElements.forEach((n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),["link"].includes(this.options.dropEffect)&&(e.on(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.on(`canvas:${t.CommonEvent.DROP}`,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return Zu([t.dx,t.dy],e)}onDragStart(t){this.enable=this.validate(t),this.enable&&(this.context.batch?.startBatch(),this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=Ku([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),this.options.onFinish?.(this.target),this.context.batch?.endBatch(),this.target=[]}onDrop=async t=>{if("link"!==this.options.dropEffect)return;const{model:e,element:n}=this.context,r=t.target.id;this.target.forEach((t=>{const n=e.getParentData(t,mu);n&&Fu(n)===r&&e.refreshComboData(r),e.setParent(t,r,mu)})),await(n?.draw({animation:!0}))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}async moveElement(t,e){const{model:n,element:r}=this.context,{dropEffect:i}=this.options;t.forEach((t=>{const r=n.getElementType(t);"node"===r?n.translateNodeBy(t,e):"combo"===r&&n.translateComboBy(t,e)})),"move"===i&&t.forEach((t=>n.refreshComboData(t))),await r.draw({animation:this.animation})}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=Uu(this.options,"shadow"),n=Pu(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Su(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr({...e,...s,visibility:"visible"}):(this.shadow=new Fs({style:{...e,...s,pointerEvents:"none",$layer:"transient"}}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(Fu):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(Fu))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e}=this.context;this.enableElements.forEach((n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){this.unbindEvents(),this.shadow?.destroy(),super.destroy()}}const gd=["node","combo"];class md extends Qh{static defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};constructor(t,e){super(t,Object.assign({},md.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),gd.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.clickFocusElement)}))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}clickFocusElement=async t=>{if(!this.validate(t))return;const{animation:e}=this.options,{graph:n}=this.context,r=this.getSelectedNodeIDs([t.target.id]);await n.focusElement(r,e)};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;gd.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.clickFocusElement)}))}destroy(){this.unbindEvents(),super.destroy()}}class vd extends Qh{static defaultOptions={animation:!0,enable:!0,degree:0,activeState:"active",inactiveState:void 0};constructor(t,e){super(t,Object.assign({},vd.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),jl.forEach((n=>{e.on(`${n}:${t.CommonEvent.POINTER_OVER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_OUT}`,this.hoverEndElement)}))}hoverElement=t=>{this.validate(t)&&(this.updateElementsState(t,!0),this.options.onHover?.(t))};hoverEndElement=t=>{this.validate(t)&&(this.updateElementsState(t,!1),this.options.onHoverEnd?.(t))};updateElementsState=(t,e)=>{if(!this.options.activeState&&!this.options.inactiveState)return;const{graph:n}=this.context,{targetType:r,target:i}=t,o=sd(n,r,i.id,this.options.degree),a={};if(this.options.activeState&&Object.assign(a,this.getElementsState(o,this.options.activeState,e)),this.options.inactiveState){const t=Vu(n.getData(),!0).filter((t=>!o.includes(t)));Object.assign(a,this.getElementsState(t,this.options.inactiveState,e))}n.setElementState(a,this.options.animation)};getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t),a=n?[...o,e]:o.filter((t=>t!==e));i[t]=a})),i};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;jl.forEach((n=>{e.off(`${n}:${t.CommonEvent.POINTER_OVER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_OUT}`,this.hoverEndElement)}))}destroy(){this.unbindEvents(),super.destroy()}}const yd=(t,e,n)=>{const r=t.getElementRenderBounds(e);if(!r)return!1;const i=[[r.min[0],r.min[1]],[r.max[0],r.min[1]],[r.max[0],r.max[1]],[r.min[0],r.max[1]]];return bd(n,i)},bd=(t,e)=>{const n=t=>{const e=t.map((t=>t[0])),n=t.map((t=>t[1]));return{min:[Math.min.apply(null,e),Math.min.apply(null,n),0],max:[Math.max.apply(null,e),Math.max.apply(null,n),0]}},r=t=>{const e=[],n=t.length;for(let r=0;r<n-1;r++){const n=t[r],i=t[r+1];e.push([n,i])}if(e.length>1){const r=t[0],i=t[n-1];e.push([i,r])}return e};if(t.length<2||e.length<2)return!1;const i=n(t),o=n(e);if(!xd(i,o))return!1;let a=!1;if(e.forEach((e=>{if(vl(e,t))return a=!0,!1})),a)return!0;if(t.forEach((t=>{if(vl(t,e))return a=!0,!1})),a)return!0;const s=r(t),c=r(e);let u=!1;return c.forEach((t=>{if(Ed(s,t))return u=!0,!1})),u},xd=(t,e)=>!!(e?.min&&t?.min&&e?.max&&t?.max)&&(e.min[0]<=t.max[0]&&e.max[0]>=t.min[0]&&e.min[1]<=t.max[1]&&e.max[1]>=t.min[1]),Ed=(t,e)=>{let n=!1;return t.forEach((t=>{if(t.length>1&&e.length>1&&ul(t,e))return n=!0,!1})),n};const wd={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function Md(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in wd?r=t:e.unshift(t),i={type:r},wd[r].forEach((n=>{t=e.shift(),i[n]=t})),"M"===r?r="L":"m"===r&&(r="l");const[o,...a]=Object.values(i);n.push([o,...a.map(Number)])}return n}(t):t;return n.forEach((t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}class Nd extends od{static defaultOptions={...od.defaultOptions,style:id};points;pathShape;selectElementFn=yd;constructor(t,e){super(t,Object.assign({},Nd.defaultOptions,e)),this.bindEvents()}pointerDown=async t=>{if(!this.validate(t)||!this.isKeydown()||this.points)return;const{style:e,trigger:n}=this.options,r=Array.isArray(n)?n:[n];if("canvas"!==t.targetType&&r.includes("drag"))return;const{canvas:i}=this.context;this.pathShape=new js({id:"g6-lasso-select-path-id",style:{...Nd.defaultOptions.style,fill:e.color||id.color,...e,pointerEvents:"none"}}),i.appendChild(this.pathShape),this.points=[[t.canvas.x,t.canvas.y]]};pointerMove=async t=>{if(!this.points)return;const{immediately:e,mode:n}=this.options,{element:r}=this.context;this.points.push([t.canvas.x,t.canvas.y]),this.pathShape?.setAttribute("path",function(t,e=!0){const n=[];return t.forEach(((t,e)=>{n.push([0===e?"M":"L",...t])})),e&&n.push(["Z"]),n}(this.points)),e&&"default"===n&&this.lassoUpdateElementState(),await(r?.draw({animation:!1,silence:!0}))};pointerUp=async()=>{this.points&&(this.points.length<2||this.lassoUpdateElementState(),await this.clearLasso())};clearSelected=()=>{if(this.points)return;const{graph:t}=this.context,e=ed(t,(()=>[]));t.setElementState(e,this.options.animation)};lassoUpdateElementState=()=>{!this.points||this.points?.length<2||this.updateElementState(this.points)};clearLasso=async()=>{this.pathShape?.remove(),this.pathShape=void 0,this.points=void 0}}class Sd extends Qh{static defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[]};shortcut;constructor(t,e){super(t,Object.assign({},Sd.defaultOptions,e)),this.shortcut=new rd(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),_t(e)&&(this.preventDefault(t.CanvasEvent.WHEEL),this.shortcut.bind([...e,t.CanvasEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(n??e),t,!1)}))),Rt(e)){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,(t=>this.zoom(10,t,this.options.animation))),this.shortcut.bind(n,(t=>this.zoom(-10,t,this.options.animation))),this.shortcut.bind(r,this.onReset)}}zoom=async(t,e,n)=>{if(!this.validate(e))return;const{graph:r}=this.context;let i;"viewport"in e&&(i=ll(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+Vt(t,-50,50)*o/100,c=r.getZoom();await r.zoomTo(c*s,n,i),a?.()};onReset=async()=>{await this.context.graph.zoomTo(1,this.options.animation)};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Pt(e)?e(t):!!e}preventDefault(t){const e=this.context.canvas.getContainer();e&&e.addEventListener(t,(t=>t.preventDefault()))}destroy(){this.shortcut.destroy(),super.destroy()}}var Cd=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Td=function(t,e){return!!Cd(t)&&t.indexOf(e)>-1},Pd=function(t,e){if(!Cd(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n},kd={}.toString,Ad=function(t,e){return kd.call(t)==="[object "+e+"]"},Od=function(t){return Ad(t,"Function")},_d=function(t){return null==t},Rd=function(t){return Array.isArray?Array.isArray(t):Ad(t,"Array")},Dd=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Id(t,e){if(t)if(Rd(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(Dd(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Ld=Object.keys?function(t){return Object.keys(t)}:function(t){var e=[];return Id(t,(function(n,r){Od(t)&&"prototype"===r||e.push(r)})),e};function jd(t,e){var n=Ld(e),r=n.length;if(_d(t))return!r;for(var i=0;i<r;i+=1){var o=n[i];if(e[o]!==t[o]||!(o in t))return!1}return!0}var zd=function(t){return"object"==typeof t&&null!==t},Bd=function(t){if(!zd(t)||!Ad(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};var Fd=function(t,e){if(void 0===e&&(e=[]),Rd(t))for(var n=0;n<t.length;n+=1)Fd(t[n],e);else e.push(t);return e},Gd=function(t){if(Rd(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},Vd=function(t){if(Rd(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},Wd=Array.prototype,Ud=Wd.splice,Hd=Wd.indexOf,$d=Array.prototype.splice,qd=function(t,e){if(!Cd(t))return[];for(var n=t?e.length:0,r=n-1;n--;){var i=void 0,o=e[n];n!==r&&o===i||(i=o,$d.call(t,o,1))}return t},Yd=function(t,e,n){if(!Rd(t)&&!Bd(t))return t;var r=n;return Id(t,(function(t,n){r=e(r,t,n)})),r},Kd=function(t){return Ad(t,"String")};function Xd(t,e){void 0===e&&(e=new Map);var n=[];if(Array.isArray(t))for(var r=0,i=t.length;r<i;r++){var o=t[r];e.has(o)||(n.push(o),e.set(o,!0))}return n}var Zd=Object.prototype.hasOwnProperty;function Qd(t,e){if(!e||!Rd(t))return{};for(var n,r={},i=Od(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),Zd.call(r,n)?r[n].push(a):r[n]=[a]}return r}function Jd(t,e){if(!e)return{0:t};if(!Od(e)){var n=Rd(e)?e:e.replace(/\s+/g,"").split("*");e=function(t){for(var e="_",r=0,i=n.length;r<i;r++)e+=t[n[r]]&&t[n[r]].toString();return e}}return Qd(t,e)}var tf={};var ef=function(t){return Ad(t,"Number")},nf=Number.isInteger?Number.isInteger:function(t){return ef(t)&&t%1==0};var rf=180/Math.PI,of=parseInt,af=Math.PI/180,sf=function(t,e){return t.hasOwnProperty(e)},cf=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return Id(t,(function(n,r){Od(t)&&"prototype"===r||e.push(n)})),e},uf=function(t){return _d(t)?"":t.toString()};var lf={}.toString,hf=function(t){return lf.call(t).replace(/^\[object /,"").replace(/]$/,"")};var df=Object.prototype,ff=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||df)};function pf(t,e){for(var n in e)e.hasOwnProperty(n)&&"constructor"!==n&&void 0!==e[n]&&(t[n]=e[n])}function gf(t,e,n,r){return e&&pf(t,e),n&&pf(t,n),r&&pf(t,r),t}var mf=function(t){if("object"!=typeof t||null===t)return t;var e;if(Rd(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=mf(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=mf(t[i]):e[i]=t[i];return e};var vf=function(t,e){if(!Od(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};return n.cache=new Map,n};function yf(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(e.hasOwnProperty(i)){var o=e[i];null!==o&&Bd(o)?(Bd(t[i])||(t[i]={}),n<r?yf(t[i],o,n+1,r):t[i]=e[i]):Rd(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var bf=Object.prototype.hasOwnProperty;var xf,Ef=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(Kd(t)||Kd(e))return!1;if(Cd(t)||Cd(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=Ef(t[r],e[r]));r++);return n}if(zd(t)||zd(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=Ef(t[i[r]],e[i[r]]));r++);return n}return!1},wf=function(t){return t},Mf=Object.prototype.hasOwnProperty,Nf={};var Sf=vf((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return xf||(xf=document.createElement("canvas").getContext("2d")),xf.font=[o,a,i,n+"px",r].join(" "),xf.measureText(Kd(t)?t:"").width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}([t],cf(e)).join("")})),Cf=function(){function t(){this.map={}}return t.prototype.has=function(t){return void 0!==this.map[t]},t.prototype.get=function(t,e){var n=this.map[t];return void 0===n?e:n},t.prototype.set=function(t,e){this.map[t]=e},t.prototype.clear=function(){this.map={}},t.prototype.delete=function(t){delete this.map[t]},t.prototype.size=function(){return Object.keys(this.map).length},t}(),Tf=Object.freeze({__proto__:null,Cache:Cf,assign:gf,augment:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=t[0],r=1;r<t.length;r++){var i=t[r];Od(i)&&(i=i.prototype),gf(n.prototype,i)}},clamp:function(t,e,n){return t<e?e:t>n?n:t},clearAnimationFrame:function(t){(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame||clearTimeout)(t)},clone:mf,contains:Td,debounce:function(t,e,n){var r;return function(){var i=this,o=arguments,a=n&&!r;clearTimeout(r),r=setTimeout((function(){r=null,n||t.apply(i,o)}),e),a&&t.apply(i,o)}},deepMix:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)yf(t,e[r]);return t},difference:function(t,e){return void 0===e&&(e=[]),Pd(t,(function(t){return!Td(e,t)}))},each:Id,endsWith:function(t,e){return!(!Rd(t)&&!Kd(t))&&t[t.length-1]===e},every:function(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n))return!1;return!0},extend:function(t,e,n,r){Od(e)||(n=e,e=t,t=function(){});var i=Object.create?function(t,e){return Object.create(t,{constructor:{value:e}})}:function(t,e){function n(){}n.prototype=t;var r=new n;return r.constructor=e,r},o=i(e.prototype,t);return t.prototype=gf(o,t.prototype),t.superclass=i(e.prototype,e),gf(o,n),gf(t,r),t},filter:Pd,find:function(t,e){if(!Rd(t))return null;var n;if(Od(e)&&(n=e),Bd(e)&&(n=function(t){return jd(t,e)}),n)for(var r=0;r<t.length;r+=1)if(n(t[r]))return t[r];return null},findIndex:function(t,e,n){void 0===n&&(n=0);for(var r=n;r<t.length;r++)if(e(t[r],r))return r;return-1},firstValue:function(t,e){for(var n=null,r=0;r<t.length;r++){var i=t[r][e];if(!_d(i)){n=Rd(i)?i[0]:i;break}}return n},fixedBase:function(t,e){var n=e.toString(),r=n.indexOf(".");if(-1===r)return Math.round(t);var i=n.substr(r+1).length;return i>20&&(i=20),parseFloat(t.toFixed(i))},flatten:function(t){if(!Rd(t))return[];for(var e=[],n=0;n<t.length;n++)e=e.concat(t[n]);return e},flattenDeep:Fd,forIn:Id,get:function(t,e,n){for(var r=0,i=Kd(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},getEllipsisText:function(t,e,n,r){void 0===r&&(r="...");var i,o,a=Sf(r,n),s=Kd(t)?t:uf(t),c=e,u=[];if(Sf(t,n)<=e)return t;for(;i=s.substr(0,16),!((o=Sf(i,n))+a>c&&o>c);)if(u.push(i),c-=o,!(s=s.substr(16)))return u.join("");for(;i=s.substr(0,1),!((o=Sf(i,n))+a>c);)if(u.push(i),c-=o,!(s=s.substr(1)))return u.join("");return""+u.join("")+r},getRange:function(t){var e=t.filter((function(t){return!isNaN(t)}));if(!e.length)return{min:0,max:0};if(Rd(t[0])){for(var n=[],r=0;r<t.length;r++)n=n.concat(t[r]);e=n}var i=Gd(e);return{min:Vd(e),max:i}},getType:hf,getWrapBehavior:function(t,e){return t["_wrap_"+e]},group:function(t,e){if(!e)return[t];var n=Jd(t,e),r=[];for(var i in n)r.push(n[i]);return r},groupBy:Qd,groupToMap:Jd,has:sf,hasKey:sf,hasValue:function(t,e){return Td(cf(t),e)},head:function(t){if(Cd(t))return t[0]},identity:function(t){return t},includes:Td,indexOf:function(t,e){if(!Cd(t))return-1;var n=Array.prototype.indexOf;if(n)return n.call(t,e);for(var r=-1,i=0;i<t.length;i++)if(t[i]===e){r=i;break}return r},isArguments:function(t){return Ad(t,"Arguments")},isArray:Rd,isArrayLike:Cd,isBoolean:function(t){return Ad(t,"Boolean")},isDate:function(t){return Ad(t,"Date")},isDecimal:function(t){return ef(t)&&t%1!=0},isElement:function(t){return t instanceof Element||t instanceof HTMLDocument},isEmpty:function(t){if(_d(t))return!0;if(Cd(t))return!t.length;var e=hf(t);if("Map"===e||"Set"===e)return!t.size;if(ff(t))return!Object.keys(t).length;for(var n in t)if(bf.call(t,n))return!1;return!0},isEqual:Ef,isEqualWith:function(t,e,n){return Od(n)?!!n(t,e):Ef(t,e)},isError:function(t){return Ad(t,"Error")},isEven:function(t){return ef(t)&&t%2==0},isFinite:function(t){return ef(t)&&isFinite(t)},isFunction:Od,isInteger:nf,isMatch:jd,isNegative:function(t){return ef(t)&&t<0},isNil:_d,isNull:function(t){return null===t},isNumber:ef,isNumberEqual:function(t,e,n){return void 0===n&&(n=1e-5),Math.abs(t-e)<n},isObject:Dd,isObjectLike:zd,isOdd:function(t){return ef(t)&&t%2!=0},isPlainObject:Bd,isPositive:function(t){return ef(t)&&t>0},isPrototype:ff,isRegExp:function(t){return Ad(t,"RegExp")},isString:Kd,isType:Ad,isUndefined:function(t){return void 0===t},keys:Ld,last:function(t){if(Cd(t)){return t[t.length-1]}},lowerCase:function(t){return uf(t).toLowerCase()},lowerFirst:function(t){var e=uf(t);return e.charAt(0).toLowerCase()+e.substring(1)},map:function(t,e){if(!Cd(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];n.push(e(i,r))}return n},mapValues:function(t,e){void 0===e&&(e=wf);var n={};return Dd(t)&&!_d(t)&&Object.keys(t).forEach((function(r){n[r]=e(t[r],r)})),n},max:Gd,maxBy:function(t,e){if(Rd(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=Od(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},measureTextWidth:Sf,memoize:vf,min:Vd,minBy:function(t,e){if(Rd(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=Od(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},mix:gf,mod:function(t,e){return(t%e+e)%e},noop:function(){},number2color:function(t){var e=tf[t];if(!e){for(var n=t.toString(16),r=n.length;r<6;r++)n="0"+n;e="#"+n,tf[t]=e}return e},omit:function(t,e){return Yd(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},parseRadius:function(t){var e=0,n=0,r=0,i=0;return Rd(t)?1===t.length?e=n=r=i=t[0]:2===t.length?(e=r=t[0],n=i=t[1]):3===t.length?(e=t[0],n=i=t[1],r=t[2]):(e=t[0],n=t[1],r=t[2],i=t[3]):e=n=r=i=t,{r1:e,r2:n,r3:r,r4:i}},pick:function(t,e){if(null===t||!Bd(t))return{};var n={};return Id(e,(function(e){Mf.call(t,e)&&(n[e]=t[e])})),n},pull:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],o=-1;(o=Hd.call(t,i))>-1;)Ud.call(t,o,1);return t},pullAt:qd,reduce:Yd,remove:function(t,e){var n=[];if(!Cd(t))return n;for(var r=-1,i=[],o=t.length;++r<o;){var a=t[r];e(a,r,t)&&(n.push(a),i.push(r))}return qd(t,i),n},requestAnimationFrame:function(t){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return setTimeout(t,16)})(t)},set:function(t,e,n){var r=t,i=Kd(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Dd(r[t])||(r[t]=ef(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},size:function(t){return _d(t)?0:Cd(t)?t.length:Object.keys(t).length},some:function(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n))return!0;return!1},sortBy:function(t,e){var n;if(Od(e))n=function(t,n){return e(t)-e(n)};else{var r=[];Kd(e)?r.push(e):Rd(e)&&(r=e),n=function(t,e){for(var n=0;n<r.length;n+=1){var i=r[n];if(t[i]>e[i])return 1;if(t[i]<e[i])return-1}return 0}}return t.sort(n),t},startsWith:function(t,e){return!(!Rd(t)&&!Kd(t))&&t[0]===e},substitute:function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,(function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]})):t},throttle:function(t,e,n){var r,i,o,a,s=0;n||(n={});var c=function(){s=!1===n.leading?0:Date.now(),r=null,a=t.apply(i,o),r||(i=o=null)},u=function(){var u=Date.now();s||!1!==n.leading||(s=u);var l=e-(u-s);return i=this,o=arguments,l<=0||l>e?(r&&(clearTimeout(r),r=null),s=u,a=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(c,l)),a};return u.cancel=function(){clearTimeout(r),s=0,r=i=o=null},u},toArray:function(t){return Cd(t)?Array.prototype.slice.call(t):[]},toDegree:function(t){return rf*t},toInteger:of,toRadian:function(t){return af*t},toString:uf,union:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Xd([].concat.apply([],t))},uniq:Xd,uniqueId:function(t){return Nf[t=t||"g"]?Nf[t]+=1:Nf[t]=1,t+Nf[t]},upperCase:function(t){return uf(t).toUpperCase()},upperFirst:function(t){var e=uf(t);return e.charAt(0).toUpperCase()+e.substring(1)},values:cf,valuesOfKey:function(t,e){for(var n=[],r={},i=0;i<t.length;i++){var o=t[i][e];if(!_d(o)){Rd(o)||(o=[o]);for(var a=0;a<o.length;a++){var s=o[a];r[s]||(n.push(s),r[s]=!0)}}}return n},wrapBehavior:function(t,e){if(t["_wrap_"+e])return t["_wrap_"+e];var n=function(n){t[e](n)};return t["_wrap_"+e]=n,n}});var Pf={assign:p(Tf).mix,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},kf=Pf,Af={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function Of(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof Of)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}kf.assign(Of.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)})),t},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var _f=function(t,e,n){void 0===e&&(e={});var r,i=new Of(t,e=kf.assign({},Af,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var c=0;c<s;c++){var u=new Of(a[c],e);r.children[c]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},Rf=_f,Df=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=Rf(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),If=Df;function Lf(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function jf(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){jf(t,e,n)}))}function zf(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(zf(t,e),n)})),n}function Bf(t,e){jf(t,-zf(t,e),e)}function Ff(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){Ff(t,e.children[r],n)}))}function Gf(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){Gf(t,e,n)}))}Lf.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(Lf.fromNode(t,e))})),e?new Lf(t.height,t.width,t.x,n):new Lf(t.width,t.height,t.y,n)};var Vf=_f,Wf=function(t,e){for(var n=Vf(t.data,e,!0),r=Vf(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var c=t.children[s];"right"===a(c,s)?r.children.push(c):n.children.push(c)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},Uf=Wf,Hf=["LR","RL","TB","BT","H","V"],$f=["LR","RL","H"],qf=Hf[0],Yf=function(t,e,n){var r=e.direction||qf;if(e.isHorizontal=function(t){return $f.indexOf(t)>-1}(r),r&&-1===Hf.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===Hf[0])n(t,e);else if(r===Hf[1])n(t,e),t.right2left();else if(r===Hf[2])n(t,e);else if(r===Hf[3])n(t,e),t.bottom2top();else if(r===Hf[4]||r===Hf[5]){var i=Uf(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var c=e.fixedRoot;return void 0===c&&(c=!0),c&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t};function Kf(t,e){return Kf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Kf(t,e)}var Xf=function(t,e){void 0===e&&(e={});var n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){for(var r=t.c[e-1],i=r.mod,u=t.c[e],l=u.mod;null!==r&&null!==u;){c(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(l+u.prelim);h>0&&(l+=h,o(t,e,n.index,h));var d=c(r),f=c(u);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(u=a(u))&&(l+=u.mod)}!r&&u?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,u,l):r&&!u&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function a(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function c(t){return t.y+t.h}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}Gf(t,n);var l=Lf.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=u(c(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=c(e.c[o].er);i(e,o,n),n=u(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(l),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(l,0),Ff(l,t,n),Bf(t,n),t},Zf=Yf,Qf=Pf,Jf=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,Kf(e,n),r.prototype.execute=function(){return Zf(this.rootNode,this.options,Xf)},r}(If),tp={};var ep=function(t,e){return e=Qf.assign({},tp,e),new Jf(t,e).execute()},np=Pf;function rp(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var ip={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function op(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){op(t,e.children[r],n)}))}function ap(t,e){return ap=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ap(t,e)}var sp=function(t,e){void 0===e&&(e={}),e=np.assign({},ip,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new rp(e.height,[]);return n.forEach((function(e,n){var r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)})),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),op(i,t,e.isHorizontal),t},cp=Yf,up=Pf,lp=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,ap(e,n),r.prototype.execute=function(){var t=this;return t.rootNode.width=0,cp(t.rootNode,t.options,sp)},r}(If),hp={};var dp=function(t,e){return e=up.assign({},hp,e),new lp(t,e).execute()},fp=Pf;function pp(t,e){return pp=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},pp(t,e)}var gp=If,mp=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o="function"==typeof n?n(t):n*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+fp.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+fp.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},vp=Wf,yp=Pf,bp=["LR","RL","H"],xp=bp[0],Ep=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,pp(e,n),r.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?xp:a,c=t.align;if(s&&-1===bp.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===bp[0])mp(e,r,o,c);else if(s===bp[1])mp(e,r,o,c),e.right2left();else if(s===bp[2]){var u=vp(e,t),l=u.left,h=u.right;mp(l,r,o,c),l.right2left(),mp(h,r,o,c);var d=l.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},r}(gp),wp={};var Mp=function(t,e){return e=yp.assign({},wp,e),new Ep(t,e).execute()},Np=Pf;function Sp(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=Sp(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function Cp(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){Cp(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var Tp={getSubTreeSep:function(){return 0}};function Pp(t,e){return Pp=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Pp(t,e)}var kp=function(t,e){void 0===e&&(e={}),e=Np.assign({},Tp,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,Sp(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),Cp(t)},Ap=Yf,Op=Pf,_p=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,Pp(e,n),r.prototype.execute=function(){return Ap(this.rootNode,this.options,kp)},r}(If),Rp={};var Dp=function(t,e){return e=Op.assign({},Rp,e),new _p(t,e).execute()},Ip={compactBox:ep,dendrogram:dp,indented:Mp,mindmap:Dp},Lp=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function jp(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function zp(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&zp(i,e,n,r))return!0;return!1}const Bp=()=>!0;class Fp{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||Bp,n=t.edgeFilter||Bp;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach((t=>e.add(t.id))),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];jp([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];zp(this.getNode(t),new Set,e,r)}}let Gp=class t extends Lp{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const n=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateNodeDataProperty(t,e,n)}))}))}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})}))}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})}))}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateEdgeDataProperty(t,e,n)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach((t=>{t.children?.forEach((n=>{this.setParent(n.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n),i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(void 0===e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const a=this.getNode(e);r.parentMap.set(t,a),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(a.id);s||(s=new Set,r.childrenMap.set(a.id,s)),s.add(i),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:a.id})}))}dfsTree(t,e,n){return zp(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return jp([this.getNode(t)],new Set,e,(t=>this.getChildren(t,n)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return jp([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return zp(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),n=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new t({nodes:e,edges:n});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach(((t,e)=>{i.set(e,r.getNode(t.id))}));const o=new Map;e.forEach(((t,e)=>{o.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:i,childrenMap:o})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new Fp({graph:this,...t})}};const Vp=(t,e)=>{if("next"!==t&&"prev"!==t)return e},Wp=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let Up=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return Wp(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&Wp(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,Vp)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},Hp=class extends Up{};const $p=()=>1,qp=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)Yp(t,e,n,a);for(;a=i.dequeue();)Yp(t,e,n,a);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(a=e[i].dequeue(),a){r=r.concat(Yp(t,e,n,a,!0));break}}return r},Yp=(t,e,n,r,i)=>{var o,a;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach((r=>{const o=r.data.weight,a=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===a.data.out&&(a.data.out=0),a.data.out-=o,Xp(e,n,Object.assign({v:a.id},a.data))})),null===(a=t.getRelatedEdges(r.v,"out"))||void 0===a||a.forEach((r=>{const i=r.data.weight,o=r.target,a=t.getNode(o);void 0===a.data.in&&(a.data.in=0),a.data.in-=i,Xp(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},Kp=(t,e)=>{const n=new Gp;let r=0,i=0;t.getAllNodes().forEach((t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((t=>{const o=n.getRelatedEdges(t.source,"out").find((e=>e.target===t.target)),a=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+a})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:a}}),i=Math.max(i,n.getNode(t.source).data.out+=a),r=Math.max(r,n.getNode(t.target).data.in+=a)}));const o=[],a=i+r+3;for(let t=0;t<a;t++)o.push(new Hp);const s=r+1;return n.getAllNodes().forEach((t=>{Xp(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},Xp=(t,e,n)=>{n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},Zp=(t,e)=>{const n="greedy"===e?((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=Kp(t,e||$p);return null===(n=qp(r.graph,r.buckets,r.zeroIdx).map((e=>t.getRelatedEdges(e.v,"out").filter((({target:t})=>t===e.w)))))||void 0===n?void 0:n.flat()})(t,(t=>t.data.weight||1)):Qp(t);null==n||n.forEach((e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})}))},Qp=t=>{const e=[],n={},r={},i=o=>{r[o]||(r[o]=!0,n[o]=!0,t.getRelatedEdges(o,"out").forEach((t=>{n[t.target]?e.push(t):i(t.target)})),delete n[o])};return t.getAllNodes().forEach((t=>i(t.id))),e},Jp=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},tg=t=>{const e=new Gp;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},eg=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,c=Number(t.width)/2,u=Number(t.height)/2;return i||o?(Math.abs(o)*c>Math.abs(i)*u?(o<0&&(u=-u),a=u*i/o,s=u):(i<0&&(c=-c),a=c,s=c*o/i),{x:n+a,y:r+s}):{x:0,y:0}},ng=t=>{const e=[],n=ig(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(let r=0;r<n;r++)e[r]=e[r].sort(((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},rg=(t,e,n,r)=>{const i={width:0,height:0};return Wt(n)&&Wt(r)&&(i.rank=n,i.order=r),Jp(t,"border",i,e)},ig=t=>{let e;return t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},og=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),ag=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>ag(t,e,n,r,i,o))),n&&o.push(e.id))},sg=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>r?t.getSuccessors(e):t.getNeighbors(e),a=[],s=[];return i.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);ag(t,e,"post"===n,s,o,a)})),a},cg=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],c=Jp(t,"border",a,n);i.data[e][o]=c,t.setParent(c,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:c,data:{weight:1}})},ug=t=>{t.getAllNodes().forEach((t=>{lg(t)})),t.getAllEdges().forEach((t=>{lg(t)}))},lg=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},hg=t=>{t.getAllNodes().forEach((t=>{dg(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>dg(t))),t.data.hasOwnProperty("y")&&dg(t.data)}))},dg=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},fg=t=>{t.getAllNodes().forEach((t=>{pg(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>pg(t))),t.data.hasOwnProperty("x")&&pg(t.data)}))},pg=t=>{const e=t.x;t.x=t.y,t.y=e},gg=(t,e,n,r,i,o,a)=>{const s=t.getChildren(a);if(!(null==s?void 0:s.length))return void(a!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:n}}));const c=rg(t,"_bt"),u=rg(t,"_bb"),l=t.getNode(a);t.setParent(c,a),l.data.borderTop=c,t.setParent(u,a),l.data.borderBottom=u,null==s||s.forEach((s=>{gg(t,e,n,r,i,o,s.id);const l=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=l!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:c,target:l,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:u,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:c,data:{weight:0,minlen:i+o[a]}})},mg=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach((t=>n(t.id,i+1))),e[r]=i};return t.getRoots().forEach((t=>n(t.id,1))),e},vg=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},yg="edge-label",bg=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a===i+1)return;let c,u,l;for(t.removeEdge(e.id),l=0,++i;i<a;++l,++i)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:i},c=Jp(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=yg,u.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:c,data:{weight:e.data.weight}}),0===l&&n.push(c),r=c;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},xg=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},Eg=(t,e,n)=>{const r=((t,e)=>null==t?void 0:t.reduce(((t,n,r)=>(t[n]=e[r],t)),{}))(n,n.map(((t,e)=>e))),i=e.map((e=>{const n=t.getRelatedEdges(e,"out").map((t=>({pos:r[t.target]||0,weight:t.data.weight})));return null==n?void 0:n.sort(((t,e)=>t.pos-e.pos))})),o=i.flat().filter((t=>void 0!==t));let a=1;for(;a<n.length;)a<<=1;const s=2*a-1;a-=1;const c=Array(s).fill(0,0,s);let u=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;c[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=c[e+1]),e=e-1>>1,c[e]+=t.weight;u+=t.weight*n}})),u},wg=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=Eg(t,e[r-1],e[r]);return n},Mg=t=>{const e={},n=t.getAllNodes(),r=n.map((t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o.push([]);const a=n.sort(((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder));return null==s||s.forEach((n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==a||a.forEach((n=>t.dfsTree(n.id,(t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})))),o},Ng=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Sg(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((e=>{return(n=i,e=>{e.in.push(n),0==--e.indegree&&t.push(e)})(e);var n}))}const i=r.filter((t=>!t.merged)),o=["vs","i","barycenter","weight"];return i.map((t=>{const e={};return null==o||o.forEach((n=>{void 0!==t[n]&&(e[n]=t[n])})),e}))},Sg=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},Cg=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},Tg=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},Pg=(t,e,n,r,i,o)=>{var a,s,c,u;let l=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(l=null==l?void 0:l.filter((t=>t!==d&&t!==f)));const g=((t,e)=>e.map((e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach((e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight})),{v:e,barycenter:r.sum/r.weight,weight:r.weight}})))(t,l||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Pg(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&Ag(e,i)}}));const m=((t,e)=>{var n,r,i;const o={};null==t||t.forEach(((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)})),null===(n=e.getAllEdges())||void 0===n||n.forEach((t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));const a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(t=>!t.indegree));return Ng(a)})(g,n);kg(m,p),null===(a=m.filter((t=>t.vs.length>0)))||void 0===a||a.forEach((e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));const v=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach((t=>{e(t)?n.lhs.push(t):n.rhs.push(t)})),n})(t,(t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort(((t,e)=>-t.i- -e.i)),s=[];let c=0,u=0,l=0;null==o||o.sort(Tg(!!e,!!n)),l=Cg(s,a,l),null==o||o.forEach((t=>{var e;l+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),c+=t.barycenter*t.weight,u+=t.weight,l=Cg(s,a,l)}));const h={vs:s.flat()};return u&&(h.barycenter=c/u,h.weight=u),h})(m,r,i,o);if(d&&(v.vs=[d,v.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(c=t.getPredecessors(d))||void 0===c?void 0:c[0].id)||""),n=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+e.data.order+n.data.order)/(v.weight+2),v.weight+=2}return v},kg=(t,e)=>{null==t||t.forEach((t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map((t=>e[t]?e[t].vs:t));t.vs=r.flat()}))},Ag=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},Og=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=xg(t),i=new Gp({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((o=>{const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach((e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find((({target:t})=>t===o.id)),a=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+a})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+a}})})),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i})(t,e,n))),_g=(t,e,n,r)=>{const i=new Gp;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Pg(t,a,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach((n=>{let o,a,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(a=r[o.id],r[o.id]=s.id):(a=i,i=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${a}-${s.id}`)||e.addEdge({id:`e${a}-${s.id}`,source:a,target:s.id,data:{}}));s=o}}))})(t,i,s.vs)}))},Rg=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},Dg=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach((t=>r(t.id))),e[i]={low:o,lim:n++}};return t.getRoots().forEach((t=>r(t.id))),e})(t);e.forEach((e=>{var r,i;let o=e,a=t.getNode(o);const s=a.data.originalEdge;if(!s)return;const c=((t,e,n,r)=>{var i,o;const a=[],s=[],c=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);let l,h;l=n;do{l=null===(i=t.getParent(l))||void 0===i?void 0:i.id,a.push(l)}while(l&&(e[l].low>c||u>e[l].lim));for(h=l,l=r;l&&l!==h;)s.push(l),l=null===(o=t.getParent(l))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),u=c.path,l=c.lca;let h=0,d=u[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==l&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=u[h];d===l&&(f=!1)}if(!f){for(;h<u.length-1&&(null===(i=t.getNode(u[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=u[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},Ig=(t,e)=>{const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,a){var s,c;let u;for(let l=r;l<i;l++)u=e[l],(null===(s=t.getNode(u))||void 0===s?void 0:s.data.dummy)&&(null===(c=t.getPredecessors(u))||void 0===c||c.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&jg(n,e.id,u)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((c,u)=>{var l;if("border"===(null===(l=t.getNode(c))||void 0===l?void 0:l.data.dummy)){const e=t.getPredecessors(c)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,u,o,i],s),a=u,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},Lg=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find((e=>t.getNode(e.id).data.dummy))},jg=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},zg=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},Bg=(t,e,n,r,i,o)=>{const a=new Gp,s=Fg(r,i,o);return null==e||e.forEach((e=>{let r;null==e||e.forEach((e=>{const i=n[e];if(a.hasNode(i)||a.addNode({id:i,data:{}}),r){const o=n[r],c=a.getRelatedEdges(o,"out").find((t=>t.target===i));c?a.updateEdgeData(c.id,Object.assign(Object.assign({},c.data),{weight:Math.max(s(t,e,r),c.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e}))})),a};const Fg=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let c=0,u=0;if(c+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2}if(u&&(c+=n?u:-u),u=0,c+=(a.data.dummy?e:t)/2,c+=(s.data.dummy?e:t)/2,c+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2}return u&&(c+=n?u:-u),u=0,c},Gg=(t,e)=>t.getNode(e).data.width||0,Vg=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=ng(t),a=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach(((e,c)=>{var u;const l=Lg(t,e),h=l?t.getNode(l.id).data.order:a;(l||e===s)&&(null===(u=r.slice(o,c+1))||void 0===u||u.forEach((e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((r=>{var o;const a=t.getNode(r.id),s=a.data.order;!(s<i||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||jg(n,r.id,e)}))})),o=c+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),Ig(t,o)),s={};let c=[];["u","d"].forEach((e=>{c="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(c=c.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),u=((t,e,n,r)=>{const i={},o={},a={};return null==e||e.forEach((t=>{null==t||t.forEach(((t,e)=>{i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((t=>{let e=-1;null==t||t.forEach((t=>{let s=r(t).map((t=>t.id));if(s.length){s=s.sort(((t,e)=>a[t]-a[e]));const r=(s.length-1)/2;for(let c=Math.floor(r),u=Math.ceil(r);c<=u;++c){const r=s[c];o[t]===t&&e<a[r]&&!zg(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,c,a,o),l=((t,e,n,r,i,o,a)=>{var s;const c={},u=Bg(t,e,n,i,o,a),l=a?"borderLeft":"borderRight",h=(t,e)=>{let n=u.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return h((t=>{c[t]=(u.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(c[e.source]||0)+e.data.weight)),0)}),u.getPredecessors.bind(u)),h((e=>{const n=(u.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(c[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==l&&(c[e]=Math.max(c[e],n))}),u.getSuccessors.bind(u)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{c[t]=c[n[t]]})),c})(t,c,u.root,u.align,r,i,"r"===n);"r"===n&&Object.keys(l).forEach((t=>l[t]=-l[t])),s[e+n]=l}))}));const u=((t,e)=>og(Object.values(e),(e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((n=>{const o=e[n],a=Gg(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return u&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach((n=>{["l","r"].forEach((o=>{const a=n+o,s=t[a];let c;if(s===e)return;const u=Object.values(s);c="l"===o?r-Math.min(...u):i-Math.max(...u),c&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+c})))}))}))}(s,u),((t,e)=>{const n={};return Object.keys(t.ul).forEach((r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map((t=>t[r]));n[r]=(e[0]+e[1])/2}})),n})(s,n)},Wg=(t,e)=>{var n;const r=tg(t);((t,e)=>{const{ranksep:n=0}=e||{},r=ng(t);let i=0;null==r||r.forEach((e=>{const r=e.map((e=>t.getNode(e).data.height)),o=Math.max(...r,0);null==e||e.forEach((e=>{t.getNode(e).data.y=i+o/2})),i+=o+n}))})(r,e);const i=Vg(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},Ug=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let a;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),o.data.rank=a,a};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>n(t.id)))},Hg=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,$g=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||Hg(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},qg=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&Hg(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},Yg=(t,e)=>og(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?Hg(e,n):1/0)),Kg=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},Xg=t=>{const e=(t=>{const e=new Gp;return t.getAllNodes().forEach((t=>{e.addNode(Object.assign({},t))})),t.getAllEdges().forEach((t=>{const n=e.getRelatedEdges(t.source,"out").find((e=>e.target===t.target));n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e})(t);Ug(e);const n=(t=>{const e=new Gp({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);$g(e,t)<r;)i=Yg(e,t),o=e.hasNode(i.source)?Hg(t,i):-Hg(t,i),Kg(e,t,o);return e})(e);let r,i;for(tm(n),Zg(n,e);r=nm(n);)i=rm(n,e,r),im(n,e,r,i)},Zg=(t,e)=>{let n=sg(t,t.getAllNodes(),"post",!1);n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{Qg(t,e,n)}))},Qg=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=Jg(t,e,n)},Jg=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find((t=>t.target===r)),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((t=>t.target===n))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,c=e.data.weight;if(a+=r?c:-c,am(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},tm=(t,e=t.getAllNodes()[0].id)=>{em(t,{},1,e)},em=(t,e,n,r,i)=>{var o;const a=n;let s=n;const c=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=em(t,e,s,n.id,r))})),c.data.low=a,c.data.lim=s++,i?c.data.parent=i:delete c.data.parent,s},nm=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),rm=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((t=>t.target===i))||(r=n.target,i=n.source);const o=t.getNode(r),a=t.getNode(i);let s=o,c=!1;o.data.lim>a.data.lim&&(s=a,c=!0);const u=e.getAllEdges().filter((e=>c===sm(t.getNode(e.source),s)&&c!==sm(t.getNode(e.target),s)));return og(u,(t=>Hg(e,t)))},im=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find((t=>t.source===n.target||t.target===n.target));i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),tm(t),Zg(t,e),om(t,e)},om=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=sg(t,n,"pre",!1);r=r.slice(1),r.forEach((n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find((t=>t.target===r)),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((t=>t.target===n)),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))}))},am=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),sm=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,cm=Ug,um=t=>{(t=>{const e={};let n;const r=i=>{var o;const a=t.getNode(i);if(!a)return 0;if(e[i])return a.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)})),s||(s=0),(void 0===n||s<n)&&(n=s),a.data.rank=s,s};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>{t&&r(t.id)})),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const a=t.getNode(e),s=isNaN(a.data.layer)?n:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((t=>{o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))}))})(t),(t=>{const e=new Gp({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);qg(e,t)<r;)i=Yg(e,t),o=e.hasNode(i.source)?Hg(t,i):-Hg(t,i),Kg(e,t,o)})(t)},lm=t=>{Xg(t)},hm=(t,e)=>{const{acyclicer:n,ranker:r,rankdir:i="tb",nodeOrder:o,keepNodeOrder:a,align:s,nodesep:c=50,edgesep:u=20,ranksep:l=50}=e;km(t),Zp(t,n);const{nestingRoot:h,nodeRankFactor:d}=(t=>{const e=Jp(t,"root",{},"_root"),n=mg(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach((t=>{t.data.minlen*=o}));const a=vg(t)+1;return t.getRoots().forEach((r=>{gg(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":lm(t);break;case"tight-tree":default:um(t);break;case"longest-path":cm(t)}})(tg(t),r),Em(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),i=Math.min(...r),o=[];n.forEach((t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));let a=0;for(let n=0;n<o.length;n++){const r=o[n];void 0===r?n%e!=0&&(a-=1):a&&(null==r||r.forEach((e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}})(t,d),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,h),(t=>{const e=t.getAllNodes().filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),n=Math.min(...e);t.getAllNodes().forEach((t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))})(t),wm(t),Mm(t);const f=[];((t,e)=>{t.getAllEdges().forEach((n=>bg(t,n,e)))})(t,f),Dg(t,f),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((t=>e(t.id))),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;e<r;e+=1)cg(t,"borderLeft","_bl",n,i,e),cg(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach((t=>e(t.id)))})(t),a&&((t,e)=>{const n=t.getAllNodes().filter((e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})),r=n.map((t=>t.data.rank)),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))}))})(t,o),((t,e)=>{const n=ig(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=Og(t,r,"in"),a=Og(t,i,"out");let s=Mg(t);Rg(t,s);let c,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){_g(n%2?o:a,n%4>=2,!1,e),s=ng(t);const i=wg(t,s);i<u&&(r=0,c=Jt(s),u=i)}s=Mg(t),Rg(t,s);for(let n=0,r=0;r<4;++n,++r){_g(n%2?o:a,n%4>=2,!0,e),s=ng(t);const i=wg(t,s);i<u&&(r=0,c=Jt(s),u=i)}Rg(t,c)})(t,a),Am(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||ug(t)})(t,i),Wg(t,{align:s,nodesep:c,edgesep:u,ranksep:l}),Om(t),Pm(t),((t,e)=>{e.forEach((e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let a=e;for(;n.data.dummy;)o=t.getSuccessors(a)[0],t.removeNode(a),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===yg&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),a=o.id,n=t.getNode(a)}))})(t,f),Cm(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||hg(t),"lr"!==n&&"rl"!==n||(fg(t),ug(t))})(t,i);const{width:p,height:g}=Nm(t);return Sm(t),Tm(t),(t=>{t.getAllEdges().forEach((e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}}))})(t),{width:p,height:g}},dm=(t,e)=>{t.getAllNodes().forEach((n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder}))},fm=(t,e)=>{t.getAllNodes().forEach((n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}})),t.getAllEdges().forEach((n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)}))},pm=["width","height","layer","fixorder"],gm={width:0,height:0},mm=["minlen","weight","width","height","labeloffset"],vm={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},ym=["labelpos"],bm=t=>{const e=new Gp({tree:[]});return t.getAllNodes().forEach((n=>{const r=Rm(t.getNode(n.id).data),i=Object.assign(Object.assign({},gm),r),o=_m(i,pm);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const a=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);kt(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=Rm(t.getEdge(n.id).data),i={};null==ym||ym.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},vm,_m(r,mm),i)})})),e},xm=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach((t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2},Em=t=>{t.getAllEdges().forEach((e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};Jp(t,"edge-proxy",r,"_ep")}}))},wm=t=>{let e=0;return t.getAllNodes().forEach((n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))})),e},Mm=t=>{t.getAllNodes().forEach((e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Nm=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}=e||{},c=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,c=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(a)||isNaN(c)||(void 0===r&&(r=a-c/2),r=Math.min(r,a-c/2),o=Math.max(o,a+c/2))};return t.getAllNodes().forEach((t=>{c(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&c(t)})),n-=a,r-=s,t.getAllNodes().forEach((t=>{t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>{t.x-=n,t.y-=r})),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)})),{width:i-n+a,height:o-r+s}},Sm=t=>{t.getAllEdges().forEach((e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(eg(n.data,i)),e.data.points.push(eg(r.data,o))}))},Cm=t=>{t.getAllEdges().forEach((t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},Tm=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Pm=t=>{t.getAllNodes().forEach((e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),a=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),c=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==c?void 0:c.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==a?void 0:a.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}})),t.getAllNodes().forEach((e=>{"border"===e.data.dummy&&t.removeNode(e.id)}))},km=t=>{t.getAllEdges().forEach((e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},Am=t=>{const e=ng(t);null==e||e.forEach((e=>{let n=0;null==e||e.forEach(((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((e=>{Jp(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},Om=t=>{t.getAllNodes().forEach((e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,a=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{y:o,x:i+a},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}}))},_m=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},Rm=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},Dm=Array.isArray,Im=t=>{const e=[],n=t.length;for(let r=0;r<n;r+=1){e[r]=[];for(let i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(let t=0;t<n;t+=1)for(let r=0;r<n;r+=1)for(let i=0;i<n;i+=1)e[r][i]>e[r][t]+e[t][i]&&(e[r][i]=e[r][t]+e[t][i]);return e},Lm=(t,e)=>{const{nodes:n,edges:r}=t,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach(((t,e)=>{o[t.id]=e;i.push([])})),null==r||r.forEach((t=>{const{source:n,target:r}=t,a=o[n],s=o[r];void 0!==a&&void 0!==s&&(i[a][s]=1,e||(i[s][a]=1))})),i},jm=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),zm=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let c=0;c<e.length;c++){const u=e[c];if(t.hasNode(u.id)&&!(null==a?void 0:a(u))){if(null==s?void 0:s(u))return;"TB"===r&&n(u),zm(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},Bm=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>Bm(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=Bm(t[n])})),e}return t},Fm=(t,e)=>{const n=Bm(t);return n.data=n.data||{},e&&(Wt(n.data.x)||(n.data.x=Math.random()*e[0]),Wt(n.data.y)||(n.data.y=Math.random()*e[1])),n};function Gm(t,e){let n;return n=Pt(e)?e:Wt(e)?()=>e:()=>t,n}function Vm(t,e,n=!0){return e||0===e?Pt(e)?e:Wt(e)?()=>e:Array.isArray(e)?()=>{if(n){const n=Math.max(...e);return isNaN(n)?t:n}return e}:Rt(e)?()=>{if(n){const n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:()=>t:e=>{const{size:n}=e.data||{};return n?Array.isArray(n)?n[0]>n[1]?n[0]:n[1]:Rt(n)?n.width>n.height?n.width:n.height:n:t}}const Wm=(t,e)=>{let n,r;return r=Wt(e)?()=>e:Pt(e)?e:()=>0,n=t?Array.isArray(t)?e=>(t[0]>t[1]?t[0]:t[1])+r(e):Pt(t)?t:e=>t+r(e):t=>{var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);const e=t.data.size;if(Rt(e)){return(e.width>e.height?e.width:e.height)+r(t)}return e+r(t)}return 10+r(t)},n},Um={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};const Hm=(t,e,n,r,i,o,a)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:c}=e.data,{x:u,y:l}=n.data;if(i&&(t=e.data.y,c=e.data.x,u=n.data.y,l=n.data.x),l!==c&&t!==u){const h=r.indexOf(c),d=r[h+1];if(d){const t=s[0],e=i?{x:(c+d)/2,y:(null==t?void 0:t.y)||u}:{x:(null==t?void 0:t.x)||u,y:(c+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(l),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(c+l)/2,y:t}:{x:t,y:(c+l)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(l+e)/2,y:(null==n?void 0:n.y)||u}:{x:(null==n?void 0:n.x)||t,y:(l+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},$m=(t,e,n)=>{const r=t.getAllNodes(),i=t.getAllEdges();if(!(null==r?void 0:r.length)){return{nodes:[],edges:i}}if(1===r.length){e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]});return{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:n[0],y:n[1]})})],edges:i}}},qm={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};const Ym=(t,e,n=!1)=>{const r=[Fm(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,c)=>{if(0!==c)if(c!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[c+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const c=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let u=!1;for(let e=0;e<c.length;e++){const n=c[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(Fm(n)),i[n.id]=!0,u=!0;break}}let l=0;for(;!u&&(i[e[l].id]||(r.push(Fm(e[l])),i[e[l].id]=!0,u=!0),l++,l!==o););}else r.push(Fm(s)),i[s.id]=!0,a++})),r};const Km=(t,e,n)=>{let r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},Xm={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Zm{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Xm),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:c,sweep:u,clockwise:l,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,m=e.getAllNodes(),v=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[y/2,b/2];if(!(null==m?void 0:m.length)||1===m.length)return $m(e,t,x);const E=[];let w,M=0;Dm(p)?w=Math.max(p[0],p[1]):Pt(p)?(w=-1/0,m.forEach((t=>{const e=p(t);e>w&&(w=e)}))):w=p,Dm(g)?M=Math.max(g[0],g[1]):Wt(g)&&(M=g),m.forEach((t=>{const e=Fm(t);E.push(e);let n=w;const{data:r}=e;Dm(r.size)?n=Math.max(r.size[0],r.size[1]):Wt(r.size)?n=r.size:Rt(r.size)&&(n=Math.max(r.size.width,r.size.height)),w=Math.max(w,n),Pt(g)&&(M=Math.max(g(t),M))}));const N={};E.forEach(((t,e)=>{N[t.id]=e}));let S=s;Bt(S)&&void 0!==E[0].data[S]||(S="degree"),"degree"===S?E.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):E.sort(((t,e)=>e.data[S]-t.data[S]));const C=E[0],T=(c||("degree"===S?e.getDegree(C.id,"both"):C.data[S]))/4,P=[{nodes:[]}];let k=P[0];E.forEach((t=>{if(k.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(k.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(k.nodes[0].data[S]-t.data[S]);T&&n>=T&&(k={nodes:[]},P.push(k))}k.nodes.push(t)}));let A=w+M;if(!d){const t=P.length>0&&P[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(P.length+(t?1:0));A=Math.min(A,e)}let O=0;if(P.forEach((t=>{const e=void 0===u?2*Math.PI-2*Math.PI/t.nodes.length:u;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){const e=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),r=Math.sqrt(A*A/(e*e+n*n));O=Math.max(r,O)}t.r=O,O+=A})),h){let t=0,e=0;for(let n=0;n<P.length;n++){const r=(P[n].r||0)-e;t=Math.max(t,r)}e=0,P.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}P.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(l?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&E.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:E,edges:v}}))}}function Qm(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,c,u,l,h,d,f=t._root,p={data:r},g=t._x0,m=t._y0,v=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((u=e>=(o=(g+v)/2))?g=o:v=o,(l=n>=(a=(m+y)/2))?m=a:y=a,i=f,!(f=f[h=l<<1|u]))return i[h]=p,t;if(s=+t._x.call(null,f.data),c=+t._y.call(null,f.data),e===s&&n===c)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(u=e>=(o=(g+v)/2))?g=o:v=o,(l=n>=(a=(m+y)/2))?m=a:y=a}while((h=l<<1|u)==(d=(c>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Jm(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function tv(t){return t[0]}function ev(t){return t[1]}function nv(t,e,n){var r=new rv(null==e?tv:e,null==n?ev:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function rv(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function iv(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var ov=nv.prototype=rv.prototype;function av(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,c,u,l,h,d,f,p,g,m,v=t._root,y={data:i},b=t._x0,x=t._y0,E=t._z0,w=t._x1,M=t._y1,N=t._z1;if(!v)return t._root=y,t;for(;v.length;)if((d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+M)/2))?x=s:M=s,(p=r>=(c=(E+N)/2))?E=c:N=c,o=v,!(v=v[g=p<<2|f<<1|d]))return o[g]=y,t;if(u=+t._x.call(null,v.data),l=+t._y.call(null,v.data),h=+t._z.call(null,v.data),e===u&&n===l&&r===h)return y.next=v,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+M)/2))?x=s:M=s,(p=r>=(c=(E+N)/2))?E=c:N=c}while((g=p<<2|f<<1|d)==(m=(h>=c)<<2|(l>=s)<<1|u>=a));return o[m]=v,o[g]=y,t}function sv(t,e,n,r,i,o,a){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=a}function cv(t){return t[0]}function uv(t){return t[1]}function lv(t){return t[2]}function hv(t,e,n,r){var i=new dv(null==e?cv:e,null==n?uv:n,null==r?lv:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function dv(t,e,n,r,i,o,a,s,c){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=c,this._root=void 0}function fv(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}ov.copy=function(){var t,e,n=new rv(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=iv(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=iv(e));return n},ov.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Qm(this.cover(e,n),e,n,t)},ov.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),c=1/0,u=1/0,l=-1/0,h=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<c&&(c=r),r>l&&(l=r),i<u&&(u=i),i>h&&(h=i));if(c>l||u>h)return this;for(this.cover(c,u).cover(l,h),n=0;n<o;++n)Qm(this,a[n],s[n],t[n]);return this},ov.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,c=i-n||1,u=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=u,u=a,c*=2,s){case 0:i=n+c,o=r+c;break;case 1:n=i-c,o=r+c;break;case 2:i=n+c,r=o-c;break;case 3:n=i-c,r=o-c}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},ov.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},ov.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},ov.find=function(t,e,n){var r,i,o,a,s,c,u,l=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Jm(g,l,h,d,f)),null==n?n=1/0:(l=t-n,h=e-n,d=t+n,f=e+n,n*=n);c=p.pop();)if(!(!(g=c.node)||(i=c.x0)>d||(o=c.y0)>f||(a=c.x1)<l||(s=c.y1)<h))if(g.length){var m=(i+a)/2,v=(o+s)/2;p.push(new Jm(g[3],m,v,a,s),new Jm(g[2],i,v,m,s),new Jm(g[1],m,o,a,v),new Jm(g[0],i,o,m,v)),(u=(e>=v)<<1|t>=m)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-u],p[p.length-1-u]=c)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=y*y+b*b;if(x<n){var E=Math.sqrt(n=x);l=t-E,h=e-E,d=t+E,f=e+E,r=g.data}}return r},ov.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,c,u,l,h,d,f=this._root,p=this._x0,g=this._y0,m=this._x1,v=this._y1;if(!f)return this;if(f.length)for(;;){if((u=o>=(s=(p+m)/2))?p=s:m=s,(l=a>=(c=(g+v)/2))?g=c:v=c,e=f,!(f=f[h=l<<1|u]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},ov.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},ov.root=function(){return this._root},ov.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},ov.visit=function(t){var e,n,r,i,o,a,s=[],c=this._root;for(c&&s.push(new Jm(c,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&c.length){var u=(r+o)/2,l=(i+a)/2;(n=c[3])&&s.push(new Jm(n,u,l,o,a)),(n=c[2])&&s.push(new Jm(n,r,l,u,a)),(n=c[1])&&s.push(new Jm(n,u,i,o,l)),(n=c[0])&&s.push(new Jm(n,r,i,u,l))}return this},ov.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Jm(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,c=e.x1,u=e.y1,l=(a+c)/2,h=(s+u)/2;(o=i[0])&&n.push(new Jm(o,a,s,l,h)),(o=i[1])&&n.push(new Jm(o,l,s,c,h)),(o=i[2])&&n.push(new Jm(o,a,h,l,u)),(o=i[3])&&n.push(new Jm(o,l,h,c,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},ov.x=function(t){return arguments.length?(this._x=t,this):this._x},ov.y=function(t){return arguments.length?(this._y=t,this):this._y};var pv=hv.prototype=dv.prototype;pv.copy=function(){var t,e,n=new dv(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=fv(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=fv(e));return n},pv.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return av(this.cover(e,n,r),e,n,r,t)},pv.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,c=-1/0,u=-1/0,l=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>c&&(c=d),f<a&&(a=f),f>u&&(u=f),p<s&&(s=p),p>l&&(l=p));if(o>c||a>u||s>l)return this;this.cover(o,a,s).cover(c,u,l);for(let o=0;o<e;++o)av(this,n[o],r[o],i[o],t[o]);return this},pv.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,c=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,c=(o=Math.floor(n))+1;else{for(var u,l,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=c;)switch(l=(n<o)<<2|(e<i)<<1|t<r,(u=new Array(8))[l]=d,d=u,h*=2,l){case 0:a=r+h,s=i+h,c=o+h;break;case 1:r=a-h,s=i+h,c=o+h;break;case 2:a=r+h,i=s-h,c=o+h;break;case 3:r=a-h,i=s-h,c=o+h;break;case 4:a=r+h,s=i+h,o=c-h;break;case 5:r=a-h,s=i+h,o=c-h;break;case 6:a=r+h,i=s-h,o=c-h;break;case 7:r=a-h,i=s-h,o=c-h}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=c,this},pv.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},pv.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},pv.find=function(t,e,n,r){var i,o,a,s,c,u,l,h,d,f=this._x0,p=this._y0,g=this._z0,m=this._x1,v=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new sv(x,f,p,g,m,v,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,m=t+r,v=e+r,y=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>m||(a=h.y0)>v||(s=h.z0)>y||(c=h.x1)<f||(u=h.y1)<p||(l=h.z1)<g))if(x.length){var E=(o+c)/2,w=(a+u)/2,M=(s+l)/2;b.push(new sv(x[7],E,w,M,c,u,l),new sv(x[6],o,w,M,E,u,l),new sv(x[5],E,a,M,c,w,l),new sv(x[4],o,a,M,E,w,l),new sv(x[3],E,w,s,c,u,M),new sv(x[2],o,w,s,E,u,M),new sv(x[1],E,a,s,c,w,M),new sv(x[0],o,a,s,E,w,M)),(d=(n>=M)<<2|(e>=w)<<1|t>=E)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var N=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),C=n-+this._z.call(null,x.data),T=N*N+S*S+C*C;if(T<r){var P=Math.sqrt(r=T);f=t-P,p=e-P,g=n-P,m=t+P,v=e+P,y=n+P,i=x.data}}return i},pv.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,c,u,l,h,d,f,p,g,m=this._root,v=this._x0,y=this._y0,b=this._z0,x=this._x1,E=this._y1,w=this._z1;if(!m)return this;if(m.length)for(;;){if((h=o>=(c=(v+x)/2))?v=c:x=c,(d=a>=(u=(y+E)/2))?y=u:E=u,(f=s>=(l=(b+w)/2))?b=l:w=l,e=m,!(m=m[p=f<<2|d<<1|h]))return this;if(!m.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;m.data!==t;)if(r=m,!(m=m.next))return this;return(i=m.next)&&delete m.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(m=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&m===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!m.length&&(n?n[g]=m:this._root=m),this):(this._root=i,this)},pv.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},pv.root=function(){return this._root},pv.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},pv.visit=function(t){var e,n,r,i,o,a,s,c,u=[],l=this._root;for(l&&u.push(new sv(l,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=u.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,c=e.z1)&&l.length){var h=(r+a)/2,d=(i+s)/2,f=(o+c)/2;(n=l[7])&&u.push(new sv(n,h,d,f,a,s,c)),(n=l[6])&&u.push(new sv(n,r,d,f,h,s,c)),(n=l[5])&&u.push(new sv(n,h,i,f,a,d,c)),(n=l[4])&&u.push(new sv(n,r,i,f,h,d,c)),(n=l[3])&&u.push(new sv(n,h,d,o,a,s,f)),(n=l[2])&&u.push(new sv(n,r,d,o,h,s,f)),(n=l[1])&&u.push(new sv(n,h,i,o,a,d,f)),(n=l[0])&&u.push(new sv(n,r,i,o,h,d,f))}return this},pv.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new sv(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,c=e.z0,u=e.x1,l=e.y1,h=e.z1,d=(a+u)/2,f=(s+l)/2,p=(c+h)/2;(o=i[0])&&n.push(new sv(o,a,s,c,d,f,p)),(o=i[1])&&n.push(new sv(o,d,s,c,u,f,p)),(o=i[2])&&n.push(new sv(o,a,f,c,d,l,p)),(o=i[3])&&n.push(new sv(o,d,f,c,u,l,p)),(o=i[4])&&n.push(new sv(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new sv(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new sv(o,a,f,p,d,l,h)),(o=i[7])&&n.push(new sv(o,d,f,p,u,l,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},pv.x=function(t){return arguments.length?(this._x=t,this):this._x},pv.y=function(t){return arguments.length?(this._y=t,this):this._y},pv.z=function(t){return arguments.length?(this._z=t,this):this._z};function gv(t,e,n,r,i=2){const o=e/n,a=t.getAllNodes(),s=a.map(((t,e)=>{const{nodeStrength:n,x:r,y:i,z:a,size:s}=t.data;return{x:r,y:i,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n}})),c=(2===i?nv(s,(t=>t.x),(t=>t.y)):hv(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(mv),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>vv(e,r,i,o,a,t,n)))}(t,c,i)})),s.map(((t,e)=>{const{id:n,data:i}=a[e],{mass:o=1}=i;r[n]={x:t.vx/o,y:t.vy/o,z:t.vz/o}})),r}function mv(t){let e=0,n=0,r=0,i=0,o=0;const a=t.length;if(a){for(let s=0;s<a;s++){const a=t[s];a&&a.weight&&(e+=a.weight,n+=a.x*a.weight,r+=a.y*a.weight,i+=a.z*a.weight,o+=a.size*a.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const vv=(t,e,n,r,i,o,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===o.id)return;const c=[n,r,i][a-1],u=o.x-t.x||.1,l=o.y-t.y||.1,h=o.z-t.z||.1,d=[u,l,h],f=c-e;let p=0;for(let t=0;t<a;t++)p+=d[t]*d[t];const g=Math.sqrt(p)*p;if(f*f*.81<p){const e=t.weight/g;return o.vx+=u*e,o.vy+=l*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=u*e,o.vy+=l*e,o.vz+=h*e}};const yv={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"};class bv{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},yv),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericForceLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;(this.judgingDistance>this.lastOptions.minMovement||e<1)&&e<t;e++)this.runOneStep(this.lastCalcGraph,this.lastGraph,e,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),{dimensions:s,width:c,height:u,nodeSize:l,getMass:h,nodeStrength:d,edgeStrength:f,linkDistance:p}=a,g=i.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:Wt(t.data.x)?t.data.x:Math.random()*c,y:Wt(t.data.y)?t.data.y:Math.random()*u,z:Wt(t.data.z)?t.data.z:Math.random()*Math.sqrt(c*u),size:l(t)||30,mass:h(t),nodeStrength:d(t)})}))),m=o.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:f(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})));if(!(null==i?void 0:i.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const v={};i.forEach(((t,e)=>{v[t.id]={x:0,y:0,z:0}}));const y=new Gp({nodes:g,edges:m});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:x,onTick:E}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=v,"undefined"==typeof window)return;let w=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Nv(e,g),edges:o}),this.runOneStep(y,e,w,v,a),this.updatePosition(e,y,v,a),t&&g.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==E||E({nodes:Nv(e,g),edges:o}),w++,(w>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:Nv(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o,nodeSize:a}=t;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),o||(n.getMass=t=>{let n=1;Wt(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);const r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n});const s=Gm(0,t.nodeSpacing);let c;c=a?Pt(a)?t=>a(t)+s(t):Dm(a)?t=>{const e=a;return Math.max(e[0],e[1])+s(t)}:t=>a+s(t):t=>{const{size:e}=(null==t?void 0:t.data)||{};return e?Dm(e)?Math.max(e[0],e[1])+s(t):Rt(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)},n.nodeSize=c;const u=t.linkDistance?Gm(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=u,n.nodeStrength=Gm(1,t.nodeStrength),n.edgeStrength=Gm(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:c}=t,u=e.getAllNodes(),l=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&c&&(h=xv(e,c),d=Array.from(new Set(null==u?void 0:u.map((t=>t.data[c]))))||[],t.centripetalOptions=Object.assign(l,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==d?void 0:d.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const n=e.getDegree(t.id,"both");if(!n)return{x:100,y:100,z:0};let r;if(1===n){const{sameTypeLeaves:e=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Mv(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),s&&c){h||(h=xv(e,c)),d||(d=Array.from(new Set(u.map((t=>t.data[c]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=u.filter((e=>e.data[c]===t)).map((t=>e.getNode(t.id)));n[t]=Mv(r)})),t.centripetalOptions=Object.assign(l,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[c]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:f,single:p,others:g}=t.centripetalOptions||{};f&&"function"!=typeof f&&(t.centripetalOptions.leaf=()=>f),p&&"function"!=typeof p&&(t.centripetalOptions.single=()=>p),g&&"function"!=typeof g&&(t.centripetalOptions.others=()=>g)}runOneStep(t,e,n,r,i){const o={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:c}=i;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),c){c({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let n=0;return e.forEach(((e,r)=>{const i=t[e.id].x,o=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=i*i+o*o+a*a,{mass:c=1}=e.data;n+=c*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;gv(t,i,o*o,e,r)}calAttractive(t,e,n){const{dimensions:r,nodeSize:i}=n;t.getAllEdges().forEach(((n,o)=>{const{source:a,target:s}=n,c=t.getNode(a),u=t.getNode(s);if(!c||!u)return;let l=u.data.x-c.data.x,h=u.data.y-c.data.y,d=3===r?u.data.z-c.data.z:0;l||h||(l=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(l*l+h*h+d*d);if(f<i(c)+i(u))return;const p=l/f,g=h/f,m=d/f,{linkDistance:v=200,edgeStrength:y=200}=n.data||{},b=(v-f)*y,x=1/(c.data.mass||1),E=1/(u.data.mass||1),w=p*b,M=g*b,N=m*b;e[a].x-=w*x,e[a].y-=M*x,e[a].z-=N*x,e[s].x+=w*E,e[s].y+=M*E,e[s].z+=N*E}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:c,height:u,center:l,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:m,z:v}=f,y=e.getNode(o);let b=0,x=0,E=0,w=h;const M=t.getDegree(o,"in"),N=t.getDegree(o,"out"),S=t.getDegree(o,"both"),C=null==i?void 0:i(y,S);if(C){const[t,e,n]=C;b=g-t,x=m-e,w=n}else b=g-l[0],x=m-l[1],E=v-l[2];if(w&&(n[o].x-=w*b/p,n[o].y-=w*x/p,n[o].z-=w*E/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:l,y:h,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,c,u))||{x:0,y:0,z:0,centerStrength:0};if(!Wt(l)||!Wt(h))return;const x=(g-l)/p,E=(m-h)/p,w=(v-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*E,n[o].z-=b*w),0===S){const t=e(y);if(!t)return;return n[o].x-=t*x,n[o].y-=t*E,void(n[o].z-=t*w)}if(0===M||0===N){const e=t(y,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*E,void(n[o].z-=e*w)}const C=r(y);if(!C)return;n[o].x-=C*x,n[o].y-=C*E,n[o].z-=C*w}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,c=t.getAllNodes();(null==c?void 0:c.length)&&c.forEach((t=>{const{id:r}=t;let c=(n[r].x+e[r].x*a)*i||.01,u=(n[r].y+e[r].y*a)*i||.01,l=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(c*c+u*u+l*l);if(h>o){const t=o/h;c*=t,u*=t,l*=t}n[r]={x:c,y:u,z:l}}))}updatePosition(t,e,n,r){const{distanceThresholdMode:i,interval:o,dimensions:a}=r,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let c=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,u=t.getNode(s);if(Wt(u.data.fx)&&Wt(u.data.fy))return void e.mergeNodeData(s,{x:u.data.fx,y:u.data.fy,z:3===a?u.data.fz:void 0});const l=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+l,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(l*l+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:c+=f}})),i&&"mean"!==i||(this.judgingDistance=c/s.length)}}const xv=(t,e)=>{const n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};const r={};return n.forEach(((n,i)=>{1===t.getDegree(n.id,"both")&&(r[n.id]=Ev(t,"leaf",n,e))})),r},Ev=(t,e,n,r)=>{const i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out");let a=n,s=[];0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:wv(t,e,r,n,s)}},wv=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return"leaf"===e&&(a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")))),a},Mv=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:n,y:r}=t.data;e.x+=n||0,e.y+=r||0}));const n=t.length||1;return{x:e.x/n,y:e.y/n}},Nv=(t,e)=>e.map((e=>{const{id:n,data:r}=e,i=t.getNode(n);return Object.assign(Object.assign({},i),{data:Object.assign(Object.assign({},i.data),{x:r.x,y:r.y,z:r.z})})}));var Sv={};const Cv=Object.prototype.toString;function Tv(t){const e=Cv.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Pv=p(Object.freeze({__proto__:null,isAnyArray:Tv}));var kv=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Tv(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!Tv(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Tv(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Tv(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]>a&&(a=t[s]);return a}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,a=void 0===o?n.autoMinMax?r:0:o,s=n.max,c=void 0===s?n.autoMinMax?i:1:s;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var u=(c-a)/(i-r),l=0;l<t.length;l++)e[l]=(t[l]-r)*u+a;return e}}),Av=p(kv);Object.defineProperty(Sv,"__esModule",{value:!0});var Ov=Pv,_v=Av;const Rv=" ".repeat(2),Dv=" ".repeat(4);function Iv(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${Rv}[\n${Dv}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),c=Math.min(a,n),u=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<c;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<c;o++)n.push(Lv(t.get(e,o),r,i));u.push(`${n.join(" ")}`)}c!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);s!==o&&u.push(`... ${o-e} more rows`);return u.join(`\n${Dv}`)}(t,n,r,i,o)}\n${Rv}]\n${Rv}rows: ${t.rows}\n${Rv}columns: ${t.columns}\n}`}function Lv(t,e,n){return(t>=0&&n?` ${jv(t,e-1)}`:jv(t,e)).padEnd(e)}function jv(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function zv(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Bv(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function Fv(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function Gv(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function Vv(t,e){if(!Ov.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function Wv(t,e){if(!Ov.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function Uv(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if($v("startRow",e),$v("endRow",n),$v("startColumn",r),$v("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function Hv(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function $v(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function qv(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Yv{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Xv(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new Xv(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new Xv(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new Xv(t,e)}static ones(t,e){return new Xv(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new Xv(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new Xv(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new Xv(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return Yv.isMatrix(t)?t:new Xv(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new Xv(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){zv(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Xv.rowVector(this.getRow(t))}setRow(t,e){zv(this,t),e=Fv(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){zv(this,t),zv(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){Bv(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Xv.columnVector(this.getColumn(t))}setColumn(t,e){Bv(this,t),e=Gv(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){Bv(this,t),Bv(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=Fv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=Fv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=Fv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=Fv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=Gv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=Gv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=Gv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=Gv(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){zv(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){Bv(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){qv(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){qv(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(zv(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){zv(this,t),qv(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(zv(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){zv(this,t),qv(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(Bv(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){Bv(this,t),qv(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(Bv(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){Bv(this,t),qv(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){Yv.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=Xv.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Xv(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}strassen2x2(t){t=Xv.checkMatrix(t);let e=new Xv(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),a=this.get(1,0),s=t.get(1,0),c=this.get(1,1),u=t.get(1,1),l=(n+c)*(r+u),h=(a+c)*r,d=n*(o-u),f=c*(s-r),p=(n+i)*u,g=l+f-p+(i-c)*(s+u),m=d+p,v=h+f,y=l-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,m),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=Xv.checkMatrix(t);let e=new Xv(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),a=this.get(1,1),s=this.get(1,2),c=this.get(2,0),u=this.get(2,1),l=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),m=t.get(1,2),v=t.get(2,0),y=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),E=(-n+o+a)*(h-d+g),w=(o+a)*(-h+d),M=n*h,N=(-n+c+u)*(h-f+m),S=(-n+c)*(f-m),C=(c+u)*(-h+f),T=(-i+u+l)*(g+v-y),P=(i-l)*(g-y),k=i*v,A=(u+l)*(-v+y),O=(-i+a+s)*(m+v-b),_=(i-s)*(m-b),R=(a+s)*(-v+b),D=M+k+r*p,I=(n+r+i-o-a-u-l)*g+E+w+M+T+k+A,L=M+N+C+(n+r+i-a-s-c-u)*m+k+O+R,j=x+a*(-h+d+p-g-m-v+b)+E+M+k+O+_,z=x+E+w+M+s*y,B=k+O+_+R+o*f,F=M+N+S+u*(-h+f+p-g-m-v+y)+T+P+k,G=T+P+k+A+c*d,V=M+N+S+C+l*b;return e.set(0,0,D),e.set(0,1,I),e.set(0,2,L),e.set(1,0,j),e.set(1,1,z),e.set(1,2,B),e.set(2,0,F),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=Xv.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function a(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=Yv.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),c=Math.max(r,o);return e=a(e,s,c),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=a(e,r+1,i+1),n=a(n,r+1,i+1)):r%2==1?(e=a(e,r+1,i),n=a(n,r+1,i)):i%2==1&&(e=a(e,r,i+1),n=a(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),c=e.subMatrix(0,o-1,0,s-1),u=n.subMatrix(0,o-1,0,s-1),l=e.subMatrix(0,o-1,s,e.columns-1),h=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),m=t(Yv.add(c,p),Yv.add(u,g),o,s),v=t(Yv.add(d,p),u,o,s),y=t(c,Yv.sub(h,g),o,s),b=t(p,Yv.sub(f,u),o,s),x=t(Yv.add(c,l),g,o,s),E=t(Yv.sub(d,c),Yv.add(u,h),o,s),w=t(Yv.sub(l,p),Yv.add(f,g),o,s),M=Yv.add(m,b);M.sub(x),M.add(w);let N=Yv.add(y,x),S=Yv.add(v,b),C=Yv.sub(m,v);C.add(y),C.add(E);let T=Yv.zeros(2*M.rows,2*M.columns);return T=T.setSubMatrix(M,0,0),T=T.setSubMatrix(N,M.rows,0),T=T.setSubMatrix(S,0,M.columns),T=T.setSubMatrix(C,M.rows,M.columns),T.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,c),s,c)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Xv(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&_v(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Xv(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&_v(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=Xv.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Xv(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=Xv.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(Xv.eye(n,n)),i=Xv.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Xv(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=Kv){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Kv){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){Uv(this,t,e,n,r);let i=new Xv(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new Xv(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);r.set(i,o-e,this.get(t[i],o))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new Xv(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);r.set(o-e,i,this.get(o,t[i]))}return r}setSubMatrix(t,e,n){if((t=Xv.checkMatrix(t)).isEmpty())return this;Uv(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){Vv(this,t),Wv(this,e);let n=new Xv(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new Xv(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=Hv(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=Hv(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=Hv(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=Hv(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Ov.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,c=0;for(let e=0;e<i;e++)c=t.get(a,e)-n[a],r+=c,s+=c*c;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!Ov.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,c=0;for(let e=0;e<r;e++)c=t.get(e,a)-n[a],i+=c,s+=c*c;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,c=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)c=t.get(e,r)-n,a+=c,s+=c*c;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!Ov.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!Ov.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!Ov.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!Ov.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=Math.pow(t.get(i,r),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return Iv(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function Kv(t,e){return t-e}Yv.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Yv.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Iv(this)}),Yv.random=Yv.rand,Yv.randomInt=Yv.randInt,Yv.diagonal=Yv.diag,Yv.prototype.diagonal=Yv.prototype.diag,Yv.identity=Yv.eye,Yv.prototype.negate=Yv.prototype.neg,Yv.prototype.tensorProduct=Yv.prototype.kroneckerProduct;let Xv=class t extends Yv{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!Ov.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return zv(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),zv(this,t,!0),e=Float64Array.from(Fv(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Bv(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),Bv(this,t,!0),e=Gv(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(Yv,Xv);class Zv extends Yv{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return Xv.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),Xv.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=Xv.copy(t,new Xv(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new Xv(t,t);else if(this.#e=new Xv(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Zv(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new Xv(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const r=new Zv(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}Zv.prototype.klassType="SymmetricMatrix";class Qv extends Zv{static isDistanceMatrix(t){return Zv.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new Zv(this)}clone(){const t=new Qv(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}Qv.prototype.klassSubType="DistanceMatrix";class Jv extends Yv{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class ty extends Jv{constructor(t,e,n){Vv(t,e),Wv(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class ey extends Yv{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class ny extends Yv{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class ry{constructor(t){let e,n,r,i,o,a,s,c,u,l=(t=ny.checkMatrix(t)).clone(),h=l.rows,d=l.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(c=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)c[e]=l.get(e,n);for(e=0;e<h;e++){for(u=Math.min(e,n),o=0,r=0;r<u;r++)o+=l.get(e,r)*c[r];c[e]-=o,l.set(e,n,c[e])}for(i=n,e=n+1;e<h;e++)Math.abs(c[e])>Math.abs(c[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=l.get(i,r),l.set(i,r,l.get(n,r)),l.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==l.get(n,n))for(e=n+1;e<h;e++)l.set(e,n,l.get(e,n)/l.get(n,n))}this.LU=l,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=Xv.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Xv(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Xv(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function iy(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class oy{constructor(t){let e,n,r,i,o=(t=ny.checkMatrix(t)).clone(),a=t.rows,s=t.columns,c=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=iy(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}c[r]=-t}this.QR=o,this.Rdiag=c}solve(t){t=Xv.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,c=t.clone(),u=e.columns;for(o=0;o<u;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*c.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)c.set(r,i,c.get(r,i)+a*e.get(r,o))}for(o=u-1;o>=0;o--){for(i=0;i<s;i++)c.set(o,i,c.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)c.set(r,i,c.get(r,i)-c.get(o,i)*e.get(r,o))}return c.subMatrix(0,u-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new Xv(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new Xv(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let ay=class{constructor(t,e={}){if((t=ny.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,c=Boolean(i),u=Boolean(o),l=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,l=!0;let e=c;c=u,u=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new Xv(n,h),g=new Xv(r,r),m=new Float64Array(r),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),E=Math.max(b,x);for(let t=0;t<E;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=iy(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<b&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}m[e]=s.get(t,e)}if(c&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<r;e++)m[t]=iy(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<r;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<n&&0!==m[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)v[e]+=m[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-m[e]/m[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*v[i])}}if(u)for(let e=t+1;e<r;e++)g.set(e,t,m[e])}}let w=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<w&&(f[w-1]=0),x+1<w&&(m[x]=s.get(x,w-1)),m[w-1]=0,c){for(let t=b;t<h;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(u)for(let t=r-1;t>=0;t--){if(t<x&&0!==m[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let M=w-1,N=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+N*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(m[n]):0)+(n!==t+1?Math.abs(m[n-1]):0);if(Math.abs(f[n])<=N*e){f[n]=0;break}}n===t?e=3:n===w-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[w-2];m[w-2]=0;for(let n=w-2;n>=t;n--){let i=iy(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*m[n-1],m[n-1]=o*m[n-1]),u)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,w-1),g.set(t,w-1,-a*g.get(t,n)+o*g.get(t,w-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<w;r++){let i=iy(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*m[r],m[r]=o*m[r],c)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[w-1]),Math.abs(f[w-2]),Math.abs(m[w-2]),Math.abs(f[t]),Math.abs(m[t])),i=f[w-1]/e,o=f[w-2]/e,a=m[w-2]/e,s=f[t]/e,l=m[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let v=0;0===h&&0===d||(v=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),v=d/(h+v));let y=(s+i)*(s-i)+v,b=s*l;for(let e=t;e<w-1;e++){let i=iy(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(m[e-1]=i),y=o*f[e]+a*m[e],m[e]=o*m[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],u)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=iy(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*m[e]+a*f[e+1],f[e+1]=-a*m[e]+o*f[e+1],b=a*m[e+1],m[e+1]=o*m[e+1],c&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}m[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,u))for(let e=0;e<=M;e++)g.set(e,t,-g.get(e,t));for(;t<M&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(c&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}w--}}if(l){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=Xv.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),c=a.rows,u=o.rows,l=Xv.zeros(c,u);for(let t=0;t<c;t++)for(let e=0;e<u;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);l.set(t,e,n)}return l.mmul(e)}solveForDiagonal(t){return this.solve(Xv.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Xv(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,c=new Xv(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);c.set(t,e,n)}return c}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Xv.diag(this.s)}};function sy(t,e,n=!1){return t=ny.checkMatrix(t),e=ny.checkMatrix(e),n?new ay(t).solve(e):t.isSquare()?new ry(t).solve(e):new oy(t).solve(e)}function cy(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function uy(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class ly{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=ny.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new Xv(o,o),s=new Float64Array(o),c=new Float64Array(o),u=t,l=!1;if(l=!!n||t.isSymmetric(),l){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,c,u,l,h;for(c=0;c<t;c++)n[c]=r.get(t-1,c);for(s=t-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h+=Math.abs(n[u]);if(0===h)for(e[s]=n[s-1],c=0;c<s;c++)n[c]=r.get(s-1,c),r.set(s,c,0),r.set(c,s,0);else{for(u=0;u<s;u++)n[u]/=h,a+=n[u]*n[u];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,c=0;c<s;c++)e[c]=0;for(c=0;c<s;c++){for(i=n[c],r.set(c,s,i),o=e[c]+r.get(c,c)*i,u=c+1;u<=s-1;u++)o+=r.get(u,c)*n[u],e[u]+=r.get(u,c)*i;e[c]=o}for(i=0,c=0;c<s;c++)e[c]/=a,i+=e[c]*n[c];for(l=i/(a+a),c=0;c<s;c++)e[c]-=l*n[c];for(c=0;c<s;c++){for(i=n[c],o=e[c],u=c;u<=s-1;u++)r.set(u,c,r.get(u,c)-(i*e[u]+o*n[u]));n[c]=r.get(s-1,c),r.set(s,c,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(u=0;u<=s;u++)n[u]=r.get(u,s+1)/a;for(c=0;c<=s;c++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,c);for(u=0;u<=s;u++)r.set(u,c,r.get(u,c)-o*n[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(c=0;c<t;c++)n[c]=r.get(t-1,c),r.set(t-1,c,0);r.set(t-1,t-1,1),e[0]=0}(o,c,s,a),function(t,e,n,r){let i,o,a,s,c,u,l,h,d,f,p,g,m,v,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,E=0,w=Number.EPSILON;for(u=0;u<t;u++){for(E=Math.max(E,Math.abs(n[u])+Math.abs(e[u])),l=u;l<t&&!(Math.abs(e[l])<=w*E);)l++;if(l>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=iy(h,1),h<0&&(d=-d),n[u]=e[u]/(h+d),n[u+1]=e[u]*(h+d),f=n[u+1],o=i-n[u],a=u+2;a<t;a++)n[a]-=o;for(x+=o,h=n[l],p=1,g=p,m=p,v=e[u+1],y=0,b=0,a=l-1;a>=u;a--)for(m=g,g=p,b=y,i=p*e[a],o=p*h,d=iy(h,e[a]),e[a+1]=y*d,y=e[a]/d,p=h/d,h=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),c=0;c<t;c++)o=r.get(c,a+1),r.set(c,a+1,y*r.get(c,a)+p*o),r.set(c,a,p*r.get(c,a)-y*o);h=-y*b*m*v*e[u]/f,e[u]=y*h,n[u]=p*h}while(Math.abs(e[u])>w*E);n[u]=n[u]+x,e[u]=0}for(a=0;a<t-1;a++){for(c=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(c=s,h=n[s]);if(c!==a)for(n[c]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,c)),r.set(s,c,h)}}(o,c,s,a)}else{let t=new Xv(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,c,u,l,h=0,d=t-1;for(u=h+1;u<=d-1;u++){for(l=0,s=u;s<=d;s++)l+=Math.abs(e.get(s,u-1));if(0!==l){for(a=0,s=d;s>=u;s--)n[s]=e.get(s,u-1)/l,a+=n[s]*n[s];for(o=Math.sqrt(a),n[u]>0&&(o=-o),a-=n[u]*o,n[u]=n[u]-o,c=u;c<t;c++){for(i=0,s=d;s>=u;s--)i+=n[s]*e.get(s,c);for(i/=a,s=u;s<=d;s++)e.set(s,c,e.get(s,c)-i*n[s])}for(s=0;s<=d;s++){for(i=0,c=d;c>=u;c--)i+=n[c]*e.get(s,c);for(i/=a,c=u;c<=d;c++)e.set(s,c,e.get(s,c)-i*n[c])}n[u]=l*n[u],e.set(u,u-1,l*o)}}for(s=0;s<t;s++)for(c=0;c<t;c++)r.set(s,c,s===c?1:0);for(u=d-1;u>=h+1;u--)if(0!==e.get(u,u-1)){for(s=u+1;s<=d;s++)n[s]=e.get(s,u-1);for(c=u;c<=d;c++){for(o=0,s=u;s<=d;s++)o+=n[s]*r.get(s,c);for(o=o/n[u]/e.get(u,u-1),s=u;s<=d;s++)r.set(s,c,r.get(s,c)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,c,u,l,h,d,f,p,g,m,v,y,b,x=t-1,E=0,w=t-1,M=Number.EPSILON,N=0,S=0,C=0,T=0,P=0,k=0,A=0,O=0;for(o=0;o<t;o++)for((o<E||o>w)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)S+=Math.abs(i.get(o,a));for(;x>=E;){for(c=x;c>E&&(k=Math.abs(i.get(c-1,c-1))+Math.abs(i.get(c,c)),0===k&&(k=S),!(Math.abs(i.get(c,c-1))<M*k));)c--;if(c===x)i.set(x,x,i.get(x,x)+N),n[x]=i.get(x,x),e[x]=0,x--,O=0;else if(c===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),C=(i.get(x-1,x-1)-i.get(x,x))/2,T=C*C+h,A=Math.sqrt(Math.abs(T)),i.set(x,x,i.get(x,x)+N),i.set(x-1,x-1,i.get(x-1,x-1)+N),d=i.get(x,x),T>=0){for(A=C>=0?C+A:C-A,n[x-1]=d+A,n[x]=n[x-1],0!==A&&(n[x]=d-h/A),e[x-1]=0,e[x]=0,d=i.get(x,x-1),k=Math.abs(d)+Math.abs(A),C=d/k,T=A/k,P=Math.sqrt(C*C+T*T),C/=P,T/=P,a=x-1;a<t;a++)A=i.get(x-1,a),i.set(x-1,a,T*A+C*i.get(x,a)),i.set(x,a,T*i.get(x,a)-C*A);for(o=0;o<=x;o++)A=i.get(o,x-1),i.set(o,x-1,T*A+C*i.get(o,x)),i.set(o,x,T*i.get(o,x)-C*A);for(o=E;o<=w;o++)A=r.get(o,x-1),r.set(o,x-1,T*A+C*r.get(o,x)),r.set(o,x,T*r.get(o,x)-C*A)}else n[x-1]=d+C,n[x]=d+C,e[x-1]=A,e[x]=-A;x-=2,O=0}else{if(d=i.get(x,x),f=0,h=0,c<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===O){for(N+=d,o=E;o<=x;o++)i.set(o,o,i.get(o,o)-d);k=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*k,h=-.4375*k*k}if(30===O&&(k=(f-d)/2,k=k*k+h,k>0)){for(k=Math.sqrt(k),f<d&&(k=-k),k=d-h/((f-d)/2+k),o=E;o<=x;o++)i.set(o,o,i.get(o,o)-k);N+=k,d=f=h=.964}for(O+=1,u=x-2;u>=c&&(A=i.get(u,u),P=d-A,k=f-A,C=(P*k-h)/i.get(u+1,u)+i.get(u,u+1),T=i.get(u+1,u+1)-A-P-k,P=i.get(u+2,u+1),k=Math.abs(C)+Math.abs(T)+Math.abs(P),C/=k,T/=k,P/=k,u!==c)&&!(Math.abs(i.get(u,u-1))*(Math.abs(T)+Math.abs(P))<M*(Math.abs(C)*(Math.abs(i.get(u-1,u-1))+Math.abs(A)+Math.abs(i.get(u+1,u+1)))));)u--;for(o=u+2;o<=x;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=x-1&&(y=s!==x-1,s!==u&&(C=i.get(s,s-1),T=i.get(s+1,s-1),P=y?i.get(s+2,s-1):0,d=Math.abs(C)+Math.abs(T)+Math.abs(P),0!==d&&(C/=d,T/=d,P/=d)),0!==d);s++)if(k=Math.sqrt(C*C+T*T+P*P),C<0&&(k=-k),0!==k){for(s!==u?i.set(s,s-1,-k*d):c!==u&&i.set(s,s-1,-i.get(s,s-1)),C+=k,d=C/k,f=T/k,A=P/k,T/=C,P/=C,a=s;a<t;a++)C=i.get(s,a)+T*i.get(s+1,a),y&&(C+=P*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-C*A)),i.set(s,a,i.get(s,a)-C*d),i.set(s+1,a,i.get(s+1,a)-C*f);for(o=0;o<=Math.min(x,s+3);o++)C=d*i.get(o,s)+f*i.get(o,s+1),y&&(C+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-C*P)),i.set(o,s,i.get(o,s)-C),i.set(o,s+1,i.get(o,s+1)-C*T);for(o=E;o<=w;o++)C=d*r.get(o,s)+f*r.get(o,s+1),y&&(C+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-C*P)),r.set(o,s,r.get(o,s)-C),r.set(o,s+1,r.get(o,s+1)-C*T)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(C=n[x],T=e[x],0===T)for(c=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-C,P=0,a=c;a<=x;a++)P+=i.get(o,a)*i.get(a,x);if(e[o]<0)A=h,k=P;else if(c=o,0===e[o]?i.set(o,x,0!==h?-P/h:-P/(M*S)):(d=i.get(o,o+1),f=i.get(o+1,o),T=(n[o]-C)*(n[o]-C)+e[o]*e[o],l=(d*k-A*P)/T,i.set(o,x,l),i.set(o+1,x,Math.abs(d)>Math.abs(A)?(-P-h*l)/d:(-k-f*l)/A)),l=Math.abs(i.get(o,x)),M*l*l>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/l)}else if(T<0)for(c=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,T/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-C)/i.get(x,x-1))):(b=hy(0,-i.get(x-1,x),i.get(x-1,x-1)-C,T),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=c;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-C,e[o]<0)A=h,P=p,k=g;else if(c=o,0===e[o]?(b=hy(-p,-g,h,T),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),m=(n[o]-C)*(n[o]-C)+e[o]*e[o]-T*T,v=2*(n[o]-C)*T,0===m&&0===v&&(m=M*S*(Math.abs(h)+Math.abs(T)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=hy(d*P-A*p+T*g,d*k-A*g-T*p,m,v),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(T)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+T*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-T*i.get(o,x-1))/d)):(b=hy(-P-f*i.get(o,x-1),-k-f*i.get(o,x),A,T),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),l=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),M*l*l>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/l),i.set(a,x,i.get(a,x)/l)}for(o=0;o<t;o++)if(o<E||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=E;a--)for(o=E;o<=w;o++){for(A=0,s=E;s<=Math.min(a,w);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(o,c,s,a,t)}this.n=o,this.e=c,this.d=s,this.V=a}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new Xv(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function hy(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class dy{constructor(t){if(!(t=ny.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new Xv(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=Boolean(s)}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=ny.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class fy{constructor(t,e={}){t=ny.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=Ov.isAnyArray(n)&&"number"==typeof n[0]?Xv.columnVector(n):ny.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,c,u,l,h=1;for(let e=0;e<i&&h>o;e++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),s=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),e>0&&(h=s.clone().sub(l).pow(2).sum()),l=s.clone(),n?(c=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),c=c.div(c.norm()),a=n.mmul(c).div(c.transpose().mmul(c).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(c.transpose()));this.t=s,this.p=e.transpose(),this.w=u.transpose(),this.q=c,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=u.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(u.transpose()))}}Sv.AbstractMatrix=Yv,Sv.CHO=dy,Sv.CholeskyDecomposition=dy,Sv.DistanceMatrix=Qv,Sv.EVD=ly,Sv.EigenvalueDecomposition=ly,Sv.LU=ry,Sv.LuDecomposition=ry;var py=Sv.Matrix=Xv;Sv.MatrixColumnSelectionView=class extends Jv{constructor(t,e){Wv(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},Sv.MatrixColumnView=class extends Jv{constructor(t,e){Bv(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},Sv.MatrixFlipColumnView=class extends Jv{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},Sv.MatrixFlipRowView=class extends Jv{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},Sv.MatrixRowSelectionView=class extends Jv{constructor(t,e){Vv(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},Sv.MatrixRowView=class extends Jv{constructor(t,e){zv(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},Sv.MatrixSelectionView=ty,Sv.MatrixSubView=class extends Jv{constructor(t,e,n,r,i){Uv(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},Sv.MatrixTransposeView=class extends Jv{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},Sv.NIPALS=fy,Sv.Nipals=fy,Sv.QR=oy,Sv.QrDecomposition=oy,Sv.SVD=ay;var gy=Sv.SingularValueDecomposition=ay;Sv.SymmetricMatrix=Zv,Sv.WrapperMatrix1D=ey,Sv.WrapperMatrix2D=ny,Sv.correlation=function(t,e=t,n={}){t=new Xv(t);let r=!1;if("object"!=typeof e||Xv.isMatrix(e)||Ov.isAnyArray(e)?e=new Xv(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),c=t.transpose().mmul(e);for(let e=0;e<c.rows;e++)for(let n=0;n<c.columns;n++)c.set(e,n,c.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return c},Sv.covariance=function(t,e=t,n={}){t=new Xv(t);let r=!1;if("object"!=typeof e||Xv.isMatrix(e)||Ov.isAnyArray(e)?e=new Xv(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var my=Sv.default=Xv;Sv.determinant=function t(e){if((e=Xv.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new ty(e,[1,2],[1,2]),a=new ty(e,[1,2],[0,2]),s=new ty(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new ry(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Sv.inverse=function(t,e=!1){return t=ny.checkMatrix(t),e?new ay(t).inverse():sy(t,Xv.eye(t.rows))},Sv.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=Xv.checkMatrix(t)).rows,o=new Xv(i,i);for(let e=0;e<i;e++){let a=Xv.columnVector(t.getRow(e)),s=t.subMatrixRow(cy(i,e)).transpose(),c=new ay(s).solve(a),u=Xv.sub(a,s.mmul(c)).abs().max();o.setRow(e,uy(u,c,e,n,r))}return o},Sv.pseudoInverse=function(t,e=Number.EPSILON){if((t=Xv.checkMatrix(t)).isEmpty())return t.transpose();let n=new ay(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(Xv.diag(o).mmul(r.transpose()))},Sv.solve=sy,Sv.wrap=function(t,e){if(Ov.isAnyArray(t))return t[0]&&Ov.isAnyArray(t[0])?new ny(t):new ey(t,e);throw new Error("the argument is not an array")};const vy=py,yy=gy;my.Matrix&&my.Matrix;const by={center:[0,0],linkDistance:50};class xy{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},by),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i=[0,0],linkDistance:o=50}=r,a=e.getAllNodes(),s=e.getAllEdges();if(!(null==a?void 0:a.length)||1===a.length)return $m(e,t,i);const c=Lm({nodes:a,edges:s},!1),u=Im(c);Ey(u);const l=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(u,o),h=wy(l),d=[];h.forEach(((t,e)=>{const n=Fm(a[e]);n.data.x=t[0]+i[0],n.data.y=t[1]+i[1],d.push(n)})),t&&d.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:s}}))}}const Ey=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e<t&&(e=t)}))})),t.forEach(((n,r)=>{n.forEach(((n,i)=>{n===1/0&&(t[r][i]=e)}))}))},wy=t=>{const e=vy.mul(vy.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);const o=new yy(e),a=vy.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>vy.mul([t],[a]).toJSON()[0].splice(0,2)))},My={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Ny={center:[0,0],comboPadding:10,treeKey:"combo"};function Sy(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,c=0;for(i=0;i<a;++i)s+=(o=n[i]).x,c+=o.y;for(s=(s/a-t)*r,c=(c/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=c}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function Cy(t){return function(){return t}}function Ty(t){return 1e-6*(t()-.5)}function Py(t){return t.x+t.vx}function ky(t){return t.y+t.vy}function Ay(t){var e,n,r,i=1,o=1;function a(){for(var t,a,c,u,l,h,d,f=e.length,p=0;p<o;++p)for(a=nv(e,Py,ky).visitAfter(s),t=0;t<f;++t)c=e[t],h=n[c.index],d=h*h,u=c.x+c.vx,l=c.y+c.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>u+p||o<u-p||n>l+p||a<l-p;if(s.index>c.index){var g=u-s.x-s.vx,m=l-s.y-s.vy,v=g*g+m*m;v<p*p&&(0===g&&(v+=(g=Ty(r))*g),0===m&&(v+=(m=Ty(r))*m),v=(p-(v=Math.sqrt(v)))/v*i,c.vx+=(g*=v)*(p=(f*=f)/(d+f)),c.vy+=(m*=v)*p,s.vx-=g*(p=1-p),s.vy-=m*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function c(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=Cy(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,c()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Cy(+e),c(),a):t},a}function Oy(t){return t.index}function _y(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Ry(t){var e,n,r,i,o,a,s=Oy,c=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=Cy(30),l=1;function h(r){for(var i=0,s=t.length;i<l;++i)for(var c,u,h,d,f,p,g,m=0;m<s;++m)u=(c=t[m]).source,d=(h=c.target).x+h.vx-u.x-u.vx||Ty(a),f=h.y+h.vy-u.y-u.vy||Ty(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[m])/p*r*e[m],f*=p,h.vx-=d*(g=o[m]),h.vy-=f*g,u.vx+=d*(g=1-g),u.vy+=f*g}function d(){if(r){var a,c,u=r.length,l=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(u);a<l;++a)(c=t[a]).index=a,"object"!=typeof c.source&&(c.source=_y(h,c.source)),"object"!=typeof c.target&&(c.target=_y(h,c.target)),i[c.source.index]=(i[c.source.index]||0)+1,i[c.target.index]=(i[c.target.index]||0)+1;for(a=0,o=new Array(l);a<l;++a)c=t[a],o[a]=i[c.source.index]/(i[c.source.index]+i[c.target.index]);e=new Array(l),f(),n=new Array(l),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+c(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(l=+t,h):l},h.strength=function(t){return arguments.length?(c="function"==typeof t?t:Cy(+t),f(),h):c},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:Cy(+t),p(),h):u},h}var Dy={value:()=>{}};function Iy(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Ly(r)}function Ly(t){this._=t}function jy(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function zy(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Dy,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}Ly.prototype=Iy.prototype={constructor:Ly,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=o[a]).type)i[n]=zy(i[n],t.name,e);else if(null==e)for(n in i)i[n]=zy(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=jy(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Ly(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var By,Fy,Gy=0,Vy=0,Wy=0,Uy=1e3,Hy=0,$y=0,qy=0,Yy="object"==typeof performance&&performance.now?performance:Date,Ky="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Xy(){return $y||(Ky(Zy),$y=Yy.now()+qy)}function Zy(){$y=0}function Qy(){this._call=this._time=this._next=null}function Jy(t,e,n){var r=new Qy;return r.restart(t,e,n),r}function tb(){$y=(Hy=Yy.now())+qy,Gy=Vy=0;try{!function(){Xy(),++Gy;for(var t,e=By;e;)(t=$y-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Gy}()}finally{Gy=0,function(){var t,e,n=By,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:By=e);Fy=t,nb(r)}(),$y=0}}function eb(){var t=Yy.now(),e=t-Hy;e>Uy&&(qy-=e,Hy=t)}function nb(t){Gy||(Vy&&(Vy=clearTimeout(Vy)),t-$y>24?(t<1/0&&(Vy=setTimeout(tb,t-Yy.now()-qy)),Wy&&(Wy=clearInterval(Wy))):(Wy||(Hy=Yy.now(),Wy=setInterval(eb,Uy)),Gy=1,Ky(tb)))}Qy.prototype=Jy.prototype={constructor:Qy,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Xy():+n)+(null==e?0:+e),this._next||Fy===this||(Fy?Fy._next=this:By=this,Fy=this),this._call=t,this._time=n,nb()},stop:function(){this._call&&(this._call=null,this._time=1/0,nb())}};const rb=1664525,ib=1013904223,ob=4294967296;function ab(t){return t.x}function sb(t){return t.y}var cb=Math.PI*(3-Math.sqrt(5));function ub(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,c=Jy(h),u=Iy("tick","end"),l=function(){let t=1;return()=>(t=(rb*t+ib)%ob)/ob}();function h(){d(),u.call("tick",e),n<r&&(c.stop(),u.call("end",e))}function d(r){var c,u,l=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),c=0;c<l;++c)null==(u=t[c]).fx?u.x+=u.vx*=a:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=a:(u.y=u.fy,u.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*cb;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,l),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return c.restart(h),e},stop:function(){return c.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(l=t,s.forEach(p),e):l},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,c,u=0,l=t.length;for(null==r?r=1/0:r*=r,u=0;u<l;++u)(a=(i=e-(s=t[u]).x)*i+(o=n-s.y)*o)<r&&(c=s,r=a);return c},on:function(t,n){return arguments.length>1?(u.on(t,n),e):u.on(t)}}}function lb(){var t,e,n,r,i,o=Cy(-30),a=1,s=1/0,c=.81;function u(n){var i,o=t.length,a=nv(t,ab,sb).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function l(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function h(t){var e,n,r,o,a,s=0,c=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,c+=n,r+=n*e.x,o+=n*e.y);t.x=r/c,t.y=o/c}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,u,l){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=l-o,p=h*h+d*d;if(f*f/c<p)return p<s&&(0===h&&(p+=(h=Ty(n))*h),0===d&&(p+=(d=Ty(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=Ty(n))*h),0===d&&(p+=(d=Ty(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return u.initialize=function(e,r){t=e,n=r,l()},u.strength=function(t){return arguments.length?(o="function"==typeof t?t:Cy(+t),l(),u):o},u.distanceMin=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.distanceMax=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.theta=function(t){return arguments.length?(c=t*t,u):Math.sqrt(c)},u}function hb(t,e,n){var r,i,o,a=Cy(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var c=r[a],u=c.x-e||1e-6,l=c.y-n||1e-6,h=Math.sqrt(u*u+l*l),d=(o[a]-h)*i[a]*t/h;c.vx+=u*d,c.vy+=l*d}}function c(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=Cy(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,c()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:Cy(+t),c(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Cy(+e),c(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function db(t){var e,n,r,i=Cy(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Cy(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Cy(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Cy(+e),a(),o):t},o}function fb(t){var e,n,r,i=Cy(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Cy(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Cy(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Cy(+e),a(),o):t},o}class pb{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:Ry,manyBody:lb,center:Sy,collide:Ay,radial:hb,x:db,y:fb},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},re(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=re({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return a(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign({id:t,data:e},le(e,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),c=this.setSimulation(i);return c.nodes(o),null===(r=c.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),le(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return ub()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),gb(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),gb(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const gb=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);function mb(t,e,n){var r,i=1;function o(){var o,a,s=r.length,c=0,u=0,l=0;for(o=0;o<s;++o)c+=(a=r[o]).x||0,u+=a.y||0,l+=a.z||0;for(c=(c/s-t)*i,u=(u/s-e)*i,l=(l/s-n)*i,o=0;o<s;++o)a=r[o],c&&(a.x-=c),u&&(a.y-=u),l&&(a.z-=l)}return null==t&&(t=0),null==e&&(e=0),null==n&&(n=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.z=function(t){return arguments.length?(n=+t,o):n},o.strength=function(t){return arguments.length?(i=+t,o):i},o}function vb(t,e,n){if(isNaN(e))return t;var r,i,o,a,s,c,u=t._root,l={data:n},h=t._x0,d=t._x1;if(!u)return t._root=l,t;for(;u.length;)if((a=e>=(i=(h+d)/2))?h=i:d=i,r=u,!(u=u[s=+a]))return r[s]=l,t;if(e===(o=+t._x.call(null,u.data)))return l.next=u,r?r[s]=l:t._root=l,t;do{r=r?r[s]=new Array(2):t._root=new Array(2),(a=e>=(i=(h+d)/2))?h=i:d=i}while((s=+a)==(c=+(o>=i)));return r[c]=u,r[s]=l,t}function yb(t,e,n){this.node=t,this.x0=e,this.x1=n}function bb(t){return t[0]}function xb(t,e){var n=new Eb(null==e?bb:e,NaN,NaN);return null==t?n:n.addAll(t)}function Eb(t,e,n){this._x=t,this._x0=e,this._x1=n,this._root=void 0}function wb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Mb=xb.prototype=Eb.prototype;function Nb(t){return function(){return t}}function Sb(t){return 1e-6*(t()-.5)}function Cb(t){return t.x+t.vx}function Tb(t){return t.y+t.vy}function Pb(t){return t.z+t.vz}function kb(t){var e,n,r,i,o=1,a=1;function s(){for(var t,s,u,l,h,d,f,p,g=e.length,m=0;m<a;++m)for(s=(1===n?xb(e,Cb):2===n?nv(e,Cb,Tb):3===n?hv(e,Cb,Tb,Pb):null).visitAfter(c),t=0;t<g;++t)u=e[t],f=r[u.index],p=f*f,l=u.x+u.vx,n>1&&(h=u.y+u.vy),n>2&&(d=u.z+u.vz),s.visit(v);function v(t,e,r,a,s,c,g){var m=[e,r,a,s,c,g],v=m[0],y=m[1],b=m[2],x=m[n],E=m[n+1],w=m[n+2],M=t.data,N=t.r,S=f+N;if(!M)return v>l+S||x<l-S||n>1&&(y>h+S||E<h-S)||n>2&&(b>d+S||w<d-S);if(M.index>u.index){var C=l-M.x-M.vx,T=n>1?h-M.y-M.vy:0,P=n>2?d-M.z-M.vz:0,k=C*C+T*T+P*P;k<S*S&&(0===C&&(k+=(C=Sb(i))*C),n>1&&0===T&&(k+=(T=Sb(i))*T),n>2&&0===P&&(k+=(P=Sb(i))*P),k=(S-(k=Math.sqrt(k)))/k*o,u.vx+=(C*=k)*(S=(N*=N)/(p+N)),n>1&&(u.vy+=(T*=k)*S),n>2&&(u.vz+=(P*=k)*S),M.vx-=C*(S=1-S),n>1&&(M.vy-=T*S),n>2&&(M.vz-=P*S))}}}function c(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<Math.pow(2,n);++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,i,o=e.length;for(r=new Array(o),n=0;n<o;++n)i=e[n],r[i.index]=+t(i,n,e)}}return"function"!=typeof t&&(t=Nb(null==t?1:+t)),s.initialize=function(t,...r){e=t,i=r.find((t=>"function"==typeof t))||Math.random,n=r.find((t=>[1,2,3].includes(t)))||2,u()},s.iterations=function(t){return arguments.length?(a=+t,s):a},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Nb(+e),u(),s):t},s}function Ab(t){return t.index}function Ob(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function _b(t){var e,n,r,i,o,a,s,c=Ab,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},l=Nb(30),h=1;function d(r){for(var o=0,c=t.length;o<h;++o)for(var u,l,d,f,p,g=0,m=0,v=0,y=0;g<c;++g)l=(u=t[g]).source,m=(d=u.target).x+d.vx-l.x-l.vx||Sb(s),i>1&&(v=d.y+d.vy-l.y-l.vy||Sb(s)),i>2&&(y=d.z+d.vz-l.z-l.vz||Sb(s)),m*=f=((f=Math.sqrt(m*m+v*v+y*y))-n[g])/f*r*e[g],v*=f,y*=f,d.vx-=m*(p=a[g]),i>1&&(d.vy-=v*p),i>2&&(d.vz-=y*p),l.vx+=m*(p=1-p),i>1&&(l.vy+=v*p),i>2&&(l.vz+=y*p)}function f(){if(r){var i,s,u=r.length,l=t.length,h=new Map(r.map(((t,e)=>[c(t,e,r),t])));for(i=0,o=new Array(u);i<l;++i)(s=t[i]).index=i,"object"!=typeof s.source&&(s.source=Ob(h,s.source)),"object"!=typeof s.target&&(s.target=Ob(h,s.target)),o[s.source.index]=(o[s.source.index]||0)+1,o[s.target.index]=(o[s.target.index]||0)+1;for(i=0,a=new Array(l);i<l;++i)s=t[i],a[i]=o[s.source.index]/(o[s.source.index]+o[s.target.index]);e=new Array(l),p(),n=new Array(l),g()}}function p(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+u(t[n],n,t)}function g(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+l(t[e],e,t)}return null==t&&(t=[]),d.initialize=function(t,...e){r=t,s=e.find((t=>"function"==typeof t))||Math.random,i=e.find((t=>[1,2,3].includes(t)))||2,f()},d.links=function(e){return arguments.length?(t=e,f(),d):t},d.id=function(t){return arguments.length?(c=t,d):c},d.iterations=function(t){return arguments.length?(h=+t,d):h},d.strength=function(t){return arguments.length?(u="function"==typeof t?t:Nb(+t),p(),d):u},d.distance=function(t){return arguments.length?(l="function"==typeof t?t:Nb(+t),g(),d):l},d}Mb.copy=function(){var t,e,n=new Eb(this._x,this._x0,this._x1),r=this._root;if(!r)return n;if(!r.length)return n._root=wb(r),n;for(t=[{source:r,target:n._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(2)}):r.target[i]=wb(e));return n},Mb.add=function(t){const e=+this._x.call(null,t);return vb(this.cover(e),e,t)},Mb.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e);let r=1/0,i=-1/0;for(let o,a=0;a<e;++a)isNaN(o=+this._x.call(null,t[a]))||(n[a]=o,o<r&&(r=o),o>i&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let r=0;r<e;++r)vb(this,n[r],t[r]);return this},Mb.cover=function(t){if(isNaN(t=+t))return this;var e=this._x0,n=this._x1;if(isNaN(e))n=(e=Math.floor(t))+1;else{for(var r,i,o=n-e||1,a=this._root;e>t||t>=n;)switch(i=+(t<e),(r=new Array(2))[i]=a,a=r,o*=2,i){case 0:n=e+o;break;case 1:e=n-o}this._root&&this._root.length&&(this._root=a)}return this._x0=e,this._x1=n,this},Mb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Mb.extent=function(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]},Mb.find=function(t,e){var n,r,i,o,a,s=this._x0,c=this._x1,u=[],l=this._root;for(l&&u.push(new yb(l,s,c)),null==e?e=1/0:(s=t-e,c=t+e);o=u.pop();)if(!(!(l=o.node)||(r=o.x0)>c||(i=o.x1)<s))if(l.length){var h=(r+i)/2;u.push(new yb(l[1],h,i),new yb(l[0],r,h)),(a=+(t>=h))&&(o=u[u.length-1],u[u.length-1]=u[u.length-1-a],u[u.length-1-a]=o)}else{var d=Math.abs(t-+this._x.call(null,l.data));d<e&&(e=d,s=t-d,c=t+d,n=l.data)}return n},Mb.remove=function(t){if(isNaN(o=+this._x.call(null,t)))return this;var e,n,r,i,o,a,s,c,u,l=this._root,h=this._x0,d=this._x1;if(!l)return this;if(l.length)for(;;){if((s=o>=(a=(h+d)/2))?h=a:d=a,e=l,!(l=l[c=+s]))return this;if(!l.length)break;e[c+1&1]&&(n=e,u=c)}for(;l.data!==t;)if(r=l,!(l=l.next))return this;return(i=l.next)&&delete l.next,r?(i?r.next=i:delete r.next,this):e?(i?e[c]=i:delete e[c],(l=e[0]||e[1])&&l===(e[1]||e[0])&&!l.length&&(n?n[u]=l:this._root=l),this):(this._root=i,this)},Mb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Mb.root=function(){return this._root},Mb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Mb.visit=function(t){var e,n,r,i,o=[],a=this._root;for(a&&o.push(new yb(a,this._x0,this._x1));e=o.pop();)if(!t(a=e.node,r=e.x0,i=e.x1)&&a.length){var s=(r+i)/2;(n=a[1])&&o.push(new yb(n,s,i)),(n=a[0])&&o.push(new yb(n,r,s))}return this},Mb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new yb(this._root,this._x0,this._x1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.x1,c=(a+s)/2;(o=i[0])&&n.push(new yb(o,a,c)),(o=i[1])&&n.push(new yb(o,c,s))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.x1);return this},Mb.x=function(t){return arguments.length?(this._x=t,this):this._x};const Rb=1664525,Db=1013904223,Ib=4294967296;function Lb(t){return t.x}function jb(t){return t.y}function zb(t){return t.z}var Bb,Fb,Gb,Vb,Wb,Ub,Hb,$b,qb,Yb,Kb,Xb,Zb,Qb,Jb,tx,ex,nx,rx,ix,ox,ax,sx,cx,ux,lx,hx,dx,fx,px,gx,mx,vx,yx,bx,xx,Ex,wx,Mx,Nx,Sx,Cx,Tx,Px,kx,Ax,Ox,_x,Rx,Dx,Ix,Lx,jx,zx,Bx,Fx,Gx,Vx,Wx,Ux,Hx,$x,qx,Yx,Kx,Xx,Zx,Qx,Jx,tE,eE,nE,rE,iE,oE,aE,sE,cE,uE,lE,hE,dE,fE,pE,gE,mE,vE,yE,bE,xE,EE,wE,ME,NE,SE,CE,TE,PE,kE,AE,OE,_E,RE,DE,IE,LE,jE,zE,BE=Math.PI*(3-Math.sqrt(5)),FE=20*Math.PI/(9+Math.sqrt(221));function GE(t,e){e=e||2;var n,r=Math.min(3,Math.max(1,Math.round(e))),i=1,o=.001,a=1-Math.pow(o,1/300),s=0,c=.6,u=new Map,l=Jy(f),h=Iy("tick","end"),d=function(){let t=1;return()=>(t=(Rb*t+Db)%Ib)/Ib}();function f(){p(),h.call("tick",n),i<o&&(l.stop(),h.call("end",n))}function p(e){var o,l,h=t.length;void 0===e&&(e=1);for(var d=0;d<e;++d)for(i+=(s-i)*a,u.forEach((function(t){t(i)})),o=0;o<h;++o)null==(l=t[o]).fx?l.x+=l.vx*=c:(l.x=l.fx,l.vx=0),r>1&&(null==l.fy?l.y+=l.vy*=c:(l.y=l.fy,l.vy=0)),r>2&&(null==l.fz?l.z+=l.vz*=c:(l.z=l.fz,l.vz=0));return n}function g(){for(var e,n=0,i=t.length;n<i;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),null!=e.fz&&(e.z=e.fz),isNaN(e.x)||r>1&&isNaN(e.y)||r>2&&isNaN(e.z)){var o=10*(r>2?Math.cbrt(.5+n):r>1?Math.sqrt(.5+n):n),a=n*BE,s=n*FE;1===r?e.x=o:2===r?(e.x=o*Math.cos(a),e.y=o*Math.sin(a)):(e.x=o*Math.sin(a)*Math.cos(s),e.y=o*Math.cos(a),e.z=o*Math.sin(a)*Math.sin(s))}(isNaN(e.vx)||r>1&&isNaN(e.vy)||r>2&&isNaN(e.vz))&&(e.vx=0,r>1&&(e.vy=0),r>2&&(e.vz=0))}}function m(e){return e.initialize&&e.initialize(t,d,r),e}return null==t&&(t=[]),g(),n={tick:p,restart:function(){return l.restart(f),n},stop:function(){return l.stop(),n},numDimensions:function(t){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(t))),u.forEach(m),n):r},nodes:function(e){return arguments.length?(t=e,g(),u.forEach(m),n):t},alpha:function(t){return arguments.length?(i=+t,n):i},alphaMin:function(t){return arguments.length?(o=+t,n):o},alphaDecay:function(t){return arguments.length?(a=+t,n):+a},alphaTarget:function(t){return arguments.length?(s=+t,n):s},velocityDecay:function(t){return arguments.length?(c=1-t,n):1-c},randomSource:function(t){return arguments.length?(d=t,u.forEach(m),n):d},force:function(t,e){return arguments.length>1?(null==e?u.delete(t):u.set(t,m(e)),n):u.get(t)},find:function(){var e,n,i,o,a,s,c=Array.prototype.slice.call(arguments),u=c.shift()||0,l=(r>1?c.shift():null)||0,h=(r>2?c.shift():null)||0,d=c.shift()||1/0,f=0,p=t.length;for(d*=d,f=0;f<p;++f)(o=(e=u-(a=t[f]).x)*e+(n=l-(a.y||0))*n+(i=h-(a.z||0))*i)<d&&(s=a,d=o);return s},on:function(t,e){return arguments.length>1?(h.on(t,e),n):h.on(t)}}}function VE(){var t,e,n,r,i,o,a=Nb(-30),s=1,c=1/0,u=.81;function l(r){var o,a=t.length,s=(1===e?xb(t,Lb):2===e?nv(t,Lb,jb):3===e?hv(t,Lb,jb,zb):null).visitAfter(d);for(i=r,o=0;o<a;++o)n=t[o],s.visit(f)}function h(){if(t){var e,n,r=t.length;for(o=new Array(r),e=0;e<r;++e)n=t[e],o[n.index]=+a(n,e,t)}}function d(t){var n,r,i,a,s,c,u=0,l=0,h=t.length;if(h){for(i=a=s=c=0;c<h;++c)(n=t[c])&&(r=Math.abs(n.value))&&(u+=n.value,l+=r,i+=r*(n.x||0),a+=r*(n.y||0),s+=r*(n.z||0));u*=Math.sqrt(4/h),t.x=i/l,e>1&&(t.y=a/l),e>2&&(t.z=s/l)}else{(n=t).x=n.data.x,e>1&&(n.y=n.data.y),e>2&&(n.z=n.data.z);do{u+=o[n.data.index]}while(n=n.next)}t.value=u}function f(t,a,l,h,d){if(!t.value)return!0;var f=[l,h,d][e-1],p=t.x-n.x,g=e>1?t.y-n.y:0,m=e>2?t.z-n.z:0,v=f-a,y=p*p+g*g+m*m;if(v*v/u<y)return y<c&&(0===p&&(y+=(p=Sb(r))*p),e>1&&0===g&&(y+=(g=Sb(r))*g),e>2&&0===m&&(y+=(m=Sb(r))*m),y<s&&(y=Math.sqrt(s*y)),n.vx+=p*t.value*i/y,e>1&&(n.vy+=g*t.value*i/y),e>2&&(n.vz+=m*t.value*i/y)),!0;if(!(t.length||y>=c)){(t.data!==n||t.next)&&(0===p&&(y+=(p=Sb(r))*p),e>1&&0===g&&(y+=(g=Sb(r))*g),e>2&&0===m&&(y+=(m=Sb(r))*m),y<s&&(y=Math.sqrt(s*y)));do{t.data!==n&&(v=o[t.data.index]*i/y,n.vx+=p*v,e>1&&(n.vy+=g*v),e>2&&(n.vz+=m*v))}while(t=t.next)}}return l.initialize=function(n,...i){t=n,r=i.find((t=>"function"==typeof t))||Math.random,e=i.find((t=>[1,2,3].includes(t)))||2,h()},l.strength=function(t){return arguments.length?(a="function"==typeof t?t:Nb(+t),h(),l):a},l.distanceMin=function(t){return arguments.length?(s=t*t,l):Math.sqrt(s)},l.distanceMax=function(t){return arguments.length?(c=t*t,l):Math.sqrt(c)},l.theta=function(t){return arguments.length?(u=t*t,l):Math.sqrt(u)},l}function WE(t,e,n,r){var i,o,a,s,c=Nb(.1);function u(t){for(var c=0,u=i.length;c<u;++c){var l=i[c],h=l.x-e||1e-6,d=(l.y||0)-n||1e-6,f=(l.z||0)-r||1e-6,p=Math.sqrt(h*h+d*d+f*f),g=(s[c]-p)*a[c]*t/p;l.vx+=h*g,o>1&&(l.vy+=d*g),o>2&&(l.vz+=f*g)}}function l(){if(i){var e,n=i.length;for(a=new Array(n),s=new Array(n),e=0;e<n;++e)s[e]=+t(i[e],e,i),a[e]=isNaN(s[e])?0:+c(i[e],e,i)}}return"function"!=typeof t&&(t=Nb(+t)),null==e&&(e=0),null==n&&(n=0),null==r&&(r=0),u.initialize=function(t,...e){i=t,o=e.find((t=>[1,2,3].includes(t)))||2,l()},u.strength=function(t){return arguments.length?(c="function"==typeof t?t:Nb(+t),l(),u):c},u.radius=function(e){return arguments.length?(t="function"==typeof e?e:Nb(+e),l(),u):t},u.x=function(t){return arguments.length?(e=+t,u):e},u.y=function(t){return arguments.length?(n=+t,u):n},u.z=function(t){return arguments.length?(r=+t,u):r},u}function UE(t){var e,n,r,i=Nb(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Nb(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Nb(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Nb(+e),a(),o):t},o}function HE(t){var e,n,r,i=Nb(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Nb(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Nb(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Nb(+e),a(),o):t},o}function $E(t){var e,n,r,i=Nb(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vz+=(r[o]-i.z)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Nb(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Nb(+t),a(),o):i},o.z=function(e){return arguments.length?(t="function"==typeof e?e:Nb(+e),a(),o):t},o}function qE(){if(Vb)return Gb;return Vb=1,Gb=function(t,e){return t===e||t!=t&&e!=e}}function YE(){if(Ub)return Wb;Ub=1;var t=qE();return Wb=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},Wb}function KE(){if(tx)return Jb;tx=1;var t=Fb?Bb:(Fb=1,Bb=function(){this.__data__=[],this.size=0}),e=function(){if($b)return Hb;$b=1;var t=YE(),e=Array.prototype.splice;return Hb=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},Hb}(),n=function(){if(Yb)return qb;Yb=1;var t=YE();return qb=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},qb}(),r=function(){if(Xb)return Kb;Xb=1;var t=YE();return Kb=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(Qb)return Zb;Qb=1;var t=YE();return Zb=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},Zb}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,Jb=o}function XE(){if(lx)return ux;lx=1;var t="object"==typeof d&&d&&d.Object===Object&&d;return ux=t}function ZE(){if(dx)return hx;dx=1;var t=XE(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return hx=n}function QE(){if(px)return fx;px=1;var t=ZE().Symbol;return fx=t}function JE(){if(xx)return bx;xx=1;var t=QE(),e=function(){if(mx)return gx;mx=1;var t=QE(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return gx=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var a=!0}catch(t){}var s=r.call(t);return a&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(yx)return vx;yx=1;var t=Object.prototype.toString;return vx=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return bx=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function tw(){if(wx)return Ex;return wx=1,Ex=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function ew(){if(Nx)return Mx;Nx=1;var t=JE(),e=tw();return Mx=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function nw(){if(Px)return Tx;Px=1;var t,e=function(){if(Cx)return Sx;Cx=1;var t=ZE()["__core-js_shared__"];return Sx=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Tx=function(t){return!!n&&n in t}}function rw(){if(Ax)return kx;Ax=1;var t=Function.prototype.toString;return kx=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function iw(){if(Lx)return Ix;Lx=1;var t=function(){if(_x)return Ox;_x=1;var t=ew(),e=nw(),n=tw(),r=rw(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,c=a.hasOwnProperty,u=RegExp("^"+s.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return Ox=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=Dx?Rx:(Dx=1,Rx=function(t,e){return null==t?void 0:t[e]});return Ix=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function ow(){if(zx)return jx;zx=1;var t=iw()(ZE(),"Map");return jx=t}function aw(){if(Fx)return Bx;Fx=1;var t=iw()(Object,"create");return Bx=t}function sw(){if(Qx)return Zx;Qx=1;var t=function(){if(Vx)return Gx;Vx=1;var t=aw();return Gx=function(){this.__data__=t?t(null):{},this.size=0}}(),e=Ux?Wx:(Ux=1,Wx=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if($x)return Hx;$x=1;var t=aw(),e=Object.prototype.hasOwnProperty;return Hx=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},Hx}(),r=function(){if(Yx)return qx;Yx=1;var t=aw(),e=Object.prototype.hasOwnProperty;return qx=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},qx}(),i=function(){if(Xx)return Kx;Xx=1;var t=aw();return Kx=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},Kx}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,Zx=o}function cw(){if(iE)return rE;iE=1;var t=nE?eE:(nE=1,eE=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return rE=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},rE}function uw(){if(pE)return fE;pE=1;var t=function(){if(tE)return Jx;tE=1;var t=sw(),e=KE(),n=ow();return Jx=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(aE)return oE;aE=1;var t=cw();return oE=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(cE)return sE;cE=1;var t=cw();return sE=function(e){return t(this,e).get(e)}}(),r=function(){if(lE)return uE;lE=1;var t=cw();return uE=function(e){return t(this,e).has(e)}}(),i=function(){if(dE)return hE;dE=1;var t=cw();return hE=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},hE}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,fE=o}function lw(){if(yE)return vE;yE=1;var t=KE(),e=function(){if(nx)return ex;nx=1;var t=KE();return ex=function(){this.__data__=new t,this.size=0}}(),n=(ix||(ix=1,rx=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),rx),r=ax?ox:(ax=1,ox=function(t){return this.__data__.get(t)}),i=cx?sx:(cx=1,sx=function(t){return this.__data__.has(t)}),o=function(){if(mE)return gE;mE=1;var t=KE(),e=ow(),n=uw();return gE=function(r,i){var o=this.__data__;if(o instanceof t){var a=o.__data__;if(!e||a.length<199)return a.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(a)}return o.set(r,i),this.size=o.size,this},gE}();function a(e){var n=this.__data__=new t(e);this.size=n.size}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,vE=a}function hw(){if(xE)return bE;return xE=1,bE=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},bE}function dw(){if(wE)return EE;wE=1;var t=iw(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return EE=e}function fw(){if(NE)return ME;NE=1;var t=dw();return ME=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function pw(){if(CE)return SE;CE=1;var t=fw(),e=qE(),n=Object.prototype.hasOwnProperty;return SE=function(r,i,o){var a=r[i];n.call(r,i)&&e(a,o)&&(void 0!==o||i in r)||t(r,i,o)}}function gw(){if(PE)return TE;PE=1;var t=pw(),e=fw();return TE=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,c=r.length;++s<c;){var u=r[s],l=o?o(i[u],n[u],u,i,n):void 0;void 0===l&&(l=n[u]),a?e(i,u,l):t(i,u,l)}return i},TE}function mw(){if(_E)return OE;return _E=1,OE=function(t){return null!=t&&"object"==typeof t}}function vw(){if(LE)return IE;LE=1;var t=function(){if(DE)return RE;DE=1;var t=JE(),e=mw();return RE=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=mw(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return IE=o}function yw(){if(zE)return jE;zE=1;var t=Array.isArray;return jE=t}var bw,xw,Ew,ww,Mw,Nw,Sw,Cw,Tw,Pw,kw,Aw={exports:{}};function Ow(){return Ew||(Ew=1,function(t,e){var n=ZE(),r=xw?bw:(xw=1,bw=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,a=o&&o.exports===i?n.Buffer:void 0,s=(a?a.isBuffer:void 0)||r;t.exports=s}(Aw,Aw.exports)),Aw.exports}function _w(){if(Mw)return ww;Mw=1;var t=/^(?:0|[1-9]\d*)$/;return ww=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},ww}function Rw(){if(Sw)return Nw;Sw=1;return Nw=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Dw(){if(kw)return Pw;return kw=1,Pw=function(t){return function(e){return t(e)}}}Aw.exports;var Iw,Lw,jw,zw,Bw,Fw,Gw,Vw,Ww,Uw,Hw,$w,qw,Yw,Kw,Xw,Zw,Qw,Jw,tM,eM,nM,rM,iM,oM,aM,sM,cM={exports:{}};function uM(){return Iw||(Iw=1,function(t,e){var n=XE(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,a=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=a}(cM,cM.exports)),cM.exports}function lM(){if(jw)return Lw;jw=1;var t=function(){if(Tw)return Cw;Tw=1;var t=JE(),e=Rw(),n=mw(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,Cw=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=Dw(),n=uM(),r=n&&n.isTypedArray,i=r?e(r):t;return Lw=i}function hM(){if(Bw)return zw;Bw=1;var t=(AE||(AE=1,kE=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),kE),e=vw(),n=yw(),r=Ow(),i=_w(),o=lM(),a=Object.prototype.hasOwnProperty;return zw=function(s,c){var u=n(s),l=!u&&e(s),h=!u&&!l&&r(s),d=!u&&!l&&!h&&o(s),f=u||l||h||d,p=f?t(s.length,String):[],g=p.length;for(var m in s)!c&&!a.call(s,m)||f&&("length"==m||h&&("offset"==m||"parent"==m)||d&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||i(m,g))||p.push(m);return p},zw}function dM(){if(Gw)return Fw;Gw=1;var t=Object.prototype;return Fw=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function fM(){if(Ww)return Vw;return Ww=1,Vw=function(t,e){return function(n){return t(e(n))}}}function pM(){if(qw)return $w;qw=1;var t=dM(),e=function(){if(Hw)return Uw;Hw=1;var t=fM()(Object.keys,Object);return Uw=t}(),n=Object.prototype.hasOwnProperty;return $w=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function gM(){if(Kw)return Yw;Kw=1;var t=ew(),e=Rw();return Yw=function(n){return null!=n&&e(n.length)&&!t(n)}}function mM(){if(Zw)return Xw;Zw=1;var t=hM(),e=pM(),n=gM();return Xw=function(r){return n(r)?t(r):e(r)}}function vM(){if(rM)return nM;rM=1;var t=tw(),e=dM(),n=eM?tM:(eM=1,tM=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return nM=function(i){if(!t(i))return n(i);var o=e(i),a=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&a.push(s);return a}}function yM(){if(oM)return iM;oM=1;var t=hM(),e=vM(),n=gM();return iM=function(r){return n(r)?t(r,!0):e(r)}}cM.exports;var bM,xM,EM,wM,MM,NM,SM,CM,TM,PM,kM,AM,OM,_M,RM,DM,IM,LM,jM,zM,BM,FM,GM,VM,WM,UM,HM,$M,qM,YM,KM,XM,ZM,QM,JM,tN,eN,nN,rN,iN,oN,aN,sN,cN,uN,lN,hN,dN,fN,pN,gN,mN,vN,yN,bN,xN,EN,wN,MN,NN,SN,CN,TN,PN,kN,AN,ON,_N,RN,DN,IN,LN,jN,zN,BN,FN,GN,VN,WN,UN,HN,$N,qN,YN,KN,XN,ZN,QN,JN,tS,eS,nS,rS,iS,oS,aS,sS,cS,uS,lS,hS,dS,fS,pS,gS,mS,vS,yS,bS,xS,ES,wS,MS,NS,SS,CS,TS,PS,kS,AS,OS,_S,RS,DS,IS,LS,jS,zS,BS,FS,GS,VS,WS,US,HS,$S,qS,YS,KS,XS,ZS,QS,JS,tC,eC,nC,rC,iC,oC,aC,sC,cC,uC,lC,hC,dC,fC,pC,gC,mC,vC,yC,bC,xC,EC,wC,MC,NC,SC,CC,TC,PC,kC,AC,OC,_C,RC,DC,IC,LC,jC,zC,BC,FC,GC,VC,WC,UC,HC,$C,qC,YC,KC,XC,ZC,QC,JC,tT,eT,nT,rT,iT,oT,aT,sT,cT,uT,lT,hT,dT,fT,pT,gT,mT,vT,yT,bT,xT,ET,wT,MT,NT,ST,CT,TT,PT,kT,AT,OT,_T,RT,DT,IT,LT,jT,zT,BT,FT,GT,VT,WT,UT,HT,$T,qT,YT,KT,XT,ZT,QT,JT,tP,eP,nP,rP,iP,oP,aP,sP,cP,uP,lP,hP,dP,fP,pP,gP,mP,vP,yP,bP,xP,EP,wP,MP,NP,SP,CP,TP,PP,kP={exports:{}};function AP(){return bM||(bM=1,function(t,e){var n=ZE(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}}(kP,kP.exports)),kP.exports}function OP(){if(EM)return xM;return EM=1,xM=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},xM}function _P(){if(MM)return wM;return MM=1,wM=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o},wM}function RP(){if(SM)return NM;return SM=1,NM=function(){return[]}}function DP(){if(TM)return CM;TM=1;var t=_P(),e=RP(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return CM=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function IP(){if(OM)return AM;return OM=1,AM=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},AM}function LP(){if(RM)return _M;RM=1;var t=fM()(Object.getPrototypeOf,Object);return _M=t}function jP(){if(IM)return DM;IM=1;var t=IP(),e=LP(),n=DP(),r=RP(),i=Object.getOwnPropertySymbols;return DM=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function zP(){if(BM)return zM;BM=1;var t=IP(),e=yw();return zM=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function BP(){if(GM)return FM;GM=1;var t=zP(),e=DP(),n=mM();return FM=function(r){return t(r,n,e)}}function FP(){if(KM)return YM;KM=1;var t=iw()(ZE(),"Set");return YM=t}function GP(){if(JM)return QM;JM=1;var t=function(){if(HM)return UM;HM=1;var t=iw()(ZE(),"DataView");return UM=t}(),e=ow(),n=function(){if(qM)return $M;qM=1;var t=iw()(ZE(),"Promise");return $M=t}(),r=FP(),i=function(){if(ZM)return XM;ZM=1;var t=iw()(ZE(),"WeakMap");return XM=t}(),o=JE(),a=rw(),s="[object Map]",c="[object Promise]",u="[object Set]",l="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),m=a(i),v=o;return(t&&v(new t(new ArrayBuffer(1)))!=h||e&&v(new e)!=s||n&&v(n.resolve())!=c||r&&v(new r)!=u||i&&v(new i)!=l)&&(v=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?a(n):"";if(r)switch(r){case d:return h;case f:return s;case p:return c;case g:return u;case m:return l}return e}),QM=v}function VP(){if(rN)return nN;rN=1;var t=ZE().Uint8Array;return nN=t}function WP(){if(oN)return iN;oN=1;var t=VP();return iN=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function UP(){if(fN)return dN;fN=1;var t=WP();return dN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function HP(){if(gN)return pN;gN=1;var t=WP(),e=function(){if(sN)return aN;sN=1;var t=WP();return aN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(uN)return cN;uN=1;var t=/\w*$/;return cN=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(hN)return lN;hN=1;var t=QE(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return lN=function(t){return n?Object(n.call(t)):{}}}(),i=UP();return pN=function(o,a,s){var c=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new c(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function $P(){if(vN)return mN;vN=1;var t=tw(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return mN=n}function qP(){if(bN)return yN;bN=1;var t=$P(),e=LP(),n=dM();return yN=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function YP(){if(MN)return wN;MN=1;var t=function(){if(EN)return xN;EN=1;var t=GP(),e=mw();return xN=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=Dw(),n=uM(),r=n&&n.isMap,i=r?e(r):t;return wN=i}function KP(){if(TN)return CN;TN=1;var t=function(){if(SN)return NN;SN=1;var t=GP(),e=mw();return NN=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=Dw(),n=uM(),r=n&&n.isSet,i=r?e(r):t;return CN=i}function XP(){if(kN)return PN;kN=1;var t=lw(),e=hw(),n=pw(),r=function(){if(Jw)return Qw;Jw=1;var t=gw(),e=mM();return Qw=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(sM)return aM;sM=1;var t=gw(),e=yM();return aM=function(n,r){return n&&t(r,e(r),n)}}(),o=AP(),a=OP(),s=function(){if(kM)return PM;kM=1;var t=gw(),e=DP();return PM=function(n,r){return t(n,e(n),r)}}(),c=function(){if(jM)return LM;jM=1;var t=gw(),e=jP();return LM=function(n,r){return t(n,e(n),r)}}(),u=BP(),l=function(){if(WM)return VM;WM=1;var t=zP(),e=jP(),n=yM();return VM=function(r){return t(r,n,e)}}(),h=GP(),d=function(){if(eN)return tN;eN=1;var t=Object.prototype.hasOwnProperty;return tN=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},tN}(),f=HP(),p=qP(),g=yw(),m=Ow(),v=YP(),y=tw(),b=KP(),x=mM(),E=yM(),w="[object Arguments]",M="[object Function]",N="[object Object]",S={};return S[w]=S["[object Array]"]=S["[object ArrayBuffer]"]=S["[object DataView]"]=S["[object Boolean]"]=S["[object Date]"]=S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Map]"]=S["[object Number]"]=S[N]=S["[object RegExp]"]=S["[object Set]"]=S["[object String]"]=S["[object Symbol]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S["[object Error]"]=S[M]=S["[object WeakMap]"]=!1,PN=function C(T,P,k,A,O,_){var R,D=1&P,I=2&P,L=4&P;if(k&&(R=O?k(T,A,O,_):k(T)),void 0!==R)return R;if(!y(T))return T;var j=g(T);if(j){if(R=d(T),!D)return a(T,R)}else{var z=h(T),B=z==M||"[object GeneratorFunction]"==z;if(m(T))return o(T,D);if(z==N||z==w||B&&!O){if(R=I||B?{}:p(T),!D)return I?c(T,i(R,T)):s(T,r(R,T))}else{if(!S[z])return O?T:{};R=f(T,z,D)}}_||(_=new t);var F=_.get(T);if(F)return F;_.set(T,R),b(T)?T.forEach((function(t){R.add(C(t,P,k,t,T,_))})):v(T)&&T.forEach((function(t,e){R.set(e,C(t,P,k,e,T,_))}));var G=j?void 0:(L?I?l:u:I?E:x)(T);return e(G||T,(function(t,e){G&&(t=T[e=t]),n(R,e,C(t,P,k,e,T,_))})),R},PN}function ZP(){if(ON)return AN;ON=1;var t=XP();return AN=function(e){return t(e,4)}}function QP(){if(RN)return _N;return RN=1,_N=function(t){return function(){return t}}}function JP(){if(jN)return LN;jN=1;var t=(IN||(IN=1,DN=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var c=a[t?s:++i];if(!1===n(o[c],c,o))break}return e}}),DN),e=t();return LN=e}function tk(){if(BN)return zN;BN=1;var t=JP(),e=mM();return zN=function(n,r){return n&&t(n,r,e)}}function ek(){if(WN)return VN;WN=1;var t=tk(),e=function(){if(GN)return FN;GN=1;var t=gM();return FN=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,a=n?o:-1,s=Object(r);(n?a--:++a<o)&&!1!==i(s[a],a,s););return r}},FN}(),n=e(t);return VN=n}function nk(){if(HN)return UN;return HN=1,UN=function(t){return t}}function rk(){if(qN)return $N;qN=1;var t=nk();return $N=function(e){return"function"==typeof e?e:t}}function ik(){if(KN)return YN;KN=1;var t=hw(),e=ek(),n=rk(),r=yw();return YN=function(i,o){return(r(i)?t:e)(i,n(o))}}function ok(){return ZN?XN:(ZN=1,XN=ik())}function ak(){if(oS)return iS;oS=1;var t=uw(),e=eS?tS:(eS=1,tS=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=rS?nS:(rS=1,nS=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,iS=r}function sk(){if(uS)return cS;return uS=1,cS=function(t,e){return t.has(e)}}function ck(){if(hS)return lS;hS=1;var t=ak(),e=(sS||(sS=1,aS=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),aS),n=sk();return lS=function(r,i,o,a,s,c){var u=1&o,l=r.length,h=i.length;if(l!=h&&!(u&&h>l))return!1;var d=c.get(r),f=c.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,m=2&o?new t:void 0;for(c.set(r,i),c.set(i,r);++p<l;){var v=r[p],y=i[p];if(a)var b=u?a(y,v,p,i,r,c):a(v,y,p,r,i,c);if(void 0!==b){if(b)continue;g=!1;break}if(m){if(!e(i,(function(t,e){if(!n(m,e)&&(v===t||s(v,t,o,a,c)))return m.push(e)}))){g=!1;break}}else if(v!==y&&!s(v,y,o,a,c)){g=!1;break}}return c.delete(r),c.delete(i),g},lS}function uk(){if(gS)return pS;return gS=1,pS=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},pS}function lk(){if(vS)return mS;vS=1;var t=QE(),e=VP(),n=qE(),r=ck(),i=(fS||(fS=1,dS=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),dS),o=uk(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return mS=function(t,a,c,u,l,h,d){switch(c){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!h(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&u;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;u|=2,d.set(t,a);var m=r(f(t),f(a),u,l,h,d);return d.delete(t),m;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function hk(){if(ES)return xS;ES=1;var t=lw(),e=ck(),n=lk(),r=function(){if(bS)return yS;bS=1;var t=BP(),e=Object.prototype.hasOwnProperty;return yS=function(n,r,i,o,a,s){var c=1&i,u=t(n),l=u.length;if(l!=t(r).length&&!c)return!1;for(var h=l;h--;){var d=u[h];if(!(c?d in r:e.call(r,d)))return!1}var f=s.get(n),p=s.get(r);if(f&&p)return f==r&&p==n;var g=!0;s.set(n,r),s.set(r,n);for(var m=c;++h<l;){var v=n[d=u[h]],y=r[d];if(o)var b=c?o(y,v,d,r,n,s):o(v,y,d,n,r,s);if(!(void 0===b?v===y||a(v,y,i,o,s):b)){g=!1;break}m||(m="constructor"==d)}if(g&&!m){var x=n.constructor,E=r.constructor;x==E||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(n),s.delete(r),g},yS}(),i=GP(),o=yw(),a=Ow(),s=lM(),c="[object Arguments]",u="[object Array]",l="[object Object]",h=Object.prototype.hasOwnProperty;return xS=function(d,f,p,g,m,v){var y=o(d),b=o(f),x=y?u:i(d),E=b?u:i(f),w=(x=x==c?l:x)==l,M=(E=E==c?l:E)==l,N=x==E;if(N&&a(d)){if(!a(f))return!1;y=!0,w=!1}if(N&&!w)return v||(v=new t),y||s(d)?e(d,f,p,g,m,v):n(d,f,x,p,g,m,v);if(!(1&p)){var S=w&&h.call(d,"__wrapped__"),C=M&&h.call(f,"__wrapped__");if(S||C){var T=S?d.value():d,P=C?f.value():f;return v||(v=new t),m(T,P,p,g,v)}}return!!N&&(v||(v=new t),r(d,f,p,g,m,v))}}function dk(){if(MS)return wS;MS=1;var t=hk(),e=mw();return wS=function n(r,i,o,a,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,a,n,s))},wS}function fk(){if(TS)return CS;TS=1;var t=tw();return CS=function(e){return e==e&&!t(e)}}function pk(){if(OS)return AS;return OS=1,AS=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function gk(){if(RS)return _S;RS=1;var t=function(){if(SS)return NS;SS=1;var t=lw(),e=dk();return NS=function(n,r,i,o){var a=i.length,s=a,c=!o;if(null==n)return!s;for(n=Object(n);a--;){var u=i[a];if(c&&u[2]?u[1]!==n[u[0]]:!(u[0]in n))return!1}for(;++a<s;){var l=(u=i[a])[0],h=n[l],d=u[1];if(c&&u[2]){if(void 0===h&&!(l in n))return!1}else{var f=new t;if(o)var p=o(h,d,l,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},NS}(),e=function(){if(kS)return PS;kS=1;var t=fk(),e=mM();return PS=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],a=n[o];r[i]=[o,a,t(a)]}return r},PS}(),n=pk();return _S=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function mk(){if(IS)return DS;IS=1;var t=JE(),e=mw();return DS=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function vk(){if(jS)return LS;jS=1;var t=yw(),e=mk(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return LS=function(i,o){if(t(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function yk(){if(GS)return FS;GS=1;var t=function(){if(BS)return zS;BS=1;var t=uw();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var a=n.apply(this,t);return i.cache=o.set(e,a)||o,a};return i.cache=new(e.Cache||t),i}return e.Cache=t,zS=e}();return FS=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function bk(){if(HS)return US;return HS=1,US=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},US}function xk(){if(KS)return YS;KS=1;var t=function(){if(qS)return $S;qS=1;var t=QE(),e=bk(),n=yw(),r=mk(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return $S=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},$S}();return YS=function(e){return null==e?"":t(e)}}function Ek(){if(ZS)return XS;ZS=1;var t=yw(),e=vk(),n=function(){if(WS)return VS;WS=1;var t=yk(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,(function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)})),r}));return VS=r}(),r=xk();return XS=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function wk(){if(JS)return QS;JS=1;var t=mk();return QS=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function Mk(){if(eC)return tC;eC=1;var t=Ek(),e=wk();return tC=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},tC}function Nk(){if(sC)return aC;sC=1;var t=Ek(),e=vw(),n=yw(),r=_w(),i=Rw(),o=wk();return aC=function(a,s,c){for(var u=-1,l=(s=t(s,a)).length,h=!1;++u<l;){var d=o(s[u]);if(!(h=null!=a&&c(a,d)))break;a=a[d]}return h||++u!=l?h:!!(l=null==a?0:a.length)&&i(l)&&r(d,l)&&(n(a)||e(a))},aC}function Sk(){if(uC)return cC;uC=1;var t=oC?iC:(oC=1,iC=function(t,e){return null!=t&&e in Object(t)}),e=Nk();return cC=function(n,r){return null!=n&&e(n,r,t)}}function Ck(){if(hC)return lC;hC=1;var t=dk(),e=function(){if(rC)return nC;rC=1;var t=Mk();return nC=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=Sk(),r=vk(),i=fk(),o=pk(),a=wk();return lC=function(s,c){return r(s)&&i(c)?o(a(s),c):function(r){var i=e(r,s);return void 0===i&&i===c?n(r,s):t(c,i,3)}}}function Tk(){if(fC)return dC;return fC=1,dC=function(t){return function(e){return null==e?void 0:e[t]}}}function Pk(){if(vC)return mC;vC=1;var t=Tk(),e=function(){if(gC)return pC;gC=1;var t=Mk();return pC=function(e){return function(n){return t(n,e)}}}(),n=vk(),r=wk();return mC=function(i){return n(i)?t(r(i)):e(i)}}function kk(){if(bC)return yC;bC=1;var t=gk(),e=Ck(),n=nk(),r=yw(),i=Pk();return yC=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function Ak(){if(EC)return xC;EC=1;var t=_P(),e=function(){if(JN)return QN;JN=1;var t=ek();return QN=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},QN}(),n=kk(),r=yw();return xC=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function Ok(){if(SC)return NC;SC=1;var t=function(){if(MC)return wC;MC=1;var t=Object.prototype.hasOwnProperty;return wC=function(e,n){return null!=e&&t.call(e,n)}}(),e=Nk();return NC=function(n,r){return null!=n&&e(n,r,t)}}function _k(){if(TC)return CC;TC=1;var t=pM(),e=GP(),n=vw(),r=yw(),i=gM(),o=Ow(),a=dM(),s=lM(),c=Object.prototype.hasOwnProperty;return CC=function(u){if(null==u)return!0;if(i(u)&&(r(u)||"string"==typeof u||"function"==typeof u.splice||o(u)||s(u)||n(u)))return!u.length;var l=e(u);if("[object Map]"==l||"[object Set]"==l)return!u.size;if(a(u))return!t(u).length;for(var h in u)if(c.call(u,h))return!1;return!0}}function Rk(){if(kC)return PC;return kC=1,PC=function(t){return void 0===t}}function Dk(){if(OC)return AC;OC=1;var t=ek(),e=gM();return AC=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,(function(t,e,n){o[++i]=r(t,e,n)})),o},AC}function Ik(){if(RC)return _C;RC=1;var t=bk(),e=kk(),n=Dk(),r=yw();return _C=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function Lk(){if(BC)return zC;BC=1;var t=(IC||(IC=1,DC=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),DC),e=ek(),n=kk(),r=(jC||(jC=1,LC=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),LC),i=yw();return zC=function(o,a,s){var c=i(o)?t:r,u=arguments.length<3;return c(o,n(a,4),s,u,e)},zC}function jk(){if(KC)return YC;KC=1;var t=function(){if(WC)return VC;WC=1;var t=Tk()("length");return VC=t}(),e=function(){if(HC)return UC;HC=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return UC=function(e){return t.test(e)}}(),n=function(){if(qC)return $C;qC=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",c="[\\ufe0e\\ufe0f]?",u=c+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+c+s+")*",l="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+l+u,"g");return $C=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return YC=function(r){return e(r)?n(r):t(r)}}function zk(){if(ZC)return XC;ZC=1;var t=pM(),e=GP(),n=gM(),r=function(){if(GC)return FC;GC=1;var t=JE(),e=yw(),n=mw();return FC=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=jk();return XC=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var a=e(o);return"[object Map]"==a||"[object Set]"==a?o.size:t(o).length}}function Bk(){if(JC)return QC;JC=1;var t=hw(),e=$P(),n=tk(),r=kk(),i=LP(),o=yw(),a=Ow(),s=ew(),c=tw(),u=lM();return QC=function(l,h,d){var f=o(l),p=f||a(l)||u(l);if(h=r(h,4),null==d){var g=l&&l.constructor;d=p?f?new g:[]:c(l)&&s(g)?e(i(l)):{}}return(p?t:n)(l,(function(t,e,n){return h(d,t,e,n)})),d},QC}function Fk(){if(rT)return nT;rT=1;var t=IP(),e=function(){if(eT)return tT;eT=1;var t=QE(),e=vw(),n=yw(),r=t?t.isConcatSpreadable:void 0;return tT=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return nT=function n(r,i,o,a,s){var c=-1,u=r.length;for(o||(o=e),s||(s=[]);++c<u;){var l=r[c];i>0&&o(l)?i>1?n(l,i-1,o,a,s):t(s,l):a||(s[s.length]=l)}return s},nT}function Gk(){if(sT)return aT;sT=1;var t=oT?iT:(oT=1,iT=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return aT=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,a=-1,s=e(o.length-r,0),c=Array(s);++a<s;)c[a]=o[r+a];a=-1;for(var u=Array(r+1);++a<r;)u[a]=o[a];return u[r]=i(c),t(n,this,u)}},aT}function Vk(){if(fT)return dT;fT=1;var t=function(){if(uT)return cT;uT=1;var t=QP(),e=dw(),n=nk();return cT=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(hT)return lT;hT=1;var t=Date.now;return lT=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},lT}(),n=e(t);return dT=n}function Wk(){if(gT)return pT;gT=1;var t=nk(),e=Gk(),n=Vk();return pT=function(r,i){return n(e(r,i,t),r+"")}}function Uk(){if(vT)return mT;return vT=1,mT=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},mT}function Hk(){if(MT)return wT;MT=1;var t=Uk(),e=bT?yT:(bT=1,yT=function(t){return t!=t}),n=(ET||(ET=1,xT=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),xT);return wT=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function $k(){if(OT)return AT;OT=1;var t=FP(),e=kT?PT:(kT=1,PT=function(){}),n=uk(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return AT=r}function qk(){if(RT)return _T;RT=1;var t=ak(),e=function(){if(ST)return NT;ST=1;var t=Hk();return NT=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(TT||(TT=1,CT=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),CT),r=sk(),i=$k(),o=uk();return _T=function(a,s,c){var u=-1,l=e,h=a.length,d=!0,f=[],p=f;if(c)d=!1,l=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,l=r,p=new t}else p=s?[]:f;t:for(;++u<h;){var m=a[u],v=s?s(m):m;if(m=c||0!==m?m:0,d&&v==v){for(var y=p.length;y--;)if(p[y]===v)continue t;s&&p.push(v),f.push(m)}else l(p,v,c)||(p!==f&&p.push(v),f.push(m))}return f},_T}function Yk(){if(IT)return DT;IT=1;var t=gM(),e=mw();return DT=function(n){return e(n)&&t(n)}}function Kk(){if(jT)return LT;jT=1;var t=Fk(),e=Wk(),n=qk(),r=Yk(),i=e((function(e){return n(t(e,1,r,!0))}));return LT=i}function Xk(){if(GT)return FT;GT=1;var t=function(){if(BT)return zT;BT=1;var t=bk();return zT=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=mM();return FT=function(n){return null==n?[]:t(n,e(n))}}function Zk(){if(WT)return VT;var t;WT=1;try{t={clone:ZP(),constant:QP(),each:ok(),filter:Ak(),has:Ok(),isArray:yw(),isEmpty:_k(),isFunction:ew(),isUndefined:Rk(),keys:mM(),map:Ik(),reduce:Lk(),size:zk(),transform:Bk(),union:Kk(),values:Xk()}}catch(t){}return t||(t=window._),VT=t}function Qk(){if(HT)return UT;HT=1;var t=Zk();UT=i;var e="\0",n="\0",r="";function i(e){this._isDirected=!t.has(e,"directed")||e.directed,this._isMultigraph=!!t.has(e,"multigraph")&&e.multigraph,this._isCompound=!!t.has(e,"compound")&&e.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function o(t,e){t[e]?t[e]++:t[e]=1}function a(t,e){--t[e]||delete t[e]}function s(n,i,o,a){var s=""+i,c=""+o;if(!n&&s>c){var u=s;s=c,c=u}return s+r+c+r+(t.isUndefined(a)?e:a)}function c(t,e){return s(t,e.v,e.w,e.name)}return i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(t){return this._label=t,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return t.keys(this._nodes)},i.prototype.sources=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._in[n])}))},i.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._out[n])}))},i.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,(function(t){r.length>1?i.setNode(t,n):i.setNode(t)})),this},i.prototype.setNode=function(e,r){return t.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=r),this):(this._nodes[e]=arguments.length>1?r:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=n,this._children[e]={},this._children[n][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},i.prototype.node=function(t){return this._nodes[t]},i.prototype.hasNode=function(e){return t.has(this._nodes,e)},i.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),(function(t){n.setParent(t)})),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},i.prototype.setParent=function(e,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=n;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===e)throw new Error("Setting "+r+" as parent of "+e+" would create a cycle");this.setNode(r)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=r,this._children[r][e]=!0,this},i.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},i.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==n)return e}},i.prototype.children=function(e){if(t.isUndefined(e)&&(e=n),this._isCompound){var r=this._children[e];if(r)return t.keys(r)}else{if(e===n)return this.nodes();if(this.hasNode(e))return[]}},i.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},i.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},i.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},i.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},i.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,(function(t,r){e(r)&&n.setNode(r,t)})),t.each(this._edgeObjs,(function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))}));var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),(function(t){n.setParent(t,o(t))})),n},i.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return t.values(this._edgeObjs)},i.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,(function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e})),this},i.prototype.setEdge=function(){var e,n,r,i,a=!1,c=arguments[0];"object"==typeof c&&null!==c&&"v"in c?(e=c.v,n=c.w,r=c.name,2===arguments.length&&(i=arguments[1],a=!0)):(e=c,n=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),e=""+e,n=""+n,t.isUndefined(r)||(r=""+r);var u=s(this._isDirected,e,n,r);if(t.has(this._edgeLabels,u))return a&&(this._edgeLabels[u]=i),this;if(!t.isUndefined(r)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[u]=a?i:this._defaultEdgeLabelFn(e,n,r);var l=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var a=i;i=o,o=a}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,r);return e=l.v,n=l.w,Object.freeze(l),this._edgeObjs[u]=l,o(this._preds[n],e),o(this._sucs[e],n),this._in[n][u]=l,this._out[e][u]=l,this._edgeCount++,this},i.prototype.edge=function(t,e,n){var r=1===arguments.length?c(this._isDirected,arguments[0]):s(this._isDirected,t,e,n);return this._edgeLabels[r]},i.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?c(this._isDirected,arguments[0]):s(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},i.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?c(this._isDirected,arguments[0]):s(this._isDirected,t,e,n),i=this._edgeObjs[r];return i&&(t=i.v,e=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],a(this._preds[e],t),a(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},i.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.v===n})):i}},i.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.w===n})):i}},i.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},UT}function Jk(){return KT?YT:(KT=1,YT={Graph:Qk(),version:qT?$T:(qT=1,$T="2.1.8")})}function tA(){if(ZT)return XT;ZT=1;var t=Zk(),e=Qk();function n(e){return t.map(e.nodes(),(function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o}))}function r(e){return t.map(e.edges(),(function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i}))}return XT={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,(function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)})),t.each(n.edges,(function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),r}}}function eA(){if(JT)return QT;JT=1;var t=Zk();return QT=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),(function(t){n=[],o(t),n.length&&i.push(n)})),i},QT}function nA(){if(eP)return tP;eP=1;var t=Zk();function e(){this._arr=[],this._keyIndices={}}return tP=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},tP}function rA(){if(rP)return nP;rP=1;var t=Zk(),e=nA();nP=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},c=new e,u=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);u<n.distance&&(n.distance=u,n.predecessor=o,c.decrease(e,u))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},c.add(t,e)}));for(;c.size()>0&&(o=c.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(u);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return nP}function iA(){if(oP)return iP;oP=1;var t=rA(),e=Zk();return iP=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function oA(){if(sP)return aP;sP=1;var t=Zk();return aP=function(e){var n=0,r=[],i={},o=[];function a(s){var c=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach((function(e){t.has(i,e)?i[e].onStack&&(c.lowlink=Math.min(c.lowlink,i[e].index)):(a(e),c.lowlink=Math.min(c.lowlink,i[e].lowlink))})),c.lowlink===c.index){var u,l=[];do{u=r.pop(),i[u].onStack=!1,l.push(u)}while(s!==u);o.push(l)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},aP}function aA(){if(uP)return cP;uP=1;var t=Zk(),e=oA();return cP=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function sA(){if(hP)return lP;hP=1;var t=Zk();lP=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach((function(t){r[t]={},r[t][t]={distance:0},i.forEach((function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})})),n(t).forEach((function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}}))})),i.forEach((function(t){var e=r[t];i.forEach((function(n){var o=r[n];i.forEach((function(n){var r=o[t],i=e[n],a=o[n],s=r.distance+i.distance;s<a.distance&&(a.distance=s,a.predecessor=i.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return lP}function cA(){if(fP)return dP;fP=1;var t=Zk();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),(function a(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),a),delete i[s],o.push(s))})),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return dP=e,e.CycleException=n,n.prototype=new Error,dP}function uA(){if(gP)return pP;gP=1;var t=cA();return pP=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function lA(){if(vP)return mP;vP=1;var t=Zk();function e(n,r,i,o,a,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(a(r),(function(t){e(n,t,i,o,a,s)})),i&&s.push(r))}return mP=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],s={};return t.each(r,(function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,a)})),a},mP}function hA(){if(bP)return yP;bP=1;var t=lA();return yP=function(e,n){return t(e,n,"post")}}function dA(){if(EP)return xP;EP=1;var t=lA();return xP=function(e,n){return t(e,n,"pre")}}function fA(){if(MP)return wP;MP=1;var t=Zk(),e=Qk(),n=nA();return wP=function(r,i){var o,a=new e,s={},c=new n;function u(t){var e=t.v===o?t.w:t.v,n=c.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,c.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){c.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),c.decrease(r.nodes()[0],0);var l=!1;for(;c.size()>0;){if(o=c.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(l)throw new Error("Input graph is not connected: "+r);l=!0}r.nodeEdges(o).forEach(u)}return a}}kP.exports;try{PP=function(){if(TP)return CP;TP=1;var t=Jk();return CP={Graph:t.Graph,json:tA(),alg:SP?NP:(SP=1,NP={components:eA(),dijkstra:rA(),dijkstraAll:iA(),findCycles:aA(),floydWarshall:sA(),isAcyclic:uA(),postorder:hA(),preorder:dA(),prim:fA(),tarjan:oA(),topsort:cA()}),version:t.version}}()}catch(t){}PP||(PP=window.graphlib);var pA,gA,mA,vA,yA,bA,xA,EA,wA,MA,NA,SA,CA,TA,PA,kA,AA,OA,_A,RA,DA,IA,LA,jA,zA,BA,FA,GA,VA,WA,UA,HA,$A,qA,YA,KA,XA,ZA,QA,JA,tO,eO,nO,rO,iO,oO,aO,sO,cO,uO,lO,hO,dO,fO,pO,gO,mO,vO,yO,bO,xO,EO,wO,MO,NO,SO,CO,TO,PO,kO,AO,OO,_O,RO,DO,IO,LO,jO,zO,BO,FO,GO,VO,WO,UO,HO,$O,qO,YO,KO,XO,ZO,QO,JO=PP;function t_(){if(vA)return mA;vA=1;var t=qE(),e=gM(),n=_w(),r=tw();return mA=function(i,o,a){if(!r(a))return!1;var s=typeof o;return!!("number"==s?e(a)&&n(o,a.length):"string"==s&&o in a)&&t(a[o],i)},mA}function e_(){if(SA)return NA;SA=1;var t=function(){if(MA)return wA;MA=1;var t=/\s/;return wA=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},wA}(),e=/^\s+/;return NA=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function n_(){if(kA)return PA;kA=1;var t=function(){if(TA)return CA;TA=1;var t=e_(),e=tw(),n=mk(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return CA=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var c="function"==typeof s.valueOf?s.valueOf():s;s=e(c)?c+"":c}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),e=1/0;return PA=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function r_(){if(RA)return _A;RA=1;var t=Uk(),e=kk(),n=function(){if(OA)return AA;OA=1;var t=n_();return AA=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return _A=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var c=null==a?0:n(a);return c<0&&(c=r(s+c,0)),t(i,e(o,3),c)},_A}function i_(){if(jA)return LA;jA=1;var t=Fk();return LA=function(e){return(null==e?0:e.length)?t(e,1):[]}}function o_(){if(HA)return UA;HA=1;var t=mk();return UA=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=n(a);if(null!=s&&(void 0===c?s==s&&!t(s):r(s,c)))var c=s,u=a}return u},UA}function a_(){if(ZA)return XA;ZA=1;var t=fw(),e=qE();return XA=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function s_(){if(eO)return tO;return eO=1,tO=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function c_(){if(oO)return iO;oO=1;var t=a_(),e=AP(),n=UP(),r=OP(),i=qP(),o=vw(),a=yw(),s=Yk(),c=Ow(),u=ew(),l=tw(),h=function(){if(JA)return QA;JA=1;var t=JE(),e=LP(),n=mw(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return QA=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var c=a.call(i,"constructor")&&i.constructor;return"function"==typeof c&&c instanceof c&&o.call(c)==s}}(),d=lM(),f=s_(),p=function(){if(rO)return nO;rO=1;var t=gw(),e=yM();return nO=function(n){return t(n,e(n))}}();return iO=function(g,m,v,y,b,x,E){var w=f(g,v),M=f(m,v),N=E.get(M);if(N)t(g,v,N);else{var S=x?x(w,M,v+"",g,m,E):void 0,C=void 0===S;if(C){var T=a(M),P=!T&&c(M),k=!T&&!P&&d(M);S=M,T||P||k?a(w)?S=w:s(w)?S=r(w):P?(C=!1,S=e(M,!0)):k?(C=!1,S=n(M,!0)):S=[]:h(M)||o(M)?(S=w,o(w)?S=p(w):l(w)&&!u(w)||(S=i(M))):C=!1}C&&(E.set(M,S),b(S,M,y,x,E),E.delete(M)),t(g,v,S)}}}function u_(){if(fO)return dO;return fO=1,dO=function(t,e){return t<e}}function l_(){if(MO)return wO;MO=1;var t=Mk(),e=function(){if(EO)return xO;EO=1;var t=pw(),e=Ek(),n=_w(),r=tw(),i=wk();return xO=function(o,a,s,c){if(!r(o))return o;for(var u=-1,l=(a=e(a,o)).length,h=l-1,d=o;null!=d&&++u<l;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=c?c(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}t(d,f,p),d=d[f]}return o},xO}(),n=Ek();return wO=function(r,i,o){for(var a=-1,s=i.length,c={};++a<s;){var u=i[a],l=t(r,u);o(l,u)&&e(c,n(u,r),l)}return c},wO}function h_(){if(RO)return _O;RO=1;var t=function(){if(OO)return AO;OO=1;var t=Math.ceil,e=Math.max;return AO=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),c=Array(s);s--;)c[o?s:++a]=n,n+=i;return c},AO}(),e=t_(),n=n_();return _O=function(r){return function(i,o,a){return a&&"number"!=typeof a&&e(i,o,a)&&(o=a=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),a=void 0===a?i<o?1:-1:n(a),t(i,o,a,r)}},_O}function d_(){if(GO)return FO;GO=1;var t=function(){if(BO)return zO;BO=1;var t=mk();return zO=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,c=null===n,u=n==n,l=t(n);if(!c&&!l&&!a&&e>n||a&&s&&u&&!c&&!l||i&&s&&u||!r&&u||!o)return 1;if(!i&&!a&&!l&&e<n||l&&r&&o&&!i&&!a||c&&r&&o||!s&&o||!u)return-1}return 0}}();return FO=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,c=r.length;++i<s;){var u=t(o[i],a[i]);if(u)return i>=c?u:u*("desc"==r[i]?-1:1)}return e.index-n.index},FO}function f_(){if(WO)return VO;WO=1;var t=bk(),e=Mk(),n=kk(),r=Dk(),i=(jO||(jO=1,LO=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),LO),o=Dw(),a=d_(),s=nk(),c=yw();return VO=function(u,l,h){l=l.length?t(l,(function(t){return c(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;l=t(l,o(n));var f=r(u,(function(e,n,r){return{criteria:t(l,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},VO}try{QO={cloneDeep:function(){if(gA)return pA;gA=1;var t=XP();return pA=function(e){return t(e,5)}}(),constant:QP(),defaults:function(){if(bA)return yA;bA=1;var t=Wk(),e=qE(),n=t_(),r=yM(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,c=a.length,u=c>2?a[2]:void 0;for(u&&n(a[0],a[1],u)&&(c=1);++s<c;)for(var l=a[s],h=r(l),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=l[p])}return t}));return yA=a}(),each:ok(),filter:Ak(),find:function(){if(IA)return DA;IA=1;var t=function(){if(EA)return xA;EA=1;var t=kk(),e=gM(),n=mM();return xA=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var c=t(o,3);i=n(i),o=function(t){return c(s[t],t,s)}}var u=r(i,o,a);return u>-1?s[c?i[u]:u]:void 0}},xA}(),e=t(r_());return DA=e}(),flatten:i_(),forEach:ik(),forIn:function(){if(BA)return zA;BA=1;var t=JP(),e=rk(),n=yM();return zA=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:Ok(),isUndefined:Rk(),last:(GA||(GA=1,FA=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),FA),map:Ik(),mapValues:function(){if(WA)return VA;WA=1;var t=fw(),e=tk(),n=kk();return VA=function(r,i){var o={};return i=n(i,3),e(r,(function(e,n,r){t(o,n,i(e,n,r))})),o}}(),max:function(){if(KA)return YA;KA=1;var t=o_(),e=qA?$A:(qA=1,$A=function(t,e){return t>e}),n=nk();return YA=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(hO)return lO;hO=1;var t=function(){if(sO)return aO;sO=1;var t=lw(),e=a_(),n=JP(),r=c_(),i=tw(),o=yM(),a=s_();return aO=function s(c,u,l,h,d){c!==u&&n(u,(function(n,o){if(d||(d=new t),i(n))r(c,u,o,l,s,h,d);else{var f=h?h(a(c,o),n,o+"",c,u,d):void 0;void 0===f&&(f=n),e(c,o,f)}}),o)},aO}(),e=function(){if(uO)return cO;uO=1;var t=Wk(),e=t_();return cO=function(n){return t((function(t,r){var i=-1,o=r.length,a=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(a=n.length>3&&"function"==typeof a?(o--,a):void 0,s&&e(r[0],r[1],s)&&(a=o<3?void 0:a,o=1),t=Object(t);++i<o;){var c=r[i];c&&n(t,c,i,a)}return t}))},cO}(),n=e((function(e,n,r){t(e,n,r)}));return lO=n}(),min:function(){if(gO)return pO;gO=1;var t=o_(),e=u_(),n=nk();return pO=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(vO)return mO;vO=1;var t=o_(),e=kk(),n=u_();return mO=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(bO)return yO;bO=1;var t=ZE();return yO=function(){return t.Date.now()}}(),pick:function(){if(kO)return PO;kO=1;var t=function(){if(SO)return NO;SO=1;var t=l_(),e=Sk();return NO=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(TO)return CO;TO=1;var t=i_(),e=Gk(),n=Vk();return CO=function(r){return n(e(r,void 0,t),r+"")}}(),n=e((function(e,n){return null==e?{}:t(e,n)}));return PO=n}(),range:function(){if(IO)return DO;IO=1;var t=h_()();return DO=t}(),reduce:Lk(),sortBy:function(){if(HO)return UO;HO=1;var t=Fk(),e=f_(),n=Wk(),r=t_(),i=n((function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])}));return UO=i}(),uniqueId:function(){if(qO)return $O;qO=1;var t=xk(),e=0;return $O=function(n){var r=++e;return t(n)+r},$O}(),values:Xk(),zipObject:function(){if(ZO)return XO;ZO=1;var t=pw(),e=(KO||(KO=1,YO=function(t,e,n){for(var r=-1,i=t.length,o=e.length,a={};++r<i;){var s=r<o?e[r]:void 0;n(a,t[r],s)}return a}),YO);return XO=function(n,r){return e(n||[],r||[],t)},XO}()}}catch(t){}QO||(QO=window._);var p_=QO,g_=m_;function m_(){var t={};t._next=t._prev=t,this._sentinel=t}function v_(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function y_(t,e){if("_next"!==t&&"_prev"!==t)return e}m_.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return v_(e),e},m_.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&v_(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},m_.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,y_)),n=n._prev;return"["+t.join(", ")+"]"};var b_=p_,x_=JO.Graph,E_=g_,w_=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new x_,r=0,i=0;b_.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),b_.forEach(t.edges(),(function(t){var o=n.edge(t.v,t.w)||0,a=e(t),s=o+a;n.setEdge(t.v,t.w,s),i=Math.max(i,n.node(t.v).out+=a),r=Math.max(r,n.node(t.w).in+=a)}));var o=b_.range(i+r+3).map((function(){return new E_})),a=r+1;return b_.forEach(n.nodes(),(function(t){S_(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||M_),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)N_(t,e,n,r);for(;r=o.dequeue();)N_(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(N_(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return b_.flatten(b_.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},M_=b_.constant(1);function N_(t,e,n,r,i){var o=i?[]:void 0;return b_.forEach(t.inEdges(r.v),(function(r){var a=t.edge(r),s=t.node(r.v);i&&o.push({v:r.v,w:r.w}),s.out-=a,S_(e,n,s)})),b_.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,S_(e,n,a)})),t.removeNode(r.v),o}function S_(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}var C_=p_,T_=w_,P_={run:function(t){var e="greedy"===t.graph().acyclicer?T_(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){C_.has(r,o)||(r[o]=!0,n[o]=!0,C_.forEach(t.outEdges(o),(function(t){C_.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return C_.forEach(t.nodes(),i),e}(t);C_.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,C_.uniqueId("rev"))}))},undo:function(t){C_.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}}))}};var k_=p_,A_=JO.Graph,O_={addDummyNode:__,simplify:function(t){var e=(new A_).setGraph(t.graph());return k_.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),k_.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new A_({multigraph:t.isMultigraph()}).setGraph(t.graph());return k_.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),k_.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=k_.map(t.nodes(),(function(e){var n={};return k_.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return k_.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=k_.map(t.nodes(),(function(e){var n={};return k_.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return k_.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,a=e.x-i,s=e.y-o,c=t.width/2,u=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*c>Math.abs(a)*u?(s<0&&(u=-u),n=u*a/s,r=u):(a<0&&(c=-c),n=c,r=c*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=k_.map(k_.range(R_(t)+1),(function(){return[]}));return k_.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;k_.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=k_.min(k_.map(t.nodes(),(function(e){return t.node(e).rank})));k_.forEach(t.nodes(),(function(n){var r=t.node(n);k_.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=k_.min(k_.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];k_.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var r=0,i=t.graph().nodeRankFactor;k_.forEach(n,(function(e,n){k_.isUndefined(e)&&n%i!=0?--r:r&&k_.forEach(e,(function(e){t.node(e).rank+=r}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return __(t,"border",i,e)},maxRank:R_,partition:function(t,e){var n={lhs:[],rhs:[]};return k_.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=k_.now();try{return e()}finally{console.log(t+" time: "+(k_.now()-n)+"ms")}},notime:function(t,e){return e()}};function __(t,e,n,r){var i;do{i=k_.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function R_(t){return k_.max(k_.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!k_.isUndefined(n))return n})))}var D_=p_,I_=O_,L_={run:function(t){t.graph().dummyChains=[],D_.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,c=t.node(s).rank,u=e.name,l=t.edge(e),h=l.labelRank;if(c===a+1)return;for(t.removeEdge(e),i=0,++a;a<c;++i,++a)l.points=[],r={width:0,height:0,edgeLabel:l,edgeObj:e,rank:a},n=I_.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=l.width,r.height=l.height,r.dummy="edge-label",r.labelpos=l.labelpos),t.setEdge(o,n,{weight:l.weight},u),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:l.weight},u)}(t,e)}))},undo:function(t){D_.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)}))}};var j_=p_,z_={longestPath:function(t){var e={};j_.forEach(t.sources(),(function n(r){var i=t.node(r);if(j_.has(e,r))return i.rank;e[r]=!0;var o=j_.min(j_.map(t.outEdges(r),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),i.rank=o}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var B_=p_,F_=JO.Graph,G_=z_.slack,V_=function(t){var e,n,r=new F_({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;W_(r,t)<o;)e=U_(r,t),n=r.hasNode(e.v)?G_(t,e):-G_(t,e),H_(r,t,n);return r};function W_(t,e){return B_.forEach(t.nodes(),(function n(r){B_.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||G_(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function U_(t,e){return B_.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return G_(e,n)}))}function H_(t,e,n){B_.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var $_=p_,q_=V_,Y_=z_.slack,K_=z_.longestPath,X_=JO.alg.preorder,Z_=JO.alg.postorder,Q_=O_.simplify,J_=tR;function tR(t){t=Q_(t),K_(t);var e,n=q_(t);for(rR(n),eR(n,t);e=oR(n);)sR(n,t,e,aR(n,t,e))}function eR(t,e){var n=Z_(t,t.nodes());n=n.slice(0,n.length-1),$_.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=nR(t,e,n)}(t,e,n)}))}function nR(t,e,n){var r=t.node(n).parent,i=!0,o=e.edge(n,r),a=0;return o||(i=!1,o=e.edge(r,n)),a=o.weight,$_.forEach(e.nodeEdges(n),(function(o){var s,c,u=o.v===n,l=u?o.w:o.v;if(l!==r){var h=u===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,c=l,t.hasEdge(s,c)){var f=t.edge(n,l).cutvalue;a+=h?-f:f}}})),a}function rR(t,e){arguments.length<2&&(e=t.nodes()[0]),iR(t,{},1,e)}function iR(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,$_.forEach(t.neighbors(r),(function(i){$_.has(e,i)||(n=iR(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function oR(t){return $_.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function aR(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var o=t.node(r),a=t.node(i),s=o,c=!1;o.lim>a.lim&&(s=a,c=!0);var u=$_.filter(e.edges(),(function(e){return c===cR(t,t.node(e.v),s)&&c!==cR(t,t.node(e.w),s)}));return $_.minBy(u,(function(t){return Y_(e,t)}))}function sR(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),rR(t),eR(t,e),function(t,e){var n=$_.find(t.nodes(),(function(t){return!e.node(t).parent})),r=X_(t,n);r=r.slice(1),$_.forEach(r,(function(n){var r=t.node(n).parent,i=e.edge(n,r),o=!1;i||(i=e.edge(r,n),o=!0),e.node(n).rank=e.node(r).rank+(o?i.minlen:-i.minlen)}))}(t,e)}function cR(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}tR.initLowLimValues=rR,tR.initCutValues=eR,tR.calcCutValue=nR,tR.leaveEdge=oR,tR.enterEdge=aR,tR.exchangeEdges=sR;var uR=z_.longestPath,lR=V_,hR=J_,dR=function(t){switch(t.graph().ranker){case"network-simplex":default:pR(t);break;case"tight-tree":!function(t){uR(t),lR(t)}(t);break;case"longest-path":fR(t)}};var fR=uR;function pR(t){hR(t)}var gR=p_,mR=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;gR.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return gR.forEach(t.children(),r),e}(t);gR.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,o=function(t,e,n,r){var i,o,a=[],s=[],c=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>c||u>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:a.concat(s.reverse()),lca:o}}(t,e,i.v,i.w),a=o.path,s=o.lca,c=0,u=a[c],l=!0;n!==i.w;){if(r=t.node(n),l){for(;(u=a[c])!==s&&t.node(u).maxRank<r.rank;)c++;u===s&&(l=!1)}if(!l){for(;c<a.length-1&&t.node(u=a[c+1]).minRank<=r.rank;)c++;u=a[c]}t.setParent(n,u),n=t.successors(n)[0]}}))};var vR=p_,yR=O_,bR={run:function(t){var e=yR.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&vR.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return vR.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=vR.max(vR.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,vR.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return vR.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;vR.forEach(t.children(),(function(a){xR(t,e,i,o,r,n,a)})),t.graph().nodeRankFactor=i},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,vR.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function xR(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var c=yR.addBorderNode(t,"_bt"),u=yR.addBorderNode(t,"_bb"),l=t.node(a);t.setParent(c,a),l.borderTop=c,t.setParent(u,a),l.borderBottom=u,vR.forEach(s,(function(s){xR(t,e,n,r,i,o,s);var l=t.node(s),h=l.borderTop?l.borderTop:s,d=l.borderBottom?l.borderBottom:s,f=l.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(c,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,c,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var ER=p_,wR=O_,MR=function(t){ER.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&ER.forEach(r,e),ER.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)NR(t,"borderLeft","_bl",n,i,o),NR(t,"borderRight","_br",n,i,o)}}))};function NR(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],c=wR.addDummyNode(t,"border",a,n);i[e][o]=c,t.setParent(c,r),s&&t.setEdge(s,c,{weight:1})}var SR=p_,CR={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||TR(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){SR.forEach(t.nodes(),(function(e){kR(t.node(e))})),SR.forEach(t.edges(),(function(e){var n=t.edge(e);SR.forEach(n.points,kR),SR.has(n,"y")&&kR(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){SR.forEach(t.nodes(),(function(e){AR(t.node(e))})),SR.forEach(t.edges(),(function(e){var n=t.edge(e);SR.forEach(n.points,AR),SR.has(n,"x")&&AR(n)}))}(t),TR(t))}};function TR(t){SR.forEach(t.nodes(),(function(e){PR(t.node(e))})),SR.forEach(t.edges(),(function(e){PR(t.edge(e))}))}function PR(t){var e=t.width;t.width=t.height,t.height=e}function kR(t){t.y=-t.y}function AR(t){var e=t.x;t.x=t.y,t.y=e}var OR=p_,_R=function(t){var e={},n=OR.filter(t.nodes(),(function(e){return!t.children(e).length})),r=OR.max(OR.map(n,(function(e){return t.node(e).rank}))),i=OR.map(OR.range(r+1),(function(){return[]}));function o(n){if(!OR.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),OR.forEach(t.successors(n),o)}}var a=OR.sortBy(n,(function(e){return t.node(e).rank}));return OR.forEach(a,o),i};var RR=p_,DR=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=IR(t,e[r-1],e[r]);return n};function IR(t,e,n){for(var r=RR.zipObject(n,RR.map(n,(function(t,e){return e}))),i=RR.flatten(RR.map(e,(function(e){return RR.sortBy(RR.map(t.outEdges(e),(function(e){return{pos:r[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=RR.map(new Array(a),(function(){return 0})),c=0;return RR.forEach(i.forEach((function(t){var e=t.pos+o;s[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=s[e+1]),s[e=e-1>>1]+=t.weight;c+=t.weight*n}))),c}var LR=p_;var jR=p_,zR=function(t,e){var n={};return jR.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};jR.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),jR.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];jR.isUndefined(e)||jR.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(jR.isUndefined(e.barycenter)||jR.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function r(e){return function(n){n.in.push(e),0==--n.indegree&&t.push(n)}}for(;t.length;){var i=t.pop();e.push(i),jR.forEach(i.in.reverse(),n(i)),jR.forEach(i.out,r(i))}return jR.map(jR.filter(e,(function(t){return!t.merged})),(function(t){return jR.pick(t,["vs","i","barycenter","weight"])}))}(jR.filter(n,(function(t){return!t.indegree})))};var BR=p_,FR=O_;function GR(t,e,n){for(var r;e.length&&(r=BR.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var VR=p_,WR=function(t,e){return LR.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=LR.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}}))},UR=zR,HR=function(t,e){var n=FR.partition(t,(function(t){return BR.has(t,"barycenter")})),r=n.lhs,i=BR.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,c=0;r.sort((u=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:u?e.i-t.i:t.i-e.i})),c=GR(o,i,c),BR.forEach(r,(function(t){c+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,c=GR(o,i,c)}));var u;var l={vs:BR.flatten(o,!0)};s&&(l.barycenter=a/s,l.weight=s);return l},$R=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,c=a?a.borderRight:void 0,u={};s&&(o=VR.filter(o,(function(t){return t!==s&&t!==c})));var l=WR(e,o);VR.forEach(l,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,VR.has(o,"barycenter")&&(a=n,s=o,VR.isUndefined(a.barycenter)?(a.barycenter=s.barycenter,a.weight=s.weight):(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight))}var a,s}));var h=UR(l,r);!function(t,e){VR.forEach(t,(function(t){t.vs=VR.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=HR(h,i);if(s&&(d.vs=VR.flatten([s,d.vs,c],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(c)[0]);VR.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var qR=p_,YR=JO.Graph,KR=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=qR.uniqueId("_root")););return e}(t),i=new YR({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return qR.forEach(t.nodes(),(function(o){var a=t.node(o),s=t.parent(o);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),qR.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=qR.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),qR.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var XR=p_;var ZR=p_,QR=_R,JR=DR,tD=$R,eD=KR,nD=function(t,e,n){var r,i={};XR.forEach(n,(function(n){for(var o,a,s=t.parent(n);s;){if((o=t.parent(s))?(a=i[o],i[o]=s):(a=r,r=s),a&&a!==s)return void e.setEdge(a,s);s=o}}))},rD=JO.Graph,iD=O_,oD=function(t){var e=iD.maxRank(t),n=aD(t,ZR.range(1,e+1),"inEdges"),r=aD(t,ZR.range(e-1,-1,-1),"outEdges"),i=QR(t);cD(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,c=0;c<4;++s,++c){sD(s%2?n:r,s%4>=2),i=iD.buildLayerMatrix(t);var u=JR(t,i);u<a&&(c=0,o=ZR.cloneDeep(i),a=u)}cD(t,o)};function aD(t,e,n){return ZR.map(e,(function(e){return eD(t,e,n)}))}function sD(t,e){var n=new rD;ZR.forEach(t,(function(t){var r=t.graph().root,i=tD(t,r,n,e);ZR.forEach(i.vs,(function(e,n){t.node(e).order=n})),nD(t,n,i.vs)}))}function cD(t,e){ZR.forEach(e,(function(e){ZR.forEach(e,(function(e,n){t.node(e).order=n}))}))}var uD=p_,lD=JO.Graph,hD=O_,dD=function(t){var e,n=hD.buildLayerMatrix(t),r=uD.merge(fD(t,n),pD(t,n)),i={};uD.forEach(["u","d"],(function(o){e="u"===o?n:uD.values(n).reverse(),uD.forEach(["l","r"],(function(n){"r"===n&&(e=uD.map(e,(function(t){return uD.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=vD(t,e,r,a),c=yD(t,e,s.root,s.align,"r"===n);"r"===n&&(c=uD.mapValues(c,(function(t){return-t}))),i[o+n]=c}))}));var o=bD(t,i);return xD(i,o),ED(i,t.graph().align)};function fD(t,e){var n={};return uD.reduce(e,(function(e,r){var i=0,o=0,a=e.length,s=uD.last(r);return uD.forEach(r,(function(e,c){var u=function(t,e){if(t.node(e).dummy)return uD.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),l=u?t.node(u).order:a;(u||e===s)&&(uD.forEach(r.slice(o,c+1),(function(e){uD.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||l<a)||o.dummy&&t.node(e).dummy||gD(n,r,e)}))})),o=c+1,i=l)})),r})),n}function pD(t,e){var n={};function r(e,r,i,o,a){var s;uD.forEach(uD.range(r,i),(function(r){s=e[r],t.node(s).dummy&&uD.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&gD(n,e,s)}))}))}return uD.reduce(e,(function(e,n){var i,o=-1,a=0;return uD.forEach(n,(function(s,c){if("border"===t.node(s).dummy){var u=t.predecessors(s);u.length&&(i=t.node(u[0]).order,r(n,a,c,o,i),a=c,o=i)}r(n,a,n.length,i,e.length)})),n})),n}function gD(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function mD(t,e,n){if(e>n){var r=e;e=n,n=r}return uD.has(t[e],n)}function vD(t,e,n,r){var i={},o={},a={};return uD.forEach(e,(function(t){uD.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),uD.forEach(e,(function(t){var e=-1;uD.forEach(t,(function(t){var s=r(t);if(s.length){s=uD.sortBy(s,(function(t){return a[t]}));for(var c=(s.length-1)/2,u=Math.floor(c),l=Math.ceil(c);u<=l;++u){var h=s[u];o[t]===t&&e<a[h]&&!mD(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}function yD(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new lD,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),c=r.node(o),u=0;if(u+=s.width/2,uD.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(u+=n?a:-a),a=0,u+=(s.dummy?e:t)/2,u+=(c.dummy?e:t)/2,u+=c.width/2,uD.has(c,"labelpos"))switch(c.labelpos.toLowerCase()){case"l":a=c.width/2;break;case"r":a=-c.width/2}return a&&(u+=n?a:-a),a=0,u}}(o.nodesep,o.edgesep,r);return uD.forEach(e,(function(e){var r;uD.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],c=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),c||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function c(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}return c((function(t){o[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,o[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),c((function(e){var n=a.outEdges(e).reduce((function(t,e){return Math.min(t,o[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==s&&(o[e]=Math.max(o[e],n))}),a.successors.bind(a)),uD.forEach(r,(function(t){o[t]=o[n[t]]})),o}function bD(t,e){return uD.minBy(uD.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return uD.forIn(e,(function(e,i){var o=function(t,e){return t.node(e).width}(t,i)/2;n=Math.max(e+o,n),r=Math.min(e-o,r)})),n-r}))}function xD(t,e){var n=uD.values(e),r=uD.min(n),i=uD.max(n);uD.forEach(["u","d"],(function(n){uD.forEach(["l","r"],(function(o){var a,s=n+o,c=t[s];if(c!==e){var u=uD.values(c);(a="l"===o?r-uD.min(u):i-uD.max(u))&&(t[s]=uD.mapValues(c,(function(t){return t+a})))}}))}))}function ED(t,e){return uD.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=uD.sortBy(uD.map(t,r));return(i[1]+i[2])/2}))}var wD=p_,MD=O_,ND=dD,SD=function(t){(function(t){var e=MD.buildLayerMatrix(t),n=t.graph().ranksep,r=0;wD.forEach(e,(function(e){var i=wD.max(wD.map(e,(function(e){return t.node(e).height})));wD.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=MD.asNonCompoundGraph(t)),wD.forEach(ND(t),(function(e,n){t.node(n).x=e}))};var CD=p_,TD=P_,PD=L_,kD=dR,AD=O_.normalizeRanks,OD=mR,_D=O_.removeEmptyRanks,RD=bR,DD=MR,ID=CR,LD=oD,jD=SD,zD=O_,BD=JO.Graph,FD=function(t,e){var n=e&&e.debugTiming?zD.time:zD.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new BD({multigraph:!0,compound:!0}),n=XD(t.graph());return e.setGraph(CD.merge({},VD,KD(n,GD),CD.pick(n,WD))),CD.forEach(t.nodes(),(function(n){var r=XD(t.node(n));e.setNode(n,CD.defaults(KD(r,UD),HD)),e.setParent(n,t.parent(n))})),CD.forEach(t.edges(),(function(n){var r=XD(t.edge(n));e.setEdge(n,CD.merge({},qD,KD(r,$D),CD.pick(r,YD)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,CD.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){CD.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){TD.run(t)})),e(" nestingGraph.run",(function(){RD.run(t)})),e(" rank",(function(){kD(zD.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){CD.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};zD.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){_D(t)})),e(" nestingGraph.cleanup",(function(){RD.cleanup(t)})),e(" normalizeRanks",(function(){AD(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;CD.forEach(t.nodes(),(function(n){var r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=CD.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){CD.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){PD.run(t)})),e(" parentDummyChains",(function(){OD(t)})),e(" addBorderSegments",(function(){DD(t)})),e(" order",(function(){LD(t)})),e(" insertSelfEdges",(function(){!function(t){var e=zD.buildLayerMatrix(t);CD.forEach(e,(function(e){var n=0;CD.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,CD.forEach(i.selfEdges,(function(e){zD.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){ID.adjust(t)})),e(" position",(function(){jD(t)})),e(" positionSelfEdges",(function(){!function(t){CD.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){CD.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),o=t.node(CD.last(n.borderLeft)),a=t.node(CD.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}})),CD.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){PD.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){CD.forEach(t.edges(),(function(e){var n=t.edge(e);if(CD.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){ID.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=t.graph(),a=o.marginx||0,s=o.marginy||0;function c(t){var o=t.x,a=t.y,s=t.width,c=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-c/2),i=Math.max(i,a+c/2)}CD.forEach(t.nodes(),(function(e){c(t.node(e))})),CD.forEach(t.edges(),(function(e){var n=t.edge(e);CD.has(n,"x")&&c(n)})),e-=a,r-=s,CD.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),CD.forEach(t.edges(),(function(n){var i=t.edge(n);CD.forEach(i.points,(function(t){t.x-=e,t.y-=r})),CD.has(i,"x")&&(i.x-=e),CD.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){CD.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),o=t.node(e.v),a=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=a,r=o),i.points.unshift(zD.intersectRect(o,n)),i.points.push(zD.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){CD.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){TD.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){CD.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height))})),CD.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,CD.has(i,"x")&&(r.x=i.x,r.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var GD=["nodesep","edgesep","ranksep","marginx","marginy"],VD={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},WD=["acyclicer","ranker","rankdir","align"],UD=["width","height"],HD={width:0,height:0},$D=["minlen","weight","width","height","labeloffset"],qD={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},YD=["labelpos"];function KD(t,e){return CD.mapValues(CD.pick(t,e),Number)}function XD(t){var e={};return CD.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var ZD=p_,QD=O_,JD=JO.Graph,tI={debugOrdering:function(t){var e=QD.buildLayerMatrix(t),n=new JD({compound:!0,multigraph:!0}).setGraph({});return ZD.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),ZD.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),ZD.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),ZD.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var eI={graphlib:JO,layout:FD,debug:tI,util:{time:O_.time,notime:O_.notime},version:"0.8.5"},nI=f(eI);class rI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,rI.defaultOptions,t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return a(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new eI.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>Wt(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach((t=>{const{id:e}=t,n=Object.assign({},t.data);if(void 0!==r){const[e,i]=function(t){if(!t)return[0,0,0];if(Wt(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}(Pt(r)?r(t):r);Object.assign(n,{width:e,height:i})}i.setNode(e.toString(),n)})),e.getAllEdges().forEach((({id:t,source:e,target:n})=>{i.setEdge(e.toString(),n.toString(),{id:t})})),nI.layout(i);const a={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);a.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:s}=r,c=o(r,["id"]),{v:u,w:l}=n;a.edges.push({id:s,source:u,target:l,data:c}),t&&e.mergeEdgeData(s,c)})),a}))}}rI.defaultOptions={};class iI{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new iI({rx:n,ry:r,mass:e,degree:i})}}class oI{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new oI({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new oI({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new oI({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new oI({xmid:t,ymid:e,length:n})}}class aI{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new aI(this.quad.NW()),this.NE=new aI(this.quad.NE()),this.SW=new aI(this.quad.SW()),this.SE=new aI(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const sI={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};const cI={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};const uI={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};const lI=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},hI=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},dI=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,fI=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,pI=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},gI=(t,e,n,r,i,o,a,s)=>{let c,u;const l=i[t.id];if(l)c=l.col*n+n/2+e[0],u=l.row*r+r/2+e[1];else{for(;dI(s,a);)pI(o,a);c=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],fI(s,a),pI(o,a)}t.data.x=c,t.data.y=u},mI={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},vI=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,c)=>{if(s===c)return;if(i[s]!==i[c])return;let u=a.x-e.x,l=a.y-e.y,h=Math.sqrt(u*u+l*l);if(0===h){h=1;const t=s>c?1:-1;u=.01*t,l=.01*t}if(h<o(t[s])/2+o(t[c])/2){const t=r*r/h;n[s].x+=u/h*t,n[s].y+=l/h*t}}))}))},yI=(t,e,n,r,i,o,a,s)=>{const c=o||a/10;return r&&e.forEach(((e,n)=>{const r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o);let s=o/a,c=-r/a;const u=Math.sqrt(e.x*e.x+e.y*e.y);let l=Math.acos((s*e.x+c*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,s*=-1,c*=-1);const h=Math.cos(l)*u;e.x=s*h,e.y=c*h})),t.forEach(((o,a)=>{if(a===i)return;const u=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(u>0&&a!==i){const l=Math.min(c*(n/800),u);if(o.x+=e[a].x/u*l,o.y+=e[a].y/u*l,r){let e=o.x-t[i].x,n=o.y-t[i].y;const r=Math.sqrt(e*e+n*n);e=e/r*s[a],n=n/r*s[a],o.x=t[i].x+e,o.y=t[i].y+n}}})),t},bI={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};const xI=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];if(e){const c={};e.forEach(((e,u)=>{const l=[];e.forEach(((e,s)=>{var h,d;if(u===s)l.push(0);else if(r[u]===r[s])if("data"===o)l.push(e*(Math.abs(u-s)*a)/(r[u]/i));else if(o){let n,f;if(c[t[u].id])n=c[t[u].id];else{const e=("id"===o?t[u].id:null===(h=t[u].data)||void 0===h?void 0:h[o])||0;n=Bt(e)?e.charCodeAt(0):e,c[t[u].id]=n}if(c[t[s].id])f=c[t[s].id];else{const e=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=Bt(e)?e.charCodeAt(0):e,c[t[s].id]=f}l.push(e*(Math.abs(n-f)*a)/(r[u]/i))}else l.push(e*n/(r[u]/i));else{const t=(n+i)/2;l.push(e*t)}})),s.push(l)}))}return s},EI=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},wI=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},MI=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},NI=(t,e)=>{let n=0;for(let r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},SI={center:[0,0],width:300,height:300};function CI(t){return!!t.tick&&!!t.stop}
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).G6={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null,n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function a(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function l(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function h(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function p(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var g={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),u=n?n+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],s]:t._events[u].push(s):(t._events[u]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},s.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},s.prototype.emit=function(t,e,r,i,o,a){var s=n?n+t:t;if(!this._events[s])return!1;var u,c,l=this._events[s],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,i),!0;case 5:return l.fn.call(l.context,e,r,i,o),!0;case 6:return l.fn.call(l.context,e,r,i,o,a),!0}for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var d,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),h){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,r);break;case 4:l[c].fn.call(l[c].context,e,r,i);break;default:if(!u)for(d=1,u=new Array(h-1);d<h;d++)u[d-1]=arguments[d];l[c].fn.apply(l[c].context,u)}}return!0},s.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},s.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},s.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==e||i&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c:a(this,o)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,t.exports=s}(g);var m=f(g.exports),y=1e-6,v="undefined"!=typeof Float32Array?Float32Array:Array;function b(){var t=new v(9);return v!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function x(){var t=new v(16);return v!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function w(t){var e=new v(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function E(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function M(t,e,n,r,i,o,a,s,u,c,l,h,d,f,p,g,m){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=u,t[8]=c,t[9]=l,t[10]=h,t[11]=d,t[12]=f,t[13]=p,t[14]=g,t[15]=m,t}function S(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function N(t,e){if(t===e){var n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function k(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],l=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],y=e[15],v=n*s-r*a,b=n*u-i*a,x=n*c-o*a,w=r*u-i*s,E=r*c-o*s,M=i*c-o*u,S=l*g-h*p,N=l*m-d*p,k=l*y-f*p,C=h*m-d*g,T=h*y-f*g,A=d*y-f*m,P=v*A-b*T+x*C+w*k-E*N+M*S;return P?(P=1/P,t[0]=(s*A-u*T+c*C)*P,t[1]=(i*T-r*A-o*C)*P,t[2]=(g*M-m*E+y*w)*P,t[3]=(d*E-h*M-f*w)*P,t[4]=(u*k-a*A-c*N)*P,t[5]=(n*A-i*k+o*N)*P,t[6]=(m*x-p*M-y*b)*P,t[7]=(l*M-d*x+f*b)*P,t[8]=(a*T-s*k+c*S)*P,t[9]=(r*k-n*T-o*S)*P,t[10]=(p*E-g*x+y*v)*P,t[11]=(h*x-l*E-f*v)*P,t[12]=(s*N-a*C-u*S)*P,t[13]=(n*C-r*N+i*S)*P,t[14]=(g*b-p*w-m*v)*P,t[15]=(l*w-h*b+d*v)*P,t):null}function C(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],u=t[7],c=t[8],l=t[9],h=t[10],d=t[11],f=t[12],p=t[13],g=t[14],m=t[15];return(e*a-n*o)*(h*m-d*g)-(e*s-r*o)*(l*m-d*p)+(e*u-i*o)*(l*g-h*p)+(n*s-r*a)*(c*m-d*f)-(n*u-i*a)*(c*g-h*f)+(r*u-i*s)*(c*p-l*f)}function T(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],l=e[7],h=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],y=e[14],v=e[15],b=n[0],x=n[1],w=n[2],E=n[3];return t[0]=b*r+x*s+w*h+E*g,t[1]=b*i+x*u+w*d+E*m,t[2]=b*o+x*c+w*f+E*y,t[3]=b*a+x*l+w*p+E*v,b=n[4],x=n[5],w=n[6],E=n[7],t[4]=b*r+x*s+w*h+E*g,t[5]=b*i+x*u+w*d+E*m,t[6]=b*o+x*c+w*f+E*y,t[7]=b*a+x*l+w*p+E*v,b=n[8],x=n[9],w=n[10],E=n[11],t[8]=b*r+x*s+w*h+E*g,t[9]=b*i+x*u+w*d+E*m,t[10]=b*o+x*c+w*f+E*y,t[11]=b*a+x*l+w*p+E*v,b=n[12],x=n[13],w=n[14],E=n[15],t[12]=b*r+x*s+w*h+E*g,t[13]=b*i+x*u+w*d+E*m,t[14]=b*o+x*c+w*f+E*y,t[15]=b*a+x*l+w*p+E*v,t}function A(t,e,n){var r,i,o,a,s,u,c,l,h,d,f,p,g=n[0],m=n[1],y=n[2];return e===t?(t[12]=e[0]*g+e[4]*m+e[8]*y+e[12],t[13]=e[1]*g+e[5]*m+e[9]*y+e[13],t[14]=e[2]*g+e[6]*m+e[10]*y+e[14],t[15]=e[3]*g+e[7]*m+e[11]*y+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],l=e[7],h=e[8],d=e[9],f=e[10],p=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=u,t[6]=c,t[7]=l,t[8]=h,t[9]=d,t[10]=f,t[11]=p,t[12]=r*g+s*m+h*y+e[12],t[13]=i*g+u*m+d*y+e[13],t[14]=o*g+c*m+f*y+e[14],t[15]=a*g+l*m+p*y+e[15]),t}function P(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function O(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],l=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+c*r,t[5]=a*i+l*r,t[6]=s*i+h*r,t[7]=u*i+d*r,t[8]=c*i-o*r,t[9]=l*i-a*r,t[10]=h*i-s*r,t[11]=d*i-u*r,t}function _(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],u=e[3],c=e[8],l=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-c*r,t[1]=a*i-l*r,t[2]=s*i-h*r,t[3]=u*i-d*r,t[8]=o*r+c*i,t[9]=a*r+l*i,t[10]=s*r+h*i,t[11]=u*r+d*i,t}function R(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function I(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function D(t,e,n){var r,i,o,a=n[0],s=n[1],u=n[2],c=Math.hypot(a,s,u);return c<y?null:(a*=c=1/c,s*=c,u*=c,r=Math.sin(e),o=1-(i=Math.cos(e)),t[0]=a*a*o+i,t[1]=s*a*o+u*r,t[2]=u*a*o-s*r,t[3]=0,t[4]=a*s*o-u*r,t[5]=s*s*o+i,t[6]=u*s*o+a*r,t[7]=0,t[8]=a*u*o+s*r,t[9]=s*u*o-a*r,t[10]=u*u*o+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function L(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function j(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function B(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function z(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=r+r,u=i+i,c=o+o,l=r*s,h=r*u,d=r*c,f=i*u,p=i*c,g=o*c,m=a*s,y=a*u,v=a*c;return t[0]=1-(f+g),t[1]=h+v,t[2]=d-y,t[3]=0,t[4]=h-v,t[5]=1-(l+g),t[6]=p+m,t[7]=0,t[8]=d+y,t[9]=p-m,t[10]=1-(l+f),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function F(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function G(t,e){var n=e[0],r=e[1],i=e[2],o=e[4],a=e[5],s=e[6],u=e[8],c=e[9],l=e[10];return t[0]=Math.hypot(n,r,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(u,c,l),t}function V(t,e){var n=new v(3);G(n,e);var r=1/n[0],i=1/n[1],o=1/n[2],a=e[0]*r,s=e[1]*i,u=e[2]*o,c=e[4]*r,l=e[5]*i,h=e[6]*o,d=e[8]*r,f=e[9]*i,p=e[10]*o,g=a+l+p,m=0;return g>0?(m=2*Math.sqrt(g+1),t[3]=.25*m,t[0]=(h-f)/m,t[1]=(d-u)/m,t[2]=(s-c)/m):a>l&&a>p?(m=2*Math.sqrt(1+a-l-p),t[3]=(h-f)/m,t[0]=.25*m,t[1]=(s+c)/m,t[2]=(d+u)/m):l>p?(m=2*Math.sqrt(1+l-a-p),t[3]=(d-u)/m,t[0]=(s+c)/m,t[1]=.25*m,t[2]=(h+f)/m):(m=2*Math.sqrt(1+p-a-l),t[3]=(s-c)/m,t[0]=(d+u)/m,t[1]=(h+f)/m,t[2]=.25*m),t}function W(t,e,n,r,i){var o=e[0],a=e[1],s=e[2],u=e[3],c=o+o,l=a+a,h=s+s,d=o*c,f=o*l,p=o*h,g=a*l,m=a*h,y=s*h,v=u*c,b=u*l,x=u*h,w=r[0],E=r[1],M=r[2],S=i[0],N=i[1],k=i[2],C=(1-(g+y))*w,T=(f+x)*w,A=(p-b)*w,P=(f-x)*E,O=(1-(d+y))*E,_=(m+v)*E,R=(p+b)*M,I=(m-v)*M,D=(1-(d+g))*M;return t[0]=C,t[1]=T,t[2]=A,t[3]=0,t[4]=P,t[5]=O,t[6]=_,t[7]=0,t[8]=R,t[9]=I,t[10]=D,t[11]=0,t[12]=n[0]+S-(C*S+P*N+R*k),t[13]=n[1]+N-(T*S+O*N+I*k),t[14]=n[2]+k-(A*S+_*N+D*k),t[15]=1,t}function H(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,s=r+r,u=i+i,c=n*a,l=r*a,h=r*s,d=i*a,f=i*s,p=i*u,g=o*a,m=o*s,y=o*u;return t[0]=1-h-p,t[1]=l+y,t[2]=d-m,t[3]=0,t[4]=l-y,t[5]=1-c-p,t[6]=f+g,t[7]=0,t[8]=d+m,t[9]=f-g,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function U(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=(i+r)*o,t[14]=2*i*r*o):(t[10]=-1,t[14]=-2*r),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var $=U;function q(t,e,n,r,i,o,a){var s=1/(e-n),u=1/(r-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*u,t[14]=(a+o)*c,t[15]=1,t}var Y=q;function K(t,e,n,r,i,o,a){var s=1/(e-n),u=1/(r-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*u,t[14]=o*c,t[15]=1,t}function X(t,e,n,r){var i,o,a,s,u,c,l,h,d,f,p=e[0],g=e[1],m=e[2],v=r[0],b=r[1],x=r[2],w=n[0],E=n[1],M=n[2];return Math.abs(p-w)<y&&Math.abs(g-E)<y&&Math.abs(m-M)<y?S(t):(l=p-w,h=g-E,d=m-M,i=b*(d*=f=1/Math.hypot(l,h,d))-x*(h*=f),o=x*(l*=f)-v*d,a=v*h-b*l,(f=Math.hypot(i,o,a))?(i*=f=1/f,o*=f,a*=f):(i=0,o=0,a=0),s=h*a-d*o,u=d*i-l*a,c=l*o-h*i,(f=Math.hypot(s,u,c))?(s*=f=1/f,u*=f,c*=f):(s=0,u=0,c=0),t[0]=i,t[1]=s,t[2]=l,t[3]=0,t[4]=o,t[5]=u,t[6]=h,t[7]=0,t[8]=a,t[9]=c,t[10]=d,t[11]=0,t[12]=-(i*p+o*g+a*m),t[13]=-(s*p+u*g+c*m),t[14]=-(l*p+h*g+d*m),t[15]=1,t)}function Z(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}var Q=T,J=Z,tt=Object.freeze({__proto__:null,add:function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t},adjoint:function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],l=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],m=e[14],y=e[15];return t[0]=s*(d*y-f*m)-h*(u*y-c*m)+g*(u*f-c*d),t[1]=-(r*(d*y-f*m)-h*(i*y-o*m)+g*(i*f-o*d)),t[2]=r*(u*y-c*m)-s*(i*y-o*m)+g*(i*c-o*u),t[3]=-(r*(u*f-c*d)-s*(i*f-o*d)+h*(i*c-o*u)),t[4]=-(a*(d*y-f*m)-l*(u*y-c*m)+p*(u*f-c*d)),t[5]=n*(d*y-f*m)-l*(i*y-o*m)+p*(i*f-o*d),t[6]=-(n*(u*y-c*m)-a*(i*y-o*m)+p*(i*c-o*u)),t[7]=n*(u*f-c*d)-a*(i*f-o*d)+l*(i*c-o*u),t[8]=a*(h*y-f*g)-l*(s*y-c*g)+p*(s*f-c*h),t[9]=-(n*(h*y-f*g)-l*(r*y-o*g)+p*(r*f-o*h)),t[10]=n*(s*y-c*g)-a*(r*y-o*g)+p*(r*c-o*s),t[11]=-(n*(s*f-c*h)-a*(r*f-o*h)+l*(r*c-o*s)),t[12]=-(a*(h*m-d*g)-l*(s*m-u*g)+p*(s*d-u*h)),t[13]=n*(h*m-d*g)-l*(r*m-i*g)+p*(r*d-i*h),t[14]=-(n*(s*m-u*g)-a*(r*m-i*g)+p*(r*u-i*s)),t[15]=n*(s*d-u*h)-a*(r*d-i*h)+l*(r*u-i*s),t},clone:w,copy:E,create:x,determinant:C,equals:function(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],u=t[6],c=t[7],l=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],m=t[14],v=t[15],b=e[0],x=e[1],w=e[2],E=e[3],M=e[4],S=e[5],N=e[6],k=e[7],C=e[8],T=e[9],A=e[10],P=e[11],O=e[12],_=e[13],R=e[14],I=e[15];return Math.abs(n-b)<=y*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-x)<=y*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(i-w)<=y*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(o-E)<=y*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(a-M)<=y*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(s-S)<=y*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(u-N)<=y*Math.max(1,Math.abs(u),Math.abs(N))&&Math.abs(c-k)<=y*Math.max(1,Math.abs(c),Math.abs(k))&&Math.abs(l-C)<=y*Math.max(1,Math.abs(l),Math.abs(C))&&Math.abs(h-T)<=y*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(d-A)<=y*Math.max(1,Math.abs(d),Math.abs(A))&&Math.abs(f-P)<=y*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(p-O)<=y*Math.max(1,Math.abs(p),Math.abs(O))&&Math.abs(g-_)<=y*Math.max(1,Math.abs(g),Math.abs(_))&&Math.abs(m-R)<=y*Math.max(1,Math.abs(m),Math.abs(R))&&Math.abs(v-I)<=y*Math.max(1,Math.abs(v),Math.abs(I))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},fromQuat:H,fromQuat2:function(t,e){var n=new v(3),r=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],u=e[5],c=e[6],l=e[7],h=r*r+i*i+o*o+a*a;return h>0?(n[0]=2*(s*a+l*r+u*o-c*i)/h,n[1]=2*(u*a+l*i+c*r-s*o)/h,n[2]=2*(c*a+l*o+s*i-u*r)/h):(n[0]=2*(s*a+l*r+u*o-c*i),n[1]=2*(u*a+l*i+c*r-s*o),n[2]=2*(c*a+l*o+s*i-u*r)),z(t,e,n),t},fromRotation:D,fromRotationTranslation:z,fromRotationTranslationScale:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=e[3],u=i+i,c=o+o,l=a+a,h=i*u,d=i*c,f=i*l,p=o*c,g=o*l,m=a*l,y=s*u,v=s*c,b=s*l,x=r[0],w=r[1],E=r[2];return t[0]=(1-(p+m))*x,t[1]=(d+b)*x,t[2]=(f-v)*x,t[3]=0,t[4]=(d-b)*w,t[5]=(1-(h+m))*w,t[6]=(g+y)*w,t[7]=0,t[8]=(f+v)*E,t[9]=(g-y)*E,t[10]=(1-(h+p))*E,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:W,fromScaling:I,fromTranslation:R,fromValues:function(t,e,n,r,i,o,a,s,u,c,l,h,d,f,p,g){var m=new v(16);return m[0]=t,m[1]=e,m[2]=n,m[3]=r,m[4]=i,m[5]=o,m[6]=a,m[7]=s,m[8]=u,m[9]=c,m[10]=l,m[11]=h,m[12]=d,m[13]=f,m[14]=p,m[15]=g,m},fromXRotation:L,fromYRotation:j,fromZRotation:B,frustum:function(t,e,n,r,i,o,a){var s=1/(n-e),u=1/(i-r),c=1/(o-a);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*u,t[6]=0,t[7]=0,t[8]=(n+e)*s,t[9]=(i+r)*u,t[10]=(a+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*c,t[15]=0,t},getRotation:V,getScaling:G,getTranslation:F,identity:S,invert:k,lookAt:X,mul:Q,multiply:T,multiplyScalar:function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12]*n,t[13]=e[13]*n,t[14]=e[14]*n,t[15]=e[15]*n,t},multiplyScalarAndAdd:function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t[9]=e[9]+n[9]*r,t[10]=e[10]+n[10]*r,t[11]=e[11]+n[11]*r,t[12]=e[12]+n[12]*r,t[13]=e[13]+n[13]*r,t[14]=e[14]+n[14]*r,t[15]=e[15]+n[15]*r,t},ortho:Y,orthoNO:q,orthoZO:K,perspective:$,perspectiveFromFieldOfView:function(t,e,n,r){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),u=2/(a+s),c=2/(i+o);return t[0]=u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(a-s)*u*.5,t[9]=(i-o)*c*.5,t[10]=r/(n-r),t[11]=-1,t[12]=0,t[13]=0,t[14]=r*n/(n-r),t[15]=0,t},perspectiveNO:U,perspectiveZO:function(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(o=1/(r-i),t[10]=i*o,t[14]=i*r*o):(t[10]=-1,t[14]=-r),t},rotate:function(t,e,n,r){var i,o,a,s,u,c,l,h,d,f,p,g,m,v,b,x,w,E,M,S,N,k,C,T,A=r[0],P=r[1],O=r[2],_=Math.hypot(A,P,O);return _<y?null:(A*=_=1/_,P*=_,O*=_,i=Math.sin(n),a=1-(o=Math.cos(n)),s=e[0],u=e[1],c=e[2],l=e[3],h=e[4],d=e[5],f=e[6],p=e[7],g=e[8],m=e[9],v=e[10],b=e[11],x=A*A*a+o,w=P*A*a+O*i,E=O*A*a-P*i,M=A*P*a-O*i,S=P*P*a+o,N=O*P*a+A*i,k=A*O*a+P*i,C=P*O*a-A*i,T=O*O*a+o,t[0]=s*x+h*w+g*E,t[1]=u*x+d*w+m*E,t[2]=c*x+f*w+v*E,t[3]=l*x+p*w+b*E,t[4]=s*M+h*S+g*N,t[5]=u*M+d*S+m*N,t[6]=c*M+f*S+v*N,t[7]=l*M+p*S+b*N,t[8]=s*k+h*C+g*T,t[9]=u*k+d*C+m*T,t[10]=c*k+f*C+v*T,t[11]=l*k+p*C+b*T,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:O,rotateY:_,rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],u=e[3],c=e[4],l=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+c*r,t[1]=a*i+l*r,t[2]=s*i+h*r,t[3]=u*i+d*r,t[4]=c*i-o*r,t[5]=l*i-a*r,t[6]=h*i-s*r,t[7]=d*i-u*r,t},scale:P,set:M,str:function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},sub:J,subtract:Z,targetTo:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=r[0],u=r[1],c=r[2],l=i-n[0],h=o-n[1],d=a-n[2],f=l*l+h*h+d*d;f>0&&(l*=f=1/Math.sqrt(f),h*=f,d*=f);var p=u*d-c*h,g=c*l-s*d,m=s*h-u*l;return(f=p*p+g*g+m*m)>0&&(p*=f=1/Math.sqrt(f),g*=f,m*=f),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=h*m-d*g,t[5]=d*p-l*m,t[6]=l*g-h*p,t[7]=0,t[8]=l,t[9]=h,t[10]=d,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t},translate:A,transpose:N});function et(){var t=new v(3);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function nt(t){var e=new v(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function rt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function it(t,e,n){var r=new v(3);return r[0]=t,r[1]=e,r[2]=n,r}function ot(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function at(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function st(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function ut(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function ct(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function lt(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function ht(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function dt(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],u=n[2];return t[0]=i*u-o*s,t[1]=o*a-r*u,t[2]=r*s-i*a,t}function ft(t,e,n,r){var i=e[0],o=e[1],a=e[2];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t[2]=a+r*(n[2]-a),t}function pt(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/a,t[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,t[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,t}function gt(t,e){var n=t[0],r=t[1],i=t[2],o=e[0],a=e[1],s=e[2];return Math.abs(n-o)<=y*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=y*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=y*Math.max(1,Math.abs(i),Math.abs(s))}var mt=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.hypot(n,r,i)},yt=rt;function vt(){var t=new v(4);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function bt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}function xt(){var t=new v(4);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function wt(t,e,n){n*=.5;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function Et(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=n[0],u=n[1],c=n[2],l=n[3];return t[0]=r*l+a*s+i*c-o*u,t[1]=i*l+a*u+o*s-r*c,t[2]=o*l+a*c+r*u-i*s,t[3]=a*l-r*s-i*u-o*c,t}function Mt(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return t[0]=-n*s,t[1]=-r*s,t[2]=-i*s,t[3]=o*s,t}function St(t,e,n,r){var i=.5*Math.PI/180;e*=i,n*=i,r*=i;var o=Math.sin(e),a=Math.cos(e),s=Math.sin(n),u=Math.cos(n),c=Math.sin(r),l=Math.cos(r);return t[0]=o*u*l-a*s*c,t[1]=a*s*l+o*u*c,t[2]=a*u*c-o*s*l,t[3]=a*u*l+o*s*c,t}et(),function(){var t=vt()}();var Nt=function(t,e,n,r){var i=new v(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i},kt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Ct=Et,Tt=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=n*a,t[1]=r*a,t[2]=i*a,t[3]=o*a,t};et(),it(1,0,0),it(0,1,0),xt(),xt(),b(),function(){var t,e=(t=new v(2),v!=Float32Array&&(t[0]=0,t[1]=0),t)}();var At=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Pt=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!At(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n}(t,(function(t){return!function(t,e){return!!At(t)&&t.indexOf(e)>-1}(e,t)}))},Ot=function(t){return"function"==typeof t},_t=function(t){return null==t},Rt={}.toString,It=function(t,e){return Rt.call(t)==="[object "+e+"]"},Dt=function(t){return Array.isArray?Array.isArray(t):It(t,"Array")},Lt=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function jt(t,e){if(t)if(Dt(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(Lt(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Bt=function(t){return"object"==typeof t&&null!==t},zt=function(t){if(!Bt(t)||!It(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},Ft=function(t){if(Dt(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},Gt=function(t){if(Dt(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},Vt=function(t){return It(t,"String")},Wt=Object.prototype.hasOwnProperty;function Ht(t,e){if(!e||!Dt(t))return{};for(var n,r={},i=Ot(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),Wt.call(r,n)?r[n].push(a):r[n]=[a]}return r}var Ut=function(t,e,n){return t<e?e:t>n?n:t},$t=function(t){return It(t,"Number")},qt=1e-5;function Yt(t,e,n){return void 0===n&&(n=qt),Math.abs(t-e)<n}var Kt=function(t,e){if(Dt(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=Ot(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},Xt=function(t,e){if(Dt(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=Ot(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},Zt=function(t,e){return(t%e+e)%e},Qt=function(t){return _t(t)?"":t.toString()},Jt=function(t){var e=Qt(t);return e.charAt(0).toLowerCase()+e.substring(1)};var te=function(t){var e=Qt(t);return e.charAt(0).toUpperCase()+e.substring(1)},ee={}.toString,ne=function(t){return It(t,"Boolean")},re=Object.prototype,ie=function(t){return void 0===t},oe=function(t){if("object"!=typeof t||null===t)return t;var e;if(Dt(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=oe(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=oe(t[i]):e[i]=t[i];return e};function ae(t,e,n){var r;return function(){var n=this,i=arguments;clearTimeout(r),r=setTimeout((function(){r=null,t.apply(n,i)}),e)}}function se(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function ue(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(se(e,i)){var o=e[i];null!==o&&zt(o)?(zt(t[i])||(t[i]={}),n<r?ue(t[i],o,n+1,r):t[i]=e[i]):Dt(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var ce=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)ue(t,e[r]);return t},le=Object.prototype.hasOwnProperty;function he(t){if(_t(t))return!0;if(At(t))return!t.length;var e=function(t){return ee.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||re)}(t))return!Object.keys(t).length;for(var n in t)if(le.call(t,n))return!1;return!0}var de=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(Vt(t)||Vt(e))return!1;if(At(t)||At(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=de(t[r],e[r]));r++);return n}if(Bt(t)||Bt(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=de(t[i[r]],e[i[r]]));r++);return n}return!1},fe=function(t,e,n){for(var r=0,i=Vt(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},pe=function(t,e,n){var r=t,i=Vt(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Lt(r[t])||(r[t]=$t(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},ge=Object.prototype.hasOwnProperty,me=function(t,e){if(null===t||!zt(t))return{};var n={};return jt(e,(function(e){ge.call(t,e)&&(n[e]=t[e])})),n},ye=function(t,e){return function(t,e,n){if(!Dt(t)&&!zt(t))return t;var r=n;return jt(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},ve={},be=function(){},xe=function(t){return t},we={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function Ee(t,e,n){if(t[n].length>7){t[n].shift();for(var r=t[n],i=n;r.length;)e[n]="A",t.splice(i+=1,0,["C"].concat(r.splice(0,6)));t.splice(n,1)}}var Me={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function Se(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return Me[e]===t.length-1&&"achlmqstvz".includes(e)}))}function Ne(t){return Se(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function ke(t){return Ne(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function Ce(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=Me[n]&&("m"===n&&r.length>2?(t.segments.push([e].concat(r.splice(0,2))),n="l",e="m"===e?"l":"L"):t.segments.push([e].concat(r.splice(0,Me[n]))),Me[n]););}function Te(t){var e=t.index,n=t.pathValue,r=n.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='[path-util]: invalid Arc flag "'+n[e]+'", expecting 0 or 1 at index '+e)}function Ae(t){return t>=48&&t<=57||43===t||45===t||46===t}function Pe(t){return t>=48&&t<=57}function Oe(t){var e,n=t.max,r=t.pathValue,i=t.index,o=i,a=!1,s=!1,u=!1,c=!1;if(o>=n)t.err="[path-util]: Invalid path value at index "+o+', "pathValue" is missing param';else if(43!==(e=r.charCodeAt(o))&&45!==e||(o+=1,e=r.charCodeAt(o)),Pe(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&Pe(e))return void(t.err="[path-util]: Invalid path value at index "+i+', "'+r[i]+'" illegal number');for(;o<n&&Pe(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(c=!0,o+=1;Pe(r.charCodeAt(o));)o+=1,u=!0;e=r.charCodeAt(o)}if(101===e||69===e){if(c&&!s&&!u)return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid float exponent');if(o+=1,43!==(e=r.charCodeAt(o))&&45!==e||(o+=1),!(o<n&&Pe(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid integer exponent');for(;o<n&&Pe(r.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" is not a number'}function _e(t){for(var e,n=t.pathValue,r=t.max;t.index<r&&(10===(e=n.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e));)t.index+=1}function Re(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=Me[n[r].toLowerCase()];if(t.segmentStart=r,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(i))if(t.index+=1,_e(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?Oe(t):Te(t),t.err.length)return;t.data.push(t.param),_e(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,_e(t))}if(t.index>=t.max)break;if(!Ae(n.charCodeAt(t.index)))break}Ce(t)}else Ce(t);else t.err='[path-util]: Invalid path value "'+n[r]+'" is not a path command'}var Ie=function(t){this.pathValue=t,this.segments=[],this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""};function De(t){if(Ne(t))return[].concat(t);var e=function(t){if(Se(t))return[].concat(t);var e=new Ie(t);for(_e(e);e.index<e.max&&!e.err.length;)Re(e);return e.err?e.err:e.segments}(t),n=0,r=0,i=0,o=0;return e.map((function(t){var e,a=t.slice(1).map(Number),s=t[0],u=s.toUpperCase();if("M"===s)return n=a[0],r=a[1],i=n,o=r,["M",n,r];if(s!==u)switch(u){case"A":e=[u,a[0],a[1],a[2],a[3],a[4],a[5]+n,a[6]+r];break;case"V":e=[u,a[0]+r];break;case"H":e=[u,a[0]+n];break;default:var c=a.map((function(t,e){return t+(e%2?r:n)}));e=[u].concat(c)}else e=[u].concat(a);var l=e.length;switch(u){case"Z":n=i,r=o;break;case"H":n=e[1];break;case"V":r=e[1];break;default:n=e[l-2],r=e[l-1],"M"===u&&(i=n,o=r)}return e}))}function Le(t,e){var n=t[0],r=e.x1,i=e.y1,o=e.x2,a=e.y2,s=t.slice(1).map(Number),u=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)u=["L",t[1],i];else if("V"===n)u=["L",r,t[1]];else if("S"===n){var c=2*r-o,l=2*i-a;e.x1=c,e.y1=l,u=["C",c,l].concat(s)}else if("T"===n){var h=2*r-e.qx,d=2*i-e.qy;e.qx=h,e.qy=d,u=["Q",h,d].concat(s)}else if("Q"===n){var f=s[0],p=s[1];e.qx=f,e.qy=p}return u}function je(t){if(ke(t))return[].concat(t);for(var e=De(t),n=i({},we),r=0;r<e.length;r+=1){e[r]=Le(e[r],n);var o=e[r],a=o.length;n.x1=+o[a-2],n.y1=+o[a-1],n.x2=+o[a-4]||n.x1,n.y2=+o[a-3]||n.y1}return e}function Be(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function ze(t,e,n,r,i,o,a,s,u,c){var l,h,d,f,p,g=t,m=e,y=n,v=r,b=s,x=u,w=120*Math.PI/180,E=Math.PI/180*(+i||0),M=[];if(c)h=c[0],d=c[1],f=c[2],p=c[3];else{g=(l=Be(g,m,-E)).x,m=l.y;var S=(g-(b=(l=Be(b,x,-E)).x))/2,N=(m-(x=l.y))/2,k=S*S/(y*y)+N*N/(v*v);k>1&&(y*=k=Math.sqrt(k),v*=k);var C=y*y,T=v*v,A=(o===a?-1:1)*Math.sqrt(Math.abs((C*T-C*N*N-T*S*S)/(C*N*N+T*S*S)));f=A*y*N/v+(g+b)/2,p=A*-v*S/y+(m+x)/2,h=Math.asin(((m-p)/v*Math.pow(10,9)|0)/Math.pow(10,9)),d=Math.asin(((x-p)/v*Math.pow(10,9)|0)/Math.pow(10,9)),h=g<f?Math.PI-h:h,d=b<f?Math.PI-d:d,h<0&&(h=2*Math.PI+h),d<0&&(d=2*Math.PI+d),a&&h>d&&(h-=2*Math.PI),!a&&d>h&&(d-=2*Math.PI)}var P=d-h;if(Math.abs(P)>w){var O=d,_=b,R=x;d=h+w*(a&&d>h?1:-1),M=ze(b=f+y*Math.cos(d),x=p+v*Math.sin(d),y,v,i,0,a,_,R,[d,O,f,p])}P=d-h;var I=Math.cos(h),D=Math.sin(h),L=Math.cos(d),j=Math.sin(d),B=Math.tan(P/4),z=4/3*y*B,F=4/3*v*B,G=[g,m],V=[g+z*D,m-F*I],W=[b+z*j,x-F*L],H=[b,x];if(V[0]=2*G[0]-V[0],V[1]=2*G[1]-V[1],c)return V.concat(W,H,M);for(var U=[],$=0,q=(M=V.concat(W,H,M)).length;$<q;$+=1)U[$]=$%2?Be(M[$-1],M[$],E).y:Be(M[$],M[$+1],E).x;return U}function Fe(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var Ge=function(t,e,n,r){return l(l([],Fe([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function Ve(t,e){var n,r,i,o,a,s,u,c,l,h=t[0],d=t.slice(1).map(Number),f=d[0],p=d[1],g=e.x1,m=e.y1,y=e.x,v=e.y;switch("TQ".includes(h)||(e.qx=null,e.qy=null),h){case"M":return e.x=f,e.y=p,t;case"A":return n=[g,m].concat(d),["C"].concat(ze(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9]));case"Q":return e.qx=f,e.qy=p,n=[g,m].concat(d),["C"].concat((r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],u=n[5],[(c=1/3)*r+(l=2/3)*o,c*i+l*a,c*s+l*o,c*u+l*a,s,u]));case"L":return["C"].concat(Ge(g,m,f,p));case"Z":return g===y&&m===v?["C",g,m,y,v,y,v]:["C"].concat(Ge(g,m,y,v))}return t}function We(t,e){if(void 0===e&&(e=!1),function(t){return ke(t)&&t.every((function(t){var e=t[0];return"MC".includes(e)}))}(t)){var n=[].concat(t);return e?[n,[]]:n}for(var r,o,a=je(t),s=i({},we),u=[],c="",l=a.length,h=[],d=0;d<l;d+=1){a[d]&&(c=a[d][0]),u[d]=c;var f=Ve(a[d],s);a[d]=f,Ee(a,u,d),l=a.length,"Z"===c&&h.push(d),o=(r=a[d]).length,s.x1=+r[o-2],s.y1=+r[o-1],s.x2=+r[o-4]||s.x1,s.y2=+r[o-3]||s.y1}return e?[a,h]:a}function He(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function Ue(t,e,n,r,i){var o=He([t,e],[n,r]),a={x:0,y:0};if("number"==typeof i)if(i<=0)a={x:t,y:e};else if(i>=o)a={x:n,y:r};else{var s=Fe([t,e],[n,r],i/o);a={x:s[0],y:s[1]}}return{length:o,point:a,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function $e(t,e){var n=t.x,r=t.y,i=e.x,o=e.y,a=n*i+r*o,s=Math.sqrt((Math.pow(n,2)+Math.pow(r,2))*(Math.pow(i,2)+Math.pow(o,2)));return(n*o-r*i<0?-1:1)*Math.acos(a/s)}function qe(t,e,n,r,i,o,a,s,u,c){var l=Math.abs,h=Math.sin,d=Math.cos,f=Math.sqrt,p=Math.PI,g=l(n),m=l(r),y=(i%360+360)%360*(p/180);if(t===s&&e===u)return{x:t,y:e};if(0===g||0===m)return Ue(t,e,s,u,c).point;var v=(t-s)/2,b=(e-u)/2,x={x:d(y)*v+h(y)*b,y:-h(y)*v+d(y)*b},w=Math.pow(x.x,2)/Math.pow(g,2)+Math.pow(x.y,2)/Math.pow(m,2);w>1&&(g*=f(w),m*=f(w));var E=(Math.pow(g,2)*Math.pow(m,2)-Math.pow(g,2)*Math.pow(x.y,2)-Math.pow(m,2)*Math.pow(x.x,2))/(Math.pow(g,2)*Math.pow(x.y,2)+Math.pow(m,2)*Math.pow(x.x,2)),M=(o!==a?1:-1)*f(E=E<0?0:E),S=M*(g*x.y/m),N=M*(-m*x.x/g),k=d(y)*S-h(y)*N+(t+s)/2,C=h(y)*S+d(y)*N+(e+u)/2,T={x:(x.x-S)/g,y:(x.y-N)/m},A=$e({x:1,y:0},T),P=$e(T,{x:(-x.x-S)/g,y:(-x.y-N)/m});!a&&P>0?P-=2*p:a&&P<0&&(P+=2*p);var O=A+(P%=2*p)*c,_=g*d(O),R=m*h(O);return{x:d(y)*_-h(y)*R+k,y:h(y)*_+d(y)*R+C}}function Ye(t,e,n,r,i,o,a,s,u,c,l){var h,d=l.bbox,f=void 0===d||d,p=l.length,g=void 0===p||p,m=l.sampleSize,y=void 0===m?30:m,v="number"==typeof c,b=t,x=e,w=0,E=[b,x,w],M=[b,x],S={x:0,y:0},N=[{x:b,y:x}];v&&c<=0&&(S={x:b,y:x});for(var k=0;k<=y;k+=1){if(b=(h=qe(t,e,n,r,i,o,a,s,u,k/y)).x,x=h.y,f&&N.push({x:b,y:x}),g&&(w+=He(M,[b,x])),M=[b,x],v&&w>=c&&c>E[2]){var C=(w-c)/(w-E[2]);S={x:M[0]*(1-C)+E[0]*C,y:M[1]*(1-C)+E[1]*C}}E=[b,x,w]}return v&&c>=w&&(S={x:s,y:u}),{length:w,point:S,min:{x:Math.min.apply(null,N.map((function(t){return t.x}))),y:Math.min.apply(null,N.map((function(t){return t.y})))},max:{x:Math.max.apply(null,N.map((function(t){return t.x}))),y:Math.max.apply(null,N.map((function(t){return t.y})))}}}function Ke(t,e,n,r,i,o,a,s,u){var c=1-u;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*u*n+3*c*Math.pow(u,2)*i+Math.pow(u,3)*a,y:Math.pow(c,3)*e+3*Math.pow(c,2)*u*r+3*c*Math.pow(u,2)*o+Math.pow(u,3)*s}}function Xe(t,e,n,r,i,o,a,s,u,c){var l,h=c.bbox,d=void 0===h||h,f=c.length,p=void 0===f||f,g=c.sampleSize,m=void 0===g?10:g,y="number"==typeof u,v=t,b=e,x=0,w=[v,b,x],E=[v,b],M={x:0,y:0},S=[{x:v,y:b}];y&&u<=0&&(M={x:v,y:b});for(var N=0;N<=m;N+=1){if(v=(l=Ke(t,e,n,r,i,o,a,s,N/m)).x,b=l.y,d&&S.push({x:v,y:b}),p&&(x+=He(E,[v,b])),E=[v,b],y&&x>=u&&u>w[2]){var k=(x-u)/(x-w[2]);M={x:E[0]*(1-k)+w[0]*k,y:E[1]*(1-k)+w[1]*k}}w=[v,b,x]}return y&&u>=x&&(M={x:a,y:s}),{length:x,point:M,min:{x:Math.min.apply(null,S.map((function(t){return t.x}))),y:Math.min.apply(null,S.map((function(t){return t.y})))},max:{x:Math.max.apply(null,S.map((function(t){return t.x}))),y:Math.max.apply(null,S.map((function(t){return t.y})))}}}function Ze(t,e,n,r,i,o,a){var s=1-a;return{x:Math.pow(s,2)*t+2*s*a*n+Math.pow(a,2)*i,y:Math.pow(s,2)*e+2*s*a*r+Math.pow(a,2)*o}}function Qe(t,e,n,r,i,o,a,s){var u,c=s.bbox,l=void 0===c||c,h=s.length,d=void 0===h||h,f=s.sampleSize,p=void 0===f?10:f,g="number"==typeof a,m=t,y=e,v=0,b=[m,y,v],x=[m,y],w={x:0,y:0},E=[{x:m,y:y}];g&&a<=0&&(w={x:m,y:y});for(var M=0;M<=p;M+=1){if(m=(u=Ze(t,e,n,r,i,o,M/p)).x,y=u.y,l&&E.push({x:m,y:y}),d&&(v+=He(x,[m,y])),x=[m,y],g&&v>=a&&a>b[2]){var S=(v-a)/(v-b[2]);w={x:x[0]*(1-S)+b[0]*S,y:x[1]*(1-S)+b[1]*S}}b=[m,y,v]}return g&&a>=v&&(w={x:i,y:o}),{length:v,point:w,min:{x:Math.min.apply(null,E.map((function(t){return t.x}))),y:Math.min.apply(null,E.map((function(t){return t.y})))},max:{x:Math.max.apply(null,E.map((function(t){return t.x}))),y:Math.max.apply(null,E.map((function(t){return t.y})))}}}function Je(t,e,n){for(var r,i,o,a,s,u,c,l,h,d=je(t),f="number"==typeof e,p=[],g=0,m=0,y=0,v=0,b=[],x=[],w=0,E={x:0,y:0},M=E,S=E,N=E,k=0,C=0,T=d.length;C<T;C+=1)p=(c="M"===(l=(h=d[C])[0]))?p:[g,m].concat(h.slice(1)),c?(M=E={x:y=h[1],y:v=h[2]},w=0,f&&e<.001&&(N=E)):"L"===l?(w=(r=Ue(p[0],p[1],p[2],p[3],(e||0)-k)).length,E=r.min,M=r.max,S=r.point):"A"===l?(w=(i=Ye(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-k,n||{})).length,E=i.min,M=i.max,S=i.point):"C"===l?(w=(o=Xe(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-k,n||{})).length,E=o.min,M=o.max,S=o.point):"Q"===l?(w=(a=Qe(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-k,n||{})).length,E=a.min,M=a.max,S=a.point):"Z"===l&&(w=(s=Ue((p=[g,m,y,v])[0],p[1],p[2],p[3],(e||0)-k)).length,E=s.min,M=s.max,S=s.point),f&&k<e&&k+w>=e&&(N=S),x.push(M),b.push(E),k+=w,g=(u="Z"!==l?h.slice(-2):[y,v])[0],m=u[1];return f&&e>=k&&(N={x:g,y:m}),{length:k,point:N,min:{x:Math.min.apply(null,b.map((function(t){return t.x}))),y:Math.min.apply(null,b.map((function(t){return t.y})))},max:{x:Math.max.apply(null,x.map((function(t){return t.x}))),y:Math.max.apply(null,x.map((function(t){return t.y})))}}}function tn(t,e){var n=t.length-1,r=[],i=0,o=function(t){var e=t.length,n=e-1;return t.map((function(r,i){return t.map((function(r,o){var a,s=i+o;return 0===o||t[s]&&"M"===t[s][0]?(a=t[s],["M"].concat(a.slice(-2))):(s>=e&&(s-=n),t[s])}))}))}(t);return o.forEach((function(o,a){t.slice(1).forEach((function(r,o){i+=He(t[(a+o)%n].slice(-2),e[o%n].slice(-2))})),r[a]=i,i=0})),o[r.indexOf(Math.min.apply(null,r))]}function en(t){return function(t){var e=0,n=0,r=0;return We(t).map((function(t){var i;if("M"===t[0])return e=t[1],n=t[2],0;var o=t.slice(1),a=o[0],s=o[1],u=o[2],c=o[3],l=o[4],h=o[5];return r=function(t,e,n,r,i,o,a,s){return 3*((s-e)*(n+i)-(a-t)*(r+o)+r*(t-i)-n*(e-o)+s*(i+t/3)-a*(o+e/3))/20}(e,n,a,s,u,c,l,h),i=t.slice(-2),e=i[0],n=i[1],r})).reduce((function(t,e){return t+e}),0)}(t)>=0}function nn(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?Xe(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],{bbox:!1}).length:0;return{s:t,ss:e?i?function(t,e){void 0===e&&(e=.5);var n=t.slice(0,2),r=t.slice(2,4),i=t.slice(4,6),o=t.slice(6,8),a=Fe(n,r,e),s=Fe(r,i,e),u=Fe(i,o,e),c=Fe(a,s,e),l=Fe(s,u,e),h=Fe(c,l,e);return[["C"].concat(a,c,h),["C"].concat(l,u,o)]}(r):[t,t]:[t],l:i}}))}function rn(t,e,n){var r=nn(t),i=nn(e),o=r.length,a=i.length,s=r.filter((function(t){return t.l})).length,u=i.filter((function(t){return t.l})).length,c=r.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/s||0,l=i.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/u||0,h=n||Math.max(o,a),d=[c,l],f=[h-o,h-a],p=0,g=[r,i].map((function(t,e){return t.l===h?t.map((function(t){return t.s})):t.map((function(t,n){return p=n&&f[e]&&t.l>=d[e],f[e]-=p?1:0,p?t.ss:[t.s]})).flat()}));return g[0].length===g[1].length?g:rn(g[0],g[1],h)}function on(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function an(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function sn(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function un(){}var cn=.7,ln=1/cn,hn="\\s*([+-]?\\d+)\\s*",dn="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",fn="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",pn=/^#([0-9a-f]{3,8})$/,gn=new RegExp("^rgb\\("+[hn,hn,hn]+"\\)$"),mn=new RegExp("^rgb\\("+[fn,fn,fn]+"\\)$"),yn=new RegExp("^rgba\\("+[hn,hn,hn,dn]+"\\)$"),vn=new RegExp("^rgba\\("+[fn,fn,fn,dn]+"\\)$"),bn=new RegExp("^hsl\\("+[dn,fn,fn]+"\\)$"),xn=new RegExp("^hsla\\("+[dn,fn,fn,dn]+"\\)$"),wn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function En(){return this.rgb().formatHex()}function Mn(){return this.rgb().formatRgb()}function Sn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=pn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Nn(e):3===n?new Cn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?kn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?kn(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=gn.exec(t))?new Cn(e[1],e[2],e[3],1):(e=mn.exec(t))?new Cn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=yn.exec(t))?kn(e[1],e[2],e[3],e[4]):(e=vn.exec(t))?kn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=bn.exec(t))?On(e[1],e[2]/100,e[3]/100,1):(e=xn.exec(t))?On(e[1],e[2]/100,e[3]/100,e[4]):wn.hasOwnProperty(t)?Nn(wn[t]):"transparent"===t?new Cn(NaN,NaN,NaN,0):null}function Nn(t){return new Cn(t>>16&255,t>>8&255,255&t,1)}function kn(t,e,n,r){return r<=0&&(t=e=n=NaN),new Cn(t,e,n,r)}function Cn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Tn(){return"#"+Pn(this.r)+Pn(this.g)+Pn(this.b)}function An(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function Pn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function On(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Rn(t,e,n,r)}function _n(t){if(t instanceof Rn)return new Rn(t.h,t.s,t.l,t.opacity);if(t instanceof un||(t=Sn(t)),!t)return new Rn;if(t instanceof Rn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n<r):n===o?(r-e)/s+2:(e-n)/s+4,s/=u<.5?o+i:2-o-i,a*=60):s=u>0&&u<1?0:a,new Rn(a,s,u,t.opacity)}function Rn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function In(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function Dn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function Ln(t,e){var n=Math.min.apply(Math,l([],c(t),!1)),r=Math.min.apply(Math,l([],c(e),!1));return{x:n,y:r,width:Math.max.apply(Math,l([],c(t),!1))-n,height:Math.max.apply(Math,l([],c(e),!1))-r}}function jn(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function Bn(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function zn(t,e,n,r,i,o,a){for(var s=function(t,e,n){return Math.atan(-e/t*Math.tan(n))}(n,r,i),u=1/0,c=-1/0,l=[o,a],h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var d=s+h;o<a?o<d&&d<a&&l.push(d):a<d&&d<o&&l.push(d)}for(h=0;h<l.length;h++){var f=jn(t,0,n,r,i,l[h]);f<u&&(u=f),f>c&&(c=f)}var p=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,r,i),g=1/0,m=-1/0,y=[o,a];for(h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var v=p+h;o<a?o<v&&v<a&&y.push(v):a<v&&v<o&&y.push(v)}for(h=0;h<y.length;h++){var b=Bn(0,e,n,r,i,y[h]);b<g&&(g=b),b>m&&(m=b)}return{x:u,y:g,width:c-u,height:m-g}}an(un,Sn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:En,formatHex:En,formatHsl:function(){return _n(this).formatHsl()},formatRgb:Mn,toString:Mn}),an(Cn,(function(t,e,n,r){return 1===arguments.length?((i=t)instanceof un||(i=Sn(i)),i?new Cn((i=i.rgb()).r,i.g,i.b,i.opacity):new Cn):new Cn(t,e,n,null==r?1:r);var i}),sn(un,{brighter:function(t){return t=null==t?ln:Math.pow(ln,t),new Cn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?cn:Math.pow(cn,t),new Cn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Tn,formatHex:Tn,formatRgb:An,toString:An})),an(Rn,(function(t,e,n,r){return 1===arguments.length?_n(t):new Rn(t,e,n,null==r?1:r)}),sn(un,{brighter:function(t){return t=null==t?ln:Math.pow(ln,t),new Rn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?cn:Math.pow(cn,t),new Rn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Cn(In(t>=240?t-240:t+120,i,r),In(t,i,r),In(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var Fn=1e-4;function Gn(t,e,n,r,i,o){var a=-1,s=1/0,u=[n,r],h=20;o&&o>200&&(h=o/10);for(var d=1/h,f=d/10,p=0;p<=h;p++){var g=p*d,m=[i.apply(void 0,l([],c(t.concat([g])),!1)),i.apply(void 0,l([],c(e.concat([g])),!1))];(x=Dn(u[0],u[1],m[0],m[1]))<s&&(a=g,s=x)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var y=t.length;return{x:t[y-1],y:e[y-1]}}s=1/0;for(p=0;p<32&&!(f<Fn);p++){var v=a-f,b=a+f,x=(m=[i.apply(void 0,l([],c(t.concat([v])),!1)),i.apply(void 0,l([],c(e.concat([v])),!1))],Dn(u[0],u[1],m[0],m[1]));if(v>=0&&x<s)a=v,s=x;else{var w=[i.apply(void 0,l([],c(t.concat([b])),!1)),i.apply(void 0,l([],c(e.concat([b])),!1))],E=Dn(u[0],u[1],w[0],w[1]);b<=1&&E<s?(a=b,s=E):f*=.5}}return{x:i.apply(void 0,l([],c(t.concat([a])),!1)),y:i.apply(void 0,l([],c(e.concat([a])),!1))}}function Vn(t,e,n,r){return Dn(t,e,n,r)}function Wn(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function Hn(t,e,n,r,i,o){var a=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((i-t)*(i-t)+(o-e)*(o-e));var s=[-a[1],a[0]];!function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s);var u=[i-t,o-e];return Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}(u,s))}function Un(t,e,n,r,i){var o=1-i;return o*o*o*t+3*e*i*o*o+3*n*i*i*o+r*i*i*i}function $n(t,e,n,r){var i,o,a,s=-3*t+9*e-9*n+3*r,u=6*t-12*e+6*n,c=3*e-3*t,l=[];if(Yt(s,0))Yt(u,0)||(i=-c/u)>=0&&i<=1&&l.push(i);else{var h=u*u-4*s*c;Yt(h,0)?l.push(-u/(2*s)):h>0&&(o=(-u-(a=Math.sqrt(h)))/(2*s),(i=(-u+a)/(2*s))>=0&&i<=1&&l.push(i),o>=0&&o<=1&&l.push(o))}return l}function qn(t,e,n,r,i,o,a,s){for(var u=[t,a],c=[e,s],l=$n(t,n,i,a),h=$n(e,r,o,s),d=0;d<l.length;d++)u.push(Un(t,n,i,a,l[d]));for(d=0;d<h.length;d++)c.push(Un(e,r,o,s,h[d]));return Ln(u,c)}function Yn(t,e,n,r,i,o,a,s,u,c,l){var h=function(t,e,n,r,i,o,a,s,u,c,l){return Gn([t,n,i,a],[e,r,o,s],u,c,Un,l)}(t,e,n,r,i,o,a,s,u,c,l);return Dn(h.x,h.y,u,c)}function Kn(t){return function(t){if(t.length<2)return 0;for(var e=0,n=0;n<t.length-1;n++){var r=t[n],i=t[n+1];e+=Dn(r[0],r[1],i[0],i[1])}return e}(t)}function Xn(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function Zn(t,e,n){var r=t+n-2*e;if(Yt(r,0))return[.5];var i=(t-e)/r;return i<=1&&i>=0?[i]:[]}function Qn(t,e,n,r,i,o){var a=Zn(t,n,i)[0],s=Zn(e,r,o)[0],u=[t,i],c=[e,o];return void 0!==a&&u.push(Xn(t,n,i,a)),void 0!==s&&c.push(Xn(e,r,o,s)),Ln(u,c)}function Jn(t,e,n,r,i,o,a,s){var u=function(t,e,n,r,i,o,a,s){return Gn([t,n,i],[e,r,o],a,s,Xn)}(t,e,n,r,i,o,a,s);return Dn(u.x,u.y,a,s)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var tr={exports:{}};!function(t,e){t.exports=function(){function t(t,n,i,o,a){e(t,n,i||0,o||t.length-1,a||r)}function e(t,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,u=r-i+1,c=Math.log(s),l=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*l*(s-l)/s)*(u-s/2<0?-1:1);e(t,r,Math.max(i,Math.floor(r-u*l/s+h)),Math.min(o,Math.floor(r+(s-u)*l/s+h)),a)}var d=t[r],f=i,p=o;for(n(t,i,r),a(t[o],d)>0&&n(t,i,o);f<p;){for(n(t,f,p),f++,p--;a(t[f],d)<0;)f++;for(;a(t[p],d)>0;)p--}0===a(t[i],d)?n(t,i,p):n(t,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}function n(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function r(t,e){return t<e?-1:t>e?1:0}var i=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r<e.length;r++)if(n(t,e[r]))return r;return-1}function a(t,e){s(t,0,t.children.length,e,t)}function s(t,e,n,r,i){i||(i=y(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var o=e;o<n;o++){var a=t.children[o];u(i,t.leaf?r(a):a)}return i}function u(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function c(t,e){return t.minX-e.minX}function l(t,e){return t.minY-e.minY}function h(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function d(t){return t.maxX-t.minX+(t.maxY-t.minY)}function f(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function p(t,e){var n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}function g(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function m(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function y(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(e,n,r,i,o){for(var a=[n,r];a.length;)if(!((r=a.pop())-(n=a.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;t(e,s,n,r,o),a.push(n,s,s,r)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(t){var e=this.data,n=[];if(!m(t,e))return n;for(var r=this.toBBox,i=[];e;){for(var o=0;o<e.children.length;o++){var a=e.children[o],s=e.leaf?r(a):a;m(t,s)&&(e.leaf?n.push(a):g(t,s)?this._all(a,n):i.push(a))}e=i.pop()}return n},i.prototype.collides=function(t){var e=this.data;if(!m(t,e))return!1;for(var n=[];e;){for(var r=0;r<e.children.length;r++){var i=e.children[r],o=e.leaf?this.toBBox(i):i;if(m(t,o)){if(e.leaf||g(t,o))return!0;n.push(i)}}e=n.pop()}return!1},i.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0;e<t.length;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},i.prototype.clear=function(){return this.data=y([]),this},i.prototype.remove=function(t,e){if(!t)return this;for(var n,r,i,a=this.data,s=this.toBBox(t),u=[],c=[];a||u.length;){if(a||(a=u.pop(),r=u[u.length-1],n=c.pop(),i=!0),a.leaf){var l=o(t,a.children,e);if(-1!==l)return a.children.splice(l,1),u.push(a),this._condense(u),this}i||a.leaf||!g(a,s)?r?(n++,a=r.children[n],i=!1):a=null:(u.push(a),c.push(n),n=0,r=a,a=a.children[0])}return this},i.prototype.toBBox=function(t){return t},i.prototype.compareMinX=function(t,e){return t.minX-e.minX},i.prototype.compareMinY=function(t,e){return t.minY-e.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(t){return this.data=t,this},i.prototype._all=function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},i.prototype._build=function(t,e,n,r){var i,o=n-e+1,s=this._maxEntries;if(o<=s)return a(i=y(t.slice(e,n+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,r-1))),(i=y([])).leaf=!1,i.height=r;var u=Math.ceil(o/s),c=u*Math.ceil(Math.sqrt(s));v(t,e,n,c,this.compareMinX);for(var l=e;l<=n;l+=c){var h=Math.min(l+c-1,n);v(t,l,h,u,this.compareMinY);for(var d=l;d<=h;d+=u){var f=Math.min(d+u-1,h);i.children.push(this._build(t,d,f,r-1))}}return a(i,this.toBBox),i},i.prototype._chooseSubtree=function(t,e,n,r){for(;r.push(e),!e.leaf&&r.length-1!==n;){for(var i=1/0,o=1/0,a=void 0,s=0;s<e.children.length;s++){var u=e.children[s],c=h(u),l=f(t,u)-c;l<o?(o=l,i=c<i?c:i,a=u):l===o&&c<i&&(i=c,a=u)}e=a||e.children[0]}return e},i.prototype._insert=function(t,e,n){var r=n?t:this.toBBox(t),i=[],o=this._chooseSubtree(r,this.data,e,i);for(o.children.push(t),u(o,r);e>=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)},i.prototype._split=function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=y(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,a(n,this.toBBox),a(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},i.prototype._splitRoot=function(t,e){this.data=y([t,e]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(t,e,n){for(var r,i=1/0,o=1/0,a=e;a<=n-e;a++){var u=s(t,0,a,this.toBBox),c=s(t,a,n,this.toBBox),l=p(u,c),d=h(u)+h(c);l<i?(i=l,r=a,o=d<o?d:o):l===i&&d<o&&(o=d,r=a)}return r||n-e},i.prototype._chooseSplitAxis=function(t,e,n){var r=t.leaf?this.compareMinX:c,i=t.leaf?this.compareMinY:l;this._allDistMargin(t,e,n,r)<this._allDistMargin(t,e,n,i)&&t.children.sort(r)},i.prototype._allDistMargin=function(t,e,n,r){t.children.sort(r);for(var i=this.toBBox,o=s(t,0,e,i),a=s(t,n-e,n,i),c=d(o)+d(a),l=e;l<n-e;l++){var h=t.children[l];u(o,t.leaf?i(h):h),c+=d(o)}for(var f=n-e-1;f>=e;f--){var p=t.children[f];u(a,t.leaf?i(p):p),c+=d(a)}return c},i.prototype._adjustParentBBoxes=function(t,e,n){for(var r=n;r>=0;r--)u(e[r],t)},i.prototype._condense=function(t){for(var e=t.length-1,n=void 0;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children).splice(n.indexOf(t[e]),1):this.clear():a(t[e],this.toBBox)},i}()}(tr);var er,nr,rr=tr.exports;!function(t){t.GROUP="g",t.CIRCLE="circle",t.ELLIPSE="ellipse",t.IMAGE="image",t.RECT="rect",t.LINE="line",t.POLYLINE="polyline",t.POLYGON="polygon",t.TEXT="text",t.PATH="path",t.HTML="html",t.MESH="mesh"}(er||(er={})),function(t){t[t.ZERO=0]="ZERO",t[t.NEGATIVE_ONE=1]="NEGATIVE_ONE"}(nr||(nr={}));var ir=function(){function t(){this.plugins=[]}return t.prototype.addRenderingPlugin=function(t){this.plugins.push(t),this.context.renderingPlugins.push(t)},t.prototype.removeAllRenderingPlugins=function(){var t=this;this.plugins.forEach((function(e){var n=t.context.renderingPlugins.indexOf(e);n>=0&&t.context.renderingPlugins.splice(n,1)}))},t}(),or=function(){function t(t){this.clipSpaceNearZ=nr.NEGATIVE_ONE,this.plugins=[],this.config=i({enableDirtyCheck:!0,enableCulling:!1,enableAutoRendering:!0,enableDirtyRectangleRendering:!0,enableDirtyRectangleRenderingDebug:!1,enableSizeAttenuation:!0},t)}return t.prototype.registerPlugin=function(t){-1===this.plugins.findIndex((function(e){return e===t}))&&this.plugins.push(t)},t.prototype.unregisterPlugin=function(t){var e=this.plugins.findIndex((function(e){return e===t}));e>-1&&this.plugins.splice(e,1)},t.prototype.getPlugins=function(){return this.plugins},t.prototype.getPlugin=function(t){return this.plugins.find((function(e){return e.name===t}))},t.prototype.getConfig=function(){return this.config},t.prototype.setConfig=function(t){Object.assign(this.config,t)},t}();function ar(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function sr(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function ur(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function cr(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function lr(t){return void 0===t?0:t>360||t<-360?t%360:t}function hr(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Array.isArray(t)&&3===t.length?nt(t):$t(t)?it(t,e,n):it(t[0],t[1]||e,t[2]||n)}function dr(t){return t*(Math.PI/180)}function fr(t){return t*(180/Math.PI)}function pr(t,e){return 16===e.length?function(t,e){var n,r,i=.5*Math.PI,o=c(G(et(),e),3),a=o[0],s=o[1],u=o[2],l=Math.asin(-e[2]/a);return l<i?l>-i?(n=Math.atan2(e[6]/s,e[10]/u),r=Math.atan2(e[1]/a,e[0]/a)):(r=0,n=-Math.atan2(e[4]/s,e[5]/s)):(r=0,n=Math.atan2(e[4]/s,e[5]/s)),t[0]=n,t[1]=l,t[2]=r,t}(t,e):function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=r*r,s=i*i,u=o*o,c=n*n+a+s+u,l=n*o-r*i;return l>.499995*c?(t[0]=Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):l<-.499995*c?(t[0]=-Math.PI/2,t[1]=2*Math.atan2(r,n),t[2]=0):(t[0]=Math.asin(2*(n*i-o*r)),t[1]=Math.atan2(2*(n*o+r*i),1-2*(s+u)),t[2]=Math.atan2(2*(n*r+i*o),1-2*(a+s))),t}(t,e)}function gr(t,e,n,r,i){var o,a,s,u,c,l,h,d,f,p,g=Math.cos(t),m=Math.sin(t);return o=r*g,a=i*m,s=0,u=-r*m,c=i*g,l=0,h=e,d=n,f=1,(p=new v(9))[0]=o,p[1]=a,p[2]=s,p[3]=u,p[4]=c,p[5]=l,p[6]=h,p[7]=d,p[8]=f,p}function mr(t){var e=t[0],n=t[1],r=t[3],i=t[4],o=Math.sqrt(e*e+n*n),a=Math.sqrt(r*r+i*i);e*i-n*r<0&&(e<i?o=-o:a=-a),o&&(e*=1/o,n*=1/o),a&&(r*=1/a,i*=1/a);var s=fr(Math.atan2(n,e));return[t[6],t[7],o,a,s]}var yr=x(),vr=x(),br=vt(),xr=[et(),et(),et()],wr=et();function Er(t,e,n,r,i){t[0]=e[0]*r+n[0]*i,t[1]=e[1]*r+n[1]*i,t[2]=e[2]*r+n[2]*i}var Mr,Sr=function(){function t(){this.center=[0,0,0],this.halfExtents=[0,0,0],this.min=[0,0,0],this.max=[0,0,0]}return t.isEmpty=function(t){return!t||0===t.halfExtents[0]&&0===t.halfExtents[1]&&0===t.halfExtents[2]},t.prototype.update=function(t,e){ar(this.center,t),ar(this.halfExtents,e),sr(this.min,this.center,this.halfExtents),ur(this.max,this.center,this.halfExtents)},t.prototype.setMinMax=function(t,e){ur(this.center,e,t),cr(this.center,this.center,.5),sr(this.halfExtents,e,t),cr(this.halfExtents,this.halfExtents,.5),ar(this.min,t),ar(this.max,e)},t.prototype.getMin=function(){return this.min},t.prototype.getMax=function(){return this.max},t.prototype.add=function(e){if(!t.isEmpty(e))if(t.isEmpty(this))this.setMinMax(e.getMin(),e.getMax());else{var n=this.center,r=n[0],i=n[1],o=n[2],a=this.halfExtents,s=a[0],u=a[1],c=a[2],l=r-s,h=r+s,d=i-u,f=i+u,p=o-c,g=o+c,m=e.center,y=m[0],v=m[1],b=m[2],x=e.halfExtents,w=x[0],E=x[1],M=x[2],S=y-w,N=y+w,k=v-E,C=v+E,T=b-M,A=b+M;S<l&&(l=S),N>h&&(h=N),k<d&&(d=k),C>f&&(f=C),T<p&&(p=T),A>g&&(g=A),n[0]=.5*(l+h),n[1]=.5*(d+f),n[2]=.5*(p+g),a[0]=.5*(h-l),a[1]=.5*(f-d),a[2]=.5*(g-p),this.min[0]=l,this.min[1]=d,this.min[2]=p,this.max[0]=h,this.max[1]=f,this.max[2]=g}},t.prototype.setFromTransformedAABB=function(t,e){var n=this.center,r=this.halfExtents,i=t.center,o=t.halfExtents,a=e[0],s=e[4],u=e[8],c=e[1],l=e[5],h=e[9],d=e[2],f=e[6],p=e[10],g=Math.abs(a),m=Math.abs(s),y=Math.abs(u),v=Math.abs(c),b=Math.abs(l),x=Math.abs(h),w=Math.abs(d),E=Math.abs(f),M=Math.abs(p);n[0]=e[12]+a*i[0]+s*i[1]+u*i[2],n[1]=e[13]+c*i[0]+l*i[1]+h*i[2],n[2]=e[14]+d*i[0]+f*i[1]+p*i[2],r[0]=g*o[0]+m*o[1]+y*o[2],r[1]=v*o[0]+b*o[1]+x*o[2],r[2]=w*o[0]+E*o[1]+M*o[2],sr(this.min,n,r),ur(this.max,n,r)},t.prototype.intersects=function(t){var e=this.getMax(),n=this.getMin(),r=t.getMax(),i=t.getMin();return n[0]<=r[0]&&e[0]>=i[0]&&n[1]<=r[1]&&e[1]>=i[1]&&n[2]<=r[2]&&e[2]>=i[2]},t.prototype.intersection=function(e){if(!this.intersects(e))return null;var n=new t,r=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}([0,0,0],this.getMin(),e.getMin()),i=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}([0,0,0],this.getMax(),e.getMax());return n.setMinMax(r,i),n},t.prototype.getNegativeFarPoint=function(t){return 273===t.pnVertexFlag?ar([0,0,0],this.min):272===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:257===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:256===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:17===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:16===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:1===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:[this.max[0],this.max[1],this.max[2]]},t.prototype.getPositiveFarPoint=function(t){return 273===t.pnVertexFlag?ar([0,0,0],this.max):272===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:257===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:256===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:17===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:16===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:1===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:[this.min[0],this.min[1],this.min[2]]},t}(),Nr=function(){function t(t,e){this.distance=t||0,this.normal=e||it(0,1,0),this.updatePNVertexFlag()}return t.prototype.updatePNVertexFlag=function(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0)},t.prototype.distanceToPoint=function(t){return ht(t,this.normal)-this.distance},t.prototype.normalize=function(){var t=1/yt(this.normal);ct(this.normal,this.normal,t),this.distance*=t},t.prototype.intersectsLine=function(t,e,n){var r=this.distanceToPoint(t),i=r/(r-this.distanceToPoint(e)),o=i>=0&&i<=1;return o&&n&&ft(n,t,e,i),o},t}();!function(t){t[t.OUTSIDE=4294967295]="OUTSIDE",t[t.INSIDE=0]="INSIDE",t[t.INDETERMINATE=2147483647]="INDETERMINATE"}(Mr||(Mr={}));var kr,Cr,Tr,Ar=function(){function t(t){if(this.planes=[],t)this.planes=t;else for(var e=0;e<6;e++)this.planes.push(new Nr)}return t.prototype.extractFromVPMatrix=function(t){var e=c(t,16),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],l=e[7],h=e[8],d=e[9],f=e[10],p=e[11],g=e[12],m=e[13],y=e[14],v=e[15];at(this.planes[0].normal,o-n,l-a,p-h),this.planes[0].distance=v-g,at(this.planes[1].normal,o+n,l+a,p+h),this.planes[1].distance=v+g,at(this.planes[2].normal,o+r,l+s,p+d),this.planes[2].distance=v+m,at(this.planes[3].normal,o-r,l-s,p-d),this.planes[3].distance=v-m,at(this.planes[4].normal,o-i,l-u,p-f),this.planes[4].distance=v-y,at(this.planes[5].normal,o+i,l+u,p+f),this.planes[5].distance=v+y,this.planes.forEach((function(t){t.normalize(),t.updatePNVertexFlag()}))},t}(),Pr=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}return t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t}(),Or=function(){function t(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r,this.left=t,this.right=t+n,this.top=e,this.bottom=e+r}return t.prototype.toJSON=function(){},t}(),_r="Method not implemented.",Rr="Use document.documentElement instead.";!function(t){t[t.ORBITING=0]="ORBITING",t[t.EXPLORING=1]="EXPLORING",t[t.TRACKING=2]="TRACKING"}(kr||(kr={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ROTATIONAL=1]="ROTATIONAL",t[t.TRANSLATIONAL=2]="TRANSLATIONAL",t[t.CINEMATIC=3]="CINEMATIC"}(Cr||(Cr={})),function(t){t[t.ORTHOGRAPHIC=0]="ORTHOGRAPHIC",t[t.PERSPECTIVE=1]="PERSPECTIVE"}(Tr||(Tr={}));var Ir,Dr,Lr,jr,Br,zr="updated",Fr=2e-4,Gr=function(){function t(){this.clipSpaceNearZ=nr.NEGATIVE_ONE,this.eventEmitter=new m,this.matrix=x(),this.right=it(1,0,0),this.up=it(0,1,0),this.forward=it(0,0,1),this.position=it(0,0,1),this.focalPoint=it(0,0,0),this.distanceVector=it(0,0,-1),this.distance=1,this.azimuth=0,this.elevation=0,this.roll=0,this.relAzimuth=0,this.relElevation=0,this.relRoll=0,this.dollyingStep=0,this.maxDistance=1/0,this.minDistance=-1/0,this.zoom=1,this.rotateWorld=!1,this.fov=30,this.near=.1,this.far=1e3,this.aspect=1,this.projectionMatrix=x(),this.projectionMatrixInverse=x(),this.jitteredProjectionMatrix=void 0,this.enableUpdate=!0,this.type=kr.EXPLORING,this.trackingMode=Cr.DEFAULT,this.projectionMode=Tr.PERSPECTIVE,this.frustum=new Ar,this.orthoMatrix=x()}return t.prototype.isOrtho=function(){return this.projectionMode===Tr.ORTHOGRAPHIC},t.prototype.getProjectionMode=function(){return this.projectionMode},t.prototype.getPerspective=function(){return this.jitteredProjectionMatrix||this.projectionMatrix},t.prototype.getPerspectiveInverse=function(){return this.projectionMatrixInverse},t.prototype.getFrustum=function(){return this.frustum},t.prototype.getPosition=function(){return this.position},t.prototype.getFocalPoint=function(){return this.focalPoint},t.prototype.getDollyingStep=function(){return this.dollyingStep},t.prototype.getNear=function(){return this.near},t.prototype.getFar=function(){return this.far},t.prototype.getZoom=function(){return this.zoom},t.prototype.getOrthoMatrix=function(){return this.orthoMatrix},t.prototype.getView=function(){return this.view},t.prototype.setEnableUpdate=function(t){this.enableUpdate=t},t.prototype.setType=function(t,e){return this.type=t,this.type===kr.EXPLORING?this.setWorldRotation(!0):this.setWorldRotation(!1),this._getAngles(),this.type===kr.TRACKING&&void 0!==e&&this.setTrackingMode(e),this},t.prototype.setProjectionMode=function(t){return this.projectionMode=t,this},t.prototype.setTrackingMode=function(t){if(this.type!==kr.TRACKING)throw new Error("Impossible to set a tracking mode if the camera is not of tracking type");return this.trackingMode=t,this},t.prototype.setWorldRotation=function(t){return this.rotateWorld=t,this._getAngles(),this},t.prototype.getViewTransform=function(){return k(x(),this.matrix)},t.prototype.getWorldTransform=function(){return this.matrix},t.prototype.jitterProjectionMatrix=function(t,e){var n=R(x(),[t,e,0]);this.jitteredProjectionMatrix=T(x(),n,this.projectionMatrix)},t.prototype.clearJitterProjectionMatrix=function(){this.jitteredProjectionMatrix=void 0},t.prototype.setMatrix=function(t){return this.matrix=t,this._update(),this},t.prototype.setProjectionMatrix=function(t){this.projectionMatrix=t},t.prototype.setFov=function(t){return this.setPerspective(this.near,this.far,t,this.aspect),this},t.prototype.setAspect=function(t){return this.setPerspective(this.near,this.far,this.fov,t),this},t.prototype.setNear=function(t){return this.projectionMode===Tr.PERSPECTIVE?this.setPerspective(t,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,t,this.far),this},t.prototype.setFar=function(t){return this.projectionMode===Tr.PERSPECTIVE?this.setPerspective(this.near,t,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,t),this},t.prototype.setViewOffset=function(t,e,n,r,i,o){return this.aspect=t/e,void 0===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.projectionMode===Tr.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.clearViewOffset=function(){return void 0!==this.view&&(this.view.enabled=!1),this.projectionMode===Tr.PERSPECTIVE?this.setPerspective(this.near,this.far,this.fov,this.aspect):this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far),this},t.prototype.setZoom=function(t){return this.zoom=t,this.projectionMode===Tr.ORTHOGRAPHIC?this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far):this.projectionMode===Tr.PERSPECTIVE&&this.setPerspective(this.near,this.far,this.fov,this.aspect),this},t.prototype.setZoomByViewportPoint=function(t,e){var n=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),r=n.x,i=n.y,o=this.roll;this.rotate(0,0,-o),this.setPosition(r,i),this.setFocalPoint(r,i),this.setZoom(t),this.rotate(0,0,o);var a=this.canvas.viewport2Canvas({x:e[0],y:e[1]}),s=it(a.x-r,a.y-i,0),u=ht(s,this.right)/rt(this.right),c=ht(s,this.up)/rt(this.up);return this.pan(-u,-c),this},t.prototype.setPerspective=function(t,e,n,r){var i;this.projectionMode=Tr.PERSPECTIVE,this.fov=n,this.near=t,this.far=e,this.aspect=r;var o=this.near*Math.tan(dr(.5*this.fov))/this.zoom,a=2*o,s=this.aspect*a,u=-.5*s;if(null===(i=this.view)||void 0===i?void 0:i.enabled){var c=this.view.fullWidth,l=this.view.fullHeight;u+=this.view.offsetX*s/c,o-=this.view.offsetY*a/l,s*=this.view.width/c,a*=this.view.height/l}return function(t,e,n,r,i,o,a,s){void 0===s&&(s=!1);var u,c,l=2*o/(n-e),h=2*o/(r-i),d=(n+e)/(n-e),f=(r+i)/(r-i);s?(u=-a/(a-o),c=-a*o/(a-o)):(u=-(a+o)/(a-o),c=-2*a*o/(a-o)),t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=h,t[6]=0,t[7]=0,t[8]=d,t[9]=f,t[10]=u,t[11]=-1,t[12]=0,t[13]=0,t[14]=c,t[15]=0}(this.projectionMatrix,u,u+s,o,o-a,t,this.far,this.clipSpaceNearZ===nr.ZERO),P(this.projectionMatrix,this.projectionMatrix,it(1,-1,1)),k(this.projectionMatrixInverse,this.projectionMatrix),this.triggerUpdate(),this},t.prototype.setOrthographic=function(t,e,n,r,i,o){var a;this.projectionMode=Tr.ORTHOGRAPHIC,this.rright=e,this.left=t,this.top=n,this.bottom=r,this.near=i,this.far=o;var s=(this.rright-this.left)/(2*this.zoom),u=(this.top-this.bottom)/(2*this.zoom),c=(this.rright+this.left)/2,l=(this.top+this.bottom)/2,h=c-s,d=c+s,f=l+u,p=l-u;if(null===(a=this.view)||void 0===a?void 0:a.enabled){var g=(this.rright-this.left)/this.view.fullWidth/this.zoom,m=(this.top-this.bottom)/this.view.fullHeight/this.zoom;d=(h+=g*this.view.offsetX)+g*this.view.width,p=(f-=m*this.view.offsetY)-m*this.view.height}return this.clipSpaceNearZ===nr.NEGATIVE_ONE?Y(this.projectionMatrix,h,d,p,f,i,o):K(this.projectionMatrix,h,d,p,f,i,o),P(this.projectionMatrix,this.projectionMatrix,it(1,-1,1)),k(this.projectionMatrixInverse,this.projectionMatrix),this._getOrthoMatrix(),this.triggerUpdate(),this},t.prototype.setPosition=function(t,e,n){void 0===e&&(e=this.position[1]),void 0===n&&(n=this.position[2]);var r=hr(t,e,n);return this._setPosition(r),this.setFocalPoint(this.focalPoint),this.triggerUpdate(),this},t.prototype.setFocalPoint=function(t,e,n){void 0===e&&(e=this.focalPoint[1]),void 0===n&&(n=this.focalPoint[2]);var r=it(0,1,0);if(this.focalPoint=hr(t,e,n),this.trackingMode===Cr.CINEMATIC){var i=ut(et(),this.focalPoint,this.position);t=i[0],e=i[1],n=i[2];var o=rt(i),a=fr(Math.asin(e/o)),s=90+fr(Math.atan2(n,t)),u=x();_(u,u,dr(s)),O(u,u,dr(a)),r=pt(et(),[0,1,0],u)}return k(this.matrix,X(x(),this.position,this.focalPoint,r)),this._getAxes(),this._getDistance(),this._getAngles(),this.triggerUpdate(),this},t.prototype.getDistance=function(){return this.distance},t.prototype.getDistanceVector=function(){return this.distanceVector},t.prototype.setDistance=function(t){if(this.distance===t||t<0)return this;this.distance=t,this.distance<Fr&&(this.distance=Fr),this.dollyingStep=this.distance/100;var e=et();t=this.distance;var n=this.forward,r=this.focalPoint;return e[0]=t*n[0]+r[0],e[1]=t*n[1]+r[1],e[2]=t*n[2]+r[2],this._setPosition(e),this.triggerUpdate(),this},t.prototype.setMaxDistance=function(t){return this.maxDistance=t,this},t.prototype.setMinDistance=function(t){return this.minDistance=t,this},t.prototype.setAzimuth=function(t){return this.azimuth=lr(t),this.computeMatrix(),this._getAxes(),this.type===kr.ORBITING||this.type===kr.EXPLORING?this._getPosition():this.type===kr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getAzimuth=function(){return this.azimuth},t.prototype.setElevation=function(t){return this.elevation=lr(t),this.computeMatrix(),this._getAxes(),this.type===kr.ORBITING||this.type===kr.EXPLORING?this._getPosition():this.type===kr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getElevation=function(){return this.elevation},t.prototype.setRoll=function(t){return this.roll=lr(t),this.computeMatrix(),this._getAxes(),this.type===kr.ORBITING||this.type===kr.EXPLORING?this._getPosition():this.type===kr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getRoll=function(){return this.roll},t.prototype._update=function(){this._getAxes(),this._getPosition(),this._getDistance(),this._getAngles(),this._getOrthoMatrix(),this.triggerUpdate()},t.prototype.computeMatrix=function(){var t=wt(xt(),[0,0,1],dr(this.roll));S(this.matrix);var e=wt(xt(),[1,0,0],dr((this.rotateWorld&&this.type!==kr.TRACKING||this.type===kr.TRACKING?1:-1)*this.elevation)),n=wt(xt(),[0,1,0],dr((this.rotateWorld&&this.type!==kr.TRACKING||this.type===kr.TRACKING?1:-1)*this.azimuth)),r=Et(xt(),n,e);r=Et(xt(),r,t);var i=H(x(),r);this.type===kr.ORBITING||this.type===kr.EXPLORING?(A(this.matrix,this.matrix,this.focalPoint),T(this.matrix,this.matrix,i),A(this.matrix,this.matrix,[0,0,this.distance])):this.type===kr.TRACKING&&(A(this.matrix,this.matrix,this.position),T(this.matrix,this.matrix,i))},t.prototype._setPosition=function(t,e,n){this.position=hr(t,e,n);var r=this.matrix;r[12]=this.position[0],r[13]=this.position[1],r[14]=this.position[2],r[15]=1,this._getOrthoMatrix()},t.prototype._getAxes=function(){ot(this.right,hr(bt(vt(),[1,0,0,0],this.matrix))),ot(this.up,hr(bt(vt(),[0,1,0,0],this.matrix))),ot(this.forward,hr(bt(vt(),[0,0,1,0],this.matrix))),lt(this.right,this.right),lt(this.up,this.up),lt(this.forward,this.forward)},t.prototype._getAngles=function(){var t=this.distanceVector[0],e=this.distanceVector[1],n=this.distanceVector[2],r=rt(this.distanceVector);if(0===r)return this.elevation=0,void(this.azimuth=0);this.type===kr.TRACKING||this.rotateWorld?(this.elevation=fr(Math.asin(e/r)),this.azimuth=fr(Math.atan2(-t,-n))):(this.elevation=-fr(Math.asin(e/r)),this.azimuth=-fr(Math.atan2(-t,-n)))},t.prototype._getPosition=function(){ot(this.position,hr(bt(vt(),[0,0,0,1],this.matrix))),this._getDistance()},t.prototype._getFocalPoint=function(){!function(t,e,n){var r=e[0],i=e[1],o=e[2];t[0]=r*n[0]+i*n[3]+o*n[6],t[1]=r*n[1]+i*n[4]+o*n[7],t[2]=r*n[2]+i*n[5]+o*n[8]}(this.distanceVector,[0,0,-this.distance],function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(b(),this.matrix)),st(this.focalPoint,this.position,this.distanceVector),this._getDistance()},t.prototype._getDistance=function(){this.distanceVector=ut(et(),this.focalPoint,this.position),this.distance=rt(this.distanceVector),this.dollyingStep=this.distance/100},t.prototype._getOrthoMatrix=function(){if(this.projectionMode===Tr.ORTHOGRAPHIC){var t=this.position,e=wt(xt(),[0,0,1],-this.roll*Math.PI/180);W(this.orthoMatrix,e,it((this.rright-this.left)/2-t[0],(this.top-this.bottom)/2-t[1],0),it(this.zoom,this.zoom,1),t)}},t.prototype.triggerUpdate=function(){if(this.enableUpdate){var t=this.getViewTransform(),e=T(x(),this.getPerspective(),t);this.getFrustum().extractFromVPMatrix(e),this.eventEmitter.emit(zr)}},t.prototype.rotate=function(t,e,n){throw new Error(_r)},t.prototype.pan=function(t,e){throw new Error(_r)},t.prototype.dolly=function(t){throw new Error(_r)},t.prototype.createLandmark=function(t,e){throw new Error(_r)},t.prototype.gotoLandmark=function(t,e){throw new Error(_r)},t.prototype.cancelLandmarkAnimation=function(){throw new Error(_r)},t}();function Vr(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return n.cache=a.set(o,s)||a,s};return n.cache=new(Vr.Cache||Map),n}Vr.Cache=Map,function(t){t[t.kUnknown=0]="kUnknown",t[t.kNumber=1]="kNumber",t[t.kPercentage=2]="kPercentage",t[t.kEms=3]="kEms",t[t.kPixels=4]="kPixels",t[t.kRems=5]="kRems",t[t.kDegrees=6]="kDegrees",t[t.kRadians=7]="kRadians",t[t.kGradians=8]="kGradians",t[t.kTurns=9]="kTurns",t[t.kMilliseconds=10]="kMilliseconds",t[t.kSeconds=11]="kSeconds",t[t.kInteger=12]="kInteger"}(Ir||(Ir={})),function(t){t[t.kUNumber=0]="kUNumber",t[t.kUPercent=1]="kUPercent",t[t.kULength=2]="kULength",t[t.kUAngle=3]="kUAngle",t[t.kUTime=4]="kUTime",t[t.kUOther=5]="kUOther"}(Dr||(Dr={})),function(t){t[t.kAll=0]="kAll",t[t.kNonNegative=1]="kNonNegative",t[t.kInteger=2]="kInteger",t[t.kNonNegativeInteger=3]="kNonNegativeInteger",t[t.kPositiveInteger=4]="kPositiveInteger"}(Lr||(Lr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(jr||(jr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Br||(Br={}));var Wr,Hr=[{name:"em",unit_type:Ir.kEms},{name:"px",unit_type:Ir.kPixels},{name:"deg",unit_type:Ir.kDegrees},{name:"rad",unit_type:Ir.kRadians},{name:"grad",unit_type:Ir.kGradians},{name:"ms",unit_type:Ir.kMilliseconds},{name:"s",unit_type:Ir.kSeconds},{name:"rem",unit_type:Ir.kRems},{name:"turn",unit_type:Ir.kTurns}];!function(t){t[t.kUnknownType=0]="kUnknownType",t[t.kUnparsedType=1]="kUnparsedType",t[t.kKeywordType=2]="kKeywordType",t[t.kUnitType=3]="kUnitType",t[t.kSumType=4]="kSumType",t[t.kProductType=5]="kProductType",t[t.kNegateType=6]="kNegateType",t[t.kInvertType=7]="kInvertType",t[t.kMinType=8]="kMinType",t[t.kMaxType=9]="kMaxType",t[t.kClampType=10]="kClampType",t[t.kTransformType=11]="kTransformType",t[t.kPositionType=12]="kPositionType",t[t.kURLImageType=13]="kURLImageType",t[t.kColorType=14]="kColorType",t[t.kUnsupportedColorType=15]="kUnsupportedColorType"}(Wr||(Wr={}));var Ur,$r=function(t){return t?"number"===t?Ir.kNumber:"percent"===t||"%"===t?Ir.kPercentage:function(t){return Hr.find((function(e){return e.name===t})).unit_type}(t):Ir.kUnknown},qr=function(t){var e=1;switch(t){case Ir.kPixels:case Ir.kDegrees:case Ir.kSeconds:break;case Ir.kMilliseconds:e=.001;break;case Ir.kRadians:e=180/Math.PI;break;case Ir.kGradians:e=.9;break;case Ir.kTurns:e=360}return e},Yr=function(t){switch(t){case Ir.kNumber:case Ir.kInteger:return"";case Ir.kPercentage:return"%";case Ir.kEms:return"em";case Ir.kRems:return"rem";case Ir.kPixels:return"px";case Ir.kDegrees:return"deg";case Ir.kRadians:return"rad";case Ir.kGradians:return"grad";case Ir.kMilliseconds:return"ms";case Ir.kSeconds:return"s";case Ir.kTurns:return"turn"}return""},Kr=function(){function t(){}return t.isAngle=function(t){return t===Ir.kDegrees||t===Ir.kRadians||t===Ir.kGradians||t===Ir.kTurns},t.isLength=function(t){return t>=Ir.kEms&&t<Ir.kDegrees},t.isRelativeUnit=function(t){return t===Ir.kPercentage||t===Ir.kEms||t===Ir.kRems},t.isTime=function(t){return t===Ir.kSeconds||t===Ir.kMilliseconds},t.prototype.toString=function(){return this.buildCSSText(jr.kNo,Br.kNo,"")},t.prototype.isNumericValue=function(){return this.getType()>=Wr.kUnitType&&this.getType()<=Wr.kClampType},t}(),Xr=function(t){function e(e){var n=t.call(this)||this;return n.colorSpace=e,n}return r(e,t),e.prototype.getType=function(){return Wr.kColorType},e.prototype.to=function(t){return this},e}(Kr);!function(t){t[t.Constant=0]="Constant",t[t.LinearGradient=1]="LinearGradient",t[t.RadialGradient=2]="RadialGradient"}(Ur||(Ur={}));var Zr=function(t){function e(e,n){var r=t.call(this)||this;return r.type=e,r.value=n,r}return r(e,t),e.prototype.clone=function(){return new e(this.type,this.value)},e.prototype.buildCSSText=function(t,e,n){return n},e.prototype.getType=function(){return Wr.kColorType},e}(Kr),Qr=function(t){function e(e){var n=t.call(this)||this;return n.value=e,n}return r(e,t),e.prototype.clone=function(){return new e(this.value)},e.prototype.getType=function(){return Wr.kKeywordType},e.prototype.buildCSSText=function(t,e,n){return n+this.value},e}(Kr),Jr=Vr((function(t){return void 0===t&&(t=""),t.replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()}))})),ti=function(t){return t.split("").map((function(t,e){return t.toUpperCase()===t?"".concat(0!==e?"-":"").concat(t.toLowerCase()):t})).join("")};function ei(t){return"function"==typeof t}var ni={d:{alias:"path"},strokeDasharray:{alias:"lineDash"},strokeWidth:{alias:"lineWidth"},textAnchor:{alias:"textAlign"},src:{alias:"img"}},ri=Vr((function(t){var e=Jr(t),n=ni[e];return e=(null==n?void 0:n.alias)||e})),ii=function(t,e){void 0===e&&(e="");var n="";return Number.isFinite(t)?(!function(t){if(!t)throw new Error}(Number.isNaN(t)),n="NaN"):n=t>0?"infinity":"-infinity",n+e},oi=function(t){return function(t){switch(t){case Dr.kUNumber:return Ir.kNumber;case Dr.kULength:return Ir.kPixels;case Dr.kUPercent:return Ir.kPercentage;case Dr.kUTime:return Ir.kSeconds;case Dr.kUAngle:return Ir.kDegrees;default:return Ir.kUnknown}}(function(t){switch(t){case Ir.kNumber:case Ir.kInteger:return Dr.kUNumber;case Ir.kPercentage:return Dr.kUPercent;case Ir.kPixels:return Dr.kULength;case Ir.kMilliseconds:case Ir.kSeconds:return Dr.kUTime;case Ir.kDegrees:case Ir.kRadians:case Ir.kGradians:case Ir.kTurns:return Dr.kUAngle;default:return Dr.kUOther}}(t))},ai=function(t){function e(e,n){void 0===n&&(n=Ir.kNumber);var r,i=t.call(this)||this;return r="string"==typeof n?$r(n):n,i.unit=r,i.value=e,i}return r(e,t),e.prototype.clone=function(){return new e(this.value,this.unit)},e.prototype.equals=function(t){var e=t;return this.value===e.value&&this.unit===e.unit},e.prototype.getType=function(){return Wr.kUnitType},e.prototype.convertTo=function(t){if(this.unit===t)return new e(this.value,this.unit);var n=oi(this.unit);if(n!==oi(t)||n===Ir.kUnknown)return null;var r=qr(this.unit)/qr(t);return new e(this.value*r,t)},e.prototype.buildCSSText=function(t,e,n){var r;switch(this.unit){case Ir.kUnknown:break;case Ir.kInteger:r=Number(this.value).toFixed(0);break;case Ir.kNumber:case Ir.kPercentage:case Ir.kEms:case Ir.kRems:case Ir.kPixels:case Ir.kDegrees:case Ir.kRadians:case Ir.kGradians:case Ir.kMilliseconds:case Ir.kSeconds:case Ir.kTurns:var i=this.value,o=Yr(this.unit);if(i<-999999||i>999999){var a=Yr(this.unit);r=!Number.isFinite(i)||Number.isNaN(i)?ii(i,a):i+(a||"")}else r="".concat(i).concat(o)}return n+=r},e}(Kr),si=new ai(0,"px");new ai(1,"px");var ui,ci,li=new ai(0,"deg"),hi=function(t){function e(e,n,r,i,o){void 0===i&&(i=1),void 0===o&&(o=!1);var a=t.call(this,"rgb")||this;return a.r=e,a.g=n,a.b=r,a.alpha=i,a.isNone=o,a}return r(e,t),e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.alpha)},e.prototype.buildCSSText=function(t,e,n){return n+"rgba(".concat(this.r,",").concat(this.g,",").concat(this.b,",").concat(this.alpha,")")},e}(Xr),di=new Qr("unset"),fi=new Qr("initial"),pi=new Qr("inherit"),gi={"":di,unset:di,initial:fi,inherit:pi},mi=function(t){return gi[t]||(gi[t]=new Qr(t)),gi[t]},yi=new hi(0,0,0,0,!0),vi=new hi(0,0,0,0),bi=Vr((function(t,e,n,r){return new hi(t,e,n,r)}),(function(t,e,n,r){return"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")")})),xi=function(t,e){return void 0===e&&(e=Ir.kNumber),new ai(t,e)};new ai(50,"%"),function(t){t[t.Standard=0]="Standard"}(ui||(ui={})),function(t){t[t.ADDED=0]="ADDED",t[t.REMOVED=1]="REMOVED",t[t.Z_INDEX_CHANGED=2]="Z_INDEX_CHANGED"}(ci||(ci={}));var wi,Ei={absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Or(0,0,0,0)};function Mi(t){var e=t.type,n=t.value;return"hex"===e?"#".concat(n):"literal"===e?n:"rgb"===e?"rgb(".concat(n.join(","),")"):"rgba(".concat(n.join(","),")")}!function(t){t.COORDINATE="<coordinate>",t.COLOR="<color>",t.PAINT="<paint>",t.NUMBER="<number>",t.ANGLE="<angle>",t.OPACITY_VALUE="<opacity-value>",t.SHADOW_BLUR="<shadow-blur>",t.LENGTH="<length>",t.PERCENTAGE="<percentage>",t.LENGTH_PERCENTAGE="<length> | <percentage>",t.LENGTH_PERCENTAGE_12="[<length> | <percentage>]{1,2}",t.LENGTH_PERCENTAGE_14="[<length> | <percentage>]{1,4}",t.LIST_OF_POINTS="<list-of-points>",t.PATH="<path>",t.FILTER="<filter>",t.Z_INDEX="<z-index>",t.OFFSET_DISTANCE="<offset-distance>",t.DEFINED_PATH="<defined-path>",t.MARKER="<marker>",t.TRANSFORM="<transform>",t.TRANSFORM_ORIGIN="<transform-origin>",t.TEXT="<text>",t.TEXT_TRANSFORM="<text-transform>"}(wi||(wi={}));var Si=function(){var t={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},e="";function n(t){throw new Error(e+": "+t)}function r(){var t=f(i);return e.length>0&&n("Invalid input not EOF"),t}function i(){return o("linear-gradient",t.linearGradient,s)||o("repeating-linear-gradient",t.repeatingLinearGradient,s)||o("radial-gradient",t.radialGradient,u)||o("repeating-radial-gradient",t.repeatingRadialGradient,u)||o("conic-gradient",t.conicGradient,u)}function o(e,r,i){return a(r,(function(r){var o=i();return o&&(b(t.comma)||n("Missing comma before color stops")),{type:e,orientation:o,colorStops:f(p)}}))}function a(e,r){var i=b(e);if(i){b(t.startCall)||n("Missing (");var o=r(i);return b(t.endCall)||n("Missing )"),o}}function s(){return v("directional",t.sideOrCorner,1)||v("angular",t.angleValue,1)}function u(){var n,r,i=c();return i&&((n=[]).push(i),r=e,b(t.comma)&&((i=c())?n.push(i):e=r)),n}function c(){var t=function(){var t=v("shape",/^(circle)/i,0);t&&(t.style=y()||l());return t}()||function(){var t=v("shape",/^(ellipse)/i,0);t&&(t.style=m()||l());return t}();if(t)t.at=h();else{var e=l();if(e){t=e;var n=h();n&&(t.at=n)}else{var r=d();r&&(t={type:"default-radial",at:r})}}return t}function l(){return v("extent-keyword",t.extentKeywords,1)}function h(){if(v("position",/^at/,0)){var t=d();return t||n("Missing positioning value"),t}}function d(){var t={x:m(),y:m()};if(t.x||t.y)return{type:"position",value:t}}function f(e){var r=e(),i=[];if(r)for(i.push(r);b(t.comma);)(r=e())?i.push(r):n("One extra comma");return i}function p(){var e=v("hex",t.hexColor,1)||a(t.rgbaColor,(function(){return{type:"rgba",value:f(g)}}))||a(t.rgbColor,(function(){return{type:"rgb",value:f(g)}}))||v("literal",t.literalColor,0);return e||n("Expected color definition"),e.length=m(),e}function g(){return b(t.number)[1]}function m(){return v("%",t.percentageValue,1)||v("position-keyword",t.positionKeywords,1)||y()}function y(){return v("px",t.pixelValue,1)||v("em",t.emValue,1)}function v(t,e,n){var r=b(e);if(r)return{type:t,value:r[n]}}function b(t){var n=/^[\n\r\t\s]+/.exec(e);n&&x(n[0].length);var r=t.exec(e);return r&&x(r[0].length),r}function x(t){e=e.substring(t)}return function(t){return e=t,r()}}();var Ni=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,ki=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,Ci=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,Ti=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;var Ai={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45},Pi=Vr((function(t){var e;return e="angular"===t.type?Number(t.value):Ai[t.value]||0,xi(e,"deg")})),Oi=Vr((function(t){var e=50,n=50,r="%",i="%";if("position"===(null==t?void 0:t.type)){var o=t.value,a=o.x,s=o.y;"position-keyword"===(null==a?void 0:a.type)&&("left"===a.value?e=0:"center"===a.value?e=50:"right"===a.value?e=100:"top"===a.value?n=0:"bottom"===a.value&&(n=100)),"position-keyword"===(null==s?void 0:s.type)&&("left"===s.value?e=0:"center"===s.value?n=50:"right"===s.value?e=100:"top"===s.value?n=0:"bottom"===s.value&&(n=100)),"px"!==(null==a?void 0:a.type)&&"%"!==(null==a?void 0:a.type)&&"em"!==(null==a?void 0:a.type)||(r=null==a?void 0:a.type,e=Number(a.value)),"px"!==(null==s?void 0:s.type)&&"%"!==(null==s?void 0:s.type)&&"em"!==(null==s?void 0:s.type)||(i=null==s?void 0:s.type,n=Number(s.value))}return{cx:xi(e,r),cy:xi(n,i)}})),_i=Vr((function(t){var e;if(t.indexOf("linear")>-1||t.indexOf("radial")>-1)return Si(t).map((function(t){var e=t.type,n=t.orientation,r=t.colorStops;!function(t){var e,n,r,i=t.length;t[i-1].length=null!==(e=t[i-1].length)&&void 0!==e?e:{type:"%",value:"100"},i>1&&(t[0].length=null!==(n=t[0].length)&&void 0!==n?n:{type:"%",value:"0"});for(var o=0,a=Number(t[0].length.value),s=1;s<i;s++){var u=null===(r=t[s].length)||void 0===r?void 0:r.value;if(!_t(u)&&!_t(a)){for(var c=1;c<s-o;c++)t[o+c].length={type:"%",value:"".concat(a+(Number(u)-a)*c/(s-o))};o=s,a=Number(u)}}}(r);var i=r.map((function(t){return{offset:xi(Number(t.length.value),"%"),color:Mi(t)}}));if("linear-gradient"===e)return new Zr(Ur.LinearGradient,{angle:n?Pi(n):li,steps:i});if("radial-gradient"===e&&(n||(n=[{type:"shape",value:"circle"}]),"shape"===n[0].type&&"circle"===n[0].value)){var o=Oi(n[0].at),a=o.cx,s=o.cy,u=void 0;if(n[0].style){var c=n[0].style,l=c.type,h=c.value;u="extent-keyword"===l?mi(h):xi(h,l)}return new Zr(Ur.RadialGradient,{cx:a,cy:s,size:u,steps:i})}}));var n=t[0];if("("===t[1]||"("===t[2])if("l"===n){var r=Ni.exec(t);if(r){var i=(null===(e=r[2].match(Ti))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return[new Zr(Ur.LinearGradient,{angle:xi(parseFloat(r[1]),"deg"),steps:i.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:xi(100*Number(n),"%"),color:r}}))})]}}else if("r"===n){var o=function(t){var e,n=ki.exec(t);if(n){var r=(null===(e=n[4].match(Ti))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return{cx:xi(50,"%"),cy:xi(50,"%"),steps:r.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:xi(100*Number(n),"%"),color:r}}))}}return null}(t);if(o){if(!Vt(o))return[new Zr(Ur.RadialGradient,o)];t=o}}else if("p"===n)return function(t){var e=Ci.exec(t);if(e){var n=e[1],r=e[2];switch(n){case"a":n="repeat";break;case"x":n="repeat-x";break;case"y":n="repeat-y";break;default:n="no-repeat"}return{image:r,repetition:n}}return null}(t)}));function Ri(t){return t&&!!t.image}function Ii(t){return t&&!_t(t.r)&&!_t(t.g)&&!_t(t.b)}var Di=Vr((function(t){if(Ri(t))return i({repetition:"repeat"},t);if(_t(t)&&(t=""),"transparent"===t)return vi;if("currentColor"===t)t="black";else if("none"===t)return yi;var e=_i(t);if(e)return e;var n=Sn(t),r=[0,0,0,0];return null!==n&&(r[0]=n.r||0,r[1]=n.g||0,r[2]=n.b||0,r[3]=n.opacity),bi.apply(void 0,l([],c(r),!1))}));function Li(t,e){if(Ii(t)&&Ii(e))return[[Number(t.r),Number(t.g),Number(t.b),Number(t.alpha)],[Number(e.r),Number(e.g),Number(e.b),Number(e.alpha)],function(t){var e=t.slice();if(e[3])for(var n=0;n<3;n++)e[n]=Math.round(Ut(e[n],0,255));return e[3]=Ut(e[3],0,1),"rgba(".concat(e.join(","),")")}]}function ji(t,e){if(_t(e))return xi(0,"px");if(e="".concat(e).trim().toLowerCase(),isFinite(Number(e))){if("px".search(t)>=0)return xi(Number(e),"px");if("deg".search(t)>=0)return xi(Number(e),"deg")}var n=[];e=e.replace(t,(function(t){return n.push(t),"U"+t}));var r="U("+t.source+")";return n.map((function(t){return xi(Number(e.replace(new RegExp("U"+t,"g"),"").replace(new RegExp(r,"g"),"*0")),t)}))[0]}var Bi=function(t){return ji(new RegExp("px","g"),t)},zi=Vr(Bi);Vr((function(t){return ji(new RegExp("%","g"),t)}));var Fi=function(t){return $t(t)||isFinite(Number(t))?xi(Number(t)||0,"px"):ji(new RegExp("px|%|em|rem","g"),t)},Gi=Vr(Fi),Vi=function(t){return ji(new RegExp("deg|rad|grad|turn","g"),t)},Wi=Vr(Vi);function Hi(t,e,n,r,i){void 0===i&&(i=0);var o="",a=t.value||0,s=e.value||0,u=oi(t.unit),c=t.convertTo(u),l=e.convertTo(u);return c&&l?(a=c.value,s=l.value,o=Yr(t.unit)):(ai.isLength(t.unit)||ai.isLength(e.unit))&&(a=Yi(t,i,n),s=Yi(e,i,n),o="px"),[a,s,function(t){return t+o}]}function Ui(t){var e=0;return t.unit===Ir.kDegrees?e=t.value:t.unit===Ir.kRadians?e=fr(Number(t.value)):t.unit===Ir.kTurns&&(e=360*Number(t.value)),e}function $i(t,e){var n;return Array.isArray(t)?n=t.map((function(t){return Number(t)})):Vt(t)?n=t.split(" ").map((function(t){return Number(t)})):$t(t)&&(n=[t]),2===e?1===n.length?[n[0],n[0]]:[n[0],n[1]]:1===n.length?[n[0],n[0],n[0],n[0]]:2===n.length?[n[0],n[1],n[0],n[1]]:3===n.length?[n[0],n[1],n[2],n[1]]:[n[0],n[1],n[2],n[3]]}function qi(t){return Vt(t)?t.split(" ").map((function(t){return Gi(t)})):t.map((function(t){return Gi(t.toString())}))}function Yi(t,e,n,r){if(void 0===r&&(r=!1),t.unit===Ir.kPixels)return Number(t.value);if(t.unit===Ir.kPercentage&&n){var i=n.nodeName===er.GROUP?n.getLocalBounds():n.getGeometryBounds();return(r?i.min[e]:0)+t.value/100*i.halfExtents[e]*2}return 0}var Ki=["blur","brightness","drop-shadow","contrast","grayscale","sepia","saturate","hue-rotate","invert"];function Xi(t){if(void 0===t&&(t=""),"none"===(t=t.toLowerCase().trim()))return[];for(var e,n=/\s*([\w-]+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];if(i=e.index+e[0].length,Ki.indexOf(e[1])>-1&&r.push({name:e[1],params:e[2].split(" ").map((function(t){return ji(/deg|rad|grad|turn|px|%/g,t)||Di(t)}))}),n.lastIndex===t.length)return r}return[]}function Zi(t){return t.toString()}var Qi=function(t){return"number"==typeof t?xi(t):/^\s*[-+]?(\d*\.)?\d+\s*$/.test(t)?xi(Number(t)):xi(0)},Ji=Vr(Qi);function to(t,e){return[t,e,Zi]}function eo(t,e){return function(n,r){return[n,r,function(n){return Zi(Ut(n,t,e))}]}}function no(t,e){if(t.length===e.length)return[t,e,function(t){return t}]}function ro(t){var e;return 0===t.parsedStyle.d.totalLength&&(t.parsedStyle.d.totalLength=Je(t.parsedStyle.d.absolutePath,void 0,i(i({},e),{bbox:!1,length:!0})).length),t.parsedStyle.d.totalLength}function io(t,e){return t[0]===e[0]&&t[1]===e[1]}function oo(t,e){var n=t.prePoint,r=t.currentPoint,i=t.nextPoint,o=Math.pow(r[0]-n[0],2)+Math.pow(r[1]-n[1],2),a=Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2),s=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2),u=Math.acos((o+a-s)/(2*Math.sqrt(o)*Math.sqrt(a)));if(!u||0===Math.sin(u)||Yt(u,0))return{xExtra:0,yExtra:0};var c=Math.abs(Math.atan2(i[1]-r[1],i[0]-r[0])),l=Math.abs(Math.atan2(i[0]-r[0],i[1]-r[1]));return c=c>Math.PI/2?Math.PI-c:c,l=l>Math.PI/2?Math.PI-l:l,{xExtra:Math.cos(u/2-c)*(e/2*(1/Math.sin(u/2)))-e/2||0,yExtra:Math.cos(l-u/2)*(e/2*(1/Math.sin(u/2)))-e/2||0}}function ao(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}Vr((function(t){return Vt(t)?t.split(" ").map(Ji):t.map(Ji)}));var so=function(t,e){var n=t.x*e.x+t.y*e.y,r=Math.sqrt((Math.pow(t.x,2)+Math.pow(t.y,2))*(Math.pow(e.x,2)+Math.pow(e.y,2)));return(t.x*e.y-t.y*e.x<0?-1:1)*Math.acos(n/r)},uo=function(t,e,n,r,i,o,a,s){e=Math.abs(e),n=Math.abs(n);var u=dr(r=Zt(r,360));if(t.x===a.x&&t.y===a.y)return{x:t.x,y:t.y,ellipticalArcAngle:0};if(0===e||0===n)return{x:0,y:0,ellipticalArcAngle:0};var c=(t.x-a.x)/2,l=(t.y-a.y)/2,h={x:Math.cos(u)*c+Math.sin(u)*l,y:-Math.sin(u)*c+Math.cos(u)*l},d=Math.pow(h.x,2)/Math.pow(e,2)+Math.pow(h.y,2)/Math.pow(n,2);d>1&&(e=Math.sqrt(d)*e,n=Math.sqrt(d)*n);var f=(Math.pow(e,2)*Math.pow(n,2)-Math.pow(e,2)*Math.pow(h.y,2)-Math.pow(n,2)*Math.pow(h.x,2))/(Math.pow(e,2)*Math.pow(h.y,2)+Math.pow(n,2)*Math.pow(h.x,2));f=f<0?0:f;var p=(i!==o?1:-1)*Math.sqrt(f),g=p*(e*h.y/n),m=p*(-n*h.x/e),y={x:Math.cos(u)*g-Math.sin(u)*m+(t.x+a.x)/2,y:Math.sin(u)*g+Math.cos(u)*m+(t.y+a.y)/2},v={x:(h.x-g)/e,y:(h.y-m)/n},b=so({x:1,y:0},v),x=so(v,{x:(-h.x-g)/e,y:(-h.y-m)/n});!o&&x>0?x-=2*Math.PI:o&&x<0&&(x+=2*Math.PI);var w=b+(x%=2*Math.PI)*s,E=e*Math.cos(w),M=n*Math.sin(w);return{x:Math.cos(u)*E-Math.sin(u)*M+y.x,y:Math.sin(u)*E+Math.cos(u)*M+y.y,ellipticalArcStartAngle:b,ellipticalArcEndAngle:b+x,ellipticalArcAngle:w,ellipticalArcCenter:y,resultantRx:e,resultantRy:n}};function co(t,e,n){void 0===n&&(n=!0);var r=t.arcParams,i=r.rx,o=void 0===i?0:i,a=r.ry,s=void 0===a?0:a,u=r.xRotation,c=r.arcFlag,l=r.sweepFlag,h=uo({x:t.prePoint[0],y:t.prePoint[1]},o,s,u,!!c,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},e),d=uo({x:t.prePoint[0],y:t.prePoint[1]},o,s,u,!!c,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},n?e+.005:e-.005),f=d.x-h.x,p=d.y-h.y,g=Math.sqrt(f*f+p*p);return{x:-f/g,y:-p/g}}function lo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ho(t,e){return lo(t)*lo(e)?(t[0]*e[0]+t[1]*e[1])/(lo(t)*lo(e)):1}function fo(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(ho(t,e))}function po(t,e){var n=e[1],r=e[2],i=Zt(dr(e[3]),2*Math.PI),o=e[4],a=e[5],s=t[0],u=t[1],c=e[6],l=e[7],h=Math.cos(i)*(s-c)/2+Math.sin(i)*(u-l)/2,d=-1*Math.sin(i)*(s-c)/2+Math.cos(i)*(u-l)/2,f=h*h/(n*n)+d*d/(r*r);f>1&&(n*=Math.sqrt(f),r*=Math.sqrt(f));var p=n*n*(d*d)+r*r*(h*h),g=p?Math.sqrt((n*n*(r*r)-p)/p):1;o===a&&(g*=-1),isNaN(g)&&(g=0);var m=r?g*n*d/r:0,y=n?g*-r*h/n:0,v=(s+c)/2+Math.cos(i)*m-Math.sin(i)*y,b=(u+l)/2+Math.sin(i)*m+Math.cos(i)*y,x=[(h-m)/n,(d-y)/r],w=[(-1*h-m)/n,(-1*d-y)/r],E=fo([1,0],x),M=fo(x,w);return ho(x,w)<=-1&&(M=Math.PI),ho(x,w)>=1&&(M=0),0===a&&M>0&&(M-=2*Math.PI),1===a&&M<0&&(M+=2*Math.PI),{cx:v,cy:b,rx:io(t,[c,l])?0:n,ry:io(t,[c,l])?0:r,startAngle:E,endAngle:E+M,xRotation:i,arcFlag:o,sweepFlag:a}}var go=function(t){if(""===t||Array.isArray(t)&&0===t.length)return{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:{x:0,y:0,width:0,height:0}};var e;try{e=je(t)}catch(n){e=je(""),console.error("[g]: Invalid SVG Path definition: ".concat(t))}!function(t){for(var e=0;e<t.length;e++){var n=t[e-1],r=t[e];if("M"===r[0]&&n){var i=n[0],o=[r[1],r[2]],a=void 0;"L"===i||"M"===i?a=[n[1],n[2]]:"C"!==i&&"A"!==i&&"Q"!==i||(a=[n[n.length-2],n[n.length-1]]),a&&io(o,a)&&(t.splice(e,1),e--)}}}(e);var n=function(t){for(var e=!1,n=t.length,r=0;r<n;r++){var i=t[r][0];if("C"===i||"A"===i||"Q"===i){e=!0;break}}return e}(e),r=function(t){for(var e=[],n=[],r=[],i=0;i<t.length;i++){var o=t[i],a=o[0];"M"===a?(r.length&&(n.push(r),r=[]),r.push([o[1],o[2]])):"Z"===a?r.length&&(e.push(r),r=[]):r.push([o[1],o[2]])}return r.length>0&&n.push(r),{polygons:e,polylines:n}}(e),i=r.polygons,o=r.polylines,a=function(t){for(var e=[],n=null,r=null,i=null,o=0,a=t.length,s=0;s<a;s++){var u=t[s];r=t[s+1];var c=u[0],l={command:c,prePoint:n,params:u,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(c){case"M":i=[u[1],u[2]],o=s;break;case"A":var h=po(n,u);l.arcParams=h}if("Z"===c)n=i,r=t[o+1];else{var d=u.length;n=[u[d-2],u[d-1]]}r&&"Z"===r[0]&&(r=t[o],e[o]&&(e[o].prePoint=n)),l.currentPoint=n,e[o]&&io(n,e[o].currentPoint)&&(e[o].prePoint=l.prePoint);var f=r?[r[r.length-2],r[r.length-1]]:null;l.nextPoint=f;var p=l.prePoint;if(["L","H","V"].includes(c))l.startTangent=[p[0]-n[0],p[1]-n[1]],l.endTangent=[n[0]-p[0],n[1]-p[1]];else if("Q"===c){var g=[u[1],u[2]];l.startTangent=[p[0]-g[0],p[1]-g[1]],l.endTangent=[n[0]-g[0],n[1]-g[1]]}else if("T"===c)g=ao((v=e[s-1]).currentPoint,p),"Q"===v.command?(l.command="Q",l.startTangent=[p[0]-g[0],p[1]-g[1]],l.endTangent=[n[0]-g[0],n[1]-g[1]]):(l.command="TL",l.startTangent=[p[0]-n[0],p[1]-n[1]],l.endTangent=[n[0]-p[0],n[1]-p[1]]);else if("C"===c){var m=[u[1],u[2]],y=[u[3],u[4]];l.startTangent=[p[0]-m[0],p[1]-m[1]],l.endTangent=[n[0]-y[0],n[1]-y[1]],0===l.startTangent[0]&&0===l.startTangent[1]&&(l.startTangent=[m[0]-y[0],m[1]-y[1]]),0===l.endTangent[0]&&0===l.endTangent[1]&&(l.endTangent=[y[0]-m[0],y[1]-m[1]])}else if("S"===c){var v;m=ao((v=e[s-1]).currentPoint,p),y=[u[1],u[2]],"C"===v.command?(l.command="C",l.startTangent=[p[0]-m[0],p[1]-m[1]],l.endTangent=[n[0]-y[0],n[1]-y[1]]):(l.command="SQ",l.startTangent=[p[0]-y[0],p[1]-y[1]],l.endTangent=[n[0]-y[0],n[1]-y[1]])}else if("A"===c){var b=co(l,0),x=b.x,w=b.y,E=co(l,1,!1),M=E.x,S=E.y;l.startTangent=[x,w],l.endTangent=[M,S]}e.push(l)}return e}(e),s=function(t,e){for(var n=[],r=[],i=[],o=0;o<t.length;o++){var a=(g=t[o]).currentPoint,s=g.params,u=g.prePoint,c=void 0;switch(g.command){case"Q":c=Qn(u[0],u[1],s[1],s[2],s[3],s[4]);break;case"C":c=qn(u[0],u[1],s[1],s[2],s[3],s[4],s[5],s[6]);break;case"A":var l=g.arcParams;c=zn(l.cx,l.cy,l.rx,l.ry,l.xRotation,l.startAngle,l.endAngle);break;default:n.push(a[0]),r.push(a[1])}c&&(g.box=c,n.push(c.x,c.x+c.width),r.push(c.y,c.y+c.height))}n=n.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0})),r=r.filter((function(t){return!Number.isNaN(t)&&t!==1/0&&t!==-1/0}));var h=Gt(n),d=Gt(r),f=Ft(n),p=Ft(r);if(0===i.length)return{x:h,y:d,width:f-h,height:p-d};for(o=0;o<i.length;o++){var g;(a=(g=i[o]).currentPoint)[0]===h?h-=oo(g,e).xExtra:a[0]===f&&(f+=oo(g,e).xExtra),a[1]===d?d-=oo(g,e).yExtra:a[1]===p&&(p+=oo(g,e).yExtra)}return{x:h,y:d,width:f-h,height:p-d}}(a,0),u=s.x,c=s.y,l=s.width,h=s.height;return{absolutePath:e,hasArc:n,segments:a,polygons:i,polylines:o,totalLength:0,rect:{x:Number.isFinite(u)?u:0,y:Number.isFinite(c)?c:0,width:Number.isFinite(l)?l:0,height:Number.isFinite(h)?h:0}}},mo=Vr(go);function yo(t){return Vt(t)?mo(t):go(t)}function vo(t,e,n){var r=t.curve,i=e.curve;r&&0!==r.length||(r=We(t.absolutePath,!1),t.curve=r),i&&0!==i.length||(i=We(e.absolutePath,!1),e.curve=i);var o=[r,i];r.length!==i.length&&(o=rn(r,i));var a,s,u=en(o[0])!==en(o[1])?(a=o[0],s=a.slice(1).map((function(t,e,n){return e?n[e-1].slice(-2).concat(t.slice(1)):a[0].slice(1).concat(t.slice(1))})).map((function(t){return t.map((function(e,n){return t[t.length-n-2*(1-n%2)]}))})).reverse(),[["M"].concat(s[0].slice(0,2))].concat(s.map((function(t){return["C"].concat(t.slice(2))})))):o[0].map((function(t){return Array.isArray(t)?[].concat(t):t}));return[u,tn(o[1],u),function(t){return t}]}function bo(t,e){var n;return n=Vt(t)?t.split(" ").map((function(t){var e=c(t.split(","),2),n=e[0],r=e[1];return[Number(n),Number(r)]})):t,{points:n,totalLength:0,segments:[]}}function xo(t,e){return[t.points,e.points,function(t){return t}]}var wo=null;function Eo(t){return function(e){var n=0;return t.map((function(t){return t===wo?e[n++]:t}))}}function Mo(t){return t}var So={matrix:["NNNNNN",[wo,wo,0,0,wo,wo,0,0,0,0,1,0,wo,wo,0,1],Mo],matrix3d:["NNNNNNNNNNNNNNNN",Mo],rotate:["A"],rotatex:["A"],rotatey:["A"],rotatez:["A"],rotate3d:["NNNA"],perspective:["L"],scale:["Nn",Eo([wo,wo,new ai(1)]),Mo],scalex:["N",Eo([wo,new ai(1),new ai(1)]),Eo([wo,new ai(1)])],scaley:["N",Eo([new ai(1),wo,new ai(1)]),Eo([new ai(1),wo])],scalez:["N",Eo([new ai(1),new ai(1),wo])],scale3d:["NNN",Mo],skew:["Aa",null,Mo],skewx:["A",null,Eo([wo,li])],skewy:["A",null,Eo([li,wo])],translate:["Tt",Eo([wo,wo,si]),Mo],translatex:["T",Eo([wo,si,si]),Eo([wo,si])],translatey:["T",Eo([si,wo,si]),Eo([si,wo])],translatez:["L",Eo([si,si,wo])],translate3d:["TTL",Mo]};function No(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=So[o];if(!a)return[];var s=e[2].split(","),u=a[0];if(u.length<s.length)return[];for(var c=[],l=0;l<u.length;l++){var h=s[l],d=u[l],f=void 0;if(void 0===(f=h?{A:function(t){return"0"===t.trim()?li:Wi(t)},N:Ji,T:Gi,L:zi}[d.toUpperCase()](h):{a:li,n:c[0],t:si}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}function ko(t){if("none"===(t=(t||"none").toLowerCase().trim()))return[];for(var e,n=/\s*(\w+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];i=e.index+e[0].length;var o=e[1],a=So[o];if(!a)return[];var s=e[2].split(","),u=a[0];if(u.length<s.length)return[];for(var c=[],l=0;l<u.length;l++){var h=s[l],d=u[l],f=void 0;if(void 0===(f=h?{A:function(t){return"0"===t.trim()?li:Vi(t)},N:Qi,T:Fi,L:Bi}[d.toUpperCase()](h):{a:li,n:c[0],t:si}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}function Co(t){var e,n,r,i;switch(t.t){case"rotatex":return i=dr(Ui(t.d[0])),[1,0,0,0,0,Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1];case"rotatey":return i=dr(Ui(t.d[0])),[Math.cos(i),0,-Math.sin(i),0,0,1,0,0,Math.sin(i),0,Math.cos(i),0,0,0,0,1];case"rotate":case"rotatez":return i=dr(Ui(t.d[0])),[Math.cos(i),Math.sin(i),0,0,-Math.sin(i),Math.cos(i),0,0,0,0,1,0,0,0,0,1];case"rotate3d":e=t.d[0].value,n=t.d[1].value,r=t.d[2].value,i=dr(Ui(t.d[3]));var o=e*e+n*n+r*r;if(0===o)e=1,n=0,r=0;else if(1!==o){var a=Math.sqrt(o);e/=a,n/=a,r/=a}var s=Math.sin(i/2),u=s*Math.cos(i/2),c=s*s;return[1-2*(n*n+r*r)*c,2*(e*n*c+r*u),2*(e*r*c-n*u),0,2*(e*n*c-r*u),1-2*(e*e+r*r)*c,2*(n*r*c+e*u),0,2*(e*r*c+n*u),2*(n*r*c-e*u),1-2*(e*e+n*n)*c,0,0,0,0,1];case"scale":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,1,0,0,0,0,1];case"scalex":return[t.d[0].value,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"scaley":return[1,0,0,0,0,t.d[0].value,0,0,0,0,1,0,0,0,0,1];case"scalez":return[1,0,0,0,0,1,0,0,0,0,t.d[0].value,0,0,0,0,1];case"scale3d":return[t.d[0].value,0,0,0,0,t.d[1].value,0,0,0,0,t.d[2].value,0,0,0,0,1];case"skew":var l=dr(Ui(t.d[0])),h=dr(Ui(t.d[1]));return[1,Math.tan(h),0,0,Math.tan(l),1,0,0,0,0,1,0,0,0,0,1];case"skewx":return i=dr(Ui(t.d[0])),[1,0,0,0,Math.tan(i),1,0,0,0,0,1,0,0,0,0,1];case"skewy":return i=dr(Ui(t.d[0])),[1,Math.tan(i),0,0,0,1,0,0,0,0,1,0,0,0,0,1];case"translate":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Yi(t.d[0],0,null)||0,n=Yi(t.d[1],0,null)||0,0,1];case"translatex":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Yi(t.d[0],0,null)||0,0,0,1];case"translatey":return[1,0,0,0,0,1,0,0,0,0,1,0,0,n=Yi(t.d[0],0,null)||0,0,1];case"translatez":return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,r=Yi(t.d[0],0,null)||0,1];case"translate3d":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Yi(t.d[0],0,null)||0,n=Yi(t.d[1],0,null)||0,r=Yi(t.d[2],0,null)||0,1];case"perspective":var d=Yi(t.d[0],0,null)||0;return[1,0,0,0,0,1,0,0,0,0,1,d?-1/d:0,0,0,0,1];case"matrix":return[t.d[0].value,t.d[1].value,0,0,t.d[2].value,t.d[3].value,0,0,0,0,1,0,t.d[4].value,t.d[5].value,0,1];case"matrix3d":return t.d.map((function(t){return t.value}))}}function To(t,e){return[t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12]*e[3],t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13]*e[3],t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14]*e[3],t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15]*e[3],t[0]*e[4]+t[4]*e[5]+t[8]*e[6]+t[12]*e[7],t[1]*e[4]+t[5]*e[5]+t[9]*e[6]+t[13]*e[7],t[2]*e[4]+t[6]*e[5]+t[10]*e[6]+t[14]*e[7],t[3]*e[4]+t[7]*e[5]+t[11]*e[6]+t[15]*e[7],t[0]*e[8]+t[4]*e[9]+t[8]*e[10]+t[12]*e[11],t[1]*e[8]+t[5]*e[9]+t[9]*e[10]+t[13]*e[11],t[2]*e[8]+t[6]*e[9]+t[10]*e[10]+t[14]*e[11],t[3]*e[8]+t[7]*e[9]+t[11]*e[10]+t[15]*e[11],t[0]*e[12]+t[4]*e[13]+t[8]*e[14]+t[12]*e[15],t[1]*e[12]+t[5]*e[13]+t[9]*e[14]+t[13]*e[15],t[2]*e[12]+t[6]*e[13]+t[10]*e[14]+t[14]*e[15],t[3]*e[12]+t[7]*e[13]+t[11]*e[14]+t[15]*e[15]]}function Ao(t){var e=[0,0,0],n=[1,1,1],r=[0,0,0],i=[0,0,0,1],o=[0,0,0,1];return function(t,e,n,r,i,o){if(!function(t,e){var n=e[15];if(0===n)return!1;for(var r=1/n,i=0;i<16;i++)t[i]=e[i]*r;return!0}(yr,t))return!1;if(E(vr,yr),vr[3]=0,vr[7]=0,vr[11]=0,vr[15]=1,Math.abs(C(vr))<1e-8)return!1;var a,s,u=yr[3],c=yr[7],l=yr[11],h=yr[12],d=yr[13],f=yr[14],p=yr[15];if(0!==u||0!==c||0!==l){if(br[0]=u,br[1]=c,br[2]=l,br[3]=p,!k(vr,vr))return!1;N(vr,vr),bt(i,br,vr)}else i[0]=i[1]=i[2]=0,i[3]=1;if(e[0]=h,e[1]=d,e[2]=f,s=yr,(a=xr)[0][0]=s[0],a[0][1]=s[1],a[0][2]=s[2],a[1][0]=s[4],a[1][1]=s[5],a[1][2]=s[6],a[2][0]=s[8],a[2][1]=s[9],a[2][2]=s[10],n[0]=rt(xr[0]),lt(xr[0],xr[0]),r[0]=ht(xr[0],xr[1]),Er(xr[1],xr[1],xr[0],1,-r[0]),n[1]=rt(xr[1]),lt(xr[1],xr[1]),r[0]/=n[1],r[1]=ht(xr[0],xr[2]),Er(xr[2],xr[2],xr[0],1,-r[1]),r[2]=ht(xr[1],xr[2]),Er(xr[2],xr[2],xr[1],1,-r[2]),n[2]=rt(xr[2]),lt(xr[2],xr[2]),r[1]/=n[2],r[2]/=n[2],dt(wr,xr[1],xr[2]),ht(xr[0],wr)<0)for(var g=0;g<3;g++)n[g]*=-1,xr[g][0]*=-1,xr[g][1]*=-1,xr[g][2]*=-1;o[0]=.5*Math.sqrt(Math.max(1+xr[0][0]-xr[1][1]-xr[2][2],0)),o[1]=.5*Math.sqrt(Math.max(1-xr[0][0]+xr[1][1]-xr[2][2],0)),o[2]=.5*Math.sqrt(Math.max(1-xr[0][0]-xr[1][1]+xr[2][2],0)),o[3]=.5*Math.sqrt(Math.max(1+xr[0][0]+xr[1][1]+xr[2][2],0)),xr[2][1]>xr[1][2]&&(o[0]=-o[0]),xr[0][2]>xr[2][0]&&(o[1]=-o[1]),xr[1][0]>xr[0][1]&&(o[2]=-o[2])}(function(t){return 0===t.length?[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]:t.map(Co).reduce(To)}(t),e,n,r,i,o),[[e,n,r,o,i]]}var Po=function(){function t(t,e){for(var n=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],r=0;r<4;r++)for(var i=0;i<4;i++)for(var o=0;o<4;o++)n[r][i]+=e[r][o]*t[o][i];return n}return function(e,n,r,i,o){for(var a=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],s=0;s<4;s++)a[s][3]=o[s];for(s=0;s<3;s++)for(var u=0;u<3;u++)a[3][s]+=e[u]*a[u][s];var c=i[0],l=i[1],h=i[2],d=i[3],f=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];f[0][0]=1-2*(l*l+h*h),f[0][1]=2*(c*l-h*d),f[0][2]=2*(c*h+l*d),f[1][0]=2*(c*l+h*d),f[1][1]=1-2*(c*c+h*h),f[1][2]=2*(l*h-c*d),f[2][0]=2*(c*h-l*d),f[2][1]=2*(l*h+c*d),f[2][2]=1-2*(c*c+l*l),a=t(a,f);var p=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(r[2]&&(p[2][1]=r[2],a=t(a,p)),r[1]&&(p[2][1]=0,p[2][0]=r[0],a=t(a,p)),r[0]&&(p[2][0]=0,p[1][0]=r[0],a=t(a,p)),s=0;s<3;s++)for(u=0;u<3;u++)a[s][u]*=n[s];return function(t){return 0==t[0][2]&&0==t[0][3]&&0==t[1][2]&&0==t[1][3]&&0==t[2][0]&&0==t[2][1]&&1==t[2][2]&&0==t[2][3]&&0==t[3][2]&&1==t[3][3]}(a)?[a[0][0],a[0][1],a[1][0],a[1][1],a[3][0],a[3][1]]:a[0].concat(a[1],a[2],a[3])}}();function Oo(t){return t.toFixed(6).replace(".000000","")}function _o(t,e){var n,r;return t.decompositionPair!==e&&(t.decompositionPair=e,n=Ao(t)),e.decompositionPair!==t&&(e.decompositionPair=t,r=Ao(e)),null===n[0]||null===r[0]?[[!1],[!0],function(n){return n?e[0].d:t[0].d}]:(n[0].push(0),r[0].push(1),[n,r,function(t){var e=function(t,e,n){var r=function(t,e){for(var n=0,r=0;r<t.length;r++)n+=t[r]*e[r];return n}(t,e);r=Ut(r,-1,1);var i=[];if(1===r)i=t;else for(var o=Math.acos(r),a=1*Math.sin(n*o)/Math.sqrt(1-r*r),s=0;s<4;s++)i.push(t[s]*(Math.cos(n*o)-r*a)+e[s]*a);return i}(n[0][3],r[0][3],t[5]);return Po(t[0],t[1],t[2],e,t[4]).map(Oo).join(",")}])}function Ro(t){return t.replace(/[xy]/,"")}function Io(t){return t.replace(/(x|y|z|3d)?$/,"3d")}function Do(t,e,n){var r=!1;if(!t.length||!e.length){t.length||(r=!0,t=e,e=[]);for(var i=function(n){var r=t[n],i=r.t,o=r.d,a="scale"===i.substring(0,5)?1:0;e.push({t:i,d:o.map((function(t){return"number"==typeof t?xi(a):xi(a,t.unit)}))})},o=0;o<t.length;o++)i(o)}var a,s,u=[],c=[],l=[];if(t.length!==e.length)u=[(v=_o(t,e))[0]],c=[v[1]],l=[["matrix",[v[2]]]];else for(o=0;o<t.length;o++){var h=t[o].t,d=e[o].t,f=t[o].d,p=e[o].d,g=So[h],m=So[d],y=void 0;if(s=d,"perspective"===(a=h)&&"perspective"===s||!("matrix"!==a&&"matrix3d"!==a||"matrix"!==s&&"matrix3d"!==s)){var v=_o([t[o]],[e[o]]);u.push(v[0]),c.push(v[1]),l.push(["matrix",[v[2]]])}else{if(h===d)y=h;else if(g[2]&&m[2]&&Ro(h)===Ro(d))y=Ro(h),f=g[2](f),p=m[2](p);else{if(!g[1]||!m[1]||Io(h)!==Io(d)){u=[(v=_o(t,e))[0]],c=[v[1]],l=[["matrix",[v[2]]]];break}y=Io(h),f=g[1](f),p=m[1](p)}for(var b=[],x=[],w=[],E=0;E<f.length;E++){v=Hi(f[E],p[E],n,0,E);b[E]=v[0],x[E]=v[1],w.push(v[2])}u.push(b),c.push(x),l.push([y,w])}}if(r){var M=u;u=c,c=M}return[u,c,function(t){return t.map((function(t,e){var n=t.map((function(t,n){return l[e][1][n](t)})).join(",");return"matrix"===l[e][0]&&16===n.split(",").length&&(l[e][0]="matrix3d"),"matrix3d"===l[e][0]&&6===n.split(",").length&&(l[e][0]="matrix"),l[e][0]+"("+n+")"})).join(" ")}]}var Lo=Vr((function(t){if(Vt(t)){if("text-anchor"===t)return[xi(0,"px"),xi(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Gi(Bo(e[0])),Gi(Bo(e[1]))]}return[xi(t[0]||0,"px"),xi(t[1]||0,"px")]})),jo=function(t){if(Vt(t)){if("text-anchor"===t)return[xi(0,"px"),xi(0,"px")];var e=t.split(" ");return 1===e.length&&("top"===e[0]||"bottom"===e[0]?(e[1]=e[0],e[0]="center"):e[1]="center"),2!==e.length?null:[Fi(Bo(e[0])),Fi(Bo(e[1]))]}return[xi(t[0]||0,"px"),xi(t[1]||0,"px")]};function Bo(t){return"center"===t?"50%":"left"===t||"top"===t?"0%":"right"===t||"bottom"===t?"100%":t}var zo=[{n:"display",k:["none"]},{n:"opacity",int:!0,inh:!0,d:"1",syntax:wi.OPACITY_VALUE},{n:"fillOpacity",int:!0,inh:!0,d:"1",syntax:wi.OPACITY_VALUE},{n:"strokeOpacity",int:!0,inh:!0,d:"1",syntax:wi.OPACITY_VALUE},{n:"fill",int:!0,k:["none"],d:"none",syntax:wi.PAINT},{n:"fillRule",k:["nonzero","evenodd"],d:"nonzero"},{n:"stroke",int:!0,k:["none"],d:"none",syntax:wi.PAINT,l:!0},{n:"shadowType",k:["inner","outer","both"],d:"outer",l:!0},{n:"shadowColor",int:!0,syntax:wi.COLOR},{n:"shadowOffsetX",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"shadowOffsetY",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"shadowBlur",int:!0,l:!0,d:"0",syntax:wi.SHADOW_BLUR},{n:"lineWidth",int:!0,inh:!0,d:"1",l:!0,a:["strokeWidth"],syntax:wi.LENGTH_PERCENTAGE},{n:"increasedLineWidthForHitTesting",inh:!0,d:"0",l:!0,syntax:wi.LENGTH_PERCENTAGE},{n:"lineJoin",inh:!0,l:!0,a:["strokeLinejoin"],k:["miter","bevel","round"],d:"miter"},{n:"lineCap",inh:!0,l:!0,a:["strokeLinecap"],k:["butt","round","square"],d:"butt"},{n:"lineDash",int:!0,inh:!0,k:["none"],a:["strokeDasharray"],syntax:wi.LENGTH_PERCENTAGE_12},{n:"lineDashOffset",int:!0,inh:!0,d:"0",a:["strokeDashoffset"],syntax:wi.LENGTH_PERCENTAGE},{n:"offsetPath",syntax:wi.DEFINED_PATH},{n:"offsetDistance",int:!0,syntax:wi.OFFSET_DISTANCE},{n:"dx",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"dy",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"zIndex",ind:!0,int:!0,d:"0",k:["auto"],syntax:wi.Z_INDEX},{n:"visibility",k:["visible","hidden"],ind:!0,inh:!0,int:!0,d:"visible"},{n:"pointerEvents",inh:!0,k:["none","auto","stroke","fill","painted","visible","visiblestroke","visiblefill","visiblepainted","all"],d:"auto"},{n:"filter",ind:!0,l:!0,k:["none"],d:"none",syntax:wi.FILTER},{n:"clipPath",syntax:wi.DEFINED_PATH},{n:"textPath",syntax:wi.DEFINED_PATH},{n:"textPathSide",k:["left","right"],d:"left"},{n:"textPathStartOffset",l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"transform",p:100,int:!0,k:["none"],d:"none",syntax:wi.TRANSFORM},{n:"transformOrigin",p:100,d:"0 0",l:!0,syntax:wi.TRANSFORM_ORIGIN},{n:"cx",int:!0,l:!0,d:"0",syntax:wi.COORDINATE},{n:"cy",int:!0,l:!0,d:"0",syntax:wi.COORDINATE},{n:"cz",int:!0,l:!0,d:"0",syntax:wi.COORDINATE},{n:"r",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"rx",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"ry",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"x",int:!0,l:!0,d:"0",syntax:wi.COORDINATE},{n:"y",int:!0,l:!0,d:"0",syntax:wi.COORDINATE},{n:"z",int:!0,l:!0,d:"0",syntax:wi.COORDINATE},{n:"width",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"height",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:wi.LENGTH_PERCENTAGE},{n:"radius",int:!0,l:!0,d:"0",syntax:wi.LENGTH_PERCENTAGE_14},{n:"x1",int:!0,l:!0,syntax:wi.COORDINATE},{n:"y1",int:!0,l:!0,syntax:wi.COORDINATE},{n:"z1",int:!0,l:!0,syntax:wi.COORDINATE},{n:"x2",int:!0,l:!0,syntax:wi.COORDINATE},{n:"y2",int:!0,l:!0,syntax:wi.COORDINATE},{n:"z2",int:!0,l:!0,syntax:wi.COORDINATE},{n:"d",int:!0,l:!0,d:"",syntax:wi.PATH,p:50},{n:"points",int:!0,l:!0,syntax:wi.LIST_OF_POINTS,p:50},{n:"text",l:!0,d:"",syntax:wi.TEXT,p:50},{n:"textTransform",l:!0,inh:!0,k:["capitalize","uppercase","lowercase","none"],d:"none",syntax:wi.TEXT_TRANSFORM,p:51},{n:"font",l:!0},{n:"fontSize",int:!0,inh:!0,d:"16px",l:!0,syntax:wi.LENGTH_PERCENTAGE},{n:"fontFamily",l:!0,inh:!0,d:"sans-serif"},{n:"fontStyle",l:!0,inh:!0,k:["normal","italic","oblique"],d:"normal"},{n:"fontWeight",l:!0,inh:!0,k:["normal","bold","bolder","lighter"],d:"normal"},{n:"fontVariant",l:!0,inh:!0,k:["normal","small-caps"],d:"normal"},{n:"lineHeight",l:!0,syntax:wi.LENGTH,int:!0,d:"0"},{n:"letterSpacing",l:!0,syntax:wi.LENGTH,int:!0,d:"0"},{n:"miterLimit",l:!0,syntax:wi.NUMBER,d:function(t){return t===er.PATH||t===er.POLYGON||t===er.POLYLINE?"4":"10"}},{n:"wordWrap",l:!0},{n:"wordWrapWidth",l:!0},{n:"maxLines",l:!0},{n:"textOverflow",l:!0,d:"clip"},{n:"leading",l:!0},{n:"textBaseline",l:!0,inh:!0,k:["top","hanging","middle","alphabetic","ideographic","bottom"],d:"alphabetic"},{n:"textAlign",l:!0,inh:!0,k:["start","center","middle","end","left","right"],d:"start"},{n:"markerStart",syntax:wi.MARKER},{n:"markerEnd",syntax:wi.MARKER},{n:"markerMid",syntax:wi.MARKER},{n:"markerStartOffset",syntax:wi.LENGTH,l:!0,int:!0,d:"0"},{n:"markerEndOffset",syntax:wi.LENGTH,l:!0,int:!0,d:"0"}],Fo=zo.filter((function(t){return!!t.l})).map((function(t){return t.n})),Go={},Vo=new WeakMap,Wo=function(){function t(t){var e=this;this.runtime=t,zo.forEach((function(t){e.registerMetadata(t)}))}return t.prototype.registerMetadata=function(t){l([t.n],c(t.a||[]),!1).forEach((function(e){Go[e]=t}))},t.prototype.unregisterMetadata=function(t){delete Go[t]},t.prototype.getPropertySyntax=function(t){return this.runtime.CSSPropertySyntaxFactory[t]},t.prototype.processProperties=function(t,e,n){var r=this;if(void 0===n&&(n={skipUpdateAttribute:!1,skipParse:!1,forceUpdateGeometry:!1,usedAttributes:[],memoize:!0}),this.runtime.enableCSSParsing){var o=n.skipUpdateAttribute,a=n.skipParse,s=n.forceUpdateGeometry,u=n.usedAttributes,c=n.memoize,l=s,h=Object.keys(e);h.forEach((function(n){var r;o||(t.attributes[n]=e[n]),!l&&(null===(r=Go[n])||void 0===r?void 0:r.l)&&(l=!0)})),a||h.forEach((function(e){t.computedStyle[e]=r.parseProperty(e,t.attributes[e],t,c)})),(null==u?void 0:u.length)&&(h=Array.from(new Set(h.concat(u)))),h.forEach((function(e){e in t.computedStyle&&(t.parsedStyle[e]=r.computeProperty(e,t.computedStyle[e],t,c))})),l&&(t.geometry.dirty=!0,t.renderable.boundsDirty=!0,t.renderable.renderBoundsDirty=!0,n.forceUpdateGeometry||this.runtime.sceneGraphService.dirtifyToRoot(t)),h.forEach((function(e){e in t.parsedStyle&&r.postProcessProperty(e,t,h)})),this.runtime.enableCSSParsing&&t.children.length&&h.forEach((function(e){e in t.parsedStyle&&r.isPropertyInheritable(e)&&t.children.forEach((function(t){t.internalSetAttribute(e,null,{skipUpdateAttribute:!0,skipParse:!0})}))}))}else{Object.assign(t.attributes,e);var d=Object.keys(e),f=t.parsedStyle.clipPath,p=t.parsedStyle.offsetPath;t.parsedStyle=Object.assign(t.parsedStyle,e);var g=!!n.forceUpdateGeometry;if(!g)for(var m=0;m<Fo.length;m++)if(Fo[m]in e){g=!0;break}e.fill&&(t.parsedStyle.fill=Di(e.fill)),e.stroke&&(t.parsedStyle.stroke=Di(e.stroke)),e.shadowColor&&(t.parsedStyle.shadowColor=Di(e.shadowColor)),e.filter&&(t.parsedStyle.filter=Xi(e.filter)),_t(e.radius)||(t.parsedStyle.radius=$i(e.radius,4)),_t(e.lineDash)||(t.parsedStyle.lineDash=$i(e.lineDash,2)),e.points&&(t.parsedStyle.points=bo(e.points)),""===e.d&&(t.parsedStyle.d=i({},Ei)),e.d&&(t.parsedStyle.d=yo(e.d)),e.textTransform&&this.runtime.CSSPropertySyntaxFactory["<text-transform>"].calculator(null,null,{value:e.textTransform},t,null),ie(e.clipPath)||this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("clipPath",f,e.clipPath,t,this.runtime),e.offsetPath&&this.runtime.CSSPropertySyntaxFactory["<defined-path>"].calculator("offsetPath",p,e.offsetPath,t,this.runtime),e.transform&&(t.parsedStyle.transform=No(e.transform)),e.transformOrigin&&(t.parsedStyle.transformOrigin=Lo(e.transformOrigin)),e.markerStart&&(t.parsedStyle.markerStart=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerStart,e.markerStart,null,null)),e.markerEnd&&(t.parsedStyle.markerEnd=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator(null,e.markerEnd,e.markerEnd,null,null)),e.markerMid&&(t.parsedStyle.markerMid=this.runtime.CSSPropertySyntaxFactory["<marker>"].calculator("",e.markerMid,e.markerMid,null,null)),_t(e.zIndex)||this.runtime.CSSPropertySyntaxFactory["<z-index>"].postProcessor(t,d),_t(e.offsetDistance)||this.runtime.CSSPropertySyntaxFactory["<offset-distance>"].postProcessor(t,d),e.transform&&this.runtime.CSSPropertySyntaxFactory["<transform>"].postProcessor(t,d),e.transformOrigin&&this.runtime.CSSPropertySyntaxFactory["<transform-origin>"].postProcessor(t,d),g&&(t.geometry.dirty=!0,t.renderable.boundsDirty=!0,t.renderable.renderBoundsDirty=!0,n.forceUpdateGeometry||this.runtime.sceneGraphService.dirtifyToRoot(t))}},t.prototype.parseProperty=function(t,e,n,r){var i=Go[t],o=e;if((""===e||_t(e))&&(e="unset"),"unset"===e||"initial"===e||"inherit"===e)o=mi(e);else if(i){var a=i.k,s=i.syntax,u=s&&this.getPropertySyntax(s);a&&a.indexOf(e)>-1?o=mi(e):u&&(!r&&u.parserUnmemoize?o=u.parserUnmemoize(e,n):u.parser&&(o=u.parser(e,n)))}return o},t.prototype.computeProperty=function(t,e,n,r){var i=Go[t],o="g-root"===n.id,a=e;if(i){var s=i.syntax,u=i.inh,c=i.d;if(e instanceof Qr){var l=e.value;if("unset"===l&&(l=u&&!o?"inherit":"initial"),"initial"===l)_t(c)||(e=this.parseProperty(t,ei(c)?c(n.nodeName):c,n,r));else if("inherit"===l){var h=this.tryToResolveProperty(n,t,{inherited:!0});return _t(h)?void this.addUnresolveProperty(n,t):h}}var d=s&&this.getPropertySyntax(s);if(d&&d.calculator){var f=n.parsedStyle[t];a=d.calculator(t,f,e,n,this.runtime)}else a=e instanceof Qr?e.value:e}return a},t.prototype.postProcessProperty=function(t,e,n){var r=Go[t];if(r&&r.syntax){var i=r.syntax&&this.getPropertySyntax(r.syntax);i&&i.postProcessor&&i.postProcessor(e,n)}},t.prototype.addUnresolveProperty=function(t,e){var n=Vo.get(t);n||(Vo.set(t,[]),n=Vo.get(t)),-1===n.indexOf(e)&&n.push(e)},t.prototype.tryToResolveProperty=function(t,e,n){if(void 0===n&&(n={}),n.inherited&&t.parentElement&&function(t,e){var n=Vo.get(t);return!n||0===n.length||n.includes(e)}(t.parentElement,e)){var r=t.parentElement.parsedStyle[e];if("unset"===r||"initial"===r||"inherit"===r)return;return r}},t.prototype.recalc=function(t){var e=Vo.get(t);if(e&&e.length){var n={};e.forEach((function(e){n[e]=t.attributes[e]})),this.processProperties(t,n),Vo.delete(t)}},t.prototype.updateGeometry=function(t){var e=t.nodeName,n=this.runtime.geometryUpdaterFactory[e];if(n){var r=t.geometry;r.contentBounds||(r.contentBounds=new Sr),r.renderBounds||(r.renderBounds=new Sr);var i=t.parsedStyle,o=n.update(i,t),a=o.cx,s=void 0===a?0:a,u=o.cy,c=void 0===u?0:u,l=o.cz,h=void 0===l?0:l,d=o.hwidth,f=void 0===d?0:d,p=o.hheight,g=void 0===p?0:p,m=o.hdepth,y=void 0===m?0:m,v=[Math.abs(f),Math.abs(g),y],b=i,x=b.stroke,w=b.lineWidth,E=void 0===w?1:w,M=b.increasedLineWidthForHitTesting,S=void 0===M?0:M,N=b.shadowType,k=void 0===N?"outer":N,C=b.shadowColor,T=b.filter,A=void 0===T?[]:T,P=b.transformOrigin,O=[s,c,h];r.contentBounds.update(O,v);var _=e===er.POLYLINE||e===er.POLYGON||e===er.PATH?Math.SQRT2:.5;if(x&&!x.isNone){var R=((E||0)+(S||0))*_;v[0]+=R,v[1]+=R}if(r.renderBounds.update(O,v),C&&k&&"inner"!==k){var I=r.renderBounds,D=I.min,L=I.max,j=i,B=j.shadowBlur||0,z=j.shadowOffsetX||0,F=j.shadowOffsetY||0,G=D[0]-B+z,V=L[0]+B+z,W=D[1]-B+F,H=L[1]+B+F;D[0]=Math.min(D[0],G),L[0]=Math.max(L[0],V),D[1]=Math.min(D[1],W),L[1]=Math.max(L[1],H),r.renderBounds.setMinMax(D,L)}A.forEach((function(t){var e=t.name,n=t.params;if("blur"===e){var i=n[0].value;r.renderBounds.update(r.renderBounds.center,ur(r.renderBounds.halfExtents,r.renderBounds.halfExtents,[i,i,0]))}else if("drop-shadow"===e){var o=n[0].value,a=n[1].value,s=n[2].value,u=r.renderBounds,c=u.min,l=u.max,h=c[0]-s+o,d=l[0]+s+o,f=c[1]-s+a,p=l[1]+s+a;c[0]=Math.min(c[0],h),l[0]=Math.max(l[0],d),c[1]=Math.min(c[1],f),l[1]=Math.max(l[1],p),r.renderBounds.setMinMax(c,l)}})),t.geometry.dirty=!1;var U=g<0,$=(f<0?-1:1)*(P?Yi(P[0],0,t,!0):0),q=(U?-1:1)*(P?Yi(P[1],1,t,!0):0);($||q)&&t.setOrigin($,q)}},t.prototype.updateSizeAttenuation=function(t,e){t.style.isSizeAttenuation?(t.style.rawLineWidth||(t.style.rawLineWidth=t.style.lineWidth),t.style.lineWidth=(t.style.rawLineWidth||1)/e,t.nodeName===er.CIRCLE&&(t.style.rawR||(t.style.rawR=t.style.r),t.style.r=(t.style.rawR||1)/e)):(t.style.rawLineWidth&&(t.style.lineWidth=t.style.rawLineWidth,delete t.style.rawLineWidth),t.nodeName===er.CIRCLE&&t.style.rawR&&(t.style.r=t.style.rawR,delete t.style.rawR))},t.prototype.isPropertyInheritable=function(t){var e=Go[t];return!!e&&e.inh},t}(),Ho=function(){function t(){this.parser=Wi,this.parserUnmemoize=Vi,this.parserWithCSSDisabled=null,this.mixer=to}return t.prototype.calculator=function(t,e,n,r){return Ui(n)},t}(),Uo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r,i){return n instanceof Qr&&(n=null),i.sceneGraphService.updateDisplayObjectDependency(t,e,n,r),"clipPath"===t&&r.forEach((function(t){0===t.childNodes.length&&i.sceneGraphService.dirtifyToRoot(t)})),n},t}(),$o=function(){function t(){this.parser=Di,this.parserWithCSSDisabled=Di,this.mixer=Li}return t.prototype.calculator=function(t,e,n,r){return n instanceof Qr?"none"===n.value?yi:vi:n},t}(),qo=function(){function t(){this.parser=Xi}return t.prototype.calculator=function(t,e,n){return n instanceof Qr?[]:n},t}();function Yo(t){var e=t.parsedStyle.fontSize;return _t(e)?null:e}var Ko=function(){function t(){this.parser=Gi,this.parserUnmemoize=Fi,this.parserWithCSSDisabled=null,this.mixer=to}return t.prototype.calculator=function(t,e,n,r,i){var o;if($t(n))return n;if(!ai.isRelativeUnit(n.unit))return n.value;var a=i.styleValueRegistry;if(n.unit===Ir.kPercentage)return 0;if(n.unit===Ir.kEms){if(r.parentNode){if(s=Yo(r.parentNode))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}if(n.unit===Ir.kRems){if(null===(o=null==r?void 0:r.ownerDocument)||void 0===o?void 0:o.documentElement){var s;if(s=Yo(r.ownerDocument.documentElement))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}},t}(),Xo=function(){function t(){this.mixer=no}return t.prototype.parser=function(t){var e=qi($t(t)?[t]:t);return 1===e.length?[e[0],e[0]]:[e[0],e[1]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),Zo=function(){function t(){this.mixer=no}return t.prototype.parser=function(t){var e=qi($t(t)?[t]:t);return 1===e.length?[e[0],e[0],e[0],e[0]]:2===e.length?[e[0],e[1],e[0],e[1]]:3===e.length?[e[0],e[1],e[2],e[1]]:[e[0],e[1],e[2],e[3]]},t.prototype.calculator=function(t,e,n){return n.map((function(t){return t.value}))},t}(),Qo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){n instanceof Qr&&(n=null);var i=null==n?void 0:n.cloneNode(!0);return i&&(i.style.isMarker=!0),i},t}(),Jo=function(){function t(){this.mixer=to,this.parser=Ji,this.parserUnmemoize=Qi,this.parserWithCSSDisabled=null}return t.prototype.calculator=function(t,e,n){return n.value},t}(),ta=function(){function t(){this.parser=Ji,this.parserUnmemoize=Qi,this.parserWithCSSDisabled=null,this.mixer=eo(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t.prototype.postProcessor=function(t){var e=t.parsedStyle,n=e.offsetPath,r=e.offsetDistance;if(n){var i=n.nodeName;if(i===er.LINE||i===er.PATH||i===er.POLYLINE){var o=n.getPoint(r);o&&t.setLocalPosition(o.x,o.y)}}},t}(),ea=function(){function t(){this.parser=Ji,this.parserUnmemoize=Qi,this.parserWithCSSDisabled=null,this.mixer=eo(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t}(),na=function(){function t(){this.parser=yo,this.parserWithCSSDisabled=yo,this.mixer=vo}return t.prototype.calculator=function(t,e,n){return n instanceof Qr&&"unset"===n.value?{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Or(0,0,0,0)}:n},t}(),ra=function(){this.parser=bo,this.mixer=xo},ia=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.mixer=eo(0,1/0),e}return r(e,t),e}(Ko),oa=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){return n instanceof Qr?"unset"===n.value?"":n.value:"".concat(n)},t.prototype.postProcessor=function(t){t.nodeValue="".concat(t.parsedStyle.text)||""},t}(),aa=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){var i=r.getAttribute("text");if(i){var o=i;"capitalize"===n.value?o=i.charAt(0).toUpperCase()+i.slice(1):"lowercase"===n.value?o=i.toLowerCase():"uppercase"===n.value&&(o=i.toUpperCase()),r.parsedStyle.text=o}return n.value},t}(),sa={},ua=0;var ca="undefined"!=typeof window&&void 0!==window.document;function la(t){return!!t.getAttribute}function ha(t,e){var n=Number(t.parsedStyle.zIndex||0),r=Number(e.parsedStyle.zIndex||0);if(n===r){var i=t.parentNode;if(i){var o=i.childNodes||[];return o.indexOf(t)-o.indexOf(e)}}return n-r}function da(t){var e,n=t;do{if(null===(e=n.parsedStyle)||void 0===e?void 0:e.clipPath)return n;n=n.parentElement}while(null!==n);return null}function fa(t,e){if(ca)return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}var pa={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ga="object"==typeof performance&&performance.now?performance:Date;function ma(t,e,n){void 0===t&&(t="auto");var r=!1,i=!1,o=!!e&&!e.isNone,a=!!n&&!n.isNone;return"visiblepainted"===t||"painted"===t||"auto"===t?(r=o,i=a):"visiblefill"===t||"fill"===t?r=!0:"visiblestroke"===t||"stroke"===t?i=!0:"visible"!==t&&"all"!==t||(r=!0,i=!0),[r,i]}var ya=1,va="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},ba=Date.now(),xa={},wa=Date.now(),Ea=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=Date.now(),n=e-wa,r=n>16?0:16-n,i=ya++;return xa[i]=t,Object.keys(xa).length>1||setTimeout((function(){wa=e;var t=xa;xa={},Object.keys(t).forEach((function(e){return t[e](va.performance&&"function"==typeof va.performance.now?va.performance.now():Date.now()-ba)}))}),r),i},Ma=function(t){delete xa[t]},Sa=function(t){return"string"!=typeof t?Ea:""===t?va.requestAnimationFrame:va[t+"RequestAnimationFrame"]},Na=function(t,e){for(var n=0;void 0!==t[n];){if(e(t[n]))return t[n];n+=1}}(["","webkit","moz","ms","o"],(function(t){return!!Sa(t)})),ka=Sa(Na),Ca=function(t){return"string"!=typeof t?Ma:""===t?va.cancelAnimationFrame:va[t+"CancelAnimationFrame"]||va[t+"CancelRequestAnimationFrame"]}(Na);va.requestAnimationFrame=ka,va.cancelAnimationFrame=Ca;var Ta=function(){function t(){this.callbacks=[]}return t.prototype.getCallbacksNum=function(){return this.callbacks.length},t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Promise.all(this.callbacks.map((function(e){return e.apply(void 0,l([],c(t),!1))})))},t}(),Aa=function(){function t(){this.callbacks=[]}return t.prototype.tapPromise=function(t,e){this.callbacks.push(e)},t.prototype.promise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a(this,void 0,void 0,(function(){var e,n,r;return s(this,(function(i){switch(i.label){case 0:return this.callbacks.length?[4,(r=this.callbacks)[0].apply(r,l([],c(t),!1))]:[3,6];case 1:e=i.sent(),n=0,i.label=2;case 2:return n<this.callbacks.length-1?[4,(0,this.callbacks[n])(e)]:[3,5];case 3:e=i.sent(),i.label=4;case 4:return n++,[3,2];case 5:return[2,e];case 6:return[2,null]}}))}))},t}(),Pa=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){var t=arguments;this.callbacks.forEach((function(e){e.apply(void 0,t)}))},t}(),Oa=function(){function t(){this.callbacks=[]}return t.prototype.tap=function(t,e){this.callbacks.push(e)},t.prototype.call=function(){if(this.callbacks.length){for(var t=arguments,e=this.callbacks[0].apply(void 0,t),n=0;n<this.callbacks.length-1;n++){e=(0,this.callbacks[n])(e)}return e}return null},t}(),_a=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Ra=/([\"\'])[^\'\"]+\1/;function Ia(t,e,n){return S(t),t[4]=Math.tan(e),t[1]=Math.tan(n),t}var Da=1e-5,La=x(),ja=x();function Ba(t,e){if(t.length){var n=S(La);t.forEach((function(t){var e=t.t,r=t.d;if("scale"===e){var i=(null==r?void 0:r.map((function(t){return Math.max(t.value,Da)})))||[1,1];I(ja,[i[0],i[1],1])}else if("scalex"===e){i=(null==r?void 0:r.map((function(t){return Math.max(t.value,Da)})))||[1];I(ja,[i[0],1,1])}else if("scaley"===e){i=(null==r?void 0:r.map((function(t){return Math.max(t.value,Da)})))||[1];I(ja,[1,i[0],1])}else if("scalez"===e){i=(null==r?void 0:r.map((function(t){return Math.max(t.value,Da)})))||[1];I(ja,[1,1,i[0]])}else if("scale3d"===e){i=(null==r?void 0:r.map((function(t){return Math.max(t.value,Da)})))||[1,1,1];I(ja,[i[0],i[1],i[2]])}else if("translate"===e){R(ja,[(o=r||[si,si])[0].value,o[1].value,0])}else if("translatex"===e){R(ja,[(o=r||[si])[0].value,0,0])}else if("translatey"===e){R(ja,[0,(o=r||[si])[0].value,0])}else if("translatez"===e){R(ja,[0,0,(o=r||[si])[0].value])}else if("translate3d"===e){var o;R(ja,[(o=r||[si,si,si])[0].value,o[1].value,o[2].value])}else if("rotate"===e){B(ja,dr(Ui((a=r||[li])[0])))}else if("rotatex"===e){L(ja,dr(Ui((a=r||[li])[0])))}else if("rotatey"===e){j(ja,dr(Ui((a=r||[li])[0])))}else if("rotatez"===e){B(ja,dr(Ui((a=r||[li])[0])))}else if("rotate3d"===e){var a;D(ja,dr(Ui((a=r||[si,si,si,li])[3])),[a[0].value,a[1].value,a[2].value])}else if("skew"===e){var s=(null==r?void 0:r.map((function(t){return t.value})))||[0,0];Ia(ja,dr(s[0]),dr(s[1]))}else if("skewx"===e){s=(null==r?void 0:r.map((function(t){return t.value})))||[0];Ia(ja,dr(s[0]),0)}else if("skewy"===e){s=(null==r?void 0:r.map((function(t){return t.value})))||[0];Ia(ja,0,dr(s[0]))}else if("matrix"===e){var u=c(r.map((function(t){return t.value})),6),h=u[0],d=u[1],f=u[2],p=u[3],g=u[4],m=u[5];M(ja,h,d,0,0,f,p,0,0,0,0,1,0,g,m,0,1)}else"matrix3d"===e&&M.apply(tt,l([ja],c(r.map((function(t){return t.value}))),!1));Q(n,n,ja)})),e.setLocalTransform(n)}else e.resetLocalTransform();return e.getLocalTransform()}var za=function(){function t(){this.parser=No,this.parserUnmemoize=ko,this.parserWithCSSDisabled=ko,this.mixer=Do}return t.prototype.calculator=function(t,e,n,r){return n instanceof Qr?[]:n},t.prototype.postProcessor=function(t){Ba(t.parsedStyle.transform,t)},t}(),Fa=function(){function t(){this.parser=Lo,this.parserUnmemoize=jo}return t.prototype.postProcessor=function(t){var e=t.parsedStyle.transformOrigin;e[0].unit===Ir.kPixels&&e[1].unit===Ir.kPixels?t.setOrigin(e[0].value,e[1].value):t.getGeometryBounds()},t}(),Ga=function(){function t(){this.parser=Ji,this.parserUnmemoize=Qi}return t.prototype.calculator=function(t,e,n,r){return n.value},t.prototype.postProcessor=function(t){if(t.parentNode){var e=t.parentNode,n=e.renderable,r=e.sortable;n&&(n.dirty=!0),r&&(r.dirty=!0,r.dirtyReason=ci.Z_INDEX_CHANGED)}},t}(),Va=function(){function t(){}return t.prototype.update=function(t,e){var n=t.cx,r=void 0===n?0:n,i=t.cy,o=void 0===i?0:i,a=t.r,s=void 0===a?0:a;return{cx:r,cy:o,hwidth:s,hheight:s}},t}(),Wa=function(){function t(){}return t.prototype.update=function(t,e){var n=t.cx,r=void 0===n?0:n,i=t.cy,o=void 0===i?0:i,a=t.rx,s=void 0===a?0:a,u=t.ry;return{cx:r,cy:o,hwidth:s,hheight:void 0===u?0:u}},t}(),Ha=function(){function t(){}return t.prototype.update=function(t){var e=t.x1,n=t.y1,r=t.x2,i=t.y2,o=Math.min(e,r),a=Math.max(e,r),s=Math.min(n,i),u=(a-o)/2,c=(Math.max(n,i)-s)/2;return{cx:o+u,cy:s+c,hwidth:u,hheight:c}},t}(),Ua=function(){function t(){}return t.prototype.update=function(t){var e=t.d.rect,n=e.x,r=e.y,i=e.width/2,o=e.height/2;return{cx:n+i,cy:r+o,hwidth:i,hheight:o}},t}(),$a=function(){function t(){}return t.prototype.update=function(t){if(t.points&&Dt(t.points.points)){var e=t.points.points,n=Math.min.apply(Math,l([],c(e.map((function(t){return t[0]}))),!1)),r=Math.max.apply(Math,l([],c(e.map((function(t){return t[0]}))),!1)),i=Math.min.apply(Math,l([],c(e.map((function(t){return t[1]}))),!1)),o=Math.max.apply(Math,l([],c(e.map((function(t){return t[1]}))),!1)),a=(r-n)/2,s=(o-i)/2;return{cx:n+a,cy:i+s,hwidth:a,hheight:s}}return{cx:0,cy:0,hwidth:0,hheight:0}},t}(),qa=function(){function t(){}return t.prototype.update=function(t,e){var n=t.x,r=void 0===n?0:n,i=t.y,o=void 0===i?0:i,a=t.src,s=t.width,u=void 0===s?0:s,c=t.height,l=u,h=void 0===c?0:c;return a&&!Vt(a)&&(l||(l=a.width,t.width=l),h||(h=a.height,t.height=h)),{cx:r+l/2,cy:o+h/2,hwidth:l/2,hheight:h/2}},t}(),Ya=function(){function t(t){this.globalRuntime=t}return t.prototype.isReadyToMeasure=function(t,e){var n=t.text,r=t.textAlign,i=t.textBaseline,o=t.fontSize,a=t.fontStyle,s=t.fontWeight,u=t.fontVariant,c=t.lineWidth;return Es.enableCSSParsing?n&&o&&a&&s&&u&&r&&i&&!_t(c):n},t.prototype.update=function(t,e){var n,r,i=t.text,o=t.textAlign,a=void 0===o?"start":o,s=t.lineWidth,u=void 0===s?1:s,c=t.textBaseline,l=void 0===c?"alphabetic":c,h=t.dx,d=void 0===h?0:h,f=t.dy,p=void 0===f?0:f,g=t.x,m=void 0===g?0:g,y=t.y,v=void 0===y?0:y;if(!this.isReadyToMeasure(t,e))return t.metrics={font:"",width:0,height:0,lines:[],lineWidths:[],lineHeight:0,maxLineWidth:0,fontProperties:{ascent:0,descent:0,fontSize:0},lineMetrics:[]},{hwidth:0,hheight:0,cx:0,cy:0};var b=((null===(r=null===(n=null==e?void 0:e.ownerDocument)||void 0===n?void 0:n.defaultView)||void 0===r?void 0:r.getConfig())||{}).offscreenCanvas,x=this.globalRuntime.textService.measureText(i,t,b);t.metrics=x;var w=x.width,E=x.height,M=x.lineHeight,S=x.fontProperties,N=w/2,k=E/2,C=m+N;"center"===a||"middle"===a?C+=u/2-N:"right"!==a&&"end"!==a||(C+=u-2*N);var T=v-k;return"middle"===l?T+=k:"top"===l||"hanging"===l?T+=2*k:"alphabetic"===l?T+=this.globalRuntime.enableCSSParsing?M-S.ascent:0:"bottom"!==l&&"ideographic"!==l||(T+=0),d&&(C+=d),p&&(T+=p),{cx:C,cy:T,hwidth:N,hheight:k}},t}(),Ka=function(){function t(){}return t.prototype.update=function(t,e){return{cx:0,cy:0,hwidth:0,hheight:0}},t}();var Xa,Za=function(){function t(e){this.eventPhase=t.prototype.NONE,this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.defaultPrevented=!1,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Pr,this.page=new Pr,this.canvas=new Pr,this.viewport=new Pr,this.composed=!1,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this.type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerX",{get:function(){return this.layer.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerY",{get:function(){return this.layer.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageX",{get:function(){return this.page.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageY",{get:function(){return this.page.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasX",{get:function(){return this.canvas.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasY",{get:function(){return this.canvas.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportX",{get:function(){return this.viewport.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewportY",{get:function(){return this.viewport.y},enumerable:!1,configurable:!0}),t.prototype.composedPath=function(){return!this.manager||this.path&&this.path[0]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path},Object.defineProperty(t.prototype,"propagationPath",{get:function(){return this.composedPath()},enumerable:!1,configurable:!0}),t.prototype.preventDefault=function(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0},t.prototype.stopImmediatePropagation=function(){this.propagationImmediatelyStopped=!0},t.prototype.stopPropagation=function(){this.propagationStopped=!0},t.prototype.initEvent=function(){},t.prototype.initUIEvent=function(){},t.prototype.clone=function(){throw new Error(_r)},t}(),Qa=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.client=new Pr,e.movement=new Pr,e.offset=new Pr,e.global=new Pr,e.screen=new Pr,e}return r(e,t),Object.defineProperty(e.prototype,"clientX",{get:function(){return this.client.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clientY",{get:function(){return this.client.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementX",{get:function(){return this.movement.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"movementY",{get:function(){return this.movement.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetX",{get:function(){return this.offset.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"offsetY",{get:function(){return this.offset.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalX",{get:function(){return this.global.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalY",{get:function(){return this.global.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenX",{get:function(){return this.screen.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenY",{get:function(){return this.screen.y},enumerable:!1,configurable:!0}),e.prototype.getModifierState=function(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)},e.prototype.initMouseEvent=function(){throw new Error(_r)},e}(Za),Ja=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.width=0,e.height=0,e.isPrimary=!1,e}return r(e,t),e.prototype.getCoalescedEvents=function(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]},e.prototype.getPredictedEvents=function(){throw new Error("getPredictedEvents is not supported!")},e.prototype.clone=function(){return this.manager.clonePointerEvent(this)},e}(Qa),ts=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.clone=function(){return this.manager.cloneWheelEvent(this)},e}(Qa),es=function(t){function e(e,n){var r=t.call(this,null)||this;return r.type=e,r.detail=n,Object.assign(r,n),r}return r(e,t),e}(Za),ns=function(){function t(){this.emitter=new m}return t.prototype.on=function(t,e,n){return this.addEventListener(t,e,n),this},t.prototype.addEventListener=function(t,e,n){var r=ne(n)&&n||Lt(n)&&n.capture,i=Lt(n)&&n.once,o=ei(e)?void 0:e,a=!1,s="";if(t.indexOf(":")>-1){var u=c(t.split(":"),2),h=u[0];t=u[1],s=h,a=!0}if(t=r?"".concat(t,"capture"):t,e=ei(e)?e:e.handleEvent,a){var d=e;e=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];(null===(t=e[0].target)||void 0===t?void 0:t.name)===s&&d.apply(void 0,l([],c(e),!1))}}return i?this.emitter.once(t,e,o):this.emitter.on(t,e,o),this},t.prototype.off=function(t,e,n){return t?this.removeEventListener(t,e,n):this.removeAllEventListeners(),this},t.prototype.removeAllEventListeners=function(){this.emitter.removeAllListeners()},t.prototype.removeEventListener=function(t,e,n){var r=ne(n)&&n||Lt(n)&&n.capture,i=ei(e)?void 0:e;return t=r?"".concat(t,"capture"):t,e=ei(e)?e:null==e?void 0:e.handleEvent,this.emitter.off(t,e,i),this},t.prototype.emit=function(t,e){this.dispatchEvent(new es(t,e))},t.prototype.dispatchEvent=function(t,e){var n,r,i;if(void 0===e&&(e=!1),!t.type)throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");if(i=this.document?this:this.defaultView?this.defaultView:null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView){if(t.manager=i.getEventService()||null,!t.manager)return!1;t.defaultPrevented=!1,t.path=[],e||(t.target=this),null===(r=t.manager)||void 0===r||r.dispatchEvent(t,t.type,e)}return!t.defaultPrevented},t}(),rs=function(t){function e(){var e=t.call(this)||this;return e.shadow=!1,e.ownerDocument=null,e.isConnected=!1,e.baseURI="",e.childNodes=[],e.nodeType=0,e.nodeName="",e.nodeValue=null,e.parentNode=null,e}return r(e,t),e.isNode=function(t){return!!t.childNodes},Object.defineProperty(e.prototype,"textContent",{get:function(){var t,e,n="";this.nodeName===er.TEXT&&(n+=this.style.text);try{for(var r=u(this.childNodes),i=r.next();!i.done;i=r.next()){var o=i.value;o.nodeName===er.TEXT?n+=o.nodeValue:n+=o.textContent}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return n},set:function(t){var e=this;this.childNodes.slice().forEach((function(t){e.removeChild(t)})),this.nodeName===er.TEXT&&(this.style.text="".concat(t))},enumerable:!1,configurable:!0}),e.prototype.getRootNode=function(t){return void 0===t&&(t={}),this.parentNode?this.parentNode.getRootNode(t):t.composed&&this.host?this.host.getRootNode(t):this},e.prototype.hasChildNodes=function(){return this.childNodes.length>0},e.prototype.isDefaultNamespace=function(t){throw new Error(_r)},e.prototype.lookupNamespaceURI=function(t){throw new Error(_r)},e.prototype.lookupPrefix=function(t){throw new Error(_r)},e.prototype.normalize=function(){throw new Error(_r)},e.prototype.isEqualNode=function(t){return this===t},e.prototype.isSameNode=function(t){return this.isEqualNode(t)},Object.defineProperty(e.prototype,"parent",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstChild",{get:function(){return this.childNodes.length>0?this.childNodes[0]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null},enumerable:!1,configurable:!0}),e.prototype.compareDocumentPosition=function(t){var n;if(t===this)return 0;for(var r=t,i=this,o=[r],a=[i];null!==(n=r.parentNode)&&void 0!==n?n:i.parentNode;)r=r.parentNode?(o.push(r.parentNode),r.parentNode):r,i=i.parentNode?(a.push(i.parentNode),i.parentNode):i;if(r!==i)return e.DOCUMENT_POSITION_DISCONNECTED|e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|e.DOCUMENT_POSITION_PRECEDING;var s=o.length>a.length?o:a,u=s===o?a:o;if(s[s.length-u.length]===u[0])return s===o?e.DOCUMENT_POSITION_CONTAINED_BY|e.DOCUMENT_POSITION_FOLLOWING:e.DOCUMENT_POSITION_CONTAINS|e.DOCUMENT_POSITION_PRECEDING;for(var c=s.length-u.length,l=u.length-1;l>=0;l--){var h=u[l],d=s[c+l];if(d!==h){var f=h.parentNode.childNodes;return f.indexOf(h)<f.indexOf(d)?u===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING:s===o?e.DOCUMENT_POSITION_PRECEDING:e.DOCUMENT_POSITION_FOLLOWING}}return e.DOCUMENT_POSITION_FOLLOWING},e.prototype.contain=function(t){return this.contains(t)},e.prototype.contains=function(t){for(var e=t;e&&this!==e;)e=e.parentNode;return!!e},e.prototype.getAncestor=function(t){for(var e=this;t>0&&e;)e=e.parentNode,t--;return e},e.prototype.forEach=function(t,e){void 0===e&&(e=!1),t(this)||(e?this.childNodes.slice():this.childNodes).forEach((function(e){e.forEach(t)}))},e.DOCUMENT_POSITION_DISCONNECTED=1,e.DOCUMENT_POSITION_PRECEDING=2,e.DOCUMENT_POSITION_FOLLOWING=4,e.DOCUMENT_POSITION_CONTAINS=8,e.DOCUMENT_POSITION_CONTAINED_BY=16,e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,e}(ns),is=function(){function t(t,e){var n=this;this.globalRuntime=t,this.context=e,this.emitter=new m,this.nativeHTMLMap=new WeakMap,this.cursor="default",this.mappingTable={},this.mappingState={trackingData:{}},this.eventPool=new Map,this.tmpMatrix=x(),this.tmpVec3=et(),this.onPointerDown=function(t){var e=n.createPointerEvent(t);if(n.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)n.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){var r=2===e.button;n.dispatchEvent(e,r?"rightdown":"mousedown")}n.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),n.freeEvent(e)},this.onPointerUp=function(t){var e,r=ga.now(),i=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);if(n.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)n.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){var o=2===i.button;n.dispatchEvent(i,o?"rightup":"mouseup")}var a=n.trackingData(t.pointerId),s=n.findMountedTarget(a.pressTargetsByButton[t.button]),u=s;if(s&&!i.composedPath().includes(s)){for(var c=s;c&&!i.composedPath().includes(c);){if(i.currentTarget=c,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)n.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){o=2===i.button;n.notifyTarget(i,o?"rightupoutside":"mouseupoutside")}rs.isNode(c)&&(c=c.parentNode)}delete a.pressTargetsByButton[t.button],u=c}if(u){var l=n.clonePointerEvent(i,"click");l.target=u,l.path=[],a.clicksByButton[t.button]||(a.clicksByButton[t.button]={clickCount:0,target:l.target,timeStamp:r});var h=a.clicksByButton[t.button];h.target===l.target&&r-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=l.target,h.timeStamp=r,l.detail=h.clickCount,(null===(e=i.detail)||void 0===e?void 0:e.preventClick)||(n.context.config.useNativeClickEvent||"mouse"!==l.pointerType&&"touch"!==l.pointerType||n.dispatchEvent(l,"click"),n.dispatchEvent(l,"pointertap")),n.freeEvent(l)}n.freeEvent(i)},this.onPointerMove=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0),r="mouse"===e.pointerType||"pen"===e.pointerType,i=n.trackingData(t.pointerId),o=n.findMountedTarget(i.overTargets);if(i.overTargets&&o!==e.target){var a="mousemove"===t.type?"mouseout":"pointerout",s=n.createPointerEvent(t,a,o||void 0);if(n.dispatchEvent(s,"pointerout"),r&&n.dispatchEvent(s,"mouseout"),!e.composedPath().includes(o)){var u=n.createPointerEvent(t,"pointerleave",o||void 0);for(u.eventPhase=u.AT_TARGET;u.target&&!e.composedPath().includes(u.target);)u.currentTarget=u.target,n.notifyTarget(u),r&&n.notifyTarget(u,"mouseleave"),rs.isNode(u.target)&&(u.target=u.target.parentNode);n.freeEvent(u)}n.freeEvent(s)}if(o!==e.target){var c="mousemove"===t.type?"mouseover":"pointerover",l=n.clonePointerEvent(e,c);n.dispatchEvent(l,"pointerover"),r&&n.dispatchEvent(l,"mouseover");for(var h=o&&rs.isNode(o)&&o.parentNode;h&&h!==(rs.isNode(n.rootTarget)&&n.rootTarget.parentNode)&&h!==e.target;)h=h.parentNode;if(!h||h===(rs.isNode(n.rootTarget)&&n.rootTarget.parentNode)){var d=n.clonePointerEvent(e,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==o&&d.target!==(rs.isNode(n.rootTarget)&&n.rootTarget.parentNode);)d.currentTarget=d.target,n.notifyTarget(d),r&&n.notifyTarget(d,"mouseenter"),rs.isNode(d.target)&&(d.target=d.target.parentNode);n.freeEvent(d)}n.freeEvent(l)}n.dispatchEvent(e,"pointermove"),"touch"===e.pointerType&&n.dispatchEvent(e,"touchmove"),r&&(n.dispatchEvent(e,"mousemove"),n.cursor=n.getCursor(e.target)),i.overTargets=e.composedPath(),n.freeEvent(e)},this.onPointerOut=function(t){var e=n.trackingData(t.pointerId);if(e.overTargets){var r="mouse"===t.pointerType||"pen"===t.pointerType,i=n.findMountedTarget(e.overTargets),o=n.createPointerEvent(t,"pointerout",i||void 0);n.dispatchEvent(o),r&&n.dispatchEvent(o,"mouseout");var a=n.createPointerEvent(t,"pointerleave",i||void 0);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==(rs.isNode(n.rootTarget)&&n.rootTarget.parentNode);)a.currentTarget=a.target,n.notifyTarget(a),r&&n.notifyTarget(a,"mouseleave"),rs.isNode(a.target)&&(a.target=a.target.parentNode);e.overTargets=null,n.freeEvent(o),n.freeEvent(a)}n.cursor=null},this.onPointerOver=function(t){var e=n.trackingData(t.pointerId),r=n.createPointerEvent(t),i="mouse"===r.pointerType||"pen"===r.pointerType;n.dispatchEvent(r,"pointerover"),i&&n.dispatchEvent(r,"mouseover"),"mouse"===r.pointerType&&(n.cursor=n.getCursor(r.target));var o=n.clonePointerEvent(r,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==(rs.isNode(n.rootTarget)&&n.rootTarget.parentNode);)o.currentTarget=o.target,n.notifyTarget(o),i&&n.notifyTarget(o,"mouseenter"),rs.isNode(o.target)&&(o.target=o.target.parentNode);e.overTargets=r.composedPath(),n.freeEvent(r),n.freeEvent(o)},this.onPointerUpOutside=function(t){var e=n.trackingData(t.pointerId),r=n.findMountedTarget(e.pressTargetsByButton[t.button]),i=n.createPointerEvent(t);if(r){for(var o=r;o;)i.currentTarget=o,n.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType||"mouse"!==i.pointerType&&"pen"!==i.pointerType||n.notifyTarget(i,2===i.button?"rightupoutside":"mouseupoutside"),rs.isNode(o)&&(o=o.parentNode);delete e.pressTargetsByButton[t.button]}n.freeEvent(i)},this.onWheel=function(t){var e=n.createWheelEvent(t);n.dispatchEvent(e),n.freeEvent(e)},this.onClick=function(t){if(n.context.config.useNativeClickEvent){var e=n.createPointerEvent(t);n.dispatchEvent(e),n.freeEvent(e)}},this.onPointerCancel=function(t){var e=n.createPointerEvent(t,void 0,void 0,n.context.config.alwaysTriggerPointerEventOnCanvas?n.rootTarget:void 0);n.dispatchEvent(e),n.freeEvent(e)}}return t.prototype.init=function(){this.rootTarget=this.context.renderingContext.root.parentNode,this.addEventMapping("pointerdown",this.onPointerDown),this.addEventMapping("pointerup",this.onPointerUp),this.addEventMapping("pointermove",this.onPointerMove),this.addEventMapping("pointerout",this.onPointerOut),this.addEventMapping("pointerleave",this.onPointerOut),this.addEventMapping("pointercancel",this.onPointerCancel),this.addEventMapping("pointerover",this.onPointerOver),this.addEventMapping("pointerupoutside",this.onPointerUpOutside),this.addEventMapping("wheel",this.onWheel),this.addEventMapping("click",this.onClick)},t.prototype.destroy=function(){this.emitter.removeAllListeners(),this.mappingTable={},this.mappingState={},this.eventPool.clear()},t.prototype.getScale=function(){var t=this.context.contextService.getBoundingClientRect(),e=1,n=1,r=this.context.contextService.getDomElement();if(r&&t){var i=r.offsetWidth,o=r.offsetHeight;i&&o&&(e=t.width/i,n=t.height/o)}return{scaleX:e,scaleY:n,bbox:t}},t.prototype.client2Viewport=function(t){var e=this.getScale(),n=e.scaleX,r=e.scaleY,i=e.bbox;return new Pr((t.x-((null==i?void 0:i.left)||0))/n,(t.y-((null==i?void 0:i.top)||0))/r)},t.prototype.viewport2Client=function(t){var e=this.getScale(),n=e.scaleX,r=e.scaleY,i=e.bbox;return new Pr((t.x+((null==i?void 0:i.left)||0))*n,(t.y+((null==i?void 0:i.top)||0))*r)},t.prototype.viewport2Canvas=function(t){var e=t.x,n=t.y,r=this.rootTarget.defaultView.getCamera(),i=this.context.config,o=i.width,a=i.height,s=r.getPerspectiveInverse(),u=r.getWorldTransform(),c=T(this.tmpMatrix,u,s),l=at(this.tmpVec3,e/o*2-1,2*(1-n/a)-1,0);return pt(l,l,c),new Pr(l[0],l[1])},t.prototype.canvas2Viewport=function(t){var e=this.rootTarget.defaultView.getCamera(),n=e.getPerspective(),r=e.getViewTransform(),i=T(this.tmpMatrix,n,r),o=at(this.tmpVec3,t.x,t.y,0);pt(this.tmpVec3,this.tmpVec3,i);var a=this.context.config,s=a.width,u=a.height;return new Pr((o[0]+1)/2*s,(1-(o[1]+1)/2)*u)},t.prototype.setPickHandler=function(t){this.pickHandler=t},t.prototype.addEventMapping=function(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((function(t,e){return t.priority-e.priority}))},t.prototype.mapEvent=function(t){if(this.rootTarget){var e=this.mappingTable[t.type];if(e)for(var n=0,r=e.length;n<r;n++)e[n].fn(t);else console.warn("[EventService]: Event mapping not defined for ".concat(t.type))}},t.prototype.dispatchEvent=function(t,e,n){if(n){t.eventPhase=t.AT_TARGET;var r=this.rootTarget.defaultView||null;t.currentTarget=r,this.notifyListeners(t,e)}else t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e);this.emitter.emit(e||t.type,t)},t.prototype.propagate=function(t,e){if(t.target){var n=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(var r=n.length-1;r>=1;r--)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){var i=n.indexOf(t.currentTarget);t.eventPhase=t.BUBBLING_PHASE;for(r=i+1;r<n.length;r++)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}},t.prototype.propagationPath=function(t){var e=[t],n=this.rootTarget.defaultView||null;if(n&&n===t)return e.unshift(n.document),e;for(var r=0;r<2048&&t!==this.rootTarget;r++)rs.isNode(t)&&t.parentNode&&(e.push(t.parentNode),t=t.parentNode);return n&&e.push(n),e},t.prototype.hitTest=function(t){var e=t.viewportX,n=t.viewportY,r=this.context.config,i=r.width,o=r.height,a=r.disableHitTesting;return e<0||n<0||e>i||n>o?null:!a&&this.pickHandler(t)||this.rootTarget||null},t.prototype.isNativeEventFromCanvas=function(t,e){var n=null==e?void 0:e.target;if((null==n?void 0:n.shadowRoot)&&(n=e.composedPath()[0]),n){if(n===t)return!0;if(t&&t.contains)return t.contains(n)}return!!(null==e?void 0:e.composedPath)&&e.composedPath().indexOf(t)>-1},t.prototype.getExistedHTML=function(t){var e,n;if(t.nativeEvent.composedPath)try{for(var r=u(t.nativeEvent.composedPath()),i=r.next();!i.done;i=r.next()){var o=i.value,a=this.nativeHTMLMap.get(o);if(a)return a}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return null},t.prototype.pickTarget=function(t){return this.hitTest({clientX:t.clientX,clientY:t.clientY,viewportX:t.viewportX,viewportY:t.viewportY,x:t.canvasX,y:t.canvasY})},t.prototype.createPointerEvent=function(t,e,n,r){var i=this.allocateEvent(Ja);this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.nativeEvent=t.nativeEvent,i.originalEvent=t;var o=this.getExistedHTML(i),a=this.context.contextService.getDomElement();return i.target=null!=n?n:o||this.isNativeEventFromCanvas(a,i.nativeEvent)&&this.pickTarget(i)||r,"string"==typeof e&&(i.type=e),i},t.prototype.createWheelEvent=function(t){var e=this.allocateEvent(ts);this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t;var n=this.getExistedHTML(e),r=this.context.contextService.getDomElement();return e.target=n||this.isNativeEventFromCanvas(r,e.nativeEvent)&&this.pickTarget(e),e},t.prototype.trackingData=function(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]},t.prototype.cloneWheelEvent=function(t){var e=this.allocateEvent(ts);return e.nativeEvent=t.nativeEvent,e.originalEvent=t.originalEvent,this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.target=t.target,e.path=t.composedPath().slice(),e.type=t.type,e},t.prototype.clonePointerEvent=function(t,e){var n=this.allocateEvent(Ja);return n.nativeEvent=t.nativeEvent,n.originalEvent=t.originalEvent,this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.target=t.target,n.path=t.composedPath().slice(),n.type=null!=e?e:n.type,n},t.prototype.copyPointerData=function(t,e){e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist},t.prototype.copyMouseData=function(t,e){e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.shiftKey=t.shiftKey,e.client.copyFrom(t.client),e.movement.copyFrom(t.movement),e.canvas.copyFrom(t.canvas),e.screen.copyFrom(t.screen),e.global.copyFrom(t.global),e.offset.copyFrom(t.offset)},t.prototype.copyWheelData=function(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ},t.prototype.copyData=function(t,e){e.isTrusted=t.isTrusted,e.timeStamp=ga.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.page.copyFrom(t.page),e.viewport.copyFrom(t.viewport)},t.prototype.allocateEvent=function(t){this.eventPool.has(t)||this.eventPool.set(t,[]);var e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=[],e.target=null,e},t.prototype.freeEvent=function(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");var e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)},t.prototype.notifyTarget=function(t,e){e=null!=e?e:t.type;var n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?"".concat(e,"capture"):e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)},t.prototype.notifyListeners=function(t,e){var n=t.currentTarget.emitter,r=n._events[e];if(r)if("fn"in r)r.once&&n.removeListener(e,r.fn,void 0,!0),r.fn.call(t.currentTarget||r.context,t);else for(var i=0;i<r.length&&!t.propagationImmediatelyStopped;i++)r[i].once&&n.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(t.currentTarget||r[i].context,t)},t.prototype.findMountedTarget=function(t){if(!t)return null;for(var e=t[t.length-1],n=t.length-2;n>=0;n--){var r=t[n];if(!(r===this.rootTarget||rs.isNode(r)&&r.parentNode===e))break;e=t[n]}return e},t.prototype.getCursor=function(t){for(var e=t;e;){var n=la(e)&&e.getAttribute("cursor");if(n)return n;e=rs.isNode(e)&&e.parentNode}},t}(),os=function(){function t(){}return t.prototype.getOrCreateCanvas=function(t,e){if(this.canvas)return this.canvas;if(t||Es.offscreenCanvas)this.canvas=t||Es.offscreenCanvas,this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e));else try{this.canvas=new window.OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e)),this.context&&this.context.measureText||(this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"))}catch(t){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",i({willReadFrequently:!0},e))}return this.canvas.width=10,this.canvas.height=10,this.canvas},t.prototype.getOrCreateContext=function(t,e){return this.context||this.getOrCreateCanvas(t,e),this.context},t}();!function(t){t[t.CAMERA_CHANGED=0]="CAMERA_CHANGED",t[t.DISPLAY_OBJECT_CHANGED=1]="DISPLAY_OBJECT_CHANGED",t[t.NONE=2]="NONE"}(Xa||(Xa={}));var as,ss=function(){function t(t,e){this.globalRuntime=t,this.context=e,this.inited=!1,this.stats={total:0,rendered:0},this.zIndexCounter=0,this.hooks={init:new Pa,initAsync:new Ta,dirtycheck:new Oa,cull:new Oa,beginFrame:new Pa,beforeRender:new Pa,render:new Pa,afterRender:new Pa,endFrame:new Pa,destroy:new Pa,pick:new Aa,pickSync:new Oa,pointerDown:new Pa,pointerUp:new Pa,pointerMove:new Pa,pointerOut:new Pa,pointerOver:new Pa,pointerWheel:new Pa,pointerCancel:new Pa,click:new Pa}}return t.prototype.init=function(t){var e=this,n=i(i({},this.globalRuntime),this.context);this.context.renderingPlugins.forEach((function(t){t.apply(n,e.globalRuntime)})),this.hooks.init.call(),0===this.hooks.initAsync.getCallbacksNum()?(this.inited=!0,t()):this.hooks.initAsync.promise().then((function(){e.inited=!0,t()}))},t.prototype.getStats=function(){return this.stats},t.prototype.disableDirtyRectangleRendering=function(){return!this.context.config.renderer.getConfig().enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has(Xa.CAMERA_CHANGED)},t.prototype.render=function(t,e,n){var r=this;this.stats.total=0,this.stats.rendered=0,this.zIndexCounter=0;var i=this.context.renderingContext;if(this.globalRuntime.sceneGraphService.syncHierarchy(i.root),this.globalRuntime.sceneGraphService.triggerPendingEvents(),i.renderReasons.size&&this.inited){i.dirtyRectangleRenderingDisabled=this.disableDirtyRectangleRendering();var o=1===i.renderReasons.size&&i.renderReasons.has(Xa.CAMERA_CHANGED),a=!t.disableRenderHooks||!(t.disableRenderHooks&&o);a&&this.renderDisplayObject(i.root,t,i),this.hooks.beginFrame.call(e),a&&i.renderListCurrentFrame.forEach((function(t){r.hooks.beforeRender.call(t),r.hooks.render.call(t),r.hooks.afterRender.call(t)})),this.hooks.endFrame.call(e),i.renderListCurrentFrame=[],i.renderReasons.clear(),n()}},t.prototype.renderDisplayObject=function(t,e,n){var r=this,i=e.renderer.getConfig(),o=i.enableDirtyCheck,a=i.enableCulling;this.globalRuntime.enableCSSParsing&&this.globalRuntime.styleValueRegistry.recalc(t);var s=t.renderable,u=o?s.dirty||n.dirtyRectangleRenderingDisabled?t:null:t;if(u){var c=a?this.hooks.cull.call(u,this.context.camera):u;c&&(this.stats.rendered++,n.renderListCurrentFrame.push(c))}t.renderable.dirty=!1,t.sortable.renderOrder=this.zIndexCounter++,this.stats.total++;var l=t.sortable;l.dirty&&(this.sort(t,l),l.dirty=!1,l.dirtyChildren=[],l.dirtyReason=void 0),(l.sorted||t.childNodes).forEach((function(t){r.renderDisplayObject(t,e,n)}))},t.prototype.sort=function(t,e){e.sorted&&e.dirtyReason!==ci.Z_INDEX_CHANGED?e.dirtyChildren.forEach((function(n){if(-1===t.childNodes.indexOf(n)){var r=e.sorted.indexOf(n);r>=0&&e.sorted.splice(r,1)}else if(0===e.sorted.length)e.sorted.push(n);else{var i=function(t,e){for(var n=0,r=t.length;n<r;){var i=n+r>>>1;ha(t[i],e)<0?n=i+1:r=i}return n}(e.sorted,n);e.sorted.splice(i,0,n)}})):e.sorted=t.childNodes.slice().sort(ha)},t.prototype.destroy=function(){this.inited=!1,this.hooks.destroy.call(),this.globalRuntime.sceneGraphService.clearPendingEvents()},t.prototype.dirtify=function(){this.context.renderingContext.renderReasons.add(Xa.DISPLAY_OBJECT_CHANGED)},t}(),us=/\[\s*(.*)=(.*)\s*\]/,cs=function(){function t(){}return t.prototype.selectOne=function(t,e){var n=this;if(t.startsWith("."))return e.find((function(e){return((null==e?void 0:e.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.find((function(e){return e.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.find((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):null}return e.find((function(n){return e!==n&&n.nodeName===t}))},t.prototype.selectAll=function(t,e){var n=this;if(t.startsWith("."))return e.findAll((function(r){return e!==r&&((null==r?void 0:r.classList)||[]).indexOf(n.getIdOrClassname(t))>-1}));if(t.startsWith("#"))return e.findAll((function(r){return e!==r&&r.id===n.getIdOrClassname(t)}));if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.findAll((function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)})):[]}return e.findAll((function(n){return e!==n&&n.nodeName===t}))},t.prototype.is=function(t,e){if(t.startsWith("."))return e.className===this.getIdOrClassname(t);if(t.startsWith("#"))return e.id===this.getIdOrClassname(t);if(t.startsWith("[")){var n=this.getAttribute(t),r=n.name,i=n.value;return"name"===r?e.name===i:this.attributeToString(e,r)===i}return e.nodeName===t},t.prototype.getIdOrClassname=function(t){return t.substring(1)},t.prototype.getAttribute=function(t){var e=t.match(us),n="",r="";return e&&e.length>2&&(n=e[1].replace(/"/g,""),r=e[2].replace(/"/g,"")),{name:n,value:r}},t.prototype.attributeToString=function(t,e){if(!t.getAttribute)return"";var n=t.getAttribute(e);return _t(n)?"":n.toString?n.toString():""},t}(),ls=function(t){function e(e,n,r,i,o,a,s,u){var c=t.call(this,null)||this;return c.relatedNode=n,c.prevValue=r,c.newValue=i,c.attrName=o,c.attrChange=a,c.prevParsedValue=s,c.newParsedValue=u,c.type=e,c}return r(e,t),e.ADDITION=2,e.MODIFICATION=1,e.REMOVAL=3,e}(Za);function hs(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0)}!function(t){t.REPARENT="reparent",t.DESTROY="destroy",t.ATTR_MODIFIED="DOMAttrModified",t.INSERTED="DOMNodeInserted",t.REMOVED="removed",t.MOUNTED="DOMNodeInsertedIntoDocument",t.UNMOUNTED="DOMNodeRemovedFromDocument",t.BOUNDS_CHANGED="bounds-changed",t.CULLED="culled"}(as||(as={}));var ds,fs,ps,gs=new ls(as.REPARENT,null,"","","",0,"",""),ms=function(){function t(t){var e,n,r,i,o,a,s,u,c=this;this.runtime=t,this.pendingEvents=[],this.boundsChangedEvent=new es(as.BOUNDS_CHANGED),this.rotate=(e=xt(),function(t,n,r,i,o){void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=!0),"number"==typeof n&&(n=it(n,r,i));var a=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){var s=xt();St(s,n[0],n[1],n[2]);var u=c.getRotation(t),l=c.getRotation(t.parentNode);kt(e,l),Mt(e,e),Et(s,e,s),Et(a.localRotation,s,u),Tt(a.localRotation,a.localRotation),o&&c.dirtifyLocal(t,a)}else c.rotateLocal(t,n)}),this.rotateLocal=(n=xt(),function(t,e,r,i,o){void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=!0),"number"==typeof e&&(e=it(e,r,i));var a=t.transformable;St(n,e[0],e[1],e[2]),Ct(a.localRotation,a.localRotation,n),o&&c.dirtifyLocal(t,a)}),this.setEulerAngles=(r=xt(),function(t,e,n,i,o){void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=!0),"number"==typeof e&&(e=it(e,n,i));var a=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){St(a.localRotation,e[0],e[1],e[2]);var s=c.getRotation(t.parentNode);kt(r,Mt(xt(),s)),Ct(a.localRotation,a.localRotation,r),o&&c.dirtifyLocal(t,a)}else c.setLocalEulerAngles(t,e)}),this.translateLocal=function(t,e,n,r,i){void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=!0),"number"==typeof e&&(e=it(e,n,r));var o=t.transformable;gt(e,et())||(function(t,e,n){var r=n[0],i=n[1],o=n[2],a=n[3],s=e[0],u=e[1],c=e[2],l=i*c-o*u,h=o*s-r*c,d=r*u-i*s,f=i*d-o*h,p=o*l-r*d,g=r*h-i*l,m=2*a;l*=m,h*=m,d*=m,f*=2,p*=2,g*=2,t[0]=s+l+f,t[1]=u+h+p,t[2]=c+d+g}(e,e,o.localRotation),st(o.localPosition,o.localPosition,e),i&&c.dirtifyLocal(t,o))},this.setPosition=(i=x(),o=et(),function(t,e,n){void 0===n&&(n=!0);var r=t.transformable;if(o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,!gt(c.getPosition(t),o)){if(ot(r.position,o),null!==t.parentNode&&t.parentNode.transformable){var a=t.parentNode.transformable;E(i,a.worldTransform),k(i,i),pt(r.localPosition,o,i)}else ot(r.localPosition,o);n&&c.dirtifyLocal(t,r)}}),this.setLocalPosition=function(){var t=et();return function(e,n,r){void 0===r&&(r=!0);var i=e.transformable;t[0]=n[0],t[1]=n[1],t[2]=n[2]||0,gt(i.localPosition,t)||(ot(i.localPosition,t),r&&c.dirtifyLocal(e,i))}}(),this.translate=(a=et(),s=et(),u=et(),function(t,e,n,r,i){void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=!0),"number"==typeof e&&(e=at(s,e,n,r)),gt(e,a)||(st(u,c.getPosition(t),e),c.setPosition(t,u,i))}),this.setRotation=function(){var t=xt();return function(e,n,r,i,o,a){void 0===a&&(a=!0);var s=e.transformable;if("number"==typeof n&&(n=Nt(n,r,i,o)),null!==e.parentNode&&e.parentNode.transformable){var u=c.getRotation(e.parentNode);kt(t,u),Mt(t,t),Et(s.localRotation,t,n),Tt(s.localRotation,s.localRotation),a&&c.dirtifyLocal(e,s)}else c.setLocalRotation(e,n)}},this.displayObjectDependencyMap=new WeakMap,this.calcLocalTransform=function(){var t=x(),e=et(),n=Nt(0,0,0,1);return function(r){if(0!==r.localSkew[0]||0!==r.localSkew[1]){if(W(r.localTransform,r.localRotation,r.localPosition,it(1,1,1),r.origin),0!==r.localSkew[0]||0!==r.localSkew[1]){var i=S(t);i[4]=Math.tan(r.localSkew[0]),i[1]=Math.tan(r.localSkew[1]),T(r.localTransform,r.localTransform,i)}var o=W(t,n,e,r.localScale,r.origin);T(r.localTransform,r.localTransform,o)}else W(r.localTransform,r.localRotation,r.localPosition,r.localScale,r.origin)}}()}return t.prototype.matches=function(t,e){return this.runtime.sceneGraphSelector.is(t,e)},t.prototype.querySelector=function(t,e){return this.runtime.sceneGraphSelector.selectOne(t,e)},t.prototype.querySelectorAll=function(t,e){return this.runtime.sceneGraphSelector.selectAll(t,e)},t.prototype.attach=function(t,e,n){var r,i=!1;t.parentNode&&(i=t.parentNode!==e,this.detach(t)),t.parentNode=e,_t(n)?t.parentNode.childNodes.push(t):t.parentNode.childNodes.splice(n,0,t);var o=e.sortable;((null===(r=null==o?void 0:o.sorted)||void 0===r?void 0:r.length)||t.parsedStyle.zIndex)&&(-1===o.dirtyChildren.indexOf(t)&&o.dirtyChildren.push(t),o.dirty=!0,o.dirtyReason=ci.ADDED);var a=t.transformable;a&&this.dirtifyWorld(t,a),a.frozen&&this.unfreezeParentToRoot(t),i&&t.dispatchEvent(gs)},t.prototype.detach=function(t){var e,n;if(t.parentNode){var r=t.transformable,i=t.parentNode.sortable;((null===(e=null==i?void 0:i.sorted)||void 0===e?void 0:e.length)||(null===(n=t.style)||void 0===n?void 0:n.zIndex))&&(-1===i.dirtyChildren.indexOf(t)&&i.dirtyChildren.push(t),i.dirty=!0,i.dirtyReason=ci.REMOVED);var o=t.parentNode.childNodes.indexOf(t);o>-1&&t.parentNode.childNodes.splice(o,1),r&&this.dirtifyWorld(t,r),t.parentNode=null}},t.prototype.getOrigin=function(t){return t.getGeometryBounds(),t.transformable.origin},t.prototype.setOrigin=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=[e,n,r]);var i=t.transformable;if(e[0]!==i.origin[0]||e[1]!==i.origin[1]||e[2]!==i.origin[2]){var o=i.origin;o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,this.dirtifyLocal(t,i)}},t.prototype.setLocalEulerAngles=function(t,e,n,r,i){void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=!0),"number"==typeof e&&(e=it(e,n,r));var o=t.transformable;St(o.localRotation,e[0],e[1],e[2]),i&&this.dirtifyLocal(t,o)},t.prototype.scaleLocal=function(t,e,n){void 0===n&&(n=!0);var r=t.transformable;!function(t,e,n){t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2]}(r.localScale,r.localScale,it(e[0],e[1],e[2]||1)),n&&this.dirtifyLocal(t,r)},t.prototype.setLocalScale=function(t,e,n){void 0===n&&(n=!0);var r=t.transformable,i=it(e[0],e[1],e[2]||r.localScale[2]);gt(i,r.localScale)||(ot(r.localScale,i),n&&this.dirtifyLocal(t,r))},t.prototype.setLocalRotation=function(t,e,n,r,i,o){void 0===o&&(o=!0),"number"==typeof e&&(e=Nt(e,n,r,i));var a=t.transformable;kt(a.localRotation,e),o&&this.dirtifyLocal(t,a)},t.prototype.setLocalSkew=function(t,e,n){"number"==typeof e&&(e=function(t,e){var n=new v(2);return n[0]=t,n[1]=e,n}(e,n));var r=t.transformable;!function(t,e){t[0]=e[0],t[1]=e[1]}(r.localSkew,e),this.dirtifyLocal(t,r)},t.prototype.dirtifyLocal=function(t,e){e.localDirtyFlag||(e.localDirtyFlag=!0,e.dirtyFlag||this.dirtifyWorld(t,e))},t.prototype.dirtifyWorld=function(t,e){e.dirtyFlag||this.unfreezeParentToRoot(t),this.dirtifyWorldInternal(t,e),this.dirtifyToRoot(t,!0)},t.prototype.triggerPendingEvents=function(){var t=this,e=new Set,n=function(n,r){n.isConnected&&!e.has(n.entity)&&(t.boundsChangedEvent.detail=r,t.boundsChangedEvent.target=n,n.isMutationObserved?n.dispatchEvent(t.boundsChangedEvent):n.ownerDocument.defaultView.dispatchEvent(t.boundsChangedEvent,!0),e.add(n.entity))};this.pendingEvents.forEach((function(t){var e=c(t,2),r=e[0],i=e[1];i.affectChildren?r.forEach((function(t){n(t,i)})):n(r,i)})),this.clearPendingEvents(),e.clear()},t.prototype.clearPendingEvents=function(){this.pendingEvents=[]},t.prototype.dirtifyToRoot=function(t,e){void 0===e&&(e=!1);var n=t;for(n.renderable&&(n.renderable.dirty=!0);n;)hs(n),n=n.parentNode;e&&t.forEach((function(t){hs(t)})),this.informDependentDisplayObjects(t),this.pendingEvents.push([t,{affectChildren:e}])},t.prototype.updateDisplayObjectDependency=function(t,e,n,r){if(e&&e!==n){var i=this.displayObjectDependencyMap.get(e);if(i&&i[t]){var o=i[t].indexOf(r);i[t].splice(o,1)}}if(n){var a=this.displayObjectDependencyMap.get(n);a||(this.displayObjectDependencyMap.set(n,{}),a=this.displayObjectDependencyMap.get(n)),a[t]||(a[t]=[]),a[t].push(r)}},t.prototype.informDependentDisplayObjects=function(t){var e=this,n=this.displayObjectDependencyMap.get(t);n&&Object.keys(n).forEach((function(t){n[t].forEach((function(n){e.dirtifyToRoot(n,!0),n.dispatchEvent(new ls(as.ATTR_MODIFIED,n,e,e,t,ls.MODIFICATION,e,e)),n.isCustomElement&&n.isConnected&&n.attributeChangedCallback&&n.attributeChangedCallback(t,e,e)}))}))},t.prototype.getPosition=function(t){var e=t.transformable;return F(e.position,this.getWorldTransform(t,e))},t.prototype.getRotation=function(t){var e=t.transformable;return V(e.rotation,this.getWorldTransform(t,e))},t.prototype.getScale=function(t){var e=t.transformable;return G(e.scaling,this.getWorldTransform(t,e))},t.prototype.getWorldTransform=function(t,e){return void 0===e&&(e=t.transformable),e.localDirtyFlag||e.dirtyFlag?(t.parentNode&&t.parentNode.transformable&&this.getWorldTransform(t.parentNode),this.sync(t,e),e.worldTransform):e.worldTransform},t.prototype.getLocalPosition=function(t){return t.transformable.localPosition},t.prototype.getLocalRotation=function(t){return t.transformable.localRotation},t.prototype.getLocalScale=function(t){return t.transformable.localScale},t.prototype.getLocalSkew=function(t){return t.transformable.localSkew},t.prototype.getLocalTransform=function(t){var e=t.transformable;return e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.localTransform},t.prototype.setLocalTransform=function(t,e){var n=F(et(),e),r=V(xt(),e),i=G(et(),e);this.setLocalScale(t,i,!1),this.setLocalPosition(t,n,!1),this.setLocalRotation(t,r,void 0,void 0,void 0,!1),this.dirtifyLocal(t,t.transformable)},t.prototype.resetLocalTransform=function(t){this.setLocalScale(t,[1,1,1]),this.setLocalPosition(t,[0,0,0]),this.setLocalEulerAngles(t,[0,0,0]),this.setLocalSkew(t,[0,0])},t.prototype.getTransformedGeometryBounds=function(t,e,n){void 0===e&&(e=!1);var r=this.getGeometryBounds(t,e);if(Sr.isEmpty(r))return null;var i=n||new Sr;return i.setFromTransformedAABB(r,this.getWorldTransform(t)),i},t.prototype.getGeometryBounds=function(t,e){void 0===e&&(e=!1);var n=t.geometry;return n.dirty&&Es.styleValueRegistry.updateGeometry(t),(e?n.renderBounds:n.contentBounds||null)||new Sr},t.prototype.getBounds=function(t,e){var n=this;void 0===e&&(e=!1);var r=t.renderable;if(!r.boundsDirty&&!e&&r.bounds)return r.bounds;if(!r.renderBoundsDirty&&e&&r.renderBounds)return r.renderBounds;var i=e?r.renderBounds:r.bounds,o=this.getTransformedGeometryBounds(t,e,i);if(t.childNodes.forEach((function(t){var r=n.getBounds(t,e);r&&(o?o.add(r):(o=i||new Sr).update(r.center,r.halfExtents))})),o||(o=new Sr),e){var a=da(t);if(a){var s=a.parsedStyle.clipPath.getBounds(e);o?s&&(o=s.intersection(o)):o.update(s.center,s.halfExtents)}}return e?(r.renderBounds=o,r.renderBoundsDirty=!1):(r.bounds=o,r.boundsDirty=!1),o},t.prototype.getLocalBounds=function(t){if(t.parentNode){var e=x();t.parentNode.transformable&&(e=k(x(),this.getWorldTransform(t.parentNode)));var n=this.getBounds(t);if(!Sr.isEmpty(n)){var r=new Sr;return r.setFromTransformedAABB(n,e),r}}return this.getBounds(t)},t.prototype.getBoundingClientRect=function(t){var e,n,r,i=this.getGeometryBounds(t);Sr.isEmpty(i)||(r=new Sr).setFromTransformedAABB(i,this.getWorldTransform(t));var o=null===(n=null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0===n?void 0:n.getContextService().getBoundingClientRect();if(r){var a=c(r.getMin(),2),s=a[0],u=a[1],l=c(r.getMax(),2),h=l[0],d=l[1];return new Or(s+((null==o?void 0:o.left)||0),u+((null==o?void 0:o.top)||0),h-s,d-u)}return new Or((null==o?void 0:o.left)||0,(null==o?void 0:o.top)||0,0,0)},t.prototype.dirtifyWorldInternal=function(t,e){var n=this;if(!e.dirtyFlag){e.dirtyFlag=!0,e.frozen=!1,t.childNodes.forEach((function(t){var e=t.transformable;e.dirtyFlag||n.dirtifyWorldInternal(t,e)}));var r=t.renderable;r&&(r.renderBoundsDirty=!0,r.boundsDirty=!0,r.dirty=!0)}},t.prototype.syncHierarchy=function(t){var e=t.transformable;if(!e.frozen){e.frozen=!0,(e.localDirtyFlag||e.dirtyFlag)&&this.sync(t,e);for(var n=t.childNodes,r=0;r<n.length;r++)this.syncHierarchy(n[r])}},t.prototype.sync=function(t,e){if(e.localDirtyFlag&&(this.calcLocalTransform(e),e.localDirtyFlag=!1),e.dirtyFlag){var n=t.parentNode,r=n&&n.transformable;null!==n&&r?T(e.worldTransform,r.worldTransform,e.localTransform):E(e.worldTransform,e.localTransform),e.dirtyFlag=!1}},t.prototype.unfreezeParentToRoot=function(t){for(var e=t.parentNode;e;){var n=e.transformable;n&&(n.frozen=!1),e=e.parentNode}},t}(),ys={MetricsString:"|ÉqÅ",BaselineSymbol:"M",BaselineMultiplier:1.4,HeightMultiplier:2,Newlines:[10,13],BreakingSpaces:[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288]},vs=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,bs=new RegExp("".concat(/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/.source,"|").concat(/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹓﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/.source,"|").concat(/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/.source,"|").concat(/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/.source)),xs=new RegExp("".concat(/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/.source,"|").concat(/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/.source,"|").concat(/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/.source,"|").concat(/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/.source)),ws=function(){function t(t){var e=this;this.runtime=t,this.fontMetricsCache={},this.shouldBreakByKinsokuShorui=function(t,n){return!e.isBreakingSpace(n)&&!(!t||!xs.exec(n)&&!bs.exec(t))},this.trimByKinsokuShorui=function(t){var e=l([],c(t),!1),n=e[e.length-2];if(!n)return t;var r=n[n.length-1];return e[e.length-2]=n.slice(0,-1),e[e.length-1]=r+e[e.length-1],e}}return t.prototype.measureFont=function(t,e){if(this.fontMetricsCache[t])return this.fontMetricsCache[t];var n={ascent:0,descent:0,fontSize:0},r=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(e),i=this.runtime.offscreenCanvasCreator.getOrCreateContext(e,{willReadFrequently:!0});i.font=t;var o=ys.MetricsString+ys.BaselineSymbol,a=Math.ceil(i.measureText(o).width),s=Math.ceil(i.measureText(ys.BaselineSymbol).width),u=ys.HeightMultiplier*s;s=s*ys.BaselineMultiplier|0,r.width=a,r.height=u,i.fillStyle="#f00",i.fillRect(0,0,a,u),i.font=t,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(o,0,s);var c=i.getImageData(0,0,a||1,u||1).data,l=c.length,h=4*a,d=0,f=0,p=!1;for(d=0;d<s;++d){for(var g=0;g<h;g+=4)if(255!==c[f+g]){p=!0;break}if(p)break;f+=h}for(n.ascent=s-d,f=l-h,p=!1,d=u;d>s;--d){for(g=0;g<h;g+=4)if(255!==c[f+g]){p=!0;break}if(p)break;f-=h}return n.descent=d-s,n.fontSize=n.ascent+n.descent,this.fontMetricsCache[t]=n,n},t.prototype.measureText=function(t,e,n){var r=e.fontSize,i=void 0===r?16:r,o=e.wordWrap,a=void 0!==o&&o,s=e.lineHeight,u=e.lineWidth,c=void 0===u?1:u,l=e.textBaseline,h=void 0===l?"alphabetic":l,d=e.textAlign,f=void 0===d?"start":d,p=e.letterSpacing,g=void 0===p?0:p,m=e.textPath;e.textPathSide,e.textPathStartOffset;var y=e.leading,v=void 0===y?0:y,b=function(t){for(var e=t.fontSize,n=void 0===e?16:e,r=t.fontFamily,i=void 0===r?"sans-serif":r,o=t.fontStyle,a=void 0===o?"normal":o,s=t.fontVariant,u=void 0===s?"normal":s,c=t.fontWeight,l=void 0===c?"normal":c,h=$t(n)&&"".concat(n,"px")||"16px",d=i.split(","),f=d.length-1;f>=0;f--){var p=d[f].trim();!Ra.test(p)&&_a.indexOf(p)<0&&(p='"'.concat(p,'"')),d[f]=p}return"".concat(a," ").concat(u," ").concat(l," ").concat(h," ").concat(d.join(","))}(e),x=this.measureFont(b,n);0===x.fontSize&&(x.fontSize=i,x.ascent=i);var w=this.runtime.offscreenCanvasCreator.getOrCreateContext(n);w.font=b,e.isOverflowing=!1;var E=(a?this.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),M=new Array(E.length),S=0;if(!m){for(A=0;A<E.length;A++){var N=w.measureText(E[A]).width+(E[A].length-1)*g;M[A]=N,S=Math.max(S,N)}P=S+c;var k=s||x.fontSize+c,C=Math.max(k,x.fontSize+c)+(E.length-1)*(k+v),T=0;return"middle"===h?T=-C/2:"bottom"===h||"alphabetic"===h||"ideographic"===h?T=-C:"top"!==h&&"hanging"!==h||(T=0),{font:b,width:P,height:C,lines:E,lineWidths:M,lineHeight:k+=v,maxLineWidth:S,fontProperties:x,lineMetrics:M.map((function(t,e){var n=0;return"center"===f||"middle"===f?n-=t/2:"right"!==f&&"end"!==f||(n-=t),new Or(n-c/2,T+e*k,t+c,k)}))}}m.getTotalLength();for(var A=0;A<E.length;A++)var P=w.measureText(E[A]).width+(E[A].length-1)*g},t.prototype.setGraphemeOnPath=function(){},t.prototype.wordWrap=function(t,e,n){var r=this,i=e.wordWrapWidth,o=void 0===i?0:i,a=e.letterSpacing,s=void 0===a?0:a,u=e.maxLines,c=void 0===u?1/0:u,l=e.textOverflow,h=this.runtime.offscreenCanvasCreator.getOrCreateContext(n),d=o+s,f="";"ellipsis"===l?f="...":l&&"clip"!==l&&(f=l);for(var p=[],g=0,m=0,y={},v=function(t){return r.getFromCache(t,s,y,h)},b=Array.from(f).reduce((function(t,e){return t+v(e)}),0),x=Array.from(t),w=0;w<x.length;w++){var E=x[w],M=t[w-1],S=t[w+1],N=v(E);if(this.isNewline(E)){if(++g>=c){e.isOverflowing=!0;break}m=0,p[g]=""}else{if(m>0&&m+N>d){if(g+1>=c){if(e.isOverflowing=!0,b>0&&b<=d){for(var k=p[g].length,C=0,T=k,A=0;A<k;A++){var P=v(p[g][A]);if(C+P+b>d){T=A;break}C+=P}p[g]=(p[g]||"").slice(0,T)+f}break}if(m=0,p[++g]="",this.isBreakingSpace(E))continue;this.canBreakInLastChar(E)||(p=this.trimToBreakable(p),m=this.sumTextWidthByCache(p[g]||"",y)),this.shouldBreakByKinsokuShorui(E,S)&&(p=this.trimByKinsokuShorui(p),m+=v(M||""))}m+=N,p[g]=(p[g]||"")+E}}return p.join("\n")},t.prototype.isBreakingSpace=function(t){return"string"==typeof t&&ys.BreakingSpaces.indexOf(t.charCodeAt(0))>=0},t.prototype.isNewline=function(t){return"string"==typeof t&&ys.Newlines.indexOf(t.charCodeAt(0))>=0},t.prototype.trimToBreakable=function(t){var e=l([],c(t),!1),n=e[e.length-2],r=this.findBreakableIndex(n);if(-1===r||!n)return e;var i=n.slice(r,r+1),o=r+1,a=r+(this.isBreakingSpace(i)?0:1);return e[e.length-1]+=n.slice(o,n.length),e[e.length-2]=n.slice(0,a),e},t.prototype.canBreakInLastChar=function(t){return!t||!vs.test(t)},t.prototype.sumTextWidthByCache=function(t,e){return t.split("").reduce((function(t,n){if(!e[n])throw Error("cannot count the word without cache");return t+e[n]}),0)},t.prototype.findBreakableIndex=function(t){for(var e=t.length-1;e>=0;e--)if(!vs.test(t[e]))return e;return-1},t.prototype.getFromCache=function(t,e,n,r){var i=n[t];if("number"!=typeof i){var o=t.length*e;i=r.measureText(t).width+o,n[t]=i}return i},t}(),Es={},Ms=(fs=new qa,ps=new $a,(ds={})[er.CIRCLE]=new Va,ds[er.ELLIPSE]=new Wa,ds[er.RECT]=fs,ds[er.IMAGE]=fs,ds[er.GROUP]=new Ka,ds[er.LINE]=new Ha,ds[er.TEXT]=new Ya(Es),ds[er.POLYLINE]=ps,ds[er.POLYGON]=ps,ds[er.PATH]=new Ua,ds[er.HTML]=null,ds[er.MESH]=null,ds),Ss=function(){var t,e=new $o,n=new Ko;return(t={})[wi.PERCENTAGE]=null,t[wi.NUMBER]=new Jo,t[wi.ANGLE]=new Ho,t[wi.DEFINED_PATH]=new Uo,t[wi.PAINT]=e,t[wi.COLOR]=e,t[wi.FILTER]=new qo,t[wi.LENGTH]=n,t[wi.LENGTH_PERCENTAGE]=n,t[wi.LENGTH_PERCENTAGE_12]=new Xo,t[wi.LENGTH_PERCENTAGE_14]=new Zo,t[wi.COORDINATE]=new Ko,t[wi.OFFSET_DISTANCE]=new ta,t[wi.OPACITY_VALUE]=new ea,t[wi.PATH]=new na,t[wi.LIST_OF_POINTS]=new ra,t[wi.SHADOW_BLUR]=new ia,t[wi.TEXT]=new oa,t[wi.TEXT_TRANSFORM]=new aa,t[wi.TRANSFORM]=new za,t[wi.TRANSFORM_ORIGIN]=new Fa,t[wi.Z_INDEX]=new Ga,t[wi.MARKER]=new Qo,t}();Es.CameraContribution=Gr,Es.AnimationTimeline=null,Es.EasingFunction=null,Es.offscreenCanvasCreator=new os,Es.sceneGraphSelector=new cs,Es.sceneGraphService=new ms(Es),Es.textService=new ws(Es),Es.geometryUpdaterFactory=Ms,Es.CSSPropertySyntaxFactory=Ss,Es.styleValueRegistry=new Wo(Es),Es.layoutRegistry=null,Es.globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Es.enableCSSParsing=!1,Es.enableDataset=!1,Es.enableStyleSyntax=!0,Es.enableAttributeDashCased=!1,Es.enableSizeAttenuation=!1;var Ns=0,ks=new ls(as.INSERTED,null,"","","",0,"",""),Cs=new ls(as.REMOVED,null,"","","",0,"",""),Ts=new es(as.DESTROY),As=function(t){function e(){var e=t.call(this)||this;return e.entity=Ns++,e.renderable={bounds:void 0,boundsDirty:!0,renderBounds:void 0,renderBoundsDirty:!0,dirtyRenderBounds:void 0,dirty:!1},e.cullable={strategy:ui.Standard,visibilityPlaneMask:-1,visible:!0,enable:!0},e.transformable={dirtyFlag:!1,localDirtyFlag:!1,frozen:!1,localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],origin:[0,0,0]},e.sortable={dirty:!1,sorted:void 0,renderOrder:0,dirtyChildren:[],dirtyReason:void 0},e.geometry={contentBounds:void 0,renderBounds:void 0,dirty:!0},e.rBushNode={aabb:void 0},e.namespaceURI="g",e.scrollLeft=0,e.scrollTop=0,e.clientTop=0,e.clientLeft=0,e.destroyed=!1,e.style={},e.computedStyle=Es.enableCSSParsing?{opacity:di,fillOpacity:di,strokeOpacity:di,fill:di,stroke:di,transform:di,transformOrigin:di,visibility:di,pointerEvents:di,lineWidth:di,lineCap:di,lineJoin:di,increasedLineWidthForHitTesting:di,fontSize:di,fontFamily:di,fontStyle:di,fontWeight:di,fontVariant:di,textAlign:di,textBaseline:di,textTransform:di,zIndex:di,filter:di,shadowType:di}:null,e.parsedStyle={},e.attributes={},e}return r(e,t),Object.defineProperty(e.prototype,"className",{get:function(){return this.getAttribute("class")||""},set:function(t){this.setAttribute("class",t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"classList",{get:function(){return this.className.split(" ").filter((function(t){return""!==t}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tagName",{get:function(){return this.nodeName},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return this.parentNode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t+1]||null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t-1]||null}return null},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(t){throw new Error(_r)},e.prototype.appendChild=function(t,e){var n;if(t.destroyed)throw new Error("Cannot append a destroyed element.");return Es.sceneGraphService.attach(t,this,e),(null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView)&&this.ownerDocument.defaultView.mountChildren(t),this.isMutationObserved&&(ks.relatedNode=this,t.dispatchEvent(ks)),t},e.prototype.insertBefore=function(t,e){if(e){t.parentElement&&t.parentElement.removeChild(t);var n=this.childNodes.indexOf(e);-1===n?this.appendChild(t):this.appendChild(t,n)}else this.appendChild(t);return t},e.prototype.replaceChild=function(t,e){var n=this.childNodes.indexOf(e);return this.removeChild(e),this.appendChild(t,n),e},e.prototype.removeChild=function(t){var e;return Cs.relatedNode=this,t.dispatchEvent(Cs),(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)&&t.ownerDocument.defaultView.unmountChildren(t),Es.sceneGraphService.detach(t),t},e.prototype.removeChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];this.removeChild(e)}},e.prototype.destroyChildren=function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];e.childNodes.length&&e.destroyChildren(),e.destroy()}},e.prototype.matches=function(t){return Es.sceneGraphService.matches(t,this)},e.prototype.getElementById=function(t){return Es.sceneGraphService.querySelector("#".concat(t),this)},e.prototype.getElementsByName=function(t){return Es.sceneGraphService.querySelectorAll('[name="'.concat(t,'"]'),this)},e.prototype.getElementsByClassName=function(t){return Es.sceneGraphService.querySelectorAll(".".concat(t),this)},e.prototype.getElementsByTagName=function(t){return Es.sceneGraphService.querySelectorAll(t,this)},e.prototype.querySelector=function(t){return Es.sceneGraphService.querySelector(t,this)},e.prototype.querySelectorAll=function(t){return Es.sceneGraphService.querySelectorAll(t,this)},e.prototype.closest=function(t){var e=this;do{if(Es.sceneGraphService.matches(t,e))return e;e=e.parentElement}while(null!==e);return null},e.prototype.find=function(t){var e=this,n=null;return this.forEach((function(r){return!(r===e||!t(r))&&(n=r,!0)})),n},e.prototype.findAll=function(t){var e=this,n=[];return this.forEach((function(r){r!==e&&t(r)&&n.push(r)})),n},e.prototype.after=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this);e.forEach((function(e,n){var i;return null===(i=t.parentNode)||void 0===i?void 0:i.appendChild(e,r+n+1)}))}},e.prototype.before=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.parentNode){var r=this.parentNode.childNodes.indexOf(this),i=c(e),o=i[0],a=i.slice(1);this.parentNode.appendChild(o,r),(t=o).after.apply(t,l([],c(a),!1))}},e.prototype.replaceWith=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.after.apply(this,l([],c(t),!1)),this.remove()},e.prototype.append=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e){return t.appendChild(e)}))},e.prototype.prepend=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e.forEach((function(e,n){return t.appendChild(e,n)}))},e.prototype.replaceChildren=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(;this.childNodes.length&&this.firstChild;)this.removeChild(this.firstChild);this.append.apply(this,l([],c(t),!1))},e.prototype.remove=function(){return this.parentNode?this.parentNode.removeChild(this):this},e.prototype.destroy=function(){this.dispatchEvent(Ts),this.remove(),this.emitter.removeAllListeners(),this.destroyed=!0},e.prototype.getGeometryBounds=function(){return Es.sceneGraphService.getGeometryBounds(this)},e.prototype.getRenderBounds=function(){return Es.sceneGraphService.getBounds(this,!0)},e.prototype.getBounds=function(){return Es.sceneGraphService.getBounds(this)},e.prototype.getLocalBounds=function(){return Es.sceneGraphService.getLocalBounds(this)},e.prototype.getBoundingClientRect=function(){return Es.sceneGraphService.getBoundingClientRect(this)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.computedStyleMap=function(){return new Map(Object.entries(this.computedStyle))},e.prototype.getAttributeNames=function(){return Object.keys(this.attributes)},e.prototype.getAttribute=function(t){if(function(t){return"symbol"==typeof t}(t))return Es.enableCSSParsing?null:void 0;var e=this.attributes[t];if(void 0===e){if(Es.enableAttributeDashCased){var n=ri(t);e=this.attributes[n]}return Es.enableCSSParsing&&_t(e)?null:e}return e},e.prototype.hasAttribute=function(t){return this.getAttributeNames().includes(t)},e.prototype.hasAttributes=function(){return!!this.getAttributeNames().length},e.prototype.removeAttribute=function(t){this.setAttribute(t,null),delete this.attributes[t]},e.prototype.setAttribute=function(t,e,n,r){this.attributes[t]=e},e.prototype.getAttributeNS=function(t,e){throw new Error(_r)},e.prototype.getAttributeNode=function(t){throw new Error(_r)},e.prototype.getAttributeNodeNS=function(t,e){throw new Error(_r)},e.prototype.hasAttributeNS=function(t,e){throw new Error(_r)},e.prototype.removeAttributeNS=function(t,e){throw new Error(_r)},e.prototype.removeAttributeNode=function(t){throw new Error(_r)},e.prototype.setAttributeNS=function(t,e,n){throw new Error(_r)},e.prototype.setAttributeNode=function(t){throw new Error(_r)},e.prototype.setAttributeNodeNS=function(t){throw new Error(_r)},e.prototype.toggleAttribute=function(t,e){throw new Error(_r)},e}(rs);function Ps(t){return!!(null==t?void 0:t.nodeName)}var Os,_s=Es.globalThis.Proxy?Es.globalThis.Proxy:function(){},Rs=new ls(as.ATTR_MODIFIED,null,null,null,null,ls.MODIFICATION,null,null),Is={opacity:"",fillOpacity:"",strokeOpacity:"",fill:"",stroke:"",transform:"",transformOrigin:"",visibility:"",pointerEvents:"",lineWidth:"",lineCap:"",lineJoin:"",increasedLineWidthForHitTesting:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",zIndex:"",filter:"",shadowType:""},Ds={fill:yi,stroke:yi,transform:[],zIndex:0,filter:[],shadowType:"outer",miterLimit:10},Ls=l(l([],c(["opacity","fillOpacity","strokeOpacity","transformOrigin","visibility","pointerEvents","lineWidth","lineCap","lineJoin","increasedLineWidthForHitTesting"]),!1),["fontSize","fontFamily","fontStyle","fontWeight","fontVariant","textAlign","textBaseline","textTransform"],!1),js="data-",Bs=function(t){function e(e){var n=t.call(this)||this;return n.isCustomElement=!1,n.isMutationObserved=!1,n.activeAnimations=[],n.config=e,n.id=n.config.id||"",n.name=n.config.name||"",(n.config.className||n.config.class)&&(n.className=n.config.className||n.config.class),n.nodeName=n.config.type||er.GROUP,Es.enableCSSParsing?(Object.assign(n.attributes,Is),Object.assign(n.parsedStyle,Ds,n.config.initialParsedStyle)):n.config.initialParsedStyle&&Object.assign(n.parsedStyle,n.config.initialParsedStyle),n.initAttributes(n.config.style),Es.enableDataset&&(n.dataset=new _s({},{get:function(t,e){var r="".concat(js).concat(ti(e));return void 0!==t[r]?t[r]:n.getAttribute(r)},set:function(t,e,r){return n.setAttribute("".concat(js).concat(ti(e)),r),!0}})),Es.enableStyleSyntax&&(n.style=new _s({setProperty:function(t,e){n.setAttribute(t,e)},getPropertyValue:function(t){return n.getAttribute(t)},removeProperty:function(t){n.removeAttribute(t)},item:function(){return""}},{get:function(t,e){return void 0!==t[e]?t[e]:n.getAttribute(e)},set:function(t,e,r){return n.setAttribute(e,r),!0}})),n}return r(e,t),e.prototype.destroy=function(){t.prototype.destroy.call(this),this.getAnimations().forEach((function(t){t.cancel()}))},e.prototype.cloneNode=function(t,e){var n=i({},this.attributes);for(var r in n){var o=n[r];Ps(o)&&"clipPath"!==r&&"offsetPath"!==r&&"textPath"!==r&&(n[r]=o.cloneNode(t)),e&&(n[r]=e(r,o))}var a=new this.constructor({id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:n});return a.setLocalTransform(this.getLocalTransform()),t&&this.children.forEach((function(e){if(!e.style.isMarker){var n=e.cloneNode(t);a.appendChild(n)}})),a},e.prototype.initAttributes=function(t){void 0===t&&(t={});var e=this.renderable,n={forceUpdateGeometry:!0};Es.enableCSSParsing&&(n.usedAttributes=Ls);var r=t;if(Es.enableAttributeDashCased)for(var i in r={},t){r[ri(i)]=t[i]}Es.styleValueRegistry.processProperties(this,r,n),e.dirty=!0},e.prototype.setAttribute=function(e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=!0),Es.enableAttributeDashCased&&(e=ri(e)),ie(n)||(r||n!==this.attributes[e])&&(this.internalSetAttribute(e,n,{memoize:i}),t.prototype.setAttribute.call(this,e,n))},e.prototype.internalSetAttribute=function(t,e,n){var r;void 0===n&&(n={});var i=this.renderable,o=this.attributes[t],a=this.parsedStyle[t];Es.styleValueRegistry.processProperties(this,((r={})[t]=e,r),n),i.dirty=!0;var s=this.parsedStyle[t];this.isConnected&&(Rs.relatedNode=this,Rs.prevValue=o,Rs.newValue=e,Rs.attrName=t,Rs.prevParsedValue=a,Rs.newParsedValue=s,this.isMutationObserved?this.dispatchEvent(Rs):(Rs.target=this,this.ownerDocument.defaultView.dispatchEvent(Rs,!0))),(this.isCustomElement&&this.isConnected||!this.isCustomElement)&&this.attributeChangedCallback&&this.attributeChangedCallback(t,o,e,a,s)},e.prototype.getBBox=function(){var t=this.getBounds(),e=c(t.getMin(),2),n=e[0],r=e[1],i=c(t.getMax(),2),o=i[0],a=i[1];return new Or(n,r,o-n,a-r)},e.prototype.setOrigin=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Es.sceneGraphService.setOrigin(this,hr(t,e,n)),this},e.prototype.getOrigin=function(){return Es.sceneGraphService.getOrigin(this)},e.prototype.setPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Es.sceneGraphService.setPosition(this,hr(t,e,n)),this},e.prototype.setLocalPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Es.sceneGraphService.setLocalPosition(this,hr(t,e,n)),this},e.prototype.translate=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Es.sceneGraphService.translate(this,hr(t,e,n)),this},e.prototype.translateLocal=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Es.sceneGraphService.translateLocal(this,hr(t,e,n)),this},e.prototype.getPosition=function(){return Es.sceneGraphService.getPosition(this)},e.prototype.getLocalPosition=function(){return Es.sceneGraphService.getLocalPosition(this)},e.prototype.scale=function(t,e,n){return this.scaleLocal(t,e,n)},e.prototype.scaleLocal=function(t,e,n){return"number"==typeof t&&(t=hr(t,e=e||t,n=n||t)),Es.sceneGraphService.scaleLocal(this,t),this},e.prototype.setLocalScale=function(t,e,n){return"number"==typeof t&&(t=hr(t,e=e||t,n=n||t)),Es.sceneGraphService.setLocalScale(this,t),this},e.prototype.getLocalScale=function(){return Es.sceneGraphService.getLocalScale(this)},e.prototype.getScale=function(){return Es.sceneGraphService.getScale(this)},e.prototype.getEulerAngles=function(){return fr(c(pr(et(),Es.sceneGraphService.getWorldTransform(this)),3)[2])},e.prototype.getLocalEulerAngles=function(){return fr(c(pr(et(),Es.sceneGraphService.getLocalRotation(this)),3)[2])},e.prototype.setEulerAngles=function(t){return Es.sceneGraphService.setEulerAngles(this,0,0,t),this},e.prototype.setLocalEulerAngles=function(t){return Es.sceneGraphService.setLocalEulerAngles(this,0,0,t),this},e.prototype.rotateLocal=function(t,e,n){return _t(e)&&_t(n)?Es.sceneGraphService.rotateLocal(this,0,0,t):Es.sceneGraphService.rotateLocal(this,t,e,n),this},e.prototype.rotate=function(t,e,n){return _t(e)&&_t(n)?Es.sceneGraphService.rotate(this,0,0,t):Es.sceneGraphService.rotate(this,t,e,n),this},e.prototype.setRotation=function(t,e,n,r){return Es.sceneGraphService.setRotation(this,t,e,n,r),this},e.prototype.setLocalRotation=function(t,e,n,r){return Es.sceneGraphService.setLocalRotation(this,t,e,n,r),this},e.prototype.setLocalSkew=function(t,e){return Es.sceneGraphService.setLocalSkew(this,t,e),this},e.prototype.getRotation=function(){return Es.sceneGraphService.getRotation(this)},e.prototype.getLocalRotation=function(){return Es.sceneGraphService.getLocalRotation(this)},e.prototype.getLocalSkew=function(){return Es.sceneGraphService.getLocalSkew(this)},e.prototype.getLocalTransform=function(){return Es.sceneGraphService.getLocalTransform(this)},e.prototype.getWorldTransform=function(){return Es.sceneGraphService.getWorldTransform(this)},e.prototype.setLocalTransform=function(t){return Es.sceneGraphService.setLocalTransform(this,t),this},e.prototype.resetLocalTransform=function(){Es.sceneGraphService.resetLocalTransform(this)},e.prototype.getAnimations=function(){return this.activeAnimations},e.prototype.animate=function(t,e){var n,r=null===(n=this.ownerDocument)||void 0===n?void 0:n.timeline;return r?r.play(this,t,e):null},e.prototype.isVisible=function(){var t,e;return Es.enableCSSParsing?"visible"===(null===(t=this.parsedStyle)||void 0===t?void 0:t.visibility):"hidden"!==(null===(e=this.parsedStyle)||void 0===e?void 0:e.visibility)},Object.defineProperty(e.prototype,"interactive",{get:function(){return this.isInteractive()},set:function(t){this.style.pointerEvents=t?"auto":"none"},enumerable:!1,configurable:!0}),e.prototype.isInteractive=function(){var t;return"none"!==(null===(t=this.parsedStyle)||void 0===t?void 0:t.pointerEvents)},e.prototype.isCulled=function(){return!(!this.cullable||!this.cullable.enable||this.cullable.visible)},e.prototype.toFront=function(){return this.parentNode&&(this.style.zIndex=Math.max.apply(Math,l([],c(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))+1),this},e.prototype.toBack=function(){return this.parentNode&&(this.style.zIndex=Math.min.apply(Math,l([],c(this.parentNode.children.map((function(t){return Number(t.style.zIndex)}))),!1))-1),this},e.prototype.getConfig=function(){return this.config},e.prototype.attr=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=c(e,2),i=r[0],o=r[1];return i?Lt(i)?(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),this):2===e.length?(this.setAttribute(i,o),this):this.attributes[i]:this.attributes},e.prototype.getMatrix=function(t){var e=t||this.getWorldTransform(),n=c(F(et(),e),2),r=n[0],i=n[1],o=c(G(et(),e),2),a=o[0],s=o[1],u=V(xt(),e),l=c(pr(et(),u),3),h=l[0],d=l[2];return gr(h||d,r,i,a,s)},e.prototype.getLocalMatrix=function(){return this.getMatrix(this.getLocalTransform())},e.prototype.setMatrix=function(t){var e=c(mr(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setEulerAngles(a).setPosition(n,r).setLocalScale(i,o)},e.prototype.setLocalMatrix=function(t){var e=c(mr(t),5),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4];this.setLocalEulerAngles(a).setLocalPosition(n,r).setLocalScale(i,o)},e.prototype.show=function(){Es.enableCSSParsing?this.style.visibility="visible":this.forEach((function(t){t.style.visibility="visible"}))},e.prototype.hide=function(){Es.enableCSSParsing?this.style.visibility="hidden":this.forEach((function(t){t.style.visibility="hidden"}))},e.prototype.getCount=function(){return this.childElementCount},e.prototype.getParent=function(){return this.parentElement},e.prototype.getChildren=function(){return this.children},e.prototype.getFirst=function(){return this.firstElementChild},e.prototype.getLast=function(){return this.lastElementChild},e.prototype.getChildByIndex=function(t){return this.children[t]||null},e.prototype.add=function(t,e){return this.appendChild(t,e)},e.prototype.set=function(t,e){this.config[t]=e},e.prototype.get=function(t){return this.config[t]},e.prototype.moveTo=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.move=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),this.setPosition(t,e,n),this},e.prototype.setZIndex=function(t){return this.style.zIndex=t,this},e}(As),zs=function(t){function e(e){return void 0===e&&(e={}),t.call(this,i({type:er.CIRCLE},e))||this}return r(e,t),e}(Bs),Fs=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({style:(Es.enableCSSParsing,i({},r))},a))||this).isCustomElement=!0,n}return r(e,t),e}(Bs),Gs=function(t){function e(e){return void 0===e&&(e={}),t.call(this,i({type:er.ELLIPSE},e))||this}return r(e,t),e}(Bs),Vs=function(t){function e(e){return void 0===e&&(e={}),t.call(this,i({type:er.GROUP},e))||this}return r(e,t),e}(Bs),Ws=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,i({type:er.HTML,style:Es.enableCSSParsing?i({x:"",y:"",width:"auto",height:"auto",innerHTML:""},r):i({},r)},a))||this).cullable.enable=!1,n}return r(e,t),e.prototype.getDomElement=function(){return this.parsedStyle.$el},e.prototype.getBoundingClientRect=function(){if(this.parsedStyle.$el)return this.parsedStyle.$el.getBoundingClientRect();var t=this.parsedStyle,e=t.x,n=t.y,r=t.width,i=t.height;return new Or(e,n,r,i)},e.prototype.getClientRects=function(){return[this.getBoundingClientRect()]},e.prototype.getBounds=function(){var t,e,n=this.getBoundingClientRect(),r=null===(e=null===(t=this.ownerDocument)||void 0===t?void 0:t.defaultView)||void 0===e?void 0:e.getContextService().getBoundingClientRect(),i=new Sr,o=n.left-((null==r?void 0:r.left)||0),a=n.top-((null==r?void 0:r.top)||0);return i.setMinMax([o,a,0],[o+n.width,a+n.height,0]),i},e.prototype.getLocalBounds=function(){if(this.parentNode){var t=k(x(),this.parentNode.getWorldTransform()),e=this.getBounds();if(!Sr.isEmpty(e)){var n=new Sr;return n.setFromTransformedAABB(e,t),n}}return this.getBounds()},e}(Bs),Hs=function(t){function e(e){return void 0===e&&(e={}),t.call(this,i({type:er.IMAGE},e))||this}return r(e,t),e}(Bs),Us=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:er.LINE,style:i({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0},r)},a))||this).markerStartAngle=0,n.markerEndAngle=0;var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd;return u&&Ps(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),c&&Ps(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"x1"===t||"y1"===t||"x2"===t||"y2"===t||"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Ps(r)&&(this.markerStartAngle=0,r.remove()),i&&Ps(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t&&(r&&Ps(r)&&(this.markerEndAngle=0,r.remove()),i&&Ps(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1)))},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=e.x1,s=e.x2,u=e.y1,c=e.y2,l=t?n:r;if(l&&Ps(l)){var h,d,f,p,g,m,y;t?(p=a,g=u,d=s-a,f=c-u,m=i||0,y=this.markerStartAngle):(p=s,g=c,d=a-s,f=u-c,m=o||0,y=this.markerEndAngle),h=Math.atan2(f,d),l.setLocalEulerAngles(180*h/Math.PI+y),l.setLocalPosition(p+Math.cos(h)*m,g+Math.sin(h)*m)}},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle,r=Wn(n.x1,n.y1,n.x2,n.y2,t),i=r.x,o=r.y,a=pt(et(),it(i,o,0),e?this.getWorldTransform():this.getLocalTransform());return new Pr(a[0],a[1])},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getTotalLength=function(){var t=this.parsedStyle;return Vn(t.x1,t.y1,t.x2,t.y2)},e}(Bs),$s=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:er.PATH,style:Es.enableCSSParsing?i({d:"",miterLimit:""},r):i({},r),initialParsedStyle:Es.enableCSSParsing?null:{miterLimit:4,d:i({},Ei)}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd,l=s.markerMid;return u&&Ps(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),l&&Ps(l)&&n.placeMarkerMid(l),c&&Ps(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"d"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Ps(r)&&(this.markerStartAngle=0,r.remove()),i&&Ps(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&Ps(r)&&(this.markerEndAngle=0,r.remove()),i&&Ps(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=t?n:r;if(a&&Ps(a)){var s,u,l,h,d,f,p;if(t){var g=c(this.getStartTangent(),2),m=g[0];h=(y=g[1])[0],d=y[1],u=m[0]-y[0],l=m[1]-y[1],f=i||0,p=this.markerStartAngle}else{var y,v=c(this.getEndTangent(),2);m=v[0];h=(y=v[1])[0],d=y[1],u=m[0]-y[0],l=m[1]-y[1],f=o||0,p=this.markerEndAngle}s=Math.atan2(l,u),a.setLocalEulerAngles(180*s/Math.PI+p),a.setLocalPosition(h+Math.cos(s)*f,d+Math.sin(s)*f)}},e.prototype.placeMarkerMid=function(t){var e=this.parsedStyle.d.segments;if(this.markerMidList.forEach((function(t){t.remove()})),t&&Ps(t))for(var n=1;n<e.length-1;n++){var r=c(e[n].currentPoint,2),i=r[0],o=r[1],a=1===n?t:t.cloneNode(!0);this.markerMidList.push(a),this.appendChild(a),a.setLocalPosition(i,o)}},e.prototype.getTotalLength=function(){return ro(this)},e.prototype.getPointAtLength=function(t,e){void 0===e&&(e=!1);var n=function(t,e,n){return Je(t,e,i(i({},n),{bbox:!1,length:!0})).point}(this.parsedStyle.d.absolutePath,t),r=n.x,o=n.y,a=pt(et(),it(r,o,0),e?this.getWorldTransform():this.getLocalTransform());return new Pr(a[0],a[1])},e.prototype.getPoint=function(t,e){return void 0===e&&(e=!1),this.getPointAtLength(t*ro(this),e)},e.prototype.getStartTangent=function(){var t=this.parsedStyle.d.segments,e=[];if(t.length>1){var n=t[0].currentPoint,r=t[1].currentPoint,i=t[1].startTangent;e=[],i?(e.push([n[0]-i[0],n[1]-i[1]]),e.push([n[0],n[1]])):(e.push([r[0],r[1]]),e.push([n[0],n[1]]))}return e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.d.segments,e=t.length,n=[];if(e>1){var r=t[e-2].currentPoint,i=t[e-1].currentPoint,o=t[e-1].endTangent;n=[],o?(n.push([i[0]-o[0],i[1]-o[1]]),n.push([i[0],i[1]])):(n.push([r[0],r[1]]),n.push([i[0],i[1]]))}return n},e}(Bs),qs=function(t){function e(e){void 0===e&&(e={});var n=this,r=e.style,a=o(e,["style"]);(n=t.call(this,i({type:er.POLYGON,style:Es.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!0},r):i({},r),initialParsedStyle:Es.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!0}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd,l=s.markerMid;return u&&Ps(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),l&&Ps(l)&&n.placeMarkerMid(l),c&&Ps(c)&&(n.markerEndAngle=c.getLocalEulerAngles(),n.appendChild(c)),n.transformMarker(!0),n.transformMarker(!1),n}return r(e,t),e.prototype.attributeChangedCallback=function(t,e,n,r,i){"points"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Ps(r)&&(this.markerStartAngle=0,r.remove()),i&&Ps(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&Ps(r)&&(this.markerEndAngle=0,r.remove()),i&&Ps(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)},e.prototype.transformMarker=function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,a=(e.points||{}).points,s=t?n:r;if(s&&Ps(s)&&a){var u,c,l,h,d,f,p;if(h=a[0][0],d=a[0][1],t)c=a[1][0]-a[0][0],l=a[1][1]-a[0][1],f=i||0,p=this.markerStartAngle;else{var g=a.length;this.parsedStyle.isClosed?(c=a[g-1][0]-a[0][0],l=a[g-1][1]-a[0][1]):(h=a[g-1][0],d=a[g-1][1],c=a[g-2][0]-a[g-1][0],l=a[g-2][1]-a[g-1][1]),f=o||0,p=this.markerEndAngle}u=Math.atan2(l,c),s.setLocalEulerAngles(180*u/Math.PI+p),s.setLocalPosition(h+Math.cos(u)*f,d+Math.sin(u)*f)}},e.prototype.placeMarkerMid=function(t){var e=(this.parsedStyle.points||{}).points;if(this.markerMidList.forEach((function(t){t.remove()})),this.markerMidList=[],t&&Ps(t)&&e)for(var n=1;n<(this.parsedStyle.isClosed?e.length:e.length-1);n++){var r=e[n][0],i=e[n][1],o=1===n?t:t.cloneNode(!0);this.markerMidList.push(o),this.appendChild(o),o.setLocalPosition(r,i)}},e}(Bs),Ys=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:er.POLYLINE,style:Es.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!1},n):i({},n),initialParsedStyle:Es.enableCSSParsing?null:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!1}},r))||this}return r(e,t),e.prototype.getTotalLength=function(){return 0===(t=this).parsedStyle.points.totalLength&&(t.parsedStyle.points.totalLength=Kn(t.parsedStyle.points.points)),t.parsedStyle.points.totalLength;var t},e.prototype.getPointAtLength=function(t,e){return void 0===e&&(e=!1),this.getPoint(t/this.getTotalLength(),e)},e.prototype.getPoint=function(t,e){void 0===e&&(e=!1);var n=this.parsedStyle.points.points;if(0===this.parsedStyle.points.segments.length){var r,i,o=[],a=0,s=this.getTotalLength();n.forEach((function(t,e){n[e+1]&&((r=[0,0])[0]=a/s,i=Vn(t[0],t[1],n[e+1][0],n[e+1][1]),a+=i,r[1]=a/s,o.push(r))})),this.parsedStyle.points.segments=o}var u=0,c=0;this.parsedStyle.points.segments.forEach((function(e,n){t>=e[0]&&t<=e[1]&&(u=(t-e[0])/(e[1]-e[0]),c=n)}));var l=Wn(n[c][0],n[c][1],n[c+1][0],n[c+1][1],u),h=l.x,d=l.y,f=pt(et(),it(h,d,0),e?this.getWorldTransform():this.getLocalTransform());return new Pr(f[0],f[1])},e.prototype.getStartTangent=function(){var t=this.parsedStyle.points.points,e=[];return e.push([t[1][0],t[1][1]]),e.push([t[0][0],t[0][1]]),e},e.prototype.getEndTangent=function(){var t=this.parsedStyle.points.points,e=t.length-1,n=[];return n.push([t[e-1][0],t[e-1][1]]),n.push([t[e][0],t[e][1]]),n},e}(qs),Ks=function(t){function e(e){return void 0===e&&(e={}),t.call(this,i({type:er.RECT},e))||this}return r(e,t),e}(Bs),Xs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:er.TEXT,style:Es.enableCSSParsing?i({x:"",y:"",text:"",fontSize:"",fontFamily:"",fontStyle:"",fontWeight:"",fontVariant:"",textAlign:"",textBaseline:"",textTransform:"",fill:"black",letterSpacing:"",lineHeight:"",miterLimit:"",wordWrap:!1,wordWrapWidth:0,leading:0,dx:"",dy:""},n):i({fill:"black"},n)},r))||this}return r(e,t),e.prototype.getComputedTextLength=function(){var t;return this.getGeometryBounds(),(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.maxLineWidth)||0},e.prototype.getLineBoundingRects=function(){var t;return this.getGeometryBounds(),(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.lineMetrics)||[]},e.prototype.isOverflowing=function(){return this.getGeometryBounds(),!!this.parsedStyle.isOverflowing},e}(Bs),Zs=function(){function t(){this.registry={},this.define(er.CIRCLE,zs),this.define(er.ELLIPSE,Gs),this.define(er.RECT,Ks),this.define(er.IMAGE,Hs),this.define(er.LINE,Us),this.define(er.GROUP,Vs),this.define(er.PATH,$s),this.define(er.POLYGON,qs),this.define(er.POLYLINE,Ys),this.define(er.TEXT,Xs),this.define(er.HTML,Ws)}return t.prototype.define=function(t,e){this.registry[t]=e},t.prototype.get=function(t){return this.registry[t]},t}(),Qs=function(t){function e(){var e=t.call(this)||this;e.defaultView=null,e.ownerDocument=null,e.nodeName="document";try{e.timeline=new Es.AnimationTimeline(e)}catch(t){}var n={};return zo.forEach((function(t){var e=t.n,r=t.inh,i=t.d;r&&i&&(n[e]=ei(i)?i(er.GROUP):i)})),e.documentElement=new Vs({id:"g-root",style:n}),e.documentElement.ownerDocument=e,e.documentElement.parentNode=e,e.childNodes=[e.documentElement],e}return r(e,t),Object.defineProperty(e.prototype,"children",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){return this.firstChild},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){return this.lastChild},enumerable:!1,configurable:!0}),e.prototype.createElement=function(t,e){if("svg"===t)return this.documentElement;var n=this.defaultView.customElements.get(t);n||(console.warn("Unsupported tagName: ",t),n="tspan"===t?Xs:Vs);var r=new n(e);return r.ownerDocument=this,r},e.prototype.createElementNS=function(t,e,n){return this.createElement(e,n)},e.prototype.cloneNode=function(t){throw new Error(_r)},e.prototype.destroy=function(){try{this.documentElement.destroyChildren(),this.timeline.destroy()}catch(t){}},e.prototype.elementsFromBBox=function(t,e,n,r){var i=this.defaultView.context.rBushRoot.search({minX:t,minY:e,maxX:n,maxY:r}),o=[];return i.forEach((function(t){var e=t.displayObject,n=e.parsedStyle.pointerEvents,r=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(void 0===n?"auto":n);(!r||r&&e.isVisible())&&!e.isCulled()&&e.isInteractive()&&o.push(e)})),o.sort((function(t,e){return e.sortable.renderOrder-t.sortable.renderOrder})),o},e.prototype.elementFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return null;var u=this.defaultView.viewport2Client({x:r,y:i}),c=u.x,l=u.y,h=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:l},picked:[]}).picked;return h&&h[0]||this.documentElement},e.prototype.elementFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,u,c,l,h,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,u=o.height,r<0||i<0||r>a||i>u?[2,null]:(c=this.defaultView.viewport2Client({x:r,y:i}),l=c.x,h=c.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:l,clientY:h},picked:[]})]);case 1:return[2,(d=s.sent().picked)&&d[0]||this.documentElement]}}))}))},e.prototype.elementsFromPointSync=function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,s=o.height;if(r<0||i<0||r>a||i>s)return[];var u=this.defaultView.viewport2Client({x:r,y:i}),c=u.x,l=u.y,h=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:l},picked:[]}).picked;return h[h.length-1]!==this.documentElement&&h.push(this.documentElement),h},e.prototype.elementsFromPoint=function(t,e){return a(this,void 0,void 0,(function(){var n,r,i,o,a,u,c,l,h,d;return s(this,(function(s){switch(s.label){case 0:return n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),a=o.width,u=o.height,r<0||i<0||r>a||i>u?[2,[]]:(c=this.defaultView.viewport2Client({x:r,y:i}),l=c.x,h=c.y,[4,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:l,clientY:h},picked:[]})]);case 1:return(d=s.sent().picked)[d.length-1]!==this.documentElement&&d.push(this.documentElement),[2,d]}}))}))},e.prototype.appendChild=function(t,e){throw new Error(Rr)},e.prototype.insertBefore=function(t,e){throw new Error(Rr)},e.prototype.removeChild=function(t,e){throw new Error(Rr)},e.prototype.replaceChild=function(t,e,n){throw new Error(Rr)},e.prototype.append=function(){throw new Error(Rr)},e.prototype.prepend=function(){throw new Error(Rr)},e.prototype.getElementById=function(t){return this.documentElement.getElementById(t)},e.prototype.getElementsByName=function(t){return this.documentElement.getElementsByName(t)},e.prototype.getElementsByTagName=function(t){return this.documentElement.getElementsByTagName(t)},e.prototype.getElementsByClassName=function(t){return this.documentElement.getElementsByClassName(t)},e.prototype.querySelector=function(t){return this.documentElement.querySelector(t)},e.prototype.querySelectorAll=function(t){return this.documentElement.querySelectorAll(t)},e.prototype.find=function(t){return this.documentElement.find(t)},e.prototype.findAll=function(t){return this.documentElement.findAll(t)},e}(rs),Js=function(){function t(t){this.strategies=t}return t.prototype.apply=function(e){var n=e.camera,r=e.renderingService,i=e.renderingContext,o=this.strategies;r.hooks.cull.tap(t.tag,(function(t){if(t){var e=t.cullable;return 0===o.length?e.visible=i.unculledEntities.indexOf(t.entity)>-1:e.visible=o.every((function(e){return e.isVisible(n,t)})),!t.isCulled()&&t.isVisible()?t:(t.dispatchEvent(new es(as.CULLED)),null)}return t})),r.hooks.afterRender.tap(t.tag,(function(t){t.cullable.visibilityPlaneMask=-1}))},t.tag="Culling",t}(),tu=function(){function t(){var t=this;this.autoPreventDefault=!1,this.rootPointerEvent=new Ja(null),this.rootWheelEvent=new ts(null),this.onPointerMove=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView;if(!a.supportsTouchEvents||"touch"!==e.pointerType){var s=t.normalizeToPointerEvent(e,a);try{for(var c=u(s),l=c.next();!l.done;l=c.next()){var h=l.value,d=t.bootstrapEvent(t.rootPointerEvent,h,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}},this.onClick=function(e){var n,r,i,o,a=null===(o=null===(i=t.context.renderingContext.root)||void 0===i?void 0:i.ownerDocument)||void 0===o?void 0:o.defaultView,s=t.normalizeToPointerEvent(e,a);try{for(var c=u(s),l=c.next();!l.done;l=c.next()){var h=l.value,d=t.bootstrapEvent(t.rootPointerEvent,h,a,e);t.context.eventService.mapEvent(d)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}t.setCursor(t.context.eventService.cursor)}}return t.prototype.apply=function(e){var n=this;this.context=e;var r=e.renderingService,i=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler((function(t){return n.context.renderingService.hooks.pickSync.call({position:t,picked:[],topmost:!0}).picked[0]||null})),r.hooks.pointerWheel.tap(t.tag,(function(t){var e=n.normalizeWheelEvent(t);n.context.eventService.mapEvent(e)})),r.hooks.pointerDown.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.normalizeToPointerEvent(t,i);if(n.autoPreventDefault&&o[0].isNormalized)(t.cancelable||!("cancelable"in t))&&t.preventDefault();try{for(var a=u(o),s=a.next();!s.done;s=a.next()){var c=s.value,l=n.bootstrapEvent(n.rootPointerEvent,c,i,t);n.context.eventService.mapEvent(l)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerUp.tap(t.tag,(function(t){var e,r;if(!i.supportsTouchEvents||"touch"!==t.pointerType){var o=n.context.contextService.getDomElement(),a=n.context.eventService.isNativeEventFromCanvas(o,t)?"":"outside",s=n.normalizeToPointerEvent(t,i);try{for(var c=u(s),l=c.next();!l.done;l=c.next()){var h=l.value,d=n.bootstrapEvent(n.rootPointerEvent,h,i,t);d.type+=a,n.context.eventService.mapEvent(d)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}})),r.hooks.pointerMove.tap(t.tag,this.onPointerMove),r.hooks.pointerOver.tap(t.tag,this.onPointerMove),r.hooks.pointerOut.tap(t.tag,this.onPointerMove),r.hooks.click.tap(t.tag,this.onClick),r.hooks.pointerCancel.tap(t.tag,(function(t){var e,r,o=n.normalizeToPointerEvent(t,i);try{for(var a=u(o),s=a.next();!s.done;s=a.next()){var c=s.value,l=n.bootstrapEvent(n.rootPointerEvent,c,i,t);n.context.eventService.mapEvent(l)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}n.setCursor(n.context.eventService.cursor)}))},t.prototype.bootstrapEvent=function(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);var i=this.context.eventService.client2Viewport({x:e.clientX,y:e.clientY}),o=i.x,a=i.y;t.viewport.x=o,t.viewport.y=a;var s=this.context.eventService.viewport2Canvas(t.viewport),u=s.x,c=s.y;return t.canvas.x=u,t.canvas.y=c,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=pa[t.type]||t.type),t},t.prototype.normalizeWheelEvent=function(t){var e=this.rootWheelEvent;this.transferMouseData(e,t),e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ;var n=this.context.eventService.client2Viewport({x:t.clientX,y:t.clientY}),r=n.x,i=n.y;e.viewport.x=r,e.viewport.y=i;var o=this.context.eventService.viewport2Canvas(e.viewport),a=o.x,s=o.y;return e.canvas.x=a,e.canvas.y=s,e.global.copyFrom(e.canvas),e.offset.copyFrom(e.canvas),e.nativeEvent=t,e.type=t.type,e},t.prototype.transferMouseData=function(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=ga.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null},t.prototype.setCursor=function(t){this.context.contextService.applyCursorStyle(t||this.context.config.cursor||"default")},t.prototype.normalizeToPointerEvent=function(t,e){var n=[];if(e.isTouchEvent(t))for(var r=0;r<t.changedTouches.length;r++){var i=t.changedTouches[r];ie(i.button)&&(i.button=0),ie(i.buttons)&&(i.buttons=1),ie(i.isPrimary)&&(i.isPrimary=1===t.touches.length&&"touchstart"===t.type),ie(i.width)&&(i.width=i.radiusX||1),ie(i.height)&&(i.height=i.radiusY||1),ie(i.tiltX)&&(i.tiltX=0),ie(i.tiltY)&&(i.tiltY=0),ie(i.pointerType)&&(i.pointerType="touch"),ie(i.pointerId)&&(i.pointerId=i.identifier||0),ie(i.pressure)&&(i.pressure=i.force||.5),ie(i.twist)&&(i.twist=0),ie(i.tangentialPressure)&&(i.tangentialPressure=0),i.isNormalized=!0,i.type=t.type,n.push(i)}else if(e.isMouseEvent(t)){var o=t;ie(o.isPrimary)&&(o.isPrimary=!0),ie(o.width)&&(o.width=1),ie(o.height)&&(o.height=1),ie(o.tiltX)&&(o.tiltX=0),ie(o.tiltY)&&(o.tiltY=0),ie(o.pointerType)&&(o.pointerType="mouse"),ie(o.pointerId)&&(o.pointerId=1),ie(o.pressure)&&(o.pressure=.5),ie(o.twist)&&(o.twist=0),ie(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,n.push(o)}else n.push(t);return n},t.tag="Event",t}(),eu=[er.CIRCLE,er.ELLIPSE,er.IMAGE,er.RECT,er.LINE,er.POLYLINE,er.POLYGON,er.TEXT,er.PATH,er.HTML],nu=function(){function t(){}return t.prototype.isVisible=function(t,e){var n,r,i=e.cullable;if(!i.enable)return!0;var o=e.getRenderBounds();if(Sr.isEmpty(o))return!1;var a=t.getFrustum(),s=null===(r=null===(n=e.parentNode)||void 0===n?void 0:n.cullable)||void 0===r?void 0:r.visibilityPlaneMask;return i.visibilityPlaneMask=this.computeVisibilityWithPlaneMask(e,o,s||Mr.INDETERMINATE,a.planes),i.visible=i.visibilityPlaneMask!==Mr.OUTSIDE,i.visible},t.prototype.computeVisibilityWithPlaneMask=function(t,e,n,r){if(n===Mr.OUTSIDE||n===Mr.INSIDE)return n;for(var i=Mr.INSIDE,o=eu.indexOf(t.nodeName)>-1,a=0,s=r.length;a<s;++a){var u=1<<a;if(n&u&&(!o||4!==a&&5!==a)){var c=r[a],l=c.normal,h=c.distance;if(ht(l,e.getPositiveFarPoint(r[a]))+h<0)return Mr.OUTSIDE;ht(l,e.getNegativeFarPoint(r[a]))+h<0&&(i|=u)}}return i},t}(),ru=function(){function t(){this.toSync=new Set,this.isFirstTimeRendering=!0,this.syncing=!1,this.isFirstTimeRenderingFinished=!1}return t.prototype.apply=function(e){var n,r=this,i=e.renderingService,o=e.renderingContext,a=e.rBushRoot,s=o.root.ownerDocument.defaultView;this.rBush=a;var u=function(t){t.target.renderable.dirty=!0,i.dirtify()},c=function(t){var e=t.detail.affectChildren,n=t.target;e&&n.forEach((function(t){r.toSync.add(t)}));for(var o=n;o;)o.renderable&&r.toSync.add(o),o=o.parentElement;i.dirtify()},l=function(t){var e=t.target;Es.enableSizeAttenuation&&Es.styleValueRegistry.updateSizeAttenuation(e,s.getCamera().getZoom()),Es.enableCSSParsing&&Es.styleValueRegistry.recalc(e),Es.sceneGraphService.dirtifyToRoot(e),i.dirtify()},h=function(t){var e=t.target,n=e.rBushNode;n.aabb&&r.rBush.remove(n.aabb),r.toSync.delete(e),Es.sceneGraphService.dirtifyToRoot(e),i.dirtify()};i.hooks.init.tap(t.tag,(function(){s.addEventListener(as.MOUNTED,l),s.addEventListener(as.UNMOUNTED,h),s.addEventListener(as.ATTR_MODIFIED,u),s.addEventListener(as.BOUNDS_CHANGED,c)})),i.hooks.destroy.tap(t.tag,(function(){s.removeEventListener(as.MOUNTED,l),s.removeEventListener(as.UNMOUNTED,h),s.removeEventListener(as.ATTR_MODIFIED,u),s.removeEventListener(as.BOUNDS_CHANGED,c),r.toSync.clear()}));var d=null!==(n=Es.globalThis.requestIdleCallback)&&void 0!==n?n:ka.bind(Es.globalThis);i.hooks.endFrame.tap(t.tag,(function(){r.isFirstTimeRendering?(r.isFirstTimeRendering=!1,r.syncing=!0,d((function(){r.syncRTree(!0),r.isFirstTimeRenderingFinished=!0}))):r.syncRTree()}))},t.prototype.syncRTree=function(t){var e=this;if(void 0===t&&(t=!1),t||!this.syncing&&0!==this.toSync.size){this.syncing=!0;var n=[];Array.from(this.toSync).filter((function(t){return t.isConnected})).forEach((function(r){var i=r.rBushNode;i&&i.aabb&&e.rBush.remove(i.aabb);var o=r.getRenderBounds();if(o){var a=r.renderable;t&&(a.dirtyRenderBounds||(a.dirtyRenderBounds=new Sr),a.dirtyRenderBounds.update(o.center,o.halfExtents));var s=c(o.getMin(),2),u=s[0],l=s[1],h=c(o.getMax(),2),d=h[0],f=h[1];i.aabb||(i.aabb={}),i.aabb.displayObject=r,i.aabb.minX=u,i.aabb.minY=l,i.aabb.maxX=d,i.aabb.maxY=f}i.aabb&&(isNaN(i.aabb.maxX)||isNaN(i.aabb.maxX)||isNaN(i.aabb.minX)||isNaN(i.aabb.minY)||n.push(i.aabb))})),this.rBush.load(n),n.length=0,this.toSync.clear(),this.syncing=!1}},t.tag="Prepare",t}();!function(t){t.READY="ready",t.BEFORE_RENDER="beforerender",t.RERENDER="rerender",t.AFTER_RENDER="afterrender",t.BEFORE_DESTROY="beforedestroy",t.AFTER_DESTROY="afterdestroy",t.RESIZE="resize",t.DIRTY_RECTANGLE="dirtyrectangle",t.RENDERER_CHANGED="rendererchanged"}(Os||(Os={}));var iu=new es(as.MOUNTED),ou=new es(as.UNMOUNTED),au=new es(Os.BEFORE_RENDER),su=new es(Os.RERENDER),uu=new es(Os.AFTER_RENDER),cu=function(t){function e(e){var n=t.call(this)||this;n.Element=Bs,n.inited=!1,n.context={},n.document=new Qs,n.document.defaultView=n,n.customElements=new Zs;var r=e.container,i=e.canvas,o=e.offscreenCanvas,a=e.width,s=e.height,u=e.devicePixelRatio,c=e.renderer,l=e.background,h=e.cursor,d=e.document,f=e.requestAnimationFrame,p=e.cancelAnimationFrame,g=e.createImage,m=e.supportsPointerEvents,y=e.supportsTouchEvents,v=e.supportsCSSTransform,b=e.supportsMutipleCanvasesInOneContainer,x=e.useNativeClickEvent,w=e.alwaysTriggerPointerEventOnCanvas,E=e.isTouchEvent,M=e.isMouseEvent;b||function(t,e){if(t){var n="string"==typeof t?t:t.id||ua++;sa[n]&&sa[n].destroy(),sa[n]=e}}(r,n);var S=a,N=s,k=u;return i&&(k=(k=u||ca&&window.devicePixelRatio||1)>=1?Math.ceil(k):1,S=a||function(t){var e=fa(t,"width");return"auto"===e?t.offsetWidth:parseFloat(e)}(i)||i.width/k,N=s||function(t){var e=fa(t,"height");return"auto"===e?t.offsetHeight:parseFloat(e)}(i)||i.height/k),o&&(Es.offscreenCanvas=o),n.devicePixelRatio=k,n.requestAnimationFrame=null!=f?f:ka.bind(Es.globalThis),n.cancelAnimationFrame=null!=p?p:Ca.bind(Es.globalThis),n.supportsTouchEvents=null!=y?y:"ontouchstart"in Es.globalThis,n.supportsPointerEvents=null!=m?m:!!Es.globalThis.PointerEvent,n.isTouchEvent=null!=E?E:function(t){return n.supportsTouchEvents&&t instanceof Es.globalThis.TouchEvent},n.isMouseEvent=null!=M?M:function(t){return!Es.globalThis.MouseEvent||t instanceof Es.globalThis.MouseEvent&&(!n.supportsPointerEvents||!(t instanceof Es.globalThis.PointerEvent))},n.initRenderingContext({container:r,canvas:i,width:S,height:N,renderer:c,offscreenCanvas:o,devicePixelRatio:k,cursor:h||"default",background:l||"transparent",createImage:g,document:d,supportsCSSTransform:v,useNativeClickEvent:x,alwaysTriggerPointerEventOnCanvas:w}),n.initDefaultCamera(S,N,c.clipSpaceNearZ),n.initRenderer(c,!0),n}return r(e,t),e.prototype.initRenderingContext=function(t){this.context.config=t,this.context.renderingContext={root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set,force:!1,dirty:!1}},e.prototype.initDefaultCamera=function(t,e,n){var r=this,i=new Es.CameraContribution;i.clipSpaceNearZ=n,i.setType(kr.EXPLORING,Cr.DEFAULT).setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0).setOrthographic(t/-2,t/2,e/2,e/-2,.1,1e3),i.canvas=this,i.eventEmitter.on(zr,(function(){r.context.renderingContext.renderReasons.add(Xa.CAMERA_CHANGED),Es.enableSizeAttenuation&&r.getConfig().renderer.getConfig().enableSizeAttenuation&&r.updateSizeAttenuation()})),this.context.camera=i},e.prototype.updateSizeAttenuation=function(){var t=this.getCamera().getZoom();this.document.documentElement.forEach((function(e){Es.styleValueRegistry.updateSizeAttenuation(e,t)}))},e.prototype.getConfig=function(){return this.context.config},e.prototype.getRoot=function(){return this.document.documentElement},e.prototype.getCamera=function(){return this.context.camera},e.prototype.getContextService=function(){return this.context.contextService},e.prototype.getEventService=function(){return this.context.eventService},e.prototype.getRenderingService=function(){return this.context.renderingService},e.prototype.getRenderingContext=function(){return this.context.renderingContext},e.prototype.getStats=function(){return this.getRenderingService().getStats()},Object.defineProperty(e.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(this.readyPromise=new Promise((function(e){t.resolveReadyPromise=function(){e(t)}})),this.inited&&this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),e.prototype.destroy=function(t,e){(void 0===t&&(t=!0),void 0===e&&(e=!1),e||this.dispatchEvent(new es(Os.BEFORE_DESTROY)),this.frameId)&&(this.getConfig().cancelAnimationFrame||cancelAnimationFrame)(this.frameId);var n=this.getRoot();this.unmountChildren(n),t&&(this.document.destroy(),this.getEventService().destroy()),this.getRenderingService().destroy(),this.getContextService().destroy(),t&&this.context.rBushRoot&&(this.context.rBushRoot.clear(),this.context.rBushRoot=null,this.context.renderingContext.root=null),e||this.dispatchEvent(new es(Os.AFTER_DESTROY))},e.prototype.changeSize=function(t,e){this.resize(t,e)},e.prototype.resize=function(t,e){var n=this.context.config;n.width=t,n.height=e,this.getContextService().resize(t,e);var r=this.context.camera,i=r.getProjectionMode();r.setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0),i===Tr.ORTHOGRAPHIC?r.setOrthographic(t/-2,t/2,e/2,e/-2,r.getNear(),r.getFar()):r.setAspect(t/e),this.dispatchEvent(new es(Os.RESIZE,{width:t,height:e}))},e.prototype.appendChild=function(t,e){return this.document.documentElement.appendChild(t,e)},e.prototype.insertBefore=function(t,e){return this.document.documentElement.insertBefore(t,e)},e.prototype.removeChild=function(t){return this.document.documentElement.removeChild(t)},e.prototype.removeChildren=function(){this.document.documentElement.removeChildren()},e.prototype.destroyChildren=function(){this.document.documentElement.destroyChildren()},e.prototype.render=function(t){var e=this;this.dispatchEvent(au),this.getRenderingService().render(this.getConfig(),t,(function(){e.dispatchEvent(su)})),this.dispatchEvent(uu)},e.prototype.run=function(){var t=this,e=function(n,r){t.render(r),t.frameId=t.requestAnimationFrame(e)};e()},e.prototype.initRenderer=function(t,e){var n=this;if(void 0===e&&(e=!1),!t)throw new Error("Renderer is required.");this.inited=!1,this.readyPromise=void 0,this.context.rBushRoot=new rr,this.context.renderingPlugins=[],this.context.renderingPlugins.push(new tu,new ru,new Js([new nu])),this.loadRendererContainerModule(t),this.context.contextService=new this.context.ContextService(i(i({},Es),this.context)),this.context.renderingService=new ss(Es,this.context),this.context.eventService=new is(Es,this.context),this.context.eventService.init(),this.context.contextService.init?(this.context.contextService.init(),this.initRenderingService(t,e,!0)):this.context.contextService.initAsync().then((function(){n.initRenderingService(t,e)}))},e.prototype.initRenderingService=function(t,e,n){var r=this;void 0===e&&(e=!1),void 0===n&&(n=!1),this.context.renderingService.init((function(){r.inited=!0,e?(n?r.requestAnimationFrame((function(){r.dispatchEvent(new es(Os.READY))})):r.dispatchEvent(new es(Os.READY)),r.readyPromise&&r.resolveReadyPromise()):r.dispatchEvent(new es(Os.RENDERER_CHANGED)),e||r.getRoot().forEach((function(t){var e=t.renderable;e&&(e.renderBoundsDirty=!0,e.boundsDirty=!0,e.dirty=!0)})),r.mountChildren(r.getRoot()),t.getConfig().enableAutoRendering&&r.run()}))},e.prototype.loadRendererContainerModule=function(t){var e=this;t.getPlugins().forEach((function(t){t.context=e.context,t.init(Es)}))},e.prototype.setRenderer=function(t){var e=this.getConfig();if(e.renderer!==t){var n=e.renderer;e.renderer=t,this.destroy(!1,!0),l([],c(null==n?void 0:n.getPlugins()),!1).reverse().forEach((function(t){t.destroy(Es)})),this.initRenderer(t)}},e.prototype.setCursor=function(t){this.getConfig().cursor=t,this.getContextService().applyCursorStyle(t)},e.prototype.unmountChildren=function(t){var e=this;t.childNodes.forEach((function(t){e.unmountChildren(t)})),this.inited&&(t.isMutationObserved?t.dispatchEvent(ou):(ou.target=t,this.dispatchEvent(ou,!0)),t!==this.document.documentElement&&(t.ownerDocument=null),t.isConnected=!1),t.isCustomElement&&t.disconnectedCallback&&t.disconnectedCallback()},e.prototype.mountChildren=function(t){var e=this;this.inited?t.isConnected||(t.ownerDocument=this.document,t.isConnected=!0,t.isMutationObserved?t.dispatchEvent(iu):(iu.target=t,this.dispatchEvent(iu,!0))):console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.","appended child: ",t.nodeName),t.childNodes.forEach((function(t){e.mountChildren(t)})),t.isCustomElement&&t.connectedCallback&&t.connectedCallback()},e.prototype.client2Viewport=function(t){return this.getEventService().client2Viewport(t)},e.prototype.viewport2Client=function(t){return this.getEventService().viewport2Client(t)},e.prototype.viewport2Canvas=function(t){return this.getEventService().viewport2Canvas(t)},e.prototype.canvas2Viewport=function(t){return this.getEventService().canvas2Viewport(t)},e.prototype.getPointByClient=function(t,e){return this.client2Viewport({x:t,y:e})},e.prototype.getClientByPoint=function(t,e){return this.viewport2Client({x:t,y:e})},e}(ns),lu=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.landmarks=[],e}return r(e,t),e.prototype.rotate=function(t,e,n){if(this.relElevation=lr(e),this.relAzimuth=lr(t),this.relRoll=lr(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===kr.EXPLORING){var r=wt(xt(),[1,0,0],dr((this.rotateWorld?1:-1)*this.relElevation)),i=wt(xt(),[0,1,0],dr((this.rotateWorld?1:-1)*this.relAzimuth)),o=wt(xt(),[0,0,1],dr(this.relRoll)),a=Et(xt(),i,r);a=Et(xt(),a,o);var s=H(x(),a);A(this.matrix,this.matrix,[0,0,-this.distance]),T(this.matrix,this.matrix,s),A(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===kr.ORBITING||this.type===kr.EXPLORING?this._getPosition():this.type===kr.TRACKING&&this._getFocalPoint(),this._update(),this},e.prototype.pan=function(t,e){var n=hr(t,e,0),r=nt(this.position);return st(r,r,ct(et(),this.right,n[0])),st(r,r,ct(et(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this},e.prototype.dolly=function(t){var e=this.forward,n=nt(this.position),r=this.dollyingStep,i=this.distance+t*this.dollyingStep;return r=Math.max(Math.min(i,this.maxDistance),this.minDistance)-this.distance,n[0]+=r*e[0],n[1]+=r*e[1],n[2]+=r*e[2],this._setPosition(n),this.type===kr.ORBITING||this.type===kr.EXPLORING?this._getDistance():this.type===kr.TRACKING&&st(this.focalPoint,n,this.distanceVector),this.triggerUpdate(),this},e.prototype.cancelLandmarkAnimation=function(){void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID)},e.prototype.createLandmark=function(t,e){var n,r,i,o;void 0===e&&(e={});var a=e.position,s=void 0===a?this.position:a,u=e.focalPoint,c=void 0===u?this.focalPoint:u,l=e.roll,h=e.zoom,d=new Es.CameraContribution;d.setType(this.type,void 0),d.setPosition(s[0],null!==(n=s[1])&&void 0!==n?n:this.position[1],null!==(r=s[2])&&void 0!==r?r:this.position[2]),d.setFocalPoint(c[0],null!==(i=c[1])&&void 0!==i?i:this.focalPoint[1],null!==(o=c[2])&&void 0!==o?o:this.focalPoint[2]),d.setRoll(null!=l?l:this.roll),d.setZoom(null!=h?h:this.zoom);var f={name:t,matrix:w(d.getWorldTransform()),right:nt(d.right),up:nt(d.up),forward:nt(d.forward),position:nt(d.getPosition()),focalPoint:nt(d.getFocalPoint()),distanceVector:nt(d.getDistanceVector()),distance:d.getDistance(),dollyingStep:d.getDollyingStep(),azimuth:d.getAzimuth(),elevation:d.getElevation(),roll:d.getRoll(),relAzimuth:d.relAzimuth,relElevation:d.relElevation,relRoll:d.relRoll,zoom:d.getZoom()};return this.landmarks.push(f),f},e.prototype.gotoLandmark=function(t,e){var n=this;void 0===e&&(e={});var r=Vt(t)?this.landmarks.find((function(e){return e.name===t})):t;if(r){var i=$t(e)?{duration:e}:e,o=i.easing,a=void 0===o?"linear":o,s=i.duration,u=void 0===s?100:s,c=i.easingFunction,l=void 0===c?void 0:c,h=i.onfinish,d=void 0===h?void 0:h,f=i.onframe,p=void 0===f?void 0:f;if(0===u)return this.syncFromLandmark(r),void(d&&d());this.cancelLandmarkAnimation();var g,m=r.position,y=r.focalPoint,v=r.zoom,b=r.roll,x=l||Es.EasingFunction(a),w=function(){n.setFocalPoint(y),n.setPosition(m),n.setRoll(b),n.setZoom(v),n.computeMatrix(),n.triggerUpdate(),d&&d()},E=function(t){void 0===g&&(g=t);var e=t-g;if(e>u)w();else{var r,i,o=x(e/u),a=et(),s=et();ft(a,n.focalPoint,y,o),ft(s,n.position,m,o),i=n.roll*(1-o)+b*o,r=n.zoom*(1-o)+v*o,n.setFocalPoint(a),n.setPosition(s),n.setRoll(i),n.setZoom(r),mt(a,y)+mt(s,m)<=.01&&null==v&&null==b?w():(n.computeMatrix(),n.triggerUpdate(),e<u&&(p&&p(o),n.landmarkAnimationID=n.canvas.requestAnimationFrame(E)))}};this.canvas.requestAnimationFrame(E)}},e.prototype.syncFromLandmark=function(t){this.matrix=E(this.matrix,t.matrix),this.right=ot(this.right,t.right),this.up=ot(this.up,t.up),this.forward=ot(this.forward,t.forward),this.position=ot(this.position,t.position),this.focalPoint=ot(this.focalPoint,t.focalPoint),this.distanceVector=ot(this.distanceVector,t.distanceVector),this.azimuth=t.azimuth,this.elevation=t.elevation,this.roll=t.roll,this.relAzimuth=t.relAzimuth,this.relElevation=t.relElevation,this.relRoll=t.relRoll,this.dollyingStep=t.dollyingStep,this.distance=t.distance,this.zoom=t.zoom},e}(Gr);Es.CameraContribution=lu;var hu=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return r(e,t),e}(Za),du=0,fu=function(){function t(t,e){var n;this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=t,t.animation=this,this.timeline=e,this.id="".concat(du++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(n=this.effect)||void 0===n?void 0:n.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}return Object.defineProperty(t.prototype,"pending",{get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playState",{get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"finished",{get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentTime",{get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){var e;t=Number(t),isNaN(t)||(this.timeline.restart(),this._paused||null===this._startTime||(this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate),this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this)))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startTime",{get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isFinished",{get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalDuration",{get:function(){return this._totalDuration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_needsTick",{get:function(){return this.pending||"running"===this.playState||!this._finishedFlag},enumerable:!1,configurable:!0}),t.prototype.updatePromises=function(){var t=this.oldPlayState,e=this.pending?"pending":this.playState;return this.readyPromise&&e!==t&&("idle"===e?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===t?this.resolveReadyPromise():"pending"===e&&(this.readyPromise=void 0)),this.finishedPromise&&e!==t&&("idle"===e?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===e?this.resolveFinishedPromise():"finished"===t&&(this.finishedPromise=void 0)),this.oldPlayState=e,this.readyPromise||this.finishedPromise},t.prototype.play=function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()},t.prototype.pause=function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()},t.prototype.finish=function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())},t.prototype.cancel=function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new hu(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}},t.prototype.reverse=function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()},t.prototype.updatePlaybackRate=function(t){this.playbackRate=t},t.prototype.targetAnimations=function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()},t.prototype.markTarget=function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)},t.prototype.unmarkTarget=function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)},t.prototype.tick=function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))},t.prototype.rewind=function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}},t.prototype.persist=function(){throw new Error(_r)},t.prototype.addEventListener=function(t,e,n){throw new Error(_r)},t.prototype.removeEventListener=function(t,e,n){throw new Error(_r)},t.prototype.dispatchEvent=function(t){throw new Error(_r)},t.prototype.commitStyles=function(){throw new Error(_r)},t.prototype.ensureAlive=function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!!(null===(t=this.effect)||void 0===t?void 0:t.update(-1)):this._inEffect=!!(null===(e=this.effect)||void 0===e?void 0:e.update(this.currentTime)),this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))},t.prototype.tickCurrentTime=function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())},t.prototype.fireEvents=function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new hu(null,this,this.currentTime,t);setTimeout((function(){e.onfinish&&e.onfinish(n)}))}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new hu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}},t}(),pu=.1,gu="function"==typeof Float32Array,mu=function(t,e){return 1-3*e+3*t},yu=function(t,e){return 3*e-6*t},vu=function(t){return 3*t},bu=function(t,e,n){return((mu(e,n)*t+yu(e,n))*t+vu(e))*t},xu=function(t,e,n){return 3*mu(e,n)*t*t+2*yu(e,n)*t+vu(e)},wu=function(t,e,n,r){if(!(0<=t&&t<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=gu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=bu(o*pu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=pu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*pu,s=xu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=xu(e,n,r);if(0===o)return e;e-=(bu(e,n,r)-t)/o}return e}(e,a,t,n):0===s?a:function(t,e,n,r,i){var o,a,s=0;do{(o=bu(a=e+(n-e)/2,r,i)-t)>0?n=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,r,r+pu,t,n)};return function(t){return 0===t||1===t?t:bu(a(t),e,r)}},Eu=function(t){return Math.pow(t,2)},Mu=function(t){return Math.pow(t,3)},Su=function(t){return Math.pow(t,4)},Nu=function(t){return Math.pow(t,5)},ku=function(t){return Math.pow(t,6)},Cu=function(t){return 1-Math.cos(t*Math.PI/2)},Tu=function(t){return 1-Math.sqrt(1-t*t)},Au=function(t){return t*t*(3*t-2)},Pu=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},Ou=function(t,e){void 0===e&&(e=[]);var n=c(e,2),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?.5:o,s=Ut(Number(i),1,10),u=Ut(Number(a),.1,2);return 0===t||1===t?t:-s*Math.pow(2,10*(t-1))*Math.sin((t-1-u/(2*Math.PI)*Math.asin(1/s))*(2*Math.PI)/u)},_u=function(t,e,n){void 0===e&&(e=[]);var r=c(e,4),i=r[0],o=void 0===i?1:i,a=r[1],s=void 0===a?100:a,u=r[2],l=void 0===u?10:u,h=r[3],d=void 0===h?0:h;o=Ut(o,.1,1e3),s=Ut(s,.1,1e3),l=Ut(l,.1,1e3),d=Ut(d,.1,1e3);var f=Math.sqrt(s/o),p=l/(2*Math.sqrt(s*o)),g=p<1?f*Math.sqrt(1-p*p):0,m=p<1?(p*f-d)/g:-d+f,y=n?n*t/1e3:t;return y=p<1?Math.exp(-y*p*f)*(1*Math.cos(g*y)+m*Math.sin(g*y)):(1+m*y)*Math.exp(-y*f),0===t||1===t?t:1-y},Ru=function(t,e){void 0===e&&(e=[]);var n=c(e,2),r=n[0],i=void 0===r?10:r;return("start"==n[1]?Math.ceil:Math.floor)(Ut(t,0,1)*i)/i},Iu=function(t,e){void 0===e&&(e=[]);var n=c(e,4),r=n[0],i=n[1],o=n[2],a=n[3];return wu(r,i,o,a)(t)},Du=wu(.42,0,1,1),Lu=function(t){return function(e,n,r){return void 0===n&&(n=[]),1-t(1-e,n,r)}},ju=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},Bu=function(t){return function(e,n,r){return void 0===n&&(n=[]),e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},zu={steps:Ru,"step-start":function(t){return Ru(t,[1,"start"])},"step-end":function(t){return Ru(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Iu,ease:function(t){return Iu(t,[.25,.1,.25,1])},in:Du,out:Lu(Du),"in-out":ju(Du),"out-in":Bu(Du),"in-quad":Eu,"out-quad":Lu(Eu),"in-out-quad":ju(Eu),"out-in-quad":Bu(Eu),"in-cubic":Mu,"out-cubic":Lu(Mu),"in-out-cubic":ju(Mu),"out-in-cubic":Bu(Mu),"in-quart":Su,"out-quart":Lu(Su),"in-out-quart":ju(Su),"out-in-quart":Bu(Su),"in-quint":Nu,"out-quint":Lu(Nu),"in-out-quint":ju(Nu),"out-in-quint":Bu(Nu),"in-expo":ku,"out-expo":Lu(ku),"in-out-expo":ju(ku),"out-in-expo":Bu(ku),"in-sine":Cu,"out-sine":Lu(Cu),"in-out-sine":ju(Cu),"out-in-sine":Bu(Cu),"in-circ":Tu,"out-circ":Lu(Tu),"in-out-circ":ju(Tu),"out-in-circ":Bu(Tu),"in-back":Au,"out-back":Lu(Au),"in-out-back":ju(Au),"out-in-back":Bu(Au),"in-bounce":Pu,"out-bounce":Lu(Pu),"in-out-bounce":ju(Pu),"out-in-bounce":Bu(Pu),"in-elastic":Ou,"out-elastic":Lu(Ou),"in-out-elastic":ju(Ou),"out-in-elastic":Bu(Ou),spring:_u,"spring-in":_u,"spring-out":Lu(_u),"spring-in-out":ju(_u),"spring-out-in":Bu(_u)},Fu=function(t){return zu[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,(function(t){return"-".concat(t.toLowerCase())}))).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||zu.linear},Gu=function(t){return t},Vu=1,Wu=.5,Hu=0;function Uu(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var $u="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",qu=new RegExp("cubic-bezier\\("+$u+","+$u+","+$u+","+$u+"\\)"),Yu=/steps\(\s*(\d+)\s*\)/,Ku=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Xu(t){var e=qu.exec(t);if(e)return wu.apply(void 0,l([],c(e.slice(1).map(Number)),!1));var n=Yu.exec(t);if(n)return Uu(Number(n[1]),Hu);var r=Ku.exec(t);return r?Uu(Number(r[1]),{start:Vu,middle:Wu,end:Hu}[r[2]]):Fu(t)}function Zu(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}var Qu=0,Ju=1,tc=2,ec=3;function nc(t,e,n){var r=function(t,e,n){if(null===e)return Qu;var r=n.endTime;return e<Math.min(n.delay,r)?Ju:e>=Math.min(n.delay+t+n.endDelay,r)?tc:ec}(t,e,n),i=function(t,e,n,r,i){switch(r){case Ju:return"backwards"===e||"both"===e?0:null;case ec:return n-i;case tc:return"forwards"===e||"both"===e?t:null;case Qu:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,a=function(t,e,n,r,i){var o=i;return 0===t?e!==Ju&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var a=t===1/0?e%1:t%1;return 0!==a||n!==tc||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),u=function(t,e,n,r){return t===tc&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),c=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,u,s);return n.currentIteration=u,n.progress=c,n.easingFunction(c)}function rc(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(ic(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Xu(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,u=i[a].computedOffset,c=i[s].computedOffset,l=u,h=c;0===o&&(l=-1/0,0===c&&(s=a)),o===i.length-2&&(h=1/0,1===u&&(a=s)),n.push({applyFrom:l,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:ac(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)ic(n)&&t.setAttribute(n,null)}}function ic(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var oc=function(t,e,n){return function(r){var i=sc(t,e,r);return!Es.enableCSSParsing&&$t(i)?i:n(i)}};function ac(t,e,n,r){var i=Go[t];if(i&&i.syntax&&i.int){var o=Es.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=void 0,s=void 0;if(Es.enableCSSParsing){var u=Es.styleValueRegistry.parseProperty(t,e,r,!1),h=Es.styleValueRegistry.parseProperty(t,n,r,!1);a=Es.styleValueRegistry.computeProperty(t,u,r,!1),s=Es.styleValueRegistry.computeProperty(t,h,r,!1)}else{var d=o.parserWithCSSDisabled;a=d?d(e,r):e,s=d?d(n,r):n}var f=o.mixer(a,s,r);if(f){var p=oc.apply(void 0,l([],c(f),!1));return function(t){return 0===t?e:1===t?n:p(t)}}}}return oc(!1,!0,(function(t){return t?n:e}))}function sc(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(sc(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments "+t+":"+e)}var uc=function(){function t(){this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Gu,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}return Object.defineProperty(t.prototype,"easing",{get:function(){return this._easing},set:function(t){this.easingFunction=Xu(t),this._easing=t},enumerable:!1,configurable:!0}),t}();function cc(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in(null==e?void 0:e.composite)&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n})),r=!0,i=-1/0,o=0;o<n.length;o++){var a=n[o].offset;if(_t(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=0&&Number(t.offset)<=1})),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),a=1;a<r;a++){var s=n[a].computedOffset;if(!_t(s)&&!_t(o)){for(var u=1;u<a-i;u++)n[i+u].computedOffset=o+(Number(s)-o)*u/(a-i);i=a,o=Number(s)}}}(),n}var lc="backwards|forwards|both|none".split("|"),hc="reverse|alternate|alternate-reverse".split("|");function dc(t,e){return function(t,e){var n=new uc;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(e){if(void 0!==t[e]&&null!==t[e]&&"auto"!==t[e]){if(("number"==typeof n[e]||"duration"===e)&&("number"!=typeof t[e]||isNaN(t[e])))return;if("fill"===e&&-1===lc.indexOf(t[e]))return;if("direction"===e&&-1===hc.indexOf(t[e]))return;n[e]=t[e]}})):n.duration=t,n}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}))}var fc=function(){function t(t,e,n){var r=this;this.composite="replace",this.iterationComposite="replace",this.target=t,this.timing=dc(n),this.timing.effect=this,this.timing.activeDuration=Zu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=cc(e,this.timing),this.interpolations=rc(this.normalizedKeyframes,this.timing,this.target);var i=Es.globalThis.Proxy;this.computedTiming=i?new i(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?r.animation&&r.animation.currentTime||null:"currentIteration"===e?r.animation&&"running"===r.animation.playState?t.currentIteration||0:null:"progress"===e?r.animation&&"running"===r.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}return t.prototype.applyInterpolations=function(){this.interpolations(this.target,Number(this.timeFraction))},t.prototype.update=function(t){return null!==t&&(this.timeFraction=nc(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)},t.prototype.getKeyframes=function(){return this.normalizedKeyframes},t.prototype.setKeyframes=function(t){this.normalizedKeyframes=cc(t)},t.prototype.getComputedTiming=function(){return this.computedTiming},t.prototype.getTiming=function(){return this.timing},t.prototype.updateTiming=function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))},t}();function pc(t,e){return Number(t.id)-Number(e.id)}var gc=function(){function t(t){var e=this;this.document=t,this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){e.currentTime=t,e.discardAnimations(),0===e.animations.length?e.timelineTicking=!1:e.requestAnimationFrame(e.webAnimationsNextTick)},this.processRafCallbacks=function(t){var n=e.rafCallbacks;e.rafCallbacks=[],t<Number(e.currentTime)&&(t=Number(e.currentTime)),e.animations.sort(pc),e.animations=e.tick(t,!0,e.animations)[0],n.forEach((function(e){e[1](t)})),e.applyPendingEffects()}}return t.prototype.getAnimations=function(){return this.discardAnimations(),this.animations.slice()},t.prototype.isTicking=function(){return this.inTick},t.prototype.play=function(t,e,n){var r=new fc(t,e,n),i=new fu(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i},t.prototype.applyDirtiedAnimation=function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(pc),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}},t.prototype.restart=function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame},t.prototype.destroy=function(){this.document.defaultView.cancelAnimationFrame(this.frameId)},t.prototype.applyPendingEffects=function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]},t.prototype.updateAnimationsPromises=function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))},t.prototype.discardAnimations=function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))},t.prototype.restartWebAnimationsNextTick=function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))},t.prototype.rAF=function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e},t.prototype.requestAnimationFrame=function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))},t.prototype.tick=function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],u=[],h=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?u.push(n):h.push(n)})),(r=this.pendingEffects).push.apply(r,l([],c(a),!1)),(i=this.pendingEffects).push.apply(i,l([],c(s),!1)),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[u,h]},t}();Es.EasingFunction=Xu,Es.AnimationTimeline=gc;const mc={duration:500},yc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var vc,bc,xc,wc,Ec,Mc,Sc,Nc;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(vc||(vc={})),function(t){t.DRAW="draw",t.TRANSFORM="transform"}(bc||(bc={})),t.CanvasEvent=void 0,function(t){t.CLICK="click",t.DBLCLICK="dblclick",t.POINTER_OVER="pointerover",t.POINTER_LEAVE="pointerleave",t.POINTER_ENTER="pointerenter",t.POINTER_MOVE="pointermove",t.POINTER_OUT="pointerout",t.POINTER_DOWN="pointerdown",t.POINTER_UP="pointerup",t.CONTEXT_MENU="contextmenu",t.DRAG_START="dragstart",t.DRAG="drag",t.DRAG_END="dragend",t.DRAG_ENTER="dragenter",t.DRAG_OVER="dragover",t.DRAG_LEAVE="dragleave",t.DROP="drop",t.WHEEL="wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.NodeEvent=void 0,(xc=t.NodeEvent||(t.NodeEvent={})).CLICK="click",xc.DBLCLICK="dblclick",xc.POINTER_OVER="pointerover",xc.POINTER_LEAVE="pointerleave",xc.POINTER_ENTER="pointerenter",xc.POINTER_MOVE="pointermove",xc.POINTER_OUT="pointerout",xc.POINTER_DOWN="pointerdown",xc.POINTER_UP="pointerup",xc.CONTEXT_MENU="contextmenu",xc.DRAG_START="dragstart",xc.DRAG="drag",xc.DRAG_END="dragend",xc.DRAG_ENTER="dragenter",xc.DRAG_OVER="dragover",xc.DRAG_LEAVE="dragleave",xc.DROP="drop",t.CommonEvent=void 0,(wc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",wc.DBLCLICK="dblclick",wc.POINTER_OVER="pointerover",wc.POINTER_LEAVE="pointerleave",wc.POINTER_ENTER="pointerenter",wc.POINTER_MOVE="pointermove",wc.POINTER_OUT="pointerout",wc.POINTER_DOWN="pointerdown",wc.POINTER_UP="pointerup",wc.CONTEXT_MENU="contextmenu",wc.DRAG_START="dragstart",wc.DRAG="drag",wc.DRAG_END="dragend",wc.DRAG_ENTER="dragenter",wc.DRAG_OVER="dragover",wc.DRAG_LEAVE="dragleave",wc.DROP="drop",wc.KEY_DOWN="keydown",wc.KEY_UP="keyup",wc.WHEEL="wheel",t.ContainerEvent=void 0,(Ec=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",Ec.KEY_UP="keyup",t.EdgeEvent=void 0,(Mc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="click",Mc.DBLCLICK="dblclick",Mc.POINTER_OVER="pointerover",Mc.POINTER_LEAVE="pointerleave",Mc.POINTER_ENTER="pointerenter",Mc.POINTER_MOVE="pointermove",Mc.POINTER_OUT="pointerout",Mc.POINTER_DOWN="pointerdown",Mc.POINTER_UP="pointerup",Mc.CONTEXT_MENU="contextmenu",Mc.DRAG_ENTER="dragenter",Mc.DRAG_OVER="dragover",Mc.DRAG_LEAVE="dragleave",Mc.DROP="drop",t.GraphEvent=void 0,(Sc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",Sc.AFTER_CANVAS_INIT="aftercanvasinit",Sc.BEFORE_SIZE_CHANGE="beforesizechange",Sc.AFTER_SIZE_CHANGE="aftersizechange",Sc.BEFORE_ELEMENT_CREATE="beforeelementcreate",Sc.AFTER_ELEMENT_CREATE="afterelementcreate",Sc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",Sc.AFTER_ELEMENT_UPDATE="afterelementupdate",Sc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",Sc.AFTER_ELEMENT_DESTROY="afterelementdestroy",Sc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",Sc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",Sc.BEFORE_DRAW="beforedraw",Sc.AFTER_DRAW="afterdraw",Sc.BEFORE_RENDER="beforerender",Sc.AFTER_RENDER="afterrender",Sc.BEFORE_ANIMATE="beforeanimate",Sc.AFTER_ANIMATE="afteranimate",Sc.BEFORE_LAYOUT="beforelayout",Sc.AFTER_LAYOUT="afterlayout",Sc.BEFORE_TRANSFORM="beforetransform",Sc.AFTER_TRANSFORM="aftertransform",Sc.BEFORE_ELEMENT_STATE_CHANGE="beforeelementstatechange",Sc.AFTER_ELEMENT_STATE_CHANGE="afterelementstatechange",Sc.BATCH_START="batchstart",Sc.BATCH_END="batchend",Sc.BEFORE_DESTROY="beforedestroy",Sc.AFTER_DESTROY="afterdestroy",t.HistoryEvent=void 0,(Nc=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",Nc.REDO="redo",Nc.CANCEL="cancel",Nc.ADD="add",Nc.CLEAR="clear",Nc.CHANGE="change";const kc="combo",Cc="tree";var Tc;function Ac(t){return"source"in t&&"target"in t}function Pc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Oc(t,e,n){return t>=e&&t<=n}function _c(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function Rc(t){return t.max[0]-t.min[0]}function Ic(t){return t.max[1]-t.min[1]}function Dc(t){return[Rc(t),Ic(t)]}function Lc(t,e){const n=Pc(t)?function(t){const[e,n,r=0]=t,i=new Sr;return i.setMinMax([e,n,r],[e,n,r]),i}(t):t.getKey().getBounds();return e?jc(n,e):n}function jc(t,e){const[n,r,i,o]=_c(e),[a,s,u]=t.min,[c,l,h]=t.max,d=new Sr;return d.setMinMax([a-o,s-n,u],[c+r,l+i,h]),d}function Bc(t){if(0===t.length)return new Sr;if(1===t.length)return t[0];const e=new Sr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function zc(t,e){return Oc(t[0],e.min[0],e.max[0])&&Oc(t[1],e.min[1],e.max[1])}function Fc(t,e){const[n,r]=e,[i,o]=t.min,[a,s]=t.max,u=n-i,c=a-n,l=r-o,h=s-r,d=Math.min(u,c,l,h);return d===u?"left":d===c?"right":d===l?"top":d===h?"bottom":"left"}function Gc(t,e){const n=oe(e);if(zc(e,t)){switch(Fc(t,e)){case"left":n[0]=t.min[0];break;case"right":n[0]=t.max[0];break;case"top":n[1]=t.min[1];break;case"bottom":n[1]=t.max[1]}}else{const[r,i]=e,[o,a]=t.min,[s,u]=t.max;n[0]=Oc(r,o,s)?r:r<o?o:s,n[1]=Oc(i,a,u)?i:i<a?a:u}return n}function Vc(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Wc(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}function Hc(t,e="center"){const n=function(t){if(Array.isArray(t))return Oc(t[0],0,1)&&Oc(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}(e);return Wc(t,n)}function Uc(t,e){const n=function(t){const e="string"==typeof t?t.split(" ").map((t=>parseFloat(t))):t.slice(0,2);return Oc(e[0],0,1)&&Oc(e[1],0,1)?e:[.5,.5]}(e);return Wc(t,n)}function $c(t=0){if($t(t))return Array(3).fill(t);const[e,n=e,r=e]=t;return[e,n,r]}function qc(t,e,n){if(Array.isArray(t))return t;const[r,i]=$c(n),[o,a]=$c(e),s=o/2/r,u=a/2/i;switch(t){case"top":return[.5,u];case"bottom":return[.5,1-u];case"left":return[s,.5];case"right":return[1-s,.5];case"top-left":case"left-top":return[s,u];case"top-right":case"right-top":return[1-s,u];case"bottom-left":case"left-bottom":return[s,1-u];case"bottom-right":case"right-bottom":return[1-s,1-u];default:return[.5,.5]}}function Yc(t,e,n){if(Array.isArray(t))return t;const r=$c(n)[0],i=r/2,o=$c(e)[0]/2,a=o/r;switch(t){case"top":return[.5,a];case"bottom":return[.5,1-a];case"left":return[a,.5];case"right":return[1-a,.5]}const s=(i-o)*(Math.sqrt(2)/2)/r;switch(t){case"top-left":case"left-top":return[.5-s,.5-s];case"top-right":case"right-top":return[.5+s,.5-s];case"bottom-left":case"left-bottom":return[.5-s,.5+s];case"bottom-right":case"right-bottom":return[.5+s,.5+s];default:return[.5,.5]}}function Kc(t,e,n,r,i=qc){const o=i(t,n,r),[a,s]=$c(r),u=new Sr;return u.setMinMax([e[0]-a/2,e[1]-s/2,0],[e[0]+a/2,e[1]+s/2,0]),Uc(u,o)}function Xc(t){if(Vt(t.id)||$t(t.id))return t.id;if(Ac(t))return`${t.source}-${t.target}`;throw new Error("The data does not have available id.")}function Zc(t){return t.combo}function Qc(t,e){const n={nodes:(t.nodes||[]).map(Xc),edges:(t.edges||[]).map(Xc),combos:(t.combos||[]).map(Xc)};return e?Object.values(n).flat():n}function Jc(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function tl(t,e,n=!0){if(!e)return t;if(!Jc(t,e))return t;const r=t.slice(e.length);return n?Jt(r):r}function el(t,e){const n=Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Jc(n,e)&&Object.assign(t,{[tl(n,e)]:r}),t)),{});if("opacity"in t){const r=function(t,e){return`${e}${te(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function nl(t,e){const n=e.length;return Object.keys(t).reduce(((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r}),{})}function rl(t,e){const n=Vt(e)?[e]:e;return Object.entries(t).reduce(((t,[e,r])=>(n.find((t=>e.startsWith(t)))||(t[e]=r),t)),{})}t.ExtensionCategory=void 0,(Tc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",Tc.EDGE="edge",Tc.COMBO="combo",Tc.THEME="theme",Tc.PALETTE="palette",Tc.LAYOUT="layout",Tc.BEHAVIOR="behavior",Tc.PLUGIN="plugin",Tc.ANIMATION="animation",Tc.TRANSFORM="transform";const il=[0,0,0];function ol(t,e){return t.map(((t,n)=>t+e[n]))}function al(t,e){return t.map(((t,n)=>t-e[n]))}function sl(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function ul(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function cl(t,e){return t.map((t=>t*e))}function ll(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+(n-e[r]||0)**2),0))}function hl(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function dl(t){const e=t.reduce(((t,e)=>t+e**2),0);return t.map((t=>t/Math.sqrt(e)))}function fl(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(sl(t,e).reduce(((t,e)=>t+e),0)/(ll(t,il)*ll(e,il)));return n&&r<0&&(i=2*Math.PI-i),i}function pl(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function gl(t){return[t[0],t[1]]}function ml(t){return 2===t.length?[t[0],t[1],0]:t}function yl(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function vl(t){const e=Vt(t)?OV("palette",t):t;if(!Ot(e))return e}function bl(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=ml(t),r=ml(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(al(n,r),al(i,o)).every((t=>0===t))}function xl(t,e,n=!1){if(bl(t,e))return;const[r,i]=t,[o,a]=e,s=((r[0]-o[0])*(o[1]-a[1])-(r[1]-o[1])*(o[0]-a[0]))/((r[0]-i[0])*(o[1]-a[1])-(r[1]-i[1])*(o[0]-a[0])),u=a[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(a[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(a[1]-o[1]);return n||Oc(s,0,1)&&Oc(u,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function wl(t){return[t.x,t.y]}function El(t){return{x:t[0],y:t[1]}}function Ml(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function Sl(t,e,n,r=!1){const i=dl(r?al(t,e):al(e,t)),o=[i[0]*n,i[1]*n];return ol(gl(t),o)}function Nl(t,e){return t[1]===e[1]}function kl(t,e,n,r=!0){for(let i=0;i<n.length;i++){let o=n[i],a=n[(i+1)%n.length];r&&(o=ol(e,o),a=ol(e,a));const s=xl([e,t],[o,a]);if(s)return{point:s,line:[o,a]}}return{point:e,line:void 0}}function Cl(t,e){const n=e.center,r=al(t,e.center),i=Math.atan2(r[1],r[0]);if(isNaN(i))return n;const o=Rc(e)/2,a=Ic(e)/2;return[n[0]+o*Math.cos(i),n[1]+a*Math.sin(i)]}function Tl(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=function(t,e){const n=Al(t,e);return ll(t,n)}(t,e);i<n&&(n=i,r=e)})),r}function Al(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,u=i-n,c=o-r;if(0===u&&0===c)return[n,r];let l=((a-n)*u+(s-r)*c)/(u*u+c*c);l>1?l=1:l<0&&(l=0);return[n+l*u,r+l*c]}function Pl(t,e=!0){const n=function(t){return ul(t.reduce(((t,e)=>ol(t,e)),[0,0]),t.length)}(t);return t.sort((([t,r],[i,o])=>{const a=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-a:a-s}))}function Ol(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}function _l(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function Rl(t,e,n=1,r=!1){const i=r?n:1;return _l((t.max[0]-t.min[0])*i,e)}function Il(t,e,n,r){const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Dl="cachedStyle",Ll=t=>`__${t}__`;function jl(t,e){const n=Array.isArray(e)?e:[e];fe(t,Dl)||pe(t,Dl,{}),n.forEach((e=>{pe(fe(t,Dl),Ll(e),t.attributes[e])}))}function Bl(t,e){return fe(t,[Dl,Ll(e)])}function zl(t,e){return Ll(e)in(fe(t,Dl)||{})}function Fl(t){const e=[],n=t=>{t.children&&t.children.length&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}const Gl="visibility";class Vl extends Fs{constructor(t){super(t),this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}shapeMap={};animateMap={};upsert(t,e,n,r){const i=this.shapeMap[t];if(!1!==n){if(!i){const i=new e({style:n});return i.id=t,r.appendChild(i),this.shapeMap[t]=i,i}return id(i,n),i}i&&(r.removeChild(i),delete this.shapeMap[t])}update(t={}){this.attr(Object.assign({},this.attributes,t)),this.render(this.attributes,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){const{x:e,y:n,z:r,className:i,transform:o,transformOrigin:a,context:s,zIndex:u,...c}=t;return c}animate(t,e){if(0===t.length)return null;const n=[],r=super.animate(t,e);if(r&&n.push(r),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some((t=>!r.includes(t)))){Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${te(r)}Style`];if(Ot(o)){const r=t.map((t=>o.call(this,{...this.attributes,...t}))),a=i.animate(ad(r),e);a&&n.push(a)}}));const r=nl(this.shapeMap,"badge-"),i=nl(this.shapeMap,"port-"),o=(r,i)=>{if(!he(r)){const o=this[`get${te(i)}Style`];if(Ot(o)){const i=t.map((t=>o.call(this,{...this.attributes,...t})));Object.entries(i[0]).map((([t])=>{const o=i.map((e=>e[t])),a=r[t];if(a){const t=a.animate(ad(o),e);t&&n.push(t)}}))}}};o(r,"badges"),o(i,"ports")}}return od(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;!function(t,e){[t,...Fl(t)].forEach((n=>{zl(n,Gl)||jl(n,Gl);const r=Bl(n,Gl);t!==n&&"hidden"===r||(n.style.visibility=e)}))}(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}class Wl extends Vl{static defaultStyleProps={padding:0,fontSize:12,wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};constructor(t){super(ce({},{style:Wl.defaultStyleProps},t))}isTextStyle(t){return Jc(t,"label")}isBackgroundStyle(t){return Jc(t,"background")}getTextStyle(t){const{padding:e,...n}=this.getGraphicStyle(t);return rl(n,"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=el(e,"background"),{min:[a,s],halfExtents:[u,c]}=this.shapeMap.text.getGeometryBounds(),[l,h,d,f]=_c(i),p=2*u+f+h;Object.assign(o,{x:a-f,y:s-l,width:n?Math.min(p,r):p,height:2*c+l+d});const{radius:g}=o;if("string"==typeof g&&g.endsWith("%")){const t=Number(g.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Xs,this.getTextStyle(t),e),this.upsert("background",Ks,this.getBackgroundStyle(t),e)}}class Hl extends Vl{static defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};constructor(t){super(ce({},{style:Hl.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",Wl,this.getBadgeStyle(t),e)}connectedCallback(){this.upsert("label",Wl,this.getBadgeStyle(this.parsedAttributes),this)}}const Ul={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function $l(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in Ul?r=t:e.unshift(t),i={type:r},Ul[r].forEach((n=>{t=e.shift(),i[n]=t})),"M"===r?r="L":"m"===r&&(r="l");const[o,...a]=Object.values(i);n.push([o,...a.map(Number)])}return n}(t):t;return n.forEach((t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}const ql=t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,u]=t[e+1],[c,l]=e!==t.length-2?t[e+2]:[s,u],h=i+(s-n)/6,d=a+(u-r)/6,f=s-(c-i)/6,p=u-(l-a)/6;o.push(["C",h,d,f,p,s,u])}return o};class Yl extends Vl{static defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};constructor(t){super(ce({},{style:Yl.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const{maxWidth:e,offsetX:n,offsetY:r,autoRotate:i,placement:o,closeToPath:a,...s}=el(this.getGraphicStyle(t),"label"),u=this.shapeMap.key,c=u?.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,a){const[s,u]=Hc(t,e),c={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:`translate(${s+n}, ${u+r})`};if("center"===e||!i)return c;const l=$l(o);if(!l||l.length<=3)return c;const h=l.map(((t,e)=>{const n=t,r=l[(e+1)%l.length];return de(n,r)?null:[n,r]})).filter(Boolean),d=Tl([s,u],h),f=Al([s,u],d);if(f&&d&&(c.transform=`translate(${f[0]+n}, ${f[1]+r})`,a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));c.transform+=`rotate(${t/Math.PI*180}deg)`,c.textAlign="center","right"!==e&&"left"!==e||(c.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return c}(c,o,n,r,a,t.d,i),{wordWrapWidth:Rl(c,e)},s)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",$s,this.getKeyStyle(t),e),this.upsert("label",Wl,this.getLabelStyle(t),e)}}class Kl extends Vl{constructor(t){super(t)}isGImage(){return!!this.getAttribute("src")}getIconStyle(t=this.attributes){const{x:e=0,y:n=0}=t,r=this.getGraphicStyle(t),{width:i,height:o}=r;return this.isGImage()?{x:e-i/2,y:n-o/2,...r}:{textBaseline:"middle",textAlign:"center",...r}}render(t=this.attributes,e=this){this.upsert("icon",this.isGImage()?Hs:Xs,this.getIconStyle(t),e)}connectedCallback(){this.upsert("icon",this.isGImage()?Hs:Xs,this.getIconStyle(this.attributes),this)}}class Xl extends Vl{type="node";static defaultStyleProps={x:0,y:0,size:24,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};constructor(t){super(ce({},{style:Xl.defaultStyleProps},t))}get parsedAttributes(){return this.attributes}getSize(t=this.attributes){const{size:e}=t;return $c(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(rl(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||he(t.labelText))return!1;const{placement:e,maxWidth:n,...r}=el(this.getGraphicStyle(t),"label"),i=this.getKey().getLocalBounds();return Object.assign(rd(i,e),{wordWrapWidth:Rl(i,n)},r)}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,...n}=this.getKeyStyle(t);return{...n,stroke:e,...el(this.getGraphicStyle(t),"halo")}}getIconStyle(t){if(!1===t.icon||he(t.iconText||t.iconSrc))return!1;const e=el(this.getGraphicStyle(t),"icon"),n=this.getKey(),[r,i]=Hc(n.getLocalBounds(),"center");return{x:r,y:i,...e}}getBadgesStyle(t){const e=nl(this.shapeMap,"badge-"),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.badge||he(t.badges))return n;const{badges:r=[],badgePalette:i,opacity:o=1,...a}=t,s=vl(i),u=el(this.getGraphicStyle(a),"badge");return r.forEach(((t,e)=>{n[e]={backgroundFill:s?s[e%s?.length]:void 0,opacity:o,...u,...this.getBadgeStyle(t)}})),n}getBadgeStyle(t){const e=this.getKey(),{placement:n="top",...r}=t;return{...rd(e.getLocalBounds(),n,!0),...r}}getPortsStyle(t){const e=this.getPorts(),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.port||he(t.ports))return n;const r=el(this.getGraphicStyle(t),"port"),{ports:i=[]}=t;return i.forEach(((e,i)=>{const o=e.key||i,a={...r,...e};if(Xh(a))n[o]=!1;else{const[r,i]=this.getPortXY(t,e);n[o]={transform:`translate(${r}, ${i})`,...a}}})),n}getPortXY(t,e){const{placement:n="left"}=e;return Yh(this.getKey().getLocalBounds(),n)}getKey(){return this.shapeMap.key}getPorts(){return nl(this.shapeMap,"port-")}getCenter(){return this.getKey().getBounds().center}getIntersectPoint(t){const e=this.getKey().getBounds();return kl(t,Hc(n=e,"center"),[Hc(n,"left-top"),Hc(n,"right-top"),Hc(n,"right-bottom"),Hc(n,"left-bottom")],!1).point;var n}drawHaloShape(t,e){const n=this.getKey();this.upsert("halo",n.constructor,this.getHaloStyle(t),e)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{this.upsert(`badge-${t}`,Hl,n[t],e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{this.upsert(`port-${t}`,zs,n[t],e)}))}render(t=this.parsedAttributes,e=this){const{x:n=0,y:r=0,z:i=0,transform:o}=t;0===n&&0===r&&0===i||(this.style.transform=Il(n,r,i,o));this.drawKeyShape(t,e)&&(this.drawHaloShape(t,e),this.upsert("icon",Kl,this.getIconStyle(t),e),this.drawBadgeShapes(t,e),this.upsert("label",Wl,this.getLabelStyle(t),e),this.drawPortShapes(t,e))}onCreate(){}onUpdate(){}onDestroy(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawBadgeShapes(this.parsedAttributes,this)}),n}}const Zl=.8,Ql=["node","edge","combo"];let Jl=class t extends Xl{static defaultStyleProps={size:24};constructor(e){super(ce({},{style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",zs,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),r:Math.min(...this.getSize(t))/2}}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getKeyStyle(t),r=2*n*Zl;return!!e&&{width:r,height:r,...e}}getIntersectPoint(t){return Cl(t,this.getKey().getBounds())}};class th extends Xl{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",qs,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),points:this.getPoints(t)}}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return kl(t,[+(this.attributes?.x||0),+(this.attributes?.y||0)],e).point}}class eh extends th{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return kl(t,[this.attributes.x,this.attributes.y],e).point}}class nh extends Jl{static defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};constructor(t){super(ce({},{style:nh.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...$c(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return Vt(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!n?.length)return;const r=n.map((t=>$t(t)?{value:t}:t)),i=el(this.getGraphicStyle(t),"donut"),o=vl(t.donutPalette);if(!o)return;const a=r.reduce(((t,e)=>t+(e.value??0)),0),s=this.parseOuterR(),u=this.parseInnerR();let c=0;r.forEach(((t,n)=>{const{value:l=0,color:h=o[n%o.length],...d}=t,f=360*(0===a?1/r.length:l/a);this.upsert(`round${n}`,$s,{...i,d:ih(s,u,c,c+f),fill:h,...d},e),c+=f}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}const rh=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],ih=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[a,s]=[i/360*2*Math.PI,o/360*2*Math.PI],u=[rh(t,e,r,a),rh(t,e,n,a),rh(t,e,n,s),rh(t,e,r,s)],c=s-a>Math.PI?1:0;return[["M",u[0][0],u[0][1]],["L",u[1][0],u[1][1]],["A",n,n,0,c,1,u[2][0],u[2][1]],["L",u[3][0],u[3][1]],["A",r,r,0,c,0,u[0][0],u[0][1]],["Z"]]})(i,o,t,e,n,r)};class oh extends Xl{static defaultStyleProps={size:[80,40]};constructor(t){super(ce({},{style:oh.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Gs,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return{...e,rx:n/2,ry:r/2}}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getKeyStyle(t),i=2*Math.min(+n,+r)*Zl;return!!e&&{width:i,height:i,...e}}getIntersectPoint(t){return Cl(t,this.getKey().getBounds())}}class ah extends th{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*Zl;return!!e&&{width:n,height:n,...e}}}class sh extends Xl{static defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};constructor(t){super({...t,style:Object.assign({},sh.defaultStyleProps,t.style)})}rootPointerEvent=new Ja(null);get eventService(){return this.attributes.context.canvas.context.eventService}get events(){return[t.NodeEvent.CLICK,t.NodeEvent.POINTER_DOWN,t.NodeEvent.POINTER_MOVE,t.NodeEvent.POINTER_UP,t.NodeEvent.POINTER_OVER,t.NodeEvent.POINTER_LEAVE]}getDomElement(){return this.getKey().getDomElement()}getKeyStyle(t){const e=me(t,["innerHTML","pointerEvents","cursor"]),[n,r]=this.getSize(t);return{...e,width:n,height:r}}drawKeyShape(t,e){return this.upsert("key",Ws,this.getKeyStyle(t),e)}connectedCallback(){const t=this.getDomElement();this.events.forEach((e=>{t.addEventListener(e,this.forwardEvents)}))}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}onDestroy(){const t=this.getDomElement();this.events.forEach((e=>{t.removeEventListener(e,this.forwardEvents)}))}forwardEvents=t=>{const e=this.attributes.context.canvas.main,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach((r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);e.context.eventService.mapEvent(i)}))};normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];ie(r.button)&&(r.button=0),ie(r.buttons)&&(r.buttons=1),ie(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),ie(r.width)&&(r.width=r.radiusX||1),ie(r.height)&&(r.height=r.radiusY||1),ie(r.tiltX)&&(r.tiltX=0),ie(r.tiltY)&&(r.tiltY=0),ie(r.pointerType)&&(r.pointerType="touch"),ie(r.pointerId)&&(r.pointerId=r.identifier||0),ie(r.pressure)&&(r.pressure=r.force||.5),ie(r.twist)&&(r.twist=0),ie(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;ie(e.isPrimary)&&(e.isPrimary=!0),ie(e.width)&&(e.width=1),ie(e.height)&&(e.height=1),ie(e.tiltX)&&(e.tiltX=0),ie(e.tiltY)&&(e.tiltY=0),ie(e.pointerType)&&(e.pointerType="mouse"),ie(e.pointerId)&&(e.pointerId=1),ie(e.pressure)&&(e.pressure=.5),ie(e.twist)&&(e.twist=0),ie(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}bootstrapEvent(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const{x:a,y:s}=this.attributes.context.canvas.viewport2Canvas(t.viewport);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if(!this.attributes.context?.canvas.main.context.config.supportsCSSTransform||_t(r)||_t(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}}let uh=class t extends Xl{static defaultStyleProps={size:50};constructor(e){super(ce({},{style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),{fillOpacity:r,opacity:i=r,...o}=super.getKeyStyle(t);return{opacity:i,...o,width:e,height:n,x:-e/2,y:-n/2}}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,stroke:n,...r}=this.getKeyStyle(t),i=el(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=ol(this.getSize(t),[o,o]);return{...r,...i,width:a,height:s,fill:"transparent",x:-a/2,y:-s/2}}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&{width:n*Zl,height:r*Zl,...e}}drawKeyShape(t,e){return this.upsert("key",Hs,this.getKeyStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Ks,this.getHaloStyle(t),e)}};class ch extends Xl{static defaultStyleProps={size:[48,24]};constructor(t){super(ce({},{style:ch.defaultStyleProps},t))}getKeyStyle(t){const[e,n]=this.getSize(t);return{...super.getKeyStyle(t),width:e,height:n,x:-e/2,y:-n/2}}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getKeyStyle(t);return!!e&&{width:n*Zl,height:r*Zl,...e}}drawKeyShape(t,e){return this.upsert("key",Ks,this.getKeyStyle(t),e)}}class lh extends th{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*Zl;return!!e&&{width:n,height:n,...e}}getPortXY(t,e){const{placement:n="top"}=e;return Yh(this.getKey().getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}}class hh extends th{static defaultStyleProps={size:40,direction:"up"};constructor(t){super(ce({},{style:hh.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getKey().getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return Yh(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||he(n||r))return!1;const o=el(this.getGraphicStyle(t),"icon"),a=this.getKey().getLocalBounds(),[s,u]=function(t,e){const{center:n}=t,[r,i]=Dc(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),c=2*function(t,e){let[n,r]=Dc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(r**2-(Math.sqrt((n/2)**2+r**2)-n/2)**2)/(2*r)}(a,i)*Zl;return{x:s,y:u,width:c,height:c,...o}}}class dh extends Xl{type="combo";static defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedOrigin:[.5,.5],collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};constructor(t){super(ce({},{style:dh.defaultStyleProps},t))}calculatePosition(t){const{x:e=0,y:n=0,collapsed:r,childrenNode:i=[],childrenData:o=[]}=t;if(i.length<o.length){if(o.length>0&&r){return ul(o.reduce(((t,e)=>ol(t,Vc(e))),[0,0,0]),o.length)}return[+e,+n,0]}return o.length?r?this.getCollapsedOriginPosition(t):this.getContentBBox(t).center:[+e,+n,0]}getCollapsedOriginPosition(t){return Kc(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t))}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=_c(e);return ol($c(n),[a+i,r+o,0])}getCollapsedKeySize(t){return $c(t.collapsedSize)}getExpandedKeySize(t){if(!he(t.size))return $c(t.size);const e=this.getContentBBox(t);return[Rc(e),Ic(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=Bc(e.map((t=>t.getBounds())));return n?jc(r,n):r}drawCollapsedMarkerShape(t,e){this.upsert("collapsed-marker",Kl,this.getCollapsedMarkerStyle(t),e)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const{type:e,...n}=el(this.getGraphicStyle(t),"collapsedMarker"),r=this.getKey(),[i,o]=Hc(r.getLocalBounds(),"center"),a={...n,x:i,y:o};if(e){const n=this.getCollapsedMarkerText(e,t);Object.assign(a,{text:n})}return a}getCollapsedMarkerText(t,e){const{context:n,childrenData:r=[]}=e;if(!n)return"";const{model:i}=n;return"descendant-count"===t?i.getDescendantsData(this.id).length.toString():"child-count"===t?r.length.toString():"node-count"===t?i.getDescendantsData(this.id).filter((t=>"node"===i.getElementType(Xc(t)))).length.toString():Ot(t)?t(r):""}getComboZIndex(t){return(t.context?.model.getAncestorsData(this.id,kc)||[]).length}getComboStyle(t){const{zIndex:e=this.getComboZIndex(t)}=t,[n,r]=this.calculatePosition(t);return{x:n,y:r,transform:`translate(${n}, ${r})`,zIndex:e}}render(t,e=this){super.render(t,e);const n=this.getComboStyle(t);Object.assign(this.style,n),t.context?.model.syncComboDatum({id:this.id,style:n}),this.drawCollapsedMarkerShape(t,e)}onCreate(){}onUpdate(){}onDestroy(){}}class fh extends dh{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",zs,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),r=el(n,"collapsed"),[i]=this.getKeySize(t);return{...n,...e&&r,r:i/2}}getCollapsedKeySize(t){const[e,n]=$c(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){if(!he(t.size)){const[e,n]=$c(t.size),r=Math.sqrt(e**2+n**2)/2;return[2*r,2*r,0]}const e=this.getContentBBox(t),[n,r]=Dc(e),i=Math.sqrt(n**2+r**2)/2;return[2*i,2*i,0]}getCollapsedOriginPosition(t){return Kc(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t),Yc)}getIntersectPoint(t){return Cl(t,this.getKey().getBounds())}}class ph extends dh{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Ks,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),n=el(e,"collapsed"),[r,i]=this.getKeySize(t);return{...e,...t.collapsed&&n,width:r,height:i,x:-r/2,y:-i/2}}}const gh={N:"S",S:"N",W:"E",E:"W"},mh={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function yh(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function vh(t,e){return"N"===e||"S"===e?Ic(t):Rc(t)}function bh(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=yh(t,r),a=yh(t,i),s=n?gh[n]:null,u=o===n||o!==s&&a!==n?r:i;return{points:[u],direction:yh(u,e)}}function xh(t,e,n){const r=Sh(t,e,n);return{points:[r],direction:yh(r,e)}}function wh(t,e,n,r){const i=[[e[0],t[1]],[t[0],e[1]]],o=i.filter((t=>function(t,e){return!zc(t,e)}(t,n))),a=o.filter((e=>yh(e,t)!==r));if(a.length>0){const n=a.find((e=>yh(t,e)===r))||a[0];return{points:[n],direction:yh(n,e)}}{const a=Sl(e,Pt(i,o)[0],vh(n,r)/2);return{points:[Sh(a,t,n),a],direction:yh(a,e)}}}function Eh(t,e,n,r){let i=xh(t,e,n);const o=ml(i.points[0]);if(zc(o,r)){i=xh(e,t,r);const a=ml(i.points[0]);if(zc(a,n)){const s=Sl(t,a,vh(n,yh(t,a))/2),u=Sl(e,o,vh(r,yh(e,o))/2),c=[(s[0]+u[0])/2,(s[1]+u[1])/2],l=xh(t,c,n),h=wh(c,e,r,l.direction);i.points=[l.points[0],h.points[0]],i.direction=h.direction}}return i}function Mh(t,e,n,r,i){const o=.01,a=Bc([n,r]),s=ll(e,a.center)>ll(t,a.center),[u,c]=s?[e,t]:[t,e],l=Ic(a)+Rc(a);let h;if(i){const t=[u[0]+l*Math.cos(mh[i]),u[1]+l*Math.sin(mh[i])];h=Sl(Gc(a,t),t,o)}else h=Sl(Gc(a,u),u,-.01);let d=Sh(h,c,a),f=[Ml(h,2),Ml(d,2)];if(de(Ml(h),Ml(d))){const t=fl(al(h,u),[1,0,0])+Math.PI/2;d=[c[0]+l*Math.cos(t),c[1]+l*Math.sin(t),0],d=Ml(Sl(Gc(a,d),c,-.01),2);f=[h,Sh(h,d,a),d]}return{points:s?f.reverse():f,direction:yh(s?h:d,e)}}function Sh(t,e,n){let r=[t[0],e[1]];return zc(r,n)&&(r=[e[0],t[1]]),r}function Nh(t,e,n,r,i){const[o,a]=wl(t.getPoint(e));let s=n,u=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),u=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+u]}function kh(t,e,n,r){if(de(t,e))return t;const i=al(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=dl(pl(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Ch(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function Th(t,e=0,n=!1){const r=t[0],i=t[t.length-1],o=t.slice(1,t.length-1),a=[["M",r[0],r[1]]];return o.forEach(((t,n)=>{const s=o[n-1]||r,u=o[n+1]||i;if(!bl([s,c=t],[c,u])&&e){const[n,r]=function(t,e,n,r){const i=hl(t,e),o=hl(n,e),a=Math.min(r,Math.min(i,o)/2),s=[e[0]-a/i*(e[0]-t[0]),e[1]-a/i*(e[1]-t[1])],u=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,u]}(s,t,u,e);a.push(["L",n[0],n[1]],["Q",t[0],t[1],r[0],r[1]],["L",r[0],r[1]])}else a.push(["L",t[0],t[1]]);var c})),a.push(["L",i[0],i[1]]),n&&a.push(["Z"]),a}const Ah=t=>{const e=Math.PI/2,n=Ic(t)/2,r=Rc(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}};function Ph(t,e,n,r,i){const o=Lc(t),a=t.getCenter();let s=r&&Zh(r),u=i&&Zh(i);if(!s||!u){const r=Ah(o),i=r[e][0],c=r[e][1],[l,h]=Dc(o),d=Math.max(l,h),f=ol(a,[d*Math.cos(i),d*Math.sin(i),0]),p=ol(a,[d*Math.cos(c),d*Math.sin(c),0]);s=nd(t,f),u=nd(t,p),n||([s,u]=[u,s])}return[s,u]}function Oh(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[u,c]=Ph(t,e,n,a,s);const l=function(t,e,n,r){const i=t.getCenter();if(de(e,n)){const t=al(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[ol(e,o),ol(n,sl(o,[1,-1,1]))]}return[Sl(i,e,ll(i,e)+r),Sl(i,n,ll(i,n)+r)]}(t,u,c,r);return a&&(u=ed(a,l[0])),s&&(c=ed(s,l[l.length-1])),Ch(u,c,l)}function _h(t,e,n,r,i,o,a){const s=Kh(t),u=s[o||a],c=s[a||o];let[l,h]=Ph(t,n,r,u,c);const d=function(t,e,n,r){const i=[],o=Lc(t);if(de(e,n)){switch(Fc(o,e)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=Fc(o,e),a=Fc(o,n);if(t===a){let o,a;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":a=Math.min(e[1],n[1])-r,i.push([e[0],a]),i.push([n[0],a]);break;case"bottom":a=Math.max(e[1],n[1])+r,i.push([e[0],a]),i.push([n[0],a])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),u=s(t,e),c=s(a,n),l=Sh(u,c,o);i.push(u,l,c)}}return i}(t,l,h,i);return u&&(l=ed(u,d[0])),c&&(h=ed(c,d[d.length-1])),Th([l,...d,h],e)}function Rh(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach((o=>{e(o).forEach((e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)}))})),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}function Ih(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(Xc(r));if(!t)break;r=t}if(n.some((t=>t.style?.collapsed))){const t=n.reverse().findIndex((t=>t.style?.collapsed));return n[t]||n.at(-1)}return t}const Dh=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var Lh=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,e/2]],triangle:Dh,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",2*t/3-t/2,0],["L",t/2,e/2],["Z"]]});class jh extends Vl{type="edge";static defaultStyleProps={isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,startArrow:!1,startArrowSize:8,startArrowLineDash:0,startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"triangle",endArrow:!1,endArrowSize:8,endArrowLineDash:0,endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"triangle",loopPlacement:"top",loopClockwise:!0};constructor(t){super(ce({},{style:jh.defaultStyleProps},t))}getKeyStyle(t){const{sourceNode:e,targetNode:n,...r}=this.getGraphicStyle(t);var i,o;return{d:(o=n,(i=e)&&o&&i===o?this.getLoopPath(t):this.getKeyPath(t)),...rl(r,["halo","label","startArrow","endArrow"])}}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r}=t,i=Lc(e),o=Math.max(Rc(i),Ic(i)),{placement:a,clockwise:s,dist:u=o}=el(this.getGraphicStyle(t),"loop");return Oh(e,a,s,u,n,r)}getEndpoints(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=Qh(e,n,r,i);return[td(o||e,a||n),td(a||n,o||e)]}getHaloStyle(t){if(!1===t.halo)return!1;return{...this.getKeyStyle(t),...el(this.getGraphicStyle(t),"halo")}}getLabelStyle(t){if(!1===t.label||he(t.labelText))return!1;const e=el(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a,...s}=e,u=function(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=wl(t.getPoint(o)),s=wl(t.getPoint(o+.01));let u="start"===e?"left":"end"===e?"right":"center";if(Nl(a,s)||!n){const[e,n]=Nh(t,o,r,i);return{transform:`translate(${e}, ${n})`,textAlign:u}}let c=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(u="center"===u?u:"left"===u?"right":"left",r*=-1,c+=Math.PI);const[l,h]=Nh(t,o,r,i,c);return{textAlign:u,transform:`translate(${l}, ${h}) rotate(${c/Math.PI*180}deg)`}}(this.shapeMap.key,n,o,r,i),c=this.shapeMap.key.getLocalBounds(),l=function(t,e,n=1){return _l(ll(t[0],t[1])*n,e)}([c.min,c.max],a);return Object.assign({wordWrapWidth:l},u,s)}drawArrow(t,e){const n="start"===e,r=t["start"===e?"startArrow":"endArrow"],i=this.shapeMap.key;if(r){const e=this.getArrowStyle(t,n),r=he(e.src)?$s:Hs,[o,a,s]=n?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],u=i.style[o];u?u.attr(e):i.style[o]=new r({style:e}),i.style[a]=t[s]||e.width/2+ +e.lineWidth}else{const t=n?"markerStart":"markerEnd";i.style[t]?.destroy(),i.style[t]=null}}getArrowStyle(t,e){const n=this.getKeyStyle(t),r=e?"startArrow":"endArrow",{size:i,type:o,...a}=el(this.getGraphicStyle(t),r),[s,u]=$c(i),c=(Ot(o)?o:Lh[o]||Dh)(s,u);return{...n,width:s,height:u,...c&&{d:c,fill:"simple"===o?"":n.stroke},...a}}drawLabelShape(t,e){this.upsert("label",Wl,this.getLabelStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",$s,this.getHaloStyle(t),e)}drawKeyShape(t,e){return this.upsert("key",$s,this.getKeyStyle(t),e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawArrow(t,"start"),this.drawArrow(t,"end"),this.drawLabelShape(t,e),this.drawHaloShape(t,e))}onCreate(){}onUpdate(){}onDestroy(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawLabelShape(this.parsedAttributes,this)}),n}}class Bh extends jh{static defaultStyleProps={curvePosition:.5,curveOffset:20};constructor(t){super(ce({},{style:Bh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,a=this.getControlPoints(e,n,function(t){return $t(t)?[t,1-t]:t}(i),function(t){return $t(t)?[t,-t]:t}(o),r);return Ch(e,n,a)}getControlPoints(t,e,n,r,i){return 2===i?.length?i:[kh(t,e,n[0],r[0]),kh(t,e,n[1],r[1])]}}class zh extends Bh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(ce({},{style:zh.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}class Fh extends Bh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(ce({},{style:Fh.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}let Gh=class t extends jh{static defaultStyleProps={};constructor(e){super(ce({},{style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};class Vh extends jh{static defaultStyleProps={radius:0,controlPoints:[],router:!1,routerName:"orth",routerPadding:10};constructor(t){super(ce({},{style:Vh.defaultStyleProps},t))}getKeyPath(t){const{sourceNode:e,targetNode:n,radius:r}=t,{sourcePoint:i,targetPoint:o,sourcePort:a,targetPort:s}=this.getEndpointsAndPorts(t),u=this.getControlPoints(t,i,o),c=td(a||e,u[0]||s||n),l=td(s||n,u[u.length-1]||a||e);return Th([c,...u,l],r)}getEndpointsAndPorts(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=Qh(e,n,r,i);return{sourcePoint:o?Zh(o):e.getCenter(),targetPoint:a?Zh(a):n.getCenter(),sourcePort:o,targetPort:a}}getControlPoints(t,e,n){const{controlPoints:r,sourceNode:i,targetNode:o,router:a,routerPadding:s}=t;if(!a)return[...r];return function(t,e,n,r,i,o){const a=[t,...i,e];let s=null;const u=[];for(let t=0,e=a.length;t<e-1;t++){const i=t+1,h=a[t],d=a[i],f=Nl(c=h,l=d)||function(t,e){return t[0]===e[0]}(c,l);let p=null;0===t?i===e-1?n.intersects(r)?p=Mh(h,d,n,r):f||(p=Eh(h,d,n,r)):zc(d,n)?p=Mh(h,d,n,Lc(d,o),s):f||(p=xh(h,d,n)):i===e-1?zc(h,r)?p=Mh(h,d,Lc(h,o),r,s):f||(p=wh(h,d,r,s)):f||(p=bh(h,d,s)),p?(u.push(...p.points),s=p.direction):s=yh(h,d),i<e-1&&u.push(d)}var c,l;return u}(e,n,Lc(i,s),Lc(o,s),r,s)}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r,radius:i}=t,o=Lc(e),a=Math.max(Rc(o),Ic(o))/4,{placement:s,clockwise:u,dist:c=a}=el(this.getGraphicStyle(t),"loop");return _h(e,i,s,u,c,n,r)}}class Wh extends jh{static defaultStyleProps={curvePosition:.5,curveOffset:30};constructor(t){super(ce({},{style:Wh.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||kh(r,i,e,n))}}function Hh(t){return t instanceof Xl&&"node"===t.type}function Uh(t){return t instanceof jh}function $h(t){return t instanceof dh}const qh={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function Yh(t,e,n=qh,r=!0){const i=[.5,.5],o=Vt(e)?fe(n,e.toLocaleLowerCase(),i):e;if(!r&&Vt(e))return o;const[a,s]=o||i;return[t.min[0]+Rc(t)*a,t.min[1]+Ic(t)*s]}function Kh(t){const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{const{key:i,placement:o}=n;Xh(n)&&(e[i||r]||=Hc(t.getKey().getBounds(),o))})),e}function Xh(t){const{r:e}=t;return!e||0===Number(e)}function Zh(t){return Pc(t)?t:t.getPosition()}function Qh(t,e,n,r){return[Jh(t,e,n,r),Jh(e,t,r,n)]}function Jh(t,e,n,r){const i=Kh(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Zh(t))),s=function(t,e){const n=Kh(t);if(e)return[Zh(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Zh(t))):[t.getCenter()]}(e,r),[u]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=ll(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Zh(t)===u))}function td(t,e){return $h(t)||Hh(t)?nd(t,e):ed(t,e)}function ed(t,e){if(Pc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return Cl(Pc(e)?e:Hh(e)?e.getCenter():e.getPosition(),t.getBounds())}function nd(t,e){const n=Pc(e)?e:Hh(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function rd(t,e="bottom",n=!1){const r=e.split("-"),[i,o]=Hc(t,e),a=r.includes("left")?"right":r.includes("right")?"left":"center";let s=r.includes("top")?"bottom":r.includes("bottom")?"top":"middle";return n&&(s="top"===s?"bottom":"bottom"===s?"top":s),{transform:`translate(${i}, ${o})`,textBaseline:s,textAlign:a}}function id(t,e){"update"in t?t.update(e):t.attr(e)}function od(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map((t=>t.finished))]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach((t=>t[e]?.(...n)))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function ad(t){const e=t.reduce(((t,e)=>(Object.entries(e).forEach((([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)})),t)),{});return Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>_t(t)))||r.every((t=>!Hh(t)&&de(t,r[0]))))&&delete e[n]})),Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[])}function sd(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function ud(t,e){return e.before?.(),t?(e.beforeAnimate?.(t),t.finished.then((()=>{e.afterAnimate?.(t),e.after?.()}))):e.after?.(),t||null}function cd(t,e){const{animation:n}=t;if(!n||!1===e)return!1;const r={...mc};return Lt(n)&&Object.assign(r,n),Lt(e)&&Object.assign(r,e),r}const ld=(t,e,n,r)=>{if(!e)return null;const{animationsFilter:i=(()=>!0)}=r,o=(Vt(e)?OV("animation",e)||[]:e).filter(i);if(0===o.length)return null;const{originalStyle:a,modifiedStyle:s,states:u}=r;let c;const l=o.map((({fields:e,shape:r,states:i,...o})=>{if(void 0===i||i?.some((t=>u.includes(t)))){const i=(e=>{if(e){const n=t.getShape(e);if(!n)return null;const r=`get${te(e)}Style`,i=t?.[r]?.bind(t)||(t=>t);return{shape:n,fromStyle:i?.({...t.attributes,...a})||{},toStyle:{...n.attributes}}}return{shape:t,fromStyle:a,toStyle:{...t.attributes,...s}}})(r);if(!i)return null;const{shape:u,fromStyle:l,toStyle:h}=i,d=[{},{}];e.forEach((t=>{Object.assign(d[0],{[t]:l[t]??sd(t)}),Object.assign(d[1],{[t]:h[t]??sd(t)})}));const f=["x","y","z"];if(d.some((t=>Object.keys(t).some((t=>f.includes(t)))))){const{x:t=0,y:e=0,z:n=0,transform:r=""}=u.attributes||{};d.forEach((i=>{i.transform=Il(i.x||t,i.y||e,i.z||n,r)}))}const p=u.animate(ad(d),{...yc,...n,...o});return void 0===r&&(c=p),p}return null})).filter(Boolean),h=c||l?.[0];return h?od(h,l.filter((t=>t!=t))):null};function hd(t,e,n){const r=new Map(t.map((t=>[n(t),t]))),i=new Map(e.map((t=>[n(t),t]))),o=new Set(r.keys()),a=new Set(i.keys()),s=[],u=[],c=[],l=[];return a.forEach((t=>{o.has(t)?de(r.get(t),i.get(t))?l.push(i.get(t)):u.push(i.get(t)):s.push(i.get(t))})),o.forEach((t=>{a.has(t)||c.push(r.get(t))})),{enter:s,exit:c,keep:l,update:u}}class dd{context;extensions=[];extensionMap={};constructor(t){this.context=t}setExtensions(t){const e=function(t,e){const n={},r=e=>(e in n||(n[e]=0),`${t}-${e}-${n[e]++}`);return e.map((t=>"string"==typeof t?{type:t,key:r(t)}:t.key?t:{...t,key:r(t.type)}))}(this.category,t),{enter:n,update:r,exit:i,keep:o}=hd(this.extensions,e,(t=>t.key));this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=OV(e,r);if(!i)return;const o=new i(this.context,t);this.extensionMap[n]=o}createExtensions(t){t.forEach((t=>this.createExtension(t)))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach((t=>this.updateExtension(t)))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),this.context={},this.extensions=[],this.extensionMap={}}}class fd{context;options;events=[];destroyed=!1;constructor(t,e){this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class pd extends fd{}const gd=t=>t.map((t=>Vt(t)?t.toLocaleLowerCase():t));class md{map=new Map;emitter;recordKey=new Set;constructor(t){this.emitter=t,this.bindEvents()}bind(t,e){0!==t.length&&this.map.set(t,e)}unbind(t,e){this.map.forEach(((n,r)=>{de(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=gd(Array.from(this.recordKey)).sort(),n=gd(t).sort();return de(e,n)}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),e.on(t.CommonEvent.KEY_UP,this.onKeyUp),e.on(t.CommonEvent.WHEEL,this.onWheel),e.on(t.CommonEvent.DRAG,this.onDrag)}onKeyDown=t=>{t?.key&&(this.recordKey.add(t.key),this.trigger(t))};onKeyUp=t=>{t?.key&&this.recordKey.delete(t.key)};trigger(t){this.map.forEach(((e,n)=>{this.match(n)&&e(t)}))}triggerExtendKey(t,e){this.map.forEach(((n,r)=>{r.includes(t)&&de(Array.from(this.recordKey),r.filter((e=>e!==t)))&&n(e)}))}onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)};onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)};destroy(){this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag)}}class yd extends pd{static defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#EEF6FF",stroke:"#DDEEFE",fillOpacity:.4,zIndex:2,pointerEvents:"none"}};startPoint;endPoint;rectShape;shortcut;constructor(t,e){super(t,ce({},yd.defaultOptions,e)),this.shortcut=new md(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e}=this.context;this.rectShape=new Ks({id:"g6-brush-select",style:this.options.style}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){if(!this.startPoint)return;const{immediately:e,mode:n}=this.options;this.endPoint=vd(t),this.rectShape?.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),e&&"default"===n&&this.updateElementsStates(Ol(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=vd(t),this.updateElementsStates(Ol(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce(((t,e)=>Object.assign({},t,e.reduce(((t,e)=>(t[Xc(e)]=[],t)),{}))),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,a=this.selector(e,t,n);let s={};switch(i){case"union":a.forEach((t=>{s[t]=[...e.getElementState(t),r]}));break;case"diff":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter((t=>t!==r)):[...n,r]}));break;case"intersect":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]}));break;default:a.forEach((t=>{s[t]=[r]}))}Ot(o)&&(s=o(s)),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach((n=>{const o=i[`${n}s`];o?.forEach((n=>{const i=Xc(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let a=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;t<s;r=t++){const s=e[t+n][0],u=e[t+n][1],c=e[r+n][0],l=e[r+n][1];u>o!=l>o&&i<(c-s)*(o-u)/(l-u)+s&&(a=!a)}return a}(t.getElementPosition(i),e)&&r.push(i)}))})),n.includes("edge")){const t=i.edges;t?.forEach((t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(Xc(t))}))}return r}clearBrush(){this.rectShape?.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return!(t&&!e.includes("drag"))||this.shortcut.match(e)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(`canvas:${t.CommonEvent.CLICK}`,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(`canvas:${t.CommonEvent.CLICK}`,this.clearStates)}update(t){this.options=ce(this.options,t)}destroy(){this.unbindEvents(),super.destroy()}}const vd=t=>[t.canvas.x,t.canvas.y];function bd(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)bd(t,e,n,r,i+1);"BT"===r&&e(t,i)}function xd(t,e,n,r){if("combo"===e||"node"===e)return wd(t,n,r);const i=t.getEdgeData(n);if(!i)return[];const o=wd(t,i.source,r-1),a=wd(t,i.target,r-1);return Array.from(new Set([...o,...a,n]))}function wd(t,e,n){const r=new Set,i=new Set,o=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,((e,r)=>{r>n||(o.add(e),t.getRelatedEdgesData(e).forEach((t=>{const e=Xc(t);!i.has(e)&&r<n&&(o.add(e),i.add(e))})))}),(e=>t.getRelatedEdgesData(e).map((t=>t.source===e?t.target:t.source)).filter((t=>!r.has(t)&&(r.add(t),!0))))),Array.from(o)}class Ed extends pd{selectedElementIds=[];shortcut;static defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],selectedState:"selected",unselectedState:void 0,degree:0};constructor(t,e){super(t,Object.assign({},Ed.defaultOptions,e)),this.shortcut=new md(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ql.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickElement)})),e.on(`canvas:${t.CommonEvent.CLICK}`,this.onClickCanvas)}onClickElement=t=>{this.validate(t)&&(this.updateElementsState(t,!1),this.updateElementsState(t,!0))};onClickCanvas=t=>{this.validate(t)&&(this.updateElementsState(t,!1),this.selectedElementIds=[])};updateElementsState=(t,e)=>{if(!this.options.selectedState&&!this.options.unselectedState)return;const{graph:n}=this.context,{targetType:r,target:i}=t;if(e)if(this.selectedElementIds.includes(i.id))this.selectedElementIds=this.selectedElementIds.filter((t=>t!==i.id));else{const t=xd(n,r,i.id,this.options.degree);this.options.multiple&&this.shortcut.match(this.options.trigger)?this.selectedElementIds.push(...t):this.selectedElementIds=t}if(!this.selectedElementIds.length)return;const o={};if(this.options.selectedState&&Object.assign(o,this.getElementsState(this.selectedElementIds,this.options.selectedState,e)),this.options.unselectedState){const t=Qc(n.getData(),!0).filter((t=>!this.selectedElementIds.includes(t)));Object.assign(o,this.getElementsState(t,this.options.unselectedState,e))}n.setElementState(o,this.options.animation)};getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t),a=n?[...o,e]:o.filter((t=>t!==e));i[t]=a})),i};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ql.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickElement)})),e.off(`canvas:${t.CommonEvent.CLICK}`,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}class Md extends pd{static defaultOptions={enable:!0,animation:!0};constructor(t,e){super(t,Object.assign({},Md.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),e.on(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}unbindEvents(){const{graph:e}=this.context;e.off(`combo:${t.CommonEvent.DBLCLICK}`,this.onCollapseExpand)}onCollapseExpand=async t=>{if(!this.validate(t))return;const{target:e}=t;if(!(Hh(n=e)||Uh(n)||$h(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,a=i.getComboData([r])[0];if(!a)return!1;const{onCollapse:s,onExpand:u,animation:c}=this.options,l=a.style?.collapsed;l?(await o.expandElement(r,c),u?.(r)):(await o.collapseElement(r,c),s?.(r))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}const Sd="g6-create-edge-assist-node-id";class Nd extends pd{static defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};source;constructor(t,e){super(t,Object.assign({},Nd.defaultOptions,e)),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(`node:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.on(`combo:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.on(`canvas:${t.CommonEvent.CLICK}`,this.cancelEdge),e.on(`edge:${t.CommonEvent.CLICK}`,this.cancelEdge)):(e.on(`node:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.on(`combo:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}drop=async t=>{const{targetType:e}=t;["combo","node"].includes(e)&&this.source?await this.handleCreateEdge(t):await this.cancelEdge()};handleCreateEdge=async t=>{if(!this.validate(t))return;const{graph:e,canvas:n}=this.context,{style:r}=this.options;if(this.source)return this.createEdge(t),void await this.cancelEdge();n.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0],e.addNodeData([{id:Sd,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}]}}]),e.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Sd,style:{pointerEvents:"none",...r}}])};updateAssistEdge=async t=>{if(!this.source)return;const{model:e,element:n}=this.context;e.translateNodeTo(Sd,[t.canvas.x,t.canvas.y]),await n.draw({animation:!1,silence:!0})};createEdge=t=>{const{graph:e}=this.context,{style:n,onFinish:r,onCreate:i}=this.options,o=t.target?.id;if(void 0===o||void 0===this.source)return;const a=this.getSelectedNodeIDs([t.target.id])?.[0];var s;const u=i({id:`${this.source}-${a}-${ve[s=s||"g"]?ve[s]+=1:ve[s]=1,s+ve[s]}`,source:this.source,target:a,style:n});e.addEdgeData([u]),r(u)};cancelEdge=async()=>{if(!this.source)return;const{graph:t,element:e,canvas:n}=this.context;n.setCursor("default"),t.removeNodeData([Sd]),this.source=void 0,await e.draw({animation:!1,silence:!0})};getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(`node:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.off(`combo:${t.CommonEvent.CLICK}`,this.handleCreateEdge),e.off(`canvas:${t.CommonEvent.CLICK}`,this.cancelEdge),e.off(`edge:${t.CommonEvent.CLICK}`,this.cancelEdge),e.off(`node:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.off(`combo:${t.CommonEvent.DRAG_START}`,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}class kd extends pd{static defaultOptions={enable:!0,sensitivity:10};shortcut;defaultCursor;constructor(t,e){super(t,Object.assign({},kd.defaultOptions,e)),this.shortcut=new md(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default",t.canvas.setCursor("grab")}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;this.shortcut.unbindAll();const{graph:n}=this.context;if(Lt(e)){n.off(t.CanvasEvent.DRAG,this.onDrag);const{up:r=[],down:i=[],left:o=[],right:a=[]}=e;this.shortcut.bind(r,(t=>this.onTranslate([0,1],t))),this.shortcut.bind(i,(t=>this.onTranslate([0,-1],t))),this.shortcut.bind(o,(t=>this.onTranslate([1,0],t))),this.shortcut.bind(a,(t=>this.onTranslate([-1,0],t)))}else n.on(t.CanvasEvent.DRAG,this.onDrag)}onDrag=t=>{this.validate(t)&&"canvas"===t.targetType&&(this.translate([t.movement.x,t.movement.y],!1),this.options.onFinish?.())};async onTranslate(t,e){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;await this.translate(sl(t,r),this.options.animation),this.options.onFinish?.()}async translate(t,e){await this.context.graph.translateBy(t,e)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}destroy(){this.shortcut.destroy(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}class Cd extends pd{static defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5]};enable=!1;enableElements=["node","combo"];target=[];shadow;shadowOrigin=[0,0];hiddenEdges=[];get animation(){return!!this.options.shadow&&this.options.animation}constructor(t,e){super(t,Object.assign({},Cd.defaultOptions,e)),this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),this.enableElements.forEach((n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),["link"].includes(this.options.dropEffect)&&(e.on(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.on(`canvas:${t.CommonEvent.DROP}`,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return ul([t.dx,t.dy],e)}onDragStart(t){this.enable=this.validate(t),this.enable&&(this.context.batch?.startBatch(),this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=al([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),this.options.onFinish?.(this.target),this.context.batch?.endBatch(),this.target=[]}onDrop=async t=>{if("link"!==this.options.dropEffect)return;const{model:e,element:n}=this.context,r=t.target.id;this.target.forEach((t=>{const n=e.getParentData(t,kc);n&&Xc(n)===r&&e.refreshComboData(r),e.setParent(t,r,kc)})),await(n?.draw({animation:!0}))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}async moveElement(t,e){const{model:n,element:r}=this.context,{dropEffect:i}=this.options;t.forEach((t=>{const r=n.getElementType(t);"node"===r?n.translateNodeBy(t,e):"combo"===r&&n.translateComboBy(t,e)})),"move"===i&&t.forEach((t=>n.refreshComboData(t))),await r.draw({animation:this.animation})}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=el(this.options,"shadow"),n=Bc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Dc(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr({...e,...s,visibility:"visible"}):(this.shadow=new Ks({style:{...e,...s,pointerEvents:"none",$layer:"transient"}}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(Xc):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(Xc))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e}=this.context;this.enableElements.forEach((n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){this.unbindEvents(),this.shadow?.destroy(),super.destroy()}}var Td=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function Ad(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function Pd(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&Pd(i,e,n,r))return!0;return!1}const Od=()=>!0;class _d{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||Od,n=t.edgeFilter||Od;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach((t=>e.add(t.id))),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Ad([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Pd(this.getNode(t),new Set,e,r)}}let Rd=class t extends Td{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const n=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateNodeDataProperty(t,e,n)}))}))}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})}))}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})}))}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateEdgeDataProperty(t,e,n)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach((t=>{t.children?.forEach((n=>{this.setParent(n.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n),i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(void 0===e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const a=this.getNode(e);r.parentMap.set(t,a),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(a.id);s||(s=new Set,r.childrenMap.set(a.id,s)),s.add(i),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:a.id})}))}dfsTree(t,e,n){return Pd(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Ad([this.getNode(t)],new Set,e,(t=>this.getChildren(t,n)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Ad([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Pd(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),n=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new t({nodes:e,edges:n});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach(((t,e)=>{i.set(e,r.getNode(t.id))}));const o=new Map;e.forEach(((t,e)=>{o.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:i,childrenMap:o})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new _d({graph:this,...t})}};class Id{options;constructor(t){this.options=t||{}}stop;tick}function Dd(t){const{nodes:e,edges:n}=t,r={nodes:[],edges:[],combos:[]};return e.forEach((t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;e?.push({id:t.id,style:{x:n,y:i,z:o}})})),n.forEach((t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:a=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:{...a?.length?{controlPoints:a.map(wl)}:{}}})})),r}function Ld(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function jd(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class Bd extends Cd{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find((t=>["d3-force","d3-force-3d"].includes(t?.id)))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(console.warn("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}async moveElement(t,e){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach(((r,i)=>{const{x:o=0,y:a=0}=r.style||{};n&&Ld(n,"setFixedPosition",t[i],[...ol([+o,+a],e)])}))}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&jd(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e&&Ld(e,"setFixedPosition",Xc(t),[+n,+r])}))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&jd(t,"simulation").alphaTarget(0),this.context.graph.getNodeData(this.target).forEach((e=>{t&&Ld(t,"setFixedPosition",Xc(e),[null,null,null])}))}}class zd extends pd{static defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};constructor(t,e){super(t,Object.assign({},zd.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ql.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}focus=async t=>{if(!this.validate(t))return;const{graph:e}=this.context;await e.focusElement(t.target.id,this.options.animation)};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ql.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}destroy(){this.unbindEvents(),super.destroy()}}class Fd extends pd{static defaultOptions={animation:!0,enable:!0,degree:0,activeState:"active",inactiveState:void 0};constructor(t,e){super(t,Object.assign({},Fd.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ql.forEach((n=>{e.on(`${n}:${t.CommonEvent.POINTER_OVER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_OUT}`,this.hoverEndElement)}))}hoverElement=t=>{this.validate(t)&&(this.updateElementsState(t,!0),this.options.onHover?.(t))};hoverEndElement=t=>{this.validate(t)&&(this.updateElementsState(t,!1),this.options.onHoverEnd?.(t))};updateElementsState=(t,e)=>{if(!this.options.activeState&&!this.options.inactiveState)return;const{graph:n}=this.context,{targetType:r,target:i}=t,o=xd(n,r,i.id,this.options.degree),a={};if(this.options.activeState&&Object.assign(a,this.getElementsState(o,this.options.activeState,e)),this.options.inactiveState){const t=Qc(n.getData(),!0).filter((t=>!o.includes(t)));Object.assign(a,this.getElementsState(t,this.options.inactiveState,e))}n.setElementState(a,this.options.animation)};getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t),a=n?[...o,e]:o.filter((t=>t!==e));i[t]=a})),i};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ql.forEach((n=>{e.off(`${n}:${t.CommonEvent.POINTER_OVER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_OUT}`,this.hoverEndElement)}))}destroy(){this.unbindEvents(),super.destroy()}}class Gd extends yd{points;pathShape;onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e}=this.context;this.pathShape=new $s({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[vd(t)]}onPointerMove(t){if(!this.points)return;const{immediately:e,mode:n}=this.options;this.points.push(vd(t)),this.pathShape?.setAttribute("d",function(t,e=!0){const n=[];return t.forEach(((t,e)=>{n.push([0===e?"M":"L",...t])})),e&&n.push(["Z"]),n}(this.points)),e&&"default"===n&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){this.pathShape?.remove(),this.pathShape=void 0,this.points=void 0}}class Vd extends pd{static defaultOptions={enable:!0,sensitivity:1};shortcut;constructor(t,e){super(t,Object.assign({},Vd.defaultOptions,e)),this.shortcut=new md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;this.shortcut.unbindAll();const{graph:n}=this.context;if(Lt(e)){n.off(t.CanvasEvent.WHEEL,this.onWheel);const{up:r=[],down:i=[],left:o=[],right:a=[]}=e;this.shortcut.bind(r,(t=>this.scroll([0,-10],t))),this.shortcut.bind(i,(t=>this.scroll([0,10],t))),this.shortcut.bind(o,(t=>this.scroll([-10,0],t))),this.shortcut.bind(a,(t=>this.scroll([10,0],t)))}else this.graphDom?.addEventListener(t.CanvasEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}onWheel=async t=>{t.preventDefault();const e=t.deltaX,n=t.deltaY;await this.scroll([-e,-n],t)};formatDisplacement([t,e]){const{direction:n,sensitivity:r}=this.options;return t*=r,e*=r,"x"===n?e=0:"y"===n&&(t=0),[t,e]}async scroll(t,e){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);await r.translateBy(i,!1),n?.()}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}destroy(){this.shortcut.destroy(),this.graphDom?.removeEventListener(t.CanvasEvent.WHEEL,this.onWheel),super.destroy()}}class Wd extends pd{static defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[]};shortcut;constructor(t,e){super(t,Object.assign({},Wd.defaultOptions,e)),this.shortcut=new md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Dt(e)&&(this.preventDefault(t.CanvasEvent.WHEEL),this.shortcut.bind([...e,t.CanvasEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(n??e),t,!1)}))),Lt(e)){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,(t=>this.zoom(10,t,this.options.animation))),this.shortcut.bind(n,(t=>this.zoom(-10,t,this.options.animation))),this.shortcut.bind(r,this.onReset)}}zoom=async(t,e,n)=>{if(!this.validate(e))return;const{graph:r}=this.context;let i;"viewport"in e&&(i=wl(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+Ut(t,-50,50)*o/100,u=r.getZoom();await r.zoomTo(u*s,n,i),a?.()};onReset=async()=>{await this.context.graph.zoomTo(1,this.options.animation)};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ot(e)?e(t):!!e}preventDefault(t){const e=this.context.canvas.getContainer();e&&e.addEventListener(t,(t=>t.preventDefault()))}destroy(){this.shortcut.destroy(),super.destroy()}}var Hd={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},Ud=Hd,$d={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function qd(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof qd)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}Ud.assign(qd.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)})),t},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var Yd=function(t,e,n){void 0===e&&(e={});var r,i=new qd(t,e=Ud.assign({},$d,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var u=0;u<s;u++){var c=new qd(a[u],e);r.children[u]=c,o.push(c),c.parent=r,c.depth=r.depth+1}}return i},Kd=Yd,Xd=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=Kd(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),Zd=Xd;function Qd(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function Jd(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){Jd(t,e,n)}))}function tf(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(tf(t,e),n)})),n}function ef(t,e){Jd(t,-tf(t,e),e)}function nf(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){nf(t,e.children[r],n)}))}function rf(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){rf(t,e,n)}))}Qd.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(Qd.fromNode(t,e))})),e?new Qd(t.height,t.width,t.x,n):new Qd(t.width,t.height,t.y,n)};var of=Yd,af=function(t,e){for(var n=of(t.data,e,!0),r=of(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var u=t.children[s];"right"===a(u,s)?r.children.push(u):n.children.push(u)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},sf=af,uf=["LR","RL","TB","BT","H","V"],cf=["LR","RL","H"],lf=uf[0],hf=function(t,e,n){var r=e.direction||lf;if(e.isHorizontal=function(t){return cf.indexOf(t)>-1}(r),r&&-1===uf.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===uf[0])n(t,e);else if(r===uf[1])n(t,e),t.right2left();else if(r===uf[2])n(t,e);else if(r===uf[3])n(t,e),t.bottom2top();else if(r===uf[4]||r===uf[5]){var i=sf(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var u=e.fixedRoot;return void 0===u&&(u=!0),u&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),t};function df(t,e){return df=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},df(t,e)}var ff=function(t,e){void 0===e&&(e={});var n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){for(var r=t.c[e-1],i=r.mod,c=t.c[e],l=c.mod;null!==r&&null!==c;){u(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(l+c.prelim);h>0&&(l+=h,o(t,e,n.index,h));var d=u(r),f=u(c);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(c=a(c))&&(l+=c.mod)}!r&&c?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,c,l):r&&!c&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function a(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function u(t){return t.y+t.h}function c(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}rf(t,n);var l=Qd.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=c(u(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=u(e.c[o].er);i(e,o,n),n=c(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(l),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(l,0),nf(l,t,n),ef(t,n),t},pf=hf,gf=Hd,mf=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,df(n,r),e.prototype.execute=function(){return pf(this.rootNode,this.options,ff)},e}(Zd),yf={};var vf=function(t,e){return e=gf.assign({},yf,e),new mf(t,e).execute()},bf=Hd;function xf(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var wf={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function Ef(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){Ef(t,e.children[r],n)}))}function Mf(t,e){return Mf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mf(t,e)}var Sf=function(t,e){void 0===e&&(e={}),e=bf.assign({},wf,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new xf(e.height,[]);return n.forEach((function(e,n){var r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)})),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),Ef(i,t,e.isHorizontal),t},Nf=hf,kf=Hd,Cf=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Mf(n,r),e.prototype.execute=function(){var t=this;return t.rootNode.width=0,Nf(t.rootNode,t.options,Sf)},e}(Zd),Tf={};var Af=function(t,e){return e=kf.assign({},Tf,e),new Cf(t,e).execute()},Pf=Hd;function Of(t,e){return Of=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Of(t,e)}var _f=Zd,Rf=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o="function"==typeof n?n(t):n*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+Pf.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Pf.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},If=af,Df=Hd,Lf=["LR","RL","H"],jf=Lf[0],Bf=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Of(n,r),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?jf:a,u=t.align;if(s&&-1===Lf.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Lf[0])Rf(e,r,o,u);else if(s===Lf[1])Rf(e,r,o,u),e.right2left();else if(s===Lf[2]){var c=If(e,t),l=c.left,h=c.right;Rf(l,r,o,u),l.right2left(),Rf(h,r,o,u);var d=l.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},e}(_f),zf={};var Ff=function(t,e){return e=Df.assign({},zf,e),new Bf(t,e).execute()},Gf=Hd;function Vf(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=Vf(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function Wf(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){Wf(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var Hf={getSubTreeSep:function(){return 0}};function Uf(t,e){return Uf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Uf(t,e)}var $f=function(t,e){void 0===e&&(e={}),e=Gf.assign({},Hf,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,Vf(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),Wf(t)},qf=hf,Yf=Hd,Kf=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Uf(n,r),e.prototype.execute=function(){return qf(this.rootNode,this.options,$f)},e}(Zd),Xf={};var Zf=function(t,e){return e=Yf.assign({},Xf,e),new Kf(t,e).execute()},Qf={compactBox:vf,dendrogram:Af,indented:Ff,mindmap:Zf};const Jf=(t,e)=>{if("next"!==t&&"prev"!==t)return e},tp=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let ep=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return tp(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&tp(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,Jf)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},np=class extends ep{};const rp=()=>1,ip=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)op(t,e,n,a);for(;a=i.dequeue();)op(t,e,n,a);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(a=e[i].dequeue(),a){r=r.concat(op(t,e,n,a,!0));break}}return r},op=(t,e,n,r,i)=>{var o,a;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach((r=>{const o=r.data.weight,a=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===a.data.out&&(a.data.out=0),a.data.out-=o,sp(e,n,Object.assign({v:a.id},a.data))})),null===(a=t.getRelatedEdges(r.v,"out"))||void 0===a||a.forEach((r=>{const i=r.data.weight,o=r.target,a=t.getNode(o);void 0===a.data.in&&(a.data.in=0),a.data.in-=i,sp(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},ap=(t,e)=>{const n=new Rd;let r=0,i=0;t.getAllNodes().forEach((t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((t=>{const o=n.getRelatedEdges(t.source,"out").find((e=>e.target===t.target)),a=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+a})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:a}}),i=Math.max(i,n.getNode(t.source).data.out+=a),r=Math.max(r,n.getNode(t.target).data.in+=a)}));const o=[],a=i+r+3;for(let t=0;t<a;t++)o.push(new np);const s=r+1;return n.getAllNodes().forEach((t=>{sp(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},sp=(t,e,n)=>{n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},up=(t,e)=>{const n="greedy"===e?((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=ap(t,e||rp);return null===(n=ip(r.graph,r.buckets,r.zeroIdx).map((e=>t.getRelatedEdges(e.v,"out").filter((({target:t})=>t===e.w)))))||void 0===n?void 0:n.flat()})(t,(t=>t.data.weight||1)):cp(t);null==n||n.forEach((e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})}))},cp=t=>{const e=[],n={},r={},i=o=>{r[o]||(r[o]=!0,n[o]=!0,t.getRelatedEdges(o,"out").forEach((t=>{n[t.target]?e.push(t):i(t.target)})),delete n[o])};return t.getAllNodes().forEach((t=>i(t.id))),e},lp=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},hp=t=>{const e=new Rd;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},dp=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,u=Number(t.width)/2,c=Number(t.height)/2;return i||o?(Math.abs(o)*u>Math.abs(i)*c?(o<0&&(c=-c),a=c*i/o,s=c):(i<0&&(u=-u),a=u,s=u*o/i),{x:n+a,y:r+s}):{x:0,y:0}},fp=t=>{const e=[],n=gp(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(let r=0;r<n;r++)e[r]=e[r].sort(((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},pp=(t,e,n,r)=>{const i={width:0,height:0};return $t(n)&&$t(r)&&(i.rank=n,i.order=r),lp(t,"border",i,e)},gp=t=>{let e;return t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},mp=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),yp=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>yp(t,e,n,r,i,o))),n&&o.push(e.id))},vp=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),a=[],s=[];return i.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);yp(t,e,"post"===n,s,o,a)})),a},bp=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],u=lp(t,"border",a,n);i.data[e][o]=u,t.setParent(u,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:u,data:{weight:1}})},xp=t=>{t.getAllNodes().forEach((t=>{wp(t)})),t.getAllEdges().forEach((t=>{wp(t)}))},wp=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Ep=t=>{t.getAllNodes().forEach((t=>{Mp(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Mp(t))),t.data.hasOwnProperty("y")&&Mp(t.data)}))},Mp=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Sp=t=>{t.getAllNodes().forEach((t=>{Np(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Np(t))),t.data.hasOwnProperty("x")&&Np(t.data)}))},Np=t=>{const e=t.x;t.x=t.y,t.y=e},kp=(t,e,n,r,i,o,a)=>{const s=t.getChildren(a);if(!(null==s?void 0:s.length))return void(a!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:n}}));const u=pp(t,"_bt"),c=pp(t,"_bb"),l=t.getNode(a);t.setParent(u,a),l.data.borderTop=u,t.setParent(c,a),l.data.borderBottom=c,null==s||s.forEach((s=>{kp(t,e,n,r,i,o,s.id);const l=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=l!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:u,target:l,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:c,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:u,data:{weight:0,minlen:i+o[a]}})},Cp=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach((t=>n(t.id,i+1))),e[r]=i};return t.getRoots().forEach((t=>n(t.id,1))),e},Tp=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Ap="edge-label",Pp=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a===i+1)return;let u,c,l;for(t.removeEdge(e.id),l=0,++i;i<a;++l,++i)e.data.points=[],c={originalEdge:e,width:0,height:0,rank:i},u=lp(t,"edge",c,"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=Ap,c.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:u,data:{weight:e.data.weight}}),0===l&&n.push(u),r=u;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Op=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},_p=(t,e,n)=>{const r=(i=n,o=n.map(((t,e)=>e)),null==i?void 0:i.reduce(((t,e,n)=>(t[e]=o[n],t)),{}));var i,o;const a=e.map((e=>{const n=t.getRelatedEdges(e,"out").map((t=>({pos:r[t.target]||0,weight:t.data.weight})));return null==n?void 0:n.sort(((t,e)=>t.pos-e.pos))})),s=a.flat().filter((t=>void 0!==t));let u=1;for(;u<n.length;)u<<=1;const c=2*u-1;u-=1;const l=Array(c).fill(0,0,c);let h=0;return null==s||s.forEach((t=>{if(t){let e=t.pos+u;l[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=l[e+1]),e=e-1>>1,l[e]+=t.weight;h+=t.weight*n}})),h},Rp=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=_p(t,e[r-1],e[r]);return n},Ip=t=>{const e={},n=t.getAllNodes(),r=n.map((t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o.push([]);const a=n.sort(((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder));return null==s||s.forEach((n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==a||a.forEach((n=>t.dfsTree(n.id,(t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})))),o},Dp=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Lp(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((e=>{return(n=i,e=>{e.in.push(n),0==--e.indegree&&t.push(e)})(e);var n}))}const i=r.filter((t=>!t.merged)),o=["vs","i","barycenter","weight"];return i.map((t=>{const e={};return null==o||o.forEach((n=>{void 0!==t[n]&&(e[n]=t[n])})),e}))},Lp=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},jp=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},Bp=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},zp=(t,e,n,r,i,o)=>{var a,s,u,c;let l=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(l=null==l?void 0:l.filter((t=>t!==d&&t!==f)));const g=((t,e)=>e.map((e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach((e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight})),{v:e,barycenter:r.sum/r.weight,weight:r.weight}})))(t,l||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=zp(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&Gp(e,i)}}));const m=((t,e)=>{var n,r,i;const o={};null==t||t.forEach(((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)})),null===(n=e.getAllEdges())||void 0===n||n.forEach((t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));const a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(t=>!t.indegree));return Dp(a)})(g,n);Fp(m,p),null===(a=m.filter((t=>t.vs.length>0)))||void 0===a||a.forEach((e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));const y=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach((t=>{e(t)?n.lhs.push(t):n.rhs.push(t)})),n})(t,(t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort(((t,e)=>-t.i- -e.i)),s=[];let u=0,c=0,l=0;null==o||o.sort(Bp(!!e,!!n)),l=jp(s,a,l),null==o||o.forEach((t=>{var e;l+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,c+=t.weight,l=jp(s,a,l)}));const h={vs:s.flat()};return c&&(h.barycenter=u/c,h.weight=c),h})(m,r,i,o);if(d&&(y.vs=[d,y.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(u=t.getPredecessors(d))||void 0===u?void 0:u[0].id)||""),n=t.getNode((null===(c=t.getPredecessors(f))||void 0===c?void 0:c[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+e.data.order+n.data.order)/(y.weight+2),y.weight+=2}return y},Fp=(t,e)=>{null==t||t.forEach((t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map((t=>e[t]?e[t].vs:t));t.vs=r.flat()}))},Gp=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},Vp=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Op(t),i=new Rd({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((o=>{const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach((e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find((({target:t})=>t===o.id)),a=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+a})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+a}})})),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i})(t,e,n))),Wp=(t,e,n,r)=>{const i=new Rd;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=zp(t,a,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach((n=>{let o,a,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(a=r[o.id],r[o.id]=s.id):(a=i,i=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${a}-${s.id}`)||e.addEdge({id:`e${a}-${s.id}`,source:a,target:s.id,data:{}}));s=o}}))})(t,i,s.vs)}))},Hp=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},Up=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach((t=>r(t.id))),e[i]={low:o,lim:n++}};return t.getRoots().forEach((t=>r(t.id))),e})(t);e.forEach((e=>{var r,i;let o=e,a=t.getNode(o);const s=a.data.originalEdge;if(!s)return;const u=((t,e,n,r)=>{var i,o;const a=[],s=[],u=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);let l,h;l=n;do{l=null===(i=t.getParent(l))||void 0===i?void 0:i.id,a.push(l)}while(l&&(e[l].low>u||c>e[l].lim));for(h=l,l=r;l&&l!==h;)s.push(l),l=null===(o=t.getParent(l))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),c=u.path,l=u.lca;let h=0,d=c[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==l&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=c[h];d===l&&(f=!1)}if(!f){for(;h<c.length-1&&(null===(i=t.getNode(c[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=c[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},$p=(t,e)=>{const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,a){var s,u;let c;for(let l=r;l<i;l++)c=e[l],(null===(s=t.getNode(c))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(c))||void 0===u||u.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&Yp(n,e.id,c)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((u,c)=>{var l;if("border"===(null===(l=t.getNode(u))||void 0===l?void 0:l.data.dummy)){const e=t.getPredecessors(u)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,c,o,i],s),a=c,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},qp=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find((e=>t.getNode(e.id).data.dummy))},Yp=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},Kp=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},Xp=(t,e,n,r,i,o)=>{const a=new Rd,s=Zp(r,i,o);return null==e||e.forEach((e=>{let r;null==e||e.forEach((e=>{const i=n[e];if(a.hasNode(i)||a.addNode({id:i,data:{}}),r){const o=n[r],u=a.getRelatedEdges(o,"out").find((t=>t.target===i));u?a.updateEdgeData(u.id,Object.assign(Object.assign({},u.data),{weight:Math.max(s(t,e,r),u.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e}))})),a};const Zp=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let u=0,c=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":c=-a.data.width/2;break;case"r":c=a.data.width/2}if(c&&(u+=n?c:-c),c=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(u+=n?c:-c),c=0,u},Qp=(t,e)=>t.getNode(e).data.width||0,Jp=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=fp(t),a=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach(((e,u)=>{var c;const l=qp(t,e),h=l?t.getNode(l.id).data.order:a;(l||e===s)&&(null===(c=r.slice(o,u+1))||void 0===c||c.forEach((e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((r=>{var o;const a=t.getNode(r.id),s=a.data.order;!(s<i||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||Yp(n,r.id,e)}))})),o=u+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),$p(t,o)),s={};let u=[];["u","d"].forEach((e=>{u="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(u=u.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=((t,e,n,r)=>{const i={},o={},a={};return null==e||e.forEach((t=>{null==t||t.forEach(((t,e)=>{i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((t=>{let e=-1;null==t||t.forEach((t=>{let s=r(t).map((t=>t.id));if(s.length){s=s.sort(((t,e)=>a[t]-a[e]));const r=(s.length-1)/2;for(let u=Math.floor(r),c=Math.ceil(r);u<=c;++u){const r=s[u];o[t]===t&&e<a[r]&&!Kp(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,u,a,o),l=((t,e,n,r,i,o,a)=>{var s;const u={},c=Xp(t,e,n,i,o,a),l=a?"borderLeft":"borderRight",h=(t,e)=>{let n=c.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return h((t=>{u[t]=(c.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(u[e.source]||0)+e.data.weight)),0)}),c.getPredecessors.bind(c)),h((e=>{const n=(c.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(u[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==l&&(u[e]=Math.max(u[e],n))}),c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{u[t]=u[n[t]]})),u})(t,u,c.root,c.align,r,i,"r"===n);"r"===n&&Object.keys(l).forEach((t=>l[t]=-l[t])),s[e+n]=l}))}));const c=((t,e)=>mp(Object.values(e),(e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((n=>{const o=e[n],a=Qp(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return c&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach((n=>{["l","r"].forEach((o=>{const a=n+o,s=t[a];let u;if(s===e)return;const c=Object.values(s);u="l"===o?r-Math.min(...c):i-Math.max(...c),u&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+u})))}))}))}(s,c),((t,e)=>{const n={};return Object.keys(t.ul).forEach((r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map((t=>t[r]));n[r]=(e[0]+e[1])/2}})),n})(s,n)},tg=(t,e)=>{var n;const r=hp(t);((t,e)=>{const{ranksep:n=0}=e||{},r=fp(t);let i=0;null==r||r.forEach((e=>{const r=e.map((e=>t.getNode(e).data.height)),o=Math.max(...r,0);null==e||e.forEach((e=>{t.getNode(e).data.y=i+o/2})),i+=o+n}))})(r,e);const i=Jp(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},eg=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let a;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),o.data.rank=a,a};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>n(t.id)))},ng=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,rg=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||ng(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},ig=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&ng(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},og=(t,e)=>mp(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?ng(e,n):1/0)),ag=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},sg=t=>{const e=(t=>{const e=new Rd;return t.getAllNodes().forEach((t=>{e.addNode(Object.assign({},t))})),t.getAllEdges().forEach((t=>{const n=e.getRelatedEdges(t.source,"out").find((e=>e.target===t.target));n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e})(t);eg(e);const n=(t=>{const e=new Rd({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);rg(e,t)<r;)i=og(e,t),o=e.hasNode(i.source)?ng(t,i):-ng(t,i),ag(e,t,o);return e})(e);let r,i;for(hg(n),ug(n,e);r=fg(n);)i=pg(n,e,r),gg(n,e,r,i)},ug=(t,e)=>{let n=vp(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{cg(t,e,n)}))},cg=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=lg(t,e,n)},lg=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find((t=>t.target===r)),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((t=>t.target===n))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,u=e.data.weight;if(a+=r?u:-u,yg(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},hg=(t,e=t.getAllNodes()[0].id)=>{dg(t,{},1,e)},dg=(t,e,n,r,i)=>{var o;const a=n;let s=n;const u=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=dg(t,e,s,n.id,r))})),u.data.low=a,u.data.lim=s++,i?u.data.parent=i:delete u.data.parent,s},fg=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),pg=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((t=>t.target===i))||(r=n.target,i=n.source);const o=t.getNode(r),a=t.getNode(i);let s=o,u=!1;o.data.lim>a.data.lim&&(s=a,u=!0);const c=e.getAllEdges().filter((e=>u===vg(t.getNode(e.source),s)&&u!==vg(t.getNode(e.target),s)));return mp(c,(t=>ng(e,t)))},gg=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find((t=>t.source===n.target||t.target===n.target));i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),hg(t),ug(t,e),mg(t,e)},mg=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=vp(t,n,"pre");r=r.slice(1),r.forEach((n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find((t=>t.target===r)),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((t=>t.target===n)),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))}))},yg=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),vg=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,bg=eg,xg=t=>{(t=>{const e={};let n;const r=i=>{var o;const a=t.getNode(i);if(!a)return 0;if(e[i])return a.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)})),s||(s=0),(void 0===n||s<n)&&(n=s),a.data.rank=s,s};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>{t&&r(t.id)})),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const a=t.getNode(e),s=isNaN(a.data.layer)?n:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((t=>{o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))}))})(t),(t=>{const e=new Rd({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);ig(e,t)<r;)i=og(e,t),o=e.hasNode(i.source)?ng(t,i):-ng(t,i),ag(e,t,o)})(t)},wg=t=>{sg(t)},Eg=(t,e)=>{const{acyclicer:n,ranker:r,rankdir:i="tb",nodeOrder:o,keepNodeOrder:a,align:s,nodesep:u=50,edgesep:c=20,ranksep:l=50}=e;Fg(t),up(t,n);const{nestingRoot:h,nodeRankFactor:d}=(t=>{const e=lp(t,"root",{},"_root"),n=Cp(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach((t=>{t.data.minlen*=o}));const a=Tp(t)+1;return t.getRoots().forEach((r=>{kp(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":wg(t);break;case"tight-tree":default:xg(t);break;case"longest-path":bg(t)}})(hp(t),r),_g(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),i=Math.min(...r),o=[];n.forEach((t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));let a=0;for(let n=0;n<o.length;n++){const r=o[n];void 0===r?n%e!=0&&(a-=1):a&&(null==r||r.forEach((e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}})(t,d),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,h),(t=>{const e=t.getAllNodes().filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),n=Math.min(...e);t.getAllNodes().forEach((t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))})(t),Rg(t),Ig(t);const f=[];((t,e)=>{t.getAllEdges().forEach((n=>Pp(t,n,e)))})(t,f),Up(t,f),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((t=>e(t.id))),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;e<r;e+=1)bp(t,"borderLeft","_bl",n,i,e),bp(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach((t=>e(t.id)))})(t),a&&((t,e)=>{const n=t.getAllNodes().filter((e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})),r=n.map((t=>t.data.rank)),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))}))})(t,o),((t,e)=>{const n=gp(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=Vp(t,r,"in"),a=Vp(t,i,"out");let s=Ip(t);Hp(t,s);let u,c=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){Wp(n%2?o:a,n%4>=2,!1,e),s=fp(t);const i=Rp(t,s);i<c&&(r=0,u=oe(s),c=i)}s=Ip(t),Hp(t,s);for(let n=0,r=0;r<4;++n,++r){Wp(n%2?o:a,n%4>=2,!0,e),s=fp(t);const i=Rp(t,s);i<c&&(r=0,u=oe(s),c=i)}Hp(t,u)})(t,a),Gg(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||xp(t)})(t,i),tg(t,{align:s,nodesep:u,edgesep:c,ranksep:l}),Vg(t),zg(t),((t,e)=>{e.forEach((e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let a=e;for(;n.data.dummy;)o=t.getSuccessors(a)[0],t.removeNode(a),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Ap&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),a=o.id,n=t.getNode(a)}))})(t,f),jg(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Ep(t),"lr"!==n&&"rl"!==n||(Sp(t),xp(t))})(t,i);const{width:p,height:g}=Dg(t);return Lg(t),Bg(t),(t=>{t.getAllEdges().forEach((e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}}))})(t),{width:p,height:g}},Mg=(t,e)=>{t.getAllNodes().forEach((n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder}))},Sg=(t,e)=>{t.getAllNodes().forEach((n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}})),t.getAllEdges().forEach((n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)}))},Ng=["width","height","layer","fixorder"],kg={width:0,height:0},Cg=["minlen","weight","width","height","labeloffset"],Tg={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Ag=["labelpos"],Pg=t=>{const e=new Rd({tree:[]});return t.getAllNodes().forEach((n=>{const r=Hg(t.getNode(n.id).data),i=Object.assign(Object.assign({},kg),r),o=Wg(i,Ng);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const a=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);_t(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=Hg(t.getEdge(n.id).data),i={};null==Ag||Ag.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Tg,Wg(r,Cg),i)})})),e},Og=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach((t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2},_g=t=>{t.getAllEdges().forEach((e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};lp(t,"edge-proxy",r,"_ep")}}))},Rg=t=>{let e=0;return t.getAllNodes().forEach((n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))})),e},Ig=t=>{t.getAllNodes().forEach((e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Dg=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}={},u=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(a)||isNaN(u)||(void 0===r&&(r=a-u/2),r=Math.min(r,a-u/2),o=Math.max(o,a+u/2))};return t.getAllNodes().forEach((t=>{u(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&u(t)})),n-=a,r-=s,t.getAllNodes().forEach((t=>{t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>{t.x-=n,t.y-=r})),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)})),{width:i-n+a,height:o-r+s}},Lg=t=>{t.getAllEdges().forEach((e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(dp(n.data,i)),e.data.points.push(dp(r.data,o))}))},jg=t=>{t.getAllEdges().forEach((t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},Bg=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},zg=t=>{t.getAllNodes().forEach((e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),a=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),u=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==u?void 0:u.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==a?void 0:a.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}})),t.getAllNodes().forEach((e=>{"border"===e.data.dummy&&t.removeNode(e.id)}))},Fg=t=>{t.getAllEdges().forEach((e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},Gg=t=>{const e=fp(t);null==e||e.forEach((e=>{let n=0;null==e||e.forEach(((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((e=>{lp(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},Vg=t=>{t.getAllNodes().forEach((e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,a=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{y:o,x:i+a},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}}))},Wg=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},Hg=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},Ug=Array.isArray,$g=t=>{const e=[],n=t.length;for(let r=0;r<n;r+=1){e[r]=[];for(let i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(let t=0;t<n;t+=1)for(let r=0;r<n;r+=1)for(let i=0;i<n;i+=1)e[r][i]>e[r][t]+e[t][i]&&(e[r][i]=e[r][t]+e[t][i]);return e},qg=(t,e)=>{const{nodes:n,edges:r}=t,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach(((t,e)=>{o[t.id]=e;i.push([])})),null==r||r.forEach((t=>{const{source:e,target:n}=t,r=o[e],a=o[n];void 0!==r&&void 0!==a&&(i[r][a]=1,i[a][r]=1)})),i},Yg=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),Kg=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let u=0;u<e.length;u++){const c=e[u];if(t.hasNode(c.id)&&!(null==a?void 0:a(c))){if(null==s?void 0:s(c))return;"TB"===r&&n(c),Kg(t,t.getChildren(c.id,i),n,r,i,o),"TB"!==r&&n(c)}}},Xg=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>Xg(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=Xg(t[n])})),e}return t},Zg=(t,e)=>{const n=Xg(t);return n.data=n.data||{},e&&($t(n.data.x)||(n.data.x=Math.random()*e[0]),$t(n.data.y)||(n.data.y=Math.random()*e[1])),n};function Qg(t,e){let n;return n=Ot(e)?e:$t(e)?()=>e:()=>t,n}function Jg(t,e,n=!0){return e||0===e?Ot(e)?e:$t(e)?()=>e:Array.isArray(e)?()=>{if(n){const n=Math.max(...e);return isNaN(n)?t:n}return e}:Lt(e)?()=>{if(n){const n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:()=>t:e=>{const{size:n}=e.data||{};return n?Array.isArray(n)?n[0]>n[1]?n[0]:n[1]:Lt(n)?n.width>n.height?n.width:n.height:n:t}}const tm=(t,e)=>{let n,r;return r=$t(e)?()=>e:Ot(e)?e:()=>0,n=t?Array.isArray(t)?e=>(t[0]>t[1]?t[0]:t[1])+r(e):Ot(t)?t:e=>t+r(e):t=>{var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);const e=t.data.size;if(Lt(e)){return(e.width>e.height?e.width:e.height)+r(t)}return e+r(t)}return 10+r(t)},n},em={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class nm{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},em),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{nodeSize:i,align:o,rankdir:a="TB",ranksep:s,nodesep:u,ranksepFunc:c,nodesepFunc:l,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:m,sortByCombo:y,preset:v}=r,b=new Rd({tree:[]}),x=Qg(s||50,c),w=Qg(u||50,l);let E=w,M=x;"LR"!==a&&"RL"!==a||(E=x,M=w);const S=tm(i,void 0),N=e.getAllNodes(),k=e.getAllEdges();let C;N.forEach((t=>{const e=S(t),n=M(t),r=e+2*E(t),i=e+2*n,o=t.data.layer;$t(o)?b.addNode({id:t.id,data:{width:r,height:i,layer:o}}):b.addNode({id:t.id,data:{width:r,height:i}})})),y&&(b.attachTreeStructure("combo"),N.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),k.forEach((t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==v?void 0:v.length)&&(C=new Rd({nodes:v})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&Mg(t,i);const s=Pg(t);let u;n&&(e.ranksep=Og(s,{rankdir:o,ranksep:a}));try{u=Eg(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}Sg(t,s)})(b,{prevGraph:C,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:u,align:o});const T=[0,0];if(p){let t=1/0,e=1/0;b.getAllNodes().forEach((n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)})),b.getAllEdges().forEach((n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach((n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)}))})),T[0]=p[0]-t,T[1]=p[1]-e}const A="LR"===a||"RL"===a;if(m);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach((e=>{e.data.x=e.data.x+T[0],e.data.y=e.data.y+T[1],t.add(A?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=A?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=A?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((t=>t.y<=r&&t.y>=i))}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((t=>t.x<=r&&t.x>=i))};b.getAllEdges().forEach(((t,e)=>{var o;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=rm(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+T[0],y:e+T[1]}))),b.getNode(t.source),b.getNode(t.target),n,A,r,i))}))}let P=[];P=b.getAllNodes().map((t=>Zg(t)));const O=b.getAllEdges();t&&(P.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),O.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:P,edges:O}}))}}const rm=(t,e,n,r,i,o,a)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:u}=e.data,{x:c,y:l}=n.data;if(i&&(t=e.data.y,u=e.data.x,c=n.data.y,l=n.data.x),l!==u&&t!==c){const h=r.indexOf(u),d=r[h+1];if(d){const t=s[0],e=i?{x:(u+d)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(u+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(l),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(u+l)/2,y:t}:{x:t,y:(u+l)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(l+e)/2,y:(null==n?void 0:n.y)||c}:{x:(null==n?void 0:n.x)||t,y:(l+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},im=(t,e,n)=>{const r=t.getAllNodes(),i=t.getAllEdges();if(!(null==r?void 0:r.length)){return{nodes:[],edges:i}}if(1===r.length){e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]});return{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:n[0],y:n[1]})})],edges:i}}},om={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class am{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},om),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:u=0,endAngle:c=2*Math.PI,angleRatio:l,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),m=e.getAllEdges(),[y,v,b]=um(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return im(e,t,b);const w=(c-u)/x;let{radius:E,startRadius:M,endRadius:S}=r;if(f){const t=Qg(10,f),e=Jg(10,p);let n=-1/0;g.forEach((t=>{const r=e(t);n<r&&(n=r)}));let r=0;g.forEach(((e,i)=>{r+=0===i?n||10:(t(e)||0)+(n||10)})),E=r/(2*Math.PI)}else E||M||S?!M&&S?M=S:M&&!S&&(S=M):E=Math.min(v,y)/2;const N=w*l;let k=[];k="topology"===h?sm(e,g):"topology-directed"===h?sm(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(Zg(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>Zg(t)));const C=Math.ceil(x/s);for(let t=0;t<x;++t){let e=E;e||null===M||null===S||(e=M+t*(S-M)/(x-1)),e||(e=10+100*t/(x-1));let n=u+t%C*N+2*Math.PI/s*Math.floor(t/C);d||(n=c-t%C*N-2*Math.PI/s*Math.floor(t/C)),k[t].data.x=b[0]+Math.cos(n)*e,k[t].data.y=b[1]+Math.sin(n)*e}t&&k.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:k,edges:m}}))}}const sm=(t,e,n=!1)=>{const r=[Zg(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,u)=>{if(0!==u)if(u!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const u=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let c=!1;for(let e=0;e<u.length;e++){const n=u[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(Zg(n)),i[n.id]=!0,c=!0;break}}let l=0;for(;!c&&(i[e[l].id]||(r.push(Zg(e[l])),i[e[l].id]=!0,c=!0),l++,l!==o););}else r.push(Zg(s)),i[s.id]=!0,a++})),r};const um=(t,e,n)=>{let r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},cm={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class lm{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},cm),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:u,sweep:c,clockwise:l,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,m=e.getAllNodes(),y=e.getAllEdges(),v=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[v/2,b/2];if(!(null==m?void 0:m.length)||1===m.length)return im(e,t,x);const w=[];let E,M=0;Ug(p)?E=Math.max(p[0],p[1]):Ot(p)?(E=-1/0,m.forEach((t=>{const e=p(t);e>E&&(E=e)}))):E=p,Ug(g)?M=Math.max(g[0],g[1]):$t(g)&&(M=g),m.forEach((t=>{const e=Zg(t);w.push(e);let n=E;const{data:r}=e;Ug(r.size)?n=Math.max(r.size[0],r.size[1]):$t(r.size)?n=r.size:Lt(r.size)&&(n=Math.max(r.size.width,r.size.height)),E=Math.max(E,n),Ot(g)&&(M=Math.max(g(t),M))}));const S={};w.forEach(((t,e)=>{S[t.id]=e}));let N=s;Vt(N)&&void 0!==w[0].data[N]||(N="degree"),"degree"===N?w.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):w.sort(((t,e)=>e.data[N]-t.data[N]));const k=w[0],C=(u||("degree"===N?e.getDegree(k.id,"both"):k.data[N]))/4,T=[{nodes:[]}];let A=T[0];w.forEach((t=>{if(A.nodes.length>0){const n="degree"===N?Math.abs(e.getDegree(A.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(A.nodes[0].data[N]-t.data[N]);C&&n>=C&&(A={nodes:[]},T.push(A))}A.nodes.push(t)}));let P=E+M;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(v,b)/2-P)/(T.length+(t?1:0));P=Math.min(P,e)}let O=0;if(T.forEach((t=>{const e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){const e=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),r=Math.sqrt(P*P/(e*e+n*n));O=Math.max(r,O)}t.r=O,O+=P})),h){let t=0,e=0;for(let n=0;n<T.length;n++){const r=(T[n].r||0)-e;t=Math.max(t,r)}e=0,T.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}T.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(l?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&w.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:w,edges:y}}))}}function hm(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,u,c,l,h,d,f=t._root,p={data:r},g=t._x0,m=t._y0,y=t._x1,v=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((c=e>=(o=(g+y)/2))?g=o:y=o,(l=n>=(a=(m+v)/2))?m=a:v=a,i=f,!(f=f[h=l<<1|c]))return i[h]=p,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&n===u)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+y)/2))?g=o:y=o,(l=n>=(a=(m+v)/2))?m=a:v=a}while((h=l<<1|c)==(d=(u>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function dm(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function fm(t){return t[0]}function pm(t){return t[1]}function gm(t,e,n){var r=new mm(null==e?fm:e,null==n?pm:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function mm(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function ym(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var vm=gm.prototype=mm.prototype;function bm(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,u,c,l,h,d,f,p,g,m,y=t._root,v={data:i},b=t._x0,x=t._y0,w=t._z0,E=t._x1,M=t._y1,S=t._z1;if(!y)return t._root=v,t;for(;y.length;)if((d=e>=(a=(b+E)/2))?b=a:E=a,(f=n>=(s=(x+M)/2))?x=s:M=s,(p=r>=(u=(w+S)/2))?w=u:S=u,o=y,!(y=y[g=p<<2|f<<1|d]))return o[g]=v,t;if(c=+t._x.call(null,y.data),l=+t._y.call(null,y.data),h=+t._z.call(null,y.data),e===c&&n===l&&r===h)return v.next=y,o?o[g]=v:t._root=v,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(b+E)/2))?b=a:E=a,(f=n>=(s=(x+M)/2))?x=s:M=s,(p=r>=(u=(w+S)/2))?w=u:S=u}while((g=p<<2|f<<1|d)==(m=(h>=u)<<2|(l>=s)<<1|c>=a));return o[m]=y,o[g]=v,t}function xm(t,e,n,r,i,o,a){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=a}function wm(t){return t[0]}function Em(t){return t[1]}function Mm(t){return t[2]}function Sm(t,e,n,r){var i=new Nm(null==e?wm:e,null==n?Em:n,null==r?Mm:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Nm(t,e,n,r,i,o,a,s,u){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=u,this._root=void 0}function km(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}vm.copy=function(){var t,e,n=new mm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=ym(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=ym(e));return n},vm.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return hm(this.cover(e,n),e,n,t)},vm.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),u=1/0,c=1/0,l=-1/0,h=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<u&&(u=r),r>l&&(l=r),i<c&&(c=i),i>h&&(h=i));if(u>l||c>h)return this;for(this.cover(u,c).cover(l,h),n=0;n<o;++n)hm(this,a[n],s[n],t[n]);return this},vm.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,u=i-n||1,c=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=c,c=a,u*=2,s){case 0:i=n+u,o=r+u;break;case 1:n=i-u,o=r+u;break;case 2:i=n+u,r=o-u;break;case 3:n=i-u,r=o-u}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},vm.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},vm.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},vm.find=function(t,e,n){var r,i,o,a,s,u,c,l=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new dm(g,l,h,d,f)),null==n?n=1/0:(l=t-n,h=e-n,d=t+n,f=e+n,n*=n);u=p.pop();)if(!(!(g=u.node)||(i=u.x0)>d||(o=u.y0)>f||(a=u.x1)<l||(s=u.y1)<h))if(g.length){var m=(i+a)/2,y=(o+s)/2;p.push(new dm(g[3],m,y,a,s),new dm(g[2],i,y,m,s),new dm(g[1],m,o,a,y),new dm(g[0],i,o,m,y)),(c=(e>=y)<<1|t>=m)&&(u=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=u)}else{var v=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=v*v+b*b;if(x<n){var w=Math.sqrt(n=x);l=t-w,h=e-w,d=t+w,f=e+w,r=g.data}}return r},vm.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,l,h,d,f=this._root,p=this._x0,g=this._y0,m=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((c=o>=(s=(p+m)/2))?p=s:m=s,(l=a>=(u=(g+y)/2))?g=u:y=u,e=f,!(f=f[h=l<<1|c]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},vm.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},vm.root=function(){return this._root},vm.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},vm.visit=function(t){var e,n,r,i,o,a,s=[],u=this._root;for(u&&s.push(new dm(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&u.length){var c=(r+o)/2,l=(i+a)/2;(n=u[3])&&s.push(new dm(n,c,l,o,a)),(n=u[2])&&s.push(new dm(n,r,l,c,a)),(n=u[1])&&s.push(new dm(n,c,i,o,l)),(n=u[0])&&s.push(new dm(n,r,i,c,l))}return this},vm.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new dm(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,u=e.x1,c=e.y1,l=(a+u)/2,h=(s+c)/2;(o=i[0])&&n.push(new dm(o,a,s,l,h)),(o=i[1])&&n.push(new dm(o,l,s,u,h)),(o=i[2])&&n.push(new dm(o,a,h,l,c)),(o=i[3])&&n.push(new dm(o,l,h,u,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},vm.x=function(t){return arguments.length?(this._x=t,this):this._x},vm.y=function(t){return arguments.length?(this._y=t,this):this._y};var Cm=Sm.prototype=Nm.prototype;Cm.copy=function(){var t,e,n=new Nm(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=km(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=km(e));return n},Cm.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return bm(this.cover(e,n,r),e,n,r,t)},Cm.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,u=-1/0,c=-1/0,l=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>u&&(u=d),f<a&&(a=f),f>c&&(c=f),p<s&&(s=p),p>l&&(l=p));if(o>u||a>c||s>l)return this;this.cover(o,a,s).cover(u,c,l);for(let o=0;o<e;++o)bm(this,n[o],r[o],i[o],t[o]);return this},Cm.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,u=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,u=(o=Math.floor(n))+1;else{for(var c,l,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=u;)switch(l=(n<o)<<2|(e<i)<<1|t<r,(c=new Array(8))[l]=d,d=c,h*=2,l){case 0:a=r+h,s=i+h,u=o+h;break;case 1:r=a-h,s=i+h,u=o+h;break;case 2:a=r+h,i=s-h,u=o+h;break;case 3:r=a-h,i=s-h,u=o+h;break;case 4:a=r+h,s=i+h,o=u-h;break;case 5:r=a-h,s=i+h,o=u-h;break;case 6:a=r+h,i=s-h,o=u-h;break;case 7:r=a-h,i=s-h,o=u-h}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=u,this},Cm.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Cm.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Cm.find=function(t,e,n,r){var i,o,a,s,u,c,l,h,d,f=this._x0,p=this._y0,g=this._z0,m=this._x1,y=this._y1,v=this._z1,b=[],x=this._root;for(x&&b.push(new xm(x,f,p,g,m,y,v)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,m=t+r,y=e+r,v=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>m||(a=h.y0)>y||(s=h.z0)>v||(u=h.x1)<f||(c=h.y1)<p||(l=h.z1)<g))if(x.length){var w=(o+u)/2,E=(a+c)/2,M=(s+l)/2;b.push(new xm(x[7],w,E,M,u,c,l),new xm(x[6],o,E,M,w,c,l),new xm(x[5],w,a,M,u,E,l),new xm(x[4],o,a,M,w,E,l),new xm(x[3],w,E,s,u,c,M),new xm(x[2],o,E,s,w,c,M),new xm(x[1],w,a,s,u,E,M),new xm(x[0],o,a,s,w,E,M)),(d=(n>=M)<<2|(e>=E)<<1|t>=w)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var S=t-+this._x.call(null,x.data),N=e-+this._y.call(null,x.data),k=n-+this._z.call(null,x.data),C=S*S+N*N+k*k;if(C<r){var T=Math.sqrt(r=C);f=t-T,p=e-T,g=n-T,m=t+T,y=e+T,v=n+T,i=x.data}}return i},Cm.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,l,h,d,f,p,g,m=this._root,y=this._x0,v=this._y0,b=this._z0,x=this._x1,w=this._y1,E=this._z1;if(!m)return this;if(m.length)for(;;){if((h=o>=(u=(y+x)/2))?y=u:x=u,(d=a>=(c=(v+w)/2))?v=c:w=c,(f=s>=(l=(b+E)/2))?b=l:E=l,e=m,!(m=m[p=f<<2|d<<1|h]))return this;if(!m.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;m.data!==t;)if(r=m,!(m=m.next))return this;return(i=m.next)&&delete m.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(m=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&m===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!m.length&&(n?n[g]=m:this._root=m),this):(this._root=i,this)},Cm.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Cm.root=function(){return this._root},Cm.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Cm.visit=function(t){var e,n,r,i,o,a,s,u,c=[],l=this._root;for(l&&c.push(new xm(l,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,u=e.z1)&&l.length){var h=(r+a)/2,d=(i+s)/2,f=(o+u)/2;(n=l[7])&&c.push(new xm(n,h,d,f,a,s,u)),(n=l[6])&&c.push(new xm(n,r,d,f,h,s,u)),(n=l[5])&&c.push(new xm(n,h,i,f,a,d,u)),(n=l[4])&&c.push(new xm(n,r,i,f,h,d,u)),(n=l[3])&&c.push(new xm(n,h,d,o,a,s,f)),(n=l[2])&&c.push(new xm(n,r,d,o,h,s,f)),(n=l[1])&&c.push(new xm(n,h,i,o,a,d,f)),(n=l[0])&&c.push(new xm(n,r,i,o,h,d,f))}return this},Cm.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new xm(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,u=e.z0,c=e.x1,l=e.y1,h=e.z1,d=(a+c)/2,f=(s+l)/2,p=(u+h)/2;(o=i[0])&&n.push(new xm(o,a,s,u,d,f,p)),(o=i[1])&&n.push(new xm(o,d,s,u,c,f,p)),(o=i[2])&&n.push(new xm(o,a,f,u,d,l,p)),(o=i[3])&&n.push(new xm(o,d,f,u,c,l,p)),(o=i[4])&&n.push(new xm(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new xm(o,d,s,p,c,f,h)),(o=i[6])&&n.push(new xm(o,a,f,p,d,l,h)),(o=i[7])&&n.push(new xm(o,d,f,p,c,l,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Cm.x=function(t){return arguments.length?(this._x=t,this):this._x},Cm.y=function(t){return arguments.length?(this._y=t,this):this._y},Cm.z=function(t){return arguments.length?(this._z=t,this):this._z};function Tm(t,e,n,r,i=2){const o=e/n,a=t.getAllNodes(),s=a.map(((t,e)=>{const{nodeStrength:n,x:r,y:i,z:a,size:s}=t.data;return{x:r,y:i,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n}})),u=(2===i?gm(s,(t=>t.x),(t=>t.y)):Sm(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Am),c=new Map;return s.forEach((t=>{c.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>Pm(e,r,i,o,a,t,n)))}(t,u,i)})),s.map(((t,e)=>{const{id:n,data:i}=a[e],{mass:o=1}=i;r[n]={x:t.vx/o,y:t.vy/o,z:t.vz/o}})),r}function Am(t){let e=0,n=0,r=0,i=0,o=0;const a=t.length;if(a){for(let s=0;s<a;s++){const a=t[s];a&&a.weight&&(e+=a.weight,n+=a.x*a.weight,r+=a.y*a.weight,i+=a.z*a.weight,o+=a.size*a.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const Pm=(t,e,n,r,i,o,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===o.id)return;const u=[n,r,i][a-1],c=o.x-t.x||.1,l=o.y-t.y||.1,h=o.z-t.z||.1,d=[c,l,h],f=u-e;let p=0;for(let t=0;t<a;t++)p+=d[t]*d[t];const g=Math.sqrt(p)*p;if(f*f*.81<p){const e=t.weight/g;return o.vx+=c*e,o.vy+=l*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=c*e,o.vy+=l*e,o.vz+=h*e}};const Om={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"};class _m{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Om),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericForceLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;(this.judgingDistance>this.lastOptions.minMovement||e<1)&&e<t;e++)this.runOneStep(this.lastCalcGraph,this.lastGraph,e,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),{dimensions:s,width:u,height:c,nodeSize:l,getMass:h,nodeStrength:d,edgeStrength:f,linkDistance:p}=a,g=i.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:$t(t.data.x)?t.data.x:Math.random()*u,y:$t(t.data.y)?t.data.y:Math.random()*c,z:$t(t.data.z)?t.data.z:Math.random()*Math.sqrt(u*c),size:l(t)||30,mass:h(t),nodeStrength:d(t)})}))),m=o.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:f(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})));if(!(null==i?void 0:i.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const y={};i.forEach(((t,e)=>{y[t.id]={x:0,y:0,z:0}}));const v=new Rd({nodes:g,edges:m});this.formatCentripetal(a,v);const{maxIteration:b,minMovement:x,onTick:w}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=v,this.lastOptions=a,this.lastVelMap=y,"undefined"==typeof window)return;let E=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:jm(e,g),edges:o}),this.runOneStep(v,e,E,y,a),this.updatePosition(e,v,y,a),t&&g.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==w||w({nodes:jm(e,g),edges:o}),E++,(E>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:jm(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o,nodeSize:a}=t;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),o||(n.getMass=t=>{let n=1;$t(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);const r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n});const s=Qg(0,t.nodeSpacing);let u;u=a?Ot(a)?t=>a(t)+s(t):Ug(a)?t=>{const e=a;return Math.max(e[0],e[1])+s(t)}:t=>a+s(t):t=>{const{size:e}=(null==t?void 0:t.data)||{};return e?Ug(e)?Math.max(e[0],e[1])+s(t):Lt(e)?Math.max(e.width,e.height)+s(t):e+s(t):10+s(t)},n.nodeSize=u;const c=t.linkDistance?Qg(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=c,n.nodeStrength=Qg(1,t.nodeStrength),n.edgeStrength=Qg(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:u}=t,c=e.getAllNodes(),l=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&u&&(h=Rm(e,u),d=Array.from(new Set(null==c?void 0:c.map((t=>t.data[u]))))||[],t.centripetalOptions=Object.assign(l,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==d?void 0:d.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const n=e.getDegree(t.id,"both");if(!n)return{x:100,y:100,z:0};let r;if(1===n){const{sameTypeLeaves:e=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Lm(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),s&&u){h||(h=Rm(e,u)),d||(d=Array.from(new Set(c.map((t=>t.data[u]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=c.filter((e=>e.data[u]===t)).map((t=>e.getNode(t.id)));n[t]=Lm(r)})),t.centripetalOptions=Object.assign(l,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:f,single:p,others:g}=t.centripetalOptions||{};f&&"function"!=typeof f&&(t.centripetalOptions.leaf=()=>f),p&&"function"!=typeof p&&(t.centripetalOptions.single=()=>p),g&&"function"!=typeof g&&(t.centripetalOptions.others=()=>g)}runOneStep(t,e,n,r,i){const o={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:u}=i;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),u){u({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let n=0;return e.forEach(((e,r)=>{const i=t[e.id].x,o=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=i*i+o*o+a*a,{mass:u=1}=e.data;n+=u*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;Tm(t,i,o*o,e,r)}calAttractive(t,e,n){const{dimensions:r,nodeSize:i}=n;t.getAllEdges().forEach(((n,o)=>{const{source:a,target:s}=n,u=t.getNode(a),c=t.getNode(s);if(!u||!c)return;let l=c.data.x-u.data.x,h=c.data.y-u.data.y,d=3===r?c.data.z-u.data.z:0;l||h||(l=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(l*l+h*h+d*d);if(f<i(u)+i(c))return;const p=l/f,g=h/f,m=d/f,{linkDistance:y=200,edgeStrength:v=200}=n.data||{},b=(y-f)*v,x=1/(u.data.mass||1),w=1/(c.data.mass||1),E=p*b,M=g*b,S=m*b;e[a].x-=E*x,e[a].y-=M*x,e[a].z-=S*x,e[s].x+=E*w,e[s].y+=M*w,e[s].z+=S*w}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:u,height:c,center:l,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:m,z:y}=f,v=e.getNode(o);let b=0,x=0,w=0,E=h;const M=t.getDegree(o,"in"),S=t.getDegree(o,"out"),N=t.getDegree(o,"both"),k=null==i?void 0:i(v,N);if(k){const[t,e,n]=k;b=g-t,x=m-e,E=n}else b=g-l[0],x=m-l[1],w=y-l[2];if(E&&(n[o].x-=E*b/p,n[o].y-=E*x/p,n[o].z-=E*w/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:l,y:h,z:f,centerStrength:b}=(null==i?void 0:i(v,a,s,u,c))||{x:0,y:0,z:0,centerStrength:0};if(!$t(l)||!$t(h))return;const x=(g-l)/p,w=(m-h)/p,E=(y-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*w,n[o].z-=b*E),0===N){const t=e(v);if(!t)return;return n[o].x-=t*x,n[o].y-=t*w,void(n[o].z-=t*E)}if(0===M||0===S){const e=t(v,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*w,void(n[o].z-=e*E)}const k=r(v);if(!k)return;n[o].x-=k*x,n[o].y-=k*w,n[o].z-=k*E}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((t=>{const{id:r}=t;let u=(n[r].x+e[r].x*a)*i||.01,c=(n[r].y+e[r].y*a)*i||.01,l=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(u*u+c*c+l*l);if(h>o){const t=o/h;u*=t,c*=t,l*=t}n[r]={x:u,y:c,z:l}}))}updatePosition(t,e,n,r){const{distanceThresholdMode:i,interval:o,dimensions:a}=r,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,c=t.getNode(s);if($t(c.data.fx)&&$t(c.data.fy))return void e.mergeNodeData(s,{x:c.data.fx,y:c.data.fy,z:3===a?c.data.fz:void 0});const l=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+l,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(l*l+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:u+=f}})),i&&"mean"!==i||(this.judgingDistance=u/s.length)}}const Rm=(t,e)=>{const n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};const r={};return n.forEach(((n,i)=>{1===t.getDegree(n.id,"both")&&(r[n.id]=Im(t,"leaf",n,e))})),r},Im=(t,e,n,r)=>{const i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out");let a=n,s=[];0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:Dm(t,e,r,n,s)}},Dm=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out"))),a},Lm=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:n,y:r}=t.data;e.x+=n||0,e.y+=r||0}));const n=t.length||1;return{x:e.x/n,y:e.y/n}},jm=(t,e)=>e.map((e=>{const{id:n,data:r}=e,i=t.getNode(n);return Object.assign(Object.assign({},i),{data:Object.assign(Object.assign({},i.data),{x:r.x,y:r.y,z:r.z})})}));var Bm={};const zm=Object.prototype.toString;function Fm(t){const e=zm.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Gm=p(Object.freeze({__proto__:null,isAnyArray:Fm}));var Vm=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Fm(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!Fm(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Fm(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Fm(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]>a&&(a=t[s]);return a}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,a=void 0===o?n.autoMinMax?r:0:o,s=n.max,u=void 0===s?n.autoMinMax?i:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var c=(u-a)/(i-r),l=0;l<t.length;l++)e[l]=(t[l]-r)*c+a;return e}}),Wm=p(Vm);Object.defineProperty(Bm,"__esModule",{value:!0});var Hm=Gm,Um=Wm;const $m=" ".repeat(2),qm=" ".repeat(4);function Ym(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${$m}[\n${qm}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),u=Math.min(a,n),c=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<u;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<u;o++)n.push(Km(t.get(e,o),r,i));c.push(`${n.join(" ")}`)}u!==a&&(c[c.length-1]+=` ... ${a-n} more columns`);s!==o&&c.push(`... ${o-e} more rows`);return c.join(`\n${qm}`)}(t,n,r,i,o)}\n${$m}]\n${$m}rows: ${t.rows}\n${$m}columns: ${t.columns}\n}`}function Km(t,e,n){return(t>=0&&n?` ${Xm(t,e-1)}`:Xm(t,e)).padEnd(e)}function Xm(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function Zm(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Qm(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function Jm(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function ty(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function ey(t,e){if(!Hm.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function ny(t,e){if(!Hm.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function ry(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(oy("startRow",e),oy("endRow",n),oy("startColumn",r),oy("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function iy(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function oy(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function ay(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class sy{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new cy(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new cy(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new cy(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new cy(t,e)}static ones(t,e){return new cy(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new cy(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new cy(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new cy(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return sy.isMatrix(t)?t:new cy(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new cy(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){Zm(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return cy.rowVector(this.getRow(t))}setRow(t,e){Zm(this,t),e=Jm(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){Zm(this,t),Zm(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){Qm(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return cy.columnVector(this.getColumn(t))}setColumn(t,e){Qm(this,t),e=ty(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){Qm(this,t),Qm(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=Jm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=Jm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=Jm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=Jm(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=ty(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=ty(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=ty(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=ty(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){Zm(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){Qm(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){ay(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){ay(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(Zm(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){Zm(this,t),ay(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(Zm(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){Zm(this,t),ay(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(Qm(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){Qm(this,t),ay(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(Qm(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){Qm(this,t),ay(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){sy.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=cy.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new cy(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}strassen2x2(t){t=cy.checkMatrix(t);let e=new cy(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),c=t.get(1,1),l=(n+u)*(r+c),h=(a+u)*r,d=n*(o-c),f=u*(s-r),p=(n+i)*c,g=l+f-p+(i-u)*(s+c),m=d+p,y=h+f,v=l-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,m),e.set(1,0,y),e.set(1,1,v),e}strassen3x3(t){t=cy.checkMatrix(t);let e=new cy(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),c=this.get(2,1),l=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),m=t.get(1,2),y=t.get(2,0),v=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),w=(-n+o+a)*(h-d+g),E=(o+a)*(-h+d),M=n*h,S=(-n+u+c)*(h-f+m),N=(-n+u)*(f-m),k=(u+c)*(-h+f),C=(-i+c+l)*(g+y-v),T=(i-l)*(g-v),A=i*y,P=(c+l)*(-y+v),O=(-i+a+s)*(m+y-b),_=(i-s)*(m-b),R=(a+s)*(-y+b),I=M+A+r*p,D=(n+r+i-o-a-c-l)*g+w+E+M+C+A+P,L=M+S+k+(n+r+i-a-s-u-c)*m+A+O+R,j=x+a*(-h+d+p-g-m-y+b)+w+M+A+O+_,B=x+w+E+M+s*v,z=A+O+_+R+o*f,F=M+S+N+c*(-h+f+p-g-m-y+v)+C+T+A,G=C+T+A+P+u*d,V=M+S+N+k+l*b;return e.set(0,0,I),e.set(0,1,D),e.set(0,2,L),e.set(1,0,j),e.set(1,1,B),e.set(1,2,z),e.set(2,0,F),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=cy.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function a(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=sy.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),u=Math.max(r,o);return e=a(e,s,u),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=a(e,r+1,i+1),n=a(n,r+1,i+1)):r%2==1?(e=a(e,r+1,i),n=a(n,r+1,i)):i%2==1&&(e=a(e,r,i+1),n=a(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,o-1,0,s-1),c=n.subMatrix(0,o-1,0,s-1),l=e.subMatrix(0,o-1,s,e.columns-1),h=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),m=t(sy.add(u,p),sy.add(c,g),o,s),y=t(sy.add(d,p),c,o,s),v=t(u,sy.sub(h,g),o,s),b=t(p,sy.sub(f,c),o,s),x=t(sy.add(u,l),g,o,s),w=t(sy.sub(d,u),sy.add(c,h),o,s),E=t(sy.sub(l,p),sy.add(f,g),o,s),M=sy.add(m,b);M.sub(x),M.add(E);let S=sy.add(v,x),N=sy.add(y,b),k=sy.sub(m,y);k.add(v),k.add(w);let C=sy.zeros(2*M.rows,2*M.columns);return C=C.setSubMatrix(M,0,0),C=C.setSubMatrix(S,M.rows,0),C=C.setSubMatrix(N,0,M.columns),C=C.setSubMatrix(k,M.rows,M.columns),C.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new cy(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&Um(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new cy(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&Um(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=cy.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new cy(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=cy.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(cy.eye(n,n)),i=cy.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new cy(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=uy){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=uy){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){ry(this,t,e,n,r);let i=new cy(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new cy(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);r.set(i,o-e,this.get(t[i],o))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new cy(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);r.set(o-e,i,this.get(o,t[i]))}return r}setSubMatrix(t,e,n){if((t=cy.checkMatrix(t)).isEmpty())return this;ry(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){ey(this,t),ny(this,e);let n=new cy(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new cy(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=iy(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=iy(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=iy(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=iy(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Hm.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,u=0;for(let e=0;e<i;e++)u=t.get(a,e)-n[a],r+=u,s+=u*u;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!Hm.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,u=0;for(let e=0;e<r;e++)u=t.get(e,a)-n[a],i+=u,s+=u*u;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,u=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)u=t.get(e,r)-n,a+=u,s+=u*u;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!Hm.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!Hm.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!Hm.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!Hm.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=Math.pow(t.get(i,r),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return Ym(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function uy(t,e){return t-e}sy.prototype.klass="Matrix","undefined"!=typeof Symbol&&(sy.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Ym(this)}),sy.random=sy.rand,sy.randomInt=sy.randInt,sy.diagonal=sy.diag,sy.prototype.diagonal=sy.prototype.diag,sy.identity=sy.eye,sy.prototype.negate=sy.prototype.neg,sy.prototype.tensorProduct=sy.prototype.kroneckerProduct;let cy=class t extends sy{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!Hm.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return Zm(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Zm(this,t,!0),e=Float64Array.from(Jm(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Qm(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),Qm(this,t,!0),e=ty(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(sy,cy);class ly extends sy{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return cy.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),cy.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=cy.copy(t,new cy(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new cy(t,t);else if(this.#e=new cy(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new ly(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new cy(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const r=new ly(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}ly.prototype.klassType="SymmetricMatrix";class hy extends ly{static isDistanceMatrix(t){return ly.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new ly(this)}clone(){const t=new hy(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}hy.prototype.klassSubType="DistanceMatrix";class dy extends sy{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class fy extends dy{constructor(t,e,n){ey(t,e),ny(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class py extends sy{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class gy extends sy{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class my{constructor(t){let e,n,r,i,o,a,s,u,c,l=(t=gy.checkMatrix(t)).clone(),h=l.rows,d=l.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(u=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)u[e]=l.get(e,n);for(e=0;e<h;e++){for(c=Math.min(e,n),o=0,r=0;r<c;r++)o+=l.get(e,r)*u[r];u[e]-=o,l.set(e,n,u[e])}for(i=n,e=n+1;e<h;e++)Math.abs(u[e])>Math.abs(u[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=l.get(i,r),l.set(i,r,l.get(n,r)),l.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==l.get(n,n))for(e=n+1;e<h;e++)l.set(e,n,l.get(e,n)/l.get(n,n))}this.LU=l,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=cy.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new cy(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new cy(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function yy(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class vy{constructor(t){let e,n,r,i,o=(t=gy.checkMatrix(t)).clone(),a=t.rows,s=t.columns,u=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=yy(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}u[r]=-t}this.QR=o,this.Rdiag=u}solve(t){t=cy.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,u=t.clone(),c=e.columns;for(o=0;o<c;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*u.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)u.set(r,i,u.get(r,i)+a*e.get(r,o))}for(o=c-1;o>=0;o--){for(i=0;i<s;i++)u.set(o,i,u.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)u.set(r,i,u.get(r,i)-u.get(o,i)*e.get(r,o))}return u.subMatrix(0,c-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new cy(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new cy(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let by=class{constructor(t,e={}){if((t=gy.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,u=Boolean(i),c=Boolean(o),l=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,l=!0;let e=u;u=c,c=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new cy(n,h),g=new cy(r,r),m=new Float64Array(r),y=new Float64Array(n),v=new Float64Array(d);for(let t=0;t<d;t++)v[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),w=Math.max(b,x);for(let t=0;t<w;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=yy(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<b&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}m[e]=s.get(t,e)}if(u&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){m[t]=0;for(let e=t+1;e<r;e++)m[t]=yy(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<r;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<n&&0!==m[t]){for(let e=t+1;e<n;e++)y[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)y[e]+=m[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-m[e]/m[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*y[i])}}if(c)for(let e=t+1;e<r;e++)g.set(e,t,m[e])}}let E=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<E&&(f[E-1]=0),x+1<E&&(m[x]=s.get(x,E-1)),m[E-1]=0,u){for(let t=b;t<h;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(c)for(let t=r-1;t>=0;t--){if(t<x&&0!==m[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let M=E-1,S=Number.EPSILON;for(;E>0;){let t,e;for(t=E-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[t]=0;break}}if(t===E-2)e=4;else{let n;for(n=E-1;n>=t&&n!==t;n--){let e=(n!==E?Math.abs(m[n]):0)+(n!==t+1?Math.abs(m[n-1]):0);if(Math.abs(f[n])<=S*e){f[n]=0;break}}n===t?e=3:n===E-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[E-2];m[E-2]=0;for(let n=E-2;n>=t;n--){let i=yy(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*m[n-1],m[n-1]=o*m[n-1]),c)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,E-1),g.set(t,E-1,-a*g.get(t,n)+o*g.get(t,E-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<E;r++){let i=yy(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*m[r],m[r]=o*m[r],u)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[E-1]),Math.abs(f[E-2]),Math.abs(m[E-2]),Math.abs(f[t]),Math.abs(m[t])),i=f[E-1]/e,o=f[E-2]/e,a=m[E-2]/e,s=f[t]/e,l=m[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let y=0;0===h&&0===d||(y=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),y=d/(h+y));let v=(s+i)*(s-i)+y,b=s*l;for(let e=t;e<E-1;e++){let i=yy(v,b);0===i&&(i=Number.MIN_VALUE);let o=v/i,a=b/i;if(e!==t&&(m[e-1]=i),v=o*f[e]+a*m[e],m[e]=o*m[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],c)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=yy(v,b),0===i&&(i=Number.MIN_VALUE),o=v/i,a=b/i,f[e]=i,v=o*m[e]+a*f[e+1],f[e+1]=-a*m[e]+o*f[e+1],b=a*m[e+1],m[e+1]=o*m[e+1],u&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}m[E-2]=v;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,c))for(let e=0;e<=M;e++)g.set(e,t,-g.get(e,t));for(;t<M&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,c&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(u&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}E--}}if(l){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=cy.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),u=a.rows,c=o.rows,l=cy.zeros(u,c);for(let t=0;t<u;t++)for(let e=0;e<c;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);l.set(t,e,n)}return l.mmul(e)}solveForDiagonal(t){return this.solve(cy.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new cy(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,u=new cy(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);u.set(t,e,n)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return cy.diag(this.s)}};function xy(t,e,n=!1){return t=gy.checkMatrix(t),e=gy.checkMatrix(e),n?new by(t).solve(e):t.isSquare()?new my(t).solve(e):new vy(t).solve(e)}function wy(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Ey(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class My{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=gy.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new cy(o,o),s=new Float64Array(o),u=new Float64Array(o),c=t,l=!1;if(l=!!n||t.isSymmetric(),l){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,a,s,u,c,l,h;for(u=0;u<t;u++)n[u]=r.get(t-1,u);for(s=t-1;s>0;s--){for(h=0,a=0,c=0;c<s;c++)h+=Math.abs(n[c]);if(0===h)for(e[s]=n[s-1],u=0;u<s;u++)n[u]=r.get(s-1,u),r.set(s,u,0),r.set(u,s,0);else{for(c=0;c<s;c++)n[c]/=h,a+=n[c]*n[c];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,u=0;u<s;u++)e[u]=0;for(u=0;u<s;u++){for(i=n[u],r.set(u,s,i),o=e[u]+r.get(u,u)*i,c=u+1;c<=s-1;c++)o+=r.get(c,u)*n[c],e[c]+=r.get(c,u)*i;e[u]=o}for(i=0,u=0;u<s;u++)e[u]/=a,i+=e[u]*n[u];for(l=i/(a+a),u=0;u<s;u++)e[u]-=l*n[u];for(u=0;u<s;u++){for(i=n[u],o=e[u],c=u;c<=s-1;c++)r.set(c,u,r.get(c,u)-(i*e[c]+o*n[c]));n[u]=r.get(s-1,u),r.set(s,u,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(c=0;c<=s;c++)n[c]=r.get(c,s+1)/a;for(u=0;u<=s;u++){for(o=0,c=0;c<=s;c++)o+=r.get(c,s+1)*r.get(c,u);for(c=0;c<=s;c++)r.set(c,u,r.get(c,u)-o*n[c])}}for(c=0;c<=s;c++)r.set(c,s+1,0)}for(u=0;u<t;u++)n[u]=r.get(t-1,u),r.set(t-1,u,0);r.set(t-1,t-1,1),e[0]=0}(o,u,s,a),function(t,e,n,r){let i,o,a,s,u,c,l,h,d,f,p,g,m,y,v,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,w=0,E=Number.EPSILON;for(c=0;c<t;c++){for(w=Math.max(w,Math.abs(n[c])+Math.abs(e[c])),l=c;l<t&&!(Math.abs(e[l])<=E*w);)l++;if(l>c)do{for(i=n[c],h=(n[c+1]-i)/(2*e[c]),d=yy(h,1),h<0&&(d=-d),n[c]=e[c]/(h+d),n[c+1]=e[c]*(h+d),f=n[c+1],o=i-n[c],a=c+2;a<t;a++)n[a]-=o;for(x+=o,h=n[l],p=1,g=p,m=p,y=e[c+1],v=0,b=0,a=l-1;a>=c;a--)for(m=g,g=p,b=v,i=p*e[a],o=p*h,d=yy(h,e[a]),e[a+1]=v*d,v=e[a]/d,p=h/d,h=p*n[a]-v*i,n[a+1]=o+v*(p*i+v*n[a]),u=0;u<t;u++)o=r.get(u,a+1),r.set(u,a+1,v*r.get(u,a)+p*o),r.set(u,a,p*r.get(u,a)-v*o);h=-v*b*m*y*e[c]/f,e[c]=v*h,n[c]=p*h}while(Math.abs(e[c])>E*w);n[c]=n[c]+x,e[c]=0}for(a=0;a<t-1;a++){for(u=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(u=s,h=n[s]);if(u!==a)for(n[u]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,u)),r.set(s,u,h)}}(o,u,s,a)}else{let t=new cy(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,a,s,u,c,l,h=0,d=t-1;for(c=h+1;c<=d-1;c++){for(l=0,s=c;s<=d;s++)l+=Math.abs(e.get(s,c-1));if(0!==l){for(a=0,s=d;s>=c;s--)n[s]=e.get(s,c-1)/l,a+=n[s]*n[s];for(o=Math.sqrt(a),n[c]>0&&(o=-o),a-=n[c]*o,n[c]=n[c]-o,u=c;u<t;u++){for(i=0,s=d;s>=c;s--)i+=n[s]*e.get(s,u);for(i/=a,s=c;s<=d;s++)e.set(s,u,e.get(s,u)-i*n[s])}for(s=0;s<=d;s++){for(i=0,u=d;u>=c;u--)i+=n[u]*e.get(s,u);for(i/=a,u=c;u<=d;u++)e.set(s,u,e.get(s,u)-i*n[u])}n[c]=l*n[c],e.set(c,c-1,l*o)}}for(s=0;s<t;s++)for(u=0;u<t;u++)r.set(s,u,s===u?1:0);for(c=d-1;c>=h+1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=d;s++)n[s]=e.get(s,c-1);for(u=c;u<=d;u++){for(o=0,s=c;s<=d;s++)o+=n[s]*r.get(s,u);for(o=o/n[c]/e.get(c,c-1),s=c;s<=d;s++)r.set(s,u,r.get(s,u)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,u,c,l,h,d,f,p,g,m,y,v,b,x=t-1,w=0,E=t-1,M=Number.EPSILON,S=0,N=0,k=0,C=0,T=0,A=0,P=0,O=0;for(o=0;o<t;o++)for((o<w||o>E)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)N+=Math.abs(i.get(o,a));for(;x>=w;){for(u=x;u>w&&(A=Math.abs(i.get(u-1,u-1))+Math.abs(i.get(u,u)),0===A&&(A=N),!(Math.abs(i.get(u,u-1))<M*A));)u--;if(u===x)i.set(x,x,i.get(x,x)+S),n[x]=i.get(x,x),e[x]=0,x--,O=0;else if(u===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),k=(i.get(x-1,x-1)-i.get(x,x))/2,C=k*k+h,P=Math.sqrt(Math.abs(C)),i.set(x,x,i.get(x,x)+S),i.set(x-1,x-1,i.get(x-1,x-1)+S),d=i.get(x,x),C>=0){for(P=k>=0?k+P:k-P,n[x-1]=d+P,n[x]=n[x-1],0!==P&&(n[x]=d-h/P),e[x-1]=0,e[x]=0,d=i.get(x,x-1),A=Math.abs(d)+Math.abs(P),k=d/A,C=P/A,T=Math.sqrt(k*k+C*C),k/=T,C/=T,a=x-1;a<t;a++)P=i.get(x-1,a),i.set(x-1,a,C*P+k*i.get(x,a)),i.set(x,a,C*i.get(x,a)-k*P);for(o=0;o<=x;o++)P=i.get(o,x-1),i.set(o,x-1,C*P+k*i.get(o,x)),i.set(o,x,C*i.get(o,x)-k*P);for(o=w;o<=E;o++)P=r.get(o,x-1),r.set(o,x-1,C*P+k*r.get(o,x)),r.set(o,x,C*r.get(o,x)-k*P)}else n[x-1]=d+k,n[x]=d+k,e[x-1]=P,e[x]=-P;x-=2,O=0}else{if(d=i.get(x,x),f=0,h=0,u<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===O){for(S+=d,o=w;o<=x;o++)i.set(o,o,i.get(o,o)-d);A=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*A,h=-.4375*A*A}if(30===O&&(A=(f-d)/2,A=A*A+h,A>0)){for(A=Math.sqrt(A),f<d&&(A=-A),A=d-h/((f-d)/2+A),o=w;o<=x;o++)i.set(o,o,i.get(o,o)-A);S+=A,d=f=h=.964}for(O+=1,c=x-2;c>=u&&(P=i.get(c,c),T=d-P,A=f-P,k=(T*A-h)/i.get(c+1,c)+i.get(c,c+1),C=i.get(c+1,c+1)-P-T-A,T=i.get(c+2,c+1),A=Math.abs(k)+Math.abs(C)+Math.abs(T),k/=A,C/=A,T/=A,c!==u)&&!(Math.abs(i.get(c,c-1))*(Math.abs(C)+Math.abs(T))<M*(Math.abs(k)*(Math.abs(i.get(c-1,c-1))+Math.abs(P)+Math.abs(i.get(c+1,c+1)))));)c--;for(o=c+2;o<=x;o++)i.set(o,o-2,0),o>c+2&&i.set(o,o-3,0);for(s=c;s<=x-1&&(v=s!==x-1,s!==c&&(k=i.get(s,s-1),C=i.get(s+1,s-1),T=v?i.get(s+2,s-1):0,d=Math.abs(k)+Math.abs(C)+Math.abs(T),0!==d&&(k/=d,C/=d,T/=d)),0!==d);s++)if(A=Math.sqrt(k*k+C*C+T*T),k<0&&(A=-A),0!==A){for(s!==c?i.set(s,s-1,-A*d):u!==c&&i.set(s,s-1,-i.get(s,s-1)),k+=A,d=k/A,f=C/A,P=T/A,C/=k,T/=k,a=s;a<t;a++)k=i.get(s,a)+C*i.get(s+1,a),v&&(k+=T*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-k*P)),i.set(s,a,i.get(s,a)-k*d),i.set(s+1,a,i.get(s+1,a)-k*f);for(o=0;o<=Math.min(x,s+3);o++)k=d*i.get(o,s)+f*i.get(o,s+1),v&&(k+=P*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-k*T)),i.set(o,s,i.get(o,s)-k),i.set(o,s+1,i.get(o,s+1)-k*C);for(o=w;o<=E;o++)k=d*r.get(o,s)+f*r.get(o,s+1),v&&(k+=P*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-k*T)),r.set(o,s,r.get(o,s)-k),r.set(o,s+1,r.get(o,s+1)-k*C)}}}if(0===N)return;for(x=t-1;x>=0;x--)if(k=n[x],C=e[x],0===C)for(u=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-k,T=0,a=u;a<=x;a++)T+=i.get(o,a)*i.get(a,x);if(e[o]<0)P=h,A=T;else if(u=o,0===e[o]?i.set(o,x,0!==h?-T/h:-T/(M*N)):(d=i.get(o,o+1),f=i.get(o+1,o),C=(n[o]-k)*(n[o]-k)+e[o]*e[o],l=(d*A-P*T)/C,i.set(o,x,l),i.set(o+1,x,Math.abs(d)>Math.abs(P)?(-T-h*l)/d:(-A-f*l)/P)),l=Math.abs(i.get(o,x)),M*l*l>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/l)}else if(C<0)for(u=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,C/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-k)/i.get(x,x-1))):(b=Sy(0,-i.get(x-1,x),i.get(x-1,x-1)-k,C),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=u;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-k,e[o]<0)P=h,T=p,A=g;else if(u=o,0===e[o]?(b=Sy(-p,-g,h,C),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),m=(n[o]-k)*(n[o]-k)+e[o]*e[o]-C*C,y=2*(n[o]-k)*C,0===m&&0===y&&(m=M*N*(Math.abs(h)+Math.abs(C)+Math.abs(d)+Math.abs(f)+Math.abs(P))),b=Sy(d*T-P*p+C*g,d*A-P*g-C*p,m,y),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(P)+Math.abs(C)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+C*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-C*i.get(o,x-1))/d)):(b=Sy(-T-f*i.get(o,x-1),-A-f*i.get(o,x),P,C),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),l=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),M*l*l>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/l),i.set(a,x,i.get(a,x)/l)}for(o=0;o<t;o++)if(o<w||o>E)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=w;a--)for(o=w;o<=E;o++){for(P=0,s=w;s<=Math.min(a,E);s++)P+=r.get(o,s)*i.get(s,a);r.set(o,a,P)}}(o,u,s,a,t)}this.n=o,this.e=u,this.d=s,this.V=a}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new cy(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function Sy(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class Ny{constructor(t){if(!(t=gy.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new cy(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=Boolean(s)}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=gy.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class ky{constructor(t,e={}){t=gy.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=Hm.isAnyArray(n)&&"number"==typeof n[0]?cy.columnVector(n):gy.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,u,c,l,h=1;for(let e=0;e<i&&h>o;e++)c=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),s=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),e>0&&(h=s.clone().sub(l).pow(2).sum()),l=s.clone(),n?(u=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),u=u.div(u.norm()),a=n.mmul(u).div(u.transpose().mmul(u).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(u.transpose()));this.t=s,this.p=e.transpose(),this.w=c.transpose(),this.q=u,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=c.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(c.transpose()))}}Bm.AbstractMatrix=sy,Bm.CHO=Ny,Bm.CholeskyDecomposition=Ny,Bm.DistanceMatrix=hy,Bm.EVD=My,Bm.EigenvalueDecomposition=My,Bm.LU=my,Bm.LuDecomposition=my;var Cy=Bm.Matrix=cy;Bm.MatrixColumnSelectionView=class extends dy{constructor(t,e){ny(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},Bm.MatrixColumnView=class extends dy{constructor(t,e){Qm(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},Bm.MatrixFlipColumnView=class extends dy{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},Bm.MatrixFlipRowView=class extends dy{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},Bm.MatrixRowSelectionView=class extends dy{constructor(t,e){ey(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},Bm.MatrixRowView=class extends dy{constructor(t,e){Zm(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},Bm.MatrixSelectionView=fy,Bm.MatrixSubView=class extends dy{constructor(t,e,n,r,i){ry(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},Bm.MatrixTransposeView=class extends dy{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},Bm.NIPALS=ky,Bm.Nipals=ky,Bm.QR=vy,Bm.QrDecomposition=vy,Bm.SVD=by;var Ty=Bm.SingularValueDecomposition=by;Bm.SymmetricMatrix=ly,Bm.WrapperMatrix1D=py,Bm.WrapperMatrix2D=gy,Bm.correlation=function(t,e=t,n={}){t=new cy(t);let r=!1;if("object"!=typeof e||cy.isMatrix(e)||Hm.isAnyArray(e)?e=new cy(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),u=t.transpose().mmul(e);for(let e=0;e<u.rows;e++)for(let n=0;n<u.columns;n++)u.set(e,n,u.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return u},Bm.covariance=function(t,e=t,n={}){t=new cy(t);let r=!1;if("object"!=typeof e||cy.isMatrix(e)||Hm.isAnyArray(e)?e=new cy(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var Ay=Bm.default=cy;Bm.determinant=function t(e){if((e=cy.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new fy(e,[1,2],[1,2]),a=new fy(e,[1,2],[0,2]),s=new fy(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new my(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Bm.inverse=function(t,e=!1){return t=gy.checkMatrix(t),e?new by(t).inverse():xy(t,cy.eye(t.rows))},Bm.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=cy.checkMatrix(t)).rows,o=new cy(i,i);for(let e=0;e<i;e++){let a=cy.columnVector(t.getRow(e)),s=t.subMatrixRow(wy(i,e)).transpose(),u=new by(s).solve(a),c=cy.sub(a,s.mmul(u)).abs().max();o.setRow(e,Ey(c,u,e,n,r))}return o},Bm.pseudoInverse=function(t,e=Number.EPSILON){if((t=cy.checkMatrix(t)).isEmpty())return t.transpose();let n=new by(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(cy.diag(o).mmul(r.transpose()))},Bm.solve=xy,Bm.wrap=function(t,e){if(Hm.isAnyArray(t))return t[0]&&Hm.isAnyArray(t[0])?new gy(t):new py(t,e);throw new Error("the argument is not an array")};const Py=Cy,Oy=Ty;Ay.Matrix&&Ay.Matrix;const _y={center:[0,0],linkDistance:50};class Ry{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},_y),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i=[0,0],linkDistance:o=50}=r,a=e.getAllNodes(),s=e.getAllEdges();if(!(null==a?void 0:a.length)||1===a.length)return im(e,t,i);const u=qg({nodes:a,edges:s}),c=$g(u);Iy(c);const l=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(c,o),h=Dy(l),d=[];h.forEach(((t,e)=>{const n=Zg(a[e]);n.data.x=t[0]+i[0],n.data.y=t[1]+i[1],d.push(n)})),t&&d.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:s}}))}}const Iy=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e<t&&(e=t)}))})),t.forEach(((n,r)=>{n.forEach(((n,i)=>{n===1/0&&(t[r][i]=e)}))}))},Dy=t=>{const e=Py.mul(Py.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);const o=new Oy(e),a=Py.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>Py.mul([t],[a]).toJSON()[0].splice(0,2)))},Ly={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},jy={center:[0,0],comboPadding:10,treeKey:"combo"};class By{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},jy),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:i,treeKey:o,outerLayout:a}=r,s=e.getAllNodes().filter((t=>!t.data._isCombo)),u=e.getAllNodes().filter((t=>t.data._isCombo)),c=e.getAllEdges(),l=null==s?void 0:s.length;if(!l||1===l)return im(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;u.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,c,r,p);yield Promise.all(g);const m=new Map,y=[],v=new Map;let b=!0;e.getRoots(o).forEach((t=>{const n=p.get(t.id),r=f.get(t.id)||d.get(t.id),i={id:t.id,data:Object.assign(Object.assign({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};y.push(i),m.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):b=!1,Kg(e,[t],(e=>{e.id!==t.id&&v.set(e.id,t.id)}),"TB",o)}));const x=[];let w;if(c.forEach((t=>{const e=v.get(t.source)||t.source,n=v.get(t.target)||t.target;e!==n&&m.has(e)&&m.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==y?void 0:y.length){if(1===y.length)y[0].data.x=i[0],y[0].data.y=i[1];else{const t=new Rd({nodes:y,edges:x}),e=a||new _m;if(b&&Ly[e.id]){const e=y.length<100?new Ry:new lm;yield e.assign(t)}w=yield e.execute(t,Object.assign({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,n)=>(Math.max(...e.data.size)||32)/2+(Math.max(...n.data.size)||32)/2+200}:{}))}p.forEach((t=>{var e;const n=w.nodes.find((e=>e.id===t.id));if(n){const{x:e,y:r}=n.data;t.data.visited=!0,t.data.x=e,t.data.y=r,h.push({id:t.id,data:{x:e,y:r}})}const{x:r,y:i}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{h.push({id:t.id,data:{x:t.data.x+r,y:t.data.y+i}})}))})),p.forEach((({data:t})=>{const{x:e,y:n,visited:r,nodes:i}=t;null==i||i.forEach((t=>{if(!r){const r=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:c}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=$t(r)?()=>r:Ot(r)?r:()=>0,e.spacing=a,n)if(Ot(n))o=t=>{const e=n(t),r=a(t);if(Ug(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(Ug(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)/2}else{const t=n/2;o=e=>t+a(e)/2}else o=t=>{const e=a(t);if(t.size){if(Ug(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(Lt(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=o,s=$t(i)?()=>i:Ug(i)?()=>Math.max.apply(null,i):Ot(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,s){const{nodeSize:u,comboPadding:c,spacing:l,innerLayout:h}=o,d=h||new lm({}),f={center:[0,0],preventOverlap:!0,nodeSpacing:l},p=[],g=t=>{let e=(null==c?void 0:c(t))||10;return Ug(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{s.set(o.id,{id:o.id,data:{nodes:[],size:g(o).size}});let c=Promise.resolve();Kg(t,[o],(o=>{var l;if(!o.data._isCombo)return;const{size:h,padding:p}=g(o);if(null===(l=t.getChildren(o.id,e))||void 0===l?void 0:l.length){const l=s.get(o.id);s.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==l?void 0:l.data)});const h=new Map,g=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return s.has(t.id)||s.set(t.id,{id:t.id,data:Object.assign({},t.data)}),h.set(t.id,!0),s.get(t.id);const e=n.get(t.id)||r.get(t.id);return h.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),m={nodes:g,edges:i.filter((t=>h.has(t.source)&&h.has(t.target)))};let y=1/0;g.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=s.get(t.id))||void 0===e?void 0:e.data.size)||(null==u?void 0:u(t))||[30,30]),$t(n)&&(n=[n,n]);const[r,i]=n;y>r&&(y=r),y>i&&(y=i),t.data.size=n})),c=c.then((()=>a(this,void 0,void 0,(function*(){const t=new Rd(m),e=yield d.assign(t,f),{minX:n,minY:r,maxX:i,maxY:a}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;Ug(o)?1===o.length&&(o=[o[0],o[0]]):$t(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],c=t.data.y-a[1],l=t.data.y+a[1];e>s&&(e=s),n>c&&(n=c),r<u&&(r=u),i<l&&(i=l)})),{minX:e,minY:n,maxX:r,maxY:i}})(g),u=(i+n)/2,c=(a+r)/2;m.nodes.forEach((t=>{t.data.x-=u,t.data.y-=c}));const l=[Math.max(i-n,y)+2*p,Math.max(a-r,y)+2*p];return s.get(o.id).data.size=l,s.get(o.id).data.nodes=g,e}))))}else s.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:h})});return!0}),"BT",e),p.push(c)})),p}}function zy(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,u=0;for(i=0;i<a;++i)s+=(o=n[i]).x,u+=o.y;for(s=(s/a-t)*r,u=(u/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=u}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function Fy(t){return function(){return t}}function Gy(t){return 1e-6*(t()-.5)}function Vy(t){return t.x+t.vx}function Wy(t){return t.y+t.vy}function Hy(t){var e,n,r,i=1,o=1;function a(){for(var t,a,u,c,l,h,d,f=e.length,p=0;p<o;++p)for(a=gm(e,Vy,Wy).visitAfter(s),t=0;t<f;++t)u=e[t],h=n[u.index],d=h*h,c=u.x+u.vx,l=u.y+u.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>c+p||o<c-p||n>l+p||a<l-p;if(s.index>u.index){var g=c-s.x-s.vx,m=l-s.y-s.vy,y=g*g+m*m;y<p*p&&(0===g&&(y+=(g=Gy(r))*g),0===m&&(y+=(m=Gy(r))*m),y=(p-(y=Math.sqrt(y)))/y*i,u.vx+=(g*=y)*(p=(f*=f)/(d+f)),u.vy+=(m*=y)*p,s.vx-=g*(p=1-p),s.vy-=m*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=Fy(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,u()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Fy(+e),u(),a):t},a}function Uy(t){return t.index}function $y(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function qy(t){var e,n,r,i,o,a,s=Uy,u=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=Fy(30),l=1;function h(r){for(var i=0,s=t.length;i<l;++i)for(var u,c,h,d,f,p,g,m=0;m<s;++m)c=(u=t[m]).source,d=(h=u.target).x+h.vx-c.x-c.vx||Gy(a),f=h.y+h.vy-c.y-c.vy||Gy(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[m])/p*r*e[m],f*=p,h.vx-=d*(g=o[m]),h.vy-=f*g,c.vx+=d*(g=1-g),c.vy+=f*g}function d(){if(r){var a,u,c=r.length,l=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(c);a<l;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=$y(h,u.source)),"object"!=typeof u.target&&(u.target=$y(h,u.target)),i[u.source.index]=(i[u.source.index]||0)+1,i[u.target.index]=(i[u.target.index]||0)+1;for(a=0,o=new Array(l);a<l;++a)u=t[a],o[a]=i[u.source.index]/(i[u.source.index]+i[u.target.index]);e=new Array(l),f(),n=new Array(l),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+u(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+c(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(l=+t,h):l},h.strength=function(t){return arguments.length?(u="function"==typeof t?t:Fy(+t),f(),h):u},h.distance=function(t){return arguments.length?(c="function"==typeof t?t:Fy(+t),p(),h):c},h}var Yy={value:()=>{}};function Ky(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Xy(r)}function Xy(t){this._=t}function Zy(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Qy(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Yy,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}Xy.prototype=Ky.prototype={constructor:Xy,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=o[a]).type)i[n]=Qy(i[n],t.name,e);else if(null==e)for(n in i)i[n]=Qy(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=Zy(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Xy(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var Jy,tv,ev=0,nv=0,rv=0,iv=1e3,ov=0,av=0,sv=0,uv="object"==typeof performance&&performance.now?performance:Date,cv="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function lv(){return av||(cv(hv),av=uv.now()+sv)}function hv(){av=0}function dv(){this._call=this._time=this._next=null}function fv(t,e,n){var r=new dv;return r.restart(t,e,n),r}function pv(){av=(ov=uv.now())+sv,ev=nv=0;try{!function(){lv(),++ev;for(var t,e=Jy;e;)(t=av-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ev}()}finally{ev=0,function(){var t,e,n=Jy,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Jy=e);tv=t,mv(r)}(),av=0}}function gv(){var t=uv.now(),e=t-ov;e>iv&&(sv-=e,ov=t)}function mv(t){ev||(nv&&(nv=clearTimeout(nv)),t-av>24?(t<1/0&&(nv=setTimeout(pv,t-uv.now()-sv)),rv&&(rv=clearInterval(rv))):(rv||(ov=uv.now(),rv=setInterval(gv,iv)),ev=1,cv(pv)))}dv.prototype=fv.prototype={constructor:dv,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?lv():+n)+(null==e?0:+e),this._next||tv===this||(tv?tv._next=this:Jy=this,tv=this),this._call=t,this._time=n,mv()},stop:function(){this._call&&(this._call=null,this._time=1/0,mv())}};const yv=1664525,vv=1013904223,bv=4294967296;function xv(t){return t.x}function wv(t){return t.y}var Ev=Math.PI*(3-Math.sqrt(5));function Mv(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,u=fv(h),c=Ky("tick","end"),l=function(){let t=1;return()=>(t=(yv*t+vv)%bv)/bv}();function h(){d(),c.call("tick",e),n<r&&(u.stop(),c.call("end",e))}function d(r){var u,c,l=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),u=0;u<l;++u)null==(c=t[u]).fx?c.x+=c.vx*=a:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=a:(c.y=c.fy,c.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*Ev;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,l),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return u.restart(h),e},stop:function(){return u.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(l=t,s.forEach(p),e):l},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,u,c=0,l=t.length;for(null==r?r=1/0:r*=r,c=0;c<l;++c)(a=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(u=s,r=a);return u},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function Sv(){var t,e,n,r,i,o=Fy(-30),a=1,s=1/0,u=.81;function c(n){var i,o=t.length,a=gm(t,xv,wv).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function l(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function h(t){var e,n,r,o,a,s=0,u=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,u+=n,r+=n*e.x,o+=n*e.y);t.x=r/u,t.y=o/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,c,l){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=l-o,p=h*h+d*d;if(f*f/u<p)return p<s&&(0===h&&(p+=(h=Gy(n))*h),0===d&&(p+=(d=Gy(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=Gy(n))*h),0===d&&(p+=(d=Gy(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,l()},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:Fy(+t),l(),c):o},c.distanceMin=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c}function Nv(t,e,n){var r,i,o,a=Fy(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var u=r[a],c=u.x-e||1e-6,l=u.y-n||1e-6,h=Math.sqrt(c*c+l*l),d=(o[a]-h)*i[a]*t/h;u.vx+=c*d,u.vy+=l*d}}function u(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=Fy(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,u()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:Fy(+t),u(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Fy(+e),u(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function kv(t){var e,n,r,i=Fy(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Fy(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Fy(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Fy(+e),a(),o):t},o}function Cv(t){var e,n,r,i=Fy(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Fy(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Fy(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Fy(+e),a(),o):t},o}class Tv{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:qy,manyBody:Sv,center:zy,collide:Hy,radial:Nv,x:kv,y:Cv},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},ce(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=ce({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return a(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign({id:t,data:e},me(e,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),u=this.setSimulation(i);return u.nodes(o),null===(r=u.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),me(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return Mv()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),Av(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),Av(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const Av=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);function Pv(t,e,n){var r,i=1;function o(){var o,a,s=r.length,u=0,c=0,l=0;for(o=0;o<s;++o)u+=(a=r[o]).x||0,c+=a.y||0,l+=a.z||0;for(u=(u/s-t)*i,c=(c/s-e)*i,l=(l/s-n)*i,o=0;o<s;++o)a=r[o],u&&(a.x-=u),c&&(a.y-=c),l&&(a.z-=l)}return null==t&&(t=0),null==e&&(e=0),null==n&&(n=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.z=function(t){return arguments.length?(n=+t,o):n},o.strength=function(t){return arguments.length?(i=+t,o):i},o}function Ov(t,e,n){if(isNaN(e))return t;var r,i,o,a,s,u,c=t._root,l={data:n},h=t._x0,d=t._x1;if(!c)return t._root=l,t;for(;c.length;)if((a=e>=(i=(h+d)/2))?h=i:d=i,r=c,!(c=c[s=+a]))return r[s]=l,t;if(e===(o=+t._x.call(null,c.data)))return l.next=c,r?r[s]=l:t._root=l,t;do{r=r?r[s]=new Array(2):t._root=new Array(2),(a=e>=(i=(h+d)/2))?h=i:d=i}while((s=+a)==(u=+(o>=i)));return r[u]=c,r[s]=l,t}function _v(t,e,n){this.node=t,this.x0=e,this.x1=n}function Rv(t){return t[0]}function Iv(t,e){var n=new Dv(null==e?Rv:e,NaN,NaN);return null==t?n:n.addAll(t)}function Dv(t,e,n){this._x=t,this._x0=e,this._x1=n,this._root=void 0}function Lv(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var jv=Iv.prototype=Dv.prototype;function Bv(t){return function(){return t}}function zv(t){return 1e-6*(t()-.5)}function Fv(t){return t.x+t.vx}function Gv(t){return t.y+t.vy}function Vv(t){return t.z+t.vz}function Wv(t){var e,n,r,i,o=1,a=1;function s(){for(var t,s,c,l,h,d,f,p,g=e.length,m=0;m<a;++m)for(s=(1===n?Iv(e,Fv):2===n?gm(e,Fv,Gv):3===n?Sm(e,Fv,Gv,Vv):null).visitAfter(u),t=0;t<g;++t)c=e[t],f=r[c.index],p=f*f,l=c.x+c.vx,n>1&&(h=c.y+c.vy),n>2&&(d=c.z+c.vz),s.visit(y);function y(t,e,r,a,s,u,g){var m=[e,r,a,s,u,g],y=m[0],v=m[1],b=m[2],x=m[n],w=m[n+1],E=m[n+2],M=t.data,S=t.r,N=f+S;if(!M)return y>l+N||x<l-N||n>1&&(v>h+N||w<h-N)||n>2&&(b>d+N||E<d-N);if(M.index>c.index){var k=l-M.x-M.vx,C=n>1?h-M.y-M.vy:0,T=n>2?d-M.z-M.vz:0,A=k*k+C*C+T*T;A<N*N&&(0===k&&(A+=(k=zv(i))*k),n>1&&0===C&&(A+=(C=zv(i))*C),n>2&&0===T&&(A+=(T=zv(i))*T),A=(N-(A=Math.sqrt(A)))/A*o,c.vx+=(k*=A)*(N=(S*=S)/(p+S)),n>1&&(c.vy+=(C*=A)*N),n>2&&(c.vz+=(T*=A)*N),M.vx-=k*(N=1-N),n>1&&(M.vy-=C*N),n>2&&(M.vz-=T*N))}}}function u(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<Math.pow(2,n);++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function c(){if(e){var n,i,o=e.length;for(r=new Array(o),n=0;n<o;++n)i=e[n],r[i.index]=+t(i,n,e)}}return"function"!=typeof t&&(t=Bv(null==t?1:+t)),s.initialize=function(t,...r){e=t,i=r.find((t=>"function"==typeof t))||Math.random,n=r.find((t=>[1,2,3].includes(t)))||2,c()},s.iterations=function(t){return arguments.length?(a=+t,s):a},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Bv(+e),c(),s):t},s}function Hv(t){return t.index}function Uv(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function $v(t){var e,n,r,i,o,a,s,u=Hv,c=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},l=Bv(30),h=1;function d(r){for(var o=0,u=t.length;o<h;++o)for(var c,l,d,f,p,g=0,m=0,y=0,v=0;g<u;++g)l=(c=t[g]).source,m=(d=c.target).x+d.vx-l.x-l.vx||zv(s),i>1&&(y=d.y+d.vy-l.y-l.vy||zv(s)),i>2&&(v=d.z+d.vz-l.z-l.vz||zv(s)),m*=f=((f=Math.sqrt(m*m+y*y+v*v))-n[g])/f*r*e[g],y*=f,v*=f,d.vx-=m*(p=a[g]),i>1&&(d.vy-=y*p),i>2&&(d.vz-=v*p),l.vx+=m*(p=1-p),i>1&&(l.vy+=y*p),i>2&&(l.vz+=v*p)}function f(){if(r){var i,s,c=r.length,l=t.length,h=new Map(r.map(((t,e)=>[u(t,e,r),t])));for(i=0,o=new Array(c);i<l;++i)(s=t[i]).index=i,"object"!=typeof s.source&&(s.source=Uv(h,s.source)),"object"!=typeof s.target&&(s.target=Uv(h,s.target)),o[s.source.index]=(o[s.source.index]||0)+1,o[s.target.index]=(o[s.target.index]||0)+1;for(i=0,a=new Array(l);i<l;++i)s=t[i],a[i]=o[s.source.index]/(o[s.source.index]+o[s.target.index]);e=new Array(l),p(),n=new Array(l),g()}}function p(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+c(t[n],n,t)}function g(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+l(t[e],e,t)}return null==t&&(t=[]),d.initialize=function(t,...e){r=t,s=e.find((t=>"function"==typeof t))||Math.random,i=e.find((t=>[1,2,3].includes(t)))||2,f()},d.links=function(e){return arguments.length?(t=e,f(),d):t},d.id=function(t){return arguments.length?(u=t,d):u},d.iterations=function(t){return arguments.length?(h=+t,d):h},d.strength=function(t){return arguments.length?(c="function"==typeof t?t:Bv(+t),p(),d):c},d.distance=function(t){return arguments.length?(l="function"==typeof t?t:Bv(+t),g(),d):l},d}jv.copy=function(){var t,e,n=new Dv(this._x,this._x0,this._x1),r=this._root;if(!r)return n;if(!r.length)return n._root=Lv(r),n;for(t=[{source:r,target:n._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(2)}):r.target[i]=Lv(e));return n},jv.add=function(t){const e=+this._x.call(null,t);return Ov(this.cover(e),e,t)},jv.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e);let r=1/0,i=-1/0;for(let o,a=0;a<e;++a)isNaN(o=+this._x.call(null,t[a]))||(n[a]=o,o<r&&(r=o),o>i&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let r=0;r<e;++r)Ov(this,n[r],t[r]);return this},jv.cover=function(t){if(isNaN(t=+t))return this;var e=this._x0,n=this._x1;if(isNaN(e))n=(e=Math.floor(t))+1;else{for(var r,i,o=n-e||1,a=this._root;e>t||t>=n;)switch(i=+(t<e),(r=new Array(2))[i]=a,a=r,o*=2,i){case 0:n=e+o;break;case 1:e=n-o}this._root&&this._root.length&&(this._root=a)}return this._x0=e,this._x1=n,this},jv.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},jv.extent=function(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]},jv.find=function(t,e){var n,r,i,o,a,s=this._x0,u=this._x1,c=[],l=this._root;for(l&&c.push(new _v(l,s,u)),null==e?e=1/0:(s=t-e,u=t+e);o=c.pop();)if(!(!(l=o.node)||(r=o.x0)>u||(i=o.x1)<s))if(l.length){var h=(r+i)/2;c.push(new _v(l[1],h,i),new _v(l[0],r,h)),(a=+(t>=h))&&(o=c[c.length-1],c[c.length-1]=c[c.length-1-a],c[c.length-1-a]=o)}else{var d=Math.abs(t-+this._x.call(null,l.data));d<e&&(e=d,s=t-d,u=t+d,n=l.data)}return n},jv.remove=function(t){if(isNaN(o=+this._x.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,l=this._root,h=this._x0,d=this._x1;if(!l)return this;if(l.length)for(;;){if((s=o>=(a=(h+d)/2))?h=a:d=a,e=l,!(l=l[u=+s]))return this;if(!l.length)break;e[u+1&1]&&(n=e,c=u)}for(;l.data!==t;)if(r=l,!(l=l.next))return this;return(i=l.next)&&delete l.next,r?(i?r.next=i:delete r.next,this):e?(i?e[u]=i:delete e[u],(l=e[0]||e[1])&&l===(e[1]||e[0])&&!l.length&&(n?n[c]=l:this._root=l),this):(this._root=i,this)},jv.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},jv.root=function(){return this._root},jv.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},jv.visit=function(t){var e,n,r,i,o=[],a=this._root;for(a&&o.push(new _v(a,this._x0,this._x1));e=o.pop();)if(!t(a=e.node,r=e.x0,i=e.x1)&&a.length){var s=(r+i)/2;(n=a[1])&&o.push(new _v(n,s,i)),(n=a[0])&&o.push(new _v(n,r,s))}return this},jv.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new _v(this._root,this._x0,this._x1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.x1,u=(a+s)/2;(o=i[0])&&n.push(new _v(o,a,u)),(o=i[1])&&n.push(new _v(o,u,s))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.x1);return this},jv.x=function(t){return arguments.length?(this._x=t,this):this._x};const qv=1664525,Yv=1013904223,Kv=4294967296;function Xv(t){return t.x}function Zv(t){return t.y}function Qv(t){return t.z}var Jv,tb,eb,nb,rb,ib,ob,ab,sb,ub,cb,lb,hb,db,fb,pb,gb,mb,yb,vb,bb,xb,wb,Eb,Mb,Sb,Nb,kb,Cb,Tb,Ab,Pb,Ob,_b,Rb,Ib,Db,Lb,jb,Bb,zb,Fb,Gb,Vb,Wb,Hb,Ub,$b,qb,Yb,Kb,Xb,Zb,Qb,Jb,tx,ex,nx,rx,ix,ox,ax,sx,ux,cx,lx,hx,dx,fx,px,gx,mx,yx,vx,bx,xx,wx,Ex,Mx,Sx,Nx,kx,Cx,Tx,Ax,Px,Ox,_x,Rx,Ix,Dx,Lx,jx,Bx,zx,Fx,Gx,Vx,Wx,Hx,Ux,$x,qx,Yx,Kx,Xx,Zx,Qx,Jx=Math.PI*(3-Math.sqrt(5)),tw=20*Math.PI/(9+Math.sqrt(221));function ew(t,e){e=e||2;var n,r=Math.min(3,Math.max(1,Math.round(e))),i=1,o=.001,a=1-Math.pow(o,1/300),s=0,u=.6,c=new Map,l=fv(f),h=Ky("tick","end"),d=function(){let t=1;return()=>(t=(qv*t+Yv)%Kv)/Kv}();function f(){p(),h.call("tick",n),i<o&&(l.stop(),h.call("end",n))}function p(e){var o,l,h=t.length;void 0===e&&(e=1);for(var d=0;d<e;++d)for(i+=(s-i)*a,c.forEach((function(t){t(i)})),o=0;o<h;++o)null==(l=t[o]).fx?l.x+=l.vx*=u:(l.x=l.fx,l.vx=0),r>1&&(null==l.fy?l.y+=l.vy*=u:(l.y=l.fy,l.vy=0)),r>2&&(null==l.fz?l.z+=l.vz*=u:(l.z=l.fz,l.vz=0));return n}function g(){for(var e,n=0,i=t.length;n<i;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),null!=e.fz&&(e.z=e.fz),isNaN(e.x)||r>1&&isNaN(e.y)||r>2&&isNaN(e.z)){var o=10*(r>2?Math.cbrt(.5+n):r>1?Math.sqrt(.5+n):n),a=n*Jx,s=n*tw;1===r?e.x=o:2===r?(e.x=o*Math.cos(a),e.y=o*Math.sin(a)):(e.x=o*Math.sin(a)*Math.cos(s),e.y=o*Math.cos(a),e.z=o*Math.sin(a)*Math.sin(s))}(isNaN(e.vx)||r>1&&isNaN(e.vy)||r>2&&isNaN(e.vz))&&(e.vx=0,r>1&&(e.vy=0),r>2&&(e.vz=0))}}function m(e){return e.initialize&&e.initialize(t,d,r),e}return null==t&&(t=[]),g(),n={tick:p,restart:function(){return l.restart(f),n},stop:function(){return l.stop(),n},numDimensions:function(t){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(t))),c.forEach(m),n):r},nodes:function(e){return arguments.length?(t=e,g(),c.forEach(m),n):t},alpha:function(t){return arguments.length?(i=+t,n):i},alphaMin:function(t){return arguments.length?(o=+t,n):o},alphaDecay:function(t){return arguments.length?(a=+t,n):+a},alphaTarget:function(t){return arguments.length?(s=+t,n):s},velocityDecay:function(t){return arguments.length?(u=1-t,n):1-u},randomSource:function(t){return arguments.length?(d=t,c.forEach(m),n):d},force:function(t,e){return arguments.length>1?(null==e?c.delete(t):c.set(t,m(e)),n):c.get(t)},find:function(){var e,n,i,o,a,s,u=Array.prototype.slice.call(arguments),c=u.shift()||0,l=(r>1?u.shift():null)||0,h=(r>2?u.shift():null)||0,d=u.shift()||1/0,f=0,p=t.length;for(d*=d,f=0;f<p;++f)(o=(e=c-(a=t[f]).x)*e+(n=l-(a.y||0))*n+(i=h-(a.z||0))*i)<d&&(s=a,d=o);return s},on:function(t,e){return arguments.length>1?(h.on(t,e),n):h.on(t)}}}function nw(){var t,e,n,r,i,o,a=Bv(-30),s=1,u=1/0,c=.81;function l(r){var o,a=t.length,s=(1===e?Iv(t,Xv):2===e?gm(t,Xv,Zv):3===e?Sm(t,Xv,Zv,Qv):null).visitAfter(d);for(i=r,o=0;o<a;++o)n=t[o],s.visit(f)}function h(){if(t){var e,n,r=t.length;for(o=new Array(r),e=0;e<r;++e)n=t[e],o[n.index]=+a(n,e,t)}}function d(t){var n,r,i,a,s,u,c=0,l=0,h=t.length;if(h){for(i=a=s=u=0;u<h;++u)(n=t[u])&&(r=Math.abs(n.value))&&(c+=n.value,l+=r,i+=r*(n.x||0),a+=r*(n.y||0),s+=r*(n.z||0));c*=Math.sqrt(4/h),t.x=i/l,e>1&&(t.y=a/l),e>2&&(t.z=s/l)}else{(n=t).x=n.data.x,e>1&&(n.y=n.data.y),e>2&&(n.z=n.data.z);do{c+=o[n.data.index]}while(n=n.next)}t.value=c}function f(t,a,l,h,d){if(!t.value)return!0;var f=[l,h,d][e-1],p=t.x-n.x,g=e>1?t.y-n.y:0,m=e>2?t.z-n.z:0,y=f-a,v=p*p+g*g+m*m;if(y*y/c<v)return v<u&&(0===p&&(v+=(p=zv(r))*p),e>1&&0===g&&(v+=(g=zv(r))*g),e>2&&0===m&&(v+=(m=zv(r))*m),v<s&&(v=Math.sqrt(s*v)),n.vx+=p*t.value*i/v,e>1&&(n.vy+=g*t.value*i/v),e>2&&(n.vz+=m*t.value*i/v)),!0;if(!(t.length||v>=u)){(t.data!==n||t.next)&&(0===p&&(v+=(p=zv(r))*p),e>1&&0===g&&(v+=(g=zv(r))*g),e>2&&0===m&&(v+=(m=zv(r))*m),v<s&&(v=Math.sqrt(s*v)));do{t.data!==n&&(y=o[t.data.index]*i/v,n.vx+=p*y,e>1&&(n.vy+=g*y),e>2&&(n.vz+=m*y))}while(t=t.next)}}return l.initialize=function(n,...i){t=n,r=i.find((t=>"function"==typeof t))||Math.random,e=i.find((t=>[1,2,3].includes(t)))||2,h()},l.strength=function(t){return arguments.length?(a="function"==typeof t?t:Bv(+t),h(),l):a},l.distanceMin=function(t){return arguments.length?(s=t*t,l):Math.sqrt(s)},l.distanceMax=function(t){return arguments.length?(u=t*t,l):Math.sqrt(u)},l.theta=function(t){return arguments.length?(c=t*t,l):Math.sqrt(c)},l}function rw(t,e,n,r){var i,o,a,s,u=Bv(.1);function c(t){for(var u=0,c=i.length;u<c;++u){var l=i[u],h=l.x-e||1e-6,d=(l.y||0)-n||1e-6,f=(l.z||0)-r||1e-6,p=Math.sqrt(h*h+d*d+f*f),g=(s[u]-p)*a[u]*t/p;l.vx+=h*g,o>1&&(l.vy+=d*g),o>2&&(l.vz+=f*g)}}function l(){if(i){var e,n=i.length;for(a=new Array(n),s=new Array(n),e=0;e<n;++e)s[e]=+t(i[e],e,i),a[e]=isNaN(s[e])?0:+u(i[e],e,i)}}return"function"!=typeof t&&(t=Bv(+t)),null==e&&(e=0),null==n&&(n=0),null==r&&(r=0),c.initialize=function(t,...e){i=t,o=e.find((t=>[1,2,3].includes(t)))||2,l()},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:Bv(+t),l(),c):u},c.radius=function(e){return arguments.length?(t="function"==typeof e?e:Bv(+e),l(),c):t},c.x=function(t){return arguments.length?(e=+t,c):e},c.y=function(t){return arguments.length?(n=+t,c):n},c.z=function(t){return arguments.length?(r=+t,c):r},c}function iw(t){var e,n,r,i=Bv(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Bv(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Bv(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Bv(+e),a(),o):t},o}function ow(t){var e,n,r,i=Bv(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Bv(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Bv(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Bv(+e),a(),o):t},o}function aw(t){var e,n,r,i=Bv(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vz+=(r[o]-i.z)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=Bv(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Bv(+t),a(),o):i},o.z=function(e){return arguments.length?(t="function"==typeof e?e:Bv(+e),a(),o):t},o}class sw extends Tv{constructor(){super(...arguments),this.id="d3-force-3d",this.config={inputNodeAttrs:["x","y","z","vx","vy","vz","fx","fy","fz"],outputNodeAttrs:["x","y","z","vx","vy","vz"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:$v,manyBody:nw,center:Pv,collide:Wv,radial:rw,x:iw,y:ow,z:aw},this.options={numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return ew()}}function uw(){if(nb)return eb;return nb=1,eb=function(t,e){return t===e||t!=t&&e!=e}}function cw(){if(ib)return rb;ib=1;var t=uw();return rb=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},rb}function lw(){if(pb)return fb;pb=1;var t=tb?Jv:(tb=1,Jv=function(){this.__data__=[],this.size=0}),e=function(){if(ab)return ob;ab=1;var t=cw(),e=Array.prototype.splice;return ob=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},ob}(),n=function(){if(ub)return sb;ub=1;var t=cw();return sb=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},sb}(),r=function(){if(lb)return cb;lb=1;var t=cw();return cb=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(db)return hb;db=1;var t=cw();return hb=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},hb}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,fb=o}function hw(){if(Sb)return Mb;Sb=1;var t="object"==typeof d&&d&&d.Object===Object&&d;return Mb=t}function dw(){if(kb)return Nb;kb=1;var t=hw(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return Nb=n}function fw(){if(Tb)return Cb;Tb=1;var t=dw().Symbol;return Cb=t}function pw(){if(Ib)return Rb;Ib=1;var t=fw(),e=function(){if(Pb)return Ab;Pb=1;var t=fw(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return Ab=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var a=!0}catch(t){}var s=r.call(t);return a&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(_b)return Ob;_b=1;var t=Object.prototype.toString;return Ob=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return Rb=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function gw(){if(Lb)return Db;return Lb=1,Db=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function mw(){if(Bb)return jb;Bb=1;var t=pw(),e=gw();return jb=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function yw(){if(Vb)return Gb;Vb=1;var t,e=function(){if(Fb)return zb;Fb=1;var t=dw()["__core-js_shared__"];return zb=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Gb=function(t){return!!n&&n in t}}function vw(){if(Hb)return Wb;Hb=1;var t=Function.prototype.toString;return Wb=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function bw(){if(Xb)return Kb;Xb=1;var t=function(){if($b)return Ub;$b=1;var t=mw(),e=yw(),n=gw(),r=vw(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,u=a.hasOwnProperty,c=RegExp("^"+s.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return Ub=function(o){return!(!n(o)||e(o))&&(t(o)?c:i).test(r(o))}}(),e=Yb?qb:(Yb=1,qb=function(t,e){return null==t?void 0:t[e]});return Kb=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function xw(){if(Qb)return Zb;Qb=1;var t=bw()(dw(),"Map");return Zb=t}function ww(){if(tx)return Jb;tx=1;var t=bw()(Object,"create");return Jb=t}function Ew(){if(dx)return hx;dx=1;var t=function(){if(nx)return ex;nx=1;var t=ww();return ex=function(){this.__data__=t?t(null):{},this.size=0}}(),e=ix?rx:(ix=1,rx=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(ax)return ox;ax=1;var t=ww(),e=Object.prototype.hasOwnProperty;return ox=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},ox}(),r=function(){if(ux)return sx;ux=1;var t=ww(),e=Object.prototype.hasOwnProperty;return sx=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},sx}(),i=function(){if(lx)return cx;lx=1;var t=ww();return cx=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},cx}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,hx=o}function Mw(){if(vx)return yx;vx=1;var t=mx?gx:(mx=1,gx=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return yx=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},yx}function Sw(){if(Tx)return Cx;Tx=1;var t=function(){if(px)return fx;px=1;var t=Ew(),e=lw(),n=xw();return fx=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(xx)return bx;xx=1;var t=Mw();return bx=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(Ex)return wx;Ex=1;var t=Mw();return wx=function(e){return t(this,e).get(e)}}(),r=function(){if(Sx)return Mx;Sx=1;var t=Mw();return Mx=function(e){return t(this,e).has(e)}}(),i=function(){if(kx)return Nx;kx=1;var t=Mw();return Nx=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},Nx}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,Cx=o}function Nw(){if(_x)return Ox;_x=1;var t=lw(),e=function(){if(mb)return gb;mb=1;var t=lw();return gb=function(){this.__data__=new t,this.size=0}}(),n=(vb||(vb=1,yb=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),yb),r=xb?bb:(xb=1,bb=function(t){return this.__data__.get(t)}),i=Eb?wb:(Eb=1,wb=function(t){return this.__data__.has(t)}),o=function(){if(Px)return Ax;Px=1;var t=lw(),e=xw(),n=Sw();return Ax=function(r,i){var o=this.__data__;if(o instanceof t){var a=o.__data__;if(!e||a.length<199)return a.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(a)}return o.set(r,i),this.size=o.size,this},Ax}();function a(e){var n=this.__data__=new t(e);this.size=n.size}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,Ox=a}function kw(){if(Ix)return Rx;return Ix=1,Rx=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},Rx}function Cw(){if(Lx)return Dx;Lx=1;var t=bw(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Dx=e}function Tw(){if(Bx)return jx;Bx=1;var t=Cw();return jx=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function Aw(){if(Fx)return zx;Fx=1;var t=Tw(),e=uw(),n=Object.prototype.hasOwnProperty;return zx=function(r,i,o){var a=r[i];n.call(r,i)&&e(a,o)&&(void 0!==o||i in r)||t(r,i,o)}}function Pw(){if(Vx)return Gx;Vx=1;var t=Aw(),e=Tw();return Gx=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,u=r.length;++s<u;){var c=r[s],l=o?o(i[c],n[c],c,i,n):void 0;void 0===l&&(l=n[c]),a?e(i,c,l):t(i,c,l)}return i},Gx}function Ow(){if($x)return Ux;return $x=1,Ux=function(t){return null!=t&&"object"==typeof t}}function _w(){if(Xx)return Kx;Xx=1;var t=function(){if(Yx)return qx;Yx=1;var t=pw(),e=Ow();return qx=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=Ow(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return Kx=o}function Rw(){if(Qx)return Zx;Qx=1;var t=Array.isArray;return Zx=t}var Iw,Dw,Lw,jw,Bw,zw,Fw,Gw,Vw,Ww,Hw,Uw={exports:{}};function $w(){return Lw||(Lw=1,function(t,e){var n=dw(),r=Dw?Iw:(Dw=1,Iw=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,a=o&&o.exports===i?n.Buffer:void 0,s=(a?a.isBuffer:void 0)||r;t.exports=s}(Uw,Uw.exports)),Uw.exports}function qw(){if(Bw)return jw;Bw=1;var t=/^(?:0|[1-9]\d*)$/;return jw=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},jw}function Yw(){if(Fw)return zw;Fw=1;return zw=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Kw(){if(Hw)return Ww;return Hw=1,Ww=function(t){return function(e){return t(e)}}}Uw.exports;var Xw,Zw,Qw,Jw,tE,eE,nE,rE,iE,oE,aE,sE,uE,cE,lE,hE,dE,fE,pE,gE,mE,yE,vE,bE,xE,wE,EE,ME={exports:{}};function SE(){return Xw||(Xw=1,function(t,e){var n=hw(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,a=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=a}(ME,ME.exports)),ME.exports}function NE(){if(Qw)return Zw;Qw=1;var t=function(){if(Vw)return Gw;Vw=1;var t=pw(),e=Yw(),n=Ow(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,Gw=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=Kw(),n=SE(),r=n&&n.isTypedArray,i=r?e(r):t;return Zw=i}function kE(){if(tE)return Jw;tE=1;var t=(Hx||(Hx=1,Wx=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),Wx),e=_w(),n=Rw(),r=$w(),i=qw(),o=NE(),a=Object.prototype.hasOwnProperty;return Jw=function(s,u){var c=n(s),l=!c&&e(s),h=!c&&!l&&r(s),d=!c&&!l&&!h&&o(s),f=c||l||h||d,p=f?t(s.length,String):[],g=p.length;for(var m in s)!u&&!a.call(s,m)||f&&("length"==m||h&&("offset"==m||"parent"==m)||d&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||i(m,g))||p.push(m);return p},Jw}function CE(){if(nE)return eE;nE=1;var t=Object.prototype;return eE=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function TE(){if(iE)return rE;return iE=1,rE=function(t,e){return function(n){return t(e(n))}}}function AE(){if(uE)return sE;uE=1;var t=CE(),e=function(){if(aE)return oE;aE=1;var t=TE()(Object.keys,Object);return oE=t}(),n=Object.prototype.hasOwnProperty;return sE=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function PE(){if(lE)return cE;lE=1;var t=mw(),e=Yw();return cE=function(n){return null!=n&&e(n.length)&&!t(n)}}function OE(){if(dE)return hE;dE=1;var t=kE(),e=AE(),n=PE();return hE=function(r){return n(r)?t(r):e(r)}}function _E(){if(vE)return yE;vE=1;var t=gw(),e=CE(),n=mE?gE:(mE=1,gE=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return yE=function(i){if(!t(i))return n(i);var o=e(i),a=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&a.push(s);return a}}function RE(){if(xE)return bE;xE=1;var t=kE(),e=_E(),n=PE();return bE=function(r){return n(r)?t(r,!0):e(r)}}ME.exports;var IE,DE,LE,jE,BE,zE,FE,GE,VE,WE,HE,UE,$E,qE,YE,KE,XE,ZE,QE,JE,tM,eM,nM,rM,iM,oM,aM,sM,uM,cM,lM,hM,dM,fM,pM,gM,mM,yM,vM,bM,xM,wM,EM,MM,SM,NM,kM,CM,TM,AM,PM,OM,_M,RM,IM,DM,LM,jM,BM,zM,FM,GM,VM,WM,HM,UM,$M,qM,YM,KM,XM,ZM,QM,JM,tS,eS,nS,rS,iS,oS,aS,sS,uS,cS,lS,hS,dS,fS,pS,gS,mS,yS,vS,bS,xS,wS,ES,MS,SS,NS,kS,CS,TS,AS,PS,OS,_S,RS,IS,DS,LS,jS,BS,zS,FS,GS,VS,WS,HS,US,$S,qS,YS,KS,XS,ZS,QS,JS,tN,eN,nN,rN,iN,oN,aN,sN,uN,cN,lN,hN,dN,fN,pN,gN,mN,yN,vN,bN,xN,wN,EN,MN,SN,NN,kN,CN,TN,AN,PN,ON,_N,RN,IN,DN,LN,jN,BN,zN,FN,GN,VN,WN,HN,UN,$N,qN,YN,KN,XN,ZN,QN,JN,tk,ek,nk,rk,ik,ok,ak,sk,uk,ck,lk,hk,dk,fk,pk,gk,mk,yk,vk,bk,xk,wk,Ek,Mk,Sk,Nk,kk,Ck,Tk,Ak,Pk,Ok,_k,Rk,Ik,Dk,Lk,jk,Bk,zk,Fk,Gk,Vk,Wk,Hk,Uk,$k,qk,Yk,Kk,Xk,Zk,Qk,Jk,tC,eC,nC,rC,iC,oC,aC,sC,uC,cC,lC,hC,dC,fC,pC,gC,mC,yC,vC,bC,xC,wC,EC,MC,SC,NC,kC,CC,TC,AC,PC,OC,_C,RC,IC,DC,LC,jC,BC,zC,FC,GC,VC,WC,HC={exports:{}};function UC(){return IE||(IE=1,function(t,e){var n=dw(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}}(HC,HC.exports)),HC.exports}function $C(){if(LE)return DE;return LE=1,DE=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},DE}function qC(){if(BE)return jE;return BE=1,jE=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o},jE}function YC(){if(FE)return zE;return FE=1,zE=function(){return[]}}function KC(){if(VE)return GE;VE=1;var t=qC(),e=YC(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return GE=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function XC(){if($E)return UE;return $E=1,UE=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},UE}function ZC(){if(YE)return qE;YE=1;var t=TE()(Object.getPrototypeOf,Object);return qE=t}function QC(){if(XE)return KE;XE=1;var t=XC(),e=ZC(),n=KC(),r=YC(),i=Object.getOwnPropertySymbols;return KE=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function JC(){if(tM)return JE;tM=1;var t=XC(),e=Rw();return JE=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function tT(){if(nM)return eM;nM=1;var t=JC(),e=KC(),n=OE();return eM=function(r){return t(r,n,e)}}function eT(){if(lM)return cM;lM=1;var t=bw()(dw(),"Set");return cM=t}function nT(){if(pM)return fM;pM=1;var t=function(){if(aM)return oM;aM=1;var t=bw()(dw(),"DataView");return oM=t}(),e=xw(),n=function(){if(uM)return sM;uM=1;var t=bw()(dw(),"Promise");return sM=t}(),r=eT(),i=function(){if(dM)return hM;dM=1;var t=bw()(dw(),"WeakMap");return hM=t}(),o=pw(),a=vw(),s="[object Map]",u="[object Promise]",c="[object Set]",l="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),m=a(i),y=o;return(t&&y(new t(new ArrayBuffer(1)))!=h||e&&y(new e)!=s||n&&y(n.resolve())!=u||r&&y(new r)!=c||i&&y(new i)!=l)&&(y=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?a(n):"";if(r)switch(r){case d:return h;case f:return s;case p:return u;case g:return c;case m:return l}return e}),fM=y}function rT(){if(vM)return yM;vM=1;var t=dw().Uint8Array;return yM=t}function iT(){if(xM)return bM;xM=1;var t=rT();return bM=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function oT(){if(TM)return CM;TM=1;var t=iT();return CM=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function aT(){if(PM)return AM;PM=1;var t=iT(),e=function(){if(EM)return wM;EM=1;var t=iT();return wM=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(SM)return MM;SM=1;var t=/\w*$/;return MM=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(kM)return NM;kM=1;var t=fw(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return NM=function(t){return n?Object(n.call(t)):{}}}(),i=oT();return AM=function(o,a,s){var u=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new u(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function sT(){if(_M)return OM;_M=1;var t=gw(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return OM=n}function uT(){if(IM)return RM;IM=1;var t=sT(),e=ZC(),n=CE();return RM=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function cT(){if(BM)return jM;BM=1;var t=function(){if(LM)return DM;LM=1;var t=nT(),e=Ow();return DM=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=Kw(),n=SE(),r=n&&n.isMap,i=r?e(r):t;return jM=i}function lT(){if(VM)return GM;VM=1;var t=function(){if(FM)return zM;FM=1;var t=nT(),e=Ow();return zM=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=Kw(),n=SE(),r=n&&n.isSet,i=r?e(r):t;return GM=i}function hT(){if(HM)return WM;HM=1;var t=Nw(),e=kw(),n=Aw(),r=function(){if(pE)return fE;pE=1;var t=Pw(),e=OE();return fE=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(EE)return wE;EE=1;var t=Pw(),e=RE();return wE=function(n,r){return n&&t(r,e(r),n)}}(),o=UC(),a=$C(),s=function(){if(HE)return WE;HE=1;var t=Pw(),e=KC();return WE=function(n,r){return t(n,e(n),r)}}(),u=function(){if(QE)return ZE;QE=1;var t=Pw(),e=QC();return ZE=function(n,r){return t(n,e(n),r)}}(),c=tT(),l=function(){if(iM)return rM;iM=1;var t=JC(),e=QC(),n=RE();return rM=function(r){return t(r,n,e)}}(),h=nT(),d=function(){if(mM)return gM;mM=1;var t=Object.prototype.hasOwnProperty;return gM=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},gM}(),f=aT(),p=uT(),g=Rw(),m=$w(),y=cT(),v=gw(),b=lT(),x=OE(),w=RE(),E="[object Arguments]",M="[object Function]",S="[object Object]",N={};return N[E]=N["[object Array]"]=N["[object ArrayBuffer]"]=N["[object DataView]"]=N["[object Boolean]"]=N["[object Date]"]=N["[object Float32Array]"]=N["[object Float64Array]"]=N["[object Int8Array]"]=N["[object Int16Array]"]=N["[object Int32Array]"]=N["[object Map]"]=N["[object Number]"]=N[S]=N["[object RegExp]"]=N["[object Set]"]=N["[object String]"]=N["[object Symbol]"]=N["[object Uint8Array]"]=N["[object Uint8ClampedArray]"]=N["[object Uint16Array]"]=N["[object Uint32Array]"]=!0,N["[object Error]"]=N[M]=N["[object WeakMap]"]=!1,WM=function k(C,T,A,P,O,_){var R,I=1&T,D=2&T,L=4&T;if(A&&(R=O?A(C,P,O,_):A(C)),void 0!==R)return R;if(!v(C))return C;var j=g(C);if(j){if(R=d(C),!I)return a(C,R)}else{var B=h(C),z=B==M||"[object GeneratorFunction]"==B;if(m(C))return o(C,I);if(B==S||B==E||z&&!O){if(R=D||z?{}:p(C),!I)return D?u(C,i(R,C)):s(C,r(R,C))}else{if(!N[B])return O?C:{};R=f(C,B,I)}}_||(_=new t);var F=_.get(C);if(F)return F;_.set(C,R),b(C)?C.forEach((function(t){R.add(k(t,T,A,t,C,_))})):y(C)&&C.forEach((function(t,e){R.set(e,k(t,T,A,e,C,_))}));var G=j?void 0:(L?D?l:c:D?w:x)(C);return e(G||C,(function(t,e){G&&(t=C[e=t]),n(R,e,k(t,T,A,e,C,_))})),R},WM}function dT(){if($M)return UM;$M=1;var t=hT();return UM=function(e){return t(e,4)}}function fT(){if(YM)return qM;return YM=1,qM=function(t){return function(){return t}}}function pT(){if(QM)return ZM;QM=1;var t=(XM||(XM=1,KM=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var u=a[t?s:++i];if(!1===n(o[u],u,o))break}return e}}),KM),e=t();return ZM=e}function gT(){if(tS)return JM;tS=1;var t=pT(),e=OE();return JM=function(n,r){return n&&t(n,r,e)}}function mT(){if(iS)return rS;iS=1;var t=gT(),e=function(){if(nS)return eS;nS=1;var t=PE();return eS=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,a=n?o:-1,s=Object(r);(n?a--:++a<o)&&!1!==i(s[a],a,s););return r}},eS}(),n=e(t);return rS=n}function yT(){if(aS)return oS;return aS=1,oS=function(t){return t}}function vT(){if(uS)return sS;uS=1;var t=yT();return sS=function(e){return"function"==typeof e?e:t}}function bT(){if(lS)return cS;lS=1;var t=kw(),e=mT(),n=vT(),r=Rw();return cS=function(i,o){return(r(i)?t:e)(i,n(o))}}function xT(){return dS?hS:(dS=1,hS=bT())}function wT(){if(xS)return bS;xS=1;var t=Sw(),e=mS?gS:(mS=1,gS=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=vS?yS:(vS=1,yS=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,bS=r}function ET(){if(SS)return MS;return SS=1,MS=function(t,e){return t.has(e)}}function MT(){if(kS)return NS;kS=1;var t=wT(),e=(ES||(ES=1,wS=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),wS),n=ET();return NS=function(r,i,o,a,s,u){var c=1&o,l=r.length,h=i.length;if(l!=h&&!(c&&h>l))return!1;var d=u.get(r),f=u.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,m=2&o?new t:void 0;for(u.set(r,i),u.set(i,r);++p<l;){var y=r[p],v=i[p];if(a)var b=c?a(v,y,p,i,r,u):a(y,v,p,r,i,u);if(void 0!==b){if(b)continue;g=!1;break}if(m){if(!e(i,(function(t,e){if(!n(m,e)&&(y===t||s(y,t,o,a,u)))return m.push(e)}))){g=!1;break}}else if(y!==v&&!s(y,v,o,a,u)){g=!1;break}}return u.delete(r),u.delete(i),g},NS}function ST(){if(PS)return AS;return PS=1,AS=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},AS}function NT(){if(_S)return OS;_S=1;var t=fw(),e=rT(),n=uw(),r=MT(),i=(TS||(TS=1,CS=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),CS),o=ST(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return OS=function(t,a,u,c,l,h,d){switch(u){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!h(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&c;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;c|=2,d.set(t,a);var m=r(f(t),f(a),c,l,h,d);return d.delete(t),m;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function kT(){if(LS)return DS;LS=1;var t=Nw(),e=MT(),n=NT(),r=function(){if(IS)return RS;IS=1;var t=tT(),e=Object.prototype.hasOwnProperty;return RS=function(n,r,i,o,a,s){var u=1&i,c=t(n),l=c.length;if(l!=t(r).length&&!u)return!1;for(var h=l;h--;){var d=c[h];if(!(u?d in r:e.call(r,d)))return!1}var f=s.get(n),p=s.get(r);if(f&&p)return f==r&&p==n;var g=!0;s.set(n,r),s.set(r,n);for(var m=u;++h<l;){var y=n[d=c[h]],v=r[d];if(o)var b=u?o(v,y,d,r,n,s):o(y,v,d,n,r,s);if(!(void 0===b?y===v||a(y,v,i,o,s):b)){g=!1;break}m||(m="constructor"==d)}if(g&&!m){var x=n.constructor,w=r.constructor;x==w||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof w&&w instanceof w||(g=!1)}return s.delete(n),s.delete(r),g},RS}(),i=nT(),o=Rw(),a=$w(),s=NE(),u="[object Arguments]",c="[object Array]",l="[object Object]",h=Object.prototype.hasOwnProperty;return DS=function(d,f,p,g,m,y){var v=o(d),b=o(f),x=v?c:i(d),w=b?c:i(f),E=(x=x==u?l:x)==l,M=(w=w==u?l:w)==l,S=x==w;if(S&&a(d)){if(!a(f))return!1;v=!0,E=!1}if(S&&!E)return y||(y=new t),v||s(d)?e(d,f,p,g,m,y):n(d,f,x,p,g,m,y);if(!(1&p)){var N=E&&h.call(d,"__wrapped__"),k=M&&h.call(f,"__wrapped__");if(N||k){var C=N?d.value():d,T=k?f.value():f;return y||(y=new t),m(C,T,p,g,y)}}return!!S&&(y||(y=new t),r(d,f,p,g,m,y))}}function CT(){if(BS)return jS;BS=1;var t=kT(),e=Ow();return jS=function n(r,i,o,a,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,a,n,s))},jS}function TT(){if(VS)return GS;VS=1;var t=gw();return GS=function(e){return e==e&&!t(e)}}function AT(){if($S)return US;return $S=1,US=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function PT(){if(YS)return qS;YS=1;var t=function(){if(FS)return zS;FS=1;var t=Nw(),e=CT();return zS=function(n,r,i,o){var a=i.length,s=a,u=!o;if(null==n)return!s;for(n=Object(n);a--;){var c=i[a];if(u&&c[2]?c[1]!==n[c[0]]:!(c[0]in n))return!1}for(;++a<s;){var l=(c=i[a])[0],h=n[l],d=c[1];if(u&&c[2]){if(void 0===h&&!(l in n))return!1}else{var f=new t;if(o)var p=o(h,d,l,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},zS}(),e=function(){if(HS)return WS;HS=1;var t=TT(),e=OE();return WS=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],a=n[o];r[i]=[o,a,t(a)]}return r},WS}(),n=AT();return qS=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function OT(){if(XS)return KS;XS=1;var t=pw(),e=Ow();return KS=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function _T(){if(QS)return ZS;QS=1;var t=Rw(),e=OT(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return ZS=function(i,o){if(t(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function RT(){if(nN)return eN;nN=1;var t=function(){if(tN)return JS;tN=1;var t=Sw();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var a=n.apply(this,t);return i.cache=o.set(e,a)||o,a};return i.cache=new(e.Cache||t),i}return e.Cache=t,JS=e}();return eN=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function IT(){if(aN)return oN;return aN=1,oN=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},oN}function DT(){if(lN)return cN;lN=1;var t=function(){if(uN)return sN;uN=1;var t=fw(),e=IT(),n=Rw(),r=OT(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return sN=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},sN}();return cN=function(e){return null==e?"":t(e)}}function LT(){if(dN)return hN;dN=1;var t=Rw(),e=_T(),n=function(){if(iN)return rN;iN=1;var t=RT(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,(function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)})),r}));return rN=r}(),r=DT();return hN=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function jT(){if(pN)return fN;pN=1;var t=OT();return fN=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function BT(){if(mN)return gN;mN=1;var t=LT(),e=jT();return gN=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},gN}function zT(){if(EN)return wN;EN=1;var t=LT(),e=_w(),n=Rw(),r=qw(),i=Yw(),o=jT();return wN=function(a,s,u){for(var c=-1,l=(s=t(s,a)).length,h=!1;++c<l;){var d=o(s[c]);if(!(h=null!=a&&u(a,d)))break;a=a[d]}return h||++c!=l?h:!!(l=null==a?0:a.length)&&i(l)&&r(d,l)&&(n(a)||e(a))},wN}function FT(){if(SN)return MN;SN=1;var t=xN?bN:(xN=1,bN=function(t,e){return null!=t&&e in Object(t)}),e=zT();return MN=function(n,r){return null!=n&&e(n,r,t)}}function GT(){if(kN)return NN;kN=1;var t=CT(),e=function(){if(vN)return yN;vN=1;var t=BT();return yN=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=FT(),r=_T(),i=TT(),o=AT(),a=jT();return NN=function(s,u){return r(s)&&i(u)?o(a(s),u):function(r){var i=e(r,s);return void 0===i&&i===u?n(r,s):t(u,i,3)}}}function VT(){if(TN)return CN;return TN=1,CN=function(t){return function(e){return null==e?void 0:e[t]}}}function WT(){if(_N)return ON;_N=1;var t=VT(),e=function(){if(PN)return AN;PN=1;var t=BT();return AN=function(e){return function(n){return t(n,e)}}}(),n=_T(),r=jT();return ON=function(i){return n(i)?t(r(i)):e(i)}}function HT(){if(IN)return RN;IN=1;var t=PT(),e=GT(),n=yT(),r=Rw(),i=WT();return RN=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function UT(){if(LN)return DN;LN=1;var t=qC(),e=function(){if(pS)return fS;pS=1;var t=mT();return fS=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},fS}(),n=HT(),r=Rw();return DN=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function $T(){if(FN)return zN;FN=1;var t=function(){if(BN)return jN;BN=1;var t=Object.prototype.hasOwnProperty;return jN=function(e,n){return null!=e&&t.call(e,n)}}(),e=zT();return zN=function(n,r){return null!=n&&e(n,r,t)}}function qT(){if(VN)return GN;VN=1;var t=AE(),e=nT(),n=_w(),r=Rw(),i=PE(),o=$w(),a=CE(),s=NE(),u=Object.prototype.hasOwnProperty;return GN=function(c){if(null==c)return!0;if(i(c)&&(r(c)||"string"==typeof c||"function"==typeof c.splice||o(c)||s(c)||n(c)))return!c.length;var l=e(c);if("[object Map]"==l||"[object Set]"==l)return!c.size;if(a(c))return!t(c).length;for(var h in c)if(u.call(c,h))return!1;return!0}}function YT(){if(HN)return WN;return HN=1,WN=function(t){return void 0===t}}function KT(){if($N)return UN;$N=1;var t=mT(),e=PE();return UN=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,(function(t,e,n){o[++i]=r(t,e,n)})),o},UN}function XT(){if(YN)return qN;YN=1;var t=IT(),e=HT(),n=KT(),r=Rw();return qN=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function ZT(){if(tk)return JN;tk=1;var t=(XN||(XN=1,KN=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),KN),e=mT(),n=HT(),r=(QN||(QN=1,ZN=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),ZN),i=Rw();return JN=function(o,a,s){var u=i(o)?t:r,c=arguments.length<3;return u(o,n(a,4),s,c,e)},JN}function QT(){if(lk)return ck;lk=1;var t=function(){if(ik)return rk;ik=1;var t=VT()("length");return rk=t}(),e=function(){if(ak)return ok;ak=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return ok=function(e){return t.test(e)}}(),n=function(){if(uk)return sk;uk=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",u="[\\ufe0e\\ufe0f]?",c=u+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+u+s+")*",l="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+l+c,"g");return sk=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return ck=function(r){return e(r)?n(r):t(r)}}function JT(){if(dk)return hk;dk=1;var t=AE(),e=nT(),n=PE(),r=function(){if(nk)return ek;nk=1;var t=pw(),e=Rw(),n=Ow();return ek=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=QT();return hk=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var a=e(o);return"[object Map]"==a||"[object Set]"==a?o.size:t(o).length}}function tA(){if(pk)return fk;pk=1;var t=kw(),e=sT(),n=gT(),r=HT(),i=ZC(),o=Rw(),a=$w(),s=mw(),u=gw(),c=NE();return fk=function(l,h,d){var f=o(l),p=f||a(l)||c(l);if(h=r(h,4),null==d){var g=l&&l.constructor;d=p?f?new g:[]:u(l)&&s(g)?e(i(l)):{}}return(p?t:n)(l,(function(t,e,n){return h(d,t,e,n)})),d},fk}function eA(){if(vk)return yk;vk=1;var t=XC(),e=function(){if(mk)return gk;mk=1;var t=fw(),e=_w(),n=Rw(),r=t?t.isConcatSpreadable:void 0;return gk=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return yk=function n(r,i,o,a,s){var u=-1,c=r.length;for(o||(o=e),s||(s=[]);++u<c;){var l=r[u];i>0&&o(l)?i>1?n(l,i-1,o,a,s):t(s,l):a||(s[s.length]=l)}return s},yk}function nA(){if(Ek)return wk;Ek=1;var t=xk?bk:(xk=1,bk=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return wk=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,a=-1,s=e(o.length-r,0),u=Array(s);++a<s;)u[a]=o[r+a];a=-1;for(var c=Array(r+1);++a<r;)c[a]=o[a];return c[r]=i(u),t(n,this,c)}},wk}function rA(){if(Tk)return Ck;Tk=1;var t=function(){if(Sk)return Mk;Sk=1;var t=fT(),e=Cw(),n=yT();return Mk=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(kk)return Nk;kk=1;var t=Date.now;return Nk=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},Nk}(),n=e(t);return Ck=n}function iA(){if(Pk)return Ak;Pk=1;var t=yT(),e=nA(),n=rA();return Ak=function(r,i){return n(e(r,i,t),r+"")}}function oA(){if(_k)return Ok;return _k=1,Ok=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},Ok}function aA(){if(Bk)return jk;Bk=1;var t=oA(),e=Ik?Rk:(Ik=1,Rk=function(t){return t!=t}),n=(Lk||(Lk=1,Dk=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),Dk);return jk=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function sA(){if($k)return Uk;$k=1;var t=eT(),e=Hk?Wk:(Hk=1,Wk=function(){}),n=ST(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return Uk=r}function uA(){if(Yk)return qk;Yk=1;var t=wT(),e=function(){if(Fk)return zk;Fk=1;var t=aA();return zk=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(Vk||(Vk=1,Gk=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),Gk),r=ET(),i=sA(),o=ST();return qk=function(a,s,u){var c=-1,l=e,h=a.length,d=!0,f=[],p=f;if(u)d=!1,l=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,l=r,p=new t}else p=s?[]:f;t:for(;++c<h;){var m=a[c],y=s?s(m):m;if(m=u||0!==m?m:0,d&&y==y){for(var v=p.length;v--;)if(p[v]===y)continue t;s&&p.push(y),f.push(m)}else l(p,y,u)||(p!==f&&p.push(y),f.push(m))}return f},qk}function cA(){if(Xk)return Kk;Xk=1;var t=PE(),e=Ow();return Kk=function(n){return e(n)&&t(n)}}function lA(){if(Qk)return Zk;Qk=1;var t=eA(),e=iA(),n=uA(),r=cA(),i=e((function(e){return n(t(e,1,r,!0))}));return Zk=i}function hA(){if(nC)return eC;nC=1;var t=function(){if(tC)return Jk;tC=1;var t=IT();return Jk=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=OE();return eC=function(n){return null==n?[]:t(n,e(n))}}function dA(){if(iC)return rC;var t;iC=1;try{t={clone:dT(),constant:fT(),each:xT(),filter:UT(),has:$T(),isArray:Rw(),isEmpty:qT(),isFunction:mw(),isUndefined:YT(),keys:OE(),map:XT(),reduce:ZT(),size:JT(),transform:tA(),union:lA(),values:hA()}}catch(t){}return t||(t=window._),rC=t}function fA(){if(aC)return oC;aC=1;var t=dA();oC=i;var e="\0",n="\0",r="";function i(e){this._isDirected=!t.has(e,"directed")||e.directed,this._isMultigraph=!!t.has(e,"multigraph")&&e.multigraph,this._isCompound=!!t.has(e,"compound")&&e.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function o(t,e){t[e]?t[e]++:t[e]=1}function a(t,e){--t[e]||delete t[e]}function s(n,i,o,a){var s=""+i,u=""+o;if(!n&&s>u){var c=s;s=u,u=c}return s+r+u+r+(t.isUndefined(a)?e:a)}function u(t,e){return s(t,e.v,e.w,e.name)}return i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(t){return this._label=t,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return t.keys(this._nodes)},i.prototype.sources=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._in[n])}))},i.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._out[n])}))},i.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,(function(t){r.length>1?i.setNode(t,n):i.setNode(t)})),this},i.prototype.setNode=function(e,r){return t.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=r),this):(this._nodes[e]=arguments.length>1?r:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=n,this._children[e]={},this._children[n][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},i.prototype.node=function(t){return this._nodes[t]},i.prototype.hasNode=function(e){return t.has(this._nodes,e)},i.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),(function(t){n.setParent(t)})),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},i.prototype.setParent=function(e,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=n;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===e)throw new Error("Setting "+r+" as parent of "+e+" would create a cycle");this.setNode(r)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=r,this._children[r][e]=!0,this},i.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},i.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==n)return e}},i.prototype.children=function(e){if(t.isUndefined(e)&&(e=n),this._isCompound){var r=this._children[e];if(r)return t.keys(r)}else{if(e===n)return this.nodes();if(this.hasNode(e))return[]}},i.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},i.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},i.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},i.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},i.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,(function(t,r){e(r)&&n.setNode(r,t)})),t.each(this._edgeObjs,(function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))}));var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),(function(t){n.setParent(t,o(t))})),n},i.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return t.values(this._edgeObjs)},i.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,(function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e})),this},i.prototype.setEdge=function(){var e,n,r,i,a=!1,u=arguments[0];"object"==typeof u&&null!==u&&"v"in u?(e=u.v,n=u.w,r=u.name,2===arguments.length&&(i=arguments[1],a=!0)):(e=u,n=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),e=""+e,n=""+n,t.isUndefined(r)||(r=""+r);var c=s(this._isDirected,e,n,r);if(t.has(this._edgeLabels,c))return a&&(this._edgeLabels[c]=i),this;if(!t.isUndefined(r)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[c]=a?i:this._defaultEdgeLabelFn(e,n,r);var l=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var a=i;i=o,o=a}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,r);return e=l.v,n=l.w,Object.freeze(l),this._edgeObjs[c]=l,o(this._preds[n],e),o(this._sucs[e],n),this._in[n][c]=l,this._out[e][c]=l,this._edgeCount++,this},i.prototype.edge=function(t,e,n){var r=1===arguments.length?u(this._isDirected,arguments[0]):s(this._isDirected,t,e,n);return this._edgeLabels[r]},i.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?u(this._isDirected,arguments[0]):s(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},i.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?u(this._isDirected,arguments[0]):s(this._isDirected,t,e,n),i=this._edgeObjs[r];return i&&(t=i.v,e=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],a(this._preds[e],t),a(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},i.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.v===n})):i}},i.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.w===n})):i}},i.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},oC}function pA(){return lC?cC:(lC=1,cC={Graph:fA(),version:uC?sC:(uC=1,sC="2.1.8")})}function gA(){if(dC)return hC;dC=1;var t=dA(),e=fA();function n(e){return t.map(e.nodes(),(function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o}))}function r(e){return t.map(e.edges(),(function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i}))}return hC={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,(function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)})),t.each(n.edges,(function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),r}}}function mA(){if(pC)return fC;pC=1;var t=dA();return fC=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),(function(t){n=[],o(t),n.length&&i.push(n)})),i},fC}function yA(){if(mC)return gC;mC=1;var t=dA();function e(){this._arr=[],this._keyIndices={}}return gC=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},gC}function vA(){if(vC)return yC;vC=1;var t=dA(),e=yA();yC=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},u=new e,c=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),c=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);c<n.distance&&(n.distance=c,n.predecessor=o,u.decrease(e,c))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},u.add(t,e)}));for(;u.size()>0&&(o=u.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(c);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return yC}function bA(){if(xC)return bC;xC=1;var t=vA(),e=dA();return bC=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function xA(){if(EC)return wC;EC=1;var t=dA();return wC=function(e){var n=0,r=[],i={},o=[];function a(s){var u=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach((function(e){t.has(i,e)?i[e].onStack&&(u.lowlink=Math.min(u.lowlink,i[e].index)):(a(e),u.lowlink=Math.min(u.lowlink,i[e].lowlink))})),u.lowlink===u.index){var c,l=[];do{c=r.pop(),i[c].onStack=!1,l.push(c)}while(s!==c);o.push(l)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},wC}function wA(){if(SC)return MC;SC=1;var t=dA(),e=xA();return MC=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function EA(){if(kC)return NC;kC=1;var t=dA();NC=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach((function(t){r[t]={},r[t][t]={distance:0},i.forEach((function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})})),n(t).forEach((function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}}))})),i.forEach((function(t){var e=r[t];i.forEach((function(n){var o=r[n];i.forEach((function(n){var r=o[t],i=e[n],a=o[n],s=r.distance+i.distance;s<a.distance&&(a.distance=s,a.predecessor=i.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return NC}function MA(){if(TC)return CC;TC=1;var t=dA();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),(function a(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),a),delete i[s],o.push(s))})),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return CC=e,e.CycleException=n,n.prototype=new Error,CC}function SA(){if(PC)return AC;PC=1;var t=MA();return AC=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function NA(){if(_C)return OC;_C=1;var t=dA();function e(n,r,i,o,a,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(a(r),(function(t){e(n,t,i,o,a,s)})),i&&s.push(r))}return OC=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],s={};return t.each(r,(function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,a)})),a},OC}function kA(){if(IC)return RC;IC=1;var t=NA();return RC=function(e,n){return t(e,n,"post")}}function CA(){if(LC)return DC;LC=1;var t=NA();return DC=function(e,n){return t(e,n,"pre")}}function TA(){if(BC)return jC;BC=1;var t=dA(),e=fA(),n=yA();return jC=function(r,i){var o,a=new e,s={},u=new n;function c(t){var e=t.v===o?t.w:t.v,n=u.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,u.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){u.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),u.decrease(r.nodes()[0],0);var l=!1;for(;u.size()>0;){if(o=u.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(l)throw new Error("Input graph is not connected: "+r);l=!0}r.nodeEdges(o).forEach(c)}return a}}HC.exports;try{WC=function(){if(VC)return GC;VC=1;var t=pA();return GC={Graph:t.Graph,json:gA(),alg:FC?zC:(FC=1,zC={components:mA(),dijkstra:vA(),dijkstraAll:bA(),findCycles:wA(),floydWarshall:EA(),isAcyclic:SA(),postorder:kA(),preorder:CA(),prim:TA(),tarjan:xA(),topsort:MA()}),version:t.version}}()}catch(t){}WC||(WC=window.graphlib);var AA,PA,OA,_A,RA,IA,DA,LA,jA,BA,zA,FA,GA,VA,WA,HA,UA,$A,qA,YA,KA,XA,ZA,QA,JA,tP,eP,nP,rP,iP,oP,aP,sP,uP,cP,lP,hP,dP,fP,pP,gP,mP,yP,vP,bP,xP,wP,EP,MP,SP,NP,kP,CP,TP,AP,PP,OP,_P,RP,IP,DP,LP,jP,BP,zP,FP,GP,VP,WP,HP,UP,$P,qP,YP,KP,XP,ZP,QP,JP,tO,eO,nO,rO,iO,oO,aO,sO,uO,cO,lO,hO,dO,fO,pO=WC;function gO(){if(_A)return OA;_A=1;var t=uw(),e=PE(),n=qw(),r=gw();return OA=function(i,o,a){if(!r(a))return!1;var s=typeof o;return!!("number"==s?e(a)&&n(o,a.length):"string"==s&&o in a)&&t(a[o],i)},OA}function mO(){if(FA)return zA;FA=1;var t=function(){if(BA)return jA;BA=1;var t=/\s/;return jA=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},jA}(),e=/^\s+/;return zA=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function yO(){if(HA)return WA;HA=1;var t=function(){if(VA)return GA;VA=1;var t=mO(),e=gw(),n=OT(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return GA=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var u="function"==typeof s.valueOf?s.valueOf():s;s=e(u)?u+"":u}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var c=i.test(s);return c||o.test(s)?a(s.slice(2),c?2:8):r.test(s)?NaN:+s}}(),e=1/0;return WA=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function vO(){if(YA)return qA;YA=1;var t=oA(),e=HT(),n=function(){if($A)return UA;$A=1;var t=yO();return UA=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return qA=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var u=null==a?0:n(a);return u<0&&(u=r(s+u,0)),t(i,e(o,3),u)},qA}function bO(){if(QA)return ZA;QA=1;var t=eA();return ZA=function(e){return(null==e?0:e.length)?t(e,1):[]}}function xO(){if(aP)return oP;aP=1;var t=OT();return oP=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=n(a);if(null!=s&&(void 0===u?s==s&&!t(s):r(s,u)))var u=s,c=a}return c},oP}function wO(){if(dP)return hP;dP=1;var t=Tw(),e=uw();return hP=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function EO(){if(mP)return gP;return mP=1,gP=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function MO(){if(xP)return bP;xP=1;var t=wO(),e=UC(),n=oT(),r=$C(),i=uT(),o=_w(),a=Rw(),s=cA(),u=$w(),c=mw(),l=gw(),h=function(){if(pP)return fP;pP=1;var t=pw(),e=ZC(),n=Ow(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return fP=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var u=a.call(i,"constructor")&&i.constructor;return"function"==typeof u&&u instanceof u&&o.call(u)==s}}(),d=NE(),f=EO(),p=function(){if(vP)return yP;vP=1;var t=Pw(),e=RE();return yP=function(n){return t(n,e(n))}}();return bP=function(g,m,y,v,b,x,w){var E=f(g,y),M=f(m,y),S=w.get(M);if(S)t(g,y,S);else{var N=x?x(E,M,y+"",g,m,w):void 0,k=void 0===N;if(k){var C=a(M),T=!C&&u(M),A=!C&&!T&&d(M);N=M,C||T||A?a(E)?N=E:s(E)?N=r(E):T?(k=!1,N=e(M,!0)):A?(k=!1,N=n(M,!0)):N=[]:h(M)||o(M)?(N=E,o(E)?N=p(E):l(E)&&!c(E)||(N=i(M))):k=!1}k&&(w.set(M,N),b(N,M,v,x,w),w.delete(M)),t(g,y,N)}}}function SO(){if(TP)return CP;return TP=1,CP=function(t,e){return t<e}}function NO(){if(BP)return jP;BP=1;var t=BT(),e=function(){if(LP)return DP;LP=1;var t=Aw(),e=LT(),n=qw(),r=gw(),i=jT();return DP=function(o,a,s,u){if(!r(o))return o;for(var c=-1,l=(a=e(a,o)).length,h=l-1,d=o;null!=d&&++c<l;){var f=i(a[c]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(c!=h){var g=d[f];void 0===(p=u?u(g,f,d):void 0)&&(p=r(g)?g:n(a[c+1])?[]:{})}t(d,f,p),d=d[f]}return o},DP}(),n=LT();return jP=function(r,i,o){for(var a=-1,s=i.length,u={};++a<s;){var c=i[a],l=t(r,c);o(l,c)&&e(u,n(c,r),l)}return u},jP}function kO(){if(YP)return qP;YP=1;var t=function(){if($P)return UP;$P=1;var t=Math.ceil,e=Math.max;return UP=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),u=Array(s);s--;)u[o?s:++a]=n,n+=i;return u},UP}(),e=gO(),n=yO();return qP=function(r){return function(i,o,a){return a&&"number"!=typeof a&&e(i,o,a)&&(o=a=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),a=void 0===a?i<o?1:-1:n(a),t(i,o,a,r)}},qP}function CO(){if(nO)return eO;nO=1;var t=function(){if(tO)return JP;tO=1;var t=OT();return JP=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,u=null===n,c=n==n,l=t(n);if(!u&&!l&&!a&&e>n||a&&s&&c&&!u&&!l||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!l&&e<n||l&&r&&o&&!i&&!a||u&&r&&o||!s&&o||!c)return-1}return 0}}();return eO=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,u=r.length;++i<s;){var c=t(o[i],a[i]);if(c)return i>=u?c:c*("desc"==r[i]?-1:1)}return e.index-n.index},eO}function TO(){if(iO)return rO;iO=1;var t=IT(),e=BT(),n=HT(),r=KT(),i=(QP||(QP=1,ZP=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),ZP),o=Kw(),a=CO(),s=yT(),u=Rw();return rO=function(c,l,h){l=l.length?t(l,(function(t){return u(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;l=t(l,o(n));var f=r(c,(function(e,n,r){return{criteria:t(l,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},rO}try{fO={cloneDeep:function(){if(PA)return AA;PA=1;var t=hT();return AA=function(e){return t(e,5)}}(),constant:fT(),defaults:function(){if(IA)return RA;IA=1;var t=iA(),e=uw(),n=gO(),r=RE(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,u=a.length,c=u>2?a[2]:void 0;for(c&&n(a[0],a[1],c)&&(u=1);++s<u;)for(var l=a[s],h=r(l),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=l[p])}return t}));return RA=a}(),each:xT(),filter:UT(),find:function(){if(XA)return KA;XA=1;var t=function(){if(LA)return DA;LA=1;var t=HT(),e=PE(),n=OE();return DA=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var u=t(o,3);i=n(i),o=function(t){return u(s[t],t,s)}}var c=r(i,o,a);return c>-1?s[u?i[c]:c]:void 0}},DA}(),e=t(vO());return KA=e}(),flatten:bO(),forEach:bT(),forIn:function(){if(tP)return JA;tP=1;var t=pT(),e=vT(),n=RE();return JA=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:$T(),isUndefined:YT(),last:(nP||(nP=1,eP=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),eP),map:XT(),mapValues:function(){if(iP)return rP;iP=1;var t=Tw(),e=gT(),n=HT();return rP=function(r,i){var o={};return i=n(i,3),e(r,(function(e,n,r){t(o,n,i(e,n,r))})),o}}(),max:function(){if(lP)return cP;lP=1;var t=xO(),e=uP?sP:(uP=1,sP=function(t,e){return t>e}),n=yT();return cP=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(kP)return NP;kP=1;var t=function(){if(EP)return wP;EP=1;var t=Nw(),e=wO(),n=pT(),r=MO(),i=gw(),o=RE(),a=EO();return wP=function s(u,c,l,h,d){u!==c&&n(c,(function(n,o){if(d||(d=new t),i(n))r(u,c,o,l,s,h,d);else{var f=h?h(a(u,o),n,o+"",u,c,d):void 0;void 0===f&&(f=n),e(u,o,f)}}),o)},wP}(),e=function(){if(SP)return MP;SP=1;var t=iA(),e=gO();return MP=function(n){return t((function(t,r){var i=-1,o=r.length,a=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(a=n.length>3&&"function"==typeof a?(o--,a):void 0,s&&e(r[0],r[1],s)&&(a=o<3?void 0:a,o=1),t=Object(t);++i<o;){var u=r[i];u&&n(t,u,i,a)}return t}))},MP}(),n=e((function(e,n,r){t(e,n,r)}));return NP=n}(),min:function(){if(PP)return AP;PP=1;var t=xO(),e=SO(),n=yT();return AP=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(_P)return OP;_P=1;var t=xO(),e=HT(),n=SO();return OP=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(IP)return RP;IP=1;var t=dw();return RP=function(){return t.Date.now()}}(),pick:function(){if(HP)return WP;HP=1;var t=function(){if(FP)return zP;FP=1;var t=NO(),e=FT();return zP=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(VP)return GP;VP=1;var t=bO(),e=nA(),n=rA();return GP=function(r){return n(e(r,void 0,t),r+"")}}()((function(e,n){return null==e?{}:t(e,n)}));return WP=e}(),range:function(){if(XP)return KP;XP=1;var t=kO()();return KP=t}(),reduce:ZT(),sortBy:function(){if(aO)return oO;aO=1;var t=eA(),e=TO(),n=iA(),r=gO(),i=n((function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])}));return oO=i}(),uniqueId:function(){if(uO)return sO;uO=1;var t=DT(),e=0;return sO=function(n){var r=++e;return t(n)+r},sO}(),values:hA(),zipObject:function(){if(dO)return hO;dO=1;var t=Aw(),e=(lO||(lO=1,cO=function(t,e,n){for(var r=-1,i=t.length,o=e.length,a={};++r<i;){var s=r<o?e[r]:void 0;n(a,t[r],s)}return a}),cO);return hO=function(n,r){return e(n||[],r||[],t)}}()}}catch(t){}fO||(fO=window._);var AO=fO,PO=OO;function OO(){var t={};t._next=t._prev=t,this._sentinel=t}function _O(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function RO(t,e){if("_next"!==t&&"_prev"!==t)return e}OO.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return _O(e),e},OO.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&_O(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},OO.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,RO)),n=n._prev;return"["+t.join(", ")+"]"};var IO=AO,DO=pO.Graph,LO=PO,jO=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new DO,r=0,i=0;IO.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),IO.forEach(t.edges(),(function(t){var o=n.edge(t.v,t.w)||0,a=e(t),s=o+a;n.setEdge(t.v,t.w,s),i=Math.max(i,n.node(t.v).out+=a),r=Math.max(r,n.node(t.w).in+=a)}));var o=IO.range(i+r+3).map((function(){return new LO})),a=r+1;return IO.forEach(n.nodes(),(function(t){FO(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||BO),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)zO(t,e,n,r);for(;r=o.dequeue();)zO(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(zO(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return IO.flatten(IO.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},BO=IO.constant(1);function zO(t,e,n,r,i){var o=i?[]:void 0;return IO.forEach(t.inEdges(r.v),(function(r){var a=t.edge(r),s=t.node(r.v);i&&o.push({v:r.v,w:r.w}),s.out-=a,FO(e,n,s)})),IO.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,FO(e,n,a)})),t.removeNode(r.v),o}function FO(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}var GO=AO,VO=jO,WO={run:function(t){var e="greedy"===t.graph().acyclicer?VO(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){GO.has(r,o)||(r[o]=!0,n[o]=!0,GO.forEach(t.outEdges(o),(function(t){GO.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return GO.forEach(t.nodes(),i),e}(t);GO.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,GO.uniqueId("rev"))}))},undo:function(t){GO.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}}))}};var HO=AO,UO=pO.Graph,$O={addDummyNode:qO,simplify:function(t){var e=(new UO).setGraph(t.graph());return HO.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),HO.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new UO({multigraph:t.isMultigraph()}).setGraph(t.graph());return HO.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),HO.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=HO.map(t.nodes(),(function(e){var n={};return HO.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return HO.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=HO.map(t.nodes(),(function(e){var n={};return HO.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return HO.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,a=e.x-i,s=e.y-o,u=t.width/2,c=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*u>Math.abs(a)*c?(s<0&&(c=-c),n=c*a/s,r=c):(a<0&&(u=-u),n=u,r=u*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=HO.map(HO.range(YO(t)+1),(function(){return[]}));return HO.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;HO.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=HO.min(HO.map(t.nodes(),(function(e){return t.node(e).rank})));HO.forEach(t.nodes(),(function(n){var r=t.node(n);HO.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=HO.min(HO.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];HO.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var r=0,i=t.graph().nodeRankFactor;HO.forEach(n,(function(e,n){HO.isUndefined(e)&&n%i!=0?--r:r&&HO.forEach(e,(function(e){t.node(e).rank+=r}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return qO(t,"border",i,e)},maxRank:YO,partition:function(t,e){var n={lhs:[],rhs:[]};return HO.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=HO.now();try{return e()}finally{console.log(t+" time: "+(HO.now()-n)+"ms")}},notime:function(t,e){return e()}};function qO(t,e,n,r){var i;do{i=HO.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function YO(t){return HO.max(HO.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!HO.isUndefined(n))return n})))}var KO=AO,XO=$O,ZO={run:function(t){t.graph().dummyChains=[],KO.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,u=t.node(s).rank,c=e.name,l=t.edge(e),h=l.labelRank;if(u===a+1)return;for(t.removeEdge(e),i=0,++a;a<u;++i,++a)l.points=[],r={width:0,height:0,edgeLabel:l,edgeObj:e,rank:a},n=XO.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=l.width,r.height=l.height,r.dummy="edge-label",r.labelpos=l.labelpos),t.setEdge(o,n,{weight:l.weight},c),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:l.weight},c)}(t,e)}))},undo:function(t){KO.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)}))}};var QO=AO,JO={longestPath:function(t){var e={};QO.forEach(t.sources(),(function n(r){var i=t.node(r);if(QO.has(e,r))return i.rank;e[r]=!0;var o=QO.min(QO.map(t.outEdges(r),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),i.rank=o}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var t_=AO,e_=pO.Graph,n_=JO.slack,r_=function(t){var e,n,r=new e_({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;i_(r,t)<o;)e=o_(r,t),n=r.hasNode(e.v)?n_(t,e):-n_(t,e),a_(r,t,n);return r};function i_(t,e){return t_.forEach(t.nodes(),(function n(r){t_.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||n_(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function o_(t,e){return t_.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return n_(e,n)}))}function a_(t,e,n){t_.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var s_=AO,u_=r_,c_=JO.slack,l_=JO.longestPath,h_=pO.alg.preorder,d_=pO.alg.postorder,f_=$O.simplify,p_=g_;function g_(t){t=f_(t),l_(t);var e,n=u_(t);for(v_(n),m_(n,t);e=x_(n);)E_(n,t,e,w_(n,t,e))}function m_(t,e){var n=d_(t,t.nodes());n=n.slice(0,n.length-1),s_.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=y_(t,e,n)}(t,e,n)}))}function y_(t,e,n){var r=t.node(n).parent,i=!0,o=e.edge(n,r),a=0;return o||(i=!1,o=e.edge(r,n)),a=o.weight,s_.forEach(e.nodeEdges(n),(function(o){var s,u,c=o.v===n,l=c?o.w:o.v;if(l!==r){var h=c===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,u=l,t.hasEdge(s,u)){var f=t.edge(n,l).cutvalue;a+=h?-f:f}}})),a}function v_(t,e){arguments.length<2&&(e=t.nodes()[0]),b_(t,{},1,e)}function b_(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,s_.forEach(t.neighbors(r),(function(i){s_.has(e,i)||(n=b_(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function x_(t){return s_.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function w_(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var o=t.node(r),a=t.node(i),s=o,u=!1;o.lim>a.lim&&(s=a,u=!0);var c=s_.filter(e.edges(),(function(e){return u===M_(t,t.node(e.v),s)&&u!==M_(t,t.node(e.w),s)}));return s_.minBy(c,(function(t){return c_(e,t)}))}function E_(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),v_(t),m_(t,e),function(t,e){var n=s_.find(t.nodes(),(function(t){return!e.node(t).parent})),r=h_(t,n);r=r.slice(1),s_.forEach(r,(function(n){var r=t.node(n).parent,i=e.edge(n,r),o=!1;i||(i=e.edge(r,n),o=!0),e.node(n).rank=e.node(r).rank+(o?i.minlen:-i.minlen)}))}(t,e)}function M_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}g_.initLowLimValues=v_,g_.initCutValues=m_,g_.calcCutValue=y_,g_.leaveEdge=x_,g_.enterEdge=w_,g_.exchangeEdges=E_;var S_=JO.longestPath,N_=r_,k_=p_,C_=function(t){switch(t.graph().ranker){case"network-simplex":default:A_(t);break;case"tight-tree":!function(t){S_(t),N_(t)}(t);break;case"longest-path":T_(t)}};var T_=S_;function A_(t){k_(t)}var P_=AO,O_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;P_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return P_.forEach(t.children(),r),e}(t);P_.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,o=function(t,e,n,r){var i,o,a=[],s=[],u=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>u||c>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:a.concat(s.reverse()),lca:o}}(t,e,i.v,i.w),a=o.path,s=o.lca,u=0,c=a[u],l=!0;n!==i.w;){if(r=t.node(n),l){for(;(c=a[u])!==s&&t.node(c).maxRank<r.rank;)u++;c===s&&(l=!1)}if(!l){for(;u<a.length-1&&t.node(c=a[u+1]).minRank<=r.rank;)u++;c=a[u]}t.setParent(n,c),n=t.successors(n)[0]}}))};var __=AO,R_=$O,I_={run:function(t){var e=R_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&__.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return __.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=__.max(__.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,__.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return __.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;__.forEach(t.children(),(function(a){D_(t,e,i,o,r,n,a)})),t.graph().nodeRankFactor=i},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,__.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function D_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var u=R_.addBorderNode(t,"_bt"),c=R_.addBorderNode(t,"_bb"),l=t.node(a);t.setParent(u,a),l.borderTop=u,t.setParent(c,a),l.borderBottom=c,__.forEach(s,(function(s){D_(t,e,n,r,i,o,s);var l=t.node(s),h=l.borderTop?l.borderTop:s,d=l.borderBottom?l.borderBottom:s,f=l.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(u,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,c,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,u,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var L_=AO,j_=$O,B_=function(t){L_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&L_.forEach(r,e),L_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)z_(t,"borderLeft","_bl",n,i,o),z_(t,"borderRight","_br",n,i,o)}}))};function z_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],u=j_.addDummyNode(t,"border",a,n);i[e][o]=u,t.setParent(u,r),s&&t.setEdge(s,u,{weight:1})}var F_=AO,G_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||V_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){F_.forEach(t.nodes(),(function(e){H_(t.node(e))})),F_.forEach(t.edges(),(function(e){var n=t.edge(e);F_.forEach(n.points,H_),F_.has(n,"y")&&H_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){F_.forEach(t.nodes(),(function(e){U_(t.node(e))})),F_.forEach(t.edges(),(function(e){var n=t.edge(e);F_.forEach(n.points,U_),F_.has(n,"x")&&U_(n)}))}(t),V_(t))}};function V_(t){F_.forEach(t.nodes(),(function(e){W_(t.node(e))})),F_.forEach(t.edges(),(function(e){W_(t.edge(e))}))}function W_(t){var e=t.width;t.width=t.height,t.height=e}function H_(t){t.y=-t.y}function U_(t){var e=t.x;t.x=t.y,t.y=e}var $_=AO,q_=function(t){var e={},n=$_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=$_.max($_.map(n,(function(e){return t.node(e).rank}))),i=$_.map($_.range(r+1),(function(){return[]}));function o(n){if(!$_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),$_.forEach(t.successors(n),o)}}var a=$_.sortBy(n,(function(e){return t.node(e).rank}));return $_.forEach(a,o),i};var Y_=AO,K_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=X_(t,e[r-1],e[r]);return n};function X_(t,e,n){for(var r=Y_.zipObject(n,Y_.map(n,(function(t,e){return e}))),i=Y_.flatten(Y_.map(e,(function(e){return Y_.sortBy(Y_.map(t.outEdges(e),(function(e){return{pos:r[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=Y_.map(new Array(a),(function(){return 0})),u=0;return Y_.forEach(i.forEach((function(t){var e=t.pos+o;s[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=s[e+1]),s[e=e-1>>1]+=t.weight;u+=t.weight*n}))),u}var Z_=AO;var Q_=AO,J_=function(t,e){var n={};return Q_.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};Q_.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),Q_.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];Q_.isUndefined(e)||Q_.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(Q_.isUndefined(e.barycenter)||Q_.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function r(e){return function(n){n.in.push(e),0==--n.indegree&&t.push(n)}}for(;t.length;){var i=t.pop();e.push(i),Q_.forEach(i.in.reverse(),n(i)),Q_.forEach(i.out,r(i))}return Q_.map(Q_.filter(e,(function(t){return!t.merged})),(function(t){return Q_.pick(t,["vs","i","barycenter","weight"])}))}(Q_.filter(n,(function(t){return!t.indegree})))};var tR=AO,eR=$O;function nR(t,e,n){for(var r;e.length&&(r=tR.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var rR=AO,iR=function(t,e){return Z_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=Z_.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}}))},oR=J_,aR=function(t,e){var n=eR.partition(t,(function(t){return tR.has(t,"barycenter")})),r=n.lhs,i=tR.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,u=0;r.sort((c=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:c?e.i-t.i:t.i-e.i})),u=nR(o,i,u),tR.forEach(r,(function(t){u+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,u=nR(o,i,u)}));var c;var l={vs:tR.flatten(o,!0)};s&&(l.barycenter=a/s,l.weight=s);return l},sR=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,u=a?a.borderRight:void 0,c={};s&&(o=rR.filter(o,(function(t){return t!==s&&t!==u})));var l=iR(e,o);rR.forEach(l,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);c[n.v]=o,rR.has(o,"barycenter")&&(a=n,s=o,rR.isUndefined(a.barycenter)?(a.barycenter=s.barycenter,a.weight=s.weight):(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight))}var a,s}));var h=oR(l,r);!function(t,e){rR.forEach(t,(function(t){t.vs=rR.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,c);var d=aR(h,i);if(s&&(d.vs=rR.flatten([s,d.vs,u],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(u)[0]);rR.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var uR=AO,cR=pO.Graph,lR=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=uR.uniqueId("_root")););return e}(t),i=new cR({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return uR.forEach(t.nodes(),(function(o){var a=t.node(o),s=t.parent(o);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),uR.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=uR.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),uR.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var hR=AO;var dR=AO,fR=q_,pR=K_,gR=sR,mR=lR,yR=function(t,e,n){var r,i={};hR.forEach(n,(function(n){for(var o,a,s=t.parent(n);s;){if((o=t.parent(s))?(a=i[o],i[o]=s):(a=r,r=s),a&&a!==s)return void e.setEdge(a,s);s=o}}))},vR=pO.Graph,bR=$O,xR=function(t){var e=bR.maxRank(t),n=wR(t,dR.range(1,e+1),"inEdges"),r=wR(t,dR.range(e-1,-1,-1),"outEdges"),i=fR(t);MR(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,u=0;u<4;++s,++u){ER(s%2?n:r,s%4>=2),i=bR.buildLayerMatrix(t);var c=pR(t,i);c<a&&(u=0,o=dR.cloneDeep(i),a=c)}MR(t,o)};function wR(t,e,n){return dR.map(e,(function(e){return mR(t,e,n)}))}function ER(t,e){var n=new vR;dR.forEach(t,(function(t){var r=t.graph().root,i=gR(t,r,n,e);dR.forEach(i.vs,(function(e,n){t.node(e).order=n})),yR(t,n,i.vs)}))}function MR(t,e){dR.forEach(e,(function(e){dR.forEach(e,(function(e,n){t.node(e).order=n}))}))}var SR=AO,NR=pO.Graph,kR=$O,CR=function(t){var e,n=kR.buildLayerMatrix(t),r=SR.merge(TR(t,n),AR(t,n)),i={};SR.forEach(["u","d"],(function(o){e="u"===o?n:SR.values(n).reverse(),SR.forEach(["l","r"],(function(n){"r"===n&&(e=SR.map(e,(function(t){return SR.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=_R(t,e,r,a),u=RR(t,e,s.root,s.align,"r"===n);"r"===n&&(u=SR.mapValues(u,(function(t){return-t}))),i[o+n]=u}))}));var o=IR(t,i);return DR(i,o),LR(i,t.graph().align)};function TR(t,e){var n={};return SR.reduce(e,(function(e,r){var i=0,o=0,a=e.length,s=SR.last(r);return SR.forEach(r,(function(e,u){var c=function(t,e){if(t.node(e).dummy)return SR.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),l=c?t.node(c).order:a;(c||e===s)&&(SR.forEach(r.slice(o,u+1),(function(e){SR.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||l<a)||o.dummy&&t.node(e).dummy||PR(n,r,e)}))})),o=u+1,i=l)})),r})),n}function AR(t,e){var n={};function r(e,r,i,o,a){var s;SR.forEach(SR.range(r,i),(function(r){s=e[r],t.node(s).dummy&&SR.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&PR(n,e,s)}))}))}return SR.reduce(e,(function(e,n){var i,o=-1,a=0;return SR.forEach(n,(function(s,u){if("border"===t.node(s).dummy){var c=t.predecessors(s);c.length&&(i=t.node(c[0]).order,r(n,a,u,o,i),a=u,o=i)}r(n,a,n.length,i,e.length)})),n})),n}function PR(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function OR(t,e,n){if(e>n){var r=e;e=n,n=r}return SR.has(t[e],n)}function _R(t,e,n,r){var i={},o={},a={};return SR.forEach(e,(function(t){SR.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),SR.forEach(e,(function(t){var e=-1;SR.forEach(t,(function(t){var s=r(t);if(s.length){s=SR.sortBy(s,(function(t){return a[t]}));for(var u=(s.length-1)/2,c=Math.floor(u),l=Math.ceil(u);c<=l;++c){var h=s[c];o[t]===t&&e<a[h]&&!OR(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}function RR(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new NR,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),u=r.node(o),c=0;if(c+=s.width/2,SR.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(c+=n?a:-a),a=0,c+=(s.dummy?e:t)/2,c+=(u.dummy?e:t)/2,c+=u.width/2,SR.has(u,"labelpos"))switch(u.labelpos.toLowerCase()){case"l":a=u.width/2;break;case"r":a=-u.width/2}return a&&(c+=n?a:-a),a=0,c}}(o.nodesep,o.edgesep,r);return SR.forEach(e,(function(e){var r;SR.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],u=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),u||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function u(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}return u((function(t){o[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,o[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),u((function(e){var n=a.outEdges(e).reduce((function(t,e){return Math.min(t,o[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==s&&(o[e]=Math.max(o[e],n))}),a.successors.bind(a)),SR.forEach(r,(function(t){o[t]=o[n[t]]})),o}function IR(t,e){return SR.minBy(SR.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return SR.forIn(e,(function(e,i){var o=function(t,e){return t.node(e).width}(t,i)/2;n=Math.max(e+o,n),r=Math.min(e-o,r)})),n-r}))}function DR(t,e){var n=SR.values(e),r=SR.min(n),i=SR.max(n);SR.forEach(["u","d"],(function(n){SR.forEach(["l","r"],(function(o){var a,s=n+o,u=t[s];if(u!==e){var c=SR.values(u);(a="l"===o?r-SR.min(c):i-SR.max(c))&&(t[s]=SR.mapValues(u,(function(t){return t+a})))}}))}))}function LR(t,e){return SR.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=SR.sortBy(SR.map(t,r));return(i[1]+i[2])/2}))}var jR=AO,BR=$O,zR=CR,FR=function(t){(function(t){var e=BR.buildLayerMatrix(t),n=t.graph().ranksep,r=0;jR.forEach(e,(function(e){var i=jR.max(jR.map(e,(function(e){return t.node(e).height})));jR.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=BR.asNonCompoundGraph(t)),jR.forEach(zR(t),(function(e,n){t.node(n).x=e}))};var GR=AO,VR=WO,WR=ZO,HR=C_,UR=$O.normalizeRanks,$R=O_,qR=$O.removeEmptyRanks,YR=I_,KR=B_,XR=G_,ZR=xR,QR=FR,JR=$O,tI=pO.Graph,eI=function(t,e){var n=e&&e.debugTiming?JR.time:JR.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new tI({multigraph:!0,compound:!0}),n=hI(t.graph());return e.setGraph(GR.merge({},rI,lI(n,nI),GR.pick(n,iI))),GR.forEach(t.nodes(),(function(n){var r=hI(t.node(n));e.setNode(n,GR.defaults(lI(r,oI),aI)),e.setParent(n,t.parent(n))})),GR.forEach(t.edges(),(function(n){var r=hI(t.edge(n));e.setEdge(n,GR.merge({},uI,lI(r,sI),GR.pick(r,cI)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,GR.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){GR.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){VR.run(t)})),e(" nestingGraph.run",(function(){YR.run(t)})),e(" rank",(function(){HR(JR.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){GR.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};JR.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){qR(t)})),e(" nestingGraph.cleanup",(function(){YR.cleanup(t)})),e(" normalizeRanks",(function(){UR(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;GR.forEach(t.nodes(),(function(n){var r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=GR.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){GR.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){WR.run(t)})),e(" parentDummyChains",(function(){$R(t)})),e(" addBorderSegments",(function(){KR(t)})),e(" order",(function(){ZR(t)})),e(" insertSelfEdges",(function(){!function(t){var e=JR.buildLayerMatrix(t);GR.forEach(e,(function(e){var n=0;GR.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,GR.forEach(i.selfEdges,(function(e){JR.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){XR.adjust(t)})),e(" position",(function(){QR(t)})),e(" positionSelfEdges",(function(){!function(t){GR.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){GR.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),o=t.node(GR.last(n.borderLeft)),a=t.node(GR.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}})),GR.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){WR.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){GR.forEach(t.edges(),(function(e){var n=t.edge(e);if(GR.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){XR.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=t.graph(),a=o.marginx||0,s=o.marginy||0;function u(t){var o=t.x,a=t.y,s=t.width,u=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-u/2),i=Math.max(i,a+u/2)}GR.forEach(t.nodes(),(function(e){u(t.node(e))})),GR.forEach(t.edges(),(function(e){var n=t.edge(e);GR.has(n,"x")&&u(n)})),e-=a,r-=s,GR.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),GR.forEach(t.edges(),(function(n){var i=t.edge(n);GR.forEach(i.points,(function(t){t.x-=e,t.y-=r})),GR.has(i,"x")&&(i.x-=e),GR.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){GR.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),o=t.node(e.v),a=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=a,r=o),i.points.unshift(JR.intersectRect(o,n)),i.points.push(JR.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){GR.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){VR.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){GR.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height))})),GR.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,GR.has(i,"x")&&(r.x=i.x,r.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var nI=["nodesep","edgesep","ranksep","marginx","marginy"],rI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},iI=["acyclicer","ranker","rankdir","align"],oI=["width","height"],aI={width:0,height:0},sI=["minlen","weight","width","height","labeloffset"],uI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},cI=["labelpos"];function lI(t,e){return GR.mapValues(GR.pick(t,e),Number)}function hI(t){var e={};return GR.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var dI=AO,fI=$O,pI=pO.Graph,gI={debugOrdering:function(t){var e=fI.buildLayerMatrix(t),n=new pI({compound:!0,multigraph:!0}).setGraph({});return dI.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),dI.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),dI.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),dI.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var mI={graphlib:pO,layout:eI,debug:gI,util:{time:$O.time,notime:$O.notime},version:"0.8.5"},yI=f(mI);class vI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,vI.defaultOptions,t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return a(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new mI.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>$t(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach((t=>{const{id:e}=t,n=Object.assign({},t.data);if(void 0!==r){const[e,i]=function(t){if(!t)return[0,0,0];if($t(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}(Ot(r)?r(t):r);Object.assign(n,{width:e,height:i})}i.setNode(e.toString(),n)})),e.getAllEdges().forEach((({id:t,source:e,target:n})=>{i.setEdge(e.toString(),n.toString(),{id:t})})),yI.layout(i);const a={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);a.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:s}=r,u=o(r,["id"]),{v:c,w:l}=n;a.edges.push({id:s,source:c,target:l,data:u}),t&&e.mergeEdgeData(s,u)})),a}))}}vI.defaultOptions={};class bI{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new bI({rx:n,ry:r,mass:e,degree:i})}}class xI{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new xI({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new xI({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new xI({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new xI({xmid:t,ymid:e,length:n})}}class wI{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new wI(this.quad.NW()),this.NE=new wI(this.quad.NE()),this.SW=new wI(this.quad.SW()),this.SE=new wI(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const EI={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class MI{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},EI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return a(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:u,maxIteration:c,nodeSize:l,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return im(e,t,h);const d=i.map((t=>Zg(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Rd({nodes:d,edges:f}),g=this.getSizes(p,e,l);if(this.run(p,e,c,g,t,o),u){for(let t=0;t<f.length;t+=1){const{source:e,target:n}=f[t],r=p.getDegree(e),i=p.getDegree(e);if(r<=1){const t=p.getNode(n);p.mergeNodeData(e,{x:t.data.x,y:t.data.y})}else if(i<=1){const t=p.getNode(e);p.mergeNodeData(n,{x:t.data.x,y:t.data.y})}}const n=Object.assign(Object.assign({},o),{prune:!1,barnesHut:!1});this.run(p,e,100,g,t,n)}return{nodes:d,edges:r}}))}getSizes(t,e,n){const r=t.getAllNodes(),i={};for(let t=0;t<r.length;t+=1){const{id:o,data:a}=r[t];if(i[o]=10,$t(a.size))i[o]=a.size;else if(Ug(a.size))isNaN(a.size[0])||(i[o]=Math.max(a.size[0])),isNaN(a.size[1])||(i[o]=Math.max(a.size[1]));else if(Lt(a.size))i[o]=Math.max(a.size.width,a.size.height);else if(Ot(n)){const t=n(e.getNode(o));Ug(t)?i[o]=Math.max(...t):i[o]=t}else Ug(n)?i[o]=Math.max(...n):$t(n)&&(i[o]=n)}return i}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:u,kr:c,kg:l}=n;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===s&&e>100&&(n.prune=!0),0!==u||s?0===u&&s&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),c||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),l||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:u}=o,c=t.getAllNodes();let l=0,h=n;const d={},f={},p={};for(let e=0;e<c.length;e+=1){const{data:n,id:r}=c[e];if(d[r]=[0,0],s){const i={id:e,rx:n.x,ry:n.y,mass:1,g:a,degree:t.getDegree(r)};p[r]=new bI(i)}}for(;h>0;)l=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:l,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==u||u({nodes:c,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:u,sizes:c}=e;let{forces:l}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...l[e]],l[e]=[0,0]}return l=this.getAttrForces(t,r,i,c,l,n),l=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,l,u,n):this.getRepGraForces(t,r,i,l,o,c,n),this.updatePos(t,l,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:u,prune:c}=o,l=t.getAllEdges();for(let o=0;o<l.length;o+=1){const{source:h,target:d}=l[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),m=t.getDegree(d);if(c&&(g<=1||m<=1))continue;const y=[p.data.x-f.data.x,p.data.y-f.data.y];let v=Math.hypot(y[0],y[1]);v=v<1e-4?1e-4:v,y[0]=y[0]/v,y[1]=y[1]/v,a&&e<n&&(v=v-r[h]-r[d]);let b=v,x=b;"linlog"===u&&(b=Math.log(1+v),x=b),s&&(b=v/g,x=v/m),a&&e<n&&v<=0?(b=0,x=0):a&&e<n&&v>0&&(b=v,x=v),i[h][0]+=b*y[0],i[d][0]-=x*y[0],i[h][1]+=b*y[1],i[d][1]-=x*y[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),u=s.length;let c=9e10,l=-9e10,h=9e10,d=-9e10;for(let e=0;e<u;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=l&&(l=i.x),i.x<=c&&(c=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(l-c,d-h),p=new xI({xmid:(l+c)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:u}),g=new wI(p);for(let e=0;e<u;e+=1){const{id:r}=s[e];a&&t.getDegree(r)<=1||n[r].in(p)&&g.insert(n[r])}for(let r=0;r<u;r+=1){const{id:u,data:c}=s[r],l=t.getDegree(u);if(a&&l<=1)continue;n[u].resetForce(),g.updateForce(n[u]),e[u][0]-=n[u].fx,e[u][1]-=n[u].fy;const h=[c.x-o[0],c.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(l+1);e[u][0]-=f*h[0],e[u][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:u,kg:c,center:l,prune:h}=a,d=t.getAllNodes(),f=d.length;for(let a=0;a<f;a+=1){const p=d[a],g=t.getDegree(p.id);for(let c=a+1;c<f;c+=1){const a=d[c],l=t.getDegree(a.id);if(h&&(g<=1||l<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let m=Math.hypot(f[0],f[1]);m=m<1e-4?1e-4:m,f[0]=f[0]/m,f[1]=f[1]/m,s&&e<n&&(m=m-o[p.id]-o[a.id]);let y=u*(g+1)*(l+1)/m;s&&e<n&&m<0?y=i*(g+1)*(l+1):s&&e<n&&0===m?y=0:s&&e<n&&m>0&&(y=u*(g+1)*(l+1)/m),r[p.id][0]-=y*f[0],r[a.id][0]+=y*f[0],r[p.id][1]-=y*f[1],r[a.id][1]+=y*f[1]}const m=[p.data.x-l[0],p.data.y-l[1]],y=Math.hypot(m[0],m[1]);m[0]=m[0]/y,m[1]=m[1]/y;const v=c*(g+1);r[p.id][0]-=v*m[0],r[p.id][1]-=v*m[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:u}=i,c=t.getAllNodes(),l=c.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<l;r+=1){const{id:i}=c[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],u=Math.hypot(a[0],a[1]),l=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(l[0],l[1]);h[r]=u,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const m=g;g=a*p/f,0!==m&&(g=g>1.5*m?1.5*m:g);for(let n=0;n<l;n+=1){const{id:r,data:i}=c[n],a=t.getDegree(r);if(s&&a<=1)continue;if($t(i.fx)&&$t(i.fy))continue;let l=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=u/d;l=l>f?f:l;const p=l*e[r][0],m=l*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+m})}return g}}const SI={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};class NI{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},SI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericFruchtermanLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;e<t;e++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,e,n){return a(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:u,nodeClusterBy:c,maxIteration:l,onTick:h}=r,d=e.getAllNodes(),f=e.getAllEdges();if(!(null==d?void 0:d.length)){const t={nodes:[],edges:f};return this.lastResult=t,t}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0});const n={nodes:[Object.assign(Object.assign({},d[0]),{data:Object.assign(Object.assign({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:f};return this.lastResult=n,n}const p=d.map((t=>Zg(t,[o,a]))),g=new Rd({nodes:p,edges:f}),m={};if(u&&p.forEach((t=>{const e=t.data[c];m[e]||(m[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=p,this.lastLayoutEdges=f,this.lastAssign=t,this.lastGraph=g,this.lastOptions=r,this.lastClusterMap=m,"undefined"==typeof window)return;let y=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,m,r),t&&p.forEach((({id:t,data:n})=>e.mergeNodeData(t,{x:n.x,y:n.y,z:3===i?n.z:void 0}))),null==h||h({nodes:p,edges:f}),y++,y>=l&&(window.clearInterval(this.timeInterval),n({nodes:p,edges:f}))):n({nodes:p,edges:f})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:r}=e,{center:i,width:o,height:a}=e;return e.width=o||"undefined"==typeof window?o:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!r,e}runOneStep(t,e,n){const{dimensions:r,height:i,width:o,gravity:a,center:s,speed:u,clustering:c,nodeClusterBy:l,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),m=Math.sqrt(g),y={};if(this.applyCalculate(t,y,m,g),c){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;p.forEach((t=>{const{data:n}=t,r=e[n[l]];$t(n.x)&&(r.cx+=n.x),$t(n.y)&&(r.cy+=n.y),r.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!$t(o.x)||!$t(o.y))return;const a=e[o[l]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),u=m*t;y[i].x-=u*(o.x-a.cx)/s,y[i].y-=u*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!$t(i.x)||!$t(i.y))return;const o=.01*m*a;y[n].x-=o*(i.x-s[0]),y[n].y-=o*(i.y-s[1]),3===r&&(y[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if($t(o.fx)&&$t(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!$t(o.x)||!$t(o.y))return;const a=Math.sqrt(y[i].x*y[i].x+y[i].y*y[i].y+(3===r?y[i].z*y[i].z:0));if(a>0){const e=Math.min(f*(u/800),a);t.mergeNodeData(i,{x:o.x+y[i].x/a*e,y:o.y+y[i].y/a*e,z:3===r?o.z+y[i].z/a*e:void 0})}}))}applyCalculate(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)}calRepulsive(t,e,n){const r=t.getAllNodes();r.forEach((({data:t,id:i},o)=>{e[i]={x:0,y:0,z:0},r.forEach((({data:r,id:a},s)=>{if(o<=s||!$t(t.x)||!$t(r.x)||!$t(t.y)||!$t(r.y))return;let u=t.x-r.x,c=t.y-r.y,l=3===this.options.dimensions?t.z-r.z:0,h=u*u+c*c+l*l;0===h&&(h=1,u=.01,c=.01,l=.01);const d=n/h,f=u*d,p=c*d,g=l*d;e[i].x+=f,e[i].y+=p,e[a].x-=f,e[a].y-=p,3===this.options.dimensions&&(e[i].z+=g,e[a].z-=g)}))}))}calAttractive(t,e,n){t.getAllEdges().forEach((r=>{const{source:i,target:o}=r;if(!i||!o||i===o)return;const{data:a}=t.getNode(i),{data:s}=t.getNode(o);if(!($t(s.x)&&$t(a.x)&&$t(s.y)&&$t(a.y)))return;const u=s.x-a.x,c=s.y-a.y,l=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(u*u+c*c+l*l)/n,d=u*h,f=c*h,p=l*h;e[i].x+=d,e[i].y+=f,e[o].x-=d,e[o].y-=f,3===this.options.dimensions&&(e[i].z+=p,e[o].z-=p)}))}}const kI={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};class CI{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},kI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{begin:i=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:s,rows:u,cols:c,nodeSpacing:l,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const m=e.getAllNodes(),y=e.getAllEdges(),v=null==m?void 0:m.length;if(!v||1===v)return im(e,t,i);const b=m.map((t=>Zg(t)));"id"===g||Vt(g)&&void 0!==b[0].data[g]||(g="degree"),"degree"===g?b.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):"id"===g?b.sort(((t,e)=>$t(e.id)&&$t(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,w=f||"undefined"==typeof window?f:window.innerHeight,E=v,M={rows:u,cols:c};if(null!=u&&null!=c)M.rows=u,M.cols=c;else if(null!=u&&null==c)M.rows=u,M.cols=Math.ceil(E/M.rows);else if(null==u&&null!=c)M.cols=c,M.rows=Math.ceil(E/M.cols);else{const t=Math.sqrt(E*w/x);M.rows=Math.round(t),M.cols=Math.round(x/w*t)}if(M.rows=Math.max(M.rows,1),M.cols=Math.max(M.cols,1),M.cols*M.rows>E){const t=TI(M),e=AI(M);(t-1)*e>=E?TI(M,t-1):(e-1)*t>=E&&AI(M,e-1)}else for(;M.cols*M.rows<E;){const t=TI(M),e=AI(M);(e+1)*t>=E?AI(M,e+1):TI(M,t+1)}let S=o?0:x/M.cols,N=o?0:w/M.rows;if(s||l){const t=Qg(10,l),n=Jg(30,h,!1);b.forEach((r=>{r.data.x&&r.data.y||(r.data.x=0,r.data.y=0);const i=e.getNode(r.id),o=n(i)||30;let s,u;Ug(o)?(s=o[0],u=o[1]):(s=o,u=o);const c=void 0!==t?t(r):a,l=s+c,h=u+c;S=Math.max(S,l),N=Math.max(N,h)}))}const k={},C={row:0,col:0},T={};for(let t=0;t<b.length;t++){const n=b[t];let r;if(p&&(r=p(e.getNode(n.id))),r&&(void 0!==r.row||void 0!==r.col)){const t={row:r.row,col:r.col};if(void 0===t.col)for(t.col=0;PI(k,t);)t.col++;else if(void 0===t.row)for(t.row=0;PI(k,t);)t.row++;T[n.id]=t,OI(k,t)}RI(n,i,S,N,T,M,C,k)}const A={nodes:b,edges:y};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),A}))}}const TI=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},AI=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},PI=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,OI=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,_I=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},RI=(t,e,n,r,i,o,a,s)=>{let u,c;const l=i[t.id];if(l)u=l.col*n+n/2+e[0],c=l.row*r+r/2+e[1];else{for(;PI(s,a);)_I(o,a);u=a.col*n+n/2+e[0],c=a.row*r+r/2+e[1],OI(s,a),_I(o,a)}t.data.x=u,t.data.y=c},II={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},DI=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,u)=>{if(s===u)return;if(i[s]!==i[u])return;let c=a.x-e.x,l=a.y-e.y,h=Math.sqrt(c*c+l*l);if(0===h){h=1;const t=s>u?1:-1;c=.01*t,l=.01*t}if(h<o(t[s])/2+o(t[u])/2){const t=r*r/h;n[s].x+=c/h*t,n[s].y+=l/h*t}}))}))},LI=(t,e,n,r,i,o,a,s)=>{const u=o||a/10;return r&&e.forEach(((e,n)=>{const r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o);let s=o/a,u=-r/a;const c=Math.sqrt(e.x*e.x+e.y*e.y);let l=Math.acos((s*e.x+u*e.y)/c);l>Math.PI/2&&(l-=Math.PI/2,s*=-1,u*=-1);const h=Math.cos(l)*c;e.x=s*h,e.y=u*h})),t.forEach(((o,a)=>{if(a===i)return;const c=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(c>0&&a!==i){const l=Math.min(u*(n/800),c);if(o.x+=e[a].x/c*l,o.y+=e[a].y/c*l,r){let e=o.x-t[i].x,n=o.y-t[i].y;const r=Math.sqrt(e*e+n*n);e=e/r*s[a],n=n/r*s[a],o.x=t[i].x+e,o.y=t[i].y+n}}})),t},jI={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class BI{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},jI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:u,nodeSize:c,nodeSpacing:l,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:m=10,maxIteration:y=1e3}=r,v=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,w=o||"undefined"==typeof window?o:window.innerHeight,E=a||[x/2,w/2];if(!(null==v?void 0:v.length)||1===v.length)return im(e,t,E);let M=v[0];if(Vt(s)){for(let t=0;t<v.length;t++)if(v[t].id===s){M=v[t];break}}else M=s||v[0];const S=GI(v,M.id),N=qg({nodes:v,edges:b}),k=$g(N),C=WI(k,S);VI(k,S,C+1);const T=k[S];let A=x-E[0]>E[0]?E[0]:x-E[0],P=w-E[1]>E[1]?E[1]:w-E[1];0===A&&(A=x/2),0===P&&(P=w/2);const O=Math.min(A,P),_=Math.max(...T),R=[],I=u||O/_;T.forEach(((t,e)=>{R[e]=t*I}));const D=zI(v,k,g,R,I,p,m),L=FI(D),j=((t,e,n)=>{try{const n=Py.mul(Py.pow(e,2),-.5),r=n.mean("row"),i=n.mean("column"),o=n.mean();n.add(o).subRowVector(r).subColumnVector(i);const a=new Oy(n),s=Py.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>Py.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const r=[];for(let t=0;t<e.length;t++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}})(g,D,g);let B,z=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[S][0],y:(isNaN(e)?Math.random()*g:e)-j[S][1]})));if(this.run(y,z,L,D,R,S),d){B=tm(c,l);const t={nodes:v,nodeSizeFunc:B,positions:z,radii:R,height:w,width:x,strictRadial:Boolean(h),focusIdx:S,iterations:f||200,k:z.length/4.5};z=((t,e)=>{const n=Object.assign(Object.assign({},II),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:u,focusIdx:c,radii:l=[],nodeSizeFunc:h}=n,d=t.getAllNodes(),f=[],p=o/10;for(let t=0;t<i;t++)r.forEach(((t,e)=>{f[e]={x:0,y:0}})),DI(d,r,f,a,l,h),LI(r,f,s,u,c,p,o,l);return r})(e,t)}const F=[];z.forEach(((t,e)=>{const n=Zg(v[e]);n.data.x=t.x+E[0],n.data.y=t.y+E[1],F.push(n)})),t&&F.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:F,edges:b}}))}run(t,e,n,r,i,o){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,i,r,n,o)}}oneIteration(t,e,n,r,i,o){const a=1-t;e.forEach(((s,u)=>{const c=Yg(s,{x:0,y:0}),l=0===c?0:1/c;if(u===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(u===e)return;const n=Yg(s,t),o=0===n?0:1/n,a=r[e][u];f+=i[u][e],h+=i[u][e]*(t.x+a*(s.x-t.x)*o),d+=i[u][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[u]?0:1/n[u];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*l,s.x=h/f,d*=a,d+=t*p*s.y*l,s.y=d/f}))}}const zI=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];if(e){const u={};e.forEach(((e,c)=>{const l=[];e.forEach(((e,s)=>{var h,d;if(c===s)l.push(0);else if(r[c]===r[s])if("data"===o)l.push(e*(Math.abs(c-s)*a)/(r[c]/i));else if(o){let n,f;if(u[t[c].id])n=u[t[c].id];else{const e=("id"===o?t[c].id:null===(h=t[c].data)||void 0===h?void 0:h[o])||0;n=Vt(e)?e.charCodeAt(0):e,u[t[c].id]=n}if(u[t[s].id])f=u[t[s].id];else{const e=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=Vt(e)?e.charCodeAt(0):e,u[t[s].id]=f}l.push(e*(Math.abs(n-f)*a)/(r[c]/i))}else l.push(e*n/(r[c]/i));else{const t=(n+i)/2;l.push(e*t)}})),s.push(l)}))}return s},FI=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},GI=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},VI=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},WI=(t,e)=>{let n=0;for(let r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},HI={center:[0,0],width:300,height:300};class UI{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},HI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a}=r,s=e.getAllNodes(),u=o||"undefined"==typeof window?o:window.innerWidth,c=a||"undefined"==typeof window?a:window.innerHeight,l=i||[u/2,c/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*u+l[0],y:.9*(Math.random()-.5)*c+l[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}function $I(t){return!!t.tick&&!!t.stop}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2019 Google LLC
5
5
  * SPDX-License-Identifier: Apache-2.0
6
- */const TI=Symbol("Comlink.proxy"),PI=Symbol("Comlink.endpoint"),kI=Symbol("Comlink.releaseProxy"),AI=Symbol("Comlink.finalizer"),OI=Symbol("Comlink.thrown"),_I=t=>"object"==typeof t&&null!==t||"function"==typeof t,RI=new Map([["proxy",{canHandle:t=>_I(t)&&t[TI],serialize(t){const{port1:e,port2:n}=new MessageChannel;return DI(t,e),[n,[n]]},deserialize:t=>(t.start(),LI(t))}],["throw",{canHandle:t=>_I(t)&&OI in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function DI(t,e=globalThis,n=["*"]){e.addEventListener("message",(function r(i){if(!i||!i.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:o,type:a,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(HI);let u;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(a){case"GET":u=n;break;case"SET":e[s.slice(-1)[0]]=HI(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,c);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[TI]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;DI(t,n),u=function(t,e){return WI.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[OI]:0}}Promise.resolve(u).catch((t=>({value:t,[OI]:0}))).then((n=>{const[i,s]=UI(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),II(e),AI in t&&"function"==typeof t[AI]&&t[AI]())})).catch((t=>{const[n,r]=UI({value:new TypeError("Unserializable return value"),[OI]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function II(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function LI(t,e){return GI(t,[],e)}function jI(t){if(t)throw new Error("Proxy has been released and is not useable")}function zI(t){return $I(t,{type:"RELEASE"}).then((()=>{II(t)}))}const BI=new WeakMap,FI="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(BI.get(t)||0)-1;BI.set(t,e),0===e&&zI(t)}));function GI(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(jI(r),o===kI)return()=>{!function(t){FI&&FI.unregister(t)}(i),zI(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=$I(t,{type:"GET",path:e.map((t=>t.toString()))}).then(HI);return n.then.bind(n)}return GI(t,[...e,o])},set(n,i,o){jI(r);const[a,s]=UI(o);return $I(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(HI)},apply(n,i,o){jI(r);const a=e[e.length-1];if(a===PI)return $I(t,{type:"ENDPOINT"}).then(HI);if("bind"===a)return GI(t,e.slice(0,-1));const[s,c]=VI(o);return $I(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},c).then(HI)},construct(n,i){jI(r);const[o,a]=VI(i);return $I(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(HI)}});return function(t,e){const n=(BI.get(e)||0)+1;BI.set(e,n),FI&&FI.register(t,e,t)}(i,t),i}function VI(t){const e=t.map(UI);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const WI=new WeakMap;function UI(t){for(const[e,n]of RI)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},WI.get(t)||[]]}function HI(t){switch(t.type){case"HANDLER":return RI.get(t.name).deserialize(t.value);case"RAW":return t.value}}function $I(t,e,n){return new Promise((r=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){n.data&&n.data.id&&n.data.id===i&&(t.removeEventListener("message",e),r(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),n)}))}class qI extends Lp{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=LI(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())}execute(){var t;return a(this,void 0,void 0,(function*(){if(this.running)return this;this.running=!0;const e=o(this.layout.options,["onTick"]),n={};Object.keys(e).forEach((t=>{Pt(e[t])||(n[t]=e[t])}));const r={layout:{id:this.layout.id,options:n,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},i=new Float32Array([0]),[a]=yield this.proxy.calculateLayout(r,[i]);return a}))}stop(){return this.running=!1,this.proxy.stopLayout(),this}kill(){this.proxy[kI]()}isRunning(){return this.running}}class YI extends Zh{}const KI=t=>t?parseInt(t):0;function XI(t){let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||KI(e.width),r=t.clientHeight||KI(e.height);return[n-(KI(e.paddingLeft)+KI(e.paddingRight)),r-(KI(e.paddingTop)+KI(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(Wt(e)?e:1,1),Math.max(Wt(n)?n:1,1)]}function ZI(t,e=!0){const n=document.createElement("div");return n.setAttribute("class",`g6-${t}`),n.style.position="absolute",n.style.display="block",e&&(n.style.top="0px",n.style.left="0px",n.style.height="100%",n.style.width="100%",n.style.overflow="hidden",n.style.pointerEvents="none"),n}function QI(t,e="div",n={},r="",i=document.body){const o=document.getElementById(t);o&&o.remove();const a=document.createElement(e);return a.innerHTML=r,a.id=t,Object.assign(a.style,n),i.appendChild(a),a}class JI extends YI{static defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};$element=ZI("contextmenu",!1);constructor(t,e){super(t,Object.assign({},JI.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),QI("g6-contextmenu-css","style",{},"\n .g6-contextmenu {\n font-size: 12px;\n background-color: rgba(255, 255, 255, 0.96);\n border-radius: 4px;\n overflow: hidden;\n box-shadow: rgba(0, 0, 0, 0.12) 0px 6px 12px 0px;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s;\n }\n\n .g6-contextmenu-ul {\n max-width: 256px;\n min-width: 96px;\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n .g6-contextmenu-li {\n padding: 8px 12px;\n cursor: pointer;\n user-select: none;\n }\n\n .g6-contextmenu-li:hover {\n background-color: #f5f5f5;\n cursor: pointer;\n }\n",document.head),this.update(e)}async showContextmenu(t){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hideContextmenu();const r=await this.getDOMContent(t);r instanceof HTMLElement?this.$element.appendChild(r):this.$element.innerHTML=r;const i=this.context.graph.getCanvas().getContainer().getBoundingClientRect();this.$element.style.left=`${t.client.x-i.left+n[0]}px`,this.$element.style.top=`${t.client.y-i.top+n[1]}px`,this.$element.style.display="block"}hideContextmenu(){this.$element.style.display="none"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}async getDOMContent(t){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(await n(t)).map((t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`)).join("")}\n </ul>\n `:await e(t)}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`canvas:${e}`,this.onTriggerEvent),t.on(`node:${e}`,this.onTriggerEvent),t.on(`edge:${e}`,this.onTriggerEvent),t.on(`combo:${e}`,this.onTriggerEvent),document.addEventListener("click",this.onMenuItemClick)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`canvas:${e}`,this.onTriggerEvent),t.off(`node:${e}`,this.onTriggerEvent),t.off(`edge:${e}`,this.onTriggerEvent),t.off(`combo:${e}`,this.onTriggerEvent),document.removeEventListener("click",this.onMenuItemClick)}onTriggerEvent=t=>{t.preventDefault?.(),this.showContextmenu(t)};onMenuItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof HTMLElement){if(t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");e&&e(n,t.target),this.hideContextmenu()}this.context.graph.getCanvas().getContainer().contains(t.target)||this.hideContextmenu()}}}class tL extends YI{static defaultOptions={lineWidth:1,border:!0,borderLineWidth:1,borderStroke:"#0001",borderStyle:"solid",stroke:"#0001",size:20,tickCount:4,tickStrokeOpacity:.5};$element=ZI("grid-line");offset=[0,0];constructor(t,e){super(t,Object.assign({},tL.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),this.updateStyle(),this.bindEvents()}update(t){super.update(t),this.updateStyle()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}updateStyle(){const{size:t,stroke:e,lineWidth:n,border:r,borderLineWidth:i,borderStroke:o,borderStyle:a}=this.options;Object.assign(this.$element.style,{border:r?`${i}px ${a} ${o}`:"none",backgroundImage:`linear-gradient(${e} ${n}px, transparent ${n}px), linear-gradient(90deg, ${e} ${n}px, transparent ${n}px)`,backgroundSize:`${t}px ${t}px`})}updateOffset(t){this.offset=function(t,e){return t.map((t=>t%e))}(Yu(this.offset,t),this.options.size),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}onTransform=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)};destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}var eL;function nL(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=Fu(r);if("NodeAdded"===n||"EdgeAdded"===n||"ComboAdded"===n)e.Added.set(i,t);else if("NodeUpdated"===n||"EdgeUpdated"===n||"ComboUpdated"===n)if(e.Added.has(i))e.Added.set(i,{type:n.replace("Updated","Added"),value:r});else if(e.Updated.has(i)){const{original:t}=e.Updated.get(i);e.Updated.set(i,{type:n,value:r,original:t})}else e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)||e.Updated.has(i)?(e.Added.delete(i),e.Updated.delete(i)):e.Removed.set(i,t))})),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}function rL(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:a=[],ComboAdded:s=[],ComboUpdated:c=[],ComboRemoved:u=[]}=Gt(t,(t=>t.type));return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:c},remove:{nodes:r,edges:a,combos:u}}}function iL(t,e){for(const n in t)Rt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),iL(t[n],e[n])):e[n]||(e[n]=Hh(n))}function oL(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:a}=rL(nL(t));return["nodes","edges","combos"].forEach((t=>{o[t]&&o[t].forEach((e=>{const i={...e.value};let o={...e.original};if(n){const t=n.graph.getElementType(Fu(e.original)),{color:r}=n.element.getElementComputedStyle(t,e.original);o={...e.original,style:{color:r,...e.original.style}}}iL(i,o),r.current.update[t]||=[],r.current.update[t].push(i),r.original.update[t]||=[],r.original.update[t].push(o)})),i[t]&&i[t].forEach((e=>{const n={...e.value};r.current.add[t]||=[],r.current.add[t].push(n),r.original.remove[t]||=[],r.original.remove[t].push(n)})),a[t]&&a[t].forEach((e=>{const n={...e.value};r.current.remove[t]||=[],r.current.remove[t].push(n),r.original.add[t]||=[],r.original.add[t].push(n)}))})),r}!function(t){t.UNDO="undo",t.REDO="redo",t.CANCEL="cancel",t.ADD="add",t.CLEAR="clear",t.CHANGE="change"}(eL||(eL={}));class aL extends YI{static defaultOptions={stackSize:0};emitter;batchChanges=null;batchAnimation=!1;undoStack=[];redoStack=[];isFirstDraw=!0;freezed=!1;constructor(e,n){super(e,Object.assign({},aL.defaultOptions,n)),this.emitter=new Lp;const{graph:r}=this.context;r.on(t.GraphEvent.AFTER_DRAW,this.addCommand),r.on(t.GraphEvent.BATCH_START,this.initBatchCommand),r.on(t.GraphEvent.BATCH_END,this.addCommand)}canUndo=()=>this.undoStack.length>0;canRedo=()=>this.redoStack.length>0;undo=()=>{const t=this.undoStack.pop();return t&&(this.executeCommand(t),this.options.beforeAddCommand?.(t,!1),this.redoStack.push(t),this.options.afterAddCommand?.(t,!1),this.notify(eL.UNDO,t)),this};redo=()=>{const t=this.redoStack.pop();return t&&(this.executeCommand(t,!1),this.undoStackPush(t),this.notify(eL.REDO,t)),this};undoAndCancel=()=>{const t=this.undoStack.pop();return t&&(this.executeCommand(t,!1),this.redoStack=[],this.notify(eL.CANCEL,t)),this};executeCommand=(t,e=!0)=>{this.freezed=!0,this.options.executeCommand?.(t);const n=e?t.original:t.current;this.context.graph.addData(n.add),this.context.graph.updateData(n.update),this.context.graph.removeData(Vu(n.remove,!1)),this.context.element?.draw({silence:!0,animation:t.animation}),this.freezed=!1};addCommand=e=>{if(this.isFirstDraw)this.isFirstDraw=!1;else if(!this.freezed){if(e.type===t.GraphEvent.AFTER_DRAW){const{dataChanges:t=[],animation:n=!0}=e.data;if(this.context.batch?.isBatching){if(!this.batchChanges)return;return this.batchChanges.push(t),void(this.batchAnimation&&=n)}this.batchChanges=[t],this.batchAnimation=n}this.undoStackPush(oL(this.batchChanges.flat(),this.batchAnimation,this.context)),this.notify(eL.ADD,this.undoStack[this.undoStack.length-1])}};initBatchCommand=t=>{const{initiate:e}=t.data;if(this.batchAnimation=!1,e)this.batchChanges=[];else{this.undoStack.pop()||(this.batchChanges=null)}};undoStackPush(t){const{stackSize:e}=this.options;0!==e&&this.undoStack.length>=e&&this.undoStack.shift(),this.options.beforeAddCommand?.(t,!0),this.undoStack.push(t),this.options.afterAddCommand?.(t,!0)}clear(){this.undoStack=[],this.redoStack=[],this.batchChanges=null,this.batchAnimation=!1,this.notify(eL.CLEAR,null)}notify(t,e){this.emitter.emit(t,{cmd:e}),this.emitter.emit(eL.CHANGE,{cmd:e})}on(t,e){this.emitter.on(t,e)}destroy(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.addCommand),e.off(t.GraphEvent.BATCH_START,this.initBatchCommand),e.off(t.GraphEvent.BATCH_END,this.addCommand),this.emitter.off(),super.destroy(),this.undoStack=[],this.redoStack=[]}}function sL(t,e,n,r,i,o){const a=(o-e)*(n-t)-(r-e)*(i-t);return a>0||!(a<0)}var cL=function(t,e){const n=t[0][0],r=t[0][1],i=t[1][0],o=t[1][1],a=e[0][0],s=e[0][1],c=e[1][0],u=e[1][1];return sL(n,r,a,s,c,u)!==sL(i,o,a,s,c,u)&&sL(n,r,i,o,a,s)!==sL(n,r,i,o,c,u)};function uL(t,e){this._cells=[],this._cellSize=e,this._reverseCellSize=1/e;for(let e=0;e<t.length;e++){const n=t[e],r=this.coordToCellNum(n[0]),i=this.coordToCellNum(n[1]);if(this._cells[r])this._cells[r][i]?this._cells[r][i].push(n):this._cells[r][i]=[n];else{const t=[];t[i]=[n],this._cells[r]=t}}}function lL(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}uL.prototype={cellPoints:function(t,e){return void 0!==this._cells[t]&&void 0!==this._cells[t][e]?this._cells[t][e]:[]},rangePoints:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this.coordToCellNum(t[2]),i=this.coordToCellNum(t[3]),o=[];for(let t=e;t<=r;t++)for(let e=n;e<=i;e++)for(let n=0;n<this.cellPoints(t,e).length;n++)o.push(this.cellPoints(t,e)[n]);return o},removePoint:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this._cells[e][n];let i;for(let e=0;e<r.length;e++)if(r[e][0]===t[0]&&r[e][1]===t[1]){i=e;break}return r.splice(i,1),r},trunc:Math.trunc||function(t){return t-t%1},coordToCellNum:function(t){return this.trunc(t*this._reverseCellSize)},extendBbox:function(t,e){return[t[0]-e*this._cellSize,t[1]-e*this._cellSize,t[2]+e*this._cellSize,t[3]+e*this._cellSize]}};var hL=function(t){const e=function(t){const e=[];for(let n=0;n<t.length;n++){for(;e.length>=2&&lL(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}return e.pop(),e}(t),n=function(t){const e=t.reverse(),n=[];for(let t=0;t<e.length;t++){for(;n.length>=2&&lL(n[n.length-2],n[n.length-1],e[t])<=0;)n.pop();n.push(e[t])}return n.pop(),n}(t).concat(e);return n.push(t[0]),n};const dL=cL,fL=function(t,e){return new uL(t,e)},pL={toXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","return [pt"+e[0]+",pt"+e[1]+"];")(t)}))},fromXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","const o = {}; o"+e[0]+"= pt[0]; o"+e[1]+"= pt[1]; return o;")(t)}))}},gL=hL;function mL(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function vL(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=mL(t,e),a=mL(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*a)}function yL(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&dL(t,r))return!0}return!1}function bL(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function xL(t,e,n){let r,i,o=null,a=wL,s=wL;for(let c=0;c<e.length;c++)r=vL(t[0],t[1],e[c]),i=vL(t[1],t[0],e[c]),r>a&&i>s&&!yL([t[0],e[c]],n)&&!yL([t[1],e[c]],n)&&(a=r,s=i,o=e[c]);return o}function EL(t,e,n,r,i){let o=!1;for(let a=0;a<t.length-1;a++){const s=[t[a],t[a+1]],c=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(mL(s[0],s[1])<e||i.has(c))continue;let u,l,h,d=0,f=bL(s);do{f=r.extendBbox(f,d),u=f[2]-f[0],l=f[3]-f[1],h=xL(s,r.rangePoints(f),t),d++}while(null===h&&(n[0]>u||n[1]>l));u>=n[0]&&l>=n[1]&&i.add(c),null!==h&&(t.splice(a+1,0,h),r.removePoint(h),o=!0)}return o?EL(t,e,n,r,i):t}const wL=Math.cos(90/(180/Math.PI)),ML=.6;var NL=function(t,e,n){let r=e||20;const i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort((function(t,e){return t[0]-e[0]||t[1]-e[1]}))}(pL.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?pL.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),t[o][0]>r&&(r=t[o][0]),t[o][1]>i&&(i=t[o][1]);return[r-e,i-n]}(i),a=[o[0]*ML,o[1]*ML],s=gL(i),c=i.filter((function(t){return s.indexOf(t)<0})),u=Math.ceil(1/(i.length/(o[0]*o[1]))),l=EL(s,Math.pow(r,2),a,fL(c,u),new Set);return n?pL.fromXy(l,n):l},SL=f(NL);function CL(t,e,n,r,i,o,a){const[s,c]=Du(t,e),u={x:s+n,y:c+r,textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:"none"};if("center"===e||!i)return u;const l=Md(o);if(!l||l.length<=3)return u;const h=l.map(((t,e)=>{const n=t,r=l[(e+1)%l.length];return ae(n,r)?null:[n,r]})).filter(Boolean),d=function(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=bl(t,e);i<n&&(n=i,r=e)})),r}([s,c],h),f=xl([s,c],d);if(f&&d&&(u.x=f[0]+n,u.y=f[1]+r,a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));u.transform=`rotate(${t/Math.PI*180}deg)`,u.textAlign="center","right"!==e&&"left"!==e||(u.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return u}let TL=class t extends Ol{static defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToHull:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};constructor(e){super(re({},{style:t.defaultStyleProps},e))}getLabelStyle(t){if(!t.label||!t.path||0===t.path.length)return!1;const{maxWidth:e,offsetX:n,offsetY:r,autoRotate:i,placement:o,closeToHull:a,...s}=Uu(this.getGraphicStyle(t),"label"),c=this.shapeMap.contour,u=c?.getRenderBounds();return Object.assign(CL(u,o,n,r,a,t.path,i),{wordWrapWidth:Ml(u,e)},s)}getContourStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("contour",js,this.getContourStyle(t),e),this.upsert("label",_l,this.getLabelStyle(t),e)}};const PL=(t,e,n)=>{if("sharp"===n)return[["M",t[0]-e,t[1]-e],["L",t[0]+e,t[1]-e],["L",t[0]+e,t[1]+e],["L",t[0]-e,t[1]+e],["Z"]];const r=[e,e,0,0,0];return[["M",t[0],t[1]-e],["A",...r,t[0],t[1]+e],["A",...r,t[0],t[1]-e]]},kL=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?Yu(t[0],Qu(el(Ku(t[0],t[1])),e)):t[0],o="sharp"===n?Yu(t[1],Qu(el(Ku(t[1],t[0])),e)):t[1],a=Qu(el(rl(Ku(i,o),!1)),e),s=Qu(a,-1),c=Yu(i,a),u=Yu(o,a),l=Yu(o,s),h=Yu(i,s);return"sharp"===n?[["M",c[0],c[1]],["L",u[0],u[1]],["L",l[0],l[1]],["L",h[0],h[1]],["Z"]]:[["M",c[0],c[1]],["L",u[0],u[1]],["A",...r,l[0],l[1]],["L",h[0],h[1]],["A",...r,c[0],c[1]]]},AL=(t,e)=>{const n=El(t).map(((n,r)=>{const i=(r-2+t.length)%t.length,o=(r-1+t.length)%t.length,a=(r+1)%t.length,s=t[i],c=t[o],u=t[a],l=Ku(s,c),h=Ku(c,n),d=Ku(n,u),f=(t,e)=>nl(t,e,!0)<Math.PI,p=f(l,h),g=f(h,d),m=t=>Qu(el(rl(t,!1)),e),v=m(h);return[{p:il(Yu(c,p?m(l):v)),concave:p&&c},{p:il(Yu(n,g?m(d):v)),concave:g&&n}]})),r=[e,e,0,0,0],i=n.findIndex(((t,e)=>!(n[(e-1+n.length)%n.length][0].concave||n[(e-1+n.length)%n.length][1].concave||t[0].concave||t[0].concave||t[1].concave))),o=n.slice(i).concat(n.slice(0,i));let a=[];return o.flatMap(((t,e)=>{const i=[],s=o[n.length-1];return 0===e&&i.push(["M",...s[1].p]),t[0].concave?a.push(t[0].p,t[1].p):i.push(["A",...r,...t[0].p]),t[1].concave?a.unshift(t[1].p):i.push(["L",...t[1].p]),3===a.length&&(i.pop(),i.push(["C",...a.flat()]),a=[]),i}))},OL=(t,e)=>{const n=El(t).map(((e,n)=>({p:e,v:el(Ku(t[(n+1)%t.length],e))})));return n.forEach(((r,i)=>{const o=i>0?i-1:t.length-1,a=n[o].v,s=el(Yu(a,Qu(r.v,nl(a,r.v,!0)<Math.PI?1:-1)));r.p=Yu(r.p,Qu(s,e))})),(t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,c]=t[e+1],[u,l]=e!==t.length-2?t[e+2]:[s,c],h=i+(s-n)/6,d=a+(c-r)/6,f=s-(u-i)/6,p=c-(l-a)/6;o.push(["C",h,d,f,p,s,c])}return o})(n.map((t=>t.p)))},_L=(t,e)=>{const n=t.map(((n,r)=>{const i=t[0===r?t.length-1:r-1],o=ol(Qu(el(rl(Ku(i,n),!1)),e));return[Yu(i,o),Yu(n,o)]})).flat();return n.map(((t,e)=>{if(e%2==0)return null;return ul([n[(e-1)%n.length],n[e%n.length]],[n[(e+1)%n.length],n[(e+2)%n.length]],!0)})).filter(Boolean).map(((t,e)=>[0===e?"M":"L",t[0],t[1]])).concat([["Z"]])};class RL extends YI{shape;hullMemberIds=[];path;firstRender=!1;static defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",stroke:"blue",opacity:.2};constructor(t,e){super(t,Object.assign({},RL.defaultOptions,e)),this.bindEvents()}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}getHullStyle(t){const{members:e,padding:n,corner:r,...i}=this.options;return{...i,path:this.getHullPath(t)}}drawHull=()=>{this.shape=new TL({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape),this.firstRender=!0};updateHullPath=t=>{this.firstRender&&this.options.members.includes(Fu(t.data))&&this.shape.update({path:this.getHullPath(!0)})};getHullPath=(t=!1)=>{const{graph:e}=this.context,n=this.options.members.map((t=>e.getNodeData(t))),r=SL(n.map(_u),this.options.concavity).slice(1).reverse(),i=r.flatMap((t=>n.filter((e=>ae(_u(e),t))).map(Fu)));return ae(i,this.hullMemberIds)&&!t||(this.hullMemberIds=i,this.path=function(t,e,n){if(1===t.length)return PL(t[0],e,n);if(2===t.length)return kL(t,e,n);switch(n){case"smooth":return OL(t,e);case"sharp":return _L(t,e);default:return AL(t,e)}}(r,this.getPadding(),this.options.corner)),this.path};getPadding(){const{graph:t}=this.context,e=this.hullMemberIds.reduce(((e,n)=>{const{halfExtents:r}=t.getElementRenderBounds(n),i=Math.max(r[0],r[1]);return Math.max(e,i)}),0);return e+this.options.padding}addMembers(t){const e=Array.isArray(t)?t:[t];this.options.members=[...new Set([...this.options.members,...e])],this.shape.update({path:this.getHullPath()})}removeMembers(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter((t=>!e.includes(t))),e.some((t=>this.hullMemberIds.includes(t)))&&this.shape.update({path:this.getHullPath()})}updateMembers(t){this.options.members=Pt(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}updateOptions(t){this.options=Pt(t)?t(this.options):t,this.shape.update({...this.options,path:this.getHullPath(!0)})}destroy(){this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.drawHull),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function DL(t,e){e(t),t.children&&t.children.forEach((function(t){t&&DL(t,e)}))}function IL(t){LL(t,!1)}function LL(t,e){var n=e?"visible":"hidden";DL(t,(function(t){t.attr("visibility",n)}))}var jL=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,l([],u(e),!1))||this;return r.addEventListener(Za.INSERTED,(function(){IL(r)})),r}return r(e,t),e}(Rs);function zL(t){var e=t.appendChild(new jL({class:"offscreen"}));return IL(e),e}var BL=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({style:i({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return r(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=zL(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(Gs),FL=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=r}return Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t.prototype.toJSON=function(){return{x:this.x,y:this.y,width:this.width,height:this.height,top:this.top,right:this.right,bottom:this.bottom,left:this.left}},t.prototype.isPointIn=function(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}();var GL,VL=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=u(t,2),r=e[0],i=e[1],o=n(i);return[r,{name:o,class:".".concat(o),id:"#".concat(o),toString:function(){return o}}]})));return Object.assign(r,{prefix:n}),r},WL=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=u(i,2),a=o[0],s=o[1],c=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?Lt(s)?(Lt(t[a])||(c[a]={}),n<r?WL(t[a],s,n+1,r):c[a]=e[a]):_t(s)?(c[a]=[],c[a]=c[a].concat(s)):c[a]=s:c[a]=s)}))},UL=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)WL(t,e[r]);return t};!function(t,e,n){if(void 0===n&&(n=128),!Pt(t))throw new TypeError("Expected a function");var r=function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=e?e.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var s=t.apply(this,n);return a.set(o,s),s};r.cache=function(t){var e,n,r,i=t||1;function o(t,o){++e>i&&(r=n,a(1),++e),n[t]=o}function a(t){e=0,n=Object.create(null),t||(r=Object.create(null))}return a(),{clear:a,has:function(t){return void 0!==n[t]||void 0!==r[t]},get:function(t){var e=n[t];return void 0!==e?e:void 0!==(e=r[t])?(o(t,e),e):void 0},set:function(t,e){void 0!==n[t]?n[t]=e:o(t,e)}}}(n)}((function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return GL||(GL=fs.offscreenCanvasCreator.getOrCreateContext(void 0)),GL.font=[o,a,i,"".concat(n,"px"),r].join(" "),GL.measureText(t).width}),(function(t,e){return[t,Object.values(e||HL(t)).join()].join("")}),4096);var HL=function(t){var e=t.style.fontFamily||"sans-serif",n=t.style.fontWeight||"normal",r=t.style.fontStyle||"normal",i=t.style.fontVariant,o=t.style.fontSize;return{fontSize:o="object"==typeof o?o.value:o,fontFamily:e,fontWeight:n,fontStyle:r,fontVariant:i}};function $L(t,e,n){void 0===n&&(n="..."),function(t,e){var n=function(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}(t);n&&n.attr(e)}(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function qL(t){return"function"==typeof t?t():Bt(t)||Wt(t)?new BL({style:{text:String(t)}}):t}function YL(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=function(t){t.node().removeChildren()}),t?n(e):(r&&i(e),null)}function KL(t){for(var e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;o<t.length;o++){var a=t[o],s=a.x,c=a.y,l=u([s+a.width,c+a.height],2),h=l[0],d=l[1];s<e&&(e=s),c<n&&(n=c),h>r&&(r=h),d>i&&(i=d)}return new FL(e,n,r-e,i-n)}var XL=function(t,e,n){var r=t.width,i=t.height,o=n.flexDirection,a=void 0===o?"row":o;n.flexWrap;var s=n.justifyContent,c=void 0===s?"flex-start":s;n.alignContent;var l=n.alignItems,h=void 0===l?"flex-start":l,d="row"===a,f="row"===a||"column"===a,p=d?f?[1,0]:[-1,0]:f?[0,1]:[0,-1],g=u([0,0],2),m=g[0],v=g[1],y=e.map((function(t){var e,n=t.width,r=t.height,i=u([m,v],2),o=i[0],a=i[1];return e=u([m+n*p[0],v+r*p[1]],2),m=e[0],v=e[1],new FL(o,a,n,r)})),b=KL(y),x={"flex-start":0,"flex-end":d?r-b.width:i-b.height,center:d?(r-b.width)/2:(i-b.height)/2},E=y.map((function(t){var e=t.x,n=t.y,r=FL.fromRect(t);return r.x=d?e+x[c]:e,r.y=d?n:n+x[c],r}));KL(E);var w=function(t){var e=u(d?["height",i]:["width",r],2),n=e[0],o=e[1];switch(h){case"flex-start":default:return 0;case"flex-end":return o-t[n];case"center":return o/2-t[n]/2}},M=E.map((function(t){var e=t.x,n=t.y,r=FL.fromRect(t);return r.x=d?e:e+w(r),r.y=d?n+w(r):n,r})),N=M.map((function(e){var n,r,i=FL.fromRect(e);return i.x+=null!==(n=t.x)&&void 0!==n?n:0,i.y+=null!==(r=t.y)&&void 0!==r?r:0,i}));return N},ZL=function(t,e,n){return[]};function QL(t,e,n){void 0===n&&(n=!1);var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return n&&t.scale(a),a}var JL=function(){function t(t,n,r,i,o,a,s){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=[null,null,null,null,null]),void 0===a&&(a=[]),void 0===s&&(s=[]),e.add(this),this._elements=Array.from(t),this._data=n,this._parent=r,this._document=i,this._enter=o[0],this._update=o[1],this._exit=o[2],this._merge=o[3],this._split=o[4],this._transitions=a,this._facetElements=s}var e,n,r;return t.prototype.selectAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(e,null,this._elements[0],this._document)},t.prototype.selectFacetAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(this._elements,null,this._parent,this._document,void 0,void 0,e)},t.prototype.select=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t)[0]||null:t;return new n([e],null,e,this._document)},t.prototype.append=function(t){var e=this,r="function"==typeof t?t:function(){return e.createElement(t)},i=[];if(null!==this._data){for(var o=0;o<this._data.length;o++){var a=this._data[o],s=u(Array.isArray(a)?a:[a,null],2),c=s[0],l=s[1];(d=r(c,o)).__data__=c,null!==l&&(d.__fromElements__=l),this._parent.appendChild(d),i.push(d)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var h=this._elements[o],d=r(c=h.__data__,o);h.appendChild(d),i.push(d)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=h(this,e,"m",r).call(this,"#"===t[0]?t:"#".concat(t),n);return i.attr("id",t),i},t.prototype.maybeAppendByClassName=function(t,n){var i=t.toString(),o=h(this,e,"m",r).call(this,"."===i[0]?i:".".concat(i),n);return o.attr("className",i),o},t.prototype.maybeAppendByName=function(t,n){var i=h(this,e,"m",r).call(this,'[name="'.concat(t,'"]'),n);return i.attr("name",t),i},t.prototype.data=function(t,e,r){var i,o;void 0===e&&(e=function(t){return t}),void 0===r&&(r=function(){return null});for(var a,s,u,l=[],h=[],d=new Set(this._elements),f=[],p=new Set,g=new Map(this._elements.map((function(t,n){return[e(t.__data__,n),t]}))),m=new Map(this._facetElements.map((function(t,n){return[e(t.__data__,n),t]}))),v=(a=this._elements,s=function(t){return r(t.__data__)},u=new Map,a.forEach((function(t){var e=s(t);u.has(e)||u.set(e,[]),u.get(e).push(t)})),u),y=0;y<t.length;y++){var b=t[y],x=e(b,y),E=r(b,y);if(g.has(x))(S=g.get(x)).__data__=b,S.__facet__=!1,h.push(S),d.delete(S),g.delete(x);else if(m.has(x)){(S=m.get(x)).__data__=b,S.__facet__=!0,h.push(S),m.delete(x)}else if(v.has(x)){var w=v.get(x);f.push([b,w]);try{for(var M=(i=void 0,c(w)),N=M.next();!N.done;N=M.next()){var S=N.value;d.delete(S)}}catch(t){i={error:t}}finally{try{N&&!N.done&&(o=M.return)&&o.call(M)}finally{if(i)throw i.error}}v.delete(x)}else if(g.has(E)){(S=g.get(E)).__toData__?S.__toData__.push(b):S.__toData__=[b],p.add(S),d.delete(S)}else l.push(b)}var C=[new n([],l,this._parent,this._document),new n(h,null,this._parent,this._document),new n(d,null,this._parent,this._document),new n([],f,this._parent,this._document),new n(p,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,C)},t.prototype.merge=function(t){var e=l(l([],u(this._elements),!1),u(t._elements),!1),r=l(l([],u(this._transitions),!1),u(t._transitions),!1);return new n(e,null,this._parent,this._document,void 0,r)},t.prototype.createElement=function(t){if(this._document)return this._document.createElement(t,{});var e=n.registry[t];return e?new e:function(t){throw new Error(t)}("Unknown node type: ".concat(t))},t.prototype.join=function(t,e,n,r,i){void 0===t&&(t=function(t){return t}),void 0===e&&(e=function(t){return t}),void 0===n&&(n=function(t){return t.remove()}),void 0===r&&(r=function(t){return t}),void 0===i&&(i=function(t){return t.remove()});var o=t(this._enter),a=e(this._update),s=n(this._exit),c=r(this._merge),u=i(this._split);return a.merge(o).merge(s).merge(c).merge(u)},t.prototype.remove=function(){for(var t=function(t){var n=e._elements[t],r=e._transitions[t];r?r.then((function(){return n.remove()})):n.remove()},e=this,r=0;r<this._elements.length;r++)t(r);return new n([],null,this._parent,this._document,void 0,this._transitions)},t.prototype.each=function(t){for(var e=0;e<this._elements.length;e++){var n=this._elements[e],r=n.__data__;t.call(n,r,e)}return this},t.prototype.attr=function(t,e){var n="function"!=typeof e?function(){return e}:e;return this.each((function(r,i){void 0!==e&&(this[t]=n.call(this,r,i))}))},t.prototype.style=function(t,e,n){void 0===n&&(n=!0);var r="function"==typeof e&&n?e:function(){return e};return this.each((function(n,i){void 0!==e&&(this.style[t]=r.call(this,n,i))}))},t.prototype.styles=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!0),this.each((function(n,r){var i=this;Object.entries(t).forEach((function(t){var o=u(t,2),a=o[0],s=o[1],c="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(a,c.call(i,n,r))}))}))},t.prototype.update=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.maybeUpdate=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.transition=function(t){var e=this._transitions;return this.each((function(n,r){e[r]=t.call(this,n,r)}))},t.prototype.on=function(t,e){return this.each((function(){this.addEventListener(t,e)})),this},t.prototype.call=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.call.apply(t,l([this._parent,this],u(e),!1)),this},t.prototype.node=function(){return this._elements[0]},t.prototype.nodes=function(){return this._elements},t.prototype.transitions=function(){return this._transitions.filter((function(t){return!!t}))},t.prototype.parent=function(){return this._parent},n=t,e=new WeakSet,r=function(t,e){var r=this._elements[0],i=r.querySelector(t);if(i)return new n([i],null,this._parent,this._document);var o="string"==typeof e?this.createElement(e):e();return r.appendChild(o),new n([o],null,this._parent,this._document)},t.registry={g:Rs,rect:Fs,circle:As,path:js,text:BL,ellipse:_s,image:Is,line:Ls,polygon:zs,polyline:Bs,html:Ds},t}();function tj(t){return new JL([t],null,t,t.ownerDocument)}function ej(t){if(Wt(t))return[t,t,t,t];if(_t(t)){var e=t.length;if(1===e)return[t[0],t[0],t[0],t[0]];if(2===e)return[t[0],t[1],t[0],t[1]];if(3===e)return[t[0],t[1],t[2],t[1]];if(4===e)return t}return[0,0,0,0]}function nj(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function rj(t,e,n){var r;void 0===n&&(n=!0);var i=e||(null===(r=t.match(/^([a-z][a-z0-9]+)/))||void 0===r?void 0:r[0])||"",o=t.replace(new RegExp("^(".concat(i,")")),"");return n?function(t){return t.toString().charAt(0).toLowerCase()+t.toString().slice(1)}(o):o}var ij=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function oj(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=u(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(ij(o,"show")&&ij(rj(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(nj(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(nj(e)),"")]=a;else if(!ij(o,"show")&&ij(o,e)!==n){var s=rj(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function aj(t,e){void 0===e&&(e=["x","y","class","className"]);var n=["transform","transformOrigin","anchor","visibility","pointerEvents","zIndex","cursor","clipPath","clipPathTargets","offsetPath","offsetPathTargets","offsetDistance","draggable","droppable"],r={},i={};return Object.entries(t).forEach((function(t){var o=u(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function sj(){LL(this,"hidden"!==this.attributes.visibility)}var cj=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,UL({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return r(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=zL(this)),this._offscreen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultOptions",{get:function(){return this._defaultOptions},enumerable:!1,configurable:!0}),e.prototype.connectedCallback=function(){this.render(this.attributes,this),this.bindEvents(this.attributes,this),this.initialized=!0},e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e.prototype.attributeChangedCallback=function(t){"visibility"===t&&sj.call(this)},e.prototype.update=function(t,e){var n;return this.attr(UL({},this.attributes,t||{})),null===(n=this.render)||void 0===n?void 0:n.call(this,this.attributes,this,e)},e.prototype.clear=function(){this.removeChildren()},e.prototype.bindEvents=function(t,e){},e.prototype.getSubShapeStyle=function(t){return t.x,t.y,t.transform,t.transformOrigin,t.class,t.className,t.zIndex,o(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(Os),uj=function(t,e,n){return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"]]},lj=uj,hj=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},dj=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},fj=dj;var pj=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function gj(t){var e=function(t){var e="default";if(Rt(t)&&t instanceof Image)e="image";else if(Pt(t))e="symbol";else if(Bt(t)){var n=new RegExp("data:(image|text)");e=t.match(n)?"base64":/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(t)?"url":"symbol"}return e}(t);return["base64","url","image"].includes(e)?"image":t&&"symbol"===e?"path":null}var mj=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.render=function(t,n){var r=this.getSubShapeStyle(t),a=r.symbol,s=r.size,c=void 0===s?16:s,u=o(r,["symbol","size"]),l=gj(a);YL(!!l,tj(n),(function(t){t.maybeAppendByClassName("marker",l).attr("className","marker ".concat(l,"-marker")).call((function(t){if("image"===l){var n=2*c;t.styles({img:a,width:n,height:n,x:-c,y:-c})}else{n=c/2;var r=Pt(a)?a:e.getSymbol(a);t.styles(i({path:null==r?void 0:r(0,0,n)},u))}}))}))},e.MARKER_SYMBOL_MAP=new Map,e.registerSymbol=function(t,n){e.MARKER_SYMBOL_MAP.set(t,n)},e.getSymbol=function(t){return e.MARKER_SYMBOL_MAP.get(t)},e.getSymbols=function(){return Array.from(e.MARKER_SYMBOL_MAP.keys())},e}(cj);mj.registerSymbol("cross",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e+n],["M",t+n,e-n],["L",t-n,e+n]]})),mj.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),mj.registerSymbol("line",hj),mj.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),mj.registerSymbol("tick",(function(t,e,n){return[["M",t-n/2,e-n],["L",t+n/2,e-n],["M",t,e-n],["L",t,e+n],["M",t-n/2,e+n],["L",t+n/2,e+n]]})),mj.registerSymbol("circle",uj),mj.registerSymbol("point",lj),mj.registerSymbol("bowtie",(function(t,e,n){var r=n-1.5;return[["M",t-n,e-r],["L",t+n,e+r],["L",t+n,e-r],["L",t-n,e+r],["Z"]]})),mj.registerSymbol("hexagon",(function(t,e,n){var r=n/2*Math.sqrt(3);return[["M",t,e-n],["L",t+r,e-n/2],["L",t+r,e+n/2],["L",t,e+n],["L",t-r,e+n/2],["L",t-r,e-n/2],["Z"]]})),mj.registerSymbol("square",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]})),mj.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),mj.registerSymbol("triangle",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+r],["L",t,e-r],["L",t+n,e+r],["Z"]]})),mj.registerSymbol("triangle-down",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-r],["L",t+n,e-r],["L",t,e+r],["Z"]]})),mj.registerSymbol("line",hj),mj.registerSymbol("dot",dj),mj.registerSymbol("dash",fj),mj.registerSymbol("smooth",(function(t,e,n){return[["M",t-n,e],["A",n/2,n/2,0,1,1,t,e],["A",n/2,n/2,0,1,0,t+n,e]]})),mj.registerSymbol("hv",(function(t,e,n){return[["M",t-n-1,e-2.5],["L",t,e-2.5],["L",t,e+2.5],["L",t+n+1,e+2.5]]})),mj.registerSymbol("vh",(function(t,e,n){return[["M",t-n-1,e+2.5],["L",t,e+2.5],["L",t,e-2.5],["L",t+n+1,e-2.5]]})),mj.registerSymbol("hvh",(function(t,e,n){return[["M",t-(n+1),e+2.5],["L",t-n/2,e+2.5],["L",t-n/2,e-2.5],["L",t+n/2,e-2.5],["L",t+n/2,e+2.5],["L",t+n+1,e+2.5]]})),mj.registerSymbol("vhv",(function(t,e){return[["M",t-5,e+2.5],["L",t-5,e],["L",t,e],["L",t,e-3],["L",t,e+3],["L",t+6.5,e+3]]}));var vj=VL({text:"text"},"title");function yj(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function bj(t,e){var n=Object.entries(e).reduce((function(e,n){var r=u(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var xj=function(t){function e(e){return t.call(this,e,{text:"",width:0,height:0,fill:"#4a505a",fontWeight:"bold",fontSize:12,fontFamily:"sans-serif",inset:0,spacing:0,position:"top-left"})||this}return r(e,t),e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=t.position,i=t.spacing,o=t.inset,a=this.querySelector(vj.text.class);if(!a)return new FL(0,0,+e,+n);var s=a.getBBox(),c=s.width,l=s.height,h=u(ej(i),4),d=h[0],f=h[1],p=h[2],g=h[3],m=u([0,0,+e,+n],4),v=m[0],y=m[1],b=m[2],x=m[3],E=yj(r);if(E.includes("i"))return new FL(v,y,b,x);E.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=u(0===r?[l+p,+n-l-p]:[0,+n],2),y=i[0],x=i[1]),"r"===t&&(o=u([+e-c-g],1),b=o[0]),"b"===t&&(a=u([+n-l-d],1),x=a[0]),"l"===t&&(s=u(0===r?[c+f,+e-c-f]:[0,+e],2),v=s[0],b=s[1])}));var w=u(ej(o),4),M=w[0],N=w[1],S=w[2],C=w[3],T=u([C+N,M+S],2),P=T[0],k=T[1];return new FL(v+C,y+M,b-P,x-k)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new FL(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=o(t,["width","height","position","spacing"]),i=u(aj(r),1)[0],a=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,c=o.position,l=u([+a/2,+s/2],2),h=u([+l[0],+l[1],"center","middle"],4),d=h[0],f=h[1],p=h[2],g=h[3],m=yj(c);return m.includes("l")&&(d=(e=u([0,"start"],2))[0],p=e[1]),m.includes("r")&&(d=(n=u([+a,"end"],2))[0],p=n[1]),m.includes("t")&&(f=(r=u([0,"top"],2))[0],g=r[1]),m.includes("b")&&(f=(i=u([+s,"bottom"],2))[0],g=i[1]),{x:d,y:f,textAlign:p,textBaseline:g}}(t),s=a.x,c=a.y,l=a.textAlign,h=a.textBaseline;YL(!!r.text,tj(e),(function(t){n.title=t.maybeAppendByClassName(vj.text,"text").styles(i).call(bj,{x:s,y:c,textAlign:l,textBaseline:h}).node()}))},e}(cj),Ej=VL({prevBtnGroup:"prev-btn-group",prevBtn:"prev-btn",nextBtnGroup:"next-btn-group",nextBtn:"next-btn",pageInfoGroup:"page-info-group",pageInfo:"page-info",playWindow:"play-window",contentGroup:"content-group",controller:"controller",clipPath:"clip-path"},"navigator"),wj=function(t){function e(e){var n=t.call(this,e,{animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonPath:pj(0,0,6),buttonSize:12,controllerPadding:5,controllerSpacing:5,formatter:function(t,e){return"".concat(t,"/").concat(e)},defaultPage:0,loop:!1,orientation:"horizontal",pageNumFill:"black",pageNumFontSize:12,pageNumTextAlign:"start",pageNumTextBaseline:"middle"})||this;return n.playState="idle",n.contentGroup=n.appendChild(new Rs({class:Ej.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new Rs({class:Ej.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return r(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return Vt(t,0,Math.max(this.pageViews.length-1,0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.playWindow.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controllerShape",{get:function(){return this.totalPages>1?{width:55,height:0}:{width:0,height:0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageShape",{get:function(){var t=u(function(t){var e;return(null===(e=t[0])||void 0===e?void 0:e.map((function(e,n){return t.map((function(t){return t[n]}))})))||[]}(this.pageViews.map((function(t){var e=t.getBBox();return[e.width,e.height]}))).map((function(t){return Math.max.apply(Math,l([],u(t),!1))})),2),e=t[0],n=t[1],r=this.attributes,i=r.pageWidth,o=void 0===i?e:i,a=r.pageHeight;return{pageWidth:o,pageHeight:void 0===a?n:a}},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.playWindow},Object.defineProperty(e.prototype,"totalPages",{get:function(){return this.pageViews.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.innerCurrPage},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e=t.prototype.getBBox.call(this),n=e.x,r=e.y,i=this.controllerShape,o=this.pageShape,a=o.pageWidth,s=o.pageHeight;return new FL(n,r,a+i.width,s)},e.prototype.goTo=function(t){var e=this,n=this.attributes.animate,r=this,i=r.currPage,o=r.playState,a=r.playWindow,s=r.pageViews;if("idle"!==o||t<0||s.length<=0||t>=s.length)return null;s[i].setLocalPosition(0,0),this.prepareFollowingPage(t);var c=u(this.getFollowingPageDiff(t),2),l=c[0],h=c[1];this.playState="running";var d,f,p,g=(d=a,f=[{transform:"translate(0, 0)"},{transform:"translate(".concat(-l,", ").concat(-h,")")}],p=n,0===f.length?null:p?d.animate(f,p):(function(t,e){"update"in t?t.update(e):t.attr(e)}(d,{style:f.slice(-1)[0]}),null));return function(t,e){t?t.finished.then(e):e()}(g,(function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()})),g},e.prototype.prev=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n<=0)return null;var r=t?(n-1+e)%e:Vt(n-1,0,e);return this.goTo(r)},e.prototype.next=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n>=e-1)return null;var r=t?(n+1)%e:Vt(n+1,0,e);return this.goTo(r)},e.prototype.renderClipPath=function(t){var e=this.pageShape,n=e.pageWidth,r=e.pageHeight;n&&r?(this.clipPath=t.maybeAppendByClassName(Ej.clipPath,"rect").styles({width:n,height:r}),this.contentGroup.attr("clipPath",this.clipPath.node())):this.contentGroup.style.clipPath=void 0},e.prototype.setVisiblePages=function(t){this.playWindow.children.forEach((function(e,n){t.includes(n)?LL(e,!0):IL(e)}))},e.prototype.adjustControllerLayout=function(){var t=this,e=t.prevBtnGroup,n=t.nextBtnGroup,r=t.pageInfoGroup,i=this.attributes,o=i.orientation,a=i.controllerPadding,s=r.getBBox(),c=s.width;s.height;var l=u("horizontal"===o?[-180,0]:[-90,90],2),h=l[0],d=l[1];e.setLocalEulerAngles(h),n.setLocalEulerAngles(d);var f=e.getBBox(),p=f.width,g=f.height,m=n.getBBox(),v=m.width,y=m.height,b=Math.max(p,c,v),x="horizontal"===o?{offset:[[0,0],[p/2+a,0],[p+c+2*a,0]],textAlign:"start"}:{offset:[[b/2,-g-a],[b/2,0],[b/2,y+a]],textAlign:"center"},E=u(x.offset,3),w=u(E[0],2),M=w[0],N=w[1],S=u(E[1],2),C=S[0],T=S[1],P=u(E[2],2),k=P[0],A=P[1],O=x.textAlign,_=r.querySelector("text");_&&(_.style.textAlign=O),e.setLocalPosition(M,N),r.setLocalPosition(C,T),n.setLocalPosition(k,A)},e.prototype.updatePageInfo=function(){var t,e=this,n=e.currPage,r=e.pageViews,i=e.attributes.formatter;r.length<2||(null===(t=this.pageInfoGroup.querySelector(Ej.pageInfo.class))||void 0===t||t.attr("text",i(n+1,r.length)),this.adjustControllerLayout())},e.prototype.getFollowingPageDiff=function(t){var e=this.currPage;if(e===t)return[0,0];var n=this.attributes.orientation,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=t<e?-1:1;return"horizontal"===n?[a*i,0]:[0,a*o]},e.prototype.prepareFollowingPage=function(t){var e=this.currPage,n=this.pageViews;if(this.setVisiblePages([t,e]),t!==e){var r=u(this.getFollowingPageDiff(t),2),i=r[0],o=r[1];n[t].setLocalPosition(i,o)}},e.prototype.renderController=function(t){var e=this,n=this.attributes.controllerSpacing,r=this.pageShape,a=r.pageWidth,s=r.pageHeight,c=this.pageViews.length>=2,l=t.maybeAppendByClassName(Ej.controller,"g");if(LL(l.node(),c),c){var h=oj(this.attributes,"button"),d=oj(this.attributes,"pageNum"),f=u(aj(h),2),p=f[0],g=f[1],m=p.size,v=o(p,["size"]),y=!l.select(Ej.prevBtnGroup.class).node(),b=l.maybeAppendByClassName(Ej.prevBtnGroup,"g").styles(g);this.prevBtnGroup=b.node();var x=b.maybeAppendByClassName(Ej.prevBtn,"path"),E=l.maybeAppendByClassName(Ej.nextBtnGroup,"g").styles(g);this.nextBtnGroup=E.node(),[x,E.maybeAppendByClassName(Ej.nextBtn,"path")].forEach((function(t){t.styles(i(i({},v),{transformOrigin:"center"})),QL(t.node(),m,!0)}));var w=l.maybeAppendByClassName(Ej.pageInfoGroup,"g");this.pageInfoGroup=w.node(),w.maybeAppendByClassName(Ej.pageInfo,"text").styles(d),this.updatePageInfo(),l.node().setLocalPosition(a+n,s/2),y&&(this.prevBtnGroup.addEventListener("click",(function(){e.prev()})),this.nextBtnGroup.addEventListener("click",(function(){e.next()})))}},e.prototype.render=function(t,e){var n=tj(e);this.renderClipPath(n),this.renderController(n),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=te((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(Za.INSERTED,e),this.playWindow.addEventListener(Za.REMOVED,e)},e}(cj);function Mj(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}mj.registerSymbol("hiddenHandle",(function(t,e,n){var r=1.4*n;return[["M",t-n,e-r],["L",t+n,e-r],["L",t+n,e+r],["L",t-n,e+r],["Z"]]})),mj.registerSymbol("verticalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=t+.4*r;return[["M",t,e],["L",a,e+i],["L",t+r,e+i],["L",t+r,e-i],["L",a,e-i],["Z"],["M",a,e+o],["L",t+r-2,e+o],["M",a,e-o],["L",t+r-2,e-o]]})),mj.registerSymbol("horizontalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=e+.4*r;return[["M",t,e],["L",t-i,a],["L",t-i,e+r],["L",t+i,e+r],["L",t+i,a],["Z"],["M",t-o,a],["L",t-o,e+r-2],["M",t+o,a],["L",t+o,e+r-2]]}));var Nj=VL({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item");var Sj=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new As({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return r(e,t),Object.defineProperty(e.prototype,"showValue",{get:function(){var t=this.attributes.valueText;return!!t&&("string"==typeof t||"number"==typeof t?""!==t:"function"==typeof t||""!==t.attr("text"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"actualSpace",{get:function(){var t=this.labelGroup,e=this.valueGroup,n=this.attributes.markerSize,r=t.node().getBBox(),i=r.width,o=r.height,a=e.node().getBBox(),s=a.width,c=a.height;return{markerWidth:n,labelWidth:i,valueWidth:s,height:Math.max(n,o,c)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=u(ej(t),2),n=e[0],r=e[1],i=this.showValue?r:0,o=n+i;return[n/o,i/o]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t,e=this.attributes,n=e.markerSize,r=e.width,i=this.actualSpace,o=i.markerWidth,a=i.height,s=this.actualSpace,c=s.labelWidth,l=s.valueWidth,h=u(this.spacing,2),d=h[0],f=h[1];if(r){var p=r-n-d-f,g=u(this.span,2);c=(t=u([g[0]*p,g[1]*p],2))[0],l=t[1]}return{width:o+c+l+d+f,height:a,markerWidth:o,labelWidth:c,valueWidth:l}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=u(ej(t),2),n=e[0],r=e[1];return this.showValue?[n,r]:[n,0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layout",{get:function(){var t=this.shape,e=t.markerWidth,n=t.labelWidth,r=t.valueWidth,i=t.width,o=t.height,a=u(this.spacing,2),s=a[0];return{height:o,width:i,markerWidth:e,labelWidth:n,valueWidth:r,position:[e/2,e+s,e+n+s+a[1]]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(Nj.marker.class);return e?e.style:{}}(this.markerGroup.node()),e=this.attributes,n=e.markerSize,r=e.markerStrokeWidth,i=void 0===r?t.strokeWidth:r,o=e.markerLineWidth,a=void 0===o?t.lineWidth:o,s=e.markerStroke,c=void 0===s?t.stroke:s,u=+(i||a||(c?1:0))*Math.sqrt(2),l=this.markerGroup.node().getBBox(),h=l.width,d=l.height;return(1-u/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=oj(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(Nj.markerGroup,"g").style("zIndex",0),YL(!!n,this.markerGroup,(function(){var t,o=e.markerGroup.node(),a=null===(t=o.childNodes)||void 0===t?void 0:t[0],s="string"==typeof n?new mj({style:{symbol:n},className:Nj.marker.name}):n();a?s.nodeName===a.nodeName?a instanceof mj?a.update(i(i({},r),{symbol:n})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=c(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=u(a.value,2),l=s[0],h=s[1];"id"!==l&&"className"!==l&&t.attr(l,h)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(a,s),tj(a).styles(r)):(a.remove(),tj(s).attr("className",Nj.marker.name).styles(r),o.appendChild(s)):(s instanceof mj||tj(s).attr("className",Nj.marker.name).styles(r),o.appendChild(s)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]),QL(e.markerGroup.node(),e.scaleSize,!0)}))},e.prototype.renderLabel=function(t){var e=oj(this.attributes,"label"),n=e.text,r=o(e,["text"]);this.labelGroup=t.maybeAppendByClassName(Nj.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(Nj.label,(function(){return qL(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=oj(this.attributes,"value"),r=n.text,i=o(n,["text"]);this.valueGroup=t.maybeAppendByClassName(Nj.valueGroup,"g").style("zIndex",0),YL(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(Nj.value,(function(){return qL(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,o=oj(this.attributes,"background");this.background=t.maybeAppendByClassName(Nj.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(Nj.background,"rect").styles(i({width:n,height:r},o))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=u(t.position,3),o=i[0],a=i[1],s=i[2],c=r/2;this.markerGroup.styles({x:o,y:c}),this.labelGroup.styles({x:a,y:c}),$L(this.labelGroup.select(Nj.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({x:s,y:c}),$L(this.valueGroup.select(Nj.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=tj(e);this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.adjustLayout()},e}(cj),Cj=VL({page:"item-page",navigator:"navigator",item:"item"},"items"),Tj=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},Pj=function(t){function e(e){var n=t.call(this,e,{data:[],gridRow:1/0,gridCol:void 0,padding:0,width:1e3,height:100,rowPadding:0,colPadding:0,layout:"flex",orientation:"horizontal",click:fe,mouseenter:fe,mouseleave:fe})||this;return n.navigatorShape=[0,0],n}return r(e,t),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.navigator.getContainer()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){var t=this.attributes,e=t.gridRow,n=t.gridCol,r=t.data;if(!e&&!n)throw new Error("gridRow and gridCol can not be set null at the same time");return e&&n?[e,n]:e?[e,r.length]:[r.length,n]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderData",{get:function(){var t=this.attributes,e=t.data,n=t.layout,r=oj(this.attributes,"item"),o=e.map((function(t,o){var a=t.id,s=void 0===a?o:a,c=t.label,h=t.value;return{id:"".concat(s),index:o,style:i({layout:n,labelText:c,valueText:h},Object.fromEntries(Object.entries(r).map((function(n){var r,i,a=u(n,2),s=a[0],c=a[1];return[s,(r=c,i=[t,o,e],Pt(r)?r.apply(void 0,l([],u(i),!1)):r)]}))))}}));return o},enumerable:!1,configurable:!0}),e.prototype.getGridLayout=function(){var t=this,e=this.attributes,n=e.orientation,r=e.width,i=e.rowPadding,o=e.colPadding,a=u(this.navigatorShape,1)[0],s=u(this.grid,2),c=s[0],l=s[1],h=l*c,d=0;return this.pageViews.children.map((function(e,s){var f,p,g=Math.floor(s/h),m=s%h,v=t.ifHorizontal(l,c),y=[Math.floor(m/v),m%v];"vertical"===n&&y.reverse();var b=u(y,2),x=b[0],E=b[1],w=(r-a-(l-1)*o)/l,M=e.getBBox().height,N=u([0,0],2),S=N[0],C=N[1];return"horizontal"===n?(S=(f=u([d,x*(M+i)],2))[0],C=f[1],d=E===l-1?0:d+w+o):(S=(p=u([E*(w+o),d],2))[0],C=p[1],d=x===c-1?0:d+M+i),{page:g,index:s,row:x,col:E,pageIndex:m,width:w,height:M,x:S,y:C}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=u(this.navigatorShape,1)[0],a=u(this.grid,2),s=a[0],c=a[1],l=u([e-o,n],2),h=l[0],d=l[1],f=u([0,0,0,0,0,0,0,0],8),p=f[0],g=f[1],m=f[2],v=f[3],y=f[4],b=f[5],x=f[6],E=f[7];return this.pageViews.children.map((function(t,e){var n,o,a,l,f=t.getBBox(),w=f.width,M=f.height,N=0===x?0:i,S=x+N+w;return S<=h&&Tj(y,(function(t){return t<c}))?(n=u([x+N,E,S],3),p=n[0],g=n[1],x=n[2],{width:w,height:M,x:p,y:g,page:m,index:e,pageIndex:v++,row:b,col:y++}):(o=u([b+1,0,0,E+M+r],4),b=o[0],y=o[1],x=o[2],(E=o[3])+M<=d&&Tj(b,(function(t){return t<s}))?(a=u([x,E,w],3),p=a[0],g=a[1],x=a[2],{width:w,height:M,x:p,y:g,page:m,index:e,pageIndex:v++,row:b,col:y++}):(l=u([0,0,w,0,m+1,0,0,0],8),p=l[0],g=l[1],x=l[2],E=l[3],m=l[4],v=l[5],b=l[6],y=l[7],{width:w,height:M,x:p,y:g,page:m,index:e,pageIndex:v++,row:b,col:y++}))}))},Object.defineProperty(e.prototype,"itemsLayout",{get:function(){this.navigatorShape=[0,0];var t="grid"===this.attributes.layout?this.getGridLayout:this.getFlexLayout,e=t.call(this);return e.slice(-1)[0].page>0?(this.navigatorShape=[55,0],t.call(this)):e},enumerable:!1,configurable:!0}),e.prototype.ifHorizontal=function(t,e){return Mj(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(Cj.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(Cj.page.class).forEach((function(e){t.removeChild(e).destroy()}))},e.prototype.renderItems=function(t){var e=this.attributes,n=e.click,r=e.mouseenter,i=e.mouseleave;this.flattenPage(t);var o=this.dispatchCustomEvent.bind(this);tj(t).selectAll(Cj.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new Sj({style:e})})).attr("className",Cj.item.name).on("click",(function(){null==n||n(this),o("itemClick",{item:this})})).on("pointerenter",(function(){null==r||r(this),o("itemMouseenter",{item:this})})).on("pointerleave",(function(){null==i||i(this),o("itemMouseleave",{item:this})}))}),(function(t){return t.each((function(t){var e=t.style;this.update(e)}))}),(function(t){return t.remove()}))},e.prototype.relayoutNavigator=function(){var t,e=this.attributes,n=e.layout,r=e.width,i=(null===(t=this.pageViews.children[0])||void 0===t?void 0:t.getBBox().height)||0,o=u(this.navigatorShape,2),a=o[0],s=o[1];this.navigator.update("grid"===n?{pageWidth:r-a,pageHeight:i-s}:{})},e.prototype.adjustLayout=function(){var t,e,n=this,r=Object.entries((t=this.itemsLayout,e="page",t.reduce((function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t}),{}))).map((function(t){var e=u(t,2);return{page:e[0],layouts:e[1]}})),i=l([],u(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new Rs({className:Cj.page.name}));e.forEach((function(t){var e=t.x,n=t.y,o=t.index,a=t.width,s=t.height,c=i[o];r.appendChild(c),ce(c,"__layout__",t),c.update({x:e,y:n,width:a,height:s})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=oj(this.attributes,"nav"),r=UL({orientation:e},n),i=this;return t.selectAll(Cj.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new wj({style:r})})).attr("className",Cj.navigator.name).each((function(){i.navigator=this}))}),(function(t){return t.each((function(){this.update(r)}))}),(function(t){return t.remove()})),this.navigator},e.prototype.getBBox=function(){return this.navigator.getBBox()},e.prototype.render=function(t,e){var n=this.attributes.data;if(n&&0!==n.length){var r=this.renderNavigator(tj(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new $a(t,{detail:e});this.dispatchEvent(n)},e}(cj),kj=VL({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),Aj={showLabel:!0,formatter:function(t){return t.toString()},markerSize:25,markerStroke:"#c5c5c5",markerFill:"#fff",markerLineWidth:1,labelFontSize:12,labelFill:"#c5c5c5",labelText:"",orientation:"vertical",spacing:0};!function(t){function e(e){return t.call(this,e,Aj)||this}r(e,t),e.prototype.render=function(t,e){var n=tj(e).maybeAppendByClassName(kj.markerGroup,"g");this.renderMarker(n);var r=tj(e).maybeAppendByClassName(kj.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,o=n.markerSymbol,a=void 0===o?Mj(r,"horizontalHandle","verticalHandle"):o;YL(!!a,t,(function(t){var n=oj(e.attributes,"marker"),r=i({symbol:a},n);e.marker=t.maybeAppendByClassName(kj.marker,(function(){return new mj({style:r})})).update(r)}))},e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.showLabel,a=n.orientation,s=n.spacing,c=void 0===s?0:s,l=n.formatter;YL(r,t,(function(t){var n,r=oj(e.attributes,"label"),s=r.text,h=o(r,["text"]),d=(null===(n=t.select(kj.marker.class))||void 0===n?void 0:n.node().getBBox())||{},f=d.width,p=void 0===f?0:f,g=d.height,m=u(Mj(a,[0,(void 0===g?0:g)+c,"center","top"],[p+c,0,"start","middle"]),4),v=m[0],y=m[1],b=m[2],x=m[3];t.maybeAppendByClassName(kj.label,"text").styles(i(i({},h),{x:v,y:y,text:l(s).toString(),textAlign:b,textBaseline:x}))}))}}(cj);var Oj,_j,Rj={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},Dj=UL({},Rj,{});UL({},Rj,(Oj=Aj,_j="handle",Object.entries(Oj).reduce((function(t,e){var n=u(e,2),r=n[0],i=n[1];return r.startsWith("show")?t["show".concat(_j).concat(r.slice(4))]=i:t["".concat(_j).concat(nj(r))]=i,t}),{})),{color:["#d0e3fa","#acc7f6","#8daaf2","#6d8eea","#4d73cd","#325bb1","#5a3e75","#8c3c79","#e23455","#e7655b"],indicatorBackgroundFill:"#262626",indicatorLabelFill:"white",indicatorLabelFontSize:12,indicatorVisibility:"hidden",labelAlign:"value",labelDirection:"positive",labelSpacing:5,showHandle:!0,showIndicator:!0,showLabel:!0,slidable:!0,titleText:"",type:"continuous"});var Ij=VL({title:"title",titleGroup:"title-group",items:"items",itemsGroup:"items-group",contentGroup:"content-group",ribbonGroup:"ribbon-group",ribbon:"ribbon",handlesGroup:"handles-group",handle:"handle",startHandle:"start-handle",endHandle:"end-handle",labelGroup:"label-group",label:"label",indicator:"indicator"},"legend"),Lj=function(t){function e(e){return t.call(this,e,Dj)||this}return r(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,o=r.showTitle,a=r.titleText,s=u(aj(oj(this.attributes,"title")),2),c=s[0],l=s[1];this.titleGroup=t.maybeAppendByClassName(Ij.titleGroup,"g").styles(l);var h=i(i({width:e,height:n},c),{text:o?a:""});this.title=this.titleGroup.maybeAppendByClassName(Ij.title,(function(){return new xj({style:h})})).update(h)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,o=e.width,a=e.height,s=u(aj(oj(this.attributes,"title",!0)),2),c=s[0],l=s[1],h=i(i({},c),{width:o,height:a,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(Ij.itemsGroup,"g").styles(i({x:n,y:r},l));var d=this;this.itemsGroup.selectAll(Ij.items.class).data(["items"]).join((function(t){return t.append((function(){return new Pj({style:h})})).attr("className",Ij.items.name).each((function(){d.items=tj(this)}))}),(function(t){return t.update(h)}),(function(t){return t.remove()}))},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().setLocalPosition(e,n)}},Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes,e=t.showTitle,n=t.width,r=t.height;return e?this.title.node().getAvailableSpace():new FL(0,0,n,r)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e,n,r=null===(e=this.title)||void 0===e?void 0:e.node(),i=null===(n=this.items)||void 0===n?void 0:n.node();return r&&i?function(t,e){var n=t.attributes,r=n.position,i=n.spacing,o=n.inset,a=n.text,s=t.getBBox(),c=e.getBBox(),l=yj(r),h=u(ej(a?i:0),4),d=h[0],f=h[1],p=h[2],g=h[3],m=u(ej(o),4),v=m[0],y=m[1],b=m[2],x=m[3],E=u([g+f,d+p],2),w=E[0],M=E[1],N=u([x+y,v+b],2),S=N[0],C=N[1];if("l"===l[0])return new FL(s.x,s.y,c.width+s.width+w+S,Math.max(c.height+C,s.height));if("t"===l[0])return new FL(s.x,s.y,Math.max(c.width+S,s.width),c.height+s.height+M+C);var T=u([e.attributes.width||c.width,e.attributes.height||c.height],2),P=T[0],k=T[1];return new FL(c.x,c.y,P+s.width+w+S,k+s.height+M+C)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=t.width,r=t.height,i=tj(e);this.renderTitle(i,n,r),this.renderItems(i,this.availableSpace),this.adjustLayout()},e}(cj);function jj(t){return void 0===t&&(t=""),{CONTAINER:"".concat(t,"tooltip"),TITLE:"".concat(t,"tooltip-title"),LIST:"".concat(t,"tooltip-list"),LIST_ITEM:"".concat(t,"tooltip-list-item"),NAME:"".concat(t,"tooltip-list-item-name"),MARKER:"".concat(t,"tooltip-list-item-marker"),NAME_LABEL:"".concat(t,"tooltip-list-item-name-label"),VALUE:"".concat(t,"tooltip-list-item-value"),CROSSHAIR_X:"".concat(t,"tooltip-crosshair-x"),CROSSHAIR_Y:"".concat(t,"tooltip-crosshair-y")}}var zj={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function Bj(t){var e;void 0===t&&(t="");var n=jj(t);return(e={})[".".concat(n.CONTAINER)]={position:"absolute",visibility:"visible","z-index":8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)","background-color":"rgba(255, 255, 255, 0.96)","box-shadow":"0 6px 12px 0 rgba(0, 0, 0, 0.12)","border-radius":"4px",color:"rgba(0, 0, 0, 0.65)","font-size":"12px","line-height":"20px",padding:"12px","min-width":"120px","max-width":"360px","font-family":"Roboto-Regular"},e[".".concat(n.TITLE)]={color:"rgba(0, 0, 0, 0.45)"},e[".".concat(n.LIST)]={margin:"0px","list-style-type":"none",padding:"0px"},e[".".concat(n.LIST_ITEM)]={"list-style-type":"none",display:"flex","line-height":"2em","align-items":"center","justify-content":"space-between","white-space":"nowrap"},e[".".concat(n.MARKER)]={width:"8px",height:"8px","border-radius":"50%",display:"inline-block","margin-right":"4px"},e[".".concat(n.NAME)]={display:"flex","align-items":"center","max-width":"216px"},e[".".concat(n.NAME_LABEL)]=i({flex:1},zj),e[".".concat(n.VALUE)]=i({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},zj),e[".".concat(n.CROSSHAIR_X)]={position:"absolute",width:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e[".".concat(n.CROSSHAIR_Y)]={position:"absolute",height:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e}var Fj=function(t){function e(e){var n,r,i=this,o=null===(r=null===(n=e.style)||void 0===n?void 0:n.template)||void 0===r?void 0:r.prefixCls,a=jj(o);return(i=t.call(this,e,{data:[],x:0,y:0,visibility:"visible",title:"",position:"bottom-right",offset:[5,5],enterable:!1,container:{x:0,y:0},bounding:null,template:{prefixCls:"",container:'<div class="'.concat(a.CONTAINER,'"></div>'),title:'<div class="'.concat(a.TITLE,'"></div>'),item:'<li class="'.concat(a.LIST_ITEM,'" data-index={index}>\n <span class="').concat(a.NAME,'">\n <span class="').concat(a.MARKER,'" style="background:{color}"></span>\n <span class="').concat(a.NAME_LABEL,'" title="{name}">{name}</span>\n </span>\n <span class="').concat(a.VALUE,'" title="{value}">{value}</span>\n </li>')},style:Bj(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return r(e,t),Object.defineProperty(e.prototype,"HTMLTooltipElement",{get:function(){return this.element},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.element},Object.defineProperty(e.prototype,"elementSize",{get:function(){return{width:this.element.offsetWidth,height:this.element.offsetHeight}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"HTMLTooltipItemsElements",{get:function(){var t=this.attributes,e=t.data,n=t.template;return e.map((function(t,e){var r=t.name,a=void 0===r?"":r,s=t.color,c=void 0===s?"black":s,u=t.index,l=o(t,["name","color","index"]),h=i({name:a,color:c,index:null!=u?u:e},l);return Ze(function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,(function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]})):t}(n.item,h))}))},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.renderHTMLTooltipElement(),this.updatePosition()},e.prototype.destroy=function(){var e;null===(e=this.element)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.show=function(t,e){var n=this;if(void 0!==t&&void 0!==e){var r=function(){n.attributes.x=null!=t?t:n.attributes.x,n.attributes.y=null!=e?e:n.attributes.y,n.updatePosition()};"hidden"===this.element.style.visibility?this.closeTransition(r):r()}this.element.style.visibility="visible"},e.prototype.hide=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.attributes.enterable&&this.isCursorEntered(t,e)||(this.element.style.visibility="hidden")},e.prototype.initShape=function(){var t=this.attributes.template;this.element=Ze(t.container),this.id&&this.element.setAttribute("id",this.id)},e.prototype.renderCustomContent=function(){if(void 0===this.prevCustomContentKey||this.prevCustomContentKey!==this.attributes.contentKey){this.prevCustomContentKey=this.attributes.contentKey;var t=this.attributes.content;t&&("string"==typeof t?this.element.innerHTML=t:this.element.replaceChildren(t))}},e.prototype.renderHTMLTooltipElement=function(){var t,e,n=this.attributes,r=n.template,i=n.title,o=n.enterable,a=n.style,s=n.content,c=jj(r.prefixCls),h=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(h.innerHTML=r.title,h.getElementsByClassName(c.TITLE)[0].innerHTML=i):null===(e=null===(t=h.getElementsByClassName(c.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var d=this.HTMLTooltipItemsElements,f=document.createElement("ul");f.className=c.LIST,f.replaceChildren.apply(f,l([],u(d),!1));var p=this.element.querySelector(".".concat(c.LIST));p?p.replaceWith(f):h.appendChild(f)}!function(t,e){Object.entries(e).forEach((function(e){var n=u(e,2),r=n[0],i=n[1];l([t],u(t.querySelectorAll(r)),!1).filter((function(t){return t.matches(r)})).forEach((function(t){t&&(t.style.cssText+=Object.entries(i).reduce((function(t,e){return"".concat(t).concat(e.join(":"),";")}),""))}))}))}(h,a)},e.prototype.getRelativeOffsetFromCursor=function(t){var e=this.attributes,n=e.position,r=e.offset,i=(t||n).split("-"),o={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]},a=this.elementSize,s=a.width,c=a.height,l=[-s/2,-c/2];return i.forEach((function(t){var e=u(l,2),n=e[0],i=e[1],a=u(o[t],2),h=a[0],d=a[1];l=[n+(s/2+r[0])*h,i+(c/2+r[1])*d]})),l},e.prototype.setOffsetPosition=function(t){var e=u(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=void 0===o?0:o,s=i.y,c=void 0===s?0:s,l=i.container,h=l.x,d=l.y;this.element.style.left="".concat(+a+h+n,"px"),this.element.style.top="".concat(+c+d+r,"px")},e.prototype.updatePosition=function(){var t=this.attributes.showDelay,e=void 0===t?60:t,n=Date.now();this.timestamp>0&&n-this.timestamp<e||(this.timestamp=n,this.setOffsetPosition(this.autoPosition(this.getRelativeOffsetFromCursor())))},e.prototype.autoPosition=function(t){var e=u(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=i.y,s=i.bounding,c=i.position;if(!s)return[n,r];var l=this.element,h=l.offsetWidth,d=l.offsetHeight,f=u([+o+n,+a+r],2),p=f[0],g=f[1],m={left:"right",right:"left",top:"bottom",bottom:"top"},v=s.x,y=s.y,b={left:p<v,right:p+h>v+s.width,top:g<y,bottom:g+d>y+s.height},x=[];c.split("-").forEach((function(t){b[t]?x.push(m[t]):x.push(t)}));var E=x.join("-");return this.getRelativeOffsetFromCursor(E)},e.prototype.isCursorEntered=function(t,e){if(this.element){var n=this.element.getBoundingClientRect(),r=n.x,i=n.y,o=n.width,a=n.height;return new FL(r,i,o,a).isPointIn(t,e)}return!1},e.prototype.closeTransition=function(t){var e=this,n=this.element.style.transition;this.element.style.transition="none",t(),setTimeout((function(){e.element.style.transition=n}),10)},e.tag="tooltip",e}(cj),Gj=function(t){function e(e){var n=t.call(this,e)||this;n.layoutEvents=[Za.BOUNDS_CHANGED,Za.INSERTED,Za.REMOVED],n.$margin=ej(0),n.$padding=ej(0);var r=e.style||{},i=r.margin,o=void 0===i?0:i,a=r.padding,s=void 0===a?0:a;return n.margin=o,n.padding=s,n.isMutationObserved=!0,n.bindEvents(),n}return r(e,t),Object.defineProperty(e.prototype,"margin",{get:function(){return this.$margin},set:function(t){this.$margin=ej(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return this.$padding},set:function(t){this.$padding=ej(t)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var t=this.attributes,e=t.x,n=void 0===e?0:e,r=t.y,i=void 0===r?0:r,o=t.width,a=t.height,s=u(this.$margin,4),c=s[0],l=s[1],h=s[2],d=s[3];return new FL(n-d,i-c,o+d+l,a+c+h)},e.prototype.appendChild=function(e,n){return e.isMutationObserved=!0,t.prototype.appendChild.call(this,e,n),e},e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=u(this.$padding,4),i=r[0],o=r[1],a=r[2],s=r[3],c=u(this.$margin,4),l=c[0],h=c[3];return new FL(s+h,i+l,e-s-o,n-i-a)},e.prototype.layout=function(){if(this.attributes.display&&this.isConnected&&!this.children.some((function(t){return!t.isConnected})))try{var t=function(t,e,n){if(0===e.length)return[];var r={flex:XL,grid:ZL},i=n.display in r?r[n.display]:null;return(null==i?void 0:i.call(null,t,e,n))||[]}(this.getAvailableSpace(),this.children.map((function(t){return t.getBBox()})),this.attributes);this.children.forEach((function(e,n){var r=t[n],i=r.x,o=r.y;e.attr({x:i,y:o})}))}catch(t){}},e.prototype.bindEvents=function(){var t=this;this.layoutEvents.forEach((function(e){t.addEventListener(e,(function(e){e.target.isMutationObserved=!0,t.layout()}))}))},e.prototype.attributeChangedCallback=function(t,e,n){"margin"===t?this.margin=n:"padding"===t&&(this.padding=n),this.layout()},e}(Rs);class Vj extends YI{static defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16};typePrefix="__data__";element=null;draw=!1;fieldMap={node:new Map,edge:new Map,combo:new Map};selectedItems=[];constructor(t,e){super(t,Object.assign({},Vj.defaultOptions,e)),this.bindEvents()}update(t){super.update(t),this.clear(),this.createElement()}clear(){this.element?.destroy(),this.element=null,this.draw=!1}bindEvents=()=>{const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.createElement)};changeState=(t,e)=>{const{graph:n}=this.context,{typePrefix:r}=this,i=se(t,[r,"id"]),o=se(t,[r,"style","labelText"]),[a]=i.split("__"),s=this.fieldMap[a].get(o)||[];n.setElementState(Object.fromEntries(s?.map((t=>[t,e]))))};click=t=>{if("hover"===this.options.trigger)return;const e=se(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?(this.selectedItems=this.selectedItems.filter((t=>t!==e)),this.changeState(t,[])):(this.selectedItems.push(e),this.changeState(t,"selected"))};mouseleave=t=>{"click"!==this.options.trigger&&(this.selectedItems=[],this.changeState(t,[]))};mouseenter=t=>{if("click"===this.options.trigger)return;const e=se(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?this.selectedItems=this.selectedItems.filter((t=>t!==e)):(this.selectedItems.push(e),this.changeState(t,"active"))};updateElement(){if(!this.element)return;this.element.getChildByIndex(0).update({itemMarkerOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5,itemLabelOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5})}setFieldMap=(t,e,n)=>{if(!t)return;const r=this.fieldMap[n];if(r)if(r.has(t)){const n=r.get(t);n&&(n.push(e),r.set(t,n))}else r.set(t,[e])};getEvents=()=>({mouseenter:this.mouseenter,mouseleave:this.mouseleave,click:this.click});getMarkerData=(t,e)=>{if(!t)return[];const{model:n,element:r,graph:i}=this.context,{nodes:o,edges:a,combos:s}=n.getData(),c={},u=e=>Pt(t)?t(e):t,l={node:"circle",edge:"line",combo:"rect"},h={circle:"circle",ellipse:"circle",image:"bowtie",rect:"square",star:"cross",triangle:"triangle",diamond:"diamond",cubic:"dot",line:"hyphen",polyline:"hyphen",quadratic:"hv","cubic-horizontal":"hyphen","cubic-vertical":"line"},d=(t,e)=>{t.forEach((t=>{const{id:n}=t,i=se(t,["data",u(t)]),o=r?.getElementType(e,t)||"circle",{color:a="#1783ff"}=((t,e)=>{const n=r?.getElementComputedStyle(t,e);return n})(e,t);n&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),c[i]||(c[i]={id:`${e}__${n}`,label:i,marker:h[o]||l[e],elementType:e,lineWidth:1,stroke:a,fill:a}))}))};switch(e){case"node":d(o,"node");break;case"edge":d(a,"edge");break;case"combo":d(s,"combo");break;default:return[]}return Object.values(c)};layout=t=>{let{flexDirection:e,alignItems:n,justifyContent:r}={flexDirection:"row",alignItems:"flex-end",justifyContent:"center"};const i={top:["row","flex-start","center"],bottom:["row","flex-end","center"],left:["column","flex-start","center"],right:["column","flex-end","center"]};return t in i&&([e,n,r]=i[t]),{display:"flex",flexDirection:e,justifyContent:r,alignItems:n}};createElement=()=>{if(this.draw)return void this.updateElement();const{canvas:t}=this.context,[e,n]=t.getSize(),{width:r=e,height:i=n,nodeField:o,edgeField:a,comboField:s,trigger:c,position:u,...l}=this.options,h=this.getMarkerData(o,"node"),d=this.getMarkerData(a,"edge"),f=this.getMarkerData(s,"combo"),p=[...h,...f,...d],g=this.layout(u),m=new Gj({style:{width:r,height:i,...g}}),v={width:r,height:i,data:p,itemMarkerLineWidth:({lineWidth:t})=>t,itemMarker:({marker:t})=>t,itemMarkerStroke:({stroke:t})=>t,itemMarkerFill:({fill:t})=>t,gridCol:h.length,...l,...this.getEvents()},y=new Lj({className:"legend",style:v});m.appendChild(y),t.appendChild(m),this.element=m,this.draw=!0};destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}class Wj extends YI{static defaultOptions={position:"top-left",enable:!0};$element=ZI("toolbar",!1);constructor(t,e){super(t,Object.assign({},Wj.defaultOptions,e));const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),QI("g6-toolbar-css","style",{},"\n .g6-toolbar {\n position: absolute;\n z-index: 100;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);\n opacity: 0.65;\n } \n .g6-toolbar .g6-toolbar-item {\n display: inline-block;\n width: 16px;\n height: 16px;\n padding: 4px;\n cursor: pointer;\n box-sizing: content-box;\n }\n\n .g6-toolbar .g6-toolbar-item:hover {\n background-color: #f0f0f0;\n }\n\n .g6-toolbar .g6-toolbar-item svg {\n display: inline-block;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n",document.head),QI("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}async update(t){super.update(t);const{className:e,position:n,style:r}=this.options;this.$element.className=`g6-toolbar ${e||""}`,Object.assign(this.$element.style,r,function(t){const e={top:"unset",right:"unset",bottom:"unset",left:"unset"};return t.split("-").forEach((t=>{e[t]="8px"})),e.flexDirection=t.startsWith("top")||t.startsWith("bottom")?"row":"column",e}(n)),this.$element.innerHTML=await this.getDOMContent()}destroy(){this.$element.removeEventListener("click",this.onToolbarItemClick),this.$element.remove(),super.destroy()}async getDOMContent(){return(await this.options.getItems()).map((t=>`\n <div class="g6-toolbar-item" value="${t.value}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`)).join("")}onToolbarItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof Element&&t.target.className.includes("g6-toolbar-item")){const n=t.target.getAttribute("value");e?.(n,t.target)}}}class Uj extends YI{static defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,style:{".tooltip":{visibility:"hidden"}}};currentTarget=null;tooltipElement=null;container=null;constructor(t,e){super(t,Object.assign({},Uj.defaultOptions,e)),this.render(),this.bindEvents()}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerenter":this.onPointerEnter,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerenter":this.onPointerEnter,"edge:pointermove":this.onPointerMove,"combo:pointerenter":this.onPointerEnter,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(t){this.unbindEvents(),super.update(t),this.tooltipElement&&this.container?.removeChild(this.tooltipElement.HTMLTooltipElement),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:t}=this.context,e=t.getContainer();e&&(this.container=e,this.tooltipElement=this.initTooltip())}unbindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach((n=>{t.off(n,e[n])}))}bindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach((n=>{t.on(n,e[n])}))}isEnable=t=>{const{enable:e}=this.options;return"function"==typeof e?e(t):e};onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?(this.currentTarget=null,this.hideTooltip(t)):(this.currentTarget=e,this.showTooltip(t))};onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.showTooltip(t)};onPointerLeave=t=>{this.hideTooltip(t),this.currentTarget=null};onCanvasMove=t=>{this.hideTooltip(t),this.currentTarget=null};onPointerEnter=t=>{this.showTooltip(t)};showTooltipById=(t,e="node")=>{const n={targetType:e,target:{id:t}};this.showTooltip(n)};getItems=(t,e)=>{const{model:n}=this.context;switch(e){case"node":return n.getNodeData([t]);case"edge":return n.getEdgeData([t]);case"combo":return n.getComboData([t]);default:return[]}};showTooltip=t=>{const{targetType:e,client:n,target:{id:r,attributes:i={color:"#1883FF"}}}=t;if(!this.tooltipElement||!this.isEnable(t))return;const{getContent:o}=this.options,{color:a,stroke:s}=i;this.currentTarget=r;const c=this.getItems(r,e);let u,l;if(n)u=n.x,l=n.y;else{const t=se(c,"0.style",{x:0,y:0});u=t.x,l=t.y}let h={};o?h.content=o(t,c):h={title:e,data:c.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:a||s})))},this.tooltipElement.update({x:u,y:l,style:{".tooltip":{visibility:"visible"}},...h})};hideTooltip=t=>{if(!t)return void this.tooltipElement?.hide();if(!this.tooltipElement||!this.isEnable(t))return;const{client:{x:e,y:n}}=t;this.tooltipElement.hide(e,n)};initTooltip=()=>{const{canvas:t}=this.context,{center:e}=t.getBounds(),n=t.getContainer(),{top:r,left:i}=n.getBoundingClientRect(),{style:o,position:a,enterable:s,container:c={x:-i,y:-r}}=this.options,[u,l]=e,[h,d]=t.getSize(),f=new Fj({className:"tooltip",style:{x:u,y:l,container:c,bounding:{x:0,y:0,width:h,height:d},position:a,enterable:s,title:"",offset:[10,10],style:o}});return this.container?.appendChild(f.HTMLTooltipElement),f};destroy(){this.unbindEvents(),this.tooltipElement&&this.container?.removeChild(this.tooltipElement.HTMLTooltipElement),super.destroy()}}let Hj;function $j(t,e){Hj||(Hj=document.createElement("canvas")),Hj.width=t,Hj.height=e;return Hj.getContext("2d").clearRect(0,0,t,e),Hj}class qj extends YI{static defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};$element=ZI("watermark");constructor(t,e){super(t,Object.assign({},qj.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}async update(t){super.update(t);const{width:e,height:n,text:r,imageURL:i,...o}=this.options;Object.keys(o).forEach((e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])}));const a=i?await async function(t,e,n,r){const i=$j(t,e),o=i.getContext("2d"),{rotate:a,opacity:s}=r;a&&o.rotate(a),s&&(o.globalAlpha=s);const c=new Image;return c.crossOrigin="anonymous",c.src=n,new Promise((n=>{c.onload=function(){const r=t>c.width?(t-c.width)/2:0,a=e>c.height?(e-c.height)/2:0;o.drawImage(c,0,0,c.width,c.height,r,a,t-2*r,e-2*a),n(i.toDataURL())}}))}(e,n,i,o):await async function(t,e,n,r){const i=$j(t,e),o=i.getContext("2d"),{rotate:a,opacity:s,textFill:c,textFontSize:u,textFontFamily:l,textFontVariant:h,textFontWeight:d,textAlign:f,textBaseline:p}=r;return o.textAlign=f,o.textBaseline=p,o.translate(t/2,e/2),o.font=`${u}px ${l} ${h} ${d}`,a&&o.rotate(a),s&&(o.globalAlpha=s),c&&(o.fillStyle=c,o.fillText(`${n}`,0,0)),i.toDataURL()}(e,n,r,o);this.$element.style.backgroundImage=`url(${a})`}destroy(){super.destroy(),this.$element.remove()}}const Yj=["#7E92B5","#f5222d","#faad14"],Kj={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},Xj={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function Zj(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeBadgePalette:a=Yj,nodePaletteOptions:s=Kj,edgeColor:c,edgeColorDisabled:u,edgePaletteOptions:l=Xj,comboColor:h,comboColorDisabled:d,comboStroke:f,comboStrokeDisabled:p}=t;return{background:e,node:{palette:s,style:{badgeFill:e,badgeFontSize:8,badgePadding:[1,4],badgePalette:a,color:r,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,iconFill:e,iconFontSize:16,iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.5,labelBackgroundPadding:[0,2],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineWidth:0,opacity:1,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65,stroke:o,strokeOpacity:1},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:3,stroke:o},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:3,stroke:o,strokeOpacity:.85},inactive:{donutOpacity:.25,iconOpacity:.25,labelOpacity:.25,opacity:.25},disabled:{color:i,labelOpacity:.25,donutOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["x","y","color","stroke"]}]}},edge:{palette:l,style:{color:c,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,opacity:1},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:2},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:2},inactive:{labelOpacity:.25,opacity:.25},disabled:{color:u,labelOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["color"]},{fields:["path"],shape:"key"}]}},combo:{style:{collapsedMaskFill:h,collapsedMaskFontSize:12,collapsedSize:32,color:h,halo:!1,haloLineWidth:12,haloStroke:f,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,opacity:1,padding:10,stroke:f},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{labelOpacity:.25,opacity:.65},disabled:{color:d,labelOpacity:.25,opacity:.25,stroke:p}},animation:{enter:"fade",exit:"fade",visibility:"fade",expand:"combo-collapse-expand",collapse:"combo-collapse-expand",update:[{fields:["x","y"]},{fields:["size","color","stroke"],shape:"key"}]}}}}const Qj=Zj({bgColor:"#000000",textColor:"#ffffffd9",nodeColor:"#1783ff",nodeColorDisabled:"#d0e4ff",nodeStroke:"#d0e4ff",edgeColor:"#99add1",edgeColorDisabled:"#969696",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696"}),Jj=Zj({bgColor:"#fff",textColor:"#000000d9",nodeColor:"#1783ff",nodeColorDisabled:"#f0f0f0",nodeStroke:"#000000",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",comboColor:"#fdfdfd",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9"});class tz extends Zh{beforeDraw(t){return t}}const ez=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class nz extends tz{static defaultOptions={mode:"bundle",edges:void 0,distance:15};constructor(t,e){super(t,Object.assign({},nz.defaultOptions,e))}beforeDraw(t){const e=this.getAffectedParallelEdges(t);if(0===e.size)return t;const n=(e,n,r)=>{const i=`${n}s`;Object.entries(t).forEach((([t,n])=>{e===t?n[i].set(Fu(r),r):n[i].delete(Fu(r))}))};return"bundle"===this.options.mode?this.applyBundlingStyle(n,e,this.options.distance):this.applyMergingStyle(n,e),t}getAffectedParallelEdges=t=>{const{add:{edges:e},update:{nodes:n,edges:r,combos:i},remove:{edges:o}}=t,{model:a}=this.context,s=new Map,c=(t,e)=>{a.getRelatedEdgesData(e).forEach((t=>!s.has(Fu(t))&&s.set(Fu(t),t)))};n.forEach(c),i.forEach(c);const u=t=>{iz(t,a.getEdgeData(),!0).forEach((t=>!s.has(Fu(t))&&s.set(Fu(t),t)))};if(o.size&&o.forEach(u),e.size&&e.forEach(u),r.size){const t=rL(nL(a.getChanges())).update.edges;r.forEach((e=>{u(e);const n=t.find((t=>Fu(t.value)===Fu(e)))?.original;n&&!oz(e,n)&&u(n)}))}oe(this.options.edges)||s.forEach(((t,e)=>!this.options.edges.includes(e)&&s.delete(e)));const l=a.getEdgeData().map(Fu);return new Map([...s].sort(((t,e)=>l.indexOf(t[0])-l.indexOf(e[0]))))};applyBundlingStyle=(t,e,n)=>{const{edgeMap:r,reverses:i}=rz(e);r.forEach((e=>{e.forEach(((e,r,o)=>{const a=re(e,{type:"quadratic",style:(()=>{const t=o.length,a={};if(e.source===e.target){const t=ez.length;a.loopPlacement=ez[r%t],a.loopDist=Math.floor(r/t)*n+50}else if(1===t)a.curveOffset=0;else{const o=(r%2==0?1:-1)*(i[`${e.source}|${e.target}|${r}`]?-1:1);a.curveOffset=t%2==1?o*Math.ceil(r/2)*n*2:o*(Math.floor(r/2)*n*2+n)}return a})()}),s=this.context.element?.getElement(Fu(e));t(s?"update":"add","edge",a)}))}))};applyMergingStyle=(t,e)=>{const{edgeMap:n,reverses:r}=rz(e);n.forEach((e=>{if(1===e.length){const n=e[0],r=this.context.element?.getElement(Fu(n));return void t(r?"update":"add","edge",n)}const n=e.map((({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:a}=n,s={},[c,u]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return Xt(o)&&(s[c]=o),Xt(a)&&(s[u]=a),s})).reduce(((t,e)=>({...t,...e})),{});e.forEach(((e,r)=>{if(0===r){const r={...e,style:{...n,...this.options.style}},i=this.context.element?.getElement(Fu(e));t(i?"update":"add","edge",r)}else t("remove","edge",e)}))}))}}const rz=t=>{const e=new Map,n=new Set,r={};for(const[i,o]of t){if(n.has(i))continue;const{source:a,target:s}=o,c=`${a}-${s}`;e.has(c)||e.set(c,[]),e.get(c).push(o),n.add(i);for(const[i,u]of t)n.has(i)||oz(o,u)&&(e.get(c).push(u),n.add(i),a===u.target&&s===u.source&&(r[`${u.source}|${u.target}|${e.get(c).length-1}`]=!0))}return{edgeMap:e,reverses:r}},iz=(t,e,n)=>e.filter((e=>(n||Fu(e)!==Fu(t))&&oz(e,t))),oz=(t,e)=>{const{source:n,target:r}=t,{source:i,target:o}=e;return n===i&&r===o||n===o&&r===i};const az={animation:{fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}],"combo-collapse-expand":[{fields:["x","y"]},{fields:["r","width","height"],shape:"key"}]},behavior:{"zoom-canvas":Sd,"drag-canvas":fd,"drag-element":pd,"drag-element-force":class extends pd{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find((t=>["d3-force","d3-force-3d"].includes(t?.id)))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(console.warn("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}async moveElement(t,e){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach(((r,i)=>{const{x:o=0,y:a=0}=r.style||{};n.setFixedPosition(t[i],[...Yu([+o,+a],e)])}))}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e.simulation.alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e.setFixedPosition(Fu(t),[+n,+r])}))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t.simulation.alphaTarget(0),this.context.graph.getNodeData(this.target).forEach((e=>{t.setFixedPosition(Fu(e),[null,null,null])}))}},"collapse-expand":ld,"click-element":ud,"hover-element":vd,"focus-element":md,"create-edge":dd,"brush-select":od,"lasso-select":Nd},combo:{circle:Ql,rect:Jl},edge:{cubic:wh,line:Sh,polyline:Ch,quadratic:Th,"cubic-horizontal":Mh,"cubic-vertical":Nh},layout:{"antv-dagre":class{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},Um),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{nodeSize:i,align:o,rankdir:a="TB",ranksep:s,nodesep:c,ranksepFunc:u,nodesepFunc:l,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:m,sortByCombo:v,preset:y}=r,b=new Gp({tree:[]}),x=Gm(s||50,u),E=Gm(c||50,l);let w=E,M=x;"LR"!==a&&"RL"!==a||(w=x,M=E);const N=Wm(i,void 0),S=e.getAllNodes(),C=e.getAllEdges();let T;S.forEach((t=>{const e=N(t),n=M(t),r=e+2*w(t),i=e+2*n,o=t.data.layer;Wt(o)?b.addNode({id:t.id,data:{width:r,height:i,layer:o}}):b.addNode({id:t.id,data:{width:r,height:i}})})),v&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),C.forEach((t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==y?void 0:y.length)&&(T=new Gp({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&dm(t,i);const s=bm(t);let c;n&&(e.ranksep=xm(s,{rankdir:o,ranksep:a}));try{c=hm(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}fm(t,s)})(b,{prevGraph:T,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:c,align:o});const P=[0,0];if(p){let t=1/0,e=1/0;b.getAllNodes().forEach((n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)})),b.getAllEdges().forEach((n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach((n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)}))})),P[0]=p[0]-t,P[1]=p[1]-e}const k="LR"===a||"RL"===a;if(m);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach((e=>{e.data.x=e.data.x+P[0],e.data.y=e.data.y+P[1],t.add(k?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=k?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=k?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((t=>t.y<=r&&t.y>=i))}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((t=>t.x<=r&&t.x>=i))};b.getAllEdges().forEach(((t,e)=>{var o;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=Hm(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+P[0],y:e+P[1]}))),b.getNode(t.source),b.getNode(t.target),n,k,r,i))}))}let A=[];A=b.getAllNodes().map((t=>Fm(t)));const O=b.getAllEdges();t&&(A.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),O.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:A,edges:O}}))}},"combo-combined":class{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},Ny),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:i,treeKey:o,outerLayout:a}=r,s=e.getAllNodes().filter((t=>!t.data._isCombo)),c=e.getAllNodes().filter((t=>t.data._isCombo)),u=e.getAllEdges(),l=null==s?void 0:s.length;if(!l||1===l)return $m(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;c.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,u,r,p);yield Promise.all(g);const m=new Map,v=[],y=new Map;let b=!0;e.getRoots(o).forEach((t=>{const n=p.get(t.id),r=f.get(t.id)||d.get(t.id),i={id:t.id,data:Object.assign(Object.assign({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};v.push(i),m.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):b=!1,zm(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const x=[];let E;if(u.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&m.has(e)&&m.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==v?void 0:v.length){if(1===v.length)v[0].data.x=i[0],v[0].data.y=i[1];else{const t=new Gp({nodes:v,edges:x}),e=a||new bv;if(b&&My[e.id]){const e=v.length<100?new xy:new Zm;yield e.assign(t)}E=yield e.execute(t,Object.assign({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,n)=>(Math.max(...e.data.size)||32)/2+(Math.max(...n.data.size)||32)/2+200}:{}))}p.forEach((t=>{var e;const n=E.nodes.find((e=>e.id===t.id));if(n){const{x:e,y:r}=n.data;t.data.visited=!0,t.data.x=e,t.data.y=r,h.push({id:t.id,data:{x:e,y:r}})}const{x:r,y:i}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{h.push({id:t.id,data:{x:t.data.x+r,y:t.data.y+i}})}))})),p.forEach((({data:t})=>{const{x:e,y:n,visited:r,nodes:i}=t;null==i||i.forEach((t=>{if(!r){const r=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=Wt(r)?()=>r:Pt(r)?r:()=>0,e.spacing=a,n)if(Pt(n))o=t=>{const e=n(t),r=a(t);if(Dm(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(Dm(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)/2}else{const t=n/2;o=e=>t+a(e)/2}else o=t=>{const e=a(t);if(t.size){if(Dm(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(Rt(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=o,s=Wt(i)?()=>i:Dm(i)?()=>Math.max.apply(null,i):Pt(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,s){const{nodeSize:c,comboPadding:u,spacing:l,innerLayout:h}=o,d=h||new Zm({}),f={center:[0,0],preventOverlap:!0,nodeSpacing:l},p=[],g=t=>{let e=(null==u?void 0:u(t))||10;return Dm(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{s.set(o.id,{id:o.id,data:{nodes:[],size:g(o).size}});let u=Promise.resolve();zm(t,[o],(o=>{var l;if(!o.data._isCombo)return;const{size:h,padding:p}=g(o);if(null===(l=t.getChildren(o.id,e))||void 0===l?void 0:l.length){const l=s.get(o.id);s.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==l?void 0:l.data)});const h=new Map,g=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return s.has(t.id)||s.set(t.id,{id:t.id,data:Object.assign({},t.data)}),h.set(t.id,!0),s.get(t.id);const e=n.get(t.id)||r.get(t.id);return h.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),m={nodes:g,edges:i.filter((t=>h.has(t.source)&&h.has(t.target)))};let v=1/0;g.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=s.get(t.id))||void 0===e?void 0:e.data.size)||(null==c?void 0:c(t))||[30,30]),Wt(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),u=u.then((()=>a(this,void 0,void 0,(function*(){const t=new Gp(m),e=yield d.assign(t,f),{minX:n,minY:r,maxX:i,maxY:a}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;Dm(o)?1===o.length&&(o=[o[0],o[0]]):Wt(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],s=t.data.x-a[0],c=t.data.x+a[0],u=t.data.y-a[1],l=t.data.y+a[1];e>s&&(e=s),n>u&&(n=u),r<c&&(r=c),i<l&&(i=l)})),{minX:e,minY:n,maxX:r,maxY:i}})(g),c=(i+n)/2,u=(a+r)/2;m.nodes.forEach((t=>{t.data.x-=c,t.data.y-=u}));const l=[Math.max(i-n,v)+2*p,Math.max(a-r,v)+2*p];return s.get(o.id).data.size=l,s.get(o.id).data.nodes=g,e}))))}else s.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:h})});return!0}),"BT",e),p.push(u)})),p}},"compact-box":Ip.compactBox,"force-atlas2":class{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},sI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return a(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:c,maxIteration:u,nodeSize:l,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return $m(e,t,h);const d=i.map((t=>Fm(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Gp({nodes:d,edges:f}),g=this.getSizes(p,e,l);if(this.run(p,e,u,g,t,o),c){for(let t=0;t<f.length;t+=1){const{source:e,target:n}=f[t],r=p.getDegree(e),i=p.getDegree(e);if(r<=1){const t=p.getNode(n);p.mergeNodeData(e,{x:t.data.x,y:t.data.y})}else if(i<=1){const t=p.getNode(e);p.mergeNodeData(n,{x:t.data.x,y:t.data.y})}}const n=Object.assign(Object.assign({},o),{prune:!1,barnesHut:!1});this.run(p,e,100,g,t,n)}return{nodes:d,edges:r}}))}getSizes(t,e,n){const r=t.getAllNodes(),i={};for(let t=0;t<r.length;t+=1){const{id:o,data:a}=r[t];if(i[o]=10,Wt(a.size))i[o]=a.size;else if(Dm(a.size))isNaN(a.size[0])||(i[o]=Math.max(a.size[0])),isNaN(a.size[1])||(i[o]=Math.max(a.size[1]));else if(Rt(a.size))i[o]=Math.max(a.size.width,a.size.height);else if(Pt(n)){const t=n(e.getNode(o));Dm(t)?i[o]=Math.max(...t):i[o]=t}else Dm(n)?i[o]=Math.max(...n):Wt(n)&&(i[o]=n)}return i}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:c,kr:u,kg:l}=n;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===s&&e>100&&(n.prune=!0),0!==c||s?0===c&&s&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),u||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),l||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:c}=o,u=t.getAllNodes();let l=0,h=n;const d={},f={},p={};for(let e=0;e<u.length;e+=1){const{data:n,id:r}=u[e];if(d[r]=[0,0],s){const i={id:e,rx:n.x,ry:n.y,mass:1,g:a,degree:t.getDegree(r)};p[r]=new iI(i)}}for(;h>0;)l=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:l,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==c||c({nodes:u,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:c,sizes:u}=e;let{forces:l}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...l[e]],l[e]=[0,0]}return l=this.getAttrForces(t,r,i,u,l,n),l=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,l,c,n):this.getRepGraForces(t,r,i,l,o,u,n),this.updatePos(t,l,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:c,prune:u}=o,l=t.getAllEdges();for(let o=0;o<l.length;o+=1){const{source:h,target:d}=l[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),m=t.getDegree(d);if(u&&(g<=1||m<=1))continue;const v=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(v[0],v[1]);y=y<1e-4?1e-4:y,v[0]=v[0]/y,v[1]=v[1]/y,a&&e<n&&(y=y-r[h]-r[d]);let b=y,x=b;"linlog"===c&&(b=Math.log(1+y),x=b),s&&(b=y/g,x=y/m),a&&e<n&&y<=0?(b=0,x=0):a&&e<n&&y>0&&(b=y,x=y),i[h][0]+=b*v[0],i[d][0]-=x*v[0],i[h][1]+=b*v[1],i[d][1]-=x*v[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),c=s.length;let u=9e10,l=-9e10,h=9e10,d=-9e10;for(let e=0;e<c;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=l&&(l=i.x),i.x<=u&&(u=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(l-u,d-h),p=new oI({xmid:(l+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:c}),g=new aI(p);for(let e=0;e<c;e+=1){const{id:r}=s[e];a&&t.getDegree(r)<=1||n[r].in(p)&&g.insert(n[r])}for(let r=0;r<c;r+=1){const{id:c,data:u}=s[r],l=t.getDegree(c);if(a&&l<=1)continue;n[c].resetForce(),g.updateForce(n[c]),e[c][0]-=n[c].fx,e[c][1]-=n[c].fy;const h=[u.x-o[0],u.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(l+1);e[c][0]-=f*h[0],e[c][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:c,kg:u,center:l,prune:h}=a,d=t.getAllNodes(),f=d.length;for(let a=0;a<f;a+=1){const p=d[a],g=t.getDegree(p.id);for(let u=a+1;u<f;u+=1){const a=d[u],l=t.getDegree(a.id);if(h&&(g<=1||l<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let m=Math.hypot(f[0],f[1]);m=m<1e-4?1e-4:m,f[0]=f[0]/m,f[1]=f[1]/m,s&&e<n&&(m=m-o[p.id]-o[a.id]);let v=c*(g+1)*(l+1)/m;s&&e<n&&m<0?v=i*(g+1)*(l+1):s&&e<n&&0===m?v=0:s&&e<n&&m>0&&(v=c*(g+1)*(l+1)/m),r[p.id][0]-=v*f[0],r[a.id][0]+=v*f[0],r[p.id][1]-=v*f[1],r[a.id][1]+=v*f[1]}const m=[p.data.x-l[0],p.data.y-l[1]],v=Math.hypot(m[0],m[1]);m[0]=m[0]/v,m[1]=m[1]/v;const y=u*(g+1);r[p.id][0]-=y*m[0],r[p.id][1]-=y*m[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:c}=i,u=t.getAllNodes(),l=u.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<l;r+=1){const{id:i}=u[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],c=Math.hypot(a[0],a[1]),l=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(l[0],l[1]);h[r]=c,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const m=g;g=a*p/f,0!==m&&(g=g>1.5*m?1.5*m:g);for(let n=0;n<l;n+=1){const{id:r,data:i}=u[n],a=t.getDegree(r);if(s&&a<=1)continue;if(Wt(i.fx)&&Wt(i.fy))continue;let l=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=c/d;l=l>f?f:l;const p=l*e[r][0],m=l*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+m})}return g}},circular:class{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},qm),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:c=0,endAngle:u=2*Math.PI,angleRatio:l,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),m=e.getAllEdges(),[v,y,b]=Km(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return $m(e,t,b);const E=(u-c)/x;let{radius:w,startRadius:M,endRadius:N}=r;if(f){const t=Gm(10,f),e=Vm(10,p);let n=-1/0;g.forEach((t=>{const r=e(t);n<r&&(n=r)}));let r=0;g.forEach(((e,i)=>{r+=0===i?n||10:(t(e)||0)+(n||10)})),w=r/(2*Math.PI)}else w||M||N?!M&&N?M=N:M&&!N&&(N=M):w=Math.min(y,v)/2;const S=E*l;let C=[];C="topology"===h?Ym(e,g):"topology-directed"===h?Ym(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(Fm(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>Fm(t)));const T=Math.ceil(x/s);for(let t=0;t<x;++t){let e=w;e||null===M||null===N||(e=M+t*(N-M)/(x-1)),e||(e=10+100*t/(x-1));let n=c+t%T*S+2*Math.PI/s*Math.floor(t/T);d||(n=u-t%T*S-2*Math.PI/s*Math.floor(t/T)),C[t].data.x=b[0]+Math.cos(n)*e,C[t].data.y=b[1]+Math.sin(n)*e}t&&C.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:C,edges:m}}))}},concentric:Zm,d3force:pb,"d3-force-3d":class extends pb{constructor(){super(...arguments),this.id="d3-force-3d",this.config={inputNodeAttrs:["x","y","z","vx","vy","vz","fx","fy","fz"],outputNodeAttrs:["x","y","z","vx","vy","vz"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:_b,manyBody:VE,center:mb,collide:kb,radial:WE,x:UE,y:HE,z:$E},this.options={numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return GE()}},dagre:rI,dendrogram:Ip.dendrogram,force:bv,fruchterman:class{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},cI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericFruchtermanLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;e<t;e++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,e,n){return a(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:c,nodeClusterBy:u,maxIteration:l,onTick:h}=r,d=e.getAllNodes(),f=e.getAllEdges();if(!(null==d?void 0:d.length)){const t={nodes:[],edges:f};return this.lastResult=t,t}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0});const n={nodes:[Object.assign(Object.assign({},d[0]),{data:Object.assign(Object.assign({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:f};return this.lastResult=n,n}const p=d.map((t=>Fm(t,[o,a]))),g=new Gp({nodes:p,edges:f}),m={};if(c&&p.forEach((t=>{const e=t.data[u];m[e]||(m[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=p,this.lastLayoutEdges=f,this.lastAssign=t,this.lastGraph=g,this.lastOptions=r,this.lastClusterMap=m,"undefined"==typeof window)return;let v=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,m,r),t&&p.forEach((({id:t,data:n})=>e.mergeNodeData(t,{x:n.x,y:n.y,z:3===i?n.z:void 0}))),null==h||h({nodes:p,edges:f}),v++,v>=l&&(window.clearInterval(this.timeInterval),n({nodes:p,edges:f}))):n({nodes:p,edges:f})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:r}=e,{center:i,width:o,height:a}=e;return e.width=o||"undefined"==typeof window?o:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!r,e}runOneStep(t,e,n){const{dimensions:r,height:i,width:o,gravity:a,center:s,speed:c,clustering:u,nodeClusterBy:l,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),m=Math.sqrt(g),v={};if(this.applyCalculate(t,v,m,g),u){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;p.forEach((t=>{const{data:n}=t,r=e[n[l]];Wt(n.x)&&(r.cx+=n.x),Wt(n.y)&&(r.cy+=n.y),r.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!Wt(o.x)||!Wt(o.y))return;const a=e[o[l]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),c=m*t;v[i].x-=c*(o.x-a.cx)/s,v[i].y-=c*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!Wt(i.x)||!Wt(i.y))return;const o=.01*m*a;v[n].x-=o*(i.x-s[0]),v[n].y-=o*(i.y-s[1]),3===r&&(v[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(Wt(o.fx)&&Wt(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!Wt(o.x)||!Wt(o.y))return;const a=Math.sqrt(v[i].x*v[i].x+v[i].y*v[i].y+(3===r?v[i].z*v[i].z:0));if(a>0){const e=Math.min(f*(c/800),a);t.mergeNodeData(i,{x:o.x+v[i].x/a*e,y:o.y+v[i].y/a*e,z:3===r?o.z+v[i].z/a*e:void 0})}}))}applyCalculate(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)}calRepulsive(t,e,n){const r=t.getAllNodes();r.forEach((({data:t,id:i},o)=>{e[i]={x:0,y:0,z:0},r.forEach((({data:r,id:a},s)=>{if(o<=s||!Wt(t.x)||!Wt(r.x)||!Wt(t.y)||!Wt(r.y))return;let c=t.x-r.x,u=t.y-r.y,l=3===this.options.dimensions?t.z-r.z:0,h=c*c+u*u+l*l;0===h&&(h=1,c=.01,u=.01,l=.01);const d=n/h,f=c*d,p=u*d,g=l*d;e[i].x+=f,e[i].y+=p,e[a].x-=f,e[a].y-=p,3===this.options.dimensions&&(e[i].z+=g,e[a].z-=g)}))}))}calAttractive(t,e,n){t.getAllEdges().forEach((r=>{const{source:i,target:o}=r;if(!i||!o||i===o)return;const{data:a}=t.getNode(i),{data:s}=t.getNode(o);if(!(Wt(s.x)&&Wt(a.x)&&Wt(s.y)&&Wt(a.y)))return;const c=s.x-a.x,u=s.y-a.y,l=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(c*c+u*u+l*l)/n,d=c*h,f=u*h,p=l*h;e[i].x+=d,e[i].y+=f,e[o].x-=d,e[o].y-=f,3===this.options.dimensions&&(e[i].z+=p,e[o].z-=p)}))}},grid:class{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},uI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{begin:i=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:s,rows:c,cols:u,nodeSpacing:l,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const m=e.getAllNodes(),v=e.getAllEdges(),y=null==m?void 0:m.length;if(!y||1===y)return $m(e,t,i);const b=m.map((t=>Fm(t)));"id"===g||Bt(g)&&void 0!==b[0].data[g]||(g="degree"),"degree"===g?b.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):"id"===g?b.sort(((t,e)=>Wt(e.id)&&Wt(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,E=f||"undefined"==typeof window?f:window.innerHeight,w=y,M={rows:c,cols:u};if(null!=c&&null!=u)M.rows=c,M.cols=u;else if(null!=c&&null==u)M.rows=c,M.cols=Math.ceil(w/M.rows);else if(null==c&&null!=u)M.cols=u,M.rows=Math.ceil(w/M.cols);else{const t=Math.sqrt(w*E/x);M.rows=Math.round(t),M.cols=Math.round(x/E*t)}if(M.rows=Math.max(M.rows,1),M.cols=Math.max(M.cols,1),M.cols*M.rows>w){const t=lI(M),e=hI(M);(t-1)*e>=w?lI(M,t-1):(e-1)*t>=w&&hI(M,e-1)}else for(;M.cols*M.rows<w;){const t=lI(M),e=hI(M);(e+1)*t>=w?hI(M,e+1):lI(M,t+1)}let N=o?0:x/M.cols,S=o?0:E/M.rows;if(s||l){const t=Gm(10,l),n=Vm(30,h,!1);b.forEach((r=>{r.data.x&&r.data.y||(r.data.x=0,r.data.y=0);const i=e.getNode(r.id),o=n(i)||30;let s,c;Dm(o)?(s=o[0],c=o[1]):(s=o,c=o);const u=void 0!==t?t(r):a,l=s+u,h=c+u;N=Math.max(N,l),S=Math.max(S,h)}))}const C={},T={row:0,col:0},P={};for(let t=0;t<b.length;t++){const n=b[t];let r;if(p&&(r=p(e.getNode(n.id))),r&&(void 0!==r.row||void 0!==r.col)){const t={row:r.row,col:r.col};if(void 0===t.col)for(t.col=0;dI(C,t);)t.col++;else if(void 0===t.row)for(t.row=0;dI(C,t);)t.row++;P[n.id]=t,fI(C,t)}gI(n,i,N,S,P,M,T,C)}const k={nodes:b,edges:v};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),k}))}},indented:Ip.indented,mds:xy,mindmap:Ip.mindmap,radial:class{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},bI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:c,nodeSize:u,nodeSpacing:l,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:m=10,maxIteration:v=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,E=o||"undefined"==typeof window?o:window.innerHeight,w=a||[x/2,E/2];if(!(null==y?void 0:y.length)||1===y.length)return $m(e,t,w);let M=y[0];if(Bt(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){M=y[t];break}}else M=s||y[0];const N=wI(y,M.id),S=Lm({nodes:y,edges:b},!1),C=Im(S),T=NI(C,N);MI(C,N,T+1);const P=C[N];let k=x-w[0]>w[0]?w[0]:x-w[0],A=E-w[1]>w[1]?w[1]:E-w[1];0===k&&(k=x/2),0===A&&(A=E/2);const O=Math.min(k,A),_=Math.max(...P),R=[],D=c||O/_;P.forEach(((t,e)=>{R[e]=t*D}));const I=xI(y,C,g,R,D,p,m),L=EI(I),j=((t,e,n)=>{try{const n=vy.mul(vy.pow(e,2),-.5),r=n.mean("row"),i=n.mean("column"),o=n.mean();n.add(o).subRowVector(r).subColumnVector(i);const a=new yy(n),s=vy.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>vy.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const r=[];for(let t=0;t<e.length;t++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}})(g,I,g);let z,B=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[N][0],y:(isNaN(e)?Math.random()*g:e)-j[N][1]})));if(this.run(v,B,L,I,R,N),d){z=Wm(u,l);const t={nodes:y,nodeSizeFunc:z,positions:B,radii:R,height:E,width:x,strictRadial:Boolean(h),focusIdx:N,iterations:f||200,k:B.length/4.5};B=((t,e)=>{const n=Object.assign(Object.assign({},mI),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:c,focusIdx:u,radii:l=[],nodeSizeFunc:h}=n,d=t.getAllNodes(),f=[],p=o/10;for(let t=0;t<i;t++)r.forEach(((t,e)=>{f[e]={x:0,y:0}})),vI(d,r,f,a,l,h),yI(r,f,s,c,u,p,o,l);return r})(e,t)}const F=[];B.forEach(((t,e)=>{const n=Fm(y[e]);n.data.x=t.x+w[0],n.data.y=t.y+w[1],F.push(n)})),t&&F.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:F,edges:b}}))}run(t,e,n,r,i,o){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,i,r,n,o)}}oneIteration(t,e,n,r,i,o){const a=1-t;e.forEach(((s,c)=>{const u=jm(s,{x:0,y:0}),l=0===u?0:1/u;if(c===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(c===e)return;const n=jm(s,t),o=0===n?0:1/n,a=r[e][c];f+=i[c][e],h+=i[c][e]*(t.x+a*(s.x-t.x)*o),d+=i[c][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[c]?0:1/n[c];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*l,s.x=h/f,d*=a,d+=t*p*s.y*l,s.y=d/f}))}},random:class{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},SI),t)}execute(t,e){return a(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return a(this,void 0,void 0,(function*(){this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return a(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a}=r,s=e.getAllNodes(),c=o||"undefined"==typeof window?o:window.innerWidth,u=a||"undefined"==typeof window?a:window.innerHeight,l=i||[c/2,u/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+l[0],y:.9*(Math.random()-.5)*u+l[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}},node:{circle:zl,diamond:Fl,ellipse:Ul,hexagon:Hl,html:$l,image:ql,rect:Yl,star:Kl,donut:Gl,triangle:Xl},palette:{spectral:["rgb(158, 1, 66)","rgb(213, 62, 79)","rgb(244, 109, 67)","rgb(253, 174, 97)","rgb(254, 224, 139)","rgb(255, 255, 191)","rgb(230, 245, 152)","rgb(171, 221, 164)","rgb(102, 194, 165)","rgb(50, 136, 189)","rgb(94, 79, 162)"],tableau:["rgb(78, 121, 167)","rgb(242, 142, 44)","rgb(225, 87, 89)","rgb(118, 183, 178)","rgb(89, 161, 79)","rgb(237, 201, 73)","rgb(175, 122, 161)","rgb(255, 157, 167)","rgb(156, 117, 95)","rgb(186, 176, 171)"],oranges:["rgb(255, 245, 235)","rgb(254, 230, 206)","rgb(253, 208, 162)","rgb(253, 174, 107)","rgb(253, 141, 60)","rgb(241, 105, 19)","rgb(217, 72, 1)","rgb(166, 54, 3)","rgb(127, 39, 4)"],greens:["rgb(247, 252, 245)","rgb(229, 245, 224)","rgb(199, 233, 192)","rgb(161, 217, 155)","rgb(116, 196, 118)","rgb(65, 171, 93)","rgb(35, 139, 69)","rgb(0, 109, 44)","rgb(0, 68, 27)"],blues:["rgb(247, 251, 255)","rgb(222, 235, 247)","rgb(198, 219, 239)","rgb(158, 202, 225)","rgb(107, 174, 214)","rgb(66, 146, 198)","rgb(33, 113, 181)","rgb(8, 81, 156)","rgb(8, 48, 107)"]},theme:{dark:Qj,light:Jj},plugin:{hull:RL,"grid-line":tL,watermark:qj,tooltip:Uj,contextmenu:JI,toolbar:Wj,legend:Vj,history:aL},transform:{"update-related-edges":class extends tz{beforeDraw(t){const{model:e}=this.context,{update:{nodes:n,edges:r,combos:i}}=t,o=(t,n)=>{e.getRelatedEdgesData(n).forEach((t=>!r.has(Fu(t))&&r.set(Fu(t),t)))};return n.forEach(o),i.forEach(o),t}},"arrange-draw-order":class extends tz{beforeDraw(t){const{model:e}=this.context,n=t.add.combos,r=[];return n.forEach(((t,n)=>{const i=e.getAncestorsData(n,"combo").map((t=>Fu(t))).reverse();r.push([n,t,i.length])})),t.add.combos=new Map(r.sort((([,,t],[,,e])=>e-t)).map((([t,e])=>[t,e]))),t}},"collapse-expand-combo":class extends tz{beforeDraw(t){const{model:e}=this.context,{add:n,update:r}=t,i=(e,n,r)=>{const i=`${n}s`;Object.entries(t).forEach((([t,n])=>{e===t?n[i].set(Fu(r),r):n[i].delete(Fu(r))}))},o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[t,a]=o.pop();if(!!a.style?.collapsed){const s=e.getDescendantsData(t),c=s.map(Fu),{internal:u,external:l}=yh(c,(t=>e.getRelatedEdgesData(t)));s.forEach((t=>{const n=Fu(t),r=o.findIndex((([t])=>t===n));-1!==r&&o.splice(r,1);const a=e.getElementType(n);i("remove",a,t)})),u.forEach((t=>i("remove","edge",t))),l.forEach((t=>{const e=Fu(t),i=c.includes(t.source)?"source":"target",o={...t,[i]:Fu(a)};n.edges.has(e)&&n.edges.set(e,o),r.edges.has(e)&&r.edges.set(e,o)}))}else{const n=e.getChildrenData(t),r=n.map(Fu),{edges:a}=yh(r,(t=>e.getRelatedEdgesData(t)));[...n,...a].forEach((t=>{const n=Fu(t),r=e.getElementType(n),a=this.context.element?.getElement(n);i(a?"update":"add",r,t),"combo"===r&&o.push([n,t])}))}}return t}},"process-parallel-edges":nz}},sz={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{}};function cz(t,e,n){sz[t][e]?console.error(`The extension ${e} of ${t} has been registered before.`):Object.assign(sz[t],{[e]:n})}function uz(t,e){const n=sz[t]?.[e];if(n)return n}fs.enableCSSParsing=!1,Object.entries(az).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{cz(t,e,n)}))}));class lz{type;constructor(t){this.type=t}}class hz extends lz{data;constructor(t,e){super(t),this.data=e}}class dz extends lz{animationType;animation;data;constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class fz extends lz{elementType;data;constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class pz extends lz{data;constructor(t,e){super(t),this.data=e}}function gz(t,e){t.emit(e.type,e)}function mz(t,e){const{datum:n}=e;return Pt(t)?t(n):Object.fromEntries(Object.entries(t).map((([t,e])=>Pt(e)?[t,e(n)]:[t,e])))}function vz(t){return t.style?.zIndex??Hh("zIndex")??0}class yz{context;batchCount=0;constructor(t){this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(e=!0){this.batchCount++,1===this.batchCount&&this.emit(new hz(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new hz(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class bz extends Xh{currentTarget=null;category="behavior";constructor(t){super(t),this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.addEventListener(t,this.forwardContainerEvents)}));const n=this.context.canvas.document;n&&[t.CanvasEvent.CLICK,t.CanvasEvent.DBLCLICK,t.CanvasEvent.POINTER_OVER,t.CanvasEvent.POINTER_LEAVE,t.CanvasEvent.POINTER_ENTER,t.CanvasEvent.POINTER_MOVE,t.CanvasEvent.POINTER_OUT,t.CanvasEvent.POINTER_DOWN,t.CanvasEvent.POINTER_UP,t.CanvasEvent.CONTEXT_MENU,t.CanvasEvent.DRAG_START,t.CanvasEvent.DRAG,t.CanvasEvent.DRAG_END,t.CanvasEvent.DRAG_ENTER,t.CanvasEvent.DRAG_OVER,t.CanvasEvent.DRAG_LEAVE,t.CanvasEvent.DROP,t.CanvasEvent.WHEEL].forEach((t=>{n.addEventListener(t,this.forwardCanvasEvents)}))}forwardCanvasEvents=e=>{const{target:n}=e,r=function(t){if(!t)return null;if(t instanceof Ws)return{type:"canvas",element:t};let e=t;for(;e;){if(Ph(e))return{type:"node",element:e};if(kh(e))return{type:"edge",element:e};if(Ah(e))return{type:"combo",element:e};e=e.parentElement}return null}(n);if(!r)return;const{graph:i,canvas:o}=this.context,{type:a,element:s}=r,{type:c,detail:u,button:l}=e,h={...e,target:s,targetType:a,originalTarget:n};if(c===t.CanvasEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${a}:${t.CanvasEvent.POINTER_LEAVE}`,{...h,target:this.currentTarget}),s&&i.emit(`${a}:${t.CanvasEvent.POINTER_ENTER}`,h)),this.currentTarget=s),c===t.CanvasEvent.CLICK&&2===l||(i.emit(`${a}:${c}`,h),i.emit(c,h)),c===t.CanvasEvent.CLICK&&2===u&&(i.emit(`${a}:${t.CanvasEvent.DBLCLICK}`,h),i.emit(t.CanvasEvent.DBLCLICK,h)),c===t.CanvasEvent.POINTER_DOWN&&2===l){const e={...h,preventDefault:()=>{o.getContainer()?.addEventListener(t.CanvasEvent.CONTEXT_MENU,(t=>t.preventDefault()),{once:!0})}};i.emit(`${a}:${t.CanvasEvent.CONTEXT_MENU}`,e),i.emit(t.CanvasEvent.CONTEXT_MENU,e)}};forwardContainerEvents=t=>{this.context.graph.emit(t.type,t)};destroy(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.removeEventListener(t,this.forwardContainerEvents)})),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}function xz(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function Ez(t,e){var n=e.rx,r=e.ry;if(t.ellipse)t.ellipse(n,r,n,r,0,0,2*Math.PI,!1);else{var i=n>r?n:r,o=n>r?1:n/r,a=n>r?r/n:1;t.save(),t.scale(o,a),t.arc(i,i,i,0,2*Math.PI)}}function wz(t,e){var n,r,i=e.x1,o=e.y1,a=e.x2,s=e.y2,c=e.defX,u=void 0===c?0:c,l=e.defY,h=void 0===l?0:l,d=e.markerStart,f=e.markerEnd,p=e.markerStartOffset,g=e.markerEndOffset,m=0,v=0,y=0,b=0,x=0;d&&Es(d)&&p&&(n=a-i,r=s-o,x=Math.atan2(r,n),m=Math.cos(x)*(p||0),v=Math.sin(x)*(p||0)),f&&Es(f)&&g&&(n=i-a,r=o-s,x=Math.atan2(r,n),y=Math.cos(x)*(g||0),b=Math.sin(x)*(g||0)),t.moveTo(i-u+m,o-h+v),t.lineTo(a-u+y,s-h+b)}function Mz(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,c=e.markerStart,l=e.markerEnd,h=e.markerStartOffset,d=e.markerEndOffset,f=e.path,p=f.absolutePath,g=f.segments,m=0,v=0,y=0,b=0,x=0;if(c&&Es(c)&&h){var E=u(c.parentNode.getStartTangent(),2),w=E[0],M=E[1];n=w[0]-M[0],r=w[1]-M[1],x=Math.atan2(r,n),m=Math.cos(x)*(h||0),v=Math.sin(x)*(h||0)}if(l&&Es(l)&&d){var N=u(l.parentNode.getEndTangent(),2);w=N[0],M=N[1];n=w[0]-M[0],r=w[1]-M[1],x=Math.atan2(r,n),y=Math.cos(x)*(d||0),b=Math.sin(x)*(d||0)}for(var S=0;S<p.length;S++){var C=p[S],T=C[0],P=p[S+1],k=0===S&&(0!==m||0!==v),A=(S===p.length-1||P&&("M"===P[0]||"Z"===P[0]))&&0!==y&&0!==b;switch(T){case"M":k?(t.moveTo(C[1]-o+m,C[2]-s+v),t.lineTo(C[1]-o,C[2]-s)):t.moveTo(C[1]-o,C[2]-s);break;case"L":A?t.lineTo(C[1]-o+y,C[2]-s+b):t.lineTo(C[1]-o,C[2]-s);break;case"Q":t.quadraticCurveTo(C[1]-o,C[2]-s,C[3]-o,C[4]-s),A&&t.lineTo(C[3]-o+y,C[4]-s+b);break;case"C":t.bezierCurveTo(C[1]-o,C[2]-s,C[3]-o,C[4]-s,C[5]-o,C[6]-s),A&&t.lineTo(C[5]-o+y,C[6]-s+b);break;case"A":var O=g[S].arcParams,_=O.cx,R=O.cy,D=O.rx,I=O.ry,L=O.startAngle,j=O.endAngle,z=O.xRotation,B=O.sweepFlag;if(t.ellipse)t.ellipse(_-o,R-s,D,I,z,L,j,!!(1-B));else{var F=D>I?D:I,G=D>I?1:D/I,V=D>I?I/D:1;t.translate(_-o,R-s),t.rotate(z),t.scale(G,V),t.arc(0,0,F,L,j,!!(1-B)),t.scale(1/G,1/V),t.rotate(-z),t.translate(-(_-o),-(R-s))}A&&t.lineTo(C[6]-o+y,C[7]-s+b);break;case"Z":t.closePath()}}}function Nz(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,c=e.markerStart,u=e.markerEnd,l=e.markerStartOffset,h=e.markerEndOffset,d=e.points.points,f=d.length,p=d[0][0]-o,g=d[0][1]-s,m=d[f-1][0]-o,v=d[f-1][1]-s,y=0,b=0,x=0,E=0,w=0;c&&Es(c)&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],w=Math.atan2(r,n),y=Math.cos(w)*(l||0),b=Math.sin(w)*(l||0)),u&&Es(u)&&h&&(n=d[f-1][0]-d[0][0],r=d[f-1][1]-d[0][1],w=Math.atan2(r,n),x=Math.cos(w)*(h||0),E=Math.sin(w)*(h||0)),t.moveTo(p+(y||x),g+(b||E));for(var M=1;M<f-1;M++){var N=d[M];t.lineTo(N[0]-o,N[1]-s)}t.lineTo(m,v)}function Sz(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,c=e.markerStart,u=e.markerEnd,l=e.markerStartOffset,h=e.markerEndOffset,d=e.points.points,f=d.length,p=d[0][0]-o,g=d[0][1]-s,m=d[f-1][0]-o,v=d[f-1][1]-s,y=0,b=0,x=0,E=0,w=0;c&&Es(c)&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],w=Math.atan2(r,n),y=Math.cos(w)*(l||0),b=Math.sin(w)*(l||0)),u&&Es(u)&&h&&(n=d[f-2][0]-d[f-1][0],r=d[f-2][1]-d[f-1][1],w=Math.atan2(r,n),x=Math.cos(w)*(h||0),E=Math.sin(w)*(h||0)),t.moveTo(p+y,g+b);for(var M=1;M<f-1;M++){var N=d[M];t.lineTo(N[0]-o,N[1]-s)}t.lineTo(m+x,v+E)}function Cz(t,e){var n=e.radius,r=e.width,i=e.height,o=r,a=i;if(n&&n.some((function(t){return 0!==t}))){var s=r>0?1:-1,c=i>0?1:-1,l=s+c===0,h=u(n.map((function(t){return Vt(t,0,Math.min(Math.abs(o)/2,Math.abs(a)/2))})),4),d=h[0],f=h[1],p=h[2],g=h[3];t.moveTo(s*d,0),t.lineTo(o-s*f,0),0!==f&&t.arc(o-s*f,c*f,f,-c*Math.PI/2,s>0?0:Math.PI,l),t.lineTo(o,a-c*p),0!==p&&t.arc(o-s*p,a-c*p,p,s>0?0:Math.PI,c>0?Math.PI/2:1.5*Math.PI,l),t.lineTo(s*g,a),0!==g&&t.arc(s*g,a-c*g,g,c>0?Math.PI/2:-Math.PI/2,s>0?Math.PI:0,l),t.lineTo(0,c*d),0!==d&&t.arc(s*d,c*d,d,s>0?Math.PI:0,c>0?1.5*Math.PI:Math.PI/2,l)}else t.rect(0,0,o,a)}var Tz=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.name="canvas-path-generator",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[Yn.CIRCLE]=xz,t[Yn.ELLIPSE]=Ez,t[Yn.RECT]=Cz,t[Yn.LINE]=wz,t[Yn.POLYLINE]=Sz,t[Yn.POLYGON]=Nz,t[Yn.PATH]=Mz,t[Yn.TEXT]=void 0,t[Yn.GROUP]=void 0,t[Yn.IMAGE]=void 0,t[Yn.HTML]=void 0,t[Yn.MESH]=void 0,t);this.context.pathGeneratorFactory=e},e.prototype.destroy=function(){delete this.context.pathGeneratorFactory},e}(Zn),Pz=Z(),kz=Z(),Az=Z(),Oz=x(),_z=function(){function t(){var t=this;this.isHit=function(e,n,r,i){var o=t.context.pointInPathPickerFactory[e.nodeName];if(o){var a=C(Oz,r),s=lt(kz,nt(Az,n[0],n[1],0),a),c=e.getGeometryBounds().halfExtents,u=e.parsedStyle.anchor;if(s[0]+=(u&&u[0]||0)*c[0]*2,s[1]+=(u&&u[1]||0)*c[1]*2,o(e,new Mr(s[0],s[1]),i,t.isPointInPath,t.context,t.runtime))return!0}return!1},this.isPointInPath=function(e,n){var r=t.runtime.offscreenCanvasCreator.getOrCreateContext(t.context.config.offscreenCanvas),i=t.context.pathGeneratorFactory[e.nodeName];return i&&(r.beginPath(),i(r,e.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return t.prototype.apply=function(e,n){var r,i=this,o=e.renderingService,c=e.renderingContext;this.context=e,this.runtime=n;var u=null===(r=c.root)||void 0===r?void 0:r.ownerDocument;o.hooks.pick.tapPromise(t.tag,(function(t){return a(i,void 0,void 0,(function(){return s(this,(function(e){return[2,this.pick(u,t)]}))}))})),o.hooks.pickSync.tap(t.tag,(function(t){return i.pick(u,t)}))},t.prototype.pick=function(t,e){var n,r,i=e.topmost,o=e.position,a=o.x,s=o.y,u=nt(Pz,a,s,0),l=t.elementsFromBBox(u[0],u[1],u[0],u[1]),h=[];try{for(var d=c(l),f=d.next();!f.done;f=d.next()){var p=f.value,g=p.getWorldTransform();if(this.isHit(p,u,g,!1)){var m=ua(p);if(m){var v=m.parsedStyle.clipPath;if(this.isHit(v,u,v.getWorldTransform(),!0)){if(i)return e.picked=[p],e;h.push(p)}}else{if(i)return e.picked=[p],e;h.push(p)}}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return e.picked=h,e},t.tag="CanvasPicker",t}();function Rz(t,e,n){var r=t.parsedStyle,i=r.r,o=r.fill,a=r.stroke,s=r.lineWidth,c=r.increasedLineWidthForHitTesting,l=r.pointerEvents,h=((s||0)+(c||0))/2,d=Pn(i,i,e.x,e.y),f=u(fa(l,o,a),2),p=f[0],g=f[1];return p&&g||n?d<=i+h:p?d<=i:!!g&&(d>=i-h&&d<=i+h)}function Dz(t,e,n,r){return t/(n*n)+e/(r*r)}function Iz(t,e,n){var r=t.parsedStyle,i=r.rx,o=r.ry,a=r.fill,s=r.stroke,c=r.lineWidth,l=r.increasedLineWidthForHitTesting,h=r.pointerEvents,d=e.x,f=e.y,p=u(fa(h,a,s),2),g=p[0],m=p[1],v=((c||0)+(l||0))/2,y=(d-i)*(d-i),b=(f-o)*(f-o);return g&&m||n?Dz(y,b,i+v,o+v)<=1:g?Dz(y,b,i,o)<=1:!!m&&(Dz(y,b,i-v,o-v)>=1&&Dz(y,b,i+v,o+v)<=1)}function Lz(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function jz(t,e,n,r,i,o,a,s){var c=(Math.atan2(s-e,a-t)+2*Math.PI)%(2*Math.PI),u={x:t+n*Math.cos(c),y:e+n*Math.sin(c)};return Pn(u.x,u.y,a,s)<=o/2}function zz(t,e,n,r,i,o,a){var s=Math.min(t,n),c=Math.max(t,n),u=Math.min(e,r),l=Math.max(e,r),h=i/2;return o>=s-h&&o<=c+h&&a>=u-h&&a<=l+h&&jn(t,e,n,r,o,a)<=i/2}function Bz(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var a=0;a<o-1;a++){if(zz(t[a][0],t[a][1],t[a+1][0],t[a+1][1],e,n,r))return!0}if(i){var s=t[0],c=t[o-1];if(zz(s[0],s[1],c[0],c[1],e,n,r))return!0}return!1}var Fz=1e-6;function Gz(t){return Math.abs(t)<Fz?0:t<0?-1:1}function Vz(t,e,n){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function Wz(t,e,n){var r=!1,i=t.length;if(i<=2)return!1;for(var o=0;o<i;o++){var a=t[o],s=t[(o+1)%i];if(Vz(a,s,[e,n]))return!0;Gz(a[1]-n)>0!=Gz(s[1]-n)>0&&Gz(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(r=!r)}return r}function Uz(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=Wz(t[i],e,n))break}return r}function Hz(t,e,n){var r=t.parsedStyle,i=r.x1,o=r.y1,a=r.x2,s=r.y2,c=r.lineWidth,l=r.increasedLineWidthForHitTesting,h=r.defX,d=void 0===h?0:h,f=r.defY,p=void 0===f?0:f;return!(!u(fa(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!c)&&zz(i,o,a,s,(c||0)+(l||0),e.x+d,e.y+p)}function $z(t,e,n,r,i,o){var a=t.parsedStyle,s=a.lineWidth,c=a.increasedLineWidthForHitTesting,l=a.stroke,h=a.fill,d=a.defX,f=void 0===d?0:d,p=a.defY,g=void 0===p?0:p,m=a.path,v=a.pointerEvents,y=m.segments,b=m.hasArc,x=m.polylines,E=m.polygons,w=u(fa(v,(null==E?void 0:E.length)&&h,l),2),M=w[0],N=w[1],S=Zi(t),C=!1;return M||n?C=b?r(t,e):Uz(E,e.x+f,e.y+g)||Uz(x,e.x+f,e.y+g):((N||n)&&(C=function(t,e,n,r,i){for(var o=!1,a=e/2,s=0;s<t.length;s++){var c=t[s],u=c.currentPoint,l=c.params,h=c.prePoint,d=c.box;if(!d||Lz(d.x-a,d.y-a,d.width+e,d.height+e,n,r))switch(c.command){case"L":case"Z":if(o=zz(h[0],h[1],u[0],u[1],e,n,r))return!0;break;case"Q":if(o=$n(h[0],h[1],l[1],l[2],l[3],l[4],n,r)<=e/2)return!0;break;case"C":if(o=Gn(h[0],h[1],l[1],l[2],l[3],l[4],l[5],l[6],n,r,i)<=e/2)return!0;break;case"A":c.cubicParams||(c.cubicParams=_e(h[0],h[1],l[1],l[2],l[3],l[4],l[5],l[6],l[7],void 0));for(var f=c.cubicParams,p=h,g=0;g<f.length;g+=6){var m=Gn(p[0],p[1],f[g],f[g+1],f[g+2],f[g+3],f[g+4],f[g+5],n,r,i);if(p=[f[g+4],f[g+5]],o=m<=e/2)return!0}}}return o}(y,(s||0)+(c||0),e.x+f,e.y+g,S)),C)}function qz(t,e,n){var r=t.parsedStyle,i=r.stroke,o=r.fill,a=r.lineWidth,s=r.increasedLineWidthForHitTesting,c=r.points,l=r.defX,h=void 0===l?0:l,d=r.defY,f=void 0===d?0:d,p=u(fa(r.pointerEvents,o,i),2),g=p[0],m=!1;return(p[1]||n)&&(m=Bz(c.points,(a||0)+(s||0),e.x+h,e.y+f,!0)),m||!g&&!n||(m=Wz(c.points,e.x+h,e.y+f)),m}function Yz(t,e,n){var r=t.parsedStyle,i=r.lineWidth,o=r.increasedLineWidthForHitTesting,a=r.points,s=r.defX,c=void 0===s?0:s,l=r.defY,h=void 0===l?0:l;return!(!u(fa(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!i)&&Bz(a.points,(i||0)+(o||0),e.x+c,e.y+h,!1)}function Kz(t,e,n,r,i){var o=t.parsedStyle,a=o.radius,s=o.fill,c=o.stroke,l=o.lineWidth,h=o.increasedLineWidthForHitTesting,d=o.width,f=o.height,p=u(fa(o.pointerEvents,s,c),2),g=p[0],m=p[1],v=(l||0)+(h||0);if(a&&a.some((function(t){return 0!==t}))){var y=!1;return(m||n)&&(y=function(t,e,n,r,i,o,a,s){var c=u(i,4),l=c[0],h=c[1],d=c[2],f=c[3];return zz(t+l,e,t+n-h,e,o,a,s)||zz(t+n,e+h,t+n,e+r-d,o,a,s)||zz(t+n-d,e+r,t+f,e+r,o,a,s)||zz(t,e+r-f,t,e+l,o,a,s)||jz(t+n-h,e+h,h,Math.PI,Math.PI,o,a,s)||jz(t+n-d,e+r-d,d,0,Math.PI,o,a,s)||jz(t+f,e+r-f,f,Math.PI,Math.PI,o,a,s)||jz(t+l,e+l,l,Math.PI,Math.PI,o,a,s)}(0,0,d,f,a.map((function(t){return Vt(t,0,Math.min(Math.abs(d)/2,Math.abs(f)/2))})),v,e.x,e.y)),y||!g&&!n||(y=r(t,e)),y}var b=v/2;return g&&m||n?Lz(0-b,0-b,d+b,f+b,e.x,e.y):g?Lz(0,0,d,f,e.x,e.y):!!m&&function(t,e,n,r,i,o,a){var s=i/2;return Lz(t-s,e-s,n,i,o,a)||Lz(t+n-s,e-s,i,r,o,a)||Lz(t+s,e+r-s,n,i,o,a)||Lz(t-s,e+s,i,r,o,a)}(0,0,d,f,v,e.x,e.y)}function Xz(t,e,n,r,i,o){var a=t.parsedStyle,s=a.pointerEvents,c=a.width,u=a.height;if("non-transparent-pixel"===s){var l=i.config.offscreenCanvas,h=o.offscreenCanvasCreator.getOrCreateCanvas(l),d=o.offscreenCanvasCreator.getOrCreateContext(l,{willReadFrequently:!0});return h.width=c,h.height=u,i.defaultStyleRendererFactory[Yn.IMAGE].render(d,t.parsedStyle,t,void 0,void 0,void 0),d.getImageData(e.x,e.y,1,1).data.every((function(t){return 0!==t}))}return!0}var Zz=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.name="canvas-picker",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[Yn.CIRCLE]=Rz,t[Yn.ELLIPSE]=Iz,t[Yn.RECT]=Kz,t[Yn.LINE]=Hz,t[Yn.POLYLINE]=Yz,t[Yn.POLYGON]=qz,t[Yn.PATH]=$z,t[Yn.TEXT]=function(){return!0},t[Yn.GROUP]=null,t[Yn.IMAGE]=Xz,t[Yn.HTML]=null,t[Yn.MESH]=null,t);this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new _z)},e.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},e}(Zn),Qz=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=x(),this.dprMatrix=x(),this.tmpMat4=x(),this.vec3a=Z(),this.vec3b=Z(),this.vec3c=Z(),this.vec3d=Z()}return t.prototype.apply=function(e,n){var r=this;this.context=e;var i=e.config,o=e.camera,a=e.renderingService,s=e.renderingContext,c=e.rBushRoot,h=e.pathGeneratorFactory;this.rBush=c,this.pathGeneratorFactory=h;var d=e.contextService,f=s.root.ownerDocument.defaultView,p=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)},g=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)};a.hooks.init.tap(t.tag,(function(){f.addEventListener(Za.UNMOUNTED,p),f.addEventListener(Za.CULLED,g);var t=d.getDPR(),e=i.width,n=i.height,o=d.getContext();r.clearRect(o,0,0,e*t,n*t,i.background)})),a.hooks.destroy.tap(t.tag,(function(){f.removeEventListener(Za.UNMOUNTED,p),f.removeEventListener(Za.CULLED,g),r.renderQueue=[],r.removedRBushNodeAABBs=[],r.restoreStack=[]})),a.hooks.beginFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR(),n=i.width,o=i.height,s=r.canvasRendererPluginOptions,c=s.dirtyObjectNumThreshold,u=s.dirtyObjectRatioThreshold,l=a.getStats(),h=l.total,f=l.rendered,p=f/h;r.clearFullScreen=a.disableDirtyRectangleRendering()||f>c&&p>u,t&&(t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),r.clearFullScreen&&r.clearRect(t,0,0,n*e,o*e,i.background))}));var m=function(t,e){t.isVisible()&&!t.isCulled()&&(r.renderDisplayObject(t,e,r.context,r.restoreStack,n),r.saveDirtyAABB(t)),(t.sortable.sorted||t.childNodes).forEach((function(t){m(t,e)}))};a.hooks.endFrame.tap(t.tag,(function(){var t=d.getContext(),e=d.getDPR();if(D(r.dprMatrix,[e,e,1]),P(r.vpMatrix,r.dprMatrix,o.getOrthoMatrix()),r.clearFullScreen)m(s.root,t);else{var a=r.safeMergeAABB.apply(r,l([r.mergeDirtyAABBs(r.renderQueue)],u(r.removedRBushNodeAABBs.map((function(t){var e=t.minX,n=t.minY,r=t.maxX,i=t.maxY,o=new vr;return o.setMinMax([e,n,0],[r,i,0]),o}))),!1));if(r.removedRBushNodeAABBs=[],vr.isEmpty(a))return void(r.renderQueue=[]);var c=r.convertAABB2Rect(a),h=c.x,p=c.y,g=c.width,v=c.height,y=lt(r.vec3a,[h,p,0],r.vpMatrix),b=lt(r.vec3b,[h+g,p,0],r.vpMatrix),x=lt(r.vec3c,[h,p+v,0],r.vpMatrix),E=lt(r.vec3d,[h+g,p+v,0],r.vpMatrix),w=Math.min(y[0],b[0],E[0],x[0]),M=Math.min(y[1],b[1],E[1],x[1]),N=Math.max(y[0],b[0],E[0],x[0]),S=Math.max(y[1],b[1],E[1],x[1]),C=Math.floor(w),T=Math.floor(M),k=Math.ceil(N-w),A=Math.ceil(S-M);t.save(),r.clearRect(t,C,T,k,A,i.background),t.beginPath(),t.rect(C,T,k,A),t.clip(),t.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),i.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new $a(ws.DIRTY_RECTANGLE,{dirtyRect:{x:C,y:T,width:k,height:A}})),r.searchDirtyObjects(a).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t,r.context,r.restoreStack,n)})),t.restore(),r.renderQueue.forEach((function(t){r.saveDirtyAABB(t)})),r.renderQueue=[]}r.restoreStack.forEach((function(){t.restore()})),r.restoreStack=[]})),a.hooks.render.tap(t.tag,(function(t){r.clearFullScreen||r.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,n,r,i,o){t.clearRect(e,n,r,i),o&&(t.fillStyle=o,t.fillRect(e,n,r,i))},t.prototype.renderDisplayObject=function(t,e,n,r,i){var o=t.nodeName,a=r[r.length-1];!a||t.compareDocumentPosition(a)&Ya.DOCUMENT_POSITION_CONTAINS||(e.restore(),r.pop());var s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=t.parsedStyle.clipPath;if(u){this.applyWorldTransform(e,u);var l=this.pathGeneratorFactory[u.nodeName];l&&(e.save(),r.push(t),e.beginPath(),l(e,u.parsedStyle),e.closePath(),e.clip())}s&&(this.applyWorldTransform(e,t),e.save(),this.applyAttributesToContext(e,t)),c&&(e.beginPath(),c(e,t.parsedStyle),t.nodeName!==Yn.LINE&&t.nodeName!==Yn.PATH&&t.nodeName!==Yn.POLYLINE&&e.closePath()),s&&(s.render(e,t.parsedStyle,t,n,this,i),e.restore()),t.renderable.dirty=!1},t.prototype.convertAABB2Rect=function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}},t.prototype.mergeDirtyAABBs=function(t){var e=new vr;return t.forEach((function(t){var n=t.getRenderBounds();e.add(n);var r=t.renderable.dirtyRenderBounds;r&&e.add(r)})),e},t.prototype.searchDirtyObjects=function(t){var e=u(t.getMin(),2),n=e[0],r=e[1],i=u(t.getMax(),2),o=i[0],a=i[1];return this.rBush.search({minX:n,minY:r,maxX:o,maxY:a}).map((function(t){return t.displayObject}))},t.prototype.saveDirtyAABB=function(t){var e=t.renderable;e.dirtyRenderBounds||(e.dirtyRenderBounds=new vr);var n=t.getRenderBounds();n&&e.dirtyRenderBounds.update(n.center,n.halfExtents)},t.prototype.applyAttributesToContext=function(t,e){var n=e.parsedStyle,r=n.stroke,i=n.fill,o=n.opacity,a=n.lineDash,s=n.lineDashOffset;a&&t.setLineDash(a),kt(s)||(t.lineDashOffset=s),kt(o)||(t.globalAlpha*=o),kt(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),kt(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,n){var r=0,i=0,o=(e.parsedStyle||{}).anchor,a=o&&o[0]||0,s=o&&o[1]||0;if(0!==a||0!==s){var c=e.geometry.contentBounds;r=-a*(c&&2*c.halfExtents[0]||0),i=-s*(c&&2*c.halfExtents[1]||0)}n?(w(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,k(this.tmpMat4,this.tmpMat4,this.vec3a),P(this.tmpMat4,n,this.tmpMat4),P(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(w(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,k(this.tmpMat4,this.tmpMat4,this.vec3a),P(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},t.prototype.safeMergeAABB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new vr;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),Jz=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n,r,i,o){var a=e.fill,s=e.fillRule,c=e.opacity,u=e.fillOpacity,l=e.stroke,h=e.strokeOpacity,d=e.lineWidth,f=e.lineCap,p=e.lineJoin,g=e.shadowType,m=e.shadowColor,v=e.shadowBlur,y=e.filter,b=e.miterLimit,x=!kt(a)&&!a.isNone,E=!kt(l)&&!l.isNone&&d>0,w=0===a.alpha,M=!(!y||!y.length),N=!kt(m)&&v>0,S=n.nodeName,C="inner"===g,T=E&&N&&(S===Yn.PATH||S===Yn.LINE||S===Yn.POLYLINE||w||C);x&&(t.globalAlpha=c*u,T||tB(n,t,N),this.fill(t,n,a,s,r,i,o),T||this.clearShadowAndFilter(t,M,N)),E&&(t.globalAlpha=c*h,t.lineWidth=d,kt(b)||(t.miterLimit=b),kt(f)||(t.lineCap=f),kt(p)||(t.lineJoin=p),T&&(C&&(t.globalCompositeOperation="source-atop"),tB(n,t,!0),C&&(this.stroke(t,n,l,r,i,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,M,!0))),this.stroke(t,n,l,r,i,o))},t.prototype.clearShadowAndFilter=function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!kt(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,e,n,r,i,o,a){var s=this;Array.isArray(n)?n.forEach((function(n){t.fillStyle=s.getColor(n,e,t),r?t.fill(r):t.fill()})):(Ti(n)&&(t.fillStyle=this.getPattern(n,e,t,i,o,a)),r?t.fill(r):t.fill())},t.prototype.stroke=function(t,e,n,r,i,o){var a=this;Array.isArray(n)?n.forEach((function(n){t.strokeStyle=a.getColor(n,e,t),t.stroke()})):(Ti(n)&&(t.strokeStyle=this.getPattern(n,e,t,r,i,o)),t.stroke())},t.prototype.getPattern=function(t,e,n,r,i,o){var a,s;if("rect"===t.image.nodeName){var c=t.image.parsedStyle,u=c.width,l=c.height;s=r.contextService.getDPR();var h=r.config.offscreenCanvas;(a=o.offscreenCanvasCreator.getOrCreateCanvas(h)).width=u*s,a.height=l*s;var d=o.offscreenCanvasCreator.getOrCreateContext(h),f=[];t.image.forEach((function(t){i.renderDisplayObject(t,d,r,f,o)})),f.forEach((function(){d.restore()}))}return this.imagePool.getOrCreatePatternSync(t,n,a,s,(function(){e.renderable.dirty=!0,r.renderingService.dirtify()}))},t.prototype.getColor=function(t,e,n){var r;if(t.type===zr.LinearGradient||t.type===zr.RadialGradient){var o=e.getGeometryBounds(),a=o&&2*o.halfExtents[0]||1,s=o&&2*o.halfExtents[1]||1;r=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{width:a,height:s}),n)}return r},t}();function tB(t,e,n){var r=t.parsedStyle,i=r.filter,o=r.shadowColor,a=r.shadowBlur,s=r.shadowOffsetX,c=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=o.toString(),e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=c||0)}var eB=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n){var r,i=e.width,o=e.height,a=e.img,s=e.shadowColor,c=e.shadowBlur,u=i,l=o;if(Bt(a)?r=this.imagePool.getImageSync(a):(u||(u=a.width),l||(l=a.height),r=a),r){tB(n,t,!kt(s)&&c>0);try{t.drawImage(r,0,0,u,l)}catch(t){}}},t}(),nB=function(){function t(){}return t.prototype.render=function(t,e,n,r,i,o){var a=e,s=a.lineWidth,c=a.textAlign,u=a.textBaseline,l=a.lineJoin,h=a.miterLimit,d=a.letterSpacing,f=a.stroke,p=a.fill,g=a.fillOpacity,m=a.strokeOpacity,v=a.opacity,y=a.metrics,b=a.dx,x=a.dy,E=a.shadowColor,w=a.shadowBlur,M=y.font,N=y.lines,S=y.height,C=y.lineHeight,T=y.lineMetrics;t.font=M,t.lineWidth=s,t.textAlign="middle"===c?"center":c;var P=u;o.enableCSSParsing||"alphabetic"!==P||(P="bottom"),t.lineJoin=l,kt(h)||(t.miterLimit=h);var k=0;"middle"===u?k=-S/2-C/2:"bottom"===u||"alphabetic"===u||"ideographic"===u?k=-S:"top"!==u&&"hanging"!==u||(k=-C);var A=b||0;k+=x||0,1===N.length&&("bottom"===P?(P="middle",k-=.5*S):"top"===P&&(P="middle",k+=.5*S)),t.textBaseline=P,tB(n,t,!kt(E)&&w>0);for(var O=0;O<N.length;O++){var _=s/2+A;k+=C,kt(f)||f.isNone||!s||this.drawLetterSpacing(t,N[O],T[O],c,_,k,d,g,m,v,!0),kt(p)||this.drawLetterSpacing(t,N[O],T[O],c,_,k,d,g,m,v)}},t.prototype.drawLetterSpacing=function(t,e,n,r,i,o,a,s,c,u,l){if(void 0===l&&(l=!1),0!==a){var h=t.textAlign;t.textAlign="left";var d=i;"center"===r||"middle"===r?d=i-n.width/2:"right"!==r&&"end"!==r||(d=i-n.width);for(var f=Array.from(e),p=t.measureText(e).width,g=0,m=0;m<f.length;++m){var v=f[m];l?this.strokeText(t,v,d,o,c):this.fillText(t,v,d,o,s,u),d+=p-(g=t.measureText(e.substring(m+1)).width)+a,p=g}t.textAlign=h}else l?this.strokeText(t,e,i,o,c):this.fillText(t,e,i,o,s,u)},t.prototype.fillText=function(t,e,n,r,i,o){var a,s=!kt(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,n,r),s&&(t.globalAlpha=a)},t.prototype.strokeText=function(t,e,n,r,i){var o,a=!kt(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,n,r),a&&(t.globalAlpha=o)},t}();!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Jz),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Jz),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Jz),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Jz),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Jz),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Jz),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(Jz);var rB=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="canvas-renderer",n}return r(e,t),e.prototype.init=function(){var t,e=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,r=new Jz(n),o=((t={})[Yn.CIRCLE]=r,t[Yn.ELLIPSE]=r,t[Yn.RECT]=r,t[Yn.IMAGE]=new eB(n),t[Yn.TEXT]=new nB,t[Yn.LINE]=r,t[Yn.POLYLINE]=r,t[Yn.POLYGON]=r,t[Yn.PATH]=r,t[Yn.GROUP]=void 0,t[Yn.HTML]=void 0,t[Yn.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new Qz(e))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},e}(Zn),iB=function(){function t(){}return t.prototype.apply=function(e,n){var r=this,i=e.renderingService,o=e.renderingContext,a=e.config;this.context=e;var s=o.root.ownerDocument.defaultView,c=function(t){i.hooks.pointerMove.call(t)},u=function(t){i.hooks.pointerUp.call(t)},l=function(t){i.hooks.pointerDown.call(t)},h=function(t){i.hooks.pointerOver.call(t)},d=function(t){i.hooks.pointerOut.call(t)},f=function(t){i.hooks.pointerCancel.call(t)},p=function(t){i.hooks.pointerWheel.call(t)},g=function(t){i.hooks.click.call(t)};i.hooks.init.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):s.supportsPointerEvents&&(t.style.touchAction="none"),s.supportsPointerEvents?function(t){n.globalThis.document.addEventListener("pointermove",c,!0),t.addEventListener("pointerdown",l,!0),t.addEventListener("pointerleave",d,!0),t.addEventListener("pointerover",h,!0),n.globalThis.addEventListener("pointerup",u,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(t):function(t){n.globalThis.document.addEventListener("mousemove",c,!0),t.addEventListener("mousedown",l,!0),t.addEventListener("mouseout",d,!0),t.addEventListener("mouseover",h,!0),n.globalThis.addEventListener("mouseup",u,!0)}(t),s.supportsTouchEvents&&function(t){t.addEventListener("touchstart",l,!0),t.addEventListener("touchend",u,!0),t.addEventListener("touchmove",c,!0),t.addEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.addEventListener("click",g,!0),t.addEventListener("wheel",p,{passive:!0,capture:!0})})),i.hooks.destroy.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){n.globalThis.document.removeEventListener("pointermove",c,!0),t.removeEventListener("pointerdown",l,!0),t.removeEventListener("pointerleave",d,!0),t.removeEventListener("pointerover",h,!0),n.globalThis.removeEventListener("pointerup",u,!0)}(t):function(t){n.globalThis.document.removeEventListener("mousemove",c,!0),t.removeEventListener("mousedown",l,!0),t.removeEventListener("mouseout",d,!0),t.removeEventListener("mouseover",h,!0),n.globalThis.removeEventListener("mouseup",u,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",l,!0),t.removeEventListener("touchend",u,!0),t.removeEventListener("touchmove",c,!0),t.removeEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.removeEventListener("click",g,!0),t.removeEventListener("wheel",p,!0)}))},t.tag="DOMInteraction",t}(),oB=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.name="dom-interaction",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new iB)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Zn),aB=function(){function t(){this.displayObjectHTMLElementMap=new WeakMap}return t.prototype.joinTransformMatrix=function(t){return"matrix(".concat([t[0],t[1],t[4],t[5],t[12],t[13]].join(","),")")},t.prototype.apply=function(e,n){var r=this,i=e.camera,o=e.renderingContext,a=e.renderingService;this.context=e;var s=o.root.ownerDocument.defaultView,c=s.context.eventService.nativeHTMLMap,u=function(t,e){e.style.transform=r.joinTransformMatrix(t.getWorldTransform())},l=function(t){var e=t.target;if(e.nodeName===Yn.HTML){r.$camera||(r.$camera=r.createCamera(i));var o=r.getOrCreateEl(e);if(r.$camera.appendChild(o),n.enableCSSParsing){var a=e.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(t){o.style[t]=a[t]}))}Object.keys(e.attributes).forEach((function(t){r.updateAttribute(t,e)})),u(e,o),c.set(o,e)}},h=function(t){var e=t.target;if(e.nodeName===Yn.HTML&&r.$camera){var n=r.getOrCreateEl(e);n&&(n.remove(),c.delete(n))}},d=function(t){var e=t.target;if(e.nodeName===Yn.HTML){var n=t.attrName;r.updateAttribute(n,e)}},f=function(t){var e=t.target;if(e.nodeName===Yn.HTML){var n=r.getOrCreateEl(e);u(e,n)}},p=function(){if(r.$camera){var t=r.context.config,e=t.width,n=t.height;r.$camera.style.width="".concat(e||0,"px"),r.$camera.style.height="".concat(n||0,"px")}};a.hooks.init.tap(t.tag,(function(){s.addEventListener(ws.RESIZE,p),s.addEventListener(Za.MOUNTED,l),s.addEventListener(Za.UNMOUNTED,h),s.addEventListener(Za.ATTR_MODIFIED,d),s.addEventListener(Za.BOUNDS_CHANGED,f)})),a.hooks.endFrame.tap(t.tag,(function(){r.$camera&&o.renderReasons.has(Ga.CAMERA_CHANGED)&&(r.$camera.style.transform=r.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(t.tag,(function(){r.$camera&&r.$camera.remove(),s.removeEventListener(ws.RESIZE,p),s.removeEventListener(Za.MOUNTED,l),s.removeEventListener(Za.UNMOUNTED,h),s.removeEventListener(Za.ATTR_MODIFIED,d),s.removeEventListener(Za.BOUNDS_CHANGED,f)}))},t.prototype.createCamera=function(t){var e=this.context.config,n=e.document,r=e.width,i=e.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",c=a.querySelector("#"+s);if(!c){var u=(n||document).createElement("div");c=u,u.id=s,u.style.position="absolute",u.style.left="".concat(o.offsetLeft||0,"px"),u.style.top="".concat(o.offsetTop||0,"px"),u.style.transformOrigin="left top",u.style.transform=this.joinTransformMatrix(t.getOrthoMatrix()),u.style.overflow="hidden",u.style.pointerEvents="none",u.style.width="".concat(r||0,"px"),u.style.height="".concat(i||0,"px"),a.appendChild(u)}return c}return null},t.prototype.getOrCreateEl=function(t){var e=this.context.config.document,n=this.displayObjectHTMLElementMap.get(t);return n||(n=(e||document).createElement("div"),t.parsedStyle.$el=n,this.displayObjectHTMLElementMap.set(t,n),t.id&&(n.id=t.id),t.name&&n.setAttribute("name",t.name),t.className&&(n.className=t.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(t.getWorldTransform())),n},t.prototype.updateAttribute=function(t,e){var n=this.getOrCreateEl(e);switch(t){case"innerHTML":var r=e.parsedStyle.innerHTML;Bt(r)?n.innerHTML=r:(n.innerHTML="",n.appendChild(r));break;case"transformOrigin":var i=e.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(i[0].value," ").concat(i[1].value);break;case"width":if(this.context.enableCSSParsing){var o=e.computedStyleMap().get("width");n.style.width=o.toString()}else{o=e.parsedStyle.width;n.style.width=Wt(o)?"".concat(o,"px"):o.toString()}break;case"height":if(this.context.enableCSSParsing){var a=e.computedStyleMap().get("height");n.style.height=a.toString()}else{a=e.parsedStyle.height;n.style.height=Wt(a)?"".concat(a,"px"):a.toString()}break;case"zIndex":var s=e.parsedStyle.zIndex;n.style["z-index"]="".concat(s);break;case"visibility":var c=e.parsedStyle.visibility;n.style.visibility=c;break;case"pointerEvents":var u=e.parsedStyle.pointerEvents;n.style.pointerEvents=u;break;case"opacity":var l=e.parsedStyle.opacity;n.style.opacity="".concat(l);break;case"fill":var h=e.parsedStyle.fill,d="";Pi(h)?d=h.isNone?"transparent":e.getAttribute("fill"):Array.isArray(h)?d=e.getAttribute("fill"):Ti(h),n.style.background=d;break;case"stroke":var f=e.parsedStyle.stroke,p="";Pi(f)?p=f.isNone?"transparent":e.getAttribute("stroke"):Array.isArray(f)?p=e.getAttribute("stroke"):Ti(f),n.style["border-color"]=p,n.style["border-style"]="solid";break;case"lineWidth":var g=e.parsedStyle.lineWidth;n.style["border-width"]="".concat(g||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":var m=e.style.filter;n.style.filter=m;break;default:"x"!==t&&"y"!==t&&(kt(e.style[t])||""===e.style[t]||(n.style[t]=e.style[t]))}},t.tag="HTMLRendering",t}(),sB=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.name="html-renderer",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new aB)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Zn),cB=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e(this.imageCache[t]):this.getOrCreateImage(t).then((function(t){e&&e(t)})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var e=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var n=this.canvasConfig.createImage;return new Promise((function(r,i){var o;n?o=n(t):aa&&(o=new window.Image),o&&(o.onload=function(){e.imageCache[t]=o,r(o)},o.onerror=function(t){i(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,e,n,r,i){var o=this.generatePatternKey(t);if(o&&this.patternCache[o])return this.patternCache[o];var a,s=t.image,c=t.repetition,u=t.transform,l=!1;Bt(s)?a=this.getImageSync(s,i):n?(a=n,l=!0):a=s;var h=a&&e.createPattern(a,c);if(h){var d=void 0;d=u?qo(bo(u),new ks({})):N(x()),l&&A(d,d,[1/r,1/r,1]),h.setTransform({a:d[0],b:d[1],c:d[4],d:d[5],e:d[12],f:d[13]})}return o&&h&&(this.patternCache[o]=h),h},t.prototype.getOrCreateGradient=function(t,e){var n=this.generateGradientKey(t),r=t.type,i=t.steps,o=t.width,a=t.height,s=t.angle,c=t.cx,u=t.cy,l=t.size;if(this.gradientCache[n])return this.gradientCache[n];var h=null;if(r===zr.LinearGradient){var d=function(t,e,n){var r=or(n.value),i=0+t/2,o=0+e/2,a=Math.abs(t*Math.cos(r))+Math.abs(e*Math.sin(r));return{x1:i-Math.cos(r)*a/2,y1:o-Math.sin(r)*a/2,x2:i+Math.cos(r)*a/2,y2:o+Math.sin(r)*a/2}}(o,a,s),f=d.x1,p=d.y1,g=d.x2,m=d.y2;h=e.createLinearGradient(f,p,g,m)}else if(r===zr.RadialGradient){var v=function(t,e,n,r,i){var o=n.value,a=r.value;n.unit===Tr.kPercentage&&(o=n.value/100*t),r.unit===Tr.kPercentage&&(a=r.value/100*e);var s=Math.max(je([0,0],[o,a]),je([0,e],[o,a]),je([t,e],[o,a]),je([t,0],[o,a]));return i&&(i instanceof Jr?s=i.value:i instanceof Hr&&("closest-side"===i.value?s=Math.min(o,t-o,a,e-a):"farthest-side"===i.value?s=Math.max(o,t-o,a,e-a):"closest-corner"===i.value&&(s=Math.min(je([0,0],[o,a]),je([0,e],[o,a]),je([t,e],[o,a]),je([t,0],[o,a]))))),{x:o,y:a,r:s}}(o,a,c,u,l),y=v.x,b=v.y,x=v.r;h=e.createRadialGradient(y,b,0,y,b,x)}return h&&(i.forEach((function(t){var e=t.offset,n=t.color;e.unit===Tr.kPercentage&&(null==h||h.addColorStop(e.value/100,n.toString()))})),this.gradientCache[n]=h),this.gradientCache[n]},t.prototype.generateGradientKey=function(t){var e=t.type,n=t.width,r=t.height,i=t.steps,o=t.angle,a=t.cx,s=t.cy,c=t.size;return"gradient-".concat(e,"-").concat((null==o?void 0:o.toString())||0,"-").concat((null==a?void 0:a.toString())||0,"-").concat((null==s?void 0:s.toString())||0,"-").concat((null==c?void 0:c.toString())||0,"-").concat(n,"-").concat(r,"-").concat(i.map((function(t){var e=t.offset,n=t.color;return"".concat(e).concat(n)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return Bt(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),uB=function(){function t(){}return t.prototype.apply=function(e){var n=e.renderingService,r=e.renderingContext,i=e.imagePool,o=r.root.ownerDocument.defaultView,a=function(t,e,n){var r=t.parsedStyle,i=r.width,o=r.height;i&&!o?t.setAttribute("height",n/e*i):!i&&o&&t.setAttribute("width",e/n*o)},s=function(t){var e=t.target,r=e.nodeName,o=e.attributes;if(r===Yn.IMAGE){var s=o.img,c=o.keepAspectRatio;Bt(s)&&i.getImageSync(s,(function(t){var r=t.width,i=t.height;c&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))}},c=function(t){var e=t.target,r=t.attrName,o=t.newValue;e.nodeName===Yn.IMAGE&&"img"===r&&Bt(o)&&i.getOrCreateImage(o).then((function(t){var r=t.width,i=t.height;e.attributes.keepAspectRatio&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(t.tag,(function(){o.addEventListener(Za.MOUNTED,s),o.addEventListener(Za.ATTR_MODIFIED,c)})),n.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(Za.MOUNTED,s),o.removeEventListener(Za.ATTR_MODIFIED,c)}))},t.tag="LoadImage",t}(),lB=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.name="image-loader",e}return r(e,t),e.prototype.init=function(){this.context.imagePool=new cB(this.context.config),this.addRenderingPlugin(new uB)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Zn),hB=function(){function t(t){this.renderingContext=t.renderingContext,this.canvasConfig=t.config}return t.prototype.init=function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=Bt(e)?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)},t.prototype.getContext=function(){return this.context},t.prototype.getDomElement=function(){return this.$canvas},t.prototype.getDPR=function(){return this.dpr},t.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},t.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},t.prototype.resize=function(t,e){var n=this.canvasConfig.devicePixelRatio||aa&&window.devicePixelRatio||1;n=n>=1?Math.ceil(n):1,this.dpr=n,this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*e,function(t,e,n){aa&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add(Ga.CAMERA_CHANGED)},t.prototype.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},t.prototype.toDataURL=function(t){return void 0===t&&(t={}),a(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){return e=t.type,n=t.encoderOptions,[2,this.context.canvas.toDataURL(e,n)]}))}))},t}(),dB=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.name="canvas-context-register",e}return r(e,t),e.prototype.init=function(){this.context.ContextService=hB},e.prototype.destroy=function(){delete this.context.ContextService},e}(Zn),fB=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new dB),n.registerPlugin(new lB),n.registerPlugin(new Tz),n.registerPlugin(new rB),n.registerPlugin(new oB),n.registerPlugin(new Zz),n.registerPlugin(new sB),n}return r(e,t),e}(Qn),pB=function(){function t(t){this.dragndropPluginOptions=t}return t.prototype.apply=function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,c=function(t){var e=t.target,r=e===i,c=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(c){var u=!1,l=t.timeStamp,h=[t.clientX,t.clientY],d=null,f=[t.clientX,t.clientY],p=function(t){return a(n,void 0,void 0,(function(){var n,o,a,p,g,m;return s(this,(function(s){switch(s.label){case 0:if(!u){if(n=t.timeStamp-l,o=je([t.clientX,t.clientY],h),n<=this.dragndropPluginOptions.dragstartTimeThreshold||o<=this.dragndropPluginOptions.dragstartDistanceThreshold)return[2];t.type="dragstart",c.dispatchEvent(t),u=!0}return t.type="drag",t.dx=t.clientX-f[0],t.dy=t.clientY-f[1],c.dispatchEvent(t),f=[t.clientX,t.clientY],r?[3,2]:(a="pointer"===this.dragndropPluginOptions.overlap?[t.canvasX,t.canvasY]:e.getBounds().center,[4,i.elementsFromPoint(a[0],a[1])]);case 1:p=s.sent(),g=p[p.indexOf(e)+1],m=(null==g?void 0:g.closest("[droppable=true]"))||(this.dragndropPluginOptions.isDocumentDroppable?i:null),d!==m&&(d&&(t.type="dragleave",t.target=d,d.dispatchEvent(t)),m&&(t.type="dragenter",t.target=m,m.dispatchEvent(t)),(d=m)&&(t.type="dragover",t.target=d,d.dispatchEvent(t))),s.label=2;case 2:return[2]}}))}))};o.addEventListener("pointermove",p);var g=function(t){if(u){t.detail={preventClick:!0};var e=t.clone();d&&(e.type="drop",e.target=d,d.dispatchEvent(e)),e.type="dragend",c.dispatchEvent(e),u=!1}o.removeEventListener("pointermove",p)};e.addEventListener("pointerup",g,{once:!0}),e.addEventListener("pointerupoutside",g,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",c)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",c)}))},t.tag="Dragndrop",t}(),gB=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="dragndrop",n}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new pB(i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e.prototype.setOptions=function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)},e}(Zn);class mB{config;background;main;label;transient;get canvas(){return{main:this.main,label:this.label,transient:this.transient,background:this.background}}get document(){return this.main.document}renderers;initialized=!1;constructor(t){this.config=t}async init(){if(this.initialized)return;const{renderer:t,background:e,...n}=this.config,{renderers:r,canvas:i}=["main","label","transient","background"].reduce(((e,r)=>{const i=Pt(t)?t?.(r):new fB;"main"===r?i.registerPlugin(new gB({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):i.unregisterPlugin(i.getPlugin("dom-interaction"));const o=new tc({renderer:i,supportsMutipleCanvasesInOneContainer:!0,...n});return e.renderers[r]=i,e.canvas[r]=o,this[r]=o,e}),{renderers:{},canvas:{}});this.renderers=r,Object.entries(i).forEach((([t,e])=>{const n=e.getContextService().getDomElement();n.style.position="absolute",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")})),this.setBackground(),await Promise.all(Object.values(this.canvas).map((t=>t.ready))),this.initialized=!0}getRendererType(t="main"){const e=this.renderers[t].getPlugins();for(const t of e){if("canvas-renderer"===t.name)return"canvas";if("svg-renderer"===t.name)return"svg";if("device-renderer"===t.name)return"gpu"}return"unknown"}get context(){return this.main.context}getDevice(){return this.main.context?.deviceRendererPlugin?.getDevice()}getConfig(){return this.config}setBackground(t=this.config.background){const e=this.getContainer();this.config.background=t,e&&t&&(e.style.background=t,e.style.transition="background 0.5s")}setCursor(t){Object.values(this.canvas).forEach((e=>{e.setCursor(t)}))}getSize(){return[this.config.width||0,this.config.height||0]}resize(t,e){this.config.width=t,this.config.height=e,Object.values(this.canvas).forEach((n=>{n.resize(t,e)}))}getCamera(){return this.main.getCamera()}getBounds(){return Pu(Object.values(this.canvas).map((t=>t.document.documentElement)).filter((t=>t.childNodes.length>0)).map((t=>t.getRenderBounds())))}getContainer(){const t=this.config.container;return Bt(t)?document.getElementById(t):t}appendChild(t){return this[t.style?.$layer||"main"].appendChild(t)}getContextService(){return this.main.getContextService()}viewport2Client(t){return this.main.viewport2Client(t)}viewport2Canvas(t){return this.main.viewport2Canvas(t)}client2Viewport(t){return this.main.client2Viewport(t)}canvas2Viewport(t){return this.main.canvas2Viewport(t)}async toDataURL(t={}){const e=window.devicePixelRatio||1,{mode:n="viewport",...r}=t;let i=0,o=0,a=0,s=0;if("viewport"===n)[a,s]=[this.config.width||0,this.config.height||0];else if("overall"===n){const t=this.getBounds(),e=Su(t);[i,o]=t.min,[a,s]=e}const c=Ze('<div id="virtual-image"></div>'),u=new tc({width:a,height:s,renderer:new fB,devicePixelRatio:e,container:c,background:this.config.background});await u.ready,u.appendChild(this.background.getRoot().cloneNode(!0)),u.appendChild(this.main.getRoot().cloneNode(!0));const l=this.label.getRoot().cloneNode(!0),h=u.viewport2Canvas({x:0,y:0}),d=this.main.viewport2Canvas({x:0,y:0});l.translate([d.x-h.x,d.y-h.y]),l.scale(1/this.main.getCamera().getZoom()),u.appendChild(l),u.appendChild(this.transient.getRoot().cloneNode(!0));const f=this.main.getCamera(),p=u.getCamera();if("viewport"===n)p.setZoom(f.getZoom()),p.setPosition(f.getPosition()),p.setFocalPoint(f.getFocalPoint());else if("overall"===n){const[t,e,n]=p.getPosition(),[r,a,s]=p.getFocalPoint();p.setPosition([t+i,e+o,n]),p.setFocalPoint([r+i,a+o,s])}const g=u.getContextService();return new Promise((t=>{u.on(ws.RERENDER,(async()=>{await new Promise((t=>setTimeout(t,300)));const e=await g.toDataURL(r);t(e)}))}))}destroy(){this.config={},this.renderers={},Object.entries(this.canvas).forEach((([t,e])=>{const n=e.getCamera();n.landmarks?.length&&n.cancelLandmarkAnimation(),function(t){t.destroy();const e=t.getCamera();e.eventEmitter.removeAllListeners(),t.document.timeline.destroy();const{animationsWithPromises:n}=t.document.timeline;n.forEach((t=>{t.effect.target&&(t.effect.target=null),t.effect.computedTiming&&(t.effect.computedTiming=null)})),t.document.timeline.animationsWithPromises=[],t.document.timeline.rafCallbacks=[],t.document.timeline=null}(e),this[t]=void 0}))}}function vB(t,e){const{data:n,style:r,...i}=t,{data:o,style:a,...s}=e,c={...i,...s};return(n||o)&&Object.assign(c,{data:{...n,...o}}),(r||a)&&Object.assign(c,{style:{...r,...a}}),c}function yB(t){const{data:e,style:n,...r}=t,i=r;return e&&(i.data={...e}),n&&(i.style={...n}),i}function bB(t){const{id:e=Fu(t),style:n,data:r,...i}=t,o={...t,style:{...n},data:{...r}};return bu(t)?{id:e,data:o,...i}:{id:e,data:o}}function xB(t){return t.data}class EB{model;latestRemovedComboIds=new Set;comboIds=new Set;changes=[];batchCount=0;isTraceless=!1;constructor(){this.model=new Gp}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===uu.NodeUpdated||e===uu.EdgeUpdated||e===uu.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:yB(n),original:yB(r),type:e})}else this.changes.push({value:yB(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=xB(n);return this.isCombo(Fu(r))||(void 0===t||t.includes(Fu(r)))&&e.push(r),e}),[])}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=xB(n);return(void 0===t||t.includes(Fu(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=xB(n);return this.isCombo(Fu(r))?((void 0===t||t.includes(Fu(r)))&&e.push(r),e):e}),[])}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(xB):[]}getDescendantsData(t){const e=this.getElementsData([t])[0],n=[];return ad(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(Fu(t))),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void console.error("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?xB(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?vu:mu,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(xB):[]}getElementData(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementsData(t){return t.map((t=>{const e=this.getElementType(t);return"node"===e?this.getNodeData([t])[0]:"edge"===e?this.getEdgeData([t])[0]:this.getComboData([t])[0]}))}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=xB(n);return t?t.includes(Fu(r))&&e.push(r):e.push(r),e}),[])}getElementDataByState(t,e){return this.getElementData(t).filter((t=>t.style?.states?.includes(e)))}getElementState(t){return this.getElementsData([t])?.[0]?.style?.states||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(xB)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(xB)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i=[],edges:o=[],combos:a=[]}=this.getData(),s=Kh(i,e,(t=>Fu(t))),c=Kh(o,n,(t=>Fu(t))),u=Kh(a,r,(t=>Fu(t)));this.batch((()=>{this.addData({nodes:s.enter,edges:c.enter,combos:u.enter}),this.updateData({nodes:s.update,edges:c.update,combos:u.update}),this.removeData({nodes:s.exit.map(Fu),edges:c.exit.map(Fu),combos:u.exit.map(Fu)})}))}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)}))}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map((t=>(this.pushChange({value:t,type:uu.NodeAdded}),bB(t))))),this.updateNodeLikeHierarchy(t))}addEdgeData(t=[]){t.length&&this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:uu.EdgeAdded}),bB(t)))))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(mu)||e.attachTreeStructure(mu),e.addNodes(t.map((t=>(this.comboIds.add(Fu(t)),this.pushChange({value:t,type:uu.ComboAdded}),bB(t))))),this.updateNodeLikeHierarchy(t)}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=Fu(t);e.attachTreeStructure(mu),this.setParent(n,Gu(t),mu);const r=t?.style?.children;void 0!==r&&(e.attachTreeStructure(vu),r.forEach((t=>{this.setParent(t,n,vu)})))}))}enableUpdateNodeLikeHierarchy=!0;preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.updateNodeData(e),this.updateComboData(r),this.updateEdgeData(n)}))}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{const n=[];t.forEach((t=>{const r=Fu(t),i=xB(e.getNode(r));if(ae(i,t))return;const o=vB(i,t);this.pushChange({value:o,original:i,type:uu.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}syncNodeDatum(t){const{model:e}=this,n=Fu(t),r=vB(xB(e.getNode(n)),t);e.mergeNodeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{t.forEach((t=>{const n=Fu(t),r=xB(e.getEdge(n));if(ae(r,t))return;t.source&&r.source!==t.source&&e.updateEdgeSource(n,t.source),t.target&&r.target!==t.target&&e.updateEdgeTarget(n,t.target);const i=vB(r,t);this.pushChange({value:i,original:r,type:uu.EdgeUpdated}),e.mergeEdgeData(n,i)}))}))}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=Fu(t),i=xB(e.getNode(r));if(ae(i,t))return;const o=vB(i,t);this.pushChange({value:o,original:i,type:uu.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}setParent(t,e,n,r=!0){if(t===e)return;const i=Gu(this.getNodeLikeData([t])[0]);if(i!==e){const n={id:t,style:{parentId:e}};this.isCombo(t)?this.syncComboDatum(n):this.syncNodeDatum(n)}this.model.setParent(t,e,n),r&&new Set([i,e]).forEach((t=>{void 0!==t&&this.refreshComboData(t)}))}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,mu);e&&this.pushChange({value:e,original:e,type:uu.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:uu.ComboUpdated})}))}syncComboDatum(t){const{model:e}=this,n=Fu(t),r=vB(xB(e.getNode(n)),t);e.mergeNodeData(n,r)}getElementPosition(t){return _u(this.getElementsData([t])[0])}translateNodeBy(t,e){const n=Yu(this.getElementPosition(t),[...e,0].slice(0,3));this.translateNodeTo(t,n)}translateNodeTo(t,e){const[n=0,r=0,i=0]=e;this.preventUpdateNodeLikeHierarchy((()=>{this.updateNodeData([{id:t,style:{x:n,y:r,z:i}}])}))}translateComboBy(t,e){const[n=0,r=0,i=0]=e;if([n,r,i].some(isNaN)||[n,r,i].every((t=>0===t)))return;const o=this.getComboData([t])[0];o&&ad(o,(t=>{const e=Fu(t),[o,a,s]=_u(t),c=vB(t,{style:{x:o+n,y:a+r,z:s+i}});this.pushChange({value:c,original:t,type:this.isCombo(e)?uu.ComboUpdated:uu.NodeUpdated}),this.model.mergeNodeData(e,c)}),(t=>this.getChildrenData(Fu(t))),"BT")}translateComboTo(t,e){if(e.some(isNaN))return;const[n=0,r=0,i=0]=e,o=this.getComboData([t])?.[0];if(!o)return;const[a,s,c]=_u(o),u=n-a,l=r-s,h=i-c;ad(o,(t=>{const e=Fu(t),[n,r,i]=_u(t),o=vB(t,{style:{x:n+u,y:r+l,z:i+h}});this.pushChange({value:o,original:t,type:this.isCombo(e)?uu.ComboUpdated:uu.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(Fu(t))),"BT")}removeData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.removeEdgeData(n),this.removeNodeData(e),this.removeComboData(r),this.latestRemovedComboIds=new Set(r)}))}removeNodeData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Fu)),this.pushChange({value:this.getNodeData([t])[0],type:uu.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:uu.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:uu.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(mu)){const e=Gu(this.getNodeLikeData([t])[0]);this.setParent(t,void 0,mu,!1),this.model.getChildren(t,mu).forEach((t=>{const n=xB(t),r=Fu(n);this.setParent(Fu(n),e,mu,!1);const i=vB(n,{id:Fu(n),style:{parentId:e}});this.pushChange({value:i,original:n,type:this.isCombo(r)?uu.ComboUpdated:uu.NodeUpdated}),this.model.mergeNodeData(Fu(n),i)})),Qt(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error(`Unknown element type of id: ${t}`)}getFrontZIndex(t){let e=[];if("combo"===this.getElementType(t)){const n=[t,...this.getAncestorsData(t,mu).map(Fu)];e=this.getComboData().filter((t=>{const e=Fu(t),r=this.getAncestorsData(e,mu),i=r.map(Fu);return!r.some((t=>!!t.style?.collapsed))&&!n.includes(e)&&!i.includes(e)}))}else e=this.getNodeData().filter((e=>Fu(e)!==t));return Math.max(0,...e.map(vz))+1}destroy(){const{model:t}=this,e=t.getAllNodes(),n=t.getAllEdges();t.removeEdges(n.map((t=>t.id))),t.removeNodes(e.map((t=>t.id))),this.context={}}}class wB{context;container;elementMap={};shapeTypeMap={};constructor(t){this.context=t}init(){if(!this.container){const{canvas:t}=this.context;this.container={node:t.appendChild(new Rs({style:{zIndex:2}})),edge:t.appendChild(new Rs({style:{zIndex:1}})),combo:t.appendChild(new Rs({style:{zIndex:0}}))}}}emit(t,e){e.silence||gz(this.context.graph,t)}forEachElementData(t){jl.forEach((e=>{const n=this.context.model.getElementData(e);t(e,n)}))}getElementType(t,e){const{options:n}=this.context,r=n[t]?.type||e.type;return r?Bt(r)?r:r(e):{node:"circle",edge:"line",combo:"circle"}[t]}getTheme(t){const{theme:e}=this.context.options;if(!e)return{};const n=uz("theme",e);return n?.[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:n={}}=this.getTheme(t);return Object.assign({},...e.map((t=>n[t]||{})))}paletteStyle={};computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData(((e,n)=>{const r=Object.assign({},al(this.getTheme(e)?.palette),al(t[e]?.palette));!oe(r)&&r?.field&&Object.assign(this.paletteStyle,function(t,e){if(!e)return{};const{type:n,color:r,field:i,invert:o}=e,a=t=>{const e=Bt(r)?uz("palette",r):r;if(Pt(e))return Object.fromEntries(t.map((([t,n])=>[t,e(o?1-n:n)])));if(Array.isArray(e)){const n=o?[...e].reverse():e;return Object.fromEntries(t.map((([t,r])=>[t,n[r%e.length]])))}return{}},s=(t,e)=>Bt(t)?e.data?.[t]:t?.(e);if("group"===n){const e=Gt(t,(t=>{if(!i)return"default";const e=s(i,t);return e?String(e):"default"})),n=a(Object.keys(e).map(((t,e)=>[t,e]))),r={};return Object.entries(e).forEach((([t,e])=>{e.forEach((e=>{r[Fu(e)]=n[t]}))})),r}if("value"===n){const[e,n]=t.reduce((([t,e],n)=>{const r=s(i,n);if(!Wt(r))throw new Error(`Palette field ${i} is not a number`);return[Math.min(t,r),Math.max(e,r)]}),[1/0,-1/0]),r=n-e;return a(t.map((t=>[t.id,(s(i,t)-e)/r])))}}(n,r))}))}getPaletteStyle(t){const e=this.paletteStyle[t];return e?{color:e}:{}}defaultStyle={};computeElementDefaultStyle(t,e){const{options:n}=this.context,r=n[t]?.style||{};this.defaultStyle[Fu(e.datum)]=mz(r,e)}computeElementsDefaultStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Fu(e)))).forEach((t=>{this.computeElementDefaultStyle(e,{datum:t})}))}))}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch{return[]}}stateStyle={};getElementStateStyle(t,e,n){const{options:r}=this.context;return mz(r[t]?.state?.[e]||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Fu(n.datum)]=Object.assign({},...e.map((e=>this.getElementStateStyle(t,e,n))))}computeElementsStatesStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Fu(e)))).forEach((t=>{const n=this.getElementState(Fu(t));this.computeElementStatesStyle(e,n,{datum:t})}))}))}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t){this.computePaletteStyle(),this.computeElementsDefaultStyle(t),this.computeElementsStatesStyle(t)}getElement(t){return this.elementMap[t]}getNodes(){return this.container.node.children}getEdges(){return this.container.edge.children}getCombos(){return this.container.combo.children}getAnimation(t,e){const{options:n}=this.context,r=n?.[t]?.animation;if(!1===r)return!1;const i=r?.[e];if(i)return i;const o=this.getTheme(t)?.animation;if(!1===o)return!1;const a=o?.[e];return a??!1}getAnimationExecutor(t,e,n=!0,r){const{options:i}=this.context;return!1!==i.animation&&n?(n,i,o,a)=>Yh(i,this.getAnimation(t,e),{},{originalStyle:o,modifiedStyle:a,states:this.getElementState(n),...r}):()=>null}getEdgeEndsContext(t){const{source:e,target:n}=t;return{sourceNode:this.getElement(e),targetNode:this.getElement(n)}}getElementComputedStyle(t,e){const n=Fu(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),c=this.getStateStyle(n),u=Object.assign({},r,i,o,a,s,c);if("edge"===t)Object.assign(u,this.getEdgeEndsContext(e));else if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!u.collapsed?[]:t.map((t=>this.getElement(Fu(t)))).filter(Boolean);Object.assign(u,{childrenNode:e,childrenData:t})}return u}async draw(e={animation:!0}){this.init();const n=this.computeChangesAndDrawData();if(!n)return;const{dataChanges:r,drawData:i}=n;this.computeStyle();const{add:o,update:a,remove:s}=i,c=this.getDestroyTasks(s,e),u=this.getCreateTasks(o,e),l=this.getUpdateTasks(a,e);await(function(t,e={}){if(0===t.length)return null;const{before:n,...r}=e;e.before?.();const i=Wh(t.map((t=>t())).map((t=>t())).flat().filter(Boolean));return $h(i,r),i}([...c,...u,...l],e.silence?{}:{before:()=>this.emit(new hz(t.GraphEvent.BEFORE_DRAW,{dataChanges:r,animation:e.animation}),e),beforeAnimate:n=>this.emit(new dz(t.GraphEvent.BEFORE_ANIMATE,lu.DRAW,n,i),e),afterAnimate:n=>this.emit(new dz(t.GraphEvent.AFTER_ANIMATE,lu.DRAW,n,i),e),after:()=>this.emit(new hz(t.GraphEvent.AFTER_DRAW,{dataChanges:r,animation:e.animation}),e)})?.finished)}computeChangesAndDrawData(){const{model:t}=this.context,e=t.getChanges(),n=nL(e);if(0===n.length)return null;const{NodeAdded:r=[],NodeUpdated:i=[],NodeRemoved:o=[],EdgeAdded:a=[],EdgeUpdated:s=[],EdgeRemoved:c=[],ComboAdded:u=[],ComboUpdated:l=[],ComboRemoved:h=[]}=Gt(n,(t=>t.type)),d=t=>new Map(t.map((t=>{const e=t.value;return[Fu(e),e]}))),f={add:{nodes:d(r),edges:d(a),combos:d(u)},update:{nodes:d(i),edges:d(s),combos:d(l)},remove:{nodes:d(o),edges:d(c),combos:d(h)}},p=this.transformData(f);return t.clearChanges(),{dataChanges:e,drawData:p}}transformData(t){const e=this.context.transform.getTransformInstance();return Object.values(e).reduce(((t,e)=>e.beforeDraw(t)),t)}createElement(e,n,r){const i=Fu(n);if(this.getElement(i))return()=>null;const o=this.getElementType(e,n),a=this.getElementComputedStyle(e,n),s=uz(e,o);if(!s)return()=>null;this.emit(new fz(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const c=this.container[e].appendChild(new s({id:i,style:{context:this.context,...a}}));this.shapeTypeMap[i]=o,this.elementMap[i]=c;const{animation:u,animator:l}=r;return()=>$h(u?l?.(i,c,{...c.attributes,opacity:0}):null,{after:()=>{this.emit(new fz(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),c.onCreate()}})}getCreateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[];return[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{if(0===n.size)return;const r=this.getAnimationExecutor(t,"enter",e.animation);n.forEach((n=>o.push((()=>this.createElement(t,n,{...e,animator:r})))))})),o}latestElementVisibilityMap=new WeakMap;updateElement(e,n,r){const{animator:i}=r,o=Fu(n),a=this.getElement(o);if(!a)return()=>null;this.emit(new fz(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const s=()=>{this.emit(new fz(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n),r),a.onUpdate()},c=this.getElementType(e,n),u=this.getElementComputedStyle(e,n);if(this.shapeTypeMap[o]!==c)return this.destroyElement(e,n,{animation:!1,silence:!0})(),this.createElement(e,n,{animation:!1,silence:!0})(),()=>(s(),null);if("visibility"===r.stage&&"visibility"in u){Pl(a,"opacity")||Cl(a,"opacity");const t=Tl(a,"opacity")??Hh("opacity");if(this.latestElementVisibilityMap.set(a,u.visibility),"hidden"!==u.visibility)return Vh(a,{visibility:"visible"}),()=>$h(i?.(o,a,{...a.attributes,opacity:0},{opacity:t}),{after:s});if("hidden"===u.visibility)return()=>$h(i?.(o,a,{...a.attributes,opacity:t},{opacity:0}),{after:()=>{Vh(a,{visibility:this.latestElementVisibilityMap.get(a)}),s()}})}const l={...a.attributes};return Vh(a,u),"edge"===e&&(l.sourceNode.destroyed&&(l.sourceNode=u.sourceNode),l.targetNode.destroyed&&(l.targetNode=u.targetNode)),()=>$h(i?.(o,a,l),{after:s})}getUpdateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["node",n],["combo",i],["edge",r]],{animation:a,stage:s}=e,c=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"update",a);n.forEach((n=>c.push((()=>this.updateElement(t,n,{...e,animator:r})))))})),c}destroyElement(e,n,r){const{animator:i}=r,o=Fu(n),a=this.elementMap[o];return a?(this.emit(new fz(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n),r),()=>$h(i?.(o,a,{...a.attributes},{opacity:0}),{after:()=>{this.clearElement(o),a.destroy(),a.onDestroy(),this.emit(new fz(t.GraphEvent.AFTER_ELEMENT_DESTROY,e,n),r)}})):()=>null}getDestroyTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["combo",i],["edge",r],["node",n]],{animation:a,stage:s="exit"}=e,c=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s,a);n.forEach((n=>c.push((()=>this.destroyElement(t,n,{...e,animator:r})))))})),c}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}destroy(){Object.values(this.elementMap).forEach((t=>t.destroy())),Object.values(this.container).forEach((t=>t.destroy())),this.container={},this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={},this.context={},this.latestElementVisibilityMap=void 0}}class MB{context;supervisor;instance;instances=[];animationResult;get presetOptions(){return{animation:!!qh(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.context=t}getLayoutInstance(t){return void 0===t?this.instances:this.instance}async layout(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;gz(n,new hz(t.GraphEvent.BEFORE_LAYOUT));for(const t of e){const n=e.indexOf(t),r=this.getLayoutDataModel(t),i=await this.stepLayout(r,{...this.presetOptions,...t},n);t.animation||this.updateElementPosition(i,!1)}gz(n,new hz(t.GraphEvent.AFTER_LAYOUT))}async stepLayout(t,e,n){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?await this.treeLayout(t,e,n):await this.graphLayout(t,e,n)}async graphLayout(t,e,n){const{animation:r,enableWorker:i,iterations:o=300}=e,a=this.initGraphLayout(t,e);if(this.instances[n]=a,this.instance=a,i)return this.supervisor=new qI(t,a,{iterations:o}),await this.supervisor.execute();if(CI(a))return r?await a.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(a.execute(t),a.stop(),a.tick(o));const s=await a.execute(t);return r&&this.updateElementPosition(s,r),s}async treeLayout(t,e,n){const{type:r,animation:i}=e,o=uz("layout",r);if(!o)throw new Error(`The layout type ${r} is not found`);!function(t){if(t.hasTreeStructure(vu))return;t.attachTreeStructure(vu);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,vu)}}(t);const a={nodes:[],edges:[]};return t.getRoots(vu).forEach((n=>{ad(n,(e=>{e.children=t.getSuccessors(e.id)}),(e=>t.getSuccessors(e.id)),"TB");ad(o(n,e),(t=>{const{id:e,x:n,y:r}=t;a.nodes.push({id:e,data:{x:n,y:r}})}),(t=>t.children),"TB")})),i&&this.updateElementPosition(a,i),a}stopLayout(){this.instance&&CI(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutDataModel(t){const{model:e,element:n}=this.context;if(!n)return new Gp;const{nodesFilter:r=(()=>!0)}=t,i=Object.fromEntries(n.getNodes().map((t=>[t.id,t]))),o=Object.fromEntries(n.getCombos().map((t=>[t.id,t]))),a=Object.fromEntries(n.getEdges().map((t=>[t.id,t]))),s=e.model.getAllNodes().filter((t=>r(t.data))),c=e.model.getAllEdges(),u=(function(t){const{type:e}=t;return!!["comboCombined","comboForce"].includes(e)||!("antv-dagre"!==e||!t.sortByCombo)}(t)?s:s.filter((t=>!o[t.id]&&function(t){return"hidden"!==se(t,["style","visibility"])}(i[t.id])))).map((t=>{const{id:e}=t,n={id:e};return!!o[e]?Object.assign(n,{data:{...NB(o[e].attributes),_isCombo:!0}}):Object.assign(n,{data:NB(i[e]?.attributes||{})}),n})),l=new Map(u.map((t=>[t.id,t]))),h=c.filter((t=>{const e=l.get(t.source),n=l.get(t.target);return e&&n})).map((t=>{const{id:e,source:n,target:r}=t;return{id:e,source:n,target:r,data:NB(a[e].attributes)}})),d=new Gp({nodes:u,edges:h});return e.model.hasTreeStructure(mu)&&(d.attachTreeStructure(mu),u.forEach((t=>{const n=e.model.getParent(t.id,mu);n&&d.hasNode(n.id)&&d.setParent(t.id,n.id,mu)}))),d}initGraphLayout(t,e){const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s,...c}=e,[u,l]=r.getCanvasSize(),h=[u/2,l/2],d=e?.nodeSize??(t=>{const e=n?.getElement(t.id),{size:r}=e?.attributes||{};return Math.max(...Lu(r))}),f=uz("layout",i);if(!f)throw new Error(`The layout type ${i} is not found`);const p=new f,g={nodeSize:d,width:u,height:l,center:h};switch(p.id){case"d3-force":case"d3-force-3d":Object.assign(g,{center:{x:u/2,y:l/2,z:0}})}return re(p.options,g,c),p}updateElementPosition(t,e){const{model:n,element:r}=this.context;if(!r)return null;const{nodes:i,edges:o}=t,a={nodes:[],edges:[],combos:[]};return i.forEach((({id:t,data:{x:e,y:n,z:r=0}})=>{a.nodes.push({id:t,style:{x:e,y:n,z:r}})})),o.forEach((({id:t,data:{points:e=[],controlPoints:n=e.slice(1,e.length-1)}})=>{n?.length&&a.edges.push({id:t,style:{controlPoints:n.map(ll)}})})),n.updateData(a),r.draw({animation:e,silence:!0})}destroy(){this.stopLayout(),this.context={},this.supervisor?.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const NB=t=>Object.entries(t).reduce(((t,[e,n])=>(["function","object"].includes(typeof n)||["x","y","z"].includes(e)||(t[e]=n),t)),{});class SB extends Xh{category="plugin";constructor(t){super(t),this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){return this.extensionMap[t]}}const CB=["update-related-edges","arrange-draw-order","collapse-expand-combo"];class TB extends Xh{category="transform";constructor(t){super(t),this.setTransforms(this.context.options.transforms||[])}setTransforms(t){this.setExtensions([...t,...CB])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class PB{context;get padding(){return wu(this.context.options.padding)}get paddingOffset(){const[t,e,n,r]=this.padding,[i,o,a]=[(r-e)/2,(t-n)/2,0];return[i,o,a]}constructor(t){this.context=t;const[e,n]=this.paddingOffset,{zoom:r,rotation:i,x:o=e,y:a=n}=t.options;this.transform({mode:"absolute",scale:r,translate:[o,a],rotate:i},!1)}get camera(){return this.context.canvas.getCamera()}landmarkCounter=0;createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=qh(this.context.options,t);return!!e&&le({...e},["easing","duration"])}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e,n]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e/2,n/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateArgs(t){const e=this.getZoom(),{camera:n}=this,{mode:r,translate:i=[]}=t,[o=0,a=0]=i,[s=0,c=0]=this.getCanvasCenter(),[u,l]=n.getPosition(),h=Zu([-o,-a],e);return"relative"===r?h:Yu([s-u,c-l],h)}getAnimationTranslateArgs(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),a=e.getFocalPoint(),s=this.getCanvasCenter(),[c=0,u=0,l=0]=r,h=Zu([-c,-u,-l],i);return"relative"===n?{position:Yu(o,h),focalPoint:Yu(a,h)}:{position:Yu(s,h),focalPoint:Yu(a,h)}}getRotateArgs(t){const{mode:e,rotate:n=0}=t;return"relative"===e?n:n-this.camera.getRoll()}getAnimationRotateArgs(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomArgs(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return Vt("relative"===r?n*i:i,...e)}async transform(e,n){const{camera:r}=this,{graph:i}=this.context,{translate:o,rotate:a,scale:s,origin:c=this.getGraphCenter()}=e;this.cancelAnimation(),gz(i,new pz(t.GraphEvent.BEFORE_TRANSFORM,e));const u=this.getAnimation(n);if(u){const n={};return o&&Object.assign(n,this.getAnimationTranslateArgs(e)),Wt(a)&&Object.assign(n,this.getAnimationRotateArgs(e)),Wt(s)&&Object.assign(n,{zoom:this.getZoomArgs(e)}),gz(i,new dz(t.GraphEvent.BEFORE_ANIMATE,lu.TRANSFORM,null,e)),new Promise((r=>{this.camera.gotoLandmark(this.createLandmark(n),{...u,onfinish:()=>{gz(i,new dz(t.GraphEvent.AFTER_ANIMATE,lu.TRANSFORM,null,e)),gz(i,new pz(t.GraphEvent.AFTER_TRANSFORM,e)),r()}})}))}if(o&&r.pan(...this.getTranslateArgs(e)),Wt(a)){const[t,n]=r.getFocalPoint();c&&r.pan(c[0]-t,c[1]-n);const i=this.getRotateArgs(e);r.rotate(0,0,i),c&&r.pan(t-c[0],n-c[1])}if(Wt(s)){const t=this.getZoomArgs(e);r.setZoomByViewportPoint(t,c)}gz(i,new pz(t.GraphEvent.AFTER_TRANSFORM,e))}async fitView(t,e){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[c,u]=this.context.canvas.getSize(),l=c-o-r,h=u-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=Su(f);if("overflow"===a&&!("x"===s&&p>=l||"y"===s&&g>=h||"both"===s&&p>=l&&g>=h))return await this.fitCenter(e);const m=l/p,v=h/g,y="x"===s?m:"y"===s?v:Math.min(m,v),b=this.getAnimation(e);await this.transform({mode:"relative",scale:y,translate:Yu(Ku(this.getCanvasCenter(),this.getBBoxInViewport(d).center),b?Zu(this.paddingOffset,y):this.paddingOffset)},b)}async fitCenter(t){const e=this.context.canvas.getBounds();await this.focus(e,t)}async focusElements(t,e){const{element:n}=this.context;if(!n)return;const r=Pu(t.map((t=>n.getElement(t).getRenderBounds())));await this.focus(r,e)}async focus(t,e){const{center:n}=this.getBBoxInViewport(t),r=Ku(this.getCanvasCenter(),n);await this.transform({mode:"relative",translate:Yu(r,this.paddingOffset)},e)}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[a,s]=r.getViewportByCanvas(n),c=new vr;return c.setMinMax([i,o,0],[a,s,0]),c}cancelAnimation(){this.camera.landmarks?.length&&this.camera.cancelLandmarkAnimation()}}class kB extends Lp{options;static defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};destroyed=!1;context={model:new EB};constructor(t){super(),this.options=Object.assign({},kB.defaultOptions,t),this.setOptions(this.options),this.context.graph=this,this.options.autoResize&&window.addEventListener("resize",this.onResize)}getOptions(){return this.options}setOptions(t){const{animation:e,background:n,behaviors:r,combo:i,container:o,data:a,edge:s,height:c,layout:u,node:l,padding:h,plugins:d,theme:f,transforms:p,width:g,zoom:m,zoomRange:v}=t;n&&this.setBackground(n),r&&this.setBehaviors(r),i&&this.setCombo(i),a&&this.setData(a),s&&this.setEdge(s),u&&this.setLayout(u),l&&this.setNode(l),f&&this.setTheme(f),d&&this.setPlugins(d),p&&this.setTransforms(p),(Wt(g)||Wt(c))&&this.setSize(g??this.options.width??0,c??this.options.height??0),v&&(this.options.zoomRange=v),Wt(m)&&(this.options.zoom=m),(Wt(h)||_t(h))&&(this.options.padding=h)}setBackground(t){this.options.background=t,this.context.canvas?.setBackground(t)}getBackground(){return this.options.background}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){this.options.width=t,this.options.height=e}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t}setEdge(t){this.options.edge=t}setCombo(t){this.options.combo=t}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Pt(t)?t(this.getTheme()):t;const{background:e}=uz("theme",this.options.theme)||{};e&&!this.options.background&&this.setBackground(e)}setLayout(t){this.options.layout=Pt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){this.options.behaviors=Pt(t)?t(this.getBehaviors()):t,this.context.behavior?.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors((e=>e.map((e=>Rt(e)&&e.key===t.key?{...e,...t}:e))))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){this.options.plugins=Pt(t)?t(this.getPlugins()):t,this.context.plugin?.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins((e=>e.map((e=>Rt(e)&&e.key===t.key?{...e,...t}:e))))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){this.options.transforms=Pt(t)?t(this.getTransforms()):t,this.context.transform?.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms((e=>e.map((e=>Rt(e)&&e.key===t.key?{...e,...t}:e))))}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}getNodeData(t){return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeData([t])?.[0]}getEdgeData(t){return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeData([t])?.[0]}getComboData(t){return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getComboData([t])?.[0]}setData(t){this.context.model.setData(Pt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Pt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Pt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Pt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Pt(t)?t(this.getComboData()):t)}updateData(t){this.context.model.updateData(Pt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Pt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Pt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Pt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Pt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Pt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Pt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Pt(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}async initCanvas(){if(this.context.canvas)return await this.context.canvas.init();const{container:e="container",width:n,height:r,renderer:i,background:o}=this.options;if(e instanceof mB)this.context.canvas=e,e.setBackground(o),await e.init();else{const o=Bt(e)?document.getElementById(e):e,a=XI(o);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:o,width:n,height:r});const s=new mB({container:o,width:n??a[0],height:r??a[1],renderer:i});this.context.canvas=s,await s.init(),this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:s})}}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new yz(this.context)),this.context.plugin||(this.context.plugin=new SB(this.context)),this.context.viewport||(this.context.viewport=new PB(this.context)),this.context.transform||(this.context.transform=new TB(this.context)),this.context.element||(this.context.element=new wB(this.context)),this.context.layout||(this.context.layout=new MB(this.context)),this.context.behavior||(this.context.behavior=new bz(this.context))}async prepare(){if(await Promise.resolve(),this.destroyed)throw new Error("Graph has been destroyed");await this.initCanvas(),this.initRuntime()}async render(){await this.prepare(),gz(this,new hz(t.GraphEvent.BEFORE_RENDER)),await Promise.all([this.context.element?.draw(),this.context.layout?.layout()]),await this.autoFit(),gz(this,new hz(t.GraphEvent.AFTER_RENDER))}async draw(){return await this.prepare(),this.context.element.draw()}layout(){return this.context.layout.layout()}stopLayout(){return this.context.layout.stopLayout()}async clear(){this.context.model.setData({}),await this.draw()}destroy(){const{layout:t,element:e,model:n,canvas:r,behavior:i,plugin:o}=this.context;o?.destroy(),i?.destroy(),t?.destroy(),e?.destroy(),n.destroy(),r?.destroy(),this.options={},this.context={},this.off(),window.removeEventListener("resize",this.onResize),this.destroyed=!0}getCanvas(){return this.context.canvas}resize(e,n){const r=e&&n?[e,n]:XI(this.context.canvas.getContainer());ae(r,this.getSize())||(gz(this,new hz(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:r})),this.context.canvas.resize(...r),gz(this,new hz(t.GraphEvent.AFTER_SIZE_CHANGE,{size:r})))}async fitView(t,e){await(this.context.viewport?.fitView(t,e))}async fitCenter(t){await(this.context.viewport?.fitCenter(t))}async autoFit(){const{autoFit:t}=this.context.options;if(t)if(Bt(t))"view"===t?await this.fitView():"center"===t&&await this.fitCenter();else{const{type:e,animation:n}=t;"view"===e?await this.fitView(t.options,n):"center"===e&&await this.fitCenter(n)}}async focusElement(t,e){await(this.context.viewport?.focusElements(Array.isArray(t)?t:[t],e))}async zoomBy(t,e,n){await this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}async zoomTo(t,e,n){this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)}getZoom(){return this.context.viewport.getZoom()}async rotateBy(t,e,n){await this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}async rotateTo(t,e,n){await this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)}getRotation(){return this.context.viewport.getRotation()}async translateBy(t,e){await this.context.viewport.transform({mode:"relative",translate:t},e)}async translateTo(t,e){await this.context.viewport.transform({mode:"absolute",translate:t},e)}getPosition(){return Ku([0,0],this.getCanvasByViewport([0,0]))}async translateElementBy(t,e,n=!0){const[r,i]=Rt(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeBy(t,e))),await this.context.element.draw({animation:i})}async translateElementTo(t,e,n=!0){const[r,i]=Rt(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeTo(t,e))),await this.context.element.draw({animation:i})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return he(this.context.element.getElement(t).attributes,["context"])}async setElementVisibility(t,e,n=!0){const[r,i]=Rt(t)?[t,e??!0]:[{[t]:e},n],o={nodes:[],edges:[],combos:[]};Object.entries(r).forEach((([t,e])=>{const n=this.getElementType(t);o[`${n}s`].push({id:t,style:{visibility:e}})})),this.updateData(o),await this.context.element.draw({animation:i,stage:"visibility"})}async showElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"visible"]))),e)}async hideElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"hidden"]))),e)}getElementVisibility(t){const e=this.context.element.getElement(t);return e?.style?.visibility??"visible"}async setElementZIndex(t,e){const n={nodes:[],edges:[],combos:[]},r=Rt(t)?t:{[t]:e};Object.entries(r).forEach((([t,e])=>{const r=this.getElementType(t);n[`${r}s`].push({id:t,style:{zIndex:e}})}));const{model:i,element:o}=this.context;i.preventUpdateNodeLikeHierarchy((()=>i.updateData(n))),await o.draw({animation:!1})}async frontElement(t){const e=Array.isArray(t)?t:[t],{model:n}=this.context,r={};e.map((t=>{const e=n.getFrontZIndex(t);if("combo"===n.getElementType(t)){const i=n.getAncestorsData(t,mu).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Fu(i))].filter((t=>n.isCombo(Fu(t)))),a=e-vz(i);o.forEach((t=>{r[Fu(t)]=vz(t)+a}))}else r[t]=e})),await this.setElementZIndex(r)}getElementZIndex(t){return vz(this.context.model.getElementsData([t])[0])}async setElementState(t,e,n=!0){const[r,i]=Rt(t)?[t,e??!0]:[{[t]:e},n],o={nodes:[],edges:[],combos:[]};Object.entries(r).forEach((([t,e])=>{const n=this.getElementType(t);var r;o[`${n}s`].push({id:t,style:{states:(r=e,r?Array.isArray(r)?r:[r]:[])}})})),this.updateData(o),await this.context.element.draw({animation:i})}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}async collapse(t,e=!0){this.setElementCollapsibility(t,!0),await this.context.element.draw({animation:e,stage:"collapse"})}async expand(t,e=!0){this.setElementCollapsibility(t,!1),await this.context.element.draw({animation:e,stage:"expand"})}setElementCollapsibility(t,e){const n=this.getElementType(t);"node"===n?this.updateNodeData([{id:t,style:{collapsed:e}}]):"combo"===n&&this.updateComboData([{id:t,style:{collapsed:e}}])}async toDataURL(t={}){return this.context.canvas.toDataURL(t)}getCanvasByViewport(t){return ll(this.context.canvas.viewport2Canvas(hl(t)))}getViewportByCanvas(t){return ll(this.context.canvas.canvas2Viewport(hl(t)))}getClientByCanvas(t){const e=this.context.canvas.canvas2Viewport(hl(t));return ll(this.context.canvas.viewport2Canvas(e))}getCanvasByClient(t){const e=this.context.canvas.client2Viewport(hl(t));return ll(this.context.canvas.viewport2Canvas(e))}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}onResize=te((()=>{this.resize()}),300);on(t,e){return super.on(t,e)}once(t,e){return super.once(t,e)}}const AB={idOf:Fu,treeToGraphData:function(t,e){const{getNodeData:n=(t=>{if(!t.children)return t;const{children:e,style:n={},...r}=t;return{style:{...n,children:e.map((t=>t.id))},...r}}),getEdgeData:r=((t,e)=>({source:t.id,target:e.id})),getChildren:i=(t=>t.children||[])}=e||{},o=[],a=[];return ad(t,(t=>{o.push(n(t));const e=i(t);for(const n of e)a.push(r(t,n))}),(t=>i(t)),"TB"),{nodes:o,edges:a}},subStyleProps:Uu,omitStyleProps:$u},OB={dark:Qj,light:Jj};t.BaseBehavior=Qh,t.BaseCombo=Zl,t.BaseEdge=Eh,t.BaseNode=Il,t.BasePlugin=YI,t.BaseShape=Ol,t.BaseTransform=tz,t.CameraSetting=class extends YI{constructor(t,e){super(t,e),this.bindEvents()}update(t){this.setOptions(t),super.update(t)}bindEvents(){this.context.graph.once(t.GraphEvent.BEFORE_DRAW,(()=>this.setOptions(this.options)))}setOptions=t=>{const e=(t,e)=>{switch(t){case"projectionMode":return"perspective"===e?1:0;case"cameraType":return{orbiting:0,exploring:1,tracking:2}[e];case"aspect":return"number"==typeof e?e:this.getCanvasAspect();default:return e}};Object.entries({cameraType:"setType",near:"setNear",far:"setFar",fov:"setFov",aspect:"setAspect",projectionMode:"setProjectionMode",distance:"setDistance",minDistance:"setMinDistance",maxDistance:"setMaxDistance",roll:"setRoll",elevation:"setElevation",azimuth:"setAzimuth"}).forEach((([n,r])=>{const i=t[n];if(void 0!==i){const t=e(n,i);this.context.canvas.getCamera()[r](t)}}))};getCanvasAspect(){const[t,e]=this.context.viewport.getCanvasSize();return t/e}},t.Circle=zl,t.CircleCombo=Ql,t.ComboEvent=t.NodeEvent,t.Cubic=wh,t.CubicHorizontal=Mh,t.CubicVertical=Nh,t.Diamond=Fl,t.Donut=Gl,t.DragCanvas=fd,t.Ellipse=Ul,t.Graph=kB,t.HTML=$l,t.Hexagon=Hl,t.History=aL,t.Image=ql,t.Line=Sh,t.Polyline=Ch,t.Quadratic=Th,t.Rect=Yl,t.RectCombo=Jl,t.Shortcut=rd,t.Star=Kl,t.Theme=OB,t.Triangle=Xl,t.Utils=AB,t.ZoomCanvas=Sd,t.getExtension=uz,t.getExtensions=function(t){return sz[t]},t.parseSize=Lu,t.register=cz,t.version="5.0.0"}));
6
+ */const qI=Symbol("Comlink.proxy"),YI=Symbol("Comlink.endpoint"),KI=Symbol("Comlink.releaseProxy"),XI=Symbol("Comlink.finalizer"),ZI=Symbol("Comlink.thrown"),QI=t=>"object"==typeof t&&null!==t||"function"==typeof t,JI=new Map([["proxy",{canHandle:t=>QI(t)&&t[qI],serialize(t){const{port1:e,port2:n}=new MessageChannel;return tD(t,e),[n,[n]]},deserialize:t=>(t.start(),nD(t))}],["throw",{canHandle:t=>QI(t)&&ZI in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function tD(t,e=globalThis,n=["*"]){e.addEventListener("message",(function r(i){if(!i||!i.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:o,type:a,path:s}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(hD);let c;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(a){case"GET":c=n;break;case"SET":e[s.slice(-1)[0]]=hD(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,u);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[qI]:!0})}(new n(...u));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;tD(t,n),c=function(t,e){return cD.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[ZI]:0}}Promise.resolve(c).catch((t=>({value:t,[ZI]:0}))).then((n=>{const[i,s]=lD(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),eD(e),XI in t&&"function"==typeof t[XI]&&t[XI]())})).catch((t=>{const[n,r]=lD({value:new TypeError("Unserializable return value"),[ZI]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function eD(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function nD(t,e){return sD(t,[],e)}function rD(t){if(t)throw new Error("Proxy has been released and is not useable")}function iD(t){return dD(t,{type:"RELEASE"}).then((()=>{eD(t)}))}const oD=new WeakMap,aD="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(oD.get(t)||0)-1;oD.set(t,e),0===e&&iD(t)}));function sD(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(rD(r),o===KI)return()=>{!function(t){aD&&aD.unregister(t)}(i),iD(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=dD(t,{type:"GET",path:e.map((t=>t.toString()))}).then(hD);return n.then.bind(n)}return sD(t,[...e,o])},set(n,i,o){rD(r);const[a,s]=lD(o);return dD(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(hD)},apply(n,i,o){rD(r);const a=e[e.length-1];if(a===YI)return dD(t,{type:"ENDPOINT"}).then(hD);if("bind"===a)return sD(t,e.slice(0,-1));const[s,u]=uD(o);return dD(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},u).then(hD)},construct(n,i){rD(r);const[o,a]=uD(i);return dD(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(hD)}});return function(t,e){const n=(oD.get(e)||0)+1;oD.set(e,n),aD&&aD.register(t,e,t)}(i,t),i}function uD(t){const e=t.map(lD);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const cD=new WeakMap;function lD(t){for(const[e,n]of JI)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},cD.get(t)||[]]}function hD(t){switch(t.type){case"HANDLER":return JI.get(t.name).deserialize(t.value);case"RAW":return t.value}}function dD(t,e,n){return new Promise((r=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){n.data&&n.data.id&&n.data.id===i&&(t.removeEventListener("message",e),r(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),n)}))}class fD extends Td{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=nD(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())}execute(){var t;return a(this,void 0,void 0,(function*(){if(this.running)return this;this.running=!0;const e=o(this.layout.options,["onTick"]),n={};Object.keys(e).forEach((t=>{Ot(e[t])||(n[t]=e[t])}));const r={layout:{id:this.layout.id,options:n,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},i=new Float32Array([0]),[a]=yield this.proxy.calculateLayout(r,[i]);return a}))}stop(){return this.running=!1,this.proxy.stopLayout(),this}kill(){this.proxy[KI]()}isRunning(){return this.running}}class pD extends fd{}function gD(t,e,n,r,i,o){const a=n-t,s=r-e;let u=i-t,c=o-e,l=u*a+c*s,h=0;l<=0?h=0:(u=a-u,c=s-c,l=u*a+c*s,h=l<=0?0:l*l/(a*a+s*s));const d=u*u+c*c-h;return d<0?0:d}function mD(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function yD(t,e,n,r,i){return mD(t,e,n,r)<i*i}function vD(t){const e=Math.min(t.x1,t.x2),n=Math.max(t.x1,t.x2),r=Math.min(t.y1,t.y2),i=Math.max(t.y1,t.y2);return{x:e,y:r,x2:n,y2:i,width:n-e,height:i-r}}class bD{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}draw(t){t.moveTo(this.x1,this.y1),t.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(t){return new bD(t.x1,t.y1,t.x2,t.y2)}cuts(t,e){if(this.y1===this.y2)return!1;if(e<this.y1&&e<=this.y2||e>this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(t<this.x1&&t<=this.x2)return!0;return t<=this.x1+(e-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(t,e){return gD(this.x1,this.y1,this.x2,this.y2,t,e)}ptClose(t,e,n){if(this.x1<this.x2){if(t<this.x1-n||t>this.x2+n)return!1}else if(t<this.x2-n||t>this.x1+n)return!1;if(this.y1<this.y2){if(e<this.y1-n||e>this.y2+n)return!1}else if(e<this.y2-n||e>this.y1+n)return!1;return!0}}var xD,wD;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(xD||(xD={}));class ED{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function MD(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const e=n/i,o=r/i;return 0<=e&&e<=1&&0<=o&&o<=1?new ED(xD.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new ED(xD.NONE)}return new ED(0===n||0===r?xD.COINCIDENT:xD.PARALLEL)}function SD(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const t=n/i,e=r/i;if(0<=t&&t<=1&&0<=e&&e<=1)return t}return Number.POSITIVE_INFINITY}function ND(t,e,n){const r=new Set;return t.width<=0?(r.add(wD.LEFT),r.add(wD.RIGHT)):e<t.x?r.add(wD.LEFT):e>t.x+t.width&&r.add(wD.RIGHT),t.height<=0?(r.add(wD.TOP),r.add(wD.BOTTOM)):n<t.y?r.add(wD.TOP):n>t.y+t.height&&r.add(wD.BOTTOM),r}function kD(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,a=Array.from(ND(t,i,o));if(0===a.length)return!0;let s=ND(t,n,r);for(;0!==s.size;){for(const t of a)if(s.has(t))return!1;if(s.has(wD.RIGHT)||s.has(wD.LEFT)){let e=t.x;s.has(wD.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(wD.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=ND(t,n,r)}return!0}function CD(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,a){let s=SD(e,new bD(t,i,o,a));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(t.x,t.y,t.x2,t.y),i(t.x,t.y,t.x,t.y2),r>1?n:(i(t.x,t.y2,t.x2,t.y2),r>1?n:(i(t.x2,t.y,t.x2,t.y2),0===r?-1:n))}function TD(t,e){let n=0;const r=MD(t,new bD(e.x,e.y,e.x2,e.y));n+=r.state===xD.POINT?1:0;const i=MD(t,new bD(e.x,e.y,e.x,e.y2));n+=i.state===xD.POINT?1:0;const o=MD(t,new bD(e.x,e.y2,e.x2,e.y2));n+=o.state===xD.POINT?1:0;const a=MD(t,new bD(e.x2,e.y,e.x2,e.y2));return n+=a.state===xD.POINT?1:0,{top:r,left:i,bottom:o,right:a,count:n}}!function(t){t[t.LEFT=0]="LEFT",t[t.TOP=1]="TOP",t[t.RIGHT=2]="RIGHT",t[t.BOTTOM=3]="BOTTOM"}(wD||(wD={}));class AD{constructor(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(t){return new AD(t.x,t.y,t.width,t.height)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new AD(this.x,this.y,this.width,this.height)}add(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x+t.width),i=Math.max(this.y2,t.y+t.height);this.x=e,this.y=n,this.width=r-e,this.height=i-n}addPoint(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x),i=Math.max(this.y2,t.y);this.x=e,this.y=n,this.width=r-e,this.height=i-n}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(t){t.rect(this.x,this.y,this.width,this.height)}containsPt(t,e){return t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}get area(){return this.width*this.height}intersects(t){return!(this.area<=0||t.width<=0||t.height<=0)&&(t.x+t.width>this.x&&t.y+t.height>this.y&&t.x<this.x2&&t.y<this.y2)}distSquare(t,e){if(this.containsPt(t,e))return 0;const n=ND(this,t,e);return n.has(wD.TOP)?n.has(wD.LEFT)?mD(t,e,this.x,this.y):n.has(wD.RIGHT)?mD(t,e,this.x2,this.y):(this.y-e)*(this.y-e):n.has(wD.BOTTOM)?n.has(wD.LEFT)?mD(t,e,this.x,this.y2):n.has(wD.RIGHT)?mD(t,e,this.x2,this.y2):(e-this.y2)*(e-this.y2):n.has(wD.LEFT)?(this.x-t)*(this.x-t):n.has(wD.RIGHT)?(t-this.x2)*(t-this.x2):0}}class PD{constructor(t,e,n){this.cx=t,this.cy=e,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(t){return new PD(t.cx,t.cy,t.radius)}containsPt(t,e){return mD(this.cx,this.cy,t,e)<this.radius*this.radius}distSquare(t,e){const n=mD(this.cx,this.cy,t,e);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(t){t.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class OD{constructor(t,e=0,n=0,r=0,i=0,o=10,a=10,s=new Float32Array(Math.max(0,o*a)).fill(0)){this.pixelGroup=t,this.i=e,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=a,this.area=s}createSub(t,e){return new OD(this.pixelGroup,t.x,t.y,e.x,e.y,t.width,t.height)}static fromPixelRegion(t,e){return new OD(e,0,0,t.x,t.y,Math.ceil(t.width/e),Math.ceil(t.height/e))}copy(t,e){return new OD(this.pixelGroup,this.scaleX(e.x),this.scaleY(e.y),e.x,e.y,t.width,t.height,t.area)}boundX(t){return t<this.i?this.i:t>=this.width?this.width-1:t}boundY(t){return t<this.j?this.j:t>=this.height?this.height-1:t}scaleX(t){return this.boundX(Math.floor((t-this.pixelX)/this.pixelGroup))}scaleY(t){return this.boundY(Math.floor((t-this.pixelY)/this.pixelGroup))}scale(t){const e=this.scaleX(t.x),n=this.scaleY(t.y),r=this.boundX(Math.ceil((t.x+t.width-this.pixelX)/this.pixelGroup)),i=this.boundY(Math.ceil((t.y+t.height-this.pixelY)/this.pixelGroup));return new AD(e,n,r-e,i-n)}invertScaleX(t){return Math.round(t*this.pixelGroup+this.pixelX)}invertScaleY(t){return Math.round(t*this.pixelGroup+this.pixelY)}addPadding(t,e){const n=Math.ceil(e/this.pixelGroup),r=this.boundX(t.x-n),i=this.boundY(t.y-n),o=this.boundX(t.x2+n),a=this.boundY(t.y2+n);return new AD(r,i,o-r,a-i)}get(t,e){return t<0||e<0||t>=this.width||e>=this.height?Number.NaN:this.area[t+e*this.width]}inc(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]+=n)}set(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]=n)}incArea(t,e){if(t.width<=0||t.height<=0||0===e)return;const n=this.width,r=t.width,i=Math.max(0,t.i),o=Math.max(0,t.j),a=Math.min(t.i+t.width,n),s=Math.min(t.j+t.height,this.height);if(!(s<=0||a<=0||i>=n||s>=this.height))for(let u=o;u<s;u++){const o=(u-t.j)*r,s=u*n;for(let n=i;n<a;n++){const r=t.area[n-t.i+o];0!==r&&(this.area[n+s]+=e*r)}}}fill(t){this.area.fill(t)}fillArea(t,e){const n=t.x+t.y*this.width;for(let r=0;r<t.height;r++){const i=n+r*this.width;this.area.fill(e,i,i+t.width)}}fillHorizontalLine(t,e,n,r){const i=t+e*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(t,e,n,r){const i=t+e*this.width;for(let t=0;t<n;t++)this.area[i+t*this.width]=r}clear(){this.area.fill(0)}toString(){let t="";for(let e=0;e<this.height;e++){const n=e*this.width;for(let e=0;e<this.width;e++){t+=this.area[n+e].toFixed(1).padStart(6),t+=" "}t+="\n"}return t}draw(t,e=!0){if(this.width<=0||this.height<=0)return;t.save(),e&&t.translate(this.pixelX,this.pixelY);const n=this.area.reduce(((t,e)=>Math.min(t,e)),Number.POSITIVE_INFINITY),r=this.area.reduce(((t,e)=>Math.max(t,e)),Number.NEGATIVE_INFINITY),i=t=>(t-n)/(r-n);t.scale(this.pixelGroup,this.pixelGroup);for(let e=0;e<this.width;e++)for(let n=0;n<this.height;n++){const r=this.area[e+n*this.width];t.fillStyle=`rgba(0, 0, 0, ${i(r)})`,t.fillRect(e,n,1,1)}t.restore()}drawThreshold(t,e,n=!0){if(!(this.width<=0||this.height<=0)){t.save(),n&&t.translate(this.pixelX,this.pixelY),t.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];t.fillStyle=i>e?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function _D(t,e){const n=t=>({x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e});return Array.isArray(t)?t.map(n):n(t)}function RD(t,e,n){return ID(Object.assign(vD(t),{distSquare:(e,n)=>gD(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function ID(t,e,n){const r=_D(t,n),i=e.scale(r),o=e.createSub(i,r);return function(t,e,n,r){const i=n*n;for(let o=0;o<t.height;o++)for(let a=0;a<t.width;a++){const s=r(e.invertScaleX(t.i+a),e.invertScaleY(t.j+o));if(0!==s){if(s<i){const e=n-Math.sqrt(s);t.set(a,o,e*e)}}else t.set(a,o,i)}}(o,e,n,((e,n)=>t.distSquare(e,n))),o}function DD(t,e){return{x:t,y:e}}function LD(t,e,n,r){if(0===t.length)return[];const i=function(t){if(t.length<2)return t;let e=0,n=0;return t.forEach((t=>{e+=t.cx,n+=t.cy})),e/=t.length,n/=t.length,t.map((t=>{const r=e-t.cx,i=n-t.cy;return[t,r*r+i*i]})).sort(((t,e)=>t[1]-e[1])).map((t=>t[0]))}(t);return i.map(((t,o)=>{const a=i.slice(0,o);return function(t,e,n,r,i){const o=DD(e.cx,e.cy),a=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce(((e,i)=>{const o=mD(t.x,t.y,i.cx,i.cy);if(o>r)return e;const a=new bD(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce(((t,n)=>kD(n,e)&&function(t,e){function n(t,n,r,i){let o=SD(e,new bD(t,n,r,i));return o=Math.abs(o-.5),o>=0&&o<=1?1:0}let r=n(t.x,t.y,t.x2,t.y);return r+=n(t.x,t.y,t.x,t.y2),r>1||(r+=n(t.x,t.y2,t.x2,t.y2),r>1||(r+=n(t.x2,t.y,t.x2,t.y2),r>0))}(n,e)?t+1:t),0)}(n,a);return o*(s+1)*(s+1)<r&&(e=i,r=o*(s+1)*(s+1)),e}),null)}(o,n,t);if(null==a)return[];const s=function(t,e,n,r){const i=[],o=[];o.push(t);let a=!0;for(let t=0;t<n&&a;t++)for(a=!1;!a&&o.length>0;){const t=o.pop(),n=zD(e,t),s=n?TD(t,n):null;if(!n||!s||2!==s.count){a||i.push(t);continue}let u=r,c=FD(n,u,s,!0),l=BD(c,o)||BD(c,i),h=jD(c,e);for(;!l&&h&&u>=1;)u/=1.5,c=FD(n,u,s,!0),l=BD(c,o)||BD(c,i),h=jD(c,e);if(!c||l||h||(o.push(new bD(t.x1,t.y1,c.x,c.y)),o.push(new bD(c.x,c.y,t.x2,t.y2)),a=!0),a)continue;u=r,c=FD(n,u,s,!1);let d=BD(c,o)||BD(c,i);for(h=jD(c,e);!d&&h&&u>=1;)u/=1.5,c=FD(n,u,s,!1),d=BD(c,o)||BD(c,i),h=jD(c,e);c&&!d&&(o.push(new bD(t.x1,t.y1,c.x,c.y)),o.push(new bD(c.x,c.y,t.x2,t.y2)),a=!0),a||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new bD(o.x,o.y,a.cx,a.cy),t,r,i);return function(t,e){const n=[];for(;t.length>0;){const r=t.pop();if(0===t.length){n.push(r);break}const i=t.pop(),o=new bD(r.x1,r.y1,i.x2,i.y2);zD(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,a,n,r)})).flat()}function jD(t,e){return e.some((e=>e.containsPt(t.x,t.y)))}function BD(t,e){return e.some((e=>!!yD(e.x1,e.y1,t.x,t.y,.001)||!!yD(e.x2,e.y2,t.x,t.y,.001)))}function zD(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!kD(i,e))continue;const t=CD(i,e);t>=0&&t<n&&(r=i,n=t)}return r}function FD(t,e,n,r){const i=n.top,o=n.left,a=n.bottom,s=n.right;if(r){if(o.state===xD.POINT){if(i.state===xD.POINT)return DD(t.x-e,t.y-e);if(a.state===xD.POINT)return DD(t.x-e,t.y2+e);const n=t.width*t.height;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?DD(t.x-e,t.y-e):DD(t.x2+e,t.y-e):o.y<s.y?DD(t.x-e,t.y2+e):DD(t.x2+e,t.y2+e)}if(s.state===xD.POINT){if(i.state===xD.POINT)return DD(t.x2+e,t.y-e);if(a.state===xD.POINT)return DD(t.x2+e,t.y2+e)}const n=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*n?i.x>a.x?DD(t.x-e,t.y-e):DD(t.x-e,t.y2+e):i.x<a.x?DD(t.x2+e,t.y-e):DD(t.x2+e,t.y2+e)}if(o.state===xD.POINT){if(i.state===xD.POINT)return DD(t.x2+e,t.y2+e);if(a.state===xD.POINT)return DD(t.x2+e,t.y-e);const n=t.height*t.width;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?DD(t.x2+e,t.y2+e):DD(t.x-e,t.y2+e):o.y<s.y?DD(t.x2+e,t.y-e):DD(t.x-e,t.y-e)}if(s.state===xD.POINT){if(i.state===xD.POINT)return DD(t.x-e,t.y2+e);if(a.state===xD.POINT)return DD(t.x-e,t.y-e)}const u=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*u?i.x>a.x?DD(t.x2+e,t.y2+e):DD(t.x2+e,t.y-e):i.x<a.x?DD(t.x-e,t.y2+e):DD(t.x-e,t.y-e)}function GD(t,e,n,r){if(!(t.closed?n<t.length:n<t.length-1))return!1;const i=t.get(e),o=t.get(n+1);for(let a=e+1;a<=n;a++){const e=t.get(a);if(gD(i.x,i.y,o.x,o.y,e.x,e.y)>r)return!1}return!0}function VD(t,e){switch(t){case-2:return(((3-e)*e-3)*e+1)/6;case-1:return((3*e-6)*e*e+4)/6;case 0:return(((-3*e+3)*e+3)*e+1)/6;case 1:return e*e*e/6;default:throw new Error("unknown error")}}class WD{constructor(t=[],e=!0){this.points=t,this.closed=e}get(t){const e=t,n=this.points.length;return t<0?this.closed?this.get(t+n):this.points[0]:t>=n?this.closed?this.get(t-n):this.points[n-1]:this.points[e]}get length(){return this.points.length}toString(t=1/0){const e=this.points;if(0===e.length)return"";const n="function"==typeof t?t:function(t){if(!Number.isFinite(t))return t=>t;if(0===t)return Math.round;const e=Math.pow(10,t);return t=>Math.round(t*e)/e}(t);let r="M";for(const t of e)r+=`${n(t.x)},${n(t.y)} L`;return r=r.slice(0,-1),this.closed&&(r+=" Z"),r}draw(t){const e=this.points;if(0!==e.length){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const n of e)t.lineTo(n.x,n.y);this.closed&&t.closePath()}}sample(t){return function(t=8){return e=>{let n=t,r=e.length;if(n>1)for(r=Math.floor(e.length/n);r<3&&n>1;)n-=1,r=Math.floor(e.length/n);const i=[];for(let t=0,o=0;o<r;o++,t+=n)i.push(e.get(t));return new WD(i)}}(t)(this)}simplify(t){return function(t=0){return e=>{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r<e.length;){let t=r+1;for(;GD(e,r,t,i);)t++;n.push(e.get(r)),r=t}return new WD(n)}}(t)(this)}bSplines(t){return function(t=6){function e(t,e,n){let r=0,i=0;for(let o=-2;o<=1;o++){const a=t.get(e+o),s=VD(o,n);r+=s*a.x,i+=s*a.y}return{x:r,y:i}}return n=>{if(n.length<3)return n;const r=[],i=n.closed,o=n.length+3-1+(i?0:2);r.push(e(n,2-(i?0:2),0));for(let a=2-(i?0:2);a<o;a++)for(let i=1;i<=t;i++)r.push(e(n,a,i/t));return new WD(r)}}(t)(this)}apply(t){return t(this)}containsElements(t){const e=function(t){if(0===t.length)return null;const e=t[0],n=new AD(e.x,e.y,0,0);for(const e of t)n.addPoint(e);return n}(this.points);return!!e&&t.every((t=>e.containsPt(t.cx,t.cy)&&this.withinArea(t.cx,t.cy)))}withinArea(t,e){if(0===this.length)return!1;let n=0;const r=this.points[0],i=new bD(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(t,e)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(t,e)&&n++,n%2==1}}class HD{constructor(t=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=t}add(t){this.set.add(`${t.x}x${t.y}`),this.arr[this.count++]=t}contains(t){return this.set.has(`${t.x}x${t.y}`)}isFirst(t){if(0===this.count)return!1;const e=this.arr[0];return null!=e&&e.x===t.x&&e.y===t.y}path(){return new WD(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(t){return this.arr[t]}get length(){return this.count}}const UD=0,$D=1,qD=2,YD=3;function KD(t,e){const n=2*(Math.floor(t.width)+Math.floor(t.height)),r=new HD(n);function i(n,r,i,o){const a=t.get(n,r);return Number.isNaN(a)?Number.NaN:a>e?i+o:i}function o(t,e){let n=UD;return n=i(t,e,n,1),n=i(t+1,e,n,2),n=i(t,e+1,n,4),n=i(t+1,e+1,n,8),Number.isNaN(n)?-1:n}let a=$D;function s(e,n){let i=e,s=n,u=t.invertScaleX(i),c=t.invertScaleY(s);for(let e=0;e<t.width*t.height;e++){const e={x:u,y:c};if(r.contains(e)){if(r.isFirst(e))return!0}else r.add(e);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:a=qD;break;case 12:case 14:case 4:a=YD;break;case 6:a=a===UD?YD:qD;break;case 1:case 13:case 5:a=UD;break;case 9:a=a===qD?UD:$D;break;case 10:case 8:case 11:a=$D;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(a){case UD:s--,c-=t.pixelGroup;break;case $D:s++,c+=t.pixelGroup;break;case YD:i--,u-=t.pixelGroup;break;case qD:i++,u+=t.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<t.width;n++)for(let i=0;i<t.height;i++){if(t.get(n,i)<=e)continue;const a=o(n,i);if(!(a<0||15===a)&&s(n,i))return r.path()}return null}const XD={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function ZD(t){return null!=t&&"number"==typeof t.radius}function QD(t,e){if(ZD(t)!==ZD(e))return!1;if(ZD(t)){const n=e;return t.cx===n.cx&&t.cy===n.cy&&t.radius===n.radius}const n=e;return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}var JD;!function(t){t[t.MEMBERS=0]="MEMBERS",t[t.NON_MEMBERS=1]="NON_MEMBERS",t[t.EDGES=2]="EDGES"}(JD||(JD={}));let tL=class{constructor(t={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new AD(0,0,0,0),this.potentialArea=new OD(1,0,0,0,0,0,0),this.o=Object.assign({},XD,t)}pushMember(...t){if(0!==t.length){this.dirty.add(JD.MEMBERS);for(const e of t)this.members.push({raw:e,obj:ZD(e)?PD.from(e):AD.from(e),area:null})}}removeMember(t){const e=this.members.findIndex((e=>QD(e.raw,t)));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(JD.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex((e=>QD(e.raw,t)));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(JD.NON_MEMBERS),!0)}removeEdge(t){const e=this.edges.findIndex((e=>e.obj.equals(t)));return!(e<0)&&(this.edges.splice(e,1),this.dirty.add(JD.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(JD.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:ZD(e)?PD.from(e):AD.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(JD.EDGES);for(const e of t)this.edges.push({raw:e,obj:bD.from(e),area:null})}}update(){const t=this.dirty.has(JD.MEMBERS),e=this.dirty.has(JD.NON_MEMBERS);let n=this.dirty.has(JD.EDGES);this.dirty.clear();const r=this.members.map((t=>t.obj));if(this.o.virtualEdges&&(t||e)){const t=LD(r,this.nonMembers.map((t=>t.obj)),this.o.maxRoutingIterations,this.o.morphBuffer),e=new Map(this.virtualEdges.map((t=>[t.obj.toString(),t.area])));this.virtualEdges=t.map((t=>{var n;return{raw:t,obj:t,area:null!==(n=e.get(t.toString()))&&void 0!==n?n:null}})),n=!0}let i=!1;if(t||n){const t=function(t,e){if(0===t.length)return new AD(0,0,0,0);const n=AD.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(vD(t));return n}(r,this.virtualEdges.concat(this.edges).map((t=>t.obj))),e=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,n=AD.from(_D(t,e));n.equals(this.activeRegion)||(i=!0,this.activeRegion=n)}if(i){const t=Math.ceil(this.activeRegion.width/this.o.pixelGroup),e=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=OD.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach((t=>t.area=null)),this.nonMembers.forEach((t=>t.area=null)),this.edges.forEach((t=>t.area=null)),this.virtualEdges.forEach((t=>t.area=null))):t===this.potentialArea.width&&e===this.potentialArea.height||(this.potentialArea=OD.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const o=new Map,a=t=>{if(t.area){const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof AD?"R":"C"}`;o.set(e,t.area)}},s=t=>{if(t.area)return;const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof AD?"R":"C"}`;if(o.has(e)){const n=o.get(e);return void(t.area=this.potentialArea.copy(n,{x:t.obj.x-this.o.nodeR1,y:t.obj.y-this.o.nodeR1}))}const n=t.obj instanceof AD?function(t,e,n){const r=e.scale(t),i=e.addPadding(r,n),o=e.createSub(i,{x:t.x-n,y:t.y-n}),a=r.x-i.x,s=r.y-i.y,u=i.x2-r.x2,c=i.y2-r.y2,l=i.width-a-u,h=i.height-s-c,d=n*n;o.fillArea({x:a,y:s,width:l+1,height:h+1},d);const f=[0],p=Math.max(s,a,u,c);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o<p;o++){const a=e.invertScaleY(r.y-o),s=t.distSquare(i,a);if(!(s<d))break;{const t=n-Math.sqrt(s);f.push(t*t)}}}const g=[],m=Math.max(a,u),y=Math.max(s,u);for(let i=1;i<m;i++){const o=e.invertScaleX(r.x-i),a=[];for(let i=1;i<y;i++){const s=e.invertScaleY(r.y-i),u=t.distSquare(o,s);if(u<d){const t=n-Math.sqrt(u);a.push(t*t)}else a.push(0)}g.push(a)}for(let t=1;t<Math.min(s,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s-t,l+1,e)}for(let t=1;t<Math.min(c,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s+h+t,l+1,e)}for(let t=1;t<Math.min(a,f.length);t++){const e=f[t];o.fillVerticalLine(a-t,s,h+1,e)}for(let t=1;t<Math.min(c,f.length);t++){const e=f[t];o.fillVerticalLine(a+l+t,s,h+1,e)}for(let t=1;t<a;t++){const e=g[t-1],n=a-t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<c;t++)o.set(n,s+h+t,e[t-1])}for(let t=1;t<u;t++){const e=g[t-1],n=a+l+t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<c;t++)o.set(n,s+h+t,e[t-1])}return o}(t.obj,this.potentialArea,this.o.nodeR1):ID(t.obj,this.potentialArea,this.o.nodeR1);t.area=n,o.set(e,n)};this.members.forEach(a),this.nonMembers.forEach(a),this.members.forEach(s),this.nonMembers.forEach((t=>{this.activeRegion.intersects(t.obj)?s(t):t.area=null})),this.edges.forEach((t=>{t.area||(t.area=RD(t.obj,this.potentialArea,this.o.edgeR1))})),this.virtualEdges.forEach((t=>{t.area||(t.area=RD(t.obj,this.potentialArea,this.o.edgeR1))}))}drawMembers(t){for(const e of this.members)e.obj.draw(t)}drawNonMembers(t){for(const e of this.nonMembers)e.obj.draw(t)}drawEdges(t){for(const e of this.edges)e.obj.draw(t)}drawPotentialArea(t,e=!0){this.potentialArea.draw(t,e)}compute(){if(0===this.members.length)return new WD([]);this.dirty.size>0&&this.update();const{o:t,potentialArea:e}=this,n=this.members.map((t=>t.area)),r=this.virtualEdges.concat(this.edges).map((t=>t.area)),i=this.nonMembers.filter((t=>null!=t.area)).map((t=>t.area)),o=this.members.map((t=>t.obj));return function(t,e,n,r,i,o={}){const a=Object.assign({},XD,o);let s=a.threshold,u=a.memberInfluenceFactor,c=a.edgeInfluenceFactor,l=a.nonMemberInfluenceFactor;const h=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),d=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1);for(let o=0;o<a.maxMarchingIterations;o++){if(t.clear(),0!==u){const n=u/h;for(const r of e)t.incArea(r,n)}if(0!==c){const e=c/d;for(const r of n)t.incArea(r,e)}if(0!==l){const e=l/h;for(const n of r)t.incArea(n,e)}const f=KD(t,s);if(f&&i(f))return f;if(s*=.95,o<=.5*a.maxMarchingIterations)u*=1.2,c*=1.2;else{if(!(0!==l&&r.length>0))break;l*=.8}}return new WD([])}(e,n,r,i,(t=>t.containsElements(o)),t)}};class eL extends pD{shape;bubbleSets;path;members=new Map;avoidMembers=new Map;bubbleSetOptions={};static defaultOptions={members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2,...XD};constructor(t,e){super(t,ce({},eL.defaultOptions,e)),this.bindEvents(),this.bubbleSets=new tL(this.options)}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath)}init(){this.bubbleSets=new tL(this.options),this.members=new Map,this.avoidMembers=new Map}parseOptions(){const{type:t,key:e,members:n,avoidMembers:r,...i}=this.options,o=Object.keys(i).reduce(((t,e)=>(e in XD?t.bubbleSetOptions[e]=i[e]:t.style[e]=i[e],t)),{style:{},bubbleSetOptions:{}});return{type:t,key:e,members:n,avoidMembers:r,...o}}drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();de(this.bubbleSetOptions,e)||this.init(),this.bubbleSetOptions={...e};const n={...t,d:this.getPath()};this.shape?this.shape.update(n):(this.shape=new Yl({style:n}),this.context.canvas.appendChild(this.shape))};updateBubbleSetsPath=t=>{if(!this.shape)return;const e=Xc(t.data);[...this.options.members,...this.options.avoidMembers].includes(e)&&this.shape.update({...this.parseOptions().style,d:this.getPath(e)})};getPath=t=>{const{graph:e}=this.context,n=this.options.members,r=[...this.members.keys()],i=this.options.avoidMembers,o=[...this.avoidMembers.keys()];if(!t&&de(n,r)&&de(i,o))return this.path;const{enter:a=[],exit:s=[]}=hd(r,n,(t=>t)),{enter:u=[],exit:c=[]}=hd(o,i,(t=>t));t&&(s.push(t),a.push(t));const l=(t,n,r)=>{t.forEach((t=>{const i=r?this.members:this.avoidMembers,o=r?"pushMember":"pushNonMember",a=r?"removeMember":"removeNonMember";if(n){let n;"edge"===e.getElementType(t)?([n]=rL(e,t),this.bubbleSets.pushEdge(n)):([n]=nL(e,t),this.bubbleSets[o](n)),i.set(t,n)}else{const n=i.get(t);n&&("edge"===e.getElementType(t)?this.bubbleSets.removeEdge(n):this.bubbleSets[a](n),i.delete(t))}}))};l(s,!1,!0),l(a,!0,!0),l(c,!1,!1),l(u,!0,!1);const h=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=ql(h.points.map(wl)),this.path};addMember(t){const e=Array.isArray(t)?t:[t];e.some((t=>this.options.avoidMembers.includes(t)))&&(this.options.avoidMembers=this.options.avoidMembers.filter((t=>!e.includes(t)))),this.options.members=[...new Set([...this.options.members,...e])],this.drawBubbleSets()}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter((t=>!e.includes(t))),this.drawBubbleSets()}updateMember(t){this.options.members=Ot(t)?t(this.options.members):t,this.drawBubbleSets()}getMember(){return this.options.members}addAvoidMember(t){const e=Array.isArray(t)?t:[t];e.some((t=>this.options.members.includes(t)))&&(this.options.members=this.options.members.filter((t=>!e.includes(t)))),this.options.avoidMembers=[...new Set([...this.options.avoidMembers,...e])],this.drawBubbleSets()}removeAvoidMember(t){const e=Array.isArray(t)?t:[t];this.options.avoidMembers.some((t=>e.includes(t)))&&(this.options.avoidMembers=this.options.avoidMembers.filter((t=>!e.includes(t))),this.drawBubbleSets())}updateAvoidMember(t){this.options.avoidMembers=Array.isArray(t)?t:[t],this.drawBubbleSets()}getAvoidMember(){return this.options.avoidMembers}destroy(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath),this.shape.destroy(),super.destroy()}}const nL=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getElementRenderBounds(e);return new AD(n.min[0],n.min[1],Rc(n),Ic(n))})),rL=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getEdgeData(e),r=t.getElementPosition(n.source),i=t.getElementPosition(n.target);return bD.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})}));const iL=t=>t?parseInt(t):0;function oL(t){let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||iL(e.width),r=t.clientHeight||iL(e.height);return[n-(iL(e.paddingLeft)+iL(e.paddingRight)),r-(iL(e.paddingTop)+iL(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max($t(e)?e:1,1),Math.max($t(n)?n:1,1)]}function aL(t,e=!0){const n=document.createElement("div");return n.setAttribute("class",`g6-${t}`),n.style.position="absolute",n.style.display="block",e&&(n.style.top="0px",n.style.left="0px",n.style.height="100%",n.style.width="100%",n.style.overflow="hidden",n.style.pointerEvents="none"),n}function sL(t,e="div",n={},r="",i=document.body){const o=document.getElementById(t);o&&o.remove();const a=document.createElement(e);return a.innerHTML=r,a.id=t,Object.assign(a.style,n),i.appendChild(a),a}class uL extends pD{static defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};$element=aL("contextmenu",!1);constructor(t,e){super(t,Object.assign({},uL.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),sL("g6-contextmenu-css","style",{},"\n .g6-contextmenu {\n font-size: 12px;\n background-color: rgba(255, 255, 255, 0.96);\n border-radius: 4px;\n overflow: hidden;\n box-shadow: rgba(0, 0, 0, 0.12) 0px 6px 12px 0px;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s;\n }\n\n .g6-contextmenu-ul {\n max-width: 256px;\n min-width: 96px;\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n .g6-contextmenu-li {\n padding: 8px 12px;\n cursor: pointer;\n user-select: none;\n }\n\n .g6-contextmenu-li:hover {\n background-color: #f5f5f5;\n cursor: pointer;\n }\n",document.head),this.update(e)}async show(t){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hide();const r=await this.getDOMContent(t);r instanceof HTMLElement?this.$element.appendChild(r):this.$element.innerHTML=r;const i=this.context.graph.getCanvas().getContainer().getBoundingClientRect();this.$element.style.left=`${t.client.x-i.left+n[0]}px`,this.$element.style.top=`${t.client.y-i.top+n[1]}px`,this.$element.style.display="block"}hide(){this.$element.style.display="none"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}async getDOMContent(t){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(await n(t)).map((t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`)).join("")}\n </ul>\n `:await e(t)}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`canvas:${e}`,this.onTriggerEvent),t.on(`node:${e}`,this.onTriggerEvent),t.on(`edge:${e}`,this.onTriggerEvent),t.on(`combo:${e}`,this.onTriggerEvent),document.addEventListener("click",this.onMenuItemClick)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`canvas:${e}`,this.onTriggerEvent),t.off(`node:${e}`,this.onTriggerEvent),t.off(`edge:${e}`,this.onTriggerEvent),t.off(`combo:${e}`,this.onTriggerEvent),document.removeEventListener("click",this.onMenuItemClick)}onTriggerEvent=t=>{t.preventDefault?.(),this.show(t)};onMenuItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof HTMLElement){if(t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");e&&e(n,t.target),this.hide()}this.context.graph.getCanvas().getContainer().contains(t.target)||this.hide()}}}class cL extends pD{static defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};$element=aL("grid-line");offset=[0,0];constructor(t,e){super(t,Object.assign({},cL.defaultOptions,e));!function(t,e){const n=t.firstChild;n?t.insertBefore(e,n):t.appendChild(e)}(this.context.canvas.getContainer(),this.$element),this.updateStyle(),this.bindEvents()}update(t){super.update(t),this.updateStyle()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}updateStyle(){const{size:t,stroke:e,lineWidth:n,border:r,borderLineWidth:i,borderStroke:o,borderStyle:a}=this.options;Object.assign(this.$element.style,{border:r?`${i}px ${a} ${o}`:"none",backgroundImage:`linear-gradient(${e} ${n}px, transparent ${n}px), linear-gradient(90deg, ${e} ${n}px, transparent ${n}px)`,backgroundSize:`${t}px ${t}px`})}updateOffset(t){this.offset=function(t,e){return t.map((t=>t%e))}(ol(this.offset,t),this.options.size),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}onTransform=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)};destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}function lL(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=Xc(r);if("NodeAdded"===n||"EdgeAdded"===n||"ComboAdded"===n)e.Added.set(i,t);else if("NodeUpdated"===n||"EdgeUpdated"===n||"ComboUpdated"===n)if(e.Added.has(i))e.Added.set(i,{type:n.replace("Updated","Added"),value:r});else if(e.Updated.has(i)){const{original:t}=e.Updated.get(i);e.Updated.set(i,{type:n,value:r,original:t})}else e.Removed.has(i)||e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)?e.Added.delete(i):e.Updated.has(i)?(e.Updated.delete(i),e.Removed.set(i,t)):e.Removed.set(i,t))})),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}function hL(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:a=[],ComboAdded:s=[],ComboUpdated:u=[],ComboRemoved:c=[]}=Ht(t,(t=>t.type));return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:u},remove:{nodes:r,edges:a,combos:c}}}function dL(t,e){for(const n in t)Lt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),dL(t[n],e[n])):e[n]||(e[n]=sd(n))}function fL(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:a}=hL(lL(t));return["nodes","edges","combos"].forEach((t=>{o[t]&&o[t].forEach((e=>{const i={...e.value};let o={...e.original};if(n){const t=n.graph.getElementType(Xc(e.original)),r="edge"===t?"stroke":"fill",i=n.element.getElementComputedStyle(t,e.original);o={...e.original,style:{[r]:i[r],...e.original.style}}}dL(i,o),r.current.update[t]||=[],r.current.update[t].push(i),r.original.update[t]||=[],r.original.update[t].push(o)})),i[t]&&i[t].forEach((e=>{const n={...e.value};r.current.add[t]||=[],r.current.add[t].push(n),r.original.remove[t]||=[],r.original.remove[t].push(n)})),a[t]&&a[t].forEach((e=>{const n={...e.value};r.current.remove[t]||=[],r.current.remove[t].push(n),r.original.add[t]||=[],r.original.add[t].push(n)}))})),r}class pL extends pD{static defaultOptions={stackSize:0};emitter;batchChanges=null;batchAnimation=!1;undoStack=[];redoStack=[];isFirstDraw=!0;freezed=!1;constructor(e,n){super(e,Object.assign({},pL.defaultOptions,n)),this.emitter=new Td;const{graph:r}=this.context;r.on(t.GraphEvent.AFTER_DRAW,this.addCommand),r.on(t.GraphEvent.BATCH_START,this.initBatchCommand),r.on(t.GraphEvent.BATCH_END,this.addCommand)}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}undo(){const e=this.undoStack.pop();return e&&(this.executeCommand(e),this.options.beforeAddCommand?.(e,!1),this.redoStack.push(e),this.options.afterAddCommand?.(e,!1),this.notify(t.HistoryEvent.UNDO,e)),this}redo(){const e=this.redoStack.pop();return e&&(this.executeCommand(e,!1),this.undoStackPush(e),this.notify(t.HistoryEvent.REDO,e)),this}undoAndCancel(){const e=this.undoStack.pop();return e&&(this.executeCommand(e,!1),this.redoStack=[],this.notify(t.HistoryEvent.CANCEL,e)),this}executeCommand=(t,e=!0)=>{this.freezed=!0,this.options.executeCommand?.(t);const n=e?t.original:t.current;this.context.graph.addData(n.add),this.context.graph.updateData(n.update),this.context.graph.removeData(Qc(n.remove,!1)),this.context.element?.draw({silence:!0,animation:t.animation}),this.freezed=!1};addCommand=e=>{if(this.isFirstDraw)this.isFirstDraw=!1;else if(!this.freezed){if(e.type===t.GraphEvent.AFTER_DRAW){const{dataChanges:t=[],animation:n=!0}=e.data;if(this.context.batch?.isBatching){if(!this.batchChanges)return;return this.batchChanges.push(t),void(this.batchAnimation&&=n)}this.batchChanges=[t],this.batchAnimation=n}this.undoStackPush(fL(this.batchChanges.flat(),this.batchAnimation,this.context)),this.notify(t.HistoryEvent.ADD,this.undoStack[this.undoStack.length-1])}};initBatchCommand=t=>{const{initiate:e}=t.data;if(this.batchAnimation=!1,e)this.batchChanges=[];else{this.undoStack.pop()||(this.batchChanges=null)}};undoStackPush(t){const{stackSize:e}=this.options;0!==e&&this.undoStack.length>=e&&this.undoStack.shift(),this.options.beforeAddCommand?.(t,!0),this.undoStack.push(t),this.options.afterAddCommand?.(t,!0)}clear(){this.undoStack=[],this.redoStack=[],this.batchChanges=null,this.batchAnimation=!1,this.notify(t.HistoryEvent.CLEAR,null)}notify(e,n){this.emitter.emit(e,{cmd:n}),this.emitter.emit(t.HistoryEvent.CHANGE,{cmd:n})}on(t,e){this.emitter.on(t,e)}destroy(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.addCommand),e.off(t.GraphEvent.BATCH_START,this.initBatchCommand),e.off(t.GraphEvent.BATCH_END,this.addCommand),this.emitter.off(),super.destroy(),this.undoStack=[],this.redoStack=[]}}function gL(t,e,n,r,i,o){const a=(o-e)*(n-t)-(r-e)*(i-t);return a>0||!(a<0)}var mL=function(t,e){const n=t[0][0],r=t[0][1],i=t[1][0],o=t[1][1],a=e[0][0],s=e[0][1],u=e[1][0],c=e[1][1];return gL(n,r,a,s,u,c)!==gL(i,o,a,s,u,c)&&gL(n,r,i,o,a,s)!==gL(n,r,i,o,u,c)};function yL(t,e){this._cells=[],this._cellSize=e,this._reverseCellSize=1/e;for(let e=0;e<t.length;e++){const n=t[e],r=this.coordToCellNum(n[0]),i=this.coordToCellNum(n[1]);if(this._cells[r])this._cells[r][i]?this._cells[r][i].push(n):this._cells[r][i]=[n];else{const t=[];t[i]=[n],this._cells[r]=t}}}function vL(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}yL.prototype={cellPoints:function(t,e){return void 0!==this._cells[t]&&void 0!==this._cells[t][e]?this._cells[t][e]:[]},rangePoints:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this.coordToCellNum(t[2]),i=this.coordToCellNum(t[3]),o=[];for(let t=e;t<=r;t++)for(let e=n;e<=i;e++)for(let n=0;n<this.cellPoints(t,e).length;n++)o.push(this.cellPoints(t,e)[n]);return o},removePoint:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this._cells[e][n];let i;for(let e=0;e<r.length;e++)if(r[e][0]===t[0]&&r[e][1]===t[1]){i=e;break}return r.splice(i,1),r},trunc:Math.trunc||function(t){return t-t%1},coordToCellNum:function(t){return this.trunc(t*this._reverseCellSize)},extendBbox:function(t,e){return[t[0]-e*this._cellSize,t[1]-e*this._cellSize,t[2]+e*this._cellSize,t[3]+e*this._cellSize]}};var bL=function(t){const e=function(t){const e=[];for(let n=0;n<t.length;n++){for(;e.length>=2&&vL(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}return e.pop(),e}(t),n=function(t){const e=t.reverse(),n=[];for(let t=0;t<e.length;t++){for(;n.length>=2&&vL(n[n.length-2],n[n.length-1],e[t])<=0;)n.pop();n.push(e[t])}return n.pop(),n}(t).concat(e);return n.push(t[0]),n};const xL=mL,wL=function(t,e){return new yL(t,e)},EL={toXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","return [pt"+e[0]+",pt"+e[1]+"];")(t)}))},fromXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","const o = {}; o"+e[0]+"= pt[0]; o"+e[1]+"= pt[1]; return o;")(t)}))}},ML=bL;function SL(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function NL(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=SL(t,e),a=SL(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*a)}function kL(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&xL(t,r))return!0}return!1}function CL(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function TL(t,e,n){let r,i,o=null,a=PL,s=PL;for(let u=0;u<e.length;u++)r=NL(t[0],t[1],e[u]),i=NL(t[1],t[0],e[u]),r>a&&i>s&&!kL([t[0],e[u]],n)&&!kL([t[1],e[u]],n)&&(a=r,s=i,o=e[u]);return o}function AL(t,e,n,r,i){let o=!1;for(let a=0;a<t.length-1;a++){const s=[t[a],t[a+1]],u=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(SL(s[0],s[1])<e||i.has(u))continue;let c,l,h,d=0,f=CL(s);do{f=r.extendBbox(f,d),c=f[2]-f[0],l=f[3]-f[1],h=TL(s,r.rangePoints(f),t),d++}while(null===h&&(n[0]>c||n[1]>l));c>=n[0]&&l>=n[1]&&i.add(u),null!==h&&(t.splice(a+1,0,h),r.removePoint(h),o=!0)}return o?AL(t,e,n,r,i):t}const PL=Math.cos(90/(180/Math.PI)),OL=.6;var _L=function(t,e,n){let r=e||20;const i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort((function(t,e){return t[0]-e[0]||t[1]-e[1]}))}(EL.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?EL.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),t[o][0]>r&&(r=t[o][0]),t[o][1]>i&&(i=t[o][1]);return[r-e,i-n]}(i),a=[o[0]*OL,o[1]*OL],s=ML(i),u=i.filter((function(t){return s.indexOf(t)<0})),c=Math.ceil(1/(i.length/(o[0]*o[1]))),l=AL(s,Math.pow(r,2),a,wL(u,c),new Set);return n?EL.fromXy(l,n):l},RL=f(_L);const IL=(t,e,n)=>{if("sharp"===n)return[["M",t[0]-e,t[1]-e],["L",t[0]+e,t[1]-e],["L",t[0]+e,t[1]+e],["L",t[0]-e,t[1]+e],["Z"]];const r=[e,e,0,0,0];return[["M",t[0],t[1]-e],["A",...r,t[0],t[1]+e],["A",...r,t[0],t[1]-e]]},DL=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?ol(t[0],cl(dl(al(t[0],t[1])),e)):t[0],o="sharp"===n?ol(t[1],cl(dl(al(t[1],t[0])),e)):t[1],a=cl(dl(pl(al(i,o),!1)),e),s=cl(a,-1),u=ol(i,a),c=ol(o,a),l=ol(o,s),h=ol(i,s);return"sharp"===n?[["M",u[0],u[1]],["L",c[0],c[1]],["L",l[0],l[1]],["L",h[0],h[1]],["Z"]]:[["M",u[0],u[1]],["L",c[0],c[1]],["A",...r,l[0],l[1]],["L",h[0],h[1]],["A",...r,u[0],u[1]]]},LL=(t,e)=>{const n=Pl(t).map(((n,r)=>{const i=(r-2+t.length)%t.length,o=(r-1+t.length)%t.length,a=(r+1)%t.length,s=t[i],u=t[o],c=t[a],l=al(s,u),h=al(u,n),d=al(n,c),f=(t,e)=>fl(t,e,!0)<Math.PI,p=f(l,h),g=f(h,d),m=t=>cl(dl(pl(t,!1)),e),y=m(h);return[{p:gl(ol(u,p?m(l):y)),concave:p&&u},{p:gl(ol(n,g?m(d):y)),concave:g&&n}]})),r=[e,e,0,0,0],i=n.findIndex(((t,e)=>!(n[(e-1+n.length)%n.length][0].concave||n[(e-1+n.length)%n.length][1].concave||t[0].concave||t[0].concave||t[1].concave))),o=n.slice(i).concat(n.slice(0,i));let a=[];return o.flatMap(((t,e)=>{const i=[],s=o[n.length-1];return 0===e&&i.push(["M",...s[1].p]),t[0].concave?a.push(t[0].p,t[1].p):i.push(["A",...r,...t[0].p]),t[1].concave?a.unshift(t[1].p):i.push(["L",...t[1].p]),3===a.length&&(i.pop(),i.push(["C",...a.flat()]),a=[]),i}))},jL=(t,e)=>{const n=Pl(t).map(((e,n)=>({p:e,v:dl(al(t[(n+1)%t.length],e))})));return n.forEach(((r,i)=>{const o=i>0?i-1:t.length-1,a=n[o].v,s=dl(ol(a,cl(r.v,fl(a,r.v,!0)<Math.PI?1:-1)));r.p=ol(r.p,cl(s,e))})),ql(n.map((t=>t.p)))},BL=(t,e)=>{const n=t.map(((n,r)=>{const i=t[0===r?t.length-1:r-1],o=ml(cl(dl(pl(al(i,n),!1)),e));return[ol(i,o),ol(n,o)]})).flat();return n.map(((t,e)=>{if(e%2==0)return null;return xl([n[(e-1)%n.length],n[e%n.length]],[n[(e+1)%n.length],n[(e+2)%n.length]],!0)})).filter(Boolean).map(((t,e)=>[0===e?"M":"L",t[0],t[1]])).concat([["Z"]])};class zL extends pD{shape;hullMemberIds=[];path;optionsCache;static defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};constructor(t,e){super(t,Object.assign({},zL.defaultOptions,e)),this.bindEvents()}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}getHullStyle(t){const{members:e,padding:n,corner:r,...i}=this.options;return{...i,d:this.getHullPath(t)}}drawHull=()=>{if(this.shape){const t=!de(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new Yl({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache={...this.options}};updateHullPath=t=>{this.shape&&this.options.members.includes(Xc(t.data))&&this.shape.update({d:this.getHullPath(!0)})};getHullPath=(t=!1)=>{const{graph:e}=this.context,n=this.options.members.map((t=>e.getNodeData(t))),r=RL(n.map(Vc),this.options.concavity).slice(1).reverse(),i=r.flatMap((t=>n.filter((e=>de(Vc(e),t))).map(Xc)));return de(i,this.hullMemberIds)&&!t||(this.hullMemberIds=i,this.path=function(t,e,n){if(1===t.length)return IL(t[0],e,n);if(2===t.length)return DL(t,e,n);switch(n){case"smooth":return jL(t,e);case"sharp":return BL(t,e);default:return LL(t,e)}}(r,this.getPadding(),this.options.corner)),this.path};getPadding(){const{graph:t}=this.context,e=this.hullMemberIds.reduce(((e,n)=>{const{halfExtents:r}=t.getElementRenderBounds(n),i=Math.max(r[0],r[1]);return Math.max(e,i)}),0);return e+this.options.padding}addMember(t){const e=Array.isArray(t)?t:[t];this.options.members=[...new Set([...this.options.members,...e])],this.shape.update({d:this.getHullPath()})}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter((t=>!e.includes(t))),e.some((t=>this.hullMemberIds.includes(t)))&&this.shape.update({d:this.getHullPath()})}updateMember(t){this.options.members=Ot(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.drawHull),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function FL(t,e){e(t),t.children&&t.children.forEach((function(t){t&&FL(t,e)}))}function GL(t){WL(t,!0)}function VL(t){WL(t,!1)}function WL(t,e){var n=e?"visible":"hidden";FL(t,(function(t){t.attr("visibility",n)}))}var HL=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,l([],c(e),!1))||this;return r.isMutationObserved=!0,r.addEventListener(as.INSERTED,(function(){VL(r)})),r}return r(e,t),e}(Vs);function UL(t){var e=t.appendChild(new HL({class:"offscreen"}));return VL(e),e}var $L=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({style:i({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return r(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=UL(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(Xs);function qL(t){return t*Math.PI/180}function YL(t){return Number((180*t/Math.PI).toPrecision(5))}var KL=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=r}return Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t.prototype.toJSON=function(){return{x:this.x,y:this.y,width:this.width,height:this.height,top:this.top,right:this.right,bottom:this.bottom,left:this.left}},t.prototype.isPointIn=function(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}();function XL(t,e){return Ot(t)?t.apply(void 0,l([],c(e),!1)):t}var ZL,QL=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=c(t,2),r=e[0],i=e[1],o=n(i);return[r,{name:o,class:".".concat(o),id:"#".concat(o),toString:function(){return o}}]})));return Object.assign(r,{prefix:n}),r},JL=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=c(i,2),a=o[0],s=o[1],u=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?zt(s)?(zt(t[a])||(u[a]={}),n<r?JL(t[a],s,n+1,r):u[a]=e[a]):Dt(s)?(u[a]=[],u[a]=u[a].concat(s)):u[a]=s:u[a]=s)}))},tj=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)JL(t,e[r]);return t},ej=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},nj=function(t,e,n){if(!Ot(t))throw new TypeError("Expected a function");var r=function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=e?e.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var s=t.apply(this,n);return a.set(o,s),s};return r.cache=function(t){var e,n,r,i=t;function o(t,o){++e>i&&(r=n,a(1),++e),n[t]=o}function a(t){e=0,n=Object.create(null),t||(r=Object.create(null))}return a(),{clear:a,has:function(t){return void 0!==n[t]||void 0!==r[t]},get:function(t){var e=n[t];return void 0!==e?e:void 0!==(e=r[t])?(o(t,e),e):void 0},set:function(t,e){void 0!==n[t]?n[t]=e:o(t,e)}}}(n),r}((function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return ZL||(ZL=Es.offscreenCanvasCreator.getOrCreateContext(void 0)),ZL.font=[o,a,i,"".concat(n,"px"),r].join(" "),ZL.measureText(t).width}),(function(t,e){return[t,Object.values(e||rj(t)).join()].join("")}),4096),rj=function(t){var e=t.style.fontFamily||"sans-serif",n=t.style.fontWeight||"normal",r=t.style.fontStyle||"normal",i=t.style.fontVariant,o=t.style.fontSize;return{fontSize:o="object"==typeof o?o.value:o,fontFamily:e,fontWeight:n,fontStyle:r,fontVariant:i}};function ij(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function oj(t,e){var n=ij(t);n&&n.attr(e)}function aj(t,e,n){void 0===n&&(n="..."),oj(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function sj(t){var e=t.canvas,n=t.touches,r=t.offsetX,i=t.offsetY;if(e)return[e.x,e.y];if(n){var o=n[0];return[o.clientX,o.clientY]}return r&&i?[r,i]:[0,0]}function uj(t){return"function"==typeof t?t():Vt(t)||$t(t)?new $L({style:{text:String(t)}}):t}function cj(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=function(t){t.node().removeChildren()}),t?n(e):(r&&i(e),null)}function lj(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=!1),!!(r&&t===e||i&&t===n)||t>e&&t<n}var hj=function(t,e){return function(n){return t*(1-n)+e*n}};function dj(t,e){return"number"==typeof t&&"number"==typeof e?hj(t,e):Array.isArray(t)&&Array.isArray(e)?function(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0;return function(i){var o=new Array(r),a=new Array(n),s=0;for(s=0;s<r;++s)o[s]=dj(t[s],e[s]);for(;s<n;++s)a[s]=e[s];for(s=0;s<r;++s)a[s]=o[s](i);return a}}(t,e):"object"==typeof t&&"object"==typeof e?function(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n={},r={};return Object.entries(e).forEach((function(e){var i=c(e,2),o=i[0],a=i[1];o in t?n[o]=dj(t[o],a):r[o]=a})),function(t){return Object.entries(n).forEach((function(e){var n=c(e,2),i=n[0],o=n[1];return r[i]=o(t)})),r}}(t,e):function(e){return t}}function fj(t){for(var e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;o<t.length;o++){var a=t[o],s=a.x,u=a.y,l=c([s+a.width,u+a.height],2),h=l[0],d=l[1];s<e&&(e=s),u<n&&(n=u),h>r&&(r=h),d>i&&(i=d)}return new KL(e,n,r-e,i-n)}var pj=function(t,e,n){var r=t.width,i=t.height,o=n.flexDirection,a=void 0===o?"row":o;n.flexWrap;var s=n.justifyContent,u=void 0===s?"flex-start":s;n.alignContent;var l=n.alignItems,h=void 0===l?"flex-start":l,d="row"===a,f="row"===a||"column"===a,p=d?f?[1,0]:[-1,0]:f?[0,1]:[0,-1],g=c([0,0],2),m=g[0],y=g[1],v=e.map((function(t){var e,n=t.width,r=t.height,i=c([m,y],2),o=i[0],a=i[1];return e=c([m+n*p[0],y+r*p[1]],2),m=e[0],y=e[1],new KL(o,a,n,r)})),b=fj(v),x={"flex-start":0,"flex-end":d?r-b.width:i-b.height,center:d?(r-b.width)/2:(i-b.height)/2},w=v.map((function(t){var e=t.x,n=t.y,r=KL.fromRect(t);return r.x=d?e+x[u]:e,r.y=d?n:n+x[u],r}));fj(w);var E=function(t){var e=c(d?["height",i]:["width",r],2),n=e[0],o=e[1];switch(h){case"flex-start":default:return 0;case"flex-end":return o-t[n];case"center":return o/2-t[n]/2}},M=w.map((function(t){var e=t.x,n=t.y,r=KL.fromRect(t);return r.x=d?e:e+E(r),r.y=d?n+E(r):n,r})),S=M.map((function(e){var n,r,i=KL.fromRect(e);return i.x+=null!==(n=t.x)&&void 0!==n?n:0,i.y+=null!==(r=t.y)&&void 0!==r?r:0,i}));return S},gj=function(t,e,n){return[]};function mj(t,e){return[t[0]*e,t[1]*e]}function yj(t,e){return[t[0]+e[0],t[1]+e[1]]}function vj(t,e){return[t[0]-e[0],t[1]-e[1]]}function bj(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function xj(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function wj(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function Ej(t){if(0===t[0]&&0===t[1])return[0,0];var e=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2));return[t[0]/e,t[1]/e]}function Mj(t,e){return+t.toPrecision(e)}function Sj(t,e){var n={},r=Array.isArray(e)?e:[e];for(var i in t)r.includes(i)||(n[i]=t[i]);return n}function Nj(t,e,n){void 0===n&&(n=[[0,0],[1,1]]);for(var r=!!e,i=[],o=0,a=t.length;o<a;o+=2)i.push([t[o],t[o+1]]);var s,u,l,h=function(t,e,n,r){var i,o,a,s,u,l,h=[],d=!!r,f=[1/0,1/0],p=[-1/0,-1/0];if(d){f=(i=c(r,2))[0],p=i[1];for(var g=0,m=t.length;g<m;g+=1)f=bj(f,v=t[g]),p=xj(p,v)}g=0;for(var y=t.length;g<y;g+=1){var v=t[g];if(0!==g||n)if(g!==y-1||n){o=t[g-1];var b=[0,0];b=mj(b=vj(a=t[g+1],o),e);var x=wj(v,o),w=wj(v,a),E=x+w;0!==E&&(x/=E,w/=E);var M=mj(b,-x),S=mj(b,w);u=yj(v,M),s=bj(s=yj(v,S),xj(a,v)),s=xj(s,bj(a,v)),u=bj(u=yj(v,M=mj(M=vj(s,v),-x/w)),xj(o,v)),s=yj(v,S=mj(S=vj(v,u=xj(u,bj(o,v))),w/x)),d&&(u=bj(u=xj(u,f),p),s=bj(s=xj(s,f),p)),h.push(l),h.push(u),l=s}else u=v,h.push(l),h.push(u);else l=v}return h}(i,.4,r,n),d=i.length,f=[];for(o=0;o<d-1;o+=1)s=h[2*o],u=h[2*o+1],l=i[o+1],f.push(["C",s[0],s[1],u[0],u[1],l[0],l[1]]);return f}var kj=["$el","cx","cy","d","dx","dy","fill","fillOpacity","filter","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","height","img","increasedLineWidthForHitTesting","innerHTML","isBillboard","billboardRotation","isSizeAttenuation","isClosed","isOverflowing","leading","letterSpacing","lineDash","lineHeight","lineWidth","markerEnd","markerEndOffset","markerMid","markerStart","markerStartOffset","maxLines","metrics","miterLimit","offsetX","offsetY","opacity","path","points","r","radius","rx","ry","shadowColor","src","stroke","strokeOpacity","text","textAlign","textBaseline","textDecorationColor","textDecorationLine","textDecorationStyle","textOverflow","textPath","textPathSide","textPathStartOffset","transform","transformOrigin","visibility","width","wordWrap","wordWrapWidth","x","x1","x2","y","y1","y2","z1","z2","zIndex"];function Cj(t){return kj.includes(t)}function Tj(t){var e={};for(var n in t)Cj(n)&&(e[n]=t[n]);return e}function Aj(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return t.style.transform="scale(".concat(a,")"),a}var Pj=function(){function t(t,n,r,i,o,a,s){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=[null,null,null,null,null]),void 0===a&&(a=[]),void 0===s&&(s=[]),e.add(this),this._elements=Array.from(t),this._data=n,this._parent=r,this._document=i,this._enter=o[0],this._update=o[1],this._exit=o[2],this._merge=o[3],this._split=o[4],this._transitions=a,this._facetElements=s}var e,n,r;return t.prototype.selectAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(e,null,this._elements[0],this._document)},t.prototype.selectFacetAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(this._elements,null,this._parent,this._document,void 0,void 0,e)},t.prototype.select=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t)[0]||null:t;return new n([e],null,e,this._document)},t.prototype.append=function(t){var e=this,r="function"==typeof t?t:function(){return e.createElement(t)},i=[];if(null!==this._data){for(var o=0;o<this._data.length;o++){var a=this._data[o],s=c(Array.isArray(a)?a:[a,null],2),u=s[0],l=s[1];(d=r(u,o)).__data__=u,null!==l&&(d.__fromElements__=l),this._parent.appendChild(d),i.push(d)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var h=this._elements[o],d=r(u=h.__data__,o);h.appendChild(d),i.push(d)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=h(this,e,"m",r).call(this,"#"===t[0]?t:"#".concat(t),n);return i.attr("id",t),i},t.prototype.maybeAppendByClassName=function(t,n){var i=t.toString(),o=h(this,e,"m",r).call(this,"."===i[0]?i:".".concat(i),n);return o.attr("className",i),o},t.prototype.maybeAppendByName=function(t,n){var i=h(this,e,"m",r).call(this,'[name="'.concat(t,'"]'),n);return i.attr("name",t),i},t.prototype.data=function(t,e,r){var i,o;void 0===e&&(e=function(t){return t}),void 0===r&&(r=function(){return null});for(var a,s,c,l=[],h=[],d=new Set(this._elements),f=[],p=new Set,g=new Map(this._elements.map((function(t,n){return[e(t.__data__,n),t]}))),m=new Map(this._facetElements.map((function(t,n){return[e(t.__data__,n),t]}))),y=(a=this._elements,s=function(t){return r(t.__data__)},c=new Map,a.forEach((function(t){var e=s(t);c.has(e)||c.set(e,[]),c.get(e).push(t)})),c),v=0;v<t.length;v++){var b=t[v],x=e(b,v),w=r(b,v);if(g.has(x))(N=g.get(x)).__data__=b,N.__facet__=!1,h.push(N),d.delete(N),g.delete(x);else if(m.has(x)){(N=m.get(x)).__data__=b,N.__facet__=!0,h.push(N),m.delete(x)}else if(y.has(x)){var E=y.get(x);f.push([b,E]);try{for(var M=(i=void 0,u(E)),S=M.next();!S.done;S=M.next()){var N=S.value;d.delete(N)}}catch(t){i={error:t}}finally{try{S&&!S.done&&(o=M.return)&&o.call(M)}finally{if(i)throw i.error}}y.delete(x)}else if(g.has(w)){(N=g.get(w)).__toData__?N.__toData__.push(b):N.__toData__=[b],p.add(N),d.delete(N)}else l.push(b)}var k=[new n([],l,this._parent,this._document),new n(h,null,this._parent,this._document),new n(d,null,this._parent,this._document),new n([],f,this._parent,this._document),new n(p,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,k)},t.prototype.merge=function(t){var e=l(l([],c(this._elements),!1),c(t._elements),!1),r=l(l([],c(this._transitions),!1),c(t._transitions),!1);return new n(e,null,this._parent,this._document,void 0,r)},t.prototype.createElement=function(t){if(this._document)return this._document.createElement(t,{});var e=n.registry[t];return e?new e:function(t){throw new Error(t)}("Unknown node type: ".concat(t))},t.prototype.join=function(t,e,n,r,i){void 0===t&&(t=function(t){return t}),void 0===e&&(e=function(t){return t}),void 0===n&&(n=function(t){return t.remove()}),void 0===r&&(r=function(t){return t}),void 0===i&&(i=function(t){return t.remove()});var o=t(this._enter),a=e(this._update),s=n(this._exit),u=r(this._merge),c=i(this._split);return a.merge(o).merge(s).merge(u).merge(c)},t.prototype.remove=function(){for(var t=function(t){var n=e._elements[t],r=e._transitions[t];r?r.then((function(){return n.remove()})):n.remove()},e=this,r=0;r<this._elements.length;r++)t(r);return new n([],null,this._parent,this._document,void 0,this._transitions)},t.prototype.each=function(t){for(var e=0;e<this._elements.length;e++){var n=this._elements[e],r=n.__data__;t.call(n,r,e)}return this},t.prototype.attr=function(t,e){var n="function"!=typeof e?function(){return e}:e;return this.each((function(r,i){void 0!==e&&(this[t]=n.call(this,r,i))}))},t.prototype.style=function(t,e,n){void 0===n&&(n=!0);var r="function"==typeof e&&n?e:function(){return e};return this.each((function(n,i){void 0!==e&&(this.style[t]=r.call(this,n,i))}))},t.prototype.styles=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!0),this.each((function(n,r){var i=this;Object.entries(t).forEach((function(t){var o=c(t,2),a=o[0],s=o[1],u="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(a,u.call(i,n,r))}))}))},t.prototype.update=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.maybeUpdate=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.transition=function(t){var e=this._transitions;return this.each((function(n,r){e[r]=t.call(this,n,r)}))},t.prototype.on=function(t,e){return this.each((function(){this.addEventListener(t,e)})),this},t.prototype.call=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.call.apply(t,l([this._parent,this],c(e),!1)),this},t.prototype.node=function(){return this._elements[0]},t.prototype.nodes=function(){return this._elements},t.prototype.transitions=function(){return this._transitions.filter((function(t){return!!t}))},t.prototype.parent=function(){return this._parent},n=t,e=new WeakSet,r=function(t,e){var r=this._elements[0],i=r.querySelector(t);if(i)return new n([i],null,this._parent,this._document);var o="string"==typeof e?this.createElement(e):e();return r.appendChild(o),new n([o],null,this._parent,this._document)},t.registry={g:Vs,rect:Ks,circle:zs,path:$s,text:$L,ellipse:Gs,image:Hs,line:Us,polygon:qs,polyline:Ys,html:Ws},t}();function Oj(t){return new Pj([t],null,t,t.ownerDocument)}function _j(t){if($t(t))return[t,t,t,t];if(Dt(t)){var e=t.length;if(1===e)return[t[0],t[0],t[0],t[0]];if(2===e)return[t[0],t[1],t[0],t[1]];if(3===e)return[t[0],t[1],t[2],t[1]];if(4===e)return t}return[0,0,0,0]}function Rj(t){var e=t.getLocalBounds(),n=c([e.min,e.max],2),r=c(n[0],2),i=r[0],o=r[1],a=c(n[1],2),s=a[0],u=a[1];return{x:i,y:o,width:s-i,height:u-o,left:i,bottom:u,top:o,right:s}}function Ij(t,e){var n=c(t,2),r=n[0],i=n[1],o=c(e,2),a=o[0],s=o[1];return r!==a&&i===s}function Dj(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function Lj(t,e,n){var r;void 0===n&&(n=!0);var i=e||(null===(r=t.match(/^([a-z][a-z0-9]+)/))||void 0===r?void 0:r[0])||"",o=t.replace(new RegExp("^(".concat(i,")")),"");return n?function(t){return t.toString().charAt(0).toLowerCase()+t.toString().slice(1)}(o):o}var jj=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function Bj(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=c(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(jj(o,"show")&&jj(Lj(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(Dj(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(Dj(e)),"")]=a;else if(!jj(o,"show")&&jj(o,e)!==n){var s=Lj(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function zj(t,e){return Object.entries(t).reduce((function(t,n){var r=c(n,2),i=r[0],o=r[1];return i.startsWith("show")?t["show".concat(e).concat(i.slice(4))]=o:t["".concat(e).concat(Dj(i))]=o,t}),{})}function Fj(t,e){void 0===e&&(e=["x","y","class","className"]);var n=["transform","transformOrigin","anchor","visibility","pointerEvents","zIndex","cursor","clipPath","clipPathTargets","offsetPath","offsetPathTargets","offsetDistance","draggable","droppable"],r={},i={};return Object.entries(t).forEach((function(t){var o=c(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function Gj(t,e){var n={YYYY:t.getFullYear(),MM:t.getMonth()+1,DD:t.getDate(),HH:t.getHours(),mm:t.getMinutes(),ss:t.getSeconds()},r=e;return Object.keys(n).forEach((function(t){var e=n[t];r=r.replace(t,"YYYY"===t?"".concat(e):"".concat(e).padStart(2,"0"))})),r}function Vj(t,e){if(e)try{var n=e.replace(/translate\(([+-]*[\d]+[%]*),[ ]*([+-]*[\d]+[%]*)\)/g,(function(e,n,r){return"translate(".concat(function(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=c([e,n].map((function(t,e){var n;return t.includes("%")?parseFloat((null===(n=t.match(/[+-]?([0-9]*[.])?[0-9]+/))||void 0===n?void 0:n[0])||"0")/100*(0===e?i:o):t})),2);return[a[0],a[1]]}(t,n,r),")")}));t.attr("transform",n)}catch(t){}}function Wj(){WL(this,"hidden"!==this.attributes.visibility)}var Hj=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,tj({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return r(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=UL(this)),this._offscreen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultOptions",{get:function(){return this._defaultOptions},enumerable:!1,configurable:!0}),e.prototype.connectedCallback=function(){this.render(this.attributes,this),this.bindEvents(this.attributes,this),this.initialized=!0},e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e.prototype.attributeChangedCallback=function(t){"visibility"===t&&Wj.call(this)},e.prototype.update=function(t,e){var n;return this.attr(tj({},this.attributes,t||{})),null===(n=this.render)||void 0===n?void 0:n.call(this,this.attributes,this,e)},e.prototype.clear=function(){this.removeChildren()},e.prototype.bindEvents=function(t,e){},e.prototype.getSubShapeStyle=function(t){return t.x,t.y,t.transform,t.transformOrigin,t.class,t.className,t.zIndex,o(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(Fs),Uj=function(t,e,n){return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"]]},$j=Uj,qj=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},Yj=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},Kj=Yj;var Xj=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function Zj(t){var e=function(t){var e="default";if(Lt(t)&&t instanceof Image)e="image";else if(Ot(t))e="symbol";else if(Vt(t)){var n=new RegExp("data:(image|text)");e=t.match(n)?"base64":/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(t)?"url":"symbol"}return e}(t);return["base64","url","image"].includes(e)?"image":t&&"symbol"===e?"path":null}var Qj=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.render=function(t,n){var r=t.x,a=void 0===r?0:r,s=t.y,u=void 0===s?0:s,c=this.getSubShapeStyle(t),l=c.symbol,h=c.size,d=void 0===h?16:h,f=o(c,["symbol","size"]),p=Zj(l);cj(!!p,Oj(n),(function(t){t.maybeAppendByClassName("marker",p).attr("className","marker ".concat(p,"-marker")).call((function(t){if("image"===p){var n=2*d;t.styles({img:l,width:n,height:n,x:a-d,y:u-d})}else{n=d/2;var r=Ot(l)?l:e.getSymbol(l);t.styles(i({d:null==r?void 0:r(a,u,n)},f))}}))}))},e.MARKER_SYMBOL_MAP=new Map,e.registerSymbol=function(t,n){e.MARKER_SYMBOL_MAP.set(t,n)},e.getSymbol=function(t){return e.MARKER_SYMBOL_MAP.get(t)},e.getSymbols=function(){return Array.from(e.MARKER_SYMBOL_MAP.keys())},e}(Hj);function Jj(t,...e){return e.reduce(((t,e)=>n=>t(e(n))),t)}function tB(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}Qj.registerSymbol("cross",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e+n],["M",t+n,e-n],["L",t-n,e+n]]})),Qj.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),Qj.registerSymbol("line",qj),Qj.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),Qj.registerSymbol("tick",(function(t,e,n){return[["M",t-n/2,e-n],["L",t+n/2,e-n],["M",t,e-n],["L",t,e+n],["M",t-n/2,e+n],["L",t+n/2,e+n]]})),Qj.registerSymbol("circle",Uj),Qj.registerSymbol("point",$j),Qj.registerSymbol("bowtie",(function(t,e,n){var r=n-1.5;return[["M",t-n,e-r],["L",t+n,e+r],["L",t+n,e-r],["L",t-n,e+r],["Z"]]})),Qj.registerSymbol("hexagon",(function(t,e,n){var r=n/2*Math.sqrt(3);return[["M",t,e-n],["L",t+r,e-n/2],["L",t+r,e+n/2],["L",t,e+n],["L",t-r,e+n/2],["L",t-r,e-n/2],["Z"]]})),Qj.registerSymbol("square",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]})),Qj.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),Qj.registerSymbol("triangle",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+r],["L",t,e-r],["L",t+n,e+r],["Z"]]})),Qj.registerSymbol("triangle-down",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-r],["L",t+n,e-r],["L",t,e+r],["Z"]]})),Qj.registerSymbol("line",qj),Qj.registerSymbol("dot",Yj),Qj.registerSymbol("dash",Kj),Qj.registerSymbol("smooth",(function(t,e,n){return[["M",t-n,e],["A",n/2,n/2,0,1,1,t,e],["A",n/2,n/2,0,1,0,t+n,e]]})),Qj.registerSymbol("hv",(function(t,e,n){return[["M",t-n-1,e-2.5],["L",t,e-2.5],["L",t,e+2.5],["L",t+n+1,e+2.5]]})),Qj.registerSymbol("vh",(function(t,e,n){return[["M",t-n-1,e+2.5],["L",t,e+2.5],["L",t,e-2.5],["L",t+n+1,e-2.5]]})),Qj.registerSymbol("hvh",(function(t,e,n){return[["M",t-(n+1),e+2.5],["L",t-n/2,e+2.5],["L",t-n/2,e-2.5],["L",t+n/2,e-2.5],["L",t+n/2,e+2.5],["L",t+n+1,e+2.5]]})),Qj.registerSymbol("vhv",(function(t,e){return[["M",t-5,e+2.5],["L",t-5,e],["L",t,e],["L",t,e-3],["L",t,e+3],["L",t+6.5,e+3]]}));const eB=Math.sqrt(50),nB=Math.sqrt(10),rB=Math.sqrt(2);function iB(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),o=r/10**i;return i>=0?(o>=eB?10:o>=nB?5:o>=rB?2:1)*10**i:-(10**-i)/(o>=eB?10:o>=nB?5:o>=rB?2:1)}const oB=(t,e,n=5)=>{const r=[t,e];let i,o=0,a=r.length-1,s=r[o],u=r[a];return u<s&&([s,u]=[u,s],[o,a]=[a,o]),i=iB(s,u,n),i>0?(s=Math.floor(s/i)*i,u=Math.ceil(u/i)*i,i=iB(s,u,n)):i<0&&(s=Math.ceil(s*i)/i,u=Math.floor(u*i)/i,i=iB(s,u,n)),i>0?(r[o]=Math.floor(s/i)*i,r[a]=Math.ceil(u/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[a]=Math.floor(u*i)/i),r};function aB(t){return!(ie(t)||(e=t,null===e)||Number.isNaN(t));var e}var sB={exports:{}},uB={exports:{}},cB=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},lB=Array.prototype.concat,hB=Array.prototype.slice,dB=uB.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];cB(i)?e=lB.call(e,hB.call(i)):e.push(i)}return e};dB.wrap=function(t){return function(){return t(dB(arguments))}};var fB=uB.exports,pB={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},gB=fB,mB=Object.hasOwnProperty,yB=Object.create(null);for(var vB in pB)mB.call(pB,vB)&&(yB[pB[vB]]=vB);var bB=sB.exports={to:{},get:{}};function xB(t,e,n){return Math.min(Math.max(e,t),n)}function wB(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}bB.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=bB.get.hsl(t),n="hsl";break;case"hwb":e=bB.get.hwb(t),n="hwb";break;default:e=bB.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},bB.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;i[n]=parseInt(e.slice(o,o+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:mB.call(pB,e[1])?((i=pB[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=xB(i[n],0,255);return i[3]=xB(i[3],0,1),i},bB.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,xB(parseFloat(e[2]),0,100),xB(parseFloat(e[3]),0,100),xB(isNaN(n)?1:n,0,1)]}return null},bB.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,xB(parseFloat(e[2]),0,100),xB(parseFloat(e[3]),0,100),xB(isNaN(n)?1:n,0,1)]}return null},bB.to.hex=function(){var t=gB(arguments);return"#"+wB(t[0])+wB(t[1])+wB(t[2])+(t[3]<1?wB(Math.round(255*t[3])):"")},bB.to.rgb=function(){var t=gB(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},bB.to.rgb.percent=function(){var t=gB(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},bB.to.hsl=function(){var t=gB(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},bB.to.hwb=function(){var t=gB(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},bB.to.keyword=function(t){return yB[t.slice(0,3)]};var EB=f(sB.exports);function MB(t,e,n){let r=n;return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function SB(t){const e=EB.get(t);if(!e)return null;const{model:n,value:r}=e;return"rgb"===n?r:"hsl"===n?function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100,i=t[3];if(0===n)return[255*r,255*r,255*r,i];const o=r<.5?r*(1+n):r+n-r*n,a=2*r-o;return[255*MB(a,o,e+1/3),255*MB(a,o,e),255*MB(a,o,e-1/3),i]}(r):null}const NB=(t,e)=>n=>t*(1-n)+e*n,kB=(t,e)=>"number"==typeof t&&"number"==typeof e?NB(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=SB(t),r=SB(e);return null===n||null===r?n?()=>t:()=>e:t=>{const e=new Array(4);for(let i=0;i<4;i+=1){const o=n[i],a=r[i];e[i]=o*(1-t)+a*t}const[i,o,a,s]=e;return`rgba(${Math.round(i)}, ${Math.round(o)}, ${Math.round(a)}, ${s})`}})(t,e):()=>t,CB=(t,e)=>{const n=NB(t,e);return t=>Math.round(n(t))};function TB({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function AB(t){return"object"==typeof t?t.valueOf():t}class PB extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=AB,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(TB({map:this.map,initKey:this.initKey},t))}has(t){return super.has(TB({map:this.map,initKey:this.initKey},t))}set(t,e){return super.set(function({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}({map:this.map,initKey:this.initKey},t),e)}delete(t){return super.delete(function({map:t,initKey:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}({map:this.map,initKey:this.initKey},t))}}class OB{constructor(t){this.options=ce({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=ce({},this.options,t),this.rescale(t)}rescale(t){}}const _B=Symbol("defaultUnknown");function RB(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function IB(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let a=i.get(e);if(void 0===a){if(o!==_B)return o;a=n.push(e)-1,i.set(e,a)}return r[a%r.length]}function DB(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class LB extends OB{getDefaultOptions(){return{domain:[],range:[],unknown:_B}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&RB(this.domainIndexMap,this.getDomain(),this.domainKey),IB({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&RB(this.rangeIndexMap,this.getRange(),this.rangeKey),IB({value:this.rangeKey(t),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(t){const[e]=this.options.domain,[n]=this.options.range;if(this.domainKey=DB(e),this.rangeKey=DB(n),!this.rangeIndexMap)return this.rangeIndexMap=new Map,void(this.domainIndexMap=new Map);t&&!t.range||this.rangeIndexMap.clear(),(!t||t.domain||t.compare)&&(this.domainIndexMap.clear(),this.sortedDomain=void 0)}clone(){return new LB(this.options)}getRange(){return this.options.range}getDomain(){if(this.sortedDomain)return this.sortedDomain;const{domain:t,compare:e}=this.options;return this.sortedDomain=e?[...t].sort(e):t,this.sortedDomain}}function jB(t){return Math.round(1e12*t)/1e12}function BB(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:a,align:s}=t,u=e.length,c=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,u),[l,h]=n,d=h-l,f=d/(2/u*r+1-1/u*i),p=f*i/u,g=f-u*p,m=function(t){const e=Math.min(...t);return t.map((t=>t/e))}(c),y=g/m.reduce(((t,e)=>t+e)),v=new PB(e.map(((t,e)=>{const n=m[e]*y;return[t,a?Math.floor(n):n]}))),b=new PB(e.map(((t,e)=>{const n=m[e]*y+p;return[t,a?Math.floor(n):n]}))),x=Array.from(b.values()).reduce(((t,e)=>t+e)),w=l+(d-(x-x/u*i))*s;let E=a?Math.round(w):w;const M=new Array(u);for(let t=0;t<u;t+=1){M[t]=jB(E);const n=e[t];E+=b.get(n)}return{valueBandWidth:v,valueStep:b,adjustedRange:M}}class zB extends LB{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:_B,flex:[]}}constructor(t){super(t)}clone(){return new zB(this.options)}getStep(t){return void 0===this.valueStep?1:"number"==typeof this.valueStep?this.valueStep:void 0===t?Array.from(this.valueStep.values())[0]:this.valueStep.get(t)}getBandWidth(t){return void 0===this.valueBandWidth?1:"number"==typeof this.valueBandWidth?this.valueBandWidth:void 0===t?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(t)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:t,paddingInner:e}=this.options;return t>0?t:e}getPaddingOuter(){const{padding:t,paddingOuter:e}=this.options;return t>0?t:e}rescale(){super.rescale();const{align:t,domain:e,range:n,round:r,flex:i}=this.options,{adjustedRange:o,valueBandWidth:a,valueStep:s}=function(t){var e;const{domain:n}=t,r=n.length;if(0===r)return{valueBandWidth:void 0,valueStep:void 0,adjustedRange:[]};if(null===(e=t.flex)||void 0===e?void 0:e.length)return BB(t);const{range:i,paddingOuter:o,paddingInner:a,round:s,align:u}=t;let c,l,h=i[0];const d=i[1]-h,f=2*o,p=r-a;c=d/Math.max(1,f+p),s&&(c=Math.floor(c)),h+=(d-c*(r-a))*u,l=c*(1-a),s&&(h=Math.round(h),l=Math.round(l));const g=new Array(r).fill(0).map(((t,e)=>h+e*c));return{valueStep:c,valueBandWidth:l,adjustedRange:g}}({align:t,range:n,round:r,flex:i,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:e});this.valueStep=s,this.valueBandWidth=a,this.adjustedRange=o}}const FB=(t,e,n)=>{let r,i,o=t,a=e;if(o===a&&n>0)return[o];let s=iB(o,a,n);if(0===s||!Number.isFinite(s))return[];if(s>0){o=Math.ceil(o/s),a=Math.floor(a/s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)*s}else{s=-s,o=Math.ceil(o*s),a=Math.floor(a*s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)/s}return i},GB=(t,e,n)=>{const[r,i]=t,[o,a]=e;let s,u;return r<i?(s=tB(r,i),u=n(o,a)):(s=tB(i,r),u=n(a,o)),Jj(u,s)},VB=(t,e,n)=>{const r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),a=t[0]>t[r],s=a?[...t].reverse():t,u=a?[...e].reverse():e;for(let t=0;t<r;t+=1)i[t]=tB(s[t],s[t+1]),o[t]=n(u[t],u[t+1]);return e=>{const n=function(t,e,n,r,i){let o=n||0,a=r||t.length;for(;o<a;){const n=Math.floor((o+a)/2);t[n]>e?a=n:o=n+1}return o}(t,e,1,r)-1,a=i[n];return Jj(o[n],a)(e)}},WB=(t,e,n,r)=>(Math.min(t.length,e.length)>2?VB:GB)(t,e,r?CB:n);class HB extends OB{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:NB,tickCount:5}}map(t){return aB(t)?this.output(t):this.options.unknown}invert(t){return aB(t)?this.input(t):this.options.unknown}nice(){if(!this.options.nice)return;const[t,e,n,...r]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(t,e,n,...r)}getTicks(){const{tickMethod:t}=this.options,[e,n,r,...i]=this.getTickMethodOptions();return t(e,n,r,...i)}getTickMethodOptions(){const{domain:t,tickCount:e}=this.options;return[t[0],t[t.length-1],e]}chooseNice(){return oB}rescale(){this.nice();const[t,e]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t)),this.composeInput(t,e,this.chooseClamp(e))}chooseClamp(t){const{clamp:e,range:n}=this.options,r=this.options.domain.map(t),i=Math.min(r.length,n.length);return e?function(t,e){const n=e<t?e:t,r=t>e?t:e;return t=>Math.min(Math.max(n,t),r)}(r[0],r[i-1]):xe}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,a=WB(n.map(t),r,o,i);this.output=Jj(a,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=WB(i,r.map(t),NB);this.input=Jj(e,n,o)}}class UB extends HB{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:kB,tickMethod:FB,tickCount:5}}chooseTransforms(){return[xe,xe]}clone(){return new UB(this.options)}}var $B=function(t){function e(e){var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,ce({},{type:"column"},i({style:r},a)))||this).columnsGroup=new Vs({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return r(e,t),e.prototype.render=function(){var t=this.attributes,e=t.columns,n=t.x,r=t.y;this.columnsGroup.style.transform="translate(".concat(n,", ").concat(r,")"),Oj(this.columnsGroup).selectAll(".column").data(e.flat()).join((function(t){return t.append("rect").attr("className","column").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.attr(t)}))}),(function(t){return t.remove()}))},e.prototype.update=function(t){this.attr(tj({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(Bs),qB=function(t){function e(e){var n=this,r=e.style,a=o(e,["style"]);return(n=t.call(this,ce({},{type:"lines"},i({style:r},a)))||this).linesGroup=n.appendChild(new Vs),n.areasGroup=n.appendChild(new Vs),n.render(),n}return r(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas,r=t.x,i=t.y;this.style.transform="translate(".concat(r,", ").concat(i,")"),e&&this.renderLines(e),n&&this.renderAreas(n)},e.prototype.clear=function(){this.linesGroup.removeChildren(),this.areasGroup.removeChildren()},e.prototype.update=function(t){this.attr(tj({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){Oj(this.linesGroup).selectAll(".line").data(t).join((function(t){return t.append("path").attr("className","line").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.attr(t)}))}),(function(t){return t.remove()}))},e.prototype.renderAreas=function(t){Oj(this.linesGroup).selectAll(".area").data(t).join((function(t){return t.append("path").attr("className","area").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.style(t)}))}),(function(t){return t.remove()}))},e}(Bs);function YB(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map((function(t,e){return l([e===n?"M":"L"],c(t),!1)}));return e?r.reverse():r}function KB(t,e){if(void 0===e&&(e=!1),t.length<=2)return YB(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];de(o,n.slice(-2))||n.push.apply(n,l([],c(o),!1))}var a=Nj(n,!1);return e?a.unshift(l(["M"],c(t[r-1]),!1)):a.unshift(l(["M"],c(t[0]),!1)),a}function XB(t,e,n){var r=oe(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function ZB(t){return 0===t.length?[0,0]:[Gt(Xt(t,(function(t){return Gt(t)||0}))),Ft(Kt(t,(function(t){return Ft(t)||0})))]}function QB(t){for(var e=oe(t),n=e[0].length,r=c([Array(n).fill(0),Array(n).fill(0)],2),i=r[0],o=r[1],a=0;a<e.length;a+=1)for(var s=e[a],u=0;u<n;u+=1)s[u]>=0?(s[u]+=i[u],i[u]=s[u]):(s[u]+=o[u],o[u]=s[u]);return e}var JB=function(t){function e(e){return t.call(this,e,{type:"line",x:0,y:0,width:200,height:20,isStack:!1,color:["#83daad","#edbf45","#d2cef9","#e290b3","#6f63f4"],smooth:!0,lineLineWidth:1,areaOpacity:0,isGroup:!1,columnLineWidth:1,columnStroke:"#fff",scale:1,spacing:0})||this}return r(e,t),Object.defineProperty(e.prototype,"rawData",{get:function(){var t=this.attributes.data;if(!t||0===(null==t?void 0:t.length))return[[]];var e=oe(t);return $t(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?QB(this.rawData):this.rawData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scales",{get:function(){return this.createScales(this.data)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseline",{get:function(){var t=this.scales.y,e=c(t.getOptions().domain||[0,0],2),n=e[0],r=e[1];return r<0?t.map(r):t.map(n<0?0:n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"containerShape",{get:function(){var t=this.attributes;return{width:t.width,height:t.height}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesStyle",{get:function(){var t=this,e=this.attributes,n=e.type,r=e.isStack,o=e.smooth;if("line"!==n)throw new Error("linesStyle can only be used in line type");var a=Bj(this.attributes,"area"),s=Bj(this.attributes,"line"),u=this.containerShape.width,h=this.data;if(0===h[0].length)return{lines:[],areas:[]};var d=this.scales,f=function(t,e){var n,r=e.x,i=e.y,o=c(i.getOptions().range||[0,0],2),a=o[0],s=o[1];return s>a&&(n=c([a,s],2),s=n[0],a=n[1]),t.map((function(t){return t.map((function(t,e){return[r.map(e),Ut(i.map(t),s,a)]}))}))}(h,{type:"line",x:d.x,y:d.y}),p=[];if(a){var g=this.baseline;p=r?o?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],a=KB(o),s=void 0;if(0===i)s=XB(a,e,n);else{var u=KB(t[i-1],!0),h=o[0];u[0][0]="L",s=l(l(l([],c(a),!1),c(u),!1),[l(["M"],c(h),!1),["Z"]],!1)}r.push(s)}return r}(f,u,g):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=YB(t[i]),a=void 0;if(0===i)a=XB(o,e,n);else{var s=YB(t[i-1],!0);s[0][0]="L",a=l(l(l([],c(o),!1),c(s),!1),[["Z"]],!1)}r.push(a)}return r}(f,u,g):function(t,e,n,r){return t.map((function(t){return XB(e?KB(t):YB(t),n,r)}))}(f,o,u,g)}return{lines:f.map((function(e,n){return i({stroke:t.getColor(n),d:o?KB(e):YB(e)},s)})),areas:p.map((function(e,n){return i({d:e,fill:t.getColor(n)},a)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=Bj(this.attributes,"column"),n=this.attributes,r=n.isStack,o=n.type,a=n.scale;if("column"!==o)throw new Error("columnsStyle can only be used in column type");var s=this.containerShape.height,u=this.rawData;if(!u)return{columns:[]};r&&(u=QB(u));var l=this.createScales(u),h=l.x,d=l.y,f=c(ZB(u),2),p=f[0],g=f[1],m=new UB({domain:[0,g-(p>0?0:p)],range:[0,s*a]}),y=h.getBandWidth(),v=this.rawData;return{columns:u.map((function(n,o){return n.map((function(n,a){var s=y/u.length;return i(i({fill:t.getColor(o)},e),r?{x:h.map(a),y:d.map(n),width:y,height:m.map(v[o][a])}:{x:h.map(a)+s*o,y:n>=0?d.map(n):d.map(0),width:s,height:m.map(Math.abs(n))})}))}))}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,o;(n=e,r=".container",o="rect",n.querySelector(r)?Oj(n).select(r):Oj(n).append(o)).attr("className","container").node();var a=t.type,s=t.x,u=t.y,c="spark".concat(a),l=i({x:s,y:u},"line"===a?this.linesStyle:this.columnsStyle);Oj(e).selectAll(".spark").data([a]).join((function(t){return t.append((function(t){return"line"===t?new qB({className:c,style:l}):new $B({className:c,style:l})})).attr("className","spark ".concat(c))}),(function(t){return t.update(l)}),(function(t){return t.remove()}))},e.prototype.getColor=function(t){var e=this.attributes.color;return Dt(e)?e[t%e.length]:Ot(e)?e.call(null,t):e},e.prototype.createScales=function(t){var e,n,r=this.attributes,i=r.type,o=r.scale,a=r.range,s=void 0===a?[]:a,u=r.spacing,l=this.containerShape,h=l.width,d=l.height,f=c(ZB(t),2),p=f[0],g=f[1],m=new UB({domain:[null!==(e=s[0])&&void 0!==e?e:p,null!==(n=s[1])&&void 0!==n?n:g],range:[d,d*(1-o)]});return"line"===i?{type:i,x:new UB({domain:[0,t[0].length-1],range:[0,h]}),y:m}:{type:i,x:new zB({domain:t[0].map((function(t,e){return e})),range:[0,h],paddingInner:u,paddingOuter:u/2,align:.5}),y:m}},e.tag="sparkline",e}(Hj);function tz(t){if(!t)return{enter:!1,update:!1,exit:!1};var e=["enter","update","exit"],n=Object.fromEntries(Object.entries(t).filter((function(t){var n=c(t,1)[0];return!e.includes(n)})));return Object.fromEntries(e.map((function(e){return function(t){return"boolean"!=typeof t&&"enter"in t&&"update"in t&&"exit"in t}(t)?!1===t[e]?[e,!1]:[e,i(i({},t[e]),n)]:[e,n]})))}function ez(t,e){t?t.finished.then(e):e()}function nz(t,e){"update"in t?t.update(e):t.attr(e)}function rz(t,e,n){return 0===e.length?null:n?t.animate(e,n):(nz(t,{style:e.slice(-1)[0]}),null)}function iz(t,e,n){var r={},o={};return Object.entries(e).forEach((function(e){var n=c(e,2),i=n[0],a=n[1];if(!_t(a)){var s=t.style[i]||t.parsedStyle[i]||0;s!==a&&(r[i]=s,o[i]=a)}})),n?rz(t,[r,o],i({fill:"both"},n)):(nz(t,o),null)}function oz(t,e){return t.style.opacity||(t.style.opacity=1),iz(t,{opacity:0},e)}var az={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},sz={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},uz={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},cz=QL({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),lz=QL({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),hz=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.render=function(t,e){var n=t.x,r=t.y,a=t.size,s=void 0===a?10:a,u=t.radius,c=void 0===u?s/4:u,l=t.orientation,h=o(t,["x","y","size","radius","orientation"]),d=s,f=2.4*d,p=Oj(e).maybeAppendByClassName(lz.iconRect,"rect").styles(i(i({},h),{width:d,height:f,radius:c,x:n-d/2,y:r-f/2,transformOrigin:"center"})),g=n+1/3*d-d/2,m=n+2/3*d-d/2,y=r+1/4*f-f/2,v=r+3/4*f-f/2;p.maybeAppendByClassName("".concat(lz.iconLine,"-1"),"line").styles(i({x1:g,x2:g,y1:y,y2:v},h)),p.maybeAppendByClassName("".concat(lz.iconLine,"-2"),"line").styles(i({x1:m,x2:m,y1:y,y2:v},h)),"vertical"===l&&(p.node().style.transform="rotate(90)")},e}(Hj),dz=function(t){function e(e){return t.call(this,e,uz)||this}return r(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,a=n.y,s=n.showLabel,u=Bj(this.attributes,"label"),l=u.x,h=void 0===l?0:l,d=u.y,f=void 0===d?0:d,p=u.transform,g=u.transformOrigin,m=c(Fj(o(u,["x","y","transform","transformOrigin"]),[]),2),y=m[0],v=m[1],b=Oj(t).maybeAppendByClassName(lz.labelGroup,"g").styles(v),x=i(i({},sz),y),w=x.text,E=o(x,["text"]);cj(!!s,b,(function(t){e.label=t.maybeAppendByClassName(lz.label,"text").styles(i(i({},E),{x:r+h,y:a+f,transform:p,transformOrigin:g,text:"".concat(w)})),e.label.on("mousedown",(function(t){t.stopPropagation()})),e.label.on("touchstart",(function(t){t.stopPropagation()}))}))},e.prototype.renderIcon=function(t){var e=this.attributes,n=e.x,r=e.y,o=e.orientation,a=e.type,s=i(i({x:n,y:r,orientation:o},az),Bj(this.attributes,"icon")),u=this.attributes.iconShape,c=void 0===u?function(){return new hz({style:s})}:u;Oj(t).maybeAppendByClassName(lz.iconGroup,"g").selectAll(lz.icon.class).data([c]).join((function(t){return t.append("string"==typeof c?c:function(){return c(a)}).attr("className",lz.icon.name)}),(function(t){return t.update(s)}),(function(t){return t.remove()}))},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(Hj),fz=function(t){function e(e){var n=t.call(this,e,i(i(i({x:0,y:0,animate:{duration:100,fill:"both"},brushable:!0,formatter:function(t){return t.toString()},handleSpacing:2,orientation:"horizontal",padding:0,autoFitLabel:!0,scrollable:!0,selectionFill:"#5B8FF9",selectionFillOpacity:.45,selectionZIndex:2,showHandle:!0,showLabel:!0,slidable:!0,trackFill:"#416180",trackLength:200,trackOpacity:.05,trackSize:20,trackZIndex:-1,values:[0,1],type:"range",selectionType:"select",handleIconOffset:0},zj(uz,"handle")),zj(az,"handleIcon")),zj(sz,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(sj(e));var r=n.availableSpace,i=r.x,o=r.y,a=n.getBBox(),s=a.x,u=a.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+u])),n.selectionWidth=0,document.addEventListener("pointermove",n.onDragging),document.addEventListener("pointerup",n.onDragEnd)}},n.onDragging=function(t){var e=n.attributes,r=e.slidable,i=e.brushable,o=e.type;t.stopPropagation();var a=n.getOrientVal(sj(t)),s=a-n.prevPos;if(s){var u=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(u);break;case"end":r&&n.setValuesOffset(0,u);break;case"selection":r&&n.setValuesOffset(u,u);break;case"track":if(!i)return;n.selectionWidth+=u,"range"===o?n.innerSetValues([n.selectionStartPos,n.selectionStartPos+n.selectionWidth].sort(),!0):n.innerSetValues([0,n.selectionStartPos+n.selectionWidth],!0)}n.prevPos=a}},n.onDragEnd=function(){document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointerup",n.onDragEnd),n.target="",n.updateHandlesPosition(!1)},n.onValueChange=function(t){var e=n.attributes,r=e.onChange,i=e.type,o="range"===i?t:t[1],a="range"===i?n.getValues():n.getValues()[1],s=new es("valuechange",{detail:{oldValue:o,value:a}});n.dispatchEvent(s),null==r||r(a)},n.selectionStartPos=0,n.selectionWidth=0,n.prevPos=0,n.target="",n}return r(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.attributes.values},set:function(t){this.attributes.values=this.clampValues(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sparklineStyle",{get:function(){if("horizontal"!==this.attributes.orientation)return null;var t=Bj(this.attributes,"sparkline");return i(i({zIndex:0},this.availableSpace),t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t=this.attributes,e=t.trackLength,n=t.trackSize,r=c(this.getOrientVal([[e,n],[n,e]]),2);return{width:r[0],height:r[1]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes;t.x,t.y;var e=c(_j(t.padding),4),n=e[0],r=e[1],i=e[2],o=e[3],a=this.shape;return{x:o,y:n,width:a.width-(o+r),height:a.height-(n+i)}},enumerable:!1,configurable:!0}),e.prototype.getValues=function(){return this.values},e.prototype.setValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1),this.attributes.values=t;var n=!1!==e&&this.attributes.animate;this.updateSelectionArea(n),this.updateHandlesPosition(n)},e.prototype.updateSelectionArea=function(t){var e=this.calcSelectionArea();this.foregroundGroup.selectAll(cz.selection.class).each((function(n,r){iz(this,e[r],t)}))},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&iz(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&iz(this.endHandle,this.getHandleStyle("end"),t))},e.prototype.innerSetValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1);var n=this.values,r=this.clampValues(t);this.attributes.values=r,this.setValues(r),e&&this.onValueChange(n)},e.prototype.renderTrack=function(t){var e=this.attributes,n=e.x,r=e.y,o=Bj(this.attributes,"track");this.trackShape=Oj(t).maybeAppendByClassName(cz.track,"rect").styles(i(i({x:n,y:r},this.shape),o))},e.prototype.renderBrushArea=function(t){var e=this.attributes,n=e.x,r=e.y,o=e.brushable;this.brushArea=Oj(t).maybeAppendByClassName(cz.brushArea,"rect").styles(i({x:n,y:r,fill:"transparent",cursor:o?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this,n=this.attributes,r=n.x,o=n.y;cj("horizontal"===n.orientation,Oj(t).maybeAppendByClassName(cz.sparklineGroup,"g"),(function(t){var n=i(i({},e.sparklineStyle),{x:r,y:o});t.maybeAppendByClassName(cz.sparkline,(function(){return new JB({style:n})})).update(n)}))},e.prototype.renderHandles=function(){var t,e=this,n=this.attributes,r=n.showHandle,i=n.type,o=r?"range"===i?["start","end"]:["end"]:[],a=this;null===(t=this.foregroundGroup)||void 0===t||t.selectAll(cz.handle.class).data(o.map((function(t){return{type:t}})),(function(t){return t.type})).join((function(t){return t.append((function(t){var n=t.type;return new dz({style:e.getHandleStyle(n)})})).each((function(t){var e=t.type;this.attr("class","".concat(cz.handle.name," ").concat(e,"-handle"));var n="".concat(e,"Handle");a[n]=this,this.addEventListener("pointerdown",a.onDragStart(e))}))}),(function(t){return t.each((function(t){var e=t.type;this.update(a.getHandleStyle(e))}))}),(function(t){return t.each((function(t){var e=t.type,n="".concat(e,"Handle");a[n]=void 0})).remove()}))},e.prototype.renderSelection=function(t){var e=this.attributes,n=e.x,r=e.y,o=e.type,a=e.selectionType;this.foregroundGroup=Oj(t).maybeAppendByClassName(cz.foreground,"g");var s=Bj(this.attributes,"selection"),u=function(t){return t.style("visibility",(function(t){return t.show?"visible":"hidden"})).style("cursor",(function(t){return"select"===a?"grab":"invert"===a?"crosshair":"default"})).styles(i(i({},s),{transform:"translate(".concat(n,", ").concat(r,")")}))},c=this;this.foregroundGroup.selectAll(cz.selection.class).data("value"===o?[]:this.calcSelectionArea().map((function(t,e){return{style:i({},t),index:e,show:"select"===a?1===e:1!==e}})),(function(t){return t.index})).join((function(t){return t.append("rect").attr("className",cz.selection.name).call(u).each((function(t,e){var n=this;1===e?(c.selectionShape=Oj(this),this.on("pointerdown",(function(t){n.attr("cursor","grabbing"),c.onDragStart("selection")(t)})),c.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),c.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),c.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",(function(){n.attr("cursor","grabbing")})),this.addEventListener("pointerup",(function(){n.attr("cursor","pointer")})),this.addEventListener("pointerover",(function(){n.attr("cursor","pointer")}))):this.on("pointerdown",c.onDragStart("track"))}))}),(function(t){return t.call(u)}),(function(t){return t.remove()})),this.updateSelectionArea(!1),this.renderHandles()},e.prototype.render=function(t,e){this.renderTrack(e),this.renderSparkline(e),this.renderBrushArea(e),this.renderSelection(e)},e.prototype.clampValues=function(t,e){var n;void 0===e&&(e=4);var r=c(this.range,2),i=r[0],o=r[1],a=c(this.getValues().map((function(t){return Mj(t,e)})),2),s=a[0],u=a[1],l=c(((Array.isArray(t)?t:[s,null!=t?t:u])||[s,u]).map((function(t){return Mj(t,e)})),2),h=l[0],d=l[1];if("value"===this.attributes.type)return[0,Ut(d,i,o)];h>d&&(h=(n=c([d,h],2))[0],d=n[1]);var f=d-h;return f>o-i?[i,o]:h<i?s===i&&u===d?[i,d]:[i,f+i]:d>o?u===o&&s===h?[h,o]:[o-f,o]:[h,d]},e.prototype.calcSelectionArea=function(t){var e=c(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,a=i.y,s=i.width,u=i.height;return this.getOrientVal([[{y:a,height:u,x:o,width:n*s},{y:a,height:u,x:n*s+o,width:(r-n)*s},{y:a,height:u,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:a,height:n*u},{x:o,width:s,y:n*u+a,height:(r-n)*u},{x:o,width:s,y:r*u,height:(1-r)*u}]])},e.prototype.calcHandlePosition=function(t){var e=this.attributes.handleIconOffset,n=this.availableSpace,r=n.x,i=n.y,o=n.width,a=n.height,s=c(this.clampValues(),2),u=s[0],l=s[1],h="start"===t?-e:e,d=("start"===t?u:l)*this.getOrientVal([o,a])+h;return{x:r+this.getOrientVal([d,o/2]),y:i+this.getOrientVal([a/2,d])}},e.prototype.inferTextStyle=function(t){return"horizontal"===this.attributes.orientation?{}:"start"===t?{transformOrigin:"left center",transform:"rotate(90)",textAlign:"start"}:"end"===t?{transformOrigin:"right center",transform:"rotate(90)",textAlign:"end"}:{}},e.prototype.calcHandleText=function(t){var e,n=this.attributes,r=n.type,o=n.orientation,a=n.formatter,s=n.autoFitLabel,u=Bj(this.attributes,"handle"),c=Bj(u,"label"),l=u.spacing,h=this.getHandleSize(),d=this.clampValues(),f=a("start"===t?d[0]:d[1]),p=new $L({style:i(i(i({},c),this.inferTextStyle(t)),{text:f})}),g=p.getBBox(),m=g.width,y=g.height;if(p.destroy(),!s){if("value"===r)return{text:f,x:0,y:-y-l};var v=l+h+("horizontal"===o?m/2:0);return(e={text:f})["horizontal"===o?"x":"y"]="start"===t?-v:v,e}var b=0,x=0,w=this.availableSpace,E=w.width,M=w.height,S=this.calcSelectionArea()[1],N=S.x,k=S.y,C=S.width,T=S.height,A=l+h;if("horizontal"===o){var P=A+m/2;if("start"===t)b=N-A-m>0?-P:P;else b=E-N-C-A>m?P:-P}else{var O=y+A;x="start"===t?k-h>y?-O:A:M-(k+T)-h>y?O:-A}return{x:b,y:x,text:f}},e.prototype.getHandleLabelStyle=function(t){var e=Bj(this.attributes,"handleLabel");return i(i(i({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=Bj(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return i({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.x,r=e.y,o=e.showLabel,a=e.showLabelOnInteraction,s=e.orientation,u=this.calcHandlePosition(t),c=u.x,l=u.y,h=this.calcHandleText(t),d=o;return!o&&a&&(d=!!this.target),i(i(i({},zj(this.getHandleIconStyle(),"icon")),zj(i(i({},this.getHandleLabelStyle(t)),h),"label")),{transform:"translate(".concat(c+n,", ").concat(l+r,")"),orientation:s,showLabel:d,type:t,zIndex:3})},e.prototype.getHandleSize=function(){var t=this.attributes,e=t.handleIconSize,n=t.width,r=t.height;return e||Math.floor((this.getOrientVal([+r,+n])+4)/2.4)},e.prototype.getOrientVal=function(t){var e=c(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=!1);var r=this.attributes.type,i=c(this.getValues(),2),o=[i[0]+("range"===r?t:0),i[1]+e].sort();n?this.setValues(o):this.innerSetValues(o,!0)},e.prototype.getRatio=function(t){var e=this.availableSpace,n=e.width,r=e.height;return t/this.getOrientVal([n,r])},e.prototype.dispatchCustomEvent=function(t,e,n){var r=this;t.on(e,(function(t){t.stopPropagation(),r.dispatchEvent(new es(n,{detail:t}))}))},e.prototype.bindEvents=function(){this.addEventListener("wheel",this.onScroll);var t=this.brushArea;this.dispatchCustomEvent(t,"click","trackClick"),this.dispatchCustomEvent(t,"pointerenter","trackMouseenter"),this.dispatchCustomEvent(t,"pointerleave","trackMouseleave"),t.on("pointerdown",this.onDragStart("track"))},e.prototype.onScroll=function(t){if(this.attributes.scrollable){var e=t.deltaX,n=t.deltaY||e,r=this.getRatio(n);this.setValuesOffset(r,r,!0)}},e.tag="slider",e}(Hj),pz={data:[],animate:{enter:!1,update:{duration:100,easing:"ease-in-out-sine",fill:"both"},exit:{duration:100,fill:"both"}},showArrow:!0,showGrid:!0,showLabel:!0,showLine:!0,showTick:!0,showTitle:!0,showTrunc:!1,dataThreshold:100,lineLineWidth:1,lineStroke:"black",crossPadding:10,titleFill:"black",titleFontSize:12,titlePosition:"lb",titleSpacing:0,titleTextAlign:"center",titleTextBaseline:"middle",lineArrow:function(){return new $s({style:{d:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],fill:"black",transformOrigin:"center"}})},labelAlign:"parallel",labelDirection:"positive",labelFontSize:12,labelSpacing:0,gridConnect:"line",gridControlAngles:[],gridDirection:"positive",gridLength:0,gridType:"segment",lineArrowOffset:15,lineArrowSize:10,tickDirection:"positive",tickLength:5,tickLineWidth:1,tickStroke:"black",labelOverlap:[]};ce({},pz,{style:{type:"arc"}}),ce({},pz,{style:{}});var gz=QL({mainGroup:"main-group",gridGroup:"grid-group",grid:"grid",lineGroup:"line-group",line:"line",tickGroup:"tick-group",tick:"tick",tickItem:"tick-item",labelGroup:"label-group",label:"label",labelItem:"label-item",titleGroup:"title-group",title:"title",lineFirst:"line-first",lineSecond:"line-second"},"axis"),mz=QL({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function yz(t){return t.reduce((function(t,e,n){return t.push(l([0===n?"M":"L"],c(e),!1)),t}),[])}function vz(t,e,n){return"surround"===e.type?function(t,e,n){var r=e.connect,i=void 0===r?"line":r,o=e.center;if("line"===i)return yz(t);if(!o)return[];var a=wj(t[0],o),s=n?0:1;return t.reduce((function(t,e,n){return 0===n?t.push(l(["M"],c(e),!1)):t.push(l(["A",a,a,0,0,s],c(e),!1)),t}),[])}(t,e,n):yz(t)}function bz(t,e,n){var r=n.type,i=n.connect,o=n.center,a=n.closed?[["Z"]]:[],s=c([vz(t,n),vz(e.slice().reverse(),n,!0)],2),u=s[0],h=s[1],d=c([t[0],e.slice(-1)[0]],2),f=d[0],p=d[1],g=function(t,e){return[u,t,h,e,a].flat()};if("line"===i||"surround"===r)return g([l(["L"],c(p),!1)],[l(["L"],c(f),!1)]);if(!o)throw new Error("Arc grid need to specified center");var m=c([wj(p,o),wj(f,o)],2),y=m[0],v=m[1];return g([l(["A",y,y,0,0,1],c(p),!1),l(["L"],c(p),!1)],[l(["A",v,v,0,0,0],c(f),!1),l(["L"],c(f),!1)])}var xz=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=o(t,["type","center","areaFill","closed"]),r=function(t){var e=t.data,n=void 0===e?[]:e;return t.closed?n.map((function(t){var e=t.points,n=c(e,1)[0];return i(i({},t),{points:l(l([],c(e),!1),[n],!1)})})):n}(t),a=Oj(e).maybeAppendByClassName(mz.lineGroup,"g"),s=Oj(e).maybeAppendByClassName(mz.regionGroup,"g"),u=function(t,e,n,r){var o=n.animate,a=n.isBillboard,s=e.map((function(t,e){return{id:t.id||"grid-line-".concat(e),d:vz(t.points,n)}}));return t.selectAll(mz.line.class).data(s,(function(t){return t.id})).join((function(t){return t.append("path").each((function(t,e){var n=XL(Tj(i({d:t.d},r)),[t,e,s]);this.attr(i({class:mz.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:a},n))}))}),(function(t){return t.transition((function(t,e){return iz(this,XL(Tj(i({d:t.d},r)),[t,e,s]),o.update)}))}),(function(t){return t.transition((function(){var t=this,e=oz(this,o.exit);return ez(e,(function(){return t.remove()})),e}))})).transitions()}(a,r,t,n),h=function(t,e,n){var r=n.animate,i=n.connect,o=n.areaFill;if(e.length<2||!o||!i)return[];for(var a=Array.isArray(o)?o:[o,"transparent"],s=function(t){return a[t%a.length]},u=[],l=0;l<e.length-1;l++){var h=c([e[l].points,e[l+1].points],2),d=bz(h[0],h[1],n);u.push({d:d,fill:s(l)})}return t.selectAll(mz.region.class).data(u,(function(t,e){return e})).join((function(t){return t.append("path").each((function(t,e){var n=XL(t,[t,e,u]);this.attr(n)})).attr("className",mz.region.name)}),(function(t){return t.transition((function(t,e){return iz(this,XL(t,[t,e,u]),r.update)}))}),(function(t){return t.transition((function(){var t=this,e=oz(this,r.exit);return ez(e,(function(){return t.remove()})),e}))})).transitions()}(s,r,t);return l(l([],c(u),!1),c(h),!1)},e}(Hj);function wz(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var n=c(t,2);return[n[0],XL(n[1],e)]})))}function Ez(t,e){return e&&Ot(e)?t.filter(e):t}function Mz(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}function Sz(t,e){if("linear"===e.type){var n=c(e.startPos,2),r=n[0],i=n[1],o=c(e.endPos,2),a=c([o[0]-r,o[1]-i],2);return Ej([a[0],a[1]])}var s=qL(Mz(t,e));return[-Math.sin(s),Math.cos(s)]}function Nz(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(Sz(t,n),"positive"!==e)}function kz(t,e){return Nz(t,e.labelDirection,e)}function Cz(t,e){return"linear"===e.type?function(t,e){var n=c(e.startPos,2),r=n[0],i=n[1],o=c(e.endPos,2),a=c([o[0]-r,o[1]-i],2);return[r+a[0]*t,i+a[1]*t]}(t,e):function(t,e){var n=e.radius,r=c(e.center,2),i=r[0],o=r[1],a=qL(Mz(t,e));return[i+n*Math.cos(a),o+n*Math.sin(a)]}(t,e)}function Tz(t){return 0===Sz(0,t)[1]}function Az(t){return 0===Sz(0,t)[0]}function Pz(t,e){return e-t==360}function Oz(t,e,n,r,i){var o=e-t,a=c([i,i],2),s=a[0],u=a[1],l=c([qL(t),qL(e)],2),h=l[0],d=l[1],f=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},p=c(f(h),2),g=p[0],m=p[1],y=c(f(d),2),v=y[0],b=y[1];if(Pz(t,e)){var x=c(f((d+h)/2),2);return[["M",g,m],["A",s,u,0,1,0,x[0],x[1]],["A",s,u,0,1,0,v,b]]}var w=o>180?1:0,E=t>e?0:1;return"M".concat(g,",").concat(m,",A").concat(s,",").concat(u,",0,").concat(w,",").concat(E,",").concat(v,",").concat(b)}function _z(t,e,n,r){var o=e.startAngle,a=e.endAngle,s=e.center,u=e.radius;return t.selectAll(gz.line.class).data([{d:Oz.apply(void 0,l(l([o,a],c(s),!1),[u],!1))}],(function(t,e){return e})).join((function(t){return t.append("path").attr("className",gz.line.name).styles(e).styles({d:function(t){return t.d}})}),(function(t){return t.transition((function(){var t=this,e=function(t,e,n,r){if(!r)return t.attr("__keyframe_data__",n),null;var o=r.duration,a=void 0===o?0:o,s=dj(e,n),u=Math.ceil(+a/16),c=new Array(u).fill(0).map((function(t,e,n){return{__keyframe_data__:s(e/(n.length-1))}}));return t.animate(c,i({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return l(l([n,r],c(i),!1),[o],!1)}(this),l(l([o,a],c(s),!1),[u],!1),r.update);if(e){var n=function(){var e=fe(t.attributes,"__keyframe_data__");t.style.d=Oz.apply(void 0,l([],c(e),!1))};e.onframe=n,e.onfinish=n}return e})).styles(e)}),(function(t){return t.remove()})).styles(n).transitions()}function Rz(t){var e=c(t,2),n=c(e[0],2),r=n[0],i=n[1],o=c(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function Iz(t,e,n,r){var i=e.showTrunc,o=e.startPos,a=e.endPos,s=e.truncRange,u=e.lineExtension,l=c([o,a],2),h=c(l[0],2),d=h[0],f=h[1],p=c(l[1],2),g=p[0],m=p[1],y=c(u?function(t,e,n){void 0===n&&(n=[0,0]);var r=c([t,e,n],3),i=c(r[0],2),o=i[0],a=i[1],s=c(r[1],2),u=s[0],l=s[1],h=c(r[2],2),d=h[0],f=h[1],p=c([u-o,l-a],2),g=p[0],m=p[1],y=Math.sqrt(Math.pow(g,2)+Math.pow(m,2)),v=c([-d/y,f/y],2),b=v[0],x=v[1];return[b*g,b*m,x*g,x*m]}(o,a,u):new Array(4).fill(0),4),v=y[0],b=y[1],x=y[2],w=y[3],E=function(e){return t.selectAll(gz.line.class).data(e,(function(t,e){return e})).join((function(t){return t.append("line").attr("className",(function(t){return"".concat(gz.line.name," ").concat(t.className)})).styles(n).transition((function(t){return iz(this,Rz(t.line),!1)}))}),(function(t){return t.styles(n).transition((function(t){return iz(this,Rz(t.line),r.update)}))}),(function(t){return t.remove()})).transitions()};if(!i||!s)return E([{line:[[d+v,f+b],[g+x,m+w]],className:gz.line.name}]);var M=c(s,2),S=M[0],N=M[1],k=g-d,C=m-f,T=c([d+k*S,f+C*S],2),A=T[0],P=T[1],O=c([d+k*N,f+C*N],2),_=O[0],R=O[1],I=E([{line:[[d+v,f+b],[A,P]],className:gz.lineFirst.name},{line:[[_,R],[g+x,m+w]],className:gz.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),I}function Dz(t,e,n){var r,i=e.type,o=Bj(e,"line");return r="linear"===i?Iz(t,e,Sj(o,"arrow"),n):_z(t,e,Sj(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,a=n.showTrunc,s=n.lineArrow,u=n.lineArrowOffset,c=n.lineArrowSize;if(i="arc"===e?t.select(gz.line.class):a?t.select(gz.lineSecond.class):t.select(gz.line.class),!o||!s||"arc"===n.type&&Pz(n.startAngle,n.endAngle)){var l=i.node();l&&(l.style.markerEnd=void 0)}else{var h=uj(s);h.attr(r),Aj(h,c),i.style("markerEnd",h).style("markerEndOffset",-u)}}(t,i,e,o),r}function Lz(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function jz(t,e){var n=e.gridLength;return t.map((function(t,r){var i=t.value,o=c(Cz(i,e),2),a=o[0],s=o[1],u=c(mj(function(t,e){return Nz(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[a,s],[a+u[0],s+u[1]]]}}))}function Bz(t,e,n,r){var o=Bj(n,"grid"),a=o.type,s=o.areaFill,u=Lz(n),l=Ez(e,n.gridFilter),h="segment"===a?jz(l,n):function(t,e){var n=e.gridControlAngles,r=Lz(e);if(!r)throw new Error("grid center is not provide");if(t.length<2)throw new Error("Invalid grid data");if(!n||0===n.length)throw new Error("Invalid gridControlAngles");var i=c(r,2),o=i[0],a=i[1];return t.map((function(t,r){var i=c(Cz(t.value,e),2),s=i[0],u=i[1],l=c([s-o,u-a],2),h=l[0],d=l[1],f=[];return n.forEach((function(t){var e=qL(t),n=c([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=h*r-d*i+o,u=h*i+d*r+a;f.push([s,u])})),{points:f,id:r}}))}(l,n),d=i(i({},o),{center:u,areaFill:Ot(s)?l.map((function(t,e){return XL(s,[t,e,l])})):s,animate:r,data:h});return t.selectAll(gz.grid.class).data([1]).join((function(t){return t.append((function(){return new xz({style:d})})).attr("className",gz.grid.name)}),(function(t){return t.transition((function(){return this.update(d)}))}),(function(t){return t.remove()})).transitions()}var zz=function(){function t(t,e,n,r){this.set(t,e,n,r)}return Object.defineProperty(t.prototype,"left",{get:function(){return this.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this.defined("x2")&&this.defined("x1")?this.x2-this.x1:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.defined("y2")&&this.defined("y1")?this.y2-this.y1:void 0},enumerable:!1,configurable:!0}),t.prototype.rotatedPoints=function(t,e,n){var r=this,i=r.x1,o=r.y1,a=r.x2,s=r.y2,u=Math.cos(t),c=Math.sin(t),l=e-e*u+n*c,h=n-e*c-n*u;return[[u*i-c*s+l,c*i+u*s+h],[u*a-c*s+l,c*a+u*s+h],[u*i-c*o+l,c*i+u*o+h],[u*a-c*o+l,c*a+u*o+h]]},t.prototype.set=function(t,e,n,r){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),r<e?(this.y2=e,this.y1=r):(this.y1=e,this.y2=r),this},t.prototype.defined=function(t){return this[t]!==Number.MAX_VALUE&&this[t]!==-Number.MAX_VALUE},t}();function Fz(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getBounds(),i=c(r.min,2),o=i[0],a=i[1],s=c(r.max,2),u=s[0],l=s[1],h=t.getBBox(),d=h.width,f=h.height,p=0,g=0,m=o,y=a,v=ij(t);if(v){f-=1.5;var b=v.style.textAlign,x=v.style.textBaseline;"center"===b?m=(o+u)/2:"right"!==b&&"end"!==b||(m=u),"middle"===x?y=(a+l)/2:"bottom"===x&&(y=l)}var w=c(_j(e),4),E=w[0],M=void 0===E?0:E,S=w[1],N=void 0===S?0:S,k=w[2],C=void 0===k?M:k,T=w[3],A=new zz((p+=o)-(void 0===T?N:T),(g+=a)-M,p+d+N,g+f+C);return t.setEulerAngles(n),A.rotatedPoints(qL(n),m,y)}function Gz(t,e){return e[0]<=Math.max(t[0][0],t[1][0])&&e[0]<=Math.min(t[0][0],t[1][0])&&e[1]<=Math.max(t[0][1],t[1][1])&&e[1]<=Math.min(t[0][1],t[1][1])}function Vz(t,e,n){var r=(e[1]-t[1])*(n[0]-e[0])-(e[0]-t[0])*(n[1]-e[1]);return 0===r?0:r<0?2:1}function Wz(t,e){return e.every((function(e){return function(t,e){var n=t.length;if(n<3)return!1;var r,i,o,a,s,u,c=[e,[9999,e[1]]],l=0,h=0;do{var d=[t[h],t[(h+1)%n]];if(i=c,o=void 0,a=void 0,s=void 0,u=void 0,o=Vz((r=d)[0],r[1],i[0]),a=Vz(r[0],r[1],i[1]),s=Vz(i[0],i[1],r[0]),u=Vz(i[0],i[1],r[1]),o!==a&&s!==u||0===o&&Gz(r,i[0])||0===a&&Gz(r,i[1])||0===s&&Gz(i,r[0])||0===u&&Gz(i,r[1])){if(0===Vz(d[0],e,d[1]))return Gz(d,e);l++}h=(h+1)%n}while(0!==h);return!!(1&l)}(t,e)}))}function Hz(t,e){return[[t[0],t[1],t[2],t[3]],[t[2],t[3],t[4],t[5]],[t[4],t[5],t[6],t[7]],[t[6],t[7],t[0],t[1]]].some((function(t){return function(t,e){var n=c(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=c(e,4),u=s[0],l=s[1],h=o-r,d=a-i,f=s[2]-u,p=s[3]-l,g=h*p-f*d;if(0===g)return!1;var m=g>0,y=r-u,v=i-l,b=h*v-d*y;if(b<0===m)return!1;var x=f*v-p*y;return x<0!==m&&b>g!==m&&x>g!==m}(e,t)}))}function Uz(t,e,n){var r,i,o=e.crossPadding,a=new Set,s=null,l=function(t,e){var n=t.type,r=t.labelDirection,i=t.crossSize;if(!i)return!1;if("arc"===n){var o=t.center,a=t.radius,s=c(o,2),u=s[0],l=s[1],h="negative"===r?0:i,d=-a-h,f=a+h,p=c(_j(e),4),g=p[0],m=p[1],y=p[2],v=p[3];return new zz(u+d-v,l+d-g,u+f+m,l+f+y)}var b=c(t.startPos,2),x=b[0],w=b[1],E=c(t.endPos,2),M=E[0],S=E[1],N=c(Az(t)?[-e,0,e,0]:[0,e,0,-e],4),k=N[0],C=N[1],T=N[2],A=N[3],P=mj(kz(0,t),i),O=new zz(x,w,M,S);return O.x1+=A,O.y1+=k,O.x2+=C+P[0],O.y2+=T+P[1],O}(e,o),h=function(t){return!l||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,a=t.y2;return Wz([[r,o],[i,o],[i,a],[r,a]],Fz(e,n))}(l,t)},d=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=Fz(t,n).flat(1),a=Fz(e,n).flat(1),s=[[o[0],o[1],o[2],o[3]],[o[0],o[1],o[4],o[5]],[o[4],o[5],o[6],o[7]],[o[2],o[3],o[6],o[7]]];try{for(var c=u(s),l=c.next();!l.done;l=c.next())if(Hz(a,l.value))return!0}catch(t){r={error:t}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,_j(n))};try{for(var f=u(t),p=f.next();!p.done;p=f.next()){var g=p.value;h(g)?!s||d(s,g)?s=g:(a.add(s),a.add(g)):a.add(g)}}catch(t){r={error:t}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}return Array.from(a)}function $z(t,e){return void 0===e&&(e={}),_t(t)?0:"number"==typeof t?t:Math.floor(nj(t,e))}var qz=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter((function(t,e){return!(e%r)||(VL(t),!1)}))};var Yz=new Map([["hide",function(t,e,n,r){var i=t.length,o=e.keepHeader,a=e.keepTail;if(!(i<=1||2===i&&o&&a)){var s,u,h,d=qz,f=function(t){return t.forEach(r.show),t},p=2,g=t.slice(),m=t.slice(),y=Math.min.apply(Math,l([1],c(t.map((function(t){return t.getBBox().width}))),!1));if("linear"===n.type&&(Tz(n)||Az(n))){var v=Rj(t[0]).left,b=Rj(t[i-1]).right,x=Math.abs(b-v)||1;p=Math.max(Math.floor(i*y/x),p)}for(o&&(s=g.splice(0,1)[0]),a&&(u=g.splice(-1,1)[0],g.reverse()),f(g);p<t.length&&Uz((h=u?l(l([u],c(m),!1),[s],!1):l([s],c(m),!1),h.filter(ej)),n,null==e?void 0:e.margin).length;){if(u&&!s&&p%2==0)g.splice(0,1).forEach(r.hide);else if(u&&s){g.splice(0,1).forEach(r.hide)}m=d(f(g),{seq:p}),p++}}}],["rotate",function(t,e,n,r){var i,o,a=e.optionalAngles,s=void 0===a?[0,45,90]:a,c=e.margin,l=e.recoverWhenFailed,h=void 0===l||l,d=t.map((function(t){return t.getLocalEulerAngles()})),f=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.rotate(t,+i)}))};try{for(var p=u(s),g=p.next();!g.done;g=p.next()){if(f(g.value),Uz(t,n,c).length<1)return}}catch(t){i={error:t}}finally{try{g&&!g.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}h&&f(d)}],["ellipsis",function(t,e,n,r){if(!(t.length<=1)){var i=e.suffix,o=void 0===i?"...":i,a=e.minLength,s=e.maxLength,u=void 0===s?1/0:s,l=e.step,h=void 0===l?" ":l,d=e.margin,f=void 0===d?[0,0,0,0]:d,p=rj(r.getTextShape(t[0])),g=$z(h,p),m=a?$z(a,p):g,y=$z(u,p);(_t(y)||y===1/0)&&(y=Math.max.apply(null,t.map((function(t){return t.getBBox().width}))));var v=t.slice(),b=c(f,4);b[0],b[1],b[2],b[3];for(var x=function(e){if(v.forEach((function(t){r.ellipsis(r.getTextShape(t),e,o)})),(v=Uz(t,n,f)).length<1)return{value:void 0}},w=y;w>m+g;w-=g){var E=x(w);if("object"==typeof E)return E.value}}}],["wrap",function(t,e,n,r){var i=e.wordWrapWidth,o=void 0===i?50:i,a=e.maxLines,s=void 0===a?3:a,u=e.recoverWhenFailed,h=void 0===u||u,d=e.margin,f=void 0===d?[0,0,0,0]:d,p=t.map((function(t){return t.attr("maxLines")||1})),g=Math.min.apply(Math,l([],c(p),!1)),m=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&Tz(t)?"negative"===n?"bottom":"top":"middle"}(n),y=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,o,i,m)}))};if(!(g>s)){for(var v=g;v<=s;v++)if(y(v),Uz(t,n,f).length<1)return;h&&y(p)}}]]);function Kz(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce((function(t,e){return t*function(t){return"positive"===t?-1:1}(e)}),1)}function Xz(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)}function Zz(t,e){var n=c(t,2),r=n[0],i=n[1],o=c(e,2),a=o[0],s=o[1],u=c([r*a+i*s,r*s-i*a],2),l=u[0],h=u[1];return Math.atan2(h,l)}function Qz(t,e,n){var r,i=n.labelAlign;if(null===(r=e.style.transform)||void 0===r?void 0:r.includes("rotate"))return e.getLocalEulerAngles();var o=kz(t.value,n),a=Sz(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return lj(e,-90,90)||(e+=180),e}(YL("perpendicular"===i?Zz([1,0],o):Zz([a[0]<0?-1:1,0],a)))}function Jz(t,e,n){var r=n.type,i=n.labelAlign,o=kz(t,n),a=Xz(e),s=Xz(YL(Zz([1,0],o))),u="center",c="middle";return"linear"===r?[90,270].includes(s)&&0===a?(u="center",c=1===o[1]?"top":"bottom"):s%180||![90,270].includes(a)?0===s?(lj(a,0,90,!1,!0)||lj(a,0,90)||lj(a,270,360))&&(u="start"):90===s?lj(a,0,90,!1,!0)?u="start":(lj(a,90,180)||lj(a,270,360))&&(u="end"):270===s?lj(a,0,90,!1,!0)?u="end":(lj(a,90,180)||lj(a,270,360))&&(u="start"):180===s&&(90===a?u="start":(lj(a,0,90)||lj(a,270,360))&&(u="end")):u="center":"parallel"===i?c=lj(s,0,180,!0)?"top":"bottom":"horizontal"===i?lj(s,90,270,!1)?u="end":(lj(s,270,360,!1)||lj(s,0,90))&&(u="start"):"perpendicular"===i&&(u=lj(s,90,270)?"end":"start"),{textAlign:u,textBaseline:c}}function tF(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,a=n.labelDirection,s=n.labelSpacing,u=e.indexOf(t),l=XL(s,[t,u,e]),h=c([kz(t.value,n),Kz(a,o)],2),d=c(yj(mj(h[0],l+(1===h[1]?XL(r?i:0,[t,u,e]):0)),Cz(t.value,n)),2);return{x:d[0],y:d[1]}}function eF(t,e){"text"===t.nodeName&&t.attr(e)}function nF(t){!function(t,e,n){var r=e.labelOverlap,i=void 0===r?[]:r;i.length&&i.forEach((function(r){var i=r.type,o=Yz.get(i);(function(t,e,n){return!(e.labelOverlap.length<1)&&("hide"===n?!function(t){for(var e=t;e;){if("offscreen"===e.className)return!0;e=e.parent}return!1}(t[0]):"rotate"===n?!t.some((function(t){var e;return!!(null===(e=t.attr("transform"))||void 0===e?void 0:e.includes("rotate"))})):"ellipsis"!==n&&"wrap"!==n||t.filter((function(t){return t.querySelector("text")})).length>1)})(t,e,i)&&(null==o||o(t,r,e,n))}))}(this.node().childNodes,t,{hide:VL,show:GL,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=Jz(e.__data__.value,t,n),i=e.querySelector(gz.labelItem.class);i&&eF(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&aj(t,e||1/0,n)},wrap:function(t,e,n){var r,i;t&&(void 0===(r=n)&&(r=2),void 0===i&&(i="top"),oj(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector("text")}})}function rF(t,e,n,r,a){var s=n.indexOf(e),u=Oj(t).append(function(t,e,n,r){var i=r.labelFormatter;return Ot(i)?function(){return uj(XL(i,[t,e,n,kz(t.value,r)]))}:function(){return uj(t.label||"")}}(e,s,n,a)).attr("className",gz.labelItem.name).node(),l=c(Fj(wz(r,[e,s,n])),2),h=l[0],d=l[1],f=d.transform,p=o(d,["transform"]);Vj(u,f);var g=Qz(e,u,a);return u.getLocalEulerAngles()||u.setLocalEulerAngles(g),eF(u,i(i({},Jz(e.value,g,a)),h)),t.attr(p),u}function iF(t,e,n,r){var o=Ez(e,n.labelFilter),a=Bj(n,"label");return t.selectAll(gz.label.class).data(o,(function(t,e){return e})).join((function(r){return r.append("g").attr("className",gz.label.name).transition((function(t){rF(this,t,e,a,n);var r=tF(t,e,n),i=r.x,o=r.y;return this.style.transform="translate(".concat(i,", ").concat(o,")"),null})).call((function(){nF.call(t,n)}))}),(function(o){return o.transition((function(t){var o=function(t,e,n,r){if(void 0===r&&(r="destroy"),function(t,e){return"text"===t.nodeName&&"text"===e.nodeName&&t.attributes.text===e.attributes.text}(t,e))return t.remove(),[null];var o=function(){"destroy"===r?t.destroy():"hide"===r&&VL(t),e.isVisible()&&GL(e)};if(!n)return o(),[null];var a=n.duration,s=void 0===a?0:a,u=n.delay,l=void 0===u?0:u,h=Math.ceil(+s/2),d=+s/4,f=c(t.getGeometryBounds().center,2),p=f[0],g=f[1],m=c(e.getGeometryBounds().center,2),y=c([(p+m[0])/2-p,(g+m[1])/2-g],2),v=y[0],b=y[1],x=t.style.opacity,w=void 0===x?1:x,E=e.style.opacity,M=void 0===E?1:E,S=t.style.transform||"",N=e.style.transform||"",k=t.animate([{opacity:w,transform:"translate(0, 0) ".concat(S)},{opacity:0,transform:"translate(".concat(v,", ").concat(b,") ").concat(S)}],i(i({fill:"both"},n),{duration:l+h+d})),C=e.animate([{opacity:0,transform:"translate(".concat(-v,", ").concat(-b,") ").concat(N),offset:.01},{opacity:M,transform:"translate(0, 0) ".concat(N)}],i(i({fill:"both"},n),{duration:h+d,delay:l+h-d}));return ez(C,o),[k,C]}(this.querySelector(gz.labelItem.class),rF(this,t,e,a,n),r.update),s=tF(t,e,n),u=s.x,h=s.y,d=iz(this,{transform:"translate(".concat(u,", ").concat(h,")")},r.update);return l(l([],c(o),!1),[d],!1)})).call((function(e){var r,i,o=fe(e,"_transitions").flat().filter(ej);i=function(){nF.call(t,n)},0===(r=o).length?i():Promise.all(r.map((function(t){return null==t?void 0:t.finished}))).then(i)}))}),(function(t){return t.transition((function(){var t=this,e=oz(this.childNodes[0],r.exit);return ez(e,(function(){return Oj(t).remove()})),e}))})).transitions()}function oF(t,e){return Nz(t,e.tickDirection,e)}function aF(t,e,n,r,i){var o=c(function(t,e){var n=c(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,XL(i.tickLength,[t,e,n])),2),a=c(o[0],2),s=a[0],u=a[1],l=c(o[1],2);return{x1:s,x2:l[0],y1:u,y2:l[1]}}function sF(t,e,n,r,o,a){var s=function(t,e,n,r,i){var o=i.tickFormatter,a=oF(e.value,i),s="line";return Ot(o)&&(s=function(){return XL(o,[e,n,r,a])}),t.append(s).attr("className",gz.tickItem.name)}(Oj(this),t,e,n,r);!function(t,e,n,r,o,a,s){var u=oF(t.value,a),l=aF(t,e,n,u,a),h=l.x1,d=l.x2,f=l.y1,p=l.y2,g=c(Fj(wz(s,[t,e,n,u])),2),m=g[0],y=g[1];"line"===r.node().nodeName&&r.styles(i({x1:h,x2:d,y1:f,y2:p},m)),o.attr(y),r.styles(m)}(t,e,n,s,this,r,o);var u=c(Cz(t.value,r),2),l=u[0],h=u[1];return iz(this,{transform:"translate(".concat(l,", ").concat(h,")")},a)}var uF=QL({text:"text"},"title");function cF(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function lF(t,e){var n=Object.entries(e).reduce((function(e,n){var r=c(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var hF=function(t){function e(e){return t.call(this,e,{text:"",width:0,height:0,fill:"#4a505a",fontWeight:"bold",fontSize:12,fontFamily:"sans-serif",inset:0,spacing:0,position:"top-left"})||this}return r(e,t),e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=t.position,i=t.spacing,o=t.inset,a=this.querySelector(uF.text.class);if(!a)return new KL(0,0,+e,+n);var s=a.getBBox(),u=s.width,l=s.height,h=c(_j(i),4),d=h[0],f=h[1],p=h[2],g=h[3],m=c([0,0,+e,+n],4),y=m[0],v=m[1],b=m[2],x=m[3],w=cF(r);if(w.includes("i"))return new KL(y,v,b,x);w.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=c(0===r?[l+p,+n-l-p]:[0,+n],2),v=i[0],x=i[1]),"r"===t&&(o=c([+e-u-g],1),b=o[0]),"b"===t&&(a=c([+n-l-d],1),x=a[0]),"l"===t&&(s=c(0===r?[u+f,+e-u-f]:[0,+e],2),y=s[0],b=s[1])}));var E=c(_j(o),4),M=E[0],S=E[1],N=E[2],k=E[3],C=c([k+S,M+N],2),T=C[0],A=C[1];return new KL(y+k,v+M,b-T,x-A)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new KL(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=o(t,["width","height","position","spacing"]),i=c(Fj(r),1)[0],a=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,u=o.position,l=c([+a/2,+s/2],2),h=c([+l[0],+l[1],"center","middle"],4),d=h[0],f=h[1],p=h[2],g=h[3],m=cF(u);return m.includes("l")&&(d=(e=c([0,"start"],2))[0],p=e[1]),m.includes("r")&&(d=(n=c([+a,"end"],2))[0],p=n[1]),m.includes("t")&&(f=(r=c([0,"top"],2))[0],g=r[1]),m.includes("b")&&(f=(i=c([+s,"bottom"],2))[0],g=i[1]),{x:d,y:f,textAlign:p,textBaseline:g}}(t),s=a.x,u=a.y,l=a.textAlign,h=a.textBaseline;cj(!!r.text,Oj(e),(function(t){n.title=t.maybeAppendByClassName(uF.text,"text").styles(i).call(lF,{x:s,y:u,textAlign:l,textBaseline:h}).node()}))},e}(Hj);function dF(t,e,n,r,a){var s=c(Fj(Bj(r,"title")),2),u=s[0],l=s[1],h=l.transform,d=l.transformOrigin,f=o(l,["transform","transformOrigin"]);e.styles(f);var p=h||function(t,e,n){var r=2*t.getGeometryBounds().halfExtents[1];if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(r/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(r/2,")")}return""}(t.node(),u.direction,u.position);t.styles(i(i({},u),{transformOrigin:d})),Vj(t.node(),p);var g=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,a=cF(i),s=t.node().getLocalBounds(),u=c(s.min,2),l=u[0],h=u[1],d=c(s.halfExtents,2),f=d[0],p=d[1],g=c(e.node().getLocalBounds().halfExtents,2),m=g[0],y=g[1],v=c([l+f,h+p],2),b=v[0],x=v[1],w=c(_j(o),4),E=w[0],M=w[1],S=w[2],N=w[3];if(["start","end"].includes(i)&&"linear"===n.type){var k=n.startPos,C=n.endPos,T=c("start"===i?[k,C]:[C,k],2),A=T[0],P=T[1],O=c(mj(Ej([-P[0]+A[0],-P[1]+A[1]]),E),2),_=O[0],R=O[1];return{x:A[0]+_,y:A[1]+R}}return a.includes("t")&&(x-=p+y+E),a.includes("r")&&(b+=f+m+M),a.includes("l")&&(b-=f+m+N),a.includes("b")&&(x+=p+y+S),{x:b,y:x}}(Oj(n._offscreen||n.querySelector(gz.mainGroup.class)),e,r),m=g.x,y=g.y;return iz(e.node(),{transform:"translate(".concat(m,", ").concat(y,")")},a)}function fF(t,e,n,r){var i=t.showLine,o=t.showTick,a=t.showLabel,s=cj(i,e.maybeAppendByClassName(gz.lineGroup,"g"),(function(e){return Dz(e,t,r)}))||[],u=cj(o,e.maybeAppendByClassName(gz.tickGroup,"g"),(function(e){return function(t,e,n,r){var i=Ez(e,n.tickFilter),o=Bj(n,"tick");return t.selectAll(gz.tick.class).data(i,(function(t){return t.id||t.label})).join((function(t){return t.append("g").attr("className",gz.tick.name).transition((function(t,e){return sF.call(this,t,e,i,n,o,!1)}))}),(function(t){return t.transition((function(t,e){return this.removeChildren(),sF.call(this,t,e,i,n,o,r.update)}))}),(function(t){return t.transition((function(){var t=this,e=oz(this.childNodes[0],r.exit);return ez(e,(function(){return t.remove()})),e}))})).transitions()}(e,n,t,r)}))||[],h=cj(a,e.maybeAppendByClassName(gz.labelGroup,"g"),(function(e){return iF(e,n,t,r)}))||[];return l(l(l([],c(s),!1),c(u),!1),c(h),!1).filter((function(t){return!!t}))}var pF=function(t){function e(e){return t.call(this,e,pz)||this}return r(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,a=t.animate,s=t.showTitle,u=t.showGrid,h=t.dataThreshold,d=t.truncRange,f=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;i<t.length;i+=n)r.push(t[i]);return r}(o,h).filter((function(t){var e=t.value;return!(d&&e>d[0]&&e<d[1])})),p=tz(void 0===n?a:n),g=cj(u,Oj(e).maybeAppendByClassName(gz.gridGroup,"g"),(function(e){return Bz(e,f,t,p)}))||[],m=Oj(e).maybeAppendByClassName(gz.mainGroup,"g");i&&(!this.initialized&&p.enter||this.initialized&&p.update)&&fF(t,Oj(this.offscreenGroup),f,tz(!1));var y=fF(t,Oj(m.node()),f,p),v=cj(s,Oj(e).maybeAppendByClassName(gz.titleGroup,"g"),(function(e){return function(t,e,n,r){var i=n.titleText;return t.selectAll(gz.title.class).data([{title:i}].filter((function(t){return!!t.title})),(function(t,e){return t.title})).join((function(o){return o.append((function(){return uj(i)})).attr("className",gz.title.name).transition((function(){return dF(Oj(this),t,e,n,r.enter)}))}),(function(i){return i.transition((function(){return dF(Oj(this),t,e,n,r.update)}))}),(function(t){return t.remove()})).transitions()}(e,r,t,p)}))||[];return l(l(l([],c(g),!1),c(y),!1),c(v),!1).flat().filter((function(t){return!!t}))},e}(Hj),gF=QL({prevBtnGroup:"prev-btn-group",prevBtn:"prev-btn",nextBtnGroup:"next-btn-group",nextBtn:"next-btn",pageInfoGroup:"page-info-group",pageInfo:"page-info",playWindow:"play-window",contentGroup:"content-group",controller:"controller",clipPath:"clip-path"},"navigator"),mF=function(t){function e(e){var n=t.call(this,e,{x:0,y:0,animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonD:Xj(0,0,6),buttonSize:12,controllerPadding:5,controllerSpacing:5,formatter:function(t,e){return"".concat(t,"/").concat(e)},defaultPage:0,loop:!1,orientation:"horizontal",pageNumFill:"black",pageNumFontSize:12,pageNumTextAlign:"start",pageNumTextBaseline:"middle"})||this;return n.playState="idle",n.contentGroup=n.appendChild(new Vs({class:gF.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new Vs({class:gF.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return r(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return Ut(t,0,Math.max(this.pageViews.length-1,0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.playWindow.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controllerShape",{get:function(){return this.totalPages>1?{width:55,height:0}:{width:0,height:0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageShape",{get:function(){var t=c(function(t){var e;return(null===(e=t[0])||void 0===e?void 0:e.map((function(e,n){return t.map((function(t){return t[n]}))})))||[]}(this.pageViews.map((function(t){var e=t.getBBox();return[e.width,e.height]}))).map((function(t){return Math.max.apply(Math,l([],c(t),!1))})),2),e=t[0],n=t[1],r=this.attributes,i=r.pageWidth,o=void 0===i?e:i,a=r.pageHeight;return{pageWidth:o,pageHeight:void 0===a?n:a}},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.playWindow},Object.defineProperty(e.prototype,"totalPages",{get:function(){return this.pageViews.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.innerCurrPage},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e=t.prototype.getBBox.call(this),n=e.x,r=e.y,i=this.controllerShape,o=this.pageShape,a=o.pageWidth,s=o.pageHeight;return new KL(n,r,a+i.width,s)},e.prototype.goTo=function(t){var e=this,n=this.attributes.animate,r=this,i=r.currPage,o=r.playState,a=r.playWindow,s=r.pageViews;if("idle"!==o||t<0||s.length<=0||t>=s.length)return null;s[i].setLocalPosition(0,0),this.prepareFollowingPage(t);var u=c(this.getFollowingPageDiff(t),2),l=u[0],h=u[1];this.playState="running";var d=rz(a,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-l,", ").concat(-h,")")}],n);return ez(d,(function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()})),d},e.prototype.prev=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n<=0)return null;var r=t?(n-1+e)%e:Ut(n-1,0,e);return this.goTo(r)},e.prototype.next=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n>=e-1)return null;var r=t?(n+1)%e:Ut(n+1,0,e);return this.goTo(r)},e.prototype.renderClipPath=function(t){var e=this.pageShape,n=e.pageWidth,r=e.pageHeight;n&&r?(this.clipPath=t.maybeAppendByClassName(gF.clipPath,"rect").styles({width:n,height:r}),this.contentGroup.attr("clipPath",this.clipPath.node())):this.contentGroup.style.clipPath=void 0},e.prototype.setVisiblePages=function(t){this.playWindow.children.forEach((function(e,n){t.includes(n)?GL(e):VL(e)}))},e.prototype.adjustControllerLayout=function(){var t=this,e=t.prevBtnGroup,n=t.nextBtnGroup,r=t.pageInfoGroup,i=this.attributes,o=i.orientation,a=i.controllerPadding,s=r.getBBox(),u=s.width;s.height;var l=c("horizontal"===o?[-180,0]:[-90,90],2),h=l[0],d=l[1];e.setLocalEulerAngles(h),n.setLocalEulerAngles(d);var f=e.getBBox(),p=f.width,g=f.height,m=n.getBBox(),y=m.width,v=m.height,b=Math.max(p,u,y),x="horizontal"===o?{offset:[[0,0],[p/2+a,0],[p+u+2*a,0]],textAlign:"start"}:{offset:[[b/2,-g-a],[b/2,0],[b/2,v+a]],textAlign:"center"},w=c(x.offset,3),E=c(w[0],2),M=E[0],S=E[1],N=c(w[1],2),k=N[0],C=N[1],T=c(w[2],2),A=T[0],P=T[1],O=x.textAlign,_=r.querySelector("text");_&&(_.style.textAlign=O),e.setLocalPosition(M,S),r.setLocalPosition(k,C),n.setLocalPosition(A,P)},e.prototype.updatePageInfo=function(){var t,e=this,n=e.currPage,r=e.pageViews,i=e.attributes.formatter;r.length<2||(null===(t=this.pageInfoGroup.querySelector(gF.pageInfo.class))||void 0===t||t.attr("text",i(n+1,r.length)),this.adjustControllerLayout())},e.prototype.getFollowingPageDiff=function(t){var e=this.currPage;if(e===t)return[0,0];var n=this.attributes.orientation,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=t<e?-1:1;return"horizontal"===n?[a*i,0]:[0,a*o]},e.prototype.prepareFollowingPage=function(t){var e=this.currPage,n=this.pageViews;if(this.setVisiblePages([t,e]),t!==e){var r=c(this.getFollowingPageDiff(t),2),i=r[0],o=r[1];n[t].setLocalPosition(i,o)}},e.prototype.renderController=function(t){var e=this,n=this.attributes.controllerSpacing,r=this.pageShape,a=r.pageWidth,s=r.pageHeight,u=this.pageViews.length>=2,l=t.maybeAppendByClassName(gF.controller,"g");if(WL(l.node(),u),u){var h=Bj(this.attributes,"button"),d=Bj(this.attributes,"pageNum"),f=c(Fj(h),2),p=f[0],g=f[1],m=p.size,y=o(p,["size"]),v=!l.select(gF.prevBtnGroup.class).node(),b=l.maybeAppendByClassName(gF.prevBtnGroup,"g").styles(g);this.prevBtnGroup=b.node();var x=b.maybeAppendByClassName(gF.prevBtn,"path"),w=l.maybeAppendByClassName(gF.nextBtnGroup,"g").styles(g);this.nextBtnGroup=w.node(),[x,w.maybeAppendByClassName(gF.nextBtn,"path")].forEach((function(t){t.styles(i(i({},y),{transformOrigin:"center"})),Aj(t.node(),m)}));var E=l.maybeAppendByClassName(gF.pageInfoGroup,"g");this.pageInfoGroup=E.node(),E.maybeAppendByClassName(gF.pageInfo,"text").styles(d),this.updatePageInfo(),l.node().setLocalPosition(a+n,s/2),v&&(this.prevBtnGroup.addEventListener("click",(function(){e.prev()})),this.nextBtnGroup.addEventListener("click",(function(){e.next()})))}},e.prototype.render=function(t,e){var n=t.x,r=void 0===n?0:n,i=t.y,o=void 0===i?0:i;this.attr("transform","translate(".concat(r,", ").concat(o,")"));var a=Oj(e);this.renderClipPath(a),this.renderController(a),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=ae((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(as.INSERTED,e),this.playWindow.addEventListener(as.REMOVED,e)},e}(Hj);function yF(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}Qj.registerSymbol("hiddenHandle",(function(t,e,n){var r=1.4*n;return[["M",t-n,e-r],["L",t+n,e-r],["L",t+n,e+r],["L",t-n,e+r],["Z"]]})),Qj.registerSymbol("verticalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=t+.4*r;return[["M",t,e],["L",a,e+i],["L",t+r,e+i],["L",t+r,e-i],["L",a,e-i],["Z"],["M",a,e+o],["L",t+r-2,e+o],["M",a,e-o],["L",t+r-2,e-o]]})),Qj.registerSymbol("horizontalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=e+.4*r;return[["M",t,e],["L",t-i,a],["L",t-i,e+r],["L",t+i,e+r],["L",t+i,a],["Z"],["M",t-o,a],["L",t-o,e+r-2],["M",t+o,a],["L",t+o,e+r-2]]}));var vF=QL({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item");var bF=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new zs({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return r(e,t),Object.defineProperty(e.prototype,"showValue",{get:function(){var t=this.attributes.valueText;return!!t&&("string"==typeof t||"number"==typeof t?""!==t:"function"==typeof t||""!==t.attr("text"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"actualSpace",{get:function(){var t=this.labelGroup,e=this.valueGroup,n=this.attributes.markerSize,r=t.node().getBBox(),i=r.width,o=r.height,a=e.node().getBBox(),s=a.width,u=a.height;return{markerWidth:n,labelWidth:i,valueWidth:s,height:Math.max(n,o,u)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=c(_j(t),2),n=e[0],r=e[1],i=this.showValue?r:0,o=n+i;return[n/o,i/o]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t,e=this.attributes,n=e.markerSize,r=e.width,i=this.actualSpace,o=i.markerWidth,a=i.height,s=this.actualSpace,u=s.labelWidth,l=s.valueWidth,h=c(this.spacing,2),d=h[0],f=h[1];if(r){var p=r-n-d-f,g=c(this.span,2);u=(t=c([g[0]*p,g[1]*p],2))[0],l=t[1]}return{width:o+u+l+d+f,height:a,markerWidth:o,labelWidth:u,valueWidth:l}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=c(_j(t),2),n=e[0],r=e[1];return this.showValue?[n,r]:[n,0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layout",{get:function(){var t=this.shape,e=t.markerWidth,n=t.labelWidth,r=t.valueWidth,i=t.width,o=t.height,a=c(this.spacing,2),s=a[0];return{height:o,width:i,markerWidth:e,labelWidth:n,valueWidth:r,position:[e/2,e+s,e+n+s+a[1]]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(vF.marker.class);return e?e.style:{}}(this.markerGroup.node()),e=this.attributes,n=e.markerSize,r=e.markerStrokeWidth,i=void 0===r?t.strokeWidth:r,o=e.markerLineWidth,a=void 0===o?t.lineWidth:o,s=e.markerStroke,u=void 0===s?t.stroke:s,c=+(i||a||(u?1:0))*Math.sqrt(2),l=this.markerGroup.node().getBBox(),h=l.width,d=l.height;return(1-c/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=Bj(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(vF.markerGroup,"g").style("zIndex",0),cj(!!n,this.markerGroup,(function(){var t,o=e.markerGroup.node(),a=null===(t=o.childNodes)||void 0===t?void 0:t[0],s="string"==typeof n?new Qj({style:{symbol:n},className:vF.marker.name}):n();a?s.nodeName===a.nodeName?a instanceof Qj?a.update(i(i({},r),{symbol:n})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=u(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=c(a.value,2),l=s[0],h=s[1];"id"!==l&&"className"!==l&&t.attr(l,h)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(a,s),Oj(a).styles(r)):(a.remove(),Oj(s).attr("className",vF.marker.name).styles(r),o.appendChild(s)):(s instanceof Qj||Oj(s).attr("className",vF.marker.name).styles(r),o.appendChild(s)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var l=Aj(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(l,")")}))},e.prototype.renderLabel=function(t){var e=Bj(this.attributes,"label"),n=e.text,r=o(e,["text"]);this.labelGroup=t.maybeAppendByClassName(vF.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(vF.label,(function(){return uj(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=Bj(this.attributes,"value"),r=n.text,i=o(n,["text"]);this.valueGroup=t.maybeAppendByClassName(vF.valueGroup,"g").style("zIndex",0),cj(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(vF.value,(function(){return uj(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,o=Bj(this.attributes,"background");this.background=t.maybeAppendByClassName(vF.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(vF.background,"rect").styles(i({width:n,height:r},o))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=c(t.position,3),o=i[0],a=i[1],s=i[2],u=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(u,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(a,", ").concat(u,")")}),aj(this.labelGroup.select(vF.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(u,")")}),aj(this.valueGroup.select(vF.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=Oj(e),r=t.x,i=void 0===r?0:r,o=t.y,a=void 0===o?0:o;n.styles({transform:"translate(".concat(i,", ").concat(a,")")}),this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.adjustLayout()},e}(Hj),xF=QL({page:"item-page",navigator:"navigator",item:"item"},"items"),wF=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},EF=function(t){function e(e){var n=t.call(this,e,{data:[],gridRow:1/0,gridCol:void 0,padding:0,width:1e3,height:100,rowPadding:0,colPadding:0,layout:"flex",orientation:"horizontal",click:be,mouseenter:be,mouseleave:be})||this;return n.navigatorShape=[0,0],n}return r(e,t),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.navigator.getContainer()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){var t=this.attributes,e=t.gridRow,n=t.gridCol,r=t.data;if(!e&&!n)throw new Error("gridRow and gridCol can not be set null at the same time");return e&&n?[e,n]:e?[e,r.length]:[r.length,n]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderData",{get:function(){var t=this.attributes,e=t.data,n=t.layout,r=Bj(this.attributes,"item"),o=e.map((function(t,o){var a=t.id,s=void 0===a?o:a,u=t.label,l=t.value;return{id:"".concat(s),index:o,style:i({layout:n,labelText:u,valueText:l},Object.fromEntries(Object.entries(r).map((function(n){var r=c(n,2);return[r[0],XL(r[1],[t,o,e])]}))))}}));return o},enumerable:!1,configurable:!0}),e.prototype.getGridLayout=function(){var t=this,e=this.attributes,n=e.orientation,r=e.width,i=e.rowPadding,o=e.colPadding,a=c(this.navigatorShape,1)[0],s=c(this.grid,2),u=s[0],l=s[1],h=l*u,d=0;return this.pageViews.children.map((function(e,s){var f,p,g=Math.floor(s/h),m=s%h,y=t.ifHorizontal(l,u),v=[Math.floor(m/y),m%y];"vertical"===n&&v.reverse();var b=c(v,2),x=b[0],w=b[1],E=(r-a-(l-1)*o)/l,M=e.getBBox().height,S=c([0,0],2),N=S[0],k=S[1];return"horizontal"===n?(N=(f=c([d,x*(M+i)],2))[0],k=f[1],d=w===l-1?0:d+E+o):(N=(p=c([w*(E+o),d],2))[0],k=p[1],d=x===u-1?0:d+M+i),{page:g,index:s,row:x,col:w,pageIndex:m,width:E,height:M,x:N,y:k}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=c(this.navigatorShape,1)[0],a=c(this.grid,2),s=a[0],u=a[1],l=c([e-o,n],2),h=l[0],d=l[1],f=c([0,0,0,0,0,0,0,0],8),p=f[0],g=f[1],m=f[2],y=f[3],v=f[4],b=f[5],x=f[6],w=f[7];return this.pageViews.children.map((function(t,e){var n,o,a,l,f=t.getBBox(),E=f.width,M=f.height,S=0===x?0:i,N=x+S+E;return N<=h&&wF(v,(function(t){return t<u}))?(n=c([x+S,w,N],3),p=n[0],g=n[1],x=n[2],{width:E,height:M,x:p,y:g,page:m,index:e,pageIndex:y++,row:b,col:v++}):(o=c([b+1,0,0,w+M+r],4),b=o[0],v=o[1],x=o[2],(w=o[3])+M<=d&&wF(b,(function(t){return t<s}))?(a=c([x,w,E],3),p=a[0],g=a[1],x=a[2],{width:E,height:M,x:p,y:g,page:m,index:e,pageIndex:y++,row:b,col:v++}):(l=c([0,0,E,0,m+1,0,0,0],8),p=l[0],g=l[1],x=l[2],w=l[3],m=l[4],y=l[5],b=l[6],v=l[7],{width:E,height:M,x:p,y:g,page:m,index:e,pageIndex:y++,row:b,col:v++}))}))},Object.defineProperty(e.prototype,"itemsLayout",{get:function(){this.navigatorShape=[0,0];var t="grid"===this.attributes.layout?this.getGridLayout:this.getFlexLayout,e=t.call(this);return e.slice(-1)[0].page>0?(this.navigatorShape=[55,0],t.call(this)):e},enumerable:!1,configurable:!0}),e.prototype.ifHorizontal=function(t,e){return yF(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(xF.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(xF.page.class).forEach((function(e){t.removeChild(e).destroy()}))},e.prototype.renderItems=function(t){var e=this.attributes,n=e.click,r=e.mouseenter,i=e.mouseleave;this.flattenPage(t);var o=this.dispatchCustomEvent.bind(this);Oj(t).selectAll(xF.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new bF({style:e})})).attr("className",xF.item.name).on("click",(function(){null==n||n(this),o("itemClick",{item:this})})).on("pointerenter",(function(){null==r||r(this),o("itemMouseenter",{item:this})})).on("pointerleave",(function(){null==i||i(this),o("itemMouseleave",{item:this})}))}),(function(t){return t.each((function(t){var e=t.style;this.update(e)}))}),(function(t){return t.remove()}))},e.prototype.relayoutNavigator=function(){var t,e=this.attributes,n=e.layout,r=e.width,i=(null===(t=this.pageViews.children[0])||void 0===t?void 0:t.getBBox().height)||0,o=c(this.navigatorShape,2),a=o[0],s=o[1];this.navigator.update("grid"===n?{pageWidth:r-a,pageHeight:i-s}:{})},e.prototype.adjustLayout=function(){var t,e,n=this,r=Object.entries((t=this.itemsLayout,e="page",t.reduce((function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t}),{}))).map((function(t){var e=c(t,2);return{page:e[0],layouts:e[1]}})),i=l([],c(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new Vs({className:xF.page.name}));e.forEach((function(t){var e=t.x,n=t.y,o=t.index,a=t.width,s=t.height,u=i[o];r.appendChild(u),pe(u,"__layout__",t),u.update({x:e,y:n,width:a,height:s})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=Bj(this.attributes,"nav"),r=tj({orientation:e},n),i=this;return t.selectAll(xF.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new mF({style:r})})).attr("className",xF.navigator.name).each((function(){i.navigator=this}))}),(function(t){return t.each((function(){this.update(r)}))}),(function(t){return t.remove()})),this.navigator},e.prototype.getBBox=function(){return this.navigator.getBBox()},e.prototype.render=function(t,e){var n=this.attributes.data;if(n&&0!==n.length){var r=this.renderNavigator(Oj(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new es(t,{detail:e});this.dispatchEvent(n)},e}(Hj),MF=QL({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),SF={showLabel:!0,formatter:function(t){return t.toString()},markerSize:25,markerStroke:"#c5c5c5",markerFill:"#fff",markerLineWidth:1,labelFontSize:12,labelFill:"#c5c5c5",labelText:"",orientation:"vertical",spacing:0};!function(t){function e(e){return t.call(this,e,SF)||this}r(e,t),e.prototype.render=function(t,e){var n=Oj(e).maybeAppendByClassName(MF.markerGroup,"g");this.renderMarker(n);var r=Oj(e).maybeAppendByClassName(MF.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,o=n.markerSymbol,a=void 0===o?yF(r,"horizontalHandle","verticalHandle"):o;cj(!!a,t,(function(t){var n=Bj(e.attributes,"marker"),r=i({symbol:a},n);e.marker=t.maybeAppendByClassName(MF.marker,(function(){return new Qj({style:r})})).update(r)}))},e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.showLabel,a=n.orientation,s=n.spacing,u=void 0===s?0:s,l=n.formatter;cj(r,t,(function(t){var n,r=Bj(e.attributes,"label"),s=r.text,h=o(r,["text"]),d=(null===(n=t.select(MF.marker.class))||void 0===n?void 0:n.node().getBBox())||{},f=d.width,p=void 0===f?0:f,g=d.height,m=c(yF(a,[0,(void 0===g?0:g)+u,"center","top"],[p+u,0,"start","middle"]),4),y=m[0],v=m[1],b=m[2],x=m[3];t.maybeAppendByClassName(MF.label,"text").styles(i(i({},h),{x:y,y:v,text:l(s).toString(),textAlign:b,textBaseline:x}))}))}}(Hj);var NF={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},kF=tj({},NF,{});tj({},NF,zj(SF,"handle"),{color:["#d0e3fa","#acc7f6","#8daaf2","#6d8eea","#4d73cd","#325bb1","#5a3e75","#8c3c79","#e23455","#e7655b"],indicatorBackgroundFill:"#262626",indicatorLabelFill:"white",indicatorLabelFontSize:12,indicatorVisibility:"hidden",labelAlign:"value",labelDirection:"positive",labelSpacing:5,showHandle:!0,showIndicator:!0,showLabel:!0,slidable:!0,titleText:"",type:"continuous"});var CF=QL({title:"title",titleGroup:"title-group",items:"items",itemsGroup:"items-group",contentGroup:"content-group",ribbonGroup:"ribbon-group",ribbon:"ribbon",handlesGroup:"handles-group",handle:"handle",startHandle:"start-handle",endHandle:"end-handle",labelGroup:"label-group",label:"label",indicator:"indicator"},"legend"),TF=function(t){function e(e){return t.call(this,e,kF)||this}return r(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,o=r.showTitle,a=r.titleText,s=c(Fj(Bj(this.attributes,"title")),2),u=s[0],l=s[1];this.titleGroup=t.maybeAppendByClassName(CF.titleGroup,"g").styles(l);var h=i(i({width:e,height:n},u),{text:o?a:""});this.title=this.titleGroup.maybeAppendByClassName(CF.title,(function(){return new hF({style:h})})).update(h)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,o=e.width,a=e.height,s=c(Fj(Bj(this.attributes,"title",!0)),2),u=s[0],l=s[1],h=i(i({},u),{width:o,height:a,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(CF.itemsGroup,"g").styles(i(i({},l),{transform:"translate(".concat(n,", ").concat(r,")")}));var d=this;this.itemsGroup.selectAll(CF.items.class).data(["items"]).join((function(t){return t.append((function(){return new EF({style:h})})).attr("className",CF.items.name).each((function(){d.items=Oj(this)}))}),(function(t){return t.update(h)}),(function(t){return t.remove()}))},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().style.transform="translate(".concat(e,", ").concat(n,")")}},Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes,e=t.showTitle,n=t.width,r=t.height;return e?this.title.node().getAvailableSpace():new KL(0,0,n,r)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e,n,r=null===(e=this.title)||void 0===e?void 0:e.node(),i=null===(n=this.items)||void 0===n?void 0:n.node();return r&&i?function(t,e){var n=t.attributes,r=n.position,i=n.spacing,o=n.inset,a=n.text,s=t.getBBox(),u=e.getBBox(),l=cF(r),h=c(_j(a?i:0),4),d=h[0],f=h[1],p=h[2],g=h[3],m=c(_j(o),4),y=m[0],v=m[1],b=m[2],x=m[3],w=c([g+f,d+p],2),E=w[0],M=w[1],S=c([x+v,y+b],2),N=S[0],k=S[1];if("l"===l[0])return new KL(s.x,s.y,u.width+s.width+E+N,Math.max(u.height+k,s.height));if("t"===l[0])return new KL(s.x,s.y,Math.max(u.width+N,s.width),u.height+s.height+M+k);var C=c([e.attributes.width||u.width,e.attributes.height||u.height],2),T=C[0],A=C[1];return new KL(u.x,u.y,T+s.width+E+N,A+s.height+M+k)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=this.attributes,r=n.width,i=n.height,o=n.x,a=void 0===o?0:o,s=n.y,u=void 0===s?0:s,c=Oj(e);e.style.transform="translate(".concat(a,", ").concat(u,")"),this.renderTitle(c,r,i),this.renderItems(c,this.availableSpace),this.adjustLayout()},e}(Hj),AF={backgroundFill:"#262626",backgroundLineCap:"round",backgroundLineWidth:1,backgroundStroke:"#333",backgroundZIndex:-1,formatter:function(t){return t.toString()},labelFill:"#fff",labelFontSize:12,labelTextBaseline:"middle",padding:[2,4],position:"right",radius:0,zIndex:999},PF=QL({background:"background",labelGroup:"label-group",label:"label"},"indicator"),OF=function(t){function e(e){var n=t.call(this,e,AF)||this;return n.point=[0,0],n.group=n.appendChild(new Vs({})),n.isMutationObserved=!0,n}return r(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=c(_j(t.padding),4),r=n[0],o=n[1],a=n[2],s=n[3],u=this.label.node().getLocalBounds(),l=u.min,h=u.max,d=new KL(l[0]-s,l[1]-r,h[0]+o-l[0]+s,h[1]+a-l[1]+r),f=this.getPath(e,d),p=Bj(this.attributes,"background");this.background=Oj(this.group).maybeAppendByClassName(PF.background,"path").styles(i(i({},p),{d:f})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=c(Fj(Bj(this.attributes,"label")),2),i=r[0],a=r[1];i.text;var s=o(i,["text"]);(this.label=Oj(this.group).maybeAppendByClassName(PF.labelGroup,"g").styles(a),n)&&this.label.maybeAppendByClassName(PF.label,(function(){return uj(e(n))})).style("text",e(n).toString()).selectAll("text").styles(s)},e.prototype.adjustLayout=function(){var t=c(this.point,2),e=t[0],n=t[1],r=this.attributes,i=r.x,o=r.y;this.group.attr("transform","translate(".concat(i-e,", ").concat(o-n,")"))},e.prototype.getPath=function(t,e){var n=this.attributes.radius,r=e.x,i=e.y,o=e.width,a=e.height,s=[["M",r+n,i],["L",r+o-n,i],["A",n,n,0,0,1,r+o,i+n],["L",r+o,i+a-n],["A",n,n,0,0,1,r+o-n,i+a],["L",r+n,i+a],["A",n,n,0,0,1,r,i+a-n],["L",r,i+n],["A",n,n,0,0,1,r+n,i],["Z"]],u={top:4,right:6,bottom:0,left:2}[t],h=this.createCorner([s[u].slice(-2),s[u+1].slice(-2)]);return s.splice.apply(s,l([u+1,1],c(h),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=Ij.apply(void 0,l([],c(t),!1)),r=c(t,2),i=c(r[0],2),o=i[0],a=i[1],s=c(r[1],2),u=s[0],h=s[1],d=c(n?[u-o,[o,u]]:[h-a,[a,h]],2),f=d[0],p=c(d[1],2),g=p[0],m=p[1],y=f/2,v=e*(f/Math.abs(f)),b=v/2,x=v*Math.sqrt(3)/2*.8,w=c([g,g+y-b,g+y,g+y+b,m],5),E=w[0],M=w[1],S=w[2],N=w[3],k=w[4];return n?(this.point=[S,a-x],[["L",E,a],["L",M,a],["L",S,a-x],["L",N,a],["L",k,a]]):(this.point=[o+x,S],[["L",o,E],["L",o,M],["L",o+x,S],["L",o,N],["L",o,k]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?VL(this):GL(this)},e.prototype.bindEvents=function(){this.label.on(as.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(Hj);function _F(t){return void 0===t&&(t=""),{CONTAINER:"".concat(t,"tooltip"),TITLE:"".concat(t,"tooltip-title"),LIST:"".concat(t,"tooltip-list"),LIST_ITEM:"".concat(t,"tooltip-list-item"),NAME:"".concat(t,"tooltip-list-item-name"),MARKER:"".concat(t,"tooltip-list-item-marker"),NAME_LABEL:"".concat(t,"tooltip-list-item-name-label"),VALUE:"".concat(t,"tooltip-list-item-value"),CROSSHAIR_X:"".concat(t,"tooltip-crosshair-x"),CROSSHAIR_Y:"".concat(t,"tooltip-crosshair-y")}}var RF={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function IF(t){var e;void 0===t&&(t="");var n=_F(t);return(e={})[".".concat(n.CONTAINER)]={position:"absolute",visibility:"visible","z-index":8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)","background-color":"rgba(255, 255, 255, 0.96)","box-shadow":"0 6px 12px 0 rgba(0, 0, 0, 0.12)","border-radius":"4px",color:"rgba(0, 0, 0, 0.65)","font-size":"12px","line-height":"20px",padding:"12px","min-width":"120px","max-width":"360px","font-family":"Roboto-Regular"},e[".".concat(n.TITLE)]={color:"rgba(0, 0, 0, 0.45)"},e[".".concat(n.LIST)]={margin:"0px","list-style-type":"none",padding:"0px"},e[".".concat(n.LIST_ITEM)]={"list-style-type":"none",display:"flex","line-height":"2em","align-items":"center","justify-content":"space-between","white-space":"nowrap"},e[".".concat(n.MARKER)]={width:"8px",height:"8px","border-radius":"50%",display:"inline-block","margin-right":"4px"},e[".".concat(n.NAME)]={display:"flex","align-items":"center","max-width":"216px"},e[".".concat(n.NAME_LABEL)]=i({flex:1},RF),e[".".concat(n.VALUE)]=i({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},RF),e[".".concat(n.CROSSHAIR_X)]={position:"absolute",width:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e[".".concat(n.CROSSHAIR_Y)]={position:"absolute",height:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e}var DF=function(t){function e(e){var n,r,i=this,o=null===(r=null===(n=e.style)||void 0===n?void 0:n.template)||void 0===r?void 0:r.prefixCls,a=_F(o);return(i=t.call(this,e,{data:[],x:0,y:0,visibility:"visible",title:"",position:"bottom-right",offset:[5,5],enterable:!1,container:{x:0,y:0},bounding:null,template:{prefixCls:"",container:'<div class="'.concat(a.CONTAINER,'"></div>'),title:'<div class="'.concat(a.TITLE,'"></div>'),item:'<li class="'.concat(a.LIST_ITEM,'" data-index={index}>\n <span class="').concat(a.NAME,'">\n <span class="').concat(a.MARKER,'" style="background:{color}"></span>\n <span class="').concat(a.NAME_LABEL,'" title="{name}">{name}</span>\n </span>\n <span class="').concat(a.VALUE,'" title="{value}">{value}</span>\n </li>')},style:IF(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return r(e,t),Object.defineProperty(e.prototype,"HTMLTooltipElement",{get:function(){return this.element},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.element},Object.defineProperty(e.prototype,"elementSize",{get:function(){return{width:this.element.offsetWidth,height:this.element.offsetHeight}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"HTMLTooltipItemsElements",{get:function(){var t=this.attributes,e=t.data,n=t.template;return e.map((function(t,e){var r=t.name,a=void 0===r?"":r,s=t.color,u=void 0===s?"black":s,c=t.index,l=o(t,["name","color","index"]),h=i({name:a,color:u,index:null!=c?c:e},l);return on(function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,(function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]})):t}(n.item,h))}))},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.renderHTMLTooltipElement(),this.updatePosition()},e.prototype.destroy=function(){var e;null===(e=this.element)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.show=function(t,e){var n=this;if(void 0!==t&&void 0!==e){var r=function(){n.attributes.x=null!=t?t:n.attributes.x,n.attributes.y=null!=e?e:n.attributes.y,n.updatePosition()};"hidden"===this.element.style.visibility?this.closeTransition(r):r()}this.element.style.visibility="visible"},e.prototype.hide=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.attributes.enterable&&this.isCursorEntered(t,e)||(this.element.style.visibility="hidden")},e.prototype.initShape=function(){var t=this.attributes.template;this.element=on(t.container),this.id&&this.element.setAttribute("id",this.id)},e.prototype.renderCustomContent=function(){if(void 0===this.prevCustomContentKey||this.prevCustomContentKey!==this.attributes.contentKey){this.prevCustomContentKey=this.attributes.contentKey;var t=this.attributes.content;t&&("string"==typeof t?this.element.innerHTML=t:this.element.replaceChildren(t))}},e.prototype.renderHTMLTooltipElement=function(){var t,e,n=this.attributes,r=n.template,i=n.title,o=n.enterable,a=n.style,s=n.content,u=_F(r.prefixCls),h=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(h.innerHTML=r.title,h.getElementsByClassName(u.TITLE)[0].innerHTML=i):null===(e=null===(t=h.getElementsByClassName(u.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var d=this.HTMLTooltipItemsElements,f=document.createElement("ul");f.className=u.LIST,f.replaceChildren.apply(f,l([],c(d),!1));var p=this.element.querySelector(".".concat(u.LIST));p?p.replaceWith(f):h.appendChild(f)}!function(t,e){Object.entries(e).forEach((function(e){var n=c(e,2),r=n[0],i=n[1];l([t],c(t.querySelectorAll(r)),!1).filter((function(t){return t.matches(r)})).forEach((function(t){t&&(t.style.cssText+=Object.entries(i).reduce((function(t,e){return"".concat(t).concat(e.join(":"),";")}),""))}))}))}(h,a)},e.prototype.getRelativeOffsetFromCursor=function(t){var e=this.attributes,n=e.position,r=e.offset,i=(t||n).split("-"),o={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]},a=this.elementSize,s=a.width,u=a.height,l=[-s/2,-u/2];return i.forEach((function(t){var e=c(l,2),n=e[0],i=e[1],a=c(o[t],2),h=a[0],d=a[1];l=[n+(s/2+r[0])*h,i+(u/2+r[1])*d]})),l},e.prototype.setOffsetPosition=function(t){var e=c(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=void 0===o?0:o,s=i.y,u=void 0===s?0:s,l=i.container,h=l.x,d=l.y;this.element.style.left="".concat(+a+h+n,"px"),this.element.style.top="".concat(+u+d+r,"px")},e.prototype.updatePosition=function(){var t=this.attributes.showDelay,e=void 0===t?60:t,n=Date.now();this.timestamp>0&&n-this.timestamp<e||(this.timestamp=n,this.setOffsetPosition(this.autoPosition(this.getRelativeOffsetFromCursor())))},e.prototype.autoPosition=function(t){var e=c(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=i.y,s=i.bounding,u=i.position;if(!s)return[n,r];var l=this.element,h=l.offsetWidth,d=l.offsetHeight,f=c([+o+n,+a+r],2),p=f[0],g=f[1],m={left:"right",right:"left",top:"bottom",bottom:"top"},y=s.x,v=s.y,b={left:p<y,right:p+h>y+s.width,top:g<v,bottom:g+d>v+s.height},x=[];u.split("-").forEach((function(t){b[t]?x.push(m[t]):x.push(t)}));var w=x.join("-");return this.getRelativeOffsetFromCursor(w)},e.prototype.isCursorEntered=function(t,e){if(this.element){var n=this.element.getBoundingClientRect(),r=n.x,i=n.y,o=n.width,a=n.height;return new KL(r,i,o,a).isPointIn(t,e)}return!1},e.prototype.closeTransition=function(t){var e=this,n=this.element.style.transition;this.element.style.transition="none",t(),setTimeout((function(){e.element.style.transition=n}),10)},e.tag="tooltip",e}(Hj),LF=function(t){function e(e){var n=t.call(this,e)||this;n.layoutEvents=[as.BOUNDS_CHANGED,as.INSERTED,as.REMOVED],n.$margin=_j(0),n.$padding=_j(0);var r=e.style||{},i=r.margin,o=void 0===i?0:i,a=r.padding,s=void 0===a?0:a;return n.margin=o,n.padding=s,n.isMutationObserved=!0,n.bindEvents(),n}return r(e,t),Object.defineProperty(e.prototype,"margin",{get:function(){return this.$margin},set:function(t){this.$margin=_j(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return this.$padding},set:function(t){this.$padding=_j(t)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var t=this.attributes,e=t.x,n=void 0===e?0:e,r=t.y,i=void 0===r?0:r,o=t.width,a=t.height,s=c(this.$margin,4),u=s[0],l=s[1],h=s[2],d=s[3];return new KL(n-d,i-u,o+d+l,a+u+h)},e.prototype.appendChild=function(e,n){return e.isMutationObserved=!0,t.prototype.appendChild.call(this,e,n),e},e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=c(this.$padding,4),i=r[0],o=r[1],a=r[2],s=r[3],u=c(this.$margin,4),l=u[0],h=u[3];return new KL(s+h,i+l,e-s-o,n-i-a)},e.prototype.layout=function(){if(this.attributes.display&&this.isConnected&&!this.children.some((function(t){return!t.isConnected})))try{var t=this.attributes,e=t.x,n=t.y;this.style.transform="translate(".concat(e,", ").concat(n,")");var r=function(t,e,n){if(0===e.length)return[];var r={flex:pj,grid:gj},i=n.display in r?r[n.display]:null;return(null==i?void 0:i.call(null,t,e,n))||[]}(this.getAvailableSpace(),this.children.map((function(t){return t.getBBox()})),this.attributes);this.children.forEach((function(t,e){var n=r[e],i=n.x,o=n.y;t.style.transform="translate(".concat(i,", ").concat(o,")")}))}catch(t){}},e.prototype.bindEvents=function(){var t=this;this.layoutEvents.forEach((function(e){t.addEventListener(e,(function(e){e.target.isMutationObserved=!0,t.layout()}))}))},e.prototype.attributeChangedCallback=function(t,e,n){"margin"===t?this.margin=n:"padding"===t&&(this.padding=n),this.layout()},e}(Vs),jF=function(t){function e(n){var r=t.call(this,tj({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new Ks({})),r.label=r.background.appendChild(new Vs({})),r}return r(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return _j(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=Bj(this.attributes,"label");Oj(this.label).maybeAppend(".label",(function(){return uj(e)})).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=c(this.padding,4),n=e[0],r=e[1],o=e[2],a=e[3],s=t.width,u=t.height,l=s+a+r,h=u+n+o,d=Bj(this.attributes,"background"),f=this.style,p=f.width,g=void 0===p?0:p,m=f.height,y=void 0===m?0:m,v=f.selected;this.background.attr(i(i({},d),{width:Math.max(l,g),height:Math.max(h,y),fill:v?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(a,", ").concat((h-u)/2,")")})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",(function(){t.style.selected||t.background.attr("fill",t.hoverColor)})),this.addEventListener("pointerleave",(function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)}));var e=this;this.addEventListener("click",(function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)}))},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(Hj),BF=function(t){function e(n){var r,i,o=t.call(this,tj({},e.defaultOptions,n))||this;o.currentValue=null===(r=e.defaultOptions.style)||void 0===r?void 0:r.defaultValue,o.isPointerInSelect=!1,o.select=o.appendChild(new Ks({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new Ks({className:"dropdown"}));var a=o.style.defaultValue;return a&&(null===(i=o.style.options)||void 0===i?void 0:i.some((function(t){return t.value===a})))&&(o.currentValue=a),o}return r(e,t),e.prototype.setValue=function(t){this.currentValue=t,this.render()},e.prototype.getValue=function(){return this.currentValue},Object.defineProperty(e.prototype,"dropdownPadding",{get:function(){return _j(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.x,o=n.y,a=n.width,s=n.height,u=n.bordered,c=n.showDropdownIcon,l=Bj(this.attributes,"select"),h=Bj(this.attributes,"placeholder");this.select.attr(i(i({x:r,y:o,width:a,height:s},l),{fill:"#fff",strokeWidth:u?1:0}));var d=this.dropdownPadding;c&&Oj(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r+a-10-d[1]-d[3],", ").concat(o+s/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var f=null===(t=this.style.options)||void 0===t?void 0:t.find((function(t){return t.value===e.currentValue})),p=i({x:r+d[3]},h);Oj(this.select).selectAll(".placeholder").data(f?[]:[1]).join((function(t){return t.append("text").attr("className","placeholder").styles(p).style("y",(function(){var t=this.getBBox();return o+(s-t.height)/2}))}),(function(t){return t.styles(p)}),(function(t){return t.remove()}));var g=Bj(this.attributes,"optionLabel"),m=i({x:r+d[3]},g);Oj(this.select).selectAll(".value").data(f?[f]:[]).join((function(t){return t.append((function(t){return uj(t.label)})).attr("className","value").styles(m).style("y",(function(){var t=this.getBBox();return o+(s-t.height)/2}))}),(function(t){return t.styles(m)}),(function(t){return t.remove()}))},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,o=r.x,a=r.y,s=r.width,u=r.height,c=r.options,l=r.onSelect,h=r.open,d=Bj(this.attributes,"dropdown"),f=Bj(this.attributes,"option"),p=this.dropdownPadding;Oj(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(c,(function(t){return t.value})).join((function(t){return t.append((function(t){return new jF({className:"dropdown-item",style:i(i(i({},t),f),{width:s-p[1]-p[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==l||l(t,e,r),n.dispatchEvent(new es("change",{detail:{value:t,option:e,item:r}})),VL(n.dropdown)}})})})).each((function(t,e){var n,r=(null===(n=this.parentNode)||void 0===n?void 0:n.children).reduce((function(t,n,r){return r<e&&(t+=n.getBBox().height),t}),0);this.attr("transform","translate(".concat(p[3],", ").concat(p[0]+r,")"))}))}),(function(t){return t.update((function(t){return{selected:t.value===n.currentValue}}))}),(function(t){return t.remove()}));var g=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),m=d.spacing;this.dropdown.attr(i({transform:"translate(".concat(o,", ").concat(a+u+m,")"),width:g.width+p[1]+p[3],height:g.height+p[0]+p[2]},d)),!h&&VL(this.dropdown)},e.prototype.render=function(){this.renderSelect(),this.renderDropdown()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("click",(function(t){t.stopPropagation()})),this.select.addEventListener("click",(function(){"visible"===t.dropdown.style.visibility?VL(t.dropdown):GL(t.dropdown)})),this.addEventListener("pointerenter",(function(){t.isPointerInSelect=!0})),this.addEventListener("pointerleave",(function(){t.isPointerInSelect=!1})),null===document||void 0===document||document.addEventListener("click",(function(){t.isPointerInSelect||VL(t.dropdown)}))},e.defaultOptions={style:{x:0,y:0,width:140,height:32,options:[],bordered:!0,defaultValue:"",selectRadius:8,selectStroke:"#d9d9d9",showDropdownIcon:!0,placeholderText:"请选择",placeholderFontSize:12,placeholderTextBaseline:"top",placeholderFill:"#c2c2c2",dropdownFill:"#fff",dropdownStroke:"#d9d9d9",dropdownRadius:8,dropdownShadowBlur:4,dropdownShadowColor:"rgba(0, 0, 0, 0.08)",dropdownPadding:8,dropdownSpacing:10,optionPadding:[8,12],optionFontSize:12,optionTextBaseline:"top",optionBackgroundFill:"#fff",optionBackgroundRadius:4,optionLabelFontSize:12,optionLabelTextBaseline:"top"}},e}(Hj),zF=function(t){function e(n){var r=t.call(this,tj({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new Ks({})),r.icon=r.appendChild(new Vs({})),r}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"BaseIcon"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return Math.log10(this.attributes.size)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return _j(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=c(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3];return Math.max(t-Math.max(o+r,n+i),2*this.lineWidth+1)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.size,o=r/2,a=Bj(this.attributes,"background");this.background.attr(i({x:e-o,y:n-o,width:r,height:r},a))},e.prototype.showIndicator=function(){if(this.label){var t=this.attributes.size,e=this.background.getBBox(),n=e.x,r=e.y;this.indicator.update({x:n+t/2,y:r-5,labelText:this.label,visibility:"visible"})}},e.prototype.hideIndicator=function(){this.indicator.update({visibility:"hidden"})},e.prototype.connectedCallback=function(){var e;t.prototype.connectedCallback.call(this);var n=this.attributes.size,r=this.background.getBBox(),i=r.x,o=r.y,a=null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView;a&&(this.indicator=a.appendChild(new OF({style:{x:i+n/2,y:o-n/2,visibility:"hidden",position:"top",radius:3,zIndex:100}})))},e.prototype.disconnectedCallback=function(){this.indicator.destroy()},e.prototype.render=function(){this.renderIcon(),this.showBackground&&this.renderBackground()},e.prototype.bindEvents=function(){var t=this,n=this.attributes.onClick;if(this.addEventListener("click",(function(){null==n||n(t)})),this.showBackground){var r=function(){return t.background.attr({opacity:e.backgroundOpacities.default})};this.addEventListener("pointerenter",(function(){t.background.attr({opacity:e.backgroundOpacities.hover}),t.showIndicator()})),this.addEventListener("pointerleave",(function(){r(),t.hideIndicator()})),this.addEventListener("pointerdown",(function(){t.background.attr({opacity:e.backgroundOpacities.active})})),this.addEventListener("pointerup",(function(){r()}))}},e.tag="IconBase",e.defaultOptions={style:{x:0,y:0,size:10,color:"#565758",backgroundRadius:4,backgroundFill:"#e2e2e2"}},e.backgroundOpacities={default:0,hover:.8,active:1},e}(Hj),FF=function(t,e){return void 0===e&&(e="#565758"),new $s({style:{fill:e,d:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},GF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.arcPath=function(t,e,n){var r=c([n,n],2),i=r[0],o=r[1],a=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=c(a(-5/4*Math.PI),2),u=s[0],l=s[1],h=c(a(1/4*Math.PI),2),d=h[0],f=h[1];return"M".concat(u,",").concat(l,",A").concat(i,",").concat(o,",0,1,1,").concat(d,",").concat(f)},Object.defineProperty(e.prototype,"label",{get:function(){return"重置"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o+.5;Oj(this.icon).maybeAppend(".reset","path").styles({stroke:r,lineWidth:o,d:this.arcPath(e,n,i/2-o),markerStart:FF(a,r)})},e}(zF),VF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e-o,n],[e,n+a],[e,n],[e+o,n-a],[e+o,n+a],[e,n]];Oj(this.icon).maybeAppend(".backward","polygon").styles({points:s,fill:r})},e}(zF),WF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e+o,n],[e,n+a],[e,n],[e-o,n-a],[e-o,n+a],[e,n]];Oj(this.icon).maybeAppend(".forward","polygon").styles({points:s,fill:r})},e}(zF),HF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3*Math.pow(3,.5)*.8,a=[[e+o,n],[e-o/2,n-i/2*.8],[e-o/2,n+i/2*.8],[e+o,n]];Oj(this.icon).maybeAppend(".play","polygon").styles({points:a,fill:r})},e}(zF),UF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3,a=[[e-o,n-i/2],[e-o,n+i/2],[e-o/2,n+i/2],[e-o/2,n-i/2],[e-o,n-i/2],[e+o/2,n-i/2],[e+o/2,n+i/2],[e+o,n+i/2],[e+o,n-i/2]];Oj(this.icon).maybeAppend(".pause","polygon").styles({points:a,fill:r})},e}(zF),$F=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o;Oj(this.icon).maybeAppend(".left-line","line").styles({x1:e-i/2,y1:n-i/2,x2:e-i/2,y2:n+i/2,stroke:r,lineWidth:o}),Oj(this.icon).maybeAppend(".right-line","line").styles({x1:e+i/2,y1:n-i/2,x2:e+i/2,y2:n+i/2,stroke:r,lineWidth:o}),Oj(this.icon).maybeAppend(".left-arrow","line").styles({x1:e,y1:n,x2:e-i/2+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:FF(2*o,r)}),Oj(this.icon).maybeAppend(".right-arrow","line").styles({x1:e,y1:n,x2:e+i/2-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:FF(2*o,r)})},e}(zF),qF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;Oj(this.icon).maybeAppend(".line","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o});var a=o;Oj(this.icon).maybeAppend(".left-arrow","line").styles({x1:e-i/2-2*a,y1:n,x2:e-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:FF(2*o,r)}),Oj(this.icon).maybeAppend(".right-arrow","line").styles({x1:e+i/2+2*a,y1:n,x2:e+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:FF(2*o,r)})},e}(zF),YF=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},KF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=(i-2*o-o)/4,s=(i-2*o-o)/2,u=c([e-i/2+o,n+i/2-2*o],2),l=u[0],h=u[1];Oj(this.icon).maybeAppend(".coordinate","polyline").styles({points:YF(i).map((function(t){var r=c(t,2),i=r[0],o=r[1];return[i+e,o+n]})),stroke:r,lineWidth:o}),Oj(this.icon).maybeAppend(".line","polyline").styles({points:[[l,h],[l+a,h-s],[l+2*a,h],[l+4*a,h-2*s]],stroke:r,lineWidth:o})},e}(zF),XF=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"条形图"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return[1,4,2,4,3]},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.data,e=this.attributes,n=e.x,r=e.y,i=e.color,o=this.iconSize,a=this.lineWidth,s=a,u=(o-s)/t.length,l=(o-2*s)/4,h=c([n-o/2+2*s,r+o/2-s],2),d=h[0],f=h[1];Oj(this.icon).maybeAppend(".coordinate","polyline").styles({points:YF(o).map((function(t){var e=c(t,2),i=e[0],o=e[1];return[i+n,o+r]})),stroke:i,lineWidth:a}),Oj(this.icon).maybeAppend(".bars","g").selectAll(".column").data(this.data.map((function(t,e){return{value:t,index:e}}))).join((function(t){return t.append("line").attr("className","column").style("x1",(function(t){var e=t.index;return d+u*e})).style("y1",f).style("x2",(function(t){var e=t.index;return d+u*e})).style("y2",(function(t){var e=t.value;return f-l*e})).styles({y1:f,stroke:i,lineWidth:a})}))},e}(zF),ZF=function(t){function e(e){var n=t.call(this,tj({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return r(e,t),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;Oj(this.icon).maybeAppend(".split","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o})},e}(zF),QF=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.showBackground=!1,e}return r(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return _j(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes,n=e.x,r=e.y,o=e.speed,a=void 0===o?1:o,s=ye(this.attributes,["x","y","transform","transformOrigin","width","height","size","color","speed"]),u=Ut(t,20,1/0),c=i(i({},s),{x:n-u/2,y:r-10,width:u,height:20,defaultValue:a,bordered:!1,showDropdownIcon:!1,selectRadius:2,dropdownPadding:this.padding,dropdownRadius:2,dropdownSpacing:t/5,placeholderFontSize:t/2,optionPadding:0,optionLabelFontSize:t/2,optionBackgroundRadius:1,options:[{label:"1x",value:1},{label:"1.5x",value:1.5},{label:"2x",value:2}]});Oj(this.icon).maybeAppend(".speed",(function(){return new BF({style:c})})).attr("className","speed").each((function(){this.update(c)}))},e.tag="SpeedSelect",e}(zF),JF=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new Vs({})),n.currentType=n.attributes.type,n}return r(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.onChange;var n=o(e,["onChange"]);Oj(this.icon).selectAll(".icon").data([this.currentType]).join((function(e){return e.append((function(e){var n,r=null===(n=t.toggles.find((function(t){return c(t,1)[0]===e})))||void 0===n?void 0:n[1];if(!r)throw new Error("Invalid type: ".concat(e));return new r({})})).attr("className","icon").styles(n,!1).update({})}),(function(t){return t.styles({restStyles:n}).update({})}),(function(t){return t.remove()}))},e.prototype.bindEvents=function(){var t=this,e=this.attributes.onChange;this.addEventListener("click",(function(n){n.preventDefault(),n.stopPropagation();var r=(t.toggles.findIndex((function(e){return c(e,1)[0]===t.currentType}))+1)%t.toggles.length,i=t.toggles[r][0];null==e||e(t.currentType),t.currentType=i,t.render()}))},e.tag="ToggleIcon",e}(Hj),tG=function(t){function e(e){var n=t.call(this,tj({},{style:{type:"play"}},e))||this;return n.toggles=[["play",HF],["pause",UF]],n}return r(e,t),e}(JF),eG=function(t){function e(e){var n=t.call(this,tj({},{style:{type:"range"}},e))||this;return n.toggles=[["range",$F],["value",qF]],n}return r(e,t),e}(JF),nG=function(t){function e(e){var n=t.call(this,tj({},{style:{type:"column"}},e))||this;return n.toggles=[["line",KF],["column",XF]],n}return r(e,t),e}(JF),rG={reset:GF,speed:QF,backward:VF,playPause:tG,forward:WF,selectionType:eG,chartType:nG,split:ZF},iG=function(t){function e(n){var r=t.call(this,tj({},e.defaultOptions,n))||this;return r.background=r.appendChild(new Ks({})),r.functions=r.appendChild(new Vs({})),r}return r(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return _j(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.x,n=t.y,r=t.width,o=t.height,a=Bj(this.attributes,"background");this.background.attr(i({x:e,y:n,width:r,height:o},a))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,o=n.iconSize,a=n.iconSpacing,s=n.x,u=n.y,h=n.width,d=n.height,f=n.align,p=c(this.padding,4),g=p[1],m=p[3],y=r.reduce((function(t,e){return t.length&&e.length?t.concat.apply(t,l(["split"],c(e),!1)):t.concat.apply(t,l([],c(e),!1))}),[]),v=y.length*(o+a)-a,b={left:m+o/2,center:(h-v)/2+o/2,right:h-v-m-g+o/2}[f]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),y.forEach((function(t,n){var r,c=rG[t],l={x:s+n*(o+a)+b,y:u+d/2,size:o};if(c===QF?(l.speed=e.attributes.speed,l.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[tG,eG,nG].includes(c)?(l.onChange=function(n){return e.handleFunctionChange(t,{value:n})},c===tG&&(l.type="play"===e.attributes.state?"pause":"play"),c===eG&&(l.type="range"===e.attributes.selectionType?"value":"range"),c===nG&&(l.type="line"===e.attributes.chartType?"column":"line")):l.onClick=function(){return e.handleFunctionChange(t,{value:t})},c===QF){var h=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;h&&(e.speedSelect=new c({style:i(i({},l),{zIndex:100})}),h.appendChild(e.speedSelect))}else e.functions.appendChild(new c({style:l}))}))},e.prototype.disconnectedCallback=function(){var e;t.prototype.disconnectedCallback.call(this),null===(e=this.speedSelect)||void 0===e||e.destroy()},e.prototype.render=function(){this.renderBackground(),this.renderFunctions()},e.prototype.handleFunctionChange=function(t,e){var n=this.attributes.onChange;null==n||n(t,e)},e.defaultOptions={style:{x:0,y:0,width:300,height:40,padding:0,align:"center",iconSize:25,iconSpacing:0,speed:1,state:"pause",chartType:"line",selectionType:"range",backgroundFill:"#fbfdff",backgroundStroke:"#ebedf0",functions:[["reset","speed"],["backward","playPause","forward"],["selectionType","chartType"]]}},e}(Hj),oG=function(t){function e(n){var r=t.call(this,tj({},e.defaultOptions,n))||this;return r.bindEvents(),r}return r(e,t),e.prototype.bindEvents=function(){var t=this;this.addEventListener("mouseenter",(function(){t.attr("lineWidth",Math.ceil(+(t.style.r||0)/2))})),this.addEventListener("mouseleave",(function(){t.attr("lineWidth",0)}))},e.defaultOptions={style:{r:5,fill:"#3f7cf7",lineWidth:0,stroke:"#3f7cf7",strokeOpacity:.5,cursor:"pointer"}},e}(zs),aG=function(t){function e(n){return t.call(this,tj({},e.defaultOptions,n))||this}return r(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,o=t.height,a=Bj(this.attributes,"background");Oj(this).maybeAppend("background","rect").attr("className","background").styles(i({x:e-r/2,y:n-o/2,width:r,height:o},a))},e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.iconSize,o=Bj(this.attributes,"icon"),a=r/2;Oj(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(i({x1:e-1,y1:n-a,x2:e-1,y2:n+a},o)),Oj(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(i({x1:e+1,y1:n-a,x2:e+1,y2:n+a},o))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,o=t.height,a=t.type,s=Bj(this.attributes,"border"),u="start"===a?+r/2:-r/2;Oj(this).maybeAppend("border","line").attr("className","border").styles(i({x1:u+e,y1:n-o/2,x2:u+e,y2:n+o/2},s))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{x:0,y:0,width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(Hj);function sG(t,e){return"number"==typeof t?uG(t):function(t,e){var n=new Date(t);switch(e){case"half-hour":case"hour":case"four-hour":return[0,6,12,18].includes(n.getHours())&&0===n.getMinutes()?Gj(n,"HH:mm\nYYYY-MM-DD"):Gj(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(Gj(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?Gj(n,"DD\nYYYY-MM"):Gj(n,"DD");case"week":return n.getDate()<=7?Gj(n,"DD\nYYYY-MM"):Gj(n,"DD");case"month":return[0,6].includes(n.getMonth())?Gj(n,"MM月\nYYYY"):Gj(n,"MM月");case"season":return[0].includes(n.getMonth())?Gj(n,"MM月\nYYYY"):Gj(n,"MM月");case"year":return Gj(n,"YYYY");default:return Gj(n,"YYYY-MM-DD HH:mm")}}(t,e)}function uG(t){var e=String(Math.floor(t/3600)).padStart(2,"0"),n=String(Math.floor(t%3600/60)).padStart(2,"0"),r=String(Math.floor(t%60)).padStart(2,"0");return t<3600?"".concat(n,":").concat(r):"".concat(e,":").concat(n,":").concat(r)}var cG=function(t){function e(n){var r=t.call(this,tj({},e.defaultOptions,n))||this;r.axis=r.appendChild(new pF({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new fz({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new iG({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?l([],c(e),!1):e);r.setBySliderValues(t),r.dispatchOnChange(n)};var i=r.attributes,o=i.selectionType,a=i.chartType,s=i.speed,u=i.state,h=i.playMode,d=i.values;return r.states={chartType:a,playMode:h,selectionType:o,speed:s,state:u},r.setByTimebarValues(d),r}return r(e,t),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.data.sort((function(t,e){return t.time<e.time?-1:t.time>e.time?1:0}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"space",{get:function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,a=t.controllerHeight,s=Ut(+i-a,0,+i),u=new KL(e,n+ +i-a,+r,a),c=0,l="time"===o?10:s;return{axisBBox:"chart"===o?new KL(e,n+s-(c=35),+r,c):new KL,controllerBBox:u,timelineBBox:new KL(e,n+("time"===o?s:s-l),+r,l-c)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=c(Array.isArray(t)?t:[0,t],2),o=i[0],a=i[1],s=r.length,u=r[Math.floor(o*s)],l=r[Math.ceil(a*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==u?void 0:u.time)&&void 0!==e?e:r[0].time,null!==(n=null==l?void 0:l.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=c(Array.isArray(t)?t:[void 0,t],2),a=o[0],s=o[1],u=i.find((function(t){return t.time===a})),l=i.find((function(t){return t.time===s}));this.states.values=[null!==(e=null==u?void 0:u.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==l?void 0:l.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,a=c(t,2),s=a[0],u=a[1];this.states.values=[null!==(n=null===(e=o[s])||void 0===e?void 0:e.time)&&void 0!==n?n:o[0].time,null!==(i=null===(r=this.data[u])||void 0===r?void 0:r.time)&&void 0!==i?i:1/0]},Object.defineProperty(e.prototype,"sliderValues",{get:function(){var t,e=this.states,n=e.values,r=e.selectionType,i=c(Array.isArray(n)?n:[void 0,n],2),o=i[0],a=i[1],s=this.data,u=s.length,l="value"===r;return[(t=s.findIndex((function(t){return t.time===o})),l?0:t>-1?t/u:0),function(){if(a===1/0)return 1;var t=s.findIndex((function(t){return t.time===a}));return t>-1?t/u:l?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=c(Array.isArray(e)?e:[this.data[0].time,e],2),i=r[0],o=r[1];return"value"===n?o:[i,o]},enumerable:!1,configurable:!0}),e.prototype.getDatumByRatio=function(t){var e=this.data,n=e.length;return e[Math.floor(t*(n-1))]},Object.defineProperty(e.prototype,"chartHandleIconShape",{get:function(){var t=this.states.selectionType,e=this.space.timelineBBox.height;return"range"===t?function(t){return new aG({style:{type:t,height:e,iconSize:e/6}})}:function(){return new Us({style:{x1:0,y1:-e/2,x2:0,y2:e/2,lineWidth:2,stroke:"#c8c8c8"}})}},enumerable:!1,configurable:!0}),e.prototype.getChartStyle=function(t){var e=this,n=t.x,r=t.y,a=t.width,s=t.height,u=this.states,c=u.selectionType,l=u.chartType,h=this.data,d=this.attributes,f=d.type,p=d.labelFormatter,g=Bj(this.attributes,"chart");g.type;var m=o(g,["type"]),y="range"===c;if("time"===f)return i({handleIconShape:function(){return new oG({})},selectionFill:"#2e7ff8",selectionFillOpacity:1,showLabelOnInteraction:!0,handleLabelDy:y?-15:0,autoFitLabel:y,handleSpacing:y?-15:0,trackFill:"#edeeef",trackLength:a,trackOpacity:.5,trackRadius:s/2,trackSize:s/2,type:c,values:this.sliderValues,formatter:function(t){if(p)return p(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?uG(n):Gj(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},m);var v="range"===c?5:0,b=h.map((function(t){return t.value}));return i({handleIconOffset:v,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:b,sparklineType:l,sparklineScale:.8,trackLength:a,trackSize:s,type:c,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},m)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,o=n.labelFormatter,a=Bj(this.attributes,"axis"),s=t.x,u=t.y,h=t.width,d=l(l([],c(e),!1),[{time:0}],!1).map((function(t,e,n){var r=t.time;return{label:"".concat(r),value:e/(n.length-1),time:r}})),f=i({startPos:[s,u],endPos:[s+h,u],data:d,labelFilter:function(t,e){return e<d.length-1},labelFormatter:function(t){var e=t.time;return o?o(e):sG(e,r)}},a);return f},e.prototype.renderAxis=function(t){void 0===t&&(t=this.space.axisBBox),"chart"===this.attributes.type&&this.axis.update(this.getAxisStyle(t))},e.prototype.renderController=function(t){void 0===t&&(t=this.space.controllerBBox);var e=this.attributes.type,n=this.states,r=n.state,o=n.speed,a=n.selectionType,s=n.chartType,u=Bj(this.attributes,"controller"),c=this,l=i(i(i({},t),{iconSize:20,speed:o,state:r,selectionType:a,chartType:s,onChange:function(t,e){var n=e.value;switch(t){case"reset":c.internalReset();break;case"speed":c.handleSpeedChange(n);break;case"backward":c.internalBackward();break;case"playPause":"play"===n?c.internalPlay():c.internalPause();break;case"forward":c.internalForward();break;case"selectionType":c.handleSelectionTypeChange(n);break;case"chartType":c.handleChartTypeChange(n)}}}),u);"time"===e&&(l.functions=[["reset","speed"],["backward","playPause","forward"],["selectionType"]]),this.controller.update(l)},e.prototype.dispatchOnChange=function(t){var e=this.data,n=this.attributes.onChange,r=this.states,i=r.values,o=r.selectionType,a=c(i,2),s=a[0],u=a[1],l=u===1/0?e.at(-1).time:u;t&&function(t,e){if(Array.isArray(t)){if(!Array.isArray(e))return!1;if(t[0]===e[0]){if(t[1]===e[1])return!0;if(t[1]===1/0||e[1]===1/0)return!0}return!1}return!Array.isArray(e)&&t===e}(t,"range"===o?[s,l]:l)||null==n||n("range"===o?[s,l]:l)},e.prototype.internalReset=function(t){var e,n,r=this.states.selectionType;this.internalPause(),this.setBySliderValues("range"===r?[0,1]:[0,0]),this.renderController(),this.updateSelection(),t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onReset)||void 0===n||n.call(e),this.dispatchOnChange())},e.prototype.reset=function(){this.internalReset()},e.prototype.moveSelection=function(t,e){var n=this.data,r=n.length,i=this.states,o=i.values,a=i.selectionType,s=i.playMode,u=c(o,2),l=u[0],h=u[1],d=n.findIndex((function(t){return t.time===l})),f=n.findIndex((function(t){return t.time===h}));-1===f&&(f=r);var p,g="backward"===t?-1:1;"range"===a?"acc"===s?(p=[d,f+g],-1===g&&d===f&&(p=[d,r])):p=[d+g,f+g]:p=[d,f+g];var m=function(t){var e=c(t.sort((function(t,e){return t-e})),2),n=e[0],i=e[1],o=function(t){return Ut(t,0,r)};return i>r?"value"===a?[0,0]:"acc"===s?[o(n),o(n)]:[0,o(i-n)]:n<0?"acc"===s?[0,o(i)]:[o(n+r-i),r]:[o(n),o(i)]}(p);return this.setByIndex(m),this.updateSelection(),m},e.prototype.internalBackward=function(t){var e,n,r=this.moveSelection("backward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onBackward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.backward=function(){this.internalBackward()},e.prototype.internalPlay=function(t){var e,n,r=this,i=this.data,o=this.attributes.loop,a=this.states.speed,s=void 0===a?1:a;this.playInterval=window.setInterval((function(){r.internalForward()[1]!==i.length||o||(r.internalPause(),r.renderController())}),1e3/s),this.states.state="play",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPlay)||void 0===n||n.call(e))},e.prototype.play=function(){this.internalPlay()},e.prototype.internalPause=function(t){var e,n;clearInterval(this.playInterval),this.states.state="pause",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPause)||void 0===n||n.call(e))},e.prototype.pause=function(){this.internalPause()},e.prototype.internalForward=function(t){var e,n,r=this.moveSelection("forward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onForward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.forward=function(){this.internalForward()},e.prototype.handleSpeedChange=function(t){var e,n;this.states.speed=t,"play"===this.states.state&&(this.internalPause(!0),this.internalPlay(!0)),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSpeedChange)||void 0===n||n.call(e,t)},e.prototype.handleSelectionTypeChange=function(t){var e,n;this.states.selectionType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSelectionTypeChange)||void 0===n||n.call(e,t)},e.prototype.handleChartTypeChange=function(t){var e,n;this.states.chartType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onChartTypeChange)||void 0===n||n.call(e,t)},e.prototype.render=function(){var t=this.space,e=t.axisBBox,n=t.controllerBBox,r=t.timelineBBox;this.renderController(n),this.renderAxis(e),this.renderChart(r),"play"===this.states.state&&this.internalPlay()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.internalPause(!0)},e.defaultOptions={style:{x:0,y:0,axisLabelFill:"#6e6e6e",axisLabelTextAlign:"left",axisLabelTextBaseline:"top",axisLabelTransform:"translate(5, -12)",axisLineLineWidth:1,axisLineStroke:"#cacdd1",axisTickLength:15,axisTickLineWidth:1,axisTickStroke:"#cacdd1",chartShowLabel:!1,chartType:"line",controllerAlign:"center",controllerHeight:40,data:[],interval:"day",loop:!1,playMode:"acc",selectionType:"range",type:"time"}},e}(Hj);class lG extends pD{static defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16};typePrefix="__data__";element=null;draw=!1;fieldMap={node:new Map,edge:new Map,combo:new Map};selectedItems=[];constructor(t,e){super(t,Object.assign({},lG.defaultOptions,e)),this.bindEvents()}update(t){super.update(t),this.clear(),this.createElement()}clear(){this.element?.destroy(),this.element=null,this.draw=!1}bindEvents=()=>{const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.createElement)};changeState=(t,e)=>{const{graph:n}=this.context,{typePrefix:r}=this,i=fe(t,[r,"id"]),o=fe(t,[r,"style","labelText"]),[a]=i.split("__"),s=this.fieldMap[a].get(o)||[];n.setElementState(Object.fromEntries(s?.map((t=>[t,e]))))};click=t=>{if("hover"===this.options.trigger)return;const e=fe(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?(this.selectedItems=this.selectedItems.filter((t=>t!==e)),this.changeState(t,[])):(this.selectedItems.push(e),this.changeState(t,"selected"))};mouseleave=t=>{"click"!==this.options.trigger&&(this.selectedItems=[],this.changeState(t,[]))};mouseenter=t=>{if("click"===this.options.trigger)return;const e=fe(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?this.selectedItems=this.selectedItems.filter((t=>t!==e)):(this.selectedItems.push(e),this.changeState(t,"active"))};updateElement(){if(!this.element)return;this.element.getChildByIndex(0).update({itemMarkerOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5,itemLabelOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5})}setFieldMap=(t,e,n)=>{if(!t)return;const r=this.fieldMap[n];if(r)if(r.has(t)){const n=r.get(t);n&&(n.push(e),r.set(t,n))}else r.set(t,[e])};getEvents=()=>({mouseenter:this.mouseenter,mouseleave:this.mouseleave,click:this.click});getMarkerData=(t,e)=>{if(!t)return[];const{model:n,element:r,graph:i}=this.context,{nodes:o,edges:a,combos:s}=n.getData(),u={},c=e=>Ot(t)?t(e):t,l={node:"circle",edge:"line",combo:"rect"},h={circle:"circle",ellipse:"circle",image:"bowtie",rect:"square",star:"cross",triangle:"triangle",diamond:"diamond",cubic:"dot",line:"hyphen",polyline:"hyphen",quadratic:"hv","cubic-horizontal":"hyphen","cubic-vertical":"line"},d=(t,e)=>{t.forEach((t=>{const{id:n}=t,i=fe(t,["data",c(t)]),o=r?.getElementType(e,t)||"circle",a=((t,e)=>{const n=r?.getElementComputedStyle(t,e);return n})(e,t),s=("edge"===e?a?.stroke:a?.fill)||"#1783ff";n&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),u[i]||(u[i]={id:`${e}__${n}`,label:i,marker:h[o]||l[e],elementType:e,lineWidth:1,stroke:s,fill:s}))}))};switch(e){case"node":d(o,"node");break;case"edge":d(a,"edge");break;case"combo":d(s,"combo");break;default:return[]}return Object.values(u)};layout=t=>{let{flexDirection:e,alignItems:n,justifyContent:r}={flexDirection:"row",alignItems:"flex-end",justifyContent:"center"};const i={top:["row","flex-start","center"],bottom:["row","flex-end","center"],left:["column","flex-start","center"],right:["column","flex-end","center"]};return t in i&&([e,n,r]=i[t]),{display:"flex",flexDirection:e,justifyContent:r,alignItems:n}};createElement=()=>{if(this.draw)return void this.updateElement();const{canvas:t}=this.context,[e,n]=t.getSize(),{width:r=e,height:i=n,nodeField:o,edgeField:a,comboField:s,trigger:u,position:c,...l}=this.options,h=this.getMarkerData(o,"node"),d=this.getMarkerData(a,"edge"),f=this.getMarkerData(s,"combo"),p=[...h,...f,...d],g=this.layout(c),m=new LF({style:{width:r,height:i,...g}}),y=Object.assign({width:r,height:i,data:p,itemMarkerLineWidth:({lineWidth:t})=>t,itemMarker:({marker:t})=>t,itemMarkerStroke:({stroke:t})=>t,itemMarkerFill:({fill:t})=>t,gridCol:h.length},l,this.getEvents()),v=new TF({className:"legend",style:y});m.appendChild(v),t.appendChild(m),this.element=m,this.draw=!0};destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}function hG(t,e){var n=e.cx,r=void 0===n?0:n,i=e.cy,o=void 0===i?0:i,a=e.r;t.arc(r,o,a,0,2*Math.PI,!1)}function dG(t,e){var n=e.cx,r=void 0===n?0:n,i=e.cy,o=void 0===i?0:i,a=e.rx,s=e.ry;if(t.ellipse)t.ellipse(r,o,a,s,0,0,2*Math.PI,!1);else{var u=a>s?a:s,c=a>s?1:a/s,l=a>s?s/a:1;t.save(),t.scale(c,l),t.arc(r,o,u,0,2*Math.PI)}}function fG(t,e){var n,r,i=e.x1,o=e.y1,a=e.x2,s=e.y2,u=e.markerStart,c=e.markerEnd,l=e.markerStartOffset,h=e.markerEndOffset,d=0,f=0,p=0,g=0,m=0;u&&Ps(u)&&l&&(n=a-i,r=s-o,m=Math.atan2(r,n),d=Math.cos(m)*(l||0),f=Math.sin(m)*(l||0)),c&&Ps(c)&&h&&(n=i-a,r=o-s,m=Math.atan2(r,n),p=Math.cos(m)*(h||0),g=Math.sin(m)*(h||0)),t.moveTo(i+d,o+f),t.lineTo(a+p,s+g)}function pG(t,e){var n,r,i=e.markerStart,o=e.markerEnd,a=e.markerStartOffset,s=e.markerEndOffset,u=e.d,l=u.absolutePath,h=u.segments,d=0,f=0,p=0,g=0,m=0;if(i&&Ps(i)&&a){var y=c(i.parentNode.getStartTangent(),2),v=y[0],b=y[1];n=v[0]-b[0],r=v[1]-b[1],m=Math.atan2(r,n),d=Math.cos(m)*(a||0),f=Math.sin(m)*(a||0)}if(o&&Ps(o)&&s){var x=c(o.parentNode.getEndTangent(),2);v=x[0],b=x[1];n=v[0]-b[0],r=v[1]-b[1],m=Math.atan2(r,n),p=Math.cos(m)*(s||0),g=Math.sin(m)*(s||0)}for(var w=0;w<l.length;w++){var E=l[w],M=E[0],S=l[w+1],N=0===w&&(0!==d||0!==f),k=(w===l.length-1||S&&("M"===S[0]||"Z"===S[0]))&&0!==p&&0!==g;switch(M){case"M":N?(t.moveTo(E[1]+d,E[2]+f),t.lineTo(E[1],E[2])):t.moveTo(E[1],E[2]);break;case"L":k?t.lineTo(E[1]+p,E[2]+g):t.lineTo(E[1],E[2]);break;case"Q":t.quadraticCurveTo(E[1],E[2],E[3],E[4]),k&&t.lineTo(E[3]+p,E[4]+g);break;case"C":t.bezierCurveTo(E[1],E[2],E[3],E[4],E[5],E[6]),k&&t.lineTo(E[5]+p,E[6]+g);break;case"A":var C=h[w].arcParams,T=C.cx,A=C.cy,P=C.rx,O=C.ry,_=C.startAngle,R=C.endAngle,I=C.xRotation,D=C.sweepFlag;if(t.ellipse)t.ellipse(T,A,P,O,I,_,R,!!(1-D));else{var L=P>O?P:O,j=P>O?1:P/O,B=P>O?O/P:1;t.translate(T,A),t.rotate(I),t.scale(j,B),t.arc(0,0,L,_,R,!!(1-D)),t.scale(1/j,1/B),t.rotate(-I),t.translate(-T,-A)}k&&t.lineTo(E[6]+p,E[7]+g);break;case"Z":t.closePath()}}}function gG(t,e){var n,r,i=e.markerStart,o=e.markerEnd,a=e.markerStartOffset,s=e.markerEndOffset,u=e.points.points,c=u.length,l=u[0][0],h=u[0][1],d=u[c-1][0],f=u[c-1][1],p=0,g=0,m=0,y=0,v=0;i&&Ps(i)&&a&&(n=u[1][0]-u[0][0],r=u[1][1]-u[0][1],v=Math.atan2(r,n),p=Math.cos(v)*(a||0),g=Math.sin(v)*(a||0)),o&&Ps(o)&&s&&(n=u[c-1][0]-u[0][0],r=u[c-1][1]-u[0][1],v=Math.atan2(r,n),m=Math.cos(v)*(s||0),y=Math.sin(v)*(s||0)),t.moveTo(l+(p||m),h+(g||y));for(var b=1;b<c-1;b++){var x=u[b];t.lineTo(x[0],x[1])}t.lineTo(d,f)}function mG(t,e){var n,r,i=e.markerStart,o=e.markerEnd,a=e.markerStartOffset,s=e.markerEndOffset,u=e.points.points,c=u.length,l=u[0][0],h=u[0][1],d=u[c-1][0],f=u[c-1][1],p=0,g=0,m=0,y=0,v=0;i&&Ps(i)&&a&&(n=u[1][0]-u[0][0],r=u[1][1]-u[0][1],v=Math.atan2(r,n),p=Math.cos(v)*(a||0),g=Math.sin(v)*(a||0)),o&&Ps(o)&&s&&(n=u[c-2][0]-u[c-1][0],r=u[c-2][1]-u[c-1][1],v=Math.atan2(r,n),m=Math.cos(v)*(s||0),y=Math.sin(v)*(s||0)),t.moveTo(l+p,h+g);for(var b=1;b<c-1;b++){var x=u[b];t.lineTo(x[0],x[1])}t.lineTo(d+m,f+y)}function yG(t,e){var n=e.x,r=void 0===n?0:n,i=e.y,o=void 0===i?0:i,a=e.radius,s=e.width,u=e.height,l=s,h=u;if(a&&a.some((function(t){return 0!==t}))){var d=s>0?1:-1,f=u>0?1:-1,p=d+f===0,g=c(a.map((function(t){return Ut(t,0,Math.min(Math.abs(l)/2,Math.abs(h)/2))})),4),m=g[0],y=g[1],v=g[2],b=g[3];t.moveTo(d*m+r,o),t.lineTo(l-d*y+r,o),0!==y&&t.arc(l-d*y+r,f*y+o,y,-f*Math.PI/2,d>0?0:Math.PI,p),t.lineTo(l+r,h-f*v+o),0!==v&&t.arc(l-d*v+r,h-f*v+o,v,d>0?0:Math.PI,f>0?Math.PI/2:1.5*Math.PI,p),t.lineTo(d*b+r,h+o),0!==b&&t.arc(d*b+r,h-f*b+o,b,f>0?Math.PI/2:-Math.PI/2,d>0?Math.PI:0,p),t.lineTo(r,f*m+o),0!==m&&t.arc(d*m+r,f*m+o,m,d>0?Math.PI:0,f>0?1.5*Math.PI:Math.PI/2,p)}else t.rect(r,o,l,h)}var vG=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.name="canvas-path-generator",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[er.CIRCLE]=hG,t[er.ELLIPSE]=dG,t[er.RECT]=yG,t[er.LINE]=fG,t[er.POLYLINE]=mG,t[er.POLYGON]=gG,t[er.PATH]=pG,t[er.TEXT]=void 0,t[er.GROUP]=void 0,t[er.IMAGE]=void 0,t[er.HTML]=void 0,t[er.MESH]=void 0,t);this.context.pathGeneratorFactory=e},e.prototype.destroy=function(){delete this.context.pathGeneratorFactory},e}(ir),bG=et(),xG=et(),wG=et(),EG=x(),MG=function(){function t(){var t=this;this.isHit=function(e,n,r,i){var o=t.context.pointInPathPickerFactory[e.nodeName];if(o){var a=k(EG,r),s=pt(xG,at(wG,n[0],n[1],0),a);if(o(e,new Pr(s[0],s[1]),i,t.isPointInPath,t.context,t.runtime))return!0}return!1},this.isPointInPath=function(e,n){var r=t.runtime.offscreenCanvasCreator.getOrCreateContext(t.context.config.offscreenCanvas),i=t.context.pathGeneratorFactory[e.nodeName];return i&&(r.beginPath(),i(r,e.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return t.prototype.apply=function(e,n){var r,i=this,o=e.renderingService,u=e.renderingContext;this.context=e,this.runtime=n;var c=null===(r=u.root)||void 0===r?void 0:r.ownerDocument;o.hooks.pick.tapPromise(t.tag,(function(t){return a(i,void 0,void 0,(function(){return s(this,(function(e){return[2,this.pick(c,t)]}))}))})),o.hooks.pickSync.tap(t.tag,(function(t){return i.pick(c,t)}))},t.prototype.pick=function(t,e){var n,r,i=e.topmost,o=e.position,a=o.x,s=o.y,c=at(bG,a,s,0),l=t.elementsFromBBox(c[0],c[1],c[0],c[1]),h=[];try{for(var d=u(l),f=d.next();!f.done;f=d.next()){var p=f.value,g=p.getWorldTransform();if(this.isHit(p,c,g,!1)){var m=da(p);if(m){var y=m.parsedStyle.clipPath;if(this.isHit(y,c,y.getWorldTransform(),!0)){if(i)return e.picked=[p],e;h.push(p)}}else{if(i)return e.picked=[p],e;h.push(p)}}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return e.picked=h,e},t.tag="CanvasPicker",t}();function SG(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,a=r.cy,s=void 0===a?0:a,u=r.r,l=r.fill,h=r.stroke,d=r.lineWidth,f=void 0===d?1:d,p=r.increasedLineWidthForHitTesting,g=void 0===p?0:p,m=r.pointerEvents,y=void 0===m?"auto":m,v=(f+g)/2,b=Dn(o,s,e.x,e.y),x=c(ma(y,l,h),2),w=x[0],E=x[1];return w&&E||n?b<=u+v:w?b<=u:!!E&&(b>=u-v&&b<=u+v)}function NG(t,e,n,r){return t/(n*n)+e/(r*r)}function kG(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,a=r.cy,s=void 0===a?0:a,u=r.rx,l=r.ry,h=r.fill,d=r.stroke,f=r.lineWidth,p=void 0===f?1:f,g=r.increasedLineWidthForHitTesting,m=void 0===g?0:g,y=r.pointerEvents,v=void 0===y?"auto":y,b=e.x,x=e.y,w=c(ma(v,h,d),2),E=w[0],M=w[1],S=(p+m)/2,N=(b-o)*(b-o),k=(x-s)*(x-s);return E&&M||n?NG(N,k,u+S,l+S)<=1:E?NG(N,k,u,l)<=1:!!M&&(NG(N,k,u-S,l-S)>=1&&NG(N,k,u+S,l+S)<=1)}function CG(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function TG(t,e,n,r,i,o,a,s){var u=(Math.atan2(s-e,a-t)+2*Math.PI)%(2*Math.PI),c={x:t+n*Math.cos(u),y:e+n*Math.sin(u)};return Dn(c.x,c.y,a,s)<=o/2}function AG(t,e,n,r,i,o,a){var s=Math.min(t,n),u=Math.max(t,n),c=Math.min(e,r),l=Math.max(e,r),h=i/2;return o>=s-h&&o<=u+h&&a>=c-h&&a<=l+h&&Hn(t,e,n,r,o,a)<=i/2}function PG(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var a=0;a<o-1;a++){if(AG(t[a][0],t[a][1],t[a+1][0],t[a+1][1],e,n,r))return!0}if(i){var s=t[0],u=t[o-1];if(AG(s[0],s[1],u[0],u[1],e,n,r))return!0}return!1}var OG=1e-6;function _G(t){return Math.abs(t)<OG?0:t<0?-1:1}function RG(t,e,n){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function IG(t,e,n){var r=!1,i=t.length;if(i<=2)return!1;for(var o=0;o<i;o++){var a=t[o],s=t[(o+1)%i];if(RG(a,s,[e,n]))return!0;_G(a[1]-n)>0!=_G(s[1]-n)>0&&_G(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(r=!r)}return r}function DG(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=IG(t[i],e,n))break}return r}function LG(t,e,n){var r=t.parsedStyle,i=r.x1,o=r.y1,a=r.x2,s=r.y2,u=r.lineWidth,l=void 0===u?1:u,h=r.increasedLineWidthForHitTesting,d=void 0===h?0:h,f=r.pointerEvents;return!(!c(ma(void 0===f?"auto":f,r.fill,r.stroke),2)[1]&&!n||!l)&&AG(i,o,a,s,l+d,e.x,e.y)}function jG(t,e,n,r,i,o){var a=t.parsedStyle,s=a.lineWidth,u=void 0===s?1:s,l=a.increasedLineWidthForHitTesting,h=void 0===l?0:l,d=a.stroke,f=a.fill,p=a.d,g=a.pointerEvents,m=void 0===g?"auto":g,y=p.segments,v=p.hasArc,b=p.polylines,x=p.polygons,w=c(ma(m,(null==x?void 0:x.length)&&f,d),2),E=w[0],M=w[1],S=ro(t),N=!1;return E||n?N=v?r(t,e):DG(x,e.x,e.y)||DG(b,e.x,e.y):((M||n)&&(N=function(t,e,n,r,i){for(var o=!1,a=e/2,s=0;s<t.length;s++){var u=t[s],c=u.currentPoint,l=u.params,h=u.prePoint,d=u.box;if(!d||CG(d.x-a,d.y-a,d.width+e,d.height+e,n,r))switch(u.command){case"L":case"Z":if(o=AG(h[0],h[1],c[0],c[1],e,n,r))return!0;break;case"Q":if(o=Jn(h[0],h[1],l[1],l[2],l[3],l[4],n,r)<=e/2)return!0;break;case"C":if(o=Yn(h[0],h[1],l[1],l[2],l[3],l[4],l[5],l[6],n,r,i)<=e/2)return!0;break;case"A":u.cubicParams||(u.cubicParams=ze(h[0],h[1],l[1],l[2],l[3],l[4],l[5],l[6],l[7],void 0));for(var f=u.cubicParams,p=h,g=0;g<f.length;g+=6){var m=Yn(p[0],p[1],f[g],f[g+1],f[g+2],f[g+3],f[g+4],f[g+5],n,r,i);if(p=[f[g+4],f[g+5]],o=m<=e/2)return!0}}}return o}(y,u+h,e.x,e.y,S)),N)}function BG(t,e,n){var r=t.parsedStyle,i=r.stroke,o=r.fill,a=r.lineWidth,s=void 0===a?1:a,u=r.increasedLineWidthForHitTesting,l=void 0===u?0:u,h=r.points,d=r.pointerEvents,f=c(ma(void 0===d?"auto":d,o,i),2),p=f[0],g=!1;return(f[1]||n)&&(g=PG(h.points,s+l,e.x,e.y,!0)),g||!p&&!n||(g=IG(h.points,e.x,e.y)),g}function zG(t,e,n){var r=t.parsedStyle,i=r.lineWidth,o=void 0===i?1:i,a=r.increasedLineWidthForHitTesting,s=void 0===a?0:a,u=r.points,l=r.pointerEvents;return!(!c(ma(void 0===l?"auto":l,r.fill,r.stroke),2)[1]&&!n||!o)&&PG(u.points,o+s,e.x,e.y,!1)}function FG(t,e,n,r,i){var o=t.parsedStyle,a=o.radius,s=o.fill,u=o.stroke,l=o.lineWidth,h=void 0===l?1:l,d=o.increasedLineWidthForHitTesting,f=void 0===d?0:d,p=o.x,g=void 0===p?0:p,m=o.y,y=void 0===m?0:m,v=o.width,b=o.height,x=o.pointerEvents,w=c(ma(void 0===x?"auto":x,s,u),2),E=w[0],M=w[1],S=h+f;if(a&&a.some((function(t){return 0!==t}))){var N=!1;return(M||n)&&(N=function(t,e,n,r,i,o,a,s){var u=c(i,4),l=u[0],h=u[1],d=u[2],f=u[3];return AG(t+l,e,t+n-h,e,o,a,s)||AG(t+n,e+h,t+n,e+r-d,o,a,s)||AG(t+n-d,e+r,t+f,e+r,o,a,s)||AG(t,e+r-f,t,e+l,o,a,s)||TG(t+n-h,e+h,h,Math.PI,Math.PI,o,a,s)||TG(t+n-d,e+r-d,d,0,Math.PI,o,a,s)||TG(t+f,e+r-f,f,Math.PI,Math.PI,o,a,s)||TG(t+l,e+l,l,Math.PI,Math.PI,o,a,s)}(g,y,v,b,a.map((function(t){return Ut(t,0,Math.min(Math.abs(v)/2,Math.abs(b)/2))})),S,e.x,e.y)),N||!E&&!n||(N=r(t,e)),N}var k=S/2;return E&&M||n?CG(g-k,y-k,v+k,b+k,e.x,e.y):E?CG(g,y,v,b,e.x,e.y):!!M&&function(t,e,n,r,i,o,a){var s=i/2;return CG(t-s,e-s,n,i,o,a)||CG(t+n-s,e-s,i,r,o,a)||CG(t+s,e+r-s,n,i,o,a)||CG(t-s,e+s,i,r,o,a)}(g,y,v,b,S,e.x,e.y)}function GG(t,e,n,r,o,a){var s=t.parsedStyle,u=s.pointerEvents,c=void 0===u?"auto":u,l=s.x,h=void 0===l?0:l,d=s.y,f=void 0===d?0:d,p=s.width,g=s.height;if("non-transparent-pixel"===c){var m=o.config.offscreenCanvas,y=a.offscreenCanvasCreator.getOrCreateCanvas(m),v=a.offscreenCanvasCreator.getOrCreateContext(m,{willReadFrequently:!0});return y.width=p,y.height=g,o.defaultStyleRendererFactory[er.IMAGE].render(v,i(i({},t.parsedStyle),{x:0,y:0}),t,void 0,void 0,void 0),v.getImageData(e.x-h,e.y-f,1,1).data.every((function(t){return 0!==t}))}return!0}var VG=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.name="canvas-picker",e}return r(e,t),e.prototype.init=function(){var t,e=((t={})[er.CIRCLE]=SG,t[er.ELLIPSE]=kG,t[er.RECT]=FG,t[er.LINE]=LG,t[er.POLYLINE]=zG,t[er.POLYGON]=BG,t[er.PATH]=jG,t[er.TEXT]=function(){return!0},t[er.GROUP]=null,t[er.IMAGE]=GG,t[er.HTML]=null,t[er.MESH]=null,t);this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new MG)},e.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},e}(ir),WG=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=x(),this.dprMatrix=x(),this.tmpMat4=x(),this.vec3a=et(),this.vec3b=et(),this.vec3c=et(),this.vec3d=et()}return t.prototype.apply=function(e,n){var r=this;this.context=e;var i=e.config,o=e.camera,a=e.renderingService,s=e.renderingContext,u=e.rBushRoot,h=e.pathGeneratorFactory;this.rBush=u,this.pathGeneratorFactory=h;var d=e.contextService,f=s.root.ownerDocument.defaultView,p=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)},g=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)};a.hooks.init.tap(t.tag,(function(){f.addEventListener(as.UNMOUNTED,p),f.addEventListener(as.CULLED,g);var t=d.getDPR(),e=i.width,n=i.height,o=d.getContext();r.clearRect(o,0,0,e*t,n*t,i.background)})),a.hooks.destroy.tap(t.tag,(function(){f.removeEventListener(as.UNMOUNTED,p),f.removeEventListener(as.CULLED,g),r.renderQueue=[],r.removedRBushNodeAABBs=[],r.restoreStack=[]})),a.hooks.beginFrame.tap(t.tag,(function(){var t,e=d.getContext(),n=d.getDPR(),o=i.width,s=i.height,u=r.canvasRendererPluginOptions,c=u.dirtyObjectNumThreshold,l=u.dirtyObjectRatioThreshold,h=a.getStats(),p=h.total,g=h.rendered,m=g/p;r.clearFullScreen=r.clearFullScreenLastFrame||!(null===(t=f.context.renderingPlugins[1])||void 0===t?void 0:t.isFirstTimeRenderingFinished)||a.disableDirtyRectangleRendering()||g>c&&m>l,e&&(e.resetTransform?e.resetTransform():e.setTransform(1,0,0,1,0,0),r.clearFullScreen&&r.clearRect(e,0,0,o*n,s*n,i.background))}));var m=function(t,e){t.isVisible()&&!t.isCulled()&&r.renderDisplayObject(t,e,r.context,r.restoreStack,n),(t.sortable.sorted||t.childNodes).forEach((function(t){m(t,e)}))};a.hooks.endFrame.tap(t.tag,(function(){if(0!==s.root.childNodes.length){r.clearFullScreenLastFrame=!1;var t=d.getContext(),e=d.getDPR();if(I(r.dprMatrix,[e,e,1]),T(r.vpMatrix,r.dprMatrix,o.getOrthoMatrix()),r.clearFullScreen)m(s.root,t);else{var a=r.safeMergeAABB.apply(r,l([r.mergeDirtyAABBs(r.renderQueue)],c(r.removedRBushNodeAABBs.map((function(t){var e=t.minX,n=t.minY,r=t.maxX,i=t.maxY,o=new Sr;return o.setMinMax([e,n,0],[r,i,0]),o}))),!1));if(r.removedRBushNodeAABBs=[],Sr.isEmpty(a))return void(r.renderQueue=[]);var u=r.convertAABB2Rect(a),h=u.x,p=u.y,g=u.width,y=u.height,v=pt(r.vec3a,[h,p,0],r.vpMatrix),b=pt(r.vec3b,[h+g,p,0],r.vpMatrix),x=pt(r.vec3c,[h,p+y,0],r.vpMatrix),w=pt(r.vec3d,[h+g,p+y,0],r.vpMatrix),E=Math.min(v[0],b[0],w[0],x[0]),M=Math.min(v[1],b[1],w[1],x[1]),S=Math.max(v[0],b[0],w[0],x[0]),N=Math.max(v[1],b[1],w[1],x[1]),k=Math.floor(E),C=Math.floor(M),A=Math.ceil(S-E),P=Math.ceil(N-M);t.save(),r.clearRect(t,k,C,A,P,i.background),t.beginPath(),t.rect(k,C,A,P),t.clip(),t.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),i.renderer.getConfig().enableDirtyRectangleRenderingDebug&&f.dispatchEvent(new es(Os.DIRTY_RECTANGLE,{dirtyRect:{x:k,y:C,width:A,height:P}})),r.searchDirtyObjects(a).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t,r.context,r.restoreStack,n)})),t.restore(),r.renderQueue.forEach((function(t){r.saveDirtyAABB(t)})),r.renderQueue=[]}r.restoreStack.forEach((function(){t.restore()})),r.restoreStack=[]}else r.clearFullScreenLastFrame=!0})),a.hooks.render.tap(t.tag,(function(t){r.clearFullScreen||r.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,n,r,i,o){t.clearRect(e,n,r,i),o&&(t.fillStyle=o,t.fillRect(e,n,r,i))},t.prototype.renderDisplayObject=function(t,e,n,r,i){var o=t.nodeName,a=r[r.length-1];!a||t.compareDocumentPosition(a)&rs.DOCUMENT_POSITION_CONTAINS||(e.restore(),r.pop());var s=this.context.styleRendererFactory[o],u=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(e,c);var l=this.pathGeneratorFactory[c.nodeName];l&&(e.save(),r.push(t),e.beginPath(),l(e,c.parsedStyle),e.closePath(),e.clip())}s&&(this.applyWorldTransform(e,t),e.save(),this.applyAttributesToContext(e,t)),u&&(e.beginPath(),u(e,t.parsedStyle),t.nodeName!==er.LINE&&t.nodeName!==er.PATH&&t.nodeName!==er.POLYLINE&&e.closePath()),s&&(s.render(e,t.parsedStyle,t,n,this,i),e.restore()),t.renderable.dirty=!1},t.prototype.convertAABB2Rect=function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}},t.prototype.mergeDirtyAABBs=function(t){var e=new Sr;return t.forEach((function(t){var n=t.getRenderBounds();e.add(n);var r=t.renderable.dirtyRenderBounds;r&&e.add(r)})),e},t.prototype.searchDirtyObjects=function(t){var e=c(t.getMin(),2),n=e[0],r=e[1],i=c(t.getMax(),2),o=i[0],a=i[1];return this.rBush.search({minX:n,minY:r,maxX:o,maxY:a}).map((function(t){return t.displayObject}))},t.prototype.saveDirtyAABB=function(t){var e=t.renderable;e.dirtyRenderBounds||(e.dirtyRenderBounds=new Sr);var n=t.getRenderBounds();n&&e.dirtyRenderBounds.update(n.center,n.halfExtents)},t.prototype.applyAttributesToContext=function(t,e){var n=e.parsedStyle,r=n.stroke,i=n.fill,o=n.opacity,a=n.lineDash,s=n.lineDashOffset;a&&t.setLineDash(a),_t(s)||(t.lineDashOffset=s),_t(o)||(t.globalAlpha*=o),_t(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),_t(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,n){n?(E(this.tmpMat4,e.getLocalTransform()),T(this.tmpMat4,n,this.tmpMat4),T(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(E(this.tmpMat4,e.getWorldTransform()),T(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},t.prototype.safeMergeAABB=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new Sr;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),HG=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n,r,i,o){var a=e.fill,s=e.fillRule,u=e.opacity,c=void 0===u?1:u,l=e.fillOpacity,h=void 0===l?1:l,d=e.stroke,f=e.strokeOpacity,p=void 0===f?1:f,g=e.lineWidth,m=void 0===g?1:g,y=e.lineCap,v=e.lineJoin,b=e.shadowType,x=e.shadowColor,w=e.shadowBlur,E=e.filter,M=e.miterLimit,S=!_t(a)&&!a.isNone,N=!_t(d)&&!d.isNone&&m>0,k=0===(null==a?void 0:a.alpha),C=!(!E||!E.length),T=!_t(x)&&w>0,A=n.nodeName,P="inner"===b,O=N&&T&&(A===er.PATH||A===er.LINE||A===er.POLYLINE||k||P);S&&(t.globalAlpha=c*h,O||UG(n,t,T),this.fill(t,n,a,s,r,i,o),O||this.clearShadowAndFilter(t,C,T)),N&&(t.globalAlpha=c*p,t.lineWidth=m,_t(M)||(t.miterLimit=M),_t(y)||(t.lineCap=y),_t(v)||(t.lineJoin=v),O&&(P&&(t.globalCompositeOperation="source-atop"),UG(n,t,!0),P&&(this.stroke(t,n,d,r,i,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,C,!0))),this.stroke(t,n,d,r,i,o))},t.prototype.clearShadowAndFilter=function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!_t(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,e,n,r,i,o,a){var s=this;Array.isArray(n)?n.forEach((function(n){t.fillStyle=s.getColor(n,e,t),r?t.fill(r):t.fill()})):(Ri(n)&&(t.fillStyle=this.getPattern(n,e,t,i,o,a)),r?t.fill(r):t.fill())},t.prototype.stroke=function(t,e,n,r,i,o){var a=this;Array.isArray(n)?n.forEach((function(n){t.strokeStyle=a.getColor(n,e,t),t.stroke()})):(Ri(n)&&(t.strokeStyle=this.getPattern(n,e,t,r,i,o)),t.stroke())},t.prototype.getPattern=function(t,e,n,r,i,o){var a,s;if("rect"===t.image.nodeName){var u=t.image.parsedStyle,c=u.width,l=u.height;s=r.contextService.getDPR();var h=r.config.offscreenCanvas;(a=o.offscreenCanvasCreator.getOrCreateCanvas(h)).width=c*s,a.height=l*s;var d=o.offscreenCanvasCreator.getOrCreateContext(h),f=[];t.image.forEach((function(t){i.renderDisplayObject(t,d,r,f,o)})),f.forEach((function(){d.restore()}))}return this.imagePool.getOrCreatePatternSync(t,n,a,s,e.getGeometryBounds().min,(function(){e.renderable.dirty=!0,r.renderingService.dirtify()}))},t.prototype.getColor=function(t,e,n){var r;if(t.type===Ur.LinearGradient||t.type===Ur.RadialGradient){var o=e.getGeometryBounds(),a=o&&2*o.halfExtents[0]||1,s=o&&2*o.halfExtents[1]||1,u=o&&o.min||[0,0];r=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{min:u,width:a,height:s}),n)}return r},t}();function UG(t,e,n){var r=t.parsedStyle,i=r.filter,o=r.shadowColor,a=r.shadowBlur,s=r.shadowOffsetX,u=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=o.toString(),e.shadowBlur=a||0,e.shadowOffsetX=s||0,e.shadowOffsetY=u||0)}var $G=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n){var r,i=e.x,o=void 0===i?0:i,a=e.y,s=void 0===a?0:a,u=e.width,c=e.height,l=e.src,h=e.shadowColor,d=e.shadowBlur,f=u,p=c;if(Vt(l)?r=this.imagePool.getImageSync(l):(f||(f=l.width),p||(p=l.height),r=l),r){UG(n,t,!_t(h)&&d>0);try{t.drawImage(r,o,s,f,p)}catch(t){}}},t}(),qG=function(){function t(){}return t.prototype.render=function(t,e,n,r,i,o){n.getBounds();var a=e,s=a.lineWidth,u=void 0===s?1:s,c=a.textAlign,l=void 0===c?"start":c,h=a.textBaseline,d=void 0===h?"alphabetic":h,f=a.lineJoin,p=void 0===f?"miter":f,g=a.miterLimit,m=void 0===g?10:g,y=a.letterSpacing,v=void 0===y?0:y,b=a.stroke,x=a.fill,w=a.fillOpacity,E=void 0===w?1:w,M=a.strokeOpacity,S=void 0===M?1:M,N=a.opacity,k=void 0===N?1:N,C=a.metrics,T=a.x,A=void 0===T?0:T,P=a.y,O=void 0===P?0:P,_=a.dx,R=a.dy,I=a.shadowColor,D=a.shadowBlur,L=C.font,j=C.lines,B=C.height,z=C.lineHeight,F=C.lineMetrics;t.font=L,t.lineWidth=u,t.textAlign="middle"===l?"center":l;var G=d;o.enableCSSParsing||"alphabetic"!==G||(G="bottom"),t.lineJoin=p,_t(m)||(t.miterLimit=m);var V=O;"middle"===d?V+=-B/2-z/2:"bottom"===d||"alphabetic"===d||"ideographic"===d?V+=-B:"top"!==d&&"hanging"!==d||(V+=-z);var W=A+(_||0);V+=R||0,1===j.length&&("bottom"===G?(G="middle",V-=.5*B):"top"===G&&(G="middle",V+=.5*B)),t.textBaseline=G,UG(n,t,!_t(I)&&D>0);for(var H=0;H<j.length;H++){var U=u/2+W;V+=z,_t(b)||b.isNone||!u||this.drawLetterSpacing(t,j[H],F[H],l,U,V,v,E,S,k,!0),_t(x)||this.drawLetterSpacing(t,j[H],F[H],l,U,V,v,E,S,k)}},t.prototype.drawLetterSpacing=function(t,e,n,r,i,o,a,s,u,c,l){if(void 0===l&&(l=!1),0!==a){var h=t.textAlign;t.textAlign="left";var d=i;"center"===r||"middle"===r?d=i-n.width/2:"right"!==r&&"end"!==r||(d=i-n.width);for(var f=Array.from(e),p=t.measureText(e).width,g=0,m=0;m<f.length;++m){var y=f[m];l?this.strokeText(t,y,d,o,u):this.fillText(t,y,d,o,s,c),d+=p-(g=t.measureText(e.substring(m+1)).width)+a,p=g}t.textAlign=h}else l?this.strokeText(t,e,i,o,u):this.fillText(t,e,i,o,s,c)},t.prototype.fillText=function(t,e,n,r,i,o){var a,s=!_t(i)&&1!==i;s&&(a=t.globalAlpha,t.globalAlpha=i*o),t.fillText(e,n,r),s&&(t.globalAlpha=a)},t.prototype.strokeText=function(t,e,n,r,i){var o,a=!_t(i)&&1!==i;a&&(o=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,n,r),a&&(t.globalAlpha=o)},t}();!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(HG),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(HG),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(HG),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(HG),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(HG),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(HG),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(HG);var YG=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="canvas-renderer",n}return r(e,t),e.prototype.init=function(){var t,e=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,r=new HG(n),o=((t={})[er.CIRCLE]=r,t[er.ELLIPSE]=r,t[er.RECT]=r,t[er.IMAGE]=new $G(n),t[er.TEXT]=new qG,t[er.LINE]=r,t[er.POLYLINE]=r,t[er.POLYGON]=r,t[er.PATH]=r,t[er.GROUP]=void 0,t[er.HTML]=void 0,t[er.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new WG(e))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},e}(ir),KG=function(){function t(){}return t.prototype.apply=function(e,n){var r=this,i=e.renderingService,o=e.renderingContext,a=e.config;this.context=e;var s=o.root.ownerDocument.defaultView,u=function(t){i.hooks.pointerMove.call(t)},c=function(t){i.hooks.pointerUp.call(t)},l=function(t){i.hooks.pointerDown.call(t)},h=function(t){i.hooks.pointerOver.call(t)},d=function(t){i.hooks.pointerOut.call(t)},f=function(t){i.hooks.pointerCancel.call(t)},p=function(t){i.hooks.pointerWheel.call(t)},g=function(t){i.hooks.click.call(t)};i.hooks.init.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):s.supportsPointerEvents&&(t.style.touchAction="none"),s.supportsPointerEvents?function(t){n.globalThis.document.addEventListener("pointermove",u,!0),t.addEventListener("pointerdown",l,!0),t.addEventListener("pointerleave",d,!0),t.addEventListener("pointerover",h,!0),n.globalThis.addEventListener("pointerup",c,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(t):function(t){n.globalThis.document.addEventListener("mousemove",u,!0),t.addEventListener("mousedown",l,!0),t.addEventListener("mouseout",d,!0),t.addEventListener("mouseover",h,!0),n.globalThis.addEventListener("mouseup",c,!0)}(t),s.supportsTouchEvents&&function(t){t.addEventListener("touchstart",l,!0),t.addEventListener("touchend",c,!0),t.addEventListener("touchmove",u,!0),t.addEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.addEventListener("click",g,!0),t.addEventListener("wheel",p,{passive:!0,capture:!0})})),i.hooks.destroy.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){n.globalThis.document.removeEventListener("pointermove",u,!0),t.removeEventListener("pointerdown",l,!0),t.removeEventListener("pointerleave",d,!0),t.removeEventListener("pointerover",h,!0),n.globalThis.removeEventListener("pointerup",c,!0)}(t):function(t){n.globalThis.document.removeEventListener("mousemove",u,!0),t.removeEventListener("mousedown",l,!0),t.removeEventListener("mouseout",d,!0),t.removeEventListener("mouseover",h,!0),n.globalThis.removeEventListener("mouseup",c,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",l,!0),t.removeEventListener("touchend",c,!0),t.removeEventListener("touchmove",u,!0),t.removeEventListener("touchcancel",f,!0)}(t),a.useNativeClickEvent&&t.removeEventListener("click",g,!0),t.removeEventListener("wheel",p,!0)}))},t.tag="DOMInteraction",t}(),XG=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.name="dom-interaction",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new KG)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(ir),ZG=function(){function t(){this.displayObjectHTMLElementMap=new WeakMap}return t.prototype.joinTransformMatrix=function(t){return"matrix(".concat([t[0],t[1],t[4],t[5],t[12],t[13]].join(","),")")},t.prototype.apply=function(e,n){var r=this,i=e.camera,o=e.renderingContext,a=e.renderingService;this.context=e;var s=o.root.ownerDocument.defaultView,u=s.context.eventService.nativeHTMLMap,c=function(t,e){e.style.transform=r.joinTransformMatrix(t.getWorldTransform())},l=function(t){var e=t.target;if(e.nodeName===er.HTML){r.$camera||(r.$camera=r.createCamera(i));var o=r.getOrCreateEl(e);if(r.$camera.appendChild(o),n.enableCSSParsing){var a=e.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(t){o.style[t]=a[t]}))}Object.keys(e.attributes).forEach((function(t){r.updateAttribute(t,e)})),c(e,o),u.set(o,e)}},h=function(t){var e=t.target;if(e.nodeName===er.HTML&&r.$camera){var n=r.getOrCreateEl(e);n&&(n.remove(),u.delete(n))}},d=function(t){var e=t.target;if(e.nodeName===er.HTML){var n=t.attrName;r.updateAttribute(n,e)}},f=function(t){var e=t.target;if(e.nodeName===er.HTML){var n=r.getOrCreateEl(e);c(e,n)}},p=function(){if(r.$camera){var t=r.context.config,e=t.width,n=t.height;r.$camera.style.width="".concat(e||0,"px"),r.$camera.style.height="".concat(n||0,"px")}};a.hooks.init.tap(t.tag,(function(){s.addEventListener(Os.RESIZE,p),s.addEventListener(as.MOUNTED,l),s.addEventListener(as.UNMOUNTED,h),s.addEventListener(as.ATTR_MODIFIED,d),s.addEventListener(as.BOUNDS_CHANGED,f)})),a.hooks.endFrame.tap(t.tag,(function(){r.$camera&&o.renderReasons.has(Xa.CAMERA_CHANGED)&&(r.$camera.style.transform=r.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(t.tag,(function(){r.$camera&&r.$camera.remove(),s.removeEventListener(Os.RESIZE,p),s.removeEventListener(as.MOUNTED,l),s.removeEventListener(as.UNMOUNTED,h),s.removeEventListener(as.ATTR_MODIFIED,d),s.removeEventListener(as.BOUNDS_CHANGED,f)}))},t.prototype.createCamera=function(t){var e=this.context.config,n=e.document,r=e.width,i=e.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",u=a.querySelector("#"+s);if(!u){var c=(n||document).createElement("div");u=c,c.id=s,c.style.position="absolute",c.style.left="".concat(o.offsetLeft||0,"px"),c.style.top="".concat(o.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(t.getOrthoMatrix()),c.style.overflow="hidden",c.style.pointerEvents="none",c.style.width="".concat(r||0,"px"),c.style.height="".concat(i||0,"px"),a.appendChild(c)}return u}return null},t.prototype.getOrCreateEl=function(t){var e=this.context.config.document,n=this.displayObjectHTMLElementMap.get(t);return n||(n=(e||document).createElement("div"),t.parsedStyle.$el=n,this.displayObjectHTMLElementMap.set(t,n),t.id&&(n.id=t.id),t.name&&n.setAttribute("name",t.name),t.className&&(n.className=t.className),n.style.position="absolute",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(t.getWorldTransform())),n},t.prototype.updateAttribute=function(t,e){var n=this.getOrCreateEl(e);switch(t){case"innerHTML":var r=e.parsedStyle.innerHTML;Vt(r)?n.innerHTML=r:(n.innerHTML="",n.appendChild(r));break;case"x":n.style.left="".concat(e.parsedStyle.x,"px");break;case"y":n.style.top="".concat(e.parsedStyle.y,"px");break;case"transformOrigin":var i=e.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(i[0].value," ").concat(i[1].value);break;case"width":if(this.context.enableCSSParsing){var o=e.computedStyleMap().get("width");n.style.width=o.toString()}else{o=e.parsedStyle.width;n.style.width=$t(o)?"".concat(o,"px"):o.toString()}break;case"height":if(this.context.enableCSSParsing){var a=e.computedStyleMap().get("height");n.style.height=a.toString()}else{a=e.parsedStyle.height;n.style.height=$t(a)?"".concat(a,"px"):a.toString()}break;case"zIndex":var s=e.parsedStyle.zIndex;n.style["z-index"]="".concat(s);break;case"visibility":var u=e.parsedStyle.visibility;n.style.visibility=u;break;case"pointerEvents":var c=e.parsedStyle.pointerEvents,l=void 0===c?"auto":c;n.style.pointerEvents=l;break;case"opacity":var h=e.parsedStyle.opacity;n.style.opacity="".concat(h);break;case"fill":var d=e.parsedStyle.fill,f="";Ii(d)?f=d.isNone?"transparent":e.getAttribute("fill"):Array.isArray(d)?f=e.getAttribute("fill"):Ri(d),n.style.background=f;break;case"stroke":var p=e.parsedStyle.stroke,g="";Ii(p)?g=p.isNone?"transparent":e.getAttribute("stroke"):Array.isArray(p)?g=e.getAttribute("stroke"):Ri(p),n.style["border-color"]=g,n.style["border-style"]="solid";break;case"lineWidth":var m=e.parsedStyle.lineWidth;n.style["border-width"]="".concat(m||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":var y=e.style.filter;n.style.filter=y;break;default:_t(e.style[t])||""===e.style[t]||(n.style[t]=e.style[t])}},t.tag="HTMLRendering",t}(),QG=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.name="html-renderer",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new ZG)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(ir),JG=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e(this.imageCache[t]):this.getOrCreateImage(t).then((function(t){e&&e(t)})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var e=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var n=this.canvasConfig.createImage;return new Promise((function(r,i){var o;n?o=n(t):ca&&(o=new window.Image),o&&(o.onload=function(){e.imageCache[t]=o,r(o)},o.onerror=function(t){i(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,e,n,r,i,o){var a=this.generatePatternKey(t);if(a&&this.patternCache[a])return this.patternCache[a];var s,u=t.image,c=t.repetition,l=t.transform,h=!1;Vt(u)?s=this.getImageSync(u,o):n?(s=n,h=!0):s=u;var d=s&&e.createPattern(s,c);if(d){var f=void 0;f=l?Ba(No(l),new Bs({})):S(x()),h&&P(f,f,[1/r,1/r,1]),d.setTransform({a:f[0],b:f[1],c:f[4],d:f[5],e:f[12]+i[0],f:f[13]+i[1]})}return a&&d&&(this.patternCache[a]=d),d},t.prototype.getOrCreateGradient=function(t,e){var n=this.generateGradientKey(t),r=t.type,i=t.steps,o=t.min,a=t.width,s=t.height,u=t.angle,c=t.cx,l=t.cy,h=t.size;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(r===Ur.LinearGradient){var f=function(t,e,n,r){var i=dr(r.value),o=0+e/2,a=0+n/2,s=Math.abs(e*Math.cos(i))+Math.abs(n*Math.sin(i));return{x1:t[0]+o-Math.cos(i)*s/2,y1:t[1]+a-Math.sin(i)*s/2,x2:t[0]+o+Math.cos(i)*s/2,y2:t[1]+a+Math.sin(i)*s/2}}(o,a,s,u),p=f.x1,g=f.y1,m=f.x2,y=f.y2;d=e.createLinearGradient(p,g,m,y)}else if(r===Ur.RadialGradient){var v=function(t,e,n,r,i,o){var a=r.value,s=i.value;r.unit===Ir.kPercentage&&(a=r.value/100*e),i.unit===Ir.kPercentage&&(s=i.value/100*n);var u=Math.max(He([0,0],[a,s]),He([0,n],[a,s]),He([e,n],[a,s]),He([e,0],[a,s]));return o&&(o instanceof ai?u=o.value:o instanceof Qr&&("closest-side"===o.value?u=Math.min(a,e-a,s,n-s):"farthest-side"===o.value?u=Math.max(a,e-a,s,n-s):"closest-corner"===o.value&&(u=Math.min(He([0,0],[a,s]),He([0,n],[a,s]),He([e,n],[a,s]),He([e,0],[a,s]))))),{x:a+t[0],y:s+t[1],r:u}}(o,a,s,c,l,h),b=v.x,x=v.y,w=v.r;d=e.createRadialGradient(b,x,0,b,x,w)}return d&&(i.forEach((function(t){var e=t.offset,n=t.color;e.unit===Ir.kPercentage&&(null==d||d.addColorStop(e.value/100,n.toString()))})),this.gradientCache[n]=d),this.gradientCache[n]},t.prototype.generateGradientKey=function(t){var e=t.type,n=t.min,r=t.width,i=t.height,o=t.steps,a=t.angle,s=t.cx,u=t.cy,c=t.size;return"gradient-".concat(e,"-").concat((null==a?void 0:a.toString())||0,"-").concat((null==s?void 0:s.toString())||0,"-").concat((null==u?void 0:u.toString())||0,"-").concat((null==c?void 0:c.toString())||0,"-").concat(n[0],"-").concat(n[1],"-").concat(r,"-").concat(i,"-").concat(o.map((function(t){var e=t.offset,n=t.color;return"".concat(e).concat(n)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return Vt(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),tV=function(){function t(){}return t.prototype.apply=function(e){var n=e.renderingService,r=e.renderingContext,i=e.imagePool,o=r.root.ownerDocument.defaultView,a=function(t,e,n){var r=t.parsedStyle,i=r.width,o=r.height;i&&!o?t.setAttribute("height",n/e*i):!i&&o&&t.setAttribute("width",e/n*o)},s=function(t){var e=t.target,r=e.nodeName,o=e.attributes;if(r===er.IMAGE){var s=o.src,u=o.keepAspectRatio;Vt(s)&&i.getImageSync(s,(function(t){var r=t.width,i=t.height;u&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))}},u=function(t){var e=t.target,r=t.attrName,o=t.newValue;e.nodeName===er.IMAGE&&"src"===r&&Vt(o)&&i.getOrCreateImage(o).then((function(t){var r=t.width,i=t.height;e.attributes.keepAspectRatio&&a(e,r,i),e.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(t.tag,(function(){o.addEventListener(as.MOUNTED,s),o.addEventListener(as.ATTR_MODIFIED,u)})),n.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(as.MOUNTED,s),o.removeEventListener(as.ATTR_MODIFIED,u)}))},t.tag="LoadImage",t}(),eV=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.name="image-loader",e}return r(e,t),e.prototype.init=function(){this.context.imagePool=new JG(this.context.config),this.addRenderingPlugin(new tV)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(ir),nV=function(){function t(t){this.renderingContext=t.renderingContext,this.canvasConfig=t.config}return t.prototype.init=function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=Vt(e)?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)},t.prototype.getContext=function(){return this.context},t.prototype.getDomElement=function(){return this.$canvas},t.prototype.getDPR=function(){return this.dpr},t.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},t.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},t.prototype.resize=function(t,e){var n=this.canvasConfig.devicePixelRatio||ca&&window.devicePixelRatio||1;n=n>=1?Math.ceil(n):1,this.dpr=n,this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*e,function(t,e,n){ca&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add(Xa.CAMERA_CHANGED)},t.prototype.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},t.prototype.toDataURL=function(t){return void 0===t&&(t={}),a(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){return e=t.type,n=t.encoderOptions,[2,this.context.canvas.toDataURL(e,n)]}))}))},t}(),rV=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.name="canvas-context-register",e}return r(e,t),e.prototype.init=function(){this.context.ContextService=nV},e.prototype.destroy=function(){delete this.context.ContextService},e}(ir),iV=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new rV),n.registerPlugin(new eV),n.registerPlugin(new vG),n.registerPlugin(new YG),n.registerPlugin(new XG),n.registerPlugin(new VG),n.registerPlugin(new QG),n}return r(e,t),e}(or);const oV=["timestamp","time","date","datetime"];class aV extends pD{static defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],mode:"modify",getTime:t=>cV(t,oV,void 0),loop:!1};timebar;canvas;wrapper;originalData;constructor(t,e){super(t,Object.assign({},aV.defaultOptions,e)),this.backup(),this.upsertTimebar()}play(){this.timebar?.play()}pause(){this.timebar?.pause()}forward(){this.timebar?.forward()}backward(){this.timebar?.backward()}reset(){this.timebar?.reset()}update(t){super.update(t),this.backup(),Object.keys(t).forEach((t=>{if("position"===t)this.upsertWrapper();else this.upsertTimebar()}))}backup(){this.originalData=sV(this.context.graph.getData())}upsertTimebar(){const{canvas:t}=this.context,{onChange:e,timebarType:n,data:r,x:i,y:o,width:a,height:s,mode:u,...c}=this.options,l=t.getSize();this.upsertCanvas().ready.then((()=>{const t={x:l[0]/2-a/2,y:10,onChange:t=>{const n=(Dt(t)?t:[t,t]).map((t=>function(t){return It(t,"Date")}(t)?t.getTime():t));"modify"===this.options.mode?this.filterElements(n):this.hiddenElements(n),e?.(n)},...c,data:r.map((t=>$t(t)?{time:t,value:0}:t)),width:a,height:s,type:n};this.timebar?this.timebar.update(t):(this.timebar=new cG({style:t}),this.canvas?.appendChild(this.timebar))}))}upsertWrapper(){if(!this.wrapper){const t=document.createElement("div");t.style.position="absolute",this.wrapper=t}const{x:t,y:e,className:n,position:r}=this.options;return n&&(this.wrapper.className=n),$t(t)||$t(e)?Object.assign(this.wrapper.style,{left:`${t??0}px`,top:`${e??0}px`}):Object.assign(this.wrapper.style,{["top"===r?"bottom":"top"]:"unset",["top"===r?"top":"bottom"]:"0px"}),this.context.canvas.getContainer()?.appendChild(this.wrapper),this.wrapper}upsertCanvas(){const t=this.upsertWrapper();if(this.canvas)return this.canvas;const{height:e}=this.options,[n]=this.context.canvas.getSize();return this.canvas=new cu({container:t,width:n,height:e+10,renderer:this.context.options.renderer?.("main")||new iV,supportsMutipleCanvasesInOneContainer:!0}),this.canvas}async filterElements(t){if(!this.originalData)return;const{elementTypes:e,getTime:n}=this.options,{graph:r,element:i}=this.context,o=sV(this.originalData);e.forEach((e=>{const r=`${e}s`;o[r]=(this.originalData[r]||[]).filter((e=>{const r=n(e);return!!uV(r,t)}))}));const a=[...o.nodes,...o.combos].map((t=>Xc(t)));o.edges=o.edges.filter((t=>{const e=t.source,n=t.target;return a.includes(e)&&a.includes(n)})),r.setData(o),await i.draw({animation:!1,silence:!0})}hiddenElements(t){const{graph:e}=this.context,{elementTypes:n,getTime:r}=this.options,i=[],o=[];n.forEach((e=>{const n=`${e}s`;(this.originalData?.[n]||[]).forEach((e=>{const n=Xc(e),a=r(e);uV(a,t)?o.push(n):i.push(n)}))})),e.hideElement(i,!1),e.showElement(o,!1)}destroy(){const{graph:t}=this.context;this.originalData&&t.setData({...this.originalData}),this.timebar?.destroy(),this.canvas?.destroy(),this.wrapper?.remove(),this.originalData=void 0,this.wrapper=void 0,this.timebar=void 0,this.canvas=void 0,super.destroy()}}const sV=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},uV=(t,e)=>{if($t(e))return t===e;const[n,r]=e;return t>=n&&t<=r},cV=(t,e,n)=>{for(let n=0;n<e.length;n++){const r=e[n],i=t.data?.[r];if(i)return i}return n};class lV extends pD{static defaultOptions={position:"top-left"};$element=aL("toolbar",!1);constructor(t,e){super(t,Object.assign({},lV.defaultOptions,e));const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),sL("g6-toolbar-css","style",{},"\n .g6-toolbar {\n position: absolute;\n z-index: 100;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);\n opacity: 0.65;\n }\n .g6-toolbar .g6-toolbar-item {\n display: inline-block;\n width: 16px;\n height: 16px;\n padding: 4px;\n cursor: pointer;\n box-sizing: content-box;\n }\n\n .g6-toolbar .g6-toolbar-item:hover {\n background-color: #f0f0f0;\n }\n\n .g6-toolbar .g6-toolbar-item svg {\n display: inline-block;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n",document.head),sL("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}async update(t){super.update(t);const{className:e,position:n,style:r}=this.options;this.$element.className=`g6-toolbar ${e||""}`,Object.assign(this.$element.style,r,function(t){const e={top:"unset",right:"unset",bottom:"unset",left:"unset"};return t.split("-").forEach((t=>{e[t]="8px"})),e.flexDirection=t.startsWith("top")||t.startsWith("bottom")?"row":"column",e}(n)),this.$element.innerHTML=await this.getDOMContent()}destroy(){this.$element.removeEventListener("click",this.onToolbarItemClick),this.$element.remove(),super.destroy()}async getDOMContent(){return(await this.options.getItems()).map((t=>`\n <div class="g6-toolbar-item" value="${t.value}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`)).join("")}onToolbarItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof Element&&t.target.className.includes("g6-toolbar-item")){const n=t.target.getAttribute("value");e?.(n,t.target)}}}class hV extends pD{static defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};currentTarget=null;tooltipElement=null;container=null;constructor(t,e){super(t,Object.assign({},hV.defaultOptions,e)),this.render(),this.bindEvents()}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerenter":this.onPointerEnter,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerenter":this.onPointerEnter,"edge:pointermove":this.onPointerMove,"combo:pointerenter":this.onPointerEnter,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(t){this.unbindEvents(),super.update(t),this.tooltipElement&&this.container?.removeChild(this.tooltipElement.HTMLTooltipElement),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:t}=this.context,e=t.getContainer();e&&(this.container=e,this.tooltipElement=this.initTooltip())}unbindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach((n=>{t.off(n,e[n])}))}bindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach((n=>{t.on(n,e[n])}))}isEnable=t=>{const{enable:e}=this.options;return"function"==typeof e?e(t):e};onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?(this.currentTarget=null,this.hide(t)):(this.currentTarget=e,this.show(t))};onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.show(t)};onPointerLeave=t=>{this.hide(t),this.currentTarget=null};onCanvasMove=t=>{this.hide(t),this.currentTarget=null};onPointerEnter=t=>{this.show(t)};showById=t=>{const e={target:{id:t}};this.show(e)};getElementData=(t,e)=>{const{model:n}=this.context;switch(e){case"node":return n.getNodeData([t]);case"edge":return n.getEdgeData([t]);case"combo":return n.getComboData([t]);default:return[]}};show=t=>{const{client:e,target:{id:n}}=t,r=this.context.graph.getElementType(n);if(!this.tooltipElement||!this.isEnable(t))return;const{getContent:i,title:o}=this.options;this.currentTarget=n;const a=this.getElementData(n,r);let s,u;if(e)s=e.x,u=e.y;else{const t=fe(a,"0.style",{x:0,y:0});s=t.x,u=t.y}let c={};if(i)c.content=i(t,a);else{const t=this.context.graph.getElementRenderStyle(n),e="node"===r?t.fill:t.stroke;c={title:o||r,data:a.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e})))}}this.tooltipElement.update({x:s,y:u,style:{".tooltip":{visibility:"visible"}},...c})};hide=t=>{if(!t)return void this.tooltipElement?.hide();if(!this.tooltipElement||!this.isEnable(t))return;const{client:{x:e,y:n}}=t;this.tooltipElement.hide(e,n)};initTooltip=()=>{const{canvas:t}=this.context,{center:e}=t.getBounds(),n=t.getContainer(),{top:r,left:i}=n.getBoundingClientRect(),{style:o,position:a,enterable:s,container:u={x:-i,y:-r},title:c,offset:l}=this.options,[h,d]=e,[f,p]=t.getSize(),g=new DF({className:"tooltip",style:{x:h,y:d,container:u,title:c,bounding:{x:0,y:0,width:f,height:p},position:a,enterable:s,offset:l,style:o}});return this.container?.appendChild(g.HTMLTooltipElement),g};destroy(){this.unbindEvents(),this.tooltipElement&&this.container?.removeChild(this.tooltipElement.HTMLTooltipElement),super.destroy()}}let dV;function fV(t,e){dV||(dV=document.createElement("canvas")),dV.width=t,dV.height=e;return dV.getContext("2d").clearRect(0,0,t,e),dV}class pV extends pD{static defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};$element=aL("watermark");constructor(t,e){super(t,Object.assign({},pV.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}async update(t){super.update(t);const{width:e,height:n,text:r,imageURL:i,...o}=this.options;Object.keys(o).forEach((e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])}));const a=i?await async function(t,e,n,r){const i=fV(t,e),o=i.getContext("2d"),{rotate:a,opacity:s}=r;a&&o.rotate(a),s&&(o.globalAlpha=s);const u=new Image;return u.crossOrigin="anonymous",u.src=n,new Promise((n=>{u.onload=function(){const r=t>u.width?(t-u.width)/2:0,a=e>u.height?(e-u.height)/2:0;o.drawImage(u,0,0,u.width,u.height,r,a,t-2*r,e-2*a),n(i.toDataURL())}}))}(e,n,i,o):await async function(t,e,n,r){const i=fV(t,e),o=i.getContext("2d"),{rotate:a,opacity:s,textFill:u,textFontSize:c,textFontFamily:l,textFontVariant:h,textFontWeight:d,textAlign:f,textBaseline:p}=r;return o.textAlign=f,o.textBaseline=p,o.translate(t/2,e/2),o.font=`${c}px ${l} ${h} ${d}`,a&&o.rotate(a),s&&(o.globalAlpha=s),u&&(o.fillStyle=u,o.fillText(`${n}`,0,0)),i.toDataURL()}(e,n,r,o);this.$element.style.backgroundImage=`url(${a})`}destroy(){super.destroy(),this.$element.remove()}}const gV=["#7E92B5","#f5222d","#faad14"],mV={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},yV={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function vV(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeBadgePalette:a=gV,nodePaletteOptions:s=mV,edgeColor:u,edgeColorDisabled:c,edgePaletteOptions:l=yV,comboColor:h,comboColorDisabled:d,comboStroke:f,comboStrokeDisabled:p}=t;return{background:e,node:{palette:s,style:{badgeFill:e,badgeFontSize:8,badgePadding:[1,4],badgePalette:a,fill:r,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,iconFill:e,iconFontSize:16,iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.5,labelBackgroundPadding:[0,2],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineWidth:0,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65,stroke:o,strokeOpacity:1},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:3,stroke:o},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:3,stroke:o,strokeOpacity:.85},inactive:{donutOpacity:.25,fillOpacity:.25,iconOpacity:.25,labelOpacity:.25,strokeOpacity:.25},disabled:{fill:i,labelOpacity:.25,donutOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["x","y","fill","stroke"]}]}},edge:{palette:l,style:{fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:.25,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:u,strokeOpacity:1},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:2},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:2},inactive:{fillOpacity:.25,labelOpacity:.25,strokeOpacity:.25},disabled:{stroke:c,labelOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["d","stroke"],shape:"key"},{fields:["d","stroke"],shape:"halo"}]}},combo:{style:{collapsedMaskFill:h,collapsedMaskFontSize:12,collapsedSize:32,fill:h,halo:!1,haloLineWidth:12,haloStroke:f,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:1,strokeOpacity:1,padding:10,stroke:f},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:d,fillOpacity:.25,labelOpacity:.25,stroke:p,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",expand:"combo-collapse-expand",collapse:"combo-collapse-expand",update:[{fields:["x","y"]},{fields:["size","fill","stroke"],shape:"key"}]}}}}const bV=vV({bgColor:"#000000",textColor:"#ffffffd9",nodeColor:"#1783ff",nodeColorDisabled:"#d0e4ff",nodeStroke:"#d0e4ff",edgeColor:"#99add1",edgeColorDisabled:"#969696",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696"}),xV=vV({bgColor:"#fff",textColor:"#000000d9",nodeColor:"#1783ff",nodeColorDisabled:"#f0f0f0",nodeStroke:"#000000",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",comboColor:"#fdfdfd",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9"});class wV extends fd{beforeDraw(t){return t}}const EV=(t,e,n,r)=>{const i=Xc(r),o=`${n}s`,a=t.add[o].get(i)||t.update[o].get(i)||t.remove[o].get(i)||r;Object.entries(t).forEach((([t,n])=>{e===t?n[o].set(i,a):n[o].delete(i)}))};const MV=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class SV extends wV{static defaultOptions={mode:"bundle",edges:void 0,distance:15};constructor(t,e){super(t,Object.assign({},SV.defaultOptions,e))}beforeDraw(t){const e=this.getAffectedParallelEdges(t);if(0===e.size)return t;const n=(e,n,r)=>{const i=`${n}s`;Object.entries(t).forEach((([t,n])=>{e===t?n[i].set(Xc(r),r):n[i].delete(Xc(r))}))};return"bundle"===this.options.mode?this.applyBundlingStyle(n,e,this.options.distance):this.applyMergingStyle(n,e),t}getAffectedParallelEdges=t=>{const{add:{edges:e},update:{nodes:n,edges:r,combos:i},remove:{edges:o}}=t,{model:a}=this.context,s=new Map,u=(t,e)=>{a.getRelatedEdgesData(e).forEach((t=>!s.has(Xc(t))&&s.set(Xc(t),t)))};n.forEach(u),i.forEach(u);const c=t=>{kV(t,a.getEdgeData()).forEach((t=>!s.has(Xc(t))&&s.set(Xc(t),t)))};if(o.size&&o.forEach(c),e.size&&e.forEach(c),r.size){const t=hL(lL(a.getChanges())).update.edges;r.forEach((e=>{c(e);const n=t.find((t=>Xc(t.value)===Xc(e)))?.original;n&&!CV(e,n)&&c(n)}))}he(this.options.edges)||s.forEach(((t,e)=>!this.options.edges.includes(e)&&s.delete(e)));const l=a.getEdgeData().map(Xc);return new Map([...s].sort(((t,e)=>l.indexOf(t[0])-l.indexOf(e[0]))))};applyBundlingStyle=(t,e,n)=>{const{edgeMap:r,reverses:i}=NV(e);r.forEach((e=>{e.forEach(((e,r,o)=>{const a=ce(e,{type:"quadratic",style:(()=>{const t=o.length,a={};if(e.source===e.target){const t=MV.length;a.loopPlacement=MV[r%t],a.loopDist=Math.floor(r/t)*n+50}else if(1===t)a.curveOffset=0;else{const o=(r%2==0?1:-1)*(i[`${e.source}|${e.target}|${r}`]?-1:1);a.curveOffset=t%2==1?o*Math.ceil(r/2)*n*2:o*(Math.floor(r/2)*n*2+n)}return a})()}),s=this.context.element?.getElement(Xc(e));t(s?"update":"add","edge",a)}))}))};applyMergingStyle=(t,e)=>{const{edgeMap:n,reverses:r}=NV(e);n.forEach((e=>{if(1===e.length){const n=e[0],r=this.context.element?.getElement(Xc(n));return void t(r?"update":"add","edge",n)}const n=e.map((({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:a}=n,s={},[u,c]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return ne(o)&&(s[u]=o),ne(a)&&(s[c]=a),s})).reduce(((t,e)=>({...t,...e})),{});e.forEach(((e,r)=>{if(0===r){const r={...e,style:{...n,...this.options.style}},i=this.context.element?.getElement(Xc(e));t(i?"update":"add","edge",r)}else t("remove","edge",e)}))}))}}const NV=t=>{const e=new Map,n=new Set,r={};for(const[i,o]of t){if(n.has(i))continue;const{source:a,target:s}=o,u=`${a}-${s}`;e.has(u)||e.set(u,[]),e.get(u).push(o),n.add(i);for(const[i,c]of t)n.has(i)||CV(o,c)&&(e.get(u).push(c),n.add(i),a===c.target&&s===c.source&&(r[`${c.source}|${c.target}|${e.get(u).length-1}`]=!0))}return{edgeMap:e,reverses:r}},kV=(t,e,n)=>e.filter((e=>CV(e,t))),CV=(t,e)=>{const{source:n,target:r}=t,{source:i,target:o}=e;return n===i&&r===o||n===o&&r===i};const TV={animation:{fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}],"combo-collapse-expand":[{fields:["x","y"]},{fields:["r","width","height"],shape:"key"}]},behavior:{"zoom-canvas":Wd,"drag-canvas":kd,"drag-element":Cd,"drag-element-force":Bd,"scroll-canvas":Vd,"collapse-expand":Md,"click-element":Ed,"hover-element":Fd,"focus-element":zd,"create-edge":Nd,"brush-select":yd,"lasso-select":Gd},combo:{circle:fh,rect:ph},edge:{cubic:Bh,line:Gh,polyline:Vh,quadratic:Wh,"cubic-horizontal":zh,"cubic-vertical":Fh},layout:{"antv-dagre":nm,"combo-combined":By,"compact-box":Qf.compactBox,"force-atlas2":MI,circular:am,concentric:lm,d3force:Tv,"d3-force-3d":sw,dagre:vI,dendrogram:Qf.dendrogram,force:_m,fruchterman:NI,grid:CI,indented:Qf.indented,mds:Ry,mindmap:Qf.mindmap,radial:BI,random:UI},node:{circle:Jl,diamond:eh,ellipse:oh,hexagon:ah,html:sh,image:uh,rect:ch,star:lh,donut:nh,triangle:hh},palette:{spectral:["rgb(158, 1, 66)","rgb(213, 62, 79)","rgb(244, 109, 67)","rgb(253, 174, 97)","rgb(254, 224, 139)","rgb(255, 255, 191)","rgb(230, 245, 152)","rgb(171, 221, 164)","rgb(102, 194, 165)","rgb(50, 136, 189)","rgb(94, 79, 162)"],tableau:["rgb(78, 121, 167)","rgb(242, 142, 44)","rgb(225, 87, 89)","rgb(118, 183, 178)","rgb(89, 161, 79)","rgb(237, 201, 73)","rgb(175, 122, 161)","rgb(255, 157, 167)","rgb(156, 117, 95)","rgb(186, 176, 171)"],oranges:["rgb(255, 245, 235)","rgb(254, 230, 206)","rgb(253, 208, 162)","rgb(253, 174, 107)","rgb(253, 141, 60)","rgb(241, 105, 19)","rgb(217, 72, 1)","rgb(166, 54, 3)","rgb(127, 39, 4)"],greens:["rgb(247, 252, 245)","rgb(229, 245, 224)","rgb(199, 233, 192)","rgb(161, 217, 155)","rgb(116, 196, 118)","rgb(65, 171, 93)","rgb(35, 139, 69)","rgb(0, 109, 44)","rgb(0, 68, 27)"],blues:["rgb(247, 251, 255)","rgb(222, 235, 247)","rgb(198, 219, 239)","rgb(158, 202, 225)","rgb(107, 174, 214)","rgb(66, 146, 198)","rgb(33, 113, 181)","rgb(8, 81, 156)","rgb(8, 48, 107)"]},theme:{dark:bV,light:xV},plugin:{"bubble-sets":eL,"grid-line":cL,contextmenu:uL,history:pL,timebar:aV,hull:zL,legend:lG,toolbar:lV,tooltip:hV,watermark:pV},transform:{"update-related-edges":class extends wV{beforeDraw(t){const{model:e}=this.context,{update:{nodes:n,edges:r,combos:i}}=t,o=(t,n)=>{e.getRelatedEdgesData(n).forEach((t=>!r.has(Xc(t))&&r.set(Xc(t),t)))};return n.forEach(o),i.forEach(o),t}},"arrange-draw-order":class extends wV{beforeDraw(t){const{model:e}=this.context,n=t.add.combos,r=t=>{const n=[];return t.forEach(((t,r)=>{const i=e.getAncestorsData(r,"combo").map((t=>Xc(t))).reverse();n.push([r,t,i.length])})),new Map(n.sort((([,,t],[,,e])=>e-t)).map((([t,e])=>[t,e])))};return t.add.combos=r(n),t.update.combos=r(t.update.combos),t}},"collapse-expand-combo":class extends wV{beforeDraw(t){const{model:e}=this.context,{add:n,update:r}=t,i=[...t.update.combos.entries(),...t.add.combos.entries()];for(;i.length;){const[o,a]=i.pop();if(!!a.style?.collapsed){const a=e.getDescendantsData(o),s=a.map(Xc),{internal:u,external:c}=Rh(s,(t=>e.getRelatedEdgesData(t)));a.forEach((n=>{const r=Xc(n),o=i.findIndex((([t])=>t===r));-1!==o&&i.splice(o,1);const a=e.getElementType(r);EV(t,"remove",a,n)})),u.forEach((e=>EV(t,"remove","edge",e))),c.forEach((t=>{const e=Xc(t),i=this.context.element?.getElement(e);i?r.edges.set(e,t):n.edges.set(e,t)}))}else{const n=e.getChildrenData(o),r=n.map(Xc),{edges:a}=Rh(r,(t=>e.getRelatedEdgesData(t)));[...n,...a].forEach((n=>{const r=Xc(n),o=e.getElementType(r),a=this.context.element?.getElement(r);EV(t,a?"update":"add",o,n),"combo"===o&&i.push([r,n])}))}}return t}},"process-parallel-edges":SV}},AV={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{}};function PV(t,e,n){AV[t][e]?console.error(`The extension ${e} of ${t} has been registered before.`):Object.assign(AV[t],{[e]:n})}function OV(t,e){const n=AV[t]?.[e];if(n)return n}Es.enableCSSParsing=!1,Object.entries(TV).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{PV(t,e,n)}))}));class _V{type;constructor(t){this.type=t}}class RV extends _V{data;constructor(t,e){super(t),this.data=e}}class IV extends _V{animationType;animation;data;constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class DV extends _V{elementType;data;constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class LV extends _V{data;constructor(t,e){super(t),this.data=e}}function jV(t,e){t.emit(e.type,e)}function BV(t,e){const{datum:n}=e;return Ot(t)?t(n):Object.fromEntries(Object.entries(t).map((([t,e])=>Ot(e)?[t,e(n)]:[t,e])))}function zV(t){return t.style?.zIndex??sd("zIndex")??0}class FV{context;batchCount=0;constructor(t){this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(e=!0){this.batchCount++,1===this.batchCount&&this.emit(new RV(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new RV(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class GV extends dd{currentTarget=null;category="behavior";constructor(t){super(t),this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.addEventListener(t,this.forwardContainerEvents)}));const n=this.context.canvas.document;n&&[t.CanvasEvent.CLICK,t.CanvasEvent.DBLCLICK,t.CanvasEvent.POINTER_OVER,t.CanvasEvent.POINTER_LEAVE,t.CanvasEvent.POINTER_ENTER,t.CanvasEvent.POINTER_MOVE,t.CanvasEvent.POINTER_OUT,t.CanvasEvent.POINTER_DOWN,t.CanvasEvent.POINTER_UP,t.CanvasEvent.CONTEXT_MENU,t.CanvasEvent.DRAG_START,t.CanvasEvent.DRAG,t.CanvasEvent.DRAG_END,t.CanvasEvent.DRAG_ENTER,t.CanvasEvent.DRAG_OVER,t.CanvasEvent.DRAG_LEAVE,t.CanvasEvent.DROP,t.CanvasEvent.WHEEL].forEach((t=>{n.addEventListener(t,this.forwardCanvasEvents)}))}forwardCanvasEvents=e=>{const{target:n}=e,r=function(t){if(!t)return null;if(t instanceof Qs)return{type:"canvas",element:t};let e=t;for(;e;){if(Hh(e))return{type:"node",element:e};if(Uh(e))return{type:"edge",element:e};if($h(e))return{type:"combo",element:e};e=e.parentElement}return null}(n);if(!r)return;const{graph:i,canvas:o}=this.context,{type:a,element:s}=r,{type:u,detail:c,button:l}=e,h={...e,target:s,targetType:a,originalTarget:n};if(u===t.CanvasEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${a}:${t.CanvasEvent.POINTER_LEAVE}`,{...h,target:this.currentTarget}),s&&i.emit(`${a}:${t.CanvasEvent.POINTER_ENTER}`,h)),this.currentTarget=s),u===t.CanvasEvent.CLICK&&2===l||(i.emit(`${a}:${u}`,h),i.emit(u,h)),u===t.CanvasEvent.CLICK&&2===c&&(i.emit(`${a}:${t.CanvasEvent.DBLCLICK}`,h),i.emit(t.CanvasEvent.DBLCLICK,h)),u===t.CanvasEvent.POINTER_DOWN&&2===l){const e={...h,preventDefault:()=>{o.getContainer()?.addEventListener(t.CanvasEvent.CONTEXT_MENU,(t=>t.preventDefault()),{once:!0})}};i.emit(`${a}:${t.CanvasEvent.CONTEXT_MENU}`,e),i.emit(t.CanvasEvent.CONTEXT_MENU,e)}};forwardContainerEvents=t=>{this.context.graph.emit(t.type,t)};destroy(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.removeEventListener(t,this.forwardContainerEvents)})),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}var VV=function(){function t(t){this.dragndropPluginOptions=t}return t.prototype.apply=function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,u=function(t){var e=t.target,r=e===i,u=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(u){var c=!1,l=t.timeStamp,h=[t.clientX,t.clientY],d=null,f=[t.clientX,t.clientY],p=function(t){return a(n,void 0,void 0,(function(){var n,o,a,p,g,m;return s(this,(function(s){switch(s.label){case 0:if(!c){if(n=t.timeStamp-l,o=He([t.clientX,t.clientY],h),n<=this.dragndropPluginOptions.dragstartTimeThreshold||o<=this.dragndropPluginOptions.dragstartDistanceThreshold)return[2];t.type="dragstart",u.dispatchEvent(t),c=!0}return t.type="drag",t.dx=t.clientX-f[0],t.dy=t.clientY-f[1],u.dispatchEvent(t),f=[t.clientX,t.clientY],r?[3,2]:(a="pointer"===this.dragndropPluginOptions.overlap?[t.canvasX,t.canvasY]:e.getBounds().center,[4,i.elementsFromPoint(a[0],a[1])]);case 1:p=s.sent(),g=p[p.indexOf(e)+1],m=(null==g?void 0:g.closest("[droppable=true]"))||(this.dragndropPluginOptions.isDocumentDroppable?i:null),d!==m&&(d&&(t.type="dragleave",t.target=d,d.dispatchEvent(t)),m&&(t.type="dragenter",t.target=m,m.dispatchEvent(t)),(d=m)&&(t.type="dragover",t.target=d,d.dispatchEvent(t))),s.label=2;case 2:return[2]}}))}))};o.addEventListener("pointermove",p);var g=function(t){if(c){t.detail={preventClick:!0};var e=t.clone();d&&(e.type="drop",e.target=d,d.dispatchEvent(e)),e.type="dragend",u.dispatchEvent(e),c=!1}o.removeEventListener("pointermove",p)};e.addEventListener("pointerup",g,{once:!0}),e.addEventListener("pointerupoutside",g,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",u)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",u)}))},t.tag="Dragndrop",t}(),WV=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="dragndrop",n}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new VV(i({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e.prototype.setOptions=function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)},e}(ir);class HV{config;background;main;label;transient;get canvas(){return{main:this.main,label:this.label,transient:this.transient,background:this.background}}get document(){return this.main.document}renderers;initialized=!1;constructor(t){this.config=t}async init(){if(this.initialized)return;const{renderer:t,background:e,...n}=this.config,{renderers:r,canvas:i}=["main","label","transient","background"].reduce(((e,r)=>{const i=Ot(t)?t?.(r):new iV;"main"===r?i.registerPlugin(new WV({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):i.unregisterPlugin(i.getPlugin("dom-interaction"));const o=new cu({renderer:i,supportsMutipleCanvasesInOneContainer:!0,...n});return e.renderers[r]=i,e.canvas[r]=o,this[r]=o,e}),{renderers:{},canvas:{}});this.renderers=r,Object.entries(i).forEach((([t,e])=>{const n=e.getContextService().getDomElement();n.style.position="absolute",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")})),this.setBackground(),await Promise.all(Object.values(this.canvas).map((t=>t.ready))),this.initialized=!0}getRendererType(t="main"){const e=this.renderers[t].getPlugins();for(const t of e){if("canvas-renderer"===t.name)return"canvas";if("svg-renderer"===t.name)return"svg";if("device-renderer"===t.name)return"gpu"}return"unknown"}get context(){return this.main.context}getDevice(){return this.main.context?.deviceRendererPlugin?.getDevice()}getConfig(){return this.config}setBackground(t=this.config.background){const e=this.getContainer();this.config.background=t,e&&t&&(e.style.background=t,e.style.transition="background 0.5s")}setCursor(t){Object.values(this.canvas).forEach((e=>{e.setCursor(t)}))}getSize(){return[this.config.width||0,this.config.height||0]}resize(t,e){this.config.width=t,this.config.height=e,Object.values(this.canvas).forEach((n=>{n.resize(t,e)}))}getCamera(){return this.main.getCamera()}getBounds(){return Bc(Object.values(this.canvas).map((t=>t.document.documentElement)).filter((t=>t.childNodes.length>0)).map((t=>t.getBounds())))}getContainer(){const t=this.config.container;return Vt(t)?document.getElementById(t):t}appendChild(t){return this[t.style?.$layer||"main"].appendChild(t)}getContextService(){return this.main.getContextService()}viewport2Client(t){return this.main.viewport2Client(t)}viewport2Canvas(t){return this.main.viewport2Canvas(t)}client2Viewport(t){return this.main.client2Viewport(t)}canvas2Viewport(t){return this.main.canvas2Viewport(t)}async toDataURL(t={}){const e=window.devicePixelRatio||1,{mode:n="viewport",...r}=t;let i=0,o=0,a=0,s=0;if("viewport"===n)[a,s]=[this.config.width||0,this.config.height||0];else if("overall"===n){const t=this.getBounds(),e=Dc(t);[i,o]=t.min,[a,s]=e}const u=on('<div id="virtual-image"></div>'),c=new cu({width:a,height:s,renderer:new iV,devicePixelRatio:e,container:u,background:this.config.background});await c.ready,c.appendChild(this.background.getRoot().cloneNode(!0)),c.appendChild(this.main.getRoot().cloneNode(!0));const l=this.label.getRoot().cloneNode(!0),h=c.viewport2Canvas({x:0,y:0}),d=this.main.viewport2Canvas({x:0,y:0});l.translate([d.x-h.x,d.y-h.y]),l.scale(1/this.main.getCamera().getZoom()),c.appendChild(l),c.appendChild(this.transient.getRoot().cloneNode(!0));const f=this.main.getCamera(),p=c.getCamera();if("viewport"===n)p.setZoom(f.getZoom()),p.setPosition(f.getPosition()),p.setFocalPoint(f.getFocalPoint());else if("overall"===n){const[t,e,n]=p.getPosition(),[r,a,s]=p.getFocalPoint();p.setPosition([t+i,e+o,n]),p.setFocalPoint([r+i,a+o,s])}const g=c.getContextService();return new Promise((t=>{c.on(Os.RERENDER,(async()=>{await new Promise((t=>setTimeout(t,300)));const e=await g.toDataURL(r);t(e)}))}))}destroy(){this.config={},this.renderers={},Object.entries(this.canvas).forEach((([t,e])=>{const n=e.getCamera();n.landmarks?.length&&n.cancelLandmarkAnimation(),function(t){t.destroy();const e=t.getCamera();e.eventEmitter.removeAllListeners(),t.document.timeline.destroy();const{animationsWithPromises:n}=t.document.timeline;n.forEach((t=>{t.effect.target&&(t.effect.target=null),t.effect.computedTiming&&(t.effect.computedTiming=null)})),t.document.timeline.animationsWithPromises=[],t.document.timeline.rafCallbacks=[],t.document.timeline=null}(e),this[t]=void 0}))}}function UV(t,e){const{data:n,style:r,...i}=t,{data:o,style:a,...s}=e,u={...i,...s};return(n||o)&&Object.assign(u,{data:{...n,...o}}),(r||a)&&Object.assign(u,{style:{...r,...a}}),u}function $V(t){const{data:e,style:n,...r}=t,i=r;return e&&(i.data={...e}),n&&(i.style={...n}),i}function qV(t){const{id:e=Xc(t),style:n,data:r,...i}=t,o={...t,style:{...n},data:{...r}};return Ac(t)?{id:e,data:o,...i}:{id:e,data:o}}function YV(t){return t.data}class KV{model;latestRemovedComboIds=new Set;comboIds=new Set;changes=[];batchCount=0;isTraceless=!1;constructor(){this.model=new Rd}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===vc.NodeUpdated||e===vc.EdgeUpdated||e===vc.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:$V(n),original:$V(r),type:e})}else this.changes.push({value:$V(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=YV(n);return this.isCombo(Xc(r))||(void 0===t||t.includes(Xc(r)))&&e.push(r),e}),[])}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=YV(n);return(void 0===t||t.includes(Xc(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=YV(n);return this.isCombo(Xc(r))?((void 0===t||t.includes(Xc(r)))&&e.push(r),e):e}),[])}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(YV):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return bd(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(Xc(t))),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void console.error("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?YV(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?Cc:kc,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(YV):[]}getElementsDataByType(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementDataById(t){const e=this.getElementType(t);return"node"===e?this.getNodeData([t])[0]:"edge"===e?this.getEdgeData([t])[0]:this.getComboData([t])[0]}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=YV(n);return t?t.includes(Xc(r))&&e.push(r):e.push(r),e}),[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter((t=>t.states?.includes(e)))}getElementState(t){return this.getElementDataById(t)?.states||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(YV)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(YV)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i=[],edges:o=[],combos:a=[]}=this.getData(),s=hd(i,e,(t=>Xc(t))),u=hd(o,n,(t=>Xc(t))),c=hd(a,r,(t=>Xc(t)));this.batch((()=>{this.addData({nodes:s.enter,edges:u.enter,combos:c.enter}),this.updateData({nodes:s.update,edges:u.update,combos:c.update}),this.removeData({nodes:s.exit.map(Xc),edges:u.exit.map(Xc),combos:c.exit.map(Xc)})}))}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)}))}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map((t=>(this.pushChange({value:t,type:vc.NodeAdded}),qV(t))))),this.updateNodeLikeHierarchy(t))}addEdgeData(t=[]){t.length&&this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:vc.EdgeAdded}),qV(t)))))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(kc)||e.attachTreeStructure(kc),e.addNodes(t.map((t=>(this.comboIds.add(Xc(t)),this.pushChange({value:t,type:vc.ComboAdded}),qV(t))))),this.updateNodeLikeHierarchy(t)}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=Xc(t);e.attachTreeStructure(kc),this.setParent(n,Zc(t),kc);const r=t.children;void 0!==r&&(e.attachTreeStructure(Cc),r.forEach((t=>{this.setParent(t,n,Cc)})))}))}enableUpdateNodeLikeHierarchy=!0;preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.updateNodeData(e),this.updateComboData(r),this.updateEdgeData(n)}))}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{const n=[];t.forEach((t=>{const r=Xc(t),i=YV(e.getNode(r));if(de(i,t))return;const o=UV(i,t);this.pushChange({value:o,original:i,type:vc.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}refreshData(){const{nodes:t,edges:e,combos:n}=this.getData();t.forEach((t=>{this.pushChange({value:t,original:t,type:vc.NodeUpdated})})),e.forEach((t=>{this.pushChange({value:t,original:t,type:vc.EdgeUpdated})})),n.forEach((t=>{this.pushChange({value:t,original:t,type:vc.ComboUpdated})}))}syncNodeDatum(t){const{model:e}=this,n=Xc(t),r=UV(YV(e.getNode(n)),t);e.mergeNodeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{t.forEach((t=>{const n=Xc(t),r=YV(e.getEdge(n));if(de(r,t))return;t.source&&r.source!==t.source&&e.updateEdgeSource(n,t.source),t.target&&r.target!==t.target&&e.updateEdgeTarget(n,t.target);const i=UV(r,t);this.pushChange({value:i,original:r,type:vc.EdgeUpdated}),e.mergeEdgeData(n,i)}))}))}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=Xc(t),i=YV(e.getNode(r));if(de(i,t))return;const o=UV(i,t);this.pushChange({value:o,original:i,type:vc.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}setParent(t,e,n,r=!0){if(t===e)return;const i=Zc(this.getNodeLikeData([t])[0]);if(i!==e){const n={id:t,combo:e};this.isCombo(t)?this.syncComboDatum(n):this.syncNodeDatum(n)}this.model.setParent(t,e,n),r&&new Set([i,e]).forEach((t=>{void 0!==t&&this.refreshComboData(t)}))}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,kc);e&&this.pushChange({value:e,original:e,type:vc.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:vc.ComboUpdated})}))}syncComboDatum(t){const{model:e}=this,n=Xc(t),r=UV(YV(e.getNode(n)),t);e.mergeNodeData(n,r)}getElementPosition(t){return Vc(this.getElementDataById(t))}translateNodeBy(t,e){const n=ol(this.getElementPosition(t),[...e,0].slice(0,3));this.translateNodeTo(t,n)}translateNodeTo(t,e){const[n=0,r=0,i=0]=e;this.preventUpdateNodeLikeHierarchy((()=>{this.updateNodeData([{id:t,style:{x:n,y:r,z:i}}])}))}translateComboBy(t,e){const[n=0,r=0,i=0]=e;if([n,r,i].some(isNaN)||[n,r,i].every((t=>0===t)))return;const o=this.getComboData([t])[0];o&&bd(o,(t=>{const e=Xc(t),[o,a,s]=Vc(t),u=UV(t,{style:{x:o+n,y:a+r,z:s+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?vc.ComboUpdated:vc.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(Xc(t))),"BT")}translateComboTo(t,e){if(e.some(isNaN))return;const[n=0,r=0,i=0]=e,o=this.getComboData([t])?.[0];if(!o)return;const[a,s,u]=Vc(o),c=n-a,l=r-s,h=i-u;bd(o,(t=>{const e=Xc(t),[n,r,i]=Vc(t),o=UV(t,{style:{x:n+c,y:r+l,z:i+h}});this.pushChange({value:o,original:t,type:this.isCombo(e)?vc.ComboUpdated:vc.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(Xc(t))),"BT")}removeData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.removeEdgeData(n),this.removeNodeData(e),this.removeComboData(r),this.latestRemovedComboIds=new Set(r)}))}removeNodeData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Xc)),this.pushChange({value:this.getNodeData([t])[0],type:vc.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:vc.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:vc.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(kc)){const e=Zc(this.getNodeLikeData([t])[0]);this.setParent(t,void 0,kc,!1),this.model.getChildren(t,kc).forEach((t=>{const n=YV(t),r=Xc(n);this.setParent(Xc(n),e,kc,!1);const i=UV(n,{id:Xc(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?vc.ComboUpdated:vc.NodeUpdated}),this.model.mergeNodeData(Xc(n),i)})),ie(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error(`Unknown element type of id: ${t}`)}getFrontZIndex(t){let e=[];if("combo"===this.getElementType(t)){const n=[t,...this.getAncestorsData(t,kc).map(Xc)];e=this.getComboData().filter((t=>{const e=Xc(t),r=this.getAncestorsData(e,kc),i=r.map(Xc);return!r.some((t=>!!t.style?.collapsed))&&!n.includes(e)&&!i.includes(e)}))}else e=this.getNodeData().filter((e=>Xc(e)!==t));return Math.max(0,...e.map(zV))+1}destroy(){const{model:t}=this,e=t.getAllNodes(),n=t.getAllEdges();t.removeEdges(n.map((t=>t.id))),t.removeNodes(e.map((t=>t.id))),this.context={}}}class XV{context;container;elementMap={};shapeTypeMap={};constructor(t){this.context=t}init(){if(!this.container){const{canvas:t}=this.context;this.container={node:t.appendChild(new Vs({style:{zIndex:2}})),edge:t.appendChild(new Vs({style:{zIndex:1}})),combo:t.appendChild(new Vs({style:{zIndex:0}}))}}}emit(t,e){e.silence||jV(this.context.graph,t)}forEachElementData(t){Ql.forEach((e=>{const n=this.context.model.getElementsDataByType(e);t(e,n)}))}getElementType(t,e){const{options:n}=this.context,r=n[t]?.type||e.type;return r?Vt(r)?r:r(e):{node:"circle",edge:"line",combo:"circle"}[t]}getTheme(t){const{theme:e}=this.context.options;if(!e)return{};const n=OV("theme",e);return n?.[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:n={}}=this.getTheme(t);return Object.assign({},...e.map((t=>n[t]||{})))}paletteStyle={};computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData(((e,n)=>{const r=Object.assign({},yl(this.getTheme(e)?.palette),yl(t[e]?.palette));!he(r)&&r?.field&&Object.assign(this.paletteStyle,function(t,e){if(!e)return{};const{type:n,color:r,field:i,invert:o}=e,a=t=>{const e=Vt(r)?OV("palette",r):r;if(Ot(e))return Object.fromEntries(t.map((([t,n])=>[t,e(o?1-n:n)])));if(Array.isArray(e)){const n=o?[...e].reverse():e;return Object.fromEntries(t.map((([t,r])=>[t,n[r%e.length]])))}return{}},s=(t,e)=>Vt(t)?e.data?.[t]:t?.(e);if("group"===n){const e=Ht(t,(t=>{if(!i)return"default";const e=s(i,t);return e?String(e):"default"})),n=a(Object.keys(e).map(((t,e)=>[t,e]))),r={};return Object.entries(e).forEach((([t,e])=>{e.forEach((e=>{r[Xc(e)]=n[t]}))})),r}if("value"===n){const[e,n]=t.reduce((([t,e],n)=>{const r=s(i,n);if(!$t(r))throw new Error(`Palette field ${i} is not a number`);return[Math.min(t,r),Math.max(e,r)]}),[1/0,-1/0]),r=n-e;return a(t.map((t=>[t.id,(s(i,t)-e)/r])))}}(n,r))}))}getPaletteStyle(t,e){const n=this.paletteStyle[e];return n?"edge"===t?{stroke:n}:{fill:n}:{}}defaultStyle={};computeElementDefaultStyle(t,e){const{options:n}=this.context,r=n[t]?.style||{};this.defaultStyle[Xc(e.datum)]=BV(r,e)}computeElementsDefaultStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Xc(e)))).forEach((t=>{this.computeElementDefaultStyle(e,{datum:t})}))}))}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch{return[]}}stateStyle={};getElementStateStyle(t,e,n){const{options:r}=this.context;return BV(r[t]?.state?.[e]||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Xc(n.datum)]=Object.assign({},...e.map((e=>this.getElementStateStyle(t,e,n))))}computeElementsStatesStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Xc(e)))).forEach((t=>{const n=this.getElementState(Xc(t));this.computeElementStatesStyle(e,n,{datum:t})}))}))}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t){this.computePaletteStyle(),this.computeElementsDefaultStyle(t),this.computeElementsStatesStyle(t)}getElement(t){return this.elementMap[t]}getNodes(){return this.container.node.children}getEdges(){return this.container.edge.children}getCombos(){return this.container.combo.children}getAnimation(t,e){const{options:n}=this.context,r=n?.[t]?.animation;if(!1===r)return!1;const i=r?.[e];if(i)return i;const o=this.getTheme(t)?.animation;if(!1===o)return!1;const a=o?.[e];return a??!1}getAnimationExecutor(t,e,n=!0,r){const{options:i}=this.context,o=fe(i,[t,"animation",e],!0);return!1!==i.animation&&!1!==o&&n?(n,i,o,a)=>ld(i,this.getAnimation(t,e),{},{originalStyle:o,modifiedStyle:a,states:this.getElementState(n),...r}):()=>null}getEdgeEndsContext(t){const{model:e}=this.context,{source:n,target:r}=t,i=e.getElementDataById(n),o=e.getElementDataById(r),a=this.getElement(Ih(i,(t=>e.getParentData(t,kc))).id),s=this.getElement(Ih(o,(t=>e.getParentData(t,kc))).id);return{sourceNode:a,targetNode:s}}getElementComputedStyle(t,e){const n=Xc(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),u=this.getStateStyle(n),c=Object.assign({},r,i,o,a,s,u);if("edge"===t)Object.assign(c,this.getEdgeEndsContext(e));else if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!c.collapsed?[]:t.map((t=>this.getElement(Xc(t)))).filter(Boolean);Object.assign(c,{childrenNode:e,childrenData:t})}return c}async draw(e={animation:!0}){this.init();const n=this.computeChangesAndDrawData();if(!n)return;const{dataChanges:r,drawData:i}=n;this.computeStyle();const{add:o,update:a,remove:s}=i,u=this.getDestroyTasks(s,e),c=this.getCreateTasks(o,e),l=this.getUpdateTasks(a,e);await(function(t,e={}){if(0===t.length)return null;const{before:n,...r}=e;e.before?.();const i=od(t.map((t=>t())).map((t=>t())).flat().filter(Boolean));return ud(i,r),i}([...u,...c,...l],e.silence?{}:{before:()=>this.emit(new RV(t.GraphEvent.BEFORE_DRAW,{dataChanges:r,animation:e.animation}),e),beforeAnimate:n=>this.emit(new IV(t.GraphEvent.BEFORE_ANIMATE,bc.DRAW,n,i),e),afterAnimate:n=>this.emit(new IV(t.GraphEvent.AFTER_ANIMATE,bc.DRAW,n,i),e),after:()=>this.emit(new RV(t.GraphEvent.AFTER_DRAW,{dataChanges:r,animation:e.animation}),e)})?.finished)}computeChangesAndDrawData(){const{model:t}=this.context,e=t.getChanges(),n=lL(e);if(0===n.length)return null;const{NodeAdded:r=[],NodeUpdated:i=[],NodeRemoved:o=[],EdgeAdded:a=[],EdgeUpdated:s=[],EdgeRemoved:u=[],ComboAdded:c=[],ComboUpdated:l=[],ComboRemoved:h=[]}=Ht(n,(t=>t.type)),d=t=>new Map(t.map((t=>{const e=t.value;return[Xc(e),e]}))),f={add:{nodes:d(r),edges:d(a),combos:d(c)},update:{nodes:d(i),edges:d(s),combos:d(l)},remove:{nodes:d(o),edges:d(u),combos:d(h)}},p=this.transformData(f);return t.clearChanges(),{dataChanges:e,drawData:p}}transformData(t){const e=this.context.transform.getTransformInstance();return Object.values(e).reduce(((t,e)=>e.beforeDraw(t)),t)}createElement(e,n,r){const i=Xc(n);if(this.getElement(i))return()=>null;const o=this.getElementType(e,n),a=this.getElementComputedStyle(e,n),s=OV(e,o);if(!s)return()=>null;this.emit(new DV(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const u=this.container[e].appendChild(new s({id:i,style:{context:this.context,...a}}));this.shapeTypeMap[i]=o,this.elementMap[i]=u;const{animation:c,animator:l}=r;return()=>ud(c?l?.(i,u,{...u.attributes,opacity:0}):null,{after:()=>{this.emit(new DV(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),u.onCreate()}})}getCreateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[];return[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{if(0===n.size)return;const r=this.getAnimationExecutor(t,"enter",e.animation);n.forEach((n=>o.push((()=>this.createElement(t,n,{...e,animator:r})))))})),o}latestElementVisibilityMap=new WeakMap;updateElement(e,n,r){const{animator:i}=r,o=Xc(n),a=this.getElement(o);if(!a)return()=>null;this.emit(new DV(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const s=()=>{this.emit(new DV(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n),r),a.onUpdate()},u=this.getElementType(e,n),c=this.getElementComputedStyle(e,n);if(this.shapeTypeMap[o]!==u)return this.destroyElement(e,n,{animation:!1,silence:!0})(),this.createElement(e,n,{animation:!1,silence:!0})(),()=>(s(),null);if("visibility"===r.stage&&"visibility"in c){zl(a,"opacity")||jl(a,"opacity");const t=Bl(a,"opacity")??sd("opacity");if(this.latestElementVisibilityMap.set(a,c.visibility),"hidden"!==c.visibility)return id(a,{visibility:"visible"}),()=>ud(i?.(o,a,{...a.attributes,opacity:0},{opacity:t}),{after:s});if("hidden"===c.visibility)return()=>ud(i?.(o,a,{...a.attributes,opacity:t},{opacity:0}),{after:()=>{id(a,{visibility:this.latestElementVisibilityMap.get(a)}),s()}})}const l={...a.attributes};return id(a,c),"edge"===e&&(l.sourceNode.destroyed&&(l.sourceNode=c.sourceNode),l.targetNode.destroyed&&(l.targetNode=c.targetNode)),()=>ud(i?.(o,a,l),{after:s})}getUpdateTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["node",n],["combo",i],["edge",r]],{animation:a,stage:s}=e,u=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"update",a);n.forEach((n=>u.push((()=>this.updateElement(t,n,{...e,animator:r})))))})),u}destroyElement(e,n,r){const{animator:i}=r,o=Xc(n),a=this.elementMap[o];return a?(this.emit(new DV(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n),r),()=>ud(i?.(o,a,{...a.attributes},{opacity:0}),{after:()=>{this.clearElement(o),a.destroy(),a.onDestroy(),this.emit(new DV(t.GraphEvent.AFTER_ELEMENT_DESTROY,e,n),r)}})):()=>null}getDestroyTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["combo",i],["edge",r],["node",n]],{animation:a,stage:s="exit"}=e,u=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s,a);n.forEach((n=>u.push((()=>this.destroyElement(t,n,{...e,animator:r})))))})),u}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}destroy(){Object.values(this.elementMap).forEach((t=>t.destroy())),Object.values(this.container).forEach((t=>t.destroy())),this.container={},this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={},this.context={},this.latestElementVisibilityMap=void 0}}class ZV{context;supervisor;instance;instances=[];animationResult;get presetOptions(){return{animation:!!cd(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.context=t}getLayoutInstance(){return this.instances}async layout(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;jV(n,new RV(t.GraphEvent.BEFORE_LAYOUT));for(const t of e){const n=e.indexOf(t),r=this.getLayoutData(t),i=await this.stepLayout(r,{...this.presetOptions,...t},n);t.animation||this.updateElementPosition(i,!1)}jV(n,new RV(t.GraphEvent.AFTER_LAYOUT))}async stepLayout(t,e,n){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?await this.treeLayout(t,e,n):await this.graphLayout(t,e,n)}async graphLayout(t,e,n){const{animation:r,enableWorker:i,iterations:o=300}=e,a=this.initGraphLayout(e);if(this.instances[n]=a,this.instance=a,i){const e=a;return this.supervisor=new fD(e.graphData2LayoutModel(t),e.instance,{iterations:o}),Dd(await this.supervisor.execute())}if($I(a))return r?await a.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(a.execute(t),a.stop(),a.tick(o));const s=await a.execute(t);return r&&this.updateElementPosition(s,r),s}async treeLayout(t,e,n){const{type:r,animation:i}=e,o=OV("layout",r);if(!o)throw new Error(`The layout type ${r} is not found`);const{nodes:a=[],edges:s=[]}=t,u=new Rd({nodes:a.map((t=>({id:Xc(t),data:t.data||{}}))),edges:s.map((t=>({id:Xc(t),source:t.source,target:t.target,data:t.data||{}})))});!function(t){if(t.hasTreeStructure(Cc))return;t.attachTreeStructure(Cc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,Cc)}}(u);const c={nodes:[],edges:[]};return u.getRoots(Cc).forEach((t=>{bd(t,(t=>{t.children=u.getSuccessors(t.id)}),(t=>u.getSuccessors(t.id)),"TB");bd(o(t,e),(t=>{const{id:e,x:n,y:r,z:i=0}=t;c.nodes.push({id:e,style:{x:n,y:r,z:i}})}),(t=>t.children),"TB")})),i&&this.updateElementPosition(c,i),c}stopLayout(){this.instance&&$I(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(t){const{nodeFilter:e=(()=>!0)}=t,{nodes:n,edges:r,combos:i}=this.context.model.getData();return{nodes:n.filter(e),edges:r,combos:i}}initGraphLayout(t){const{element:e,viewport:n}=this.context,{type:r,enableWorker:i,animation:o,iterations:a,...s}=t,[u,c]=n.getCanvasSize(),l=[u/2,c/2],h=t?.nodeSize??(t=>{const n=e?.getElement(t.id),{size:r}=n?.attributes||{};return Math.max(...$c(r))}),d=OV("layout",r);if(!d)throw new Error(`The layout type ${r} is not found`);const f=Object.getPrototypeOf(d.prototype)===Id.prototype?d:function(t,e){return class extends Id{instance;id;constructor(e){if(super(e),this.instance=new t,this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>Dd(t.tick(e))}}async execute(t,e){return Dd(await this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(ce({},this.options,e))))}transformOptions(t){const{onTick:e}=t;return e?(t.onTick=t=>e(Dd(t)),t):t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map((t=>{const e=Xc(t),{data:n,style:r,combo:i}=t;return{id:e,data:{...n,...i?{parentId:i}:{}},style:{...r}}})),a=new Map(o.map((t=>[t.id,t]))),s=r.filter((t=>{const{source:e,target:n}=t;return a.has(e)&&a.has(n)})).map((t=>{const{source:e,target:n,data:r,style:i}=t;return{id:Xc(t),source:e,target:n,data:{...r},style:{...i}}})),u=i.map((t=>({id:Xc(t),data:{_isCombo:!0,...t.data},style:{...t.style}}))),c=new Rd({nodes:[...o,...u],edges:s});return e.model.model.hasTreeStructure(kc)&&(c.attachTreeStructure(kc),o.forEach((t=>{const n=e.model.model.getParent(t.id,kc);n&&c.hasNode(n.id)&&c.setParent(t.id,n.id,kc)}))),c}}}(d,this.context),p=new f,g={nodeSize:h,width:u,height:c,center:l};switch(p.id){case"d3-force":case"d3-force-3d":Object.assign(g,{center:{x:u/2,y:c/2,z:0}})}return ce(p.options,g,s),p}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){this.stopLayout(),this.context={},this.supervisor?.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}class QV extends dd{category="plugin";constructor(t){super(t),this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){return this.extensionMap[t]}}const JV=["update-related-edges","arrange-draw-order","collapse-expand-combo"];class tW extends dd{category="transform";constructor(t){super(t),this.setTransforms(this.context.options.transforms||[])}setTransforms(t){this.setExtensions([...t,...JV])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class eW{context;get padding(){return _c(this.context.options.padding)}get paddingOffset(){const[t,e,n,r]=this.padding,[i,o,a]=[(r-e)/2,(t-n)/2,0];return[i,o,a]}constructor(t){this.context=t;const[e,n]=this.paddingOffset,{zoom:r,rotation:i,x:o=e,y:a=n}=t.options;this.transform({mode:"absolute",scale:r,translate:[o,a],rotate:i},!1)}get camera(){return this.context.canvas.getCamera()}landmarkCounter=0;createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=cd(this.context.options,t);return!!e&&me({...e},["easing","duration"])}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e,n]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e/2,n/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateArgs(t){const e=this.getZoom(),{camera:n}=this,{mode:r,translate:i=[]}=t,[o=0,a=0]=i,[s=0,u=0]=this.getCanvasCenter(),[c,l]=n.getPosition(),h=ul([-o,-a],e);return"relative"===r?h:ol([s-c,u-l],h)}getAnimationTranslateArgs(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),a=e.getFocalPoint(),s=this.getCanvasCenter(),[u=0,c=0,l=0]=r,h=ul([-u,-c,-l],i);return"relative"===n?{position:ol(o,h),focalPoint:ol(a,h)}:{position:ol(s,h),focalPoint:ol(a,h)}}getRotateArgs(t){const{mode:e,rotate:n=0}=t;return"relative"===e?n:n-this.camera.getRoll()}getAnimationRotateArgs(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomArgs(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return Ut("relative"===r?n*i:i,...e)}async transform(e,n){const{camera:r}=this,{graph:i}=this.context,{translate:o,rotate:a,scale:s,origin:u=this.getGraphCenter()}=e;this.cancelAnimation(),jV(i,new LV(t.GraphEvent.BEFORE_TRANSFORM,e));const c=this.getAnimation(n);if(c){const n={};return o&&Object.assign(n,this.getAnimationTranslateArgs(e)),$t(a)&&Object.assign(n,this.getAnimationRotateArgs(e)),$t(s)&&Object.assign(n,{zoom:this.getZoomArgs(e)}),jV(i,new IV(t.GraphEvent.BEFORE_ANIMATE,bc.TRANSFORM,null,e)),new Promise((r=>{this.camera.gotoLandmark(this.createLandmark(n),{...c,onfinish:()=>{jV(i,new IV(t.GraphEvent.AFTER_ANIMATE,bc.TRANSFORM,null,e)),jV(i,new LV(t.GraphEvent.AFTER_TRANSFORM,e)),r()}})}))}if(o&&r.pan(...this.getTranslateArgs(e)),$t(a)){const[t,n]=r.getFocalPoint();u&&r.pan(u[0]-t,u[1]-n);const i=this.getRotateArgs(e);r.rotate(0,0,i),u&&r.pan(t-u[0],n-u[1])}if($t(s)){const t=this.getZoomArgs(e);r.setZoomByViewportPoint(t,u)}jV(i,new LV(t.GraphEvent.AFTER_TRANSFORM,e))}async fitView(t,e){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[u,c]=this.context.canvas.getSize(),l=u-o-r,h=c-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=Dc(f);if("overflow"===a&&!("x"===s&&p>=l||"y"===s&&g>=h||"both"===s&&p>=l&&g>=h))return await this.fitCenter(e);const m=l/p,y=h/g,v="x"===s?m:"y"===s?y:Math.min(m,y),b=this.getAnimation(e);await this.transform({mode:"relative",scale:v,translate:ol(al(this.getCanvasCenter(),this.getBBoxInViewport(d).center),b?ul(this.paddingOffset,v):this.paddingOffset)},b)}async fitCenter(t){const e=this.context.canvas.getBounds();await this.focus(e,t)}async focusElements(t,e){const{element:n}=this.context;if(!n)return;const r=Bc(t.map((t=>n.getElement(t).getRenderBounds())));await this.focus(r,e)}async focus(t,e){const{center:n}=this.getBBoxInViewport(t),r=al(this.getCanvasCenter(),n);await this.transform({mode:"relative",translate:ol(r,this.paddingOffset)},e)}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[a,s]=r.getViewportByCanvas(n),u=new Sr;return u.setMinMax([i,o,0],[a,s,0]),u}cancelAnimation(){this.camera.landmarks?.length&&this.camera.cancelLandmarkAnimation()}}class nW extends Td{options;static defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};destroyed=!1;context={model:new KV};constructor(t){super(),this.options=Object.assign({},nW.defaultOptions,t),this.setOptions(this.options),this.context.graph=this,this.options.autoResize&&window.addEventListener("resize",this.onResize)}getOptions(){return this.options}setOptions(t){const{animation:e,background:n,behaviors:r,combo:i,container:o,data:a,edge:s,height:u,layout:c,node:l,padding:h,plugins:d,theme:f,transforms:p,width:g,zoom:m,zoomRange:y}=t;n&&this.setBackground(n),r&&this.setBehaviors(r),i&&this.setCombo(i),a&&this.setData(a),s&&this.setEdge(s),c&&this.setLayout(c),l&&this.setNode(l),f&&this.setTheme(f),d&&this.setPlugins(d),p&&this.setTransforms(p),($t(g)||$t(u))&&this.setSize(g??this.options.width??0,u??this.options.height??0),y&&(this.options.zoomRange=y),$t(m)&&(this.options.zoom=m),($t(h)||Dt(h))&&(this.options.padding=h)}setBackground(t){this.options.background=t,this.context.canvas?.setBackground(t)}getBackground(){return this.options.background}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){this.options.width=t,this.options.height=e}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Ot(t)?t(this.getTheme()):t;const{background:e}=OV("theme",this.options.theme)||{};e&&!this.options.background&&this.setBackground(e)}setLayout(t){this.options.layout=Ot(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){this.options.behaviors=Ot(t)?t(this.getBehaviors()):t,this.context.behavior?.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors((e=>e.map((e=>Lt(e)&&e.key===t.key?{...e,...t}:e))))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){this.options.plugins=Ot(t)?t(this.getPlugins()):t,this.context.plugin?.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins((e=>e.map((e=>Lt(e)&&e.key===t.key?{...e,...t}:e))))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){this.options.transforms=Ot(t)?t(this.getTransforms()):t,this.context.transform?.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms((e=>e.map((e=>Lt(e)&&e.key===t.key?{...e,...t}:e))))}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}getNodeData(t){return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeData([t])?.[0]}getEdgeData(t){return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeData([t])?.[0]}getComboData(t){return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getComboData([t])?.[0]}setData(t){this.context.model.setData(Ot(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Ot(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Ot(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Ot(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Ot(t)?t(this.getComboData()):t)}updateData(t){this.context.model.updateData(Ot(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Ot(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Ot(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Ot(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Ot(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Ot(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Ot(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Ot(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}async initCanvas(){if(this.context.canvas)return await this.context.canvas.init();const{container:e="container",width:n,height:r,renderer:i,background:o}=this.options;if(e instanceof HV)this.context.canvas=e,e.setBackground(o),await e.init();else{const o=Vt(e)?document.getElementById(e):e,a=oL(o);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:o,width:n,height:r});const s=new HV({container:o,width:n||a[0],height:r||a[1],renderer:i});this.context.canvas=s,await s.init(),this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:s})}}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new FV(this.context)),this.context.plugin||(this.context.plugin=new QV(this.context)),this.context.viewport||(this.context.viewport=new eW(this.context)),this.context.transform||(this.context.transform=new tW(this.context)),this.context.element||(this.context.element=new XV(this.context)),this.context.layout||(this.context.layout=new ZV(this.context)),this.context.behavior||(this.context.behavior=new GV(this.context))}async prepare(){if(await Promise.resolve(),this.destroyed)throw new Error("Graph has been destroyed");await this.initCanvas(),this.initRuntime()}async render(){await this.prepare(),jV(this,new RV(t.GraphEvent.BEFORE_RENDER)),await Promise.all([this.context.element?.draw(),this.context.layout?.layout()]),await this.autoFit(),jV(this,new RV(t.GraphEvent.AFTER_RENDER))}async draw(){return await this.prepare(),this.context.element.draw()}async layout(){await this.context.layout.layout()}stopLayout(){this.context.layout.stopLayout()}async clear(){this.context.model.setData({}),await this.draw()}destroy(){jV(this,new RV(t.GraphEvent.BEFORE_DESTROY));const{layout:e,element:n,model:r,canvas:i,behavior:o,plugin:a}=this.context;a?.destroy(),o?.destroy(),e?.destroy(),n?.destroy(),r.destroy(),i?.destroy(),this.options={},this.context={},this.off(),window.removeEventListener("resize",this.onResize),this.destroyed=!0,jV(this,new RV(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){const r=e&&n?[e,n]:oL(this.context.canvas.getContainer());de(r,this.getSize())||(jV(this,new RV(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:r})),this.context.canvas.resize(...r),jV(this,new RV(t.GraphEvent.AFTER_SIZE_CHANGE,{size:r})))}async fitView(t,e){await(this.context.viewport?.fitView(t,e))}async fitCenter(t){await(this.context.viewport?.fitCenter(t))}async autoFit(){const{autoFit:t}=this.context.options;if(t)if(Vt(t))"view"===t?await this.fitView():"center"===t&&await this.fitCenter();else{const{type:e,animation:n}=t;"view"===e?await this.fitView(t.options,n):"center"===e&&await this.fitCenter(n)}}async focusElement(t,e){await(this.context.viewport?.focusElements(Array.isArray(t)?t:[t],e))}async zoomBy(t,e,n){await this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}async zoomTo(t,e,n){this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)}getZoom(){return this.context.viewport.getZoom()}async rotateBy(t,e,n){await this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}async rotateTo(t,e,n){await this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)}getRotation(){return this.context.viewport.getRotation()}async translateBy(t,e){await this.context.viewport.transform({mode:"relative",translate:t},e)}async translateTo(t,e){await this.context.viewport.transform({mode:"absolute",translate:t},e)}getPosition(){return al([0,0],this.getCanvasByViewport([0,0]))}async translateElementBy(t,e,n=!0){const[r,i]=Lt(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeBy(t,e))),await this.context.element.draw({animation:i})}async translateElementTo(t,e,n=!0){const[r,i]=Lt(t)?[t,e??!0]:[{[t]:e},n];Object.entries(r).forEach((([t,e])=>this.context.model.translateNodeTo(t,e))),await this.context.element.draw({animation:i})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return ye(this.context.element.getElement(t).attributes,["context"])}async setElementVisibility(t,e,n=!0){const[r,i]=Lt(t)?[t,e??!0]:[{[t]:e},n],o={nodes:[],edges:[],combos:[]};Object.entries(r).forEach((([t,e])=>{const n=this.getElementType(t);o[`${n}s`].push({id:t,style:{visibility:e}})})),this.updateData(o),await this.context.element.draw({animation:i,stage:"visibility"})}async showElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"visible"]))),e)}async hideElement(t,e){const n=Array.isArray(t)?t:[t];await this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"hidden"]))),e)}getElementVisibility(t){const e=this.context.element.getElement(t);return e?.style?.visibility??"visible"}async setElementZIndex(t,e){const n={nodes:[],edges:[],combos:[]},r=Lt(t)?t:{[t]:e};Object.entries(r).forEach((([t,e])=>{const r=this.getElementType(t);n[`${r}s`].push({id:t,style:{zIndex:e}})}));const{model:i,element:o}=this.context;i.preventUpdateNodeLikeHierarchy((()=>i.updateData(n))),await o.draw({animation:!1})}async frontElement(t){const e=Array.isArray(t)?t:[t],{model:n}=this.context,r={};e.map((t=>{const e=n.getFrontZIndex(t);if("combo"===n.getElementType(t)){const i=n.getAncestorsData(t,kc).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Xc(i))].filter((t=>n.isCombo(Xc(t)))),a=e-zV(i);o.forEach((t=>{r[Xc(t)]=zV(t)+a}))}else r[t]=e})),await this.setElementZIndex(r)}getElementZIndex(t){return zV(this.context.model.getElementDataById(t))}async setElementState(t,e,n=!0){const[r,i]=Lt(t)?[t,e??!0]:[{[t]:e},n],o={nodes:[],edges:[],combos:[]};Object.entries(r).forEach((([t,e])=>{const n=this.getElementType(t);var r;o[`${n}s`].push({id:t,states:(r=e,r?Array.isArray(r)?r:[r]:[])})})),this.updateData(o),await this.context.element.draw({animation:i})}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}async collapseElement(t,e=!0){this.setElementCollapsibility(t,!0),await this.context.element.draw({animation:e,stage:"collapse"})}async expandElement(t,e=!0){this.setElementCollapsibility(t,!1),await this.context.element.draw({animation:e,stage:"expand"})}setElementCollapsibility(t,e){const n=this.getElementType(t);"node"===n?this.updateNodeData([{id:t,style:{collapsed:e}}]):"combo"===n&&this.updateComboData([{id:t,style:{collapsed:e}}])}async toDataURL(t={}){return this.context.canvas.toDataURL(t)}getCanvasByViewport(t){return wl(this.context.canvas.viewport2Canvas(El(t)))}getViewportByCanvas(t){return wl(this.context.canvas.canvas2Viewport(El(t)))}getClientByCanvas(t){const e=this.context.canvas.canvas2Viewport(El(t));return wl(this.context.canvas.viewport2Canvas(e))}getCanvasByClient(t){const e=this.context.canvas.client2Viewport(El(t));return wl(this.context.canvas.viewport2Canvas(e))}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}onResize=ae((()=>{this.resize()}),300);on(t,e){return super.on(t,e)}once(t,e){return super.once(t,e)}}t.AntVDagreLayout=nm,t.BaseBehavior=pd,t.BaseCombo=dh,t.BaseEdge=jh,t.BaseLayout=Id,t.BaseNode=Xl,t.BasePlugin=pD,t.BaseShape=Vl,t.BaseTransform=wV,t.BrushSelect=yd,t.BubbleSets=eL,t.CameraSetting=class extends pD{constructor(t,e){super(t,e),this.bindEvents()}update(t){this.setOptions(t),super.update(t)}bindEvents(){this.context.graph.once(t.GraphEvent.BEFORE_DRAW,(()=>this.setOptions(this.options)))}setOptions=t=>{const e=(t,e)=>{switch(t){case"projectionMode":return"perspective"===e?1:0;case"cameraType":return{orbiting:0,exploring:1,tracking:2}[e];case"aspect":return"number"==typeof e?e:this.getCanvasAspect();default:return e}};Object.entries({cameraType:"setType",near:"setNear",far:"setFar",fov:"setFov",aspect:"setAspect",projectionMode:"setProjectionMode",distance:"setDistance",minDistance:"setMinDistance",maxDistance:"setMaxDistance",roll:"setRoll",elevation:"setElevation",azimuth:"setAzimuth"}).forEach((([n,r])=>{const i=t[n];if(void 0!==i){const t=e(n,i);this.context.canvas.getCamera()[r](t)}}))};getCanvasAspect(){const[t,e]=this.context.viewport.getCanvasSize();return t/e}},t.Circle=Jl,t.CircleCombo=fh,t.CircularLayout=am,t.ClickElement=Ed,t.CollapseExpand=Md,t.ComboCombinedLayout=By,t.ComboEvent=t.NodeEvent,t.ConcentricLayout=lm,t.Contextmenu=uL,t.CreateEdge=Nd,t.Cubic=Bh,t.CubicHorizontal=zh,t.CubicVertical=Fh,t.D3Force3DLayout=sw,t.D3ForceLayout=Tv,t.DagreLayout=vI,t.Diamond=eh,t.Donut=nh,t.DragCanvas=kd,t.DragElement=Cd,t.DragElementForce=Bd,t.Ellipse=oh,t.FocusElement=zd,t.ForceAtlas2Layout=MI,t.ForceLayout=_m,t.FruchtermanLayout=NI,t.Graph=nW,t.GridLayout=CI,t.GridLine=cL,t.HTML=sh,t.Hexagon=ah,t.History=pL,t.HoverElement=Fd,t.Hull=zL,t.Image=uh,t.LassoSelect=Gd,t.Legend=lG,t.Line=Gh,t.MDSLayout=Ry,t.Polyline=Vh,t.Quadratic=Wh,t.RadialLayout=BI,t.RandomLayout=UI,t.Rect=ch,t.RectCombo=ph,t.ScrollCanvas=Vd,t.Shortcut=md,t.Star=lh,t.Timebar=aV,t.Toolbar=lV,t.Tooltip=hV,t.Triangle=hh,t.Watermark=pV,t.ZoomCanvas=Wd,t.compactBox=Qf.compactBox,t.dendrogram=Qf.dendrogram,t.getExtension=OV,t.getExtensions=function(t){return AV[t]},t.idOf=Xc,t.indented=Qf.indented,t.invokeLayoutMethod=Ld,t.mindmap=Qf.mindmap,t.omitStyleProps=rl,t.parseSize=$c,t.register=PV,t.subStyleProps=el,t.treeToGraphData=function(t,e){const{getNodeData:n=(t=>{if(!t.children)return t;const{children:e,...n}=t;return{...n,children:e.map((t=>t.id))}}),getEdgeData:r=((t,e)=>({source:t.id,target:e.id})),getChildren:i=(t=>t.children||[])}=e||{},o=[],a=[];return bd(t,(t=>{o.push(n(t));const e=i(t);for(const n of e)a.push(r(t,n))}),(t=>i(t)),"TB"),{nodes:o,edges:a}},t.version="5.0.0"}));