@arcgis/core 5.0.0-next.49 → 5.0.0-next.50

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 (558) hide show
  1. package/applications/Components/baUtils.js +1 -1
  2. package/arcade.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0000781c850b1b4828b3.js +1 -0
  5. package/assets/esri/core/workers/chunks/00f044370bf3bb6b24d7.js +1 -0
  6. package/assets/esri/core/workers/chunks/0136cd1a5da204b6daeb.js +1 -0
  7. package/assets/esri/core/workers/chunks/044a0ccd89741c1ae770.js +1 -0
  8. package/assets/esri/core/workers/chunks/090dad5579f0148d6486.js +1 -0
  9. package/assets/esri/core/workers/chunks/09bd9bd37a339802907a.js +1 -0
  10. package/assets/esri/core/workers/chunks/0bc01d71ed1ab8c3af3c.js +1 -0
  11. package/assets/esri/core/workers/chunks/0d9904ba62558686c289.js +1 -0
  12. package/assets/esri/core/workers/chunks/0fcb40204db8ee5571c3.js +1 -0
  13. package/assets/esri/core/workers/chunks/1065fd655bb7cee243fd.js +1 -0
  14. package/assets/esri/core/workers/chunks/11ab10668632648b2ba7.js +1 -0
  15. package/assets/esri/core/workers/chunks/13167bdd486b41163147.js +1 -0
  16. package/assets/esri/core/workers/chunks/{d8db2c51b2fb42f37b2a.js → 1363345f31f4f5051132.js} +1 -1
  17. package/assets/esri/core/workers/chunks/13be94357dcf5afc4fcb.js +1 -0
  18. package/assets/esri/core/workers/chunks/{e66bcdfd75e0113d1cec.js → 13ce8e8d45779b11ee12.js} +1 -1
  19. package/assets/esri/core/workers/chunks/1693f19f1c37e0a2087e.js +1 -0
  20. package/assets/esri/core/workers/chunks/18ab5959ebf8689f8fe8.js +1 -0
  21. package/assets/esri/core/workers/chunks/18c4cd160a4052b05831.js +1 -0
  22. package/assets/esri/core/workers/chunks/1bf4b5e5402790ccb450.js +1 -0
  23. package/assets/esri/core/workers/chunks/1db058f91a8e17b24db6.js +1 -0
  24. package/assets/esri/core/workers/chunks/1dc3ab52fcde7bff0f23.js +1 -0
  25. package/assets/esri/core/workers/chunks/{a7cd795042ebb8585906.js → 1f0c7ab33e466a37c7f9.js} +1 -1
  26. package/assets/esri/core/workers/chunks/224f01b11fdba9250b1e.js +1 -0
  27. package/assets/esri/core/workers/chunks/{a1a7b0e7ca488c895cb7.js → 22c115ec003351c7d8ee.js} +1 -1
  28. package/assets/esri/core/workers/chunks/24c35a46cf8ed11b774d.js +1 -0
  29. package/assets/esri/core/workers/chunks/27794d48c04a5875fd22.js +1 -0
  30. package/assets/esri/core/workers/chunks/294acaaebfedb05fe81e.js +1 -0
  31. package/assets/esri/core/workers/chunks/2a66841243975cac3e3c.js +1 -0
  32. package/assets/esri/core/workers/chunks/2c12848e4934e9bb2bd0.js +1 -0
  33. package/assets/esri/core/workers/chunks/2d61b6efa17e8c5832da.js +1 -0
  34. package/assets/esri/core/workers/chunks/2d6fa00273a73d44297d.js +1 -0
  35. package/assets/esri/core/workers/chunks/2da13c2269ab90281143.js +1 -0
  36. package/assets/esri/core/workers/chunks/2dfaead2ec6434513d45.js +1 -0
  37. package/assets/esri/core/workers/chunks/2fae37f34b28a46841e3.js +1 -0
  38. package/assets/esri/core/workers/chunks/{3298e96d3f2e49e338d2.js → 308fb48d080e01499a26.js} +1 -1
  39. package/assets/esri/core/workers/chunks/30dd4a7c93b33988a270.js +1 -0
  40. package/assets/esri/core/workers/chunks/355c8d0eadfff9f62dfb.js +1 -0
  41. package/assets/esri/core/workers/chunks/35961e71f69ae1d24b9e.js +1 -0
  42. package/assets/esri/core/workers/chunks/36a04be40369111a633d.js +1 -0
  43. package/assets/esri/core/workers/chunks/36d9208895abd1ba4ff1.js +1 -0
  44. package/assets/esri/core/workers/chunks/395a0773ccafd1f24c4d.js +1 -0
  45. package/assets/esri/core/workers/chunks/{81a60dfa600b690098f9.js → 3a612f873e29348370b2.js} +1 -1
  46. package/assets/esri/core/workers/chunks/3b1471f908fdecec2815.js +1 -0
  47. package/assets/esri/core/workers/chunks/{da1e61f355fb943085dc.js → 3c66dd52ad156711a6a2.js} +1 -1
  48. package/assets/esri/core/workers/chunks/3dd0db77a05263000bd8.js +1 -0
  49. package/assets/esri/core/workers/chunks/{08c1ea29678da27136f3.js → 44fb1184eeed0636704a.js} +1 -1
  50. package/assets/esri/core/workers/chunks/46d430a6983b81ba7556.js +1 -0
  51. package/assets/esri/core/workers/chunks/472d290f8eb1c1a85724.js +1 -0
  52. package/assets/esri/core/workers/chunks/47338472f5a8e004a671.js +1 -0
  53. package/assets/esri/core/workers/chunks/48b3906ac3ec57253d90.js +1 -0
  54. package/assets/esri/core/workers/chunks/{2a41283bba2361afa1fd.js → 495af366ec1defd89a72.js} +1 -1
  55. package/assets/esri/core/workers/chunks/49b581782f63abb6dd9f.js +1 -0
  56. package/assets/esri/core/workers/chunks/49df576f0215618aa651.js +1 -0
  57. package/assets/esri/core/workers/chunks/4abe2c56aecc9e9b8e86.js +1 -0
  58. package/assets/esri/core/workers/chunks/4e01e509a761a9d00b52.js +1 -0
  59. package/assets/esri/core/workers/chunks/{9d0f0d055ec25af037e0.js → 51093e552e31344cefa5.js} +1 -1
  60. package/assets/esri/core/workers/chunks/521aac8a665e98e4ca78.js +1 -0
  61. package/assets/esri/core/workers/chunks/54666586754949bfa584.js +1 -0
  62. package/assets/esri/core/workers/chunks/549f4ab9e285deaf04fb.js +1 -0
  63. package/assets/esri/core/workers/chunks/553ca1e55e9f1359839c.js +1 -0
  64. package/assets/esri/core/workers/chunks/{6f3943bebe2d5f4994f7.js → 58242447b72cc60a5040.js} +1 -1
  65. package/assets/esri/core/workers/chunks/58419d362f24b35003c1.js +1 -0
  66. package/assets/esri/core/workers/chunks/5aa354854219361f722b.js +1 -0
  67. package/assets/esri/core/workers/chunks/{aab93e885b6c7c6aa76e.js → 5ce524e0060053f35592.js} +19 -19
  68. package/assets/esri/core/workers/chunks/5d244fcf5c075afccdc6.js +1 -0
  69. package/assets/esri/core/workers/chunks/5e9fdd4eff7189f45932.js +1 -0
  70. package/assets/esri/core/workers/chunks/60954ab810dbbf36e5e1.js +1 -0
  71. package/assets/esri/core/workers/chunks/62ed6b45482e39d67785.js +1 -0
  72. package/assets/esri/core/workers/chunks/63b8193ad90b2ebe6884.js +1 -0
  73. package/assets/esri/core/workers/chunks/63c91421a71ae3b3599e.js +1 -0
  74. package/assets/esri/core/workers/chunks/63cf702cde83692126be.js +1 -0
  75. package/assets/esri/core/workers/chunks/687d2b761dc5b5cf0c31.js +1 -0
  76. package/assets/esri/core/workers/chunks/6cfcfebe9a4c491e453a.js +1 -0
  77. package/assets/esri/core/workers/chunks/{88aa71f02f43bb069345.js → 7033fa18b7dd7bd3e49c.js} +1 -1
  78. package/assets/esri/core/workers/chunks/710b29729f252f11115d.js +1 -0
  79. package/assets/esri/core/workers/chunks/72a520802b8accfd4512.js +1 -0
  80. package/assets/esri/core/workers/chunks/{72fbee59d5d909615408.js → 73892ac79b24b05e6863.js} +1 -1
  81. package/assets/esri/core/workers/chunks/73c3ee2697265b0f7208.js +1 -0
  82. package/assets/esri/core/workers/chunks/73f9cbf0f919b6adc2d5.js +1 -0
  83. package/assets/esri/core/workers/chunks/75e9759290f0f67b2128.js +1 -0
  84. package/assets/esri/core/workers/chunks/7737e69da604d2521da8.js +1 -0
  85. package/assets/esri/core/workers/chunks/{8e8d5422f57269d8c8d2.js → 7891825d5cdca03d2db0.js} +1 -1
  86. package/assets/esri/core/workers/chunks/7cd0ab01933bfb2c6e43.js +1 -0
  87. package/assets/esri/core/workers/chunks/81c2cc77c275a5b555c0.js +1 -0
  88. package/assets/esri/core/workers/chunks/82ace0195b63790b22c9.js +1 -0
  89. package/assets/esri/core/workers/chunks/8892bf3d2367e35de001.js +1 -0
  90. package/assets/esri/core/workers/chunks/8a132d91077ecf849248.js +1 -0
  91. package/assets/esri/core/workers/chunks/8a6e50d95539b46f629c.js +1 -0
  92. package/assets/esri/core/workers/chunks/8d941204425571b656ec.js +1 -0
  93. package/assets/esri/core/workers/chunks/914746077017fa50933f.js +1 -0
  94. package/assets/esri/core/workers/chunks/{004c2a1a37b99a184b13.js → 91fba3bebd78cb956941.js} +1 -1
  95. package/assets/esri/core/workers/chunks/92ec96aa743cabc9475d.js +1 -0
  96. package/assets/esri/core/workers/chunks/{5b290d18de61789417f9.js → 9361834d2c3064eb41fc.js} +1 -1
  97. package/assets/esri/core/workers/chunks/{44f036cc21e3a2308f69.js → 93b139be6488a1b4ba19.js} +1 -1
  98. package/assets/esri/core/workers/chunks/95057105f1b3bf805140.js +1 -0
  99. package/assets/esri/core/workers/chunks/968335b28b895e19913b.js +1 -0
  100. package/assets/esri/core/workers/chunks/973bf2ed34d57f299472.js +1 -0
  101. package/assets/esri/core/workers/chunks/9b6e2099aabf67b9f9f2.js +1 -0
  102. package/assets/esri/core/workers/chunks/{97b01803d0c38541aa08.js → 9c93eadbd19bef1191b4.js} +1 -1
  103. package/assets/esri/core/workers/chunks/a1594486177015e8a6c3.js +1 -0
  104. package/assets/esri/core/workers/chunks/{df458ad51be27df3d79d.js → a1f264abbd6354c333bf.js} +1 -1
  105. package/assets/esri/core/workers/chunks/a3407ca77b0ff62c0e75.js +1 -0
  106. package/assets/esri/core/workers/chunks/{8be61e13530fd0dc2fd1.js → a4f89568205d78d91cfe.js} +1 -1
  107. package/assets/esri/core/workers/chunks/a5e7c9517939f762c518.js +1 -0
  108. package/assets/esri/core/workers/chunks/a63ff3e9a9f3853d12f3.js +1 -0
  109. package/assets/esri/core/workers/chunks/a81a7cba815adb575c36.js +1 -0
  110. package/assets/esri/core/workers/chunks/{fe6fa1f2c2d54d41645e.js → a8dfd246c797f3b979f5.js} +1 -1
  111. package/assets/esri/core/workers/chunks/a8f7e44657083f6aa3fd.js +1 -0
  112. package/assets/esri/core/workers/chunks/a8fd635d1165db8616ab.js +1 -0
  113. package/assets/esri/core/workers/chunks/a92c1171314a68504c1b.js +1 -0
  114. package/assets/esri/core/workers/chunks/aa297e0931213341f51b.js +1 -0
  115. package/assets/esri/core/workers/chunks/aa7a1705266eec353cb6.js +1 -0
  116. package/assets/esri/core/workers/chunks/ab5e2f823960c33cefe4.js +1 -0
  117. package/assets/esri/core/workers/chunks/{f11453f24c0b728669d2.js → ac6f002cfad42e60de8f.js} +1 -1
  118. package/assets/esri/core/workers/chunks/b11c0e80e583f2b7c5de.js +1 -0
  119. package/assets/esri/core/workers/chunks/b14f9a46e583e1625a2b.js +1 -0
  120. package/assets/esri/core/workers/chunks/{8c271e9272e4eaf1325a.js → b1d3d2c93c189e215f67.js} +1 -1
  121. package/assets/esri/core/workers/chunks/b2425f6af7df6902dfc4.js +1 -0
  122. package/assets/esri/core/workers/chunks/b638ce18b93d3cfb9967.js +1 -0
  123. package/assets/esri/core/workers/chunks/b648a1e641cf5c772d67.js +1 -0
  124. package/assets/esri/core/workers/chunks/{1c58064ea80e6a4a4a3b.js → b907d16e82ac908bb896.js} +1 -1
  125. package/assets/esri/core/workers/chunks/b91c13f44f4d1bac5799.js +1 -0
  126. package/assets/esri/core/workers/chunks/ba7e97b1e324118b8156.js +1 -0
  127. package/assets/esri/core/workers/chunks/bb4aefaf9b0327dda738.js +1 -0
  128. package/assets/esri/core/workers/chunks/{9664d9e679abc41f6c42.js → bce81df760f5e34c01d7.js} +1 -1
  129. package/assets/esri/core/workers/chunks/be6a05d5375e80968877.js +1 -0
  130. package/assets/esri/core/workers/chunks/c02b09f16241db233103.js +1 -0
  131. package/assets/esri/core/workers/chunks/c09cba77ee60a3d765e2.js +1 -0
  132. package/assets/esri/core/workers/chunks/c0d6336c10b4081c4e32.js +1 -0
  133. package/assets/esri/core/workers/chunks/c27842a34e73ccb46116.js +1 -0
  134. package/assets/esri/core/workers/chunks/c7802c144959d60e774a.js +1 -0
  135. package/assets/esri/core/workers/chunks/c91201b37d1cb3875fb4.js +1 -0
  136. package/assets/esri/core/workers/chunks/cc4ae105e727d9211d82.js +1 -0
  137. package/assets/esri/core/workers/chunks/cd39a53ef74f47604977.js +1 -0
  138. package/assets/esri/core/workers/chunks/d22e0d733bfe821c0510.js +1 -0
  139. package/assets/esri/core/workers/chunks/{d7878fba02814adaf19f.js → d57577c02fb2932e8305.js} +1 -1
  140. package/assets/esri/core/workers/chunks/d62193323c67b379dee3.js +1 -0
  141. package/assets/esri/core/workers/chunks/d7a62504e00989202c45.js +1 -0
  142. package/assets/esri/core/workers/chunks/{adfe28c1c1619cdd3ca1.js → d8511e71c5108a0ba9eb.js} +2 -2
  143. package/assets/esri/core/workers/chunks/da922e861d5845ae0979.js +1 -0
  144. package/assets/esri/core/workers/chunks/dbe55d4731227d6e9571.js +1 -0
  145. package/assets/esri/core/workers/chunks/de05c59da6d67716795d.js +1 -0
  146. package/assets/esri/core/workers/chunks/de60421029fbcebe2950.js +1 -0
  147. package/assets/esri/core/workers/chunks/e00d56ae5e68267fe269.js +1 -0
  148. package/assets/esri/core/workers/chunks/{fecae7495e53bb05f282.js → e25be3b6b67ce6b03011.js} +1 -1
  149. package/assets/esri/core/workers/chunks/e2973e5626e5039209f9.js +1 -0
  150. package/assets/esri/core/workers/chunks/e2c7c269be93c552dc5b.js +1 -0
  151. package/assets/esri/core/workers/chunks/e4d593ddcbcf06010ab0.js +1 -0
  152. package/assets/esri/core/workers/chunks/e5ac9b048b16fef9840c.js +1 -0
  153. package/assets/esri/core/workers/chunks/{f7163048146ddaedfc36.js → e668ddc7332e5e560e78.js} +1 -1
  154. package/assets/esri/core/workers/chunks/e6bab7b739bfbb39f6cd.js +1 -0
  155. package/assets/esri/core/workers/chunks/{8b578ffc3a83089aa782.js → e7c08a03772f7fccd949.js} +1 -1
  156. package/assets/esri/core/workers/chunks/e8e4d48ab4024e17108d.js +1 -0
  157. package/assets/esri/core/workers/chunks/e9e0f1c355f963cbea74.js +1 -0
  158. package/assets/esri/core/workers/chunks/ec7e6427d99cf3148a61.js +1 -0
  159. package/assets/esri/core/workers/chunks/edd3cf415955309b4ca4.js +1 -0
  160. package/assets/esri/core/workers/chunks/ee361690b456c12c30d8.js +1 -0
  161. package/assets/esri/core/workers/chunks/efa95c50d1ed8e74219f.js +1 -0
  162. package/assets/esri/core/workers/chunks/f142c5cbdd16f1768275.js +1 -0
  163. package/assets/esri/core/workers/chunks/f286f13686f003c5eec5.js +1 -0
  164. package/assets/esri/core/workers/chunks/f379fd459a103f42d447.js +1 -0
  165. package/assets/esri/core/workers/chunks/{f2ba50eb29f93df885d6.js → f3d8d5fe15501220792d.js} +1 -1
  166. package/assets/esri/core/workers/chunks/f56906c443ce8ff68a27.js +1 -0
  167. package/assets/esri/core/workers/chunks/fb6670a929b7333f1764.js +1 -0
  168. package/assets/esri/core/workers/chunks/fbdf553253cf8f22c022.js +1 -0
  169. package/assets/esri/core/workers/chunks/fc10c738bae304721ab2.js +1 -0
  170. package/assets/esri/core/workers/chunks/ff79c2cb28db7e0a1fc4.js +1 -0
  171. package/assets/esri/core/workers/chunks/ffdf1cbc1e54414d0f96.js +1 -0
  172. package/assets/esri/themes/base/widgets/_Attribution.scss +7 -4
  173. package/assets/esri/themes/dark/main.css +1 -1
  174. package/assets/esri/themes/light/main.css +1 -1
  175. package/assets/esri/themes/light/view.css +1 -1
  176. package/chunks/Bufferer-Dw9Qi4T1.js +1 -1
  177. package/chunks/Distance2DCalculator-CXhBP-8I.js +1 -1
  178. package/chunks/Envelope.js +1 -1
  179. package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +1 -1
  180. package/chunks/GeodeticUtils.js +1 -1
  181. package/chunks/Geometry.js +1 -1
  182. package/chunks/MultiPathImpl.js +1 -1
  183. package/chunks/OperatorCrosses.js +1 -1
  184. package/chunks/OperatorCut.js +1 -1
  185. package/chunks/OperatorGeodesicBuffer.js +1 -1
  186. package/chunks/OperatorGeodeticArea.js +1 -1
  187. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  188. package/chunks/OperatorGeodeticLength.js +1 -1
  189. package/chunks/OperatorIntersects.js +1 -1
  190. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  191. package/chunks/OperatorOverlaps.js +1 -1
  192. package/chunks/OperatorProject.js +1 -1
  193. package/chunks/OperatorProximity.js +1 -1
  194. package/chunks/OperatorProximityGeodesic.js +1 -1
  195. package/chunks/OperatorShapePreservingLength.js +1 -1
  196. package/chunks/OperatorShapePreservingProject.js +1 -1
  197. package/chunks/OperatorSimplifyOGC.js +1 -1
  198. package/chunks/OperatorTouches.js +1 -1
  199. package/chunks/OperatorWithin.js +1 -1
  200. package/chunks/Point2D.js +1 -1
  201. package/chunks/ProjectionTransformation.js +1 -1
  202. package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
  203. package/chunks/SpatialReference.js +1 -1
  204. package/chunks/boundedPlane.js +1 -1
  205. package/chunks/containsOperator.js +1 -1
  206. package/chunks/disjointOperator.js +1 -1
  207. package/chunks/equalsOperator.js +1 -1
  208. package/chunks/pe.js +1 -1
  209. package/chunks/relateOperator.js +1 -1
  210. package/config.js +1 -1
  211. package/core/units.js +1 -1
  212. package/core/workers/workerFactory.js +1 -1
  213. package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
  214. package/editing/sharedTemplates/executor/builders/support/offsetUtils.js +1 -1
  215. package/editing/sharedTemplates/executor/createTemplateExecutor.js +1 -1
  216. package/geometry/FlatGeometry.js +1 -1
  217. package/geometry/GeometryCursor.js +1 -1
  218. package/geometry/operators/containsOperator.js +1 -1
  219. package/geometry/operators/disjointOperator.js +1 -1
  220. package/geometry/operators/gx/geodeticUtils.js +1 -1
  221. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  222. package/geometry/operators/gx/operatorBuffer.js +1 -1
  223. package/geometry/operators/gx/operatorDifference.js +1 -1
  224. package/geometry/operators/gx/operatorGeodesicBuffer.js +1 -1
  225. package/geometry/operators/gx/operatorGeodeticArea.js +1 -1
  226. package/geometry/operators/gx/operatorGeodeticDensify.js +1 -1
  227. package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
  228. package/geometry/operators/gx/operatorGeodeticLength.js +1 -1
  229. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  230. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  231. package/geometry/operators/gx/operatorIntersection.js +1 -1
  232. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  233. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  234. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  235. package/geometry/operators/gx/operatorProject.js +1 -1
  236. package/geometry/operators/gx/operatorProximityGeodesic.js +1 -1
  237. package/geometry/operators/gx/operatorShapePreservingProject.js +1 -1
  238. package/geometry/operators/gx/operatorSimplify.js +1 -1
  239. package/geometry/operators/gx/operatorSinglePartToMultiPart.js +1 -1
  240. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  241. package/geometry/operators/gx/operatorUnion.js +1 -1
  242. package/geometry/operators/json/containsOperator.js +1 -1
  243. package/geometry/operators/json/disjointOperator.js +1 -1
  244. package/geometry/operators/json/projectOperator.js +1 -1
  245. package/geometry/operators/projectOperator.js +1 -1
  246. package/geometry/operators/reshapeOperator.js +1 -1
  247. package/geometry/operators/support/geographicTransformationUtils.js +1 -1
  248. package/geometry/operators/support/initNoPeFactory.js +1 -1
  249. package/geometry/operators/support/jsonConverter.js +1 -1
  250. package/geometry/operators/support/projectionTransformation.js +1 -1
  251. package/geometry/operators/support/projectionZScaling.js +5 -0
  252. package/geometry/projection/projectPointToVector.js +1 -1
  253. package/geometry/projectionUtils.js +1 -1
  254. package/geometry/support/boundedPlane.js +1 -1
  255. package/geometry/support/jsonTypeUtils.js +5 -0
  256. package/geometry/support/jsonUtils.js +1 -1
  257. package/geometry/support/normalizeUtilsCommon.js +1 -1
  258. package/geometry/support/normalizeUtilsSync.js +1 -1
  259. package/geometry/support/quantizationUtils.js +1 -1
  260. package/geometry/support/zscale.js +1 -1
  261. package/interfaces.d.ts +84 -17
  262. package/kernel.js +1 -1
  263. package/layers/SceneLayer.js +1 -1
  264. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  265. package/layers/graphics/data/QueryEngine.js +1 -1
  266. package/layers/graphics/data/queryUtils.js +1 -1
  267. package/layers/graphics/data/spatialQuerySupport.js +1 -1
  268. package/layers/graphics/featureConversionUtils.js +1 -1
  269. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  270. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  271. package/layers/graphics/sources/support/uploadAssets.js +1 -1
  272. package/layers/mixins/ArcGISMapService.js +1 -1
  273. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  274. package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
  275. package/layers/orientedImagery/transformations/utils.js +1 -1
  276. package/layers/support/ControlPointsGeoreference.js +1 -1
  277. package/layers/support/Sublayer.js +1 -1
  278. package/package.json +4 -4
  279. package/renderers/support/DictionaryLoader.js +1 -1
  280. package/renderers/support/pointCloud/PointSizeFixedSizeAlgorithm.js +1 -1
  281. package/renderers/support/pointCloud/PointSizeSplatAlgorithm.js +1 -1
  282. package/rest/geometryService/cut.js +1 -1
  283. package/rest/geometryService/difference.js +1 -1
  284. package/rest/geometryService/intersect.js +1 -1
  285. package/rest/geometryService/project.js +1 -1
  286. package/rest/geometryService/reshape.js +1 -1
  287. package/rest/geometryService/simplify.js +1 -1
  288. package/rest/geometryService/utils.js +1 -1
  289. package/rest/knowledgeGraph/DataModel.js +1 -1
  290. package/rest/operations/generalize.js +1 -1
  291. package/rest/operations/identify.js +1 -1
  292. package/rest/operations/offset.js +1 -1
  293. package/rest/operations/relation.js +1 -1
  294. package/rest/query/operations/queryAttributeBins.js +1 -1
  295. package/rest/query/operations/queryTopFeatures.js +1 -1
  296. package/rest/query/operations/queryUtils.js +1 -1
  297. package/rest/support/BaseImageMeasureResultValue.js +1 -1
  298. package/rest/support/BufferParameters.js +1 -1
  299. package/rest/support/DensifyParameters.js +1 -1
  300. package/rest/support/DistanceParameters.js +1 -1
  301. package/rest/support/FeatureSet.js +1 -1
  302. package/rest/support/IdentifyParameters.js +1 -1
  303. package/rest/support/ImageAreaParameters.js +1 -1
  304. package/rest/support/ImageDistanceParameters.js +1 -1
  305. package/rest/support/ImageGPSInfoParameters.js +1 -1
  306. package/rest/support/ImageHeightParameters.js +1 -1
  307. package/rest/support/ImageHistogramParameters.js +1 -1
  308. package/rest/support/ImageIdentifyParameters.js +1 -1
  309. package/rest/support/ImageMeasureResultAngleValue.js +1 -1
  310. package/rest/support/ImageMeasureResultAreaValue.js +1 -1
  311. package/rest/support/ImageMeasureResultLengthValue.js +1 -1
  312. package/rest/support/ImagePointParameters.js +1 -1
  313. package/rest/support/ImageSampleParameters.js +1 -1
  314. package/rest/support/ImageToMapMultirayParameters.js +1 -1
  315. package/rest/support/ImageToMapParameters.js +1 -1
  316. package/rest/support/ImageVolumeParameters.js +1 -1
  317. package/rest/support/MapToImageParameters.js +1 -1
  318. package/rest/support/MeasureFromImageParameters.js +1 -1
  319. package/rest/support/ProjectParameters.js +1 -1
  320. package/support/modeUtils.js +1 -1
  321. package/support/revision.js +1 -1
  322. package/support/tests/serviceMockDependencies.js +1 -1
  323. package/symbols/MarkerSymbol.js +1 -1
  324. package/symbols/PictureMarkerSymbol.js +1 -1
  325. package/symbols/SimpleFillSymbol.js +1 -1
  326. package/symbols/SimpleMarkerSymbol.js +1 -1
  327. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  328. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  329. package/symbols/cim/SDFHelper.js +1 -1
  330. package/symbols/cim/effects/EffectOffset.js +1 -1
  331. package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
  332. package/symbols/support/ObjectSymbol3DLayerResource.js +1 -1
  333. package/views/2d/analysis/ElevationProfile/ElevationProfileVisualization2D.js +1 -1
  334. package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
  335. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  336. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  337. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  338. package/views/2d/layers/MediaLayerView2D.js +1 -1
  339. package/views/2d/layers/TileLayerView2D.js +1 -1
  340. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  341. package/views/2d/layers/graphics/GraphicStoreItem.js +1 -1
  342. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  343. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  344. package/views/3d/analysis/ShadowCast/analysisViewRegister.js +5 -0
  345. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  346. package/views/3d/analysis/Slice/SliceController.js +1 -1
  347. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  348. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  349. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  350. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  351. package/views/3d/analysis/support/projectionUtils.js +1 -1
  352. package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
  353. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
  354. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  355. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  356. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  357. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  358. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  359. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  360. package/views/3d/layers/RouteLayerView3D.js +1 -1
  361. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  362. package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
  363. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  364. package/views/3d/layers/support/featureReference.js +1 -1
  365. package/views/3d/state/ScreenSizePerspective.js +1 -1
  366. package/views/3d/support/ViewSlice.js +1 -1
  367. package/views/3d/support/cameraUtils.js +1 -1
  368. package/views/3d/support/viewpointUtils.js +1 -1
  369. package/views/3d/webgl-engine/effects/glow/GlowPresets.glsl.js +1 -1
  370. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  371. package/views/3d/webgl-engine/lib/SliceHelper.js +1 -1
  372. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  373. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  374. package/views/Attribution.js +1 -1
  375. package/views/DOMContainer.js +1 -1
  376. package/views/PopupView.js +1 -1
  377. package/views/SceneView.js +1 -1
  378. package/views/VideoView.js +1 -1
  379. package/views/View.js +1 -1
  380. package/views/View2D.js +1 -1
  381. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +1 -1
  382. package/views/draw/DrawAction.js +1 -1
  383. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  384. package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
  385. package/views/layers/CatalogFootprintLayerView.js +1 -1
  386. package/views/layers/LayerView.js +1 -1
  387. package/views/support/attributionUtils.js +1 -1
  388. package/views/support/projectionUtils.js +1 -1
  389. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  390. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  391. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  392. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  393. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  394. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  395. package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
  396. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  397. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  398. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  399. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  400. package/widgets/OrientedImageryViewer/support/NonPanoramicMedia.js +5 -0
  401. package/widgets/OrientedImageryViewer/support/NonPanoramicMediaCollection.js +5 -0
  402. package/widgets/OrientedImageryViewer/support/urlUtils.js +5 -0
  403. package/widgets/OrientedImageryViewer/utils.js +1 -1
  404. package/widgets/OrientedImageryViewer.js +1 -1
  405. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  406. package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
  407. package/widgets/PanoramicViewer/utils.js +1 -1
  408. package/widgets/PanoramicViewer.js +1 -1
  409. package/widgets/Slice.js +1 -1
  410. package/widgets/Swipe/SwipeViewModel.js +1 -1
  411. package/widgets/TimeSlider.js +1 -1
  412. package/widgets/Track.js +1 -1
  413. package/widgets/UtilityNetworkAssociations.js +1 -1
  414. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  415. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  416. package/widgets/Weather.js +1 -1
  417. package/widgets/support/GridControls.js +1 -1
  418. package/widgets/support/SnappingControls.js +1 -1
  419. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js +1 -1
  420. package/assets/esri/core/workers/chunks/00ff4ca88c9d291d82c3.js +0 -1
  421. package/assets/esri/core/workers/chunks/0271a2ca4e9b1e4fd284.js +0 -1
  422. package/assets/esri/core/workers/chunks/02a65563779b4c64b2cf.js +0 -1
  423. package/assets/esri/core/workers/chunks/02d1c48e874dfd985bc4.js +0 -1
  424. package/assets/esri/core/workers/chunks/05b7720ab6bf0874f27c.js +0 -1
  425. package/assets/esri/core/workers/chunks/061def9163a09c804b5c.js +0 -1
  426. package/assets/esri/core/workers/chunks/06221ebadab32111e2c6.js +0 -1
  427. package/assets/esri/core/workers/chunks/063045ac5553e91c0c4c.js +0 -1
  428. package/assets/esri/core/workers/chunks/06d52a570d5d44f8c86e.js +0 -1
  429. package/assets/esri/core/workers/chunks/0a58b57e1777a8b0ea23.js +0 -1
  430. package/assets/esri/core/workers/chunks/0e4d0213d568f50c231f.js +0 -1
  431. package/assets/esri/core/workers/chunks/103153951ba312dc5e9e.js +0 -1
  432. package/assets/esri/core/workers/chunks/169be08394c5e7703628.js +0 -1
  433. package/assets/esri/core/workers/chunks/1a6f3531ef3d671e0289.js +0 -1
  434. package/assets/esri/core/workers/chunks/1c816aff8613d1e4bf38.js +0 -1
  435. package/assets/esri/core/workers/chunks/1e2d42e9984ed3437ba2.js +0 -1
  436. package/assets/esri/core/workers/chunks/2008b22f76071a2dde4e.js +0 -1
  437. package/assets/esri/core/workers/chunks/20e4243ea563d05a5256.js +0 -1
  438. package/assets/esri/core/workers/chunks/2107c93d1fe87f3b8dfa.js +0 -1
  439. package/assets/esri/core/workers/chunks/21f37a4b8d1857369203.js +0 -1
  440. package/assets/esri/core/workers/chunks/229e1ed4282005aa0b83.js +0 -1
  441. package/assets/esri/core/workers/chunks/22b8eaa6afab0e5ffc47.js +0 -1
  442. package/assets/esri/core/workers/chunks/231c0b583fa97f2ca675.js +0 -1
  443. package/assets/esri/core/workers/chunks/233f9eb617f3d72995b5.js +0 -1
  444. package/assets/esri/core/workers/chunks/2463cebf904a3c46c639.js +0 -1
  445. package/assets/esri/core/workers/chunks/249504f7d356be80d214.js +0 -1
  446. package/assets/esri/core/workers/chunks/2550d2ba935cfdf30236.js +0 -1
  447. package/assets/esri/core/workers/chunks/273ac1066095d63d6a6f.js +0 -1
  448. package/assets/esri/core/workers/chunks/28db329528def851efd7.js +0 -1
  449. package/assets/esri/core/workers/chunks/2de32649f8b0c6404d7c.js +0 -1
  450. package/assets/esri/core/workers/chunks/2e2867bc66c94aba7dc7.js +0 -1
  451. package/assets/esri/core/workers/chunks/30c4af16e3a2acc25589.js +0 -1
  452. package/assets/esri/core/workers/chunks/32d32d3c3b38a215d20d.js +0 -1
  453. package/assets/esri/core/workers/chunks/3386d4392f465b807b94.js +0 -1
  454. package/assets/esri/core/workers/chunks/34613b288cf174983f8b.js +0 -1
  455. package/assets/esri/core/workers/chunks/35f086a2ae0585348ae6.js +0 -1
  456. package/assets/esri/core/workers/chunks/37ea150dec5e491f691e.js +0 -1
  457. package/assets/esri/core/workers/chunks/3ac8de121a07c70bae0f.js +0 -1
  458. package/assets/esri/core/workers/chunks/3c94db7ecdcd38eeb1b1.js +0 -1
  459. package/assets/esri/core/workers/chunks/3f7749f06ae54a4437d9.js +0 -1
  460. package/assets/esri/core/workers/chunks/40a722933af28823953b.js +0 -1
  461. package/assets/esri/core/workers/chunks/444026d1938c1078ca97.js +0 -1
  462. package/assets/esri/core/workers/chunks/44f759d723ae05bb1b19.js +0 -1
  463. package/assets/esri/core/workers/chunks/456684b1c1417ed0e611.js +0 -1
  464. package/assets/esri/core/workers/chunks/48e2737182c75005fb8f.js +0 -1
  465. package/assets/esri/core/workers/chunks/48f805929fe6241952f5.js +0 -1
  466. package/assets/esri/core/workers/chunks/4a48b8ec5f3f2fd139b5.js +0 -1
  467. package/assets/esri/core/workers/chunks/4b084f985bc4100e7aec.js +0 -1
  468. package/assets/esri/core/workers/chunks/4b1de1fcd13677b615a8.js +0 -1
  469. package/assets/esri/core/workers/chunks/4d933de84afb2e3b7d18.js +0 -1
  470. package/assets/esri/core/workers/chunks/4f0de45a0a295d66d446.js +0 -1
  471. package/assets/esri/core/workers/chunks/4ff771942531fb2755c4.js +0 -1
  472. package/assets/esri/core/workers/chunks/513a4ef960e27500f986.js +0 -1
  473. package/assets/esri/core/workers/chunks/56b693baa376bb990925.js +0 -1
  474. package/assets/esri/core/workers/chunks/57fd5e1260269002d18a.js +0 -1
  475. package/assets/esri/core/workers/chunks/5b73c77587772120b209.js +0 -1
  476. package/assets/esri/core/workers/chunks/5fe40bb0e9ab333f6854.js +0 -1
  477. package/assets/esri/core/workers/chunks/61373d2fa7e7638d3395.js +0 -1
  478. package/assets/esri/core/workers/chunks/6202922b1c2637e9aaa5.js +0 -1
  479. package/assets/esri/core/workers/chunks/633368ae6fbb46373328.js +0 -1
  480. package/assets/esri/core/workers/chunks/6d0fe4db6b94f3d2c53a.js +0 -1
  481. package/assets/esri/core/workers/chunks/6d702cb26cef46a76963.js +0 -1
  482. package/assets/esri/core/workers/chunks/6e8925412fb90f88d688.js +0 -1
  483. package/assets/esri/core/workers/chunks/6e8c20ff1d28ef2fe72c.js +0 -1
  484. package/assets/esri/core/workers/chunks/708aba69a1870ea41a61.js +0 -1
  485. package/assets/esri/core/workers/chunks/74b1028e95f7cfff387b.js +0 -1
  486. package/assets/esri/core/workers/chunks/755ce019c97f5d527772.js +0 -1
  487. package/assets/esri/core/workers/chunks/780f60210878a8286633.js +0 -1
  488. package/assets/esri/core/workers/chunks/78fccea3445fb2f9120a.js +0 -1
  489. package/assets/esri/core/workers/chunks/7d3c2a063598bdd015e2.js +0 -1
  490. package/assets/esri/core/workers/chunks/7eab0bb42f9f062522ef.js +0 -1
  491. package/assets/esri/core/workers/chunks/804958f3f4ff47a4eff5.js +0 -1
  492. package/assets/esri/core/workers/chunks/82ba4140e30f083fbc87.js +0 -1
  493. package/assets/esri/core/workers/chunks/833fd2bc42c5cb459084.js +0 -1
  494. package/assets/esri/core/workers/chunks/83c8e5a92d8d6193cb32.js +0 -1
  495. package/assets/esri/core/workers/chunks/83da9ee6544ee9d3c124.js +0 -1
  496. package/assets/esri/core/workers/chunks/870022661376442411e4.js +0 -1
  497. package/assets/esri/core/workers/chunks/897ce6fc9cefb1e14a64.js +0 -1
  498. package/assets/esri/core/workers/chunks/898ab7db220e81e921c6.js +0 -1
  499. package/assets/esri/core/workers/chunks/8b75861196d1ce5cba63.js +0 -1
  500. package/assets/esri/core/workers/chunks/8c07396e9ea3007d6404.js +0 -1
  501. package/assets/esri/core/workers/chunks/8e26831f71634288f834.js +0 -1
  502. package/assets/esri/core/workers/chunks/8ec238b5b59ef18a1713.js +0 -1
  503. package/assets/esri/core/workers/chunks/90b8ccee883738917a6d.js +0 -1
  504. package/assets/esri/core/workers/chunks/90bc9c299ae0e8b8b5e5.js +0 -1
  505. package/assets/esri/core/workers/chunks/9100330ed4b4437c819d.js +0 -1
  506. package/assets/esri/core/workers/chunks/933dce4d4ff8b90219c8.js +0 -1
  507. package/assets/esri/core/workers/chunks/934bc1028b287f8df4aa.js +0 -1
  508. package/assets/esri/core/workers/chunks/94dc8b0fa129f1e168c4.js +0 -1
  509. package/assets/esri/core/workers/chunks/96055de47831e59a28bf.js +0 -1
  510. package/assets/esri/core/workers/chunks/963ba863e0f87abfca25.js +0 -1
  511. package/assets/esri/core/workers/chunks/987e19af8a525e77883f.js +0 -1
  512. package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.js +0 -1
  513. package/assets/esri/core/workers/chunks/9aa8d60483ad905fe13b.js +0 -1
  514. package/assets/esri/core/workers/chunks/9c0efd06c9000ccbd62d.js +0 -1
  515. package/assets/esri/core/workers/chunks/9f1d3c0b53bef07e39bf.js +0 -1
  516. package/assets/esri/core/workers/chunks/9fed9946241bb2a5cfa4.js +0 -1
  517. package/assets/esri/core/workers/chunks/a2662e98857f0abf8e82.js +0 -1
  518. package/assets/esri/core/workers/chunks/a59dab47a58695c639da.js +0 -1
  519. package/assets/esri/core/workers/chunks/a5a9b0a35849b9f2e86d.js +0 -1
  520. package/assets/esri/core/workers/chunks/a60006c9ccf6817fc0d2.js +0 -1
  521. package/assets/esri/core/workers/chunks/a627b7eb94b7fca33210.js +0 -1
  522. package/assets/esri/core/workers/chunks/a651dc3b8f1fc1ab34cc.js +0 -1
  523. package/assets/esri/core/workers/chunks/a96742e678a506c461ab.js +0 -1
  524. package/assets/esri/core/workers/chunks/af663e81c851bcf142f1.js +0 -1
  525. package/assets/esri/core/workers/chunks/af8d6e6949930d0e6c7b.js +0 -1
  526. package/assets/esri/core/workers/chunks/b59be95949445ff5afab.js +0 -1
  527. package/assets/esri/core/workers/chunks/b6dec5dfdeca54bae88d.js +0 -1
  528. package/assets/esri/core/workers/chunks/b88dc7d8ae105747e6a4.js +0 -1
  529. package/assets/esri/core/workers/chunks/b90c786dd474ea1a409c.js +0 -1
  530. package/assets/esri/core/workers/chunks/b92e9e5df8154a128982.js +0 -1
  531. package/assets/esri/core/workers/chunks/bbdfa8ffcf084cbd9938.js +0 -1
  532. package/assets/esri/core/workers/chunks/bff814d34b38ec80c44d.js +0 -1
  533. package/assets/esri/core/workers/chunks/c36d699a75b6e8fb93eb.js +0 -1
  534. package/assets/esri/core/workers/chunks/c50fdf723f2d4316862e.js +0 -1
  535. package/assets/esri/core/workers/chunks/c5e8ff4721b15ac3c6eb.js +0 -1
  536. package/assets/esri/core/workers/chunks/ca61077e0a598654f33f.js +0 -1
  537. package/assets/esri/core/workers/chunks/ca81be5bdb88ef557bf3.js +0 -1
  538. package/assets/esri/core/workers/chunks/ced12ad98f8f48d0dc00.js +0 -1
  539. package/assets/esri/core/workers/chunks/d0320ca67abca4f8b0d2.js +0 -1
  540. package/assets/esri/core/workers/chunks/d561624ddb9388732b25.js +0 -1
  541. package/assets/esri/core/workers/chunks/d5fd6d0eaf96edfab123.js +0 -1
  542. package/assets/esri/core/workers/chunks/d705410c369bd03b1875.js +0 -1
  543. package/assets/esri/core/workers/chunks/d82e17522ed946c2d809.js +0 -1
  544. package/assets/esri/core/workers/chunks/dc29cb16704e2e4d0a46.js +0 -1
  545. package/assets/esri/core/workers/chunks/dc5075b2326c79130baa.js +0 -1
  546. package/assets/esri/core/workers/chunks/dd105d6e0fcedee32644.js +0 -1
  547. package/assets/esri/core/workers/chunks/defc6b50df5018bd9e86.js +0 -1
  548. package/assets/esri/core/workers/chunks/e1148067ceae7d9eaaf8.js +0 -1
  549. package/assets/esri/core/workers/chunks/e5a6a646f27715152714.js +0 -1
  550. package/assets/esri/core/workers/chunks/e8c2e2fbe9cef4c8a8c6.js +0 -1
  551. package/assets/esri/core/workers/chunks/efc293c8bbc12156096d.js +0 -1
  552. package/assets/esri/core/workers/chunks/f693a4d97b2762d0e6ff.js +0 -1
  553. package/assets/esri/core/workers/chunks/f7f53567b0c5b35d6aea.js +0 -1
  554. package/assets/esri/core/workers/chunks/f92a78ce5510e0d0d0f7.js +0 -1
  555. package/assets/esri/core/workers/chunks/fb76b43181077c55a207.js +0 -1
  556. package/assets/esri/core/workers/chunks/fc61443546f21869f8ba.js +0 -1
  557. package/assets/esri/core/workers/chunks/fdaa10a588db394e2f65.js +0 -1
  558. package/chunks/UnitFactory.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{a as t,G as e,t as s,g as n,q as i,d as r,B as o,z as a,i as h,C as u,f as m,e as l,h as c,n as g,p as d,D as _,j as p,o as f}from"./Geometry.js";import{K as P,L as y,M as x,E as C,N as v,V as b,O as S,d as E,Q as D,R as w,U as A,q as T,W as I,X as M,Y,Z as N,_ as X,$ as q,P as F,D as V,a0 as L,a1 as R,a2 as z,t as B,a3 as k,S as G,B as W,A as j,T as Z,a4 as H}from"./Envelope.js";import{E as U,K as O,c as Q,a3 as K,P as $,a4 as J,M as tt,d as et,b as st,q as nt,a5 as it,X as rt,a6 as ot,U as at,g as ht,m as ut,a7 as mt,a8 as lt,H as ct,s as gt,a9 as dt,i as _t,O as pt,aa as ft,F as Pt,ab as yt,ac as xt,L as Ct,ad as vt,ae as bt,af as St,ag as Et,ah as Dt,ai as wt,aj as At,ak as Tt,o as It,al as Mt,l as Yt,j as Nt,e as Xt,am as qt,an as Ft,ao as Vt,ap as Lt,aq as Rt,ar as zt,a as Bt,R as kt,as as Gt,v as Wt,at as jt,au as Zt,w as Ht,av as Ut,aw as Ot,ax as Qt,n as Kt,ay as $t,az as Jt,aA as te,aB as ee,aC as se,u as ne,aD as ie,aE as re,aF as oe,aG as ae,aH as he,aI as ue,a1 as me}from"./Point2D.js";import{Envelope2D as le}from"./Envelope2D.js";import{T as ce}from"./Transformation2D.js";import{G as ge}from"./SimpleGeometryCursor.js";class de extends ge{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class _e{constructor(e){this.m_geoms=[],this.m_description=P(),e&&(e.vd?this.m_description=e.vd:e.copy?e.copy.copyTo(this):t("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===e.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(e){return(e<0||e>=this.m_geoms.length)&&t("Geometry_collection.get_geometry"),this.m_geoms[e]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return e.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new U;const n=new U;n.setEmpty();for(const i of this.m_geoms)s=i.queryInterval(t,e),n.merge(s);return n}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new C;t.setEmpty(),t.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){const e=new le;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}s("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new le;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}s("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(const e of this.m_geoms)e.applyTransformation(t);s("3d xform not impl")}transformAttribute(t,e,s,n,i){for(const r of this.m_geoms)r.transformAttribute(t,e,s,n,i)}createInstance(){return new _e({vd:this.getDescription()})}copyTo(s){s.getGeometryType()!==e.enumGeometryCollection&&t("");const n=s;if(n!==this){n.m_geoms.length=0,n.assignVertexDescription(this.m_description);for(const t of this.m_geoms)n.m_geoms.push(t.clone())}}calculateArea2D(){const t=new O(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new O(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return n(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const s of this.m_geoms){const t=s.getBoundary();t&&e.m_geoms.push(t)}return t}clone(){return new _e({copy:this})}equals(t,s){if(t===this)return!0;if(t.getGeometryType()!==e.enumGeometryCollection)return!1;const n=t;if(this.m_description!==n.m_description)return!1;if(this.m_geoms.length!==n.m_geoms.length)return!1;for(let e=0;e<this.m_geoms.length;++e)if(!this.m_geoms[e].equals(n.m_geoms[e],s))return!1;return!0}swap(s){s.getGeometryType()!==e.enumGeometryCollection&&t("");const n=s;n!==this&&(this.m_geoms=Q(n.m_geoms,n.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const n of this.m_geoms)n.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=v(e,t);this.assignVertexDescription(s)}}function pe(t,e=-1){return new de(t,e)}_e.type=e.enumGeometryCollection;class fe{constructor(){this.m_EnvelopeType=5,this.envAabb=le.constructEmpty(),this.envRot=le.constructEmpty()}static constructEmpty(){return new fe}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:xe(t),y:Ce(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(xe(t),Ce(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let n=s;n<e;n++){const e=xe(t[n]),s=Ce(t[n]);this.envRot.mergeNeCoords(e,s)}break}{const e=xe(t[s]),n=Ce(t[s]);this.envRot.setCoords({x:e,y:n}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(xe(t),Ce(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*K();this.envRot.inflateCoords(e,e),e<0&&fe.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}sqrMaxMinDistance(t){const e=this.envAabb.sqrMaxMinDistance(t),s=this.envRot.sqrMaxMinDistance(ve(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(ve(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(ve(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=Pe(t.x,t.y),n=ye(t.x,t.y);e.setCoords(s,n)}}function Pe(t,e){return t-e}function ye(t,e){return t+e}function xe(t){return t.x-t.y}function Ce(t){return t.x+t.y}function ve(t){return new $(xe(t),Ce(t))}class be{constructor(){this.x=rt.getNAN(),this.y=rt.getNAN()}static getNAN(){return new be}static constructPoint2D(t){const e=new be;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new be;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new be;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new be).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new be;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new be;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=ot.clone(),this.y=at.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),n=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),n=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return $.construct(this.x.value(),this.y.value())}}class Se{constructor(){this.a11=new rt(1),this.a12=new rt(0),this.a21=new rt(0),this.a22=new rt(1)}clone(){const t=new Se;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),n=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),i=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=n,this.a22=i,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),n=this.a21.negate().divThisE(t),i=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=n,this.a22=i}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=Q(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let n=new rt(1),i=new rt(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new rt(1);if(this.a11.ne(this.a22)){const r=this.a11.subE(this.a22).divE(s);r.mulThisByPower2(.5);const o=r.sqr();e.setE(r),e.absThis(),e.subThisE(o.add(1).sqrtThis()),r.gt(at)&&e.negateThis();const a=e.sqr().addThis(1).sqrtThis().invThis();i=e.mulE(a),n.setE(a);const h=e.mulE(s);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else n=new rt(1/Math.sqrt(2)),i=n.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=n.toDouble(),e[0].y=i.toDouble(),e[1].x=i.negate().toDouble(),e[1].y=n.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=Q(t[0],t[0]=t[1]),e[1]=Q(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class Ee{static constructPoint2D(t){return new Ee(tt.constructDouble(t.x),tt.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new tt).setNAN(),void(this.y=(new tt).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new $(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new Ee(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new Ee(this.x.add(t.x),this.y.add(t.y))}sub(t){return new Ee(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}subThis(t){return this.x.subThis(t.x),this.y.subThis(t.y),this}addThis(t){return this.x.addThis(t.x),this.y.addThis(t.y),this}}var De=b;function we(t){let e=!1;for(let s=0;s<2;s++){const n=J(t[0][s],t[3][s]);n>0?(J(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),J(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),J(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),J(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),J(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):n<0?(J(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),J(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),J(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),J(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),J(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function Ae(t){const e=J(t[0].y,t[1].y),s=J(t[1].y,t[2].y),n=J(t[2].y,t[3].y);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0){const e=J(t[0].x,t[1].x),s=J(t[1].x,t[2].x),n=J(t[2].x,t[3].x);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0)return!0}return!1}function Te(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const n=t.getEndXY();return!!n.equals(e.getStartXY())||!!n.equals(e.getEndXY())}function Ie(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Me(t,s,n){const i=ut($,4);let r=t.queryControlPointsHelper(i);const o=ut($,4);let h=s.queryControlPointsHelper(o);i[0].equals(o[0])||a("");const u=t.getGeometryType();if(u===s.getGeometryType()&&i.map((t,e)=>o[e].equals(t)).reduce((t,e)=>t&&e)){if(u!==e.enumRationalBezier2)return 0;{const e=s,n=[0,0,0],i=[0,0,0];if(t.queryWeights(n),e.queryWeights(i),n.map((t,e)=>i[e]===t).reduce((t,e)=>t&&e))return 0}}for(;r>2&&i[1].equals(i[0]);)i.splice(1,1),r--;for(;h>2&&o[1].equals(o[0]);)o.splice(1,1),h--;(i[1].equals(i[0])||o[1].equals(i[0]))&&a("");const m=$.compareVectorsOrigin(i[0],i[1],o[1]);if(0===m){const e=Ee.constructPoint2D(i[0]),n=new Ee;t.queryCoord2DMP(1e-16,n),n.sub(e);const r=new Ee;s.queryCoord2DMP(1e-16,r),r.sub(e);return r.crossProduct(n).sign()}return m}function Ye(t,e,s,i,r,o,a,h){let u=t.calculateUpperLength2D(),m=e.calculateUpperLength2D(),l=t,c=e,g=!1;u>m&&(c=Q(l,l=c),i=Q(s,s=i),m=Q(u,u=m),g=!0);const d=0===s;{a[0]=d?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if($.distance(t,e)<=r){const e=[.5,.75,.25,.1,.9];let s=!0;for(let n=0;n<e.length;n++)if(t.assign(l.getCoord2D(e[n])),!c.isCloserThanDistance(t,new U(0,1),r)){s=!1;break}if(s)return g&&(h[0]=Q(a[0],a[0]=h[0])),1}}if(u<=3*r)return 0;let _=gt(Math.max(r/u,.1),0,.5),p=.01*r,f=0,P=0,y=_,x=-1,C=0,v=1/32;for(let b=0;;b++){n(b<4095);const t=d?_:1-_,e=l.getCoord2D(t),s=c.getClosestCoordinate(e,!1);if(s===i)return C;const u=c.getCoord2D(s),m=$.distance(e,u);if(0===b&&(x=m),m<=p?(v=.5,P=m,f=_):(y=_,x=m),Math.abs(P-x)>.1*p&&y-f>1e-16)_=nt(f,y,v);else{if(a[C]=t,h[C]=s,g&&(h[C]=Q(a[C],a[C]=h[C])),1===o||1===C)return 1===C&&a[0]>a[1]&&(a[1]=Q(a[0],a[0]=a[1]),h[1]=Q(h[0],h[0]=h[1])),C+1;C++,f=y,P=x,y=.8,x=-1,_=.8,v=1/32,p=10*r,b=0}}}function Ne(t,e,s,n,i,r,o,a,h){if(lt(s,0,1)&&lt(n,0,1)){if(0===$.distance(t.getCoord2D(s),e.getCoord2D(n))){const h=1e-12,u=new be,m=ct();if(t.queryDerivative(new rt(s,m),u),u.isTrueZero()){const e=1===s?-h:h;t.queryDerivative(new rt(s,m).add(e),u)}1===s&&u.negateThis();const l=new be;if(e.queryDerivative(new rt(n,m),l),l.isTrueZero()){const t=1===s?-h:h;e.queryDerivative(new rt(n,m).add(t),l)}1===n&&l.negateThis(),u.isZero()||u.normalize(),l.isZero()||l.normalize();const c=u.dotProduct(l),g=u.crossProduct(l);g.scaleError(3);const d=()=>{{const s=t.calculateUpperLength2D(),n=e.calculateUpperLength2D();return Math.min(.01*i/Math.min(s,n),1e-10)}};if(c.ge(at)&&(g.isZero()||Math.abs(g.value())<d())){return Ye(t,e,s,n,i,r,o,a)}}}return 0}function Xe(t,e,s){if(n(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(Ne(t,e,0,0,s,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(Ne(t,e,1,1,s,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(Ne(t,e,0,1,s,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(Ne(t,e,1,0,s,2,[0,0],[0,0]))return!0}return!1}function qe(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function Fe(t,e,s){t.m_XStart=e,t.m_YStart=s}function Ve(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function Le(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Re(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}function ze(t,e){const s=new E;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=Be(t,e),s}function Be(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:De.getDefaultValue(1)}function ke(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function Ge(t,e,s){s.assignVertexDescription(t.m_description);const n=0===e?t.m_XStart:t.m_XEnd,i=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(n,i);for(let r=1;r<t.m_description.getAttributeCount();r++){const n=t.m_description.getSemantics(r);for(let i=0,r=De.getComponentCount(n);i<r;i++){const r=je(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function We(t,e,s){s.isEmpty()&&o(""),Re(t,e,s.getXY());const n=s.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let i=1,r=n.getAttributeCount();i<r;i++){const r=n.getSemantics(i),o=De.getComponentCount(r);for(let n=0;n<o;n++){Ze(t,e,r,n,s.getAttributeAsDbl(r,n))}}}function je(t,e,s,n){if((e<0||e>1)&&i(""),0===s)return(n<0||n>=2)&&i(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=De.getComponentCount(s);(n<0||n>=r)&&i("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:De.getDefaultValue(s)}function Ze(t,e,s,n,r){if((e<0||e>1)&&i(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:i(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:i(""):i(""),void t.endPointModified();const o=De.getComponentCount(s);(n<0||n>=o)&&i("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function He(t,e){if(t===e)return;e.isEmpty()&&o("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let n=1,i=s.getAttributeCount();n<i;n++){const i=s.getSemantics(n),r=De.getComponentCount(i);for(let s=0;s<r;s++){let n=je(e,0,i,s);Ze(t,0,i,s,n),n=je(e,1,i,s),Ze(t,1,i,s,n)}}}function Ue(t,e){const s=D();w(e,t.m_description,s);let n=null;const i=e.getTotalComponentCount()-2,r=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(i>0&&(n=et(2*i,Number.NaN),st(n,e.getDefaultPointAttributes(),0,2,i),st(n,e.getDefaultPointAttributes(),i,2,i),null!==t.m_description))for(let o=1;o<e.getAttributeCount();o++){const a=s[o];if(-1!==a){const s=t.m_description.getPointAttributeOffset(a)-2,h=e.getPointAttributeOffset(o)-2,u=De.getComponentCount(e.getSemantics(o));for(let e=0;e<u;++e)n[h]=t.m_attributes[s],n[i+h]=t.m_attributes[r+s]}}t.m_attributes=n,t.m_description=e}function Oe(t){return t.absNorm()*ht()}function Qe(t,e){return Math.max(t.absNorm(),e.absNorm())*ht()}function Ke(t,e,s){const n=new fe;t.queryEnvelopeW(U.unit(),n);const i=new fe;return e.queryEnvelopeW(U.unit(),i),i.inflate(s),!n.isIntersectingW(i)}function $e(t,e,s){const n=mt(t,s),i=mt(e,s);n.sort((t,e)=>t.compare(e)),i.sort((t,e)=>t.compare(e));for(let r=0;r<3;r++){if(n[r].compare(i[r])<0)return-1;if(0!==n[r].compare(i[r]))return 1}return 0}var Je=b;class ts{constructor(t){if(t.copy){if(this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description){this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice())}}else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:P(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:S(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=P());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:S(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);r("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=et(2*t,Number.NaN)),st(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),st(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return s("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return s("not implemented"),!1}setCoordsForIntersector3D(t,e,n){s("not implemented")}transformAttribute(t,e,n,i,r){s("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=v(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),n=e.getXY();this.changeEndPoints2D(s,n);let i=t.getDescription();i!==this.getDescription()&&this.mergeVertexDescription(i),i=e.getDescription(),i!==this.getDescription()&&this.mergeVertexDescription(i);for(let r=1,o=i.getAttributeCount();r<o;r++){const s=i.getSemantics(r),n=Je.getComponentCount(s);for(let i=0;i<n;i++){Ze(this,0,s,i,t.getAttributeAsDbl(s,i));Ze(this,1,s,i,e.getAttributeAsDbl(s,i))}}}getStartXY(){return new $(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return ze(this,0)}setStartXYZ(t){ke(this,0,t)}setStartXYZCoords(t,e,s){ke(this,0,E.construct(t,e,s))}queryStart(t){Ge(this,0,t)}setStart(t){We(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return je(this,0,t,e)}getStartAttributeAsInt(t,e){return n(0),0}setStartAttribute(t,e,s){Ze(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=Je.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,n)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=Je.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,n)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return n(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return n(0),0}getEndXY(){return new $(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return ze(this,1)}setEndXYZ(t){ke(this,1,t)}setEndXYZCoords(t,e,s){ke(this,1,E.construct(t,e,s))}queryEnd(t){Ge(this,1,t)}setEnd(t){We(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return je(this,1,t,e)}getEndAttributeAsInt(t,e){return n(0),Math.trunc(0)}setEndAttribute(t,e,s){Ze(this,1,t,e,s)}getDimension(){return 1}copyTo(e){if(this===e)return;e.getGeometryType()!==this.getGeometryType()&&t("");const s=e;s.assignVertexDescription(this.m_description),s.m_attributes&&st(s.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),s.m_XStart=this.m_XStart,s.m_YStart=this.m_YStart,s.m_XEnd=this.m_XEnd,s.m_YEnd=this.m_YEnd,this.copyToImpl(s)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=U.constructEmpty();return s.vmin=je(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(je(this,1,t,e)),s}calculateLength3D(t){return n(0),0}getCoord3D(t){return n(0),{}}getCoord2D(t){const e=$.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){n(0)}getCoordZ(t){return n(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const n=this.m_description.getSemantics(s),i=Je.getComponentCount(n);for(let s=0;s<i;s++){const i=this.getAttributeAsDbl(t,n,s);e.setAttributeBasic(n,s,i)}}}isCloserThanDistance(t,e,s){const n=le.constructEmpty();this.queryLooseEnvelopeOnInterval(e,n);if(n.distance(t)>s)return!1;const i=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(i)&&$.distance(t,this.getCoord2D(i))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=Je.getComponentCount(e);t<s;t++){const s=je(this,0,e,t);Ze(this,0,e,t,je(this,1,e,t)),Ze(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,s,i){if(!e&&this.isIntersecting(t,0,!1)){if(null!==s||null!==i){const e=et(9,Number.NaN),o=et(9,Number.NaN),a=this.intersect(t,null,e,o,0);n(a<=9),0===a&&r(""),null!==s&&(s[0]=e[0]),null!==i&&(i[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,h=-1,u=a;return o=this.getStartXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==i&&(i[0]=h),null!==s&&(s[0]=0)),o=this.getEndXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==i&&(i[0]=h),null!==s&&(s[0]=1)),o=t.getStartXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==s&&(s[0]=h),null!==i&&(i[0]=0)),o=t.getEndXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==s&&(s[0]=h),null!==i&&(i[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return nt(t,e,s)}moveTo(t){const e=this.isClosed(),s=new ce;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){n(0)}getDescription(){return this.m_description}assignVertexDescription(t){Ue(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}swap(e){if(this===e)return;e.getGeometryType()!==this.getGeometryType()&&t("wrong geometry type");const s=e;s.m_description=Q(this.m_description,this.m_description=s.m_description),s.m_XStart=Q(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=Q(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=Q(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=Q(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attributes=Q(this.m_attributes,this.m_attributes=s.m_attributes),this.swapImpl(s)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const n=t;if(this===n)return!0;if(this.m_description!==n.m_description)return!1;if(Math.abs(this.m_XStart-n.m_XStart)>e||Math.abs(this.m_XEnd-n.m_XEnd)>e||Math.abs(this.m_YStart-n.m_YStart)>e||Math.abs(this.m_YEnd-n.m_YEnd)>e)return!1;for(let i=0,r=2*(this.m_description.getTotalComponentCount()-2);i<r;i++)if(!it(this.m_attributes[i],n.m_attributes[i],e))return!1;return s?this.equalsImpl(n):this.equalsImplTol(n,e)}getImpl(){return this}setAttributeBasic(e,s,n){if(this.addAttribute(e),0===e&&this.isCurve()){(s<0||s>1)&&t("");const e=new ce,i=0===s?n:0,r=1===s?n:0;e.setShiftCoords(i,r),0===s?e.xx=0:e.yy=0,this.applyTransformation(e)}else this.setStartAttribute(e,s,n),this.setEndAttribute(e,s,n)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=Je.getComponentCount(t);for(let n=0;n<s;n++){const s=this.getStartAttributeAsDbl(t,n);Number.isNaN(s)&&this.setStartAttribute(t,n,e);const i=this.getEndAttributeAsDbl(t,n);Number.isNaN(i)&&this.setEndAttribute(t,n,e)}}}ts.s_maxMonotonicPartParams=8;class es{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function ss(e,s,n,i,r){(s<0||n<0||i<1||s+i*(n-1)+1>e.size())&&t("Index out of bound");for(let t=s,o=s+i*(n-1)+1;t<o;t+=i)e.writeAsDbl(t,r(e.readAsDbl(t)))}function ns(t,e,s){if(t)for(let n=e.length-1;n>=0;--n)s(e[n]);else e.forEach(s)}function is(t,e){let s=pt(t);const n=e.length/_t();for(let i=0;i<e.length;++i){const t=Math.trunc(s*n);s=pt(s);const i=Math.trunc(s*n),r=e[t];e[t]=e[i],e[i]=r}}function rs(t,e,s){if(0===t.length)return;let n=0,i=0;for(++i;i!==t.length;++i)e(t[n],t[i])||(s(n,i),n=i);s(n,i)}function os(t,e,s,n,i){ft(t,e,n-e,(t,e)=>i(t,e)?-1:1)}function as(t,e,s){if(!(s<=e))for(;e<s;)t[s]=Q(t[e],t[e]=t[s]),e++,s--}function hs(t,e,s,n){as(t,e,s-1),as(t,s,n-1),t.reverse()}function us(t,e,s){const n=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),st(t.getAttributeArray(),e,0,2,n-2)}var ms=b;const ls="can not assign an empty point to a vertex";class cs{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=P(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new es,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new A,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:P();this.m_description=e,this.m_vertexAttributes=new es,this.m_envelopeData=new A,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!h(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const n=this.getPointCount();if(n!==s.getPointCount())return!1;for(let i=0;i<this.m_description.getAttributeCount();i++){const t=this.m_description.getSemantics(i),r=this.getAttributeStreamRef(t),o=s.getAttributeStreamRef(t),a=ms.getComponentCount(t);if(!r.equals(o,0,n*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(e,s,n,i,r){if(this.addAttribute(e),!this.isEmpty()&&(0!==n||1!==i)){if(0===e){const e=new ce;return 0===r?0===s?(e.setShiftCoords(n,0),e.scale(i,1)):1===s?(e.setShiftCoords(0,n),e.scale(1,i)):t(""):0===s?(e.setScaleCoords(1/i,1),e.shiftCoords(-n,0)):1===s?(e.setScaleCoords(1,1/i),e.shiftCoords(0,-n)):t(""),void this.applyTransformation(e)}ss(this.getAttributeStreamRef(e),s,this.getPointCount(),ms.getComponentCount(e),X(n,i,r)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=v(e,t);this.assignVertexDescription(s)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(e){this.throwIfEmpty(),this.m_description.hasAttribute(e)||t("AttributeStream : Geometry does not have the attribute");const s=this.m_description.getAttributeIndex(e);return this.m_vertexAttributes.get(s)}setAttributeStreamRef(e,s){s||t("stream"),s&&ms.getPersistence(e)!==s.getPersistence()&&t(""),this.addAttribute(e);const n=this.m_description.getAttributeIndex(e);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(n,s),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let n=0;n<this.m_description.getAttributeCount();n++){const e=this.m_description.getSemantics(n);for(let i=0,r=ms.getComponentCount(e);i<r;i++){const o=this.m_vertexAttributes.get(n).readAsDbl(r*t+i);s.setAttributeBasic(e,i,o)}}}setPointByValNoCurves(e,s){const n=s;n.isEmpty()&&t(ls);const i=n.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const r=this.m_vertexAttributes.get(0);r.write(2*e,n.getX()),r.write(2*e+1,n.getY());for(let t=1,o=this.m_description.getAttributeCount();t<o;t++){const s=this.m_description.getSemantics(t),i=ms.getComponentCount(s);for(let r=0;r<i;r++){const o=n.getAttributeAsDbl(s,r);this.m_vertexAttributes.get(t).writeAsDbl(e*i+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,s,i){n(0)}getPointByValAsArray(t,e,s,i){n(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=ms.getComponentCount(t);s>=n&&i("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):ms.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=ms.getComponentCount(t);n<r&&i("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,n=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=n.readAsDbl(t+e)}else{const e=ms.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,s,i){n(0)}setAttributeNoCurves(t,e,s,n){const r=ms.getComponentCount(t);s>=r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArrayNoCurves(t,e,s,n){(e<0||e>=this.m_pointCount)&&i("");const r=ms.getComponentCount(t);n<r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let i=0;i<r;++i)a.writeAsDbl(e*r+i,s[i])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXYNoCurves(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoordsNoCurves(t,e,s){const n=this.m_vertexAttributes.get(0);n.write(2*t,e),n.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=E.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=ms.getDefaultValue(1),s}setXYZNoCurves(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y);this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof le||t instanceof T?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=U.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let n=!1;const i=ms.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*i;r<a;r+=i){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),n=!0)}}else for(let a=e,h=this.m_pointCount*i;a<h;a+=i){r.readAsDbl(a)!==s&&(r.writeAsDbl(a,s),n=!0)}n&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const n=ms.getComponentCount(t),i=this.getAttributeStreamRef(t);for(let r=0;r<n;r++)if(1===i.getPersistence()){const t=i;for(let i=0,r=this.m_pointCount*n;i<r;i++){const n=t.read(i);Number.isNaN(n)&&(t.write(i,e),s=!0)}}else for(let t=0,o=this.m_pointCount*n;t<o;t++){const n=i.readAsDbl(t);Number.isNaN(n)&&(i.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return n(0),0}setEnvelopeForImport(e){this.m_description.equals(e.getDescription())||t(""),this.m_envelopeData=new A({moveEnv:e}),this.setDirtyFlagProtected(192,!1)}copyTo(e){e.getGeometryType()!==this.getGeometryType()&&t(""),this!==e&&this.copyToUnchecked(e,!1)}queryCoordinates(e,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&t(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let t=2*n,a=2*r,h=0;t<a;t+=2,h++)o.queryPoint2D(t,e[h]);return r}queryCoordinates3D(e,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&t(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=ms.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let t=n;t<r;t++,m++)e[m].x=o.read(2*t),e[m].y=o.read(2*t+1),e[m].z=u?a.read(t):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const n=t&~e,i=e|n;s=this.m_flags,(s&i)!==e&&(this.m_flags=s&~n|e)}getIsSimple(t,e){e[0]=0;let s=-1;const n=this.m_flags,i=this.m_simpleTolerance;if(!(1&n)){s=(14&n)>>1,e[0]=i,i<t&&(s=-1)}return s}setIsSimple(t,s,i=!1){if(2===t?n(this.getGeometryType()===e.enumPolyline):1===t?n(this.getGeometryType()===e.enumMultiPoint||this.getGeometryType()===e.enumPolyline):3===t&&n(this.getGeometryType()===e.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let e=t<<1;i||(e|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,e),this.m_simpleTolerance!==s&&(this.m_simpleTolerance=s)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,s=!1){s&&this.hasDirtyFlag(32)&&u("Cannot do shallow clone on unprepared geometry");const i=t,r=this.getGeometryType(),o=i.getGeometryType();n(r===o||r===e.enumPolygon&&o===e.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();const a=this.m_description.getAttributeCount(),h=new es;if(!this.m_vertexAttributes.empty()){h.destroyAndSetSize(a);for(let t=0;t<a;t++)if(this.m_vertexAttributes.get(t))if(s)h.set(t,this.m_vertexAttributes.get(t));else{const e=ms.getComponentCount(this.m_description.getSemantics(t));h.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,r!==o){const t=[Number.NaN];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(h),h.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)||i.m_vertexAttributes.empty()?(n(!s||0===i.m_pointCount),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,s)}catch(m){throw i.setEmpty(),m}i.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,s,r){(t<0||t>=this.m_pointCount)&&i(""),(e<0||e>=this.m_pointCount)&&i(""),r.assignVertexDescription(this.m_description);const o=et(ms.maxComponentCount(),Number.NaN),a=et(ms.maxComponentCount(),Number.NaN),h=I();let u=0;for(let i=0;i<this.m_description.getAttributeCount();i++){const r=this.m_description.getSemantics(i),m=ms.getInterpolation(r),l=ms.getComponentCount(r),c=ms.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),n(u+l<=M),dt(m,o,a,h,u,l,s,c),u+=l}us(r,h)}getShortestDistance(t,e){return $.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return $.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(e){if(e<0&&t(),(e=Math.ceil(e))===this.m_pointCount)return;this.m_pointCount=e;const s=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(s)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=D();w(t,this.m_description,e);const s=new es;s.destroyAndSetSize(t.getAttributeCount());for(let n=0;n<t.getAttributeCount();n++){const t=e[n];-1!==t?s.set(n,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return 0!==(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=-1;let t=Number.MAX_SAFE_INTEGER,e=0;e=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let s=0;s<this.m_description.getAttributeCount();s++){const n=this.m_description.getSemantics(s);let i=0;if(null!==this.m_vertexAttributes.get(s)){const t=ms.getComponentCount(n);i=this.m_vertexAttributes.get(s).size()/t,i<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,ms.getDefaultValue(n)),i=e)}else this.m_vertexAttributes.set(s,Y(n,e)),i=e;i<t&&(t=i)}this.m_reservedPointCount=t}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new C({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),n=ms.getComponentCount(e),i=this.m_vertexAttributes.get(t);for(let t=0;t<n;t++){const r=new U;r.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=i.readAsDbl(e*n+t);r.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,r)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new A({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=le.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){n(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof le?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(e,s){if(e<0&&t(""),0===e)return;let n=e=Math.ceil(e);if(this.m_reservedPointCount<n){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),s?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,N(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*n),n=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,N(0,n)):this.m_vertexAttributes.get(0).resize(2*n);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),s=ms.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(n*s):this.m_vertexAttributes.set(t,N(e,n))}this.reserveImplImpl(n,s),this.m_reservedPointCount=n}}reserveRounded(e){e<0&&t(),e=Math.ceil(e),this.reserveImpl(e,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&o("")}exportVertexAttributes(){const t=this.getPointCount(),e=this.m_description.getAttributeIndex(1),s=this.m_description.getAttributeIndex(2),n=this.m_vertexAttributes.posStream,i=e>0?this.m_vertexAttributes.get(e):void 0,r=s>0?this.m_vertexAttributes.get(s):void 0,o=n?.getArray()??new Float64Array,a=i?.getArray(),h=r?.getArray();return{vertexCount:t,vertexXY:o,vertexZ:a,vertexM:h}}}class gs extends cs{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(e,s){e>this.getPointCount()&&t("invalid point index"),e<0&&(e=this.getPointCount());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),r=b.getComponentCount(i);if(0===i)this.m_vertexAttributes.get(t).insert(r*e,s,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(r*e,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoint(e,s){s.isEmpty()&&t(ls),e<0&&(e=this.getPointCount()),this.mergeVertexDescription(s.getDescription());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),r=b.getComponentCount(i);if(s.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(r*e,s,i,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(r*e,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&i(""),t<0&&(t=this.getPointCount()),0===s)return;const n=e[0].getDescription();this.mergeVertexDescription(n);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=b.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(n.hasAttribute(o))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=b.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(e,s,n){if((e>this.getPointCount()||n<0)&&t("invalid point index"),e<0&&(e=this.getPointCount()),0===n)return;const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+n);for(let t=0,r=this.m_description.getAttributeCount();t<r;t++){const r=this.m_description.getSemantics(t),o=b.getComponentCount(r);if(this.m_vertexAttributes.get(t))if(0===r)this.m_vertexAttributes.get(t).insertRangeFromPoints(o*e,s,0,n,!0,o*i);else{const s=b.getDefaultValue(r);this.m_vertexAttributes.get(t).insertRange(o*e,s,o,o*i)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&i("remove_points"),0!==e){for(let s=0,n=this.m_description.getAttributeCount();s<n;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),i=b.getComponentCount(n);this.m_vertexAttributes.get(s).eraseRange(i*t,i*e,i*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),n=b.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(n*t,n,n*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const t=this.m_description.getSemantics(s),n=b.getDefaultValue(t),i=b.getComponentCount(t);this.m_vertexAttributes.get(s).insertRange(i*e,n,i*(this.m_pointCount-e),i*e)}}queryCoordinates3D(e,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&t(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=b.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let t=n;t<r;t++,m++)e[m].x=o.read(2*t),e[m].y=o.read(2*t+1),e[m].z=u?a.read(t):h;return r}queryAttributeAsInt(t,e,s,i){n(0)}add(e){e.isEmpty()&&t(ls),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,e)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new $(t,e);this.setXYNoCurves(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const n=new E;n.setCoords(t,e,s),this.setXYZNoCurves(this.m_pointCount-1,n)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(e,s,n){this===e&&t("Multi_point_impl.add");const i=n<0?e.getPointCount():n;if((s<0||s>e.getPointCount()||i<s)&&t(""),s===i)return;const r=e.getDescription();this.mergeVertexDescription(r);const o=i-s,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let t=0,h=this.m_description.getAttributeCount();t<h;t++){const n=this.m_description.getSemantics(t),i=b.getComponentCount(n),h=this.getAttributeStreamRef(n);if(r.hasAttribute(n)){const t=e.getAttributeStreamRef(n);h.insertRangeFromStream(a*i,t,s*i,o*i,!0,1,a*i)}else{const t=b.getDefaultValue(n);h.insertRange(a*i,t,o*i,a*i)}}}addPoints2D(e,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&t(""),n===o)return;r=o-n;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let t=0;t<r;++t)h.writePoint2D(2*(a+t),e[n+t]);this.notifyModifiedFlags(2001)}addPoints3D(e,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&t(""),this.addAttribute(1),n===o)return;r=o-n;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0),u=new $;for(let t=0;t<r;t++)u.x=e[n+t].x,u.y=e[n+t].y,h.writePoint2D(2*(a+t),u);const m=this.getAttributeStreamRef(1);for(let t=0;t<r;t++)m.write(a+t,e[n+t].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,s){this.setXYCoordsNoCurves(t,e,s)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,s,n){this.setAttributeNoCurves(t,e,s,n)}getGeometryType(){return e.enumMultiPoint}getDimension(){return 0}createInstance(){return new gs({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):s("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,s){return t.getGeometryType()===e.enumMultiPoint&&this.equalsBase(t,s)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):s("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){n(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return n(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}toFlatGeometry(){return{type:"multipoint",...this.exportVertexAttributes(),...q}}}gs.type=e.enumMultiPoint;class ds extends ts{constructor(t){super(t)}}class _s extends ds{isTrue3D(){return!0}constructor(t){super(t)}}function ps(t,e,s){fs(e,t.getStartXY(),t.getEndXY(),s)}function fs(t,e,s,n){Ct(e,s,t,n)}function Ps(t,e){return nt(t.m_XStart,t.m_XEnd,e)}function ys(t,e){return nt(t.m_YStart,t.m_YEnd,e)}function xs(t,e){const s=t.getStartZ(),n=t.getEndZ();return nt(s,n,e)}function Cs(t,e,s){const n=be.constructPoint2D(t.getStartXY()),i=be.constructPoint2D(t.getEndXY());s.setCoordsE(i.x.subE(n.x),i.y.subE(n.y))}function vs(t,e,s){e.value()<=.5?Vt(2,be.constructPoint2D(t.getStartXY()),be.constructPoint2D(t.getEndXY()),e,s):Lt(2,be.constructPoint2D(t.getStartXY()),be.constructPoint2D(t.getEndXY()),e,s)}function bs(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function Ss(t,e){const s=t.getStartXYZ();s.z*=e;const n=t.getEndXYZ();return n.z*=e,s.norm(1)+n.norm(1)}function Es(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=Q(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=Q(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=Q(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function Ds(t,e,s,n){let i=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(i++,!n))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(i++,2===i)return 2;if(!n)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:n&&i?0:Ts(t,e)?4:0}function ws(t,e,s,n,i,r,o,a){null!==n&&Ht(n,2,Number.NaN),null!==i&&Ht(i,2,Number.NaN),null!==s&&Ut(s,$,2);const h=As(t,e,2,s,n,i,r,o,a);return n&&(n.length=h),i&&(i.length=h),s&&(s.length=h),h}function As(t,e,s,n,i,r,o,a,h){const u=Ms(t,e.getStartXY(),o,!1),m=Ms(t,e.getEndXY(),o,!1),l=Ms(e,t.getStartXY(),o,!1),c=Ms(e,t.getEndXY(),o,!1);let g=0,d=0;if(!Number.isNaN(u)){let s=!1;a&&lt(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getStartXY())&&(g++,s=!0),s||(i&&(i[d]=u),r&&(r[d]=0),n&&n[d].setCoords(e.m_XStart,e.m_YStart),d++)}if(!Number.isNaN(m)){let o=!1;a&&lt(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getEndXY())&&(g++,o=!0),o||(s>d&&(i&&(i[d]=m),r&&(r[d]=1),n&&n[d].setCoords(e.m_XEnd,e.m_YEnd)),d++)}if(2!==d&&!Number.isNaN(l)&&!(0===u&&0===l||0===m&&1===l)){let o=!1;a&&lt(l,0,1)&&e.getCoord2D(l).isEqualPoint2D(t.getStartXY())&&(g++,o=!0),o||(s>d&&(i&&(i[d]=0),r&&(r[d]=l),n&&n[d].setCoords(t.m_XStart,t.m_YStart)),d++)}if(2!==d&&!Number.isNaN(c)&&!(1===u&&0===c||1===m&&1===c)){let o=!1;a&&lt(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getEndXY())&&(g++,o=!0),o||(s>d&&(i&&(i[d]=1),r&&(r[d]=c),n&&n[d].setCoords(e.m_XEnd,e.m_YEnd)),d++)}if(d>0)return h&&(r=Q(i,i=r)),2===d&&s>=2&&i&&i[0]>i[1]&&(i[1]=Q(i[0],i[0]=i[1]),r&&(r[1]=Q(r[0],r[0]=r[1])),n&&(n[1]=Q(n[0],n[0]=n[1]))),d;if(g>0)return 0;const _=Fs(t,e,o);return Number.isNaN(_.x)?0:(n&&(n[0]=t.getCoord2D(_.x)),i&&(i[0]=_.x),r&&(r[0]=_.y),1)}function Ts(t,e){const s=Ys(t,e.m_XStart,e.m_YStart),n=Ys(t,e.m_XEnd,e.m_YEnd);if(s<0&&n<0||s>0&&n>0)return!1;const i=Ys(e,t.m_XStart,t.m_YStart),r=Ys(e,t.m_XEnd,t.m_YEnd);if(i<0&&r<0||i>0&&r>0)return!1;return qs(t)>qs(e)?Xs(t,e):Xs(e,t)}function Is(t,e){const s={bIntersect:!1,t1:Number.NaN,t2:Number.NaN},n=t.m_XEnd-t.m_XStart,i=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*i-n*o;if(0===a)return s;const h=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,m=r*u-h*o,l=n*u-h*i,c=1/a;return s.t1=m*c,s.t2=l*c,s.bIntersect=!0,s}function Ms(t,e,s,n){const i=$.getNAN(),r=$.getNAN();let o=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(i.setCoords(t.m_XEnd,t.m_YEnd),r.setCoords(t.m_XStart,t.m_YStart),o=!0):(i.setCoords(t.m_XStart,t.m_YStart),r.setCoords(t.m_XEnd,t.m_YEnd));const a=o?1:0,h=o?0:1,u=$.getNAN();u.setSub(e,i);let m=u.length(),l=3*m*ct();if(m<=Math.max(s,l))return n&&0===m?Number.NaN:a;if(u.setSub(e,r),m=u.length(),l=3*m*ct(),m<=Math.max(s,l))return n&&0===m?Number.NaN:h;u.setCoords(r.x-i.x,r.y-i.y);const c=u.length();if(c>0){const t=1/c;u.scale(t);const n=$.getNAN();n.setSub(e,i);const m=n.dotProduct(u),l=8*n.dotProductAbs(u)*ct();u.leftPerpendicularThis();const g=n.dotProduct(u),d=8*n.dotProductAbs(u)*ct(),_=Math.max(s,l);if(m<-_||m>c+_)return Number.NaN;const p=Math.max(s,d);if(Math.abs(g)<=p){let n=m*t;n=gt(n,0,1);const u=$.getNAN();if(fs(n,i,r,u),$.distance(u,e)<=s){if(n<.5){if($.distance(u,i)<=s&&$.distance(e,i)<=s)return a}else if($.distance(u,r)<=s&&$.distance(e,r)<=s)return h;return o?1-n:n}}}return Number.NaN}function Ys(t,e,s){const n=$.getNAN();n.setCoords(e,s),n.subThis(t.getStartXY());const i=$.getNAN();i.setSub(t.getEndXY(),t.getStartXY());const r=i.crossProduct(n),o=4*ct()*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?-1:r<-o?1:0}function Ns(t,e,s,n){const i=n?t.m_XStart:t.m_XEnd,r=n?t.m_YStart:t.m_YEnd,o=$.getNAN();o.x=e.getEndX()-i,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*ct()*s.dotProductAbs(o)){o.x=e.getStartX()-i,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*ct()*s.dotProductAbs(o)}return!0}function Xs(t,e){const s=$.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!Ns(t,e,s,!1)&&(s.negateThis(),!!Ns(t,e,s,!0))}function qs(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function Fs(t,e,s){const n=t.m_XEnd-t.m_XStart,i=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*i-n*o;if(0===a)return $.getNAN();const h=4*ct()*(Math.abs(r*i)+Math.abs(n*o)),u=e.m_XStart-t.m_XStart,m=e.m_YStart-t.m_YStart,l=r*m-u*o,c=4*ct()*(Math.abs(r*m)+Math.abs(u*o)),g=l/a,d=Math.abs(a),_=(c*d+h*Math.abs(l))/(a*a)+ct()*Math.abs(g);if(g<-_||g>1+_)return $.getNAN();const p=n*m-u*i,f=p/a,P=(4*ct()*(Math.abs(n*m)+Math.abs(u*i))*d+h*Math.abs(p))/(a*a)+ct()*Math.abs(f);if(f<-P||f>1+P)return $.getNAN();let y=gt(g,0,1),x=gt(f,0,1);const C=$.getNAN();ps(t,y,C);const v=$.getNAN();if(ps(e,x,v),!s||$.distance(C,v)>s){const n=$.getNAN();Ct(C,v,.5,n),y=t.getClosestCoordinate(n,!1),x=e.getClosestCoordinate(n,!1);const i=$.getNAN();ps(t,y,i);const r=$.getNAN();ps(e,x,r),i.subThis(r);const o=i.length(),a=(t.absNorm()+e.absNorm())*ht();if(o>Math.max(s,a))return $.getNAN()}return new $(y,x)}class Vs{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&i("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&i("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&i(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount())&&(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,!0)}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&i(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&d(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&i(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!==(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&i(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){if(null!==this.m_segFlagStream){return 1!==(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}return!1}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class Ls{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&(n(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new Ls;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0===--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){n(this.uniqueUse())}setQuadTree(t){n(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){n(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function Rs(t){return!(t.isEmpty()||t.getGeometryType()!==e.enumPolyline&&t.getGeometryType()!==e.enumPolygon)&&!(t.getPointCount()<20)}function zs(t){return!(t.isEmpty()||t.getGeometryType()!==e.enumPolyline&&t.getGeometryType()!==e.enumPolygon)&&!(t.getPointCount()<20)}function Bs(t,e){return t.readPoint2D(e+4)}function ks(t){const s=t.getGeometryType();return s===e.enumEllipticArc?10:s===e.enumBezier?4:s===e.enumRationalBezier2?5:s===e.enumBezier2?2:void r("")}function Gs(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Ws(t,e,s,n){const i=t.getPathStart(e),r=t.getPathEnd(e);if(r-i<3)return;const o=2*i,a=$.getNAN();s.queryPoint2D(o,a);const h=a.x,u=a.y,m=$.getNAN();s.queryPoint2D(o+2,m);const l=$.getNAN();for(let c=o+4,g=2*r;c<g;c+=2)s.queryPoint2D(c,l),n.pe((l.x-a.x)*(m.y-u)),a.setCoordsPoint2D(m),m.setCoordsPoint2D(l);n.pe((h-a.x)*(m.y-u))}function js(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var Zs=b;class Hs{static toSegType(t){let s=0;switch(t){case e.enumLine:s=1;break;case e.enumBezier:s=2;break;case e.enumEllipticArc:s=4;break;case e.enumRationalBezier2:s=8;break;case e.enumBezier2:s=16;break;default:r("")}return s}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class Us extends cs{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?e.enumPolygon:e.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(e){n(this.m_bPolygon);const s=this.getPathIndexFromPointIndex(e),i=this.getPathStart(s);if(i===e)return;const r=this.getPathEnd(s);(e>=r||e<i)&&t("change_ring_start_point");for(let t=0,n=this.m_description.getAttributeCount();t<n;t++){const s=this.m_description.getSemantics(t),n=Zs.getComponentCount(s);this.m_vertexAttributes.get(t).rotate(i*n,e*n,r*n)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(i,e,r),this.m_curveData.m_segmentParamIndex.rotate(i,e,r))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new V(t),s=new O(0),n=new O(0);if(0!==this.m_pointCount){const i=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new Vs({parent:this});for(t.stripAttributes();t.nextPath();){n.reset();const r=t.getPathIndex();Ws(this,r,i,n),js(this,t,n);const o=.5*n.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){n.reset(),Ws(this,r,i,n);const t=.5*n.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return n(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==e.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Us.isNonLinearSegmentFlag(s))continue;const n=this.m_curveData.m_segmentParamIndex.read(t),i=e.m_curveData.m_segmentParamIndex.read(t),r=Gs(s);for(let t=0;t<r;t++){const s=this.m_curveData.m_segmentParams.read(n+t),r=e.m_curveData.m_segmentParams.read(i+t);if(!Pt(s,r))return!1}}}return!0}equalsImplTol(t,e){const s=t,n=this.getPathCount();if(n!==s.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==s.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,n+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,n))return!1;if(!i)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=L(1,0),this.m_pathFlags=R(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new Hs),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new O(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new O(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return n(0),0}calculatePathLength3D(t,e){return n(0),0}copyTo(e){c(e.getGeometryType())||t(""),this!==e&&super.copyTo(e)}swap(t){n(0)}setPointByVal(t,e){this.setPointByValWithCurves(t,e)}setPointByValWithCurves(t,e){if(this.hasNonLinearSegments()){const s=e.getXY();if(this.setXYCoordsWithCurves(t,s.x,s.y),1===this.m_description.getAttributeCount())return}this.setPointByValNoCurves(t,e)}setXYCoordsWithCurves(t,e,s){if(this.hasNonLinearSegments()){const n=Us.getPathIndexFromPointIndexImpl(this.m_paths,this.getPathCount(),t,this.m_currentPathIndex);this.m_currentPathIndex=n;const i=this.getPrevSegmentTypeFromPath(n,t),r=this.getNextSegmentType(t);if(1!==i||1!==r){let o=t-1;const a=new Pm;if(1!==i){if(this.isClosedPath(n)&&t===this.getPathStart(n)){o=this.getPathEnd(n)-1}this.getSegmentBuffer(o,a,!0)}const h=new Pm;1!==r&&this.getSegmentBuffer(t,h,!0);const u=t+1;this.setXYCoordsNoCurves(t,e,s);const m=new $(e,s);return 1!==i&&(a.get().changeEndPoints2D(a.get().getStartXY(),m),this.replaceSegmentImpl(o,t,a.get(),!0)),void(1!==r&&(h.get().changeEndPoints2D(m,h.get().getEndXY()),this.replaceSegmentImpl(t,u,h.get(),!0)))}}this.setXYCoordsNoCurves(t,e,s)}setXYZWithCurves(t,e){this.hasNonLinearSegments()?(this.setXYCoordsWithCurves(t,e.x,e.y),this.setAttributeNoCurves(1,t,0,e.z)):this.setXYZNoCurves(t,e)}setAttributeWithCurves(t,e,s,n){if(0===t&&this.hasNonLinearSegments()){const t=this.getXY(e);0===s?t.x=n:t.y=n,this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeNoCurves(t,e,s,n)}setXY(t,e){this.setXYCoordsWithCurves(t,e.x,e.y)}setXYCoords(t,e,s){this.setXYCoordsWithCurves(t,e,s)}setXYZ(t,e){this.setXYZWithCurves(t,e)}setAttribute(t,e,s,n){this.setAttributeWithCurves(t,e,s,n)}setAttributeWithCurvesFromArray(t,e,s,n){if(0===t&&this.hasNonLinearSegments()){n<2&&i("");const t=this.getXY(e);t.x=s[0],t.y=s[1],this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeFromArrayNoCurves(t,e,s,n)}setAttributeFromArray(t,e,s,n){this.setAttributeWithCurvesFromArray(t,e,s,n)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(e,s){this===e&&t("Multi_path_impl::add");for(let t=0,n=e.getPathCount();t<n;t++)this.addPath(e,t,!s)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addPathMultiPoint(t,e,s,n){s<0&&(s=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,s,n)}addSegmentsFromPath(e,s,n,r,o){if(this===e&&t("Multi_path_impl.add_segments_from_path"),o||0!==this.getPathCount()||(o=!0),s<0&&(s=e.getPathCount()-1),(s>=e.getPathCount()||n<0||r<0||n+r>e.getSegmentCountPath(s))&&i("add_segments_from_path"),0===r)return;const a=e.getPathStart(s),h=e.isClosedPath(s)&&n+r===e.getSegmentCountPath(s);this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());let u=r;const m=a+n;let l=m+1;o&&(u++,l--),!o&&e.hasNonLinearSegments()&&1!==e.m_curveData.m_segmentFlags.read(m)&&(e.getXY(m).equals(this.getXY(this.m_pointCount-1))||t("add_segments_from_path: start point mismatch"));const c=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+u),this.verifyAllStreamsAfterSizeChange(),o){if(0===u)return;this.m_paths.add(this.m_pointCount);let t=e.m_pathFlags.read(s);this.m_bPolygon&&(t|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,t),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const g=h?u-1:u;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const s=this.m_description.getSemantics(t),n=Zs.getComponentCount(s),i=e.m_description.getAttributeIndex(s);if(g>0){if(i<0||!e.m_vertexAttributes.get(i)){const e=Zs.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(n*c,e,g*n,n*c),h&&this.m_vertexAttributes.get(t).insertRange(n*c+g*n,e,n,n*c);continue}this.m_vertexAttributes.get(t).insertRangeFromStream(n*c,e.m_vertexAttributes.get(i),n*l,g*n,!0,n,n*c)}h&&this.m_vertexAttributes.get(t).insertRangeFromStream(n*(c+g),e.m_vertexAttributes.get(i),n*a,n,!0,n,n*(c+g))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),e.hasNonLinearSegments()){let t=0;for(let s=0,n=m;s<r;s++){t+=Gs(e.m_curveData.m_segmentFlags.read(n)),n++}if(t>0){this.initSegmentData(t);let s=m,n=c-(o?0:1),i=0;for(let t=0;t<r;t++){const t=e.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(n,t),Us.isNonLinearSegmentFlag(t)){i++;let r=e.m_curveData.m_segmentParamIndex.read(s);const o=Gs(t);this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);for(let t=0;t<o;t++){const t=e.m_curveData.m_segmentParams.read(r);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,r++}this.incCurveType(t,1)}else this.m_curveData.m_segmentParamIndex.write(n,-1);n++,s++}this.modifyCurveCounter(i)}}if(h){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,n=this.getXY(e),i=this.getXY(s);n.isEqualPoint2D(i)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(e){e>=this.getPathCount()&&t("");const s=this.getPathSize(e);if(0===s)return;const n=this.getPathStart(e),i=this.isClosedPath(e);if(this.hasNonLinearSegments()){let t=n;const e=new this.m_segmentBufferCTor;let r=!1;for(let n=0;n<s;n++,t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Us.isNonLinearSegmentFlag(s))continue;r=!0,this.querySegment(t,e,!0),e.get().reverse();const n=this.m_curveData.m_segmentParamIndex.read(t);e.get().writeInBufferStream(this.m_curveData.m_segmentParams,n)}if(r){const t=i?0:1;this.m_curveData.m_segmentFlags.reverseRange(n,s-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(n,s-t,1)}}const r=i?1:0;for(let t=0,a=this.m_description.getAttributeCount();t<a;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=Zs.getComponentCount(e);this.m_vertexAttributes.get(t).reverseRange(i*(n+r),i*(s-r),i)}const o=6&this.m_pathFlags.read(e);if(o){let t=0;4&o&&(t|=2),2&o&&(t|=4),this.m_pathFlags.clearBits(e,6),this.m_pathFlags.setBits(e,t)}this.notifyModifiedFlags(1233)}removePath(e){const s=this.getPathCount();e<0&&(e=s-1),e>=s&&t("");const n=this.getPathStart(e),i=this.getPathSize(e);for(let t=0,r=this.m_description.getAttributeCount();t<r;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*n,s*i,s*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=n,s=n+i;e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);Us.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(n,i,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(n,i,this.m_pointCount)}for(let t=e+1;t<=s;t++){const e=this.m_paths.read(t);this.m_paths.write(t-1,e-i)}if(this.m_pathFlags)for(let t=e+1;t<=s;t++){const e=this.m_pathFlags.read(t);this.m_pathFlags.write(t-1,e)}this.m_paths.resize(s),this.m_pathFlags.resize(s),this.m_pointCount-=i,this.m_reservedPointCount-=i,e===s-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(e,s,n,i){this===s&&t("Multi_path_impl::insert_path");const r=this.getPathCount();if(!i&&s.hasNonLinearSegmentsPath(n))return e=this.insertPath(e,s,n,!0),this.reversePath(e),e;n>=s.getPathCount()&&t(""),e>r&&t(""),e<0&&(e=r),n<0&&(n=s.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(s.getDescription());const o=s.getPathStart(n),a=s.getPathSize(n);if(0===a)return this.insertPath2D(e,null,0,0,!0);const h=this.m_pointCount,u=s.isClosedPath(n)&&!i?1:0;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const m=e<r?this.getPathStart(e):h;for(let t=0,g=this.m_description.getAttributeCount();t<g;t++){const e=this.m_description.getSemantics(t),n=s.getDescription().getAttributeIndex(e),r=Zs.getComponentCount(e);if(n>=0&&s.m_vertexAttributes.get(n))0!==u&&this.m_vertexAttributes.get(t).insertRangeFromStream(m*r,s.m_vertexAttributes.get(n),r*o,r,!0,r,r*h),this.m_vertexAttributes.get(t).insertRangeFromStream((m+u)*r,s.m_vertexAttributes.get(n),r*(o+u),r*(a-u),i,r,r*(h+u));else{const s=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(m*r,s,r*a,r*h)}}const l=h+a;this.m_paths.add(l);for(let t=r;t>=e+1;t--){const e=this.m_paths.read(t-1);this.m_paths.write(t,e+a)}this.m_pathFlags.add(0);for(let t=r-1;t>=e+1;t--){let e=this.m_pathFlags.read(t);e&=-9,this.m_pathFlags.write(t+1,e)}let c=s.getPathFlagsStreamRef().read(n);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(e,c),s.hasNonLinearSegments()){this.initSegmentData(0);let t=o,e=0;for(let n=0;n<a;n++){e+=Gs(s.m_curveData.m_segmentFlags.read(t)),t++}if(e>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=R(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=L(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(m,1,a,h),this.m_curveData.m_segmentParamIndex.insertRange(m,-1,a,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+e):this.m_curveData.m_segmentParams=z(e),t=o;let n=m,i=0;for(let e=0;e<a;e++){const e=s.m_curveData.m_segmentFlags.read(t);if(Us.isNonLinearSegmentFlag(e)){this.m_curveData.m_segmentFlags.write(n,e),this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);const r=Gs(e);let o=s.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){const t=s.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}i++,this.incCurveType(e,1)}t++,n++}this.modifyCurveCounter(i)}}return this.notifyModifiedFlags(2001),e}insertPath2D(e,s,n,i,r){const o=this.getPathCount();(e>o||n<0)&&t(""),e<0&&(e=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+i),0===i&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=e<o?this.getPathStart(e):a;if(s)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,s,n,i,r,2*a);else{const t=Zs.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*i,2*a)}for(let t=1,u=this.m_description.getAttributeCount();t<u;t++){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e),n=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(h*s,n,s*i,s*a)}this.m_paths.add(this.m_pointCount);for(let t=o;t>=e+1;t--){const e=this.m_paths.read(t-1);this.m_paths.write(t,e+i)}this.m_pathFlags.add(0);for(let t=o-1;t>=e+1;t--){let e=this.m_pathFlags.read(t);e&=-9,this.m_pathFlags.write(t+1,e)}return this.m_bPolygon&&this.m_pathFlags.write(e,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,i,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,i,a)),this.notifyModifiedFlags(2001),e}insertPathFromMultipoint(e,s,n,i,r){const o=s.getImpl(),a=this.getPathCount();(e>a||n<0)&&t("");const h=i<0?o.getPointCount()-n:i;if(h>o.getPointCount()&&t(""),n>=o.getPointCount()&&t("pointsOffset"),e<0&&(e=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(e,null,0,0,!0);const u=this.m_pointCount,m=n;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=e<a?this.getPathStart(e):u;for(let t=0,d=this.m_description.getAttributeCount();t<d;t++){const e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),n=Zs.getComponentCount(e);if(s>=0){const s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(l*n,s,n*m,n*h,r,n,n*u)}else{const s=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(l*n,s,n*h,n*u)}}const c=u+h;this.m_paths.add(c);for(let t=a;t>=e+1;t--){const e=this.m_paths.read(t-1);this.m_paths.write(t,e+h)}this.m_pathFlags.add(0);for(let t=a-1;t>=e+1;t--){let e=this.m_pathFlags.read(t);e&=-9,this.m_pathFlags.write(t+1,e)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(e,g),this.notifyModifiedFlags(2001)}insertPoints(e,s,n,r,o,a,h){if(this===n&&t("Multi_path_impl.insert_points"),e<0&&(e=this.getPathCount()),r<0&&(r=n.getPathCount()-1),(e>this.getPathCount()||s>=0&&s>this.getPathSize(e)||r>=n.getPathCount()||a>n.getPathSize(r))&&i(""),!a)return;if(this.mergeVertexDescription(n.m_description),e===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=n.m_pathFlags.read(r);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}s<0&&(s=this.getPathSize(e));const u=this.m_pointCount;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(e),l=m+s;a<0&&(a=n.getPathSize(r));const c=n.getPathStart(r),g=c+a;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const e=this.m_description.getSemantics(t),i=Zs.getComponentCount(e),r=n.m_description.getAttributeIndex(e);if(r<0||!n.m_vertexAttributes.get(r)){const s=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(i*l,s,g*i,i*u);continue}this.m_vertexAttributes.get(t)?.insertRangeFromStream(i*(m+s),n.m_vertexAttributes.get(r),i*(c+o),a*i,h,i,i*u)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+s,1,a,u),this.m_curveData.m_segmentParamIndex.insertRange(m+s,-1,a,u),s>0&&this.isNonLinearSegment(m+s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+s-1),-1),this.m_curveData.m_segmentFlags.write(m+s-1,1),this.m_curveData.m_segmentParamIndex.write(m+s-1,-1),this.modifyCurveCounter(-1)));for(let t=e+1,i=this.getPathCount();t<=i;t++){const e=this.m_paths.read(t);this.m_paths.write(t,e+a)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&i(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let i=1,u=this.m_description.getAttributeCount();i<u;i++){const t=this.m_description.getSemantics(i),s=Zs.getComponentCount(t),n=Zs.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange((h+e)*s,n,s*r,s*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,u=this.getPathCount();i<=u;i++)this.m_paths.write(i,this.m_paths.read(i)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl(),h=this.getPathCount();t<0&&(t=this.getPathCount());const u=a.getPointCount();if((n<0||n>u)&&i(""),(r<0||n+r>u)&&(r=u-n),e<0&&(e=t<h?this.getPathSize(t):0),(t>h||t<h&&e>this.getPathSize(t)||t===h&&e>0||r<0)&&i(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===h){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const m=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const l=this.getPathStart(t),c=l+e,g=0,d=g+r;for(let i=0,_=this.m_description.getAttributeCount();i<_;i++){const t=this.m_description.getSemantics(i),s=Zs.getComponentCount(t);if(a.getDescription().getAttributeIndex(t)<0){const e=Zs.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange(s*c,e,d*s,s*m);continue}const h=a.getAttributeStreamRef(t);this.m_vertexAttributes.get(i).insertRangeFromStream(s*(l+e),h,s*(g+n),r*s,o,s,s*m)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l+e,1,r,m),this.m_curveData.m_segmentParamIndex.insertRange(l+e,-1,r,m),e>0&&this.isNonLinearSegment(l+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(l+e-1),-1),this.m_curveData.m_segmentFlags.write(l+e-1,1),this.m_curveData.m_segmentParamIndex.write(l+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,_=this.getPathCount();i<=_;i++){const t=this.m_paths.read(i);this.m_paths.write(i,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e),n=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,n,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByValNoCurves(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,n=this.m_description.getAttributeCount();t<n;t++){const n=this.m_description.getSemantics(t),i=Zs.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(t).insertAttributes(i*a,s,n,i*r);else{const e=Zs.getDefaultValue(n);this.m_vertexAttributes.get(t).insertRange(i*a,e,i,i*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let s=t+1,i=n;s<=i;s++)this.m_paths.write(s,this.m_paths.read(s)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&i("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&i("Multi_path.remove_point");const o=n+e;for(let i=0,a=this.m_description.getAttributeCount();i<a;i++)if(this.m_vertexAttributes.get(i)){const t=this.m_description.getSemantics(i),e=Zs.getComponentCount(t);this.m_vertexAttributes.get(i).eraseRange(e*o,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let i=s;i>=t+1;i--){const t=this.m_paths.read(i);this.m_paths.write(i,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNextSegmentType(t){return this.hasNonLinearSegments()?this.m_curveData.m_segmentFlags.read(t):1}getPrevSegmentTypeFromPath(t,e){if(!this.hasNonLinearSegments())return 1;const s=this.getPathStart(t);if(e>s)return this.m_curveData.m_segmentFlags.read(e-1);if(e===s){if(this.isClosedPath(t)){const e=this.getPathEnd(t);return this.m_curveData.m_segmentFlags.read(e-1)}return 1}r("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),n=this.getPathEnd(t);s<n;s++)Us.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),n=Us.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=n,n}startPathCoords(t,e){this.startPathPoint(new F({x:t,y:e}))}startPath(t){this.startPathPoint(new F({pt:t}))}startPath3D(t){this.startPathPoint(new F({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new F({x:t,y:e,z:s}))}startPathPoint(e){e.isEmpty()&&t("");const s=e.getDescription();let n;if(this.m_description!==s){this.mergeVertexDescription(s);const t=new F({vd:this.m_description});e.copyCommonAttributesTo(t),n=t}else n=e;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,n):(this.insertPoint(-1,-1,n),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=L(2),this.m_paths.write(0,0),this.m_pathFlags=R(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,n=e+t;this.m_paths.write(s,n),this.resizeImpl(n),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoordsNoCurves(this.m_pointCount-1,t,e);else{const s=I(),n=new F({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});n.setXYCoords(t,e),this.setPointByValNoCurves(this.m_pointCount-1,n)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=v(this.m_description,S()),s=I(),n=new F({vd:e,attribBuffer:s,initDefaultValues:!0});n.setXYZ(t),this.setPointByValNoCurves(this.m_pointCount-1,n),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new E(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByValNoCurves(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=I(),s=new F({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(e){this.m_bPolygon&&r("");const s=this.getPathCount();if(e>s&&t(""),!this.isClosedPath(e))return;this.m_pathFlags||r("");const n=this.m_pointCount,i=this.getPathStart(e),o=this.getPathEnd(e);if(o-i!==0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*o,this.m_vertexAttributes.get(t),s*i,s,!0,1,s*n)}for(let t=s;t>e;t--){const e=this.m_paths.read(t);this.m_paths.write(t,e+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(o,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(o,-1,1,n)),this.m_pathFlags.clearBits(e,1)}}openPath(e){this.m_bPolygon&&r(""),e>this.getPathCount()&&t(""),this.m_pathFlags||r(""),this.m_pathFlags.clearBits(e,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&r(""),this.isEmpty())return;this.m_pathFlags||r("");let t=0;const e=this.getPathCount();for(let r=0;r<e;r++)this.isClosedPath(r)&&(this.getPathSize(r)>0?t++:this.m_pathFlags.clearBits(r,1));if(0===t)return;const s=this.hasNonLinearSegments();let n=0;const i=this.getPathCount(),o=this.m_description.getAttributeCount(),a=new Array(o);let h=null,u=null;for(let r=0;r<i;++r){const e=this.getPathStart(r),i=this.getPathSize(r),m=this.isClosedPath(r);if(i>0){const r=e+n;for(let s=0;s<o;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),o=Zs.getComponentCount(n);if(!a[s]){const e=o*(this.m_pointCount+t),i=N(n,e);a[s]=i}a[s].writeRange(r*o,i*o,this.m_vertexAttributes.get(s),e*o,!0,1),m&&a[s].writeRange((r+i)*o,o,this.m_vertexAttributes.get(s),e*o,!0,1)}if(s){if(null===h){const e=this.m_pointCount+t;h=R(e),u=L(e)}h.writeRange(r,i,this.m_curveData.m_segmentFlags,e,!0,1),u.writeRange(r,i,this.m_curveData.m_segmentParamIndex,e,!0,1),m&&(h.write(r+i,1),u.write(r+i,-1))}}this.m_paths.write(r,e+n),m&&(this.m_pathFlags.clearBits(r,1),++n)}this.m_paths.write(i,this.m_pointCount+t),this.m_pathFlags.clearBits(i,1);for(let r=0;r<o;r++)this.m_vertexAttributes.get(r)&&this.m_vertexAttributes.set(r,a[r]);s&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=u),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(e){void 0===e&&(e=this.getPathCount()-1),this.throwIfEmpty(),(e<0||e>=this.getPathCount())&&t("close_path_with_line"),e===this.getPathCount()-1&&(this.m_bPathStarted=!1);const s=this.m_pathFlags.read(e);if(1&s||this.m_pathFlags.write(e,1|s),this.m_curveData&&this.m_curveData.m_segmentFlags){const t=this.getPathEnd(e)-1,s=this.m_curveData.m_segmentFlags.read(t);1!==s&&(this.m_curveData.m_segmentFlags.write(t,1),this.m_curveData.m_segmentParamIndex.write(t,-1),this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(s,n){if(this.throwIfEmpty(),(s<0||s>=this.getPathCount())&&t("close_path_with_line"),n.getEndXY().equals(this.getXY(this.getPathStart(s)))||t("close_path_with_segment: end point mismatch"),s===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(n,!1),--this.m_pointCount,this.m_paths.write(s+1,this.m_pointCount);else{this.mergeVertexDescription(n.getDescription());const i=n.getStartXY(),r=this.getPathEnd(s)-1;i.equals(this.getXY(r))||t("close_path_with_segment: start point mismatch");const o=n.getGeometryType();if(o===e.enumLine)return void this.closePathWithLine(s);{const t=ks(n);this.initSegmentData(t);const e=Hs.toSegType(o),s=this.m_curveData.m_segmentFlags.read(r);if(s!==e)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),n.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(e,1),1!==s?this.incCurveType(s,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(r);n.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,e)}}const i=this.m_pathFlags.read(s);1&i||this.m_pathFlags.write(s,1|i),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const n=this.getXY(e),i=this.getXY(s);return n.isEqualPoint2D(i)}isClosedPathIn3D(t){return n(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Us.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof le)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),n=I(),i=new F({vd:s,attribBuffer:n,initDefaultValues:!1});for(let r=0,o=4;r<o;r++){const s=e?o-r-1:r;t.queryCornerByVal(s,i),0===r?this.startPathPoint(i):this.lineToPoint(i)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(e,s){if(e.isClosed()||t("add_path_from_closedSegment: segment must be closed"),s){const t=e.getReversed(),s=new F;t.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(t)}else{const t=new F;e.queryStart(t),this.startPathPoint(t),this.closeLastPathWithSegment(e)}}addSegment_(s,n){const i=s.getDescription();this.mergeVertexDescription(i);const r=I(),o=new F({vd:i,attribBuffer:r,initDefaultValues:!1}),a=s.getGeometryType();if(a===e.enumLine)(n||this.isEmptyImpl())&&(s.queryStart(o),this.startPathPoint(o)),s.queryEnd(o),this.lineToPoint(o);else{let e=!1;if((n||this.isEmptyImpl())&&(e=!0),!e){s.getStartXY().equals(this.getXY(this.m_pointCount-1))||t("add_segment: start point mismatch")}if(e&&(s.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),s.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=I(),e=new F({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const i=ks(s);this.initSegmentData(i),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),s.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=i;const r=Hs.toSegType(a);this.incCurveType(r,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,r)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(e,s,n,i){for(let a=e;a<n-1;a++)this.isClosedPath(a)&&t("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(e,s,n,i);if(0!==o)for(let t=1;t<r;t++){const r=this.m_description.getSemantics(t);this.interpolateAttributesSemanticsImpl(r,e,s,n,i,o)}}interpolateAttributesSemantics(e,s,n,i,r){if(0===e)return;this.hasAttribute(e)||t("does not have the given attribute");2===Zs.getInterpolation(e)&&t("angular interpolation");for(let a=s;a<i-1;a++)this.isClosedPath(a)&&t("cannot interpolate across closed paths");const o=this.calculateSubLength2D(s,n,i,r);0!==o&&this.interpolateAttributesSemanticsImpl(e,s,n,i,r,o)}interpolateAttributesPath(t,e,s){const n=this.m_description.getAttributeCount();if(1===n)return;if(e===s)return;const i=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<n;r++){const n=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(n,t,e,s,i)}}interpolateAttributesSemanticsPath(e,s,n,i){if(0===e)return;this.hasAttribute(e)||t("does not have the given attribute");2===Zs.getInterpolation(e)&&t("angular interpolation");const r=this.calculatePathSubLength2D(s,n,i);0!==r&&this.interpolateAttributesSemanticsPathImpl(e,s,n,i,r)}interpolateAttributesSemanticsImpl(t,e,s,n,i,r){const o=this.querySegmentIterator(),a=this.getPathStart(e)+s,h=this.getPathStart(n)+i,u=Zs.getComponentCount(t),m=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,a,m,u);const l=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,u);const c=et(Zs.maxComponentCount(),Number.NaN);st(c,m,0,0,u);let g=0;const d=Zs.getDefaultValue(t),_=Zs.getInterpolation(t);o.resetToVertex(a,e);do{if(o.hasNextSegment()){if(o.nextSegment(),o.getStartPointIndex()===h)return;this.setAttributeFromArray(t,o.getStartPointIndex(),c,u),o.previousSegment();do{const e=o.nextSegment();if(o.getEndPointIndex()===h)return;g+=e.calculateLength2D();dt(_,m,l,c,0,u,g/r,d),o.isClosingSegment()||this.setAttributeFromArray(t,o.getEndPointIndex(),c,u)}while(o.hasNextSegment())}}while(o.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,r){n(0!==t);const o=this.querySegmentIterator(),a=Zs.getInterpolation(t),h=this.getPathStart(e)+s,u=this.getPathStart(e)+i;if(u===h)return;const m=Zs.getComponentCount(t),l=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,m);const c=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,u,c,m);const g=new O(0);o.resetToVertex(h,e),o.setCirculator(this.isClosedPath(e));const d=Zs.getDefaultValue(t),_=et(Zs.maxComponentCount(),Number.NaN);st(_,l,0,0,m);const p=0===r;let f=.5;do{const e=o.nextSegment();if(this.setAttributeFromArrayNoCurves(t,o.getStartPointIndex(),_,m),!p){const t=e.calculateLength2D();g.pe(t),f=g.getResult()/r}dt(a,l,c,_,0,m,f,d)}while(o.getEndPointIndex()!==u)}querySegment(e,s,n){const i=this.getPathIndexFromPointIndex(e),r=e-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&t("get_segment"),this.getSegmentFromPath(i,r,s,n)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(e){const s=this.getPathIndexFromPointIndex(e),n=e-this.getPathStart(s);return n>=this.getSegmentCountPath(s)&&t("get_segment"),this.getSegmentTypeFromPath(s,n)}getSegmentFromPath(t,e,s,n){const i=this.getPathStart(t)+e,o=this.getSegmentFlagsStreamRef();let a=1;switch(o&&(a=31&o.read(i)),a){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:r("")}const h=s.get();let u,m=null;n?(m=P(),h.assignVertexDescription(m)):h.assignVertexDescription(this.m_description),u=i===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):i+1;qe(h,this.getXY(i));if(Ve(h,this.getXY(u)),!n)for(let r=1,l=this.m_description.getAttributeCount();r<l;r++){const t=this.m_description.getSemantics(r),e=Zs.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,i,s);h.setStartAttribute(t,s,e);const n=this.getAttributeAsDbl(t,u,s);h.setEndAttribute(t,s,n)}}if(Us.isNonLinearSegmentFlag(a)){const t=this.m_curveData.m_segmentParamIndex.read(i);h.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++){if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);Bs(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(e,s,n,i=!1){const r={iSegment:-1},o=i?r:{tSegment:0};if(n.setEmpty(),this.isEmpty())return r;if((e<0||e>=this.getPathCount())&&t("query_point_along_path"),s<0)return r;const a=this.getPathSize(e);if(0===a)return r;if(1===a)return this.getPointByVal(this.getPathStart(e),n),o.tSegment=0,r.iSegment=this.getPathStart(e),r;const h=this.querySegmentIteratorAtVertex(this.getPathStart(e)),u=new O(0);for(;h.hasNextSegment();){const t=h.nextSegment(),e=t.calculateLength2D(),i=u.getResult();if(u.add(e),u.getResult()>=s){let a=s-i;a>e&&(a=e);const u=t.lengthToT(a);return t.queryCoord(u,n),o.tSegment=u,r.iSegment=h.getStartPointIndex(),r}}if(this.isClosedPath(e)){const t=this.getPathStart(e);return this.getPointByVal(t,n),o.tSegment=1,r.iSegment=this.getPathEnd(e)-1,r}{const t=this.getPathEnd(e)-1;return this.getPointByVal(t,n),this.getPathSize(e)>1?(o.tSegment=1,r.iSegment=this.getPathEnd(e)-2,r):(o.tSegment=0,r.iSegment=this.getPathStart(e),r)}}queryPointsAlongPath(e,s,n,i,r,o){{let e=0;for(let a=0;a<s;++a)i&&i[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),e>n[a]&&t("query_points_along"),e=n[a]}const a=this.getPathSize(e);if(0===s||0===a)return 0;if(1===a){const t=this.getPathStart(e);return i&&this.getPointByVal(t,i[0]),o&&(o[0]=0),r&&(r[0]=t),1}const h=this.getPathStart(e),u=new O(0),m=this.querySegmentIteratorAtVertex(h);let l=0,c=0,g=n[l];for(;m.hasNextSegment();){const t=m.nextSegment(),e=t.calculateLength2D(),a=u.getResult();for(u.add(e);u.getResult()>=g;){let h=g-a;h>e&&(h=e);const u=t.lengthToT(h);if(i&&t.queryCoord(u,i[c]),o&&(o[c]=u),r&&(r[c]=m.getStartPointIndex()),c++,l++,g=n[l],l===s)return c}}if(this.isClosedPath(e)){const t=this.getPathStart(e),s=0;i&&this.getPointByVal(t,i[c]),o&&(o[c]=s),r&&(r[c]=t),c++}else if(this.getPathSize(e)>1){const t=this.getPathEnd(e)-2,s=1;i&&this.getPointByVal(t+1,i[c]),o&&(o[c]=s),r&&(r[c]=t),c++}return c}queryPointsAlong(e,s,n,i,r){{let o=0;for(let a=0;a<e;++a)n&&n[a].setEmpty(),i&&(i[a]=-1),r&&(r[a]=0),o>s[a]&&t("query_points_along"),o=s[a]}if(0===e)return 0;const o=new O(0),a=this.querySegmentIterator();let h=-1,u=0,m=0,l=s[u];for(;a.nextPath();)for(;a.hasNextSegment();){h=a.getPathIndex();const t=a.nextSegment(),c=t.calculateLength2D(),g=o.getResult();for(o.add(c);o.getResult()>=l;){let o=l-g;o>c&&(o=c);const h=t.lengthToT(o);if(n&&t.queryCoord(h,n[m]),r&&(r[m]=h),i&&(i[m]=a.getStartPointIndex()),m++,u++,l=s[u],u===e)return m}}if(h<0)return 0;if(this.isClosedPath(h)){const t=this.getPathStart(h),e=0;n&&this.getPointByVal(t,n[m]),r&&(r[m]=e),i&&(i[m]=t),m++}else if(this.getPathSize(h)>1){const t=this.getPathEnd(h)-2,e=1;n&&this.getPointByVal(t+1,n[m]),r&&(r[m]=e),i&&(i[m]=t),m++}return m}querySegmentIterator(){return new Vs({parent:this})}querySegmentIteratorAtVertex(t){return new Vs({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(e,s,i){if(s instanceof C&&n(0,"not implemented for Envelope"),s instanceof T&&n(0,"not implemented for Envelope3D"),(e>=this.getPathCount()||e<0)&&t(""),this.isEmpty())return void s.setEmpty();const r=this.getAttributeStreamRef(0),o=le.constructEmpty();o.setEmpty();for(let t=2*this.getPathStart(e),a=2*this.getPathEnd(e);t<a;){const e=a-t;n(!(1&e)),o.mergePointsInterleaved(r,t/2,e/2),t+=e}if(s.setCoords({env2D:o}),this.hasNonLinearSegmentsPath(e)){const t=this.querySegmentIterator();if(t.resetToPath(e),t.nextPath())for(;t.hasNextSegment();){const e=t.nextCurve();if(!e)break;{const t=le.constructEmpty();i?e.queryEnvelope(t):e.queryLooseEnvelope(t),s.mergeEnvelope2D(t)}}else n(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=10,e=Gs(4)*this.m_curveData.m_arcCount+Gs(2)*this.m_curveData.m_bezierCount+Gs(8)*this.m_curveData.m_rbezier2Count+Gs(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*e>>1,t)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let n=0,i=this.getPointCount();n<i;n++){const e=this.m_curveData.m_segmentFlags.read(n);if(Us.isNonLinearSegmentFlag(e)){t+=Gs(e)}}const e=z(t);let s=0;for(let n=0,i=this.getPointCount();n<i;n++){const t=this.m_curveData.m_segmentFlags.read(n);if(Us.isNonLinearSegmentFlag(t)){let i=this.m_curveData.m_segmentParamIndex.read(n);this.m_curveData.m_segmentParamIndex.write(n,s);const r=Gs(t);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(i)),s++,i++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){n(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=L(0),this.m_pathFlags=R(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=L(0),this.m_pathFlags=R(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new Os(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,n){this.m_curveData||(this.m_curveData=new Hs),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=n}static getPathIndexFromPointIndexImpl(t,e,s,n){if(n>=0&&n<e){if(s>=t.read(n)){if(s<t.read(n+1))return n;n++}else n--;if(n>=0&&n<e&&s>=t.read(n)&&s<t.read(n+1))return n}if(e<5){for(let n=0;n<e;n++)if(s<t.read(n+1))return n;g("")}let i=0,r=e-1;for(;r>i;){const e=i+(r-i>>1);if(s<t.read(e))r=e-1;else{if(!(s>=t.read(e+1)))return e;i=e+1}}return i}getHighestPointIndex(t){n(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),s=this.getPathEnd(t),i=this.getPathStart(t);let r=-1;const o=new $;o.y=Number.NEGATIVE_INFINITY,o.x=Number.NEGATIVE_INFINITY;for(let n=i+0;n<s;n++){const t=e.readPoint2D(2*n);-1===o.compare(t)&&(r=n,o.setCoordsPoint2D(t))}return r}applyTransformationToPath(e,s){if(s>=this.getPathCount()&&t("apply_transformation"),this.isEmpty())return;if(e.isIdentity())return;const n=this.m_vertexAttributes.get(0);if(!(s<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(s))){let t,i;return s<0?(t=0,i=this.m_pointCount):(t=this.getPathStart(s),i=this.getPathEnd(s)),n.applyTransformation(e,2*t,i-t),void this.notifyModifiedFlags(2001)}const i=new this.m_segmentBufferCTor,r=this.getPathCount();let o=s<0?0:s;do{const t=this.getPathStart(o),r=this.getPathEnd(o),a=this.isClosedPath(o),h=n.readPoint2D(2*t);if(!this.hasNonLinearSegmentsPath(o)){n.applyTransformation(e,2*t,r-t);continue}const u=$.getNAN();for(let s=t;s<r;++s){if(1!==(31&this.m_curveData.m_segmentFlags.read(s))){const o=a&&s+1===r;o&&n.writePoint2D(2*t,h),this.getSegmentBuffer(s,i,!0),i.get().applyTransformation(e);const u=this.m_curveData.m_segmentParamIndex.read(s);i.get().writeInBufferStream(this.m_curveData.m_segmentParams,u),n.writePoint2D(2*s,i.get().getStartXY()),o&&n.writePoint2D(2*t,i.get().getEndXY());continue}const o=2*s;n.queryPoint2D(o,u),e.transformInPlace(u),n.writePoint2D(o,u)}if(o===s)break}while(++o<r);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,n){const i=this.getPathStart(t)+e,r=this.getPathStart(s)+n;(r<i||i<0||r>this.getPointCount()-1)&&d("");const o=this.querySegmentIterator();let a=0;o.resetToVertex(i,t);do{for(;o.hasNextSegment();){const t=o.nextSegment();if(o.getStartPointIndex()===r)break;a+=t.calculateLength2D()}if(o.getStartPointIndex()===r)break}while(o.nextPath());return a}calculatePathSubLength2D(e,s,n){const i=this.getPathStart(e)+s,r=this.getPathStart(e)+n;(i<0||r>this.getPointCount()-1)&&d("");const o=this.querySegmentIterator();if(i>r&&(this.isClosedPath(e)||t("cannot iterate across an open path"),o.setCirculator(!0)),i===r)return 0;let a=0,h=0;o.resetToVertex(i,e);do{h+=a;a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==r);return h}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=le.constructEmpty(),n=this.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const i=n.nextCurve();if(!i)break;t?i.queryEnvelope(s):i.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(e,s){this===e&&t("Multi_path_impl::add");let n=this.getPathCount();for(let t=0,i=e.getPathCount();t<i;t++)this.addPath(e,t,!s),this.openPathAndDuplicateStartVertex(n),n++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(e,s,n){const i=this.getPathIndexFromPointIndex(e),r=e-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&t("getSegmentBuffer"),this.getSegmentFromPath(i,r,s,n)}getSegmentTypeFromPath(t,s){const n=this.getPathStart(t)+s,i=this.getSegmentFlagsStreamRef();let o=1;switch(i&&(o=31&i.read(n)),o){case 1:return e.enumLine;case 2:return e.enumBezier;case 4:return e.enumEllipticArc;case 8:return e.enumRationalBezier2;case 16:return e.enumBezier2;default:r("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,n=this.getPathCount();e<n;e++){const n=this.getPathStart(e),i=this.getPathEnd(e),r=i-n;for(let e=n;e<i;e++){const i=31&this.m_curveData.m_segmentFlags.read(e);if(1===i)continue;2!==i&&s("ensure_xy_monotone_segments");const o=(e-n+1)%r+n,a=this.m_curveData.m_segmentParamIndex.read(e),h=ut($,4);h[0]=this.getXY(e),h[3]=this.getXY(o),h[1].x=this.m_curveData.m_segmentParams.read(a),h[1].y=this.m_curveData.m_segmentParams.read(a+1),h[2].x=this.m_curveData.m_segmentParams.read(a+2),h[2].y=this.m_curveData.m_segmentParams.read(a+3),we(h)&&(t=!0,this.m_curveData.m_segmentParams.write(a,h[1].x),this.m_curveData.m_segmentParams.write(a+1,h[1].y),this.m_curveData.m_segmentParams.write(a+2,h[2].x),this.m_curveData.m_segmentParams.write(a+3,h[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ls),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=B(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ls),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=k(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Us.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new Hs),Us.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new Hs),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Hs);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=R(e,1),this.m_curveData.m_segmentParamIndex=L(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=z(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new Hs),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let n=0;n<t;n++){const t=this.m_cachedRingAreas2D.read(n);0===s&&(s=Xt(t)),t*s>0||0===s?e.setBits(n,8):e.clearBits(n,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(e,s,i){(e<0||e>=this.getPointCount())&&t("Multi_path_impl.replace_segment"),n(s.isCurve());const r=this.getPathIndexFromPointIndex(e),o=this.getPathStart(r),a=(e-o+1)%this.getPathSize(r)+o;{const t=this.getXY(e),i=this.getXY(a),r=!t.isEqualPoint2D(s.getStartXY())||!i.isEqualPoint2D(s.getEndXY());n(!r)}this.replaceSegmentImpl(e,a,s,i)}replaceSegmentImpl(t,e,s,i){const r=s.getDescription();this.mergeVertexDescription(r);const o=et(32,Number.NaN),a=new F({vd:r,attribBuffer:o,initDefaultValues:!1}),h=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),u=Gs(h),m=ks(s);let l,c=!1;u>=m?(n(null!==this.m_curveData),c=!0,l=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(m),c=!1,l=this.m_curveData.m_curveParamWritePoint);const g=s.getGeometryType(),d=Hs.toSegType(g);i||(s.queryStart(a),this.setPointByValNoCurves(t,a),s.queryEnd(a),this.setPointByValNoCurves(e,a)),this.m_curveData.m_segmentParamIndex.write(t,1!==d?l:-1),this.m_curveData.m_segmentFlags.write(t,d),1!==d&&s.writeInBufferStream(this.m_curveData.m_segmentParams,l),c||(this.m_curveData.m_curveParamWritePoint+=m),h!==d&&(this.incCurveType(h,-1),this.incCurveType(d,1),this.modifyCurveCounter(1===h?1:-1))}setAttributeImpl(e,s,n){if(this.addAttribute(e),!this.isEmpty())if(this.hasNonLinearSegments()&&0===e){(s<0||s>1)&&t("");const e=new ce,i=0===s?n:0,r=0===s?0:1;e.setShiftCoords(i,r),0===s?e.xx=0:e.yy=0,this.applyTransformation(e)}else super.setAttributeImpl(e,s,n)}toFlatGeometry(){const t=this.m_bPolygon?"polygon":"polyline",e=this.getPathCount(),s=this.m_paths?this.m_paths.getArray():new Int32Array,n=this.m_paths?this.m_pathFlags.getArray():new Int8Array;let i,r,o,a=0,h=0;if(this.m_curveData){const{m_segmentFlags:t,m_segmentParamIndex:e,m_segmentParams:s}=this.m_curveData;i=t?.getArray()??new Int8Array,r=e?.getArray()??new Int32Array,o=s?.getArray()??new Float64Array,a=this.m_curveData.m_arcCount,h=this.m_curveData.m_bezierCount}return{type:t,...this.exportVertexAttributes(),partCount:e,partOffsets:s,partFlags:n,segmentFlags:i,segmentIndices:r,segmentParams:o,segmentCountArc:a,segmentCountBezier:h}}}Us.st_totalCurveCount=0;class Os{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new le(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e);return this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=le.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class Qs extends Us{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Pm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Pm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Pm):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Pm,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Pm,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):r("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Pm)}getBoundary(){return Js(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Qs.type}getDimension(){return 1}createInstance(){return new Qs({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Qs.type=e.enumPolyline;var Ks=e;function $s(t,e){if(t.isEmpty())return!1;const n=t.getGeometryType();if(n===Ks.enumPolygon)return 0!==t.calculateArea2D();if(n===Ks.enumPolyline)return tn(t.getImpl(),e,!0).bNotEmpty;if(n===Ks.enumEnvelope)return!0;if(m(n))return!!t.isClosed();if(l(n))return!1;if(n===Ks.enumGeometryCollection){const s=t;for(let t=0,n=s.getGeometryCount();t<n;t++)if($s(s.getGeometry(t),e))return!0;return!1}s("")}function Js(t,e){const n=t.getGeometryType();if(n===Ks.enumPolygon){const e=new Qs({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(n===Ks.enumPolyline)return tn(t.getImpl(),e,!1).boundary;if(n===Ks.enumEnvelope){const e=new Qs({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(m(n)){const e=new gs({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new F;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(n===Ks.enumGeometryCollection){const s=t;let n=null;for(let i=0,r=s.getGeometryCount();i<r;i++){const r=Js(s.getGeometry(i),e);if(null!==r){null===n&&(n=t.createInstance());const e=r;n.addGeometry(e)}}return n}if(l(n))return new F({vd:t.getDescription()});s("")}function tn(t,e,s){const n=!1,i=t;let r=null;if(s||(r=new gs({vd:i.getDescription()})),!i.isEmpty()){const t=new j(0);for(let e=0,s=i.getPathCount();e<s;e++){if(i.getPathSize(e)>0&&!i.isClosedPathInXYPlane(e)){const s=i.getPathStart(e);t.add(s);const n=i.getPathEnd(e)-1;t.add(n)}}if(t.size()>0){const e=new W,n=i.getAttributeStreamRef(0),o={userSort(t,e,s){const i=$.getNAN(),r=$.getNAN();s.sort(t,e,(t,e)=>(n.queryPoint2D(2*t,i),n.queryPoint2D(2*e,r),i.compare(r)))},getValue:t=>n.read(2*t+1)};e.sort(t,0,t.size(),o);let a=n.readPoint2D(2*t.read(0)),h=0,u=1;const m=new F;for(let i=1,r=t.size();i<r;i++){const e=n.readPoint2D(2*t.read(i));if(e.isEqualPoint2D(a))t.read(h)>t.read(i)?(t.write(h,Nt()),h=i):t.write(i,Nt()),u++;else{if(1&u){if(s)return{bNotEmpty:!0,boundary:new gs({})}}else t.write(h,Nt());a=e,h=i,u=1}}if(1&u){if(s)return{bNotEmpty:!0,boundary:new gs({})}}else t.write(h,Nt());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==Nt();e++)i.getPointByVal(t.read(e),m),r.add(m)}}}return s?{bNotEmpty:n,boundary:new gs({})}:{bNotEmpty:n,boundary:r}}function en(t,e,s,i){const r=4*ct()*(Math.abs(e.vmin)+Math.abs(e.vmax)),o=ct();if(1===t.getMaxDerivative()){n(s>0);const o=un(t,0,e,ct(),r);return i[0]=o.root,o.cRoots}let a,h=[];const u=new U(e.vmin-r,e.vmax+r);h.push(new $(u.vmin,u.vmax));let m=0;for(let n=t.getMaxDerivative()-1;n>=0;n--){a=h,h=[];for(let u=0,l=a.length;u<l;u++){if(a[u][0]<a[u][1]){let l,c,g;if(n===t.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:g}=un(t,n,U.construct(a[u][0],a[u][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:g}=mn(t,n,U.construct(a[u][0],a[u][1]),o,.5*r)),1===g){if(0===n){if(m<s){if(a[u][0]<=e.vmin&&a[u][1]>=e.vmin&&l!==e.vmin){0===t.getValue(0,e.vmin)&&(l=e.vmin)}if(a[u][0]<=e.vmax&&a[u][1]>=e.vmax&&l!==e.vmax){0===t.getValue(0,e.vmax)&&(l=e.vmax)}i[m]=e.snapClip(l),m>0?i[m]-i[m-1]>r&&m++:m++}}else{const t=$.getNAN();t[0]=a[u][0],t[1]=l,h.push(t);const e=$.getNAN();e[0]=l,e[1]=a[u][1],h.push(e)}continue}}h.push(a[u])}}return m}function sn(t,e,s,n){const i=new rt,r=gn(new rt(t),new rt(e),s,i);return n[0]=i.value(),r}function nn(t,e,s,n,i,r){const o=ut(rt,2),a=dn(new rt(t),new rt(e),new rt(s),n,i,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function rn(t,e,s,n,i,r,o){const a=ut(rt,3),h=_n(new rt(t),new rt(e),new rt(s),new rt(n),i,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function on(t,e,s,n,i,r,o,a){return hn(t,e,s,n,i,r,o,a)}function an(t,e,s,n,i,r){return cn(t,e,s,n,i,r)}function hn(t,e,s,n,i,r,o,a){const h=et(s*s,Number.NaN);h.fill(0),st(a,n,0,0,s);const u=et(s,Number.NaN),m=et(s,Number.NaN),l=et(s,Number.NaN);let c=t(a,s,e);const g=100;let d=0;for(d=0;d<g;d++){const n=c;for(let t=0;t<s;++t)m[t]=a[t];if(d%s===0){h.fill(0);for(let t=0;t<s;t++)h[t*s+t]=1}let o=0,g=0;for(let m=0;m<s;++m){for(let t=0;t<s;++t)u[t]=h[m*s+t];const n=c;c=ln(t,e,a,u,i,r,s);const l=n-c;l>o&&(g=m,o=l)}for(let t=0;t<s;t++)u[t]=a[t]-m[t],l[t]=a[t]+(a[t]-m[t]);const _=t(l,s,e);if(_<n){if(2*(n-2*c+_)*Bt(n-c-o)<Bt(n-_)*o){c=ln(t,e,a,u,i,r,s);for(let t=0;t<s;++t)h[g*s+t]=h[(s-1)*s+t],h[(s-1)*s+t]=u[t]}}if(n<=c)return t(a,s,e)}return c}function un(t,e,s,n,i){const o={root:0,funcAtRoot:0,cRoots:0};let a=s.vmin,h=s.vmax,u=0,m=Number.MAX_VALUE,l=t.getValue(e,a),c=t.getValue(e,h),g=0,d=0,_=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(o.funcAtRoot=l,o.root=a,o.cRoots=0===l?1:0,o):(o.funcAtRoot=c,o.root=h,o.cRoots=0===c?1:0,o);Math.abs(l)<Math.abs(c)&&(h=Q(a,a=h),c=Q(l,l=c)),u=a,g=l;let p=!0,f=0;for(;0!==c&&Math.abs(a-h)>n*Math.abs(h)+i;f++){let s=f>64;if(!s){d=l!==g&&c!==g?a*c*g/((l-c)*(l-g))+h*l*g/((c-l)*(c-g))+u*l*c/((g-l)*(g-c)):h-c*(h-a)/(c-l);const t=(3*a+h)/4;if(s=!(d>t&&d<h||d>h&&d<t),!s){const t=n*Math.abs(h)+i;if(p){const e=Math.abs(h-u);s=Math.abs(d-h)>=.5*e||e<t}else{const e=Math.abs(u-m);s=Math.abs(d-h)>=.5*e||e<t}}}if(s?(d=(a+h)/2,p=!0):p=!1,_=t.getValue(e,d),0===_)return o.root=d,o.funcAtRoot=_,o.cRoots=1,o;if(!s){const s=a-d,n=d-h;if(Math.abs(s)>10*Math.abs(n)){let s=h+3*n;for(let n=0;n<2;n++){const n=t.getValue(e,s);Xt(l)*Xt(n)>0?(a=s,l=n):s=nt(a,h,.75)}}else if(Math.abs(n)>10*Math.abs(s)){let n=a-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,n);Xt(c)*Xt(s)>0?(h=n,c=s):n=nt(a,h,.25)}}}m=u,u=h,g=c,Xt(l)*Xt(_)<0?(h=d,c=_):(a=d,l=_),Math.abs(l)<Math.abs(c)&&(h=Q(a,a=h),c=Q(l,l=c)),128===f&&r("Root_finder iterations exceeded")}return o.root=h,o.funcAtRoot=c,o.cRoots=1,o}function mn(t,e,s,n,i){const o={root:0,funcAtRoot:0,cRoots:0};let a=s.vmin,h=t.getValue(e,a),u=s.vmax,m=t.getValue(e,u);if(h>=0&&m>=0||h<=0&&m<=0)return Math.abs(h)<Math.abs(m)?(o.funcAtRoot=h,o.root=a,o.cRoots=0===h?1:0,o):(o.funcAtRoot=m,o.root=u,o.cRoots=0===m?1:0,o);m<0&&(m=Q(h,h=m),u=Q(a,a=u));let l=.5*(a+u),c=Math.abs(u-a),g=c,d=t.getValue(e,l),_=t.getValue(e+1,l);const p=1,f=4;let P=f;const y=2;let x=1,C=0,v=0,b=p;const S=32;let E=0;for(;++E<100;){let s;E>S||0===_||b===y&&C>1||b===p&&P<f?(b=p,x>1&&x--):(b=y,v>1&&Math.abs(2*d)>Math.abs(c*_)&&x++),c=g;let n=!1;if(b===p)do{if(v>2){const t=16*Math.abs(c);if(.5*Math.abs(a-u)>t){const e=Math.min(a,u),n=Math.max(a,u);if(l===e){s=l,l=e+t,g=l-s;break}if(l===n){s=l,l=n-t,g=l-s;break}}}g=.5*(u-a),s=l,l=a+g,n=a===l||u===l}while(0);else for(;;){g=x*d/_,s=l,l-=g,n=l===s;const t=Math.min(a,u),e=Math.max(a,u);if(l<t){if(x>1){l=s,x--;continue}g=s-t,l=t}else if(l>e){if(x>1){l=s,x--;continue}g=s-e,l=e}break}if(n||Math.abs(g)<i){s!==l&&(d=t.getValue(e,l));break}d=t.getValue(e,l),_=t.getValue(e+1,l);const r=a,o=u;d<0?(h=d,a=l):(m=d,u=l),b===y&&(a===r&&u===o||v>1&&Math.abs(g)>=.5001*Math.abs(c))?C++:C=0,b===p?(P++,v=0):(P=0,v++)}return 100===E&&r("Root_finder iterations exceeded"),o.root=l,o.funcAtRoot=d,o.cRoots=1,o}function ln(t,e,s,n,i,r,o){const a=n.slice(0,o);let h=0;for(let f=0;f<o;f++)h+=n[f]*n[f];if(h=Math.sqrt(h),h>0)for(let f=0;f<o;f++)a[f]/=h;let u=Number.NEGATIVE_INFINITY,m=Number.POSITIVE_INFINITY;{const t=et(o,0);for(let e=0;e<o;e++)t[e]=e;t.sort((t,e)=>{const s=Math.abs(a[t]),n=Math.abs(a[e]);return s<n?-1:s>n?1:0});for(let e=0;e<o;e++){const n=t[e];if(0===a[n])continue;let o=(i[n]-s[n])/a[n],h=(r[n]-s[n])/a[n];h<o&&(h=Q(o,o=h)),o>u&&(u=o),h<m&&(m=h)}}let l=0;const c=(Math.abs(u)+Math.abs(m))*ct()*100,g=et(o,Number.NaN),d=a.slice();function _(n,i){for(let t=0,e=o;t<e;t++)g[t]=s[t]+n*d[t];return t(g,o,e)}c>0&&(l=an(_,null,u,0,m,c));const p=_(l);for(let f=0,P=o;f<P;f++)s[f]=gt(g[f],i[f],r[f]);return p}function cn(t,e,s,n,i,r){const o=me();let a=n,h=t(a,e),u=s,m=i,l=t(u,e),c=t(m,e);h>l&&(h=l,a=u),h>c&&(h=c,a=m);let g=u,d=m,_=l,p=c;_>p&&(_=Q(p,p=_),d=Q(g,g=d));let f=a-g,P=g-d;const y=.5*Math.min(r,m-u),x=2*y,C=100;let v,b=0;for(v=0;v<C&&!(m-u<=x);++v){const s=u+.5*(m-u);let n=b>0;if(!n&&Math.abs(P)<=y&&(n=!0,b=3),!n){const t=a-g,e=a-d,s=t*(h-p);let i=e*(h-_),r=e*i-t*s;i=2*(i-s),i>0&&(r=-r),i=Math.abs(i),0===i||Math.abs(r)>=Math.abs(i*P/2)||r<=i*(u-a)||r>=i*(m-a)?(n=!0,b=3):(P=f,f=r/i)}n&&(P=a>=s?u-a:m-a,f=o*P,b--);let i=a+f;i<u+y?i=u+y:i>m-y&&(i=m-y);const r=t(i,e);r<h?(i>=a?(u=a,l=h):(m=a,c=h),d=g,g=a,a=i,p=_,_=h,h=r):(i<a?(u=i,l=r):(m=i,c=r),r<=_||g===a?(d=g,g=i,p=_,_=r):(r<=p||d===a||d===g)&&(d=i,p=r))}return a}function gn(t,e,s,n){return t.isZero()?e.isZero()?-1:0:(n.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(n.value())?1:0)}function dn(t,e,s,n,i,r){if(0===t.value()){if(i)return r[0].set(1),n.containsCoordinate(r[0].value())?1:0;return gn(e,s,n,r[0])}if(i){let e=2;return r[0].set(1),r[1].setE(s).divThisE(t),r[1].eq(r[0])&&(r[1].set(1),e=1),n.containsCoordinate(r[1].value())||(e=1),n.containsCoordinate(r[0].value())||(e--,r[0].setE(r[1])),2===e&&r[0].value()>r[1].value()&&(r[1]=Q(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(Rt));if(o.lt(at))return 0;const a=new rt(e.value()>=0?1:-1),h=o.clone().sqrtThis(),u=new rt(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let m=0;r[0].setE(u.divE(t));const l=new rt(r[0].value()),c=new rt(t.value()).mulE(l).addE(new rt(e.value()).mulE(l).addE(new rt(s.value())));return c.isZero()||vn(r[0],t,e,s,r[0]),n.containsCoordinate(r[0].value())&&m++,0!==h.value()&&0!==u.value()?(r[m].assign(s.divE(u)),l.set(r[m].value()),c.assign(new rt(t.value()).mulE(l).addE(new rt(e.value()).mulE(l).addE(new rt(s.value())))),c.isZero()||vn(r[m],t,e,s,r[m]),n.containsCoordinate(r[m].value())&&m++,2===m&&r[0].value()>r[1].value()&&(r[1]=Q(r[0],r[0]=r[1])),m):m}function _n(t,e,s,n,i,r,o){if(0===t.value()){return dn(e,s,n,i,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=dn(t,e.addE(t),n.negate(),i,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(ot)&&(o[s-1]=Q(o[t],o[t]=o[s-1]),s--)}const h=o.slice(0,s);h.sort((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);for(let t=0;t<s;++t)o[t]=h[t];return s}return bn(t,e,s,n,i,o)}function pn(e,s,n,i,r,o){return(o<s||s<0)&&t("nth_degree_real_roots"),Sn(e,s,n,i,r)}function fn(t,e,s,n){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:n.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),n=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(n.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(n.value())}}}class Pn{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=0;for(let s=0,n=this.truePower-t;s<=n;++s){e.push(this.coefs[s+t].clone());let n=s+t,i=n--;for(let e=1;e<t;e++)i*=n--;e[s].mulThis(i)}this.curCoefs=e}constructor(t,e,s,n){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let i=e;i>=1;i--)if(0!==this.coefs[i].value()){this.truePower=i;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const n=new O(0);let i=1;for(let r=0,o=this.truePower-t;r<=o;++r)n.pe(i*s[r].value()),i*=e;return n.getResult()}getError(t){const e=Math.abs(t),s=new O(0),n=new rt(1),i=new rt(0);for(let o=0,a=this.power;o<=a;++o)i.addThisE(this.coefs[o].mulE(n)),s.pe(n.value()*this.coefs[o].eps()),n.mulThis(e);s.pe(i.eps());let r=1;for(let o=1;o<=this.truePower;++o){r*=o,this.updateCoefs(o);const e=new rt(1),n=new rt(0);for(let s=0,i=this.truePower-o;s<=i;++s)n.addThisE(this.curCoefs[s].mulE(e)),e.mulThis(t);if(!n.isZero())return Math.pow(r*s.getResult()/Math.abs(n.value()),1/o)}return 0}}function yn(t,e,s,n,i,r){let o=t,a=e,h=a-o;if(!r){let s=n.calcF(t).value(),i=n.calcF(e).value();if((s>0||s>i)&&(a=Q(o,o=a),i=Q(s,s=i)),s>=0||i<=0)return!1}let u,m=!1,l=s,c=0;for(;c<100;c++){const t=n.calcF(l);if(u=n.calcDF(l),u.isZero())return!1;if(!t.value()||c>3&&t.isZero()){m=!0;break}r||(t.value()<0?o=l:a=l);const e=t.value()/u.value(),s=l-e;r||(s>=o&&s<=a||s>=a&&s<=o)&&Math.abs(e)<=.5*h?(l=s,h=Math.abs(e)):(h=Math.abs(.5*(a-o)),l=.5*(o+a))}return!!m&&(i.set(l,n.estimateError(l)),!0)}function xn(t,e,s,n,i,r,o,a){return yn(t,e,s.value(),fn(n,i,r,o),a,!1)}class Cn{constructor(t,e,s){this.coefs=ut(rt,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new rt(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new rt(t);return rt.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),n=new rt(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(n.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(n.value())}}function vn(t,e,s,n,i){return yn(0,0,t.value(),new Cn(e,s,n),i,!0)}function bn(t,e,s,n,i,o){const a=ut(rt,3);let h=0;const u=e.negate().divThisE(t.clone().mulThis(3));i.containsCoordinate(u.value())&&(a[0].setE(u),h=1);const m=ut(rt,2),l=dn(t.mul(3),e.mul(2),s,i,!1,m);if(l<0)return n.isZero()?-1:0;for(let r=0;r<l;r++)i.containsCoordinate(m[r].value())&&a[h++].setE(m[r]);ft(a,0,h,(t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);const c=ut(rt,5);c[0].set(i.vmin);for(let r=0;r<h;r++)c[1+r].setE(a[r]);c[1+h].set(i.vmax);const g=h+2;let d=1,_=0;{const i=c[0].clone();if(t.clone().mulThisE(i).addThisE(e).mulThisE(i).addThisE(s).mulThisE(i).addThisE(n).isZero()){const r=fn(t,e,s,n);i.setError(r.estimateError(i.value())),o[_]=i,_++,d++}}for(let p=d;p<g;p++){const a=c[p].clone(),h=t.clone().mulThisE(a).addThisE(e).mulThisE(a).addThisE(s).mulThisE(a).addThisE(n).isZero();if(h||!c[p].eq(c[p-1])){if(h||xn(c[p-1].value(),c[p].value(),c[p-1].clone().addThisE(c[p]).divThisByPower2(2),t,e,s,n,a)){if(_>0&&a.eq(o[_-1]))continue;if(_>=3&&r("cubic_polynomial_solver_too_many_roots"),h){const i=fn(t,e,s,n);a.setError(i.estimateError(a.value()))}o[_]=a,_++}if(c[p].value()===i.vmax)break;h&&p++}}return _}function Sn(t,e,s,n,i,r){const o=new Pn(t,e,s,ct());let a=0;if(2===o.truePower)a=dn(t[2],t[1],t[0],s,n,i);else if(1===o.truePower)a=gn(t[1],t[0],s,i[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=en(o,s,e,t);for(let e=0;e<a;e++)i[e].set(t[e])}}for(let h=0;h<a;h++)i[h].setError(o.getError(i[h].value()));return a}var En=b;class Dn extends ds{constructor(e){return void 0===e||bt(e,"vd")?(super({vd:e?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new $(0,0),void(this.m_weights=[1,0,1])):(e.fromPoint&&e.weight?e={fromPoint:e.fromPoint,controlPoint1:e.controlPoint1,toPoint:e.toPoint,weight0:1,weight1:e.weight,weight2:1}:e.points&&e.weight?e={fromPoint:e.points[0],controlPoint1:e.points[1],toPoint:e.points[2],weight0:1,weight1:e.weight,weight2:1}:e.points&&e.weights&&(e={fromPoint:e.points[0],controlPoint1:e.points[1],toPoint:e.points[2],weight0:e.weights[0],weight1:e.weights[1],weight2:e.weights[2]}),e.fromPoint&&e.weight0?(super({start:e.fromPoint,end:e.toPoint}),(e.weight0<=0||e.weight1<0||e.weight2<=0)&&t("weights"),this.m_cp=e.controlPoint1.clone(),void(this.m_weights=[e.weight0,e.weight1,e.weight2])):e.copy?(super(e),this.m_cp=e.copy.m_cp.clone(),void(this.m_weights=e.copy.m_weights.slice())):e.move?(super(e),this.m_cp=e.move.m_cp.clone(),void(this.m_weights=e.move.m_weights.slice())):void s("unexpected constructor param"))}getBoundary(){return Js(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,n){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,n,1),ca(this)}constructWeights(t,e,s,n,i,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,n,i,r),ca(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),ca(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return e.enumRationalBezier2}queryEnvelope(t){if(t instanceof le){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=La(this);if(null!==e){const s=new $;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[],s=ut($,3);this.queryControlPoints(s),_a(s,this.m_weights,e);const n=new $;for(const i of e)this.queryCoord2D(i,n),t.mergeNe(n)}}}applyTransformation(t){if(t instanceof ce){const e=ut($,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new Dn({vd:this.m_description})}calculateLength2D(){return pa(this,1,!1)}calculateLowerLength2D(){return $.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return $.distance(this.getStartXY(),this.m_cp)+$.distance(this.getEndXY(),this.m_cp)}return $.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){ch(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void ps(new fm({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void ps(new fm({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const n=ut($,3);this.queryControlPoints(n),ph(n,this.m_weights,t,e)}getCoordX(t){const e=new $;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new $;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=En.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=En.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){Da(this,t,e)}cutBezierIgnoreAttributes(e,s,n){(e<0||s>1||e>s)&&t("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const i=ut($,3);this.queryControlPoints(i);const r=[0,0,0];Ka(i,this.m_weights,e,s,i,r),n.setControlPointsAndWeights(i,r)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,r=En.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return vt(r,o,a,i,En.getDefaultValue(e))}getClosestCoordinate(t,e){return za(this,t,U.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return za(this,t,e,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(e,s){e.length<2&&t("");const i=da(this);let r=0;if(2===i.specialPointsCount())return 0;n(e.length>=i.specialPointsCount()-1);for(let t=1,n=i.specialPointsCount();t<n;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[r],s),r++;for(let t=0;t<r;++t){Ha(e[t].get())}return r}intersectionWithAxis2D(t,e,s,n){s&&(s.length=9),n&&(n.length=9);const i=new Array(3),r=ut(rt,2),o=new U(0,1);let a=0;const h=ut($,3);if(this.queryControlPoints(h),t){if(i[0]=new rt(h[0].y).sub(e).mul(this.m_weights[0]),i[1]=new rt(h[1].y).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new rt(h[2].y).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let u=0;u<a;u++)s[u]=this.getCoordX(r[u].value())}else if(i[0]=new rt(h[0].x).sub(e).mul(this.m_weights[0]),i[1]=new rt(h[1].x).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new rt(h[2].x).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let u=0;u<a;u++)s[u]=this.getCoordY(r[u].value());if(n)for(let u=0;u<a;u++)n[u]=r[u].value();else s&&ft(s,0,a,kt);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[Number.NaN,Number.NaN],i=this.intersectionWithAxis2D(!0,t,s,null);return n(2!==i),-1===i?e:s[0]}isCurve(){return!0}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof le)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=le.constructEmpty();this.queryEnvelope(t);const s=U.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=ut($,3);this.queryControlPoints(s);const n=[0,0,0];Ka(s,this.m_weights,t.vmin,t.vmax,s,n),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),n=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):n&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return pa(this,t,!0)}lengthToT(t){return Ia(this,t)}calculateWeightedAreaCentroid2D(t){const e=Xa(this),s=Ma(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new $;return this.isDegenerate(0)?(t.setCoords(0,0),t):Va(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Oa(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}queryCoord2DMP(t,e){const s=ut($,3);return this.queryControlPoints(s),dh(s.map(t=>Ee.constructPoint2D(t)),this.m_weights.map(t=>tt.constructDouble(t)),tt.constructDouble(t),e)}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=ut($,3);return this.queryControlPoints(e),Aa(e,this.m_weights,t)}getDerivative(t){const e=gt(t,0,1),s=ut($,4);return fa(this,1,e,s),s[1]}getCurvature(t){const e=ut($,4);fa(this,2,t,e);const s=e[1].sqrLength();if(0===s)return Number.NaN;e[1].divThis(Math.sqrt(s));return e[1].crossProduct(e[2])/s}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,n,i=1){return!1}isMonotoneQuickAndDirty(){const t=ut($,3);return this.queryControlPoints(t),Za(t)}getMonotonicPartParams(e,s){const n=da(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();e<i&&t("");for(let t=0;t<i;t++)s[t]=n.specialPoints[t];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=Q(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=ut($,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if($.distance(e[0],e[1])+$.distance(e[2],e[1])-n>t)return!1;const i=t,r=e[1].clone();r.subThis(e[0]);return!(Math.abs(r.crossProduct(s))/n>i)}copyIgnoreAttributes(t){const e=ut($,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Ma(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return n(0),0}queryEnvelopeW(t,e){Wa(this,t,e)}setSegmentFromCoordsForStitcher(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=ut($,3);this.queryControlPoints(e);const s=$.sqrDistance(e[1],e[0]),n=$.sqrDistance(e[1],e[2]);let i=e[0].clone(),r=s;s>n&&(i=e[2].clone(),r=n);let o=!1;return r<=t&&0!==r&&(o=!0,this.setControlPoint1(i)),o}needsSnapControlPoints(t){if(!t)return!1;const e=ut($,3);this.queryControlPoints(e);const s=$.sqrDistance(e[1],e[0]),n=$.sqrDistance(e[1],e[2]);e[0].clone();let i=s;return s>n&&(e[2].clone(),i=n),i<=t&&0!==i}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ha(this)}setCoordsForIntersector(t,e,s){Ja(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],Ra(e,La(this))}reverseImpl(){this.m_weights[2]=Q(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let s=0;s<3;s++)if(this.m_weights[s]!==e.m_weights[s])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const n=ut($,3);this.queryControlPoints(n);const i=ut($,3);s.queryControlPoints(i);const r=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let o=0;o<3;o++){const t=new E;t.setCoordsPoint2DZ(n[o].mul(this.m_weights[o]),this.m_weights[o]);const s=new E;if(s.setCoordsPoint2DZ(i[o].mul(r[o]),r[o]),!t.isEqual(s,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=Q(this.m_cp,this.m_cp=e.m_cp),e.m_weights=Q(this.m_weights,this.m_weights=e.m_weights),ga(this,e)}afterCompletedModification(){ca(this)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return Ga(this,t,e,s)}endPointModified(){ca(this)}clearEndPointModified(){}setCpsAndWeights(e,s,n,i,r,o){(i<=0||o<=0||r<0)&&t("weights"),(e.isNAN()||s.isNAN()||n.isNAN())&&t("NAN control points in bezier are not supported"),this.setStartXY(e),this.m_cp.assign(s),this.m_weights[0]=i,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(n)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}Dn.type=e.enumRationalBezier2;var wn=b;class An extends ds{constructor(t){void 0===t||bt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new $(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):r("unexpected constructor args")}getBoundary(){return Js(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),ri(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),ri(this)}getGeometryType(){return e.enumBezier2}queryEnvelope(t){if(2===t.m_EnvelopeType){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=xi(this);if(null!==e){const s=new $;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[];hi(this,e);const s=new $;for(const n of e)this.queryCoord2D(n,s),t.mergeNe(s)}return}s("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){const e=ut($,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}n(0)}createInstance(){return new An({vd:this.m_description})}calculateLength2D(){return ui(this,1,!1)}calculateLowerLength2D(){return $.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return $.distance(this.getStartXY(),this.m_cp)+$.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const n=ut($,3);this.queryControlPoints(n),Zi(n,t,e,s)}queryCoord2DE(t,e){Hi(this,t,e)}queryCoord2DMP(t,e){n(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){const e=new $;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=St(this.getStartX(),this.m_cp.x,t),s=St(this.m_cp.x,this.getEndX(),t);return St(e,s,t)}{const e=Et(this.getStartX(),this.m_cp.x,t),s=Et(this.m_cp.x,this.getEndX(),t);return Et(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new $;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=St(this.getStartX(),this.m_cp.x,t),s=St(this.m_cp.x,this.getEndX(),t);return St(e,s,t)}{const e=Et(this.getStartY(),this.m_cp.y,t),s=Et(this.m_cp.y,this.getEndY(),t);return Et(e,s,t)}}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=wn.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=wn.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){Oi(this,t,e)}cutBezierIgnoreAttributes(e,s,n){if((e<0||s>1||e>s)&&t("Quadratic_bezier.cut_bezier_ignore_attributes"),0===e&&1===s)return n.setStartXY(this.getStartXY()),n.m_cp.assign(this.m_cp),void n.setEndXY(this.getEndXY());const i=ut($,3);this.queryControlPoints(i),Yi(i,e,s,i),n.constructPoints(i)}splitBezierIgnoreAttributes(t,e,s){n(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,r=wn.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return vt(r,o,a,i,wn.getDefaultValue(e))}getClosestCoordinate(t,e){return vi(this,t,U.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return vi(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(e,s){e.length<2&&t("");const i=ai(this);let r=0;if(2===i.specialPointsCount())return 0;n(e.length>=i.specialPointsCount()-1);for(let t=1,n=i.specialPointsCount();t<n;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[r],s),r++;for(let t=0;t<r;++t){Ai(e[t].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=ut(rt,3),r=ut(rt,2),o=new U(0,1);let a=0;if(t){if(i[0]=new rt(this.getStartY()).sub(e),i[1]=new rt(this.m_cp.y).subE(new rt(this.getStartY())).mulThisByPower2(2),i[2]=new rt(this.getStartY()).add(this.getEndY()).subE(new rt(this.m_cp.y).mulThisByPower2(2)),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordX(r[h].value())}else if(i[0]=new rt(this.getStartX()).sub(e),i[1]=new rt(this.m_cp.x).subE(new rt(this.getStartX())).mulThisByPower2(2),i[2]=new rt(this.getStartX()).add(this.getEndX()).subE(new rt(this.m_cp.x).mulThisByPower2(2)),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordY(r[h].value());if(n)for(let h=0;h<a;h++)n[h]=r[h].value();else s&&Dt(s,a);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],i=this.intersectionWithAxis2D(!0,t,s,null);return n(2!==i),-1===i?e:s[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());n(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new le;this.queryEnvelope(t);const s=new U;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=ut($,4);this.queryControlPoints(s),Yi(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),n=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):n&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return ui(this,t,!0)}lengthToT(t){return pi(this,t)}calculateWeightedAreaCentroid2D(t){const e=ut($,3);ki(this,e);const s=e[2],n=e[1],i=new $,r=s.y*n.x-s.x*n.y;i.x=-(4*s.x+5*n.x)*r/60,i.y=-(4*s.y+5*n.y)*r/60;const o=fi(this);return i.x+=(e[0].x-t.x)*o,i.y+=(e[0].y-t.y)*o,i}calculateWeightedCentroid2D(){const t=new $;return this.isDegenerate(0)?(t.setCoords(0,0),t):yi(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Ii(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPoints(e){for(let s=0;s<3;s++)e[s].isNAN()&&t("NaN control points in bezier are not supported");this.m_XStart=e[0].x,this.m_YStart=e[0].y,this.m_cp.setCoordsPoint2D(e[1]),this.m_XEnd=e[2].x,this.m_YEnd=e[2].y,this.afterCompletedModification()}getTangent(t){const e=gt(t,0,1);let s=gi(this,1,e);return s.isZero()&&(s=gi(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return gi(this,1,gt(t,0,1))}getCurvature(t){const e=gi(this,1,t),s=gi(this,2,t),n=e.sqrLength();if(0===n)return Number.NaN;e.divThis(Math.sqrt(n));return e.crossProduct(s)/n}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const n=new le;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new $;this.queryCoord2D(i,r);return $.distance(r,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(e,s){const n=ai(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();e<i&&t("");for(let t=0;t<i;t++)s[t]=n.specialPoints[t];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){Q(this.m_XStart,this.m_XStart=this.m_XEnd),Q(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=ut($,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if($.distance(e[0],e[1])+$.distance(e[2],e[1])-n>t)return!1;const i=t,r=e[1].clone();r.subThis(e[0]);return!(Math.abs(r.crossProduct(s))/n>i)}copyIgnoreAttributes(t){const e=ut($,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return fi(this)}absNorm(){return Xi(this)}queryEnvelopeW(t,e){const s=ut($,3);this.queryControlPoints(s),Di(s,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return tr(this,t)}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(t){return er(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ai(this)}setCoordsForIntersector(t,e,s){Ni(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Ci(e,xi(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=Q(this.m_cp,this.m_cp=e.m_cp),oi(this,e)}afterCompletedModification(){ri(this)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return Si(this,t,e.length,e,s)}endPointModified(){ri(this)}clearEndPointModified(){}}An.type=e.enumBezier2;class Tn{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),n(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map(t=>t.clone()))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map(t=>t.clone()),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map(t=>t.clone()),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}scaleRangeToUnitInterval(t,e){const s=e;s.subThis(t);const n=this.power();for(let i=0;i<=n;i++){const e=new this.m_zeroCtor;for(let s=i;s<=n;s++){const n=this.m_elements[s];n.mulDoubleThis(he(s,i));const r=t.pow(s-i);n.mulThis(r),e.addThis(n)}const r=s.pow(i);e.mulThis(r),this.m_elements[i]=e}}fmSubThis(t,e){return n(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let n=0;n<=e;++n)this.m_elements[n].addThis(t.m_elements[n]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return n(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let n=0;n<=e;++n)this.m_elements[n].subThis(t.m_elements[n]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n].clone(),this.m_elements[n].negateThis();return this.updatePower(),this}sub0(t){return n(0),this}subNumber0(t){return n(0),this}subShifted(t,e){const s=this.power(),n=t.power()+e,i=Math.min(this.power(),n);let r=0;for(let o=e;o<=i;++o)this.m_elements[o].subThis(t.m_elements[r]),r++;if(n<=s)return this.updatePower(),this;this.m_elements.length=n+1;for(let o=s+1;o<this.m_elements.length;++o)this.m_elements[o]=new this.m_zeroCtor;for(let o=i+1;o<=n;++o)this.m_elements[o].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const n=this.power(),i=t.power()+s,r=Math.min(this.power(),i);let o=0;for(let a=s;a<=r;++a)this.m_elements[a].fmSubThis(t.m_elements[o],e),o++;if(i<=n)return this.updatePower(),this;this.m_elements.length=i+1;for(let a=n+1;a<this.m_elements.length;++a)this.m_elements[a]=new this.m_zeroCtor;for(let a=r+1;a<=i;++a)this.m_elements[a].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,n=this.power();t<=n;t++)for(let i=0,r=e.power();i<=r;i++){const n=this.m_elements[t].clone();n.mulThis(e.m_elements[i]),t+i<s.length?s[t+i].addThis(n):s.push(n)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulDoubleThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulDoubleThis(t);return this.updatePower(),this}mulNumber0(t){return n(0),this}mulBigint0(t){return n(0),this}mulBigIntThis(t){return n(0),this}mulInt320(t){return n(0),this}div0(t){return n(0),this}absThis(){return n(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const n=t.getElement(t.power()),i=this.clone();let r=i.power();const o=i.power()-t.power();let a=o;for(e.m_elements=ut(e.m_zeroCtor,o+1);;){if(r<t.power()){s.assignMove(i);break}if(r===i.power()){const s=i.getElement(i.power());s.divThis(n),i.subShiftedWithCoef(t,s,i.power()-t.power()),e.m_elements[a]=s.clone()}a--,r--}s.updatePower(),e.updatePower()}divThis(t){return n(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let n=0;n<=e;++n)this.m_elements[n].subThis(t.m_elements[n]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n].clone(),this.m_elements[n].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){n(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let n=e-1;n>=0;--n)s.mulThis(t),s.addThis(this.m_elements[n]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,n=this.power();s<=n;s++){let n=BigInt(s);for(let e=s-1,i=s-t;e>i;--e)n*=BigInt(e);e.m_elements[s-t].mulBigIntThis(n)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(tt.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce((t,e)=>{const s=e.hiBitIndex();return t<s?s:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}evaluateDerivative(t){const e=this.power(),s=this.m_elements[e];s.mulDoubleThis(e);for(let n=e-1;n>=1;--n){s.mulThis(t);const e=this.m_elements[n];e.mulDoubleThis(n),s.addThis(e)}return s}static evaluateCoefs(t,e,s){const n=t.power();s.construct0(t.getElement(0).evaluate(e));for(let i=1;i<=n;++i)s.addElement(t.getElement(i).evaluate(e));s.updatePower()}}class In extends Tn{constructor(t){super(void 0===t?{zeroCtor:tt}:{...t,zeroCtor:tt})}clone(){return new In({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const n=t.clone();n.absThis();for(let i=e-1;i>=0;--i)s.mulThis(n),s.addThis(this.m_elements[i].abs());return s}}class Mn extends Tn{constructor(t){super(void 0===t?{zeroCtor:In}:{...t,zeroCtor:In})}clone(){return new Mn({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new In({coef0:t[s]}));return this.updatePower(),this}}function Yn(){return{polypoly1:new Mn,polypoly2:new Mn,polyX2:new In,polyY2:new In,polyX2Deriv:new In,polyY2Deriv:new In,polypolyX1:new Mn,polypolyY1:new Mn,polypolyX1Deriv:new Mn,polypolyY1Deriv:new Mn,lazyPolypolyD1:new Mn,lazyPolypolyD1Deriv:new Mn,lazyPolyD2:new In,lazyPolyD2Deriv:null,polypoly11:new Mn,polypoly12:new Mn,tempPp:new Mn,tempPp1:new Mn,tempPp2:new Mn,tempP:new In,tempP1:new In,tempP2:new In}}function Nn(t,e,s,i,o,a,h,u,m,l,c,g,d,_,p,f,P,y,x,C=!1){const v=Yn();v.polyX2.construct(h,u),v.polyY2.construct(m,l),v.polypolyX1.constructFromMPValues(t,e),v.polypolyY1.constructFromMPValues(s,i),v.polypoly11.assignCopy(v.polypolyX1),v.polypoly12.assignCopy(v.polypolyY1),c&&(v.lazyPolyD2.construct(c,g),v.polypoly11.mulElementThis(v.lazyPolyD2),v.polypoly12.mulElementThis(v.lazyPolyD2)),o?(v.lazyPolypolyD1.constructFromMPValues(o,a),v.lazyPolypolyD1Deriv=new Mn({copy:v.lazyPolypolyD1}),v.lazyPolypolyD1Deriv.derivative1This(),v.tempPp.assignCopy(v.lazyPolypolyD1),v.tempPp.mulElementThis(v.polyX2),v.polypoly11.subThis(v.tempPp),v.tempPp.assignCopy(v.lazyPolypolyD1),v.tempPp.mulElementThis(v.polyY2),v.polypoly12.subThis(v.tempPp)):(v.polypoly11.sub0This(v.polyX2),v.polypoly12.sub0This(v.polyY2)),v.polypolyX1Deriv.assignCopy(v.polypolyX1),v.polypolyX1Deriv.derivative1This(),v.polypolyY1Deriv.assignCopy(v.polypolyY1),v.polypolyY1Deriv.derivative1This(),o&&(v.polypolyX1Deriv.mulThis(v.lazyPolypolyD1),v.tempPp2.assignCopy(v.lazyPolypolyD1Deriv),v.tempPp2.mulThis(v.polypolyX1),v.polypolyX1Deriv.subThis(v.tempPp2),v.polypolyY1Deriv.mulThis(v.lazyPolypolyD1),v.tempPp2.assignCopy(v.lazyPolypolyD1Deriv),v.tempPp2.mulThis(v.polypolyY1),v.polypolyY1Deriv.subThis(v.tempPp2)),v.polyX2Deriv.assignCopy(v.polyX2),v.polyX2Deriv.derivative1This(),v.polyY2Deriv.assignCopy(v.polyY2),v.polyY2Deriv.derivative1This(),c&&(n(null===v.lazyPolyD2Deriv),v.lazyPolyD2Deriv=new In({copy:v.lazyPolyD2}),v.lazyPolyD2Deriv.derivative1This(),v.polyX2Deriv.mulThis(v.lazyPolyD2),v.tempP1.assignCopy(v.lazyPolyD2Deriv),v.tempP1.mulThis(v.polyX2),v.polyX2Deriv.subThis(v.tempP1),v.polyY2Deriv.mulThis(v.lazyPolyD2),v.tempP1.assignCopy(v.lazyPolyD2Deriv),v.tempP1.mulThis(v.polyY2),v.polyY2Deriv.subThis(v.tempP1)),v.polypoly1.assignCopy(v.polypoly11),v.polypoly1.mulElementThis(v.polyX2Deriv),v.tempPp.assignCopy(v.polypoly12),v.tempPp.mulElementThis(v.polyY2Deriv),v.polypoly1.addThis(v.tempPp),v.polypoly2.assignCopy(v.polypolyX1Deriv),v.polypoly2.mulElementThis(v.polyY2Deriv),v.tempPp.assignCopy(v.polypolyY1Deriv),v.tempPp.mulElementThis(v.polyX2Deriv),v.polypoly2.subThis(v.tempPp);let b=[];const S=[];P||(P=[]),f||(f=[]),Gn(v.polypoly11,v.polypoly12,v.tempP);const E=64,D=ee.ldexp(-59).toDouble(),w=[];let A=Wn(v.tempP,d,p,D,E,w,y,y);if(A<0)return-1;for(let Y=0;Y<A;Y++){const t=v.tempP1,e=v.tempP2;In.evaluateCoefs(v.polypoly11,w[Y],t);const s=se(t.m_elements,t.power()+1);s.sort((t,e)=>t.compare(e)),In.evaluateCoefs(v.polypoly12,w[Y],e);const i=se(e.m_elements,e.power()+1);i.sort((t,e)=>t.compare(e));const o=s[0],a=s.at(-1),h=i[0],u=i.at(-1);a.subThis(o),u.subThis(h);const m=a.subThis(u).GEZ(),l=58,c=ee.ldexp(-59).toDouble(),g=[];let p;if(p=Wn(m?t:e,d,_,c,l,g,y,y),p<0&&r("mp_curve_proximity"),p>0){const s=m?e:t;for(let t=0;t<p;t++){let e;if(m){const s=v.tempP;In.evaluateCoefs(v.polypoly12,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}else{const s=v.tempP;In.evaluateCoefs(v.polypoly11,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}const i=s.evaluateDerivative(g[t]).abs().mulDoubleThis(Number.EPSILON),r=s.evaluate(g[t]);i.addThis(e.sub(r).absThis()),i.ldexpThis(3),r.absThis(),r.lt(i)?S.push(Yt(g[t].toDouble(),w[Y].toDouble())):n(r.gte(i))}}}A=S.length,Gn(v.polypoly1,v.polypoly2,v.tempP);const T=[];let I=Wn(v.tempP,d,p,D,E,T);I<0&&(I=0);for(let n=0;n<I;n++){In.evaluateCoefs(v.polypoly1,T[n],v.tempP1);const t=[];let e=Wn(v.tempP1,d,_,D,E,t);if(0!==e)if(In.evaluateCoefs(v.polypoly2,T[n],v.tempP2),e<0){if(e=Wn(v.tempP2,d,_,D,E,t),e<0)continue;for(let s=0;s<e;s++)b.push(Yt(t[s].toDouble(),T[n].toDouble()))}else{const s=v.tempP2.absEvaluate(ee);s.mulThis(tt.constructDouble(1e-12));for(let i=0;i<e;i++){const e=v.tempP2.evaluate(t[i]);e.absThis(),e.lt(s)&&b.push(Yt(t[i].toDouble(),T[n].toDouble()))}}}if(I=b.length,0===A&&0===I)return 0;b=b.concat(S),b.sort((t,e)=>C?kt(t.second,e.second):kt(t.first,e.first));const M=ne(b,(t,e)=>t.first===e.first&&t.second===e.second);b=b.slice(0,M),f.length=0,P.length=0;for(const n of b)f.push(n.first),P.push(n.second);return n(f.length===P.length),P.length}function Xn(t,e,s,n,i,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(tt.constructInt32(1)).isZero();if(1===t.power()){const s=Vn(t.getElement(1),t.getElement(0),e,r.at(0));return r[0].limitPrecisionThis(n),1!==s?0:(r[0].limitPrecisionThis(n),1)}if(2===t.power()){return Ln(t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(3===t.power()){return Rn(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(4===t.power()){return zn(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}return On(t,e,s,n,a,i,r,o)}function qn(){return{polyIntersect:new In,polyX1:new In,polyY1:new In,polyX1Deriv:new In,polyY1Deriv:new In,lazyPolyD1:new In,lazyPolyD1Deriv:new In,tempP:new In,tempP1:new In,tempP2:new In,polypoly1Proximity:new Mn,polypoly2Proximity:new Mn}}function Fn(t,e,s,n,i,r,o,a,h,u,m,l,c){const g=qn();g.polyX1.construct(t,e),g.polyY1.construct(s,n),g.polyX1Deriv.assignCopy(g.polyX1),g.polyX1Deriv.derivative1This(),g.polyY1Deriv.assignCopy(g.polyY1),g.polyY1Deriv.derivative1This(),g.polyIntersect.assignCopy(g.polyX1),g.polyIntersect.mulThis(g.polyX1),g.polyIntersect.mulElementThis(o[0]),g.tempP.assignCopy(g.polyY1),g.tempP.mulThis(g.polyY1),g.tempP.mulElementThis(o[1]),g.polyIntersect.addThis(g.tempP),i?(g.lazyPolyD1.construct(i,r),g.tempP.assignCopy(g.lazyPolyD1),g.tempP.mulThis(g.lazyPolyD1),g.tempP.mulElementThis(o[2]),g.polyIntersect.addThis(g.tempP)):g.polyIntersect.add0(o[2]);{const i=o[0].clone(),r=i.clone();r.sqrThis();const a=o[1].clone(),h=a.clone();h.sqrThis();const u=o[2].clone(),m=i.clone();m.subThis(a),g.polyX1.construct(t,e),g.polyX1Deriv.assignCopy(g.polyX1),g.polyX1Deriv.derivative1This(),g.polyY1.construct(s,n),g.polyY1Deriv.assignCopy(g.polyY1),g.polyY1Deriv.derivative1This(),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1),g.tempP.mulElementThis(h),g.tempP.mulElementThis(u),g.polypoly1Proximity.construct0(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(a.mul(m).mul(u).ldexpThis(1)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1),g.tempP.mulElementThis(i.mul(h)),g.tempP1.assignCopy(g.polyY1),g.tempP1.mulThis(g.polyY1),g.tempP1.mulElementThis(r.mul(a)),g.tempP.addThis(g.tempP1),g.tempP.add0(m.mul(m).mul(u)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulElementThis(m.mul(i).mul(a).ldexpThis(1)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.construct0(i.mul(m).mul(m)),g.polypoly1Proximity.addElement(g.tempP),g.polypoly1Proximity.updatePower(),g.tempP.construct0(te),g.polypoly2Proximity.construct0(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1Deriv),g.tempP1.assignCopy(g.polyY1),g.tempP1.mulThis(g.polyY1Deriv),g.tempP.addThis(g.tempP1),g.tempP.mulElementThis(i.mul(a)),g.polypoly2Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1Deriv),g.tempP.mulElementThis(m.mul(i)),g.polypoly2Proximity.addElement(g.tempP),g.polypoly2Proximity.updatePower()}const d=[],_=[];null===m&&(m=[]);let p=2*g.polyIntersect.power()+58;const f=.5*Number.EPSILON,P=[],y=Wn(g.polyIntersect,a,h,f,p,P,l,l);if(y<0)return-1;for(const b of P)_.push(b.toDouble());Gn(g.polypoly1Proximity,g.polypoly2Proximity,g.tempP),p=2*g.tempP.power()+58,P.length=0;let x=Wn(g.tempP,a,h,f,p,P);if(x<0&&(x=0),0===y&&0===x)return 0;for(const b of P)d.push(b.toDouble());const C=d.concat(_);m.length=C.length,st(m,C,0,0,C.length),Wt(m);const v=ne(m,(t,e)=>0===kt(t,e));return m.length=v,m.length}function Vn(t,e,s,n){return t.isZero()?e.isZero()?-1:0:(n.setThis(e),n.negateThis(),n.divThis(t),s.isEmpty()||s.containsCoordinate(n.value())?1:0)}function Ln(t,e,s,n,i,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),i.containsCoordinate(1)?1:0;return Vn(e,s,i,o[0])}if(r){let e=2;return o[0].setInt32(1),s.equals(t)?(o[1].setInt32(1),e=1):o[1].setThis(s.div(t)),i.containsCoordinate(o[1].value())||(e=1),i.containsCoordinate(o[0].value())||(e--,o[0].setThis(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=Q(o[0],o[0]=o[1])),e}const a=e.clone();a.sqrThis();const h=t.clone();if(h.mulThis(s).ldexpThis(2).negateThis().addThis(a),h.LZ())return 0;const u=n+2,m=tt.sqrt(h,u),l=m.clone();e.LZ()&&l.negateThis(),l.addThis(e).limitPrecisionThis(u).ldexpThis(-1).negateThis();let c=0;return o[0].setThis(l).divThis(tt.constructAssign(t,u)).limitPrecisionThis(n),(i.isEmpty()||i.containsCoordinate(o[0].value()))&&c++,m.isZero()||l.isZero()||(o[c].setThis(s).divThis(l).limitPrecisionThis(n),(i.isEmpty()||i.containsCoordinate(o[c].value()))&&c++,2===c&&o[0].gt(o[1])&&(o[1]=Q(o[0],o[0]=o[1]))),c}function Rn(t,e,s,i,r,o,a,h){if(t.isZero()){return Ln(e,s,i,r,o,a,h)}const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=Q(h[t],h[t]=h[s-1]),s--);e=s}return ft(h,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let n=0;o.containsCoordinate(0)&&(h[0].setInt32(0),n=1);return u(Ln(t,e,s,r,o,a,h.slice(1)),n)}if(a){let s=0;o.containsCoordinate(1)&&(h[0].setInt32(1),s=1);const n=e.add(t),a=i.negate(),m=t.add(n).add(a).isZero();return u(Ln(t,n,a,r,o,m,h.slice(s)),s)}const m=new tt,l=new tt,c=new tt,g=e.clone();if(g.isZero())l.setThis(s),l.divThis(t),c.setThis(i),c.divThis(t);else{g.divThis(t).divDoubleThis(3).negateThis();const n=e.clone();n.sqrThis();const r=t.clone();r.sqrThis(),l.setThis(t),l.mulThis(s).mulDoubleThis(3).subThis(n).divThis(r).divDoubleThis(3),c.setThis(n),c.mulThis(e),c.ldexpThis(1),m.setThis(t),m.mulThis(e).mulThis(s).mulDoubleThis(9),c.subThis(m),m.setThis(r),m.mulThis(i).mulDoubleThis(27),c.addThis(m),c.divThis(r).divThis(t).divDoubleThis(27)}if(l.isZero()){const t=c.clone();return t.negateThis(),t.isZero()?(h[0].setThis(g),Kn(o,r,h,1)):(h[0].setThis(tt.cubicRoot(t,r).add(g)),Kn(o,r,h,1))}const d=c.clone();if(d.sqrThis().ldexpThis(-2),m.setThis(l.clone()),m.sqrThis().mulThis(l).divDoubleThis(27),d.addThis(m),d.isZero())return h[0].setThis(c),h[0].mulDoubleThis(3).divThis(l),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(g),h[1].addThis(g),Kn(o,r,h,2);if(d.GZ())return d.setThis(tt.sqrt(d,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.addThis(d),h[0].setThis(tt.cubicRoot(m,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.subThis(d),h[0].addThis(tt.cubicRoot(m,r+8)),h[0].addThis(g),Kn(o,r,h,1);m.setThis(l),m.divDoubleThis(3).negateThis(),n(m.GEZ());const _=tt.sqrt(m,r+8),p=_.clone();p.negateThis(),p.addThis(g),_.addThis(g);const f=tt.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),P=tt.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),y=new In({zeroCtor:tt});y.construct0(i),y.addElement(s),y.addElement(e),y.addElement(t);const x=new In({copy:y});x.derivative1This();let C=0;const v=ut(tt,4);v[C++].setThis(f),p.gt(f)&&p.lt(P)&&v[C++].setThis(p),_.gt(f)&&_.lt(P)&&v[C++].setThis(_),v[C++].setThis(P);const b=3*r;let S=52,E=Number.EPSILON;for(;S<b;)2*S<=b?(E*=E,S*=2):(E*=Number.EPSILON,S+=52);S+=2;let D=0,w=!1;for(let n=1;n<C;n++){if(Hn(y,x,v[n-1],v[n],E,S,h[0])){D=1,w=n+1<C;break}}if(!D)return 0;if(w){const t=new In({zeroCtor:tt,coef0:h[0]});t.negateThis(),t.addElement(ee);const e=new In({zeroCtor:tt}),s=new In({zeroCtor:tt});y.div(t,e,s),n(2===e.power()),n(0===s.power());const i=Ln(e.getElement(2),e.getElement(1),e.getElement(0),r,o,!1,h.slice(1));n(i>=0&&i<=2),D+=i}return Kn(o,r,h,D)}function zn(t,e,s,n,i,r,o,a,h){if(t.isZero())return Rn(e,s,n,i,r,o,a,h);const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=Q(h[t],h[t]=h[s-1]),s--);e=s}return ft(h,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let i=0;o.containsCoordinate(0)&&(h[0].setInt32(0),i=1);return u(Rn(t,e,s,n,r,o,a,h.slice(i)),i)}const m=new In({zeroCtor:tt,coef0:i});if(m.addElement(n),m.addElement(s),m.addElement(e),m.addElement(t),a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const e=new In({zeroCtor:tt,coef0:tt.constructInt32(-1)});e.addElement(tt.constructInt32(1));const s=new In({zeroCtor:tt}),n=new In({zeroCtor:tt});m.div(e,s,n);return u(Rn(3===s.power()?s.getElement(3):te.clone(),s.power()>=2?s.getElement(2):te.clone(),s.power()>=1?s.getElement(1):te.clone(),s.getElement(0),r,o,s.evaluate(ee).isZero(),h.slice(t)),t)}if(m.getElement(0).isZero()){let t=0;for(o.containsCoordinate(0)&&(t=1,h[0].setDouble(0));m.getElement(0).isZero()&&m.power()>0;)m.shiftRight(1);const e=Rn(3===m.power()?m.getElement(3):te.clone(),m.power()>=2?m.getElement(2):te.clone(),m.power()>=1?m.getElement(1):te.clone(),m.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),ft(h,0,t,(t,e)=>t.compare(e)),t}let l=52,c=Number.EPSILON;for(;l<r;)2*l<=r?(c*=c,l*=2):(c*=Number.EPSILON,l+=52);l+=2;const g=Qn(m),d=tt.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(g.lt(d)?g:d).mul(tt.constructDouble(c)).toDouble(),On(m,o,c,l,a,!1,h,4)}function Bn(t,e){let s=t,n=e;n.power()>s.power()&&(n=Q(s,s=n));const i=s.power()-n.power(),r=new In({copy:s.getElement(s.power())});s.mulThis(n.getElement(n.power()));for(let o=0,a=s.power();o<a;o++)if(o>=i){const t=new In({copy:n.getElement(o-i)});t.mulThis(r);const e=s.getElement(o).sub(t);s.setElement(o,e)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),kn(s)}function kn(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Gn(t,e,s){const n=t.clone(),i=e.clone();for(kn(n),kn(i);0!==n.power()||0!==i.power();)Bn(n,i);s.assignMove(n.getElement(0))}function Wn(t,e,s,n,i,r,o=!1,a=!1){r.length=0;const h=t.power(),u=ut(tt,2*h+4),m=Xn(t,s||U.unit(),n,i,!1,u,u.length);if(m>0){r.length=0;for(let t=0;t<m;t++){const e=u[t];t>0&&e.lte(r.at(-1))||r.push(e.clone())}return r.length}return m}function jn(t,e,s){if(n(s>=1),0===t.power())return t.isZero()?-1:0;const i=t.getElement(0);return i.negateThis(),i.divThis(t.getElement(1)),e[0].setThis(i),1}function Zn(t,e,s,i){if(t.power()<2)return jn(t,s,i);n(i>=1);let r=t.getElement(1);r.mulThis(t.getElement(1));const o=t.getElement(0);if(o.mulThis(t.getElement(2)),o.ldexpThis(2),r.subThis(o),r.LZ())return 0;if(r.isZero()){const n=t.getElement(1);return n.negateThis(),n.divThis(t.getElement(2)),n.ldexpThis(-1),n.limitPrecisionThis(e),s[0].setThis(n),1}n(i>=2),r=tt.sqrt(r,e+8);const a=t.getElement(1);a.negateThis();const h=a.clone();h.subThis(r),h.divThis(t.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(e);const u=a.clone();return u.addThis(r),u.divThis(t.getElement(2)),u.ldexpThis(-1),u.limitPrecisionThis(e),h.lt(u)?(s[0].setThis(h),s[1].setThis(u)):(s[1].setThis(h),s[0].setThis(u)),2}function Hn(t,e,s,n,i,o,a){let h=s.clone(),u=n.clone();h.limitPrecisionThis(o),u.limitPrecisionThis(o);let m=t.evaluate(h);m.limitPrecisionThis(o+2);let l=t.evaluate(u);if(l.limitPrecisionThis(o+2),m.GEZ()&&l.GEZ()||m.LEZ()&&l.LEZ())return m.absLessAbs(l)?(a=h,m.isZero()):(a=u,l.isZero());const c=l.LZ();c&&(l=Q(m,m=l),u=Q(h,h=u));const g=c?u:h,d=c?h:u,_=h.add(u).ldexpThis(-1);_.limitPrecisionThis(o);const p=u.sub(h);p.limitPrecisionThis(o),p.absThis();const f=p.clone();let P=t.evaluate(_),y=e.evaluate(_);const x=new In({copy:t}),C=new In({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),n=ee.clone();n.ldexpThis(-(o+2));for(let i=64;i<s;){x.limitPrecisionThis(i),C.limitPrecisionThis(i);const r=x.evaluate(_),o=C.evaluate(_),a=r.sub(P),h=o.sub(y);if(a.divThis(P).absThis().lt(n)&&(y.isZero()||h.divThis(y).absThis().lt(n)))break;x.assignCopy(t),C.assignCopy(e),i=Math.min(i+64,s)}P.limitPrecisionThis(o+2),y.limitPrecisionThis(o+2)}const v=1,b=4;let S=b;const E=2;let D=1,w=0,A=0,T=v;const I=32,M=tt.constructDouble(.25*i),Y=tt.constructDouble(.5001);let N=0;const X=300;for(;++N<X;){if(N>I&&w>0||y.isZero()||T===E&&w>1||T===v&&S<b)T=v,D>1&&D--;else if(T=E,A>1){const t=p.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&D++}p.setThis(f);const t=new tt;let e=!1;if(T===v)do{if(A>2){const e=p.clone();if(e.absThis(),e.ldexpThis(4),d.sub(g).ldexpThis(-1).gt(e)){if(_.equals(g)){t.setThis(_),_.setThis(g.add(e)),_.limitPrecisionThis(o),f.setThis(_.sub(t));break}if(_.equals(d)){t.setThis(_),_.setThis(d.sub(e)),_.limitPrecisionThis(o),f.setThis(_.sub(t));break}}}f.setThis(u.sub(h)),f.ldexpThis(-1),f.limitPrecisionThis(o),t.setThis(_),_.setThis(h.add(f)),_.limitPrecisionThis(o),_.lt(g)?_.setThis(g):_.gt(d)&&_.setThis(d),e=h.equals(_)||u.equals(_)}while(0);else for(;;){if(f.setThis(P.div(y)),f.limitPrecisionThis(o),1!==D&&f.mulDoubleThis(D),t.setThis(_),_.subThis(f),_.limitPrecisionThis(o),e=_.equals(t),_.lt(g)){if(D>1){_.setThis(t),D--;continue}f.setThis(t.sub(g)),_.setThis(g)}else if(_.gt(d)){if(D>1){_.setThis(t),D--;continue}f.setThis(t.sub(d)),_.setThis(d)}break}if(e||f.absLessAbs(M)){t.equals(_)||(P=x.evaluate(_),P.limitPrecisionThis(o+2));break}P=x.evaluate(_),P.limitPrecisionThis(o+2),y=C.evaluate(_),y.limitPrecisionThis(o+2);const s=h.clone(),n=u.clone();P.LZ()?(m.setThis(P),h.setThis(_)):(l.setThis(P),u.setThis(_)),T===E&&(h.equals(s)&&u.equals(n)||A>1&&!f.absLessAbs(Y.mul(p)))?w++:w=0,T===v?(S++,A=0):(S=0,A++)}return N>=X&&r("Root_finder iterations exceeded"),a.setThis(_),!0}function Un(t,e,s,n,i){const r=t.evaluate(s);if(r.isZero())return!0;const o=tt.constructDouble(.5*n),a=s.clone();a.subThis(o);const h=t.evaluate(a),u=s.clone();u.addThis(o);const m=t.evaluate(u);if(h.LZ()&&m.GZ()||h.GZ()&&m.LZ())return!0;if(r.GZ()?h.LEZ()||m.LEZ():h.GEZ()||m.GEZ())return!0;const l=h.LEZ()&&m.LEZ(),c=h.GEZ()&&m.GEZ();let g=!1;return l?r.gt(h)&&r.gt(m)&&(g=!0):c&&r.lt(h)&&r.lt(m)&&(g=!0),!!g&&r.absThis().lt(tt.constructDouble(1e-17))}function On(t,e,s,i,r,o,a,h){n(s>0),n(h>=t.power());const u=a,m=[];let l=[];const c=new In({zeroCtor:t.m_zeroCtor}),g=new In({zeroCtor:t.m_zeroCtor}),d=new In({zeroCtor:t.m_zeroCtor}),_=tt.constructDouble(s),p=tt.constructDouble(e.vmin),f=tt.constructDouble(e.vmax),P=p.sub(_),y=f.add(_),x=Qn(t),C=x.clone();if(C.negateThis(),P.lt(C))P.setThis(C.sub(_));else if(P.gt(x))return 0;if(y.gt(x))y.setThis(x.add(_));else if(y.lt(C))return 0;let v=t,b=null;if(r){const e=new In({coef0:tt.constructInt32(-1)});e.addElement(ee),b=new In,v=b;const s=new In,n=new In;for(t.div(e,s,n),b.assignCopy(s);v.evaluate(ee).isZero();)v.div(e,s,n),b.assignCopy(s)}let S=!1;if(v.power()>0&&v.getElement(0).isZero())for(S=!0,b||(b=new In({copy:v}),v=b);v.getElement(0).isZero();)b.shiftRight(1);let E=i+2*v.power()+2,D=s/Math.pow(2,v.power()+2),w=E;if(te.gt(P)&&te.lt(y))for(let n=0,Y=v.power();n<Y;n++)if(v.getElement(n).isZero()){m.push(te.clone());break}for(let Y=v.power()-1;Y>0;Y--){if(D*=2,E-=2,w-=2,v.power()-Y===1){g.assignMove(v.derivative(Y));1===jn(g,u,h)&&(u[0].gt(P)&&u[0].lt(y)&&!u[0].isZero()&&m.push(u[0].clone()),c.assignMove(g),d.assignMove(v.derivative(Y-1)));continue}if(v.power()-Y===2){g.assignMove(v.derivative(Y));const t=Zn(g,E,u,h);n(t>=0&&t<=2);for(let e=0;e<t;e++)u[e].gt(P)&&u[e].lt(y)&&!u[e].isZero()&&m.push(u[e].clone());if(m.length>1&&m.sort((t,e)=>t.compare(e)),m.length>0){let t=m[0].sub(_);t.limitPrecisionThis(w),l.push(Yt(P.clone(),t));let e=1===m.length?y.clone():m[1].sub(_);t=m[0].add(_),t.limitPrecisionThis(w),e.limitPrecisionThis(w),l.push(Yt(t,e)),m.length>1&&(e=2===m.length?y.clone():m[2].sub(_),e.limitPrecisionThis(w),t=m[1].add(_),t.limitPrecisionThis(w),l.push(Yt(t,e)),m.length>2&&(t=m[2].add(_),t.limitPrecisionThis(w),l.push(Yt(t,y.clone()))))}else l.push(Yt(P.clone(),y.clone()));c.assignCopy(g),d.assignMove(v.derivative(Y-1));continue}{g.assignMove(d),d.assignMove(v.derivative(Y-1));let t=[];for(let e=0,s=l.length;e<s;++e)if(l[e].first.lte(l[e].second)){const s=new tt;if(Hn(g,c,l[e].first,l[e].second,D,E,s)){m.push(s);let n=s.sub(_);n.limitPrecisionThis(w),t.push(Yt(l[e].first,n)),n=s.add(_),n.limitPrecisionThis(w),t.push(Yt(n,l[e].second))}else t.push(l[e])}l=t,t=[],c.assignMove(g)}}m.sort((t,e)=>t.compare(e)),0===l.length&&(c.assignMove(v.derivative(v.power())),c.isZero()||l.push(Yt(P.clone(),y.clone())));let A=0,T=0,I=0;const M=new tt;for(;;){if(T<l.length){if(l[T].first.gt(l[T].second)){T++;continue}let t=!1;if(I<m.length&&m[I].lt(l[T].first)&&(t=!0),!t){Hn(v,c,l[T].first,l[T].second,s,i,M)&&(M.lt(p)?u[A++].setThis(p):M.gt(f)?u[A++].setThis(f):u[A++].setThis(M)),T++;continue}}if(!(I<m.length))break;0!==I&&m[I-1].equals(m[I])||Un(v,c,m[I],s)&&(M.setThis(m[I]),M.lt(p)?M.setThis(p):M.gt(f)&&M.setThis(f),0!==A&&u[A].equals(M)||u[A++].setThis(M)),I++}return S&&te.gt(P)&&te.lt(y)&&(u[A++].setThis(te),ft(u,0,A,(t,e)=>t.compare(e))),r&&ee.gt(P)&&ee.lt(y)&&(u[A++].setThis(ee),ft(u,0,A,(t,e)=>t.compare(e))),A}function Qn(t){const e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();const s=te.clone();for(let n=0,i=t.power();n<i;n++){const e=t.getElement(n);e.limitPrecisionThis(53),e.gt(s)&&s.setThis(e)}return s.divThis(e),s.addThis(ee),s.mulThis(tt.constructDouble(1+100*Number.EPSILON)),s}function Kn(t,e,s,n){let i=n;if(!t.isEmpty()){i=0;for(let e=0;e<n;++e)t.containsCoordinate(s[e].value())&&(i!==e&&s[i].setThis(s[e]),i++)}i>1&&(s[0].gt(s[1])&&(s[1]=Q(s[0],s[0]=s[1])),i>2&&(s[0].gt(s[2])&&(s[2]=Q(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=Q(s[1],s[1]=s[2]))));for(let r=0;r<i;++r)s[r].limitPrecisionThis(e);return i}function $n(t,e,s,n,i,r){return ei(t,e,s,r,n,i)}function Jn(t,e,s,n,i,r){let o=i;if(n)return r[0]=1,o=.5*(e-t)*(s(t)+s(e)),o;const a=r[0],h=(e-t)/a,u=t,m=new O(0);for(let l=1;l<=r[0];++l){const t=(l-.5)*h;m.add(s(u+t))}return o=.5*(o+(e-t)*m.getResult()/a),r[0]*=2,o}function ti(t,e,s,n,i,r,o){let a=0,h=Math.abs(i-s[t]);const u=et(e,Number.NaN),m=et(e,Number.NaN);for(let d=0;d<e;++d){const e=Math.abs(i-s[t+d]);e<h&&(a=d,h=e),u[d]=n[t+d],m[d]=n[t+d]}let l=0,c=0,g=0;r[0]=n[t+a],a--;for(let d=1;d<e;d++){for(let n=0;n<e-d;n++){if(c=s[t+n]-i,g=s[t+n+d]-i,l=c-g,0===l)return!1;const e=(u[n+1]-m[n])/l;u[n]=c*e,m[n]=g*e}if(2*(a+1)<e-d){const t=a+1;o[0]=u[t]}else{const t=a;o[0]=m[t],a--}r[0]+=o[0]}return!0}function ei(e,s,n,i,o,a){if(n<s&&t("xTo < xFrom"),n===s)return 0;const h=[0];let u=Number.MAX_VALUE;const m=[Number.MAX_VALUE];let l=0;const c=32,g=et(c+1,Number.NaN),d=et(c+1,Number.NaN),_=[0];g[0]=1;let p=0,f=0;for(let t=0;t<c;t++){if(l=Jn(s,n,i,0===t,l,_),d[t]=l,t+1>=e){ti(t+1-e,e,g,d,0,h,m)||r("polynomial_interpolation");const s=o*Math.abs(h[0])+a,n=Math.abs(u-h[0]);if(n<=s&&Math.abs(m[0])<=s){if(p++,p>1&&(n<=.1*f||0===f||p>2))return h[0]}else p=0;f=n,u=h[0]}d[t+1]=d[t],g[t+1]=.25*g[t]}return h[0]}class si{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let ni=class{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-ui(this.b,e,!1):0}getError(t){return n(0),0}};function ii(t,e,s,n,i){let r=!0;const o=ut($,3);t.queryControlPoints(o);let a=r?0:1,h=o[1][a]-o[0][a],u=o[2][a]-o[0][a];const m=$n(5,e,s,n,i,t=>{let e;if(t<=.5){const s=St(0,h,t),n=St(h,u,t);e=St(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*di(o,1,t).length()});r=!1,a=r?0:1,h=o[1][a]-o[0][a],u=o[2][a]-o[0][a];const l=$n(5,e,s,n,i,t=>{let e;if(t<=.5){const s=St(0,h,t),n=St(h,u,t);e=St(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*di(o,1,t).length()});return new $(m,l)}function ri(t){t.m_cachedValues=null}function oi(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function ai(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new si;return hi(t,e.specialPoints),Ci(t,e),e}function hi(t,e){const s=ut($,3);t.queryControlPoints(s);const n=ut(rt,8);n[0].set(0);let i=1;{const t=ut(rt,3);Gi(s,t,!1);const e=ut(rt,2),r=new U(0,1);let o=gn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)lt(e[s].value(),0,1)||(n[i]=e[s],i++)}{const t=ut(rt,3);Wi(s,t,!1);const e=ut(rt,2),r=new U(0,1);let o=gn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)lt(e[s].value(),0,1)||(n[i]=e[s],i++)}if(n[i].set(1),i++,i>2){ft(n,0,i,(t,e)=>t.value()-e.value());let t=0,e=n[0].value(),s=1;for(let r=1;r<i;r++)n[r].eq(n[r-1])?(e+=n[r].value(),s++):(s>1&&(e/=s,n[t].set(e)),t++,n[t]=n[r],e=n[r].value(),s=1);t++,i=t}n[0].set(0),n[i-1].set(1),e.length=i;for(let r=0;r<i;r++)e[r]=n[r].value()}function ui(t,e,s){const n=ut($,3);return t.queryControlPoints(n),mi(n,e,s)}function mi(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+mi(t,1,!1)}if(1===e)return li(t);const n=ut($,3);return Mi(t,e,n,null),li(n)}function li(t){if(t[0].equals(t[1]))return $.distance(t[2],t[0]);if(t[1].equals(t[2]))return $.distance(t[0],t[2]);const e=$.distance(t[0],t[1])+$.distance(t[2],t[1]),s=$.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const n=1,i=ut($,3);Bi(t,i,!0);const r=4*(Bt(i[2].x)+Bt(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=Bt(i[1].x)+Bt(i[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r)){if(1e-14*Math.abs(a)>=Math.abs(o)){return Math.sqrt(a)*n}return 2/(3*o)*(Math.pow(o*n+a,1.5)-Math.pow(a,1.5))}const h=o/r,u=a/r,m=u-h*h,l=n+h;if(0===m){if(h>=0&&l>=0||h<=0&&l<=0){return Math.abs(.5*Math.sqrt(r)*(l*l-h*h))}return.5*Math.sqrt(r)*(l*l+h*h)}const c=Math.sqrt(m+l*l),g=Math.sqrt(u);return.5*Math.sqrt(r)*(l*c-h*g+m*Math.log(Math.abs((l+c)/(h+g))))}function ci(t,e){const s=gt(e,0,1);let n=di(t,1,s);return n.isZero()&&(n=di(t,2,s)),n}function gi(t,e,s){const n=ut($,3);return t.queryControlPoints(n),di(n,e,s)}function di(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):$.construct(0,0)}function _i(t,e,s){{const e=be.constructPoint2D(t[1]).subE(be.constructPoint2D(t[0])),n=new rt(1).subE(s),i=be.constructPoint2D(t[2]).subE(be.constructPoint2D(t[1])),r=e.mulE(n).addE(i.mulE(s));return r.mulThisE(new rt(2)),r}}function pi(t,e,s){const n=ui(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==en(new ni(t,e),U.unit(),1,i)&&r(""),i[0]}function fi(t){const e=ut($,3);return t.queryControlPoints(e),Pi(e)}function Pi(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function yi(t){const e=$.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function xi(t){return t.m_cachedValues}function Ci(t,e){t.m_cachedValues=e}function vi(t,e,s,n,i){_(U.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=ut($,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=bi(r,e,a);if(s.containsCoordinate(a[0]))o=$.distance(e,h);else{a[0]=s.vmin,Zi(r,a[0],h),o=$.distance(h,e);const t=new $;Zi(r,s.vmax,t);const n=$.distance(t,e);o>n&&(h.setCoordsPoint2D(t),a[0]=s.vmax,o=n)}if(!n)return a[0];if(s.vmin<=0){const n=new $;t.queryCoord2DExtended(-1,n,!0);const i=new $;t.queryCoord2D(s.vmin,i);const r=new fm({start:n,end:i}),u=r.getClosestCoordinate(e,!0);if(u<1){const t=r.getCoord2D(u),s=$.distance(t,e);s<o&&(o=s,a[0]=u-1,h.assign(t))}}if(s.vmin>=1){const n=new $;t.queryCoord2DExtended(2,n,!0);const i=new $;t.queryCoord2D(s.vmax,i);const r=new fm({start:i,end:n}),u=r.getClosestCoordinate(e,!0);if(u>0){const t=r.getCoord2D(u),s=$.distance(t,e);s<o&&(o=s,a[0]=1+u,h.assign(t))}}return a[0]}function bi(t,e,s){const n=t[2].sub(t[1]).sub(t[1].sub(t[0])),i=t[1].sub(t[0]),r=t[0].sub(e),o=r.dotProduct(i),a=r.dotProduct(n)+2*i.dotProduct(i),h=3*i.dotProduct(n),u=n.dotProduct(n),m=et(3,Number.NaN),l=rn(u,h,a,o,U.unit(),!1,m),c=t[0].clone();let g=0,d=$.sqrDistance(t[0],e),_=$.sqrDistance(t[2],e);_<d&&(g=1,c.assign(t[2]),d=_);for(let p=0;p<l;p++){const s=new $;Zi(t,m[p],s),_=$.sqrDistance(s,e),_<d&&(d=_,c.assign(s),g=m[p])}return s&&(s[0]=g),c}function Si(t,e,s,n,i,r){const o=new fe;if(Ei(t,U.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=new $,h=vi(t,e,U.unit(),!1);t.queryCoord2D(h,a);return $.distance(a,e)<=i?(n&&(n[0]=h),1):0}function Ei(t,e,s){const n=ut($,3);t.queryControlPoints(n),Di(n,e,s)}function Di(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const n=ut($,3);Yi(t,e.vmin,e.vmax,n),s.setFromPoints(n,3)}function wi(t,e,s){s.setEmpty();const n=[];n.push(new U(0,1));const i=.5*Math.max(e.width(),e.height());for(;n.length;){const r=n.at(-1);n.pop();const o=new fe;if(Di(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=i||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();n.push(U.construct(r.vmin,t)),n.push(U.construct(t,r.vmax))}}}}function Ai(t){const e=ut($,3);t.queryControlPoints(e);const s=Ti(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ti(t){let e=!1;for(let s=0;s<2;s++){const n=J(t[0][s],t[2][s]);n>0?(J(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),J(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?(J(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),J(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Ii(e,s,n){void 0===n&&(n=s,s=0);const i=new $;if(s<0||n>1)return i.setNAN(),i;if(s>n&&t("calculate_sub_weighted_centroid"),s===n||e.isDegenerate(0))return i.setCoords(0,0),i;const r=ai(e),o=Oe(e),a=Math.min(o/e.calculateUpperLength2D(),1e-7);let h=s,u=0;for(let t=1,m=r.specialPointsCount();t<m;t++)if(s<r.specialPoints[t]){u=t-1;break}i.setCoords(0,0);for(let t=u+1,m=r.specialPointsCount();t<m;t++){const s=Math.min(r.specialPoints[t],n),u=ii(e,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[t])break}return i.add(e.getStartXY().mul(e.calculateLength2D()))}function Mi(t,e,s,n){(new $).setCoordsPoint2D(t[0]);(new $).setCoordsPoint2D(t[1]);(new $).setCoordsPoint2D(t[2]);const i=new $,r=new $,o=new $;if(Ct(t[0],t[1],e,i),Ct(t[1],t[2],e,r),Ct(i,r,e,o),s&&(s[0].assign(t[0]),s[1].assign(i),s[2].assign(o)),n){const e=t[2];n[0].assign(o),n[1].assign(r),n[2].assign(e)}}function Yi(t,e,s,n){if(e===s){const s=new $;return Zi(t,e,s),n[0]=s,n[1]=s,void(n[2]=s)}const i=ut($,3);Mi(t,s,i,null),Mi(i,e/s,null,i),Zi(t,e,i[0]),Zi(t,s,i[2]),n[0].setCoordsPoint2D(i[0]),n[1].setCoordsPoint2D(i[1]),n[2].setCoordsPoint2D(i[2])}function Ni(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),r=new ce,o=ut($,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new $;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=ut($,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Ct(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&Ai(t)}function Xi(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function qi(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Li(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Fi(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Ri(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Vi(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==zi(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Li(t,e,s,i,r,o,a,h,u,m){if(null!=r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0],n=e.intersectPoint(s.getStartXY(),t,a);if(n>0){if(null!==r)for(let e=0;e<n;e++)r.push(t[e]);if(null!==o)for(let t=0;t<n;t++)o.push(0);if(null!==i)for(let s=0;s<n;s++){const n=new $;e.queryCoord2D(t[s],n),i.push(n)}}return n}const l=Qe(e,s);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new fm({start:e.getStartXY(),end:e.getEndXY()}),n=ws(t,s,i,r,o,a,h,m);if(r)for(let s=0;s<n;++s){const n=t.getCoord2D(r[s]);r[s]=e.getClosestCoordinate(n,!1)}return n}if(Ke(e,s,a))return 0;const c=Ee.constructPoint2D(s.getStartXY()),g=Ee.constructPoint2D(s.getEndXY()).sub(c),d=g.clone();d.leftPerpendicularThis();const _=Ee.constructPoint2D(e.m_cp).sub(Ee.constructPoint2D(e.getStartXY())),p=Ee.constructPoint2D(e.getEndXY()).sub(Ee.constructPoint2D(e.m_cp));let f=_.dotProduct(d).toDouble(),P=p.sub(_).dotProduct(d).toDouble();const y=et(12,Number.NaN),x=et(12,Number.NaN);let C=sn(P,f,U.unit(),y);C<0&&(y[0]=0,y[1]=1,C=2);let v,b=0;for(let n=0,w=b;n<C;++n){const t=e.getCoord2D(y[n+w]);x[b]=s.getClosestCoordinate(t,!1),$.distance(t,s.getCoord2D(x[b]))<=a&&(y[b]=y[n+w],b++)}const S=ut($,3);e.queryControlPoints(S);{const t=ut(Ee,3);if(ji(S,t,!1),t[0]=t[0].sub(c),g.x.abs().gte(g.y.abs())){const e=g.y.div(g.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),f=t[1].y.sub(t[1].x.mul(e)).toDouble(),v=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=g.x.div(g.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),f=t[1].x.sub(t[1].y.mul(e)).toDouble(),v=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const E=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),D=[0,0];C=nn(P,f,v,U.unit(),E,D);for(let n=0,w=b;n<C;++n){y[n+w]=D[n];const t=e.getCoord2D(y[n+w]);x[b]=s.getClosestCoordinate(t,!1),$.distance(t,s.getCoord2D(x[b]))<=a&&(y[b]=y[n+w],b++)}n(b<y.length+4),C=e.intersectPoint(s.getStartXY(),D,a);for(let n=0;n<C;n++)y[b]=D[n],x[b++]=0;C=e.intersectPoint(s.getEndXY(),D,a);for(let n=0;n<C;n++)y[b]=D[n],x[b++]=1;C=s.intersectPoint(e.getStartXY(),D,a);for(let n=0;n<C;n++)x[b]=D[n],y[b++]=0;C=s.intersectPoint(e.getEndXY(),D,a);for(let n=0;n<C;n++)x[b]=D[n],y[b++]=0;return 0===b?0:gm(t,e,s,y,x,b,i,r,o,a,h,u,m)}function Ri(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return Li(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Ke(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=ut($,3);{e.queryControlPoints(g);const t=ut($,3),n=new ce;s.canonicToWorldTransformation(n);const i=new ce;i.setInvert(n),i.transformPoints2D(g,3,t);const r=ut(Ee,3);ji(t,r);const h=[r[0].x,r[1].x,r[2].x],u=[r[0].y,r[1].y,r[2].y],m=ut(tt,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2]=m[0],m[2].mul(m[1]),m[2].negate();const d=Fn(h,2,u,2,null,0,m,!0,U.unit(),U.unit(),l,a);if(d>0){let t=0;for(let n=0;n<d;n++){const i=new $;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new $;s.queryCoord2D(r,a),$.distance(i,a)<=o&&(l[t]=l[n],c.push(r),t++)}l.length=t}}const d=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),e=[0];bi(g,t,e);const n=new $;Zi(g,e[0],n),$.distance(t,n)<=o&&(l.push(e[0]),c.push(d[_]))}for(let _=0;_<2;_++){const t=[0,2];{const e=s.getClosestCoordinate(g[t[_]],!1),n=new $;s.queryCoord2D(e,n),$.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return gm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function zi(t,e,s,n,i,r,o,a,h,u){const m=ut($,3);e.queryControlPoints(m);const l=ut($,3);if(s.queryControlPoints(l),$e(m,l,3)<0)return zi(t,s,e,n,r,i,o,a,h,!u);const c=Qe(e,s);if(Ke(e,s,o=Math.max(o,c)))return 0;if(sr(e,s,n,i,r,o,a,h,u))return 2;const g=new U(0,1),d=new U(0,1);{const t=new fe;Di(m,U.unit(),t);const e=new fe;Di(l,U.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(wi(m,t,g),wi(l,t,d),g.isEmpty()||d.isEmpty())return 0;Yi(m,g.vmin,g.vmax,m),Yi(l,d.vmin,d.vmax,l)}}const _=_m(m,2,l,2,o);if(0===_)return 0;const p=[],f=[];if(-1===_){const t=ut(Ee,3);ji(m,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],n=ut(Ee,3);ji(l,n);const i=Nn(e,2,s,2,null,0,[n[0].x,n[1].x,n[2].x],2,[n[0].y,n[1].y,n[2].y],2,null,0,!0,U.unit(),U.unit(),p,f,u,a,u);if(i>0){let t=0;for(let e=0;e<i;e++){const s=new $,n=new $;Zi(l,f[e],n),Zi(m,p[e],s),$.distance(s,n)<=o&&(p[t]=p[e],f[t]=f[e],t++)}p.length=t,f.length=t}}for(let P=0;P<2;P++){const t=0===P?m:l,e=0===P?l:m;for(let s=0;s<2;s++){const n=0===s?0:2,i=[0];bi(e,t[n],i);const r=new $;Zi(e,i[0],r),$.distance(t[n],r)<=o&&(0===P?(p.push(0===n?0:1),f.push(i[0])):(f.push(0===n?0:1),p.push(i[0])))}}if(0===p.length)return 0;if(!g.equalsRange(0,1))for(let P=0;P<p.length;++P)p[P]=An.recalculateParentT(g.vmin,g.vmax,p[P]);if(!d.equalsRange(0,1))for(let P=0;P<f.length;++P)f[P]=An.recalculateParentT(d.vmin,d.vmax,f[P]);return gm(t,e,s,p,f,p.length,n,i,r,o,a,h,u)}function Bi(t,e,s=!1){const n=t[1].sub(t[0]);e[1].assign(n.mul(2)),e[2].assign(t[2].sub(t[1]).sub(n)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function ki(t,e,s=!1){const n=ut($,3);t.queryControlPoints(n),Bi(n,e,s)}function Gi(t,e,s=!1){const n=0,i=new rt(t[1][n]).subE(new rt(t[0][n]));e[1]=i.mul(2),e[2]=new rt(t[2][n]).subE(new rt(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function Wi(t,e,s=!1){const n=1,i=new rt(t[1][n]).subE(new rt(t[0][n]));e[1]=i.mul(2),e[2]=new rt(t[2][n]).subE(new rt(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function ji(t,e,s=!1){const n=Ee.constructPoint2D(t[1]),i=n.sub(Ee.constructPoint2D(t[0]));e[1]=i.mul(tt.constructInt32(2)),e[2]=Ee.constructPoint2D(t[2]).sub(n).sub(i),e[0]=s?new Ee(te,te):Ee.constructPoint2D(t[0])}function Zi(t,e,s,n){if(n){if(e<0){return void ps(new fm({start:t[0],end:t[0].add(ci(t,0).getUnitVector())}),e,s)}if(e>1){return void ps(new fm({start:t[2],end:t[2].add(ci(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=t[1].clone(),i=new $;qt(2,t[0],n,e,i);const r=new $;qt(2,n,t[2],e,r);const o=new $;qt(2,i,r,e,o),s.assign(o)}else{const n=t[1].clone(),i=new $;Ft(2,t[0],n,e,i);const r=new $;Ft(2,n,t[2],e,r);const o=new $;Ft(2,i,r,e,o),s.assign(o)}}function Hi(t,e,s){const n=ut($,3);t.queryControlPoints(n),Ui(n,e,s)}function Ui(t,e,s){if(e.value()<=.5){const n=be.constructPoint2D(t[1]),i=new be;Vt(2,be.constructPoint2D(t[0]),n,e,i);const r=new be;Vt(2,n,be.constructPoint2D(t[2]),e,r);const o=new be;Vt(2,i,r,e,o),s.setE(o)}else{const n=be.constructPoint2D(t[1]),i=new be;Lt(2,be.constructPoint2D(t[0]),n,e,i);const r=new be;Lt(2,n,be.constructPoint2D(t[2]),e,r);const o=new be;Lt(2,i,r,e,o),s.setE(o)}}function Oi(t,e,s){const n=ut($,4);t.queryControlPoints(n),Qi(n,e,s)}function Qi(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(_i(t,1,e))}function Ki(t,e){let s=1;t[1].isEqualPoint2D(t[0])&&(s=2,t[2].isEqualPoint2D(t[0])&&(s=3));let n=2;t[2].isEqualPoint2D(t[3])&&(n=1,t[1].isEqualPoint2D(t[3])&&(n=0)),e[0].assign(t[0]),e[2].assign(t[3]);const i=$.intersectLinesAtOnePoint(t[0],t[s],t[n],t[3]),r=new $;Ct(t[0],t[3],.5,r);const o=new $;yo(t,.5,o);const a=new $;e[1].assign(i),Zi(e,.5,a);const h=new $;e[1].assign(r),Zi(e,.5,h);const u=$.sqrDistance(o,a),m=$.sqrDistance(o,h);return u<m?(e[1].setCoordsPoint2D(i),Math.sqrt(u)):(e[1].setCoordsPoint2D(r),Math.sqrt(m))}function $i(t,e,s){s[0].assign(t[0]),s[1].assign(t[1]),s[2].assign(t[2]);const n=new $;ph(t,e,.5,n);const i=new $;Zi(s,.5,i);const r=$.sqrDistance(n,i);return Math.sqrt(r)}function Ji(t,e){e[0].assign(t[0]),e[3].assign(t[2]),Ct(t[0],t[1],2/3,e[1]),Ct(t[1],t[2],1/3,e[2])}function tr(t,e){const s=ut($,3);t.queryControlPoints(s);const n=$.sqrDistance(s[1],s[0]),i=$.sqrDistance(s[1],s[2]);let r=s[0].clone(),o=n;n>i&&(r=s[2].clone(),o=i);let a=!1;return o<=e&&0!==o&&(a=!0,t.setControlPoint1(r)),a}function er(t,e){if(!e)return!1;const s=ut($,3);t.queryControlPoints(s);const n=$.sqrDistance(s[1],s[0]),i=$.sqrDistance(s[1],s[2]);s[0].clone();let r=n;return n>i&&(s[2].clone(),r=i),r<=e&&0!==r}function sr(t,e,s,n,i,r,o,a,h){const u=ut($,3);t.queryControlPoints(u);const m=ut($,3);if(e.queryControlPoints(m),u[0].equals(m[0])){if(u[1].equals(m[1])&&u[2].equals(m[2]))return s&&(s.length=0,s.push(u[0]),s.push(u[2])),n&&(n.length=0,n.push(0),n.push(1)),i&&(i.length=0,i.push(0),i.push(1)),!0;if(!u[0].equals(m[2]))return!1}return!!(u[0].equals(m[2])&&u[1].equals(m[1])&&u[2].equals(m[0]))&&(n&&(n.length=0,n.push(0),n.push(1),h&&(n[1]=Q(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=Q(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[2]),h&&(s[1]=Q(s[0],s[0]=s[1]))),!0)}const nr=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],ir=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],rr=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],or=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],ar=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],hr=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function ur(t,e,s,n){const i=.5*(n-s),r=s+i,o=new O(0);for(let a=0,h=Math.trunc(t/2);a<h;++a){let s,n;switch(t){case 4:s=nr[a][0],n=nr[a][1];break;case 8:s=ir[a][0],n=ir[a][1];break;case 16:s=rr[a][0],n=rr[a][1];break;case 32:s=or[a][0],n=or[a][1];break;case 64:s=ar[a][0],n=ar[a][1];break;case 128:s=hr[a][0],n=hr[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=oe(-i,s,r),u=oe(i,s,r);o.pe(e(h)*n),o.pe(e(u)*n)}return o.getResult()*i}class mr extends Us{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Pm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Pm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Pm):t.envelope?s("envelope constructor not impl"):r("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Pm)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return Js(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return mr.type}getDimension(){return 2}createInstance(){return new mr({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function lr(n,i){let r,o=i,a=null;switch(o||(a=p(n)?S():P(),o=a),n){case e.enumPoint:r=new F({vd:o});break;case e.enumLine:r=new fm({vd:o});break;case e.enumBezier:r=new ra({vd:o});break;case e.enumEllipticArc:r=new qh({vd:o});break;case e.enumRationalBezier2:r=new Dn({vd:o});break;case e.enumBezier2:r=new An({vd:o});break;case e.enumEnvelope:r=new C({vd:o});break;case e.enumMultiPoint:r=new gs({vd:o});break;case e.enumPolyline:r=new Qs({vd:o});break;case e.enumPolygon:r=new mr({vd:o});break;case e.enumMultipatch:s("multipatch not impl");break;case e.enumGeometryCollection:r=new _e({vd:o});break;default:t("Geometry.create")}return r}mr.type=e.enumPolygon;var cr=b;const gr=-1,dr=1;class _r{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}function pr(t){return void 0!==t.parent}class fr{constructor(t){pr(t)?(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0):(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==gr;){for(;this.m_path!==gr;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==gr)return this.m_vertex;if(this.m_bOneGeom)return gr;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===gr)break;this.m_bSkipMultiPoints&&!c(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return gr}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==gr&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return gr}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==gr?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==gr&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):gr}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,n,i,r,o,a,h){return new fr({parent:t,geometry:e,path:s,vertex:n,firstVertex:i,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class Pr{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class yr{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let s=0,n=this.m_indices.length;s<n;s++){if(s===this.m_selectionIndex)continue;const t=this.m_indices[s];null!==t&&t.size()>e&&t.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,dr),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,dr),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,n){this.m_hasForceSetEnvelope=0;const i=e!==gr?this.getPrevVertex(e):this.getLastVertex(t),r=i!==gr?this.getNextVertex(i):gr,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByValNoCurves(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,i),r!==gr&&this.setPrevVertex(r,o),i!==gr&&this.setNextVertex(i,o);const h=this.isClosedPath(t),u=this.getFirstVertex(t);e===gr&&this.setLastVertex(t,o),e===u&&(h&&n&&u!==gr||this.setFirstVertex(t,o)),h&&r===gr&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const m=this.getGeometryFromPath(t);return this.setGeometryVertexCount(m,this.getPointCount(m)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new F({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,s){const n=this.createGeometry(e.enumMultiPoint,t.getDescription());return this.appendPoint(n,t,s),n}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const n=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let i=0,r=s.getPathCount();i<r;i++){if(0===s.getPathSize(i))continue;const e=this.insertPath(t,gr);this.setClosedPath(e,s.isClosedPath(i));for(let t=s.getPathStart(i),r=s.getPathEnd(i);t<r;t++){const i=this.insertVertex_(e,gr,null,!1);if(n){const e=this.getVertexIndex(i);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const n=new Pm;s.querySegment(t,n,!0),this.setSegmentToIndex(e,n.releaseSegment())}}}s.isStrongPathStart(i)&&this.setStrongPathStart(e,!0),s.isStrongPathEnd(i)&&this.setStrongPathEnd(e,!0)}}addMultiPath(t,s){const n=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===e.enumPolygon&&this.setFillRule(n,t.getFillRule()),this.appendMultiPath(n,t,s),n}appendMultiPathPolyline(t,e,s){const n=e.getImpl(),i=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),r=new le;e.queryEnvelope(r);{const r=s.clone();let o=n.getPointCount();const a=n.getAccelerators();if(a&&a.getQuadTree()){o=a.getQuadTree().getIntersectionCount(r,0,n.getPointCount()+1)}if(o<e.getPointCount()){if(0===o)return;const s=n.queryLimitedSegmentIterator(r);let a=-1,h=-100,u=-1,m=0,l=-1,c=gr,g=!1,d=s.nextSegment();if(null!==d)for(;;d=s.nextSegment()){let r=null===d;const o=null!==d?s.getPathIndex():a,_=null!==d?s.getStartPointIndex():h;if(r||(a===o&&h+1===_?m++:r=!0),r){if(-1!==l){let t=-1,s=-1;if(m===u){this.setClosedPath(c,g);const i=n.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i-l),this.m_verticesMp.addPoints(e,l,i),s=n.getPathSize(a),t=i-1}else if(!g||h+1<n.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp.addPoints(e,l,h+2),s=h-l+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp?.addPoints(e,l,h+1),t=h,s=h-l+1;const i=n.getPathStart(a);this.m_verticesMp.addPoints(e,i,i+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=l;e<s;e++,r++){const e=this.insertVertex_(c,gr,null,!1);if(i){const s=this.getVertexIndex(e);if(1&n.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new Pm;n.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===d)break;m=1,l=_,a!==o?(c=this.insertPath(t,gr),this.setClosedPath(c,!1),u=n.getSegmentCountPath(o),g=n.isClosedPath(o),a=o):c=this.insertPath(t,gr)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,s){const i=e.getImpl(),r=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),o=le.constructEmpty();e.queryEnvelope(o),n(s.isIntersecting(o)&&!s.containsEnvelope(o));let a=le.construct(Number.NEGATIVE_INFINITY,s.ymin,Number.POSITIVE_INFINITY,s.ymax),h=le.construct(s.xmin,Number.NEGATIVE_INFINITY,s.xmax,Number.POSITIVE_INFINITY);const u=i.getAccelerators();if(u&&u.getQuadTree()){const t=u.getQuadTree(),e=t.getIntersectionCount(a,0,0);e>t.getIntersectionCount(h,0,e+1)&&(h=Q(a,a=h))}else a.height()>h.width()&&(h=Q(a,a=h));const m=[],l=i.queryLimitedSegmentIterator(a);let c=-1,g=-100,d=-1,_=0,p=-1,f=-1,P=gr,y=!0,x=l.nextSegment();if(null!==x)for(;;x=l.nextSegment()){let s=null===x;const o=null!==x?l.getPathIndex():c,a=null!==x?l.getStartPointIndex():g;if(s||(o===c?g+1===a?_++:s=!0:(s=c>=0,c<0&&(c=o,d=i.getSegmentCountPath(c),p=a,P=gr,_=1))),s){if(!(0===m.length&&d===_)){0!==m.length&&m[0].first===p||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,p,p+1),-1===f&&(f=p),P===gr&&(P=this.insertPath(t,gr),this.setClosedPath(P,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(P,gr,null,!1));for(const{first:s,second:o}of m){-1===f&&(f=s);let a=-1,h=-1;const u=s+o-1;if(o===d){const t=u+1;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),a=u,n(1===m.length)}else if(u+1<i.getPathEnd(c)){const t=u+2;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),a=u}else{const t=i.getPathStart(c),n=t!==f?1:0,r=u+1;h=r-s+n,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-s)+n),this.m_verticesMp.addPoints(e,s,r),a=u,n>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),P===gr&&(P=this.insertPath(t,gr),this.setClosedPath(P,!0));for(let t=0,e=s;t<h;t++,e++){const t=this.insertVertex_(P,gr,null,!1);if(r){const s=this.getVertexIndex(t);if(1&i.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new Pm;i.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===m.length||m.at(-1).first+m.at(-1).second!==p+_){let t=p+_;t===e.getPathEnd(c)&&(t=e.getPathStart(c)),f!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(P,gr,null,!1))}}m.length=0,y=!0,o!==c&&(c=o,d=i.getSegmentCountPath(c),P=gr,f=-1),p=a,_=1}if(!x)break;{const t=le.constructEmpty();x.queryLooseEnvelope(t),h.isIntersecting(t)?(y?m.push(Yt(a,1)):m.at(-1).second++,y=!1):y=!0}g=a}}appendMultiPath(t,s,n){if(void 0===n)return void this.appendMultiPath_(t,s);if(s.isEmpty())return;const i=s.getGeometryType()===e.enumPolygon,r=le.constructEmpty();s.queryEnvelope(r),n.isIntersecting(r)&&(!n.containsEnvelope(r)&&s.getPointCount()>10?i?this.appendMultiPathPolygon(t,s,n):this.appendMultiPathPolyline(t,s,n):this.appendMultiPath_(t,s))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const n=this.insertPath(t,gr);this.insertVertex_(n,gr,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,gr);for(let n=0,i=e.getPointCount();n<i;n++)this.insertVertex_(s,gr,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const n=e.getAttributeStreamRef(0);let i=0;for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)&&i++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i);let r=-1,o=-1,a=0;for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)?(-1===r&&(r=u,o=u),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+i);const h=this.insertPath(t,gr);for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)&&this.insertVertex_(h,gr,null,!1)}}splitSegmentForward(s,n,i,r,o){const a=this.getNextVertex(s);a===gr&&t("Edit_shape.split_segment_forward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(s);let m=s;const l=this.hasSegmentParentage();for(let t=0,c=n.getResultSegmentCount(i);t<c;t++){const s=this.getVertexIndex(m),r=this.getNextVertex(m),g=n.getResultSegment(i,t);let d=null;if(g.getGeometryType()!==e.enumLine&&(d=g.clone(),d.dropAllAttributes()),0===t&&(g.queryStart(h),this.setSegmentToIndex(s,null),this.setPointEx(m,h,n.getResultSegmentStartPointRank(i,t),n.getResultSegmentStartPointWeight(i,t),o)),this.setSegmentRank(m,n.getResultSegmentInteriorRank(i,t)),this.setSegmentWeight(m,n.getResultSegmentInteriorWeight(i,t)),l){const e=n.getResultSegmentSegmentParentage(i,t),s=n.getResultSegmentStartPointIsBreak(i,t);this.setSegmentParentageAndBreak(m,e,s)}if(g.queryEnd(h),t<c-1){this.setSegmentToIndex(s,d);const e=this.insertVertex(u,r,h);this.setWeight(e,n.getResultSegmentEndPointWeight(i,t)),this.setRank(e,n.getResultSegmentEndPointRank(i,t)),this.select(e),m=e}else{this.setPointEx(a,h,n.getResultSegmentEndPointRank(i,t),n.getResultSegmentEndPointWeight(i,t),o);const e=n.getResultSegmentEndPointIsBreak(i,t);this.setSegmentParentageBreakVertex(a,e),this.setSegmentToIndex(s,d)}}}splitSegmentBackward(s,n,i,r,o){const a=this.getNextVertex(s);a===gr&&t("Edit_shape.split_segment_backward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(s);let m=s;const l=this.hasSegmentParentage();for(let t=0,c=n.getResultSegmentCount(i);t<c;t++){const s=c-t-1,r=this.getVertexIndex(m),g=this.getNextVertex(m),d=n.getResultSegment(i,s);let _=null;if(d.getGeometryType()!==e.enumLine&&(_=d.clone(),_.reverse(),_.dropAllAttributes()),0===t&&(d.queryEnd(h),this.setSegmentToIndex(r,null),this.setPointEx(m,h,n.getResultSegmentEndPointRank(i,s),n.getResultSegmentEndPointWeight(i,s),o),this.setSegmentParentageAndBreak(m,n.getResultSegmentSegmentParentage(i,s),n.getResultSegmentEndPointIsBreak(i,s))),d.getGeometryType()===e.enumLine?this.setSegmentToIndex(r,null):this.setSegmentToIndex(r,_),this.setSegmentRank(m,n.getResultSegmentInteriorRank(i,s)),this.setSegmentWeight(m,n.getResultSegmentInteriorWeight(i,s)),d.queryStart(h),t<c-1){const t=this.insertVertex(u,g,h);this.setWeight(t,n.getResultSegmentStartPointWeight(i,s)),this.setRank(t,n.getResultSegmentStartPointRank(i,s)),this.select(t),m=t,l&&this.setSegmentParentageAndBreak(t,n.getResultSegmentSegmentParentage(i,s),n.getResultSegmentEndPointIsBreak(i,s))}else this.setPointEx(a,h,n.getResultSegmentStartPointRank(i,s),n.getResultSegmentStartPointWeight(i,s),o)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?L(0,-1):L(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return L(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const n=this.getNextVertex(t),i=this.getNextVertex(e),r=this.getVertexIndex(t),o=this.getVertexIndex(e);if(this.setNextVertex(t,i),this.setPrevVertex(i,t),this.setNextVertex(e,n),this.setPrevVertex(n,e),this.m_segments){const t=this.getSegmentFromIndex(r),e=this.getSegmentFromIndex(o);this.setSegmentToIndex(o,null),this.setSegmentToIndex(r,e),this.setSegmentToIndex(o,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),n=this.getSegmentParentage(t);-1===s&&-1===n||(n=Q(s,s=n),this.setSegmentParentageAndBreak(t,n),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,gr,n,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,i);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return gr}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,(t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const n=this.getPathInternalIndexFromVertex(t),i=this.getPathInternalIndexFromVertex(e);s=n<i?-1:n>i?1:0}return s})}sortVerticesSimpleByYHelper3D(t,e,s){n(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=T.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=$.getNAN(),this.m_workPoint2_2D=$.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=gr,this.m_lastGeometry=gr,this.m_vertexIndexList=new G(5),this.m_pathIndexList=new G(8),this.m_geometryIndexList=new G(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new W,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new le(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=le.constructEmpty(),n=this.queryVertexIterator();let i=!0;for(let r=n.next();r!==gr;r=n.next()){if(i?s.merge(this.getXY(r)):s.mergeNe(this.getXY(r)),e){const t=this.getSegment(r);if(null!==t){const e=le.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}i=!1}return s}getEnvelope3D(t){return n(0),T.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){n(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(s,n){const i=s.getGeometryType();if(c(i))return this.addMultiPath(s,n);if(i===e.enumMultiPoint)return this.addMultiPoint(s,n);if(i===e.enumPoint)return this.addPoint_(s,n);if(i===e.enumEnvelope){const t=new mr;return t.addEnvelope(s,!1),this.addMultiPath(t,n)}t("")}appendGeometry(s,n){this.mergeVertexDescription(n.getDescription());const i=n.getGeometryType();c(i)?this.appendMultiPath(s,n):i!==e.enumMultiPoint?t(""):this.appendMultiPoint(s,n)}assignRankToGeometryVertices(t,e){e<dr&&(e=dr);const s=this.queryVertexIterator();for(let n=s.next();n!==gr;n=s.next())this.setRank(n,e),this.setSegmentRank(n,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(e.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let s=gr,n=-1,i=-1;for(let r=this.getFirstGeometry();r!==gr;){if(t===e.enumUnknown||this.getGeometryType(r)===t){if(s===gr){s=r,n=this.getPathCount(s),i=this.getPointCount(s),r=this.getNextGeometry(r);continue}for(let n=this.getFirstPath(r);n!==gr;n=this.getNextPath(n))this.setPathGeometry(n,s);n+=this.getPathCount(r),i+=this.getPointCount(r);const t=this.getLastPath(s),e=this.getFirstPath(r);t!==gr?this.setNextPath(t,e):this.setFirstPath(s,e),e!==gr&&(this.setPrevPath(e,t),this.setLastPath(s,this.getLastPath(r))),this.setFirstPath(r,gr),this.setLastPath(r,gr);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}r=this.getNextGeometry(r)}return s!==gr&&(this.setGeometryVertexCount(s,i),this.setGeometryPathCount(s,n),this.dbgVerifyVertexCounts()),s}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),n=this.getGeometryFromPath(s);this.setGeometryModified(n,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),n=this.getFirstPath(e),i=this.getLastPath(t),r=this.getLastPath(e);for(let c=this.getFirstPath(t);c!==gr;c=this.getNextPath(c))this.setPathGeometry(c,e);for(let c=this.getFirstPath(e);c!==gr;c=this.getNextPath(c))this.setPathGeometry(c,t);this.setFirstPath(t,n),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,i);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),u=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,u),this.setGeometryPathCount(e,a);const m=this.m_geometryIndexList.getField(t,2),l=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,l),this.m_geometryIndexList.setField(e,2,m)}addPathFromMultiPath(t,s,n){const i=this.createGeometry(n?e.enumPolygon:e.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(s)<2)return i;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(s)),this.m_verticesMp.addPoints(t,t.getPathStart(s),r.getPathEnd(s)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(i,gr);this.setClosedPath(o,r.isClosedPath(s)||n);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let e=r.getPathStart(s),h=r.getPathEnd(s);e<h;e++){const t=this.insertVertex_(o,gr,null,!1);if(a){const s=this.getVertexIndex(t);if(1&r.getSegmentFlags(e))this.setSegmentToIndex(s,null);else{const t=new Pm;r.querySegment(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}return r.isStrongPathStart(s)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(s)&&this.setStrongPathEnd(o,!0),i}getGeometry(t){const s=this.getGeometryType(t),n=lr(s,this.m_verticesMp.getDescription()),i=this.getPointCount(t);if(0===i)return n;if(c(s)){const e=n.getImpl(),s=this.getPathCount(t),r=L(s+1),o=R(s+1,0),a=n.getDescription(),h=this.hasCurves();for(let n=0,u=a.getAttributeCount();n<u;n++){const h=a.getSemantics(n),u=cr.getComponentCount(h),m=Y(h,i),l=this.m_vertices.getAttributeStreamRef(h);let c=0,g=0,d=0;for(let e=this.getFirstPath(t);e!==gr;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&o.setBits(g,t);const s=this.getPathSize(e);if(r.write(g++,d),d+=s,0===h){const t=l,s=m;let n;for(let i=this.getFirstVertex(e);c<d;i=this.getNextVertex(i),c++){const e=this.getVertexIndex(i);n=t.readPoint2D(2*e),s.writePoint2D(2*c,n)}}else for(let n=this.getFirstVertex(e);c<d;n=this.getNextVertex(n),c++){const t=this.getVertexIndex(n);for(let e=0;e<u;e++){const s=l.readAsDbl(t*u+e);m.writeAsDbl(c*u+e,s)}}}e.setAttributeStreamRef(h,m),r.write(s,i)}if(e.setPathFlagsStreamRef(o),e.setPathStreamRef(r),e.notifyModifiedFlags(65535),h){let s=0,n=0;for(let i=this.getFirstPath(t);i!==gr;i=this.getNextPath(i)){s+=this.getPathSize(i);for(let t=this.getFirstVertex(i);n<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(n,s,!0),n++}}}}else if(s===e.enumMultiPoint){const e=n.getImpl(),s=n.getDescription();e.reserve(i),e.resizeNoInit(i);for(let n=0,i=s.getAttributeCount();n<i;n++){const i=s.getSemantics(n),r=cr.getComponentCount(i),o=e.getAttributeStreamRef(i),a=this.m_vertices.getAttributeStreamRef(i);let h=0;const u=this.getFirstPath(t),m=this.getPathSize(u);for(let t=this.getFirstVertex(u);h<m;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(i,o)}e.notifyModifiedFlags(65535)}else r("getGeometry");return n}queryPointGeometryOnly(s,n){this.getGeometryType(s)!==e.enumMultiPoint&&t("get_point_geometry_only");const i=this.getPointCount(s);if(i>1&&t("get_point_geometry_only"),0===i)return n.assignVertexDescription(this.m_vertexDescription),void n.setEmpty();const r=this.getFirstPath(s),o=this.getFirstVertex(r);this.queryPoint(o,n)}removeGeometry(t){for(let n=this.getFirstPath(t);n!==gr;n=this.removePath(n));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==gr?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==gr?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=P());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new gs({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===gr?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const n=this.m_geometryIndices[e],i=this.getGeometryIndex(t);i>=n.size()&&n.resize(Math.max(1.25*i,16),-1),n.write(i,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),n=this.m_geometryIndices[e];return s<n.size()?n.read(s):-1}createGeometryUserIndex(){for(let e=0;e<this.m_geometryIndices.length;e++)if(null===this.m_geometryIndices[e])return this.m_geometryIndices[e]=L(0),e;this.m_geometryIndices.push(L(0));const t=this.m_geometryIndices.length-1;return n(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==gr;t=this.getNextGeometry(t))if(!c(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,s,i,r,o){const a=t*t;let h=0;const u=this.hasCurves(),m=this.hasSegmentParentage(),l=!0;for(let g=o===gr?this.getFirstGeometry():o;g!==gr;g=o===gr?this.getNextGeometry(g):gr){const t=this.getGeometryType(g);if(!c(t))continue;if(i&&t!==e.enumPolygon)continue;const o=this.getGeometryType(g)===e.enumPolygon;let d=this.getGeometryModified(g);for(let e=this.getFirstPath(g);e!==gr;){let t=0;for(let s=this.getFirstVertex(e);t<Math.trunc(this.getPathSize(e)/2);){const i=this.getNextVertex(s);if(i===gr)break;const o=this.getXY(s),c=this.getXY(i);let _=$.sqrDistance(o,c),p=!0;do{if(_<=a){if(u){const t=this.getSegment(s);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===h&&(h=-1):h=1,i!==this.getLastVertex(e)){const t=m&&(this.getSegmentParentageBreakVertex(s)||this.getSegmentParentageBreakVertex(i));if(this.transferAllDataToTheVertex(i,s,l),this.removeVertex(i,!1),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&s!==i){this.setSegmentParentageBreakVertex(s,t);const e=this.getNextVertex(s);n(e!==gr),this.isDiscontinuousSegmentParentage(e)&&this.setSegmentParentageBreakVertex(e,!0)}}p=!1}}while(0);p&&(s=this.getNextVertex(s)),t++}let i=this.getFirstVertex(e);for(let s=this.isClosedPath(e)?i:this.getLastVertex(e);this.getPathSize(e)>0;){const t=this.getPrevVertex(s);if(t===gr)break;{const o=this.getXY(t),c=this.getXY(s);let _=$.sqrDistance(o,c),p=!0;do{if(_<=a){if(u){const e=this.getSegment(t);if(null!==e){const t=e.calculateLength2D();if(_=t*t,_>a)break}}if(0===_?0===h&&(h=-1):h=1,m){n(this.m_segmentParentageIndex>=0);const e=this.getUserIndex(s,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(t,s,l),this.setUserIndex(s,this.m_segmentParentageIndex,e)}else this.transferAllDataToTheVertex(t,s,l);const o=m&&(this.getSegmentParentageBreakVertex(s)||this.getSegmentParentageBreakVertex(t));this.removeVertex(t,!0),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&t!==s&&(o||this.isDiscontinuousSegmentParentage(s))&&this.setSegmentParentageBreakVertex(s,!0),i===t&&(i=this.getFirstVertex(e)),p=!1}}while(0);if(p&&(s=this.getPrevVertex(s),s===i))break}}const c=this.getPathSize(e);let _=s&&c<(o?3:2);_&&o&&2===c&&u&&(_=!this.pathHasCurves(e)),_?(e=this.removePath(e),0===h&&(h=-1),r&&!d&&(this.setGeometryModified(g,!0),d=!0)):e=this.getNextPath(e)}}return h}filterClosePoints3D(t,e,s,i,r,o){return n(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==gr;e=this.getNextGeometry(e))if(c(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==gr;){const e=this.getPathSize(s);if(0===e)return!0;let n=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(n);if(e===gr)break;const s=this.getVertexIndex(n),i=this.getSegmentFromIndex(s);let r=0;if(null!==i){if(r=i.calculateLowerLength2D(),r<=t){if(r=i.calculateUpperLength2D(),r<=t)return!0;if(r=i.calculateLength2D(),r<=t)return!0}}else{const n=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,n),r<=t)return!0}n=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return n(0),!1}transferAllDataToTheVertex(t,e,s=!1){const n=this.getVertexIndex(t),i=this.getVertexIndex(e);if(s){let t=1,e=1;if(this.m_ranks&&(t=this.getRankWithIndex(n),e=this.getRankWithIndex(i)),t>e&&this.setRankWithIndex(i,t),t>=e&&this.m_weights){const s=this.getWeightWithIndex(n),r=this.getWeightWithIndex(i);(t>e||s>r)&&this.setWeightWithIndex(i,s)}}else{if(this.m_weights){const t=this.getWeightWithIndex(n);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(n);this.setRankWithIndex(i,t)}}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(n);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(n);this.setSegmentRankWithIndex(i,t)}for(let o=0,a=this.m_indices.length;o<a;o++)if(o!==this.m_selectionIndex&&null!==this.m_indices[o]){const s=this.getUserIndex(t,o);this.setUserIndex(e,o,s)}const r=this.selected(t);r!==this.selected(e)&&(r?this.select(e):this.unselect(e))}splitSegmentAxisAware(e,s,n,i,r){let o=0;const a=this.getNextVertex(e);a===gr&&t("");const h=this.getVertexIndex(e),u=this.getVertexIndex(a),m=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,u);const c=this.getPathFromVertex(e),g=this.m_bHasAttributes;g&&m&&(l=m.calculateLength2D());const d=this.getSegmentParentage(e),_=this.getHelperPoint();if(m){let t=0,e=0,r=gr;for(let p=0;p<n;p++){const n=s[p];if(t<n&&n<1){const s=m.cut(t,n);if(null!==i&&(p>0&&s.setStartXY(i[p-1]),s.setEndXY(i[p]),s.normalizeAfterEndpointChange(),e=p),g){const t=l>0?m.calculateSubLengthFromStart(n)/l:0;this.m_vertices.interpolateTwoVertices(h,u,t,_)}_.setXY(s.getEndXY()),r=this.insertVertex(c,a,_),o++;const f=this.getPrevVertex(r),P=this.getVertexIndex(f);this.setSegmentToIndex(P,s),-1!==d&&this.setSegmentParentageAndBreak(r,d,!1),t=n}}if(r!==gr){const s=m.cut(t,1);null!==i&&(s.setStartXY(i[e]),s.normalizeAfterEndpointChange());const n=this.getVertexIndex(r);this.setSegmentToIndex(n,s)}}else{let t=0;for(let e=0;e<n;e++){const n=s[e];if(t<n&&n<1){this.m_vertices.interpolateTwoVertices(h,u,n,_);const t=this.insertVertex(c,a,_);o++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=n}}return o}splitSegment(t,e,s,n=null){return this.splitSegmentAxisAware(t,e,s,n,-1)}snapControlPoints(e,s,n){this.getNextVertex(e)===gr&&t("");let i=e,r=!1;for(let t=0;t<s;++t){const t=this.getVertexIndex(i),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(n);r||=t}i=this.getNextVertex(i)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let n=s.next();n!==gr;n=s.next()){const s=this.getVertexIndex(n),i=this.getSegmentFromIndex(s);i&&(e|=i.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,s){return n(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const n=this.getVertexIndex(t),i=this.getSegmentFromIndex(n);null!==i&&(i.setStartXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==gr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);null!==n&&(n.setEndXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone())}}}setPointEx(t,e,s,n,i){this.setPoint(t,e,i);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,n),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByValNoCurves(s,e)}setPointOnlyEx(t,e,s,i){n(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const n=this.getVertexIndex(t);if(this.m_vertices?.setXYCoordsNoCurves(n,e,s),null!==this.m_segments){const i=this.getSegmentFromIndex(n);null!==i&&(i.setStartXYCoords(e,s),i.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==gr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);null!=n&&(n.setEndXYCoords(e,s),n.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const n=this.getVertexIndex(t);if(this.m_vertices.setXYCoordsNoCurves(n,e,s),null!==this.m_segments){const i=this.getSegmentFromIndex(n);if(null!==i){const t=i.getEndXY();i.setCoordsForIntersector(new $(e,s),t,!1),i.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==gr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);if(null!==n){const t=n.getStartXY();n.setCoordsForIntersector(t,new $(e,s),!1),n.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,s){n(0)}setXYZ(t,e,s){n(0)}setXYZCoords(t,e,s,i){n(0)}queryXYZ(t,e){n(0)}getXYZ(t){return n(0),E.getNAN()}getXYZWithIndex(t){return n(0),E.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){n(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,s,i){n(0)}setAttribute(t,e,s,i){n(0)}setAttributeInt(t,e,s,i){n(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return n(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return n(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=z(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_weights.size()){if(s)return;this.m_weights.resize(n+1,1)}this.m_weights.write(n,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=z(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return dr;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?dr:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?dr:this.m_ranks.read(t)}setRank(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_ranks){if(s)return;this.m_ranks=L(this.m_vertices.getPointCount(),dr)}const n=this.getVertexIndex(t);if(n>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(n+1,dr)}this.m_ranks.write(n,e)}setRankWithIndex(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_ranks){if(s)return;this.m_ranks=L(this.m_vertices.getPointCount(),dr)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,dr)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=z(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(n+1,1)}this.m_segmentWeights.write(n,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=z(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return yr.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?yr.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?dr:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=L(this.m_vertices.getPointCount(),dr)}const n=this.getVertexIndex(t);if(n>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(n+1,dr)}this.m_segmentRanks.write(n,e)}setSegmentRankWithIndex(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=L(this.m_vertices.getPointCount(),dr)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,dr)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const n=this.m_indices[e],i=this.getVertexIndex(t);if(n.size()<=i){if(-1===s)return;n.resize(this.m_vertices.getPointCount(),-1)}n.write(i,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),n=this.m_indices[e];if(s<n.size()){return n.read(s)}return-1}addToUserIndex(t,e,s){const n=this.m_indices[e],i=this.getVertexIndex(t);n.size()<=i&&n.resize(this.m_vertices.getPointCount(),-1);const r=n.read(i);n.write(i,r+s)}createUserIndex(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(),e;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return n(t>=0&&t<=_t()),t}createUserIndexUninitialized(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(!1),e;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return n(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const n=this.m_indices[e],i=n.size();for(let r=this.getFirstPath(t);r!==gr;r=this.getNextPath(r)){let t=this.getFirstVertex(r);for(let e=0,o=this.getPathSize(r);e<o;e++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<i&&n.write(e,s)}}}fillUserIndexForSelection(t,e){n(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const n=this.getNextVertex(t);if(n===gr)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const i=this.getXY(n);e.setEndXY(i)}else{const s=new F({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(n,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,s=!1){return n(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return n(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const s=this.getFirstVertex(t);if(s===gr)return!1;const n=this.getPathSize(t);let i=s;for(let r=0;r<n;r++,i=this.getNextVertex(i)){const t=this.getSegment(i);if(null!==t&&t.getGeometryType()!==e.enumLine)return!0}return!1}insertPath(e,s){let n=gr;s!==gr?(e!==this.getGeometryFromPath(s)&&t(""),n=this.getPrevPath(s)):n=this.getLastPath(e);const i=this.newPath(e);return s!==gr&&this.setPrevPath(s,i),this.setNextPath(i,s),this.setPrevPath(i,n),n!==gr?this.setNextPath(n,i):this.setFirstPath(e,i),s===gr&&this.setLastPath(e,i),this.setGeometryPathCount(e,this.getPathCount(e)+1),i}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);return e!==gr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==gr?this.setPrevPath(s,e):this.setLastPath(n,e),this.clearPath(t),this.setGeometryPathCount(n,this.getPathCount(n)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==gr){let s=e;for(let e=0,i=this.getPathSize(t);e<i;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const n=this.getGeometryFromPath(t);this.setGeometryVertexCount(n,this.getPointCount(n)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),n=this.getLastVertex(t);if(e){this.setNextVertex(n,s),this.setPrevVertex(s,n);const t=this.getVertexIndex(n);this.setSegmentToIndex(t,null)}else{this.setNextVertex(n,gr),this.setPrevVertex(s,gr);const t=this.getVertexIndex(n);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){n(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const s=this.getFirstVertex(t);if(s===gr)return 0;const n=this.getXY(s),i=new O(0),r=this.getPathSize(t);if(r>2){const t=n.clone(),e=t.x,o=t.y;let a=this.getNextVertex(s);const h=this.getXY(a);a=this.getNextVertex(a);const u=$.getNAN();for(let s=2;s<r;s++,a=this.getNextVertex(a))this.queryXY(a,u),i.pe((u.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(u);i.pe((e-t.x)*(h.y-o))}if(this.hasCurves()){let t=s;for(let s=0;s<r;s++,t=this.getNextVertex(t)){const s=this.getSegment(t);if(null===s||s.getGeometryType()===e.enumLine)continue;const n=2*s.calculateArea2DHelper();i.pe(n)}}this.setRingAreaValid(t,!0);const o=.5*i.getResult();return this.m_pathAreas[this.getPathIndex(t)]=o,o}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const n=this.m_pathindices[e],i=this.getPathIndex(t);n.size()<this.m_pathAreas.length&&n.resize(this.m_pathAreas.length,-1),n.write(i,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),n=this.m_pathindices[e];return s<n.size()?n.read(s):-1}createPathUserIndex(){for(let e=0;e<this.m_pathindices.length;e++)if(null===this.m_pathindices[e])return this.m_pathindices[e]=this.allocatePathIndex(),e;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return n(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const n=this.m_pathindices[e],i=n.size();for(let r=this.getFirstPath(t);r!==gr;r=this.getNextPath(r)){const t=this.getPathIndex(r);t<i&&n.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(e,s,n){if(n===gr&&t(""),s===n)return;const i=this.getNextPath(n);let r=this.getPrevPath(n);const o=this.getGeometryFromPath(n);r===gr?this.setFirstPath(o,i):this.setNextPath(r,i),i===gr?this.setLastPath(o,r):this.setPrevPath(i,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(n)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=s===gr?this.getLastPath(e):this.getPrevPath(s),this.setPrevPath(n,r),this.setNextPath(n,s),s===gr?this.setLastPath(e,n):this.setPrevPath(s,n),r===gr?this.setFirstPath(e,n):this.setNextPath(r,n),this.setGeometryVertexCount(e,this.getPointCount(e)+this.getPathSize(n)),this.setGeometryPathCount(e,this.getPathCount(e)+1),this.setPathGeometry(n,e)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,gr,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),n=this.getPrevVertex(t),i=this.getNextVertex(t);n!==gr&&this.setNextVertex(n,i);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?i:gr),i!==gr&&this.setPrevVertex(i,n),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?n:gr);if(this.hasCurves()&&n!==gr&&i!==gr){const s=this.getVertexIndex(t),r=this.getVertexIndex(n),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),i}removeVertices(t,e){n(t!==e);const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),r=this.getPrevVertex(e);i!==gr&&this.setNextVertex(i,e);let o=this.getPathSize(s);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,i),this.setPrevVertex(t,gr),this.setNextVertex(r,gr);let h=0,u=t;const m=this.getFirstVertex(s);let l=!1;for(;;){const t=this.getNextVertex(u);if(l||=m===u,this.freeVertex(u),h++,u===r)break;u=t}o-=h,l&&this.setFirstVertex(s,o>0?e:gr),this.setPathSize(s,o);const c=this.getGeometryFromPath(s);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,gr,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||r(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==gr;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==gr;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,n=this.getPathSize(e);s<n;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=gr){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=gr){let s=gr,n=gr,i=gr,r=gr,o=0,a=!1;for(s=e!==gr?e:this.getFirstGeometry();s!==gr;s=this.getNextGeometry(s))if(!t||c(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==gr;n=this.getNextPath(n))if(i=this.getFirstVertex(n),r=i,o=0,i!==gr){a=!0;break}if(a||e!==gr)break}return a||(s=gr),fr.create_(this,s,n,i,r,o,t,!1,e!==gr)}queryVertexIteratorOnSelection(t=gr){return this.m_selection?fr.create_(this,t,gr,gr,gr,-1,!1,!0,t!==gr):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){n(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=gr,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return n(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,n,i){n?this.splitSegmentForward(t,e,s,!0,i):this.splitSegmentBackward(t,e,s,!0,i)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){if(null===this.m_segments)return!1;const e=this.getVertexIndex(t);return this.m_segments.length>e&&null!==this.m_segments[e]}querySegment(t,e,s=!0,n=!1){const i=this.getNextVertex(t);if(i===gr)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),n),!0);if(e.copyFrom(r,!0),n)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(i,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}getAndClearSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return n(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let n=null,i=-1,r=t;if(e){const t=this.getVertexIndex(r);n=this.getAndClearSegmentFromIndex(t)}s&&(i=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);n&&n.reverse(),this.setSegmentToIndex(t,n),n=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,i),i=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);e!==gr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==gr?this.setPrevPath(s,e):this.setLastPath(n,e),this.setFirstVertex(t,gr),this.setLastVertex(t,gr),this.freePath(t)}insertClosedPath(t,e,s,n,i){const r=this.insertPath(t,gr);let o=0,a=s;for(i[0]=!1;;){a===n&&(i[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),i[0]&&(s=n),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return n(0),0}findVertex3D(t,e,s){return n(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}getNextNthVertex(t,e){if(0===e)return t;let s=t;for(let n=0;n<e;++n)if(s=e>0?this.getNextVertex(s):this.getPrevVertex(s),s===gr)return gr;return s}removeVertexInternal(t,e){const s=this.getPrevVertex(t),n=this.getNextVertex(t);s!==gr&&this.setNextVertex(s,n),n!==gr&&this.setPrevVertex(n,s);if(this.hasCurves()&&s!==gr&&n!==gr){const i=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(i,null)}else{const t=this.getSegmentFromIndex(i);if(this.setSegmentToIndex(i,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),n}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){n(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new _r(this))}sortVerticesSimpleByX(t,e,s){n(0)}sortVerticesSimpleByY3D(t,e,s){n(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==gr&&this.replaceCurveWithLine(s);this.getNextVertex(t)!==gr&&this.replaceCurveWithLine(t);const n=new $;this.queryXY(t,n),n.y=e,this.setXY(t,n)}setSegmentParentageAndBreak(t,e,s=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&(n(e<=Nt()>>1),e<<=1,e|=s?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if(n(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}if(e>=0){n(e<=Nt()>>1),e<<=1;e|=this.getSegmentParentageBreakVertex(t)?1:0}this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new Pr(e)}return new Pr(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=Nt()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);if(e===gr)return!1;return this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function xr(t){if(t.isEmpty())return new mr({vd:t.getDescription()});if(c(t.getGeometryType())&&t.hasNonLinearSegments())return vr(t);const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new F({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new F,s=new Qs({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const n=e.getAttributeStreamRef(0),i=new Ar({stream:n,n:s});let r=0,o=1;const a=n.readPoint2D(r<<1),h=new $;for(;o<s&&n.queryPoint2D(o<<1,h).equals(a);)o++;if(i.m_treeHull.addElement(r),o<s){i.m_treeHull.addBiggestElement(o);const t=new $;for(let s=o+1;s<e.getPointCount();s++){n.queryPoint2D(s<<1,t);const e=i.treeHull(t);-1!==e&&i.m_treeHull.setElement(e,s)}}const u=e.getDescription(),m=u.getAttributeCount()>1,l=i.m_treeHull.size();let g=null;if(l>=2){g=l>=3?new mr({vd:u}):new Qs({vd:u});const t=g.getImpl();t.reserve(i.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new $;for(let r=i.m_treeHull.getFirst();-1!==r;r=i.m_treeHull.getNext(r))if(m){const s=new F;e.getPointByVal(i.m_treeHull.getElement(r),s),t.insertPoint(0,-1,s)}else n.queryPoint2D(i.m_treeHull.getElement(r)<<1,s),t.insertPoint2D(0,-1,s)}else if(m){const t=new F({vd:u});e.getPointByVal(i.m_treeHull.getElement(i.m_treeHull.getFirst()),t),g=t}else{const t=n.readPoint2D(i.m_treeHull.getElement(i.m_treeHull.getFirst())<<1);g=new F(t)}return g}function Cr(t,e,s,n=!1){if(e<=262144)return Mr(t,e,s,n);const i=new Ar({points:t,n:e}),r=0;let o=1;const a=t[r];for(;o<e&&t[o].equals(a);)o++;if(i.m_treeHull.addElement(r),o<e){i.m_treeHull.addBiggestElement(o);for(let s=o+1;s<e;s++){const e=t[s],n=i.treeHull(e);-1!==n&&i.m_treeHull.setElement(n,s)}}let h=0;for(let u=i.m_treeHull.getFirst();-1!==u;u=i.m_treeHull.getNext(u))s[h++]=i.m_treeHull.getElement(u);return h}function vr(t){n(t.hasNonLinearSegments()&&!t.isEmpty());const e=new Ar;return e.addGeometry(t),e.getBoundingGeometry()}function br(e,s,n){if((s<0||s>=e.getPathCount())&&t("path index"),e.hasNonLinearSegmentsPath(s))return!1;const i=e.getImpl(),r=i.getPathStart(s),o=i.getPathEnd(s),a=!i.isClosedPath(s)&&i.isClosedPathInXYPlane(s),h=i.getAttributeStreamRef(0),u=2*r;let m=2*o;if(a&&(m-=2),m-u<6)return!0;const l=h.readPoint2D(u),c=h.readPoint2D(u+2),g=h.readPoint2D(u+4);if(!Yr($.orientationRobust(c,g,l)))return!1;const d=c.clone(),_=new $;for(let t=u+6;t<m;t+=2){_.assign(c),c.assign(g),h.queryPoint2D(t,g);if(!Yr($.orientationRobust(c,g,l)))return!1;if(!Yr($.orientationRobust(d,g,l)))return!1;if(!Yr($.orientationRobust(c,g,_)))return!1}return!0}function Sr(t,e,s){t.setNAN(),e.setCoords(1,0),s.setCoords(0,0)}function Er(t,s,n,i,r){if(Sr(n,i,r),t.isEmpty())return;if(t.getGeometryType()===e.enumPoint)return void n.assign(t.getXY());const o=t,a=o.getPointCount();0!==a&&(1!==a?Dr(o,a,s,n,i,r):n.assign(o.getXY(0)))}function Dr(t,e,s,n,i,r){if(2===e){const e=t.getXY(0),s=t.getXY(1);n.assign(e.add(s).mul(.5));const o=s.sub(e);i=qr(o),r.setCoords(.5*o.length(),0)}else{let o=Number.MAX_VALUE;const a=[0,1,0,0],h=new yt(4,2);for(h.set(0,0,0),h.set(0,1,1),h.set(1,0,1),h.set(1,1,2);a[0]<e;++a[0],Fr(h,0,e)){a[1]===a[0]&&(++a[1],Fr(h,1,e));for(let s=1;;++s){for(;;){const n=Vr(t.getXY(h.get(0,0)),t.getXY(h.get(0,1)),t.getXY(h.get(s,0)),t.getXY(h.get(s,1)),2^s);if(n>0)break;if(++a[s],Fr(h,s,e),0===n)break}if(3===s)break;a[s+1]<a[s]&&(a[s+1]=a[s],h.set(s+1,0,h.get(s,0)),h.set(s+1,1,h.get(s,1)))}const u=t.getXY(h.get(0,0)).add(t.getXY(h.get(2,0))).mul(.5),m=qr(t.getXY(h.get(0,1)).sub(t.getXY(h.get(0,0)))),l=new $;let c,g;if(l.x=Math.max(0,m.dotProduct(t.getXY(h.get(1,0)).sub(t.getXY(h.get(3,0))))),l.y=Math.max(0,m.crossProduct(t.getXY(h.get(0,0)).sub(t.getXY(h.get(2,0))))),s?(c=l.x*l.y,g=c<o):(c=l.y,g=c<o),g){o=c;const e=t.getXY(h.get(1,0)),s=t.getXY(h.get(3,0)),a=e.add(s).mul(.5).sub(u);n.assign(u.add(m.mul(m.dotProduct(a)))),i.assign(m),r.assign(l)}}r.mulThis(.5),r.x<r.y&&(r.y=Q(r.x,r.x=r.y),i.leftPerpendicularThis())}i.y<0?i.negateThis():0===i.y&&(i.x=1)}yr.st_defaultRank=1;class wr{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,n(0),this.m_convexHull=t,this.m_function=this.done_}next(){return n(0),!1}get_vertex_handle_p(){return n(0),0}get_vertex_handle_q(){return n(0),0}get_current_support(){return n(0),0}getNext(t){return n(0),0}getPrev(t){return n(0),0}intialize_(){return n(0),!1}increment_(){return n(0),!1}increment_q_(){return n(0),!1}increment_p_(){return n(0),!1}parallel_edge_with_q_support_(){return n(0),!1}parallel_edge_with_p_support_(){return n(0),!1}done_(){return n(0),!1}}class Ar{nullGetXY(t){return r("m_getXY is null"),{}}nullDeleteNode(t){r("m_deleteNode is null")}constructor(t){return this.m_treeHull=new Z,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=gr,void(this.m_pathHandle=gr)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=gr,void(this.m_pathHandle=gr)):void d("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new yr,this.m_geometryHandle=this.m_shape.createGeometry(e.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,gr),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return n(0),new $}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){n(0)}addGeometry(s){if(s.isEmpty())return;const n=s.getGeometryType();if(n===e.enumGeometryCollection){const t=s;for(let e=0,s=t.getGeometryCount();e<s;e++)this.addGeometry(t.getGeometry(e))}else h(n)?this.addMultiVertexGeometry(s):m(n)?this.addSegment(s,!1):n===e.enumEnvelope?this.addEnvelope(s):n===e.enumPoint?this.addPoint(s):t("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new F,e=this.m_treeHull.getFirst(),s=new mr({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let n=this.m_treeHull.getNext(e);-1!==n;n=this.m_treeHull.getNext(n))this.m_shape.queryPoint(this.m_treeHull.getElement(n),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return n(0),new wr(this)}getXY(t){return n(0),new $}getXYWithIndex(t){return n(0),new $}getFirst(){return n(0),0}getLast(){return n(0),0}getNext(t){return n(0),0}getPrev(t){return n(0),0}getVertexIndex(t){return n(0),0}getPointCount(){return n(0),0}addMultiVertexGeometry(t){const e=new F,s=t.getImpl(),n=new $;for(let i=0;i<t.getPointCount();i++){s.queryXY(i,n);const r=this.addPoint2D(n);if(-1!==r){t.getPointByVal(i,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}if(c(t.getGeometryType())){const e=t;if(e.hasNonLinearSegments()){const t=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextCurve();null!==e&&this.addSegment(e,!0)}}}}addEnvelope(t){const e=new F;for(let s=0;s<4;s++){const n=new $;t.queryCorner(s,n);const i=this.addPoint2D(n);if(-1!==i){t.queryCornerByVal(s,e);const n=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,n)}}}static querySegmentControlPoints(s,i,r){const o=s.getGeometryType();if(n(o!==e.enumLine),o===e.enumEllipticArc){const t=s,e=60*Math.PI/180,n=Math.abs(t.getSweepAngle());if(n>e){const s=Math.min(6,Math.ceil(n/e)),r=1/s,o=new Pm;t.queryStart(i[0]);let a=1;for(let e=0;e<s;e++){t.queryCut(e*r,(e+1)*r,o);const n=ut($,3);ku(o.get(),n);const h=$.calculateLength(n,3),u=$.calculateLength(n,2),m=h>0?u/h:.5;e<s-1?o.get().queryEnd(i[a+1]):t.queryEnd(i[a+1]),F.lerp(i[a-1],i[a+1],m,i[a]),i[a].setXY(n[1]),a+=2}return a}{const t=ut($,3);ku(s,t);const e=$.calculateLength(t,3);s.queryStart(i[0]),s.queryEnd(i[2]);const n=$.calculateLength(t,2),r=e>0?n/e:.5;return F.lerp(i[0],i[2],r,i[1]),i[1].setXY(t[1]),3}}if(o===e.enumBezier){const t=s,e=ut($,4);t.queryControlPoints(e);const n=$.calculateLength(e,4),r=$.calculateLength(e,2),o=$.calculateLength(e,3);s.queryStart(i[0]),s.queryEnd(i[3]);const a=n>0?r/n:.5;F.lerp(i[0],i[3],a,i[1]),i[1].setXY(e[1]);const h=n>0?o/n:.5;return F.lerp(i[0],i[3],h,i[2]),i[2].setXY(e[2]),4}if(o===e.enumBezier2){const t=s,e=ut($,3);t.queryControlPoints(e);const n=$.calculateLength(e,3);s.queryStart(i[0]),s.queryEnd(i[2]);const r=$.calculateLength(e,2),o=n>0?r/n:.5;return F.lerp(i[0],i[2],o,i[1]),i[1].setXY(e[1]),3}if(o===e.enumRationalBezier2){const t=s,e=ut($,3);t.queryControlPoints(e);const n=$.calculateLength(e,3);s.queryStart(i[0]),s.queryEnd(i[2]);const r=$.calculateLength(e,2),o=n>0?r/n:.5;return F.lerp(i[0],i[2],o,i[1]),i[1].setXY(e[1]),3}t("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){const e=new F,s=t.getStartXY(),n=this.addPoint2D(s);if(-1!==n){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,s)}const i=t.getEndXY(),r=this.addPoint2D(i);if(-1!==r){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}if(t.isCurve()){const e=ut(F,13);for(let s=1,n=Ar.querySegmentControlPoints(t,e,e.length)-1;s<n;++s){const t=e[s].getXY(),n=this.addPoint2D(t);if(-1!==n){const t=this.m_shape.addPoint(this.m_pathHandle,e[s]);this.m_treeHull.setElement(n,t)}}}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),n=this.m_shape.getXY(s);return t.equals(n)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),n=this.m_treeHull.getLast(),i=this.m_treeHull.getElement(s),r=this.m_treeHull.getElement(n),o=this.m_getXY(i),a=this.m_getXY(r),h=$.orientationRobust(a,t,o);if(Yr(h)){e=this.m_treeHull.addBiggestElement(-1);const i=this.treeHullWalkBackward(t,n,s);i!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(i));break}if(Nr(h)){let i=this.m_treeHull.getRoot(),r=this.m_treeHull.getFirst(),a=this.m_treeHull.getLast(),h=-1,u=-1,m=-1;for(;r!==this.m_treeHull.getPrev(a);){u=this.m_treeHull.getElement(i);const e=this.m_getXY(u);Nr($.orientationRobust(e,t,o))?(a=i,i=this.m_treeHull.getLeft(i)):(r=i,i=this.m_treeHull.getRight(i))}i=a,h=r,u=this.m_treeHull.getElement(i),m=this.m_treeHull.getElement(h);const l=this.m_getXY(u),c=this.m_getXY(m);if(h!==s){if(!Yr($.orientationRobust(c,t,l)))break}e=this.m_treeHull.addElementAtPosition(h,i,-2,!0,!1),this.treeHullWalkForward(t,i,n),this.treeHullWalkBackward(t,h,s);break}{const i=Xr(t,a,o);if(-1===i){const i=this.m_treeHull.getPrev(n);this.m_treeHull.deleteNode(n),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,i,s)}else if(1===i){const i=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,i,-3,!0,!1),this.treeHullWalkForward(t,i,n)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let n=e,i=this.m_treeHull.getElement(n),r=this.m_treeHull.getNext(n);const o=this.m_getXY(i);for(;n!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(Yr($.orientationRobust(s,t,o)))break;const a=n;n=r,i=e,o.assign(s),r=this.m_treeHull.getNext(n),this.m_deleteNode(a)}return n}treeHullWalkBackward(t,e,s){if(e===s)return s;let n=e,i=this.m_treeHull.getElement(n),r=this.m_treeHull.getPrev(n);const o=this.m_getXY(i);for(;n!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(Yr($.orientationRobust(o,t,s)))break;const a=n;n=r,i=e,o.assign(s),r=this.m_treeHull.getPrev(n),this.m_deleteNode(a)}return n}}function Tr(t,e,s){const n=e.sub(t),i=s.sub(e);if(0===n.x)return i.x>0?-1:0;if(0===n.y)return i.y>0?1:i.y<0?-1:0;const r=n.crossProduct(i),o=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?1:r<-o?-1:$.orientationRobust(t,e,s)}function Ir(t,e,s){const n=e.sub(t),i=s.sub(e);if(0===n.x)return i.x<0?-1:0;if(0===n.y)return i.y>0?-1:i.y<0?1:0;const r=n.crossProduct(i),o=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?1:r<-o?-1:$.orientationRobust(t,e,s)}function Mr(t,e,s,n){const i=new j(0);for(let h=0;h<e;h++)i.add(h);const r={userSort(e,s,n){n.sort(e,s,(e,s)=>t[e].compareX(t[s]))},getValue:e=>t[e].x};n||W.sortEx(i,0,e,r);let o=0;t:for(let h=0;h<e;++h){const e=i.read(h);for(;o>=2;){const n=s[o-2],r=s[o-1];if(t[r].equals(t[e])){i.write(h,-1);continue t}if(!(Tr(t[n],t[r],t[e])>=0)){r===i.read(h-1)&&i.write(h-1,-1);break}o--}s[o++]=e,2===o&&t[e].equals(t[s[0]])&&(i.write(1,-1),o--)}const a=o+1;t:for(let h=e-2;h>=0;--h){const e=i.read(h);if(!(e<0)){for(;o>=a;){const n=s[o-2],i=s[o-1];if(t[i].equals(t[e]))continue t;if(!(Ir(t[n],t[i],t[e])>=0))break;o--}if(0!==h){const n=s[o-1];s[o++]=e,t[e].equals(t[n])&&o--}}}return o>1&&t[s[0]].equals(t[s[o-1]])&&o--,o}function Yr(t){return t<0}function Nr(t){return t>0}function Xr(t,e,s){let n=-1;if(e.y===s.y)n=0;else if(e.x===s.x)n=1;else{n=Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1}let i=-1;return i=e[n]<s[n]?t[n]<e[n]?-1:s[n]<t[n]?1:0:e[n]<t[n]?-1:t[n]<s[n]?1:0,i}function qr(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function Fr(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Vr(e,s,n,i,r){switch(r){case 0:break;case 1:s.rightPerpendicularThis(),e.rightPerpendicularThis();break;case 2:s.negateThis(),e.negateThis();break;case 3:s.leftPerpendicularThis(),e.leftPerpendicularThis();break;default:t("")}return $.orientationRobustEx(e,s,n,i)}class Lr{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Rr(t){return zr(t.calculateUpperLength2D())}function zr(t){return 256*ct()*t}function Br(t){const e=$.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function kr(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Gr(t,e,s){const n=ut($,4);t.queryControlPoints(n),jr(n,e,s)}function Wr(t,e,s){const n=ut($,4);t.queryControlPoints(n),Zr(n,e,s)}function jr(t,e,s){let n=t[1].x;n-=t[0].x,n*=3;let i=t[2].x;i-=t[1].x,i*=3;let r=t[3].x;r-=t[0].x,r-=i,i-=n,e[3].setWithEps(r),e[2].setWithEps(i),e[1].setWithEps(n),s?e[0].set(0):e[0].set(t[0].x)}function Zr(t,e,s){let n=t[1].y;n-=t[0].y,n*=3;let i=t[2].y;i-=t[1].y,i*=3;let r=t[3].y;r-=t[0].y,r-=i,i-=n,e[3].setWithEps(r),e[2].setWithEps(i),e[1].setWithEps(n),s?e[0].set(0):e[0].set(t[0].y)}function Hr(t,e,s=!1){const n=ut(Ee,4);n[0].assignPoint2D(t[0]),n[1].assignPoint2D(t[1]),n[2].assignPoint2D(t[2]),n[3].assignPoint2D(t[3]),e[1].setCoords(n[1].x.sub(n[0].x),n[1].y.sub(n[0].y)),e[1].mulThis(tt.constructInt32(3)),e[2].setCoords(n[2].x.sub(n[1].x),n[2].y.sub(n[1].y)),e[2].mulThis(tt.constructInt32(3)),e[3]=n[3].sub(n[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(te,te):e[0]=n[0].clone()}function Ur(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ur(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=Kr(t);if(n&&!Number.isNaN(i.length)&&!Number.isNaN(i.length))return i.length;const r=Rr(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let u=1,m=i.specialPointsCount();u<m;u++){const s=i.specialPoints[u];if(a+=ta(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function Or(t,e,s){const n=Ur(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==en(new $o(t,e),U.unit(),1,i)&&r(""),i[0]}function Qr(e,s,n){void 0===n&&(n=s,s=0);const i=new $;if(s<0||n>1)return i.setNAN(),i;if(s>n&&t("calculate_sub_weightedCentroid"),s===n||e.isDegenerate(0))return i.setCoords(0,0),i;const r=Kr(e),o=Rr(e),a=o/e.calculateUpperLength2D();let h=s,u=0;for(let t=1,m=r.specialPointsCount();t<m;t++)if(s<r.specialPoints[t]){u=t-1;break}i.setCoords(0,0);for(let t=u+1,m=r.specialPointsCount();t<m;t++){const s=Math.min(r.specialPoints[t],n),u=ea(e,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[t])break}return i.add(e.getStartXY().mul(e.calculateLength2D()))}function Kr(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Lr,s=ut(rt,8),n=ut($,4);t.queryControlPoints(n);const i=Zo(n,s);e.specialPoints=[];for(let r=0;r<i;r++)e.specialPoints.push(s[r].value());return Jr(t,e),e}function $r(t){let e=null;return e=t.m_cachedValues,e}function Jr(t,e){t.m_cachedValues=e}function to(t){t.m_cachedValues=null}function eo(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function so(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),r=new ce,o=ut($,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new $;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=ut($,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformPoints2D(t.m_cp,2,t.m_cp):(Ct(e,s,1/3,t.m_cp[0]),Ct(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),i&&co(t)}function no(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function io(t,e,s,n){const i=ut($,4);t.queryControlPoints(i);const r=et(18,NaN),o=en(new Lo(i,e,NaN),U.construct(s,n),18,r),a=new $;t.queryCoord2D(s,a);let h=s,u=$.distance(a,e);const m=new $;t.queryCoord2D(n,m);const l=$.distance(m,e);l<u&&(u=l,h=n,a.assign(m));for(let c=0;c<o;c++){t.queryCoord2D(r[c],m);const s=$.distance(m,e);s<u&&(u=s,h=r[c],a.assign(m))}return no(s,n,h,u,a)}function ro(t,e){const s=ut(rt,4);Gr(t,s,!0);const i=ut(rt,4);Wr(t,i,!0);const r=s[3].clone(),o=s[2].clone(),a=s[1].clone(),h=i[3].clone(),u=i[2].clone(),m=i[1].clone(),l=o.mulE(a).addE(u.mulE(m)).mul(4),c=o.mulE(o).mul(8).addE(r.mulE(a).mul(12)).addE(u.mulE(u).mul(8).addE(h.mulE(m).mul(12))),g=r.mulE(o).addE(h.mulE(u)).mul(36),d=r.mulE(r).addE(h.mulE(h)).mul(36),_=ut(rt,3),p=_n(d,g,c,l,new U(0,1),!1,_);if(n(p<=3),p>0){const s=mo(t,1,0).sqrLength(),n=mo(t,1,1).sqrLength();let i=s;e.set(0),i<n&&(i=n,e.set(1));for(let r=0;r<p;r++){const s=mo(t,1,_[r].value()).sqrLength();s<i&&(i=s,e=_[r])}}}function oo(t,e,s,n){if(1===e){const e=1-s,i=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),u=o.mul(i).add(a.mul(2*e*s)).add(h.mul(r));n.assign(u.mul(3))}else if(2===e){const e=1-s,i=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=i.mul(e).add(r.mul(s));n.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);n.assign(s.mul(6))}else n.setCoords(0,0)}function ao(t,e,s,n){{const e=ot.subE(s),i=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(i).addE(t[2].subE(t[1]).mulE(new rt(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));n.setE(o.mulE(new rt(3)))}}function ho(t,e,s){const n=new $;return oo(t,e,s,n),n}function uo(t,e,s){const n=[be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),be.constructPoint2D(t[2]),be.constructPoint2D(t[3])],i=new be;return ao(n,e,s,i),i}function mo(t,e,s){const n=ut($,4);return t.queryControlPoints(n),ho(n,e,s)}function lo(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),n=t.getEndXY().sub(t.getStartXY());e.mulThis(3),s.mulThis(3),n.subThis(s),s.subThis(e);return(3*n.x*(2*s.y+5*e.y)-3*n.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function co(t){const e=ut($,4);t.queryControlPoints(e);const s=go(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function go(t){return we(t)}function _o(t){return Ae(t)}function po(t,e,s){const n=new $,i=new $,r=new $,o=new $,a=new $;e<=.5?(qt(2,t[0],t[1],e,n),qt(2,t[1],t[2],e,i),qt(2,t[2],t[3],e,r),qt(2,n,i,e,o),qt(2,i,r,e,a),qt(2,o,a,e,s)):(Ft(2,t[0],t[1],e,n),Ft(2,t[1],t[2],e,i),Ft(2,t[2],t[3],e,r),Ft(2,n,i,e,o),Ft(2,i,r,e,a),Ft(2,o,a,e,s))}function fo(t,e,s,i){n(e>=0&&e<=1);const r=new $,o=new $,a=new $,h=new $,u=new $,m=new $;e<=.5?(qt(2,t[0],t[1],e,r),qt(2,t[1],t[2],e,o),qt(2,t[2],t[3],e,a),qt(2,r,o,e,h),qt(2,o,a,e,u),qt(2,h,u,e,m)):(Ft(2,t[0],t[1],e,r),Ft(2,t[1],t[2],e,o),Ft(2,t[2],t[3],e,a),Ft(2,r,o,e,h),Ft(2,o,a,e,u),Ft(2,h,u,e,m));const l=t[3].clone();s&&(s[0].assign(t[0]),s[1].assign(r),s[2].assign(h),s[3].assign(m)),i&&(i[0].assign(m),i[1].assign(u),i[2].assign(a),i[3].assign(l))}function Po(t,e,s,i){if(n(e>=0&&s<=1&&e<=s),e===s){const s=new $;return yo(t,e,s),i[0].assign(s),i[1].assign(s),i[2].assign(s),void i[3].assign(s)}if(0===e&&1===s){for(let e=0;e<4;++e)i[e].assign(t[e]);return}const r=ut($,4);fo(t,s,r,null),fo(r,s>0?e/s:0,null,r),yo(t,e,r[0]),yo(t,s,r[3]),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]),i[2].setCoordsPoint2D(r[2]),i[3].setCoordsPoint2D(r[3])}function yo(t,e,s,n){if(n){if(e<0){return void ps(new fm({start:t[0],end:t[0].add(vo(t,0).getUnitVector())}),e,s)}if(e>1){return void ps(new fm({start:t[3],end:t[3].add(vo(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=new $;qt(2,t[0],t[1],e,n);const i=new $;qt(2,t[1],t[2],e,i);const r=new $;qt(2,t[2],t[3],e,r);const o=new $;qt(2,n,i,e,o);const a=new $;qt(2,i,r,e,a),qt(2,o,a,e,s)}else{const n=new $;Ft(2,t[0],t[1],e,n);const i=new $;Ft(2,t[1],t[2],e,i);const r=new $;Ft(2,t[2],t[3],e,r);const o=new $;Ft(2,n,i,e,o);const a=new $;Ft(2,i,r,e,a),Ft(2,o,a,e,s)}}function xo(t,e,s){if(e.value()<=.5){const n=new be;Vt(2,be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),e,n);const i=new be;Vt(2,be.constructPoint2D(t[1]),be.constructPoint2D(t[2]),e,i);const r=new be;Vt(2,be.constructPoint2D(t[2]),be.constructPoint2D(t[3]),e,r);const o=new be;Vt(2,n,i,e,o);const a=new be;Vt(2,i,r,e,a),Vt(2,o,a,e,s)}else{const n=new be;Lt(2,be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),e,n);const i=new be;Lt(2,be.constructPoint2D(t[1]),be.constructPoint2D(t[2]),e,i);const r=new be;Lt(2,be.constructPoint2D(t[2]),be.constructPoint2D(t[3]),e,r);const o=new be;Lt(2,n,i,e,o);const a=new be;Lt(2,i,r,e,a),Lt(2,o,a,e,s)}}function Co(t,e,s){const n=ut($,4);t.queryControlPoints(n),xo(n,e,s)}function vo(t,e){const s=gt(e,0,1);let n=ho(t,1,s);return n.isZero()&&(n=ho(t,2,s),n.isZero()?n=ho(t,3,s):1===s&&n.negateThis()),n}function bo(t,e,s){const n=ut($,4);t.queryControlPoints(n),So(n,e,s)}function So(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(uo(t,1,e))}function Eo(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Io(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Do(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Mo(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function wo(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==Yo(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Ao(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==No(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function To(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Xo(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Io(t,e,s,n,i,r,o,a,h,u){if(null!==i&&(i.length=0),null!=r&&(r.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0,0],a=e.intersectPoint(s.getStartXY(),t,o);if(a>0){if(null!==i)for(let e=0;e<a;e++)i.push(t[e]);if(null!==r)for(let t=0;t<a;t++)r.push(0);if(null!=n)for(let s=0;s<a;s++){const i=new $;e.queryCoord2D(t[s],i),n.push(i)}}return a}const m=Qe(e,s);if(Ke(e,s,o=Math.max(o,m)))return 0;const l=ut($,4);kr(e,l);const c=s.getEndXY();c.subThis(s.getStartXY());const g=c.clone();g.leftPerpendicularThis();let d=3*l[3].dotProduct(g),_=2*l[2].dotProduct(g),p=l[1].dotProduct(g);const f=et(15,Number.NaN),P=et(15,Number.NaN);let y=nn(d,_,p,U.unit(),!1,f);y<0&&(f[0]=0,f[1]=1,y=2);let x,C=0;for(let S=0,E=C;S<y;++S){const t=e.getCoord2D(f[S+E]);P[C]=s.getClosestCoordinate(t,!1),$.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[S+E],C++)}if(l[0].subThis(s.getStartXY()),Math.abs(c.x)>=Math.abs(c.y)){const t=c.y/c.x;d=l[3].y-l[3].x*t,_=l[2].y-l[2].x*t,p=l[1].y-l[1].x*t,x=l[0].y-l[0].x*t}else{const t=c.x/c.y;d=l[3].x-l[3].y*t,_=l[2].x-l[2].y*t,p=l[1].x-l[1].y*t,x=l[0].x-l[0].y*t}const v=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),b=[0,0,0];y=rn(d,_,p,x,U.unit(),v,b);for(let S=0,E=C;S<y;++S){f[S+E]=b[S];const t=e.getCoord2D(f[S+E]);P[C]=s.getClosestCoordinate(t,!1);$.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[S+E],C++)}y=e.intersectPoint(s.getStartXY(),b,o);for(let S=0;S<y;S++)f[C]=b[S],P[C++]=0;y=e.intersectPoint(s.getEndXY(),b,o);for(let S=0;S<y;S++)f[C]=b[S],P[C++]=1;return 0!==s.intersectPoint(e.getStartXY(),b,o)&&(P[C]=b[0],f[C++]=0),0!==s.intersectPoint(e.getEndXY(),b,o)&&(P[C]=b[0],f[C++]=1),0===C?0:gm(t,e,s,f,P,C,n,i,r,o,a,h,u)}function Mo(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return Io(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Ke(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=[],d=ut($,4);{e.queryControlPoints(d);const t=ut($,4),n=new ce;s.canonicToWorldTransformation(n);const i=new ce;i.setInvert(n),i.transformPoints2D(d,4,t);const r=ut(Ee,4);Hr(t,r);const h=[r[0].x,r[1].x,r[2].x,r[3].x],u=[r[0].y,r[1].y,r[2].y,r[3].y],m=ut(tt,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2].setThis(m[0]),m[2].mulThis(m[1]),m[2].negateThis();const _=Fn(h,3,u,3,null,0,m,!0,U.unit(),U.unit(),c,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new $;e.queryCoord2D(c[n],i);const r=s.getClosestCoordinate(i,!1),a=new $;s.queryCoord2D(r,a);$.distance(i,a)<=o&&(l.push(i.clone()),c[t]=c[n],g.push(r),t++)}c.length=t,l.length=t}}const _=[0,1];for(let p=0;p<2;p++){const t=0===p?s.getStartXY():s.getEndXY(),e=[0];Ro(d,t,U.unit(),!1,-1,1,e);const n=new $;yo(d,e[0],n);$.distance(t,n)<=o&&(c.push(e[0]),g.push(_[p]),l.push(n.clone()))}for(let p=0;p<2;p++){const t=[0,3];{const e=s.getClosestCoordinate(d[t[p]],!1),n=new $;s.queryCoord2D(e,n);$.distance(d[t[p]],n)<=o&&(c.push(_[p]),g.push(e),l.push(n.clone()))}}return gm(t,e,s,c,g,c.length,n,i,r,o,a,h,u)}function Yo(t,e,s,i,r,o,a,h,u,m){const l=ut($,4);e.queryControlPoints(l);const c=ut($,4);if(s.queryControlPoints(c),$e(l,c,4)<0)return Yo(t,s,e,i,o,r,a,h,u,!m);const g=Qe(e,s);if(Ke(e,s,a=Math.max(a,g)))return 0;if(sa(e,s,i,r,o,a,h,u,m))return 2;const d=new U(0,1),_=new U(0,1);{const t=new fe;Vo(l,new U(0,1),t);const e=new fe;Vo(c,new U(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Qo(l,t,d),d.isEmpty())return 0;if(Qo(c,t,_),_.isEmpty())return 0;Po(l,d.vmin,d.vmax,l),Po(c,_.vmin,_.vmax,c)}}const p=_m(l,3,c,3,a);if(0===p)return 0;const f=[],P=[],y=[];let x=!1;if(-1===p){const t=ut(Ee,4);Hr(l,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],n=ut(Ee,4);Hr(c,n);const i=[],r=[],o=Nn(e,3,s,3,null,0,[n[0].x,n[1].x,n[2].x,n[3].x],3,[n[0].y,n[1].y,n[2].y,n[3].y],3,null,0,!0,U.unit(),U.unit(),i,r,u);if(o>0)for(let h=0;h<o;h++){const t=new $;yo(c,r[h],t);const e=new $;yo(l,i[h],e);$.distance(e,t)<=a&&(f.push(e.clone()),y.push(r[h]),P.push(i[h]))}else-1===o&&(x=!0)}for(let n=0;n<2;n++){const t=0===n?l:c,e=0===n?c:l;for(let s=0;s<2;s++){const i=0===s?0:3,r=[0];Ro(e,t[i],U.unit(),!1,-1,1,r);const o=new $;yo(e,r[0],o);$.distance(t[i],o)<=a&&(0===n?(P.push(0===i?0:1),y.push(r[0])):(y.push(0===i?0:1),P.push(r[0])),f.push(o.clone()))}}if(0===P.length&&x){const t=e.calculateUpperLength2D()>s.calculateUpperLength2D();{const i=[0,0];if(2===Wo(t?e:s,i,!0)&&(n(U.unit().containsCoordinate(i[0])),!U.unit().containsCoordinate(i[1]))){const e=new $;yo(t?l:c,i[0],e);const s=[0,0];1===Ro(t?c:l,e,U.unit(),!1,-1,2,s)&&(f.push(e.clone()),P.push(t?i[0]:s[0]),y.push(t?s[0]:i[0]))}}}if(0===P.length)return 0;if(!d.equalsRange(0,1))for(let n=0;n<P.length;++n)P[n]=ra.recalculateParentT(d.vmin,d.vmax,P[n]);if(!_.equalsRange(0,1))for(let n=0;n<y.length;++n)y[n]=ra.recalculateParentT(_.vmin,_.vmax,y[n]);return gm(t,e,s,P,y,P.length,i,r,o,a,h,u,m)}function No(t,e,s,i,r,o,a,h,u,m){const l=Qe(e,s);if(s.isDegenerateToLineHelper(l)){const n=new fm({start:s.getStartXY(),end:s.getEndXY()}),l=Io(t,e,n,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=n.getCoord2D(o[t]);o[t]=s.getClosestCoordinate(e,!1)}return l}if(Ke(e,s,a=Math.max(a,l)))return 0;const c=ut($,4);e.queryControlPoints(c);const g=ut($,3);s.queryControlPoints(g);const d=new U(0,1),_=new U(0,1),p=[0,0,0];s.queryWeights(p);const f=[1,Ph(p),1];{const t=new fe;Vo(c,new U(0,1),t);const e=new fe;ja(g,f,new U(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Qo(c,t,d),d.isEmpty())return 0;if(fh(g,f,t,_),_.isEmpty())return 0;Po(c,d.vmin,d.vmax,c),Ka(g,f,_.vmin,_.vmax,g,f)}}const P=_m(c,3,g,2,a);if(0===P)return 0;const y=[],x=[],C=[];if(-1===P){const t=ut(Ee,4);Hr(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],n=ut(tt,3),i=ut(tt,3),r=ut(tt,3);uh(g,f,n,i,r);const o=[],h=[],m=Nn(n,2,i,2,r,2,e,3,s,3,null,0,!0,U.unit(),U.unit(),h,o,u);if(m>0)for(let u=0;u<m;u++){const t=new $;yo(c,o[u],t);const e=new $;ph(g,f,h[u],e);$.distance(t,e)<=a&&(y.push(t.clone()),x.push(o[u]),C.push(h[u]))}}for(let v=0;v<2;v++){let t,e;0===v?(t=c,e=g):(e=c,t=g);for(let s=0;s<2;s++){const i=0===s?0:t.length-1,r=[0],o=new $;if(0===v){const s=Ba(e,f,t[i],U.unit(),!1,-1,1,r);n(1===s),ph(e,f,r[0],o)}else{const s=Ro(e,t[i],U.unit(),!1,-1,1,r);n(1===s),yo(e,r[0],o)}$.distance(t[i],o)<=a&&(0===v?(x.push(0===i?0:1),C.push(r[0])):(C.push(0===i?0:1),x.push(r[0])),y.push(o.clone()))}}if(0===x.length)return 0;if(!d.equalsRange(0,1))for(let n=0;n<x.length;++n)x[n]=ra.recalculateParentT(d.vmin,d.vmax,x[n]);if(!_.equalsRange(0,1))for(let n=0;n<C.length;++n)C[n]=Dn.recalculateParentT(_.vmin,_.vmax,C[n]);for(let n=0;n<C.length;++n)C[n]=yh(p,C[n]);return gm(t,e,s,x,C,x.length,i,r,o,a,h,u,m)}function Xo(t,e,s,i,r,o,a,h,u,m){const l=Qe(e,s);if(Ke(e,s,a=Math.max(a,l)))return 0;const c=ut($,4);e.queryControlPoints(c);const g=ut($,3);s.queryControlPoints(g);const d=_m(c,3,g,2,a);if(0===d)return 0;const _=[],p=[],f=[];if(-1===d){const t=ut(Ee,4);Hr(c,t);const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y],r=ut(Ee,3);ji(g,r);const o=Nn([r[0].x,r[1].x,r[2].x],2,[r[0].y,r[1].y,r[2].y],2,null,0,n,3,i,3,null,0,!0,U.unit(),U.unit(),f,p,h);if(o>0){let t=0;for(let n=0;n<o;n++){const i=new $;e.queryCoord2D(p[n],i);const r=new $;s.queryCoord2D(f[n],r);$.distance(i,r)<=a&&(_.push(i.clone()),p[t]=p[n],f[t]=f[n],t++)}p.length=t,_.length=t}}for(let P=0;P<2;P++){let t,e;0===P?(t=c,e=g):(e=c,t=g);for(let s=0;s<2;s++){const i=0===s?0:t.length-1,r=[0],o=new $;if(0===P)bi(e,t[i],r),Zi(e,r[0],o);else{const s=Ro(e,t[i],U.unit(),!1,-1,1,r);n(1===s),yo(e,r[0],o)}$.distance(t[i],o)<=a&&(0===P?(p.push(0===i?0:1),f.push(r[0])):(f.push(0===i?0:1),p.push(r[0])),_.push(o.clone()))}}return gm(t,e,s,p,f,p.length,i,r,o,a,h,u,m)}function qo(t,e,s,r,o){const a=new fe;if(Fo(t,U.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;const h=Kr(t);let u=0,m=h.specialPoints[0];const l=[];for(let i=1,c=h.specialPoints.length;i<c;++i){const s=h.specialPoints[i],r=io(t,e,m,s);if(0===l.length)l.push(r);else if(r.t===r.tmin)n(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){n(l.at(-1).d>=r.d);const t=l.at(-1).tmin;l[l.length-1]=r,l.at(-1).tmin=t}else l.push(r);m=s}for(const n of l)if(n.d<=r){const t=n.t;s?(u>=s.length&&i(""),s[u]=t,u++):u++}return u}function Fo(t,e,s){const n=ut($,4);t.queryControlPoints(n),Vo(n,e,s)}function Vo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const n=ut($,4);Po(t,e.vmin,e.vmax,n),s.setFromPoints(n,4)}let Lo=class{constructor(t,e,s){this.dbgCounter=0,this.controlPoints=t,this.point=e.clone(),this.maxDistance=s}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new $;yo(this.controlPoints,e,t);const s=ho(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new $;yo(this.controlPoints,e,t);const s=ho(this.controlPoints,1,e),n=ho(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(n)+s.dotProduct(s))}case 2:{const t=new $;yo(this.controlPoints,e,t);const s=ho(this.controlPoints,1,e),n=ho(this.controlPoints,2,e),i=ho(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(i)+3*s.dotProduct(n))}case 3:{const t=ho(this.controlPoints,1,e),s=ho(this.controlPoints,2,e),n=ho(this.controlPoints,3,e);return 2*(4*t.dotProduct(n)+3*s.sqrLength())}case 4:{const t=ho(this.controlPoints,2,e),s=ho(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=ho(this.controlPoints,3,e);return 2*(10*t.dotProduct(t))}default:return 0}}getError(t){return 0}isInterestingInterval(t,e){if(t>=0&&e<=1){const s=ut($,4);Po(this.controlPoints,t,e,s);const n=new fe;if(n.setFromPoints(s,4),Math.sqrt(n.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function Ro(t,e,s,i,r,o,a){_(U.unit().contains(s)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],u=new $;yo(t,s.vmin,u);let m=$.distance(u,e);if(m<=r&&h.push(new $(s.vmin,m)),s.vmin!==s.vmax&&(yo(t,s.vmax,u),m=$.distance(u,e),m<=r&&h.push(new $(s.vmax,m))),s.width()>0){const n=et(18,Number.NaN),i=en(new Lo(t,e,r),s,18,n);for(let s=0;s<i;s++)yo(t,n[s],u),m=$.distance(u,e),m>r||h.push(new $(n[s],m))}if(i){n(s.equals(U.unit()));{yo(t,-1,u,!0);const s=new $;yo(t,0,s);const n=new fm({start:u,end:s}),i=n.getClosestCoordinate(e,!0);i<1&&(u.assign(n.getCoord2D(i)),m=$.distance(u,e),m<=r&&h.push(new $(i-1,m)))}{yo(t,2,u,!0);const n=new $;yo(t,s.vmax,n);const i=new fm({start:n,end:u}),o=i.getClosestCoordinate(e,!0);o>0&&(u.assign(i.getCoord2D(o)),m=$.distance(u,e),m<=r&&h.push(new $(1+o,m)))}}if(!h.length)return 0;h.sort((t,e)=>t.compare(e));let l=0;const c=h[0].x;if(a[l++]=c,l<o){const e=H(t,4,!1).total(),s=h[0].y;for(let t=1,n=h.length;t<n;t++)if(h[t].y>s+e){h.length=t;break}h.sort((t,e)=>kt(t.x,e.x)),l=0,a[l++]=h[0].x;for(let t=1,n=h.length;t<n;t++)h[t].x!==a[l-1]&&l<o&&(a[l++]=h[t].x)}return l}function zo(t,e,s,n,i,r,o){const a=ut($,4);return t.queryControlPoints(a),Ro(a,e,s,n,i,r,o)}function Bo(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function ko(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function Go(t,e,s){if(n(s>=2),2===s){const n=new $;Ct(e[0],e[s-1],1/3,n);const i=new $;return Ct(e[0],e[s-1],2/3,i),void t.construct(e[0],n,i,e[s-1])}const i=e[0],r=e[s-1],o=[0,0],a=zo(t,i,U.unit(),!1,Number.NaN,2,o),h=[0,0],u=zo(t,r,U.unit(),!1,Number.NaN,2,h),m=[];for(let n=0;n<a;n++)for(let a=0;a<u;a++){const u=o[n],l=h[a],c=u>l,g=(n,o)=>{const a=et(s-2,Number.NaN),h=()=>{let t=0;for(let n=1,i=s-1;n<i;n++){t+=$.distance(e[n-1],e[n]);const s=t;a[n-1]=s}t+=$.distance(e[s-2],e[s-1]),c&&a.reverse();for(let e=1,n=s-1;e<n;e++)a[e-1]/=t,c&&(a[e-1]=1-a[e-1])};let m=!1,g=!1;{const e=new Pm;c?(t.queryCut(l,u,e,!0),n.assign(e.get().getControlPoint2()),o.assign(e.get().getControlPoint1())):(t.queryCut(u,l,e,!0),n.assign(e.get().getControlPoint1()),o.assign(e.get().getControlPoint2())),i.equals(n)&&(m=!0),r.equals(o)&&(g=!0)}h();let d=Number.MAX_VALUE;const _=n.clone(),p=o.clone();for(let t=0;t<5;t++){d=na(!0,!1,i,_,p,r,m,g,a,s-2,e,s)}for(let t=0;t<30;t++){const t=_.clone();p.clone();const n=na(!0,!0,i,_,p,r,m,g,a,s-2,e,s);if(d<=n&&t.equals(_)&&t.equals(p))break;d=n}h();let f=!1,P=Number.MAX_VALUE;const y=n.clone(),x=o.clone();for(let t=0;t<30;t++){const t=y.clone();x.clone();const n=na(f,!0,i,y,x,r,m,g,a,s-2,e,s);if(P<=n&&t.equals(y)&&t.equals(x))break;f=!0,P=n}return P<d?(n.assign(y),o.assign(x)):(n.assign(_),o.assign(p),P=d),P},d=new $,_=new $,p=[g(d,_),$.distance(i,d)+$.distance(d,_)+$.distance(_,r),d.x,d.y,_.x,_.y];m.splice(m.length,0,...p)}let l=m[0],c=m[1],g=0;for(let n=6;n<m.length;n+=6)m[n]<l&&(l=m[n],c=m[n+1],g=n);let d=g;for(let n=0;n<m.length;n+=6)n!==g&&m[n+1]<c&&Math.abs(l-m[n])<10*l&&(c=m[n+1],d=n);t.construct(i,new $(m[d+2],m[d+3]),new $(m[d+4],m[d+5]),r)}function Wo(t,e,s=!1){const n=ut($,4);t.queryControlPoints(n);const i=ut(Ee,4);let r,o,a;Hr(n,i,!0);const h=i[3].x.isZero(),u=i[3].y.isZero();if(h||u)if(h&&!u){if(i[2].x.isZero())return 0;r=i[1].x.div(i[2].x).negate(),o=i[2].y.div(i[3].y),a=i[1].y.div(i[3].y)}else{if(h||!u)return 0;if(i[2].y.isZero())return 0;r=i[1].y.div(i[2].y).negate(),o=i[2].x.div(i[3].x),a=i[1].x.div(i[3].x)}else{i[2].x.divThis(i[3].x),i[1].x.divThis(i[3].x),i[2].y.divThis(i[3].y),i[1].y.divThis(i[3].y);const t=i[2].x.sub(i[2].y);if(t.isZero())return 0;r=i[1].x.sub(i[1].y).div(t).negate(),o=i[2].x.clone(),a=i[1].x.clone()}if(!s&&r.abs().value()>2)return 0;const m=[0,0],l=t.getStartXY().equals(t.getEndXY()),c=nn(1,-r.toDouble(),r.add(o).mul(r).add(a).toDouble(),U.unit(),l,m);if(0===c)return 0;if(m[0]>=0&&m[0]<=1){const t=r.toDouble()-m[0];if(s||t>=0&&t<=1)return e[0]=m[0],e[1]=t,e[0]>e[1]&&(e[1]=Q(e[0],e[0]=e[1])),2}if(2===c&&m[1]>=0&&m[1]<=1){const t=r.toDouble()-m[1];if(s||t>=0&&t<=1)return e[0]=m[1],e[1]=t,e[0]>e[1]&&(e[1]=Q(e[0],e[0]=e[1])),2}return 0}function jo(t,e,s){const n=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),i=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),r=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),o=ut(rt,2);let a=dn(r,i,n,new U(0,1),!1,o);a<0&&(a=0);let h=0;for(let u=0;u<a;u++)lt(o[u].value(),0,1)||(s[h].setE(o[u]),h++);return h}function Zo(t,e){e[0].set(0);let s=1;const i=ut(rt,4);jr(t,i,!0);const r=ut(rt,4);Zr(t,r,!0);{const t=i[3].mul(3),n=i[2].mul(2),r=i[1].clone(),o=ut(rt,2);let a=dn(t,n,r,new U(0,1),!1,o);a<0&&(a=0);for(let i=0;i<a;i++)lt(o[i].value(),0,1)||(e[s]=o[i],s++)}{const t=r[3].mul(3),n=r[2].mul(2),i=r[1].clone(),o=ut(rt,2);let a=dn(t,n,i,new U(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)lt(o[r].value(),0,1)||(e[s]=o[r],s++)}if(s+=jo(i,r,e.slice(s)),e[s].set(1),s++,s>2){ft(e,0,s,(t,e)=>{const s=t.value(),n=e.value();return s<n?-1:s>n?1:0});let n=0;const i=e[0].clone();let r=0;const o=ko(t)*ct(),a=new $;po(t,e[0].value(),a);for(let h=1;h<s;h++){const s=new $;if(po(t,e[h].value(),s),e[h].eq(i)||s.isEqualPoint2D(a,o)){if(0!==n){if(0===e[h].eps())i.setE(e[h]),r=0;else if(0!==r){const t=Bt(1/e[h].eps()),s=1/r,n=t+s;i.set((e[h].value()*t+i.value()*s)/n),r=1/n,i.setError(Math.sqrt(r))}e[n].setE(i),po(t,i.value(),a)}}else n++,e[n].setE(e[h]),i.setE(e[h]),po(t,i.value(),a),r=Bt(e[h].eps())}n++,s=n}return 1===s&&(s=2,e[1].set(1)),n(0===e[0].value()),n(1===e[s-1].value()),s}function Ho(t,e,s,n,i){const r=ut(rt,4),o=ut(rt,3),a=new U(0,1);let h=0;if(e){if(Zr(t,r,!1),h=_n(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new $;yo(t,o[u].value(),e),n[u]=e.x}}else if(jr(t,r,!1),h=_n(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new $;yo(t,o[u].value(),e),n[u]=e.y}if(i)for(let u=0;u<h;u++)i[u]=o[u].value();else n&&ft(n,0,h,kt);return h}function Uo(t,e,s,n){const i=Oo(t,e,s,n.getEnvelope2D());if(i.isEmpty())return new U(i);const r=ut($,s);for(let a=0;a<s;++a)n.xyRot(t[a],r[a]);const o=Oo(r,e,s,n.getRotatedEnvelope2D());return i.intersect(new U(o)),new U(i)}function Oo(t,e,s,n){const i=ut($,s);for(let a=0;a<s;++a)i[a]=new $(a/(s-1),0);const r=(t,e,s,n)=>{const i=.1,r=new rt(e.x).subE(new rt(t.x)).divE(new rt(e.y).subE(new rt(t.y))).mulE(new rt(s).subE(new rt(t.y))).addE(new rt(t.x));if(r.eps()>i){const n=(e.x-t.x)/(e.y-t.y)*(s-t.y)+t.x;r.set(n,ct())}if(r.lt(new rt(0))||r.gt(new rt(1)))return!1;let o=r.value()-r.eps();o=gt(o,0,1);let a=r.value()+r.eps();return a=gt(a,0,1),n.mergeCoordinate(o),n.mergeCoordinate(a),!0},o=[];{const e=(t,e)=>{o.length=s;const n=Cr(i,s,o,!0),a=new U;a.setEmpty();const h=s=>s.y<t?-1:s.y>e?1:0;let u=i[o[0]],m=h(u);0===m&&a.mergeCoordinate(u.x);for(let s=1;s<=n;++s){const l=i[o[s%n]],c=h(l);0===c&&a.mergeCoordinate(l.x);let g=0;c!==m&&(g=c*m===0?1===c||1===m?2:1:3,1&g&&r(u,l,t,a),2&g&&r(u,l,e,a)),u=l,m=c}return a};for(let n=0;n<s;++n)i[n].y=t[n].x;const a=e(n.xmin,n.xmax);if(a.isEmpty())return new U(a);for(let n=0;n<s;++n)i[n].y=t[n].y;const h=e(n.ymin,n.ymax);return a.intersect(new U(h)),new U(a)}}function Qo(t,e,s){s.setEmpty(),s.merge(Uo(t,null,4,e))}function Ko(t,e,s){s.length=0;{const e=new rt;ro(t,e);const n=new be;if(bo(t,e,n),n.isZero())return e.isZero()||e.eq(new rt(1))?0:(s.push(e.value()),1)}const n=ut(rt,4);Gr(t,n,!0);const i=ut(rt,4);Wr(t,i,!0);const r=ut(rt,6),o=n[3].negate().mulE(i[1]).addE(n[2].mulE(i[2]).mul(2)).addE(n[1].mulE(i[3])),a=n[3].negate().mulE(i[1]).subE(n[2].mulE(i[2]).mul(2)).addE(n[1].mulE(i[3])),h=n[2].mulE(n[2]).subE(i[2].mulE(i[2]));r[0]=i[1].mulE(i[1]).mulE(o).addE(n[1].mulE(n[1]).mulE(a)).addE(n[1].mulE(i[1]).mulE(h).mul(2)).mul(6),r[1]=n[2].mulE(i[1]).subE(n[1].mulE(i[2])).mulE(n[2].mulE(n[2]).addE(n[1].mulE(n[3]).mul(2)).addE(i[2].mulE(i[2])).addE(i[1].mulE(i[3]).mul(2))).mul(24);const u=n[1].mulE(i[2]).mulE(i[2]).mulE(i[3]),m=n[2].mulE(n[2]).mulE(n[3]).mulE(i[1]).subE(u).mul(156),l=n[3].mulE(i[1]).subE(n[1].mulE(i[3])),c=n[3].mulE(i[1]).subE(n[1].mulE(i[3])),g=n[1].mulE(n[3]).mulE(c).addE(i[1].mulE(i[3]).mulE(l)).mul(72),d=i[1].mulE(i[3]).subE(n[1].mulE(n[3])),_=n[2].mulE(i[2]).mulE(d).mul(120),p=n[1].mulE(n[2]).mulE(n[2]).mulE(i[3]),f=n[3].mulE(i[1]).mulE(i[2]).mulE(i[2]).subE(p).mul(36);r[2]=m.addE(g).addE(_).addE(f);const P=n[2].mulE(n[3]).mulE(n[3]).mulE(i[1]).subE(n[1].mulE(i[2]).mulE(i[3]).mulE(i[3])).mul(360),y=n[2].mulE(i[2]).mulE(n[2].mulE(n[3]).subE(i[2].mulE(i[3]))).addE(n[3].mulE(i[2]).mulE(i[2]).mulE(i[2])).subE(n[2].mulE(n[2]).mulE(n[2]).mulE(i[3])).mul(24),x=n[2].mulE(i[1]).mulE(i[3]).mulE(i[3]).subE(n[1].mulE(n[3]).mulE(n[3]).mulE(i[2])).mul(72),C=n[3].mulE(i[3]).mulE(i[1].mulE(i[2]).subE(n[1].mulE(n[2]))).mul(288);r[3]=P.addE(y).addE(x).addE(C),r[4]=i[3].mulE(i[3]).addE(n[3].mulE(n[3])).mulE(n[3].mulE(i[1]).subE(n[1].mulE(i[3]))).mul(270).addE(n[3].mulE(i[2]).subE(n[2].mulE(i[3]))).mulE(n[2].mulE(n[3]).addE(i[2].mulE(i[3]))).mul(180),r[5]=n[3].mulE(i[2]).subE(n[2].mulE(i[3])).mulE(n[3].mulE(n[3]).addE(i[3].mulE(i[3]))).mul(216);const v=ut(rt,5),b=pn(r,5,new U(0,1),!1,v,5);if(b>0){let n=Math.abs(t.getCurvature(0)),i=0;const r=Math.abs(t.getCurvature(1));(r>n||!Number.isFinite(r))&&(i=1);for(let e=0;e<b;e++){const s=Math.abs(t.getCurvature(v[e].value()));t.getCoord2D(v[e].value()),(s>n||!Number.isFinite(s))&&(n=s,i=v[e].value())}if((!Number.isFinite(n)||1/n<e)&&!lt(i,0,1)){const e=t.getCoord2D(i);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(i),1}}if(!t.isClosed()){const e=[0,0],n=Wo(t,e,!1);for(let t=0;t<n;t++)e[t]>0&&e[t]<1&&s.push(e[t]);return s.length}return 0}class $o{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ur(this.b,e,!1):0}getError(t){return 0}}function Jo(t,e,s,i,r,o,a){for(;;){const h=$.distance(e[0],e[3]),u=$.distance(e[0],e[1])+$.distance(e[1],e[2])+$.distance(e[2],e[3]);if(u-h<=i+s*u)return t+nt(h,u,.5);const m=t=>ho(e,1,t).length();{n(a<12);let h=m(0),l=m(1);r[0]+=2,h>l&&(l=Q(h,h=l),e[3]=Q(e[0],e[0]=e[3]),e[2]=Q(e[1],e[1]=e[2]));let c=h/(h+l),g=1,d=u;for(;c<1/32&&d>=32*(i+s*d);){g/=4;const t=m(g);r[0]++,c=h/(t+h);const s=new $;if(yo(e,.5*g,s),d=$.distance(s,e[0]),d<=i){const t=new $;yo(e,g,t),d+=$.distance(t,s)}}if(1!==g){const n=ut($,4);fo(e,g,e,n),t=Jo(t,n,s,i,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=ur(l,m,0,1),g=16;r[0]+=g;const d=ur(g,m,0,1);let _=Math.abs(c-d)>i+s*u;if(!_)return t+d;if(o<3){const n=ut($,4);fo(e,.5,e,n),t=Jo(t,n,s,i,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const f=ur(p,m,0,1);if(_=Math.abs(d-f)>i+s*u,!_)return t+f;const P=64;r[0]+=P;const y=ur(P,m,0,1);if(_=Math.abs(f-y)>i+s*u,!_)return t+y;const x=128;r[0]+=x;const C=ur(x,m,0,1);return _=Math.abs(y-C)>i+s*u,t+C}}function ta(t,e,s,n,i){if(s===e)return 0;const r=ut($,4);t.queryControlPoints(r);const o=ut($,4);Po(r,e,s,o);return Jo(0,o,n,i,[0],0,0)}function ea(t,e,s,n,i){let r=!0;const o=$n(5,e,s,n,i,e=>{const s=mo(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});r=!1;const a=$n(5,e,s,n,i,e=>{const s=mo(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});return new $(o,a)}function sa(t,e,s,n,i,r,o,a,h){const u=ut($,4);t.queryControlPoints(u);const m=ut($,4);if(e.queryControlPoints(m),u[0].equals(m[0])){if(u[1].equals(m[1])&&u[2].equals(m[2])&&u[3].equals(m[3]))return s&&(s.length=0,s.push(u[0]),s.push(u[3])),n&&(n.length=0,n.push(0),n.push(1)),i&&(i.length=0,i.push(0),i.push(1)),!0;if(!u[0].equals(m[3]))return!1}return!!(u[0].equals(m[3])&&u[1].equals(m[2])&&u[2].equals(m[1])&&u[3].equals(m[0]))&&(n&&(n.length=0,n.push(0),n.push(1),h&&(n[1]=Q(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=Q(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[3]),h&&(s[1]=Q(s[0],s[0]=s[1]))),!0)}function na(t,e,s,i,r,o,a,h,u,m,l,c){n(m+2===c);let g=0,d=0,_=0,p=0,f=0,P=0,y=0;const x=(t,e)=>{const n=1-e,a=s.mul(ae(n)),h=i.mul(3*e*n*n),u=r.mul(3*e*e*n),m=o.mul(ae(e));return a.add(h).add(u).add(m).sub(l[t]).sqrLength()};for(let n=1,v=c-1;n<v;n++){let e=u[n-1];if(t){n>2?(e=gt(2*u[n-2]-u[n-3],0,1),u[n-1]=e):2===n&&(e=gt(2*u[n-2],0,1),u[n-1]=e);const t=(t,e,n)=>{let a=-1;for(let h=0;!(Math.abs(e-a)<1e-12)&&10!==h;h++){const h=e*e,u=1-e,m=u*u,c=m*u,g=s.x-2*i.x+r.x,d=s.x-3*i.x+3*r.x-o.x,_=s.y-2*i.y+r.y,p=s.y-3*i.y+3*r.y-o.y,f=s.x-i.x-2*g*e+d*h,P=-l[t].x+s.x*c+e*(3*i.x*m+e*(3*r.x*u+o.x*e)),y=s.y-i.y-2*_*e+p*h,x=-l[t].y+s.y*c+e*(3*i.y*m+e*(3*r.y*u+o.y*e)),C=-6*(f*P+y*x),v=6*(3*Bt(f)-(-2*g+2*d*e)*P)+6*(3*Bt(y)-(-2*_+2*p*e)*x);if(a=e,0===v)break;e=gt(e-C/v,n,1)}return a};{const e=x(n,u[n-1]);let s=t(n,u[n-1],0),i=x(n,s);if(1.01*e<i){const e=n>1?u[n-2]:0,r=t(n,.3*(u[n-1]-e)+e,0),o=x(n,r);o<i&&(i=o,s=r)}e>i&&(u[n-1]=s)}}const a=u[n-1],h=a*a,m=h*a,c=1-a,C=c*c,v=C*c;g+=3*h*C*C,d+=3*m*v,_+=3*h*h*C;const b=-(v*s.x+m*o.x-l[n].x);p+=b*a*C,f+=b*h*c;const S=-(v*s.y+m*o.y-l[n].y);P+=S*a*C,y+=S*h*c}if(e){const t=g*_-d*d;Math.abs(t)>=1e-12*(Math.abs(g*_)+Math.abs(d*d))+1e-10?(a||(i.x=(p*_-f*d)/t,i.y=(P*_-y*d)/t),h||(r.x=(g*f-d*p)/t,r.y=(g*y-d*P)/t)):(Ct(s,o,.3,i),Ct(s,o,.6,r))}let C=0;for(let n=1,v=c-1;n<v;n++)C+=x(n,u[n-1]);return C}var ia=b;class ra extends ds{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=ut($,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||bt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=ut($,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=ut($,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),r("unrecognized constructor params"),this.m_cp=ut($,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return Js(this)}construct(t,e,s,n){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=n.x,this.m_YEnd=n.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=ut($,4);Ji(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),wt(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),wt(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),He(this,t)}getGeometryType(){return e.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void n(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=$r(this);if(null!==e){const s=new $;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s);return}const s=ut(rt,8),i=ut($,4);this.queryControlPoints(i);const r=Zo(i,s),o=new $;for(let n=1;n<r-1;n++)this.queryCoord2D(s[n].value(),o),t.mergeNe(o)}applyTransformation(t){if(1===t.m_TransformationType){const e=ut($,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void to(this)}n(0)}createInstance(){return new ra({vd:this.m_description})}calculateLength2D(){return Ur(this,1,!1)}calculateLowerLength2D(){return $.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return $.distance(this.getStartXY(),this.m_cp[0])+$.distance(this.m_cp[0],this.m_cp[1])+$.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){n(0)}queryCoord2DExtends(t,e,s){const n=ut($,4);this.queryControlPoints(n),yo(n,t,e,s)}queryCoord2DE(t,e){Co(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new $;return this.queryCoord2DExtends(t,e,!0),e.x}const e=nt(this.getStartX(),this.m_cp[0].x,t),s=nt(this.m_cp[0].x,this.m_cp[1].x,t),n=nt(this.m_cp[1].x,this.getEndX(),t),i=nt(e,s,t),r=nt(s,n,t);return nt(i,r,t)}getCoordY(t){if(t<0||t>1){const e=new $;return this.queryCoord2DExtends(t,e,!0),e.y}const e=nt(this.getStartY(),this.m_cp[0].y,t),s=nt(this.m_cp[0].y,this.m_cp[1].y,t),n=nt(this.m_cp[1].y,this.getEndY(),t),i=nt(e,s,t),r=nt(s,n,t);return nt(i,r,t)}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=ia.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=ia.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){bo(this,t,e)}cutBezierIgnoreAttributes(e,s,n){(e<0||s>1||e>s)&&t("Cubic_bezier.cut_bezier_ignore_attributes");const i=ut($,4);this.queryControlPoints(i);const r=ut($,4);Po(i,e,s,r),n.setControlPoints(r)}splitBezierIgnoreAttributes(e,s,n){this===s&&this===n&&t("Cubic_bezier.split_bezier_ignore_attributes");const i=ut($,4);this.queryControlPoints(i);const r=ut($,4),o=ut($,4);fo(i,e,r,o),s&&s.setControlPoints(r),n&&n.setControlPoints(o)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const n=this.getStartAttributeAsDbl(e,s),i=this.getEndAttributeAsDbl(e,s),r=this.calculateLength2D(),o=r>0?this.tToLength(t)/r:0,a=ia.getInterpolation(e);return vt(a,n,i,o,ia.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return zo(this,t,U.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const n=[Number.NaN];return 0===zo(this,t,e,!1,s,1,n)?Number.NaN:n[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(e,s){e.length<2&&t("");const i=Kr(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;n(e.length>=i.specialPointsCount()-1);for(let t=1,n=i.specialPointsCount();t<n;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[r],s),r++;for(let t=0;t<r;++t){co(e[t].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=ut($,4);return this.queryControlPoints(i),Ho(i,t,e,s,n)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],i=this.intersectionWithAxis2D(!0,t,s,null);return n(2!==i),-1===i?e:s[0]}isCurve(){return!0}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());n(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=le.constructEmpty();this.queryEnvelope(t);const s=U.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=ut($,4);this.queryControlPoints(s),Po(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),n=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),i=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):n&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):i&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ur(this,t,!0)}lengthToT(t){return Or(this,t)}calculateWeightedAreaCentroid2D(t){const e=ut($,4);kr(this,e);const s=e[3],n=e[2],i=e[1],r=new $;r.x=(5*s.x*s.x*(7*n.y+16*i.y)+s.x*(-35*s.y*n.x+40*n.x*n.y-80*s.y*i.x+140*n.x*i.y+112*i.x*i.y)-2*(s.y*(20*n.x*n.x+70*n.x*i.x+56*i.x*i.x)-7*(4*n.x+5*i.x)*(-n.y*i.x+n.x*i.y)))/840,r.y=(-5*s.y*s.y*(7*n.x+16*i.x)+s.y*(5*s.x*(7*n.y+16*i.y)-4*(10*n.x*n.y+35*n.y*i.x+28*i.x*i.y))+2*(-7*(4*n.y+5*i.y)*(n.y*i.x-n.x*i.y)+s.x*(20*n.y*n.y+70*n.y*i.y+56*i.y*i.y)))/840;const o=lo(this);return r.x+=(e[0].x-t.x)*o,r.y+=(e[0].y-t.y)*o,r}calculateWeightedCentroid2D(){const t=new $;return this.isDegenerate(0)?(t.setCoords(0,0),t):Br(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Qr(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),4}setControlPoints(e){for(let s=0;s<4;s++)e[s].isNAN()&&t("NAN control points in bezier are not supported");this.m_XStart=e[0].x,this.m_YStart=e[0].y,this.m_cp[0].setCoordsPoint2D(e[1]),this.m_cp[1].setCoordsPoint2D(e[2]),this.m_XEnd=e[3].x,this.m_YEnd=e[3].y,this.afterCompletedModification()}getTangent(t){const e=ut($,4);return this.queryControlPoints(e),vo(e,t)}getDerivative(t){const e=ut($,4);return this.queryControlPoints(e),ho(e,1,t)}getCurvature(t){const e=mo(this,1,t),s=mo(this,2,t),n=e.sqrLength();if(0===n)return Number.NaN;e.divThis(Math.sqrt(n));return e.crossProduct(s)/n}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const n=new le;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new $;this.queryCoord2D(i,r);return $.distance(r,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}isMonotoneQuickAndDirty(){const t=ut($,4);return this.queryControlPoints(t),_o(t)}getMonotonicPartParams(e,s){const i=Kr(this),r=i.specialPointsCount();if(n(ts.s_maxMonotonicPartParams>=r),!s)return i.specialPointsCount();e<r&&t("");for(let t=0;t<r;t++)s[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=Q(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new rt;return ro(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=ut($,4);this.queryControlPoints(e);const s=e[3].sub(e[0]),n=s.length();if($.distance(e[0],e[1])+$.distance(e[2],e[1])+$.distance(e[2],e[3])-n>t)return!1;const i=t;let r=e[1].clone();r.subThis(e[0]);let o=Math.abs(r.crossProduct(s))/n;return!(o>i)&&(r=e[2].clone(),r.subThis(e[1]),o=Math.abs(r.crossProduct(s))/n,!(o>i))}copyIgnoreAttributes(t){const e=ut($,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return lo(this)}absNorm(){return Bo(this)}queryEnvelopeW(t,e){Fo(this,t,e)}setSegmentFromCoordsForStitcher(t,e){Go(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=ut($,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=ut($,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if($.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);$.sqrDistance(s,n)<=t&&(i||=!s.equals(n),s.setCoordsPoint2D(n))}return i},n=s(e[1],e[2],e[0]),i=s(e[2],e[1],e[3]);return(n||i)&&this.setControlPoints(e),n||i}needsSnapControlPoints(t){if(!t)return!1;const e=ut($,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if($.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);$.sqrDistance(s,n)<=t&&(i||=!s.equals(n),s.setCoordsPoint2D(n))}return i},n=s(e[1],e[2],e[0]),i=s(e[2],e[1],e[3]);return n||i}calculateSpecialPointsForCracking(t,e){return Ko(this,t,e)}ensureXYMonotone(){return co(this)}setCoordsForIntersector(t,e,s){so(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Jr(e,$r(this))}reverseImpl(){this.m_cp[1]=Q(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t,s=0,n=1;return!!this.m_cp[0].equals(e.m_cp[s])&&!!this.m_cp[1].equals(e.m_cp[n])}equalsImplTol(t,e){const s=t,n=0,i=1;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[n],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[i],e)}swapImpl(t){const e=t;e.m_cp[0]=Q(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=Q(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),eo(this,e)}afterCompletedModification(){to(this)}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return qo(this,t,e,s)}endPointModified(){to(this)}clearEndPointModified(){}}ra.type=e.enumBezier;class oa{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function aa(t,e,s,i,r,o,a,h){for(;;){const u=$.distance(e[0],e[2]),m=$.distance(e[0],e[1])+$.distance(e[1],e[2]);if(m-u<=r+i*m)return t+nt(u,m,.5);const l=ut($,4),c=t=>{Pa(e,s,1,t,l);return l[1].length()};if(0===a&&h<8){n(h<8);let u=c(0),l=c(1);o[0]+=2,u>l&&(l=Q(u,u=l),e[2]=Q(e[0],e[0]=e[2]),s[2]=Q(s[0],s[0]=s[2]));let g=u/(u+l),d=1,_=m;for(;g<1/32&&_>=r+i*_;){d/=4;const t=c(d);o[0]++,g=u/(t+u);const n=new $;if(ph(e,s,.5*d,n),_=$.distance(n,e[0]),_<=r){const t=new $;ph(e,s,d,t),_+=$.distance(t,n)}}if(1!==d){const n=ut($,3),u=[0,0,0];Qa(e,s,d,e,s,n,u),t=aa(t,n,u,i,r,o,0,h+1),a++,h++;continue}}let g=!1;const d=8;o[0]+=d;const _=ur(d,c,0,1),p=16;o[0]+=p;const f=ur(p,c,0,1);if(g=Math.abs(_-f)>r+i*m,!g)return t+f;if(a<8&&h<9){const n=ut($,3),u=[0,0,0];Qa(e,s,.5,e,s,n,u),t=aa(t,n,u,i,r,o,a+1,h+1),a++,h++;continue}const P=32;o[0]+=P;const y=ur(P,c,0,1);if(g=Math.abs(f-y)>r+i*m,!g)return t+y;const x=64;o[0]+=x;const C=ur(x,c,0,1);if(g=Math.abs(y-C)>r+i*m,!g)return t+C;const v=128;o[0]+=v;const b=ur(v,c,0,1);return g=Math.abs(C-b)>r+i*m,t+b}}function ha(t,e,s,n,i){if(s===e)return 0;const r=ut($,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=ut($,3);Ka(r,o,e,s,h,a);return aa(0,h,a,n,i,[0],0,0)}class ua{constructor(t,e,s){this.controlPoints=mt(t,3),this.weights=[0,0,0],st(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new $;ph(this.controlPoints,this.weights,e,t);const s=ut($,4);Pa(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new $;ph(this.controlPoints,this.weights,e,t);const s=ut($,4);Pa(this.controlPoints,this.weights,2,e,s);return 2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new $;ph(this.controlPoints,this.weights,e,t);const s=ut($,4);Pa(this.controlPoints,this.weights,3,e,s);return 2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return n(0),0}}function ma(t,e,s,n){const i=ka(0,0,0,0,$.getNAN()),r=et(18,Number.NaN),o=ut($,3);t.queryControlPoints(o),o[2].subThis(e),o[1].subThis(e),o[0].subThis(e);const a=[0,0,0];t.queryWeights(a);const h=[1,Ph(a),1],u=xh(a,s),m=xh(a,n),l=en(new ua(o,h,new $(0,0)),U.construct(u,m),18,r);ph(o,h,u,i.pt),i.t=u,i.d=$.distance(i.pt,new $(0,0));const c=new $;ph(o,h,m,c);const g=$.distance(c,new $(0,0));g<i.d&&(i.d=g,i.t=m,i.pt.assign(c));for(let d=0;d<l;d++){ph(o,h,r[d],c);const t=$.distance(c,new $(0,0));t<i.d&&(i.d=t,i.t=yh(a,r[d]),i.pt.assign(c))}return i}function la(t,e,s,n,i){let r=!0;const o=ut($,4),a=$n(5,e,s,n,i,e=>{fa(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()});r=!1;const h=$n(5,e,s,n,i,e=>{fa(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()});return new $(a,h)}function ca(t){t.m_cachedValues=null}function ga(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function da(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new oa,s=ut($,3);t.queryControlPoints(s);const n=[0,0,0];return t.queryWeights(n),_a(s,n,e.specialPoints),Ra(t,e),e}function _a(t,e,s){if(0===e[1])return s.length=0,s.push(0),void s.push(1);const n=ut(rt,8);n[0].set(0);let i=1;{const s=new rt(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new rt(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new rt(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=ut(rt,2);let h=dn(o,r,s,new U(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)lt(a[t].value(),0,1)||(n[i]=a[t],i++)}{const s=new rt(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new rt(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new rt(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=ut(rt,2);let h=dn(o,r,s,new U(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)lt(a[t].value(),0,1)||(n[i]=a[t],i++)}if(n[i].set(1),i++,i>2){ft(n,0,i,(t,e)=>kt(t.value(),e.value()));let t=0,e=n[0].value(),s=1;for(let r=1;r<i;r++)n[r].eq(n[r-1])?(e+=n[r].value(),s++):(s>1&&(e/=s,n[t].set(e)),t++,n[t]=n[r],e=n[r].value(),s=1);t++,i=t}n[0].set(0),n[i-1].set(1),s.length=i;for(let r=0;r<i;r++)s[r]=n[r].value()}function pa(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+pa(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=da(t);if(n&&!Number.isNaN(i.length))return i.length;const r=qa(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let u=1,m=i.specialPointsCount();u<m;u++){const s=i.specialPoints[u];if(a+=ha(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function fa(t,e,s,n){const i=ut($,3);t.queryControlPoints(i);const r=[0,0,0];t.queryWeights(r),Pa(i,r,e,s,n)}function Pa(t,e,s,n,i){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=ut($,4);ya(r,o,s,n,a);for(let h=0;h<=s;h++)i[h].setCoords(a[h].x,a[h].y)}function ya(t,e,s,i,o){n(s>0);const a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThis(a[0]);a[0].setCoords(0,0)}const h=xa(a,e,0,i),u=va(e,0,i),m=h.divide(u);if(o[0].assign(m),0===s)return;const l=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],c=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],g=u*u,d=xa(c,l,0,i).mul(2).divide(g);if(o[1].assign(d),1===s)return;const _=va(e,1,i),p=2*u*_,f=xa(c,l,1,i).mul(2).sub(d.mul(p)).divide(g);if(o[2].assign(f),2===s)return;const P=xa(c,l,2,i).mul(2),y=2*(_*_+u*va(e,2,i)),x=P.sub(f.mul(p).mul(2)).sub(d.mul(y)).divide(g);o[3].assign(x),3!==s&&r("")}function xa(t,e,s,n){if(0===s){if(n<=.5){const s=new $;qt(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new $;qt(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new $;return qt(2,s,i,n,r),r}{const s=new $;Ft(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new $;Ft(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new $;return Ft(2,s,i,n,r),r}}if(1===s){const s=t[1].mul(e[1]),i=s.sub(t[0].mul(e[0])).mul(1-n).add(t[2].mul(e[2]).sub(s).mul(n));return i.mulThis(2),i}if(2===s){const s=t[1].mul(e[1]),n=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return n.mulThis(2),n}r("")}function Ca(t,e,s,n){if(n.toDouble()<=.5){const s=new be;Vt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new be;Vt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new be;return Vt(2,s,i,n,r),r}{const s=new be;Lt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new be;Lt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new be;return Lt(2,s,i,n,r),r}}function va(t,e,s){if(0===e){const e=nt(t[0],t[1],s),n=nt(t[1],t[2],s);return nt(e,n,s)}if(1===e){return 2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s)}if(2===e){return 2*(t[2]-t[1]-(t[1]-t[0]))}r("")}function ba(t,e,s){if(s.toDouble()<=.5){const e=Ot(t[0],t[1],s),n=Ot(t[1],t[2],s);return Ot(e,n,s)}{const e=Qt(t[0],t[1],s),n=Qt(t[1],t[2],s);return Qt(e,n,s)}}function Sa(t,e,s,n,i){const r=[be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),be.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);Ea(r,[new rt(e[0]),new rt(e[1]),new rt(e[2])],s,n,i)}function Ea(t,e,s,i,r){n(s>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThisE(o[0]);o[0]=be.constructCoords(0,0)}const a=Ca(o,e,0,i),h=ba(e,0,i),u=a.divE(h);r[0].setE(u);const m=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],l=Ca([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],m,0,i).mul(2),c=h.sqr(),g=l.divE(c);r[1].setE(g)}function Da(t,e,s){const n=ut($,3);t.queryControlPoints(n);const i=et(3,Number.NaN);t.queryWeights(i),wa(n,i,e,s)}function wa(t,e,s,n){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const i=ut(be,4);Sa(t,e,1,s,i),n.setE(i[1])}function Aa(t,e,s){const n=gt(s,0,1),i=ut($,4);if(Pa(t,e,3,n,i),i[1].isZero()){if(i[2].isZero())return i[3];{const t=i[2].clone();return 1===n&&t.negateThis(),t}}return i[1]}class Ta{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-pa(this.b,e,!1):0}getError(t){return n(0),0}}function Ia(t,e,s){const n=pa(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==en(new Ta(t,e),U.unit(),1,i)&&r(""),i[0]}function Ma(t){const e=ut($,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Ya(e,s)}function Ya(t,e){const s=Ph(e);if(1===s){return Pi(t)}if(0===s)return 0;const i=[new $(0,0),t[1].sub(t[0]),t[2].sub(t[0])],r=i[1].crossProduct(i[2]);if(s<1){n(s>0);const t=1-s;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const n=t*(1+s),i=Math.atan2(Math.sqrt(t),Math.sqrt(1+s));e=s*(.5*s-ue(n)*i)/n}return r*e}{const t=(s-1)*(s+1);return.25*s/Math.pow(t,1.5)*(-2*s*Math.sqrt(t)*r-4*i[1].y*i[2].x*Math.atanh(Math.sqrt((s-1)/(s+1)))-i[1].x*i[2].y*Math.log(2*s*(s-Math.sqrt(t))-1))}}function Na(t,e){const s=Ph(e);if(1===s){const e=ut($,3);Bi(t,e);const s=e[2].clone(),n=e[1].clone(),i=new $,r=s.y*n.x-s.x*n.y;return i.x=-(4*s.x+5*n.x)*r/60,i.y=-(4*s.y+5*n.y)*r/60,i}if(0===s)return new $(0,0);n(s>0);const i=t[1].sub(t[0]),r=t[2].sub(t[0]);if(s<1){const t=Math.sqrt(1-s),e=Math.sqrt(1+s),n=(i.y*r.x-i.x*r.y)*s/Math.pow(t*e,5)/12,o=Math.atan2(t,e),a=s*t*e,h=s*s,u=i.mul(2*(2+h)),m=r.mul(2*h-5),l=u.add(m).mul(a),c=r.sub(i.mul(2*h)).mul(6*o);return l.add(c).mul(n)}{const t=Math.sqrt(s-1),e=Math.sqrt(s+1),n=(i.y*r.x-i.x*r.y)*s/Math.pow(t*e,5)/12,o=Math.atanh(t/e),a=s*t*e,h=s*s,u=i.mul(4).sub(r.mul(5)),m=i.add(r).mul(2*h),l=u.add(m).mul(a),c=r.sub(i.mul(2*h)).mul(6*o);return l.add(c).mul(n)}}function Xa(t){const e=ut($,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Na(e,s)}function qa(t){return Fa(t.calculateUpperLength2D())}function Fa(t){return 256*ct()*t}function Va(t){if(0===t.m_weights[1])return!0;const e=$.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function La(t){return t.m_cachedValues}function Ra(t,e){t.m_cachedValues=e}function za(t,e,s,n,i){const r=ut($,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===Ba(r,o,e,U.unit(),n,i,1,a)?a[0]:Number.NaN}function Ba(t,e,s,i,r,o,a,h){_(U.unit().contains(i)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const u=new Array(3);for(let n=0;n<3;++n)u[n]=t[n].sub(s);const m=Ph(e),l=Ee.constructPoint2D(u[0]),c=Ee.constructPoint2D(u[1]),g=Ee.constructPoint2D(u[2]),d=tt.constructDouble(m),p=d.clone();p.ldexpThis(1);const f=l.dotProduct(c.sub(l)).mul(d),P=d.mul(d.addDouble(2)),y=g.sub(c.mul(P.ldexp(1))),x=c.sqrLength().mul(d.mul(d).ldexp(1)).add(l.sqrLength().mul(d.ldexp(2).subDouble(1))).add(l.dotProduct(y)),C=g.sub(c.mul(p)).add(l.mul(p.subDouble(1))),v=c.mul(d).sub(l).dotProduct(C).mulDouble(3),b=c.dotProduct(g).mul(d.subDouble(3).mul(d)).ldexp(1),S=c.sqrLength().mul(d.mul(d).ldexp(2)),E=l.sqrLength().mul(d.ldexp(2).subDouble(3)),D=l.dotProduct(g.sub(c.mul(d.mulDouble(3).subDouble(1)).mul(d))).ldexp(1),w=g.sqrLength().addThis(b).addThis(S).addThis(E).addThis(D),A=l.add(g).sub(c.mul(p)),T=d.subDouble(1),I=g.sub(l).dotProduct(A).mul(T),M=new $(0,0),Y=[];let N=new $;ph(u,e,i.vmin,N);let X=$.distance(N,M);if(X<=o&&Y.push(new $(i.vmin,X)),i.vmin!==i.vmax&&(ph(u,e,i.vmax,N),X=$.distance(N,M),X<=o&&Y.push(new $(i.vmax,X))),i.width()>0){const t=u[2].isZero(),s=ut(tt,4),n=zn(I,w,v,x,f,58,i,t,s);for(let r=0;r<n;r++){if(!i.containsExclusiveCoordinate(s[r].toDouble()))continue;let t=s[r].toDouble();t=yh(e,t);const n=new $;ph(u,e,t,n),X=$.distance(n,M),X<=o&&Y.push(new $(t,X))}}if(r){n(i.equals(U.unit()));{ph(u,e,-1,N,!0);const t=new $;ph(u,e,0,t);const s=new fm({start:N,end:t}),n=s.getClosestCoordinate(M,!0);n<1&&(N=s.getCoord2D(n),X=$.distance(N,M),X<=o&&Y.push(new $(n-1,X)))}{ph(u,e,2,N,!0);const t=new $;ph(u,e,i.vmax,t);const s=new fm({start:t,end:N}),n=s.getClosestCoordinate(M,!0);n>0&&(N=s.getCoord2D(n),X=$.distance(N,M),X<=o&&Y.push(new $(1+n,X)))}}if(!Y.length)return 0;Y.sort((t,e)=>t.compare(e));let q=0;const F=Y[0].x;if(h[q++]=F,q<a){const t=H(u,4,!1).total(),e=Y[0].y;for(let s=1,n=Y.length;s<n;s++)if(Y[s].y>e+t){Y.length=s;break}Y.sort((t,e)=>kt(t.x,e.x)),q=0,h[q++]=Y[0].x;for(let s=1,n=Y.length;s<n;s++)Y[s].x!==h[q-1]&&q<a&&(h[q++]=Y[s].x)}return q}function ka(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function Ga(t,e,s,i,r){const o=new fe;if(Wa(t,U.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=da(t);let h=0;const u=[];let m=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const s=a.specialPoints[l],i=ma(t,e,m,s);if(0===u.length)u.push(i);else if(i.t===i.tmin)n(u.at(-1).d<=i.d),u.at(-1).tmax=i.tmax;else if(u.at(-1).t===u.at(-1).tmax){n(u.at(-1).d>=i.d);const t=u.at(-1).tmin;u[u.length-1]=i,u.at(-1).tmin=t}else u.push(i);m=s}for(const n of u)if(n.d<=i){const t=n.t;s?(s[h]=t,h++):h++}return h}function Wa(t,e,s){const n=ut($,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i),ja(n,i,e,s)}function ja(t,e,s,n){if(s.equalsRange(0,1))return void n.setFromPoints(t,3);const i=ut($,3),r=[0,0,0];Ka(t,e,s.vmin,s.vmax,i,r),n.setFromPoints(i,3)}function Za(t){const e=J(t[0].y,t[1].y),s=J(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=J(t[0].x,t[1].x),s=J(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function Ha(t){const e=ut($,3);t.queryControlPoints(e);const s=Ua(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ua(t){let e=!1;for(let s=0;s<2;s++){const n=J(t[0][s],t[2][s]);n>0?(J(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),J(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?(J(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),J(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Oa(e,s,n){void 0===n&&(n=s,s=0);const i=new $;if(s<0||n>1)return i.setNAN(),i;if(s>n&&t("calculate_sub_weighted_centroid"),s===n||e.isDegenerate(0))return i.setCoords(0,0),i;const r=da(e),o=qa(e),a=o/e.calculateUpperLength2D();let h=s,u=0;for(let t=1,m=r.specialPointsCount();t<m;t++)if(s<r.specialPoints[t]){u=t-1;break}i.setCoords(0,0);for(let t=u+1,m=r.specialPointsCount();t<m;t++){const s=Math.min(r.specialPoints[t],n),u=la(e,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[t])break}return i.add(e.getStartXY().mul(e.calculateLength2D()))}function Qa(t,e,s,i,r,o,a){n(s>=0&&s<=1&&i!==o&&r!==a),n(e[0]>0&&e[2]>0&&e[1]>=0);const h=[1,Ph(e),1],u=xh(e,s),m=mt(t,3),l=ut(E,3);mh(m,h,l);const c=ut(E,3),g=ut(E,3);Ch(l,u,i?c:null,o?g:null),vh(e,s,r,a);const d=Za(m);if(i){for(let t=0;t<3;++t)_h(c[t],i[t]);Sh(m,i),d&&Ua(i)}if(o){for(let t=0;t<3;++t)_h(g[t],o[t]);Sh(m,o),d&&Ua(o)}}function Ka(t,e,s,i,r,o){if(n(s>=0&&i<=1&&s<=i),s===i){const n=new $,i=lh(t,e,s,n);return bh(t,n),r[0].assign(n),r[1].assign(n),r[2].assign(n),o[0]=i,o[1]=i,void(o[2]=i)}if(0===s&&1===i)return r[0].assign(t[0]),r[1].assign(t[1]),r[2].assign(t[2]),o[0]=e[0],o[1]=e[1],void(o[2]=e[2]);const a=ut(E,3);{const n=[1,Ph(e),1],r=xh(e,s),o=xh(e,i);mh(t,n,a),Ch(a,o,a,null);Ch(a,r>=o?1:r/o,null,a)}const h=[0,0,0];vh(e,i,h,null),vh(h,s/i,null,h);const u=Za(t),m=ut($,3);_h(a[1],m[1]),ph(t,e,s,m[0]),ph(t,e,i,m[2]),Sh(t,m);for(let n=0;n<3;++n)r[n].assign(m[n]),o[n]=h[n];u&&Ua(r)}function $a(t,e,s){const n=Ph(e),i=[1,n,1],r=4*n/(3*(1+n));s[0].assign(t[0]),s[3].assign(t[2]),Ct(t[0],t[1],r,s[1]),Ct(t[2],t[1],r,s[2]),new ra({cp:s}),new Dn({points:t,weight:n});let o=0,a=.1,h=0;for(let u=0;u<9;u++,a+=.1){const e=new $;ph(t,i,a,e);const n=new $;yo(s,a,n);const r=$.sqrDistance(e,n);r>o&&(o=r,h=a)}{const e=new $;ph(t,i,h,e);const n=[0];Ro(s,e,U.unit(),!1,-1,1,n);const r=new $;return yo(s,n[0],r),o=$.sqrDistance(e,r),Math.sqrt(o)}}function Ja(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),r=new ce,o=ut($,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new $;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=ut($,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Ct(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&Ha(t)}function th(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==ih(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function eh(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==rh(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function sh(t,e,s,n,i){if(i){const n=hm(e,s);if(0!==n){if(t){if(1===n){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(Te(e,s))return 1;return 0!==oh(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function nh(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==ah(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function ih(t,e,s,i,r,o,a,h,u,m){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0],n=e.intersectPoint(s.getStartXY(),t,a);if(n>0){if(null!==r)for(let e=0;e<n;e++)r.push(t[e]);if(null!=o)for(let t=0;t<n;t++)o.push(0);if(null!=i)for(let s=0;s<n;s++){const n=new $;e.queryCoord2D(t[s],n),i.push(n)}}return n}const l=Qe(e,s);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new fm({start:e.getStartXY(),end:e.getEndXY()}),n=ws(t,s,i,r,o,a,h,m);if(r)for(let s=0;s<n;++s){const n=t.getCoord2D(r[s]);r[s]=e.getClosestCoordinate(n,!1)}return n}if(Ke(e,s,a))return 0;const c=ut($,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[1,Ph(g),1],_=s.getEndXY().sub(s.getStartXY()),p=_.clone();p.leftPerpendicularThis();const f=c[0].clone(),P=c[1].clone(),y=c[2].clone(),x=P.sub(f),C=y.sub(f),v=y.sub(P),b=d[0],S=d[1],E=d[2],D=b*S,w=b*E,A=S*E,T=x.dotProduct(p)*D,I=C.dotProduct(p)*w;let M=T,Y=I-2*T,N=v.dotProduct(p)*A+I-I;const X=et(13,Number.NaN),q=et(13,Number.NaN);let F=nn(N,Y,M,U.unit(),!1,X);F<0&&(X[0]=0,X[1]=1,F=2);let V=0;for(let n=0,k=V;n<F;++n){const t=new $;ph(c,d,X[n+k],t),q[V]=s.getClosestCoordinate(t,!1);$.distance(t,s.getCoord2D(q[V]))<=a&&(X[V]=X[n+k],V++)}const L=ut($,3),R=ut($,3);if(e.queryControlPoints(R),R[0].subThis(s.getStartXY()),R[1].subThis(s.getStartXY()),R[2].subThis(s.getStartXY()),hh(R,d,L,!1),Math.abs(_.x)>=Math.abs(_.y)){const t=_.y/_.x;N=L[2].y-L[2].x*t,Y=L[1].y-L[1].x*t,M=L[0].y-L[0].x*t}else{const t=_.x/_.y;N=L[2].x-L[2].y*t,Y=L[1].x-L[1].y*t,M=L[0].x-L[0].y*t}const z=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),B=[0,0];F=nn(N,Y,M,U.unit(),z,B);for(let n=0,k=V;n<F;++n){X[n+k]=B[n];const t=new $;ph(c,d,X[n+k],t),q[V]=s.getClosestCoordinate(t,!1);$.distance(t,s.getCoord2D(q[V]))<=a&&(X[V]=X[n+k],V++)}n(V<X.length+4);for(let n=0;n<V;n++)X[n]=yh(g,X[n]);F=e.intersectPoint(s.getStartXY(),B,a);for(let n=0;n<F;n++)X[V]=B[n],q[V++]=0;F=e.intersectPoint(s.getEndXY(),B,a);for(let n=0;n<F;n++)X[V]=B[n],q[V++]=1;F=s.intersectPoint(e.getStartXY(),B,a);for(let n=0;n<F;n++)q[V]=B[n],X[V++]=0;F=s.intersectPoint(e.getEndXY(),B,a);for(let n=0;n<F;n++)q[V]=B[n],X[V++]=1;return 0===V?0:gm(t,e,s,X,q,V,i,r,o,a,h,u,m)}function rh(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return ih(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Ke(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=ut($,4);{e.queryControlPoints(g);const t=ut($,4),n=new ce;s.canonicToWorldTransformation(n);const i=new ce;i.setInvert(n),i.transformPoints2D(g,4,t);const r=ut(tt,3),h=ut(tt,3),u=ut(tt,3),m=[0,0,0];e.queryWeights(m),uh(t,m,r,h,u);const d=ut(tt,3);d[0].setDouble(s.getSemiMinorAxis()),d[0].sqrThis(),d[1].setDouble(s.getSemiMajorAxis()),d[1].sqrThis(),d[2].setThis(d[0]),d[2].mulThis(d[1]),d[2].negateThis();const _=Fn(r,2,h,2,u,2,d,!0,U.unit(),U.unit(),l,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new $;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new $;s.queryCoord2D(r,a);$.distance(i,a)<=o&&(l[t]=l[n],c.push(r),t++)}l.length=t}}const d=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),n=za(e,t,U.unit(),!1,-1),i=new $;e.queryCoord2D(n,i);$.distance(t,i)<=o&&(l.push(n),c.push(d[_]))}for(let _=0;_<2;_++){const t=[0,3];{const e=s.getClosestCoordinate(g[t[_]],!1),n=new $;s.queryCoord2D(e,n);$.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return gm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function oh(t,e,s,i,r,o,a,h,u,m){const l=ut($,3);e.queryControlPoints(l);const c=ut($,3);if(s.queryControlPoints(c),$e(l,c,3)<0)return oh(t,s,e,i,o,r,a,h,u,!m);const g=Qe(e,s);if(e.isDegenerateToLineHelper(g)){const n=new fm({start:e.getStartXY(),end:e.getEndXY()}),l=ih(t,s,n,i,o,r,a,h,u,!m);if(r)for(let t=0;t<l;++t){const s=n.getCoord2D(r[t]);r[t]=e.getClosestCoordinate(s,!1)}return l}if(s.isDegenerateToLineHelper(g)){const n=new fm({start:s.getStartXY(),end:s.getEndXY()}),l=ih(t,e,n,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=n.getCoord2D(o[t]);o[t]=s.getClosestCoordinate(e,!1)}return l}if(Ke(e,s,a=Math.max(a,g)))return 0;const d=et(3,Number.NaN);e.queryWeights(d);const _=et(3,Number.NaN);s.queryWeights(_);const p=[1,Ph(d),1],f=[1,Ph(_),1],P=new U(0,1),y=new U(0,1);{const t=fe.constructEmpty();ja(l,p,new U(0,1),t);const e=fe.constructEmpty();ja(c,f,new U(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(fh(l,p,t,P),fh(c,f,t,y),P.isEmpty()||y.isEmpty())return 0;Ka(l,p,P.vmin,P.vmax,l,p),Ka(c,f,y.vmin,y.vmax,c,f)}}const x=_m(l,2,c,2,a);if(0===x)return 0;const C=[],v=[];if(-1===x){const t=ut(tt,3),e=ut(tt,3),s=ut(tt,3);uh(l,p,t,e,s);const n=ut(tt,3),i=ut(tt,3),r=ut(tt,3);uh(c,f,n,i,r);const o=[],g=[],d=Nn(t,2,e,2,s,2,n,2,i,2,r,2,!0,U.unit(),U.unit(),o,g,h,u,m);if(d>0)for(let h=0;h<d;h++){const t=new $;ph(c,f,g[h],t);const e=new $;ph(l,p,o[h],e);$.distance(e,t)<=a&&(C.push(o[h]),v.push(g[h]))}}for(let b=0;b<2;b++){let t,e,s;0===b?(t=l,e=c,s=f):(t=c,e=l,s=p);for(let i=0;i<2;i++){const r=0===i?0:t.length-1,o=new $,h=[0],u=Ba(e,s,t[r],U.unit(),!1,-1,1,h);n(1===u),ph(e,s,h[0],o),$.distance(t[r],o)<=a&&(0===b?(C.push(0===r?0:1),v.push(h[0])):(v.push(0===r?0:1),C.push(h[0])))}}if(0===C.length)return 0;if(!P.equalsRange(0,1))for(let n=0;n<C.length;++n)C[n]=Dn.recalculateParentT(P.vmin,P.vmax,C[n]);if(!y.equalsRange(0,1))for(let n=0;n<v.length;++n)v[n]=Dn.recalculateParentT(y.vmin,y.vmax,v[n]);for(let n=0;n<C.length;++n)C[n]=yh(d,C[n]);for(let n=0;n<v.length;++n)v[n]=yh(_,v[n]);return gm(t,e,s,C,v,C.length,i,r,o,a,h,u,m)}function ah(t,e,s,n,i,r,o,a,h,u){if(e.isLine()){return Li(t,s,new fm({start:e.getStartXY(),end:e.getEndXY()}),n,r,i,o,a,h,!u)}if(s.isLine()){return ih(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Ke(e,s,o=Math.max(o,m)))return 0;const l=ut($,3);e.queryControlPoints(l);const c=ut($,3);s.queryControlPoints(c);const g=_m(l,2,c,2,o);if(0===g)return 0;const d=[],_=[];if(-1===g){const t=ut(tt,3),n=ut(tt,3),i=ut(tt,3),r=[0,0,0];e.queryWeights(r),uh(l,r,t,n,i);const m=ut(Ee,3);ji(c,m);const g=Nn(t,2,n,2,i,2,[m[0].x,m[1].x,m[2].x],2,[m[0].y,m[1].y,m[2].y],2,null,0,!0,U.unit(),U.unit(),d,_,a,h,u);if(g>0){let t=0;for(let n=0;n<g;n++){const i=new $;s.queryCoord2D(_[n],i);const r=new $;e.queryCoord2D(d[n],r),$.distance(r,i)<=o&&(d[t]=d[n],_[t]=_[n],t++)}d.length=t,_.length=t}}for(let p=0;p<2;p++){let t;t=0===p?l:c;for(let n=0;n<2;n++){const i=0===n?0:t.length-1;let r;const a=new $;0===p?(r=vi(s,t[i],U.unit(),!1),s.queryCoord2D(r,a)):(r=za(e,t[i],U.unit(),!1,-1),e.queryCoord2D(r,a)),$.distance(t[i],a)<=o&&(0===p?(d.push(0===i?0:1),_.push(r)):(_.push(0===i?0:1),d.push(r)))}}return gm(t,e,s,d,_,d.length,n,i,r,o,a,h,u)}function hh(t,e,s,n=!1){const i=ut($,3);n?(i[0].setCoordsPoint2D(t[0]),i[1].setCoordsPoint2D(t[1]),i[1].subThis(i[0]),i[2].setCoordsPoint2D(t[2]),i[2].subThis(i[0]),i[0].setCoords(0,0)):(i[0].setCoordsPoint2D(t[0]),i[1].setCoordsPoint2D(t[1]),i[2].setCoordsPoint2D(t[2])),i[0].mulThis(e[0]),i[1].mulThis(e[1]),i[2].mulThis(e[2]),s[1].setCoords(i[1].x-i[0].x,i[1].y-i[0].y),s[2].setCoordsPoint2D(i[2].sub(i[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(i[0])}function uh(t,e,s,n,i){const r=tt.constructDouble(e[0]),o=tt.constructDouble(e[1]),a=tt.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(r),s[1].setDouble(t[1].x),s[1].mulThis(o),s[2].setDouble(t[2].x),s[2].mulThis(a),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),n[0].setDouble(t[0].y),n[0].mulThis(r),n[1].setDouble(t[1].y),n[1].mulThis(o),n[2].setDouble(t[2].y),n[2].mulThis(a),n[2].subThis(n[1]),n[1].subThis(n[0]),n[2].subThis(n[1]),n[1].ldexpThis(1),i[0].setDouble(e[0]),i[1].setDouble(e[1]),i[2].setThis(i[1]),i[2].ldexpThis(1),i[2].negateThis(),i[2].addThis(i[0]),i[2].addDoubleThis(e[2]),i[1].subThis(i[0]),i[1].ldexpThis(1)}function mh(t,e,s){for(let n=0;n<3;++n)s[n].setCoordsPoint2DZ(t[n].mul(e[n]),e[n])}function lh(t,e,s,n){if(0===s)return n.assign(t[0]),e[0];if(1===s)return n.assign(t[2]),e[2];const i=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],r=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],o=[e[0],e[1],e[2]],a=s;let h,u,m;if(s<=.5){const t=St(i[0],i[1],a),e=St(i[1],i[2],a);h=nt(t,e,a);const s=St(r[0],r[1],a),n=St(r[1],r[2],a);u=nt(s,n,a);const l=St(o[0],o[1],a),c=St(o[1],o[2],a);m=St(l,c,a)}else{const t=Et(i[0],i[1],a),e=Et(i[1],i[2],a);h=Et(t,e,a);const s=Et(r[0],r[1],a),n=Et(r[1],r[2],a);u=Et(s,n,a);const l=Et(o[0],o[1],a),c=Et(o[1],o[2],a);m=Et(l,c,a)}return h/=m,u/=m,n.setCoords(h,u),bh(t,n),m}function ch(t,e,s){const n=ut($,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i);gh([be.constructPoint2D(n[0]),be.constructPoint2D(n[1]),be.constructPoint2D(n[2])],[new rt(i[0]),new rt(i[1]),new rt(i[2])],e,s)}function gh(t,e,s,n){if(0===s.value())return void n.setE(t[0]);if(1===s.value())return void n.setE(t[2]);const i=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],r=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],o=[e[0].clone(),e[1].clone(),e[2].clone()],a=new rt,h=new rt,u=new rt;if(s.value()<=.5){const t=Ot(i[0],i[1],s),e=Ot(i[1],i[2],s);a.setE(Ot(t,e,s));const n=Ot(r[0],r[1],s),m=Ot(r[1],r[2],s);h.setE(Ot(n,m,s));const l=Ot(o[0],o[1],s),c=Ot(o[1],o[2],s);u.setE(Ot(l,c,s))}else{const t=Qt(i[0],i[1],s),e=Qt(i[1],i[2],s);a.setE(Qt(t,e,s));const n=Qt(r[0],r[1],s),m=Qt(r[1],r[2],s);h.setE(Qt(n,m,s));const l=Qt(o[0],o[1],s),c=Qt(o[1],o[2],s);u.setE(Qt(l,c,s))}a.divThisE(u),h.divThisE(u);const m=new $(a.value(),h.value());bh([t[0].value(),t[1].value(),t[2].value()],m),n.x.set(m.x,a.eps()),n.y.set(m.y,h.eps())}function dh(t,e,s,n){const i=s.lte(zt)?tt.lerpLo:tt.lerpHi,[r,o,a]=[e.map((e,s)=>t[s].x.mul(e)),e.map((e,s)=>t[s].y.mul(e)),e].map(([t,e,n])=>i(i(t,e,s),i(e,n,s),s)),h=new $(r.divThis(a).value(),o.divThis(a).value());bh(t.map(t=>t.asPoint2D()),h),n.x=tt.constructDouble(h.x),n.y=tt.constructDouble(h.y)}function _h(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function ph(t,e,s,n,i){if(i){if(s<0){return void ps(new fm({start:t[0],end:t[0].add(Aa(t,e,0).getUnitVector())}),s,n)}if(s>1){return void ps(new fm({start:t[2],end:t[2].add(Aa(t,e,1).getUnitVector())}),s-1,n)}}lh(t,e,s,n)}function fh(t,e,s,n){n.setEmpty();const i=[];i.push(new U(0,1));const r=.5*Math.max(s.width(),s.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new fe;if(ja(t,e,o,a),a.isIntersectingW(s)){const t=Math.max(a.width(),a.height());if(s.containsW(a)||t<=r||o.width()<1e-12)n.merge(o);else{const t=o.getCenter();i.push(U.construct(o.vmin,t)),i.push(U.construct(t,o.vmax))}}}}function Ph(t){return t[1]/Math.sqrt(t[0]*t[2])}function yh(t,e){const s=Math.sqrt(t[2]/t[0]);return e/nt(s,1,e)}function xh(t,e){const s=Math.sqrt(t[0]/t[2]);return e/nt(s,1,e)}function Ch(t,e,s,i){n(e>=0&&e<=1);(new E).setCoordsPoint3D(t[0]);(new E).setCoordsPoint3D(t[1]);(new E).setCoordsPoint3D(t[2]);const r=new E,o=new E,a=new E;wt(3,t[0],t[1],e,r),wt(3,t[1],t[2],e,o),wt(3,r,o,e,a);const h=t[2].clone();s&&(s[0].assign(t[0]),s[1].assign(r),s[2].assign(a)),i&&(i[0].assign(a),i[1].assign(o),i[2].assign(h))}function vh(t,e,s,i){const r=[t[0],t[1],t[2]];n(e>=0&&e<=1&&s!==i);const o=nt(r[0],r[1],e),a=nt(r[1],r[2],e),h=nt(o,a,e);s&&(s[0]=r[0],s[1]=o,s[2]=h),i&&(i[0]=h,i[1]=a,i[2]=r[2])}function bh(t,e){const s=U.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=gt(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=gt(e.y,s.vmin,s.vmax)}function Sh(t,e){const s=new U;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=gt(e[0].x,s.vmin,s.vmax),e[1].x=gt(e[1].x,s.vmin,s.vmax),e[2].x=gt(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=gt(e[0].y,s.vmin,s.vmax),e[1].y=gt(e[1].y,s.vmin,s.vmax),e[2].y=gt(e[2].y,s.vmin,s.vmax)}const Eh=Jt/180,Dh=180/Jt;function wh(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=Kt(e,360),e<0&&(e+=360),e)}function Ah(t){let e=t;return e=wh(e),e>180&&(e-=360),e}function Th(t){return t*Eh}function Ih(t){return t*Dh}function Mh(t){const e=Gt();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=Kt(s,e),s<0&&(s+=e),s)}function Yh(t){const e=At();let s=t;return s>-e&&s<=e||(s=Mh(s),s>e&&(s-=Gt())),s}function Nh(t,e){return Ah(e-t)}var Xh=b;class qh extends ds{constructor(t){if(void 0===t||bt(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new $(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new $(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new $(0,0),this.m_interior=new $(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new $(0,0),this.m_interior=new $(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new $(0,0),this.m_interior=new $(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return Js(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const n=$.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,n,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const n=$.lerp(t,e,.5);return this.constructCircleCenterAndPoint(n,t,s),this}constructLineEllipticArc(t,e){return Su(this,t,e,1),this}constructLineCircularArc(t,e){return Su(this,t,e,0),this}constructEllipse(t,e,s,n,i=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const r=new $(0,this.m_minorMajorRatio*this.m_semiMajorAxis),o=Math.cos(n),a=Math.sin(n);return r.rotateDirect(o,a),r.addThis(s),this.constructEllipticArcEndPointsCenter(r,r,this.m_semiMajorAxis,this.m_minorMajorRatio,n,!0,i,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new ce;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new ce;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return Zu(this,t,e,s),this}constructThreePointCircle(t,e,s,n=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const i=t.clone(),r=e.clone(),o=s.clone();return i.equals(r)&&r.assign(o),this.constructTwoPointCircle(i,r,n)}{const i=$.calculateCircleCenterFromThreePoints(t,e,s);if(!i.isFinite()||!Number.isFinite($.distance(t,i))){const n=$.distance(t,e),i=$.distance(t,s);this.constructLineCircularArc(t,n>=i?e:s)}return this.constructCircleCenterAndPoint(i,t,n)}}constructCircularArcThreePoint(t,e,s){const n=new rt(t.x),i=new rt(e.x),r=new rt(s.x),o=new rt(t.y),a=new rt(e.y),h=new rt(s.y),u=new rt(.5),m=i.subE(n),l=a.subE(o),c=r.subE(n),g=h.subE(o),d=m.mulE(g).subThisE(l.mulE(c));if(d.scaleError(10),d.isZero()){if(!m.isZero()||!l.isZero())return Su(this,t,e,0),this;{const n=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),i=s.sub(n).length();this.constructEllipticArcEndPointsCenter(t,e,i,1,0,!0,!1,n),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const _=m.sqr().addThisE(l.sqr()).mulThisE(u),p=c.sqr().addThisE(g.sqr()).mulThisE(u),f=_.mulE(g).subThisE(p.mulE(l)),P=m.mulE(p).subThisE(c.mulE(_));f.divThisE(d),P.divThisE(d);const y=f.sqr().addThisE(P.sqr());y.sqrtThis();const x=f.addE(n),C=P.addE(o);let v=t.x-x.value(),b=t.y-C.value();const S=Math.atan2(b,v);v=e.x-x.value(),b=e.y-C.value();const E=Math.atan2(b,v);v=s.x-x.value(),b=s.y-C.value();const D=Math.atan2(b,v);let w=D-2*At();for(;w<S;)w+=2*At();let A=E-2*At();for(;A<w;)A+=2*At();let T=D+2*At();for(;T>S;)T-=2*At();let I,M=E+2*At();for(;M>T;)M-=2*At();I=A-S<S-M?A-S:M-S;const Y=new $(x.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(I)>At(),I>0,Y),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,n){return this.constructEllipticArcGeneral(t,1,e,s,n,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,n,i,r,o){return bu(this,t,e,s,n,i,r,o)}constructEllipticArcEndPointsCenter(t,e,s,n,i,r,o,a){return bu(this,t,e,s,n,i,r,o,a)}constructEllipticArcGeneral(t,e,s,n,i,r){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=Yh(r),a=Math.cos(o),h=Math.sin(o),u=new $(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),m=$.getNAN(),l=Yh(n);m.x=u.x*Math.cos(l),m.y=u.y*Math.sin(l),m.rotateDirect(a,h),m.addThis(s);const c=Tt(i,Gt());let g=c;Math.abs(g)===Gt()&&(g=0);const d=$.getNAN();return d.x=u.x*Math.cos(l+g),d.y=u.y*Math.sin(l+g),d.rotateDirect(a,h),d.addThis(s),this.constructEllipticArcEndPointsCenter(m,d,this.m_semiMajorAxis,this.m_minorMajorRatio,o,Math.abs(c)>At(),c>0,s)}constructEllipticArcAsNURB(e,s,n,i){(i>=1||i<0)&&t("construct_elliptic_arc_as_NURB: weight"),s.isFinite()||t("construct_elliptic_arc_as_NURB: control_point");return Gu([e,s,n],i*i,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,Uu(this),this.afterCompletedModification(),t!==this&&He(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){if(this.isLine())return!0;if(this.isMajor())return!1;const e=this.getEndXY().sub(this.getStartXY()).length();return!(this.calculateLength2D()-e>t)}isDegenerateToLine(){return Eu(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return $.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!qu(this)}isMajor(){return Vu(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return e.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=le.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const e=this.m_description.getSemantics(s);for(let n=0,i=Xh.getComponentCount(e);s<i;s++){const s=this.queryInterval(e,n);t.setIntervalEnvelope(e,n,s)}}}else 2===t.m_EnvelopeType?Ju(this,U.unit(),t):s("3d not impl")}applyTransformation(t){Tu(this,t,!1,null,null)}createInstance(){return new qh}calculateLength2D(){return fu(this,0,1)}queryControlPointsHelper(t){r("")}queryCoord2D(t,e){if(Eu(this))fs(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign($.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign($.construct(this.m_XEnd,this.m_YEnd));else{const s=gu(this,t),n=new $(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));n.rotateDirect(this.m_cosr,this.m_sinr),n.addThis(this.m_center),e.assign(n)}}queryCoord2DE(t,e){iu(this,t,e)}queryCoord2DMP(t,e){s("")}getCoordX(t){const e=new $;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new $;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createEllipticArc();n&&i.dropAllAttributes();let r=0===t&&1===e;if(r&&!n)return void this.copyTo(i);const o=$.getNAN();this.queryCoord2D(t,o);const a=$.getNAN();if(this.queryCoord2D(e,a),!r)if(o.equals(a))e-t>.5&&this.isMajor()&&this.isClosed()?(r=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&o.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&a.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),r=0===t&&1===e,r&&!n)return void this.copyTo(i);if(i.m_center.assign(this.m_center),i.m_semiMajorAxis=this.m_semiMajorAxis,i.m_minorMajorRatio=this.m_minorMajorRatio,i.m_interior.assign(this.m_interior),i.m_rotation=this.m_rotation,i.m_cosr=this.m_cosr,i.m_sinr=this.m_sinr,i.m_sweepAngle=this.m_sweepAngle,i.m_startAngle=this.m_startAngle,i.m_bits=this.m_bits,Fe(i,o.x,o.y),Le(i,a.x,a.y),r)return void Mu(i,Pu(this));i.m_startAngle=gu(this,t),i.m_sweepAngle=gu(this,e)-i.m_startAngle,i.m_startAngle=hu(i.m_startAngle),Fu(i,Math.abs(i.m_sweepAngle)>At()),n&&i.assignVertexDescription(this.m_description),Uu(i),lu(i);const h=this.m_description.getAttributeCount();if(h>1&&!n){for(let e=1;e<h;e++){const s=this.m_description.getSemantics(e),n=Xh.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<h;t++){const s=this.m_description.getSemantics(t),n=Xh.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}i.afterCompletedModification()}queryDerivative(t,e){nm(this,t,e)}cutArcIgnoreAttributes(t,e,s){let n=0===t&&1===e;const i=new $;this.queryCoord2D(t,i);const r=new $;this.queryCoord2D(e,r),n||(i.equals(r)?e-t>.5&&this.isMajor()&&this.isClosed()?(n=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&i.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&r.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),n=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,Fe(s,i.x,i.y),Le(s,r.x,r.y),n?Mu(s,Pu(this)):(s.m_startAngle=gu(this,t),s.m_sweepAngle=gu(this,e)-s.m_startAngle,s.m_startAngle=hu(s.m_startAngle),Fu(s,Math.abs(s.m_sweepAngle)>Math.PI),Uu(s),s.afterCompletedModification())}changeEndPoints2D(t,e){xu(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,r=Xh.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return vt(r,o,a,i,Xh.getDefaultValue(e))}getClosestCoordinate(t,e){return tm(this,t,U.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return tm(this,t,e,!1)}getYMonotonicParts(e,s=!1){e.length<2&&t("");const i=this.getSemiAxes(),r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),o=r+At(),a=et(3,Number.NaN);let h=0;if(a[0]=cu(this,r),a[0]>0&&a[0]<1&&h++,a[1]=cu(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,n(e.length>=h);let u=0;for(let t=0;t<h;t++){const n=a[t];this.queryCut(u,n,e[t],s),u=n}return h}getMonotonicParts(e,s){if(e.length<4&&t(""),this.isDegenerateToLine())return e[0].createEllipticArc().assignCopy(this),s&&e[0].get().dropAllAttributes(),1;const i=this.getSemiAxes(),r=et(4,Number.NaN);r[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r[1]=r[0]+At(),r[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),r[3]=r[2]+At();const o=et(5,Number.NaN);let a=0;for(let t=0;t<4;t++)o[a]=cu(this,r[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;Dt(o,a),o[a-1]<1&&(o[a]=1,a++),n(e.length>=a);let h=0;for(let t=0;t<a;t++){const n=o[t];this.queryCut(h,n,e[t],s),h=n}return a}intersectionWithAxis2D(t,e,s,n){if(Eu(this)){return new fm({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,n)}let i,r;const o=new rt(e),a=this.getSemiAxes();if(t){if(e>this.m_center.y+a.x||e<this.m_center.y-a.x)return 0;i=new rt(a.x).mulThis(this.m_sinr),r=new rt(a.y).mulThis(this.m_cosr),o.subThis(this.m_center.y)}else{if(e>this.m_center.x+a.x||e<this.m_center.x-a.x)return 0;i=new rt(a.x).mulThis(this.m_cosr),r=new rt(a.y).mulThis(-this.m_sinr),o.subThis(this.m_center.x)}const h=i.sqr(),u=r.sqr(),m=h.addE(u),l=r.mulE(o).mulThis(-2),c=o.sqr().subThisE(h),g=l.sqr().subThisE(m.mulE(c).mulThis(4)),d=i.mulE(o).mulThis(-2),_=o.sqr().subThisE(u),p=d.sqr().subThisE(m.mulE(_).mulThis(4));let f=g.eps()*Math.abs(p.value())<=p.eps()*Math.abs(g.value());f?i.isZero()&&(f=!1):r.isZero()&&(f=!0),f||(l.setE(d),c.setE(_));const P=ut(rt,2);let y=dn(m,l,c,U.construct(-1,1),!1,P);if(0===y)return 0;const x=[0,0];let C=0;for(let v=0;v<y;v++){const t=new rt,e=new rt;f?(t.setE(P[v]),e.setE(o.subE(r.mulE(P[v])).divThisE(i))):(e.setE(P[v]),t.setE(o.subE(i.mulE(P[v])).divThisE(r)));const s=cu(this,Math.atan2(t.value(),e.value()));s>=0&&s<=1&&(x[C]=s,C++)}return y=C,0===y?0:(2===y&&x[0]>x[1]&&(x[1]=Q(x[0],x[0]=x[1])),n&&st(n,x,0,0,y),s&&(s[0]=t?this.getCoordX(x[0]):this.getCoordY(x[0]),y>1&&(s[1]=t?this.getCoordX(x[1]):this.getCoordY(x[1]),!n&&s[0]>s[1]&&(s[1]=Q(s[0],s[0]=s[1])))),y)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new U(0,1),t):s("3d not impl")}clone(t){const e=new qh;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Eu(this))return 0===e?U.construct(this.getStartX(),this.getEndX()):U.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const n=t+Math.PI,i=[0,0];i[0]=cu(this,t),i[1]=cu(this,n);const r=0===e?U.construct(this.getStartX(),this.getEndX()):U.construct(this.getStartY(),this.getEndY()),o=new $;for(let a=0;a<2;a++){const t=i[a];t>0&&t<1&&(this.queryCoord2D(t,o),r.mergeNeCoordinate(0===e?o.x:o.y))}return r}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new U(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(Eu(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const n=this.getCoord2D(s.vmin),i=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=It){let t=$.lerp(n,i,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*$.distance(n,i))),e.setCoords(n),e.mergeNe(i),void e.mergeNe(t)}Ju(this,s,e)}tToLength(t){return Eu(this)?t*$.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Du(this,t)}parametricAngleToT(t){return cu(this,t)}tToParametricAngle(t){return gu(this,t)}lengthToT(t){if(Eu(this)){const e=$.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return wu(this,t)}calculateWeightedAreaCentroid2D(t){if(Eu(this)){const t=new $;return t.setCoords(0,0),t}const e=Hu(this),s=this.getStartXY().sub(this.m_center),n=this.getEndXY().sub(this.m_center),i=this.m_semiMajorAxis,r=this.getSemiMinorAxis(),o=this.m_startAngle+this.m_sweepAngle,a=new $;a.x=i*r*(i*this.m_cosr*(-Math.sin(o)+Math.sin(this.m_startAngle))+r*(-Math.cos(o)+Math.cos(this.m_startAngle))*this.m_sinr)/3,a.y=i*r*(r*(Math.cos(o)-Math.cos(this.m_startAngle))*this.m_cosr+i*(-Math.sin(o)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const h=n.add(s).mul(n.crossProduct(s)/6);return a.x-=h.x,a.y-=h.y,a.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new $;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Eu(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const n=Math.sin(e),i=Math.sin(s),r=Math.cos(e),o=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,a=s*(i-n),h=s*(r-o);t.setCoords(a,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),a=e*e,h=s*s,u=e*s,m=a-h,l=m/h,c=m/a,g=Math.sqrt(l),d=Math.sqrt(c),_=.5*u*(Math.asinh(g*i)/g+i*Math.sqrt(1+l*i*i))-.5*u*(Math.asinh(g*n)/g+n*Math.sqrt(1+l*n*n)),p=-.5*u*(Math.asin(d*o)/d+o*Math.sqrt(1-c*o*o))- -.5*u*(Math.asin(d*r)/d+r*Math.sqrt(1-c*r*r));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Eu(this)){const s=$.distance(t,this.m_center),n=this.getSemiAxes();if(s<n.x-e||s>n.y+e)return!1}const n=this.getClosestCoordinate(t,!1),i=new $;this.queryCoord2D(n,i);return $.distance(i,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}getTangent(t){if(Eu(this))return this.getEndXY().sub(this.getStartXY());{const e=gu(this,t),s=new $;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(t){if(Eu(this))return this.getEndXY().sub(this.getStartXY());{const e=gu(this,t),s=new $;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}normalizeAfterEndpointChange(){return!!Ru(this)&&(Eu(this)?(zu(this),!1):Bu(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new $(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new $(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){const e=gu(this,t),s=new $,n=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),n*Math.cos(e));const i=new $;i.setCoords(-this.m_semiMajorAxis*Math.cos(e),-n*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),i.rotateDirect(this.m_cosr,this.m_sinr));const r=s.sqrLength();if(0===r)return Number.NaN;const o=Math.sqrt(r);s.divThis(o);return s.crossProduct(i)/r}getMonotonicPartParams(e,s){const n=et(6,Number.NaN);n[0]=0;let i=1;if(this.isDegenerateToLine())n[1]=1,i=2;else{const t=this.getSemiAxes(),e=et(4,Number.NaN);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=Mt());for(let s=0;s<4;s++){const t=cu(this,e[s]);t>0&&t<1&&(n[i]=t,i++)}i>2&&Dt(n,i),n[i]=1,i++}if(s){e<i&&t("");for(let t=0;t<i;t++)s[t]=n[t]}return i}calculateLowerLength2D(){const t=$.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=$.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Eu(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,Yu(t)}calculateArea2DHelper(){return Hu(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),Eu(this))return;const s=this.getSemiAxes(),n=et(8,Number.NaN);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,i=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=i+Math.PI;n[0]=cu(this,t),n[1]=cu(this,e),n[2]=cu(this,i),n[3]=cu(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,i=Math.atan2(-s.y*t,s.x*e),r=i+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;n[4]=cu(this,i),n[5]=cu(this,r),n[6]=cu(this,o),n[7]=cu(this,a)}const i=$.getNAN();for(let r=0;r<8;r++){const s=n[r];t.containsExclusiveCoordinate(s)&&(this.queryCoord2D(s,i),e.mergeNe(i))}}setSegmentFromCoordsForStitcher(t,e){Cu(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return r("should not1; be called"),0}ensureXYMonotone(){if(Eu(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return Su(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=ut($,3);let e=ku(this,t);if(Ua(t)){let s=!1;if(0===this.projectionBehavior()){const n=new le;n.setCoords({pt:t[0]}),n.mergeNe(t[2]);const i=new $;i.setSub(t[2],t[0]),i.leftPerpendicularThis(),i.normalize(),i.scale($.distance(t[2],t[0]));const r=$.lerp(t[2],t[0],.5),o=r.sub(i),a=r.add(i);n.clipLine(o,a);const h=$.getClosestCoordinate(o,a,t[1],!1);t[1]=$.lerp(o,a,h);const u=t[2].sub(t[1]),m=t[0].sub(t[1]),l=u.crossProduct(m),c=u.dotProduct(m);e=xt()-Math.abs(.5*Math.atan2(l,c)),s=!0}return Gu(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){xu(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,Mu(e,Pu(this))}reverseImpl(){Xu(this,!qu(this)),lu(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&Uu(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const n=e.m_startAngle;return this.m_startAngle===n}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const n=Math.abs(Th(Ah(Ih(this.m_rotation-s.m_rotation)))),i=Math.abs(At()-n),r=Math.min(n,i);if(this.m_semiMajorAxis*Math.abs(r)>e)return!1;const o=this.getCoord2D(.5),a=s.getCoord2D(.5);return!!o.isEqualPoint2D(a,e)}swapImpl(t){const e=t;this.m_center=Q(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=Q(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=Q(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=Q(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=Q(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=Q(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=Q(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=Q(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=Q(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=Q(e.m_bits,e.m_bits=this.m_bits),Nu(this,e)}afterCompletedModification(){zu(this),Yu(this)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){if(e.length<2&&i(""),Eu(this)){return new fm({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s)}{const e=$.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const n=this.getClosestCoordinate(t,!1),r=$.getNAN();return this.queryCoord2D(n,r),$.distance(r,t)<=s?lt(n,0,1)&&(this.queryCoord2D(0===n?1:0,r),$.distance(r,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,Yu(this)}clearEndPointModified(){zu(this)}}function Fh(t,e,s){t.isEmpty()&&o(""),f(t);const n=t.getImpl(),i=[];return Rh(n.getPointCount(),i),zh(Lh(n),i,n.getPointCount(),e)}function Vh(t,e,s,n){const i=[];return Rh(e,i),zh(t,i,e,s)}function Lh(t){return{at:e=>t.getXY(e)}}function Rh(t,e){e.length=t;for(let s=0;s<e.length;++s)e[s]=s;t>3&&is(t,e)}function zh(t,e,s,n,i){let r=0;const o=[0,0,0];let a=0;const h=3;let u=0;for(let m=0;m<h;++m){let i=!1;for(;u<s;){const s=t.at(e[u]);let l=1;if(3===r?l=$.inCircleRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]),s):2===r?l=$.inCircleRobust3Point(t.at(n[0]),t.at(n[1]),s):1===r&&s.equals(t.at(n[0]))&&(l=0),l<=0){if(l<0&&m+1<h){e[a]=Q(e[u],e[u]=e[a]);for(let t=0;t<r;t++)if(n[t]===e[u]){o[t]=u;break}a++}u++;continue}i=!0;let c=0;for(let t=0;t<r;t++)o[t]>u&&(n[c]=n[t],o[c]=o[t],c++);r=c,n[r]=e[u],o[r]=u,r++,r<3?u=a:(1===$.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=Q(n[0],n[0]=n[2]),o[2]=Q(o[0],o[0]=o[2])),u++)}if(!i)break;if(m+1<h){a=0;let s=!1;for(let t=0;t<r;t++)for(let e=t+1;e<r;e++)o[t]>o[e]&&(o[e]=Q(o[t],o[t]=o[e]),n[e]=Q(n[t],n[t]=n[e]),s=!0);for(let t=0;t<r;t++)e[o[t]]=Q(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===r&&1===$.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=Q(n[0],n[0]=n[2]),o[2]=Q(o[0],o[0]=o[2]))}u=r}return r}function Bh(t,e,s,n,i,r){return new Zh(0,0,0,null,!1,_t()).densifyEx(t,e,s,n,!1,r)}function kh(s,n,i,r){return Number.isFinite(n)||t("replace_all_curves_with_beziers: maxDeviation"),Qh(e.enumBezier,s,n,i)}function Gh(t,i,r,o,a,h,u,m){h&&(h.length=0),u&&(u.length=0);const l=t.getGeometryType();if(l===e.enumLine)return h&&(h.push(t.getStartXY()),h.push($.getNAN()),h.push($.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(l===e.enumBezier){if(!o)return h&&(h.push(t.getStartXY()),h.push(t.getControlPoint1()),h.push(t.getControlPoint2()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;const e=et(9,Number.NaN);let s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Hh(t,r,e),2===s&&a&&(e[1]=.5,e.push(1),s=3),u&&u.splice(0,0,...e.slice(0,s)),h){const n=new Pm;for(let i=1;i<s;i++){const s=e[i-1],r=e[i];t.queryCut(s,r,n,!0);const o=n.get();co(o),1===i&&h.push(o.getStartXY()),h.push(o.getControlPoint1()),h.push(o.getControlPoint2()),h.push(o.getEndXY())}}return s-1}if(l===e.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return h&&(h.push(t.getStartXY()),h.push($.getNAN()),h.push($.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(o&&(a||!e.isMonotoneQuickAndDirty())){const s=et(6,Number.NaN);let m=e.getMonotonicPartParams(s.length,s);s.length=m,m=Hh(t,r,s),2===m&&a&&(s[1]=.5,s.push(1),m=3);let l=0;if(m>2){const t=new Pm,a=u||[];let c=0;for(let g=1;g<m;g++){const d=s[c],_=s[g];if(e.queryCut(d,_,t,!0),t.get().isDegenerate(0))continue;const p=a.length,f=Kh(1===g,t.get(),i,r,o,h,u);n(f>0),l+=f;const P=g===m-1,y=s[c],x=t.get().getSweepAngle()/e.getSweepAngle();for(let t=p,s=a.length;t<s;t++)if(a[t]=!P||t+1<s?y+a[t]*x:1,h){const s=3*t,n=e.getCoord2D(a[t]);if(h[s].setCoordsPoint2D(n),s>0){go(h.slice(s-3))}}c=g}return l}}return Kh(!0,e,i,r,o,h,u)}if(l===e.enumRationalBezier2){const e=t;if(o&&(a||!e.isMonotoneQuickAndDirty())){const s=et(6,Number.NaN);let n=e.getMonotonicPartParams(s.length,s);s.length=n,n=Hh(t,r,s),2===n&&a&&(s[1]=.5,s.push(1),n=3);let o=0;if(n>2){const t=new Pm,a=u||[];for(let m=1;m<n;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=a.length;o+=Jh(1===m,t.get(),i,r,!1,h,u);const d=m===n-1,_=s[m-1];for(let t=g,s=a.length;t<s;t++)if(a[t]=!d||t+1<s?_+a[t]:1,h){const s=3*t,n=e.getCoord2D(a[t]);if(h[s].setCoordsPoint2D(n),s>0){Ti(h.slice(s-3))}}}return o}}return Jh(!0,e,i,r,o,h,u)}if(l===e.enumBezier2){const e=t,s=ut($,3);e.queryControlPoints(s);const n=new ra;n.constructFromQuadratic(s);const m=Gh(n,i,r,o,a,h,u);if(null!=h&&null!=u){const t=3;for(let s=1,n=0;s<m;++s,n+=t){const i=new $;e.queryCoord2D(u[s],i);const r=h[n+t];if(!i.equals(r)&&(h[n+t].setCoordsPoint2D(i),o)){go(h.slice(n,n+4))}}}return m}s("")}function Wh(t,n,i,r,o,a,h,u){a&&(a.length=0),h&&(h.length=0);const m=t.getGeometryType();if(m===e.enumLine)return a&&(a.push(t.getStartXY()),a.push($.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(m===e.enumBezier2){const e=et(9,Number.NaN);let s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Hh(t,i,e),h&&h.splice(0,0,...e.slice(0,s)),a){const n=new Pm;for(let i=1;i<s;i++){const s=e[i-1],r=e[i];t.queryCut(s,r,n,!0);const o=n.get();Ai(o),1===i&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getEndXY())}}return s-1}if(m===e.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push($.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(!e.isMonotoneQuickAndDirty()){const s=et(6,Number.NaN);let r=e.getMonotonicPartParams(s.length,s);s.length=r,r=Hh(t,i,s);let o=0;if(r>2){const t=new Pm,u=h||[];for(let m=1;m<r;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=u.length;o+=tu(1===m,t.get(),n,i,!1,a,h);const d=m===r-1,_=s[m-1],p=t.get().getSweepAngle()/e.getSweepAngle();for(let t=g,s=u.length;t<s;t++)if(u[t]=!d||t+1<s?_+u[t]*p:1,a){const s=2*t,n=e.getCoord2D(u[t]);if(a[s].setCoordsPoint2D(n),s>0){Ti(a.slice(s-2))}}}return o}}return Kh(!0,e,n,i,r,a,h)}if(m===e.enumBezier){const e=t;if(!e.isMonotoneQuickAndDirty()){const s=et(6,Number.NaN);let r=e.getMonotonicPartParams(s.length,s);s.length=r,r=Hh(t,i,s);let o=0;if(r>2){const t=new Pm,u=h||[];for(let m=1;m<r;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=u.length;o+=eu(1===m,t.get(),n,i,!1,a,h);const d=m===r-1,_=s[m-1];for(let t=g,s=u.length;t<s;t++)if(u[t]=!d||t+1<s?_+u[t]:1,a){const s=2*t,n=e.getCoord2D(u[t]);if(a[s].setCoordsPoint2D(n),s>0){Ti(a.slice(s-2))}}}return o}}return eu(!0,e,n,i,r,a,h)}if(m===e.enumRationalBezier2){const e=t;if(!e.isMonotoneQuickAndDirty()){const s=et(6,Number.NaN);let r=e.getMonotonicPartParams(s.length,s);s.length=r,r=Hh(t,i,s);let o=0;if(r>2){const t=new Pm,u=h||[];for(let m=1;m<r;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=u.length;o+=$h(1===m,t.get(),n,i,!1,a,h);const d=m===r-1,_=s[m-1];for(let t=g,s=u.length;t<s;t++)if(u[t]=!d||t+1<s?_+u[t]:1,a){const s=2*t,n=e.getCoord2D(u[t]);if(a[s].setCoordsPoint2D(n),s>0){Ti(a.slice(s-2))}}}return o}}return $h(!0,e,n,i,r,a,h)}s("")}function jh(t,s,i,r,o,a,h,u,m){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),u&&(u.length=0),l===e.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push($.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),u&&(u.push(0),u.push(1)),1}const c=et(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Hh(t,i,c);else{if(g=2,c[0]=0,c[1]=1,l===qh.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,g=4):(c[0]=0,c[1]=.5,c[2]=1,g=3)}}else n(l===Dn.type);c.length=g}if(2===g&&r&&(c[1]=.5,c.push(1),g=3),a){const s=new Pm;let n=1;for(;n<g;){const i=c[n-1],r=c[n];t.queryCut(i,r,s,!0);const u=ut($,3),m=[1,1,1];if(l===e.enumEllipticArc){const t=s.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(r-i)/3;c.splice(n,0,i+t),c.splice(n+1,0,i+2*t),g+=2;continue}m[1]=ku(t,u)}else{const t=s.get();t.queryControlPoints(u),t.queryWeights(m)}o&&Ua(u),1===n&&(a.push(u[0].clone()),h.push(m[0])),a.push(u[1].clone()),a.push(u[2].clone()),h.push(m[1]),h.push(m[2]),n++}}return u&&(u.length=g,st(u,c,0,0,g)),g-1}qh.type=e.enumEllipticArc;class Zh{static constructDefault(t){return new Zh(0,0,0,t,!1,_t())}constructor(t,e,s,n,i,r){this.m_segmentBuffer=null,this.m_dummyPoint=new F,this.m_progressCounter=0,this.m_progressTracker=n,this.m_bSetDensifyFlag=i,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>xt()?xt():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=r,_(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,n,i,r){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=n>xt()?xt():n,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=i,this.m_maxSegmentsPerCurve=r,_(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const s=t.getGeometryType();return p(s)?t:c(s)?this.densifyMultiPath(t):m(s)?this.densifySegmentImpl(t):s===e.enumEnvelope?this.densifyEnvelope(t):void r("")}densifySegmentEx(t,s,n,i,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==e.enumLine)&&(!i||n))return void(s?o===e.enumLine?s.addSegment(t,n):(n&&(t.queryStart(this.m_dummyPoint),s.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint)):(n&&r.push(0),r.push(1)));if(o===e.enumBezier)return void this.densifyCubicBezier(t,s,n,i,r);if(o===e.enumRationalBezier2)return void this.densifyRationalBezier2(t,s,n,i,r);if(o===e.enumBezier2)return void this.densifyBezier2(t,s,n,i,r);if(o===e.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,s,n,i,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,s,n,i,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const s=t.createInstance();if(s.getGeometryType()===e.enumPolygon){s.setFillRule(t.getFillRule())}s.reserve(t.getPointCount());const n=t.getImpl().querySegmentIterator();for(;n.nextPath();){let t=!0;for(;n.hasNextSegment();){const e=n.nextSegment(),i=n.isClosingSegment();this.densifySegmentEx(e,s,t,i,null),i&&s.closePathWithLine(),t=!1}}return s}densifySegmentImpl(t){const e=new Qs({vd:t.getDescription()}),s=[0];return this.densifySegmentEx(t,e,!0,!1,s),e}densifyEnvelope(t){const e=new mr({vd:t.getDescription()});e.addEnvelope(t,!1);const s=le.constructEmpty();t.queryEnvelope(s);const n=s.width(),i=s.height();return!(this.m_maxLength>0)||n<=this.m_maxLength&&i<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const s=t.createInstance();if(s.getGeometryType()===e.enumPolygon){s.setFillRule(t.getFillRule())}s.reserve(t.getPointCount());const n=s.getImpl(),i=t.getImpl(),r=i.getAttributeStreamRef(0),o=new fm;for(let e=0,a=i.getPathCount();e<a;e++){const t=i.isClosedPath(e);if(0===i.getPathSize(e))continue;const a=i.getPathStart(e),h=r.readPoint2D(2*a),u=h.clone();n.startPath(h);for(let m=a+1,l=i.getPathEnd(e);m<l;m++){const t=r.readPoint2D(2*m),e=$.distance(u,t);if(e>this.m_maxLength){let s=Math.ceil(e/this.m_maxLength);s>_t()&&(s=_t());const i=1/s;let r,a,h;u.compare(t)<0?(o.setStartXY(u),o.setEndXY(t),r=0,a=1):(o.setStartXY(t),o.setEndXY(u),r=s-2,a=-1);for(let t=0,e=s-1;t<e;t++,r+=a){this.progress_(),h=i*(r+1);const t=new $;o.queryCoord2D(h,t),n.lineTo(t),this.m_bSetDensifyFlag&&n.setAttributeNoCurves(10,n.getPointCount()-1,0,1)}}else this.progress_();s.lineTo(t),u.assign(t)}if(t){const t=$.distance(u,h);if(t>this.m_maxLength){const e=h;let s=Math.ceil(t/this.m_maxLength);s>_t()&&(s=_t());const i=1/s;let r,a;u.compare(e)<0?(o.setStartXY(u),o.setEndXY(e),r=0,a=1):(o.setStartXY(e),o.setEndXY(u),r=s-2,a=-1);const m=new $(0,0);let l;for(let t=0,h=s-1;t<h;t++,r+=a)this.progress_(),l=i*(r+1),o.queryCoord2D(l,m),n.lineTo(m),this.m_bSetDensifyFlag&&n.setAttributeNoCurves(10,n.getPointCount()-1,0,1)}n.closePathWithLine()}}return s}densifySegmentByLength(t,i,r,o,a,h){n(t.getGeometryType()!==e.enumBezier);let u=t.getStartXY().compare(t.getEndXY());if(0===u&&i<1){t.getGeometryType()===e.enumEllipticArc?u=t.getSweepAngle()<0?1:-1:s("densify segment by length")}let m=0;if(o&&(r?(t.queryStart(this.m_dummyPoint),r.startPathPoint(this.m_dummyPoint)):h.push(0),++m),i*this.m_maxSegmentsPerCurve<1&&(i=1/this.m_maxSegmentsPerCurve),i<1){this.m_segmentBuffer||(this.m_segmentBuffer=new Pm);let e=Math.ceil(1/i);e>_t()&&(e=_t()),i=1/e,this.m_segmentBuffer.create(t.getGeometryType());let s,n,o,a=t;u<0?(s=0,n=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),s=e-2,n=-1,a=this.m_segmentBuffer.get());const l=e-1;for(let t=0;t<l;t++,s+=n)o=i*(s+1),r?(a.queryCoord(o,this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==o&&0!==o&&r.setAttribute(10,r.getPointCount()-1,0,1)):h.push(u>0?1-o:o),this.progress_();o=1,m+=l}(!a||a&&o&&m<2)&&(r?(t.queryEnd(this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint)):h.push(1))}densifyCubicBezier(t,e,s,n,i){const r=new ra;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());if(0===h&&a>0){const e=ut($,4);t.queryControlPoints(e),h=e[1].compare(e[2]),0===h&&(h=e[1].compare(e[0]))}h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=[],l=[],c=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let g=!0,d=0;if(h>0)for(m.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new $(0,1)]),l.push(0);m.length;){this.progress_();const t=m.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){g&&(d=o.findMinDeriv(),g=!1);let e=.5*(a+h);Math.abs(d-e)<.4*(h-a)&&(e=d);const s=(e-a)/(h-a),n=t[0].mul(1-s).add(t[1].mul(s)),i=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),c=n.mul(1-s).add(i.mul(s)),_=i.mul(1-s).add(u.mul(s)),p=c.mul(1-s).add(_.mul(s)),f=t[3];t[1]=n,t[2]=c,t[3]=p,t[4].setCoords(a,e);const P=[p,_,u,f,new $(e,h)];m.push(P),l[l.length-1]=r+1,l.push(r+1);continue}m.pop(),l.pop(),(m.length>0||!n||n&&s&&u<2)&&(e?(o.queryCoord(a,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==a&&0!==a&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(1-a),++u)}else for(m.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new $(0,1)]),l.push(0);m.length;){this.progress_();const t=m.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){g&&(d=o.findMinDeriv(),g=!1);let e=.5*(a+h);Math.abs(d-e)<.4*(h-a)&&(e=d);const s=(e-a)/(h-a),n=t[0].mul(1-s).add(t[1].mul(s)),i=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),c=n.mul(1-s).add(i.mul(s)),_=i.mul(1-s).add(u.mul(s)),p=c.mul(1-s).add(_.mul(s)),f=t[0];t[0]=p,t[1]=_,t[2]=u,t[4].setCoords(e,h);const P=[f,n,c,p,new $(a,e)];m.push(P),l[l.length-1]=r+1,l.push(r+1);continue}m.pop(),l.pop(),(m.length>0||!n||n&&s&&u<2)&&(e?(o.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h),++u)}}densifyRationalBezier2(t,e,s,n,i){const r=new Dn;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new Dn,c=[],g=[];for(c.push(new U(0,1)),g.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=g.at(-1);if(r<m&&this.rationalBezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new U(e,t.vmax))):(c.at(-1).vmin=e,c.push(new U(t.vmin,e))),g[g.length-1]=r+1,g.push(r+1);continue}if(c.pop(),g.pop(),c.length>0||!n||n&&s&&u<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h>0?1-s:s),++u}}}densifyBezier2(t,e,s,n,i){const r=new An;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),l=new An,c=[],g=[];for(c.push(new U(0,1)),g.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=g.at(-1);if(r<m&&this.bezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new U(e,t.vmax))):(c.at(-1).vmin=e,c.push(new U(t.vmin,e))),g[g.length-1]=r+1,g.push(r+1);continue}if(c.pop(),g.pop(),c.length>0||!n||n&&s&&u<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h>0?1-s:s),++u}}}densifyEllipticArc(t,e,s,n,i){const r=new qh;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=t.isClockwise()?0:1),h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new qh,c=[],g=[];for(c.push(new U(0,1)),g.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=g.at(-1);if(r<m&&this.ellipticArcNeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new U(e,t.vmax))):(c.at(-1).vmin=e,c.push(new U(t.vmin,e))),g[g.length-1]=r+1,g.push(r+1);continue}if(c.pop(),g.pop(),c.length>0||!n||n&&s&&u<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h>0?1-s:s),++u}}}calculateLengthSubdivisionStep(t,n){const i=t.calculateUpperLength2D();if(!t.isCurve())return i?n/i:1;if(t.getGeometryType()===e.enumEllipticArc){const e=t;if(e.isCircular()||e.isDegenerate(0)||e.isDegenerateToLine()){let t=n/i;return t<this.m_minStep&&(t=this.m_minStep),t}return n/i*e.getSemiAxes().y/e.getSemiAxes().x}t.getGeometryType()===e.enumBezier&&s(""),s("")}calculateDeviationSubdivisionStep(t,n){if(!t.isCurve())return 1;if(t.getGeometryType()===e.enumEllipticArc){const e=t;if(e.isDegenerate(0)||e.isDegenerateToLine())return 1;{const s=e.getSemiMajorAxis(),i=1-n/s;let r=Math.PI/2;if(i>0){const t=4*Math.sqrt(n/s*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*s;return this.calculateLengthSubdivisionStep(t,o)}}s("")}calculateAngularSubdivisionStep(t,n){if(!t.isCurve())return 1;if(t.getGeometryType()===e.enumEllipticArc){const e=t;return e.isDegenerate(0)||e.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,n*e.getSemiMinorAxis())}s("")}rationalBezier2NeedsSplit(t,e,s,n){t.cutBezierIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0}const r=ut($,3);e.queryControlPoints(r);const o=[0,0,0];return e.queryWeights(o),!i&&this.m_maxDeviation>0&&(i=!Zh.checkRationalBezier2MaxDeviation(r,o,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Zh.checkRationalBezier2MaxAngle(r,o,this.m_cosMaxAngle)),i}bezier2NeedsSplit(t,e,s,n){t.cutBezierIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0}const r=ut($,3);return e.queryControlPoints(r),!i&&this.m_maxDeviation>0&&(i=!Zh.checkBezier2MaxDeviation(r,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Zh.checkBezier2MaxAngle(r,this.m_cosMaxAngle)),i}ellipticArcNeedsSplit(t,e,s,n){t.cutArcIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0}return!i&&this.m_maxDeviation>0&&(i=!Zh.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Zh.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),i}bezierNeedsSplit(t){let e=!1;if(this.m_maxLength>0){if($.distance(t[0],t[1])+$.distance(t[1],t[2])+$.distance(t[2],t[3])>this.m_maxLength)return e=!0,!0}return!e&&this.m_maxDeviation>0&&(e=!Zh.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!Zh.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const n=s.clone();n.leftPerpendicularThis(),n.normalize();const i=n.dotProduct(t[0].sub(t[1])),r=n.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(i),Math.abs(r))<=e){const e=new $;yo(t,.5,e,!1);const n=e.sub(t[0]).dotProduct(s);return n>=0&&n<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const n=t[1].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}{const n=t[2].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}{const n=t[2].sub(t[1]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const n=t[2].sub(t[0]);if(n.sqrLength()>0){const e=n.clone();e.leftPerpendicularThis(),e.normalize();const i=e.dotProduct(t[0].sub(t[1]));if(Math.abs(i)<=s){const e=t[1].sub(t[0]).dotProduct(n);return e>=0&&e<=n.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const n=t[2].sub(t[0]);n.normalize();{const e=t[1].sub(t[0]),i=e.dotProduct(n);if(i<0)return!1;if(e.length()*s>i)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const n=s.clone();n.leftPerpendicularThis(),n.normalize();const i=n.dotProduct(t[0].sub(t[1]));if(Math.abs(i)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const n=t[1].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),n=[0,0];if(1===em(t,s,n)){const s=t.getCoord2D(n[0]),i=$.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),r=new $;Ct(t.getStartXY(),t.getEndXY(),i,r);return $.distance(s,r)<=e}}const s=t.getCoord2D(.5),n=new $;Ct(t.getEndXY(),t.getStartXY(),.5,n);return $.distance(s,n)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),n=t.getTangent(1),i=s.dotProduct(n);return!(i<0)&&!(s.length()*n.length()*e>i)}static checkTypeForReplace(t,s){return t.getGeometryType()===s&&(s!==e.enumEllipticArc||t.isCircular())}}function Hh(t,e,s){const n=s.length;if(e<=0||n<=2)return n;let i=0;const r=et(n-1,Number.NaN);for(let o=1,a=n;o<a;o++){const e=t.tToLength(s[o]);r[o-1]=e-i,i=e}for(;r.length>1;){const t=r.findIndex(t=>t<=2*e);if(-1===t)break;let n=t+1,i=t+1;if(t>0){const e=t-1;(i===r.length||r[e]>r[i])&&(i=e,n--)}r[i]+=r[t],r.splice(t,1),s.splice(n,1)}return s.length}function Uh(t,e,s,n,i){const r=[],o=[],a=Gh(e,s,0,n,!1,r,o),h=new ra;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new F,g=new fm;for(let d=0,_=0;d<a;d++){if(r[_+1].isNAN()){if(l){let t=o[d];e.queryCoord(t,c),g.setStart(c),t=o[d+1],e.queryCoord(t,c),g.setEnd(c)}g.setStartXY(r[_]),g.setEndXY(r[_+3]),t.addSegment(g,u)}else{if(l){let t=o[d];e.queryCoord(t,c),h.setStart(c),t=o[d+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setControlPoint2(r[_+2]),h.setEndXY(r[_+3]),t.addSegment(h,u)}_+=3,u=!1}}function Oh(t,e,s,n,i){const r=[],o=[],a=Wh(e,s,0,n,!1,r,o),h=new An;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new F,g=new fm;for(let d=0,_=0;d<a;d++){if(r[_+1].isNAN()){if(l){let t=o[d];e.queryCoord(t,c),g.setStart(c),t=o[d+1],e.queryCoord(t,c),g.setEnd(c)}g.setStartXY(r[_]),g.setEndXY(r[_+2]),t.addSegment(g,u)}else{if(l){let t=o[d];e.queryCoord(t,c),h.setStart(c),t=o[d+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setEndXY(r[_+2]),t.addSegment(h,u)}_+=2,u=!1}}function Qh(t,s,i,o,a){n(t===e.enumBezier||t===e.enumEllipticArc||t===e.enumBezier2);const h=s.createInstance();h.getGeometryType()===e.enumPolygon&&h.setFillRule(s.getFillRule());const u=s.querySegmentIterator();for(let m=0,l=s.getPathCount();m<l;++m){if(!s.hasNonLinearSegmentsPath(m)){h.addPath(s,m,!0);continue}const a=s.getPathStart(m);let l=!0,c=0;for(u.resetToPath(m),n(u.nextPath());u.hasNextSegment();){const n=u.nextCurve();if(!n)break;{const g=u.getStartPointIndex()-a,d=g-c;d>0&&(h.addSegmentsFromPath(s,m,c,d,l),l=!1),c=g+1,t===e.enumBezier?Uh(h,n,i,o,l):t===e.enumBezier2?Oh(h,n,i,o,l):r(""),l=!1}}const g=s.getSegmentCountPath(m);g-c!==0&&h.addSegmentsFromPath(s,m,c,g-c,l)}return h}function Kh(t,e,s,n,i,r,o,a){const h=e.clone();h.dropAllAttributes();const u=(t,e,s,n)=>(e&&(t&&e.push(n.getStartXY()),e.push($.getNAN()),e.push($.getNAN()),e.push(n.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(h.isDegenerateToLine()||h.isDegenerate(0))return u(t,r,o,e);const m=h.getStartXY(),l=h.getEndXY(),c=h.getSemiAxes(),g=new ce;if(h.isCircular())g.setIdentity();else{const t=h.getAxisXRotation();g.setScaleCoords(1,h.getMinorMajorRatio()),g.rotateAngle(t)}const d=h.getCenter();g.shift(d);const _=g.clone();_.invertThis(),h.applyTransformation(_);const p=h.getSweepAngle();if(0===p)return u(t,r,o,e);const f=le.constructEmpty();f.setCoords({center:d,width:2*c.x,height:2*c.x});const P=.05*f.calculateToleranceFromEnvelope(),y=Math.max(s/c.x,P/c.x);let x=4*Math.pow(y/.0741,1/6);x=Math.min(x,Math.PI/2);const C=Mh(h.getStartAngle());let v=p>0?Math.floor(C/x):Math.ceil(C/x);v*=x;const b=p>0?x:-x;v+b===C&&(v+=b);let S=4/3*Math.tan(Math.abs(x)/4);p>0&&(S=-S),o&&t&&o.push(0);const E=x/Math.abs(p);let D=(v-C)/p;const w=m.clone(),A=new $;h.queryCoord2D(0,A);const T=A.clone(),I=1-.01*E;let M=0,Y=0;for(;D<1;){let s;if(D+=E,Y>0&&D<I)s=S;else{D>=I&&(D=1);const t=(D-Y)*p;s=4/3*Math.tan(Math.abs(t)/4),p>0&&(s=-s)}h.queryCoord2D(D,A);const a=new $;g.queryTransform(A,a);const u=e.getClosestCoordinate(a,!1);if(e.queryCoord2D(u,a),1!==D&&($.distance(w,a)<=2*n||$.distance(a,l)<=2*n))continue;w.setCoordsPoint2D(a);const c=ut($,4);c[0].assign(T),c[3].assign(A),c[1].rightPerpendicularOther(T),c[1].scaleAddThis(s,T),c[2].leftPerpendicularOther(A),c[2].scaleAddThis(s,A),g.transformPoints2D(c,3,c),c[3].assign(a),0===Y&&c[0].setCoordsPoint2D(m),1===D&&c[3].setCoordsPoint2D(l),i&&go(c);let d=!0;for(let t=1;t<4;t++)if(!c[t].isEqualPoint2D(c[0])){d=!1;break}d||(o&&o.push(u),r&&(0===Y&&t&&r.push(c[0].clone()),r.push(c[1].clone()),r.push(c[2].clone()),r.push(c[3].clone())),M++),Y=D,T.setCoordsPoint2D(A)}return M}function $h(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new le;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=ut($,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=et(9,Number.NaN);let p=e.getMonotonicPartParams(_.length,_);_.length=p,p=Hh(e,n,_);let f=0,P=t;for(let y=1;y<p;y++){const t=_[y];for(d.push(f),d.push(t);d.length>1;){const t=d.at(-1);d.pop();const e=d.at(-1),s=ut($,3);Ka(c,g,t,e,s,[0,0,0]);const n=ut($,3),i=$i(s,g,n),a=16,h=d.length>a;m>=i||h?(o.push(e),r&&(P&&(r.push(n[0]),P=!1),r.push(n[1]),r.push(n[2])),l++):(d.push(.5*(t+e)),d.push(t))}f=t}return l}function Jh(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new le;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=ut($,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=et(9,Number.NaN);let p=0;i?(p=e.getMonotonicPartParams(_.length,_),_.length=p,p=Hh(e,n,_)):(_.length=2,p=2,_[0]=0,_[1]=1);let f=0,P=t;for(let y=1;y<p;y++){const t=_[y];for(d.length=0,d.push(t),d.push(f);d.length>1;){const t=d.at(-1);d.pop();const e=d.at(-1),s=ut($,3),n=[0,0,0];Ka(c,g,t,e,s,n);const i=ut($,4),a=$a(s,n,i),h=16,u=d.length>h;m>=a||u?(o.push(e),r&&(P&&(r.push(i[0]),P=!1),r.push(i[1]),r.push(i[2]),r.push(i[3])),l++):(d.push(.5*(t+e)),d.push(t))}f=t}return l}function tu(t,e,s,n,i,r,o,a){const h=e.clone();if(h.dropAllAttributes(),h.isDegenerateToLine()||0===h.getSweepAngle())return r&&(t&&r.push(e.getStartXY()),r.push($.getNAN()),r.push(e.getEndXY())),o&&(t&&o.push(0),o.push(1)),1;const u=h.getStartXY(),m=h.getEndXY(),l=h.getSemiAxes(),c=new ce;if(h.isCircular())c.setIdentity();else{const t=h.getAxisXRotation();c.setScaleCoords(1,h.getMinorMajorRatio()),c.rotateAngle(t)}const g=h.getCenter();c.shift(g);const d=c.clone();d.invertThis(),h.applyTransformation(d);const _=le.constructEmpty();_.setCoords({center:g,width:2*l.x,height:2*l.x});const p=.05*_.calculateToleranceFromEnvelope(),f=Math.max(s/l.x,p/l.x),P=Math.sqrt(2*f+f*f);let y=2*Math.sqrt(2*P*(1+f-P));y=Math.min(y,Math.PI/2);const x=h.getSweepAngle(),C=Math.ceil(Math.abs(x)/y),v=Math.max(C,1);y=x/v;const b=1/v;let S=Math.tan(Math.abs(y)/2);x>0&&(S=-S),o&&t&&o.push(0);const E=new $;h.queryCoord2D(0,E);for(let D=0;D<v;D++){const e=E.clone(),s=(D+1)*b;if(o&&o.push(s),!r)continue;h.queryCoord2D(s,E);const n=ut($,3);n[0].assign(e),n[2].assign(E),n[1].rightPerpendicularOther(n[0]),n[1].mulThis(S),n[1].addThis(n[0]),c.transformPoints2D(n,3,n),0===D&&n[0].setCoordsPoint2D(u),D===v-1&&n[2].setCoordsPoint2D(m),0===D&&t&&r.push(n[0]),r.push(n[1]),r.push(n[2])}return v}function eu(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new le;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=ut($,4);e.queryControlPoints(c);const g=[],d=et(9,Number.NaN);let _=e.getMonotonicPartParams(d.length,d);d.length=_,_=Hh(e,n,d);let p=0,f=t;for(let P=1;P<_;P++){const t=d[P];for(g.push(p),g.push(t);g.length>1;){const t=g.at(-1);g.pop();const e=g.at(-1),s=ut($,4);Po(c,t,e,s);const n=ut($,3),i=Ki(s,n),a=16,h=g.length>a;m>=i||h?(o.push(e),r&&(f&&(r.push(n[0]),f=!1),r.push(n[1]),r.push(n[2])),l++):(g.push(.5*(t+e)),g.push(t))}p=t}return l}function su(){return{e2:0,completeE:0}}class nu{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?$.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function iu(t,e,s){if(Eu(t)){return void vs(new fm({start:t.getStartXY(),end:t.getEndXY()}),e,s)}if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const n=new rt;du(t,e,n);const i=new rt,r=new rt;rt.st_cosAndSin(n,i,r);const o=be.constructCoordsE(new rt(t.m_semiMajorAxis).mulThisE(i),new rt(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(r)),a=new rt(t.m_rotation);rt.st_cosAndSin(a,i,r),o.rotateDirect(i,r),o.addThisE(be.constructPoint2D(t.m_center)),s.setE(o)}}function ru(t,e){return t.convertToCanonic(e)}function ou(t,e){const s=new U(t.getStartAngle(),t.getEndAngle());s.normalize();const n=Gt(),i=Kt(e,n);if(i<s.vmin){let t=i+n;for(;t<s.vmin;)t+=n;return s.containsCoordinate(t)?t:s.vmin-i<t-s.vmax?i:t}if(i>s.vmax){let t=i-n;for(;t>s.vmax;)t-=n;return s.containsCoordinate(t)||s.vmin-t<i-s.vmax?t:i}return i}function au(t,e,s,n){let i=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;i>At();)i-=2*At();for(;i<=-At();)i+=2*At();if(!Number.isNaN(e)){for(;e>At();)e-=2*At();for(;e<=-At();)e+=2*At();!s&&e>i&&(e-=2*At()),s&&e<i&&(e+=2*At()),r=e-i,Math.abs(r)<o&&!n&&(r=s?2*At():-2*At()),Math.abs(r)>2*At()-o&&n&&(r=0)}Math.abs(r)>2*At()-o&&(r=r>=0?2*At():-2*At(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),n=Math.abs(r)<=At(),r&&(s=r>0),t.m_startAngle=hu(i),t.m_sweepAngle=r,Fu(t,!n),Xu(t,s)}function hu(t){let e=t,s=!1;return e<=-At()?(e+=Gt(),s=!0):e>At()&&(e-=Gt(),s=!0),e<=-At()?(e=Kt(e,Gt()),e<=-At()&&(e+=Gt()),s=!0):e>At()&&(e=Kt(e,Gt()),e>At()&&(e-=Gt()),s=!0),s&&(e>At()||e<=-At())&&(e=At()),e}function uu(t,e,s){const n=s,i=n.getSemiAxes();let r=new $(i.x*Math.cos(t[0]),i.y*Math.sin(t[0]));return r=n.convertFromCanonic(r),$.sqrDistance(r,n.getStartXY())}function mu(t,e,s){const n=s,i=n.getSemiAxes(),r=t[0]+n.getStartAngle();let o=new $(i.x*Math.cos(r),i.y*Math.sin(r));return o=n.convertFromCanonic(o),$.sqrDistance(o,n.getEndXY())}function lu(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),n=e.equals(s),i=Vu(t),r=qu(t),o=t.projectionBehavior();if(n){const s=t.convertToCanonic(e),n=new $(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=n.x,s.y/=n.y,t.m_startAngle=hu(Math.atan2(s.y,s.x)),t.m_sweepAngle=i?r?Gt():-Gt():0}else{const n=t.convertToCanonic(e),a=new $(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);n.x/=a.x,n.y/=a.y;const h=t.convertToCanonic(s);h.x/=a.x,h.y/=a.y,t.m_startAngle=Math.atan2(n.y,n.x),t.m_sweepAngle=$.calculateAngle(n,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=Gt()):t.m_sweepAngle>0&&(t.m_sweepAngle-=Gt()),t.m_startAngle=hu(t.m_startAngle);let u=uu([t.m_startAngle],1,t);if(u=Math.sqrt(u),u>.25*Oe(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,n=[0];on(uu,t,1,[t.m_startAngle],[e],[s],1e-14,n),t.m_startAngle=hu(n[0])}if(u=mu([t.m_sweepAngle],1,t),u=Math.sqrt(u),u>.25*Oe(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,n=[0];on(mu,t,1,[t.m_sweepAngle],[e],[s],1e-14,n),t.m_sweepAngle=n[0]}const m=Math.abs(t.m_sweepAngle)>At();if(Fu(t,m),i!==m&&!i&&Math.abs(t.m_sweepAngle)>1.5*At())return void Su(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void Su(t,e,s,o)}}function cu(t,e){return(ou(t,e)-t.getStartAngle())/t.getSweepAngle()}function gu(t,e){return t.m_startAngle+e*t.m_sweepAngle}function du(t,e,s){s.assign(new rt(t.m_startAngle).addE(e.mulE(new rt(t.m_sweepAngle))))}function _u(t,e){const s=new rt(t.m_cosr).sqrThis(),n=new rt(t.m_sinr).sqrThis(),i=new rt(t.m_minorMajorRatio),r=new rt(1/t.m_minorMajorRatio),o=i.mulE(s).addThisE(r.mulE(n)),a=i.subE(r).mulThis(2*t.m_cosr*t.m_sinr),h=i.mulE(n).addThisE(r.mulE(s));e[0]=o,e[1]=a,e[2]=h,e[3]=new rt(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function pu(t,e){const s=new Se;s.a11.setE(t[0]),s.a12=rt.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const n=[$.getNAN(),$.getNAN()],i=[new rt,new rt];s.eigenSymmetric(i,n);const r=t[3].clone();r.negateThis(),r.invThis(),i[0].mulThisE(r),i[1].mulThisE(r),i[0].sqrtThis().invThis(),i[1].sqrtThis().invThis(),e.x=i[0].toDouble(),e.y=i[1].toDouble();return Math.atan2(n[0].y,n[0].x)}function fu(t,e,s){if(Eu(t))return(s-e)*$.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const n=Du(t,e);return Du(t,s)-n}function Pu(t){return t.m_cachedValues}function yu(t){if(t.m_cachedValues)return t.m_cachedValues;const e=su();return e.e2=vu(t),e.completeE=$t(e.e2),t.m_cachedValues=e,e}function xu(t,e,s,n){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Eu(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,Uu(t),void t.afterCompletedModification();if(n&&Math.abs(t.getSweepAngle())<=1.01*xt()){const n=ut($,3),i=ku(t,n);if(Za(n)){n[0].assign(e),n[2].assign(s),Ua(n);if(0===t.projectionBehavior()){let e=0,s=2;$.sqrDistance(n[1],n[0])<$.sqrDistance(n[1],n[2])&&(s=Q(e,e=s));const i=n[s].sub(n[e]),r=i.length();i.divThis(r);const o=n[1].sub(n[e]),a=o.length(),h=o.dotProduct(i)/a,u=o.crossProduct(i)/a,m=new $;Ct(n[e],n[s],.5,m);const l=.5*r/u*gt(1-h,0,1),c=n[1].side(n[e],n[s]),g=i.clone();c?g.leftPerpendicularThis():g.rightPerpendicularThis();const d=m.sub(g.mul(l));t.constructCircularArcThreePoint(n[0],n[2],d)}else Gu(n,i*i,null,!1,t);return}}0===t.projectionBehavior()?im(t,e,s):rm(t,e,s)}}function Cu(t,e,s){const n=0===t.projectionBehavior();if(s<=2)return void Su(t,e[0],e[s-1],n?0:1);if(n){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const n=new $;return t.queryCoord2D(.5,n),void t.m_interior.setCoordsPoint2D(n)}const i=t.getSemiMajorAxis(),r=t.getMinorMajorRatio(),o=t.getAxisXRotation(),a=t.getCenter(),h=new Array(4);h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];const u=new Array(4);u[0]=t.isClockwise(),u[1]=u[0],u[2]=!u[0],u[3]=!u[0];const m=Math.trunc(s<5?1:(s+4)/5),l=ut(qh,4),c=et(4,Number.NaN);let g=0;for(let d=0;d<4;d++){l[d].constructEllipticArcEndPointsCenter(e[0],e[s-1],i,r,o,h[d],u[d],a),c[d]=0;let t=0;for(let n=m;n<s-1;n+=m){const s=l[d].getClosestCoordinate(e[n],!1);c[d]+=$.sqrDistance(l[d].getCoord2D(s),e[n]),t++}c[d]/=t,c[d]<c[g]&&(g=d)}t.assignCopy(l[g])}function vu(t){return 1-Bt(t.m_minorMajorRatio)}function bu(t,e,s,n,i,r,o,a,h){return t.m_bits=0,t.m_rotation=r,qe(t,e),Ve(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),Fu(t,o),Xu(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=n,t.m_minorMajorRatio=i,Bu(t,void 0===h)}function Su(t,e,s,n){t.m_bits=0,t.m_rotation=0,qe(t,e),Ve(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,Fu(t,!1),Xu(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(n),t.afterCompletedModification()}function Eu(t){return t.m_center.isNAN()}function Du(t,e){if(0===e)return 0;const s=yu(t),n=gu(t,e),i=xt(),r=Au(t),o=jt(n+i,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function wu(t,e){if(Eu(t)){const s=$.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const n=yu(t),i=xt(),r=Au(t);s<0&&(e=-e);const o=e/t.m_semiMajorAxis+r;let a=Zt(o,n.e2,n.completeE);a-=i,a-=t.getStartAngle();return a/s}function Au(t){const e=yu(t);return jt(t.getStartAngle()+xt(),e.e2,e.completeE)}function Tu(t,e,s,i,r){if(2===e.m_TransformationType)return void n(0);if(n(!Ru(t)),e.isIdentity()&&(!i||i.equals(t.getStartXY())&&r.equals(t.getEndXY())))return;Yu(t);let o=$.getNAN(),a=$.getNAN();if(null===i?(o.x=t.m_XStart,o.y=t.m_YStart,e.transformInPlace(o),a.x=t.m_XEnd,a.y=t.m_YEnd,e.transformInPlace(a)):(o=i,a=r),Eu(t))return t.m_XStart=o.x,t.m_YStart=o.y,t.m_XEnd=a.x,void(t.m_YEnd=a.y);const h=t.m_center.clone();if(e.transformInPlace(h),s||e.isUniformNoRotation()){let s=qu(t);e.isReflective()&&(s=!s);if(0===t.projectionBehavior()){if(!o.equals(a)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(o,a,s)}return void Iu(t,o,a,h,s,!1)}const n=new $(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(n);const i=Math.atan2(n.y,n.x),r=t.getSemiAxes();e.transformWithoutTranslateInPlace(r);const u=t.m_center.clone();return e.transformInPlace(u),void t.constructEllipticArcEndPointsCenter(o,a,r.x,r.y/r.x,i,t.isMajor(),s,u)}{{const s=new Array(4);_u(t,s);const n=new Se;n.a11.setE(s[0]),n.a12.setE(s[1]),n.a12.mulThisByPower2(.5),n.a21.setE(n.a12),n.a22.setE(s[2]);if(!n.det().isZero()){const i=new Se;if(i.a11.set(e.xx),i.a12.set(e.xy),i.a21.set(e.yx),i.a22.set(e.yy),i.invertThis()){const r=i.clone();r.transposeThis();const u=n.clone();u.mulThis(i),u.mulLeftThis(r);if(!u.det().isZero()){const n=ut(rt,4);n[0].setE(u.a11),n[1].setE(u.a12),n[1].mulThisByPower2(2),n[2].setE(u.a22),n[3].setE(s[3]);const i=$.getNAN(),r=pu(n,i);let m=qu(t);return e.isReflective()&&(m=!m),void t.constructEllipticArcEndPointsCenter(o,a,i.x,i.y/i.x,r,t.isMajor(),m,h)}}}}const s=[$.getNAN(),$.getNAN(),$.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let n=t.isClockwise();n&&(s[2]=Q(s[0],s[0]=s[2]));const i=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(n=!n);const r=new $(0,0),u=t.createInstance();Gu(s,i,r,!1,u),t.constructEllipticArcEndPointsCenter(o,a,u.getSemiMajorAxis(),u.getMinorMajorRatio(),u.getAxisXRotation(),t.isMajor(),!n,h)}}function Iu(t,e,s,n,i,r){const o=.5*(n.sub(e).length()+n.sub(s).length());t.m_center.assign(n),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x);au(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),i,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,n);return t.setProjectionBehavior(0),a}function Mu(t,e){t.m_cachedValues=e}function Yu(t){t.m_cachedValues=null}function Nu(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function Xu(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function qu(t){return!!(1&t.m_bits)}function Fu(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function Vu(t){return!!(2&t.m_bits)}function Lu(t){if(t.m_center.isNAN())return!1;const e=8,s=new be;s.setWithEps(t.getStartXY(),e),s.subThisE((new be).setWithEps(t.m_center,e));const n=new rt;n.setWithEps(t.m_rotation,e);const i=new rt,r=new rt;rt.st_cosAndSin(n,i,r),s.rotateReverse(i,r);const o=new be;o.setWithEps(t.getEndXY()),o.subThisE(be.constructPoint2D(t.m_center)),o.rotateReverse(i,r);const a=new rt;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),u=new rt;u.setWithEps(t.m_minorMajorRatio),h.mulThisE(u),s.x.divThisE(a),s.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const m=s.x.sqr().addThisE(s.y.sqr()).subThisE(ot),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(ot);return!m.isZero()||!l.isZero()}function Ru(t){return!!(8&t.m_bits)}function zu(t){t.m_bits&=-9}function Bu(t,e){zu(t);const s=t.getStartXY(),i=t.getEndXY();let r=!1;const o=Vu(t),a=qu(t),h=t.projectionBehavior(),u=s.equals(i);let m=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:g("NAN minor major ratio and non-zero major axis")),m||=e?u:t.m_center.isNAN(),m)return Su(t,s,i,h),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const l=new $(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(n(l.y>0&&l.x>=l.y),u){const e=t.convertToCanonic(s);n(!l.isZero()),e.x/=l.x,e.y/=l.y;const i=Math.sqrt(Bt(e.x)+Bt(e.y));if(r=1!==i,t.m_semiMajorAxis*=i,l.mulThis(i),t.m_startAngle=hu(Math.atan2(e.y,e.x)),!o)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),r;t.m_sweepAngle=a?Gt():-Gt()}else{let e=t.m_center.isNAN()||Lu(t);if(!e){const n=t.convertToCanonic(s);n.x/=l.x,n.y/=l.y;const r=new $(1,0);t.m_startAngle=$.calculateAngle(r,n);const o=t.convertToCanonic(i);o.x/=l.x,o.y/=l.y,t.m_sweepAngle=$.calculateAngle(n,o),e=!ju(t)}if(e){r=!0;const e=s.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let n=Bt(e.x/l.x)+Bt(e.y/l.y);n>1&&(n=Math.sqrt(n),t.m_semiMajorAxis*=n,l.mulThis(n));const h=new $(0,0);{const t=l.x*l.x,s=l.y*l.y,n=t*e.y*e.y+s*e.x*e.x,i=t*s-n;if(i>0){const t=Math.sqrt(i/n);h.setCoords(l.x*e.y/l.y,-l.y*e.x/l.x),h.mulThis(t),o===a&&h.negateThis()}}{const e=new $(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(i).mulThis(.5)),t.m_center.assign(e)}}if(lu(t),!ju(t))return Su(t,s,i,h),!0}return Uu(t),t.afterCompletedModification(),r}function ku(t,e){n(Math.abs(t.getSweepAngle())<15*Math.PI/16);const s=t.getSemiMajorAxis(),i=t.getSemiMinorAxis();let r;if(0===s)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),r=1,r;if(0===i)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=$.lerp(e[0],e[2],.5),r=1,r;const o=t.getSweepAngle(),a=t.getStartAngle(),h=a+o,u=new $(-s*Math.sin(a),i*Math.cos(a)),m=new $(-s*Math.sin(h),i*Math.cos(h));u.normalize(),m.normalize(),u.rotateDirect(t.m_cosr,t.m_sinr),m.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const l=u.crossProduct(m);e[1].assign(u.mul(e[1].crossProduct(m)/l)),e[1].addThis(e[0]);return r=Math.cos(.5*o),r}function Gu(t,e,s,i,r){if(i){const s=.5,n=Math.sqrt(e),i=Bt(1-s)+2*n*s*(1-s)+Bt(s),o=t[0].mul(Bt(1-s)).add(t[1].mul(2*n*s*(1-s))).add(t[2].mul(Bt(s))).divThis(i);return r.constructCircularArcThreePoint(t[0],t[2],o),!0}const o=t[0].sub(t[1]),a=t[2].sub(t[1]),h=o.crossProduct(a),u=o.dotProduct(a),m=e;n(m<=1),n(m>0);const l=.5/(1-m),c=o.sqrLength(),g=u,d=a.sqrLength(),_=Bt(h),p=o.sub(a).sqrLength();if(0===_)return Su(r,t[0],t[2],1),!1;if(u<=-Math.sqrt(c)*Math.sqrt(d))return Su(r,t[0],t[2],1),!1;const f=[0,0],P=new U;P.setInfinite();const y=nn(2*_,-(p/m+4*g),2*(1-m)/m,P,!1,f);if(0===y)return Su(r,t[0],t[2],1),!1;1===y&&(f[1]=f[0]);const x=Math.sqrt(l/f[0]),C=Math.sqrt(l/f[1]),v=.5/m;let b=v-d*f[0],S=v-c*f[0];Math.abs(b)>Math.abs(S)?S=g*f[0]-v+1:b=g*f[0]-v+1;const E=o.mul(b).add(a.mul(S)),D=E.norm(1)<1e-15*x?0:Math.atan2(E.y,E.x)+Math.PI,w=o.add(a),A=s?s.clone():t[1].add(w.mul(l)),T=t[0].sub(A),I=t[2].sub(A),M=T.crossProduct(I)<0,Y=!1;new qh;return r.constructEllipticArcEndPointsCenter(t[0],t[2],x,C/x,D,Y,!M,A)}function Wu(t,e,s,n,i){return Gu(t,e,s,n,i)}function ju(t){const e=Oe(t);let s=!1;{const n=new $(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));n.rotateDirect(t.m_cosr,t.m_sinr),n.addThis(t.m_center);s=$.distance(t.getStartXY(),n)>e}let n=!1;if(!s){const s=new $(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center);n=$.distance(t.getEndXY(),s)>e}return!s&&!n}function Zu(e,s,n,i){0===n&&t("construct_enclosing_circle");const o=[0,0,0],a=Vh(s,n,o);if(1===a)e.constructCircleRadius(0,s[o[0]],i);else if(2===a){const t=$.lerp(s[o[0]],s[o[1]],.5),n=$.distance(s[o[0]],t),r=$.distance(s[o[1]],t);e.constructCircleRadius(Math.max(n,r),t,i)}else if(3===a){const t=$.calculateCircleCenterFromThreePoints(s[o[0]],s[o[1]],s[o[2]]),n=$.distance(s[o[0]],t),r=$.distance(s[o[1]],t),a=$.distance(s[o[2]],t);e.constructCircleRadius(Math.max(n,r,a),t,i)}else r("unexpected")}function Hu(t){if(Eu(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),n=e*e+s*s,i=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let u=1,m=0;t.m_rotation&&(u=(a-h)*(a+h),m=2*a*h);const l=((-.5*(r-i)+.25*u*(2*Math.cos(r+i)*Math.sin(r-i)))*s+-2*Math.sin(.5*(r+i))*Math.sin(.5*(r-i))*a*o)*e/n;let c=0;if(t.m_rotation){c=.125*(-2*Math.sin(r+i)*Math.sin(r-i))*m-s*o/n*(2*Math.cos(.5*(r+i))*Math.sin(.5*(r-i)))*h}return n*(l+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function Uu(t){t.queryCoord2D(.5,t.m_interior)}function Ou(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==Ku(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Qu(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==$u(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Ku(t,e,s,i,r,o,a,h,u,m){if(Eu(e)){return ws(new fm({start:e.getStartXY(),end:e.getEndXY()}),s,i,r,o,a,h,m)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0);const l=Qe(e,s);if(Ke(e,s,a=Math.max(l,a)))return 0;const c=s.getStartXY();c.subThis(e.m_center);const g=s.getEndXY();g.subThis(e.m_center),c.rotateReverse(e.m_cosr,e.m_sinr),g.rotateReverse(e.m_cosr,e.m_sinr);const d=g.clone();d.subThis(c);const _=e.m_semiMajorAxis,p=1/_,f=e.getSemiMinorAxis(),P=1/f,y=d.clone();y.leftPerpendicularThis();const x=Math.atan2(f*y.y,_*y.x),C=et(16,Number.NaN),v=et(16,Number.NaN);let b=0;const S=[x,x+Math.PI];for(let n=0;n<2;++n){const t=cu(e,S[n]);if(t>=0&&t<=1){C[b]=t;const n=e.getCoord2D(C[b]);v[b]=s.getClosestCoordinate(n,!1),$.distance(n,s.getCoord2D(v[b]))<=a&&b++}}const E=c.x*p,D=c.y*P,w=d.x*p,A=d.y*P;let T=nn(w*w+A*A,2*(E*w+D*A),E*E+D*D-1,U.unit(),!1,v);n(T>=0);for(let n=0;n<T;n++){const t=d.mul(v[n]).add(c);t.x*=p,t.y*=P;const i=cu(e,Math.atan2(t.y,t.x));if(i>=0&&i<=1){C[b]=i;const t=e.getCoord2D(i);v[b]=s.getClosestCoordinate(t,!1),$.distance(t,s.getCoord2D(v[b]))<=a&&b++}}n(b<C.length+4);const I=et(16,Number.NaN);T=e.intersectPoint(s.getStartXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=I[n],v[b]=0;T=e.intersectPoint(s.getEndXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=I[n],v[b]=1;T=s.intersectPoint(e.getStartXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=0,v[b]=I[n];T=s.intersectPoint(e.getEndXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=1,v[b]=I[n];return 0===b?0:gm(t,e,s,C,v,b,i,r,o,a,h,u,m)}function $u(t,e,s,i,r,o,a,h,u,m){if(Eu(e)){const n=new fm({start:e.getStartXY(),end:e.getEndXY()});return Ku(t,s,n,i,o,r,a,h,u,!m)}if(Eu(s)){const n=new fm({start:s.getStartXY(),end:s.getEndXY()});return Ku(t,e,n,i,r,o,a,h,u,m)}const l=Qe(e,s);a=Math.max(a,l);let c=!1;{const t=e.getSemiAxes(),i=e.getCenter(),m=s.getSemiAxes(),l=s.getCenter(),g=$.distance(l,i),d=t.x+m.x;if(g>d+a)return 0;if(t.y>m.x){if(g+m.x+a<t.y)return 0}else if(m.y>t.x&&g+t.x+a<m.y)return 0;if(u&&!h){const i=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),a=1===s.m_minorMajorRatio&&s.isClosed()&&s.isMajor();if(i&&a&&(c=!0,g<=d)){if(Math.max(t.x,m.x)<=Math.min(t.x,m.x)+g)return n(!r&&!o),1}}}if(!c&&Ke(e,s,a))return 0;const g=[],d=[],_=!1,p=!1,f=jh(e,0,0,_,p,g,d,null),P=[],y=[],x=jh(s,0,0,_,p,P,y,null);if(1===f&&1===x){const t=new Dn({points:g,weights:d}),n=new Dn({points:P,weights:y}),l=[],c=[],_=oh(!1,t,n,i,null===r?null:l,null===o?null:c,a,h,u,m);if(_>0&&null!==r||null!==o){r&&(r.length=0),o&&(o.length=0);for(let i=0;i<_;++i){if(r)if(lt(l[i],0,1))r.push(l[i]);else{const s=t.tToLength(l[i]),n=e.lengthToT(s);r.push(n)}if(o)if(lt(c[i],0,1))o.push(c[i]);else{const t=n.tToLength(c[i]),e=s.lengthToT(t);o.push(e)}}}return _}let C=[];const v=[];let b=0;const S=u&&!h;for(let n=0;n<f;n++){const t=new Dn({points:g.slice(2*n,2*n+3),weights:d.slice(2*n,2*n+3)});let i=0;for(let r=0;r<x;r++){v.length<=r&&v.push(new Dn({points:P.slice(2*r,2*r+3),weights:y.slice(2*r,2*r+3)}));const o=[],h=[],u=S?null:o,m=S?null:h,l=oh(!1,t,v[r],null,u,m,a,!1,S,!1);if(l>0&&S)return 1;for(let a=0;a<l;++a){if(0===o[a]&&0===n)o[a]=0;else if(1===o[a]&&n===f-1)o[a]=1;else{const s=t.tToLength(o[a])+b,n=e.lengthToT(s);o[a]=n}if(0===h[a]&&0===r)h[a]=0;else if(1===h[a]&&r===x-1)h[a]=1;else{const t=v[r].tToLength(h[a])+i,e=s.lengthToT(t);h[a]=e}C.push(Yt(o[a],h[a]))}i+=v[r].calculateLength2D()}b+=t.calculateLength2D()}if(0===C.length)return 0;if(h&&(C=C.filter(t=>!lt(t.first,0,1)||!lt(t.second,0,1)||!e.getCoord2D(t.first).equals(s.getCoord2D(t.second)))),u)return C.length;const E=[],D=[];for(const n of C)E.push(n.first),D.push(n.second);return gm(t,e,s,E,D,E.length,i,r,o,a,h,u,m)}function Ju(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Eu(t))return;const n=t.getSemiAxes(),i=[0,0,0,0];{const e=Math.atan2(-n.y*t.m_sinr,n.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(n.y*t.m_cosr,n.x*t.m_sinr),o=r+Math.PI;i[0]=cu(t,e),i[1]=cu(t,s),i[2]=cu(t,r),i[3]=cu(t,o)}const r=new $;for(let o=0;o<4;o++){const n=i[o];e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,r),s.mergeNe(r))}}function tm(t,e,s,i,r){if(0===t.m_semiMajorAxis)return s.vmin;let o=$.getNAN();t.queryCoord2D(s.vmin,o);let a=$.getNAN();if(t.queryCoord2D(s.vmax,a),Eu(t)){return new fm({start:o,end:a}).getClosestCoordinate(e,i)}const h=ru(t,e);if(o=ru(t,o),a=ru(t,a),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return s.vmin;const e=cu(t,Math.atan2(h.y,h.x));if(i||s.containsCoordinate(e))return e;return $.distance(h,o)<=$.distance(h,a)?s.vmin:s.vmax}const u=t.getSemiMajorAxis(),m=t.getSemiMinorAxis(),l=(u-m)*(u+m),c=Bt(l),g=h.x,d=h.y,_=Bt(m*d),p=m*l*d*2,f=[new rt(_),new rt(p),new rt(c-Bt(u*g)-_),new rt(-p),new rt(-c)],P=ut(rt,4),y=pn(f,4,new U(-1,1),!1,P,4);let x=s.vmin,C=$.sqrDistance(h,o);{const t=$.sqrDistance(h,a);t<C&&(x=s.vmax,C=t)}n(!i);let v=et(8,Number.NaN);for(let n=0;n<y;++n){const e=P[n].value(),s=Math.sqrt(1-e*e),i=Math.atan2(e,s),r=Math.atan2(e,-s);v[2*n]=cu(t,i),v[2*n+1]=cu(t,r)}v=v.slice(0,2*y),Wt(v);for(let n=0,b=2*y;n<b;++n)if(v[n]>s.vmin&&v[n]<s.vmax){const s=$.sqrDistance(e,t.getCoord2D(v[n]));C>s&&(C=s,x=v[n])}return x}function em(t,e,s){n(!Eu(t));const i=new ce;i.setRotateAngle(-t.getAxisXRotation());const r=new $;i.queryTransform(e,r);const o=Math.atan2(-r.x*t.getMinorMajorRatio(),r.y),a=o+At();let h=cu(t,o),u=cu(t,a);u<h&&(u=Q(h,h=u));let m=0;return h>=0&&h<=1&&(s[m++]=h),u>=0&&u<=1&&(s[m++]=u),m}function sm(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&(t.isMajor()!==e.isMajor()&&(!!t.m_center.equals(e.m_center)&&(t.m_sinr===e.m_sinr&&(t.m_cosr===e.m_cosr&&(t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise()))))))}function nm(t,e,s){if(Eu(t))s.setE(be.constructPoint2D(t.getEndXY()).subE(be.constructPoint2D(t.getStartXY())));else{const n=new rt;du(t,e,n);const i=new be;if(i.setCoordsE(new rt(t.m_semiMajorAxis).negate().mulE((new rt).setSin(n)),new rt(t.getSemiMinorAxis()).mulE((new rt).setCos(n))),t.m_rotation){const e=new rt(t.m_rotation);i.rotateDirect((new rt).setCos(e),(new rt).setSin(e))}i.scaleThis(new rt(t.getSweepAngle())),s.setE(i)}}function im(t,e,s,n){const i=t.getStartXY(),r=t.getEndXY(),o=i.equals(r),a=e.equals(s);if(!o&&!a){const n=new ce;n.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=$.distance(e,s),a=$.distance(i,r),h=o/a;n.scale(h,h);const u=r.sub(i);u.divThis(a);const m=s.sub(e);m.divThis(o);const l=u.crossProduct(m),c=m.dotProduct(u);return n.rotate(c,l),n.shiftCoords(e.x,e.y),void Tu(t,n,!0,e,s)}const h=new $;if(t.queryCoord2D(.5,h),a){if(o){const n=t.m_center.add(e.sub(i));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),n),t.setProjectionBehavior(0)}else if(t.isMajor()){const n=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,n)}else t.constructCircularArcThreePoint(e,s,e);return}const u=e.add(s).mul(.5),m=s.sub(e);m.rightPerpendicularThis();const l=u.add(m),c=$.getClosestCoordinate(u,l,t.getCenter(),!0),g=new $;Ct(u,l,c,g);const d=$.distance(e,g);t.constructEllipticArcEndPointsCenter(e,s,d,1,0,!0,!t.isClockwise(),g),t.setProjectionBehavior(0)}function rm(t,e,s,i){const r=t.getStartXY(),o=t.getEndXY(),a=r.equals(o),h=e.equals(s);if(!a&&!h){const n=new ce;return n.initializeFromTwoPoints(r,o,e,s),Tu(t,n,!0,e,s),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void Su(t,e,s,1);if(a&&h){const n=t.m_center.add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),n)}if(!a){const n=.5*(Gt()-Math.abs(t.getSweepAngle())),i=(t.getSweepAngle()+n*Xt(t.getSweepAngle()))/t.getSweepAngle(),r=new $;t.queryCoord2D(i,r),t.constructEllipticArcEndPointsCenter(r,r,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const o=t.getCenter().add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),o)}const u=$.sqrDistance(e,s);let m=.25,l=.75;if(u<$.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],s=en(new nu(t,u),U.construct(0,.25),1,e);s>0&&(n(1===s),m=e[0],l=1-e[0])}const c=t.getCoord2D(m),g=t.getCoord2D(l);n(!c.equals(g)),t.constructEllipticArcEndPointsCenter(c,g,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),rm(t,e,s)}function om(t,e,s,n,i){return am(t,!1,e,s,n,i)}function am(t,s,n,i,o,a){const h=n.getGeometryType(),u=i.getGeometryType(),m=Math.max(o,Qe(n,i));if(h===e.enumLine&&u===e.enumLine)return Ds(n,i,m,a);let l=n,c=i,g=n.getStartXY(),d=n.getEndXY();if(g.compare(d)>0&&(l=n.clone().reverse()),g=i.getStartXY(),d=i.getEndXY(),g.compare(d)>0&&(c=i.clone().reverse()),s){if(n.equals(i))return 2;if(Xe(n,i,m))return 4}switch(h){case e.enumLine:switch(u){case e.enumEllipticArc:return Ou(t,c,l,m,a);case e.enumBezier:return Eo(t,c,l,m,a);case e.enumRationalBezier2:return th(t,c,l,m,a);case e.enumBezier2:return qi(t,c,l,m,a);default:r("")}break;case e.enumEllipticArc:switch(u){case e.enumLine:return Ou(t,l,c,m,a);case e.enumEllipticArc:return Qu(t,l,c,m,a);case e.enumBezier:return Do(t,c,l,m,a);case e.enumRationalBezier2:return eh(t,c,l,m,a);case e.enumBezier2:return Fi(t,c,l,m,a);default:r("")}break;case e.enumBezier:switch(u){case e.enumLine:return Eo(t,l,c,m,a);case e.enumEllipticArc:return Do(t,l,c,m,a);case e.enumBezier:return wo(t,l,c,m,a);case e.enumRationalBezier2:return Ao(t,l,c,m,a);case e.enumBezier2:return To(t,l,c,m,a);default:r("")}break;case e.enumRationalBezier2:switch(u){case e.enumLine:return th(t,l,c,m,a);case e.enumEllipticArc:return eh(t,l,c,m,a);case e.enumBezier:return Ao(t,c,l,m,a);case e.enumRationalBezier2:return sh(t,l,c,m,a);case e.enumBezier2:return nh(t,l,c,m,a);default:r("")}break;case e.enumBezier2:switch(u){case e.enumLine:return qi(t,l,c,m,a);case e.enumEllipticArc:return Fi(t,l,c,m,a);case e.enumBezier:return To(t,c,l,m,a);case e.enumRationalBezier2:return nh(t,c,l,m,a);case e.enumBezier2:return Vi(t,l,c,m,a);default:r("")}break;default:r("")}}function hm(t,s,n=!0){if(!n&&!um(t,s))return 0;const i=t.isLine()&&s.isLine();if(t.getStartXY().equals(s.getStartXY())&&t.getEndXY().equals(s.getEndXY())){const n=1;if(i)return n;const r=t.getGeometryType();if(r!==s.getGeometryType())return 0;if(r===e.enumBezier){const e=t,i=s;return e.getControlPoint1().equals(i.getControlPoint1())&&e.getControlPoint2().equals(i.getControlPoint2())?n:0}if(r===e.enumEllipticArc){return sm(t,s,!1)?n:0}if(r===e.enumRationalBezier2){const e=t,i=s;if(e.getControlPoint1().equals(i.getControlPoint1())&&e.getStandardFormWeight()===i.getStandardFormWeight())return n}else if(r===e.enumBezier2){const e=s;if(t.getControlPoint1().equals(e.getControlPoint1()))return n}return 0}if(t.getStartXY().equals(s.getEndXY())&&t.getEndXY().equals(s.getStartXY())){const n=-1;if(i)return n;const r=t.getGeometryType();if(r!==s.getGeometryType())return 0;if(r===e.enumBezier){const e=t,i=s;return e.getControlPoint1().equals(i.getControlPoint2())&&e.getControlPoint2().equals(i.getControlPoint1())?n:0}if(r===e.enumEllipticArc){return sm(t,s,!0)?n:-1}if(r===e.enumRationalBezier2){const e=t,i=s;if(e.getControlPoint1().equals(i.getControlPoint1())&&e.getStandardFormWeight()===i.getStandardFormWeight())return n}else if(r===e.enumBezier2){const e=s;if(t.getControlPoint1().equals(e.getControlPoint1()))return n}return 0}return 0}function um(t,s){const n=t.getGeometryType();return n===s.getGeometryType()&&(n!==e.enumEllipticArc||t.projectionBehavior()===s.projectionBehavior())}function mm(s,n,i,o,a,h,u){!a&&h&&t("");const m=n.getGeometryType(),l=i.getGeometryType(),c=Math.max(u,Qe(n,i));if(o&&(o.length=0),a&&(a.length=0),h&&(h.length=0),m===e.enumLine&&l===e.enumLine)return ws(n,i,o,a,h,c,!1,!1);let g=n,d=i,_=n.getStartXY(),p=n.getEndXY(),f=!1,P=!1;_.compare(p)>0&&(g=n.clone(!0).reverse(),f=!0),_=i.getStartXY(),p=i.getEndXY(),_.compare(p)>0&&(d=i.clone(!0).reverse(),P=!0);let y=0;switch(m){case e.enumLine:switch(l){case e.enumEllipticArc:y=Ku(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier:y=Io(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=ih(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier2:y=Li(s,d,g,o,h,a,c,!1,!1,!0);break;default:r("")}break;case e.enumEllipticArc:switch(l){case e.enumLine:y=Ku(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=$u(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=Mo(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=rh(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier2:y=Ri(s,d,g,o,h,a,c,!1,!1,!0);break;default:r("")}break;case e.enumRationalBezier2:switch(l){case e.enumLine:y=ih(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=rh(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=No(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=oh(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier2:y=ah(s,g,d,o,a,h,c,!1,!1,!1);break;default:r("")}break;case e.enumBezier2:switch(l){case e.enumLine:y=Li(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=Ri(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=Xo(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=ah(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier2:y=zi(s,g,d,o,a,h,c,!1,!1,!1);break;default:r("")}break;case e.enumBezier:switch(l){case e.enumLine:y=Io(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=Mo(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=Yo(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumRationalBezier2:y=No(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier2:y=Xo(s,g,d,o,a,h,c,!1,!1,!1);break;default:r("")}break;default:r("")}if(f){if(a){for(let t=0;t<y;t++)a[t]=1-a[t];a.reverse()}o&&o.reverse(),h&&h.reverse()}if(P&&h)for(let t=0;t<y;t++)h[t]=1-h[t];return y}function lm(t,e,s){if(e===s)return 0;e>s&&(s=Q(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function cm(t,e,s,n,i){const r=[],o=[],a=[];for(let u=0,m=i;u<m;u++)r.push(t.calculateSubLengthFromStart(s[u])),o.push(e.calculateSubLengthFromStart(n[u])),lt(s[u],0,1)&&lt(n[u],0,1)&&t.getCoord2D(s[u]).equals(e.getCoord2D(n[u]))&&a.push(u);if(0===a.length||a.length===i)return;a.sort((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:n[t]<n[e]?-1:n[t]>n[e]?1:0);let h=-1;for(const u of a){if(h>=0&&s[u]===s[h]&&s[u]===s[h]){h=u;continue}h=u;const a=[];a.length=i;for(let t=0;t<a.length;++t)a[t]=t;a.sort((t,e)=>{const s=r[u],n=o[u],i=r[t]-s,a=o[t]-n,h=i*i+a*a,m=r[e]-s,l=o[e]-n,c=m*m+l*l;return h<c?-1:h>c?1:0});for(let r=0;r<i;r++){const i=a[r];if(i===u||s[i]===s[u]&&n[i]===n[u]||lt(s[i],0,1)&&lt(n[i],0,1))continue;const o=(s,n,i,r)=>{const o=new be,a=new rt;a.setWithEps(1);const h=new rt;h.set(n,a.eps()),t.queryCoord2DE(h,o);const u=new be;t.queryCoord2DE(new rt(s),u);let m=!1;return o.eq(u)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new rt(i),u),m=o.eq(u)),!m},h=$.getNAN();t.queryCoord2D(s[i],h);const m=$.getNAN();e.queryCoord2D(n[i],m);if(0===$.distance(h,m)&&o(s[u],s[i],n[u],n[i]))break;const l=new U(n[i],n[u]);l.normalizeNoNAN();const c=new U(s[i],s[u]);c.normalizeNoNAN();let g=-1,d=Number.POSITIVE_INFINITY,_=Number.POSITIVE_INFINITY,p=s[i];h.assign(t.getCoord2D(p));for(let r=0;r<5;r++){const r=e.getClosestCoordinateOnInterval(h,l,-1);m.assign(e.getCoord2D(r));const a=$.distance(h,m);if(p=t.getClosestCoordinateOnInterval(m,c,-1),p===s[u]&&r===n[u]){g=1;break}h.assign(t.getCoord2D(p));const f=$.distance(m,h);if(!(f<_&&a<d)){g=0;break}if(0===f&&0===a){o(s[u],s[i],n[u],n[i])?(s[i]=p,n[i]=r,g=0):g=1;break}_=f,d=a}if(-1===g&&(g=lt(s[i],0,1)||lt(n[i],0,1)?0:1),1!==g)break;s[i]=s[u],n[i]=n[u]}}}function gm(t,e,s,n,i,r,o,a,h,u,m,l,c){if(!r)return 0;const g=(t,e)=>{for(let s=0;s<r;++s){let n=e[s];if(lt(n,0,1)){n=ie(n);continue}const i=t.getCoord2D(n);n<.5?i.equals(t.getStartXY())&&lm(t,0,n)<=Oe(t)&&(e[s]=0):i.equals(t.getEndXY())&&lm(t,n,1)<=Oe(t)&&(e[s]=1)}};g(e,n),g(s,i),cm(e,s,n,i,r);const d=[];for(let f=0,P=r;f<P;f++)d.push(f);const _=(t,e)=>c?re(i[t],n[t],i[e],n[e]):re(n[t],i[t],n[e],i[e]);if(d.length>1){d.sort(_);const t=Math.max(Oe(e),Oe(s));let r=0;for(let o=1,a=d.length;o<a;o++){const a=n[d[r]],h=n[d[o]],u=i[d[r]],m=i[d[o]];if(a!==h||u!==m){if(lm(e,a,h)<=t&&lm(s,u,m)<=t&&!(lt(a,0,1)&&lt(u,0,1)||lt(h,0,1)&&lt(m,0,1))){const t=$.distance(e.getCoord2D(a),s.getCoord2D(u)),n=$.distance(e.getCoord2D(h),s.getCoord2D(m));if(t<=n)continue;if(n<t){d[r]=d[o];continue}continue}r++,d[r]=d[o]}}if(d.length=r+1,1===d.length&&0!==d[0]&&(n[0]=n[d[0]],i[0]=i[d[0]],d[0]=0),d.length>2){const t=U.constructEmpty(),r=U.constructEmpty();t.setCoords(n[d[0]],n[d.at(-1)]),r.setCoords(i[d[0]],i[d.at(-1)]);let o=!0;for(let e=1,s=d.length-1;e<s;e++)if(!t.containsCoordinate(n[d[e]])||!r.containsCoordinate(i[d[e]])){o=!1;break}if(o){const n=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let i=0;i<n.length;i++){let a=nt(t.vmin,t.vmax,n[i]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,u)){o=!1;break}a=nt(r.vmin,r.vmax,n[i]);const m=s.getCoord2D(a);if(!e.isCloserThanDistance(m,t,u)){o=!1;break}}}o&&(d[1]=d.at(-1),d.length=2)}}if(1===d.length&&t){const t=0,r=0;Ne(e,s,n[0],i[0],u,1,[t],[r])&&(d.push(1),n[1]=t,i[1]=r,d.sort(_))}if(m&&1===d.length){let t=!0;for(let r=0,o=d.length;r<o;r++){if(lt(n[d[r]],0,1)&&lt(i[d[r]],0,1)){if(0===$.distance(e.getCoord2D(n[d[r]]),s.getCoord2D(i[d[r]])))continue}t=!1;break}if(t)return 0}let p=0;for(let f=0,P=d.length;f<P;f++){if(a&&a.push(n[d[f]]),h&&h.push(i[d[f]]),o){const t=$.getNAN();e.queryCoord2D(n[d[f]],t),o.push(t)}p++}return p}function dm(t,e,s,n,i,r,o,a,h){if(lt(s,0,1)&&lt(n,0,1)){if(0===$.distance(t.getCoord2D(s),e.getCoord2D(n))){const u=1e-12,m=new be,l=Number.EPSILON;if(t.queryDerivative(new rt(s,l),m),m.isTrueZero()){const e=1===s?-u:u;t.queryDerivative(new rt(s,l).add(e),m)}1===s&&m.negateThis();const c=new be;if(e.queryDerivative(new rt(n,l),c),c.isTrueZero()){const t=1===s?-u:u;e.queryDerivative(new rt(n,l).add(t),c)}1===n&&c.negateThis(),m.isZero()||m.normalize(),c.isZero()||c.normalize();const g=m.dotProduct(c),d=m.crossProduct(c);d.scaleError(3);const _=()=>{if(h)return.001;{const s=t.calculateUpperLength2D(),n=e.calculateUpperLength2D();return Math.min(.01*i/Math.min(s,n),1e-10)}};if(g.ge(at)&&(d.isZero()||Math.abs(d.value())<_())){return Ye(t,e,s,n,i,r,o,a)}}}return 0}function _m(t,e,s,i,r){let o=-1,a=-1,h=-1,u=-1;{const n=[0,e],r=[e,0],m=[0,i],l=[i,0];for(let e=0;e<2&&-1===o;++e)for(let i=0;i<2;++i)if(t[n[e]].equals(s[m[i]])){o=n[e],a=r[e],h=m[i],u=l[i];break}}if(-1===o){const n=new fe;n.setFromPoints(t,e+1);const o=new fe;return o.setFromPoints(s,i+1),o.inflate(r),n.isIntersectingW(o)?-1:0}{const m=et(e+1,Number.NaN),l=Cr(t,e+1,m);n(l>1);let c=0,g=0;for(let t=0;t<l;++t)o===m[t]&&(g=t,c++),a===m[t]&&c++;if(2!==c)return-1;const d=et(i+1,Number.NaN),_=Cr(s,i+1,d);n(_>1),c=0;let p=0;for(let t=0;t<_;++t)h===d[t]&&(p=t,c++),u===d[t]&&c++;if(2!==c)return-1;const f=t[m[(g+l-1)%l]],P=t[m[(g+1)%l]],y=s[d[(p+_-1)%_]],x=s[d[(p+1)%_]],C=t[o],v=[f,P,y,x],b=[0,1,2,3];b.sort((t,e)=>$.compareVectorsOrigin(C,v[t],v[e]));let S=b[0];for(let t=1;t<4;t++){if(b[t]!==(S+1)%4)return-1;S=b[t]}{const t=f.sub(C),e=x.sub(C),s=e.dotProduct(t);if(s>0){const n=e.crossProduct(t),i=Math.abs(Math.atan2(n,s)),o=i*t.length(),a=i*e.length();if(o<=r||a<=r)return-1}}{const t=P.sub(C),e=y.sub(C),s=e.dotProduct(t);if(s>0){const n=e.crossProduct(t),i=Math.abs(Math.atan2(n,s)),o=i*t.length(),a=i*e.length();if(o<=r||a<=r)return-1}}return 1}}var pm=b;class fm extends _s{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return n(0),0}calculateUpperLength3D(){return n(0),0}changeEndPoints3D(t,e){n(0)}getClosestCoordinate3D(t,e,s){return n(0),0}getBoundary(){return Js(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?Ps(this,t):ys(this,t);const n=pm.getInterpolation(e),i=this.getStartAttributeAsDbl(e,s),r=this.getEndAttributeAsDbl(e,s);return vt(n,i,r,t,pm.getDefaultValue(e))}constructFromCoords(t,e,s,n){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,n)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){n(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return fm.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=le.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const e=this.m_description.getSemantics(s);for(let n=0,i=pm.getComponentCount(e);s<i;s++){const s=this.queryInterval(e,n);t.setIntervalEnvelope(e,n,s)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,je(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,je(this,1,1,0))):s("env type not impl")}applyTransformation(t){n(t instanceof ce);const e=new $;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new fm({vd:this.m_description})}calculateLength2D(){return Math.sqrt(qs(this))}calculateLength3D(t){return n(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return n(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return ps(this,t,e)}queryCoord3D(t,e){n(0)}getCoordZ(t){return xs(this,t)}queryCoord2DE(t,e){vs(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());const s=Ee.constructPoint2D(this.getEndXY());s.subThis(e),s.mulThis(tt.constructDouble(t)),e.addThis(s)}getCoordX(t){return Ps(this,t)}getCoordY(t){return ys(this,t)}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createLine();n&&i.assignVertexDescription(this.m_description);const r=$.getNAN();if(ps(this,t,r),i.setStartXYCoords(r.x,r.y),ps(this,e,r),i.setEndXYCoords(r.x,r.y),!n)for(let o=1,a=this.m_description.getAttributeCount();o<a;o++){const s=this.m_description.getSemantics(o),n=pm.getComponentCount(s);for(let r=0;r<n;r++){const n=this.getAttributeAsDbl(t,s,r);i.setStartAttribute(s,r,n);const o=this.getAttributeAsDbl(e,s,r);i.setEndAttribute(s,r,o)}}}queryDerivative(t,e){Cs(this,t,e)}getClosestCoordinate(t,e){return $.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const n=new $;this.queryCoord2D(e.vmin,n);const i=new $;this.queryCoord2D(e.vmax,i);const r=$.getClosestCoordinate(n,i,t,!1);return ts.recalculateParentT(e.vmin,e.vmax,r)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const n=(t-this.m_YStart)/s;let i=Ps(this,n);return 1===n&&(i=this.m_XEnd),i}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new fm;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new $;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=$.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new $;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return Ms(this,t,e,s)>=0}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(e,s){return s&&(e<2&&t(""),s[0]=0,s[1]=1),2}intersectionWithAxis2D(t,e,s,n){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const i=(e-this.m_YStart)/t;return i<0||i>1?0:(s&&(s[0]=Ps(this,i)),n&&(n[0]=i),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const i=(e-this.m_XStart)/t;return i<0||i>1?0:(s&&(s[0]=ys(this,i)),n&&(n[0]=i),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let s=gt(t.vmin,0,1);const n=new $;return this.queryCoord2D(s,n),e.setCoords({pt:n}),s=gt(t.vmax,0,1),this.queryCoord2D(s,n),void e.mergeNe(n)}s("3d dst not impl")}orientBottomUp(){Es(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return Ss(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoordsForStitcher(t,e){bs(this,t[0],t[e-1])}writeInBufferStream(t,e){return n(0),0}readFromBufferStream(t,e){n(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){bs(this,t,e)}static isIntersectingLineLine(t,e,s,n){return Ds(t,e,s,n)}static isIntersectingLineLine_(t,e,s,n){return Ds(t,e,s,n)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){e.length<1&&i("");const n=Ms(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}}fm.type=e.enumLine;class Pm{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new fm,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):r("bad constructor params"))}assignCopy(t){return t instanceof Pm?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Pm){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:r("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){n(0)}createImpl(s){switch(s){case e.enumLine:1&this.m_mask||(this.m_lineBuffer=new fm,this.m_mask|=1,this.m_active=1);break;case e.enumEllipticArc:2&this.m_mask||(this.m_curves=new qh,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case e.enumBezier:4&this.m_mask||(this.m_curves=new ra,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case e.enumBezier2:8&this.m_mask||(this.m_curves=new An,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case e.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Dn,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:t("")}}create(s){s===e.enumLine?this.createLine():s===e.enumEllipticArc?this.createEllipticArc():s===e.enumBezier?this.createCubicBezier():s===e.enumRationalBezier2?this.createQuadraticRationalBezier():s===e.enumBezier2?this.createQuadraticBezier():t("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){n(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(e.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(e.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(e.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(e.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(e.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&r("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():r("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Pm?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):(s("seg comparison not yet impl"),!1)}}export{Ee as $,$s as A,Gh as B,Ar as C,Zh as D,yr as E,jh as F,_e as G,om as H,Me as I,ra as J,Ph as K,fm as L,gs as M,Wu as N,ts as O,Qs as P,Dn as Q,am as R,Pm as S,mm as T,Oe as U,fr as V,Es as W,be as X,hm as Y,um as Z,dm as _,mr as a,gu as a0,Pr as a1,Nh as a2,Ih as a3,ns as a4,Ru as a5,zu as a6,Iu as a7,au as a8,Gs as a9,Th as b,Js as c,Bh as d,Er as e,xr as f,pe as g,os as h,br as i,Is as j,Fh as k,qh as l,Vh as m,gr as n,dr as o,kh as p,nn as q,hs as r,is as s,en as t,co as u,rs as v,kr as w,$n as x,Rs as y,zs as z};
5
+ import{a as t,G as e,t as s,g as n,q as i,d as r,s as o,u as a,i as h,w as u,f as m,e as l,h as c,n as g,p as d,x as _,j as p,o as f}from"./Geometry.js";import{j as P,k as y,r as x,E as C,l as v,V as b,m as S,d as E,n as D,o as w,p as A,q as T,t as I,O as M,u as Y,v as N,w as X,x as q,P as F,y as V,z as L,D as R,F as z,G as B,H as k,S as G,B as W,A as j,T as Z,I as H}from"./Envelope.js";import{E as U,K as O,c as Q,A as J,P as K,B as $,M as tt,d as et,b as st,q as nt,C as it,D as rt,F as ot,G as at,g as ht,m as ut,H as mt,I as lt,J as ct,s as gt,L as dt,i as _t,N as pt,O as ft,Q as Pt,R as yt,T as xt,U as Ct,V as vt,W as bt,X as St,Y as Et,Z as Dt,_ as wt,$ as At,a0 as Tt,o as It,a1 as Mt,l as Yt,j as Nt,e as Xt,a2 as qt,a3 as Ft,a4 as Vt,a5 as Lt,a6 as Rt,a7 as zt,a as Bt,a8 as kt,a9 as Gt,v as Wt,aa as jt,ab as Zt,w as Ht,ac as Ut,ad as Ot,ae as Qt,n as Jt,af as Kt,ag as $t,ah as te,ai as ee,aj as se,u as ne,ak as ie,al as re,am as oe,an as ae,ao as he,ap as ue,aq as me}from"./Point2D.js";import{Envelope2D as le}from"./Envelope2D.js";import{T as ce}from"./Transformation2D.js";import{G as ge}from"./SimpleGeometryCursor.js";class de extends ge{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class _e{constructor(e){this.m_geoms=[],this.m_description=P(),e&&(e.vd?this.m_description=e.vd:e.copy?e.copy.copyTo(this):t("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===e.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(e){return(e<0||e>=this.m_geoms.length)&&t("Geometry_collection.get_geometry"),this.m_geoms[e]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return e.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new U;const n=new U;n.setEmpty();for(const i of this.m_geoms)s=i.queryInterval(t,e),n.merge(s);return n}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new C;t.setEmpty(),t.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){const e=new le;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}s("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new le;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}s("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(const e of this.m_geoms)e.applyTransformation(t);s("3d xform not impl")}transformAttribute(t,e,s,n,i){for(const r of this.m_geoms)r.transformAttribute(t,e,s,n,i)}createInstance(){return new _e({vd:this.getDescription()})}copyTo(s){s.getGeometryType()!==e.enumGeometryCollection&&t("");const n=s;if(n!==this){n.m_geoms.length=0,n.assignVertexDescription(this.m_description);for(const t of this.m_geoms)n.m_geoms.push(t.clone())}}calculateArea2D(){const t=new O(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new O(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return n(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const s of this.m_geoms){const t=s.getBoundary();t&&e.m_geoms.push(t)}return t}clone(){return new _e({copy:this})}equals(t,s){if(t===this)return!0;if(t.getGeometryType()!==e.enumGeometryCollection)return!1;const n=t;if(this.m_description!==n.m_description)return!1;if(this.m_geoms.length!==n.m_geoms.length)return!1;for(let e=0;e<this.m_geoms.length;++e)if(!this.m_geoms[e].equals(n.m_geoms[e],s))return!1;return!0}swap(s){s.getGeometryType()!==e.enumGeometryCollection&&t("");const n=s;n!==this&&(this.m_geoms=Q(n.m_geoms,n.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const n of this.m_geoms)n.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=v(e,t);this.assignVertexDescription(s)}}function pe(t,e=-1){return new de(t,e)}_e.type=e.enumGeometryCollection;class fe{constructor(){this.m_EnvelopeType=5,this.envAabb=le.constructEmpty(),this.envRot=le.constructEmpty()}static constructEmpty(){return new fe}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:xe(t),y:Ce(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(xe(t),Ce(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let n=s;n<e;n++){const e=xe(t[n]),s=Ce(t[n]);this.envRot.mergeNeCoords(e,s)}break}{const e=xe(t[s]),n=Ce(t[s]);this.envRot.setCoords({x:e,y:n}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(xe(t),Ce(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*J();this.envRot.inflateCoords(e,e),e<0&&fe.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}sqrMaxMinDistance(t){const e=this.envAabb.sqrMaxMinDistance(t),s=this.envRot.sqrMaxMinDistance(ve(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(ve(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(ve(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=Pe(t.x,t.y),n=ye(t.x,t.y);e.setCoords(s,n)}}function Pe(t,e){return t-e}function ye(t,e){return t+e}function xe(t){return t.x-t.y}function Ce(t){return t.x+t.y}function ve(t){return new K(xe(t),Ce(t))}class be{constructor(){this.x=rt.getNAN(),this.y=rt.getNAN()}static getNAN(){return new be}static constructPoint2D(t){const e=new be;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new be;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new be;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new be).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new be;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new be;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=ot.clone(),this.y=at.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),n=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),n=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return K.construct(this.x.value(),this.y.value())}}class Se{constructor(){this.a11=new rt(1),this.a12=new rt(0),this.a21=new rt(0),this.a22=new rt(1)}clone(){const t=new Se;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),n=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),i=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=n,this.a22=i,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),n=this.a21.negate().divThisE(t),i=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=n,this.a22=i}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=Q(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let n=new rt(1),i=new rt(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new rt(1);if(this.a11.ne(this.a22)){const r=this.a11.subE(this.a22).divE(s);r.mulThisByPower2(.5);const o=r.sqr();e.setE(r),e.absThis(),e.subThisE(o.add(1).sqrtThis()),r.gt(at)&&e.negateThis();const a=e.sqr().addThis(1).sqrtThis().invThis();i=e.mulE(a),n.setE(a);const h=e.mulE(s);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else n=new rt(1/Math.sqrt(2)),i=n.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=n.toDouble(),e[0].y=i.toDouble(),e[1].x=i.negate().toDouble(),e[1].y=n.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=Q(t[0],t[0]=t[1]),e[1]=Q(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class Ee{static constructPoint2D(t){return new Ee(tt.constructDouble(t.x),tt.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new tt).setNAN(),void(this.y=(new tt).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new K(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new Ee(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new Ee(this.x.add(t.x),this.y.add(t.y))}sub(t){return new Ee(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}subThis(t){return this.x.subThis(t.x),this.y.subThis(t.y),this}addThis(t){return this.x.addThis(t.x),this.y.addThis(t.y),this}}var De=b;function we(t){let e=!1;for(let s=0;s<2;s++){const n=$(t[0][s],t[3][s]);n>0?($(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),$(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),$(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),$(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),$(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):n<0?($(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),$(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),$(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),$(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),$(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function Ae(t){const e=$(t[0].y,t[1].y),s=$(t[1].y,t[2].y),n=$(t[2].y,t[3].y);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0){const e=$(t[0].x,t[1].x),s=$(t[1].x,t[2].x),n=$(t[2].x,t[3].x);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0)return!0}return!1}function Te(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const n=t.getEndXY();return!!n.equals(e.getStartXY())||!!n.equals(e.getEndXY())}function Ie(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Me(t,s,n){const i=ut(K,4);let r=t.queryControlPointsHelper(i);const o=ut(K,4);let h=s.queryControlPointsHelper(o);i[0].equals(o[0])||a("");const u=t.getGeometryType();if(u===s.getGeometryType()&&i.map((t,e)=>o[e].equals(t)).reduce((t,e)=>t&&e)){if(u!==e.enumRationalBezier2)return 0;{const e=s,n=[0,0,0],i=[0,0,0];if(t.queryWeights(n),e.queryWeights(i),n.map((t,e)=>i[e]===t).reduce((t,e)=>t&&e))return 0}}for(;r>2&&i[1].equals(i[0]);)i.splice(1,1),r--;for(;h>2&&o[1].equals(o[0]);)o.splice(1,1),h--;(i[1].equals(i[0])||o[1].equals(i[0]))&&a("");const m=K.compareVectorsOrigin(i[0],i[1],o[1]);if(0===m){const e=Ee.constructPoint2D(i[0]),n=new Ee;t.queryCoord2DMP(1e-16,n),n.sub(e);const r=new Ee;s.queryCoord2DMP(1e-16,r),r.sub(e);return r.crossProduct(n).sign()}return m}function Ye(t,e,s,i,r,o,a,h){let u=t.calculateUpperLength2D(),m=e.calculateUpperLength2D(),l=t,c=e,g=!1;u>m&&(c=Q(l,l=c),i=Q(s,s=i),m=Q(u,u=m),g=!0);const d=0===s;{a[0]=d?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(K.distance(t,e)<=r){const e=[.5,.75,.25,.1,.9];let s=!0;for(let n=0;n<e.length;n++)if(t.assign(l.getCoord2D(e[n])),!c.isCloserThanDistance(t,new U(0,1),r)){s=!1;break}if(s)return g&&(h[0]=Q(a[0],a[0]=h[0])),1}}if(u<=3*r)return 0;let _=gt(Math.max(r/u,.1),0,.5),p=.01*r,f=0,P=0,y=_,x=-1,C=0,v=1/32;for(let b=0;;b++){n(b<4095);const t=d?_:1-_,e=l.getCoord2D(t),s=c.getClosestCoordinate(e,!1);if(s===i)return C;const u=c.getCoord2D(s),m=K.distance(e,u);if(0===b&&(x=m),m<=p?(v=.5,P=m,f=_):(y=_,x=m),Math.abs(P-x)>.1*p&&y-f>1e-16)_=nt(f,y,v);else{if(a[C]=t,h[C]=s,g&&(h[C]=Q(a[C],a[C]=h[C])),1===o||1===C)return 1===C&&a[0]>a[1]&&(a[1]=Q(a[0],a[0]=a[1]),h[1]=Q(h[0],h[0]=h[1])),C+1;C++,f=y,P=x,y=.8,x=-1,_=.8,v=1/32,p=10*r,b=0}}}function Ne(t,e,s,n,i,r,o,a,h){if(lt(s,0,1)&&lt(n,0,1)){if(0===K.distance(t.getCoord2D(s),e.getCoord2D(n))){const h=1e-12,u=new be,m=ct();if(t.queryDerivative(new rt(s,m),u),u.isTrueZero()){const e=1===s?-h:h;t.queryDerivative(new rt(s,m).add(e),u)}1===s&&u.negateThis();const l=new be;if(e.queryDerivative(new rt(n,m),l),l.isTrueZero()){const t=1===s?-h:h;e.queryDerivative(new rt(n,m).add(t),l)}1===n&&l.negateThis(),u.isZero()||u.normalize(),l.isZero()||l.normalize();const c=u.dotProduct(l),g=u.crossProduct(l);g.scaleError(3);const d=()=>{{const s=t.calculateUpperLength2D(),n=e.calculateUpperLength2D();return Math.min(.01*i/Math.min(s,n),1e-10)}};if(c.ge(at)&&(g.isZero()||Math.abs(g.value())<d())){return Ye(t,e,s,n,i,r,o,a)}}}return 0}function Xe(t,e,s){if(n(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(Ne(t,e,0,0,s,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(Ne(t,e,1,1,s,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(Ne(t,e,0,1,s,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(Ne(t,e,1,0,s,2,[0,0],[0,0]))return!0}return!1}function qe(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function Fe(t,e,s){t.m_XStart=e,t.m_YStart=s}function Ve(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function Le(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Re(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}function ze(t,e){const s=new E;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=Be(t,e),s}function Be(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:De.getDefaultValue(1)}function ke(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function Ge(t,e,s){s.assignVertexDescription(t.m_description);const n=0===e?t.m_XStart:t.m_XEnd,i=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(n,i);for(let r=1;r<t.m_description.getAttributeCount();r++){const n=t.m_description.getSemantics(r);for(let i=0,r=De.getComponentCount(n);i<r;i++){const r=je(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function We(t,e,s){s.isEmpty()&&o(""),Re(t,e,s.getXY());const n=s.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let i=1,r=n.getAttributeCount();i<r;i++){const r=n.getSemantics(i),o=De.getComponentCount(r);for(let n=0;n<o;n++){Ze(t,e,r,n,s.getAttributeAsDbl(r,n))}}}function je(t,e,s,n){if((e<0||e>1)&&i(""),0===s)return(n<0||n>=2)&&i(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=De.getComponentCount(s);(n<0||n>=r)&&i("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:De.getDefaultValue(s)}function Ze(t,e,s,n,r){if((e<0||e>1)&&i(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:i(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:i(""):i(""),void t.endPointModified();const o=De.getComponentCount(s);(n<0||n>=o)&&i("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function He(t,e){if(t===e)return;e.isEmpty()&&o("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let n=1,i=s.getAttributeCount();n<i;n++){const i=s.getSemantics(n),r=De.getComponentCount(i);for(let s=0;s<r;s++){let n=je(e,0,i,s);Ze(t,0,i,s,n),n=je(e,1,i,s),Ze(t,1,i,s,n)}}}function Ue(t,e){const s=D();w(e,t.m_description,s);let n=null;const i=e.getTotalComponentCount()-2,r=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(i>0&&(n=et(2*i,Number.NaN),st(n,e.getDefaultPointAttributes(),0,2,i),st(n,e.getDefaultPointAttributes(),i,2,i),null!==t.m_description))for(let o=1;o<e.getAttributeCount();o++){const a=s[o];if(-1!==a){const s=t.m_description.getPointAttributeOffset(a)-2,h=e.getPointAttributeOffset(o)-2,u=De.getComponentCount(e.getSemantics(o));for(let e=0;e<u;++e)n[h]=t.m_attributes[s],n[i+h]=t.m_attributes[r+s]}}t.m_attributes=n,t.m_description=e}function Oe(t){return t.absNorm()*ht()}function Qe(t,e){return Math.max(t.absNorm(),e.absNorm())*ht()}function Je(t,e,s){const n=new fe;t.queryEnvelopeW(U.unit(),n);const i=new fe;return e.queryEnvelopeW(U.unit(),i),i.inflate(s),!n.isIntersectingW(i)}function Ke(t,e,s){const n=mt(t,s),i=mt(e,s);n.sort((t,e)=>t.compare(e)),i.sort((t,e)=>t.compare(e));for(let r=0;r<3;r++){if(n[r].compare(i[r])<0)return-1;if(0!==n[r].compare(i[r]))return 1}return 0}var $e=b;class ts{constructor(t){if(t.copy){if(this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description){this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice())}}else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:P(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:S(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=P());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:S(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);r("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=et(2*t,Number.NaN)),st(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),st(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return s("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return s("not implemented"),!1}setCoordsForIntersector3D(t,e,n){s("not implemented")}transformAttribute(t,e,n,i,r){s("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=v(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),n=e.getXY();this.changeEndPoints2D(s,n);let i=t.getDescription();i!==this.getDescription()&&this.mergeVertexDescription(i),i=e.getDescription(),i!==this.getDescription()&&this.mergeVertexDescription(i);for(let r=1,o=i.getAttributeCount();r<o;r++){const s=i.getSemantics(r),n=$e.getComponentCount(s);for(let i=0;i<n;i++){Ze(this,0,s,i,t.getAttributeAsDbl(s,i));Ze(this,1,s,i,e.getAttributeAsDbl(s,i))}}}getStartXY(){return new K(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return ze(this,0)}setStartXYZ(t){ke(this,0,t)}setStartXYZCoords(t,e,s){ke(this,0,E.construct(t,e,s))}queryStart(t){Ge(this,0,t)}setStart(t){We(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return je(this,0,t,e)}getStartAttributeAsInt(t,e){return n(0),0}setStartAttribute(t,e,s){Ze(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=$e.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,n)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=$e.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,n)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return n(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return n(0),0}getEndXY(){return new K(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return ze(this,1)}setEndXYZ(t){ke(this,1,t)}setEndXYZCoords(t,e,s){ke(this,1,E.construct(t,e,s))}queryEnd(t){Ge(this,1,t)}setEnd(t){We(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return je(this,1,t,e)}getEndAttributeAsInt(t,e){return n(0),Math.trunc(0)}setEndAttribute(t,e,s){Ze(this,1,t,e,s)}getDimension(){return 1}copyTo(e){if(this===e)return;e.getGeometryType()!==this.getGeometryType()&&t("");const s=e;s.assignVertexDescription(this.m_description),s.m_attributes&&st(s.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),s.m_XStart=this.m_XStart,s.m_YStart=this.m_YStart,s.m_XEnd=this.m_XEnd,s.m_YEnd=this.m_YEnd,this.copyToImpl(s)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=U.constructEmpty();return s.vmin=je(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(je(this,1,t,e)),s}calculateLength3D(t){return n(0),0}getCoord3D(t){return n(0),{}}getCoord2D(t){const e=K.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){n(0)}getCoordZ(t){return n(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const n=this.m_description.getSemantics(s),i=$e.getComponentCount(n);for(let s=0;s<i;s++){const i=this.getAttributeAsDbl(t,n,s);e.setAttributeBasic(n,s,i)}}}isCloserThanDistance(t,e,s){const n=le.constructEmpty();this.queryLooseEnvelopeOnInterval(e,n);if(n.distance(t)>s)return!1;const i=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(i)&&K.distance(t,this.getCoord2D(i))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=$e.getComponentCount(e);t<s;t++){const s=je(this,0,e,t);Ze(this,0,e,t,je(this,1,e,t)),Ze(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,s,i){if(!e&&this.isIntersecting(t,0,!1)){if(null!==s||null!==i){const e=et(9,Number.NaN),o=et(9,Number.NaN),a=this.intersect(t,null,e,o,0);n(a<=9),0===a&&r(""),null!==s&&(s[0]=e[0]),null!==i&&(i[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,h=-1,u=a;return o=this.getStartXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==i&&(i[0]=h),null!==s&&(s[0]=0)),o=this.getEndXY(),h=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==i&&(i[0]=h),null!==s&&(s[0]=1)),o=t.getStartXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==s&&(s[0]=h),null!==i&&(i[0]=0)),o=t.getEndXY(),h=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(h)),u=o.length(),u<a&&(a=u,null!==s&&(s[0]=h),null!==i&&(i[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return nt(t,e,s)}moveTo(t){const e=this.isClosed(),s=new ce;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){n(0)}getDescription(){return this.m_description}assignVertexDescription(t){Ue(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}swap(e){if(this===e)return;e.getGeometryType()!==this.getGeometryType()&&t("wrong geometry type");const s=e;s.m_description=Q(this.m_description,this.m_description=s.m_description),s.m_XStart=Q(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=Q(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=Q(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=Q(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attributes=Q(this.m_attributes,this.m_attributes=s.m_attributes),this.swapImpl(s)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const n=t;if(this===n)return!0;if(this.m_description!==n.m_description)return!1;if(Math.abs(this.m_XStart-n.m_XStart)>e||Math.abs(this.m_XEnd-n.m_XEnd)>e||Math.abs(this.m_YStart-n.m_YStart)>e||Math.abs(this.m_YEnd-n.m_YEnd)>e)return!1;for(let i=0,r=2*(this.m_description.getTotalComponentCount()-2);i<r;i++)if(!it(this.m_attributes[i],n.m_attributes[i],e))return!1;return s?this.equalsImpl(n):this.equalsImplTol(n,e)}getImpl(){return this}setAttributeBasic(e,s,n){if(this.addAttribute(e),0===e&&this.isCurve()){(s<0||s>1)&&t("");const e=new ce,i=0===s?n:0,r=1===s?n:0;e.setShiftCoords(i,r),0===s?e.xx=0:e.yy=0,this.applyTransformation(e)}else this.setStartAttribute(e,s,n),this.setEndAttribute(e,s,n)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=$e.getComponentCount(t);for(let n=0;n<s;n++){const s=this.getStartAttributeAsDbl(t,n);Number.isNaN(s)&&this.setStartAttribute(t,n,e);const i=this.getEndAttributeAsDbl(t,n);Number.isNaN(i)&&this.setEndAttribute(t,n,e)}}}ts.s_maxMonotonicPartParams=8;class es{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function ss(e,s,n,i,r){(s<0||n<0||i<1||s+i*(n-1)+1>e.size())&&t("Index out of bound");for(let t=s,o=s+i*(n-1)+1;t<o;t+=i)e.writeAsDbl(t,r(e.readAsDbl(t)))}function ns(t,e,s){if(t)for(let n=e.length-1;n>=0;--n)s(e[n]);else e.forEach(s)}function is(t,e){let s=pt(t);const n=e.length/_t();for(let i=0;i<e.length;++i){const t=Math.trunc(s*n);s=pt(s);const i=Math.trunc(s*n),r=e[t];e[t]=e[i],e[i]=r}}function rs(t,e,s){if(0===t.length)return;let n=0,i=0;for(++i;i!==t.length;++i)e(t[n],t[i])||(s(n,i),n=i);s(n,i)}function os(t,e,s,n,i){ft(t,e,n-e,(t,e)=>i(t,e)?-1:1)}function as(t,e,s){if(!(s<=e))for(;e<s;)t[s]=Q(t[e],t[e]=t[s]),e++,s--}function hs(t,e,s,n){as(t,e,s-1),as(t,s,n-1),t.reverse()}function us(t,e,s){const n=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),st(t.getAttributeArray(),e,0,2,n-2)}var ms=b;const ls="can not assign an empty point to a vertex";class cs{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=P(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new es,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new A,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:P();this.m_description=e,this.m_vertexAttributes=new es,this.m_envelopeData=new A,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!h(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const n=this.getPointCount();if(n!==s.getPointCount())return!1;for(let i=0;i<this.m_description.getAttributeCount();i++){const t=this.m_description.getSemantics(i),r=this.getAttributeStreamRef(t),o=s.getAttributeStreamRef(t),a=ms.getComponentCount(t);if(!r.equals(o,0,n*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(e,s,n,i,r){if(this.addAttribute(e),!this.isEmpty()&&(0!==n||1!==i)){if(0===e){const e=new ce;return 0===r?0===s?(e.setShiftCoords(n,0),e.scale(i,1)):1===s?(e.setShiftCoords(0,n),e.scale(1,i)):t(""):0===s?(e.setScaleCoords(1/i,1),e.shiftCoords(-n,0)):1===s?(e.setScaleCoords(1,1/i),e.shiftCoords(0,-n)):t(""),void this.applyTransformation(e)}ss(this.getAttributeStreamRef(e),s,this.getPointCount(),ms.getComponentCount(e),X(n,i,r)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=v(e,t);this.assignVertexDescription(s)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(e){this.throwIfEmpty(),this.m_description.hasAttribute(e)||t("AttributeStream : Geometry does not have the attribute");const s=this.m_description.getAttributeIndex(e);return this.m_vertexAttributes.get(s)}setAttributeStreamRef(e,s){s||t("stream"),s&&ms.getPersistence(e)!==s.getPersistence()&&t(""),this.addAttribute(e);const n=this.m_description.getAttributeIndex(e);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(n,s),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let n=0;n<this.m_description.getAttributeCount();n++){const e=this.m_description.getSemantics(n);for(let i=0,r=ms.getComponentCount(e);i<r;i++){const o=this.m_vertexAttributes.get(n).readAsDbl(r*t+i);s.setAttributeBasic(e,i,o)}}}setPointByValNoCurves(e,s){const n=s;n.isEmpty()&&t(ls);const i=n.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const r=this.m_vertexAttributes.get(0);r.write(2*e,n.getX()),r.write(2*e+1,n.getY());for(let t=1,o=this.m_description.getAttributeCount();t<o;t++){const s=this.m_description.getSemantics(t),i=ms.getComponentCount(s);for(let r=0;r<i;r++){const o=n.getAttributeAsDbl(s,r);this.m_vertexAttributes.get(t).writeAsDbl(e*i+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,s,i){n(0)}getPointByValAsArray(t,e,s,i){n(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=ms.getComponentCount(t);s>=n&&i("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):ms.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=ms.getComponentCount(t);n<r&&i("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,n=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=n.readAsDbl(t+e)}else{const e=ms.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,s,i){n(0)}setAttributeNoCurves(t,e,s,n){const r=ms.getComponentCount(t);s>=r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArrayNoCurves(t,e,s,n){(e<0||e>=this.m_pointCount)&&i("");const r=ms.getComponentCount(t);n<r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let i=0;i<r;++i)a.writeAsDbl(e*r+i,s[i])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXYNoCurves(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoordsNoCurves(t,e,s){const n=this.m_vertexAttributes.get(0);n.write(2*t,e),n.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=E.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=ms.getDefaultValue(1),s}setXYZNoCurves(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y);this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof le||t instanceof T?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=U.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let n=!1;const i=ms.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*i;r<a;r+=i){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),n=!0)}}else for(let a=e,h=this.m_pointCount*i;a<h;a+=i){r.readAsDbl(a)!==s&&(r.writeAsDbl(a,s),n=!0)}n&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const n=ms.getComponentCount(t),i=this.getAttributeStreamRef(t);for(let r=0;r<n;r++)if(1===i.getPersistence()){const t=i;for(let i=0,r=this.m_pointCount*n;i<r;i++){const n=t.read(i);Number.isNaN(n)&&(t.write(i,e),s=!0)}}else for(let t=0,o=this.m_pointCount*n;t<o;t++){const n=i.readAsDbl(t);Number.isNaN(n)&&(i.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return n(0),0}setEnvelopeForImport(e){this.m_description.equals(e.getDescription())||t(""),this.m_envelopeData=new A({moveEnv:e}),this.setDirtyFlagProtected(192,!1)}copyTo(e){e.getGeometryType()!==this.getGeometryType()&&t(""),this!==e&&this.copyToUnchecked(e,!1)}queryCoordinates(e,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&t(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let t=2*n,a=2*r,h=0;t<a;t+=2,h++)o.queryPoint2D(t,e[h]);return r}queryCoordinates3D(e,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&t(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=ms.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let t=n;t<r;t++,m++)e[m].x=o.read(2*t),e[m].y=o.read(2*t+1),e[m].z=u?a.read(t):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const n=t&~e,i=e|n;s=this.m_flags,(s&i)!==e&&(this.m_flags=s&~n|e)}getIsSimple(t,e){e[0]=0;let s=-1;const n=this.m_flags,i=this.m_simpleTolerance;if(!(1&n)){s=(14&n)>>1,e[0]=i,i<t&&(s=-1)}return s}setIsSimple(t,s,i=!1){if(2===t?n(this.getGeometryType()===e.enumPolyline):1===t?n(this.getGeometryType()===e.enumMultiPoint||this.getGeometryType()===e.enumPolyline):3===t&&n(this.getGeometryType()===e.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let e=t<<1;i||(e|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,e),this.m_simpleTolerance!==s&&(this.m_simpleTolerance=s)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,s=!1){s&&this.hasDirtyFlag(32)&&u("Cannot do shallow clone on unprepared geometry");const i=t,r=this.getGeometryType(),o=i.getGeometryType();n(r===o||r===e.enumPolygon&&o===e.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();const a=this.m_description.getAttributeCount(),h=new es;if(!this.m_vertexAttributes.empty()){h.destroyAndSetSize(a);for(let t=0;t<a;t++)if(this.m_vertexAttributes.get(t))if(s)h.set(t,this.m_vertexAttributes.get(t));else{const e=ms.getComponentCount(this.m_description.getSemantics(t));h.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,r!==o){const t=[Number.NaN];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(h),h.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)||i.m_vertexAttributes.empty()?(n(!s||0===i.m_pointCount),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,s)}catch(m){throw i.setEmpty(),m}i.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,s,r){(t<0||t>=this.m_pointCount)&&i(""),(e<0||e>=this.m_pointCount)&&i(""),r.assignVertexDescription(this.m_description);const o=et(ms.maxComponentCount(),Number.NaN),a=et(ms.maxComponentCount(),Number.NaN),h=I();let u=0;for(let i=0;i<this.m_description.getAttributeCount();i++){const r=this.m_description.getSemantics(i),m=ms.getInterpolation(r),l=ms.getComponentCount(r),c=ms.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),n(u+l<=M),dt(m,o,a,h,u,l,s,c),u+=l}us(r,h)}getShortestDistance(t,e){return K.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return K.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(e){if(e<0&&t(),(e=Math.ceil(e))===this.m_pointCount)return;this.m_pointCount=e;const s=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(s)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=D();w(t,this.m_description,e);const s=new es;s.destroyAndSetSize(t.getAttributeCount());for(let n=0;n<t.getAttributeCount();n++){const t=e[n];-1!==t?s.set(n,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return 0!==(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=-1;let t=Number.MAX_SAFE_INTEGER,e=0;e=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let s=0;s<this.m_description.getAttributeCount();s++){const n=this.m_description.getSemantics(s);let i=0;if(null!==this.m_vertexAttributes.get(s)){const t=ms.getComponentCount(n);i=this.m_vertexAttributes.get(s).size()/t,i<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,ms.getDefaultValue(n)),i=e)}else this.m_vertexAttributes.set(s,Y(n,e)),i=e;i<t&&(t=i)}this.m_reservedPointCount=t}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new C({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),n=ms.getComponentCount(e),i=this.m_vertexAttributes.get(t);for(let t=0;t<n;t++){const r=new U;r.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=i.readAsDbl(e*n+t);r.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,r)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new A({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=le.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){n(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof le?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(e,s){if(e<0&&t(""),0===e)return;let n=e=Math.ceil(e);if(this.m_reservedPointCount<n){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),s?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,N(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*n),n=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,N(0,n)):this.m_vertexAttributes.get(0).resize(2*n);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),s=ms.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(n*s):this.m_vertexAttributes.set(t,N(e,n))}this.reserveImplImpl(n,s),this.m_reservedPointCount=n}}reserveRounded(e){e<0&&t(),e=Math.ceil(e),this.reserveImpl(e,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&o("")}exportVertexAttributes(){const t=this.getPointCount(),e=this.m_description.getAttributeIndex(1),s=this.m_description.getAttributeIndex(2),n=this.m_vertexAttributes.posStream,i=e>0?this.m_vertexAttributes.get(e):void 0,r=s>0?this.m_vertexAttributes.get(s):void 0,o=n?.getArray()??new Float64Array,a=i?.getArray(),h=r?.getArray();return{vertexCount:t,vertexXY:o,vertexZ:a,vertexM:h}}}class gs extends cs{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(e,s){e>this.getPointCount()&&t("invalid point index"),e<0&&(e=this.getPointCount());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),r=b.getComponentCount(i);if(0===i)this.m_vertexAttributes.get(t).insert(r*e,s,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(r*e,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoint(e,s){s.isEmpty()&&t(ls),e<0&&(e=this.getPointCount()),this.mergeVertexDescription(s.getDescription());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),r=b.getComponentCount(i);if(s.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(r*e,s,i,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(r*e,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&i(""),t<0&&(t=this.getPointCount()),0===s)return;const n=e[0].getDescription();this.mergeVertexDescription(n);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=b.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(n.hasAttribute(o))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=b.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(e,s,n){if((e>this.getPointCount()||n<0)&&t("invalid point index"),e<0&&(e=this.getPointCount()),0===n)return;const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+n);for(let t=0,r=this.m_description.getAttributeCount();t<r;t++){const r=this.m_description.getSemantics(t),o=b.getComponentCount(r);if(this.m_vertexAttributes.get(t))if(0===r)this.m_vertexAttributes.get(t).insertRangeFromPoints(o*e,s,0,n,!0,o*i);else{const s=b.getDefaultValue(r);this.m_vertexAttributes.get(t).insertRange(o*e,s,o,o*i)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&i("remove_points"),0!==e){for(let s=0,n=this.m_description.getAttributeCount();s<n;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),i=b.getComponentCount(n);this.m_vertexAttributes.get(s).eraseRange(i*t,i*e,i*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),n=b.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(n*t,n,n*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const t=this.m_description.getSemantics(s),n=b.getDefaultValue(t),i=b.getComponentCount(t);this.m_vertexAttributes.get(s).insertRange(i*e,n,i*(this.m_pointCount-e),i*e)}}queryCoordinates3D(e,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&t(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=b.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let t=n;t<r;t++,m++)e[m].x=o.read(2*t),e[m].y=o.read(2*t+1),e[m].z=u?a.read(t):h;return r}queryAttributeAsInt(t,e,s,i){n(0)}add(e){e.isEmpty()&&t(ls),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,e)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new K(t,e);this.setXYNoCurves(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const n=new E;n.setCoords(t,e,s),this.setXYZNoCurves(this.m_pointCount-1,n)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(e,s,n){this===e&&t("Multi_point_impl.add");const i=n<0?e.getPointCount():n;if((s<0||s>e.getPointCount()||i<s)&&t(""),s===i)return;const r=e.getDescription();this.mergeVertexDescription(r);const o=i-s,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let t=0,h=this.m_description.getAttributeCount();t<h;t++){const n=this.m_description.getSemantics(t),i=b.getComponentCount(n),h=this.getAttributeStreamRef(n);if(r.hasAttribute(n)){const t=e.getAttributeStreamRef(n);h.insertRangeFromStream(a*i,t,s*i,o*i,!0,1,a*i)}else{const t=b.getDefaultValue(n);h.insertRange(a*i,t,o*i,a*i)}}}addPoints2D(e,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&t(""),n===o)return;r=o-n;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let t=0;t<r;++t)h.writePoint2D(2*(a+t),e[n+t]);this.notifyModifiedFlags(2001)}addPoints3D(e,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&t(""),this.addAttribute(1),n===o)return;r=o-n;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0),u=new K;for(let t=0;t<r;t++)u.x=e[n+t].x,u.y=e[n+t].y,h.writePoint2D(2*(a+t),u);const m=this.getAttributeStreamRef(1);for(let t=0;t<r;t++)m.write(a+t,e[n+t].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,s){this.setXYCoordsNoCurves(t,e,s)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,s,n){this.setAttributeNoCurves(t,e,s,n)}getGeometryType(){return e.enumMultiPoint}getDimension(){return 0}createInstance(){return new gs({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):s("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,s){return t.getGeometryType()===e.enumMultiPoint&&this.equalsBase(t,s)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):s("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){n(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return n(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}toFlatGeometry(){return{type:"multipoint",...this.exportVertexAttributes(),...q}}}gs.type=e.enumMultiPoint;class ds extends ts{constructor(t){super(t)}}class _s extends ds{isTrue3D(){return!0}constructor(t){super(t)}}function ps(t,e,s){fs(e,t.getStartXY(),t.getEndXY(),s)}function fs(t,e,s,n){Ct(e,s,t,n)}function Ps(t,e){return nt(t.m_XStart,t.m_XEnd,e)}function ys(t,e){return nt(t.m_YStart,t.m_YEnd,e)}function xs(t,e){const s=t.getStartZ(),n=t.getEndZ();return nt(s,n,e)}function Cs(t,e,s){const n=be.constructPoint2D(t.getStartXY()),i=be.constructPoint2D(t.getEndXY());s.setCoordsE(i.x.subE(n.x),i.y.subE(n.y))}function vs(t,e,s){e.value()<=.5?Vt(2,be.constructPoint2D(t.getStartXY()),be.constructPoint2D(t.getEndXY()),e,s):Lt(2,be.constructPoint2D(t.getStartXY()),be.constructPoint2D(t.getEndXY()),e,s)}function bs(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function Ss(t,e){const s=t.getStartXYZ();s.z*=e;const n=t.getEndXYZ();return n.z*=e,s.norm(1)+n.norm(1)}function Es(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=Q(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=Q(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=Q(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function Ds(t,e,s,n){let i=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(i++,!n))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(i++,2===i)return 2;if(!n)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:n&&i?0:Ts(t,e)?4:0}function ws(t,e,s,n,i,r,o,a){null!==n&&Ht(n,2,Number.NaN),null!==i&&Ht(i,2,Number.NaN),null!==s&&Ut(s,K,2);const h=As(t,e,2,s,n,i,r,o,a);return n&&(n.length=h),i&&(i.length=h),s&&(s.length=h),h}function As(t,e,s,n,i,r,o,a,h){const u=Ms(t,e.getStartXY(),o,!1),m=Ms(t,e.getEndXY(),o,!1),l=Ms(e,t.getStartXY(),o,!1),c=Ms(e,t.getEndXY(),o,!1);let g=0,d=0;if(!Number.isNaN(u)){let s=!1;a&&lt(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getStartXY())&&(g++,s=!0),s||(i&&(i[d]=u),r&&(r[d]=0),n&&n[d].setCoords(e.m_XStart,e.m_YStart),d++)}if(!Number.isNaN(m)){let o=!1;a&&lt(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getEndXY())&&(g++,o=!0),o||(s>d&&(i&&(i[d]=m),r&&(r[d]=1),n&&n[d].setCoords(e.m_XEnd,e.m_YEnd)),d++)}if(2!==d&&!Number.isNaN(l)&&!(0===u&&0===l||0===m&&1===l)){let o=!1;a&&lt(l,0,1)&&e.getCoord2D(l).isEqualPoint2D(t.getStartXY())&&(g++,o=!0),o||(s>d&&(i&&(i[d]=0),r&&(r[d]=l),n&&n[d].setCoords(t.m_XStart,t.m_YStart)),d++)}if(2!==d&&!Number.isNaN(c)&&!(1===u&&0===c||1===m&&1===c)){let o=!1;a&&lt(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getEndXY())&&(g++,o=!0),o||(s>d&&(i&&(i[d]=1),r&&(r[d]=c),n&&n[d].setCoords(e.m_XEnd,e.m_YEnd)),d++)}if(d>0)return h&&(r=Q(i,i=r)),2===d&&s>=2&&i&&i[0]>i[1]&&(i[1]=Q(i[0],i[0]=i[1]),r&&(r[1]=Q(r[0],r[0]=r[1])),n&&(n[1]=Q(n[0],n[0]=n[1]))),d;if(g>0)return 0;const _=Fs(t,e,o);return Number.isNaN(_.x)?0:(n&&(n[0]=t.getCoord2D(_.x)),i&&(i[0]=_.x),r&&(r[0]=_.y),1)}function Ts(t,e){const s=Ys(t,e.m_XStart,e.m_YStart),n=Ys(t,e.m_XEnd,e.m_YEnd);if(s<0&&n<0||s>0&&n>0)return!1;const i=Ys(e,t.m_XStart,t.m_YStart),r=Ys(e,t.m_XEnd,t.m_YEnd);if(i<0&&r<0||i>0&&r>0)return!1;return qs(t)>qs(e)?Xs(t,e):Xs(e,t)}function Is(t,e){const s={bIntersect:!1,t1:Number.NaN,t2:Number.NaN},n=t.m_XEnd-t.m_XStart,i=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*i-n*o;if(0===a)return s;const h=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,m=r*u-h*o,l=n*u-h*i,c=1/a;return s.t1=m*c,s.t2=l*c,s.bIntersect=!0,s}function Ms(t,e,s,n){const i=K.getNAN(),r=K.getNAN();let o=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(i.setCoords(t.m_XEnd,t.m_YEnd),r.setCoords(t.m_XStart,t.m_YStart),o=!0):(i.setCoords(t.m_XStart,t.m_YStart),r.setCoords(t.m_XEnd,t.m_YEnd));const a=o?1:0,h=o?0:1,u=K.getNAN();u.setSub(e,i);let m=u.length(),l=3*m*ct();if(m<=Math.max(s,l))return n&&0===m?Number.NaN:a;if(u.setSub(e,r),m=u.length(),l=3*m*ct(),m<=Math.max(s,l))return n&&0===m?Number.NaN:h;u.setCoords(r.x-i.x,r.y-i.y);const c=u.length();if(c>0){const t=1/c;u.scale(t);const n=K.getNAN();n.setSub(e,i);const m=n.dotProduct(u),l=8*n.dotProductAbs(u)*ct();u.leftPerpendicularThis();const g=n.dotProduct(u),d=8*n.dotProductAbs(u)*ct(),_=Math.max(s,l);if(m<-_||m>c+_)return Number.NaN;const p=Math.max(s,d);if(Math.abs(g)<=p){let n=m*t;n=gt(n,0,1);const u=K.getNAN();if(fs(n,i,r,u),K.distance(u,e)<=s){if(n<.5){if(K.distance(u,i)<=s&&K.distance(e,i)<=s)return a}else if(K.distance(u,r)<=s&&K.distance(e,r)<=s)return h;return o?1-n:n}}}return Number.NaN}function Ys(t,e,s){const n=K.getNAN();n.setCoords(e,s),n.subThis(t.getStartXY());const i=K.getNAN();i.setSub(t.getEndXY(),t.getStartXY());const r=i.crossProduct(n),o=4*ct()*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?-1:r<-o?1:0}function Ns(t,e,s,n){const i=n?t.m_XStart:t.m_XEnd,r=n?t.m_YStart:t.m_YEnd,o=K.getNAN();o.x=e.getEndX()-i,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*ct()*s.dotProductAbs(o)){o.x=e.getStartX()-i,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*ct()*s.dotProductAbs(o)}return!0}function Xs(t,e){const s=K.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!Ns(t,e,s,!1)&&(s.negateThis(),!!Ns(t,e,s,!0))}function qs(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function Fs(t,e,s){const n=t.m_XEnd-t.m_XStart,i=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*i-n*o;if(0===a)return K.getNAN();const h=4*ct()*(Math.abs(r*i)+Math.abs(n*o)),u=e.m_XStart-t.m_XStart,m=e.m_YStart-t.m_YStart,l=r*m-u*o,c=4*ct()*(Math.abs(r*m)+Math.abs(u*o)),g=l/a,d=Math.abs(a),_=(c*d+h*Math.abs(l))/(a*a)+ct()*Math.abs(g);if(g<-_||g>1+_)return K.getNAN();const p=n*m-u*i,f=p/a,P=(4*ct()*(Math.abs(n*m)+Math.abs(u*i))*d+h*Math.abs(p))/(a*a)+ct()*Math.abs(f);if(f<-P||f>1+P)return K.getNAN();let y=gt(g,0,1),x=gt(f,0,1);const C=K.getNAN();ps(t,y,C);const v=K.getNAN();if(ps(e,x,v),!s||K.distance(C,v)>s){const n=K.getNAN();Ct(C,v,.5,n),y=t.getClosestCoordinate(n,!1),x=e.getClosestCoordinate(n,!1);const i=K.getNAN();ps(t,y,i);const r=K.getNAN();ps(e,x,r),i.subThis(r);const o=i.length(),a=(t.absNorm()+e.absNorm())*ht();if(o>Math.max(s,a))return K.getNAN()}return new K(y,x)}class Vs{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&i("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&i("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&i(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount())&&(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,!0)}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&i(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&d(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&i(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!==(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&i(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){if(null!==this.m_segFlagStream){return 1!==(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}return!1}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class Ls{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&(n(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new Ls;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0===--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){n(this.uniqueUse())}setQuadTree(t){n(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){n(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function Rs(t){return!(t.isEmpty()||t.getGeometryType()!==e.enumPolyline&&t.getGeometryType()!==e.enumPolygon)&&!(t.getPointCount()<20)}function zs(t){return!(t.isEmpty()||t.getGeometryType()!==e.enumPolyline&&t.getGeometryType()!==e.enumPolygon)&&!(t.getPointCount()<20)}function Bs(t,e){return t.readPoint2D(e+4)}function ks(t){const s=t.getGeometryType();return s===e.enumEllipticArc?10:s===e.enumBezier?4:s===e.enumRationalBezier2?5:s===e.enumBezier2?2:void r("")}function Gs(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Ws(t,e,s,n){const i=t.getPathStart(e),r=t.getPathEnd(e);if(r-i<3)return;const o=2*i,a=K.getNAN();s.queryPoint2D(o,a);const h=a.x,u=a.y,m=K.getNAN();s.queryPoint2D(o+2,m);const l=K.getNAN();for(let c=o+4,g=2*r;c<g;c+=2)s.queryPoint2D(c,l),n.pe((l.x-a.x)*(m.y-u)),a.setCoordsPoint2D(m),m.setCoordsPoint2D(l);n.pe((h-a.x)*(m.y-u))}function js(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var Zs=b;class Hs{static toSegType(t){let s=0;switch(t){case e.enumLine:s=1;break;case e.enumBezier:s=2;break;case e.enumEllipticArc:s=4;break;case e.enumRationalBezier2:s=8;break;case e.enumBezier2:s=16;break;default:r("")}return s}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class Us extends cs{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?e.enumPolygon:e.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(e){n(this.m_bPolygon);const s=this.getPathIndexFromPointIndex(e),i=this.getPathStart(s);if(i===e)return;const r=this.getPathEnd(s);(e>=r||e<i)&&t("change_ring_start_point");for(let t=0,n=this.m_description.getAttributeCount();t<n;t++){const s=this.m_description.getSemantics(t),n=Zs.getComponentCount(s);this.m_vertexAttributes.get(t).rotate(i*n,e*n,r*n)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(i,e,r),this.m_curveData.m_segmentParamIndex.rotate(i,e,r))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new V(t),s=new O(0),n=new O(0);if(0!==this.m_pointCount){const i=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new Vs({parent:this});for(t.stripAttributes();t.nextPath();){n.reset();const r=t.getPathIndex();Ws(this,r,i,n),js(this,t,n);const o=.5*n.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){n.reset(),Ws(this,r,i,n);const t=.5*n.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return n(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==e.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Us.isNonLinearSegmentFlag(s))continue;const n=this.m_curveData.m_segmentParamIndex.read(t),i=e.m_curveData.m_segmentParamIndex.read(t),r=Gs(s);for(let t=0;t<r;t++){const s=this.m_curveData.m_segmentParams.read(n+t),r=e.m_curveData.m_segmentParams.read(i+t);if(!Pt(s,r))return!1}}}return!0}equalsImplTol(t,e){const s=t,n=this.getPathCount();if(n!==s.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==s.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,n+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,n))return!1;if(!i)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=L(1,0),this.m_pathFlags=R(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new Hs),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new O(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new O(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return n(0),0}calculatePathLength3D(t,e){return n(0),0}copyTo(e){c(e.getGeometryType())||t(""),this!==e&&super.copyTo(e)}swap(t){n(0)}setPointByVal(t,e){this.setPointByValWithCurves(t,e)}setPointByValWithCurves(t,e){if(this.hasNonLinearSegments()){const s=e.getXY();if(this.setXYCoordsWithCurves(t,s.x,s.y),1===this.m_description.getAttributeCount())return}this.setPointByValNoCurves(t,e)}setXYCoordsWithCurves(t,e,s){if(this.hasNonLinearSegments()){const n=Us.getPathIndexFromPointIndexImpl(this.m_paths,this.getPathCount(),t,this.m_currentPathIndex);this.m_currentPathIndex=n;const i=this.getPrevSegmentTypeFromPath(n,t),r=this.getNextSegmentType(t);if(1!==i||1!==r){let o=t-1;const a=new Pm;if(1!==i){if(this.isClosedPath(n)&&t===this.getPathStart(n)){o=this.getPathEnd(n)-1}this.getSegmentBuffer(o,a,!0)}const h=new Pm;1!==r&&this.getSegmentBuffer(t,h,!0);const u=t+1;this.setXYCoordsNoCurves(t,e,s);const m=new K(e,s);return 1!==i&&(a.get().changeEndPoints2D(a.get().getStartXY(),m),this.replaceSegmentImpl(o,t,a.get(),!0)),void(1!==r&&(h.get().changeEndPoints2D(m,h.get().getEndXY()),this.replaceSegmentImpl(t,u,h.get(),!0)))}}this.setXYCoordsNoCurves(t,e,s)}setXYZWithCurves(t,e){this.hasNonLinearSegments()?(this.setXYCoordsWithCurves(t,e.x,e.y),this.setAttributeNoCurves(1,t,0,e.z)):this.setXYZNoCurves(t,e)}setAttributeWithCurves(t,e,s,n){if(0===t&&this.hasNonLinearSegments()){const t=this.getXY(e);0===s?t.x=n:t.y=n,this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeNoCurves(t,e,s,n)}setXY(t,e){this.setXYCoordsWithCurves(t,e.x,e.y)}setXYCoords(t,e,s){this.setXYCoordsWithCurves(t,e,s)}setXYZ(t,e){this.setXYZWithCurves(t,e)}setAttribute(t,e,s,n){this.setAttributeWithCurves(t,e,s,n)}setAttributeWithCurvesFromArray(t,e,s,n){if(0===t&&this.hasNonLinearSegments()){n<2&&i("");const t=this.getXY(e);t.x=s[0],t.y=s[1],this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeFromArrayNoCurves(t,e,s,n)}setAttributeFromArray(t,e,s,n){this.setAttributeWithCurvesFromArray(t,e,s,n)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(e,s){this===e&&t("Multi_path_impl::add");for(let t=0,n=e.getPathCount();t<n;t++)this.addPath(e,t,!s)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addPathMultiPoint(t,e,s,n){s<0&&(s=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,s,n)}addSegmentsFromPath(e,s,n,r,o){if(this===e&&t("Multi_path_impl.add_segments_from_path"),o||0!==this.getPathCount()||(o=!0),s<0&&(s=e.getPathCount()-1),(s>=e.getPathCount()||n<0||r<0||n+r>e.getSegmentCountPath(s))&&i("add_segments_from_path"),0===r)return;const a=e.getPathStart(s),h=e.isClosedPath(s)&&n+r===e.getSegmentCountPath(s);this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());let u=r;const m=a+n;let l=m+1;o&&(u++,l--),!o&&e.hasNonLinearSegments()&&1!==e.m_curveData.m_segmentFlags.read(m)&&(e.getXY(m).equals(this.getXY(this.m_pointCount-1))||t("add_segments_from_path: start point mismatch"));const c=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+u),this.verifyAllStreamsAfterSizeChange(),o){if(0===u)return;this.m_paths.add(this.m_pointCount);let t=e.m_pathFlags.read(s);this.m_bPolygon&&(t|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,t),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const g=h?u-1:u;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const s=this.m_description.getSemantics(t),n=Zs.getComponentCount(s),i=e.m_description.getAttributeIndex(s);if(g>0){if(i<0||!e.m_vertexAttributes.get(i)){const e=Zs.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(n*c,e,g*n,n*c),h&&this.m_vertexAttributes.get(t).insertRange(n*c+g*n,e,n,n*c);continue}this.m_vertexAttributes.get(t).insertRangeFromStream(n*c,e.m_vertexAttributes.get(i),n*l,g*n,!0,n,n*c)}h&&this.m_vertexAttributes.get(t).insertRangeFromStream(n*(c+g),e.m_vertexAttributes.get(i),n*a,n,!0,n,n*(c+g))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),e.hasNonLinearSegments()){let t=0;for(let s=0,n=m;s<r;s++){t+=Gs(e.m_curveData.m_segmentFlags.read(n)),n++}if(t>0){this.initSegmentData(t);let s=m,n=c-(o?0:1),i=0;for(let t=0;t<r;t++){const t=e.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(n,t),Us.isNonLinearSegmentFlag(t)){i++;let r=e.m_curveData.m_segmentParamIndex.read(s);const o=Gs(t);this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);for(let t=0;t<o;t++){const t=e.m_curveData.m_segmentParams.read(r);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,r++}this.incCurveType(t,1)}else this.m_curveData.m_segmentParamIndex.write(n,-1);n++,s++}this.modifyCurveCounter(i)}}if(h){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,n=this.getXY(e),i=this.getXY(s);n.isEqualPoint2D(i)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(e){e>=this.getPathCount()&&t("");const s=this.getPathSize(e);if(0===s)return;const n=this.getPathStart(e),i=this.isClosedPath(e);if(this.hasNonLinearSegments()){let t=n;const e=new this.m_segmentBufferCTor;let r=!1;for(let n=0;n<s;n++,t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Us.isNonLinearSegmentFlag(s))continue;r=!0,this.querySegment(t,e,!0),e.get().reverse();const n=this.m_curveData.m_segmentParamIndex.read(t);e.get().writeInBufferStream(this.m_curveData.m_segmentParams,n)}if(r){const t=i?0:1;this.m_curveData.m_segmentFlags.reverseRange(n,s-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(n,s-t,1)}}const r=i?1:0;for(let t=0,a=this.m_description.getAttributeCount();t<a;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),i=Zs.getComponentCount(e);this.m_vertexAttributes.get(t).reverseRange(i*(n+r),i*(s-r),i)}const o=6&this.m_pathFlags.read(e);if(o){let t=0;4&o&&(t|=2),2&o&&(t|=4),this.m_pathFlags.clearBits(e,6),this.m_pathFlags.setBits(e,t)}this.notifyModifiedFlags(1233)}removePath(e){const s=this.getPathCount();e<0&&(e=s-1),e>=s&&t("");const n=this.getPathStart(e),i=this.getPathSize(e);for(let t=0,r=this.m_description.getAttributeCount();t<r;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*n,s*i,s*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=n,s=n+i;e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);Us.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(n,i,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(n,i,this.m_pointCount)}for(let t=e+1;t<=s;t++){const e=this.m_paths.read(t);this.m_paths.write(t-1,e-i)}if(this.m_pathFlags)for(let t=e+1;t<=s;t++){const e=this.m_pathFlags.read(t);this.m_pathFlags.write(t-1,e)}this.m_paths.resize(s),this.m_pathFlags.resize(s),this.m_pointCount-=i,this.m_reservedPointCount-=i,e===s-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(e,s,n,i){this===s&&t("Multi_path_impl::insert_path");const r=this.getPathCount();if(!i&&s.hasNonLinearSegmentsPath(n))return e=this.insertPath(e,s,n,!0),this.reversePath(e),e;n>=s.getPathCount()&&t(""),e>r&&t(""),e<0&&(e=r),n<0&&(n=s.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(s.getDescription());const o=s.getPathStart(n),a=s.getPathSize(n);if(0===a)return this.insertPath2D(e,null,0,0,!0);const h=this.m_pointCount,u=s.isClosedPath(n)&&!i?1:0;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const m=e<r?this.getPathStart(e):h;for(let t=0,g=this.m_description.getAttributeCount();t<g;t++){const e=this.m_description.getSemantics(t),n=s.getDescription().getAttributeIndex(e),r=Zs.getComponentCount(e);if(n>=0&&s.m_vertexAttributes.get(n))0!==u&&this.m_vertexAttributes.get(t).insertRangeFromStream(m*r,s.m_vertexAttributes.get(n),r*o,r,!0,r,r*h),this.m_vertexAttributes.get(t).insertRangeFromStream((m+u)*r,s.m_vertexAttributes.get(n),r*(o+u),r*(a-u),i,r,r*(h+u));else{const s=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(m*r,s,r*a,r*h)}}const l=h+a;this.m_paths.add(l);for(let t=r;t>=e+1;t--){const e=this.m_paths.read(t-1);this.m_paths.write(t,e+a)}this.m_pathFlags.add(0);for(let t=r-1;t>=e+1;t--){let e=this.m_pathFlags.read(t);e&=-9,this.m_pathFlags.write(t+1,e)}let c=s.getPathFlagsStreamRef().read(n);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(e,c),s.hasNonLinearSegments()){this.initSegmentData(0);let t=o,e=0;for(let n=0;n<a;n++){e+=Gs(s.m_curveData.m_segmentFlags.read(t)),t++}if(e>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=R(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=L(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(m,1,a,h),this.m_curveData.m_segmentParamIndex.insertRange(m,-1,a,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+e):this.m_curveData.m_segmentParams=z(e),t=o;let n=m,i=0;for(let e=0;e<a;e++){const e=s.m_curveData.m_segmentFlags.read(t);if(Us.isNonLinearSegmentFlag(e)){this.m_curveData.m_segmentFlags.write(n,e),this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);const r=Gs(e);let o=s.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){const t=s.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}i++,this.incCurveType(e,1)}t++,n++}this.modifyCurveCounter(i)}}return this.notifyModifiedFlags(2001),e}insertPath2D(e,s,n,i,r){const o=this.getPathCount();(e>o||n<0)&&t(""),e<0&&(e=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+i),0===i&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=e<o?this.getPathStart(e):a;if(s)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,s,n,i,r,2*a);else{const t=Zs.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*i,2*a)}for(let t=1,u=this.m_description.getAttributeCount();t<u;t++){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e),n=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(h*s,n,s*i,s*a)}this.m_paths.add(this.m_pointCount);for(let t=o;t>=e+1;t--){const e=this.m_paths.read(t-1);this.m_paths.write(t,e+i)}this.m_pathFlags.add(0);for(let t=o-1;t>=e+1;t--){let e=this.m_pathFlags.read(t);e&=-9,this.m_pathFlags.write(t+1,e)}return this.m_bPolygon&&this.m_pathFlags.write(e,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,i,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,i,a)),this.notifyModifiedFlags(2001),e}insertPathFromMultipoint(e,s,n,i,r){const o=s.getImpl(),a=this.getPathCount();(e>a||n<0)&&t("");const h=i<0?o.getPointCount()-n:i;if(h>o.getPointCount()&&t(""),n>=o.getPointCount()&&t("pointsOffset"),e<0&&(e=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(e,null,0,0,!0);const u=this.m_pointCount,m=n;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=e<a?this.getPathStart(e):u;for(let t=0,d=this.m_description.getAttributeCount();t<d;t++){const e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),n=Zs.getComponentCount(e);if(s>=0){const s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(l*n,s,n*m,n*h,r,n,n*u)}else{const s=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(l*n,s,n*h,n*u)}}const c=u+h;this.m_paths.add(c);for(let t=a;t>=e+1;t--){const e=this.m_paths.read(t-1);this.m_paths.write(t,e+h)}this.m_pathFlags.add(0);for(let t=a-1;t>=e+1;t--){let e=this.m_pathFlags.read(t);e&=-9,this.m_pathFlags.write(t+1,e)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(e,g),this.notifyModifiedFlags(2001)}insertPoints(e,s,n,r,o,a,h){if(this===n&&t("Multi_path_impl.insert_points"),e<0&&(e=this.getPathCount()),r<0&&(r=n.getPathCount()-1),(e>this.getPathCount()||s>=0&&s>this.getPathSize(e)||r>=n.getPathCount()||a>n.getPathSize(r))&&i(""),!a)return;if(this.mergeVertexDescription(n.m_description),e===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=n.m_pathFlags.read(r);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}s<0&&(s=this.getPathSize(e));const u=this.m_pointCount;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(e),l=m+s;a<0&&(a=n.getPathSize(r));const c=n.getPathStart(r),g=c+a;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const e=this.m_description.getSemantics(t),i=Zs.getComponentCount(e),r=n.m_description.getAttributeIndex(e);if(r<0||!n.m_vertexAttributes.get(r)){const s=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(i*l,s,g*i,i*u);continue}this.m_vertexAttributes.get(t)?.insertRangeFromStream(i*(m+s),n.m_vertexAttributes.get(r),i*(c+o),a*i,h,i,i*u)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+s,1,a,u),this.m_curveData.m_segmentParamIndex.insertRange(m+s,-1,a,u),s>0&&this.isNonLinearSegment(m+s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+s-1),-1),this.m_curveData.m_segmentFlags.write(m+s-1,1),this.m_curveData.m_segmentParamIndex.write(m+s-1,-1),this.modifyCurveCounter(-1)));for(let t=e+1,i=this.getPathCount();t<=i;t++){const e=this.m_paths.read(t);this.m_paths.write(t,e+a)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&i(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let i=1,u=this.m_description.getAttributeCount();i<u;i++){const t=this.m_description.getSemantics(i),s=Zs.getComponentCount(t),n=Zs.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange((h+e)*s,n,s*r,s*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,u=this.getPathCount();i<=u;i++)this.m_paths.write(i,this.m_paths.read(i)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl(),h=this.getPathCount();t<0&&(t=this.getPathCount());const u=a.getPointCount();if((n<0||n>u)&&i(""),(r<0||n+r>u)&&(r=u-n),e<0&&(e=t<h?this.getPathSize(t):0),(t>h||t<h&&e>this.getPathSize(t)||t===h&&e>0||r<0)&&i(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===h){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const m=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const l=this.getPathStart(t),c=l+e,g=0,d=g+r;for(let i=0,_=this.m_description.getAttributeCount();i<_;i++){const t=this.m_description.getSemantics(i),s=Zs.getComponentCount(t);if(a.getDescription().getAttributeIndex(t)<0){const e=Zs.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange(s*c,e,d*s,s*m);continue}const h=a.getAttributeStreamRef(t);this.m_vertexAttributes.get(i).insertRangeFromStream(s*(l+e),h,s*(g+n),r*s,o,s,s*m)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l+e,1,r,m),this.m_curveData.m_segmentParamIndex.insertRange(l+e,-1,r,m),e>0&&this.isNonLinearSegment(l+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(l+e-1),-1),this.m_curveData.m_segmentFlags.write(l+e-1,1),this.m_curveData.m_segmentParamIndex.write(l+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,_=this.getPathCount();i<=_;i++){const t=this.m_paths.read(i);this.m_paths.write(i,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e),n=Zs.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,n,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByValNoCurves(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,n=this.m_description.getAttributeCount();t<n;t++){const n=this.m_description.getSemantics(t),i=Zs.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(t).insertAttributes(i*a,s,n,i*r);else{const e=Zs.getDefaultValue(n);this.m_vertexAttributes.get(t).insertRange(i*a,e,i,i*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let s=t+1,i=n;s<=i;s++)this.m_paths.write(s,this.m_paths.read(s)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&i("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&i("Multi_path.remove_point");const o=n+e;for(let i=0,a=this.m_description.getAttributeCount();i<a;i++)if(this.m_vertexAttributes.get(i)){const t=this.m_description.getSemantics(i),e=Zs.getComponentCount(t);this.m_vertexAttributes.get(i).eraseRange(e*o,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let i=s;i>=t+1;i--){const t=this.m_paths.read(i);this.m_paths.write(i,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNextSegmentType(t){return this.hasNonLinearSegments()?this.m_curveData.m_segmentFlags.read(t):1}getPrevSegmentTypeFromPath(t,e){if(!this.hasNonLinearSegments())return 1;const s=this.getPathStart(t);if(e>s)return this.m_curveData.m_segmentFlags.read(e-1);if(e===s){if(this.isClosedPath(t)){const e=this.getPathEnd(t);return this.m_curveData.m_segmentFlags.read(e-1)}return 1}r("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),n=this.getPathEnd(t);s<n;s++)Us.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),n=Us.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=n,n}startPathCoords(t,e){this.startPathPoint(new F({x:t,y:e}))}startPath(t){this.startPathPoint(new F({pt:t}))}startPath3D(t){this.startPathPoint(new F({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new F({x:t,y:e,z:s}))}startPathPoint(e){e.isEmpty()&&t("");const s=e.getDescription();let n;if(this.m_description!==s){this.mergeVertexDescription(s);const t=new F({vd:this.m_description});e.copyCommonAttributesTo(t),n=t}else n=e;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,n):(this.insertPoint(-1,-1,n),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=L(2),this.m_paths.write(0,0),this.m_pathFlags=R(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,n=e+t;this.m_paths.write(s,n),this.resizeImpl(n),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoordsNoCurves(this.m_pointCount-1,t,e);else{const s=I(),n=new F({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});n.setXYCoords(t,e),this.setPointByValNoCurves(this.m_pointCount-1,n)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=v(this.m_description,S()),s=I(),n=new F({vd:e,attribBuffer:s,initDefaultValues:!0});n.setXYZ(t),this.setPointByValNoCurves(this.m_pointCount-1,n),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new E(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByValNoCurves(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=I(),s=new F({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(e){this.m_bPolygon&&r("");const s=this.getPathCount();if(e>s&&t(""),!this.isClosedPath(e))return;this.m_pathFlags||r("");const n=this.m_pointCount,i=this.getPathStart(e),o=this.getPathEnd(e);if(o-i!==0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=Zs.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*o,this.m_vertexAttributes.get(t),s*i,s,!0,1,s*n)}for(let t=s;t>e;t--){const e=this.m_paths.read(t);this.m_paths.write(t,e+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(o,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(o,-1,1,n)),this.m_pathFlags.clearBits(e,1)}}openPath(e){this.m_bPolygon&&r(""),e>this.getPathCount()&&t(""),this.m_pathFlags||r(""),this.m_pathFlags.clearBits(e,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&r(""),this.isEmpty())return;this.m_pathFlags||r("");let t=0;const e=this.getPathCount();for(let r=0;r<e;r++)this.isClosedPath(r)&&(this.getPathSize(r)>0?t++:this.m_pathFlags.clearBits(r,1));if(0===t)return;const s=this.hasNonLinearSegments();let n=0;const i=this.getPathCount(),o=this.m_description.getAttributeCount(),a=new Array(o);let h=null,u=null;for(let r=0;r<i;++r){const e=this.getPathStart(r),i=this.getPathSize(r),m=this.isClosedPath(r);if(i>0){const r=e+n;for(let s=0;s<o;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),o=Zs.getComponentCount(n);if(!a[s]){const e=o*(this.m_pointCount+t),i=N(n,e);a[s]=i}a[s].writeRange(r*o,i*o,this.m_vertexAttributes.get(s),e*o,!0,1),m&&a[s].writeRange((r+i)*o,o,this.m_vertexAttributes.get(s),e*o,!0,1)}if(s){if(null===h){const e=this.m_pointCount+t;h=R(e),u=L(e)}h.writeRange(r,i,this.m_curveData.m_segmentFlags,e,!0,1),u.writeRange(r,i,this.m_curveData.m_segmentParamIndex,e,!0,1),m&&(h.write(r+i,1),u.write(r+i,-1))}}this.m_paths.write(r,e+n),m&&(this.m_pathFlags.clearBits(r,1),++n)}this.m_paths.write(i,this.m_pointCount+t),this.m_pathFlags.clearBits(i,1);for(let r=0;r<o;r++)this.m_vertexAttributes.get(r)&&this.m_vertexAttributes.set(r,a[r]);s&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=u),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(e){void 0===e&&(e=this.getPathCount()-1),this.throwIfEmpty(),(e<0||e>=this.getPathCount())&&t("close_path_with_line"),e===this.getPathCount()-1&&(this.m_bPathStarted=!1);const s=this.m_pathFlags.read(e);if(1&s||this.m_pathFlags.write(e,1|s),this.m_curveData&&this.m_curveData.m_segmentFlags){const t=this.getPathEnd(e)-1,s=this.m_curveData.m_segmentFlags.read(t);1!==s&&(this.m_curveData.m_segmentFlags.write(t,1),this.m_curveData.m_segmentParamIndex.write(t,-1),this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(s,n){if(this.throwIfEmpty(),(s<0||s>=this.getPathCount())&&t("close_path_with_line"),n.getEndXY().equals(this.getXY(this.getPathStart(s)))||t("close_path_with_segment: end point mismatch"),s===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(n,!1),--this.m_pointCount,this.m_paths.write(s+1,this.m_pointCount);else{this.mergeVertexDescription(n.getDescription());const i=n.getStartXY(),r=this.getPathEnd(s)-1;i.equals(this.getXY(r))||t("close_path_with_segment: start point mismatch");const o=n.getGeometryType();if(o===e.enumLine)return void this.closePathWithLine(s);{const t=ks(n);this.initSegmentData(t);const e=Hs.toSegType(o),s=this.m_curveData.m_segmentFlags.read(r);if(s!==e)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),n.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(e,1),1!==s?this.incCurveType(s,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(r);n.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,e)}}const i=this.m_pathFlags.read(s);1&i||this.m_pathFlags.write(s,1|i),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const n=this.getXY(e),i=this.getXY(s);return n.isEqualPoint2D(i)}isClosedPathIn3D(t){return n(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Us.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof le)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),n=I(),i=new F({vd:s,attribBuffer:n,initDefaultValues:!1});for(let r=0,o=4;r<o;r++){const s=e?o-r-1:r;t.queryCornerByVal(s,i),0===r?this.startPathPoint(i):this.lineToPoint(i)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(e,s){if(e.isClosed()||t("add_path_from_closedSegment: segment must be closed"),s){const t=e.getReversed(),s=new F;t.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(t)}else{const t=new F;e.queryStart(t),this.startPathPoint(t),this.closeLastPathWithSegment(e)}}addSegment_(s,n){const i=s.getDescription();this.mergeVertexDescription(i);const r=I(),o=new F({vd:i,attribBuffer:r,initDefaultValues:!1}),a=s.getGeometryType();if(a===e.enumLine)(n||this.isEmptyImpl())&&(s.queryStart(o),this.startPathPoint(o)),s.queryEnd(o),this.lineToPoint(o);else{let e=!1;if((n||this.isEmptyImpl())&&(e=!0),!e){s.getStartXY().equals(this.getXY(this.m_pointCount-1))||t("add_segment: start point mismatch")}if(e&&(s.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),s.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=I(),e=new F({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const i=ks(s);this.initSegmentData(i),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),s.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=i;const r=Hs.toSegType(a);this.incCurveType(r,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,r)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(e,s,n,i){for(let a=e;a<n-1;a++)this.isClosedPath(a)&&t("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(e,s,n,i);if(0!==o)for(let t=1;t<r;t++){const r=this.m_description.getSemantics(t);this.interpolateAttributesSemanticsImpl(r,e,s,n,i,o)}}interpolateAttributesSemantics(e,s,n,i,r){if(0===e)return;this.hasAttribute(e)||t("does not have the given attribute");2===Zs.getInterpolation(e)&&t("angular interpolation");for(let a=s;a<i-1;a++)this.isClosedPath(a)&&t("cannot interpolate across closed paths");const o=this.calculateSubLength2D(s,n,i,r);0!==o&&this.interpolateAttributesSemanticsImpl(e,s,n,i,r,o)}interpolateAttributesPath(t,e,s){const n=this.m_description.getAttributeCount();if(1===n)return;if(e===s)return;const i=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<n;r++){const n=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(n,t,e,s,i)}}interpolateAttributesSemanticsPath(e,s,n,i){if(0===e)return;this.hasAttribute(e)||t("does not have the given attribute");2===Zs.getInterpolation(e)&&t("angular interpolation");const r=this.calculatePathSubLength2D(s,n,i);0!==r&&this.interpolateAttributesSemanticsPathImpl(e,s,n,i,r)}interpolateAttributesSemanticsImpl(t,e,s,n,i,r){const o=this.querySegmentIterator(),a=this.getPathStart(e)+s,h=this.getPathStart(n)+i,u=Zs.getComponentCount(t),m=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,a,m,u);const l=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,u);const c=et(Zs.maxComponentCount(),Number.NaN);st(c,m,0,0,u);let g=0;const d=Zs.getDefaultValue(t),_=Zs.getInterpolation(t);o.resetToVertex(a,e);do{if(o.hasNextSegment()){if(o.nextSegment(),o.getStartPointIndex()===h)return;this.setAttributeFromArray(t,o.getStartPointIndex(),c,u),o.previousSegment();do{const e=o.nextSegment();if(o.getEndPointIndex()===h)return;g+=e.calculateLength2D();dt(_,m,l,c,0,u,g/r,d),o.isClosingSegment()||this.setAttributeFromArray(t,o.getEndPointIndex(),c,u)}while(o.hasNextSegment())}}while(o.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,r){n(0!==t);const o=this.querySegmentIterator(),a=Zs.getInterpolation(t),h=this.getPathStart(e)+s,u=this.getPathStart(e)+i;if(u===h)return;const m=Zs.getComponentCount(t),l=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,m);const c=et(Zs.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,u,c,m);const g=new O(0);o.resetToVertex(h,e),o.setCirculator(this.isClosedPath(e));const d=Zs.getDefaultValue(t),_=et(Zs.maxComponentCount(),Number.NaN);st(_,l,0,0,m);const p=0===r;let f=.5;do{const e=o.nextSegment();if(this.setAttributeFromArrayNoCurves(t,o.getStartPointIndex(),_,m),!p){const t=e.calculateLength2D();g.pe(t),f=g.getResult()/r}dt(a,l,c,_,0,m,f,d)}while(o.getEndPointIndex()!==u)}querySegment(e,s,n){const i=this.getPathIndexFromPointIndex(e),r=e-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&t("get_segment"),this.getSegmentFromPath(i,r,s,n)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(e){const s=this.getPathIndexFromPointIndex(e),n=e-this.getPathStart(s);return n>=this.getSegmentCountPath(s)&&t("get_segment"),this.getSegmentTypeFromPath(s,n)}getSegmentFromPath(t,e,s,n){const i=this.getPathStart(t)+e,o=this.getSegmentFlagsStreamRef();let a=1;switch(o&&(a=31&o.read(i)),a){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:r("")}const h=s.get();let u,m=null;n?(m=P(),h.assignVertexDescription(m)):h.assignVertexDescription(this.m_description),u=i===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):i+1;qe(h,this.getXY(i));if(Ve(h,this.getXY(u)),!n)for(let r=1,l=this.m_description.getAttributeCount();r<l;r++){const t=this.m_description.getSemantics(r),e=Zs.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,i,s);h.setStartAttribute(t,s,e);const n=this.getAttributeAsDbl(t,u,s);h.setEndAttribute(t,s,n)}}if(Us.isNonLinearSegmentFlag(a)){const t=this.m_curveData.m_segmentParamIndex.read(i);h.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++){if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);Bs(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(e,s,n,i=!1){const r={iSegment:-1},o=i?r:{tSegment:0};if(n.setEmpty(),this.isEmpty())return r;if((e<0||e>=this.getPathCount())&&t("query_point_along_path"),s<0)return r;const a=this.getPathSize(e);if(0===a)return r;if(1===a)return this.getPointByVal(this.getPathStart(e),n),o.tSegment=0,r.iSegment=this.getPathStart(e),r;const h=this.querySegmentIteratorAtVertex(this.getPathStart(e)),u=new O(0);for(;h.hasNextSegment();){const t=h.nextSegment(),e=t.calculateLength2D(),i=u.getResult();if(u.add(e),u.getResult()>=s){let a=s-i;a>e&&(a=e);const u=t.lengthToT(a);return t.queryCoord(u,n),o.tSegment=u,r.iSegment=h.getStartPointIndex(),r}}if(this.isClosedPath(e)){const t=this.getPathStart(e);return this.getPointByVal(t,n),o.tSegment=1,r.iSegment=this.getPathEnd(e)-1,r}{const t=this.getPathEnd(e)-1;return this.getPointByVal(t,n),this.getPathSize(e)>1?(o.tSegment=1,r.iSegment=this.getPathEnd(e)-2,r):(o.tSegment=0,r.iSegment=this.getPathStart(e),r)}}queryPointsAlongPath(e,s,n,i,r,o){{let e=0;for(let a=0;a<s;++a)i&&i[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),e>n[a]&&t("query_points_along"),e=n[a]}const a=this.getPathSize(e);if(0===s||0===a)return 0;if(1===a){const t=this.getPathStart(e);return i&&this.getPointByVal(t,i[0]),o&&(o[0]=0),r&&(r[0]=t),1}const h=this.getPathStart(e),u=new O(0),m=this.querySegmentIteratorAtVertex(h);let l=0,c=0,g=n[l];for(;m.hasNextSegment();){const t=m.nextSegment(),e=t.calculateLength2D(),a=u.getResult();for(u.add(e);u.getResult()>=g;){let h=g-a;h>e&&(h=e);const u=t.lengthToT(h);if(i&&t.queryCoord(u,i[c]),o&&(o[c]=u),r&&(r[c]=m.getStartPointIndex()),c++,l++,g=n[l],l===s)return c}}if(this.isClosedPath(e)){const t=this.getPathStart(e),s=0;i&&this.getPointByVal(t,i[c]),o&&(o[c]=s),r&&(r[c]=t),c++}else if(this.getPathSize(e)>1){const t=this.getPathEnd(e)-2,s=1;i&&this.getPointByVal(t+1,i[c]),o&&(o[c]=s),r&&(r[c]=t),c++}return c}queryPointsAlong(e,s,n,i,r){{let o=0;for(let a=0;a<e;++a)n&&n[a].setEmpty(),i&&(i[a]=-1),r&&(r[a]=0),o>s[a]&&t("query_points_along"),o=s[a]}if(0===e)return 0;const o=new O(0),a=this.querySegmentIterator();let h=-1,u=0,m=0,l=s[u];for(;a.nextPath();)for(;a.hasNextSegment();){h=a.getPathIndex();const t=a.nextSegment(),c=t.calculateLength2D(),g=o.getResult();for(o.add(c);o.getResult()>=l;){let o=l-g;o>c&&(o=c);const h=t.lengthToT(o);if(n&&t.queryCoord(h,n[m]),r&&(r[m]=h),i&&(i[m]=a.getStartPointIndex()),m++,u++,l=s[u],u===e)return m}}if(h<0)return 0;if(this.isClosedPath(h)){const t=this.getPathStart(h),e=0;n&&this.getPointByVal(t,n[m]),r&&(r[m]=e),i&&(i[m]=t),m++}else if(this.getPathSize(h)>1){const t=this.getPathEnd(h)-2,e=1;n&&this.getPointByVal(t+1,n[m]),r&&(r[m]=e),i&&(i[m]=t),m++}return m}querySegmentIterator(){return new Vs({parent:this})}querySegmentIteratorAtVertex(t){return new Vs({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(e,s,i){if(s instanceof C&&n(0,"not implemented for Envelope"),s instanceof T&&n(0,"not implemented for Envelope3D"),(e>=this.getPathCount()||e<0)&&t(""),this.isEmpty())return void s.setEmpty();const r=this.getAttributeStreamRef(0),o=le.constructEmpty();o.setEmpty();for(let t=2*this.getPathStart(e),a=2*this.getPathEnd(e);t<a;){const e=a-t;n(!(1&e)),o.mergePointsInterleaved(r,t/2,e/2),t+=e}if(s.setCoords({env2D:o}),this.hasNonLinearSegmentsPath(e)){const t=this.querySegmentIterator();if(t.resetToPath(e),t.nextPath())for(;t.hasNextSegment();){const e=t.nextCurve();if(!e)break;{const t=le.constructEmpty();i?e.queryEnvelope(t):e.queryLooseEnvelope(t),s.mergeEnvelope2D(t)}}else n(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=10,e=Gs(4)*this.m_curveData.m_arcCount+Gs(2)*this.m_curveData.m_bezierCount+Gs(8)*this.m_curveData.m_rbezier2Count+Gs(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*e>>1,t)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let n=0,i=this.getPointCount();n<i;n++){const e=this.m_curveData.m_segmentFlags.read(n);if(Us.isNonLinearSegmentFlag(e)){t+=Gs(e)}}const e=z(t);let s=0;for(let n=0,i=this.getPointCount();n<i;n++){const t=this.m_curveData.m_segmentFlags.read(n);if(Us.isNonLinearSegmentFlag(t)){let i=this.m_curveData.m_segmentParamIndex.read(n);this.m_curveData.m_segmentParamIndex.write(n,s);const r=Gs(t);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(i)),s++,i++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){n(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=L(0),this.m_pathFlags=R(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=L(0),this.m_pathFlags=R(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,this.m_bPolygon?1:0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new Os(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,n){this.m_curveData||(this.m_curveData=new Hs),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=n}static getPathIndexFromPointIndexImpl(t,e,s,n){if(n>=0&&n<e){if(s>=t.read(n)){if(s<t.read(n+1))return n;n++}else n--;if(n>=0&&n<e&&s>=t.read(n)&&s<t.read(n+1))return n}if(e<5){for(let n=0;n<e;n++)if(s<t.read(n+1))return n;g("")}let i=0,r=e-1;for(;r>i;){const e=i+(r-i>>1);if(s<t.read(e))r=e-1;else{if(!(s>=t.read(e+1)))return e;i=e+1}}return i}getHighestPointIndex(t){n(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),s=this.getPathEnd(t),i=this.getPathStart(t);let r=-1;const o=new K;o.y=Number.NEGATIVE_INFINITY,o.x=Number.NEGATIVE_INFINITY;for(let n=i+0;n<s;n++){const t=e.readPoint2D(2*n);-1===o.compare(t)&&(r=n,o.setCoordsPoint2D(t))}return r}applyTransformationToPath(e,s){if(s>=this.getPathCount()&&t("apply_transformation"),this.isEmpty())return;if(e.isIdentity())return;const n=this.m_vertexAttributes.get(0);if(!(s<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(s))){let t,i;return s<0?(t=0,i=this.m_pointCount):(t=this.getPathStart(s),i=this.getPathEnd(s)),n.applyTransformation(e,2*t,i-t),void this.notifyModifiedFlags(2001)}const i=new this.m_segmentBufferCTor,r=this.getPathCount();let o=s<0?0:s;do{const t=this.getPathStart(o),r=this.getPathEnd(o),a=this.isClosedPath(o),h=n.readPoint2D(2*t);if(!this.hasNonLinearSegmentsPath(o)){n.applyTransformation(e,2*t,r-t);continue}const u=K.getNAN();for(let s=t;s<r;++s){if(1!==(31&this.m_curveData.m_segmentFlags.read(s))){const o=a&&s+1===r;o&&n.writePoint2D(2*t,h),this.getSegmentBuffer(s,i,!0),i.get().applyTransformation(e);const u=this.m_curveData.m_segmentParamIndex.read(s);i.get().writeInBufferStream(this.m_curveData.m_segmentParams,u),n.writePoint2D(2*s,i.get().getStartXY()),o&&n.writePoint2D(2*t,i.get().getEndXY());continue}const o=2*s;n.queryPoint2D(o,u),e.transformInPlace(u),n.writePoint2D(o,u)}if(o===s)break}while(++o<r);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,n){const i=this.getPathStart(t)+e,r=this.getPathStart(s)+n;(r<i||i<0||r>this.getPointCount()-1)&&d("");const o=this.querySegmentIterator();let a=0;o.resetToVertex(i,t);do{for(;o.hasNextSegment();){const t=o.nextSegment();if(o.getStartPointIndex()===r)break;a+=t.calculateLength2D()}if(o.getStartPointIndex()===r)break}while(o.nextPath());return a}calculatePathSubLength2D(e,s,n){const i=this.getPathStart(e)+s,r=this.getPathStart(e)+n;(i<0||r>this.getPointCount()-1)&&d("");const o=this.querySegmentIterator();if(i>r&&(this.isClosedPath(e)||t("cannot iterate across an open path"),o.setCirculator(!0)),i===r)return 0;let a=0,h=0;o.resetToVertex(i,e);do{h+=a;a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==r);return h}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=le.constructEmpty(),n=this.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const i=n.nextCurve();if(!i)break;t?i.queryEnvelope(s):i.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(e,s){this===e&&t("Multi_path_impl::add");let n=this.getPathCount();for(let t=0,i=e.getPathCount();t<i;t++)this.addPath(e,t,!s),this.openPathAndDuplicateStartVertex(n),n++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(e,s,n){const i=this.getPathIndexFromPointIndex(e),r=e-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&t("getSegmentBuffer"),this.getSegmentFromPath(i,r,s,n)}getSegmentTypeFromPath(t,s){const n=this.getPathStart(t)+s,i=this.getSegmentFlagsStreamRef();let o=1;switch(i&&(o=31&i.read(n)),o){case 1:return e.enumLine;case 2:return e.enumBezier;case 4:return e.enumEllipticArc;case 8:return e.enumRationalBezier2;case 16:return e.enumBezier2;default:r("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,n=this.getPathCount();e<n;e++){const n=this.getPathStart(e),i=this.getPathEnd(e),r=i-n;for(let e=n;e<i;e++){const i=31&this.m_curveData.m_segmentFlags.read(e);if(1===i)continue;2!==i&&s("ensure_xy_monotone_segments");const o=(e-n+1)%r+n,a=this.m_curveData.m_segmentParamIndex.read(e),h=ut(K,4);h[0]=this.getXY(e),h[3]=this.getXY(o),h[1].x=this.m_curveData.m_segmentParams.read(a),h[1].y=this.m_curveData.m_segmentParams.read(a+1),h[2].x=this.m_curveData.m_segmentParams.read(a+2),h[2].y=this.m_curveData.m_segmentParams.read(a+3),we(h)&&(t=!0,this.m_curveData.m_segmentParams.write(a,h[1].x),this.m_curveData.m_segmentParams.write(a+1,h[1].y),this.m_curveData.m_segmentParams.write(a+2,h[2].x),this.m_curveData.m_segmentParams.write(a+3,h[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ls),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=B(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ls),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=k(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Us.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new Hs),Us.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new Hs),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Hs);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=R(e,1),this.m_curveData.m_segmentParamIndex=L(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=z(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new Hs),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let n=0;n<t;n++){const t=this.m_cachedRingAreas2D.read(n);0===s&&(s=Xt(t)),t*s>0||0===s?e.setBits(n,8):e.clearBits(n,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(e,s,i){(e<0||e>=this.getPointCount())&&t("Multi_path_impl.replace_segment"),n(s.isCurve());const r=this.getPathIndexFromPointIndex(e),o=this.getPathStart(r),a=(e-o+1)%this.getPathSize(r)+o;{const t=this.getXY(e),i=this.getXY(a),r=!t.isEqualPoint2D(s.getStartXY())||!i.isEqualPoint2D(s.getEndXY());n(!r)}this.replaceSegmentImpl(e,a,s,i)}replaceSegmentImpl(t,e,s,i){const r=s.getDescription();this.mergeVertexDescription(r);const o=et(32,Number.NaN),a=new F({vd:r,attribBuffer:o,initDefaultValues:!1}),h=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),u=Gs(h),m=ks(s);let l,c=!1;u>=m?(n(null!==this.m_curveData),c=!0,l=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(m),c=!1,l=this.m_curveData.m_curveParamWritePoint);const g=s.getGeometryType(),d=Hs.toSegType(g);i||(s.queryStart(a),this.setPointByValNoCurves(t,a),s.queryEnd(a),this.setPointByValNoCurves(e,a)),this.m_curveData.m_segmentParamIndex.write(t,1!==d?l:-1),this.m_curveData.m_segmentFlags.write(t,d),1!==d&&s.writeInBufferStream(this.m_curveData.m_segmentParams,l),c||(this.m_curveData.m_curveParamWritePoint+=m),h!==d&&(this.incCurveType(h,-1),this.incCurveType(d,1),this.modifyCurveCounter(1===h?1:-1))}setAttributeImpl(e,s,n){if(this.addAttribute(e),!this.isEmpty())if(this.hasNonLinearSegments()&&0===e){(s<0||s>1)&&t("");const e=new ce,i=0===s?n:0,r=0===s?0:1;e.setShiftCoords(i,r),0===s?e.xx=0:e.yy=0,this.applyTransformation(e)}else super.setAttributeImpl(e,s,n)}toFlatGeometry(){const t=this.m_bPolygon?"polygon":"polyline",e=this.getPathCount(),s=this.m_paths?this.m_paths.getArray():new Int32Array,n=this.m_paths?this.m_pathFlags.getArray():new Int8Array;let i,r,o,a=0,h=0;if(this.m_curveData){const{m_segmentFlags:t,m_segmentParamIndex:e,m_segmentParams:s}=this.m_curveData;i=t?.getArray()??new Int8Array,r=e?.getArray()??new Int32Array,o=s?.getArray()??new Float64Array,a=this.m_curveData.m_arcCount,h=this.m_curveData.m_bezierCount}return{type:t,...this.exportVertexAttributes(),partCount:e,partOffsets:s,partFlags:n,segmentFlags:i,segmentIndices:r,segmentParams:o,segmentCountArc:a,segmentCountBezier:h}}}Us.st_totalCurveCount=0;class Os{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new le(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e);return this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=le.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class Qs extends Us{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Pm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Pm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Pm):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Pm,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Pm,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):r("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Pm)}getBoundary(){return $s(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Qs.type}getDimension(){return 1}createInstance(){return new Qs({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Qs.type=e.enumPolyline;var Js=e;function Ks(t,e){if(t.isEmpty())return!1;const n=t.getGeometryType();if(n===Js.enumPolygon)return 0!==t.calculateArea2D();if(n===Js.enumPolyline)return tn(t.getImpl(),e,!0).bNotEmpty;if(n===Js.enumEnvelope)return!0;if(m(n))return!!t.isClosed();if(l(n))return!1;if(n===Js.enumGeometryCollection){const s=t;for(let t=0,n=s.getGeometryCount();t<n;t++)if(Ks(s.getGeometry(t),e))return!0;return!1}s("")}function $s(t,e){const n=t.getGeometryType();if(n===Js.enumPolygon){const e=new Qs({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(n===Js.enumPolyline)return tn(t.getImpl(),e,!1).boundary;if(n===Js.enumEnvelope){const e=new Qs({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(m(n)){const e=new gs({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new F;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(n===Js.enumGeometryCollection){const s=t;let n=null;for(let i=0,r=s.getGeometryCount();i<r;i++){const r=$s(s.getGeometry(i),e);if(null!==r){null===n&&(n=t.createInstance());const e=r;n.addGeometry(e)}}return n}if(l(n))return new F({vd:t.getDescription()});s("")}function tn(t,e,s){const n=!1,i=t;let r=null;if(s||(r=new gs({vd:i.getDescription()})),!i.isEmpty()){const t=new j(0);for(let e=0,s=i.getPathCount();e<s;e++){if(i.getPathSize(e)>0&&!i.isClosedPathInXYPlane(e)){const s=i.getPathStart(e);t.add(s);const n=i.getPathEnd(e)-1;t.add(n)}}if(t.size()>0){const e=new W,n=i.getAttributeStreamRef(0),o={userSort(t,e,s){const i=K.getNAN(),r=K.getNAN();s.sort(t,e,(t,e)=>(n.queryPoint2D(2*t,i),n.queryPoint2D(2*e,r),i.compare(r)))},getValue:t=>n.read(2*t+1)};e.sort(t,0,t.size(),o);let a=n.readPoint2D(2*t.read(0)),h=0,u=1;const m=new F;for(let i=1,r=t.size();i<r;i++){const e=n.readPoint2D(2*t.read(i));if(e.isEqualPoint2D(a))t.read(h)>t.read(i)?(t.write(h,Nt()),h=i):t.write(i,Nt()),u++;else{if(1&u){if(s)return{bNotEmpty:!0,boundary:new gs({})}}else t.write(h,Nt());a=e,h=i,u=1}}if(1&u){if(s)return{bNotEmpty:!0,boundary:new gs({})}}else t.write(h,Nt());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==Nt();e++)i.getPointByVal(t.read(e),m),r.add(m)}}}return s?{bNotEmpty:n,boundary:new gs({})}:{bNotEmpty:n,boundary:r}}function en(t,e,s,i){const r=4*ct()*(Math.abs(e.vmin)+Math.abs(e.vmax)),o=ct();if(1===t.getMaxDerivative()){n(s>0);const o=un(t,0,e,ct(),r);return i[0]=o.root,o.cRoots}let a,h=[];const u=new U(e.vmin-r,e.vmax+r);h.push(new K(u.vmin,u.vmax));let m=0;for(let n=t.getMaxDerivative()-1;n>=0;n--){a=h,h=[];for(let u=0,l=a.length;u<l;u++){if(a[u][0]<a[u][1]){let l,c,g;if(n===t.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:g}=un(t,n,U.construct(a[u][0],a[u][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:g}=mn(t,n,U.construct(a[u][0],a[u][1]),o,.5*r)),1===g){if(0===n){if(m<s){if(a[u][0]<=e.vmin&&a[u][1]>=e.vmin&&l!==e.vmin){0===t.getValue(0,e.vmin)&&(l=e.vmin)}if(a[u][0]<=e.vmax&&a[u][1]>=e.vmax&&l!==e.vmax){0===t.getValue(0,e.vmax)&&(l=e.vmax)}i[m]=e.snapClip(l),m>0?i[m]-i[m-1]>r&&m++:m++}}else{const t=K.getNAN();t[0]=a[u][0],t[1]=l,h.push(t);const e=K.getNAN();e[0]=l,e[1]=a[u][1],h.push(e)}continue}}h.push(a[u])}}return m}function sn(t,e,s,n){const i=new rt,r=gn(new rt(t),new rt(e),s,i);return n[0]=i.value(),r}function nn(t,e,s,n,i,r){const o=ut(rt,2),a=dn(new rt(t),new rt(e),new rt(s),n,i,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function rn(t,e,s,n,i,r,o){const a=ut(rt,3),h=_n(new rt(t),new rt(e),new rt(s),new rt(n),i,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function on(t,e,s,n,i,r,o,a){return hn(t,e,s,n,i,r,o,a)}function an(t,e,s,n,i,r){return cn(t,e,s,n,i,r)}function hn(t,e,s,n,i,r,o,a){const h=et(s*s,Number.NaN);h.fill(0),st(a,n,0,0,s);const u=et(s,Number.NaN),m=et(s,Number.NaN),l=et(s,Number.NaN);let c=t(a,s,e);const g=100;let d=0;for(d=0;d<g;d++){const n=c;for(let t=0;t<s;++t)m[t]=a[t];if(d%s===0){h.fill(0);for(let t=0;t<s;t++)h[t*s+t]=1}let o=0,g=0;for(let m=0;m<s;++m){for(let t=0;t<s;++t)u[t]=h[m*s+t];const n=c;c=ln(t,e,a,u,i,r,s);const l=n-c;l>o&&(g=m,o=l)}for(let t=0;t<s;t++)u[t]=a[t]-m[t],l[t]=a[t]+(a[t]-m[t]);const _=t(l,s,e);if(_<n){if(2*(n-2*c+_)*Bt(n-c-o)<Bt(n-_)*o){c=ln(t,e,a,u,i,r,s);for(let t=0;t<s;++t)h[g*s+t]=h[(s-1)*s+t],h[(s-1)*s+t]=u[t]}}if(n<=c)return t(a,s,e)}return c}function un(t,e,s,n,i){const o={root:0,funcAtRoot:0,cRoots:0};let a=s.vmin,h=s.vmax,u=0,m=Number.MAX_VALUE,l=t.getValue(e,a),c=t.getValue(e,h),g=0,d=0,_=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(o.funcAtRoot=l,o.root=a,o.cRoots=0===l?1:0,o):(o.funcAtRoot=c,o.root=h,o.cRoots=0===c?1:0,o);Math.abs(l)<Math.abs(c)&&(h=Q(a,a=h),c=Q(l,l=c)),u=a,g=l;let p=!0,f=0;for(;0!==c&&Math.abs(a-h)>n*Math.abs(h)+i;f++){let s=f>64;if(!s){d=l!==g&&c!==g?a*c*g/((l-c)*(l-g))+h*l*g/((c-l)*(c-g))+u*l*c/((g-l)*(g-c)):h-c*(h-a)/(c-l);const t=(3*a+h)/4;if(s=!(d>t&&d<h||d>h&&d<t),!s){const t=n*Math.abs(h)+i;if(p){const e=Math.abs(h-u);s=Math.abs(d-h)>=.5*e||e<t}else{const e=Math.abs(u-m);s=Math.abs(d-h)>=.5*e||e<t}}}if(s?(d=(a+h)/2,p=!0):p=!1,_=t.getValue(e,d),0===_)return o.root=d,o.funcAtRoot=_,o.cRoots=1,o;if(!s){const s=a-d,n=d-h;if(Math.abs(s)>10*Math.abs(n)){let s=h+3*n;for(let n=0;n<2;n++){const n=t.getValue(e,s);Xt(l)*Xt(n)>0?(a=s,l=n):s=nt(a,h,.75)}}else if(Math.abs(n)>10*Math.abs(s)){let n=a-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,n);Xt(c)*Xt(s)>0?(h=n,c=s):n=nt(a,h,.25)}}}m=u,u=h,g=c,Xt(l)*Xt(_)<0?(h=d,c=_):(a=d,l=_),Math.abs(l)<Math.abs(c)&&(h=Q(a,a=h),c=Q(l,l=c)),128===f&&r("Root_finder iterations exceeded")}return o.root=h,o.funcAtRoot=c,o.cRoots=1,o}function mn(t,e,s,n,i){const o={root:0,funcAtRoot:0,cRoots:0};let a=s.vmin,h=t.getValue(e,a),u=s.vmax,m=t.getValue(e,u);if(h>=0&&m>=0||h<=0&&m<=0)return Math.abs(h)<Math.abs(m)?(o.funcAtRoot=h,o.root=a,o.cRoots=0===h?1:0,o):(o.funcAtRoot=m,o.root=u,o.cRoots=0===m?1:0,o);m<0&&(m=Q(h,h=m),u=Q(a,a=u));let l=.5*(a+u),c=Math.abs(u-a),g=c,d=t.getValue(e,l),_=t.getValue(e+1,l);const p=1,f=4;let P=f;const y=2;let x=1,C=0,v=0,b=p;const S=32;let E=0;for(;++E<100;){let s;E>S||0===_||b===y&&C>1||b===p&&P<f?(b=p,x>1&&x--):(b=y,v>1&&Math.abs(2*d)>Math.abs(c*_)&&x++),c=g;let n=!1;if(b===p)do{if(v>2){const t=16*Math.abs(c);if(.5*Math.abs(a-u)>t){const e=Math.min(a,u),n=Math.max(a,u);if(l===e){s=l,l=e+t,g=l-s;break}if(l===n){s=l,l=n-t,g=l-s;break}}}g=.5*(u-a),s=l,l=a+g,n=a===l||u===l}while(0);else for(;;){g=x*d/_,s=l,l-=g,n=l===s;const t=Math.min(a,u),e=Math.max(a,u);if(l<t){if(x>1){l=s,x--;continue}g=s-t,l=t}else if(l>e){if(x>1){l=s,x--;continue}g=s-e,l=e}break}if(n||Math.abs(g)<i){s!==l&&(d=t.getValue(e,l));break}d=t.getValue(e,l),_=t.getValue(e+1,l);const r=a,o=u;d<0?(h=d,a=l):(m=d,u=l),b===y&&(a===r&&u===o||v>1&&Math.abs(g)>=.5001*Math.abs(c))?C++:C=0,b===p?(P++,v=0):(P=0,v++)}return 100===E&&r("Root_finder iterations exceeded"),o.root=l,o.funcAtRoot=d,o.cRoots=1,o}function ln(t,e,s,n,i,r,o){const a=n.slice(0,o);let h=0;for(let f=0;f<o;f++)h+=n[f]*n[f];if(h=Math.sqrt(h),h>0)for(let f=0;f<o;f++)a[f]/=h;let u=Number.NEGATIVE_INFINITY,m=Number.POSITIVE_INFINITY;{const t=et(o,0);for(let e=0;e<o;e++)t[e]=e;t.sort((t,e)=>{const s=Math.abs(a[t]),n=Math.abs(a[e]);return s<n?-1:s>n?1:0});for(let e=0;e<o;e++){const n=t[e];if(0===a[n])continue;let o=(i[n]-s[n])/a[n],h=(r[n]-s[n])/a[n];h<o&&(h=Q(o,o=h)),o>u&&(u=o),h<m&&(m=h)}}let l=0;const c=(Math.abs(u)+Math.abs(m))*ct()*100,g=et(o,Number.NaN),d=a.slice();function _(n,i){for(let t=0,e=o;t<e;t++)g[t]=s[t]+n*d[t];return t(g,o,e)}c>0&&(l=an(_,null,u,0,m,c));const p=_(l);for(let f=0,P=o;f<P;f++)s[f]=gt(g[f],i[f],r[f]);return p}function cn(t,e,s,n,i,r){const o=me();let a=n,h=t(a,e),u=s,m=i,l=t(u,e),c=t(m,e);h>l&&(h=l,a=u),h>c&&(h=c,a=m);let g=u,d=m,_=l,p=c;_>p&&(_=Q(p,p=_),d=Q(g,g=d));let f=a-g,P=g-d;const y=.5*Math.min(r,m-u),x=2*y,C=100;let v,b=0;for(v=0;v<C&&!(m-u<=x);++v){const s=u+.5*(m-u);let n=b>0;if(!n&&Math.abs(P)<=y&&(n=!0,b=3),!n){const t=a-g,e=a-d,s=t*(h-p);let i=e*(h-_),r=e*i-t*s;i=2*(i-s),i>0&&(r=-r),i=Math.abs(i),0===i||Math.abs(r)>=Math.abs(i*P/2)||r<=i*(u-a)||r>=i*(m-a)?(n=!0,b=3):(P=f,f=r/i)}n&&(P=a>=s?u-a:m-a,f=o*P,b--);let i=a+f;i<u+y?i=u+y:i>m-y&&(i=m-y);const r=t(i,e);r<h?(i>=a?(u=a,l=h):(m=a,c=h),d=g,g=a,a=i,p=_,_=h,h=r):(i<a?(u=i,l=r):(m=i,c=r),r<=_||g===a?(d=g,g=i,p=_,_=r):(r<=p||d===a||d===g)&&(d=i,p=r))}return a}function gn(t,e,s,n){return t.isZero()?e.isZero()?-1:0:(n.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(n.value())?1:0)}function dn(t,e,s,n,i,r){if(0===t.value()){if(i)return r[0].set(1),n.containsCoordinate(r[0].value())?1:0;return gn(e,s,n,r[0])}if(i){let e=2;return r[0].set(1),r[1].setE(s).divThisE(t),r[1].eq(r[0])&&(r[1].set(1),e=1),n.containsCoordinate(r[1].value())||(e=1),n.containsCoordinate(r[0].value())||(e--,r[0].setE(r[1])),2===e&&r[0].value()>r[1].value()&&(r[1]=Q(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(Rt));if(o.lt(at))return 0;const a=new rt(e.value()>=0?1:-1),h=o.clone().sqrtThis(),u=new rt(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let m=0;r[0].setE(u.divE(t));const l=new rt(r[0].value()),c=new rt(t.value()).mulE(l).addE(new rt(e.value()).mulE(l).addE(new rt(s.value())));return c.isZero()||vn(r[0],t,e,s,r[0]),n.containsCoordinate(r[0].value())&&m++,0!==h.value()&&0!==u.value()?(r[m].assign(s.divE(u)),l.set(r[m].value()),c.assign(new rt(t.value()).mulE(l).addE(new rt(e.value()).mulE(l).addE(new rt(s.value())))),c.isZero()||vn(r[m],t,e,s,r[m]),n.containsCoordinate(r[m].value())&&m++,2===m&&r[0].value()>r[1].value()&&(r[1]=Q(r[0],r[0]=r[1])),m):m}function _n(t,e,s,n,i,r,o){if(0===t.value()){return dn(e,s,n,i,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=dn(t,e.addE(t),n.negate(),i,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(ot)&&(o[s-1]=Q(o[t],o[t]=o[s-1]),s--)}const h=o.slice(0,s);h.sort((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);for(let t=0;t<s;++t)o[t]=h[t];return s}return bn(t,e,s,n,i,o)}function pn(e,s,n,i,r,o){return(o<s||s<0)&&t("nth_degree_real_roots"),Sn(e,s,n,i,r)}function fn(t,e,s,n){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:n.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),n=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(n.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(n.value())}}}class Pn{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=0;for(let s=0,n=this.truePower-t;s<=n;++s){e.push(this.coefs[s+t].clone());let n=s+t,i=n--;for(let e=1;e<t;e++)i*=n--;e[s].mulThis(i)}this.curCoefs=e}constructor(t,e,s,n){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let i=e;i>=1;i--)if(0!==this.coefs[i].value()){this.truePower=i;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const n=new O(0);let i=1;for(let r=0,o=this.truePower-t;r<=o;++r)n.pe(i*s[r].value()),i*=e;return n.getResult()}getError(t){const e=Math.abs(t),s=new O(0),n=new rt(1),i=new rt(0);for(let o=0,a=this.power;o<=a;++o)i.addThisE(this.coefs[o].mulE(n)),s.pe(n.value()*this.coefs[o].eps()),n.mulThis(e);s.pe(i.eps());let r=1;for(let o=1;o<=this.truePower;++o){r*=o,this.updateCoefs(o);const e=new rt(1),n=new rt(0);for(let s=0,i=this.truePower-o;s<=i;++s)n.addThisE(this.curCoefs[s].mulE(e)),e.mulThis(t);if(!n.isZero())return Math.pow(r*s.getResult()/Math.abs(n.value()),1/o)}return 0}}function yn(t,e,s,n,i,r){let o=t,a=e,h=a-o;if(!r){let s=n.calcF(t).value(),i=n.calcF(e).value();if((s>0||s>i)&&(a=Q(o,o=a),i=Q(s,s=i)),s>=0||i<=0)return!1}let u,m=!1,l=s,c=0;for(;c<100;c++){const t=n.calcF(l);if(u=n.calcDF(l),u.isZero())return!1;if(!t.value()||c>3&&t.isZero()){m=!0;break}r||(t.value()<0?o=l:a=l);const e=t.value()/u.value(),s=l-e;r||(s>=o&&s<=a||s>=a&&s<=o)&&Math.abs(e)<=.5*h?(l=s,h=Math.abs(e)):(h=Math.abs(.5*(a-o)),l=.5*(o+a))}return!!m&&(i.set(l,n.estimateError(l)),!0)}function xn(t,e,s,n,i,r,o,a){return yn(t,e,s.value(),fn(n,i,r,o),a,!1)}class Cn{constructor(t,e,s){this.coefs=ut(rt,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new rt(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new rt(t);return rt.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),n=new rt(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(n.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(n.value())}}function vn(t,e,s,n,i){return yn(0,0,t.value(),new Cn(e,s,n),i,!0)}function bn(t,e,s,n,i,o){const a=ut(rt,3);let h=0;const u=e.negate().divThisE(t.clone().mulThis(3));i.containsCoordinate(u.value())&&(a[0].setE(u),h=1);const m=ut(rt,2),l=dn(t.mul(3),e.mul(2),s,i,!1,m);if(l<0)return n.isZero()?-1:0;for(let r=0;r<l;r++)i.containsCoordinate(m[r].value())&&a[h++].setE(m[r]);ft(a,0,h,(t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);const c=ut(rt,5);c[0].set(i.vmin);for(let r=0;r<h;r++)c[1+r].setE(a[r]);c[1+h].set(i.vmax);const g=h+2;let d=1,_=0;{const i=c[0].clone();if(t.clone().mulThisE(i).addThisE(e).mulThisE(i).addThisE(s).mulThisE(i).addThisE(n).isZero()){const r=fn(t,e,s,n);i.setError(r.estimateError(i.value())),o[_]=i,_++,d++}}for(let p=d;p<g;p++){const a=c[p].clone(),h=t.clone().mulThisE(a).addThisE(e).mulThisE(a).addThisE(s).mulThisE(a).addThisE(n).isZero();if(h||!c[p].eq(c[p-1])){if(h||xn(c[p-1].value(),c[p].value(),c[p-1].clone().addThisE(c[p]).divThisByPower2(2),t,e,s,n,a)){if(_>0&&a.eq(o[_-1]))continue;if(_>=3&&r("cubic_polynomial_solver_too_many_roots"),h){const i=fn(t,e,s,n);a.setError(i.estimateError(a.value()))}o[_]=a,_++}if(c[p].value()===i.vmax)break;h&&p++}}return _}function Sn(t,e,s,n,i,r){const o=new Pn(t,e,s,ct());let a=0;if(2===o.truePower)a=dn(t[2],t[1],t[0],s,n,i);else if(1===o.truePower)a=gn(t[1],t[0],s,i[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=en(o,s,e,t);for(let e=0;e<a;e++)i[e].set(t[e])}}for(let h=0;h<a;h++)i[h].setError(o.getError(i[h].value()));return a}var En=b;class Dn extends ds{constructor(e){return void 0===e||bt(e,"vd")?(super({vd:e?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new K(0,0),void(this.m_weights=[1,0,1])):(e.fromPoint&&e.weight?e={fromPoint:e.fromPoint,controlPoint1:e.controlPoint1,toPoint:e.toPoint,weight0:1,weight1:e.weight,weight2:1}:e.points&&e.weight?e={fromPoint:e.points[0],controlPoint1:e.points[1],toPoint:e.points[2],weight0:1,weight1:e.weight,weight2:1}:e.points&&e.weights&&(e={fromPoint:e.points[0],controlPoint1:e.points[1],toPoint:e.points[2],weight0:e.weights[0],weight1:e.weights[1],weight2:e.weights[2]}),e.fromPoint&&e.weight0?(super({start:e.fromPoint,end:e.toPoint}),(e.weight0<=0||e.weight1<0||e.weight2<=0)&&t("weights"),this.m_cp=e.controlPoint1.clone(),void(this.m_weights=[e.weight0,e.weight1,e.weight2])):e.copy?(super(e),this.m_cp=e.copy.m_cp.clone(),void(this.m_weights=e.copy.m_weights.slice())):e.move?(super(e),this.m_cp=e.move.m_cp.clone(),void(this.m_weights=e.move.m_weights.slice())):void s("unexpected constructor param"))}getBoundary(){return $s(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,n){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,n,1),ca(this)}constructWeights(t,e,s,n,i,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,n,i,r),ca(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),ca(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return e.enumRationalBezier2}queryEnvelope(t){if(t instanceof le){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=La(this);if(null!==e){const s=new K;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[],s=ut(K,3);this.queryControlPoints(s),_a(s,this.m_weights,e);const n=new K;for(const i of e)this.queryCoord2D(i,n),t.mergeNe(n)}}}applyTransformation(t){if(t instanceof ce){const e=ut(K,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new Dn({vd:this.m_description})}calculateLength2D(){return pa(this,1,!1)}calculateLowerLength2D(){return K.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return K.distance(this.getStartXY(),this.m_cp)+K.distance(this.getEndXY(),this.m_cp)}return K.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){ch(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void ps(new fm({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void ps(new fm({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const n=ut(K,3);this.queryControlPoints(n),ph(n,this.m_weights,t,e)}getCoordX(t){const e=new K;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new K;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=En.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=En.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){Da(this,t,e)}cutBezierIgnoreAttributes(e,s,n){(e<0||s>1||e>s)&&t("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const i=ut(K,3);this.queryControlPoints(i);const r=[0,0,0];Ja(i,this.m_weights,e,s,i,r),n.setControlPointsAndWeights(i,r)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,r=En.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return vt(r,o,a,i,En.getDefaultValue(e))}getClosestCoordinate(t,e){return za(this,t,U.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return za(this,t,e,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(e,s){e.length<2&&t("");const i=da(this);let r=0;if(2===i.specialPointsCount())return 0;n(e.length>=i.specialPointsCount()-1);for(let t=1,n=i.specialPointsCount();t<n;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[r],s),r++;for(let t=0;t<r;++t){Ha(e[t].get())}return r}intersectionWithAxis2D(t,e,s,n){s&&(s.length=9),n&&(n.length=9);const i=new Array(3),r=ut(rt,2),o=new U(0,1);let a=0;const h=ut(K,3);if(this.queryControlPoints(h),t){if(i[0]=new rt(h[0].y).sub(e).mul(this.m_weights[0]),i[1]=new rt(h[1].y).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new rt(h[2].y).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let u=0;u<a;u++)s[u]=this.getCoordX(r[u].value())}else if(i[0]=new rt(h[0].x).sub(e).mul(this.m_weights[0]),i[1]=new rt(h[1].x).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new rt(h[2].x).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let u=0;u<a;u++)s[u]=this.getCoordY(r[u].value());if(n)for(let u=0;u<a;u++)n[u]=r[u].value();else s&&ft(s,0,a,kt);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[Number.NaN,Number.NaN],i=this.intersectionWithAxis2D(!0,t,s,null);return n(2!==i),-1===i?e:s[0]}isCurve(){return!0}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof le)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=le.constructEmpty();this.queryEnvelope(t);const s=U.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=ut(K,3);this.queryControlPoints(s);const n=[0,0,0];Ja(s,this.m_weights,t.vmin,t.vmax,s,n),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),n=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):n&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return pa(this,t,!0)}lengthToT(t){return Ia(this,t)}calculateWeightedAreaCentroid2D(t){const e=Xa(this),s=Ma(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new K;return this.isDegenerate(0)?(t.setCoords(0,0),t):Va(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Oa(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}queryCoord2DMP(t,e){const s=ut(K,3);return this.queryControlPoints(s),dh(s.map(t=>Ee.constructPoint2D(t)),this.m_weights.map(t=>tt.constructDouble(t)),tt.constructDouble(t),e)}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=ut(K,3);return this.queryControlPoints(e),Aa(e,this.m_weights,t)}getDerivative(t){const e=gt(t,0,1),s=ut(K,4);return fa(this,1,e,s),s[1]}getCurvature(t){const e=ut(K,4);fa(this,2,t,e);const s=e[1].sqrLength();if(0===s)return Number.NaN;e[1].divThis(Math.sqrt(s));return e[1].crossProduct(e[2])/s}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,n,i=1){return!1}isMonotoneQuickAndDirty(){const t=ut(K,3);return this.queryControlPoints(t),Za(t)}getMonotonicPartParams(e,s){const n=da(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();e<i&&t("");for(let t=0;t<i;t++)s[t]=n.specialPoints[t];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=Q(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=ut(K,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(K.distance(e[0],e[1])+K.distance(e[2],e[1])-n>t)return!1;const i=t,r=e[1].clone();r.subThis(e[0]);return!(Math.abs(r.crossProduct(s))/n>i)}copyIgnoreAttributes(t){const e=ut(K,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Ma(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return n(0),0}queryEnvelopeW(t,e){Wa(this,t,e)}setSegmentFromCoordsForStitcher(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=ut(K,3);this.queryControlPoints(e);const s=K.sqrDistance(e[1],e[0]),n=K.sqrDistance(e[1],e[2]);let i=e[0].clone(),r=s;s>n&&(i=e[2].clone(),r=n);let o=!1;return r<=t&&0!==r&&(o=!0,this.setControlPoint1(i)),o}needsSnapControlPoints(t){if(!t)return!1;const e=ut(K,3);this.queryControlPoints(e);const s=K.sqrDistance(e[1],e[0]),n=K.sqrDistance(e[1],e[2]);e[0].clone();let i=s;return s>n&&(e[2].clone(),i=n),i<=t&&0!==i}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ha(this)}setCoordsForIntersector(t,e,s){$a(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],Ra(e,La(this))}reverseImpl(){this.m_weights[2]=Q(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let s=0;s<3;s++)if(this.m_weights[s]!==e.m_weights[s])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const n=ut(K,3);this.queryControlPoints(n);const i=ut(K,3);s.queryControlPoints(i);const r=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let o=0;o<3;o++){const t=new E;t.setCoordsPoint2DZ(n[o].mul(this.m_weights[o]),this.m_weights[o]);const s=new E;if(s.setCoordsPoint2DZ(i[o].mul(r[o]),r[o]),!t.isEqual(s,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=Q(this.m_cp,this.m_cp=e.m_cp),e.m_weights=Q(this.m_weights,this.m_weights=e.m_weights),ga(this,e)}afterCompletedModification(){ca(this)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return Ga(this,t,e,s)}endPointModified(){ca(this)}clearEndPointModified(){}setCpsAndWeights(e,s,n,i,r,o){(i<=0||o<=0||r<0)&&t("weights"),(e.isNAN()||s.isNAN()||n.isNAN())&&t("NAN control points in bezier are not supported"),this.setStartXY(e),this.m_cp.assign(s),this.m_weights[0]=i,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(n)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}Dn.type=e.enumRationalBezier2;var wn=b;class An extends ds{constructor(t){void 0===t||bt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new K(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):r("unexpected constructor args")}getBoundary(){return $s(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),ri(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),ri(this)}getGeometryType(){return e.enumBezier2}queryEnvelope(t){if(2===t.m_EnvelopeType){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=xi(this);if(null!==e){const s=new K;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[];hi(this,e);const s=new K;for(const n of e)this.queryCoord2D(n,s),t.mergeNe(s)}return}s("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){const e=ut(K,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}n(0)}createInstance(){return new An({vd:this.m_description})}calculateLength2D(){return ui(this,1,!1)}calculateLowerLength2D(){return K.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return K.distance(this.getStartXY(),this.m_cp)+K.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const n=ut(K,3);this.queryControlPoints(n),Zi(n,t,e,s)}queryCoord2DE(t,e){Hi(this,t,e)}queryCoord2DMP(t,e){n(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){const e=new K;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=St(this.getStartX(),this.m_cp.x,t),s=St(this.m_cp.x,this.getEndX(),t);return St(e,s,t)}{const e=Et(this.getStartX(),this.m_cp.x,t),s=Et(this.m_cp.x,this.getEndX(),t);return Et(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new K;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=St(this.getStartX(),this.m_cp.x,t),s=St(this.m_cp.x,this.getEndX(),t);return St(e,s,t)}{const e=Et(this.getStartY(),this.m_cp.y,t),s=Et(this.m_cp.y,this.getEndY(),t);return Et(e,s,t)}}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=wn.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=wn.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){Oi(this,t,e)}cutBezierIgnoreAttributes(e,s,n){if((e<0||s>1||e>s)&&t("Quadratic_bezier.cut_bezier_ignore_attributes"),0===e&&1===s)return n.setStartXY(this.getStartXY()),n.m_cp.assign(this.m_cp),void n.setEndXY(this.getEndXY());const i=ut(K,3);this.queryControlPoints(i),Yi(i,e,s,i),n.constructPoints(i)}splitBezierIgnoreAttributes(t,e,s){n(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,r=wn.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return vt(r,o,a,i,wn.getDefaultValue(e))}getClosestCoordinate(t,e){return vi(this,t,U.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return vi(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(e,s){e.length<2&&t("");const i=ai(this);let r=0;if(2===i.specialPointsCount())return 0;n(e.length>=i.specialPointsCount()-1);for(let t=1,n=i.specialPointsCount();t<n;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[r],s),r++;for(let t=0;t<r;++t){Ai(e[t].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=ut(rt,3),r=ut(rt,2),o=new U(0,1);let a=0;if(t){if(i[0]=new rt(this.getStartY()).sub(e),i[1]=new rt(this.m_cp.y).subE(new rt(this.getStartY())).mulThisByPower2(2),i[2]=new rt(this.getStartY()).add(this.getEndY()).subE(new rt(this.m_cp.y).mulThisByPower2(2)),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordX(r[h].value())}else if(i[0]=new rt(this.getStartX()).sub(e),i[1]=new rt(this.m_cp.x).subE(new rt(this.getStartX())).mulThisByPower2(2),i[2]=new rt(this.getStartX()).add(this.getEndX()).subE(new rt(this.m_cp.x).mulThisByPower2(2)),a=dn(i[2],i[1],i[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordY(r[h].value());if(n)for(let h=0;h<a;h++)n[h]=r[h].value();else s&&Dt(s,a);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],i=this.intersectionWithAxis2D(!0,t,s,null);return n(2!==i),-1===i?e:s[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());n(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new le;this.queryEnvelope(t);const s=new U;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=ut(K,4);this.queryControlPoints(s),Yi(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),n=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):n&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return ui(this,t,!0)}lengthToT(t){return pi(this,t)}calculateWeightedAreaCentroid2D(t){const e=ut(K,3);ki(this,e);const s=e[2],n=e[1],i=new K,r=s.y*n.x-s.x*n.y;i.x=-(4*s.x+5*n.x)*r/60,i.y=-(4*s.y+5*n.y)*r/60;const o=fi(this);return i.x+=(e[0].x-t.x)*o,i.y+=(e[0].y-t.y)*o,i}calculateWeightedCentroid2D(){const t=new K;return this.isDegenerate(0)?(t.setCoords(0,0),t):yi(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Ii(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),3}setControlPoints(e){for(let s=0;s<3;s++)e[s].isNAN()&&t("NaN control points in bezier are not supported");this.m_XStart=e[0].x,this.m_YStart=e[0].y,this.m_cp.setCoordsPoint2D(e[1]),this.m_XEnd=e[2].x,this.m_YEnd=e[2].y,this.afterCompletedModification()}getTangent(t){const e=gt(t,0,1);let s=gi(this,1,e);return s.isZero()&&(s=gi(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return gi(this,1,gt(t,0,1))}getCurvature(t){const e=gi(this,1,t),s=gi(this,2,t),n=e.sqrLength();if(0===n)return Number.NaN;e.divThis(Math.sqrt(n));return e.crossProduct(s)/n}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const n=new le;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new K;this.queryCoord2D(i,r);return K.distance(r,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(e,s){const n=ai(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();e<i&&t("");for(let t=0;t<i;t++)s[t]=n.specialPoints[t];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){Q(this.m_XStart,this.m_XStart=this.m_XEnd),Q(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=ut(K,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(K.distance(e[0],e[1])+K.distance(e[2],e[1])-n>t)return!1;const i=t,r=e[1].clone();r.subThis(e[0]);return!(Math.abs(r.crossProduct(s))/n>i)}copyIgnoreAttributes(t){const e=ut(K,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return fi(this)}absNorm(){return Xi(this)}queryEnvelopeW(t,e){const s=ut(K,3);this.queryControlPoints(s),Di(s,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return tr(this,t)}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(t){return er(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ai(this)}setCoordsForIntersector(t,e,s){Ni(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Ci(e,xi(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=Q(this.m_cp,this.m_cp=e.m_cp),oi(this,e)}afterCompletedModification(){ri(this)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return Si(this,t,e.length,e,s)}endPointModified(){ri(this)}clearEndPointModified(){}}An.type=e.enumBezier2;class Tn{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),n(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map(t=>t.clone()))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map(t=>t.clone()),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map(t=>t.clone()),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}scaleRangeToUnitInterval(t,e){const s=e;s.subThis(t);const n=this.power();for(let i=0;i<=n;i++){const e=new this.m_zeroCtor;for(let s=i;s<=n;s++){const n=this.m_elements[s];n.mulDoubleThis(he(s,i));const r=t.pow(s-i);n.mulThis(r),e.addThis(n)}const r=s.pow(i);e.mulThis(r),this.m_elements[i]=e}}fmSubThis(t,e){return n(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let n=0;n<=e;++n)this.m_elements[n].addThis(t.m_elements[n]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return n(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let n=0;n<=e;++n)this.m_elements[n].subThis(t.m_elements[n]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n].clone(),this.m_elements[n].negateThis();return this.updatePower(),this}sub0(t){return n(0),this}subNumber0(t){return n(0),this}subShifted(t,e){const s=this.power(),n=t.power()+e,i=Math.min(this.power(),n);let r=0;for(let o=e;o<=i;++o)this.m_elements[o].subThis(t.m_elements[r]),r++;if(n<=s)return this.updatePower(),this;this.m_elements.length=n+1;for(let o=s+1;o<this.m_elements.length;++o)this.m_elements[o]=new this.m_zeroCtor;for(let o=i+1;o<=n;++o)this.m_elements[o].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const n=this.power(),i=t.power()+s,r=Math.min(this.power(),i);let o=0;for(let a=s;a<=r;++a)this.m_elements[a].fmSubThis(t.m_elements[o],e),o++;if(i<=n)return this.updatePower(),this;this.m_elements.length=i+1;for(let a=n+1;a<this.m_elements.length;++a)this.m_elements[a]=new this.m_zeroCtor;for(let a=r+1;a<=i;++a)this.m_elements[a].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,n=this.power();t<=n;t++)for(let i=0,r=e.power();i<=r;i++){const n=this.m_elements[t].clone();n.mulThis(e.m_elements[i]),t+i<s.length?s[t+i].addThis(n):s.push(n)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulDoubleThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulDoubleThis(t);return this.updatePower(),this}mulNumber0(t){return n(0),this}mulBigint0(t){return n(0),this}mulBigIntThis(t){return n(0),this}mulInt320(t){return n(0),this}div0(t){return n(0),this}absThis(){return n(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const n=t.getElement(t.power()),i=this.clone();let r=i.power();const o=i.power()-t.power();let a=o;for(e.m_elements=ut(e.m_zeroCtor,o+1);;){if(r<t.power()){s.assignMove(i);break}if(r===i.power()){const s=i.getElement(i.power());s.divThis(n),i.subShiftedWithCoef(t,s,i.power()-t.power()),e.m_elements[a]=s.clone()}a--,r--}s.updatePower(),e.updatePower()}divThis(t){return n(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let n=0;n<=e;++n)this.m_elements[n].subThis(t.m_elements[n]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let n=e+1;n<=s;++n)this.m_elements[n]=t.m_elements[n].clone(),this.m_elements[n].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){n(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let n=e-1;n>=0;--n)s.mulThis(t),s.addThis(this.m_elements[n]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,n=this.power();s<=n;s++){let n=BigInt(s);for(let e=s-1,i=s-t;e>i;--e)n*=BigInt(e);e.m_elements[s-t].mulBigIntThis(n)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(tt.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce((t,e)=>{const s=e.hiBitIndex();return t<s?s:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}evaluateDerivative(t){const e=this.power(),s=this.m_elements[e];s.mulDoubleThis(e);for(let n=e-1;n>=1;--n){s.mulThis(t);const e=this.m_elements[n];e.mulDoubleThis(n),s.addThis(e)}return s}static evaluateCoefs(t,e,s){const n=t.power();s.construct0(t.getElement(0).evaluate(e));for(let i=1;i<=n;++i)s.addElement(t.getElement(i).evaluate(e));s.updatePower()}}class In extends Tn{constructor(t){super(void 0===t?{zeroCtor:tt}:{...t,zeroCtor:tt})}clone(){return new In({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const n=t.clone();n.absThis();for(let i=e-1;i>=0;--i)s.mulThis(n),s.addThis(this.m_elements[i].abs());return s}}class Mn extends Tn{constructor(t){super(void 0===t?{zeroCtor:In}:{...t,zeroCtor:In})}clone(){return new Mn({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new In({coef0:t[s]}));return this.updatePower(),this}}function Yn(){return{polypoly1:new Mn,polypoly2:new Mn,polyX2:new In,polyY2:new In,polyX2Deriv:new In,polyY2Deriv:new In,polypolyX1:new Mn,polypolyY1:new Mn,polypolyX1Deriv:new Mn,polypolyY1Deriv:new Mn,lazyPolypolyD1:new Mn,lazyPolypolyD1Deriv:new Mn,lazyPolyD2:new In,lazyPolyD2Deriv:null,polypoly11:new Mn,polypoly12:new Mn,tempPp:new Mn,tempPp1:new Mn,tempPp2:new Mn,tempP:new In,tempP1:new In,tempP2:new In}}function Nn(t,e,s,i,o,a,h,u,m,l,c,g,d,_,p,f,P,y,x,C=!1){const v=Yn();v.polyX2.construct(h,u),v.polyY2.construct(m,l),v.polypolyX1.constructFromMPValues(t,e),v.polypolyY1.constructFromMPValues(s,i),v.polypoly11.assignCopy(v.polypolyX1),v.polypoly12.assignCopy(v.polypolyY1),c&&(v.lazyPolyD2.construct(c,g),v.polypoly11.mulElementThis(v.lazyPolyD2),v.polypoly12.mulElementThis(v.lazyPolyD2)),o?(v.lazyPolypolyD1.constructFromMPValues(o,a),v.lazyPolypolyD1Deriv=new Mn({copy:v.lazyPolypolyD1}),v.lazyPolypolyD1Deriv.derivative1This(),v.tempPp.assignCopy(v.lazyPolypolyD1),v.tempPp.mulElementThis(v.polyX2),v.polypoly11.subThis(v.tempPp),v.tempPp.assignCopy(v.lazyPolypolyD1),v.tempPp.mulElementThis(v.polyY2),v.polypoly12.subThis(v.tempPp)):(v.polypoly11.sub0This(v.polyX2),v.polypoly12.sub0This(v.polyY2)),v.polypolyX1Deriv.assignCopy(v.polypolyX1),v.polypolyX1Deriv.derivative1This(),v.polypolyY1Deriv.assignCopy(v.polypolyY1),v.polypolyY1Deriv.derivative1This(),o&&(v.polypolyX1Deriv.mulThis(v.lazyPolypolyD1),v.tempPp2.assignCopy(v.lazyPolypolyD1Deriv),v.tempPp2.mulThis(v.polypolyX1),v.polypolyX1Deriv.subThis(v.tempPp2),v.polypolyY1Deriv.mulThis(v.lazyPolypolyD1),v.tempPp2.assignCopy(v.lazyPolypolyD1Deriv),v.tempPp2.mulThis(v.polypolyY1),v.polypolyY1Deriv.subThis(v.tempPp2)),v.polyX2Deriv.assignCopy(v.polyX2),v.polyX2Deriv.derivative1This(),v.polyY2Deriv.assignCopy(v.polyY2),v.polyY2Deriv.derivative1This(),c&&(n(null===v.lazyPolyD2Deriv),v.lazyPolyD2Deriv=new In({copy:v.lazyPolyD2}),v.lazyPolyD2Deriv.derivative1This(),v.polyX2Deriv.mulThis(v.lazyPolyD2),v.tempP1.assignCopy(v.lazyPolyD2Deriv),v.tempP1.mulThis(v.polyX2),v.polyX2Deriv.subThis(v.tempP1),v.polyY2Deriv.mulThis(v.lazyPolyD2),v.tempP1.assignCopy(v.lazyPolyD2Deriv),v.tempP1.mulThis(v.polyY2),v.polyY2Deriv.subThis(v.tempP1)),v.polypoly1.assignCopy(v.polypoly11),v.polypoly1.mulElementThis(v.polyX2Deriv),v.tempPp.assignCopy(v.polypoly12),v.tempPp.mulElementThis(v.polyY2Deriv),v.polypoly1.addThis(v.tempPp),v.polypoly2.assignCopy(v.polypolyX1Deriv),v.polypoly2.mulElementThis(v.polyY2Deriv),v.tempPp.assignCopy(v.polypolyY1Deriv),v.tempPp.mulElementThis(v.polyX2Deriv),v.polypoly2.subThis(v.tempPp);let b=[];const S=[];P||(P=[]),f||(f=[]),Gn(v.polypoly11,v.polypoly12,v.tempP);const E=64,D=ee.ldexp(-59).toDouble(),w=[];let A=Wn(v.tempP,d,p,D,E,w,y,y);if(A<0)return-1;for(let Y=0;Y<A;Y++){const t=v.tempP1,e=v.tempP2;In.evaluateCoefs(v.polypoly11,w[Y],t);const s=se(t.m_elements,t.power()+1);s.sort((t,e)=>t.compare(e)),In.evaluateCoefs(v.polypoly12,w[Y],e);const i=se(e.m_elements,e.power()+1);i.sort((t,e)=>t.compare(e));const o=s[0],a=s.at(-1),h=i[0],u=i.at(-1);a.subThis(o),u.subThis(h);const m=a.subThis(u).GEZ(),l=58,c=ee.ldexp(-59).toDouble(),g=[];let p;if(p=Wn(m?t:e,d,_,c,l,g,y,y),p<0&&r("mp_curve_proximity"),p>0){const s=m?e:t;for(let t=0;t<p;t++){let e;if(m){const s=v.tempP;In.evaluateCoefs(v.polypoly12,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}else{const s=v.tempP;In.evaluateCoefs(v.polypoly11,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}const i=s.evaluateDerivative(g[t]).abs().mulDoubleThis(Number.EPSILON),r=s.evaluate(g[t]);i.addThis(e.sub(r).absThis()),i.ldexpThis(3),r.absThis(),r.lt(i)?S.push(Yt(g[t].toDouble(),w[Y].toDouble())):n(r.gte(i))}}}A=S.length,Gn(v.polypoly1,v.polypoly2,v.tempP);const T=[];let I=Wn(v.tempP,d,p,D,E,T);I<0&&(I=0);for(let n=0;n<I;n++){In.evaluateCoefs(v.polypoly1,T[n],v.tempP1);const t=[];let e=Wn(v.tempP1,d,_,D,E,t);if(0!==e)if(In.evaluateCoefs(v.polypoly2,T[n],v.tempP2),e<0){if(e=Wn(v.tempP2,d,_,D,E,t),e<0)continue;for(let s=0;s<e;s++)b.push(Yt(t[s].toDouble(),T[n].toDouble()))}else{const s=v.tempP2.absEvaluate(ee);s.mulThis(tt.constructDouble(1e-12));for(let i=0;i<e;i++){const e=v.tempP2.evaluate(t[i]);e.absThis(),e.lt(s)&&b.push(Yt(t[i].toDouble(),T[n].toDouble()))}}}if(I=b.length,0===A&&0===I)return 0;b=b.concat(S),b.sort((t,e)=>C?kt(t.second,e.second):kt(t.first,e.first));const M=ne(b,(t,e)=>t.first===e.first&&t.second===e.second);b=b.slice(0,M),f.length=0,P.length=0;for(const n of b)f.push(n.first),P.push(n.second);return n(f.length===P.length),P.length}function Xn(t,e,s,n,i,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(tt.constructInt32(1)).isZero();if(1===t.power()){const s=Vn(t.getElement(1),t.getElement(0),e,r.at(0));return r[0].limitPrecisionThis(n),1!==s?0:(r[0].limitPrecisionThis(n),1)}if(2===t.power()){return Ln(t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(3===t.power()){return Rn(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(4===t.power()){return zn(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}return On(t,e,s,n,a,i,r,o)}function qn(){return{polyIntersect:new In,polyX1:new In,polyY1:new In,polyX1Deriv:new In,polyY1Deriv:new In,lazyPolyD1:new In,lazyPolyD1Deriv:new In,tempP:new In,tempP1:new In,tempP2:new In,polypoly1Proximity:new Mn,polypoly2Proximity:new Mn}}function Fn(t,e,s,n,i,r,o,a,h,u,m,l,c){const g=qn();g.polyX1.construct(t,e),g.polyY1.construct(s,n),g.polyX1Deriv.assignCopy(g.polyX1),g.polyX1Deriv.derivative1This(),g.polyY1Deriv.assignCopy(g.polyY1),g.polyY1Deriv.derivative1This(),g.polyIntersect.assignCopy(g.polyX1),g.polyIntersect.mulThis(g.polyX1),g.polyIntersect.mulElementThis(o[0]),g.tempP.assignCopy(g.polyY1),g.tempP.mulThis(g.polyY1),g.tempP.mulElementThis(o[1]),g.polyIntersect.addThis(g.tempP),i?(g.lazyPolyD1.construct(i,r),g.tempP.assignCopy(g.lazyPolyD1),g.tempP.mulThis(g.lazyPolyD1),g.tempP.mulElementThis(o[2]),g.polyIntersect.addThis(g.tempP)):g.polyIntersect.add0(o[2]);{const i=o[0].clone(),r=i.clone();r.sqrThis();const a=o[1].clone(),h=a.clone();h.sqrThis();const u=o[2].clone(),m=i.clone();m.subThis(a),g.polyX1.construct(t,e),g.polyX1Deriv.assignCopy(g.polyX1),g.polyX1Deriv.derivative1This(),g.polyY1.construct(s,n),g.polyY1Deriv.assignCopy(g.polyY1),g.polyY1Deriv.derivative1This(),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1),g.tempP.mulElementThis(h),g.tempP.mulElementThis(u),g.polypoly1Proximity.construct0(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(a.mul(m).mul(u).ldexpThis(1)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1),g.tempP.mulElementThis(i.mul(h)),g.tempP1.assignCopy(g.polyY1),g.tempP1.mulThis(g.polyY1),g.tempP1.mulElementThis(r.mul(a)),g.tempP.addThis(g.tempP1),g.tempP.add0(m.mul(m).mul(u)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulElementThis(m.mul(i).mul(a).ldexpThis(1)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.construct0(i.mul(m).mul(m)),g.polypoly1Proximity.addElement(g.tempP),g.polypoly1Proximity.updatePower(),g.tempP.construct0(te),g.polypoly2Proximity.construct0(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1Deriv),g.tempP1.assignCopy(g.polyY1),g.tempP1.mulThis(g.polyY1Deriv),g.tempP.addThis(g.tempP1),g.tempP.mulElementThis(i.mul(a)),g.polypoly2Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1Deriv),g.tempP.mulElementThis(m.mul(i)),g.polypoly2Proximity.addElement(g.tempP),g.polypoly2Proximity.updatePower()}const d=[],_=[];null===m&&(m=[]);let p=2*g.polyIntersect.power()+58;const f=.5*Number.EPSILON,P=[],y=Wn(g.polyIntersect,a,h,f,p,P,l,l);if(y<0)return-1;for(const b of P)_.push(b.toDouble());Gn(g.polypoly1Proximity,g.polypoly2Proximity,g.tempP),p=2*g.tempP.power()+58,P.length=0;let x=Wn(g.tempP,a,h,f,p,P);if(x<0&&(x=0),0===y&&0===x)return 0;for(const b of P)d.push(b.toDouble());const C=d.concat(_);m.length=C.length,st(m,C,0,0,C.length),Wt(m);const v=ne(m,(t,e)=>0===kt(t,e));return m.length=v,m.length}function Vn(t,e,s,n){return t.isZero()?e.isZero()?-1:0:(n.setThis(e),n.negateThis(),n.divThis(t),s.isEmpty()||s.containsCoordinate(n.value())?1:0)}function Ln(t,e,s,n,i,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),i.containsCoordinate(1)?1:0;return Vn(e,s,i,o[0])}if(r){let e=2;return o[0].setInt32(1),s.equals(t)?(o[1].setInt32(1),e=1):o[1].setThis(s.div(t)),i.containsCoordinate(o[1].value())||(e=1),i.containsCoordinate(o[0].value())||(e--,o[0].setThis(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=Q(o[0],o[0]=o[1])),e}const a=e.clone();a.sqrThis();const h=t.clone();if(h.mulThis(s).ldexpThis(2).negateThis().addThis(a),h.LZ())return 0;const u=n+2,m=tt.sqrt(h,u),l=m.clone();e.LZ()&&l.negateThis(),l.addThis(e).limitPrecisionThis(u).ldexpThis(-1).negateThis();let c=0;return o[0].setThis(l).divThis(tt.constructAssign(t,u)).limitPrecisionThis(n),(i.isEmpty()||i.containsCoordinate(o[0].value()))&&c++,m.isZero()||l.isZero()||(o[c].setThis(s).divThis(l).limitPrecisionThis(n),(i.isEmpty()||i.containsCoordinate(o[c].value()))&&c++,2===c&&o[0].gt(o[1])&&(o[1]=Q(o[0],o[0]=o[1]))),c}function Rn(t,e,s,i,r,o,a,h){if(t.isZero()){return Ln(e,s,i,r,o,a,h)}const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=Q(h[t],h[t]=h[s-1]),s--);e=s}return ft(h,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let n=0;o.containsCoordinate(0)&&(h[0].setInt32(0),n=1);return u(Ln(t,e,s,r,o,a,h.slice(1)),n)}if(a){let s=0;o.containsCoordinate(1)&&(h[0].setInt32(1),s=1);const n=e.add(t),a=i.negate(),m=t.add(n).add(a).isZero();return u(Ln(t,n,a,r,o,m,h.slice(s)),s)}const m=new tt,l=new tt,c=new tt,g=e.clone();if(g.isZero())l.setThis(s),l.divThis(t),c.setThis(i),c.divThis(t);else{g.divThis(t).divDoubleThis(3).negateThis();const n=e.clone();n.sqrThis();const r=t.clone();r.sqrThis(),l.setThis(t),l.mulThis(s).mulDoubleThis(3).subThis(n).divThis(r).divDoubleThis(3),c.setThis(n),c.mulThis(e),c.ldexpThis(1),m.setThis(t),m.mulThis(e).mulThis(s).mulDoubleThis(9),c.subThis(m),m.setThis(r),m.mulThis(i).mulDoubleThis(27),c.addThis(m),c.divThis(r).divThis(t).divDoubleThis(27)}if(l.isZero()){const t=c.clone();return t.negateThis(),t.isZero()?(h[0].setThis(g),Jn(o,r,h,1)):(h[0].setThis(tt.cubicRoot(t,r).add(g)),Jn(o,r,h,1))}const d=c.clone();if(d.sqrThis().ldexpThis(-2),m.setThis(l.clone()),m.sqrThis().mulThis(l).divDoubleThis(27),d.addThis(m),d.isZero())return h[0].setThis(c),h[0].mulDoubleThis(3).divThis(l),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(g),h[1].addThis(g),Jn(o,r,h,2);if(d.GZ())return d.setThis(tt.sqrt(d,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.addThis(d),h[0].setThis(tt.cubicRoot(m,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.subThis(d),h[0].addThis(tt.cubicRoot(m,r+8)),h[0].addThis(g),Jn(o,r,h,1);m.setThis(l),m.divDoubleThis(3).negateThis(),n(m.GEZ());const _=tt.sqrt(m,r+8),p=_.clone();p.negateThis(),p.addThis(g),_.addThis(g);const f=tt.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),P=tt.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),y=new In({zeroCtor:tt});y.construct0(i),y.addElement(s),y.addElement(e),y.addElement(t);const x=new In({copy:y});x.derivative1This();let C=0;const v=ut(tt,4);v[C++].setThis(f),p.gt(f)&&p.lt(P)&&v[C++].setThis(p),_.gt(f)&&_.lt(P)&&v[C++].setThis(_),v[C++].setThis(P);const b=3*r;let S=52,E=Number.EPSILON;for(;S<b;)2*S<=b?(E*=E,S*=2):(E*=Number.EPSILON,S+=52);S+=2;let D=0,w=!1;for(let n=1;n<C;n++){if(Hn(y,x,v[n-1],v[n],E,S,h[0])){D=1,w=n+1<C;break}}if(!D)return 0;if(w){const t=new In({zeroCtor:tt,coef0:h[0]});t.negateThis(),t.addElement(ee);const e=new In({zeroCtor:tt}),s=new In({zeroCtor:tt});y.div(t,e,s),n(2===e.power()),n(0===s.power());const i=Ln(e.getElement(2),e.getElement(1),e.getElement(0),r,o,!1,h.slice(1));n(i>=0&&i<=2),D+=i}return Jn(o,r,h,D)}function zn(t,e,s,n,i,r,o,a,h){if(t.isZero())return Rn(e,s,n,i,r,o,a,h);const u=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=Q(h[t],h[t]=h[s-1]),s--);e=s}return ft(h,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let i=0;o.containsCoordinate(0)&&(h[0].setInt32(0),i=1);return u(Rn(t,e,s,n,r,o,a,h.slice(i)),i)}const m=new In({zeroCtor:tt,coef0:i});if(m.addElement(n),m.addElement(s),m.addElement(e),m.addElement(t),a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const e=new In({zeroCtor:tt,coef0:tt.constructInt32(-1)});e.addElement(tt.constructInt32(1));const s=new In({zeroCtor:tt}),n=new In({zeroCtor:tt});m.div(e,s,n);return u(Rn(3===s.power()?s.getElement(3):te.clone(),s.power()>=2?s.getElement(2):te.clone(),s.power()>=1?s.getElement(1):te.clone(),s.getElement(0),r,o,s.evaluate(ee).isZero(),h.slice(t)),t)}if(m.getElement(0).isZero()){let t=0;for(o.containsCoordinate(0)&&(t=1,h[0].setDouble(0));m.getElement(0).isZero()&&m.power()>0;)m.shiftRight(1);const e=Rn(3===m.power()?m.getElement(3):te.clone(),m.power()>=2?m.getElement(2):te.clone(),m.power()>=1?m.getElement(1):te.clone(),m.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),ft(h,0,t,(t,e)=>t.compare(e)),t}let l=52,c=Number.EPSILON;for(;l<r;)2*l<=r?(c*=c,l*=2):(c*=Number.EPSILON,l+=52);l+=2;const g=Qn(m),d=tt.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(g.lt(d)?g:d).mul(tt.constructDouble(c)).toDouble(),On(m,o,c,l,a,!1,h,4)}function Bn(t,e){let s=t,n=e;n.power()>s.power()&&(n=Q(s,s=n));const i=s.power()-n.power(),r=new In({copy:s.getElement(s.power())});s.mulThis(n.getElement(n.power()));for(let o=0,a=s.power();o<a;o++)if(o>=i){const t=new In({copy:n.getElement(o-i)});t.mulThis(r);const e=s.getElement(o).sub(t);s.setElement(o,e)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),kn(s)}function kn(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Gn(t,e,s){const n=t.clone(),i=e.clone();for(kn(n),kn(i);0!==n.power()||0!==i.power();)Bn(n,i);s.assignMove(n.getElement(0))}function Wn(t,e,s,n,i,r,o=!1,a=!1){r.length=0;const h=t.power(),u=ut(tt,2*h+4),m=Xn(t,s||U.unit(),n,i,!1,u,u.length);if(m>0){r.length=0;for(let t=0;t<m;t++){const e=u[t];t>0&&e.lte(r.at(-1))||r.push(e.clone())}return r.length}return m}function jn(t,e,s){if(n(s>=1),0===t.power())return t.isZero()?-1:0;const i=t.getElement(0);return i.negateThis(),i.divThis(t.getElement(1)),e[0].setThis(i),1}function Zn(t,e,s,i){if(t.power()<2)return jn(t,s,i);n(i>=1);let r=t.getElement(1);r.mulThis(t.getElement(1));const o=t.getElement(0);if(o.mulThis(t.getElement(2)),o.ldexpThis(2),r.subThis(o),r.LZ())return 0;if(r.isZero()){const n=t.getElement(1);return n.negateThis(),n.divThis(t.getElement(2)),n.ldexpThis(-1),n.limitPrecisionThis(e),s[0].setThis(n),1}n(i>=2),r=tt.sqrt(r,e+8);const a=t.getElement(1);a.negateThis();const h=a.clone();h.subThis(r),h.divThis(t.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(e);const u=a.clone();return u.addThis(r),u.divThis(t.getElement(2)),u.ldexpThis(-1),u.limitPrecisionThis(e),h.lt(u)?(s[0].setThis(h),s[1].setThis(u)):(s[1].setThis(h),s[0].setThis(u)),2}function Hn(t,e,s,n,i,o,a){let h=s.clone(),u=n.clone();h.limitPrecisionThis(o),u.limitPrecisionThis(o);let m=t.evaluate(h);m.limitPrecisionThis(o+2);let l=t.evaluate(u);if(l.limitPrecisionThis(o+2),m.GEZ()&&l.GEZ()||m.LEZ()&&l.LEZ())return m.absLessAbs(l)?(a=h,m.isZero()):(a=u,l.isZero());const c=l.LZ();c&&(l=Q(m,m=l),u=Q(h,h=u));const g=c?u:h,d=c?h:u,_=h.add(u).ldexpThis(-1);_.limitPrecisionThis(o);const p=u.sub(h);p.limitPrecisionThis(o),p.absThis();const f=p.clone();let P=t.evaluate(_),y=e.evaluate(_);const x=new In({copy:t}),C=new In({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),n=ee.clone();n.ldexpThis(-(o+2));for(let i=64;i<s;){x.limitPrecisionThis(i),C.limitPrecisionThis(i);const r=x.evaluate(_),o=C.evaluate(_),a=r.sub(P),h=o.sub(y);if(a.divThis(P).absThis().lt(n)&&(y.isZero()||h.divThis(y).absThis().lt(n)))break;x.assignCopy(t),C.assignCopy(e),i=Math.min(i+64,s)}P.limitPrecisionThis(o+2),y.limitPrecisionThis(o+2)}const v=1,b=4;let S=b;const E=2;let D=1,w=0,A=0,T=v;const I=32,M=tt.constructDouble(.25*i),Y=tt.constructDouble(.5001);let N=0;const X=300;for(;++N<X;){if(N>I&&w>0||y.isZero()||T===E&&w>1||T===v&&S<b)T=v,D>1&&D--;else if(T=E,A>1){const t=p.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&D++}p.setThis(f);const t=new tt;let e=!1;if(T===v)do{if(A>2){const e=p.clone();if(e.absThis(),e.ldexpThis(4),d.sub(g).ldexpThis(-1).gt(e)){if(_.equals(g)){t.setThis(_),_.setThis(g.add(e)),_.limitPrecisionThis(o),f.setThis(_.sub(t));break}if(_.equals(d)){t.setThis(_),_.setThis(d.sub(e)),_.limitPrecisionThis(o),f.setThis(_.sub(t));break}}}f.setThis(u.sub(h)),f.ldexpThis(-1),f.limitPrecisionThis(o),t.setThis(_),_.setThis(h.add(f)),_.limitPrecisionThis(o),_.lt(g)?_.setThis(g):_.gt(d)&&_.setThis(d),e=h.equals(_)||u.equals(_)}while(0);else for(;;){if(f.setThis(P.div(y)),f.limitPrecisionThis(o),1!==D&&f.mulDoubleThis(D),t.setThis(_),_.subThis(f),_.limitPrecisionThis(o),e=_.equals(t),_.lt(g)){if(D>1){_.setThis(t),D--;continue}f.setThis(t.sub(g)),_.setThis(g)}else if(_.gt(d)){if(D>1){_.setThis(t),D--;continue}f.setThis(t.sub(d)),_.setThis(d)}break}if(e||f.absLessAbs(M)){t.equals(_)||(P=x.evaluate(_),P.limitPrecisionThis(o+2));break}P=x.evaluate(_),P.limitPrecisionThis(o+2),y=C.evaluate(_),y.limitPrecisionThis(o+2);const s=h.clone(),n=u.clone();P.LZ()?(m.setThis(P),h.setThis(_)):(l.setThis(P),u.setThis(_)),T===E&&(h.equals(s)&&u.equals(n)||A>1&&!f.absLessAbs(Y.mul(p)))?w++:w=0,T===v?(S++,A=0):(S=0,A++)}return N>=X&&r("Root_finder iterations exceeded"),a.setThis(_),!0}function Un(t,e,s,n,i){const r=t.evaluate(s);if(r.isZero())return!0;const o=tt.constructDouble(.5*n),a=s.clone();a.subThis(o);const h=t.evaluate(a),u=s.clone();u.addThis(o);const m=t.evaluate(u);if(h.LZ()&&m.GZ()||h.GZ()&&m.LZ())return!0;if(r.GZ()?h.LEZ()||m.LEZ():h.GEZ()||m.GEZ())return!0;const l=h.LEZ()&&m.LEZ(),c=h.GEZ()&&m.GEZ();let g=!1;return l?r.gt(h)&&r.gt(m)&&(g=!0):c&&r.lt(h)&&r.lt(m)&&(g=!0),!!g&&r.absThis().lt(tt.constructDouble(1e-17))}function On(t,e,s,i,r,o,a,h){n(s>0),n(h>=t.power());const u=a,m=[];let l=[];const c=new In({zeroCtor:t.m_zeroCtor}),g=new In({zeroCtor:t.m_zeroCtor}),d=new In({zeroCtor:t.m_zeroCtor}),_=tt.constructDouble(s),p=tt.constructDouble(e.vmin),f=tt.constructDouble(e.vmax),P=p.sub(_),y=f.add(_),x=Qn(t),C=x.clone();if(C.negateThis(),P.lt(C))P.setThis(C.sub(_));else if(P.gt(x))return 0;if(y.gt(x))y.setThis(x.add(_));else if(y.lt(C))return 0;let v=t,b=null;if(r){const e=new In({coef0:tt.constructInt32(-1)});e.addElement(ee),b=new In,v=b;const s=new In,n=new In;for(t.div(e,s,n),b.assignCopy(s);v.evaluate(ee).isZero();)v.div(e,s,n),b.assignCopy(s)}let S=!1;if(v.power()>0&&v.getElement(0).isZero())for(S=!0,b||(b=new In({copy:v}),v=b);v.getElement(0).isZero();)b.shiftRight(1);let E=i+2*v.power()+2,D=s/Math.pow(2,v.power()+2),w=E;if(te.gt(P)&&te.lt(y))for(let n=0,Y=v.power();n<Y;n++)if(v.getElement(n).isZero()){m.push(te.clone());break}for(let Y=v.power()-1;Y>0;Y--){if(D*=2,E-=2,w-=2,v.power()-Y===1){g.assignMove(v.derivative(Y));1===jn(g,u,h)&&(u[0].gt(P)&&u[0].lt(y)&&!u[0].isZero()&&m.push(u[0].clone()),c.assignMove(g),d.assignMove(v.derivative(Y-1)));continue}if(v.power()-Y===2){g.assignMove(v.derivative(Y));const t=Zn(g,E,u,h);n(t>=0&&t<=2);for(let e=0;e<t;e++)u[e].gt(P)&&u[e].lt(y)&&!u[e].isZero()&&m.push(u[e].clone());if(m.length>1&&m.sort((t,e)=>t.compare(e)),m.length>0){let t=m[0].sub(_);t.limitPrecisionThis(w),l.push(Yt(P.clone(),t));let e=1===m.length?y.clone():m[1].sub(_);t=m[0].add(_),t.limitPrecisionThis(w),e.limitPrecisionThis(w),l.push(Yt(t,e)),m.length>1&&(e=2===m.length?y.clone():m[2].sub(_),e.limitPrecisionThis(w),t=m[1].add(_),t.limitPrecisionThis(w),l.push(Yt(t,e)),m.length>2&&(t=m[2].add(_),t.limitPrecisionThis(w),l.push(Yt(t,y.clone()))))}else l.push(Yt(P.clone(),y.clone()));c.assignCopy(g),d.assignMove(v.derivative(Y-1));continue}{g.assignMove(d),d.assignMove(v.derivative(Y-1));let t=[];for(let e=0,s=l.length;e<s;++e)if(l[e].first.lte(l[e].second)){const s=new tt;if(Hn(g,c,l[e].first,l[e].second,D,E,s)){m.push(s);let n=s.sub(_);n.limitPrecisionThis(w),t.push(Yt(l[e].first,n)),n=s.add(_),n.limitPrecisionThis(w),t.push(Yt(n,l[e].second))}else t.push(l[e])}l=t,t=[],c.assignMove(g)}}m.sort((t,e)=>t.compare(e)),0===l.length&&(c.assignMove(v.derivative(v.power())),c.isZero()||l.push(Yt(P.clone(),y.clone())));let A=0,T=0,I=0;const M=new tt;for(;;){if(T<l.length){if(l[T].first.gt(l[T].second)){T++;continue}let t=!1;if(I<m.length&&m[I].lt(l[T].first)&&(t=!0),!t){Hn(v,c,l[T].first,l[T].second,s,i,M)&&(M.lt(p)?u[A++].setThis(p):M.gt(f)?u[A++].setThis(f):u[A++].setThis(M)),T++;continue}}if(!(I<m.length))break;0!==I&&m[I-1].equals(m[I])||Un(v,c,m[I],s)&&(M.setThis(m[I]),M.lt(p)?M.setThis(p):M.gt(f)&&M.setThis(f),0!==A&&u[A].equals(M)||u[A++].setThis(M)),I++}return S&&te.gt(P)&&te.lt(y)&&(u[A++].setThis(te),ft(u,0,A,(t,e)=>t.compare(e))),r&&ee.gt(P)&&ee.lt(y)&&(u[A++].setThis(ee),ft(u,0,A,(t,e)=>t.compare(e))),A}function Qn(t){const e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();const s=te.clone();for(let n=0,i=t.power();n<i;n++){const e=t.getElement(n);e.limitPrecisionThis(53),e.gt(s)&&s.setThis(e)}return s.divThis(e),s.addThis(ee),s.mulThis(tt.constructDouble(1+100*Number.EPSILON)),s}function Jn(t,e,s,n){let i=n;if(!t.isEmpty()){i=0;for(let e=0;e<n;++e)t.containsCoordinate(s[e].value())&&(i!==e&&s[i].setThis(s[e]),i++)}i>1&&(s[0].gt(s[1])&&(s[1]=Q(s[0],s[0]=s[1])),i>2&&(s[0].gt(s[2])&&(s[2]=Q(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=Q(s[1],s[1]=s[2]))));for(let r=0;r<i;++r)s[r].limitPrecisionThis(e);return i}function Kn(t,e,s,n,i,r){return ei(t,e,s,r,n,i)}function $n(t,e,s,n,i,r){let o=i;if(n)return r[0]=1,o=.5*(e-t)*(s(t)+s(e)),o;const a=r[0],h=(e-t)/a,u=t,m=new O(0);for(let l=1;l<=r[0];++l){const t=(l-.5)*h;m.add(s(u+t))}return o=.5*(o+(e-t)*m.getResult()/a),r[0]*=2,o}function ti(t,e,s,n,i,r,o){let a=0,h=Math.abs(i-s[t]);const u=et(e,Number.NaN),m=et(e,Number.NaN);for(let d=0;d<e;++d){const e=Math.abs(i-s[t+d]);e<h&&(a=d,h=e),u[d]=n[t+d],m[d]=n[t+d]}let l=0,c=0,g=0;r[0]=n[t+a],a--;for(let d=1;d<e;d++){for(let n=0;n<e-d;n++){if(c=s[t+n]-i,g=s[t+n+d]-i,l=c-g,0===l)return!1;const e=(u[n+1]-m[n])/l;u[n]=c*e,m[n]=g*e}if(2*(a+1)<e-d){const t=a+1;o[0]=u[t]}else{const t=a;o[0]=m[t],a--}r[0]+=o[0]}return!0}function ei(e,s,n,i,o,a){if(n<s&&t("xTo < xFrom"),n===s)return 0;const h=[0];let u=Number.MAX_VALUE;const m=[Number.MAX_VALUE];let l=0;const c=32,g=et(c+1,Number.NaN),d=et(c+1,Number.NaN),_=[0];g[0]=1;let p=0,f=0;for(let t=0;t<c;t++){if(l=$n(s,n,i,0===t,l,_),d[t]=l,t+1>=e){ti(t+1-e,e,g,d,0,h,m)||r("polynomial_interpolation");const s=o*Math.abs(h[0])+a,n=Math.abs(u-h[0]);if(n<=s&&Math.abs(m[0])<=s){if(p++,p>1&&(n<=.1*f||0===f||p>2))return h[0]}else p=0;f=n,u=h[0]}d[t+1]=d[t],g[t+1]=.25*g[t]}return h[0]}class si{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let ni=class{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-ui(this.b,e,!1):0}getError(t){return n(0),0}};function ii(t,e,s,n,i){let r=!0;const o=ut(K,3);t.queryControlPoints(o);let a=r?0:1,h=o[1][a]-o[0][a],u=o[2][a]-o[0][a];const m=Kn(5,e,s,n,i,t=>{let e;if(t<=.5){const s=St(0,h,t),n=St(h,u,t);e=St(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*di(o,1,t).length()});r=!1,a=r?0:1,h=o[1][a]-o[0][a],u=o[2][a]-o[0][a];const l=Kn(5,e,s,n,i,t=>{let e;if(t<=.5){const s=St(0,h,t),n=St(h,u,t);e=St(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*di(o,1,t).length()});return new K(m,l)}function ri(t){t.m_cachedValues=null}function oi(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function ai(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new si;return hi(t,e.specialPoints),Ci(t,e),e}function hi(t,e){const s=ut(K,3);t.queryControlPoints(s);const n=ut(rt,8);n[0].set(0);let i=1;{const t=ut(rt,3);Gi(s,t,!1);const e=ut(rt,2),r=new U(0,1);let o=gn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)lt(e[s].value(),0,1)||(n[i]=e[s],i++)}{const t=ut(rt,3);Wi(s,t,!1);const e=ut(rt,2),r=new U(0,1);let o=gn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)lt(e[s].value(),0,1)||(n[i]=e[s],i++)}if(n[i].set(1),i++,i>2){ft(n,0,i,(t,e)=>t.value()-e.value());let t=0,e=n[0].value(),s=1;for(let r=1;r<i;r++)n[r].eq(n[r-1])?(e+=n[r].value(),s++):(s>1&&(e/=s,n[t].set(e)),t++,n[t]=n[r],e=n[r].value(),s=1);t++,i=t}n[0].set(0),n[i-1].set(1),e.length=i;for(let r=0;r<i;r++)e[r]=n[r].value()}function ui(t,e,s){const n=ut(K,3);return t.queryControlPoints(n),mi(n,e,s)}function mi(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+mi(t,1,!1)}if(1===e)return li(t);const n=ut(K,3);return Mi(t,e,n,null),li(n)}function li(t){if(t[0].equals(t[1]))return K.distance(t[2],t[0]);if(t[1].equals(t[2]))return K.distance(t[0],t[2]);const e=K.distance(t[0],t[1])+K.distance(t[2],t[1]),s=K.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const n=1,i=ut(K,3);Bi(t,i,!0);const r=4*(Bt(i[2].x)+Bt(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=Bt(i[1].x)+Bt(i[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r)){if(1e-14*Math.abs(a)>=Math.abs(o)){return Math.sqrt(a)*n}return 2/(3*o)*(Math.pow(o*n+a,1.5)-Math.pow(a,1.5))}const h=o/r,u=a/r,m=u-h*h,l=n+h;if(0===m){if(h>=0&&l>=0||h<=0&&l<=0){return Math.abs(.5*Math.sqrt(r)*(l*l-h*h))}return.5*Math.sqrt(r)*(l*l+h*h)}const c=Math.sqrt(m+l*l),g=Math.sqrt(u);return.5*Math.sqrt(r)*(l*c-h*g+m*Math.log(Math.abs((l+c)/(h+g))))}function ci(t,e){const s=gt(e,0,1);let n=di(t,1,s);return n.isZero()&&(n=di(t,2,s)),n}function gi(t,e,s){const n=ut(K,3);return t.queryControlPoints(n),di(n,e,s)}function di(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):K.construct(0,0)}function _i(t,e,s){{const e=be.constructPoint2D(t[1]).subE(be.constructPoint2D(t[0])),n=new rt(1).subE(s),i=be.constructPoint2D(t[2]).subE(be.constructPoint2D(t[1])),r=e.mulE(n).addE(i.mulE(s));return r.mulThisE(new rt(2)),r}}function pi(t,e,s){const n=ui(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==en(new ni(t,e),U.unit(),1,i)&&r(""),i[0]}function fi(t){const e=ut(K,3);return t.queryControlPoints(e),Pi(e)}function Pi(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function yi(t){const e=K.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function xi(t){return t.m_cachedValues}function Ci(t,e){t.m_cachedValues=e}function vi(t,e,s,n,i){_(U.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=ut(K,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=bi(r,e,a);if(s.containsCoordinate(a[0]))o=K.distance(e,h);else{a[0]=s.vmin,Zi(r,a[0],h),o=K.distance(h,e);const t=new K;Zi(r,s.vmax,t);const n=K.distance(t,e);o>n&&(h.setCoordsPoint2D(t),a[0]=s.vmax,o=n)}if(!n)return a[0];if(s.vmin<=0){const n=new K;t.queryCoord2DExtended(-1,n,!0);const i=new K;t.queryCoord2D(s.vmin,i);const r=new fm({start:n,end:i}),u=r.getClosestCoordinate(e,!0);if(u<1){const t=r.getCoord2D(u),s=K.distance(t,e);s<o&&(o=s,a[0]=u-1,h.assign(t))}}if(s.vmin>=1){const n=new K;t.queryCoord2DExtended(2,n,!0);const i=new K;t.queryCoord2D(s.vmax,i);const r=new fm({start:i,end:n}),u=r.getClosestCoordinate(e,!0);if(u>0){const t=r.getCoord2D(u),s=K.distance(t,e);s<o&&(o=s,a[0]=1+u,h.assign(t))}}return a[0]}function bi(t,e,s){const n=t[2].sub(t[1]).sub(t[1].sub(t[0])),i=t[1].sub(t[0]),r=t[0].sub(e),o=r.dotProduct(i),a=r.dotProduct(n)+2*i.dotProduct(i),h=3*i.dotProduct(n),u=n.dotProduct(n),m=et(3,Number.NaN),l=rn(u,h,a,o,U.unit(),!1,m),c=t[0].clone();let g=0,d=K.sqrDistance(t[0],e),_=K.sqrDistance(t[2],e);_<d&&(g=1,c.assign(t[2]),d=_);for(let p=0;p<l;p++){const s=new K;Zi(t,m[p],s),_=K.sqrDistance(s,e),_<d&&(d=_,c.assign(s),g=m[p])}return s&&(s[0]=g),c}function Si(t,e,s,n,i,r){const o=new fe;if(Ei(t,U.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=new K,h=vi(t,e,U.unit(),!1);t.queryCoord2D(h,a);return K.distance(a,e)<=i?(n&&(n[0]=h),1):0}function Ei(t,e,s){const n=ut(K,3);t.queryControlPoints(n),Di(n,e,s)}function Di(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const n=ut(K,3);Yi(t,e.vmin,e.vmax,n),s.setFromPoints(n,3)}function wi(t,e,s){s.setEmpty();const n=[];n.push(new U(0,1));const i=.5*Math.max(e.width(),e.height());for(;n.length;){const r=n.at(-1);n.pop();const o=new fe;if(Di(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=i||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();n.push(U.construct(r.vmin,t)),n.push(U.construct(t,r.vmax))}}}}function Ai(t){const e=ut(K,3);t.queryControlPoints(e);const s=Ti(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ti(t){let e=!1;for(let s=0;s<2;s++){const n=$(t[0][s],t[2][s]);n>0?($(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),$(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?($(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),$(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Ii(e,s,n){void 0===n&&(n=s,s=0);const i=new K;if(s<0||n>1)return i.setNAN(),i;if(s>n&&t("calculate_sub_weighted_centroid"),s===n||e.isDegenerate(0))return i.setCoords(0,0),i;const r=ai(e),o=Oe(e),a=Math.min(o/e.calculateUpperLength2D(),1e-7);let h=s,u=0;for(let t=1,m=r.specialPointsCount();t<m;t++)if(s<r.specialPoints[t]){u=t-1;break}i.setCoords(0,0);for(let t=u+1,m=r.specialPointsCount();t<m;t++){const s=Math.min(r.specialPoints[t],n),u=ii(e,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[t])break}return i.add(e.getStartXY().mul(e.calculateLength2D()))}function Mi(t,e,s,n){(new K).setCoordsPoint2D(t[0]);(new K).setCoordsPoint2D(t[1]);(new K).setCoordsPoint2D(t[2]);const i=new K,r=new K,o=new K;if(Ct(t[0],t[1],e,i),Ct(t[1],t[2],e,r),Ct(i,r,e,o),s&&(s[0].assign(t[0]),s[1].assign(i),s[2].assign(o)),n){const e=t[2];n[0].assign(o),n[1].assign(r),n[2].assign(e)}}function Yi(t,e,s,n){if(e===s){const s=new K;return Zi(t,e,s),n[0]=s,n[1]=s,void(n[2]=s)}const i=ut(K,3);Mi(t,s,i,null),Mi(i,e/s,null,i),Zi(t,e,i[0]),Zi(t,s,i[2]),n[0].setCoordsPoint2D(i[0]),n[1].setCoordsPoint2D(i[1]),n[2].setCoordsPoint2D(i[2])}function Ni(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),r=new ce,o=ut(K,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new K;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=ut(K,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Ct(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&Ai(t)}function Xi(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function qi(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Li(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Fi(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Ri(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Vi(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==zi(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Li(t,e,s,i,r,o,a,h,u,m){if(null!=r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0],n=e.intersectPoint(s.getStartXY(),t,a);if(n>0){if(null!==r)for(let e=0;e<n;e++)r.push(t[e]);if(null!==o)for(let t=0;t<n;t++)o.push(0);if(null!==i)for(let s=0;s<n;s++){const n=new K;e.queryCoord2D(t[s],n),i.push(n)}}return n}const l=Qe(e,s);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new fm({start:e.getStartXY(),end:e.getEndXY()}),n=ws(t,s,i,r,o,a,h,m);if(r)for(let s=0;s<n;++s){const n=t.getCoord2D(r[s]);r[s]=e.getClosestCoordinate(n,!1)}return n}if(Je(e,s,a))return 0;const c=Ee.constructPoint2D(s.getStartXY()),g=Ee.constructPoint2D(s.getEndXY()).sub(c),d=g.clone();d.leftPerpendicularThis();const _=Ee.constructPoint2D(e.m_cp).sub(Ee.constructPoint2D(e.getStartXY())),p=Ee.constructPoint2D(e.getEndXY()).sub(Ee.constructPoint2D(e.m_cp));let f=_.dotProduct(d).toDouble(),P=p.sub(_).dotProduct(d).toDouble();const y=et(12,Number.NaN),x=et(12,Number.NaN);let C=sn(P,f,U.unit(),y);C<0&&(y[0]=0,y[1]=1,C=2);let v,b=0;for(let n=0,w=b;n<C;++n){const t=e.getCoord2D(y[n+w]);x[b]=s.getClosestCoordinate(t,!1),K.distance(t,s.getCoord2D(x[b]))<=a&&(y[b]=y[n+w],b++)}const S=ut(K,3);e.queryControlPoints(S);{const t=ut(Ee,3);if(ji(S,t,!1),t[0]=t[0].sub(c),g.x.abs().gte(g.y.abs())){const e=g.y.div(g.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),f=t[1].y.sub(t[1].x.mul(e)).toDouble(),v=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=g.x.div(g.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),f=t[1].x.sub(t[1].y.mul(e)).toDouble(),v=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const E=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),D=[0,0];C=nn(P,f,v,U.unit(),E,D);for(let n=0,w=b;n<C;++n){y[n+w]=D[n];const t=e.getCoord2D(y[n+w]);x[b]=s.getClosestCoordinate(t,!1),K.distance(t,s.getCoord2D(x[b]))<=a&&(y[b]=y[n+w],b++)}n(b<y.length+4),C=e.intersectPoint(s.getStartXY(),D,a);for(let n=0;n<C;n++)y[b]=D[n],x[b++]=0;C=e.intersectPoint(s.getEndXY(),D,a);for(let n=0;n<C;n++)y[b]=D[n],x[b++]=1;C=s.intersectPoint(e.getStartXY(),D,a);for(let n=0;n<C;n++)x[b]=D[n],y[b++]=0;C=s.intersectPoint(e.getEndXY(),D,a);for(let n=0;n<C;n++)x[b]=D[n],y[b++]=0;return 0===b?0:gm(t,e,s,y,x,b,i,r,o,a,h,u,m)}function Ri(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return Li(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Je(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=ut(K,3);{e.queryControlPoints(g);const t=ut(K,3),n=new ce;s.canonicToWorldTransformation(n);const i=new ce;i.setInvert(n),i.transformPoints2D(g,3,t);const r=ut(Ee,3);ji(t,r);const h=[r[0].x,r[1].x,r[2].x],u=[r[0].y,r[1].y,r[2].y],m=ut(tt,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2]=m[0],m[2].mul(m[1]),m[2].negate();const d=Fn(h,2,u,2,null,0,m,!0,U.unit(),U.unit(),l,a);if(d>0){let t=0;for(let n=0;n<d;n++){const i=new K;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new K;s.queryCoord2D(r,a),K.distance(i,a)<=o&&(l[t]=l[n],c.push(r),t++)}l.length=t}}const d=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),e=[0];bi(g,t,e);const n=new K;Zi(g,e[0],n),K.distance(t,n)<=o&&(l.push(e[0]),c.push(d[_]))}for(let _=0;_<2;_++){const t=[0,2];{const e=s.getClosestCoordinate(g[t[_]],!1),n=new K;s.queryCoord2D(e,n),K.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return gm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function zi(t,e,s,n,i,r,o,a,h,u){const m=ut(K,3);e.queryControlPoints(m);const l=ut(K,3);if(s.queryControlPoints(l),Ke(m,l,3)<0)return zi(t,s,e,n,r,i,o,a,h,!u);const c=Qe(e,s);if(Je(e,s,o=Math.max(o,c)))return 0;if(sr(e,s,n,i,r,o,a,h,u))return 2;const g=new U(0,1),d=new U(0,1);{const t=new fe;Di(m,U.unit(),t);const e=new fe;Di(l,U.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(wi(m,t,g),wi(l,t,d),g.isEmpty()||d.isEmpty())return 0;Yi(m,g.vmin,g.vmax,m),Yi(l,d.vmin,d.vmax,l)}}const _=_m(m,2,l,2,o);if(0===_)return 0;const p=[],f=[];if(-1===_){const t=ut(Ee,3);ji(m,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],n=ut(Ee,3);ji(l,n);const i=Nn(e,2,s,2,null,0,[n[0].x,n[1].x,n[2].x],2,[n[0].y,n[1].y,n[2].y],2,null,0,!0,U.unit(),U.unit(),p,f,u,a,u);if(i>0){let t=0;for(let e=0;e<i;e++){const s=new K,n=new K;Zi(l,f[e],n),Zi(m,p[e],s),K.distance(s,n)<=o&&(p[t]=p[e],f[t]=f[e],t++)}p.length=t,f.length=t}}for(let P=0;P<2;P++){const t=0===P?m:l,e=0===P?l:m;for(let s=0;s<2;s++){const n=0===s?0:2,i=[0];bi(e,t[n],i);const r=new K;Zi(e,i[0],r),K.distance(t[n],r)<=o&&(0===P?(p.push(0===n?0:1),f.push(i[0])):(f.push(0===n?0:1),p.push(i[0])))}}if(0===p.length)return 0;if(!g.equalsRange(0,1))for(let P=0;P<p.length;++P)p[P]=An.recalculateParentT(g.vmin,g.vmax,p[P]);if(!d.equalsRange(0,1))for(let P=0;P<f.length;++P)f[P]=An.recalculateParentT(d.vmin,d.vmax,f[P]);return gm(t,e,s,p,f,p.length,n,i,r,o,a,h,u)}function Bi(t,e,s=!1){const n=t[1].sub(t[0]);e[1].assign(n.mul(2)),e[2].assign(t[2].sub(t[1]).sub(n)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function ki(t,e,s=!1){const n=ut(K,3);t.queryControlPoints(n),Bi(n,e,s)}function Gi(t,e,s=!1){const n=0,i=new rt(t[1][n]).subE(new rt(t[0][n]));e[1]=i.mul(2),e[2]=new rt(t[2][n]).subE(new rt(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function Wi(t,e,s=!1){const n=1,i=new rt(t[1][n]).subE(new rt(t[0][n]));e[1]=i.mul(2),e[2]=new rt(t[2][n]).subE(new rt(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function ji(t,e,s=!1){const n=Ee.constructPoint2D(t[1]),i=n.sub(Ee.constructPoint2D(t[0]));e[1]=i.mul(tt.constructInt32(2)),e[2]=Ee.constructPoint2D(t[2]).sub(n).sub(i),e[0]=s?new Ee(te,te):Ee.constructPoint2D(t[0])}function Zi(t,e,s,n){if(n){if(e<0){return void ps(new fm({start:t[0],end:t[0].add(ci(t,0).getUnitVector())}),e,s)}if(e>1){return void ps(new fm({start:t[2],end:t[2].add(ci(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=t[1].clone(),i=new K;qt(2,t[0],n,e,i);const r=new K;qt(2,n,t[2],e,r);const o=new K;qt(2,i,r,e,o),s.assign(o)}else{const n=t[1].clone(),i=new K;Ft(2,t[0],n,e,i);const r=new K;Ft(2,n,t[2],e,r);const o=new K;Ft(2,i,r,e,o),s.assign(o)}}function Hi(t,e,s){const n=ut(K,3);t.queryControlPoints(n),Ui(n,e,s)}function Ui(t,e,s){if(e.value()<=.5){const n=be.constructPoint2D(t[1]),i=new be;Vt(2,be.constructPoint2D(t[0]),n,e,i);const r=new be;Vt(2,n,be.constructPoint2D(t[2]),e,r);const o=new be;Vt(2,i,r,e,o),s.setE(o)}else{const n=be.constructPoint2D(t[1]),i=new be;Lt(2,be.constructPoint2D(t[0]),n,e,i);const r=new be;Lt(2,n,be.constructPoint2D(t[2]),e,r);const o=new be;Lt(2,i,r,e,o),s.setE(o)}}function Oi(t,e,s){const n=ut(K,4);t.queryControlPoints(n),Qi(n,e,s)}function Qi(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(_i(t,1,e))}function Ji(t,e){let s=1;t[1].isEqualPoint2D(t[0])&&(s=2,t[2].isEqualPoint2D(t[0])&&(s=3));let n=2;t[2].isEqualPoint2D(t[3])&&(n=1,t[1].isEqualPoint2D(t[3])&&(n=0)),e[0].assign(t[0]),e[2].assign(t[3]);const i=K.intersectLinesAtOnePoint(t[0],t[s],t[n],t[3]),r=new K;Ct(t[0],t[3],.5,r);const o=new K;yo(t,.5,o);const a=new K;e[1].assign(i),Zi(e,.5,a);const h=new K;e[1].assign(r),Zi(e,.5,h);const u=K.sqrDistance(o,a),m=K.sqrDistance(o,h);return u<m?(e[1].setCoordsPoint2D(i),Math.sqrt(u)):(e[1].setCoordsPoint2D(r),Math.sqrt(m))}function Ki(t,e,s){s[0].assign(t[0]),s[1].assign(t[1]),s[2].assign(t[2]);const n=new K;ph(t,e,.5,n);const i=new K;Zi(s,.5,i);const r=K.sqrDistance(n,i);return Math.sqrt(r)}function $i(t,e){e[0].assign(t[0]),e[3].assign(t[2]),Ct(t[0],t[1],2/3,e[1]),Ct(t[1],t[2],1/3,e[2])}function tr(t,e){const s=ut(K,3);t.queryControlPoints(s);const n=K.sqrDistance(s[1],s[0]),i=K.sqrDistance(s[1],s[2]);let r=s[0].clone(),o=n;n>i&&(r=s[2].clone(),o=i);let a=!1;return o<=e&&0!==o&&(a=!0,t.setControlPoint1(r)),a}function er(t,e){if(!e)return!1;const s=ut(K,3);t.queryControlPoints(s);const n=K.sqrDistance(s[1],s[0]),i=K.sqrDistance(s[1],s[2]);s[0].clone();let r=n;return n>i&&(s[2].clone(),r=i),r<=e&&0!==r}function sr(t,e,s,n,i,r,o,a,h){const u=ut(K,3);t.queryControlPoints(u);const m=ut(K,3);if(e.queryControlPoints(m),u[0].equals(m[0])){if(u[1].equals(m[1])&&u[2].equals(m[2]))return s&&(s.length=0,s.push(u[0]),s.push(u[2])),n&&(n.length=0,n.push(0),n.push(1)),i&&(i.length=0,i.push(0),i.push(1)),!0;if(!u[0].equals(m[2]))return!1}return!!(u[0].equals(m[2])&&u[1].equals(m[1])&&u[2].equals(m[0]))&&(n&&(n.length=0,n.push(0),n.push(1),h&&(n[1]=Q(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=Q(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[2]),h&&(s[1]=Q(s[0],s[0]=s[1]))),!0)}const nr=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],ir=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],rr=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],or=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],ar=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],hr=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function ur(t,e,s,n){const i=.5*(n-s),r=s+i,o=new O(0);for(let a=0,h=Math.trunc(t/2);a<h;++a){let s,n;switch(t){case 4:s=nr[a][0],n=nr[a][1];break;case 8:s=ir[a][0],n=ir[a][1];break;case 16:s=rr[a][0],n=rr[a][1];break;case 32:s=or[a][0],n=or[a][1];break;case 64:s=ar[a][0],n=ar[a][1];break;case 128:s=hr[a][0],n=hr[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=oe(-i,s,r),u=oe(i,s,r);o.pe(e(h)*n),o.pe(e(u)*n)}return o.getResult()*i}class mr extends Us{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Pm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Pm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Pm):t.envelope?s("envelope constructor not impl"):r("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Pm)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return $s(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return mr.type}getDimension(){return 2}createInstance(){return new mr({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function lr(n,i){let r,o=i,a=null;switch(o||(a=p(n)?S():P(),o=a),n){case e.enumPoint:r=new F({vd:o});break;case e.enumLine:r=new fm({vd:o});break;case e.enumBezier:r=new ra({vd:o});break;case e.enumEllipticArc:r=new qh({vd:o});break;case e.enumRationalBezier2:r=new Dn({vd:o});break;case e.enumBezier2:r=new An({vd:o});break;case e.enumEnvelope:r=new C({vd:o});break;case e.enumMultiPoint:r=new gs({vd:o});break;case e.enumPolyline:r=new Qs({vd:o});break;case e.enumPolygon:r=new mr({vd:o});break;case e.enumMultipatch:s("multipatch not impl");break;case e.enumGeometryCollection:r=new _e({vd:o});break;default:t("Geometry.create")}return r}mr.type=e.enumPolygon;var cr=b;const gr=-1,dr=1;class _r{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}function pr(t){return void 0!==t.parent}class fr{constructor(t){pr(t)?(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0):(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==gr;){for(;this.m_path!==gr;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==gr)return this.m_vertex;if(this.m_bOneGeom)return gr;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===gr)break;this.m_bSkipMultiPoints&&!c(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return gr}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==gr&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return gr}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==gr?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==gr&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):gr}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,n,i,r,o,a,h){return new fr({parent:t,geometry:e,path:s,vertex:n,firstVertex:i,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class Pr{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class yr{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let s=0,n=this.m_indices.length;s<n;s++){if(s===this.m_selectionIndex)continue;const t=this.m_indices[s];null!==t&&t.size()>e&&t.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,dr),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,dr),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,n){this.m_hasForceSetEnvelope=0;const i=e!==gr?this.getPrevVertex(e):this.getLastVertex(t),r=i!==gr?this.getNextVertex(i):gr,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByValNoCurves(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,i),r!==gr&&this.setPrevVertex(r,o),i!==gr&&this.setNextVertex(i,o);const h=this.isClosedPath(t),u=this.getFirstVertex(t);e===gr&&this.setLastVertex(t,o),e===u&&(h&&n&&u!==gr||this.setFirstVertex(t,o)),h&&r===gr&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const m=this.getGeometryFromPath(t);return this.setGeometryVertexCount(m,this.getPointCount(m)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new F({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,s){const n=this.createGeometry(e.enumMultiPoint,t.getDescription());return this.appendPoint(n,t,s),n}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const n=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let i=0,r=s.getPathCount();i<r;i++){if(0===s.getPathSize(i))continue;const e=this.insertPath(t,gr);this.setClosedPath(e,s.isClosedPath(i));for(let t=s.getPathStart(i),r=s.getPathEnd(i);t<r;t++){const i=this.insertVertex_(e,gr,null,!1);if(n){const e=this.getVertexIndex(i);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const n=new Pm;s.querySegment(t,n,!0),this.setSegmentToIndex(e,n.releaseSegment())}}}s.isStrongPathStart(i)&&this.setStrongPathStart(e,!0),s.isStrongPathEnd(i)&&this.setStrongPathEnd(e,!0)}}addMultiPath(t,s){const n=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===e.enumPolygon&&this.setFillRule(n,t.getFillRule()),this.appendMultiPath(n,t,s),n}appendMultiPathPolyline(t,e,s){const n=e.getImpl(),i=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),r=new le;e.queryEnvelope(r);{const r=s.clone();let o=n.getPointCount();const a=n.getAccelerators();if(a&&a.getQuadTree()){o=a.getQuadTree().getIntersectionCount(r,0,n.getPointCount()+1)}if(o<e.getPointCount()){if(0===o)return;const s=n.queryLimitedSegmentIterator(r);let a=-1,h=-100,u=-1,m=0,l=-1,c=gr,g=!1,d=s.nextSegment();if(null!==d)for(;;d=s.nextSegment()){let r=null===d;const o=null!==d?s.getPathIndex():a,_=null!==d?s.getStartPointIndex():h;if(r||(a===o&&h+1===_?m++:r=!0),r){if(-1!==l){let t=-1,s=-1;if(m===u){this.setClosedPath(c,g);const i=n.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i-l),this.m_verticesMp.addPoints(e,l,i),s=n.getPathSize(a),t=i-1}else if(!g||h+1<n.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp.addPoints(e,l,h+2),s=h-l+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp?.addPoints(e,l,h+1),t=h,s=h-l+1;const i=n.getPathStart(a);this.m_verticesMp.addPoints(e,i,i+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=l;e<s;e++,r++){const e=this.insertVertex_(c,gr,null,!1);if(i){const s=this.getVertexIndex(e);if(1&n.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new Pm;n.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===d)break;m=1,l=_,a!==o?(c=this.insertPath(t,gr),this.setClosedPath(c,!1),u=n.getSegmentCountPath(o),g=n.isClosedPath(o),a=o):c=this.insertPath(t,gr)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,s){const i=e.getImpl(),r=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),o=le.constructEmpty();e.queryEnvelope(o),n(s.isIntersecting(o)&&!s.containsEnvelope(o));let a=le.construct(Number.NEGATIVE_INFINITY,s.ymin,Number.POSITIVE_INFINITY,s.ymax),h=le.construct(s.xmin,Number.NEGATIVE_INFINITY,s.xmax,Number.POSITIVE_INFINITY);const u=i.getAccelerators();if(u&&u.getQuadTree()){const t=u.getQuadTree(),e=t.getIntersectionCount(a,0,0);e>t.getIntersectionCount(h,0,e+1)&&(h=Q(a,a=h))}else a.height()>h.width()&&(h=Q(a,a=h));const m=[],l=i.queryLimitedSegmentIterator(a);let c=-1,g=-100,d=-1,_=0,p=-1,f=-1,P=gr,y=!0,x=l.nextSegment();if(null!==x)for(;;x=l.nextSegment()){let s=null===x;const o=null!==x?l.getPathIndex():c,a=null!==x?l.getStartPointIndex():g;if(s||(o===c?g+1===a?_++:s=!0:(s=c>=0,c<0&&(c=o,d=i.getSegmentCountPath(c),p=a,P=gr,_=1))),s){if(!(0===m.length&&d===_)){0!==m.length&&m[0].first===p||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,p,p+1),-1===f&&(f=p),P===gr&&(P=this.insertPath(t,gr),this.setClosedPath(P,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(P,gr,null,!1));for(const{first:s,second:o}of m){-1===f&&(f=s);let a=-1,h=-1;const u=s+o-1;if(o===d){const t=u+1;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),a=u,n(1===m.length)}else if(u+1<i.getPathEnd(c)){const t=u+2;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),a=u}else{const t=i.getPathStart(c),n=t!==f?1:0,r=u+1;h=r-s+n,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-s)+n),this.m_verticesMp.addPoints(e,s,r),a=u,n>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),P===gr&&(P=this.insertPath(t,gr),this.setClosedPath(P,!0));for(let t=0,e=s;t<h;t++,e++){const t=this.insertVertex_(P,gr,null,!1);if(r){const s=this.getVertexIndex(t);if(1&i.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new Pm;i.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===m.length||m.at(-1).first+m.at(-1).second!==p+_){let t=p+_;t===e.getPathEnd(c)&&(t=e.getPathStart(c)),f!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(P,gr,null,!1))}}m.length=0,y=!0,o!==c&&(c=o,d=i.getSegmentCountPath(c),P=gr,f=-1),p=a,_=1}if(!x)break;{const t=le.constructEmpty();x.queryLooseEnvelope(t),h.isIntersecting(t)?(y?m.push(Yt(a,1)):m.at(-1).second++,y=!1):y=!0}g=a}}appendMultiPath(t,s,n){if(void 0===n)return void this.appendMultiPath_(t,s);if(s.isEmpty())return;const i=s.getGeometryType()===e.enumPolygon,r=le.constructEmpty();s.queryEnvelope(r),n.isIntersecting(r)&&(!n.containsEnvelope(r)&&s.getPointCount()>10?i?this.appendMultiPathPolygon(t,s,n):this.appendMultiPathPolyline(t,s,n):this.appendMultiPath_(t,s))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const n=this.insertPath(t,gr);this.insertVertex_(n,gr,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,gr);for(let n=0,i=e.getPointCount();n<i;n++)this.insertVertex_(s,gr,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const n=e.getAttributeStreamRef(0);let i=0;for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)&&i++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i);let r=-1,o=-1,a=0;for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)?(-1===r&&(r=u,o=u),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+i);const h=this.insertPath(t,gr);for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)&&this.insertVertex_(h,gr,null,!1)}}splitSegmentForward(s,n,i,r,o){const a=this.getNextVertex(s);a===gr&&t("Edit_shape.split_segment_forward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(s);let m=s;const l=this.hasSegmentParentage();for(let t=0,c=n.getResultSegmentCount(i);t<c;t++){const s=this.getVertexIndex(m),r=this.getNextVertex(m),g=n.getResultSegment(i,t);let d=null;if(g.getGeometryType()!==e.enumLine&&(d=g.clone(),d.dropAllAttributes()),0===t&&(g.queryStart(h),this.setSegmentToIndex(s,null),this.setPointEx(m,h,n.getResultSegmentStartPointRank(i,t),n.getResultSegmentStartPointWeight(i,t),o)),this.setSegmentRank(m,n.getResultSegmentInteriorRank(i,t)),this.setSegmentWeight(m,n.getResultSegmentInteriorWeight(i,t)),l){const e=n.getResultSegmentSegmentParentage(i,t),s=n.getResultSegmentStartPointIsBreak(i,t);this.setSegmentParentageAndBreak(m,e,s)}if(g.queryEnd(h),t<c-1){this.setSegmentToIndex(s,d);const e=this.insertVertex(u,r,h);this.setWeight(e,n.getResultSegmentEndPointWeight(i,t)),this.setRank(e,n.getResultSegmentEndPointRank(i,t)),this.select(e),m=e}else{this.setPointEx(a,h,n.getResultSegmentEndPointRank(i,t),n.getResultSegmentEndPointWeight(i,t),o);const e=n.getResultSegmentEndPointIsBreak(i,t);this.setSegmentParentageBreakVertex(a,e),this.setSegmentToIndex(s,d)}}}splitSegmentBackward(s,n,i,r,o){const a=this.getNextVertex(s);a===gr&&t("Edit_shape.split_segment_backward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(s);let m=s;const l=this.hasSegmentParentage();for(let t=0,c=n.getResultSegmentCount(i);t<c;t++){const s=c-t-1,r=this.getVertexIndex(m),g=this.getNextVertex(m),d=n.getResultSegment(i,s);let _=null;if(d.getGeometryType()!==e.enumLine&&(_=d.clone(),_.reverse(),_.dropAllAttributes()),0===t&&(d.queryEnd(h),this.setSegmentToIndex(r,null),this.setPointEx(m,h,n.getResultSegmentEndPointRank(i,s),n.getResultSegmentEndPointWeight(i,s),o),this.setSegmentParentageAndBreak(m,n.getResultSegmentSegmentParentage(i,s),n.getResultSegmentEndPointIsBreak(i,s))),d.getGeometryType()===e.enumLine?this.setSegmentToIndex(r,null):this.setSegmentToIndex(r,_),this.setSegmentRank(m,n.getResultSegmentInteriorRank(i,s)),this.setSegmentWeight(m,n.getResultSegmentInteriorWeight(i,s)),d.queryStart(h),t<c-1){const t=this.insertVertex(u,g,h);this.setWeight(t,n.getResultSegmentStartPointWeight(i,s)),this.setRank(t,n.getResultSegmentStartPointRank(i,s)),this.select(t),m=t,l&&this.setSegmentParentageAndBreak(t,n.getResultSegmentSegmentParentage(i,s),n.getResultSegmentEndPointIsBreak(i,s))}else this.setPointEx(a,h,n.getResultSegmentStartPointRank(i,s),n.getResultSegmentStartPointWeight(i,s),o)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?L(0,-1):L(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return L(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const n=this.getNextVertex(t),i=this.getNextVertex(e),r=this.getVertexIndex(t),o=this.getVertexIndex(e);if(this.setNextVertex(t,i),this.setPrevVertex(i,t),this.setNextVertex(e,n),this.setPrevVertex(n,e),this.m_segments){const t=this.getSegmentFromIndex(r),e=this.getSegmentFromIndex(o);this.setSegmentToIndex(o,null),this.setSegmentToIndex(r,e),this.setSegmentToIndex(o,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),n=this.getSegmentParentage(t);-1===s&&-1===n||(n=Q(s,s=n),this.setSegmentParentageAndBreak(t,n),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,gr,n,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,i);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return gr}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,(t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const n=this.getPathInternalIndexFromVertex(t),i=this.getPathInternalIndexFromVertex(e);s=n<i?-1:n>i?1:0}return s})}sortVerticesSimpleByYHelper3D(t,e,s){n(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=T.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=K.getNAN(),this.m_workPoint2_2D=K.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=gr,this.m_lastGeometry=gr,this.m_vertexIndexList=new G(5),this.m_pathIndexList=new G(8),this.m_geometryIndexList=new G(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new W,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new le(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=le.constructEmpty(),n=this.queryVertexIterator();let i=!0;for(let r=n.next();r!==gr;r=n.next()){if(i?s.merge(this.getXY(r)):s.mergeNe(this.getXY(r)),e){const t=this.getSegment(r);if(null!==t){const e=le.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}i=!1}return s}getEnvelope3D(t){return n(0),T.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){n(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(s,n){const i=s.getGeometryType();if(c(i))return this.addMultiPath(s,n);if(i===e.enumMultiPoint)return this.addMultiPoint(s,n);if(i===e.enumPoint)return this.addPoint_(s,n);if(i===e.enumEnvelope){const t=new mr;return t.addEnvelope(s,!1),this.addMultiPath(t,n)}t("")}appendGeometry(s,n){this.mergeVertexDescription(n.getDescription());const i=n.getGeometryType();c(i)?this.appendMultiPath(s,n):i!==e.enumMultiPoint?t(""):this.appendMultiPoint(s,n)}assignRankToGeometryVertices(t,e){e<dr&&(e=dr);const s=this.queryVertexIterator();for(let n=s.next();n!==gr;n=s.next())this.setRank(n,e),this.setSegmentRank(n,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(e.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let s=gr,n=-1,i=-1;for(let r=this.getFirstGeometry();r!==gr;){if(t===e.enumUnknown||this.getGeometryType(r)===t){if(s===gr){s=r,n=this.getPathCount(s),i=this.getPointCount(s),r=this.getNextGeometry(r);continue}for(let n=this.getFirstPath(r);n!==gr;n=this.getNextPath(n))this.setPathGeometry(n,s);n+=this.getPathCount(r),i+=this.getPointCount(r);const t=this.getLastPath(s),e=this.getFirstPath(r);t!==gr?this.setNextPath(t,e):this.setFirstPath(s,e),e!==gr&&(this.setPrevPath(e,t),this.setLastPath(s,this.getLastPath(r))),this.setFirstPath(r,gr),this.setLastPath(r,gr);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}r=this.getNextGeometry(r)}return s!==gr&&(this.setGeometryVertexCount(s,i),this.setGeometryPathCount(s,n),this.dbgVerifyVertexCounts()),s}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),n=this.getGeometryFromPath(s);this.setGeometryModified(n,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),n=this.getFirstPath(e),i=this.getLastPath(t),r=this.getLastPath(e);for(let c=this.getFirstPath(t);c!==gr;c=this.getNextPath(c))this.setPathGeometry(c,e);for(let c=this.getFirstPath(e);c!==gr;c=this.getNextPath(c))this.setPathGeometry(c,t);this.setFirstPath(t,n),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,i);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),u=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,u),this.setGeometryPathCount(e,a);const m=this.m_geometryIndexList.getField(t,2),l=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,l),this.m_geometryIndexList.setField(e,2,m)}addPathFromMultiPath(t,s,n){const i=this.createGeometry(n?e.enumPolygon:e.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(s)<2)return i;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(s)),this.m_verticesMp.addPoints(t,t.getPathStart(s),r.getPathEnd(s)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(i,gr);this.setClosedPath(o,r.isClosedPath(s)||n);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let e=r.getPathStart(s),h=r.getPathEnd(s);e<h;e++){const t=this.insertVertex_(o,gr,null,!1);if(a){const s=this.getVertexIndex(t);if(1&r.getSegmentFlags(e))this.setSegmentToIndex(s,null);else{const t=new Pm;r.querySegment(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}return r.isStrongPathStart(s)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(s)&&this.setStrongPathEnd(o,!0),i}getGeometry(t){const s=this.getGeometryType(t),n=lr(s,this.m_verticesMp.getDescription()),i=this.getPointCount(t);if(0===i)return n;if(c(s)){const e=n.getImpl(),s=this.getPathCount(t),r=L(s+1),o=R(s+1,0),a=n.getDescription(),h=this.hasCurves();for(let n=0,u=a.getAttributeCount();n<u;n++){const h=a.getSemantics(n),u=cr.getComponentCount(h),m=Y(h,i),l=this.m_vertices.getAttributeStreamRef(h);let c=0,g=0,d=0;for(let e=this.getFirstPath(t);e!==gr;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&o.setBits(g,t);const s=this.getPathSize(e);if(r.write(g++,d),d+=s,0===h){const t=l,s=m;let n;for(let i=this.getFirstVertex(e);c<d;i=this.getNextVertex(i),c++){const e=this.getVertexIndex(i);n=t.readPoint2D(2*e),s.writePoint2D(2*c,n)}}else for(let n=this.getFirstVertex(e);c<d;n=this.getNextVertex(n),c++){const t=this.getVertexIndex(n);for(let e=0;e<u;e++){const s=l.readAsDbl(t*u+e);m.writeAsDbl(c*u+e,s)}}}e.setAttributeStreamRef(h,m),r.write(s,i)}if(e.setPathFlagsStreamRef(o),e.setPathStreamRef(r),e.notifyModifiedFlags(65535),h){let s=0,n=0;for(let i=this.getFirstPath(t);i!==gr;i=this.getNextPath(i)){s+=this.getPathSize(i);for(let t=this.getFirstVertex(i);n<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(n,s,!0),n++}}}}else if(s===e.enumMultiPoint){const e=n.getImpl(),s=n.getDescription();e.reserve(i),e.resizeNoInit(i);for(let n=0,i=s.getAttributeCount();n<i;n++){const i=s.getSemantics(n),r=cr.getComponentCount(i),o=e.getAttributeStreamRef(i),a=this.m_vertices.getAttributeStreamRef(i);let h=0;const u=this.getFirstPath(t),m=this.getPathSize(u);for(let t=this.getFirstVertex(u);h<m;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(i,o)}e.notifyModifiedFlags(65535)}else r("getGeometry");return n}queryPointGeometryOnly(s,n){this.getGeometryType(s)!==e.enumMultiPoint&&t("get_point_geometry_only");const i=this.getPointCount(s);if(i>1&&t("get_point_geometry_only"),0===i)return n.assignVertexDescription(this.m_vertexDescription),void n.setEmpty();const r=this.getFirstPath(s),o=this.getFirstVertex(r);this.queryPoint(o,n)}removeGeometry(t){for(let n=this.getFirstPath(t);n!==gr;n=this.removePath(n));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==gr?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==gr?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=P());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new gs({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===gr?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const n=this.m_geometryIndices[e],i=this.getGeometryIndex(t);i>=n.size()&&n.resize(Math.max(1.25*i,16),-1),n.write(i,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),n=this.m_geometryIndices[e];return s<n.size()?n.read(s):-1}createGeometryUserIndex(){for(let e=0;e<this.m_geometryIndices.length;e++)if(null===this.m_geometryIndices[e])return this.m_geometryIndices[e]=L(0),e;this.m_geometryIndices.push(L(0));const t=this.m_geometryIndices.length-1;return n(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==gr;t=this.getNextGeometry(t))if(!c(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,s,i,r,o){const a=t*t;let h=0;const u=this.hasCurves(),m=this.hasSegmentParentage(),l=!0;for(let g=o===gr?this.getFirstGeometry():o;g!==gr;g=o===gr?this.getNextGeometry(g):gr){const t=this.getGeometryType(g);if(!c(t))continue;if(i&&t!==e.enumPolygon)continue;const o=this.getGeometryType(g)===e.enumPolygon;let d=this.getGeometryModified(g);for(let e=this.getFirstPath(g);e!==gr;){let t=0;for(let s=this.getFirstVertex(e);t<Math.trunc(this.getPathSize(e)/2);){const i=this.getNextVertex(s);if(i===gr)break;const o=this.getXY(s),c=this.getXY(i);let _=K.sqrDistance(o,c),p=!0;do{if(_<=a){if(u){const t=this.getSegment(s);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===h&&(h=-1):h=1,i!==this.getLastVertex(e)){const t=m&&(this.getSegmentParentageBreakVertex(s)||this.getSegmentParentageBreakVertex(i));if(this.transferAllDataToTheVertex(i,s,l),this.removeVertex(i,!1),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&s!==i){this.setSegmentParentageBreakVertex(s,t);const e=this.getNextVertex(s);n(e!==gr),this.isDiscontinuousSegmentParentage(e)&&this.setSegmentParentageBreakVertex(e,!0)}}p=!1}}while(0);p&&(s=this.getNextVertex(s)),t++}let i=this.getFirstVertex(e);for(let s=this.isClosedPath(e)?i:this.getLastVertex(e);this.getPathSize(e)>0;){const t=this.getPrevVertex(s);if(t===gr)break;{const o=this.getXY(t),c=this.getXY(s);let _=K.sqrDistance(o,c),p=!0;do{if(_<=a){if(u){const e=this.getSegment(t);if(null!==e){const t=e.calculateLength2D();if(_=t*t,_>a)break}}if(0===_?0===h&&(h=-1):h=1,m){n(this.m_segmentParentageIndex>=0);const e=this.getUserIndex(s,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(t,s,l),this.setUserIndex(s,this.m_segmentParentageIndex,e)}else this.transferAllDataToTheVertex(t,s,l);const o=m&&(this.getSegmentParentageBreakVertex(s)||this.getSegmentParentageBreakVertex(t));this.removeVertex(t,!0),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&t!==s&&(o||this.isDiscontinuousSegmentParentage(s))&&this.setSegmentParentageBreakVertex(s,!0),i===t&&(i=this.getFirstVertex(e)),p=!1}}while(0);if(p&&(s=this.getPrevVertex(s),s===i))break}}const c=this.getPathSize(e);let _=s&&c<(o?3:2);_&&o&&2===c&&u&&(_=!this.pathHasCurves(e)),_?(e=this.removePath(e),0===h&&(h=-1),r&&!d&&(this.setGeometryModified(g,!0),d=!0)):e=this.getNextPath(e)}}return h}filterClosePoints3D(t,e,s,i,r,o){return n(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==gr;e=this.getNextGeometry(e))if(c(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==gr;){const e=this.getPathSize(s);if(0===e)return!0;let n=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(n);if(e===gr)break;const s=this.getVertexIndex(n),i=this.getSegmentFromIndex(s);let r=0;if(null!==i){if(r=i.calculateLowerLength2D(),r<=t){if(r=i.calculateUpperLength2D(),r<=t)return!0;if(r=i.calculateLength2D(),r<=t)return!0}}else{const n=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,n),r<=t)return!0}n=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return n(0),!1}transferAllDataToTheVertex(t,e,s=!1){const n=this.getVertexIndex(t),i=this.getVertexIndex(e);if(s){let t=1,e=1;if(this.m_ranks&&(t=this.getRankWithIndex(n),e=this.getRankWithIndex(i)),t>e&&this.setRankWithIndex(i,t),t>=e&&this.m_weights){const s=this.getWeightWithIndex(n),r=this.getWeightWithIndex(i);(t>e||s>r)&&this.setWeightWithIndex(i,s)}}else{if(this.m_weights){const t=this.getWeightWithIndex(n);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(n);this.setRankWithIndex(i,t)}}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(n);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(n);this.setSegmentRankWithIndex(i,t)}for(let o=0,a=this.m_indices.length;o<a;o++)if(o!==this.m_selectionIndex&&null!==this.m_indices[o]){const s=this.getUserIndex(t,o);this.setUserIndex(e,o,s)}const r=this.selected(t);r!==this.selected(e)&&(r?this.select(e):this.unselect(e))}splitSegmentAxisAware(e,s,n,i,r){let o=0;const a=this.getNextVertex(e);a===gr&&t("");const h=this.getVertexIndex(e),u=this.getVertexIndex(a),m=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,u);const c=this.getPathFromVertex(e),g=this.m_bHasAttributes;g&&m&&(l=m.calculateLength2D());const d=this.getSegmentParentage(e),_=this.getHelperPoint();if(m){let t=0,e=0,r=gr;for(let p=0;p<n;p++){const n=s[p];if(t<n&&n<1){const s=m.cut(t,n);if(null!==i&&(p>0&&s.setStartXY(i[p-1]),s.setEndXY(i[p]),s.normalizeAfterEndpointChange(),e=p),g){const t=l>0?m.calculateSubLengthFromStart(n)/l:0;this.m_vertices.interpolateTwoVertices(h,u,t,_)}_.setXY(s.getEndXY()),r=this.insertVertex(c,a,_),o++;const f=this.getPrevVertex(r),P=this.getVertexIndex(f);this.setSegmentToIndex(P,s),-1!==d&&this.setSegmentParentageAndBreak(r,d,!1),t=n}}if(r!==gr){const s=m.cut(t,1);null!==i&&(s.setStartXY(i[e]),s.normalizeAfterEndpointChange());const n=this.getVertexIndex(r);this.setSegmentToIndex(n,s)}}else{let t=0;for(let e=0;e<n;e++){const n=s[e];if(t<n&&n<1){this.m_vertices.interpolateTwoVertices(h,u,n,_);const t=this.insertVertex(c,a,_);o++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=n}}return o}splitSegment(t,e,s,n=null){return this.splitSegmentAxisAware(t,e,s,n,-1)}snapControlPoints(e,s,n){this.getNextVertex(e)===gr&&t("");let i=e,r=!1;for(let t=0;t<s;++t){const t=this.getVertexIndex(i),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(n);r||=t}i=this.getNextVertex(i)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let n=s.next();n!==gr;n=s.next()){const s=this.getVertexIndex(n),i=this.getSegmentFromIndex(s);i&&(e|=i.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,s){return n(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const n=this.getVertexIndex(t),i=this.getSegmentFromIndex(n);null!==i&&(i.setStartXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==gr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);null!==n&&(n.setEndXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone())}}}setPointEx(t,e,s,n,i){this.setPoint(t,e,i);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,n),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByValNoCurves(s,e)}setPointOnlyEx(t,e,s,i){n(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const n=this.getVertexIndex(t);if(this.m_vertices?.setXYCoordsNoCurves(n,e,s),null!==this.m_segments){const i=this.getSegmentFromIndex(n);null!==i&&(i.setStartXYCoords(e,s),i.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==gr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);null!=n&&(n.setEndXYCoords(e,s),n.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const n=this.getVertexIndex(t);if(this.m_vertices.setXYCoordsNoCurves(n,e,s),null!==this.m_segments){const i=this.getSegmentFromIndex(n);if(null!==i){const t=i.getEndXY();i.setCoordsForIntersector(new K(e,s),t,!1),i.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==gr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);if(null!==n){const t=n.getStartXY();n.setCoordsForIntersector(t,new K(e,s),!1),n.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,s){n(0)}setXYZ(t,e,s){n(0)}setXYZCoords(t,e,s,i){n(0)}queryXYZ(t,e){n(0)}getXYZ(t){return n(0),E.getNAN()}getXYZWithIndex(t){return n(0),E.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){n(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,s,i){n(0)}setAttribute(t,e,s,i){n(0)}setAttributeInt(t,e,s,i){n(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return n(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return n(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=z(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_weights.size()){if(s)return;this.m_weights.resize(n+1,1)}this.m_weights.write(n,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=z(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return dr;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?dr:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?dr:this.m_ranks.read(t)}setRank(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_ranks){if(s)return;this.m_ranks=L(this.m_vertices.getPointCount(),dr)}const n=this.getVertexIndex(t);if(n>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(n+1,dr)}this.m_ranks.write(n,e)}setRankWithIndex(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_ranks){if(s)return;this.m_ranks=L(this.m_vertices.getPointCount(),dr)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,dr)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=z(this.m_vertices.getPointCount(),1)}const n=this.getVertexIndex(t);if(n>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(n+1,1)}this.m_segmentWeights.write(n,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=z(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return yr.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?yr.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?dr:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=L(this.m_vertices.getPointCount(),dr)}const n=this.getVertexIndex(t);if(n>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(n+1,dr)}this.m_segmentRanks.write(n,e)}setSegmentRankWithIndex(t,e){e<dr&&(e=dr);const s=e===dr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=L(this.m_vertices.getPointCount(),dr)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,dr)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const n=this.m_indices[e],i=this.getVertexIndex(t);if(n.size()<=i){if(-1===s)return;n.resize(this.m_vertices.getPointCount(),-1)}n.write(i,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),n=this.m_indices[e];if(s<n.size()){return n.read(s)}return-1}addToUserIndex(t,e,s){const n=this.m_indices[e],i=this.getVertexIndex(t);n.size()<=i&&n.resize(this.m_vertices.getPointCount(),-1);const r=n.read(i);n.write(i,r+s)}createUserIndex(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(),e;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return n(t>=0&&t<=_t()),t}createUserIndexUninitialized(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(!1),e;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return n(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const n=this.m_indices[e],i=n.size();for(let r=this.getFirstPath(t);r!==gr;r=this.getNextPath(r)){let t=this.getFirstVertex(r);for(let e=0,o=this.getPathSize(r);e<o;e++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<i&&n.write(e,s)}}}fillUserIndexForSelection(t,e){n(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const n=this.getNextVertex(t);if(n===gr)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const i=this.getXY(n);e.setEndXY(i)}else{const s=new F({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(n,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,s=!1){return n(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return n(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const s=this.getFirstVertex(t);if(s===gr)return!1;const n=this.getPathSize(t);let i=s;for(let r=0;r<n;r++,i=this.getNextVertex(i)){const t=this.getSegment(i);if(null!==t&&t.getGeometryType()!==e.enumLine)return!0}return!1}insertPath(e,s){let n=gr;s!==gr?(e!==this.getGeometryFromPath(s)&&t(""),n=this.getPrevPath(s)):n=this.getLastPath(e);const i=this.newPath(e);return s!==gr&&this.setPrevPath(s,i),this.setNextPath(i,s),this.setPrevPath(i,n),n!==gr?this.setNextPath(n,i):this.setFirstPath(e,i),s===gr&&this.setLastPath(e,i),this.setGeometryPathCount(e,this.getPathCount(e)+1),i}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);return e!==gr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==gr?this.setPrevPath(s,e):this.setLastPath(n,e),this.clearPath(t),this.setGeometryPathCount(n,this.getPathCount(n)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==gr){let s=e;for(let e=0,i=this.getPathSize(t);e<i;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const n=this.getGeometryFromPath(t);this.setGeometryVertexCount(n,this.getPointCount(n)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),n=this.getLastVertex(t);if(e){this.setNextVertex(n,s),this.setPrevVertex(s,n);const t=this.getVertexIndex(n);this.setSegmentToIndex(t,null)}else{this.setNextVertex(n,gr),this.setPrevVertex(s,gr);const t=this.getVertexIndex(n);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){n(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const s=this.getFirstVertex(t);if(s===gr)return 0;const n=this.getXY(s),i=new O(0),r=this.getPathSize(t);if(r>2){const t=n.clone(),e=t.x,o=t.y;let a=this.getNextVertex(s);const h=this.getXY(a);a=this.getNextVertex(a);const u=K.getNAN();for(let s=2;s<r;s++,a=this.getNextVertex(a))this.queryXY(a,u),i.pe((u.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(u);i.pe((e-t.x)*(h.y-o))}if(this.hasCurves()){let t=s;for(let s=0;s<r;s++,t=this.getNextVertex(t)){const s=this.getSegment(t);if(null===s||s.getGeometryType()===e.enumLine)continue;const n=2*s.calculateArea2DHelper();i.pe(n)}}this.setRingAreaValid(t,!0);const o=.5*i.getResult();return this.m_pathAreas[this.getPathIndex(t)]=o,o}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const n=this.m_pathindices[e],i=this.getPathIndex(t);n.size()<this.m_pathAreas.length&&n.resize(this.m_pathAreas.length,-1),n.write(i,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),n=this.m_pathindices[e];return s<n.size()?n.read(s):-1}createPathUserIndex(){for(let e=0;e<this.m_pathindices.length;e++)if(null===this.m_pathindices[e])return this.m_pathindices[e]=this.allocatePathIndex(),e;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return n(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const n=this.m_pathindices[e],i=n.size();for(let r=this.getFirstPath(t);r!==gr;r=this.getNextPath(r)){const t=this.getPathIndex(r);t<i&&n.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(e,s,n){if(n===gr&&t(""),s===n)return;const i=this.getNextPath(n);let r=this.getPrevPath(n);const o=this.getGeometryFromPath(n);r===gr?this.setFirstPath(o,i):this.setNextPath(r,i),i===gr?this.setLastPath(o,r):this.setPrevPath(i,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(n)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=s===gr?this.getLastPath(e):this.getPrevPath(s),this.setPrevPath(n,r),this.setNextPath(n,s),s===gr?this.setLastPath(e,n):this.setPrevPath(s,n),r===gr?this.setFirstPath(e,n):this.setNextPath(r,n),this.setGeometryVertexCount(e,this.getPointCount(e)+this.getPathSize(n)),this.setGeometryPathCount(e,this.getPathCount(e)+1),this.setPathGeometry(n,e)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,gr,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),n=this.getPrevVertex(t),i=this.getNextVertex(t);n!==gr&&this.setNextVertex(n,i);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?i:gr),i!==gr&&this.setPrevVertex(i,n),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?n:gr);if(this.hasCurves()&&n!==gr&&i!==gr){const s=this.getVertexIndex(t),r=this.getVertexIndex(n),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),i}removeVertices(t,e){n(t!==e);const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),r=this.getPrevVertex(e);i!==gr&&this.setNextVertex(i,e);let o=this.getPathSize(s);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,i),this.setPrevVertex(t,gr),this.setNextVertex(r,gr);let h=0,u=t;const m=this.getFirstVertex(s);let l=!1;for(;;){const t=this.getNextVertex(u);if(l||=m===u,this.freeVertex(u),h++,u===r)break;u=t}o-=h,l&&this.setFirstVertex(s,o>0?e:gr),this.setPathSize(s,o);const c=this.getGeometryFromPath(s);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,gr,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||r(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==gr;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==gr;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,n=this.getPathSize(e);s<n;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=gr){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=gr){let s=gr,n=gr,i=gr,r=gr,o=0,a=!1;for(s=e!==gr?e:this.getFirstGeometry();s!==gr;s=this.getNextGeometry(s))if(!t||c(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==gr;n=this.getNextPath(n))if(i=this.getFirstVertex(n),r=i,o=0,i!==gr){a=!0;break}if(a||e!==gr)break}return a||(s=gr),fr.create_(this,s,n,i,r,o,t,!1,e!==gr)}queryVertexIteratorOnSelection(t=gr){return this.m_selection?fr.create_(this,t,gr,gr,gr,-1,!1,!0,t!==gr):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){n(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=gr,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return n(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,n,i){n?this.splitSegmentForward(t,e,s,!0,i):this.splitSegmentBackward(t,e,s,!0,i)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){if(null===this.m_segments)return!1;const e=this.getVertexIndex(t);return this.m_segments.length>e&&null!==this.m_segments[e]}querySegment(t,e,s=!0,n=!1){const i=this.getNextVertex(t);if(i===gr)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),n),!0);if(e.copyFrom(r,!0),n)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(i,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}getAndClearSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return n(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let n=null,i=-1,r=t;if(e){const t=this.getVertexIndex(r);n=this.getAndClearSegmentFromIndex(t)}s&&(i=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);n&&n.reverse(),this.setSegmentToIndex(t,n),n=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,i),i=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);e!==gr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==gr?this.setPrevPath(s,e):this.setLastPath(n,e),this.setFirstVertex(t,gr),this.setLastVertex(t,gr),this.freePath(t)}insertClosedPath(t,e,s,n,i){const r=this.insertPath(t,gr);let o=0,a=s;for(i[0]=!1;;){a===n&&(i[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),i[0]&&(s=n),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return n(0),0}findVertex3D(t,e,s){return n(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}getNextNthVertex(t,e){if(0===e)return t;let s=t;for(let n=0;n<e;++n)if(s=e>0?this.getNextVertex(s):this.getPrevVertex(s),s===gr)return gr;return s}removeVertexInternal(t,e){const s=this.getPrevVertex(t),n=this.getNextVertex(t);s!==gr&&this.setNextVertex(s,n),n!==gr&&this.setPrevVertex(n,s);if(this.hasCurves()&&s!==gr&&n!==gr){const i=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(i,null)}else{const t=this.getSegmentFromIndex(i);if(this.setSegmentToIndex(i,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),n}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){n(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new _r(this))}sortVerticesSimpleByX(t,e,s){n(0)}sortVerticesSimpleByY3D(t,e,s){n(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==gr&&this.replaceCurveWithLine(s);this.getNextVertex(t)!==gr&&this.replaceCurveWithLine(t);const n=new K;this.queryXY(t,n),n.y=e,this.setXY(t,n)}setSegmentParentageAndBreak(t,e,s=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&(n(e<=Nt()>>1),e<<=1,e|=s?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if(n(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}if(e>=0){n(e<=Nt()>>1),e<<=1;e|=this.getSegmentParentageBreakVertex(t)?1:0}this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new Pr(e)}return new Pr(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=Nt()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);if(e===gr)return!1;return this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function xr(t){if(t.isEmpty())return new mr({vd:t.getDescription()});if(c(t.getGeometryType())&&t.hasNonLinearSegments())return vr(t);const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new F({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new F,s=new Qs({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const n=e.getAttributeStreamRef(0),i=new Ar({stream:n,n:s});let r=0,o=1;const a=n.readPoint2D(r<<1),h=new K;for(;o<s&&n.queryPoint2D(o<<1,h).equals(a);)o++;if(i.m_treeHull.addElement(r),o<s){i.m_treeHull.addBiggestElement(o);const t=new K;for(let s=o+1;s<e.getPointCount();s++){n.queryPoint2D(s<<1,t);const e=i.treeHull(t);-1!==e&&i.m_treeHull.setElement(e,s)}}const u=e.getDescription(),m=u.getAttributeCount()>1,l=i.m_treeHull.size();let g=null;if(l>=2){g=l>=3?new mr({vd:u}):new Qs({vd:u});const t=g.getImpl();t.reserve(i.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new K;for(let r=i.m_treeHull.getFirst();-1!==r;r=i.m_treeHull.getNext(r))if(m){const s=new F;e.getPointByVal(i.m_treeHull.getElement(r),s),t.insertPoint(0,-1,s)}else n.queryPoint2D(i.m_treeHull.getElement(r)<<1,s),t.insertPoint2D(0,-1,s)}else if(m){const t=new F({vd:u});e.getPointByVal(i.m_treeHull.getElement(i.m_treeHull.getFirst()),t),g=t}else{const t=n.readPoint2D(i.m_treeHull.getElement(i.m_treeHull.getFirst())<<1);g=new F(t)}return g}function Cr(t,e,s,n=!1){if(e<=262144)return Mr(t,e,s,n);const i=new Ar({points:t,n:e}),r=0;let o=1;const a=t[r];for(;o<e&&t[o].equals(a);)o++;if(i.m_treeHull.addElement(r),o<e){i.m_treeHull.addBiggestElement(o);for(let s=o+1;s<e;s++){const e=t[s],n=i.treeHull(e);-1!==n&&i.m_treeHull.setElement(n,s)}}let h=0;for(let u=i.m_treeHull.getFirst();-1!==u;u=i.m_treeHull.getNext(u))s[h++]=i.m_treeHull.getElement(u);return h}function vr(t){n(t.hasNonLinearSegments()&&!t.isEmpty());const e=new Ar;return e.addGeometry(t),e.getBoundingGeometry()}function br(e,s,n){if((s<0||s>=e.getPathCount())&&t("path index"),e.hasNonLinearSegmentsPath(s))return!1;const i=e.getImpl(),r=i.getPathStart(s),o=i.getPathEnd(s),a=!i.isClosedPath(s)&&i.isClosedPathInXYPlane(s),h=i.getAttributeStreamRef(0),u=2*r;let m=2*o;if(a&&(m-=2),m-u<6)return!0;const l=h.readPoint2D(u),c=h.readPoint2D(u+2),g=h.readPoint2D(u+4);if(!Yr(K.orientationRobust(c,g,l)))return!1;const d=c.clone(),_=new K;for(let t=u+6;t<m;t+=2){_.assign(c),c.assign(g),h.queryPoint2D(t,g);if(!Yr(K.orientationRobust(c,g,l)))return!1;if(!Yr(K.orientationRobust(d,g,l)))return!1;if(!Yr(K.orientationRobust(c,g,_)))return!1}return!0}function Sr(t,e,s){t.setNAN(),e.setCoords(1,0),s.setCoords(0,0)}function Er(t,s,n,i,r){if(Sr(n,i,r),t.isEmpty())return;if(t.getGeometryType()===e.enumPoint)return void n.assign(t.getXY());const o=t,a=o.getPointCount();0!==a&&(1!==a?Dr(o,a,s,n,i,r):n.assign(o.getXY(0)))}function Dr(t,e,s,n,i,r){if(2===e){const e=t.getXY(0),s=t.getXY(1);n.assign(e.add(s).mul(.5));const o=s.sub(e);i=qr(o),r.setCoords(.5*o.length(),0)}else{let o=Number.MAX_VALUE;const a=[0,1,0,0],h=new yt(4,2);for(h.set(0,0,0),h.set(0,1,1),h.set(1,0,1),h.set(1,1,2);a[0]<e;++a[0],Fr(h,0,e)){a[1]===a[0]&&(++a[1],Fr(h,1,e));for(let s=1;;++s){for(;;){const n=Vr(t.getXY(h.get(0,0)),t.getXY(h.get(0,1)),t.getXY(h.get(s,0)),t.getXY(h.get(s,1)),2^s);if(n>0)break;if(++a[s],Fr(h,s,e),0===n)break}if(3===s)break;a[s+1]<a[s]&&(a[s+1]=a[s],h.set(s+1,0,h.get(s,0)),h.set(s+1,1,h.get(s,1)))}const u=t.getXY(h.get(0,0)).add(t.getXY(h.get(2,0))).mul(.5),m=qr(t.getXY(h.get(0,1)).sub(t.getXY(h.get(0,0)))),l=new K;let c,g;if(l.x=Math.max(0,m.dotProduct(t.getXY(h.get(1,0)).sub(t.getXY(h.get(3,0))))),l.y=Math.max(0,m.crossProduct(t.getXY(h.get(0,0)).sub(t.getXY(h.get(2,0))))),s?(c=l.x*l.y,g=c<o):(c=l.y,g=c<o),g){o=c;const e=t.getXY(h.get(1,0)),s=t.getXY(h.get(3,0)),a=e.add(s).mul(.5).sub(u);n.assign(u.add(m.mul(m.dotProduct(a)))),i.assign(m),r.assign(l)}}r.mulThis(.5),r.x<r.y&&(r.y=Q(r.x,r.x=r.y),i.leftPerpendicularThis())}i.y<0?i.negateThis():0===i.y&&(i.x=1)}yr.st_defaultRank=1;class wr{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,n(0),this.m_convexHull=t,this.m_function=this.done_}next(){return n(0),!1}get_vertex_handle_p(){return n(0),0}get_vertex_handle_q(){return n(0),0}get_current_support(){return n(0),0}getNext(t){return n(0),0}getPrev(t){return n(0),0}intialize_(){return n(0),!1}increment_(){return n(0),!1}increment_q_(){return n(0),!1}increment_p_(){return n(0),!1}parallel_edge_with_q_support_(){return n(0),!1}parallel_edge_with_p_support_(){return n(0),!1}done_(){return n(0),!1}}class Ar{nullGetXY(t){return r("m_getXY is null"),{}}nullDeleteNode(t){r("m_deleteNode is null")}constructor(t){return this.m_treeHull=new Z,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=gr,void(this.m_pathHandle=gr)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=gr,void(this.m_pathHandle=gr)):void d("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new yr,this.m_geometryHandle=this.m_shape.createGeometry(e.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,gr),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return n(0),new K}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){n(0)}addGeometry(s){if(s.isEmpty())return;const n=s.getGeometryType();if(n===e.enumGeometryCollection){const t=s;for(let e=0,s=t.getGeometryCount();e<s;e++)this.addGeometry(t.getGeometry(e))}else h(n)?this.addMultiVertexGeometry(s):m(n)?this.addSegment(s,!1):n===e.enumEnvelope?this.addEnvelope(s):n===e.enumPoint?this.addPoint(s):t("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new F,e=this.m_treeHull.getFirst(),s=new mr({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let n=this.m_treeHull.getNext(e);-1!==n;n=this.m_treeHull.getNext(n))this.m_shape.queryPoint(this.m_treeHull.getElement(n),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return n(0),new wr(this)}getXY(t){return n(0),new K}getXYWithIndex(t){return n(0),new K}getFirst(){return n(0),0}getLast(){return n(0),0}getNext(t){return n(0),0}getPrev(t){return n(0),0}getVertexIndex(t){return n(0),0}getPointCount(){return n(0),0}addMultiVertexGeometry(t){const e=new F,s=t.getImpl(),n=new K;for(let i=0;i<t.getPointCount();i++){s.queryXY(i,n);const r=this.addPoint2D(n);if(-1!==r){t.getPointByVal(i,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}if(c(t.getGeometryType())){const e=t;if(e.hasNonLinearSegments()){const t=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextCurve();null!==e&&this.addSegment(e,!0)}}}}addEnvelope(t){const e=new F;for(let s=0;s<4;s++){const n=new K;t.queryCorner(s,n);const i=this.addPoint2D(n);if(-1!==i){t.queryCornerByVal(s,e);const n=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,n)}}}static querySegmentControlPoints(s,i,r){const o=s.getGeometryType();if(n(o!==e.enumLine),o===e.enumEllipticArc){const t=s,e=60*Math.PI/180,n=Math.abs(t.getSweepAngle());if(n>e){const s=Math.min(6,Math.ceil(n/e)),r=1/s,o=new Pm;t.queryStart(i[0]);let a=1;for(let e=0;e<s;e++){t.queryCut(e*r,(e+1)*r,o);const n=ut(K,3);ku(o.get(),n);const h=K.calculateLength(n,3),u=K.calculateLength(n,2),m=h>0?u/h:.5;e<s-1?o.get().queryEnd(i[a+1]):t.queryEnd(i[a+1]),F.lerp(i[a-1],i[a+1],m,i[a]),i[a].setXY(n[1]),a+=2}return a}{const t=ut(K,3);ku(s,t);const e=K.calculateLength(t,3);s.queryStart(i[0]),s.queryEnd(i[2]);const n=K.calculateLength(t,2),r=e>0?n/e:.5;return F.lerp(i[0],i[2],r,i[1]),i[1].setXY(t[1]),3}}if(o===e.enumBezier){const t=s,e=ut(K,4);t.queryControlPoints(e);const n=K.calculateLength(e,4),r=K.calculateLength(e,2),o=K.calculateLength(e,3);s.queryStart(i[0]),s.queryEnd(i[3]);const a=n>0?r/n:.5;F.lerp(i[0],i[3],a,i[1]),i[1].setXY(e[1]);const h=n>0?o/n:.5;return F.lerp(i[0],i[3],h,i[2]),i[2].setXY(e[2]),4}if(o===e.enumBezier2){const t=s,e=ut(K,3);t.queryControlPoints(e);const n=K.calculateLength(e,3);s.queryStart(i[0]),s.queryEnd(i[2]);const r=K.calculateLength(e,2),o=n>0?r/n:.5;return F.lerp(i[0],i[2],o,i[1]),i[1].setXY(e[1]),3}if(o===e.enumRationalBezier2){const t=s,e=ut(K,3);t.queryControlPoints(e);const n=K.calculateLength(e,3);s.queryStart(i[0]),s.queryEnd(i[2]);const r=K.calculateLength(e,2),o=n>0?r/n:.5;return F.lerp(i[0],i[2],o,i[1]),i[1].setXY(e[1]),3}t("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){const e=new F,s=t.getStartXY(),n=this.addPoint2D(s);if(-1!==n){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,s)}const i=t.getEndXY(),r=this.addPoint2D(i);if(-1!==r){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}if(t.isCurve()){const e=ut(F,13);for(let s=1,n=Ar.querySegmentControlPoints(t,e,e.length)-1;s<n;++s){const t=e[s].getXY(),n=this.addPoint2D(t);if(-1!==n){const t=this.m_shape.addPoint(this.m_pathHandle,e[s]);this.m_treeHull.setElement(n,t)}}}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),n=this.m_shape.getXY(s);return t.equals(n)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),n=this.m_treeHull.getLast(),i=this.m_treeHull.getElement(s),r=this.m_treeHull.getElement(n),o=this.m_getXY(i),a=this.m_getXY(r),h=K.orientationRobust(a,t,o);if(Yr(h)){e=this.m_treeHull.addBiggestElement(-1);const i=this.treeHullWalkBackward(t,n,s);i!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(i));break}if(Nr(h)){let i=this.m_treeHull.getRoot(),r=this.m_treeHull.getFirst(),a=this.m_treeHull.getLast(),h=-1,u=-1,m=-1;for(;r!==this.m_treeHull.getPrev(a);){u=this.m_treeHull.getElement(i);const e=this.m_getXY(u);Nr(K.orientationRobust(e,t,o))?(a=i,i=this.m_treeHull.getLeft(i)):(r=i,i=this.m_treeHull.getRight(i))}i=a,h=r,u=this.m_treeHull.getElement(i),m=this.m_treeHull.getElement(h);const l=this.m_getXY(u),c=this.m_getXY(m);if(h!==s){if(!Yr(K.orientationRobust(c,t,l)))break}e=this.m_treeHull.addElementAtPosition(h,i,-2,!0,!1),this.treeHullWalkForward(t,i,n),this.treeHullWalkBackward(t,h,s);break}{const i=Xr(t,a,o);if(-1===i){const i=this.m_treeHull.getPrev(n);this.m_treeHull.deleteNode(n),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,i,s)}else if(1===i){const i=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,i,-3,!0,!1),this.treeHullWalkForward(t,i,n)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let n=e,i=this.m_treeHull.getElement(n),r=this.m_treeHull.getNext(n);const o=this.m_getXY(i);for(;n!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(Yr(K.orientationRobust(s,t,o)))break;const a=n;n=r,i=e,o.assign(s),r=this.m_treeHull.getNext(n),this.m_deleteNode(a)}return n}treeHullWalkBackward(t,e,s){if(e===s)return s;let n=e,i=this.m_treeHull.getElement(n),r=this.m_treeHull.getPrev(n);const o=this.m_getXY(i);for(;n!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(Yr(K.orientationRobust(o,t,s)))break;const a=n;n=r,i=e,o.assign(s),r=this.m_treeHull.getPrev(n),this.m_deleteNode(a)}return n}}function Tr(t,e,s){const n=e.sub(t),i=s.sub(e);if(0===n.x)return i.x>0?-1:0;if(0===n.y)return i.y>0?1:i.y<0?-1:0;const r=n.crossProduct(i),o=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?1:r<-o?-1:K.orientationRobust(t,e,s)}function Ir(t,e,s){const n=e.sub(t),i=s.sub(e);if(0===n.x)return i.x<0?-1:0;if(0===n.y)return i.y>0?-1:i.y<0?1:0;const r=n.crossProduct(i),o=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?1:r<-o?-1:K.orientationRobust(t,e,s)}function Mr(t,e,s,n){const i=new j(0);for(let h=0;h<e;h++)i.add(h);const r={userSort(e,s,n){n.sort(e,s,(e,s)=>t[e].compareX(t[s]))},getValue:e=>t[e].x};n||W.sortEx(i,0,e,r);let o=0;t:for(let h=0;h<e;++h){const e=i.read(h);for(;o>=2;){const n=s[o-2],r=s[o-1];if(t[r].equals(t[e])){i.write(h,-1);continue t}if(!(Tr(t[n],t[r],t[e])>=0)){r===i.read(h-1)&&i.write(h-1,-1);break}o--}s[o++]=e,2===o&&t[e].equals(t[s[0]])&&(i.write(1,-1),o--)}const a=o+1;t:for(let h=e-2;h>=0;--h){const e=i.read(h);if(!(e<0)){for(;o>=a;){const n=s[o-2],i=s[o-1];if(t[i].equals(t[e]))continue t;if(!(Ir(t[n],t[i],t[e])>=0))break;o--}if(0!==h){const n=s[o-1];s[o++]=e,t[e].equals(t[n])&&o--}}}return o>1&&t[s[0]].equals(t[s[o-1]])&&o--,o}function Yr(t){return t<0}function Nr(t){return t>0}function Xr(t,e,s){let n=-1;if(e.y===s.y)n=0;else if(e.x===s.x)n=1;else{n=Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1}let i=-1;return i=e[n]<s[n]?t[n]<e[n]?-1:s[n]<t[n]?1:0:e[n]<t[n]?-1:t[n]<s[n]?1:0,i}function qr(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function Fr(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Vr(e,s,n,i,r){switch(r){case 0:break;case 1:s.rightPerpendicularThis(),e.rightPerpendicularThis();break;case 2:s.negateThis(),e.negateThis();break;case 3:s.leftPerpendicularThis(),e.leftPerpendicularThis();break;default:t("")}return K.orientationRobustEx(e,s,n,i)}class Lr{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Rr(t){return zr(t.calculateUpperLength2D())}function zr(t){return 256*ct()*t}function Br(t){const e=K.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function kr(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Gr(t,e,s){const n=ut(K,4);t.queryControlPoints(n),jr(n,e,s)}function Wr(t,e,s){const n=ut(K,4);t.queryControlPoints(n),Zr(n,e,s)}function jr(t,e,s){let n=t[1].x;n-=t[0].x,n*=3;let i=t[2].x;i-=t[1].x,i*=3;let r=t[3].x;r-=t[0].x,r-=i,i-=n,e[3].setWithEps(r),e[2].setWithEps(i),e[1].setWithEps(n),s?e[0].set(0):e[0].set(t[0].x)}function Zr(t,e,s){let n=t[1].y;n-=t[0].y,n*=3;let i=t[2].y;i-=t[1].y,i*=3;let r=t[3].y;r-=t[0].y,r-=i,i-=n,e[3].setWithEps(r),e[2].setWithEps(i),e[1].setWithEps(n),s?e[0].set(0):e[0].set(t[0].y)}function Hr(t,e,s=!1){const n=ut(Ee,4);n[0].assignPoint2D(t[0]),n[1].assignPoint2D(t[1]),n[2].assignPoint2D(t[2]),n[3].assignPoint2D(t[3]),e[1].setCoords(n[1].x.sub(n[0].x),n[1].y.sub(n[0].y)),e[1].mulThis(tt.constructInt32(3)),e[2].setCoords(n[2].x.sub(n[1].x),n[2].y.sub(n[1].y)),e[2].mulThis(tt.constructInt32(3)),e[3]=n[3].sub(n[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(te,te):e[0]=n[0].clone()}function Ur(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ur(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=Jr(t);if(n&&!Number.isNaN(i.length)&&!Number.isNaN(i.length))return i.length;const r=Rr(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let u=1,m=i.specialPointsCount();u<m;u++){const s=i.specialPoints[u];if(a+=ta(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function Or(t,e,s){const n=Ur(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==en(new Ko(t,e),U.unit(),1,i)&&r(""),i[0]}function Qr(e,s,n){void 0===n&&(n=s,s=0);const i=new K;if(s<0||n>1)return i.setNAN(),i;if(s>n&&t("calculate_sub_weightedCentroid"),s===n||e.isDegenerate(0))return i.setCoords(0,0),i;const r=Jr(e),o=Rr(e),a=o/e.calculateUpperLength2D();let h=s,u=0;for(let t=1,m=r.specialPointsCount();t<m;t++)if(s<r.specialPoints[t]){u=t-1;break}i.setCoords(0,0);for(let t=u+1,m=r.specialPointsCount();t<m;t++){const s=Math.min(r.specialPoints[t],n),u=ea(e,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[t])break}return i.add(e.getStartXY().mul(e.calculateLength2D()))}function Jr(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Lr,s=ut(rt,8),n=ut(K,4);t.queryControlPoints(n);const i=Zo(n,s);e.specialPoints=[];for(let r=0;r<i;r++)e.specialPoints.push(s[r].value());return $r(t,e),e}function Kr(t){let e=null;return e=t.m_cachedValues,e}function $r(t,e){t.m_cachedValues=e}function to(t){t.m_cachedValues=null}function eo(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function so(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),r=new ce,o=ut(K,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new K;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=ut(K,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformPoints2D(t.m_cp,2,t.m_cp):(Ct(e,s,1/3,t.m_cp[0]),Ct(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),i&&co(t)}function no(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function io(t,e,s,n){const i=ut(K,4);t.queryControlPoints(i);const r=et(18,NaN),o=en(new Lo(i,e,NaN),U.construct(s,n),18,r),a=new K;t.queryCoord2D(s,a);let h=s,u=K.distance(a,e);const m=new K;t.queryCoord2D(n,m);const l=K.distance(m,e);l<u&&(u=l,h=n,a.assign(m));for(let c=0;c<o;c++){t.queryCoord2D(r[c],m);const s=K.distance(m,e);s<u&&(u=s,h=r[c],a.assign(m))}return no(s,n,h,u,a)}function ro(t,e){const s=ut(rt,4);Gr(t,s,!0);const i=ut(rt,4);Wr(t,i,!0);const r=s[3].clone(),o=s[2].clone(),a=s[1].clone(),h=i[3].clone(),u=i[2].clone(),m=i[1].clone(),l=o.mulE(a).addE(u.mulE(m)).mul(4),c=o.mulE(o).mul(8).addE(r.mulE(a).mul(12)).addE(u.mulE(u).mul(8).addE(h.mulE(m).mul(12))),g=r.mulE(o).addE(h.mulE(u)).mul(36),d=r.mulE(r).addE(h.mulE(h)).mul(36),_=ut(rt,3),p=_n(d,g,c,l,new U(0,1),!1,_);if(n(p<=3),p>0){const s=mo(t,1,0).sqrLength(),n=mo(t,1,1).sqrLength();let i=s;e.set(0),i<n&&(i=n,e.set(1));for(let r=0;r<p;r++){const s=mo(t,1,_[r].value()).sqrLength();s<i&&(i=s,e=_[r])}}}function oo(t,e,s,n){if(1===e){const e=1-s,i=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),u=o.mul(i).add(a.mul(2*e*s)).add(h.mul(r));n.assign(u.mul(3))}else if(2===e){const e=1-s,i=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=i.mul(e).add(r.mul(s));n.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);n.assign(s.mul(6))}else n.setCoords(0,0)}function ao(t,e,s,n){{const e=ot.subE(s),i=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(i).addE(t[2].subE(t[1]).mulE(new rt(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));n.setE(o.mulE(new rt(3)))}}function ho(t,e,s){const n=new K;return oo(t,e,s,n),n}function uo(t,e,s){const n=[be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),be.constructPoint2D(t[2]),be.constructPoint2D(t[3])],i=new be;return ao(n,e,s,i),i}function mo(t,e,s){const n=ut(K,4);return t.queryControlPoints(n),ho(n,e,s)}function lo(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),n=t.getEndXY().sub(t.getStartXY());e.mulThis(3),s.mulThis(3),n.subThis(s),s.subThis(e);return(3*n.x*(2*s.y+5*e.y)-3*n.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function co(t){const e=ut(K,4);t.queryControlPoints(e);const s=go(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function go(t){return we(t)}function _o(t){return Ae(t)}function po(t,e,s){const n=new K,i=new K,r=new K,o=new K,a=new K;e<=.5?(qt(2,t[0],t[1],e,n),qt(2,t[1],t[2],e,i),qt(2,t[2],t[3],e,r),qt(2,n,i,e,o),qt(2,i,r,e,a),qt(2,o,a,e,s)):(Ft(2,t[0],t[1],e,n),Ft(2,t[1],t[2],e,i),Ft(2,t[2],t[3],e,r),Ft(2,n,i,e,o),Ft(2,i,r,e,a),Ft(2,o,a,e,s))}function fo(t,e,s,i){n(e>=0&&e<=1);const r=new K,o=new K,a=new K,h=new K,u=new K,m=new K;e<=.5?(qt(2,t[0],t[1],e,r),qt(2,t[1],t[2],e,o),qt(2,t[2],t[3],e,a),qt(2,r,o,e,h),qt(2,o,a,e,u),qt(2,h,u,e,m)):(Ft(2,t[0],t[1],e,r),Ft(2,t[1],t[2],e,o),Ft(2,t[2],t[3],e,a),Ft(2,r,o,e,h),Ft(2,o,a,e,u),Ft(2,h,u,e,m));const l=t[3].clone();s&&(s[0].assign(t[0]),s[1].assign(r),s[2].assign(h),s[3].assign(m)),i&&(i[0].assign(m),i[1].assign(u),i[2].assign(a),i[3].assign(l))}function Po(t,e,s,i){if(n(e>=0&&s<=1&&e<=s),e===s){const s=new K;return yo(t,e,s),i[0].assign(s),i[1].assign(s),i[2].assign(s),void i[3].assign(s)}if(0===e&&1===s){for(let e=0;e<4;++e)i[e].assign(t[e]);return}const r=ut(K,4);fo(t,s,r,null),fo(r,s>0?e/s:0,null,r),yo(t,e,r[0]),yo(t,s,r[3]),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]),i[2].setCoordsPoint2D(r[2]),i[3].setCoordsPoint2D(r[3])}function yo(t,e,s,n){if(n){if(e<0){return void ps(new fm({start:t[0],end:t[0].add(vo(t,0).getUnitVector())}),e,s)}if(e>1){return void ps(new fm({start:t[3],end:t[3].add(vo(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=new K;qt(2,t[0],t[1],e,n);const i=new K;qt(2,t[1],t[2],e,i);const r=new K;qt(2,t[2],t[3],e,r);const o=new K;qt(2,n,i,e,o);const a=new K;qt(2,i,r,e,a),qt(2,o,a,e,s)}else{const n=new K;Ft(2,t[0],t[1],e,n);const i=new K;Ft(2,t[1],t[2],e,i);const r=new K;Ft(2,t[2],t[3],e,r);const o=new K;Ft(2,n,i,e,o);const a=new K;Ft(2,i,r,e,a),Ft(2,o,a,e,s)}}function xo(t,e,s){if(e.value()<=.5){const n=new be;Vt(2,be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),e,n);const i=new be;Vt(2,be.constructPoint2D(t[1]),be.constructPoint2D(t[2]),e,i);const r=new be;Vt(2,be.constructPoint2D(t[2]),be.constructPoint2D(t[3]),e,r);const o=new be;Vt(2,n,i,e,o);const a=new be;Vt(2,i,r,e,a),Vt(2,o,a,e,s)}else{const n=new be;Lt(2,be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),e,n);const i=new be;Lt(2,be.constructPoint2D(t[1]),be.constructPoint2D(t[2]),e,i);const r=new be;Lt(2,be.constructPoint2D(t[2]),be.constructPoint2D(t[3]),e,r);const o=new be;Lt(2,n,i,e,o);const a=new be;Lt(2,i,r,e,a),Lt(2,o,a,e,s)}}function Co(t,e,s){const n=ut(K,4);t.queryControlPoints(n),xo(n,e,s)}function vo(t,e){const s=gt(e,0,1);let n=ho(t,1,s);return n.isZero()&&(n=ho(t,2,s),n.isZero()?n=ho(t,3,s):1===s&&n.negateThis()),n}function bo(t,e,s){const n=ut(K,4);t.queryControlPoints(n),So(n,e,s)}function So(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(uo(t,1,e))}function Eo(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Io(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Do(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Mo(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function wo(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==Yo(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Ao(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==No(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function To(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==Xo(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Io(t,e,s,n,i,r,o,a,h,u){if(null!==i&&(i.length=0),null!=r&&(r.length=0),null!==n&&(n.length=0),s.isDegenerate(0)){const t=[0,0,0],a=e.intersectPoint(s.getStartXY(),t,o);if(a>0){if(null!==i)for(let e=0;e<a;e++)i.push(t[e]);if(null!==r)for(let t=0;t<a;t++)r.push(0);if(null!=n)for(let s=0;s<a;s++){const i=new K;e.queryCoord2D(t[s],i),n.push(i)}}return a}const m=Qe(e,s);if(Je(e,s,o=Math.max(o,m)))return 0;const l=ut(K,4);kr(e,l);const c=s.getEndXY();c.subThis(s.getStartXY());const g=c.clone();g.leftPerpendicularThis();let d=3*l[3].dotProduct(g),_=2*l[2].dotProduct(g),p=l[1].dotProduct(g);const f=et(15,Number.NaN),P=et(15,Number.NaN);let y=nn(d,_,p,U.unit(),!1,f);y<0&&(f[0]=0,f[1]=1,y=2);let x,C=0;for(let S=0,E=C;S<y;++S){const t=e.getCoord2D(f[S+E]);P[C]=s.getClosestCoordinate(t,!1),K.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[S+E],C++)}if(l[0].subThis(s.getStartXY()),Math.abs(c.x)>=Math.abs(c.y)){const t=c.y/c.x;d=l[3].y-l[3].x*t,_=l[2].y-l[2].x*t,p=l[1].y-l[1].x*t,x=l[0].y-l[0].x*t}else{const t=c.x/c.y;d=l[3].x-l[3].y*t,_=l[2].x-l[2].y*t,p=l[1].x-l[1].y*t,x=l[0].x-l[0].y*t}const v=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),b=[0,0,0];y=rn(d,_,p,x,U.unit(),v,b);for(let S=0,E=C;S<y;++S){f[S+E]=b[S];const t=e.getCoord2D(f[S+E]);P[C]=s.getClosestCoordinate(t,!1);K.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[S+E],C++)}y=e.intersectPoint(s.getStartXY(),b,o);for(let S=0;S<y;S++)f[C]=b[S],P[C++]=0;y=e.intersectPoint(s.getEndXY(),b,o);for(let S=0;S<y;S++)f[C]=b[S],P[C++]=1;return 0!==s.intersectPoint(e.getStartXY(),b,o)&&(P[C]=b[0],f[C++]=0),0!==s.intersectPoint(e.getEndXY(),b,o)&&(P[C]=b[0],f[C++]=1),0===C?0:gm(t,e,s,f,P,C,n,i,r,o,a,h,u)}function Mo(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return Io(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Je(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=[],d=ut(K,4);{e.queryControlPoints(d);const t=ut(K,4),n=new ce;s.canonicToWorldTransformation(n);const i=new ce;i.setInvert(n),i.transformPoints2D(d,4,t);const r=ut(Ee,4);Hr(t,r);const h=[r[0].x,r[1].x,r[2].x,r[3].x],u=[r[0].y,r[1].y,r[2].y,r[3].y],m=ut(tt,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2].setThis(m[0]),m[2].mulThis(m[1]),m[2].negateThis();const _=Fn(h,3,u,3,null,0,m,!0,U.unit(),U.unit(),c,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new K;e.queryCoord2D(c[n],i);const r=s.getClosestCoordinate(i,!1),a=new K;s.queryCoord2D(r,a);K.distance(i,a)<=o&&(l.push(i.clone()),c[t]=c[n],g.push(r),t++)}c.length=t,l.length=t}}const _=[0,1];for(let p=0;p<2;p++){const t=0===p?s.getStartXY():s.getEndXY(),e=[0];Ro(d,t,U.unit(),!1,-1,1,e);const n=new K;yo(d,e[0],n);K.distance(t,n)<=o&&(c.push(e[0]),g.push(_[p]),l.push(n.clone()))}for(let p=0;p<2;p++){const t=[0,3];{const e=s.getClosestCoordinate(d[t[p]],!1),n=new K;s.queryCoord2D(e,n);K.distance(d[t[p]],n)<=o&&(c.push(_[p]),g.push(e),l.push(n.clone()))}}return gm(t,e,s,c,g,c.length,n,i,r,o,a,h,u)}function Yo(t,e,s,i,r,o,a,h,u,m){const l=ut(K,4);e.queryControlPoints(l);const c=ut(K,4);if(s.queryControlPoints(c),Ke(l,c,4)<0)return Yo(t,s,e,i,o,r,a,h,u,!m);const g=Qe(e,s);if(Je(e,s,a=Math.max(a,g)))return 0;if(sa(e,s,i,r,o,a,h,u,m))return 2;const d=new U(0,1),_=new U(0,1);{const t=new fe;Vo(l,new U(0,1),t);const e=new fe;Vo(c,new U(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Qo(l,t,d),d.isEmpty())return 0;if(Qo(c,t,_),_.isEmpty())return 0;Po(l,d.vmin,d.vmax,l),Po(c,_.vmin,_.vmax,c)}}const p=_m(l,3,c,3,a);if(0===p)return 0;const f=[],P=[],y=[];let x=!1;if(-1===p){const t=ut(Ee,4);Hr(l,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],n=ut(Ee,4);Hr(c,n);const i=[],r=[],o=Nn(e,3,s,3,null,0,[n[0].x,n[1].x,n[2].x,n[3].x],3,[n[0].y,n[1].y,n[2].y,n[3].y],3,null,0,!0,U.unit(),U.unit(),i,r,u);if(o>0)for(let h=0;h<o;h++){const t=new K;yo(c,r[h],t);const e=new K;yo(l,i[h],e);K.distance(e,t)<=a&&(f.push(e.clone()),y.push(r[h]),P.push(i[h]))}else-1===o&&(x=!0)}for(let n=0;n<2;n++){const t=0===n?l:c,e=0===n?c:l;for(let s=0;s<2;s++){const i=0===s?0:3,r=[0];Ro(e,t[i],U.unit(),!1,-1,1,r);const o=new K;yo(e,r[0],o);K.distance(t[i],o)<=a&&(0===n?(P.push(0===i?0:1),y.push(r[0])):(y.push(0===i?0:1),P.push(r[0])),f.push(o.clone()))}}if(0===P.length&&x){const t=e.calculateUpperLength2D()>s.calculateUpperLength2D();{const i=[0,0];if(2===Wo(t?e:s,i,!0)&&(n(U.unit().containsCoordinate(i[0])),!U.unit().containsCoordinate(i[1]))){const e=new K;yo(t?l:c,i[0],e);const s=[0,0];1===Ro(t?c:l,e,U.unit(),!1,-1,2,s)&&(f.push(e.clone()),P.push(t?i[0]:s[0]),y.push(t?s[0]:i[0]))}}}if(0===P.length)return 0;if(!d.equalsRange(0,1))for(let n=0;n<P.length;++n)P[n]=ra.recalculateParentT(d.vmin,d.vmax,P[n]);if(!_.equalsRange(0,1))for(let n=0;n<y.length;++n)y[n]=ra.recalculateParentT(_.vmin,_.vmax,y[n]);return gm(t,e,s,P,y,P.length,i,r,o,a,h,u,m)}function No(t,e,s,i,r,o,a,h,u,m){const l=Qe(e,s);if(s.isDegenerateToLineHelper(l)){const n=new fm({start:s.getStartXY(),end:s.getEndXY()}),l=Io(t,e,n,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=n.getCoord2D(o[t]);o[t]=s.getClosestCoordinate(e,!1)}return l}if(Je(e,s,a=Math.max(a,l)))return 0;const c=ut(K,4);e.queryControlPoints(c);const g=ut(K,3);s.queryControlPoints(g);const d=new U(0,1),_=new U(0,1),p=[0,0,0];s.queryWeights(p);const f=[1,Ph(p),1];{const t=new fe;Vo(c,new U(0,1),t);const e=new fe;ja(g,f,new U(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Qo(c,t,d),d.isEmpty())return 0;if(fh(g,f,t,_),_.isEmpty())return 0;Po(c,d.vmin,d.vmax,c),Ja(g,f,_.vmin,_.vmax,g,f)}}const P=_m(c,3,g,2,a);if(0===P)return 0;const y=[],x=[],C=[];if(-1===P){const t=ut(Ee,4);Hr(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],n=ut(tt,3),i=ut(tt,3),r=ut(tt,3);uh(g,f,n,i,r);const o=[],h=[],m=Nn(n,2,i,2,r,2,e,3,s,3,null,0,!0,U.unit(),U.unit(),h,o,u);if(m>0)for(let u=0;u<m;u++){const t=new K;yo(c,o[u],t);const e=new K;ph(g,f,h[u],e);K.distance(t,e)<=a&&(y.push(t.clone()),x.push(o[u]),C.push(h[u]))}}for(let v=0;v<2;v++){let t,e;0===v?(t=c,e=g):(e=c,t=g);for(let s=0;s<2;s++){const i=0===s?0:t.length-1,r=[0],o=new K;if(0===v){const s=Ba(e,f,t[i],U.unit(),!1,-1,1,r);n(1===s),ph(e,f,r[0],o)}else{const s=Ro(e,t[i],U.unit(),!1,-1,1,r);n(1===s),yo(e,r[0],o)}K.distance(t[i],o)<=a&&(0===v?(x.push(0===i?0:1),C.push(r[0])):(C.push(0===i?0:1),x.push(r[0])),y.push(o.clone()))}}if(0===x.length)return 0;if(!d.equalsRange(0,1))for(let n=0;n<x.length;++n)x[n]=ra.recalculateParentT(d.vmin,d.vmax,x[n]);if(!_.equalsRange(0,1))for(let n=0;n<C.length;++n)C[n]=Dn.recalculateParentT(_.vmin,_.vmax,C[n]);for(let n=0;n<C.length;++n)C[n]=yh(p,C[n]);return gm(t,e,s,x,C,x.length,i,r,o,a,h,u,m)}function Xo(t,e,s,i,r,o,a,h,u,m){const l=Qe(e,s);if(Je(e,s,a=Math.max(a,l)))return 0;const c=ut(K,4);e.queryControlPoints(c);const g=ut(K,3);s.queryControlPoints(g);const d=_m(c,3,g,2,a);if(0===d)return 0;const _=[],p=[],f=[];if(-1===d){const t=ut(Ee,4);Hr(c,t);const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y],r=ut(Ee,3);ji(g,r);const o=Nn([r[0].x,r[1].x,r[2].x],2,[r[0].y,r[1].y,r[2].y],2,null,0,n,3,i,3,null,0,!0,U.unit(),U.unit(),f,p,h);if(o>0){let t=0;for(let n=0;n<o;n++){const i=new K;e.queryCoord2D(p[n],i);const r=new K;s.queryCoord2D(f[n],r);K.distance(i,r)<=a&&(_.push(i.clone()),p[t]=p[n],f[t]=f[n],t++)}p.length=t,_.length=t}}for(let P=0;P<2;P++){let t,e;0===P?(t=c,e=g):(e=c,t=g);for(let s=0;s<2;s++){const i=0===s?0:t.length-1,r=[0],o=new K;if(0===P)bi(e,t[i],r),Zi(e,r[0],o);else{const s=Ro(e,t[i],U.unit(),!1,-1,1,r);n(1===s),yo(e,r[0],o)}K.distance(t[i],o)<=a&&(0===P?(p.push(0===i?0:1),f.push(r[0])):(f.push(0===i?0:1),p.push(r[0])),_.push(o.clone()))}}return gm(t,e,s,p,f,p.length,i,r,o,a,h,u,m)}function qo(t,e,s,r,o){const a=new fe;if(Fo(t,U.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;const h=Jr(t);let u=0,m=h.specialPoints[0];const l=[];for(let i=1,c=h.specialPoints.length;i<c;++i){const s=h.specialPoints[i],r=io(t,e,m,s);if(0===l.length)l.push(r);else if(r.t===r.tmin)n(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){n(l.at(-1).d>=r.d);const t=l.at(-1).tmin;l[l.length-1]=r,l.at(-1).tmin=t}else l.push(r);m=s}for(const n of l)if(n.d<=r){const t=n.t;s?(u>=s.length&&i(""),s[u]=t,u++):u++}return u}function Fo(t,e,s){const n=ut(K,4);t.queryControlPoints(n),Vo(n,e,s)}function Vo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const n=ut(K,4);Po(t,e.vmin,e.vmax,n),s.setFromPoints(n,4)}let Lo=class{constructor(t,e,s){this.dbgCounter=0,this.controlPoints=t,this.point=e.clone(),this.maxDistance=s}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new K;yo(this.controlPoints,e,t);const s=ho(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new K;yo(this.controlPoints,e,t);const s=ho(this.controlPoints,1,e),n=ho(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(n)+s.dotProduct(s))}case 2:{const t=new K;yo(this.controlPoints,e,t);const s=ho(this.controlPoints,1,e),n=ho(this.controlPoints,2,e),i=ho(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(i)+3*s.dotProduct(n))}case 3:{const t=ho(this.controlPoints,1,e),s=ho(this.controlPoints,2,e),n=ho(this.controlPoints,3,e);return 2*(4*t.dotProduct(n)+3*s.sqrLength())}case 4:{const t=ho(this.controlPoints,2,e),s=ho(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=ho(this.controlPoints,3,e);return 2*(10*t.dotProduct(t))}default:return 0}}getError(t){return 0}isInterestingInterval(t,e){if(t>=0&&e<=1){const s=ut(K,4);Po(this.controlPoints,t,e,s);const n=new fe;if(n.setFromPoints(s,4),Math.sqrt(n.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function Ro(t,e,s,i,r,o,a){_(U.unit().contains(s)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],u=new K;yo(t,s.vmin,u);let m=K.distance(u,e);if(m<=r&&h.push(new K(s.vmin,m)),s.vmin!==s.vmax&&(yo(t,s.vmax,u),m=K.distance(u,e),m<=r&&h.push(new K(s.vmax,m))),s.width()>0){const n=et(18,Number.NaN),i=en(new Lo(t,e,r),s,18,n);for(let s=0;s<i;s++)yo(t,n[s],u),m=K.distance(u,e),m>r||h.push(new K(n[s],m))}if(i){n(s.equals(U.unit()));{yo(t,-1,u,!0);const s=new K;yo(t,0,s);const n=new fm({start:u,end:s}),i=n.getClosestCoordinate(e,!0);i<1&&(u.assign(n.getCoord2D(i)),m=K.distance(u,e),m<=r&&h.push(new K(i-1,m)))}{yo(t,2,u,!0);const n=new K;yo(t,s.vmax,n);const i=new fm({start:n,end:u}),o=i.getClosestCoordinate(e,!0);o>0&&(u.assign(i.getCoord2D(o)),m=K.distance(u,e),m<=r&&h.push(new K(1+o,m)))}}if(!h.length)return 0;h.sort((t,e)=>t.compare(e));let l=0;const c=h[0].x;if(a[l++]=c,l<o){const e=H(t,4,!1).total(),s=h[0].y;for(let t=1,n=h.length;t<n;t++)if(h[t].y>s+e){h.length=t;break}h.sort((t,e)=>kt(t.x,e.x)),l=0,a[l++]=h[0].x;for(let t=1,n=h.length;t<n;t++)h[t].x!==a[l-1]&&l<o&&(a[l++]=h[t].x)}return l}function zo(t,e,s,n,i,r,o){const a=ut(K,4);return t.queryControlPoints(a),Ro(a,e,s,n,i,r,o)}function Bo(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function ko(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function Go(t,e,s){if(n(s>=2),2===s){const n=new K;Ct(e[0],e[s-1],1/3,n);const i=new K;return Ct(e[0],e[s-1],2/3,i),void t.construct(e[0],n,i,e[s-1])}const i=e[0],r=e[s-1],o=[0,0],a=zo(t,i,U.unit(),!1,Number.NaN,2,o),h=[0,0],u=zo(t,r,U.unit(),!1,Number.NaN,2,h),m=[];for(let n=0;n<a;n++)for(let a=0;a<u;a++){const u=o[n],l=h[a],c=u>l,g=(n,o)=>{const a=et(s-2,Number.NaN),h=()=>{let t=0;for(let n=1,i=s-1;n<i;n++){t+=K.distance(e[n-1],e[n]);const s=t;a[n-1]=s}t+=K.distance(e[s-2],e[s-1]),c&&a.reverse();for(let e=1,n=s-1;e<n;e++)a[e-1]/=t,c&&(a[e-1]=1-a[e-1])};let m=!1,g=!1;{const e=new Pm;c?(t.queryCut(l,u,e,!0),n.assign(e.get().getControlPoint2()),o.assign(e.get().getControlPoint1())):(t.queryCut(u,l,e,!0),n.assign(e.get().getControlPoint1()),o.assign(e.get().getControlPoint2())),i.equals(n)&&(m=!0),r.equals(o)&&(g=!0)}h();let d=Number.MAX_VALUE;const _=n.clone(),p=o.clone();for(let t=0;t<5;t++){d=na(!0,!1,i,_,p,r,m,g,a,s-2,e,s)}for(let t=0;t<30;t++){const t=_.clone();p.clone();const n=na(!0,!0,i,_,p,r,m,g,a,s-2,e,s);if(d<=n&&t.equals(_)&&t.equals(p))break;d=n}h();let f=!1,P=Number.MAX_VALUE;const y=n.clone(),x=o.clone();for(let t=0;t<30;t++){const t=y.clone();x.clone();const n=na(f,!0,i,y,x,r,m,g,a,s-2,e,s);if(P<=n&&t.equals(y)&&t.equals(x))break;f=!0,P=n}return P<d?(n.assign(y),o.assign(x)):(n.assign(_),o.assign(p),P=d),P},d=new K,_=new K,p=[g(d,_),K.distance(i,d)+K.distance(d,_)+K.distance(_,r),d.x,d.y,_.x,_.y];m.splice(m.length,0,...p)}let l=m[0],c=m[1],g=0;for(let n=6;n<m.length;n+=6)m[n]<l&&(l=m[n],c=m[n+1],g=n);let d=g;for(let n=0;n<m.length;n+=6)n!==g&&m[n+1]<c&&Math.abs(l-m[n])<10*l&&(c=m[n+1],d=n);t.construct(i,new K(m[d+2],m[d+3]),new K(m[d+4],m[d+5]),r)}function Wo(t,e,s=!1){const n=ut(K,4);t.queryControlPoints(n);const i=ut(Ee,4);let r,o,a;Hr(n,i,!0);const h=i[3].x.isZero(),u=i[3].y.isZero();if(h||u)if(h&&!u){if(i[2].x.isZero())return 0;r=i[1].x.div(i[2].x).negate(),o=i[2].y.div(i[3].y),a=i[1].y.div(i[3].y)}else{if(h||!u)return 0;if(i[2].y.isZero())return 0;r=i[1].y.div(i[2].y).negate(),o=i[2].x.div(i[3].x),a=i[1].x.div(i[3].x)}else{i[2].x.divThis(i[3].x),i[1].x.divThis(i[3].x),i[2].y.divThis(i[3].y),i[1].y.divThis(i[3].y);const t=i[2].x.sub(i[2].y);if(t.isZero())return 0;r=i[1].x.sub(i[1].y).div(t).negate(),o=i[2].x.clone(),a=i[1].x.clone()}if(!s&&r.abs().value()>2)return 0;const m=[0,0],l=t.getStartXY().equals(t.getEndXY()),c=nn(1,-r.toDouble(),r.add(o).mul(r).add(a).toDouble(),U.unit(),l,m);if(0===c)return 0;if(m[0]>=0&&m[0]<=1){const t=r.toDouble()-m[0];if(s||t>=0&&t<=1)return e[0]=m[0],e[1]=t,e[0]>e[1]&&(e[1]=Q(e[0],e[0]=e[1])),2}if(2===c&&m[1]>=0&&m[1]<=1){const t=r.toDouble()-m[1];if(s||t>=0&&t<=1)return e[0]=m[1],e[1]=t,e[0]>e[1]&&(e[1]=Q(e[0],e[0]=e[1])),2}return 0}function jo(t,e,s){const n=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),i=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),r=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),o=ut(rt,2);let a=dn(r,i,n,new U(0,1),!1,o);a<0&&(a=0);let h=0;for(let u=0;u<a;u++)lt(o[u].value(),0,1)||(s[h].setE(o[u]),h++);return h}function Zo(t,e){e[0].set(0);let s=1;const i=ut(rt,4);jr(t,i,!0);const r=ut(rt,4);Zr(t,r,!0);{const t=i[3].mul(3),n=i[2].mul(2),r=i[1].clone(),o=ut(rt,2);let a=dn(t,n,r,new U(0,1),!1,o);a<0&&(a=0);for(let i=0;i<a;i++)lt(o[i].value(),0,1)||(e[s]=o[i],s++)}{const t=r[3].mul(3),n=r[2].mul(2),i=r[1].clone(),o=ut(rt,2);let a=dn(t,n,i,new U(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)lt(o[r].value(),0,1)||(e[s]=o[r],s++)}if(s+=jo(i,r,e.slice(s)),e[s].set(1),s++,s>2){ft(e,0,s,(t,e)=>{const s=t.value(),n=e.value();return s<n?-1:s>n?1:0});let n=0;const i=e[0].clone();let r=0;const o=ko(t)*ct(),a=new K;po(t,e[0].value(),a);for(let h=1;h<s;h++){const s=new K;if(po(t,e[h].value(),s),e[h].eq(i)||s.isEqualPoint2D(a,o)){if(0!==n){if(0===e[h].eps())i.setE(e[h]),r=0;else if(0!==r){const t=Bt(1/e[h].eps()),s=1/r,n=t+s;i.set((e[h].value()*t+i.value()*s)/n),r=1/n,i.setError(Math.sqrt(r))}e[n].setE(i),po(t,i.value(),a)}}else n++,e[n].setE(e[h]),i.setE(e[h]),po(t,i.value(),a),r=Bt(e[h].eps())}n++,s=n}return 1===s&&(s=2,e[1].set(1)),n(0===e[0].value()),n(1===e[s-1].value()),s}function Ho(t,e,s,n,i){const r=ut(rt,4),o=ut(rt,3),a=new U(0,1);let h=0;if(e){if(Zr(t,r,!1),h=_n(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new K;yo(t,o[u].value(),e),n[u]=e.x}}else if(jr(t,r,!1),h=_n(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new K;yo(t,o[u].value(),e),n[u]=e.y}if(i)for(let u=0;u<h;u++)i[u]=o[u].value();else n&&ft(n,0,h,kt);return h}function Uo(t,e,s,n){const i=Oo(t,e,s,n.getEnvelope2D());if(i.isEmpty())return new U(i);const r=ut(K,s);for(let a=0;a<s;++a)n.xyRot(t[a],r[a]);const o=Oo(r,e,s,n.getRotatedEnvelope2D());return i.intersect(new U(o)),new U(i)}function Oo(t,e,s,n){const i=ut(K,s);for(let a=0;a<s;++a)i[a]=new K(a/(s-1),0);const r=(t,e,s,n)=>{const i=.1,r=new rt(e.x).subE(new rt(t.x)).divE(new rt(e.y).subE(new rt(t.y))).mulE(new rt(s).subE(new rt(t.y))).addE(new rt(t.x));if(r.eps()>i){const n=(e.x-t.x)/(e.y-t.y)*(s-t.y)+t.x;r.set(n,ct())}if(r.lt(new rt(0))||r.gt(new rt(1)))return!1;let o=r.value()-r.eps();o=gt(o,0,1);let a=r.value()+r.eps();return a=gt(a,0,1),n.mergeCoordinate(o),n.mergeCoordinate(a),!0},o=[];{const e=(t,e)=>{o.length=s;const n=Cr(i,s,o,!0),a=new U;a.setEmpty();const h=s=>s.y<t?-1:s.y>e?1:0;let u=i[o[0]],m=h(u);0===m&&a.mergeCoordinate(u.x);for(let s=1;s<=n;++s){const l=i[o[s%n]],c=h(l);0===c&&a.mergeCoordinate(l.x);let g=0;c!==m&&(g=c*m===0?1===c||1===m?2:1:3,1&g&&r(u,l,t,a),2&g&&r(u,l,e,a)),u=l,m=c}return a};for(let n=0;n<s;++n)i[n].y=t[n].x;const a=e(n.xmin,n.xmax);if(a.isEmpty())return new U(a);for(let n=0;n<s;++n)i[n].y=t[n].y;const h=e(n.ymin,n.ymax);return a.intersect(new U(h)),new U(a)}}function Qo(t,e,s){s.setEmpty(),s.merge(Uo(t,null,4,e))}function Jo(t,e,s){s.length=0;{const e=new rt;ro(t,e);const n=new be;if(bo(t,e,n),n.isZero())return e.isZero()||e.eq(new rt(1))?0:(s.push(e.value()),1)}const n=ut(rt,4);Gr(t,n,!0);const i=ut(rt,4);Wr(t,i,!0);const r=ut(rt,6),o=n[3].negate().mulE(i[1]).addE(n[2].mulE(i[2]).mul(2)).addE(n[1].mulE(i[3])),a=n[3].negate().mulE(i[1]).subE(n[2].mulE(i[2]).mul(2)).addE(n[1].mulE(i[3])),h=n[2].mulE(n[2]).subE(i[2].mulE(i[2]));r[0]=i[1].mulE(i[1]).mulE(o).addE(n[1].mulE(n[1]).mulE(a)).addE(n[1].mulE(i[1]).mulE(h).mul(2)).mul(6),r[1]=n[2].mulE(i[1]).subE(n[1].mulE(i[2])).mulE(n[2].mulE(n[2]).addE(n[1].mulE(n[3]).mul(2)).addE(i[2].mulE(i[2])).addE(i[1].mulE(i[3]).mul(2))).mul(24);const u=n[1].mulE(i[2]).mulE(i[2]).mulE(i[3]),m=n[2].mulE(n[2]).mulE(n[3]).mulE(i[1]).subE(u).mul(156),l=n[3].mulE(i[1]).subE(n[1].mulE(i[3])),c=n[3].mulE(i[1]).subE(n[1].mulE(i[3])),g=n[1].mulE(n[3]).mulE(c).addE(i[1].mulE(i[3]).mulE(l)).mul(72),d=i[1].mulE(i[3]).subE(n[1].mulE(n[3])),_=n[2].mulE(i[2]).mulE(d).mul(120),p=n[1].mulE(n[2]).mulE(n[2]).mulE(i[3]),f=n[3].mulE(i[1]).mulE(i[2]).mulE(i[2]).subE(p).mul(36);r[2]=m.addE(g).addE(_).addE(f);const P=n[2].mulE(n[3]).mulE(n[3]).mulE(i[1]).subE(n[1].mulE(i[2]).mulE(i[3]).mulE(i[3])).mul(360),y=n[2].mulE(i[2]).mulE(n[2].mulE(n[3]).subE(i[2].mulE(i[3]))).addE(n[3].mulE(i[2]).mulE(i[2]).mulE(i[2])).subE(n[2].mulE(n[2]).mulE(n[2]).mulE(i[3])).mul(24),x=n[2].mulE(i[1]).mulE(i[3]).mulE(i[3]).subE(n[1].mulE(n[3]).mulE(n[3]).mulE(i[2])).mul(72),C=n[3].mulE(i[3]).mulE(i[1].mulE(i[2]).subE(n[1].mulE(n[2]))).mul(288);r[3]=P.addE(y).addE(x).addE(C),r[4]=i[3].mulE(i[3]).addE(n[3].mulE(n[3])).mulE(n[3].mulE(i[1]).subE(n[1].mulE(i[3]))).mul(270).addE(n[3].mulE(i[2]).subE(n[2].mulE(i[3]))).mulE(n[2].mulE(n[3]).addE(i[2].mulE(i[3]))).mul(180),r[5]=n[3].mulE(i[2]).subE(n[2].mulE(i[3])).mulE(n[3].mulE(n[3]).addE(i[3].mulE(i[3]))).mul(216);const v=ut(rt,5),b=pn(r,5,new U(0,1),!1,v,5);if(b>0){let n=Math.abs(t.getCurvature(0)),i=0;const r=Math.abs(t.getCurvature(1));(r>n||!Number.isFinite(r))&&(i=1);for(let e=0;e<b;e++){const s=Math.abs(t.getCurvature(v[e].value()));t.getCoord2D(v[e].value()),(s>n||!Number.isFinite(s))&&(n=s,i=v[e].value())}if((!Number.isFinite(n)||1/n<e)&&!lt(i,0,1)){const e=t.getCoord2D(i);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(i),1}}if(!t.isClosed()){const e=[0,0],n=Wo(t,e,!1);for(let t=0;t<n;t++)e[t]>0&&e[t]<1&&s.push(e[t]);return s.length}return 0}class Ko{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ur(this.b,e,!1):0}getError(t){return 0}}function $o(t,e,s,i,r,o,a){for(;;){const h=K.distance(e[0],e[3]),u=K.distance(e[0],e[1])+K.distance(e[1],e[2])+K.distance(e[2],e[3]);if(u-h<=i+s*u)return t+nt(h,u,.5);const m=t=>ho(e,1,t).length();{n(a<12);let h=m(0),l=m(1);r[0]+=2,h>l&&(l=Q(h,h=l),e[3]=Q(e[0],e[0]=e[3]),e[2]=Q(e[1],e[1]=e[2]));let c=h/(h+l),g=1,d=u;for(;c<1/32&&d>=32*(i+s*d);){g/=4;const t=m(g);r[0]++,c=h/(t+h);const s=new K;if(yo(e,.5*g,s),d=K.distance(s,e[0]),d<=i){const t=new K;yo(e,g,t),d+=K.distance(t,s)}}if(1!==g){const n=ut(K,4);fo(e,g,e,n),t=$o(t,n,s,i,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=ur(l,m,0,1),g=16;r[0]+=g;const d=ur(g,m,0,1);let _=Math.abs(c-d)>i+s*u;if(!_)return t+d;if(o<3){const n=ut(K,4);fo(e,.5,e,n),t=$o(t,n,s,i,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const f=ur(p,m,0,1);if(_=Math.abs(d-f)>i+s*u,!_)return t+f;const P=64;r[0]+=P;const y=ur(P,m,0,1);if(_=Math.abs(f-y)>i+s*u,!_)return t+y;const x=128;r[0]+=x;const C=ur(x,m,0,1);return _=Math.abs(y-C)>i+s*u,t+C}}function ta(t,e,s,n,i){if(s===e)return 0;const r=ut(K,4);t.queryControlPoints(r);const o=ut(K,4);Po(r,e,s,o);return $o(0,o,n,i,[0],0,0)}function ea(t,e,s,n,i){let r=!0;const o=Kn(5,e,s,n,i,e=>{const s=mo(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});r=!1;const a=Kn(5,e,s,n,i,e=>{const s=mo(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});return new K(o,a)}function sa(t,e,s,n,i,r,o,a,h){const u=ut(K,4);t.queryControlPoints(u);const m=ut(K,4);if(e.queryControlPoints(m),u[0].equals(m[0])){if(u[1].equals(m[1])&&u[2].equals(m[2])&&u[3].equals(m[3]))return s&&(s.length=0,s.push(u[0]),s.push(u[3])),n&&(n.length=0,n.push(0),n.push(1)),i&&(i.length=0,i.push(0),i.push(1)),!0;if(!u[0].equals(m[3]))return!1}return!!(u[0].equals(m[3])&&u[1].equals(m[2])&&u[2].equals(m[1])&&u[3].equals(m[0]))&&(n&&(n.length=0,n.push(0),n.push(1),h&&(n[1]=Q(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=Q(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[3]),h&&(s[1]=Q(s[0],s[0]=s[1]))),!0)}function na(t,e,s,i,r,o,a,h,u,m,l,c){n(m+2===c);let g=0,d=0,_=0,p=0,f=0,P=0,y=0;const x=(t,e)=>{const n=1-e,a=s.mul(ae(n)),h=i.mul(3*e*n*n),u=r.mul(3*e*e*n),m=o.mul(ae(e));return a.add(h).add(u).add(m).sub(l[t]).sqrLength()};for(let n=1,v=c-1;n<v;n++){let e=u[n-1];if(t){n>2?(e=gt(2*u[n-2]-u[n-3],0,1),u[n-1]=e):2===n&&(e=gt(2*u[n-2],0,1),u[n-1]=e);const t=(t,e,n)=>{let a=-1;for(let h=0;!(Math.abs(e-a)<1e-12)&&10!==h;h++){const h=e*e,u=1-e,m=u*u,c=m*u,g=s.x-2*i.x+r.x,d=s.x-3*i.x+3*r.x-o.x,_=s.y-2*i.y+r.y,p=s.y-3*i.y+3*r.y-o.y,f=s.x-i.x-2*g*e+d*h,P=-l[t].x+s.x*c+e*(3*i.x*m+e*(3*r.x*u+o.x*e)),y=s.y-i.y-2*_*e+p*h,x=-l[t].y+s.y*c+e*(3*i.y*m+e*(3*r.y*u+o.y*e)),C=-6*(f*P+y*x),v=6*(3*Bt(f)-(-2*g+2*d*e)*P)+6*(3*Bt(y)-(-2*_+2*p*e)*x);if(a=e,0===v)break;e=gt(e-C/v,n,1)}return a};{const e=x(n,u[n-1]);let s=t(n,u[n-1],0),i=x(n,s);if(1.01*e<i){const e=n>1?u[n-2]:0,r=t(n,.3*(u[n-1]-e)+e,0),o=x(n,r);o<i&&(i=o,s=r)}e>i&&(u[n-1]=s)}}const a=u[n-1],h=a*a,m=h*a,c=1-a,C=c*c,v=C*c;g+=3*h*C*C,d+=3*m*v,_+=3*h*h*C;const b=-(v*s.x+m*o.x-l[n].x);p+=b*a*C,f+=b*h*c;const S=-(v*s.y+m*o.y-l[n].y);P+=S*a*C,y+=S*h*c}if(e){const t=g*_-d*d;Math.abs(t)>=1e-12*(Math.abs(g*_)+Math.abs(d*d))+1e-10?(a||(i.x=(p*_-f*d)/t,i.y=(P*_-y*d)/t),h||(r.x=(g*f-d*p)/t,r.y=(g*y-d*P)/t)):(Ct(s,o,.3,i),Ct(s,o,.6,r))}let C=0;for(let n=1,v=c-1;n<v;n++)C+=x(n,u[n-1]);return C}var ia=b;class ra extends ds{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=ut(K,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||bt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=ut(K,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=ut(K,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),r("unrecognized constructor params"),this.m_cp=ut(K,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return $s(this)}construct(t,e,s,n){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=n.x,this.m_YEnd=n.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=ut(K,4);$i(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),wt(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),wt(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),He(this,t)}getGeometryType(){return e.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void n(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=Kr(this);if(null!==e){const s=new K;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s);return}const s=ut(rt,8),i=ut(K,4);this.queryControlPoints(i);const r=Zo(i,s),o=new K;for(let n=1;n<r-1;n++)this.queryCoord2D(s[n].value(),o),t.mergeNe(o)}applyTransformation(t){if(1===t.m_TransformationType){const e=ut(K,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void to(this)}n(0)}createInstance(){return new ra({vd:this.m_description})}calculateLength2D(){return Ur(this,1,!1)}calculateLowerLength2D(){return K.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return K.distance(this.getStartXY(),this.m_cp[0])+K.distance(this.m_cp[0],this.m_cp[1])+K.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){n(0)}queryCoord2DExtends(t,e,s){const n=ut(K,4);this.queryControlPoints(n),yo(n,t,e,s)}queryCoord2DE(t,e){Co(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new K;return this.queryCoord2DExtends(t,e,!0),e.x}const e=nt(this.getStartX(),this.m_cp[0].x,t),s=nt(this.m_cp[0].x,this.m_cp[1].x,t),n=nt(this.m_cp[1].x,this.getEndX(),t),i=nt(e,s,t),r=nt(s,n,t);return nt(i,r,t)}getCoordY(t){if(t<0||t>1){const e=new K;return this.queryCoord2DExtends(t,e,!0),e.y}const e=nt(this.getStartY(),this.m_cp[0].y,t),s=nt(this.m_cp[0].y,this.m_cp[1].y,t),n=nt(this.m_cp[1].y,this.getEndY(),t),i=nt(e,s,t),r=nt(s,n,t);return nt(i,r,t)}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,i),n)return;i.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),n=ia.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),n=ia.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){bo(this,t,e)}cutBezierIgnoreAttributes(e,s,n){(e<0||s>1||e>s)&&t("Cubic_bezier.cut_bezier_ignore_attributes");const i=ut(K,4);this.queryControlPoints(i);const r=ut(K,4);Po(i,e,s,r),n.setControlPoints(r)}splitBezierIgnoreAttributes(e,s,n){this===s&&this===n&&t("Cubic_bezier.split_bezier_ignore_attributes");const i=ut(K,4);this.queryControlPoints(i);const r=ut(K,4),o=ut(K,4);fo(i,e,r,o),s&&s.setControlPoints(r),n&&n.setControlPoints(o)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const n=this.getStartAttributeAsDbl(e,s),i=this.getEndAttributeAsDbl(e,s),r=this.calculateLength2D(),o=r>0?this.tToLength(t)/r:0,a=ia.getInterpolation(e);return vt(a,n,i,o,ia.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return zo(this,t,U.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const n=[Number.NaN];return 0===zo(this,t,e,!1,s,1,n)?Number.NaN:n[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(e,s){e.length<2&&t("");const i=Jr(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;n(e.length>=i.specialPointsCount()-1);for(let t=1,n=i.specialPointsCount();t<n;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[r],s),r++;for(let t=0;t<r;++t){co(e[t].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=ut(K,4);return this.queryControlPoints(i),Ho(i,t,e,s,n)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0],i=this.intersectionWithAxis2D(!0,t,s,null);return n(2!==i),-1===i?e:s[0]}isCurve(){return!0}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());n(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=le.constructEmpty();this.queryEnvelope(t);const s=U.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=ut(K,4);this.queryControlPoints(s),Po(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),n=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),i=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):n&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):i&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ur(this,t,!0)}lengthToT(t){return Or(this,t)}calculateWeightedAreaCentroid2D(t){const e=ut(K,4);kr(this,e);const s=e[3],n=e[2],i=e[1],r=new K;r.x=(5*s.x*s.x*(7*n.y+16*i.y)+s.x*(-35*s.y*n.x+40*n.x*n.y-80*s.y*i.x+140*n.x*i.y+112*i.x*i.y)-2*(s.y*(20*n.x*n.x+70*n.x*i.x+56*i.x*i.x)-7*(4*n.x+5*i.x)*(-n.y*i.x+n.x*i.y)))/840,r.y=(-5*s.y*s.y*(7*n.x+16*i.x)+s.y*(5*s.x*(7*n.y+16*i.y)-4*(10*n.x*n.y+35*n.y*i.x+28*i.x*i.y))+2*(-7*(4*n.y+5*i.y)*(n.y*i.x-n.x*i.y)+s.x*(20*n.y*n.y+70*n.y*i.y+56*i.y*i.y)))/840;const o=lo(this);return r.x+=(e[0].x-t.x)*o,r.y+=(e[0].y-t.y)*o,r}calculateWeightedCentroid2D(){const t=new K;return this.isDegenerate(0)?(t.setCoords(0,0),t):Br(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Qr(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}queryControlPointsHelper(t){return this.queryControlPoints(t),4}setControlPoints(e){for(let s=0;s<4;s++)e[s].isNAN()&&t("NAN control points in bezier are not supported");this.m_XStart=e[0].x,this.m_YStart=e[0].y,this.m_cp[0].setCoordsPoint2D(e[1]),this.m_cp[1].setCoordsPoint2D(e[2]),this.m_XEnd=e[3].x,this.m_YEnd=e[3].y,this.afterCompletedModification()}getTangent(t){const e=ut(K,4);return this.queryControlPoints(e),vo(e,t)}getDerivative(t){const e=ut(K,4);return this.queryControlPoints(e),ho(e,1,t)}getCurvature(t){const e=mo(this,1,t),s=mo(this,2,t),n=e.sqrLength();if(0===n)return Number.NaN;e.divThis(Math.sqrt(n));return e.crossProduct(s)/n}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const n=new le;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new K;this.queryCoord2D(i,r);return K.distance(r,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}isMonotoneQuickAndDirty(){const t=ut(K,4);return this.queryControlPoints(t),_o(t)}getMonotonicPartParams(e,s){const i=Jr(this),r=i.specialPointsCount();if(n(ts.s_maxMonotonicPartParams>=r),!s)return i.specialPointsCount();e<r&&t("");for(let t=0;t<r;t++)s[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=Q(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new rt;return ro(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=ut(K,4);this.queryControlPoints(e);const s=e[3].sub(e[0]),n=s.length();if(K.distance(e[0],e[1])+K.distance(e[2],e[1])+K.distance(e[2],e[3])-n>t)return!1;const i=t;let r=e[1].clone();r.subThis(e[0]);let o=Math.abs(r.crossProduct(s))/n;return!(o>i)&&(r=e[2].clone(),r.subThis(e[1]),o=Math.abs(r.crossProduct(s))/n,!(o>i))}copyIgnoreAttributes(t){const e=ut(K,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return lo(this)}absNorm(){return Bo(this)}queryEnvelopeW(t,e){Fo(this,t,e)}setSegmentFromCoordsForStitcher(t,e){Go(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=ut(K,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=ut(K,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if(K.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);K.sqrDistance(s,n)<=t&&(i||=!s.equals(n),s.setCoordsPoint2D(n))}return i},n=s(e[1],e[2],e[0]),i=s(e[2],e[1],e[3]);return(n||i)&&this.setControlPoints(e),n||i}needsSnapControlPoints(t){if(!t)return!1;const e=ut(K,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if(K.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);K.sqrDistance(s,n)<=t&&(i||=!s.equals(n),s.setCoordsPoint2D(n))}return i},n=s(e[1],e[2],e[0]),i=s(e[2],e[1],e[3]);return n||i}calculateSpecialPointsForCracking(t,e){return Jo(this,t,e)}ensureXYMonotone(){return co(this)}setCoordsForIntersector(t,e,s){so(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),$r(e,Kr(this))}reverseImpl(){this.m_cp[1]=Q(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t,s=0,n=1;return!!this.m_cp[0].equals(e.m_cp[s])&&!!this.m_cp[1].equals(e.m_cp[n])}equalsImplTol(t,e){const s=t,n=0,i=1;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[n],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[i],e)}swapImpl(t){const e=t;e.m_cp[0]=Q(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=Q(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),eo(this,e)}afterCompletedModification(){to(this)}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return qo(this,t,e,s)}endPointModified(){to(this)}clearEndPointModified(){}}ra.type=e.enumBezier;class oa{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function aa(t,e,s,i,r,o,a,h){for(;;){const u=K.distance(e[0],e[2]),m=K.distance(e[0],e[1])+K.distance(e[1],e[2]);if(m-u<=r+i*m)return t+nt(u,m,.5);const l=ut(K,4),c=t=>{Pa(e,s,1,t,l);return l[1].length()};if(0===a&&h<8){n(h<8);let u=c(0),l=c(1);o[0]+=2,u>l&&(l=Q(u,u=l),e[2]=Q(e[0],e[0]=e[2]),s[2]=Q(s[0],s[0]=s[2]));let g=u/(u+l),d=1,_=m;for(;g<1/32&&_>=r+i*_;){d/=4;const t=c(d);o[0]++,g=u/(t+u);const n=new K;if(ph(e,s,.5*d,n),_=K.distance(n,e[0]),_<=r){const t=new K;ph(e,s,d,t),_+=K.distance(t,n)}}if(1!==d){const n=ut(K,3),u=[0,0,0];Qa(e,s,d,e,s,n,u),t=aa(t,n,u,i,r,o,0,h+1),a++,h++;continue}}let g=!1;const d=8;o[0]+=d;const _=ur(d,c,0,1),p=16;o[0]+=p;const f=ur(p,c,0,1);if(g=Math.abs(_-f)>r+i*m,!g)return t+f;if(a<8&&h<9){const n=ut(K,3),u=[0,0,0];Qa(e,s,.5,e,s,n,u),t=aa(t,n,u,i,r,o,a+1,h+1),a++,h++;continue}const P=32;o[0]+=P;const y=ur(P,c,0,1);if(g=Math.abs(f-y)>r+i*m,!g)return t+y;const x=64;o[0]+=x;const C=ur(x,c,0,1);if(g=Math.abs(y-C)>r+i*m,!g)return t+C;const v=128;o[0]+=v;const b=ur(v,c,0,1);return g=Math.abs(C-b)>r+i*m,t+b}}function ha(t,e,s,n,i){if(s===e)return 0;const r=ut(K,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=ut(K,3);Ja(r,o,e,s,h,a);return aa(0,h,a,n,i,[0],0,0)}class ua{constructor(t,e,s){this.controlPoints=mt(t,3),this.weights=[0,0,0],st(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new K;ph(this.controlPoints,this.weights,e,t);const s=ut(K,4);Pa(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new K;ph(this.controlPoints,this.weights,e,t);const s=ut(K,4);Pa(this.controlPoints,this.weights,2,e,s);return 2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new K;ph(this.controlPoints,this.weights,e,t);const s=ut(K,4);Pa(this.controlPoints,this.weights,3,e,s);return 2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return n(0),0}}function ma(t,e,s,n){const i=ka(0,0,0,0,K.getNAN()),r=et(18,Number.NaN),o=ut(K,3);t.queryControlPoints(o),o[2].subThis(e),o[1].subThis(e),o[0].subThis(e);const a=[0,0,0];t.queryWeights(a);const h=[1,Ph(a),1],u=xh(a,s),m=xh(a,n),l=en(new ua(o,h,new K(0,0)),U.construct(u,m),18,r);ph(o,h,u,i.pt),i.t=u,i.d=K.distance(i.pt,new K(0,0));const c=new K;ph(o,h,m,c);const g=K.distance(c,new K(0,0));g<i.d&&(i.d=g,i.t=m,i.pt.assign(c));for(let d=0;d<l;d++){ph(o,h,r[d],c);const t=K.distance(c,new K(0,0));t<i.d&&(i.d=t,i.t=yh(a,r[d]),i.pt.assign(c))}return i}function la(t,e,s,n,i){let r=!0;const o=ut(K,4),a=Kn(5,e,s,n,i,e=>{fa(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()});r=!1;const h=Kn(5,e,s,n,i,e=>{fa(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()});return new K(a,h)}function ca(t){t.m_cachedValues=null}function ga(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function da(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new oa,s=ut(K,3);t.queryControlPoints(s);const n=[0,0,0];return t.queryWeights(n),_a(s,n,e.specialPoints),Ra(t,e),e}function _a(t,e,s){if(0===e[1])return s.length=0,s.push(0),void s.push(1);const n=ut(rt,8);n[0].set(0);let i=1;{const s=new rt(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new rt(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new rt(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=ut(rt,2);let h=dn(o,r,s,new U(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)lt(a[t].value(),0,1)||(n[i]=a[t],i++)}{const s=new rt(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new rt(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new rt(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=ut(rt,2);let h=dn(o,r,s,new U(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)lt(a[t].value(),0,1)||(n[i]=a[t],i++)}if(n[i].set(1),i++,i>2){ft(n,0,i,(t,e)=>kt(t.value(),e.value()));let t=0,e=n[0].value(),s=1;for(let r=1;r<i;r++)n[r].eq(n[r-1])?(e+=n[r].value(),s++):(s>1&&(e/=s,n[t].set(e)),t++,n[t]=n[r],e=n[r].value(),s=1);t++,i=t}n[0].set(0),n[i-1].set(1),s.length=i;for(let r=0;r<i;r++)s[r]=n[r].value()}function pa(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+pa(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=da(t);if(n&&!Number.isNaN(i.length))return i.length;const r=qa(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let u=1,m=i.specialPointsCount();u<m;u++){const s=i.specialPoints[u];if(a+=ha(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function fa(t,e,s,n){const i=ut(K,3);t.queryControlPoints(i);const r=[0,0,0];t.queryWeights(r),Pa(i,r,e,s,n)}function Pa(t,e,s,n,i){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=ut(K,4);ya(r,o,s,n,a);for(let h=0;h<=s;h++)i[h].setCoords(a[h].x,a[h].y)}function ya(t,e,s,i,o){n(s>0);const a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThis(a[0]);a[0].setCoords(0,0)}const h=xa(a,e,0,i),u=va(e,0,i),m=h.divide(u);if(o[0].assign(m),0===s)return;const l=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],c=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],g=u*u,d=xa(c,l,0,i).mul(2).divide(g);if(o[1].assign(d),1===s)return;const _=va(e,1,i),p=2*u*_,f=xa(c,l,1,i).mul(2).sub(d.mul(p)).divide(g);if(o[2].assign(f),2===s)return;const P=xa(c,l,2,i).mul(2),y=2*(_*_+u*va(e,2,i)),x=P.sub(f.mul(p).mul(2)).sub(d.mul(y)).divide(g);o[3].assign(x),3!==s&&r("")}function xa(t,e,s,n){if(0===s){if(n<=.5){const s=new K;qt(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new K;qt(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new K;return qt(2,s,i,n,r),r}{const s=new K;Ft(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new K;Ft(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new K;return Ft(2,s,i,n,r),r}}if(1===s){const s=t[1].mul(e[1]),i=s.sub(t[0].mul(e[0])).mul(1-n).add(t[2].mul(e[2]).sub(s).mul(n));return i.mulThis(2),i}if(2===s){const s=t[1].mul(e[1]),n=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return n.mulThis(2),n}r("")}function Ca(t,e,s,n){if(n.toDouble()<=.5){const s=new be;Vt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new be;Vt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new be;return Vt(2,s,i,n,r),r}{const s=new be;Lt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new be;Lt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new be;return Lt(2,s,i,n,r),r}}function va(t,e,s){if(0===e){const e=nt(t[0],t[1],s),n=nt(t[1],t[2],s);return nt(e,n,s)}if(1===e){return 2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s)}if(2===e){return 2*(t[2]-t[1]-(t[1]-t[0]))}r("")}function ba(t,e,s){if(s.toDouble()<=.5){const e=Ot(t[0],t[1],s),n=Ot(t[1],t[2],s);return Ot(e,n,s)}{const e=Qt(t[0],t[1],s),n=Qt(t[1],t[2],s);return Qt(e,n,s)}}function Sa(t,e,s,n,i){const r=[be.constructPoint2D(t[0]),be.constructPoint2D(t[1]),be.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);Ea(r,[new rt(e[0]),new rt(e[1]),new rt(e[2])],s,n,i)}function Ea(t,e,s,i,r){n(s>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThisE(o[0]);o[0]=be.constructCoords(0,0)}const a=Ca(o,e,0,i),h=ba(e,0,i),u=a.divE(h);r[0].setE(u);const m=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],l=Ca([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],m,0,i).mul(2),c=h.sqr(),g=l.divE(c);r[1].setE(g)}function Da(t,e,s){const n=ut(K,3);t.queryControlPoints(n);const i=et(3,Number.NaN);t.queryWeights(i),wa(n,i,e,s)}function wa(t,e,s,n){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const i=ut(be,4);Sa(t,e,1,s,i),n.setE(i[1])}function Aa(t,e,s){const n=gt(s,0,1),i=ut(K,4);if(Pa(t,e,3,n,i),i[1].isZero()){if(i[2].isZero())return i[3];{const t=i[2].clone();return 1===n&&t.negateThis(),t}}return i[1]}class Ta{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-pa(this.b,e,!1):0}getError(t){return n(0),0}}function Ia(t,e,s){const n=pa(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==en(new Ta(t,e),U.unit(),1,i)&&r(""),i[0]}function Ma(t){const e=ut(K,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Ya(e,s)}function Ya(t,e){const s=Ph(e);if(1===s){return Pi(t)}if(0===s)return 0;const i=[new K(0,0),t[1].sub(t[0]),t[2].sub(t[0])],r=i[1].crossProduct(i[2]);if(s<1){n(s>0);const t=1-s;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const n=t*(1+s),i=Math.atan2(Math.sqrt(t),Math.sqrt(1+s));e=s*(.5*s-ue(n)*i)/n}return r*e}{const t=(s-1)*(s+1);return.25*s/Math.pow(t,1.5)*(-2*s*Math.sqrt(t)*r-4*i[1].y*i[2].x*Math.atanh(Math.sqrt((s-1)/(s+1)))-i[1].x*i[2].y*Math.log(2*s*(s-Math.sqrt(t))-1))}}function Na(t,e){const s=Ph(e);if(1===s){const e=ut(K,3);Bi(t,e);const s=e[2].clone(),n=e[1].clone(),i=new K,r=s.y*n.x-s.x*n.y;return i.x=-(4*s.x+5*n.x)*r/60,i.y=-(4*s.y+5*n.y)*r/60,i}if(0===s)return new K(0,0);n(s>0);const i=t[1].sub(t[0]),r=t[2].sub(t[0]);if(s<1){const t=Math.sqrt(1-s),e=Math.sqrt(1+s),n=(i.y*r.x-i.x*r.y)*s/Math.pow(t*e,5)/12,o=Math.atan2(t,e),a=s*t*e,h=s*s,u=i.mul(2*(2+h)),m=r.mul(2*h-5),l=u.add(m).mul(a),c=r.sub(i.mul(2*h)).mul(6*o);return l.add(c).mul(n)}{const t=Math.sqrt(s-1),e=Math.sqrt(s+1),n=(i.y*r.x-i.x*r.y)*s/Math.pow(t*e,5)/12,o=Math.atanh(t/e),a=s*t*e,h=s*s,u=i.mul(4).sub(r.mul(5)),m=i.add(r).mul(2*h),l=u.add(m).mul(a),c=r.sub(i.mul(2*h)).mul(6*o);return l.add(c).mul(n)}}function Xa(t){const e=ut(K,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Na(e,s)}function qa(t){return Fa(t.calculateUpperLength2D())}function Fa(t){return 256*ct()*t}function Va(t){if(0===t.m_weights[1])return!0;const e=K.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function La(t){return t.m_cachedValues}function Ra(t,e){t.m_cachedValues=e}function za(t,e,s,n,i){const r=ut(K,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===Ba(r,o,e,U.unit(),n,i,1,a)?a[0]:Number.NaN}function Ba(t,e,s,i,r,o,a,h){_(U.unit().contains(i)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const u=new Array(3);for(let n=0;n<3;++n)u[n]=t[n].sub(s);const m=Ph(e),l=Ee.constructPoint2D(u[0]),c=Ee.constructPoint2D(u[1]),g=Ee.constructPoint2D(u[2]),d=tt.constructDouble(m),p=d.clone();p.ldexpThis(1);const f=l.dotProduct(c.sub(l)).mul(d),P=d.mul(d.addDouble(2)),y=g.sub(c.mul(P.ldexp(1))),x=c.sqrLength().mul(d.mul(d).ldexp(1)).add(l.sqrLength().mul(d.ldexp(2).subDouble(1))).add(l.dotProduct(y)),C=g.sub(c.mul(p)).add(l.mul(p.subDouble(1))),v=c.mul(d).sub(l).dotProduct(C).mulDouble(3),b=c.dotProduct(g).mul(d.subDouble(3).mul(d)).ldexp(1),S=c.sqrLength().mul(d.mul(d).ldexp(2)),E=l.sqrLength().mul(d.ldexp(2).subDouble(3)),D=l.dotProduct(g.sub(c.mul(d.mulDouble(3).subDouble(1)).mul(d))).ldexp(1),w=g.sqrLength().addThis(b).addThis(S).addThis(E).addThis(D),A=l.add(g).sub(c.mul(p)),T=d.subDouble(1),I=g.sub(l).dotProduct(A).mul(T),M=new K(0,0),Y=[];let N=new K;ph(u,e,i.vmin,N);let X=K.distance(N,M);if(X<=o&&Y.push(new K(i.vmin,X)),i.vmin!==i.vmax&&(ph(u,e,i.vmax,N),X=K.distance(N,M),X<=o&&Y.push(new K(i.vmax,X))),i.width()>0){const t=u[2].isZero(),s=ut(tt,4),n=zn(I,w,v,x,f,58,i,t,s);for(let r=0;r<n;r++){if(!i.containsExclusiveCoordinate(s[r].toDouble()))continue;let t=s[r].toDouble();t=yh(e,t);const n=new K;ph(u,e,t,n),X=K.distance(n,M),X<=o&&Y.push(new K(t,X))}}if(r){n(i.equals(U.unit()));{ph(u,e,-1,N,!0);const t=new K;ph(u,e,0,t);const s=new fm({start:N,end:t}),n=s.getClosestCoordinate(M,!0);n<1&&(N=s.getCoord2D(n),X=K.distance(N,M),X<=o&&Y.push(new K(n-1,X)))}{ph(u,e,2,N,!0);const t=new K;ph(u,e,i.vmax,t);const s=new fm({start:t,end:N}),n=s.getClosestCoordinate(M,!0);n>0&&(N=s.getCoord2D(n),X=K.distance(N,M),X<=o&&Y.push(new K(1+n,X)))}}if(!Y.length)return 0;Y.sort((t,e)=>t.compare(e));let q=0;const F=Y[0].x;if(h[q++]=F,q<a){const t=H(u,4,!1).total(),e=Y[0].y;for(let s=1,n=Y.length;s<n;s++)if(Y[s].y>e+t){Y.length=s;break}Y.sort((t,e)=>kt(t.x,e.x)),q=0,h[q++]=Y[0].x;for(let s=1,n=Y.length;s<n;s++)Y[s].x!==h[q-1]&&q<a&&(h[q++]=Y[s].x)}return q}function ka(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function Ga(t,e,s,i,r){const o=new fe;if(Wa(t,U.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=da(t);let h=0;const u=[];let m=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const s=a.specialPoints[l],i=ma(t,e,m,s);if(0===u.length)u.push(i);else if(i.t===i.tmin)n(u.at(-1).d<=i.d),u.at(-1).tmax=i.tmax;else if(u.at(-1).t===u.at(-1).tmax){n(u.at(-1).d>=i.d);const t=u.at(-1).tmin;u[u.length-1]=i,u.at(-1).tmin=t}else u.push(i);m=s}for(const n of u)if(n.d<=i){const t=n.t;s?(s[h]=t,h++):h++}return h}function Wa(t,e,s){const n=ut(K,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i),ja(n,i,e,s)}function ja(t,e,s,n){if(s.equalsRange(0,1))return void n.setFromPoints(t,3);const i=ut(K,3),r=[0,0,0];Ja(t,e,s.vmin,s.vmax,i,r),n.setFromPoints(i,3)}function Za(t){const e=$(t[0].y,t[1].y),s=$(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=$(t[0].x,t[1].x),s=$(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function Ha(t){const e=ut(K,3);t.queryControlPoints(e);const s=Ua(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ua(t){let e=!1;for(let s=0;s<2;s++){const n=$(t[0][s],t[2][s]);n>0?($(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),$(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?($(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),$(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Oa(e,s,n){void 0===n&&(n=s,s=0);const i=new K;if(s<0||n>1)return i.setNAN(),i;if(s>n&&t("calculate_sub_weighted_centroid"),s===n||e.isDegenerate(0))return i.setCoords(0,0),i;const r=da(e),o=qa(e),a=o/e.calculateUpperLength2D();let h=s,u=0;for(let t=1,m=r.specialPointsCount();t<m;t++)if(s<r.specialPoints[t]){u=t-1;break}i.setCoords(0,0);for(let t=u+1,m=r.specialPointsCount();t<m;t++){const s=Math.min(r.specialPoints[t],n),u=la(e,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[t])break}return i.add(e.getStartXY().mul(e.calculateLength2D()))}function Qa(t,e,s,i,r,o,a){n(s>=0&&s<=1&&i!==o&&r!==a),n(e[0]>0&&e[2]>0&&e[1]>=0);const h=[1,Ph(e),1],u=xh(e,s),m=mt(t,3),l=ut(E,3);mh(m,h,l);const c=ut(E,3),g=ut(E,3);Ch(l,u,i?c:null,o?g:null),vh(e,s,r,a);const d=Za(m);if(i){for(let t=0;t<3;++t)_h(c[t],i[t]);Sh(m,i),d&&Ua(i)}if(o){for(let t=0;t<3;++t)_h(g[t],o[t]);Sh(m,o),d&&Ua(o)}}function Ja(t,e,s,i,r,o){if(n(s>=0&&i<=1&&s<=i),s===i){const n=new K,i=lh(t,e,s,n);return bh(t,n),r[0].assign(n),r[1].assign(n),r[2].assign(n),o[0]=i,o[1]=i,void(o[2]=i)}if(0===s&&1===i)return r[0].assign(t[0]),r[1].assign(t[1]),r[2].assign(t[2]),o[0]=e[0],o[1]=e[1],void(o[2]=e[2]);const a=ut(E,3);{const n=[1,Ph(e),1],r=xh(e,s),o=xh(e,i);mh(t,n,a),Ch(a,o,a,null);Ch(a,r>=o?1:r/o,null,a)}const h=[0,0,0];vh(e,i,h,null),vh(h,s/i,null,h);const u=Za(t),m=ut(K,3);_h(a[1],m[1]),ph(t,e,s,m[0]),ph(t,e,i,m[2]),Sh(t,m);for(let n=0;n<3;++n)r[n].assign(m[n]),o[n]=h[n];u&&Ua(r)}function Ka(t,e,s){const n=Ph(e),i=[1,n,1],r=4*n/(3*(1+n));s[0].assign(t[0]),s[3].assign(t[2]),Ct(t[0],t[1],r,s[1]),Ct(t[2],t[1],r,s[2]),new ra({cp:s}),new Dn({points:t,weight:n});let o=0,a=.1,h=0;for(let u=0;u<9;u++,a+=.1){const e=new K;ph(t,i,a,e);const n=new K;yo(s,a,n);const r=K.sqrDistance(e,n);r>o&&(o=r,h=a)}{const e=new K;ph(t,i,h,e);const n=[0];Ro(s,e,U.unit(),!1,-1,1,n);const r=new K;return yo(s,n[0],r),o=K.sqrDistance(e,r),Math.sqrt(o)}}function $a(t,e,s,n){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const i=!!n&&t.isMonotoneQuickAndDirty(),r=new ce,o=ut(K,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new K;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=ut(K,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Ct(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&Ha(t)}function th(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==ih(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function eh(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==rh(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function sh(t,e,s,n,i){if(i){const n=hm(e,s);if(0!==n){if(t){if(1===n){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(Te(e,s))return 1;return 0!==oh(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function nh(t,e,s,n,i){if(i){if(0!==hm(e,s))return t?4:2}else if(Te(e,s))return 1;return 0!==ah(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function ih(t,e,s,i,r,o,a,h,u,m){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0],n=e.intersectPoint(s.getStartXY(),t,a);if(n>0){if(null!==r)for(let e=0;e<n;e++)r.push(t[e]);if(null!=o)for(let t=0;t<n;t++)o.push(0);if(null!=i)for(let s=0;s<n;s++){const n=new K;e.queryCoord2D(t[s],n),i.push(n)}}return n}const l=Qe(e,s);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new fm({start:e.getStartXY(),end:e.getEndXY()}),n=ws(t,s,i,r,o,a,h,m);if(r)for(let s=0;s<n;++s){const n=t.getCoord2D(r[s]);r[s]=e.getClosestCoordinate(n,!1)}return n}if(Je(e,s,a))return 0;const c=ut(K,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[1,Ph(g),1],_=s.getEndXY().sub(s.getStartXY()),p=_.clone();p.leftPerpendicularThis();const f=c[0].clone(),P=c[1].clone(),y=c[2].clone(),x=P.sub(f),C=y.sub(f),v=y.sub(P),b=d[0],S=d[1],E=d[2],D=b*S,w=b*E,A=S*E,T=x.dotProduct(p)*D,I=C.dotProduct(p)*w;let M=T,Y=I-2*T,N=v.dotProduct(p)*A+I-I;const X=et(13,Number.NaN),q=et(13,Number.NaN);let F=nn(N,Y,M,U.unit(),!1,X);F<0&&(X[0]=0,X[1]=1,F=2);let V=0;for(let n=0,k=V;n<F;++n){const t=new K;ph(c,d,X[n+k],t),q[V]=s.getClosestCoordinate(t,!1);K.distance(t,s.getCoord2D(q[V]))<=a&&(X[V]=X[n+k],V++)}const L=ut(K,3),R=ut(K,3);if(e.queryControlPoints(R),R[0].subThis(s.getStartXY()),R[1].subThis(s.getStartXY()),R[2].subThis(s.getStartXY()),hh(R,d,L,!1),Math.abs(_.x)>=Math.abs(_.y)){const t=_.y/_.x;N=L[2].y-L[2].x*t,Y=L[1].y-L[1].x*t,M=L[0].y-L[0].x*t}else{const t=_.x/_.y;N=L[2].x-L[2].y*t,Y=L[1].x-L[1].y*t,M=L[0].x-L[0].y*t}const z=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),B=[0,0];F=nn(N,Y,M,U.unit(),z,B);for(let n=0,k=V;n<F;++n){X[n+k]=B[n];const t=new K;ph(c,d,X[n+k],t),q[V]=s.getClosestCoordinate(t,!1);K.distance(t,s.getCoord2D(q[V]))<=a&&(X[V]=X[n+k],V++)}n(V<X.length+4);for(let n=0;n<V;n++)X[n]=yh(g,X[n]);F=e.intersectPoint(s.getStartXY(),B,a);for(let n=0;n<F;n++)X[V]=B[n],q[V++]=0;F=e.intersectPoint(s.getEndXY(),B,a);for(let n=0;n<F;n++)X[V]=B[n],q[V++]=1;F=s.intersectPoint(e.getStartXY(),B,a);for(let n=0;n<F;n++)q[V]=B[n],X[V++]=0;F=s.intersectPoint(e.getEndXY(),B,a);for(let n=0;n<F;n++)q[V]=B[n],X[V++]=1;return 0===V?0:gm(t,e,s,X,q,V,i,r,o,a,h,u,m)}function rh(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return ih(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Je(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=ut(K,4);{e.queryControlPoints(g);const t=ut(K,4),n=new ce;s.canonicToWorldTransformation(n);const i=new ce;i.setInvert(n),i.transformPoints2D(g,4,t);const r=ut(tt,3),h=ut(tt,3),u=ut(tt,3),m=[0,0,0];e.queryWeights(m),uh(t,m,r,h,u);const d=ut(tt,3);d[0].setDouble(s.getSemiMinorAxis()),d[0].sqrThis(),d[1].setDouble(s.getSemiMajorAxis()),d[1].sqrThis(),d[2].setThis(d[0]),d[2].mulThis(d[1]),d[2].negateThis();const _=Fn(r,2,h,2,u,2,d,!0,U.unit(),U.unit(),l,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new K;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new K;s.queryCoord2D(r,a);K.distance(i,a)<=o&&(l[t]=l[n],c.push(r),t++)}l.length=t}}const d=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),n=za(e,t,U.unit(),!1,-1),i=new K;e.queryCoord2D(n,i);K.distance(t,i)<=o&&(l.push(n),c.push(d[_]))}for(let _=0;_<2;_++){const t=[0,3];{const e=s.getClosestCoordinate(g[t[_]],!1),n=new K;s.queryCoord2D(e,n);K.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return gm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function oh(t,e,s,i,r,o,a,h,u,m){const l=ut(K,3);e.queryControlPoints(l);const c=ut(K,3);if(s.queryControlPoints(c),Ke(l,c,3)<0)return oh(t,s,e,i,o,r,a,h,u,!m);const g=Qe(e,s);if(e.isDegenerateToLineHelper(g)){const n=new fm({start:e.getStartXY(),end:e.getEndXY()}),l=ih(t,s,n,i,o,r,a,h,u,!m);if(r)for(let t=0;t<l;++t){const s=n.getCoord2D(r[t]);r[t]=e.getClosestCoordinate(s,!1)}return l}if(s.isDegenerateToLineHelper(g)){const n=new fm({start:s.getStartXY(),end:s.getEndXY()}),l=ih(t,e,n,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=n.getCoord2D(o[t]);o[t]=s.getClosestCoordinate(e,!1)}return l}if(Je(e,s,a=Math.max(a,g)))return 0;const d=et(3,Number.NaN);e.queryWeights(d);const _=et(3,Number.NaN);s.queryWeights(_);const p=[1,Ph(d),1],f=[1,Ph(_),1],P=new U(0,1),y=new U(0,1);{const t=fe.constructEmpty();ja(l,p,new U(0,1),t);const e=fe.constructEmpty();ja(c,f,new U(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(fh(l,p,t,P),fh(c,f,t,y),P.isEmpty()||y.isEmpty())return 0;Ja(l,p,P.vmin,P.vmax,l,p),Ja(c,f,y.vmin,y.vmax,c,f)}}const x=_m(l,2,c,2,a);if(0===x)return 0;const C=[],v=[];if(-1===x){const t=ut(tt,3),e=ut(tt,3),s=ut(tt,3);uh(l,p,t,e,s);const n=ut(tt,3),i=ut(tt,3),r=ut(tt,3);uh(c,f,n,i,r);const o=[],g=[],d=Nn(t,2,e,2,s,2,n,2,i,2,r,2,!0,U.unit(),U.unit(),o,g,h,u,m);if(d>0)for(let h=0;h<d;h++){const t=new K;ph(c,f,g[h],t);const e=new K;ph(l,p,o[h],e);K.distance(e,t)<=a&&(C.push(o[h]),v.push(g[h]))}}for(let b=0;b<2;b++){let t,e,s;0===b?(t=l,e=c,s=f):(t=c,e=l,s=p);for(let i=0;i<2;i++){const r=0===i?0:t.length-1,o=new K,h=[0],u=Ba(e,s,t[r],U.unit(),!1,-1,1,h);n(1===u),ph(e,s,h[0],o),K.distance(t[r],o)<=a&&(0===b?(C.push(0===r?0:1),v.push(h[0])):(v.push(0===r?0:1),C.push(h[0])))}}if(0===C.length)return 0;if(!P.equalsRange(0,1))for(let n=0;n<C.length;++n)C[n]=Dn.recalculateParentT(P.vmin,P.vmax,C[n]);if(!y.equalsRange(0,1))for(let n=0;n<v.length;++n)v[n]=Dn.recalculateParentT(y.vmin,y.vmax,v[n]);for(let n=0;n<C.length;++n)C[n]=yh(d,C[n]);for(let n=0;n<v.length;++n)v[n]=yh(_,v[n]);return gm(t,e,s,C,v,C.length,i,r,o,a,h,u,m)}function ah(t,e,s,n,i,r,o,a,h,u){if(e.isLine()){return Li(t,s,new fm({start:e.getStartXY(),end:e.getEndXY()}),n,r,i,o,a,h,!u)}if(s.isLine()){return ih(t,e,new fm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=Qe(e,s);if(Je(e,s,o=Math.max(o,m)))return 0;const l=ut(K,3);e.queryControlPoints(l);const c=ut(K,3);s.queryControlPoints(c);const g=_m(l,2,c,2,o);if(0===g)return 0;const d=[],_=[];if(-1===g){const t=ut(tt,3),n=ut(tt,3),i=ut(tt,3),r=[0,0,0];e.queryWeights(r),uh(l,r,t,n,i);const m=ut(Ee,3);ji(c,m);const g=Nn(t,2,n,2,i,2,[m[0].x,m[1].x,m[2].x],2,[m[0].y,m[1].y,m[2].y],2,null,0,!0,U.unit(),U.unit(),d,_,a,h,u);if(g>0){let t=0;for(let n=0;n<g;n++){const i=new K;s.queryCoord2D(_[n],i);const r=new K;e.queryCoord2D(d[n],r),K.distance(r,i)<=o&&(d[t]=d[n],_[t]=_[n],t++)}d.length=t,_.length=t}}for(let p=0;p<2;p++){let t;t=0===p?l:c;for(let n=0;n<2;n++){const i=0===n?0:t.length-1;let r;const a=new K;0===p?(r=vi(s,t[i],U.unit(),!1),s.queryCoord2D(r,a)):(r=za(e,t[i],U.unit(),!1,-1),e.queryCoord2D(r,a)),K.distance(t[i],a)<=o&&(0===p?(d.push(0===i?0:1),_.push(r)):(_.push(0===i?0:1),d.push(r)))}}return gm(t,e,s,d,_,d.length,n,i,r,o,a,h,u)}function hh(t,e,s,n=!1){const i=ut(K,3);n?(i[0].setCoordsPoint2D(t[0]),i[1].setCoordsPoint2D(t[1]),i[1].subThis(i[0]),i[2].setCoordsPoint2D(t[2]),i[2].subThis(i[0]),i[0].setCoords(0,0)):(i[0].setCoordsPoint2D(t[0]),i[1].setCoordsPoint2D(t[1]),i[2].setCoordsPoint2D(t[2])),i[0].mulThis(e[0]),i[1].mulThis(e[1]),i[2].mulThis(e[2]),s[1].setCoords(i[1].x-i[0].x,i[1].y-i[0].y),s[2].setCoordsPoint2D(i[2].sub(i[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(i[0])}function uh(t,e,s,n,i){const r=tt.constructDouble(e[0]),o=tt.constructDouble(e[1]),a=tt.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(r),s[1].setDouble(t[1].x),s[1].mulThis(o),s[2].setDouble(t[2].x),s[2].mulThis(a),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),n[0].setDouble(t[0].y),n[0].mulThis(r),n[1].setDouble(t[1].y),n[1].mulThis(o),n[2].setDouble(t[2].y),n[2].mulThis(a),n[2].subThis(n[1]),n[1].subThis(n[0]),n[2].subThis(n[1]),n[1].ldexpThis(1),i[0].setDouble(e[0]),i[1].setDouble(e[1]),i[2].setThis(i[1]),i[2].ldexpThis(1),i[2].negateThis(),i[2].addThis(i[0]),i[2].addDoubleThis(e[2]),i[1].subThis(i[0]),i[1].ldexpThis(1)}function mh(t,e,s){for(let n=0;n<3;++n)s[n].setCoordsPoint2DZ(t[n].mul(e[n]),e[n])}function lh(t,e,s,n){if(0===s)return n.assign(t[0]),e[0];if(1===s)return n.assign(t[2]),e[2];const i=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],r=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],o=[e[0],e[1],e[2]],a=s;let h,u,m;if(s<=.5){const t=St(i[0],i[1],a),e=St(i[1],i[2],a);h=nt(t,e,a);const s=St(r[0],r[1],a),n=St(r[1],r[2],a);u=nt(s,n,a);const l=St(o[0],o[1],a),c=St(o[1],o[2],a);m=St(l,c,a)}else{const t=Et(i[0],i[1],a),e=Et(i[1],i[2],a);h=Et(t,e,a);const s=Et(r[0],r[1],a),n=Et(r[1],r[2],a);u=Et(s,n,a);const l=Et(o[0],o[1],a),c=Et(o[1],o[2],a);m=Et(l,c,a)}return h/=m,u/=m,n.setCoords(h,u),bh(t,n),m}function ch(t,e,s){const n=ut(K,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i);gh([be.constructPoint2D(n[0]),be.constructPoint2D(n[1]),be.constructPoint2D(n[2])],[new rt(i[0]),new rt(i[1]),new rt(i[2])],e,s)}function gh(t,e,s,n){if(0===s.value())return void n.setE(t[0]);if(1===s.value())return void n.setE(t[2]);const i=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],r=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],o=[e[0].clone(),e[1].clone(),e[2].clone()],a=new rt,h=new rt,u=new rt;if(s.value()<=.5){const t=Ot(i[0],i[1],s),e=Ot(i[1],i[2],s);a.setE(Ot(t,e,s));const n=Ot(r[0],r[1],s),m=Ot(r[1],r[2],s);h.setE(Ot(n,m,s));const l=Ot(o[0],o[1],s),c=Ot(o[1],o[2],s);u.setE(Ot(l,c,s))}else{const t=Qt(i[0],i[1],s),e=Qt(i[1],i[2],s);a.setE(Qt(t,e,s));const n=Qt(r[0],r[1],s),m=Qt(r[1],r[2],s);h.setE(Qt(n,m,s));const l=Qt(o[0],o[1],s),c=Qt(o[1],o[2],s);u.setE(Qt(l,c,s))}a.divThisE(u),h.divThisE(u);const m=new K(a.value(),h.value());bh([t[0].value(),t[1].value(),t[2].value()],m),n.x.set(m.x,a.eps()),n.y.set(m.y,h.eps())}function dh(t,e,s,n){const i=s.lte(zt)?tt.lerpLo:tt.lerpHi,[r,o,a]=[e.map((e,s)=>t[s].x.mul(e)),e.map((e,s)=>t[s].y.mul(e)),e].map(([t,e,n])=>i(i(t,e,s),i(e,n,s),s)),h=new K(r.divThis(a).value(),o.divThis(a).value());bh(t.map(t=>t.asPoint2D()),h),n.x=tt.constructDouble(h.x),n.y=tt.constructDouble(h.y)}function _h(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function ph(t,e,s,n,i){if(i){if(s<0){return void ps(new fm({start:t[0],end:t[0].add(Aa(t,e,0).getUnitVector())}),s,n)}if(s>1){return void ps(new fm({start:t[2],end:t[2].add(Aa(t,e,1).getUnitVector())}),s-1,n)}}lh(t,e,s,n)}function fh(t,e,s,n){n.setEmpty();const i=[];i.push(new U(0,1));const r=.5*Math.max(s.width(),s.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new fe;if(ja(t,e,o,a),a.isIntersectingW(s)){const t=Math.max(a.width(),a.height());if(s.containsW(a)||t<=r||o.width()<1e-12)n.merge(o);else{const t=o.getCenter();i.push(U.construct(o.vmin,t)),i.push(U.construct(t,o.vmax))}}}}function Ph(t){return t[1]/Math.sqrt(t[0]*t[2])}function yh(t,e){const s=Math.sqrt(t[2]/t[0]);return e/nt(s,1,e)}function xh(t,e){const s=Math.sqrt(t[0]/t[2]);return e/nt(s,1,e)}function Ch(t,e,s,i){n(e>=0&&e<=1);(new E).setCoordsPoint3D(t[0]);(new E).setCoordsPoint3D(t[1]);(new E).setCoordsPoint3D(t[2]);const r=new E,o=new E,a=new E;wt(3,t[0],t[1],e,r),wt(3,t[1],t[2],e,o),wt(3,r,o,e,a);const h=t[2].clone();s&&(s[0].assign(t[0]),s[1].assign(r),s[2].assign(a)),i&&(i[0].assign(a),i[1].assign(o),i[2].assign(h))}function vh(t,e,s,i){const r=[t[0],t[1],t[2]];n(e>=0&&e<=1&&s!==i);const o=nt(r[0],r[1],e),a=nt(r[1],r[2],e),h=nt(o,a,e);s&&(s[0]=r[0],s[1]=o,s[2]=h),i&&(i[0]=h,i[1]=a,i[2]=r[2])}function bh(t,e){const s=U.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=gt(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=gt(e.y,s.vmin,s.vmax)}function Sh(t,e){const s=new U;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=gt(e[0].x,s.vmin,s.vmax),e[1].x=gt(e[1].x,s.vmin,s.vmax),e[2].x=gt(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=gt(e[0].y,s.vmin,s.vmax),e[1].y=gt(e[1].y,s.vmin,s.vmax),e[2].y=gt(e[2].y,s.vmin,s.vmax)}const Eh=$t/180,Dh=180/$t;function wh(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=Jt(e,360),e<0&&(e+=360),e)}function Ah(t){let e=t;return e=wh(e),e>180&&(e-=360),e}function Th(t){return t*Eh}function Ih(t){return t*Dh}function Mh(t){const e=Gt();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=Jt(s,e),s<0&&(s+=e),s)}function Yh(t){const e=At();let s=t;return s>-e&&s<=e||(s=Mh(s),s>e&&(s-=Gt())),s}function Nh(t,e){return Ah(e-t)}var Xh=b;class qh extends ds{constructor(t){if(void 0===t||bt(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new K(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new K(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new K(0,0),this.m_interior=new K(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new K(0,0),this.m_interior=new K(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new K(0,0),this.m_interior=new K(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return $s(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const n=K.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,n,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const n=K.lerp(t,e,.5);return this.constructCircleCenterAndPoint(n,t,s),this}constructLineEllipticArc(t,e){return Su(this,t,e,1),this}constructLineCircularArc(t,e){return Su(this,t,e,0),this}constructEllipse(t,e,s,n,i=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const r=new K(0,this.m_minorMajorRatio*this.m_semiMajorAxis),o=Math.cos(n),a=Math.sin(n);return r.rotateDirect(o,a),r.addThis(s),this.constructEllipticArcEndPointsCenter(r,r,this.m_semiMajorAxis,this.m_minorMajorRatio,n,!0,i,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new ce;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new ce;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return Zu(this,t,e,s),this}constructThreePointCircle(t,e,s,n=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const i=t.clone(),r=e.clone(),o=s.clone();return i.equals(r)&&r.assign(o),this.constructTwoPointCircle(i,r,n)}{const i=K.calculateCircleCenterFromThreePoints(t,e,s);if(!i.isFinite()||!Number.isFinite(K.distance(t,i))){const n=K.distance(t,e),i=K.distance(t,s);this.constructLineCircularArc(t,n>=i?e:s)}return this.constructCircleCenterAndPoint(i,t,n)}}constructCircularArcThreePoint(t,e,s){const n=new rt(t.x),i=new rt(e.x),r=new rt(s.x),o=new rt(t.y),a=new rt(e.y),h=new rt(s.y),u=new rt(.5),m=i.subE(n),l=a.subE(o),c=r.subE(n),g=h.subE(o),d=m.mulE(g).subThisE(l.mulE(c));if(d.scaleError(10),d.isZero()){if(!m.isZero()||!l.isZero())return Su(this,t,e,0),this;{const n=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),i=s.sub(n).length();this.constructEllipticArcEndPointsCenter(t,e,i,1,0,!0,!1,n),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const _=m.sqr().addThisE(l.sqr()).mulThisE(u),p=c.sqr().addThisE(g.sqr()).mulThisE(u),f=_.mulE(g).subThisE(p.mulE(l)),P=m.mulE(p).subThisE(c.mulE(_));f.divThisE(d),P.divThisE(d);const y=f.sqr().addThisE(P.sqr());y.sqrtThis();const x=f.addE(n),C=P.addE(o);let v=t.x-x.value(),b=t.y-C.value();const S=Math.atan2(b,v);v=e.x-x.value(),b=e.y-C.value();const E=Math.atan2(b,v);v=s.x-x.value(),b=s.y-C.value();const D=Math.atan2(b,v);let w=D-2*At();for(;w<S;)w+=2*At();let A=E-2*At();for(;A<w;)A+=2*At();let T=D+2*At();for(;T>S;)T-=2*At();let I,M=E+2*At();for(;M>T;)M-=2*At();I=A-S<S-M?A-S:M-S;const Y=new K(x.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(I)>At(),I>0,Y),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,n){return this.constructEllipticArcGeneral(t,1,e,s,n,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,n,i,r,o){return bu(this,t,e,s,n,i,r,o)}constructEllipticArcEndPointsCenter(t,e,s,n,i,r,o,a){return bu(this,t,e,s,n,i,r,o,a)}constructEllipticArcGeneral(t,e,s,n,i,r){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=Yh(r),a=Math.cos(o),h=Math.sin(o),u=new K(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),m=K.getNAN(),l=Yh(n);m.x=u.x*Math.cos(l),m.y=u.y*Math.sin(l),m.rotateDirect(a,h),m.addThis(s);const c=Tt(i,Gt());let g=c;Math.abs(g)===Gt()&&(g=0);const d=K.getNAN();return d.x=u.x*Math.cos(l+g),d.y=u.y*Math.sin(l+g),d.rotateDirect(a,h),d.addThis(s),this.constructEllipticArcEndPointsCenter(m,d,this.m_semiMajorAxis,this.m_minorMajorRatio,o,Math.abs(c)>At(),c>0,s)}constructEllipticArcAsNURB(e,s,n,i){(i>=1||i<0)&&t("construct_elliptic_arc_as_NURB: weight"),s.isFinite()||t("construct_elliptic_arc_as_NURB: control_point");return Gu([e,s,n],i*i,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,Uu(this),this.afterCompletedModification(),t!==this&&He(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){if(this.isLine())return!0;if(this.isMajor())return!1;const e=this.getEndXY().sub(this.getStartXY()).length();return!(this.calculateLength2D()-e>t)}isDegenerateToLine(){return Eu(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return K.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!qu(this)}isMajor(){return Vu(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return e.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=le.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const e=this.m_description.getSemantics(s);for(let n=0,i=Xh.getComponentCount(e);s<i;s++){const s=this.queryInterval(e,n);t.setIntervalEnvelope(e,n,s)}}}else 2===t.m_EnvelopeType?$u(this,U.unit(),t):s("3d not impl")}applyTransformation(t){Tu(this,t,!1,null,null)}createInstance(){return new qh}calculateLength2D(){return fu(this,0,1)}queryControlPointsHelper(t){r("")}queryCoord2D(t,e){if(Eu(this))fs(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(K.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(K.construct(this.m_XEnd,this.m_YEnd));else{const s=gu(this,t),n=new K(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));n.rotateDirect(this.m_cosr,this.m_sinr),n.addThis(this.m_center),e.assign(n)}}queryCoord2DE(t,e){iu(this,t,e)}queryCoord2DMP(t,e){s("")}getCoordX(t){const e=new K;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new K;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createEllipticArc();n&&i.dropAllAttributes();let r=0===t&&1===e;if(r&&!n)return void this.copyTo(i);const o=K.getNAN();this.queryCoord2D(t,o);const a=K.getNAN();if(this.queryCoord2D(e,a),!r)if(o.equals(a))e-t>.5&&this.isMajor()&&this.isClosed()?(r=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&o.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&a.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),r=0===t&&1===e,r&&!n)return void this.copyTo(i);if(i.m_center.assign(this.m_center),i.m_semiMajorAxis=this.m_semiMajorAxis,i.m_minorMajorRatio=this.m_minorMajorRatio,i.m_interior.assign(this.m_interior),i.m_rotation=this.m_rotation,i.m_cosr=this.m_cosr,i.m_sinr=this.m_sinr,i.m_sweepAngle=this.m_sweepAngle,i.m_startAngle=this.m_startAngle,i.m_bits=this.m_bits,Fe(i,o.x,o.y),Le(i,a.x,a.y),r)return void Mu(i,Pu(this));i.m_startAngle=gu(this,t),i.m_sweepAngle=gu(this,e)-i.m_startAngle,i.m_startAngle=hu(i.m_startAngle),Fu(i,Math.abs(i.m_sweepAngle)>At()),n&&i.assignVertexDescription(this.m_description),Uu(i),lu(i);const h=this.m_description.getAttributeCount();if(h>1&&!n){for(let e=1;e<h;e++){const s=this.m_description.getSemantics(e),n=Xh.getComponentCount(s);for(let e=0;e<n;e++){const n=this.getAttributeAsDbl(t,s,e);i.setStartAttribute(s,e,n)}}for(let t=1;t<h;t++){const s=this.m_description.getSemantics(t),n=Xh.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}i.afterCompletedModification()}queryDerivative(t,e){nm(this,t,e)}cutArcIgnoreAttributes(t,e,s){let n=0===t&&1===e;const i=new K;this.queryCoord2D(t,i);const r=new K;this.queryCoord2D(e,r),n||(i.equals(r)?e-t>.5&&this.isMajor()&&this.isClosed()?(n=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&i.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&r.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),n=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,Fe(s,i.x,i.y),Le(s,r.x,r.y),n?Mu(s,Pu(this)):(s.m_startAngle=gu(this,t),s.m_sweepAngle=gu(this,e)-s.m_startAngle,s.m_startAngle=hu(s.m_startAngle),Fu(s,Math.abs(s.m_sweepAngle)>Math.PI),Uu(s),s.afterCompletedModification())}changeEndPoints2D(t,e){xu(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const n=this.calculateLength2D(),i=n>0?this.tToLength(t)/n:0,r=Xh.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return vt(r,o,a,i,Xh.getDefaultValue(e))}getClosestCoordinate(t,e){return tm(this,t,U.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return tm(this,t,e,!1)}getYMonotonicParts(e,s=!1){e.length<2&&t("");const i=this.getSemiAxes(),r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),o=r+At(),a=et(3,Number.NaN);let h=0;if(a[0]=cu(this,r),a[0]>0&&a[0]<1&&h++,a[1]=cu(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,n(e.length>=h);let u=0;for(let t=0;t<h;t++){const n=a[t];this.queryCut(u,n,e[t],s),u=n}return h}getMonotonicParts(e,s){if(e.length<4&&t(""),this.isDegenerateToLine())return e[0].createEllipticArc().assignCopy(this),s&&e[0].get().dropAllAttributes(),1;const i=this.getSemiAxes(),r=et(4,Number.NaN);r[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r[1]=r[0]+At(),r[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),r[3]=r[2]+At();const o=et(5,Number.NaN);let a=0;for(let t=0;t<4;t++)o[a]=cu(this,r[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;Dt(o,a),o[a-1]<1&&(o[a]=1,a++),n(e.length>=a);let h=0;for(let t=0;t<a;t++){const n=o[t];this.queryCut(h,n,e[t],s),h=n}return a}intersectionWithAxis2D(t,e,s,n){if(Eu(this)){return new fm({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,n)}let i,r;const o=new rt(e),a=this.getSemiAxes();if(t){if(e>this.m_center.y+a.x||e<this.m_center.y-a.x)return 0;i=new rt(a.x).mulThis(this.m_sinr),r=new rt(a.y).mulThis(this.m_cosr),o.subThis(this.m_center.y)}else{if(e>this.m_center.x+a.x||e<this.m_center.x-a.x)return 0;i=new rt(a.x).mulThis(this.m_cosr),r=new rt(a.y).mulThis(-this.m_sinr),o.subThis(this.m_center.x)}const h=i.sqr(),u=r.sqr(),m=h.addE(u),l=r.mulE(o).mulThis(-2),c=o.sqr().subThisE(h),g=l.sqr().subThisE(m.mulE(c).mulThis(4)),d=i.mulE(o).mulThis(-2),_=o.sqr().subThisE(u),p=d.sqr().subThisE(m.mulE(_).mulThis(4));let f=g.eps()*Math.abs(p.value())<=p.eps()*Math.abs(g.value());f?i.isZero()&&(f=!1):r.isZero()&&(f=!0),f||(l.setE(d),c.setE(_));const P=ut(rt,2);let y=dn(m,l,c,U.construct(-1,1),!1,P);if(0===y)return 0;const x=[0,0];let C=0;for(let v=0;v<y;v++){const t=new rt,e=new rt;f?(t.setE(P[v]),e.setE(o.subE(r.mulE(P[v])).divThisE(i))):(e.setE(P[v]),t.setE(o.subE(i.mulE(P[v])).divThisE(r)));const s=cu(this,Math.atan2(t.value(),e.value()));s>=0&&s<=1&&(x[C]=s,C++)}return y=C,0===y?0:(2===y&&x[0]>x[1]&&(x[1]=Q(x[0],x[0]=x[1])),n&&st(n,x,0,0,y),s&&(s[0]=t?this.getCoordX(x[0]):this.getCoordY(x[0]),y>1&&(s[1]=t?this.getCoordX(x[1]):this.getCoordY(x[1]),!n&&s[0]>s[1]&&(s[1]=Q(s[0],s[0]=s[1])))),y)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return Ie(this,t)}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new U(0,1),t):s("3d not impl")}clone(t){const e=new qh;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Eu(this))return 0===e?U.construct(this.getStartX(),this.getEndX()):U.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const n=t+Math.PI,i=[0,0];i[0]=cu(this,t),i[1]=cu(this,n);const r=0===e?U.construct(this.getStartX(),this.getEndX()):U.construct(this.getStartY(),this.getEndY()),o=new K;for(let a=0;a<2;a++){const t=i[a];t>0&&t<1&&(this.queryCoord2D(t,o),r.mergeNeCoordinate(0===e?o.x:o.y))}return r}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new U(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(Eu(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const n=this.getCoord2D(s.vmin),i=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=It){let t=K.lerp(n,i,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*K.distance(n,i))),e.setCoords(n),e.mergeNe(i),void e.mergeNe(t)}$u(this,s,e)}tToLength(t){return Eu(this)?t*K.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Du(this,t)}parametricAngleToT(t){return cu(this,t)}tToParametricAngle(t){return gu(this,t)}lengthToT(t){if(Eu(this)){const e=K.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return wu(this,t)}calculateWeightedAreaCentroid2D(t){if(Eu(this)){const t=new K;return t.setCoords(0,0),t}const e=Hu(this),s=this.getStartXY().sub(this.m_center),n=this.getEndXY().sub(this.m_center),i=this.m_semiMajorAxis,r=this.getSemiMinorAxis(),o=this.m_startAngle+this.m_sweepAngle,a=new K;a.x=i*r*(i*this.m_cosr*(-Math.sin(o)+Math.sin(this.m_startAngle))+r*(-Math.cos(o)+Math.cos(this.m_startAngle))*this.m_sinr)/3,a.y=i*r*(r*(Math.cos(o)-Math.cos(this.m_startAngle))*this.m_cosr+i*(-Math.sin(o)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const h=n.add(s).mul(n.crossProduct(s)/6);return a.x-=h.x,a.y-=h.y,a.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new K;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Eu(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const n=Math.sin(e),i=Math.sin(s),r=Math.cos(e),o=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,a=s*(i-n),h=s*(r-o);t.setCoords(a,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),a=e*e,h=s*s,u=e*s,m=a-h,l=m/h,c=m/a,g=Math.sqrt(l),d=Math.sqrt(c),_=.5*u*(Math.asinh(g*i)/g+i*Math.sqrt(1+l*i*i))-.5*u*(Math.asinh(g*n)/g+n*Math.sqrt(1+l*n*n)),p=-.5*u*(Math.asin(d*o)/d+o*Math.sqrt(1-c*o*o))- -.5*u*(Math.asin(d*r)/d+r*Math.sqrt(1-c*r*r));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Eu(this)){const s=K.distance(t,this.m_center),n=this.getSemiAxes();if(s<n.x-e||s>n.y+e)return!1}const n=this.getClosestCoordinate(t,!1),i=new K;this.queryCoord2D(n,i);return K.distance(i,t)<=e}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}getTangent(t){if(Eu(this))return this.getEndXY().sub(this.getStartXY());{const e=gu(this,t),s=new K;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(t){if(Eu(this))return this.getEndXY().sub(this.getStartXY());{const e=gu(this,t),s=new K;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}normalizeAfterEndpointChange(){return!!Ru(this)&&(Eu(this)?(zu(this),!1):Bu(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new K(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new K(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){const e=gu(this,t),s=new K,n=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),n*Math.cos(e));const i=new K;i.setCoords(-this.m_semiMajorAxis*Math.cos(e),-n*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),i.rotateDirect(this.m_cosr,this.m_sinr));const r=s.sqrLength();if(0===r)return Number.NaN;const o=Math.sqrt(r);s.divThis(o);return s.crossProduct(i)/r}getMonotonicPartParams(e,s){const n=et(6,Number.NaN);n[0]=0;let i=1;if(this.isDegenerateToLine())n[1]=1,i=2;else{const t=this.getSemiAxes(),e=et(4,Number.NaN);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=Mt());for(let s=0;s<4;s++){const t=cu(this,e[s]);t>0&&t<1&&(n[i]=t,i++)}i>2&&Dt(n,i),n[i]=1,i++}if(s){e<i&&t("");for(let t=0;t<i;t++)s[t]=n[t]}return i}calculateLowerLength2D(){const t=K.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=K.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Q(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Q(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Q(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Eu(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,Yu(t)}calculateArea2DHelper(){return Hu(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),Eu(this))return;const s=this.getSemiAxes(),n=et(8,Number.NaN);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,i=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=i+Math.PI;n[0]=cu(this,t),n[1]=cu(this,e),n[2]=cu(this,i),n[3]=cu(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,i=Math.atan2(-s.y*t,s.x*e),r=i+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;n[4]=cu(this,i),n[5]=cu(this,r),n[6]=cu(this,o),n[7]=cu(this,a)}const i=K.getNAN();for(let r=0;r<8;r++){const s=n[r];t.containsExclusiveCoordinate(s)&&(this.queryCoord2D(s,i),e.mergeNe(i))}}setSegmentFromCoordsForStitcher(t,e){Cu(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return r("should not1; be called"),0}ensureXYMonotone(){if(Eu(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return Su(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=ut(K,3);let e=ku(this,t);if(Ua(t)){let s=!1;if(0===this.projectionBehavior()){const n=new le;n.setCoords({pt:t[0]}),n.mergeNe(t[2]);const i=new K;i.setSub(t[2],t[0]),i.leftPerpendicularThis(),i.normalize(),i.scale(K.distance(t[2],t[0]));const r=K.lerp(t[2],t[0],.5),o=r.sub(i),a=r.add(i);n.clipLine(o,a);const h=K.getClosestCoordinate(o,a,t[1],!1);t[1]=K.lerp(o,a,h);const u=t[2].sub(t[1]),m=t[0].sub(t[1]),l=u.crossProduct(m),c=u.dotProduct(m);e=xt()-Math.abs(.5*Math.atan2(l,c)),s=!0}return Gu(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){xu(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,Mu(e,Pu(this))}reverseImpl(){Xu(this,!qu(this)),lu(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&Uu(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const n=e.m_startAngle;return this.m_startAngle===n}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const n=Math.abs(Th(Ah(Ih(this.m_rotation-s.m_rotation)))),i=Math.abs(At()-n),r=Math.min(n,i);if(this.m_semiMajorAxis*Math.abs(r)>e)return!1;const o=this.getCoord2D(.5),a=s.getCoord2D(.5);return!!o.isEqualPoint2D(a,e)}swapImpl(t){const e=t;this.m_center=Q(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=Q(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=Q(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=Q(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=Q(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=Q(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=Q(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=Q(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=Q(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=Q(e.m_bits,e.m_bits=this.m_bits),Nu(this,e)}afterCompletedModification(){zu(this),Yu(this)}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){if(e.length<2&&i(""),Eu(this)){return new fm({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s)}{const e=K.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const n=this.getClosestCoordinate(t,!1),r=K.getNAN();return this.queryCoord2D(n,r),K.distance(r,t)<=s?lt(n,0,1)&&(this.queryCoord2D(0===n?1:0,r),K.distance(r,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,Yu(this)}clearEndPointModified(){zu(this)}}function Fh(t,e,s){t.isEmpty()&&o(""),f(t);const n=t.getImpl(),i=[];return Rh(n.getPointCount(),i),zh(Lh(n),i,n.getPointCount(),e)}function Vh(t,e,s,n){const i=[];return Rh(e,i),zh(t,i,e,s)}function Lh(t){return{at:e=>t.getXY(e)}}function Rh(t,e){e.length=t;for(let s=0;s<e.length;++s)e[s]=s;t>3&&is(t,e)}function zh(t,e,s,n,i){let r=0;const o=[0,0,0];let a=0;const h=3;let u=0;for(let m=0;m<h;++m){let i=!1;for(;u<s;){const s=t.at(e[u]);let l=1;if(3===r?l=K.inCircleRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]),s):2===r?l=K.inCircleRobust3Point(t.at(n[0]),t.at(n[1]),s):1===r&&s.equals(t.at(n[0]))&&(l=0),l<=0){if(l<0&&m+1<h){e[a]=Q(e[u],e[u]=e[a]);for(let t=0;t<r;t++)if(n[t]===e[u]){o[t]=u;break}a++}u++;continue}i=!0;let c=0;for(let t=0;t<r;t++)o[t]>u&&(n[c]=n[t],o[c]=o[t],c++);r=c,n[r]=e[u],o[r]=u,r++,r<3?u=a:(1===K.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=Q(n[0],n[0]=n[2]),o[2]=Q(o[0],o[0]=o[2])),u++)}if(!i)break;if(m+1<h){a=0;let s=!1;for(let t=0;t<r;t++)for(let e=t+1;e<r;e++)o[t]>o[e]&&(o[e]=Q(o[t],o[t]=o[e]),n[e]=Q(n[t],n[t]=n[e]),s=!0);for(let t=0;t<r;t++)e[o[t]]=Q(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===r&&1===K.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=Q(n[0],n[0]=n[2]),o[2]=Q(o[0],o[0]=o[2]))}u=r}return r}function Bh(t,e,s,n,i,r){return new Zh(0,0,0,null,!1,_t()).densifyEx(t,e,s,n,!1,r)}function kh(s,n,i,r){return Number.isFinite(n)||t("replace_all_curves_with_beziers: maxDeviation"),Qh(e.enumBezier,s,n,i)}function Gh(t,i,r,o,a,h,u,m){h&&(h.length=0),u&&(u.length=0);const l=t.getGeometryType();if(l===e.enumLine)return h&&(h.push(t.getStartXY()),h.push(K.getNAN()),h.push(K.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(l===e.enumBezier){if(!o)return h&&(h.push(t.getStartXY()),h.push(t.getControlPoint1()),h.push(t.getControlPoint2()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;const e=et(9,Number.NaN);let s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Hh(t,r,e),2===s&&a&&(e[1]=.5,e.push(1),s=3),u&&u.splice(0,0,...e.slice(0,s)),h){const n=new Pm;for(let i=1;i<s;i++){const s=e[i-1],r=e[i];t.queryCut(s,r,n,!0);const o=n.get();co(o),1===i&&h.push(o.getStartXY()),h.push(o.getControlPoint1()),h.push(o.getControlPoint2()),h.push(o.getEndXY())}}return s-1}if(l===e.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return h&&(h.push(t.getStartXY()),h.push(K.getNAN()),h.push(K.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(o&&(a||!e.isMonotoneQuickAndDirty())){const s=et(6,Number.NaN);let m=e.getMonotonicPartParams(s.length,s);s.length=m,m=Hh(t,r,s),2===m&&a&&(s[1]=.5,s.push(1),m=3);let l=0;if(m>2){const t=new Pm,a=u||[];let c=0;for(let g=1;g<m;g++){const d=s[c],_=s[g];if(e.queryCut(d,_,t,!0),t.get().isDegenerate(0))continue;const p=a.length,f=Jh(1===g,t.get(),i,r,o,h,u);n(f>0),l+=f;const P=g===m-1,y=s[c],x=t.get().getSweepAngle()/e.getSweepAngle();for(let t=p,s=a.length;t<s;t++)if(a[t]=!P||t+1<s?y+a[t]*x:1,h){const s=3*t,n=e.getCoord2D(a[t]);if(h[s].setCoordsPoint2D(n),s>0){go(h.slice(s-3))}}c=g}return l}}return Jh(!0,e,i,r,o,h,u)}if(l===e.enumRationalBezier2){const e=t;if(o&&(a||!e.isMonotoneQuickAndDirty())){const s=et(6,Number.NaN);let n=e.getMonotonicPartParams(s.length,s);s.length=n,n=Hh(t,r,s),2===n&&a&&(s[1]=.5,s.push(1),n=3);let o=0;if(n>2){const t=new Pm,a=u||[];for(let m=1;m<n;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=a.length;o+=$h(1===m,t.get(),i,r,!1,h,u);const d=m===n-1,_=s[m-1];for(let t=g,s=a.length;t<s;t++)if(a[t]=!d||t+1<s?_+a[t]:1,h){const s=3*t,n=e.getCoord2D(a[t]);if(h[s].setCoordsPoint2D(n),s>0){Ti(h.slice(s-3))}}}return o}}return $h(!0,e,i,r,o,h,u)}if(l===e.enumBezier2){const e=t,s=ut(K,3);e.queryControlPoints(s);const n=new ra;n.constructFromQuadratic(s);const m=Gh(n,i,r,o,a,h,u);if(null!=h&&null!=u){const t=3;for(let s=1,n=0;s<m;++s,n+=t){const i=new K;e.queryCoord2D(u[s],i);const r=h[n+t];if(!i.equals(r)&&(h[n+t].setCoordsPoint2D(i),o)){go(h.slice(n,n+4))}}}return m}s("")}function Wh(t,n,i,r,o,a,h,u){a&&(a.length=0),h&&(h.length=0);const m=t.getGeometryType();if(m===e.enumLine)return a&&(a.push(t.getStartXY()),a.push(K.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(m===e.enumBezier2){const e=et(9,Number.NaN);let s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Hh(t,i,e),h&&h.splice(0,0,...e.slice(0,s)),a){const n=new Pm;for(let i=1;i<s;i++){const s=e[i-1],r=e[i];t.queryCut(s,r,n,!0);const o=n.get();Ai(o),1===i&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getEndXY())}}return s-1}if(m===e.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(K.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(!e.isMonotoneQuickAndDirty()){const s=et(6,Number.NaN);let r=e.getMonotonicPartParams(s.length,s);s.length=r,r=Hh(t,i,s);let o=0;if(r>2){const t=new Pm,u=h||[];for(let m=1;m<r;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=u.length;o+=tu(1===m,t.get(),n,i,!1,a,h);const d=m===r-1,_=s[m-1],p=t.get().getSweepAngle()/e.getSweepAngle();for(let t=g,s=u.length;t<s;t++)if(u[t]=!d||t+1<s?_+u[t]*p:1,a){const s=2*t,n=e.getCoord2D(u[t]);if(a[s].setCoordsPoint2D(n),s>0){Ti(a.slice(s-2))}}}return o}}return Jh(!0,e,n,i,r,a,h)}if(m===e.enumBezier){const e=t;if(!e.isMonotoneQuickAndDirty()){const s=et(6,Number.NaN);let r=e.getMonotonicPartParams(s.length,s);s.length=r,r=Hh(t,i,s);let o=0;if(r>2){const t=new Pm,u=h||[];for(let m=1;m<r;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=u.length;o+=eu(1===m,t.get(),n,i,!1,a,h);const d=m===r-1,_=s[m-1];for(let t=g,s=u.length;t<s;t++)if(u[t]=!d||t+1<s?_+u[t]:1,a){const s=2*t,n=e.getCoord2D(u[t]);if(a[s].setCoordsPoint2D(n),s>0){Ti(a.slice(s-2))}}}return o}}return eu(!0,e,n,i,r,a,h)}if(m===e.enumRationalBezier2){const e=t;if(!e.isMonotoneQuickAndDirty()){const s=et(6,Number.NaN);let r=e.getMonotonicPartParams(s.length,s);s.length=r,r=Hh(t,i,s);let o=0;if(r>2){const t=new Pm,u=h||[];for(let m=1;m<r;m++){const l=s[m-1],c=s[m];e.queryCut(l,c,t,!0);const g=u.length;o+=Kh(1===m,t.get(),n,i,!1,a,h);const d=m===r-1,_=s[m-1];for(let t=g,s=u.length;t<s;t++)if(u[t]=!d||t+1<s?_+u[t]:1,a){const s=2*t,n=e.getCoord2D(u[t]);if(a[s].setCoordsPoint2D(n),s>0){Ti(a.slice(s-2))}}}return o}}return Kh(!0,e,n,i,r,a,h)}s("")}function jh(t,s,i,r,o,a,h,u,m){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),u&&(u.length=0),l===e.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(K.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),u&&(u.push(0),u.push(1)),1}const c=et(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Hh(t,i,c);else{if(g=2,c[0]=0,c[1]=1,l===qh.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,g=4):(c[0]=0,c[1]=.5,c[2]=1,g=3)}}else n(l===Dn.type);c.length=g}if(2===g&&r&&(c[1]=.5,c.push(1),g=3),a){const s=new Pm;let n=1;for(;n<g;){const i=c[n-1],r=c[n];t.queryCut(i,r,s,!0);const u=ut(K,3),m=[1,1,1];if(l===e.enumEllipticArc){const t=s.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(r-i)/3;c.splice(n,0,i+t),c.splice(n+1,0,i+2*t),g+=2;continue}m[1]=ku(t,u)}else{const t=s.get();t.queryControlPoints(u),t.queryWeights(m)}o&&Ua(u),1===n&&(a.push(u[0].clone()),h.push(m[0])),a.push(u[1].clone()),a.push(u[2].clone()),h.push(m[1]),h.push(m[2]),n++}}return u&&(u.length=g,st(u,c,0,0,g)),g-1}qh.type=e.enumEllipticArc;class Zh{static constructDefault(t){return new Zh(0,0,0,t,!1,_t())}constructor(t,e,s,n,i,r){this.m_segmentBuffer=null,this.m_dummyPoint=new F,this.m_progressCounter=0,this.m_progressTracker=n,this.m_bSetDensifyFlag=i,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>xt()?xt():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=r,_(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,n,i,r){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=n>xt()?xt():n,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=i,this.m_maxSegmentsPerCurve=r,_(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const s=t.getGeometryType();return p(s)?t:c(s)?this.densifyMultiPath(t):m(s)?this.densifySegmentImpl(t):s===e.enumEnvelope?this.densifyEnvelope(t):void r("")}densifySegmentEx(t,s,n,i,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==e.enumLine)&&(!i||n))return void(s?o===e.enumLine?s.addSegment(t,n):(n&&(t.queryStart(this.m_dummyPoint),s.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint)):(n&&r.push(0),r.push(1)));if(o===e.enumBezier)return void this.densifyCubicBezier(t,s,n,i,r);if(o===e.enumRationalBezier2)return void this.densifyRationalBezier2(t,s,n,i,r);if(o===e.enumBezier2)return void this.densifyBezier2(t,s,n,i,r);if(o===e.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,s,n,i,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,s,n,i,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const s=t.createInstance();if(s.getGeometryType()===e.enumPolygon){s.setFillRule(t.getFillRule())}s.reserve(t.getPointCount());const n=t.getImpl().querySegmentIterator();for(;n.nextPath();){let t=!0;for(;n.hasNextSegment();){const e=n.nextSegment(),i=n.isClosingSegment();this.densifySegmentEx(e,s,t,i,null),i&&s.closePathWithLine(),t=!1}}return s}densifySegmentImpl(t){const e=new Qs({vd:t.getDescription()}),s=[0];return this.densifySegmentEx(t,e,!0,!1,s),e}densifyEnvelope(t){const e=new mr({vd:t.getDescription()});e.addEnvelope(t,!1);const s=le.constructEmpty();t.queryEnvelope(s);const n=s.width(),i=s.height();return!(this.m_maxLength>0)||n<=this.m_maxLength&&i<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const s=t.createInstance();if(s.getGeometryType()===e.enumPolygon){s.setFillRule(t.getFillRule())}s.reserve(t.getPointCount());const n=s.getImpl(),i=t.getImpl(),r=i.getAttributeStreamRef(0),o=new fm;for(let e=0,a=i.getPathCount();e<a;e++){const t=i.isClosedPath(e);if(0===i.getPathSize(e))continue;const a=i.getPathStart(e),h=r.readPoint2D(2*a),u=h.clone();n.startPath(h);for(let m=a+1,l=i.getPathEnd(e);m<l;m++){const t=r.readPoint2D(2*m),e=K.distance(u,t);if(e>this.m_maxLength){let s=Math.ceil(e/this.m_maxLength);s>_t()&&(s=_t());const i=1/s;let r,a,h;u.compare(t)<0?(o.setStartXY(u),o.setEndXY(t),r=0,a=1):(o.setStartXY(t),o.setEndXY(u),r=s-2,a=-1);for(let t=0,e=s-1;t<e;t++,r+=a){this.progress_(),h=i*(r+1);const t=new K;o.queryCoord2D(h,t),n.lineTo(t),this.m_bSetDensifyFlag&&n.setAttributeNoCurves(10,n.getPointCount()-1,0,1)}}else this.progress_();s.lineTo(t),u.assign(t)}if(t){const t=K.distance(u,h);if(t>this.m_maxLength){const e=h;let s=Math.ceil(t/this.m_maxLength);s>_t()&&(s=_t());const i=1/s;let r,a;u.compare(e)<0?(o.setStartXY(u),o.setEndXY(e),r=0,a=1):(o.setStartXY(e),o.setEndXY(u),r=s-2,a=-1);const m=new K(0,0);let l;for(let t=0,h=s-1;t<h;t++,r+=a)this.progress_(),l=i*(r+1),o.queryCoord2D(l,m),n.lineTo(m),this.m_bSetDensifyFlag&&n.setAttributeNoCurves(10,n.getPointCount()-1,0,1)}n.closePathWithLine()}}return s}densifySegmentByLength(t,i,r,o,a,h){n(t.getGeometryType()!==e.enumBezier);let u=t.getStartXY().compare(t.getEndXY());if(0===u&&i<1){t.getGeometryType()===e.enumEllipticArc?u=t.getSweepAngle()<0?1:-1:s("densify segment by length")}let m=0;if(o&&(r?(t.queryStart(this.m_dummyPoint),r.startPathPoint(this.m_dummyPoint)):h.push(0),++m),i*this.m_maxSegmentsPerCurve<1&&(i=1/this.m_maxSegmentsPerCurve),i<1){this.m_segmentBuffer||(this.m_segmentBuffer=new Pm);let e=Math.ceil(1/i);e>_t()&&(e=_t()),i=1/e,this.m_segmentBuffer.create(t.getGeometryType());let s,n,o,a=t;u<0?(s=0,n=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),s=e-2,n=-1,a=this.m_segmentBuffer.get());const l=e-1;for(let t=0;t<l;t++,s+=n)o=i*(s+1),r?(a.queryCoord(o,this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==o&&0!==o&&r.setAttribute(10,r.getPointCount()-1,0,1)):h.push(u>0?1-o:o),this.progress_();o=1,m+=l}(!a||a&&o&&m<2)&&(r?(t.queryEnd(this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint)):h.push(1))}densifyCubicBezier(t,e,s,n,i){const r=new ra;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());if(0===h&&a>0){const e=ut(K,4);t.queryControlPoints(e),h=e[1].compare(e[2]),0===h&&(h=e[1].compare(e[0]))}h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=[],l=[],c=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let g=!0,d=0;if(h>0)for(m.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new K(0,1)]),l.push(0);m.length;){this.progress_();const t=m.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){g&&(d=o.findMinDeriv(),g=!1);let e=.5*(a+h);Math.abs(d-e)<.4*(h-a)&&(e=d);const s=(e-a)/(h-a),n=t[0].mul(1-s).add(t[1].mul(s)),i=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),c=n.mul(1-s).add(i.mul(s)),_=i.mul(1-s).add(u.mul(s)),p=c.mul(1-s).add(_.mul(s)),f=t[3];t[1]=n,t[2]=c,t[3]=p,t[4].setCoords(a,e);const P=[p,_,u,f,new K(e,h)];m.push(P),l[l.length-1]=r+1,l.push(r+1);continue}m.pop(),l.pop(),(m.length>0||!n||n&&s&&u<2)&&(e?(o.queryCoord(a,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==a&&0!==a&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(1-a),++u)}else for(m.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new K(0,1)]),l.push(0);m.length;){this.progress_();const t=m.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){g&&(d=o.findMinDeriv(),g=!1);let e=.5*(a+h);Math.abs(d-e)<.4*(h-a)&&(e=d);const s=(e-a)/(h-a),n=t[0].mul(1-s).add(t[1].mul(s)),i=t[1].mul(1-s).add(t[2].mul(s)),u=t[2].mul(1-s).add(t[3].mul(s)),c=n.mul(1-s).add(i.mul(s)),_=i.mul(1-s).add(u.mul(s)),p=c.mul(1-s).add(_.mul(s)),f=t[0];t[0]=p,t[1]=_,t[2]=u,t[4].setCoords(e,h);const P=[f,n,c,p,new K(a,e)];m.push(P),l[l.length-1]=r+1,l.push(r+1);continue}m.pop(),l.pop(),(m.length>0||!n||n&&s&&u<2)&&(e?(o.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h),++u)}}densifyRationalBezier2(t,e,s,n,i){const r=new Dn;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new Dn,c=[],g=[];for(c.push(new U(0,1)),g.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=g.at(-1);if(r<m&&this.rationalBezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new U(e,t.vmax))):(c.at(-1).vmin=e,c.push(new U(t.vmin,e))),g[g.length-1]=r+1,g.push(r+1);continue}if(c.pop(),g.pop(),c.length>0||!n||n&&s&&u<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h>0?1-s:s),++u}}}densifyBezier2(t,e,s,n,i){const r=new An;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),l=new An,c=[],g=[];for(c.push(new U(0,1)),g.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=g.at(-1);if(r<m&&this.bezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new U(e,t.vmax))):(c.at(-1).vmin=e,c.push(new U(t.vmin,e))),g[g.length-1]=r+1,g.push(r+1);continue}if(c.pop(),g.pop(),c.length>0||!n||n&&s&&u<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h>0?1-s:s),++u}}}densifyEllipticArc(t,e,s,n,i){const r=new qh;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=t.isClockwise()?0:1),h>0&&(t.copyTo(r),r.reverse(),o=r);let u=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):i.push(0),++u);const m=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new qh,c=[],g=[];for(c.push(new U(0,1)),g.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=g.at(-1);if(r<m&&this.ellipticArcNeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new U(e,t.vmax))):(c.at(-1).vmin=e,c.push(new U(t.vmin,e))),g[g.length-1]=r+1,g.push(r+1);continue}if(c.pop(),g.pop(),c.length>0||!n||n&&s&&u<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):i.push(h>0?1-s:s),++u}}}calculateLengthSubdivisionStep(t,n){const i=t.calculateUpperLength2D();if(!t.isCurve())return i?n/i:1;if(t.getGeometryType()===e.enumEllipticArc){const e=t;if(e.isCircular()||e.isDegenerate(0)||e.isDegenerateToLine()){let t=n/i;return t<this.m_minStep&&(t=this.m_minStep),t}return n/i*e.getSemiAxes().y/e.getSemiAxes().x}t.getGeometryType()===e.enumBezier&&s(""),s("")}calculateDeviationSubdivisionStep(t,n){if(!t.isCurve())return 1;if(t.getGeometryType()===e.enumEllipticArc){const e=t;if(e.isDegenerate(0)||e.isDegenerateToLine())return 1;{const s=e.getSemiMajorAxis(),i=1-n/s;let r=Math.PI/2;if(i>0){const t=4*Math.sqrt(n/s*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*s;return this.calculateLengthSubdivisionStep(t,o)}}s("")}calculateAngularSubdivisionStep(t,n){if(!t.isCurve())return 1;if(t.getGeometryType()===e.enumEllipticArc){const e=t;return e.isDegenerate(0)||e.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,n*e.getSemiMinorAxis())}s("")}rationalBezier2NeedsSplit(t,e,s,n){t.cutBezierIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0}const r=ut(K,3);e.queryControlPoints(r);const o=[0,0,0];return e.queryWeights(o),!i&&this.m_maxDeviation>0&&(i=!Zh.checkRationalBezier2MaxDeviation(r,o,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Zh.checkRationalBezier2MaxAngle(r,o,this.m_cosMaxAngle)),i}bezier2NeedsSplit(t,e,s,n){t.cutBezierIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0}const r=ut(K,3);return e.queryControlPoints(r),!i&&this.m_maxDeviation>0&&(i=!Zh.checkBezier2MaxDeviation(r,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Zh.checkBezier2MaxAngle(r,this.m_cosMaxAngle)),i}ellipticArcNeedsSplit(t,e,s,n){t.cutArcIgnoreAttributes(s,n,e);let i=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return i=!0,!0}return!i&&this.m_maxDeviation>0&&(i=!Zh.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!Zh.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),i}bezierNeedsSplit(t){let e=!1;if(this.m_maxLength>0){if(K.distance(t[0],t[1])+K.distance(t[1],t[2])+K.distance(t[2],t[3])>this.m_maxLength)return e=!0,!0}return!e&&this.m_maxDeviation>0&&(e=!Zh.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!Zh.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const n=s.clone();n.leftPerpendicularThis(),n.normalize();const i=n.dotProduct(t[0].sub(t[1])),r=n.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(i),Math.abs(r))<=e){const e=new K;yo(t,.5,e,!1);const n=e.sub(t[0]).dotProduct(s);return n>=0&&n<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const n=t[1].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}{const n=t[2].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}{const n=t[2].sub(t[1]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const n=t[2].sub(t[0]);if(n.sqrLength()>0){const e=n.clone();e.leftPerpendicularThis(),e.normalize();const i=e.dotProduct(t[0].sub(t[1]));if(Math.abs(i)<=s){const e=t[1].sub(t[0]).dotProduct(n);return e>=0&&e<=n.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const n=t[2].sub(t[0]);n.normalize();{const e=t[1].sub(t[0]),i=e.dotProduct(n);if(i<0)return!1;if(e.length()*s>i)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const n=s.clone();n.leftPerpendicularThis(),n.normalize();const i=n.dotProduct(t[0].sub(t[1]));if(Math.abs(i)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const n=t[1].sub(t[0]),i=n.dotProduct(s);if(i<0)return!1;if(n.length()*e>i)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),n=[0,0];if(1===em(t,s,n)){const s=t.getCoord2D(n[0]),i=K.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),r=new K;Ct(t.getStartXY(),t.getEndXY(),i,r);return K.distance(s,r)<=e}}const s=t.getCoord2D(.5),n=new K;Ct(t.getEndXY(),t.getStartXY(),.5,n);return K.distance(s,n)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),n=t.getTangent(1),i=s.dotProduct(n);return!(i<0)&&!(s.length()*n.length()*e>i)}static checkTypeForReplace(t,s){return t.getGeometryType()===s&&(s!==e.enumEllipticArc||t.isCircular())}}function Hh(t,e,s){const n=s.length;if(e<=0||n<=2)return n;let i=0;const r=et(n-1,Number.NaN);for(let o=1,a=n;o<a;o++){const e=t.tToLength(s[o]);r[o-1]=e-i,i=e}for(;r.length>1;){const t=r.findIndex(t=>t<=2*e);if(-1===t)break;let n=t+1,i=t+1;if(t>0){const e=t-1;(i===r.length||r[e]>r[i])&&(i=e,n--)}r[i]+=r[t],r.splice(t,1),s.splice(n,1)}return s.length}function Uh(t,e,s,n,i){const r=[],o=[],a=Gh(e,s,0,n,!1,r,o),h=new ra;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new F,g=new fm;for(let d=0,_=0;d<a;d++){if(r[_+1].isNAN()){if(l){let t=o[d];e.queryCoord(t,c),g.setStart(c),t=o[d+1],e.queryCoord(t,c),g.setEnd(c)}g.setStartXY(r[_]),g.setEndXY(r[_+3]),t.addSegment(g,u)}else{if(l){let t=o[d];e.queryCoord(t,c),h.setStart(c),t=o[d+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setControlPoint2(r[_+2]),h.setEndXY(r[_+3]),t.addSegment(h,u)}_+=3,u=!1}}function Oh(t,e,s,n,i){const r=[],o=[],a=Wh(e,s,0,n,!1,r,o),h=new An;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new F,g=new fm;for(let d=0,_=0;d<a;d++){if(r[_+1].isNAN()){if(l){let t=o[d];e.queryCoord(t,c),g.setStart(c),t=o[d+1],e.queryCoord(t,c),g.setEnd(c)}g.setStartXY(r[_]),g.setEndXY(r[_+2]),t.addSegment(g,u)}else{if(l){let t=o[d];e.queryCoord(t,c),h.setStart(c),t=o[d+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setEndXY(r[_+2]),t.addSegment(h,u)}_+=2,u=!1}}function Qh(t,s,i,o,a){n(t===e.enumBezier||t===e.enumEllipticArc||t===e.enumBezier2);const h=s.createInstance();h.getGeometryType()===e.enumPolygon&&h.setFillRule(s.getFillRule());const u=s.querySegmentIterator();for(let m=0,l=s.getPathCount();m<l;++m){if(!s.hasNonLinearSegmentsPath(m)){h.addPath(s,m,!0);continue}const a=s.getPathStart(m);let l=!0,c=0;for(u.resetToPath(m),n(u.nextPath());u.hasNextSegment();){const n=u.nextCurve();if(!n)break;{const g=u.getStartPointIndex()-a,d=g-c;d>0&&(h.addSegmentsFromPath(s,m,c,d,l),l=!1),c=g+1,t===e.enumBezier?Uh(h,n,i,o,l):t===e.enumBezier2?Oh(h,n,i,o,l):r(""),l=!1}}const g=s.getSegmentCountPath(m);g-c!==0&&h.addSegmentsFromPath(s,m,c,g-c,l)}return h}function Jh(t,e,s,n,i,r,o,a){const h=e.clone();h.dropAllAttributes();const u=(t,e,s,n)=>(e&&(t&&e.push(n.getStartXY()),e.push(K.getNAN()),e.push(K.getNAN()),e.push(n.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(h.isDegenerateToLine()||h.isDegenerate(0))return u(t,r,o,e);const m=h.getStartXY(),l=h.getEndXY(),c=h.getSemiAxes(),g=new ce;if(h.isCircular())g.setIdentity();else{const t=h.getAxisXRotation();g.setScaleCoords(1,h.getMinorMajorRatio()),g.rotateAngle(t)}const d=h.getCenter();g.shift(d);const _=g.clone();_.invertThis(),h.applyTransformation(_);const p=h.getSweepAngle();if(0===p)return u(t,r,o,e);const f=le.constructEmpty();f.setCoords({center:d,width:2*c.x,height:2*c.x});const P=.05*f.calculateToleranceFromEnvelope(),y=Math.max(s/c.x,P/c.x);let x=4*Math.pow(y/.0741,1/6);x=Math.min(x,Math.PI/2);const C=Mh(h.getStartAngle());let v=p>0?Math.floor(C/x):Math.ceil(C/x);v*=x;const b=p>0?x:-x;v+b===C&&(v+=b);let S=4/3*Math.tan(Math.abs(x)/4);p>0&&(S=-S),o&&t&&o.push(0);const E=x/Math.abs(p);let D=(v-C)/p;const w=m.clone(),A=new K;h.queryCoord2D(0,A);const T=A.clone(),I=1-.01*E;let M=0,Y=0;for(;D<1;){let s;if(D+=E,Y>0&&D<I)s=S;else{D>=I&&(D=1);const t=(D-Y)*p;s=4/3*Math.tan(Math.abs(t)/4),p>0&&(s=-s)}h.queryCoord2D(D,A);const a=new K;g.queryTransform(A,a);const u=e.getClosestCoordinate(a,!1);if(e.queryCoord2D(u,a),1!==D&&(K.distance(w,a)<=2*n||K.distance(a,l)<=2*n))continue;w.setCoordsPoint2D(a);const c=ut(K,4);c[0].assign(T),c[3].assign(A),c[1].rightPerpendicularOther(T),c[1].scaleAddThis(s,T),c[2].leftPerpendicularOther(A),c[2].scaleAddThis(s,A),g.transformPoints2D(c,3,c),c[3].assign(a),0===Y&&c[0].setCoordsPoint2D(m),1===D&&c[3].setCoordsPoint2D(l),i&&go(c);let d=!0;for(let t=1;t<4;t++)if(!c[t].isEqualPoint2D(c[0])){d=!1;break}d||(o&&o.push(u),r&&(0===Y&&t&&r.push(c[0].clone()),r.push(c[1].clone()),r.push(c[2].clone()),r.push(c[3].clone())),M++),Y=D,T.setCoordsPoint2D(A)}return M}function Kh(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new le;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=ut(K,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=et(9,Number.NaN);let p=e.getMonotonicPartParams(_.length,_);_.length=p,p=Hh(e,n,_);let f=0,P=t;for(let y=1;y<p;y++){const t=_[y];for(d.push(f),d.push(t);d.length>1;){const t=d.at(-1);d.pop();const e=d.at(-1),s=ut(K,3);Ja(c,g,t,e,s,[0,0,0]);const n=ut(K,3),i=Ki(s,g,n),a=16,h=d.length>a;m>=i||h?(o.push(e),r&&(P&&(r.push(n[0]),P=!1),r.push(n[1]),r.push(n[2])),l++):(d.push(.5*(t+e)),d.push(t))}f=t}return l}function $h(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new le;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=ut(K,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=et(9,Number.NaN);let p=0;i?(p=e.getMonotonicPartParams(_.length,_),_.length=p,p=Hh(e,n,_)):(_.length=2,p=2,_[0]=0,_[1]=1);let f=0,P=t;for(let y=1;y<p;y++){const t=_[y];for(d.length=0,d.push(t),d.push(f);d.length>1;){const t=d.at(-1);d.pop();const e=d.at(-1),s=ut(K,3),n=[0,0,0];Ja(c,g,t,e,s,n);const i=ut(K,4),a=Ka(s,n,i),h=16,u=d.length>h;m>=a||u?(o.push(e),r&&(P&&(r.push(i[0]),P=!1),r.push(i[1]),r.push(i[2]),r.push(i[3])),l++):(d.push(.5*(t+e)),d.push(t))}f=t}return l}function tu(t,e,s,n,i,r,o,a){const h=e.clone();if(h.dropAllAttributes(),h.isDegenerateToLine()||0===h.getSweepAngle())return r&&(t&&r.push(e.getStartXY()),r.push(K.getNAN()),r.push(e.getEndXY())),o&&(t&&o.push(0),o.push(1)),1;const u=h.getStartXY(),m=h.getEndXY(),l=h.getSemiAxes(),c=new ce;if(h.isCircular())c.setIdentity();else{const t=h.getAxisXRotation();c.setScaleCoords(1,h.getMinorMajorRatio()),c.rotateAngle(t)}const g=h.getCenter();c.shift(g);const d=c.clone();d.invertThis(),h.applyTransformation(d);const _=le.constructEmpty();_.setCoords({center:g,width:2*l.x,height:2*l.x});const p=.05*_.calculateToleranceFromEnvelope(),f=Math.max(s/l.x,p/l.x),P=Math.sqrt(2*f+f*f);let y=2*Math.sqrt(2*P*(1+f-P));y=Math.min(y,Math.PI/2);const x=h.getSweepAngle(),C=Math.ceil(Math.abs(x)/y),v=Math.max(C,1);y=x/v;const b=1/v;let S=Math.tan(Math.abs(y)/2);x>0&&(S=-S),o&&t&&o.push(0);const E=new K;h.queryCoord2D(0,E);for(let D=0;D<v;D++){const e=E.clone(),s=(D+1)*b;if(o&&o.push(s),!r)continue;h.queryCoord2D(s,E);const n=ut(K,3);n[0].assign(e),n[2].assign(E),n[1].rightPerpendicularOther(n[0]),n[1].mulThis(S),n[1].addThis(n[0]),c.transformPoints2D(n,3,n),0===D&&n[0].setCoordsPoint2D(u),D===v-1&&n[2].setCoordsPoint2D(m),0===D&&t&&r.push(n[0]),r.push(n[1]),r.push(n[2])}return v}function eu(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new le;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=ut(K,4);e.queryControlPoints(c);const g=[],d=et(9,Number.NaN);let _=e.getMonotonicPartParams(d.length,d);d.length=_,_=Hh(e,n,d);let p=0,f=t;for(let P=1;P<_;P++){const t=d[P];for(g.push(p),g.push(t);g.length>1;){const t=g.at(-1);g.pop();const e=g.at(-1),s=ut(K,4);Po(c,t,e,s);const n=ut(K,3),i=Ji(s,n),a=16,h=g.length>a;m>=i||h?(o.push(e),r&&(f&&(r.push(n[0]),f=!1),r.push(n[1]),r.push(n[2])),l++):(g.push(.5*(t+e)),g.push(t))}p=t}return l}function su(){return{e2:0,completeE:0}}class nu{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?K.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function iu(t,e,s){if(Eu(t)){return void vs(new fm({start:t.getStartXY(),end:t.getEndXY()}),e,s)}if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const n=new rt;du(t,e,n);const i=new rt,r=new rt;rt.st_cosAndSin(n,i,r);const o=be.constructCoordsE(new rt(t.m_semiMajorAxis).mulThisE(i),new rt(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(r)),a=new rt(t.m_rotation);rt.st_cosAndSin(a,i,r),o.rotateDirect(i,r),o.addThisE(be.constructPoint2D(t.m_center)),s.setE(o)}}function ru(t,e){return t.convertToCanonic(e)}function ou(t,e){const s=new U(t.getStartAngle(),t.getEndAngle());s.normalize();const n=Gt(),i=Jt(e,n);if(i<s.vmin){let t=i+n;for(;t<s.vmin;)t+=n;return s.containsCoordinate(t)?t:s.vmin-i<t-s.vmax?i:t}if(i>s.vmax){let t=i-n;for(;t>s.vmax;)t-=n;return s.containsCoordinate(t)||s.vmin-t<i-s.vmax?t:i}return i}function au(t,e,s,n){let i=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;i>At();)i-=2*At();for(;i<=-At();)i+=2*At();if(!Number.isNaN(e)){for(;e>At();)e-=2*At();for(;e<=-At();)e+=2*At();!s&&e>i&&(e-=2*At()),s&&e<i&&(e+=2*At()),r=e-i,Math.abs(r)<o&&!n&&(r=s?2*At():-2*At()),Math.abs(r)>2*At()-o&&n&&(r=0)}Math.abs(r)>2*At()-o&&(r=r>=0?2*At():-2*At(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),n=Math.abs(r)<=At(),r&&(s=r>0),t.m_startAngle=hu(i),t.m_sweepAngle=r,Fu(t,!n),Xu(t,s)}function hu(t){let e=t,s=!1;return e<=-At()?(e+=Gt(),s=!0):e>At()&&(e-=Gt(),s=!0),e<=-At()?(e=Jt(e,Gt()),e<=-At()&&(e+=Gt()),s=!0):e>At()&&(e=Jt(e,Gt()),e>At()&&(e-=Gt()),s=!0),s&&(e>At()||e<=-At())&&(e=At()),e}function uu(t,e,s){const n=s,i=n.getSemiAxes();let r=new K(i.x*Math.cos(t[0]),i.y*Math.sin(t[0]));return r=n.convertFromCanonic(r),K.sqrDistance(r,n.getStartXY())}function mu(t,e,s){const n=s,i=n.getSemiAxes(),r=t[0]+n.getStartAngle();let o=new K(i.x*Math.cos(r),i.y*Math.sin(r));return o=n.convertFromCanonic(o),K.sqrDistance(o,n.getEndXY())}function lu(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),n=e.equals(s),i=Vu(t),r=qu(t),o=t.projectionBehavior();if(n){const s=t.convertToCanonic(e),n=new K(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=n.x,s.y/=n.y,t.m_startAngle=hu(Math.atan2(s.y,s.x)),t.m_sweepAngle=i?r?Gt():-Gt():0}else{const n=t.convertToCanonic(e),a=new K(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);n.x/=a.x,n.y/=a.y;const h=t.convertToCanonic(s);h.x/=a.x,h.y/=a.y,t.m_startAngle=Math.atan2(n.y,n.x),t.m_sweepAngle=K.calculateAngle(n,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=Gt()):t.m_sweepAngle>0&&(t.m_sweepAngle-=Gt()),t.m_startAngle=hu(t.m_startAngle);let u=uu([t.m_startAngle],1,t);if(u=Math.sqrt(u),u>.25*Oe(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,n=[0];on(uu,t,1,[t.m_startAngle],[e],[s],1e-14,n),t.m_startAngle=hu(n[0])}if(u=mu([t.m_sweepAngle],1,t),u=Math.sqrt(u),u>.25*Oe(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,n=[0];on(mu,t,1,[t.m_sweepAngle],[e],[s],1e-14,n),t.m_sweepAngle=n[0]}const m=Math.abs(t.m_sweepAngle)>At();if(Fu(t,m),i!==m&&!i&&Math.abs(t.m_sweepAngle)>1.5*At())return void Su(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void Su(t,e,s,o)}}function cu(t,e){return(ou(t,e)-t.getStartAngle())/t.getSweepAngle()}function gu(t,e){return t.m_startAngle+e*t.m_sweepAngle}function du(t,e,s){s.assign(new rt(t.m_startAngle).addE(e.mulE(new rt(t.m_sweepAngle))))}function _u(t,e){const s=new rt(t.m_cosr).sqrThis(),n=new rt(t.m_sinr).sqrThis(),i=new rt(t.m_minorMajorRatio),r=new rt(1/t.m_minorMajorRatio),o=i.mulE(s).addThisE(r.mulE(n)),a=i.subE(r).mulThis(2*t.m_cosr*t.m_sinr),h=i.mulE(n).addThisE(r.mulE(s));e[0]=o,e[1]=a,e[2]=h,e[3]=new rt(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function pu(t,e){const s=new Se;s.a11.setE(t[0]),s.a12=rt.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const n=[K.getNAN(),K.getNAN()],i=[new rt,new rt];s.eigenSymmetric(i,n);const r=t[3].clone();r.negateThis(),r.invThis(),i[0].mulThisE(r),i[1].mulThisE(r),i[0].sqrtThis().invThis(),i[1].sqrtThis().invThis(),e.x=i[0].toDouble(),e.y=i[1].toDouble();return Math.atan2(n[0].y,n[0].x)}function fu(t,e,s){if(Eu(t))return(s-e)*K.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const n=Du(t,e);return Du(t,s)-n}function Pu(t){return t.m_cachedValues}function yu(t){if(t.m_cachedValues)return t.m_cachedValues;const e=su();return e.e2=vu(t),e.completeE=Kt(e.e2),t.m_cachedValues=e,e}function xu(t,e,s,n){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Eu(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,Uu(t),void t.afterCompletedModification();if(n&&Math.abs(t.getSweepAngle())<=1.01*xt()){const n=ut(K,3),i=ku(t,n);if(Za(n)){n[0].assign(e),n[2].assign(s),Ua(n);if(0===t.projectionBehavior()){let e=0,s=2;K.sqrDistance(n[1],n[0])<K.sqrDistance(n[1],n[2])&&(s=Q(e,e=s));const i=n[s].sub(n[e]),r=i.length();i.divThis(r);const o=n[1].sub(n[e]),a=o.length(),h=o.dotProduct(i)/a,u=o.crossProduct(i)/a,m=new K;Ct(n[e],n[s],.5,m);const l=.5*r/u*gt(1-h,0,1),c=n[1].side(n[e],n[s]),g=i.clone();c?g.leftPerpendicularThis():g.rightPerpendicularThis();const d=m.sub(g.mul(l));t.constructCircularArcThreePoint(n[0],n[2],d)}else Gu(n,i*i,null,!1,t);return}}0===t.projectionBehavior()?im(t,e,s):rm(t,e,s)}}function Cu(t,e,s){const n=0===t.projectionBehavior();if(s<=2)return void Su(t,e[0],e[s-1],n?0:1);if(n){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const n=new K;return t.queryCoord2D(.5,n),void t.m_interior.setCoordsPoint2D(n)}const i=t.getSemiMajorAxis(),r=t.getMinorMajorRatio(),o=t.getAxisXRotation(),a=t.getCenter(),h=new Array(4);h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];const u=new Array(4);u[0]=t.isClockwise(),u[1]=u[0],u[2]=!u[0],u[3]=!u[0];const m=Math.trunc(s<5?1:(s+4)/5),l=ut(qh,4),c=et(4,Number.NaN);let g=0;for(let d=0;d<4;d++){l[d].constructEllipticArcEndPointsCenter(e[0],e[s-1],i,r,o,h[d],u[d],a),c[d]=0;let t=0;for(let n=m;n<s-1;n+=m){const s=l[d].getClosestCoordinate(e[n],!1);c[d]+=K.sqrDistance(l[d].getCoord2D(s),e[n]),t++}c[d]/=t,c[d]<c[g]&&(g=d)}t.assignCopy(l[g])}function vu(t){return 1-Bt(t.m_minorMajorRatio)}function bu(t,e,s,n,i,r,o,a,h){return t.m_bits=0,t.m_rotation=r,qe(t,e),Ve(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),Fu(t,o),Xu(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=n,t.m_minorMajorRatio=i,Bu(t,void 0===h)}function Su(t,e,s,n){t.m_bits=0,t.m_rotation=0,qe(t,e),Ve(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,Fu(t,!1),Xu(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(n),t.afterCompletedModification()}function Eu(t){return t.m_center.isNAN()}function Du(t,e){if(0===e)return 0;const s=yu(t),n=gu(t,e),i=xt(),r=Au(t),o=jt(n+i,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function wu(t,e){if(Eu(t)){const s=K.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const n=yu(t),i=xt(),r=Au(t);s<0&&(e=-e);const o=e/t.m_semiMajorAxis+r;let a=Zt(o,n.e2,n.completeE);a-=i,a-=t.getStartAngle();return a/s}function Au(t){const e=yu(t);return jt(t.getStartAngle()+xt(),e.e2,e.completeE)}function Tu(t,e,s,i,r){if(2===e.m_TransformationType)return void n(0);if(n(!Ru(t)),e.isIdentity()&&(!i||i.equals(t.getStartXY())&&r.equals(t.getEndXY())))return;Yu(t);let o=K.getNAN(),a=K.getNAN();if(null===i?(o.x=t.m_XStart,o.y=t.m_YStart,e.transformInPlace(o),a.x=t.m_XEnd,a.y=t.m_YEnd,e.transformInPlace(a)):(o=i,a=r),Eu(t))return t.m_XStart=o.x,t.m_YStart=o.y,t.m_XEnd=a.x,void(t.m_YEnd=a.y);const h=t.m_center.clone();if(e.transformInPlace(h),s||e.isUniformNoRotation()){let s=qu(t);e.isReflective()&&(s=!s);if(0===t.projectionBehavior()){if(!o.equals(a)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(o,a,s)}return void Iu(t,o,a,h,s,!1)}const n=new K(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(n);const i=Math.atan2(n.y,n.x),r=t.getSemiAxes();e.transformWithoutTranslateInPlace(r);const u=t.m_center.clone();return e.transformInPlace(u),void t.constructEllipticArcEndPointsCenter(o,a,r.x,r.y/r.x,i,t.isMajor(),s,u)}{{const s=new Array(4);_u(t,s);const n=new Se;n.a11.setE(s[0]),n.a12.setE(s[1]),n.a12.mulThisByPower2(.5),n.a21.setE(n.a12),n.a22.setE(s[2]);if(!n.det().isZero()){const i=new Se;if(i.a11.set(e.xx),i.a12.set(e.xy),i.a21.set(e.yx),i.a22.set(e.yy),i.invertThis()){const r=i.clone();r.transposeThis();const u=n.clone();u.mulThis(i),u.mulLeftThis(r);if(!u.det().isZero()){const n=ut(rt,4);n[0].setE(u.a11),n[1].setE(u.a12),n[1].mulThisByPower2(2),n[2].setE(u.a22),n[3].setE(s[3]);const i=K.getNAN(),r=pu(n,i);let m=qu(t);return e.isReflective()&&(m=!m),void t.constructEllipticArcEndPointsCenter(o,a,i.x,i.y/i.x,r,t.isMajor(),m,h)}}}}const s=[K.getNAN(),K.getNAN(),K.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let n=t.isClockwise();n&&(s[2]=Q(s[0],s[0]=s[2]));const i=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(n=!n);const r=new K(0,0),u=t.createInstance();Gu(s,i,r,!1,u),t.constructEllipticArcEndPointsCenter(o,a,u.getSemiMajorAxis(),u.getMinorMajorRatio(),u.getAxisXRotation(),t.isMajor(),!n,h)}}function Iu(t,e,s,n,i,r){const o=.5*(n.sub(e).length()+n.sub(s).length());t.m_center.assign(n),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x);au(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),i,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,n);return t.setProjectionBehavior(0),a}function Mu(t,e){t.m_cachedValues=e}function Yu(t){t.m_cachedValues=null}function Nu(t,e){e.m_cachedValues=Q(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function Xu(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function qu(t){return!!(1&t.m_bits)}function Fu(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function Vu(t){return!!(2&t.m_bits)}function Lu(t){if(t.m_center.isNAN())return!1;const e=8,s=new be;s.setWithEps(t.getStartXY(),e),s.subThisE((new be).setWithEps(t.m_center,e));const n=new rt;n.setWithEps(t.m_rotation,e);const i=new rt,r=new rt;rt.st_cosAndSin(n,i,r),s.rotateReverse(i,r);const o=new be;o.setWithEps(t.getEndXY()),o.subThisE(be.constructPoint2D(t.m_center)),o.rotateReverse(i,r);const a=new rt;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),u=new rt;u.setWithEps(t.m_minorMajorRatio),h.mulThisE(u),s.x.divThisE(a),s.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const m=s.x.sqr().addThisE(s.y.sqr()).subThisE(ot),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(ot);return!m.isZero()||!l.isZero()}function Ru(t){return!!(8&t.m_bits)}function zu(t){t.m_bits&=-9}function Bu(t,e){zu(t);const s=t.getStartXY(),i=t.getEndXY();let r=!1;const o=Vu(t),a=qu(t),h=t.projectionBehavior(),u=s.equals(i);let m=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:g("NAN minor major ratio and non-zero major axis")),m||=e?u:t.m_center.isNAN(),m)return Su(t,s,i,h),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const l=new K(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(n(l.y>0&&l.x>=l.y),u){const e=t.convertToCanonic(s);n(!l.isZero()),e.x/=l.x,e.y/=l.y;const i=Math.sqrt(Bt(e.x)+Bt(e.y));if(r=1!==i,t.m_semiMajorAxis*=i,l.mulThis(i),t.m_startAngle=hu(Math.atan2(e.y,e.x)),!o)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),r;t.m_sweepAngle=a?Gt():-Gt()}else{let e=t.m_center.isNAN()||Lu(t);if(!e){const n=t.convertToCanonic(s);n.x/=l.x,n.y/=l.y;const r=new K(1,0);t.m_startAngle=K.calculateAngle(r,n);const o=t.convertToCanonic(i);o.x/=l.x,o.y/=l.y,t.m_sweepAngle=K.calculateAngle(n,o),e=!ju(t)}if(e){r=!0;const e=s.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let n=Bt(e.x/l.x)+Bt(e.y/l.y);n>1&&(n=Math.sqrt(n),t.m_semiMajorAxis*=n,l.mulThis(n));const h=new K(0,0);{const t=l.x*l.x,s=l.y*l.y,n=t*e.y*e.y+s*e.x*e.x,i=t*s-n;if(i>0){const t=Math.sqrt(i/n);h.setCoords(l.x*e.y/l.y,-l.y*e.x/l.x),h.mulThis(t),o===a&&h.negateThis()}}{const e=new K(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(i).mulThis(.5)),t.m_center.assign(e)}}if(lu(t),!ju(t))return Su(t,s,i,h),!0}return Uu(t),t.afterCompletedModification(),r}function ku(t,e){n(Math.abs(t.getSweepAngle())<15*Math.PI/16);const s=t.getSemiMajorAxis(),i=t.getSemiMinorAxis();let r;if(0===s)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),r=1,r;if(0===i)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=K.lerp(e[0],e[2],.5),r=1,r;const o=t.getSweepAngle(),a=t.getStartAngle(),h=a+o,u=new K(-s*Math.sin(a),i*Math.cos(a)),m=new K(-s*Math.sin(h),i*Math.cos(h));u.normalize(),m.normalize(),u.rotateDirect(t.m_cosr,t.m_sinr),m.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const l=u.crossProduct(m);e[1].assign(u.mul(e[1].crossProduct(m)/l)),e[1].addThis(e[0]);return r=Math.cos(.5*o),r}function Gu(t,e,s,i,r){if(i){const s=.5,n=Math.sqrt(e),i=Bt(1-s)+2*n*s*(1-s)+Bt(s),o=t[0].mul(Bt(1-s)).add(t[1].mul(2*n*s*(1-s))).add(t[2].mul(Bt(s))).divThis(i);return r.constructCircularArcThreePoint(t[0],t[2],o),!0}const o=t[0].sub(t[1]),a=t[2].sub(t[1]),h=o.crossProduct(a),u=o.dotProduct(a),m=e;n(m<=1),n(m>0);const l=.5/(1-m),c=o.sqrLength(),g=u,d=a.sqrLength(),_=Bt(h),p=o.sub(a).sqrLength();if(0===_)return Su(r,t[0],t[2],1),!1;if(u<=-Math.sqrt(c)*Math.sqrt(d))return Su(r,t[0],t[2],1),!1;const f=[0,0],P=new U;P.setInfinite();const y=nn(2*_,-(p/m+4*g),2*(1-m)/m,P,!1,f);if(0===y)return Su(r,t[0],t[2],1),!1;1===y&&(f[1]=f[0]);const x=Math.sqrt(l/f[0]),C=Math.sqrt(l/f[1]),v=.5/m;let b=v-d*f[0],S=v-c*f[0];Math.abs(b)>Math.abs(S)?S=g*f[0]-v+1:b=g*f[0]-v+1;const E=o.mul(b).add(a.mul(S)),D=E.norm(1)<1e-15*x?0:Math.atan2(E.y,E.x)+Math.PI,w=o.add(a),A=s?s.clone():t[1].add(w.mul(l)),T=t[0].sub(A),I=t[2].sub(A),M=T.crossProduct(I)<0,Y=!1;new qh;return r.constructEllipticArcEndPointsCenter(t[0],t[2],x,C/x,D,Y,!M,A)}function Wu(t,e,s,n,i){return Gu(t,e,s,n,i)}function ju(t){const e=Oe(t);let s=!1;{const n=new K(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));n.rotateDirect(t.m_cosr,t.m_sinr),n.addThis(t.m_center);s=K.distance(t.getStartXY(),n)>e}let n=!1;if(!s){const s=new K(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center);n=K.distance(t.getEndXY(),s)>e}return!s&&!n}function Zu(e,s,n,i){0===n&&t("construct_enclosing_circle");const o=[0,0,0],a=Vh(s,n,o);if(1===a)e.constructCircleRadius(0,s[o[0]],i);else if(2===a){const t=K.lerp(s[o[0]],s[o[1]],.5),n=K.distance(s[o[0]],t),r=K.distance(s[o[1]],t);e.constructCircleRadius(Math.max(n,r),t,i)}else if(3===a){const t=K.calculateCircleCenterFromThreePoints(s[o[0]],s[o[1]],s[o[2]]),n=K.distance(s[o[0]],t),r=K.distance(s[o[1]],t),a=K.distance(s[o[2]],t);e.constructCircleRadius(Math.max(n,r,a),t,i)}else r("unexpected")}function Hu(t){if(Eu(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),n=e*e+s*s,i=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let u=1,m=0;t.m_rotation&&(u=(a-h)*(a+h),m=2*a*h);const l=((-.5*(r-i)+.25*u*(2*Math.cos(r+i)*Math.sin(r-i)))*s+-2*Math.sin(.5*(r+i))*Math.sin(.5*(r-i))*a*o)*e/n;let c=0;if(t.m_rotation){c=.125*(-2*Math.sin(r+i)*Math.sin(r-i))*m-s*o/n*(2*Math.cos(.5*(r+i))*Math.sin(.5*(r-i)))*h}return n*(l+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function Uu(t){t.queryCoord2D(.5,t.m_interior)}function Ou(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==Ju(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Qu(t,e,s,n,i){if(i){if(0!==hm(e,s))return 2}else if(Te(e,s))return 1;return 0!==Ku(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Ju(t,e,s,i,r,o,a,h,u,m){if(Eu(e)){return ws(new fm({start:e.getStartXY(),end:e.getEndXY()}),s,i,r,o,a,h,m)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0);const l=Qe(e,s);if(Je(e,s,a=Math.max(l,a)))return 0;const c=s.getStartXY();c.subThis(e.m_center);const g=s.getEndXY();g.subThis(e.m_center),c.rotateReverse(e.m_cosr,e.m_sinr),g.rotateReverse(e.m_cosr,e.m_sinr);const d=g.clone();d.subThis(c);const _=e.m_semiMajorAxis,p=1/_,f=e.getSemiMinorAxis(),P=1/f,y=d.clone();y.leftPerpendicularThis();const x=Math.atan2(f*y.y,_*y.x),C=et(16,Number.NaN),v=et(16,Number.NaN);let b=0;const S=[x,x+Math.PI];for(let n=0;n<2;++n){const t=cu(e,S[n]);if(t>=0&&t<=1){C[b]=t;const n=e.getCoord2D(C[b]);v[b]=s.getClosestCoordinate(n,!1),K.distance(n,s.getCoord2D(v[b]))<=a&&b++}}const E=c.x*p,D=c.y*P,w=d.x*p,A=d.y*P;let T=nn(w*w+A*A,2*(E*w+D*A),E*E+D*D-1,U.unit(),!1,v);n(T>=0);for(let n=0;n<T;n++){const t=d.mul(v[n]).add(c);t.x*=p,t.y*=P;const i=cu(e,Math.atan2(t.y,t.x));if(i>=0&&i<=1){C[b]=i;const t=e.getCoord2D(i);v[b]=s.getClosestCoordinate(t,!1),K.distance(t,s.getCoord2D(v[b]))<=a&&b++}}n(b<C.length+4);const I=et(16,Number.NaN);T=e.intersectPoint(s.getStartXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=I[n],v[b]=0;T=e.intersectPoint(s.getEndXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=I[n],v[b]=1;T=s.intersectPoint(e.getStartXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=0,v[b]=I[n];T=s.intersectPoint(e.getEndXY(),I,a);for(let n=0;n<T;n++,b++)C[b]=1,v[b]=I[n];return 0===b?0:gm(t,e,s,C,v,b,i,r,o,a,h,u,m)}function Ku(t,e,s,i,r,o,a,h,u,m){if(Eu(e)){const n=new fm({start:e.getStartXY(),end:e.getEndXY()});return Ju(t,s,n,i,o,r,a,h,u,!m)}if(Eu(s)){const n=new fm({start:s.getStartXY(),end:s.getEndXY()});return Ju(t,e,n,i,r,o,a,h,u,m)}const l=Qe(e,s);a=Math.max(a,l);let c=!1;{const t=e.getSemiAxes(),i=e.getCenter(),m=s.getSemiAxes(),l=s.getCenter(),g=K.distance(l,i),d=t.x+m.x;if(g>d+a)return 0;if(t.y>m.x){if(g+m.x+a<t.y)return 0}else if(m.y>t.x&&g+t.x+a<m.y)return 0;if(u&&!h){const i=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),a=1===s.m_minorMajorRatio&&s.isClosed()&&s.isMajor();if(i&&a&&(c=!0,g<=d)){if(Math.max(t.x,m.x)<=Math.min(t.x,m.x)+g)return n(!r&&!o),1}}}if(!c&&Je(e,s,a))return 0;const g=[],d=[],_=!1,p=!1,f=jh(e,0,0,_,p,g,d,null),P=[],y=[],x=jh(s,0,0,_,p,P,y,null);if(1===f&&1===x){const t=new Dn({points:g,weights:d}),n=new Dn({points:P,weights:y}),l=[],c=[],_=oh(!1,t,n,i,null===r?null:l,null===o?null:c,a,h,u,m);if(_>0&&null!==r||null!==o){r&&(r.length=0),o&&(o.length=0);for(let i=0;i<_;++i){if(r)if(lt(l[i],0,1))r.push(l[i]);else{const s=t.tToLength(l[i]),n=e.lengthToT(s);r.push(n)}if(o)if(lt(c[i],0,1))o.push(c[i]);else{const t=n.tToLength(c[i]),e=s.lengthToT(t);o.push(e)}}}return _}let C=[];const v=[];let b=0;const S=u&&!h;for(let n=0;n<f;n++){const t=new Dn({points:g.slice(2*n,2*n+3),weights:d.slice(2*n,2*n+3)});let i=0;for(let r=0;r<x;r++){v.length<=r&&v.push(new Dn({points:P.slice(2*r,2*r+3),weights:y.slice(2*r,2*r+3)}));const o=[],h=[],u=S?null:o,m=S?null:h,l=oh(!1,t,v[r],null,u,m,a,!1,S,!1);if(l>0&&S)return 1;for(let a=0;a<l;++a){if(0===o[a]&&0===n)o[a]=0;else if(1===o[a]&&n===f-1)o[a]=1;else{const s=t.tToLength(o[a])+b,n=e.lengthToT(s);o[a]=n}if(0===h[a]&&0===r)h[a]=0;else if(1===h[a]&&r===x-1)h[a]=1;else{const t=v[r].tToLength(h[a])+i,e=s.lengthToT(t);h[a]=e}C.push(Yt(o[a],h[a]))}i+=v[r].calculateLength2D()}b+=t.calculateLength2D()}if(0===C.length)return 0;if(h&&(C=C.filter(t=>!lt(t.first,0,1)||!lt(t.second,0,1)||!e.getCoord2D(t.first).equals(s.getCoord2D(t.second)))),u)return C.length;const E=[],D=[];for(const n of C)E.push(n.first),D.push(n.second);return gm(t,e,s,E,D,E.length,i,r,o,a,h,u,m)}function $u(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Eu(t))return;const n=t.getSemiAxes(),i=[0,0,0,0];{const e=Math.atan2(-n.y*t.m_sinr,n.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(n.y*t.m_cosr,n.x*t.m_sinr),o=r+Math.PI;i[0]=cu(t,e),i[1]=cu(t,s),i[2]=cu(t,r),i[3]=cu(t,o)}const r=new K;for(let o=0;o<4;o++){const n=i[o];e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,r),s.mergeNe(r))}}function tm(t,e,s,i,r){if(0===t.m_semiMajorAxis)return s.vmin;let o=K.getNAN();t.queryCoord2D(s.vmin,o);let a=K.getNAN();if(t.queryCoord2D(s.vmax,a),Eu(t)){return new fm({start:o,end:a}).getClosestCoordinate(e,i)}const h=ru(t,e);if(o=ru(t,o),a=ru(t,a),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return s.vmin;const e=cu(t,Math.atan2(h.y,h.x));if(i||s.containsCoordinate(e))return e;return K.distance(h,o)<=K.distance(h,a)?s.vmin:s.vmax}const u=t.getSemiMajorAxis(),m=t.getSemiMinorAxis(),l=(u-m)*(u+m),c=Bt(l),g=h.x,d=h.y,_=Bt(m*d),p=m*l*d*2,f=[new rt(_),new rt(p),new rt(c-Bt(u*g)-_),new rt(-p),new rt(-c)],P=ut(rt,4),y=pn(f,4,new U(-1,1),!1,P,4);let x=s.vmin,C=K.sqrDistance(h,o);{const t=K.sqrDistance(h,a);t<C&&(x=s.vmax,C=t)}n(!i);let v=et(8,Number.NaN);for(let n=0;n<y;++n){const e=P[n].value(),s=Math.sqrt(1-e*e),i=Math.atan2(e,s),r=Math.atan2(e,-s);v[2*n]=cu(t,i),v[2*n+1]=cu(t,r)}v=v.slice(0,2*y),Wt(v);for(let n=0,b=2*y;n<b;++n)if(v[n]>s.vmin&&v[n]<s.vmax){const s=K.sqrDistance(e,t.getCoord2D(v[n]));C>s&&(C=s,x=v[n])}return x}function em(t,e,s){n(!Eu(t));const i=new ce;i.setRotateAngle(-t.getAxisXRotation());const r=new K;i.queryTransform(e,r);const o=Math.atan2(-r.x*t.getMinorMajorRatio(),r.y),a=o+At();let h=cu(t,o),u=cu(t,a);u<h&&(u=Q(h,h=u));let m=0;return h>=0&&h<=1&&(s[m++]=h),u>=0&&u<=1&&(s[m++]=u),m}function sm(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&(t.isMajor()!==e.isMajor()&&(!!t.m_center.equals(e.m_center)&&(t.m_sinr===e.m_sinr&&(t.m_cosr===e.m_cosr&&(t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise()))))))}function nm(t,e,s){if(Eu(t))s.setE(be.constructPoint2D(t.getEndXY()).subE(be.constructPoint2D(t.getStartXY())));else{const n=new rt;du(t,e,n);const i=new be;if(i.setCoordsE(new rt(t.m_semiMajorAxis).negate().mulE((new rt).setSin(n)),new rt(t.getSemiMinorAxis()).mulE((new rt).setCos(n))),t.m_rotation){const e=new rt(t.m_rotation);i.rotateDirect((new rt).setCos(e),(new rt).setSin(e))}i.scaleThis(new rt(t.getSweepAngle())),s.setE(i)}}function im(t,e,s,n){const i=t.getStartXY(),r=t.getEndXY(),o=i.equals(r),a=e.equals(s);if(!o&&!a){const n=new ce;n.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=K.distance(e,s),a=K.distance(i,r),h=o/a;n.scale(h,h);const u=r.sub(i);u.divThis(a);const m=s.sub(e);m.divThis(o);const l=u.crossProduct(m),c=m.dotProduct(u);return n.rotate(c,l),n.shiftCoords(e.x,e.y),void Tu(t,n,!0,e,s)}const h=new K;if(t.queryCoord2D(.5,h),a){if(o){const n=t.m_center.add(e.sub(i));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),n),t.setProjectionBehavior(0)}else if(t.isMajor()){const n=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,n)}else t.constructCircularArcThreePoint(e,s,e);return}const u=e.add(s).mul(.5),m=s.sub(e);m.rightPerpendicularThis();const l=u.add(m),c=K.getClosestCoordinate(u,l,t.getCenter(),!0),g=new K;Ct(u,l,c,g);const d=K.distance(e,g);t.constructEllipticArcEndPointsCenter(e,s,d,1,0,!0,!t.isClockwise(),g),t.setProjectionBehavior(0)}function rm(t,e,s,i){const r=t.getStartXY(),o=t.getEndXY(),a=r.equals(o),h=e.equals(s);if(!a&&!h){const n=new ce;return n.initializeFromTwoPoints(r,o,e,s),Tu(t,n,!0,e,s),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void Su(t,e,s,1);if(a&&h){const n=t.m_center.add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),n)}if(!a){const n=.5*(Gt()-Math.abs(t.getSweepAngle())),i=(t.getSweepAngle()+n*Xt(t.getSweepAngle()))/t.getSweepAngle(),r=new K;t.queryCoord2D(i,r),t.constructEllipticArcEndPointsCenter(r,r,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const o=t.getCenter().add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),o)}const u=K.sqrDistance(e,s);let m=.25,l=.75;if(u<K.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],s=en(new nu(t,u),U.construct(0,.25),1,e);s>0&&(n(1===s),m=e[0],l=1-e[0])}const c=t.getCoord2D(m),g=t.getCoord2D(l);n(!c.equals(g)),t.constructEllipticArcEndPointsCenter(c,g,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),rm(t,e,s)}function om(t,e,s,n,i){return am(t,!1,e,s,n,i)}function am(t,s,n,i,o,a){const h=n.getGeometryType(),u=i.getGeometryType(),m=Math.max(o,Qe(n,i));if(h===e.enumLine&&u===e.enumLine)return Ds(n,i,m,a);let l=n,c=i,g=n.getStartXY(),d=n.getEndXY();if(g.compare(d)>0&&(l=n.clone().reverse()),g=i.getStartXY(),d=i.getEndXY(),g.compare(d)>0&&(c=i.clone().reverse()),s){if(n.equals(i))return 2;if(Xe(n,i,m))return 4}switch(h){case e.enumLine:switch(u){case e.enumEllipticArc:return Ou(t,c,l,m,a);case e.enumBezier:return Eo(t,c,l,m,a);case e.enumRationalBezier2:return th(t,c,l,m,a);case e.enumBezier2:return qi(t,c,l,m,a);default:r("")}break;case e.enumEllipticArc:switch(u){case e.enumLine:return Ou(t,l,c,m,a);case e.enumEllipticArc:return Qu(t,l,c,m,a);case e.enumBezier:return Do(t,c,l,m,a);case e.enumRationalBezier2:return eh(t,c,l,m,a);case e.enumBezier2:return Fi(t,c,l,m,a);default:r("")}break;case e.enumBezier:switch(u){case e.enumLine:return Eo(t,l,c,m,a);case e.enumEllipticArc:return Do(t,l,c,m,a);case e.enumBezier:return wo(t,l,c,m,a);case e.enumRationalBezier2:return Ao(t,l,c,m,a);case e.enumBezier2:return To(t,l,c,m,a);default:r("")}break;case e.enumRationalBezier2:switch(u){case e.enumLine:return th(t,l,c,m,a);case e.enumEllipticArc:return eh(t,l,c,m,a);case e.enumBezier:return Ao(t,c,l,m,a);case e.enumRationalBezier2:return sh(t,l,c,m,a);case e.enumBezier2:return nh(t,l,c,m,a);default:r("")}break;case e.enumBezier2:switch(u){case e.enumLine:return qi(t,l,c,m,a);case e.enumEllipticArc:return Fi(t,l,c,m,a);case e.enumBezier:return To(t,c,l,m,a);case e.enumRationalBezier2:return nh(t,c,l,m,a);case e.enumBezier2:return Vi(t,l,c,m,a);default:r("")}break;default:r("")}}function hm(t,s,n=!0){if(!n&&!um(t,s))return 0;const i=t.isLine()&&s.isLine();if(t.getStartXY().equals(s.getStartXY())&&t.getEndXY().equals(s.getEndXY())){const n=1;if(i)return n;const r=t.getGeometryType();if(r!==s.getGeometryType())return 0;if(r===e.enumBezier){const e=t,i=s;return e.getControlPoint1().equals(i.getControlPoint1())&&e.getControlPoint2().equals(i.getControlPoint2())?n:0}if(r===e.enumEllipticArc){return sm(t,s,!1)?n:0}if(r===e.enumRationalBezier2){const e=t,i=s;if(e.getControlPoint1().equals(i.getControlPoint1())&&e.getStandardFormWeight()===i.getStandardFormWeight())return n}else if(r===e.enumBezier2){const e=s;if(t.getControlPoint1().equals(e.getControlPoint1()))return n}return 0}if(t.getStartXY().equals(s.getEndXY())&&t.getEndXY().equals(s.getStartXY())){const n=-1;if(i)return n;const r=t.getGeometryType();if(r!==s.getGeometryType())return 0;if(r===e.enumBezier){const e=t,i=s;return e.getControlPoint1().equals(i.getControlPoint2())&&e.getControlPoint2().equals(i.getControlPoint1())?n:0}if(r===e.enumEllipticArc){return sm(t,s,!0)?n:-1}if(r===e.enumRationalBezier2){const e=t,i=s;if(e.getControlPoint1().equals(i.getControlPoint1())&&e.getStandardFormWeight()===i.getStandardFormWeight())return n}else if(r===e.enumBezier2){const e=s;if(t.getControlPoint1().equals(e.getControlPoint1()))return n}return 0}return 0}function um(t,s){const n=t.getGeometryType();return n===s.getGeometryType()&&(n!==e.enumEllipticArc||t.projectionBehavior()===s.projectionBehavior())}function mm(s,n,i,o,a,h,u){!a&&h&&t("");const m=n.getGeometryType(),l=i.getGeometryType(),c=Math.max(u,Qe(n,i));if(o&&(o.length=0),a&&(a.length=0),h&&(h.length=0),m===e.enumLine&&l===e.enumLine)return ws(n,i,o,a,h,c,!1,!1);let g=n,d=i,_=n.getStartXY(),p=n.getEndXY(),f=!1,P=!1;_.compare(p)>0&&(g=n.clone(!0).reverse(),f=!0),_=i.getStartXY(),p=i.getEndXY(),_.compare(p)>0&&(d=i.clone(!0).reverse(),P=!0);let y=0;switch(m){case e.enumLine:switch(l){case e.enumEllipticArc:y=Ju(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier:y=Io(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=ih(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier2:y=Li(s,d,g,o,h,a,c,!1,!1,!0);break;default:r("")}break;case e.enumEllipticArc:switch(l){case e.enumLine:y=Ju(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=Ku(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=Mo(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=rh(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier2:y=Ri(s,d,g,o,h,a,c,!1,!1,!0);break;default:r("")}break;case e.enumRationalBezier2:switch(l){case e.enumLine:y=ih(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=rh(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=No(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=oh(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier2:y=ah(s,g,d,o,a,h,c,!1,!1,!1);break;default:r("")}break;case e.enumBezier2:switch(l){case e.enumLine:y=Li(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=Ri(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=Xo(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumRationalBezier2:y=ah(s,d,g,o,h,a,c,!1,!1,!0);break;case e.enumBezier2:y=zi(s,g,d,o,a,h,c,!1,!1,!1);break;default:r("")}break;case e.enumBezier:switch(l){case e.enumLine:y=Io(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumEllipticArc:y=Mo(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier:y=Yo(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumRationalBezier2:y=No(s,g,d,o,a,h,c,!1,!1,!1);break;case e.enumBezier2:y=Xo(s,g,d,o,a,h,c,!1,!1,!1);break;default:r("")}break;default:r("")}if(f){if(a){for(let t=0;t<y;t++)a[t]=1-a[t];a.reverse()}o&&o.reverse(),h&&h.reverse()}if(P&&h)for(let t=0;t<y;t++)h[t]=1-h[t];return y}function lm(t,e,s){if(e===s)return 0;e>s&&(s=Q(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function cm(t,e,s,n,i){const r=[],o=[],a=[];for(let u=0,m=i;u<m;u++)r.push(t.calculateSubLengthFromStart(s[u])),o.push(e.calculateSubLengthFromStart(n[u])),lt(s[u],0,1)&&lt(n[u],0,1)&&t.getCoord2D(s[u]).equals(e.getCoord2D(n[u]))&&a.push(u);if(0===a.length||a.length===i)return;a.sort((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:n[t]<n[e]?-1:n[t]>n[e]?1:0);let h=-1;for(const u of a){if(h>=0&&s[u]===s[h]&&s[u]===s[h]){h=u;continue}h=u;const a=[];a.length=i;for(let t=0;t<a.length;++t)a[t]=t;a.sort((t,e)=>{const s=r[u],n=o[u],i=r[t]-s,a=o[t]-n,h=i*i+a*a,m=r[e]-s,l=o[e]-n,c=m*m+l*l;return h<c?-1:h>c?1:0});for(let r=0;r<i;r++){const i=a[r];if(i===u||s[i]===s[u]&&n[i]===n[u]||lt(s[i],0,1)&&lt(n[i],0,1))continue;const o=(s,n,i,r)=>{const o=new be,a=new rt;a.setWithEps(1);const h=new rt;h.set(n,a.eps()),t.queryCoord2DE(h,o);const u=new be;t.queryCoord2DE(new rt(s),u);let m=!1;return o.eq(u)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new rt(i),u),m=o.eq(u)),!m},h=K.getNAN();t.queryCoord2D(s[i],h);const m=K.getNAN();e.queryCoord2D(n[i],m);if(0===K.distance(h,m)&&o(s[u],s[i],n[u],n[i]))break;const l=new U(n[i],n[u]);l.normalizeNoNAN();const c=new U(s[i],s[u]);c.normalizeNoNAN();let g=-1,d=Number.POSITIVE_INFINITY,_=Number.POSITIVE_INFINITY,p=s[i];h.assign(t.getCoord2D(p));for(let r=0;r<5;r++){const r=e.getClosestCoordinateOnInterval(h,l,-1);m.assign(e.getCoord2D(r));const a=K.distance(h,m);if(p=t.getClosestCoordinateOnInterval(m,c,-1),p===s[u]&&r===n[u]){g=1;break}h.assign(t.getCoord2D(p));const f=K.distance(m,h);if(!(f<_&&a<d)){g=0;break}if(0===f&&0===a){o(s[u],s[i],n[u],n[i])?(s[i]=p,n[i]=r,g=0):g=1;break}_=f,d=a}if(-1===g&&(g=lt(s[i],0,1)||lt(n[i],0,1)?0:1),1!==g)break;s[i]=s[u],n[i]=n[u]}}}function gm(t,e,s,n,i,r,o,a,h,u,m,l,c){if(!r)return 0;const g=(t,e)=>{for(let s=0;s<r;++s){let n=e[s];if(lt(n,0,1)){n=ie(n);continue}const i=t.getCoord2D(n);n<.5?i.equals(t.getStartXY())&&lm(t,0,n)<=Oe(t)&&(e[s]=0):i.equals(t.getEndXY())&&lm(t,n,1)<=Oe(t)&&(e[s]=1)}};g(e,n),g(s,i),cm(e,s,n,i,r);const d=[];for(let f=0,P=r;f<P;f++)d.push(f);const _=(t,e)=>c?re(i[t],n[t],i[e],n[e]):re(n[t],i[t],n[e],i[e]);if(d.length>1){d.sort(_);const t=Math.max(Oe(e),Oe(s));let r=0;for(let o=1,a=d.length;o<a;o++){const a=n[d[r]],h=n[d[o]],u=i[d[r]],m=i[d[o]];if(a!==h||u!==m){if(lm(e,a,h)<=t&&lm(s,u,m)<=t&&!(lt(a,0,1)&&lt(u,0,1)||lt(h,0,1)&&lt(m,0,1))){const t=K.distance(e.getCoord2D(a),s.getCoord2D(u)),n=K.distance(e.getCoord2D(h),s.getCoord2D(m));if(t<=n)continue;if(n<t){d[r]=d[o];continue}continue}r++,d[r]=d[o]}}if(d.length=r+1,1===d.length&&0!==d[0]&&(n[0]=n[d[0]],i[0]=i[d[0]],d[0]=0),d.length>2){const t=U.constructEmpty(),r=U.constructEmpty();t.setCoords(n[d[0]],n[d.at(-1)]),r.setCoords(i[d[0]],i[d.at(-1)]);let o=!0;for(let e=1,s=d.length-1;e<s;e++)if(!t.containsCoordinate(n[d[e]])||!r.containsCoordinate(i[d[e]])){o=!1;break}if(o){const n=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let i=0;i<n.length;i++){let a=nt(t.vmin,t.vmax,n[i]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,u)){o=!1;break}a=nt(r.vmin,r.vmax,n[i]);const m=s.getCoord2D(a);if(!e.isCloserThanDistance(m,t,u)){o=!1;break}}}o&&(d[1]=d.at(-1),d.length=2)}}if(1===d.length&&t){const t=0,r=0;Ne(e,s,n[0],i[0],u,1,[t],[r])&&(d.push(1),n[1]=t,i[1]=r,d.sort(_))}if(m&&1===d.length){let t=!0;for(let r=0,o=d.length;r<o;r++){if(lt(n[d[r]],0,1)&&lt(i[d[r]],0,1)){if(0===K.distance(e.getCoord2D(n[d[r]]),s.getCoord2D(i[d[r]])))continue}t=!1;break}if(t)return 0}let p=0;for(let f=0,P=d.length;f<P;f++){if(a&&a.push(n[d[f]]),h&&h.push(i[d[f]]),o){const t=K.getNAN();e.queryCoord2D(n[d[f]],t),o.push(t)}p++}return p}function dm(t,e,s,n,i,r,o,a,h){if(lt(s,0,1)&&lt(n,0,1)){if(0===K.distance(t.getCoord2D(s),e.getCoord2D(n))){const u=1e-12,m=new be,l=Number.EPSILON;if(t.queryDerivative(new rt(s,l),m),m.isTrueZero()){const e=1===s?-u:u;t.queryDerivative(new rt(s,l).add(e),m)}1===s&&m.negateThis();const c=new be;if(e.queryDerivative(new rt(n,l),c),c.isTrueZero()){const t=1===s?-u:u;e.queryDerivative(new rt(n,l).add(t),c)}1===n&&c.negateThis(),m.isZero()||m.normalize(),c.isZero()||c.normalize();const g=m.dotProduct(c),d=m.crossProduct(c);d.scaleError(3);const _=()=>{if(h)return.001;{const s=t.calculateUpperLength2D(),n=e.calculateUpperLength2D();return Math.min(.01*i/Math.min(s,n),1e-10)}};if(g.ge(at)&&(d.isZero()||Math.abs(d.value())<_())){return Ye(t,e,s,n,i,r,o,a)}}}return 0}function _m(t,e,s,i,r){let o=-1,a=-1,h=-1,u=-1;{const n=[0,e],r=[e,0],m=[0,i],l=[i,0];for(let e=0;e<2&&-1===o;++e)for(let i=0;i<2;++i)if(t[n[e]].equals(s[m[i]])){o=n[e],a=r[e],h=m[i],u=l[i];break}}if(-1===o){const n=new fe;n.setFromPoints(t,e+1);const o=new fe;return o.setFromPoints(s,i+1),o.inflate(r),n.isIntersectingW(o)?-1:0}{const m=et(e+1,Number.NaN),l=Cr(t,e+1,m);n(l>1);let c=0,g=0;for(let t=0;t<l;++t)o===m[t]&&(g=t,c++),a===m[t]&&c++;if(2!==c)return-1;const d=et(i+1,Number.NaN),_=Cr(s,i+1,d);n(_>1),c=0;let p=0;for(let t=0;t<_;++t)h===d[t]&&(p=t,c++),u===d[t]&&c++;if(2!==c)return-1;const f=t[m[(g+l-1)%l]],P=t[m[(g+1)%l]],y=s[d[(p+_-1)%_]],x=s[d[(p+1)%_]],C=t[o],v=[f,P,y,x],b=[0,1,2,3];b.sort((t,e)=>K.compareVectorsOrigin(C,v[t],v[e]));let S=b[0];for(let t=1;t<4;t++){if(b[t]!==(S+1)%4)return-1;S=b[t]}{const t=f.sub(C),e=x.sub(C),s=e.dotProduct(t);if(s>0){const n=e.crossProduct(t),i=Math.abs(Math.atan2(n,s)),o=i*t.length(),a=i*e.length();if(o<=r||a<=r)return-1}}{const t=P.sub(C),e=y.sub(C),s=e.dotProduct(t);if(s>0){const n=e.crossProduct(t),i=Math.abs(Math.atan2(n,s)),o=i*t.length(),a=i*e.length();if(o<=r||a<=r)return-1}}return 1}}var pm=b;class fm extends _s{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return n(0),0}calculateUpperLength3D(){return n(0),0}changeEndPoints3D(t,e){n(0)}getClosestCoordinate3D(t,e,s){return n(0),0}getBoundary(){return $s(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?Ps(this,t):ys(this,t);const n=pm.getInterpolation(e),i=this.getStartAttributeAsDbl(e,s),r=this.getEndAttributeAsDbl(e,s);return vt(n,i,r,t,pm.getDefaultValue(e))}constructFromCoords(t,e,s,n){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,n)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){n(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return fm.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=le.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let s=1,n=this.m_description.getAttributeCount();s<n;s++){const e=this.m_description.getSemantics(s);for(let n=0,i=pm.getComponentCount(e);s<i;s++){const s=this.queryInterval(e,n);t.setIntervalEnvelope(e,n,s)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,je(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,je(this,1,1,0))):s("env type not impl")}applyTransformation(t){n(t instanceof ce);const e=new K;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new fm({vd:this.m_description})}calculateLength2D(){return Math.sqrt(qs(this))}calculateLength3D(t){return n(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return n(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return ps(this,t,e)}queryCoord3D(t,e){n(0)}getCoordZ(t){return xs(this,t)}queryCoord2DE(t,e){vs(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());const s=Ee.constructPoint2D(this.getEndXY());s.subThis(e),s.mulThis(tt.constructDouble(t)),e.addThis(s)}getCoordX(t){return Ps(this,t)}getCoordY(t){return ys(this,t)}cut(t,e,s){const n=new Pm;return this.queryCut(t,e,n,s),n.releaseSegment()}queryCut(t,e,s,n){const i=s.createLine();n&&i.assignVertexDescription(this.m_description);const r=K.getNAN();if(ps(this,t,r),i.setStartXYCoords(r.x,r.y),ps(this,e,r),i.setEndXYCoords(r.x,r.y),!n)for(let o=1,a=this.m_description.getAttributeCount();o<a;o++){const s=this.m_description.getSemantics(o),n=pm.getComponentCount(s);for(let r=0;r<n;r++){const n=this.getAttributeAsDbl(t,s,r);i.setStartAttribute(s,r,n);const o=this.getAttributeAsDbl(e,s,r);i.setEndAttribute(s,r,o)}}}queryDerivative(t,e){Cs(this,t,e)}getClosestCoordinate(t,e){return K.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const n=new K;this.queryCoord2D(e.vmin,n);const i=new K;this.queryCoord2D(e.vmax,i);const r=K.getClosestCoordinate(n,i,t,!1);return ts.recalculateParentT(e.vmin,e.vmax,r)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const n=(t-this.m_YStart)/s;let i=Ps(this,n);return 1===n&&(i=this.m_XEnd),i}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return n(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new fm;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new K;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=K.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new K;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return Ms(this,t,e,s)>=0}isIntersectingPoint3D(t,e,s,i,r=1){return n(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(e,s){return s&&(e<2&&t(""),s[0]=0,s[1]=1),2}intersectionWithAxis2D(t,e,s,n){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const i=(e-this.m_YStart)/t;return i<0||i>1?0:(s&&(s[0]=Ps(this,i)),n&&(n[0]=i),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const i=(e-this.m_XStart)/t;return i<0||i>1?0:(s&&(s[0]=ys(this,i)),n&&(n[0]=i),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let s=gt(t.vmin,0,1);const n=new K;return this.queryCoord2D(s,n),e.setCoords({pt:n}),s=gt(t.vmax,0,1),this.queryCoord2D(s,n),void e.mergeNe(n)}s("3d dst not impl")}orientBottomUp(){Es(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return Ss(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoordsForStitcher(t,e){bs(this,t[0],t[e-1])}writeInBufferStream(t,e){return n(0),0}readFromBufferStream(t,e){n(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){bs(this,t,e)}static isIntersectingLineLine(t,e,s,n){return Ds(t,e,s,n)}static isIntersectingLineLine_(t,e,s,n){return Ds(t,e,s,n)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,n,i){return mm(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){e.length<1&&i("");const n=Ms(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==om(!1,this,t,e,s)}}fm.type=e.enumLine;class Pm{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new fm,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):r("bad constructor params"))}assignCopy(t){return t instanceof Pm?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Pm){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:r("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){n(0)}createImpl(s){switch(s){case e.enumLine:1&this.m_mask||(this.m_lineBuffer=new fm,this.m_mask|=1,this.m_active=1);break;case e.enumEllipticArc:2&this.m_mask||(this.m_curves=new qh,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case e.enumBezier:4&this.m_mask||(this.m_curves=new ra,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case e.enumBezier2:8&this.m_mask||(this.m_curves=new An,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case e.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Dn,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:t("")}}create(s){s===e.enumLine?this.createLine():s===e.enumEllipticArc?this.createEllipticArc():s===e.enumBezier?this.createCubicBezier():s===e.enumRationalBezier2?this.createQuadraticRationalBezier():s===e.enumBezier2?this.createQuadraticBezier():t("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){n(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(e.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(e.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(e.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(e.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(e.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&r("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():r("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Pm?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):(s("seg comparison not yet impl"),!1)}}export{Es as $,zu as A,Iu as B,Ar as C,Zh as D,yr as E,au as F,_e as G,Gs as H,Rs as I,zs as J,Ks as K,fm as L,gs as M,Gh as N,jh as O,Qs as P,om as Q,Me as R,Pm as S,Dn as T,Ph as U,Wu as V,ts as W,fr as X,am as Y,mm as Z,Oe as _,mr as a,be as a0,hm as a1,um as a2,dm as a3,Ee as a4,gu as a5,Pr as a6,Nh as a7,Ih as a8,ns as a9,Th as b,$s as c,Bh as d,Er as e,xr as f,pe as g,os as h,br as i,Is as j,Fh as k,qh as l,Vh as m,gr as n,dr as o,kh as p,nn as q,hs as r,is as s,en as t,co as u,rs as v,kr as w,Kn as x,ra as y,Ru as z};