@arcgis/core 4.34.0-next.89 → 4.34.0-next.90

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 (380) hide show
  1. package/applications/Components/featureUtils.d.ts +2 -0
  2. package/applications/Components/featureUtils.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{eada3483116a5ea8baed.js → 004c2a1a37b99a184b13.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{23f54b49742098def8ae.js → 00ee2a605c30744f415a.js} +1 -1
  6. package/assets/esri/core/workers/chunks/024063fe2bbb27899094.js +1 -0
  7. package/assets/esri/core/workers/chunks/0271a2ca4e9b1e4fd284.js +1 -0
  8. package/assets/esri/core/workers/chunks/0328eaea66c1db98da1c.js +1 -0
  9. package/assets/esri/core/workers/chunks/04bac7bb3f794b33e2e4.js +1 -0
  10. package/assets/esri/core/workers/chunks/{8380a092ffc8e92ede7a.js → 05072093e0209ef5db20.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{b53008c1461dd6bacc63.js → 06221ebadab32111e2c6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/06aed0a5464965be8d52.js +1 -0
  13. package/assets/esri/core/workers/chunks/{67fdc8074cdcf374af9a.js → 07a7ca89ef2ca4fc090b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/0810dbbf348a927392e7.js +1 -0
  15. package/assets/esri/core/workers/chunks/08374e5805fcedc1cb57.js +1 -0
  16. package/assets/esri/core/workers/chunks/0856cd281efd71bfe3c4.js +1 -0
  17. package/assets/esri/core/workers/chunks/08957e462d06c4dc8ab5.js +1 -0
  18. package/assets/esri/core/workers/chunks/0aaaf4d1c4a5d284216e.js +1 -0
  19. package/assets/esri/core/workers/chunks/{3c0990c4be06a2fd51e9.js → 0ca5060c81a1a05b8be3.js} +1 -1
  20. package/assets/esri/core/workers/chunks/0ceb68ff73e5d39e837a.js +1 -0
  21. package/assets/esri/core/workers/chunks/{998d164b3e0b99a0ff1e.js → 0e5e565df6ec71445f2e.js} +1 -1
  22. package/assets/esri/core/workers/chunks/0f4e9846d074864b39c2.js +1 -0
  23. package/assets/esri/core/workers/chunks/100a0041ee42b0b2fa32.js +1 -0
  24. package/assets/esri/core/workers/chunks/1194c2432c31def87db1.js +1 -0
  25. package/assets/esri/core/workers/chunks/{2896ada406074f754b00.js → 1214c126af0de25a4b4a.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{978ffde9ebebf5c83aea.js → 14114be3afd6d292f89c.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{4dd4b19c410026233999.js → 142c45ad68eecaf3fc7c.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{2b2f1fcd50dea017d891.js → 147f6e7b147beaa4ed29.js} +1 -1
  29. package/assets/esri/core/workers/chunks/155dcbd957f8787a45c3.js +1 -0
  30. package/assets/esri/core/workers/chunks/{d5363e5637d37e89a25f.js → 18e9cb71fa020e93d139.js} +1 -1
  31. package/assets/esri/core/workers/chunks/19bd0b56d82446dbb7c5.js +1 -0
  32. package/assets/esri/core/workers/chunks/{96de78f9994207aa7201.js → 1bbc0dfad4cd72a1c42b.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{914eaed113dda727eb47.js → 20988e116f3723228f36.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{831a69e5a87e92830fbe.js → 21f37a4b8d1857369203.js} +1 -1
  35. package/assets/esri/core/workers/chunks/22c3a21bc9f32c429c48.js +1 -0
  36. package/assets/esri/core/workers/chunks/282c4f3484c605ce7d5e.js +1 -0
  37. package/assets/esri/core/workers/chunks/2870723d57aa7b885896.js +1 -0
  38. package/assets/esri/core/workers/chunks/28bb6896c5fd353ca5e9.js +1 -0
  39. package/assets/esri/core/workers/chunks/2b867cec6ada339f1c8f.js +1 -0
  40. package/assets/esri/core/workers/chunks/{709dc98379f4ce18a0b5.js → 31186e83fe009aa0fd36.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{c779c8b98e07fa881c1d.js → 348c871657b0af621c33.js} +1 -1
  42. package/assets/esri/core/workers/chunks/35ca317490540fae437c.js +1 -0
  43. package/assets/esri/core/workers/chunks/{c5fe356fc5b8b7be0d31.js → 375f20f2e91d6a7507e8.js} +1 -1
  44. package/assets/esri/core/workers/chunks/3807d0b9b1894731174d.js +1 -0
  45. package/assets/esri/core/workers/chunks/38d874d7f815f5329420.js +1 -0
  46. package/assets/esri/core/workers/chunks/393274af1804e5b6046a.js +1 -0
  47. package/assets/esri/core/workers/chunks/3c3b1dc95f03082e4d5b.js +1 -0
  48. package/assets/esri/core/workers/chunks/3dcdbba706a8034b6ba3.js +1 -0
  49. package/assets/esri/core/workers/chunks/{834985ec601623df34a1.js → 3e11a893271caa11a881.js} +1 -1
  50. package/assets/esri/core/workers/chunks/4133ab8720e7e4afa9a6.js +1 -0
  51. package/assets/esri/core/workers/chunks/{b246ed6d86c2c8df56fb.js → 41f275401e1cde7eee20.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{595593dd03bcfba795c8.js → 4660798b3b45dcb5cecb.js} +2 -2
  53. package/assets/esri/core/workers/chunks/{69ae235423f0b1bdfcb4.js → 48c8ef4170e803a564d6.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{c90830ee562b5ddc4f8b.js → 49e6219dd08cb6c27023.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{00bbd37910c70989b54d.js → 4d0e099f34639cda3a9b.js} +1 -1
  56. package/assets/esri/core/workers/chunks/4d807bfe75108438db83.js +1 -0
  57. package/assets/esri/core/workers/chunks/{d1fc2c6e95fe2572d297.js → 50d9f69d5255af4b29bb.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{300b96f0f8e34b4a5d8b.js → 56de25a6fe659a5b5c2b.js} +1 -1
  59. package/assets/esri/core/workers/chunks/57c08ccb75e3135978d1.js +1 -0
  60. package/assets/esri/core/workers/chunks/5ad1985a9e66fb2232ae.js +1 -0
  61. package/assets/esri/core/workers/chunks/{d8494617cebc68e50d35.js → 5b7a2ee44883b1fb2a5f.js} +1 -1
  62. package/assets/esri/core/workers/chunks/5caf49e679ed0c27e0bd.js +1 -0
  63. package/assets/esri/core/workers/chunks/{f5c821ca2911a5103c9a.js → 5d15ca055071d7db6de8.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{59139347495988b19061.js → 61a9ffd4cf07d8bb7a9b.js} +1 -1
  65. package/assets/esri/core/workers/chunks/61e8e159f1f336569b27.js +1 -0
  66. package/assets/esri/core/workers/chunks/{88b8f33ce1cbf8a0f855.js → 633faa9cec8988ab06af.js} +4 -4
  67. package/assets/esri/core/workers/chunks/648c91a9822bc9d6ee47.js +1 -0
  68. package/assets/esri/core/workers/chunks/6aa349e1adf844df4b5b.js +1 -0
  69. package/assets/esri/core/workers/chunks/{d2371f5034b2a32e2523.js → 6cfa0967045068ce8a8b.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{28d30be414e59eabd963.js → 70c8f69eed14d55c5cf6.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{fdc8300b6374ef2b8b3e.js → 74881340e040bfd0580f.js} +1 -1
  72. package/assets/esri/core/workers/chunks/{8be81e1530b952c97936.js → 768ae52b4e5c3e571ef5.js} +1 -1
  73. package/assets/esri/core/workers/chunks/{b43473e84b3f7fa2634d.js → 77e611724a499d36eacc.js} +1 -1
  74. package/assets/esri/core/workers/chunks/7f8b85de079614b9c336.js +1 -0
  75. package/assets/esri/core/workers/chunks/{9280edff80fd87860a5e.js → 80a155496deef2c02a3e.js} +1 -1
  76. package/assets/esri/core/workers/chunks/{7db105f6b688b6da8106.js → 82ba4140e30f083fbc87.js} +1 -1
  77. package/assets/esri/core/workers/chunks/{672c04d48aa51f16e9b7.js → 8a6052b4d163d5088e11.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{5b35b30495145bf8dd5d.js → 8ff2daef892881ff2019.js} +1 -1
  79. package/assets/esri/core/workers/chunks/9a855a10798348a21bab.js +1 -0
  80. package/assets/esri/core/workers/chunks/9bb6984f24cd5461a754.js +1 -0
  81. package/assets/esri/core/workers/chunks/9d9a639f7388a29e7c96.js +1 -0
  82. package/assets/esri/core/workers/chunks/{813efde41e90e652b7db.js → 9f2a3f37fe9b19ef1209.js} +1 -1
  83. package/assets/esri/core/workers/chunks/a1a7b0e7ca488c895cb7.js +1 -0
  84. package/assets/esri/core/workers/chunks/a6a2d4602dfeb62e0ecc.js +1 -0
  85. package/assets/esri/core/workers/chunks/{d3fd11da3a823e148957.js → ab88577987cf2fe1cb32.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{a6767d75e718f2e1e714.js → ad9606164c694af0c61f.js} +1 -1
  87. package/assets/esri/core/workers/chunks/b18887a6dc86f0c8324a.js +1 -0
  88. package/assets/esri/core/workers/chunks/b240298b8b643a323d34.js +1 -0
  89. package/assets/esri/core/workers/chunks/{481c2b01e2fe92249698.js → b265472ac3f949a7f40c.js} +1 -1
  90. package/assets/esri/core/workers/chunks/b47f26d6aa9a2848a677.js +1 -0
  91. package/assets/esri/core/workers/chunks/{4094cebc4b92c52f4e27.js → b48abbf877e26ed1a4f8.js} +1 -1
  92. package/assets/esri/core/workers/chunks/b510c07dfd0d31683b08.js +1 -0
  93. package/assets/esri/core/workers/chunks/b661ea374fe38c8e29ca.js +1 -0
  94. package/assets/esri/core/workers/chunks/b8f55ee77ab6ea4c289e.js +1 -0
  95. package/assets/esri/core/workers/chunks/{ccd157ede169b93eea65.js → bb0a1be03bb9d621432c.js} +1 -1
  96. package/assets/esri/core/workers/chunks/{fdae43a97537093e4b97.js → bdf0ab95401c6d8fbc7d.js} +1 -1
  97. package/assets/esri/core/workers/chunks/c20862fe15295a294bbd.js +1 -0
  98. package/assets/esri/core/workers/chunks/{365d63c2aed3a49918f2.js → c27783ce7ea51a5e49c5.js} +1 -1
  99. package/assets/esri/core/workers/chunks/{ce937ff0dd1147ea297e.js → c3020747f9001ca6a6e7.js} +1 -1
  100. package/assets/esri/core/workers/chunks/{516864fb68025acc7db6.js → c547692862df95d22818.js} +1 -1
  101. package/assets/esri/core/workers/chunks/c5c6a32a24005478c976.js +1 -0
  102. package/assets/esri/core/workers/chunks/{e4acc3c2b6d865ed1940.js → c7c76a8a1c47eb62bef1.js} +1 -1
  103. package/assets/esri/core/workers/chunks/{58422c616a824ab49218.js → c84665db250b05e2829d.js} +1 -1
  104. package/assets/esri/core/workers/chunks/cb6a9b43406f4fbe10b2.js +1 -0
  105. package/assets/esri/core/workers/chunks/{cef9ff811221a7c3812c.js → cb90cfa35d77ab561939.js} +1 -1
  106. package/assets/esri/core/workers/chunks/ced12ad98f8f48d0dc00.js +1 -0
  107. package/assets/esri/core/workers/chunks/{bd451668c4ce9f7d7128.js → d56548a994753b08403c.js} +1 -1
  108. package/assets/esri/core/workers/chunks/{251b7f2e295ce191eb62.js → da4163b4f9b34e83c92d.js} +1 -1
  109. package/assets/esri/core/workers/chunks/{43fba9d6be5971ec20a9.js → e0017c6739d2532793e6.js} +1 -1
  110. package/assets/esri/core/workers/chunks/e22b400636094fc7b6c0.js +1 -0
  111. package/assets/esri/core/workers/chunks/{0296ebe8e37e30af771c.js → e2fdc4dc1ab9decd731e.js} +1 -1
  112. package/assets/esri/core/workers/chunks/e34136ad9d620cb845fd.js +1 -0
  113. package/assets/esri/core/workers/chunks/e537e1d37f3fcb14fce2.js +1 -0
  114. package/assets/esri/core/workers/chunks/e5baa30944061418cb13.js +1 -0
  115. package/assets/esri/core/workers/chunks/edef1e2254c992459c63.js +1 -0
  116. package/assets/esri/core/workers/chunks/{109149c378aa4c5f8526.js → eea9d49d55c2d1355497.js} +1 -1
  117. package/assets/esri/core/workers/chunks/{3245663da75e168bf85c.js → ef75cad6570b14a42b62.js} +1 -1
  118. package/assets/esri/core/workers/chunks/{2a2a925c45d5fd58628b.js → f3284d4e0d41efb0b4a0.js} +1 -1
  119. package/assets/esri/core/workers/chunks/f62717338075df626eda.js +1 -0
  120. package/assets/esri/core/workers/chunks/{d07d3b0e06f12aee4a8b.js → f6ce485c082d0d640b01.js} +1 -1
  121. package/assets/esri/core/workers/chunks/fb6ebb780bb59e252887.js +1 -0
  122. package/assets/esri/core/workers/chunks/{69e6000044bfb03776ac.js → fd34c033ce7f16835368.js} +1 -1
  123. package/assets/esri/core/workers/chunks/fdadf11f31384c09db9f.js +1 -0
  124. package/assets/esri/core/workers/chunks/{80bd5988180f4618fd61.js → ff6d189ba78980d40bb5.js} +1 -1
  125. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  126. package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
  127. package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
  128. package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
  129. package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
  130. package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
  131. package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
  132. package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
  133. package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
  134. package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
  135. package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
  136. package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
  137. package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
  138. package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
  139. package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
  140. package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
  141. package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
  142. package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
  143. package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
  144. package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
  145. package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
  146. package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
  147. package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
  148. package/assets/esri/widgets/Sketch/t9n/Sketch_no.json +1 -1
  149. package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
  150. package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
  151. package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
  152. package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
  153. package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
  154. package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
  155. package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
  156. package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
  157. package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
  158. package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
  159. package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
  160. package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
  161. package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
  162. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
  163. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
  164. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
  165. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ar.json +1 -1
  166. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_bg.json +1 -1
  167. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_bs.json +1 -1
  168. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ca.json +1 -1
  169. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_cs.json +1 -1
  170. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_da.json +1 -1
  171. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_de.json +1 -1
  172. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_el.json +1 -1
  173. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_es.json +1 -1
  174. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_et.json +1 -1
  175. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_fi.json +1 -1
  176. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_fr.json +1 -1
  177. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_he.json +1 -1
  178. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_hr.json +1 -1
  179. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_hu.json +1 -1
  180. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_id.json +1 -1
  181. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_it.json +1 -1
  182. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ja.json +1 -1
  183. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ko.json +1 -1
  184. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_lt.json +1 -1
  185. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_lv.json +1 -1
  186. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_nl.json +1 -1
  187. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_no.json +1 -1
  188. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pl.json +1 -1
  189. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pt-BR.json +1 -1
  190. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pt-PT.json +1 -1
  191. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ro.json +1 -1
  192. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ru.json +1 -1
  193. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sk.json +1 -1
  194. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sl.json +1 -1
  195. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sr.json +1 -1
  196. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sv.json +1 -1
  197. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_th.json +1 -1
  198. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_tr.json +1 -1
  199. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_uk.json +1 -1
  200. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_vi.json +1 -1
  201. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-CN.json +1 -1
  202. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-HK.json +1 -1
  203. package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-TW.json +1 -1
  204. package/chunks/Bufferer-Dw9Qi4T1.js +1 -1
  205. package/chunks/Distance2DCalculator-CXhBP-8I.js +1 -1
  206. package/chunks/GaussianSplat.glsl.js +2 -2
  207. package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +1 -1
  208. package/chunks/GeodeticUtils.js +1 -1
  209. package/chunks/GlowBlur.glsl.js +5 -5
  210. package/chunks/MultiPathImpl.js +1 -1
  211. package/chunks/OITBlend.glsl.js +9 -7
  212. package/chunks/OperatorCrosses.js +1 -1
  213. package/chunks/OperatorCut.js +1 -1
  214. package/chunks/OperatorGeodesicBuffer.js +1 -1
  215. package/chunks/OperatorGeodeticArea.js +1 -1
  216. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  217. package/chunks/OperatorGeodeticLength.js +1 -1
  218. package/chunks/OperatorIntersects.js +1 -1
  219. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  220. package/chunks/OperatorOverlaps.js +1 -1
  221. package/chunks/OperatorProximity.js +1 -1
  222. package/chunks/OperatorProximityGeodesic.js +1 -1
  223. package/chunks/OperatorShapePreservingLength.js +1 -1
  224. package/chunks/OperatorShapePreservingProject.js +1 -1
  225. package/chunks/OperatorSimplifyOGC.js +1 -1
  226. package/chunks/OperatorTouches.js +1 -1
  227. package/chunks/OperatorWithin.js +1 -1
  228. package/chunks/Point2D.js +1 -1
  229. package/chunks/ProjectionTransformation.js +1 -1
  230. package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
  231. package/chunks/UnitFactory.js +1 -1
  232. package/chunks/containsOperator.js +1 -1
  233. package/chunks/disjointOperator.js +1 -1
  234. package/chunks/equalsOperator.js +1 -1
  235. package/chunks/relateOperator.js +1 -1
  236. package/config.js +1 -1
  237. package/geohash/geohashUtils.js +1 -1
  238. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  239. package/geometry/operators/gx/operatorBuffer.js +1 -1
  240. package/geometry/operators/gx/operatorDifference.js +1 -1
  241. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  242. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  243. package/geometry/operators/gx/operatorIntersection.js +1 -1
  244. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  245. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  246. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  247. package/geometry/operators/gx/operatorSimplify.js +1 -1
  248. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  249. package/geometry/operators/gx/operatorUnion.js +1 -1
  250. package/geometry/operators/json/containsOperator.js +1 -1
  251. package/geometry/operators/json/disjointOperator.js +1 -1
  252. package/geometry/operators/json/projectOperator.js +5 -0
  253. package/geometry/operators/projectOperator.js +1 -1
  254. package/geometry/operators/reshapeOperator.js +1 -1
  255. package/geometry/operators/shapePreservingProjectOperator.js +1 -1
  256. package/geometry/operators/support/geographicTransformationUtils.js +1 -1
  257. package/geometry/operators/support/initNoPeFactory.js +1 -1
  258. package/geometry/operators/support/jsonConverter.js +1 -1
  259. package/geometry/operators/support/projectionTransformation.js +5 -0
  260. package/geometry/projectionUtils.js +1 -1
  261. package/geometry/support/GeographicTransformation.js +1 -1
  262. package/geometry/support/GeographicTransformationStep.js +1 -1
  263. package/interfaces.d.ts +359 -0
  264. package/intl/date.js +1 -1
  265. package/kernel.js +1 -1
  266. package/layers/graphics/data/QueryEngine.js +1 -1
  267. package/layers/graphics/data/projectionSupport.js +1 -1
  268. package/layers/graphics/data/queryUtils.js +1 -1
  269. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  270. package/layers/support/DateTimeFieldFormat.d.ts +4 -0
  271. package/layers/support/FieldConfiguration.d.ts +4 -0
  272. package/layers/support/NumberFieldFormat.d.ts +4 -0
  273. package/layers/support/vectorTileLayerLoader.js +1 -1
  274. package/package.json +2 -2
  275. package/support/revision.js +1 -1
  276. package/views/2d/engine/flow/dataUtils.js +1 -1
  277. package/views/2d/engine/flow/utils.js +1 -1
  278. package/views/2d/layers/MediaLayerView2D.js +1 -1
  279. package/views/2d/layers/TileLayerView2D.js +1 -1
  280. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementError.d.ts +4 -0
  281. package/views/3d/{support/flow/VisualQuery3D.js → analysis/VolumeMeasurement/VolumeMeasurementError.js} +1 -1
  282. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  283. package/views/3d/layers/FlowSubView3D.js +1 -1
  284. package/views/3d/state/ViewState.js +1 -1
  285. package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +1 -1
  286. package/views/3d/support/DisplayQualityProfile.js +1 -1
  287. package/views/3d/support/QualitySettings.js +1 -1
  288. package/views/3d/support/flow/FlowQuery3D.js +5 -0
  289. package/views/3d/support/flow/FlowSubViewExtent3D.js +1 -1
  290. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  291. package/views/3d/support/flow/FlowWorker.js +1 -1
  292. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  293. package/views/3d/support/flow/geometryUtils.js +1 -1
  294. package/views/3d/support/flow/loadUtils.js +1 -1
  295. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  296. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +2 -2
  297. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  298. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  299. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  300. package/views/3d/webgl-engine/effects/transparency/OITBlendTechniqueConfiguration.js +1 -1
  301. package/views/3d/webgl-engine/lib/CutFillColor.js +1 -1
  302. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  303. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  304. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  305. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  306. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  307. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  308. package/views/VideoView.js +1 -1
  309. package/views/webgl/enums.js +1 -1
  310. package/views/webgl/renderState.js +1 -1
  311. package/webmap/utils.js +1 -1
  312. package/widgets/Editor/Upload.js +1 -1
  313. package/widgets/FeatureTable/FieldColumn.js +1 -1
  314. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  315. package/widgets/OrientedImageryViewer.js +1 -1
  316. package/assets/esri/core/workers/chunks/0103b70126bc5dffc55e.js +0 -1
  317. package/assets/esri/core/workers/chunks/03ef19f0753d68770444.js +0 -1
  318. package/assets/esri/core/workers/chunks/050429f516149ce3b517.js +0 -1
  319. package/assets/esri/core/workers/chunks/09f1a27442bdd52cdeb7.js +0 -1
  320. package/assets/esri/core/workers/chunks/0fadd1defbb6743dacdc.js +0 -1
  321. package/assets/esri/core/workers/chunks/124f8757ea18bfd158ec.js +0 -1
  322. package/assets/esri/core/workers/chunks/135142f3cbfaf24949bc.js +0 -1
  323. package/assets/esri/core/workers/chunks/138c11b5eca621e51396.js +0 -1
  324. package/assets/esri/core/workers/chunks/14743a962e661babe0a4.js +0 -1
  325. package/assets/esri/core/workers/chunks/1bf17c6548ac4cd5a166.js +0 -1
  326. package/assets/esri/core/workers/chunks/1d9212a70df68a508dca.js +0 -1
  327. package/assets/esri/core/workers/chunks/213e82a7e3fa5b253ec1.js +0 -1
  328. package/assets/esri/core/workers/chunks/3b23c37e5bc552dc81d4.js +0 -1
  329. package/assets/esri/core/workers/chunks/3d68a650a1f944ec5171.js +0 -1
  330. package/assets/esri/core/workers/chunks/451555af283b32a10fef.js +0 -1
  331. package/assets/esri/core/workers/chunks/48913b944c28343816ac.js +0 -1
  332. package/assets/esri/core/workers/chunks/4e6e8dda6c12f6fbed8e.js +0 -1
  333. package/assets/esri/core/workers/chunks/4e77b9cc1d9437bcbb0c.js +0 -1
  334. package/assets/esri/core/workers/chunks/5019f1b8186a65a0313b.js +0 -1
  335. package/assets/esri/core/workers/chunks/547af4ffbeeccba9d187.js +0 -1
  336. package/assets/esri/core/workers/chunks/589a0e244ef5f1b84ab6.js +0 -1
  337. package/assets/esri/core/workers/chunks/59e27818cb68f0285d54.js +0 -1
  338. package/assets/esri/core/workers/chunks/5e1d6704ee0aa41b1d06.js +0 -1
  339. package/assets/esri/core/workers/chunks/6b0baecbd35d26393dcf.js +0 -1
  340. package/assets/esri/core/workers/chunks/6dafb2b95bae552c1cc2.js +0 -1
  341. package/assets/esri/core/workers/chunks/71df48968d6cdc736458.js +0 -1
  342. package/assets/esri/core/workers/chunks/773d106f60f7dad1493d.js +0 -1
  343. package/assets/esri/core/workers/chunks/79c4f10da8360ee60cd2.js +0 -1
  344. package/assets/esri/core/workers/chunks/7aa7aff6d42be7c2d1d2.js +0 -1
  345. package/assets/esri/core/workers/chunks/82404ff7c298493ff6f4.js +0 -1
  346. package/assets/esri/core/workers/chunks/84a556dafd583635ad5e.js +0 -1
  347. package/assets/esri/core/workers/chunks/885a398de8a33d36c59e.js +0 -1
  348. package/assets/esri/core/workers/chunks/8bd6c27a93a697a7fa3d.js +0 -1
  349. package/assets/esri/core/workers/chunks/8be9fa12e854a83062c3.js +0 -1
  350. package/assets/esri/core/workers/chunks/9386a0ebff78b6303ed2.js +0 -1
  351. package/assets/esri/core/workers/chunks/9673e25114fc1897460d.js +0 -1
  352. package/assets/esri/core/workers/chunks/96a14689815bec741308.js +0 -1
  353. package/assets/esri/core/workers/chunks/977582cb3c8f17a2cb4c.js +0 -1
  354. package/assets/esri/core/workers/chunks/97d71459ad72b4b780a3.js +0 -1
  355. package/assets/esri/core/workers/chunks/a1abe9865d66789bd5af.js +0 -1
  356. package/assets/esri/core/workers/chunks/a7ea2e3895046e566bc6.js +0 -1
  357. package/assets/esri/core/workers/chunks/a96e58ed9a4a2329ee53.js +0 -1
  358. package/assets/esri/core/workers/chunks/aa778e5d7db40d9b9b4a.js +0 -1
  359. package/assets/esri/core/workers/chunks/acb49f3d2b783e81a215.js +0 -1
  360. package/assets/esri/core/workers/chunks/b0a03b6edbcf6e933431.js +0 -1
  361. package/assets/esri/core/workers/chunks/bc83bcfe123525d21884.js +0 -1
  362. package/assets/esri/core/workers/chunks/bd028badc07270eda3d0.js +0 -1
  363. package/assets/esri/core/workers/chunks/be8dd8e68c8805300ad1.js +0 -1
  364. package/assets/esri/core/workers/chunks/c1d75c48558ed23c5b2b.js +0 -1
  365. package/assets/esri/core/workers/chunks/c24214666d10cb648428.js +0 -1
  366. package/assets/esri/core/workers/chunks/c3010d783506f8410f99.js +0 -1
  367. package/assets/esri/core/workers/chunks/d0296368ae143de4d5ce.js +0 -1
  368. package/assets/esri/core/workers/chunks/d51aabb9b950f49df183.js +0 -1
  369. package/assets/esri/core/workers/chunks/d8a0eb143b2079d7b6b7.js +0 -1
  370. package/assets/esri/core/workers/chunks/dca2b487152cde45fb65.js +0 -1
  371. package/assets/esri/core/workers/chunks/e760b8ca64d67c04d98a.js +0 -1
  372. package/assets/esri/core/workers/chunks/ee78a38a0cacb19b2fd4.js +0 -1
  373. package/assets/esri/core/workers/chunks/f5710ced8d38f9a90fc5.js +0 -1
  374. package/assets/esri/core/workers/chunks/f592c4e5e1746d4619db.js +0 -1
  375. package/assets/esri/core/workers/chunks/f8d2c52cc51d5f1bbce2.js +0 -1
  376. package/assets/esri/core/workers/chunks/f9decc88561c03aca3c9.js +0 -1
  377. package/assets/esri/core/workers/chunks/fd1fdb97a294a1b7041d.js +0 -1
  378. package/assets/esri/core/workers/chunks/ffee8cc83d703c1dc0c0.js +0 -1
  379. package/chunks/CompositeGeographicTransformation.js +0 -5
  380. package/chunks/GeographicTransformation.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/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{i as t,a as e,g as s,q as n,G as i,B as r,C as o,t as a,d as h,z 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,N as C,O as v,V as b,d as E,q as S,Q as D,R as w,U as A,W as T,X as I,E as M,Y,Z as N,_ as X,P as q,D as F,$ as V,a0 as L,a1 as R,t as z,a2 as B,S as k,B as G,A as W,T as j,a3 as Z}from"./Envelope.js";import{E as H,d as U,a3 as O,P as Q,i as K,b as J,J as $,a4 as tt,c as et,a5 as st,a6 as nt,M as it,q as rt,a7 as ot,X as at,a8 as ht,U as ut,g as mt,m as lt,a9 as ct,aa as gt,H as dt,s as _t,K as pt,F as ft,ab as Pt,ac as yt,Q as xt,ad as Ct,ae as vt,af as bt,ag as Et,ah as St,ai as Dt,aj as wt,ak as At,o as Tt,al as It,l as Mt,j as Yt,e as Nt,am as Xt,an as qt,ao as Ft,ap as Vt,aq as Lt,ar as Rt,a as zt,R as Bt,as as kt,v as Gt,at as Wt,au as jt,w as Zt,av as Ht,aw as Ut,ax as Ot,n as Qt,ay as Kt,az as Jt,aA as $t,aB as te,aC as ee,u as se,aD as ne,aE as ie,aF as re,aG as oe,aH as ae,aI as he,a1 as ue}from"./Point2D.js";import{Envelope2D as me}from"./Envelope2D.js";import{T as le}from"./Transformation2D.js";import{G as ce}from"./SimpleGeometryCursor.js";class ge{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 de(t,s,n,i,r){(s<0||n<0||i<1||s+i*(n-1)+1>t.size())&&e("Index out of bound");for(let e=s,o=s+i*(n-1)+1;e<o;e+=i)t.writeAsDbl(e,r(t.readAsDbl(e)))}function _e(t,e,s){if(t)for(let n=e.length-1;n>=0;--n)s(e[n]);else e.forEach(s)}function pe(t,e){let s=$(t);const n=e.length/K();for(let i=0;i<e.length;++i){const t=Math.trunc(s*n);s=$(s);const i=Math.trunc(s*n),r=e[t];e[t]=e[i],e[i]=r}}function fe(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 Pe(t,e,s,n,i){tt(t,e,n-e,(t,e)=>i(t,e)?-1:1)}function ye(t,e,s){if(!(s<=e))for(;e<s;)t[s]=et(t[e],t[e]=t[s]),e++,s--}function xe(t,e,s,n){ye(t,e,s-1),ye(t,s,n-1),t.reverse()}function Ce(t,e,s){const n=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),J(t.getAttributeArray(),e,0,2,n-2)}var ve=b;const be="can not assign an empty point to a vertex";class Ee{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 ge,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new y,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 ge,this.m_envelopeData=new y,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(e,s){if(!t(e.getGeometryType()))return!1;const n=e;if(this===n)return!0;if(!this.m_description.equals(n.getDescription()))return!1;if(this.isEmptyImpl()!==n.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==n.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(e),o=n.getAttributeStreamRef(e),a=ve.getComponentCount(e);if(!r.equals(o,0,i*a,s))return!1}if(s){if(!this.equalsImplTol(e,s))return!1}else if(!this.equalsImpl(e))return!1;return!0}transformAttribute(t,s,n,i,r){if(this.addAttribute(t),!this.isEmpty()&&(0!==n||1!==i)){if(0===t){const t=new le;return 0===r?0===s?(t.setShiftCoords(n,0),t.scale(i,1)):1===s?(t.setShiftCoords(0,n),t.scale(1,i)):e(""):0===s?(t.setScaleCoords(1/i,1),t.shiftCoords(-n,0)):1===s?(t.setScaleCoords(1,1/i),t.shiftCoords(0,-n)):e(""),void this.applyTransformation(t)}de(this.getAttributeStreamRef(t),s,this.getPointCount(),ve.getComponentCount(t),N(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=x(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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||e("AttributeStream : Geometry does not have the attribute");const s=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(s)}setAttributeStreamRef(t,s){s||e("stream"),s&&ve.getPersistence(t)!==s.getPersistence()&&e(""),this.addAttribute(t);const n=this.m_description.getAttributeIndex(t);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=ve.getComponentCount(e);i<r;i++){const o=this.m_vertexAttributes.get(n).readAsDbl(r*t+i);s.setAttributeBasic(e,i,o)}}}setPointByValNoCurves(t,s){const n=s;n.isEmpty()&&e(be);const i=n.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const r=this.m_vertexAttributes.get(0);r.write(2*t,n.getX()),r.write(2*t+1,n.getY());for(let e=1,o=this.m_description.getAttributeCount();e<o;e++){const s=this.m_description.getSemantics(e),i=ve.getComponentCount(s);for(let r=0;r<i;r++){const o=n.getAttributeAsDbl(s,r);this.m_vertexAttributes.get(e).writeAsDbl(t*i+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,n,i){s(0)}getPointByValAsArray(t,e,n,i){s(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const i=ve.getComponentCount(t);s>=i&&n("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*i+s):ve.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,i){const r=ve.getComponentCount(t);i<r&&n("");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=ve.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,n,i){s(0)}setAttributeNoCurves(t,e,s,i){const r=ve.getComponentCount(t);s>=r&&n(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,i)}setAttributeFromArrayNoCurves(t,e,s,i){(e<0||e>=this.m_pointCount)&&n("");const r=ve.getComponentCount(t);i<r&&n(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let n=0;n<r;++n)a.writeAsDbl(e*r+n,s[n])}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=ve.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 me||t instanceof S?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=H.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=ve.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=ve.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 s(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||e(""),this.m_envelopeData=new y({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&e(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,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)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*n,a=2*r,h=0;e<a;e+=2,h++)o.queryPoint2D(e,t[h]);return r}queryCoordinates3D(t,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)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=ve.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let e=n;e<r;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=u?a.read(e):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,e,n=!1){if(2===t?s(this.getGeometryType()===i.enumPolyline):1===t?s(this.getGeometryType()===i.enumMultiPoint||this.getGeometryType()===i.enumPolyline):3===t&&s(this.getGeometryType()===i.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;n||(s|=16);const i=31;this.clearAndSetDirtyFlagProtected(i,s),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}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,e=!1){e&&this.hasDirtyFlag(32)&&r("Cannot do shallow clone on unprepared geometry");const n=t,o=this.getGeometryType(),a=n.getGeometryType();s(o===a||o===i.enumPolygon&&a===i.enumPolyline,"failure in copyToUnchcked"),n.clearAccelerators(),n.m_description=this.m_description,n.m_vertexAttributes.destroyAndSetSize(0),n.m_envelopeData.releaseAttributes();const h=this.m_description.getAttributeCount(),u=new ge;if(!this.m_vertexAttributes.empty()){u.destroyAndSetSize(h);for(let t=0;t<h;t++)if(this.m_vertexAttributes.get(t))if(e)u.set(t,this.m_vertexAttributes.get(t));else{const e=ve.getComponentCount(this.m_description.getSemantics(t));u.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,n.m_envelopeData),n.m_flags=this.m_flags,n.m_simpleTolerance=this.m_simpleTolerance,o!==a){const t=[Number.NaN];n.getIsSimple(0,t)>=3?n.setIsSimple(1,t[0]):n.setIsSimple(-1,0)}n.m_vertexAttributes.swap(u),u.destroyAndSetSize(0),n.m_pointCount=this.m_pointCount,n.hasDirtyFlag(32)||n.m_vertexAttributes.empty()?(s(!e||0===n.m_pointCount),n.m_reservedPointCount=-1):n.m_reservedPointCount=n.m_pointCount;try{this.copyToImpl(n,e)}catch(m){throw n.setEmpty(),m}n.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,i,r){(t<0||t>=this.m_pointCount)&&n(""),(e<0||e>=this.m_pointCount)&&n(""),r.assignVertexDescription(this.m_description);const o=U(ve.maxComponentCount(),Number.NaN),a=U(ve.maxComponentCount(),Number.NaN),h=D();let u=0;for(let n=0;n<this.m_description.getAttributeCount();n++){const r=this.m_description.getSemantics(n),m=ve.getInterpolation(r),l=ve.getComponentCount(r),c=ve.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),s(u+l<=w),O(m,o,a,h,u,l,i,c),u+=l}Ce(r,h)}getShortestDistance(t,e){return Q.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return Q.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&e(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const s=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(s)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=A();T(t,this.m_description,e);const s=new ge;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=ve.getComponentCount(n);i=this.m_vertexAttributes.get(s).size()/t,i<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,ve.getDefaultValue(n)),i=e)}else this.m_vertexAttributes.set(s,I(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 M({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=ve.getComponentCount(e),i=this.m_vertexAttributes.get(t);for(let t=0;t<n;t++){const r=new H;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 y({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=me.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){s(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof me?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(t,s){if(t<0&&e(""),0===t)return;let n=t=Math.ceil(t);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,Y(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,Y(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=ve.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(n*s):this.m_vertexAttributes.set(t,Y(e,n))}this.reserveImplImpl(n,s),this.m_reservedPointCount=n}}reserveRounded(t){t<0&&e(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&o("")}}class Se extends Ee{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(t,s){t>this.getPointCount()&&e("invalid point index"),t<0&&(t=this.getPointCount());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=b.getComponentCount(i);if(0===i)this.m_vertexAttributes.get(e).insert(r*t,s,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoint(t,s){s.isEmpty()&&e(be),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(s.getDescription());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=b.getComponentCount(i);if(s.hasAttribute(i))this.m_vertexAttributes.get(e).insertAttributes(r*t,s,i,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&n(""),t<0&&(t=this.getPointCount()),0===s)return;const i=e[0].getDescription();this.mergeVertexDescription(i);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let n=0,o=this.m_description.getAttributeCount();n<o;n++){const o=this.m_description.getSemantics(n),a=b.getComponentCount(o);if(this.m_vertexAttributes.get(n))if(i.hasAttribute(o))this.m_vertexAttributes.get(n).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=b.getDefaultValue(o);this.m_vertexAttributes.get(n).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,s,n){if((t>this.getPointCount()||n<0)&&e("invalid point index"),t<0&&(t=this.getPointCount()),0===n)return;const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+n);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++){const r=this.m_description.getSemantics(e),o=b.getComponentCount(r);if(this.m_vertexAttributes.get(e))if(0===r)this.m_vertexAttributes.get(e).insertRangeFromPoints(o*t,s,0,n,!0,o*i);else{const s=b.getDefaultValue(r);this.m_vertexAttributes.get(e).insertRange(o*t,s,o,o*i)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&n("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(t,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)&&e(""),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 e=n;e<r;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=u?a.read(e):h;return r}queryAttributeAsInt(t,e,n,i){s(0)}add(t){t.isEmpty()&&e(be),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new Q(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(t,s,n){this===t&&e("Multi_point_impl.add");const i=n<0?t.getPointCount():n;if((s<0||s>t.getPointCount()||i<s)&&e(""),s===i)return;const r=t.getDescription();this.mergeVertexDescription(r);const o=i-s,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let e=0,h=this.m_description.getAttributeCount();e<h;e++){const n=this.m_description.getSemantics(e),i=b.getComponentCount(n),h=this.getAttributeStreamRef(n);if(r.hasAttribute(n)){const e=t.getAttributeStreamRef(n);h.insertRangeFromStream(a*i,e,s*i,o*i,!0,1,a*i)}else{const t=b.getDefaultValue(n);h.insertRange(a*i,t,o*i,a*i)}}}addPoints2D(t,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&e(""),n===o)return;r=o-n;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[n+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&e(""),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 Q;for(let e=0;e<r;e++)u.x=t[n+e].x,u.y=t[n+e].y,h.writePoint2D(2*(a+e),u);const m=this.getAttributeStreamRef(1);for(let e=0;e<r;e++)m.write(a+e,t[n+e].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 i.enumMultiPoint}getDimension(){return 0}createInstance(){return new Se({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):a("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===i.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):a("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){s(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return s(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}Se.type=i.enumMultiPoint;class De{constructor(){this.m_EnvelopeType=5,this.envAabb=me.constructEmpty(),this.envRot=me.constructEmpty()}static constructEmpty(){return new De}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:Te(t),y:Ie(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Te(t),Ie(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=Te(t[n]),s=Ie(t[n]);this.envRot.mergeNeCoords(e,s)}break}{const e=Te(t[s]),n=Ie(t[s]);this.envRot.setCoords({x:e,y:n}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Te(t),Ie(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*st();this.envRot.inflateCoords(e,e),e<0&&De.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(Me(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(Me(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(Me(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=we(t.x,t.y),n=Ae(t.x,t.y);e.setCoords(s,n)}}function we(t,e){return t-e}function Ae(t,e){return t+e}function Te(t){return t.x-t.y}function Ie(t){return t.x+t.y}function Me(t){return new Q(Te(t),Ie(t))}class Ye{constructor(){this.x=at.getNAN(),this.y=at.getNAN()}static getNAN(){return new Ye}static constructPoint2D(t){const e=new Ye;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Ye;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Ye;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 Ye).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 Ye;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Ye;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=ht.clone(),this.y=ut.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 Q.construct(this.x.value(),this.y.value())}}class Ne{constructor(){this.a11=new at(1),this.a12=new at(0),this.a21=new at(0),this.a22=new at(1)}clone(){const t=new Ne;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=et(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 at(1),i=new at(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new at(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(ut)&&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 at(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]=et(t[0],t[0]=t[1]),e[1]=et(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class Xe{static constructPoint2D(t){return new Xe(it.constructDouble(t.x),it.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new it).setNAN(),void(this.y=(new it).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 Q(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 Xe(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new Xe(this.x.add(t.x),this.y.add(t.y))}sub(t){return new Xe(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 qe=b;function Fe(t){let e=!1;for(let s=0;s<2;s++){const n=nt(t[0][s],t[3][s]);n>0?(nt(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),nt(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),nt(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),nt(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):n<0?(nt(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),nt(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),nt(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),nt(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 Ve(t){const e=nt(t[0].y,t[1].y),s=nt(t[1].y,t[2].y),n=nt(t[2].y,t[3].y);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0){const e=nt(t[0].x,t[1].x),s=nt(t[1].x,t[2].x),n=nt(t[2].x,t[3].x);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0)return!0}return!1}function Le(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 Re(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function ze(t,e,s){const n=lt(Q,4);let r=t.queryControlPointsHelper(n);const o=lt(Q,4);let a=e.queryControlPointsHelper(o);n[0].equals(o[0])||u("");const h=t.getGeometryType();if(h===e.getGeometryType()&&n.map((t,e)=>o[e].equals(t)).reduce((t,e)=>t&&e)){if(h!==i.enumRationalBezier2)return 0;{const s=e,n=[0,0,0],i=[0,0,0];if(t.queryWeights(n),s.queryWeights(i),n.map((t,e)=>i[e]===t).reduce((t,e)=>t&&e))return 0}}for(;r>2&&n[1].equals(n[0]);)n.splice(1,1),r--;for(;a>2&&o[1].equals(o[0]);)o.splice(1,1),a--;(n[1].equals(n[0])||o[1].equals(n[0]))&&u("");const m=Q.compareVectorsOrigin(n[0],n[1],o[1]);if(0===m){const s=Xe.constructPoint2D(n[0]),i=new Xe;t.queryCoord2DMP(1e-16,i),i.sub(s);const r=new Xe;e.queryCoord2DMP(1e-16,r),r.sub(s);return r.crossProduct(i).sign()}return m}function Be(t,e,n,i,r,o,a,h){let u=t.calculateUpperLength2D(),m=e.calculateUpperLength2D(),l=t,c=e,g=!1;u>m&&(c=et(l,l=c),i=et(n,n=i),m=et(u,u=m),g=!0);const d=0===n;{a[0]=d?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(Q.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 H(0,1),r)){s=!1;break}if(s)return g&&(h[0]=et(a[0],a[0]=h[0])),1}}if(u<=3*r)return 0;let _=_t(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++){s(b<4095);const t=d?_:1-_,e=l.getCoord2D(t),n=c.getClosestCoordinate(e,!1);if(n===i)return C;const u=c.getCoord2D(n),m=Q.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)_=rt(f,y,v);else{if(a[C]=t,h[C]=n,g&&(h[C]=et(a[C],a[C]=h[C])),1===o||1===C)return 1===C&&a[0]>a[1]&&(a[1]=et(a[0],a[0]=a[1]),h[1]=et(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 ke(t,e,s,n,i,r,o,a,h){if(gt(s,0,1)&&gt(n,0,1)){if(0===Q.distance(t.getCoord2D(s),e.getCoord2D(n))){const h=1e-12,u=new Ye,m=dt();if(t.queryDerivative(new at(s,m),u),u.isTrueZero()){const e=1===s?-1e-12:h;t.queryDerivative(new at(s,m).add(e),u)}1===s&&u.negateThis();const l=new Ye;if(e.queryDerivative(new at(n,m),l),l.isTrueZero()){const t=1===s?-1e-12:h;e.queryDerivative(new at(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(ut)&&(g.isZero()||Math.abs(g.value())<d())){return Be(t,e,s,n,i,r,o,a)}}}return 0}function Ge(t,e,n){if(s(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(ke(t,e,0,0,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(ke(t,e,1,1,n,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(ke(t,e,0,1,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(ke(t,e,1,0,n,2,[0,0],[0,0]))return!0}return!1}function We(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function je(t,e,s){t.m_XStart=e,t.m_YStart=s}function Ze(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function He(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Ue(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 Oe(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=Qe(t,e),s}function Qe(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:qe.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 Je(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=qe.getComponentCount(n);i<r;i++){const r=ts(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function $e(t,e,s){s.isEmpty()&&o(""),Ue(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=qe.getComponentCount(r);for(let n=0;n<o;n++){es(t,e,r,n,s.getAttributeAsDbl(r,n))}}}function ts(t,e,s,i){if((e<0||e>1)&&n(""),0===s)return(i<0||i>=2)&&n(""),0===e?0===i?t.m_XStart:t.m_YStart:0===i?t.m_XEnd:t.m_YEnd;const r=qe.getComponentCount(s);(i<0||i>=r)&&n("");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+i]:qe.getDefaultValue(s)}function es(t,e,s,i,r){if((e<0||e>1)&&n(""),0===s)return 0===e?0===i?t.m_XStart=r:1===i?t.m_YStart=r:n(""):1===e?0===i?t.m_XEnd=r:1===i?t.m_YEnd=r:n(""):n(""),void t.endPointModified();const o=qe.getComponentCount(s);(i<0||i>=o)&&n("");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+i]=r}function ss(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=qe.getComponentCount(i);for(let s=0;s<r;s++){let n=ts(e,0,i,s);es(t,0,i,s,n),n=ts(e,1,i,s),es(t,1,i,s,n)}}}function ns(t,e){const s=A();T(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=U(2*i,Number.NaN),J(n,e.getDefaultPointAttributes(),0,2,i),J(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=qe.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 is(t){return t.absNorm()*mt()}function rs(t,e){return Math.max(t.absNorm(),e.absNorm())*mt()}function os(t,e,s){const n=new De;t.queryEnvelopeW(H.unit(),n);const i=new De;return e.queryEnvelopeW(H.unit(),i),i.inflate(s),!n.isIntersectingW(i)}function as(t,e,s){const n=ct(t,s),i=ct(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 hs=b;class us{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:X(),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:X(),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]);h("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=U(2*t,Number.NaN)),J(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),J(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return a("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return a("not implemented"),!1}setCoordsForIntersector3D(t,e,s){a("not implemented")}transformAttribute(t,e,s,n,i){a("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=x(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=hs.getComponentCount(s);for(let i=0;i<n;i++){es(this,0,s,i,t.getAttributeAsDbl(s,i));es(this,1,s,i,e.getAttributeAsDbl(s,i))}}}getStartXY(){return new Q(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 Oe(this,0)}setStartXYZ(t){Ke(this,0,t)}setStartXYZCoords(t,e,s){Ke(this,0,E.construct(t,e,s))}queryStart(t){Je(this,0,t)}setStart(t){$e(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return ts(this,0,t,e)}getStartAttributeAsInt(t,e){return s(0),0}setStartAttribute(t,e,s){es(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=hs.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=hs.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 s(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return s(0),0}getEndXY(){return new Q(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 Oe(this,1)}setEndXYZ(t){Ke(this,1,t)}setEndXYZCoords(t,e,s){Ke(this,1,E.construct(t,e,s))}queryEnd(t){Je(this,1,t)}setEnd(t){$e(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return ts(this,1,t,e)}getEndAttributeAsInt(t,e){return s(0),Math.trunc(0)}setEndAttribute(t,e,s){es(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("");const s=t;s.assignVertexDescription(this.m_description),s.m_attributes&&J(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=H.constructEmpty();return s.vmin=ts(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(ts(this,1,t,e)),s}calculateLength3D(t){return s(0),0}getCoord3D(t){return s(0),{}}getCoord2D(t){const e=Q.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){s(0)}getCoordZ(t){return s(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=hs.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=me.constructEmpty();this.queryLooseEnvelopeOnInterval(e,n);if(n.distance(t)>s)return!1;const i=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(i)&&Q.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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(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=hs.getComponentCount(e);t<s;t++){const s=ts(this,0,e,t);es(this,0,e,t,ts(this,1,e,t)),es(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,n,i){if(!e&&this.isIntersecting(t,0,!1)){if(null!==n||null!==i){const e=U(9,Number.NaN),r=U(9,Number.NaN),o=this.intersect(t,null,e,r,0);s(o<=9),0===o&&h(""),null!==n&&(n[0]=e[0]),null!==i&&(i[0]=r[0])}return 0}let r,o=Number.MAX_VALUE,a=-1,u=o;return r=this.getStartXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==i&&(i[0]=a),null!==n&&(n[0]=0)),r=this.getEndXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==i&&(i[0]=a),null!==n&&(n[0]=1)),r=t.getStartXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==n&&(n[0]=a),null!==i&&(i[0]=0)),r=t.getEndXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==n&&(n[0]=a),null!==i&&(i[0]=1)),o}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 rt(t,e,s)}moveTo(t){const e=this.isClosed(),s=new le;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){s(0)}getDescription(){return this.m_description}assignVertexDescription(t){ns(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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("wrong geometry type");const s=t;s.m_description=et(this.m_description,this.m_description=s.m_description),s.m_XStart=et(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=et(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=et(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=et(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attributes=et(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(!ot(this.m_attributes[i],n.m_attributes[i],e))return!1;return s?this.equalsImpl(n):this.equalsImplTol(n,e)}getImpl(){return this}setAttributeBasic(t,s,n){if(this.addAttribute(t),0===t&&this.isCurve()){(s<0||s>1)&&e("");const t=new le,i=0===s?n:0,r=1===s?n:0;t.setShiftCoords(i,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,s,n),this.setEndAttribute(t,s,n)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=hs.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)}}}us.s_maxMonotonicPartParams=8;class ms extends ce{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 ls{constructor(t){this.m_geoms=[],this.m_description=P(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):e("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===i.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(t){return(t<0||t>=this.m_geoms.length)&&e("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return i.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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new H;const n=new H;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 M;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 me;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}a("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new me;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}a("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);a("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 ls({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==i.enumGeometryCollection&&e("");const s=t;if(s!==this){s.m_geoms.length=0,s.assignVertexDescription(this.m_description);for(const t of this.m_geoms)s.m_geoms.push(t.clone())}}calculateArea2D(){const t=new pt(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new pt(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return s(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 ls({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==i.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let n=0;n<this.m_geoms.length;++n)if(!this.m_geoms[n].equals(s.m_geoms[n],e))return!1;return!0}swap(t){t.getGeometryType()!==i.enumGeometryCollection&&e("");const s=t;s!==this&&(this.m_geoms=et(s.m_geoms,s.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=x(e,t);this.assignVertexDescription(s)}}function cs(t,e=-1){return new ms(t,e)}ls.type=i.enumGeometryCollection;class gs extends us{constructor(t){super(t)}}class ds extends gs{isTrue3D(){return!0}constructor(t){super(t)}}function _s(t,e,s){ps(e,t.getStartXY(),t.getEndXY(),s)}function ps(t,e,s,n){xt(e,s,t,n)}function fs(t,e){return rt(t.m_XStart,t.m_XEnd,e)}function Ps(t,e){return rt(t.m_YStart,t.m_YEnd,e)}function ys(t,e){const s=t.getStartZ(),n=t.getEndZ();return rt(s,n,e)}function xs(t,e,s){const n=Ye.constructPoint2D(t.getStartXY()),i=Ye.constructPoint2D(t.getEndXY());s.setCoordsE(i.x.subE(n.x),i.y.subE(n.y))}function Cs(t,e,s){e.value()<=.5?Ft(2,Ye.constructPoint2D(t.getStartXY()),Ye.constructPoint2D(t.getEndXY()),e,s):Vt(2,Ye.constructPoint2D(t.getStartXY()),Ye.constructPoint2D(t.getEndXY()),e,s)}function vs(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 bs(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=et(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=et(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]=et(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function Ss(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:As(t,e)?4:0}function Ds(t,e,s,n,i,r,o,a){null!==n&&Zt(n,2,Number.NaN),null!==i&&Zt(i,2,Number.NaN),null!==s&&Ht(s,Q,2);const h=ws(t,e,2,s,n,i,r,o,a);return n&&(n.length=h),i&&(i.length=h),s&&(s.length=h),h}function ws(t,e,s,n,i,r,o,a,h){const u=Is(t,e.getStartXY(),o,!1),m=Is(t,e.getEndXY(),o,!1),l=Is(e,t.getStartXY(),o,!1),c=Is(e,t.getEndXY(),o,!1);let g=0,d=0;if(!Number.isNaN(u)){let s=!1;a&&gt(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&&gt(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&&gt(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&&gt(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=et(i,i=r)),2===d&&s>=2&&i&&i[0]>i[1]&&(i[1]=et(i[0],i[0]=i[1]),r&&(r[1]=et(r[0],r[0]=r[1])),n&&(n[1]=et(n[0],n[0]=n[1]))),d;if(g>0)return 0;const _=qs(t,e,o);return Number.isNaN(_.x)?0:(n&&(n[0]=t.getCoord2D(_.x)),i&&(i[0]=_.x),r&&(r[0]=_.y),1)}function As(t,e){const s=Ms(t,e.m_XStart,e.m_YStart),n=Ms(t,e.m_XEnd,e.m_YEnd);if(s<0&&n<0||s>0&&n>0)return!1;const i=Ms(e,t.m_XStart,t.m_YStart),r=Ms(e,t.m_XEnd,t.m_YEnd);if(i<0&&r<0||i>0&&r>0)return!1;return Xs(t)>Xs(e)?Ns(t,e):Ns(e,t)}function Ts(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 Is(t,e,s,n){const i=Q.getNAN(),r=Q.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=Q.getNAN();u.setSub(e,i);let m=u.length(),l=3*m*dt();if(m<=Math.max(s,l))return n&&0===m?Number.NaN:a;if(u.setSub(e,r),m=u.length(),l=3*m*dt(),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=Q.getNAN();n.setSub(e,i);const m=n.dotProduct(u),l=8*n.dotProductAbs(u)*dt();u.leftPerpendicularThis();const g=n.dotProduct(u),d=8*n.dotProductAbs(u)*dt(),_=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=_t(n,0,1);const u=Q.getNAN();if(ps(n,i,r,u),Q.distance(u,e)<=s){if(n<.5){if(Q.distance(u,i)<=s&&Q.distance(e,i)<=s)return a}else if(Q.distance(u,r)<=s&&Q.distance(e,r)<=s)return h;return o?1-n:n}}}return Number.NaN}function Ms(t,e,s){const n=Q.getNAN();n.setCoords(e,s),n.subThis(t.getStartXY());const i=Q.getNAN();i.setSub(t.getEndXY(),t.getStartXY());const r=i.crossProduct(n),o=4*dt()*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?-1:r<-o?1:0}function Ys(t,e,s,n){const i=n?t.m_XStart:t.m_XEnd,r=n?t.m_YStart:t.m_YEnd,o=Q.getNAN();o.x=e.getEndX()-i,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*dt()*s.dotProductAbs(o)){o.x=e.getStartX()-i,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*dt()*s.dotProductAbs(o)}return!0}function Ns(t,e){const s=Q.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!Ys(t,e,s,!1)&&(s.negateThis(),!!Ys(t,e,s,!0))}function Xs(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function qs(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 Q.getNAN();const h=4*dt()*(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*dt()*(Math.abs(r*m)+Math.abs(u*o)),g=l/a,d=Math.abs(a),_=(c*d+h*Math.abs(l))/(a*a)+dt()*Math.abs(g);if(g<-_||g>1+_)return Q.getNAN();const p=n*m-u*i,f=p/a,P=(4*dt()*(Math.abs(n*m)+Math.abs(u*i))*d+h*Math.abs(p))/(a*a)+dt()*Math.abs(f);if(f<-P||f>1+P)return Q.getNAN();let y=_t(g,0,1),x=_t(f,0,1);const C=Q.getNAN();_s(t,y,C);const v=Q.getNAN();if(_s(e,x,v),!s||Q.distance(C,v)>s){const n=Q.getNAN();xt(C,v,.5,n),y=t.getClosestCoordinate(n,!1),x=e.getClosestCoordinate(n,!1);const i=Q.getNAN();_s(t,y,i);const r=Q.getNAN();_s(e,x,r),i.subThis(r);const o=i.length(),a=(t.absNorm()+e.absNorm())*mt();if(o>Math.max(s,a))return Q.getNAN()}return new Q(y,x)}class Fs{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())&&n("");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)&&n("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&n(""),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())&&n(""),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&&n("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&&n(""),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&&n(""),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)&&n(""),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 Vs{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&&(s(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new Vs;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){s(this.uniqueUse())}setQuadTree(t){s(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){s(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function Ls(t){return!(t.isEmpty()||t.getGeometryType()!==i.enumPolyline&&t.getGeometryType()!==i.enumPolygon)&&!(t.getPointCount()<20)}function Rs(t){return!(t.isEmpty()||t.getGeometryType()!==i.enumPolyline&&t.getGeometryType()!==i.enumPolygon)&&!(t.getPointCount()<20)}function zs(t,e){return t.readPoint2D(e+4)}function Bs(t){const e=t.getGeometryType();return e===i.enumEllipticArc?10:e===i.enumBezier?4:e===i.enumRationalBezier2?5:e===i.enumBezier2?2:void h("")}function ks(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Gs(t,e,s,n){const i=t.getPathStart(e),r=t.getPathEnd(e);if(r-i<3)return;const o=2*i,a=Q.getNAN();s.queryPoint2D(o,a);const h=a.x,u=a.y,m=Q.getNAN();s.queryPoint2D(o+2,m);const l=Q.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 Ws(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var js=b;class Zs{static toSegType(t){let e=0;switch(t){case i.enumLine:e=1;break;case i.enumBezier:e=2;break;case i.enumEllipticArc:e=4;break;case i.enumRationalBezier2:e=8;break;case i.enumBezier2:e=16;break;default:h("")}return e}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 Hs extends Ee{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?i.enumPolygon:i.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){s(this.m_bPolygon);const n=this.getPathIndexFromPointIndex(t),i=this.getPathStart(n);if(i===t)return;const r=this.getPathEnd(n);(t>=r||t<i)&&e("change_ring_start_point");for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),n=js.getComponentCount(s);this.m_vertexAttributes.get(e).rotate(i*n,t*n,r*n)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(i,t,r),this.m_curveData.m_segmentParamIndex.rotate(i,t,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 F(t),s=new pt(0),n=new pt(0);if(0!==this.m_pointCount){const i=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new Fs({parent:this});for(t.stripAttributes();t.nextPath();){n.reset();const r=t.getPathIndex();Gs(this,r,i,n),Ws(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(),Gs(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 s(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(!Hs.isNonLinearSegmentFlag(s))continue;const n=this.m_curveData.m_segmentParamIndex.read(t),i=e.m_curveData.m_segmentParamIndex.read(t),r=ks(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(!ft(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=V(1,0),this.m_pathFlags=L(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 Zs),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 pt(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 pt(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return s(0),0}calculatePathLength3D(t,e){return s(0),0}copyTo(t){c(t.getGeometryType())||e(""),this!==t&&super.copyTo(t)}swap(t){s(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=Hs.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 fm;if(1!==i){if(this.isClosedPath(n)&&t===this.getPathStart(n)){o=this.getPathEnd(n)-1}this.getSegmentBuffer(o,a,!0)}const h=new fm;1!==r&&this.getSegmentBuffer(t,h,!0);const u=t+1;this.setXYCoordsNoCurves(t,e,s);const m=new Q(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,i){if(0===t&&this.hasNonLinearSegments()){i<2&&n("");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,i)}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(t,s){this===t&&e("Multi_path_impl::add");for(let e=0,n=t.getPathCount();e<n;e++)this.addPath(t,e,!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(t,s,i,r,o){if(this===t&&e("Multi_path_impl.add_segments_from_path"),o||0!==this.getPathCount()||(o=!0),s<0&&(s=t.getPathCount()-1),(s>=t.getPathCount()||i<0||r<0||i+r>t.getSegmentCountPath(s))&&n("add_segments_from_path"),0===r)return;const a=t.getPathStart(s),h=t.isClosedPath(s)&&i+r===t.getSegmentCountPath(s);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let u=r;const m=a+i;let l=m+1;o&&(u++,l--),!o&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(m)&&(t.getXY(m).equals(this.getXY(this.m_pointCount-1))||e("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 e=t.m_pathFlags.read(s);this.m_bPolygon&&(e|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,e),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 e=0,n=this.m_description.getAttributeCount();e<n;e++){const s=this.m_description.getSemantics(e),n=js.getComponentCount(s),i=t.m_description.getAttributeIndex(s);if(g>0){if(i<0||!t.m_vertexAttributes.get(i)){const t=js.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(n*c,t,g*n,n*c),h&&this.m_vertexAttributes.get(e).insertRange(n*c+g*n,t,n,n*c);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(n*c,t.m_vertexAttributes.get(i),n*l,g*n,!0,n,n*c)}h&&this.m_vertexAttributes.get(e).insertRangeFromStream(n*(c+g),t.m_vertexAttributes.get(i),n*a,n,!0,n,n*(c+g))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,n=m;s<r;s++){e+=ks(t.m_curveData.m_segmentFlags.read(n)),n++}if(e>0){this.initSegmentData(e);let s=m,n=c-(o?0:1),i=0;for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(n,e),Hs.isNonLinearSegmentFlag(e)){i++;let r=t.m_curveData.m_segmentParamIndex.read(s);const o=ks(e);this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<o;e++){const e=t.m_curveData.m_segmentParams.read(r);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,r++}this.incCurveType(e,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(t){t>=this.getPathCount()&&e("");const s=this.getPathSize(t);if(0===s)return;const n=this.getPathStart(t),i=this.isClosedPath(t);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(!Hs.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 e=0,a=this.m_description.getAttributeCount();e<a;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),i=js.getComponentCount(t);this.m_vertexAttributes.get(e).reverseRange(i*(n+r),i*(s-r),i)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const s=this.getPathCount();t<0&&(t=s-1),t>=s&&e("");const n=this.getPathStart(t),i=this.getPathSize(t);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),s=js.getComponentCount(t);this.m_vertexAttributes.get(e).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);Hs.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 e=t+1;e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e-1,t-i)}if(this.m_pathFlags)for(let e=t+1;e<=s;e++){const t=this.m_pathFlags.read(e);this.m_pathFlags.write(e-1,t)}this.m_paths.resize(s),this.m_pathFlags.resize(s),this.m_pointCount-=i,this.m_reservedPointCount-=i,t===s-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,s,n,i){this===s&&e("Multi_path_impl::insert_path");const r=this.getPathCount();if(!i&&s.hasNonLinearSegmentsPath(n))return t=this.insertPath(t,s,n,!0),this.reversePath(t),t;n>=s.getPathCount()&&e(""),t>r&&e(""),t<0&&(t=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(t,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=t<r?this.getPathStart(t):h;for(let e=0,g=this.m_description.getAttributeCount();e<g;e++){const t=this.m_description.getSemantics(e),n=s.getDescription().getAttributeIndex(t),r=js.getComponentCount(t);if(n>=0&&s.m_vertexAttributes.get(n))0!==u&&this.m_vertexAttributes.get(e).insertRangeFromStream(m*r,s.m_vertexAttributes.get(n),r*o,r,!0,r,r*h),this.m_vertexAttributes.get(e).insertRangeFromStream((m+u)*r,s.m_vertexAttributes.get(n),r*(o+u),r*(a-u),i,r,r*(h+u));else{const s=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(m*r,s,r*a,r*h)}}const l=h+a;this.m_paths.add(l);for(let e=r;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+a)}this.m_pathFlags.add(0);for(let e=r-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let c=s.getPathFlagsStreamRef().read(n);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(t,c),s.hasNonLinearSegments()){this.initSegmentData(0);let t=o,e=0;for(let n=0;n<a;n++){e+=ks(s.m_curveData.m_segmentFlags.read(t)),t++}if(e>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=L(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=V(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=R(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(Hs.isNonLinearSegmentFlag(e)){this.m_curveData.m_segmentFlags.write(n,e),this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);const r=ks(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),t}insertPath2D(t,s,n,i,r){const o=this.getPathCount();(t>o||n<0)&&e(""),t<0&&(t=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=t<o?this.getPathStart(t):a;if(s)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,s,n,i,r,2*a);else{const t=js.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*i,2*a)}for(let e=1,u=this.m_description.getAttributeCount();e<u;e++){const t=this.m_description.getSemantics(e),s=js.getComponentCount(t),n=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(h*s,n,s*i,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+i)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,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),t}insertPathFromMultipoint(t,s,n,i,r){const o=s.getImpl(),a=this.getPathCount();(t>a||n<0)&&e("");const h=i<0?o.getPointCount()-n:i;if(h>o.getPointCount()&&e(""),n>=o.getPointCount()&&e("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const u=this.m_pointCount,m=n;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<a?this.getPathStart(t):u;for(let e=0,d=this.m_description.getAttributeCount();e<d;e++){const t=this.m_description.getSemantics(e),s=o.getDescription().getAttributeIndex(t),n=js.getComponentCount(t);if(s>=0){const s=o.getAttributeStreamRef(t);this.m_vertexAttributes.get(e).insertRangeFromStream(l*n,s,n*m,n*h,r,n,n*u)}else{const s=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(l*n,s,n*h,n*u)}}const c=u+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),this.notifyModifiedFlags(2001)}insertPoints(t,s,i,r,o,a,h){if(this===i&&e("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),r<0&&(r=i.getPathCount()-1),(t>this.getPathCount()||s>=0&&s>this.getPathSize(t)||r>=i.getPathCount()||a>i.getPathSize(r))&&n(""),!a)return;if(this.mergeVertexDescription(i.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=i.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(t));const u=this.m_pointCount;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),l=m+s;a<0&&(a=i.getPathSize(r));const c=i.getPathStart(r),g=c+a;for(let e=0,n=this.m_description.getAttributeCount();e<n;e++){const t=this.m_description.getSemantics(e),n=js.getComponentCount(t),r=i.m_description.getAttributeIndex(t);if(r<0||!i.m_vertexAttributes.get(r)){const s=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(n*l,s,g*n,n*u);continue}this.m_vertexAttributes.get(e)?.insertRangeFromStream(n*(m+s),i.m_vertexAttributes.get(r),n*(c+o),a*n,h,n,n*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 e=t+1,n=this.getPathCount();e<=n;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+a)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,i,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||i<0)&&n(""),!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,i,r,o,2*a);for(let n=1,u=this.m_description.getAttributeCount();n<u;n++){const t=this.m_description.getSemantics(n),s=js.getComponentCount(t),i=js.getDefaultValue(t);this.m_vertexAttributes.get(n).insertRange((h+e)*s,i,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 n=t+1,u=this.getPathCount();n<=u;n++)this.m_paths.write(n,this.m_paths.read(n)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,i,r,o){const a=s.getImpl(),h=this.getPathCount();t<0&&(t=this.getPathCount());const u=a.getPointCount();if((i<0||i>u)&&n(""),(r<0||i+r>u)&&(r=u-i),e<0&&(e=t<h?this.getPathSize(t):0),(t>h||t<h&&e>this.getPathSize(t)||t===h&&e>0||r<0)&&n(""),!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 n=0,_=this.m_description.getAttributeCount();n<_;n++){const t=this.m_description.getSemantics(n),s=js.getComponentCount(t);if(a.getDescription().getAttributeIndex(t)<0){const e=js.getDefaultValue(t);this.m_vertexAttributes.get(n).insertRange(s*c,e,d*s,s*m);continue}const h=a.getAttributeStreamRef(t);this.m_vertexAttributes.get(n).insertRangeFromStream(s*(l+e),h,s*(g+i),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 n=t+1,_=this.getPathCount();n<=_;n++){const t=this.m_paths.read(n);this.m_paths.write(n,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&n(""),t===i&&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=js.getComponentCount(e),n=js.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=i;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 i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&n(""),t===i&&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=js.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(t).insertAttributes(i*a,s,n,i*r);else{const e=js.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,n=i;s<=n;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))&&n("Multi_path.remove_point");const i=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&n("Multi_path.remove_point");const o=i+e;for(let n=0,a=this.m_description.getAttributeCount();n<a;n++)if(this.m_vertexAttributes.get(n)){const t=this.m_description.getSemantics(n),e=js.getComponentCount(t);this.m_vertexAttributes.get(n).eraseRange(e*o,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>i&&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&&i+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 n=s;n>=t+1;n--){const t=this.m_paths.read(n);this.m_paths.write(n,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}h("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),n=this.getPathEnd(t);s<n;s++)Hs.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=Hs.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=n,n}startPathCoords(t,e){this.startPathPoint(new q({x:t,y:e}))}startPath(t){this.startPathPoint(new q({pt:t}))}startPath3D(t){this.startPathPoint(new q({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new q({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&e("");const s=t.getDescription();let n;if(this.m_description!==s){this.mergeVertexDescription(s);const e=new q({vd:this.m_description});t.copyCommonAttributesTo(e),n=e}else n=t;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,n):(this.insertPoint(-1,-1,n),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=V(2),this.m_paths.write(0,0),this.m_pathFlags=L(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=D(),n=new q({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=x(this.m_description,X()),s=D(),n=new q({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=D(),s=new q({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&h("");const s=this.getPathCount();if(t>s&&e(""),!this.isClosedPath(t))return;this.m_pathFlags||h("");const n=this.m_pointCount,i=this.getPathStart(t),r=this.getPathEnd(t);if(r-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=js.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*r,this.m_vertexAttributes.get(t),s*i,s,!0,1,s*n)}for(let e=s;e>t;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,n)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&h(""),t>this.getPathCount()&&e(""),this.m_pathFlags||h(""),this.m_pathFlags.clearBits(t,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&&h(""),this.isEmpty())return;this.m_pathFlags||h("");let t=0;const e=this.getPathCount();for(let h=0;h<e;h++)this.isClosedPath(h)&&(this.getPathSize(h)>0?t++:this.m_pathFlags.clearBits(h,1));if(0===t)return;const s=this.hasNonLinearSegments();let n=0;const i=this.getPathCount(),r=this.m_description.getAttributeCount(),o=new Array(r);let a=null,u=null;for(let h=0;h<i;++h){const e=this.getPathStart(h),i=this.getPathSize(h),m=this.isClosedPath(h);if(i>0){const h=e+n;for(let s=0;s<r;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),r=js.getComponentCount(n);if(!o[s]){const e=r*(this.m_pointCount+t),i=Y(n,e);o[s]=i}o[s].writeRange(h*r,i*r,this.m_vertexAttributes.get(s),e*r,!0,1),m&&o[s].writeRange((h+i)*r,r,this.m_vertexAttributes.get(s),e*r,!0,1)}if(s){if(null===a){const e=this.m_pointCount+t;a=L(e),u=V(e)}a.writeRange(h,i,this.m_curveData.m_segmentFlags,e,!0,1),u.writeRange(h,i,this.m_curveData.m_segmentParamIndex,e,!0,1),m&&(a.write(h+i,1),u.write(h+i,-1))}}this.m_paths.write(h,e+n),m&&(this.m_pathFlags.clearBits(h,1),++n)}this.m_paths.write(i,this.m_pointCount+t),this.m_pathFlags.clearBits(i,1);for(let h=0;h<r;h++)this.m_vertexAttributes.get(h)&&this.m_vertexAttributes.set(h,o[h]);s&&(this.m_curveData.m_segmentFlags=a,this.m_curveData.m_segmentParamIndex=u),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const s=this.m_pathFlags.read(t);if(1&s||this.m_pathFlags.write(t,1|s),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);1!==s&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,s){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),s.getEndXY().equals(this.getXY(this.getPathStart(t)))||e("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(s,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(s.getDescription());const n=s.getStartXY(),r=this.getPathEnd(t)-1;n.equals(this.getXY(r))||e("close_path_with_segment: start point mismatch");const o=s.getGeometryType();if(o===i.enumLine)return void this.closePathWithLine(t);{const t=Bs(s);this.initSegmentData(t);const e=Zs.toSegType(o),n=this.m_curveData.m_segmentFlags.read(r);if(n!==e)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),s.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(e,1),1!==n?this.incCurveType(n,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(r);s.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,e)}}const n=this.m_pathFlags.read(t);1&n||this.m_pathFlags.write(t,1|n),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 s(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Hs.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 me)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=D(),i=new q({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(t,s){if(t.isClosed()||e("add_path_from_closedSegment: segment must be closed"),s){const e=t.getReversed(),s=new q;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new q;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,s){const n=t.getDescription();this.mergeVertexDescription(n);const r=D(),o=new q({vd:n,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===i.enumLine)(s||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let n=!1;if((s||this.isEmptyImpl())&&(n=!0),!n){t.getStartXY().equals(this.getXY(this.m_pointCount-1))||e("add_segment: start point mismatch")}if(n&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=D(),e=new q({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const i=Bs(t);this.initSegmentData(i),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=i;const r=Zs.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(t,s,n,i){for(let a=t;a<n-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,s,n,i);if(0!==o)for(let e=1;e<r;e++){const r=this.m_description.getSemantics(e);this.interpolateAttributesSemanticsImpl(r,t,s,n,i,o)}}interpolateAttributesSemantics(t,s,n,i,r){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===js.getInterpolation(t)&&e("angular interpolation");for(let a=s;a<i-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const o=this.calculateSubLength2D(s,n,i,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,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(t,s,n,i){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===js.getInterpolation(t)&&e("angular interpolation");const r=this.calculatePathSubLength2D(s,n,i);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,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=js.getComponentCount(t),m=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,a,m,u);const l=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,u);const c=U(js.maxComponentCount(),Number.NaN);J(c,m,0,0,u);let g=0;const d=js.getDefaultValue(t),_=js.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();O(_,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,n,i,r){s(0!==t);const o=this.querySegmentIterator(),a=js.getInterpolation(t),h=this.getPathStart(e)+n,u=this.getPathStart(e)+i;if(u===h)return;const m=js.getComponentCount(t),l=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,m);const c=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,u,c,m);const g=new pt(0);o.resetToVertex(h,e),o.setCirculator(this.isClosedPath(e));const d=js.getDefaultValue(t),_=U(js.maxComponentCount(),Number.NaN);J(_,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}O(a,l,c,_,0,m,f,d)}while(o.getEndPointIndex()!==u)}querySegment(t,s,n){const i=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&e("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(t){const s=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(s);return n>=this.getSegmentCountPath(s)&&e("get_segment"),this.getSegmentTypeFromPath(s,n)}getSegmentFromPath(t,e,s,n){const i=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef();let o=1;switch(r&&(o=31&r.read(i)),o){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:h("")}const a=s.get();let u,m=null;n?(m=P(),a.assignVertexDescription(m)):a.assignVertexDescription(this.m_description),u=i===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):i+1;We(a,this.getXY(i));if(Ze(a,this.getXY(u)),!n)for(let h=1,l=this.m_description.getAttributeCount();h<l;h++){const t=this.m_description.getSemantics(h),e=js.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,i,s);a.setStartAttribute(t,s,e);const n=this.getAttributeAsDbl(t,u,s);a.setEndAttribute(t,s,n)}}if(Hs.isNonLinearSegmentFlag(o)){const t=this.m_curveData.m_segmentParamIndex.read(i);a.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);zs(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(t,s,n,i=!1){const r={iSegment:-1},o=i?r:{tSegment:0};if(n.setEmpty(),this.isEmpty())return r;if((t<0||t>=this.getPathCount())&&e("query_point_along_path"),s<0)return r;const a=this.getPathSize(t);if(0===a)return r;if(1===a)return this.getPointByVal(this.getPathStart(t),n),o.tSegment=0,r.iSegment=this.getPathStart(t),r;const h=this.querySegmentIteratorAtVertex(this.getPathStart(t)),u=new pt(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(t)){const e=this.getPathStart(t);return this.getPointByVal(e,n),o.tSegment=1,r.iSegment=this.getPathEnd(t)-1,r}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,n),this.getPathSize(t)>1?(o.tSegment=1,r.iSegment=this.getPathEnd(t)-2,r):(o.tSegment=0,r.iSegment=this.getPathStart(t),r)}}queryPointsAlongPath(t,s,n,i,r,o){{let t=0;for(let a=0;a<s;++a)i&&i[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),t>n[a]&&e("query_points_along"),t=n[a]}const a=this.getPathSize(t);if(0===s||0===a)return 0;if(1===a){const e=this.getPathStart(t);return i&&this.getPointByVal(e,i[0]),o&&(o[0]=0),r&&(r[0]=e),1}const h=this.getPathStart(t),u=new pt(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(t)){const e=this.getPathStart(t),s=0;i&&this.getPointByVal(e,i[c]),o&&(o[c]=s),r&&(r[c]=e),c++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;i&&this.getPointByVal(e+1,i[c]),o&&(o[c]=s),r&&(r[c]=e),c++}return c}queryPointsAlong(t,s,n,i,r){{let o=0;for(let a=0;a<t;++a)n&&n[a].setEmpty(),i&&(i[a]=-1),r&&(r[a]=0),o>s[a]&&e("query_points_along"),o=s[a]}if(0===t)return 0;const o=new pt(0),a=this.querySegmentIterator();let h=-1,u=0,m=0,l=s[u];for(;a.nextPath();)for(;a.hasNextSegment();){h=a.getPathIndex();const e=a.nextSegment(),c=e.calculateLength2D(),g=o.getResult();for(o.add(c);o.getResult()>=l;){let o=l-g;o>c&&(o=c);const h=e.lengthToT(o);if(n&&e.queryCoord(h,n[m]),r&&(r[m]=h),i&&(i[m]=a.getStartPointIndex()),m++,u++,l=s[u],u===t)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 Fs({parent:this})}querySegmentIteratorAtVertex(t){return new Fs({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,n,i){if(n instanceof M&&s(0,"not implemented for Envelope"),n instanceof S&&s(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&e(""),this.isEmpty())return void n.setEmpty();const r=this.getAttributeStreamRef(0),o=me.constructEmpty();o.setEmpty();for(let e=2*this.getPathStart(t),a=2*this.getPathEnd(t);e<a;){const t=a-e;s(!(1&t)),o.mergePointsInterleaved(r,e/2,t/2),e+=t}if(n.setCoords({env2D:o}),this.hasNonLinearSegmentsPath(t)){const e=this.querySegmentIterator();if(e.resetToPath(t),e.nextPath())for(;e.hasNextSegment();){const t=e.nextCurve();if(!t)break;{const e=me.constructEmpty();i?t.queryEnvelope(e):t.queryLooseEnvelope(e),n.mergeEnvelope2D(e)}}else s(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=ks(4)*this.m_curveData.m_arcCount+ks(2)*this.m_curveData.m_bezierCount+ks(8)*this.m_curveData.m_rbezier2Count+ks(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(Hs.isNonLinearSegmentFlag(e)){t+=ks(e)}}const e=R(t);let s=0;for(let n=0,i=this.getPointCount();n<i;n++){const t=this.m_curveData.m_segmentFlags.read(n);if(Hs.isNonLinearSegmentFlag(t)){let i=this.m_curveData.m_segmentParamIndex.read(n);this.m_curveData.m_segmentParamIndex.write(n,s);const r=ks(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){s(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=V(0),this.m_pathFlags=L(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=V(0),this.m_pathFlags=L(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 Us(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 Zs),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){s(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),n=this.getPathEnd(t),i=this.getPathStart(t);let r=-1;const o=new Q;o.y=Number.NEGATIVE_INFINITY,o.x=Number.NEGATIVE_INFINITY;for(let s=i+0;s<n;s++){const t=e.readPoint2D(2*s);-1===o.compare(t)&&(r=s,o.setCoordsPoint2D(t))}return r}applyTransformationToPath(t,s){if(s>=this.getPathCount()&&e("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const n=this.m_vertexAttributes.get(0);if(!(s<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(s))){let e,i;return s<0?(e=0,i=this.m_pointCount):(e=this.getPathStart(s),i=this.getPathEnd(s)),n.applyTransformation(t,2*e,i-e),void this.notifyModifiedFlags(2001)}const i=new this.m_segmentBufferCTor,r=this.getPathCount();let o=s<0?0:s;do{const e=this.getPathStart(o),r=this.getPathEnd(o),a=this.isClosedPath(o),h=n.readPoint2D(2*e);if(!this.hasNonLinearSegmentsPath(o)){n.applyTransformation(t,2*e,r-e);continue}const u=Q.getNAN();for(let s=e;s<r;++s){if(1!==(31&this.m_curveData.m_segmentFlags.read(s))){const o=a&&s+1===r;o&&n.writePoint2D(2*e,h),this.getSegmentBuffer(s,i,!0),i.get().applyTransformation(t);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*e,i.get().getEndXY());continue}const o=2*s;n.queryPoint2D(o,u),t.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(t,s,n){const i=this.getPathStart(t)+s,r=this.getPathStart(t)+n;(i<0||r>this.getPointCount()-1)&&d("");const o=this.querySegmentIterator();if(i>r&&(this.isClosedPath(t)||e("cannot iterate across an open path"),o.setCirculator(!0)),i===r)return 0;let a=0,h=0;o.resetToVertex(i,t);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=me.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(t,s){this===t&&e("Multi_path_impl::add");let n=this.getPathCount();for(let e=0,i=t.getPathCount();e<i;e++)this.addPath(t,e,!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(t,s,n){const i=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&e("getSegmentBuffer"),this.getSegmentFromPath(i,r,s,n)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,n=this.getSegmentFlagsStreamRef();let r=1;switch(n&&(r=31&n.read(s)),r){case 1:return i.enumLine;case 2:return i.enumBezier;case 4:return i.enumEllipticArc;case 8:return i.enumRationalBezier2;case 16:return i.enumBezier2;default:h("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,s=this.getPathCount();e<s;e++){const s=this.getPathStart(e),n=this.getPathEnd(e),i=n-s;for(let e=s;e<n;e++){const n=31&this.m_curveData.m_segmentFlags.read(e);if(1===n)continue;2!==n&&a("ensure_xy_monotone_segments");const r=(e-s+1)%i+s,o=this.m_curveData.m_segmentParamIndex.read(e),h=lt(Q,4);h[0]=this.getXY(e),h[3]=this.getXY(r),h[1].x=this.m_curveData.m_segmentParams.read(o),h[1].y=this.m_curveData.m_segmentParams.read(o+1),h[2].x=this.m_curveData.m_segmentParams.read(o+2),h[2].y=this.m_curveData.m_segmentParams.read(o+3),Fe(h)&&(t=!0,this.m_curveData.m_segmentParams.write(o,h[1].x),this.m_curveData.m_segmentParams.write(o+1,h[1].y),this.m_curveData.m_segmentParams.write(o+2,h[2].x),this.m_curveData.m_segmentParams.write(o+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 Vs),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=z(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Vs),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=B(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Hs.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 Zs),Hs.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 Zs),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 Zs);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=L(e,1),this.m_curveData.m_segmentParamIndex=V(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=R(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 Zs),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=Nt(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(t,n,i){(t<0||t>=this.getPointCount())&&e("Multi_path_impl.replace_segment"),s(n.isCurve());const r=this.getPathIndexFromPointIndex(t),o=this.getPathStart(r),a=(t-o+1)%this.getPathSize(r)+o;{const e=this.getXY(t),i=this.getXY(a),r=!e.isEqualPoint2D(n.getStartXY())||!i.isEqualPoint2D(n.getEndXY());s(!r)}this.replaceSegmentImpl(t,a,n,i)}replaceSegmentImpl(t,e,n,i){const r=n.getDescription();this.mergeVertexDescription(r);const o=U(32,Number.NaN),a=new q({vd:r,attribBuffer:o,initDefaultValues:!1}),h=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),u=ks(h),m=Bs(n);let l,c=!1;u>=m?(s(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=n.getGeometryType(),d=Zs.toSegType(g);i||(n.queryStart(a),this.setPointByValNoCurves(t,a),n.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&&n.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(t,s,n){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(s<0||s>1)&&e("");const t=new le,i=0===s?n:0,r=0===s?0:1;t.setShiftCoords(i,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,s,n)}}Hs.st_totalCurveCount=0;class Us{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new me(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=me.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 Os extends Hs{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=fm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=fm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=fm):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=fm,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=fm,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):h("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=fm)}getBoundary(){return Js(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Os.type}getDimension(){return 1}createInstance(){return new Os({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Os.type=i.enumPolyline;var Qs=i;function Ks(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===Qs.enumPolygon)return 0!==t.calculateArea2D();if(s===Qs.enumPolyline)return $s(t.getImpl(),e,!0).bNotEmpty;if(s===Qs.enumEnvelope)return!0;if(m(s))return!!t.isClosed();if(l(s))return!1;if(s===Qs.enumGeometryCollection){const s=t;for(let t=0,n=s.getGeometryCount();t<n;t++)if(Ks(s.getGeometry(t),e))return!0;return!1}a("")}function Js(t,e){const s=t.getGeometryType();if(s===Qs.enumPolygon){const e=new Os({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===Qs.enumPolyline)return $s(t.getImpl(),e,!1).boundary;if(s===Qs.enumEnvelope){const e=new Os({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(m(s)){const e=new Se({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new q;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===Qs.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(s))return new q({vd:t.getDescription()});a("")}function $s(t,e,s){const n=!1,i=t;let r=null;if(s||(r=new Se({vd:i.getDescription()})),!i.isEmpty()){const t=new W(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 G,n=i.getAttributeStreamRef(0),o={userSort(t,e,s){const i=Q.getNAN(),r=Q.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 q;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,Yt()),h=i):t.write(i,Yt()),u++;else{if(1&u){if(s)return{bNotEmpty:!0,boundary:new Se({})}}else t.write(h,Yt());a=e,h=i,u=1}}if(1&u){if(s)return{bNotEmpty:!0,boundary:new Se({})}}else t.write(h,Yt());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==Yt();e++)i.getPointByVal(t.read(e),m),r.add(m)}}}return s?{bNotEmpty:n,boundary:new Se({})}:{bNotEmpty:n,boundary:r}}function tn(t,e,n,i){const r=4*dt()*(Math.abs(e.vmin)+Math.abs(e.vmax)),o=dt();if(1===t.getMaxDerivative()){s(n>0);const o=hn(t,0,e,dt(),r);return i[0]=o.root,o.cRoots}let a,h=[];const u=new H(e.vmin-r,e.vmax+r);h.push(new Q(u.vmin,u.vmax));let m=0;for(let s=t.getMaxDerivative()-1;s>=0;s--){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(s===t.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:g}=hn(t,s,H.construct(a[u][0],a[u][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:g}=un(t,s,H.construct(a[u][0],a[u][1]),o,.5*r)),1===g){if(0===s){if(m<n){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=Q.getNAN();t[0]=a[u][0],t[1]=l,h.push(t);const e=Q.getNAN();e[0]=l,e[1]=a[u][1],h.push(e)}continue}}h.push(a[u])}}return m}function en(t,e,s,n){const i=new at,r=cn(new at(t),new at(e),s,i);return n[0]=i.value(),r}function sn(t,e,s,n,i,r){const o=lt(at,2),a=gn(new at(t),new at(e),new at(s),n,i,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function nn(t,e,s,n,i,r,o){const a=lt(at,3),h=dn(new at(t),new at(e),new at(s),new at(n),i,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function rn(t,e,s,n,i,r,o,a){return an(t,e,s,n,i,r,o,a)}function on(t,e,s,n,i,r){return ln(t,e,s,n,i,r)}function an(t,e,s,n,i,r,o,a){const h=U(s*s,Number.NaN);h.fill(0),J(a,n,0,0,s);const u=U(s,Number.NaN),m=U(s,Number.NaN),l=U(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=mn(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+_)*zt(n-c-o)<zt(n-_)*o){c=mn(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 hn(t,e,s,n,i){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,a=s.vmax,u=0,m=Number.MAX_VALUE,l=t.getValue(e,o),c=t.getValue(e,a),g=0,d=0,_=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(r.funcAtRoot=l,r.root=o,r.cRoots=0===l?1:0,r):(r.funcAtRoot=c,r.root=a,r.cRoots=0===c?1:0,r);Math.abs(l)<Math.abs(c)&&(a=et(o,o=a),c=et(l,l=c)),u=o,g=l;let p=!0,f=0;for(;0!==c&&Math.abs(o-a)>n*Math.abs(a)+i;f++){let s=f>64;if(!s){d=l!==g&&c!==g?o*c*g/((l-c)*(l-g))+a*l*g/((c-l)*(c-g))+u*l*c/((g-l)*(g-c)):a-c*(a-o)/(c-l);const t=(3*o+a)/4;if(s=!(d>t&&d<a||d>a&&d<t),!s){const t=n*Math.abs(a)+i;if(p){const e=Math.abs(a-u);s=Math.abs(d-a)>=.5*e||e<t}else{const e=Math.abs(u-m);s=Math.abs(d-a)>=.5*e||e<t}}}if(s?(d=(o+a)/2,p=!0):p=!1,_=t.getValue(e,d),0===_)return r.root=d,r.funcAtRoot=_,r.cRoots=1,r;if(!s){const s=o-d,n=d-a;if(Math.abs(s)>10*Math.abs(n)){let s=a+3*n;for(let n=0;n<2;n++){const n=t.getValue(e,s);Nt(l)*Nt(n)>0?(o=s,l=n):s=rt(o,a,.75)}}else if(Math.abs(n)>10*Math.abs(s)){let n=o-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,n);Nt(c)*Nt(s)>0?(a=n,c=s):n=rt(o,a,.25)}}}m=u,u=a,g=c,Nt(l)*Nt(_)<0?(a=d,c=_):(o=d,l=_),Math.abs(l)<Math.abs(c)&&(a=et(o,o=a),c=et(l,l=c)),128===f&&h("Root_finder iterations exceeded")}return r.root=a,r.funcAtRoot=c,r.cRoots=1,r}function un(t,e,s,n,i){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,a=t.getValue(e,o),u=s.vmax,m=t.getValue(e,u);if(a>=0&&m>=0||a<=0&&m<=0)return Math.abs(a)<Math.abs(m)?(r.funcAtRoot=a,r.root=o,r.cRoots=0===a?1:0,r):(r.funcAtRoot=m,r.root=u,r.cRoots=0===m?1:0,r);m<0&&(m=et(a,a=m),u=et(o,o=u));let l=.5*(o+u),c=Math.abs(u-o),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 E=32;let S=0;for(;++S<100;){let s;S>E||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(o-u)>t){const e=Math.min(o,u),n=Math.max(o,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-o),s=l,l=o+g,n=o===l||u===l}while(0);else for(;;){g=x*d/_,s=l,l-=g,n=l===s;const t=Math.min(o,u),e=Math.max(o,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=o,h=u;d<0?(a=d,o=l):(m=d,u=l),b===y&&(o===r&&u===h||v>1&&Math.abs(g)>=.5001*Math.abs(c))?C++:C=0,b===p?(P++,v=0):(P=0,v++)}return 100===S&&h("Root_finder iterations exceeded"),r.root=l,r.funcAtRoot=d,r.cRoots=1,r}function mn(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=U(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=et(o,o=h)),o>u&&(u=o),h<m&&(m=h)}}let l=0;const c=(Math.abs(u)+Math.abs(m))*dt()*100,g=U(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=on(_,null,u,0,m,c));const p=_(l);for(let f=0,P=o;f<P;f++)s[f]=_t(g[f],i[f],r[f]);return p}function ln(t,e,s,n,i,r){const o=ue();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&&(_=et(p,p=_),d=et(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 cn(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 gn(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 cn(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]=et(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(Lt));if(o.lt(ut))return 0;const a=new at(e.value()>=0?1:-1),h=o.clone().sqrtThis(),u=new at(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let m=0;r[0].setE(u.divE(t));const l=new at(r[0].value()),c=new at(t.value()).mulE(l).addE(new at(e.value()).mulE(l).addE(new at(s.value())));return c.isZero()||Cn(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 at(t.value()).mulE(l).addE(new at(e.value()).mulE(l).addE(new at(s.value())))),c.isZero()||Cn(r[m],t,e,s,r[m]),n.containsCoordinate(r[m].value())&&m++,2===m&&r[0].value()>r[1].value()&&(r[1]=et(r[0],r[0]=r[1])),m):m}function dn(t,e,s,n,i,r,o){if(0===t.value()){return gn(e,s,n,i,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=gn(t,e.addE(t),n.negate(),i,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(ht)&&(o[s-1]=et(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 vn(t,e,s,n,i,o)}function _n(t,s,n,i,r,o){return(o<s||s<0)&&e("nth_degree_real_roots"),bn(t,s,n,i,r)}function pn(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 fn{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 pt(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 pt(0),n=new at(1),i=new at(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 at(1),n=new at(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 Pn(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=et(o,o=a),i=et(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 yn(t,e,s,n,i,r,o,a){return Pn(t,e,s.value(),pn(n,i,r,o),a,!1)}class xn{constructor(t,e,s){this.coefs=lt(at,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new at(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new at(t);return at.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 at(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 Cn(t,e,s,n,i){return Pn(0,0,t.value(),new xn(e,s,n),i,!0)}function vn(t,e,s,n,i,r){const o=lt(at,3);let a=0;const u=e.negate().divThisE(t.clone().mulThis(3));i.containsCoordinate(u.value())&&(o[0].setE(u),a=1);const m=lt(at,2),l=gn(t.mul(3),e.mul(2),s,i,!1,m);if(l<0)return n.isZero()?-1:0;for(let h=0;h<l;h++)i.containsCoordinate(m[h].value())&&o[a++].setE(m[h]);tt(o,0,a,(t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);const c=lt(at,5);c[0].set(i.vmin);for(let h=0;h<a;h++)c[1+h].setE(o[h]);c[1+a].set(i.vmax);const g=a+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 o=pn(t,e,s,n);i.setError(o.estimateError(i.value())),r[_]=i,_++,d++}}for(let p=d;p<g;p++){const o=c[p].clone(),a=t.clone().mulThisE(o).addThisE(e).mulThisE(o).addThisE(s).mulThisE(o).addThisE(n).isZero();if(a||!c[p].eq(c[p-1])){if(a||yn(c[p-1].value(),c[p].value(),c[p-1].clone().addThisE(c[p]).divThisByPower2(2),t,e,s,n,o)){if(_>0&&o.eq(r[_-1]))continue;if(_>=3&&h("cubic_polynomial_solver_too_many_roots"),a){const i=pn(t,e,s,n);o.setError(i.estimateError(o.value()))}r[_]=o,_++}if(c[p].value()===i.vmax)break;a&&p++}}return _}function bn(t,e,s,n,i,r){const o=new fn(t,e,s,dt());let a=0;if(2===o.truePower)a=gn(t[2],t[1],t[0],s,n,i);else if(1===o.truePower)a=cn(t[1],t[0],s,i[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=tn(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 Sn extends gs{constructor(t){return void 0===t||vt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new Q(0,0),void(this.m_weights=[1,0,1])):(t.fromPoint&&t.weight?t={fromPoint:t.fromPoint,controlPoint1:t.controlPoint1,toPoint:t.toPoint,weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weight?t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weights&&(t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:t.weights[0],weight1:t.weights[1],weight2:t.weights[2]}),t.fromPoint&&t.weight0?(super({start:t.fromPoint,end:t.toPoint}),(t.weight0<=0||t.weight1<0||t.weight2<=0)&&e("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void a("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),la(this)}constructWeights(t,e,s,n,i,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,n,i,r),la(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),la(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return i.enumRationalBezier2}queryEnvelope(t){if(t instanceof me){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Va(this);if(null!==e){const s=new Q;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[],s=lt(Q,3);this.queryControlPoints(s),da(s,this.m_weights,e);const n=new Q;for(const i of e)this.queryCoord2D(i,n),t.mergeNe(n)}}}applyTransformation(t){if(t instanceof le){const e=lt(Q,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 Sn({vd:this.m_description})}calculateLength2D(){return _a(this,1,!1)}calculateLowerLength2D(){return Q.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return Q.distance(this.getStartXY(),this.m_cp)+Q.distance(this.getEndXY(),this.m_cp)}return Q.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){lh(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void _s(new pm({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void _s(new pm({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const n=lt(Q,3);this.queryControlPoints(n),_h(n,this.m_weights,t,e)}getCoordX(t){const e=new Q;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new Q;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const n=new fm;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){Sa(this,t,e)}cutBezierIgnoreAttributes(t,s,n){(t<0||s>1||t>s)&&e("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const i=lt(Q,3);this.queryControlPoints(i);const r=[0,0,0];Qa(i,this.m_weights,t,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 Ct(r,o,a,i,En.getDefaultValue(e))}getClosestCoordinate(t,e){return Ra(this,t,H.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return Ra(this,t,e,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,n){t.length<2&&e("");const i=ga(this);let r=0;if(2===i.specialPointsCount())return 0;s(t.length>=i.specialPointsCount()-1);for(let e=1,s=i.specialPointsCount();e<s;++e)this.queryCut(i.specialPoints[e-1],i.specialPoints[e],t[r],n),r++;for(let e=0;e<r;++e){Za(t[e].get())}return r}intersectionWithAxis2D(t,e,s,n){s&&(s.length=9),n&&(n.length=9);const i=new Array(3),r=lt(at,2),o=new H(0,1);let a=0;const h=lt(Q,3);if(this.queryControlPoints(h),t){if(i[0]=new at(h[0].y).sub(e).mul(this.m_weights[0]),i[1]=new at(h[1].y).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new at(h[2].y).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=gn(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 at(h[0].x).sub(e).mul(this.m_weights[0]),i[1]=new at(h[1].x).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new at(h[2].x).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=gn(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&&tt(s,0,a,Bt);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 n=[Number.NaN,Number.NaN],i=this.intersectionWithAxis2D(!0,t,n,null);return s(2!==i),-1===i?e:n[0]}isCurve(){return!0}isDegenerate(t){return Re(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof me)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=me.constructEmpty();this.queryEnvelope(t);const s=H.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=lt(Q,3);this.queryControlPoints(s);const n=[0,0,0];Qa(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 _a(this,t,!0)}lengthToT(t){return Ta(this,t)}calculateWeightedAreaCentroid2D(t){const e=Na(this),s=Ia(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new Q;return this.isDegenerate(0)?(t.setCoords(0,0),t):Fa(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Ua(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=lt(Q,3);return this.queryControlPoints(s),gh(s.map(t=>Xe.constructPoint2D(t)),this.m_weights.map(t=>it.constructDouble(t)),it.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=lt(Q,3);return this.queryControlPoints(e),wa(e,this.m_weights,t)}getDerivative(t){const e=_t(t,0,1),s=lt(Q,4);return pa(this,1,e,s),s[1]}getCurvature(t){const e=lt(Q,4);pa(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=lt(Q,3);return this.queryControlPoints(t),ja(t)}getMonotonicPartParams(t,s){const n=ga(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();t<i&&e("");for(let e=0;e<i;e++)s[e]=n.specialPoints[e];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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=et(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]=et(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=lt(Q,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(Q.distance(e[0],e[1])+Q.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=lt(Q,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Ia(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return s(0),0}queryEnvelopeW(t,e){Ga(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=lt(Q,3);this.queryControlPoints(e);const s=Q.sqrDistance(e[1],e[0]),n=Q.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=lt(Q,3);this.queryControlPoints(e);const s=Q.sqrDistance(e[1],e[0]),n=Q.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 Za(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],La(e,Va(this))}reverseImpl(){this.m_weights[2]=et(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=lt(Q,3);this.queryControlPoints(n);const i=lt(Q,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=et(this.m_cp,this.m_cp=e.m_cp),e.m_weights=et(this.m_weights,this.m_weights=e.m_weights),ca(this,e)}afterCompletedModification(){la(this)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return ka(this,t,e,s)}endPointModified(){la(this)}clearEndPointModified(){}setCpsAndWeights(t,s,n,i,r,o){(i<=0||o<=0||r<0)&&e("weights"),(t.isNAN()||s.isNAN()||n.isNAN())&&e("NAN control points in bezier are not supported"),this.setStartXY(t),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])}}Sn.type=i.enumRationalBezier2;var Dn=b;class wn extends gs{constructor(t){void 0===t||vt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new Q(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()):h("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),ii(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),ii(this)}getGeometryType(){return i.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=yi(this);if(null!==e){const s=new Q;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[];ai(this,e);const s=new Q;for(const n of e)this.queryCoord2D(n,s),t.mergeNe(s)}return}a("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){const e=lt(Q,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()}s(0)}createInstance(){return new wn({vd:this.m_description})}calculateLength2D(){return hi(this,1,!1)}calculateLowerLength2D(){return Q.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return Q.distance(this.getStartXY(),this.m_cp)+Q.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const n=lt(Q,3);this.queryControlPoints(n),ji(n,t,e,s)}queryCoord2DE(t,e){Zi(this,t,e)}queryCoord2DMP(t,e){s(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){const e=new Q;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=bt(this.getStartX(),this.m_cp.x,t),s=bt(this.m_cp.x,this.getEndX(),t);return bt(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 Q;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=bt(this.getStartX(),this.m_cp.x,t),s=bt(this.m_cp.x,this.getEndX(),t);return bt(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 fm;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=Dn.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=Dn.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){Ui(this,t,e)}cutBezierIgnoreAttributes(t,s,n){if((t<0||s>1||t>s)&&e("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===s)return n.setStartXY(this.getStartXY()),n.m_cp.assign(this.m_cp),void n.setEndXY(this.getEndXY());const i=lt(Q,3);this.queryControlPoints(i),Mi(i,t,s,i),n.constructPoints(i)}splitBezierIgnoreAttributes(t,e,n){s(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=Dn.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return Ct(r,o,a,i,Dn.getDefaultValue(e))}getClosestCoordinate(t,e){return Ci(this,t,H.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Ci(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,n){t.length<2&&e("");const i=oi(this);let r=0;if(2===i.specialPointsCount())return 0;s(t.length>=i.specialPointsCount()-1);for(let e=1,s=i.specialPointsCount();e<s;++e)this.queryCut(i.specialPoints[e-1],i.specialPoints[e],t[r],n),r++;for(let e=0;e<r;++e){wi(t[e].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=lt(at,3),r=lt(at,2),o=new H(0,1);let a=0;if(t){if(i[0]=new at(this.getStartY()).sub(e),i[1]=new at(this.m_cp.y).subE(new at(this.getStartY())).mulThisByPower2(2),i[2]=new at(this.getStartY()).add(this.getEndY()).subE(new at(this.m_cp.y).mulThisByPower2(2)),a=gn(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 at(this.getStartX()).sub(e),i[1]=new at(this.m_cp.x).subE(new at(this.getStartX())).mulThisByPower2(2),i[2]=new at(this.getStartX()).add(this.getEndX()).subE(new at(this.m_cp.x).mulThisByPower2(2)),a=gn(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&&St(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 n=[0,0],i=this.intersectionWithAxis2D(!0,t,n,null);return s(2!==i),-1===i?e:n[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return Re(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new me;this.queryEnvelope(t);const s=new H;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=lt(Q,4);this.queryControlPoints(s),Mi(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 hi(this,t,!0)}lengthToT(t){return _i(this,t)}calculateWeightedAreaCentroid2D(t){const e=lt(Q,3);Bi(this,e);const s=e[2],n=e[1],i=new Q,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=pi(this);return i.x+=(e[0].x-t.x)*o,i.y+=(e[0].y-t.y)*o,i}calculateWeightedCentroid2D(){const t=new Q;return this.isDegenerate(0)?(t.setCoords(0,0),t):Pi(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Ti(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(t){for(let s=0;s<3;s++)t[s].isNAN()&&e("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=_t(t,0,1);let s=ci(this,1,e);return s.isZero()&&(s=ci(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return ci(this,1,_t(t,0,1))}getCurvature(t){const e=ci(this,1,t),s=ci(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!==rm(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const n=new me;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new Q;this.queryCoord2D(i,r);return Q.distance(r,t)<=e}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,s){const n=oi(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();t<i&&e("");for(let e=0;e<i;e++)s[e]=n.specialPoints[e];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){et(this.m_XStart,this.m_XStart=this.m_XEnd),et(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]=et(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=lt(Q,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(Q.distance(e[0],e[1])+Q.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=lt(Q,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return pi(this)}absNorm(){return Ni(this)}queryEnvelopeW(t,e){const s=lt(Q,3);this.queryControlPoints(s),Si(s,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return $i(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 tr(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return wi(this)}setCoordsForIntersector(t,e,s){Yi(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),xi(e,yi(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=et(this.m_cp,this.m_cp=e.m_cp),ri(this,e)}afterCompletedModification(){ii(this)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return bi(this,t,e.length,e,s)}endPointModified(){ii(this)}clearEndPointModified(){}}wn.type=i.enumBezier2;class An{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),s(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(ae(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 s(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 s(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 s(0),this}subNumber0(t){return s(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 s(0),this}mulBigint0(t){return s(0),this}mulBigIntThis(t){return s(0),this}mulInt320(t){return s(0),this}div0(t){return s(0),this}absThis(){return s(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=lt(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 s(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){s(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(it.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 Tn extends An{constructor(t){super(void 0===t?{zeroCtor:it}:{...t,zeroCtor:it})}clone(){return new Tn({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 In extends An{constructor(t){super(void 0===t?{zeroCtor:Tn}:{...t,zeroCtor:Tn})}clone(){return new In({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new Tn({coef0:t[s]}));return this.updatePower(),this}}function Mn(){return{polypoly1:new In,polypoly2:new In,polyX2:new Tn,polyY2:new Tn,polyX2Deriv:new Tn,polyY2Deriv:new Tn,polypolyX1:new In,polypolyY1:new In,polypolyX1Deriv:new In,polypolyY1Deriv:new In,lazyPolypolyD1:new In,lazyPolypolyD1Deriv:new In,lazyPolyD2:new Tn,lazyPolyD2Deriv:null,polypoly11:new In,polypoly12:new In,tempPp:new In,tempPp1:new In,tempPp2:new In,tempP:new Tn,tempP1:new Tn,tempP2:new Tn}}function Yn(t,e,n,i,r,o,a,u,m,l,c,g,d,_,p,f,P,y,x,C=!1){const v=Mn();v.polyX2.construct(a,u),v.polyY2.construct(m,l),v.polypolyX1.constructFromMPValues(t,e),v.polypolyY1.constructFromMPValues(n,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)),r?(v.lazyPolypolyD1.constructFromMPValues(r,o),v.lazyPolypolyD1Deriv=new In({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(),r&&(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&&(s(null===v.lazyPolyD2Deriv),v.lazyPolyD2Deriv=new Tn({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 E=[];P||(P=[]),f||(f=[]),kn(v.polypoly11,v.polypoly12,v.tempP);const S=64,D=te.ldexp(-59).toDouble(),w=[];let A=Gn(v.tempP,d,p,D,S,w,y,y);if(A<0)return-1;for(let Y=0;Y<A;Y++){const t=v.tempP1,e=v.tempP2;Tn.evaluateCoefs(v.polypoly11,w[Y],t);const n=ee(t.m_elements,t.power()+1);n.sort((t,e)=>t.compare(e)),Tn.evaluateCoefs(v.polypoly12,w[Y],e);const i=ee(e.m_elements,e.power()+1);i.sort((t,e)=>t.compare(e));const r=n[0],o=n.at(-1),a=i[0],u=i.at(-1);o.subThis(r),u.subThis(a);const m=o.subThis(u).GEZ(),l=58,c=te.ldexp(-59).toDouble(),g=[];let p;if(p=Gn(m?t:e,d,_,c,l,g,y,y),p<0&&h("mp_curve_proximity"),p>0){const n=m?e:t;for(let t=0;t<p;t++){let e;if(m){const s=v.tempP;Tn.evaluateCoefs(v.polypoly12,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}else{const s=v.tempP;Tn.evaluateCoefs(v.polypoly11,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}const i=n.evaluateDerivative(g[t]).abs().mulDoubleThis(Number.EPSILON),r=n.evaluate(g[t]);i.addThis(e.sub(r).absThis()),i.ldexpThis(3),r.absThis(),r.lt(i)?E.push(Mt(g[t].toDouble(),w[Y].toDouble())):s(r.gte(i))}}}A=E.length,kn(v.polypoly1,v.polypoly2,v.tempP);const T=[];let I=Gn(v.tempP,d,p,D,S,T);I<0&&(I=0);for(let s=0;s<I;s++){Tn.evaluateCoefs(v.polypoly1,T[s],v.tempP1);const t=[];let e=Gn(v.tempP1,d,_,D,S,t);if(0!==e)if(Tn.evaluateCoefs(v.polypoly2,T[s],v.tempP2),e<0){if(e=Gn(v.tempP2,d,_,D,S,t),e<0)continue;for(let n=0;n<e;n++)b.push(Mt(t[n].toDouble(),T[s].toDouble()))}else{const n=v.tempP2.absEvaluate(te);n.mulThis(it.constructDouble(1e-12));for(let i=0;i<e;i++){const e=v.tempP2.evaluate(t[i]);e.absThis(),e.lt(n)&&b.push(Mt(t[i].toDouble(),T[s].toDouble()))}}}if(I=b.length,0===A&&0===I)return 0;b=b.concat(E),b.sort((t,e)=>C?Bt(t.second,e.second):Bt(t.first,e.first));const M=se(b,(t,e)=>t.first===e.first&&t.second===e.second);b=b.slice(0,M),f.length=0,P.length=0;for(const s of b)f.push(s.first),P.push(s.second);return s(f.length===P.length),P.length}function Nn(t,e,s,n,i,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(it.constructInt32(1)).isZero();if(1===t.power()){const s=Fn(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 Vn(t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(3===t.power()){return Ln(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(4===t.power()){return Rn(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}return Un(t,e,s,n,a,i,r,o)}function Xn(){return{polyIntersect:new Tn,polyX1:new Tn,polyY1:new Tn,polyX1Deriv:new Tn,polyY1Deriv:new Tn,lazyPolyD1:new Tn,lazyPolyD1Deriv:new Tn,tempP:new Tn,tempP1:new Tn,tempP2:new Tn,polypoly1Proximity:new In,polypoly2Proximity:new In}}function qn(t,e,s,n,i,r,o,a,h,u,m,l,c){const g=Xn();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($t),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=Gn(g.polyIntersect,a,h,f,p,P,l,l);if(y<0)return-1;for(const b of P)_.push(b.toDouble());kn(g.polypoly1Proximity,g.polypoly2Proximity,g.tempP),p=2*g.tempP.power()+58,P.length=0;let x=Gn(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,J(m,C,0,0,C.length),Gt(m);const v=se(m,(t,e)=>0===Bt(t,e));return m.length=v,m.length}function Fn(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 Vn(t,e,s,n,i,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),i.containsCoordinate(1)?1:0;return Fn(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]=et(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=it.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(it.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]=et(o[0],o[0]=o[1]))),c}function Ln(t,e,n,i,r,o,a,h){if(t.isZero()){return Vn(e,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]=et(h[t],h[t]=h[s-1]),s--);e=s}return tt(h,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let s=0;o.containsCoordinate(0)&&(h[0].setInt32(0),s=1);return u(Vn(t,e,n,r,o,a,h.slice(1)),s)}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(Vn(t,n,a,r,o,m,h.slice(s)),s)}const m=new it,l=new it,c=new it,g=e.clone();if(g.isZero())l.setThis(n),l.divThis(t),c.setThis(i),c.divThis(t);else{g.divThis(t).divDoubleThis(3).negateThis();const s=e.clone();s.sqrThis();const r=t.clone();r.sqrThis(),l.setThis(t),l.mulThis(n).mulDoubleThis(3).subThis(s).divThis(r).divDoubleThis(3),c.setThis(s),c.mulThis(e),c.ldexpThis(1),m.setThis(t),m.mulThis(e).mulThis(n).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),Qn(o,r,h,1)):(h[0].setThis(it.cubicRoot(t,r).add(g)),Qn(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),Qn(o,r,h,2);if(d.GZ())return d.setThis(it.sqrt(d,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.addThis(d),h[0].setThis(it.cubicRoot(m,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.subThis(d),h[0].addThis(it.cubicRoot(m,r+8)),h[0].addThis(g),Qn(o,r,h,1);m.setThis(l),m.divDoubleThis(3).negateThis(),s(m.GEZ());const _=it.sqrt(m,r+8),p=_.clone();p.negateThis(),p.addThis(g),_.addThis(g);const f=it.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),P=it.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),y=new Tn({zeroCtor:it});y.construct0(i),y.addElement(n),y.addElement(e),y.addElement(t);const x=new Tn({copy:y});x.derivative1This();let C=0;const v=lt(it,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 E=52,S=Number.EPSILON;for(;E<b;)2*E<=b?(S*=S,E*=2):(S*=Number.EPSILON,E+=52);E+=2;let D=0,w=!1;for(let s=1;s<C;s++){if(Zn(y,x,v[s-1],v[s],S,E,h[0])){D=1,w=s+1<C;break}}if(!D)return 0;if(w){const t=new Tn({zeroCtor:it,coef0:h[0]});t.negateThis(),t.addElement(te);const e=new Tn({zeroCtor:it}),n=new Tn({zeroCtor:it});y.div(t,e,n),s(2===e.power()),s(0===n.power());const i=Vn(e.getElement(2),e.getElement(1),e.getElement(0),r,o,!1,h.slice(1));s(i>=0&&i<=2),D+=i}return Qn(o,r,h,D)}function Rn(t,e,s,n,i,r,o,a,h){if(t.isZero())return Ln(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]=et(h[t],h[t]=h[s-1]),s--);e=s}return tt(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(Ln(t,e,s,n,r,o,a,h.slice(i)),i)}const m=new Tn({zeroCtor:it,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 Tn({zeroCtor:it,coef0:it.constructInt32(-1)});e.addElement(it.constructInt32(1));const s=new Tn({zeroCtor:it}),n=new Tn({zeroCtor:it});m.div(e,s,n);return u(Ln(3===s.power()?s.getElement(3):$t.clone(),s.power()>=2?s.getElement(2):$t.clone(),s.power()>=1?s.getElement(1):$t.clone(),s.getElement(0),r,o,s.evaluate(te).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=Ln(3===m.power()?m.getElement(3):$t.clone(),m.power()>=2?m.getElement(2):$t.clone(),m.power()>=1?m.getElement(1):$t.clone(),m.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),tt(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=On(m),d=it.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(g.lt(d)?g:d).mul(it.constructDouble(c)).toDouble(),Un(m,o,c,l,a,!1,h,4)}function zn(t,e){let s=t,n=e;n.power()>s.power()&&(n=et(s,s=n));const i=s.power()-n.power(),r=new Tn({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 Tn({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(),Bn(s)}function Bn(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function kn(t,e,s){const n=t.clone(),i=e.clone();for(Bn(n),Bn(i);0!==n.power()||0!==i.power();)zn(n,i);s.assignMove(n.getElement(0))}function Gn(t,e,s,n,i,r,o=!1,a=!1){r.length=0;const h=t.power(),u=lt(it,2*h+4),m=Nn(t,s||H.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 Wn(t,e,n){if(s(n>=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 jn(t,e,n,i){if(t.power()<2)return Wn(t,n,i);s(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 s=t.getElement(1);return s.negateThis(),s.divThis(t.getElement(2)),s.ldexpThis(-1),s.limitPrecisionThis(e),n[0].setThis(s),1}s(i>=2),r=it.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)?(n[0].setThis(h),n[1].setThis(u)):(n[1].setThis(h),n[0].setThis(u)),2}function Zn(t,e,s,n,i,r,o){let a=s.clone(),u=n.clone();a.limitPrecisionThis(r),u.limitPrecisionThis(r);let m=t.evaluate(a);m.limitPrecisionThis(r+2);let l=t.evaluate(u);if(l.limitPrecisionThis(r+2),m.GEZ()&&l.GEZ()||m.LEZ()&&l.LEZ())return m.absLessAbs(l)?(o=a,m.isZero()):(o=u,l.isZero());const c=l.LZ();c&&(l=et(m,m=l),u=et(a,a=u));const g=c?u:a,d=c?a:u,_=a.add(u).ldexpThis(-1);_.limitPrecisionThis(r);const p=u.sub(a);p.limitPrecisionThis(r),p.absThis();const f=p.clone();let P=t.evaluate(_),y=e.evaluate(_);const x=new Tn({copy:t}),C=new Tn({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),n=te.clone();n.ldexpThis(-(r+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(r+2),y.limitPrecisionThis(r+2)}const v=1,b=4;let E=b;const S=2;let D=1,w=0,A=0,T=v;const I=32,M=it.constructDouble(.25*i),Y=it.constructDouble(.5001);let N=0;const X=300;for(;++N<X;){if(N>I&&w>0||y.isZero()||T===S&&w>1||T===v&&E<b)T=v,D>1&&D--;else if(T=S,A>1){const t=p.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&D++}p.setThis(f);const t=new it;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(r),f.setThis(_.sub(t));break}if(_.equals(d)){t.setThis(_),_.setThis(d.sub(e)),_.limitPrecisionThis(r),f.setThis(_.sub(t));break}}}f.setThis(u.sub(a)),f.ldexpThis(-1),f.limitPrecisionThis(r),t.setThis(_),_.setThis(a.add(f)),_.limitPrecisionThis(r),_.lt(g)?_.setThis(g):_.gt(d)&&_.setThis(d),e=a.equals(_)||u.equals(_)}while(0);else for(;;){if(f.setThis(P.div(y)),f.limitPrecisionThis(r),1!==D&&f.mulDoubleThis(D),t.setThis(_),_.subThis(f),_.limitPrecisionThis(r),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(r+2));break}P=x.evaluate(_),P.limitPrecisionThis(r+2),y=C.evaluate(_),y.limitPrecisionThis(r+2);const s=a.clone(),n=u.clone();P.LZ()?(m.setThis(P),a.setThis(_)):(l.setThis(P),u.setThis(_)),T===S&&(a.equals(s)&&u.equals(n)||A>1&&!f.absLessAbs(Y.mul(p)))?w++:w=0,T===v?(E++,A=0):(E=0,A++)}return N>=X&&h("Root_finder iterations exceeded"),o.setThis(_),!0}function Hn(t,e,s,n,i){const r=t.evaluate(s);if(r.isZero())return!0;const o=it.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(it.constructDouble(1e-17))}function Un(t,e,n,i,r,o,a,h){s(n>0),s(h>=t.power());const u=a,m=[];let l=[];const c=new Tn({zeroCtor:t.m_zeroCtor}),g=new Tn({zeroCtor:t.m_zeroCtor}),d=new Tn({zeroCtor:t.m_zeroCtor}),_=it.constructDouble(n),p=it.constructDouble(e.vmin),f=it.constructDouble(e.vmax),P=p.sub(_),y=f.add(_),x=On(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 Tn({coef0:it.constructInt32(-1)});e.addElement(te),b=new Tn,v=b;const s=new Tn,n=new Tn;for(t.div(e,s,n),b.assignCopy(s);v.evaluate(te).isZero();)v.div(e,s,n),b.assignCopy(s)}let E=!1;if(v.power()>0&&v.getElement(0).isZero())for(E=!0,b||(b=new Tn({copy:v}),v=b);v.getElement(0).isZero();)b.shiftRight(1);let S=i+2*v.power()+2,D=n/Math.pow(2,v.power()+2),w=S;if($t.gt(P)&&$t.lt(y))for(let s=0,Y=v.power();s<Y;s++)if(v.getElement(s).isZero()){m.push($t.clone());break}for(let Y=v.power()-1;Y>0;Y--){if(D*=2,S-=2,w-=2,v.power()-Y===1){g.assignMove(v.derivative(Y));1===Wn(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=jn(g,S,u,h);s(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(Mt(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(Mt(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(Mt(t,e)),m.length>2&&(t=m[2].add(_),t.limitPrecisionThis(w),l.push(Mt(t,y.clone()))))}else l.push(Mt(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 it;if(Zn(g,c,l[e].first,l[e].second,D,S,s)){m.push(s);let n=s.sub(_);n.limitPrecisionThis(w),t.push(Mt(l[e].first,n)),n=s.add(_),n.limitPrecisionThis(w),t.push(Mt(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(Mt(P.clone(),y.clone())));let A=0,T=0,I=0;const M=new it;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){Zn(v,c,l[T].first,l[T].second,n,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])||Hn(v,c,m[I],n)&&(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 E&&$t.gt(P)&&$t.lt(y)&&(u[A++].setThis($t),tt(u,0,A,(t,e)=>t.compare(e))),r&&te.gt(P)&&te.lt(y)&&(u[A++].setThis(te),tt(u,0,A,(t,e)=>t.compare(e))),A}function On(t){const e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();const s=$t.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(te),s.mulThis(it.constructDouble(1+100*Number.EPSILON)),s}function Qn(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]=et(s[0],s[0]=s[1])),i>2&&(s[0].gt(s[2])&&(s[2]=et(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=et(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 ti(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 pt(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 $n(t,e,s,n,i,r,o){let a=0,h=Math.abs(i-s[t]);const u=U(e,Number.NaN),m=U(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 ti(t,s,n,i,r,o){if(n<s&&e("xTo < xFrom"),n===s)return 0;const a=[0];let u=Number.MAX_VALUE;const m=[Number.MAX_VALUE];let l=0;const c=32,g=U(c+1,Number.NaN),d=U(c+1,Number.NaN),_=[0];g[0]=1;let p=0,f=0;for(let e=0;e<c;e++){if(l=Jn(s,n,i,0===e,l,_),d[e]=l,e+1>=t){$n(e+1-t,t,g,d,0,a,m)||h("polynomial_interpolation");const s=r*Math.abs(a[0])+o,n=Math.abs(u-a[0]);if(n<=s&&Math.abs(m[0])<=s){if(p++,p>1&&(n<=.1*f||0===f||p>2))return a[0]}else p=0;f=n,u=a[0]}d[e+1]=d[e],g[e+1]=.25*g[e]}return a[0]}class ei{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let si=class{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-hi(this.b,e,!1):0}getError(t){return s(0),0}};function ni(t,e,s,n,i){let r=!0;const o=lt(Q,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=bt(0,h,t),n=bt(h,u,t);e=bt(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*gi(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=bt(0,h,t),n=bt(h,u,t);e=bt(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*gi(o,1,t).length()});return new Q(m,l)}function ii(t){t.m_cachedValues=null}function ri(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function oi(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ei;return ai(t,e.specialPoints),xi(t,e),e}function ai(t,e){const s=lt(Q,3);t.queryControlPoints(s);const n=lt(at,8);n[0].set(0);let i=1;{const t=lt(at,3);ki(s,t,!1);const e=lt(at,2),r=new H(0,1);let o=cn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)gt(e[s].value(),0,1)||(n[i]=e[s],i++)}{const t=lt(at,3);Gi(s,t,!1);const e=lt(at,2),r=new H(0,1);let o=cn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)gt(e[s].value(),0,1)||(n[i]=e[s],i++)}if(n[i].set(1),i++,i>2){tt(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 hi(t,e,s){const n=lt(Q,3);return t.queryControlPoints(n),ui(n,e,s)}function ui(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+ui(t,1,!1)}if(1===e)return mi(t);const n=lt(Q,3);return Ii(t,e,n,null),mi(n)}function mi(t){if(t[0].equals(t[1]))return Q.distance(t[2],t[0]);if(t[1].equals(t[2]))return Q.distance(t[0],t[2]);const e=Q.distance(t[0],t[1])+Q.distance(t[2],t[1]),s=Q.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const n=1,i=lt(Q,3);zi(t,i,!0);const r=4*(zt(i[2].x)+zt(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=zt(i[1].x)+zt(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 li(t,e){const s=_t(e,0,1);let n=gi(t,1,s);return n.isZero()&&(n=gi(t,2,s)),n}function ci(t,e,s){const n=lt(Q,3);return t.queryControlPoints(n),gi(n,e,s)}function gi(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)):Q.construct(0,0)}function di(t,e,s){{const e=Ye.constructPoint2D(t[1]).subE(Ye.constructPoint2D(t[0])),n=new at(1).subE(s),i=Ye.constructPoint2D(t[2]).subE(Ye.constructPoint2D(t[1])),r=e.mulE(n).addE(i.mulE(s));return r.mulThisE(new at(2)),r}}function _i(t,e,s){const n=hi(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==tn(new si(t,e),H.unit(),1,i)&&h(""),i[0]}function pi(t){const e=lt(Q,3);return t.queryControlPoints(e),fi(e)}function fi(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Pi(t){const e=Q.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function yi(t){return t.m_cachedValues}function xi(t,e){t.m_cachedValues=e}function Ci(t,e,s,n,i){_(H.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=lt(Q,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=vi(r,e,a);if(s.containsCoordinate(a[0]))o=Q.distance(e,h);else{a[0]=s.vmin,ji(r,a[0],h),o=Q.distance(h,e);const t=new Q;ji(r,s.vmax,t);const n=Q.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 Q;t.queryCoord2DExtended(-1,n,!0);const i=new Q;t.queryCoord2D(s.vmin,i);const r=new pm({start:n,end:i}),u=r.getClosestCoordinate(e,!0);if(u<1){const t=r.getCoord2D(u),s=Q.distance(t,e);s<o&&(o=s,a[0]=u-1,h.assign(t))}}if(s.vmin>=1){const n=new Q;t.queryCoord2DExtended(2,n,!0);const i=new Q;t.queryCoord2D(s.vmax,i);const r=new pm({start:i,end:n}),u=r.getClosestCoordinate(e,!0);if(u>0){const t=r.getCoord2D(u),s=Q.distance(t,e);s<o&&(o=s,a[0]=1+u,h.assign(t))}}return a[0]}function vi(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=U(3,Number.NaN),l=nn(u,h,a,o,H.unit(),!1,m),c=t[0].clone();let g=0,d=Q.sqrDistance(t[0],e),_=Q.sqrDistance(t[2],e);_<d&&(g=1,c.assign(t[2]),d=_);for(let p=0;p<l;p++){const s=new Q;ji(t,m[p],s),_=Q.sqrDistance(s,e),_<d&&(d=_,c.assign(s),g=m[p])}return s&&(s[0]=g),c}function bi(t,e,s,n,i,r){const o=new De;if(Ei(t,H.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=new Q,h=Ci(t,e,H.unit(),!1);t.queryCoord2D(h,a);return Q.distance(a,e)<=i?(n&&(n[0]=h),1):0}function Ei(t,e,s){const n=lt(Q,3);t.queryControlPoints(n),Si(n,e,s)}function Si(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const n=lt(Q,3);Mi(t,e.vmin,e.vmax,n),s.setFromPoints(n,3)}function Di(t,e,s){s.setEmpty();const n=[];n.push(new H(0,1));const i=.5*Math.max(e.width(),e.height());for(;n.length;){const r=n.at(-1);n.pop();const o=new De;if(Si(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(H.construct(r.vmin,t)),n.push(H.construct(t,r.vmax))}}}}function wi(t){const e=lt(Q,3);t.queryControlPoints(e);const s=Ai(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ai(t){let e=!1;for(let s=0;s<2;s++){const n=nt(t[0][s],t[2][s]);n>0?(nt(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?(nt(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),nt(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 Ti(t,s,n){void 0===n&&(n=s,s=0);const i=new Q;if(s<0||n>1)return i.setNAN(),i;if(s>n&&e("calculate_sub_weighted_centroid"),s===n||t.isDegenerate(0))return i.setCoords(0,0),i;const r=oi(t),o=is(t),a=Math.min(o/t.calculateUpperLength2D(),1e-7);let h=s,u=0;for(let e=1,m=r.specialPointsCount();e<m;e++)if(s<r.specialPoints[e]){u=e-1;break}i.setCoords(0,0);for(let e=u+1,m=r.specialPointsCount();e<m;e++){const s=Math.min(r.specialPoints[e],n),u=ni(t,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}function Ii(t,e,s,n){(new Q).setCoordsPoint2D(t[0]);(new Q).setCoordsPoint2D(t[1]);(new Q).setCoordsPoint2D(t[2]);const i=new Q,r=new Q,o=new Q;if(xt(t[0],t[1],e,i),xt(t[1],t[2],e,r),xt(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 Mi(t,e,s,n){if(e===s){const s=new Q;return ji(t,e,s),n[0]=s,n[1]=s,void(n[2]=s)}const i=lt(Q,3);Ii(t,s,i,null),Ii(i,e/s,null,i),ji(t,e,i[0]),ji(t,s,i[2]),n[0].setCoordsPoint2D(i[0]),n[1].setCoordsPoint2D(i[1]),n[2].setCoordsPoint2D(i[2])}function Yi(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 le,o=lt(Q,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new Q;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=lt(Q,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):xt(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&wi(t)}function Ni(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function Xi(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==Vi(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function qi(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(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!==am(e,s))return 2}else if(Le(e,s))return 1;return 0!==Ri(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Vi(t,e,n,i,r,o,a,h,u,m){if(null!=r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),n.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(n.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!==o)for(let t=0;t<s;t++)o.push(0);if(null!==i)for(let n=0;n<s;n++){const s=new Q;e.queryCoord2D(t[n],s),i.push(s)}}return s}const l=rs(e,n);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new pm({start:e.getStartXY(),end:e.getEndXY()}),s=Ds(t,n,i,r,o,a,h,m);if(r)for(let n=0;n<s;++n){const s=t.getCoord2D(r[n]);r[n]=e.getClosestCoordinate(s,!1)}return s}if(os(e,n,a))return 0;const c=Xe.constructPoint2D(n.getStartXY()),g=Xe.constructPoint2D(n.getEndXY()).sub(c),d=g.clone();d.leftPerpendicularThis();const _=Xe.constructPoint2D(e.m_cp).sub(Xe.constructPoint2D(e.getStartXY())),p=Xe.constructPoint2D(e.getEndXY()).sub(Xe.constructPoint2D(e.m_cp));let f=_.dotProduct(d).toDouble(),P=p.sub(_).dotProduct(d).toDouble();const y=U(12,Number.NaN),x=U(12,Number.NaN);let C=en(P,f,H.unit(),y);C<0&&(y[0]=0,y[1]=1,C=2);let v,b=0;for(let s=0,w=b;s<C;++s){const t=e.getCoord2D(y[s+w]);x[b]=n.getClosestCoordinate(t,!1),Q.distance(t,n.getCoord2D(x[b]))<=a&&(y[b]=y[s+w],b++)}const E=lt(Q,3);e.queryControlPoints(E);{const t=lt(Xe,3);if(Wi(E,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 S=e.getEndXY().equals(n.getStartXY())||e.getEndXY().equals(n.getEndXY()),D=[0,0];C=sn(P,f,v,H.unit(),S,D);for(let s=0,w=b;s<C;++s){y[s+w]=D[s];const t=e.getCoord2D(y[s+w]);x[b]=n.getClosestCoordinate(t,!1),Q.distance(t,n.getCoord2D(x[b]))<=a&&(y[b]=y[s+w],b++)}s(b<y.length+4),C=e.intersectPoint(n.getStartXY(),D,a);for(let s=0;s<C;s++)y[b]=D[s],x[b++]=0;C=e.intersectPoint(n.getEndXY(),D,a);for(let s=0;s<C;s++)y[b]=D[s],x[b++]=1;C=n.intersectPoint(e.getStartXY(),D,a);for(let s=0;s<C;s++)x[b]=D[s],y[b++]=0;C=n.intersectPoint(e.getEndXY(),D,a);for(let s=0;s<C;s++)x[b]=D[s],y[b++]=0;return 0===b?0:cm(t,e,n,y,x,b,i,r,o,a,h,u,m)}function Li(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return Vi(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=lt(Q,3);{e.queryControlPoints(g);const t=lt(Q,3),n=new le;s.canonicToWorldTransformation(n);const i=new le;i.setInvert(n),i.transformPoints2D(g,3,t);const r=lt(Xe,3);Wi(t,r);const h=[r[0].x,r[1].x,r[2].x],u=[r[0].y,r[1].y,r[2].y],m=lt(it,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=qn(h,2,u,2,null,0,m,!0,H.unit(),H.unit(),l,a);if(d>0){let t=0;for(let n=0;n<d;n++){const i=new Q;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new Q;s.queryCoord2D(r,a),Q.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];vi(g,t,e);const n=new Q;ji(g,e[0],n),Q.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 Q;s.queryCoord2D(e,n),Q.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return cm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function Ri(t,e,s,n,i,r,o,a,h,u){const m=lt(Q,3);e.queryControlPoints(m);const l=lt(Q,3);if(s.queryControlPoints(l),as(m,l,3)<0)return Ri(t,s,e,n,r,i,o,a,h,!u);const c=rs(e,s);if(os(e,s,o=Math.max(o,c)))return 0;if(er(e,s,n,i,r,o,a,h,u))return 2;const g=new H(0,1),d=new H(0,1);{const t=new De;Si(m,H.unit(),t);const e=new De;Si(l,H.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(Di(m,t,g),Di(l,t,d),g.isEmpty()||d.isEmpty())return 0;Mi(m,g.vmin,g.vmax,m),Mi(l,d.vmin,d.vmax,l)}}const _=dm(m,2,l,2,o);if(0===_)return 0;const p=[],f=[];if(-1===_){const t=lt(Xe,3);Wi(m,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],n=lt(Xe,3);Wi(l,n);const i=Yn(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,H.unit(),H.unit(),p,f,u,a,u);if(i>0){let t=0;for(let e=0;e<i;e++){const s=new Q,n=new Q;ji(l,f[e],n),ji(m,p[e],s),Q.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];vi(e,t[n],i);const r=new Q;ji(e,i[0],r),Q.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]=wn.recalculateParentT(g.vmin,g.vmax,p[P]);if(!d.equalsRange(0,1))for(let P=0;P<f.length;++P)f[P]=wn.recalculateParentT(d.vmin,d.vmax,f[P]);return cm(t,e,s,p,f,p.length,n,i,r,o,a,h,u)}function zi(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 Bi(t,e,s=!1){const n=lt(Q,3);t.queryControlPoints(n),zi(n,e,s)}function ki(t,e,s=!1){const n=0,i=new at(t[1][n]).subE(new at(t[0][n]));e[1]=i.mul(2),e[2]=new at(t[2][n]).subE(new at(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function Gi(t,e,s=!1){const n=1,i=new at(t[1][n]).subE(new at(t[0][n]));e[1]=i.mul(2),e[2]=new at(t[2][n]).subE(new at(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function Wi(t,e,s=!1){const n=Xe.constructPoint2D(t[1]),i=n.sub(Xe.constructPoint2D(t[0]));e[1]=i.mul(it.constructInt32(2)),e[2]=Xe.constructPoint2D(t[2]).sub(n).sub(i),e[0]=s?new Xe($t,$t):Xe.constructPoint2D(t[0])}function ji(t,e,s,n){if(n){if(e<0){return void _s(new pm({start:t[0],end:t[0].add(li(t,0).getUnitVector())}),e,s)}if(e>1){return void _s(new pm({start:t[2],end:t[2].add(li(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=t[1].clone(),i=new Q;Xt(2,t[0],n,e,i);const r=new Q;Xt(2,n,t[2],e,r);const o=new Q;Xt(2,i,r,e,o),s.assign(o)}else{const n=t[1].clone(),i=new Q;qt(2,t[0],n,e,i);const r=new Q;qt(2,n,t[2],e,r);const o=new Q;qt(2,i,r,e,o),s.assign(o)}}function Zi(t,e,s){const n=lt(Q,3);t.queryControlPoints(n),Hi(n,e,s)}function Hi(t,e,s){if(e.value()<=.5){const n=Ye.constructPoint2D(t[1]),i=new Ye;Ft(2,Ye.constructPoint2D(t[0]),n,e,i);const r=new Ye;Ft(2,n,Ye.constructPoint2D(t[2]),e,r);const o=new Ye;Ft(2,i,r,e,o),s.setE(o)}else{const n=Ye.constructPoint2D(t[1]),i=new Ye;Vt(2,Ye.constructPoint2D(t[0]),n,e,i);const r=new Ye;Vt(2,n,Ye.constructPoint2D(t[2]),e,r);const o=new Ye;Vt(2,i,r,e,o),s.setE(o)}}function Ui(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),Oi(n,e,s)}function Oi(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(di(t,1,e))}function Qi(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=Q.intersectLinesAtOnePoint(t[0],t[s],t[n],t[3]),r=new Q;xt(t[0],t[3],.5,r);const o=new Q;Po(t,.5,o);const a=new Q;e[1].assign(i),ji(e,.5,a);const h=new Q;e[1].assign(r),ji(e,.5,h);const u=Q.sqrDistance(o,a),m=Q.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 Q;_h(t,e,.5,n);const i=new Q;ji(s,.5,i);const r=Q.sqrDistance(n,i);return Math.sqrt(r)}function Ji(t,e){e[0].assign(t[0]),e[3].assign(t[2]),xt(t[0],t[1],2/3,e[1]),xt(t[1],t[2],1/3,e[2])}function $i(t,e){const s=lt(Q,3);t.queryControlPoints(s);const n=Q.sqrDistance(s[1],s[0]),i=Q.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 tr(t,e){if(!e)return!1;const s=lt(Q,3);t.queryControlPoints(s);const n=Q.sqrDistance(s[1],s[0]),i=Q.sqrDistance(s[1],s[2]);s[0].clone();let r=n;return n>i&&(s[2].clone(),r=i),r<=e&&0!==r}function er(t,e,s,n,i,r,o,a,h){const u=lt(Q,3);t.queryControlPoints(u);const m=lt(Q,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]=et(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=et(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[2]),h&&(s[1]=et(s[0],s[0]=s[1]))),!0)}const sr=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],nr=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],ir=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],rr=[[.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]],or=[[.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]],ar=[[.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 hr(t,e,s,n){const i=.5*(n-s),r=s+i,o=new pt(0);for(let a=0,h=Math.trunc(t/2);a<h;++a){let s,n;switch(t){case 4:s=sr[a][0],n=sr[a][1];break;case 8:s=nr[a][0],n=nr[a][1];break;case 16:s=ir[a][0],n=ir[a][1];break;case 32:s=rr[a][0],n=rr[a][1];break;case 64:s=or[a][0],n=or[a][1];break;case 128:s=ar[a][0],n=ar[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=re(-.5,s,r),u=re(i,s,r);o.pe(e(h)*n),o.pe(e(u)*n)}return o.getResult()*i}class ur extends Hs{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=fm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=fm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=fm):t.envelope?a("envelope constructor not impl"):h("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=fm)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return Js(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return ur.type}getDimension(){return 2}createInstance(){return new ur({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function mr(t,s){let n,r=s,o=null;switch(r||(o=p(t)?X():P(),r=o),t){case i.enumPoint:n=new q({vd:r});break;case i.enumLine:n=new pm({vd:r});break;case i.enumBezier:n=new ia({vd:r});break;case i.enumEllipticArc:n=new Xh({vd:r});break;case i.enumRationalBezier2:n=new Sn({vd:r});break;case i.enumBezier2:n=new wn({vd:r});break;case i.enumEnvelope:n=new M({vd:r});break;case i.enumMultiPoint:n=new Se({vd:r});break;case i.enumPolyline:n=new Os({vd:r});break;case i.enumPolygon:n=new ur({vd:r});break;case i.enumMultipatch:a("multipatch not impl");break;case i.enumGeometryCollection:n=new ls({vd:r});break;default:e("Geometry.create")}return n}ur.type=i.enumPolygon;var lr=b;const cr=-1,gr=1;class dr{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 _r(t){return void 0!==t.parent}class pr{constructor(t){_r(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!==cr;){for(;this.m_path!==cr;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!==cr)return this.m_vertex;if(this.m_bOneGeom)return cr;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===cr)break;this.m_bSkipMultiPoints&&!c(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return cr}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==cr&&(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 cr}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==cr?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==cr&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):cr}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,n,i,r,o,a,h){return new pr({parent:t,geometry:e,path:s,vertex:n,firstVertex:i,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class fr{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class Pr{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,gr),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,gr),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,n){this.m_hasForceSetEnvelope=0;const i=e!==cr?this.getPrevVertex(e):this.getLastVertex(t),r=i!==cr?this.getNextVertex(i):cr,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!==cr&&this.setPrevVertex(r,o),i!==cr&&this.setNextVertex(i,o);const h=this.isClosedPath(t),u=this.getFirstVertex(t);e===cr&&this.setLastVertex(t,o),e===u&&(h&&n&&u!==cr||this.setFirstVertex(t,o)),h&&r===cr&&(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 q({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,e){const s=this.createGeometry(i.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}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,cr);this.setClosedPath(e,s.isClosedPath(i));for(let t=s.getPathStart(i),r=s.getPathEnd(i);t<r;t++){const i=this.insertVertex_(e,cr,null,!1);if(n){const e=this.getVertexIndex(i);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const n=new fm;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,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===i.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const n=e.getImpl(),i=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),r=new me;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=cr,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,cr,null,!1);if(i){const s=this.getVertexIndex(e);if(1&n.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new fm;n.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===d)break;m=1,l=_,a!==o?(c=this.insertPath(t,cr),this.setClosedPath(c,!1),u=n.getSegmentCountPath(o),g=n.isClosedPath(o),a=o):c=this.insertPath(t,cr)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,n){const i=e.getImpl(),r=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),o=me.constructEmpty();e.queryEnvelope(o),s(n.isIntersecting(o)&&!n.containsEnvelope(o));let a=me.construct(Number.NEGATIVE_INFINITY,n.ymin,Number.POSITIVE_INFINITY,n.ymax),h=me.construct(n.xmin,Number.NEGATIVE_INFINITY,n.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=et(a,a=h))}else a.height()>h.width()&&(h=et(a,a=h));const m=[],l=i.queryLimitedSegmentIterator(a);let c=-1,g=-100,d=-1,_=0,p=-1,f=-1,P=cr,y=!0,x=l.nextSegment();if(null!==x)for(;;x=l.nextSegment()){let n=null===x;const o=null!==x?l.getPathIndex():c,a=null!==x?l.getStartPointIndex():g;if(n||(o===c?g+1===a?_++:n=!0:(n=c>=0,c<0&&(c=o,d=i.getSegmentCountPath(c),p=a,P=cr,_=1))),n){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===cr&&(P=this.insertPath(t,cr),this.setClosedPath(P,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(P,cr,null,!1));for(const{first:n,second:o}of m){-1===f&&(f=n);let a=-1,h=-1;const u=n+o-1;if(o===d){const t=u+1;h=t-n,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,n,t),a=u,s(1===m.length)}else if(u+1<i.getPathEnd(c)){const t=u+2;h=t-n,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,n,t),a=u}else{const t=i.getPathStart(c),s=t!==f?1:0,r=u+1;h=r-n+s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-n)+s),this.m_verticesMp.addPoints(e,n,r),a=u,s>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),P===cr&&(P=this.insertPath(t,cr),this.setClosedPath(P,!0));for(let t=0,e=n;t<h;t++,e++){const t=this.insertVertex_(P,cr,null,!1);if(r){const s=this.getVertexIndex(t);if(1&i.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new fm;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,cr,null,!1))}}m.length=0,y=!0,o!==c&&(c=o,d=i.getSegmentCountPath(c),P=cr,f=-1),p=a,_=1}if(!x)break;{const t=me.constructEmpty();x.queryLooseEnvelope(t),h.isIntersecting(t)?(y?m.push(Mt(a,1)):m.at(-1).second++,y=!1):y=!0}g=a}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const n=e.getGeometryType()===i.enumPolygon,r=me.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?n?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}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,cr);this.insertVertex_(n,cr,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,cr);for(let n=0,i=e.getPointCount();n<i;n++)this.insertVertex_(s,cr,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,cr);for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)&&this.insertVertex_(h,cr,null,!1)}}splitSegmentForward(t,s,n,r,o){const a=this.getNextVertex(t);a===cr&&e("Edit_shape.split_segment_forward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(n);e<c;e++){const t=this.getVertexIndex(m),r=this.getNextVertex(m),g=s.getResultSegment(n,e);let d=null;if(g.getGeometryType()!==i.enumLine&&(d=g.clone(),d.dropAllAttributes()),0===e&&(g.queryStart(h),this.setSegmentToIndex(t,null),this.setPointEx(m,h,s.getResultSegmentStartPointRank(n,e),s.getResultSegmentStartPointWeight(n,e),o)),this.setSegmentRank(m,s.getResultSegmentInteriorRank(n,e)),this.setSegmentWeight(m,s.getResultSegmentInteriorWeight(n,e)),l){const t=s.getResultSegmentSegmentParentage(n,e),i=s.getResultSegmentStartPointIsBreak(n,e);this.setSegmentParentageAndBreak(m,t,i)}if(g.queryEnd(h),e<c-1){this.setSegmentToIndex(t,d);const i=this.insertVertex(u,r,h);this.setWeight(i,s.getResultSegmentEndPointWeight(n,e)),this.setRank(i,s.getResultSegmentEndPointRank(n,e)),this.select(i),m=i}else{this.setPointEx(a,h,s.getResultSegmentEndPointRank(n,e),s.getResultSegmentEndPointWeight(n,e),o);const i=s.getResultSegmentEndPointIsBreak(n,e);this.setSegmentParentageBreakVertex(a,i),this.setSegmentToIndex(t,d)}}}splitSegmentBackward(t,s,n,r,o){const a=this.getNextVertex(t);a===cr&&e("Edit_shape.split_segment_backward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(n);e<c;e++){const t=c-e-1,r=this.getVertexIndex(m),g=this.getNextVertex(m),d=s.getResultSegment(n,t);let _=null;if(d.getGeometryType()!==i.enumLine&&(_=d.clone(),_.reverse(),_.dropAllAttributes()),0===e&&(d.queryEnd(h),this.setSegmentToIndex(r,null),this.setPointEx(m,h,s.getResultSegmentEndPointRank(n,t),s.getResultSegmentEndPointWeight(n,t),o),this.setSegmentParentageAndBreak(m,s.getResultSegmentSegmentParentage(n,t),s.getResultSegmentEndPointIsBreak(n,t))),d.getGeometryType()===i.enumLine?this.setSegmentToIndex(r,null):this.setSegmentToIndex(r,_),this.setSegmentRank(m,s.getResultSegmentInteriorRank(n,t)),this.setSegmentWeight(m,s.getResultSegmentInteriorWeight(n,t)),d.queryStart(h),e<c-1){const e=this.insertVertex(u,g,h);this.setWeight(e,s.getResultSegmentStartPointWeight(n,t)),this.setRank(e,s.getResultSegmentStartPointRank(n,t)),this.select(e),m=e,l&&this.setSegmentParentageAndBreak(e,s.getResultSegmentSegmentParentage(n,t),s.getResultSegmentEndPointIsBreak(n,t))}else this.setPointEx(a,h,s.getResultSegmentStartPointRank(n,t),s.getResultSegmentStartPointWeight(n,t),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?V(0,-1):V(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 V(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=et(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,cr,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 cr}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,n){s(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=S.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=Q.getNAN(),this.m_workPoint2_2D=Q.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=cr,this.m_lastGeometry=cr,this.m_vertexIndexList=new k(5),this.m_pathIndexList=new k(8),this.m_geometryIndexList=new k(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new G,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new me(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=me.constructEmpty(),n=this.queryVertexIterator();let i=!0;for(let r=n.next();r!==cr;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=me.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}i=!1}return s}getEnvelope3D(t){return s(0),S.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){s(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,s){const n=t.getGeometryType();if(c(n))return this.addMultiPath(t,s);if(n===i.enumMultiPoint)return this.addMultiPoint(t,s);if(n===i.enumPoint)return this.addPoint_(t,s);if(n===i.enumEnvelope){const e=new ur;return e.addEnvelope(t,!1),this.addMultiPath(e,s)}e("")}appendGeometry(t,s){this.mergeVertexDescription(s.getDescription());const n=s.getGeometryType();c(n)?this.appendMultiPath(t,s):n!==i.enumMultiPoint?e(""):this.appendMultiPoint(t,s)}assignRankToGeometryVertices(t,e){e<gr&&(e=gr);const s=this.queryVertexIterator();for(let n=s.next();n!==cr;n=s.next())this.setRank(n,e),this.setSegmentRank(n,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(i.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=cr,s=-1,n=-1;for(let r=this.getFirstGeometry();r!==cr;){if(t===i.enumUnknown||this.getGeometryType(r)===t){if(e===cr){e=r,s=this.getPathCount(e),n=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let s=this.getFirstPath(r);s!==cr;s=this.getNextPath(s))this.setPathGeometry(s,e);s+=this.getPathCount(r),n+=this.getPointCount(r);const t=this.getLastPath(e),i=this.getFirstPath(r);t!==cr?this.setNextPath(t,i):this.setFirstPath(e,i),i!==cr&&(this.setPrevPath(i,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,cr),this.setLastPath(r,cr);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}r=this.getNextGeometry(r)}return e!==cr&&(this.setGeometryVertexCount(e,n),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}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!==cr;c=this.getNextPath(c))this.setPathGeometry(c,e);for(let c=this.getFirstPath(e);c!==cr;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,e,s){const n=this.createGeometry(s?i.enumPolygon:i.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return n;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(n,cr);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let i=r.getPathStart(e),h=r.getPathEnd(e);i<h;i++){const t=this.insertVertex_(o,cr,null,!1);if(a){const e=this.getVertexIndex(t);if(1&r.getSegmentFlags(i))this.setSegmentToIndex(e,null);else{const t=new fm;r.querySegment(i,t,!0),this.setSegmentToIndex(e,t.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),n}getGeometry(t){const e=this.getGeometryType(t),s=mr(e,this.m_verticesMp.getDescription()),n=this.getPointCount(t);if(0===n)return s;if(c(e)){const e=s.getImpl(),i=this.getPathCount(t),r=V(i+1),o=L(i+1,0),a=s.getDescription(),h=this.hasCurves();for(let s=0,u=a.getAttributeCount();s<u;s++){const h=a.getSemantics(s),u=lr.getComponentCount(h),m=I(h,n),l=this.m_vertices.getAttributeStreamRef(h);let c=0,g=0,d=0;for(let e=this.getFirstPath(t);e!==cr;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(i,n)}if(e.setPathFlagsStreamRef(o),e.setPathStreamRef(r),e.notifyModifiedFlags(65535),h){let s=0,n=0;for(let i=this.getFirstPath(t);i!==cr;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(e===i.enumMultiPoint){const e=s.getImpl(),i=s.getDescription();e.reserve(n),e.resizeNoInit(n);for(let s=0,n=i.getAttributeCount();s<n;s++){const n=i.getSemantics(s),r=lr.getComponentCount(n),o=e.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);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(n,o)}e.notifyModifiedFlags(65535)}else h("getGeometry");return s}queryPointGeometryOnly(t,s){this.getGeometryType(t)!==i.enumMultiPoint&&e("get_point_geometry_only");const n=this.getPointCount(t);if(n>1&&e("get_point_geometry_only"),0===n)return s.assignVertexDescription(this.m_vertexDescription),void s.setEmpty();const r=this.getFirstPath(t),o=this.getFirstVertex(r);this.queryPoint(o,s)}removeGeometry(t){for(let n=this.getFirstPath(t);n!==cr;n=this.removePath(n));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==cr?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==cr?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 Se({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===cr?(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]=V(0),e;this.m_geometryIndices.push(V(0));const t=this.m_geometryIndices.length-1;return s(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!==cr;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,e,n,r,o){const a=t*t;let h=0;const u=this.hasCurves(),m=this.hasSegmentParentage(),l=!0;for(let g=o===cr?this.getFirstGeometry():o;g!==cr;g=o===cr?this.getNextGeometry(g):cr){const t=this.getGeometryType(g);if(!c(t))continue;if(n&&t!==i.enumPolygon)continue;const o=this.getGeometryType(g)===i.enumPolygon;let d=this.getGeometryModified(g);for(let n=this.getFirstPath(g);n!==cr;){let t=0;for(let e=this.getFirstVertex(n);t<Math.trunc(this.getPathSize(n)/2);){const i=this.getNextVertex(e);if(i===cr)break;const o=this.getXY(e),c=this.getXY(i);let _=Q.sqrDistance(o,c),p=!0;do{if(_<=a){if(u){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===h&&(h=-1):h=1,i!==this.getLastVertex(n)){const t=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(i));if(this.transferAllDataToTheVertex(i,e,l),this.removeVertex(i,!1),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&e!==i){this.setSegmentParentageBreakVertex(e,t);const n=this.getNextVertex(e);s(n!==cr),this.isDiscontinuousSegmentParentage(n)&&this.setSegmentParentageBreakVertex(n,!0)}}p=!1}}while(0);p&&(e=this.getNextVertex(e)),t++}let i=this.getFirstVertex(n);for(let e=this.isClosedPath(n)?i:this.getLastVertex(n);this.getPathSize(n)>0;){const t=this.getPrevVertex(e);if(t===cr)break;{const o=this.getXY(t),c=this.getXY(e);let _=Q.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){s(this.m_segmentParentageIndex>=0);const n=this.getUserIndex(e,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(t,e,l),this.setUserIndex(e,this.m_segmentParentageIndex,n)}else this.transferAllDataToTheVertex(t,e,l);const o=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(t));this.removeVertex(t,!0),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&t!==e&&(o||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),i===t&&(i=this.getFirstVertex(n)),p=!1}}while(0);if(p&&(e=this.getPrevVertex(e),e===i))break}}const c=this.getPathSize(n);let _=e&&c<(o?3:2);_&&o&&2===c&&u&&(_=!this.pathHasCurves(n)),_?(n=this.removePath(n),0===h&&(h=-1),r&&!d&&(this.setGeometryModified(g,!0),d=!0)):n=this.getNextPath(n)}}return h}filterClosePoints3D(t,e,n,i,r,o){return s(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==cr;e=this.getNextGeometry(e))if(c(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==cr;){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===cr)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 s(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(t,s,n,i,r){let o=0;const a=this.getNextVertex(t);a===cr&&e("");const h=this.getVertexIndex(t),u=this.getVertexIndex(a),m=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,u);const c=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&m&&(l=m.calculateLength2D());const d=this.getSegmentParentage(t),_=this.getHelperPoint();if(m){let t=0,e=0,r=cr;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!==cr){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(t,s,n){this.getNextVertex(t)===cr&&e("");let i=t,r=!1;for(let e=0;e<s;++e){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!==cr;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,n){return s(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!==cr){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,n,i){s(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!==cr){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 Q(e,s),t,!1),i.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==cr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);if(null!==n){const t=n.getStartXY();n.setCoordsForIntersector(t,new Q(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,n){s(0)}setXYZ(t,e,n){s(0)}setXYZCoords(t,e,n,i){s(0)}queryXYZ(t,e){s(0)}getXYZ(t){return s(0),E.getNAN()}getXYZWithIndex(t){return s(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){s(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,n,i){s(0)}setAttribute(t,e,n,i){s(0)}setAttributeInt(t,e,n,i){s(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return s(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 s(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=R(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=R(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 gr;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?gr:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?gr:this.m_ranks.read(t)}setRank(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_ranks){if(s)return;this.m_ranks=V(this.m_vertices.getPointCount(),gr)}const n=this.getVertexIndex(t);if(n>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(n+1,gr)}this.m_ranks.write(n,e)}setRankWithIndex(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_ranks){if(s)return;this.m_ranks=V(this.m_vertices.getPointCount(),gr)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,gr)}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=R(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=R(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 Pr.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?Pr.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?gr:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=V(this.m_vertices.getPointCount(),gr)}const n=this.getVertexIndex(t);if(n>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(n+1,gr)}this.m_segmentRanks.write(n,e)}setSegmentRankWithIndex(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=V(this.m_vertices.getPointCount(),gr)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,gr)}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 s(t>=0&&t<=K()),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 s(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!==cr;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){s(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===cr)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 q({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(n,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,n=!1){return s(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return s(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===cr)return!1;const s=this.getPathSize(t);let n=e;for(let r=0;r<s;r++,n=this.getNextVertex(n)){const t=this.getSegment(n);if(null!==t&&t.getGeometryType()!==i.enumLine)return!0}return!1}insertPath(t,s){let n=cr;s!==cr?(t!==this.getGeometryFromPath(s)&&e(""),n=this.getPrevPath(s)):n=this.getLastPath(t);const i=this.newPath(t);return s!==cr&&this.setPrevPath(s,i),this.setNextPath(i,s),this.setPrevPath(i,n),n!==cr?this.setNextPath(n,i):this.setFirstPath(t,i),s===cr&&this.setLastPath(t,i),this.setGeometryPathCount(t,this.getPathCount(t)+1),i}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);return e!==cr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==cr?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!==cr){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,cr),this.setPrevVertex(s,cr);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){s(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 e=this.getFirstVertex(t);if(e===cr)return 0;const s=this.getXY(e),n=new pt(0),r=this.getPathSize(t);if(r>2){const t=s.clone(),i=t.x,o=t.y;let a=this.getNextVertex(e);const h=this.getXY(a);a=this.getNextVertex(a);const u=Q.getNAN();for(let e=2;e<r;e++,a=this.getNextVertex(a))this.queryXY(a,u),n.pe((u.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(u);n.pe((i-t.x)*(h.y-o))}if(this.hasCurves()){let t=e;for(let e=0;e<r;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===i.enumLine)continue;const s=2*e.calculateArea2DHelper();n.pe(s)}}this.setRingAreaValid(t,!0);const o=.5*n.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 s(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!==cr;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(t,s,n){if(n===cr&&e(""),s===n)return;const i=this.getNextPath(n);let r=this.getPrevPath(n);const o=this.getGeometryFromPath(n);r===cr?this.setFirstPath(o,i):this.setNextPath(r,i),i===cr?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===cr?this.getLastPath(t):this.getPrevPath(s),this.setPrevPath(n,r),this.setNextPath(n,s),s===cr?this.setLastPath(t,n):this.setPrevPath(s,n),r===cr?this.setFirstPath(t,n):this.setNextPath(r,n),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(n)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(n,t)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,cr,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!==cr&&this.setNextVertex(n,i);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?i:cr),i!==cr&&this.setPrevVertex(i,n),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?n:cr);if(this.hasCurves()&&n!==cr&&i!==cr){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){s(t!==e);const n=this.getPathFromVertex(t),i=this.getPrevVertex(t),r=this.getPrevVertex(e);i!==cr&&this.setNextVertex(i,e);let o=this.getPathSize(n);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,i),this.setPrevVertex(t,cr),this.setNextVertex(r,cr);let h=0,u=t;const m=this.getFirstVertex(n);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(n,o>0?e:cr),this.setPathSize(n,o);const c=this.getGeometryFromPath(n);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,cr,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||h(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==cr;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==cr;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=cr){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=cr){let s=cr,n=cr,i=cr,r=cr,o=0,a=!1;for(s=e!==cr?e:this.getFirstGeometry();s!==cr;s=this.getNextGeometry(s))if(!t||c(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==cr;n=this.getNextPath(n))if(i=this.getFirstVertex(n),r=i,o=0,i!==cr){a=!0;break}if(a||e!==cr)break}return a||(s=cr),pr.create_(this,s,n,i,r,o,t,!1,e!==cr)}queryVertexIteratorOnSelection(t=cr){return this.m_selection?pr.create_(this,t,cr,cr,cr,-1,!1,!0,t!==cr):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){s(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]=cr,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 s(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===cr)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 s(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!==cr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==cr?this.setPrevPath(s,e):this.setLastPath(n,e),this.setFirstVertex(t,cr),this.setLastVertex(t,cr),this.freePath(t)}insertClosedPath(t,e,s,n,i){const r=this.insertPath(t,cr);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 s(0),0}findVertex3D(t,e,n){return s(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===cr)return cr;return s}removeVertexInternal(t,e){const s=this.getPrevVertex(t),n=this.getNextVertex(t);s!==cr&&this.setNextVertex(s,n),n!==cr&&this.setPrevVertex(n,s);if(this.hasCurves()&&s!==cr&&n!==cr){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){s(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new dr(this))}sortVerticesSimpleByX(t,e,n){s(0)}sortVerticesSimpleByY3D(t,e,n){s(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==cr&&this.replaceCurveWithLine(s);this.getNextVertex(t)!==cr&&this.replaceCurveWithLine(t);const n=new Q;this.queryXY(t,n),n.y=e,this.setXY(t,n)}setSegmentParentageAndBreak(t,e,n=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&(s(e<=Yt()>>1),e<<=1,e|=n?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if(s(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}if(e>=0){s(e<=Yt()>>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 fr(e)}return new fr(-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&=Yt()>>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===cr)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 yr(t){if(t.isEmpty())return new ur({vd:t.getDescription()});if(c(t.getGeometryType())&&t.hasNonLinearSegments())return Cr(t);const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new q({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new q,s=new Os({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 wr({stream:n,n:s});let r=0,o=1;const a=n.readPoint2D(r<<1),h=new Q;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 Q;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 ur({vd:u}):new Os({vd:u});const t=g.getImpl();t.reserve(i.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new Q;for(let r=i.m_treeHull.getFirst();-1!==r;r=i.m_treeHull.getNext(r))if(m){const s=new q;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 q({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 q(t)}return g}function xr(t,e,s,n=!1){if(e<=262144)return Ir(t,e,s,n);const i=new wr({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 Cr(t){s(t.hasNonLinearSegments()&&!t.isEmpty());const e=new wr;return e.addGeometry(t),e.getBoundingGeometry()}function vr(t,s,n){if((s<0||s>=t.getPathCount())&&e("path index"),t.hasNonLinearSegmentsPath(s))return!1;const i=t.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(!Mr(Q.orientationRobust(c,g,l)))return!1;const d=c.clone(),_=new Q;for(let e=u+6;e<m;e+=2){_.assign(c),c.assign(g),h.queryPoint2D(e,g);if(!Mr(Q.orientationRobust(c,g,l)))return!1;if(!Mr(Q.orientationRobust(d,g,l)))return!1;if(!Mr(Q.orientationRobust(c,g,_)))return!1}return!0}function br(t,e,s){t.setNAN(),e.setCoords(1,0),s.setCoords(0,0)}function Er(t,e,s,n,r){if(br(s,n,r),t.isEmpty())return;if(t.getGeometryType()===i.enumPoint)return void s.assign(t.getXY());const o=t,a=o.getPointCount();0!==a&&(1!==a?Sr(o,a,e,s,n,r):s.assign(o.getXY(0)))}function Sr(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=Xr(o),r.setCoords(.5*o.length(),0)}else{let o=Number.MAX_VALUE;const a=[0,1,0,0],h=new Pt(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],qr(h,0,e)){a[1]===a[0]&&(++a[1],qr(h,1,e));for(let s=1;;++s){for(;;){const n=Fr(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],qr(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=Xr(t.getXY(h.get(0,1)).sub(t.getXY(h.get(0,0)))),l=new Q;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=et(r.x,r.x=r.y),i.leftPerpendicularThis())}i.y<0?i.negateThis():0===i.y&&(i.x=1)}Pr.st_defaultRank=1;class Dr{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,s(0),this.m_convexHull=t,this.m_function=this.done_}next(){return s(0),!1}get_vertex_handle_p(){return s(0),0}get_vertex_handle_q(){return s(0),0}get_current_support(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}intialize_(){return s(0),!1}increment_(){return s(0),!1}increment_q_(){return s(0),!1}increment_p_(){return s(0),!1}parallel_edge_with_q_support_(){return s(0),!1}parallel_edge_with_p_support_(){return s(0),!1}done_(){return s(0),!1}}class wr{nullGetXY(t){return h("m_getXY is null"),{}}nullDeleteNode(t){h("m_deleteNode is null")}constructor(t){return this.m_treeHull=new j,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=cr,void(this.m_pathHandle=cr)):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=cr,void(this.m_pathHandle=cr)):void d("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new Pr,this.m_geometryHandle=this.m_shape.createGeometry(i.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,cr),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 s(0),new Q}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){s(0)}addGeometry(s){if(s.isEmpty())return;const n=s.getGeometryType();if(n===i.enumGeometryCollection){const t=s;for(let e=0,s=t.getGeometryCount();e<s;e++)this.addGeometry(t.getGeometry(e))}else t(n)?this.addMultiVertexGeometry(s):m(n)?this.addSegment(s,!1):n===i.enumEnvelope?this.addEnvelope(s):n===i.enumPoint?this.addPoint(s):e("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new q,e=this.m_treeHull.getFirst(),s=new ur({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 s(0),new Dr(this)}getXY(t){return s(0),new Q}getXYWithIndex(t){return s(0),new Q}getFirst(){return s(0),0}getLast(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}getVertexIndex(t){return s(0),0}getPointCount(){return s(0),0}addMultiVertexGeometry(t){const e=new q,s=t.getImpl(),n=new Q;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 q;for(let s=0;s<4;s++){const n=new Q;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(t,n,r){const o=t.getGeometryType();if(s(o!==i.enumLine),o===i.enumEllipticArc){const e=t,s=60*Math.PI/180,i=Math.abs(e.getSweepAngle());if(i>s){const t=Math.min(6,Math.ceil(i/s)),r=1/t,o=new fm;e.queryStart(n[0]);let a=1;for(let s=0;s<t;s++){e.queryCut(s*r,(s+1)*r,o);const i=lt(Q,3);Bu(o.get(),i);const h=Q.calculateLength(i,3),u=Q.calculateLength(i,2),m=h>0?u/h:.5;s<t-1?o.get().queryEnd(n[a+1]):e.queryEnd(n[a+1]),q.lerp(n[a-1],n[a+1],m,n[a]),n[a].setXY(i[1]),a+=2}return a}{const e=lt(Q,3);Bu(t,e);const s=Q.calculateLength(e,3);t.queryStart(n[0]),t.queryEnd(n[2]);const i=Q.calculateLength(e,2),r=s>0?i/s:.5;return q.lerp(n[0],n[2],r,n[1]),n[1].setXY(e[1]),3}}if(o===i.enumBezier){const e=t,s=lt(Q,4);e.queryControlPoints(s);const i=Q.calculateLength(s,4),r=Q.calculateLength(s,2),o=Q.calculateLength(s,3);t.queryStart(n[0]),t.queryEnd(n[3]);const a=i>0?r/i:.5;q.lerp(n[0],n[3],a,n[1]),n[1].setXY(s[1]);const h=i>0?o/i:.5;return q.lerp(n[0],n[3],h,n[2]),n[2].setXY(s[2]),4}if(o===i.enumBezier2){const e=t,s=lt(Q,3);e.queryControlPoints(s);const i=Q.calculateLength(s,3);t.queryStart(n[0]),t.queryEnd(n[2]);const r=Q.calculateLength(s,2),o=i>0?r/i:.5;return q.lerp(n[0],n[2],o,n[1]),n[1].setXY(s[1]),3}if(o===i.enumRationalBezier2){const e=t,s=lt(Q,3);e.queryControlPoints(s);const i=Q.calculateLength(s,3);t.queryStart(n[0]),t.queryEnd(n[2]);const r=Q.calculateLength(s,2),o=i>0?r/i:.5;return q.lerp(n[0],n[2],o,n[1]),n[1].setXY(s[1]),3}e("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){const e=new q,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=lt(q,13);for(let s=1,n=wr.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=Q.orientationRobust(a,t,o);if(Mr(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(Yr(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);Yr(Q.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(!Mr(Q.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=Nr(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(Mr(Q.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(Mr(Q.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 Ar(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:Q.orientationRobust(t,e,s)}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:Q.orientationRobust(t,e,s)}function Ir(t,e,s,n){const i=new W(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||G.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(!(Ar(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(!(Tr(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 Mr(t){return t<0}function Yr(t){return t>0}function Nr(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 Xr(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function qr(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Fr(t,s,n,i,r){switch(r){case 0:break;case 1:s.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:s.negateThis(),t.negateThis();break;case 3:s.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:e("")}return Q.orientationRobustEx(t,s,n,i)}class Vr{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Lr(t){return Rr(t.calculateUpperLength2D())}function Rr(t){return 256*dt()*t}function zr(t){const e=Q.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function Br(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 kr(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),Wr(n,e,s)}function Gr(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),jr(n,e,s)}function Wr(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 jr(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 Zr(t,e,s=!1){const n=lt(Xe,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(it.constructInt32(3)),e[2].setCoords(n[2].x.sub(n[1].x),n[2].y.sub(n[1].y)),e[2].mulThis(it.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($t,$t):e[0]=n[0].clone()}function Hr(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Hr(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=Qr(t);if(n&&!Number.isNaN(i.length)&&!Number.isNaN(i.length))return i.length;const r=Lr(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+=$o(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function Ur(t,e,s){const n=Hr(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==tn(new Ko(t,e),H.unit(),1,i)&&h(""),i[0]}function Or(t,s,n){void 0===n&&(n=s,s=0);const i=new Q;if(s<0||n>1)return i.setNAN(),i;if(s>n&&e("calculate_sub_weightedCentroid"),s===n||t.isDegenerate(0))return i.setCoords(0,0),i;const r=Qr(t),o=Lr(t),a=o/t.calculateUpperLength2D();let h=s,u=0;for(let e=1,m=r.specialPointsCount();e<m;e++)if(s<r.specialPoints[e]){u=e-1;break}i.setCoords(0,0);for(let e=u+1,m=r.specialPointsCount();e<m;e++){const s=Math.min(r.specialPoints[e],n),u=ta(t,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}function Qr(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Vr,s=lt(at,8),n=lt(Q,4);t.queryControlPoints(n);const i=jo(n,s);e.specialPoints=[];for(let r=0;r<i;r++)e.specialPoints.push(s[r].value());return Jr(t,e),e}function Kr(t){let e=null;return e=t.m_cachedValues,e}function Jr(t,e){t.m_cachedValues=e}function $r(t){t.m_cachedValues=null}function to(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function eo(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 le,o=lt(Q,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new Q;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=lt(Q,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):(xt(e,s,1/3,t.m_cp[0]),xt(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),i&&lo(t)}function so(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function no(t,e,s,n){const i=lt(Q,4);t.queryControlPoints(i);const r=U(18,NaN),o=tn(new Vo(i,e,NaN),H.construct(s,n),18,r),a=new Q;t.queryCoord2D(s,a);let h=s,u=Q.distance(a,e);const m=new Q;t.queryCoord2D(n,m);const l=Q.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=Q.distance(m,e);s<u&&(u=s,h=r[c],a.assign(m))}return so(s,n,h,u,a)}function io(t,e){const n=lt(at,4);kr(t,n,!0);const i=lt(at,4);Gr(t,i,!0);const r=n[3].clone(),o=n[2].clone(),a=n[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),_=lt(at,3),p=dn(d,g,c,l,new H(0,1),!1,_);if(s(p<=3),p>0){const s=uo(t,1,0).sqrLength(),n=uo(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=uo(t,1,_[r].value()).sqrLength();s<i&&(i=s,e=_[r])}}}function ro(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 oo(t,e,s,n){{const e=ht.subE(s),i=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(i).addE(t[2].subE(t[1]).mulE(new at(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));n.setE(o.mulE(new at(3)))}}function ao(t,e,s){const n=new Q;return ro(t,e,s,n),n}function ho(t,e,s){const n=[Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2]),Ye.constructPoint2D(t[3])],i=new Ye;return oo(n,e,s,i),i}function uo(t,e,s){const n=lt(Q,4);return t.queryControlPoints(n),ao(n,e,s)}function mo(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 lo(t){const e=lt(Q,4);t.queryControlPoints(e);const s=co(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function co(t){return Fe(t)}function go(t){return Ve(t)}function _o(t,e,s){const n=new Q,i=new Q,r=new Q,o=new Q,a=new Q;e<=.5?(Xt(2,t[0],t[1],e,n),Xt(2,t[1],t[2],e,i),Xt(2,t[2],t[3],e,r),Xt(2,n,i,e,o),Xt(2,i,r,e,a),Xt(2,o,a,e,s)):(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))}function po(t,e,n,i){s(e>=0&&e<=1);const r=new Q,o=new Q,a=new Q,h=new Q,u=new Q,m=new Q;e<=.5?(Xt(2,t[0],t[1],e,r),Xt(2,t[1],t[2],e,o),Xt(2,t[2],t[3],e,a),Xt(2,r,o,e,h),Xt(2,o,a,e,u),Xt(2,h,u,e,m)):(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));const l=t[3].clone();n&&(n[0].assign(t[0]),n[1].assign(r),n[2].assign(h),n[3].assign(m)),i&&(i[0].assign(m),i[1].assign(u),i[2].assign(a),i[3].assign(l))}function fo(t,e,n,i){if(s(e>=0&&n<=1&&e<=n),e===n){const s=new Q;return Po(t,e,s),i[0].assign(s),i[1].assign(s),i[2].assign(s),void i[3].assign(s)}if(0===e&&1===n){for(let e=0;e<4;++e)i[e].assign(t[e]);return}const r=lt(Q,4);po(t,n,r,null),po(r,n>0?e/n:0,null,r),Po(t,e,r[0]),Po(t,n,r[3]),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]),i[2].setCoordsPoint2D(r[2]),i[3].setCoordsPoint2D(r[3])}function Po(t,e,s,n){if(n){if(e<0){return void _s(new pm({start:t[0],end:t[0].add(Co(t,0).getUnitVector())}),e,s)}if(e>1){return void _s(new pm({start:t[3],end:t[3].add(Co(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=new Q;Xt(2,t[0],t[1],e,n);const i=new Q;Xt(2,t[1],t[2],e,i);const r=new Q;Xt(2,t[2],t[3],e,r);const o=new Q;Xt(2,n,i,e,o);const a=new Q;Xt(2,i,r,e,a),Xt(2,o,a,e,s)}else{const n=new Q;qt(2,t[0],t[1],e,n);const i=new Q;qt(2,t[1],t[2],e,i);const r=new Q;qt(2,t[2],t[3],e,r);const o=new Q;qt(2,n,i,e,o);const a=new Q;qt(2,i,r,e,a),qt(2,o,a,e,s)}}function yo(t,e,s){if(e.value()<=.5){const n=new Ye;Ft(2,Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),e,n);const i=new Ye;Ft(2,Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2]),e,i);const r=new Ye;Ft(2,Ye.constructPoint2D(t[2]),Ye.constructPoint2D(t[3]),e,r);const o=new Ye;Ft(2,n,i,e,o);const a=new Ye;Ft(2,i,r,e,a),Ft(2,o,a,e,s)}else{const n=new Ye;Vt(2,Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),e,n);const i=new Ye;Vt(2,Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2]),e,i);const r=new Ye;Vt(2,Ye.constructPoint2D(t[2]),Ye.constructPoint2D(t[3]),e,r);const o=new Ye;Vt(2,n,i,e,o);const a=new Ye;Vt(2,i,r,e,a),Vt(2,o,a,e,s)}}function xo(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),yo(n,e,s)}function Co(t,e){const s=_t(e,0,1);let n=ao(t,1,s);return n.isZero()&&(n=ao(t,2,s),n.isZero()?n=ao(t,3,s):1===s&&n.negateThis()),n}function vo(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),bo(n,e,s)}function bo(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(ho(t,1,e))}function Eo(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==To(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function So(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(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!==am(e,s))return 2}else if(Le(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!==am(e,s))return t?4:2}else if(Le(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!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==No(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function To(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 Q;e.queryCoord2D(t[s],i),n.push(i)}}return a}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=lt(Q,4);Br(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=U(15,Number.NaN),P=U(15,Number.NaN);let y=sn(d,_,p,H.unit(),!1,f);y<0&&(f[0]=0,f[1]=1,y=2);let x,C=0;for(let E=0,S=C;E<y;++E){const t=e.getCoord2D(f[E+S]);P[C]=s.getClosestCoordinate(t,!1),Q.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[E+S],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=nn(d,_,p,x,H.unit(),v,b);for(let E=0,S=C;E<y;++E){f[E+S]=b[E];const t=e.getCoord2D(f[E+S]);P[C]=s.getClosestCoordinate(t,!1);Q.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[E+S],C++)}y=e.intersectPoint(s.getStartXY(),b,o);for(let E=0;E<y;E++)f[C]=b[E],P[C++]=0;y=e.intersectPoint(s.getEndXY(),b,o);for(let E=0;E<y;E++)f[C]=b[E],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:cm(t,e,s,f,P,C,n,i,r,o,a,h,u)}function Io(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return To(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=[],d=lt(Q,4);{e.queryControlPoints(d);const t=lt(Q,4),n=new le;s.canonicToWorldTransformation(n);const i=new le;i.setInvert(n),i.transformPoints2D(d,4,t);const r=lt(Xe,4);Zr(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=lt(it,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 _=qn(h,3,u,3,null,0,m,!0,H.unit(),H.unit(),c,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new Q;e.queryCoord2D(c[n],i);const r=s.getClosestCoordinate(i,!1),a=new Q;s.queryCoord2D(r,a);Q.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];Lo(d,t,H.unit(),!1,-1,1,e);const n=new Q;Po(d,e[0],n);Q.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 Q;s.queryCoord2D(e,n);Q.distance(d[t[p]],n)<=o&&(c.push(_[p]),g.push(e),l.push(n.clone()))}}return cm(t,e,s,c,g,c.length,n,i,r,o,a,h,u)}function Mo(t,e,n,i,r,o,a,h,u,m){const l=lt(Q,4);e.queryControlPoints(l);const c=lt(Q,4);if(n.queryControlPoints(c),as(l,c,4)<0)return Mo(t,n,e,i,o,r,a,h,u,!m);const g=rs(e,n);if(os(e,n,a=Math.max(a,g)))return 0;if(ea(e,n,i,r,o,a,h,u,m))return 2;const d=new H(0,1),_=new H(0,1);{const t=new De;Fo(l,new H(0,1),t);const e=new De;Fo(c,new H(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(Oo(l,t,d),d.isEmpty())return 0;if(Oo(c,t,_),_.isEmpty())return 0;fo(l,d.vmin,d.vmax,l),fo(c,_.vmin,_.vmax,c)}}const p=dm(l,3,c,3,a);if(0===p)return 0;const f=[],P=[],y=[];let x=!1;if(-1===p){const t=lt(Xe,4);Zr(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=lt(Xe,4);Zr(c,n);const i=[],r=[],o=Yn(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,H.unit(),H.unit(),i,r,u);if(o>0)for(let h=0;h<o;h++){const t=new Q;Po(c,r[h],t);const e=new Q;Po(l,i[h],e);Q.distance(e,t)<=a&&(f.push(e.clone()),y.push(r[h]),P.push(i[h]))}else-1===o&&(x=!0)}for(let s=0;s<2;s++){const t=0===s?l:c,e=0===s?c:l;for(let n=0;n<2;n++){const i=0===n?0:3,r=[0];Lo(e,t[i],H.unit(),!1,-1,1,r);const o=new Q;Po(e,r[0],o);Q.distance(t[i],o)<=a&&(0===s?(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()>n.calculateUpperLength2D();{const i=[0,0];if(2===Go(t?e:n,i,!0)&&(s(H.unit().containsCoordinate(i[0])),!H.unit().containsCoordinate(i[1]))){const e=new Q;Po(t?l:c,i[0],e);const s=[0,0];1===Lo(t?c:l,e,H.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 s=0;s<P.length;++s)P[s]=ia.recalculateParentT(d.vmin,d.vmax,P[s]);if(!_.equalsRange(0,1))for(let s=0;s<y.length;++s)y[s]=ia.recalculateParentT(_.vmin,_.vmax,y[s]);return cm(t,e,n,P,y,P.length,i,r,o,a,h,u,m)}function Yo(t,e,n,i,r,o,a,h,u,m){const l=rs(e,n);if(n.isDegenerateToLineHelper(l)){const s=new pm({start:n.getStartXY(),end:n.getEndXY()}),l=To(t,e,s,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=n.getClosestCoordinate(e,!1)}return l}if(os(e,n,a=Math.max(a,l)))return 0;const c=lt(Q,4);e.queryControlPoints(c);const g=lt(Q,3);n.queryControlPoints(g);const d=new H(0,1),_=new H(0,1),p=[0,0,0];n.queryWeights(p);const f=[1,fh(p),1];{const t=new De;Fo(c,new H(0,1),t);const e=new De;Wa(g,f,new H(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(Oo(c,t,d),d.isEmpty())return 0;if(ph(g,f,t,_),_.isEmpty())return 0;fo(c,d.vmin,d.vmax,c),Qa(g,f,_.vmin,_.vmax,g,f)}}const P=dm(c,3,g,2,a);if(0===P)return 0;const y=[],x=[],C=[];if(-1===P){const t=lt(Xe,4);Zr(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=lt(it,3),i=lt(it,3),r=lt(it,3);hh(g,f,n,i,r);const o=[],h=[],m=Yn(n,2,i,2,r,2,e,3,s,3,null,0,!0,H.unit(),H.unit(),h,o,u);if(m>0)for(let u=0;u<m;u++){const t=new Q;Po(c,o[u],t);const e=new Q;_h(g,f,h[u],e);Q.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 n=0;n<2;n++){const i=0===n?0:t.length-1,r=[0],o=new Q;if(0===v){const n=za(e,f,t[i],H.unit(),!1,-1,1,r);s(1===n),_h(e,f,r[0],o)}else{const n=Lo(e,t[i],H.unit(),!1,-1,1,r);s(1===n),Po(e,r[0],o)}Q.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 s=0;s<x.length;++s)x[s]=ia.recalculateParentT(d.vmin,d.vmax,x[s]);if(!_.equalsRange(0,1))for(let s=0;s<C.length;++s)C[s]=Sn.recalculateParentT(_.vmin,_.vmax,C[s]);for(let s=0;s<C.length;++s)C[s]=Ph(p,C[s]);return cm(t,e,n,x,C,x.length,i,r,o,a,h,u,m)}function No(t,e,n,i,r,o,a,h,u,m){const l=rs(e,n);if(os(e,n,a=Math.max(a,l)))return 0;const c=lt(Q,4);e.queryControlPoints(c);const g=lt(Q,3);n.queryControlPoints(g);const d=dm(c,3,g,2,a);if(0===d)return 0;const _=[],p=[],f=[];if(-1===d){const t=lt(Xe,4);Zr(c,t);const s=[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=lt(Xe,3);Wi(g,r);const o=Yn([r[0].x,r[1].x,r[2].x],2,[r[0].y,r[1].y,r[2].y],2,null,0,s,3,i,3,null,0,!0,H.unit(),H.unit(),f,p,h);if(o>0){let t=0;for(let s=0;s<o;s++){const i=new Q;e.queryCoord2D(p[s],i);const r=new Q;n.queryCoord2D(f[s],r);Q.distance(i,r)<=a&&(_.push(i.clone()),p[t]=p[s],f[t]=f[s],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 n=0;n<2;n++){const i=0===n?0:t.length-1,r=[0],o=new Q;if(0===P)vi(e,t[i],r),ji(e,r[0],o);else{const n=Lo(e,t[i],H.unit(),!1,-1,1,r);s(1===n),Po(e,r[0],o)}Q.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 cm(t,e,n,p,f,p.length,i,r,o,a,h,u,m)}function Xo(t,e,i,r,o){const a=new De;if(qo(t,H.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;const h=Qr(t);let u=0,m=h.specialPoints[0];const l=[];for(let n=1,c=h.specialPoints.length;n<c;++n){const i=h.specialPoints[n],r=no(t,e,m,i);if(0===l.length)l.push(r);else if(r.t===r.tmin)s(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){s(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=i}for(const s of l)if(s.d<=r){const t=s.t;i?(u>=i.length&&n(""),i[u]=t,u++):u++}return u}function qo(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),Fo(n,e,s)}function Fo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const n=lt(Q,4);fo(t,e.vmin,e.vmax,n),s.setFromPoints(n,4)}let Vo=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 Q;Po(this.controlPoints,e,t);const s=ao(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new Q;Po(this.controlPoints,e,t);const s=ao(this.controlPoints,1,e),n=ao(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(n)+s.dotProduct(s))}case 2:{const t=new Q;Po(this.controlPoints,e,t);const s=ao(this.controlPoints,1,e),n=ao(this.controlPoints,2,e),i=ao(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(i)+3*s.dotProduct(n))}case 3:{const t=ao(this.controlPoints,1,e),s=ao(this.controlPoints,2,e),n=ao(this.controlPoints,3,e);return 2*(4*t.dotProduct(n)+3*s.sqrLength())}case 4:{const t=ao(this.controlPoints,2,e),s=ao(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=ao(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=lt(Q,4);fo(this.controlPoints,t,e,s);const n=new De;if(n.setFromPoints(s,4),Math.sqrt(n.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function Lo(t,e,n,i,r,o,a){_(H.unit().contains(n)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],u=new Q;Po(t,n.vmin,u);let m=Q.distance(u,e);if(m<=r&&h.push(new Q(n.vmin,m)),n.vmin!==n.vmax&&(Po(t,n.vmax,u),m=Q.distance(u,e),m<=r&&h.push(new Q(n.vmax,m))),n.width()>0){const s=U(18,Number.NaN),i=tn(new Vo(t,e,r),n,18,s);for(let n=0;n<i;n++)Po(t,s[n],u),m=Q.distance(u,e),m>r||h.push(new Q(s[n],m))}if(i){s(n.equals(H.unit()));{Po(t,-1,u,!0);const s=new Q;Po(t,0,s);const n=new pm({start:u,end:s}),i=n.getClosestCoordinate(e,!0);i<1&&(u.assign(n.getCoord2D(i)),m=Q.distance(u,e),m<=r&&h.push(new Q(i-1,m)))}{Po(t,2,u,!0);const s=new Q;Po(t,n.vmax,s);const i=new pm({start:s,end:u}),o=i.getClosestCoordinate(e,!0);o>0&&(u.assign(i.getCoord2D(o)),m=Q.distance(u,e),m<=r&&h.push(new Q(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=Z(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)=>Bt(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 Ro(t,e,s,n,i,r,o){const a=lt(Q,4);return t.queryControlPoints(a),Lo(a,e,s,n,i,r,o)}function zo(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function Bo(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function ko(t,e,n){if(s(n>=2),2===n){const s=new Q;xt(e[0],e[n-1],1/3,s);const i=new Q;return xt(e[0],e[n-1],2/3,i),void t.construct(e[0],s,i,e[n-1])}const i=e[0],r=e[n-1],o=[0,0],a=Ro(t,i,H.unit(),!1,Number.NaN,2,o),h=[0,0],u=Ro(t,r,H.unit(),!1,Number.NaN,2,h),m=[];for(let s=0;s<a;s++)for(let a=0;a<u;a++){const u=o[s],l=h[a],c=u>l,g=(s,o)=>{const a=U(n-2,Number.NaN),h=()=>{let t=0;for(let s=1,i=n-1;s<i;s++){t+=Q.distance(e[s-1],e[s]);const n=t;a[s-1]=n}t+=Q.distance(e[n-2],e[n-1]),c&&a.reverse();for(let e=1,s=n-1;e<s;e++)a[e-1]/=t,c&&(a[e-1]=1-a[e-1])};let m=!1,g=!1;{const e=new fm;c?(t.queryCut(l,u,e,!0),s.assign(e.get().getControlPoint2()),o.assign(e.get().getControlPoint1())):(t.queryCut(u,l,e,!0),s.assign(e.get().getControlPoint1()),o.assign(e.get().getControlPoint2())),i.equals(s)&&(m=!0),r.equals(o)&&(g=!0)}h();let d=Number.MAX_VALUE;const _=s.clone(),p=o.clone();for(let t=0;t<5;t++){d=sa(!0,!1,i,_,p,r,m,g,a,n-2,e,n)}for(let t=0;t<30;t++){const t=_.clone();p.clone();const s=sa(!0,!0,i,_,p,r,m,g,a,n-2,e,n);if(d<=s&&t.equals(_)&&t.equals(p))break;d=s}h();let f=!1,P=Number.MAX_VALUE;const y=s.clone(),x=o.clone();for(let t=0;t<30;t++){const t=y.clone();x.clone();const s=sa(f,!0,i,y,x,r,m,g,a,n-2,e,n);if(P<=s&&t.equals(y)&&t.equals(x))break;f=!0,P=s}return P<d?(s.assign(y),o.assign(x)):(s.assign(_),o.assign(p),P=d),P},d=new Q,_=new Q,p=[g(d,_),Q.distance(i,d)+Q.distance(d,_)+Q.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 s=6;s<m.length;s+=6)m[s]<l&&(l=m[s],c=m[s+1],g=s);let d=g;for(let s=0;s<m.length;s+=6)s!==g&&m[s+1]<c&&Math.abs(l-m[s])<10*l&&(c=m[s+1],d=s);t.construct(i,new Q(m[d+2],m[d+3]),new Q(m[d+4],m[d+5]),r)}function Go(t,e,s=!1){const n=lt(Q,4);t.queryControlPoints(n);const i=lt(Xe,4);let r,o,a;Zr(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=sn(1,-r.toDouble(),r.add(o).mul(r).add(a).toDouble(),H.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]=et(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]=et(e[0],e[0]=e[1])),2}return 0}function Wo(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=lt(at,2);let a=gn(r,i,n,new H(0,1),!1,o);a<0&&(a=0);let h=0;for(let u=0;u<a;u++)gt(o[u].value(),0,1)||(s[h].setE(o[u]),h++);return h}function jo(t,e){e[0].set(0);let n=1;const i=lt(at,4);Wr(t,i,!0);const r=lt(at,4);jr(t,r,!0);{const t=i[3].mul(3),s=i[2].mul(2),r=i[1].clone(),o=lt(at,2);let a=gn(t,s,r,new H(0,1),!1,o);a<0&&(a=0);for(let i=0;i<a;i++)gt(o[i].value(),0,1)||(e[n]=o[i],n++)}{const t=r[3].mul(3),s=r[2].mul(2),i=r[1].clone(),o=lt(at,2);let a=gn(t,s,i,new H(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)gt(o[r].value(),0,1)||(e[n]=o[r],n++)}if(n+=Wo(i,r,e.slice(n)),e[n].set(1),n++,n>2){tt(e,0,n,(t,e)=>{const s=t.value(),n=e.value();return s<n?-1:s>n?1:0});let s=0;const i=e[0].clone();let r=0;const o=Bo(t)*dt(),a=new Q;_o(t,e[0].value(),a);for(let h=1;h<n;h++){const n=new Q;if(_o(t,e[h].value(),n),e[h].eq(i)||n.isEqualPoint2D(a,o)){if(0!==s){if(0===e[h].eps())i.setE(e[h]),r=0;else if(0!==r){const t=zt(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[s].setE(i),_o(t,i.value(),a)}}else s++,e[s].setE(e[h]),i.setE(e[h]),_o(t,i.value(),a),r=zt(e[h].eps())}s++,n=s}return 1===n&&(n=2,e[1].set(1)),s(0===e[0].value()),s(1===e[n-1].value()),n}function Zo(t,e,s,n,i){const r=lt(at,4),o=lt(at,3),a=new H(0,1);let h=0;if(e){if(jr(t,r,!1),h=dn(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new Q;Po(t,o[u].value(),e),n[u]=e.x}}else if(Wr(t,r,!1),h=dn(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new Q;Po(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&&tt(n,0,h,Bt);return h}function Ho(t,e,s,n){const i=Uo(t,e,s,n.getEnvelope2D());if(i.isEmpty())return new H(i);const r=lt(Q,s);for(let a=0;a<s;++a)n.xyRot(t[a],r[a]);const o=Uo(r,e,s,n.getRotatedEnvelope2D());return i.intersect(new H(o)),new H(i)}function Uo(t,e,s,n){const i=lt(Q,s);for(let a=0;a<s;++a)i[a]=new Q(a/(s-1),0);const r=(t,e,s,n)=>{const i=.1,r=new at(e.x).subE(new at(t.x)).divE(new at(e.y).subE(new at(t.y))).mulE(new at(s).subE(new at(t.y))).addE(new at(t.x));if(r.eps()>i){const n=(e.x-t.x)/(e.y-t.y)*(s-t.y)+t.x;r.set(n,dt())}if(r.lt(new at(0))||r.gt(new at(1)))return!1;let o=r.value()-r.eps();o=_t(o,0,1);let a=r.value()+r.eps();return a=_t(a,0,1),n.mergeCoordinate(o),n.mergeCoordinate(a),!0},o=[];{const e=(t,e)=>{o.length=s;const n=xr(i,s,o,!0),a=new H;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 H(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 H(h)),new H(a)}}function Oo(t,e,s){s.setEmpty(),s.merge(Ho(t,null,4,e))}function Qo(t,e,s){s.length=0;{const e=new at;io(t,e);const n=new Ye;if(vo(t,e,n),n.isZero())return e.isZero()||e.eq(new at(1))?0:(s.push(e.value()),1)}const n=lt(at,4);kr(t,n,!0);const i=lt(at,4);Gr(t,i,!0);const r=lt(at,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=lt(at,5),b=_n(r,5,new H(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)&&!gt(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=Go(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-Hr(this.b,e,!1):0}getError(t){return 0}}function Jo(t,e,n,i,r,o,a){for(;;){const h=Q.distance(e[0],e[3]),u=Q.distance(e[0],e[1])+Q.distance(e[1],e[2])+Q.distance(e[2],e[3]);if(u-h<=i+n*u)return t+rt(h,u,.5);const m=t=>ao(e,1,t).length();{s(a<12);let h=m(0),l=m(1);r[0]+=2,h>l&&(l=et(h,h=l),e[3]=et(e[0],e[0]=e[3]),e[2]=et(e[1],e[1]=e[2]));let c=h/(h+l),g=1,d=u;for(;c<1/32&&d>=32*(i+n*d);){g/=4;const t=m(g);r[0]++,c=h/(t+h);const s=new Q;if(Po(e,.5*g,s),d=Q.distance(s,e[0]),d<=i){const t=new Q;Po(e,g,t),d+=Q.distance(t,s)}}if(1!==g){const s=lt(Q,4);po(e,g,e,s),t=Jo(t,s,n,i,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=hr(l,m,0,1),g=16;r[0]+=g;const d=hr(g,m,0,1);let _=Math.abs(c-d)>i+n*u;if(!_)return t+d;if(o<3){const s=lt(Q,4);po(e,.5,e,s),t=Jo(t,s,n,i,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const f=hr(p,m,0,1);if(_=Math.abs(d-f)>i+n*u,!_)return t+f;const P=64;r[0]+=P;const y=hr(P,m,0,1);if(_=Math.abs(f-y)>i+n*u,!_)return t+y;const x=128;r[0]+=x;const C=hr(x,m,0,1);return _=Math.abs(y-C)>i+n*u,t+C}}function $o(t,e,s,n,i){if(s===e)return 0;const r=lt(Q,4);t.queryControlPoints(r);const o=lt(Q,4);fo(r,e,s,o);return Jo(0,o,n,i,[0],0,0)}function ta(t,e,s,n,i){let r=!0;const o=Kn(5,e,s,n,i,e=>{const s=uo(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=uo(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});return new Q(o,a)}function ea(t,e,s,n,i,r,o,a,h){const u=lt(Q,4);t.queryControlPoints(u);const m=lt(Q,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]=et(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=et(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[3]),h&&(s[1]=et(s[0],s[0]=s[1]))),!0)}function sa(t,e,n,i,r,o,a,h,u,m,l,c){s(m+2===c);let g=0,d=0,_=0,p=0,f=0,P=0,y=0;const x=(t,e)=>{const s=1-e,a=n.mul(oe(s)),h=i.mul(3*e*s*s),u=r.mul(3*e*e*s),m=o.mul(oe(e));return a.add(h).add(u).add(m).sub(l[t]).sqrLength()};for(let s=1,v=c-1;s<v;s++){let e=u[s-1];if(t){s>2?(e=_t(2*u[s-2]-u[s-3],0,1),u[s-1]=e):2===s&&(e=_t(2*u[s-2],0,1),u[s-1]=e);const t=(t,e,s)=>{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=n.x-2*i.x+r.x,d=n.x-3*i.x+3*r.x-o.x,_=n.y-2*i.y+r.y,p=n.y-3*i.y+3*r.y-o.y,f=n.x-i.x-2*g*e+d*h,P=-l[t].x+n.x*c+e*(3*i.x*m+e*(3*r.x*u+o.x*e)),y=n.y-i.y-2*_*e+p*h,x=-l[t].y+n.y*c+e*(3*i.y*m+e*(3*r.y*u+o.y*e)),C=-6*(f*P+y*x),v=6*(3*zt(f)-(-2*g+2*d*e)*P)+6*(3*zt(y)-(-2*_+2*p*e)*x);if(a=e,0===v)break;e=_t(e-C/v,s,1)}return a};{const e=x(s,u[s-1]);let n=t(s,u[s-1],0),i=x(s,n);if(1.01*e<i){const e=s>1?u[s-2]:0,r=t(s,.3*(u[s-1]-e)+e,0),o=x(s,r);o<i&&(i=o,n=r)}e>i&&(u[s-1]=n)}}const a=u[s-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*n.x+m*o.x-l[s].x);p+=b*a*C,f+=b*h*c;const E=-(v*n.y+m*o.y-l[s].y);P+=E*a*C,y+=E*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)):(xt(n,o,.3,i),xt(n,o,.6,r))}let C=0;for(let s=1,v=c-1;s<v;s++)C+=x(s,u[s-1]);return C}var na=b;class ia extends gs{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=lt(Q,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||vt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=lt(Q,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=lt(Q,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}),h("unrecognized constructor params"),this.m_cp=lt(Q,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=lt(Q,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(),Dt(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),Dt(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),ss(this,t)}getGeometryType(){return i.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void s(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 Q;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s);return}const n=lt(at,8),i=lt(Q,4);this.queryControlPoints(i);const r=jo(i,n),o=new Q;for(let s=1;s<r-1;s++)this.queryCoord2D(n[s].value(),o),t.mergeNe(o)}applyTransformation(t){if(1===t.m_TransformationType){const e=lt(Q,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 $r(this)}s(0)}createInstance(){return new ia({vd:this.m_description})}calculateLength2D(){return Hr(this,1,!1)}calculateLowerLength2D(){return Q.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return Q.distance(this.getStartXY(),this.m_cp[0])+Q.distance(this.m_cp[0],this.m_cp[1])+Q.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){s(0)}queryCoord2DExtends(t,e,s){const n=lt(Q,4);this.queryControlPoints(n),Po(n,t,e,s)}queryCoord2DE(t,e){xo(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new Q;return this.queryCoord2DExtends(t,e,!0),e.x}const e=rt(this.getStartX(),this.m_cp[0].x,t),s=rt(this.m_cp[0].x,this.m_cp[1].x,t),n=rt(this.m_cp[1].x,this.getEndX(),t),i=rt(e,s,t),r=rt(s,n,t);return rt(i,r,t)}getCoordY(t){if(t<0||t>1){const e=new Q;return this.queryCoord2DExtends(t,e,!0),e.y}const e=rt(this.getStartY(),this.m_cp[0].y,t),s=rt(this.m_cp[0].y,this.m_cp[1].y,t),n=rt(this.m_cp[1].y,this.getEndY(),t),i=rt(e,s,t),r=rt(s,n,t);return rt(i,r,t)}cut(t,e,s){const n=new fm;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=na.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=na.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){vo(this,t,e)}cutBezierIgnoreAttributes(t,s,n){(t<0||s>1||t>s)&&e("Cubic_bezier.cut_bezier_ignore_attributes");const i=lt(Q,4);this.queryControlPoints(i);const r=lt(Q,4);fo(i,t,s,r),n.setControlPoints(r)}splitBezierIgnoreAttributes(t,s,n){this===s&&this===n&&e("Cubic_bezier.split_bezier_ignore_attributes");const i=lt(Q,4);this.queryControlPoints(i);const r=lt(Q,4),o=lt(Q,4);po(i,t,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=na.getInterpolation(e);return Ct(a,n,i,o,na.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return Ro(this,t,H.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const n=[Number.NaN];return 0===Ro(this,t,e,!1,s,1,n)?Number.NaN:n[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,n){t.length<2&&e("");const i=Qr(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;s(t.length>=i.specialPointsCount()-1);for(let e=1,s=i.specialPointsCount();e<s;++e)this.queryCut(i.specialPoints[e-1],i.specialPoints[e],t[r],n),r++;for(let e=0;e<r;++e){lo(t[e].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=lt(Q,4);return this.queryControlPoints(i),Zo(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 n=[0,0],i=this.intersectionWithAxis2D(!0,t,n,null);return s(2!==i),-1===i?e:n[0]}isCurve(){return!0}isDegenerate(t){return Re(this,t)}isDegenerate3D(t,e){return s(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());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=me.constructEmpty();this.queryEnvelope(t);const s=H.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=lt(Q,4);this.queryControlPoints(s),fo(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 Hr(this,t,!0)}lengthToT(t){return Ur(this,t)}calculateWeightedAreaCentroid2D(t){const e=lt(Q,4);Br(this,e);const s=e[3],n=e[2],i=e[1],r=new Q;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=mo(this);return r.x+=(e[0].x-t.x)*o,r.y+=(e[0].y-t.y)*o,r}calculateWeightedCentroid2D(){const t=new Q;return this.isDegenerate(0)?(t.setCoords(0,0),t):zr(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Or(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(t){for(let s=0;s<4;s++)t[s].isNAN()&&e("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=lt(Q,4);return this.queryControlPoints(e),Co(e,t)}getDerivative(t){const e=lt(Q,4);return this.queryControlPoints(e),ao(e,1,t)}getCurvature(t){const e=uo(this,1,t),s=uo(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 me;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new Q;this.queryCoord2D(i,r);return Q.distance(r,t)<=e}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}isMonotoneQuickAndDirty(){const t=lt(Q,4);return this.queryControlPoints(t),go(t)}getMonotonicPartParams(t,n){const i=Qr(this),r=i.specialPointsCount();if(s(us.s_maxMonotonicPartParams>=r),!n)return i.specialPointsCount();t<r&&e("");for(let e=0;e<r;e++)n[e]=i.specialPoints[e];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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(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]=et(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=et(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new at;return io(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=lt(Q,4);this.queryControlPoints(e);const s=e[3].sub(e[0]),n=s.length();if(Q.distance(e[0],e[1])+Q.distance(e[2],e[1])+Q.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=lt(Q,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return mo(this)}absNorm(){return zo(this)}queryEnvelopeW(t,e){qo(this,t,e)}setSegmentFromCoordsForStitcher(t,e){ko(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=lt(Q,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=lt(Q,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if(Q.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);Q.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=lt(Q,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if(Q.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);Q.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 Qo(this,t,e)}ensureXYMonotone(){return lo(this)}setCoordsForIntersector(t,e,s){eo(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,Kr(this))}reverseImpl(){this.m_cp[1]=et(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]=et(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=et(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),to(this,e)}afterCompletedModification(){$r(this)}isIntersecting(t,e,s){return 0!==rm(!1,this,t,e,s)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return Xo(this,t,e,s)}endPointModified(){$r(this)}clearEndPointModified(){}}ia.type=i.enumBezier;class ra{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 oa(t,e,n,i,r,o,a,h){for(;;){const u=Q.distance(e[0],e[2]),m=Q.distance(e[0],e[1])+Q.distance(e[1],e[2]);if(m-u<=r+i*m)return t+rt(u,m,.5);const l=lt(Q,4),c=t=>{fa(e,n,1,t,l);return l[1].length()};if(0===a&&h<8){s(h<8);let u=c(0),l=c(1);o[0]+=2,u>l&&(l=et(u,u=l),e[2]=et(e[0],e[0]=e[2]),n[2]=et(n[0],n[0]=n[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 s=new Q;if(_h(e,n,.5*d,s),_=Q.distance(s,e[0]),_<=r){const t=new Q;_h(e,n,d,t),_+=Q.distance(t,s)}}if(1!==d){const s=lt(Q,3),u=[0,0,0];Oa(e,n,d,e,n,s,u),t=oa(t,s,u,i,r,o,0,h+1),a++,h++;continue}}let g=!1;const d=8;o[0]+=d;const _=hr(d,c,0,1),p=16;o[0]+=p;const f=hr(p,c,0,1);if(g=Math.abs(_-f)>r+i*m,!g)return t+f;if(a<8&&h<9){const s=lt(Q,3),u=[0,0,0];Oa(e,n,.5,e,n,s,u),t=oa(t,s,u,i,r,o,a+1,h+1),a++,h++;continue}const P=32;o[0]+=P;const y=hr(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=hr(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=hr(v,c,0,1);return g=Math.abs(C-b)>r+i*m,t+b}}function aa(t,e,s,n,i){if(s===e)return 0;const r=lt(Q,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=lt(Q,3);Qa(r,o,e,s,h,a);return oa(0,h,a,n,i,[0],0,0)}class ha{constructor(t,e,s){this.controlPoints=ct(t,3),this.weights=[0,0,0],J(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new Q;_h(this.controlPoints,this.weights,e,t);const s=lt(Q,4);fa(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new Q;_h(this.controlPoints,this.weights,e,t);const s=lt(Q,4);fa(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 Q;_h(this.controlPoints,this.weights,e,t);const s=lt(Q,4);fa(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 s(0),0}}function ua(t,e,s,n){const i=Ba(0,0,0,0,Q.getNAN()),r=U(18,Number.NaN),o=lt(Q,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,fh(a),1],u=yh(a,s),m=yh(a,n),l=tn(new ha(o,h,new Q(0,0)),H.construct(u,m),18,r);_h(o,h,u,i.pt),i.t=u,i.d=Q.distance(i.pt,new Q(0,0));const c=new Q;_h(o,h,m,c);const g=Q.distance(c,new Q(0,0));g<i.d&&(i.d=g,i.t=m,i.pt.assign(c));for(let d=0;d<l;d++){_h(o,h,r[d],c);const t=Q.distance(c,new Q(0,0));t<i.d&&(i.d=t,i.t=Ph(a,r[d]),i.pt.assign(c))}return i}function ma(t,e,s,n,i){let r=!0;const o=lt(Q,4),a=Kn(5,e,s,n,i,e=>{pa(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=>{pa(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()});return new Q(a,h)}function la(t){t.m_cachedValues=null}function ca(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function ga(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ra,s=lt(Q,3);t.queryControlPoints(s);const n=[0,0,0];return t.queryWeights(n),da(s,n,e.specialPoints),La(t,e),e}function da(t,e,s){if(0===e[1])return s.length=0,s.push(0),void s.push(1);const n=lt(at,8);n[0].set(0);let i=1;{const s=new at(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new at(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new at(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=lt(at,2);let h=gn(o,r,s,new H(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)gt(a[t].value(),0,1)||(n[i]=a[t],i++)}{const s=new at(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new at(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new at(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=lt(at,2);let h=gn(o,r,s,new H(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)gt(a[t].value(),0,1)||(n[i]=a[t],i++)}if(n[i].set(1),i++,i>2){tt(n,0,i,(t,e)=>Bt(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 _a(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+_a(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=ga(t);if(n&&!Number.isNaN(i.length))return i.length;const r=Xa(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+=aa(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function pa(t,e,s,n){const i=lt(Q,3);t.queryControlPoints(i);const r=[0,0,0];t.queryWeights(r),fa(i,r,e,s,n)}function fa(t,e,s,n,i){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=lt(Q,4);Pa(r,o,s,n,a);for(let h=0;h<=s;h++)i[h].setCoords(a[h].x,a[h].y)}function Pa(t,e,n,i,r){s(n>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].subThis(o[0]);o[0].setCoords(0,0)}const a=ya(o,e,0,i),u=Ca(e,0,i),m=a.divide(u);if(r[0].assign(m),0===n)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=ya(c,l,0,i).mul(2).divide(g);if(r[1].assign(d),1===n)return;const _=Ca(e,1,i),p=2*u*_,f=ya(c,l,1,i).mul(2).sub(d.mul(p)).divide(g);if(r[2].assign(f),2===n)return;const P=ya(c,l,2,i).mul(2),y=2*(_*_+u*Ca(e,2,i)),x=P.sub(f.mul(p).mul(2)).sub(d.mul(y)).divide(g);r[3].assign(x),3!==n&&h("")}function ya(t,e,s,n){if(0===s){if(n<=.5){const s=new Q;Xt(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new Q;Xt(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new Q;return Xt(2,s,i,n,r),r}{const s=new Q;qt(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new Q;qt(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new Q;return qt(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}h("")}function xa(t,e,s,n){if(n.toDouble()<=.5){const s=new Ye;Ft(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new Ye;Ft(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new Ye;return Ft(2,s,i,n,r),r}{const s=new Ye;Vt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new Ye;Vt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new Ye;return Vt(2,s,i,n,r),r}}function Ca(t,e,s){if(0===e){const e=rt(t[0],t[1],s),n=rt(t[1],t[2],s);return rt(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]))}h("")}function va(t,e,s){if(s.toDouble()<=.5){const e=Ut(t[0],t[1],s),n=Ut(t[1],t[2],s);return Ut(e,n,s)}{const e=Ot(t[0],t[1],s),n=Ot(t[1],t[2],s);return Ot(e,n,s)}}function ba(t,e,s,n,i){const r=[Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);Ea(r,[new at(e[0]),new at(e[1]),new at(e[2])],s,n,i)}function Ea(t,e,n,i,r){s(n>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]=Ye.constructCoords(0,0)}const a=xa(o,e,0,i),h=va(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=xa([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 Sa(t,e,s){const n=lt(Q,3);t.queryControlPoints(n);const i=U(3,Number.NaN);t.queryWeights(i),Da(n,i,e,s)}function Da(t,e,s,n){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const i=lt(Ye,4);ba(t,e,1,s,i),n.setE(i[1])}function wa(t,e,s){const n=_t(s,0,1),i=lt(Q,4);if(fa(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 Aa{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-_a(this.b,e,!1):0}getError(t){return s(0),0}}function Ta(t,e,s){const n=_a(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==tn(new Aa(t,e),H.unit(),1,i)&&h(""),i[0]}function Ia(t){const e=lt(Q,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Ma(e,s)}function Ma(t,e){const n=fh(e);if(1===n){return fi(t)}if(0===n)return 0;const i=[new Q(0,0),t[1].sub(t[0]),t[2].sub(t[0])],r=i[1].crossProduct(i[2]);if(n<1){s(n>0);const t=1-n;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 s=t*(1+n),i=Math.atan2(Math.sqrt(t),Math.sqrt(1+n));e=n*(.5*n-he(s)*i)/s}return r*e}{const t=(n-1)*(n+1);return.25*n/Math.pow(t,1.5)*(-2*n*Math.sqrt(t)*r-4*i[1].y*i[2].x*Math.atanh(Math.sqrt((n-1)/(n+1)))-i[1].x*i[2].y*Math.log(2*n*(n-Math.sqrt(t))-1))}}function Ya(t,e){const n=fh(e);if(1===n){const e=lt(Q,3);zi(t,e);const s=e[2].clone(),n=e[1].clone(),i=new Q,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===n)return new Q(0,0);s(n>0);const i=t[1].sub(t[0]),r=t[2].sub(t[0]);if(n<1){const t=Math.sqrt(1-n),e=Math.sqrt(1+n),s=(i.y*r.x-i.x*r.y)*n/Math.pow(t*e,5)/12,o=Math.atan2(t,e),a=n*t*e,h=n*n,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(s)}{const t=Math.sqrt(n-1),e=Math.sqrt(n+1),s=(i.y*r.x-i.x*r.y)*n/Math.pow(t*e,5)/12,o=Math.atanh(t/e),a=n*t*e,h=n*n,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(s)}}function Na(t){const e=lt(Q,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Ya(e,s)}function Xa(t){return qa(t.calculateUpperLength2D())}function qa(t){return 256*dt()*t}function Fa(t){if(0===t.m_weights[1])return!0;const e=Q.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function Va(t){return t.m_cachedValues}function La(t,e){t.m_cachedValues=e}function Ra(t,e,s,n,i){const r=lt(Q,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===za(r,o,e,H.unit(),n,i,1,a)?a[0]:Number.NaN}function za(t,e,n,i,r,o,a,h){_(H.unit().contains(i)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const u=new Array(3);for(let s=0;s<3;++s)u[s]=t[s].sub(n);const m=fh(e),l=Xe.constructPoint2D(u[0]),c=Xe.constructPoint2D(u[1]),g=Xe.constructPoint2D(u[2]),d=it.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),E=c.sqrLength().mul(d.mul(d).ldexp(2)),S=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(E).addThis(S).addThis(D),A=l.add(g).sub(c.mul(p)),T=d.subDouble(1),I=g.sub(l).dotProduct(A).mul(T),M=new Q(0,0),Y=[];let N=new Q;_h(u,e,i.vmin,N);let X=Q.distance(N,M);if(X<=o&&Y.push(new Q(i.vmin,X)),i.vmin!==i.vmax&&(_h(u,e,i.vmax,N),X=Q.distance(N,M),X<=o&&Y.push(new Q(i.vmax,X))),i.width()>0){const t=u[2].isZero(),s=lt(it,4),n=Rn(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=Ph(e,t);const n=new Q;_h(u,e,t,n),X=Q.distance(n,M),X<=o&&Y.push(new Q(t,X))}}if(r){s(i.equals(H.unit()));{_h(u,e,-1,N,!0);const t=new Q;_h(u,e,0,t);const s=new pm({start:N,end:t}),n=s.getClosestCoordinate(M,!0);n<1&&(N=s.getCoord2D(n),X=Q.distance(N,M),X<=o&&Y.push(new Q(n-1,X)))}{_h(u,e,2,N,!0);const t=new Q;_h(u,e,i.vmax,t);const s=new pm({start:t,end:N}),n=s.getClosestCoordinate(M,!0);n>0&&(N=s.getCoord2D(n),X=Q.distance(N,M),X<=o&&Y.push(new Q(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=Z(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)=>Bt(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 Ba(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function ka(t,e,n,i,r){const o=new De;if(Ga(t,H.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=ga(t);let h=0;const u=[];let m=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const n=a.specialPoints[l],i=ua(t,e,m,n);if(0===u.length)u.push(i);else if(i.t===i.tmin)s(u.at(-1).d<=i.d),u.at(-1).tmax=i.tmax;else if(u.at(-1).t===u.at(-1).tmax){s(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=n}for(const s of u)if(s.d<=i){const t=s.t;n?(n[h]=t,h++):h++}return h}function Ga(t,e,s){const n=lt(Q,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i),Wa(n,i,e,s)}function Wa(t,e,s,n){if(s.equalsRange(0,1))return void n.setFromPoints(t,3);const i=lt(Q,3),r=[0,0,0];Qa(t,e,s.vmin,s.vmax,i,r),n.setFromPoints(i,3)}function ja(t){const e=nt(t[0].y,t[1].y),s=nt(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=nt(t[0].x,t[1].x),s=nt(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function Za(t){const e=lt(Q,3);t.queryControlPoints(e);const s=Ha(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ha(t){let e=!1;for(let s=0;s<2;s++){const n=nt(t[0][s],t[2][s]);n>0?(nt(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?(nt(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),nt(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 Ua(t,s,n){void 0===n&&(n=s,s=0);const i=new Q;if(s<0||n>1)return i.setNAN(),i;if(s>n&&e("calculate_sub_weighted_centroid"),s===n||t.isDegenerate(0))return i.setCoords(0,0),i;const r=ga(t),o=Xa(t),a=o/t.calculateUpperLength2D();let h=s,u=0;for(let e=1,m=r.specialPointsCount();e<m;e++)if(s<r.specialPoints[e]){u=e-1;break}i.setCoords(0,0);for(let e=u+1,m=r.specialPointsCount();e<m;e++){const s=Math.min(r.specialPoints[e],n),u=ma(t,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}function Oa(t,e,n,i,r,o,a){s(n>=0&&n<=1&&i!==o&&r!==a),s(e[0]>0&&e[2]>0&&e[1]>=0);const h=[1,fh(e),1],u=yh(e,n),m=ct(t,3),l=lt(E,3);uh(m,h,l);const c=lt(E,3),g=lt(E,3);xh(l,u,i?c:null,o?g:null),Ch(e,n,r,a);const d=ja(m);if(i){for(let t=0;t<3;++t)dh(c[t],i[t]);bh(m,i),d&&Ha(i)}if(o){for(let t=0;t<3;++t)dh(g[t],o[t]);bh(m,o),d&&Ha(o)}}function Qa(t,e,n,i,r,o){if(s(n>=0&&i<=1&&n<=i),n===i){const s=new Q,i=mh(t,e,n,s);return vh(t,s),r[0].assign(s),r[1].assign(s),r[2].assign(s),o[0]=i,o[1]=i,void(o[2]=i)}if(0===n&&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=lt(E,3);{const s=[1,fh(e),1],r=yh(e,n),o=yh(e,i);uh(t,s,a),xh(a,o,a,null);xh(a,r>=o?1:r/o,null,a)}const h=[0,0,0];Ch(e,i,h,null),Ch(h,n/i,null,h);const u=ja(t),m=lt(Q,3);dh(a[1],m[1]),_h(t,e,n,m[0]),_h(t,e,i,m[2]),bh(t,m);for(let s=0;s<3;++s)r[s].assign(m[s]),o[s]=h[s];u&&Ha(r)}function Ka(t,e,s){const n=fh(e),i=[1,n,1],r=4*n/(3*(1+n));s[0].assign(t[0]),s[3].assign(t[2]),xt(t[0],t[1],r,s[1]),xt(t[2],t[1],r,s[2]),new ia({cp:s}),new Sn({points:t,weight:n});let o=0,a=.1,h=0;for(let u=0;u<9;u++,a+=.1){const e=new Q;_h(t,i,a,e);const n=new Q;Po(s,a,n);const r=Q.sqrDistance(e,n);r>o&&(o=r,h=a)}{const e=new Q;_h(t,i,h,e);const n=[0];Lo(s,e,H.unit(),!1,-1,1,n);const r=new Q;return Po(s,n[0],r),o=Q.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 le,o=lt(Q,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new Q;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=lt(Q,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):xt(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&Za(t)}function $a(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==nh(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function th(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==ih(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function eh(t,e,s,n,i){if(i){const n=am(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(Le(e,s))return 1;return 0!==rh(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function sh(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==oh(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function nh(t,e,n,i,r,o,a,h,u,m){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),n.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(n.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!=o)for(let t=0;t<s;t++)o.push(0);if(null!=i)for(let n=0;n<s;n++){const s=new Q;e.queryCoord2D(t[n],s),i.push(s)}}return s}const l=rs(e,n);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new pm({start:e.getStartXY(),end:e.getEndXY()}),s=Ds(t,n,i,r,o,a,h,m);if(r)for(let n=0;n<s;++n){const s=t.getCoord2D(r[n]);r[n]=e.getClosestCoordinate(s,!1)}return s}if(os(e,n,a))return 0;const c=lt(Q,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[1,fh(g),1],_=n.getEndXY().sub(n.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],E=d[1],S=d[2],D=b*E,w=b*S,A=E*S,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=U(13,Number.NaN),q=U(13,Number.NaN);let F=sn(N,Y,M,H.unit(),!1,X);F<0&&(X[0]=0,X[1]=1,F=2);let V=0;for(let s=0,k=V;s<F;++s){const t=new Q;_h(c,d,X[s+k],t),q[V]=n.getClosestCoordinate(t,!1);Q.distance(t,n.getCoord2D(q[V]))<=a&&(X[V]=X[s+k],V++)}const L=lt(Q,3),R=lt(Q,3);if(e.queryControlPoints(R),R[0].subThis(n.getStartXY()),R[1].subThis(n.getStartXY()),R[2].subThis(n.getStartXY()),ah(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(n.getStartXY())||e.getEndXY().equals(n.getEndXY()),B=[0,0];F=sn(N,Y,M,H.unit(),z,B);for(let s=0,k=V;s<F;++s){X[s+k]=B[s];const t=new Q;_h(c,d,X[s+k],t),q[V]=n.getClosestCoordinate(t,!1);Q.distance(t,n.getCoord2D(q[V]))<=a&&(X[V]=X[s+k],V++)}s(V<X.length+4);for(let s=0;s<V;s++)X[s]=Ph(g,X[s]);F=e.intersectPoint(n.getStartXY(),B,a);for(let s=0;s<F;s++)X[V]=B[s],q[V++]=0;F=e.intersectPoint(n.getEndXY(),B,a);for(let s=0;s<F;s++)X[V]=B[s],q[V++]=1;F=n.intersectPoint(e.getStartXY(),B,a);for(let s=0;s<F;s++)q[V]=B[s],X[V++]=0;F=n.intersectPoint(e.getEndXY(),B,a);for(let s=0;s<F;s++)q[V]=B[s],X[V++]=1;return 0===V?0:cm(t,e,n,X,q,V,i,r,o,a,h,u,m)}function ih(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return nh(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=lt(Q,4);{e.queryControlPoints(g);const t=lt(Q,4),n=new le;s.canonicToWorldTransformation(n);const i=new le;i.setInvert(n),i.transformPoints2D(g,4,t);const r=lt(it,3),h=lt(it,3),u=lt(it,3),m=[0,0,0];e.queryWeights(m),hh(t,m,r,h,u);const d=lt(it,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 _=qn(r,2,h,2,u,2,d,!0,H.unit(),H.unit(),l,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new Q;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new Q;s.queryCoord2D(r,a);Q.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=Ra(e,t,H.unit(),!1,-1),i=new Q;e.queryCoord2D(n,i);Q.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 Q;s.queryCoord2D(e,n);Q.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return cm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function rh(t,e,n,i,r,o,a,h,u,m){const l=lt(Q,3);e.queryControlPoints(l);const c=lt(Q,3);if(n.queryControlPoints(c),as(l,c,3)<0)return rh(t,n,e,i,o,r,a,h,u,!m);const g=rs(e,n);if(e.isDegenerateToLineHelper(g)){const s=new pm({start:e.getStartXY(),end:e.getEndXY()}),l=nh(t,n,s,i,o,r,a,h,u,!m);if(r)for(let t=0;t<l;++t){const n=s.getCoord2D(r[t]);r[t]=e.getClosestCoordinate(n,!1)}return l}if(n.isDegenerateToLineHelper(g)){const s=new pm({start:n.getStartXY(),end:n.getEndXY()}),l=nh(t,e,s,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=n.getClosestCoordinate(e,!1)}return l}if(os(e,n,a=Math.max(a,g)))return 0;const d=U(3,Number.NaN);e.queryWeights(d);const _=U(3,Number.NaN);n.queryWeights(_);const p=[1,fh(d),1],f=[1,fh(_),1],P=new H(0,1),y=new H(0,1);{const t=De.constructEmpty();Wa(l,p,new H(0,1),t);const e=De.constructEmpty();Wa(c,f,new H(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(ph(l,p,t,P),ph(c,f,t,y),P.isEmpty()||y.isEmpty())return 0;Qa(l,p,P.vmin,P.vmax,l,p),Qa(c,f,y.vmin,y.vmax,c,f)}}const x=dm(l,2,c,2,a);if(0===x)return 0;const C=[],v=[];if(-1===x){const t=lt(it,3),e=lt(it,3),s=lt(it,3);hh(l,p,t,e,s);const n=lt(it,3),i=lt(it,3),r=lt(it,3);hh(c,f,n,i,r);const o=[],g=[],d=Yn(t,2,e,2,s,2,n,2,i,2,r,2,!0,H.unit(),H.unit(),o,g,h,u,m);if(d>0)for(let h=0;h<d;h++){const t=new Q;_h(c,f,g[h],t);const e=new Q;_h(l,p,o[h],e);Q.distance(e,t)<=a&&(C.push(o[h]),v.push(g[h]))}}for(let b=0;b<2;b++){let t,e,n;0===b?(t=l,e=c,n=f):(t=c,e=l,n=p);for(let i=0;i<2;i++){const r=0===i?0:t.length-1,o=new Q,h=[0],u=za(e,n,t[r],H.unit(),!1,-1,1,h);s(1===u),_h(e,n,h[0],o),Q.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 s=0;s<C.length;++s)C[s]=Sn.recalculateParentT(P.vmin,P.vmax,C[s]);if(!y.equalsRange(0,1))for(let s=0;s<v.length;++s)v[s]=Sn.recalculateParentT(y.vmin,y.vmax,v[s]);for(let s=0;s<C.length;++s)C[s]=Ph(d,C[s]);for(let s=0;s<v.length;++s)v[s]=Ph(_,v[s]);return cm(t,e,n,C,v,C.length,i,r,o,a,h,u,m)}function oh(t,e,s,n,i,r,o,a,h,u){if(e.isLine()){return Vi(t,s,new pm({start:e.getStartXY(),end:e.getEndXY()}),n,r,i,o,a,h,!u)}if(s.isLine()){return nh(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=lt(Q,3);e.queryControlPoints(l);const c=lt(Q,3);s.queryControlPoints(c);const g=dm(l,2,c,2,o);if(0===g)return 0;const d=[],_=[];if(-1===g){const t=lt(it,3),n=lt(it,3),i=lt(it,3),r=[0,0,0];e.queryWeights(r),hh(l,r,t,n,i);const m=lt(Xe,3);Wi(c,m);const g=Yn(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,H.unit(),H.unit(),d,_,a,h,u);if(g>0){let t=0;for(let n=0;n<g;n++){const i=new Q;s.queryCoord2D(_[n],i);const r=new Q;e.queryCoord2D(d[n],r),Q.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 Q;0===p?(r=Ci(s,t[i],H.unit(),!1),s.queryCoord2D(r,a)):(r=Ra(e,t[i],H.unit(),!1,-1),e.queryCoord2D(r,a)),Q.distance(t[i],a)<=o&&(0===p?(d.push(0===i?0:1),_.push(r)):(_.push(0===i?0:1),d.push(r)))}}return cm(t,e,s,d,_,d.length,n,i,r,o,a,h,u)}function ah(t,e,s,n=!1){const i=lt(Q,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 hh(t,e,s,n,i){const r=it.constructDouble(e[0]),o=it.constructDouble(e[1]),a=it.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 uh(t,e,s){for(let n=0;n<3;++n)s[n].setCoordsPoint2DZ(t[n].mul(e[n]),e[n])}function mh(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=bt(i[0],i[1],a),e=bt(i[1],i[2],a);h=rt(t,e,a);const s=bt(r[0],r[1],a),n=bt(r[1],r[2],a);u=rt(s,n,a);const l=bt(o[0],o[1],a),c=bt(o[1],o[2],a);m=bt(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),vh(t,n),m}function lh(t,e,s){const n=lt(Q,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i);ch([Ye.constructPoint2D(n[0]),Ye.constructPoint2D(n[1]),Ye.constructPoint2D(n[2])],[new at(i[0]),new at(i[1]),new at(i[2])],e,s)}function ch(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 at,h=new at,u=new at;if(s.value()<=.5){const t=Ut(i[0],i[1],s),e=Ut(i[1],i[2],s);a.setE(Ut(t,e,s));const n=Ut(r[0],r[1],s),m=Ut(r[1],r[2],s);h.setE(Ut(n,m,s));const l=Ut(o[0],o[1],s),c=Ut(o[1],o[2],s);u.setE(Ut(l,c,s))}else{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))}a.divThisE(u),h.divThisE(u);const m=new Q(a.value(),h.value());vh([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 gh(t,e,s,n){const i=s.lte(Rt)?it.lerpLo:it.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 Q(r.divThis(a).value(),o.divThis(a).value());vh(t.map(t=>t.asPoint2D()),h),n.x=it.constructDouble(h.x),n.y=it.constructDouble(h.y)}function dh(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function _h(t,e,s,n,i){if(i){if(s<0){return void _s(new pm({start:t[0],end:t[0].add(wa(t,e,0).getUnitVector())}),s,n)}if(s>1){return void _s(new pm({start:t[2],end:t[2].add(wa(t,e,1).getUnitVector())}),s-1,n)}}mh(t,e,s,n)}function ph(t,e,s,n){n.setEmpty();const i=[];i.push(new H(0,1));const r=.5*Math.max(s.width(),s.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new De;if(Wa(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(H.construct(o.vmin,t)),i.push(H.construct(t,o.vmax))}}}}function fh(t){return t[1]/Math.sqrt(t[0]*t[2])}function Ph(t,e){const s=Math.sqrt(t[2]/t[0]);return e/rt(s,1,e)}function yh(t,e){const s=Math.sqrt(t[0]/t[2]);return e/rt(s,1,e)}function xh(t,e,n,i){s(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;Dt(3,t[0],t[1],e,r),Dt(3,t[1],t[2],e,o),Dt(3,r,o,e,a);const h=t[2].clone();n&&(n[0].assign(t[0]),n[1].assign(r),n[2].assign(a)),i&&(i[0].assign(a),i[1].assign(o),i[2].assign(h))}function Ch(t,e,n,i){const r=[t[0],t[1],t[2]];s(e>=0&&e<=1&&n!==i);const o=rt(r[0],r[1],e),a=rt(r[1],r[2],e),h=rt(o,a,e);n&&(n[0]=r[0],n[1]=o,n[2]=h),i&&(i[0]=h,i[1]=a,i[2]=r[2])}function vh(t,e){const s=H.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=_t(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=_t(e.y,s.vmin,s.vmax)}function bh(t,e){const s=new H;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=_t(e[0].x,s.vmin,s.vmax),e[1].x=_t(e[1].x,s.vmin,s.vmax),e[2].x=_t(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=_t(e[0].y,s.vmin,s.vmax),e[1].y=_t(e[1].y,s.vmin,s.vmax),e[2].y=_t(e[2].y,s.vmin,s.vmax)}const Eh=Jt/180,Sh=180/Jt;function Dh(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=Qt(e,360),e<0&&(e+=360),e)}function wh(t){let e=t;return e=Dh(e),e>180&&(e-=360),e}function Ah(t){return t*Eh}function Th(t){return t*Sh}function Ih(t){const e=kt();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=Qt(s,e),s<0&&(s+=e),s)}function Mh(t){const e=wt();let s=t;return s>-e&&s<=e||(s=Ih(s),s>e&&(s-=kt())),s}function Yh(t,e){return wh(e-t)}var Nh=b;class Xh extends gs{constructor(t){if(void 0===t||vt(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 Q(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new Q(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new Q(0,0),this.m_interior=new Q(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 Q(0,0),this.m_interior=new Q(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 Q(0,0),this.m_interior=new Q(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=Q.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=Q.lerp(t,e,.5);return this.constructCircleCenterAndPoint(n,t,s),this}constructLineEllipticArc(t,e){return bu(this,t,e,1),this}constructLineCircularArc(t,e){return bu(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 Q(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 le;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 le;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 ju(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=Q.calculateCircleCenterFromThreePoints(t,e,s);if(!i.isFinite()||!Number.isFinite(Q.distance(t,i))){const n=Q.distance(t,e),i=Q.distance(t,s);this.constructLineCircularArc(t,n>=i?e:s)}return this.constructCircleCenterAndPoint(i,t,n)}}constructCircularArcThreePoint(t,e,s){const n=new at(t.x),i=new at(e.x),r=new at(s.x),o=new at(t.y),a=new at(e.y),h=new at(s.y),u=new at(.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 bu(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 E=Math.atan2(b,v);v=e.x-x.value(),b=e.y-C.value();const S=Math.atan2(b,v);v=s.x-x.value(),b=s.y-C.value();const D=Math.atan2(b,v);let w=D-2*wt();for(;w<E;)w+=2*wt();let A=S-2*wt();for(;A<w;)A+=2*wt();let T=D+2*wt();for(;T>E;)T-=2*wt();let I,M=S+2*wt();for(;M>T;)M-=2*wt();I=A-E<E-M?A-E:M-E;const Y=new Q(x.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(I)>wt(),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 vu(this,t,e,s,n,i,r,o)}constructEllipticArcEndPointsCenter(t,e,s,n,i,r,o,a){return vu(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=Mh(r),a=Math.cos(o),h=Math.sin(o),u=new Q(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),m=Q.getNAN(),l=Mh(n);m.x=u.x*Math.cos(l),m.y=u.y*Math.sin(l),m.rotateDirect(a,h),m.addThis(s);const c=At(i,kt());let g=c;Math.abs(g)===kt()&&(g=0);const d=Q.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)>wt(),c>0,s)}constructEllipticArcAsNURB(t,s,n,i){(i>=1||i<0)&&e("construct_elliptic_arc_as_NURB: weight"),s.isFinite()||e("construct_elliptic_arc_as_NURB: control_point");return ku([t,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,Hu(this),this.afterCompletedModification(),t!==this&&ss(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 Q.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!Xu(this)}isMajor(){return Fu(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return i.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=me.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=Nh.getComponentCount(e);s<i;s++){const s=this.queryInterval(e,n);t.setIntervalEnvelope(e,n,s)}}}else 2===t.m_EnvelopeType?Ju(this,H.unit(),t):a("3d not impl")}applyTransformation(t){Au(this,t,!1,null,null)}createInstance(){return new Xh}calculateLength2D(){return pu(this,0,1)}queryControlPointsHelper(t){h("")}queryCoord2D(t,e){if(Eu(this))ps(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(Q.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(Q.construct(this.m_XEnd,this.m_YEnd));else{const s=cu(this,t),n=new Q(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){nu(this,t,e)}queryCoord2DMP(t,e){a("")}getCoordX(t){const e=new Q;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new Q;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const n=new fm;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=Q.getNAN();this.queryCoord2D(t,o);const a=Q.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,je(i,o.x,o.y),He(i,a.x,a.y),r)return void Iu(i,fu(this));i.m_startAngle=cu(this,t),i.m_sweepAngle=cu(this,e)-i.m_startAngle,i.m_startAngle=au(i.m_startAngle),qu(i,Math.abs(i.m_sweepAngle)>wt()),n&&i.assignVertexDescription(this.m_description),Hu(i),mu(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=Nh.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=Nh.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){sm(this,t,e)}cutArcIgnoreAttributes(t,e,s){let n=0===t&&1===e;const i=new Q;this.queryCoord2D(t,i);const r=new Q;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,je(s,i.x,i.y),He(s,r.x,r.y),n?Iu(s,fu(this)):(s.m_startAngle=cu(this,t),s.m_sweepAngle=cu(this,e)-s.m_startAngle,s.m_startAngle=au(s.m_startAngle),qu(s,Math.abs(s.m_sweepAngle)>Math.PI),Hu(s),s.afterCompletedModification())}changeEndPoints2D(t,e){yu(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=Nh.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return Ct(r,o,a,i,Nh.getDefaultValue(e))}getClosestCoordinate(t,e){return $u(this,t,H.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return $u(this,t,e,!1)}getYMonotonicParts(t,n=!1){t.length<2&&e("");const i=this.getSemiAxes(),r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),o=r+wt(),a=U(3,Number.NaN);let h=0;if(a[0]=lu(this,r),a[0]>0&&a[0]<1&&h++,a[1]=lu(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,s(t.length>=h);let u=0;for(let e=0;e<h;e++){const s=a[e];this.queryCut(u,s,t[e],n),u=s}return h}getMonotonicParts(t,n){if(t.length<4&&e(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),n&&t[0].get().dropAllAttributes(),1;const i=this.getSemiAxes(),r=U(4,Number.NaN);r[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r[1]=r[0]+wt(),r[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),r[3]=r[2]+wt();const o=U(5,Number.NaN);let a=0;for(let e=0;e<4;e++)o[a]=lu(this,r[e]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;St(o,a),o[a-1]<1&&(o[a]=1,a++),s(t.length>=a);let h=0;for(let e=0;e<a;e++){const s=o[e];this.queryCut(h,s,t[e],n),h=s}return a}intersectionWithAxis2D(t,e,s,n){if(Eu(this)){return new pm({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,n)}let i,r;const o=new at(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 at(a.x).mulThis(this.m_sinr),r=new at(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 at(a.x).mulThis(this.m_cosr),r=new at(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=lt(at,2);let y=gn(m,l,c,H.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 at,e=new at;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=lu(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]=et(x[0],x[0]=x[1])),n&&J(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]=et(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 Re(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new H(0,1),t):a("3d not impl")}clone(t){const e=new Xh;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Eu(this))return 0===e?H.construct(this.getStartX(),this.getEndX()):H.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]=lu(this,t),i[1]=lu(this,n);const r=0===e?H.construct(this.getStartX(),this.getEndX()):H.construct(this.getStartY(),this.getEndY()),o=new Q;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 H(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()<=Tt){let t=Q.lerp(n,i,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*Q.distance(n,i))),e.setCoords(n),e.mergeNe(i),void e.mergeNe(t)}Ju(this,s,e)}tToLength(t){return Eu(this)?t*Q.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Su(this,t)}parametricAngleToT(t){return lu(this,t)}tToParametricAngle(t){return cu(this,t)}lengthToT(t){if(Eu(this)){const e=Q.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 Du(this,t)}calculateWeightedAreaCentroid2D(t){if(Eu(this)){const t=new Q;return t.setCoords(0,0),t}const e=Zu(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 Q;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 Q;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=Q.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 Q;this.queryCoord2D(n,i);return Q.distance(i,t)<=e}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}getTangent(t){if(Eu(this))return this.getEndXY().sub(this.getStartXY());{const e=cu(this,t),s=new Q;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=cu(this,t),s=new Q;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!!Lu(this)&&(Eu(this)?(Ru(this),!1):zu(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 Q(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new Q(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=cu(this,t),s=new Q,n=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),n*Math.cos(e));const i=new Q;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(t,s){const n=U(6,Number.NaN);n[0]=0;let i=1;if(this.isDegenerateToLine())n[1]=1,i=2;else{const t=this.getSemiAxes(),e=U(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]=It());for(let s=0;s<4;s++){const t=lu(this,e[s]);t>0&&t<1&&(n[i]=t,i++)}i>2&&St(n,i),n[i]=1,i++}if(s){t<i&&e("");for(let t=0;t<i;t++)s[t]=n[t]}return i}calculateLowerLength2D(){const t=Q.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=Q.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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(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]=et(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,Mu(t)}calculateArea2DHelper(){return Zu(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=U(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]=lu(this,t),n[1]=lu(this,e),n[2]=lu(this,i),n[3]=lu(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]=lu(this,i),n[5]=lu(this,r),n[6]=lu(this,o),n[7]=lu(this,a)}const i=Q.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){xu(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 h("should not1; be called"),0}ensureXYMonotone(){if(Eu(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return bu(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=lt(Q,3);let e=Bu(this,t);if(Ha(t)){let s=!1;if(0===this.projectionBehavior()){const n=new me;n.setCoords({pt:t[0]}),n.mergeNe(t[2]);const i=new Q;i.setSub(t[2],t[0]),i.leftPerpendicularThis(),i.normalize(),i.scale(Q.distance(t[2],t[0]));const r=Q.lerp(t[2],t[0],.5),o=r.sub(i),a=r.add(i);n.clipLine(o,a);const h=Q.getClosestCoordinate(o,a,t[1],!1);t[1]=Q.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=yt()-Math.abs(.5*Math.atan2(l,c)),s=!0}return ku(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){yu(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,Iu(e,fu(this))}reverseImpl(){Nu(this,!Xu(this)),mu(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&Hu(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(Ah(wh(Th(this.m_rotation-s.m_rotation)))),i=Math.abs(wt()-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=et(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=et(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=et(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=et(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=et(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=et(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=et(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=et(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=et(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=et(e.m_bits,e.m_bits=this.m_bits),Yu(this,e)}afterCompletedModification(){Ru(this),Mu(this)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){if(e.length<2&&n(""),Eu(this)){return new pm({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s)}{const e=Q.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const i=this.getClosestCoordinate(t,!1),r=Q.getNAN();return this.queryCoord2D(i,r),Q.distance(r,t)<=s?gt(i,0,1)&&(this.queryCoord2D(0===i?1:0,r),Q.distance(r,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==rm(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,Mu(this)}clearEndPointModified(){Ru(this)}}function qh(t,e,s){t.isEmpty()&&o(""),f(t);const n=t.getImpl(),i=[];return Lh(n.getPointCount(),i),Rh(Vh(n),i,n.getPointCount(),e)}function Fh(t,e,s,n){const i=[];return Lh(e,i),Rh(t,i,e,s)}function Vh(t){return{at:e=>t.getXY(e)}}function Lh(t,e){e.length=t;for(let s=0;s<e.length;++s)e[s]=s;t>3&&pe(t,e)}function Rh(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=Q.inCircleRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]),s):2===r?l=Q.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]=et(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===Q.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=et(n[0],n[0]=n[2]),o[2]=et(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]=et(o[t],o[t]=o[e]),n[e]=et(n[t],n[t]=n[e]),s=!0);for(let t=0;t<r;t++)e[o[t]]=et(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===r&&1===Q.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=et(n[0],n[0]=n[2]),o[2]=et(o[0],o[0]=o[2]))}u=r}return r}function zh(t,e,s,n,i,r){return new jh(0,0,0,null,!1,K()).densifyEx(t,e,s,n,!1,r)}function Bh(t,s,n,r){return Number.isFinite(s)||e("replace_all_curves_with_beziers: maxDeviation"),Oh(i.enumBezier,t,s,n)}function kh(t,e,n,r,o,h,u,m){h&&(h.length=0),u&&(u.length=0);const l=t.getGeometryType();if(l===i.enumLine)return h&&(h.push(t.getStartXY()),h.push(Q.getNAN()),h.push(Q.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(l===i.enumBezier){if(!r)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=U(9,Number.NaN);let s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Zh(t,n,e),2===s&&o&&(e[1]=.5,e.push(1),s=3),u&&u.splice(0,0,...e.slice(0,s)),h){const n=new fm;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();lo(o),1===i&&h.push(o.getStartXY()),h.push(o.getControlPoint1()),h.push(o.getControlPoint2()),h.push(o.getEndXY())}}return s-1}if(l===i.enumEllipticArc){const i=t;if(i.isDegenerateToLine()||i.isDegenerate(0))return h&&(h.push(t.getStartXY()),h.push(Q.getNAN()),h.push(Q.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(r&&(o||!i.isMonotoneQuickAndDirty())){const a=U(6,Number.NaN);let m=i.getMonotonicPartParams(a.length,a);a.length=m,m=Zh(t,n,a),2===m&&o&&(a[1]=.5,a.push(1),m=3);let l=0;if(m>2){const t=new fm,o=u||[];let c=0;for(let g=1;g<m;g++){const d=a[c],_=a[g];if(i.queryCut(d,_,t,!0),t.get().isDegenerate(0))continue;const p=o.length,f=Qh(1===g,t.get(),e,n,r,h,u);s(f>0),l+=f;const P=g===m-1,y=a[c],x=t.get().getSweepAngle()/i.getSweepAngle();for(let t=p,e=o.length;t<e;t++)if(o[t]=!P||t+1<e?y+o[t]*x:1,h){const e=3*t,s=i.getCoord2D(o[t]);if(h[e].setCoordsPoint2D(s),e>0){co(h.slice(e-3))}}c=g}return l}}return Qh(!0,i,e,n,r,h,u)}if(l===i.enumRationalBezier2){const s=t;if(r&&(o||!s.isMonotoneQuickAndDirty())){const i=U(6,Number.NaN);let r=s.getMonotonicPartParams(i.length,i);i.length=r,r=Zh(t,n,i),2===r&&o&&(i[1]=.5,i.push(1),r=3);let a=0;if(r>2){const t=new fm,o=u||[];for(let m=1;m<r;m++){const l=i[m-1],c=i[m];s.queryCut(l,c,t,!0);const g=o.length;a+=Jh(1===m,t.get(),e,n,!1,h,u);const d=m===r-1,_=i[m-1];for(let t=g,e=o.length;t<e;t++)if(o[t]=!d||t+1<e?_+o[t]:1,h){const e=3*t,n=s.getCoord2D(o[t]);if(h[e].setCoordsPoint2D(n),e>0){Ai(h.slice(e-3))}}}return a}}return Jh(!0,s,e,n,r,h,u)}if(l===i.enumBezier2){const s=t,i=lt(Q,3);s.queryControlPoints(i);const a=new ia;a.constructFromQuadratic(i);const m=kh(a,e,n,r,o,h,u);if(null!=h&&null!=u){const t=3;for(let e=1,n=0;e<m;++e,n+=t){const i=new Q;s.queryCoord2D(u[e],i);const o=h[n+t];if(!i.equals(o)&&(h[n+t].setCoordsPoint2D(i),r)){co(h.slice(n,n+4))}}}return m}a("")}function Gh(t,e,s,n,r,o,h,u){o&&(o.length=0),h&&(h.length=0);const m=t.getGeometryType();if(m===i.enumLine)return o&&(o.push(t.getStartXY()),o.push(Q.getNAN()),o.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(m===i.enumBezier2){const e=U(9,Number.NaN);let n=t.getMonotonicPartParams(e.length,e);if(e.length=n,n=Zh(t,s,e),h&&h.splice(0,0,...e.slice(0,n)),o){const s=new fm;for(let i=1;i<n;i++){const n=e[i-1],r=e[i];t.queryCut(n,r,s,!0);const a=s.get();wi(a),1===i&&o.push(a.getStartXY()),o.push(a.getControlPoint1()),o.push(a.getEndXY())}}return n-1}if(m===i.enumEllipticArc){const i=t;if(i.isDegenerateToLine()||i.isDegenerate(0))return o&&(o.push(t.getStartXY()),o.push(Q.getNAN()),o.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(!i.isMonotoneQuickAndDirty()){const n=U(6,Number.NaN);let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=Zh(t,s,n);let a=0;if(r>2){const t=new fm,u=h||[];for(let m=1;m<r;m++){const l=n[m-1],c=n[m];i.queryCut(l,c,t,!0);const g=u.length;a+=$h(1===m,t.get(),e,s,!1,o,h);const d=m===r-1,_=n[m-1],p=t.get().getSweepAngle()/i.getSweepAngle();for(let t=g,e=u.length;t<e;t++)if(u[t]=!d||t+1<e?_+u[t]*p:1,o){const e=2*t,s=i.getCoord2D(u[t]);if(o[e].setCoordsPoint2D(s),e>0){Ai(o.slice(e-2))}}}return a}}return Qh(!0,i,e,s,n,o,h)}if(m===i.enumBezier){const i=t;if(!i.isMonotoneQuickAndDirty()){const n=U(6,Number.NaN);let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=Zh(t,s,n);let a=0;if(r>2){const t=new fm,u=h||[];for(let m=1;m<r;m++){const l=n[m-1],c=n[m];i.queryCut(l,c,t,!0);const g=u.length;a+=tu(1===m,t.get(),e,s,!1,o,h);const d=m===r-1,_=n[m-1];for(let t=g,e=u.length;t<e;t++)if(u[t]=!d||t+1<e?_+u[t]:1,o){const e=2*t,s=i.getCoord2D(u[t]);if(o[e].setCoordsPoint2D(s),e>0){Ai(o.slice(e-2))}}}return a}}return tu(!0,i,e,s,n,o,h)}if(m===i.enumRationalBezier2){const i=t;if(!i.isMonotoneQuickAndDirty()){const n=U(6,Number.NaN);let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=Zh(t,s,n);let a=0;if(r>2){const t=new fm,u=h||[];for(let m=1;m<r;m++){const l=n[m-1],c=n[m];i.queryCut(l,c,t,!0);const g=u.length;a+=Kh(1===m,t.get(),e,s,!1,o,h);const d=m===r-1,_=n[m-1];for(let t=g,e=u.length;t<e;t++)if(u[t]=!d||t+1<e?_+u[t]:1,o){const e=2*t,s=i.getCoord2D(u[t]);if(o[e].setCoordsPoint2D(s),e>0){Ai(o.slice(e-2))}}}return a}}return Kh(!0,i,e,s,n,o,h)}a("")}function Wh(t,e,n,r,o,a,h,u,m){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),u&&(u.length=0),l===i.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(Q.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=U(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Zh(t,n,c);else{if(g=2,c[0]=0,c[1]=1,l===Xh.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 s(l===Sn.type);c.length=g}if(2===g&&r&&(c[1]=.5,c.push(1),g=3),a){const e=new fm;let s=1;for(;s<g;){const n=c[s-1],r=c[s];t.queryCut(n,r,e,!0);const u=lt(Q,3),m=[1,1,1];if(l===i.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(r-n)/3;c.splice(s,0,n+t),c.splice(s+1,0,n+2*t),g+=2;continue}m[1]=Bu(t,u)}else{const t=e.get();t.queryControlPoints(u),t.queryWeights(m)}o&&Ha(u),1===s&&(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]),s++}}return u&&(u.length=g,J(u,c,0,0,g)),g-1}Xh.type=i.enumEllipticArc;class jh{static constructDefault(t){return new jh(0,0,0,t,!1,K())}constructor(t,e,s,n,i,r){this.m_segmentBuffer=null,this.m_dummyPoint=new q,this.m_progressCounter=0,this.m_progressTracker=n,this.m_bSetDensifyFlag=i,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>yt()?yt():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>yt()?yt():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 e=t.getGeometryType();return p(e)?t:c(e)?this.densifyMultiPath(t):m(e)?this.densifySegmentImpl(t):e===i.enumEnvelope?this.densifyEnvelope(t):void h("")}densifySegmentEx(t,e,s,n,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==i.enumLine)&&(!n||s))return void(e?o===i.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===i.enumBezier)return void this.densifyCubicBezier(t,e,s,n,r);if(o===i.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,n,r);if(o===i.enumBezier2)return void this.densifyBezier2(t,e,s,n,r);if(o===i.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,n,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,e,s,n,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();if(e.getGeometryType()===i.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const n=s.nextSegment(),i=s.isClosingSegment();this.densifySegmentEx(n,e,t,i,null),i&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new Os({vd:t.getDescription()}),s=[0];return this.densifySegmentEx(t,e,!0,!1,s),e}densifyEnvelope(t){const e=new ur({vd:t.getDescription()});e.addEnvelope(t,!1);const s=me.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 e=t.createInstance();if(e.getGeometryType()===i.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=e.getImpl(),n=t.getImpl(),r=n.getAttributeStreamRef(0),o=new pm;for(let i=0,a=n.getPathCount();i<a;i++){const t=n.isClosedPath(i);if(0===n.getPathSize(i))continue;const a=n.getPathStart(i),h=r.readPoint2D(2*a),u=h.clone();s.startPath(h);for(let m=a+1,l=n.getPathEnd(i);m<l;m++){const t=r.readPoint2D(2*m),n=Q.distance(u,t);if(n>this.m_maxLength){let e=Math.ceil(n/this.m_maxLength);e>K()&&(e=K());const i=1/e;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=e-2,a=-1);for(let t=0,n=e-1;t<n;t++,r+=a){this.progress_(),h=i*(r+1);const t=new Q;o.queryCoord2D(h,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),u.assign(t)}if(t){const t=Q.distance(u,h);if(t>this.m_maxLength){const e=h;let n=Math.ceil(t/this.m_maxLength);n>K()&&(n=K());const i=1/n;let r,a;u.compare(e)<0?(o.setStartXY(u),o.setEndXY(e),r=0,a=1):(o.setStartXY(e),o.setEndXY(u),r=n-2,a=-1);const m=new Q(0,0);let l;for(let t=0,h=n-1;t<h;t++,r+=a)this.progress_(),l=i*(r+1),o.queryCoord2D(l,m),s.lineTo(m),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(t,e,n,r,o,h){s(t.getGeometryType()!==i.enumBezier);let u=t.getStartXY().compare(t.getEndXY());if(0===u&&e<1){t.getGeometryType()===i.enumEllipticArc?u=t.getSweepAngle()<0?1:-1:a("densify segment by length")}let m=0;if(r&&(n?(t.queryStart(this.m_dummyPoint),n.startPathPoint(this.m_dummyPoint)):h.push(0),++m),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||(this.m_segmentBuffer=new fm);let s=Math.ceil(1/e);s>K()&&(s=K()),e=1/s,this.m_segmentBuffer.create(t.getGeometryType());let i,r,o,a=t;u<0?(i=0,r=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),i=s-2,r=-1,a=this.m_segmentBuffer.get());const l=s-1;for(let t=0;t<l;t++,i+=r)o=e*(i+1),n?(a.queryCoord(o,this.m_dummyPoint),n.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==o&&0!==o&&n.setAttribute(10,n.getPointCount()-1,0,1)):h.push(u>0?1-o:o),this.progress_();o=1,m+=l}(!o||o&&r&&m<2)&&(n?(t.queryEnd(this.m_dummyPoint),n.lineToPoint(this.m_dummyPoint)):h.push(1))}densifyCubicBezier(t,e,s,n,i){const r=new ia;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());if(0===h&&a>0){const e=lt(Q,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 Q(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 Q(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 Q(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 Q(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 Sn;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 Sn,c=[],g=[];for(c.push(new H(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 H(e,t.vmax))):(c.at(-1).vmin=e,c.push(new H(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 wn;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 wn,c=[],g=[];for(c.push(new H(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 H(e,t.vmax))):(c.at(-1).vmin=e,c.push(new H(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 Xh;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 Xh,c=[],g=[];for(c.push(new H(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 H(e,t.vmax))):(c.at(-1).vmin=e,c.push(new H(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,e){const s=t.calculateUpperLength2D();if(!t.isCurve())return s?e/s:1;if(t.getGeometryType()===i.enumEllipticArc){const n=t;if(n.isCircular()||n.isDegenerate(0)||n.isDegenerateToLine()){let t=e/s;return t<this.m_minStep&&(t=this.m_minStep),t}return e/s*n.getSemiAxes().y/n.getSemiAxes().x}t.getGeometryType()===i.enumBezier&&a(""),a("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.enumEllipticArc){const s=t;if(s.isDegenerate(0)||s.isDegenerateToLine())return 1;{const n=s.getSemiMajorAxis(),i=1-e/n;let r=Math.PI/2;if(i>0){const t=4*Math.sqrt(e/n*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*n;return this.calculateLengthSubdivisionStep(t,o)}}a("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.enumEllipticArc){const s=t;return s.isDegenerate(0)||s.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*s.getSemiMinorAxis())}a("")}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=lt(Q,3);e.queryControlPoints(r);const o=[0,0,0];return e.queryWeights(o),!i&&this.m_maxDeviation>0&&(i=!jh.checkRationalBezier2MaxDeviation(r,o,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!jh.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=lt(Q,3);return e.queryControlPoints(r),!i&&this.m_maxDeviation>0&&(i=!jh.checkBezier2MaxDeviation(r,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!jh.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=!jh.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!jh.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),i}bezierNeedsSplit(t){let e=!1;if(this.m_maxLength>0){if(Q.distance(t[0],t[1])+Q.distance(t[1],t[2])+Q.distance(t[2],t[3])>this.m_maxLength)return e=!0,!0}return!e&&this.m_maxDeviation>0&&(e=!jh.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!jh.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 Q;Po(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===tm(t,s,n)){const s=t.getCoord2D(n[0]),i=Q.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),r=new Q;xt(t.getStartXY(),t.getEndXY(),i,r);return Q.distance(s,r)<=e}}const s=t.getCoord2D(.5),n=new Q;xt(t.getEndXY(),t.getStartXY(),.5,n);return Q.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,e){return t.getGeometryType()===e&&(e!==i.enumEllipticArc||t.isCircular())}}function Zh(t,e,s){const n=s.length;if(e<=0||n<=2)return n;let i=0;const r=U(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 Hh(t,e,s,n,i){const r=[],o=[],a=kh(e,s,0,n,!1,r,o),h=new ia;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new q,g=new pm;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 Uh(t,e,s,n,i){const r=[],o=[],a=Gh(e,s,0,n,!1,r,o),h=new wn;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new q,g=new pm;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 Oh(t,e,n,r,o){s(t===i.enumBezier||t===i.enumEllipticArc||t===i.enumBezier2);const a=e.createInstance();a.getGeometryType()===i.enumPolygon&&a.setFillRule(e.getFillRule());const u=e.querySegmentIterator();for(let m=0,l=e.getPathCount();m<l;++m){if(!e.hasNonLinearSegmentsPath(m)){a.addPath(e,m,!0);continue}const o=e.getPathStart(m);let l=!0,c=0;for(u.resetToPath(m),s(u.nextPath());u.hasNextSegment();){const s=u.nextCurve();if(!s)break;{const g=u.getStartPointIndex()-o,d=g-c;d>0&&(a.addSegmentsFromPath(e,m,c,d,l),l=!1),c=g+1,t===i.enumBezier?Hh(a,s,n,r,l):t===i.enumBezier2?Uh(a,s,n,r,l):h(""),l=!1}}const g=e.getSegmentCountPath(m);g-c!==0&&a.addSegmentsFromPath(e,m,c,g-c,l)}return a}function Qh(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(Q.getNAN()),e.push(Q.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 le;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=me.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=Ih(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 E=4/3*Math.tan(Math.abs(x)/4);p>0&&(E=-E),o&&t&&o.push(0);const S=x/Math.abs(p);let D=(v-C)/p;const w=m.clone(),A=new Q;h.queryCoord2D(0,A);const T=A.clone(),I=1-.01*S;let M=0,Y=0;for(;D<1;){let s;if(D+=S,Y>0&&D<I)s=E;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 Q;g.queryTransform(A,a);const u=e.getClosestCoordinate(a,!1);if(e.queryCoord2D(u,a),1!==D&&(Q.distance(w,a)<=2*n||Q.distance(a,l)<=2*n))continue;w.setCoordsPoint2D(a);const c=lt(Q,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&&co(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 me;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=lt(Q,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=U(9,Number.NaN);let p=e.getMonotonicPartParams(_.length,_);_.length=p,p=Zh(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=lt(Q,3);Qa(c,g,t,e,s,[0,0,0]);const n=lt(Q,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 Jh(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new me;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=lt(Q,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=U(9,Number.NaN);let p=0;i?(p=e.getMonotonicPartParams(_.length,_),_.length=p,p=Zh(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=lt(Q,3),n=[0,0,0];Qa(c,g,t,e,s,n);const i=lt(Q,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 $h(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(Q.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 le;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 _=me.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 E=Math.tan(Math.abs(y)/2);x>0&&(E=-E),o&&t&&o.push(0);const S=new Q;h.queryCoord2D(0,S);for(let D=0;D<v;D++){const e=S.clone(),s=(D+1)*b;if(o&&o.push(s),!r)continue;h.queryCoord2D(s,S);const n=lt(Q,3);n[0].assign(e),n[2].assign(S),n[1].rightPerpendicularOther(n[0]),n[1].mulThis(E),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 tu(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new me;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=lt(Q,4);e.queryControlPoints(c);const g=[],d=U(9,Number.NaN);let _=e.getMonotonicPartParams(d.length,d);d.length=_,_=Zh(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=lt(Q,4);fo(c,t,e,s);const n=lt(Q,3),i=Qi(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 eu(){return{e2:0,completeE:0}}class su{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?Q.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function nu(t,e,s){if(Eu(t)){return void Cs(new pm({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 at;gu(t,e,n);const i=new at,r=new at;at.st_cosAndSin(n,i,r);const o=Ye.constructCoordsE(new at(t.m_semiMajorAxis).mulThisE(i),new at(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(r)),a=new at(t.m_rotation);at.st_cosAndSin(a,i,r),o.rotateDirect(i,r),o.addThisE(Ye.constructPoint2D(t.m_center)),s.setE(o)}}function iu(t,e){return t.convertToCanonic(e)}function ru(t,e){const s=new H(t.getStartAngle(),t.getEndAngle());s.normalize();const n=kt(),i=Qt(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 ou(t,e,s,n){let i=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;i>wt();)i-=2*wt();for(;i<=-wt();)i+=2*wt();if(!Number.isNaN(e)){for(;e>wt();)e-=2*wt();for(;e<=-wt();)e+=2*wt();!s&&e>i&&(e-=2*wt()),s&&e<i&&(e+=2*wt()),r=e-i,Math.abs(r)<o&&!n&&(r=s?2*wt():-2*wt()),Math.abs(r)>2*wt()-o&&n&&(r=0)}Math.abs(r)>2*wt()-o&&(r=r>=0?2*wt():-2*wt(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),n=Math.abs(r)<=wt(),r&&(s=r>0),t.m_startAngle=au(i),t.m_sweepAngle=r,qu(t,!n),Nu(t,s)}function au(t){let e=t,s=!1;return e<=-wt()?(e+=kt(),s=!0):e>wt()&&(e-=kt(),s=!0),e<=-wt()?(e=Qt(e,kt()),e<=-wt()&&(e+=kt()),s=!0):e>wt()&&(e=Qt(e,kt()),e>wt()&&(e-=kt()),s=!0),s&&(e>wt()||e<=-wt())&&(e=wt()),e}function hu(t,e,s){const n=s,i=n.getSemiAxes();let r=new Q(i.x*Math.cos(t[0]),i.y*Math.sin(t[0]));return r=n.convertFromCanonic(r),Q.sqrDistance(r,n.getStartXY())}function uu(t,e,s){const n=s,i=n.getSemiAxes(),r=t[0]+n.getStartAngle();let o=new Q(i.x*Math.cos(r),i.y*Math.sin(r));return o=n.convertFromCanonic(o),Q.sqrDistance(o,n.getEndXY())}function mu(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=Fu(t),r=Xu(t),o=t.projectionBehavior();if(n){const s=t.convertToCanonic(e),n=new Q(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=n.x,s.y/=n.y,t.m_startAngle=au(Math.atan2(s.y,s.x)),t.m_sweepAngle=i?r?kt():-kt():0}else{const n=t.convertToCanonic(e),a=new Q(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=Q.calculateAngle(n,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=kt()):t.m_sweepAngle>0&&(t.m_sweepAngle-=kt()),t.m_startAngle=au(t.m_startAngle);let u=hu([t.m_startAngle],1,t);if(u=Math.sqrt(u),u>.25*is(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,n=[0];rn(hu,t,1,[t.m_startAngle],[e],[s],1e-14,n),t.m_startAngle=au(n[0])}if(u=uu([t.m_sweepAngle],1,t),u=Math.sqrt(u),u>.25*is(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,n=[0];rn(uu,t,1,[t.m_sweepAngle],[e],[s],1e-14,n),t.m_sweepAngle=n[0]}const m=Math.abs(t.m_sweepAngle)>wt();if(qu(t,m),i!==m&&!i&&Math.abs(t.m_sweepAngle)>1.5*wt())return void bu(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void bu(t,e,s,o)}}function lu(t,e){return(ru(t,e)-t.getStartAngle())/t.getSweepAngle()}function cu(t,e){return t.m_startAngle+e*t.m_sweepAngle}function gu(t,e,s){s.assign(new at(t.m_startAngle).addE(e.mulE(new at(t.m_sweepAngle))))}function du(t,e){const s=new at(t.m_cosr).sqrThis(),n=new at(t.m_sinr).sqrThis(),i=new at(t.m_minorMajorRatio),r=new at(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 at(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function _u(t,e){const s=new Ne;s.a11.setE(t[0]),s.a12=at.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const n=[Q.getNAN(),Q.getNAN()],i=[new at,new at];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 pu(t,e,s){if(Eu(t))return(s-e)*Q.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const n=Su(t,e);return Su(t,s)-n}function fu(t){return t.m_cachedValues}function Pu(t){if(t.m_cachedValues)return t.m_cachedValues;const e=eu();return e.e2=Cu(t),e.completeE=Kt(e.e2),t.m_cachedValues=e,e}function yu(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,Hu(t),void t.afterCompletedModification();if(n&&Math.abs(t.getSweepAngle())<=1.01*yt()){const n=lt(Q,3),i=Bu(t,n);if(ja(n)){n[0].assign(e),n[2].assign(s),Ha(n);if(0===t.projectionBehavior()){let e=0,s=2;Q.sqrDistance(n[1],n[0])<Q.sqrDistance(n[1],n[2])&&(s=et(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 Q;xt(n[e],n[s],.5,m);const l=.5*r/u*_t(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 ku(n,i*i,null,!1,t);return}}0===t.projectionBehavior()?nm(t,e,s):im(t,e,s)}}function xu(t,e,s){const n=0===t.projectionBehavior();if(s<=2)return void bu(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 Q;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=lt(Xh,4),c=U(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]+=Q.sqrDistance(l[d].getCoord2D(s),e[n]),t++}c[d]/=t,c[d]<c[g]&&(g=d)}t.assignCopy(l[g])}function Cu(t){return 1-zt(t.m_minorMajorRatio)}function vu(t,e,s,n,i,r,o,a,h){return t.m_bits=0,t.m_rotation=r,We(t,e),Ze(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),qu(t,o),Nu(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,zu(t,void 0===h)}function bu(t,e,s,n){t.m_bits=0,t.m_rotation=0,We(t,e),Ze(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,qu(t,!1),Nu(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 Su(t,e){if(0===e)return 0;const s=Pu(t),n=cu(t,e),i=yt(),r=wu(t),o=Wt(n+i,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function Du(t,e){if(Eu(t)){const s=Q.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=Pu(t),i=yt(),r=wu(t);s<0&&(e=-e);const o=e/t.m_semiMajorAxis+r;let a=jt(o,n.e2,n.completeE);a-=i,a-=t.getStartAngle();return a/s}function wu(t){const e=Pu(t);return Wt(t.getStartAngle()+yt(),e.e2,e.completeE)}function Au(t,e,n,i,r){if(2===e.m_TransformationType)return void s(0);if(s(!Lu(t)),e.isIdentity()&&(!i||i.equals(t.getStartXY())&&r.equals(t.getEndXY())))return;Mu(t);let o=Q.getNAN(),a=Q.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),n||e.isUniformNoRotation()){let s=Xu(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 Tu(t,o,a,h,s,!1)}const n=new Q(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);du(t,s);const n=new Ne;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 Ne;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=lt(at,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=Q.getNAN(),r=_u(n,i);let m=Xu(t);return e.isReflective()&&(m=!m),void t.constructEllipticArcEndPointsCenter(o,a,i.x,i.y/i.x,r,t.isMajor(),m,h)}}}}const s=[Q.getNAN(),Q.getNAN(),Q.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]=et(s[0],s[0]=s[2]));const i=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(n=!n);const r=new Q(0,0),u=t.createInstance();ku(s,i,r,!1,u),t.constructEllipticArcEndPointsCenter(o,a,u.getSemiMajorAxis(),u.getMinorMajorRatio(),u.getAxisXRotation(),t.isMajor(),!n,h)}}function Tu(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);ou(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 Iu(t,e){t.m_cachedValues=e}function Mu(t){t.m_cachedValues=null}function Yu(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function Nu(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function Xu(t){return!!(1&t.m_bits)}function qu(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function Fu(t){return!!(2&t.m_bits)}function Vu(t){if(t.m_center.isNAN())return!1;const e=8,s=new Ye;s.setWithEps(t.getStartXY(),e),s.subThisE((new Ye).setWithEps(t.m_center,e));const n=new at;n.setWithEps(t.m_rotation,e);const i=new at,r=new at;at.st_cosAndSin(n,i,r),s.rotateReverse(i,r);const o=new Ye;o.setWithEps(t.getEndXY()),o.subThisE(Ye.constructPoint2D(t.m_center)),o.rotateReverse(i,r);const a=new at;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),u=new at;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(ht),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(ht);return!m.isZero()||!l.isZero()}function Lu(t){return!!(8&t.m_bits)}function Ru(t){t.m_bits&=-9}function zu(t,e){Ru(t);const n=t.getStartXY(),i=t.getEndXY();let r=!1;const o=Fu(t),a=Xu(t),h=t.projectionBehavior(),u=n.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 bu(t,n,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 Q(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(s(l.y>0&&l.x>=l.y),u){const e=t.convertToCanonic(n);s(!l.isZero()),e.x/=l.x,e.y/=l.y;const i=Math.sqrt(zt(e.x)+zt(e.y));if(r=1!==i,t.m_semiMajorAxis*=i,l.mulThis(i),t.m_startAngle=au(Math.atan2(e.y,e.x)),!o)return t.m_interior.assign(n),t.m_sweepAngle=0,t.afterCompletedModification(),r;t.m_sweepAngle=a?kt():-kt()}else{let e=t.m_center.isNAN()||Vu(t);if(!e){const s=t.convertToCanonic(n);s.x/=l.x,s.y/=l.y;const r=new Q(1,0);t.m_startAngle=Q.calculateAngle(r,s);const o=t.convertToCanonic(i);o.x/=l.x,o.y/=l.y,t.m_sweepAngle=Q.calculateAngle(s,o),e=!Wu(t)}if(e){r=!0;const e=n.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let s=zt(e.x/l.x)+zt(e.y/l.y);s>1&&(s=Math.sqrt(s),t.m_semiMajorAxis*=s,l.mulThis(s));const h=new Q(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 Q(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(n.add(i).mulThis(.5)),t.m_center.assign(e)}}if(mu(t),!Wu(t))return bu(t,n,i,h),!0}return Hu(t),t.afterCompletedModification(),r}function Bu(t,e){s(Math.abs(t.getSweepAngle())<15*Math.PI/16);const n=t.getSemiMajorAxis(),i=t.getSemiMinorAxis();let r;if(0===n)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]=Q.lerp(e[0],e[2],.5),r=1,r;const o=t.getSweepAngle(),a=t.getStartAngle(),h=a+o,u=new Q(-n*Math.sin(a),i*Math.cos(a)),m=new Q(-n*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 ku(t,e,n,i,r){if(i){const s=.5,n=Math.sqrt(e),i=zt(1-s)+2*n*s*(1-s)+zt(s),o=t[0].mul(zt(1-s)).add(t[1].mul(2*n*s*(1-s))).add(t[2].mul(zt(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;s(m<=1),s(m>0);const l=.5/(1-m),c=o.sqrLength(),g=u,d=a.sqrLength(),_=zt(h),p=o.sub(a).sqrLength();if(0===_)return bu(r,t[0],t[2],1),!1;if(u<=-Math.sqrt(c)*Math.sqrt(d))return bu(r,t[0],t[2],1),!1;const f=[0,0],P=new H;P.setInfinite();const y=sn(2*_,-(p/m+4*g),2*(1-m)/m,P,!1,f);if(0===y)return bu(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],E=v-c*f[0];Math.abs(b)>Math.abs(E)?E=g*f[0]-v+1:b=g*f[0]-v+1;const S=o.mul(b).add(a.mul(E)),D=S.norm(1)<1e-15*x?0:Math.atan2(S.y,S.x)+Math.PI,w=o.add(a),A=n?n.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 Xh;return r.constructEllipticArcEndPointsCenter(t[0],t[2],x,C/x,D,Y,!M,A)}function Gu(t,e,s,n,i){return ku(t,e,s,n,i)}function Wu(t){const e=is(t);let s=!1;{const n=new Q(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=Q.distance(t.getStartXY(),n)>e}let n=!1;if(!s){const s=new Q(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=Q.distance(t.getEndXY(),s)>e}return!s&&!n}function ju(t,s,n,i){0===n&&e("construct_enclosing_circle");const r=[0,0,0],o=Fh(s,n,r);if(1===o)t.constructCircleRadius(0,s[r[0]],i);else if(2===o){const e=Q.lerp(s[r[0]],s[r[1]],.5),n=Q.distance(s[r[0]],e),o=Q.distance(s[r[1]],e);t.constructCircleRadius(Math.max(n,o),e,i)}else if(3===o){const e=Q.calculateCircleCenterFromThreePoints(s[r[0]],s[r[1]],s[r[2]]),n=Q.distance(s[r[0]],e),o=Q.distance(s[r[1]],e),a=Q.distance(s[r[2]],e);t.constructCircleRadius(Math.max(n,o,a),e,i)}else h("unexpected")}function Zu(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 Hu(t){t.queryCoord2D(.5,t.m_interior)}function Uu(t,e,s,n,i){if(i){if(0!==am(e,s))return 2}else if(Le(e,s))return 1;return 0!==Qu(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Ou(t,e,s,n,i){if(i){if(0!==am(e,s))return 2}else if(Le(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,n,i,r,o,a,h,u,m){if(Eu(e)){return Ds(new pm({start:e.getStartXY(),end:e.getEndXY()}),n,i,r,o,a,h,m)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0);const l=rs(e,n);if(os(e,n,a=Math.max(l,a)))return 0;const c=n.getStartXY();c.subThis(e.m_center);const g=n.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=U(16,Number.NaN),v=U(16,Number.NaN);let b=0;const E=[x,x+Math.PI];for(let s=0;s<2;++s){const t=lu(e,E[s]);if(t>=0&&t<=1){C[b]=t;const s=e.getCoord2D(C[b]);v[b]=n.getClosestCoordinate(s,!1),Q.distance(s,n.getCoord2D(v[b]))<=a&&b++}}const S=c.x*p,D=c.y*P,w=d.x*p,A=d.y*P;let T=sn(w*w+A*A,2*(S*w+D*A),S*S+D*D-1,H.unit(),!1,v);s(T>=0);for(let s=0;s<T;s++){const t=d.mul(v[s]).add(c);t.x*=p,t.y*=P;const i=lu(e,Math.atan2(t.y,t.x));if(i>=0&&i<=1){C[b]=i;const t=e.getCoord2D(i);v[b]=n.getClosestCoordinate(t,!1),Q.distance(t,n.getCoord2D(v[b]))<=a&&b++}}s(b<C.length+4);const I=U(16,Number.NaN);T=e.intersectPoint(n.getStartXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=I[s],v[b]=0;T=e.intersectPoint(n.getEndXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=I[s],v[b]=1;T=n.intersectPoint(e.getStartXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=0,v[b]=I[s];T=n.intersectPoint(e.getEndXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=1,v[b]=I[s];return 0===b?0:cm(t,e,n,C,v,b,i,r,o,a,h,u,m)}function Ku(t,e,n,i,r,o,a,h,u,m){if(Eu(e)){const s=new pm({start:e.getStartXY(),end:e.getEndXY()});return Qu(t,n,s,i,o,r,a,h,u,!0)}if(Eu(n)){const s=new pm({start:n.getStartXY(),end:n.getEndXY()});return Qu(t,e,s,i,r,o,a,h,u,m)}const l=rs(e,n);a=Math.max(a,l);let c=!1;{const t=e.getSemiAxes(),i=e.getCenter(),m=n.getSemiAxes(),l=n.getCenter(),g=Q.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===n.m_minorMajorRatio&&n.isClosed()&&n.isMajor();if(i&&a&&(c=!0,g<=d)){if(Math.max(t.x,m.x)<=Math.min(t.x,m.x)+g)return s(!r&&!o),1}}}if(!c&&os(e,n,a))return 0;const g=[],d=[],_=!1,p=!1,f=Wh(e,0,0,_,p,g,d,null),P=[],y=[],x=Wh(n,0,0,_,p,P,y,null);if(1===f&&1===x){const t=new Sn({points:g,weights:d}),s=new Sn({points:P,weights:y}),l=[],c=[],_=rh(!1,t,s,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(gt(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(gt(c[i],0,1))o.push(c[i]);else{const t=s.tToLength(c[i]),e=n.lengthToT(t);o.push(e)}}}return _}let C=[];const v=[];let b=0;const E=u&&!h;for(let s=0;s<f;s++){const t=new Sn({points:g.slice(2*s,2*s+3),weights:d.slice(2*s,2*s+3)});let i=0;for(let r=0;r<x;r++){v.length<=r&&v.push(new Sn({points:P.slice(2*r,2*r+3),weights:y.slice(2*r,2*r+3)}));const o=[],h=[],u=E?null:o,m=E?null:h,l=rh(!1,t,v[r],null,u,m,a,!1,E,!1);if(l>0&&E)return 1;for(let a=0;a<l;++a){if(0===o[a]&&0===s)o[a]=0;else if(1===o[a]&&s===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=n.lengthToT(t);h[a]=e}C.push(Mt(o[a],h[a]))}i+=v[r].calculateLength2D()}b+=t.calculateLength2D()}if(0===C.length)return 0;if(h&&(C=C.filter(t=>!gt(t.first,0,1)||!gt(t.second,0,1)||!e.getCoord2D(t.first).equals(n.getCoord2D(t.second)))),u)return C.length;const S=[],D=[];for(const s of C)S.push(s.first),D.push(s.second);return cm(t,e,n,S,D,S.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]=lu(t,e),i[1]=lu(t,s),i[2]=lu(t,r),i[3]=lu(t,o)}const r=new Q;for(let o=0;o<4;o++){const n=i[o];e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,r),s.mergeNe(r))}}function $u(t,e,n,i,r){if(0===t.m_semiMajorAxis)return n.vmin;let o=Q.getNAN();t.queryCoord2D(n.vmin,o);let a=Q.getNAN();if(t.queryCoord2D(n.vmax,a),Eu(t)){return new pm({start:o,end:a}).getClosestCoordinate(e,i)}const h=iu(t,e);if(o=iu(t,o),a=iu(t,a),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return n.vmin;const e=lu(t,Math.atan2(h.y,h.x));if(i||n.containsCoordinate(e))return e;return Q.distance(h,o)<=Q.distance(h,a)?n.vmin:n.vmax}const u=t.getSemiMajorAxis(),m=t.getSemiMinorAxis(),l=(u-m)*(u+m),c=zt(l),g=h.x,d=h.y,_=zt(m*d),p=m*l*d*2,f=[new at(_),new at(p),new at(c-zt(u*g)-_),new at(-p),new at(-c)],P=lt(at,4),y=_n(f,4,new H(-1,1),!1,P,4);let x=n.vmin,C=Q.sqrDistance(h,o);{const t=Q.sqrDistance(h,a);t<C&&(x=n.vmax,C=t)}s(!i);let v=U(8,Number.NaN);for(let s=0;s<y;++s){const e=P[s].value(),n=Math.sqrt(1-e*e),i=Math.atan2(e,n),r=Math.atan2(e,-n);v[2*s]=lu(t,i),v[2*s+1]=lu(t,r)}v=v.slice(0,2*y),Gt(v);for(let s=0,b=2*y;s<b;++s)if(v[s]>n.vmin&&v[s]<n.vmax){const n=Q.sqrDistance(e,t.getCoord2D(v[s]));C>n&&(C=n,x=v[s])}return x}function tm(t,e,n){s(!Eu(t));const i=new le;i.setRotateAngle(-t.getAxisXRotation());const r=new Q;i.queryTransform(e,r);const o=Math.atan2(-r.x*t.getMinorMajorRatio(),r.y),a=o+wt();let h=lu(t,o),u=lu(t,a);u<h&&(u=et(h,h=u));let m=0;return h>=0&&h<=1&&(n[m++]=h),u>=0&&u<=1&&(n[m++]=u),m}function em(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 sm(t,e,s){if(Eu(t))s.setE(Ye.constructPoint2D(t.getEndXY()).subE(Ye.constructPoint2D(t.getStartXY())));else{const n=new at;gu(t,e,n);const i=new Ye;if(i.setCoordsE(new at(t.m_semiMajorAxis).negate().mulE((new at).setSin(n)),new at(t.getSemiMinorAxis()).mulE((new at).setCos(n))),t.m_rotation){const e=new at(t.m_rotation);i.rotateDirect((new at).setCos(e),(new at).setSin(e))}i.scaleThis(new at(t.getSweepAngle())),s.setE(i)}}function nm(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 le;n.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=Q.distance(e,s),a=Q.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 Au(t,n,!0,e,s)}const h=new Q;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=Q.getClosestCoordinate(u,l,t.getCenter(),!0),g=new Q;xt(u,l,c,g);const d=Q.distance(e,g);t.constructEllipticArcEndPointsCenter(e,s,d,1,0,!0,!t.isClockwise(),g),t.setProjectionBehavior(0)}function im(t,e,n,i){const r=t.getStartXY(),o=t.getEndXY(),a=r.equals(o),h=e.equals(n);if(!a&&!h){const s=new le;return s.initializeFromTwoPoints(r,o,e,n),Au(t,s,!0,e,n),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void bu(t,e,n,1);if(a&&h){const s=t.m_center.add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,n,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),s)}if(!a){const s=.5*(kt()-Math.abs(t.getSweepAngle())),i=(t.getSweepAngle()+s*Nt(t.getSweepAngle()))/t.getSweepAngle(),r=new Q;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,n,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),o)}const u=Q.sqrDistance(e,n);let m=.25,l=.75;if(u<Q.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],n=tn(new su(t,u),H.construct(0,.25),1,e);n>0&&(s(1===n),m=e[0],l=1-e[0])}const c=t.getCoord2D(m),g=t.getCoord2D(l);s(!c.equals(g)),t.constructEllipticArcEndPointsCenter(c,g,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),im(t,e,n)}function rm(t,e,s,n,i){return om(t,!1,e,s,n,i)}function om(t,e,s,n,r,o){const a=s.getGeometryType(),u=n.getGeometryType(),m=Math.max(r,rs(s,n));if(a===i.enumLine&&u===i.enumLine)return Ss(s,n,m,o);let l=s,c=n,g=s.getStartXY(),d=s.getEndXY();if(g.compare(d)>0&&(l=s.clone().reverse()),g=n.getStartXY(),d=n.getEndXY(),g.compare(d)>0&&(c=n.clone().reverse()),e){if(s.equals(n))return 2;if(Ge(s,n,m))return 4}switch(a){case i.enumLine:switch(u){case i.enumEllipticArc:return Uu(t,c,l,m,o);case i.enumBezier:return Eo(t,c,l,m,o);case i.enumRationalBezier2:return $a(t,c,l,m,o);case i.enumBezier2:return Xi(t,c,l,m,o);default:h("")}break;case i.enumEllipticArc:switch(u){case i.enumLine:return Uu(t,l,c,m,o);case i.enumEllipticArc:return Ou(t,l,c,m,o);case i.enumBezier:return So(t,c,l,m,o);case i.enumRationalBezier2:return th(t,c,l,m,o);case i.enumBezier2:return qi(t,c,l,m,o);default:h("")}break;case i.enumBezier:switch(u){case i.enumLine:return Eo(t,l,c,m,o);case i.enumEllipticArc:return So(t,l,c,m,o);case i.enumBezier:return Do(t,l,c,m,o);case i.enumRationalBezier2:return wo(t,l,c,m,o);case i.enumBezier2:return Ao(t,l,c,m,o);default:h("")}break;case i.enumRationalBezier2:switch(u){case i.enumLine:return $a(t,l,c,m,o);case i.enumEllipticArc:return th(t,l,c,m,o);case i.enumBezier:return wo(t,c,l,m,o);case i.enumRationalBezier2:return eh(t,l,c,m,o);case i.enumBezier2:return sh(t,l,c,m,o);default:h("")}break;case i.enumBezier2:switch(u){case i.enumLine:return Xi(t,l,c,m,o);case i.enumEllipticArc:return qi(t,l,c,m,o);case i.enumBezier:return Ao(t,c,l,m,o);case i.enumRationalBezier2:return sh(t,c,l,m,o);case i.enumBezier2:return Fi(t,l,c,m,o);default:h("")}break;default:h("")}}function am(t,e,s=!0){if(!s&&!hm(t,e))return 0;const n=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.enumBezier){const n=t,i=e;return n.getControlPoint1().equals(i.getControlPoint1())&&n.getControlPoint2().equals(i.getControlPoint2())?s:0}if(r===i.enumEllipticArc){return em(t,e,!1)?s:0}if(r===i.enumRationalBezier2){const n=t,i=e;if(n.getControlPoint1().equals(i.getControlPoint1())&&n.getStandardFormWeight()===i.getStandardFormWeight())return s}else if(r===i.enumBezier2){const n=e;if(t.getControlPoint1().equals(n.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.enumBezier){const n=t,i=e;return n.getControlPoint1().equals(i.getControlPoint2())&&n.getControlPoint2().equals(i.getControlPoint1())?s:0}if(r===i.enumEllipticArc){return em(t,e,!0)?s:-1}if(r===i.enumRationalBezier2){const n=t,i=e;if(n.getControlPoint1().equals(i.getControlPoint1())&&n.getStandardFormWeight()===i.getStandardFormWeight())return s}else if(r===i.enumBezier2){const n=e;if(t.getControlPoint1().equals(n.getControlPoint1()))return s}return 0}return 0}function hm(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==i.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function um(t,s,n,r,o,a,u){!o&&a&&e("");const m=s.getGeometryType(),l=n.getGeometryType(),c=Math.max(u,rs(s,n));if(r&&(r.length=0),o&&(o.length=0),a&&(a.length=0),m===i.enumLine&&l===i.enumLine)return Ds(s,n,r,o,a,c,!1,!1);let g=s,d=n,_=s.getStartXY(),p=s.getEndXY(),f=!1,P=!1;_.compare(p)>0&&(g=s.clone(!0).reverse(),f=!0),_=n.getStartXY(),p=n.getEndXY(),_.compare(p)>0&&(d=n.clone(!0).reverse(),P=!0);let y=0;switch(m){case i.enumLine:switch(l){case i.enumEllipticArc:y=Qu(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier:y=To(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=nh(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier2:y=Vi(t,d,g,r,a,o,c,!1,!1,!0);break;default:h("")}break;case i.enumEllipticArc:switch(l){case i.enumLine:y=Qu(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=Ku(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=Io(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=ih(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier2:y=Li(t,d,g,r,a,o,c,!1,!1,!0);break;default:h("")}break;case i.enumRationalBezier2:switch(l){case i.enumLine:y=nh(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=ih(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=Yo(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=rh(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier2:y=oh(t,g,d,r,o,a,c,!1,!1,!1);break;default:h("")}break;case i.enumBezier2:switch(l){case i.enumLine:y=Vi(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=Li(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=No(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=oh(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier2:y=Ri(t,g,d,r,o,a,c,!1,!1,!1);break;default:h("")}break;case i.enumBezier:switch(l){case i.enumLine:y=To(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=Io(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=Mo(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumRationalBezier2:y=Yo(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier2:y=No(t,g,d,r,o,a,c,!1,!1,!1);break;default:h("")}break;default:h("")}if(f){if(o){for(let t=0;t<y;t++)o[t]=1-o[t];o.reverse()}r&&r.reverse(),a&&a.reverse()}if(P&&a)for(let e=0;e<y;e++)a[e]=1-a[e];return y}function mm(t,e,s){if(e===s)return 0;e>s&&(s=et(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function lm(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])),gt(s[u],0,1)&&gt(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]||gt(s[i],0,1)&&gt(n[i],0,1))continue;const o=(s,n,i,r)=>{const o=new Ye,a=new at;a.setWithEps(1);const h=new at;h.set(n,a.eps()),t.queryCoord2DE(h,o);const u=new Ye;t.queryCoord2DE(new at(s),u);let m=!1;return o.eq(u)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new at(i),u),m=o.eq(u)),!m},h=Q.getNAN();t.queryCoord2D(s[i],h);const m=Q.getNAN();e.queryCoord2D(n[i],m);if(0===Q.distance(h,m)&&o(s[u],s[i],n[u],n[i]))break;const l=new H(n[i],n[u]);l.normalizeNoNAN();const c=new H(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=Q.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=Q.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=gt(s[i],0,1)||gt(n[i],0,1)?0:1),1!==g)break;s[i]=s[u],n[i]=n[u]}}}function cm(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(gt(n,0,1)){n=ne(n);continue}const i=t.getCoord2D(n);n<.5?i.equals(t.getStartXY())&&mm(t,0,n)<=is(t)&&(e[s]=0):i.equals(t.getEndXY())&&mm(t,n,1)<=is(t)&&(e[s]=1)}};g(e,n),g(s,i),lm(e,s,n,i,r);const d=[];for(let f=0,P=r;f<P;f++)d.push(f);const _=(t,e)=>c?ie(i[t],n[t],i[e],n[e]):ie(n[t],i[t],n[e],i[e]);if(d.length>1){d.sort(_);const t=Math.max(is(e),is(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(mm(e,a,h)<=t&&mm(s,u,m)<=t&&!(gt(a,0,1)&&gt(u,0,1)||gt(h,0,1)&&gt(m,0,1))){const t=Q.distance(e.getCoord2D(a),s.getCoord2D(u)),n=Q.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=H.constructEmpty(),r=H.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=rt(t.vmin,t.vmax,n[i]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,u)){o=!1;break}a=rt(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;ke(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(gt(n[d[r]],0,1)&&gt(i[d[r]],0,1)){if(0===Q.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=Q.getNAN();e.queryCoord2D(n[d[f]],t),o.push(t)}p++}return p}function gm(t,e,s,n,i,r,o,a,h){if(gt(s,0,1)&&gt(n,0,1)){if(0===Q.distance(t.getCoord2D(s),e.getCoord2D(n))){const u=1e-12,m=new Ye,l=Number.EPSILON;if(t.queryDerivative(new at(s,l),m),m.isTrueZero()){const e=1===s?-1e-12:u;t.queryDerivative(new at(s,l).add(e),m)}1===s&&m.negateThis();const c=new Ye;if(e.queryDerivative(new at(n,l),c),c.isTrueZero()){const t=1===s?-1e-12:u;e.queryDerivative(new at(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(ut)&&(d.isZero()||Math.abs(d.value())<_())){return Be(t,e,s,n,i,r,o,a)}}}return 0}function dm(t,e,n,i,r){let o=-1,a=-1,h=-1,u=-1;{const s=[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[s[e]].equals(n[m[i]])){o=s[e],a=r[e],h=m[i],u=l[i];break}}if(-1===o){const s=new De;s.setFromPoints(t,e+1);const o=new De;return o.setFromPoints(n,i+1),o.inflate(r),s.isIntersectingW(o)?-1:0}{const m=U(e+1,Number.NaN),l=xr(t,e+1,m);s(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=U(i+1,Number.NaN),_=xr(n,i+1,d);s(_>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=n[d[(p+_-1)%_]],x=n[d[(p+1)%_]],C=t[o],v=[f,P,y,x],b=[0,1,2,3];b.sort((t,e)=>Q.compareVectorsOrigin(C,v[t],v[e]));let E=b[0];for(let t=1;t<4;t++){if(b[t]!==(E+1)%4)return-1;E=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 _m=b;class pm extends ds{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 s(0),0}calculateUpperLength3D(){return s(0),0}changeEndPoints3D(t,e){s(0)}getClosestCoordinate3D(t,e,n){return s(0),0}getBoundary(){return Js(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?fs(this,t):Ps(this,t);const n=_m.getInterpolation(e),i=this.getStartAttributeAsDbl(e,s),r=this.getEndAttributeAsDbl(e,s);return Ct(n,i,r,t,_m.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){s(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return pm.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=me.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=_m.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,ts(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,ts(this,1,1,0))):a("env type not impl")}applyTransformation(t){s(t instanceof le);const e=new Q;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 pm({vd:this.m_description})}calculateLength2D(){return Math.sqrt(Xs(this))}calculateLength3D(t){return s(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return s(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return _s(this,t,e)}queryCoord3D(t,e){s(0)}getCoordZ(t){return ys(this,t)}queryCoord2DE(t,e){Cs(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());const s=Xe.constructPoint2D(this.getEndXY());s.subThis(e),s.mulThis(it.constructDouble(t)),e.addThis(s)}getCoordX(t){return fs(this,t)}getCoordY(t){return Ps(this,t)}cut(t,e,s){const n=new fm;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=Q.getNAN();if(_s(this,t,r),i.setStartXYCoords(r.x,r.y),_s(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=_m.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){xs(this,t,e)}getClosestCoordinate(t,e){return Q.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const n=new Q;this.queryCoord2D(e.vmin,n);const i=new Q;this.queryCoord2D(e.vmax,i);const r=Q.getClosestCoordinate(n,i,t,!1);return us.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=fs(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 s(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new pm;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 Q;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=Q.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new Q;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return Is(this,t,e,s)>=0}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,s){return s&&(t<2&&e(""),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]=fs(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]=Ps(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=_t(t.vmin,0,1);const n=new Q;return this.queryCoord2D(s,n),e.setCoords({pt:n}),s=_t(t.vmax,0,1),this.queryCoord2D(s,n),void e.mergeNe(n)}a("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 bs(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){vs(this,t[0],t[e-1])}writeInBufferStream(t,e){return s(0),0}readFromBufferStream(t,e){s(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){vs(this,t,e)}static isIntersectingLineLine(t,e,s,n){return Ss(t,e,s,n)}static isIntersectingLineLine_(t,e,s,n){return Ss(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 um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){e.length<1&&n("");const i=Is(this,t,s,!1);return i>=0?(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==rm(!1,this,t,e,s)}}pm.type=i.enumLine;class fm{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new pm,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):h("bad constructor params"))}assignCopy(t){return t instanceof fm?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof fm){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:h("")}}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){s(0)}createImpl(t){switch(t){case i.enumLine:1&this.m_mask||(this.m_lineBuffer=new pm,this.m_mask|=1,this.m_active=1);break;case i.enumEllipticArc:2&this.m_mask||(this.m_curves=new Xh,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case i.enumBezier:4&this.m_mask||(this.m_curves=new ia,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case i.enumBezier2:8&this.m_mask||(this.m_curves=new wn,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case i.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Sn,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:e("")}}create(t){t===i.enumLine?this.createLine():t===i.enumEllipticArc?this.createEllipticArc():t===i.enumBezier?this.createCubicBezier():t===i.enumRationalBezier2?this.createQuadraticRationalBezier():t===i.enumBezier2?this.createQuadraticBezier():e("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){s(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(i.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(i.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(i.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(i.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(i.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&h("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():h("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof fm?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):(a("seg comparison not yet impl"),!1)}}export{Xe as $,Ks as A,kh as B,wr as C,jh as D,Pr as E,Wh as F,ls as G,rm as H,ze as I,ia as J,fh as K,pm as L,Se as M,Gu as N,us as O,Os as P,Sn as Q,om as R,fm as S,um as T,is as U,pr as V,Es as W,Ye as X,am as Y,hm as Z,gm as _,ur as a,cu as a0,fr as a1,Yh as a2,_e as a3,Th as a4,Lu as a5,Ru as a6,Tu as a7,ou as a8,ks as a9,Ah as b,Js as c,zh as d,Er as e,yr as f,cs as g,Pe as h,vr as i,Ts as j,qh as k,Xh as l,Fh as m,cr as n,gr as o,Bh as p,sn as q,xe as r,pe as s,tn as t,lo as u,fe as v,Br as w,Kn as x,Ls as y,Rs as z};
5
+ import{i as t,a as e,g as s,q as n,G as i,B as r,C as o,t as a,d as h,z 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,N as C,O as v,V as b,d as E,q as S,Q as D,R as w,U as A,W as T,X as I,E as M,Y,Z as N,_ as X,P as q,D as F,$ as V,a0 as L,a1 as R,t as z,a2 as B,S as k,B as G,A as W,T as j,a3 as Z}from"./Envelope.js";import{E as H,d as U,a3 as O,P as Q,i as K,b as J,J as $,a4 as tt,c as et,a5 as st,a6 as nt,M as it,q as rt,a7 as ot,X as at,a8 as ht,U as ut,g as mt,m as lt,a9 as ct,aa as gt,H as dt,s as _t,K as pt,F as ft,ab as Pt,ac as yt,Q as xt,ad as Ct,ae as vt,af as bt,ag as Et,ah as St,ai as Dt,aj as wt,ak as At,o as Tt,al as It,l as Mt,j as Yt,e as Nt,am as Xt,an as qt,ao as Ft,ap as Vt,aq as Lt,ar as Rt,a as zt,R as Bt,as as kt,v as Gt,at as Wt,au as jt,w as Zt,av as Ht,aw as Ut,ax as Ot,n as Qt,ay as Kt,az as Jt,aA as $t,aB as te,aC as ee,u as se,aD as ne,aE as ie,aF as re,aG as oe,aH as ae,aI as he,a1 as ue}from"./Point2D.js";import{Envelope2D as me}from"./Envelope2D.js";import{T as le}from"./Transformation2D.js";import{G as ce}from"./SimpleGeometryCursor.js";class ge{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 de(t,s,n,i,r){(s<0||n<0||i<1||s+i*(n-1)+1>t.size())&&e("Index out of bound");for(let e=s,o=s+i*(n-1)+1;e<o;e+=i)t.writeAsDbl(e,r(t.readAsDbl(e)))}function _e(t,e,s){if(t)for(let n=e.length-1;n>=0;--n)s(e[n]);else e.forEach(s)}function pe(t,e){let s=$(t);const n=e.length/K();for(let i=0;i<e.length;++i){const t=Math.trunc(s*n);s=$(s);const i=Math.trunc(s*n),r=e[t];e[t]=e[i],e[i]=r}}function fe(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 Pe(t,e,s,n,i){tt(t,e,n-e,(t,e)=>i(t,e)?-1:1)}function ye(t,e,s){if(!(s<=e))for(;e<s;)t[s]=et(t[e],t[e]=t[s]),e++,s--}function xe(t,e,s,n){ye(t,e,s-1),ye(t,s,n-1),t.reverse()}function Ce(t,e,s){const n=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),J(t.getAttributeArray(),e,0,2,n-2)}var ve=b;const be="can not assign an empty point to a vertex";class Ee{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 ge,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new y,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 ge,this.m_envelopeData=new y,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(e,s){if(!t(e.getGeometryType()))return!1;const n=e;if(this===n)return!0;if(!this.m_description.equals(n.getDescription()))return!1;if(this.isEmptyImpl()!==n.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==n.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(e),o=n.getAttributeStreamRef(e),a=ve.getComponentCount(e);if(!r.equals(o,0,i*a,s))return!1}if(s){if(!this.equalsImplTol(e,s))return!1}else if(!this.equalsImpl(e))return!1;return!0}transformAttribute(t,s,n,i,r){if(this.addAttribute(t),!this.isEmpty()&&(0!==n||1!==i)){if(0===t){const t=new le;return 0===r?0===s?(t.setShiftCoords(n,0),t.scale(i,1)):1===s?(t.setShiftCoords(0,n),t.scale(1,i)):e(""):0===s?(t.setScaleCoords(1/i,1),t.shiftCoords(-n,0)):1===s?(t.setScaleCoords(1,1/i),t.shiftCoords(0,-n)):e(""),void this.applyTransformation(t)}de(this.getAttributeStreamRef(t),s,this.getPointCount(),ve.getComponentCount(t),N(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=x(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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||e("AttributeStream : Geometry does not have the attribute");const s=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(s)}setAttributeStreamRef(t,s){s||e("stream"),s&&ve.getPersistence(t)!==s.getPersistence()&&e(""),this.addAttribute(t);const n=this.m_description.getAttributeIndex(t);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=ve.getComponentCount(e);i<r;i++){const o=this.m_vertexAttributes.get(n).readAsDbl(r*t+i);s.setAttributeBasic(e,i,o)}}}setPointByValNoCurves(t,s){const n=s;n.isEmpty()&&e(be);const i=n.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const r=this.m_vertexAttributes.get(0);r.write(2*t,n.getX()),r.write(2*t+1,n.getY());for(let e=1,o=this.m_description.getAttributeCount();e<o;e++){const s=this.m_description.getSemantics(e),i=ve.getComponentCount(s);for(let r=0;r<i;r++){const o=n.getAttributeAsDbl(s,r);this.m_vertexAttributes.get(e).writeAsDbl(t*i+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,n,i){s(0)}getPointByValAsArray(t,e,n,i){s(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const i=ve.getComponentCount(t);s>=i&&n("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*i+s):ve.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,i){const r=ve.getComponentCount(t);i<r&&n("");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=ve.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,n,i){s(0)}setAttributeNoCurves(t,e,s,i){const r=ve.getComponentCount(t);s>=r&&n(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,i)}setAttributeFromArrayNoCurves(t,e,s,i){(e<0||e>=this.m_pointCount)&&n("");const r=ve.getComponentCount(t);i<r&&n(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let n=0;n<r;++n)a.writeAsDbl(e*r+n,s[n])}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=ve.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 me||t instanceof S?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=H.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=ve.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=ve.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 s(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||e(""),this.m_envelopeData=new y({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&e(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,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)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*n,a=2*r,h=0;e<a;e+=2,h++)o.queryPoint2D(e,t[h]);return r}queryCoordinates3D(t,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)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=ve.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let e=n;e<r;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=u?a.read(e):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,e,n=!1){if(2===t?s(this.getGeometryType()===i.enumPolyline):1===t?s(this.getGeometryType()===i.enumMultiPoint||this.getGeometryType()===i.enumPolyline):3===t&&s(this.getGeometryType()===i.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;n||(s|=16);const i=31;this.clearAndSetDirtyFlagProtected(i,s),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}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,e=!1){e&&this.hasDirtyFlag(32)&&r("Cannot do shallow clone on unprepared geometry");const n=t,o=this.getGeometryType(),a=n.getGeometryType();s(o===a||o===i.enumPolygon&&a===i.enumPolyline,"failure in copyToUnchcked"),n.clearAccelerators(),n.m_description=this.m_description,n.m_vertexAttributes.destroyAndSetSize(0),n.m_envelopeData.releaseAttributes();const h=this.m_description.getAttributeCount(),u=new ge;if(!this.m_vertexAttributes.empty()){u.destroyAndSetSize(h);for(let t=0;t<h;t++)if(this.m_vertexAttributes.get(t))if(e)u.set(t,this.m_vertexAttributes.get(t));else{const e=ve.getComponentCount(this.m_description.getSemantics(t));u.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,n.m_envelopeData),n.m_flags=this.m_flags,n.m_simpleTolerance=this.m_simpleTolerance,o!==a){const t=[Number.NaN];n.getIsSimple(0,t)>=3?n.setIsSimple(1,t[0]):n.setIsSimple(-1,0)}n.m_vertexAttributes.swap(u),u.destroyAndSetSize(0),n.m_pointCount=this.m_pointCount,n.hasDirtyFlag(32)||n.m_vertexAttributes.empty()?(s(!e||0===n.m_pointCount),n.m_reservedPointCount=-1):n.m_reservedPointCount=n.m_pointCount;try{this.copyToImpl(n,e)}catch(m){throw n.setEmpty(),m}n.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,i,r){(t<0||t>=this.m_pointCount)&&n(""),(e<0||e>=this.m_pointCount)&&n(""),r.assignVertexDescription(this.m_description);const o=U(ve.maxComponentCount(),Number.NaN),a=U(ve.maxComponentCount(),Number.NaN),h=D();let u=0;for(let n=0;n<this.m_description.getAttributeCount();n++){const r=this.m_description.getSemantics(n),m=ve.getInterpolation(r),l=ve.getComponentCount(r),c=ve.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),s(u+l<=w),O(m,o,a,h,u,l,i,c),u+=l}Ce(r,h)}getShortestDistance(t,e){return Q.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return Q.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&e(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const s=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(s)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=A();T(t,this.m_description,e);const s=new ge;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=ve.getComponentCount(n);i=this.m_vertexAttributes.get(s).size()/t,i<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,ve.getDefaultValue(n)),i=e)}else this.m_vertexAttributes.set(s,I(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 M({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=ve.getComponentCount(e),i=this.m_vertexAttributes.get(t);for(let t=0;t<n;t++){const r=new H;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 y({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=me.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){s(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof me?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(t,s){if(t<0&&e(""),0===t)return;let n=t=Math.ceil(t);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,Y(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,Y(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=ve.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(n*s):this.m_vertexAttributes.set(t,Y(e,n))}this.reserveImplImpl(n,s),this.m_reservedPointCount=n}}reserveRounded(t){t<0&&e(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&o("")}}class Se extends Ee{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(t,s){t>this.getPointCount()&&e("invalid point index"),t<0&&(t=this.getPointCount());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=b.getComponentCount(i);if(0===i)this.m_vertexAttributes.get(e).insert(r*t,s,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoint(t,s){s.isEmpty()&&e(be),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(s.getDescription());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=b.getComponentCount(i);if(s.hasAttribute(i))this.m_vertexAttributes.get(e).insertAttributes(r*t,s,i,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&n(""),t<0&&(t=this.getPointCount()),0===s)return;const i=e[0].getDescription();this.mergeVertexDescription(i);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let n=0,o=this.m_description.getAttributeCount();n<o;n++){const o=this.m_description.getSemantics(n),a=b.getComponentCount(o);if(this.m_vertexAttributes.get(n))if(i.hasAttribute(o))this.m_vertexAttributes.get(n).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=b.getDefaultValue(o);this.m_vertexAttributes.get(n).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,s,n){if((t>this.getPointCount()||n<0)&&e("invalid point index"),t<0&&(t=this.getPointCount()),0===n)return;const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+n);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++){const r=this.m_description.getSemantics(e),o=b.getComponentCount(r);if(this.m_vertexAttributes.get(e))if(0===r)this.m_vertexAttributes.get(e).insertRangeFromPoints(o*t,s,0,n,!0,o*i);else{const s=b.getDefaultValue(r);this.m_vertexAttributes.get(e).insertRange(o*t,s,o,o*i)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&n("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(t,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)&&e(""),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 e=n;e<r;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=u?a.read(e):h;return r}queryAttributeAsInt(t,e,n,i){s(0)}add(t){t.isEmpty()&&e(be),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new Q(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(t,s,n){this===t&&e("Multi_point_impl.add");const i=n<0?t.getPointCount():n;if((s<0||s>t.getPointCount()||i<s)&&e(""),s===i)return;const r=t.getDescription();this.mergeVertexDescription(r);const o=i-s,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let e=0,h=this.m_description.getAttributeCount();e<h;e++){const n=this.m_description.getSemantics(e),i=b.getComponentCount(n),h=this.getAttributeStreamRef(n);if(r.hasAttribute(n)){const e=t.getAttributeStreamRef(n);h.insertRangeFromStream(a*i,e,s*i,o*i,!0,1,a*i)}else{const t=b.getDefaultValue(n);h.insertRange(a*i,t,o*i,a*i)}}}addPoints2D(t,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&e(""),n===o)return;r=o-n;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[n+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&e(""),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 Q;for(let e=0;e<r;e++)u.x=t[n+e].x,u.y=t[n+e].y,h.writePoint2D(2*(a+e),u);const m=this.getAttributeStreamRef(1);for(let e=0;e<r;e++)m.write(a+e,t[n+e].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 i.enumMultiPoint}getDimension(){return 0}createInstance(){return new Se({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):a("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===i.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):a("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){s(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return s(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}Se.type=i.enumMultiPoint;class De{constructor(){this.m_EnvelopeType=5,this.envAabb=me.constructEmpty(),this.envRot=me.constructEmpty()}static constructEmpty(){return new De}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:Te(t),y:Ie(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Te(t),Ie(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=Te(t[n]),s=Ie(t[n]);this.envRot.mergeNeCoords(e,s)}break}{const e=Te(t[s]),n=Ie(t[s]);this.envRot.setCoords({x:e,y:n}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Te(t),Ie(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*st();this.envRot.inflateCoords(e,e),e<0&&De.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(Me(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(Me(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(Me(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=we(t.x,t.y),n=Ae(t.x,t.y);e.setCoords(s,n)}}function we(t,e){return t-e}function Ae(t,e){return t+e}function Te(t){return t.x-t.y}function Ie(t){return t.x+t.y}function Me(t){return new Q(Te(t),Ie(t))}class Ye{constructor(){this.x=at.getNAN(),this.y=at.getNAN()}static getNAN(){return new Ye}static constructPoint2D(t){const e=new Ye;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Ye;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Ye;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 Ye).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 Ye;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Ye;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=ht.clone(),this.y=ut.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 Q.construct(this.x.value(),this.y.value())}}class Ne{constructor(){this.a11=new at(1),this.a12=new at(0),this.a21=new at(0),this.a22=new at(1)}clone(){const t=new Ne;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=et(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 at(1),i=new at(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new at(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(ut)&&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 at(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]=et(t[0],t[0]=t[1]),e[1]=et(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class Xe{static constructPoint2D(t){return new Xe(it.constructDouble(t.x),it.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new it).setNAN(),void(this.y=(new it).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 Q(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 Xe(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new Xe(this.x.add(t.x),this.y.add(t.y))}sub(t){return new Xe(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 qe=b;function Fe(t){let e=!1;for(let s=0;s<2;s++){const n=nt(t[0][s],t[3][s]);n>0?(nt(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),nt(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),nt(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),nt(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):n<0?(nt(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),nt(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),nt(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),nt(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 Ve(t){const e=nt(t[0].y,t[1].y),s=nt(t[1].y,t[2].y),n=nt(t[2].y,t[3].y);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0){const e=nt(t[0].x,t[1].x),s=nt(t[1].x,t[2].x),n=nt(t[2].x,t[3].x);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0)return!0}return!1}function Le(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 Re(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function ze(t,e,s){const n=lt(Q,4);let r=t.queryControlPointsHelper(n);const o=lt(Q,4);let a=e.queryControlPointsHelper(o);n[0].equals(o[0])||u("");const h=t.getGeometryType();if(h===e.getGeometryType()&&n.map((t,e)=>o[e].equals(t)).reduce((t,e)=>t&&e)){if(h!==i.enumRationalBezier2)return 0;{const s=e,n=[0,0,0],i=[0,0,0];if(t.queryWeights(n),s.queryWeights(i),n.map((t,e)=>i[e]===t).reduce((t,e)=>t&&e))return 0}}for(;r>2&&n[1].equals(n[0]);)n.splice(1,1),r--;for(;a>2&&o[1].equals(o[0]);)o.splice(1,1),a--;(n[1].equals(n[0])||o[1].equals(n[0]))&&u("");const m=Q.compareVectorsOrigin(n[0],n[1],o[1]);if(0===m){const s=Xe.constructPoint2D(n[0]),i=new Xe;t.queryCoord2DMP(1e-16,i),i.sub(s);const r=new Xe;e.queryCoord2DMP(1e-16,r),r.sub(s);return r.crossProduct(i).sign()}return m}function Be(t,e,n,i,r,o,a,h){let u=t.calculateUpperLength2D(),m=e.calculateUpperLength2D(),l=t,c=e,g=!1;u>m&&(c=et(l,l=c),i=et(n,n=i),m=et(u,u=m),g=!0);const d=0===n;{a[0]=d?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(Q.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 H(0,1),r)){s=!1;break}if(s)return g&&(h[0]=et(a[0],a[0]=h[0])),1}}if(u<=3*r)return 0;let _=_t(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++){s(b<4095);const t=d?_:1-_,e=l.getCoord2D(t),n=c.getClosestCoordinate(e,!1);if(n===i)return C;const u=c.getCoord2D(n),m=Q.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)_=rt(f,y,v);else{if(a[C]=t,h[C]=n,g&&(h[C]=et(a[C],a[C]=h[C])),1===o||1===C)return 1===C&&a[0]>a[1]&&(a[1]=et(a[0],a[0]=a[1]),h[1]=et(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 ke(t,e,s,n,i,r,o,a,h){if(gt(s,0,1)&&gt(n,0,1)){if(0===Q.distance(t.getCoord2D(s),e.getCoord2D(n))){const h=1e-12,u=new Ye,m=dt();if(t.queryDerivative(new at(s,m),u),u.isTrueZero()){const e=1===s?-h:h;t.queryDerivative(new at(s,m).add(e),u)}1===s&&u.negateThis();const l=new Ye;if(e.queryDerivative(new at(n,m),l),l.isTrueZero()){const t=1===s?-h:h;e.queryDerivative(new at(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(ut)&&(g.isZero()||Math.abs(g.value())<d())){return Be(t,e,s,n,i,r,o,a)}}}return 0}function Ge(t,e,n){if(s(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(ke(t,e,0,0,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(ke(t,e,1,1,n,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(ke(t,e,0,1,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(ke(t,e,1,0,n,2,[0,0],[0,0]))return!0}return!1}function We(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function je(t,e,s){t.m_XStart=e,t.m_YStart=s}function Ze(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function He(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Ue(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 Oe(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=Qe(t,e),s}function Qe(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:qe.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 Je(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=qe.getComponentCount(n);i<r;i++){const r=ts(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function $e(t,e,s){s.isEmpty()&&o(""),Ue(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=qe.getComponentCount(r);for(let n=0;n<o;n++){es(t,e,r,n,s.getAttributeAsDbl(r,n))}}}function ts(t,e,s,i){if((e<0||e>1)&&n(""),0===s)return(i<0||i>=2)&&n(""),0===e?0===i?t.m_XStart:t.m_YStart:0===i?t.m_XEnd:t.m_YEnd;const r=qe.getComponentCount(s);(i<0||i>=r)&&n("");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+i]:qe.getDefaultValue(s)}function es(t,e,s,i,r){if((e<0||e>1)&&n(""),0===s)return 0===e?0===i?t.m_XStart=r:1===i?t.m_YStart=r:n(""):1===e?0===i?t.m_XEnd=r:1===i?t.m_YEnd=r:n(""):n(""),void t.endPointModified();const o=qe.getComponentCount(s);(i<0||i>=o)&&n("");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+i]=r}function ss(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=qe.getComponentCount(i);for(let s=0;s<r;s++){let n=ts(e,0,i,s);es(t,0,i,s,n),n=ts(e,1,i,s),es(t,1,i,s,n)}}}function ns(t,e){const s=A();T(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=U(2*i,Number.NaN),J(n,e.getDefaultPointAttributes(),0,2,i),J(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=qe.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 is(t){return t.absNorm()*mt()}function rs(t,e){return Math.max(t.absNorm(),e.absNorm())*mt()}function os(t,e,s){const n=new De;t.queryEnvelopeW(H.unit(),n);const i=new De;return e.queryEnvelopeW(H.unit(),i),i.inflate(s),!n.isIntersectingW(i)}function as(t,e,s){const n=ct(t,s),i=ct(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 hs=b;class us{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:X(),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:X(),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]);h("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=U(2*t,Number.NaN)),J(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),J(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return a("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return a("not implemented"),!1}setCoordsForIntersector3D(t,e,s){a("not implemented")}transformAttribute(t,e,s,n,i){a("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=x(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=hs.getComponentCount(s);for(let i=0;i<n;i++){es(this,0,s,i,t.getAttributeAsDbl(s,i));es(this,1,s,i,e.getAttributeAsDbl(s,i))}}}getStartXY(){return new Q(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 Oe(this,0)}setStartXYZ(t){Ke(this,0,t)}setStartXYZCoords(t,e,s){Ke(this,0,E.construct(t,e,s))}queryStart(t){Je(this,0,t)}setStart(t){$e(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return ts(this,0,t,e)}getStartAttributeAsInt(t,e){return s(0),0}setStartAttribute(t,e,s){es(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=hs.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=hs.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 s(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return s(0),0}getEndXY(){return new Q(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 Oe(this,1)}setEndXYZ(t){Ke(this,1,t)}setEndXYZCoords(t,e,s){Ke(this,1,E.construct(t,e,s))}queryEnd(t){Je(this,1,t)}setEnd(t){$e(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return ts(this,1,t,e)}getEndAttributeAsInt(t,e){return s(0),Math.trunc(0)}setEndAttribute(t,e,s){es(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("");const s=t;s.assignVertexDescription(this.m_description),s.m_attributes&&J(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=H.constructEmpty();return s.vmin=ts(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(ts(this,1,t,e)),s}calculateLength3D(t){return s(0),0}getCoord3D(t){return s(0),{}}getCoord2D(t){const e=Q.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){s(0)}getCoordZ(t){return s(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=hs.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=me.constructEmpty();this.queryLooseEnvelopeOnInterval(e,n);if(n.distance(t)>s)return!1;const i=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(i)&&Q.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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(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=hs.getComponentCount(e);t<s;t++){const s=ts(this,0,e,t);es(this,0,e,t,ts(this,1,e,t)),es(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,n,i){if(!e&&this.isIntersecting(t,0,!1)){if(null!==n||null!==i){const e=U(9,Number.NaN),r=U(9,Number.NaN),o=this.intersect(t,null,e,r,0);s(o<=9),0===o&&h(""),null!==n&&(n[0]=e[0]),null!==i&&(i[0]=r[0])}return 0}let r,o=Number.MAX_VALUE,a=-1,u=o;return r=this.getStartXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==i&&(i[0]=a),null!==n&&(n[0]=0)),r=this.getEndXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==i&&(i[0]=a),null!==n&&(n[0]=1)),r=t.getStartXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==n&&(n[0]=a),null!==i&&(i[0]=0)),r=t.getEndXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==n&&(n[0]=a),null!==i&&(i[0]=1)),o}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 rt(t,e,s)}moveTo(t){const e=this.isClosed(),s=new le;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){s(0)}getDescription(){return this.m_description}assignVertexDescription(t){ns(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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("wrong geometry type");const s=t;s.m_description=et(this.m_description,this.m_description=s.m_description),s.m_XStart=et(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=et(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=et(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=et(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attributes=et(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(!ot(this.m_attributes[i],n.m_attributes[i],e))return!1;return s?this.equalsImpl(n):this.equalsImplTol(n,e)}getImpl(){return this}setAttributeBasic(t,s,n){if(this.addAttribute(t),0===t&&this.isCurve()){(s<0||s>1)&&e("");const t=new le,i=0===s?n:0,r=1===s?n:0;t.setShiftCoords(i,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,s,n),this.setEndAttribute(t,s,n)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=hs.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)}}}us.s_maxMonotonicPartParams=8;class ms extends ce{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 ls{constructor(t){this.m_geoms=[],this.m_description=P(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):e("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===i.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(t){return(t<0||t>=this.m_geoms.length)&&e("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return i.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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new H;const n=new H;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 M;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 me;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}a("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new me;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}a("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);a("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 ls({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==i.enumGeometryCollection&&e("");const s=t;if(s!==this){s.m_geoms.length=0,s.assignVertexDescription(this.m_description);for(const t of this.m_geoms)s.m_geoms.push(t.clone())}}calculateArea2D(){const t=new pt(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new pt(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return s(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 ls({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==i.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let n=0;n<this.m_geoms.length;++n)if(!this.m_geoms[n].equals(s.m_geoms[n],e))return!1;return!0}swap(t){t.getGeometryType()!==i.enumGeometryCollection&&e("");const s=t;s!==this&&(this.m_geoms=et(s.m_geoms,s.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=x(e,t);this.assignVertexDescription(s)}}function cs(t,e=-1){return new ms(t,e)}ls.type=i.enumGeometryCollection;class gs extends us{constructor(t){super(t)}}class ds extends gs{isTrue3D(){return!0}constructor(t){super(t)}}function _s(t,e,s){ps(e,t.getStartXY(),t.getEndXY(),s)}function ps(t,e,s,n){xt(e,s,t,n)}function fs(t,e){return rt(t.m_XStart,t.m_XEnd,e)}function Ps(t,e){return rt(t.m_YStart,t.m_YEnd,e)}function ys(t,e){const s=t.getStartZ(),n=t.getEndZ();return rt(s,n,e)}function xs(t,e,s){const n=Ye.constructPoint2D(t.getStartXY()),i=Ye.constructPoint2D(t.getEndXY());s.setCoordsE(i.x.subE(n.x),i.y.subE(n.y))}function Cs(t,e,s){e.value()<=.5?Ft(2,Ye.constructPoint2D(t.getStartXY()),Ye.constructPoint2D(t.getEndXY()),e,s):Vt(2,Ye.constructPoint2D(t.getStartXY()),Ye.constructPoint2D(t.getEndXY()),e,s)}function vs(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 bs(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=et(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=et(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]=et(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function Ss(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:As(t,e)?4:0}function Ds(t,e,s,n,i,r,o,a){null!==n&&Zt(n,2,Number.NaN),null!==i&&Zt(i,2,Number.NaN),null!==s&&Ht(s,Q,2);const h=ws(t,e,2,s,n,i,r,o,a);return n&&(n.length=h),i&&(i.length=h),s&&(s.length=h),h}function ws(t,e,s,n,i,r,o,a,h){const u=Is(t,e.getStartXY(),o,!1),m=Is(t,e.getEndXY(),o,!1),l=Is(e,t.getStartXY(),o,!1),c=Is(e,t.getEndXY(),o,!1);let g=0,d=0;if(!Number.isNaN(u)){let s=!1;a&&gt(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&&gt(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&&gt(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&&gt(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=et(i,i=r)),2===d&&s>=2&&i&&i[0]>i[1]&&(i[1]=et(i[0],i[0]=i[1]),r&&(r[1]=et(r[0],r[0]=r[1])),n&&(n[1]=et(n[0],n[0]=n[1]))),d;if(g>0)return 0;const _=qs(t,e,o);return Number.isNaN(_.x)?0:(n&&(n[0]=t.getCoord2D(_.x)),i&&(i[0]=_.x),r&&(r[0]=_.y),1)}function As(t,e){const s=Ms(t,e.m_XStart,e.m_YStart),n=Ms(t,e.m_XEnd,e.m_YEnd);if(s<0&&n<0||s>0&&n>0)return!1;const i=Ms(e,t.m_XStart,t.m_YStart),r=Ms(e,t.m_XEnd,t.m_YEnd);if(i<0&&r<0||i>0&&r>0)return!1;return Xs(t)>Xs(e)?Ns(t,e):Ns(e,t)}function Ts(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 Is(t,e,s,n){const i=Q.getNAN(),r=Q.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=Q.getNAN();u.setSub(e,i);let m=u.length(),l=3*m*dt();if(m<=Math.max(s,l))return n&&0===m?Number.NaN:a;if(u.setSub(e,r),m=u.length(),l=3*m*dt(),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=Q.getNAN();n.setSub(e,i);const m=n.dotProduct(u),l=8*n.dotProductAbs(u)*dt();u.leftPerpendicularThis();const g=n.dotProduct(u),d=8*n.dotProductAbs(u)*dt(),_=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=_t(n,0,1);const u=Q.getNAN();if(ps(n,i,r,u),Q.distance(u,e)<=s){if(n<.5){if(Q.distance(u,i)<=s&&Q.distance(e,i)<=s)return a}else if(Q.distance(u,r)<=s&&Q.distance(e,r)<=s)return h;return o?1-n:n}}}return Number.NaN}function Ms(t,e,s){const n=Q.getNAN();n.setCoords(e,s),n.subThis(t.getStartXY());const i=Q.getNAN();i.setSub(t.getEndXY(),t.getStartXY());const r=i.crossProduct(n),o=4*dt()*(Math.abs(i.x*n.y)+Math.abs(i.y*n.x));return r>o?-1:r<-o?1:0}function Ys(t,e,s,n){const i=n?t.m_XStart:t.m_XEnd,r=n?t.m_YStart:t.m_YEnd,o=Q.getNAN();o.x=e.getEndX()-i,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*dt()*s.dotProductAbs(o)){o.x=e.getStartX()-i,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*dt()*s.dotProductAbs(o)}return!0}function Ns(t,e){const s=Q.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!Ys(t,e,s,!1)&&(s.negateThis(),!!Ys(t,e,s,!0))}function Xs(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function qs(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 Q.getNAN();const h=4*dt()*(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*dt()*(Math.abs(r*m)+Math.abs(u*o)),g=l/a,d=Math.abs(a),_=(c*d+h*Math.abs(l))/(a*a)+dt()*Math.abs(g);if(g<-_||g>1+_)return Q.getNAN();const p=n*m-u*i,f=p/a,P=(4*dt()*(Math.abs(n*m)+Math.abs(u*i))*d+h*Math.abs(p))/(a*a)+dt()*Math.abs(f);if(f<-P||f>1+P)return Q.getNAN();let y=_t(g,0,1),x=_t(f,0,1);const C=Q.getNAN();_s(t,y,C);const v=Q.getNAN();if(_s(e,x,v),!s||Q.distance(C,v)>s){const n=Q.getNAN();xt(C,v,.5,n),y=t.getClosestCoordinate(n,!1),x=e.getClosestCoordinate(n,!1);const i=Q.getNAN();_s(t,y,i);const r=Q.getNAN();_s(e,x,r),i.subThis(r);const o=i.length(),a=(t.absNorm()+e.absNorm())*mt();if(o>Math.max(s,a))return Q.getNAN()}return new Q(y,x)}class Fs{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())&&n("");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)&&n("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&n(""),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())&&n(""),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&&n("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&&n(""),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&&n(""),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)&&n(""),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 Vs{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&&(s(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new Vs;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){s(this.uniqueUse())}setQuadTree(t){s(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){s(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function Ls(t){return!(t.isEmpty()||t.getGeometryType()!==i.enumPolyline&&t.getGeometryType()!==i.enumPolygon)&&!(t.getPointCount()<20)}function Rs(t){return!(t.isEmpty()||t.getGeometryType()!==i.enumPolyline&&t.getGeometryType()!==i.enumPolygon)&&!(t.getPointCount()<20)}function zs(t,e){return t.readPoint2D(e+4)}function Bs(t){const e=t.getGeometryType();return e===i.enumEllipticArc?10:e===i.enumBezier?4:e===i.enumRationalBezier2?5:e===i.enumBezier2?2:void h("")}function ks(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Gs(t,e,s,n){const i=t.getPathStart(e),r=t.getPathEnd(e);if(r-i<3)return;const o=2*i,a=Q.getNAN();s.queryPoint2D(o,a);const h=a.x,u=a.y,m=Q.getNAN();s.queryPoint2D(o+2,m);const l=Q.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 Ws(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var js=b;class Zs{static toSegType(t){let e=0;switch(t){case i.enumLine:e=1;break;case i.enumBezier:e=2;break;case i.enumEllipticArc:e=4;break;case i.enumRationalBezier2:e=8;break;case i.enumBezier2:e=16;break;default:h("")}return e}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 Hs extends Ee{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?i.enumPolygon:i.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){s(this.m_bPolygon);const n=this.getPathIndexFromPointIndex(t),i=this.getPathStart(n);if(i===t)return;const r=this.getPathEnd(n);(t>=r||t<i)&&e("change_ring_start_point");for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),n=js.getComponentCount(s);this.m_vertexAttributes.get(e).rotate(i*n,t*n,r*n)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(i,t,r),this.m_curveData.m_segmentParamIndex.rotate(i,t,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 F(t),s=new pt(0),n=new pt(0);if(0!==this.m_pointCount){const i=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new Fs({parent:this});for(t.stripAttributes();t.nextPath();){n.reset();const r=t.getPathIndex();Gs(this,r,i,n),Ws(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(),Gs(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 s(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(!Hs.isNonLinearSegmentFlag(s))continue;const n=this.m_curveData.m_segmentParamIndex.read(t),i=e.m_curveData.m_segmentParamIndex.read(t),r=ks(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(!ft(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=V(1,0),this.m_pathFlags=L(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 Zs),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 pt(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 pt(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return s(0),0}calculatePathLength3D(t,e){return s(0),0}copyTo(t){c(t.getGeometryType())||e(""),this!==t&&super.copyTo(t)}swap(t){s(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=Hs.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 fm;if(1!==i){if(this.isClosedPath(n)&&t===this.getPathStart(n)){o=this.getPathEnd(n)-1}this.getSegmentBuffer(o,a,!0)}const h=new fm;1!==r&&this.getSegmentBuffer(t,h,!0);const u=t+1;this.setXYCoordsNoCurves(t,e,s);const m=new Q(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,i){if(0===t&&this.hasNonLinearSegments()){i<2&&n("");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,i)}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(t,s){this===t&&e("Multi_path_impl::add");for(let e=0,n=t.getPathCount();e<n;e++)this.addPath(t,e,!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(t,s,i,r,o){if(this===t&&e("Multi_path_impl.add_segments_from_path"),o||0!==this.getPathCount()||(o=!0),s<0&&(s=t.getPathCount()-1),(s>=t.getPathCount()||i<0||r<0||i+r>t.getSegmentCountPath(s))&&n("add_segments_from_path"),0===r)return;const a=t.getPathStart(s),h=t.isClosedPath(s)&&i+r===t.getSegmentCountPath(s);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let u=r;const m=a+i;let l=m+1;o&&(u++,l--),!o&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(m)&&(t.getXY(m).equals(this.getXY(this.m_pointCount-1))||e("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 e=t.m_pathFlags.read(s);this.m_bPolygon&&(e|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,e),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 e=0,n=this.m_description.getAttributeCount();e<n;e++){const s=this.m_description.getSemantics(e),n=js.getComponentCount(s),i=t.m_description.getAttributeIndex(s);if(g>0){if(i<0||!t.m_vertexAttributes.get(i)){const t=js.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(n*c,t,g*n,n*c),h&&this.m_vertexAttributes.get(e).insertRange(n*c+g*n,t,n,n*c);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(n*c,t.m_vertexAttributes.get(i),n*l,g*n,!0,n,n*c)}h&&this.m_vertexAttributes.get(e).insertRangeFromStream(n*(c+g),t.m_vertexAttributes.get(i),n*a,n,!0,n,n*(c+g))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,n=m;s<r;s++){e+=ks(t.m_curveData.m_segmentFlags.read(n)),n++}if(e>0){this.initSegmentData(e);let s=m,n=c-(o?0:1),i=0;for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(n,e),Hs.isNonLinearSegmentFlag(e)){i++;let r=t.m_curveData.m_segmentParamIndex.read(s);const o=ks(e);this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<o;e++){const e=t.m_curveData.m_segmentParams.read(r);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,r++}this.incCurveType(e,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(t){t>=this.getPathCount()&&e("");const s=this.getPathSize(t);if(0===s)return;const n=this.getPathStart(t),i=this.isClosedPath(t);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(!Hs.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 e=0,a=this.m_description.getAttributeCount();e<a;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),i=js.getComponentCount(t);this.m_vertexAttributes.get(e).reverseRange(i*(n+r),i*(s-r),i)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const s=this.getPathCount();t<0&&(t=s-1),t>=s&&e("");const n=this.getPathStart(t),i=this.getPathSize(t);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),s=js.getComponentCount(t);this.m_vertexAttributes.get(e).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);Hs.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 e=t+1;e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e-1,t-i)}if(this.m_pathFlags)for(let e=t+1;e<=s;e++){const t=this.m_pathFlags.read(e);this.m_pathFlags.write(e-1,t)}this.m_paths.resize(s),this.m_pathFlags.resize(s),this.m_pointCount-=i,this.m_reservedPointCount-=i,t===s-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,s,n,i){this===s&&e("Multi_path_impl::insert_path");const r=this.getPathCount();if(!i&&s.hasNonLinearSegmentsPath(n))return t=this.insertPath(t,s,n,!0),this.reversePath(t),t;n>=s.getPathCount()&&e(""),t>r&&e(""),t<0&&(t=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(t,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=t<r?this.getPathStart(t):h;for(let e=0,g=this.m_description.getAttributeCount();e<g;e++){const t=this.m_description.getSemantics(e),n=s.getDescription().getAttributeIndex(t),r=js.getComponentCount(t);if(n>=0&&s.m_vertexAttributes.get(n))0!==u&&this.m_vertexAttributes.get(e).insertRangeFromStream(m*r,s.m_vertexAttributes.get(n),r*o,r,!0,r,r*h),this.m_vertexAttributes.get(e).insertRangeFromStream((m+u)*r,s.m_vertexAttributes.get(n),r*(o+u),r*(a-u),i,r,r*(h+u));else{const s=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(m*r,s,r*a,r*h)}}const l=h+a;this.m_paths.add(l);for(let e=r;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+a)}this.m_pathFlags.add(0);for(let e=r-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let c=s.getPathFlagsStreamRef().read(n);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(t,c),s.hasNonLinearSegments()){this.initSegmentData(0);let t=o,e=0;for(let n=0;n<a;n++){e+=ks(s.m_curveData.m_segmentFlags.read(t)),t++}if(e>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=L(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=V(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=R(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(Hs.isNonLinearSegmentFlag(e)){this.m_curveData.m_segmentFlags.write(n,e),this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint);const r=ks(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),t}insertPath2D(t,s,n,i,r){const o=this.getPathCount();(t>o||n<0)&&e(""),t<0&&(t=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=t<o?this.getPathStart(t):a;if(s)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,s,n,i,r,2*a);else{const t=js.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*i,2*a)}for(let e=1,u=this.m_description.getAttributeCount();e<u;e++){const t=this.m_description.getSemantics(e),s=js.getComponentCount(t),n=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(h*s,n,s*i,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+i)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,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),t}insertPathFromMultipoint(t,s,n,i,r){const o=s.getImpl(),a=this.getPathCount();(t>a||n<0)&&e("");const h=i<0?o.getPointCount()-n:i;if(h>o.getPointCount()&&e(""),n>=o.getPointCount()&&e("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const u=this.m_pointCount,m=n;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<a?this.getPathStart(t):u;for(let e=0,d=this.m_description.getAttributeCount();e<d;e++){const t=this.m_description.getSemantics(e),s=o.getDescription().getAttributeIndex(t),n=js.getComponentCount(t);if(s>=0){const s=o.getAttributeStreamRef(t);this.m_vertexAttributes.get(e).insertRangeFromStream(l*n,s,n*m,n*h,r,n,n*u)}else{const s=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(l*n,s,n*h,n*u)}}const c=u+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),this.notifyModifiedFlags(2001)}insertPoints(t,s,i,r,o,a,h){if(this===i&&e("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),r<0&&(r=i.getPathCount()-1),(t>this.getPathCount()||s>=0&&s>this.getPathSize(t)||r>=i.getPathCount()||a>i.getPathSize(r))&&n(""),!a)return;if(this.mergeVertexDescription(i.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=i.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(t));const u=this.m_pointCount;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),l=m+s;a<0&&(a=i.getPathSize(r));const c=i.getPathStart(r),g=c+a;for(let e=0,n=this.m_description.getAttributeCount();e<n;e++){const t=this.m_description.getSemantics(e),n=js.getComponentCount(t),r=i.m_description.getAttributeIndex(t);if(r<0||!i.m_vertexAttributes.get(r)){const s=js.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(n*l,s,g*n,n*u);continue}this.m_vertexAttributes.get(e)?.insertRangeFromStream(n*(m+s),i.m_vertexAttributes.get(r),n*(c+o),a*n,h,n,n*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 e=t+1,n=this.getPathCount();e<=n;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+a)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,i,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||i<0)&&n(""),!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,i,r,o,2*a);for(let n=1,u=this.m_description.getAttributeCount();n<u;n++){const t=this.m_description.getSemantics(n),s=js.getComponentCount(t),i=js.getDefaultValue(t);this.m_vertexAttributes.get(n).insertRange((h+e)*s,i,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 n=t+1,u=this.getPathCount();n<=u;n++)this.m_paths.write(n,this.m_paths.read(n)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,i,r,o){const a=s.getImpl(),h=this.getPathCount();t<0&&(t=this.getPathCount());const u=a.getPointCount();if((i<0||i>u)&&n(""),(r<0||i+r>u)&&(r=u-i),e<0&&(e=t<h?this.getPathSize(t):0),(t>h||t<h&&e>this.getPathSize(t)||t===h&&e>0||r<0)&&n(""),!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 n=0,_=this.m_description.getAttributeCount();n<_;n++){const t=this.m_description.getSemantics(n),s=js.getComponentCount(t);if(a.getDescription().getAttributeIndex(t)<0){const e=js.getDefaultValue(t);this.m_vertexAttributes.get(n).insertRange(s*c,e,d*s,s*m);continue}const h=a.getAttributeStreamRef(t);this.m_vertexAttributes.get(n).insertRangeFromStream(s*(l+e),h,s*(g+i),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 n=t+1,_=this.getPathCount();n<=_;n++){const t=this.m_paths.read(n);this.m_paths.write(n,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&n(""),t===i&&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=js.getComponentCount(e),n=js.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=i;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 i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&n(""),t===i&&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=js.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(t).insertAttributes(i*a,s,n,i*r);else{const e=js.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,n=i;s<=n;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))&&n("Multi_path.remove_point");const i=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&n("Multi_path.remove_point");const o=i+e;for(let n=0,a=this.m_description.getAttributeCount();n<a;n++)if(this.m_vertexAttributes.get(n)){const t=this.m_description.getSemantics(n),e=js.getComponentCount(t);this.m_vertexAttributes.get(n).eraseRange(e*o,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>i&&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&&i+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 n=s;n>=t+1;n--){const t=this.m_paths.read(n);this.m_paths.write(n,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}h("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),n=this.getPathEnd(t);s<n;s++)Hs.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=Hs.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=n,n}startPathCoords(t,e){this.startPathPoint(new q({x:t,y:e}))}startPath(t){this.startPathPoint(new q({pt:t}))}startPath3D(t){this.startPathPoint(new q({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new q({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&e("");const s=t.getDescription();let n;if(this.m_description!==s){this.mergeVertexDescription(s);const e=new q({vd:this.m_description});t.copyCommonAttributesTo(e),n=e}else n=t;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,n):(this.insertPoint(-1,-1,n),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=V(2),this.m_paths.write(0,0),this.m_pathFlags=L(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=D(),n=new q({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=x(this.m_description,X()),s=D(),n=new q({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=D(),s=new q({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&h("");const s=this.getPathCount();if(t>s&&e(""),!this.isClosedPath(t))return;this.m_pathFlags||h("");const n=this.m_pointCount,i=this.getPathStart(t),r=this.getPathEnd(t);if(r-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=js.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*r,this.m_vertexAttributes.get(t),s*i,s,!0,1,s*n)}for(let e=s;e>t;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,n)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&h(""),t>this.getPathCount()&&e(""),this.m_pathFlags||h(""),this.m_pathFlags.clearBits(t,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&&h(""),this.isEmpty())return;this.m_pathFlags||h("");let t=0;const e=this.getPathCount();for(let h=0;h<e;h++)this.isClosedPath(h)&&(this.getPathSize(h)>0?t++:this.m_pathFlags.clearBits(h,1));if(0===t)return;const s=this.hasNonLinearSegments();let n=0;const i=this.getPathCount(),r=this.m_description.getAttributeCount(),o=new Array(r);let a=null,u=null;for(let h=0;h<i;++h){const e=this.getPathStart(h),i=this.getPathSize(h),m=this.isClosedPath(h);if(i>0){const h=e+n;for(let s=0;s<r;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),r=js.getComponentCount(n);if(!o[s]){const e=r*(this.m_pointCount+t),i=Y(n,e);o[s]=i}o[s].writeRange(h*r,i*r,this.m_vertexAttributes.get(s),e*r,!0,1),m&&o[s].writeRange((h+i)*r,r,this.m_vertexAttributes.get(s),e*r,!0,1)}if(s){if(null===a){const e=this.m_pointCount+t;a=L(e),u=V(e)}a.writeRange(h,i,this.m_curveData.m_segmentFlags,e,!0,1),u.writeRange(h,i,this.m_curveData.m_segmentParamIndex,e,!0,1),m&&(a.write(h+i,1),u.write(h+i,-1))}}this.m_paths.write(h,e+n),m&&(this.m_pathFlags.clearBits(h,1),++n)}this.m_paths.write(i,this.m_pointCount+t),this.m_pathFlags.clearBits(i,1);for(let h=0;h<r;h++)this.m_vertexAttributes.get(h)&&this.m_vertexAttributes.set(h,o[h]);s&&(this.m_curveData.m_segmentFlags=a,this.m_curveData.m_segmentParamIndex=u),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const s=this.m_pathFlags.read(t);if(1&s||this.m_pathFlags.write(t,1|s),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);1!==s&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,s){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),s.getEndXY().equals(this.getXY(this.getPathStart(t)))||e("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(s,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(s.getDescription());const n=s.getStartXY(),r=this.getPathEnd(t)-1;n.equals(this.getXY(r))||e("close_path_with_segment: start point mismatch");const o=s.getGeometryType();if(o===i.enumLine)return void this.closePathWithLine(t);{const t=Bs(s);this.initSegmentData(t);const e=Zs.toSegType(o),n=this.m_curveData.m_segmentFlags.read(r);if(n!==e)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),s.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(e,1),1!==n?this.incCurveType(n,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(r);s.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,e)}}const n=this.m_pathFlags.read(t);1&n||this.m_pathFlags.write(t,1|n),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 s(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Hs.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 me)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=D(),i=new q({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(t,s){if(t.isClosed()||e("add_path_from_closedSegment: segment must be closed"),s){const e=t.getReversed(),s=new q;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new q;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,s){const n=t.getDescription();this.mergeVertexDescription(n);const r=D(),o=new q({vd:n,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===i.enumLine)(s||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let n=!1;if((s||this.isEmptyImpl())&&(n=!0),!n){t.getStartXY().equals(this.getXY(this.m_pointCount-1))||e("add_segment: start point mismatch")}if(n&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=D(),e=new q({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const i=Bs(t);this.initSegmentData(i),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=i;const r=Zs.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(t,s,n,i){for(let a=t;a<n-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,s,n,i);if(0!==o)for(let e=1;e<r;e++){const r=this.m_description.getSemantics(e);this.interpolateAttributesSemanticsImpl(r,t,s,n,i,o)}}interpolateAttributesSemantics(t,s,n,i,r){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===js.getInterpolation(t)&&e("angular interpolation");for(let a=s;a<i-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const o=this.calculateSubLength2D(s,n,i,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,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(t,s,n,i){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===js.getInterpolation(t)&&e("angular interpolation");const r=this.calculatePathSubLength2D(s,n,i);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,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=js.getComponentCount(t),m=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,a,m,u);const l=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,u);const c=U(js.maxComponentCount(),Number.NaN);J(c,m,0,0,u);let g=0;const d=js.getDefaultValue(t),_=js.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();O(_,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,n,i,r){s(0!==t);const o=this.querySegmentIterator(),a=js.getInterpolation(t),h=this.getPathStart(e)+n,u=this.getPathStart(e)+i;if(u===h)return;const m=js.getComponentCount(t),l=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,h,l,m);const c=U(js.maxComponentCount(),Number.NaN);this.queryAttributeAsDbl(t,u,c,m);const g=new pt(0);o.resetToVertex(h,e),o.setCirculator(this.isClosedPath(e));const d=js.getDefaultValue(t),_=U(js.maxComponentCount(),Number.NaN);J(_,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}O(a,l,c,_,0,m,f,d)}while(o.getEndPointIndex()!==u)}querySegment(t,s,n){const i=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&e("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(t){const s=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(s);return n>=this.getSegmentCountPath(s)&&e("get_segment"),this.getSegmentTypeFromPath(s,n)}getSegmentFromPath(t,e,s,n){const i=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef();let o=1;switch(r&&(o=31&r.read(i)),o){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:h("")}const a=s.get();let u,m=null;n?(m=P(),a.assignVertexDescription(m)):a.assignVertexDescription(this.m_description),u=i===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):i+1;We(a,this.getXY(i));if(Ze(a,this.getXY(u)),!n)for(let h=1,l=this.m_description.getAttributeCount();h<l;h++){const t=this.m_description.getSemantics(h),e=js.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,i,s);a.setStartAttribute(t,s,e);const n=this.getAttributeAsDbl(t,u,s);a.setEndAttribute(t,s,n)}}if(Hs.isNonLinearSegmentFlag(o)){const t=this.m_curveData.m_segmentParamIndex.read(i);a.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);zs(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(t,s,n,i=!1){const r={iSegment:-1},o=i?r:{tSegment:0};if(n.setEmpty(),this.isEmpty())return r;if((t<0||t>=this.getPathCount())&&e("query_point_along_path"),s<0)return r;const a=this.getPathSize(t);if(0===a)return r;if(1===a)return this.getPointByVal(this.getPathStart(t),n),o.tSegment=0,r.iSegment=this.getPathStart(t),r;const h=this.querySegmentIteratorAtVertex(this.getPathStart(t)),u=new pt(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(t)){const e=this.getPathStart(t);return this.getPointByVal(e,n),o.tSegment=1,r.iSegment=this.getPathEnd(t)-1,r}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,n),this.getPathSize(t)>1?(o.tSegment=1,r.iSegment=this.getPathEnd(t)-2,r):(o.tSegment=0,r.iSegment=this.getPathStart(t),r)}}queryPointsAlongPath(t,s,n,i,r,o){{let t=0;for(let a=0;a<s;++a)i&&i[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),t>n[a]&&e("query_points_along"),t=n[a]}const a=this.getPathSize(t);if(0===s||0===a)return 0;if(1===a){const e=this.getPathStart(t);return i&&this.getPointByVal(e,i[0]),o&&(o[0]=0),r&&(r[0]=e),1}const h=this.getPathStart(t),u=new pt(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(t)){const e=this.getPathStart(t),s=0;i&&this.getPointByVal(e,i[c]),o&&(o[c]=s),r&&(r[c]=e),c++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;i&&this.getPointByVal(e+1,i[c]),o&&(o[c]=s),r&&(r[c]=e),c++}return c}queryPointsAlong(t,s,n,i,r){{let o=0;for(let a=0;a<t;++a)n&&n[a].setEmpty(),i&&(i[a]=-1),r&&(r[a]=0),o>s[a]&&e("query_points_along"),o=s[a]}if(0===t)return 0;const o=new pt(0),a=this.querySegmentIterator();let h=-1,u=0,m=0,l=s[u];for(;a.nextPath();)for(;a.hasNextSegment();){h=a.getPathIndex();const e=a.nextSegment(),c=e.calculateLength2D(),g=o.getResult();for(o.add(c);o.getResult()>=l;){let o=l-g;o>c&&(o=c);const h=e.lengthToT(o);if(n&&e.queryCoord(h,n[m]),r&&(r[m]=h),i&&(i[m]=a.getStartPointIndex()),m++,u++,l=s[u],u===t)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 Fs({parent:this})}querySegmentIteratorAtVertex(t){return new Fs({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,n,i){if(n instanceof M&&s(0,"not implemented for Envelope"),n instanceof S&&s(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&e(""),this.isEmpty())return void n.setEmpty();const r=this.getAttributeStreamRef(0),o=me.constructEmpty();o.setEmpty();for(let e=2*this.getPathStart(t),a=2*this.getPathEnd(t);e<a;){const t=a-e;s(!(1&t)),o.mergePointsInterleaved(r,e/2,t/2),e+=t}if(n.setCoords({env2D:o}),this.hasNonLinearSegmentsPath(t)){const e=this.querySegmentIterator();if(e.resetToPath(t),e.nextPath())for(;e.hasNextSegment();){const t=e.nextCurve();if(!t)break;{const e=me.constructEmpty();i?t.queryEnvelope(e):t.queryLooseEnvelope(e),n.mergeEnvelope2D(e)}}else s(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=ks(4)*this.m_curveData.m_arcCount+ks(2)*this.m_curveData.m_bezierCount+ks(8)*this.m_curveData.m_rbezier2Count+ks(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(Hs.isNonLinearSegmentFlag(e)){t+=ks(e)}}const e=R(t);let s=0;for(let n=0,i=this.getPointCount();n<i;n++){const t=this.m_curveData.m_segmentFlags.read(n);if(Hs.isNonLinearSegmentFlag(t)){let i=this.m_curveData.m_segmentParamIndex.read(n);this.m_curveData.m_segmentParamIndex.write(n,s);const r=ks(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){s(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=V(0),this.m_pathFlags=L(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=V(0),this.m_pathFlags=L(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 Us(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 Zs),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){s(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),n=this.getPathEnd(t),i=this.getPathStart(t);let r=-1;const o=new Q;o.y=Number.NEGATIVE_INFINITY,o.x=Number.NEGATIVE_INFINITY;for(let s=i+0;s<n;s++){const t=e.readPoint2D(2*s);-1===o.compare(t)&&(r=s,o.setCoordsPoint2D(t))}return r}applyTransformationToPath(t,s){if(s>=this.getPathCount()&&e("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const n=this.m_vertexAttributes.get(0);if(!(s<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(s))){let e,i;return s<0?(e=0,i=this.m_pointCount):(e=this.getPathStart(s),i=this.getPathEnd(s)),n.applyTransformation(t,2*e,i-e),void this.notifyModifiedFlags(2001)}const i=new this.m_segmentBufferCTor,r=this.getPathCount();let o=s<0?0:s;do{const e=this.getPathStart(o),r=this.getPathEnd(o),a=this.isClosedPath(o),h=n.readPoint2D(2*e);if(!this.hasNonLinearSegmentsPath(o)){n.applyTransformation(t,2*e,r-e);continue}const u=Q.getNAN();for(let s=e;s<r;++s){if(1!==(31&this.m_curveData.m_segmentFlags.read(s))){const o=a&&s+1===r;o&&n.writePoint2D(2*e,h),this.getSegmentBuffer(s,i,!0),i.get().applyTransformation(t);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*e,i.get().getEndXY());continue}const o=2*s;n.queryPoint2D(o,u),t.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(t,s,n){const i=this.getPathStart(t)+s,r=this.getPathStart(t)+n;(i<0||r>this.getPointCount()-1)&&d("");const o=this.querySegmentIterator();if(i>r&&(this.isClosedPath(t)||e("cannot iterate across an open path"),o.setCirculator(!0)),i===r)return 0;let a=0,h=0;o.resetToVertex(i,t);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=me.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(t,s){this===t&&e("Multi_path_impl::add");let n=this.getPathCount();for(let e=0,i=t.getPathCount();e<i;e++)this.addPath(t,e,!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(t,s,n){const i=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(i);r>=this.getSegmentCountPath(i)&&e("getSegmentBuffer"),this.getSegmentFromPath(i,r,s,n)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,n=this.getSegmentFlagsStreamRef();let r=1;switch(n&&(r=31&n.read(s)),r){case 1:return i.enumLine;case 2:return i.enumBezier;case 4:return i.enumEllipticArc;case 8:return i.enumRationalBezier2;case 16:return i.enumBezier2;default:h("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,s=this.getPathCount();e<s;e++){const s=this.getPathStart(e),n=this.getPathEnd(e),i=n-s;for(let e=s;e<n;e++){const n=31&this.m_curveData.m_segmentFlags.read(e);if(1===n)continue;2!==n&&a("ensure_xy_monotone_segments");const r=(e-s+1)%i+s,o=this.m_curveData.m_segmentParamIndex.read(e),h=lt(Q,4);h[0]=this.getXY(e),h[3]=this.getXY(r),h[1].x=this.m_curveData.m_segmentParams.read(o),h[1].y=this.m_curveData.m_segmentParams.read(o+1),h[2].x=this.m_curveData.m_segmentParams.read(o+2),h[2].y=this.m_curveData.m_segmentParams.read(o+3),Fe(h)&&(t=!0,this.m_curveData.m_segmentParams.write(o,h[1].x),this.m_curveData.m_segmentParams.write(o+1,h[1].y),this.m_curveData.m_segmentParams.write(o+2,h[2].x),this.m_curveData.m_segmentParams.write(o+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 Vs),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=z(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Vs),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=B(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Hs.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 Zs),Hs.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 Zs),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 Zs);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=L(e,1),this.m_curveData.m_segmentParamIndex=V(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=R(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 Zs),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=Nt(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(t,n,i){(t<0||t>=this.getPointCount())&&e("Multi_path_impl.replace_segment"),s(n.isCurve());const r=this.getPathIndexFromPointIndex(t),o=this.getPathStart(r),a=(t-o+1)%this.getPathSize(r)+o;{const e=this.getXY(t),i=this.getXY(a),r=!e.isEqualPoint2D(n.getStartXY())||!i.isEqualPoint2D(n.getEndXY());s(!r)}this.replaceSegmentImpl(t,a,n,i)}replaceSegmentImpl(t,e,n,i){const r=n.getDescription();this.mergeVertexDescription(r);const o=U(32,Number.NaN),a=new q({vd:r,attribBuffer:o,initDefaultValues:!1}),h=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),u=ks(h),m=Bs(n);let l,c=!1;u>=m?(s(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=n.getGeometryType(),d=Zs.toSegType(g);i||(n.queryStart(a),this.setPointByValNoCurves(t,a),n.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&&n.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(t,s,n){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(s<0||s>1)&&e("");const t=new le,i=0===s?n:0,r=0===s?0:1;t.setShiftCoords(i,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,s,n)}}Hs.st_totalCurveCount=0;class Us{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new me(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=me.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 Os extends Hs{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=fm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=fm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=fm):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=fm,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=fm,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):h("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=fm)}getBoundary(){return Js(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Os.type}getDimension(){return 1}createInstance(){return new Os({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Os.type=i.enumPolyline;var Qs=i;function Ks(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===Qs.enumPolygon)return 0!==t.calculateArea2D();if(s===Qs.enumPolyline)return $s(t.getImpl(),e,!0).bNotEmpty;if(s===Qs.enumEnvelope)return!0;if(m(s))return!!t.isClosed();if(l(s))return!1;if(s===Qs.enumGeometryCollection){const s=t;for(let t=0,n=s.getGeometryCount();t<n;t++)if(Ks(s.getGeometry(t),e))return!0;return!1}a("")}function Js(t,e){const s=t.getGeometryType();if(s===Qs.enumPolygon){const e=new Os({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===Qs.enumPolyline)return $s(t.getImpl(),e,!1).boundary;if(s===Qs.enumEnvelope){const e=new Os({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(m(s)){const e=new Se({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new q;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===Qs.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(s))return new q({vd:t.getDescription()});a("")}function $s(t,e,s){const n=!1,i=t;let r=null;if(s||(r=new Se({vd:i.getDescription()})),!i.isEmpty()){const t=new W(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 G,n=i.getAttributeStreamRef(0),o={userSort(t,e,s){const i=Q.getNAN(),r=Q.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 q;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,Yt()),h=i):t.write(i,Yt()),u++;else{if(1&u){if(s)return{bNotEmpty:!0,boundary:new Se({})}}else t.write(h,Yt());a=e,h=i,u=1}}if(1&u){if(s)return{bNotEmpty:!0,boundary:new Se({})}}else t.write(h,Yt());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==Yt();e++)i.getPointByVal(t.read(e),m),r.add(m)}}}return s?{bNotEmpty:n,boundary:new Se({})}:{bNotEmpty:n,boundary:r}}function tn(t,e,n,i){const r=4*dt()*(Math.abs(e.vmin)+Math.abs(e.vmax)),o=dt();if(1===t.getMaxDerivative()){s(n>0);const o=hn(t,0,e,dt(),r);return i[0]=o.root,o.cRoots}let a,h=[];const u=new H(e.vmin-r,e.vmax+r);h.push(new Q(u.vmin,u.vmax));let m=0;for(let s=t.getMaxDerivative()-1;s>=0;s--){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(s===t.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:g}=hn(t,s,H.construct(a[u][0],a[u][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:g}=un(t,s,H.construct(a[u][0],a[u][1]),o,.5*r)),1===g){if(0===s){if(m<n){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=Q.getNAN();t[0]=a[u][0],t[1]=l,h.push(t);const e=Q.getNAN();e[0]=l,e[1]=a[u][1],h.push(e)}continue}}h.push(a[u])}}return m}function en(t,e,s,n){const i=new at,r=cn(new at(t),new at(e),s,i);return n[0]=i.value(),r}function sn(t,e,s,n,i,r){const o=lt(at,2),a=gn(new at(t),new at(e),new at(s),n,i,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function nn(t,e,s,n,i,r,o){const a=lt(at,3),h=dn(new at(t),new at(e),new at(s),new at(n),i,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function rn(t,e,s,n,i,r,o,a){return an(t,e,s,n,i,r,o,a)}function on(t,e,s,n,i,r){return ln(t,e,s,n,i,r)}function an(t,e,s,n,i,r,o,a){const h=U(s*s,Number.NaN);h.fill(0),J(a,n,0,0,s);const u=U(s,Number.NaN),m=U(s,Number.NaN),l=U(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=mn(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+_)*zt(n-c-o)<zt(n-_)*o){c=mn(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 hn(t,e,s,n,i){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,a=s.vmax,u=0,m=Number.MAX_VALUE,l=t.getValue(e,o),c=t.getValue(e,a),g=0,d=0,_=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(r.funcAtRoot=l,r.root=o,r.cRoots=0===l?1:0,r):(r.funcAtRoot=c,r.root=a,r.cRoots=0===c?1:0,r);Math.abs(l)<Math.abs(c)&&(a=et(o,o=a),c=et(l,l=c)),u=o,g=l;let p=!0,f=0;for(;0!==c&&Math.abs(o-a)>n*Math.abs(a)+i;f++){let s=f>64;if(!s){d=l!==g&&c!==g?o*c*g/((l-c)*(l-g))+a*l*g/((c-l)*(c-g))+u*l*c/((g-l)*(g-c)):a-c*(a-o)/(c-l);const t=(3*o+a)/4;if(s=!(d>t&&d<a||d>a&&d<t),!s){const t=n*Math.abs(a)+i;if(p){const e=Math.abs(a-u);s=Math.abs(d-a)>=.5*e||e<t}else{const e=Math.abs(u-m);s=Math.abs(d-a)>=.5*e||e<t}}}if(s?(d=(o+a)/2,p=!0):p=!1,_=t.getValue(e,d),0===_)return r.root=d,r.funcAtRoot=_,r.cRoots=1,r;if(!s){const s=o-d,n=d-a;if(Math.abs(s)>10*Math.abs(n)){let s=a+3*n;for(let n=0;n<2;n++){const n=t.getValue(e,s);Nt(l)*Nt(n)>0?(o=s,l=n):s=rt(o,a,.75)}}else if(Math.abs(n)>10*Math.abs(s)){let n=o-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,n);Nt(c)*Nt(s)>0?(a=n,c=s):n=rt(o,a,.25)}}}m=u,u=a,g=c,Nt(l)*Nt(_)<0?(a=d,c=_):(o=d,l=_),Math.abs(l)<Math.abs(c)&&(a=et(o,o=a),c=et(l,l=c)),128===f&&h("Root_finder iterations exceeded")}return r.root=a,r.funcAtRoot=c,r.cRoots=1,r}function un(t,e,s,n,i){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,a=t.getValue(e,o),u=s.vmax,m=t.getValue(e,u);if(a>=0&&m>=0||a<=0&&m<=0)return Math.abs(a)<Math.abs(m)?(r.funcAtRoot=a,r.root=o,r.cRoots=0===a?1:0,r):(r.funcAtRoot=m,r.root=u,r.cRoots=0===m?1:0,r);m<0&&(m=et(a,a=m),u=et(o,o=u));let l=.5*(o+u),c=Math.abs(u-o),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 E=32;let S=0;for(;++S<100;){let s;S>E||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(o-u)>t){const e=Math.min(o,u),n=Math.max(o,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-o),s=l,l=o+g,n=o===l||u===l}while(0);else for(;;){g=x*d/_,s=l,l-=g,n=l===s;const t=Math.min(o,u),e=Math.max(o,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=o,h=u;d<0?(a=d,o=l):(m=d,u=l),b===y&&(o===r&&u===h||v>1&&Math.abs(g)>=.5001*Math.abs(c))?C++:C=0,b===p?(P++,v=0):(P=0,v++)}return 100===S&&h("Root_finder iterations exceeded"),r.root=l,r.funcAtRoot=d,r.cRoots=1,r}function mn(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=U(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=et(o,o=h)),o>u&&(u=o),h<m&&(m=h)}}let l=0;const c=(Math.abs(u)+Math.abs(m))*dt()*100,g=U(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=on(_,null,u,0,m,c));const p=_(l);for(let f=0,P=o;f<P;f++)s[f]=_t(g[f],i[f],r[f]);return p}function ln(t,e,s,n,i,r){const o=ue();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&&(_=et(p,p=_),d=et(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 cn(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 gn(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 cn(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]=et(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(Lt));if(o.lt(ut))return 0;const a=new at(e.value()>=0?1:-1),h=o.clone().sqrtThis(),u=new at(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let m=0;r[0].setE(u.divE(t));const l=new at(r[0].value()),c=new at(t.value()).mulE(l).addE(new at(e.value()).mulE(l).addE(new at(s.value())));return c.isZero()||Cn(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 at(t.value()).mulE(l).addE(new at(e.value()).mulE(l).addE(new at(s.value())))),c.isZero()||Cn(r[m],t,e,s,r[m]),n.containsCoordinate(r[m].value())&&m++,2===m&&r[0].value()>r[1].value()&&(r[1]=et(r[0],r[0]=r[1])),m):m}function dn(t,e,s,n,i,r,o){if(0===t.value()){return gn(e,s,n,i,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=gn(t,e.addE(t),n.negate(),i,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(ht)&&(o[s-1]=et(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 vn(t,e,s,n,i,o)}function _n(t,s,n,i,r,o){return(o<s||s<0)&&e("nth_degree_real_roots"),bn(t,s,n,i,r)}function pn(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 fn{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 pt(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 pt(0),n=new at(1),i=new at(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 at(1),n=new at(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 Pn(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=et(o,o=a),i=et(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 yn(t,e,s,n,i,r,o,a){return Pn(t,e,s.value(),pn(n,i,r,o),a,!1)}class xn{constructor(t,e,s){this.coefs=lt(at,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new at(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new at(t);return at.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 at(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 Cn(t,e,s,n,i){return Pn(0,0,t.value(),new xn(e,s,n),i,!0)}function vn(t,e,s,n,i,r){const o=lt(at,3);let a=0;const u=e.negate().divThisE(t.clone().mulThis(3));i.containsCoordinate(u.value())&&(o[0].setE(u),a=1);const m=lt(at,2),l=gn(t.mul(3),e.mul(2),s,i,!1,m);if(l<0)return n.isZero()?-1:0;for(let h=0;h<l;h++)i.containsCoordinate(m[h].value())&&o[a++].setE(m[h]);tt(o,0,a,(t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0);const c=lt(at,5);c[0].set(i.vmin);for(let h=0;h<a;h++)c[1+h].setE(o[h]);c[1+a].set(i.vmax);const g=a+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 o=pn(t,e,s,n);i.setError(o.estimateError(i.value())),r[_]=i,_++,d++}}for(let p=d;p<g;p++){const o=c[p].clone(),a=t.clone().mulThisE(o).addThisE(e).mulThisE(o).addThisE(s).mulThisE(o).addThisE(n).isZero();if(a||!c[p].eq(c[p-1])){if(a||yn(c[p-1].value(),c[p].value(),c[p-1].clone().addThisE(c[p]).divThisByPower2(2),t,e,s,n,o)){if(_>0&&o.eq(r[_-1]))continue;if(_>=3&&h("cubic_polynomial_solver_too_many_roots"),a){const i=pn(t,e,s,n);o.setError(i.estimateError(o.value()))}r[_]=o,_++}if(c[p].value()===i.vmax)break;a&&p++}}return _}function bn(t,e,s,n,i,r){const o=new fn(t,e,s,dt());let a=0;if(2===o.truePower)a=gn(t[2],t[1],t[0],s,n,i);else if(1===o.truePower)a=cn(t[1],t[0],s,i[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=tn(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 Sn extends gs{constructor(t){return void 0===t||vt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new Q(0,0),void(this.m_weights=[1,0,1])):(t.fromPoint&&t.weight?t={fromPoint:t.fromPoint,controlPoint1:t.controlPoint1,toPoint:t.toPoint,weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weight?t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weights&&(t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:t.weights[0],weight1:t.weights[1],weight2:t.weights[2]}),t.fromPoint&&t.weight0?(super({start:t.fromPoint,end:t.toPoint}),(t.weight0<=0||t.weight1<0||t.weight2<=0)&&e("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void a("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),la(this)}constructWeights(t,e,s,n,i,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,n,i,r),la(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),la(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return i.enumRationalBezier2}queryEnvelope(t){if(t instanceof me){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Va(this);if(null!==e){const s=new Q;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[],s=lt(Q,3);this.queryControlPoints(s),da(s,this.m_weights,e);const n=new Q;for(const i of e)this.queryCoord2D(i,n),t.mergeNe(n)}}}applyTransformation(t){if(t instanceof le){const e=lt(Q,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 Sn({vd:this.m_description})}calculateLength2D(){return _a(this,1,!1)}calculateLowerLength2D(){return Q.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return Q.distance(this.getStartXY(),this.m_cp)+Q.distance(this.getEndXY(),this.m_cp)}return Q.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){lh(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void _s(new pm({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void _s(new pm({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const n=lt(Q,3);this.queryControlPoints(n),_h(n,this.m_weights,t,e)}getCoordX(t){const e=new Q;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new Q;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const n=new fm;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){Sa(this,t,e)}cutBezierIgnoreAttributes(t,s,n){(t<0||s>1||t>s)&&e("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const i=lt(Q,3);this.queryControlPoints(i);const r=[0,0,0];Qa(i,this.m_weights,t,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 Ct(r,o,a,i,En.getDefaultValue(e))}getClosestCoordinate(t,e){return Ra(this,t,H.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return Ra(this,t,e,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,n){t.length<2&&e("");const i=ga(this);let r=0;if(2===i.specialPointsCount())return 0;s(t.length>=i.specialPointsCount()-1);for(let e=1,s=i.specialPointsCount();e<s;++e)this.queryCut(i.specialPoints[e-1],i.specialPoints[e],t[r],n),r++;for(let e=0;e<r;++e){Za(t[e].get())}return r}intersectionWithAxis2D(t,e,s,n){s&&(s.length=9),n&&(n.length=9);const i=new Array(3),r=lt(at,2),o=new H(0,1);let a=0;const h=lt(Q,3);if(this.queryControlPoints(h),t){if(i[0]=new at(h[0].y).sub(e).mul(this.m_weights[0]),i[1]=new at(h[1].y).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new at(h[2].y).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=gn(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 at(h[0].x).sub(e).mul(this.m_weights[0]),i[1]=new at(h[1].x).sub(e).mul(this.m_weights[1]),i[2]=i[0].subE(i[1].mul(2)).addE(new at(h[2].x).sub(e).mul(this.m_weights[2])),i[1]=i[1].subE(i[0]).mulThisByPower2(2),a=gn(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&&tt(s,0,a,Bt);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 n=[Number.NaN,Number.NaN],i=this.intersectionWithAxis2D(!0,t,n,null);return s(2!==i),-1===i?e:n[0]}isCurve(){return!0}isDegenerate(t){return Re(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof me)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=me.constructEmpty();this.queryEnvelope(t);const s=H.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=lt(Q,3);this.queryControlPoints(s);const n=[0,0,0];Qa(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 _a(this,t,!0)}lengthToT(t){return Ta(this,t)}calculateWeightedAreaCentroid2D(t){const e=Na(this),s=Ia(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new Q;return this.isDegenerate(0)?(t.setCoords(0,0),t):Fa(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Ua(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=lt(Q,3);return this.queryControlPoints(s),gh(s.map(t=>Xe.constructPoint2D(t)),this.m_weights.map(t=>it.constructDouble(t)),it.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=lt(Q,3);return this.queryControlPoints(e),wa(e,this.m_weights,t)}getDerivative(t){const e=_t(t,0,1),s=lt(Q,4);return pa(this,1,e,s),s[1]}getCurvature(t){const e=lt(Q,4);pa(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=lt(Q,3);return this.queryControlPoints(t),ja(t)}getMonotonicPartParams(t,s){const n=ga(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();t<i&&e("");for(let e=0;e<i;e++)s[e]=n.specialPoints[e];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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=et(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]=et(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=lt(Q,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(Q.distance(e[0],e[1])+Q.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=lt(Q,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return Ia(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return s(0),0}queryEnvelopeW(t,e){Ga(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=lt(Q,3);this.queryControlPoints(e);const s=Q.sqrDistance(e[1],e[0]),n=Q.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=lt(Q,3);this.queryControlPoints(e);const s=Q.sqrDistance(e[1],e[0]),n=Q.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 Za(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],La(e,Va(this))}reverseImpl(){this.m_weights[2]=et(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=lt(Q,3);this.queryControlPoints(n);const i=lt(Q,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=et(this.m_cp,this.m_cp=e.m_cp),e.m_weights=et(this.m_weights,this.m_weights=e.m_weights),ca(this,e)}afterCompletedModification(){la(this)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return ka(this,t,e,s)}endPointModified(){la(this)}clearEndPointModified(){}setCpsAndWeights(t,s,n,i,r,o){(i<=0||o<=0||r<0)&&e("weights"),(t.isNAN()||s.isNAN()||n.isNAN())&&e("NAN control points in bezier are not supported"),this.setStartXY(t),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])}}Sn.type=i.enumRationalBezier2;var Dn=b;class wn extends gs{constructor(t){void 0===t||vt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new Q(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()):h("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),ii(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),ii(this)}getGeometryType(){return i.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=yi(this);if(null!==e){const s=new Q;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s)}else{const e=[];ai(this,e);const s=new Q;for(const n of e)this.queryCoord2D(n,s),t.mergeNe(s)}return}a("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){const e=lt(Q,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()}s(0)}createInstance(){return new wn({vd:this.m_description})}calculateLength2D(){return hi(this,1,!1)}calculateLowerLength2D(){return Q.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return Q.distance(this.getStartXY(),this.m_cp)+Q.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const n=lt(Q,3);this.queryControlPoints(n),ji(n,t,e,s)}queryCoord2DE(t,e){Zi(this,t,e)}queryCoord2DMP(t,e){s(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){const e=new Q;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=bt(this.getStartX(),this.m_cp.x,t),s=bt(this.m_cp.x,this.getEndX(),t);return bt(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 Q;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=bt(this.getStartX(),this.m_cp.x,t),s=bt(this.m_cp.x,this.getEndX(),t);return bt(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 fm;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=Dn.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=Dn.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){Ui(this,t,e)}cutBezierIgnoreAttributes(t,s,n){if((t<0||s>1||t>s)&&e("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===s)return n.setStartXY(this.getStartXY()),n.m_cp.assign(this.m_cp),void n.setEndXY(this.getEndXY());const i=lt(Q,3);this.queryControlPoints(i),Mi(i,t,s,i),n.constructPoints(i)}splitBezierIgnoreAttributes(t,e,n){s(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=Dn.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return Ct(r,o,a,i,Dn.getDefaultValue(e))}getClosestCoordinate(t,e){return Ci(this,t,H.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Ci(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,n){t.length<2&&e("");const i=oi(this);let r=0;if(2===i.specialPointsCount())return 0;s(t.length>=i.specialPointsCount()-1);for(let e=1,s=i.specialPointsCount();e<s;++e)this.queryCut(i.specialPoints[e-1],i.specialPoints[e],t[r],n),r++;for(let e=0;e<r;++e){wi(t[e].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=lt(at,3),r=lt(at,2),o=new H(0,1);let a=0;if(t){if(i[0]=new at(this.getStartY()).sub(e),i[1]=new at(this.m_cp.y).subE(new at(this.getStartY())).mulThisByPower2(2),i[2]=new at(this.getStartY()).add(this.getEndY()).subE(new at(this.m_cp.y).mulThisByPower2(2)),a=gn(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 at(this.getStartX()).sub(e),i[1]=new at(this.m_cp.x).subE(new at(this.getStartX())).mulThisByPower2(2),i[2]=new at(this.getStartX()).add(this.getEndX()).subE(new at(this.m_cp.x).mulThisByPower2(2)),a=gn(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&&St(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 n=[0,0],i=this.intersectionWithAxis2D(!0,t,n,null);return s(2!==i),-1===i?e:n[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return Re(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new me;this.queryEnvelope(t);const s=new H;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=lt(Q,4);this.queryControlPoints(s),Mi(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 hi(this,t,!0)}lengthToT(t){return _i(this,t)}calculateWeightedAreaCentroid2D(t){const e=lt(Q,3);Bi(this,e);const s=e[2],n=e[1],i=new Q,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=pi(this);return i.x+=(e[0].x-t.x)*o,i.y+=(e[0].y-t.y)*o,i}calculateWeightedCentroid2D(){const t=new Q;return this.isDegenerate(0)?(t.setCoords(0,0),t):Pi(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Ti(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(t){for(let s=0;s<3;s++)t[s].isNAN()&&e("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=_t(t,0,1);let s=ci(this,1,e);return s.isZero()&&(s=ci(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return ci(this,1,_t(t,0,1))}getCurvature(t){const e=ci(this,1,t),s=ci(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!==rm(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const n=new me;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new Q;this.queryCoord2D(i,r);return Q.distance(r,t)<=e}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,s){const n=oi(this),i=n.specialPointsCount();if(!s)return n.specialPointsCount();t<i&&e("");for(let e=0;e<i;e++)s[e]=n.specialPoints[e];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){et(this.m_XStart,this.m_XStart=this.m_XEnd),et(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]=et(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=lt(Q,3);this.queryControlPoints(e);const s=e[2].sub(e[0]),n=s.length();if(Q.distance(e[0],e[1])+Q.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=lt(Q,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return pi(this)}absNorm(){return Ni(this)}queryEnvelopeW(t,e){const s=lt(Q,3);this.queryControlPoints(s),Si(s,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return $i(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 tr(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return wi(this)}setCoordsForIntersector(t,e,s){Yi(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),xi(e,yi(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=et(this.m_cp,this.m_cp=e.m_cp),ri(this,e)}afterCompletedModification(){ii(this)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return bi(this,t,e.length,e,s)}endPointModified(){ii(this)}clearEndPointModified(){}}wn.type=i.enumBezier2;class An{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),s(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(ae(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 s(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 s(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 s(0),this}subNumber0(t){return s(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 s(0),this}mulBigint0(t){return s(0),this}mulBigIntThis(t){return s(0),this}mulInt320(t){return s(0),this}div0(t){return s(0),this}absThis(){return s(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=lt(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 s(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){s(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(it.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 Tn extends An{constructor(t){super(void 0===t?{zeroCtor:it}:{...t,zeroCtor:it})}clone(){return new Tn({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 In extends An{constructor(t){super(void 0===t?{zeroCtor:Tn}:{...t,zeroCtor:Tn})}clone(){return new In({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new Tn({coef0:t[s]}));return this.updatePower(),this}}function Mn(){return{polypoly1:new In,polypoly2:new In,polyX2:new Tn,polyY2:new Tn,polyX2Deriv:new Tn,polyY2Deriv:new Tn,polypolyX1:new In,polypolyY1:new In,polypolyX1Deriv:new In,polypolyY1Deriv:new In,lazyPolypolyD1:new In,lazyPolypolyD1Deriv:new In,lazyPolyD2:new Tn,lazyPolyD2Deriv:null,polypoly11:new In,polypoly12:new In,tempPp:new In,tempPp1:new In,tempPp2:new In,tempP:new Tn,tempP1:new Tn,tempP2:new Tn}}function Yn(t,e,n,i,r,o,a,u,m,l,c,g,d,_,p,f,P,y,x,C=!1){const v=Mn();v.polyX2.construct(a,u),v.polyY2.construct(m,l),v.polypolyX1.constructFromMPValues(t,e),v.polypolyY1.constructFromMPValues(n,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)),r?(v.lazyPolypolyD1.constructFromMPValues(r,o),v.lazyPolypolyD1Deriv=new In({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(),r&&(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&&(s(null===v.lazyPolyD2Deriv),v.lazyPolyD2Deriv=new Tn({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 E=[];P||(P=[]),f||(f=[]),kn(v.polypoly11,v.polypoly12,v.tempP);const S=64,D=te.ldexp(-59).toDouble(),w=[];let A=Gn(v.tempP,d,p,D,S,w,y,y);if(A<0)return-1;for(let Y=0;Y<A;Y++){const t=v.tempP1,e=v.tempP2;Tn.evaluateCoefs(v.polypoly11,w[Y],t);const n=ee(t.m_elements,t.power()+1);n.sort((t,e)=>t.compare(e)),Tn.evaluateCoefs(v.polypoly12,w[Y],e);const i=ee(e.m_elements,e.power()+1);i.sort((t,e)=>t.compare(e));const r=n[0],o=n.at(-1),a=i[0],u=i.at(-1);o.subThis(r),u.subThis(a);const m=o.subThis(u).GEZ(),l=58,c=te.ldexp(-59).toDouble(),g=[];let p;if(p=Gn(m?t:e,d,_,c,l,g,y,y),p<0&&h("mp_curve_proximity"),p>0){const n=m?e:t;for(let t=0;t<p;t++){let e;if(m){const s=v.tempP;Tn.evaluateCoefs(v.polypoly12,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}else{const s=v.tempP;Tn.evaluateCoefs(v.polypoly11,w[Y].addDouble(Number.EPSILON),s),e=s.evaluate(g[t])}const i=n.evaluateDerivative(g[t]).abs().mulDoubleThis(Number.EPSILON),r=n.evaluate(g[t]);i.addThis(e.sub(r).absThis()),i.ldexpThis(3),r.absThis(),r.lt(i)?E.push(Mt(g[t].toDouble(),w[Y].toDouble())):s(r.gte(i))}}}A=E.length,kn(v.polypoly1,v.polypoly2,v.tempP);const T=[];let I=Gn(v.tempP,d,p,D,S,T);I<0&&(I=0);for(let s=0;s<I;s++){Tn.evaluateCoefs(v.polypoly1,T[s],v.tempP1);const t=[];let e=Gn(v.tempP1,d,_,D,S,t);if(0!==e)if(Tn.evaluateCoefs(v.polypoly2,T[s],v.tempP2),e<0){if(e=Gn(v.tempP2,d,_,D,S,t),e<0)continue;for(let n=0;n<e;n++)b.push(Mt(t[n].toDouble(),T[s].toDouble()))}else{const n=v.tempP2.absEvaluate(te);n.mulThis(it.constructDouble(1e-12));for(let i=0;i<e;i++){const e=v.tempP2.evaluate(t[i]);e.absThis(),e.lt(n)&&b.push(Mt(t[i].toDouble(),T[s].toDouble()))}}}if(I=b.length,0===A&&0===I)return 0;b=b.concat(E),b.sort((t,e)=>C?Bt(t.second,e.second):Bt(t.first,e.first));const M=se(b,(t,e)=>t.first===e.first&&t.second===e.second);b=b.slice(0,M),f.length=0,P.length=0;for(const s of b)f.push(s.first),P.push(s.second);return s(f.length===P.length),P.length}function Nn(t,e,s,n,i,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(it.constructInt32(1)).isZero();if(1===t.power()){const s=Fn(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 Vn(t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(3===t.power()){return Ln(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}if(4===t.power()){return Rn(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),n,e,a,r)}return Un(t,e,s,n,a,i,r,o)}function Xn(){return{polyIntersect:new Tn,polyX1:new Tn,polyY1:new Tn,polyX1Deriv:new Tn,polyY1Deriv:new Tn,lazyPolyD1:new Tn,lazyPolyD1Deriv:new Tn,tempP:new Tn,tempP1:new Tn,tempP2:new Tn,polypoly1Proximity:new In,polypoly2Proximity:new In}}function qn(t,e,s,n,i,r,o,a,h,u,m,l,c){const g=Xn();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($t),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=Gn(g.polyIntersect,a,h,f,p,P,l,l);if(y<0)return-1;for(const b of P)_.push(b.toDouble());kn(g.polypoly1Proximity,g.polypoly2Proximity,g.tempP),p=2*g.tempP.power()+58,P.length=0;let x=Gn(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,J(m,C,0,0,C.length),Gt(m);const v=se(m,(t,e)=>0===Bt(t,e));return m.length=v,m.length}function Fn(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 Vn(t,e,s,n,i,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),i.containsCoordinate(1)?1:0;return Fn(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]=et(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=it.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(it.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]=et(o[0],o[0]=o[1]))),c}function Ln(t,e,n,i,r,o,a,h){if(t.isZero()){return Vn(e,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]=et(h[t],h[t]=h[s-1]),s--);e=s}return tt(h,0,e,(t,e)=>t.compare(e)),e};if(i.isZero()){let s=0;o.containsCoordinate(0)&&(h[0].setInt32(0),s=1);return u(Vn(t,e,n,r,o,a,h.slice(1)),s)}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(Vn(t,n,a,r,o,m,h.slice(s)),s)}const m=new it,l=new it,c=new it,g=e.clone();if(g.isZero())l.setThis(n),l.divThis(t),c.setThis(i),c.divThis(t);else{g.divThis(t).divDoubleThis(3).negateThis();const s=e.clone();s.sqrThis();const r=t.clone();r.sqrThis(),l.setThis(t),l.mulThis(n).mulDoubleThis(3).subThis(s).divThis(r).divDoubleThis(3),c.setThis(s),c.mulThis(e),c.ldexpThis(1),m.setThis(t),m.mulThis(e).mulThis(n).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),Qn(o,r,h,1)):(h[0].setThis(it.cubicRoot(t,r).add(g)),Qn(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),Qn(o,r,h,2);if(d.GZ())return d.setThis(it.sqrt(d,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.addThis(d),h[0].setThis(it.cubicRoot(m,r+8)),m.setThis(c),m.ldexpThis(-1).negateThis(),m.subThis(d),h[0].addThis(it.cubicRoot(m,r+8)),h[0].addThis(g),Qn(o,r,h,1);m.setThis(l),m.divDoubleThis(3).negateThis(),s(m.GEZ());const _=it.sqrt(m,r+8),p=_.clone();p.negateThis(),p.addThis(g),_.addThis(g);const f=it.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),P=it.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),y=new Tn({zeroCtor:it});y.construct0(i),y.addElement(n),y.addElement(e),y.addElement(t);const x=new Tn({copy:y});x.derivative1This();let C=0;const v=lt(it,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 E=52,S=Number.EPSILON;for(;E<b;)2*E<=b?(S*=S,E*=2):(S*=Number.EPSILON,E+=52);E+=2;let D=0,w=!1;for(let s=1;s<C;s++){if(Zn(y,x,v[s-1],v[s],S,E,h[0])){D=1,w=s+1<C;break}}if(!D)return 0;if(w){const t=new Tn({zeroCtor:it,coef0:h[0]});t.negateThis(),t.addElement(te);const e=new Tn({zeroCtor:it}),n=new Tn({zeroCtor:it});y.div(t,e,n),s(2===e.power()),s(0===n.power());const i=Vn(e.getElement(2),e.getElement(1),e.getElement(0),r,o,!1,h.slice(1));s(i>=0&&i<=2),D+=i}return Qn(o,r,h,D)}function Rn(t,e,s,n,i,r,o,a,h){if(t.isZero())return Ln(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]=et(h[t],h[t]=h[s-1]),s--);e=s}return tt(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(Ln(t,e,s,n,r,o,a,h.slice(i)),i)}const m=new Tn({zeroCtor:it,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 Tn({zeroCtor:it,coef0:it.constructInt32(-1)});e.addElement(it.constructInt32(1));const s=new Tn({zeroCtor:it}),n=new Tn({zeroCtor:it});m.div(e,s,n);return u(Ln(3===s.power()?s.getElement(3):$t.clone(),s.power()>=2?s.getElement(2):$t.clone(),s.power()>=1?s.getElement(1):$t.clone(),s.getElement(0),r,o,s.evaluate(te).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=Ln(3===m.power()?m.getElement(3):$t.clone(),m.power()>=2?m.getElement(2):$t.clone(),m.power()>=1?m.getElement(1):$t.clone(),m.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),tt(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=On(m),d=it.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(g.lt(d)?g:d).mul(it.constructDouble(c)).toDouble(),Un(m,o,c,l,a,!1,h,4)}function zn(t,e){let s=t,n=e;n.power()>s.power()&&(n=et(s,s=n));const i=s.power()-n.power(),r=new Tn({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 Tn({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(),Bn(s)}function Bn(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function kn(t,e,s){const n=t.clone(),i=e.clone();for(Bn(n),Bn(i);0!==n.power()||0!==i.power();)zn(n,i);s.assignMove(n.getElement(0))}function Gn(t,e,s,n,i,r,o=!1,a=!1){r.length=0;const h=t.power(),u=lt(it,2*h+4),m=Nn(t,s||H.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 Wn(t,e,n){if(s(n>=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 jn(t,e,n,i){if(t.power()<2)return Wn(t,n,i);s(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 s=t.getElement(1);return s.negateThis(),s.divThis(t.getElement(2)),s.ldexpThis(-1),s.limitPrecisionThis(e),n[0].setThis(s),1}s(i>=2),r=it.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)?(n[0].setThis(h),n[1].setThis(u)):(n[1].setThis(h),n[0].setThis(u)),2}function Zn(t,e,s,n,i,r,o){let a=s.clone(),u=n.clone();a.limitPrecisionThis(r),u.limitPrecisionThis(r);let m=t.evaluate(a);m.limitPrecisionThis(r+2);let l=t.evaluate(u);if(l.limitPrecisionThis(r+2),m.GEZ()&&l.GEZ()||m.LEZ()&&l.LEZ())return m.absLessAbs(l)?(o=a,m.isZero()):(o=u,l.isZero());const c=l.LZ();c&&(l=et(m,m=l),u=et(a,a=u));const g=c?u:a,d=c?a:u,_=a.add(u).ldexpThis(-1);_.limitPrecisionThis(r);const p=u.sub(a);p.limitPrecisionThis(r),p.absThis();const f=p.clone();let P=t.evaluate(_),y=e.evaluate(_);const x=new Tn({copy:t}),C=new Tn({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),n=te.clone();n.ldexpThis(-(r+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(r+2),y.limitPrecisionThis(r+2)}const v=1,b=4;let E=b;const S=2;let D=1,w=0,A=0,T=v;const I=32,M=it.constructDouble(.25*i),Y=it.constructDouble(.5001);let N=0;const X=300;for(;++N<X;){if(N>I&&w>0||y.isZero()||T===S&&w>1||T===v&&E<b)T=v,D>1&&D--;else if(T=S,A>1){const t=p.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&D++}p.setThis(f);const t=new it;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(r),f.setThis(_.sub(t));break}if(_.equals(d)){t.setThis(_),_.setThis(d.sub(e)),_.limitPrecisionThis(r),f.setThis(_.sub(t));break}}}f.setThis(u.sub(a)),f.ldexpThis(-1),f.limitPrecisionThis(r),t.setThis(_),_.setThis(a.add(f)),_.limitPrecisionThis(r),_.lt(g)?_.setThis(g):_.gt(d)&&_.setThis(d),e=a.equals(_)||u.equals(_)}while(0);else for(;;){if(f.setThis(P.div(y)),f.limitPrecisionThis(r),1!==D&&f.mulDoubleThis(D),t.setThis(_),_.subThis(f),_.limitPrecisionThis(r),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(r+2));break}P=x.evaluate(_),P.limitPrecisionThis(r+2),y=C.evaluate(_),y.limitPrecisionThis(r+2);const s=a.clone(),n=u.clone();P.LZ()?(m.setThis(P),a.setThis(_)):(l.setThis(P),u.setThis(_)),T===S&&(a.equals(s)&&u.equals(n)||A>1&&!f.absLessAbs(Y.mul(p)))?w++:w=0,T===v?(E++,A=0):(E=0,A++)}return N>=X&&h("Root_finder iterations exceeded"),o.setThis(_),!0}function Hn(t,e,s,n,i){const r=t.evaluate(s);if(r.isZero())return!0;const o=it.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(it.constructDouble(1e-17))}function Un(t,e,n,i,r,o,a,h){s(n>0),s(h>=t.power());const u=a,m=[];let l=[];const c=new Tn({zeroCtor:t.m_zeroCtor}),g=new Tn({zeroCtor:t.m_zeroCtor}),d=new Tn({zeroCtor:t.m_zeroCtor}),_=it.constructDouble(n),p=it.constructDouble(e.vmin),f=it.constructDouble(e.vmax),P=p.sub(_),y=f.add(_),x=On(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 Tn({coef0:it.constructInt32(-1)});e.addElement(te),b=new Tn,v=b;const s=new Tn,n=new Tn;for(t.div(e,s,n),b.assignCopy(s);v.evaluate(te).isZero();)v.div(e,s,n),b.assignCopy(s)}let E=!1;if(v.power()>0&&v.getElement(0).isZero())for(E=!0,b||(b=new Tn({copy:v}),v=b);v.getElement(0).isZero();)b.shiftRight(1);let S=i+2*v.power()+2,D=n/Math.pow(2,v.power()+2),w=S;if($t.gt(P)&&$t.lt(y))for(let s=0,Y=v.power();s<Y;s++)if(v.getElement(s).isZero()){m.push($t.clone());break}for(let Y=v.power()-1;Y>0;Y--){if(D*=2,S-=2,w-=2,v.power()-Y===1){g.assignMove(v.derivative(Y));1===Wn(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=jn(g,S,u,h);s(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(Mt(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(Mt(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(Mt(t,e)),m.length>2&&(t=m[2].add(_),t.limitPrecisionThis(w),l.push(Mt(t,y.clone()))))}else l.push(Mt(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 it;if(Zn(g,c,l[e].first,l[e].second,D,S,s)){m.push(s);let n=s.sub(_);n.limitPrecisionThis(w),t.push(Mt(l[e].first,n)),n=s.add(_),n.limitPrecisionThis(w),t.push(Mt(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(Mt(P.clone(),y.clone())));let A=0,T=0,I=0;const M=new it;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){Zn(v,c,l[T].first,l[T].second,n,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])||Hn(v,c,m[I],n)&&(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 E&&$t.gt(P)&&$t.lt(y)&&(u[A++].setThis($t),tt(u,0,A,(t,e)=>t.compare(e))),r&&te.gt(P)&&te.lt(y)&&(u[A++].setThis(te),tt(u,0,A,(t,e)=>t.compare(e))),A}function On(t){const e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();const s=$t.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(te),s.mulThis(it.constructDouble(1+100*Number.EPSILON)),s}function Qn(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]=et(s[0],s[0]=s[1])),i>2&&(s[0].gt(s[2])&&(s[2]=et(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=et(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 ti(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 pt(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 $n(t,e,s,n,i,r,o){let a=0,h=Math.abs(i-s[t]);const u=U(e,Number.NaN),m=U(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 ti(t,s,n,i,r,o){if(n<s&&e("xTo < xFrom"),n===s)return 0;const a=[0];let u=Number.MAX_VALUE;const m=[Number.MAX_VALUE];let l=0;const c=32,g=U(c+1,Number.NaN),d=U(c+1,Number.NaN),_=[0];g[0]=1;let p=0,f=0;for(let e=0;e<c;e++){if(l=Jn(s,n,i,0===e,l,_),d[e]=l,e+1>=t){$n(e+1-t,t,g,d,0,a,m)||h("polynomial_interpolation");const s=r*Math.abs(a[0])+o,n=Math.abs(u-a[0]);if(n<=s&&Math.abs(m[0])<=s){if(p++,p>1&&(n<=.1*f||0===f||p>2))return a[0]}else p=0;f=n,u=a[0]}d[e+1]=d[e],g[e+1]=.25*g[e]}return a[0]}class ei{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let si=class{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-hi(this.b,e,!1):0}getError(t){return s(0),0}};function ni(t,e,s,n,i){let r=!0;const o=lt(Q,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=bt(0,h,t),n=bt(h,u,t);e=bt(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*gi(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=bt(0,h,t),n=bt(h,u,t);e=bt(s,n,t)}else{const s=Et(0,h,t),n=Et(h,u,t);e=Et(s,n,t)}return e*gi(o,1,t).length()});return new Q(m,l)}function ii(t){t.m_cachedValues=null}function ri(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function oi(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ei;return ai(t,e.specialPoints),xi(t,e),e}function ai(t,e){const s=lt(Q,3);t.queryControlPoints(s);const n=lt(at,8);n[0].set(0);let i=1;{const t=lt(at,3);ki(s,t,!1);const e=lt(at,2),r=new H(0,1);let o=cn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)gt(e[s].value(),0,1)||(n[i]=e[s],i++)}{const t=lt(at,3);Gi(s,t,!1);const e=lt(at,2),r=new H(0,1);let o=cn(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)gt(e[s].value(),0,1)||(n[i]=e[s],i++)}if(n[i].set(1),i++,i>2){tt(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 hi(t,e,s){const n=lt(Q,3);return t.queryControlPoints(n),ui(n,e,s)}function ui(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+ui(t,1,!1)}if(1===e)return mi(t);const n=lt(Q,3);return Ii(t,e,n,null),mi(n)}function mi(t){if(t[0].equals(t[1]))return Q.distance(t[2],t[0]);if(t[1].equals(t[2]))return Q.distance(t[0],t[2]);const e=Q.distance(t[0],t[1])+Q.distance(t[2],t[1]),s=Q.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const n=1,i=lt(Q,3);zi(t,i,!0);const r=4*(zt(i[2].x)+zt(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=zt(i[1].x)+zt(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 li(t,e){const s=_t(e,0,1);let n=gi(t,1,s);return n.isZero()&&(n=gi(t,2,s)),n}function ci(t,e,s){const n=lt(Q,3);return t.queryControlPoints(n),gi(n,e,s)}function gi(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)):Q.construct(0,0)}function di(t,e,s){{const e=Ye.constructPoint2D(t[1]).subE(Ye.constructPoint2D(t[0])),n=new at(1).subE(s),i=Ye.constructPoint2D(t[2]).subE(Ye.constructPoint2D(t[1])),r=e.mulE(n).addE(i.mulE(s));return r.mulThisE(new at(2)),r}}function _i(t,e,s){const n=hi(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==tn(new si(t,e),H.unit(),1,i)&&h(""),i[0]}function pi(t){const e=lt(Q,3);return t.queryControlPoints(e),fi(e)}function fi(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Pi(t){const e=Q.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function yi(t){return t.m_cachedValues}function xi(t,e){t.m_cachedValues=e}function Ci(t,e,s,n,i){_(H.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=lt(Q,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=vi(r,e,a);if(s.containsCoordinate(a[0]))o=Q.distance(e,h);else{a[0]=s.vmin,ji(r,a[0],h),o=Q.distance(h,e);const t=new Q;ji(r,s.vmax,t);const n=Q.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 Q;t.queryCoord2DExtended(-1,n,!0);const i=new Q;t.queryCoord2D(s.vmin,i);const r=new pm({start:n,end:i}),u=r.getClosestCoordinate(e,!0);if(u<1){const t=r.getCoord2D(u),s=Q.distance(t,e);s<o&&(o=s,a[0]=u-1,h.assign(t))}}if(s.vmin>=1){const n=new Q;t.queryCoord2DExtended(2,n,!0);const i=new Q;t.queryCoord2D(s.vmax,i);const r=new pm({start:i,end:n}),u=r.getClosestCoordinate(e,!0);if(u>0){const t=r.getCoord2D(u),s=Q.distance(t,e);s<o&&(o=s,a[0]=1+u,h.assign(t))}}return a[0]}function vi(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=U(3,Number.NaN),l=nn(u,h,a,o,H.unit(),!1,m),c=t[0].clone();let g=0,d=Q.sqrDistance(t[0],e),_=Q.sqrDistance(t[2],e);_<d&&(g=1,c.assign(t[2]),d=_);for(let p=0;p<l;p++){const s=new Q;ji(t,m[p],s),_=Q.sqrDistance(s,e),_<d&&(d=_,c.assign(s),g=m[p])}return s&&(s[0]=g),c}function bi(t,e,s,n,i,r){const o=new De;if(Ei(t,H.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=new Q,h=Ci(t,e,H.unit(),!1);t.queryCoord2D(h,a);return Q.distance(a,e)<=i?(n&&(n[0]=h),1):0}function Ei(t,e,s){const n=lt(Q,3);t.queryControlPoints(n),Si(n,e,s)}function Si(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const n=lt(Q,3);Mi(t,e.vmin,e.vmax,n),s.setFromPoints(n,3)}function Di(t,e,s){s.setEmpty();const n=[];n.push(new H(0,1));const i=.5*Math.max(e.width(),e.height());for(;n.length;){const r=n.at(-1);n.pop();const o=new De;if(Si(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(H.construct(r.vmin,t)),n.push(H.construct(t,r.vmax))}}}}function wi(t){const e=lt(Q,3);t.queryControlPoints(e);const s=Ai(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ai(t){let e=!1;for(let s=0;s<2;s++){const n=nt(t[0][s],t[2][s]);n>0?(nt(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?(nt(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),nt(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 Ti(t,s,n){void 0===n&&(n=s,s=0);const i=new Q;if(s<0||n>1)return i.setNAN(),i;if(s>n&&e("calculate_sub_weighted_centroid"),s===n||t.isDegenerate(0))return i.setCoords(0,0),i;const r=oi(t),o=is(t),a=Math.min(o/t.calculateUpperLength2D(),1e-7);let h=s,u=0;for(let e=1,m=r.specialPointsCount();e<m;e++)if(s<r.specialPoints[e]){u=e-1;break}i.setCoords(0,0);for(let e=u+1,m=r.specialPointsCount();e<m;e++){const s=Math.min(r.specialPoints[e],n),u=ni(t,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}function Ii(t,e,s,n){(new Q).setCoordsPoint2D(t[0]);(new Q).setCoordsPoint2D(t[1]);(new Q).setCoordsPoint2D(t[2]);const i=new Q,r=new Q,o=new Q;if(xt(t[0],t[1],e,i),xt(t[1],t[2],e,r),xt(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 Mi(t,e,s,n){if(e===s){const s=new Q;return ji(t,e,s),n[0]=s,n[1]=s,void(n[2]=s)}const i=lt(Q,3);Ii(t,s,i,null),Ii(i,e/s,null,i),ji(t,e,i[0]),ji(t,s,i[2]),n[0].setCoordsPoint2D(i[0]),n[1].setCoordsPoint2D(i[1]),n[2].setCoordsPoint2D(i[2])}function Yi(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 le,o=lt(Q,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new Q;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=lt(Q,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):xt(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&wi(t)}function Ni(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function Xi(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==Vi(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function qi(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(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!==am(e,s))return 2}else if(Le(e,s))return 1;return 0!==Ri(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function Vi(t,e,n,i,r,o,a,h,u,m){if(null!=r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),n.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(n.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!==o)for(let t=0;t<s;t++)o.push(0);if(null!==i)for(let n=0;n<s;n++){const s=new Q;e.queryCoord2D(t[n],s),i.push(s)}}return s}const l=rs(e,n);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new pm({start:e.getStartXY(),end:e.getEndXY()}),s=Ds(t,n,i,r,o,a,h,m);if(r)for(let n=0;n<s;++n){const s=t.getCoord2D(r[n]);r[n]=e.getClosestCoordinate(s,!1)}return s}if(os(e,n,a))return 0;const c=Xe.constructPoint2D(n.getStartXY()),g=Xe.constructPoint2D(n.getEndXY()).sub(c),d=g.clone();d.leftPerpendicularThis();const _=Xe.constructPoint2D(e.m_cp).sub(Xe.constructPoint2D(e.getStartXY())),p=Xe.constructPoint2D(e.getEndXY()).sub(Xe.constructPoint2D(e.m_cp));let f=_.dotProduct(d).toDouble(),P=p.sub(_).dotProduct(d).toDouble();const y=U(12,Number.NaN),x=U(12,Number.NaN);let C=en(P,f,H.unit(),y);C<0&&(y[0]=0,y[1]=1,C=2);let v,b=0;for(let s=0,w=b;s<C;++s){const t=e.getCoord2D(y[s+w]);x[b]=n.getClosestCoordinate(t,!1),Q.distance(t,n.getCoord2D(x[b]))<=a&&(y[b]=y[s+w],b++)}const E=lt(Q,3);e.queryControlPoints(E);{const t=lt(Xe,3);if(Wi(E,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 S=e.getEndXY().equals(n.getStartXY())||e.getEndXY().equals(n.getEndXY()),D=[0,0];C=sn(P,f,v,H.unit(),S,D);for(let s=0,w=b;s<C;++s){y[s+w]=D[s];const t=e.getCoord2D(y[s+w]);x[b]=n.getClosestCoordinate(t,!1),Q.distance(t,n.getCoord2D(x[b]))<=a&&(y[b]=y[s+w],b++)}s(b<y.length+4),C=e.intersectPoint(n.getStartXY(),D,a);for(let s=0;s<C;s++)y[b]=D[s],x[b++]=0;C=e.intersectPoint(n.getEndXY(),D,a);for(let s=0;s<C;s++)y[b]=D[s],x[b++]=1;C=n.intersectPoint(e.getStartXY(),D,a);for(let s=0;s<C;s++)x[b]=D[s],y[b++]=0;C=n.intersectPoint(e.getEndXY(),D,a);for(let s=0;s<C;s++)x[b]=D[s],y[b++]=0;return 0===b?0:cm(t,e,n,y,x,b,i,r,o,a,h,u,m)}function Li(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return Vi(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=lt(Q,3);{e.queryControlPoints(g);const t=lt(Q,3),n=new le;s.canonicToWorldTransformation(n);const i=new le;i.setInvert(n),i.transformPoints2D(g,3,t);const r=lt(Xe,3);Wi(t,r);const h=[r[0].x,r[1].x,r[2].x],u=[r[0].y,r[1].y,r[2].y],m=lt(it,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=qn(h,2,u,2,null,0,m,!0,H.unit(),H.unit(),l,a);if(d>0){let t=0;for(let n=0;n<d;n++){const i=new Q;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new Q;s.queryCoord2D(r,a),Q.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];vi(g,t,e);const n=new Q;ji(g,e[0],n),Q.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 Q;s.queryCoord2D(e,n),Q.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return cm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function Ri(t,e,s,n,i,r,o,a,h,u){const m=lt(Q,3);e.queryControlPoints(m);const l=lt(Q,3);if(s.queryControlPoints(l),as(m,l,3)<0)return Ri(t,s,e,n,r,i,o,a,h,!u);const c=rs(e,s);if(os(e,s,o=Math.max(o,c)))return 0;if(er(e,s,n,i,r,o,a,h,u))return 2;const g=new H(0,1),d=new H(0,1);{const t=new De;Si(m,H.unit(),t);const e=new De;Si(l,H.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(Di(m,t,g),Di(l,t,d),g.isEmpty()||d.isEmpty())return 0;Mi(m,g.vmin,g.vmax,m),Mi(l,d.vmin,d.vmax,l)}}const _=dm(m,2,l,2,o);if(0===_)return 0;const p=[],f=[];if(-1===_){const t=lt(Xe,3);Wi(m,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],n=lt(Xe,3);Wi(l,n);const i=Yn(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,H.unit(),H.unit(),p,f,u,a,u);if(i>0){let t=0;for(let e=0;e<i;e++){const s=new Q,n=new Q;ji(l,f[e],n),ji(m,p[e],s),Q.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];vi(e,t[n],i);const r=new Q;ji(e,i[0],r),Q.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]=wn.recalculateParentT(g.vmin,g.vmax,p[P]);if(!d.equalsRange(0,1))for(let P=0;P<f.length;++P)f[P]=wn.recalculateParentT(d.vmin,d.vmax,f[P]);return cm(t,e,s,p,f,p.length,n,i,r,o,a,h,u)}function zi(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 Bi(t,e,s=!1){const n=lt(Q,3);t.queryControlPoints(n),zi(n,e,s)}function ki(t,e,s=!1){const n=0,i=new at(t[1][n]).subE(new at(t[0][n]));e[1]=i.mul(2),e[2]=new at(t[2][n]).subE(new at(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function Gi(t,e,s=!1){const n=1,i=new at(t[1][n]).subE(new at(t[0][n]));e[1]=i.mul(2),e[2]=new at(t[2][n]).subE(new at(t[1][n])).subE(i),s?e[0].set(0):e[0].set(t[0][n])}function Wi(t,e,s=!1){const n=Xe.constructPoint2D(t[1]),i=n.sub(Xe.constructPoint2D(t[0]));e[1]=i.mul(it.constructInt32(2)),e[2]=Xe.constructPoint2D(t[2]).sub(n).sub(i),e[0]=s?new Xe($t,$t):Xe.constructPoint2D(t[0])}function ji(t,e,s,n){if(n){if(e<0){return void _s(new pm({start:t[0],end:t[0].add(li(t,0).getUnitVector())}),e,s)}if(e>1){return void _s(new pm({start:t[2],end:t[2].add(li(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=t[1].clone(),i=new Q;Xt(2,t[0],n,e,i);const r=new Q;Xt(2,n,t[2],e,r);const o=new Q;Xt(2,i,r,e,o),s.assign(o)}else{const n=t[1].clone(),i=new Q;qt(2,t[0],n,e,i);const r=new Q;qt(2,n,t[2],e,r);const o=new Q;qt(2,i,r,e,o),s.assign(o)}}function Zi(t,e,s){const n=lt(Q,3);t.queryControlPoints(n),Hi(n,e,s)}function Hi(t,e,s){if(e.value()<=.5){const n=Ye.constructPoint2D(t[1]),i=new Ye;Ft(2,Ye.constructPoint2D(t[0]),n,e,i);const r=new Ye;Ft(2,n,Ye.constructPoint2D(t[2]),e,r);const o=new Ye;Ft(2,i,r,e,o),s.setE(o)}else{const n=Ye.constructPoint2D(t[1]),i=new Ye;Vt(2,Ye.constructPoint2D(t[0]),n,e,i);const r=new Ye;Vt(2,n,Ye.constructPoint2D(t[2]),e,r);const o=new Ye;Vt(2,i,r,e,o),s.setE(o)}}function Ui(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),Oi(n,e,s)}function Oi(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(di(t,1,e))}function Qi(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=Q.intersectLinesAtOnePoint(t[0],t[s],t[n],t[3]),r=new Q;xt(t[0],t[3],.5,r);const o=new Q;Po(t,.5,o);const a=new Q;e[1].assign(i),ji(e,.5,a);const h=new Q;e[1].assign(r),ji(e,.5,h);const u=Q.sqrDistance(o,a),m=Q.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 Q;_h(t,e,.5,n);const i=new Q;ji(s,.5,i);const r=Q.sqrDistance(n,i);return Math.sqrt(r)}function Ji(t,e){e[0].assign(t[0]),e[3].assign(t[2]),xt(t[0],t[1],2/3,e[1]),xt(t[1],t[2],1/3,e[2])}function $i(t,e){const s=lt(Q,3);t.queryControlPoints(s);const n=Q.sqrDistance(s[1],s[0]),i=Q.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 tr(t,e){if(!e)return!1;const s=lt(Q,3);t.queryControlPoints(s);const n=Q.sqrDistance(s[1],s[0]),i=Q.sqrDistance(s[1],s[2]);s[0].clone();let r=n;return n>i&&(s[2].clone(),r=i),r<=e&&0!==r}function er(t,e,s,n,i,r,o,a,h){const u=lt(Q,3);t.queryControlPoints(u);const m=lt(Q,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]=et(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=et(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[2]),h&&(s[1]=et(s[0],s[0]=s[1]))),!0)}const sr=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],nr=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],ir=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],rr=[[.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]],or=[[.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]],ar=[[.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 hr(t,e,s,n){const i=.5*(n-s),r=s+i,o=new pt(0);for(let a=0,h=Math.trunc(t/2);a<h;++a){let s,n;switch(t){case 4:s=sr[a][0],n=sr[a][1];break;case 8:s=nr[a][0],n=nr[a][1];break;case 16:s=ir[a][0],n=ir[a][1];break;case 32:s=rr[a][0],n=rr[a][1];break;case 64:s=or[a][0],n=or[a][1];break;case 128:s=ar[a][0],n=ar[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=re(-i,s,r),u=re(i,s,r);o.pe(e(h)*n),o.pe(e(u)*n)}return o.getResult()*i}class ur extends Hs{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=fm):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=fm,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=fm):t.envelope?a("envelope constructor not impl"):h("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=fm)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return Js(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return ur.type}getDimension(){return 2}createInstance(){return new ur({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function mr(t,s){let n,r=s,o=null;switch(r||(o=p(t)?X():P(),r=o),t){case i.enumPoint:n=new q({vd:r});break;case i.enumLine:n=new pm({vd:r});break;case i.enumBezier:n=new ia({vd:r});break;case i.enumEllipticArc:n=new Xh({vd:r});break;case i.enumRationalBezier2:n=new Sn({vd:r});break;case i.enumBezier2:n=new wn({vd:r});break;case i.enumEnvelope:n=new M({vd:r});break;case i.enumMultiPoint:n=new Se({vd:r});break;case i.enumPolyline:n=new Os({vd:r});break;case i.enumPolygon:n=new ur({vd:r});break;case i.enumMultipatch:a("multipatch not impl");break;case i.enumGeometryCollection:n=new ls({vd:r});break;default:e("Geometry.create")}return n}ur.type=i.enumPolygon;var lr=b;const cr=-1,gr=1;class dr{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 _r(t){return void 0!==t.parent}class pr{constructor(t){_r(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!==cr;){for(;this.m_path!==cr;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!==cr)return this.m_vertex;if(this.m_bOneGeom)return cr;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===cr)break;this.m_bSkipMultiPoints&&!c(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return cr}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==cr&&(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 cr}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==cr?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==cr&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):cr}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,n,i,r,o,a,h){return new pr({parent:t,geometry:e,path:s,vertex:n,firstVertex:i,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class fr{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class Pr{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,gr),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,gr),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,n){this.m_hasForceSetEnvelope=0;const i=e!==cr?this.getPrevVertex(e):this.getLastVertex(t),r=i!==cr?this.getNextVertex(i):cr,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!==cr&&this.setPrevVertex(r,o),i!==cr&&this.setNextVertex(i,o);const h=this.isClosedPath(t),u=this.getFirstVertex(t);e===cr&&this.setLastVertex(t,o),e===u&&(h&&n&&u!==cr||this.setFirstVertex(t,o)),h&&r===cr&&(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 q({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,e){const s=this.createGeometry(i.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}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,cr);this.setClosedPath(e,s.isClosedPath(i));for(let t=s.getPathStart(i),r=s.getPathEnd(i);t<r;t++){const i=this.insertVertex_(e,cr,null,!1);if(n){const e=this.getVertexIndex(i);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const n=new fm;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,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===i.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const n=e.getImpl(),i=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),r=new me;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=cr,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,cr,null,!1);if(i){const s=this.getVertexIndex(e);if(1&n.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new fm;n.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===d)break;m=1,l=_,a!==o?(c=this.insertPath(t,cr),this.setClosedPath(c,!1),u=n.getSegmentCountPath(o),g=n.isClosedPath(o),a=o):c=this.insertPath(t,cr)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,n){const i=e.getImpl(),r=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),o=me.constructEmpty();e.queryEnvelope(o),s(n.isIntersecting(o)&&!n.containsEnvelope(o));let a=me.construct(Number.NEGATIVE_INFINITY,n.ymin,Number.POSITIVE_INFINITY,n.ymax),h=me.construct(n.xmin,Number.NEGATIVE_INFINITY,n.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=et(a,a=h))}else a.height()>h.width()&&(h=et(a,a=h));const m=[],l=i.queryLimitedSegmentIterator(a);let c=-1,g=-100,d=-1,_=0,p=-1,f=-1,P=cr,y=!0,x=l.nextSegment();if(null!==x)for(;;x=l.nextSegment()){let n=null===x;const o=null!==x?l.getPathIndex():c,a=null!==x?l.getStartPointIndex():g;if(n||(o===c?g+1===a?_++:n=!0:(n=c>=0,c<0&&(c=o,d=i.getSegmentCountPath(c),p=a,P=cr,_=1))),n){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===cr&&(P=this.insertPath(t,cr),this.setClosedPath(P,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(P,cr,null,!1));for(const{first:n,second:o}of m){-1===f&&(f=n);let a=-1,h=-1;const u=n+o-1;if(o===d){const t=u+1;h=t-n,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,n,t),a=u,s(1===m.length)}else if(u+1<i.getPathEnd(c)){const t=u+2;h=t-n,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,n,t),a=u}else{const t=i.getPathStart(c),s=t!==f?1:0,r=u+1;h=r-n+s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-n)+s),this.m_verticesMp.addPoints(e,n,r),a=u,s>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),P===cr&&(P=this.insertPath(t,cr),this.setClosedPath(P,!0));for(let t=0,e=n;t<h;t++,e++){const t=this.insertVertex_(P,cr,null,!1);if(r){const s=this.getVertexIndex(t);if(1&i.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new fm;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,cr,null,!1))}}m.length=0,y=!0,o!==c&&(c=o,d=i.getSegmentCountPath(c),P=cr,f=-1),p=a,_=1}if(!x)break;{const t=me.constructEmpty();x.queryLooseEnvelope(t),h.isIntersecting(t)?(y?m.push(Mt(a,1)):m.at(-1).second++,y=!1):y=!0}g=a}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const n=e.getGeometryType()===i.enumPolygon,r=me.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?n?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}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,cr);this.insertVertex_(n,cr,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,cr);for(let n=0,i=e.getPointCount();n<i;n++)this.insertVertex_(s,cr,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,cr);for(let u=0,m=e.getPointCount();u<m;u++){const t=n.readPoint2D(2*u);s.contains(t)&&this.insertVertex_(h,cr,null,!1)}}splitSegmentForward(t,s,n,r,o){const a=this.getNextVertex(t);a===cr&&e("Edit_shape.split_segment_forward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(n);e<c;e++){const t=this.getVertexIndex(m),r=this.getNextVertex(m),g=s.getResultSegment(n,e);let d=null;if(g.getGeometryType()!==i.enumLine&&(d=g.clone(),d.dropAllAttributes()),0===e&&(g.queryStart(h),this.setSegmentToIndex(t,null),this.setPointEx(m,h,s.getResultSegmentStartPointRank(n,e),s.getResultSegmentStartPointWeight(n,e),o)),this.setSegmentRank(m,s.getResultSegmentInteriorRank(n,e)),this.setSegmentWeight(m,s.getResultSegmentInteriorWeight(n,e)),l){const t=s.getResultSegmentSegmentParentage(n,e),i=s.getResultSegmentStartPointIsBreak(n,e);this.setSegmentParentageAndBreak(m,t,i)}if(g.queryEnd(h),e<c-1){this.setSegmentToIndex(t,d);const i=this.insertVertex(u,r,h);this.setWeight(i,s.getResultSegmentEndPointWeight(n,e)),this.setRank(i,s.getResultSegmentEndPointRank(n,e)),this.select(i),m=i}else{this.setPointEx(a,h,s.getResultSegmentEndPointRank(n,e),s.getResultSegmentEndPointWeight(n,e),o);const i=s.getResultSegmentEndPointIsBreak(n,e);this.setSegmentParentageBreakVertex(a,i),this.setSegmentToIndex(t,d)}}}splitSegmentBackward(t,s,n,r,o){const a=this.getNextVertex(t);a===cr&&e("Edit_shape.split_segment_backward_");const h=this.getHelperPoint(),u=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(n);e<c;e++){const t=c-e-1,r=this.getVertexIndex(m),g=this.getNextVertex(m),d=s.getResultSegment(n,t);let _=null;if(d.getGeometryType()!==i.enumLine&&(_=d.clone(),_.reverse(),_.dropAllAttributes()),0===e&&(d.queryEnd(h),this.setSegmentToIndex(r,null),this.setPointEx(m,h,s.getResultSegmentEndPointRank(n,t),s.getResultSegmentEndPointWeight(n,t),o),this.setSegmentParentageAndBreak(m,s.getResultSegmentSegmentParentage(n,t),s.getResultSegmentEndPointIsBreak(n,t))),d.getGeometryType()===i.enumLine?this.setSegmentToIndex(r,null):this.setSegmentToIndex(r,_),this.setSegmentRank(m,s.getResultSegmentInteriorRank(n,t)),this.setSegmentWeight(m,s.getResultSegmentInteriorWeight(n,t)),d.queryStart(h),e<c-1){const e=this.insertVertex(u,g,h);this.setWeight(e,s.getResultSegmentStartPointWeight(n,t)),this.setRank(e,s.getResultSegmentStartPointRank(n,t)),this.select(e),m=e,l&&this.setSegmentParentageAndBreak(e,s.getResultSegmentSegmentParentage(n,t),s.getResultSegmentEndPointIsBreak(n,t))}else this.setPointEx(a,h,s.getResultSegmentStartPointRank(n,t),s.getResultSegmentStartPointWeight(n,t),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?V(0,-1):V(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 V(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=et(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,cr,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 cr}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,n){s(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=S.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=Q.getNAN(),this.m_workPoint2_2D=Q.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=cr,this.m_lastGeometry=cr,this.m_vertexIndexList=new k(5),this.m_pathIndexList=new k(8),this.m_geometryIndexList=new k(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new G,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new me(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=me.constructEmpty(),n=this.queryVertexIterator();let i=!0;for(let r=n.next();r!==cr;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=me.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}i=!1}return s}getEnvelope3D(t){return s(0),S.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){s(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,s){const n=t.getGeometryType();if(c(n))return this.addMultiPath(t,s);if(n===i.enumMultiPoint)return this.addMultiPoint(t,s);if(n===i.enumPoint)return this.addPoint_(t,s);if(n===i.enumEnvelope){const e=new ur;return e.addEnvelope(t,!1),this.addMultiPath(e,s)}e("")}appendGeometry(t,s){this.mergeVertexDescription(s.getDescription());const n=s.getGeometryType();c(n)?this.appendMultiPath(t,s):n!==i.enumMultiPoint?e(""):this.appendMultiPoint(t,s)}assignRankToGeometryVertices(t,e){e<gr&&(e=gr);const s=this.queryVertexIterator();for(let n=s.next();n!==cr;n=s.next())this.setRank(n,e),this.setSegmentRank(n,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(i.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=cr,s=-1,n=-1;for(let r=this.getFirstGeometry();r!==cr;){if(t===i.enumUnknown||this.getGeometryType(r)===t){if(e===cr){e=r,s=this.getPathCount(e),n=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let s=this.getFirstPath(r);s!==cr;s=this.getNextPath(s))this.setPathGeometry(s,e);s+=this.getPathCount(r),n+=this.getPointCount(r);const t=this.getLastPath(e),i=this.getFirstPath(r);t!==cr?this.setNextPath(t,i):this.setFirstPath(e,i),i!==cr&&(this.setPrevPath(i,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,cr),this.setLastPath(r,cr);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}r=this.getNextGeometry(r)}return e!==cr&&(this.setGeometryVertexCount(e,n),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}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!==cr;c=this.getNextPath(c))this.setPathGeometry(c,e);for(let c=this.getFirstPath(e);c!==cr;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,e,s){const n=this.createGeometry(s?i.enumPolygon:i.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return n;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(n,cr);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let i=r.getPathStart(e),h=r.getPathEnd(e);i<h;i++){const t=this.insertVertex_(o,cr,null,!1);if(a){const e=this.getVertexIndex(t);if(1&r.getSegmentFlags(i))this.setSegmentToIndex(e,null);else{const t=new fm;r.querySegment(i,t,!0),this.setSegmentToIndex(e,t.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),n}getGeometry(t){const e=this.getGeometryType(t),s=mr(e,this.m_verticesMp.getDescription()),n=this.getPointCount(t);if(0===n)return s;if(c(e)){const e=s.getImpl(),i=this.getPathCount(t),r=V(i+1),o=L(i+1,0),a=s.getDescription(),h=this.hasCurves();for(let s=0,u=a.getAttributeCount();s<u;s++){const h=a.getSemantics(s),u=lr.getComponentCount(h),m=I(h,n),l=this.m_vertices.getAttributeStreamRef(h);let c=0,g=0,d=0;for(let e=this.getFirstPath(t);e!==cr;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(i,n)}if(e.setPathFlagsStreamRef(o),e.setPathStreamRef(r),e.notifyModifiedFlags(65535),h){let s=0,n=0;for(let i=this.getFirstPath(t);i!==cr;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(e===i.enumMultiPoint){const e=s.getImpl(),i=s.getDescription();e.reserve(n),e.resizeNoInit(n);for(let s=0,n=i.getAttributeCount();s<n;s++){const n=i.getSemantics(s),r=lr.getComponentCount(n),o=e.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);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(n,o)}e.notifyModifiedFlags(65535)}else h("getGeometry");return s}queryPointGeometryOnly(t,s){this.getGeometryType(t)!==i.enumMultiPoint&&e("get_point_geometry_only");const n=this.getPointCount(t);if(n>1&&e("get_point_geometry_only"),0===n)return s.assignVertexDescription(this.m_vertexDescription),void s.setEmpty();const r=this.getFirstPath(t),o=this.getFirstVertex(r);this.queryPoint(o,s)}removeGeometry(t){for(let n=this.getFirstPath(t);n!==cr;n=this.removePath(n));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==cr?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==cr?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 Se({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===cr?(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]=V(0),e;this.m_geometryIndices.push(V(0));const t=this.m_geometryIndices.length-1;return s(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!==cr;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,e,n,r,o){const a=t*t;let h=0;const u=this.hasCurves(),m=this.hasSegmentParentage(),l=!0;for(let g=o===cr?this.getFirstGeometry():o;g!==cr;g=o===cr?this.getNextGeometry(g):cr){const t=this.getGeometryType(g);if(!c(t))continue;if(n&&t!==i.enumPolygon)continue;const o=this.getGeometryType(g)===i.enumPolygon;let d=this.getGeometryModified(g);for(let n=this.getFirstPath(g);n!==cr;){let t=0;for(let e=this.getFirstVertex(n);t<Math.trunc(this.getPathSize(n)/2);){const i=this.getNextVertex(e);if(i===cr)break;const o=this.getXY(e),c=this.getXY(i);let _=Q.sqrDistance(o,c),p=!0;do{if(_<=a){if(u){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===h&&(h=-1):h=1,i!==this.getLastVertex(n)){const t=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(i));if(this.transferAllDataToTheVertex(i,e,l),this.removeVertex(i,!1),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&e!==i){this.setSegmentParentageBreakVertex(e,t);const n=this.getNextVertex(e);s(n!==cr),this.isDiscontinuousSegmentParentage(n)&&this.setSegmentParentageBreakVertex(n,!0)}}p=!1}}while(0);p&&(e=this.getNextVertex(e)),t++}let i=this.getFirstVertex(n);for(let e=this.isClosedPath(n)?i:this.getLastVertex(n);this.getPathSize(n)>0;){const t=this.getPrevVertex(e);if(t===cr)break;{const o=this.getXY(t),c=this.getXY(e);let _=Q.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){s(this.m_segmentParentageIndex>=0);const n=this.getUserIndex(e,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(t,e,l),this.setUserIndex(e,this.m_segmentParentageIndex,n)}else this.transferAllDataToTheVertex(t,e,l);const o=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(t));this.removeVertex(t,!0),r&&!d&&(this.setGeometryModified(g,!0),d=!0),m&&t!==e&&(o||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),i===t&&(i=this.getFirstVertex(n)),p=!1}}while(0);if(p&&(e=this.getPrevVertex(e),e===i))break}}const c=this.getPathSize(n);let _=e&&c<(o?3:2);_&&o&&2===c&&u&&(_=!this.pathHasCurves(n)),_?(n=this.removePath(n),0===h&&(h=-1),r&&!d&&(this.setGeometryModified(g,!0),d=!0)):n=this.getNextPath(n)}}return h}filterClosePoints3D(t,e,n,i,r,o){return s(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==cr;e=this.getNextGeometry(e))if(c(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==cr;){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===cr)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 s(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(t,s,n,i,r){let o=0;const a=this.getNextVertex(t);a===cr&&e("");const h=this.getVertexIndex(t),u=this.getVertexIndex(a),m=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,u);const c=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&m&&(l=m.calculateLength2D());const d=this.getSegmentParentage(t),_=this.getHelperPoint();if(m){let t=0,e=0,r=cr;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!==cr){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(t,s,n){this.getNextVertex(t)===cr&&e("");let i=t,r=!1;for(let e=0;e<s;++e){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!==cr;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,n){return s(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!==cr){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,n,i){s(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!==cr){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 Q(e,s),t,!1),i.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==cr){const t=this.getVertexIndex(r),n=this.getSegmentFromIndex(t);if(null!==n){const t=n.getStartXY();n.setCoordsForIntersector(t,new Q(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,n){s(0)}setXYZ(t,e,n){s(0)}setXYZCoords(t,e,n,i){s(0)}queryXYZ(t,e){s(0)}getXYZ(t){return s(0),E.getNAN()}getXYZWithIndex(t){return s(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){s(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,n,i){s(0)}setAttribute(t,e,n,i){s(0)}setAttributeInt(t,e,n,i){s(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return s(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 s(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=R(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=R(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 gr;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?gr:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?gr:this.m_ranks.read(t)}setRank(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_ranks){if(s)return;this.m_ranks=V(this.m_vertices.getPointCount(),gr)}const n=this.getVertexIndex(t);if(n>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(n+1,gr)}this.m_ranks.write(n,e)}setRankWithIndex(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_ranks){if(s)return;this.m_ranks=V(this.m_vertices.getPointCount(),gr)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,gr)}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=R(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=R(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 Pr.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?Pr.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?gr:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=V(this.m_vertices.getPointCount(),gr)}const n=this.getVertexIndex(t);if(n>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(n+1,gr)}this.m_segmentRanks.write(n,e)}setSegmentRankWithIndex(t,e){e<gr&&(e=gr);const s=e===gr;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=V(this.m_vertices.getPointCount(),gr)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,gr)}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 s(t>=0&&t<=K()),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 s(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!==cr;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){s(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===cr)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 q({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(n,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,n=!1){return s(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return s(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===cr)return!1;const s=this.getPathSize(t);let n=e;for(let r=0;r<s;r++,n=this.getNextVertex(n)){const t=this.getSegment(n);if(null!==t&&t.getGeometryType()!==i.enumLine)return!0}return!1}insertPath(t,s){let n=cr;s!==cr?(t!==this.getGeometryFromPath(s)&&e(""),n=this.getPrevPath(s)):n=this.getLastPath(t);const i=this.newPath(t);return s!==cr&&this.setPrevPath(s,i),this.setNextPath(i,s),this.setPrevPath(i,n),n!==cr?this.setNextPath(n,i):this.setFirstPath(t,i),s===cr&&this.setLastPath(t,i),this.setGeometryPathCount(t,this.getPathCount(t)+1),i}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),n=this.getGeometryFromPath(t);return e!==cr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==cr?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!==cr){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,cr),this.setPrevVertex(s,cr);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){s(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 e=this.getFirstVertex(t);if(e===cr)return 0;const s=this.getXY(e),n=new pt(0),r=this.getPathSize(t);if(r>2){const t=s.clone(),i=t.x,o=t.y;let a=this.getNextVertex(e);const h=this.getXY(a);a=this.getNextVertex(a);const u=Q.getNAN();for(let e=2;e<r;e++,a=this.getNextVertex(a))this.queryXY(a,u),n.pe((u.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(u);n.pe((i-t.x)*(h.y-o))}if(this.hasCurves()){let t=e;for(let e=0;e<r;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===i.enumLine)continue;const s=2*e.calculateArea2DHelper();n.pe(s)}}this.setRingAreaValid(t,!0);const o=.5*n.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 s(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!==cr;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(t,s,n){if(n===cr&&e(""),s===n)return;const i=this.getNextPath(n);let r=this.getPrevPath(n);const o=this.getGeometryFromPath(n);r===cr?this.setFirstPath(o,i):this.setNextPath(r,i),i===cr?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===cr?this.getLastPath(t):this.getPrevPath(s),this.setPrevPath(n,r),this.setNextPath(n,s),s===cr?this.setLastPath(t,n):this.setPrevPath(s,n),r===cr?this.setFirstPath(t,n):this.setNextPath(r,n),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(n)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(n,t)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,cr,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!==cr&&this.setNextVertex(n,i);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?i:cr),i!==cr&&this.setPrevVertex(i,n),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?n:cr);if(this.hasCurves()&&n!==cr&&i!==cr){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){s(t!==e);const n=this.getPathFromVertex(t),i=this.getPrevVertex(t),r=this.getPrevVertex(e);i!==cr&&this.setNextVertex(i,e);let o=this.getPathSize(n);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,i),this.setPrevVertex(t,cr),this.setNextVertex(r,cr);let h=0,u=t;const m=this.getFirstVertex(n);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(n,o>0?e:cr),this.setPathSize(n,o);const c=this.getGeometryFromPath(n);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,cr,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||h(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==cr;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==cr;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=cr){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=cr){let s=cr,n=cr,i=cr,r=cr,o=0,a=!1;for(s=e!==cr?e:this.getFirstGeometry();s!==cr;s=this.getNextGeometry(s))if(!t||c(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==cr;n=this.getNextPath(n))if(i=this.getFirstVertex(n),r=i,o=0,i!==cr){a=!0;break}if(a||e!==cr)break}return a||(s=cr),pr.create_(this,s,n,i,r,o,t,!1,e!==cr)}queryVertexIteratorOnSelection(t=cr){return this.m_selection?pr.create_(this,t,cr,cr,cr,-1,!1,!0,t!==cr):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){s(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]=cr,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 s(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===cr)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 s(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!==cr?this.setNextPath(e,s):this.setFirstPath(n,s),s!==cr?this.setPrevPath(s,e):this.setLastPath(n,e),this.setFirstVertex(t,cr),this.setLastVertex(t,cr),this.freePath(t)}insertClosedPath(t,e,s,n,i){const r=this.insertPath(t,cr);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 s(0),0}findVertex3D(t,e,n){return s(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===cr)return cr;return s}removeVertexInternal(t,e){const s=this.getPrevVertex(t),n=this.getNextVertex(t);s!==cr&&this.setNextVertex(s,n),n!==cr&&this.setPrevVertex(n,s);if(this.hasCurves()&&s!==cr&&n!==cr){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){s(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new dr(this))}sortVerticesSimpleByX(t,e,n){s(0)}sortVerticesSimpleByY3D(t,e,n){s(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==cr&&this.replaceCurveWithLine(s);this.getNextVertex(t)!==cr&&this.replaceCurveWithLine(t);const n=new Q;this.queryXY(t,n),n.y=e,this.setXY(t,n)}setSegmentParentageAndBreak(t,e,n=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&(s(e<=Yt()>>1),e<<=1,e|=n?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if(s(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}if(e>=0){s(e<=Yt()>>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 fr(e)}return new fr(-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&=Yt()>>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===cr)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 yr(t){if(t.isEmpty())return new ur({vd:t.getDescription()});if(c(t.getGeometryType())&&t.hasNonLinearSegments())return Cr(t);const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new q({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new q,s=new Os({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 wr({stream:n,n:s});let r=0,o=1;const a=n.readPoint2D(r<<1),h=new Q;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 Q;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 ur({vd:u}):new Os({vd:u});const t=g.getImpl();t.reserve(i.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new Q;for(let r=i.m_treeHull.getFirst();-1!==r;r=i.m_treeHull.getNext(r))if(m){const s=new q;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 q({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 q(t)}return g}function xr(t,e,s,n=!1){if(e<=262144)return Ir(t,e,s,n);const i=new wr({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 Cr(t){s(t.hasNonLinearSegments()&&!t.isEmpty());const e=new wr;return e.addGeometry(t),e.getBoundingGeometry()}function vr(t,s,n){if((s<0||s>=t.getPathCount())&&e("path index"),t.hasNonLinearSegmentsPath(s))return!1;const i=t.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(!Mr(Q.orientationRobust(c,g,l)))return!1;const d=c.clone(),_=new Q;for(let e=u+6;e<m;e+=2){_.assign(c),c.assign(g),h.queryPoint2D(e,g);if(!Mr(Q.orientationRobust(c,g,l)))return!1;if(!Mr(Q.orientationRobust(d,g,l)))return!1;if(!Mr(Q.orientationRobust(c,g,_)))return!1}return!0}function br(t,e,s){t.setNAN(),e.setCoords(1,0),s.setCoords(0,0)}function Er(t,e,s,n,r){if(br(s,n,r),t.isEmpty())return;if(t.getGeometryType()===i.enumPoint)return void s.assign(t.getXY());const o=t,a=o.getPointCount();0!==a&&(1!==a?Sr(o,a,e,s,n,r):s.assign(o.getXY(0)))}function Sr(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=Xr(o),r.setCoords(.5*o.length(),0)}else{let o=Number.MAX_VALUE;const a=[0,1,0,0],h=new Pt(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],qr(h,0,e)){a[1]===a[0]&&(++a[1],qr(h,1,e));for(let s=1;;++s){for(;;){const n=Fr(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],qr(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=Xr(t.getXY(h.get(0,1)).sub(t.getXY(h.get(0,0)))),l=new Q;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=et(r.x,r.x=r.y),i.leftPerpendicularThis())}i.y<0?i.negateThis():0===i.y&&(i.x=1)}Pr.st_defaultRank=1;class Dr{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,s(0),this.m_convexHull=t,this.m_function=this.done_}next(){return s(0),!1}get_vertex_handle_p(){return s(0),0}get_vertex_handle_q(){return s(0),0}get_current_support(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}intialize_(){return s(0),!1}increment_(){return s(0),!1}increment_q_(){return s(0),!1}increment_p_(){return s(0),!1}parallel_edge_with_q_support_(){return s(0),!1}parallel_edge_with_p_support_(){return s(0),!1}done_(){return s(0),!1}}class wr{nullGetXY(t){return h("m_getXY is null"),{}}nullDeleteNode(t){h("m_deleteNode is null")}constructor(t){return this.m_treeHull=new j,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=cr,void(this.m_pathHandle=cr)):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=cr,void(this.m_pathHandle=cr)):void d("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new Pr,this.m_geometryHandle=this.m_shape.createGeometry(i.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,cr),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 s(0),new Q}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){s(0)}addGeometry(s){if(s.isEmpty())return;const n=s.getGeometryType();if(n===i.enumGeometryCollection){const t=s;for(let e=0,s=t.getGeometryCount();e<s;e++)this.addGeometry(t.getGeometry(e))}else t(n)?this.addMultiVertexGeometry(s):m(n)?this.addSegment(s,!1):n===i.enumEnvelope?this.addEnvelope(s):n===i.enumPoint?this.addPoint(s):e("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new q,e=this.m_treeHull.getFirst(),s=new ur({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 s(0),new Dr(this)}getXY(t){return s(0),new Q}getXYWithIndex(t){return s(0),new Q}getFirst(){return s(0),0}getLast(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}getVertexIndex(t){return s(0),0}getPointCount(){return s(0),0}addMultiVertexGeometry(t){const e=new q,s=t.getImpl(),n=new Q;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 q;for(let s=0;s<4;s++){const n=new Q;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(t,n,r){const o=t.getGeometryType();if(s(o!==i.enumLine),o===i.enumEllipticArc){const e=t,s=60*Math.PI/180,i=Math.abs(e.getSweepAngle());if(i>s){const t=Math.min(6,Math.ceil(i/s)),r=1/t,o=new fm;e.queryStart(n[0]);let a=1;for(let s=0;s<t;s++){e.queryCut(s*r,(s+1)*r,o);const i=lt(Q,3);Bu(o.get(),i);const h=Q.calculateLength(i,3),u=Q.calculateLength(i,2),m=h>0?u/h:.5;s<t-1?o.get().queryEnd(n[a+1]):e.queryEnd(n[a+1]),q.lerp(n[a-1],n[a+1],m,n[a]),n[a].setXY(i[1]),a+=2}return a}{const e=lt(Q,3);Bu(t,e);const s=Q.calculateLength(e,3);t.queryStart(n[0]),t.queryEnd(n[2]);const i=Q.calculateLength(e,2),r=s>0?i/s:.5;return q.lerp(n[0],n[2],r,n[1]),n[1].setXY(e[1]),3}}if(o===i.enumBezier){const e=t,s=lt(Q,4);e.queryControlPoints(s);const i=Q.calculateLength(s,4),r=Q.calculateLength(s,2),o=Q.calculateLength(s,3);t.queryStart(n[0]),t.queryEnd(n[3]);const a=i>0?r/i:.5;q.lerp(n[0],n[3],a,n[1]),n[1].setXY(s[1]);const h=i>0?o/i:.5;return q.lerp(n[0],n[3],h,n[2]),n[2].setXY(s[2]),4}if(o===i.enumBezier2){const e=t,s=lt(Q,3);e.queryControlPoints(s);const i=Q.calculateLength(s,3);t.queryStart(n[0]),t.queryEnd(n[2]);const r=Q.calculateLength(s,2),o=i>0?r/i:.5;return q.lerp(n[0],n[2],o,n[1]),n[1].setXY(s[1]),3}if(o===i.enumRationalBezier2){const e=t,s=lt(Q,3);e.queryControlPoints(s);const i=Q.calculateLength(s,3);t.queryStart(n[0]),t.queryEnd(n[2]);const r=Q.calculateLength(s,2),o=i>0?r/i:.5;return q.lerp(n[0],n[2],o,n[1]),n[1].setXY(s[1]),3}e("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){const e=new q,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=lt(q,13);for(let s=1,n=wr.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=Q.orientationRobust(a,t,o);if(Mr(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(Yr(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);Yr(Q.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(!Mr(Q.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=Nr(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(Mr(Q.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(Mr(Q.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 Ar(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:Q.orientationRobust(t,e,s)}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:Q.orientationRobust(t,e,s)}function Ir(t,e,s,n){const i=new W(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||G.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(!(Ar(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(!(Tr(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 Mr(t){return t<0}function Yr(t){return t>0}function Nr(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 Xr(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function qr(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Fr(t,s,n,i,r){switch(r){case 0:break;case 1:s.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:s.negateThis(),t.negateThis();break;case 3:s.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:e("")}return Q.orientationRobustEx(t,s,n,i)}class Vr{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Lr(t){return Rr(t.calculateUpperLength2D())}function Rr(t){return 256*dt()*t}function zr(t){const e=Q.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function Br(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 kr(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),Wr(n,e,s)}function Gr(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),jr(n,e,s)}function Wr(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 jr(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 Zr(t,e,s=!1){const n=lt(Xe,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(it.constructInt32(3)),e[2].setCoords(n[2].x.sub(n[1].x),n[2].y.sub(n[1].y)),e[2].mulThis(it.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($t,$t):e[0]=n[0].clone()}function Hr(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Hr(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=Qr(t);if(n&&!Number.isNaN(i.length)&&!Number.isNaN(i.length))return i.length;const r=Lr(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+=$o(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function Ur(t,e,s){const n=Hr(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==tn(new Ko(t,e),H.unit(),1,i)&&h(""),i[0]}function Or(t,s,n){void 0===n&&(n=s,s=0);const i=new Q;if(s<0||n>1)return i.setNAN(),i;if(s>n&&e("calculate_sub_weightedCentroid"),s===n||t.isDegenerate(0))return i.setCoords(0,0),i;const r=Qr(t),o=Lr(t),a=o/t.calculateUpperLength2D();let h=s,u=0;for(let e=1,m=r.specialPointsCount();e<m;e++)if(s<r.specialPoints[e]){u=e-1;break}i.setCoords(0,0);for(let e=u+1,m=r.specialPointsCount();e<m;e++){const s=Math.min(r.specialPoints[e],n),u=ta(t,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}function Qr(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Vr,s=lt(at,8),n=lt(Q,4);t.queryControlPoints(n);const i=jo(n,s);e.specialPoints=[];for(let r=0;r<i;r++)e.specialPoints.push(s[r].value());return Jr(t,e),e}function Kr(t){let e=null;return e=t.m_cachedValues,e}function Jr(t,e){t.m_cachedValues=e}function $r(t){t.m_cachedValues=null}function to(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function eo(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 le,o=lt(Q,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new Q;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=lt(Q,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):(xt(e,s,1/3,t.m_cp[0]),xt(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),i&&lo(t)}function so(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function no(t,e,s,n){const i=lt(Q,4);t.queryControlPoints(i);const r=U(18,NaN),o=tn(new Vo(i,e,NaN),H.construct(s,n),18,r),a=new Q;t.queryCoord2D(s,a);let h=s,u=Q.distance(a,e);const m=new Q;t.queryCoord2D(n,m);const l=Q.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=Q.distance(m,e);s<u&&(u=s,h=r[c],a.assign(m))}return so(s,n,h,u,a)}function io(t,e){const n=lt(at,4);kr(t,n,!0);const i=lt(at,4);Gr(t,i,!0);const r=n[3].clone(),o=n[2].clone(),a=n[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),_=lt(at,3),p=dn(d,g,c,l,new H(0,1),!1,_);if(s(p<=3),p>0){const s=uo(t,1,0).sqrLength(),n=uo(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=uo(t,1,_[r].value()).sqrLength();s<i&&(i=s,e=_[r])}}}function ro(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 oo(t,e,s,n){{const e=ht.subE(s),i=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(i).addE(t[2].subE(t[1]).mulE(new at(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));n.setE(o.mulE(new at(3)))}}function ao(t,e,s){const n=new Q;return ro(t,e,s,n),n}function ho(t,e,s){const n=[Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2]),Ye.constructPoint2D(t[3])],i=new Ye;return oo(n,e,s,i),i}function uo(t,e,s){const n=lt(Q,4);return t.queryControlPoints(n),ao(n,e,s)}function mo(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 lo(t){const e=lt(Q,4);t.queryControlPoints(e);const s=co(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function co(t){return Fe(t)}function go(t){return Ve(t)}function _o(t,e,s){const n=new Q,i=new Q,r=new Q,o=new Q,a=new Q;e<=.5?(Xt(2,t[0],t[1],e,n),Xt(2,t[1],t[2],e,i),Xt(2,t[2],t[3],e,r),Xt(2,n,i,e,o),Xt(2,i,r,e,a),Xt(2,o,a,e,s)):(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))}function po(t,e,n,i){s(e>=0&&e<=1);const r=new Q,o=new Q,a=new Q,h=new Q,u=new Q,m=new Q;e<=.5?(Xt(2,t[0],t[1],e,r),Xt(2,t[1],t[2],e,o),Xt(2,t[2],t[3],e,a),Xt(2,r,o,e,h),Xt(2,o,a,e,u),Xt(2,h,u,e,m)):(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));const l=t[3].clone();n&&(n[0].assign(t[0]),n[1].assign(r),n[2].assign(h),n[3].assign(m)),i&&(i[0].assign(m),i[1].assign(u),i[2].assign(a),i[3].assign(l))}function fo(t,e,n,i){if(s(e>=0&&n<=1&&e<=n),e===n){const s=new Q;return Po(t,e,s),i[0].assign(s),i[1].assign(s),i[2].assign(s),void i[3].assign(s)}if(0===e&&1===n){for(let e=0;e<4;++e)i[e].assign(t[e]);return}const r=lt(Q,4);po(t,n,r,null),po(r,n>0?e/n:0,null,r),Po(t,e,r[0]),Po(t,n,r[3]),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]),i[2].setCoordsPoint2D(r[2]),i[3].setCoordsPoint2D(r[3])}function Po(t,e,s,n){if(n){if(e<0){return void _s(new pm({start:t[0],end:t[0].add(Co(t,0).getUnitVector())}),e,s)}if(e>1){return void _s(new pm({start:t[3],end:t[3].add(Co(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const n=new Q;Xt(2,t[0],t[1],e,n);const i=new Q;Xt(2,t[1],t[2],e,i);const r=new Q;Xt(2,t[2],t[3],e,r);const o=new Q;Xt(2,n,i,e,o);const a=new Q;Xt(2,i,r,e,a),Xt(2,o,a,e,s)}else{const n=new Q;qt(2,t[0],t[1],e,n);const i=new Q;qt(2,t[1],t[2],e,i);const r=new Q;qt(2,t[2],t[3],e,r);const o=new Q;qt(2,n,i,e,o);const a=new Q;qt(2,i,r,e,a),qt(2,o,a,e,s)}}function yo(t,e,s){if(e.value()<=.5){const n=new Ye;Ft(2,Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),e,n);const i=new Ye;Ft(2,Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2]),e,i);const r=new Ye;Ft(2,Ye.constructPoint2D(t[2]),Ye.constructPoint2D(t[3]),e,r);const o=new Ye;Ft(2,n,i,e,o);const a=new Ye;Ft(2,i,r,e,a),Ft(2,o,a,e,s)}else{const n=new Ye;Vt(2,Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),e,n);const i=new Ye;Vt(2,Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2]),e,i);const r=new Ye;Vt(2,Ye.constructPoint2D(t[2]),Ye.constructPoint2D(t[3]),e,r);const o=new Ye;Vt(2,n,i,e,o);const a=new Ye;Vt(2,i,r,e,a),Vt(2,o,a,e,s)}}function xo(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),yo(n,e,s)}function Co(t,e){const s=_t(e,0,1);let n=ao(t,1,s);return n.isZero()&&(n=ao(t,2,s),n.isZero()?n=ao(t,3,s):1===s&&n.negateThis()),n}function vo(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),bo(n,e,s)}function bo(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(ho(t,1,e))}function Eo(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==To(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function So(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(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!==am(e,s))return 2}else if(Le(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!==am(e,s))return t?4:2}else if(Le(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!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==No(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function To(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 Q;e.queryCoord2D(t[s],i),n.push(i)}}return a}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=lt(Q,4);Br(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=U(15,Number.NaN),P=U(15,Number.NaN);let y=sn(d,_,p,H.unit(),!1,f);y<0&&(f[0]=0,f[1]=1,y=2);let x,C=0;for(let E=0,S=C;E<y;++E){const t=e.getCoord2D(f[E+S]);P[C]=s.getClosestCoordinate(t,!1),Q.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[E+S],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=nn(d,_,p,x,H.unit(),v,b);for(let E=0,S=C;E<y;++E){f[E+S]=b[E];const t=e.getCoord2D(f[E+S]);P[C]=s.getClosestCoordinate(t,!1);Q.distance(t,s.getCoord2D(P[C]))<=o&&(f[C]=f[E+S],C++)}y=e.intersectPoint(s.getStartXY(),b,o);for(let E=0;E<y;E++)f[C]=b[E],P[C++]=0;y=e.intersectPoint(s.getEndXY(),b,o);for(let E=0;E<y;E++)f[C]=b[E],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:cm(t,e,s,f,P,C,n,i,r,o,a,h,u)}function Io(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return To(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=[],d=lt(Q,4);{e.queryControlPoints(d);const t=lt(Q,4),n=new le;s.canonicToWorldTransformation(n);const i=new le;i.setInvert(n),i.transformPoints2D(d,4,t);const r=lt(Xe,4);Zr(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=lt(it,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 _=qn(h,3,u,3,null,0,m,!0,H.unit(),H.unit(),c,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new Q;e.queryCoord2D(c[n],i);const r=s.getClosestCoordinate(i,!1),a=new Q;s.queryCoord2D(r,a);Q.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];Lo(d,t,H.unit(),!1,-1,1,e);const n=new Q;Po(d,e[0],n);Q.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 Q;s.queryCoord2D(e,n);Q.distance(d[t[p]],n)<=o&&(c.push(_[p]),g.push(e),l.push(n.clone()))}}return cm(t,e,s,c,g,c.length,n,i,r,o,a,h,u)}function Mo(t,e,n,i,r,o,a,h,u,m){const l=lt(Q,4);e.queryControlPoints(l);const c=lt(Q,4);if(n.queryControlPoints(c),as(l,c,4)<0)return Mo(t,n,e,i,o,r,a,h,u,!m);const g=rs(e,n);if(os(e,n,a=Math.max(a,g)))return 0;if(ea(e,n,i,r,o,a,h,u,m))return 2;const d=new H(0,1),_=new H(0,1);{const t=new De;Fo(l,new H(0,1),t);const e=new De;Fo(c,new H(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(Oo(l,t,d),d.isEmpty())return 0;if(Oo(c,t,_),_.isEmpty())return 0;fo(l,d.vmin,d.vmax,l),fo(c,_.vmin,_.vmax,c)}}const p=dm(l,3,c,3,a);if(0===p)return 0;const f=[],P=[],y=[];let x=!1;if(-1===p){const t=lt(Xe,4);Zr(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=lt(Xe,4);Zr(c,n);const i=[],r=[],o=Yn(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,H.unit(),H.unit(),i,r,u);if(o>0)for(let h=0;h<o;h++){const t=new Q;Po(c,r[h],t);const e=new Q;Po(l,i[h],e);Q.distance(e,t)<=a&&(f.push(e.clone()),y.push(r[h]),P.push(i[h]))}else-1===o&&(x=!0)}for(let s=0;s<2;s++){const t=0===s?l:c,e=0===s?c:l;for(let n=0;n<2;n++){const i=0===n?0:3,r=[0];Lo(e,t[i],H.unit(),!1,-1,1,r);const o=new Q;Po(e,r[0],o);Q.distance(t[i],o)<=a&&(0===s?(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()>n.calculateUpperLength2D();{const i=[0,0];if(2===Go(t?e:n,i,!0)&&(s(H.unit().containsCoordinate(i[0])),!H.unit().containsCoordinate(i[1]))){const e=new Q;Po(t?l:c,i[0],e);const s=[0,0];1===Lo(t?c:l,e,H.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 s=0;s<P.length;++s)P[s]=ia.recalculateParentT(d.vmin,d.vmax,P[s]);if(!_.equalsRange(0,1))for(let s=0;s<y.length;++s)y[s]=ia.recalculateParentT(_.vmin,_.vmax,y[s]);return cm(t,e,n,P,y,P.length,i,r,o,a,h,u,m)}function Yo(t,e,n,i,r,o,a,h,u,m){const l=rs(e,n);if(n.isDegenerateToLineHelper(l)){const s=new pm({start:n.getStartXY(),end:n.getEndXY()}),l=To(t,e,s,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=n.getClosestCoordinate(e,!1)}return l}if(os(e,n,a=Math.max(a,l)))return 0;const c=lt(Q,4);e.queryControlPoints(c);const g=lt(Q,3);n.queryControlPoints(g);const d=new H(0,1),_=new H(0,1),p=[0,0,0];n.queryWeights(p);const f=[1,fh(p),1];{const t=new De;Fo(c,new H(0,1),t);const e=new De;Wa(g,f,new H(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(Oo(c,t,d),d.isEmpty())return 0;if(ph(g,f,t,_),_.isEmpty())return 0;fo(c,d.vmin,d.vmax,c),Qa(g,f,_.vmin,_.vmax,g,f)}}const P=dm(c,3,g,2,a);if(0===P)return 0;const y=[],x=[],C=[];if(-1===P){const t=lt(Xe,4);Zr(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=lt(it,3),i=lt(it,3),r=lt(it,3);hh(g,f,n,i,r);const o=[],h=[],m=Yn(n,2,i,2,r,2,e,3,s,3,null,0,!0,H.unit(),H.unit(),h,o,u);if(m>0)for(let u=0;u<m;u++){const t=new Q;Po(c,o[u],t);const e=new Q;_h(g,f,h[u],e);Q.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 n=0;n<2;n++){const i=0===n?0:t.length-1,r=[0],o=new Q;if(0===v){const n=za(e,f,t[i],H.unit(),!1,-1,1,r);s(1===n),_h(e,f,r[0],o)}else{const n=Lo(e,t[i],H.unit(),!1,-1,1,r);s(1===n),Po(e,r[0],o)}Q.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 s=0;s<x.length;++s)x[s]=ia.recalculateParentT(d.vmin,d.vmax,x[s]);if(!_.equalsRange(0,1))for(let s=0;s<C.length;++s)C[s]=Sn.recalculateParentT(_.vmin,_.vmax,C[s]);for(let s=0;s<C.length;++s)C[s]=Ph(p,C[s]);return cm(t,e,n,x,C,x.length,i,r,o,a,h,u,m)}function No(t,e,n,i,r,o,a,h,u,m){const l=rs(e,n);if(os(e,n,a=Math.max(a,l)))return 0;const c=lt(Q,4);e.queryControlPoints(c);const g=lt(Q,3);n.queryControlPoints(g);const d=dm(c,3,g,2,a);if(0===d)return 0;const _=[],p=[],f=[];if(-1===d){const t=lt(Xe,4);Zr(c,t);const s=[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=lt(Xe,3);Wi(g,r);const o=Yn([r[0].x,r[1].x,r[2].x],2,[r[0].y,r[1].y,r[2].y],2,null,0,s,3,i,3,null,0,!0,H.unit(),H.unit(),f,p,h);if(o>0){let t=0;for(let s=0;s<o;s++){const i=new Q;e.queryCoord2D(p[s],i);const r=new Q;n.queryCoord2D(f[s],r);Q.distance(i,r)<=a&&(_.push(i.clone()),p[t]=p[s],f[t]=f[s],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 n=0;n<2;n++){const i=0===n?0:t.length-1,r=[0],o=new Q;if(0===P)vi(e,t[i],r),ji(e,r[0],o);else{const n=Lo(e,t[i],H.unit(),!1,-1,1,r);s(1===n),Po(e,r[0],o)}Q.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 cm(t,e,n,p,f,p.length,i,r,o,a,h,u,m)}function Xo(t,e,i,r,o){const a=new De;if(qo(t,H.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;const h=Qr(t);let u=0,m=h.specialPoints[0];const l=[];for(let n=1,c=h.specialPoints.length;n<c;++n){const i=h.specialPoints[n],r=no(t,e,m,i);if(0===l.length)l.push(r);else if(r.t===r.tmin)s(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){s(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=i}for(const s of l)if(s.d<=r){const t=s.t;i?(u>=i.length&&n(""),i[u]=t,u++):u++}return u}function qo(t,e,s){const n=lt(Q,4);t.queryControlPoints(n),Fo(n,e,s)}function Fo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const n=lt(Q,4);fo(t,e.vmin,e.vmax,n),s.setFromPoints(n,4)}let Vo=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 Q;Po(this.controlPoints,e,t);const s=ao(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new Q;Po(this.controlPoints,e,t);const s=ao(this.controlPoints,1,e),n=ao(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(n)+s.dotProduct(s))}case 2:{const t=new Q;Po(this.controlPoints,e,t);const s=ao(this.controlPoints,1,e),n=ao(this.controlPoints,2,e),i=ao(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(i)+3*s.dotProduct(n))}case 3:{const t=ao(this.controlPoints,1,e),s=ao(this.controlPoints,2,e),n=ao(this.controlPoints,3,e);return 2*(4*t.dotProduct(n)+3*s.sqrLength())}case 4:{const t=ao(this.controlPoints,2,e),s=ao(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=ao(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=lt(Q,4);fo(this.controlPoints,t,e,s);const n=new De;if(n.setFromPoints(s,4),Math.sqrt(n.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function Lo(t,e,n,i,r,o,a){_(H.unit().contains(n)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],u=new Q;Po(t,n.vmin,u);let m=Q.distance(u,e);if(m<=r&&h.push(new Q(n.vmin,m)),n.vmin!==n.vmax&&(Po(t,n.vmax,u),m=Q.distance(u,e),m<=r&&h.push(new Q(n.vmax,m))),n.width()>0){const s=U(18,Number.NaN),i=tn(new Vo(t,e,r),n,18,s);for(let n=0;n<i;n++)Po(t,s[n],u),m=Q.distance(u,e),m>r||h.push(new Q(s[n],m))}if(i){s(n.equals(H.unit()));{Po(t,-1,u,!0);const s=new Q;Po(t,0,s);const n=new pm({start:u,end:s}),i=n.getClosestCoordinate(e,!0);i<1&&(u.assign(n.getCoord2D(i)),m=Q.distance(u,e),m<=r&&h.push(new Q(i-1,m)))}{Po(t,2,u,!0);const s=new Q;Po(t,n.vmax,s);const i=new pm({start:s,end:u}),o=i.getClosestCoordinate(e,!0);o>0&&(u.assign(i.getCoord2D(o)),m=Q.distance(u,e),m<=r&&h.push(new Q(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=Z(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)=>Bt(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 Ro(t,e,s,n,i,r,o){const a=lt(Q,4);return t.queryControlPoints(a),Lo(a,e,s,n,i,r,o)}function zo(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function Bo(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function ko(t,e,n){if(s(n>=2),2===n){const s=new Q;xt(e[0],e[n-1],1/3,s);const i=new Q;return xt(e[0],e[n-1],2/3,i),void t.construct(e[0],s,i,e[n-1])}const i=e[0],r=e[n-1],o=[0,0],a=Ro(t,i,H.unit(),!1,Number.NaN,2,o),h=[0,0],u=Ro(t,r,H.unit(),!1,Number.NaN,2,h),m=[];for(let s=0;s<a;s++)for(let a=0;a<u;a++){const u=o[s],l=h[a],c=u>l,g=(s,o)=>{const a=U(n-2,Number.NaN),h=()=>{let t=0;for(let s=1,i=n-1;s<i;s++){t+=Q.distance(e[s-1],e[s]);const n=t;a[s-1]=n}t+=Q.distance(e[n-2],e[n-1]),c&&a.reverse();for(let e=1,s=n-1;e<s;e++)a[e-1]/=t,c&&(a[e-1]=1-a[e-1])};let m=!1,g=!1;{const e=new fm;c?(t.queryCut(l,u,e,!0),s.assign(e.get().getControlPoint2()),o.assign(e.get().getControlPoint1())):(t.queryCut(u,l,e,!0),s.assign(e.get().getControlPoint1()),o.assign(e.get().getControlPoint2())),i.equals(s)&&(m=!0),r.equals(o)&&(g=!0)}h();let d=Number.MAX_VALUE;const _=s.clone(),p=o.clone();for(let t=0;t<5;t++){d=sa(!0,!1,i,_,p,r,m,g,a,n-2,e,n)}for(let t=0;t<30;t++){const t=_.clone();p.clone();const s=sa(!0,!0,i,_,p,r,m,g,a,n-2,e,n);if(d<=s&&t.equals(_)&&t.equals(p))break;d=s}h();let f=!1,P=Number.MAX_VALUE;const y=s.clone(),x=o.clone();for(let t=0;t<30;t++){const t=y.clone();x.clone();const s=sa(f,!0,i,y,x,r,m,g,a,n-2,e,n);if(P<=s&&t.equals(y)&&t.equals(x))break;f=!0,P=s}return P<d?(s.assign(y),o.assign(x)):(s.assign(_),o.assign(p),P=d),P},d=new Q,_=new Q,p=[g(d,_),Q.distance(i,d)+Q.distance(d,_)+Q.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 s=6;s<m.length;s+=6)m[s]<l&&(l=m[s],c=m[s+1],g=s);let d=g;for(let s=0;s<m.length;s+=6)s!==g&&m[s+1]<c&&Math.abs(l-m[s])<10*l&&(c=m[s+1],d=s);t.construct(i,new Q(m[d+2],m[d+3]),new Q(m[d+4],m[d+5]),r)}function Go(t,e,s=!1){const n=lt(Q,4);t.queryControlPoints(n);const i=lt(Xe,4);let r,o,a;Zr(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=sn(1,-r.toDouble(),r.add(o).mul(r).add(a).toDouble(),H.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]=et(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]=et(e[0],e[0]=e[1])),2}return 0}function Wo(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=lt(at,2);let a=gn(r,i,n,new H(0,1),!1,o);a<0&&(a=0);let h=0;for(let u=0;u<a;u++)gt(o[u].value(),0,1)||(s[h].setE(o[u]),h++);return h}function jo(t,e){e[0].set(0);let n=1;const i=lt(at,4);Wr(t,i,!0);const r=lt(at,4);jr(t,r,!0);{const t=i[3].mul(3),s=i[2].mul(2),r=i[1].clone(),o=lt(at,2);let a=gn(t,s,r,new H(0,1),!1,o);a<0&&(a=0);for(let i=0;i<a;i++)gt(o[i].value(),0,1)||(e[n]=o[i],n++)}{const t=r[3].mul(3),s=r[2].mul(2),i=r[1].clone(),o=lt(at,2);let a=gn(t,s,i,new H(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)gt(o[r].value(),0,1)||(e[n]=o[r],n++)}if(n+=Wo(i,r,e.slice(n)),e[n].set(1),n++,n>2){tt(e,0,n,(t,e)=>{const s=t.value(),n=e.value();return s<n?-1:s>n?1:0});let s=0;const i=e[0].clone();let r=0;const o=Bo(t)*dt(),a=new Q;_o(t,e[0].value(),a);for(let h=1;h<n;h++){const n=new Q;if(_o(t,e[h].value(),n),e[h].eq(i)||n.isEqualPoint2D(a,o)){if(0!==s){if(0===e[h].eps())i.setE(e[h]),r=0;else if(0!==r){const t=zt(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[s].setE(i),_o(t,i.value(),a)}}else s++,e[s].setE(e[h]),i.setE(e[h]),_o(t,i.value(),a),r=zt(e[h].eps())}s++,n=s}return 1===n&&(n=2,e[1].set(1)),s(0===e[0].value()),s(1===e[n-1].value()),n}function Zo(t,e,s,n,i){const r=lt(at,4),o=lt(at,3),a=new H(0,1);let h=0;if(e){if(jr(t,r,!1),h=dn(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new Q;Po(t,o[u].value(),e),n[u]=e.x}}else if(Wr(t,r,!1),h=dn(r[3],r[2],r[1],r[0].sub(s),a,!1,o),n)for(let u=0;u<h;u++){const e=new Q;Po(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&&tt(n,0,h,Bt);return h}function Ho(t,e,s,n){const i=Uo(t,e,s,n.getEnvelope2D());if(i.isEmpty())return new H(i);const r=lt(Q,s);for(let a=0;a<s;++a)n.xyRot(t[a],r[a]);const o=Uo(r,e,s,n.getRotatedEnvelope2D());return i.intersect(new H(o)),new H(i)}function Uo(t,e,s,n){const i=lt(Q,s);for(let a=0;a<s;++a)i[a]=new Q(a/(s-1),0);const r=(t,e,s,n)=>{const i=.1,r=new at(e.x).subE(new at(t.x)).divE(new at(e.y).subE(new at(t.y))).mulE(new at(s).subE(new at(t.y))).addE(new at(t.x));if(r.eps()>i){const n=(e.x-t.x)/(e.y-t.y)*(s-t.y)+t.x;r.set(n,dt())}if(r.lt(new at(0))||r.gt(new at(1)))return!1;let o=r.value()-r.eps();o=_t(o,0,1);let a=r.value()+r.eps();return a=_t(a,0,1),n.mergeCoordinate(o),n.mergeCoordinate(a),!0},o=[];{const e=(t,e)=>{o.length=s;const n=xr(i,s,o,!0),a=new H;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 H(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 H(h)),new H(a)}}function Oo(t,e,s){s.setEmpty(),s.merge(Ho(t,null,4,e))}function Qo(t,e,s){s.length=0;{const e=new at;io(t,e);const n=new Ye;if(vo(t,e,n),n.isZero())return e.isZero()||e.eq(new at(1))?0:(s.push(e.value()),1)}const n=lt(at,4);kr(t,n,!0);const i=lt(at,4);Gr(t,i,!0);const r=lt(at,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=lt(at,5),b=_n(r,5,new H(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)&&!gt(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=Go(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-Hr(this.b,e,!1):0}getError(t){return 0}}function Jo(t,e,n,i,r,o,a){for(;;){const h=Q.distance(e[0],e[3]),u=Q.distance(e[0],e[1])+Q.distance(e[1],e[2])+Q.distance(e[2],e[3]);if(u-h<=i+n*u)return t+rt(h,u,.5);const m=t=>ao(e,1,t).length();{s(a<12);let h=m(0),l=m(1);r[0]+=2,h>l&&(l=et(h,h=l),e[3]=et(e[0],e[0]=e[3]),e[2]=et(e[1],e[1]=e[2]));let c=h/(h+l),g=1,d=u;for(;c<1/32&&d>=32*(i+n*d);){g/=4;const t=m(g);r[0]++,c=h/(t+h);const s=new Q;if(Po(e,.5*g,s),d=Q.distance(s,e[0]),d<=i){const t=new Q;Po(e,g,t),d+=Q.distance(t,s)}}if(1!==g){const s=lt(Q,4);po(e,g,e,s),t=Jo(t,s,n,i,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=hr(l,m,0,1),g=16;r[0]+=g;const d=hr(g,m,0,1);let _=Math.abs(c-d)>i+n*u;if(!_)return t+d;if(o<3){const s=lt(Q,4);po(e,.5,e,s),t=Jo(t,s,n,i,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const f=hr(p,m,0,1);if(_=Math.abs(d-f)>i+n*u,!_)return t+f;const P=64;r[0]+=P;const y=hr(P,m,0,1);if(_=Math.abs(f-y)>i+n*u,!_)return t+y;const x=128;r[0]+=x;const C=hr(x,m,0,1);return _=Math.abs(y-C)>i+n*u,t+C}}function $o(t,e,s,n,i){if(s===e)return 0;const r=lt(Q,4);t.queryControlPoints(r);const o=lt(Q,4);fo(r,e,s,o);return Jo(0,o,n,i,[0],0,0)}function ta(t,e,s,n,i){let r=!0;const o=Kn(5,e,s,n,i,e=>{const s=uo(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=uo(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()});return new Q(o,a)}function ea(t,e,s,n,i,r,o,a,h){const u=lt(Q,4);t.queryControlPoints(u);const m=lt(Q,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]=et(n[0],n[0]=n[1]))),i&&(i.length=0,i.push(1),i.push(0),h&&(i[1]=et(i[0],i[0]=i[1]))),s&&(s.length=0,s.push(u[0]),s.push(u[3]),h&&(s[1]=et(s[0],s[0]=s[1]))),!0)}function sa(t,e,n,i,r,o,a,h,u,m,l,c){s(m+2===c);let g=0,d=0,_=0,p=0,f=0,P=0,y=0;const x=(t,e)=>{const s=1-e,a=n.mul(oe(s)),h=i.mul(3*e*s*s),u=r.mul(3*e*e*s),m=o.mul(oe(e));return a.add(h).add(u).add(m).sub(l[t]).sqrLength()};for(let s=1,v=c-1;s<v;s++){let e=u[s-1];if(t){s>2?(e=_t(2*u[s-2]-u[s-3],0,1),u[s-1]=e):2===s&&(e=_t(2*u[s-2],0,1),u[s-1]=e);const t=(t,e,s)=>{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=n.x-2*i.x+r.x,d=n.x-3*i.x+3*r.x-o.x,_=n.y-2*i.y+r.y,p=n.y-3*i.y+3*r.y-o.y,f=n.x-i.x-2*g*e+d*h,P=-l[t].x+n.x*c+e*(3*i.x*m+e*(3*r.x*u+o.x*e)),y=n.y-i.y-2*_*e+p*h,x=-l[t].y+n.y*c+e*(3*i.y*m+e*(3*r.y*u+o.y*e)),C=-6*(f*P+y*x),v=6*(3*zt(f)-(-2*g+2*d*e)*P)+6*(3*zt(y)-(-2*_+2*p*e)*x);if(a=e,0===v)break;e=_t(e-C/v,s,1)}return a};{const e=x(s,u[s-1]);let n=t(s,u[s-1],0),i=x(s,n);if(1.01*e<i){const e=s>1?u[s-2]:0,r=t(s,.3*(u[s-1]-e)+e,0),o=x(s,r);o<i&&(i=o,n=r)}e>i&&(u[s-1]=n)}}const a=u[s-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*n.x+m*o.x-l[s].x);p+=b*a*C,f+=b*h*c;const E=-(v*n.y+m*o.y-l[s].y);P+=E*a*C,y+=E*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)):(xt(n,o,.3,i),xt(n,o,.6,r))}let C=0;for(let s=1,v=c-1;s<v;s++)C+=x(s,u[s-1]);return C}var na=b;class ia extends gs{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=lt(Q,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||vt(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=lt(Q,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=lt(Q,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}),h("unrecognized constructor params"),this.m_cp=lt(Q,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=lt(Q,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(),Dt(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),Dt(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),ss(this,t)}getGeometryType(){return i.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void s(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 Q;for(const n of e.specialPoints)this.queryCoord2D(n,s),t.mergeNe(s);return}const n=lt(at,8),i=lt(Q,4);this.queryControlPoints(i);const r=jo(i,n),o=new Q;for(let s=1;s<r-1;s++)this.queryCoord2D(n[s].value(),o),t.mergeNe(o)}applyTransformation(t){if(1===t.m_TransformationType){const e=lt(Q,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 $r(this)}s(0)}createInstance(){return new ia({vd:this.m_description})}calculateLength2D(){return Hr(this,1,!1)}calculateLowerLength2D(){return Q.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return Q.distance(this.getStartXY(),this.m_cp[0])+Q.distance(this.m_cp[0],this.m_cp[1])+Q.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){s(0)}queryCoord2DExtends(t,e,s){const n=lt(Q,4);this.queryControlPoints(n),Po(n,t,e,s)}queryCoord2DE(t,e){xo(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new Q;return this.queryCoord2DExtends(t,e,!0),e.x}const e=rt(this.getStartX(),this.m_cp[0].x,t),s=rt(this.m_cp[0].x,this.m_cp[1].x,t),n=rt(this.m_cp[1].x,this.getEndX(),t),i=rt(e,s,t),r=rt(s,n,t);return rt(i,r,t)}getCoordY(t){if(t<0||t>1){const e=new Q;return this.queryCoord2DExtends(t,e,!0),e.y}const e=rt(this.getStartY(),this.m_cp[0].y,t),s=rt(this.m_cp[0].y,this.m_cp[1].y,t),n=rt(this.m_cp[1].y,this.getEndY(),t),i=rt(e,s,t),r=rt(s,n,t);return rt(i,r,t)}cut(t,e,s){const n=new fm;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=na.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=na.getComponentCount(s);for(let t=0;t<n;t++){const n=this.getAttributeAsDbl(e,s,t);i.setEndAttribute(s,t,n)}}}}queryDerivative(t,e){vo(this,t,e)}cutBezierIgnoreAttributes(t,s,n){(t<0||s>1||t>s)&&e("Cubic_bezier.cut_bezier_ignore_attributes");const i=lt(Q,4);this.queryControlPoints(i);const r=lt(Q,4);fo(i,t,s,r),n.setControlPoints(r)}splitBezierIgnoreAttributes(t,s,n){this===s&&this===n&&e("Cubic_bezier.split_bezier_ignore_attributes");const i=lt(Q,4);this.queryControlPoints(i);const r=lt(Q,4),o=lt(Q,4);po(i,t,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=na.getInterpolation(e);return Ct(a,n,i,o,na.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return Ro(this,t,H.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const n=[Number.NaN];return 0===Ro(this,t,e,!1,s,1,n)?Number.NaN:n[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,n){t.length<2&&e("");const i=Qr(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;s(t.length>=i.specialPointsCount()-1);for(let e=1,s=i.specialPointsCount();e<s;++e)this.queryCut(i.specialPoints[e-1],i.specialPoints[e],t[r],n),r++;for(let e=0;e<r;++e){lo(t[e].get())}return r}intersectionWithAxis2D(t,e,s,n){const i=lt(Q,4);return this.queryControlPoints(i),Zo(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 n=[0,0],i=this.intersectionWithAxis2D(!0,t,n,null);return s(2!==i),-1===i?e:n[0]}isCurve(){return!0}isDegenerate(t){return Re(this,t)}isDegenerate3D(t,e){return s(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());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=me.constructEmpty();this.queryEnvelope(t);const s=H.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=lt(Q,4);this.queryControlPoints(s),fo(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 Hr(this,t,!0)}lengthToT(t){return Ur(this,t)}calculateWeightedAreaCentroid2D(t){const e=lt(Q,4);Br(this,e);const s=e[3],n=e[2],i=e[1],r=new Q;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=mo(this);return r.x+=(e[0].x-t.x)*o,r.y+=(e[0].y-t.y)*o,r}calculateWeightedCentroid2D(){const t=new Q;return this.isDegenerate(0)?(t.setCoords(0,0),t):zr(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Or(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(t){for(let s=0;s<4;s++)t[s].isNAN()&&e("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=lt(Q,4);return this.queryControlPoints(e),Co(e,t)}getDerivative(t){const e=lt(Q,4);return this.queryControlPoints(e),ao(e,1,t)}getCurvature(t){const e=uo(this,1,t),s=uo(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 me;if(this.queryLooseEnvelope(n),n.inflateCoords(e,e),!n.contains(t))return!1;const i=this.getClosestCoordinate(t,!1),r=new Q;this.queryCoord2D(i,r);return Q.distance(r,t)<=e}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}isMonotoneQuickAndDirty(){const t=lt(Q,4);return this.queryControlPoints(t),go(t)}getMonotonicPartParams(t,n){const i=Qr(this),r=i.specialPointsCount();if(s(us.s_maxMonotonicPartParams>=r),!n)return i.specialPointsCount();t<r&&e("");for(let e=0;e<r;e++)n[e]=i.specialPoints[e];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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(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]=et(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=et(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new at;return io(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=lt(Q,4);this.queryControlPoints(e);const s=e[3].sub(e[0]),n=s.length();if(Q.distance(e[0],e[1])+Q.distance(e[2],e[1])+Q.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=lt(Q,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return mo(this)}absNorm(){return zo(this)}queryEnvelopeW(t,e){qo(this,t,e)}setSegmentFromCoordsForStitcher(t,e){ko(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=lt(Q,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=lt(Q,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if(Q.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);Q.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=lt(Q,4);this.queryControlPoints(e);const s=(e,s,n)=>{let i=!1;if(Q.sqrDistance(e,n)<=t){i=!e.equals(n),e.setCoordsPoint2D(n);Q.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 Qo(this,t,e)}ensureXYMonotone(){return lo(this)}setCoordsForIntersector(t,e,s){eo(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,Kr(this))}reverseImpl(){this.m_cp[1]=et(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]=et(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=et(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),to(this,e)}afterCompletedModification(){$r(this)}isIntersecting(t,e,s){return 0!==rm(!1,this,t,e,s)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){return Xo(this,t,e,s)}endPointModified(){$r(this)}clearEndPointModified(){}}ia.type=i.enumBezier;class ra{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 oa(t,e,n,i,r,o,a,h){for(;;){const u=Q.distance(e[0],e[2]),m=Q.distance(e[0],e[1])+Q.distance(e[1],e[2]);if(m-u<=r+i*m)return t+rt(u,m,.5);const l=lt(Q,4),c=t=>{fa(e,n,1,t,l);return l[1].length()};if(0===a&&h<8){s(h<8);let u=c(0),l=c(1);o[0]+=2,u>l&&(l=et(u,u=l),e[2]=et(e[0],e[0]=e[2]),n[2]=et(n[0],n[0]=n[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 s=new Q;if(_h(e,n,.5*d,s),_=Q.distance(s,e[0]),_<=r){const t=new Q;_h(e,n,d,t),_+=Q.distance(t,s)}}if(1!==d){const s=lt(Q,3),u=[0,0,0];Oa(e,n,d,e,n,s,u),t=oa(t,s,u,i,r,o,0,h+1),a++,h++;continue}}let g=!1;const d=8;o[0]+=d;const _=hr(d,c,0,1),p=16;o[0]+=p;const f=hr(p,c,0,1);if(g=Math.abs(_-f)>r+i*m,!g)return t+f;if(a<8&&h<9){const s=lt(Q,3),u=[0,0,0];Oa(e,n,.5,e,n,s,u),t=oa(t,s,u,i,r,o,a+1,h+1),a++,h++;continue}const P=32;o[0]+=P;const y=hr(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=hr(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=hr(v,c,0,1);return g=Math.abs(C-b)>r+i*m,t+b}}function aa(t,e,s,n,i){if(s===e)return 0;const r=lt(Q,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=lt(Q,3);Qa(r,o,e,s,h,a);return oa(0,h,a,n,i,[0],0,0)}class ha{constructor(t,e,s){this.controlPoints=ct(t,3),this.weights=[0,0,0],J(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new Q;_h(this.controlPoints,this.weights,e,t);const s=lt(Q,4);fa(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new Q;_h(this.controlPoints,this.weights,e,t);const s=lt(Q,4);fa(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 Q;_h(this.controlPoints,this.weights,e,t);const s=lt(Q,4);fa(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 s(0),0}}function ua(t,e,s,n){const i=Ba(0,0,0,0,Q.getNAN()),r=U(18,Number.NaN),o=lt(Q,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,fh(a),1],u=yh(a,s),m=yh(a,n),l=tn(new ha(o,h,new Q(0,0)),H.construct(u,m),18,r);_h(o,h,u,i.pt),i.t=u,i.d=Q.distance(i.pt,new Q(0,0));const c=new Q;_h(o,h,m,c);const g=Q.distance(c,new Q(0,0));g<i.d&&(i.d=g,i.t=m,i.pt.assign(c));for(let d=0;d<l;d++){_h(o,h,r[d],c);const t=Q.distance(c,new Q(0,0));t<i.d&&(i.d=t,i.t=Ph(a,r[d]),i.pt.assign(c))}return i}function ma(t,e,s,n,i){let r=!0;const o=lt(Q,4),a=Kn(5,e,s,n,i,e=>{pa(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=>{pa(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()});return new Q(a,h)}function la(t){t.m_cachedValues=null}function ca(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function ga(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ra,s=lt(Q,3);t.queryControlPoints(s);const n=[0,0,0];return t.queryWeights(n),da(s,n,e.specialPoints),La(t,e),e}function da(t,e,s){if(0===e[1])return s.length=0,s.push(0),void s.push(1);const n=lt(at,8);n[0].set(0);let i=1;{const s=new at(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new at(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new at(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=lt(at,2);let h=gn(o,r,s,new H(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)gt(a[t].value(),0,1)||(n[i]=a[t],i++)}{const s=new at(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new at(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new at(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=lt(at,2);let h=gn(o,r,s,new H(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)gt(a[t].value(),0,1)||(n[i]=a[t],i++)}if(n[i].set(1),i++,i>2){tt(n,0,i,(t,e)=>Bt(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 _a(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+_a(t,1,!1)}if(t.isDegenerate(0))return 0;const n=1===e,i=ga(t);if(n&&!Number.isNaN(i.length))return i.length;const r=Xa(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+=aa(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return n&&(i.length=a),a}function pa(t,e,s,n){const i=lt(Q,3);t.queryControlPoints(i);const r=[0,0,0];t.queryWeights(r),fa(i,r,e,s,n)}function fa(t,e,s,n,i){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=lt(Q,4);Pa(r,o,s,n,a);for(let h=0;h<=s;h++)i[h].setCoords(a[h].x,a[h].y)}function Pa(t,e,n,i,r){s(n>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].subThis(o[0]);o[0].setCoords(0,0)}const a=ya(o,e,0,i),u=Ca(e,0,i),m=a.divide(u);if(r[0].assign(m),0===n)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=ya(c,l,0,i).mul(2).divide(g);if(r[1].assign(d),1===n)return;const _=Ca(e,1,i),p=2*u*_,f=ya(c,l,1,i).mul(2).sub(d.mul(p)).divide(g);if(r[2].assign(f),2===n)return;const P=ya(c,l,2,i).mul(2),y=2*(_*_+u*Ca(e,2,i)),x=P.sub(f.mul(p).mul(2)).sub(d.mul(y)).divide(g);r[3].assign(x),3!==n&&h("")}function ya(t,e,s,n){if(0===s){if(n<=.5){const s=new Q;Xt(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new Q;Xt(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new Q;return Xt(2,s,i,n,r),r}{const s=new Q;qt(2,t[0].mul(e[0]),t[1].mul(e[1]),n,s);const i=new Q;qt(2,t[1].mul(e[1]),t[2].mul(e[2]),n,i);const r=new Q;return qt(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}h("")}function xa(t,e,s,n){if(n.toDouble()<=.5){const s=new Ye;Ft(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new Ye;Ft(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new Ye;return Ft(2,s,i,n,r),r}{const s=new Ye;Vt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),n,s);const i=new Ye;Vt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),n,i);const r=new Ye;return Vt(2,s,i,n,r),r}}function Ca(t,e,s){if(0===e){const e=rt(t[0],t[1],s),n=rt(t[1],t[2],s);return rt(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]))}h("")}function va(t,e,s){if(s.toDouble()<=.5){const e=Ut(t[0],t[1],s),n=Ut(t[1],t[2],s);return Ut(e,n,s)}{const e=Ot(t[0],t[1],s),n=Ot(t[1],t[2],s);return Ot(e,n,s)}}function ba(t,e,s,n,i){const r=[Ye.constructPoint2D(t[0]),Ye.constructPoint2D(t[1]),Ye.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);Ea(r,[new at(e[0]),new at(e[1]),new at(e[2])],s,n,i)}function Ea(t,e,n,i,r){s(n>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]=Ye.constructCoords(0,0)}const a=xa(o,e,0,i),h=va(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=xa([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 Sa(t,e,s){const n=lt(Q,3);t.queryControlPoints(n);const i=U(3,Number.NaN);t.queryWeights(i),Da(n,i,e,s)}function Da(t,e,s,n){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const i=lt(Ye,4);ba(t,e,1,s,i),n.setE(i[1])}function wa(t,e,s){const n=_t(s,0,1),i=lt(Q,4);if(fa(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 Aa{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-_a(this.b,e,!1):0}getError(t){return s(0),0}}function Ta(t,e,s){const n=_a(t,1,!1);if(e<=0)return e;if(e>=n)return e-n+1;const i=[0];return 1!==tn(new Aa(t,e),H.unit(),1,i)&&h(""),i[0]}function Ia(t){const e=lt(Q,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Ma(e,s)}function Ma(t,e){const n=fh(e);if(1===n){return fi(t)}if(0===n)return 0;const i=[new Q(0,0),t[1].sub(t[0]),t[2].sub(t[0])],r=i[1].crossProduct(i[2]);if(n<1){s(n>0);const t=1-n;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 s=t*(1+n),i=Math.atan2(Math.sqrt(t),Math.sqrt(1+n));e=n*(.5*n-he(s)*i)/s}return r*e}{const t=(n-1)*(n+1);return.25*n/Math.pow(t,1.5)*(-2*n*Math.sqrt(t)*r-4*i[1].y*i[2].x*Math.atanh(Math.sqrt((n-1)/(n+1)))-i[1].x*i[2].y*Math.log(2*n*(n-Math.sqrt(t))-1))}}function Ya(t,e){const n=fh(e);if(1===n){const e=lt(Q,3);zi(t,e);const s=e[2].clone(),n=e[1].clone(),i=new Q,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===n)return new Q(0,0);s(n>0);const i=t[1].sub(t[0]),r=t[2].sub(t[0]);if(n<1){const t=Math.sqrt(1-n),e=Math.sqrt(1+n),s=(i.y*r.x-i.x*r.y)*n/Math.pow(t*e,5)/12,o=Math.atan2(t,e),a=n*t*e,h=n*n,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(s)}{const t=Math.sqrt(n-1),e=Math.sqrt(n+1),s=(i.y*r.x-i.x*r.y)*n/Math.pow(t*e,5)/12,o=Math.atanh(t/e),a=n*t*e,h=n*n,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(s)}}function Na(t){const e=lt(Q,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Ya(e,s)}function Xa(t){return qa(t.calculateUpperLength2D())}function qa(t){return 256*dt()*t}function Fa(t){if(0===t.m_weights[1])return!0;const e=Q.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function Va(t){return t.m_cachedValues}function La(t,e){t.m_cachedValues=e}function Ra(t,e,s,n,i){const r=lt(Q,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===za(r,o,e,H.unit(),n,i,1,a)?a[0]:Number.NaN}function za(t,e,n,i,r,o,a,h){_(H.unit().contains(i)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const u=new Array(3);for(let s=0;s<3;++s)u[s]=t[s].sub(n);const m=fh(e),l=Xe.constructPoint2D(u[0]),c=Xe.constructPoint2D(u[1]),g=Xe.constructPoint2D(u[2]),d=it.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),E=c.sqrLength().mul(d.mul(d).ldexp(2)),S=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(E).addThis(S).addThis(D),A=l.add(g).sub(c.mul(p)),T=d.subDouble(1),I=g.sub(l).dotProduct(A).mul(T),M=new Q(0,0),Y=[];let N=new Q;_h(u,e,i.vmin,N);let X=Q.distance(N,M);if(X<=o&&Y.push(new Q(i.vmin,X)),i.vmin!==i.vmax&&(_h(u,e,i.vmax,N),X=Q.distance(N,M),X<=o&&Y.push(new Q(i.vmax,X))),i.width()>0){const t=u[2].isZero(),s=lt(it,4),n=Rn(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=Ph(e,t);const n=new Q;_h(u,e,t,n),X=Q.distance(n,M),X<=o&&Y.push(new Q(t,X))}}if(r){s(i.equals(H.unit()));{_h(u,e,-1,N,!0);const t=new Q;_h(u,e,0,t);const s=new pm({start:N,end:t}),n=s.getClosestCoordinate(M,!0);n<1&&(N=s.getCoord2D(n),X=Q.distance(N,M),X<=o&&Y.push(new Q(n-1,X)))}{_h(u,e,2,N,!0);const t=new Q;_h(u,e,i.vmax,t);const s=new pm({start:t,end:N}),n=s.getClosestCoordinate(M,!0);n>0&&(N=s.getCoord2D(n),X=Q.distance(N,M),X<=o&&Y.push(new Q(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=Z(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)=>Bt(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 Ba(t,e,s,n,i){return{tmin:t,tmax:e,t:s,d:n,pt:i.clone()}}function ka(t,e,n,i,r){const o=new De;if(Ga(t,H.unit(),o),o.inflate(i),!o.isIntersectingPoint2D(e))return 0;const a=ga(t);let h=0;const u=[];let m=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const n=a.specialPoints[l],i=ua(t,e,m,n);if(0===u.length)u.push(i);else if(i.t===i.tmin)s(u.at(-1).d<=i.d),u.at(-1).tmax=i.tmax;else if(u.at(-1).t===u.at(-1).tmax){s(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=n}for(const s of u)if(s.d<=i){const t=s.t;n?(n[h]=t,h++):h++}return h}function Ga(t,e,s){const n=lt(Q,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i),Wa(n,i,e,s)}function Wa(t,e,s,n){if(s.equalsRange(0,1))return void n.setFromPoints(t,3);const i=lt(Q,3),r=[0,0,0];Qa(t,e,s.vmin,s.vmax,i,r),n.setFromPoints(i,3)}function ja(t){const e=nt(t[0].y,t[1].y),s=nt(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=nt(t[0].x,t[1].x),s=nt(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function Za(t){const e=lt(Q,3);t.queryControlPoints(e);const s=Ha(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Ha(t){let e=!1;for(let s=0;s<2;s++){const n=nt(t[0][s],t[2][s]);n>0?(nt(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):n<0?(nt(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),nt(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 Ua(t,s,n){void 0===n&&(n=s,s=0);const i=new Q;if(s<0||n>1)return i.setNAN(),i;if(s>n&&e("calculate_sub_weighted_centroid"),s===n||t.isDegenerate(0))return i.setCoords(0,0),i;const r=ga(t),o=Xa(t),a=o/t.calculateUpperLength2D();let h=s,u=0;for(let e=1,m=r.specialPointsCount();e<m;e++)if(s<r.specialPoints[e]){u=e-1;break}i.setCoords(0,0);for(let e=u+1,m=r.specialPointsCount();e<m;e++){const s=Math.min(r.specialPoints[e],n),u=ma(t,h,s,a,o);if(i.addThis(u),h=s,n<=r.specialPoints[e])break}return i.add(t.getStartXY().mul(t.calculateLength2D()))}function Oa(t,e,n,i,r,o,a){s(n>=0&&n<=1&&i!==o&&r!==a),s(e[0]>0&&e[2]>0&&e[1]>=0);const h=[1,fh(e),1],u=yh(e,n),m=ct(t,3),l=lt(E,3);uh(m,h,l);const c=lt(E,3),g=lt(E,3);xh(l,u,i?c:null,o?g:null),Ch(e,n,r,a);const d=ja(m);if(i){for(let t=0;t<3;++t)dh(c[t],i[t]);bh(m,i),d&&Ha(i)}if(o){for(let t=0;t<3;++t)dh(g[t],o[t]);bh(m,o),d&&Ha(o)}}function Qa(t,e,n,i,r,o){if(s(n>=0&&i<=1&&n<=i),n===i){const s=new Q,i=mh(t,e,n,s);return vh(t,s),r[0].assign(s),r[1].assign(s),r[2].assign(s),o[0]=i,o[1]=i,void(o[2]=i)}if(0===n&&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=lt(E,3);{const s=[1,fh(e),1],r=yh(e,n),o=yh(e,i);uh(t,s,a),xh(a,o,a,null);xh(a,r>=o?1:r/o,null,a)}const h=[0,0,0];Ch(e,i,h,null),Ch(h,n/i,null,h);const u=ja(t),m=lt(Q,3);dh(a[1],m[1]),_h(t,e,n,m[0]),_h(t,e,i,m[2]),bh(t,m);for(let s=0;s<3;++s)r[s].assign(m[s]),o[s]=h[s];u&&Ha(r)}function Ka(t,e,s){const n=fh(e),i=[1,n,1],r=4*n/(3*(1+n));s[0].assign(t[0]),s[3].assign(t[2]),xt(t[0],t[1],r,s[1]),xt(t[2],t[1],r,s[2]),new ia({cp:s}),new Sn({points:t,weight:n});let o=0,a=.1,h=0;for(let u=0;u<9;u++,a+=.1){const e=new Q;_h(t,i,a,e);const n=new Q;Po(s,a,n);const r=Q.sqrDistance(e,n);r>o&&(o=r,h=a)}{const e=new Q;_h(t,i,h,e);const n=[0];Lo(s,e,H.unit(),!1,-1,1,n);const r=new Q;return Po(s,n[0],r),o=Q.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 le,o=lt(Q,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new Q;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=lt(Q,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):xt(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),i&&Za(t)}function $a(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==nh(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function th(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==ih(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function eh(t,e,s,n,i){if(i){const n=am(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(Le(e,s))return 1;return 0!==rh(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function sh(t,e,s,n,i){if(i){if(0!==am(e,s))return t?4:2}else if(Le(e,s))return 1;return 0!==oh(t,e,s,null,null,null,n,i??!1,!0,!1)?4:0}function nh(t,e,n,i,r,o,a,h,u,m){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0),n.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(n.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!=o)for(let t=0;t<s;t++)o.push(0);if(null!=i)for(let n=0;n<s;n++){const s=new Q;e.queryCoord2D(t[n],s),i.push(s)}}return s}const l=rs(e,n);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new pm({start:e.getStartXY(),end:e.getEndXY()}),s=Ds(t,n,i,r,o,a,h,m);if(r)for(let n=0;n<s;++n){const s=t.getCoord2D(r[n]);r[n]=e.getClosestCoordinate(s,!1)}return s}if(os(e,n,a))return 0;const c=lt(Q,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[1,fh(g),1],_=n.getEndXY().sub(n.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],E=d[1],S=d[2],D=b*E,w=b*S,A=E*S,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=U(13,Number.NaN),q=U(13,Number.NaN);let F=sn(N,Y,M,H.unit(),!1,X);F<0&&(X[0]=0,X[1]=1,F=2);let V=0;for(let s=0,k=V;s<F;++s){const t=new Q;_h(c,d,X[s+k],t),q[V]=n.getClosestCoordinate(t,!1);Q.distance(t,n.getCoord2D(q[V]))<=a&&(X[V]=X[s+k],V++)}const L=lt(Q,3),R=lt(Q,3);if(e.queryControlPoints(R),R[0].subThis(n.getStartXY()),R[1].subThis(n.getStartXY()),R[2].subThis(n.getStartXY()),ah(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(n.getStartXY())||e.getEndXY().equals(n.getEndXY()),B=[0,0];F=sn(N,Y,M,H.unit(),z,B);for(let s=0,k=V;s<F;++s){X[s+k]=B[s];const t=new Q;_h(c,d,X[s+k],t),q[V]=n.getClosestCoordinate(t,!1);Q.distance(t,n.getCoord2D(q[V]))<=a&&(X[V]=X[s+k],V++)}s(V<X.length+4);for(let s=0;s<V;s++)X[s]=Ph(g,X[s]);F=e.intersectPoint(n.getStartXY(),B,a);for(let s=0;s<F;s++)X[V]=B[s],q[V++]=0;F=e.intersectPoint(n.getEndXY(),B,a);for(let s=0;s<F;s++)X[V]=B[s],q[V++]=1;F=n.intersectPoint(e.getStartXY(),B,a);for(let s=0;s<F;s++)q[V]=B[s],X[V++]=0;F=n.intersectPoint(e.getEndXY(),B,a);for(let s=0;s<F;s++)q[V]=B[s],X[V++]=1;return 0===V?0:cm(t,e,n,X,q,V,i,r,o,a,h,u,m)}function ih(t,e,s,n,i,r,o,a,h,u){if(Eu(s)){return nh(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=[],c=[],g=lt(Q,4);{e.queryControlPoints(g);const t=lt(Q,4),n=new le;s.canonicToWorldTransformation(n);const i=new le;i.setInvert(n),i.transformPoints2D(g,4,t);const r=lt(it,3),h=lt(it,3),u=lt(it,3),m=[0,0,0];e.queryWeights(m),hh(t,m,r,h,u);const d=lt(it,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 _=qn(r,2,h,2,u,2,d,!0,H.unit(),H.unit(),l,a);if(_>0){let t=0;for(let n=0;n<_;n++){const i=new Q;e.queryCoord2D(l[n],i);const r=s.getClosestCoordinate(i,!1),a=new Q;s.queryCoord2D(r,a);Q.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=Ra(e,t,H.unit(),!1,-1),i=new Q;e.queryCoord2D(n,i);Q.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 Q;s.queryCoord2D(e,n);Q.distance(g[t[_]],n)<=o&&(l.push(d[_]),c.push(e))}}return cm(t,e,s,l,c,l.length,n,i,r,o,a,h,u)}function rh(t,e,n,i,r,o,a,h,u,m){const l=lt(Q,3);e.queryControlPoints(l);const c=lt(Q,3);if(n.queryControlPoints(c),as(l,c,3)<0)return rh(t,n,e,i,o,r,a,h,u,!m);const g=rs(e,n);if(e.isDegenerateToLineHelper(g)){const s=new pm({start:e.getStartXY(),end:e.getEndXY()}),l=nh(t,n,s,i,o,r,a,h,u,!m);if(r)for(let t=0;t<l;++t){const n=s.getCoord2D(r[t]);r[t]=e.getClosestCoordinate(n,!1)}return l}if(n.isDegenerateToLineHelper(g)){const s=new pm({start:n.getStartXY(),end:n.getEndXY()}),l=nh(t,e,s,i,r,o,a,h,u,m);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=n.getClosestCoordinate(e,!1)}return l}if(os(e,n,a=Math.max(a,g)))return 0;const d=U(3,Number.NaN);e.queryWeights(d);const _=U(3,Number.NaN);n.queryWeights(_);const p=[1,fh(d),1],f=[1,fh(_),1],P=new H(0,1),y=new H(0,1);{const t=De.constructEmpty();Wa(l,p,new H(0,1),t);const e=De.constructEmpty();Wa(c,f,new H(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(ph(l,p,t,P),ph(c,f,t,y),P.isEmpty()||y.isEmpty())return 0;Qa(l,p,P.vmin,P.vmax,l,p),Qa(c,f,y.vmin,y.vmax,c,f)}}const x=dm(l,2,c,2,a);if(0===x)return 0;const C=[],v=[];if(-1===x){const t=lt(it,3),e=lt(it,3),s=lt(it,3);hh(l,p,t,e,s);const n=lt(it,3),i=lt(it,3),r=lt(it,3);hh(c,f,n,i,r);const o=[],g=[],d=Yn(t,2,e,2,s,2,n,2,i,2,r,2,!0,H.unit(),H.unit(),o,g,h,u,m);if(d>0)for(let h=0;h<d;h++){const t=new Q;_h(c,f,g[h],t);const e=new Q;_h(l,p,o[h],e);Q.distance(e,t)<=a&&(C.push(o[h]),v.push(g[h]))}}for(let b=0;b<2;b++){let t,e,n;0===b?(t=l,e=c,n=f):(t=c,e=l,n=p);for(let i=0;i<2;i++){const r=0===i?0:t.length-1,o=new Q,h=[0],u=za(e,n,t[r],H.unit(),!1,-1,1,h);s(1===u),_h(e,n,h[0],o),Q.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 s=0;s<C.length;++s)C[s]=Sn.recalculateParentT(P.vmin,P.vmax,C[s]);if(!y.equalsRange(0,1))for(let s=0;s<v.length;++s)v[s]=Sn.recalculateParentT(y.vmin,y.vmax,v[s]);for(let s=0;s<C.length;++s)C[s]=Ph(d,C[s]);for(let s=0;s<v.length;++s)v[s]=Ph(_,v[s]);return cm(t,e,n,C,v,C.length,i,r,o,a,h,u,m)}function oh(t,e,s,n,i,r,o,a,h,u){if(e.isLine()){return Vi(t,s,new pm({start:e.getStartXY(),end:e.getEndXY()}),n,r,i,o,a,h,!u)}if(s.isLine()){return nh(t,e,new pm({start:s.getStartXY(),end:s.getEndXY()}),n,i,r,o,a,h,u)}const m=rs(e,s);if(os(e,s,o=Math.max(o,m)))return 0;const l=lt(Q,3);e.queryControlPoints(l);const c=lt(Q,3);s.queryControlPoints(c);const g=dm(l,2,c,2,o);if(0===g)return 0;const d=[],_=[];if(-1===g){const t=lt(it,3),n=lt(it,3),i=lt(it,3),r=[0,0,0];e.queryWeights(r),hh(l,r,t,n,i);const m=lt(Xe,3);Wi(c,m);const g=Yn(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,H.unit(),H.unit(),d,_,a,h,u);if(g>0){let t=0;for(let n=0;n<g;n++){const i=new Q;s.queryCoord2D(_[n],i);const r=new Q;e.queryCoord2D(d[n],r),Q.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 Q;0===p?(r=Ci(s,t[i],H.unit(),!1),s.queryCoord2D(r,a)):(r=Ra(e,t[i],H.unit(),!1,-1),e.queryCoord2D(r,a)),Q.distance(t[i],a)<=o&&(0===p?(d.push(0===i?0:1),_.push(r)):(_.push(0===i?0:1),d.push(r)))}}return cm(t,e,s,d,_,d.length,n,i,r,o,a,h,u)}function ah(t,e,s,n=!1){const i=lt(Q,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 hh(t,e,s,n,i){const r=it.constructDouble(e[0]),o=it.constructDouble(e[1]),a=it.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 uh(t,e,s){for(let n=0;n<3;++n)s[n].setCoordsPoint2DZ(t[n].mul(e[n]),e[n])}function mh(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=bt(i[0],i[1],a),e=bt(i[1],i[2],a);h=rt(t,e,a);const s=bt(r[0],r[1],a),n=bt(r[1],r[2],a);u=rt(s,n,a);const l=bt(o[0],o[1],a),c=bt(o[1],o[2],a);m=bt(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),vh(t,n),m}function lh(t,e,s){const n=lt(Q,3);t.queryControlPoints(n);const i=[0,0,0];t.queryWeights(i);ch([Ye.constructPoint2D(n[0]),Ye.constructPoint2D(n[1]),Ye.constructPoint2D(n[2])],[new at(i[0]),new at(i[1]),new at(i[2])],e,s)}function ch(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 at,h=new at,u=new at;if(s.value()<=.5){const t=Ut(i[0],i[1],s),e=Ut(i[1],i[2],s);a.setE(Ut(t,e,s));const n=Ut(r[0],r[1],s),m=Ut(r[1],r[2],s);h.setE(Ut(n,m,s));const l=Ut(o[0],o[1],s),c=Ut(o[1],o[2],s);u.setE(Ut(l,c,s))}else{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))}a.divThisE(u),h.divThisE(u);const m=new Q(a.value(),h.value());vh([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 gh(t,e,s,n){const i=s.lte(Rt)?it.lerpLo:it.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 Q(r.divThis(a).value(),o.divThis(a).value());vh(t.map(t=>t.asPoint2D()),h),n.x=it.constructDouble(h.x),n.y=it.constructDouble(h.y)}function dh(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function _h(t,e,s,n,i){if(i){if(s<0){return void _s(new pm({start:t[0],end:t[0].add(wa(t,e,0).getUnitVector())}),s,n)}if(s>1){return void _s(new pm({start:t[2],end:t[2].add(wa(t,e,1).getUnitVector())}),s-1,n)}}mh(t,e,s,n)}function ph(t,e,s,n){n.setEmpty();const i=[];i.push(new H(0,1));const r=.5*Math.max(s.width(),s.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new De;if(Wa(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(H.construct(o.vmin,t)),i.push(H.construct(t,o.vmax))}}}}function fh(t){return t[1]/Math.sqrt(t[0]*t[2])}function Ph(t,e){const s=Math.sqrt(t[2]/t[0]);return e/rt(s,1,e)}function yh(t,e){const s=Math.sqrt(t[0]/t[2]);return e/rt(s,1,e)}function xh(t,e,n,i){s(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;Dt(3,t[0],t[1],e,r),Dt(3,t[1],t[2],e,o),Dt(3,r,o,e,a);const h=t[2].clone();n&&(n[0].assign(t[0]),n[1].assign(r),n[2].assign(a)),i&&(i[0].assign(a),i[1].assign(o),i[2].assign(h))}function Ch(t,e,n,i){const r=[t[0],t[1],t[2]];s(e>=0&&e<=1&&n!==i);const o=rt(r[0],r[1],e),a=rt(r[1],r[2],e),h=rt(o,a,e);n&&(n[0]=r[0],n[1]=o,n[2]=h),i&&(i[0]=h,i[1]=a,i[2]=r[2])}function vh(t,e){const s=H.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=_t(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=_t(e.y,s.vmin,s.vmax)}function bh(t,e){const s=new H;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=_t(e[0].x,s.vmin,s.vmax),e[1].x=_t(e[1].x,s.vmin,s.vmax),e[2].x=_t(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=_t(e[0].y,s.vmin,s.vmax),e[1].y=_t(e[1].y,s.vmin,s.vmax),e[2].y=_t(e[2].y,s.vmin,s.vmax)}const Eh=Jt/180,Sh=180/Jt;function Dh(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=Qt(e,360),e<0&&(e+=360),e)}function wh(t){let e=t;return e=Dh(e),e>180&&(e-=360),e}function Ah(t){return t*Eh}function Th(t){return t*Sh}function Ih(t){const e=kt();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=Qt(s,e),s<0&&(s+=e),s)}function Mh(t){const e=wt();let s=t;return s>-e&&s<=e||(s=Ih(s),s>e&&(s-=kt())),s}function Yh(t,e){return wh(e-t)}var Nh=b;class Xh extends gs{constructor(t){if(void 0===t||vt(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 Q(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new Q(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new Q(0,0),this.m_interior=new Q(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 Q(0,0),this.m_interior=new Q(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 Q(0,0),this.m_interior=new Q(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=Q.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=Q.lerp(t,e,.5);return this.constructCircleCenterAndPoint(n,t,s),this}constructLineEllipticArc(t,e){return bu(this,t,e,1),this}constructLineCircularArc(t,e){return bu(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 Q(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 le;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 le;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 ju(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=Q.calculateCircleCenterFromThreePoints(t,e,s);if(!i.isFinite()||!Number.isFinite(Q.distance(t,i))){const n=Q.distance(t,e),i=Q.distance(t,s);this.constructLineCircularArc(t,n>=i?e:s)}return this.constructCircleCenterAndPoint(i,t,n)}}constructCircularArcThreePoint(t,e,s){const n=new at(t.x),i=new at(e.x),r=new at(s.x),o=new at(t.y),a=new at(e.y),h=new at(s.y),u=new at(.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 bu(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 E=Math.atan2(b,v);v=e.x-x.value(),b=e.y-C.value();const S=Math.atan2(b,v);v=s.x-x.value(),b=s.y-C.value();const D=Math.atan2(b,v);let w=D-2*wt();for(;w<E;)w+=2*wt();let A=S-2*wt();for(;A<w;)A+=2*wt();let T=D+2*wt();for(;T>E;)T-=2*wt();let I,M=S+2*wt();for(;M>T;)M-=2*wt();I=A-E<E-M?A-E:M-E;const Y=new Q(x.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(I)>wt(),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 vu(this,t,e,s,n,i,r,o)}constructEllipticArcEndPointsCenter(t,e,s,n,i,r,o,a){return vu(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=Mh(r),a=Math.cos(o),h=Math.sin(o),u=new Q(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),m=Q.getNAN(),l=Mh(n);m.x=u.x*Math.cos(l),m.y=u.y*Math.sin(l),m.rotateDirect(a,h),m.addThis(s);const c=At(i,kt());let g=c;Math.abs(g)===kt()&&(g=0);const d=Q.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)>wt(),c>0,s)}constructEllipticArcAsNURB(t,s,n,i){(i>=1||i<0)&&e("construct_elliptic_arc_as_NURB: weight"),s.isFinite()||e("construct_elliptic_arc_as_NURB: control_point");return ku([t,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,Hu(this),this.afterCompletedModification(),t!==this&&ss(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 Q.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!Xu(this)}isMajor(){return Fu(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return i.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=me.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=Nh.getComponentCount(e);s<i;s++){const s=this.queryInterval(e,n);t.setIntervalEnvelope(e,n,s)}}}else 2===t.m_EnvelopeType?Ju(this,H.unit(),t):a("3d not impl")}applyTransformation(t){Au(this,t,!1,null,null)}createInstance(){return new Xh}calculateLength2D(){return pu(this,0,1)}queryControlPointsHelper(t){h("")}queryCoord2D(t,e){if(Eu(this))ps(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(Q.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(Q.construct(this.m_XEnd,this.m_YEnd));else{const s=cu(this,t),n=new Q(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){nu(this,t,e)}queryCoord2DMP(t,e){a("")}getCoordX(t){const e=new Q;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new Q;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const n=new fm;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=Q.getNAN();this.queryCoord2D(t,o);const a=Q.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,je(i,o.x,o.y),He(i,a.x,a.y),r)return void Iu(i,fu(this));i.m_startAngle=cu(this,t),i.m_sweepAngle=cu(this,e)-i.m_startAngle,i.m_startAngle=au(i.m_startAngle),qu(i,Math.abs(i.m_sweepAngle)>wt()),n&&i.assignVertexDescription(this.m_description),Hu(i),mu(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=Nh.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=Nh.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){sm(this,t,e)}cutArcIgnoreAttributes(t,e,s){let n=0===t&&1===e;const i=new Q;this.queryCoord2D(t,i);const r=new Q;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,je(s,i.x,i.y),He(s,r.x,r.y),n?Iu(s,fu(this)):(s.m_startAngle=cu(this,t),s.m_sweepAngle=cu(this,e)-s.m_startAngle,s.m_startAngle=au(s.m_startAngle),qu(s,Math.abs(s.m_sweepAngle)>Math.PI),Hu(s),s.afterCompletedModification())}changeEndPoints2D(t,e){yu(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=Nh.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return Ct(r,o,a,i,Nh.getDefaultValue(e))}getClosestCoordinate(t,e){return $u(this,t,H.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return $u(this,t,e,!1)}getYMonotonicParts(t,n=!1){t.length<2&&e("");const i=this.getSemiAxes(),r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),o=r+wt(),a=U(3,Number.NaN);let h=0;if(a[0]=lu(this,r),a[0]>0&&a[0]<1&&h++,a[1]=lu(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,s(t.length>=h);let u=0;for(let e=0;e<h;e++){const s=a[e];this.queryCut(u,s,t[e],n),u=s}return h}getMonotonicParts(t,n){if(t.length<4&&e(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),n&&t[0].get().dropAllAttributes(),1;const i=this.getSemiAxes(),r=U(4,Number.NaN);r[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r[1]=r[0]+wt(),r[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),r[3]=r[2]+wt();const o=U(5,Number.NaN);let a=0;for(let e=0;e<4;e++)o[a]=lu(this,r[e]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;St(o,a),o[a-1]<1&&(o[a]=1,a++),s(t.length>=a);let h=0;for(let e=0;e<a;e++){const s=o[e];this.queryCut(h,s,t[e],n),h=s}return a}intersectionWithAxis2D(t,e,s,n){if(Eu(this)){return new pm({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,n)}let i,r;const o=new at(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 at(a.x).mulThis(this.m_sinr),r=new at(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 at(a.x).mulThis(this.m_cosr),r=new at(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=lt(at,2);let y=gn(m,l,c,H.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 at,e=new at;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=lu(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]=et(x[0],x[0]=x[1])),n&&J(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]=et(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 Re(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new H(0,1),t):a("3d not impl")}clone(t){const e=new Xh;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Eu(this))return 0===e?H.construct(this.getStartX(),this.getEndX()):H.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]=lu(this,t),i[1]=lu(this,n);const r=0===e?H.construct(this.getStartX(),this.getEndX()):H.construct(this.getStartY(),this.getEndY()),o=new Q;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 H(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()<=Tt){let t=Q.lerp(n,i,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*Q.distance(n,i))),e.setCoords(n),e.mergeNe(i),void e.mergeNe(t)}Ju(this,s,e)}tToLength(t){return Eu(this)?t*Q.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Su(this,t)}parametricAngleToT(t){return lu(this,t)}tToParametricAngle(t){return cu(this,t)}lengthToT(t){if(Eu(this)){const e=Q.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 Du(this,t)}calculateWeightedAreaCentroid2D(t){if(Eu(this)){const t=new Q;return t.setCoords(0,0),t}const e=Zu(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 Q;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 Q;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=Q.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 Q;this.queryCoord2D(n,i);return Q.distance(i,t)<=e}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}getTangent(t){if(Eu(this))return this.getEndXY().sub(this.getStartXY());{const e=cu(this,t),s=new Q;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=cu(this,t),s=new Q;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!!Lu(this)&&(Eu(this)?(Ru(this),!1):zu(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 Q(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new Q(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=cu(this,t),s=new Q,n=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),n*Math.cos(e));const i=new Q;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(t,s){const n=U(6,Number.NaN);n[0]=0;let i=1;if(this.isDegenerateToLine())n[1]=1,i=2;else{const t=this.getSemiAxes(),e=U(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]=It());for(let s=0;s<4;s++){const t=lu(this,e[s]);t>0&&t<1&&(n[i]=t,i++)}i>2&&St(n,i),n[i]=1,i++}if(s){t<i&&e("");for(let t=0;t<i;t++)s[t]=n[t]}return i}calculateLowerLength2D(){const t=Q.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=Q.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=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(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]=et(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,Mu(t)}calculateArea2DHelper(){return Zu(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=U(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]=lu(this,t),n[1]=lu(this,e),n[2]=lu(this,i),n[3]=lu(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]=lu(this,i),n[5]=lu(this,r),n[6]=lu(this,o),n[7]=lu(this,a)}const i=Q.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){xu(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 h("should not1; be called"),0}ensureXYMonotone(){if(Eu(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return bu(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=lt(Q,3);let e=Bu(this,t);if(Ha(t)){let s=!1;if(0===this.projectionBehavior()){const n=new me;n.setCoords({pt:t[0]}),n.mergeNe(t[2]);const i=new Q;i.setSub(t[2],t[0]),i.leftPerpendicularThis(),i.normalize(),i.scale(Q.distance(t[2],t[0]));const r=Q.lerp(t[2],t[0],.5),o=r.sub(i),a=r.add(i);n.clipLine(o,a);const h=Q.getClosestCoordinate(o,a,t[1],!1);t[1]=Q.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=yt()-Math.abs(.5*Math.atan2(l,c)),s=!0}return ku(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){yu(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,Iu(e,fu(this))}reverseImpl(){Nu(this,!Xu(this)),mu(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&Hu(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(Ah(wh(Th(this.m_rotation-s.m_rotation)))),i=Math.abs(wt()-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=et(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=et(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=et(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=et(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=et(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=et(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=et(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=et(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=et(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=et(e.m_bits,e.m_bits=this.m_bits),Yu(this,e)}afterCompletedModification(){Ru(this),Mu(this)}intersect(t,e,s,n,i){return um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){if(e.length<2&&n(""),Eu(this)){return new pm({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s)}{const e=Q.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const i=this.getClosestCoordinate(t,!1),r=Q.getNAN();return this.queryCoord2D(i,r),Q.distance(r,t)<=s?gt(i,0,1)&&(this.queryCoord2D(0===i?1:0,r),Q.distance(r,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==rm(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,Mu(this)}clearEndPointModified(){Ru(this)}}function qh(t,e,s){t.isEmpty()&&o(""),f(t);const n=t.getImpl(),i=[];return Lh(n.getPointCount(),i),Rh(Vh(n),i,n.getPointCount(),e)}function Fh(t,e,s,n){const i=[];return Lh(e,i),Rh(t,i,e,s)}function Vh(t){return{at:e=>t.getXY(e)}}function Lh(t,e){e.length=t;for(let s=0;s<e.length;++s)e[s]=s;t>3&&pe(t,e)}function Rh(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=Q.inCircleRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]),s):2===r?l=Q.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]=et(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===Q.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=et(n[0],n[0]=n[2]),o[2]=et(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]=et(o[t],o[t]=o[e]),n[e]=et(n[t],n[t]=n[e]),s=!0);for(let t=0;t<r;t++)e[o[t]]=et(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===r&&1===Q.orientationRobust(t.at(n[0]),t.at(n[1]),t.at(n[2]))&&(n[2]=et(n[0],n[0]=n[2]),o[2]=et(o[0],o[0]=o[2]))}u=r}return r}function zh(t,e,s,n,i,r){return new jh(0,0,0,null,!1,K()).densifyEx(t,e,s,n,!1,r)}function Bh(t,s,n,r){return Number.isFinite(s)||e("replace_all_curves_with_beziers: maxDeviation"),Oh(i.enumBezier,t,s,n)}function kh(t,e,n,r,o,h,u,m){h&&(h.length=0),u&&(u.length=0);const l=t.getGeometryType();if(l===i.enumLine)return h&&(h.push(t.getStartXY()),h.push(Q.getNAN()),h.push(Q.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(l===i.enumBezier){if(!r)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=U(9,Number.NaN);let s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Zh(t,n,e),2===s&&o&&(e[1]=.5,e.push(1),s=3),u&&u.splice(0,0,...e.slice(0,s)),h){const n=new fm;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();lo(o),1===i&&h.push(o.getStartXY()),h.push(o.getControlPoint1()),h.push(o.getControlPoint2()),h.push(o.getEndXY())}}return s-1}if(l===i.enumEllipticArc){const i=t;if(i.isDegenerateToLine()||i.isDegenerate(0))return h&&(h.push(t.getStartXY()),h.push(Q.getNAN()),h.push(Q.getNAN()),h.push(t.getEndXY())),u&&(u.push(0),u.push(1)),1;if(r&&(o||!i.isMonotoneQuickAndDirty())){const a=U(6,Number.NaN);let m=i.getMonotonicPartParams(a.length,a);a.length=m,m=Zh(t,n,a),2===m&&o&&(a[1]=.5,a.push(1),m=3);let l=0;if(m>2){const t=new fm,o=u||[];let c=0;for(let g=1;g<m;g++){const d=a[c],_=a[g];if(i.queryCut(d,_,t,!0),t.get().isDegenerate(0))continue;const p=o.length,f=Qh(1===g,t.get(),e,n,r,h,u);s(f>0),l+=f;const P=g===m-1,y=a[c],x=t.get().getSweepAngle()/i.getSweepAngle();for(let t=p,e=o.length;t<e;t++)if(o[t]=!P||t+1<e?y+o[t]*x:1,h){const e=3*t,s=i.getCoord2D(o[t]);if(h[e].setCoordsPoint2D(s),e>0){co(h.slice(e-3))}}c=g}return l}}return Qh(!0,i,e,n,r,h,u)}if(l===i.enumRationalBezier2){const s=t;if(r&&(o||!s.isMonotoneQuickAndDirty())){const i=U(6,Number.NaN);let r=s.getMonotonicPartParams(i.length,i);i.length=r,r=Zh(t,n,i),2===r&&o&&(i[1]=.5,i.push(1),r=3);let a=0;if(r>2){const t=new fm,o=u||[];for(let m=1;m<r;m++){const l=i[m-1],c=i[m];s.queryCut(l,c,t,!0);const g=o.length;a+=Jh(1===m,t.get(),e,n,!1,h,u);const d=m===r-1,_=i[m-1];for(let t=g,e=o.length;t<e;t++)if(o[t]=!d||t+1<e?_+o[t]:1,h){const e=3*t,n=s.getCoord2D(o[t]);if(h[e].setCoordsPoint2D(n),e>0){Ai(h.slice(e-3))}}}return a}}return Jh(!0,s,e,n,r,h,u)}if(l===i.enumBezier2){const s=t,i=lt(Q,3);s.queryControlPoints(i);const a=new ia;a.constructFromQuadratic(i);const m=kh(a,e,n,r,o,h,u);if(null!=h&&null!=u){const t=3;for(let e=1,n=0;e<m;++e,n+=t){const i=new Q;s.queryCoord2D(u[e],i);const o=h[n+t];if(!i.equals(o)&&(h[n+t].setCoordsPoint2D(i),r)){co(h.slice(n,n+4))}}}return m}a("")}function Gh(t,e,s,n,r,o,h,u){o&&(o.length=0),h&&(h.length=0);const m=t.getGeometryType();if(m===i.enumLine)return o&&(o.push(t.getStartXY()),o.push(Q.getNAN()),o.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(m===i.enumBezier2){const e=U(9,Number.NaN);let n=t.getMonotonicPartParams(e.length,e);if(e.length=n,n=Zh(t,s,e),h&&h.splice(0,0,...e.slice(0,n)),o){const s=new fm;for(let i=1;i<n;i++){const n=e[i-1],r=e[i];t.queryCut(n,r,s,!0);const a=s.get();wi(a),1===i&&o.push(a.getStartXY()),o.push(a.getControlPoint1()),o.push(a.getEndXY())}}return n-1}if(m===i.enumEllipticArc){const i=t;if(i.isDegenerateToLine()||i.isDegenerate(0))return o&&(o.push(t.getStartXY()),o.push(Q.getNAN()),o.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(!i.isMonotoneQuickAndDirty()){const n=U(6,Number.NaN);let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=Zh(t,s,n);let a=0;if(r>2){const t=new fm,u=h||[];for(let m=1;m<r;m++){const l=n[m-1],c=n[m];i.queryCut(l,c,t,!0);const g=u.length;a+=$h(1===m,t.get(),e,s,!1,o,h);const d=m===r-1,_=n[m-1],p=t.get().getSweepAngle()/i.getSweepAngle();for(let t=g,e=u.length;t<e;t++)if(u[t]=!d||t+1<e?_+u[t]*p:1,o){const e=2*t,s=i.getCoord2D(u[t]);if(o[e].setCoordsPoint2D(s),e>0){Ai(o.slice(e-2))}}}return a}}return Qh(!0,i,e,s,n,o,h)}if(m===i.enumBezier){const i=t;if(!i.isMonotoneQuickAndDirty()){const n=U(6,Number.NaN);let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=Zh(t,s,n);let a=0;if(r>2){const t=new fm,u=h||[];for(let m=1;m<r;m++){const l=n[m-1],c=n[m];i.queryCut(l,c,t,!0);const g=u.length;a+=tu(1===m,t.get(),e,s,!1,o,h);const d=m===r-1,_=n[m-1];for(let t=g,e=u.length;t<e;t++)if(u[t]=!d||t+1<e?_+u[t]:1,o){const e=2*t,s=i.getCoord2D(u[t]);if(o[e].setCoordsPoint2D(s),e>0){Ai(o.slice(e-2))}}}return a}}return tu(!0,i,e,s,n,o,h)}if(m===i.enumRationalBezier2){const i=t;if(!i.isMonotoneQuickAndDirty()){const n=U(6,Number.NaN);let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=Zh(t,s,n);let a=0;if(r>2){const t=new fm,u=h||[];for(let m=1;m<r;m++){const l=n[m-1],c=n[m];i.queryCut(l,c,t,!0);const g=u.length;a+=Kh(1===m,t.get(),e,s,!1,o,h);const d=m===r-1,_=n[m-1];for(let t=g,e=u.length;t<e;t++)if(u[t]=!d||t+1<e?_+u[t]:1,o){const e=2*t,s=i.getCoord2D(u[t]);if(o[e].setCoordsPoint2D(s),e>0){Ai(o.slice(e-2))}}}return a}}return Kh(!0,i,e,s,n,o,h)}a("")}function Wh(t,e,n,r,o,a,h,u,m){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),u&&(u.length=0),l===i.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(Q.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=U(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Zh(t,n,c);else{if(g=2,c[0]=0,c[1]=1,l===Xh.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 s(l===Sn.type);c.length=g}if(2===g&&r&&(c[1]=.5,c.push(1),g=3),a){const e=new fm;let s=1;for(;s<g;){const n=c[s-1],r=c[s];t.queryCut(n,r,e,!0);const u=lt(Q,3),m=[1,1,1];if(l===i.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(r-n)/3;c.splice(s,0,n+t),c.splice(s+1,0,n+2*t),g+=2;continue}m[1]=Bu(t,u)}else{const t=e.get();t.queryControlPoints(u),t.queryWeights(m)}o&&Ha(u),1===s&&(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]),s++}}return u&&(u.length=g,J(u,c,0,0,g)),g-1}Xh.type=i.enumEllipticArc;class jh{static constructDefault(t){return new jh(0,0,0,t,!1,K())}constructor(t,e,s,n,i,r){this.m_segmentBuffer=null,this.m_dummyPoint=new q,this.m_progressCounter=0,this.m_progressTracker=n,this.m_bSetDensifyFlag=i,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>yt()?yt():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>yt()?yt():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 e=t.getGeometryType();return p(e)?t:c(e)?this.densifyMultiPath(t):m(e)?this.densifySegmentImpl(t):e===i.enumEnvelope?this.densifyEnvelope(t):void h("")}densifySegmentEx(t,e,s,n,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==i.enumLine)&&(!n||s))return void(e?o===i.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===i.enumBezier)return void this.densifyCubicBezier(t,e,s,n,r);if(o===i.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,n,r);if(o===i.enumBezier2)return void this.densifyBezier2(t,e,s,n,r);if(o===i.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,n,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,e,s,n,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();if(e.getGeometryType()===i.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const n=s.nextSegment(),i=s.isClosingSegment();this.densifySegmentEx(n,e,t,i,null),i&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new Os({vd:t.getDescription()}),s=[0];return this.densifySegmentEx(t,e,!0,!1,s),e}densifyEnvelope(t){const e=new ur({vd:t.getDescription()});e.addEnvelope(t,!1);const s=me.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 e=t.createInstance();if(e.getGeometryType()===i.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=e.getImpl(),n=t.getImpl(),r=n.getAttributeStreamRef(0),o=new pm;for(let i=0,a=n.getPathCount();i<a;i++){const t=n.isClosedPath(i);if(0===n.getPathSize(i))continue;const a=n.getPathStart(i),h=r.readPoint2D(2*a),u=h.clone();s.startPath(h);for(let m=a+1,l=n.getPathEnd(i);m<l;m++){const t=r.readPoint2D(2*m),n=Q.distance(u,t);if(n>this.m_maxLength){let e=Math.ceil(n/this.m_maxLength);e>K()&&(e=K());const i=1/e;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=e-2,a=-1);for(let t=0,n=e-1;t<n;t++,r+=a){this.progress_(),h=i*(r+1);const t=new Q;o.queryCoord2D(h,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),u.assign(t)}if(t){const t=Q.distance(u,h);if(t>this.m_maxLength){const e=h;let n=Math.ceil(t/this.m_maxLength);n>K()&&(n=K());const i=1/n;let r,a;u.compare(e)<0?(o.setStartXY(u),o.setEndXY(e),r=0,a=1):(o.setStartXY(e),o.setEndXY(u),r=n-2,a=-1);const m=new Q(0,0);let l;for(let t=0,h=n-1;t<h;t++,r+=a)this.progress_(),l=i*(r+1),o.queryCoord2D(l,m),s.lineTo(m),this.m_bSetDensifyFlag&&s.setAttributeNoCurves(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(t,e,n,r,o,h){s(t.getGeometryType()!==i.enumBezier);let u=t.getStartXY().compare(t.getEndXY());if(0===u&&e<1){t.getGeometryType()===i.enumEllipticArc?u=t.getSweepAngle()<0?1:-1:a("densify segment by length")}let m=0;if(r&&(n?(t.queryStart(this.m_dummyPoint),n.startPathPoint(this.m_dummyPoint)):h.push(0),++m),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||(this.m_segmentBuffer=new fm);let s=Math.ceil(1/e);s>K()&&(s=K()),e=1/s,this.m_segmentBuffer.create(t.getGeometryType());let i,r,o,a=t;u<0?(i=0,r=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),i=s-2,r=-1,a=this.m_segmentBuffer.get());const l=s-1;for(let t=0;t<l;t++,i+=r)o=e*(i+1),n?(a.queryCoord(o,this.m_dummyPoint),n.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==o&&0!==o&&n.setAttribute(10,n.getPointCount()-1,0,1)):h.push(u>0?1-o:o),this.progress_();o=1,m+=l}(!o||o&&r&&m<2)&&(n?(t.queryEnd(this.m_dummyPoint),n.lineToPoint(this.m_dummyPoint)):h.push(1))}densifyCubicBezier(t,e,s,n,i){const r=new ia;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());if(0===h&&a>0){const e=lt(Q,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 Q(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 Q(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 Q(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 Q(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 Sn;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 Sn,c=[],g=[];for(c.push(new H(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 H(e,t.vmax))):(c.at(-1).vmin=e,c.push(new H(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 wn;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 wn,c=[],g=[];for(c.push(new H(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 H(e,t.vmax))):(c.at(-1).vmin=e,c.push(new H(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 Xh;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 Xh,c=[],g=[];for(c.push(new H(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 H(e,t.vmax))):(c.at(-1).vmin=e,c.push(new H(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,e){const s=t.calculateUpperLength2D();if(!t.isCurve())return s?e/s:1;if(t.getGeometryType()===i.enumEllipticArc){const n=t;if(n.isCircular()||n.isDegenerate(0)||n.isDegenerateToLine()){let t=e/s;return t<this.m_minStep&&(t=this.m_minStep),t}return e/s*n.getSemiAxes().y/n.getSemiAxes().x}t.getGeometryType()===i.enumBezier&&a(""),a("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.enumEllipticArc){const s=t;if(s.isDegenerate(0)||s.isDegenerateToLine())return 1;{const n=s.getSemiMajorAxis(),i=1-e/n;let r=Math.PI/2;if(i>0){const t=4*Math.sqrt(e/n*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*n;return this.calculateLengthSubdivisionStep(t,o)}}a("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.enumEllipticArc){const s=t;return s.isDegenerate(0)||s.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*s.getSemiMinorAxis())}a("")}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=lt(Q,3);e.queryControlPoints(r);const o=[0,0,0];return e.queryWeights(o),!i&&this.m_maxDeviation>0&&(i=!jh.checkRationalBezier2MaxDeviation(r,o,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!jh.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=lt(Q,3);return e.queryControlPoints(r),!i&&this.m_maxDeviation>0&&(i=!jh.checkBezier2MaxDeviation(r,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!jh.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=!jh.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!i&&this.m_maxAngle>0&&(i=!jh.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),i}bezierNeedsSplit(t){let e=!1;if(this.m_maxLength>0){if(Q.distance(t[0],t[1])+Q.distance(t[1],t[2])+Q.distance(t[2],t[3])>this.m_maxLength)return e=!0,!0}return!e&&this.m_maxDeviation>0&&(e=!jh.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!jh.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 Q;Po(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===tm(t,s,n)){const s=t.getCoord2D(n[0]),i=Q.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),r=new Q;xt(t.getStartXY(),t.getEndXY(),i,r);return Q.distance(s,r)<=e}}const s=t.getCoord2D(.5),n=new Q;xt(t.getEndXY(),t.getStartXY(),.5,n);return Q.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,e){return t.getGeometryType()===e&&(e!==i.enumEllipticArc||t.isCircular())}}function Zh(t,e,s){const n=s.length;if(e<=0||n<=2)return n;let i=0;const r=U(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 Hh(t,e,s,n,i){const r=[],o=[],a=kh(e,s,0,n,!1,r,o),h=new ia;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new q,g=new pm;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 Uh(t,e,s,n,i){const r=[],o=[],a=Gh(e,s,0,n,!1,r,o),h=new wn;let u=i;const m=e.getDescription();h.assignVertexDescription(m);const l=m.getAttributeCount()>1,c=new q,g=new pm;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 Oh(t,e,n,r,o){s(t===i.enumBezier||t===i.enumEllipticArc||t===i.enumBezier2);const a=e.createInstance();a.getGeometryType()===i.enumPolygon&&a.setFillRule(e.getFillRule());const u=e.querySegmentIterator();for(let m=0,l=e.getPathCount();m<l;++m){if(!e.hasNonLinearSegmentsPath(m)){a.addPath(e,m,!0);continue}const o=e.getPathStart(m);let l=!0,c=0;for(u.resetToPath(m),s(u.nextPath());u.hasNextSegment();){const s=u.nextCurve();if(!s)break;{const g=u.getStartPointIndex()-o,d=g-c;d>0&&(a.addSegmentsFromPath(e,m,c,d,l),l=!1),c=g+1,t===i.enumBezier?Hh(a,s,n,r,l):t===i.enumBezier2?Uh(a,s,n,r,l):h(""),l=!1}}const g=e.getSegmentCountPath(m);g-c!==0&&a.addSegmentsFromPath(e,m,c,g-c,l)}return a}function Qh(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(Q.getNAN()),e.push(Q.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 le;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=me.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=Ih(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 E=4/3*Math.tan(Math.abs(x)/4);p>0&&(E=-E),o&&t&&o.push(0);const S=x/Math.abs(p);let D=(v-C)/p;const w=m.clone(),A=new Q;h.queryCoord2D(0,A);const T=A.clone(),I=1-.01*S;let M=0,Y=0;for(;D<1;){let s;if(D+=S,Y>0&&D<I)s=E;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 Q;g.queryTransform(A,a);const u=e.getClosestCoordinate(a,!1);if(e.queryCoord2D(u,a),1!==D&&(Q.distance(w,a)<=2*n||Q.distance(a,l)<=2*n))continue;w.setCoordsPoint2D(a);const c=lt(Q,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&&co(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 me;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=lt(Q,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=U(9,Number.NaN);let p=e.getMonotonicPartParams(_.length,_);_.length=p,p=Zh(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=lt(Q,3);Qa(c,g,t,e,s,[0,0,0]);const n=lt(Q,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 Jh(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new me;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=lt(Q,3);e.queryControlPoints(c);const g=[0,0,0];e.queryWeights(g);const d=[],_=U(9,Number.NaN);let p=0;i?(p=e.getMonotonicPartParams(_.length,_),_.length=p,p=Zh(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=lt(Q,3),n=[0,0,0];Qa(c,g,t,e,s,n);const i=lt(Q,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 $h(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(Q.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 le;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 _=me.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 E=Math.tan(Math.abs(y)/2);x>0&&(E=-E),o&&t&&o.push(0);const S=new Q;h.queryCoord2D(0,S);for(let D=0;D<v;D++){const e=S.clone(),s=(D+1)*b;if(o&&o.push(s),!r)continue;h.queryCoord2D(s,S);const n=lt(Q,3);n[0].assign(e),n[2].assign(S),n[1].rightPerpendicularOther(n[0]),n[1].mulThis(E),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 tu(t,e,s,n,i,r,o,a){e.clone().dropAllAttributes();const h=new me;e.queryLooseEnvelope(h);const u=.05*h.calculateToleranceFromEnvelope(),m=Math.max(s,u);o&&t&&o.push(0);let l=0;const c=lt(Q,4);e.queryControlPoints(c);const g=[],d=U(9,Number.NaN);let _=e.getMonotonicPartParams(d.length,d);d.length=_,_=Zh(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=lt(Q,4);fo(c,t,e,s);const n=lt(Q,3),i=Qi(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 eu(){return{e2:0,completeE:0}}class su{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?Q.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function nu(t,e,s){if(Eu(t)){return void Cs(new pm({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 at;gu(t,e,n);const i=new at,r=new at;at.st_cosAndSin(n,i,r);const o=Ye.constructCoordsE(new at(t.m_semiMajorAxis).mulThisE(i),new at(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(r)),a=new at(t.m_rotation);at.st_cosAndSin(a,i,r),o.rotateDirect(i,r),o.addThisE(Ye.constructPoint2D(t.m_center)),s.setE(o)}}function iu(t,e){return t.convertToCanonic(e)}function ru(t,e){const s=new H(t.getStartAngle(),t.getEndAngle());s.normalize();const n=kt(),i=Qt(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 ou(t,e,s,n){let i=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;i>wt();)i-=2*wt();for(;i<=-wt();)i+=2*wt();if(!Number.isNaN(e)){for(;e>wt();)e-=2*wt();for(;e<=-wt();)e+=2*wt();!s&&e>i&&(e-=2*wt()),s&&e<i&&(e+=2*wt()),r=e-i,Math.abs(r)<o&&!n&&(r=s?2*wt():-2*wt()),Math.abs(r)>2*wt()-o&&n&&(r=0)}Math.abs(r)>2*wt()-o&&(r=r>=0?2*wt():-2*wt(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),n=Math.abs(r)<=wt(),r&&(s=r>0),t.m_startAngle=au(i),t.m_sweepAngle=r,qu(t,!n),Nu(t,s)}function au(t){let e=t,s=!1;return e<=-wt()?(e+=kt(),s=!0):e>wt()&&(e-=kt(),s=!0),e<=-wt()?(e=Qt(e,kt()),e<=-wt()&&(e+=kt()),s=!0):e>wt()&&(e=Qt(e,kt()),e>wt()&&(e-=kt()),s=!0),s&&(e>wt()||e<=-wt())&&(e=wt()),e}function hu(t,e,s){const n=s,i=n.getSemiAxes();let r=new Q(i.x*Math.cos(t[0]),i.y*Math.sin(t[0]));return r=n.convertFromCanonic(r),Q.sqrDistance(r,n.getStartXY())}function uu(t,e,s){const n=s,i=n.getSemiAxes(),r=t[0]+n.getStartAngle();let o=new Q(i.x*Math.cos(r),i.y*Math.sin(r));return o=n.convertFromCanonic(o),Q.sqrDistance(o,n.getEndXY())}function mu(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=Fu(t),r=Xu(t),o=t.projectionBehavior();if(n){const s=t.convertToCanonic(e),n=new Q(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=n.x,s.y/=n.y,t.m_startAngle=au(Math.atan2(s.y,s.x)),t.m_sweepAngle=i?r?kt():-kt():0}else{const n=t.convertToCanonic(e),a=new Q(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=Q.calculateAngle(n,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=kt()):t.m_sweepAngle>0&&(t.m_sweepAngle-=kt()),t.m_startAngle=au(t.m_startAngle);let u=hu([t.m_startAngle],1,t);if(u=Math.sqrt(u),u>.25*is(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,n=[0];rn(hu,t,1,[t.m_startAngle],[e],[s],1e-14,n),t.m_startAngle=au(n[0])}if(u=uu([t.m_sweepAngle],1,t),u=Math.sqrt(u),u>.25*is(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,n=[0];rn(uu,t,1,[t.m_sweepAngle],[e],[s],1e-14,n),t.m_sweepAngle=n[0]}const m=Math.abs(t.m_sweepAngle)>wt();if(qu(t,m),i!==m&&!i&&Math.abs(t.m_sweepAngle)>1.5*wt())return void bu(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void bu(t,e,s,o)}}function lu(t,e){return(ru(t,e)-t.getStartAngle())/t.getSweepAngle()}function cu(t,e){return t.m_startAngle+e*t.m_sweepAngle}function gu(t,e,s){s.assign(new at(t.m_startAngle).addE(e.mulE(new at(t.m_sweepAngle))))}function du(t,e){const s=new at(t.m_cosr).sqrThis(),n=new at(t.m_sinr).sqrThis(),i=new at(t.m_minorMajorRatio),r=new at(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 at(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function _u(t,e){const s=new Ne;s.a11.setE(t[0]),s.a12=at.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const n=[Q.getNAN(),Q.getNAN()],i=[new at,new at];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 pu(t,e,s){if(Eu(t))return(s-e)*Q.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const n=Su(t,e);return Su(t,s)-n}function fu(t){return t.m_cachedValues}function Pu(t){if(t.m_cachedValues)return t.m_cachedValues;const e=eu();return e.e2=Cu(t),e.completeE=Kt(e.e2),t.m_cachedValues=e,e}function yu(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,Hu(t),void t.afterCompletedModification();if(n&&Math.abs(t.getSweepAngle())<=1.01*yt()){const n=lt(Q,3),i=Bu(t,n);if(ja(n)){n[0].assign(e),n[2].assign(s),Ha(n);if(0===t.projectionBehavior()){let e=0,s=2;Q.sqrDistance(n[1],n[0])<Q.sqrDistance(n[1],n[2])&&(s=et(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 Q;xt(n[e],n[s],.5,m);const l=.5*r/u*_t(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 ku(n,i*i,null,!1,t);return}}0===t.projectionBehavior()?nm(t,e,s):im(t,e,s)}}function xu(t,e,s){const n=0===t.projectionBehavior();if(s<=2)return void bu(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 Q;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=lt(Xh,4),c=U(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]+=Q.sqrDistance(l[d].getCoord2D(s),e[n]),t++}c[d]/=t,c[d]<c[g]&&(g=d)}t.assignCopy(l[g])}function Cu(t){return 1-zt(t.m_minorMajorRatio)}function vu(t,e,s,n,i,r,o,a,h){return t.m_bits=0,t.m_rotation=r,We(t,e),Ze(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),qu(t,o),Nu(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,zu(t,void 0===h)}function bu(t,e,s,n){t.m_bits=0,t.m_rotation=0,We(t,e),Ze(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,qu(t,!1),Nu(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 Su(t,e){if(0===e)return 0;const s=Pu(t),n=cu(t,e),i=yt(),r=wu(t),o=Wt(n+i,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function Du(t,e){if(Eu(t)){const s=Q.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=Pu(t),i=yt(),r=wu(t);s<0&&(e=-e);const o=e/t.m_semiMajorAxis+r;let a=jt(o,n.e2,n.completeE);a-=i,a-=t.getStartAngle();return a/s}function wu(t){const e=Pu(t);return Wt(t.getStartAngle()+yt(),e.e2,e.completeE)}function Au(t,e,n,i,r){if(2===e.m_TransformationType)return void s(0);if(s(!Lu(t)),e.isIdentity()&&(!i||i.equals(t.getStartXY())&&r.equals(t.getEndXY())))return;Mu(t);let o=Q.getNAN(),a=Q.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),n||e.isUniformNoRotation()){let s=Xu(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 Tu(t,o,a,h,s,!1)}const n=new Q(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);du(t,s);const n=new Ne;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 Ne;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=lt(at,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=Q.getNAN(),r=_u(n,i);let m=Xu(t);return e.isReflective()&&(m=!m),void t.constructEllipticArcEndPointsCenter(o,a,i.x,i.y/i.x,r,t.isMajor(),m,h)}}}}const s=[Q.getNAN(),Q.getNAN(),Q.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]=et(s[0],s[0]=s[2]));const i=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(n=!n);const r=new Q(0,0),u=t.createInstance();ku(s,i,r,!1,u),t.constructEllipticArcEndPointsCenter(o,a,u.getSemiMajorAxis(),u.getMinorMajorRatio(),u.getAxisXRotation(),t.isMajor(),!n,h)}}function Tu(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);ou(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 Iu(t,e){t.m_cachedValues=e}function Mu(t){t.m_cachedValues=null}function Yu(t,e){e.m_cachedValues=et(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function Nu(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function Xu(t){return!!(1&t.m_bits)}function qu(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function Fu(t){return!!(2&t.m_bits)}function Vu(t){if(t.m_center.isNAN())return!1;const e=8,s=new Ye;s.setWithEps(t.getStartXY(),e),s.subThisE((new Ye).setWithEps(t.m_center,e));const n=new at;n.setWithEps(t.m_rotation,e);const i=new at,r=new at;at.st_cosAndSin(n,i,r),s.rotateReverse(i,r);const o=new Ye;o.setWithEps(t.getEndXY()),o.subThisE(Ye.constructPoint2D(t.m_center)),o.rotateReverse(i,r);const a=new at;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),u=new at;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(ht),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(ht);return!m.isZero()||!l.isZero()}function Lu(t){return!!(8&t.m_bits)}function Ru(t){t.m_bits&=-9}function zu(t,e){Ru(t);const n=t.getStartXY(),i=t.getEndXY();let r=!1;const o=Fu(t),a=Xu(t),h=t.projectionBehavior(),u=n.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 bu(t,n,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 Q(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(s(l.y>0&&l.x>=l.y),u){const e=t.convertToCanonic(n);s(!l.isZero()),e.x/=l.x,e.y/=l.y;const i=Math.sqrt(zt(e.x)+zt(e.y));if(r=1!==i,t.m_semiMajorAxis*=i,l.mulThis(i),t.m_startAngle=au(Math.atan2(e.y,e.x)),!o)return t.m_interior.assign(n),t.m_sweepAngle=0,t.afterCompletedModification(),r;t.m_sweepAngle=a?kt():-kt()}else{let e=t.m_center.isNAN()||Vu(t);if(!e){const s=t.convertToCanonic(n);s.x/=l.x,s.y/=l.y;const r=new Q(1,0);t.m_startAngle=Q.calculateAngle(r,s);const o=t.convertToCanonic(i);o.x/=l.x,o.y/=l.y,t.m_sweepAngle=Q.calculateAngle(s,o),e=!Wu(t)}if(e){r=!0;const e=n.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let s=zt(e.x/l.x)+zt(e.y/l.y);s>1&&(s=Math.sqrt(s),t.m_semiMajorAxis*=s,l.mulThis(s));const h=new Q(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 Q(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(n.add(i).mulThis(.5)),t.m_center.assign(e)}}if(mu(t),!Wu(t))return bu(t,n,i,h),!0}return Hu(t),t.afterCompletedModification(),r}function Bu(t,e){s(Math.abs(t.getSweepAngle())<15*Math.PI/16);const n=t.getSemiMajorAxis(),i=t.getSemiMinorAxis();let r;if(0===n)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]=Q.lerp(e[0],e[2],.5),r=1,r;const o=t.getSweepAngle(),a=t.getStartAngle(),h=a+o,u=new Q(-n*Math.sin(a),i*Math.cos(a)),m=new Q(-n*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 ku(t,e,n,i,r){if(i){const s=.5,n=Math.sqrt(e),i=zt(1-s)+2*n*s*(1-s)+zt(s),o=t[0].mul(zt(1-s)).add(t[1].mul(2*n*s*(1-s))).add(t[2].mul(zt(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;s(m<=1),s(m>0);const l=.5/(1-m),c=o.sqrLength(),g=u,d=a.sqrLength(),_=zt(h),p=o.sub(a).sqrLength();if(0===_)return bu(r,t[0],t[2],1),!1;if(u<=-Math.sqrt(c)*Math.sqrt(d))return bu(r,t[0],t[2],1),!1;const f=[0,0],P=new H;P.setInfinite();const y=sn(2*_,-(p/m+4*g),2*(1-m)/m,P,!1,f);if(0===y)return bu(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],E=v-c*f[0];Math.abs(b)>Math.abs(E)?E=g*f[0]-v+1:b=g*f[0]-v+1;const S=o.mul(b).add(a.mul(E)),D=S.norm(1)<1e-15*x?0:Math.atan2(S.y,S.x)+Math.PI,w=o.add(a),A=n?n.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 Xh;return r.constructEllipticArcEndPointsCenter(t[0],t[2],x,C/x,D,Y,!M,A)}function Gu(t,e,s,n,i){return ku(t,e,s,n,i)}function Wu(t){const e=is(t);let s=!1;{const n=new Q(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=Q.distance(t.getStartXY(),n)>e}let n=!1;if(!s){const s=new Q(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=Q.distance(t.getEndXY(),s)>e}return!s&&!n}function ju(t,s,n,i){0===n&&e("construct_enclosing_circle");const r=[0,0,0],o=Fh(s,n,r);if(1===o)t.constructCircleRadius(0,s[r[0]],i);else if(2===o){const e=Q.lerp(s[r[0]],s[r[1]],.5),n=Q.distance(s[r[0]],e),o=Q.distance(s[r[1]],e);t.constructCircleRadius(Math.max(n,o),e,i)}else if(3===o){const e=Q.calculateCircleCenterFromThreePoints(s[r[0]],s[r[1]],s[r[2]]),n=Q.distance(s[r[0]],e),o=Q.distance(s[r[1]],e),a=Q.distance(s[r[2]],e);t.constructCircleRadius(Math.max(n,o,a),e,i)}else h("unexpected")}function Zu(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 Hu(t){t.queryCoord2D(.5,t.m_interior)}function Uu(t,e,s,n,i){if(i){if(0!==am(e,s))return 2}else if(Le(e,s))return 1;return 0!==Qu(t,e,s,null,null,null,n,void 0!==i&&i,!0,!1)?4:0}function Ou(t,e,s,n,i){if(i){if(0!==am(e,s))return 2}else if(Le(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,n,i,r,o,a,h,u,m){if(Eu(e)){return Ds(new pm({start:e.getStartXY(),end:e.getEndXY()}),n,i,r,o,a,h,m)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==i&&(i.length=0);const l=rs(e,n);if(os(e,n,a=Math.max(l,a)))return 0;const c=n.getStartXY();c.subThis(e.m_center);const g=n.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=U(16,Number.NaN),v=U(16,Number.NaN);let b=0;const E=[x,x+Math.PI];for(let s=0;s<2;++s){const t=lu(e,E[s]);if(t>=0&&t<=1){C[b]=t;const s=e.getCoord2D(C[b]);v[b]=n.getClosestCoordinate(s,!1),Q.distance(s,n.getCoord2D(v[b]))<=a&&b++}}const S=c.x*p,D=c.y*P,w=d.x*p,A=d.y*P;let T=sn(w*w+A*A,2*(S*w+D*A),S*S+D*D-1,H.unit(),!1,v);s(T>=0);for(let s=0;s<T;s++){const t=d.mul(v[s]).add(c);t.x*=p,t.y*=P;const i=lu(e,Math.atan2(t.y,t.x));if(i>=0&&i<=1){C[b]=i;const t=e.getCoord2D(i);v[b]=n.getClosestCoordinate(t,!1),Q.distance(t,n.getCoord2D(v[b]))<=a&&b++}}s(b<C.length+4);const I=U(16,Number.NaN);T=e.intersectPoint(n.getStartXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=I[s],v[b]=0;T=e.intersectPoint(n.getEndXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=I[s],v[b]=1;T=n.intersectPoint(e.getStartXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=0,v[b]=I[s];T=n.intersectPoint(e.getEndXY(),I,a);for(let s=0;s<T;s++,b++)C[b]=1,v[b]=I[s];return 0===b?0:cm(t,e,n,C,v,b,i,r,o,a,h,u,m)}function Ku(t,e,n,i,r,o,a,h,u,m){if(Eu(e)){const s=new pm({start:e.getStartXY(),end:e.getEndXY()});return Qu(t,n,s,i,o,r,a,h,u,!m)}if(Eu(n)){const s=new pm({start:n.getStartXY(),end:n.getEndXY()});return Qu(t,e,s,i,r,o,a,h,u,m)}const l=rs(e,n);a=Math.max(a,l);let c=!1;{const t=e.getSemiAxes(),i=e.getCenter(),m=n.getSemiAxes(),l=n.getCenter(),g=Q.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===n.m_minorMajorRatio&&n.isClosed()&&n.isMajor();if(i&&a&&(c=!0,g<=d)){if(Math.max(t.x,m.x)<=Math.min(t.x,m.x)+g)return s(!r&&!o),1}}}if(!c&&os(e,n,a))return 0;const g=[],d=[],_=!1,p=!1,f=Wh(e,0,0,_,p,g,d,null),P=[],y=[],x=Wh(n,0,0,_,p,P,y,null);if(1===f&&1===x){const t=new Sn({points:g,weights:d}),s=new Sn({points:P,weights:y}),l=[],c=[],_=rh(!1,t,s,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(gt(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(gt(c[i],0,1))o.push(c[i]);else{const t=s.tToLength(c[i]),e=n.lengthToT(t);o.push(e)}}}return _}let C=[];const v=[];let b=0;const E=u&&!h;for(let s=0;s<f;s++){const t=new Sn({points:g.slice(2*s,2*s+3),weights:d.slice(2*s,2*s+3)});let i=0;for(let r=0;r<x;r++){v.length<=r&&v.push(new Sn({points:P.slice(2*r,2*r+3),weights:y.slice(2*r,2*r+3)}));const o=[],h=[],u=E?null:o,m=E?null:h,l=rh(!1,t,v[r],null,u,m,a,!1,E,!1);if(l>0&&E)return 1;for(let a=0;a<l;++a){if(0===o[a]&&0===s)o[a]=0;else if(1===o[a]&&s===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=n.lengthToT(t);h[a]=e}C.push(Mt(o[a],h[a]))}i+=v[r].calculateLength2D()}b+=t.calculateLength2D()}if(0===C.length)return 0;if(h&&(C=C.filter(t=>!gt(t.first,0,1)||!gt(t.second,0,1)||!e.getCoord2D(t.first).equals(n.getCoord2D(t.second)))),u)return C.length;const S=[],D=[];for(const s of C)S.push(s.first),D.push(s.second);return cm(t,e,n,S,D,S.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]=lu(t,e),i[1]=lu(t,s),i[2]=lu(t,r),i[3]=lu(t,o)}const r=new Q;for(let o=0;o<4;o++){const n=i[o];e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,r),s.mergeNe(r))}}function $u(t,e,n,i,r){if(0===t.m_semiMajorAxis)return n.vmin;let o=Q.getNAN();t.queryCoord2D(n.vmin,o);let a=Q.getNAN();if(t.queryCoord2D(n.vmax,a),Eu(t)){return new pm({start:o,end:a}).getClosestCoordinate(e,i)}const h=iu(t,e);if(o=iu(t,o),a=iu(t,a),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return n.vmin;const e=lu(t,Math.atan2(h.y,h.x));if(i||n.containsCoordinate(e))return e;return Q.distance(h,o)<=Q.distance(h,a)?n.vmin:n.vmax}const u=t.getSemiMajorAxis(),m=t.getSemiMinorAxis(),l=(u-m)*(u+m),c=zt(l),g=h.x,d=h.y,_=zt(m*d),p=m*l*d*2,f=[new at(_),new at(p),new at(c-zt(u*g)-_),new at(-p),new at(-c)],P=lt(at,4),y=_n(f,4,new H(-1,1),!1,P,4);let x=n.vmin,C=Q.sqrDistance(h,o);{const t=Q.sqrDistance(h,a);t<C&&(x=n.vmax,C=t)}s(!i);let v=U(8,Number.NaN);for(let s=0;s<y;++s){const e=P[s].value(),n=Math.sqrt(1-e*e),i=Math.atan2(e,n),r=Math.atan2(e,-n);v[2*s]=lu(t,i),v[2*s+1]=lu(t,r)}v=v.slice(0,2*y),Gt(v);for(let s=0,b=2*y;s<b;++s)if(v[s]>n.vmin&&v[s]<n.vmax){const n=Q.sqrDistance(e,t.getCoord2D(v[s]));C>n&&(C=n,x=v[s])}return x}function tm(t,e,n){s(!Eu(t));const i=new le;i.setRotateAngle(-t.getAxisXRotation());const r=new Q;i.queryTransform(e,r);const o=Math.atan2(-r.x*t.getMinorMajorRatio(),r.y),a=o+wt();let h=lu(t,o),u=lu(t,a);u<h&&(u=et(h,h=u));let m=0;return h>=0&&h<=1&&(n[m++]=h),u>=0&&u<=1&&(n[m++]=u),m}function em(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 sm(t,e,s){if(Eu(t))s.setE(Ye.constructPoint2D(t.getEndXY()).subE(Ye.constructPoint2D(t.getStartXY())));else{const n=new at;gu(t,e,n);const i=new Ye;if(i.setCoordsE(new at(t.m_semiMajorAxis).negate().mulE((new at).setSin(n)),new at(t.getSemiMinorAxis()).mulE((new at).setCos(n))),t.m_rotation){const e=new at(t.m_rotation);i.rotateDirect((new at).setCos(e),(new at).setSin(e))}i.scaleThis(new at(t.getSweepAngle())),s.setE(i)}}function nm(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 le;n.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=Q.distance(e,s),a=Q.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 Au(t,n,!0,e,s)}const h=new Q;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=Q.getClosestCoordinate(u,l,t.getCenter(),!0),g=new Q;xt(u,l,c,g);const d=Q.distance(e,g);t.constructEllipticArcEndPointsCenter(e,s,d,1,0,!0,!t.isClockwise(),g),t.setProjectionBehavior(0)}function im(t,e,n,i){const r=t.getStartXY(),o=t.getEndXY(),a=r.equals(o),h=e.equals(n);if(!a&&!h){const s=new le;return s.initializeFromTwoPoints(r,o,e,n),Au(t,s,!0,e,n),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void bu(t,e,n,1);if(a&&h){const s=t.m_center.add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,n,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),s)}if(!a){const s=.5*(kt()-Math.abs(t.getSweepAngle())),i=(t.getSweepAngle()+s*Nt(t.getSweepAngle()))/t.getSweepAngle(),r=new Q;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,n,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),o)}const u=Q.sqrDistance(e,n);let m=.25,l=.75;if(u<Q.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],n=tn(new su(t,u),H.construct(0,.25),1,e);n>0&&(s(1===n),m=e[0],l=1-e[0])}const c=t.getCoord2D(m),g=t.getCoord2D(l);s(!c.equals(g)),t.constructEllipticArcEndPointsCenter(c,g,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),im(t,e,n)}function rm(t,e,s,n,i){return om(t,!1,e,s,n,i)}function om(t,e,s,n,r,o){const a=s.getGeometryType(),u=n.getGeometryType(),m=Math.max(r,rs(s,n));if(a===i.enumLine&&u===i.enumLine)return Ss(s,n,m,o);let l=s,c=n,g=s.getStartXY(),d=s.getEndXY();if(g.compare(d)>0&&(l=s.clone().reverse()),g=n.getStartXY(),d=n.getEndXY(),g.compare(d)>0&&(c=n.clone().reverse()),e){if(s.equals(n))return 2;if(Ge(s,n,m))return 4}switch(a){case i.enumLine:switch(u){case i.enumEllipticArc:return Uu(t,c,l,m,o);case i.enumBezier:return Eo(t,c,l,m,o);case i.enumRationalBezier2:return $a(t,c,l,m,o);case i.enumBezier2:return Xi(t,c,l,m,o);default:h("")}break;case i.enumEllipticArc:switch(u){case i.enumLine:return Uu(t,l,c,m,o);case i.enumEllipticArc:return Ou(t,l,c,m,o);case i.enumBezier:return So(t,c,l,m,o);case i.enumRationalBezier2:return th(t,c,l,m,o);case i.enumBezier2:return qi(t,c,l,m,o);default:h("")}break;case i.enumBezier:switch(u){case i.enumLine:return Eo(t,l,c,m,o);case i.enumEllipticArc:return So(t,l,c,m,o);case i.enumBezier:return Do(t,l,c,m,o);case i.enumRationalBezier2:return wo(t,l,c,m,o);case i.enumBezier2:return Ao(t,l,c,m,o);default:h("")}break;case i.enumRationalBezier2:switch(u){case i.enumLine:return $a(t,l,c,m,o);case i.enumEllipticArc:return th(t,l,c,m,o);case i.enumBezier:return wo(t,c,l,m,o);case i.enumRationalBezier2:return eh(t,l,c,m,o);case i.enumBezier2:return sh(t,l,c,m,o);default:h("")}break;case i.enumBezier2:switch(u){case i.enumLine:return Xi(t,l,c,m,o);case i.enumEllipticArc:return qi(t,l,c,m,o);case i.enumBezier:return Ao(t,c,l,m,o);case i.enumRationalBezier2:return sh(t,c,l,m,o);case i.enumBezier2:return Fi(t,l,c,m,o);default:h("")}break;default:h("")}}function am(t,e,s=!0){if(!s&&!hm(t,e))return 0;const n=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.enumBezier){const n=t,i=e;return n.getControlPoint1().equals(i.getControlPoint1())&&n.getControlPoint2().equals(i.getControlPoint2())?s:0}if(r===i.enumEllipticArc){return em(t,e,!1)?s:0}if(r===i.enumRationalBezier2){const n=t,i=e;if(n.getControlPoint1().equals(i.getControlPoint1())&&n.getStandardFormWeight()===i.getStandardFormWeight())return s}else if(r===i.enumBezier2){const n=e;if(t.getControlPoint1().equals(n.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.enumBezier){const n=t,i=e;return n.getControlPoint1().equals(i.getControlPoint2())&&n.getControlPoint2().equals(i.getControlPoint1())?s:0}if(r===i.enumEllipticArc){return em(t,e,!0)?s:-1}if(r===i.enumRationalBezier2){const n=t,i=e;if(n.getControlPoint1().equals(i.getControlPoint1())&&n.getStandardFormWeight()===i.getStandardFormWeight())return s}else if(r===i.enumBezier2){const n=e;if(t.getControlPoint1().equals(n.getControlPoint1()))return s}return 0}return 0}function hm(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==i.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function um(t,s,n,r,o,a,u){!o&&a&&e("");const m=s.getGeometryType(),l=n.getGeometryType(),c=Math.max(u,rs(s,n));if(r&&(r.length=0),o&&(o.length=0),a&&(a.length=0),m===i.enumLine&&l===i.enumLine)return Ds(s,n,r,o,a,c,!1,!1);let g=s,d=n,_=s.getStartXY(),p=s.getEndXY(),f=!1,P=!1;_.compare(p)>0&&(g=s.clone(!0).reverse(),f=!0),_=n.getStartXY(),p=n.getEndXY(),_.compare(p)>0&&(d=n.clone(!0).reverse(),P=!0);let y=0;switch(m){case i.enumLine:switch(l){case i.enumEllipticArc:y=Qu(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier:y=To(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=nh(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier2:y=Vi(t,d,g,r,a,o,c,!1,!1,!0);break;default:h("")}break;case i.enumEllipticArc:switch(l){case i.enumLine:y=Qu(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=Ku(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=Io(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=ih(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier2:y=Li(t,d,g,r,a,o,c,!1,!1,!0);break;default:h("")}break;case i.enumRationalBezier2:switch(l){case i.enumLine:y=nh(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=ih(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=Yo(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=rh(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier2:y=oh(t,g,d,r,o,a,c,!1,!1,!1);break;default:h("")}break;case i.enumBezier2:switch(l){case i.enumLine:y=Vi(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=Li(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=No(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumRationalBezier2:y=oh(t,d,g,r,a,o,c,!1,!1,!0);break;case i.enumBezier2:y=Ri(t,g,d,r,o,a,c,!1,!1,!1);break;default:h("")}break;case i.enumBezier:switch(l){case i.enumLine:y=To(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumEllipticArc:y=Io(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier:y=Mo(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumRationalBezier2:y=Yo(t,g,d,r,o,a,c,!1,!1,!1);break;case i.enumBezier2:y=No(t,g,d,r,o,a,c,!1,!1,!1);break;default:h("")}break;default:h("")}if(f){if(o){for(let t=0;t<y;t++)o[t]=1-o[t];o.reverse()}r&&r.reverse(),a&&a.reverse()}if(P&&a)for(let e=0;e<y;e++)a[e]=1-a[e];return y}function mm(t,e,s){if(e===s)return 0;e>s&&(s=et(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function lm(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])),gt(s[u],0,1)&&gt(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]||gt(s[i],0,1)&&gt(n[i],0,1))continue;const o=(s,n,i,r)=>{const o=new Ye,a=new at;a.setWithEps(1);const h=new at;h.set(n,a.eps()),t.queryCoord2DE(h,o);const u=new Ye;t.queryCoord2DE(new at(s),u);let m=!1;return o.eq(u)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new at(i),u),m=o.eq(u)),!m},h=Q.getNAN();t.queryCoord2D(s[i],h);const m=Q.getNAN();e.queryCoord2D(n[i],m);if(0===Q.distance(h,m)&&o(s[u],s[i],n[u],n[i]))break;const l=new H(n[i],n[u]);l.normalizeNoNAN();const c=new H(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=Q.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=Q.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=gt(s[i],0,1)||gt(n[i],0,1)?0:1),1!==g)break;s[i]=s[u],n[i]=n[u]}}}function cm(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(gt(n,0,1)){n=ne(n);continue}const i=t.getCoord2D(n);n<.5?i.equals(t.getStartXY())&&mm(t,0,n)<=is(t)&&(e[s]=0):i.equals(t.getEndXY())&&mm(t,n,1)<=is(t)&&(e[s]=1)}};g(e,n),g(s,i),lm(e,s,n,i,r);const d=[];for(let f=0,P=r;f<P;f++)d.push(f);const _=(t,e)=>c?ie(i[t],n[t],i[e],n[e]):ie(n[t],i[t],n[e],i[e]);if(d.length>1){d.sort(_);const t=Math.max(is(e),is(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(mm(e,a,h)<=t&&mm(s,u,m)<=t&&!(gt(a,0,1)&&gt(u,0,1)||gt(h,0,1)&&gt(m,0,1))){const t=Q.distance(e.getCoord2D(a),s.getCoord2D(u)),n=Q.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=H.constructEmpty(),r=H.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=rt(t.vmin,t.vmax,n[i]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,u)){o=!1;break}a=rt(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;ke(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(gt(n[d[r]],0,1)&&gt(i[d[r]],0,1)){if(0===Q.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=Q.getNAN();e.queryCoord2D(n[d[f]],t),o.push(t)}p++}return p}function gm(t,e,s,n,i,r,o,a,h){if(gt(s,0,1)&&gt(n,0,1)){if(0===Q.distance(t.getCoord2D(s),e.getCoord2D(n))){const u=1e-12,m=new Ye,l=Number.EPSILON;if(t.queryDerivative(new at(s,l),m),m.isTrueZero()){const e=1===s?-u:u;t.queryDerivative(new at(s,l).add(e),m)}1===s&&m.negateThis();const c=new Ye;if(e.queryDerivative(new at(n,l),c),c.isTrueZero()){const t=1===s?-u:u;e.queryDerivative(new at(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(ut)&&(d.isZero()||Math.abs(d.value())<_())){return Be(t,e,s,n,i,r,o,a)}}}return 0}function dm(t,e,n,i,r){let o=-1,a=-1,h=-1,u=-1;{const s=[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[s[e]].equals(n[m[i]])){o=s[e],a=r[e],h=m[i],u=l[i];break}}if(-1===o){const s=new De;s.setFromPoints(t,e+1);const o=new De;return o.setFromPoints(n,i+1),o.inflate(r),s.isIntersectingW(o)?-1:0}{const m=U(e+1,Number.NaN),l=xr(t,e+1,m);s(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=U(i+1,Number.NaN),_=xr(n,i+1,d);s(_>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=n[d[(p+_-1)%_]],x=n[d[(p+1)%_]],C=t[o],v=[f,P,y,x],b=[0,1,2,3];b.sort((t,e)=>Q.compareVectorsOrigin(C,v[t],v[e]));let E=b[0];for(let t=1;t<4;t++){if(b[t]!==(E+1)%4)return-1;E=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 _m=b;class pm extends ds{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 s(0),0}calculateUpperLength3D(){return s(0),0}changeEndPoints3D(t,e){s(0)}getClosestCoordinate3D(t,e,n){return s(0),0}getBoundary(){return Js(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?fs(this,t):Ps(this,t);const n=_m.getInterpolation(e),i=this.getStartAttributeAsDbl(e,s),r=this.getEndAttributeAsDbl(e,s);return Ct(n,i,r,t,_m.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){s(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return pm.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=me.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=_m.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,ts(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,ts(this,1,1,0))):a("env type not impl")}applyTransformation(t){s(t instanceof le);const e=new Q;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 pm({vd:this.m_description})}calculateLength2D(){return Math.sqrt(Xs(this))}calculateLength3D(t){return s(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return s(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return _s(this,t,e)}queryCoord3D(t,e){s(0)}getCoordZ(t){return ys(this,t)}queryCoord2DE(t,e){Cs(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());const s=Xe.constructPoint2D(this.getEndXY());s.subThis(e),s.mulThis(it.constructDouble(t)),e.addThis(s)}getCoordX(t){return fs(this,t)}getCoordY(t){return Ps(this,t)}cut(t,e,s){const n=new fm;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=Q.getNAN();if(_s(this,t,r),i.setStartXYCoords(r.x,r.y),_s(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=_m.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){xs(this,t,e)}getClosestCoordinate(t,e){return Q.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const n=new Q;this.queryCoord2D(e.vmin,n);const i=new Q;this.queryCoord2D(e.vmax,i);const r=Q.getClosestCoordinate(n,i,t,!1);return us.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=fs(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 s(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new pm;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 Q;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=Q.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new Q;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return Is(this,t,e,s)>=0}isIntersectingPoint3D(t,e,n,i,r=1){return s(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,s){return s&&(t<2&&e(""),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]=fs(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]=Ps(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=_t(t.vmin,0,1);const n=new Q;return this.queryCoord2D(s,n),e.setCoords({pt:n}),s=_t(t.vmax,0,1),this.queryCoord2D(s,n),void e.mergeNe(n)}a("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 bs(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){vs(this,t[0],t[e-1])}writeInBufferStream(t,e){return s(0),0}readFromBufferStream(t,e){s(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){vs(this,t,e)}static isIntersectingLineLine(t,e,s,n){return Ss(t,e,s,n)}static isIntersectingLineLine_(t,e,s,n){return Ss(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 um(!1,this,t,e,s,n,i)}intersectPoint(t,e,s){e.length<1&&n("");const i=Is(this,t,s,!1);return i>=0?(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==rm(!1,this,t,e,s)}}pm.type=i.enumLine;class fm{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new pm,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):h("bad constructor params"))}assignCopy(t){return t instanceof fm?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof fm){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:h("")}}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){s(0)}createImpl(t){switch(t){case i.enumLine:1&this.m_mask||(this.m_lineBuffer=new pm,this.m_mask|=1,this.m_active=1);break;case i.enumEllipticArc:2&this.m_mask||(this.m_curves=new Xh,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case i.enumBezier:4&this.m_mask||(this.m_curves=new ia,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case i.enumBezier2:8&this.m_mask||(this.m_curves=new wn,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case i.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Sn,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:e("")}}create(t){t===i.enumLine?this.createLine():t===i.enumEllipticArc?this.createEllipticArc():t===i.enumBezier?this.createCubicBezier():t===i.enumRationalBezier2?this.createQuadraticRationalBezier():t===i.enumBezier2?this.createQuadraticBezier():e("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){s(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(i.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(i.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(i.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(i.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(i.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&h("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():h("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof fm?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):(a("seg comparison not yet impl"),!1)}}export{Xe as $,Ks as A,kh as B,wr as C,jh as D,Pr as E,Wh as F,ls as G,rm as H,ze as I,ia as J,fh as K,pm as L,Se as M,Gu as N,us as O,Os as P,Sn as Q,om as R,fm as S,um as T,is as U,pr as V,Es as W,Ye as X,am as Y,hm as Z,gm as _,ur as a,cu as a0,fr as a1,Yh as a2,Th as a3,_e as a4,Lu as a5,Ru as a6,Tu as a7,ou as a8,ks as a9,Ah as b,Js as c,zh as d,Er as e,yr as f,cs as g,Pe as h,vr as i,Ts as j,qh as k,Xh as l,Fh as m,cr as n,gr as o,Bh as p,sn as q,xe as r,pe as s,tn as t,lo as u,fe as v,Br as w,Kn as x,Ls as y,Rs as z};