@antv/g6 5.0.0-beta.31 → 5.0.0-beta.32

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 (264) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/collapse-expand.d.ts +4 -5
  3. package/dist/lib/behaviors/create-edge.d.ts +55 -0
  4. package/dist/lib/behaviors/drag-canvas.d.ts +6 -6
  5. package/dist/lib/behaviors/drag-element.d.ts +5 -3
  6. package/dist/lib/behaviors/focus-element.d.ts +4 -3
  7. package/dist/lib/behaviors/hover-element.d.ts +4 -5
  8. package/dist/lib/behaviors/index.d.ts +2 -0
  9. package/dist/lib/behaviors/zoom-canvas.d.ts +7 -6
  10. package/dist/lib/constants/events/graph.d.ts +5 -13
  11. package/dist/lib/constants/index.d.ts +1 -0
  12. package/dist/lib/constants/registry.d.ts +20 -0
  13. package/dist/lib/elements/combos/base-combo.d.ts +21 -0
  14. package/dist/lib/elements/edges/base-edge.d.ts +21 -0
  15. package/dist/lib/elements/nodes/base-node.d.ts +22 -1
  16. package/dist/lib/exports.d.ts +16 -14
  17. package/dist/lib/plugins/camera-setting.d.ts +95 -0
  18. package/dist/lib/plugins/contextmenu.d.ts +8 -5
  19. package/dist/lib/plugins/index.d.ts +4 -0
  20. package/dist/lib/plugins/legend.d.ts +49 -0
  21. package/dist/lib/plugins/tooltip.d.ts +12 -10
  22. package/dist/lib/registry/extension/index.d.ts +2 -2
  23. package/dist/lib/registry/index.d.ts +6 -4
  24. package/dist/lib/registry/types.d.ts +0 -6
  25. package/dist/lib/runtime/canvas.d.ts +2 -1
  26. package/dist/lib/runtime/data.d.ts +1 -1
  27. package/dist/lib/runtime/element.d.ts +4 -5
  28. package/dist/lib/runtime/graph.d.ts +31 -4
  29. package/dist/lib/runtime/plugin.d.ts +1 -0
  30. package/dist/lib/types/event.d.ts +42 -7
  31. package/dist/lib/types/index.d.ts +0 -1
  32. package/dist/lib/utils/bbox.d.ts +1 -1
  33. package/dist/lib/utils/element.d.ts +19 -11
  34. package/dist/lib/utils/event/events.d.ts +8 -13
  35. package/dist/lib/utils/shortcut.d.ts +10 -0
  36. package/esm/behaviors/collapse-expand.d.ts +4 -5
  37. package/esm/behaviors/collapse-expand.js +8 -4
  38. package/esm/behaviors/collapse-expand.js.map +1 -1
  39. package/esm/behaviors/create-edge.d.ts +55 -0
  40. package/esm/behaviors/create-edge.js +141 -0
  41. package/esm/behaviors/create-edge.js.map +1 -0
  42. package/esm/behaviors/drag-canvas.d.ts +6 -6
  43. package/esm/behaviors/drag-canvas.js +15 -7
  44. package/esm/behaviors/drag-canvas.js.map +1 -1
  45. package/esm/behaviors/drag-element.d.ts +5 -3
  46. package/esm/behaviors/drag-element.js.map +1 -1
  47. package/esm/behaviors/focus-element.d.ts +4 -3
  48. package/esm/behaviors/focus-element.js.map +1 -1
  49. package/esm/behaviors/hover-element.d.ts +4 -5
  50. package/esm/behaviors/hover-element.js.map +1 -1
  51. package/esm/behaviors/index.d.ts +2 -0
  52. package/esm/behaviors/index.js +1 -0
  53. package/esm/behaviors/index.js.map +1 -1
  54. package/esm/behaviors/zoom-canvas.d.ts +7 -6
  55. package/esm/behaviors/zoom-canvas.js +6 -2
  56. package/esm/behaviors/zoom-canvas.js.map +1 -1
  57. package/esm/constants/events/graph.d.ts +5 -13
  58. package/esm/constants/events/graph.js +4 -12
  59. package/esm/constants/events/graph.js.map +1 -1
  60. package/esm/constants/index.d.ts +1 -0
  61. package/esm/constants/index.js +1 -0
  62. package/esm/constants/index.js.map +1 -1
  63. package/esm/constants/registry.d.ts +20 -0
  64. package/esm/constants/registry.js +22 -0
  65. package/esm/constants/registry.js.map +1 -0
  66. package/esm/elements/combos/base-combo.d.ts +21 -0
  67. package/esm/elements/combos/base-combo.js +21 -0
  68. package/esm/elements/combos/base-combo.js.map +1 -1
  69. package/esm/elements/edges/base-edge.d.ts +21 -0
  70. package/esm/elements/edges/base-edge.js +21 -0
  71. package/esm/elements/edges/base-edge.js.map +1 -1
  72. package/esm/elements/nodes/base-node.d.ts +22 -1
  73. package/esm/elements/nodes/base-node.js +21 -0
  74. package/esm/elements/nodes/base-node.js.map +1 -1
  75. package/esm/exports.d.ts +16 -14
  76. package/esm/exports.js +7 -6
  77. package/esm/exports.js.map +1 -1
  78. package/esm/plugins/camera-setting.d.ts +95 -0
  79. package/esm/plugins/camera-setting.js +65 -0
  80. package/esm/plugins/camera-setting.js.map +1 -0
  81. package/esm/plugins/contextmenu.d.ts +8 -5
  82. package/esm/plugins/contextmenu.js.map +1 -1
  83. package/esm/plugins/index.d.ts +4 -0
  84. package/esm/plugins/index.js +2 -0
  85. package/esm/plugins/index.js.map +1 -1
  86. package/esm/plugins/legend.d.ts +49 -0
  87. package/esm/plugins/legend.js +267 -0
  88. package/esm/plugins/legend.js.map +1 -0
  89. package/esm/plugins/tooltip.d.ts +12 -10
  90. package/esm/plugins/tooltip.js +0 -1
  91. package/esm/plugins/tooltip.js.map +1 -1
  92. package/esm/preset.js +2 -5
  93. package/esm/preset.js.map +1 -1
  94. package/esm/registry/build-in.js +4 -2
  95. package/esm/registry/build-in.js.map +1 -1
  96. package/esm/registry/extension/index.d.ts +2 -2
  97. package/esm/registry/extension/index.js.map +1 -1
  98. package/esm/registry/index.d.ts +6 -4
  99. package/esm/registry/index.js.map +1 -1
  100. package/esm/registry/types.d.ts +0 -6
  101. package/esm/runtime/behavior.js +3 -2
  102. package/esm/runtime/behavior.js.map +1 -1
  103. package/esm/runtime/canvas.d.ts +2 -1
  104. package/esm/runtime/canvas.js +68 -30
  105. package/esm/runtime/canvas.js.map +1 -1
  106. package/esm/runtime/data.d.ts +1 -1
  107. package/esm/runtime/element.d.ts +4 -5
  108. package/esm/runtime/element.js +32 -13
  109. package/esm/runtime/element.js.map +1 -1
  110. package/esm/runtime/graph.d.ts +31 -4
  111. package/esm/runtime/graph.js +48 -9
  112. package/esm/runtime/graph.js.map +1 -1
  113. package/esm/runtime/plugin.d.ts +1 -0
  114. package/esm/runtime/plugin.js +3 -0
  115. package/esm/runtime/plugin.js.map +1 -1
  116. package/esm/types/event.d.ts +42 -7
  117. package/esm/types/index.d.ts +0 -1
  118. package/esm/utils/bbox.d.ts +1 -1
  119. package/esm/utils/element.d.ts +19 -11
  120. package/esm/utils/element.js +19 -9
  121. package/esm/utils/element.js.map +1 -1
  122. package/esm/utils/event/events.d.ts +8 -13
  123. package/esm/utils/event/events.js +3 -8
  124. package/esm/utils/event/events.js.map +1 -1
  125. package/esm/utils/shortcut.d.ts +10 -0
  126. package/esm/utils/shortcut.js +24 -3
  127. package/esm/utils/shortcut.js.map +1 -1
  128. package/lib/behaviors/collapse-expand.d.ts +4 -5
  129. package/lib/behaviors/collapse-expand.js +8 -4
  130. package/lib/behaviors/collapse-expand.js.map +1 -1
  131. package/lib/behaviors/create-edge.d.ts +55 -0
  132. package/lib/behaviors/create-edge.js +145 -0
  133. package/lib/behaviors/create-edge.js.map +1 -0
  134. package/lib/behaviors/drag-canvas.d.ts +6 -6
  135. package/lib/behaviors/drag-canvas.js +15 -7
  136. package/lib/behaviors/drag-canvas.js.map +1 -1
  137. package/lib/behaviors/drag-element.d.ts +5 -3
  138. package/lib/behaviors/drag-element.js.map +1 -1
  139. package/lib/behaviors/focus-element.d.ts +4 -3
  140. package/lib/behaviors/focus-element.js.map +1 -1
  141. package/lib/behaviors/hover-element.d.ts +4 -5
  142. package/lib/behaviors/hover-element.js.map +1 -1
  143. package/lib/behaviors/index.d.ts +2 -0
  144. package/lib/behaviors/index.js +3 -1
  145. package/lib/behaviors/index.js.map +1 -1
  146. package/lib/behaviors/zoom-canvas.d.ts +7 -6
  147. package/lib/behaviors/zoom-canvas.js +6 -2
  148. package/lib/behaviors/zoom-canvas.js.map +1 -1
  149. package/lib/constants/events/graph.d.ts +5 -13
  150. package/lib/constants/events/graph.js +4 -12
  151. package/lib/constants/events/graph.js.map +1 -1
  152. package/lib/constants/index.d.ts +1 -0
  153. package/lib/constants/index.js +1 -0
  154. package/lib/constants/index.js.map +1 -1
  155. package/lib/constants/registry.d.ts +20 -0
  156. package/lib/constants/registry.js +25 -0
  157. package/lib/constants/registry.js.map +1 -0
  158. package/lib/elements/combos/base-combo.d.ts +21 -0
  159. package/lib/elements/combos/base-combo.js +21 -0
  160. package/lib/elements/combos/base-combo.js.map +1 -1
  161. package/lib/elements/edges/base-edge.d.ts +21 -0
  162. package/lib/elements/edges/base-edge.js +21 -0
  163. package/lib/elements/edges/base-edge.js.map +1 -1
  164. package/lib/elements/nodes/base-node.d.ts +22 -1
  165. package/lib/elements/nodes/base-node.js +21 -0
  166. package/lib/elements/nodes/base-node.js.map +1 -1
  167. package/lib/exports.d.ts +16 -14
  168. package/lib/exports.js +23 -1
  169. package/lib/exports.js.map +1 -1
  170. package/lib/plugins/camera-setting.d.ts +95 -0
  171. package/lib/plugins/camera-setting.js +69 -0
  172. package/lib/plugins/camera-setting.js.map +1 -0
  173. package/lib/plugins/contextmenu.d.ts +8 -5
  174. package/lib/plugins/contextmenu.js.map +1 -1
  175. package/lib/plugins/index.d.ts +4 -0
  176. package/lib/plugins/index.js +5 -1
  177. package/lib/plugins/index.js.map +1 -1
  178. package/lib/plugins/legend.d.ts +49 -0
  179. package/lib/plugins/legend.js +271 -0
  180. package/lib/plugins/legend.js.map +1 -0
  181. package/lib/plugins/tooltip.d.ts +12 -10
  182. package/lib/plugins/tooltip.js +0 -1
  183. package/lib/plugins/tooltip.js.map +1 -1
  184. package/lib/preset.js +2 -5
  185. package/lib/preset.js.map +1 -1
  186. package/lib/registry/build-in.js +2 -0
  187. package/lib/registry/build-in.js.map +1 -1
  188. package/lib/registry/extension/index.d.ts +2 -2
  189. package/lib/registry/extension/index.js.map +1 -1
  190. package/lib/registry/index.d.ts +6 -4
  191. package/lib/registry/index.js.map +1 -1
  192. package/lib/registry/types.d.ts +0 -6
  193. package/lib/runtime/behavior.js +3 -2
  194. package/lib/runtime/behavior.js.map +1 -1
  195. package/lib/runtime/canvas.d.ts +2 -1
  196. package/lib/runtime/canvas.js +68 -30
  197. package/lib/runtime/canvas.js.map +1 -1
  198. package/lib/runtime/data.d.ts +1 -1
  199. package/lib/runtime/element.d.ts +4 -5
  200. package/lib/runtime/element.js +31 -12
  201. package/lib/runtime/element.js.map +1 -1
  202. package/lib/runtime/graph.d.ts +31 -4
  203. package/lib/runtime/graph.js +47 -8
  204. package/lib/runtime/graph.js.map +1 -1
  205. package/lib/runtime/plugin.d.ts +1 -0
  206. package/lib/runtime/plugin.js +3 -0
  207. package/lib/runtime/plugin.js.map +1 -1
  208. package/lib/types/event.d.ts +42 -7
  209. package/lib/types/index.d.ts +0 -1
  210. package/lib/utils/bbox.d.ts +1 -1
  211. package/lib/utils/element.d.ts +19 -11
  212. package/lib/utils/element.js +21 -10
  213. package/lib/utils/element.js.map +1 -1
  214. package/lib/utils/event/events.d.ts +8 -13
  215. package/lib/utils/event/events.js +4 -10
  216. package/lib/utils/event/events.js.map +1 -1
  217. package/lib/utils/shortcut.d.ts +10 -0
  218. package/lib/utils/shortcut.js +24 -3
  219. package/lib/utils/shortcut.js.map +1 -1
  220. package/package.json +2 -2
  221. package/src/behaviors/collapse-expand.ts +13 -11
  222. package/src/behaviors/create-edge.ts +206 -0
  223. package/src/behaviors/drag-canvas.ts +22 -14
  224. package/src/behaviors/drag-element.ts +8 -11
  225. package/src/behaviors/focus-element.ts +7 -6
  226. package/src/behaviors/hover-element.ts +14 -10
  227. package/src/behaviors/index.ts +2 -0
  228. package/src/behaviors/zoom-canvas.ts +14 -9
  229. package/src/constants/events/graph.ts +4 -12
  230. package/src/constants/index.ts +1 -0
  231. package/src/constants/registry.ts +20 -0
  232. package/src/elements/combos/base-combo.ts +24 -0
  233. package/src/elements/edges/base-edge.ts +25 -1
  234. package/src/elements/nodes/base-node.ts +25 -1
  235. package/src/exports.ts +55 -12
  236. package/src/plugins/camera-setting.ts +153 -0
  237. package/src/plugins/contextmenu.ts +10 -7
  238. package/src/plugins/index.ts +4 -0
  239. package/src/plugins/legend.ts +321 -0
  240. package/src/plugins/tooltip.ts +16 -15
  241. package/src/preset.ts +2 -6
  242. package/src/registry/build-in.ts +12 -2
  243. package/src/registry/extension/index.ts +4 -4
  244. package/src/registry/index.ts +10 -4
  245. package/src/registry/types.ts +0 -7
  246. package/src/runtime/behavior.ts +3 -2
  247. package/src/runtime/canvas.ts +80 -40
  248. package/src/runtime/element.ts +52 -20
  249. package/src/runtime/graph.ts +56 -12
  250. package/src/runtime/plugin.ts +4 -0
  251. package/src/types/event.ts +62 -7
  252. package/src/types/index.ts +0 -1
  253. package/src/utils/bbox.ts +1 -1
  254. package/src/utils/element.ts +22 -11
  255. package/src/utils/event/events.ts +15 -17
  256. package/src/utils/shortcut.ts +28 -3
  257. package/dist/lib/types/behavior.d.ts +0 -5
  258. package/esm/types/behavior.d.ts +0 -5
  259. package/esm/types/behavior.js +0 -2
  260. package/esm/types/behavior.js.map +0 -1
  261. package/lib/types/behavior.d.ts +0 -5
  262. package/lib/types/behavior.js +0 -3
  263. package/lib/types/behavior.js.map +0 -1
  264. package/src/types/behavior.ts +0 -6
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"==typeof SuppressedError&&SuppressedError;var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function f(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 p={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}(p);var g=d(p.exports),m=1e-6,v="undefined"!=typeof Float32Array?Float32Array:Array;function y(){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 b(){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 E(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 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 x(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 M(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 S(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,E=n*u-o*a,w=r*c-i*s,x=r*u-o*s,M=i*u-o*c,N=l*g-h*p,S=l*m-d*p,T=l*v-f*p,k=h*m-d*g,C=h*v-f*g,P=d*v-f*m,A=y*P-b*C+E*k+w*T-x*S+M*N;return A?(A=1/A,t[0]=(s*P-c*C+u*k)*A,t[1]=(i*C-r*P-o*k)*A,t[2]=(g*M-m*x+v*w)*A,t[3]=(d*x-h*M-f*w)*A,t[4]=(c*T-a*P-u*S)*A,t[5]=(n*P-i*T+o*S)*A,t[6]=(m*E-p*M-v*b)*A,t[7]=(l*M-d*E+f*b)*A,t[8]=(a*C-s*T+u*N)*A,t[9]=(r*T-n*C-o*N)*A,t[10]=(p*x-g*E+v*y)*A,t[11]=(h*E-l*x-f*y)*A,t[12]=(s*S-a*k-c*N)*A,t[13]=(n*k-r*S+i*N)*A,t[14]=(g*b-p*w-m*y)*A,t[15]=(l*w-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 k(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],E=n[1],w=n[2],x=n[3];return t[0]=b*r+E*s+w*h+x*g,t[1]=b*i+E*c+w*d+x*m,t[2]=b*o+E*u+w*f+x*v,t[3]=b*a+E*l+w*p+x*y,b=n[4],E=n[5],w=n[6],x=n[7],t[4]=b*r+E*s+w*h+x*g,t[5]=b*i+E*c+w*d+x*m,t[6]=b*o+E*u+w*f+x*v,t[7]=b*a+E*l+w*p+x*y,b=n[8],E=n[9],w=n[10],x=n[11],t[8]=b*r+E*s+w*h+x*g,t[9]=b*i+E*c+w*d+x*m,t[10]=b*o+E*u+w*f+x*v,t[11]=b*a+E*l+w*p+x*y,b=n[12],E=n[13],w=n[14],x=n[15],t[12]=b*r+E*s+w*h+x*g,t[13]=b*i+E*c+w*d+x*m,t[14]=b*o+E*u+w*f+x*v,t[15]=b*a+E*l+w*p+x*y,t}function C(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 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 A(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 O(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 _(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=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 I(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function L(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 j(t,e){var n=new v(3);L(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 z(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,E=c*h,w=r[0],x=r[1],M=r[2],N=i[0],S=i[1],T=i[2],k=(1-(g+v))*w,C=(f+E)*w,P=(p-b)*w,A=(f-E)*x,O=(1-(d+v))*x,R=(m+y)*x,_=(p+b)*M,D=(m-y)*M,I=(1-(d+g))*M;return t[0]=k,t[1]=C,t[2]=P,t[3]=0,t[4]=A,t[5]=O,t[6]=R,t[7]=0,t[8]=_,t[9]=D,t[10]=I,t[11]=0,t[12]=n[0]+N-(k*N+A*S+_*T),t[13]=n[1]+S-(C*N+O*S+D*T),t[14]=n[2]+T-(P*N+R*S+I*T),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 B(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 G=B;function V(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=V;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]=u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*c,t[14]=o*u,t[15]=1,t}function H(t,e,n,r){var i,o,a,s,c,u,l,h,d,f,p=e[0],g=e[1],v=e[2],y=r[0],b=r[1],E=r[2],w=n[0],x=n[1],N=n[2];return Math.abs(p-w)<m&&Math.abs(g-x)<m&&Math.abs(v-N)<m?M(t):(l=p-w,h=g-x,d=v-N,i=b*(d*=f=1/Math.hypot(l,h,d))-E*(h*=f),o=E*(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*v),t[13]=-(s*p+c*g+u*v),t[14]=-(l*p+h*g+d*v),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 $=k,Y=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:b,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],v=t[14],y=t[15],b=e[0],E=e[1],w=e[2],x=e[3],M=e[4],N=e[5],S=e[6],T=e[7],k=e[8],C=e[9],P=e[10],A=e[11],O=e[12],R=e[13],_=e[14],D=e[15];return Math.abs(n-b)<=m*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-E)<=m*Math.max(1,Math.abs(r),Math.abs(E))&&Math.abs(i-w)<=m*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(o-x)<=m*Math.max(1,Math.abs(o),Math.abs(x))&&Math.abs(a-M)<=m*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(s-N)<=m*Math.max(1,Math.abs(s),Math.abs(N))&&Math.abs(c-S)<=m*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(u-T)<=m*Math.max(1,Math.abs(u),Math.abs(T))&&Math.abs(l-k)<=m*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(h-C)<=m*Math.max(1,Math.abs(h),Math.abs(C))&&Math.abs(d-P)<=m*Math.max(1,Math.abs(d),Math.abs(P))&&Math.abs(f-A)<=m*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(p-O)<=m*Math.max(1,Math.abs(p),Math.abs(O))&&Math.abs(g-R)<=m*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(v-_)<=m*Math.max(1,Math.abs(v),Math.abs(_))&&Math.abs(y-D)<=m*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 v(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)),D(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<m?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:D,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,E=r[0],w=r[1],x=r[2];return t[0]=(1-(p+m))*E,t[1]=(d+b)*E,t[2]=(f-y)*E,t[3]=0,t[4]=(d-b)*w,t[5]=(1-(h+m))*w,t[6]=(g+v)*w,t[7]=0,t[8]=(f+y)*x,t[9]=(g-v)*x,t[10]=(1-(h+p))*x,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:z,fromScaling:_,fromTranslation:R,fromValues:function(t,e,n,r,i,o,a,s,c,u,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]=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:j,getScaling:L,getTranslation:I,identity:M,invert:S,lookAt:H,mul:$,multiply:k,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:V,orthoZO:W,perspective:G,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:B,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,v,y,b,E,w,x,M,N,S,T,k,C,P=r[0],A=r[1],O=r[2],R=Math.hypot(P,A,O);return R<m?null:(P*=R=1/R,A*=R,O*=R,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],v=e[9],y=e[10],b=e[11],E=P*P*a+o,w=A*P*a+O*i,x=O*P*a-A*i,M=P*A*a-O*i,N=A*A*a+o,S=O*A*a+P*i,T=P*O*a+A*i,k=A*O*a-P*i,C=O*O*a+o,t[0]=s*E+h*w+g*x,t[1]=c*E+d*w+v*x,t[2]=u*E+f*w+y*x,t[3]=l*E+p*w+b*x,t[4]=s*M+h*N+g*S,t[5]=c*M+d*N+v*S,t[6]=u*M+f*N+y*S,t[7]=l*M+p*N+b*S,t[8]=s*T+h*k+g*C,t[9]=c*T+d*k+v*C,t[10]=u*T+f*k+y*C,t[11]=l*T+p*k+b*C,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:A,rotateY:O,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:P,set:x,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:Y,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:C,transpose:N});function K(){var t=new v(3);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Z(t){var e=new v(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Q(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function J(t,e,n){var r=new v(3);return r[0]=t,r[1]=e,r[2]=n,r}function tt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function et(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function nt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],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,t[1]=e[1]*n,t[2]=e[2]*n,t}function ot(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 at(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function st(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 ct(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 ut(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 lt(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)<=m*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=m*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=m*Math.max(1,Math.abs(i),Math.abs(s))}var ht=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)},dt=Q;function ft(){var t=new v(4);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function pt(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 gt(){var t=new v(4);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function mt(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 vt(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 yt(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 bt(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}K(),function(){var t=ft()}();var Et=function(t,e,n,r){var i=new v(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},xt=vt,Mt=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};K(),J(1,0,0),J(0,1,0),gt(),gt(),y(),function(){var t,e=(t=new v(2),v!=Float32Array&&(t[0]=0,t[1]=0),t)}();var Nt=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},St=function(t,e){return!!Nt(t)&&t.indexOf(e)>-1},Tt=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!Nt(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!St(e,t)}))},kt=function(t){return"function"==typeof t},Ct=function(t){return null==t},Pt={}.toString,At=function(t,e){return Pt.call(t)==="[object "+e+"]"},Ot=function(t){return Array.isArray?Array.isArray(t):At(t,"Array")},Rt=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function _t(t,e){if(t)if(Ot(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 Dt=function(t){return"object"==typeof t&&null!==t},It=function(t){if(!Dt(t)||!At(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},Lt=function(t){if(Ot(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},jt=function(t){if(Ot(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},zt=function(t){return At(t,"String")},Ft=Object.prototype.hasOwnProperty;function Bt(t,e){if(!e||!Ot(t))return{};for(var n,r={},i=kt(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 Gt=function(t,e,n){return t<e?e:t>n?n:t},Vt=function(t){return At(t,"Number")},Ut=1e-5;function Wt(t,e,n){return void 0===n&&(n=Ut),Math.abs(t-e)<n}var Ht=function(t,e){return(t%e+e)%e},qt=function(t){return Ct(t)?"":t.toString()},$t=function(t){var e=qt(t);return e.charAt(0).toLowerCase()+e.substring(1)};var Yt={}.toString,Xt=function(t){return At(t,"Boolean")},Kt=Object.prototype,Zt=function(t){return void 0===t},Qt=function(t){if("object"!=typeof t||null===t)return t;var e;if(Ot(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Qt(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Qt(t[i]):e[i]=t[i];return e};function Jt(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 te(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(Jt(e,i)){var o=e[i];null!==o&&It(o)?(It(t[i])||(t[i]={}),n<r?te(t[i],o,n+1,r):t[i]=e[i]):Ot(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var ee=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)te(t,e[r]);return t},ne=Object.prototype.hasOwnProperty;function re(t){if(Ct(t))return!0;if(Nt(t))return!t.length;var e=function(t){return Yt.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||Kt)}(t))return!Object.keys(t).length;for(var n in t)if(ne.call(t,n))return!1;return!0}var ie=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(zt(t)||zt(e))return!1;if(Nt(t)||Nt(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=ie(t[r],e[r]));r++);return n}if(Dt(t)||Dt(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=ie(t[i[r]],e[i[r]]));r++);return n}return!1},oe=function(t,e,n){for(var r=0,i=zt(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},ae=function(t,e,n){var r=t,i=zt(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(Rt(r[t])||(r[t]=Vt(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},se=Object.prototype.hasOwnProperty,ce=function(t,e){return function(t,e,n){if(!Ot(t)&&!It(t))return t;var r=n;return _t(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},ue={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function le(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 he={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function de(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return he[e]===t.length-1&&"achlmqstvz".includes(e)}))}function fe(t){return de(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function pe(t){return fe(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function ge(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=he[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,he[n]))),he[n]););}function me(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 ve(t){return t>=48&&t<=57||43===t||45===t||46===t}function ye(t){return t>=48&&t<=57}function be(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)),ye(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&ye(e))return void(t.err="[path-util]: Invalid path value at index "+i+', "'+r[i]+'" illegal number');for(;o<n&&ye(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(u=!0,o+=1;ye(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&&ye(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid integer exponent');for(;o<n&&ye(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 Ee(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 we(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=he[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,Ee(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?be(t):me(t),t.err.length)return;t.data.push(t.param),Ee(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,Ee(t))}if(t.index>=t.max)break;if(!ve(n.charCodeAt(t.index)))break}ge(t)}else ge(t);else t.err='[path-util]: Invalid path value "'+n[r]+'" is not a path command'}var xe=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 Me(t){if(fe(t))return[].concat(t);var e=function(t){if(de(t))return[].concat(t);var e=new xe(t);for(Ee(e);e.index<e.max&&!e.err.length;)we(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 Ne(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 Se(t){if(pe(t))return[].concat(t);for(var e=Me(t),n=i({},ue),r=0;r<e.length;r+=1){e[r]=Ne(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 Te(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function ke(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,E=c,w=120*Math.PI/180,x=Math.PI/180*(+i||0),M=[];if(u)h=u[0],d=u[1],f=u[2],p=u[3];else{g=(l=Te(g,m,-x)).x,m=l.y;var N=(g-(b=(l=Te(b,E,-x)).x))/2,S=(m-(E=l.y))/2,T=N*N/(v*v)+S*S/(y*y);T>1&&(v*=T=Math.sqrt(T),y*=T);var k=v*v,C=y*y,P=(o===a?-1:1)*Math.sqrt(Math.abs((k*C-k*S*S-C*N*N)/(k*S*S+C*N*N)));f=P*v*S/y+(g+b)/2,p=P*-y*N/v+(m+E)/2,h=Math.asin(((m-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),d=Math.asin(((E-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)>w){var O=d,R=b,_=E;d=h+w*(a&&d>h?1:-1),M=ke(b=f+v*Math.cos(d),E=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),F=4/3*v*z,B=4/3*y*z,G=[g,m],V=[g+F*I,m-B*D],U=[b+F*j,E-B*L],W=[b,E];if(V[0]=2*G[0]-V[0],V[1]=2*G[1]-V[1],u)return V.concat(U,W,M);for(var H=[],q=0,$=(M=V.concat(U,W,M)).length;q<$;q+=1)H[q]=q%2?Te(M[q-1],M[q],x).y:Te(M[q],M[q+1],x).x;return H}function Ce(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var Pe=function(t,e,n,r){return l(l([],Ce([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function Ae(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(ke(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(Pe(g,m,f,p));case"Z":return g===v&&m===y?["C",g,m,v,y,v,y]:["C"].concat(Pe(g,m,v,y))}return t}function Oe(t,e){if(void 0===e&&(e=!1),function(t){return pe(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=Se(t),s=i({},ue),c=[],u="",l=a.length,h=[],d=0;d<l;d+=1){a[d]&&(u=a[d][0]),c[d]=u;var f=Ae(a[d],s);a[d]=f,le(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 Re(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function _e(t,e,n,r,i){var o=Re([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=Ce([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 De(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 Ie(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 _e(t,e,s,c,u).point;var y=(t-s)/2,b=(e-c)/2,E={x:d(v)*y+h(v)*b,y:-h(v)*y+d(v)*b},w=Math.pow(E.x,2)/Math.pow(g,2)+Math.pow(E.y,2)/Math.pow(m,2);w>1&&(g*=f(w),m*=f(w));var x=(Math.pow(g,2)*Math.pow(m,2)-Math.pow(g,2)*Math.pow(E.y,2)-Math.pow(m,2)*Math.pow(E.x,2))/(Math.pow(g,2)*Math.pow(E.y,2)+Math.pow(m,2)*Math.pow(E.x,2)),M=(o!==a?1:-1)*f(x=x<0?0:x),N=M*(g*E.y/m),S=M*(-m*E.x/g),T=d(v)*N-h(v)*S+(t+s)/2,k=h(v)*N+d(v)*S+(e+c)/2,C={x:(E.x-N)/g,y:(E.y-S)/m},P=De({x:1,y:0},C),A=De(C,{x:(-E.x-N)/g,y:(-E.y-S)/m});!a&&A>0?A-=2*p:a&&A<0&&(A+=2*p);var O=P+(A%=2*p)*u,R=g*d(O),_=m*h(O);return{x:d(v)*R-h(v)*_+T,y:h(v)*R+d(v)*_+k}}function Le(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,E=e,w=0,x=[b,E,w],M=[b,E],N={x:0,y:0},S=[{x:b,y:E}];y&&u<=0&&(N={x:b,y:E});for(var T=0;T<=v;T+=1){if(b=(h=Ie(t,e,n,r,i,o,a,s,c,T/v)).x,E=h.y,f&&S.push({x:b,y:E}),g&&(w+=Re(M,[b,E])),M=[b,E],y&&w>=u&&u>x[2]){var k=(w-u)/(w-x[2]);N={x:M[0]*(1-k)+x[0]*k,y:M[1]*(1-k)+x[1]*k}}x=[b,E,w]}return y&&u>=w&&(N={x:s,y:c}),{length:w,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 je(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 ze(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,E=0,w=[y,b,E],x=[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=je(t,e,n,r,i,o,a,s,S/m)).x,b=l.y,d&&N.push({x:y,y:b}),p&&(E+=Re(x,[y,b])),x=[y,b],v&&E>=c&&c>w[2]){var T=(E-c)/(E-w[2]);M={x:x[0]*(1-T)+w[0]*T,y:x[1]*(1-T)+w[1]*T}}w=[y,b,E]}return v&&c>=E&&(M={x:a,y:s}),{length:E,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 Fe(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 Be(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],E=[m,v],w={x:0,y:0},x=[{x:m,y:v}];g&&a<=0&&(w={x:m,y:v});for(var M=0;M<=p;M+=1){if(m=(c=Fe(t,e,n,r,i,o,M/p)).x,v=c.y,l&&x.push({x:m,y:v}),d&&(y+=Re(E,[m,v])),E=[m,v],g&&y>=a&&a>b[2]){var N=(y-a)/(y-b[2]);w={x:E[0]*(1-N)+b[0]*N,y:E[1]*(1-N)+b[1]*N}}b=[m,v,y]}return g&&a>=y&&(w={x:i,y:o}),{length:y,point:w,min:{x:Math.min.apply(null,x.map((function(t){return t.x}))),y:Math.min.apply(null,x.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 Ge(t,e,n){for(var r,i,o,a,s,c,u,l,h,d=Se(t),f="number"==typeof e,p=[],g=0,m=0,v=0,y=0,b=[],E=[],w=0,x={x:0,y:0},M=x,N=x,S=x,T=0,k=0,C=d.length;k<C;k+=1)p=(u="M"===(l=(h=d[k])[0]))?p:[g,m].concat(h.slice(1)),u?(M=x={x:v=h[1],y:y=h[2]},w=0,f&&e<.001&&(S=x)):"L"===l?(w=(r=_e(p[0],p[1],p[2],p[3],(e||0)-T)).length,x=r.min,M=r.max,N=r.point):"A"===l?(w=(i=Le(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-T,n||{})).length,x=i.min,M=i.max,N=i.point):"C"===l?(w=(o=ze(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-T,n||{})).length,x=o.min,M=o.max,N=o.point):"Q"===l?(w=(a=Be(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-T,n||{})).length,x=a.min,M=a.max,N=a.point):"Z"===l&&(w=(s=_e((p=[g,m,v,y])[0],p[1],p[2],p[3],(e||0)-T)).length,x=s.min,M=s.max,N=s.point),f&&T<e&&T+w>=e&&(S=N),E.push(M),b.push(x),T+=w,g=(c="Z"!==l?h.slice(-2):[v,y])[0],m=c[1];return f&&e>=T&&(S={x:g,y:m}),{length:T,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,E.map((function(t){return t.x}))),y:Math.max.apply(null,E.map((function(t){return t.y})))}}}function Ve(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+=Re(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 Ue(t){return function(t){var e=0,n=0,r=0;return Oe(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 We(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?ze(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=Ce(n,r,e),s=Ce(r,i,e),c=Ce(i,o,e),u=Ce(a,s,e),l=Ce(s,c,e),h=Ce(u,l,e);return[["C"].concat(a,u,h),["C"].concat(l,c,o)]}(r):[t,t]:[t],l:i}}))}function He(t,e,n){var r=We(t),i=We(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:He(g[0],g[1],h)}function qe(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function $e(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Ye(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Xe(){}var Ke=.7,Ze=1/Ke,Qe="\\s*([+-]?\\d+)\\s*",Je="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",tn="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",en=/^#([0-9a-f]{3,8})$/,nn=new RegExp("^rgb\\("+[Qe,Qe,Qe]+"\\)$"),rn=new RegExp("^rgb\\("+[tn,tn,tn]+"\\)$"),on=new RegExp("^rgba\\("+[Qe,Qe,Qe,Je]+"\\)$"),an=new RegExp("^rgba\\("+[tn,tn,tn,Je]+"\\)$"),sn=new RegExp("^hsl\\("+[Je,tn,tn]+"\\)$"),cn=new RegExp("^hsla\\("+[Je,tn,tn,Je]+"\\)$"),un={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 ln(){return this.rgb().formatHex()}function hn(){return this.rgb().formatRgb()}function dn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=en.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?fn(e):3===n?new gn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?pn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?pn(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=nn.exec(t))?new gn(e[1],e[2],e[3],1):(e=rn.exec(t))?new gn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=on.exec(t))?pn(e[1],e[2],e[3],e[4]):(e=an.exec(t))?pn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=sn.exec(t))?bn(e[1],e[2]/100,e[3]/100,1):(e=cn.exec(t))?bn(e[1],e[2]/100,e[3]/100,e[4]):un.hasOwnProperty(t)?fn(un[t]):"transparent"===t?new gn(NaN,NaN,NaN,0):null}function fn(t){return new gn(t>>16&255,t>>8&255,255&t,1)}function pn(t,e,n,r){return r<=0&&(t=e=n=NaN),new gn(t,e,n,r)}function gn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function mn(){return"#"+yn(this.r)+yn(this.g)+yn(this.b)}function vn(){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 yn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function bn(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new wn(t,e,n,r)}function En(t){if(t instanceof wn)return new wn(t.h,t.s,t.l,t.opacity);if(t instanceof Xe||(t=dn(t)),!t)return new wn;if(t instanceof wn)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 wn(a,s,c,t.opacity)}function wn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function xn(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 Mn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function Nn(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 Sn(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function Tn(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function kn(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=Sn(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=Tn(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}}$e(Xe,dn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:ln,formatHex:ln,formatHsl:function(){return En(this).formatHsl()},formatRgb:hn,toString:hn}),$e(gn,(function(t,e,n,r){return 1===arguments.length?((i=t)instanceof Xe||(i=dn(i)),i?new gn((i=i.rgb()).r,i.g,i.b,i.opacity):new gn):new gn(t,e,n,null==r?1:r);var i}),Ye(Xe,{brighter:function(t){return t=null==t?Ze:Math.pow(Ze,t),new gn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?Ke:Math.pow(Ke,t),new gn(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:mn,formatHex:mn,formatRgb:vn,toString:vn})),$e(wn,(function(t,e,n,r){return 1===arguments.length?En(t):new wn(t,e,n,null==r?1:r)}),Ye(Xe,{brighter:function(t){return t=null==t?Ze:Math.pow(Ze,t),new wn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?Ke:Math.pow(Ke,t),new wn(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 gn(xn(t>=240?t-240:t+120,i,r),xn(t,i,r),xn(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 Cn=1e-4;function Pn(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))];(E=Mn(c[0],c[1],m[0],m[1]))<s&&(a=g,s=E)}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<Cn);p++){var y=a-f,b=a+f,E=(m=[i.apply(void 0,l([],u(t.concat([y])),!1)),i.apply(void 0,l([],u(e.concat([y])),!1))],Mn(c[0],c[1],m[0],m[1]));if(y>=0&&E<s)a=y,s=E;else{var w=[i.apply(void 0,l([],u(t.concat([b])),!1)),i.apply(void 0,l([],u(e.concat([b])),!1))],x=Mn(c[0],c[1],w[0],w[1]);b<=1&&x<s?(a=b,s=x):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 An(t,e,n,r){return Mn(t,e,n,r)}function On(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function Rn(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 _n(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 Dn(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(Wt(s,0))Wt(c,0)||(i=-u/c)>=0&&i<=1&&l.push(i);else{var h=c*c-4*s*u;Wt(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 In(t,e,n,r,i,o,a,s){for(var c=[t,a],u=[e,s],l=Dn(t,n,i,a),h=Dn(e,r,o,s),d=0;d<l.length;d++)c.push(_n(t,n,i,a,l[d]));for(d=0;d<h.length;d++)u.push(_n(e,r,o,s,h[d]));return Nn(c,u)}function Ln(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 Pn([t,n,i,a],[e,r,o,s],c,u,_n,l)}(t,e,n,r,i,o,a,s,c,u,l);return Mn(h.x,h.y,c,u)}function jn(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+=Mn(r[0],r[1],i[0],i[1])}return e}(t)}function zn(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function Fn(t,e,n){var r=t+n-2*e;if(Wt(r,0))return[.5];var i=(t-e)/r;return i<=1&&i>=0?[i]:[]}function Bn(t,e,n,r,i,o){var a=Fn(t,n,i)[0],s=Fn(e,r,o)[0],c=[t,i],u=[e,o];return void 0!==a&&c.push(zn(t,n,i,a)),void 0!==s&&u.push(zn(e,r,o,s)),Nn(c,u)}function Gn(t,e,n,r,i,o,a,s){var c=function(t,e,n,r,i,o,a,s){return Pn([t,n,i],[e,r,o],a,s,zn)}(t,e,n,r,i,o,a,s);return Mn(c.x,c.y,a,s)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Vn={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}()}(Vn);var Un,Wn,Hn=Vn.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"}(Un||(Un={})),function(t){t[t.ZERO=0]="ZERO",t[t.NEGATIVE_ONE=1]="NEGATIVE_ONE"}(Wn||(Wn={}));var qn=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}(),$n=function(){function t(t){this.clipSpaceNearZ=Wn.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 Yn(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Xn(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Kn(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Zn(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Qn(t){return void 0===t?0:t>360||t<-360?t%360:t}function Jn(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),Array.isArray(t)&&3===t.length?Z(t):Vt(t)?J(t,e,n):J(t[0],t[1]||e,t[2]||n)}function tr(t){return t*(Math.PI/180)}function er(t){return t*(180/Math.PI)}function nr(t,e){return 16===e.length?function(t,e){var n,r,i=.5*Math.PI,o=u(L(K(),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 rr(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 v(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 ir(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=er(Math.atan2(n,e));return[t[6],t[7],o,a,s]}var or=b(),ar=b(),sr=ft(),cr=[K(),K(),K()],ur=K();function lr(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 hr,dr=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){Yn(this.center,t),Yn(this.halfExtents,e),Xn(this.min,this.center,this.halfExtents),Kn(this.max,this.center,this.halfExtents)},t.prototype.setMinMax=function(t,e){Kn(this.center,e,t),Zn(this.center,this.center,.5),Xn(this.halfExtents,e,t),Zn(this.halfExtents,this.halfExtents,.5),Yn(this.min,t),Yn(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],E=e.halfExtents,w=E[0],x=E[1],M=E[2],N=v-w,S=v+w,T=y-x,k=y+x,C=b-M,P=b+M;N<l&&(l=N),S>h&&(h=S),T<d&&(d=T),k>f&&(f=k),C<p&&(p=C),P>g&&(g=P),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),E=Math.abs(h),w=Math.abs(d),x=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]+E*o[2],r[2]=w*o[0]+x*o[1]+M*o[2],Xn(this.min,n,r),Kn(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?Yn([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?Yn([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}(),fr=function(){function t(t,e){this.distance=t||0,this.normal=e||J(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 at(t,this.normal)-this.distance},t.prototype.normalize=function(){var t=1/dt(this.normal);it(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&&ct(n,t,e,i),o},t}();!function(t){t[t.OUTSIDE=4294967295]="OUTSIDE",t[t.INSIDE=0]="INSIDE",t[t.INDETERMINATE=2147483647]="INDETERMINATE"}(hr||(hr={}));var pr,gr,mr,vr=function(){function t(t){if(this.planes=[],t)this.planes=t;else for(var e=0;e<6;e++)this.planes.push(new fr)}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];et(this.planes[0].normal,o-n,l-a,p-h),this.planes[0].distance=y-g,et(this.planes[1].normal,o+n,l+a,p+h),this.planes[1].distance=y+g,et(this.planes[2].normal,o+r,l+s,p+d),this.planes[2].distance=y+m,et(this.planes[3].normal,o-r,l-s,p-d),this.planes[3].distance=y-m,et(this.planes[4].normal,o-i,l-c,p-f),this.planes[4].distance=y-v,et(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}(),yr=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}(),br=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}(),Er="Method not implemented.",wr="Use document.documentElement instead.";!function(t){t[t.ORBITING=0]="ORBITING",t[t.EXPLORING=1]="EXPLORING",t[t.TRACKING=2]="TRACKING"}(pr||(pr={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ROTATIONAL=1]="ROTATIONAL",t[t.TRANSLATIONAL=2]="TRANSLATIONAL",t[t.CINEMATIC=3]="CINEMATIC"}(gr||(gr={})),function(t){t[t.ORTHOGRAPHIC=0]="ORTHOGRAPHIC",t[t.PERSPECTIVE=1]="PERSPECTIVE"}(mr||(mr={}));var xr,Mr,Nr,Sr,Tr,kr="updated",Cr=2e-4,Pr=function(){function t(){this.clipSpaceNearZ=Wn.NEGATIVE_ONE,this.eventEmitter=new g,this.matrix=b(),this.right=J(1,0,0),this.up=J(0,1,0),this.forward=J(0,0,1),this.position=J(0,0,1),this.focalPoint=J(0,0,0),this.distanceVector=J(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=b(),this.projectionMatrixInverse=b(),this.jitteredProjectionMatrix=void 0,this.enableUpdate=!0,this.type=pr.EXPLORING,this.trackingMode=gr.DEFAULT,this.projectionMode=mr.PERSPECTIVE,this.frustum=new vr,this.orthoMatrix=b()}return t.prototype.isOrtho=function(){return this.projectionMode===mr.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===pr.EXPLORING?this.setWorldRotation(!0):this.setWorldRotation(!1),this._getAngles(),this.type===pr.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!==pr.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 S(b(),this.matrix)},t.prototype.getWorldTransform=function(){return this.matrix},t.prototype.jitterProjectionMatrix=function(t,e){var n=R(b(),[t,e,0]);this.jitteredProjectionMatrix=k(b(),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===mr.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===mr.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===mr.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===mr.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===mr.ORTHOGRAPHIC?this.setOrthographic(this.left,this.rright,this.top,this.bottom,this.near,this.far):this.projectionMode===mr.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=J(a.x-r,a.y-i,0),c=at(s,this.right)/Q(this.right),u=at(s,this.up)/Q(this.up);return this.pan(-c,-u),this},t.prototype.setPerspective=function(t,e,n,r){var i;this.projectionMode=mr.PERSPECTIVE,this.fov=n,this.near=t,this.far=e,this.aspect=r;var o=this.near*Math.tan(tr(.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===Wn.ZERO),P(this.projectionMatrix,this.projectionMatrix,J(1,-1,1)),S(this.projectionMatrixInverse,this.projectionMatrix),this.triggerUpdate(),this},t.prototype.setOrthographic=function(t,e,n,r,i,o){var a;this.projectionMode=mr.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===Wn.NEGATIVE_ONE?U(this.projectionMatrix,h,d,p,f,i,o):W(this.projectionMatrix,h,d,p,f,i,o),P(this.projectionMatrix,this.projectionMatrix,J(1,-1,1)),S(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=Jn(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=J(0,1,0);if(this.focalPoint=Jn(t,e,n),this.trackingMode===gr.CINEMATIC){var i=rt(K(),this.focalPoint,this.position);t=i[0],e=i[1],n=i[2];var o=Q(i),a=er(Math.asin(e/o)),s=90+er(Math.atan2(n,t)),c=b();O(c,c,tr(s)),A(c,c,tr(a)),r=ut(K(),[0,1,0],c)}return S(this.matrix,H(b(),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<Cr&&(this.distance=Cr),this.dollyingStep=this.distance/100;var e=K();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=Qn(t),this.computeMatrix(),this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getAzimuth=function(){return this.azimuth},t.prototype.setElevation=function(t){return this.elevation=Qn(t),this.computeMatrix(),this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getElevation=function(){return this.elevation},t.prototype.setRoll=function(t){return this.roll=Qn(t),this.computeMatrix(),this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.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=mt(gt(),[0,0,1],tr(this.roll));M(this.matrix);var e=mt(gt(),[1,0,0],tr((this.rotateWorld&&this.type!==pr.TRACKING||this.type===pr.TRACKING?1:-1)*this.elevation)),n=mt(gt(),[0,1,0],tr((this.rotateWorld&&this.type!==pr.TRACKING||this.type===pr.TRACKING?1:-1)*this.azimuth)),r=vt(gt(),n,e);r=vt(gt(),r,t);var i=F(b(),r);this.type===pr.ORBITING||this.type===pr.EXPLORING?(C(this.matrix,this.matrix,this.focalPoint),k(this.matrix,this.matrix,i),C(this.matrix,this.matrix,[0,0,this.distance])):this.type===pr.TRACKING&&(C(this.matrix,this.matrix,this.position),k(this.matrix,this.matrix,i))},t.prototype._setPosition=function(t,e,n){this.position=Jn(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(){tt(this.right,Jn(pt(ft(),[1,0,0,0],this.matrix))),tt(this.up,Jn(pt(ft(),[0,1,0,0],this.matrix))),tt(this.forward,Jn(pt(ft(),[0,0,1,0],this.matrix))),ot(this.right,this.right),ot(this.up,this.up),ot(this.forward,this.forward)},t.prototype._getAngles=function(){var t=this.distanceVector[0],e=this.distanceVector[1],n=this.distanceVector[2],r=Q(this.distanceVector);if(0===r)return this.elevation=0,void(this.azimuth=0);this.type===pr.TRACKING||this.rotateWorld?(this.elevation=er(Math.asin(e/r)),this.azimuth=er(Math.atan2(-t,-n))):(this.elevation=-er(Math.asin(e/r)),this.azimuth=-er(Math.atan2(-t,-n)))},t.prototype._getPosition=function(){tt(this.position,Jn(pt(ft(),[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}(y(),this.matrix)),nt(this.focalPoint,this.position,this.distanceVector),this._getDistance()},t.prototype._getDistance=function(){this.distanceVector=rt(K(),this.focalPoint,this.position),this.distance=Q(this.distanceVector),this.dollyingStep=this.distance/100},t.prototype._getOrthoMatrix=function(){if(this.projectionMode===mr.ORTHOGRAPHIC){var t=this.position,e=mt(gt(),[0,0,1],-this.roll*Math.PI/180);z(this.orthoMatrix,e,J((this.rright-this.left)/2-t[0],(this.top-this.bottom)/2-t[1],0),J(this.zoom,this.zoom,1),t)}},t.prototype.triggerUpdate=function(){if(this.enableUpdate){var t=this.getViewTransform(),e=k(b(),this.getPerspective(),t);this.getFrustum().extractFromVPMatrix(e),this.eventEmitter.emit(kr)}},t.prototype.rotate=function(t,e,n){throw new Error(Er)},t.prototype.pan=function(t,e){throw new Error(Er)},t.prototype.dolly=function(t){throw new Error(Er)},t.prototype.createLandmark=function(t,e){throw new Error(Er)},t.prototype.gotoLandmark=function(t,e){throw new Error(Er)},t.prototype.cancelLandmarkAnimation=function(){throw new Error(Er)},t}();function Ar(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(Ar.Cache||Map),n}Ar.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"}(xr||(xr={})),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"}(Mr||(Mr={})),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"}(Nr||(Nr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Sr||(Sr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Tr||(Tr={}));var Or,Rr=[{name:"em",unit_type:xr.kEms},{name:"px",unit_type:xr.kPixels},{name:"deg",unit_type:xr.kDegrees},{name:"rad",unit_type:xr.kRadians},{name:"grad",unit_type:xr.kGradians},{name:"ms",unit_type:xr.kMilliseconds},{name:"s",unit_type:xr.kSeconds},{name:"rem",unit_type:xr.kRems},{name:"turn",unit_type:xr.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"}(Or||(Or={}));var _r,Dr=function(t){return t?"number"===t?xr.kNumber:"percent"===t||"%"===t?xr.kPercentage:function(t){return Rr.find((function(e){return e.name===t})).unit_type}(t):xr.kUnknown},Ir=function(t){var e=1;switch(t){case xr.kPixels:case xr.kDegrees:case xr.kSeconds:break;case xr.kMilliseconds:e=.001;break;case xr.kRadians:e=180/Math.PI;break;case xr.kGradians:e=.9;break;case xr.kTurns:e=360}return e},Lr=function(t){switch(t){case xr.kNumber:case xr.kInteger:return"";case xr.kPercentage:return"%";case xr.kEms:return"em";case xr.kRems:return"rem";case xr.kPixels:return"px";case xr.kDegrees:return"deg";case xr.kRadians:return"rad";case xr.kGradians:return"grad";case xr.kMilliseconds:return"ms";case xr.kSeconds:return"s";case xr.kTurns:return"turn"}return""},jr=function(){function t(){}return t.isAngle=function(t){return t===xr.kDegrees||t===xr.kRadians||t===xr.kGradians||t===xr.kTurns},t.isLength=function(t){return t>=xr.kEms&&t<xr.kDegrees},t.isRelativeUnit=function(t){return t===xr.kPercentage||t===xr.kEms||t===xr.kRems},t.isTime=function(t){return t===xr.kSeconds||t===xr.kMilliseconds},t.prototype.toString=function(){return this.buildCSSText(Sr.kNo,Tr.kNo,"")},t.prototype.isNumericValue=function(){return this.getType()>=Or.kUnitType&&this.getType()<=Or.kClampType},t}(),zr=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 Or.kColorType},e.prototype.to=function(t){return this},e}(jr);!function(t){t[t.Constant=0]="Constant",t[t.LinearGradient=1]="LinearGradient",t[t.RadialGradient=2]="RadialGradient"}(_r||(_r={}));var Fr=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 Or.kColorType},e}(jr),Br=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 Or.kKeywordType},e.prototype.buildCSSText=function(t,e,n){return n+this.value},e}(jr),Gr=Ar((function(t){return void 0===t&&(t=""),t.replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()}))})),Vr=function(t){return t.split("").map((function(t,e){return t.toUpperCase()===t?"".concat(0!==e?"-":"").concat(t.toLowerCase()):t})).join("")};function Ur(t){return"function"==typeof t}var Wr={d:{alias:"path"},strokeDasharray:{alias:"lineDash"},strokeWidth:{alias:"lineWidth"},textAnchor:{alias:"textAlign"},src:{alias:"img"}},Hr=Ar((function(t){var e=Gr(t),n=Wr[e];return e=(null==n?void 0:n.alias)||e})),qr=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},$r=function(t){return function(t){switch(t){case Mr.kUNumber:return xr.kNumber;case Mr.kULength:return xr.kPixels;case Mr.kUPercent:return xr.kPercentage;case Mr.kUTime:return xr.kSeconds;case Mr.kUAngle:return xr.kDegrees;default:return xr.kUnknown}}(function(t){switch(t){case xr.kNumber:case xr.kInteger:return Mr.kUNumber;case xr.kPercentage:return Mr.kUPercent;case xr.kPixels:return Mr.kULength;case xr.kMilliseconds:case xr.kSeconds:return Mr.kUTime;case xr.kDegrees:case xr.kRadians:case xr.kGradians:case xr.kTurns:return Mr.kUAngle;default:return Mr.kUOther}}(t))},Yr=function(t){function e(e,n){void 0===n&&(n=xr.kNumber);var r,i=t.call(this)||this;return r="string"==typeof n?Dr(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 Or.kUnitType},e.prototype.convertTo=function(t){if(this.unit===t)return new e(this.value,this.unit);var n=$r(this.unit);if(n!==$r(t)||n===xr.kUnknown)return null;var r=Ir(this.unit)/Ir(t);return new e(this.value*r,t)},e.prototype.buildCSSText=function(t,e,n){var r;switch(this.unit){case xr.kUnknown:break;case xr.kInteger:r=Number(this.value).toFixed(0);break;case xr.kNumber:case xr.kPercentage:case xr.kEms:case xr.kRems:case xr.kPixels:case xr.kDegrees:case xr.kRadians:case xr.kGradians:case xr.kMilliseconds:case xr.kSeconds:case xr.kTurns:var i=this.value,o=Lr(this.unit);if(i<-999999||i>999999){var a=Lr(this.unit);r=!Number.isFinite(i)||Number.isNaN(i)?qr(i,a):i+(a||"")}else r="".concat(i).concat(o)}return n+=r},e}(jr),Xr=new Yr(0,"px");new Yr(1,"px");var Kr,Zr,Qr=new Yr(0,"deg"),Jr=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}(zr),ti=new Br("unset"),ei=new Br("initial"),ni=new Br("inherit"),ri={"":ti,unset:ti,initial:ei,inherit:ni},ii=function(t){return ri[t]||(ri[t]=new Br(t)),ri[t]},oi=new Jr(0,0,0,0,!0),ai=new Jr(0,0,0,0),si=Ar((function(t,e,n,r){return new Jr(t,e,n,r)}),(function(t,e,n,r){return"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")")})),ci=function(t,e){return void 0===e&&(e=xr.kNumber),new Yr(t,e)},ui=new Yr(50,"%");!function(t){t[t.Standard=0]="Standard"}(Kr||(Kr={})),function(t){t[t.ADDED=0]="ADDED",t[t.REMOVED=1]="REMOVED",t[t.Z_INDEX_CHANGED=2]="Z_INDEX_CHANGED"}(Zr||(Zr={}));var li,hi={absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new br(0,0,0,0)};function di(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>"}(li||(li={}));var fi=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&&E(n[0].length);var r=t.exec(e);return r&&E(r[0].length),r}function E(t){e=e.substring(t)}return function(t){return e=t,r()}}();var pi=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,gi=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,mi=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,vi=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;var yi={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},bi=Ar((function(t){var e;return e="angular"===t.type?Number(t.value):yi[t.value]||0,ci(e,"deg")})),Ei=Ar((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:ci(e,r),cy:ci(n,i)}})),wi=Ar((function(t){var e;if(t.indexOf("linear")>-1||t.indexOf("radial")>-1)return fi(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(!Ct(c)&&!Ct(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:ci(Number(t.length.value),"%"),color:di(t)}}));if("linear-gradient"===e)return new Fr(_r.LinearGradient,{angle:n?bi(n):Qr,steps:i});if("radial-gradient"===e&&(n||(n=[{type:"shape",value:"circle"}]),"shape"===n[0].type&&"circle"===n[0].value)){var o=Ei(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?ii(h):ci(h,l)}return new Fr(_r.RadialGradient,{cx:a,cy:s,size:c,steps:i})}}));var n=t[0];if("("===t[1]||"("===t[2])if("l"===n){var r=pi.exec(t);if(r){var i=(null===(e=r[2].match(vi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return[new Fr(_r.LinearGradient,{angle:ci(parseFloat(r[1]),"deg"),steps:i.map((function(t){var e=u(t,2),n=e[0],r=e[1];return{offset:ci(100*Number(n),"%"),color:r}}))})]}}else if("r"===n){var o=function(t){var e,n=gi.exec(t);if(n){var r=(null===(e=n[4].match(vi))||void 0===e?void 0:e.map((function(t){return t.split(":")})))||[];return{cx:ci(50,"%"),cy:ci(50,"%"),steps:r.map((function(t){var e=u(t,2),n=e[0],r=e[1];return{offset:ci(100*Number(n),"%"),color:r}}))}}return null}(t);if(o){if(!zt(o))return[new Fr(_r.RadialGradient,o)];t=o}}else if("p"===n)return function(t){var e=mi.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 xi(t){return t&&!!t.image}function Mi(t){return t&&!Ct(t.r)&&!Ct(t.g)&&!Ct(t.b)}var Ni=Ar((function(t){if(xi(t))return i({repetition:"repeat"},t);if(Ct(t)&&(t=""),"transparent"===t)return ai;"currentColor"===t&&(t="black");var e=wi(t);if(e)return e;var n=dn(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),si.apply(void 0,l([],u(r),!1))}));function Si(t,e){if(Mi(t)&&Mi(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(Gt(e[n],0,255));return e[3]=Gt(e[3],0,1),"rgba(".concat(e.join(","),")")}]}function Ti(t,e){if(Ct(e))return ci(0,"px");if(e="".concat(e).trim().toLowerCase(),isFinite(Number(e))){if("px".search(t)>=0)return ci(Number(e),"px");if("deg".search(t)>=0)return ci(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 ci(Number(e.replace(new RegExp("U"+t,"g"),"").replace(new RegExp(r,"g"),"*0")),t)}))[0]}var ki=function(t){return Ti(new RegExp("px","g"),t)},Ci=Ar(ki);Ar((function(t){return Ti(new RegExp("%","g"),t)}));var Pi=function(t){return Vt(t)||isFinite(Number(t))?ci(Number(t)||0,"px"):Ti(new RegExp("px|%|em|rem","g"),t)},Ai=Ar(Pi),Oi=function(t){return Ti(new RegExp("deg|rad|grad|turn","g"),t)},Ri=Ar(Oi);function _i(t,e,n,r,i){void 0===i&&(i=0);var o="",a=t.value||0,s=e.value||0,c=$r(t.unit),u=t.convertTo(c),l=e.convertTo(c);return u&&l?(a=u.value,s=l.value,o=Lr(t.unit)):(Yr.isLength(t.unit)||Yr.isLength(e.unit))&&(a=ji(t,i,n),s=ji(e,i,n),o="px"),[a,s,function(t){return r&&(t=Math.max(t,0)),t+o}]}function Di(t){var e=0;return t.unit===xr.kDegrees?e=t.value:t.unit===xr.kRadians?e=er(Number(t.value)):t.unit===xr.kTurns&&(e=360*Number(t.value)),e}function Ii(t,e){var n;return Array.isArray(t)?n=t.map((function(t){return Number(t)})):zt(t)?n=t.split(" ").map((function(t){return Number(t)})):Vt(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 Li(t){return zt(t)?t.split(" ").map((function(t){return Ai(t)})):t.map((function(t){return Ai(t.toString())}))}function ji(t,e,n){if(0===t.value)return 0;if(t.unit===xr.kPixels)return Number(t.value);if(t.unit===xr.kPercentage&&n){var r=n.nodeName===Un.GROUP?n.getLocalBounds():n.geometry.contentBounds;return t.value/100*r.halfExtents[e]*2}return 0}var zi=["blur","brightness","drop-shadow","contrast","grayscale","sepia","saturate","hue-rotate","invert"];function Fi(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,zi.indexOf(e[1])>-1&&r.push({name:e[1],params:e[2].split(" ").map((function(t){return Ti(/deg|rad|grad|turn|px|%/g,t)||Ni(t)}))}),n.lastIndex===t.length)return r}return[]}function Bi(t){return t.toString()}var Gi=function(t){return"number"==typeof t?ci(t):/^\s*[-+]?(\d*\.)?\d+\s*$/.test(t)?ci(Number(t)):ci(0)},Vi=Ar(Gi);function Ui(t,e){return[t,e,Bi]}function Wi(t,e){return function(n,r){return[n,r,function(n){return Bi(Gt(n,t,e))}]}}function Hi(t,e){if(t.length===e.length)return[t,e,function(t){return t}]}function qi(t){var e;return 0===t.parsedStyle.path.totalLength&&(t.parsedStyle.path.totalLength=Ge(t.parsedStyle.path.absolutePath,void 0,i(i({},e),{bbox:!1,length:!0})).length),t.parsedStyle.path.totalLength}function $i(t,e){return t[0]===e[0]&&t[1]===e[1]}function Yi(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)||Wt(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 Xi(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}Ar((function(t){return zt(t)?t.split(" ").map(Vi):t.map(Vi)}));var Ki=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)},Zi=function(t,e,n,r,i,o,a,s){e=Math.abs(e),n=Math.abs(n);var c=tr(r=Ht(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=Ki({x:1,y:0},y),E=Ki(y,{x:(-h.x-g)/e,y:(-h.y-m)/n});!o&&E>0?E-=2*Math.PI:o&&E<0&&(E+=2*Math.PI);var w=b+(E%=2*Math.PI)*s,x=e*Math.cos(w),M=n*Math.sin(w);return{x:Math.cos(c)*x-Math.sin(c)*M+v.x,y:Math.sin(c)*x+Math.cos(c)*M+v.y,ellipticalArcStartAngle:b,ellipticalArcEndAngle:b+E,ellipticalArcAngle:w,ellipticalArcCenter:v,resultantRx:e,resultantRy:n}};function Qi(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=Zi({x:t.prePoint[0],y:t.prePoint[1]},o,s,c,!!u,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},e),d=Zi({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 Ji(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function to(t,e){return Ji(t)*Ji(e)?(t[0]*e[0]+t[1]*e[1])/(Ji(t)*Ji(e)):1}function eo(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(to(t,e))}function no(t,e){var n=e[1],r=e[2],i=Ht(tr(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,E=[(h-m)/n,(d-v)/r],w=[(-1*h-m)/n,(-1*d-v)/r],x=eo([1,0],E),M=eo(E,w);return to(E,w)<=-1&&(M=Math.PI),to(E,w)>=1&&(M=0),0===a&&M>0&&(M-=2*Math.PI),1===a&&M<0&&(M+=2*Math.PI),{cx:y,cy:b,rx:$i(t,[u,l])?0:n,ry:$i(t,[u,l])?0:r,startAngle:x,endAngle:x+M,xRotation:i,arcFlag:o,sweepFlag:a}}var ro=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=Se(t)}catch(n){e=Se(""),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&&$i(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=no(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]&&$i(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=Xi((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=Xi((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=Qi(l,0),E=b.x,w=b.y,x=Qi(l,1,!1),M=x.x,N=x.y;l.startTangent=[E,w],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=Bn(c[0],c[1],s[1],s[2],s[3],s[4]);break;case"C":u=In(c[0],c[1],s[1],s[2],s[3],s[4],s[5],s[6]);break;case"A":var l=g.arcParams;u=kn(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=jt(n),d=jt(r),f=Lt(n),p=Lt(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-=Yi(g,e).xExtra:a[0]===f&&(f+=Yi(g,e).xExtra),a[1]===d?d-=Yi(g,e).yExtra:a[1]===p&&(p+=Yi(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}}},io=Ar(ro);function oo(t){return zt(t)?io(t):ro(t)}function ao(t,e,n){var r=t.curve,i=e.curve;r&&0!==r.length||(r=Oe(t.absolutePath,!1),t.curve=r),i&&0!==i.length||(i=Oe(e.absolutePath,!1),e.curve=i);var o=[r,i];r.length!==i.length&&(o=He(r,i));var a,s,c=Ue(o[0])!==Ue(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,Ve(o[1],c),function(t){return t}]}function so(t,e){var n;n=zt(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=jn(n);n.forEach((function(t,e){n[e+1]&&((r=[0,0])[0]=a/s,i=An(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 co(t,e){return[t.points,e.points,function(t){return t}]}var uo=null;function lo(t){return function(e){var n=0;return t.map((function(t){return t===uo?e[n++]:t}))}}function ho(t){return t}var fo={matrix:["NNNNNN",[uo,uo,0,0,uo,uo,0,0,0,0,1,0,uo,uo,0,1],ho],matrix3d:["NNNNNNNNNNNNNNNN",ho],rotate:["A"],rotatex:["A"],rotatey:["A"],rotatez:["A"],rotate3d:["NNNA"],perspective:["L"],scale:["Nn",lo([uo,uo,new Yr(1)]),ho],scalex:["N",lo([uo,new Yr(1),new Yr(1)]),lo([uo,new Yr(1)])],scaley:["N",lo([new Yr(1),uo,new Yr(1)]),lo([new Yr(1),uo])],scalez:["N",lo([new Yr(1),new Yr(1),uo])],scale3d:["NNN",ho],skew:["Aa",null,ho],skewx:["A",null,lo([uo,Qr])],skewy:["A",null,lo([Qr,uo])],translate:["Tt",lo([uo,uo,Xr]),ho],translatex:["T",lo([uo,Xr,Xr]),lo([uo,Xr])],translatey:["T",lo([Xr,uo,Xr]),lo([Xr,uo])],translatez:["L",lo([Xr,Xr,uo])],translate3d:["TTL",ho]};function po(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=fo[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()?Qr:Ri(t)},N:Vi,T:Ai,L:Ci}[d.toUpperCase()](h):{a:Qr,n:u[0],t:Xr}[d]))return[];u.push(f)}if(r.push({t:o,d:u}),n.lastIndex===t.length)return r}return[]}function go(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=fo[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()?Qr:Oi(t)},N:Gi,T:Pi,L:ki}[d.toUpperCase()](h):{a:Qr,n:u[0],t:Xr}[d]))return[];u.push(f)}if(r.push({t:o,d:u}),n.lastIndex===t.length)return r}return[]}function mo(t){var e,n,r,i;switch(t.t){case"rotatex":return i=tr(Di(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=tr(Di(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=tr(Di(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=tr(Di(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=tr(Di(t.d[0])),h=tr(Di(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=tr(Di(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=tr(Di(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=ji(t.d[0],0,null)||0,n=ji(t.d[1],0,null)||0,0,1];case"translatex":return[1,0,0,0,0,1,0,0,0,0,1,0,e=ji(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=ji(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=ji(t.d[0],0,null)||0,1];case"translate3d":return[1,0,0,0,0,1,0,0,0,0,1,0,e=ji(t.d[0],0,null)||0,n=ji(t.d[1],0,null)||0,r=ji(t.d[2],0,null)||0,1];case"perspective":var d=ji(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 vo(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 yo(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}(or,t))return!1;if(w(ar,or),ar[3]=0,ar[7]=0,ar[11]=0,ar[15]=1,Math.abs(T(ar))<1e-8)return!1;var a,s,c=or[3],u=or[7],l=or[11],h=or[12],d=or[13],f=or[14],p=or[15];if(0!==c||0!==u||0!==l){if(sr[0]=c,sr[1]=u,sr[2]=l,sr[3]=p,!S(ar,ar))return!1;N(ar,ar),pt(i,sr,ar)}else i[0]=i[1]=i[2]=0,i[3]=1;if(e[0]=h,e[1]=d,e[2]=f,s=or,(a=cr)[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]=Q(cr[0]),ot(cr[0],cr[0]),r[0]=at(cr[0],cr[1]),lr(cr[1],cr[1],cr[0],1,-r[0]),n[1]=Q(cr[1]),ot(cr[1],cr[1]),r[0]/=n[1],r[1]=at(cr[0],cr[2]),lr(cr[2],cr[2],cr[0],1,-r[1]),r[2]=at(cr[1],cr[2]),lr(cr[2],cr[2],cr[1],1,-r[2]),n[2]=Q(cr[2]),ot(cr[2],cr[2]),r[1]/=n[2],r[2]/=n[2],st(ur,cr[1],cr[2]),at(cr[0],ur)<0)for(var g=0;g<3;g++)n[g]*=-1,cr[g][0]*=-1,cr[g][1]*=-1,cr[g][2]*=-1;o[0]=.5*Math.sqrt(Math.max(1+cr[0][0]-cr[1][1]-cr[2][2],0)),o[1]=.5*Math.sqrt(Math.max(1-cr[0][0]+cr[1][1]-cr[2][2],0)),o[2]=.5*Math.sqrt(Math.max(1-cr[0][0]-cr[1][1]+cr[2][2],0)),o[3]=.5*Math.sqrt(Math.max(1+cr[0][0]+cr[1][1]+cr[2][2],0)),cr[2][1]>cr[1][2]&&(o[0]=-o[0]),cr[0][2]>cr[2][0]&&(o[1]=-o[1]),cr[1][0]>cr[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(mo).reduce(vo)}(t),e,n,r,i,o),[[e,n,r,o,i]]}var bo=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 Eo(t){return t.toFixed(6).replace(".000000","")}function wo(t,e){var n,r;return t.decompositionPair!==e&&(t.decompositionPair=e,n=yo(t)),e.decompositionPair!==t&&(e.decompositionPair=t,r=yo(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=Gt(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 bo(t[0],t[1],t[2],e,t[4]).map(Eo).join(",")}])}function xo(t){return t.replace(/[xy]/,"")}function Mo(t){return t.replace(/(x|y|z|3d)?$/,"3d")}function No(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?ci(a):ci(a,t.unit)}))})},o=0;o<t.length;o++)i(o)}var a,s,c=[],u=[],l=[];if(t.length!==e.length)c=[(y=wo(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=fo[h],m=fo[d],v=void 0;if(s=d,"perspective"===(a=h)&&"perspective"===s||!("matrix"!==a&&"matrix3d"!==a||"matrix"!==s&&"matrix3d"!==s)){var y=wo([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]&&xo(h)===xo(d))v=xo(h),f=g[2](f),p=m[2](p);else{if(!g[1]||!m[1]||Mo(h)!==Mo(d)){c=[(y=wo(t,e))[0]],u=[y[1]],l=[["matrix",[y[2]]]];break}v=Mo(h),f=g[1](f),p=m[1](p)}for(var b=[],E=[],w=[],x=0;x<f.length;x++){y=_i(f[x],p[x],n,!1,x);b[x]=y[0],E[x]=y[1],w.push(y[2])}c.push(b),u.push(E),l.push([v,w])}}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 So=Ar((function(t){if(zt(t)){if("text-anchor"===t)return[ci(0,"px"),ci(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:[Ai(ko(e[0])),Ai(ko(e[1]))]}return[ci(t[0]||0,"px"),ci(t[1]||0,"px")]})),To=function(t){if(zt(t)){if("text-anchor"===t)return[ci(0,"px"),ci(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:[Pi(ko(e[0])),Pi(ko(e[1]))]}return[ci(t[0]||0,"px"),ci(t[1]||0,"px")]};function ko(t){return"center"===t?"50%":"left"===t||"top"===t?"0":"right"===t||"bottom"===t?"100%":t}var Co=[{n:"display",k:["none"]},{n:"opacity",int:!0,inh:!0,d:"1",syntax:li.OPACITY_VALUE},{n:"fillOpacity",int:!0,inh:!0,d:"1",syntax:li.OPACITY_VALUE},{n:"strokeOpacity",int:!0,inh:!0,d:"1",syntax:li.OPACITY_VALUE},{n:"fill",int:!0,k:["none"],d:"none",syntax:li.PAINT},{n:"fillRule",k:["nonzero","evenodd"],d:"nonzero"},{n:"stroke",int:!0,k:["none"],d:"none",syntax:li.PAINT,l:!0},{n:"shadowType",k:["inner","outer","both"],d:"outer",l:!0},{n:"shadowColor",int:!0,syntax:li.COLOR},{n:"shadowOffsetX",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"shadowOffsetY",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"shadowBlur",int:!0,l:!0,d:"0",syntax:li.SHADOW_BLUR},{n:"lineWidth",int:!0,inh:!0,d:"1",l:!0,a:["strokeWidth"],syntax:li.LENGTH_PERCENTAGE},{n:"increasedLineWidthForHitTesting",inh:!0,d:"0",l:!0,syntax:li.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:li.LENGTH_PERCENTAGE_12},{n:"lineDashOffset",int:!0,inh:!0,d:"0",a:["strokeDashoffset"],syntax:li.LENGTH_PERCENTAGE},{n:"offsetPath",syntax:li.DEFINED_PATH},{n:"offsetDistance",int:!0,syntax:li.OFFSET_DISTANCE},{n:"dx",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"dy",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"zIndex",ind:!0,int:!0,d:"0",k:["auto"],syntax:li.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:li.FILTER},{n:"clipPath",syntax:li.DEFINED_PATH},{n:"textPath",syntax:li.DEFINED_PATH},{n:"textPathSide",k:["left","right"],d:"left"},{n:"textPathStartOffset",l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"transform",p:100,int:!0,k:["none"],d:"none",syntax:li.TRANSFORM},{n:"transformOrigin",p:100,d:function(t){return t===Un.CIRCLE||t===Un.ELLIPSE?"center":t===Un.TEXT?"text-anchor":"left top"},l:!0,syntax:li.TRANSFORM_ORIGIN},{n:"anchor",p:99,d:function(t){return t===Un.CIRCLE||t===Un.ELLIPSE?"0.5 0.5":"0 0"},l:!0,syntax:li.LENGTH_PERCENTAGE_12},{n:"cx",int:!0,d:"0",syntax:li.COORDINATE},{n:"cy",int:!0,d:"0",syntax:li.COORDINATE},{n:"cz",int:!0,d:"0",syntax:li.COORDINATE},{n:"r",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"rx",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"ry",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"x",int:!0,d:"0",syntax:li.COORDINATE},{n:"y",int:!0,d:"0",syntax:li.COORDINATE},{n:"z",int:!0,d:"0",syntax:li.COORDINATE},{n:"width",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"height",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:li.LENGTH_PERCENTAGE},{n:"radius",int:!0,l:!0,d:"0",syntax:li.LENGTH_PERCENTAGE_14},{n:"x1",int:!0,l:!0,syntax:li.COORDINATE},{n:"y1",int:!0,l:!0,syntax:li.COORDINATE},{n:"z1",int:!0,l:!0,syntax:li.COORDINATE},{n:"x2",int:!0,l:!0,syntax:li.COORDINATE},{n:"y2",int:!0,l:!0,syntax:li.COORDINATE},{n:"z2",int:!0,l:!0,syntax:li.COORDINATE},{n:"path",int:!0,l:!0,d:"",a:["d"],syntax:li.PATH,p:50},{n:"points",int:!0,l:!0,syntax:li.LIST_OF_POINTS,p:50},{n:"text",l:!0,d:"",syntax:li.TEXT,p:50},{n:"textTransform",l:!0,inh:!0,k:["capitalize","uppercase","lowercase","none"],d:"none",syntax:li.TEXT_TRANSFORM,p:51},{n:"font",l:!0},{n:"fontSize",int:!0,inh:!0,d:"16px",l:!0,syntax:li.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:li.LENGTH,int:!0,d:"0"},{n:"letterSpacing",l:!0,syntax:li.LENGTH,int:!0,d:"0"},{n:"miterLimit",l:!0,syntax:li.NUMBER,d:function(t){return t===Un.PATH||t===Un.POLYGON||t===Un.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:li.MARKER},{n:"markerEnd",syntax:li.MARKER},{n:"markerMid",syntax:li.MARKER},{n:"markerStartOffset",syntax:li.LENGTH,l:!0,int:!0,d:"0"},{n:"markerEndOffset",syntax:li.LENGTH,l:!0,int:!0,d:"0"}],Po=Co.filter((function(t){return!!t.l})).map((function(t){return t.n})),Ao={},Oo=new WeakMap,Ro=function(){function t(t){var e=this;this.runtime=t,Co.forEach((function(t){e.registerMetadata(t)}))}return t.prototype.registerMetadata=function(t){l([t.n],u(t.a||[]),!1).forEach((function(e){Ao[e]=t}))},t.prototype.unregisterMetadata=function(t){delete Ao[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<Po.length;u++)if(Po[u]in e){c=!0;break}return e.fill&&(t.parsedStyle.fill=Ni(e.fill)),e.stroke&&(t.parsedStyle.stroke=Ni(e.stroke)),e.shadowColor&&(t.parsedStyle.shadowColor=Ni(e.shadowColor)),e.filter&&(t.parsedStyle.filter=Fi(e.filter)),Ct(e.radius)||(t.parsedStyle.radius=Ii(e.radius,4)),Ct(e.lineDash)||(t.parsedStyle.lineDash=Ii(e.lineDash,2)),e.points&&(t.parsedStyle.points=so(e.points,t)),""===e.path&&(t.parsedStyle.path=i({},hi)),e.path&&(t.parsedStyle.path=oo(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=Ii(e.anchor,2)),e.transform&&(t.parsedStyle.transform=po(e.transform)),e.transformOrigin&&(t.parsedStyle.transformOrigin=So(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!==Un.CIRCLE&&t.nodeName!==Un.ELLIPSE||Ct(e.cx)&&Ct(e.cy))&&(t.nodeName!==Un.RECT&&t.nodeName!==Un.IMAGE&&t.nodeName!==Un.GROUP&&t.nodeName!==Un.HTML&&t.nodeName!==Un.TEXT&&t.nodeName!==Un.MESH||Ct(e.x)&&Ct(e.y)&&Ct(e.z))&&(t.nodeName!==Un.LINE||Ct(e.x1)&&Ct(e.y1)&&Ct(e.z1)&&Ct(e.x2)&&Ct(e.y2)&&Ct(e.z2))||this.runtime.CSSPropertySyntaxFactory["<coordinate>"].postProcessor(t,o),Ct(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),Ct(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=Ao[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=Ao[t],o=e;if((""===e||Ct(e))&&(e="unset"),"unset"===e||"initial"===e||"inherit"===e)o=ii(e);else if(i){var a=i.k,s=i.syntax,c=s&&this.getPropertySyntax(s);a&&a.indexOf(e)>-1?o=ii(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=Ao[t],o="g-root"===n.id,a=e;if(i){var s=i.syntax,c=i.inh,u=i.d;if(e instanceof Br){var l=e.value;if("unset"===l&&(l=c&&!o?"inherit":"initial"),"initial"===l)Ct(u)||(e=this.parseProperty(t,Ur(u)?u(n.nodeName):u,n,r));else if("inherit"===l){var h=this.tryToResolveProperty(n,t,{inherited:!0});return Ct(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 Br?e.value:e}return a},t.prototype.postProcessProperty=function(t,e,n){var r=Ao[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=Oo.get(t);n||(Oo.set(t,[]),n=Oo.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=Oo.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=Oo.get(t);if(e&&e.length){var n={};e.forEach((function(e){n[e]=t.attributes[e]})),this.processProperties(t,n),Oo.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 dr),r.renderBounds||(r.renderBounds=new dr);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,E=v.increasedLineWidthForHitTesting,w=v.shadowType,x=v.shadowColor,M=v.filter,N=void 0===M?[]:M,S=v.transformOrigin,T=i.anchor;e===Un.TEXT?delete i.anchor:e===Un.MESH&&(i.anchor[2]=.5);var k=[(1-2*(T&&T[0]||0))*a/2+h,(1-2*(T&&T[1]||0))*s/2+f,(1-2*(T&&T[2]||0))*m[2]+g];r.contentBounds.update(k,m);var C=e===Un.POLYLINE||e===Un.POLYGON||e===Un.PATH?Math.SQRT2:.5;if(y&&!y.isNone){var P=((b||0)+(E||0))*C;m[0]+=P,m[1]+=P}if(r.renderBounds.update(k,m),x&&w&&"inner"!==w){var A=r.renderBounds,O=A.min,R=A.max,_=i,D=_.shadowBlur||0,I=_.shadowOffsetX||0,L=_.shadowOffsetY||0,j=O[0]-D+I,z=R[0]+D+I,F=O[1]-D+L,B=R[1]+D+L;O[0]=Math.min(O[0],j),R[0]=Math.max(R[0],z),O[1]=Math.min(O[1],F),R[1]=Math.max(R[1],B),r.renderBounds.setMinMax(O,R)}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,Kn(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)}})),T=i.anchor;var G=a<0,V=s<0,U=(G?-1:1)*(S?ji(S[0],0,t):0),W=(V?-1:1)*(S?ji(S[1],1,t):0);U-=(G?-1:1)*(T&&T[0]||0)*r.contentBounds.halfExtents[0]*2,W-=(V?-1:1)*(T&&T[1]||0)*r.contentBounds.halfExtents[1]*2,t.setOrigin(U,W),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===Un.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===Un.CIRCLE&&t.style.rawR&&(t.style.r=t.style.rawR,delete t.style.rawR))},t.prototype.isPropertyInheritable=function(t){var e=Ao[t];return!!e&&e.inh},t}(),_o=function(){function t(){this.parser=Ri,this.parserUnmemoize=Oi,this.parserWithCSSDisabled=null,this.mixer=Ui}return t.prototype.calculator=function(t,e,n,r){return Di(n)},t}(),Do=function(){function t(){}return t.prototype.calculator=function(t,e,n,r,i){return n instanceof Br&&(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}(),Io=function(){function t(){this.parser=Ni,this.parserWithCSSDisabled=Ni,this.mixer=Si}return t.prototype.calculator=function(t,e,n,r){return n instanceof Br?"none"===n.value?oi:ai:n},t}(),Lo=function(){function t(){this.parser=Fi}return t.prototype.calculator=function(t,e,n){return n instanceof Br?[]:n},t}();function jo(t){var e=t.parsedStyle.fontSize;return Ct(e)?null:e}var zo=function(){function t(){this.parser=Ai,this.parserUnmemoize=Pi,this.parserWithCSSDisabled=null,this.mixer=Ui}return t.prototype.calculator=function(t,e,n,r,i){var o;if(Vt(n))return n;if(!Yr.isRelativeUnit(n.unit))return n.value;var a=i.styleValueRegistry;if(n.unit===xr.kPercentage)return 0;if(n.unit===xr.kEms){if(r.parentNode){if(s=jo(r.parentNode))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}if(n.unit===xr.kRems){if(null===(o=null==r?void 0:r.ownerDocument)||void 0===o?void 0:o.documentElement){var s;if(s=jo(r.ownerDocument.documentElement))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}},t}(),Fo=function(){function t(){this.mixer=Hi}return t.prototype.parser=function(t){var e=Li(Vt(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}(),Bo=function(){function t(){this.mixer=Hi}return t.prototype.parser=function(t){var e=Li(Vt(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}(),Go=b();function Vo(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||[Xr,Xr];e.translateLocal(s[0].value,s[1].value,0)}else if("translatex"===i){s=o||[Xr];e.translateLocal(s[0].value,0,0)}else if("translatey"===i){s=o||[Xr];e.translateLocal(0,s[0].value,0)}else if("translatez"===i){s=o||[Xr];e.translateLocal(0,0,s[0].value)}else if("translate3d"===i){s=o||[Xr,Xr,Xr];e.translateLocal(s[0].value,s[1].value,s[2].value)}else if("rotate"===i){var c=o||[Qr];e.rotateLocal(0,0,Di(c[0]))}else if("rotatex"===i){c=o||[Qr];e.rotateLocal(Di(c[0]),0,0)}else if("rotatey"===i){c=o||[Qr];e.rotateLocal(0,Di(c[0]),0)}else if("rotatez"===i){c=o||[Qr];e.rotateLocal(0,0,Di(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(tr(h[0]),tr(h[1]))}else if("skewx"===i){h=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(tr(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],tr(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(x(Go,f,p,0,0,g,m,0,0,0,0,1,0,v+n,y+r,0,1))}else"matrix3d"===i&&(x.apply(X,l([Go],u(o.map((function(t){return t.value}))),!1)),Go[12]+=n,Go[13]+=r,e.setLocalTransform(Go))})),e.getLocalTransform()}var Uo=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 Un.CIRCLE:case Un.ELLIPSE:var o=t.parsedStyle,a=o.cx,s=o.cy,c=o.cz;Ct(a)||(n=a),Ct(s)||(r=s),Ct(c)||(i=c);break;case Un.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 Un.RECT:case Un.IMAGE:case Un.GROUP:case Un.HTML:case Un.TEXT:case Un.MESH:Ct(t.parsedStyle.x)||(n=t.parsedStyle.x),Ct(t.parsedStyle.y)||(r=t.parsedStyle.y),Ct(t.parsedStyle.z)||(i=t.parsedStyle.z)}if(t.nodeName!==Un.PATH&&t.nodeName!==Un.POLYLINE&&t.nodeName!==Un.POLYGON&&(t.parsedStyle.defX=n||0,t.parsedStyle.defY=r||0),(!Ct(n)||!Ct(r)||!Ct(i))&&-1===e.indexOf("transform")){var g=t.parsedStyle.transform;if(g&&g.length)Vo(g,t);else{var m=u(t.getLocalPosition(),3),v=m[0],y=m[1],b=m[2];t.setLocalPosition(Ct(n)?v:n,Ct(r)?y:r,Ct(i)?b:i)}}},e}(zo),Wo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){n instanceof Br&&(n=null);var i=null==n?void 0:n.cloneNode(!0);return i&&(i.style.isMarker=!0),i},t}(),Ho=function(){function t(){this.mixer=Ui,this.parser=Vi,this.parserUnmemoize=Gi,this.parserWithCSSDisabled=null}return t.prototype.calculator=function(t,e,n){return n.value},t}(),qo=function(){function t(){this.parser=Vi,this.parserUnmemoize=Gi,this.parserWithCSSDisabled=null,this.mixer=Wi(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===Un.LINE||i===Un.PATH||i===Un.POLYLINE){var o=n.getPoint(r);o&&(t.parsedStyle.defX=o.x,t.parsedStyle.defY=o.y,t.setLocalPosition(o.x,o.y))}}},t}(),$o=function(){function t(){this.parser=Vi,this.parserUnmemoize=Gi,this.parserWithCSSDisabled=null,this.mixer=Wi(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t}(),Yo=function(){function t(){this.parser=oo,this.parserWithCSSDisabled=oo,this.mixer=ao}return t.prototype.calculator=function(t,e,n){return n instanceof Br&&"unset"===n.value?{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new br(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===Un.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}(),Xo=function(){function t(){this.parser=so,this.mixer=co}return t.prototype.postProcessor=function(t,e){if((t.nodeName===Un.POLYGON||t.nodeName===Un.POLYLINE)&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=n.defY;t.setLocalPosition(r,i)}},t}(),Ko=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.mixer=Wi(0,1/0),e}return r(e,t),e}(zo),Zo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){return n instanceof Br?"unset"===n.value?"":n.value:"".concat(n)},t.prototype.postProcessor=function(t){t.nodeValue="".concat(t.parsedStyle.text)||""},t}(),Qo=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}(),Jo={},ta=0;var ea="undefined"!=typeof window&&void 0!==window.document;function na(t){return!!t.getAttribute}function ra(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 ia(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 oa(t,e){if(ea)return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}var aa={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},sa="object"==typeof performance&&performance.now?performance:Date;function ca(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 ua=1,la="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},ha=Date.now(),da={},fa=Date.now(),pa=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=Date.now(),n=e-fa,r=n>16?0:16-n,i=ua++;return da[i]=t,Object.keys(da).length>1||setTimeout((function(){fa=e;var t=da;da={},Object.keys(t).forEach((function(e){return t[e](la.performance&&"function"==typeof la.performance.now?la.performance.now():Date.now()-ha)}))}),r),i},ga=function(t){delete da[t]},ma=function(t){return"string"!=typeof t?pa:""===t?la.requestAnimationFrame:la[t+"RequestAnimationFrame"]},va=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!!ma(t)})),ya=ma(va),ba=function(t){return"string"!=typeof t?ga:""===t?la.cancelAnimationFrame:la[t+"CancelAnimationFrame"]||la[t+"CancelRequestAnimationFrame"]}(va);la.requestAnimationFrame=ya,la.cancelAnimationFrame=ba;var Ea=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}(),wa=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}(),xa=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}(),Ma=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}(),Na=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Sa=/([\"\'])[^\'\"]+\1/;var Ta=function(){function t(){this.parser=po,this.parserUnmemoize=go,this.parserWithCSSDisabled=go,this.mixer=No}return t.prototype.calculator=function(t,e,n,r){return n instanceof Br?[]:n},t.prototype.postProcessor=function(t){Vo(t.parsedStyle.transform,t)},t}(),ka=function(){this.parser=So,this.parserUnmemoize=To},Ca=function(){function t(){this.parser=Vi,this.parserUnmemoize=Gi}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=Zr.Z_INDEX_CHANGED)}},t}(),Pa=function(){function t(){}return t.prototype.update=function(t,e){var n=t.r;return{width:2*n,height:2*n}},t}(),Aa=function(){function t(){}return t.prototype.update=function(t,e){return{width:2*t.rx,height:2*t.ry}},t}(),Oa=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}(),Ra=function(){function t(){}return t.prototype.update=function(t){var e=t.path.rect;return{width:e.width,height:e.height}},t}(),_a=function(){function t(){}return t.prototype.update=function(t){if(t.points&&Ot(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));return{width:r-n,height:Math.max.apply(Math,l([],u(e.map((function(t){return t[1]}))),!1))-i}}return{width:0,height:0}},t}(),Da=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&&!zt(n)&&(a||(a=n.width,t.width=a),s||(s=n.height,t.height=s)),{width:a,height:s}},t}(),Ia=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&&!Ct(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 La,ja=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 yr,this.page=new yr,this.canvas=new yr,this.viewport=new yr,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(Er)},t}(),za=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.client=new yr,e.movement=new yr,e.offset=new yr,e.global=new yr,e.screen=new yr,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(Er)},e}(ja),Fa=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}(za),Ba=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}(za),Ga=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}(ja),Va=function(){function t(){this.emitter=new g}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=Ur(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=Ur(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=Ur(e)?void 0:e;return t=r?"".concat(t,"capture"):t,e=Ur(e)?e:null==e?void 0:e.handleEvent,this.emitter.off(t,e,i),this},t.prototype.emit=function(t,e){this.dispatchEvent(new Ga(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}(),Ua=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===Un.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===Un.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===Un.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(Er)},e.prototype.lookupNamespaceURI=function(t){throw new Error(Er)},e.prototype.lookupPrefix=function(t){throw new Error(Er)},e.prototype.normalize=function(){throw new Error(Er)},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}(Va),Wa=function(){function t(t,e){var n=this;this.globalRuntime=t,this.context=e,this.emitter=new g,this.nativeHTMLMap=new WeakMap,this.cursor="default",this.mappingTable={},this.mappingState={trackingData:{}},this.eventPool=new Map,this.tmpMatrix=b(),this.tmpVec3=K(),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=sa.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")}Ua.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"),Ua.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&&Ua.isNode(o)&&o.parentNode;h&&h!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode)&&h!==e.target;)h=h.parentNode;if(!h||h===(Ua.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!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode);)d.currentTarget=d.target,n.notifyTarget(d),r&&n.notifyTarget(d,"mouseenter"),Ua.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!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode);)a.currentTarget=a.target,n.notifyTarget(a),r&&n.notifyTarget(a,"mouseleave"),Ua.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!==(Ua.isNode(n.rootTarget)&&n.rootTarget.parentNode);)o.currentTarget=o.target,n.notifyTarget(o),i&&n.notifyTarget(o,"mouseenter"),Ua.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"),Ua.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 yr(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 yr(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=k(this.tmpMatrix,c,s),l=et(this.tmpVec3,e/o*2-1,2*(1-n/a)-1,0);return ut(l,l,u),new yr(l[0],l[1])},t.prototype.canvas2Viewport=function(t){var e=this.rootTarget.defaultView.getCamera(),n=e.getPerspective(),r=e.getViewTransform(),i=k(this.tmpMatrix,n,r),o=et(this.tmpVec3,t.x,t.y,0);ut(this.tmpVec3,this.tmpVec3,i);var a=this.context.config,s=a.width,c=a.height;return new yr((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++)Ua.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){var e,n=this.context.contextService.getDomElement(),r=null===(e=t.nativeEvent)||void 0===e?void 0:e.target;if(r){if(r===n)return!0;if(n&&n.contains)return n.contains(r)}return!!t.nativeEvent.composedPath&&t.nativeEvent.composedPath().indexOf(n)>-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(Fa);this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.nativeEvent=t.nativeEvent,i.originalEvent=t;var o=this.getExistedHTML(i);return i.target=null!=n?n:o||this.isNativeEventFromCanvas(i)&&this.pickTarget(i)||r,"string"==typeof e&&(i.type=e),i},t.prototype.createWheelEvent=function(t){var e=this.allocateEvent(Ba);this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t;var n=this.getExistedHTML(e);return e.target=n||this.isNativeEventFromCanvas(e)&&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(Ba);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(Fa);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=sa.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||Ua.isNode(r)&&r.parentNode===e))break;e=t[n]}return e},t.prototype.getCursor=function(t){for(var e=t;e;){var n=na(e)&&e.getAttribute("cursor");if(n)return n;e=Ua.isNode(e)&&e.parentNode}},t}(),Ha=function(){function t(){}return t.prototype.getOrCreateCanvas=function(t,e){if(this.canvas)return this.canvas;if(t||cs.offscreenCanvas)this.canvas=t||cs.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"}(La||(La={}));var qa,$a=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 xa,initAsync:new Ea,dirtycheck:new Ma,cull:new Ma,beginFrame:new xa,beforeRender:new xa,render:new xa,afterRender:new xa,endFrame:new xa,destroy:new xa,pick:new wa,pickSync:new Ma,pointerDown:new xa,pointerUp:new xa,pointerMove:new xa,pointerOut:new xa,pointerOver:new xa,pointerWheel:new xa,pointerCancel:new xa,click:new xa}}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(La.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(La.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!==Zr.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;ra(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(ra)},t.prototype.destroy=function(){this.inited=!1,this.hooks.destroy.call(),this.globalRuntime.sceneGraphService.clearPendingEvents()},t.prototype.dirtify=function(){this.context.renderingContext.renderReasons.add(La.DISPLAY_OBJECT_CHANGED)},t}(),Ya=/\[\s*(.*)=(.*)\s*\]/,Xa=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(Ya),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 Ct(n)?"":n.toString?n.toString():""},t}(),Ka=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}(ja);function Za(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"}(qa||(qa={}));var Qa,Ja,ts,es=new Ka(qa.REPARENT,null,"","","",0,"",""),ns=function(){function t(t){var e,n,r,i,o,a,s,c,u=this;this.runtime=t,this.pendingEvents=[],this.boundsChangedEvent=new Ga(qa.BOUNDS_CHANGED),this.rotate=(e=gt(),function(t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof n&&(n=J(n,r,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){var a=gt();bt(a,n[0],n[1],n[2]);var s=u.getRotation(t),c=u.getRotation(t.parentNode);wt(e,c),yt(e,e),vt(a,e,a),vt(o.localRotation,a,s),Mt(o.localRotation,o.localRotation),u.dirtifyLocal(t,o)}else u.rotateLocal(t,n)}),this.rotateLocal=(n=gt(),function(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0),"number"==typeof e&&(e=J(e,r,i));var o=t.transformable;bt(n,e[0],e[1],e[2]),xt(o.localRotation,o.localRotation,n),u.dirtifyLocal(t,o)}),this.setEulerAngles=(r=gt(),function(t,e,n,i){void 0===n&&(n=0),void 0===i&&(i=0),"number"==typeof e&&(e=J(e,n,i));var o=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){bt(o.localRotation,e[0],e[1],e[2]);var a=u.getRotation(t.parentNode);wt(r,yt(gt(),a)),xt(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=J(e,n,r));var i=t.transformable;lt(e,K())||(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),nt(i.localPosition,i.localPosition,e),u.dirtifyLocal(t,i))},this.setPosition=(i=b(),o=K(),function(t,e){var n=t.transformable;if(o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,!lt(u.getPosition(t),o)){if(tt(n.position,o),null!==t.parentNode&&t.parentNode.transformable){var r=t.parentNode.transformable;w(i,r.worldTransform),S(i,i),ut(n.localPosition,o,i)}else tt(n.localPosition,o);u.dirtifyLocal(t,n)}}),this.setLocalPosition=function(){var t=K();return function(e,n){var r=e.transformable;t[0]=n[0],t[1]=n[1],t[2]=n[2]||0,lt(r.localPosition,t)||(tt(r.localPosition,t),u.dirtifyLocal(e,r))}}(),this.translate=(a=K(),s=K(),c=K(),function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0),"number"==typeof e&&(e=et(s,e,n,r)),lt(e,a)||(nt(c,u.getPosition(t),e),u.setPosition(t,c))}),this.setRotation=function(){var t=gt();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),yt(t,t),vt(a.localRotation,t,n),Mt(a.localRotation,a.localRotation),u.dirtifyLocal(e,a)}else u.setLocalRotation(e,n)}},this.displayObjectDependencyMap=new WeakMap,this.calcLocalTransform=function(){var t=b(),e=K(),n=Et(0,0,0,1);return function(r){if(0!==r.localSkew[0]||0!==r.localSkew[1]){if(z(r.localTransform,r.localRotation,r.localPosition,J(1,1,1),r.origin),0!==r.localSkew[0]||0!==r.localSkew[1]){var i=M(t);i[4]=Math.tan(r.localSkew[0]),i[1]=Math.tan(r.localSkew[1]),k(r.localTransform,r.localTransform,i)}var o=z(t,n,e,r.localScale,r.origin);k(r.localTransform,r.localTransform,o)}else z(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,Ct(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=Zr.ADDED);var s=t.transformable;s&&this.dirtifyWorld(t,s),s.frozen&&this.unfreezeParentToRoot(t),o&&t.dispatchEvent(es)},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=Zr.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=J(e,n,r));var i=t.transformable;bt(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,J(e[0],e[1],e[2]||1)),this.dirtifyLocal(t,n)},t.prototype.setLocalScale=function(t,e){var n=t.transformable,r=J(e[0],e[1],e[2]||n.localScale[2]);lt(r,n.localScale)||(tt(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 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=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;)Za(n),n=n.parentNode;e&&t.forEach((function(t){Za(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 Ka(qa.ATTR_MODIFIED,n,e,e,t,Ka.MODIFICATION,e,e)),n.isCustomElement&&n.isConnected&&n.attributeChangedCallback&&n.attributeChangedCallback(t,e,e)}))}))},t.prototype.getPosition=function(t){var e=t.transformable;return I(e.position,this.getWorldTransform(t,e))},t.prototype.getRotation=function(t){var e=t.transformable;return j(e.rotation,this.getWorldTransform(t,e))},t.prototype.getScale=function(t){var e=t.transformable;return L(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=I(K(),e),r=j(gt(),e),i=L(K(),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(dr.isEmpty(r))return null;var i=n||new dr;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 dr},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 dr).update(r.center,r.halfExtents))})),e){var a=ia(t);if(a){var s=a.parsedStyle.clipPath.getBounds(e);o?s&&(o=s.intersection(o)):o=s}}return o||(o=new dr),o&&(e?r.renderBounds=o:r.bounds=o),e?r.renderBoundsDirty=!1:r.boundsDirty=!1,o},t.prototype.getLocalBounds=function(t){if(t.parentNode){var e=b();t.parentNode.transformable&&(e=S(b(),this.getWorldTransform(t.parentNode)));var n=this.getBounds(t);if(!dr.isEmpty(n)){var r=new dr;return r.setFromTransformedAABB(n,e),r}}return this.getBounds(t)},t.prototype.getBoundingClientRect=function(t){var e,n,r,i=this.getGeometryBounds(t);dr.isEmpty(i)||(r=new dr).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 br(s+((null==o?void 0:o.left)||0),c+((null==o?void 0:o.top)||0),h-s,d-c)}return new br((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?k(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}(),rs={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]},is=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,os=new RegExp("".concat(/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/.source,"|").concat(/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹓﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/.source,"|").concat(/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/.source,"|").concat(/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/.source)),as=new RegExp("".concat(/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/.source,"|").concat(/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/.source,"|").concat(/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/.source,"|").concat(/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/.source)),ss=function(){function t(t){var e=this;this.runtime=t,this.fontMetricsCache={},this.shouldBreakByKinsokuShorui=function(t,n){return!e.isBreakingSpace(n)&&!(!t||!as.exec(n)&&!os.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=rs.MetricsString+rs.BaselineSymbol,a=Math.ceil(i.measureText(o).width),s=Math.ceil(i.measureText(rs.BaselineSymbol).width),c=rs.HeightMultiplier*s;s=s*rs.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=Vt(e)&&"".concat(e,"px")||"16px",s=n.split(","),c=s.length-1;c>=0;c--){var u=s[c].trim();!Sa.test(u)&&Na.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 E=o||p.fontSize+a,w=Math.max(E,p.fontSize+a)+(m.length-1)*(E+d),x=0;return"middle"===s?x=-w/2:"bottom"===s||"alphabetic"===s||"ideographic"===s?x=-w:"top"!==s&&"hanging"!==s||(x=0),{font:f,width:N,height:w,lines:m,lineWidths:v,lineHeight:E+=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 br(n-a/2,x+e*E,t+a,E)}))}}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),E=0;E<b.length;E++){var w=b[E],x=t[E-1],M=t[E+1],N=v(w);if(this.isNewline(w)){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,T=0,k=S,C=0;C<S;C++){var P=v(f[p][C]);if(T+P+y>h){k=C;break}T+=P}f[p]=(f[p]||"").slice(0,k)+d}break}if(g=0,f[++p]="",this.isBreakingSpace(w))continue;this.canBreakInLastChar(w)||(f=this.trimToBreakable(f),g=this.sumTextWidthByCache(f[p]||"",m)),this.shouldBreakByKinsokuShorui(w,M)&&(f=this.trimByKinsokuShorui(f),g+=v(x||""))}g+=N,f[p]=(f[p]||"")+w}}return f.join("\n")},t.prototype.isBreakingSpace=function(t){return"string"==typeof t&&rs.BreakingSpaces.indexOf(t.charCodeAt(0))>=0},t.prototype.isNewline=function(t){return"string"==typeof t&&rs.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||!is.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(!is.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}(),cs={},us=(Ja=new Da,ts=new _a,(Qa={})[Un.CIRCLE]=new Pa,Qa[Un.ELLIPSE]=new Aa,Qa[Un.RECT]=Ja,Qa[Un.IMAGE]=Ja,Qa[Un.GROUP]=Ja,Qa[Un.LINE]=new Oa,Qa[Un.TEXT]=new Ia(cs),Qa[Un.POLYLINE]=ts,Qa[Un.POLYGON]=ts,Qa[Un.PATH]=new Ra,Qa[Un.HTML]=null,Qa[Un.MESH]=null,Qa),ls=function(){var t,e=new Io,n=new zo;return(t={})[li.PERCENTAGE]=null,t[li.NUMBER]=new Ho,t[li.ANGLE]=new _o,t[li.DEFINED_PATH]=new Do,t[li.PAINT]=e,t[li.COLOR]=e,t[li.FILTER]=new Lo,t[li.LENGTH]=n,t[li.LENGTH_PERCENTAGE]=n,t[li.LENGTH_PERCENTAGE_12]=new Fo,t[li.LENGTH_PERCENTAGE_14]=new Bo,t[li.COORDINATE]=new Uo,t[li.OFFSET_DISTANCE]=new qo,t[li.OPACITY_VALUE]=new $o,t[li.PATH]=new Yo,t[li.LIST_OF_POINTS]=new Xo,t[li.SHADOW_BLUR]=new Ko,t[li.TEXT]=new Zo,t[li.TEXT_TRANSFORM]=new Qo,t[li.TRANSFORM]=new Ta,t[li.TRANSFORM_ORIGIN]=new ka,t[li.Z_INDEX]=new Ca,t[li.MARKER]=new Wo,t}();cs.CameraContribution=Pr,cs.AnimationTimeline=null,cs.EasingFunction=null,cs.offscreenCanvasCreator=new Ha,cs.sceneGraphSelector=new Xa,cs.sceneGraphService=new ns(cs),cs.textService=new ss(cs),cs.geometryUpdaterFactory=us,cs.CSSPropertySyntaxFactory=ls,cs.styleValueRegistry=new Ro(cs),cs.layoutRegistry=null,cs.globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},cs.enableCSSParsing=!0,cs.enableDataset=!1,cs.enableStyleSyntax=!0,cs.enableSizeAttenuation=!1;var hs=0,ds=new Ka(qa.INSERTED,null,"","","",0,"",""),fs=new Ka(qa.REMOVED,null,"","","",0,"",""),ps=new Ga(qa.DESTROY),gs=function(t){function e(){var e=t.apply(this,l([],u(arguments),!1))||this;return e.entity=hs++,e.renderable={bounds:void 0,boundsDirty:!0,renderBounds:void 0,renderBoundsDirty:!0,dirtyRenderBounds:void 0,dirty:!1},e.cullable={strategy:Kr.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=cs.enableCSSParsing?{anchor:ti,opacity:ti,fillOpacity:ti,strokeOpacity:ti,fill:ti,stroke:ti,transform:ti,transformOrigin:ti,visibility:ti,pointerEvents:ti,lineWidth:ti,lineCap:ti,lineJoin:ti,increasedLineWidthForHitTesting:ti,fontSize:ti,fontFamily:ti,fontStyle:ti,fontWeight:ti,fontVariant:ti,textAlign:ti,textBaseline:ti,textTransform:ti,zIndex:ti,filter:ti,shadowType:ti}: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(Er)},e.prototype.appendChild=function(t,e){var n;if(t.destroyed)throw new Error("Cannot append a destroyed element.");return cs.sceneGraphService.attach(t,this,e),(null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView)&&this.ownerDocument.defaultView.mountChildren(t),ds.relatedNode=this,t.dispatchEvent(ds),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 fs.relatedNode=this,t.dispatchEvent(fs),(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)&&t.ownerDocument.defaultView.unmountChildren(t),cs.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 cs.sceneGraphService.matches(t,this)},e.prototype.getElementById=function(t){return cs.sceneGraphService.querySelector("#".concat(t),this)},e.prototype.getElementsByName=function(t){return cs.sceneGraphService.querySelectorAll('[name="'.concat(t,'"]'),this)},e.prototype.getElementsByClassName=function(t){return cs.sceneGraphService.querySelectorAll(".".concat(t),this)},e.prototype.getElementsByTagName=function(t){return cs.sceneGraphService.querySelectorAll(t,this)},e.prototype.querySelector=function(t){return cs.sceneGraphService.querySelector(t,this)},e.prototype.querySelectorAll=function(t){return cs.sceneGraphService.querySelectorAll(t,this)},e.prototype.closest=function(t){var e=this;do{if(cs.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(ps),this.remove(),this.emitter.removeAllListeners(),this.destroyed=!0},e.prototype.getGeometryBounds=function(){return cs.sceneGraphService.getGeometryBounds(this)},e.prototype.getRenderBounds=function(){return cs.sceneGraphService.getBounds(this,!0)},e.prototype.getBounds=function(){return cs.sceneGraphService.getBounds(this)},e.prototype.getLocalBounds=function(){return cs.sceneGraphService.getLocalBounds(this)},e.prototype.getBoundingClientRect=function(){return cs.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 cs.enableCSSParsing?null:void 0;var e=this.attributes[t];if(void 0===e){var n=Hr(t);return e=this.attributes[n],cs.enableCSSParsing&&Ct(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(Er)},e.prototype.getAttributeNode=function(t){throw new Error(Er)},e.prototype.getAttributeNodeNS=function(t,e){throw new Error(Er)},e.prototype.hasAttributeNS=function(t,e){throw new Error(Er)},e.prototype.removeAttributeNS=function(t,e){throw new Error(Er)},e.prototype.removeAttributeNode=function(t){throw new Error(Er)},e.prototype.setAttributeNS=function(t,e,n){throw new Error(Er)},e.prototype.setAttributeNode=function(t){throw new Error(Er)},e.prototype.setAttributeNodeNS=function(t){throw new Error(Er)},e.prototype.toggleAttribute=function(t,e){throw new Error(Er)},e}(Ua);function ms(t){return!!(null==t?void 0:t.nodeName)}var vs,ys=new Ka(qa.ATTR_MODIFIED,null,null,null,null,Ka.MODIFICATION,null,null),bs={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:""},Es={anchor:[0,0],fill:oi,stroke:oi,transform:[],zIndex:0,filter:[],shadowType:"outer",miterLimit:10},ws=i(i({},Es),{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:"visible",pointerEvents:"auto",lineWidth:1,lineCap:"butt",lineJoin:"miter",increasedLineWidthForHitTesting:0,fillRule:"nonzero"}),xs=l(l([],u(["opacity","fillOpacity","strokeOpacity","transformOrigin","visibility","pointerEvents","lineWidth","lineCap","lineJoin","increasedLineWidthForHitTesting"]),!1),["fontSize","fontFamily","fontStyle","fontWeight","fontVariant","textAlign","textBaseline","textTransform"],!1),Ms="data-",Ns=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||Un.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,cs.enableCSSParsing?Es:ws,r.config.initialParsedStyle),cs.enableCSSParsing&&Object.assign(r.attributes,bs),r.initAttributes(r.config.style);var i=cs.globalThis.Proxy?cs.globalThis.Proxy:function(){};return cs.enableDataset&&(r.dataset=new i({},{get:function(t,e){var n="".concat(Ms).concat(Vr(e));return void 0!==t[n]?t[n]:r.getAttribute(n)},set:function(t,e,n){return r.setAttribute("".concat(Ms).concat(Vr(e)),n),!0}})),cs.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];ms(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};cs.enableCSSParsing&&(n.usedAttributes=xs);var r={};for(var i in t){r[Hr(i)]=t[i]}cs.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=Hr(e);Zt(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];cs.styleValueRegistry.processProperties(this,((r={})[t]=e,r),n),i.dirty=!0;var s=this.parsedStyle[t];this.isConnected&&(ys.relatedNode=this,ys.prevValue=o,ys.newValue=e,ys.attrName=t,ys.prevParsedValue=a,ys.newParsedValue=s,this.isMutationObserved?this.dispatchEvent(ys):(ys.target=this,this.ownerDocument.defaultView.dispatchEvent(ys,!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 br(n,r,o-n,a-r)},e.prototype.setOrigin=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),cs.sceneGraphService.setOrigin(this,Jn(t,e,n)),this},e.prototype.getOrigin=function(){return cs.sceneGraphService.getOrigin(this)},e.prototype.setPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),cs.sceneGraphService.setPosition(this,Jn(t,e,n)),this},e.prototype.setLocalPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),cs.sceneGraphService.setLocalPosition(this,Jn(t,e,n)),this},e.prototype.translate=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),cs.sceneGraphService.translate(this,Jn(t,e,n)),this},e.prototype.translateLocal=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),cs.sceneGraphService.translateLocal(this,Jn(t,e,n)),this},e.prototype.getPosition=function(){return cs.sceneGraphService.getPosition(this)},e.prototype.getLocalPosition=function(){return cs.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=Jn(t,e=e||t,n=n||t)),cs.sceneGraphService.scaleLocal(this,t),this},e.prototype.setLocalScale=function(t,e,n){return"number"==typeof t&&(t=Jn(t,e=e||t,n=n||t)),cs.sceneGraphService.setLocalScale(this,t),this},e.prototype.getLocalScale=function(){return cs.sceneGraphService.getLocalScale(this)},e.prototype.getScale=function(){return cs.sceneGraphService.getScale(this)},e.prototype.getEulerAngles=function(){return er(u(nr(K(),cs.sceneGraphService.getWorldTransform(this)),3)[2])},e.prototype.getLocalEulerAngles=function(){return er(u(nr(K(),cs.sceneGraphService.getLocalRotation(this)),3)[2])},e.prototype.setEulerAngles=function(t){return cs.sceneGraphService.setEulerAngles(this,0,0,t),this},e.prototype.setLocalEulerAngles=function(t){return cs.sceneGraphService.setLocalEulerAngles(this,0,0,t),this},e.prototype.rotateLocal=function(t,e,n){return Ct(e)&&Ct(n)?cs.sceneGraphService.rotateLocal(this,0,0,t):cs.sceneGraphService.rotateLocal(this,t,e,n),this},e.prototype.rotate=function(t,e,n){return Ct(e)&&Ct(n)?cs.sceneGraphService.rotate(this,0,0,t):cs.sceneGraphService.rotate(this,t,e,n),this},e.prototype.setRotation=function(t,e,n,r){return cs.sceneGraphService.setRotation(this,t,e,n,r),this},e.prototype.setLocalRotation=function(t,e,n,r){return cs.sceneGraphService.setLocalRotation(this,t,e,n,r),this},e.prototype.setLocalSkew=function(t,e){return cs.sceneGraphService.setLocalSkew(this,t,e),this},e.prototype.getRotation=function(){return cs.sceneGraphService.getRotation(this)},e.prototype.getLocalRotation=function(){return cs.sceneGraphService.getLocalRotation(this)},e.prototype.getLocalSkew=function(){return cs.sceneGraphService.getLocalSkew(this)},e.prototype.getLocalTransform=function(){return cs.sceneGraphService.getLocalTransform(this)},e.prototype.getWorldTransform=function(){return cs.sceneGraphService.getWorldTransform(this)},e.prototype.setLocalTransform=function(t){return cs.sceneGraphService.setLocalTransform(this,t),this},e.prototype.resetLocalTransform=function(){cs.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(I(K(),e),2),r=n[0],i=n[1],o=u(L(K(),e),2),a=o[0],s=o[1],c=j(gt(),e),l=u(nr(K(),c),3),h=l[0],d=l[2];return rr(h||d,r,i,a,s)},e.prototype.getLocalMatrix=function(){return this.getMatrix(this.getLocalTransform())},e.prototype.setMatrix=function(t){var e=u(ir(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(ir(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(){cs.enableCSSParsing?this.style.visibility="visible":this.forEach((function(t){t.style.visibility="visible"}))},e.prototype.hide=function(){cs.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}(gs),Ss=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.CIRCLE,style:cs.enableCSSParsing?i({cx:"",cy:"",r:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:cs.enableCSSParsing?null:[ui,ui]}},r))||this}return r(e,t),e}(Ns),Ts=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:cs.enableCSSParsing?i({x:"",y:""},r):i({},r)},a))||this).isCustomElement=!0,n}return r(e,t),e}(Ns),ks=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.ELLIPSE,style:cs.enableCSSParsing?i({cx:"",cy:"",rx:"",ry:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:cs.enableCSSParsing?null:[ui,ui]}},r))||this}return r(e,t),e}(Ns),Cs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.GROUP,style:cs.enableCSSParsing?i({x:"",y:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(Ns),Ps=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:Un.HTML,style:cs.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 br(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 dr,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=S(b(),this.parentNode.getWorldTransform()),e=this.getBounds();if(!dr.isEmpty(e)){var n=new dr;return n.setFromTransformedAABB(e,t),n}}return this.getBounds()},e}(Ns),As=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.IMAGE,style:cs.enableCSSParsing?i({x:"",y:"",img:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(Ns),Os=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:Un.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&&ms(c)&&(n.markerStartAngle=c.getLocalEulerAngles(),n.appendChild(c)),u&&ms(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&&ms(r)&&(this.markerStartAngle=0,r.remove()),i&&ms(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t&&(r&&ms(r)&&(this.markerEndAngle=0,r.remove()),i&&ms(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&&ms(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=On(r,i,o,a,t),l=u.x,h=u.y,d=ut(K(),J(l-s,h-c,0),e?this.getWorldTransform():this.getLocalTransform());return new yr(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 An(t.x1,t.y1,t.x2,t.y2)},e}(Ns),Rs=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:Un.PATH,style:cs.enableCSSParsing?i({path:"",miterLimit:""},r):i({},r),initialParsedStyle:cs.enableCSSParsing?null:{miterLimit:4,path:i({},hi)}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,c=s.markerStart,u=s.markerEnd,l=s.markerMid;return c&&ms(c)&&(n.markerStartAngle=c.getLocalEulerAngles(),n.appendChild(c)),l&&ms(l)&&n.placeMarkerMid(l),u&&ms(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&&ms(r)&&(this.markerStartAngle=0,r.remove()),i&&ms(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&ms(r)&&(this.markerEndAngle=0,r.remove()),i&&ms(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&&ms(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,E=u(this.getEndTangent(),2);y=E[0];f=(b=E[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&&ms(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 qi(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 Ge(t,e,i(i({},n),{bbox:!1,length:!0})).point}(n.path.absolutePath,t),s=a.x,c=a.y,u=ut(K(),J(s-r,c-o,0),e?this.getWorldTransform():this.getLocalTransform());return new yr(u[0],u[1])},e.prototype.getPoint=function(t,e){return void 0===e&&(e=!1),this.getPointAtLength(t*qi(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}(Ns),_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:Un.POLYGON,style:cs.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!0},r):i({},r),initialParsedStyle:cs.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&&ms(c)&&(n.markerStartAngle=c.getLocalEulerAngles(),n.appendChild(c)),l&&ms(l)&&n.placeMarkerMid(l),u&&ms(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&&ms(r)&&(this.markerStartAngle=0,r.remove()),i&&ms(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&ms(r)&&(this.markerEndAngle=0,r.remove()),i&&ms(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&&ms(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&&ms(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}(Ns),Ds=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.POLYLINE,style:cs.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!1},n):i({},n),initialParsedStyle:cs.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=On(a[u][0],a[u][1],a[u+1][0],a[u+1][1],c),h=l.x,d=l.y,f=ut(K(),J(h-r,d-i,0),e?this.getWorldTransform():this.getLocalTransform());return new yr(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}(_s),Is=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.RECT,style:cs.enableCSSParsing?i({x:"",y:"",width:"",height:"",radius:""},n):i({},n)},r))||this}return r(e,t),e}(Ns),Ls=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:Un.TEXT,style:cs.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:cs.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}(Ns),js=function(){function t(){this.registry={},this.define(Un.CIRCLE,Ss),this.define(Un.ELLIPSE,ks),this.define(Un.RECT,Is),this.define(Un.IMAGE,As),this.define(Un.LINE,Os),this.define(Un.GROUP,Cs),this.define(Un.PATH,Rs),this.define(Un.POLYGON,_s),this.define(Un.POLYLINE,Ds),this.define(Un.TEXT,Ls),this.define(Un.HTML,Ps)}return t.prototype.define=function(t,e){this.registry[t]=e},t.prototype.get=function(t){return this.registry[t]},t}(),zs=function(t){function e(){var e=t.call(this)||this;e.defaultView=null,e.ownerDocument=null,e.nodeName="document";try{e.timeline=new cs.AnimationTimeline(e)}catch(t){}var n={};return Co.forEach((function(t){var e=t.n,r=t.inh,i=t.d;r&&i&&(n[e]=Ur(i)?i(Un.GROUP):i)})),e.documentElement=new Cs({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?Ls:Cs);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(Er)},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(wr)},e.prototype.insertBefore=function(t,e){throw new Error(wr)},e.prototype.removeChild=function(t,e){throw new Error(wr)},e.prototype.replaceChild=function(t,e,n){throw new Error(wr)},e.prototype.append=function(){throw new Error(wr)},e.prototype.prepend=function(){throw new Error(wr)},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}(Ua),Fs=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 Ga(qa.CULLED)),null)}return t})),r.hooks.afterRender.tap(t.tag,(function(t){t.cullable.visibilityPlaneMask=-1}))},t.tag="Culling",t}(),Bs=function(){function t(){var t=this;this.autoPreventDefault=!1,this.rootPointerEvent=new Fa(null),this.rootWheelEvent=new Ba(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="outside";try{a=o&&t.target&&t.target!==o&&o.contains&&!o.contains(t.target)?"outside":""}catch(t){}var 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||Ct(r)||Ct(i)){var s=this.context.eventService.client2Viewport(new yr(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=aa[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=sa.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];Zt(i.button)&&(i.button=0),Zt(i.buttons)&&(i.buttons=1),Zt(i.isPrimary)&&(i.isPrimary=1===t.touches.length&&"touchstart"===t.type),Zt(i.width)&&(i.width=i.radiusX||1),Zt(i.height)&&(i.height=i.radiusY||1),Zt(i.tiltX)&&(i.tiltX=0),Zt(i.tiltY)&&(i.tiltY=0),Zt(i.pointerType)&&(i.pointerType="touch"),Zt(i.pointerId)&&(i.pointerId=i.identifier||0),Zt(i.pressure)&&(i.pressure=i.force||.5),Zt(i.twist)&&(i.twist=0),Zt(i.tangentialPressure)&&(i.tangentialPressure=0),i.isNormalized=!0,i.type=t.type,n.push(i)}else if(e.isMouseEvent(t)){var o=t;Zt(o.isPrimary)&&(o.isPrimary=!0),Zt(o.width)&&(o.width=1),Zt(o.height)&&(o.height=1),Zt(o.tiltX)&&(o.tiltX=0),Zt(o.tiltY)&&(o.tiltY=0),Zt(o.pointerType)&&(o.pointerType="mouse"),Zt(o.pointerId)&&(o.pointerId=1),Zt(o.pressure)&&(o.pressure=.5),Zt(o.twist)&&(o.twist=0),Zt(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,n.push(o)}else n.push(t);return n},t.tag="Event",t}(),Gs=[Un.CIRCLE,Un.ELLIPSE,Un.IMAGE,Un.RECT,Un.LINE,Un.POLYLINE,Un.POLYGON,Un.TEXT,Un.PATH,Un.HTML],Vs=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(dr.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||hr.INDETERMINATE,a.planes),i.visible=i.visibilityPlaneMask!==hr.OUTSIDE,i.visible},t.prototype.computeVisibilityWithPlaneMask=function(t,e,n,r){if(n===hr.OUTSIDE||n===hr.INSIDE)return n;for(var i=hr.INSIDE,o=Gs.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(at(l,e.getPositiveFarPoint(r[a]))+h<0)return hr.OUTSIDE;at(l,e.getNegativeFarPoint(r[a]))+h<0&&(i|=c)}}return i},t}(),Us=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;cs.enableSizeAttenuation&&cs.styleValueRegistry.updateSizeAttenuation(e,a.getCamera().getZoom()),cs.enableCSSParsing&&cs.styleValueRegistry.recalc(e),cs.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),cs.sceneGraphService.dirtifyToRoot(e),r.dirtify()};r.hooks.init.tap(t.tag,(function(){a.addEventListener(qa.MOUNTED,u),a.addEventListener(qa.UNMOUNTED,l),a.addEventListener(qa.ATTR_MODIFIED,s),a.addEventListener(qa.BOUNDS_CHANGED,c)})),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener(qa.MOUNTED,u),a.removeEventListener(qa.UNMOUNTED,l),a.removeEventListener(qa.ATTR_MODIFIED,s),a.removeEventListener(qa.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"}(vs||(vs={}));var Ws=new Ga(qa.MOUNTED),Hs=new Ga(qa.UNMOUNTED),qs=new Ga(vs.BEFORE_RENDER),$s=new Ga(vs.RERENDER),Ys=new Ga(vs.AFTER_RENDER),Xs=function(t){function e(e){var n=t.call(this)||this;n.Element=Ns,n.inited=!1,n.context={},n.document=new zs,n.document.defaultView=n,n.customElements=new js;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,E=e.useNativeClickEvent,w=e.alwaysTriggerPointerEventOnCanvas,x=e.isTouchEvent,M=e.isMouseEvent;b||function(t,e){if(t){var n="string"==typeof t?t:t.id||ta++;Jo[n]&&Jo[n].destroy(),Jo[n]=e}}(r,n);var N=a,S=s,T=c;return i&&(T=(T=c||ea&&window.devicePixelRatio||1)>=1?Math.ceil(T):1,N=a||function(t){var e=oa(t,"width");return"auto"===e?t.offsetWidth:parseFloat(e)}(i)||i.width/T,S=s||function(t){var e=oa(t,"height");return"auto"===e?t.offsetHeight:parseFloat(e)}(i)||i.height/T),o&&(cs.offscreenCanvas=o),n.devicePixelRatio=T,n.requestAnimationFrame=null!=f?f:ya.bind(cs.globalThis),n.cancelAnimationFrame=null!=p?p:ba.bind(cs.globalThis),n.supportsTouchEvents=null!=v?v:"ontouchstart"in cs.globalThis,n.supportsPointerEvents=null!=m?m:!!cs.globalThis.PointerEvent,n.isTouchEvent=null!=x?x:function(t){return n.supportsTouchEvents&&t instanceof cs.globalThis.TouchEvent},n.isMouseEvent=null!=M?M:function(t){return!cs.globalThis.MouseEvent||t instanceof cs.globalThis.MouseEvent&&(!n.supportsPointerEvents||!(t instanceof cs.globalThis.PointerEvent))},n.initRenderingContext({container:r,canvas:i,width:N,height:S,renderer:u,offscreenCanvas:o,devicePixelRatio:T,cursor:h||"default",background:l||"transparent",createImage:g,document:d,supportsCSSTransform:y,useNativeClickEvent:E,alwaysTriggerPointerEventOnCanvas:w}),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 cs.CameraContribution;i.clipSpaceNearZ=n,i.setType(pr.EXPLORING,gr.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(kr,(function(){r.context.renderingContext.renderReasons.add(La.CAMERA_CHANGED),cs.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){cs.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 Ga(vs.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 Ga(vs.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===mr.ORTHOGRAPHIC?r.setOrthographic(t/-2,t/2,e/2,e/-2,r.getNear(),r.getFar()):r.setAspect(t/e),this.dispatchEvent(new Ga(vs.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(qs),this.getRenderingService().render(this.getConfig(),(function(){t.dispatchEvent($s)})),this.dispatchEvent(Ys)},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 Hn,this.context.renderingPlugins=[],this.context.renderingPlugins.push(new Bs,new Us,new Fs([new Vs])),this.loadRendererContainerModule(t),this.context.contextService=new this.context.ContextService(i(i({},cs),this.context)),this.context.renderingService=new $a(cs,this.context),this.context.eventService=new Wa(cs,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 Ga(vs.READY))})):r.dispatchEvent(new Ga(vs.READY)),r.readyPromise&&r.resolveReadyPromise()):r.dispatchEvent(new Ga(vs.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(cs)}))},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(cs)})),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(Hs):(Hs.target=t,this.dispatchEvent(Hs,!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(Ws):(Ws.target=t,this.dispatchEvent(Ws,!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}(Va),Ks=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=Qn(e),this.relAzimuth=Qn(t),this.relRoll=Qn(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===pr.EXPLORING){var r=mt(gt(),[1,0,0],tr((this.rotateWorld?1:-1)*this.relElevation)),i=mt(gt(),[0,1,0],tr((this.rotateWorld?1:-1)*this.relAzimuth)),o=mt(gt(),[0,0,1],tr(this.relRoll)),a=vt(gt(),i,r);a=vt(gt(),a,o);var s=F(b(),a);C(this.matrix,this.matrix,[0,0,-this.distance]),k(this.matrix,this.matrix,s),C(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===pr.ORBITING||this.type===pr.EXPLORING?this._getPosition():this.type===pr.TRACKING&&this._getFocalPoint(),this._update(),this},e.prototype.pan=function(t,e){var n=Jn(t,e,0),r=Z(this.position);return nt(r,r,it(K(),this.right,n[0])),nt(r,r,it(K(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this},e.prototype.dolly=function(t){var e=this.forward,n=Z(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===pr.ORBITING||this.type===pr.EXPLORING?this._getDistance():this.type===pr.TRACKING&&nt(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 cs.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:Z(d.right),up:Z(d.up),forward:Z(d.forward),position:Z(d.getPosition()),focalPoint:Z(d.getFocalPoint()),distanceVector:Z(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=zt(t)?this.landmarks.find((function(e){return e.name===t})):t;if(r){var i=Vt(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,E=l||cs.EasingFunction(a),w=function(){n.setFocalPoint(v),n.setPosition(m),n.setRoll(b),n.setZoom(y),n.computeMatrix(),n.triggerUpdate(),d&&d()},x=function(t){void 0===g&&(g=t);var e=t-g;if(e>c)w();else{var r,i,o=E(e/c),a=K(),s=K();ct(a,n.focalPoint,v,o),ct(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),ht(a,v)+ht(s,m)<=.01&&null==y&&null==b?w():(n.computeMatrix(),n.triggerUpdate(),e<c&&(p&&p(o),n.landmarkAnimationID=n.canvas.requestAnimationFrame(x)))}};this.canvas.requestAnimationFrame(x)}},e.prototype.syncFromLandmark=function(t){this.matrix=w(this.matrix,t.matrix),this.right=tt(this.right,t.right),this.up=tt(this.up,t.up),this.forward=tt(this.forward,t.forward),this.position=tt(this.position,t.position),this.focalPoint=tt(this.focalPoint,t.focalPoint),this.distanceVector=tt(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}(Pr);cs.CameraContribution=Ks;var Zs=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}(ja),Qs=0,Js=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(Qs++),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 Zs(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(Er)},t.prototype.addEventListener=function(t,e,n){throw new Error(Er)},t.prototype.removeEventListener=function(t,e,n){throw new Error(Er)},t.prototype.dispatchEvent=function(t){throw new Error(Er)},t.prototype.commitStyles=function(){throw new Error(Er)},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 Zs(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 Zs(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}},t}(),tc=.1,ec="function"==typeof Float32Array,nc=function(t,e){return 1-3*e+3*t},rc=function(t,e){return 3*e-6*t},ic=function(t){return 3*t},oc=function(t,e,n){return((nc(e,n)*t+rc(e,n))*t+ic(e))*t},ac=function(t,e,n){return 3*nc(e,n)*t*t+2*rc(e,n)*t+ic(e)},sc=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=ec?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=oc(o*tc,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=tc;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*tc,s=ac(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=ac(e,n,r);if(0===o)return e;e-=(oc(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=oc(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+tc,t,n)};return function(t){return 0===t||1===t?t:oc(a(t),e,r)}},cc=function(t){return Math.pow(t,2)},uc=function(t){return Math.pow(t,3)},lc=function(t){return Math.pow(t,4)},hc=function(t){return Math.pow(t,5)},dc=function(t){return Math.pow(t,6)},fc=function(t){return 1-Math.cos(t*Math.PI/2)},pc=function(t){return 1-Math.sqrt(1-t*t)},gc=function(t){return t*t*(3*t-2)},mc=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)},vc=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=Gt(Number(i),1,10),c=Gt(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)},yc=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=Gt(o,.1,1e3),s=Gt(s,.1,1e3),l=Gt(l,.1,1e3),d=Gt(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},bc=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)(Gt(t,0,1)*i)/i},Ec=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 sc(r,i,o,a)(t)},wc=sc(.42,0,1,1),xc=function(t){return function(e,n,r){return void 0===n&&(n=[]),1-t(1-e,n,r)}},Mc=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}},Nc=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}},Sc={steps:bc,"step-start":function(t){return bc(t,[1,"start"])},"step-end":function(t){return bc(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Ec,ease:function(t){return Ec(t,[.25,.1,.25,1])},in:wc,out:xc(wc),"in-out":Mc(wc),"out-in":Nc(wc),"in-quad":cc,"out-quad":xc(cc),"in-out-quad":Mc(cc),"out-in-quad":Nc(cc),"in-cubic":uc,"out-cubic":xc(uc),"in-out-cubic":Mc(uc),"out-in-cubic":Nc(uc),"in-quart":lc,"out-quart":xc(lc),"in-out-quart":Mc(lc),"out-in-quart":Nc(lc),"in-quint":hc,"out-quint":xc(hc),"in-out-quint":Mc(hc),"out-in-quint":Nc(hc),"in-expo":dc,"out-expo":xc(dc),"in-out-expo":Mc(dc),"out-in-expo":Nc(dc),"in-sine":fc,"out-sine":xc(fc),"in-out-sine":Mc(fc),"out-in-sine":Nc(fc),"in-circ":pc,"out-circ":xc(pc),"in-out-circ":Mc(pc),"out-in-circ":Nc(pc),"in-back":gc,"out-back":xc(gc),"in-out-back":Mc(gc),"out-in-back":Nc(gc),"in-bounce":mc,"out-bounce":xc(mc),"in-out-bounce":Mc(mc),"out-in-bounce":Nc(mc),"in-elastic":vc,"out-elastic":xc(vc),"in-out-elastic":Mc(vc),"out-in-elastic":Nc(vc),spring:yc,"spring-in":yc,"spring-out":xc(yc),"spring-in-out":Mc(yc),"spring-out-in":Nc(yc)},Tc=function(t){return Sc[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)]||Sc.linear},kc=function(t){return t},Cc=1,Pc=.5,Ac=0;function Oc(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Rc="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",_c=new RegExp("cubic-bezier\\("+Rc+","+Rc+","+Rc+","+Rc+"\\)"),Dc=/steps\(\s*(\d+)\s*\)/,Ic=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Lc(t){var e=_c.exec(t);if(e)return sc.apply(void 0,l([],u(e.slice(1).map(Number)),!1));var n=Dc.exec(t);if(n)return Oc(Number(n[1]),Ac);var r=Ic.exec(t);return r?Oc(Number(r[1]),{start:Cc,middle:Pc,end:Ac}[r[2]]):Tc(t)}function jc(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 zc=0,Fc=1,Bc=2,Gc=3;function Vc(t,e,n){var r=function(t,e,n){if(null===e)return zc;var r=n.endTime;return e<Math.min(n.delay,r)?Fc:e>=Math.min(n.delay+t+n.endDelay,r)?Bc:Gc}(t,e,n),i=function(t,e,n,r,i){switch(r){case Fc:return"backwards"===e||"both"===e?0:null;case Gc:return n-i;case Bc:return"forwards"===e||"both"===e?t:null;case zc: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!==Fc&&(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!==Bc||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===Bc&&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 Uc(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Wc(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Lc(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:qc(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)Wc(n)&&t.setAttribute(n,null)}}function Wc(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Hc=function(t,e,n){return function(r){var i=$c(t,e,r);return!cs.enableCSSParsing&&Vt(i)?i:n(i)}};function qc(t,e,n,r){var i=Ao[t];if(i&&i.syntax&&i.int){var o=cs.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=void 0,s=void 0;if(cs.enableCSSParsing){var c=cs.styleValueRegistry.parseProperty(t,e,r,!1),h=cs.styleValueRegistry.parseProperty(t,n,r,!1);a=cs.styleValueRegistry.computeProperty(t,c,r,!1),s=cs.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=Hc.apply(void 0,l([],u(f),!1));return function(t){return 0===t?e:1===t?n:p(t)}}}}return Hc(!1,!0,(function(t){return t?n:e}))}function $c(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($c(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments "+t+":"+e)}var Yc=function(){function t(){this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=kc,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=Lc(t),this._easing=t},enumerable:!1,configurable:!0}),t}();function Xc(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(Ct(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(!Ct(s)&&!Ct(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 Kc="backwards|forwards|both|none".split("|"),Zc="reverse|alternate|alternate-reverse".split("|");function Qc(t,e){return function(t,e){var n=new Yc;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===Kc.indexOf(t[e]))return;if("direction"===e&&-1===Zc.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 Jc=function(){function t(t,e,n){var r=this;this.composite="replace",this.iterationComposite="replace",this.target=t,this.timing=Qc(n,!1),this.timing.effect=this,this.timing.activeDuration=jc(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=Xc(e,this.timing),this.interpolations=Uc(this.normalizedKeyframes,this.timing,this.target);var i=cs.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=Vc(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)},t.prototype.getKeyframes=function(){return this.normalizedKeyframes},t.prototype.setKeyframes=function(t){this.normalizedKeyframes=Xc(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 tu(t,e){return Number(t.id)-Number(e.id)}var eu=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(tu),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 Jc(t,e,n),i=new Js(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(tu),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}();cs.EasingFunction=Lc,cs.AnimationTimeline=eu;const nu={duration:500},ru={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var iu,ou,au,su,cu,uu,lu,hu;!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"}(iu||(iu={})),function(t){t.DRAW="draw",t.TRANSFORM="transform",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(ou||(ou={})),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,(au=t.NodeEvent||(t.NodeEvent={})).CLICK="click",au.DBLCLICK="dblclick",au.POINTER_OVER="pointerover",au.POINTER_LEAVE="pointerleave",au.POINTER_ENTER="pointerenter",au.POINTER_MOVE="pointermove",au.POINTER_OUT="pointerout",au.POINTER_DOWN="pointerdown",au.POINTER_UP="pointerup",au.CONTEXT_MENU="contextmenu",au.DRAG_START="dragstart",au.DRAG="drag",au.DRAG_END="dragend",au.DRAG_ENTER="dragenter",au.DRAG_OVER="dragover",au.DRAG_LEAVE="dragleave",au.DROP="drop",t.CommonEvent=void 0,(su=t.CommonEvent||(t.CommonEvent={})).CLICK="click",su.DBLCLICK="dblclick",su.POINTER_OVER="pointerover",su.POINTER_LEAVE="pointerleave",su.POINTER_ENTER="pointerenter",su.POINTER_MOVE="pointermove",su.POINTER_OUT="pointerout",su.POINTER_DOWN="pointerdown",su.POINTER_UP="pointerup",su.CONTEXT_MENU="contextmenu",su.DRAG_START="dragstart",su.DRAG="drag",su.DRAG_END="dragend",su.DRAG_ENTER="dragenter",su.DRAG_OVER="dragover",su.DRAG_LEAVE="dragleave",su.DROP="drop",su.KEY_DOWN="keydown",su.KEY_UP="keyup",su.WHEEL="wheel",t.ContainerEvent=void 0,(cu=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",cu.KEY_UP="keyup",t.EdgeEvent=void 0,(uu=t.EdgeEvent||(t.EdgeEvent={})).CLICK="click",uu.DBLCLICK="dblclick",uu.POINTER_OVER="pointerover",uu.POINTER_LEAVE="pointerleave",uu.POINTER_ENTER="pointerenter",uu.POINTER_MOVE="pointermove",uu.POINTER_OUT="pointerout",uu.POINTER_DOWN="pointerdown",uu.POINTER_UP="pointerup",uu.CONTEXT_MENU="contextmenu",uu.DRAG_ENTER="dragenter",uu.DRAG_OVER="dragover",uu.DRAG_LEAVE="dragleave",uu.DROP="drop",t.GraphEvent=void 0,(lu=t.GraphEvent||(t.GraphEvent={})).BEFORE_SIZE_CHANGE="beforesizechange",lu.AFTER_SIZE_CHANGE="aftersizechange",lu.BEFORE_ELEMENT_CREATE="beforeelementcreate",lu.AFTER_ELEMENT_CREATE="afterelementcreate",lu.BEFORE_ELEMENT_UPDATE="beforeelementupdate",lu.AFTER_ELEMENT_UPDATE="afterelementupdate",lu.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",lu.AFTER_ELEMENT_DESTROY="afterelementdestroy",lu.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",lu.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",lu.BEFORE_DRAW="beforedraw",lu.AFTER_DRAW="afterdraw",lu.BEFORE_RENDER="beforerender",lu.AFTER_RENDER="afterrender",lu.BEFORE_ANIMATE="beforeanimate",lu.AFTER_ANIMATE="afteranimate",lu.BEFORE_LAYOUT="beforelayout",lu.AFTER_LAYOUT="afterlayout",lu.BEFORE_TRANSFORM="beforetransform",lu.AFTER_TRANSFORM="aftertransform",lu.BEFORE_ELEMENT_VISIBILITY_CHANGE="beforeelementvisibilitychange",lu.AFTER_ELEMENT_VISIBILITY_CHANGE="afterelementvisibilitychange",lu.BEFORE_ELEMENT_Z_INDEX_CHANGE="beforeelementzindexchange",lu.AFTER_ELEMENT_Z_INDEX_CHANGE="afterelementzindexchange",lu.BEFORE_ELEMENT_STATE_CHANGE="beforeelementstatechange",lu.AFTER_ELEMENT_STATE_CHANGE="afterelementstatechange",function(t){t.DRAW="draw",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(hu||(hu={}));const du="combo",fu="tree";function pu(t){return"source"in t&&"target"in t}function gu(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function mu(t,e,n){return t>=e&&t<=n}function vu(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 yu(t){return t.max[0]-t.min[0]}function bu(t){return t.max[1]-t.min[1]}function Eu(t){return[yu(t),bu(t)]}function wu(t,e){const n=gu(t)?function(t){const[e,n,r=0]=t,i=new dr;return i.setMinMax([e,n,r],[e,n,r]),i}(t):t.getKey().getBounds();return e?xu(n,e):n}function xu(t,e){const[n,r,i,o]=vu(e),[a,s,c]=t.min,[u,l,h]=t.max,d=new dr;return d.setMinMax([a-o,s-n,c],[u+r,l+i,h]),d}function Mu(t){if(0===t.length)return new dr;if(1===t.length)return t[0];const e=new dr;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 Nu(t,e){return mu(t[0],e.min[0],e.max[0])&&mu(t[1],e.min[1],e.max[1])}function Su(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 Tu(t,e){const n=Qt(e);if(Nu(e,t)){switch(Su(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]=mu(r,o,s)?r:r<o?o:s,n[1]=mu(i,a,c)?i:i<a?a:c}return n}function ku(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Cu(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 Pu(t,e="center"){const n=function(t){if(Array.isArray(t))return mu(t[0],0,1)&&mu(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 Cu(t,n)}function Au(t,e){const n=function(t){const e="string"==typeof t?t.split(" ").map((t=>parseFloat(t))):t.slice(0,2);return mu(e[0],0,1)&&mu(e[1],0,1)?e:[.5,.5]}(e);return Cu(t,n)}function Ou(t=0){if(Vt(t))return Array(3).fill(t);const[e,n=e,r=e]=t;return[e,n,r]}function Ru(t,e,n){if(Array.isArray(t))return t;const[r,i]=Ou(n),[o,a]=Ou(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 _u(t,e,n){if(Array.isArray(t))return t;const r=Ou(n)[0],i=r/2,o=Ou(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 Du(t,e,n,r,i=Ru){const o=i(t,n,r),[a,s]=Ou(r),c=new dr;return c.setMinMax([e[0]-a/2,e[1]-s/2,0],[e[0]+a/2,e[1]+s/2,0]),Au(c,o)}function Iu(t){if(zt(t.id)||Vt(t.id))return t.id;if(pu(t))return`${t.source}-${t.target}`;throw new Error("The data does not have available id.")}function Lu(t){return t.style?.parentId}function ju(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function zu(t,e){return Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||ju(n,e)&&(t[function(t,e,n=!0){if(!e)return t;if(!ju(t,e))return t;const r=t.slice(e.length);return n?$t(r):r}(n,e)]=r),t)),{})}function Fu(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 Bu(t,e){const n=zt(e)?[e]:e;return Object.entries(t).reduce(((t,[e,r])=>(n.find((t=>e.startsWith(t)))||(t[e]=r),t)),{})}const Gu=[0,0,0];function Vu(t,e){return t.map(((t,n)=>t+e[n]))}function Uu(t,e){return t.map(((t,n)=>t-e[n]))}function Wu(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Hu(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function qu(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+(n-e[r]||0)**2),0))}function $u(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Yu(t){const e=t.reduce(((t,e)=>t+e**2),0);return t.map((t=>t/Math.sqrt(e)))}function Xu(t){return 2===t.length?[t[0],t[1],0]:t}function Ku(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 Zu(t){return[t.x,t.y]}function Qu(t){return{x:t[0],y:t[1]}}function Ju(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function tl(t,e,n,r=!1){const i=Yu(r?Uu(t,e):Uu(e,t)),o=[i[0]*n,i[1]*n];return Vu(function(t){return[t[0],t[1]]}(t),o)}function el(t,e){return t[1]===e[1]}function nl(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=Xu(t),r=Xu(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]]}(Uu(n,r),Uu(i,o)).every((t=>0===t))}function rl(t,e){if(nl(t,e))return;const[n,r]=t,[i,o]=e,a=((n[0]-i[0])*(i[1]-o[1])-(n[1]-i[1])*(i[0]-o[0]))/((n[0]-r[0])*(i[1]-o[1])-(n[1]-r[1])*(i[0]-o[0])),s=o[0]-i[0]?(n[0]-i[0]+a*(r[0]-n[0]))/(o[0]-i[0]):(n[1]-i[1]+a*(r[1]-n[1]))/(o[1]-i[1]);return mu(a,0,1)&&mu(s,0,1)?[n[0]+a*(r[0]-n[0]),n[1]+a*(r[1]-n[1])]:void 0}function il(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=Vu(e,o),a=Vu(e,a));const s=rl([e,t],[o,a]);if(s)return s}return e}function ol(t,e){const n=e.center,r=Uu(t,e.center),i=Math.atan2(r[1],r[0]);if(isNaN(i))return n;const o=yu(e)/2,a=bu(e)/2;return[n[0]+o*Math.cos(i),n[1]+a*Math.sin(i)]}function al(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 sl(t,e,n=1,r=!1){const i=r?n:1;return al((t.max[0]-t.min[0])*i,e)}const cl="cachedStyle",ul=t=>`__${t}__`;function ll(t,e){const n=Array.isArray(e)?e:[e];oe(t,cl)||ae(t,cl,{}),n.forEach((e=>{ae(oe(t,cl),ul(e),t.attributes[e])}))}function hl(t,e){return oe(t,[cl,ul(e)])}function dl(t,e){return ul(e)in(oe(t,cl)||{})}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 pl="visibility";class gl extends Ts{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(ee({},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(bh(r),e);a&&n.push(a)}}))}return yh(n)}setVisibility(){const{visibility:t}=this.attributes;!function(t,e){[t,...fl(t)].forEach((n=>{dl(n,pl)||ll(n,pl);const r=hl(n,pl);t!==n&&"hidden"===r||(n.style.visibility=e)}))}(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}class ml extends gl{static defaultStyleProps={padding:0,fontSize:12,wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};constructor(t){super(ee({},{style:ml.defaultStyleProps},t))}isTextStyle(t){return ju(t,"label")}isBackgroundStyle(t){return ju(t,"background")}getTextStyle(t){const{padding:e,...n}=this.getGraphicStyle(t);return Bu(n,"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=zu(e,"background"),{min:[a,s],halfExtents:[c,u]}=this.shapeMap.text.getGeometryBounds(),[l,h,d,f]=vu(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",Ls,this.getTextStyle(t),e),this.upsert("background",Is,this.getBackgroundStyle(t),e)}}class vl extends gl{static defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};constructor(t){super(ee({},{style:vl.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",ml,this.getBadgeStyle(t),e)}connectedCallback(){this.upsert("label",ml,this.getBadgeStyle(this.parsedAttributes),this)}}class yl extends gl{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()?As:Ls,this.getIconStyle(t),e)}connectedCallback(){this.upsert("icon",this.isGImage()?As:Ls,this.getIconStyle(this.attributes),this)}}class bl extends gl{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(ee({},{style:bl.defaultStyleProps},t))}getSize(t=this.parsedAttributes){const{size:e}=t;return Ou(e)}getKeyStyle(t){const{color:e,fill:n,...r}=this.getGraphicStyle(t);return Object.assign({fill:e||n},Bu(r,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||re(t.labelText))return!1;const{placement:e,maxWidth:n,...r}=zu(this.getGraphicStyle(t),"label"),i=this.getKey().getLocalBounds();return Object.assign(mh(i,e),{wordWrapWidth:sl(i,n)},r)}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,...n}=this.getKeyStyle(t);return{...n,stroke:e,...zu(this.getGraphicStyle(t),"halo")}}getIconStyle(t){if(!1===t.icon||re(t.iconText||t.iconSrc))return!1;const e=zu(this.getGraphicStyle(t),"icon"),n=this.getKey(),[r,i]=Pu(n.getLocalBounds(),"center");return{x:r,y:i,...e}}getBadgesStyle(t){const e=Fu(this.shapeMap,"badge-"),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.badge||re(t.badges))return n;const{badges:r=[],badgePalette:i,...o}=t,a=function(t){const e=zt(t)?lI("palette",t):t;if(!kt(e))return e}(i),s=zu(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{...mh(e.getLocalBounds(),n,!0),...r}}getPortsStyle(t){const e=this.getPorts(),n={};if(Object.keys(e).forEach((t=>{n[t]=!1})),!1===t.port||re(t.ports))return n;const r=zu(this.getGraphicStyle(t),"port"),{ports:i=[]}=t;return i.forEach(((e,i)=>{const o=e.key||i,a={...r,...e};if(uh(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 sh(this.getKey().getLocalBounds(),n)}getKey(){return this.shapeMap.key}getPorts(){return Fu(this.shapeMap,"port-")}getCenter(){return this.getKey().getBounds().center}getIntersectPoint(t){const e=this.getKey().getBounds();return il(t,Pu(n=e,"center"),[Pu(n,"left-top"),Pu(n,"right-top"),Pu(n,"right-bottom"),Pu(n,"left-bottom")],!1);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}`,vl,n[t],e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{this.upsert(`port-${t}`,Ss,n[t],e)}))}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawHaloShape(t,e),this.upsert("icon",yl,this.getIconStyle(t),e),this.drawBadgeShapes(t,e),this.upsert("label",ml,this.getLabelStyle(t),e),this.drawPortShapes(t,e))}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawBadgeShapes(this.parsedAttributes,this)}),n}}const El=.8,wl=["node","edge","combo"];class xl extends bl{static defaultStyleProps={size:24};constructor(t){super(ee({},{style:xl.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ss,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*El;return!!e&&{width:r,height:r,...e}}getIntersectPoint(t){return ol(t,this.getKey().getBounds())}}class Ml extends bl{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",_s,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),points:this.getPoints(t)}}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return il(t,[+(this.attributes?.x||0),+(this.attributes?.y||0)],e)}}class Nl extends bl{static defaultStyleProps={size:[80,40]};constructor(t){super(ee({},{style:Nl.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",ks,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)*El;return!!e&&{width:i,height:i,...e}}getIntersectPoint(t){return ol(t,this.getKey().getBounds())}}class Sl extends bl{static defaultStyleProps={size:[48,24],anchor:[.5,.5]};constructor(t){super(ee({},{style:Sl.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*El,height:r*El,...e}}drawKeyShape(t,e){return this.upsert("key",Is,this.getKeyStyle(t),e)}}class Tl extends Ml{static defaultStyleProps={size:40,direction:"up"};constructor(t){super(ee({},{style:Tl.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 sh(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||re(n||r))return!1;const o=zu(this.getGraphicStyle(t),"icon"),a=this.getKey().getLocalBounds(),[s,c]=function(t,e){const{center:n}=t,[r,i]=Eu(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]=Eu(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)*El;return{x:s,y:c,width:u,height:u,...o}}}class kl extends bl{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(ee({},{style:kl.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 Hu(o.reduce(((t,e)=>Vu(t,ku(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 Du(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]=vu(e);return Vu(Ou(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Ou(t.collapsedSize)}getExpandedKeySize(t){if(!re(t.size))return Ou(t.size);const e=this.getContentBBox(t);return[yu(e),bu(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=Mu(e.map((t=>t.getBounds())));return n?xu(r,n):r}drawCollapsedMarkerShape(t,e){this.upsert("collapsed-marker",yl,this.getCollapsedMarkerStyle(t),e)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const{type:e,...n}=zu(this.getGraphicStyle(t),"collapsedMarker"),r=this.getKey(),[i,o]=Pu(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(Iu(t)))).length.toString():kt(t)?t(r):""}getComboZIndex(t){return(t.context?.model.getAncestorsData(this.id,du)||[]).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)}}class Cl extends kl{static defaultStyleProps={anchor:[.5,.5]};constructor(t){super(ee({},{style:Cl.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Is,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),n=zu(e,"collapsed"),[r,i]=this.getKeySize(t);return{...e,...t.collapsed&&n,width:r,height:i}}}const Pl={N:"S",S:"N",W:"E",E:"W"},Al={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Ol(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Rl(t,e){return"N"===e||"S"===e?bu(t):yu(t)}function _l(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Ol(t,r),a=Ol(t,i),s=n?Pl[n]:null,c=o===n||o!==s&&a!==n?r:i;return{points:[c],direction:Ol(c,e)}}function Dl(t,e,n){const r=zl(t,e,n);return{points:[r],direction:Ol(r,e)}}function Il(t,e,n,r){const i=[[e[0],t[1]],[t[0],e[1]]],o=i.filter((t=>!Nu(t,n))),a=o.filter((e=>Ol(e,t)!==r));if(a.length>0){const n=a.find((e=>Ol(t,e)===r))||a[0];return{points:[n],direction:Ol(n,e)}}{const a=tl(e,Tt(i,o)[0],Rl(n,r)/2);return{points:[zl(a,t,n),a],direction:Ol(a,e)}}}function Ll(t,e,n,r){let i=Dl(t,e,n);const o=Xu(i.points[0]);if(Nu(o,r)){i=Dl(e,t,r);const a=Xu(i.points[0]);if(Nu(a,n)){const s=tl(t,a,Rl(n,Ol(t,a))/2),c=tl(e,o,Rl(r,Ol(e,o))/2),u=[(s[0]+c[0])/2,(s[1]+c[1])/2],l=Dl(t,u,n),h=Il(u,e,r,l.direction);i.points=[l.points[0],h.points[0]],i.direction=h.direction}}return i}function jl(t,e,n,r,i){const o=.01,a=Mu([n,r]),s=qu(e,a.center)>qu(t,a.center),[c,u]=s?[e,t]:[t,e],l=bu(a)+yu(a);let h;if(i){const t=[c[0]+l*Math.cos(Al[i]),c[1]+l*Math.sin(Al[i])];h=tl(Tu(a,t),t,o)}else h=tl(Tu(a,c),c,-.01);let d=zl(h,u,a),f=[Ju(h,2),Ju(d,2)];if(ie(Ju(h),Ju(d))){const t=function(t,e){return Math.acos(Wu(t,e).reduce(((t,e)=>t+e),0)/(qu(t,Gu)*qu(e,Gu)))}(Uu(h,c),[1,0,0])+Math.PI/2;d=[u[0]+l*Math.cos(t),u[1]+l*Math.sin(t),0],d=Ju(tl(Tu(a,d),u,-.01),2);f=[h,zl(h,d,a),d]}return{points:s?f.reverse():f,direction:Ol(s?h:d,e)}}function zl(t,e,n){let r=[t[0],e[1]];return Nu(r,n)&&(r=[e[0],t[1]]),r}function Fl(t,e,n,r,i){const[o,a]=Zu(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 Bl(t,e,n,r){if(ie(t,e))return t;const i=Uu(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Yu(function(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Gl(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 Vl(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(!nl([s,u=t],[u,c])&&e){const[n,r]=function(t,e,n,r){const i=$u(t,e),o=$u(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]]);var u})),a.push(["L",i[0],i[1]]),n&&a.push(["Z"]),a}const Ul=t=>{const e=Math.PI/2,n=bu(t)/2,r=yu(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 Wl(t,e,n,r,i){const o=wu(t),a=t.getCenter();let s=r&&lh(r),c=i&&lh(i);if(!s||!c){const r=Ul(o),i=r[e][0],u=r[e][1],[l,h]=Eu(o),d=Math.max(l,h),f=Vu(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Vu(a,[d*Math.cos(u),d*Math.sin(u),0]);s=gh(t,f),c=gh(t,p),n||([s,c]=[c,s])}return[s,c]}function Hl(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[c,u]=Wl(t,e,n,a,s);const l=function(t,e,n,r){const i=t.getCenter();if(ie(e,n)){const t=Uu(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Vu(e,o),Vu(n,Wu(o,[1,-1,1]))]}return[tl(i,e,qu(i,e)+r),tl(i,n,qu(i,n)+r)]}(t,c,u,r);return a&&(c=ph(a,l[0])),s&&(u=ph(s,l[l.length-1])),Gl(c,u,l)}function ql(t,e,n,r,i,o,a){const s=ch(t),c=s[o||a],u=s[a||o];let[l,h]=Wl(t,n,r,c,u);const d=function(t,e,n,r){const i=[],o=wu(t);if(ie(e,n)){switch(Su(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=Su(o,e),a=Su(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=zl(c,u,o);i.push(c,l,u)}}return i}(t,l,h,i);return c&&(l=ph(c,d[0])),u&&(h=ph(u,d[d.length-1])),Vl([l,...d,h],e)}function $l(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 Yl=(t,e)=>[["M",0,0],["L",t,-e/2],["L",t,e/2],["Z"]];var Xl=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:Yl,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 Kl extends gl{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(ee({},{style:Kl.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)),...Bu(o,["halo","label","startArrow","endArrow"]),stroke:r||i}}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r}=t,i=wu(e),o=Math.max(yu(i),bu(i)),{placement:a,clockwise:s,dist:c=o}=zu(this.getGraphicStyle(t),"loop");return Hl(e,a,s,c,n,r)}getEndpoints(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=hh(e,n,r,i);return[fh(o||e,a||n),fh(a||n,o||e)]}getHaloStyle(t){if(!1===t.halo)return!1;return{...this.getKeyStyle(t),...zu(this.getGraphicStyle(t),"halo")}}getLabelStyle(t){if(!1===t.label||re(t.labelText))return!1;const e=zu(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=Zu(t.getPoint(o)),s=Zu(t.getPoint(o+.01));let c="start"===e?"left":"end"===e?"right":"center";if(el(a,s)||!n){const[e,n]=Fl(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]=Fl(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 al(qu(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=re(e.src)?Rs:As,[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}=zu(this.getGraphicStyle(t),r),[s,c]=Ou(i),u=(kt(o)?o:Xl[o]||Yl)(s,c);return{...n,width:s,height:c,...u&&{path:u,fill:"simple"===o?"":n.stroke},...a}}drawLabelShape(t,e){this.upsert("label",ml,this.getLabelStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Rs,this.getHaloStyle(t),e)}drawKeyShape(t,e){return this.upsert("key",Rs,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))}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>{this.drawLabelShape(this.parsedAttributes,this)}),n}}class Zl extends Kl{static defaultStyleProps={curvePosition:.5,curveOffset:20};constructor(t){super(ee({},{style:Zl.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 Vt(t)?[t,1-t]:t}(i),function(t){return Vt(t)?[t,-t]:t}(o),r);return Gl(e,n,a)}getControlPoints(t,e,n,r,i){return 2===i?.length?i:[Bl(t,e,n[0],r[0]),Bl(t,e,n[1],r[1])]}}class Ql extends Zl{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(ee({},{style:Ql.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 Jl extends Zl{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(ee({},{style:Jl.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 th extends Kl{static defaultStyleProps={};constructor(t){super(ee({},{style:th.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}}class eh extends Kl{static defaultStyleProps={radius:0,controlPoints:[],router:!1,routerName:"orth",routerPadding:10};constructor(t){super(ee({},{style:eh.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=fh(a||e,c[0]||s||n),l=fh(s||n,c[c.length-1]||a||e);return Vl([u,...c,l],r)}getEndpointsAndPorts(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=hh(e,n,r,i);return{sourcePoint:o?lh(o):e.getCenter(),targetPoint:a?lh(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=el(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=jl(h,d,n,r):f||(p=Ll(h,d,n,r)):Nu(d,n)?p=jl(h,d,n,wu(d,o),s):f||(p=Dl(h,d,n)):i===e-1?Nu(h,r)?p=jl(h,d,wu(h,o),r,s):f||(p=Il(h,d,r,s)):f||(p=_l(h,d,s)),p?(c.push(...p.points),s=p.direction):s=Ol(h,d),i<e-1&&c.push(d)}var u,l;return c}(e,n,wu(i,s),wu(o,s),r,s)}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r,radius:i}=t,o=wu(e),a=Math.max(yu(o),bu(o))/4,{placement:s,clockwise:c,dist:u=a}=zu(this.getGraphicStyle(t),"loop");return ql(e,i,s,c,u,n,r)}}class nh extends Kl{static defaultStyleProps={curvePosition:.5,curveOffset:30};constructor(t){super(ee({},{style:nh.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||Bl(r,i,e,n))}}function rh(t){return t instanceof bl&&"node"===t.type}function ih(t){return t instanceof Kl}function oh(t){return t instanceof kl}const ah={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function sh(t,e,n=ah,r=!0){const i=[.5,.5],o=zt(e)?oe(n,e.toLocaleLowerCase(),i):e;if(!r&&zt(e))return o;const[a,s]=o||i;return[t.min[0]+yu(t)*a,t.min[1]+bu(t)*s]}function ch(t){const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{const{key:i,placement:o}=n;uh(n)&&(e[i||r]||=Pu(t.getKey().getBounds(),o))})),e}function uh(t){const{r:e}=t;return!e||0===Number(e)}function lh(t){return gu(t)?t:t.getPosition()}function hh(t,e,n,r){return[dh(t,e,n,r),dh(e,t,r,n)]}function dh(t,e,n,r){const i=ch(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>lh(t))),s=function(t,e){const n=ch(t);if(e)return[lh(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>lh(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=qu(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>lh(t)===c))}function fh(t,e){return rh(t)?gh(t,e):ph(t,e)}function ph(t,e){if(gu(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return ol(gu(e)?e:rh(e)?e.getCenter():e.getPosition(),t.getBounds())}function gh(t,e){const n=gu(e)?e:rh(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function mh(t,e="bottom",n=!1){const r=e.split("-"),[i,o]=Pu(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 yh(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 bh(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=>Ct(t)))||r.every((t=>!rh(t)&&ie(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 Eh(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;default:return}}function wh(t,e){return e.before?.(),t?(e.beforeAnimate?.(t),t.finished.then((()=>{e.afterAnimate?.(t),e.after?.()}))):e.after?.(),t}function xh(t,e){const{animation:n}=t;if(!n||!1===e)return!1;const r={...nu};return Rt(n)&&Object.assign(r,n),Rt(e)&&Object.assign(r,e),r}const Mh=(t,e,n,r)=>{if(!e)return null;const{animationsFilter:i=(()=>!0)}=r,o=(zt(e)?lI("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]??Eh(t)}),Object.assign(s[1],{[t]:a[t]??Eh(t)})}));const c=function(t,e,n){if(0===e.length)return null;const r=["opacity"];if(!e.some((t=>Object.keys(t).some((t=>r.includes(t))))))return t.animate(e,n);const i=e.map((t=>{const e={};return Object.entries(t).forEach((([t,n])=>{r.includes(t)&&(e[t]=n)})),e})),o=fl(t);return yh(t.animate(e,n),o.map((t=>t.animate(i,n))))}(r,bh(s),{...ru,...n,...i});return void 0===e&&(l=c),c}return null})).filter(Boolean),d=l||h?.[0];return d?yh(d,h.filter((t=>t!==d))):null};function Nh(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)?ie(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 Sh{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}=Nh(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=lI(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 Th{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 kh extends Th{}class Ch extends kh{static defaultOptions={enable:!0,animation:!0};constructor(t,e){super(t,Object.assign({},Ch.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 e=t?.target?.id,{model:n,graph:r}=this.context,i=n.getComboData([e])[0];if(!i)return!1;const{oncollapse:o,onexpand:a,animation:s}=this.options,c=i.style?.collapsed;c?(await r.expand(e,s),a?.(e)):(await r.collapse(e,s),o?.(e))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return kt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}class Ph{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)=>{ie(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}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)}onKeyDown=t=>{this.recordKey.add(t.key),this.trigger(t)};onKeyUp=t=>{this.recordKey.delete(t.key)};trigger(t){this.map.forEach(((e,n)=>{ie(Array.from(this.recordKey),n)&&e(t)}))}onWheel=e=>{this.map.forEach(((n,r)=>{r.includes(t.CommonEvent.WHEEL)&&ie(Array.from(this.recordKey),r.filter((e=>e!==t.CommonEvent.WHEEL)))&&n(e)}))}}class Ah extends kh{static defaultOptions={enable:!0,sensitivity:10};shortcut;defaultCursor;constructor(t,e){super(t,Object.assign({},Ah.defaultOptions,e)),this.shortcut=new Ph(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.translate([0,1],t))),this.shortcut.bind(i,(t=>this.translate([0,-1],t))),this.shortcut.bind(o,(t=>this.translate([1,0],t))),this.shortcut.bind(a,(t=>this.translate([-1,0],t)))}else n.on(t.CanvasEvent.DRAG,this.onDrag)}onDrag=t=>{"canvas"===t.targetType&&this.context.graph.translateBy([t.movement.x,t.movement.y],!1)};translate(t,e){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;this.context.graph.translateBy(Wu(t,r),this.options.animation)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return kt(e)?e(t):!!e}destroy(){this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}class Oh extends kh{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({},Oh.defaultOptions,e)),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)))}onDragStart=t=>{this.enable=this.validate(t),this.enable&&(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.context.graph.getZoom(),{dx:n,dy:r}=t,i=Hu([n,r],e);this.options.shadow?this.moveShadow(i):this.moveElement(this.target,i)};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]=Uu([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),this.options.onFinish?.(this.target),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,du);n&&Iu(n)===r&&e.refreshComboData(r),e.setParent(t,r,du)})),await(n?.draw({animation:!0}))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return kt(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=zu(this.options,"shadow"),n=Mu(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Eu(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr({...e,...s,visibility:"visible"}):(this.shadow=new Is({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(Iu):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(Iu))).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 Rh=["node","combo"];class _h extends kh{static defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};constructor(t,e){super(t,Object.assign({},_h.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Rh.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 kt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Rh.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.clickFocusElement)}))}destroy(){this.unbindEvents(),super.destroy()}}function Dh(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)Dh(t,e,n,r,i+1);"BT"===r&&e(t,i)}function Ih(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=Iu(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 Lh extends kh{static defaultOptions={animation:!0,enable:!0,degree:0,activeState:"active",inactiveState:void 0};constructor(t,e){super(t,Object.assign({},Lh.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),wl.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=function(t,e,n,r){if("combo"===e||"node"===e)return Ih(t,n,r);const i=t.getEdgeData(n);if(!i)return[];const o=Ih(t,i.source,r-1),a=Ih(t,i.target,r-1);return Array.from(new Set([...o,...a,n]))}(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=function(t){return Object.values(t).flatMap((t=>t.map(Iu)))}(n.getData()).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 kt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;wl.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 jh extends kh{static defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[]};shortcut;constructor(t,e){super(t,Object.assign({},jh.defaultOptions,e)),this.shortcut=new Ph(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Ot(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=Zu(e.viewport));const{sensitivity:o,onfinish:a}=this.options,s=1+Gt(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 kt(e)?e(t):!!e}preventDefault(t){const e=this.context.canvas.getContainer();e&&e.addEventListener(t,(t=>t.preventDefault()))}}var zh=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Fh=function(t,e){return!!zh(t)&&t.indexOf(e)>-1},Bh=function(t,e){if(!zh(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n},Gh={}.toString,Vh=function(t,e){return Gh.call(t)==="[object "+e+"]"},Uh=function(t){return Vh(t,"Function")},Wh=function(t){return null==t},Hh=function(t){return Array.isArray?Array.isArray(t):Vh(t,"Array")},qh=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function $h(t,e){if(t)if(Hh(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(qh(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Yh=Object.keys?function(t){return Object.keys(t)}:function(t){var e=[];return $h(t,(function(n,r){Uh(t)&&"prototype"===r||e.push(r)})),e};function Xh(t,e){var n=Yh(e),r=n.length;if(Wh(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 Kh=function(t){return"object"==typeof t&&null!==t},Zh=function(t){if(!Kh(t)||!Vh(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 Qh=function(t,e){if(void 0===e&&(e=[]),Hh(t))for(var n=0;n<t.length;n+=1)Qh(t[n],e);else e.push(t);return e},Jh=function(t){if(Hh(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},td=function(t){if(Hh(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},ed=Array.prototype,nd=ed.splice,rd=ed.indexOf,id=Array.prototype.splice,od=function(t,e){if(!zh(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,id.call(t,o,1))}return t},ad=function(t,e,n){if(!Hh(t)&&!Zh(t))return t;var r=n;return $h(t,(function(t,n){r=e(r,t,n)})),r},sd=function(t){return Vh(t,"String")};function cd(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 ud=Object.prototype.hasOwnProperty;function ld(t,e){if(!e||!Hh(t))return{};for(var n,r={},i=Uh(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),ud.call(r,n)?r[n].push(a):r[n]=[a]}return r}function hd(t,e){if(!e)return{0:t};if(!Uh(e)){var n=Hh(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 ld(t,e)}var dd={};var fd=function(t){return Vh(t,"Number")},pd=Number.isInteger?Number.isInteger:function(t){return fd(t)&&t%1==0};var gd=180/Math.PI,md=parseInt,vd=Math.PI/180,yd=function(t,e){return t.hasOwnProperty(e)},bd=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return $h(t,(function(n,r){Uh(t)&&"prototype"===r||e.push(n)})),e},Ed=function(t){return Wh(t)?"":t.toString()};var wd={}.toString,xd=function(t){return wd.call(t).replace(/^\[object /,"").replace(/]$/,"")};var Md=Object.prototype,Nd=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Md)};function Sd(t,e){for(var n in e)e.hasOwnProperty(n)&&"constructor"!==n&&void 0!==e[n]&&(t[n]=e[n])}function Td(t,e,n,r){return e&&Sd(t,e),n&&Sd(t,n),r&&Sd(t,r),t}var kd=function(t){if("object"!=typeof t||null===t)return t;var e;if(Hh(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=kd(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=kd(t[i]):e[i]=t[i];return e};var Cd=function(t,e){if(!Uh(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 Pd(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&&Zh(o)?(Zh(t[i])||(t[i]={}),n<r?Pd(t[i],o,n+1,r):t[i]=e[i]):Hh(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var Ad=Object.prototype.hasOwnProperty;var Od,Rd=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(sd(t)||sd(e))return!1;if(zh(t)||zh(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=Rd(t[r],e[r]));r++);return n}if(Kh(t)||Kh(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=Rd(t[i[r]],e[i[r]]));r++);return n}return!1},_d=function(t){return t},Dd=Object.prototype.hasOwnProperty,Id={};var Ld=Cd((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return Od||(Od=document.createElement("canvas").getContext("2d")),Od.font=[o,a,i,n+"px",r].join(" "),Od.measureText(sd(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],bd(e)).join("")})),jd=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}(),zd=Object.freeze({__proto__:null,Cache:jd,assign:Td,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];Uh(i)&&(i=i.prototype),Td(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:kd,contains:Fh,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)Pd(t,e[r]);return t},difference:function(t,e){return void 0===e&&(e=[]),Bh(t,(function(t){return!Fh(e,t)}))},each:$h,endsWith:function(t,e){return!(!Hh(t)&&!sd(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){Uh(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=Td(o,t.prototype),t.superclass=i(e.prototype,e),Td(o,n),Td(t,r),t},filter:Bh,find:function(t,e){if(!Hh(t))return null;var n;if(Uh(e)&&(n=e),Zh(e)&&(n=function(t){return Xh(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(!Wh(i)){n=Hh(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(!Hh(t))return[];for(var e=[],n=0;n<t.length;n++)e=e.concat(t[n]);return e},flattenDeep:Qh,forIn:$h,get:function(t,e,n){for(var r=0,i=sd(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=Ld(r,n),s=sd(t)?t:Ed(t),c=e,u=[];if(Ld(t,n)<=e)return t;for(;i=s.substr(0,16),!((o=Ld(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=Ld(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(Hh(t[0])){for(var n=[],r=0;r<t.length;r++)n=n.concat(t[r]);e=n}var i=Jh(e);return{min:td(e),max:i}},getType:xd,getWrapBehavior:function(t,e){return t["_wrap_"+e]},group:function(t,e){if(!e)return[t];var n=hd(t,e),r=[];for(var i in n)r.push(n[i]);return r},groupBy:ld,groupToMap:hd,has:yd,hasKey:yd,hasValue:function(t,e){return Fh(bd(t),e)},head:function(t){if(zh(t))return t[0]},identity:function(t){return t},includes:Fh,indexOf:function(t,e){if(!zh(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 Vh(t,"Arguments")},isArray:Hh,isArrayLike:zh,isBoolean:function(t){return Vh(t,"Boolean")},isDate:function(t){return Vh(t,"Date")},isDecimal:function(t){return fd(t)&&t%1!=0},isElement:function(t){return t instanceof Element||t instanceof HTMLDocument},isEmpty:function(t){if(Wh(t))return!0;if(zh(t))return!t.length;var e=xd(t);if("Map"===e||"Set"===e)return!t.size;if(Nd(t))return!Object.keys(t).length;for(var n in t)if(Ad.call(t,n))return!1;return!0},isEqual:Rd,isEqualWith:function(t,e,n){return Uh(n)?!!n(t,e):Rd(t,e)},isError:function(t){return Vh(t,"Error")},isEven:function(t){return fd(t)&&t%2==0},isFinite:function(t){return fd(t)&&isFinite(t)},isFunction:Uh,isInteger:pd,isMatch:Xh,isNegative:function(t){return fd(t)&&t<0},isNil:Wh,isNull:function(t){return null===t},isNumber:fd,isNumberEqual:function(t,e,n){return void 0===n&&(n=1e-5),Math.abs(t-e)<n},isObject:qh,isObjectLike:Kh,isOdd:function(t){return fd(t)&&t%2!=0},isPlainObject:Zh,isPositive:function(t){return fd(t)&&t>0},isPrototype:Nd,isRegExp:function(t){return Vh(t,"RegExp")},isString:sd,isType:Vh,isUndefined:function(t){return void 0===t},keys:Yh,last:function(t){if(zh(t)){return t[t.length-1]}},lowerCase:function(t){return Ed(t).toLowerCase()},lowerFirst:function(t){var e=Ed(t);return e.charAt(0).toLowerCase()+e.substring(1)},map:function(t,e){if(!zh(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=_d);var n={};return qh(t)&&!Wh(t)&&Object.keys(t).forEach((function(r){n[r]=e(t[r],r)})),n},max:Jh,maxBy:function(t,e){if(Hh(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=Uh(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},measureTextWidth:Ld,memoize:Cd,min:td,minBy:function(t,e){if(Hh(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=Uh(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},mix:Td,mod:function(t,e){return(t%e+e)%e},noop:function(){},number2color:function(t){var e=dd[t];if(!e){for(var n=t.toString(16),r=n.length;r<6;r++)n="0"+n;e="#"+n,dd[t]=e}return e},omit:function(t,e){return ad(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 Hh(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||!Zh(t))return{};var n={};return $h(e,(function(e){Dd.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=rd.call(t,i))>-1;)nd.call(t,o,1);return t},pullAt:od,reduce:ad,remove:function(t,e){var n=[];if(!zh(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 od(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=sd(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(qh(r[t])||(r[t]=fd(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},size:function(t){return Wh(t)?0:zh(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(Uh(e))n=function(t,n){return e(t)-e(n)};else{var r=[];sd(e)?r.push(e):Hh(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!(!Hh(t)&&!sd(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 zh(t)?Array.prototype.slice.call(t):[]},toDegree:function(t){return gd*t},toInteger:md,toRadian:function(t){return vd*t},toString:Ed,union:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return cd([].concat.apply([],t))},uniq:cd,uniqueId:function(t){return Id[t=t||"g"]?Id[t]+=1:Id[t]=1,t+Id[t]},upperCase:function(t){return Ed(t).toUpperCase()},upperFirst:function(t){var e=Ed(t);return e.charAt(0).toUpperCase()+e.substring(1)},values:bd,valuesOfKey:function(t,e){for(var n=[],r={},i=0;i<t.length;i++){var o=t[i][e];if(!Wh(o)){Hh(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 Fd={assign:f(zd).mix,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},Bd=Fd,Gd={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 Vd(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof Vd)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}Bd.assign(Vd.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 Ud=function(t,e,n){void 0===e&&(e={});var r,i=new Vd(t,e=Bd.assign({},Gd,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 Vd(a[c],e);r.children[c]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},Wd=Ud,Hd=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=Wd(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),qd=Hd;function $d(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 Yd(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){Yd(t,e,n)}))}function Xd(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(Xd(t,e),n)})),n}function Kd(t,e){Yd(t,-Xd(t,e),e)}function Zd(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){Zd(t,e.children[r],n)}))}function Qd(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){Qd(t,e,n)}))}$d.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push($d.fromNode(t,e))})),e?new $d(t.height,t.width,t.x,n):new $d(t.width,t.height,t.y,n)};var Jd=Ud,tf=function(t,e){for(var n=Jd(t.data,e,!0),r=Jd(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}},ef=tf,nf=["LR","RL","TB","BT","H","V"],rf=["LR","RL","H"],of=nf[0],af=function(t,e,n){var r=e.direction||of;if(e.isHorizontal=function(t){return rf.indexOf(t)>-1}(r),r&&-1===nf.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===nf[0])n(t,e);else if(r===nf[1])n(t,e),t.right2left();else if(r===nf[2])n(t,e);else if(r===nf[3])n(t,e),t.bottom2top();else if(r===nf[4]||r===nf[5]){var i=ef(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 sf(t,e){return sf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},sf(t,e)}var cf=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}}Qd(t,n);var l=$d.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),Zd(l,t,n),Kd(t,n),t},uf=af,lf=Fd,hf=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,sf(e,n),r.prototype.execute=function(){return uf(this.rootNode,this.options,cf)},r}(qd),df={};var ff=function(t,e){return e=lf.assign({},df,e),new hf(t,e).execute()},pf=Fd;function gf(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 mf={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function vf(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){vf(t,e.children[r],n)}))}function yf(t,e){return yf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},yf(t,e)}var bf=function(t,e){void 0===e&&(e={}),e=pf.assign({},mf,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 gf(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),vf(i,t,e.isHorizontal),t},Ef=af,wf=Fd,xf=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,yf(e,n),r.prototype.execute=function(){var t=this;return t.rootNode.width=0,Ef(t.rootNode,t.options,bf)},r}(qd),Mf={};var Nf=function(t,e){return e=wf.assign({},Mf,e),new xf(t,e).execute()},Sf=Fd;function Tf(t,e){return Tf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tf(t,e)}var kf=qd,Cf=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+Sf.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Sf.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},Pf=tf,Af=Fd,Of=["LR","RL","H"],Rf=Of[0],_f=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,Tf(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?Rf:a,c=t.align;if(s&&-1===Of.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Of[0])Cf(e,r,o,c);else if(s===Of[1])Cf(e,r,o,c),e.right2left();else if(s===Of[2]){var u=Pf(e,t),l=u.left,h=u.right;Cf(l,r,o,c),l.right2left(),Cf(h,r,o,c);var d=l.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},r}(kf),Df={};var If=function(t,e){return e=Af.assign({},Df,e),new _f(t,e).execute()},Lf=Fd;function jf(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=jf(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function zf(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){zf(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 Ff={getSubTreeSep:function(){return 0}};function Bf(t,e){return Bf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Bf(t,e)}var Gf=function(t,e){void 0===e&&(e={}),e=Lf.assign({},Ff,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,jf(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}}}})),zf(t)},Vf=af,Uf=Fd,Wf=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,Bf(e,n),r.prototype.execute=function(){return Vf(this.rootNode,this.options,Gf)},r}(qd),Hf={};var qf=function(t,e){return e=Uf.assign({},Hf,e),new Wf(t,e).execute()},$f={compactBox:ff,dendrogram:Nf,indented:If,mindmap:qf},Yf=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 Xf(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 Kf(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)&&Kf(i,e,n,r))return!0;return!1}const Zf=()=>!0;class Qf{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||Zf,n=t.edgeFilter||Zf;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];Xf([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];Kf(this.getNode(t),new Set,e,r)}}let Jf=class t extends Yf{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 Kf(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Xf([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 Xf([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 Kf(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 Qf({graph:this,...t})}};const tp=(t,e)=>{if("next"!==t&&"prev"!==t)return e},ep=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let np=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 ep(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&ep(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,tp)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},rp=class extends np{};const ip=()=>1,op=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)ap(t,e,n,a);for(;a=i.dequeue();)ap(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(ap(t,e,n,a,!0));break}}return r},ap=(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,cp(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,cp(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},sp=(t,e)=>{const n=new Jf;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 rp);const s=r+1;return n.getAllNodes().forEach((t=>{cp(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},cp=(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=sp(t,e||ip);return null===(n=op(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)):lp(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)})}))},lp=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},hp=(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},dp=t=>{const e=new Jf;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},fp=(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}},pp=t=>{const e=[],n=mp(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},gp=(t,e,n,r)=>{const i={width:0,height:0};return Vt(n)&&Vt(r)&&(i.rank=n,i.order=r),hp(t,"border",i,e)},mp=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},vp=(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))},bp=(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}`);yp(t,e,"post"===n,s,o,a)})),a},Ep=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],c=hp(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}})},wp=t=>{t.getAllNodes().forEach((t=>{xp(t)})),t.getAllEdges().forEach((t=>{xp(t)}))},xp=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Mp=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("y")&&Np(t.data)}))},Np=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Sp=t=>{t.getAllNodes().forEach((t=>{Tp(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Tp(t))),t.data.hasOwnProperty("x")&&Tp(t.data)}))},Tp=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 c=gp(t,"_bt"),u=gp(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=>{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: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]}})},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},Pp=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Ap="edge-label",Op=(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=hp(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=Ap,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}})},Rp=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},_p=(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},Dp=(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},Lp=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)&&jp(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}))},jp=(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},zp=(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},Fp=(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},Bp=(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=Bp(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&Vp(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 Lp(a)})(g,n);Gp(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(Fp(!!e,!!n)),l=zp(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=zp(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},Gp=(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()}))},Vp=(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)},Up=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Rp(t),i=new Jf({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 Jf;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Bp(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}))}))},qp=(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}}))},$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,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)&&Xp(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},Yp=(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))},Xp=(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]},Zp=(t,e,n,r,i,o)=>{const a=new Jf,s=Qp(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 Qp=(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},Jp=(t,e)=>t.getNode(e).data.width||0,tg=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=pp(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=Yp(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)||Xp(n,r.id,e)}))})),o=c+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),$p(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]&&!Kp(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=Zp(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)=>vp(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=Jp(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)},eg=(t,e)=>{var n;const r=dp(t);((t,e)=>{const{ranksep:n=0}=e||{},r=pp(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=tg(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},ng=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)))},rg=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,ig=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||rg(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)=>{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&&rg(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},ag=(t,e)=>vp(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?rg(e,n):1/0)),sg=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},cg=t=>{const e=(t=>{const e=new Jf;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);ng(e);const n=(t=>{const e=new Jf({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);ig(e,t)<r;)i=ag(e,t),o=e.hasNode(i.source)?rg(t,i):-rg(t,i),sg(e,t,o);return e})(e);let r,i;for(dg(n),ug(n,e);r=pg(n);)i=gg(n,e,r),mg(n,e,r,i)},ug=(t,e)=>{let n=bp(t,t.getAllNodes(),"post",!1);n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{lg(t,e,n)}))},lg=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=hg(t,e,n)},hg=(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,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},dg=(t,e=t.getAllNodes()[0].id)=>{fg(t,{},1,e)},fg=(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=fg(t,e,s,n.id,r))})),c.data.low=a,c.data.lim=s++,i?c.data.parent=i:delete c.data.parent,s},pg=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),gg=(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===bg(t.getNode(e.source),s)&&c!==bg(t.getNode(e.target),s)));return vp(u,(t=>rg(e,t)))},mg=(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:{}}),dg(t),ug(t,e),vg(t,e)},vg=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=bp(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))}))},yg=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),bg=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Eg=ng,wg=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 Jf({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);og(e,t)<r;)i=ag(e,t),o=e.hasNode(i.source)?rg(t,i):-rg(t,i),sg(e,t,o)})(t)},xg=t=>{cg(t)},Mg=(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;Gg(t),up(t,n);const{nestingRoot:h,nodeRankFactor:d}=(t=>{const e=hp(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=Pp(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":xg(t);break;case"tight-tree":default:wg(t);break;case"longest-path":Eg(t)}})(dp(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),Dg(t),Ig(t);const f=[];((t,e)=>{t.getAllEdges().forEach((n=>Op(t,n,e)))})(t,f),qp(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)Ep(t,"borderLeft","_bl",n,i,e),Ep(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=mp(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=Up(t,r,"in"),a=Up(t,i,"out");let s=Ip(t);Hp(t,s);let c,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){Wp(n%2?o:a,n%4>=2,!1,e),s=pp(t);const i=Dp(t,s);i<u&&(r=0,c=Qt(s),u=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=pp(t);const i=Dp(t,s);i<u&&(r=0,c=Qt(s),u=i)}Hp(t,c)})(t,a),Vg(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||wp(t)})(t,i),eg(t,{align:s,nodesep:c,edgesep:u,ranksep:l}),Ug(t),Bg(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),zg(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Mp(t),"lr"!==n&&"rl"!==n||(Sp(t),wp(t))})(t,i);const{width:p,height:g}=Lg(t);return jg(t),Fg(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}},Ng=(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)}))},Tg=["width","height","layer","fixorder"],kg={width:0,height:0},Cg=["minlen","weight","width","height","labeloffset"],Pg={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Ag=["labelpos"],Og=t=>{const e=new Jf({tree:[]});return t.getAllNodes().forEach((n=>{const r=Hg(t.getNode(n.id).data),i=Object.assign(Object.assign({},kg),r),o=Wg(i,Tg);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);Ct(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({},Pg,Wg(r,Cg),i)})})),e},Rg=(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};hp(t,"edge-proxy",r,"_ep")}}))},Dg=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))}))},Lg=(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}},jg=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(fp(n.data,i)),e.data.points.push(fp(r.data,o))}))},zg=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}}))},Fg=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Bg=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)}))},Gg=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)}}))},Vg=t=>{const e=pp(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=>{hp(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},Ug=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},qg=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},Yg=(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},Xg=(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 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),Kg(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},Zg=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=>Zg(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=Zg(t[n])})),e}return t},Qg=(t,e)=>{const n=Zg(t);return n.data=n.data||{},e&&(Vt(n.data.x)||(n.data.x=Math.random()*e[0]),Vt(n.data.y)||(n.data.y=Math.random()*e[1])),n};function Jg(t,e){let n;return n=kt(e)?e:Vt(e)?()=>e:()=>t,n}function tm(t,e,n=!0){return e||0===e?kt(e)?e:Vt(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 em=(t,e)=>{let n,r;return r=Vt(e)?()=>e:kt(e)?e:()=>0,n=t?Array.isArray(t)?e=>(t[0]>t[1]?t[0]:t[1])+r(e):kt(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},nm={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};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: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},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};const am=(t,e,n=!1)=>{const r=[Qg(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(Qg(n)),i[n.id]=!0,u=!0;break}}let l=0;for(;!u&&(i[e[l].id]||(r.push(Qg(e[l])),i[e[l].id]=!0,u=!0),l++,l!==o););}else r.push(Qg(s)),i[s.id]=!0,a++})),r};const sm=(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 um{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: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,E=i||[y/2,b/2];if(!(null==m?void 0:m.length)||1===m.length)return im(e,t,E);const w=[];let x,M=0;qg(p)?x=Math.max(p[0],p[1]):kt(p)?(x=-1/0,m.forEach((t=>{const e=p(t);e>x&&(x=e)}))):x=p,qg(g)?M=Math.max(g[0],g[1]):Vt(g)&&(M=g),m.forEach((t=>{const e=Qg(t);w.push(e);let n=x;const{data:r}=e;qg(r.size)?n=Math.max(r.size[0],r.size[1]):Vt(r.size)?n=r.size:Rt(r.size)&&(n=Math.max(r.size.width,r.size.height)),x=Math.max(x,n),kt(g)&&(M=Math.max(g(t),M))}));const N={};w.forEach(((t,e)=>{N[t.id]=e}));let S=s;zt(S)&&void 0!==w[0].data[S]||(S="degree"),"degree"===S?w.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):w.sort(((t,e)=>e.data[S]-t.data[S]));const T=w[0],k=(c||("degree"===S?e.getDegree(T.id,"both"):T.data[S]))/4,C=[{nodes:[]}];let P=C[0];w.forEach((t=>{if(P.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(P.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(P.nodes[0].data[S]-t.data[S]);k&&n>=k&&(P={nodes:[]},C.push(P))}P.nodes.push(t)}));let A=x+M;if(!d){const t=C.length>0&&C[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(C.length+(t?1:0));A=Math.min(A,e)}let O=0;if(C.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<C.length;n++){const r=(C[n].r||0)-e;t=Math.max(t,r)}e=0,C.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}C.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=E[0]+n*Math.cos(i),t.data.y=E[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:v}}))}}function lm(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 hm(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function dm(t){return t[0]}function fm(t){return t[1]}function pm(t,e,n){var r=new gm(null==e?dm:e,null==n?fm:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function gm(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 mm(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var vm=pm.prototype=gm.prototype;function ym(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,E=t._y0,w=t._z0,x=t._x1,M=t._y1,N=t._z1;if(!v)return t._root=y,t;for(;v.length;)if((d=e>=(a=(b+x)/2))?b=a:x=a,(f=n>=(s=(E+M)/2))?E=s:M=s,(p=r>=(c=(w+N)/2))?w=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+x)/2))?b=a:x=a,(f=n>=(s=(E+M)/2))?E=s:M=s,(p=r>=(c=(w+N)/2))?w=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 bm(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 Em(t){return t[0]}function wm(t){return t[1]}function xm(t){return t[2]}function Mm(t,e,n,r){var i=new Nm(null==e?Em:e,null==n?wm:n,null==r?xm:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Nm(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 Sm(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 gm(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=mm(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]=mm(e));return n},vm.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return lm(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),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)lm(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,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},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,c,u,l=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new hm(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 hm(g[3],m,v,a,s),new hm(g[2],i,v,m,s),new hm(g[1],m,o,a,v),new hm(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),E=y*y+b*b;if(E<n){var w=Math.sqrt(n=E);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,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)},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=[],c=this._root;for(c&&s.push(new hm(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 hm(n,u,l,o,a)),(n=c[2])&&s.push(new hm(n,r,l,u,a)),(n=c[1])&&s.push(new hm(n,u,i,o,l)),(n=c[0])&&s.push(new hm(n,r,i,u,l))}return this},vm.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new hm(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 hm(o,a,s,l,h)),(o=i[1])&&n.push(new hm(o,l,s,c,h)),(o=i[2])&&n.push(new hm(o,a,h,l,u)),(o=i[3])&&n.push(new hm(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},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 Tm=Mm.prototype=Nm.prototype;Tm.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=Sm(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]=Sm(e));return n},Tm.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return ym(this.cover(e,n,r),e,n,r,t)},Tm.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)ym(this,n[o],r[o],i[o],t[o]);return this},Tm.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},Tm.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Tm.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]]},Tm.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=[],E=this._root;for(E&&b.push(new bm(E,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(!(!(E=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(E.length){var w=(o+c)/2,x=(a+u)/2,M=(s+l)/2;b.push(new bm(E[7],w,x,M,c,u,l),new bm(E[6],o,x,M,w,u,l),new bm(E[5],w,a,M,c,x,l),new bm(E[4],o,a,M,w,x,l),new bm(E[3],w,x,s,c,u,M),new bm(E[2],o,x,s,w,u,M),new bm(E[1],w,a,s,c,x,M),new bm(E[0],o,a,s,w,x,M)),(d=(n>=M)<<2|(e>=x)<<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 N=t-+this._x.call(null,E.data),S=e-+this._y.call(null,E.data),T=n-+this._z.call(null,E.data),k=N*N+S*S+T*T;if(k<r){var C=Math.sqrt(r=k);f=t-C,p=e-C,g=n-C,m=t+C,v=e+C,y=n+C,i=E.data}}return i},Tm.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,E=this._x1,w=this._y1,x=this._z1;if(!m)return this;if(m.length)for(;;){if((h=o>=(c=(v+E)/2))?v=c:E=c,(d=a>=(u=(y+w)/2))?y=u:w=u,(f=s>=(l=(b+x)/2))?b=l:x=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)},Tm.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Tm.root=function(){return this._root},Tm.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Tm.visit=function(t){var e,n,r,i,o,a,s,c,u=[],l=this._root;for(l&&u.push(new bm(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 bm(n,h,d,f,a,s,c)),(n=l[6])&&u.push(new bm(n,r,d,f,h,s,c)),(n=l[5])&&u.push(new bm(n,h,i,f,a,d,c)),(n=l[4])&&u.push(new bm(n,r,i,f,h,d,c)),(n=l[3])&&u.push(new bm(n,h,d,o,a,s,f)),(n=l[2])&&u.push(new bm(n,r,d,o,h,s,f)),(n=l[1])&&u.push(new bm(n,h,i,o,a,d,f)),(n=l[0])&&u.push(new bm(n,r,i,o,h,d,f))}return this},Tm.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new bm(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 bm(o,a,s,c,d,f,p)),(o=i[1])&&n.push(new bm(o,d,s,c,u,f,p)),(o=i[2])&&n.push(new bm(o,a,f,c,d,l,p)),(o=i[3])&&n.push(new bm(o,d,f,c,u,l,p)),(o=i[4])&&n.push(new bm(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new bm(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new bm(o,a,f,p,d,l,h)),(o=i[7])&&n.push(new bm(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},Tm.x=function(t){return arguments.length?(this._x=t,this):this._x},Tm.y=function(t){return arguments.length?(this._y=t,this):this._y},Tm.z=function(t){return arguments.length?(this._z=t,this):this._z};function km(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?pm(s,(t=>t.x),(t=>t.y)):Mm(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Cm),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>Pm(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 Cm(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 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 Am={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 Om{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Am),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:Vt(t.data.x)?t.data.x:Math.random()*c,y:Vt(t.data.y)?t.data.y:Math.random()*u,z:Vt(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 Jf({nodes:g,edges:m});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:E,onTick:w}=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 x=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Lm(e,g),edges:o}),this.runOneStep(y,e,x,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==w||w({nodes:Lm(e,g),edges:o}),x++,(x>=b||this.judgingDistance<E)&&(window.clearInterval(this.timeInterval),n({nodes:Lm(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;Vt(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=Jg(0,t.nodeSpacing);let c;c=a?kt(a)?t=>a(t)+s(t):qg(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?qg(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?Jg(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=u,n.nodeStrength=Jg(1,t.nodeStrength),n.edgeStrength=Jg(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=Rm(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=Im(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=Rm(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]=Im(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;km(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,E=1/(c.data.mass||1),w=1/(u.data.mass||1),x=p*b,M=g*b,N=m*b;e[a].x-=x*E,e[a].y-=M*E,e[a].z-=N*E,e[s].x+=x*w,e[s].y+=M*w,e[s].z+=N*w}))}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,E=0,w=0,x=h;const M=t.getDegree(o,"in"),N=t.getDegree(o,"out"),S=t.getDegree(o,"both"),T=null==i?void 0:i(y,S);if(T){const[t,e,n]=T;b=g-t,E=m-e,x=n}else b=g-l[0],E=m-l[1],w=v-l[2];if(x&&(n[o].x-=x*b/p,n[o].y-=x*E/p,n[o].z-=x*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(y,a,s,c,u))||{x:0,y:0,z:0,centerStrength:0};if(!Vt(l)||!Vt(h))return;const E=(g-l)/p,w=(m-h)/p,x=(v-f)/p;if(b&&(n[o].x-=b*E,n[o].y-=b*w,n[o].z-=b*x),0===S){const t=e(y);if(!t)return;return n[o].x-=t*E,n[o].y-=t*w,void(n[o].z-=t*x)}if(0===M||0===N){const e=t(y,a,s);if(!e)return;return n[o].x-=e*E,n[o].y-=e*w,void(n[o].z-=e*x)}const T=r(y);if(!T)return;n[o].x-=T*E,n[o].y-=T*w,n[o].z-=T*x}}))}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(Vt(u.data.fx)&&Vt(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 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]=_m(t,"leaf",n,e))})),r},_m=(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"leaf"===e&&(a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")))),a},Im=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}},Lm=(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 jm={};const zm=Object.prototype.toString;function Fm(t){const e=zm.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Bm=f(Object.freeze({__proto__:null,isAnyArray:Fm}));var Gm=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,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}}),Vm=f(Gm);Object.defineProperty(jm,"__esModule",{value:!0});var Um=Bm,Wm=Vm;const Hm=" ".repeat(2),qm=" ".repeat(4);function $m(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${Hm}[\n${qm}${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(Ym(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${qm}`)}(t,n,r,i,o)}\n${Hm}]\n${Hm}rows: ${t.rows}\n${Hm}columns: ${t.columns}\n}`}function Ym(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 Km(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 Zm(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 Qm(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 Jm(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 tv(t,e){if(!Um.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 ev(t,e){if(!Um.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 nv(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(iv("startRow",e),iv("endRow",n),iv("startColumn",r),iv("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 rv(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function iv(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function ov(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class av{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new cv(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 cv(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 cv(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 cv(t,e)}static ones(t,e){return new cv(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 cv(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 cv(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 cv(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 av.isMatrix(t)?t:new cv(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 cv(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){Km(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return cv.rowVector(this.getRow(t))}setRow(t,e){Km(this,t),e=Qm(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){Km(this,t),Km(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){Zm(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return cv.columnVector(this.getColumn(t))}setColumn(t,e){Zm(this,t),e=Jm(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){Zm(this,t),Zm(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=Qm(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=Qm(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=Qm(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=Qm(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=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[e]);return this}subColumnVector(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[e]);return this}mulColumnVector(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[e]);return this}divColumnVector(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[e]);return this}mulRow(t,e){Km(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){Zm(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(){ov(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(){ov(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(Km(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){Km(this,t),ov(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(Km(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){Km(this,t),ov(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(Zm(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){Zm(this,t),ov(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(Zm(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){Zm(this,t),ov(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){av.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=cv.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new cv(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=cv.checkMatrix(t);let e=new cv(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=cv.checkMatrix(t);let e=new cv(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),E=(n-o)*(-d+g),w=(-n+o+a)*(h-d+g),x=(o+a)*(-h+d),M=n*h,N=(-n+c+u)*(h-f+m),S=(-n+c)*(f-m),T=(c+u)*(-h+f),k=(-i+u+l)*(g+v-y),C=(i-l)*(g-y),P=i*v,A=(u+l)*(-v+y),O=(-i+a+s)*(m+v-b),R=(i-s)*(m-b),_=(a+s)*(-v+b),D=M+P+r*p,I=(n+r+i-o-a-u-l)*g+w+x+M+k+P+A,L=M+N+T+(n+r+i-a-s-c-u)*m+P+O+_,j=E+a*(-h+d+p-g-m-v+b)+w+M+P+O+R,z=E+w+x+M+s*y,F=P+O+R+_+o*f,B=M+N+S+u*(-h+f+p-g-m-v+y)+k+C+P,G=k+C+P+A+c*d,V=M+N+S+T+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,F),e.set(2,0,B),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=cv.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=av.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(av.add(c,p),av.add(u,g),o,s),v=t(av.add(d,p),u,o,s),y=t(c,av.sub(h,g),o,s),b=t(p,av.sub(f,u),o,s),E=t(av.add(c,l),g,o,s),w=t(av.sub(d,c),av.add(u,h),o,s),x=t(av.sub(l,p),av.add(f,g),o,s),M=av.add(m,b);M.sub(E),M.add(x);let N=av.add(y,E),S=av.add(v,b),T=av.sub(m,v);T.add(y),T.add(w);let k=av.zeros(2*M.rows,2*M.columns);return k=k.setSubMatrix(M,0,0),k=k.setSubMatrix(N,M.rows,0),k=k.setSubMatrix(S,0,M.columns),k=k.setSubMatrix(T,M.rows,M.columns),k.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 cv(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&Wm(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 cv(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&Wm(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=cv.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new cv(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=cv.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(cv.eye(n,n)),i=cv.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new cv(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=sv){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=sv){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){nv(this,t,e,n,r);let i=new cv(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 cv(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 cv(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=cv.checkMatrix(t)).isEmpty())return this;nv(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){tv(this,t),ev(this,e);let n=new cv(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 cv(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=rv(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=rv(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=rv(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=rv(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(!Um.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(!Um.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(!Um.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(!Um.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(!Um.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(!Um.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 $m(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 sv(t,e){return t-e}av.prototype.klass="Matrix","undefined"!=typeof Symbol&&(av.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return $m(this)}),av.random=av.rand,av.randomInt=av.randInt,av.diagonal=av.diag,av.prototype.diagonal=av.prototype.diag,av.identity=av.eye,av.prototype.negate=av.prototype.neg,av.prototype.tensorProduct=av.prototype.kroneckerProduct;let cv=class t extends av{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(!Um.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 Km(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Km(this,t,!0),e=Float64Array.from(Qm(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Zm(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),Zm(this,t,!0),e=Jm(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}}(av,cv);class uv extends av{#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 cv.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(),cv.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=cv.copy(t,new cv(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new cv(t,t);else if(this.#e=new cv(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new uv(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new cv(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 uv(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)}}}uv.prototype.klassType="SymmetricMatrix";class lv extends uv{static isDistanceMatrix(t){return uv.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 uv(this)}clone(){const t=new lv(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}}lv.prototype.klassSubType="DistanceMatrix";class hv extends av{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class dv extends hv{constructor(t,e,n){tv(t,e),ev(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 fv extends av{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 pv extends av{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 gv{constructor(t){let e,n,r,i,o,a,s,c,u,l=(t=pv.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=cv.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 cv(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 cv(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 mv(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 vv{constructor(t){let e,n,r,i,o=(t=pv.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=mv(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=cv.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 cv(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 cv(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 yv=class{constructor(t,e={}){if((t=pv.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 cv(n,h),g=new cv(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),E=Math.max(0,Math.min(r-2,n)),w=Math.max(b,E);for(let t=0;t<w;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=mv(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<E){m[t]=0;for(let e=t+1;e<r;e++)m[t]=mv(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 x=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<x&&(f[x-1]=0),E+1<x&&(m[E]=s.get(E,x-1)),m[x-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<E&&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=x-1,N=Number.EPSILON;for(;x>0;){let t,e;for(t=x-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===x-2)e=4;else{let n;for(n=x-1;n>=t&&n!==t;n--){let e=(n!==x?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===x-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[x-2];m[x-2]=0;for(let n=x-2;n>=t;n--){let i=mv(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,x-1),g.set(t,x-1,-a*g.get(t,n)+o*g.get(t,x-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<x;r++){let i=mv(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[x-1]),Math.abs(f[x-2]),Math.abs(m[x-2]),Math.abs(f[t]),Math.abs(m[t])),i=f[x-1]/e,o=f[x-2]/e,a=m[x-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<x-1;e++){let i=mv(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=mv(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[x-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++}x--}}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=cv.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=cv.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(cv.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new cv(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 cv(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 cv.diag(this.s)}};function bv(t,e,n=!1){return t=pv.checkMatrix(t),e=pv.checkMatrix(e),n?new yv(t).solve(e):t.isSquare()?new gv(t).solve(e):new vv(t).solve(e)}function Ev(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function wv(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 xv{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=pv.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 cv(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 E=0,w=0,x=Number.EPSILON;for(u=0;u<t;u++){for(w=Math.max(w,Math.abs(n[u])+Math.abs(e[u])),l=u;l<t&&!(Math.abs(e[l])<=x*w);)l++;if(l>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=mv(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(E+=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=mv(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])>x*w);n[u]=n[u]+E,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 cv(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,E=t-1,w=0,x=t-1,M=Number.EPSILON,N=0,S=0,T=0,k=0,C=0,P=0,A=0,O=0;for(o=0;o<t;o++)for((o<w||o>x)&&(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(;E>=w;){for(c=E;c>w&&(P=Math.abs(i.get(c-1,c-1))+Math.abs(i.get(c,c)),0===P&&(P=S),!(Math.abs(i.get(c,c-1))<M*P));)c--;if(c===E)i.set(E,E,i.get(E,E)+N),n[E]=i.get(E,E),e[E]=0,E--,O=0;else if(c===E-1){if(h=i.get(E,E-1)*i.get(E-1,E),T=(i.get(E-1,E-1)-i.get(E,E))/2,k=T*T+h,A=Math.sqrt(Math.abs(k)),i.set(E,E,i.get(E,E)+N),i.set(E-1,E-1,i.get(E-1,E-1)+N),d=i.get(E,E),k>=0){for(A=T>=0?T+A:T-A,n[E-1]=d+A,n[E]=n[E-1],0!==A&&(n[E]=d-h/A),e[E-1]=0,e[E]=0,d=i.get(E,E-1),P=Math.abs(d)+Math.abs(A),T=d/P,k=A/P,C=Math.sqrt(T*T+k*k),T/=C,k/=C,a=E-1;a<t;a++)A=i.get(E-1,a),i.set(E-1,a,k*A+T*i.get(E,a)),i.set(E,a,k*i.get(E,a)-T*A);for(o=0;o<=E;o++)A=i.get(o,E-1),i.set(o,E-1,k*A+T*i.get(o,E)),i.set(o,E,k*i.get(o,E)-T*A);for(o=w;o<=x;o++)A=r.get(o,E-1),r.set(o,E-1,k*A+T*r.get(o,E)),r.set(o,E,k*r.get(o,E)-T*A)}else n[E-1]=d+T,n[E]=d+T,e[E-1]=A,e[E]=-A;E-=2,O=0}else{if(d=i.get(E,E),f=0,h=0,c<E&&(f=i.get(E-1,E-1),h=i.get(E,E-1)*i.get(E-1,E)),10===O){for(N+=d,o=w;o<=E;o++)i.set(o,o,i.get(o,o)-d);P=Math.abs(i.get(E,E-1))+Math.abs(i.get(E-1,E-2)),d=f=.75*P,h=-.4375*P*P}if(30===O&&(P=(f-d)/2,P=P*P+h,P>0)){for(P=Math.sqrt(P),f<d&&(P=-P),P=d-h/((f-d)/2+P),o=w;o<=E;o++)i.set(o,o,i.get(o,o)-P);N+=P,d=f=h=.964}for(O+=1,u=E-2;u>=c&&(A=i.get(u,u),C=d-A,P=f-A,T=(C*P-h)/i.get(u+1,u)+i.get(u,u+1),k=i.get(u+1,u+1)-A-C-P,C=i.get(u+2,u+1),P=Math.abs(T)+Math.abs(k)+Math.abs(C),T/=P,k/=P,C/=P,u!==c)&&!(Math.abs(i.get(u,u-1))*(Math.abs(k)+Math.abs(C))<M*(Math.abs(T)*(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<=E;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=E-1&&(y=s!==E-1,s!==u&&(T=i.get(s,s-1),k=i.get(s+1,s-1),C=y?i.get(s+2,s-1):0,d=Math.abs(T)+Math.abs(k)+Math.abs(C),0!==d&&(T/=d,k/=d,C/=d)),0!==d);s++)if(P=Math.sqrt(T*T+k*k+C*C),T<0&&(P=-P),0!==P){for(s!==u?i.set(s,s-1,-P*d):c!==u&&i.set(s,s-1,-i.get(s,s-1)),T+=P,d=T/P,f=k/P,A=C/P,k/=T,C/=T,a=s;a<t;a++)T=i.get(s,a)+k*i.get(s+1,a),y&&(T+=C*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-T*A)),i.set(s,a,i.get(s,a)-T*d),i.set(s+1,a,i.get(s+1,a)-T*f);for(o=0;o<=Math.min(E,s+3);o++)T=d*i.get(o,s)+f*i.get(o,s+1),y&&(T+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-T*C)),i.set(o,s,i.get(o,s)-T),i.set(o,s+1,i.get(o,s+1)-T*k);for(o=w;o<=x;o++)T=d*r.get(o,s)+f*r.get(o,s+1),y&&(T+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-T*C)),r.set(o,s,r.get(o,s)-T),r.set(o,s+1,r.get(o,s+1)-T*k)}}}if(0===S)return;for(E=t-1;E>=0;E--)if(T=n[E],k=e[E],0===k)for(c=E,i.set(E,E,1),o=E-1;o>=0;o--){for(h=i.get(o,o)-T,C=0,a=c;a<=E;a++)C+=i.get(o,a)*i.get(a,E);if(e[o]<0)A=h,P=C;else if(c=o,0===e[o]?i.set(o,E,0!==h?-C/h:-C/(M*S)):(d=i.get(o,o+1),f=i.get(o+1,o),k=(n[o]-T)*(n[o]-T)+e[o]*e[o],l=(d*P-A*C)/k,i.set(o,E,l),i.set(o+1,E,Math.abs(d)>Math.abs(A)?(-C-h*l)/d:(-P-f*l)/A)),l=Math.abs(i.get(o,E)),M*l*l>1)for(a=o;a<=E;a++)i.set(a,E,i.get(a,E)/l)}else if(k<0)for(c=E-1,Math.abs(i.get(E,E-1))>Math.abs(i.get(E-1,E))?(i.set(E-1,E-1,k/i.get(E,E-1)),i.set(E-1,E,-(i.get(E,E)-T)/i.get(E,E-1))):(b=Mv(0,-i.get(E-1,E),i.get(E-1,E-1)-T,k),i.set(E-1,E-1,b[0]),i.set(E-1,E,b[1])),i.set(E,E-1,0),i.set(E,E,1),o=E-2;o>=0;o--){for(p=0,g=0,a=c;a<=E;a++)p+=i.get(o,a)*i.get(a,E-1),g+=i.get(o,a)*i.get(a,E);if(h=i.get(o,o)-T,e[o]<0)A=h,C=p,P=g;else if(c=o,0===e[o]?(b=Mv(-p,-g,h,k),i.set(o,E-1,b[0]),i.set(o,E,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),m=(n[o]-T)*(n[o]-T)+e[o]*e[o]-k*k,v=2*(n[o]-T)*k,0===m&&0===v&&(m=M*S*(Math.abs(h)+Math.abs(k)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=Mv(d*C-A*p+k*g,d*P-A*g-k*p,m,v),i.set(o,E-1,b[0]),i.set(o,E,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(k)?(i.set(o+1,E-1,(-p-h*i.get(o,E-1)+k*i.get(o,E))/d),i.set(o+1,E,(-g-h*i.get(o,E)-k*i.get(o,E-1))/d)):(b=Mv(-C-f*i.get(o,E-1),-P-f*i.get(o,E),A,k),i.set(o+1,E-1,b[0]),i.set(o+1,E,b[1]))),l=Math.max(Math.abs(i.get(o,E-1)),Math.abs(i.get(o,E))),M*l*l>1)for(a=o;a<=E;a++)i.set(a,E-1,i.get(a,E-1)/l),i.set(a,E,i.get(a,E)/l)}for(o=0;o<t;o++)if(o<w||o>x)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<=x;o++){for(A=0,s=w;s<=Math.min(a,x);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 cv(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 Mv(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 Nv{constructor(t){if(!(t=pv.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new cv(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=pv.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 Sv{constructor(t,e={}){t=pv.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=Um.isAnyArray(n)&&"number"==typeof n[0]?cv.columnVector(n):pv.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()))}}jm.AbstractMatrix=av,jm.CHO=Nv,jm.CholeskyDecomposition=Nv,jm.DistanceMatrix=lv,jm.EVD=xv,jm.EigenvalueDecomposition=xv,jm.LU=gv,jm.LuDecomposition=gv;var Tv=jm.Matrix=cv;jm.MatrixColumnSelectionView=class extends hv{constructor(t,e){ev(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])}},jm.MatrixColumnView=class extends hv{constructor(t,e){Zm(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)}},jm.MatrixFlipColumnView=class extends hv{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)}},jm.MatrixFlipRowView=class extends hv{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)}},jm.MatrixRowSelectionView=class extends hv{constructor(t,e){tv(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)}},jm.MatrixRowView=class extends hv{constructor(t,e){Km(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)}},jm.MatrixSelectionView=dv,jm.MatrixSubView=class extends hv{constructor(t,e,n,r,i){nv(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)}},jm.MatrixTransposeView=class extends hv{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)}},jm.NIPALS=Sv,jm.Nipals=Sv,jm.QR=vv,jm.QrDecomposition=vv,jm.SVD=yv;var kv=jm.SingularValueDecomposition=yv;jm.SymmetricMatrix=uv,jm.WrapperMatrix1D=fv,jm.WrapperMatrix2D=pv,jm.correlation=function(t,e=t,n={}){t=new cv(t);let r=!1;if("object"!=typeof e||cv.isMatrix(e)||Um.isAnyArray(e)?e=new cv(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},jm.covariance=function(t,e=t,n={}){t=new cv(t);let r=!1;if("object"!=typeof e||cv.isMatrix(e)||Um.isAnyArray(e)?e=new cv(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 Cv=jm.default=cv;jm.determinant=function t(e){if((e=cv.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 dv(e,[1,2],[1,2]),a=new dv(e,[1,2],[0,2]),s=new dv(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 gv(e).determinant}throw Error("determinant can only be calculated for a square matrix")},jm.inverse=function(t,e=!1){return t=pv.checkMatrix(t),e?new yv(t).inverse():bv(t,cv.eye(t.rows))},jm.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=cv.checkMatrix(t)).rows,o=new cv(i,i);for(let e=0;e<i;e++){let a=cv.columnVector(t.getRow(e)),s=t.subMatrixRow(Ev(i,e)).transpose(),c=new yv(s).solve(a),u=cv.sub(a,s.mmul(c)).abs().max();o.setRow(e,wv(u,c,e,n,r))}return o},jm.pseudoInverse=function(t,e=Number.EPSILON){if((t=cv.checkMatrix(t)).isEmpty())return t.transpose();let n=new yv(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(cv.diag(o).mmul(r.transpose()))},jm.solve=bv,jm.wrap=function(t,e){if(Um.isAnyArray(t))return t[0]&&Um.isAnyArray(t[0])?new pv(t):new fv(t,e);throw new Error("the argument is not an array")};const Pv=Tv,Av=kv;Cv.Matrix&&Cv.Matrix;const Ov={center:[0,0],linkDistance:50};class Rv{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},Ov),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 c=Yg({nodes:a,edges:s},!1),u=$g(c);_v(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=Dv(l),d=[];h.forEach(((t,e)=>{const n=Qg(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 _v=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)}))}))},Dv=t=>{const e=Pv.mul(Pv.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 Av(e),a=Pv.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>Pv.mul([t],[a]).toJSON()[0].splice(0,2)))},Iv={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Lv={center:[0,0],comboPadding:10,treeKey:"combo"};function jv(t){return function(){return t}}function zv(t){return 1e-6*(t()-.5)}function Fv(t){return t.x+t.vx}function Bv(t){return t.y+t.vy}function Gv(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=pm(e,Fv,Bv).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=zv(r))*g),0===m&&(v+=(m=zv(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=jv(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:jv(+e),c(),a):t},a}function Vv(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 Wv(t){var e,n,r,i,o,a,s=Vv,c=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=jv(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||zv(a),f=h.y+h.vy-u.y-u.vy||zv(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=Uv(h,c.source)),"object"!=typeof c.target&&(c.target=Uv(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:jv(+t),f(),h):c},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:jv(+t),p(),h):u},h}var Hv={value:()=>{}};function qv(){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 $v(r)}function $v(t){this._=t}function Yv(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Xv(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Hv,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}$v.prototype=qv.prototype={constructor:$v,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]=Xv(i[n],t.name,e);else if(null==e)for(n in i)i[n]=Xv(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=Yv(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new $v(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 Kv,Zv,Qv=0,Jv=0,ty=0,ey=1e3,ny=0,ry=0,iy=0,oy="object"==typeof performance&&performance.now?performance:Date,ay="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function sy(){return ry||(ay(cy),ry=oy.now()+iy)}function cy(){ry=0}function uy(){this._call=this._time=this._next=null}function ly(t,e,n){var r=new uy;return r.restart(t,e,n),r}function hy(){ry=(ny=oy.now())+iy,Qv=Jv=0;try{!function(){sy(),++Qv;for(var t,e=Kv;e;)(t=ry-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qv}()}finally{Qv=0,function(){var t,e,n=Kv,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:Kv=e);Zv=t,fy(r)}(),ry=0}}function dy(){var t=oy.now(),e=t-ny;e>ey&&(iy-=e,ny=t)}function fy(t){Qv||(Jv&&(Jv=clearTimeout(Jv)),t-ry>24?(t<1/0&&(Jv=setTimeout(hy,t-oy.now()-iy)),ty&&(ty=clearInterval(ty))):(ty||(ny=oy.now(),ty=setInterval(dy,ey)),Qv=1,ay(hy)))}uy.prototype=ly.prototype={constructor:uy,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?sy():+n)+(null==e?0:+e),this._next||Zv===this||(Zv?Zv._next=this:Kv=this,Zv=this),this._call=t,this._time=n,fy()},stop:function(){this._call&&(this._call=null,this._time=1/0,fy())}};const py=1664525,gy=1013904223,my=4294967296;function vy(t){return t.x}function yy(t){return t.y}var by=10,Ey=Math.PI*(3-Math.sqrt(5));function wy(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,c=ly(h),u=qv("tick","end"),l=function(){let t=1;return()=>(t=(py*t+gy)%my)/my}();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=by*Math.sqrt(.5+n),o=n*Ey;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 xy(){var t,e,n,r,i,o=jv(-30),a=1,s=1/0,c=.81;function u(n){var i,o=t.length,a=pm(t,vy,yy).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=zv(n))*h),0===d&&(p+=(d=zv(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=zv(n))*h),0===d&&(p+=(d=zv(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:jv(+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 My(t){var e,n,r,i=jv(.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=jv(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:jv(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:jv(+e),a(),o):t},o}function Ny(t){var e,n,r,i=jv(.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=jv(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:jv(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:jv(+e),a(),o):t},o}function Sy(){function t(t){return()=>t}let e,n=t=>t.cluster,r=t(1),i=t(-1),o=t(100),a=t(.1),s=[0,0],c=[],u={},l=[],h=100,d=100,f={none:{x:0,y:0}},p=[],g="force",m=!0,v=.1;function y(t){if(!m)return y;e.tick(),E();for(let e,r=0,i=c.length,o=t*v;r<i;++r)e=c[r],e.vx+=(f[n(e)].x-e.x)*o,e.vy+=(f[n(e)].y-e.y)*o}function b(){c&&function(){if(!c||!c.length)return;if(void 0===n(c[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");const t=function(){const t=[],e=[],i={};let o=[],a={},s=[];return a=function(t){const e={};return t.forEach((t=>{const r=n(t);e[r]||(e[r]={count:0,sumforceNodeSize:0})})),t.forEach((t=>{const i=n(t),o=r(t),a=e[i];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=a})),e}(c),s=function(t){const e={},r=[];t.forEach((t=>{const r=function(t){const e=t.source,r=t.target,i=n(u[e]),o=n(u[r]);return i<=o?`${i}~${o}`:`${o}~${i}`}(t);let i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i}));return Object.entries(e).forEach((([t,e])=>{const n=t.split("~")[0],i=t.split("~")[1];void 0!==n&&void 0!==i&&r.push({source:n,target:i,count:e})})),r}(l),o=Object.keys(a),o.forEach(((e,n)=>{const r=a[e];t.push({id:e,size:r.count,r:Math.sqrt(r.sumforceNodeSize/Math.PI)}),i[e]=n})),s.forEach((t=>{const n=t.source,r=t.target,o=i[n],a=i[r];void 0!==o&&void 0!==a&&e.push({source:o,target:a,count:t.count})})),{nodes:t,links:e}}();e=wy(t.nodes).force("x",My(h).strength(.1)).force("y",Ny(d).strength(.1)).force("collide",Gv((t=>t.r)).iterations(4)).force("charge",xy().strength(i)).force("links",Wv(t.nodes.length?t.links:[]).distance(o).strength(a)),p=e.nodes(),E()}()}function E(){return f={none:{x:0,y:0}},p.forEach((t=>{f[t.id]={x:t.x-s[0],y:t.y-s[1]}})),f}return y.initialize=t=>{c=t,b()},y.template=function(t){return arguments.length?(g=t,b(),y):g},y.groupBy=function(t){return arguments.length?"string"==typeof t?(n=e=>e[t],y):(n=t,y):n},y.enableGrouping=function(t){return arguments.length?(m=t,y):m},y.strength=function(t){return arguments.length?(v=t,y):v},y.centerX=function(t){return arguments.length?(h=t,y):h},y.centerY=function(t){return arguments.length?(d=t,y):d},y.nodes=function(t){return arguments.length?(function(t){u={},t.forEach((t=>{u[t.id]=t}))}(t||[]),c=t||[],y):c},y.links=function(t){return arguments.length?(l=t||[],b(),y):l},y.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),b(),y):r},y.nodeSize=y.forceNodeSize,y.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),b(),y):i},y.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),b(),y):o},y.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),b(),y):a},y.offset=function(t){return arguments.length?(s=t,y):s},y.getFocis=E,y}const Ty={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10};const ky=t=>t.map((t=>{const{x:e,y:n}=t,r=o(t,["x","y"]);return Object.assign(Object.assign({},r),{data:Object.assign(Object.assign({},r.data),{x:e,y:n})})})),Cy=t=>t.map((t=>{const{source:e,target:n}=t,r=o(t,["source","target"]);return Object.assign(Object.assign({},r),{source:e.id,target:n.id})}));var Py,Ay,Oy,Ry,_y,Dy,Iy,Ly,jy,zy,Fy,By,Gy,Vy,Uy,Wy,Hy,qy,$y,Yy,Xy,Ky,Zy,Qy,Jy,tb,eb,nb,rb,ib,ob,ab,sb,cb,ub,lb,hb,db,fb,pb,gb,mb,vb,yb,bb,Eb,wb,xb,Mb,Nb,Sb,Tb,kb,Cb,Pb,Ab,Ob,Rb,_b,Db,Ib,Lb,jb,zb,Fb,Bb,Gb,Vb,Ub,Wb,Hb,qb,$b,Yb,Xb,Kb,Zb,Qb,Jb,tE,eE,nE,rE,iE,oE,aE,sE,cE,uE,lE,hE,dE,fE,pE,gE,mE,vE,yE,bE,EE,wE,xE,ME,NE,SE,TE,kE,CE;function PE(){if(Ry)return Oy;return Ry=1,Oy=function(t,e){return t===e||t!=t&&e!=e}}function AE(){if(Dy)return _y;Dy=1;var t=PE();return _y=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},_y}function OE(){if(Wy)return Uy;Wy=1;var t=Ay?Py:(Ay=1,Py=function(){this.__data__=[],this.size=0}),e=function(){if(Ly)return Iy;Ly=1;var t=AE(),e=Array.prototype.splice;return Iy=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))},Iy}(),n=function(){if(zy)return jy;zy=1;var t=AE();return jy=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},jy}(),r=function(){if(By)return Fy;By=1;var t=AE();return Fy=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(Vy)return Gy;Vy=1;var t=AE();return Gy=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},Gy}();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,Uy=o}function RE(){if(tb)return Jy;tb=1;var t="object"==typeof h&&h&&h.Object===Object&&h;return Jy=t}function _E(){if(nb)return eb;nb=1;var t=RE(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return eb=n}function DE(){if(ib)return rb;ib=1;var t=_E().Symbol;return rb=t}function IE(){if(lb)return ub;lb=1;var t=DE(),e=function(){if(ab)return ob;ab=1;var t=DE(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return ob=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(cb)return sb;cb=1;var t=Object.prototype.toString;return sb=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return ub=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function LE(){if(db)return hb;return db=1,hb=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function jE(){if(pb)return fb;pb=1;var t=IE(),e=LE();return fb=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 zE(){if(yb)return vb;yb=1;var t,e=function(){if(mb)return gb;mb=1;var t=_E()["__core-js_shared__"];return gb=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return vb=function(t){return!!n&&n in t}}function FE(){if(Eb)return bb;Eb=1;var t=Function.prototype.toString;return bb=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function BE(){if(Tb)return Sb;Tb=1;var t=function(){if(xb)return wb;xb=1;var t=jE(),e=zE(),n=LE(),r=FE(),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 wb=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=Nb?Mb:(Nb=1,Mb=function(t,e){return null==t?void 0:t[e]});return Sb=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function GE(){if(Cb)return kb;Cb=1;var t=BE()(_E(),"Map");return kb=t}function VE(){if(Ab)return Pb;Ab=1;var t=BE()(Object,"create");return Pb=t}function UE(){if(Vb)return Gb;Vb=1;var t=function(){if(Rb)return Ob;Rb=1;var t=VE();return Ob=function(){this.__data__=t?t(null):{},this.size=0}}(),e=Db?_b:(Db=1,_b=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Lb)return Ib;Lb=1;var t=VE(),e=Object.prototype.hasOwnProperty;return Ib=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},Ib}(),r=function(){if(zb)return jb;zb=1;var t=VE(),e=Object.prototype.hasOwnProperty;return jb=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},jb}(),i=function(){if(Bb)return Fb;Bb=1;var t=VE();return Fb=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},Fb}();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,Gb=o}function WE(){if(Yb)return $b;Yb=1;var t=qb?Hb:(qb=1,Hb=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return $b=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},$b}function HE(){if(iE)return rE;iE=1;var t=function(){if(Wb)return Ub;Wb=1;var t=UE(),e=OE(),n=GE();return Ub=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(Kb)return Xb;Kb=1;var t=WE();return Xb=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(Qb)return Zb;Qb=1;var t=WE();return Zb=function(e){return t(this,e).get(e)}}(),r=function(){if(tE)return Jb;tE=1;var t=WE();return Jb=function(e){return t(this,e).has(e)}}(),i=function(){if(nE)return eE;nE=1;var t=WE();return eE=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},eE}();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,rE=o}function qE(){if(cE)return sE;cE=1;var t=OE(),e=function(){if(qy)return Hy;qy=1;var t=OE();return Hy=function(){this.__data__=new t,this.size=0}}(),n=(Yy||(Yy=1,$y=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),$y),r=Ky?Xy:(Ky=1,Xy=function(t){return this.__data__.get(t)}),i=Qy?Zy:(Qy=1,Zy=function(t){return this.__data__.has(t)}),o=function(){if(aE)return oE;aE=1;var t=OE(),e=GE(),n=HE();return oE=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},oE}();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,sE=a}function $E(){if(lE)return uE;return lE=1,uE=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},uE}function YE(){if(dE)return hE;dE=1;var t=BE(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return hE=e}function XE(){if(pE)return fE;pE=1;var t=YE();return fE=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function KE(){if(mE)return gE;mE=1;var t=XE(),e=PE(),n=Object.prototype.hasOwnProperty;return gE=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 ZE(){if(yE)return vE;yE=1;var t=KE(),e=XE();return vE=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},vE}function QE(){if(xE)return wE;return xE=1,wE=function(t){return null!=t&&"object"==typeof t}}function JE(){if(TE)return SE;TE=1;var t=function(){if(NE)return ME;NE=1;var t=IE(),e=QE();return ME=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=QE(),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 SE=o}function tw(){if(CE)return kE;CE=1;var t=Array.isArray;return kE=t}var ew,nw,rw,iw,ow,aw,sw,cw,uw,lw,hw,dw={exports:{}};function fw(){return rw||(rw=1,function(t,e){var n=_E(),r=nw?ew:(nw=1,ew=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}(dw,dw.exports)),dw.exports}function pw(){if(ow)return iw;ow=1;var t=/^(?:0|[1-9]\d*)$/;return iw=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},iw}function gw(){if(sw)return aw;sw=1;return aw=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function mw(){if(hw)return lw;return hw=1,lw=function(t){return function(e){return t(e)}}}dw.exports;var vw,yw,bw,Ew,ww,xw,Mw,Nw,Sw,Tw,kw,Cw,Pw,Aw,Ow,Rw,_w,Dw,Iw,Lw,jw,zw,Fw,Bw,Gw,Vw,Uw,Ww={exports:{}};function Hw(){return vw||(vw=1,function(t,e){var n=RE(),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}(Ww,Ww.exports)),Ww.exports}function qw(){if(bw)return yw;bw=1;var t=function(){if(uw)return cw;uw=1;var t=IE(),e=gw(),n=QE(),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=mw(),n=Hw(),r=n&&n.isTypedArray,i=r?e(r):t;return yw=i}function $w(){if(ww)return Ew;ww=1;var t=(EE||(EE=1,bE=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),bE),e=JE(),n=tw(),r=fw(),i=pw(),o=qw(),a=Object.prototype.hasOwnProperty;return Ew=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},Ew}function Yw(){if(Mw)return xw;Mw=1;var t=Object.prototype;return xw=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function Xw(){if(Sw)return Nw;return Sw=1,Nw=function(t,e){return function(n){return t(e(n))}}}function Kw(){if(Pw)return Cw;Pw=1;var t=Yw(),e=function(){if(kw)return Tw;kw=1;var t=Xw()(Object.keys,Object);return Tw=t}(),n=Object.prototype.hasOwnProperty;return Cw=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 Zw(){if(Ow)return Aw;Ow=1;var t=jE(),e=gw();return Aw=function(n){return null!=n&&e(n.length)&&!t(n)}}function Qw(){if(_w)return Rw;_w=1;var t=$w(),e=Kw(),n=Zw();return Rw=function(r){return n(r)?t(r):e(r)}}function Jw(){if(Fw)return zw;Fw=1;var t=LE(),e=Yw(),n=jw?Lw:(jw=1,Lw=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return zw=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 tx(){if(Gw)return Bw;Gw=1;var t=$w(),e=Jw(),n=Zw();return Bw=function(r){return n(r)?t(r,!0):e(r)}}Ww.exports;var ex,nx,rx,ix,ox,ax,sx,cx,ux,lx,hx,dx,fx,px,gx,mx,vx,yx,bx,Ex,wx,xx,Mx,Nx,Sx,Tx,kx,Cx,Px,Ax,Ox,Rx,_x,Dx,Ix,Lx,jx,zx,Fx,Bx,Gx,Vx,Ux,Wx,Hx,qx,$x,Yx,Xx,Kx,Zx,Qx,Jx,tM,eM,nM,rM,iM,oM,aM,sM,cM,uM,lM,hM,dM,fM,pM,gM,mM,vM,yM,bM,EM,wM,xM,MM,NM,SM,TM,kM,CM,PM,AM,OM,RM,_M,DM,IM,LM,jM,zM,FM,BM,GM,VM,UM,WM,HM,qM,$M,YM,XM,KM,ZM,QM,JM,tN,eN,nN,rN,iN,oN,aN,sN,cN,uN,lN,hN,dN,fN,pN,gN,mN,vN,yN,bN,EN,wN,xN,MN,NN,SN,TN,kN,CN,PN,AN,ON,RN,_N,DN,IN,LN,jN,zN,FN,BN,GN,VN,UN,WN,HN,qN,$N,YN,XN,KN,ZN,QN,JN,tS,eS,nS,rS,iS,oS,aS,sS,cS,uS,lS,hS,dS,fS,pS,gS,mS,vS,yS,bS,ES,wS,xS,MS,NS,SS,TS,kS,CS,PS,AS,OS,RS,_S,DS,IS,LS,jS,zS,FS,BS,GS,VS,US,WS,HS,qS,$S,YS,XS,KS,ZS,QS,JS,tT,eT,nT,rT,iT,oT,aT,sT,cT,uT,lT,hT,dT,fT,pT,gT,mT,vT,yT,bT,ET,wT,xT,MT,NT,ST,TT,kT,CT,PT,AT,OT,RT,_T,DT,IT,LT,jT,zT,FT,BT,GT,VT,UT,WT,HT,qT,$T,YT,XT,KT,ZT,QT,JT,tk,ek,nk,rk,ik,ok,ak,sk,ck,uk,lk,hk={exports:{}};function dk(){return ex||(ex=1,function(t,e){var n=_E(),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}}(hk,hk.exports)),hk.exports}function fk(){if(rx)return nx;return rx=1,nx=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},nx}function pk(){if(ox)return ix;return ox=1,ix=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},ix}function gk(){if(sx)return ax;return sx=1,ax=function(){return[]}}function mk(){if(ux)return cx;ux=1;var t=pk(),e=gk(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return cx=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function vk(){if(fx)return dx;return fx=1,dx=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},dx}function yk(){if(gx)return px;gx=1;var t=Xw()(Object.getPrototypeOf,Object);return px=t}function bk(){if(vx)return mx;vx=1;var t=vk(),e=yk(),n=mk(),r=gk(),i=Object.getOwnPropertySymbols;return mx=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function Ek(){if(wx)return Ex;wx=1;var t=vk(),e=tw();return Ex=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function wk(){if(Mx)return xx;Mx=1;var t=Ek(),e=mk(),n=Qw();return xx=function(r){return t(r,n,e)}}function xk(){if(Ox)return Ax;Ox=1;var t=BE()(_E(),"Set");return Ax=t}function Mk(){if(Ix)return Dx;Ix=1;var t=function(){if(kx)return Tx;kx=1;var t=BE()(_E(),"DataView");return Tx=t}(),e=GE(),n=function(){if(Px)return Cx;Px=1;var t=BE()(_E(),"Promise");return Cx=t}(),r=xk(),i=function(){if(_x)return Rx;_x=1;var t=BE()(_E(),"WeakMap");return Rx=t}(),o=IE(),a=FE(),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}),Dx=v}function Nk(){if(Fx)return zx;Fx=1;var t=_E().Uint8Array;return zx=t}function Sk(){if(Gx)return Bx;Gx=1;var t=Nk();return Bx=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function Tk(){if(Xx)return Yx;Xx=1;var t=Sk();return Yx=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function kk(){if(Zx)return Kx;Zx=1;var t=Sk(),e=function(){if(Ux)return Vx;Ux=1;var t=Sk();return Vx=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(Hx)return Wx;Hx=1;var t=/\w*$/;return Wx=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if($x)return qx;$x=1;var t=DE(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return qx=function(t){return n?Object(n.call(t)):{}}}(),i=Tk();return Kx=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 Ck(){if(Jx)return Qx;Jx=1;var t=LE(),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 Qx=n}function Pk(){if(eM)return tM;eM=1;var t=Ck(),e=yk(),n=Yw();return tM=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function Ak(){if(oM)return iM;oM=1;var t=function(){if(rM)return nM;rM=1;var t=Mk(),e=QE();return nM=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=mw(),n=Hw(),r=n&&n.isMap,i=r?e(r):t;return iM=i}function Ok(){if(uM)return cM;uM=1;var t=function(){if(sM)return aM;sM=1;var t=Mk(),e=QE();return aM=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=mw(),n=Hw(),r=n&&n.isSet,i=r?e(r):t;return cM=i}function Rk(){if(hM)return lM;hM=1;var t=qE(),e=$E(),n=KE(),r=function(){if(Iw)return Dw;Iw=1;var t=ZE(),e=Qw();return Dw=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(Uw)return Vw;Uw=1;var t=ZE(),e=tx();return Vw=function(n,r){return n&&t(r,e(r),n)}}(),o=dk(),a=fk(),s=function(){if(hx)return lx;hx=1;var t=ZE(),e=mk();return lx=function(n,r){return t(n,e(n),r)}}(),c=function(){if(bx)return yx;bx=1;var t=ZE(),e=bk();return yx=function(n,r){return t(n,e(n),r)}}(),u=wk(),l=function(){if(Sx)return Nx;Sx=1;var t=Ek(),e=bk(),n=tx();return Nx=function(r){return t(r,n,e)}}(),h=Mk(),d=function(){if(jx)return Lx;jx=1;var t=Object.prototype.hasOwnProperty;return Lx=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},Lx}(),f=kk(),p=Pk(),g=tw(),m=fw(),v=Ak(),y=LE(),b=Ok(),E=Qw(),w=tx(),x="[object Arguments]",M="[object Function]",N="[object Object]",S={};return S[x]=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,lM=function T(k,C,P,A,O,R){var _,D=1&C,I=2&C,L=4&C;if(P&&(_=O?P(k,A,O,R):P(k)),void 0!==_)return _;if(!y(k))return k;var j=g(k);if(j){if(_=d(k),!D)return a(k,_)}else{var z=h(k),F=z==M||"[object GeneratorFunction]"==z;if(m(k))return o(k,D);if(z==N||z==x||F&&!O){if(_=I||F?{}:p(k),!D)return I?c(k,i(_,k)):s(k,r(_,k))}else{if(!S[z])return O?k:{};_=f(k,z,D)}}R||(R=new t);var B=R.get(k);if(B)return B;R.set(k,_),b(k)?k.forEach((function(t){_.add(T(t,C,P,t,k,R))})):v(k)&&k.forEach((function(t,e){_.set(e,T(t,C,P,e,k,R))}));var G=j?void 0:(L?I?l:u:I?w:E)(k);return e(G||k,(function(t,e){G&&(t=k[e=t]),n(_,e,T(t,C,P,e,k,R))})),_},lM}function _k(){if(fM)return dM;fM=1;var t=Rk();return dM=function(e){return t(e,4)}}function Dk(){if(gM)return pM;return gM=1,pM=function(t){return function(){return t}}}function Ik(){if(bM)return yM;bM=1;var t=(vM||(vM=1,mM=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}}),mM),e=t();return yM=e}function Lk(){if(wM)return EM;wM=1;var t=Ik(),e=Qw();return EM=function(n,r){return n&&t(n,r,e)}}function jk(){if(SM)return NM;SM=1;var t=Lk(),e=function(){if(MM)return xM;MM=1;var t=Zw();return xM=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}},xM}(),n=e(t);return NM=n}function zk(){if(kM)return TM;return kM=1,TM=function(t){return t}}function Fk(){if(PM)return CM;PM=1;var t=zk();return CM=function(e){return"function"==typeof e?e:t}}function Bk(){if(OM)return AM;OM=1;var t=$E(),e=jk(),n=Fk(),r=tw();return AM=function(i,o){return(r(i)?t:e)(i,n(o))}}function Gk(){return _M?RM:(_M=1,RM=Bk())}function Vk(){if(GM)return BM;GM=1;var t=HE(),e=jM?LM:(jM=1,LM=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=FM?zM:(FM=1,zM=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,BM=r}function Uk(){if(HM)return WM;return HM=1,WM=function(t,e){return t.has(e)}}function Wk(){if($M)return qM;$M=1;var t=Vk(),e=(UM||(UM=1,VM=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}),VM),n=Uk();return qM=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},qM}function Hk(){if(ZM)return KM;return ZM=1,KM=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},KM}function qk(){if(JM)return QM;JM=1;var t=DE(),e=Nk(),n=PE(),r=Wk(),i=(XM||(XM=1,YM=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),YM),o=Hk(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return QM=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 $k(){if(rN)return nN;rN=1;var t=qE(),e=Wk(),n=qk(),r=function(){if(eN)return tN;eN=1;var t=wk(),e=Object.prototype.hasOwnProperty;return tN=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 E=n.constructor,w=r.constructor;E==w||!("constructor"in n)||!("constructor"in r)||"function"==typeof E&&E instanceof E&&"function"==typeof w&&w instanceof w||(g=!1)}return s.delete(n),s.delete(r),g},tN}(),i=Mk(),o=tw(),a=fw(),s=qw(),c="[object Arguments]",u="[object Array]",l="[object Object]",h=Object.prototype.hasOwnProperty;return nN=function(d,f,p,g,m,v){var y=o(d),b=o(f),E=y?u:i(d),w=b?u:i(f),x=(E=E==c?l:E)==l,M=(w=w==c?l:w)==l,N=E==w;if(N&&a(d)){if(!a(f))return!1;y=!0,x=!1}if(N&&!x)return v||(v=new t),y||s(d)?e(d,f,p,g,m,v):n(d,f,E,p,g,m,v);if(!(1&p)){var S=x&&h.call(d,"__wrapped__"),T=M&&h.call(f,"__wrapped__");if(S||T){var k=S?d.value():d,C=T?f.value():f;return v||(v=new t),m(k,C,p,g,v)}}return!!N&&(v||(v=new t),r(d,f,p,g,m,v))}}function Yk(){if(oN)return iN;oN=1;var t=$k(),e=QE();return iN=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))},iN}function Xk(){if(uN)return cN;uN=1;var t=LE();return cN=function(e){return e==e&&!t(e)}}function Kk(){if(fN)return dN;return fN=1,dN=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function Zk(){if(gN)return pN;gN=1;var t=function(){if(sN)return aN;sN=1;var t=qE(),e=Yk();return aN=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},aN}(),e=function(){if(hN)return lN;hN=1;var t=Xk(),e=Qw();return lN=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},lN}(),n=Kk();return pN=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 Qk(){if(vN)return mN;vN=1;var t=IE(),e=QE();return mN=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function Jk(){if(bN)return yN;bN=1;var t=tw(),e=Qk(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return yN=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 tC(){if(MN)return xN;MN=1;var t=function(){if(wN)return EN;wN=1;var t=HE();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,EN=e}();return xN=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function eC(){if(kN)return TN;return kN=1,TN=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},TN}function nC(){if(ON)return AN;ON=1;var t=function(){if(PN)return CN;PN=1;var t=DE(),e=eC(),n=tw(),r=Qk(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return CN=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},CN}();return AN=function(e){return null==e?"":t(e)}}function rC(){if(_N)return RN;_N=1;var t=tw(),e=Jk(),n=function(){if(SN)return NN;SN=1;var t=tC(),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 NN=r}(),r=nC();return RN=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function iC(){if(IN)return DN;IN=1;var t=Qk();return DN=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function oC(){if(jN)return LN;jN=1;var t=rC(),e=iC();return LN=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},LN}function aC(){if(UN)return VN;UN=1;var t=rC(),e=JE(),n=tw(),r=pw(),i=gw(),o=iC();return VN=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))},VN}function sC(){if(HN)return WN;HN=1;var t=GN?BN:(GN=1,BN=function(t,e){return null!=t&&e in Object(t)}),e=aC();return WN=function(n,r){return null!=n&&e(n,r,t)}}function cC(){if($N)return qN;$N=1;var t=Yk(),e=function(){if(FN)return zN;FN=1;var t=oC();return zN=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=sC(),r=Jk(),i=Xk(),o=Kk(),a=iC();return qN=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 uC(){if(XN)return YN;return XN=1,YN=function(t){return function(e){return null==e?void 0:e[t]}}}function lC(){if(JN)return QN;JN=1;var t=uC(),e=function(){if(ZN)return KN;ZN=1;var t=oC();return KN=function(e){return function(n){return t(n,e)}}}(),n=Jk(),r=iC();return QN=function(i){return n(i)?t(r(i)):e(i)}}function hC(){if(eS)return tS;eS=1;var t=Zk(),e=cC(),n=zk(),r=tw(),i=lC();return tS=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 dC(){if(rS)return nS;rS=1;var t=pk(),e=function(){if(IM)return DM;IM=1;var t=jk();return DM=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},DM}(),n=hC(),r=tw();return nS=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function fC(){if(sS)return aS;sS=1;var t=function(){if(oS)return iS;oS=1;var t=Object.prototype.hasOwnProperty;return iS=function(e,n){return null!=e&&t.call(e,n)}}(),e=aC();return aS=function(n,r){return null!=n&&e(n,r,t)}}function pC(){if(uS)return cS;uS=1;var t=Kw(),e=Mk(),n=JE(),r=tw(),i=Zw(),o=fw(),a=Yw(),s=qw(),c=Object.prototype.hasOwnProperty;return cS=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 gC(){if(hS)return lS;return hS=1,lS=function(t){return void 0===t}}function mC(){if(fS)return dS;fS=1;var t=jk(),e=Zw();return dS=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},dS}function vC(){if(gS)return pS;gS=1;var t=eC(),e=hC(),n=mC(),r=tw();return pS=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function yC(){if(wS)return ES;wS=1;var t=(vS||(vS=1,mS=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}),mS),e=jk(),n=hC(),r=(bS||(bS=1,yS=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),yS),i=tw();return ES=function(o,a,s){var c=i(o)?t:r,u=arguments.length<3;return c(o,n(a,4),s,u,e)},ES}function bC(){if(OS)return AS;OS=1;var t=function(){if(SS)return NS;SS=1;var t=uC()("length");return NS=t}(),e=function(){if(kS)return TS;kS=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return TS=function(e){return t.test(e)}}(),n=function(){if(PS)return CS;PS=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 CS=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return AS=function(r){return e(r)?n(r):t(r)}}function EC(){if(_S)return RS;_S=1;var t=Kw(),e=Mk(),n=Zw(),r=function(){if(MS)return xS;MS=1;var t=IE(),e=tw(),n=QE();return xS=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=bC();return RS=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 wC(){if(IS)return DS;IS=1;var t=$E(),e=Ck(),n=Lk(),r=hC(),i=yk(),o=tw(),a=fw(),s=jE(),c=LE(),u=qw();return DS=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},DS}function xC(){if(FS)return zS;FS=1;var t=vk(),e=function(){if(jS)return LS;jS=1;var t=DE(),e=JE(),n=tw(),r=t?t.isConcatSpreadable:void 0;return LS=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return zS=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},zS}function MC(){if(US)return VS;US=1;var t=GS?BS:(GS=1,BS=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 VS=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)}},VS}function NC(){if(XS)return YS;XS=1;var t=function(){if(HS)return WS;HS=1;var t=Dk(),e=YE(),n=zk();return WS=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if($S)return qS;$S=1;var t=Date.now;return qS=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)}},qS}(),n=e(t);return YS=n}function SC(){if(ZS)return KS;ZS=1;var t=zk(),e=MC(),n=NC();return KS=function(r,i){return n(e(r,i,t),r+"")}}function TC(){if(JS)return QS;return JS=1,QS=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},QS}function kC(){if(oT)return iT;oT=1;var t=TC(),e=eT?tT:(eT=1,tT=function(t){return t!=t}),n=(rT||(rT=1,nT=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),nT);return iT=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function CC(){if(fT)return dT;fT=1;var t=xk(),e=hT?lT:(hT=1,lT=function(){}),n=Hk(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return dT=r}function PC(){if(gT)return pT;gT=1;var t=Vk(),e=function(){if(sT)return aT;sT=1;var t=kC();return aT=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(uT||(uT=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=Uk(),i=CC(),o=Hk();return pT=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},pT}function AC(){if(vT)return mT;vT=1;var t=Zw(),e=QE();return mT=function(n){return e(n)&&t(n)}}function OC(){if(bT)return yT;bT=1;var t=xC(),e=SC(),n=PC(),r=AC(),i=e((function(e){return n(t(e,1,r,!0))}));return yT=i}function RC(){if(MT)return xT;MT=1;var t=function(){if(wT)return ET;wT=1;var t=eC();return ET=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=Qw();return xT=function(n){return null==n?[]:t(n,e(n))}}function _C(){if(ST)return NT;var t;ST=1;try{t={clone:_k(),constant:Dk(),each:Gk(),filter:dC(),has:fC(),isArray:tw(),isEmpty:pC(),isFunction:jE(),isUndefined:gC(),keys:Qw(),map:vC(),reduce:yC(),size:EC(),transform:wC(),union:OC(),values:RC()}}catch(t){}return t||(t=window._),NT=t}function DC(){if(kT)return TT;kT=1;var t=_C();TT=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))},TT}function IC(){return OT?AT:(OT=1,AT={Graph:DC(),version:PT?CT:(PT=1,CT="2.1.8")})}function LC(){if(_T)return RT;_T=1;var t=_C(),e=DC();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 RT={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 jC(){if(IT)return DT;IT=1;var t=_C();return DT=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},DT}function zC(){if(jT)return LT;jT=1;var t=_C();function e(){this._arr=[],this._keyIndices={}}return LT=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},LT}function FC(){if(FT)return zT;FT=1;var t=_C(),e=zC();zT=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 zT}function BC(){if(GT)return BT;GT=1;var t=FC(),e=_C();return BT=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function GC(){if(UT)return VT;UT=1;var t=_C();return VT=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},VT}function VC(){if(HT)return WT;HT=1;var t=_C(),e=GC();return WT=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function UC(){if($T)return qT;$T=1;var t=_C();qT=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 qT}function WC(){if(XT)return YT;XT=1;var t=_C();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 YT=e,e.CycleException=n,n.prototype=new Error,YT}function HC(){if(ZT)return KT;ZT=1;var t=WC();return KT=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function qC(){if(JT)return QT;JT=1;var t=_C();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 QT=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},QT}function $C(){if(ek)return tk;ek=1;var t=qC();return tk=function(e,n){return t(e,n,"post")}}function YC(){if(rk)return nk;rk=1;var t=qC();return nk=function(e,n){return t(e,n,"pre")}}function XC(){if(ok)return ik;ok=1;var t=_C(),e=DC(),n=zC();return ik=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}}hk.exports;try{lk=function(){if(uk)return ck;uk=1;var t=IC();return ck={Graph:t.Graph,json:LC(),alg:sk?ak:(sk=1,ak={components:jC(),dijkstra:FC(),dijkstraAll:BC(),findCycles:VC(),floydWarshall:UC(),isAcyclic:HC(),postorder:$C(),preorder:YC(),prim:XC(),tarjan:GC(),topsort:WC()}),version:t.version}}()}catch(t){}lk||(lk=window.graphlib);var KC,ZC,QC,JC,tP,eP,nP,rP,iP,oP,aP,sP,cP,uP,lP,hP,dP,fP,pP,gP,mP,vP,yP,bP,EP,wP,xP,MP,NP,SP,TP,kP,CP,PP,AP,OP,RP,_P,DP,IP,LP,jP,zP,FP,BP,GP,VP,UP,WP,HP,qP,$P,YP,XP,KP,ZP,QP,JP,tA,eA,nA,rA,iA,oA,aA,sA,cA,uA,lA,hA,dA,fA,pA,gA,mA,vA,yA,bA,EA,wA,xA,MA,NA,SA,TA,kA,CA,PA,AA,OA,RA,_A,DA,IA=lk;function LA(){if(JC)return QC;JC=1;var t=PE(),e=Zw(),n=pw(),r=LE();return QC=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)},QC}function jA(){if(sP)return aP;sP=1;var t=function(){if(oP)return iP;oP=1;var t=/\s/;return iP=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},iP}(),e=/^\s+/;return aP=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function zA(){if(hP)return lP;hP=1;var t=function(){if(uP)return cP;uP=1;var t=jA(),e=LE(),n=Qk(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return cP=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 lP=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 FA(){if(gP)return pP;gP=1;var t=TC(),e=hC(),n=function(){if(fP)return dP;fP=1;var t=zA();return dP=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return pP=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)},pP}function BA(){if(bP)return yP;bP=1;var t=xC();return yP=function(e){return(null==e?0:e.length)?t(e,1):[]}}function GA(){if(kP)return TP;kP=1;var t=Qk();return TP=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},TP}function VA(){if(_P)return RP;_P=1;var t=XE(),e=PE();return RP=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function UA(){if(jP)return LP;return jP=1,LP=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function WA(){if(GP)return BP;GP=1;var t=VA(),e=dk(),n=Tk(),r=fk(),i=Pk(),o=JE(),a=tw(),s=AC(),c=fw(),u=jE(),l=LE(),h=function(){if(IP)return DP;IP=1;var t=IE(),e=yk(),n=QE(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return DP=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=qw(),f=UA(),p=function(){if(FP)return zP;FP=1;var t=ZE(),e=tx();return zP=function(n){return t(n,e(n))}}();return BP=function(g,m,v,y,b,E,w){var x=f(g,v),M=f(m,v),N=w.get(M);if(N)t(g,v,N);else{var S=E?E(x,M,v+"",g,m,w):void 0,T=void 0===S;if(T){var k=a(M),C=!k&&c(M),P=!k&&!C&&d(M);S=M,k||C||P?a(x)?S=x:s(x)?S=r(x):C?(T=!1,S=e(M,!0)):P?(T=!1,S=n(M,!0)):S=[]:h(M)||o(M)?(S=x,o(x)?S=p(x):l(x)&&!u(x)||(S=i(M))):T=!1}T&&(w.set(M,S),b(S,M,y,E,w),w.delete(M)),t(g,v,S)}}}function HA(){if(XP)return YP;return XP=1,YP=function(t,e){return t<e}}function qA(){if(oA)return iA;oA=1;var t=oC(),e=function(){if(rA)return nA;rA=1;var t=KE(),e=rC(),n=pw(),r=LE(),i=iC();return nA=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},nA}(),n=rC();return iA=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},iA}function $A(){if(gA)return pA;gA=1;var t=function(){if(fA)return dA;fA=1;var t=Math.ceil,e=Math.max;return dA=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},dA}(),e=LA(),n=zA();return pA=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)}},pA}function YA(){if(MA)return xA;MA=1;var t=function(){if(wA)return EA;wA=1;var t=Qk();return EA=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 xA=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},xA}function XA(){if(SA)return NA;SA=1;var t=eC(),e=oC(),n=hC(),r=mC(),i=(bA||(bA=1,yA=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),yA),o=mw(),a=YA(),s=zk(),c=tw();return NA=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)}))},NA}try{DA={cloneDeep:function(){if(ZC)return KC;ZC=1;var t=Rk();return KC=function(e){return t(e,5)}}(),constant:Dk(),defaults:function(){if(eP)return tP;eP=1;var t=SC(),e=PE(),n=LA(),r=tx(),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 tP=a}(),each:Gk(),filter:dC(),find:function(){if(vP)return mP;vP=1;var t=function(){if(rP)return nP;rP=1;var t=hC(),e=Zw(),n=Qw();return nP=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}},nP}(),e=t(FA());return mP=e}(),flatten:BA(),forEach:Bk(),forIn:function(){if(wP)return EP;wP=1;var t=Ik(),e=Fk(),n=tx();return EP=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:fC(),isUndefined:gC(),last:(MP||(MP=1,xP=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),xP),map:vC(),mapValues:function(){if(SP)return NP;SP=1;var t=XE(),e=Lk(),n=hC();return NP=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(OP)return AP;OP=1;var t=GA(),e=PP?CP:(PP=1,CP=function(t,e){return t>e}),n=zk();return AP=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if($P)return qP;$P=1;var t=function(){if(UP)return VP;UP=1;var t=qE(),e=VA(),n=Ik(),r=WA(),i=LE(),o=tx(),a=UA();return VP=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)},VP}(),e=function(){if(HP)return WP;HP=1;var t=SC(),e=LA();return WP=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}))},WP}(),n=e((function(e,n,r){t(e,n,r)}));return qP=n}(),min:function(){if(ZP)return KP;ZP=1;var t=GA(),e=HA(),n=zk();return KP=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(JP)return QP;JP=1;var t=GA(),e=hC(),n=HA();return QP=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(eA)return tA;eA=1;var t=_E();return tA=function(){return t.Date.now()}}(),pick:function(){if(hA)return lA;hA=1;var t=function(){if(sA)return aA;sA=1;var t=qA(),e=sC();return aA=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(uA)return cA;uA=1;var t=BA(),e=MC(),n=NC();return cA=function(r){return n(e(r,void 0,t),r+"")}}(),n=e((function(e,n){return null==e?{}:t(e,n)}));return lA=n}(),range:function(){if(vA)return mA;vA=1;var t=$A()();return mA=t}(),reduce:yC(),sortBy:function(){if(kA)return TA;kA=1;var t=xC(),e=XA(),n=SC(),r=LA(),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 TA=i}(),uniqueId:function(){if(PA)return CA;PA=1;var t=nC(),e=0;return CA=function(n){var r=++e;return t(n)+r},CA}(),values:RC(),zipObject:function(){if(_A)return RA;_A=1;var t=KE(),e=(OA||(OA=1,AA=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}),AA);return RA=function(n,r){return e(n||[],r||[],t)},RA}()}}catch(t){}DA||(DA=window._);var KA=DA,ZA=QA;function QA(){var t={};t._next=t._prev=t,this._sentinel=t}function JA(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function tO(t,e){if("_next"!==t&&"_prev"!==t)return e}QA.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return JA(e),e},QA.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&JA(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},QA.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,tO)),n=n._prev;return"["+t.join(", ")+"]"};var eO=KA,nO=IA.Graph,rO=ZA,iO=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new nO,r=0,i=0;eO.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),eO.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=eO.range(i+r+3).map((function(){return new rO})),a=r+1;return eO.forEach(n.nodes(),(function(t){sO(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||oO),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)aO(t,e,n,r);for(;r=o.dequeue();)aO(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(aO(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return eO.flatten(eO.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},oO=eO.constant(1);function aO(t,e,n,r,i){var o=i?[]:void 0;return eO.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,sO(e,n,s)})),eO.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,sO(e,n,a)})),t.removeNode(r.v),o}function sO(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 cO=KA,uO=iO,lO={run:function(t){var e="greedy"===t.graph().acyclicer?uO(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){cO.has(r,o)||(r[o]=!0,n[o]=!0,cO.forEach(t.outEdges(o),(function(t){cO.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return cO.forEach(t.nodes(),i),e}(t);cO.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,cO.uniqueId("rev"))}))},undo:function(t){cO.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=KA,dO=IA.Graph,fO={addDummyNode:pO,simplify:function(t){var e=(new dO).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 dO({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,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=hO.map(hO.range(gO(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 pO(t,"border",i,e)},maxRank:gO,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 pO(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 gO(t){return hO.max(hO.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!hO.isUndefined(n))return n})))}var mO=KA,vO=fO,yO={run:function(t){t.graph().dummyChains=[],mO.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=vO.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){mO.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 bO=KA,EO={longestPath:function(t){var e={};bO.forEach(t.sources(),(function n(r){var i=t.node(r);if(bO.has(e,r))return i.rank;e[r]=!0;var o=bO.min(bO.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 wO=KA,xO=IA.Graph,MO=EO.slack,NO=function(t){var e,n,r=new xO({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;SO(r,t)<o;)e=TO(r,t),n=r.hasNode(e.v)?MO(t,e):-MO(t,e),kO(r,t,n);return r};function SO(t,e){return wO.forEach(t.nodes(),(function n(r){wO.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||MO(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function TO(t,e){return wO.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return MO(e,n)}))}function kO(t,e,n){wO.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var CO=KA,PO=NO,AO=EO.slack,OO=EO.longestPath,RO=IA.alg.preorder,_O=IA.alg.postorder,DO=fO.simplify,IO=LO;function LO(t){t=DO(t),OO(t);var e,n=PO(t);for(FO(n),jO(n,t);e=GO(n);)UO(n,t,e,VO(n,t,e))}function jO(t,e){var n=_O(t,t.nodes());n=n.slice(0,n.length-1),CO.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=zO(t,e,n)}(t,e,n)}))}function zO(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,CO.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 FO(t,e){arguments.length<2&&(e=t.nodes()[0]),BO(t,{},1,e)}function BO(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,CO.forEach(t.neighbors(r),(function(i){CO.has(e,i)||(n=BO(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function GO(t){return CO.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function VO(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=CO.filter(e.edges(),(function(e){return c===WO(t,t.node(e.v),s)&&c!==WO(t,t.node(e.w),s)}));return CO.minBy(u,(function(t){return AO(e,t)}))}function UO(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),FO(t),jO(t,e),function(t,e){var n=CO.find(t.nodes(),(function(t){return!e.node(t).parent})),r=RO(t,n);r=r.slice(1),CO.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 WO(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}LO.initLowLimValues=FO,LO.initCutValues=jO,LO.calcCutValue=zO,LO.leaveEdge=GO,LO.enterEdge=VO,LO.exchangeEdges=UO;var HO=EO.longestPath,qO=NO,$O=IO,YO=function(t){switch(t.graph().ranker){case"network-simplex":default:KO(t);break;case"tight-tree":!function(t){HO(t),qO(t)}(t);break;case"longest-path":XO(t)}};var XO=HO;function KO(t){$O(t)}var ZO=KA,QO=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;ZO.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return ZO.forEach(t.children(),r),e}(t);ZO.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 JO=KA,tR=fO,eR={run:function(t){var e=tR.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&JO.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return JO.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=JO.max(JO.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,JO.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return JO.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;JO.forEach(t.children(),(function(a){nR(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,JO.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function nR(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var c=tR.addBorderNode(t,"_bt"),u=tR.addBorderNode(t,"_bb"),l=t.node(a);t.setParent(c,a),l.borderTop=c,t.setParent(u,a),l.borderBottom=u,JO.forEach(s,(function(s){nR(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 rR=KA,iR=fO,oR=function(t){rR.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&rR.forEach(r,e),rR.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)aR(t,"borderLeft","_bl",n,i,o),aR(t,"borderRight","_br",n,i,o)}}))};function aR(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],c=iR.addDummyNode(t,"border",a,n);i[e][o]=c,t.setParent(c,r),s&&t.setEdge(s,c,{weight:1})}var sR=KA,cR={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||uR(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){sR.forEach(t.nodes(),(function(e){hR(t.node(e))})),sR.forEach(t.edges(),(function(e){var n=t.edge(e);sR.forEach(n.points,hR),sR.has(n,"y")&&hR(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){sR.forEach(t.nodes(),(function(e){dR(t.node(e))})),sR.forEach(t.edges(),(function(e){var n=t.edge(e);sR.forEach(n.points,dR),sR.has(n,"x")&&dR(n)}))}(t),uR(t))}};function uR(t){sR.forEach(t.nodes(),(function(e){lR(t.node(e))})),sR.forEach(t.edges(),(function(e){lR(t.edge(e))}))}function lR(t){var e=t.width;t.width=t.height,t.height=e}function hR(t){t.y=-t.y}function dR(t){var e=t.x;t.x=t.y,t.y=e}var fR=KA,pR=function(t){var e={},n=fR.filter(t.nodes(),(function(e){return!t.children(e).length})),r=fR.max(fR.map(n,(function(e){return t.node(e).rank}))),i=fR.map(fR.range(r+1),(function(){return[]}));function o(n){if(!fR.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),fR.forEach(t.successors(n),o)}}var a=fR.sortBy(n,(function(e){return t.node(e).rank}));return fR.forEach(a,o),i};var gR=KA,mR=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=vR(t,e[r-1],e[r]);return n};function vR(t,e,n){for(var r=gR.zipObject(n,gR.map(n,(function(t,e){return e}))),i=gR.flatten(gR.map(e,(function(e){return gR.sortBy(gR.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=gR.map(new Array(a),(function(){return 0})),c=0;return gR.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 yR=KA;var bR=KA,ER=function(t,e){var n={};return bR.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};bR.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),bR.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];bR.isUndefined(e)||bR.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(bR.isUndefined(e.barycenter)||bR.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),bR.forEach(i.in.reverse(),n(i)),bR.forEach(i.out,r(i))}return bR.map(bR.filter(e,(function(t){return!t.merged})),(function(t){return bR.pick(t,["vs","i","barycenter","weight"])}))}(bR.filter(n,(function(t){return!t.indegree})))};var wR=KA,xR=fO;function MR(t,e,n){for(var r;e.length&&(r=wR.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var NR=KA,SR=function(t,e){return yR.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=yR.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}}))},TR=ER,kR=function(t,e){var n=xR.partition(t,(function(t){return wR.has(t,"barycenter")})),r=n.lhs,i=wR.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=MR(o,i,c),wR.forEach(r,(function(t){c+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,c=MR(o,i,c)}));var u;var l={vs:wR.flatten(o,!0)};s&&(l.barycenter=a/s,l.weight=s);return l},CR=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=NR.filter(o,(function(t){return t!==s&&t!==c})));var l=SR(e,o);NR.forEach(l,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,NR.has(o,"barycenter")&&(a=n,s=o,NR.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=TR(l,r);!function(t,e){NR.forEach(t,(function(t){t.vs=NR.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=kR(h,i);if(s&&(d.vs=NR.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]);NR.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 PR=KA,AR=IA.Graph,OR=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=PR.uniqueId("_root")););return e}(t),i=new AR({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return PR.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),PR.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=PR.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),PR.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var RR=KA;var _R=KA,DR=pR,IR=mR,LR=CR,jR=OR,zR=function(t,e,n){var r,i={};RR.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}}))},FR=IA.Graph,BR=fO,GR=function(t){var e=BR.maxRank(t),n=VR(t,_R.range(1,e+1),"inEdges"),r=VR(t,_R.range(e-1,-1,-1),"outEdges"),i=DR(t);WR(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,c=0;c<4;++s,++c){UR(s%2?n:r,s%4>=2),i=BR.buildLayerMatrix(t);var u=IR(t,i);u<a&&(c=0,o=_R.cloneDeep(i),a=u)}WR(t,o)};function VR(t,e,n){return _R.map(e,(function(e){return jR(t,e,n)}))}function UR(t,e){var n=new FR;_R.forEach(t,(function(t){var r=t.graph().root,i=LR(t,r,n,e);_R.forEach(i.vs,(function(e,n){t.node(e).order=n})),zR(t,n,i.vs)}))}function WR(t,e){_R.forEach(e,(function(e){_R.forEach(e,(function(e,n){t.node(e).order=n}))}))}var HR=KA,qR=IA.Graph,$R=fO,YR=function(t){var e,n=$R.buildLayerMatrix(t),r=HR.merge(XR(t,n),KR(t,n)),i={};HR.forEach(["u","d"],(function(o){e="u"===o?n:HR.values(n).reverse(),HR.forEach(["l","r"],(function(n){"r"===n&&(e=HR.map(e,(function(t){return HR.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=JR(t,e,r,a),c=t_(t,e,s.root,s.align,"r"===n);"r"===n&&(c=HR.mapValues(c,(function(t){return-t}))),i[o+n]=c}))}));var o=e_(t,i);return n_(i,o),r_(i,t.graph().align)};function XR(t,e){var n={};return HR.reduce(e,(function(e,r){var i=0,o=0,a=e.length,s=HR.last(r);return HR.forEach(r,(function(e,c){var u=function(t,e){if(t.node(e).dummy)return HR.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),l=u?t.node(u).order:a;(u||e===s)&&(HR.forEach(r.slice(o,c+1),(function(e){HR.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||l<a)||o.dummy&&t.node(e).dummy||ZR(n,r,e)}))})),o=c+1,i=l)})),r})),n}function KR(t,e){var n={};function r(e,r,i,o,a){var s;HR.forEach(HR.range(r,i),(function(r){s=e[r],t.node(s).dummy&&HR.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&ZR(n,e,s)}))}))}return HR.reduce(e,(function(e,n){var i,o=-1,a=0;return HR.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 ZR(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 QR(t,e,n){if(e>n){var r=e;e=n,n=r}return HR.has(t[e],n)}function JR(t,e,n,r){var i={},o={},a={};return HR.forEach(e,(function(t){HR.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),HR.forEach(e,(function(t){var e=-1;HR.forEach(t,(function(t){var s=r(t);if(s.length){s=HR.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]&&!QR(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}function t_(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new qR,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,HR.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,HR.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 HR.forEach(e,(function(e){var r;HR.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)),HR.forEach(r,(function(t){o[t]=o[n[t]]})),o}function e_(t,e){return HR.minBy(HR.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return HR.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 n_(t,e){var n=HR.values(e),r=HR.min(n),i=HR.max(n);HR.forEach(["u","d"],(function(n){HR.forEach(["l","r"],(function(o){var a,s=n+o,c=t[s];if(c!==e){var u=HR.values(c);(a="l"===o?r-HR.min(u):i-HR.max(u))&&(t[s]=HR.mapValues(c,(function(t){return t+a})))}}))}))}function r_(t,e){return HR.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=HR.sortBy(HR.map(t,r));return(i[1]+i[2])/2}))}var i_=KA,o_=fO,a_=YR,s_=function(t){(function(t){var e=o_.buildLayerMatrix(t),n=t.graph().ranksep,r=0;i_.forEach(e,(function(e){var i=i_.max(i_.map(e,(function(e){return t.node(e).height})));i_.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=o_.asNonCompoundGraph(t)),i_.forEach(a_(t),(function(e,n){t.node(n).x=e}))};var c_=KA,u_=lO,l_=yO,h_=YO,d_=fO.normalizeRanks,f_=QO,p_=fO.removeEmptyRanks,g_=eR,m_=oR,v_=cR,y_=GR,b_=s_,E_=fO,w_=IA.Graph,x_=function(t,e){var n=e&&e.debugTiming?E_.time:E_.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new w_({multigraph:!0,compound:!0}),n=R_(t.graph());return e.setGraph(c_.merge({},N_,O_(n,M_),c_.pick(n,S_))),c_.forEach(t.nodes(),(function(n){var r=R_(t.node(n));e.setNode(n,c_.defaults(O_(r,T_),k_)),e.setParent(n,t.parent(n))})),c_.forEach(t.edges(),(function(n){var r=R_(t.edge(n));e.setEdge(n,c_.merge({},P_,O_(r,C_),c_.pick(r,A_)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,c_.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){c_.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(){u_.run(t)})),e(" nestingGraph.run",(function(){g_.run(t)})),e(" rank",(function(){h_(E_.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){c_.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};E_.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){p_(t)})),e(" nestingGraph.cleanup",(function(){g_.cleanup(t)})),e(" normalizeRanks",(function(){d_(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;c_.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=c_.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){c_.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(){l_.run(t)})),e(" parentDummyChains",(function(){f_(t)})),e(" addBorderSegments",(function(){m_(t)})),e(" order",(function(){y_(t)})),e(" insertSelfEdges",(function(){!function(t){var e=E_.buildLayerMatrix(t);c_.forEach(e,(function(e){var n=0;c_.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,c_.forEach(i.selfEdges,(function(e){E_.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(){v_.adjust(t)})),e(" position",(function(){b_(t)})),e(" positionSelfEdges",(function(){!function(t){c_.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){c_.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(c_.last(n.borderLeft)),a=t.node(c_.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}})),c_.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){l_.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){c_.forEach(t.edges(),(function(e){var n=t.edge(e);if(c_.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(){v_.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)}c_.forEach(t.nodes(),(function(e){c(t.node(e))})),c_.forEach(t.edges(),(function(e){var n=t.edge(e);c_.has(n,"x")&&c(n)})),e-=a,r-=s,c_.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),c_.forEach(t.edges(),(function(n){var i=t.edge(n);c_.forEach(i.points,(function(t){t.x-=e,t.y-=r})),c_.has(i,"x")&&(i.x-=e),c_.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){c_.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(E_.intersectRect(o,n)),i.points.push(E_.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){c_.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){u_.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){c_.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))})),c_.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,c_.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 M_=["nodesep","edgesep","ranksep","marginx","marginy"],N_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S_=["acyclicer","ranker","rankdir","align"],T_=["width","height"],k_={width:0,height:0},C_=["minlen","weight","width","height","labeloffset"],P_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},A_=["labelpos"];function O_(t,e){return c_.mapValues(c_.pick(t,e),Number)}function R_(t){var e={};return c_.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var __=KA,D_=fO,I_=IA.Graph,L_={debugOrdering:function(t){var e=D_.buildLayerMatrix(t),n=new I_({compound:!0,multigraph:!0}).setGraph({});return __.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),__.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),__.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),__.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var j_={graphlib:IA,layout:x_,debug:L_,util:{time:fO.time,notime:fO.notime},version:"0.8.5"},z_=d(j_);class F_{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,F_.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 j_.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>Vt(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(Vt(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}(kt(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})})),z_.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}))}}F_.defaultOptions={};class B_{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 B_({rx:n,ry:r,mass:e,degree:i})}}class G_{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 G_({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 G_({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 G_({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 G_({xmid:t,ymid:e,length:n})}}class V_{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 V_(this.quad.NW()),this.NE=new V_(this.quad.NE()),this.SW=new V_(this.quad.SW()),this.SE=new V_(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 U_={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 W_={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};const H_={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 q_=(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},$_=(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},Y_=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,X_=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,K_=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},Z_=(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(;Y_(s,a);)K_(o,a);c=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],X_(s,a),K_(o,a)}t.data.x=c,t.data.y=u},Q_={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},J_=(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}}))}))},tD=(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},eD={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};const nD=(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=zt(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=zt(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},rD=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},iD=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},oD=(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}},aD=(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},sD={center:[0,0],width:300,height:300};function cD(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).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{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),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 E(){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 w(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 x(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 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],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],v=e[15],y=n*s-r*a,b=n*u-i*a,E=n*c-o*a,w=r*u-i*s,x=r*c-o*s,M=i*c-o*u,N=l*g-h*p,S=l*m-d*p,C=l*v-f*p,k=h*m-d*g,T=h*v-f*g,P=d*v-f*m,A=y*P-b*T+E*k+w*C-x*S+M*N;return A?(A=1/A,t[0]=(s*P-u*T+c*k)*A,t[1]=(i*T-r*P-o*k)*A,t[2]=(g*M-m*x+v*w)*A,t[3]=(d*x-h*M-f*w)*A,t[4]=(u*C-a*P-c*S)*A,t[5]=(n*P-i*C+o*S)*A,t[6]=(m*E-p*M-v*b)*A,t[7]=(l*M-d*E+f*b)*A,t[8]=(a*T-s*C+c*N)*A,t[9]=(r*C-n*T-o*N)*A,t[10]=(p*x-g*E+v*y)*A,t[11]=(h*E-l*x-f*y)*A,t[12]=(s*S-a*k-u*N)*A,t[13]=(n*k-r*S+i*N)*A,t[14]=(g*b-p*w-m*y)*A,t[15]=(l*w-h*b+d*y)*A,t):null}function k(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],v=e[14],y=e[15],b=n[0],E=n[1],w=n[2],x=n[3];return t[0]=b*r+E*s+w*h+x*g,t[1]=b*i+E*u+w*d+x*m,t[2]=b*o+E*c+w*f+x*v,t[3]=b*a+E*l+w*p+x*y,b=n[4],E=n[5],w=n[6],x=n[7],t[4]=b*r+E*s+w*h+x*g,t[5]=b*i+E*u+w*d+x*m,t[6]=b*o+E*c+w*f+x*v,t[7]=b*a+E*l+w*p+x*y,b=n[8],E=n[9],w=n[10],x=n[11],t[8]=b*r+E*s+w*h+x*g,t[9]=b*i+E*u+w*d+x*m,t[10]=b*o+E*c+w*f+x*v,t[11]=b*a+E*l+w*p+x*y,b=n[12],E=n[13],w=n[14],x=n[15],t[12]=b*r+E*s+w*h+x*g,t[13]=b*i+E*u+w*d+x*m,t[14]=b*o+E*c+w*f+x*v,t[15]=b*a+E*l+w*p+x*y,t}function P(t,e,n){var r,i,o,a,s,u,c,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],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*v+e[12],t[13]=i*g+u*m+d*v+e[13],t[14]=o*g+c*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],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 L(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=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,v=a*u,y=a*c;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 I(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],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 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,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 B(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,v=s*h,y=u*c,b=u*l,E=u*h,w=r[0],x=r[1],M=r[2],N=i[0],S=i[1],C=i[2],k=(1-(g+v))*w,T=(f+E)*w,P=(p-b)*w,A=(f-E)*x,O=(1-(d+v))*x,_=(m+y)*x,R=(p+b)*M,L=(m-y)*M,D=(1-(d+g))*M;return t[0]=k,t[1]=T,t[2]=P,t[3]=0,t[4]=A,t[5]=O,t[6]=_,t[7]=0,t[8]=R,t[9]=L,t[10]=D,t[11]=0,t[12]=n[0]+N-(k*N+A*S+R*C),t[13]=n[1]+S-(T*N+O*S+L*C),t[14]=n[2]+C-(P*N+_*S+D*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,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,v=o*u;return t[0]=1-h-p,t[1]=l+v,t[2]=d-m,t[3]=0,t[4]=l-v,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 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),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 U=W;function H(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 q(t,e,n,r){var i,o,a,s,u,c,l,h,d,f,p=e[0],g=e[1],m=e[2],y=r[0],b=r[1],E=r[2],w=n[0],x=n[1],M=n[2];return Math.abs(p-w)<v&&Math.abs(g-x)<v&&Math.abs(m-M)<v?N(t):(l=p-w,h=g-x,d=m-M,i=b*(d*=f=1/Math.hypot(l,h,d))-E*(h*=f),o=E*(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,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 $(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=T,K=$,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],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],v=e[15];return t[0]=s*(d*v-f*m)-h*(u*v-c*m)+g*(u*f-c*d),t[1]=-(r*(d*v-f*m)-h*(i*v-o*m)+g*(i*f-o*d)),t[2]=r*(u*v-c*m)-s*(i*v-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*v-f*m)-l*(u*v-c*m)+p*(u*f-c*d)),t[5]=n*(d*v-f*m)-l*(i*v-o*m)+p*(i*f-o*d),t[6]=-(n*(u*v-c*m)-a*(i*v-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*v-f*g)-l*(s*v-c*g)+p*(s*f-c*h),t[9]=-(n*(h*v-f*g)-l*(r*v-o*g)+p*(r*f-o*h)),t[10]=n*(s*v-c*g)-a*(r*v-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:x,create:E,determinant:k,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],y=t[15],b=e[0],E=e[1],w=e[2],x=e[3],M=e[4],N=e[5],S=e[6],C=e[7],k=e[8],T=e[9],P=e[10],A=e[11],O=e[12],_=e[13],R=e[14],L=e[15];return Math.abs(n-b)<=v*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-E)<=v*Math.max(1,Math.abs(r),Math.abs(E))&&Math.abs(i-w)<=v*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(o-x)<=v*Math.max(1,Math.abs(o),Math.abs(x))&&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(u-S)<=v*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-C)<=v*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(l-k)<=v*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(h-T)<=v*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(d-P)<=v*Math.max(1,Math.abs(d),Math.abs(P))&&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-L)<=v*Math.max(1,Math.abs(y),Math.abs(L))},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],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)),D(t,e,n),t},fromRotation:function(t,e,n){var r,i,o,a=n[0],s=n[1],u=n[2],c=Math.hypot(a,s,u);return c<v?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)},fromRotationTranslation:D,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,v=s*u,y=s*c,b=s*l,E=r[0],w=r[1],x=r[2];return t[0]=(1-(p+m))*E,t[1]=(d+b)*E,t[2]=(f-y)*E,t[3]=0,t[4]=(d-b)*w,t[5]=(1-(h+m))*w,t[6]=(g+v)*w,t[7]=0,t[8]=(f+y)*x,t[9]=(g-v)*x,t[10]=(1-(h+p))*x,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:B,fromScaling:L,fromTranslation:R,fromValues:function(t,e,n,r,i,o,a,s,u,c,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]=u,m[9]=c,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),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:z,getScaling:j,getTranslation:I,identity:N,invert:C,lookAt:q,mul:Y,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: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),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: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,u,c,l,h,d,f,p,g,m,y,b,E,w,x,M,N,S,C,k,T,P=r[0],A=r[1],O=r[2],_=Math.hypot(P,A,O);return _<v?null:(P*=_=1/_,A*=_,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],y=e[10],b=e[11],E=P*P*a+o,w=A*P*a+O*i,x=O*P*a-A*i,M=P*A*a-O*i,N=A*A*a+o,S=O*A*a+P*i,C=P*O*a+A*i,k=A*O*a-P*i,T=O*O*a+o,t[0]=s*E+h*w+g*x,t[1]=u*E+d*w+m*x,t[2]=c*E+f*w+y*x,t[3]=l*E+p*w+b*x,t[4]=s*M+h*N+g*S,t[5]=u*M+d*N+m*S,t[6]=c*M+f*N+y*S,t[7]=l*M+p*N+b*S,t[8]=s*C+h*k+g*T,t[9]=u*C+d*k+m*T,t[10]=c*C+f*k+y*T,t[11]=l*C+p*k+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: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:$,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:P,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 ut(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 ct(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],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 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 Et(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}Z(),function(){var t=pt()}();var wt=function(t,e,n,r){var i=new y(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i},xt=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},kt=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)}))},Tt=function(t){return"function"==typeof t},Pt=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 Lt(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 Dt=function(t){return"object"==typeof t&&null!==t},It=function(t){if(!Dt(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=Tt(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 qt=function(t,e){return(t%e+e)%e},$t=function(t){return Pt(t)?"":t.toString()},Yt=function(t){var e=$t(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&&It(o)?(It(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(Pt(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(Dt(t)||Dt(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},ue=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},ce=Object.prototype.hasOwnProperty,le=function(t,e){return function(t,e,n){if(!_t(t)&&!It(t))return t;var r=n;return Lt(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},he={},de=function(){},fe={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function pe(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 ge={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function me(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return ge[e]===t.length-1&&"achlmqstvz".includes(e)}))}function ve(t){return me(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function ye(t){return ve(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function be(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=ge[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,ge[n]))),ge[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 xe(t){return t>=48&&t<=57}function Me(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)),xe(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&xe(e))return void(t.err="[path-util]: Invalid path value at index "+i+', "'+r[i]+'" illegal number');for(;o<n&&xe(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(c=!0,o+=1;xe(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&&xe(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index "+o+', "'+r[o]+'" invalid integer exponent');for(;o<n&&xe(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 Ne(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 Se(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=ge[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,Ne(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?Me(t):Ee(t),t.err.length)return;t.data.push(t.param),Ne(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,Ne(t))}if(t.index>=t.max)break;if(!we(n.charCodeAt(t.index)))break}be(t)}else be(t);else t.err='[path-util]: Invalid path value "'+n[r]+'" is not a path command'}var Ce=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 ke(t){if(ve(t))return[].concat(t);var e=function(t){if(me(t))return[].concat(t);var e=new Ce(t);for(Ne(e);e.index<e.max&&!e.err.length;)Se(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 Te(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 Pe(t){if(ye(t))return[].concat(t);for(var e=ke(t),n=i({},fe),r=0;r<e.length;r+=1){e[r]=Te(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 Ae(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function Oe(t,e,n,r,i,o,a,s,u,c){var l,h,d,f,p,g=t,m=e,v=n,y=r,b=s,E=u,w=120*Math.PI/180,x=Math.PI/180*(+i||0),M=[];if(c)h=c[0],d=c[1],f=c[2],p=c[3];else{g=(l=Ae(g,m,-x)).x,m=l.y;var N=(g-(b=(l=Ae(b,E,-x)).x))/2,S=(m-(E=l.y))/2,C=N*N/(v*v)+S*S/(y*y);C>1&&(v*=C=Math.sqrt(C),y*=C);var k=v*v,T=y*y,P=(o===a?-1:1)*Math.sqrt(Math.abs((k*T-k*S*S-T*N*N)/(k*S*S+T*N*N)));f=P*v*S/y+(g+b)/2,p=P*-y*N/v+(m+E)/2,h=Math.asin(((m-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),d=Math.asin(((E-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)>w){var O=d,_=b,R=E;d=h+w*(a&&d>h?1:-1),M=Oe(b=f+v*Math.cos(d),E=p+y*Math.sin(d),v,y,i,0,a,_,R,[d,O,f,p])}A=d-h;var L=Math.cos(h),D=Math.sin(h),I=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*D,m-F*L],W=[b+B*j,E-F*I],U=[b,E];if(V[0]=2*G[0]-V[0],V[1]=2*G[1]-V[1],c)return V.concat(W,U,M);for(var H=[],q=0,$=(M=V.concat(W,U,M)).length;q<$;q+=1)H[q]=q%2?Ae(M[q-1],M[q],x).y:Ae(M[q],M[q+1],x).x;return H}function _e(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var Re=function(t,e,n,r){return l(l([],_e([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function Le(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,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(Oe(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(Re(g,m,f,p));case"Z":return g===v&&m===y?["C",g,m,v,y,v,y]:["C"].concat(Re(g,m,v,y))}return t}function De(t,e){if(void 0===e&&(e=!1),function(t){return ye(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=Pe(t),s=i({},fe),u=[],c="",l=a.length,h=[],d=0;d<l;d+=1){a[d]&&(c=a[d][0]),u[d]=c;var f=Le(a[d],s);a[d]=f,pe(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 Ie(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function je(t,e,n,r,i){var o=Ie([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=_e([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 ze(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 Be(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),v=(i%360+360)%360*(p/180);if(t===s&&e===u)return{x:t,y:e};if(0===g||0===m)return je(t,e,s,u,c).point;var y=(t-s)/2,b=(e-u)/2,E={x:d(v)*y+h(v)*b,y:-h(v)*y+d(v)*b},w=Math.pow(E.x,2)/Math.pow(g,2)+Math.pow(E.y,2)/Math.pow(m,2);w>1&&(g*=f(w),m*=f(w));var x=(Math.pow(g,2)*Math.pow(m,2)-Math.pow(g,2)*Math.pow(E.y,2)-Math.pow(m,2)*Math.pow(E.x,2))/(Math.pow(g,2)*Math.pow(E.y,2)+Math.pow(m,2)*Math.pow(E.x,2)),M=(o!==a?1:-1)*f(x=x<0?0:x),N=M*(g*E.y/m),S=M*(-m*E.x/g),C=d(v)*N-h(v)*S+(t+s)/2,k=h(v)*N+d(v)*S+(e+u)/2,T={x:(E.x-N)/g,y:(E.y-S)/m},P=ze({x:1,y:0},T),A=ze(T,{x:(-E.x-N)/g,y:(-E.y-S)/m});!a&&A>0?A-=2*p:a&&A<0&&(A+=2*p);var O=P+(A%=2*p)*c,_=g*d(O),R=m*h(O);return{x:d(v)*_-h(v)*R+C,y:h(v)*_+d(v)*R+k}}function Fe(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,v=void 0===m?30:m,y="number"==typeof c,b=t,E=e,w=0,x=[b,E,w],M=[b,E],N={x:0,y:0},S=[{x:b,y:E}];y&&c<=0&&(N={x:b,y:E});for(var C=0;C<=v;C+=1){if(b=(h=Be(t,e,n,r,i,o,a,s,u,C/v)).x,E=h.y,f&&S.push({x:b,y:E}),g&&(w+=Ie(M,[b,E])),M=[b,E],y&&w>=c&&c>x[2]){var k=(w-c)/(w-x[2]);N={x:M[0]*(1-k)+x[0]*k,y:M[1]*(1-k)+x[1]*k}}x=[b,E,w]}return y&&c>=w&&(N={x:s,y:u}),{length:w,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 Ge(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 Ve(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,v="number"==typeof u,y=t,b=e,E=0,w=[y,b,E],x=[y,b],M={x:0,y:0},N=[{x:y,y:b}];v&&u<=0&&(M={x:y,y:b});for(var S=0;S<=m;S+=1){if(y=(l=Ge(t,e,n,r,i,o,a,s,S/m)).x,b=l.y,d&&N.push({x:y,y:b}),p&&(E+=Ie(x,[y,b])),x=[y,b],v&&E>=u&&u>w[2]){var C=(E-u)/(E-w[2]);M={x:x[0]*(1-C)+w[0]*C,y:x[1]*(1-C)+w[1]*C}}w=[y,b,E]}return v&&u>=E&&(M={x:a,y:s}),{length:E,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 We(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 Ue(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,v=e,y=0,b=[m,v,y],E=[m,v],w={x:0,y:0},x=[{x:m,y:v}];g&&a<=0&&(w={x:m,y:v});for(var M=0;M<=p;M+=1){if(m=(u=We(t,e,n,r,i,o,M/p)).x,v=u.y,l&&x.push({x:m,y:v}),d&&(y+=Ie(E,[m,v])),E=[m,v],g&&y>=a&&a>b[2]){var N=(y-a)/(y-b[2]);w={x:E[0]*(1-N)+b[0]*N,y:E[1]*(1-N)+b[1]*N}}b=[m,v,y]}return g&&a>=y&&(w={x:i,y:o}),{length:y,point:w,min:{x:Math.min.apply(null,x.map((function(t){return t.x}))),y:Math.min.apply(null,x.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 He(t,e,n){for(var r,i,o,a,s,u,c,l,h,d=Pe(t),f="number"==typeof e,p=[],g=0,m=0,v=0,y=0,b=[],E=[],w=0,x={x:0,y:0},M=x,N=x,S=x,C=0,k=0,T=d.length;k<T;k+=1)p=(c="M"===(l=(h=d[k])[0]))?p:[g,m].concat(h.slice(1)),c?(M=x={x:v=h[1],y:y=h[2]},w=0,f&&e<.001&&(S=x)):"L"===l?(w=(r=je(p[0],p[1],p[2],p[3],(e||0)-C)).length,x=r.min,M=r.max,N=r.point):"A"===l?(w=(i=Fe(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-C,n||{})).length,x=i.min,M=i.max,N=i.point):"C"===l?(w=(o=Ve(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-C,n||{})).length,x=o.min,M=o.max,N=o.point):"Q"===l?(w=(a=Ue(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-C,n||{})).length,x=a.min,M=a.max,N=a.point):"Z"===l&&(w=(s=je((p=[g,m,v,y])[0],p[1],p[2],p[3],(e||0)-C)).length,x=s.min,M=s.max,N=s.point),f&&C<e&&C+w>=e&&(S=N),E.push(M),b.push(x),C+=w,g=(u="Z"!==l?h.slice(-2):[v,y])[0],m=u[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,E.map((function(t){return t.x}))),y:Math.max.apply(null,E.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+=Ie(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 $e(t){return function(t){var e=0,n=0,r=0;return De(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 Ye(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?Ve(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=_e(n,r,e),s=_e(r,i,e),u=_e(i,o,e),c=_e(a,s,e),l=_e(s,u,e),h=_e(c,l,e);return[["C"].concat(a,c,h),["C"].concat(l,u,o)]}(r):[t,t]:[t],l:i}}))}function Ke(t,e,n){var r=Ye(t),i=Ye(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:Ke(g[0],g[1],h)}function Xe(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function Ze(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Qe(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Je(){}var tn=.7,en=1/tn,nn="\\s*([+-]?\\d+)\\s*",rn="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",on="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",an=/^#([0-9a-f]{3,8})$/,sn=new RegExp("^rgb\\("+[nn,nn,nn]+"\\)$"),un=new RegExp("^rgb\\("+[on,on,on]+"\\)$"),cn=new RegExp("^rgba\\("+[nn,nn,nn,rn]+"\\)$"),ln=new RegExp("^rgba\\("+[on,on,on,rn]+"\\)$"),hn=new RegExp("^hsl\\("+[rn,on,on]+"\\)$"),dn=new RegExp("^hsla\\("+[rn,on,on,rn]+"\\)$"),fn={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 pn(){return this.rgb().formatHex()}function gn(){return this.rgb().formatRgb()}function mn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=an.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?vn(e):3===n?new bn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?yn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?yn(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=sn.exec(t))?new bn(e[1],e[2],e[3],1):(e=un.exec(t))?new bn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=cn.exec(t))?yn(e[1],e[2],e[3],e[4]):(e=ln.exec(t))?yn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=hn.exec(t))?Mn(e[1],e[2]/100,e[3]/100,1):(e=dn.exec(t))?Mn(e[1],e[2]/100,e[3]/100,e[4]):fn.hasOwnProperty(t)?vn(fn[t]):"transparent"===t?new bn(NaN,NaN,NaN,0):null}function vn(t){return new bn(t>>16&255,t>>8&255,255&t,1)}function yn(t,e,n,r){return r<=0&&(t=e=n=NaN),new bn(t,e,n,r)}function bn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function En(){return"#"+xn(this.r)+xn(this.g)+xn(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 xn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Mn(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Sn(t,e,n,r)}function Nn(t){if(t instanceof Sn)return new Sn(t.h,t.s,t.l,t.opacity);if(t instanceof Je||(t=mn(t)),!t)return new Sn;if(t instanceof Sn)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 Sn(a,s,u,t.opacity)}function Sn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Cn(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 kn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function Tn(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 Pn(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function An(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function On(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=Pn(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,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=An(0,e,n,r,i,v[h]);b<g&&(g=b),b>m&&(m=b)}return{x:u,y:g,width:c-u,height:m-g}}Ze(Je,mn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:pn,formatHex:pn,formatHsl:function(){return Nn(this).formatHsl()},formatRgb:gn,toString:gn}),Ze(bn,(function(t,e,n,r){return 1===arguments.length?((i=t)instanceof Je||(i=mn(i)),i?new bn((i=i.rgb()).r,i.g,i.b,i.opacity):new bn):new bn(t,e,n,null==r?1:r);var i}),Qe(Je,{brighter:function(t){return t=null==t?en:Math.pow(en,t),new bn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?tn:Math.pow(tn,t),new bn(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})),Ze(Sn,(function(t,e,n,r){return 1===arguments.length?Nn(t):new Sn(t,e,n,null==r?1:r)}),Qe(Je,{brighter:function(t){return t=null==t?en:Math.pow(en,t),new Sn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?tn:Math.pow(tn,t),new Sn(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 bn(Cn(t>=240?t-240:t+120,i,r),Cn(t,i,r),Cn(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 _n=1e-4;function Rn(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))];(E=kn(u[0],u[1],m[0],m[1]))<s&&(a=g,s=E)}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<_n);p++){var y=a-f,b=a+f,E=(m=[i.apply(void 0,l([],c(t.concat([y])),!1)),i.apply(void 0,l([],c(e.concat([y])),!1))],kn(u[0],u[1],m[0],m[1]));if(y>=0&&E<s)a=y,s=E;else{var w=[i.apply(void 0,l([],c(t.concat([b])),!1)),i.apply(void 0,l([],c(e.concat([b])),!1))],x=kn(u[0],u[1],w[0],w[1]);b<=1&&x<s?(a=b,s=x):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 Ln(t,e,n,r){return kn(t,e,n,r)}function Dn(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function In(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 jn(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 zn(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(Ht(s,0))Ht(u,0)||(i=-c/u)>=0&&i<=1&&l.push(i);else{var h=u*u-4*s*c;Ht(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 Bn(t,e,n,r,i,o,a,s){for(var u=[t,a],c=[e,s],l=zn(t,n,i,a),h=zn(e,r,o,s),d=0;d<l.length;d++)u.push(jn(t,n,i,a,l[d]));for(d=0;d<h.length;d++)c.push(jn(e,r,o,s,h[d]));return Tn(u,c)}function Fn(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 Rn([t,n,i,a],[e,r,o,s],u,c,jn,l)}(t,e,n,r,i,o,a,s,u,c,l);return kn(h.x,h.y,u,c)}function Gn(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+=kn(r[0],r[1],i[0],i[1])}return e}(t)}function Vn(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function Wn(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 Un(t,e,n,r,i,o){var a=Wn(t,n,i)[0],s=Wn(e,r,o)[0],u=[t,i],c=[e,o];return void 0!==a&&u.push(Vn(t,n,i,a)),void 0!==s&&c.push(Vn(e,r,o,s)),Tn(u,c)}function Hn(t,e,n,r,i,o,a,s){var u=function(t,e,n,r,i,o,a,s){return Rn([t,n,i],[e,r,o],a,s,Vn)}(t,e,n,r,i,o,a,s);return kn(u.x,u.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,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=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];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 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),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=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 u=Math.ceil(o/s),c=u*Math.ceil(Math.sqrt(s));y(t,e,n,c,this.compareMinX);for(var l=e;l<=n;l+=c){var h=Math.min(l+c-1,n);y(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=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 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}()}(qn);var $n,Yn,Kn=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"}($n||($n={})),function(t){t[t.ZERO=0]="ZERO",t[t.NEGATIVE_ONE=1]="NEGATIVE_ONE"}(Yn||(Yn={}));var Xn=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}(),Zn=function(){function t(t){this.clipSpaceNearZ=Yn.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 Qn(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Jn(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[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,t[1]=e[1]*n,t[2]=e[2]*n,t}function nr(t){return void 0===t?0:t>360||t<-360?t%360:t}function rr(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 ir(t){return t*(Math.PI/180)}function or(t){return t*(180/Math.PI)}function ar(t,e){return 16===e.length?function(t,e){var n,r,i=.5*Math.PI,o=c(j(Z(),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 sr(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 y(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 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=or(Math.atan2(n,e));return[t[6],t[7],o,a,s]}var cr=E(),lr=E(),hr=pt(),dr=[Z(),Z(),Z()],fr=Z();function pr(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 gr,mr=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){Qn(this.center,t),Qn(this.halfExtents,e),Jn(this.min,this.center,this.halfExtents),tr(this.max,this.center,this.halfExtents)},t.prototype.setMinMax=function(t,e){tr(this.center,e,t),er(this.center,this.center,.5),Jn(this.halfExtents,e,t),er(this.halfExtents,this.halfExtents,.5),Qn(this.min,t),Qn(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,v=m[0],y=m[1],b=m[2],E=e.halfExtents,w=E[0],x=E[1],M=E[2],N=v-w,S=v+w,C=y-x,k=y+x,T=b-M,P=b+M;N<l&&(l=N),S>h&&(h=S),C<d&&(d=C),k>f&&(f=k),T<p&&(p=T),P>g&&(g=P),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),v=Math.abs(u),y=Math.abs(c),b=Math.abs(l),E=Math.abs(h),w=Math.abs(d),x=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]+v*o[2],r[1]=y*o[0]+b*o[1]+E*o[2],r[2]=w*o[0]+x*o[1]+M*o[2],Jn(this.min,n,r),tr(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?Qn([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?Qn([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}(),vr=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&&ct(n,t,e,i),o},t}();!function(t){t[t.OUTSIDE=4294967295]="OUTSIDE",t[t.INSIDE=0]="INSIDE",t[t.INDETERMINATE=2147483647]="INDETERMINATE"}(gr||(gr={}));var yr,br,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 vr)}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],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-u,p-f),this.planes[4].distance=y-v,nt(this.planes[5].normal,o+i,l+u,p+f),this.planes[5].distance=y+v,this.planes.forEach((function(t){t.normalize(),t.updatePNVertexFlag()}))},t}(),xr=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}(),Mr=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}(),Nr="Method not implemented.",Sr="Use document.documentElement instead.";!function(t){t[t.ORBITING=0]="ORBITING",t[t.EXPLORING=1]="EXPLORING",t[t.TRACKING=2]="TRACKING"}(yr||(yr={})),function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ROTATIONAL=1]="ROTATIONAL",t[t.TRANSLATIONAL=2]="TRANSLATIONAL",t[t.CINEMATIC=3]="CINEMATIC"}(br||(br={})),function(t){t[t.ORTHOGRAPHIC=0]="ORTHOGRAPHIC",t[t.PERSPECTIVE=1]="PERSPECTIVE"}(Er||(Er={}));var Cr,kr,Tr,Pr,Ar,Or="updated",_r=2e-4,Rr=function(){function t(){this.clipSpaceNearZ=Yn.NEGATIVE_ONE,this.eventEmitter=new m,this.matrix=E(),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=E(),this.projectionMatrixInverse=E(),this.jitteredProjectionMatrix=void 0,this.enableUpdate=!0,this.type=yr.EXPLORING,this.trackingMode=br.DEFAULT,this.projectionMode=Er.PERSPECTIVE,this.frustum=new wr,this.orthoMatrix=E()}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===yr.EXPLORING?this.setWorldRotation(!0):this.setWorldRotation(!1),this._getAngles(),this.type===yr.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!==yr.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(E(),this.matrix)},t.prototype.getWorldTransform=function(){return this.matrix},t.prototype.jitterProjectionMatrix=function(t,e){var n=R(E(),[t,e,0]);this.jitteredProjectionMatrix=T(E(),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),u=st(s,this.right)/J(this.right),c=st(s,this.up)/J(this.up);return this.pan(-u,-c),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(ir(.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===Yn.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),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===Yn.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=rr(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=rr(t,e,n),this.trackingMode===br.CINEMATIC){var i=it(Z(),this.focalPoint,this.position);t=i[0],e=i[1],n=i[2];var o=J(i),a=or(Math.asin(e/o)),s=90+or(Math.atan2(n,t)),u=E();_(u,u,ir(s)),O(u,u,ir(a)),r=lt(Z(),[0,1,0],u)}return C(this.matrix,q(E(),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<_r&&(this.distance=_r),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=nr(t),this.computeMatrix(),this._getAxes(),this.type===yr.ORBITING||this.type===yr.EXPLORING?this._getPosition():this.type===yr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getAzimuth=function(){return this.azimuth},t.prototype.setElevation=function(t){return this.elevation=nr(t),this.computeMatrix(),this._getAxes(),this.type===yr.ORBITING||this.type===yr.EXPLORING?this._getPosition():this.type===yr.TRACKING&&this._getFocalPoint(),this.triggerUpdate(),this},t.prototype.getElevation=function(){return this.elevation},t.prototype.setRoll=function(t){return this.roll=nr(t),this.computeMatrix(),this._getAxes(),this.type===yr.ORBITING||this.type===yr.EXPLORING?this._getPosition():this.type===yr.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],ir(this.roll));N(this.matrix);var e=vt(mt(),[1,0,0],ir((this.rotateWorld&&this.type!==yr.TRACKING||this.type===yr.TRACKING?1:-1)*this.elevation)),n=vt(mt(),[0,1,0],ir((this.rotateWorld&&this.type!==yr.TRACKING||this.type===yr.TRACKING?1:-1)*this.azimuth)),r=yt(mt(),n,e);r=yt(mt(),r,t);var i=F(E(),r);this.type===yr.ORBITING||this.type===yr.EXPLORING?(P(this.matrix,this.matrix,this.focalPoint),T(this.matrix,this.matrix,i),P(this.matrix,this.matrix,[0,0,this.distance])):this.type===yr.TRACKING&&(P(this.matrix,this.matrix,this.position),T(this.matrix,this.matrix,i))},t.prototype._setPosition=function(t,e,n){this.position=rr(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,rr(gt(pt(),[1,0,0,0],this.matrix))),et(this.up,rr(gt(pt(),[0,1,0,0],this.matrix))),et(this.forward,rr(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===yr.TRACKING||this.rotateWorld?(this.elevation=or(Math.asin(e/r)),this.azimuth=or(Math.atan2(-t,-n))):(this.elevation=-or(Math.asin(e/r)),this.azimuth=-or(Math.atan2(-t,-n)))},t.prototype._getPosition=function(){et(this.position,rr(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=T(E(),this.getPerspective(),t);this.getFrustum().extractFromVPMatrix(e),this.eventEmitter.emit(Or)}},t.prototype.rotate=function(t,e,n){throw new Error(Nr)},t.prototype.pan=function(t,e){throw new Error(Nr)},t.prototype.dolly=function(t){throw new Error(Nr)},t.prototype.createLandmark=function(t,e){throw new Error(Nr)},t.prototype.gotoLandmark=function(t,e){throw new Error(Nr)},t.prototype.cancelLandmarkAnimation=function(){throw new Error(Nr)},t}();function Lr(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(Lr.Cache||Map),n}Lr.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"}(Cr||(Cr={})),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"}(kr||(kr={})),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"}(Tr||(Tr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Pr||(Pr={})),function(t){t[t.kYes=0]="kYes",t[t.kNo=1]="kNo"}(Ar||(Ar={}));var Dr,Ir=[{name:"em",unit_type:Cr.kEms},{name:"px",unit_type:Cr.kPixels},{name:"deg",unit_type:Cr.kDegrees},{name:"rad",unit_type:Cr.kRadians},{name:"grad",unit_type:Cr.kGradians},{name:"ms",unit_type:Cr.kMilliseconds},{name:"s",unit_type:Cr.kSeconds},{name:"rem",unit_type:Cr.kRems},{name:"turn",unit_type:Cr.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"}(Dr||(Dr={}));var jr,zr=function(t){return t?"number"===t?Cr.kNumber:"percent"===t||"%"===t?Cr.kPercentage:function(t){return Ir.find((function(e){return e.name===t})).unit_type}(t):Cr.kUnknown},Br=function(t){var e=1;switch(t){case Cr.kPixels:case Cr.kDegrees:case Cr.kSeconds:break;case Cr.kMilliseconds:e=.001;break;case Cr.kRadians:e=180/Math.PI;break;case Cr.kGradians:e=.9;break;case Cr.kTurns:e=360}return e},Fr=function(t){switch(t){case Cr.kNumber:case Cr.kInteger:return"";case Cr.kPercentage:return"%";case Cr.kEms:return"em";case Cr.kRems:return"rem";case Cr.kPixels:return"px";case Cr.kDegrees:return"deg";case Cr.kRadians:return"rad";case Cr.kGradians:return"grad";case Cr.kMilliseconds:return"ms";case Cr.kSeconds:return"s";case Cr.kTurns:return"turn"}return""},Gr=function(){function t(){}return t.isAngle=function(t){return t===Cr.kDegrees||t===Cr.kRadians||t===Cr.kGradians||t===Cr.kTurns},t.isLength=function(t){return t>=Cr.kEms&&t<Cr.kDegrees},t.isRelativeUnit=function(t){return t===Cr.kPercentage||t===Cr.kEms||t===Cr.kRems},t.isTime=function(t){return t===Cr.kSeconds||t===Cr.kMilliseconds},t.prototype.toString=function(){return this.buildCSSText(Pr.kNo,Ar.kNo,"")},t.prototype.isNumericValue=function(){return this.getType()>=Dr.kUnitType&&this.getType()<=Dr.kClampType},t}(),Vr=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 Dr.kColorType},e.prototype.to=function(t){return this},e}(Gr);!function(t){t[t.Constant=0]="Constant",t[t.LinearGradient=1]="LinearGradient",t[t.RadialGradient=2]="RadialGradient"}(jr||(jr={}));var Wr=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 Dr.kColorType},e}(Gr),Ur=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 Dr.kKeywordType},e.prototype.buildCSSText=function(t,e,n){return n+this.value},e}(Gr),Hr=Lr((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 $r(t){return"function"==typeof t}var Yr={d:{alias:"path"},strokeDasharray:{alias:"lineDash"},strokeWidth:{alias:"lineWidth"},textAnchor:{alias:"textAlign"},src:{alias:"img"}},Kr=Lr((function(t){var e=Hr(t),n=Yr[e];return e=(null==n?void 0:n.alias)||e})),Xr=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},Zr=function(t){return function(t){switch(t){case kr.kUNumber:return Cr.kNumber;case kr.kULength:return Cr.kPixels;case kr.kUPercent:return Cr.kPercentage;case kr.kUTime:return Cr.kSeconds;case kr.kUAngle:return Cr.kDegrees;default:return Cr.kUnknown}}(function(t){switch(t){case Cr.kNumber:case Cr.kInteger:return kr.kUNumber;case Cr.kPercentage:return kr.kUPercent;case Cr.kPixels:return kr.kULength;case Cr.kMilliseconds:case Cr.kSeconds:return kr.kUTime;case Cr.kDegrees:case Cr.kRadians:case Cr.kGradians:case Cr.kTurns:return kr.kUAngle;default:return kr.kUOther}}(t))},Qr=function(t){function e(e,n){void 0===n&&(n=Cr.kNumber);var r,i=t.call(this)||this;return r="string"==typeof n?zr(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 Dr.kUnitType},e.prototype.convertTo=function(t){if(this.unit===t)return new e(this.value,this.unit);var n=Zr(this.unit);if(n!==Zr(t)||n===Cr.kUnknown)return null;var r=Br(this.unit)/Br(t);return new e(this.value*r,t)},e.prototype.buildCSSText=function(t,e,n){var r;switch(this.unit){case Cr.kUnknown:break;case Cr.kInteger:r=Number(this.value).toFixed(0);break;case Cr.kNumber:case Cr.kPercentage:case Cr.kEms:case Cr.kRems:case Cr.kPixels:case Cr.kDegrees:case Cr.kRadians:case Cr.kGradians:case Cr.kMilliseconds:case Cr.kSeconds:case Cr.kTurns:var i=this.value,o=Fr(this.unit);if(i<-999999||i>999999){var a=Fr(this.unit);r=!Number.isFinite(i)||Number.isNaN(i)?Xr(i,a):i+(a||"")}else r="".concat(i).concat(o)}return n+=r},e}(Gr),Jr=new Qr(0,"px");new Qr(1,"px");var ti,ei,ni=new Qr(0,"deg"),ri=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}(Vr),ii=new Ur("unset"),oi=new Ur("initial"),ai=new Ur("inherit"),si={"":ii,unset:ii,initial:oi,inherit:ai},ui=function(t){return si[t]||(si[t]=new Ur(t)),si[t]},ci=new ri(0,0,0,0,!0),li=new ri(0,0,0,0),hi=Lr((function(t,e,n,r){return new ri(t,e,n,r)}),(function(t,e,n,r){return"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")")})),di=function(t,e){return void 0===e&&(e=Cr.kNumber),new Qr(t,e)},fi=new Qr(50,"%");!function(t){t[t.Standard=0]="Standard"}(ti||(ti={})),function(t){t[t.ADDED=0]="ADDED",t[t.REMOVED=1]="REMOVED",t[t.Z_INDEX_CHANGED=2]="Z_INDEX_CHANGED"}(ei||(ei={}));var pi,gi={absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Mr(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>"}(pi||(pi={}));var vi=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 y("directional",t.sideOrCorner,1)||y("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=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&&E(n[0].length);var r=t.exec(e);return r&&E(r[0].length),r}function E(t){e=e.substring(t)}return function(t){return e=t,r()}}();var yi=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,bi=/^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 xi={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},Mi=Lr((function(t){var e;return e="angular"===t.type?Number(t.value):xi[t.value]||0,di(e,"deg")})),Ni=Lr((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:di(e,r),cy:di(n,i)}})),Si=Lr((function(t){var e;if(t.indexOf("linear")>-1||t.indexOf("radial")>-1)return vi(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(!Pt(u)&&!Pt(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:di(Number(t.length.value),"%"),color:mi(t)}}));if("linear-gradient"===e)return new Wr(jr.LinearGradient,{angle:n?Mi(n):ni,steps:i});if("radial-gradient"===e&&(n||(n=[{type:"shape",value:"circle"}]),"shape"===n[0].type&&"circle"===n[0].value)){var o=Ni(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?ui(h):di(h,l)}return new Wr(jr.RadialGradient,{cx:a,cy:s,size:u,steps:i})}}));var n=t[0];if("("===t[1]||"("===t[2])if("l"===n){var r=yi.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 Wr(jr.LinearGradient,{angle:di(parseFloat(r[1]),"deg"),steps:i.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:di(100*Number(n),"%"),color:r}}))})]}}else if("r"===n){var o=function(t){var e,n=bi.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:di(50,"%"),cy:di(50,"%"),steps:r.map((function(t){var e=c(t,2),n=e[0],r=e[1];return{offset:di(100*Number(n),"%"),color:r}}))}}return null}(t);if(o){if(!Bt(o))return[new Wr(jr.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 Ci(t){return t&&!!t.image}function ki(t){return t&&!Pt(t.r)&&!Pt(t.g)&&!Pt(t.b)}var Ti=Lr((function(t){if(Ci(t))return i({repetition:"repeat"},t);if(Pt(t)&&(t=""),"transparent"===t)return li;"currentColor"===t&&(t="black");var e=Si(t);if(e)return e;var n=mn(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),hi.apply(void 0,l([],c(r),!1))}));function Pi(t,e){if(ki(t)&&ki(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 Ai(t,e){if(Pt(e))return di(0,"px");if(e="".concat(e).trim().toLowerCase(),isFinite(Number(e))){if("px".search(t)>=0)return di(Number(e),"px");if("deg".search(t)>=0)return di(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 di(Number(e.replace(new RegExp("U"+t,"g"),"").replace(new RegExp(r,"g"),"*0")),t)}))[0]}var Oi=function(t){return Ai(new RegExp("px","g"),t)},_i=Lr(Oi);Lr((function(t){return Ai(new RegExp("%","g"),t)}));var Ri=function(t){return Wt(t)||isFinite(Number(t))?di(Number(t)||0,"px"):Ai(new RegExp("px|%|em|rem","g"),t)},Li=Lr(Ri),Di=function(t){return Ai(new RegExp("deg|rad|grad|turn","g"),t)},Ii=Lr(Di);function ji(t,e,n,r,i){void 0===i&&(i=0);var o="",a=t.value||0,s=e.value||0,u=Zr(t.unit),c=t.convertTo(u),l=e.convertTo(u);return c&&l?(a=c.value,s=l.value,o=Fr(t.unit)):(Qr.isLength(t.unit)||Qr.isLength(e.unit))&&(a=Gi(t,i,n),s=Gi(e,i,n),o="px"),[a,s,function(t){return r&&(t=Math.max(t,0)),t+o}]}function zi(t){var e=0;return t.unit===Cr.kDegrees?e=t.value:t.unit===Cr.kRadians?e=or(Number(t.value)):t.unit===Cr.kTurns&&(e=360*Number(t.value)),e}function Bi(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 Fi(t){return Bt(t)?t.split(" ").map((function(t){return Li(t)})):t.map((function(t){return Li(t.toString())}))}function Gi(t,e,n){if(0===t.value)return 0;if(t.unit===Cr.kPixels)return Number(t.value);if(t.unit===Cr.kPercentage&&n){var r=n.nodeName===$n.GROUP?n.getLocalBounds():n.geometry.contentBounds;return t.value/100*r.halfExtents[e]*2}return 0}var Vi=["blur","brightness","drop-shadow","contrast","grayscale","sepia","saturate","hue-rotate","invert"];function Wi(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,Vi.indexOf(e[1])>-1&&r.push({name:e[1],params:e[2].split(" ").map((function(t){return Ai(/deg|rad|grad|turn|px|%/g,t)||Ti(t)}))}),n.lastIndex===t.length)return r}return[]}function Ui(t){return t.toString()}var Hi=function(t){return"number"==typeof t?di(t):/^\s*[-+]?(\d*\.)?\d+\s*$/.test(t)?di(Number(t)):di(0)},qi=Lr(Hi);function $i(t,e){return[t,e,Ui]}function Yi(t,e){return function(n,r){return[n,r,function(n){return Ui(Vt(n,t,e))}]}}function Ki(t,e){if(t.length===e.length)return[t,e,function(t){return t}]}function Xi(t){var e;return 0===t.parsedStyle.path.totalLength&&(t.parsedStyle.path.totalLength=He(t.parsedStyle.path.absolutePath,void 0,i(i({},e),{bbox:!1,length:!0})).length),t.parsedStyle.path.totalLength}function Zi(t,e){return t[0]===e[0]&&t[1]===e[1]}function Qi(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)||Ht(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 Ji(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}Lr((function(t){return Bt(t)?t.split(" ").map(qi):t.map(qi)}));var to=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)},eo=function(t,e,n,r,i,o,a,s){e=Math.abs(e),n=Math.abs(n);var u=ir(r=qt(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),v={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},y={x:(h.x-g)/e,y:(h.y-m)/n},b=to({x:1,y:0},y),E=to(y,{x:(-h.x-g)/e,y:(-h.y-m)/n});!o&&E>0?E-=2*Math.PI:o&&E<0&&(E+=2*Math.PI);var w=b+(E%=2*Math.PI)*s,x=e*Math.cos(w),M=n*Math.sin(w);return{x:Math.cos(u)*x-Math.sin(u)*M+v.x,y:Math.sin(u)*x+Math.cos(u)*M+v.y,ellipticalArcStartAngle:b,ellipticalArcEndAngle:b+E,ellipticalArcAngle:w,ellipticalArcCenter:v,resultantRx:e,resultantRy:n}};function no(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=eo({x:t.prePoint[0],y:t.prePoint[1]},o,s,u,!!c,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},e),d=eo({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 ro(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function io(t,e){return ro(t)*ro(e)?(t[0]*e[0]+t[1]*e[1])/(ro(t)*ro(e)):1}function oo(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(io(t,e))}function ao(t,e){var n=e[1],r=e[2],i=qt(ir(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,v=n?g*-r*h/n:0,y=(s+c)/2+Math.cos(i)*m-Math.sin(i)*v,b=(u+l)/2+Math.sin(i)*m+Math.cos(i)*v,E=[(h-m)/n,(d-v)/r],w=[(-1*h-m)/n,(-1*d-v)/r],x=oo([1,0],E),M=oo(E,w);return io(E,w)<=-1&&(M=Math.PI),io(E,w)>=1&&(M=0),0===a&&M>0&&(M-=2*Math.PI),1===a&&M<0&&(M+=2*Math.PI),{cx:y,cy:b,rx:Zi(t,[c,l])?0:n,ry:Zi(t,[c,l])?0:r,startAngle:x,endAngle:x+M,xRotation:i,arcFlag:o,sweepFlag:a}}var so=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=Pe(t)}catch(n){e=Pe(""),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&&Zi(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=ao(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]&&Zi(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=Ji((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"===c){var m=[u[1],u[2]],v=[u[3],u[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"===c){var y;m=Ji((y=e[s-1]).currentPoint,p),v=[u[1],u[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"===c){var b=no(l,0),E=b.x,w=b.y,x=no(l,1,!1),M=x.x,N=x.y;l.startTangent=[E,w],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,u=g.prePoint,c=void 0;switch(g.command){case"Q":c=Un(u[0],u[1],s[1],s[2],s[3],s[4]);break;case"C":c=Bn(u[0],u[1],s[1],s[2],s[3],s[4],s[5],s[6]);break;case"A":var l=g.arcParams;c=On(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)),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-=Qi(g,e).xExtra:a[0]===f&&(f+=Qi(g,e).xExtra),a[1]===d?d-=Qi(g,e).yExtra:a[1]===p&&(p+=Qi(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}}},uo=Lr(so);function co(t){return Bt(t)?uo(t):so(t)}function lo(t,e,n){var r=t.curve,i=e.curve;r&&0!==r.length||(r=De(t.absolutePath,!1),t.curve=r),i&&0!==i.length||(i=De(e.absolutePath,!1),e.curve=i);var o=[r,i];r.length!==i.length&&(o=Ke(r,i));var a,s,u=$e(o[0])!==$e(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,qe(o[1],u),function(t){return t}]}function ho(t,e){var n;n=Bt(t)?t.split(" ").map((function(t){var e=c(t.split(","),2),n=e[0],r=e[1];return[Number(n),Number(r)]})):t;var r,i,o=[],a=0,s=Gn(n);n.forEach((function(t,e){n[e+1]&&((r=[0,0])[0]=a/s,i=Ln(t[0],t[1],n[e+1][0],n[e+1][1]),a+=i,r[1]=a/s,o.push(r))}));var u=Math.min.apply(Math,l([],c(n.map((function(t){return t[0]}))),!1)),h=Math.min.apply(Math,l([],c(n.map((function(t){return t[1]}))),!1));return e&&(e.parsedStyle.defX=u,e.parsedStyle.defY=h),{points:n,totalLength:s,segments:o}}function fo(t,e){return[t.points,e.points,function(t){return t}]}var po=null;function go(t){return function(e){var n=0;return t.map((function(t){return t===po?e[n++]:t}))}}function mo(t){return t}var vo={matrix:["NNNNNN",[po,po,0,0,po,po,0,0,0,0,1,0,po,po,0,1],mo],matrix3d:["NNNNNNNNNNNNNNNN",mo],rotate:["A"],rotatex:["A"],rotatey:["A"],rotatez:["A"],rotate3d:["NNNA"],perspective:["L"],scale:["Nn",go([po,po,new Qr(1)]),mo],scalex:["N",go([po,new Qr(1),new Qr(1)]),go([po,new Qr(1)])],scaley:["N",go([new Qr(1),po,new Qr(1)]),go([new Qr(1),po])],scalez:["N",go([new Qr(1),new Qr(1),po])],scale3d:["NNN",mo],skew:["Aa",null,mo],skewx:["A",null,go([po,ni])],skewy:["A",null,go([ni,po])],translate:["Tt",go([po,po,Jr]),mo],translatex:["T",go([po,Jr,Jr]),go([po,Jr])],translatey:["T",go([Jr,po,Jr]),go([Jr,po])],translatez:["L",go([Jr,Jr,po])],translate3d:["TTL",mo]};function yo(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=vo[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()?ni:Ii(t)},N:qi,T:Li,L:_i}[d.toUpperCase()](h):{a:ni,n:c[0],t:Jr}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}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=vo[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()?ni:Di(t)},N:Hi,T:Ri,L:Oi}[d.toUpperCase()](h):{a:ni,n:c[0],t:Jr}[d]))return[];c.push(f)}if(r.push({t:o,d:c}),n.lastIndex===t.length)return r}return[]}function Eo(t){var e,n,r,i;switch(t.t){case"rotatex":return i=ir(zi(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=ir(zi(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=ir(zi(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=ir(zi(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=ir(zi(t.d[0])),h=ir(zi(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=ir(zi(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=ir(zi(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=Gi(t.d[0],0,null)||0,n=Gi(t.d[1],0,null)||0,0,1];case"translatex":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Gi(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=Gi(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=Gi(t.d[0],0,null)||0,1];case"translate3d":return[1,0,0,0,0,1,0,0,0,0,1,0,e=Gi(t.d[0],0,null)||0,n=Gi(t.d[1],0,null)||0,r=Gi(t.d[2],0,null)||0,1];case"perspective":var d=Gi(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 xo(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}(cr,t))return!1;if(x(lr,cr),lr[3]=0,lr[7]=0,lr[11]=0,lr[15]=1,Math.abs(k(lr))<1e-8)return!1;var a,s,u=cr[3],c=cr[7],l=cr[11],h=cr[12],d=cr[13],f=cr[14],p=cr[15];if(0!==u||0!==c||0!==l){if(hr[0]=u,hr[1]=c,hr[2]=l,hr[3]=p,!C(lr,lr))return!1;S(lr,lr),gt(i,hr,lr)}else i[0]=i[1]=i[2]=0,i[3]=1;if(e[0]=h,e[1]=d,e[2]=f,s=cr,(a=dr)[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(dr[0]),at(dr[0],dr[0]),r[0]=st(dr[0],dr[1]),pr(dr[1],dr[1],dr[0],1,-r[0]),n[1]=J(dr[1]),at(dr[1],dr[1]),r[0]/=n[1],r[1]=st(dr[0],dr[2]),pr(dr[2],dr[2],dr[0],1,-r[1]),r[2]=st(dr[1],dr[2]),pr(dr[2],dr[2],dr[1],1,-r[2]),n[2]=J(dr[2]),at(dr[2],dr[2]),r[1]/=n[2],r[2]/=n[2],ut(fr,dr[1],dr[2]),st(dr[0],fr)<0)for(var g=0;g<3;g++)n[g]*=-1,dr[g][0]*=-1,dr[g][1]*=-1,dr[g][2]*=-1;o[0]=.5*Math.sqrt(Math.max(1+dr[0][0]-dr[1][1]-dr[2][2],0)),o[1]=.5*Math.sqrt(Math.max(1-dr[0][0]+dr[1][1]-dr[2][2],0)),o[2]=.5*Math.sqrt(Math.max(1-dr[0][0]-dr[1][1]+dr[2][2],0)),o[3]=.5*Math.sqrt(Math.max(1+dr[0][0]+dr[1][1]+dr[2][2],0)),dr[2][1]>dr[1][2]&&(o[0]=-o[0]),dr[0][2]>dr[2][0]&&(o[1]=-o[1]),dr[1][0]>dr[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 Mo=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 No(t){return t.toFixed(6).replace(".000000","")}function So(t,e){var n,r;return t.decompositionPair!==e&&(t.decompositionPair=e,n=xo(t)),e.decompositionPair!==t&&(e.decompositionPair=t,r=xo(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 Mo(t[0],t[1],t[2],e,t[4]).map(No).join(",")}])}function Co(t){return t.replace(/[xy]/,"")}function ko(t){return t.replace(/(x|y|z|3d)?$/,"3d")}function To(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?di(a):di(a,t.unit)}))})},o=0;o<t.length;o++)i(o)}var a,s,u=[],c=[],l=[];if(t.length!==e.length)u=[(y=So(t,e))[0]],c=[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=vo[h],m=vo[d],v=void 0;if(s=d,"perspective"===(a=h)&&"perspective"===s||!("matrix"!==a&&"matrix3d"!==a||"matrix"!==s&&"matrix3d"!==s)){var y=So([t[o]],[e[o]]);u.push(y[0]),c.push(y[1]),l.push(["matrix",[y[2]]])}else{if(h===d)v=h;else if(g[2]&&m[2]&&Co(h)===Co(d))v=Co(h),f=g[2](f),p=m[2](p);else{if(!g[1]||!m[1]||ko(h)!==ko(d)){u=[(y=So(t,e))[0]],c=[y[1]],l=[["matrix",[y[2]]]];break}v=ko(h),f=g[1](f),p=m[1](p)}for(var b=[],E=[],w=[],x=0;x<f.length;x++){y=ji(f[x],p[x],n,!1,x);b[x]=y[0],E[x]=y[1],w.push(y[2])}u.push(b),c.push(E),l.push([v,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 Po=Lr((function(t){if(Bt(t)){if("text-anchor"===t)return[di(0,"px"),di(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:[Li(Oo(e[0])),Li(Oo(e[1]))]}return[di(t[0]||0,"px"),di(t[1]||0,"px")]})),Ao=function(t){if(Bt(t)){if("text-anchor"===t)return[di(0,"px"),di(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:[Ri(Oo(e[0])),Ri(Oo(e[1]))]}return[di(t[0]||0,"px"),di(t[1]||0,"px")]};function Oo(t){return"center"===t?"50%":"left"===t||"top"===t?"0":"right"===t||"bottom"===t?"100%":t}var _o=[{n:"display",k:["none"]},{n:"opacity",int:!0,inh:!0,d:"1",syntax:pi.OPACITY_VALUE},{n:"fillOpacity",int:!0,inh:!0,d:"1",syntax:pi.OPACITY_VALUE},{n:"strokeOpacity",int:!0,inh:!0,d:"1",syntax:pi.OPACITY_VALUE},{n:"fill",int:!0,k:["none"],d:"none",syntax:pi.PAINT},{n:"fillRule",k:["nonzero","evenodd"],d:"nonzero"},{n:"stroke",int:!0,k:["none"],d:"none",syntax:pi.PAINT,l:!0},{n:"shadowType",k:["inner","outer","both"],d:"outer",l:!0},{n:"shadowColor",int:!0,syntax:pi.COLOR},{n:"shadowOffsetX",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"shadowOffsetY",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"shadowBlur",int:!0,l:!0,d:"0",syntax:pi.SHADOW_BLUR},{n:"lineWidth",int:!0,inh:!0,d:"1",l:!0,a:["strokeWidth"],syntax:pi.LENGTH_PERCENTAGE},{n:"increasedLineWidthForHitTesting",inh:!0,d:"0",l:!0,syntax:pi.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:pi.LENGTH_PERCENTAGE_12},{n:"lineDashOffset",int:!0,inh:!0,d:"0",a:["strokeDashoffset"],syntax:pi.LENGTH_PERCENTAGE},{n:"offsetPath",syntax:pi.DEFINED_PATH},{n:"offsetDistance",int:!0,syntax:pi.OFFSET_DISTANCE},{n:"dx",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"dy",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"zIndex",ind:!0,int:!0,d:"0",k:["auto"],syntax:pi.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:pi.FILTER},{n:"clipPath",syntax:pi.DEFINED_PATH},{n:"textPath",syntax:pi.DEFINED_PATH},{n:"textPathSide",k:["left","right"],d:"left"},{n:"textPathStartOffset",l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"transform",p:100,int:!0,k:["none"],d:"none",syntax:pi.TRANSFORM},{n:"transformOrigin",p:100,d:function(t){return t===$n.CIRCLE||t===$n.ELLIPSE?"center":t===$n.TEXT?"text-anchor":"left top"},l:!0,syntax:pi.TRANSFORM_ORIGIN},{n:"anchor",p:99,d:function(t){return t===$n.CIRCLE||t===$n.ELLIPSE?"0.5 0.5":"0 0"},l:!0,syntax:pi.LENGTH_PERCENTAGE_12},{n:"cx",int:!0,d:"0",syntax:pi.COORDINATE},{n:"cy",int:!0,d:"0",syntax:pi.COORDINATE},{n:"cz",int:!0,d:"0",syntax:pi.COORDINATE},{n:"r",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"rx",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"ry",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"x",int:!0,d:"0",syntax:pi.COORDINATE},{n:"y",int:!0,d:"0",syntax:pi.COORDINATE},{n:"z",int:!0,d:"0",syntax:pi.COORDINATE},{n:"width",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"height",int:!0,l:!0,k:["auto","fit-content","min-content","max-content"],d:"0",syntax:pi.LENGTH_PERCENTAGE},{n:"radius",int:!0,l:!0,d:"0",syntax:pi.LENGTH_PERCENTAGE_14},{n:"x1",int:!0,l:!0,syntax:pi.COORDINATE},{n:"y1",int:!0,l:!0,syntax:pi.COORDINATE},{n:"z1",int:!0,l:!0,syntax:pi.COORDINATE},{n:"x2",int:!0,l:!0,syntax:pi.COORDINATE},{n:"y2",int:!0,l:!0,syntax:pi.COORDINATE},{n:"z2",int:!0,l:!0,syntax:pi.COORDINATE},{n:"path",int:!0,l:!0,d:"",a:["d"],syntax:pi.PATH,p:50},{n:"points",int:!0,l:!0,syntax:pi.LIST_OF_POINTS,p:50},{n:"text",l:!0,d:"",syntax:pi.TEXT,p:50},{n:"textTransform",l:!0,inh:!0,k:["capitalize","uppercase","lowercase","none"],d:"none",syntax:pi.TEXT_TRANSFORM,p:51},{n:"font",l:!0},{n:"fontSize",int:!0,inh:!0,d:"16px",l:!0,syntax:pi.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:pi.LENGTH,int:!0,d:"0"},{n:"letterSpacing",l:!0,syntax:pi.LENGTH,int:!0,d:"0"},{n:"miterLimit",l:!0,syntax:pi.NUMBER,d:function(t){return t===$n.PATH||t===$n.POLYGON||t===$n.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:pi.MARKER},{n:"markerEnd",syntax:pi.MARKER},{n:"markerMid",syntax:pi.MARKER},{n:"markerStartOffset",syntax:pi.LENGTH,l:!0,int:!0,d:"0"},{n:"markerEndOffset",syntax:pi.LENGTH,l:!0,int:!0,d:"0"}],Ro=_o.filter((function(t){return!!t.l})).map((function(t){return t.n})),Lo={},Do=new WeakMap,Io=function(){function t(t){var e=this;this.runtime=t,_o.forEach((function(t){e.registerMetadata(t)}))}return t.prototype.registerMetadata=function(t){l([t.n],c(t.a||[]),!1).forEach((function(e){Lo[e]=t}))},t.prototype.unregisterMetadata=function(t){delete Lo[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 u=!!n.forceUpdateGeometry;if(!u)for(var c=0;c<Ro.length;c++)if(Ro[c]in e){u=!0;break}return e.fill&&(t.parsedStyle.fill=Ti(e.fill)),e.stroke&&(t.parsedStyle.stroke=Ti(e.stroke)),e.shadowColor&&(t.parsedStyle.shadowColor=Ti(e.shadowColor)),e.filter&&(t.parsedStyle.filter=Wi(e.filter)),Pt(e.radius)||(t.parsedStyle.radius=Bi(e.radius,4)),Pt(e.lineDash)||(t.parsedStyle.lineDash=Bi(e.lineDash,2)),e.points&&(t.parsedStyle.points=ho(e.points,t)),""===e.path&&(t.parsedStyle.path=i({},gi)),e.path&&(t.parsedStyle.path=co(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=Bi(e.anchor,2)),e.transform&&(t.parsedStyle.transform=yo(e.transform)),e.transformOrigin&&(t.parsedStyle.transformOrigin=Po(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!==$n.CIRCLE&&t.nodeName!==$n.ELLIPSE||Pt(e.cx)&&Pt(e.cy))&&(t.nodeName!==$n.RECT&&t.nodeName!==$n.IMAGE&&t.nodeName!==$n.GROUP&&t.nodeName!==$n.HTML&&t.nodeName!==$n.TEXT&&t.nodeName!==$n.MESH||Pt(e.x)&&Pt(e.y)&&Pt(e.z))&&(t.nodeName!==$n.LINE||Pt(e.x1)&&Pt(e.y1)&&Pt(e.z1)&&Pt(e.x2)&&Pt(e.y2)&&Pt(e.z2))||this.runtime.CSSPropertySyntaxFactory["<coordinate>"].postProcessor(t,o),Pt(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),Pt(e.offsetDistance)||this.runtime.CSSPropertySyntaxFactory["<offset-distance>"].postProcessor(t,o),e.transform&&this.runtime.CSSPropertySyntaxFactory["<transform>"].postProcessor(t,o),void(u&&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=Lo[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=Lo[t],o=e;if((""===e||Pt(e))&&(e="unset"),"unset"===e||"initial"===e||"inherit"===e)o=ui(e);else if(i){var a=i.k,s=i.syntax,u=s&&this.getPropertySyntax(s);a&&a.indexOf(e)>-1?o=ui(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=Lo[t],o="g-root"===n.id,a=e;if(i){var s=i.syntax,u=i.inh,c=i.d;if(e instanceof Ur){var l=e.value;if("unset"===l&&(l=u&&!o?"inherit":"initial"),"initial"===l)Pt(c)||(e=this.parseProperty(t,$r(c)?c(n.nodeName):c,n,r));else if("inherit"===l){var h=this.tryToResolveProperty(n,t,{inherited:!0});return Pt(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 Ur?e.value:e}return a},t.prototype.postProcessProperty=function(t,e,n){var r=Lo[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=Do.get(t);n||(Do.set(t,[]),n=Do.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=Do.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=Do.get(t);if(e&&e.length){var n={};e.forEach((function(e){n[e]=t.attributes[e]})),this.processProperties(t,n),Do.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 mr),r.renderBounds||(r.renderBounds=new mr);var i=t.parsedStyle,o=n.update(i,t),a=o.width,s=o.height,u=o.depth,c=void 0===u?0:u,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,c/2],v=i,y=v.stroke,b=v.lineWidth,E=v.increasedLineWidthForHitTesting,w=v.shadowType,x=v.shadowColor,M=v.filter,N=void 0===M?[]:M,S=v.transformOrigin,C=i.anchor;e===$n.TEXT?delete i.anchor:e===$n.MESH&&(i.anchor[2]=.5);var k=[(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(k,m);var T=e===$n.POLYLINE||e===$n.POLYGON||e===$n.PATH?Math.SQRT2:.5;if(y&&!y.isNone){var P=((b||0)+(E||0))*T;m[0]+=P,m[1]+=P}if(r.renderBounds.update(k,m),x&&w&&"inner"!==w){var A=r.renderBounds,O=A.min,_=A.max,R=i,L=R.shadowBlur||0,D=R.shadowOffsetX||0,I=R.shadowOffsetY||0,j=O[0]-L+D,z=_[0]+L+D,B=O[1]-L+I,F=_[1]+L+I;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,tr(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)}})),C=i.anchor;var G=a<0,V=s<0,W=(G?-1:1)*(S?Gi(S[0],0,t):0),U=(V?-1:1)*(S?Gi(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===$n.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===$n.CIRCLE&&t.style.rawR&&(t.style.r=t.style.rawR,delete t.style.rawR))},t.prototype.isPropertyInheritable=function(t){var e=Lo[t];return!!e&&e.inh},t}(),jo=function(){function t(){this.parser=Ii,this.parserUnmemoize=Di,this.parserWithCSSDisabled=null,this.mixer=$i}return t.prototype.calculator=function(t,e,n,r){return zi(n)},t}(),zo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r,i){return n instanceof Ur&&(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}(),Bo=function(){function t(){this.parser=Ti,this.parserWithCSSDisabled=Ti,this.mixer=Pi}return t.prototype.calculator=function(t,e,n,r){return n instanceof Ur?"none"===n.value?ci:li:n},t}(),Fo=function(){function t(){this.parser=Wi}return t.prototype.calculator=function(t,e,n){return n instanceof Ur?[]:n},t}();function Go(t){var e=t.parsedStyle.fontSize;return Pt(e)?null:e}var Vo=function(){function t(){this.parser=Li,this.parserUnmemoize=Ri,this.parserWithCSSDisabled=null,this.mixer=$i}return t.prototype.calculator=function(t,e,n,r,i){var o;if(Wt(n))return n;if(!Qr.isRelativeUnit(n.unit))return n.value;var a=i.styleValueRegistry;if(n.unit===Cr.kPercentage)return 0;if(n.unit===Cr.kEms){if(r.parentNode){if(s=Go(r.parentNode))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}if(n.unit===Cr.kRems){if(null===(o=null==r?void 0:r.ownerDocument)||void 0===o?void 0:o.documentElement){var s;if(s=Go(r.ownerDocument.documentElement))return s*=n.value;a.addUnresolveProperty(r,t)}else a.addUnresolveProperty(r,t);return 0}},t}(),Wo=function(){function t(){this.mixer=Ki}return t.prototype.parser=function(t){var e=Fi(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}(),Uo=function(){function t(){this.mixer=Ki}return t.prototype.parser=function(t){var e=Fi(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}(),Ho=E();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||[Jr,Jr];e.translateLocal(s[0].value,s[1].value,0)}else if("translatex"===i){s=o||[Jr];e.translateLocal(s[0].value,0,0)}else if("translatey"===i){s=o||[Jr];e.translateLocal(0,s[0].value,0)}else if("translatez"===i){s=o||[Jr];e.translateLocal(0,0,s[0].value)}else if("translate3d"===i){s=o||[Jr,Jr,Jr];e.translateLocal(s[0].value,s[1].value,s[2].value)}else if("rotate"===i){var u=o||[ni];e.rotateLocal(0,0,zi(u[0]))}else if("rotatex"===i){u=o||[ni];e.rotateLocal(zi(u[0]),0,0)}else if("rotatey"===i){u=o||[ni];e.rotateLocal(0,zi(u[0]),0)}else if("rotatez"===i){u=o||[ni];e.rotateLocal(0,0,zi(u[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(ir(h[0]),ir(h[1]))}else if("skewx"===i){h=(null==o?void 0:o.map((function(t){return t.value})))||[0];e.setLocalSkew(ir(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],ir(h[0]))}else if("matrix"===i){var d=c(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(Ho,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([Ho],c(o.map((function(t){return t.value}))),!1)),Ho[12]+=n,Ho[13]+=r,e.setLocalTransform(Ho))})),e.getLocalTransform()}var $o=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 $n.CIRCLE:case $n.ELLIPSE:var o=t.parsedStyle,a=o.cx,s=o.cy,u=o.cz;Pt(a)||(n=a),Pt(s)||(r=s),Pt(u)||(i=u);break;case $n.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 $n.RECT:case $n.IMAGE:case $n.GROUP:case $n.HTML:case $n.TEXT:case $n.MESH:Pt(t.parsedStyle.x)||(n=t.parsedStyle.x),Pt(t.parsedStyle.y)||(r=t.parsedStyle.y),Pt(t.parsedStyle.z)||(i=t.parsedStyle.z)}if(t.nodeName!==$n.PATH&&t.nodeName!==$n.POLYLINE&&t.nodeName!==$n.POLYGON&&(t.parsedStyle.defX=n||0,t.parsedStyle.defY=r||0),(!Pt(n)||!Pt(r)||!Pt(i))&&-1===e.indexOf("transform")){var g=t.parsedStyle.transform;if(g&&g.length)qo(g,t);else{var m=c(t.getLocalPosition(),3),v=m[0],y=m[1],b=m[2];t.setLocalPosition(Pt(n)?v:n,Pt(r)?y:r,Pt(i)?b:i)}}},e}(Vo),Yo=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){n instanceof Ur&&(n=null);var i=null==n?void 0:n.cloneNode(!0);return i&&(i.style.isMarker=!0),i},t}(),Ko=function(){function t(){this.mixer=$i,this.parser=qi,this.parserUnmemoize=Hi,this.parserWithCSSDisabled=null}return t.prototype.calculator=function(t,e,n){return n.value},t}(),Xo=function(){function t(){this.parser=qi,this.parserUnmemoize=Hi,this.parserWithCSSDisabled=null,this.mixer=Yi(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===$n.LINE||i===$n.PATH||i===$n.POLYLINE){var o=n.getPoint(r);o&&(t.parsedStyle.defX=o.x,t.parsedStyle.defY=o.y,t.setLocalPosition(o.x,o.y))}}},t}(),Zo=function(){function t(){this.parser=qi,this.parserUnmemoize=Hi,this.parserWithCSSDisabled=null,this.mixer=Yi(0,1)}return t.prototype.calculator=function(t,e,n){return n.value},t}(),Qo=function(){function t(){this.parser=co,this.parserWithCSSDisabled=co,this.mixer=lo}return t.prototype.calculator=function(t,e,n){return n instanceof Ur&&"unset"===n.value?{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Mr(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===$n.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}(),Jo=function(){function t(){this.parser=ho,this.mixer=fo}return t.prototype.postProcessor=function(t,e){if((t.nodeName===$n.POLYGON||t.nodeName===$n.POLYLINE)&&-1===e.indexOf("transform")){var n=t.parsedStyle,r=n.defX,i=n.defY;t.setLocalPosition(r,i)}},t}(),ta=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.mixer=Yi(0,1/0),e}return r(e,t),e}(Vo),ea=function(){function t(){}return t.prototype.calculator=function(t,e,n,r){return n instanceof Ur?"unset"===n.value?"":n.value:"".concat(n)},t.prototype.postProcessor=function(t){t.nodeValue="".concat(t.parsedStyle.text)||""},t}(),na=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}(),ra={},ia=0;var oa="undefined"!=typeof window&&void 0!==window.document;function aa(t){return!!t.getAttribute}function sa(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 ca(t,e){if(oa)return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}var la={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ha="object"==typeof performance&&performance.now?performance:Date;function da(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 fa=1,pa="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},ga=Date.now(),ma={},va=Date.now(),ya=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=Date.now(),n=e-va,r=n>16?0:16-n,i=fa++;return ma[i]=t,Object.keys(ma).length>1||setTimeout((function(){va=e;var t=ma;ma={},Object.keys(t).forEach((function(e){return t[e](pa.performance&&"function"==typeof pa.performance.now?pa.performance.now():Date.now()-ga)}))}),r),i},ba=function(t){delete ma[t]},Ea=function(t){return"string"!=typeof t?ya:""===t?pa.requestAnimationFrame:pa[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)})),xa=Ea(wa),Ma=function(t){return"string"!=typeof t?ba:""===t?pa.cancelAnimationFrame:pa[t+"CancelAnimationFrame"]||pa[t+"CancelRequestAnimationFrame"]}(wa);pa.requestAnimationFrame=xa,pa.cancelAnimationFrame=Ma;var Na=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}(),Sa=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}(),Ca=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}(),ka=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}(),Ta=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Pa=/([\"\'])[^\'\"]+\1/;var Aa=function(){function t(){this.parser=yo,this.parserUnmemoize=bo,this.parserWithCSSDisabled=bo,this.mixer=To}return t.prototype.calculator=function(t,e,n,r){return n instanceof Ur?[]:n},t.prototype.postProcessor=function(t){qo(t.parsedStyle.transform,t)},t}(),Oa=function(){this.parser=Po,this.parserUnmemoize=Ao},_a=function(){function t(){this.parser=qi,this.parserUnmemoize=Hi}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=ei.Z_INDEX_CHANGED)}},t}(),Ra=function(){function t(){}return t.prototype.update=function(t,e){var n=t.r;return{width:2*n,height:2*n}},t}(),La=function(){function t(){}return t.prototype.update=function(t,e){return{width:2*t.rx,height:2*t.ry}},t}(),Da=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}(),Ia=function(){function t(){}return t.prototype.update=function(t){var e=t.path.rect;return{width:e.width,height:e.height}},t}(),ja=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([],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));return{width:r-n,height:o-i}}return{width:0,height:0}},t}(),za=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}(),Ba=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 n&&o&&a&&s&&u&&r&&i&&!Pt(c)},t.prototype.update=function(t,e){var n,r,i=t.text,o=t.textAlign,a=t.lineWidth,s=t.textBaseline,u=t.dx,c=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),u&&(y+=u),c&&(b+=c),t.anchor=[v[0],v[1],0],{width:2*m[0],height:2*m[1],offsetX:y,offsetY:b}},t}();var Fa,Ga=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 xr,this.page=new xr,this.canvas=new xr,this.viewport=new xr,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(Nr)},t}(),Va=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.client=new xr,e.movement=new xr,e.offset=new xr,e.global=new xr,e.screen=new xr,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(Nr)},e}(Ga),Wa=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}(Va),Ua=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}(Va),Ha=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}(Ga),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=$r(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=$r(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=Xt(n)&&n||Rt(n)&&n.capture,i=$r(e)?void 0:e;return t=r?"".concat(t,"capture"):t,e=$r(e)?e:null==e?void 0:e.handleEvent,this.emitter.off(t,e,i),this},t.prototype.emit=function(t,e){this.dispatchEvent(new Ha(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}(),$a=function(t){function e(){var e=t.apply(this,l([],c(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===$n.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===$n.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===$n.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(Nr)},e.prototype.lookupNamespaceURI=function(t){throw new Error(Nr)},e.prototype.lookupPrefix=function(t){throw new Error(Nr)},e.prototype.normalize=function(){throw new Error(Nr)},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}(qa),Ya=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=E(),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=ha.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")}$a.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"),$a.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&&$a.isNode(o)&&o.parentNode;h&&h!==($a.isNode(n.rootTarget)&&n.rootTarget.parentNode)&&h!==e.target;)h=h.parentNode;if(!h||h===($a.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!==($a.isNode(n.rootTarget)&&n.rootTarget.parentNode);)d.currentTarget=d.target,n.notifyTarget(d),r&&n.notifyTarget(d,"mouseenter"),$a.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!==($a.isNode(n.rootTarget)&&n.rootTarget.parentNode);)a.currentTarget=a.target,n.notifyTarget(a),r&&n.notifyTarget(a,"mouseleave"),$a.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!==($a.isNode(n.rootTarget)&&n.rootTarget.parentNode);)o.currentTarget=o.target,n.notifyTarget(o),i&&n.notifyTarget(o,"mouseenter"),$a.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"),$a.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 xr(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 xr(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(),u=r.getWorldTransform(),c=T(this.tmpMatrix,u,s),l=nt(this.tmpVec3,e/o*2-1,2*(1-n/a)-1,0);return lt(l,l,c),new xr(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=nt(this.tmpVec3,t.x,t.y,0);lt(this.tmpVec3,this.tmpVec3,i);var a=this.context.config,s=a.width,u=a.height;return new xr((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++)$a.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(Wa);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(Ua);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(Ua);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(Wa);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=ha.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||$a.isNode(r)&&r.parentNode===e))break;e=t[n]}return e},t.prototype.getCursor=function(t){for(var e=t;e;){var n=aa(e)&&e.getAttribute("cursor");if(n)return n;e=$a.isNode(e)&&e.parentNode}},t}(),Ka=function(){function t(){}return t.prototype.getOrCreateCanvas=function(t,e){if(this.canvas)return this.canvas;if(t||ds.offscreenCanvas)this.canvas=t||ds.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"}(Fa||(Fa={}));var Xa,Za=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 Ca,initAsync:new Na,dirtycheck:new ka,cull:new ka,beginFrame:new Ca,beforeRender:new Ca,render:new Ca,afterRender:new Ca,endFrame:new Ca,destroy:new Ca,pick:new Sa,pickSync:new ka,pointerDown:new Ca,pointerUp:new Ca,pointerMove:new Ca,pointerOut:new Ca,pointerOver:new Ca,pointerWheel:new Ca,pointerCancel:new Ca,click:new Ca}}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(Fa.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(Fa.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,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!==ei.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;sa(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(sa)},t.prototype.destroy=function(){this.inited=!1,this.hooks.destroy.call(),this.globalRuntime.sceneGraphService.clearPendingEvents()},t.prototype.dirtify=function(){this.context.renderingContext.renderReasons.add(Fa.DISPLAY_OBJECT_CHANGED)},t}(),Qa=/\[\s*(.*)=(.*)\s*\]/,Ja=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(Qa),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 Pt(n)?"":n.toString?n.toString():""},t}(),ts=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}(Ga);function es(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"}(Xa||(Xa={}));var ns,rs,is,os=new ts(Xa.REPARENT,null,"","","",0,"",""),as=function(){function t(t){var e,n,r,i,o,a,s,u,c=this;this.runtime=t,this.pendingEvents=[],this.boundsChangedEvent=new Ha(Xa.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();Et(a,n[0],n[1],n[2]);var s=c.getRotation(t),u=c.getRotation(t.parentNode);xt(e,u),bt(e,e),yt(a,e,a),yt(o.localRotation,a,s),Nt(o.localRotation,o.localRotation),c.dirtifyLocal(t,o)}else c.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;Et(n,e[0],e[1],e[2]),Mt(o.localRotation,o.localRotation,n),c.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){Et(o.localRotation,e[0],e[1],e[2]);var a=c.getRotation(t.parentNode);xt(r,bt(mt(),a)),Mt(o.localRotation,o.localRotation,r),c.dirtifyLocal(t,o)}else c.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],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,i.localRotation),rt(i.localPosition,i.localPosition,e),c.dirtifyLocal(t,i))},this.setPosition=(i=E(),o=Z(),function(t,e){var n=t.transformable;if(o[0]=e[0],o[1]=e[1],o[2]=e[2]||0,!ht(c.getPosition(t),o)){if(et(n.position,o),null!==t.parentNode&&t.parentNode.transformable){var r=t.parentNode.transformable;x(i,r.worldTransform),C(i,i),lt(n.localPosition,o,i)}else et(n.localPosition,o);c.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),c.dirtifyLocal(e,r))}}(),this.translate=(a=Z(),s=Z(),u=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(u,c.getPosition(t),e),c.setPosition(t,u))}),this.setRotation=function(){var t=mt();return function(e,n,r,i,o){var a=e.transformable;if("number"==typeof n&&(n=wt(n,r,i,o)),null!==e.parentNode&&e.parentNode.transformable){var s=c.getRotation(e.parentNode);xt(t,s),bt(t,t),yt(a.localRotation,t,n),Nt(a.localRotation,a.localRotation),c.dirtifyLocal(e,a)}else c.setLocalRotation(e,n)}},this.displayObjectDependencyMap=new WeakMap,this.calcLocalTransform=function(){var t=E(),e=Z(),n=wt(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]),T(r.localTransform,r.localTransform,i)}var o=B(t,n,e,r.localScale,r.origin);T(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,Pt(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=ei.ADDED);var s=t.transformable;s&&this.dirtifyWorld(t,s),s.frozen&&this.unfreezeParentToRoot(t),o&&t.dispatchEvent(os)},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=ei.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;Et(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=wt(e,n,r,i));var o=t.transformable;xt(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=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;)es(n),n=n.parentNode;e&&t.forEach((function(t){es(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 ts(Xa.ATTR_MODIFIED,n,e,e,t,ts.MODIFICATION,e,e)),n.isCustomElement&&n.isConnected&&n.attributeChangedCallback&&n.attributeChangedCallback(t,e,e)}))}))},t.prototype.getPosition=function(t){var e=t.transformable;return I(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=I(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(mr.isEmpty(r))return null;var i=n||new mr;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 mr},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 mr).update(r.center,r.halfExtents))})),o||(o=new mr),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=E();t.parentNode.transformable&&(e=C(E(),this.getWorldTransform(t.parentNode)));var n=this.getBounds(t);if(!mr.isEmpty(n)){var r=new mr;return r.setFromTransformedAABB(n,e),r}}return this.getBounds(t)},t.prototype.getBoundingClientRect=function(t){var e,n,r,i=this.getGeometryBounds(t);mr.isEmpty(i)||(r=new mr).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 Mr(s+((null==o?void 0:o.left)||0),u+((null==o?void 0:o.top)||0),h-s,d-u)}return new Mr((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):x(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}(),ss={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!"#$%&'()*+,-./:;]/,cs=new RegExp("".concat(/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/.source,"|").concat(/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹓﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/.source,"|").concat(/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/.source,"|").concat(/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/.source)),ls=new RegExp("".concat(/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/.source,"|").concat(/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/.source,"|").concat(/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/.source,"|").concat(/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/.source)),hs=function(){function t(t){var e=this;this.runtime=t,this.fontMetricsCache={},this.shouldBreakByKinsokuShorui=function(t,n){return!e.isBreakingSpace(n)&&!(!t||!ls.exec(n)&&!cs.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=ss.MetricsString+ss.BaselineSymbol,a=Math.ceil(i.measureText(o).width),s=Math.ceil(i.measureText(ss.BaselineSymbol).width),u=ss.HeightMultiplier*s;s=s*ss.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=e.wordWrap,o=e.lineHeight,a=e.lineWidth,s=e.textBaseline,u=e.textAlign,c=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(","),u=s.length-1;u>=0;u--){var c=s[u].trim();!Pa.test(c)&&Ta.indexOf(c)<0&&(c='"'.concat(c,'"')),s[u]=c}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)*c;v[M]=b,y=Math.max(y,b)}N=y+a;var E=o||p.fontSize+a,w=Math.max(E,p.fontSize+a)+(m.length-1)*(E+d),x=0;return"middle"===s?x=-w/2:"bottom"===s||"alphabetic"===s||"ideographic"===s?x=-w:"top"!==s&&"hanging"!==s||(x=0),{font:f,width:N,height:w,lines:m,lineWidths:v,lineHeight:E+=d,maxLineWidth:y,fontProperties:p,lineMetrics:v.map((function(t,e){var n=0;return"center"===u||"middle"===u?n-=t/2:"right"!==u&&"end"!==u||(n-=t),new Mr(n-a/2,x+e*E,t+a,E)}))}}l.getTotalLength();for(var M=0;M<m.length;M++)var N=g.measureText(m[M]).width+(m[M].length-1)*c},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,u=void 0===s?1/0:s,c=e.textOverflow,l=this.runtime.offscreenCanvasCreator.getOrCreateContext(n),h=o+a,d="";"ellipsis"===c?d="...":c&&"clip"!==c&&(d=c);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),E=0;E<b.length;E++){var w=b[E],x=t[E-1],M=t[E+1],N=v(w);if(this.isNewline(w)){if(++p>=u){e.isOverflowing=!0;break}g=0,f[p]=""}else{if(g>0&&g+N>h){if(p+1>=u){if(e.isOverflowing=!0,y>0&&y<=h){for(var S=f[p].length,C=0,k=S,T=0;T<S;T++){var P=v(f[p][T]);if(C+P+y>h){k=T;break}C+=P}f[p]=(f[p]||"").slice(0,k)+d}break}if(g=0,f[++p]="",this.isBreakingSpace(w))continue;this.canBreakInLastChar(w)||(f=this.trimToBreakable(f),g=this.sumTextWidthByCache(f[p]||"",m)),this.shouldBreakByKinsokuShorui(w,M)&&(f=this.trimByKinsokuShorui(f),g+=v(x||""))}g+=N,f[p]=(f[p]||"")+w}}return f.join("\n")},t.prototype.isBreakingSpace=function(t){return"string"==typeof t&&ss.BreakingSpaces.indexOf(t.charCodeAt(0))>=0},t.prototype.isNewline=function(t){return"string"==typeof t&&ss.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||!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}(),ds={},fs=(rs=new za,is=new ja,(ns={})[$n.CIRCLE]=new Ra,ns[$n.ELLIPSE]=new La,ns[$n.RECT]=rs,ns[$n.IMAGE]=rs,ns[$n.GROUP]=rs,ns[$n.LINE]=new Da,ns[$n.TEXT]=new Ba(ds),ns[$n.POLYLINE]=is,ns[$n.POLYGON]=is,ns[$n.PATH]=new Ia,ns[$n.HTML]=null,ns[$n.MESH]=null,ns),ps=function(){var t,e=new Bo,n=new Vo;return(t={})[pi.PERCENTAGE]=null,t[pi.NUMBER]=new Ko,t[pi.ANGLE]=new jo,t[pi.DEFINED_PATH]=new zo,t[pi.PAINT]=e,t[pi.COLOR]=e,t[pi.FILTER]=new Fo,t[pi.LENGTH]=n,t[pi.LENGTH_PERCENTAGE]=n,t[pi.LENGTH_PERCENTAGE_12]=new Wo,t[pi.LENGTH_PERCENTAGE_14]=new Uo,t[pi.COORDINATE]=new $o,t[pi.OFFSET_DISTANCE]=new Xo,t[pi.OPACITY_VALUE]=new Zo,t[pi.PATH]=new Qo,t[pi.LIST_OF_POINTS]=new Jo,t[pi.SHADOW_BLUR]=new ta,t[pi.TEXT]=new ea,t[pi.TEXT_TRANSFORM]=new na,t[pi.TRANSFORM]=new Aa,t[pi.TRANSFORM_ORIGIN]=new Oa,t[pi.Z_INDEX]=new _a,t[pi.MARKER]=new Yo,t}();ds.CameraContribution=Rr,ds.AnimationTimeline=null,ds.EasingFunction=null,ds.offscreenCanvasCreator=new Ka,ds.sceneGraphSelector=new Ja,ds.sceneGraphService=new as(ds),ds.textService=new hs(ds),ds.geometryUpdaterFactory=fs,ds.CSSPropertySyntaxFactory=ps,ds.styleValueRegistry=new Io(ds),ds.layoutRegistry=null,ds.globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},ds.enableCSSParsing=!0,ds.enableDataset=!1,ds.enableStyleSyntax=!0,ds.enableSizeAttenuation=!1;var gs=0,ms=new ts(Xa.INSERTED,null,"","","",0,"",""),vs=new ts(Xa.REMOVED,null,"","","",0,"",""),ys=new Ha(Xa.DESTROY),bs=function(t){function e(){var e=t.apply(this,l([],c(arguments),!1))||this;return e.entity=gs++,e.renderable={bounds:void 0,boundsDirty:!0,renderBounds:void 0,renderBoundsDirty:!0,dirtyRenderBounds:void 0,dirty:!1},e.cullable={strategy:ti.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=ds.enableCSSParsing?{anchor:ii,opacity:ii,fillOpacity:ii,strokeOpacity:ii,fill:ii,stroke:ii,transform:ii,transformOrigin:ii,visibility:ii,pointerEvents:ii,lineWidth:ii,lineCap:ii,lineJoin:ii,increasedLineWidthForHitTesting:ii,fontSize:ii,fontFamily:ii,fontStyle:ii,fontWeight:ii,fontVariant:ii,textAlign:ii,textBaseline:ii,textTransform:ii,zIndex:ii,filter:ii,shadowType:ii}: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(Nr)},e.prototype.appendChild=function(t,e){var n;if(t.destroyed)throw new Error("Cannot append a destroyed element.");return ds.sceneGraphService.attach(t,this,e),(null===(n=this.ownerDocument)||void 0===n?void 0:n.defaultView)&&this.ownerDocument.defaultView.mountChildren(t),ms.relatedNode=this,t.dispatchEvent(ms),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 vs.relatedNode=this,t.dispatchEvent(vs),(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)&&t.ownerDocument.defaultView.unmountChildren(t),ds.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 ds.sceneGraphService.matches(t,this)},e.prototype.getElementById=function(t){return ds.sceneGraphService.querySelector("#".concat(t),this)},e.prototype.getElementsByName=function(t){return ds.sceneGraphService.querySelectorAll('[name="'.concat(t,'"]'),this)},e.prototype.getElementsByClassName=function(t){return ds.sceneGraphService.querySelectorAll(".".concat(t),this)},e.prototype.getElementsByTagName=function(t){return ds.sceneGraphService.querySelectorAll(t,this)},e.prototype.querySelector=function(t){return ds.sceneGraphService.querySelector(t,this)},e.prototype.querySelectorAll=function(t){return ds.sceneGraphService.querySelectorAll(t,this)},e.prototype.closest=function(t){var e=this;do{if(ds.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(ys),this.remove(),this.emitter.removeAllListeners(),this.destroyed=!0},e.prototype.getGeometryBounds=function(){return ds.sceneGraphService.getGeometryBounds(this)},e.prototype.getRenderBounds=function(){return ds.sceneGraphService.getBounds(this,!0)},e.prototype.getBounds=function(){return ds.sceneGraphService.getBounds(this)},e.prototype.getLocalBounds=function(){return ds.sceneGraphService.getLocalBounds(this)},e.prototype.getBoundingClientRect=function(){return ds.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 ds.enableCSSParsing?null:void 0;var e=this.attributes[t];if(void 0===e){var n=Kr(t);return e=this.attributes[n],ds.enableCSSParsing&&Pt(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(Nr)},e.prototype.getAttributeNode=function(t){throw new Error(Nr)},e.prototype.getAttributeNodeNS=function(t,e){throw new Error(Nr)},e.prototype.hasAttributeNS=function(t,e){throw new Error(Nr)},e.prototype.removeAttributeNS=function(t,e){throw new Error(Nr)},e.prototype.removeAttributeNode=function(t){throw new Error(Nr)},e.prototype.setAttributeNS=function(t,e,n){throw new Error(Nr)},e.prototype.setAttributeNode=function(t){throw new Error(Nr)},e.prototype.setAttributeNodeNS=function(t){throw new Error(Nr)},e.prototype.toggleAttribute=function(t,e){throw new Error(Nr)},e}($a);function Es(t){return!!(null==t?void 0:t.nodeName)}var ws,xs=new ts(Xa.ATTR_MODIFIED,null,null,null,null,ts.MODIFICATION,null,null),Ms={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:""},Ns={anchor:[0,0],fill:ci,stroke:ci,transform:[],zIndex:0,filter:[],shadowType:"outer",miterLimit:10},Ss=i(i({},Ns),{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:"visible",pointerEvents:"auto",lineWidth:1,lineCap:"butt",lineJoin:"miter",increasedLineWidthForHitTesting:0,fillRule:"nonzero"}),Cs=l(l([],c(["opacity","fillOpacity","strokeOpacity","transformOrigin","visibility","pointerEvents","lineWidth","lineCap","lineJoin","increasedLineWidthForHitTesting"]),!1),["fontSize","fontFamily","fontStyle","fontWeight","fontVariant","textAlign","textBaseline","textTransform"],!1),ks="data-",Ts=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||$n.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,ds.enableCSSParsing?Ns:Ss,r.config.initialParsedStyle),ds.enableCSSParsing&&Object.assign(r.attributes,Ms),r.initAttributes(r.config.style);var i=ds.globalThis.Proxy?ds.globalThis.Proxy:function(){};return ds.enableDataset&&(r.dataset=new i({},{get:function(t,e){var n="".concat(ks).concat(qr(e));return void 0!==t[n]?t[n]:r.getAttribute(n)},set:function(t,e,n){return r.setAttribute("".concat(ks).concat(qr(e)),n),!0}})),ds.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};ds.enableCSSParsing&&(n.usedAttributes=Cs);var r={};for(var i in t){r[Kr(i)]=t[i]}ds.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=Kr(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];ds.styleValueRegistry.processProperties(this,((r={})[t]=e,r),n),i.dirty=!0;var s=this.parsedStyle[t];this.isConnected&&(xs.relatedNode=this,xs.prevValue=o,xs.newValue=e,xs.attrName=t,xs.prevParsedValue=a,xs.newParsedValue=s,this.isMutationObserved?this.dispatchEvent(xs):(xs.target=this,this.ownerDocument.defaultView.dispatchEvent(xs,!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 Mr(n,r,o-n,a-r)},e.prototype.setOrigin=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),ds.sceneGraphService.setOrigin(this,rr(t,e,n)),this},e.prototype.getOrigin=function(){return ds.sceneGraphService.getOrigin(this)},e.prototype.setPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),ds.sceneGraphService.setPosition(this,rr(t,e,n)),this},e.prototype.setLocalPosition=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),ds.sceneGraphService.setLocalPosition(this,rr(t,e,n)),this},e.prototype.translate=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),ds.sceneGraphService.translate(this,rr(t,e,n)),this},e.prototype.translateLocal=function(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=0),ds.sceneGraphService.translateLocal(this,rr(t,e,n)),this},e.prototype.getPosition=function(){return ds.sceneGraphService.getPosition(this)},e.prototype.getLocalPosition=function(){return ds.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=rr(t,e=e||t,n=n||t)),ds.sceneGraphService.scaleLocal(this,t),this},e.prototype.setLocalScale=function(t,e,n){return"number"==typeof t&&(t=rr(t,e=e||t,n=n||t)),ds.sceneGraphService.setLocalScale(this,t),this},e.prototype.getLocalScale=function(){return ds.sceneGraphService.getLocalScale(this)},e.prototype.getScale=function(){return ds.sceneGraphService.getScale(this)},e.prototype.getEulerAngles=function(){return or(c(ar(Z(),ds.sceneGraphService.getWorldTransform(this)),3)[2])},e.prototype.getLocalEulerAngles=function(){return or(c(ar(Z(),ds.sceneGraphService.getLocalRotation(this)),3)[2])},e.prototype.setEulerAngles=function(t){return ds.sceneGraphService.setEulerAngles(this,0,0,t),this},e.prototype.setLocalEulerAngles=function(t){return ds.sceneGraphService.setLocalEulerAngles(this,0,0,t),this},e.prototype.rotateLocal=function(t,e,n){return Pt(e)&&Pt(n)?ds.sceneGraphService.rotateLocal(this,0,0,t):ds.sceneGraphService.rotateLocal(this,t,e,n),this},e.prototype.rotate=function(t,e,n){return Pt(e)&&Pt(n)?ds.sceneGraphService.rotate(this,0,0,t):ds.sceneGraphService.rotate(this,t,e,n),this},e.prototype.setRotation=function(t,e,n,r){return ds.sceneGraphService.setRotation(this,t,e,n,r),this},e.prototype.setLocalRotation=function(t,e,n,r){return ds.sceneGraphService.setLocalRotation(this,t,e,n,r),this},e.prototype.setLocalSkew=function(t,e){return ds.sceneGraphService.setLocalSkew(this,t,e),this},e.prototype.getRotation=function(){return ds.sceneGraphService.getRotation(this)},e.prototype.getLocalRotation=function(){return ds.sceneGraphService.getLocalRotation(this)},e.prototype.getLocalSkew=function(){return ds.sceneGraphService.getLocalSkew(this)},e.prototype.getLocalTransform=function(){return ds.sceneGraphService.getLocalTransform(this)},e.prototype.getWorldTransform=function(){return ds.sceneGraphService.getWorldTransform(this)},e.prototype.setLocalTransform=function(t){return ds.sceneGraphService.setLocalTransform(this,t),this},e.prototype.resetLocalTransform=function(){ds.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([],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?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=c(I(Z(),e),2),r=n[0],i=n[1],o=c(j(Z(),e),2),a=o[0],s=o[1],u=z(mt(),e),l=c(ar(Z(),u),3),h=l[0],d=l[2];return sr(h||d,r,i,a,s)},e.prototype.getLocalMatrix=function(){return this.getMatrix(this.getLocalTransform())},e.prototype.setMatrix=function(t){var e=c(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=c(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(){ds.enableCSSParsing?this.style.visibility="visible":this.forEach((function(t){t.style.visibility="visible"}))},e.prototype.hide=function(){ds.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}(bs),Ps=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:$n.CIRCLE,style:ds.enableCSSParsing?i({cx:"",cy:"",r:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:ds.enableCSSParsing?null:[fi,fi]}},r))||this}return r(e,t),e}(Ts),As=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:ds.enableCSSParsing?i({x:"",y:""},r):i({},r)},a))||this).isCustomElement=!0,n}return r(e,t),e}(Ts),Os=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:$n.ELLIPSE,style:ds.enableCSSParsing?i({cx:"",cy:"",rx:"",ry:""},n):i({},n),initialParsedStyle:{anchor:[.5,.5],transformOrigin:ds.enableCSSParsing?null:[fi,fi]}},r))||this}return r(e,t),e}(Ts),_s=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:$n.GROUP,style:ds.enableCSSParsing?i({x:"",y:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(Ts),Rs=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:$n.HTML,style:ds.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 Mr(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 mr,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(E(),this.parentNode.getWorldTransform()),e=this.getBounds();if(!mr.isEmpty(e)){var n=new mr;return n.setFromTransformedAABB(e,t),n}}return this.getBounds()},e}(Ts),Ls=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:$n.IMAGE,style:ds.enableCSSParsing?i({x:"",y:"",img:"",width:"",height:""},n):i({},n)},r))||this}return r(e,t),e}(Ts),Ds=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:$n.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&&Es(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),c&&Es(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&&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,u=e.y1,c=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=u-h,p=s-a,g=c-u,y=i||0,b=this.markerStartAngle):(m=s-l,v=c-h,p=a-s,g=u-c,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,u=n.defY,c=Dn(r,i,o,a,t),l=c.x,h=c.y,d=lt(Z(),tt(l-s,h-u,0),e?this.getWorldTransform():this.getLocalTransform());return new xr(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 Ln(t.x1,t.y1,t.x2,t.y2)},e}(Ts),Is=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:$n.PATH,style:ds.enableCSSParsing?i({path:"",miterLimit:""},r):i({},r),initialParsedStyle:ds.enableCSSParsing?null:{miterLimit:4,path:i({},gi)}},a))||this).markerStartAngle=0,n.markerEndAngle=0,n.markerMidList=[];var s=n.parsedStyle,u=s.markerStart,c=s.markerEnd,l=s.markerMid;return u&&Es(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),l&&Es(l)&&n.placeMarkerMid(l),c&&Es(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){"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,u=t?n:r;if(u&&Es(u)){var l,h,d,f,p,g,m;if(t){var v=c(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,E=c(this.getEndTangent(),2);y=E[0];f=(b=E[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),u.setLocalEulerAngles(180*l/Math.PI+m),u.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=c(n[o].currentPoint,2),s=a[0],u=a[1],l=1===o?t:t.cloneNode(!0);this.markerMidList.push(l),this.appendChild(l),l.setLocalPosition(s-r,u-i)}},e.prototype.getTotalLength=function(){return Xi(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 He(t,e,i(i({},n),{bbox:!1,length:!0})).point}(n.path.absolutePath,t),s=a.x,u=a.y,c=lt(Z(),tt(s-r,u-o,0),e?this.getWorldTransform():this.getLocalTransform());return new xr(c[0],c[1])},e.prototype.getPoint=function(t,e){return void 0===e&&(e=!1),this.getPointAtLength(t*Xi(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}(Ts),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:$n.POLYGON,style:ds.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!0},r):i({},r),initialParsedStyle:ds.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&&Es(u)&&(n.markerStartAngle=u.getLocalEulerAngles(),n.appendChild(u)),l&&Es(l)&&n.placeMarkerMid(l),c&&Es(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&&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,u=e.defY,c=(a||{}).points,l=t?n:r;if(l&&Es(l)&&c){var h,d,f,p,g,m,v;if(p=c[0][0]-s,g=c[0][1]-u,t)d=c[1][0]-c[0][0],f=c[1][1]-c[0][1],m=i||0,v=this.markerStartAngle;else{var y=c.length;this.parsedStyle.isClosed?(d=c[y-1][0]-c[0][0],f=c[y-1][1]-c[0][1]):(p=c[y-1][0]-s,g=c[y-1][1]-u,d=c[y-2][0]-c[y-1][0],f=c[y-2][1]-c[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,u=o[a][1]-i,c=1===a?t:t.cloneNode(!0);this.markerMidList.push(c),this.appendChild(c),c.setLocalPosition(s,u)}},e}(Ts),zs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:$n.POLYLINE,style:ds.enableCSSParsing?i({points:"",miterLimit:"",isClosed:!1},n):i({},n),initialParsedStyle:ds.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,u=0,c=0;s.forEach((function(e,n){t>=e[0]&&t<=e[1]&&(u=(t-e[0])/(e[1]-e[0]),c=n)}));var l=Dn(a[c][0],a[c][1],a[c+1][0],a[c+1][1],u),h=l.x,d=l.y,f=lt(Z(),tt(h-r,d-i,0),e?this.getWorldTransform():this.getLocalTransform());return new xr(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}(js),Bs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:$n.RECT,style:ds.enableCSSParsing?i({x:"",y:"",width:"",height:"",radius:""},n):i({},n)},r))||this}return r(e,t),e}(Ts),Fs=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=o(e,["style"]);return t.call(this,i({type:$n.TEXT,style:ds.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:ds.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}(Ts),Gs=function(){function t(){this.registry={},this.define($n.CIRCLE,Ps),this.define($n.ELLIPSE,Os),this.define($n.RECT,Bs),this.define($n.IMAGE,Ls),this.define($n.LINE,Ds),this.define($n.GROUP,_s),this.define($n.PATH,Is),this.define($n.POLYGON,js),this.define($n.POLYLINE,zs),this.define($n.TEXT,Fs),this.define($n.HTML,Rs)}return t.prototype.define=function(t,e){this.registry[t]=e},t.prototype.get=function(t){return this.registry[t]},t}(),Vs=function(t){function e(){var e=t.call(this)||this;e.defaultView=null,e.ownerDocument=null,e.nodeName="document";try{e.timeline=new ds.AnimationTimeline(e)}catch(t){}var n={};return _o.forEach((function(t){var e=t.n,r=t.inh,i=t.d;r&&i&&(n[e]=$r(i)?i($n.GROUP):i)})),e.documentElement=new _s({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?Fs:_s);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(Nr)},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 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(Sr)},e.prototype.insertBefore=function(t,e){throw new Error(Sr)},e.prototype.removeChild=function(t,e){throw new Error(Sr)},e.prototype.replaceChild=function(t,e,n){throw new Error(Sr)},e.prototype.append=function(){throw new Error(Sr)},e.prototype.prepend=function(){throw new Error(Sr)},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}($a),Ws=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 Ha(Xa.CULLED)),null)}return t})),r.hooks.afterRender.tap(t.tag,(function(t){t.cullable.visibilityPlaneMask=-1}))},t.tag="Culling",t}(),Us=function(){function t(){var t=this;this.autoPreventDefault=!1,this.rootPointerEvent=new Wa(null),this.rootWheelEvent=new Ua(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.getViewportXY=function(t){var e,n,r=t.offsetX,i=t.offsetY,o=t.clientX,a=t.clientY;if(!this.context.config.supportsCSSTransform||Pt(r)||Pt(i)){var s=this.context.eventService.client2Viewport(new xr(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),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=la[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=ha.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}(),Hs=[$n.CIRCLE,$n.ELLIPSE,$n.IMAGE,$n.RECT,$n.LINE,$n.POLYLINE,$n.POLYGON,$n.TEXT,$n.PATH,$n.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(mr.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||gr.INDETERMINATE,a.planes),i.visible=i.visibilityPlaneMask!==gr.OUTSIDE,i.visible},t.prototype.computeVisibilityWithPlaneMask=function(t,e,n,r){if(n===gr.OUTSIDE||n===gr.INSIDE)return n;for(var i=gr.INSIDE,o=Hs.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(st(l,e.getPositiveFarPoint(r[a]))+h<0)return gr.OUTSIDE;st(l,e.getNegativeFarPoint(r[a]))+h<0&&(i|=u)}}return i},t}(),$s=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()},u=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()},c=function(t){var e=t.target;ds.enableSizeAttenuation&&ds.styleValueRegistry.updateSizeAttenuation(e,a.getCamera().getZoom()),ds.enableCSSParsing&&ds.styleValueRegistry.recalc(e),ds.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),ds.sceneGraphService.dirtifyToRoot(e),r.dirtify()};r.hooks.init.tap(t.tag,(function(){a.addEventListener(Xa.MOUNTED,c),a.addEventListener(Xa.UNMOUNTED,l),a.addEventListener(Xa.ATTR_MODIFIED,s),a.addEventListener(Xa.BOUNDS_CHANGED,u)})),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener(Xa.MOUNTED,c),a.removeEventListener(Xa.UNMOUNTED,l),a.removeEventListener(Xa.ATTR_MODIFIED,s),a.removeEventListener(Xa.BOUNDS_CHANGED,u),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=c(i.getMin(),2),a=o[0],s=o[1],u=c(i.getMax(),2),l=u[0],h=u[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 Ys=new Ha(Xa.MOUNTED),Ks=new Ha(Xa.UNMOUNTED),Xs=new Ha(ws.BEFORE_RENDER),Zs=new Ha(ws.RERENDER),Qs=new Ha(ws.AFTER_RENDER),Js=function(t){function e(e){var n=t.call(this)||this;n.Element=Ts,n.inited=!1,n.context={},n.document=new Vs,n.document.defaultView=n,n.customElements=new Gs;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,v=e.supportsTouchEvents,y=e.supportsCSSTransform,b=e.supportsMutipleCanvasesInOneContainer,E=e.useNativeClickEvent,w=e.alwaysTriggerPointerEventOnCanvas,x=e.isTouchEvent,M=e.isMouseEvent;b||function(t,e){if(t){var n="string"==typeof t?t:t.id||ia++;ra[n]&&ra[n].destroy(),ra[n]=e}}(r,n);var N=a,S=s,C=u;return i&&(C=(C=u||oa&&window.devicePixelRatio||1)>=1?Math.ceil(C):1,N=a||function(t){var e=ca(t,"width");return"auto"===e?t.offsetWidth:parseFloat(e)}(i)||i.width/C,S=s||function(t){var e=ca(t,"height");return"auto"===e?t.offsetHeight:parseFloat(e)}(i)||i.height/C),o&&(ds.offscreenCanvas=o),n.devicePixelRatio=C,n.requestAnimationFrame=null!=f?f:xa.bind(ds.globalThis),n.cancelAnimationFrame=null!=p?p:Ma.bind(ds.globalThis),n.supportsTouchEvents=null!=v?v:"ontouchstart"in ds.globalThis,n.supportsPointerEvents=null!=m?m:!!ds.globalThis.PointerEvent,n.isTouchEvent=null!=x?x:function(t){return n.supportsTouchEvents&&t instanceof ds.globalThis.TouchEvent},n.isMouseEvent=null!=M?M:function(t){return!ds.globalThis.MouseEvent||t instanceof ds.globalThis.MouseEvent&&(!n.supportsPointerEvents||!(t instanceof ds.globalThis.PointerEvent))},n.initRenderingContext({container:r,canvas:i,width:N,height:S,renderer:c,offscreenCanvas:o,devicePixelRatio:C,cursor:h||"default",background:l||"transparent",createImage:g,document:d,supportsCSSTransform:y,useNativeClickEvent:E,alwaysTriggerPointerEventOnCanvas:w}),n.initDefaultCamera(N,S,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 ds.CameraContribution;i.clipSpaceNearZ=n,i.setType(yr.EXPLORING,br.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(Or,(function(){r.context.renderingContext.renderReasons.add(Fa.CAMERA_CHANGED),ds.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){ds.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 Ha(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 Ha(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 Ha(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(Xs),this.getRenderingService().render(this.getConfig(),(function(){t.dispatchEvent(Zs)})),this.dispatchEvent(Qs)},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 Kn,this.context.renderingPlugins=[],this.context.renderingPlugins.push(new Us,new $s,new Ws([new qs])),this.loadRendererContainerModule(t),this.context.contextService=new this.context.ContextService(i(i({},ds),this.context)),this.context.renderingService=new Za(ds,this.context),this.context.eventService=new Ya(ds,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 Ha(ws.READY))})):r.dispatchEvent(new Ha(ws.READY)),r.readyPromise&&r.resolveReadyPromise()):r.dispatchEvent(new Ha(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(ds)}))},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(ds)})),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(Ks):(Ks.target=t,this.dispatchEvent(Ks,!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(Ys):(Ys.target=t,this.dispatchEvent(Ys,!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),tu=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=nr(e),this.relAzimuth=nr(t),this.relRoll=nr(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===yr.EXPLORING){var r=vt(mt(),[1,0,0],ir((this.rotateWorld?1:-1)*this.relElevation)),i=vt(mt(),[0,1,0],ir((this.rotateWorld?1:-1)*this.relAzimuth)),o=vt(mt(),[0,0,1],ir(this.relRoll)),a=yt(mt(),i,r);a=yt(mt(),a,o);var s=F(E(),a);P(this.matrix,this.matrix,[0,0,-this.distance]),T(this.matrix,this.matrix,s),P(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===yr.ORBITING||this.type===yr.EXPLORING?this._getPosition():this.type===yr.TRACKING&&this._getFocalPoint(),this._update(),this},e.prototype.pan=function(t,e){var n=rr(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===yr.ORBITING||this.type===yr.EXPLORING?this._getDistance():this.type===yr.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,u=e.focalPoint,c=void 0===u?this.focalPoint:u,l=e.roll,h=e.zoom,d=new ds.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: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,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,v=r.focalPoint,y=r.zoom,b=r.roll,E=l||ds.EasingFunction(a),w=function(){n.setFocalPoint(v),n.setPosition(m),n.setRoll(b),n.setZoom(y),n.computeMatrix(),n.triggerUpdate(),d&&d()},x=function(t){void 0===g&&(g=t);var e=t-g;if(e>u)w();else{var r,i,o=E(e/u),a=Z(),s=Z();ct(a,n.focalPoint,v,o),ct(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?w():(n.computeMatrix(),n.triggerUpdate(),e<u&&(p&&p(o),n.landmarkAnimationID=n.canvas.requestAnimationFrame(x)))}};this.canvas.requestAnimationFrame(x)}},e.prototype.syncFromLandmark=function(t){this.matrix=x(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}(Rr);ds.CameraContribution=tu;var eu=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}(Ga),nu=0,ru=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(nu++),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 eu(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(Nr)},t.prototype.addEventListener=function(t,e,n){throw new Error(Nr)},t.prototype.removeEventListener=function(t,e,n){throw new Error(Nr)},t.prototype.dispatchEvent=function(t){throw new Error(Nr)},t.prototype.commitStyles=function(){throw new Error(Nr)},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 eu(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 eu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}},t}(),iu=.1,ou="function"==typeof Float32Array,au=function(t,e){return 1-3*e+3*t},su=function(t,e){return 3*e-6*t},uu=function(t){return 3*t},cu=function(t,e,n){return((au(e,n)*t+su(e,n))*t+uu(e))*t},lu=function(t,e,n){return 3*au(e,n)*t*t+2*su(e,n)*t+uu(e)},hu=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=ou?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=cu(o*iu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=iu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*iu,s=lu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=lu(e,n,r);if(0===o)return e;e-=(cu(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=cu(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+iu,t,n)};return function(t){return 0===t||1===t?t:cu(a(t),e,r)}},du=function(t){return Math.pow(t,2)},fu=function(t){return Math.pow(t,3)},pu=function(t){return Math.pow(t,4)},gu=function(t){return Math.pow(t,5)},mu=function(t){return Math.pow(t,6)},vu=function(t){return 1-Math.cos(t*Math.PI/2)},yu=function(t){return 1-Math.sqrt(1-t*t)},bu=function(t){return t*t*(3*t-2)},Eu=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)},wu=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=Vt(Number(i),1,10),u=Vt(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)},xu=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=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},Mu=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)(Vt(t,0,1)*i)/i},Nu=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 hu(r,i,o,a)(t)},Su=hu(.42,0,1,1),Cu=function(t){return function(e,n,r){return void 0===n&&(n=[]),1-t(1-e,n,r)}},ku=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}},Tu=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}},Pu={steps:Mu,"step-start":function(t){return Mu(t,[1,"start"])},"step-end":function(t){return Mu(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Nu,ease:function(t){return Nu(t,[.25,.1,.25,1])},in:Su,out:Cu(Su),"in-out":ku(Su),"out-in":Tu(Su),"in-quad":du,"out-quad":Cu(du),"in-out-quad":ku(du),"out-in-quad":Tu(du),"in-cubic":fu,"out-cubic":Cu(fu),"in-out-cubic":ku(fu),"out-in-cubic":Tu(fu),"in-quart":pu,"out-quart":Cu(pu),"in-out-quart":ku(pu),"out-in-quart":Tu(pu),"in-quint":gu,"out-quint":Cu(gu),"in-out-quint":ku(gu),"out-in-quint":Tu(gu),"in-expo":mu,"out-expo":Cu(mu),"in-out-expo":ku(mu),"out-in-expo":Tu(mu),"in-sine":vu,"out-sine":Cu(vu),"in-out-sine":ku(vu),"out-in-sine":Tu(vu),"in-circ":yu,"out-circ":Cu(yu),"in-out-circ":ku(yu),"out-in-circ":Tu(yu),"in-back":bu,"out-back":Cu(bu),"in-out-back":ku(bu),"out-in-back":Tu(bu),"in-bounce":Eu,"out-bounce":Cu(Eu),"in-out-bounce":ku(Eu),"out-in-bounce":Tu(Eu),"in-elastic":wu,"out-elastic":Cu(wu),"in-out-elastic":ku(wu),"out-in-elastic":Tu(wu),spring:xu,"spring-in":xu,"spring-out":Cu(xu),"spring-in-out":ku(xu),"spring-out-in":Tu(xu)},Au=function(t){return Pu[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)]||Pu.linear},Ou=function(t){return t},_u=1,Ru=.5,Lu=0;function Du(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Iu="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",ju=new RegExp("cubic-bezier\\("+Iu+","+Iu+","+Iu+","+Iu+"\\)"),zu=/steps\(\s*(\d+)\s*\)/,Bu=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Fu(t){var e=ju.exec(t);if(e)return hu.apply(void 0,l([],c(e.slice(1).map(Number)),!1));var n=zu.exec(t);if(n)return Du(Number(n[1]),Lu);var r=Bu.exec(t);return r?Du(Number(r[1]),{start:_u,middle:Ru,end:Lu}[r[2]]):Au(t)}function Gu(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 Vu=0,Wu=1,Uu=2,Hu=3;function qu(t,e,n){var r=function(t,e,n){if(null===e)return Vu;var r=n.endTime;return e<Math.min(n.delay,r)?Wu:e>=Math.min(n.delay+t+n.endDelay,r)?Uu:Hu}(t,e,n),i=function(t,e,n,r,i){switch(r){case Wu:return"backwards"===e||"both"===e?0:null;case Hu:return n-i;case Uu:return"forwards"===e||"both"===e?t:null;case Vu: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!==Wu&&(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!==Uu||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===Uu&&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 $u(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Yu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Fu(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:Xu(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)Yu(n)&&t.setAttribute(n,null)}}function Yu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Ku=function(t,e,n){return function(r){var i=Zu(t,e,r);return!ds.enableCSSParsing&&Wt(i)?i:n(i)}};function Xu(t,e,n,r){var i=Lo[t];if(i&&i.syntax&&i.int){var o=ds.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=void 0,s=void 0;if(ds.enableCSSParsing){var u=ds.styleValueRegistry.parseProperty(t,e,r,!1),h=ds.styleValueRegistry.parseProperty(t,n,r,!1);a=ds.styleValueRegistry.computeProperty(t,u,r,!1),s=ds.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=Ku.apply(void 0,l([],c(f),!1));return function(t){return 0===t?e:1===t?n:p(t)}}}}return Ku(!1,!0,(function(t){return t?n:e}))}function Zu(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(Zu(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments "+t+":"+e)}var Qu=function(){function t(){this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Ou,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=Fu(t),this._easing=t},enumerable:!1,configurable:!0}),t}();function Ju(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(Pt(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(!Pt(s)&&!Pt(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 tc="backwards|forwards|both|none".split("|"),ec="reverse|alternate|alternate-reverse".split("|");function nc(t,e){return function(t,e){var n=new Qu;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===tc.indexOf(t[e]))return;if("direction"===e&&-1===ec.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 rc=function(){function t(t,e,n){var r=this;this.composite="replace",this.iterationComposite="replace",this.target=t,this.timing=nc(n,!1),this.timing.effect=this,this.timing.activeDuration=Gu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=Ju(e,this.timing),this.interpolations=$u(this.normalizedKeyframes,this.timing,this.target);var i=ds.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=qu(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)},t.prototype.getKeyframes=function(){return this.normalizedKeyframes},t.prototype.setKeyframes=function(t){this.normalizedKeyframes=Ju(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 ic(t,e){return Number(t.id)-Number(e.id)}var oc=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(ic),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 rc(t,e,n),i=new ru(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(ic),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}();ds.EasingFunction=Fu,ds.AnimationTimeline=oc;const ac={duration:500},sc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var uc,cc,lc,hc,dc,fc,pc,gc;!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"}(uc||(uc={})),function(t){t.DRAW="draw",t.TRANSFORM="transform",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(cc||(cc={})),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,(lc=t.NodeEvent||(t.NodeEvent={})).CLICK="click",lc.DBLCLICK="dblclick",lc.POINTER_OVER="pointerover",lc.POINTER_LEAVE="pointerleave",lc.POINTER_ENTER="pointerenter",lc.POINTER_MOVE="pointermove",lc.POINTER_OUT="pointerout",lc.POINTER_DOWN="pointerdown",lc.POINTER_UP="pointerup",lc.CONTEXT_MENU="contextmenu",lc.DRAG_START="dragstart",lc.DRAG="drag",lc.DRAG_END="dragend",lc.DRAG_ENTER="dragenter",lc.DRAG_OVER="dragover",lc.DRAG_LEAVE="dragleave",lc.DROP="drop",t.CommonEvent=void 0,(hc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",hc.DBLCLICK="dblclick",hc.POINTER_OVER="pointerover",hc.POINTER_LEAVE="pointerleave",hc.POINTER_ENTER="pointerenter",hc.POINTER_MOVE="pointermove",hc.POINTER_OUT="pointerout",hc.POINTER_DOWN="pointerdown",hc.POINTER_UP="pointerup",hc.CONTEXT_MENU="contextmenu",hc.DRAG_START="dragstart",hc.DRAG="drag",hc.DRAG_END="dragend",hc.DRAG_ENTER="dragenter",hc.DRAG_OVER="dragover",hc.DRAG_LEAVE="dragleave",hc.DROP="drop",hc.KEY_DOWN="keydown",hc.KEY_UP="keyup",hc.WHEEL="wheel",t.ContainerEvent=void 0,(dc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",dc.KEY_UP="keyup",t.EdgeEvent=void 0,(fc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="click",fc.DBLCLICK="dblclick",fc.POINTER_OVER="pointerover",fc.POINTER_LEAVE="pointerleave",fc.POINTER_ENTER="pointerenter",fc.POINTER_MOVE="pointermove",fc.POINTER_OUT="pointerout",fc.POINTER_DOWN="pointerdown",fc.POINTER_UP="pointerup",fc.CONTEXT_MENU="contextmenu",fc.DRAG_ENTER="dragenter",fc.DRAG_OVER="dragover",fc.DRAG_LEAVE="dragleave",fc.DROP="drop",t.GraphEvent=void 0,(pc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",pc.AFTER_CANVAS_INIT="aftercanvasinit",pc.BEFORE_SIZE_CHANGE="beforesizechange",pc.AFTER_SIZE_CHANGE="aftersizechange",pc.BEFORE_ELEMENT_CREATE="beforeelementcreate",pc.AFTER_ELEMENT_CREATE="afterelementcreate",pc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",pc.AFTER_ELEMENT_UPDATE="afterelementupdate",pc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",pc.AFTER_ELEMENT_DESTROY="afterelementdestroy",pc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",pc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",pc.BEFORE_DRAW="beforedraw",pc.AFTER_DRAW="afterdraw",pc.BEFORE_RENDER="beforerender",pc.AFTER_RENDER="afterrender",pc.BEFORE_ANIMATE="beforeanimate",pc.AFTER_ANIMATE="afteranimate",pc.BEFORE_LAYOUT="beforelayout",pc.AFTER_LAYOUT="afterlayout",pc.BEFORE_TRANSFORM="beforetransform",pc.AFTER_TRANSFORM="aftertransform",function(t){t.DRAW="draw",t.ELEMENT_VISIBILITY_CHANGE="elementvisibilitychange",t.ELEMENT_STATE_CHANGE="elementstatechange",t.ELEMENT_TRANSLATE="elementtranslate"}(gc||(gc={}));const mc="combo",vc="tree";var yc;function bc(t){return"source"in t&&"target"in t}function Ec(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function wc(t,e,n){return t>=e&&t<=n}function xc(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 Mc(t){return t.max[0]-t.min[0]}function Nc(t){return t.max[1]-t.min[1]}function Sc(t){return[Mc(t),Nc(t)]}function Cc(t,e){const n=Ec(t)?function(t){const[e,n,r=0]=t,i=new mr;return i.setMinMax([e,n,r],[e,n,r]),i}(t):t.getKey().getBounds();return e?kc(n,e):n}function kc(t,e){const[n,r,i,o]=xc(e),[a,s,u]=t.min,[c,l,h]=t.max,d=new mr;return d.setMinMax([a-o,s-n,u],[c+r,l+i,h]),d}function Tc(t){if(0===t.length)return new mr;if(1===t.length)return t[0];const e=new mr;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 Pc(t,e){return wc(t[0],e.min[0],e.max[0])&&wc(t[1],e.min[1],e.max[1])}function Ac(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 Oc(t,e){const n=Jt(e);if(Pc(e,t)){switch(Ac(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]=wc(r,o,s)?r:r<o?o:s,n[1]=wc(i,a,u)?i:i<a?a:u}return n}function _c(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Rc(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 Lc(t,e="center"){const n=function(t){if(Array.isArray(t))return wc(t[0],0,1)&&wc(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 Rc(t,n)}function Dc(t,e){const n=function(t){const e="string"==typeof t?t.split(" ").map((t=>parseFloat(t))):t.slice(0,2);return wc(e[0],0,1)&&wc(e[1],0,1)?e:[.5,.5]}(e);return Rc(t,n)}function Ic(t=0){if(Wt(t))return Array(3).fill(t);const[e,n=e,r=e]=t;return[e,n,r]}function jc(t,e,n){if(Array.isArray(t))return t;const[r,i]=Ic(n),[o,a]=Ic(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 zc(t,e,n){if(Array.isArray(t))return t;const r=Ic(n)[0],i=r/2,o=Ic(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 Bc(t,e,n,r,i=jc){const o=i(t,n,r),[a,s]=Ic(r),u=new mr;return u.setMinMax([e[0]-a/2,e[1]-s/2,0],[e[0]+a/2,e[1]+s/2,0]),Dc(u,o)}function Fc(t){if(Bt(t.id)||Wt(t.id))return t.id;if(bc(t))return`${t.source}-${t.target}`;throw new Error("The data does not have available id.")}function Gc(t){return t.style?.parentId}function Vc(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Wc(t,e){return Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Vc(n,e)&&(t[function(t,e,n=!0){if(!e)return t;if(!Vc(t,e))return t;const r=t.slice(e.length);return n?Yt(r):r}(n,e)]=r),t)),{})}function Uc(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 Hc(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,(yc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",yc.EDGE="edge",yc.COMBO="combo",yc.THEME="theme",yc.PALETTE="palette",yc.LAYOUT="layout",yc.BEHAVIOR="behavior",yc.PLUGIN="plugin",yc.ANIMATION="animation";const qc=[0,0,0];function $c(t,e){return t.map(((t,n)=>t+e[n]))}function Yc(t,e){return t.map(((t,n)=>t-e[n]))}function Kc(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Xc(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function Zc(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+(n-e[r]||0)**2),0))}function Qc(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Jc(t){const e=t.reduce(((t,e)=>t+e**2),0);return t.map((t=>t/Math.sqrt(e)))}function tl(t){return 2===t.length?[t[0],t[1],0]:t}function el(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 nl(t){return[t.x,t.y]}function rl(t){return{x:t[0],y:t[1]}}function il(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function ol(t,e,n,r=!1){const i=Jc(r?Yc(t,e):Yc(e,t)),o=[i[0]*n,i[1]*n];return $c(function(t){return[t[0],t[1]]}(t),o)}function al(t,e){return t[1]===e[1]}function sl(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=tl(t),r=tl(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]]}(Yc(n,r),Yc(i,o)).every((t=>0===t))}function ul(t,e){if(sl(t,e))return;const[n,r]=t,[i,o]=e,a=((n[0]-i[0])*(i[1]-o[1])-(n[1]-i[1])*(i[0]-o[0]))/((n[0]-r[0])*(i[1]-o[1])-(n[1]-r[1])*(i[0]-o[0])),s=o[0]-i[0]?(n[0]-i[0]+a*(r[0]-n[0]))/(o[0]-i[0]):(n[1]-i[1]+a*(r[1]-n[1]))/(o[1]-i[1]);return wc(a,0,1)&&wc(s,0,1)?[n[0]+a*(r[0]-n[0]),n[1]+a*(r[1]-n[1])]:void 0}function cl(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=$c(e,o),a=$c(e,a));const s=ul([e,t],[o,a]);if(s)return s}return e}function ll(t,e){const n=e.center,r=Yc(t,e.center),i=Math.atan2(r[1],r[0]);if(isNaN(i))return n;const o=Mc(e)/2,a=Nc(e)/2;return[n[0]+o*Math.cos(i),n[1]+a*Math.sin(i)]}function hl(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 dl(t,e,n=1,r=!1){const i=r?n:1;return hl((t.max[0]-t.min[0])*i,e)}const fl="cachedStyle",pl=t=>`__${t}__`;function gl(t,e){const n=Array.isArray(e)?e:[e];se(t,fl)||ue(t,fl,{}),n.forEach((e=>{ue(se(t,fl),pl(e),t.attributes[e])}))}function ml(t,e){return se(t,[fl,pl(e)])}function vl(t,e){return pl(e)in(se(t,fl)||{})}function yl(t){const e=[],n=t=>{t.children&&t.children.length&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}const bl="visibility";class El extends As{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 kh(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:u,...c}=t;return c}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(Ph(r),e);a&&n.push(a)}}))}return Th(n)}setVisibility(){const{visibility:t}=this.attributes;!function(t,e){[t,...yl(t)].forEach((n=>{vl(n,bl)||gl(n,bl);const r=ml(n,bl);t!==n&&"hidden"===r||(n.style.visibility=e)}))}(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}class wl extends El{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:wl.defaultStyleProps},t))}isTextStyle(t){return Vc(t,"label")}isBackgroundStyle(t){return Vc(t,"background")}getTextStyle(t){const{padding:e,...n}=this.getGraphicStyle(t);return Hc(n,"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Wc(e,"background"),{min:[a,s],halfExtents:[u,c]}=this.shapeMap.text.getGeometryBounds(),[l,h,d,f]=xc(i);Object.assign(o,{x:a-f,y:s-l,width:n?Math.min(2*u,r):2*u+f+h,height:2*c+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",Fs,this.getTextStyle(t),e),this.upsert("background",Bs,this.getBackgroundStyle(t),e)}}class xl extends El{static defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};constructor(t){super(re({},{style:xl.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)}}class Ml extends El{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()?Ls:Fs,this.getIconStyle(t),e)}connectedCallback(){this.upsert("icon",this.isGImage()?Ls:Fs,this.getIconStyle(this.attributes),this)}}class Nl extends El{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:Nl.defaultStyleProps},t))}getSize(t=this.parsedAttributes){const{size:e}=t;return Ic(e)}getKeyStyle(t){const{color:e,fill:n,...r}=this.getGraphicStyle(t);return Object.assign({fill:e||n},Hc(r,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||oe(t.labelText))return!1;const{placement:e,maxWidth:n,...r}=Wc(this.getGraphicStyle(t),"label"),i=this.getKey().getLocalBounds();return Object.assign(Ch(i,e),{wordWrapWidth:dl(i,n)},r)}getHaloStyle(t){if(!1===t.halo)return!1;const{fill:e,...n}=this.getKeyStyle(t);return{...n,stroke:e,...Wc(this.getGraphicStyle(t),"halo")}}getIconStyle(t){if(!1===t.icon||oe(t.iconText||t.iconSrc))return!1;const e=Wc(this.getGraphicStyle(t),"icon"),n=this.getKey(),[r,i]=Lc(n.getLocalBounds(),"center");return{x:r,y:i,...e}}getBadgesStyle(t){const e=Uc(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=function(t){const e=Bt(t)?yI("palette",t):t;if(!Tt(e))return e}(i),s=Wc(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{...Ch(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=Wc(this.getGraphicStyle(t),"port"),{ports:i=[]}=t;return i.forEach(((e,i)=>{const o=e.key||i,a={...r,...e};if(bh(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 vh(this.getKey().getLocalBounds(),n)}getKey(){return this.shapeMap.key}getPorts(){return Uc(this.shapeMap,"port-")}getCenter(){return this.getKey().getBounds().center}getIntersectPoint(t){const e=this.getKey().getBounds();return cl(t,Lc(n=e,"center"),[Lc(n,"left-top"),Lc(n,"right-top"),Lc(n,"right-bottom"),Lc(n,"left-bottom")],!1);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}`,xl,n[t],e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{this.upsert(`port-${t}`,Ps,n[t],e)}))}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e)&&(this.drawHaloShape(t,e),this.upsert("icon",Ml,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 Sl=.8,Cl=["node","edge","combo"];class kl extends Nl{static defaultStyleProps={size:24};constructor(t){super(re({},{style:kl.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ps,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*Sl;return!!e&&{width:r,height:r,...e}}getIntersectPoint(t){return ll(t,this.getKey().getBounds())}}class Tl extends Nl{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",js,this.getKeyStyle(t),e)}getKeyStyle(t){return{...super.getKeyStyle(t),points:this.getPoints(t)}}getIntersectPoint(t){const{points:e}=this.getKeyStyle(this.parsedAttributes);return cl(t,[+(this.attributes?.x||0),+(this.attributes?.y||0)],e)}}class Pl extends Tl{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.attributes);return cl(t,[this.attributes.x,this.attributes.y],e)}}class Al extends Nl{static defaultStyleProps={size:[80,40]};constructor(t){super(re({},{style:Al.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Os,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)*Sl;return!!e&&{width:i,height:i,...e}}getIntersectPoint(t){return ll(t,this.getKey().getBounds())}}class Ol extends Tl{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)*Sl;return!!e&&{width:n,height:n,...e}}}let _l=class t extends Nl{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=Wc(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=$c(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*Sl,height:r*Sl,...e}}drawKeyShape(t,e){return this.upsert("key",Ls,this.getKeyStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Bs,this.getHaloStyle(t),e)}};class Rl extends Nl{static defaultStyleProps={size:[48,24],anchor:[.5,.5]};constructor(t){super(re({},{style:Rl.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*Sl,height:r*Sl,...e}}drawKeyShape(t,e){return this.upsert("key",Bs,this.getKeyStyle(t),e)}}class Ll extends Tl{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)*Sl;return!!e&&{width:n,height:n,...e}}getPortXY(t,e){const{placement:n="top"}=e;return vh(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 Dl extends Tl{static defaultStyleProps={size:40,direction:"up"};constructor(t){super(re({},{style:Dl.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 vh(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=Wc(this.getGraphicStyle(t),"icon"),a=this.getKey().getLocalBounds(),[s,u]=function(t,e){const{center:n}=t,[r,i]=Sc(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]=Sc(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)*Sl;return{x:s,y:u,width:c,height:c,...o}}}class Il extends Nl{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:Il.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 Xc(o.reduce(((t,e)=>$c(t,_c(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 Bc(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]=xc(e);return $c(Ic(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Ic(t.collapsedSize)}getExpandedKeySize(t){if(!oe(t.size))return Ic(t.size);const e=this.getContentBBox(t);return[Mc(e),Nc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=Tc(e.map((t=>t.getBounds())));return n?kc(r,n):r}drawCollapsedMarkerShape(t,e){this.upsert("collapsed-marker",Ml,this.getCollapsedMarkerStyle(t),e)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const{type:e,...n}=Wc(this.getGraphicStyle(t),"collapsedMarker"),r=this.getKey(),[i,o]=Lc(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(Fc(t)))).length.toString():Tt(t)?t(r):""}getComboZIndex(t){return(t.context?.model.getAncestorsData(this.id,mc)||[]).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 jl extends Il{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Ps,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),r=Wc(n,"collapsed"),[i]=this.getKeySize(t);return{...n,...e&&r,r:i/2}}getCollapsedKeySize(t){const[e,n]=Ic(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){if(!oe(t.size)){const[e,n]=Ic(t.size),r=Math.sqrt(e**2+n**2)/2;return[2*r,2*r,0]}const e=this.getContentBBox(t),[n,r]=Sc(e),i=Math.sqrt(n**2+r**2)/2;return[2*i,2*i,0]}getCollapsedOriginPosition(t){return Bc(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t),zc)}}class zl extends Il{static defaultStyleProps={anchor:[.5,.5]};constructor(t){super(re({},{style:zl.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Bs,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),n=Wc(e,"collapsed"),[r,i]=this.getKeySize(t);return{...e,...t.collapsed&&n,width:r,height:i}}}const Bl={N:"S",S:"N",W:"E",E:"W"},Fl={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Gl(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Vl(t,e){return"N"===e||"S"===e?Nc(t):Mc(t)}function Wl(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Gl(t,r),a=Gl(t,i),s=n?Bl[n]:null,u=o===n||o!==s&&a!==n?r:i;return{points:[u],direction:Gl(u,e)}}function Ul(t,e,n){const r=Yl(t,e,n);return{points:[r],direction:Gl(r,e)}}function Hl(t,e,n,r){const i=[[e[0],t[1]],[t[0],e[1]]],o=i.filter((t=>function(t,e){return!Pc(t,e)}(t,n))),a=o.filter((e=>Gl(e,t)!==r));if(a.length>0){const n=a.find((e=>Gl(t,e)===r))||a[0];return{points:[n],direction:Gl(n,e)}}{const a=ol(e,kt(i,o)[0],Vl(n,r)/2);return{points:[Yl(a,t,n),a],direction:Gl(a,e)}}}function ql(t,e,n,r){let i=Ul(t,e,n);const o=tl(i.points[0]);if(Pc(o,r)){i=Ul(e,t,r);const a=tl(i.points[0]);if(Pc(a,n)){const s=ol(t,a,Vl(n,Gl(t,a))/2),u=ol(e,o,Vl(r,Gl(e,o))/2),c=[(s[0]+u[0])/2,(s[1]+u[1])/2],l=Ul(t,c,n),h=Hl(c,e,r,l.direction);i.points=[l.points[0],h.points[0]],i.direction=h.direction}}return i}function $l(t,e,n,r,i){const o=.01,a=Tc([n,r]),s=Zc(e,a.center)>Zc(t,a.center),[u,c]=s?[e,t]:[t,e],l=Nc(a)+Mc(a);let h;if(i){const t=[u[0]+l*Math.cos(Fl[i]),u[1]+l*Math.sin(Fl[i])];h=ol(Oc(a,t),t,o)}else h=ol(Oc(a,u),u,-.01);let d=Yl(h,c,a),f=[il(h,2),il(d,2)];if(ae(il(h),il(d))){const t=function(t,e){return Math.acos(Kc(t,e).reduce(((t,e)=>t+e),0)/(Zc(t,qc)*Zc(e,qc)))}(Yc(h,u),[1,0,0])+Math.PI/2;d=[c[0]+l*Math.cos(t),c[1]+l*Math.sin(t),0],d=il(ol(Oc(a,d),c,-.01),2);f=[h,Yl(h,d,a),d]}return{points:s?f.reverse():f,direction:Gl(s?h:d,e)}}function Yl(t,e,n){let r=[t[0],e[1]];return Pc(r,n)&&(r=[e[0],t[1]]),r}function Kl(t,e,n,r,i){const[o,a]=nl(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 Xl(t,e,n,r){if(ae(t,e))return t;const i=Yc(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Jc(function(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Zl(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 Ql(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(!sl([s,c=t],[c,u])&&e){const[n,r]=function(t,e,n,r){const i=Qc(t,e),o=Qc(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 Jl=t=>{const e=Math.PI/2,n=Nc(t)/2,r=Mc(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 th(t,e,n,r,i){const o=Cc(t),a=t.getCenter();let s=r&&Eh(r),u=i&&Eh(i);if(!s||!u){const r=Jl(o),i=r[e][0],c=r[e][1],[l,h]=Sc(o),d=Math.max(l,h),f=$c(a,[d*Math.cos(i),d*Math.sin(i),0]),p=$c(a,[d*Math.cos(c),d*Math.sin(c),0]);s=Sh(t,f),u=Sh(t,p),n||([s,u]=[u,s])}return[s,u]}function eh(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[u,c]=th(t,e,n,a,s);const l=function(t,e,n,r){const i=t.getCenter();if(ae(e,n)){const t=Yc(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[$c(e,o),$c(n,Kc(o,[1,-1,1]))]}return[ol(i,e,Zc(i,e)+r),ol(i,n,Zc(i,n)+r)]}(t,u,c,r);return a&&(u=Nh(a,l[0])),s&&(c=Nh(s,l[l.length-1])),Zl(u,c,l)}function nh(t,e,n,r,i,o,a){const s=yh(t),u=s[o||a],c=s[a||o];let[l,h]=th(t,n,r,u,c);const d=function(t,e,n,r){const i=[],o=Cc(t);if(ae(e,n)){switch(Ac(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=Ac(o,e),a=Ac(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=Yl(u,c,o);i.push(u,l,c)}}return i}(t,l,h,i);return u&&(l=Nh(u,d[0])),c&&(h=Nh(c,d[d.length-1])),Ql([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)}}const ih=(t,e)=>[["M",0,0],["L",t,-e/2],["L",t,e/2],["Z"]];var oh=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:ih,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 ah extends El{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:ah.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)),...Hc(o,["halo","label","startArrow","endArrow"]),stroke:r||i}}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r}=t,i=Cc(e),o=Math.max(Mc(i),Nc(i)),{placement:a,clockwise:s,dist:u=o}=Wc(this.getGraphicStyle(t),"loop");return eh(e,a,s,u,n,r)}getEndpoints(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=wh(e,n,r,i);return[Mh(o||e,a||n),Mh(a||n,o||e)]}getHaloStyle(t){if(!1===t.halo)return!1;return{...this.getKeyStyle(t),...Wc(this.getGraphicStyle(t),"halo")}}getLabelStyle(t){if(!1===t.label||oe(t.labelText))return!1;const e=Wc(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=nl(t.getPoint(o)),s=nl(t.getPoint(o+.01));let u="start"===e?"left":"end"===e?"right":"center";if(al(a,s)||!n){const[e,n]=Kl(t,o,r,i);return{x:e,y: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]=Kl(t,o,r,i,c);return{x:l,y:h,textAlign:u,transform:`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 hl(Zc(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=oe(e.src)?Is:Ls,[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}=Wc(this.getGraphicStyle(t),r),[s,u]=Ic(i),c=(Tt(o)?o:oh[o]||ih)(s,u);return{...n,width:s,height:u,...c&&{path:c,fill:"simple"===o?"":n.stroke},...a}}drawLabelShape(t,e){this.upsert("label",wl,this.getLabelStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Is,this.getHaloStyle(t),e)}drawKeyShape(t,e){return this.upsert("key",Is,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 sh extends ah{static defaultStyleProps={curvePosition:.5,curveOffset:20};constructor(t){super(re({},{style:sh.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 Zl(e,n,a)}getControlPoints(t,e,n,r,i){return 2===i?.length?i:[Xl(t,e,n[0],r[0]),Xl(t,e,n[1],r[1])]}}class uh extends sh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(re({},{style:uh.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 ch extends sh{static defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};constructor(t){super(re({},{style:ch.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 lh extends ah{static defaultStyleProps={};constructor(t){super(re({},{style:lh.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}}class hh extends ah{static defaultStyleProps={radius:0,controlPoints:[],router:!1,routerName:"orth",routerPadding:10};constructor(t){super(re({},{style:hh.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=Mh(a||e,u[0]||s||n),l=Mh(s||n,u[u.length-1]||a||e);return Ql([c,...u,l],r)}getEndpointsAndPorts(t){const{sourceNode:e,targetNode:n,sourcePort:r,targetPort:i}=t,[o,a]=wh(e,n,r,i);return{sourcePoint:o?Eh(o):e.getCenter(),targetPoint:a?Eh(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=al(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=$l(h,d,n,r):f||(p=ql(h,d,n,r)):Pc(d,n)?p=$l(h,d,n,Cc(d,o),s):f||(p=Ul(h,d,n)):i===e-1?Pc(h,r)?p=$l(h,d,Cc(h,o),r,s):f||(p=Hl(h,d,r,s)):f||(p=Wl(h,d,s)),p?(u.push(...p.points),s=p.direction):s=Gl(h,d),i<e-1&&u.push(d)}var c,l;return u}(e,n,Cc(i,s),Cc(o,s),r,s)}getLoopPath(t){const{sourceNode:e,sourcePort:n,targetPort:r,radius:i}=t,o=Cc(e),a=Math.max(Mc(o),Nc(o))/4,{placement:s,clockwise:u,dist:c=a}=Wc(this.getGraphicStyle(t),"loop");return nh(e,i,s,u,c,n,r)}}class dh extends ah{static defaultStyleProps={curvePosition:.5,curveOffset:30};constructor(t){super(re({},{style:dh.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||Xl(r,i,e,n))}}function fh(t){return t instanceof Nl&&"node"===t.type}function ph(t){return t instanceof ah}function gh(t){return t instanceof Il}const mh={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function vh(t,e,n=mh,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]+Mc(t)*a,t.min[1]+Nc(t)*s]}function yh(t){const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{const{key:i,placement:o}=n;bh(n)&&(e[i||r]||=Lc(t.getKey().getBounds(),o))})),e}function bh(t){const{r:e}=t;return!e||0===Number(e)}function Eh(t){return Ec(t)?t:t.getPosition()}function wh(t,e,n,r){return[xh(t,e,n,r),xh(e,t,r,n)]}function xh(t,e,n,r){const i=yh(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Eh(t))),s=function(t,e){const n=yh(t);if(e)return[Eh(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Eh(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=Zc(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Eh(t)===u))}function Mh(t,e){return fh(t)?Sh(t,e):Nh(t,e)}function Nh(t,e){if(Ec(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return ll(Ec(e)?e:fh(e)?e.getCenter():e.getPosition(),t.getBounds())}function Sh(t,e){const n=Ec(e)?e:fh(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Ch(t,e="bottom",n=!1){const r=e.split("-"),[i,o]=Lc(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 kh(t,e){"update"in t?t.update(e):t.attr(e)}function Th(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 Ph(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=>Pt(t)))||r.every((t=>!fh(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 Ah(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;default:return}}function Oh(t,e){return e.before?.(),t?(e.beforeAnimate?.(t),t.finished.then((()=>{e.afterAnimate?.(t),e.after?.()}))):e.after?.(),t}function _h(t,e){const{animation:n}=t;if(!n||!1===e)return!1;const r={...ac};return Rt(n)&&Object.assign(r,n),Rt(e)&&Object.assign(r,e),r}const Rh=(t,e,n,r)=>{if(!e)return null;const{animationsFilter:i=(()=>!0)}=r,o=(Bt(e)?yI("animation",e)||[]:e).filter(i);if(0===o.length)return null;const{originalStyle:a,modifiedStyle:s,states:u}=r,c=e=>{if(e){const n=t.getElementById(e),r=`get${function(t){var e=$t(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=>u.includes(t)))){const{shape:r,fromStyle:o,toStyle:a}=c(e);if(!r)return null;const s=[{},{}];t.forEach((t=>{Object.assign(s[0],{[t]:o[t]??Ah(t)}),Object.assign(s[1],{[t]:a[t]??Ah(t)})}));const u=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=yl(t);return Th(t.animate(e,n),a.map((t=>t.animate(o,n))))}(r,Ph(s),{...sc,...n,...i});return void 0===e&&(l=u),u}return null})).filter(Boolean),d=l||h?.[0];return d?Th(d,h.filter((t=>t!==d))):null};function Lh(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)?ae(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 Dh{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}=Lh(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=yI(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 Ih{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 jh extends Ih{}class zh extends jh{static defaultOptions={enable:!0,animation:!0};constructor(t,e){super(t,Object.assign({},zh.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(!(fh(n=e)||ph(n)||gh(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.expand(r,c),u?.(r)):(await o.collapse(r,c),s?.(r))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Tt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}const Bh="g6-create-edge-assist-node-id";class Fh extends jh{static defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};source;constructor(t,e){super(t,Object.assign({},Fh.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:Bh,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}]}}]),e.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Bh,style:{pointerEvents:"none",...r}}])};updateAssistEdge=async t=>{if(!this.source)return;const{model:e,element:n}=this.context;e.translateNodeTo(Bh,[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}-${he[s=s||"g"]?he[s]+=1:he[s]=1,s+he[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([Bh]),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 Tt(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 Gh{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()}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=>{this.recordKey.add(t.key),this.trigger(t)};onKeyUp=t=>{this.recordKey.delete(t.key)};trigger(t){this.map.forEach(((e,n)=>{ae(Array.from(this.recordKey),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)}}class Vh extends jh{static defaultOptions={enable:!0,sensitivity:10};shortcut;defaultCursor;constructor(t,e){super(t,Object.assign({},Vh.defaultOptions,e)),this.shortcut=new Gh(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(Kc(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 Tt(e)?e(t):!!e}destroy(){this.shortcut.destroy(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}class Wh extends jh{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({},Wh.defaultOptions,e)),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)))}onDragStart=t=>{this.enable=this.validate(t),this.enable&&(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.context.graph.getZoom(),{dx:n,dy:r}=t,i=Xc([n,r],e);this.options.shadow?this.moveShadow(i):this.moveElement(this.target,i)};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]=Yc([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),this.options.onFinish?.(this.target),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,mc);n&&Fc(n)===r&&e.refreshComboData(r),e.setParent(t,r,mc)})),await(n?.draw({animation:!0}))};validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Tt(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=Wc(this.options,"shadow"),n=Tc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Sc(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr({...e,...s,visibility:"visible"}):(this.shadow=new Bs({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(Fc):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(Fc))).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 Uh=["node","combo"];class Hh extends jh{static defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};constructor(t,e){super(t,Object.assign({},Hh.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Uh.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 Tt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Uh.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.clickFocusElement)}))}destroy(){this.unbindEvents(),super.destroy()}}function qh(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)qh(t,e,n,r,i+1);"BT"===r&&e(t,i)}function $h(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=Fc(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 Yh extends jh{static defaultOptions={animation:!0,enable:!0,degree:0,activeState:"active",inactiveState:void 0};constructor(t,e){super(t,Object.assign({},Yh.defaultOptions,e)),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Cl.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=function(t,e,n,r){if("combo"===e||"node"===e)return $h(t,n,r);const i=t.getEdgeData(n);if(!i)return[];const o=$h(t,i.source,r-1),a=$h(t,i.target,r-1);return Array.from(new Set([...o,...a,n]))}(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=function(t){return Object.values(t).flatMap((t=>t.map(Fc)))}(n.getData()).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 Tt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Cl.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 Kh extends jh{static defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[]};shortcut;constructor(t,e){super(t,Object.assign({},Kh.defaultOptions,e)),this.shortcut=new Gh(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=nl(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+Vt(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 Tt(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 Xh=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Zh=function(t,e){return!!Xh(t)&&t.indexOf(e)>-1},Qh=function(t,e){if(!Xh(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n},Jh={}.toString,td=function(t,e){return Jh.call(t)==="[object "+e+"]"},ed=function(t){return td(t,"Function")},nd=function(t){return null==t},rd=function(t){return Array.isArray?Array.isArray(t):td(t,"Array")},id=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function od(t,e){if(t)if(rd(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(id(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var ad=Object.keys?function(t){return Object.keys(t)}:function(t){var e=[];return od(t,(function(n,r){ed(t)&&"prototype"===r||e.push(r)})),e};function sd(t,e){var n=ad(e),r=n.length;if(nd(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 ud=function(t){return"object"==typeof t&&null!==t},cd=function(t){if(!ud(t)||!td(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 ld=function(t,e){if(void 0===e&&(e=[]),rd(t))for(var n=0;n<t.length;n+=1)ld(t[n],e);else e.push(t);return e},hd=function(t){if(rd(t))return t.reduce((function(t,e){return Math.max(t,e)}),t[0])},dd=function(t){if(rd(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])},fd=Array.prototype,pd=fd.splice,gd=fd.indexOf,md=Array.prototype.splice,vd=function(t,e){if(!Xh(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,md.call(t,o,1))}return t},yd=function(t,e,n){if(!rd(t)&&!cd(t))return t;var r=n;return od(t,(function(t,n){r=e(r,t,n)})),r},bd=function(t){return td(t,"String")};function Ed(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 wd=Object.prototype.hasOwnProperty;function xd(t,e){if(!e||!rd(t))return{};for(var n,r={},i=ed(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),wd.call(r,n)?r[n].push(a):r[n]=[a]}return r}function Md(t,e){if(!e)return{0:t};if(!ed(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 xd(t,e)}var Nd={};var Sd=function(t){return td(t,"Number")},Cd=Number.isInteger?Number.isInteger:function(t){return Sd(t)&&t%1==0};var kd=180/Math.PI,Td=parseInt,Pd=Math.PI/180,Ad=function(t,e){return t.hasOwnProperty(e)},Od=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return od(t,(function(n,r){ed(t)&&"prototype"===r||e.push(n)})),e},_d=function(t){return nd(t)?"":t.toString()};var Rd={}.toString,Ld=function(t){return Rd.call(t).replace(/^\[object /,"").replace(/]$/,"")};var Dd=Object.prototype,Id=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Dd)};function jd(t,e){for(var n in e)e.hasOwnProperty(n)&&"constructor"!==n&&void 0!==e[n]&&(t[n]=e[n])}function zd(t,e,n,r){return e&&jd(t,e),n&&jd(t,n),r&&jd(t,r),t}var Bd=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]=Bd(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Bd(t[i]):e[i]=t[i];return e};var Fd=function(t,e){if(!ed(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 Gd(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&&cd(o)?(cd(t[i])||(t[i]={}),n<r?Gd(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 Vd=Object.prototype.hasOwnProperty;var Wd,Ud=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(bd(t)||bd(e))return!1;if(Xh(t)||Xh(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=Ud(t[r],e[r]));r++);return n}if(ud(t)||ud(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=Ud(t[i[r]],e[i[r]]));r++);return n}return!1},Hd=function(t){return t},qd=Object.prototype.hasOwnProperty,$d={};var Yd=Fd((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return Wd||(Wd=document.createElement("canvas").getContext("2d")),Wd.font=[o,a,i,n+"px",r].join(" "),Wd.measureText(bd(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],Od(e)).join("")})),Kd=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}(),Xd=Object.freeze({__proto__:null,Cache:Kd,assign:zd,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];ed(i)&&(i=i.prototype),zd(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:Bd,contains:Zh,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)Gd(t,e[r]);return t},difference:function(t,e){return void 0===e&&(e=[]),Qh(t,(function(t){return!Zh(e,t)}))},each:od,endsWith:function(t,e){return!(!rd(t)&&!bd(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){ed(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=zd(o,t.prototype),t.superclass=i(e.prototype,e),zd(o,n),zd(t,r),t},filter:Qh,find:function(t,e){if(!rd(t))return null;var n;if(ed(e)&&(n=e),cd(e)&&(n=function(t){return sd(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(!nd(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:ld,forIn:od,get:function(t,e,n){for(var r=0,i=bd(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=Yd(r,n),s=bd(t)?t:_d(t),u=e,c=[];if(Yd(t,n)<=e)return t;for(;i=s.substr(0,16),!((o=Yd(i,n))+a>u&&o>u);)if(c.push(i),u-=o,!(s=s.substr(16)))return c.join("");for(;i=s.substr(0,1),!((o=Yd(i,n))+a>u);)if(c.push(i),u-=o,!(s=s.substr(1)))return c.join("");return""+c.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=hd(e);return{min:dd(e),max:i}},getType:Ld,getWrapBehavior:function(t,e){return t["_wrap_"+e]},group:function(t,e){if(!e)return[t];var n=Md(t,e),r=[];for(var i in n)r.push(n[i]);return r},groupBy:xd,groupToMap:Md,has:Ad,hasKey:Ad,hasValue:function(t,e){return Zh(Od(t),e)},head:function(t){if(Xh(t))return t[0]},identity:function(t){return t},includes:Zh,indexOf:function(t,e){if(!Xh(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 td(t,"Arguments")},isArray:rd,isArrayLike:Xh,isBoolean:function(t){return td(t,"Boolean")},isDate:function(t){return td(t,"Date")},isDecimal:function(t){return Sd(t)&&t%1!=0},isElement:function(t){return t instanceof Element||t instanceof HTMLDocument},isEmpty:function(t){if(nd(t))return!0;if(Xh(t))return!t.length;var e=Ld(t);if("Map"===e||"Set"===e)return!t.size;if(Id(t))return!Object.keys(t).length;for(var n in t)if(Vd.call(t,n))return!1;return!0},isEqual:Ud,isEqualWith:function(t,e,n){return ed(n)?!!n(t,e):Ud(t,e)},isError:function(t){return td(t,"Error")},isEven:function(t){return Sd(t)&&t%2==0},isFinite:function(t){return Sd(t)&&isFinite(t)},isFunction:ed,isInteger:Cd,isMatch:sd,isNegative:function(t){return Sd(t)&&t<0},isNil:nd,isNull:function(t){return null===t},isNumber:Sd,isNumberEqual:function(t,e,n){return void 0===n&&(n=1e-5),Math.abs(t-e)<n},isObject:id,isObjectLike:ud,isOdd:function(t){return Sd(t)&&t%2!=0},isPlainObject:cd,isPositive:function(t){return Sd(t)&&t>0},isPrototype:Id,isRegExp:function(t){return td(t,"RegExp")},isString:bd,isType:td,isUndefined:function(t){return void 0===t},keys:ad,last:function(t){if(Xh(t)){return t[t.length-1]}},lowerCase:function(t){return _d(t).toLowerCase()},lowerFirst:function(t){var e=_d(t);return e.charAt(0).toLowerCase()+e.substring(1)},map:function(t,e){if(!Xh(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=Hd);var n={};return id(t)&&!nd(t)&&Object.keys(t).forEach((function(r){n[r]=e(t[r],r)})),n},max:hd,maxBy:function(t,e){if(rd(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=ed(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},measureTextWidth:Yd,memoize:Fd,min:dd,minBy:function(t,e){if(rd(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=ed(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},mix:zd,mod:function(t,e){return(t%e+e)%e},noop:function(){},number2color:function(t){var e=Nd[t];if(!e){for(var n=t.toString(16),r=n.length;r<6;r++)n="0"+n;e="#"+n,Nd[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||!cd(t))return{};var n={};return od(e,(function(e){qd.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=gd.call(t,i))>-1;)pd.call(t,o,1);return t},pullAt:vd,reduce:yd,remove:function(t,e){var n=[];if(!Xh(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 vd(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=bd(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(id(r[t])||(r[t]=Sd(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},size:function(t){return nd(t)?0:Xh(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(ed(e))n=function(t,n){return e(t)-e(n)};else{var r=[];bd(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)&&!bd(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 u=function(){s=!1===n.leading?0:Date.now(),r=null,a=t.apply(i,o),r||(i=o=null)},c=function(){var c=Date.now();s||!1!==n.leading||(s=c);var l=e-(c-s);return i=this,o=arguments,l<=0||l>e?(r&&(clearTimeout(r),r=null),s=c,a=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(u,l)),a};return c.cancel=function(){clearTimeout(r),s=0,r=i=o=null},c},toArray:function(t){return Xh(t)?Array.prototype.slice.call(t):[]},toDegree:function(t){return kd*t},toInteger:Td,toRadian:function(t){return Pd*t},toString:_d,union:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ed([].concat.apply([],t))},uniq:Ed,uniqueId:function(t){return $d[t=t||"g"]?$d[t]+=1:$d[t]=1,t+$d[t]},upperCase:function(t){return _d(t).toUpperCase()},upperFirst:function(t){var e=_d(t);return e.charAt(0).toUpperCase()+e.substring(1)},values:Od,valuesOfKey:function(t,e){for(var n=[],r={},i=0;i<t.length;i++){var o=t[i][e];if(!nd(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 Zd={assign:p(Xd).mix,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},Qd=Zd,Jd={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 tf(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof tf)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}Qd.assign(tf.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 ef=function(t,e,n){void 0===e&&(e={});var r,i=new tf(t,e=Qd.assign({},Jd,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 tf(a[u],e);r.children[u]=c,o.push(c),c.parent=r,c.depth=r.depth+1}}return i},nf=ef,rf=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=nf(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),of=rf;function af(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 sf(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){sf(t,e,n)}))}function uf(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(uf(t,e),n)})),n}function cf(t,e){sf(t,-uf(t,e),e)}function lf(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){lf(t,e.children[r],n)}))}function hf(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){hf(t,e,n)}))}af.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(af.fromNode(t,e))})),e?new af(t.height,t.width,t.x,n):new af(t.width,t.height,t.y,n)};var df=ef,ff=function(t,e){for(var n=df(t.data,e,!0),r=df(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}},pf=ff,gf=["LR","RL","TB","BT","H","V"],mf=["LR","RL","H"],vf=gf[0],yf=function(t,e,n){var r=e.direction||vf;if(e.isHorizontal=function(t){return mf.indexOf(t)>-1}(r),r&&-1===gf.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===gf[0])n(t,e);else if(r===gf[1])n(t,e),t.right2left();else if(r===gf[2])n(t,e);else if(r===gf[3])n(t,e),t.bottom2top();else if(r===gf[4]||r===gf[5]){var i=pf(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 bf(t,e){return bf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},bf(t,e)}var Ef=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}}hf(t,n);var l=af.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),lf(l,t,n),cf(t,n),t},wf=yf,xf=Zd,Mf=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,bf(e,n),r.prototype.execute=function(){return wf(this.rootNode,this.options,Ef)},r}(of),Nf={};var Sf=function(t,e){return e=xf.assign({},Nf,e),new Mf(t,e).execute()},Cf=Zd;function kf(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 Tf={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function Pf(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){Pf(t,e.children[r],n)}))}function Af(t,e){return Af=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Af(t,e)}var Of=function(t,e){void 0===e&&(e={}),e=Cf.assign({},Tf,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 kf(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),Pf(i,t,e.isHorizontal),t},_f=yf,Rf=Zd,Lf=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,Af(e,n),r.prototype.execute=function(){var t=this;return t.rootNode.width=0,_f(t.rootNode,t.options,Of)},r}(of),Df={};var If=function(t,e){return e=Rf.assign({},Df,e),new Lf(t,e).execute()},jf=Zd;function zf(t,e){return zf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},zf(t,e)}var Bf=of,Ff=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+jf.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+jf.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},Gf=ff,Vf=Zd,Wf=["LR","RL","H"],Uf=Wf[0],Hf=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,zf(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?Uf:a,u=t.align;if(s&&-1===Wf.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Wf[0])Ff(e,r,o,u);else if(s===Wf[1])Ff(e,r,o,u),e.right2left();else if(s===Wf[2]){var c=Gf(e,t),l=c.left,h=c.right;Ff(l,r,o,u),l.right2left(),Ff(h,r,o,u);var d=l.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},r}(Bf),qf={};var $f=function(t,e){return e=Vf.assign({},qf,e),new Hf(t,e).execute()},Yf=Zd;function Kf(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=Kf(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function Xf(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){Xf(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 Zf={getSubTreeSep:function(){return 0}};function Qf(t,e){return Qf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Qf(t,e)}var Jf=function(t,e){void 0===e&&(e={}),e=Yf.assign({},Zf,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,Kf(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}}}})),Xf(t)},tp=yf,ep=Zd,np=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,Qf(e,n),r.prototype.execute=function(){return tp(this.rootNode,this.options,Jf)},r}(of),rp={};var ip=function(t,e){return e=ep.assign({},rp,e),new np(t,e).execute()},op={compactBox:Sf,dendrogram:If,indented:$f,mindmap:ip},ap=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 sp(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 up(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)&&up(i,e,n,r))return!0;return!1}const cp=()=>!0;class lp{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||cp,n=t.edgeFilter||cp;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];sp([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];up(this.getNode(t),new Set,e,r)}}let hp=class t extends ap{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 up(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return sp([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 sp([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 up(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 lp({graph:this,...t})}};const dp=(t,e)=>{if("next"!==t&&"prev"!==t)return e},fp=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let pp=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 fp(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&fp(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,dp)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},gp=class extends pp{};const mp=()=>1,vp=(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,Ep(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,Ep(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},bp=(t,e)=>{const n=new hp;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 gp);const s=r+1;return n.getAllNodes().forEach((t=>{Ep(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},Ep=(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)},wp=(t,e)=>{const n="greedy"===e?((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=bp(t,e||mp);return null===(n=vp(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)):xp(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)})}))},xp=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},Mp=(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},Np=t=>{const e=new hp;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},Sp=(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}},Cp=t=>{const e=[],n=Tp(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},kp=(t,e,n,r)=>{const i={width:0,height:0};return Wt(n)&&Wt(r)&&(i.rank=n,i.order=r),Mp(t,"border",i,e)},Tp=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},Pp=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),Ap=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>Ap(t,e,n,r,i,o))),n&&o.push(e.id))},Op=(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}`);Ap(t,e,"post"===n,s,o,a)})),a},_p=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],u=Mp(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}})},Rp=t=>{t.getAllNodes().forEach((t=>{Lp(t)})),t.getAllEdges().forEach((t=>{Lp(t)}))},Lp=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Dp=t=>{t.getAllNodes().forEach((t=>{Ip(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Ip(t))),t.data.hasOwnProperty("y")&&Ip(t.data)}))},Ip=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},jp=t=>{t.getAllNodes().forEach((t=>{zp(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>zp(t))),t.data.hasOwnProperty("x")&&zp(t.data)}))},zp=t=>{const e=t.x;t.x=t.y,t.y=e},Bp=(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=kp(t,"_bt"),c=kp(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=>{Bp(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]}})},Fp=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},Gp=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Vp="edge-label",Wp=(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=Mp(t,"edge",c,"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=Vp,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}})},Up=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},Hp=(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 u=Array(s).fill(0,0,s);let c=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;u[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=u[e+1]),e=e-1>>1,u[e]+=t.weight;c+=t.weight*n}})),c},qp=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=Hp(t,e[r-1],e[r]);return n},$p=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},Yp=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)&&Kp(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}))},Kp=(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},Xp=(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},Zp=(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},Qp=(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=Qp(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&tg(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 Yp(a)})(g,n);Jp(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 u=0,c=0,l=0;null==o||o.sort(Zp(!!e,!!n)),l=Xp(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=Xp(s,a,l)}));const h={vs:s.flat()};return c&&(h.barycenter=u/c,h.weight=c),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===(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)||"");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},Jp=(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()}))},tg=(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)},eg=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Up(t),i=new hp({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))),ng=(t,e,n,r)=>{const i=new hp;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Qp(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}))}))},ig=(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}}))},og=(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)&&sg(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},ag=(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))},sg=(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},ug=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},cg=(t,e,n,r,i,o)=>{const a=new hp,s=lg(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 lg=(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},hg=(t,e)=>t.getNode(e).data.width||0,dg=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=Cp(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=ag(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)||sg(n,r.id,e)}))})),o=u+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),og(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]&&!ug(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=cg(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)=>Pp(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=hg(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)},fg=(t,e)=>{var n;const r=Np(t);((t,e)=>{const{ranksep:n=0}=e||{},r=Cp(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=dg(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},pg=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)))},gg=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,mg=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||gg(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},vg=(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&&gg(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)=>Pp(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?gg(e,n):1/0)),bg=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},Eg=t=>{const e=(t=>{const e=new hp;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);pg(e);const n=(t=>{const e=new hp({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);mg(e,t)<r;)i=yg(e,t),o=e.hasNode(i.source)?gg(t,i):-gg(t,i),bg(e,t,o);return e})(e);let r,i;for(Ng(n),wg(n,e);r=Cg(n);)i=kg(n,e,r),Tg(n,e,r,i)},wg=(t,e)=>{let n=Op(t,t.getAllNodes(),"post",!1);n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{xg(t,e,n)}))},xg=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=Mg(t,e,n)},Mg=(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,Ag(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},Ng=(t,e=t.getAllNodes()[0].id)=>{Sg(t,{},1,e)},Sg=(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=Sg(t,e,s,n.id,r))})),u.data.low=a,u.data.lim=s++,i?u.data.parent=i:delete u.data.parent,s},Cg=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),kg=(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===Og(t.getNode(e.source),s)&&u!==Og(t.getNode(e.target),s)));return Pp(c,(t=>gg(e,t)))},Tg=(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:{}}),Ng(t),wg(t,e),Pg(t,e)},Pg=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=Op(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))}))},Ag=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),Og=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,_g=pg,Rg=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 hp({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);vg(e,t)<r;)i=yg(e,t),o=e.hasNode(i.source)?gg(t,i):-gg(t,i),bg(e,t,o)})(t)},Lg=t=>{Eg(t)},Dg=(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;Jg(t),wp(t,n);const{nestingRoot:h,nodeRankFactor:d}=(t=>{const e=Mp(t,"root",{},"_root"),n=Fp(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=Gp(t)+1;return t.getRoots().forEach((r=>{Bp(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":Lg(t);break;case"tight-tree":default:Rg(t);break;case"longest-path":_g(t)}})(Np(t),r),Hg(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),qg(t),$g(t);const f=[];((t,e)=>{t.getAllEdges().forEach((n=>Wp(t,n,e)))})(t,f),ig(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)_p(t,"borderLeft","_bl",n,i,e),_p(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=Tp(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=eg(t,r,"in"),a=eg(t,i,"out");let s=$p(t);rg(t,s);let u,c=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){ng(n%2?o:a,n%4>=2,!1,e),s=Cp(t);const i=qp(t,s);i<c&&(r=0,u=Jt(s),c=i)}s=$p(t),rg(t,s);for(let n=0,r=0;r<4;++n,++r){ng(n%2?o:a,n%4>=2,!0,e),s=Cp(t);const i=qp(t,s);i<c&&(r=0,u=Jt(s),c=i)}rg(t,u)})(t,a),tm(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||Rp(t)})(t,i),fg(t,{align:s,nodesep:u,edgesep:c,ranksep:l}),em(t),Qg(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===Vp&&(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),Xg(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Dp(t),"lr"!==n&&"rl"!==n||(jp(t),Rp(t))})(t,i);const{width:p,height:g}=Yg(t);return Kg(t),Zg(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}},Ig=(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}))},jg=(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)}))},zg=["width","height","layer","fixorder"],Bg={width:0,height:0},Fg=["minlen","weight","width","height","labeloffset"],Gg={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Vg=["labelpos"],Wg=t=>{const e=new hp({tree:[]});return t.getAllNodes().forEach((n=>{const r=rm(t.getNode(n.id).data),i=Object.assign(Object.assign({},Bg),r),o=nm(i,zg);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);Pt(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==Vg||Vg.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Gg,nm(r,Fg),i)})})),e},Ug=(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},Hg=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};Mp(t,"edge-proxy",r,"_ep")}}))},qg=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},$g=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))}))},Yg=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}=e||{},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}},Kg=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(Sp(n.data,i)),e.data.points.push(Sp(r.data,o))}))},Xg=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}}))},Zg=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Qg=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)}))},Jg=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)}}))},tm=t=>{const e=Cp(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=>{Mp(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},em=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}}))},nm=(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},im=Array.isArray,om=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},am=(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},sm=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),um=(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),um(t,t.getChildren(c.id,i),n,r,i,o),"TB"!==r&&n(c)}}},cm=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=>cm(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=cm(t[n])})),e}return t},lm=(t,e)=>{const n=cm(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 hm(t,e){let n;return n=Tt(e)?e:Wt(e)?()=>e:()=>t,n}function dm(t,e,n=!0){return e||0===e?Tt(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 fm=(t,e)=>{let n,r;return r=Wt(e)?()=>e:Tt(e)?e:()=>0,n=t?Array.isArray(t)?e=>(t[0]>t[1]?t[0]:t[1])+r(e):Tt(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},pm={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};const gm=(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},mm=(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}}},vm={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=[lm(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(lm(n)),i[n.id]=!0,c=!0;break}}let l=0;for(;!c&&(i[e[l].id]||(r.push(lm(e[l])),i[e[l].id]=!0,c=!0),l++,l!==o););}else r.push(lm(s)),i[s.id]=!0,a++})),r};const bm=(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]},Em={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class wm{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Em),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(),v=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,E=i||[y/2,b/2];if(!(null==m?void 0:m.length)||1===m.length)return mm(e,t,E);const w=[];let x,M=0;im(p)?x=Math.max(p[0],p[1]):Tt(p)?(x=-1/0,m.forEach((t=>{const e=p(t);e>x&&(x=e)}))):x=p,im(g)?M=Math.max(g[0],g[1]):Wt(g)&&(M=g),m.forEach((t=>{const e=lm(t);w.push(e);let n=x;const{data:r}=e;im(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)),x=Math.max(x,n),Tt(g)&&(M=Math.max(g(t),M))}));const N={};w.forEach(((t,e)=>{N[t.id]=e}));let S=s;Bt(S)&&void 0!==w[0].data[S]||(S="degree"),"degree"===S?w.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):w.sort(((t,e)=>e.data[S]-t.data[S]));const C=w[0],k=(u||("degree"===S?e.getDegree(C.id,"both"):C.data[S]))/4,T=[{nodes:[]}];let P=T[0];w.forEach((t=>{if(P.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(P.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(P.nodes[0].data[S]-t.data[S]);k&&n>=k&&(P={nodes:[]},T.push(P))}P.nodes.push(t)}));let A=x+M;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(T.length+(t?1:0));A=Math.min(A,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(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<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=E[0]+n*Math.cos(i),t.data.y=E[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:v}}))}}function xm(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,v=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((c=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|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+v)/2))?g=o:v=o,(l=n>=(a=(m+y)/2))?m=a:y=a}while((h=l<<1|c)==(d=(u>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Mm(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Nm(t){return t[0]}function Sm(t){return t[1]}function Cm(t,e,n){var r=new km(null==e?Nm:e,null==n?Sm:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function km(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 Tm(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Pm=Cm.prototype=km.prototype;function Am(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,v=t._root,y={data:i},b=t._x0,E=t._y0,w=t._z0,x=t._x1,M=t._y1,N=t._z1;if(!v)return t._root=y,t;for(;v.length;)if((d=e>=(a=(b+x)/2))?b=a:x=a,(f=n>=(s=(E+M)/2))?E=s:M=s,(p=r>=(u=(w+N)/2))?w=u:N=u,o=v,!(v=v[g=p<<2|f<<1|d]))return o[g]=y,t;if(c=+t._x.call(null,v.data),l=+t._y.call(null,v.data),h=+t._z.call(null,v.data),e===c&&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+x)/2))?b=a:x=a,(f=n>=(s=(E+M)/2))?E=s:M=s,(p=r>=(u=(w+N)/2))?w=u:N=u}while((g=p<<2|f<<1|d)==(m=(h>=u)<<2|(l>=s)<<1|c>=a));return o[m]=v,o[g]=y,t}function Om(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 _m(t){return t[0]}function Rm(t){return t[1]}function Lm(t){return t[2]}function Dm(t,e,n,r){var i=new Im(null==e?_m:e,null==n?Rm:n,null==r?Lm:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Im(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 jm(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}Pm.copy=function(){var t,e,n=new km(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=Tm(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]=Tm(e));return n},Pm.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return xm(this.cover(e,n),e,n,t)},Pm.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)xm(this,a[n],s[n],t[n]);return this},Pm.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},Pm.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Pm.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]]},Pm.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 Mm(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,v=(o+s)/2;p.push(new Mm(g[3],m,v,a,s),new Mm(g[2],i,v,m,s),new Mm(g[1],m,o,a,v),new Mm(g[0],i,o,m,v)),(c=(e>=v)<<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 y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),E=y*y+b*b;if(E<n){var w=Math.sqrt(n=E);l=t-w,h=e-w,d=t+w,f=e+w,r=g.data}}return r},Pm.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,v=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+v)/2))?g=u:v=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)},Pm.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Pm.root=function(){return this._root},Pm.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Pm.visit=function(t){var e,n,r,i,o,a,s=[],u=this._root;for(u&&s.push(new Mm(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 Mm(n,c,l,o,a)),(n=u[2])&&s.push(new Mm(n,r,l,c,a)),(n=u[1])&&s.push(new Mm(n,c,i,o,l)),(n=u[0])&&s.push(new Mm(n,r,i,c,l))}return this},Pm.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Mm(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 Mm(o,a,s,l,h)),(o=i[1])&&n.push(new Mm(o,l,s,u,h)),(o=i[2])&&n.push(new Mm(o,a,h,l,c)),(o=i[3])&&n.push(new Mm(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},Pm.x=function(t){return arguments.length?(this._x=t,this):this._x},Pm.y=function(t){return arguments.length?(this._y=t,this):this._y};var zm=Dm.prototype=Im.prototype;zm.copy=function(){var t,e,n=new Im(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=jm(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]=jm(e));return n},zm.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Am(this.cover(e,n,r),e,n,r,t)},zm.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)Am(this,n[o],r[o],i[o],t[o]);return this},zm.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},zm.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},zm.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]]},zm.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,v=this._y1,y=this._z1,b=[],E=this._root;for(E&&b.push(new Om(E,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(!(!(E=h.node)||(o=h.x0)>m||(a=h.y0)>v||(s=h.z0)>y||(u=h.x1)<f||(c=h.y1)<p||(l=h.z1)<g))if(E.length){var w=(o+u)/2,x=(a+c)/2,M=(s+l)/2;b.push(new Om(E[7],w,x,M,u,c,l),new Om(E[6],o,x,M,w,c,l),new Om(E[5],w,a,M,u,x,l),new Om(E[4],o,a,M,w,x,l),new Om(E[3],w,x,s,u,c,M),new Om(E[2],o,x,s,w,c,M),new Om(E[1],w,a,s,u,x,M),new Om(E[0],o,a,s,w,x,M)),(d=(n>=M)<<2|(e>=x)<<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 N=t-+this._x.call(null,E.data),S=e-+this._y.call(null,E.data),C=n-+this._z.call(null,E.data),k=N*N+S*S+C*C;if(k<r){var T=Math.sqrt(r=k);f=t-T,p=e-T,g=n-T,m=t+T,v=e+T,y=n+T,i=E.data}}return i},zm.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,v=this._x0,y=this._y0,b=this._z0,E=this._x1,w=this._y1,x=this._z1;if(!m)return this;if(m.length)for(;;){if((h=o>=(u=(v+E)/2))?v=u:E=u,(d=a>=(c=(y+w)/2))?y=c:w=c,(f=s>=(l=(b+x)/2))?b=l:x=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)},zm.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},zm.root=function(){return this._root},zm.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},zm.visit=function(t){var e,n,r,i,o,a,s,u,c=[],l=this._root;for(l&&c.push(new Om(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 Om(n,h,d,f,a,s,u)),(n=l[6])&&c.push(new Om(n,r,d,f,h,s,u)),(n=l[5])&&c.push(new Om(n,h,i,f,a,d,u)),(n=l[4])&&c.push(new Om(n,r,i,f,h,d,u)),(n=l[3])&&c.push(new Om(n,h,d,o,a,s,f)),(n=l[2])&&c.push(new Om(n,r,d,o,h,s,f)),(n=l[1])&&c.push(new Om(n,h,i,o,a,d,f)),(n=l[0])&&c.push(new Om(n,r,i,o,h,d,f))}return this},zm.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Om(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 Om(o,a,s,u,d,f,p)),(o=i[1])&&n.push(new Om(o,d,s,u,c,f,p)),(o=i[2])&&n.push(new Om(o,a,f,u,d,l,p)),(o=i[3])&&n.push(new Om(o,d,f,u,c,l,p)),(o=i[4])&&n.push(new Om(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new Om(o,d,s,p,c,f,h)),(o=i[6])&&n.push(new Om(o,a,f,p,d,l,h)),(o=i[7])&&n.push(new Om(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},zm.x=function(t){return arguments.length?(this._x=t,this):this._x},zm.y=function(t){return arguments.length?(this._y=t,this):this._y},zm.z=function(t){return arguments.length?(this._z=t,this):this._z};function Bm(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?Cm(s,(t=>t.x),(t=>t.y)):Dm(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Fm),c=new Map;return s.forEach((t=>{c.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>Gm(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 Fm(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 Gm=(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 Vm={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 Wm{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Vm),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:Wt(t.data.x)?t.data.x:Math.random()*u,y:Wt(t.data.y)?t.data.y:Math.random()*c,z:Wt(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 v={};i.forEach(((t,e)=>{v[t.id]={x:0,y:0,z:0}}));const y=new hp({nodes:g,edges:m});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:E,onTick:w}=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 x=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Ym(e,g),edges:o}),this.runOneStep(y,e,x,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==w||w({nodes:Ym(e,g),edges:o}),x++,(x>=b||this.judgingDistance<E)&&(window.clearInterval(this.timeInterval),n({nodes:Ym(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=hm(0,t.nodeSpacing);let u;u=a?Tt(a)?t=>a(t)+s(t):im(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?im(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=u;const c=t.linkDistance?hm(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=c,n.nodeStrength=hm(1,t.nodeStrength),n.edgeStrength=hm(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=Um(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=$m(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=Um(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]=$m(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;Bm(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:v=200,edgeStrength:y=200}=n.data||{},b=(v-f)*y,E=1/(u.data.mass||1),w=1/(c.data.mass||1),x=p*b,M=g*b,N=m*b;e[a].x-=x*E,e[a].y-=M*E,e[a].z-=N*E,e[s].x+=x*w,e[s].y+=M*w,e[s].z+=N*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:v}=f,y=e.getNode(o);let b=0,E=0,w=0,x=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,E=m-e,x=n}else b=g-l[0],E=m-l[1],w=v-l[2];if(x&&(n[o].x-=x*b/p,n[o].y-=x*E/p,n[o].z-=x*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(y,a,s,u,c))||{x:0,y:0,z:0,centerStrength:0};if(!Wt(l)||!Wt(h))return;const E=(g-l)/p,w=(m-h)/p,x=(v-f)/p;if(b&&(n[o].x-=b*E,n[o].y-=b*w,n[o].z-=b*x),0===S){const t=e(y);if(!t)return;return n[o].x-=t*E,n[o].y-=t*w,void(n[o].z-=t*x)}if(0===M||0===N){const e=t(y,a,s);if(!e)return;return n[o].x-=e*E,n[o].y-=e*w,void(n[o].z-=e*x)}const C=r(y);if(!C)return;n[o].x-=C*E,n[o].y-=C*w,n[o].z-=C*x}}))}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(Wt(c.data.fx)&&Wt(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 Um=(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]=Hm(t,"leaf",n,e))})),r},Hm=(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:qm(t,e,r,n,s)}},qm=(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},$m=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}},Ym=(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 Km={};const Xm=Object.prototype.toString;function Zm(t){const e=Xm.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var Qm=p(Object.freeze({__proto__:null,isAnyArray:Zm}));var Jm=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Zm(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(!Zm(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(!Zm(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(!Zm(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}}),tv=p(Jm);Object.defineProperty(Km,"__esModule",{value:!0});var ev=Qm,nv=tv;const rv=" ".repeat(2),iv=" ".repeat(4);function ov(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${rv}[\n${iv}${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(av(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${iv}`)}(t,n,r,i,o)}\n${rv}]\n${rv}rows: ${t.rows}\n${rv}columns: ${t.columns}\n}`}function av(t,e,n){return(t>=0&&n?` ${sv(t,e-1)}`:sv(t,e)).padEnd(e)}function sv(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 uv(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 cv(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 lv(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 hv(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 dv(t,e){if(!ev.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 fv(t,e){if(!ev.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 pv(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(mv("startRow",e),mv("endRow",n),mv("startColumn",r),mv("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 gv(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function mv(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function vv(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 Ev(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 Ev(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 Ev(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 Ev(t,e)}static ones(t,e){return new Ev(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 Ev(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 Ev(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 Ev(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 Ev(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 Ev(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){uv(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Ev.rowVector(this.getRow(t))}setRow(t,e){uv(this,t),e=lv(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){uv(this,t),uv(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){cv(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Ev.columnVector(this.getColumn(t))}setColumn(t,e){cv(this,t),e=hv(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){cv(this,t),cv(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=lv(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=lv(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=lv(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=lv(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=hv(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=hv(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=hv(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=hv(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){uv(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){cv(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(){vv(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(){vv(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(uv(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){uv(this,t),vv(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(uv(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){uv(this,t),vv(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(cv(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){cv(this,t),vv(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(cv(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){cv(this,t),vv(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=Ev.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Ev(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=Ev.checkMatrix(t);let e=new Ev(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,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=Ev.checkMatrix(t);let e=new Ev(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),v=t.get(2,0),y=t.get(2,1),b=t.get(2,2),E=(n-o)*(-d+g),w=(-n+o+a)*(h-d+g),x=(o+a)*(-h+d),M=n*h,N=(-n+u+c)*(h-f+m),S=(-n+u)*(f-m),C=(u+c)*(-h+f),k=(-i+c+l)*(g+v-y),T=(i-l)*(g-y),P=i*v,A=(c+l)*(-v+y),O=(-i+a+s)*(m+v-b),_=(i-s)*(m-b),R=(a+s)*(-v+b),L=M+P+r*p,D=(n+r+i-o-a-c-l)*g+w+x+M+k+P+A,I=M+N+C+(n+r+i-a-s-u-c)*m+P+O+R,j=E+a*(-h+d+p-g-m-v+b)+w+M+P+O+_,z=E+w+x+M+s*y,B=P+O+_+R+o*f,F=M+N+S+c*(-h+f+p-g-m-v+y)+k+T+P,G=k+T+P+A+u*d,V=M+N+S+C+l*b;return e.set(0,0,L),e.set(0,1,D),e.set(0,2,I),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=Ev.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),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(yv.add(u,p),yv.add(c,g),o,s),v=t(yv.add(d,p),c,o,s),y=t(u,yv.sub(h,g),o,s),b=t(p,yv.sub(f,c),o,s),E=t(yv.add(u,l),g,o,s),w=t(yv.sub(d,u),yv.add(c,h),o,s),x=t(yv.sub(l,p),yv.add(f,g),o,s),M=yv.add(m,b);M.sub(E),M.add(x);let N=yv.add(y,E),S=yv.add(v,b),C=yv.sub(m,v);C.add(y),C.add(w);let k=yv.zeros(2*M.rows,2*M.columns);return k=k.setSubMatrix(M,0,0),k=k.setSubMatrix(N,M.rows,0),k=k.setSubMatrix(S,0,M.columns),k=k.setSubMatrix(C,M.rows,M.columns),k.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 Ev(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&nv(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 Ev(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&nv(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=Ev.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Ev(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=Ev.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(Ev.eye(n,n)),i=Ev.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Ev(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=bv){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=bv){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){pv(this,t,e,n,r);let i=new Ev(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 Ev(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 Ev(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=Ev.checkMatrix(t)).isEmpty())return this;pv(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){dv(this,t),fv(this,e);let n=new Ev(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 Ev(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=gv(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=gv(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=gv(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=gv(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(!ev.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(!ev.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(!ev.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(!ev.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(!ev.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(!ev.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 ov(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 bv(t,e){return t-e}yv.prototype.klass="Matrix","undefined"!=typeof Symbol&&(yv.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return ov(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 Ev=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(!ev.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 uv(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),uv(this,t,!0),e=Float64Array.from(lv(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){cv(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),cv(this,t,!0),e=hv(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,Ev);class wv 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 Ev.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(),Ev.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=Ev.copy(t,new Ev(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new Ev(t,t);else if(this.#e=new Ev(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new wv(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new Ev(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 wv(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)}}}wv.prototype.klassType="SymmetricMatrix";class xv extends wv{static isDistanceMatrix(t){return wv.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 wv(this)}clone(){const t=new xv(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}}xv.prototype.klassSubType="DistanceMatrix";class Mv extends yv{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class Nv extends Mv{constructor(t,e,n){dv(t,e),fv(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 Sv 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 Cv 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 kv{constructor(t){let e,n,r,i,o,a,s,u,c,l=(t=Cv.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=Ev.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 Ev(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 Ev(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 Tv(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 Pv{constructor(t){let e,n,r,i,o=(t=Cv.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=Tv(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=Ev.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 Ev(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 Ev(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 Av=class{constructor(t,e={}){if((t=Cv.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 Ev(n,h),g=new Ev(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),E=Math.max(0,Math.min(r-2,n)),w=Math.max(b,E);for(let t=0;t<w;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=Tv(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<E){m[t]=0;for(let e=t+1;e<r;e++)m[t]=Tv(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(c)for(let e=t+1;e<r;e++)g.set(e,t,m[e])}}let x=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<x&&(f[x-1]=0),E+1<x&&(m[E]=s.get(E,x-1)),m[x-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<E&&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=x-1,N=Number.EPSILON;for(;x>0;){let t,e;for(t=x-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===x-2)e=4;else{let n;for(n=x-1;n>=t&&n!==t;n--){let e=(n!==x?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===x-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[x-2];m[x-2]=0;for(let n=x-2;n>=t;n--){let i=Tv(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,x-1),g.set(t,x-1,-a*g.get(t,n)+o*g.get(t,x-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<x;r++){let i=Tv(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[x-1]),Math.abs(f[x-2]),Math.abs(m[x-2]),Math.abs(f[t]),Math.abs(m[t])),i=f[x-1]/e,o=f[x-2]/e,a=m[x-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<x-1;e++){let i=Tv(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],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=Tv(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],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[x-2]=y;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++}x--}}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=Ev.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=Ev.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(Ev.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Ev(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 Ev(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 Ev.diag(this.s)}};function Ov(t,e,n=!1){return t=Cv.checkMatrix(t),e=Cv.checkMatrix(e),n?new Av(t).solve(e):t.isSquare()?new kv(t).solve(e):new Pv(t).solve(e)}function _v(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Rv(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 Lv{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=Cv.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 Ev(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,v,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let E=0,w=0,x=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])<=x*w);)l++;if(l>c)do{for(i=n[c],h=(n[c+1]-i)/(2*e[c]),d=Tv(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(E+=o,h=n[l],p=1,g=p,m=p,v=e[c+1],y=0,b=0,a=l-1;a>=c;a--)for(m=g,g=p,b=y,i=p*e[a],o=p*h,d=Tv(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]),u=0;u<t;u++)o=r.get(u,a+1),r.set(u,a+1,y*r.get(u,a)+p*o),r.set(u,a,p*r.get(u,a)-y*o);h=-y*b*m*v*e[c]/f,e[c]=y*h,n[c]=p*h}while(Math.abs(e[c])>x*w);n[c]=n[c]+E,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 Ev(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,v,y,b,E=t-1,w=0,x=t-1,M=Number.EPSILON,N=0,S=0,C=0,k=0,T=0,P=0,A=0,O=0;for(o=0;o<t;o++)for((o<w||o>x)&&(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(;E>=w;){for(u=E;u>w&&(P=Math.abs(i.get(u-1,u-1))+Math.abs(i.get(u,u)),0===P&&(P=S),!(Math.abs(i.get(u,u-1))<M*P));)u--;if(u===E)i.set(E,E,i.get(E,E)+N),n[E]=i.get(E,E),e[E]=0,E--,O=0;else if(u===E-1){if(h=i.get(E,E-1)*i.get(E-1,E),C=(i.get(E-1,E-1)-i.get(E,E))/2,k=C*C+h,A=Math.sqrt(Math.abs(k)),i.set(E,E,i.get(E,E)+N),i.set(E-1,E-1,i.get(E-1,E-1)+N),d=i.get(E,E),k>=0){for(A=C>=0?C+A:C-A,n[E-1]=d+A,n[E]=n[E-1],0!==A&&(n[E]=d-h/A),e[E-1]=0,e[E]=0,d=i.get(E,E-1),P=Math.abs(d)+Math.abs(A),C=d/P,k=A/P,T=Math.sqrt(C*C+k*k),C/=T,k/=T,a=E-1;a<t;a++)A=i.get(E-1,a),i.set(E-1,a,k*A+C*i.get(E,a)),i.set(E,a,k*i.get(E,a)-C*A);for(o=0;o<=E;o++)A=i.get(o,E-1),i.set(o,E-1,k*A+C*i.get(o,E)),i.set(o,E,k*i.get(o,E)-C*A);for(o=w;o<=x;o++)A=r.get(o,E-1),r.set(o,E-1,k*A+C*r.get(o,E)),r.set(o,E,k*r.get(o,E)-C*A)}else n[E-1]=d+C,n[E]=d+C,e[E-1]=A,e[E]=-A;E-=2,O=0}else{if(d=i.get(E,E),f=0,h=0,u<E&&(f=i.get(E-1,E-1),h=i.get(E,E-1)*i.get(E-1,E)),10===O){for(N+=d,o=w;o<=E;o++)i.set(o,o,i.get(o,o)-d);P=Math.abs(i.get(E,E-1))+Math.abs(i.get(E-1,E-2)),d=f=.75*P,h=-.4375*P*P}if(30===O&&(P=(f-d)/2,P=P*P+h,P>0)){for(P=Math.sqrt(P),f<d&&(P=-P),P=d-h/((f-d)/2+P),o=w;o<=E;o++)i.set(o,o,i.get(o,o)-P);N+=P,d=f=h=.964}for(O+=1,c=E-2;c>=u&&(A=i.get(c,c),T=d-A,P=f-A,C=(T*P-h)/i.get(c+1,c)+i.get(c,c+1),k=i.get(c+1,c+1)-A-T-P,T=i.get(c+2,c+1),P=Math.abs(C)+Math.abs(k)+Math.abs(T),C/=P,k/=P,T/=P,c!==u)&&!(Math.abs(i.get(c,c-1))*(Math.abs(k)+Math.abs(T))<M*(Math.abs(C)*(Math.abs(i.get(c-1,c-1))+Math.abs(A)+Math.abs(i.get(c+1,c+1)))));)c--;for(o=c+2;o<=E;o++)i.set(o,o-2,0),o>c+2&&i.set(o,o-3,0);for(s=c;s<=E-1&&(y=s!==E-1,s!==c&&(C=i.get(s,s-1),k=i.get(s+1,s-1),T=y?i.get(s+2,s-1):0,d=Math.abs(C)+Math.abs(k)+Math.abs(T),0!==d&&(C/=d,k/=d,T/=d)),0!==d);s++)if(P=Math.sqrt(C*C+k*k+T*T),C<0&&(P=-P),0!==P){for(s!==c?i.set(s,s-1,-P*d):u!==c&&i.set(s,s-1,-i.get(s,s-1)),C+=P,d=C/P,f=k/P,A=T/P,k/=C,T/=C,a=s;a<t;a++)C=i.get(s,a)+k*i.get(s+1,a),y&&(C+=T*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(E,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*T)),i.set(o,s,i.get(o,s)-C),i.set(o,s+1,i.get(o,s+1)-C*k);for(o=w;o<=x;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*T)),r.set(o,s,r.get(o,s)-C),r.set(o,s+1,r.get(o,s+1)-C*k)}}}if(0===S)return;for(E=t-1;E>=0;E--)if(C=n[E],k=e[E],0===k)for(u=E,i.set(E,E,1),o=E-1;o>=0;o--){for(h=i.get(o,o)-C,T=0,a=u;a<=E;a++)T+=i.get(o,a)*i.get(a,E);if(e[o]<0)A=h,P=T;else if(u=o,0===e[o]?i.set(o,E,0!==h?-T/h:-T/(M*S)):(d=i.get(o,o+1),f=i.get(o+1,o),k=(n[o]-C)*(n[o]-C)+e[o]*e[o],l=(d*P-A*T)/k,i.set(o,E,l),i.set(o+1,E,Math.abs(d)>Math.abs(A)?(-T-h*l)/d:(-P-f*l)/A)),l=Math.abs(i.get(o,E)),M*l*l>1)for(a=o;a<=E;a++)i.set(a,E,i.get(a,E)/l)}else if(k<0)for(u=E-1,Math.abs(i.get(E,E-1))>Math.abs(i.get(E-1,E))?(i.set(E-1,E-1,k/i.get(E,E-1)),i.set(E-1,E,-(i.get(E,E)-C)/i.get(E,E-1))):(b=Dv(0,-i.get(E-1,E),i.get(E-1,E-1)-C,k),i.set(E-1,E-1,b[0]),i.set(E-1,E,b[1])),i.set(E,E-1,0),i.set(E,E,1),o=E-2;o>=0;o--){for(p=0,g=0,a=u;a<=E;a++)p+=i.get(o,a)*i.get(a,E-1),g+=i.get(o,a)*i.get(a,E);if(h=i.get(o,o)-C,e[o]<0)A=h,T=p,P=g;else if(u=o,0===e[o]?(b=Dv(-p,-g,h,k),i.set(o,E-1,b[0]),i.set(o,E,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]-k*k,v=2*(n[o]-C)*k,0===m&&0===v&&(m=M*S*(Math.abs(h)+Math.abs(k)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=Dv(d*T-A*p+k*g,d*P-A*g-k*p,m,v),i.set(o,E-1,b[0]),i.set(o,E,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(k)?(i.set(o+1,E-1,(-p-h*i.get(o,E-1)+k*i.get(o,E))/d),i.set(o+1,E,(-g-h*i.get(o,E)-k*i.get(o,E-1))/d)):(b=Dv(-T-f*i.get(o,E-1),-P-f*i.get(o,E),A,k),i.set(o+1,E-1,b[0]),i.set(o+1,E,b[1]))),l=Math.max(Math.abs(i.get(o,E-1)),Math.abs(i.get(o,E))),M*l*l>1)for(a=o;a<=E;a++)i.set(a,E-1,i.get(a,E-1)/l),i.set(a,E,i.get(a,E)/l)}for(o=0;o<t;o++)if(o<w||o>x)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<=x;o++){for(A=0,s=w;s<=Math.min(a,x);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(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 Ev(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 Dv(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 Iv{constructor(t){if(!(t=Cv.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new Ev(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=Cv.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 jv{constructor(t,e={}){t=Cv.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=ev.isAnyArray(n)&&"number"==typeof n[0]?Ev.columnVector(n):Cv.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()))}}Km.AbstractMatrix=yv,Km.CHO=Iv,Km.CholeskyDecomposition=Iv,Km.DistanceMatrix=xv,Km.EVD=Lv,Km.EigenvalueDecomposition=Lv,Km.LU=kv,Km.LuDecomposition=kv;var zv=Km.Matrix=Ev;Km.MatrixColumnSelectionView=class extends Mv{constructor(t,e){fv(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])}},Km.MatrixColumnView=class extends Mv{constructor(t,e){cv(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)}},Km.MatrixFlipColumnView=class extends Mv{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)}},Km.MatrixFlipRowView=class extends Mv{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)}},Km.MatrixRowSelectionView=class extends Mv{constructor(t,e){dv(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)}},Km.MatrixRowView=class extends Mv{constructor(t,e){uv(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)}},Km.MatrixSelectionView=Nv,Km.MatrixSubView=class extends Mv{constructor(t,e,n,r,i){pv(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)}},Km.MatrixTransposeView=class extends Mv{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)}},Km.NIPALS=jv,Km.Nipals=jv,Km.QR=Pv,Km.QrDecomposition=Pv,Km.SVD=Av;var Bv=Km.SingularValueDecomposition=Av;Km.SymmetricMatrix=wv,Km.WrapperMatrix1D=Sv,Km.WrapperMatrix2D=Cv,Km.correlation=function(t,e=t,n={}){t=new Ev(t);let r=!1;if("object"!=typeof e||Ev.isMatrix(e)||ev.isAnyArray(e)?e=new Ev(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},Km.covariance=function(t,e=t,n={}){t=new Ev(t);let r=!1;if("object"!=typeof e||Ev.isMatrix(e)||ev.isAnyArray(e)?e=new Ev(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 Fv=Km.default=Ev;Km.determinant=function t(e){if((e=Ev.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 Nv(e,[1,2],[1,2]),a=new Nv(e,[1,2],[0,2]),s=new Nv(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 kv(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Km.inverse=function(t,e=!1){return t=Cv.checkMatrix(t),e?new Av(t).inverse():Ov(t,Ev.eye(t.rows))},Km.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=Ev.checkMatrix(t)).rows,o=new Ev(i,i);for(let e=0;e<i;e++){let a=Ev.columnVector(t.getRow(e)),s=t.subMatrixRow(_v(i,e)).transpose(),u=new Av(s).solve(a),c=Ev.sub(a,s.mmul(u)).abs().max();o.setRow(e,Rv(c,u,e,n,r))}return o},Km.pseudoInverse=function(t,e=Number.EPSILON){if((t=Ev.checkMatrix(t)).isEmpty())return t.transpose();let n=new Av(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(Ev.diag(o).mmul(r.transpose()))},Km.solve=Ov,Km.wrap=function(t,e){if(ev.isAnyArray(t))return t[0]&&ev.isAnyArray(t[0])?new Cv(t):new Sv(t,e);throw new Error("the argument is not an array")};const Gv=zv,Vv=Bv;Fv.Matrix&&Fv.Matrix;const Wv={center:[0,0],linkDistance:50};class Uv{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},Wv),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 mm(e,t,i);const u=am({nodes:a,edges:s},!1),c=om(u);Hv(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=qv(l),d=[];h.forEach(((t,e)=>{const n=lm(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 Hv=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)}))}))},qv=t=>{const e=Gv.mul(Gv.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 Vv(e),a=Gv.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>Gv.mul([t],[a]).toJSON()[0].splice(0,2)))},$v={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Yv={center:[0,0],comboPadding:10,treeKey:"combo"};function Kv(t){return function(){return t}}function Xv(t){return 1e-6*(t()-.5)}function Zv(t){return t.x+t.vx}function Qv(t){return t.y+t.vy}function Jv(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=Cm(e,Zv,Qv).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,v=g*g+m*m;v<p*p&&(0===g&&(v+=(g=Xv(r))*g),0===m&&(v+=(m=Xv(r))*m),v=(p-(v=Math.sqrt(v)))/v*i,u.vx+=(g*=v)*(p=(f*=f)/(d+f)),u.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 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=Kv(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:Kv(+e),u(),a):t},a}function ty(t){return t.index}function ey(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function ny(t){var e,n,r,i,o,a,s=ty,u=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=Kv(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||Xv(a),f=h.y+h.vy-c.y-c.vy||Xv(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=ey(h,u.source)),"object"!=typeof u.target&&(u.target=ey(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:Kv(+t),f(),h):u},h.distance=function(t){return arguments.length?(c="function"==typeof t?t:Kv(+t),p(),h):c},h}var ry={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 oy(r)}function oy(t){this._=t}function ay(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function sy(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=ry,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}oy.prototype=iy.prototype={constructor:oy,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]=sy(i[n],t.name,e);else if(null==e)for(n in i)i[n]=sy(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=ay(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new oy(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 uy,cy,ly=0,hy=0,dy=0,fy=1e3,py=0,gy=0,my=0,vy="object"==typeof performance&&performance.now?performance:Date,yy="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function by(){return gy||(yy(Ey),gy=vy.now()+my)}function Ey(){gy=0}function wy(){this._call=this._time=this._next=null}function xy(t,e,n){var r=new wy;return r.restart(t,e,n),r}function My(){gy=(py=vy.now())+my,ly=hy=0;try{!function(){by(),++ly;for(var t,e=uy;e;)(t=gy-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ly}()}finally{ly=0,function(){var t,e,n=uy,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:uy=e);cy=t,Sy(r)}(),gy=0}}function Ny(){var t=vy.now(),e=t-py;e>fy&&(my-=e,py=t)}function Sy(t){ly||(hy&&(hy=clearTimeout(hy)),t-gy>24?(t<1/0&&(hy=setTimeout(My,t-vy.now()-my)),dy&&(dy=clearInterval(dy))):(dy||(py=vy.now(),dy=setInterval(Ny,fy)),ly=1,yy(My)))}wy.prototype=xy.prototype={constructor:wy,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?by():+n)+(null==e?0:+e),this._next||cy===this||(cy?cy._next=this:uy=this,cy=this),this._call=t,this._time=n,Sy()},stop:function(){this._call&&(this._call=null,this._time=1/0,Sy())}};const Cy=1664525,ky=1013904223,Ty=4294967296;function Py(t){return t.x}function Ay(t){return t.y}var Oy=10,_y=Math.PI*(3-Math.sqrt(5));function Ry(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,u=xy(h),c=iy("tick","end"),l=function(){let t=1;return()=>(t=(Cy*t+ky)%Ty)/Ty}();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=Oy*Math.sqrt(.5+n),o=n*_y;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 Ly(){var t,e,n,r,i,o=Kv(-30),a=1,s=1/0,u=.81;function c(n){var i,o=t.length,a=Cm(t,Py,Ay).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=Xv(n))*h),0===d&&(p+=(d=Xv(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=Xv(n))*h),0===d&&(p+=(d=Xv(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:Kv(+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 Dy(t){var e,n,r,i=Kv(.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=Kv(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Kv(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Kv(+e),a(),o):t},o}function Iy(t){var e,n,r,i=Kv(.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=Kv(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Kv(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Kv(+e),a(),o):t},o}function jy(){function t(t){return()=>t}let e,n=t=>t.cluster,r=t(1),i=t(-1),o=t(100),a=t(.1),s=[0,0],u=[],c={},l=[],h=100,d=100,f={none:{x:0,y:0}},p=[],g="force",m=!0,v=.1;function y(t){if(!m)return y;e.tick(),E();for(let e,r=0,i=u.length,o=t*v;r<i;++r)e=u[r],e.vx+=(f[n(e)].x-e.x)*o,e.vy+=(f[n(e)].y-e.y)*o}function b(){u&&function(){if(!u||!u.length)return;if(void 0===n(u[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");const t=function(){const t=[],e=[],i={};let o=[],a={},s=[];return a=function(t){const e={};return t.forEach((t=>{const r=n(t);e[r]||(e[r]={count:0,sumforceNodeSize:0})})),t.forEach((t=>{const i=n(t),o=r(t),a=e[i];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=a})),e}(u),s=function(t){const e={},r=[];t.forEach((t=>{const r=function(t){const e=t.source,r=t.target,i=n(c[e]),o=n(c[r]);return i<=o?`${i}~${o}`:`${o}~${i}`}(t);let i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i}));return Object.entries(e).forEach((([t,e])=>{const n=t.split("~")[0],i=t.split("~")[1];void 0!==n&&void 0!==i&&r.push({source:n,target:i,count:e})})),r}(l),o=Object.keys(a),o.forEach(((e,n)=>{const r=a[e];t.push({id:e,size:r.count,r:Math.sqrt(r.sumforceNodeSize/Math.PI)}),i[e]=n})),s.forEach((t=>{const n=t.source,r=t.target,o=i[n],a=i[r];void 0!==o&&void 0!==a&&e.push({source:o,target:a,count:t.count})})),{nodes:t,links:e}}();e=Ry(t.nodes).force("x",Dy(h).strength(.1)).force("y",Iy(d).strength(.1)).force("collide",Jv((t=>t.r)).iterations(4)).force("charge",Ly().strength(i)).force("links",ny(t.nodes.length?t.links:[]).distance(o).strength(a)),p=e.nodes(),E()}()}function E(){return f={none:{x:0,y:0}},p.forEach((t=>{f[t.id]={x:t.x-s[0],y:t.y-s[1]}})),f}return y.initialize=t=>{u=t,b()},y.template=function(t){return arguments.length?(g=t,b(),y):g},y.groupBy=function(t){return arguments.length?"string"==typeof t?(n=e=>e[t],y):(n=t,y):n},y.enableGrouping=function(t){return arguments.length?(m=t,y):m},y.strength=function(t){return arguments.length?(v=t,y):v},y.centerX=function(t){return arguments.length?(h=t,y):h},y.centerY=function(t){return arguments.length?(d=t,y):d},y.nodes=function(t){return arguments.length?(function(t){c={},t.forEach((t=>{c[t.id]=t}))}(t||[]),u=t||[],y):u},y.links=function(t){return arguments.length?(l=t||[],b(),y):l},y.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),b(),y):r},y.nodeSize=y.forceNodeSize,y.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),b(),y):i},y.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),b(),y):o},y.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),b(),y):a},y.offset=function(t){return arguments.length?(s=t,y):s},y.getFocis=E,y}const zy={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10};const By=t=>t.map((t=>{const{x:e,y:n}=t,r=o(t,["x","y"]);return Object.assign(Object.assign({},r),{data:Object.assign(Object.assign({},r.data),{x:e,y:n})})})),Fy=t=>t.map((t=>{const{source:e,target:n}=t,r=o(t,["source","target"]);return Object.assign(Object.assign({},r),{source:e.id,target:n.id})}));var Gy,Vy,Wy,Uy,Hy,qy,$y,Yy,Ky,Xy,Zy,Qy,Jy,tb,eb,nb,rb,ib,ob,ab,sb,ub,cb,lb,hb,db,fb,pb,gb,mb,vb,yb,bb,Eb,wb,xb,Mb,Nb,Sb,Cb,kb,Tb,Pb,Ab,Ob,_b,Rb,Lb,Db,Ib,jb,zb,Bb,Fb,Gb,Vb,Wb,Ub,Hb,qb,$b,Yb,Kb,Xb,Zb,Qb,Jb,tE,eE,nE,rE,iE,oE,aE,sE,uE,cE,lE,hE,dE,fE,pE,gE,mE,vE,yE,bE,EE,wE,xE,ME,NE,SE,CE,kE,TE,PE,AE,OE,_E,RE,LE,DE,IE,jE,zE,BE,FE;function GE(){if(Uy)return Wy;return Uy=1,Wy=function(t,e){return t===e||t!=t&&e!=e}}function VE(){if(qy)return Hy;qy=1;var t=GE();return Hy=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},Hy}function WE(){if(nb)return eb;nb=1;var t=Vy?Gy:(Vy=1,Gy=function(){this.__data__=[],this.size=0}),e=function(){if(Yy)return $y;Yy=1;var t=VE(),e=Array.prototype.splice;return $y=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))},$y}(),n=function(){if(Xy)return Ky;Xy=1;var t=VE();return Ky=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},Ky}(),r=function(){if(Qy)return Zy;Qy=1;var t=VE();return Zy=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(tb)return Jy;tb=1;var t=VE();return Jy=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},Jy}();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,eb=o}function UE(){if(db)return hb;db=1;var t="object"==typeof d&&d&&d.Object===Object&&d;return hb=t}function HE(){if(pb)return fb;pb=1;var t=UE(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return fb=n}function qE(){if(mb)return gb;mb=1;var t=HE().Symbol;return gb=t}function $E(){if(xb)return wb;xb=1;var t=qE(),e=function(){if(yb)return vb;yb=1;var t=qE(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return vb=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(Eb)return bb;Eb=1;var t=Object.prototype.toString;return bb=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return wb=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function YE(){if(Nb)return Mb;return Nb=1,Mb=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function KE(){if(Cb)return Sb;Cb=1;var t=$E(),e=YE();return Sb=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 XE(){if(Ab)return Pb;Ab=1;var t,e=function(){if(Tb)return kb;Tb=1;var t=HE()["__core-js_shared__"];return kb=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Pb=function(t){return!!n&&n in t}}function ZE(){if(_b)return Ob;_b=1;var t=Function.prototype.toString;return Ob=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function QE(){if(zb)return jb;zb=1;var t=function(){if(Lb)return Rb;Lb=1;var t=KE(),e=XE(),n=YE(),r=ZE(),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 Rb=function(o){return!(!n(o)||e(o))&&(t(o)?c:i).test(r(o))}}(),e=Ib?Db:(Ib=1,Db=function(t,e){return null==t?void 0:t[e]});return jb=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function JE(){if(Fb)return Bb;Fb=1;var t=QE()(HE(),"Map");return Bb=t}function tw(){if(Vb)return Gb;Vb=1;var t=QE()(Object,"create");return Gb=t}function ew(){if(tE)return Jb;tE=1;var t=function(){if(Ub)return Wb;Ub=1;var t=tw();return Wb=function(){this.__data__=t?t(null):{},this.size=0}}(),e=qb?Hb:(qb=1,Hb=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Yb)return $b;Yb=1;var t=tw(),e=Object.prototype.hasOwnProperty;return $b=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},$b}(),r=function(){if(Xb)return Kb;Xb=1;var t=tw(),e=Object.prototype.hasOwnProperty;return Kb=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Kb}(),i=function(){if(Qb)return Zb;Qb=1;var t=tw();return Zb=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},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 nw(){if(aE)return oE;aE=1;var t=iE?rE:(iE=1,rE=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return oE=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},oE}function rw(){if(mE)return gE;mE=1;var t=function(){if(nE)return eE;nE=1;var t=ew(),e=WE(),n=JE();return eE=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(uE)return sE;uE=1;var t=nw();return sE=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(lE)return cE;lE=1;var t=nw();return cE=function(e){return t(this,e).get(e)}}(),r=function(){if(dE)return hE;dE=1;var t=nw();return hE=function(e){return t(this,e).has(e)}}(),i=function(){if(pE)return fE;pE=1;var t=nw();return fE=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},fE}();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,gE=o}function iw(){if(EE)return bE;EE=1;var t=WE(),e=function(){if(ib)return rb;ib=1;var t=WE();return rb=function(){this.__data__=new t,this.size=0}}(),n=(ab||(ab=1,ob=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),ob),r=ub?sb:(ub=1,sb=function(t){return this.__data__.get(t)}),i=lb?cb:(lb=1,cb=function(t){return this.__data__.has(t)}),o=function(){if(yE)return vE;yE=1;var t=WE(),e=JE(),n=rw();return vE=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},vE}();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,bE=a}function ow(){if(xE)return wE;return xE=1,wE=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},wE}function aw(){if(NE)return ME;NE=1;var t=QE(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return ME=e}function sw(){if(CE)return SE;CE=1;var t=aw();return SE=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function uw(){if(TE)return kE;TE=1;var t=sw(),e=GE(),n=Object.prototype.hasOwnProperty;return kE=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 cw(){if(AE)return PE;AE=1;var t=uw(),e=sw();return PE=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},PE}function lw(){if(LE)return RE;return LE=1,RE=function(t){return null!=t&&"object"==typeof t}}function hw(){if(zE)return jE;zE=1;var t=function(){if(IE)return DE;IE=1;var t=$E(),e=lw();return DE=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=lw(),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 jE=o}function dw(){if(FE)return BE;FE=1;var t=Array.isArray;return BE=t}var fw,pw,gw,mw,vw,yw,bw,Ew,ww,xw,Mw,Nw={exports:{}};function Sw(){return gw||(gw=1,function(t,e){var n=HE(),r=pw?fw:(pw=1,fw=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}(Nw,Nw.exports)),Nw.exports}function Cw(){if(vw)return mw;vw=1;var t=/^(?:0|[1-9]\d*)$/;return mw=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},mw}function kw(){if(bw)return yw;bw=1;return yw=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Tw(){if(Mw)return xw;return Mw=1,xw=function(t){return function(e){return t(e)}}}Nw.exports;var Pw,Aw,Ow,_w,Rw,Lw,Dw,Iw,jw,zw,Bw,Fw,Gw,Vw,Ww,Uw,Hw,qw,$w,Yw,Kw,Xw,Zw,Qw,Jw,tx,ex,nx={exports:{}};function rx(){return Pw||(Pw=1,function(t,e){var n=UE(),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}(nx,nx.exports)),nx.exports}function ix(){if(Ow)return Aw;Ow=1;var t=function(){if(ww)return Ew;ww=1;var t=$E(),e=kw(),n=lw(),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,Ew=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=Tw(),n=rx(),r=n&&n.isTypedArray,i=r?e(r):t;return Aw=i}function ox(){if(Rw)return _w;Rw=1;var t=(_E||(_E=1,OE=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),OE),e=hw(),n=dw(),r=Sw(),i=Cw(),o=ix(),a=Object.prototype.hasOwnProperty;return _w=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},_w}function ax(){if(Dw)return Lw;Dw=1;var t=Object.prototype;return Lw=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function sx(){if(jw)return Iw;return jw=1,Iw=function(t,e){return function(n){return t(e(n))}}}function ux(){if(Gw)return Fw;Gw=1;var t=ax(),e=function(){if(Bw)return zw;Bw=1;var t=sx()(Object.keys,Object);return zw=t}(),n=Object.prototype.hasOwnProperty;return Fw=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 cx(){if(Ww)return Vw;Ww=1;var t=KE(),e=kw();return Vw=function(n){return null!=n&&e(n.length)&&!t(n)}}function lx(){if(Hw)return Uw;Hw=1;var t=ox(),e=ux(),n=cx();return Uw=function(r){return n(r)?t(r):e(r)}}function hx(){if(Zw)return Xw;Zw=1;var t=YE(),e=ax(),n=Kw?Yw:(Kw=1,Yw=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return Xw=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 dx(){if(Jw)return Qw;Jw=1;var t=ox(),e=hx(),n=cx();return Qw=function(r){return n(r)?t(r,!0):e(r)}}nx.exports;var fx,px,gx,mx,vx,yx,bx,Ex,wx,xx,Mx,Nx,Sx,Cx,kx,Tx,Px,Ax,Ox,_x,Rx,Lx,Dx,Ix,jx,zx,Bx,Fx,Gx,Vx,Wx,Ux,Hx,qx,$x,Yx,Kx,Xx,Zx,Qx,Jx,tM,eM,nM,rM,iM,oM,aM,sM,uM,cM,lM,hM,dM,fM,pM,gM,mM,vM,yM,bM,EM,wM,xM,MM,NM,SM,CM,kM,TM,PM,AM,OM,_M,RM,LM,DM,IM,jM,zM,BM,FM,GM,VM,WM,UM,HM,qM,$M,YM,KM,XM,ZM,QM,JM,tN,eN,nN,rN,iN,oN,aN,sN,uN,cN,lN,hN,dN,fN,pN,gN,mN,vN,yN,bN,EN,wN,xN,MN,NN,SN,CN,kN,TN,PN,AN,ON,_N,RN,LN,DN,IN,jN,zN,BN,FN,GN,VN,WN,UN,HN,qN,$N,YN,KN,XN,ZN,QN,JN,tS,eS,nS,rS,iS,oS,aS,sS,uS,cS,lS,hS,dS,fS,pS,gS,mS,vS,yS,bS,ES,wS,xS,MS,NS,SS,CS,kS,TS,PS,AS,OS,_S,RS,LS,DS,IS,jS,zS,BS,FS,GS,VS,WS,US,HS,qS,$S,YS,KS,XS,ZS,QS,JS,tC,eC,nC,rC,iC,oC,aC,sC,uC,cC,lC,hC,dC,fC,pC,gC,mC,vC,yC,bC,EC,wC,xC,MC,NC,SC,CC,kC,TC,PC,AC,OC,_C,RC,LC,DC,IC,jC,zC,BC,FC,GC,VC,WC,UC,HC,qC,$C,YC,KC,XC,ZC,QC,JC,tk,ek,nk,rk,ik,ok,ak,sk,uk,ck,lk,hk,dk,fk,pk,gk,mk,vk,yk,bk,Ek,wk,xk,Mk={exports:{}};function Nk(){return fx||(fx=1,function(t,e){var n=HE(),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}}(Mk,Mk.exports)),Mk.exports}function Sk(){if(gx)return px;return gx=1,px=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},px}function Ck(){if(vx)return mx;return vx=1,mx=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},mx}function kk(){if(bx)return yx;return bx=1,yx=function(){return[]}}function Tk(){if(wx)return Ex;wx=1;var t=Ck(),e=kk(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return Ex=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function Pk(){if(Sx)return Nx;return Sx=1,Nx=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},Nx}function Ak(){if(kx)return Cx;kx=1;var t=sx()(Object.getPrototypeOf,Object);return Cx=t}function Ok(){if(Px)return Tx;Px=1;var t=Pk(),e=Ak(),n=Tk(),r=kk(),i=Object.getOwnPropertySymbols;return Tx=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function _k(){if(Rx)return _x;Rx=1;var t=Pk(),e=dw();return _x=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function Rk(){if(Dx)return Lx;Dx=1;var t=_k(),e=Tk(),n=lx();return Lx=function(r){return t(r,n,e)}}function Lk(){if(Wx)return Vx;Wx=1;var t=QE()(HE(),"Set");return Vx=t}function Dk(){if($x)return qx;$x=1;var t=function(){if(Bx)return zx;Bx=1;var t=QE()(HE(),"DataView");return zx=t}(),e=JE(),n=function(){if(Gx)return Fx;Gx=1;var t=QE()(HE(),"Promise");return Fx=t}(),r=Lk(),i=function(){if(Hx)return Ux;Hx=1;var t=QE()(HE(),"WeakMap");return Ux=t}(),o=$E(),a=ZE(),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),v=o;return(t&&v(new t(new ArrayBuffer(1)))!=h||e&&v(new e)!=s||n&&v(n.resolve())!=u||r&&v(new r)!=c||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 u;case g:return c;case m:return l}return e}),qx=v}function Ik(){if(Zx)return Xx;Zx=1;var t=HE().Uint8Array;return Xx=t}function jk(){if(Jx)return Qx;Jx=1;var t=Ik();return Qx=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function zk(){if(sM)return aM;sM=1;var t=jk();return aM=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function Bk(){if(cM)return uM;cM=1;var t=jk(),e=function(){if(eM)return tM;eM=1;var t=jk();return tM=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(rM)return nM;rM=1;var t=/\w*$/;return nM=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(oM)return iM;oM=1;var t=qE(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return iM=function(t){return n?Object(n.call(t)):{}}}(),i=zk();return uM=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 Fk(){if(hM)return lM;hM=1;var t=YE(),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 lM=n}function Gk(){if(fM)return dM;fM=1;var t=Fk(),e=Ak(),n=ax();return dM=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function Vk(){if(vM)return mM;vM=1;var t=function(){if(gM)return pM;gM=1;var t=Dk(),e=lw();return pM=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=Tw(),n=rx(),r=n&&n.isMap,i=r?e(r):t;return mM=i}function Wk(){if(wM)return EM;wM=1;var t=function(){if(bM)return yM;bM=1;var t=Dk(),e=lw();return yM=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=Tw(),n=rx(),r=n&&n.isSet,i=r?e(r):t;return EM=i}function Uk(){if(MM)return xM;MM=1;var t=iw(),e=ow(),n=uw(),r=function(){if($w)return qw;$w=1;var t=cw(),e=lx();return qw=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(ex)return tx;ex=1;var t=cw(),e=dx();return tx=function(n,r){return n&&t(r,e(r),n)}}(),o=Nk(),a=Sk(),s=function(){if(Mx)return xx;Mx=1;var t=cw(),e=Tk();return xx=function(n,r){return t(n,e(n),r)}}(),u=function(){if(Ox)return Ax;Ox=1;var t=cw(),e=Ok();return Ax=function(n,r){return t(n,e(n),r)}}(),c=Rk(),l=function(){if(jx)return Ix;jx=1;var t=_k(),e=Ok(),n=dx();return Ix=function(r){return t(r,n,e)}}(),h=Dk(),d=function(){if(Kx)return Yx;Kx=1;var t=Object.prototype.hasOwnProperty;return Yx=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},Yx}(),f=Bk(),p=Gk(),g=dw(),m=Sw(),v=Vk(),y=YE(),b=Wk(),E=lx(),w=dx(),x="[object Arguments]",M="[object Function]",N="[object Object]",S={};return S[x]=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,xM=function C(k,T,P,A,O,_){var R,L=1&T,D=2&T,I=4&T;if(P&&(R=O?P(k,A,O,_):P(k)),void 0!==R)return R;if(!y(k))return k;var j=g(k);if(j){if(R=d(k),!L)return a(k,R)}else{var z=h(k),B=z==M||"[object GeneratorFunction]"==z;if(m(k))return o(k,L);if(z==N||z==x||B&&!O){if(R=D||B?{}:p(k),!L)return D?u(k,i(R,k)):s(k,r(R,k))}else{if(!S[z])return O?k:{};R=f(k,z,L)}}_||(_=new t);var F=_.get(k);if(F)return F;_.set(k,R),b(k)?k.forEach((function(t){R.add(C(t,T,P,t,k,_))})):v(k)&&k.forEach((function(t,e){R.set(e,C(t,T,P,e,k,_))}));var G=j?void 0:(I?D?l:c:D?w:E)(k);return e(G||k,(function(t,e){G&&(t=k[e=t]),n(R,e,C(t,T,P,e,k,_))})),R},xM}function Hk(){if(SM)return NM;SM=1;var t=Uk();return NM=function(e){return t(e,4)}}function qk(){if(kM)return CM;return kM=1,CM=function(t){return function(){return t}}}function $k(){if(OM)return AM;OM=1;var t=(PM||(PM=1,TM=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}}),TM),e=t();return AM=e}function Yk(){if(RM)return _M;RM=1;var t=$k(),e=lx();return _M=function(n,r){return n&&t(n,r,e)}}function Kk(){if(jM)return IM;jM=1;var t=Yk(),e=function(){if(DM)return LM;DM=1;var t=cx();return LM=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}},LM}(),n=e(t);return IM=n}function Xk(){if(BM)return zM;return BM=1,zM=function(t){return t}}function Zk(){if(GM)return FM;GM=1;var t=Xk();return FM=function(e){return"function"==typeof e?e:t}}function Qk(){if(WM)return VM;WM=1;var t=ow(),e=Kk(),n=Zk(),r=dw();return VM=function(i,o){return(r(i)?t:e)(i,n(o))}}function Jk(){return HM?UM:(HM=1,UM=Qk())}function tT(){if(JM)return QM;JM=1;var t=rw(),e=KM?YM:(KM=1,YM=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=ZM?XM:(ZM=1,XM=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,QM=r}function eT(){if(rN)return nN;return rN=1,nN=function(t,e){return t.has(e)}}function nT(){if(oN)return iN;oN=1;var t=tT(),e=(eN||(eN=1,tN=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}),tN),n=eT();return iN=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 v=r[p],y=i[p];if(a)var b=c?a(y,v,p,i,r,u):a(v,y,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)&&(v===t||s(v,t,o,a,u)))return m.push(e)}))){g=!1;break}}else if(v!==y&&!s(v,y,o,a,u)){g=!1;break}}return u.delete(r),u.delete(i),g},iN}function rT(){if(cN)return uN;return cN=1,uN=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},uN}function iT(){if(hN)return lN;hN=1;var t=qE(),e=Ik(),n=GE(),r=nT(),i=(sN||(sN=1,aN=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),aN),o=rT(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return lN=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 oT(){if(gN)return pN;gN=1;var t=iw(),e=nT(),n=iT(),r=function(){if(fN)return dN;fN=1;var t=Rk(),e=Object.prototype.hasOwnProperty;return dN=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 v=n[d=c[h]],y=r[d];if(o)var b=u?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 E=n.constructor,w=r.constructor;E==w||!("constructor"in n)||!("constructor"in r)||"function"==typeof E&&E instanceof E&&"function"==typeof w&&w instanceof w||(g=!1)}return s.delete(n),s.delete(r),g},dN}(),i=Dk(),o=dw(),a=Sw(),s=ix(),u="[object Arguments]",c="[object Array]",l="[object Object]",h=Object.prototype.hasOwnProperty;return pN=function(d,f,p,g,m,v){var y=o(d),b=o(f),E=y?c:i(d),w=b?c:i(f),x=(E=E==u?l:E)==l,M=(w=w==u?l:w)==l,N=E==w;if(N&&a(d)){if(!a(f))return!1;y=!0,x=!1}if(N&&!x)return v||(v=new t),y||s(d)?e(d,f,p,g,m,v):n(d,f,E,p,g,m,v);if(!(1&p)){var S=x&&h.call(d,"__wrapped__"),C=M&&h.call(f,"__wrapped__");if(S||C){var k=S?d.value():d,T=C?f.value():f;return v||(v=new t),m(k,T,p,g,v)}}return!!N&&(v||(v=new t),r(d,f,p,g,m,v))}}function aT(){if(vN)return mN;vN=1;var t=oT(),e=lw();return mN=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))},mN}function sT(){if(wN)return EN;wN=1;var t=YE();return EN=function(e){return e==e&&!t(e)}}function uT(){if(SN)return NN;return SN=1,NN=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function cT(){if(kN)return CN;kN=1;var t=function(){if(bN)return yN;bN=1;var t=iw(),e=aT();return yN=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},yN}(),e=function(){if(MN)return xN;MN=1;var t=sT(),e=lx();return xN=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},xN}(),n=uT();return CN=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 lT(){if(PN)return TN;PN=1;var t=$E(),e=lw();return TN=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function hT(){if(ON)return AN;ON=1;var t=dw(),e=lT(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return AN=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 dT(){if(DN)return LN;DN=1;var t=function(){if(RN)return _N;RN=1;var t=rw();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,_N=e}();return LN=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function fT(){if(BN)return zN;return BN=1,zN=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},zN}function pT(){if(WN)return VN;WN=1;var t=function(){if(GN)return FN;GN=1;var t=qE(),e=fT(),n=dw(),r=lT(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return FN=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},FN}();return VN=function(e){return null==e?"":t(e)}}function gT(){if(HN)return UN;HN=1;var t=dw(),e=hT(),n=function(){if(jN)return IN;jN=1;var t=dT(),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 IN=r}(),r=pT();return UN=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function mT(){if($N)return qN;$N=1;var t=lT();return qN=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function vT(){if(KN)return YN;KN=1;var t=gT(),e=mT();return YN=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},YN}function yT(){if(eS)return tS;eS=1;var t=gT(),e=hw(),n=dw(),r=Cw(),i=kw(),o=mT();return tS=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))},tS}function bT(){if(rS)return nS;rS=1;var t=JN?QN:(JN=1,QN=function(t,e){return null!=t&&e in Object(t)}),e=yT();return nS=function(n,r){return null!=n&&e(n,r,t)}}function ET(){if(oS)return iS;oS=1;var t=aT(),e=function(){if(ZN)return XN;ZN=1;var t=vT();return XN=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=bT(),r=hT(),i=sT(),o=uT(),a=mT();return iS=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 wT(){if(sS)return aS;return sS=1,aS=function(t){return function(e){return null==e?void 0:e[t]}}}function xT(){if(hS)return lS;hS=1;var t=wT(),e=function(){if(cS)return uS;cS=1;var t=vT();return uS=function(e){return function(n){return t(n,e)}}}(),n=hT(),r=mT();return lS=function(i){return n(i)?t(r(i)):e(i)}}function MT(){if(fS)return dS;fS=1;var t=cT(),e=ET(),n=Xk(),r=dw(),i=xT();return dS=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 NT(){if(gS)return pS;gS=1;var t=Ck(),e=function(){if($M)return qM;$M=1;var t=Kk();return qM=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},qM}(),n=MT(),r=dw();return pS=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function ST(){if(bS)return yS;bS=1;var t=function(){if(vS)return mS;vS=1;var t=Object.prototype.hasOwnProperty;return mS=function(e,n){return null!=e&&t.call(e,n)}}(),e=yT();return yS=function(n,r){return null!=n&&e(n,r,t)}}function CT(){if(wS)return ES;wS=1;var t=ux(),e=Dk(),n=hw(),r=dw(),i=cx(),o=Sw(),a=ax(),s=ix(),u=Object.prototype.hasOwnProperty;return ES=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 kT(){if(MS)return xS;return MS=1,xS=function(t){return void 0===t}}function TT(){if(SS)return NS;SS=1;var t=Kk(),e=cx();return NS=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},NS}function PT(){if(kS)return CS;kS=1;var t=fT(),e=MT(),n=TT(),r=dw();return CS=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function AT(){if(RS)return _S;RS=1;var t=(PS||(PS=1,TS=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}),TS),e=Kk(),n=MT(),r=(OS||(OS=1,AS=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),AS),i=dw();return _S=function(o,a,s){var u=i(o)?t:r,c=arguments.length<3;return u(o,n(a,4),s,c,e)},_S}function OT(){if(WS)return VS;WS=1;var t=function(){if(jS)return IS;jS=1;var t=wT()("length");return IS=t}(),e=function(){if(BS)return zS;BS=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return zS=function(e){return t.test(e)}}(),n=function(){if(GS)return FS;GS=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 FS=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return VS=function(r){return e(r)?n(r):t(r)}}function _T(){if(HS)return US;HS=1;var t=ux(),e=Dk(),n=cx(),r=function(){if(DS)return LS;DS=1;var t=$E(),e=dw(),n=lw();return LS=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=OT();return US=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 RT(){if($S)return qS;$S=1;var t=ow(),e=Fk(),n=Yk(),r=MT(),i=Ak(),o=dw(),a=Sw(),s=KE(),u=YE(),c=ix();return qS=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},qS}function LT(){if(ZS)return XS;ZS=1;var t=Pk(),e=function(){if(KS)return YS;KS=1;var t=qE(),e=hw(),n=dw(),r=t?t.isConcatSpreadable:void 0;return YS=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return XS=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},XS}function DT(){if(eC)return tC;eC=1;var t=JS?QS:(JS=1,QS=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 tC=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)}},tC}function IT(){if(sC)return aC;sC=1;var t=function(){if(rC)return nC;rC=1;var t=qk(),e=aw(),n=Xk();return nC=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(oC)return iC;oC=1;var t=Date.now;return iC=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)}},iC}(),n=e(t);return aC=n}function jT(){if(cC)return uC;cC=1;var t=Xk(),e=DT(),n=IT();return uC=function(r,i){return n(e(r,i,t),r+"")}}function zT(){if(hC)return lC;return hC=1,lC=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},lC}function BT(){if(vC)return mC;vC=1;var t=zT(),e=fC?dC:(fC=1,dC=function(t){return t!=t}),n=(gC||(gC=1,pC=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),pC);return mC=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function FT(){if(SC)return NC;SC=1;var t=Lk(),e=MC?xC:(MC=1,xC=function(){}),n=rT(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return NC=r}function GT(){if(kC)return CC;kC=1;var t=tT(),e=function(){if(bC)return yC;bC=1;var t=BT();return yC=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(wC||(wC=1,EC=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}),EC),r=eT(),i=FT(),o=rT();return CC=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],v=s?s(m):m;if(m=u||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,u)||(p!==f&&p.push(v),f.push(m))}return f},CC}function VT(){if(PC)return TC;PC=1;var t=cx(),e=lw();return TC=function(n){return e(n)&&t(n)}}function WT(){if(OC)return AC;OC=1;var t=LT(),e=jT(),n=GT(),r=VT(),i=e((function(e){return n(t(e,1,r,!0))}));return AC=i}function UT(){if(DC)return LC;DC=1;var t=function(){if(RC)return _C;RC=1;var t=fT();return _C=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=lx();return LC=function(n){return null==n?[]:t(n,e(n))}}function HT(){if(jC)return IC;var t;jC=1;try{t={clone:Hk(),constant:qk(),each:Jk(),filter:NT(),has:ST(),isArray:dw(),isEmpty:CT(),isFunction:KE(),isUndefined:kT(),keys:lx(),map:PT(),reduce:AT(),size:_T(),transform:RT(),union:WT(),values:UT()}}catch(t){}return t||(t=window._),IC=t}function qT(){if(BC)return zC;BC=1;var t=HT();zC=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))},zC}function $T(){return WC?VC:(WC=1,VC={Graph:qT(),version:GC?FC:(GC=1,FC="2.1.8")})}function YT(){if(HC)return UC;HC=1;var t=HT(),e=qT();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 UC={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 KT(){if($C)return qC;$C=1;var t=HT();return qC=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},qC}function XT(){if(KC)return YC;KC=1;var t=HT();function e(){this._arr=[],this._keyIndices={}}return YC=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},YC}function ZT(){if(ZC)return XC;ZC=1;var t=HT(),e=XT();XC=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 XC}function QT(){if(JC)return QC;JC=1;var t=ZT(),e=HT();return QC=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function JT(){if(ek)return tk;ek=1;var t=HT();return tk=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},tk}function tP(){if(rk)return nk;rk=1;var t=HT(),e=JT();return nk=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function eP(){if(ok)return ik;ok=1;var t=HT();ik=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 ik}function nP(){if(sk)return ak;sk=1;var t=HT();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 ak=e,e.CycleException=n,n.prototype=new Error,ak}function rP(){if(ck)return uk;ck=1;var t=nP();return uk=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function iP(){if(hk)return lk;hk=1;var t=HT();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 lk=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},lk}function oP(){if(fk)return dk;fk=1;var t=iP();return dk=function(e,n){return t(e,n,"post")}}function aP(){if(gk)return pk;gk=1;var t=iP();return pk=function(e,n){return t(e,n,"pre")}}function sP(){if(vk)return mk;vk=1;var t=HT(),e=qT(),n=XT();return mk=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}}Mk.exports;try{xk=function(){if(wk)return Ek;wk=1;var t=$T();return Ek={Graph:t.Graph,json:YT(),alg:bk?yk:(bk=1,yk={components:KT(),dijkstra:ZT(),dijkstraAll:QT(),findCycles:tP(),floydWarshall:eP(),isAcyclic:rP(),postorder:oP(),preorder:aP(),prim:sP(),tarjan:JT(),topsort:nP()}),version:t.version}}()}catch(t){}xk||(xk=window.graphlib);var uP,cP,lP,hP,dP,fP,pP,gP,mP,vP,yP,bP,EP,wP,xP,MP,NP,SP,CP,kP,TP,PP,AP,OP,_P,RP,LP,DP,IP,jP,zP,BP,FP,GP,VP,WP,UP,HP,qP,$P,YP,KP,XP,ZP,QP,JP,tA,eA,nA,rA,iA,oA,aA,sA,uA,cA,lA,hA,dA,fA,pA,gA,mA,vA,yA,bA,EA,wA,xA,MA,NA,SA,CA,kA,TA,PA,AA,OA,_A,RA,LA,DA,IA,jA,zA,BA,FA,GA,VA,WA,UA,HA,qA,$A=xk;function YA(){if(hP)return lP;hP=1;var t=GE(),e=cx(),n=Cw(),r=YE();return lP=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)},lP}function KA(){if(bP)return yP;bP=1;var t=function(){if(vP)return mP;vP=1;var t=/\s/;return mP=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},mP}(),e=/^\s+/;return yP=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function XA(){if(MP)return xP;MP=1;var t=function(){if(wP)return EP;wP=1;var t=KA(),e=YE(),n=lT(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return EP=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 xP=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 ZA(){if(kP)return CP;kP=1;var t=zT(),e=MT(),n=function(){if(SP)return NP;SP=1;var t=XA();return NP=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return CP=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)},CP}function QA(){if(OP)return AP;OP=1;var t=LT();return AP=function(e){return(null==e?0:e.length)?t(e,1):[]}}function JA(){if(BP)return zP;BP=1;var t=lT();return zP=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},zP}function tO(){if(HP)return UP;HP=1;var t=sw(),e=GE();return UP=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function eO(){if(KP)return YP;return KP=1,YP=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function nO(){if(JP)return QP;JP=1;var t=tO(),e=Nk(),n=zk(),r=Sk(),i=Gk(),o=hw(),a=dw(),s=VT(),u=Sw(),c=KE(),l=YE(),h=function(){if($P)return qP;$P=1;var t=$E(),e=Ak(),n=lw(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return qP=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=ix(),f=eO(),p=function(){if(ZP)return XP;ZP=1;var t=cw(),e=dx();return XP=function(n){return t(n,e(n))}}();return QP=function(g,m,v,y,b,E,w){var x=f(g,v),M=f(m,v),N=w.get(M);if(N)t(g,v,N);else{var S=E?E(x,M,v+"",g,m,w):void 0,C=void 0===S;if(C){var k=a(M),T=!k&&u(M),P=!k&&!T&&d(M);S=M,k||T||P?a(x)?S=x:s(x)?S=r(x):T?(C=!1,S=e(M,!0)):P?(C=!1,S=n(M,!0)):S=[]:h(M)||o(M)?(S=x,o(x)?S=p(x):l(x)&&!c(x)||(S=i(M))):C=!1}C&&(w.set(M,S),b(S,M,y,E,w),w.delete(M)),t(g,v,S)}}}function rO(){if(sA)return aA;return sA=1,aA=function(t,e){return t<e}}function iO(){if(vA)return mA;vA=1;var t=vT(),e=function(){if(gA)return pA;gA=1;var t=uw(),e=gT(),n=Cw(),r=YE(),i=mT();return pA=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},pA}(),n=gT();return mA=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},mA}function oO(){if(kA)return CA;kA=1;var t=function(){if(SA)return NA;SA=1;var t=Math.ceil,e=Math.max;return NA=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},NA}(),e=YA(),n=XA();return CA=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)}},CA}function aO(){if(DA)return LA;DA=1;var t=function(){if(RA)return _A;RA=1;var t=lT();return _A=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 LA=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},LA}function sO(){if(jA)return IA;jA=1;var t=fT(),e=vT(),n=MT(),r=TT(),i=(OA||(OA=1,AA=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),AA),o=Tw(),a=aO(),s=Xk(),u=dw();return IA=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)}))},IA}try{qA={cloneDeep:function(){if(cP)return uP;cP=1;var t=Uk();return uP=function(e){return t(e,5)}}(),constant:qk(),defaults:function(){if(fP)return dP;fP=1;var t=jT(),e=GE(),n=YA(),r=dx(),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 dP=a}(),each:Jk(),filter:NT(),find:function(){if(PP)return TP;PP=1;var t=function(){if(gP)return pP;gP=1;var t=MT(),e=cx(),n=lx();return pP=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}},pP}(),e=t(ZA());return TP=e}(),flatten:QA(),forEach:Qk(),forIn:function(){if(RP)return _P;RP=1;var t=$k(),e=Zk(),n=dx();return _P=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:ST(),isUndefined:kT(),last:(DP||(DP=1,LP=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),LP),map:PT(),mapValues:function(){if(jP)return IP;jP=1;var t=sw(),e=Yk(),n=MT();return IP=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(WP)return VP;WP=1;var t=JA(),e=GP?FP:(GP=1,FP=function(t,e){return t>e}),n=Xk();return VP=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(oA)return iA;oA=1;var t=function(){if(eA)return tA;eA=1;var t=iw(),e=tO(),n=$k(),r=nO(),i=YE(),o=dx(),a=eO();return tA=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)},tA}(),e=function(){if(rA)return nA;rA=1;var t=jT(),e=YA();return nA=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}))},nA}(),n=e((function(e,n,r){t(e,n,r)}));return iA=n}(),min:function(){if(cA)return uA;cA=1;var t=JA(),e=rO(),n=Xk();return uA=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(hA)return lA;hA=1;var t=JA(),e=MT(),n=rO();return lA=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(fA)return dA;fA=1;var t=HE();return dA=function(){return t.Date.now()}}(),pick:function(){if(MA)return xA;MA=1;var t=function(){if(bA)return yA;bA=1;var t=iO(),e=bT();return yA=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(wA)return EA;wA=1;var t=QA(),e=DT(),n=IT();return EA=function(r){return n(e(r,void 0,t),r+"")}}(),n=e((function(e,n){return null==e?{}:t(e,n)}));return xA=n}(),range:function(){if(PA)return TA;PA=1;var t=oO()();return TA=t}(),reduce:AT(),sortBy:function(){if(BA)return zA;BA=1;var t=LT(),e=sO(),n=jT(),r=YA(),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 zA=i}(),uniqueId:function(){if(GA)return FA;GA=1;var t=pT(),e=0;return FA=function(n){var r=++e;return t(n)+r},FA}(),values:UT(),zipObject:function(){if(HA)return UA;HA=1;var t=uw(),e=(WA||(WA=1,VA=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}),VA);return UA=function(n,r){return e(n||[],r||[],t)},UA}()}}catch(t){}qA||(qA=window._);var uO=qA,cO=lO;function lO(){var t={};t._next=t._prev=t,this._sentinel=t}function hO(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function dO(t,e){if("_next"!==t&&"_prev"!==t)return e}lO.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return hO(e),e},lO.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&hO(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},lO.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,dO)),n=n._prev;return"["+t.join(", ")+"]"};var fO=uO,pO=$A.Graph,gO=cO,mO=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new pO,r=0,i=0;fO.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),fO.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=fO.range(i+r+3).map((function(){return new gO})),a=r+1;return fO.forEach(n.nodes(),(function(t){bO(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||vO),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)yO(t,e,n,r);for(;r=o.dequeue();)yO(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(yO(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return fO.flatten(fO.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},vO=fO.constant(1);function yO(t,e,n,r,i){var o=i?[]:void 0;return fO.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,bO(e,n,s)})),fO.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,bO(e,n,a)})),t.removeNode(r.v),o}function bO(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 EO=uO,wO=mO,xO={run:function(t){var e="greedy"===t.graph().acyclicer?wO(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){EO.has(r,o)||(r[o]=!0,n[o]=!0,EO.forEach(t.outEdges(o),(function(t){EO.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return EO.forEach(t.nodes(),i),e}(t);EO.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,EO.uniqueId("rev"))}))},undo:function(t){EO.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 MO=uO,NO=$A.Graph,SO={addDummyNode:CO,simplify:function(t){var e=(new NO).setGraph(t.graph());return MO.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),MO.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 NO({multigraph:t.isMultigraph()}).setGraph(t.graph());return MO.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),MO.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=MO.map(t.nodes(),(function(e){var n={};return MO.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return MO.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=MO.map(t.nodes(),(function(e){var n={};return MO.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return MO.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=MO.map(MO.range(kO(t)+1),(function(){return[]}));return MO.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;MO.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=MO.min(MO.map(t.nodes(),(function(e){return t.node(e).rank})));MO.forEach(t.nodes(),(function(n){var r=t.node(n);MO.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=MO.min(MO.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];MO.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;MO.forEach(n,(function(e,n){MO.isUndefined(e)&&n%i!=0?--r:r&&MO.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 CO(t,"border",i,e)},maxRank:kO,partition:function(t,e){var n={lhs:[],rhs:[]};return MO.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=MO.now();try{return e()}finally{console.log(t+" time: "+(MO.now()-n)+"ms")}},notime:function(t,e){return e()}};function CO(t,e,n,r){var i;do{i=MO.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function kO(t){return MO.max(MO.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!MO.isUndefined(n))return n})))}var TO=uO,PO=SO,AO={run:function(t){t.graph().dummyChains=[],TO.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=PO.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){TO.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 OO=uO,_O={longestPath:function(t){var e={};OO.forEach(t.sources(),(function n(r){var i=t.node(r);if(OO.has(e,r))return i.rank;e[r]=!0;var o=OO.min(OO.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 RO=uO,LO=$A.Graph,DO=_O.slack,IO=function(t){var e,n,r=new LO({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;jO(r,t)<o;)e=zO(r,t),n=r.hasNode(e.v)?DO(t,e):-DO(t,e),BO(r,t,n);return r};function jO(t,e){return RO.forEach(t.nodes(),(function n(r){RO.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||DO(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function zO(t,e){return RO.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return DO(e,n)}))}function BO(t,e,n){RO.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var FO=uO,GO=IO,VO=_O.slack,WO=_O.longestPath,UO=$A.alg.preorder,HO=$A.alg.postorder,qO=SO.simplify,$O=YO;function YO(t){t=qO(t),WO(t);var e,n=GO(t);for(ZO(n),KO(n,t);e=JO(n);)e_(n,t,e,t_(n,t,e))}function KO(t,e){var n=HO(t,t.nodes());n=n.slice(0,n.length-1),FO.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=XO(t,e,n)}(t,e,n)}))}function XO(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,FO.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 ZO(t,e){arguments.length<2&&(e=t.nodes()[0]),QO(t,{},1,e)}function QO(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,FO.forEach(t.neighbors(r),(function(i){FO.has(e,i)||(n=QO(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function JO(t){return FO.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function t_(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=FO.filter(e.edges(),(function(e){return u===n_(t,t.node(e.v),s)&&u!==n_(t,t.node(e.w),s)}));return FO.minBy(c,(function(t){return VO(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,{}),ZO(t),KO(t,e),function(t,e){var n=FO.find(t.nodes(),(function(t){return!e.node(t).parent})),r=UO(t,n);r=r.slice(1),FO.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 n_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}YO.initLowLimValues=ZO,YO.initCutValues=KO,YO.calcCutValue=XO,YO.leaveEdge=JO,YO.enterEdge=t_,YO.exchangeEdges=e_;var r_=_O.longestPath,i_=IO,o_=$O,a_=function(t){switch(t.graph().ranker){case"network-simplex":default:u_(t);break;case"tight-tree":!function(t){r_(t),i_(t)}(t);break;case"longest-path":s_(t)}};var s_=r_;function u_(t){o_(t)}var c_=uO,l_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;c_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return c_.forEach(t.children(),r),e}(t);c_.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 h_=uO,d_=SO,f_={run:function(t){var e=d_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&h_.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return h_.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=h_.max(h_.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,h_.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return h_.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;h_.forEach(t.children(),(function(a){p_(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,h_.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function p_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var u=d_.addBorderNode(t,"_bt"),c=d_.addBorderNode(t,"_bb"),l=t.node(a);t.setParent(u,a),l.borderTop=u,t.setParent(c,a),l.borderBottom=c,h_.forEach(s,(function(s){p_(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 g_=uO,m_=SO,v_=function(t){g_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&g_.forEach(r,e),g_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)y_(t,"borderLeft","_bl",n,i,o),y_(t,"borderRight","_br",n,i,o)}}))};function y_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],u=m_.addDummyNode(t,"border",a,n);i[e][o]=u,t.setParent(u,r),s&&t.setEdge(s,u,{weight:1})}var b_=uO,E_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||w_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){b_.forEach(t.nodes(),(function(e){M_(t.node(e))})),b_.forEach(t.edges(),(function(e){var n=t.edge(e);b_.forEach(n.points,M_),b_.has(n,"y")&&M_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){b_.forEach(t.nodes(),(function(e){N_(t.node(e))})),b_.forEach(t.edges(),(function(e){var n=t.edge(e);b_.forEach(n.points,N_),b_.has(n,"x")&&N_(n)}))}(t),w_(t))}};function w_(t){b_.forEach(t.nodes(),(function(e){x_(t.node(e))})),b_.forEach(t.edges(),(function(e){x_(t.edge(e))}))}function x_(t){var e=t.width;t.width=t.height,t.height=e}function M_(t){t.y=-t.y}function N_(t){var e=t.x;t.x=t.y,t.y=e}var S_=uO,C_=function(t){var e={},n=S_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=S_.max(S_.map(n,(function(e){return t.node(e).rank}))),i=S_.map(S_.range(r+1),(function(){return[]}));function o(n){if(!S_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),S_.forEach(t.successors(n),o)}}var a=S_.sortBy(n,(function(e){return t.node(e).rank}));return S_.forEach(a,o),i};var k_=uO,T_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=P_(t,e[r-1],e[r]);return n};function P_(t,e,n){for(var r=k_.zipObject(n,k_.map(n,(function(t,e){return e}))),i=k_.flatten(k_.map(e,(function(e){return k_.sortBy(k_.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=k_.map(new Array(a),(function(){return 0})),u=0;return k_.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 A_=uO;var O_=uO,__=function(t,e){var n={};return O_.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};O_.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),O_.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];O_.isUndefined(e)||O_.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(O_.isUndefined(e.barycenter)||O_.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),O_.forEach(i.in.reverse(),n(i)),O_.forEach(i.out,r(i))}return O_.map(O_.filter(e,(function(t){return!t.merged})),(function(t){return O_.pick(t,["vs","i","barycenter","weight"])}))}(O_.filter(n,(function(t){return!t.indegree})))};var R_=uO,L_=SO;function D_(t,e,n){for(var r;e.length&&(r=R_.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var I_=uO,j_=function(t,e){return A_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=A_.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}}))},z_=__,B_=function(t,e){var n=L_.partition(t,(function(t){return R_.has(t,"barycenter")})),r=n.lhs,i=R_.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=D_(o,i,u),R_.forEach(r,(function(t){u+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,u=D_(o,i,u)}));var c;var l={vs:R_.flatten(o,!0)};s&&(l.barycenter=a/s,l.weight=s);return l},F_=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=I_.filter(o,(function(t){return t!==s&&t!==u})));var l=j_(e,o);I_.forEach(l,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);c[n.v]=o,I_.has(o,"barycenter")&&(a=n,s=o,I_.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=z_(l,r);!function(t,e){I_.forEach(t,(function(t){t.vs=I_.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,c);var d=B_(h,i);if(s&&(d.vs=I_.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]);I_.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 G_=uO,V_=$A.Graph,W_=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=G_.uniqueId("_root")););return e}(t),i=new V_({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return G_.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),G_.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=G_.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),G_.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var U_=uO;var H_=uO,q_=C_,$_=T_,Y_=F_,K_=W_,X_=function(t,e,n){var r,i={};U_.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}}))},Z_=$A.Graph,Q_=SO,J_=function(t){var e=Q_.maxRank(t),n=tR(t,H_.range(1,e+1),"inEdges"),r=tR(t,H_.range(e-1,-1,-1),"outEdges"),i=q_(t);nR(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=Q_.buildLayerMatrix(t);var c=$_(t,i);c<a&&(u=0,o=H_.cloneDeep(i),a=c)}nR(t,o)};function tR(t,e,n){return H_.map(e,(function(e){return K_(t,e,n)}))}function eR(t,e){var n=new Z_;H_.forEach(t,(function(t){var r=t.graph().root,i=Y_(t,r,n,e);H_.forEach(i.vs,(function(e,n){t.node(e).order=n})),X_(t,n,i.vs)}))}function nR(t,e){H_.forEach(e,(function(e){H_.forEach(e,(function(e,n){t.node(e).order=n}))}))}var rR=uO,iR=$A.Graph,oR=SO,aR=function(t){var e,n=oR.buildLayerMatrix(t),r=rR.merge(sR(t,n),uR(t,n)),i={};rR.forEach(["u","d"],(function(o){e="u"===o?n:rR.values(n).reverse(),rR.forEach(["l","r"],(function(n){"r"===n&&(e=rR.map(e,(function(t){return rR.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=hR(t,e,r,a),u=dR(t,e,s.root,s.align,"r"===n);"r"===n&&(u=rR.mapValues(u,(function(t){return-t}))),i[o+n]=u}))}));var o=fR(t,i);return pR(i,o),gR(i,t.graph().align)};function sR(t,e){var n={};return rR.reduce(e,(function(e,r){var i=0,o=0,a=e.length,s=rR.last(r);return rR.forEach(r,(function(e,u){var c=function(t,e){if(t.node(e).dummy)return rR.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),l=c?t.node(c).order:a;(c||e===s)&&(rR.forEach(r.slice(o,u+1),(function(e){rR.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||l<a)||o.dummy&&t.node(e).dummy||cR(n,r,e)}))})),o=u+1,i=l)})),r})),n}function uR(t,e){var n={};function r(e,r,i,o,a){var s;rR.forEach(rR.range(r,i),(function(r){s=e[r],t.node(s).dummy&&rR.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&cR(n,e,s)}))}))}return rR.reduce(e,(function(e,n){var i,o=-1,a=0;return rR.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 cR(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 lR(t,e,n){if(e>n){var r=e;e=n,n=r}return rR.has(t[e],n)}function hR(t,e,n,r){var i={},o={},a={};return rR.forEach(e,(function(t){rR.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),rR.forEach(e,(function(t){var e=-1;rR.forEach(t,(function(t){var s=r(t);if(s.length){s=rR.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]&&!lR(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}function dR(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new iR,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,rR.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,rR.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 rR.forEach(e,(function(e){var r;rR.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)),rR.forEach(r,(function(t){o[t]=o[n[t]]})),o}function fR(t,e){return rR.minBy(rR.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return rR.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 pR(t,e){var n=rR.values(e),r=rR.min(n),i=rR.max(n);rR.forEach(["u","d"],(function(n){rR.forEach(["l","r"],(function(o){var a,s=n+o,u=t[s];if(u!==e){var c=rR.values(u);(a="l"===o?r-rR.min(c):i-rR.max(c))&&(t[s]=rR.mapValues(u,(function(t){return t+a})))}}))}))}function gR(t,e){return rR.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=rR.sortBy(rR.map(t,r));return(i[1]+i[2])/2}))}var mR=uO,vR=SO,yR=aR,bR=function(t){(function(t){var e=vR.buildLayerMatrix(t),n=t.graph().ranksep,r=0;mR.forEach(e,(function(e){var i=mR.max(mR.map(e,(function(e){return t.node(e).height})));mR.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=vR.asNonCompoundGraph(t)),mR.forEach(yR(t),(function(e,n){t.node(n).x=e}))};var ER=uO,wR=xO,xR=AO,MR=a_,NR=SO.normalizeRanks,SR=l_,CR=SO.removeEmptyRanks,kR=f_,TR=v_,PR=E_,AR=J_,OR=bR,_R=SO,RR=$A.Graph,LR=function(t,e){var n=e&&e.debugTiming?_R.time:_R.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new RR({multigraph:!0,compound:!0}),n=UR(t.graph());return e.setGraph(ER.merge({},IR,WR(n,DR),ER.pick(n,jR))),ER.forEach(t.nodes(),(function(n){var r=UR(t.node(n));e.setNode(n,ER.defaults(WR(r,zR),BR)),e.setParent(n,t.parent(n))})),ER.forEach(t.edges(),(function(n){var r=UR(t.edge(n));e.setEdge(n,ER.merge({},GR,WR(r,FR),ER.pick(r,VR)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,ER.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){ER.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(){wR.run(t)})),e(" nestingGraph.run",(function(){kR.run(t)})),e(" rank",(function(){MR(_R.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){ER.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};_R.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){CR(t)})),e(" nestingGraph.cleanup",(function(){kR.cleanup(t)})),e(" normalizeRanks",(function(){NR(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;ER.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=ER.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){ER.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(){xR.run(t)})),e(" parentDummyChains",(function(){SR(t)})),e(" addBorderSegments",(function(){TR(t)})),e(" order",(function(){AR(t)})),e(" insertSelfEdges",(function(){!function(t){var e=_R.buildLayerMatrix(t);ER.forEach(e,(function(e){var n=0;ER.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,ER.forEach(i.selfEdges,(function(e){_R.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(){PR.adjust(t)})),e(" position",(function(){OR(t)})),e(" positionSelfEdges",(function(){!function(t){ER.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){ER.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(ER.last(n.borderLeft)),a=t.node(ER.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}})),ER.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){xR.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){ER.forEach(t.edges(),(function(e){var n=t.edge(e);if(ER.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(){PR.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)}ER.forEach(t.nodes(),(function(e){u(t.node(e))})),ER.forEach(t.edges(),(function(e){var n=t.edge(e);ER.has(n,"x")&&u(n)})),e-=a,r-=s,ER.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),ER.forEach(t.edges(),(function(n){var i=t.edge(n);ER.forEach(i.points,(function(t){t.x-=e,t.y-=r})),ER.has(i,"x")&&(i.x-=e),ER.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){ER.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(_R.intersectRect(o,n)),i.points.push(_R.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){ER.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){wR.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){ER.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))})),ER.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,ER.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 DR=["nodesep","edgesep","ranksep","marginx","marginy"],IR={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},jR=["acyclicer","ranker","rankdir","align"],zR=["width","height"],BR={width:0,height:0},FR=["minlen","weight","width","height","labeloffset"],GR={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},VR=["labelpos"];function WR(t,e){return ER.mapValues(ER.pick(t,e),Number)}function UR(t){var e={};return ER.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var HR=uO,qR=SO,$R=$A.Graph,YR={debugOrdering:function(t){var e=qR.buildLayerMatrix(t),n=new $R({compound:!0,multigraph:!0}).setGraph({});return HR.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),HR.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),HR.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),HR.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var KR={graphlib:$A,layout:LR,debug:YR,util:{time:SO.time,notime:SO.notime},version:"0.8.5"},XR=f(KR);class ZR{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,ZR.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 KR.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]}(Tt(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})})),XR.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}))}}ZR.defaultOptions={};class QR{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 QR({rx:n,ry:r,mass:e,degree:i})}}class JR{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 JR({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 JR({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 JR({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 JR({xmid:t,ymid:e,length:n})}}class tL{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 tL(this.quad.NW()),this.NE=new tL(this.quad.NE()),this.SW=new tL(this.quad.SW()),this.SE=new tL(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 eL={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 nL={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};const rL={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 iL=(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},oL=(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},aL=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,sL=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,uL=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},cL=(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(;aL(s,a);)uL(o,a);u=a.col*n+n/2+e[0],c=a.row*r+r/2+e[1],sL(s,a),uL(o,a)}t.data.x=u,t.data.y=c},lL={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},hL=(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}}))}))},dL=(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},fL={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};const pL=(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=Bt(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=Bt(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},gL=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},mL=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},vL=(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}},yL=(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},bL={center:[0,0],width:300,height:300};function EL(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 uD=Symbol("Comlink.proxy"),lD=Symbol("Comlink.endpoint"),hD=Symbol("Comlink.releaseProxy"),dD=Symbol("Comlink.finalizer"),fD=Symbol("Comlink.thrown"),pD=t=>"object"==typeof t&&null!==t||"function"==typeof t,gD=new Map([["proxy",{canHandle:t=>pD(t)&&t[uD],serialize(t){const{port1:e,port2:n}=new MessageChannel;return mD(t,e),[n,[n]]},deserialize:t=>(t.start(),yD(t))}],["throw",{canHandle:t=>pD(t)&&fD 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 mD(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(kD);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]]=kD(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,c);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[uD]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;mD(t,n),u=function(t,e){return SD.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[fD]:0}}Promise.resolve(u).catch((t=>({value:t,[fD]:0}))).then((n=>{const[i,s]=TD(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),vD(e),dD in t&&"function"==typeof t[dD]&&t[dD]())})).catch((t=>{const[n,r]=TD({value:new TypeError("Unserializable return value"),[fD]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function vD(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function yD(t,e){return MD(t,[],e)}function bD(t){if(t)throw new Error("Proxy has been released and is not useable")}function ED(t){return CD(t,{type:"RELEASE"}).then((()=>{vD(t)}))}const wD=new WeakMap,xD="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(wD.get(t)||0)-1;wD.set(t,e),0===e&&ED(t)}));function MD(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(bD(r),o===hD)return()=>{!function(t){xD&&xD.unregister(t)}(i),ED(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=CD(t,{type:"GET",path:e.map((t=>t.toString()))}).then(kD);return n.then.bind(n)}return MD(t,[...e,o])},set(n,i,o){bD(r);const[a,s]=TD(o);return CD(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(kD)},apply(n,i,o){bD(r);const a=e[e.length-1];if(a===lD)return CD(t,{type:"ENDPOINT"}).then(kD);if("bind"===a)return MD(t,e.slice(0,-1));const[s,c]=ND(o);return CD(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},c).then(kD)},construct(n,i){bD(r);const[o,a]=ND(i);return CD(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(kD)}});return function(t,e){const n=(wD.get(e)||0)+1;wD.set(e,n),xD&&xD.register(t,e,t)}(i,t),i}function ND(t){const e=t.map(TD);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const SD=new WeakMap;function TD(t){for(const[e,n]of gD)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},SD.get(t)||[]]}function kD(t){switch(t.type){case"HANDLER":return gD.get(t.name).deserialize(t.value);case"RAW":return t.value}}function CD(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 PD extends Yf{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=yD(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=>{kt(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[hD]()}isRunning(){return this.running}}class AD extends Th{}const OD=t=>t?parseInt(t):0;function RD(t){let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||OD(e.width),r=t.clientHeight||OD(e.height);return[n-(OD(e.paddingLeft)+OD(e.paddingRight)),r-(OD(e.paddingTop)+OD(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(Vt(e)?e:1,1),Math.max(Vt(n)?n:1,1)]}function _D(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 DD(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 ID extends AD{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=_D("contextmenu",!1);constructor(t,e){super(t,Object.assign({},ID.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),DD("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 LD extends AD{static defaultOptions={lineWidth:1,border:!0,borderLineWidth:1,borderStroke:"#0001",borderStyle:"solid",stroke:"#0001",size:20,tickCount:4,tickStrokeOpacity:.5};$element=_D("grid-line");offset=[0,0];constructor(t,e){super(t,Object.assign({},LD.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))}(Vu(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()}}class jD extends AD{static defaultOptions={position:"top-left",enable:!0};$element=_D("toolbar",!1);constructor(t,e){super(t,Object.assign({},jD.defaultOptions,e));const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),DD("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),DD("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)}}}function zD(t,e){e(t),t.children&&t.children.forEach((function(t){t&&zD(t,e)}))}function FD(t){BD(t,!1)}function BD(t,e){var n=e?"visible":"hidden";zD(t,(function(t){t.attr("visibility",n)}))}var GD=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(qa.INSERTED,(function(){FD(r)})),r}return r(e,t),e}(Cs);var VD=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}(),UD=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?It(s)?(It(t[a])||(c[a]={}),n<r?UD(t[a],s,n+1,r):c[a]=e[a]):Ot(s)?(c[a]=[],c[a]=c[a].concat(s)):c[a]=s:c[a]=s)}))},WD=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)UD(t,e[r]);return t};function HD(){BD(this,"hidden"!==this.attributes.visibility)}var qD=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,WD({},{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=function(t){var e=t.appendChild(new GD({class:"offscreen"}));return FD(e),e}(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&&HD.call(this)},e.prototype.update=function(t,e){var n;return this.attr(WD({},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}(Ts);function $D(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 YD={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function XD(t){var e;void 0===t&&(t="");var n=$D(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},YD),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)"},YD),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 KD=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=$D(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:XD(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 qe(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=qe(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=$D(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},E=[];c.split("-").forEach((function(t){b[t]?E.push(m[t]):E.push(t)}));var w=E.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 VD(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}(qD);class ZD extends AD{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({},ZD.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,afterremoveitem: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=oe(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 KD({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 QD;function JD(t,e){QD||(QD=document.createElement("canvas")),QD.width=t,QD.height=e;return QD.getContext("2d").clearRect(0,0,t,e),QD}class tI extends AD{static defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};$element=_D("watermark");constructor(t,e){super(t,Object.assign({},tI.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=JD(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=JD(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 eI=["#7E92B5","#f5222d","#faad14"],nI={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},rI={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function iI(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeBadgePalette:a=eI,nodePaletteOptions:s=nI,edgeColor:c,edgeColorDisabled:u,edgePaletteOptions:l=rI,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,labelOpacity:1,opacity:1,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65},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:{iconOpacity:.25,labelOpacity:.25,opacity:.25},disabled:{color:i,labelOpacity:.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,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:{labelOpacity:.25,color:u}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["color"]},{fields:["path"],shape:"key"}]}},combo:{style:{collapsedMaskFill:h,collapsedMaskFontSize:12,collapsedSize:32,color:h,haloLineWidth:12,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,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 oI=iI({bgColor:"#000000",textColor:"#ffffffd9",nodeColor:"#1783ff",nodeColorDisabled:"#d0e4ff",nodeStroke:"#d0e4ff",edgeColor:"#99add1",edgeColorDisabled:"#969696",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696"}),aI=iI({bgColor:"#fff",textColor:"#000000d9",nodeColor:"#1783ff",nodeColorDisabled:"#f0f0f0",nodeStroke:"#000000",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",comboColor:"#fdfdfd",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9"}),sI={animation:{fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}],"combo-collapse-expand":[{fields:["x","y"]},{fields:["r","width","height"],shape:"key"}]},behavior:{"zoom-canvas":jh,"drag-canvas":Ah,"drag-element":Oh,"collapse-expand":Ch,"hover-element":Lh,"focus-element":_h},combo:{circle:class extends kl{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Ss,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),r=zu(n,"collapsed"),[i]=this.getKeySize(t);return{...n,...e&&r,r:i/2}}getCollapsedKeySize(t){const[e,n]=Ou(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){if(!re(t.size)){const[e,n]=Ou(t.size),r=Math.sqrt(e**2+n**2)/2;return[2*r,2*r,0]}const e=this.getContentBBox(t),[n,r]=Eu(e),i=Math.sqrt(n**2+r**2)/2;return[2*i,2*i,0]}getCollapsedOriginPosition(t){return Du(t.collapsedOrigin,this.getContentBBox(t).center,this.getCollapsedKeySize(t),this.getExpandedKeySize(t),_u)}},rect:Cl},edge:{cubic:Zl,line:th,polyline:eh,quadratic:nh,"cubic-horizontal":Ql,"cubic-vertical":Jl},layout:{"antv-dagre":class{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},nm),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 Jf({tree:[]}),E=Jg(s||50,u),w=Jg(c||50,l);let x=w,M=E;"LR"!==a&&"RL"!==a||(x=E,M=w);const N=em(i,void 0),S=e.getAllNodes(),T=e.getAllEdges();let k;S.forEach((t=>{const e=N(t),n=M(t),r=e+2*x(t),i=e+2*n,o=t.data.layer;Vt(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")}))),T.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)&&(k=new Jf({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&Ng(t,i);const s=Og(t);let c;n&&(e.ranksep=Rg(s,{rankdir:o,ranksep:a}));try{c=Mg(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:k,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:c,align:o});const C=[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)}))})),C[0]=p[0]-t,C[1]=p[1]-e}const P="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+C[0],e.data.y=e.data.y+C[1],t.add(P?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=P?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=P?(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+C[0],y:e+C[1]}))),b.getNode(t.source),b.getNode(t.target),n,P,r,i))}))}let A=[];A=b.getAllNodes().map((t=>Qg(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({},Lv),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 im(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,Kg(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const E=[];let w;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)&&E.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 Jf({nodes:v,edges:E}),e=a||new Om;if(b&&Iv[e.id]){const e=v.length<100?new Rv:new um;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:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=Vt(r)?()=>r:kt(r)?r:()=>0,e.spacing=a,n)if(kt(n))o=t=>{const e=n(t),r=a(t);if(qg(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(qg(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(qg(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=Vt(i)?()=>i:qg(i)?()=>Math.max.apply(null,i):kt(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 um({}),f={center:[0,0],preventOverlap:!0,nodeSpacing:l},p=[],g=t=>{let e=(null==u?void 0:u(t))||10;return qg(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();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 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]),Vt(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 Jf(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;qg(o)?1===o.length&&(o=[o[0],o[0]]):Vt(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":$f.compactBox,"force-atlas2":class{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},U_),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 im(e,t,h);const d=i.map((t=>Qg(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Jf({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,Vt(a.size))i[o]=a.size;else if(qg(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(kt(n)){const t=n(e.getNode(o));qg(t)?i[o]=Math.max(...t):i[o]=t}else qg(n)?i[o]=Math.max(...n):Vt(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 B_(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,E=b;"linlog"===c&&(b=Math.log(1+y),E=b),s&&(b=y/g,E=y/m),a&&e<n&&y<=0?(b=0,E=0):a&&e<n&&y>0&&(b=y,E=y),i[h][0]+=b*v[0],i[d][0]-=E*v[0],i[h][1]+=b*v[1],i[d][1]-=E*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 G_({xmid:(l+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:c}),g=new V_(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(Vt(i.fx)&&Vt(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({},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: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]=sm(i,o,a),E=null==g?void 0:g.length;if(!E||1===E)return im(e,t,b);const w=(u-c)/E;let{radius:x,startRadius:M,endRadius:N}=r;if(f){const t=Jg(10,f),e=tm(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)})),x=r/(2*Math.PI)}else x||M||N?!M&&N?M=N:M&&!N&&(N=M):x=Math.min(y,v)/2;const S=w*l;let T=[];T="topology"===h?am(e,g):"topology-directed"===h?am(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(Qg(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>Qg(t)));const k=Math.ceil(E/s);for(let t=0;t<E;++t){let e=x;e||null===M||null===N||(e=M+t*(N-M)/(E-1)),e||(e=10+100*t/(E-1));let n=c+t%k*S+2*Math.PI/s*Math.floor(t/k);d||(n=u-t%k*S-2*Math.PI/s*Math.floor(t/k)),T[t].data.x=b[0]+Math.cos(n)*e,T[t].data.y=b[1]+Math.sin(n)*e}t&&T.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:T,edges:m}}))}},concentric:um,d3force:class{constructor(t={}){this.options=t,this.id="d3force",this.options=Object.assign(Object.assign({},Ty),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(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()}tick(t=1){this.forceSimulation.tick(t);const e={nodes:ky(this.lastLayoutNodes),edges:Cy(this.lastLayoutEdges)};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),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=i.map((t=>{var e,n;return Object.assign(Object.assign({},Qg(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),s=o.map((t=>Qg(t)));this.lastLayoutNodes=a,this.lastLayoutEdges=s,this.lastAssign=t,this.lastGraph=e;const{alphaMin:c,alphaDecay:u,alpha:l,nodeStrength:h,edgeStrength:d,linkDistance:f,clustering:p,clusterFociStrength:g,clusterEdgeDistance:m,clusterEdgeStrength:v,clusterNodeStrength:y,clusterNodeSize:b,collideStrength:E=1,center:w=[0,0],preventOverlap:x,nodeSize:M,nodeSpacing:N,onTick:S}=r;let{forceSimulation:T}=r;return new Promise((n=>{if(T){if(p){const t=Sy();t.nodes(a),t.links(s)}if(T.nodes(a),s){const t=Wv().id((t=>t.id)).links(s);d&&t.strength(d),f&&t.distance(f),T.force("link",t)}x&&this.overlapProcess(T,{nodeSize:M,nodeSpacing:N,collideStrength:E}),T.alpha(l).restart();const r=ky(a),i=Cy(s);t&&r.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),n({nodes:r,edges:i})}else try{const r=xy();if(h&&r.strength(h),T=wy().nodes(a),p){const t=Sy();t.centerX(w[0]).centerY(w[1]).template("force").strength(g),s&&t.links(s),a&&t.nodes(a),t.forceLinkDistance(m).forceLinkStrength(v).forceCharge(y).forceNodeSize(b),T.force("group",t)}if(T.force("center",function(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}(w[0],w[1])).force("charge",r).alpha(l).alphaDecay(u).alphaMin(c),x&&this.overlapProcess(T,{nodeSize:M,nodeSpacing:N,collideStrength:E}),s){const t=Wv().id((t=>t.id)).links(s);d&&t.strength(d),f&&t.distance(f),T.force("link",t)}T.on("tick",(()=>{const n=ky(a);null==S||S({nodes:n,edges:Cy(s)}),t&&n.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})))})).on("end",(()=>{const r=ky(a);t&&r.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),n({nodes:r,edges:Cy(s)})}))}catch(t){console.warn(t)}this.forceSimulation=T}))}))}overlapProcess(t,e){const{nodeSize:n,nodeSpacing:r,collideStrength:i}=e;let o,a;if(a=Vt(r)?()=>r:kt(r)?r:()=>0,n)if(kt(n))o=t=>n(t)+a(t);else if(qg(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)}else if(Vt(n)){const t=n/2;o=e=>t+a(e)}else o=()=>10;else o=t=>{if(t.size){if(qg(t.size)){return(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+a(t)}if(Rt(t.size)){return(t.size.width>t.size.height?t.size.width:t.size.height)/2+a(t)}return t.size/2+a(t)}return 10+a(t)};t.force("collisionForce",Gv(o).strength(i))}},dagre:F_,dendrogram:$f.dendrogram,force:Om,fruchterman:class{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},W_),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=>Qg(t,[o,a]))),g=new Jf({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]];Vt(n.x)&&(r.cx+=n.x),Vt(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(!Vt(o.x)||!Vt(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(!Vt(i.x)||!Vt(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(Vt(o.fx)&&Vt(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!Vt(o.x)||!Vt(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||!Vt(t.x)||!Vt(r.x)||!Vt(t.y)||!Vt(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(!(Vt(s.x)&&Vt(a.x)&&Vt(s.y)&&Vt(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({},H_),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 im(e,t,i);const b=m.map((t=>Qg(t)));"id"===g||zt(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)=>Vt(e.id)&&Vt(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const E=d||"undefined"==typeof window?d:window.innerWidth,w=f||"undefined"==typeof window?f:window.innerHeight,x=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(x/M.rows);else if(null==c&&null!=u)M.cols=u,M.rows=Math.ceil(x/M.cols);else{const t=Math.sqrt(x*w/E);M.rows=Math.round(t),M.cols=Math.round(E/w*t)}if(M.rows=Math.max(M.rows,1),M.cols=Math.max(M.cols,1),M.cols*M.rows>x){const t=q_(M),e=$_(M);(t-1)*e>=x?q_(M,t-1):(e-1)*t>=x&&$_(M,e-1)}else for(;M.cols*M.rows<x;){const t=q_(M),e=$_(M);(e+1)*t>=x?$_(M,e+1):q_(M,t+1)}let N=o?0:E/M.cols,S=o?0:w/M.rows;if(s||l){const t=Jg(10,l),n=tm(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;qg(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 T={},k={row:0,col:0},C={};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;Y_(T,t);)t.col++;else if(void 0===t.row)for(t.row=0;Y_(T,t);)t.row++;C[n.id]=t,X_(T,t)}Z_(n,i,N,S,C,M,k,T)}const P={nodes:b,edges:v};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P}))}},indented:$f.indented,mds:Rv,mindmap:$f.mindmap,radial:class{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},eD),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(),E=i||"undefined"==typeof window?i:window.innerWidth,w=o||"undefined"==typeof window?o:window.innerHeight,x=a||[E/2,w/2];if(!(null==y?void 0:y.length)||1===y.length)return im(e,t,x);let M=y[0];if(zt(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=iD(y,M.id),S=Yg({nodes:y,edges:b},!1),T=$g(S),k=aD(T,N);oD(T,N,k+1);const C=T[N];let P=E-x[0]>x[0]?x[0]:E-x[0],A=w-x[1]>x[1]?x[1]:w-x[1];0===P&&(P=E/2),0===A&&(A=w/2);const O=Math.min(P,A),R=Math.max(...C),_=[],D=c||O/R;C.forEach(((t,e)=>{_[e]=t*D}));const I=nD(y,T,g,_,D,p,m),L=rD(I),j=((t,e,n)=>{try{const n=Pv.mul(Pv.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 Av(n),s=Pv.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>Pv.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,F=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,F,L,I,_,N),d){z=em(u,l);const t={nodes:y,nodeSizeFunc:z,positions:F,radii:_,height:w,width:E,strictRadial:Boolean(h),focusIdx:N,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},Q_),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}})),J_(d,r,f,a,l,h),tD(r,f,s,c,u,p,o,l);return r})(e,t)}const B=[];F.forEach(((t,e)=>{const n=Qg(y[e]);n.data.x=t.x+x[0],n.data.y=t.y+x[1],B.push(n)})),t&&B.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:B,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=Xg(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=Xg(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({},sD),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:xl,ellipse:Nl,image:class t extends bl{static defaultStyleProps={size:50};constructor(e){super(ee({},{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=zu(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Vu(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*El,height:r*El,...e}}drawKeyShape(t,e){return this.upsert("key",As,this.getKeyStyle(t),e)}drawHaloShape(t,e){this.upsert("halo",Is,this.getHaloStyle(t),e)}},rect:Sl,star:class extends Ml{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)*El;return!!e&&{width:n,height:n,...e}}getPortXY(t,e){const{placement:n="top"}=e;return sh(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)}},triangle:Tl,diamond:class extends Ml{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.attributes);return il(t,[this.attributes.x,this.attributes.y],e)}},hexagon:class extends Ml{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)*El;return!!e&&{width:n,height:n,...e}}}},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)"],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:oI,light:aI},plugin:{"grid-line":LD,watermark:tI,tooltip:ZD,contextmenu:ID,toolbar:jD}},cI={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{}};function uI(t,e,n){cI[t][e]?console.error(`The extension ${e} of ${t} has been registered before.`):Object.assign(cI[t],{[e]:n})}function lI(t,e){const n=cI[t]?.[e];if(n)return n}cs.enableCSSParsing=!1,Object.entries(sI).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{uI(t,e,n)}))}));class hI{type;constructor(t){this.type=t}}class dI extends hI{data;constructor(t,e){super(t),this.data=e}}class fI extends hI{animationType;animation;data;constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class pI extends hI{data;constructor(t,e){super(t),this.data=e}}class gI extends hI{states;constructor(t,e){super(t),this.states=e}}function mI(t,e){t.emit(e.type,e)}function vI(t,e){const{datum:n,index:r,elementData:i}=e;return kt(t)?t(n,r,i):Object.fromEntries(Object.entries(t).map((([t,e])=>kt(e)?[t,e(n,r,i)]:[t,e])))}function yI(t){return t.style?.zIndex??Eh("zIndex")??0}class bI extends Sh{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 n=function(t){if(!t)return null;if(t instanceof zs)return{type:"canvas",element:t};let e=t;for(;e;){if(rh(e))return{type:"node",element:e};if(ih(e))return{type:"edge",element:e};if(oh(e))return{type:"combo",element:e};e=e.parentElement}return null}(e.target);if(!n)return;const{graph:r,canvas:i}=this.context,{type:o,element:a}=n,{type:s,detail:c,button:u}=e,l={...e,target:a,targetType:o};if(s===t.CanvasEvent.POINTER_MOVE&&(this.currentTarget!==a&&(this.currentTarget&&r.emit(`${o}:${t.CanvasEvent.POINTER_LEAVE}`,{...l,target:this.currentTarget}),a&&r.emit(`${o}:${t.CanvasEvent.POINTER_ENTER}`,l)),this.currentTarget=a),s===t.CanvasEvent.CLICK&&2===u||(r.emit(`${o}:${s}`,l),r.emit(s,l)),s===t.CanvasEvent.CLICK&&2===c&&(r.emit(`${o}:${t.CanvasEvent.DBLCLICK}`,l),r.emit(t.CanvasEvent.DBLCLICK,l)),s===t.CanvasEvent.POINTER_DOWN&&2===u){const e={...l,preventDefault:()=>{i.getContainer()?.addEventListener(t.CanvasEvent.CONTEXT_MENU,(t=>t.preventDefault()),{once:!0})}};r.emit(`${o}:${t.CanvasEvent.CONTEXT_MENU}`,e),r.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 EI(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function wI(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 xI(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,E=0;d&&ms(d)&&p&&(n=a-i,r=s-o,E=Math.atan2(r,n),m=Math.cos(E)*(p||0),v=Math.sin(E)*(p||0)),f&&ms(f)&&g&&(n=i-a,r=o-s,E=Math.atan2(r,n),y=Math.cos(E)*(g||0),b=Math.sin(E)*(g||0)),t.moveTo(i-u+m,o-h+v),t.lineTo(a-u+y,s-h+b)}function MI(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,E=0;if(c&&ms(c)&&h){var w=u(c.parentNode.getStartTangent(),2),x=w[0],M=w[1];n=x[0]-M[0],r=x[1]-M[1],E=Math.atan2(r,n),m=Math.cos(E)*(h||0),v=Math.sin(E)*(h||0)}if(l&&ms(l)&&d){var N=u(l.parentNode.getEndTangent(),2);x=N[0],M=N[1];n=x[0]-M[0],r=x[1]-M[1],E=Math.atan2(r,n),y=Math.cos(E)*(d||0),b=Math.sin(E)*(d||0)}for(var S=0;S<p.length;S++){var T=p[S],k=T[0],C=p[S+1],P=0===S&&(0!==m||0!==v),A=(S===p.length-1||C&&("M"===C[0]||"Z"===C[0]))&&0!==y&&0!==b;switch(k){case"M":P?(t.moveTo(T[1]-o+m,T[2]-s+v),t.lineTo(T[1]-o,T[2]-s)):t.moveTo(T[1]-o,T[2]-s);break;case"L":A?t.lineTo(T[1]-o+y,T[2]-s+b):t.lineTo(T[1]-o,T[2]-s);break;case"Q":t.quadraticCurveTo(T[1]-o,T[2]-s,T[3]-o,T[4]-s),A&&t.lineTo(T[3]-o+y,T[4]-s+b);break;case"C":t.bezierCurveTo(T[1]-o,T[2]-s,T[3]-o,T[4]-s,T[5]-o,T[6]-s),A&&t.lineTo(T[5]-o+y,T[6]-s+b);break;case"A":var O=g[S].arcParams,R=O.cx,_=O.cy,D=O.rx,I=O.ry,L=O.startAngle,j=O.endAngle,z=O.xRotation,F=O.sweepFlag;if(t.ellipse)t.ellipse(R-o,_-s,D,I,z,L,j,!!(1-F));else{var B=D>I?D:I,G=D>I?1:D/I,V=D>I?I/D:1;t.translate(R-o,_-s),t.rotate(z),t.scale(G,V),t.arc(0,0,B,L,j,!!(1-F)),t.scale(1/G,1/V),t.rotate(-z),t.translate(-(R-o),-(_-s))}A&&t.lineTo(T[6]-o+y,T[7]-s+b);break;case"Z":t.closePath()}}}function NI(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,E=0,w=0,x=0;c&&ms(c)&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],x=Math.atan2(r,n),y=Math.cos(x)*(l||0),b=Math.sin(x)*(l||0)),u&&ms(u)&&h&&(n=d[f-1][0]-d[0][0],r=d[f-1][1]-d[0][1],x=Math.atan2(r,n),E=Math.cos(x)*(h||0),w=Math.sin(x)*(h||0)),t.moveTo(p+(y||E),g+(b||w));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 SI(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,E=0,w=0,x=0;c&&ms(c)&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],x=Math.atan2(r,n),y=Math.cos(x)*(l||0),b=Math.sin(x)*(l||0)),u&&ms(u)&&h&&(n=d[f-2][0]-d[f-1][0],r=d[f-2][1]-d[f-1][1],x=Math.atan2(r,n),E=Math.cos(x)*(h||0),w=Math.sin(x)*(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+E,v+w)}function TI(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 Gt(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 kI=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={})[Un.CIRCLE]=EI,t[Un.ELLIPSE]=wI,t[Un.RECT]=TI,t[Un.LINE]=xI,t[Un.POLYLINE]=SI,t[Un.POLYGON]=NI,t[Un.PATH]=MI,t[Un.TEXT]=void 0,t[Un.GROUP]=void 0,t[Un.IMAGE]=void 0,t[Un.HTML]=void 0,t[Un.MESH]=void 0,t);this.context.pathGeneratorFactory=e},e.prototype.destroy=function(){delete this.context.pathGeneratorFactory},e}(qn),CI=K(),PI=K(),AI=K(),OI=b(),RI=function(){function t(){var t=this;this.isHit=function(e,n,r,i){var o=t.context.pointInPathPickerFactory[e.nodeName];if(o){var a=S(OI,r),s=ut(PI,et(AI,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 yr(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=et(CI,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=ia(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 _I(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=Mn(i,i,e.x,e.y),f=u(ca(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 DI(t,e,n,r){return t/(n*n)+e/(r*r)}function II(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(ca(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?DI(y,b,i+v,o+v)<=1:g?DI(y,b,i,o)<=1:!!m&&(DI(y,b,i-v,o-v)>=1&&DI(y,b,i+v,o+v)<=1)}function LI(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function jI(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 Mn(u.x,u.y,a,s)<=o/2}function zI(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&&Rn(t,e,n,r,o,a)<=i/2}function FI(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var a=0;a<o-1;a++){if(zI(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(zI(s[0],s[1],c[0],c[1],e,n,r))return!0}return!1}var BI=1e-6;function GI(t){return Math.abs(t)<BI?0:t<0?-1:1}function VI(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 UI(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(VI(a,s,[e,n]))return!0;GI(a[1]-n)>0!=GI(s[1]-n)>0&&GI(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(r=!r)}return r}function WI(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=UI(t[i],e,n))break}return r}function HI(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(ca(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!c)&&zI(i,o,a,s,(c||0)+(l||0),e.x+d,e.y+p)}function qI(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,E=m.polylines,w=m.polygons,x=u(ca(v,(null==w?void 0:w.length)&&h,l),2),M=x[0],N=x[1],S=qi(t),T=!1;return M||n?T=b?r(t,e):WI(w,e.x+f,e.y+g)||WI(E,e.x+f,e.y+g):((N||n)&&(T=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||LI(d.x-a,d.y-a,d.width+e,d.height+e,n,r))switch(c.command){case"L":case"Z":if(o=zI(h[0],h[1],u[0],u[1],e,n,r))return!0;break;case"Q":if(o=Gn(h[0],h[1],l[1],l[2],l[3],l[4],n,r)<=e/2)return!0;break;case"C":if(o=Ln(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=ke(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=Ln(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)),T)}function $I(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(ca(r.pointerEvents,o,i),2),g=p[0],m=!1;return(p[1]||n)&&(m=FI(c.points,(a||0)+(s||0),e.x+h,e.y+f,!0)),m||!g&&!n||(m=UI(c.points,e.x+h,e.y+f)),m}function YI(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(ca(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!i)&&FI(a.points,(i||0)+(o||0),e.x+c,e.y+h,!1)}function XI(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(ca(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 zI(t+l,e,t+n-h,e,o,a,s)||zI(t+n,e+h,t+n,e+r-d,o,a,s)||zI(t+n-d,e+r,t+f,e+r,o,a,s)||zI(t,e+r-f,t,e+l,o,a,s)||jI(t+n-h,e+h,h,Math.PI,Math.PI,o,a,s)||jI(t+n-d,e+r-d,d,0,Math.PI,o,a,s)||jI(t+f,e+r-f,f,Math.PI,Math.PI,o,a,s)||jI(t+l,e+l,l,Math.PI,Math.PI,o,a,s)}(0,0,d,f,a.map((function(t){return Gt(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?LI(0-b,0-b,d+b,f+b,e.x,e.y):g?LI(0,0,d,f,e.x,e.y):!!m&&function(t,e,n,r,i,o,a){var s=i/2;return LI(t-s,e-s,n,i,o,a)||LI(t+n-s,e-s,i,r,o,a)||LI(t+s,e+r-s,n,i,o,a)||LI(t-s,e+s,i,r,o,a)}(0,0,d,f,v,e.x,e.y)}function KI(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[Un.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 ZI=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={})[Un.CIRCLE]=_I,t[Un.ELLIPSE]=II,t[Un.RECT]=XI,t[Un.LINE]=HI,t[Un.POLYLINE]=YI,t[Un.POLYGON]=$I,t[Un.PATH]=qI,t[Un.TEXT]=function(){return!0},t[Un.GROUP]=null,t[Un.IMAGE]=KI,t[Un.HTML]=null,t[Un.MESH]=null,t);this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new RI)},e.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},e}(qn),QI=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=b(),this.dprMatrix=b(),this.tmpMat4=b(),this.vec3a=K(),this.vec3b=K(),this.vec3c=K(),this.vec3d=K()}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(qa.UNMOUNTED,p),f.addEventListener(qa.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(qa.UNMOUNTED,p),f.removeEventListener(qa.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(_(r.dprMatrix,[e,e,1]),k(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 dr;return o.setMinMax([e,n,0],[r,i,0]),o}))),!1));if(r.removedRBushNodeAABBs=[],dr.isEmpty(a))return void(r.renderQueue=[]);var c=r.convertAABB2Rect(a),h=c.x,p=c.y,g=c.width,v=c.height,y=ut(r.vec3a,[h,p,0],r.vpMatrix),b=ut(r.vec3b,[h+g,p,0],r.vpMatrix),E=ut(r.vec3c,[h,p+v,0],r.vpMatrix),w=ut(r.vec3d,[h+g,p+v,0],r.vpMatrix),x=Math.min(y[0],b[0],w[0],E[0]),M=Math.min(y[1],b[1],w[1],E[1]),N=Math.max(y[0],b[0],w[0],E[0]),S=Math.max(y[1],b[1],w[1],E[1]),T=Math.floor(x),C=Math.floor(M),P=Math.ceil(N-x),A=Math.ceil(S-M);t.save(),r.clearRect(t,T,C,P,A,i.background),t.beginPath(),t.rect(T,C,P,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 Ga(vs.DIRTY_RECTANGLE,{dirtyRect:{x:T,y:C,width:P,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)&Ua.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!==Un.LINE&&t.nodeName!==Un.PATH&&t.nodeName!==Un.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 dr;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 dr);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),Ct(s)||(t.lineDashOffset=s),Ct(o)||(t.globalAlpha*=o),Ct(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),Ct(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,C(this.tmpMat4,this.tmpMat4,this.vec3a),k(this.tmpMat4,n,this.tmpMat4),k(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(w(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,C(this.tmpMat4,this.tmpMat4,this.vec3a),k(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 dr;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),JI=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,E=!Ct(a)&&!a.isNone,w=!Ct(l)&&!l.isNone&&d>0,x=0===a.alpha,M=!(!y||!y.length),N=!Ct(m)&&v>0,S=n.nodeName,T="inner"===g,k=w&&N&&(S===Un.PATH||S===Un.LINE||S===Un.POLYLINE||x||T);E&&(t.globalAlpha=c*u,k||tL(n,t,N),this.fill(t,n,a,s,r,i,o),k||this.clearShadowAndFilter(t,M,N)),w&&(t.globalAlpha=c*h,t.lineWidth=d,Ct(b)||(t.miterLimit=b),Ct(f)||(t.lineCap=f),Ct(p)||(t.lineJoin=p),k&&(T&&(t.globalCompositeOperation="source-atop"),tL(n,t,!0),T&&(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;!Ct(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()})):(xi(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()})):(xi(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===_r.LinearGradient||t.type===_r.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 tL(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 eL=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(zt(a)?r=this.imagePool.getImageSync(a):(u||(u=a.width),l||(l=a.height),r=a),r){tL(n,t,!Ct(s)&&c>0);try{t.drawImage(r,0,0,u,l)}catch(t){}}},t}(),nL=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,E=a.dy,w=a.shadowColor,x=a.shadowBlur,M=y.font,N=y.lines,S=y.height,T=y.lineHeight,k=y.lineMetrics;t.font=M,t.lineWidth=s,t.textAlign="middle"===c?"center":c;var C=u;o.enableCSSParsing||"alphabetic"!==C||(C="bottom"),t.lineJoin=l,Ct(h)||(t.miterLimit=h);var P=0;"middle"===u?P=-S/2-T/2:"bottom"===u||"alphabetic"===u||"ideographic"===u?P=-S:"top"!==u&&"hanging"!==u||(P=-T);var A=b||0;P+=E||0,1===N.length&&("bottom"===C?(C="middle",P-=.5*S):"top"===C&&(C="middle",P+=.5*S)),t.textBaseline=C,tL(n,t,!Ct(w)&&x>0);for(var O=0;O<N.length;O++){var R=s/2+A;P+=T,Ct(f)||f.isNone||!s||this.drawLetterSpacing(t,N[O],k[O],c,R,P,d,g,m,v,!0),Ct(p)||this.drawLetterSpacing(t,N[O],k[O],c,R,P,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=!Ct(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=!Ct(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)}(JI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(JI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(JI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(JI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(JI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(JI),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(JI);var rL=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 JI(n),o=((t={})[Un.CIRCLE]=r,t[Un.ELLIPSE]=r,t[Un.RECT]=r,t[Un.IMAGE]=new eL(n),t[Un.TEXT]=new nL,t[Un.LINE]=r,t[Un.POLYLINE]=r,t[Un.POLYGON]=r,t[Un.PATH]=r,t[Un.GROUP]=void 0,t[Un.HTML]=void 0,t[Un.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new QI(e))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},e}(qn),iL=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}(),oL=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 iL)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(qn),aL=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===Un.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===Un.HTML&&r.$camera){var n=r.getOrCreateEl(e);n&&(n.remove(),c.delete(n))}},d=function(t){var e=t.target;if(e.nodeName===Un.HTML){var n=t.attrName;r.updateAttribute(n,e)}},f=function(t){var e=t.target;if(e.nodeName===Un.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(vs.RESIZE,p),s.addEventListener(qa.MOUNTED,l),s.addEventListener(qa.UNMOUNTED,h),s.addEventListener(qa.ATTR_MODIFIED,d),s.addEventListener(qa.BOUNDS_CHANGED,f)})),a.hooks.endFrame.tap(t.tag,(function(){r.$camera&&o.renderReasons.has(La.CAMERA_CHANGED)&&(r.$camera.style.transform=r.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(t.tag,(function(){r.$camera&&r.$camera.remove(),s.removeEventListener(vs.RESIZE,p),s.removeEventListener(qa.MOUNTED,l),s.removeEventListener(qa.UNMOUNTED,h),s.removeEventListener(qa.ATTR_MODIFIED,d),s.removeEventListener(qa.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;zt(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=Vt(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=Vt(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="";Mi(h)?d=h.isNone?"transparent":e.getAttribute("fill"):Array.isArray(h)?d=e.getAttribute("fill"):xi(h),n.style.background=d;break;case"stroke":var f=e.parsedStyle.stroke,p="";Mi(f)?p=f.isNone?"transparent":e.getAttribute("stroke"):Array.isArray(f)?p=e.getAttribute("stroke"):xi(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&&(Ct(e.style[t])||""===e.style[t]||(n.style[t]=e.style[t]))}},t.tag="HTMLRendering",t}(),sL=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 aL)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(qn),cL=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):ea&&(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;zt(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?Vo(po(u),new Ns({})):M(b()),l&&P(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===_r.LinearGradient){var d=function(t,e,n){var r=tr(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===_r.RadialGradient){var v=function(t,e,n,r,i){var o=n.value,a=r.value;n.unit===xr.kPercentage&&(o=n.value/100*t),r.unit===xr.kPercentage&&(a=r.value/100*e);var s=Math.max(Re([0,0],[o,a]),Re([0,e],[o,a]),Re([t,e],[o,a]),Re([t,0],[o,a]));return i&&(i instanceof Yr?s=i.value:i instanceof Br&&("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(Re([0,0],[o,a]),Re([0,e],[o,a]),Re([t,e],[o,a]),Re([t,0],[o,a]))))),{x:o,y:a,r:s}}(o,a,c,u,l),y=v.x,b=v.y,E=v.r;h=e.createRadialGradient(y,b,0,y,b,E)}return h&&(i.forEach((function(t){var e=t.offset,n=t.color;e.unit===xr.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 zt(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),uL=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===Un.IMAGE){var s=o.img,c=o.keepAspectRatio;zt(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===Un.IMAGE&&"img"===r&&zt(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(qa.MOUNTED,s),o.addEventListener(qa.ATTR_MODIFIED,c)})),n.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(qa.MOUNTED,s),o.removeEventListener(qa.ATTR_MODIFIED,c)}))},t.tag="LoadImage",t}(),lL=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 cL(this.context.config),this.addRenderingPlugin(new uL)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(qn),hL=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=zt(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||ea&&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){ea&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add(La.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}(),dL=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=hL},e.prototype.destroy=function(){delete this.context.ContextService},e}(qn),fL=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new dL),n.registerPlugin(new lL),n.registerPlugin(new kI),n.registerPlugin(new rL),n.registerPlugin(new oL),n.registerPlugin(new ZI),n.registerPlugin(new sL),n}return r(e,t),e}($n),pL=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=Re([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}(),gL=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 pL(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}(qn);class mL{config;background;main;label;transient;transientLabel;get canvas(){return{main:this.main,label:this.label,transient:this.transient,transientLabel:this.transientLabel,background:this.background}}get document(){return this.main.document}renderers;constructor(t){this.config=t}async init(){if(Object.entries(this.canvas).every((([,t])=>!t))){const{renderer:t,background:e,...n}=this.config,r=["main","label","transient","transientLabel","background"],{renderers:i,canvas:o}=r.reduce(((e,r)=>{const i=kt(t)?t?.(r):new fL;i.registerPlugin(new gL({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})),"main"!==r&&i.unregisterPlugin(i.getPlugin("dom-interaction"));const o=new Xs({renderer:i,supportsMutipleCanvasesInOneContainer:!0,...n});return e.renderers[r]=i,e.canvas[r]=o,this[r]=o,e}),{renderers:{},canvas:{}});this.renderers=i,Object.entries(o).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")}))}return this.setBackground(),Promise.all(Object.values(this.canvas).map((t=>t.ready)))}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();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 Mu(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 zt(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,{width:n,height:r,renderer:i}=this.config,o=qe('<div id="virtual-image"></div>'),a=new Xs({width:n,height:r,renderer:i?.("main")||new fL,devicePixelRatio:e,container:o,background:this.background.getConfig().background});await a.ready,a.appendChild(this.background.getRoot().cloneNode(!0)),a.appendChild(this.main.getRoot().cloneNode(!0));const s=this.label.getRoot().cloneNode(!0),c=a.viewport2Canvas({x:0,y:0}),u=this.main.viewport2Canvas({x:0,y:0});s.translate([u.x-c.x,u.y-c.y]),s.scale(1/this.main.getCamera().getZoom()),a.appendChild(s),a.appendChild(this.transient.getRoot().cloneNode(!0));const l=this.main.getCamera(),h=a.getCamera();h.setZoom(l.getZoom()),h.setPosition(l.getPosition()),h.setFocalPoint(l.getFocalPoint());return a.getContextService().toDataURL(t)}destroy(){this.config={},this.renderers={},Object.entries(this.canvas).forEach((([t,e])=>{const n=e.getCamera();n.landmarks?.length&&n.cancelLandmarkAnimation(),e.destroy(),this[t]=void 0}))}}function vL(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 yL(t){const{data:e,style:n,...r}=t,i=r;return e&&(i.data={...e}),n&&(i.style={...n}),i}function bL(t){const{id:e=Iu(t),style:n,data:r,...i}=t,o={...t,style:{...n},data:{...r}};return pu(t)?{id:e,data:o,...i}:{id:e,data:o}}function EL(t){return t.data}class wL{model;latestRemovedComboIds=new Set;comboIds=new Set;changes=[];batchCount=0;isTraceless=!1;constructor(){this.model=new Jf}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===iu.NodeUpdated||e===iu.EdgeUpdated||e===iu.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:yL(n),original:yL(r),type:e})}else this.changes.push({value:yL(t.value),type:e})}getChanges(){const t=this.changes;return this.changes=[],t}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=EL(n);return this.isCombo(Iu(r))||(void 0===t||t.includes(Iu(r)))&&e.push(r),e}),[])}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=EL(n);return(void 0===t||t.includes(Iu(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=EL(n);return this.isCombo(Iu(r))?((void 0===t||t.includes(Iu(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(EL):[]}getDescendantsData(t){const e=this.getElementsData([t])[0],n=[];return Dh(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(Iu(t))),"TB"),n}getParentData(t,e=this.inferStructureKey(t)){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?EL(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?fu:du,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(EL):[]}inferStructureKey(t){if(this.isCombo(t))return du}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=EL(n);return t?t.includes(Iu(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(EL)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(EL)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i=[],edges:o=[],combos:a=[]}=this.getData(),s=Nh(i,e,(t=>Iu(t))),c=Nh(o,n,(t=>Iu(t))),u=Nh(a,r,(t=>Iu(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(Iu),edges:c.exit.map(Iu),combos:u.exit.map(Iu)})}))}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:iu.NodeAdded}),bL(t))))),this.updateNodeLikeHierarchy(t))}addEdgeData(t=[]){t.length&&this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:iu.EdgeAdded}),bL(t)))))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(du)||e.attachTreeStructure(du),e.addNodes(t.map((t=>(this.comboIds.add(Iu(t)),this.pushChange({value:t,type:iu.ComboAdded}),bL(t))))),this.updateNodeLikeHierarchy(t)}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=Iu(t);e.attachTreeStructure(du),this.setParent(n,Lu(t),du);const r=t?.style?.children;void 0!==r&&(e.attachTreeStructure(fu),r.forEach((t=>{this.setParent(t,n,fu)})))}))}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=Iu(t),i=EL(e.getNode(r));if(ie(i,t))return;const o=vL(i,t);this.pushChange({value:o,original:i,type:iu.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}syncNodeDatum(t){const{model:e}=this,n=Iu(t),r=vL(EL(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=Iu(t),r=EL(e.getEdge(n));if(ie(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=vL(r,t);e.mergeEdgeData(n,i),this.pushChange({value:i,original:r,type:iu.EdgeUpdated})}))}))}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=Iu(t),i=EL(e.getNode(r));if(ie(i,t))return;const o=vL(i,t);this.pushChange({value:o,original:i,type:iu.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}setParent(t,e,n,r=!0){if(t===e)return;const i=Lu(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,du);e&&this.pushChange({value:e,original:e,type:iu.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:iu.ComboUpdated})}))}syncComboDatum(t){const{model:e}=this,n=Iu(t),r=vL(EL(e.getNode(n)),t);e.mergeNodeData(n,r)}getElementPosition(t){return ku(this.getElementsData([t])[0])}translateNodeBy(t,e){const n=Vu(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&&Dh(o,(t=>{const e=Iu(t),[o,a,s]=ku(t),c=vL(t,{style:{x:o+n,y:a+r,z:s+i}});this.pushChange({value:c,original:t,type:this.isCombo(e)?iu.ComboUpdated:iu.NodeUpdated}),this.model.mergeNodeData(e,c)}),(t=>this.getChildrenData(Iu(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]=ku(o),u=n-a,l=r-s,h=i-c;Dh(o,(t=>{const e=Iu(t),[n,r,i]=ku(t),o=vL(t,{style:{x:n+u,y:r+l,z:i+h}});this.pushChange({value:o,original:t,type:this.isCombo(e)?iu.ComboUpdated:iu.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(Iu(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(Iu)),this.pushChange({value:this.getNodeData([t])[0],type:iu.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:iu.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:iu.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(du)){const e=Lu(this.getNodeLikeData([t])[0]);this.setParent(t,void 0,du,!1),this.model.getChildren(t,du).forEach((t=>{const n=EL(t),r=Iu(n);this.setParent(Iu(n),e,du,!1);const i=vL(n,{id:Iu(n),style:{parentId:e}});this.pushChange({value:i,original:n,type:this.isCombo(r)?iu.ComboUpdated:iu.NodeUpdated}),this.model.mergeNodeData(Iu(n),i)})),Zt(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,du).map(Iu)];e=this.getComboData().filter((t=>{const e=Iu(t),r=this.getAncestorsData(e,du),i=r.map(Iu);return!r.some((t=>!!t.style?.collapsed))&&!n.includes(e)&&!i.includes(e)}))}else e=this.getNodeData().filter((e=>Iu(e)!==t));return Math.max(0,...e.map(yI))+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 xL{context;container;elementMap={};shapeTypeMap={};constructor(t){this.context=t}init(){const{canvas:t}=this.context;this.container||(this.container={node:t.appendChild(new Cs({style:{zIndex:2}})),edge:t.appendChild(new Cs({style:{zIndex:1}})),combo:t.appendChild(new Cs({style:{zIndex:0}}))})}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}forEachElementData(t){wl.forEach((e=>{const n=this.context.model.getElementData(e);t(e,n)}))}getTheme(t){const{theme:e}=this.context.options;if(!e)return{};const n=lI("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({},Ku(this.getTheme(e)?.palette),Ku(t[e]?.palette));!re(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=zt(r)?lI("palette",r):r;if(kt(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)=>zt(t)?e.data?.[t]:t?.(e);if("group"===n){const e=Bt(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[Iu(e)]=n[t]}))})),r}if("value"===n){const[e,n]=t.reduce((([t,e],n)=>{const r=s(i,n);if(!Vt(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={};computedElementDefaultStyle(t,e){const{options:n}=this.context,r=n[t]?.style||{};this.defaultStyle[Iu(e.datum)]=vI(r,e)}computeElementsDefaultStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Iu(e)))).forEach(((t,r)=>{this.computedElementDefaultStyle(e,{datum:t,index:r,elementData:n})}))}))}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 vI(r[t]?.state?.[e]||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Iu(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(Iu(e)))).forEach(((t,r)=>{const i=this.getElementState(Iu(t));this.computeElementStatesStyle(e,i,{datum:t,index:r,elementData:n})}))}))}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)=>Mh(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=Iu(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(Iu(t)))).filter(Boolean);Object.assign(u,{childrenNode:e,childrenData:t})}return u.type||(u.type={node:"circle",edge:"line",combo:"circle"}[t]),u}async draw(e={animation:!0}){const n=this.computeDrawData();if(!n)return;this.init(),this.computeStyle();const{add:r,update:i,remove:o}=n,a=this.getDestroyTasks(o,e),s=this.getCreateTasks(r,e),c=this.getUpdateTasks(i,e);await(function(t,e={}){if(0===t.length)return null;const{before:n,...r}=e;e.before?.();const i=yh(t.map((t=>t())).map((t=>t())).flat().filter(Boolean));return wh(i,r),i}([...a,...s,...c],e.silence?{}:{before:()=>this.emit(new dI(t.GraphEvent.BEFORE_DRAW)),beforeAnimate:e=>this.emit(new fI(t.GraphEvent.BEFORE_ANIMATE,ou.DRAW,e,n)),afterAnimate:e=>this.emit(new fI(t.GraphEvent.AFTER_ANIMATE,ou.DRAW,e,n)),after:()=>this.emit(new dI(t.GraphEvent.AFTER_DRAW))})?.finished)}computeDrawData(){const{model:t}=this.context,e=function(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=Iu(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())]}(t.getChanges());if(0===e.length)return null;const{NodeAdded:n=[],NodeUpdated:r=[],NodeRemoved:i=[],EdgeAdded:o=[],EdgeUpdated:a=[],EdgeRemoved:s=[],ComboAdded:c=[],ComboUpdated:u=[],ComboRemoved:l=[]}=Bt(e,(t=>t.type)),h=t=>new Map(t.map((t=>{const e=t.value;return[Iu(e),e]}))),d={add:{nodes:h(n),edges:h(o),combos:h(c)},update:{nodes:h(r),edges:h(a),combos:h(u)},remove:{nodes:h(i),edges:h(s),combos:h(l)}},f=[this.updateRelatedEdgeFlow,this.arrangeDrawOrderFlow,this.collapseExpandFlow].reduce(((t,e)=>e(t)),d);return f}updateRelatedEdgeFlow=t=>{const{model:e}=this.context,{update:{nodes:n,edges:r,combos:i}}=t,o=(t,n)=>{e.getRelatedEdgesData(n).forEach((t=>r.set(Iu(t),t)))};return n.forEach(o),i.forEach(o),t};arrangeDrawOrderFlow=t=>{const{model:e}=this.context,n=t.add.combos,r=[];return n.forEach(((t,n)=>{const i=e.getAncestorsData(n,"combo").map((t=>Iu(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};collapseExpandFlow=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(Iu(r),r):n[i].delete(Iu(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(Iu),{internal:u,external:l}=$l(c,(t=>e.getRelatedEdgesData(t)));s.forEach((t=>{const n=Iu(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=Iu(t),i=c.includes(t.source)?"source":"target",o={...t,[i]:Iu(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(Iu),{edges:a}=$l(r,(t=>e.getRelatedEdgesData(t)));[...n,...a].forEach((t=>{const n=Iu(t),r=e.getElementType(n),a=this.getElement(n);i(a?"update":"add",r,t),"combo"===r&&o.push([n,t])}))}}return t};createElement(t,e,n){const{animator:r}=n,i=Iu(e);if(this.getElement(i))return()=>null;const{type:o,...a}=this.getElementComputedStyle(t,e),s=lI(t,o);if(!s)return()=>null;const c=this.container[t].appendChild(new s({id:i,style:{context:this.context,...a}}));return this.shapeTypeMap[i]=o,this.elementMap[i]=c,()=>r?.(i,c,{...c.attributes,opacity:0})||null}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");n.forEach((n=>o.push((()=>this.createElement(t,n,{...e,animator:r})))))})),o}latestElementVisibilityMap=new WeakMap;updateElement(t,e,n){const{animator:r}=n,i=Iu(e),o=this.getElement(i);if(!o)return()=>null;const{type:a,...s}=this.getElementComputedStyle(t,e);if(this.shapeTypeMap[i]!==a)return()=>(this.destroyElement(e,{...n,animation:!1})(),this.createElement(t,e,{...n,animation:!1})(),null);if("visibility"===n.stage&&"visibility"in s){dl(o,"opacity")||ll(o,"opacity");const t=hl(o,"opacity")??Eh("opacity");if(this.latestElementVisibilityMap.set(o,s.visibility),"hidden"!==s.visibility)return vh(o,{visibility:"visible"}),()=>r?.(i,o,{...o.attributes,opacity:0},{opacity:t})||null;if("hidden"===s.visibility)return()=>wh(r?.(i,o,{...o.attributes,opacity:t},{opacity:0})||null,{after:()=>vh(o,{visibility:this.latestElementVisibilityMap.get(o)})})}const c={...o.attributes};return vh(o,s),()=>r?.(i,o,c)||null}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(t,e){const{animator:n}=e,r=Iu(t),i=this.elementMap[r];return i?()=>{const t=n?.(r,i,{...i.attributes},{opacity:0})||null;return wh(t,{after:()=>{this.clearElement(r),i.destroy()}}),t}:()=>null}getDestroyTasks(t,e){const{nodes:n,edges:r,combos:i}=t,o=[["combo",i],["edge",r],["node",n]],{animation:a,stage:s}=e,c=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"exit",a);n.forEach((t=>c.push((()=>this.destroyElement(t,{...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}}function ML(t){return Vt(t.x)&&Vt(t.y)}class NL{context;supervisor;instance;animationResult;get presetOptions(){return{animation:!!xh(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.context=t}async presetLayout(t,e){if(!e)return;if(e.type)return this.stepLayout(t,e);const n=t.getAllNodes().reduce(((e,n)=>{if(!ML(n.data)){let r=[0,0,0],i=0;t.getNeighbors(n.id).forEach((t=>{if(ML(t.data)){const{x:e,y:n,z:o=0}=t.data;r=Vu(r,[e,n,o]),i++}})),i&&e.push({id:n.id,data:{x:r[0]/i,y:r[1]/i,z:r[2]/i}})}return e}),[]);this.updateElementPosition({nodes:n,edges:[]},!1)}async layout(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;mI(n,new dI(t.GraphEvent.BEFORE_LAYOUT));for(const t of e){const{presetLayout:e}=t,n=this.getLayoutDataModel(t);await this.presetLayout(n,e);const r=await this.stepLayout(n,{...this.presetOptions,...t});t.animation||this.updateElementPosition(r,!1)}mI(n,new dI(t.GraphEvent.AFTER_LAYOUT))}async stepLayout(t,e){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?await this.treeLayout(t,e):await this.graphLayout(t,e)}async graphLayout(t,e){const{animation:n,enableWorker:r,iterations:i=300}=e,o=this.initGraphLayout(t,e);if(this.instance=o,r)return this.supervisor=new PD(t,o,{iterations:i}),await this.supervisor.execute();if(cD(o))return n?await o.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(o.execute(t),o.stop(),o.tick(i));const a=await o.execute(t);return n&&this.updateElementPosition(a,n),a}async treeLayout(t,e){const{type:n,animation:r}=e,i=lI("layout",n);if(!i)throw new Error(`The layout type ${n} is not found`);!function(t){if(t.hasTreeStructure(fu))return;t.attachTreeStructure(fu);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,fu)}}(t);const o={nodes:[],edges:[]};return t.getRoots(fu).forEach((n=>{Dh(n,(e=>{e.children=t.getSuccessors(e.id)}),(e=>t.getSuccessors(e.id)),"TB");Dh(i(n,e),(t=>{const{id:e,x:n,y:r}=t;o.nodes.push({id:e,data:{x:n,y:r}})}),(t=>t.children),"TB")})),r&&this.updateElementPosition(o,r),o}stopLayout(){this.instance&&cD(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 Jf;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"!==oe(t,["style","visibility"])}(i[t.id])))).map((t=>{const{id:e}=t,n={id:e};return!!o[e]?Object.assign(n,{data:{...SL(o[e].attributes),_isCombo:!0}}):Object.assign(n,{data:SL(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:SL(a[e].attributes)}})),d=new Jf({nodes:u,edges:h});return e.model.hasTreeStructure(du)&&(d.attachTreeStructure(du),u.forEach((t=>{const n=e.model.getParent(t.id,du);n&&d.hasNode(n.id)&&d.setParent(t.id,n.id,du)}))),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(...Ou(r))}),f=lI("layout",i);if(!f)throw new Error(`The layout type ${i} is not found`);const p={nodeSize:d,width:u,height:l,center:h,...c};return"force"===i?Object.assign(p,{getMass:n=>{const{id:r}=n,{getMass:i}=e;if(i)return i(n);const{mass:o}=n.data;return Vt(o)?o:ML(t.getNode(r).data)||ML(n.data)?10:1}}):"dagre"===i&&Object.assign(p,{preset:[]}),new f(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(Zu)}})})),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.animationResult=void 0}}const SL=t=>Object.entries(t).reduce(((t,[e,n])=>(["function","object"].includes(typeof n)||["x","y","z"].includes(e)||(t[e]=n),t)),{});class TL extends Sh{category="plugin";constructor(t){super(t),this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}}class kL{context;get padding(){return vu(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=xh(this.context.options,t);return!!e&&function(t,e){if(null===t||!It(t))return{};var n={};return _t(e,(function(e){se.call(t,e)&&(n[e]=t[e])})),n}({...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=Hu([-o,-a],e);return"relative"===r?h:Vu([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=Hu([-c,-u,-l],i);return"relative"===n?{position:Vu(o,h),focalPoint:Vu(a,h)}:{position:Vu(s,h),focalPoint:Vu(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 Gt("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(),mI(i,new pI(t.GraphEvent.BEFORE_TRANSFORM,e));const u=this.getAnimation(n);if(u){const n={};return o&&Object.assign(n,this.getAnimationTranslateArgs(e)),Vt(a)&&Object.assign(n,this.getAnimationRotateArgs(e)),Vt(s)&&Object.assign(n,{zoom:this.getZoomArgs(e)}),mI(i,new fI(t.GraphEvent.BEFORE_ANIMATE,ou.TRANSFORM,null,e)),new Promise((r=>{this.camera.gotoLandmark(this.createLandmark(n),{...u,onfinish:()=>{mI(i,new fI(t.GraphEvent.AFTER_ANIMATE,ou.TRANSFORM,null,e)),mI(i,new pI(t.GraphEvent.AFTER_TRANSFORM,e)),r()}})}))}if(o&&r.pan(...this.getTranslateArgs(e)),Vt(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(Vt(s)){const t=this.getZoomArgs(e);r.setZoomByViewportPoint(t,c)}mI(i,new pI(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]=Eu(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:Vu(Uu(this.getCanvasCenter(),this.getBBoxInViewport(d).center),b?Hu(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=Mu(t.map((t=>n.getElement(t).getRenderBounds())));await this.focus(r,e)}async focus(t,e){const{center:n}=this.getBBoxInViewport(t),r=Uu(this.getCanvasCenter(),n);await this.transform({mode:"relative",translate:Vu(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 dr;return c.setMinMax([i,o,0],[a,s,0]),c}cancelAnimation(){this.camera.landmarks?.length&&this.camera.cancelLandmarkAnimation()}}class CL extends Yf{options;static defaultOptions={autoResize:!1,width:800,height:600,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};destroyed=!1;context={model:new wL};constructor(t){super(),this.options=Object.assign({},CL.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,theme:d,plugins:f,width:p,zoomRange:g,zoom:m}=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),d&&this.setTheme(d),f&&this.setPlugins(f),(Vt(p)||Vt(c))&&this.setSize(p??this.options.width??0,c??this.options.height??0),g&&(this.options.zoomRange=g),Vt(m)&&(this.options.zoom=m),Vt(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=kt(t)?t(this.getTheme()):t;const{background:e}=lI("theme",this.options.theme)||{};e&&!this.options.background&&this.setBackground(e)}setLayout(t){this.options.layout=kt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){this.options.behaviors=kt(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=kt(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||[]}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(kt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(kt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(kt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(kt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(kt(t)?t(this.getComboData()):t)}updateData(t){this.context.model.updateData(kt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(kt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(kt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(kt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(kt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(kt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(kt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(kt(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)}createCanvas(){if(this.context.canvas)return this.context.canvas;const{container:t="container",width:e,height:n,renderer:r,background:i}=this.options;if(t instanceof mL)this.context.canvas=t,t.setBackground(i);else{const i=zt(t)?document.getElementById(t):t;this.context.canvas=new mL({container:i,width:e,height:n,renderer:r})}return this.context.canvas}createRuntime(){this.context.options=this.options,this.context.plugin||(this.context.plugin=new TL(this.context)),this.context.viewport||(this.context.viewport=new kL(this.context)),this.context.element||(this.context.element=new xL(this.context)),this.context.layout||(this.context.layout=new NL(this.context)),this.context.behavior||(this.context.behavior=new bI(this.context))}async prepare(){if(this.destroyed)throw new Error("Graph has been destroyed");await this.createCanvas().init(),this.createRuntime()}async render(){mI(this,new dI(t.GraphEvent.BEFORE_RENDER)),await this.prepare(),await Promise.all([this.context.element?.draw(),this.context.layout?.layout()]),await this.autoFit(),mI(this,new dI(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]:RD(this.context.canvas.getContainer());ie(r,this.getSize())||(mI(this,new dI(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:r})),this.context.canvas.resize(...r),mI(this,new dI(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(zt(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 Uu([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 ce(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,du).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Iu(i))].filter((t=>n.isCombo(Iu(t)))),a=e-yI(i);o.forEach((t=>{r[Iu(t)]=yI(t)+a}))}else r[t]=e})),await this.setElementZIndex(r)}getElementZIndex(t){return yI(this.context.model.getElementsData([t])[0])}async setElementState(e,n,r=!0){const[i,o]=Rt(e)?[e,n??!0]:[{[e]:n},r];mI(this,new gI(t.GraphEvent.BEFORE_ELEMENT_STATE_CHANGE,i));const a={nodes:[],edges:[],combos:[]};Object.entries(i).forEach((([t,e])=>{const n=this.getElementType(t);a[`${n}s`].push({id:t,style:{states:Array.isArray(e)?e:[e]}})})),this.updateData(a),await this.context.element.draw({animation:o}),mI(this,new gI(t.GraphEvent.AFTER_ELEMENT_STATE_CHANGE,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 Zu(this.context.canvas.viewport2Canvas(Qu(t)))}getViewportByCanvas(t){return Zu(this.context.canvas.canvas2Viewport(Qu(t)))}getClientByCanvas(t){const e=this.context.canvas.canvas2Viewport(Qu(t));return Zu(this.context.canvas.viewport2Canvas(e))}getCanvasByClient(t){const e=this.context.canvas.client2Viewport(Qu(t));return Zu(this.context.canvas.viewport2Canvas(e))}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}onResize=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)}}((()=>{this.resize()}),300)}const PL={idOf:Iu,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 Dh(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:zu,omitStyleProps:Bu},AL={dark:oI,light:aI};t.BaseBehavior=kh,t.BaseCombo=kl,t.BaseEdge=Kl,t.BaseNode=bl,t.BasePlugin=AD,t.BaseShape=gl,t.ComboEvent=t.NodeEvent,t.Graph=CL,t.Theme=AL,t.Utils=PL,t.getExtension=lI,t.getExtensions=function(t){return cI[t]},t.register=uI,t.version="5.0.0"}));
6
+ */const wL=Symbol("Comlink.proxy"),xL=Symbol("Comlink.endpoint"),ML=Symbol("Comlink.releaseProxy"),NL=Symbol("Comlink.finalizer"),SL=Symbol("Comlink.thrown"),CL=t=>"object"==typeof t&&null!==t||"function"==typeof t,kL=new Map([["proxy",{canHandle:t=>CL(t)&&t[wL],serialize(t){const{port1:e,port2:n}=new MessageChannel;return TL(t,e),[n,[n]]},deserialize:t=>(t.start(),AL(t))}],["throw",{canHandle:t=>CL(t)&&SL 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 TL(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(BL);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]]=BL(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,u);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[wL]:!0})}(new n(...u));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;TL(t,n),c=function(t,e){return jL.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[SL]:0}}Promise.resolve(c).catch((t=>({value:t,[SL]:0}))).then((n=>{const[i,s]=zL(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),PL(e),NL in t&&"function"==typeof t[NL]&&t[NL]())})).catch((t=>{const[n,r]=zL({value:new TypeError("Unserializable return value"),[SL]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function PL(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function AL(t,e){return DL(t,[],e)}function OL(t){if(t)throw new Error("Proxy has been released and is not useable")}function _L(t){return FL(t,{type:"RELEASE"}).then((()=>{PL(t)}))}const RL=new WeakMap,LL="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(RL.get(t)||0)-1;RL.set(t,e),0===e&&_L(t)}));function DL(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(OL(r),o===ML)return()=>{!function(t){LL&&LL.unregister(t)}(i),_L(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=FL(t,{type:"GET",path:e.map((t=>t.toString()))}).then(BL);return n.then.bind(n)}return DL(t,[...e,o])},set(n,i,o){OL(r);const[a,s]=zL(o);return FL(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(BL)},apply(n,i,o){OL(r);const a=e[e.length-1];if(a===xL)return FL(t,{type:"ENDPOINT"}).then(BL);if("bind"===a)return DL(t,e.slice(0,-1));const[s,u]=IL(o);return FL(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},u).then(BL)},construct(n,i){OL(r);const[o,a]=IL(i);return FL(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(BL)}});return function(t,e){const n=(RL.get(e)||0)+1;RL.set(e,n),LL&&LL.register(t,e,t)}(i,t),i}function IL(t){const e=t.map(zL);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const jL=new WeakMap;function zL(t){for(const[e,n]of kL)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},jL.get(t)||[]]}function BL(t){switch(t.type){case"HANDLER":return kL.get(t.name).deserialize(t.value);case"RAW":return t.value}}function FL(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 GL extends ap{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=AL(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=>{Tt(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[ML]()}isRunning(){return this.running}}class VL extends Ih{}const WL=t=>t?parseInt(t):0;function UL(t){let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||WL(e.width),r=t.clientHeight||WL(e.height);return[n-(WL(e.paddingLeft)+WL(e.paddingRight)),r-(WL(e.paddingTop)+WL(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 HL(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 qL(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 $L extends VL{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=HL("contextmenu",!1);constructor(t,e){super(t,Object.assign({},$L.defaultOptions,e));this.context.canvas.getContainer().appendChild(this.$element),qL("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 YL extends VL{static defaultOptions={lineWidth:1,border:!0,borderLineWidth:1,borderStroke:"#0001",borderStyle:"solid",stroke:"#0001",size:20,tickCount:4,tickStrokeOpacity:.5};$element=HL("grid-line");offset=[0,0];constructor(t,e){super(t,Object.assign({},YL.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))}($c(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 KL(t,e){e(t),t.children&&t.children.forEach((function(t){t&&KL(t,e)}))}function XL(t){ZL(t,!1)}function ZL(t,e){var n=e?"visible":"hidden";KL(t,(function(t){t.attr("visibility",n)}))}var QL=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.addEventListener(Xa.INSERTED,(function(){XL(r)})),r}return r(e,t),e}(_s);function JL(t){var e=t.appendChild(new QL({class:"offscreen"}));return XL(e),e}var tD=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=JL(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(Fs),eD=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 nD,rD=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},iD=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?It(s)?(It(t[a])||(u[a]={}),n<r?iD(t[a],s,n+1,r):u[a]=e[a]):_t(s)?(u[a]=[],u[a]=u[a].concat(s)):u[a]=s:u[a]=s)}))},oD=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)iD(t,e[r]);return t};!function(t,e,n){if(void 0===n&&(n=128),!Tt(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 nD||(nD=ds.offscreenCanvasCreator.getOrCreateContext(void 0)),nD.font=[o,a,i,"".concat(n,"px"),r].join(" "),nD.measureText(t).width}),(function(t,e){return[t,Object.values(e||aD(t)).join()].join("")}),4096);var aD=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 sD(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 uD(t){return"function"==typeof t?t():Bt(t)||Wt(t)?new tD({style:{text:String(t)}}):t}function cD(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 lD(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 eD(e,n,r-e,i-n)}var hD=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],v=g[1],y=e.map((function(t){var e,n=t.width,r=t.height,i=c([m,v],2),o=i[0],a=i[1];return e=c([m+n*p[0],v+r*p[1]],2),m=e[0],v=e[1],new eD(o,a,n,r)})),b=lD(y),E={"flex-start":0,"flex-end":d?r-b.width:i-b.height,center:d?(r-b.width)/2:(i-b.height)/2},w=y.map((function(t){var e=t.x,n=t.y,r=eD.fromRect(t);return r.x=d?e+E[u]:e,r.y=d?n:n+E[u],r}));lD(w);var x=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=eD.fromRect(t);return r.x=d?e:e+x(r),r.y=d?n+x(r):n,r})),N=M.map((function(e){var n,r,i=eD.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},dD=function(t,e,n){return[]};function fD(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 pD=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]}))),v=(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),y=0;y<t.length;y++){var b=t[y],E=e(b,y),w=r(b,y);if(g.has(E))(S=g.get(E)).__data__=b,S.__facet__=!1,h.push(S),d.delete(S),g.delete(E);else if(m.has(E)){(S=m.get(E)).__data__=b,S.__facet__=!0,h.push(S),m.delete(E)}else if(v.has(E)){var x=v.get(E);f.push([b,x]);try{for(var M=(i=void 0,u(x)),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(E)}else if(g.has(w)){(S=g.get(w)).__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([],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:_s,rect:Bs,circle:Ps,path:Is,text:tD,ellipse:Os,image:Ls,line:Ds,polygon:js,polyline:zs,html:Rs},t}();function gD(t){return new pD([t],null,t,t.ownerDocument)}function mD(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 vD(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function yD(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 bD=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function ED(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(bD(o,"show")&&bD(yD(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(vD(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(vD(e)),"")]=a;else if(!bD(o,"show")&&bD(o,e)!==n){var s=yD(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function wD(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 xD(){ZL(this,"hidden"!==this.attributes.visibility)}var MD=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,oD({},{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=JL(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&&xD.call(this)},e.prototype.update=function(t,e){var n;return this.attr(oD({},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}(As),ND=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"]]},SD=ND,CD=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},kD=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},TD=kD;var PD=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function AD(t){var e=function(t){var e="default";if(Rt(t)&&t instanceof Image)e="image";else if(Tt(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 OD=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,u=void 0===s?16:s,c=o(r,["symbol","size"]),l=AD(a);cD(!!l,gD(n),(function(t){t.maybeAppendByClassName("marker",l).attr("className","marker ".concat(l,"-marker")).call((function(t){if("image"===l){var n=2*u;t.styles({img:a,width:n,height:n,x:-u,y:-u})}else{n=u/2;var r=Tt(a)?a:e.getSymbol(a);t.styles(i({path:null==r?void 0:r(0,0,n)},c))}}))}))},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}(MD);OD.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]]})),OD.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),OD.registerSymbol("line",CD),OD.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),OD.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]]})),OD.registerSymbol("circle",ND),OD.registerSymbol("point",SD),OD.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"]]})),OD.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"]]})),OD.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"]]})),OD.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),OD.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"]]})),OD.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"]]})),OD.registerSymbol("line",CD),OD.registerSymbol("dot",kD),OD.registerSymbol("dash",TD),OD.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]]})),OD.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]]})),OD.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]]})),OD.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]]})),OD.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 _D=rD({text:"text"},"title");function RD(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function LD(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 DD=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(_D.text.class);if(!a)return new eD(0,0,+e,+n);var s=a.getBBox(),u=s.width,l=s.height,h=c(mD(i),4),d=h[0],f=h[1],p=h[2],g=h[3],m=c([0,0,+e,+n],4),v=m[0],y=m[1],b=m[2],E=m[3],w=RD(r);if(w.includes("i"))return new eD(v,y,b,E);w.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=c(0===r?[l+p,+n-l-p]:[0,+n],2),y=i[0],E=i[1]),"r"===t&&(o=c([+e-u-g],1),b=o[0]),"b"===t&&(a=c([+n-l-d],1),E=a[0]),"l"===t&&(s=c(0===r?[u+f,+e-u-f]:[0,+e],2),v=s[0],b=s[1])}));var x=c(mD(o),4),M=x[0],N=x[1],S=x[2],C=x[3],k=c([C+N,M+S],2),T=k[0],P=k[1];return new eD(v+C,y+M,b-T,E-P)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new eD(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(wD(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=RD(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;cD(!!r.text,gD(e),(function(t){n.title=t.maybeAppendByClassName(_D.text,"text").styles(i).call(LD,{x:s,y:u,textAlign:l,textBaseline:h}).node()}))},e}(MD),ID=rD({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"),jD=function(t){function e(e){var n=t.call(this,e,{animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonPath:PD(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 _s({class:ID.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new _s({class:ID.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=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 eD(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,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(ID.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)?ZL(e,!0):XL(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(),v=m.width,y=m.height,b=Math.max(p,u,v),E="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,y+a]],textAlign:"center"},w=c(E.offset,3),x=c(w[0],2),M=x[0],N=x[1],S=c(w[1],2),C=S[0],k=S[1],T=c(w[2],2),P=T[0],A=T[1],O=E.textAlign,_=r.querySelector("text");_&&(_.style.textAlign=O),e.setLocalPosition(M,N),r.setLocalPosition(C,k),n.setLocalPosition(P,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(ID.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(ID.controller,"g");if(ZL(l.node(),u),u){var h=ED(this.attributes,"button"),d=ED(this.attributes,"pageNum"),f=c(wD(h),2),p=f[0],g=f[1],m=p.size,v=o(p,["size"]),y=!l.select(ID.prevBtnGroup.class).node(),b=l.maybeAppendByClassName(ID.prevBtnGroup,"g").styles(g);this.prevBtnGroup=b.node();var E=b.maybeAppendByClassName(ID.prevBtn,"path"),w=l.maybeAppendByClassName(ID.nextBtnGroup,"g").styles(g);this.nextBtnGroup=w.node(),[E,w.maybeAppendByClassName(ID.nextBtn,"path")].forEach((function(t){t.styles(i(i({},v),{transformOrigin:"center"})),fD(t.node(),m,!0)}));var x=l.maybeAppendByClassName(ID.pageInfoGroup,"g");this.pageInfoGroup=x.node(),x.maybeAppendByClassName(ID.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=gD(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(Xa.INSERTED,e),this.playWindow.addEventListener(Xa.REMOVED,e)},e}(MD);function zD(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}OD.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"]]})),OD.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]]})),OD.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 BD=rD({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 FD=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new Ps({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(mD(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(mD(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(BD.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=ED(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(BD.markerGroup,"g").style("zIndex",0),cD(!!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 OD({style:{symbol:n},className:BD.marker.name}):n();a?s.nodeName===a.nodeName?a instanceof OD?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),gD(a).styles(r)):(a.remove(),gD(s).attr("className",BD.marker.name).styles(r),o.appendChild(s)):(s instanceof OD||gD(s).attr("className",BD.marker.name).styles(r),o.appendChild(s)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]),fD(e.markerGroup.node(),e.scaleSize,!0)}))},e.prototype.renderLabel=function(t){var e=ED(this.attributes,"label"),n=e.text,r=o(e,["text"]);this.labelGroup=t.maybeAppendByClassName(BD.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(BD.label,(function(){return uD(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=ED(this.attributes,"value"),r=n.text,i=o(n,["text"]);this.valueGroup=t.maybeAppendByClassName(BD.valueGroup,"g").style("zIndex",0),cD(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(BD.value,(function(){return uD(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,o=ED(this.attributes,"background");this.background=t.maybeAppendByClassName(BD.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(BD.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({x:o,y:u}),this.labelGroup.styles({x:a,y:u}),sD(this.labelGroup.select(BD.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({x:s,y:u}),sD(this.valueGroup.select(BD.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=gD(e);this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.adjustLayout()},e}(MD),GD=rD({page:"item-page",navigator:"navigator",item:"item"},"items"),VD=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},WD=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:de,mouseenter:de,mouseleave:de})||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=ED(this.attributes,"item"),o=e.map((function(t,o){var a=t.id,s=void 0===a?o:a,u=t.label,h=t.value;return{id:"".concat(s),index:o,style:i({layout:n,labelText:u,valueText:h},Object.fromEntries(Object.entries(r).map((function(n){var r,i,a=c(n,2),s=a[0],u=a[1];return[s,(r=u,i=[t,o,e],Tt(r)?r.apply(void 0,l([],c(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=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,v=t.ifHorizontal(l,u),y=[Math.floor(m/v),m%v];"vertical"===n&&y.reverse();var b=c(y,2),E=b[0],w=b[1],x=(r-a-(l-1)*o)/l,M=e.getBBox().height,N=c([0,0],2),S=N[0],C=N[1];return"horizontal"===n?(S=(f=c([d,E*(M+i)],2))[0],C=f[1],d=w===l-1?0:d+x+o):(S=(p=c([w*(x+o),d],2))[0],C=p[1],d=E===u-1?0:d+M+i),{page:g,index:s,row:E,col:w,pageIndex:m,width:x,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=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],v=f[3],y=f[4],b=f[5],E=f[6],w=f[7];return this.pageViews.children.map((function(t,e){var n,o,a,l,f=t.getBBox(),x=f.width,M=f.height,N=0===E?0:i,S=E+N+x;return S<=h&&VD(y,(function(t){return t<u}))?(n=c([E+N,w,S],3),p=n[0],g=n[1],E=n[2],{width:x,height:M,x:p,y:g,page:m,index:e,pageIndex:v++,row:b,col:y++}):(o=c([b+1,0,0,w+M+r],4),b=o[0],y=o[1],E=o[2],(w=o[3])+M<=d&&VD(b,(function(t){return t<s}))?(a=c([E,w,x],3),p=a[0],g=a[1],E=a[2],{width:x,height:M,x:p,y:g,page:m,index:e,pageIndex:v++,row:b,col:y++}):(l=c([0,0,x,0,m+1,0,0,0],8),p=l[0],g=l[1],E=l[2],w=l[3],m=l[4],v=l[5],b=l[6],y=l[7],{width:x,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 zD(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(GD.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(GD.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);gD(t).selectAll(GD.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new FD({style:e})})).attr("className",GD.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 _s({className:GD.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),ue(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=ED(this.attributes,"nav"),r=oD({orientation:e},n),i=this;return t.selectAll(GD.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new jD({style:r})})).attr("className",GD.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(gD(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Ha(t,{detail:e});this.dispatchEvent(n)},e}(MD),UD=rD({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),HD={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,HD)||this}r(e,t),e.prototype.render=function(t,e){var n=gD(e).maybeAppendByClassName(UD.markerGroup,"g");this.renderMarker(n);var r=gD(e).maybeAppendByClassName(UD.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?zD(r,"horizontalHandle","verticalHandle"):o;cD(!!a,t,(function(t){var n=ED(e.attributes,"marker"),r=i({symbol:a},n);e.marker=t.maybeAppendByClassName(UD.marker,(function(){return new OD({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;cD(r,t,(function(t){var n,r=ED(e.attributes,"label"),s=r.text,h=o(r,["text"]),d=(null===(n=t.select(UD.marker.class))||void 0===n?void 0:n.node().getBBox())||{},f=d.width,p=void 0===f?0:f,g=d.height,m=c(zD(a,[0,(void 0===g?0:g)+u,"center","top"],[p+u,0,"start","middle"]),4),v=m[0],y=m[1],b=m[2],E=m[3];t.maybeAppendByClassName(UD.label,"text").styles(i(i({},h),{x:v,y:y,text:l(s).toString(),textAlign:b,textBaseline:E}))}))}}(MD);var qD,$D,YD={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},KD=oD({},YD,{});oD({},YD,(qD=HD,$D="handle",Object.entries(qD).reduce((function(t,e){var n=c(e,2),r=n[0],i=n[1];return r.startsWith("show")?t["show".concat($D).concat(r.slice(4))]=i:t["".concat($D).concat(vD(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 XD=rD({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"),ZD=function(t){function e(e){return t.call(this,e,KD)||this}return r(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,o=r.showTitle,a=r.titleText,s=c(wD(ED(this.attributes,"title")),2),u=s[0],l=s[1];this.titleGroup=t.maybeAppendByClassName(XD.titleGroup,"g").styles(l);var h=i(i({width:e,height:n},u),{text:o?a:""});this.title=this.titleGroup.maybeAppendByClassName(XD.title,(function(){return new DD({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(wD(ED(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(XD.itemsGroup,"g").styles(i({x:n,y:r},l));var d=this;this.itemsGroup.selectAll(XD.items.class).data(["items"]).join((function(t){return t.append((function(){return new WD({style:h})})).attr("className",XD.items.name).each((function(){d.items=gD(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 eD(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=RD(r),h=c(mD(a?i:0),4),d=h[0],f=h[1],p=h[2],g=h[3],m=c(mD(o),4),v=m[0],y=m[1],b=m[2],E=m[3],w=c([g+f,d+p],2),x=w[0],M=w[1],N=c([E+y,v+b],2),S=N[0],C=N[1];if("l"===l[0])return new eD(s.x,s.y,u.width+s.width+x+S,Math.max(u.height+C,s.height));if("t"===l[0])return new eD(s.x,s.y,Math.max(u.width+S,s.width),u.height+s.height+M+C);var k=c([e.attributes.width||u.width,e.attributes.height||u.height],2),T=k[0],P=k[1];return new eD(u.x,u.y,T+s.width+x+S,P+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=gD(e);this.renderTitle(i,n,r),this.renderItems(i,this.availableSpace),this.adjustLayout()},e}(MD);function QD(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 JD={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function tI(t){var e;void 0===t&&(t="");var n=QD(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},JD),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)"},JD),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 eI=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=QD(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:tI(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 Xe(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=Xe(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=QD(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"},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},E=[];u.split("-").forEach((function(t){b[t]?E.push(m[t]):E.push(t)}));var w=E.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 eD(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}(MD),nI=function(t){function e(e){var n=t.call(this,e)||this;n.layoutEvents=[Xa.BOUNDS_CHANGED,Xa.INSERTED,Xa.REMOVED],n.$margin=mD(0),n.$padding=mD(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=mD(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return this.$padding},set:function(t){this.$padding=mD(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 eD(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 eD(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:hD,grid:dD},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}(_s);class rI extends VL{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({},rI.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(),u={},c=e=>Tt(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",c(t)]),{color:o="#1783ff",type:a="circle"}=((t,e)=>{const n=r?.getElementComputedStyle(t,e);return n})(e,t);(n||0===n)&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),u[i]||(u[i]={id:`${e}__${n}`,label:i,marker:h[a]||l[e],elementType:e,lineWidth:1,stroke:o,fill:o}))}))};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 nI({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 ZD({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 iI extends VL{static defaultOptions={position:"top-left",enable:!0};$element=HL("toolbar",!1);constructor(t,e){super(t,Object.assign({},iI.defaultOptions,e));const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),qL("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),qL("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 oI extends VL{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({},oI.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 u=this.getItems(r,e);let c,l;if(n)c=n.x,l=n.y;else{const t=se(u,"0.style",{x:0,y:0});c=t.x,l=t.y}let h={};o?h.content=o(t,u):h={title:e,data:u.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:a||s})))},this.tooltipElement.update({x:c,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:u={x:-i,y:-r}}=this.options,[c,l]=e,[h,d]=t.getSize(),f=new eI({className:"tooltip",style:{x:c,y:l,container:u,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 aI;function sI(t,e){aI||(aI=document.createElement("canvas")),aI.width=t,aI.height=e;return aI.getContext("2d").clearRect(0,0,t,e),aI}class uI extends VL{static defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};$element=HL("watermark");constructor(t,e){super(t,Object.assign({},uI.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=sI(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=sI(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 cI=["#7E92B5","#f5222d","#faad14"],lI={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},hI={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function dI(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeBadgePalette:a=cI,nodePaletteOptions:s=lI,edgeColor:u,edgeColorDisabled:c,edgePaletteOptions:l=hI,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,labelOpacity:1,opacity:1,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65},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:{iconOpacity:.25,labelOpacity:.25,opacity:.25},disabled:{color:i,labelOpacity:.25}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["x","y","color","stroke"]}]}},edge:{palette:l,style:{color:u,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,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:{labelOpacity:.25,color:c}},animation:{enter:"fade",exit:"fade",visibility:"fade",update:[{fields:["color"]},{fields:["path"],shape:"key"}]}},combo:{style:{collapsedMaskFill:h,collapsedMaskFontSize:12,collapsedSize:32,color:h,haloLineWidth:12,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,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 fI=dI({bgColor:"#000000",textColor:"#ffffffd9",nodeColor:"#1783ff",nodeColorDisabled:"#d0e4ff",nodeStroke:"#d0e4ff",edgeColor:"#99add1",edgeColorDisabled:"#969696",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696"}),pI=dI({bgColor:"#fff",textColor:"#000000d9",nodeColor:"#1783ff",nodeColorDisabled:"#f0f0f0",nodeStroke:"#000000",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",comboColor:"#fdfdfd",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9"}),gI={animation:{fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}],"combo-collapse-expand":[{fields:["x","y"]},{fields:["r","width","height"],shape:"key"}]},behavior:{"zoom-canvas":Kh,"drag-canvas":Vh,"drag-element":Wh,"collapse-expand":zh,"hover-element":Yh,"focus-element":Hh,"create-edge":Fh},combo:{circle:jl,rect:zl},edge:{cubic:sh,line:lh,polyline:hh,quadratic:dh,"cubic-horizontal":uh,"cubic-vertical":ch},layout:{"antv-dagre":class{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},pm),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:v,preset:y}=r,b=new hp({tree:[]}),E=hm(s||50,c),w=hm(u||50,l);let x=w,M=E;"LR"!==a&&"RL"!==a||(x=E,M=w);const N=fm(i,void 0),S=e.getAllNodes(),C=e.getAllEdges();let k;S.forEach((t=>{const e=N(t),n=M(t),r=e+2*x(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)&&(k=new hp({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&Ig(t,i);const s=Wg(t);let u;n&&(e.ranksep=Ug(s,{rankdir:o,ranksep:a}));try{u=Dg(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}jg(t,s)})(b,{prevGraph:k,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 P="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(P?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=P?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=P?(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=gm(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,P,r,i))}))}let A=[];A=b.getAllNodes().map((t=>lm(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({},Yv),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 mm(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,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,um(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const E=[];let w;if(c.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)&&E.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 hp({nodes:v,edges:E}),e=a||new Wm;if(b&&$v[e.id]){const e=v.length<100?new Uv:new wm;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=Wt(r)?()=>r:Tt(r)?r:()=>0,e.spacing=a,n)if(Tt(n))o=t=>{const e=n(t),r=a(t);if(im(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(im(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(im(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:im(i)?()=>Math.max.apply(null,i):Tt(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 wm({}),f={center:[0,0],preventOverlap:!0,nodeSpacing:l},p=[],g=t=>{let e=(null==c?void 0:c(t))||10;return im(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();um(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==u?void 0:u(t))||[30,30]),Wt(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),c=c.then((()=>a(this,void 0,void 0,(function*(){const t=new hp(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;im(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],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,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(c)})),p}},"compact-box":op.compactBox,"force-atlas2":class{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},eL),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 mm(e,t,h);const d=i.map((t=>lm(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new hp({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,Wt(a.size))i[o]=a.size;else if(im(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(Tt(n)){const t=n(e.getNode(o));im(t)?i[o]=Math.max(...t):i[o]=t}else im(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: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 QR(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 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,E=b;"linlog"===u&&(b=Math.log(1+y),E=b),s&&(b=y/g,E=y/m),a&&e<n&&y<=0?(b=0,E=0):a&&e<n&&y>0&&(b=y,E=y),i[h][0]+=b*v[0],i[d][0]-=E*v[0],i[h][1]+=b*v[1],i[d][1]-=E*v[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 JR({xmid:(l+c)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:u}),g=new tL(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 v=u*(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=u*(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=c*(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: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(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=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}},circular:class{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},vm),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(),[v,y,b]=bm(i,o,a),E=null==g?void 0:g.length;if(!E||1===E)return mm(e,t,b);const w=(c-u)/E;let{radius:x,startRadius:M,endRadius:N}=r;if(f){const t=hm(10,f),e=dm(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)})),x=r/(2*Math.PI)}else x||M||N?!M&&N?M=N:M&&!N&&(N=M):x=Math.min(y,v)/2;const S=w*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(lm(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>lm(t)));const k=Math.ceil(E/s);for(let t=0;t<E;++t){let e=x;e||null===M||null===N||(e=M+t*(N-M)/(E-1)),e||(e=10+100*t/(E-1));let n=u+t%k*S+2*Math.PI/s*Math.floor(t/k);d||(n=c-t%k*S-2*Math.PI/s*Math.floor(t/k)),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:wm,d3force:class{constructor(t={}){this.options=t,this.id="d3force",this.options=Object.assign(Object.assign({},zy),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(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()}tick(t=1){this.forceSimulation.tick(t);const e={nodes:By(this.lastLayoutNodes),edges:Fy(this.lastLayoutEdges)};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),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=i.map((t=>{var e,n;return Object.assign(Object.assign({},lm(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),s=o.map((t=>lm(t)));this.lastLayoutNodes=a,this.lastLayoutEdges=s,this.lastAssign=t,this.lastGraph=e;const{alphaMin:u,alphaDecay:c,alpha:l,nodeStrength:h,edgeStrength:d,linkDistance:f,clustering:p,clusterFociStrength:g,clusterEdgeDistance:m,clusterEdgeStrength:v,clusterNodeStrength:y,clusterNodeSize:b,collideStrength:E=1,center:w=[0,0],preventOverlap:x,nodeSize:M,nodeSpacing:N,onTick:S}=r;let{forceSimulation:C}=r;return new Promise((n=>{if(C){if(p){const t=jy();t.nodes(a),t.links(s)}if(C.nodes(a),s){const t=ny().id((t=>t.id)).links(s);d&&t.strength(d),f&&t.distance(f),C.force("link",t)}x&&this.overlapProcess(C,{nodeSize:M,nodeSpacing:N,collideStrength:E}),C.alpha(l).restart();const r=By(a),i=Fy(s);t&&r.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),n({nodes:r,edges:i})}else try{const r=Ly();if(h&&r.strength(h),C=Ry().nodes(a),p){const t=jy();t.centerX(w[0]).centerY(w[1]).template("force").strength(g),s&&t.links(s),a&&t.nodes(a),t.forceLinkDistance(m).forceLinkStrength(v).forceCharge(y).forceNodeSize(b),C.force("group",t)}if(C.force("center",function(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}(w[0],w[1])).force("charge",r).alpha(l).alphaDecay(c).alphaMin(u),x&&this.overlapProcess(C,{nodeSize:M,nodeSpacing:N,collideStrength:E}),s){const t=ny().id((t=>t.id)).links(s);d&&t.strength(d),f&&t.distance(f),C.force("link",t)}C.on("tick",(()=>{const n=By(a);null==S||S({nodes:n,edges:Fy(s)}),t&&n.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})))})).on("end",(()=>{const r=By(a);t&&r.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y}))),n({nodes:r,edges:Fy(s)})}))}catch(t){console.warn(t)}this.forceSimulation=C}))}))}overlapProcess(t,e){const{nodeSize:n,nodeSpacing:r,collideStrength:i}=e;let o,a;if(a=Wt(r)?()=>r:Tt(r)?r:()=>0,n)if(Tt(n))o=t=>n(t)+a(t);else if(im(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)}else if(Wt(n)){const t=n/2;o=e=>t+a(e)}else o=()=>10;else o=t=>{if(t.size){if(im(t.size)){return(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+a(t)}if(Rt(t.size)){return(t.size.width>t.size.height?t.size.width:t.size.height)/2+a(t)}return t.size/2+a(t)}return 10+a(t)};t.force("collisionForce",Jv(o).strength(i))}},dagre:ZR,dendrogram:op.dendrogram,force:Wm,fruchterman:class{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},nL),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=>lm(t,[o,a]))),g=new hp({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 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: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),v={};if(this.applyCalculate(t,v,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]];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)),u=m*t;v[i].x-=u*(o.x-a.cx)/s,v[i].y-=u*(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*(u/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 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(!(Wt(s.x)&&Wt(a.x)&&Wt(s.y)&&Wt(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)}))}},grid:class{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},rL),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(),v=e.getAllEdges(),y=null==m?void 0:m.length;if(!y||1===y)return mm(e,t,i);const b=m.map((t=>lm(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 E=d||"undefined"==typeof window?d:window.innerWidth,w=f||"undefined"==typeof window?f:window.innerHeight,x=y,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(x/M.rows);else if(null==u&&null!=c)M.cols=c,M.rows=Math.ceil(x/M.cols);else{const t=Math.sqrt(x*w/E);M.rows=Math.round(t),M.cols=Math.round(E/w*t)}if(M.rows=Math.max(M.rows,1),M.cols=Math.max(M.cols,1),M.cols*M.rows>x){const t=iL(M),e=oL(M);(t-1)*e>=x?iL(M,t-1):(e-1)*t>=x&&oL(M,e-1)}else for(;M.cols*M.rows<x;){const t=iL(M),e=oL(M);(e+1)*t>=x?oL(M,e+1):iL(M,t+1)}let N=o?0:E/M.cols,S=o?0:w/M.rows;if(s||l){const t=hm(10,l),n=dm(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;im(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;N=Math.max(N,l),S=Math.max(S,h)}))}const C={},k={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;aL(C,t);)t.col++;else if(void 0===t.row)for(t.row=0;aL(C,t);)t.row++;T[n.id]=t,sL(C,t)}cL(n,i,N,S,T,M,k,C)}const P={nodes:b,edges:v};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P}))}},indented:op.indented,mds:Uv,mindmap:op.mindmap,radial:class{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},fL),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:v=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),E=i||"undefined"==typeof window?i:window.innerWidth,w=o||"undefined"==typeof window?o:window.innerHeight,x=a||[E/2,w/2];if(!(null==y?void 0:y.length)||1===y.length)return mm(e,t,x);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=mL(y,M.id),S=am({nodes:y,edges:b},!1),C=om(S),k=yL(C,N);vL(C,N,k+1);const T=C[N];let P=E-x[0]>x[0]?x[0]:E-x[0],A=w-x[1]>x[1]?x[1]:w-x[1];0===P&&(P=E/2),0===A&&(A=w/2);const O=Math.min(P,A),_=Math.max(...T),R=[],L=u||O/_;T.forEach(((t,e)=>{R[e]=t*L}));const D=pL(y,C,g,R,L,p,m),I=gL(D),j=((t,e,n)=>{try{const n=Gv.mul(Gv.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 Vv(n),s=Gv.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>Gv.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 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,I,D,R,N),d){z=fm(c,l);const t={nodes:y,nodeSizeFunc:z,positions:B,radii:R,height:w,width:E,strictRadial:Boolean(h),focusIdx:N,iterations:f||200,k:B.length/4.5};B=((t,e)=>{const n=Object.assign(Object.assign({},lL),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}})),hL(d,r,f,a,l,h),dL(r,f,s,u,c,p,o,l);return r})(e,t)}const F=[];B.forEach(((t,e)=>{const n=lm(y[e]);n.data.x=t.x+x[0],n.data.y=t.y+x[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=sm(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=sm(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}))}},random:class{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},bL),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()}}))}}},node:{circle:kl,ellipse:Al,image:_l,rect:Rl,star:Ll,triangle:Dl,diamond:Pl,hexagon:Ol},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)"],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:fI,light:pI},plugin:{"grid-line":YL,watermark:uI,tooltip:oI,contextmenu:$L,toolbar:iI,legend:rI}},mI={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{}};function vI(t,e,n){mI[t][e]?console.error(`The extension ${e} of ${t} has been registered before.`):Object.assign(mI[t],{[e]:n})}function yI(t,e){const n=mI[t]?.[e];if(n)return n}ds.enableCSSParsing=!1,Object.entries(gI).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{vI(t,e,n)}))}));class bI{type;constructor(t){this.type=t}}class EI extends bI{data;constructor(t,e){super(t),this.data=e}}class wI extends bI{animationType;animation;data;constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class xI extends bI{elementType;data;constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class MI extends bI{data;constructor(t,e){super(t),this.data=e}}function NI(t,e){t.emit(e.type,e)}function SI(t,e){const{datum:n,index:r,elementData:i}=e;return Tt(t)?t(n,r,i):Object.fromEntries(Object.entries(t).map((([t,e])=>Tt(e)?[t,e(n,r,i)]:[t,e])))}function CI(t){return t.style?.zIndex??Ah("zIndex")??0}class kI extends Dh{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 Vs)return{type:"canvas",element:t};let e=t;for(;e;){if(fh(e))return{type:"node",element:e};if(ph(e))return{type:"edge",element:e};if(gh(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()}}function TI(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function PI(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 AI(t,e){var n,r,i=e.x1,o=e.y1,a=e.x2,s=e.y2,u=e.defX,c=void 0===u?0:u,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,E=0;d&&Es(d)&&p&&(n=a-i,r=s-o,E=Math.atan2(r,n),m=Math.cos(E)*(p||0),v=Math.sin(E)*(p||0)),f&&Es(f)&&g&&(n=i-a,r=o-s,E=Math.atan2(r,n),y=Math.cos(E)*(g||0),b=Math.sin(E)*(g||0)),t.moveTo(i-c+m,o-h+v),t.lineTo(a-c+y,s-h+b)}function OI(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=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,E=0;if(u&&Es(u)&&h){var w=c(u.parentNode.getStartTangent(),2),x=w[0],M=w[1];n=x[0]-M[0],r=x[1]-M[1],E=Math.atan2(r,n),m=Math.cos(E)*(h||0),v=Math.sin(E)*(h||0)}if(l&&Es(l)&&d){var N=c(l.parentNode.getEndTangent(),2);x=N[0],M=N[1];n=x[0]-M[0],r=x[1]-M[1],E=Math.atan2(r,n),y=Math.cos(E)*(d||0),b=Math.sin(E)*(d||0)}for(var S=0;S<p.length;S++){var C=p[S],k=C[0],T=p[S+1],P=0===S&&(0!==m||0!==v),A=(S===p.length-1||T&&("M"===T[0]||"Z"===T[0]))&&0!==y&&0!==b;switch(k){case"M":P?(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,L=O.rx,D=O.ry,I=O.startAngle,j=O.endAngle,z=O.xRotation,B=O.sweepFlag;if(t.ellipse)t.ellipse(_-o,R-s,L,D,z,I,j,!!(1-B));else{var F=L>D?L:D,G=L>D?1:L/D,V=L>D?D/L:1;t.translate(_-o,R-s),t.rotate(z),t.scale(G,V),t.arc(0,0,F,I,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 _I(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,c=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,E=0,w=0,x=0;u&&Es(u)&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],x=Math.atan2(r,n),y=Math.cos(x)*(l||0),b=Math.sin(x)*(l||0)),c&&Es(c)&&h&&(n=d[f-1][0]-d[0][0],r=d[f-1][1]-d[0][1],x=Math.atan2(r,n),E=Math.cos(x)*(h||0),w=Math.sin(x)*(h||0)),t.moveTo(p+(y||E),g+(b||w));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 RI(t,e){var n,r,i=e.defX,o=void 0===i?0:i,a=e.defY,s=void 0===a?0:a,u=e.markerStart,c=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,E=0,w=0,x=0;u&&Es(u)&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],x=Math.atan2(r,n),y=Math.cos(x)*(l||0),b=Math.sin(x)*(l||0)),c&&Es(c)&&h&&(n=d[f-2][0]-d[f-1][0],r=d[f-2][1]-d[f-1][1],x=Math.atan2(r,n),E=Math.cos(x)*(h||0),w=Math.sin(x)*(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+E,v+w)}function LI(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,u=i>0?1:-1,l=s+u===0,h=c(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,u*f,f,-u*Math.PI/2,s>0?0:Math.PI,l),t.lineTo(o,a-u*p),0!==p&&t.arc(o-s*p,a-u*p,p,s>0?0:Math.PI,u>0?Math.PI/2:1.5*Math.PI,l),t.lineTo(s*g,a),0!==g&&t.arc(s*g,a-u*g,g,u>0?Math.PI/2:-Math.PI/2,s>0?Math.PI:0,l),t.lineTo(0,u*d),0!==d&&t.arc(s*d,u*d,d,s>0?Math.PI:0,u>0?1.5*Math.PI:Math.PI/2,l)}else t.rect(0,0,o,a)}var DI=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={})[$n.CIRCLE]=TI,t[$n.ELLIPSE]=PI,t[$n.RECT]=LI,t[$n.LINE]=AI,t[$n.POLYLINE]=RI,t[$n.POLYGON]=_I,t[$n.PATH]=OI,t[$n.TEXT]=void 0,t[$n.GROUP]=void 0,t[$n.IMAGE]=void 0,t[$n.HTML]=void 0,t[$n.MESH]=void 0,t);this.context.pathGeneratorFactory=e},e.prototype.destroy=function(){delete this.context.pathGeneratorFactory},e}(Xn),II=Z(),jI=Z(),zI=Z(),BI=E(),FI=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(BI,r),s=lt(jI,nt(zI,n[0],n[1],0),a),u=e.getGeometryBounds().halfExtents,c=e.parsedStyle.anchor;if(s[0]+=(c&&c[0]||0)*u[0]*2,s[1]+=(c&&c[1]||0)*u[1]*2,o(e,new xr(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=nt(II,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=ua(p);if(m){var v=m.parsedStyle.clipPath;if(this.isHit(v,c,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 GI(t,e,n){var r=t.parsedStyle,i=r.r,o=r.fill,a=r.stroke,s=r.lineWidth,u=r.increasedLineWidthForHitTesting,l=r.pointerEvents,h=((s||0)+(u||0))/2,d=kn(i,i,e.x,e.y),f=c(da(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 VI(t,e,n,r){return t/(n*n)+e/(r*r)}function WI(t,e,n){var r=t.parsedStyle,i=r.rx,o=r.ry,a=r.fill,s=r.stroke,u=r.lineWidth,l=r.increasedLineWidthForHitTesting,h=r.pointerEvents,d=e.x,f=e.y,p=c(da(h,a,s),2),g=p[0],m=p[1],v=((u||0)+(l||0))/2,y=(d-i)*(d-i),b=(f-o)*(f-o);return g&&m||n?VI(y,b,i+v,o+v)<=1:g?VI(y,b,i,o)<=1:!!m&&(VI(y,b,i-v,o-v)>=1&&VI(y,b,i+v,o+v)<=1)}function UI(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function HI(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 kn(c.x,c.y,a,s)<=o/2}function qI(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&&In(t,e,n,r,o,a)<=i/2}function $I(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var a=0;a<o-1;a++){if(qI(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(qI(s[0],s[1],u[0],u[1],e,n,r))return!0}return!1}var YI=1e-6;function KI(t){return Math.abs(t)<YI?0:t<0?-1:1}function XI(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 ZI(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(XI(a,s,[e,n]))return!0;KI(a[1]-n)>0!=KI(s[1]-n)>0&&KI(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(r=!r)}return r}function QI(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=ZI(t[i],e,n))break}return r}function JI(t,e,n){var r=t.parsedStyle,i=r.x1,o=r.y1,a=r.x2,s=r.y2,u=r.lineWidth,l=r.increasedLineWidthForHitTesting,h=r.defX,d=void 0===h?0:h,f=r.defY,p=void 0===f?0:f;return!(!c(da(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!u)&&qI(i,o,a,s,(u||0)+(l||0),e.x+d,e.y+p)}function tj(t,e,n,r,i,o){var a=t.parsedStyle,s=a.lineWidth,u=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,E=m.polylines,w=m.polygons,x=c(da(v,(null==w?void 0:w.length)&&h,l),2),M=x[0],N=x[1],S=Xi(t),C=!1;return M||n?C=b?r(t,e):QI(w,e.x+f,e.y+g)||QI(E,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 u=t[s],c=u.currentPoint,l=u.params,h=u.prePoint,d=u.box;if(!d||UI(d.x-a,d.y-a,d.width+e,d.height+e,n,r))switch(u.command){case"L":case"Z":if(o=qI(h[0],h[1],c[0],c[1],e,n,r))return!0;break;case"Q":if(o=Hn(h[0],h[1],l[1],l[2],l[3],l[4],n,r)<=e/2)return!0;break;case"C":if(o=Fn(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=Oe(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=Fn(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)+(u||0),e.x+f,e.y+g,S)),C)}function ej(t,e,n){var r=t.parsedStyle,i=r.stroke,o=r.fill,a=r.lineWidth,s=r.increasedLineWidthForHitTesting,u=r.points,l=r.defX,h=void 0===l?0:l,d=r.defY,f=void 0===d?0:d,p=c(da(r.pointerEvents,o,i),2),g=p[0],m=!1;return(p[1]||n)&&(m=$I(u.points,(a||0)+(s||0),e.x+h,e.y+f,!0)),m||!g&&!n||(m=ZI(u.points,e.x+h,e.y+f)),m}function nj(t,e,n){var r=t.parsedStyle,i=r.lineWidth,o=r.increasedLineWidthForHitTesting,a=r.points,s=r.defX,u=void 0===s?0:s,l=r.defY,h=void 0===l?0:l;return!(!c(da(r.pointerEvents,r.fill,r.stroke),2)[1]&&!n||!i)&&$I(a.points,(i||0)+(o||0),e.x+u,e.y+h,!1)}function rj(t,e,n,r,i){var o=t.parsedStyle,a=o.radius,s=o.fill,u=o.stroke,l=o.lineWidth,h=o.increasedLineWidthForHitTesting,d=o.width,f=o.height,p=c(da(o.pointerEvents,s,u),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 u=c(i,4),l=u[0],h=u[1],d=u[2],f=u[3];return qI(t+l,e,t+n-h,e,o,a,s)||qI(t+n,e+h,t+n,e+r-d,o,a,s)||qI(t+n-d,e+r,t+f,e+r,o,a,s)||qI(t,e+r-f,t,e+l,o,a,s)||HI(t+n-h,e+h,h,Math.PI,Math.PI,o,a,s)||HI(t+n-d,e+r-d,d,0,Math.PI,o,a,s)||HI(t+f,e+r-f,f,Math.PI,Math.PI,o,a,s)||HI(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?UI(0-b,0-b,d+b,f+b,e.x,e.y):g?UI(0,0,d,f,e.x,e.y):!!m&&function(t,e,n,r,i,o,a){var s=i/2;return UI(t-s,e-s,n,i,o,a)||UI(t+n-s,e-s,i,r,o,a)||UI(t+s,e+r-s,n,i,o,a)||UI(t-s,e+s,i,r,o,a)}(0,0,d,f,v,e.x,e.y)}function ij(t,e,n,r,i,o){var a=t.parsedStyle,s=a.pointerEvents,u=a.width,c=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=u,h.height=c,i.defaultStyleRendererFactory[$n.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 oj=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={})[$n.CIRCLE]=GI,t[$n.ELLIPSE]=WI,t[$n.RECT]=rj,t[$n.LINE]=JI,t[$n.POLYLINE]=nj,t[$n.POLYGON]=ej,t[$n.PATH]=tj,t[$n.TEXT]=function(){return!0},t[$n.GROUP]=null,t[$n.IMAGE]=ij,t[$n.HTML]=null,t[$n.MESH]=null,t);this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new FI)},e.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},e}(Xn),aj=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=E(),this.dprMatrix=E(),this.tmpMat4=E(),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,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(Xa.UNMOUNTED,p),f.addEventListener(Xa.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(Xa.UNMOUNTED,p),f.removeEventListener(Xa.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,u=s.dirtyObjectNumThreshold,c=s.dirtyObjectRatioThreshold,l=a.getStats(),h=l.total,f=l.rendered,p=f/h;r.clearFullScreen=a.disableDirtyRectangleRendering()||f>u&&p>c,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(L(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 mr;return o.setMinMax([e,n,0],[r,i,0]),o}))),!1));if(r.removedRBushNodeAABBs=[],mr.isEmpty(a))return void(r.renderQueue=[]);var u=r.convertAABB2Rect(a),h=u.x,p=u.y,g=u.width,v=u.height,y=lt(r.vec3a,[h,p,0],r.vpMatrix),b=lt(r.vec3b,[h+g,p,0],r.vpMatrix),E=lt(r.vec3c,[h,p+v,0],r.vpMatrix),w=lt(r.vec3d,[h+g,p+v,0],r.vpMatrix),x=Math.min(y[0],b[0],w[0],E[0]),M=Math.min(y[1],b[1],w[1],E[1]),N=Math.max(y[0],b[0],w[0],E[0]),S=Math.max(y[1],b[1],w[1],E[1]),C=Math.floor(x),k=Math.floor(M),P=Math.ceil(N-x),A=Math.ceil(S-M);t.save(),r.clearRect(t,C,k,P,A,i.background),t.beginPath(),t.rect(C,k,P,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 Ha(ws.DIRTY_RECTANGLE,{dirtyRect:{x:C,y:k,width:P,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)&$a.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!==$n.LINE&&t.nodeName!==$n.PATH&&t.nodeName!==$n.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 mr;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 mr);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),Pt(s)||(t.lineDashOffset=s),Pt(o)||(t.globalAlpha*=o),Pt(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),Pt(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 u=e.geometry.contentBounds;r=-a*(u&&2*u.halfExtents[0]||0),i=-s*(u&&2*u.halfExtents[1]||0)}n?(x(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),T(this.tmpMat4,n,this.tmpMat4),T(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(x(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),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 mr;return t.forEach((function(t){n.add(t)})),n},t.tag="CanvasRenderer",t}(),sj=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=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,E=!Pt(a)&&!a.isNone,w=!Pt(l)&&!l.isNone&&d>0,x=0===a.alpha,M=!(!y||!y.length),N=!Pt(m)&&v>0,S=n.nodeName,C="inner"===g,k=w&&N&&(S===$n.PATH||S===$n.LINE||S===$n.POLYLINE||x||C);E&&(t.globalAlpha=u*c,k||uj(n,t,N),this.fill(t,n,a,s,r,i,o),k||this.clearShadowAndFilter(t,M,N)),w&&(t.globalAlpha=u*h,t.lineWidth=d,Pt(b)||(t.miterLimit=b),Pt(f)||(t.lineCap=f),Pt(p)||(t.lineJoin=p),k&&(C&&(t.globalCompositeOperation="source-atop"),uj(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;!Pt(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()})):(Ci(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()})):(Ci(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,(function(){e.renderable.dirty=!0,r.renderingService.dirtify()}))},t.prototype.getColor=function(t,e,n){var r;if(t.type===jr.LinearGradient||t.type===jr.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 uj(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 cj=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,u=e.shadowBlur,c=i,l=o;if(Bt(a)?r=this.imagePool.getImageSync(a):(c||(c=a.width),l||(l=a.height),r=a),r){uj(n,t,!Pt(s)&&u>0);try{t.drawImage(r,0,0,c,l)}catch(t){}}},t}(),lj=function(){function t(){}return t.prototype.render=function(t,e,n,r,i,o){var a=e,s=a.lineWidth,u=a.textAlign,c=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,E=a.dy,w=a.shadowColor,x=a.shadowBlur,M=y.font,N=y.lines,S=y.height,C=y.lineHeight,k=y.lineMetrics;t.font=M,t.lineWidth=s,t.textAlign="middle"===u?"center":u;var T=c;o.enableCSSParsing||"alphabetic"!==T||(T="bottom"),t.lineJoin=l,Pt(h)||(t.miterLimit=h);var P=0;"middle"===c?P=-S/2-C/2:"bottom"===c||"alphabetic"===c||"ideographic"===c?P=-S:"top"!==c&&"hanging"!==c||(P=-C);var A=b||0;P+=E||0,1===N.length&&("bottom"===T?(T="middle",P-=.5*S):"top"===T&&(T="middle",P+=.5*S)),t.textBaseline=T,uj(n,t,!Pt(w)&&x>0);for(var O=0;O<N.length;O++){var _=s/2+A;P+=C,Pt(f)||f.isNone||!s||this.drawLetterSpacing(t,N[O],k[O],u,_,P,d,g,m,v,!0),Pt(p)||this.drawLetterSpacing(t,N[O],k[O],u,_,P,d,g,m,v)}},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 v=f[m];l?this.strokeText(t,v,d,o,u):this.fillText(t,v,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=!Pt(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=!Pt(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)}(sj),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(sj),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(sj),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(sj),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(sj),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(sj),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t)}(sj);var hj=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 sj(n),o=((t={})[$n.CIRCLE]=r,t[$n.ELLIPSE]=r,t[$n.RECT]=r,t[$n.IMAGE]=new cj(n),t[$n.TEXT]=new lj,t[$n.LINE]=r,t[$n.POLYLINE]=r,t[$n.POLYGON]=r,t[$n.PATH]=r,t[$n.GROUP]=void 0,t[$n.HTML]=void 0,t[$n.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new aj(e))},e.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},e}(Xn),dj=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}(),fj=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 dj)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Xn),pj=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===$n.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===$n.HTML&&r.$camera){var n=r.getOrCreateEl(e);n&&(n.remove(),u.delete(n))}},d=function(t){var e=t.target;if(e.nodeName===$n.HTML){var n=t.attrName;r.updateAttribute(n,e)}},f=function(t){var e=t.target;if(e.nodeName===$n.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(ws.RESIZE,p),s.addEventListener(Xa.MOUNTED,l),s.addEventListener(Xa.UNMOUNTED,h),s.addEventListener(Xa.ATTR_MODIFIED,d),s.addEventListener(Xa.BOUNDS_CHANGED,f)})),a.hooks.endFrame.tap(t.tag,(function(){r.$camera&&o.renderReasons.has(Fa.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(Xa.MOUNTED,l),s.removeEventListener(Xa.UNMOUNTED,h),s.removeEventListener(Xa.ATTR_MODIFIED,d),s.removeEventListener(Xa.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.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 u=e.parsedStyle.visibility;n.style.visibility=u;break;case"pointerEvents":var c=e.parsedStyle.pointerEvents;n.style.pointerEvents=c;break;case"opacity":var l=e.parsedStyle.opacity;n.style.opacity="".concat(l);break;case"fill":var h=e.parsedStyle.fill,d="";ki(h)?d=h.isNone?"transparent":e.getAttribute("fill"):Array.isArray(h)?d=e.getAttribute("fill"):Ci(h),n.style.background=d;break;case"stroke":var f=e.parsedStyle.stroke,p="";ki(f)?p=f.isNone?"transparent":e.getAttribute("stroke"):Array.isArray(f)?p=e.getAttribute("stroke"):Ci(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&&(Pt(e.style[t])||""===e.style[t]||(n.style[t]=e.style[t]))}},t.tag="HTMLRendering",t}(),gj=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 pj)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Xn),mj=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):oa&&(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,u=t.repetition,c=t.transform,l=!1;Bt(s)?a=this.getImageSync(s,i):n?(a=n,l=!0):a=s;var h=a&&e.createPattern(a,u);if(h){var d=void 0;d=c?qo(yo(c),new Ts({})):N(E()),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,u=t.cx,c=t.cy,l=t.size;if(this.gradientCache[n])return this.gradientCache[n];var h=null;if(r===jr.LinearGradient){var d=function(t,e,n){var r=ir(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===jr.RadialGradient){var v=function(t,e,n,r,i){var o=n.value,a=r.value;n.unit===Cr.kPercentage&&(o=n.value/100*t),r.unit===Cr.kPercentage&&(a=r.value/100*e);var s=Math.max(Ie([0,0],[o,a]),Ie([0,e],[o,a]),Ie([t,e],[o,a]),Ie([t,0],[o,a]));return i&&(i instanceof Qr?s=i.value:i instanceof Ur&&("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(Ie([0,0],[o,a]),Ie([0,e],[o,a]),Ie([t,e],[o,a]),Ie([t,0],[o,a]))))),{x:o,y:a,r:s}}(o,a,u,c,l),y=v.x,b=v.y,E=v.r;h=e.createRadialGradient(y,b,0,y,b,E)}return h&&(i.forEach((function(t){var e=t.offset,n=t.color;e.unit===Cr.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,u=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==u?void 0:u.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}(),vj=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===$n.IMAGE){var s=o.img,u=o.keepAspectRatio;Bt(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===$n.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(Xa.MOUNTED,s),o.addEventListener(Xa.ATTR_MODIFIED,u)})),n.hooks.destroy.tap(t.tag,(function(){o.removeEventListener(Xa.MOUNTED,s),o.removeEventListener(Xa.ATTR_MODIFIED,u)}))},t.tag="LoadImage",t}(),yj=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 mj(this.context.config),this.addRenderingPlugin(new vj)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(Xn),bj=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||oa&&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){oa&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add(Fa.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}(),Ej=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=bj},e.prototype.destroy=function(){delete this.context.ContextService},e}(Xn),wj=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new Ej),n.registerPlugin(new yj),n.registerPlugin(new DI),n.registerPlugin(new hj),n.registerPlugin(new fj),n.registerPlugin(new oj),n.registerPlugin(new gj),n}return r(e,t),e}(Zn),xj=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=Ie([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}(),Mj=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 xj(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}(Xn);class Nj{config;background;main;label;transient;transientLabel;get canvas(){return{main:this.main,label:this.label,transient:this.transient,transientLabel:this.transientLabel,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","transientLabel","background"].reduce(((e,r)=>{const i=Tt(t)?t?.(r):new wj;"main"===r?i.registerPlugin(new Mj({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):i.unregisterPlugin(i.getPlugin("dom-interaction"));const o=new Js({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();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 Tc(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 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,{width:n,height:r,renderer:i}=this.config,o=Xe('<div id="virtual-image"></div>'),a=new Js({width:n,height:r,renderer:i?.("main")||new wj,devicePixelRatio:e,container:o,background:this.background.getConfig().background});await a.ready,a.appendChild(this.background.getRoot().cloneNode(!0)),a.appendChild(this.main.getRoot().cloneNode(!0));const s=this.label.getRoot().cloneNode(!0),u=a.viewport2Canvas({x:0,y:0}),c=this.main.viewport2Canvas({x:0,y:0});s.translate([c.x-u.x,c.y-u.y]),s.scale(1/this.main.getCamera().getZoom()),a.appendChild(s),a.appendChild(this.transient.getRoot().cloneNode(!0));const l=this.main.getCamera(),h=a.getCamera();h.setZoom(l.getZoom()),h.setPosition(l.getPosition()),h.setFocalPoint(l.getFocalPoint());return a.getContextService().toDataURL(t)}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 Sj(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 Cj(t){const{data:e,style:n,...r}=t,i=r;return e&&(i.data={...e}),n&&(i.style={...n}),i}function kj(t){const{id:e=Fc(t),style:n,data:r,...i}=t,o={...t,style:{...n},data:{...r}};return bc(t)?{id:e,data:o,...i}:{id:e,data:o}}function Tj(t){return t.data}class Pj{model;latestRemovedComboIds=new Set;comboIds=new Set;changes=[];batchCount=0;isTraceless=!1;constructor(){this.model=new hp}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===uc.NodeUpdated||e===uc.EdgeUpdated||e===uc.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:Cj(n),original:Cj(r),type:e})}else this.changes.push({value:Cj(t.value),type:e})}getChanges(){const t=this.changes;return this.changes=[],t}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=Tj(n);return this.isCombo(Fc(r))||(void 0===t||t.includes(Fc(r)))&&e.push(r),e}),[])}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=Tj(n);return(void 0===t||t.includes(Fc(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=Tj(n);return this.isCombo(Fc(r))?((void 0===t||t.includes(Fc(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(Tj):[]}getDescendantsData(t){const e=this.getElementsData([t])[0],n=[];return qh(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(Fc(t))),"TB"),n}getParentData(t,e=this.inferStructureKey(t)){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?Tj(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?vc:mc,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(Tj):[]}inferStructureKey(t){if(this.isCombo(t))return mc}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=Tj(n);return t?t.includes(Fc(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(Tj)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(Tj)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i=[],edges:o=[],combos:a=[]}=this.getData(),s=Lh(i,e,(t=>Fc(t))),u=Lh(o,n,(t=>Fc(t))),c=Lh(a,r,(t=>Fc(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(Fc),edges:u.exit.map(Fc),combos:c.exit.map(Fc)})}))}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:uc.NodeAdded}),kj(t))))),this.updateNodeLikeHierarchy(t))}addEdgeData(t=[]){t.length&&this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:uc.EdgeAdded}),kj(t)))))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(mc)||e.attachTreeStructure(mc),e.addNodes(t.map((t=>(this.comboIds.add(Fc(t)),this.pushChange({value:t,type:uc.ComboAdded}),kj(t))))),this.updateNodeLikeHierarchy(t)}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=Fc(t);e.attachTreeStructure(mc),this.setParent(n,Gc(t),mc);const r=t?.style?.children;void 0!==r&&(e.attachTreeStructure(vc),r.forEach((t=>{this.setParent(t,n,vc)})))}))}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=Fc(t),i=Tj(e.getNode(r));if(ae(i,t))return;const o=Sj(i,t);this.pushChange({value:o,original:i,type:uc.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}syncNodeDatum(t){const{model:e}=this,n=Fc(t),r=Sj(Tj(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=Fc(t),r=Tj(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=Sj(r,t);e.mergeEdgeData(n,i),this.pushChange({value:i,original:r,type:uc.EdgeUpdated})}))}))}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=Fc(t),i=Tj(e.getNode(r));if(ae(i,t))return;const o=Sj(i,t);this.pushChange({value:o,original:i,type:uc.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)}))}setParent(t,e,n,r=!0){if(t===e)return;const i=Gc(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,mc);e&&this.pushChange({value:e,original:e,type:uc.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:uc.ComboUpdated})}))}syncComboDatum(t){const{model:e}=this,n=Fc(t),r=Sj(Tj(e.getNode(n)),t);e.mergeNodeData(n,r)}getElementPosition(t){return _c(this.getElementsData([t])[0])}translateNodeBy(t,e){const n=$c(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&&qh(o,(t=>{const e=Fc(t),[o,a,s]=_c(t),u=Sj(t,{style:{x:o+n,y:a+r,z:s+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?uc.ComboUpdated:uc.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(Fc(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]=_c(o),c=n-a,l=r-s,h=i-u;qh(o,(t=>{const e=Fc(t),[n,r,i]=_c(t),o=Sj(t,{style:{x:n+c,y:r+l,z:i+h}});this.pushChange({value:o,original:t,type:this.isCombo(e)?uc.ComboUpdated:uc.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(Fc(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(Fc)),this.pushChange({value:this.getNodeData([t])[0],type:uc.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:uc.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:uc.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(mc)){const e=Gc(this.getNodeLikeData([t])[0]);this.setParent(t,void 0,mc,!1),this.model.getChildren(t,mc).forEach((t=>{const n=Tj(t),r=Fc(n);this.setParent(Fc(n),e,mc,!1);const i=Sj(n,{id:Fc(n),style:{parentId:e}});this.pushChange({value:i,original:n,type:this.isCombo(r)?uc.ComboUpdated:uc.NodeUpdated}),this.model.mergeNodeData(Fc(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,mc).map(Fc)];e=this.getComboData().filter((t=>{const e=Fc(t),r=this.getAncestorsData(e,mc),i=r.map(Fc);return!r.some((t=>!!t.style?.collapsed))&&!n.includes(e)&&!i.includes(e)}))}else e=this.getNodeData().filter((e=>Fc(e)!==t));return Math.max(0,...e.map(CI))+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 Aj{context;container;elementMap={};shapeTypeMap={};constructor(t){this.context=t}init(){if(!this.container){const{canvas:t}=this.context;this.container={node:t.appendChild(new _s({style:{zIndex:2}})),edge:t.appendChild(new _s({style:{zIndex:1}})),combo:t.appendChild(new _s({style:{zIndex:0}}))}}}emit(t){NI(this.context.graph,t)}forEachElementData(t){Cl.forEach((e=>{const n=this.context.model.getElementData(e);t(e,n)}))}getTheme(t){const{theme:e}=this.context.options;if(!e)return{};const n=yI("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({},el(this.getTheme(e)?.palette),el(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)?yI("palette",r):r;if(Tt(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[Fc(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={};computedElementDefaultStyle(t,e){const{options:n}=this.context,r=n[t]?.style||{};this.defaultStyle[Fc(e.datum)]=SI(r,e)}computeElementsDefaultStyle(t){this.forEachElementData(((e,n)=>{n.filter((e=>void 0===t||t.includes(Fc(e)))).forEach(((t,r)=>{this.computedElementDefaultStyle(e,{datum:t,index:r,elementData:n})}))}))}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 SI(r[t]?.state?.[e]||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Fc(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(Fc(e)))).forEach(((t,r)=>{const i=this.getElementState(Fc(t));this.computeElementStatesStyle(e,i,{datum:t,index:r,elementData:n})}))}))}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)=>Rh(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=Fc(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(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(Fc(t)))).filter(Boolean);Object.assign(c,{childrenNode:e,childrenData:t})}return c.type||(c.type={node:"circle",edge:"line",combo:"circle"}[t]),c}async draw(e={animation:!0}){this.init();const n=this.computeDrawData();if(!n)return;this.computeStyle();const{add:r,update:i,remove:o}=n,a=this.getDestroyTasks(o,e),s=this.getCreateTasks(r,e),u=this.getUpdateTasks(i,e);await(function(t,e={}){if(0===t.length)return null;const{before:n,...r}=e;e.before?.();const i=Th(t.map((t=>t())).map((t=>t())).flat().filter(Boolean));return Oh(i,r),i}([...a,...s,...u],e.silence?{}:{before:()=>this.emit(new EI(t.GraphEvent.BEFORE_DRAW)),beforeAnimate:e=>this.emit(new wI(t.GraphEvent.BEFORE_ANIMATE,cc.DRAW,e,n)),afterAnimate:e=>this.emit(new wI(t.GraphEvent.AFTER_ANIMATE,cc.DRAW,e,n)),after:()=>this.emit(new EI(t.GraphEvent.AFTER_DRAW))})?.finished)}computeDrawData(){const{model:t}=this.context,e=function(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=Fc(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())]}(t.getChanges());if(0===e.length)return null;const{NodeAdded:n=[],NodeUpdated:r=[],NodeRemoved:i=[],EdgeAdded:o=[],EdgeUpdated:a=[],EdgeRemoved:s=[],ComboAdded:u=[],ComboUpdated:c=[],ComboRemoved:l=[]}=Gt(e,(t=>t.type)),h=t=>new Map(t.map((t=>{const e=t.value;return[Fc(e),e]}))),d={add:{nodes:h(n),edges:h(o),combos:h(u)},update:{nodes:h(r),edges:h(a),combos:h(c)},remove:{nodes:h(i),edges:h(s),combos:h(l)}},f=[this.updateRelatedEdgeFlow,this.arrangeDrawOrderFlow,this.collapseExpandFlow].reduce(((t,e)=>e(t)),d);return f}updateRelatedEdgeFlow=t=>{const{model:e}=this.context,{update:{nodes:n,edges:r,combos:i}}=t,o=(t,n)=>{e.getRelatedEdgesData(n).forEach((t=>r.set(Fc(t),t)))};return n.forEach(o),i.forEach(o),t};arrangeDrawOrderFlow=t=>{const{model:e}=this.context,n=t.add.combos,r=[];return n.forEach(((t,n)=>{const i=e.getAncestorsData(n,"combo").map((t=>Fc(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};collapseExpandFlow=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(Fc(r),r):n[i].delete(Fc(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),u=s.map(Fc),{internal:c,external:l}=rh(u,(t=>e.getRelatedEdgesData(t)));s.forEach((t=>{const n=Fc(t),r=o.findIndex((([t])=>t===n));-1!==r&&o.splice(r,1);const a=e.getElementType(n);i("remove",a,t)})),c.forEach((t=>i("remove","edge",t))),l.forEach((t=>{const e=Fc(t),i=u.includes(t.source)?"source":"target",o={...t,[i]:Fc(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(Fc),{edges:a}=rh(r,(t=>e.getRelatedEdgesData(t)));[...n,...a].forEach((t=>{const n=Fc(t),r=e.getElementType(n),a=this.getElement(n);i(a?"update":"add",r,t),"combo"===r&&o.push([n,t])}))}}return t};createElement(e,n,r){const{animator:i}=r,o=Fc(n);if(this.getElement(o))return()=>null;const{type:a,...s}=this.getElementComputedStyle(e,n),u=yI(e,a);if(!u)return()=>null;this.emit(new xI(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n));const c=this.container[e].appendChild(new u({id:o,style:{context:this.context,...s}}));return this.shapeTypeMap[o]=a,this.elementMap[o]=c,()=>Oh(i?.(o,c,{...c.attributes,opacity:0})||null,{after:()=>{this.emit(new xI(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n)),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=Fc(n),a=this.getElement(o);if(!a)return()=>null;this.emit(new xI(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n));const s=()=>{this.emit(new xI(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n)),a.onUpdate()},{type:u,...c}=this.getElementComputedStyle(e,n);if(this.shapeTypeMap[o]!==u)return()=>(this.destroyElement(e,n,{...r,animation:!1})(),this.createElement(e,n,{...r,animation:!1})(),s(),null);if("visibility"===r.stage&&"visibility"in c){vl(a,"opacity")||gl(a,"opacity");const t=ml(a,"opacity")??Ah("opacity");if(this.latestElementVisibilityMap.set(a,c.visibility),"hidden"!==c.visibility)return kh(a,{visibility:"visible"}),()=>Oh(i?.(o,a,{...a.attributes,opacity:0},{opacity:t})||null,{after:s});if("hidden"===c.visibility)return()=>Oh(i?.(o,a,{...a.attributes,opacity:t},{opacity:0})||null,{after:()=>{kh(a,{visibility:this.latestElementVisibilityMap.get(a)}),s()}})}const l={...a.attributes};return kh(a,c),()=>Oh(i?.(o,a,l)||null,{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=Fc(n),a=this.elementMap[o];return a?(this.emit(new xI(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n)),()=>{const r=i?.(o,a,{...a.attributes},{opacity:0})||null;return Oh(r,{after:()=>{this.clearElement(o),a.destroy(),a.onDestroy(),this.emit(new xI(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}=e,u=[];return o.forEach((([t,n])=>{if(0===n.size)return[];const r=this.getAnimationExecutor(t,s||"exit",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}}function Oj(t){return Wt(t.x)&&Wt(t.y)}class _j{context;supervisor;instance;animationResult;get presetOptions(){return{animation:!!_h(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.context=t}async presetLayout(t,e){if(!e)return;if(e.type)return this.stepLayout(t,e);const n=t.getAllNodes().reduce(((e,n)=>{if(!Oj(n.data)){let r=[0,0,0],i=0;t.getNeighbors(n.id).forEach((t=>{if(Oj(t.data)){const{x:e,y:n,z:o=0}=t.data;r=$c(r,[e,n,o]),i++}})),i&&e.push({id:n.id,data:{x:r[0]/i,y:r[1]/i,z:r[2]/i}})}return e}),[]);this.updateElementPosition({nodes:n,edges:[]},!1)}async layout(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;NI(n,new EI(t.GraphEvent.BEFORE_LAYOUT));for(const t of e){const{presetLayout:e}=t,n=this.getLayoutDataModel(t);await this.presetLayout(n,e);const r=await this.stepLayout(n,{...this.presetOptions,...t});t.animation||this.updateElementPosition(r,!1)}NI(n,new EI(t.GraphEvent.AFTER_LAYOUT))}async stepLayout(t,e){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?await this.treeLayout(t,e):await this.graphLayout(t,e)}async graphLayout(t,e){const{animation:n,enableWorker:r,iterations:i=300}=e,o=this.initGraphLayout(t,e);if(this.instance=o,r)return this.supervisor=new GL(t,o,{iterations:i}),await this.supervisor.execute();if(EL(o))return n?await o.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(o.execute(t),o.stop(),o.tick(i));const a=await o.execute(t);return n&&this.updateElementPosition(a,n),a}async treeLayout(t,e){const{type:n,animation:r}=e,i=yI("layout",n);if(!i)throw new Error(`The layout type ${n} is not found`);!function(t){if(t.hasTreeStructure(vc))return;t.attachTreeStructure(vc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,vc)}}(t);const o={nodes:[],edges:[]};return t.getRoots(vc).forEach((n=>{qh(n,(e=>{e.children=t.getSuccessors(e.id)}),(e=>t.getSuccessors(e.id)),"TB");qh(i(n,e),(t=>{const{id:e,x:n,y:r}=t;o.nodes.push({id:e,data:{x:n,y:r}})}),(t=>t.children),"TB")})),r&&this.updateElementPosition(o,r),o}stopLayout(){this.instance&&EL(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 hp;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))),u=e.model.getAllEdges(),c=(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:{...Rj(o[e].attributes),_isCombo:!0}}):Object.assign(n,{data:Rj(i[e]?.attributes||{})}),n})),l=new Map(c.map((t=>[t.id,t]))),h=u.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:Rj(a[e].attributes)}})),d=new hp({nodes:c,edges:h});return e.model.hasTreeStructure(mc)&&(d.attachTreeStructure(mc),c.forEach((t=>{const n=e.model.getParent(t.id,mc);n&&d.hasNode(n.id)&&d.setParent(t.id,n.id,mc)}))),d}initGraphLayout(t,e){const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s,...u}=e,[c,l]=r.getCanvasSize(),h=[c/2,l/2],d=e?.nodeSize??(t=>{const e=n?.getElement(t.id),{size:r}=e?.attributes||{};return Math.max(...Ic(r))}),f=yI("layout",i);if(!f)throw new Error(`The layout type ${i} is not found`);const p={nodeSize:d,width:c,height:l,center:h,...u};return"force"===i?Object.assign(p,{getMass:n=>{const{id:r}=n,{getMass:i}=e;if(i)return i(n);const{mass:o}=n.data;return Wt(o)?o:Oj(t.getNode(r).data)||Oj(n.data)?10:1}}):"dagre"===i&&Object.assign(p,{preset:[]}),new f(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(nl)}})})),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.animationResult=void 0}}const Rj=t=>Object.entries(t).reduce(((t,[e,n])=>(["function","object"].includes(typeof n)||["x","y","z"].includes(e)||(t[e]=n),t)),{});class Lj extends Dh{category="plugin";constructor(t){super(t),this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){return this.extensionMap[t]}}class Dj{context;get padding(){return xc(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=_h(this.context.options,t);return!!e&&function(t,e){if(null===t||!It(t))return{};var n={};return Lt(e,(function(e){ce.call(t,e)&&(n[e]=t[e])})),n}({...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=Xc([-o,-a],e);return"relative"===r?h:$c([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=Xc([-u,-c,-l],i);return"relative"===n?{position:$c(o,h),focalPoint:$c(a,h)}:{position:$c(s,h),focalPoint:$c(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:u=this.getGraphCenter()}=e;this.cancelAnimation(),NI(i,new MI(t.GraphEvent.BEFORE_TRANSFORM,e));const c=this.getAnimation(n);if(c){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)}),NI(i,new wI(t.GraphEvent.BEFORE_ANIMATE,cc.TRANSFORM,null,e)),new Promise((r=>{this.camera.gotoLandmark(this.createLandmark(n),{...c,onfinish:()=>{NI(i,new wI(t.GraphEvent.AFTER_ANIMATE,cc.TRANSFORM,null,e)),NI(i,new MI(t.GraphEvent.AFTER_TRANSFORM,e)),r()}})}))}if(o&&r.pan(...this.getTranslateArgs(e)),Wt(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(Wt(s)){const t=this.getZoomArgs(e);r.setZoomByViewportPoint(t,u)}NI(i,new MI(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]=Sc(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:$c(Yc(this.getCanvasCenter(),this.getBBoxInViewport(d).center),b?Xc(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=Tc(t.map((t=>n.getElement(t).getRenderBounds())));await this.focus(r,e)}async focus(t,e){const{center:n}=this.getBBoxInViewport(t),r=Yc(this.getCanvasCenter(),n);await this.transform({mode:"relative",translate:$c(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 mr;return u.setMinMax([i,o,0],[a,s,0]),u}cancelAnimation(){this.camera.landmarks?.length&&this.camera.cancelLandmarkAnimation()}}class Ij extends ap{options;static defaultOptions={autoResize:!1,width:800,height:600,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};destroyed=!1;context={model:new Pj};constructor(t){super(),this.options=Object.assign({},Ij.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,theme:d,plugins:f,width:p,zoomRange:g,zoom:m}=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),d&&this.setTheme(d),f&&this.setPlugins(f),(Wt(p)||Wt(u))&&this.setSize(p??this.options.width??0,u??this.options.height??0),g&&(this.options.zoomRange=g),Wt(m)&&(this.options.zoom=m),Wt(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=Tt(t)?t(this.getTheme()):t;const{background:e}=yI("theme",this.options.theme)||{};e&&!this.options.background&&this.setBackground(e)}setLayout(t){this.options.layout=Tt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){this.options.behaviors=Tt(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=Tt(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)}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(Tt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Tt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Tt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Tt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Tt(t)?t(this.getComboData()):t)}updateData(t){this.context.model.updateData(Tt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Tt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Tt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Tt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Tt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Tt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Tt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Tt(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 Nj)this.context.canvas=e,e.setBackground(o),await e.init();else{const o=Bt(e)?document.getElementById(e):e;this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:o,width:n,height:r});const a=new Nj({container:o,width:n,height:r,renderer:i});this.context.canvas=a,await a.init(),this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:a})}}createRuntime(){this.context.options=this.options,this.context.plugin||(this.context.plugin=new Lj(this.context)),this.context.viewport||(this.context.viewport=new Dj(this.context)),this.context.element||(this.context.element=new Aj(this.context)),this.context.layout||(this.context.layout=new _j(this.context)),this.context.behavior||(this.context.behavior=new kI(this.context))}async prepare(){if(this.destroyed)throw new Error("Graph has been destroyed");await this.initCanvas(),this.createRuntime()}async render(){NI(this,new EI(t.GraphEvent.BEFORE_RENDER)),await this.prepare(),await Promise.all([this.context.element?.draw(),this.context.layout?.layout()]),await this.autoFit(),NI(this,new EI(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]:UL(this.context.canvas.getContainer());ae(r,this.getSize())||(NI(this,new EI(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:r})),this.context.canvas.resize(...r),NI(this,new EI(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 Yc([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 le(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,mc).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Fc(i))].filter((t=>n.isCombo(Fc(t)))),a=e-CI(i);o.forEach((t=>{r[Fc(t)]=CI(t)+a}))}else r[t]=e})),await this.setElementZIndex(r)}getElementZIndex(t){return CI(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 nl(this.context.canvas.viewport2Canvas(rl(t)))}getViewportByCanvas(t){return nl(this.context.canvas.canvas2Viewport(rl(t)))}getClientByCanvas(t){const e=this.context.canvas.canvas2Viewport(rl(t));return nl(this.context.canvas.viewport2Canvas(e))}getCanvasByClient(t){const e=this.context.canvas.client2Viewport(rl(t));return nl(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 jj={idOf:Fc,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 qh(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:Wc,omitStyleProps:Hc},zj={dark:fI,light:pI};t.BaseBehavior=jh,t.BaseCombo=Il,t.BaseEdge=ah,t.BaseNode=Nl,t.BasePlugin=VL,t.BaseShape=El,t.CameraSetting=class extends VL{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=kl,t.CircleCombo=jl,t.ComboEvent=t.NodeEvent,t.Cubic=sh,t.CubicHorizontal=uh,t.CubicVertical=ch,t.Diamond=Pl,t.DragCanvas=Vh,t.Ellipse=Al,t.Graph=Ij,t.Hexagon=Ol,t.Image=_l,t.Line=lh,t.Polyline=hh,t.Quadratic=dh,t.Rect=Rl,t.RectCombo=zl,t.Shortcut=Gh,t.Star=Ll,t.Theme=zj,t.Triangle=Dl,t.Utils=jj,t.ZoomCanvas=Kh,t.getExtension=yI,t.getExtensions=function(t){return mI[t]},t.register=vI,t.version="5.0.0"}));