@arcgis/core 5.2.0-next.136 → 5.2.0-next.138

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 (507) hide show
  1. package/analysis/LineOfSightAnalysisObserver.d.ts +12 -0
  2. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  3. package/analysis/LineOfSightAnalysisTarget.d.ts +12 -0
  4. package/analysis/LineOfSightAnalysisTarget.js +1 -1
  5. package/arcade/featureset/sources/FeatureLayerParquet.js +1 -1
  6. package/arcgisGlobal.d.ts +4 -0
  7. package/assets/components/assets/icon/blockHeightMedium16.json +1 -0
  8. package/assets/components/assets/icon/blockHeightMedium24.json +1 -0
  9. package/assets/components/assets/icon/blockHeightMedium32.json +1 -0
  10. package/assets/components/assets/icon/blockHeightShort16.json +1 -0
  11. package/assets/components/assets/icon/blockHeightShort24.json +1 -0
  12. package/assets/components/assets/icon/blockHeightShort32.json +1 -0
  13. package/assets/components/assets/icon/blockHeightTall16.json +1 -0
  14. package/assets/components/assets/icon/blockHeightTall24.json +1 -0
  15. package/assets/components/assets/icon/blockHeightTall32.json +1 -0
  16. package/assets/components/assets/icon/cursorCircle16.json +1 -0
  17. package/assets/components/assets/icon/cursorCircle24.json +1 -0
  18. package/assets/components/assets/icon/cursorCircle32.json +1 -0
  19. package/assets/components/assets/icon/dictionary16.json +1 -0
  20. package/assets/components/assets/icon/dictionary24.json +1 -0
  21. package/assets/components/assets/icon/dictionary32.json +1 -0
  22. package/assets/components/assets/icon/jobDependency16.json +1 -0
  23. package/assets/components/assets/icon/jobDependency24.json +1 -0
  24. package/assets/components/assets/icon/jobDependency32.json +1 -0
  25. package/assets/components/assets/icon/referenceChip16.json +1 -0
  26. package/assets/components/assets/icon/referenceChip24.json +1 -0
  27. package/assets/components/assets/icon/referenceChip32.json +1 -0
  28. package/assets/esri/core/workers/RemoteClient.js +1 -1
  29. package/assets/esri/core/workers/chunks/{4e6f95d8c624d513849a.js → 05963f57cbe5a5249496.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{0b8681ca4a83e97f1f71.js → 067de1910190da228291.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{3c0fd1c6cda44e9f40ab.js → 070684943698fa43c2b4.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{bc1cb4b9a02e6c78deb7.js → 076e8d2e08ff2a013736.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{c10e040368065411506a.js → 10445313d0d57b34511b.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{d537c59b46cdaaf66034.js → 1188d0a136fffc009643.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{20af3f085f60c32c6c53.js → 178083d8ed7707b45ca2.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{f5efe3e800c6e23efcf3.js → 1819c45655c836b9a8d7.js} +1 -1
  37. package/assets/esri/core/workers/chunks/1b946714ca4a1a7359d4.js +2 -0
  38. package/assets/esri/core/workers/chunks/{d8d8b38ac8a91d9e45fc.js → 1cc744ab5eee5ee3bed8.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{05e39b4de7f62c5b22cc.js → 20f75cc777af13fa249b.js} +1 -1
  40. package/assets/esri/core/workers/chunks/2a1ec30f9ad305763f81.js +2 -0
  41. package/assets/esri/core/workers/chunks/34570e6bbf559f18c1a5.js +1 -0
  42. package/assets/esri/core/workers/chunks/{60f6d5da9480dd36e877.js → 3dddae78286d05eb10fc.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{9efd30bbd02ec0d1031b.js → 3ec3589f6e74d7cb87cf.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{0bec054fca104f3bf141.js → 3f776d9fd2ab68b21fca.js} +1 -1
  45. package/assets/esri/core/workers/chunks/402a82c77420254831bc.js +1 -0
  46. package/assets/esri/core/workers/chunks/{e2ebf0ea3af2e6907987.js → 406f24ec13eb30d43405.js} +1 -1
  47. package/assets/esri/core/workers/chunks/43fc42405167a5537039.js +1 -0
  48. package/assets/esri/core/workers/chunks/{ddedc414bb478b376221.js → 46b2d4addfc73f9183a4.js} +1 -1
  49. package/assets/esri/core/workers/chunks/498d6dfd3bb0d3490548.js +1 -0
  50. package/assets/esri/core/workers/chunks/{36ef86701883a20dd6f6.js → 4a640548032355e57acd.js} +1 -1
  51. package/assets/esri/core/workers/chunks/5566f14afb63065e438f.js +1 -0
  52. package/assets/esri/core/workers/chunks/{c3b96d1d43afccd23e45.js → 590e6c70206122e4cc3c.js} +2 -2
  53. package/assets/esri/core/workers/chunks/{54860dd53a46cf4c47f3.js → 59295b99bdff4045a0e7.js} +1 -1
  54. package/assets/esri/core/workers/chunks/5aeb5e18514644fe2cf9.js +1 -0
  55. package/assets/esri/core/workers/chunks/{5da86409d70098fc6a10.js → 5b3cfe95314a75a735c1.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{a54678bfa0f1807b61cd.js → 5c855af73ee3c3e764fb.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{06da3409992bb1fa85b0.js → 5e90c1b49f2b7e21d05a.js} +39 -31
  58. package/assets/esri/core/workers/chunks/5fd099ca1024707387b2.js +1 -0
  59. package/assets/esri/core/workers/chunks/{30f808cac8a34f95ea6e.js → 6079d27f4ab319fb8f0c.js} +1 -1
  60. package/assets/esri/core/workers/chunks/66c2a28a851130b87c04.js +1 -0
  61. package/assets/esri/core/workers/chunks/{dac90b3631f7f7158f68.js → 67f15538c51838201fc7.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{cfaba0470619786e1ef8.js → 68d8ae42ab71d01a70a5.js} +2 -2
  63. package/assets/esri/core/workers/chunks/6aebf7cfd294e88bf926.js +1 -0
  64. package/assets/esri/core/workers/chunks/{864e7030c4ddbfcf0114.js → 6ccf9535013fe672c93b.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{ba7f0cf7e495d3ec2d55.js → 6e62581d933e7298d1f6.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{83b5dd4029e00abd80bf.js → 700b1d5bc67b7e1b3ff3.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{f9fea72cc222a30ef2f9.js → 72399062767abdfb0bee.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{2a7fbfd77002a24bf737.js → 747461bb6a1bc2f0a64d.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{c333f6ed42985bb2b11f.js → 7851aef196eea5d6c94e.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{f0b6bd6fab5320c3082f.js → 7a05b18f655c1167ce0a.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{04296b75d0f81fbd1bb5.js → 864194927d05ebc4cc31.js} +1 -1
  72. package/assets/esri/core/workers/chunks/{3c4a13a9f0b305394a26.js → 876f7633c15f1e31078d.js} +1 -1
  73. package/assets/esri/core/workers/chunks/{62298dba3f6cbdc3f4ae.js → 879b2f0ff1977bca9376.js} +1 -1
  74. package/assets/esri/core/workers/chunks/{b547b3bce729c9dac90d.js → 898359be6996fd9763b8.js} +1 -1
  75. package/assets/esri/core/workers/chunks/8cb716f110d164030309.js +1 -0
  76. package/assets/esri/core/workers/chunks/8dc1c3042267618fd710.js +2 -0
  77. package/assets/esri/core/workers/chunks/{625f02db93d7fbf175ca.js → 9001e9a1e81bce175ddd.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{9ffa6c8d93d3443834c6.js → 912080c90b5cc2e817cf.js} +1 -1
  79. package/assets/esri/core/workers/chunks/96c50a0dda0f1503ef92.js +2 -0
  80. package/assets/esri/core/workers/chunks/{13e4379441499599c3b5.js → 9cbde13e536676767900.js} +1 -1
  81. package/assets/esri/core/workers/chunks/{408db4f32850b77264ae.js → 9cd3fcb5fca6f9dbbcd8.js} +1 -1
  82. package/assets/esri/core/workers/chunks/a054da6cbd8ee4774a57.js +1 -0
  83. package/assets/esri/core/workers/chunks/a05790444115e4cf1bcc.js +1 -0
  84. package/assets/esri/core/workers/chunks/{d1f2685782b423ef87a6.js → a556dd4e9e6d35e33a2c.js} +1 -1
  85. package/assets/esri/core/workers/chunks/{00d576d355599c88931e.js → bc38def1983089514e4b.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{0725e515f3004bdd5c56.js → ca2adcbcf44454484fd5.js} +1 -1
  87. package/assets/esri/core/workers/chunks/{f3507b9e831ffd7a6bf8.js → cca8bd07bcd1d267a2e8.js} +1 -1
  88. package/assets/esri/core/workers/chunks/cfae60b9d2f2939e9c16.js +1 -0
  89. package/assets/esri/core/workers/chunks/{1d6b2a64f4e40e5cc13d.js → d201fbf3ceff946d2bd6.js} +1 -1
  90. package/assets/esri/core/workers/chunks/{4439078780d9ba49fd26.js → d51bb11baadc741c46bc.js} +1 -1
  91. package/assets/esri/core/workers/chunks/db1ab9b9c8bf5c7635d3.js +1 -0
  92. package/assets/esri/core/workers/chunks/de02a6a1f4810f99e9bb.js +1 -0
  93. package/assets/esri/core/workers/chunks/e630f3c56c077cb2bd8e.js +1 -0
  94. package/assets/esri/core/workers/chunks/e81173724e8de8c1e65b.js +1 -0
  95. package/assets/esri/core/workers/chunks/{2025288bed125594ceda.js → f6e62d2d279a328cbed7.js} +1 -1
  96. package/assets/esri/core/workers/chunks/{47c19778fcee7154ca38.js → f8bc474434fd365ab174.js} +1 -1
  97. package/assets/esri/core/workers/chunks/{9a20dc26cb9c7b2087cf.js → f95a1f878c9c1146180e.js} +1 -1
  98. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ar.json +1 -1
  99. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bg.json +1 -1
  100. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bs.json +1 -1
  101. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ca.json +1 -1
  102. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.cs.json +1 -1
  103. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.da.json +1 -1
  104. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.de.json +1 -1
  105. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.el.json +1 -1
  106. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.en.json +1 -1
  107. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.es.json +1 -1
  108. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.et.json +1 -1
  109. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fi.json +1 -1
  110. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fr.json +1 -1
  111. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.he.json +1 -1
  112. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hr.json +1 -1
  113. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hu.json +1 -1
  114. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.id.json +1 -1
  115. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.it.json +1 -1
  116. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ja.json +1 -1
  117. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ko.json +1 -1
  118. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lt.json +1 -1
  119. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lv.json +1 -1
  120. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.nl.json +1 -1
  121. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.no.json +1 -1
  122. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pl.json +1 -1
  123. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-BR.json +1 -1
  124. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-PT.json +1 -1
  125. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ro.json +1 -1
  126. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ru.json +1 -1
  127. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sk.json +1 -1
  128. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sl.json +1 -1
  129. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sr.json +1 -1
  130. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sv.json +1 -1
  131. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.th.json +1 -1
  132. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.tr.json +1 -1
  133. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.uk.json +1 -1
  134. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.vi.json +1 -1
  135. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-CN.json +1 -1
  136. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-HK.json +1 -1
  137. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-TW.json +1 -1
  138. package/assets/esri/widgets/FeatureForm/t9n/messages.ar.json +1 -1
  139. package/assets/esri/widgets/FeatureForm/t9n/messages.bg.json +1 -1
  140. package/assets/esri/widgets/FeatureForm/t9n/messages.bs.json +1 -1
  141. package/assets/esri/widgets/FeatureForm/t9n/messages.ca.json +1 -1
  142. package/assets/esri/widgets/FeatureForm/t9n/messages.cs.json +1 -1
  143. package/assets/esri/widgets/FeatureForm/t9n/messages.da.json +1 -1
  144. package/assets/esri/widgets/FeatureForm/t9n/messages.de.json +1 -1
  145. package/assets/esri/widgets/FeatureForm/t9n/messages.el.json +1 -1
  146. package/assets/esri/widgets/FeatureForm/t9n/messages.es.json +1 -1
  147. package/assets/esri/widgets/FeatureForm/t9n/messages.et.json +1 -1
  148. package/assets/esri/widgets/FeatureForm/t9n/messages.fi.json +1 -1
  149. package/assets/esri/widgets/FeatureForm/t9n/messages.fr.json +1 -1
  150. package/assets/esri/widgets/FeatureForm/t9n/messages.he.json +1 -1
  151. package/assets/esri/widgets/FeatureForm/t9n/messages.hr.json +1 -1
  152. package/assets/esri/widgets/FeatureForm/t9n/messages.hu.json +1 -1
  153. package/assets/esri/widgets/FeatureForm/t9n/messages.id.json +1 -1
  154. package/assets/esri/widgets/FeatureForm/t9n/messages.it.json +1 -1
  155. package/assets/esri/widgets/FeatureForm/t9n/messages.ja.json +1 -1
  156. package/assets/esri/widgets/FeatureForm/t9n/messages.ko.json +1 -1
  157. package/assets/esri/widgets/FeatureForm/t9n/messages.lt.json +1 -1
  158. package/assets/esri/widgets/FeatureForm/t9n/messages.lv.json +1 -1
  159. package/assets/esri/widgets/FeatureForm/t9n/messages.nl.json +1 -1
  160. package/assets/esri/widgets/FeatureForm/t9n/messages.no.json +1 -1
  161. package/assets/esri/widgets/FeatureForm/t9n/messages.pl.json +1 -1
  162. package/assets/esri/widgets/FeatureForm/t9n/messages.pt-BR.json +1 -1
  163. package/assets/esri/widgets/FeatureForm/t9n/messages.pt-PT.json +1 -1
  164. package/assets/esri/widgets/FeatureForm/t9n/messages.ro.json +1 -1
  165. package/assets/esri/widgets/FeatureForm/t9n/messages.ru.json +1 -1
  166. package/assets/esri/widgets/FeatureForm/t9n/messages.sk.json +1 -1
  167. package/assets/esri/widgets/FeatureForm/t9n/messages.sl.json +1 -1
  168. package/assets/esri/widgets/FeatureForm/t9n/messages.sr.json +1 -1
  169. package/assets/esri/widgets/FeatureForm/t9n/messages.sv.json +1 -1
  170. package/assets/esri/widgets/FeatureForm/t9n/messages.th.json +1 -1
  171. package/assets/esri/widgets/FeatureForm/t9n/messages.tr.json +1 -1
  172. package/assets/esri/widgets/FeatureForm/t9n/messages.uk.json +1 -1
  173. package/assets/esri/widgets/FeatureForm/t9n/messages.vi.json +1 -1
  174. package/assets/esri/widgets/FeatureForm/t9n/messages.zh-CN.json +1 -1
  175. package/assets/esri/widgets/FeatureForm/t9n/messages.zh-HK.json +1 -1
  176. package/assets/esri/widgets/FeatureForm/t9n/messages.zh-TW.json +1 -1
  177. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ar.json +1 -1
  178. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.bg.json +1 -1
  179. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.bs.json +1 -1
  180. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ca.json +1 -1
  181. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.cs.json +1 -1
  182. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.da.json +1 -1
  183. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.de.json +1 -1
  184. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.el.json +1 -1
  185. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.en.json +1 -1
  186. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.es.json +1 -1
  187. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.et.json +1 -1
  188. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.fi.json +1 -1
  189. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.fr.json +1 -1
  190. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.he.json +1 -1
  191. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.hr.json +1 -1
  192. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.hu.json +1 -1
  193. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.id.json +1 -1
  194. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.it.json +1 -1
  195. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ja.json +1 -1
  196. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ko.json +1 -1
  197. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.lt.json +1 -1
  198. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.lv.json +1 -1
  199. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.nl.json +1 -1
  200. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.no.json +1 -1
  201. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.pl.json +1 -1
  202. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.pt-BR.json +1 -1
  203. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.pt-PT.json +1 -1
  204. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ro.json +1 -1
  205. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.ru.json +1 -1
  206. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sk.json +1 -1
  207. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sl.json +1 -1
  208. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sr.json +1 -1
  209. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.sv.json +1 -1
  210. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.th.json +1 -1
  211. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.tr.json +1 -1
  212. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.uk.json +1 -1
  213. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.vi.json +1 -1
  214. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.zh-CN.json +1 -1
  215. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.zh-HK.json +1 -1
  216. package/assets/esri/widgets/OrientedImageryViewer/t9n/messages.zh-TW.json +1 -1
  217. package/chunks/Bufferer-CclWhXVb.js +1 -1
  218. package/chunks/Component.glsl.js +3 -3
  219. package/chunks/DefaultMaterial.glsl.js +2 -2
  220. package/chunks/Distance2DCalculator-DjIp2uQi.js +1 -1
  221. package/chunks/Envelope.js +1 -1
  222. package/chunks/Envelope2D.js +1 -1
  223. package/chunks/FocusArea.glsl.js +8 -10
  224. package/chunks/GaussianSplat.glsl.js +2 -2
  225. package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
  226. package/chunks/GeodeticUtils.js +1 -1
  227. package/chunks/Geometry.js +1 -1
  228. package/chunks/GeometryCleaner-CIE8Wfmb.js +1 -1
  229. package/chunks/GlobalIllumination.glsl.js +3 -3
  230. package/chunks/LineMarker.glsl.js +35 -42
  231. package/chunks/MultiPathImpl.js +1 -1
  232. package/chunks/OperatorAffineTransform.js +1 -1
  233. package/chunks/OperatorClip.js +1 -1
  234. package/chunks/OperatorDensify.js +1 -1
  235. package/chunks/OperatorDistance.js +1 -1
  236. package/chunks/OperatorGeneralize.js +1 -1
  237. package/chunks/OperatorGeodesicBuffer.js +1 -1
  238. package/chunks/OperatorGeodeticArea.js +1 -1
  239. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  240. package/chunks/OperatorGeodeticDistance.js +1 -1
  241. package/chunks/OperatorGeodeticLength.js +1 -1
  242. package/chunks/OperatorGraphicBuffer.js +1 -1
  243. package/chunks/OperatorIntegrate.js +1 -1
  244. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  245. package/chunks/OperatorProximity.js +1 -1
  246. package/chunks/OperatorProximityGeodesic.js +1 -1
  247. package/chunks/OperatorShapePreservingLength.js +1 -1
  248. package/chunks/OperatorShapePreservingProject.js +1 -1
  249. package/chunks/OperatorSimplifyOGC.js +1 -1
  250. package/chunks/Path.glsl.js +2 -2
  251. package/chunks/Point2D.js +1 -1
  252. package/chunks/RealisticTree.glsl.js +2 -2
  253. package/chunks/RibbonLine.glsl.js +51 -57
  254. package/chunks/SideCalculator2D-DX0718xq.js +1 -1
  255. package/chunks/Terrain.glsl.js +2 -2
  256. package/chunks/Transformation2D.js +1 -1
  257. package/chunks/UnitFactory.js +1 -1
  258. package/config.js +1 -1
  259. package/core/workers/RemoteClient.js +1 -1
  260. package/core/workers/workerFactory.js +1 -1
  261. package/editing/fieldUtils.d.ts +12 -0
  262. package/editing/sharedTemplates/templateDefinitions/TemplateDefinitionBase.js +1 -1
  263. package/geometry/operators/extendOperator.js +1 -1
  264. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  265. package/geometry/operators/gx/operatorBoundary.js +1 -1
  266. package/geometry/operators/gx/operatorBuffer.js +1 -1
  267. package/geometry/operators/gx/operatorConvexHull.js +1 -1
  268. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  269. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  270. package/geometry/operators/gx/operatorLocateBetween.js +1 -1
  271. package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
  272. package/geometry/operators/gx/operatorOffset.js +1 -1
  273. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  274. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  275. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  276. package/geometry/operators/isNearOperator.js +1 -1
  277. package/geometry/operators/reshapeOperator.js +1 -1
  278. package/geometry/operators/support/jsonConverter.js +1 -1
  279. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  280. package/geometry/support/ellipseUtils.js +2 -0
  281. package/interfaces.d.ts +15 -18
  282. package/kernel.js +1 -1
  283. package/layers/LinkChartLayer.js +1 -1
  284. package/layers/ParquetLayer.js +1 -1
  285. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  286. package/layers/list/LayerItemCollection.d.ts +1 -0
  287. package/layers/list/types.d.ts +5 -1
  288. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  289. package/layers/orientedImagery/queries.js +1 -1
  290. package/layers/support/TimeSeriesCalculation.d.ts +1 -1
  291. package/layers/support/TimeSeriesCalculation.js +1 -1
  292. package/layers/support/dataSeriesUtils.d.ts +10 -0
  293. package/layers/support/timeSeriesUtils.js +17 -6
  294. package/libs/lyr3d/Lyr3DModule.js +1 -1
  295. package/networks/UtilityNetwork.d.ts +15 -0
  296. package/networks/UtilityNetwork.js +1 -1
  297. package/package.json +4 -4
  298. package/popup/FeatureContent.d.ts +14 -1
  299. package/popup/FeatureContent.js +1 -1
  300. package/popup/FeatureContentCollection.d.ts +4 -10
  301. package/popup/FeatureContentCollection.js +1 -1
  302. package/popup/actions.js +1 -1
  303. package/popup/support/featureUtils.js +1 -1
  304. package/renderers/support/RenderingInfo.js +1 -1
  305. package/renderers/support/renderingInfoUtils.js +1 -1
  306. package/renderers/visualVariables/SizeVariable.d.ts +16 -20
  307. package/renderers/visualVariables/support/SizeStop.d.ts +6 -2
  308. package/rest/networks/support/TraceLocation.js +1 -1
  309. package/rest/networks/support/TraceResult.d.ts +7 -0
  310. package/rest/networks/support/TraceResult.js +1 -1
  311. package/smartMapping/renderers/color.js +1 -1
  312. package/smartMapping/renderers/opacity.js +1 -1
  313. package/smartMapping/renderers/size.js +1 -1
  314. package/smartMapping/renderers/support/timeSeriesUtils.js +1 -1
  315. package/smartMapping/statistics/histogramForTimeSeries.d.ts +11 -0
  316. package/smartMapping/statistics/histogramForTimeSeries.js +2 -0
  317. package/smartMapping/statistics/summaryStatisticsForTimeSeries.d.ts +11 -0
  318. package/smartMapping/statistics/summaryStatisticsForTimeSeries.js +2 -0
  319. package/smartMapping/statistics/support/timeSeriesUtils.js +24 -0
  320. package/smartMapping/statistics/types.d.ts +50 -0
  321. package/support/tests/serviceMockDependencies.js +1 -1
  322. package/support/tests/setupServiceMocksMesh.js +1 -1
  323. package/symbols/cim/CIMPlacements.js +1 -1
  324. package/symbols/cim/callouts/calloutAnalysisUtils.js +1 -1
  325. package/symbols/cim/callouts/effects/BackgroundCallout.js +1 -1
  326. package/symbols/cim/callouts/effects/BalloonCallout.js +1 -1
  327. package/symbols/cim/callouts/effects/PointSymbolCallout.js +1 -1
  328. package/symbols/cim/callouts/effects/calloutUtils.js +1 -1
  329. package/symbols/cim/cimAnalyzer.js +1 -1
  330. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  331. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  332. package/views/2d/engine/vectorTiles/decluttering/CollisionJob.js +1 -1
  333. package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
  334. package/views/2d/engine/vectorTiles/decluttering/jobsUtil.js +1 -1
  335. package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
  336. package/views/2d/engine/webgl/definitions.js +1 -1
  337. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedShader.js +1 -1
  338. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
  339. package/views/2d/engine/webgl/shaderGraph/techniques/animated/ComputedAnimatedParams.js +1 -1
  340. package/views/2d/engine/webgl/shaderGraph/techniques/markers/ComputedMarkerParams.js +1 -1
  341. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/CalloutMeshWriterPolicy.js +1 -1
  342. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
  343. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextParams.js +1 -1
  344. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  345. package/views/2d/layers/SketchLayerView2D.js +1 -1
  346. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  347. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  348. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  349. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  350. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  351. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  352. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  353. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  354. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  355. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  356. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  357. package/views/2d/layers/features/layerAdapters/labelingUtils.js +1 -1
  358. package/views/2d/layers/features/schema/ExceedsLimitCache.js +1 -1
  359. package/views/2d/layers/features/schema/TimeSchema.js +2 -0
  360. package/views/2d/layers/features/schema/processor/LabelMatcherSchema.js +1 -1
  361. package/views/2d/layers/features/schema/processor/MatcherSchema.js +1 -1
  362. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  363. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  364. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  365. package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
  366. package/views/2d/layers/support/vectorTileDebugUtils.js +1 -1
  367. package/views/2d/layers/support/visualVariableSimpleUtils.js +1 -1
  368. package/views/2d/types.d.ts +2 -1
  369. package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
  370. package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
  371. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  372. package/views/3d/analysis/LineOfSightAnalysisView3D.d.ts +24 -0
  373. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  374. package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
  375. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  376. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  377. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  378. package/views/3d/camera/constraintUtils.js +1 -1
  379. package/views/3d/input/handlers/ground/GroundDoubleClickMove.js +1 -1
  380. package/views/3d/input/handlers/ground/GroundNavigation.js +1 -1
  381. package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
  382. package/views/3d/interactive/placementTools/GroundNavigationPlacementTool3D.js +1 -1
  383. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  384. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  385. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  386. package/views/3d/state/controllers/GroundNavigationController.js +1 -1
  387. package/views/3d/state/controllers/momentum/GroundNavigationMomentumController.js +1 -1
  388. package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
  389. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  390. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  391. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  392. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +16 -8
  393. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +5 -1
  394. package/views/3d/webgl-engine/core/shaderLibrary/shading/evaluateSceneLightingFragment.glsl.js +12 -0
  395. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +2 -2
  396. package/views/3d/webgl-engine/effects/focusArea/FocusArea.glsl.js +1 -1
  397. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  398. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  399. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  400. package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
  401. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  402. package/views/SelectionManager.d.ts +3 -3
  403. package/views/draw/support/Reshape.js +1 -1
  404. package/views/interactive/options/bindViewToolOptions.js +1 -1
  405. package/views/interactive/sketch/SketchLabelOptions.d.ts +3 -0
  406. package/views/interactive/sketch/SketchLabelOptions.js +1 -1
  407. package/views/interactive/sketch/SketchTooltipOptions.d.ts +3 -0
  408. package/views/interactive/sketch/SketchTooltipOptions.js +1 -1
  409. package/views/interactive/sketch/SketchValueOptions.d.ts +3 -0
  410. package/views/interactive/sketch/SketchValueOptions.js +1 -1
  411. package/views/interactive/snapping/SnappingOptions.d.ts +3 -0
  412. package/views/interactive/snapping/SnappingOptions.js +1 -1
  413. package/views/interactive/snapping/snappingUtils.js +1 -1
  414. package/views/interactive/tooltip/fields/parsingAndFormattingUtils.js +1 -1
  415. package/views/layers/SketchLayerView.d.ts +34 -0
  416. package/views/layers/SketchLayerView.js +2 -0
  417. package/views/layers/types.d.ts +3 -2
  418. package/views/selection/types.d.ts +15 -4
  419. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  420. package/widgets/BasemapGallery.js +1 -1
  421. package/widgets/Bookmarks/BookmarksViewModel.d.ts +4 -0
  422. package/widgets/Bookmarks/BookmarksVisibleElements.d.ts +5 -1
  423. package/widgets/Bookmarks/types.d.ts +2 -0
  424. package/widgets/Editor/EditorViewModel.d.ts +31 -30
  425. package/widgets/Editor/EditorViewModel.js +1 -1
  426. package/widgets/Editor/components/Settings.js +1 -1
  427. package/widgets/Editor/types.d.ts +44 -0
  428. package/widgets/Editor.d.ts +30 -27
  429. package/widgets/Editor.js +1 -1
  430. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -1
  431. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  432. package/widgets/FeatureTable/support/FeatureStore.d.ts +1 -1
  433. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  434. package/widgets/FeatureTable.d.ts +6 -0
  435. package/widgets/FeatureTable.js +1 -1
  436. package/widgets/Histogram/types.d.ts +10 -2
  437. package/widgets/HistogramRangeSlider/types.d.ts +4 -1
  438. package/widgets/LayerList/LayerListViewModel.d.ts +2 -1
  439. package/widgets/Legend/LegendViewModel.d.ts +2 -0
  440. package/widgets/Legend/styles/card/CardView.d.ts +2 -0
  441. package/widgets/Legend/styles/classic/ClassicView.d.ts +4 -1
  442. package/widgets/Legend.d.ts +3 -0
  443. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.d.ts +7 -0
  444. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  445. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  446. package/widgets/OrientedImageryViewer/support/VideoFeatureCache.js +2 -0
  447. package/widgets/OrientedImageryViewer/types.d.ts +9 -0
  448. package/widgets/OrientedImageryViewer.d.ts +7 -0
  449. package/widgets/OrientedImageryViewer.js +2 -2
  450. package/widgets/PanoramicVideoViewer.js +1 -1
  451. package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
  452. package/widgets/ScaleRangeSlider/types.d.ts +9 -2
  453. package/widgets/Sketch/SketchViewModel.d.ts +32 -1
  454. package/widgets/Sketch/SketchViewModel.js +1 -1
  455. package/widgets/Sketch.d.ts +27 -1
  456. package/widgets/Sketch.js +1 -1
  457. package/widgets/Slider/types.d.ts +58 -13
  458. package/widgets/Slider.d.ts +6 -0
  459. package/widgets/smartMapping/BinaryColorSizeSlider/BinaryColorSizeSliderViewModel.d.ts +2 -0
  460. package/widgets/smartMapping/ClassedColorSlider/ClassedColorSliderViewModel.d.ts +2 -0
  461. package/widgets/smartMapping/ClassedSizeSlider/ClassedSizeSliderViewModel.d.ts +2 -0
  462. package/widgets/smartMapping/ColorSizeSlider/ColorSizeSliderViewModel.d.ts +2 -0
  463. package/widgets/smartMapping/ColorSlider/ColorSliderViewModel.d.ts +2 -0
  464. package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.d.ts +2 -0
  465. package/widgets/smartMapping/OpacitySlider/OpacitySliderViewModel.d.ts +2 -0
  466. package/widgets/smartMapping/SizeSlider/SizeSliderViewModel.d.ts +3 -0
  467. package/widgets/smartMapping/SmartMappingPrimaryHandleSliderViewModel.d.ts +2 -0
  468. package/widgets/smartMapping/SmartMappingSliderViewModel.d.ts +2 -0
  469. package/widgets/smartMapping/types.d.ts +30 -7
  470. package/widgets/support/FilterBuilder/FilterBuilderViewModel.d.ts +21 -11
  471. package/widgets/support/FilterBuilder/FilterBuilderViewModel.js +1 -1
  472. package/widgets/support/FilterBuilder/types.d.ts +28 -0
  473. package/widgets/support/FilterBuilder.js +1 -1
  474. package/widgets/support/FilterCondition/FilterConditionViewModel.d.ts +24 -0
  475. package/widgets/support/FilterCondition/FilterConditionViewModel.js +1 -1
  476. package/widgets/support/FilterCondition/types.d.ts +16 -1
  477. package/widgets/support/FilterCondition.js +1 -1
  478. package/widgets/support/SnappingControls/snappingLayerListUtils.js +1 -1
  479. package/widgets/support/iconUtils.js +1 -1
  480. package/assets/esri/core/workers/chunks/0606ab6fdfc1dfea3856.js +0 -1
  481. package/assets/esri/core/workers/chunks/078dcd17f46403d44b24.js +0 -1
  482. package/assets/esri/core/workers/chunks/1289204f8ca96032c17a.js +0 -1
  483. package/assets/esri/core/workers/chunks/12b5a645c0987a0efe54.js +0 -2
  484. package/assets/esri/core/workers/chunks/152fe3d6ad7aebbd23d1.js +0 -1
  485. package/assets/esri/core/workers/chunks/17b938ba49fb1e7ab8c4.js +0 -1
  486. package/assets/esri/core/workers/chunks/1dbb3e25e005a8220779.js +0 -2
  487. package/assets/esri/core/workers/chunks/3d6fef25af7e1a51e1bd.js +0 -1
  488. package/assets/esri/core/workers/chunks/3ef367c9b7bf1588307d.js +0 -1
  489. package/assets/esri/core/workers/chunks/5f4feca26102088ea565.js +0 -1
  490. package/assets/esri/core/workers/chunks/74211d096cc3296e0968.js +0 -1
  491. package/assets/esri/core/workers/chunks/7926faab76a721a2e1c4.js +0 -1
  492. package/assets/esri/core/workers/chunks/ad28486bc6afaa346de5.js +0 -1
  493. package/assets/esri/core/workers/chunks/ad29c729e90b5866713c.js +0 -1
  494. package/assets/esri/core/workers/chunks/b72a2514aa4cc4ae7d1b.js +0 -1
  495. package/assets/esri/core/workers/chunks/bb51cf52b8ea8283f4f8.js +0 -1
  496. package/assets/esri/core/workers/chunks/be761749f8d77fbd9df5.js +0 -1
  497. package/assets/esri/core/workers/chunks/dbfd25aa0d19aed5890c.js +0 -1
  498. package/assets/esri/core/workers/chunks/de28a86775235bd5d3c4.js +0 -2
  499. package/assets/esri/core/workers/chunks/f6cfc901267a229de7a1.js +0 -2
  500. package/assets/esri/core/workers/chunks/fb147097149a89e671ff.js +0 -1
  501. package/support/revision.js +0 -2
  502. /package/assets/esri/core/workers/chunks/{1dbb3e25e005a8220779.js.LICENSE.txt → 1b946714ca4a1a7359d4.js.LICENSE.txt} +0 -0
  503. /package/assets/esri/core/workers/chunks/{f6cfc901267a229de7a1.js.LICENSE.txt → 2a1ec30f9ad305763f81.js.LICENSE.txt} +0 -0
  504. /package/assets/esri/core/workers/chunks/{c3b96d1d43afccd23e45.js.LICENSE.txt → 590e6c70206122e4cc3c.js.LICENSE.txt} +0 -0
  505. /package/assets/esri/core/workers/chunks/{cfaba0470619786e1ef8.js.LICENSE.txt → 68d8ae42ab71d01a70a5.js.LICENSE.txt} +0 -0
  506. /package/assets/esri/core/workers/chunks/{de28a86775235bd5d3c4.js.LICENSE.txt → 8dc1c3042267618fd710.js.LICENSE.txt} +0 -0
  507. /package/assets/esri/core/workers/chunks/{12b5a645c0987a0efe54.js.LICENSE.txt → 96c50a0dda0f1503ef92.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8885],{95213(t,e,i){i.d(e,{$:()=>v,A:()=>X,B:()=>L,C:()=>K,D:()=>O,E:()=>Rt,F:()=>G,H:()=>J,I:()=>H,J:()=>At,K:()=>x,L:()=>Nt,M:()=>f,N:()=>y,O:()=>P,P:()=>It,Q:()=>u,R:()=>c,S:()=>z,T:()=>Z,U:()=>C,V:()=>d,W:()=>S,X:()=>A,Z:()=>$,a:()=>R,a0:()=>T,a1:()=>I,a2:()=>M,a3:()=>bt,a4:()=>rt,a5:()=>it,a6:()=>st,a7:()=>w,b:()=>N,c:()=>nt,d:()=>ht,e:()=>lt,f:()=>dt,g:()=>et,h:()=>tt,i:()=>yt,j:()=>_t,k:()=>E,l:()=>Pt,m:()=>mt,n:()=>gt,o:()=>at,p:()=>ft,q:()=>ct,r:()=>b,s:()=>pt,t:()=>ot,u:()=>Dt,v:()=>wt,w:()=>xt,x:()=>Ct,y:()=>Et,z:()=>vt});var s=i(83661),r=i(55537),n=i(79187);const o=[0,0,NaN,0,0,0,0,0,-1,-1,0,0,0,0],a=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],l=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],h=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],m=[4,8,4,8,1];function u(){return(0,s.d)(25,NaN)}let d=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return l[t]}static getPersistence(t){return h[t]}static getPersistenceSize(t){return m[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return a[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return o[t]}static isDefaultValue(t,e){return(0,s.G)(o[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=(0,s.d)(25,NaN),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let i=0,r=1,n=14;for(;i<n;i++)e&r&&(this.m_semanticsToIndexMap[i]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=i,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(i)),r<<=1;let o=0;for(i=0,n=this.getAttributeCount();i<n;i++){let e=this.getSemantics(i),s=t.getComponentCount(e),r=t.getDefaultValue(e);this.m_pointAttributeOffsets[i]=o;for(let t=0;t<s;t++)this.m_defaultPointAttributes[o]=r,o++}}m_semanticsBitArray;m_attributeCount;m_totalComponentCount;m_semanticsToIndexMap;m_indexToSemantics;m_pointAttributeOffsets;m_defaultPointAttributes};var g=d;function c(){return(0,s.d)(14,0)}class _{m_map;m_vd2D;m_vd3D;static s_thisInstance;static{_.s_thisInstance=new _}static getInstance(){return _.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new g(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new g(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();let e=this.m_map.get(t);if(e)return e;let i=new g(t);return this.m_map.set(t,i),i}}function p(t){return _.getInstance().FindOrAdd(t)}function f(t,e){if(!t||!e)return e||t;let i=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(i&t.getSemanticsBitArray())===i?t:(i&e.getSemanticsBitArray())===i?e:p(i)}function y(t,e){let i=t.getSemanticsBitArray()|1<<e;return(i&t.getSemanticsBitArray())===i?t:p(i)}function P(t,e){let i=(t.getSemanticsBitArray()|1<<e)-(1<<e);return i===t.getSemanticsBitArray()?t:p(i)}function x(){return _.getInstance().GetVD2D()}function v(){return _.getInstance().GetVD3D()}function C(t,e,i){if(i.fill(-1),null!==t&&null!==e)for(let s=0,r=t.getAttributeCount();s<r;s++)i[s]=e.getAttributeIndex(t.getSemantics(s))}class E{x;y;z;static construct(t,e,i){return new E(t,e,i)}constructor(t,e,i){void 0!==t?(this.x=t,this.y=e,this.z=i):this.x=this.y=this.z=NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new E(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,i){return this.x=t,this.y=e,this.z=i,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){let t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){let t=new E;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return(0,r.g)(0),0}static sqrDistance(t,e){return(0,s.a)(t.x-e.x)+(0,s.a)(t.y-e.y)+(0,s.a)(t.z-e.z)}static sqrDistanceCoords(t,e,i,r,n,o){return(0,s.a)(t-r)+(0,s.a)(e-n)+(0,s.a)(i-o)}static distance(t,e){return Math.sqrt(E.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&(0,s.a8)(this.z,t.z,e)}static compareByLength(t,e,i,s){return(0,r.g)(0),0}isEqualCoords(t,e,i,s){return(0,r.g)(0),this.x===t&&this.y===e&&this.z===i}isEqualsTols(t,e,i){return(0,r.g)(0),!1}isEqualCoordsTols(t,e,i,s,n){return(0,r.g)(0),!1}static st_isEqual(t,e,i,s){return(0,r.g)(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,i){return(0,r.g)(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}sub(t){return E.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return E.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){let e=this.y*t.z-t.y*this.z,i=t.x*this.z-this.x*t.z,s=this.x*t.y-t.x*this.y;return new E(e,i,s)}setCrossProductVector(t,e){let i=t.y*e.z-e.y*t.z,s=e.x*t.z-t.x*e.z,r=t.x*e.y-e.x*t.y;return this.x=i,this.y=s,this.z=r,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return(0,r.g)(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return E.construct(NaN,NaN,NaN)}isFinite(){return(0,r.g)(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return(0,r.g)(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return(0,r.g)(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,i,s=!1){return(0,r.g)(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:+(this.z>t.z)}compareXYZ(t){return(0,r.g)(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return(0,r.g)(0),{}}static average(t,e){return(0,r.g)(0),{}}static dimensions=3;static size(){return E.dimensions}static lerp(t,e,i){let r=new E;return(0,s.y)(t,e,i,r),r}static slerp(t,e,i){return(0,r.g)(0),{}}static compareVectors(t,e){return(0,r.g)(0),0}static selectRightHandedBasisFromNormal(t,e,i){let s=t.getUnitVector(),r=s.createAPerpendicular(),n=new E;n.setCrossProductVector(s,r),n.normalizeThis(),e.setCoordsPoint3D(r),i.setCoordsPoint3D(n)}createAPerpendicular(){let t=[this.crossProductVector(new E(0,0,1)),this.crossProductVector(new E(1,0,0)),this.crossProductVector(new E(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],i=t[e.reduce((t,i,s)=>e[t]>e[s]?t:s,0)];return i.normalizeThis(),i}calculateAngle(t){return(0,r.g)(0),0}static crossDotSign(t,e,i){return(0,r.g)(0),0}static isBisectorRobust(t,e,i){return(0,r.g)(0),0}static compareZOrder(t,e){return(0,r.g)(0),!1}}class b{m_EnvelopeType=3;xmin;ymin;zmin;xmax;ymax;zmax;static constructEmpty(){return new b(NaN,NaN,NaN,NaN,NaN,NaN)}constructor(t,e,i,s,r,n){this.xmin=t,this.ymin=e,this.zmin=i,this.xmax=s,this.ymax=r,this.zmax=n,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,i){(0,r.g)(0)}getEnvelope2D(){return new n.Envelope2D(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new s.E(this.zmin,this.zmax)}setEmptyZ(){this.zmin=NaN,this.zmax=NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=(0,s.c)(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=(0,s.c)(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=(0,s.c)(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=NaN,this.ymin=NaN,this.zmin=NaN,this.xmax=NaN,this.ymax=NaN,this.zmax=NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,i){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>i?this.zmin=i:this.zmax<i&&(this.zmax=i)}mergeCoords(t,e,i){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=i,this.zmax=i):(this.isEmptyZ()&&(this.zmin=i,this.zmax=i),this.mergeNeCoords(t,e,i))}setCoords(t,e,i,s,r,n){this.xmin=t,this.ymin=e,this.zmin=i,this.xmax=s,this.ymax=r,this.zmax=n,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,i,s=1){return(0,r.g)(0),0}sqrMaxDistance(t,e=1){return(0,r.g)(0),0}}var D=d;function w(t,e,i){switch(t){case 0:return new Y(e,i);case 1:return new X(e,i);case 2:return new R(e,i);case 3:throw Error("64 bit int attribute stream not implemented");case 4:return new N(e,i);default:(0,r.a)("")}}function S(t,e){let i=D.getComponentCount(t);return w(D.getPersistence(t),e*i,D.getDefaultValue(t))}function A(t,e){let i=D.getComponentCount(t);return w(D.getPersistence(t),e*i)}function T(t,e){return new R(t,e)}function I(t,e){return new N(t,e)}function M(t,e){return new X(t,e)}class q{static s_constructMin=2;static s_resizeMin=30;size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;let i=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>q.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),i&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){let s=1.25*t,r=new this.m_a.constructor(s);r.set(this.m_a),this.m_a=r,i&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,i){(e<0||i<0||i+e>this.size())&&(0,r.a)(),this.m_a.fill(t,e,e+i)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){let i=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,i)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),i))}getArray(){return this.m_a}equals(t,e,i,r){return this.getPersistence()===t.getPersistence()&&function(t,e,i,r,n){if(t.getPersistence()!==e.getPersistence())return!1;let o=t.getPersistence()<=1,a=t.size(),l=e.size();if(r>a||r>l)return!1;if(n)if(o){for(let o=i;o<r;o++)if(!(0,s.a8)(t.read(o),e.read(o),n))return!1}else for(let s=i;s<r;s++){let i=t.read(s)-e.read(s);if(i<0&&(i=-i),i>n)return!1}else for(let s=i;s<r;s++){let i=t.read(s),r=e.read(s);if(i!==r){if(o&&Number.isNaN(i)&&Number.isNaN(r))continue;return!1}}return!0}(this,t,e,i,r)}insertRange(t,e,i,s){let r=this.m_size;this.checkResize(Math.max(0,s)+i),this.m_a.copyWithin(t+i,t,s>=0?s:r),this.m_a.fill(e,t,t+i)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,i,s,n,o,a){(0,r.g)(this.getPersistence()===e.getPersistence());let l=e,h=this.m_size;s&&this.checkResize(Math.max(0,a)+s),this.m_a.copyWithin(t+s,t,a>=0?a:h),this.m_a.set(l.readRange(i,s),t),n||this.reverseRange(t,s,o)}writeRange(t,e,i,s,n,o){(0,r.g)(this.getPersistence()===i.getPersistence());let a=i;if((t<0||e<0||s<0)&&(0,r.a)(),a.size()<s+e&&(0,r.a)(),0===e)return;this.size()<e+t&&this.resize(e+t);let l=a.m_a.subarray(s,s+e);!function(t,e,i,s){if((e<0||i<0)&&(0,r.a)(),0===i)return;if(1===i)return void(t[e]=s[0]);let n=s;i<s.length&&(n=s.subarray(0,i)),t.set(n,e)}(this.m_a,t,e,l)}insertAttributes(t,e,i,s){let r=D.getComponentCount(i);this.m_a.copyWithin(t+r,t,s>=0?s:this.m_size);for(let s=0;s<r;s++)this.m_a[t+s]=e.getAttributeAsDbl(i,s)}insertAttributesFromPoints(t,e,i,n,o){(0,r.g)(D.getPersistence(n)===this.getPersistence());let a=D.getComponentCount(n),l=this.m_size;if(this.checkResize(Math.max(0,o)+a*i),this.m_a.copyWithin(t+a*i,t,o>=0?o:l),0===n){let r=new s.P;for(let s=t,n=0;n<i;n++,s+=2)e[n].queryXY(r),this.m_a[s]=r.x,this.m_a[s+1]=r.y}else if(1===a)for(let s=t,r=0;r<i;r++,s++)this.m_a[s]=e[r].getAttributeAsDbl(n,0);else for(let s=t,r=0;r<i;r++,s+=a)for(let t=0;t<a;t++)this.m_a[s+t]=e[r].getAttributeAsDbl(n,t)}eraseRange(t,e,i){this.m_size<t+e&&(0,r.a)(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,i){if((i<1||e%i!==0)&&(0,r.a)(),this.m_a.subarray(t,t+e).reverse(),i>1)for(let s=t,r=t+e;s<r;s+=i){let t=s,e=s+i-1;for(;t<e;){let i=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=i,t++,e--}}}rotate(t,e,i){(e<t||e>i||t>i)&&(0,r.r)("rotate"),e!==t&&e!==i&&(this.reverseRange(t,e-t,1),this.reverseRange(e,i-e,1),this.reverseRange(t,i-t,1))}sort(t,e,i){this.m_a.subarray(t,e).sort(i)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.fromArray)this.m_a=t.fromArray,this.m_size=t.size??t.fromArray.length;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{let e=Math.max(t.size,q.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}m_a;m_size}class N extends q{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new N({ctor:Int8Array,copy:this})}restrictedClone(t){return new N({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class R extends q{getPersistence(){return 2}clone(){return new R({ctor:Int32Array,copy:this})}restrictedClone(t){return new R({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){(0,r.g)(e<=(0,s.i)()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class Y extends q{getPersistence(){return 0}clone(){return new Y({ctor:Float32Array,copy:this})}restrictedClone(t){return new Y({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class X extends q{getPersistence(){return 1}applyTransformation(t,e,i){(1&e||e+2*i>this.size())&&(0,r.a)();let s=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(s,i,s)}readPoint2D(t){let e=this.m_a[t],i=this.m_a[t+1];return new s.P(e,i)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,i){this.checkResize(i+2),this.m_a.copyWithin(t+2,t,i),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,i,s,r,n){let o=this.m_size;if(this.checkResize(Math.max(n,0)+2*s),this.m_a.copyWithin(t+2*s,t,n>=0?n:o),r)for(let r=i,n=t,o=0;o<s;++o,++r){let t=e[r];this.m_a[n++]=t.x,this.m_a[n++]=t.y}else for(let r=i+s-1,n=t,o=0;o<s;++o,--r){let t=e[r];this.m_a[n++]=t.x,this.m_a[n++]=t.y}}queryRange(t,e,i,s,n){if((t<0||e<0)&&(0,r.a)(),!s&&(n<=0||e%n!==0)&&(0,r.a)(),0===e)return;if(1===e)return void(i[0]=this.m_a[t]);let o=this.m_a.subarray(t,t+e);i.set(o)}writeRangeFromArray(t,e,i,s,n){if((t<0||e<0)&&(0,r.a)(),0===e)return;if(1===e)return void(this.m_a[t]=i[0]);let o=i;e<i.length&&(o=i.subarray(0,e)),this.m_a.set(o,t)}clone(){return new X({ctor:Float64Array,copy:this})}restrictedClone(t){return new X({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}const F={partCount:0,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:0,segmentCountBezier:0};class L{m_buckets;m_bucketedIndices;static c_maxBuckets=65536;m_minValue=-1;m_maxValue=-1;m_dy=NaN;constructor(){this.m_buckets=new R(0),this.m_bucketedIndices=new R(0)}static sortEx(t,e,i,s,r=32){i-e<=r?s.userSort(e,i,t):(new L).sort(t,e,i,s,r)}sort(t,e,i,s,r=32){if(i-e<=r)return void s.userSort(e,i,t);let n=!0,o=1/0,a=-1/0;for(let r=e;r<i;r++){let e=s.getValue(t.read(r));e<o&&(o=e),e>a&&(a=e)}if(this.reset(i-e,o,a,i-e)){for(let r=e;r<i;r++){let i=t.read(r),n=s.getValue(i),o=this.getBucket(n);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(r-e,i)}let r=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){let e=this.m_buckets.read(t);this.m_buckets.write(t,r),r+=e}for(let r=e;r<i;r++){let i=this.m_bucketedIndices.read(r-e),n=s.getValue(i),o=this.getBucket(n),a=this.m_buckets.read(o);t.write(a+e,i),this.m_buckets.write(o,a+1)}n=!1}if(n)return void s.userSort(e,i,t);let l=0;for(let i=0,r=this.m_buckets.size();i<r;i++){let r=l;l=this.m_buckets.read(i),l>r&&s.userSort(e+r,e+l,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,i,s){if(t<2||i===e)return!1;let r=Math.min(L.c_maxBuckets,t);return this.m_buckets.resize(r),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=i,this.m_bucketedIndices.resize(s),this.m_dy=(i-e)/(r-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}class z{m_buffer=new Int32Array;m_firstFree=-1;m_last=0;size_=0;capacity_=0;stride;capacity(){return this.capacity_}constructor(t){this.stride=t}size(){return this.size_}deleteElement(t){t<this.m_last?(this.m_buffer[t*this.stride]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.size_--}getField(t,e){return this.m_buffer[t*this.stride+e]}setField(t,e,i){this.m_buffer[t*this.stride+e]=i}elementToIndex(t){return t}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.capacity_){let t=0===this.capacity_?1:Math.trunc(3*(this.capacity_+1)/2);if(t>2**53-1&&(t=2**53-1),t===this.capacity_)throw Error("index out of bounds");this.grow_(t)}t=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[t*this.stride];this.size_++;for(let e=t*this.stride;e<t*this.stride+this.stride;e++)this.m_buffer[e]=-1;return t}newElementPset(t){let e=this.m_firstFree;if(-1===e){if(this.m_last===this.capacity_){let t=0===this.capacity_?1:Math.trunc(3*(this.capacity_+1)/2);if(t>2**53-1&&(t=2**53-1),t===this.capacity_)throw Error("index out of bounds");this.grow_(t)}e=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[e*this.stride];this.size_++;let i=e*this.stride;for(let e=0;e<t.length;e++)this.m_buffer[i+e]=t[e];return e}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.size_=0,t&&(this.m_buffer=new Int32Array,this.capacity_=0)}setCapacity(t){t>this.capacity_&&this.grow_(t)}swap(t,e){let i=t*this.stride,s=e*this.stride;for(let t=0;t<this.stride;t++){let e=this.m_buffer[s+t];this.m_buffer[s+t]=this.m_buffer[i+t],this.m_buffer[i+t]=e}}swapField(t,e,i){let s=this.m_buffer[this.stride*e+i];this.m_buffer[this.stride*e+i]=this.m_buffer[this.stride*t+i],this.m_buffer[this.stride*t+i]=s}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}grow_(t){this.m_buffer??=new Int32Array;let e=this.stride*t,i=new Int32Array(e);i.set(this.m_buffer,0),this.m_buffer=i,this.capacity_=t}}class V{m_extent=new n.Envelope2D;m_dataExtent=new n.Envelope2D;m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D];m_quadTreeNodes;m_elementNodes=new z(4);m_data=[];m_freeData=[];m_root=-1;m_height=8;m_bStoreDuplicates;static m_quadrantMask=3;static m_heightBitShift=2;static m_flushingCount=5;constructor(t,e,i){void 0===i&&(i=!1),this.m_quadTreeNodes=new z(i?11:10),this.m_bStoreDuplicates=i,this.reset_(t,e)}reset(t,e){this.m_quadTreeNodes.deleteAll(!1),this.m_elementNodes.deleteAll(!1),this.m_data.length=0,this.m_freeData.length=0,this.reset_(t,e)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){let i=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==i&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),i}let i=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==i&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),i}insertEx(t,e,i){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){let i=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==i&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),i}let s;s=-1===i?this.m_root:this.getQuad_(i);let r=this.getHeight(s),n=this.getExtent(s),o=this.insert_(t,e,r,n,s,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){(0,r.g)(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return(0,r.g)(0),0}getElementExtent(t){let e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return(0,r.g)(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return(0,r.g)(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>V.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){let e=new n.Envelope2D;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;let i=[],s=t;do{i.push(this.getQuadrant_(s)),s=this.getParent_(s)}while(s!==this.m_root);let r=i.length;for(let t=0;t<r;t++){let t=i.at(-1);i.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,i){if(-1===this.m_root)return 0;let r=new n.Envelope2D;r.setCoords({env2D:t}),r.inflateCoords(e,e);let o=[],a=[];o.push(this.m_root),a.push(this.m_extent.clone());let l=(0,s.m)(n.Envelope2D,4),h=0;for(;o.length>0;){let t=!1,e=o.at(-1),s=a.at(-1);if(o.pop(),a.pop(),r.containsEnvelope(s)){if(h+=this.getSubTreeElementCount(e),i>0&&h>=i)return i}else if(r.isIntersecting(s)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){let e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(r)&&(h++,i>0&&h>=i))return i}t=this.getHeight(e)+1<=this.m_height}if(t){V.setChildExtents_(s,l);for(let t=0;t<4;t++){let i=this.getChild_(e,t);-1!==i&&this.getSubTreeElementCount_(i)>0&&r.isIntersecting(l[t])&&(o.push(i),a.push(l[t].clone()))}}}return h}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new B(this,t,e)}getIteratorForQT(){return new B(this)}getSortedIterator(t,e){return new k(this.getIterator(t,e))}getSortedIteratorForQT(){return new k(this.getIteratorForQT())}visitLeavesNearest(t,e,i,s){(0,r.g)(0)}reset_(t,e){(e<0||e>127)&&(0,r.a)("invalid height"),this.m_height=e,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,i,s,r,o,a){if(!s.containsEnvelope(e))return 0===i?-1:this.insert_(t,e,0,this.m_extent,this.m_root,o,a);if(!o)for(let t=r;-1!==t;t=this.getParent_(t))this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1);let l=new n.Envelope2D;l.setCoords({env2D:s});let h,m=r;for(h=i;h<this.m_height&&this.canPushDown_(m);h++){V.setChildExtents_(l,this.m_childExtents);let t=!1;for(let i=0;i<4;i++)if(this.m_childExtents[i].containsEnvelope(e)){t=!0;let e=this.getChild_(m,i);-1===e&&(e=this.createChild_(m,i)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),m=e,l.setCoords({env2D:this.m_childExtents[i]});break}if(!t)break}return this.insertAtQuad_(t,e,h,l,m,o,r,a,-1)}insertDuplicates_(t,e,i,r,o,a,l){if(!a){if(!r.containsEnvelope(e))return-1;this.setSubTreeElementCount_(o,this.getSubTreeElementCount_(o)+1),this.setContainedSubTreeElementCount_(o,this.getContainedSubTreeElementCount_(o)+1)}let h=Math.max(e.width(),e.height()),m=-1,u=[],d=[],g=[];u.push(o),d.push(r.clone()),g.push(i);let c=(0,s.m)(n.Envelope2D,4);for(;u.length>0;){let i=!1,s=u.at(-1),r=d.at(-1),n=g.at(-1);if(u.pop(),d.pop(),g.pop(),n+1<this.m_height&&this.canPushDown_(s)&&h<=Math.max(r.width(),r.height())/2&&(i=!0),i){V.setChildExtents_(r,c);let t=!1;for(let i=0;i<4;i++)if(t=c[i].containsEnvelope(e),t){let t=this.getChild_(s,i);-1===t&&(t=this.createChild_(s,i)),u.push(t),d.push(c[i].clone()),g.push(n+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let t=0;t<4;t++)if(c[t].isIntersecting(e)){let e=this.getChild_(s,t);-1===e&&(e=this.createChild_(s,t)),u.push(e),d.push(c[t].clone()),g.push(n+1),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1)}}else m=this.insertAtQuad_(t,e,n,r,s,a,o,l,m),a=!1}return 0}insertAtQuad_(t,e,i,s,r,n,o,a,l){this.getFirstElement_(r);let h=this.getLastElement_(r),m=-1;if(n){if(r===o)return a;this.disconnectElementHandle_(a),m=a}else-1===l?(m=this.createElement_(),this.setDataValues_(this.getData_(m),t,e)):m=this.createElementFromDuplicate_(l);return this.setQuad_(m,r),-1===h?this.setFirstElement_(r,m):(this.setPrevElement_(m,h),this.setNextElement_(h,m)),this.setLastElement_(r,m),this.setLocalElementCount_(r,this.getLocalElementCount_(r)+1),this.canFlush_(r)&&this.flush_(i,s,r),m}static setChildExtents_(t,e){let i=.5*(t.xmin+t.xmax),s=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:i,ymin:s,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:s,xmax:i,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:i,ymax:s}),e[3].setCoords({xmin:i,ymin:t.ymin,xmax:t.xmax,ymax:s})}disconnectElementHandle_(t){let e=this.getQuad_(t),i=this.getFirstElement_(e),s=this.getLastElement_(e),r=this.getPrevElement_(t),n=this.getNextElement_(t);i===t?(-1===n?this.setLastElement_(e,-1):this.setPrevElement_(n,-1),this.setFirstElement_(e,n)):s===t?(this.setNextElement_(r,-1),this.setLastElement_(e,r)):(this.setPrevElement_(n,r),this.setNextElement_(r,n)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===V.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,i){let s,r=new n.Envelope2D,o=this.getFirstElement_(i),a=-1,l=-1;do{l=this.getData_(o),s=this.getElementValue_(l),r.setCoords({env2D:this.getBoundingBoxValue_(l)}),a=this.getNextElement_(o),this.m_bStoreDuplicates?this.insertDuplicates_(s,r,t,e,i,!0,o):this.insert_(s,r,t,e,i,!0,o),o=a}while(-1!==o)}canPushDown_(t){return this.getLocalElementCount_(t)>=V.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){let i=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,i),this.setSubTreeElementCount_(i,0),this.setLocalElementCount_(i,0),this.setParent_(i,t),this.setHeightAndQuadrant_(i,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(i,0),i}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){let t,e=this.m_elementNodes.newElement();return this.m_freeData.length>0?(t=this.m_freeData.at(-1),this.m_freeData.pop()):(t=this.m_data.length,this.m_data.length=t+1),this.setData_(e,t),e}createElementFromDuplicate_(t){let e=this.m_elementNodes.newElement(),i=this.getData_(t);return this.setData_(e,i),e}freeElementAndBoxNode_(t){(0,r.g)(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,i){this.m_quadTreeNodes.setField(t,e,i)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&V.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>V.m_heightBitShift}setHeightAndQuadrant_(t,e,i){let s=e<<V.m_heightBitShift|i;this.m_quadTreeNodes.setField(t,6,s)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,i){this.m_data[t]=function(t,e){return{element:t,box:e.clone()}}(e,i)}}class B{m_bLinear=!1;m_queryStart=new s.P;m_queryEnd=new s.P;m_queryBox=new n.Envelope2D;m_tolerance=0;m_currentElementHandle=-1;m_nextElementHandle=-1;m_quadTree;m_quadsStack=[];m_extentsStack=[];m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D];constructor(t,e,i){this.m_quadTree=t,e&&this.resetIterator(e,i)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof n.Envelope2D)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){let i=t.getGeometryType();if(this.m_bLinear=i===r.G.enumLine,this.m_bLinear){let i=t;this.m_queryStart.assign(i.getStartXY()),this.m_queryEnd.assign(i.getEndXY()),this.m_tolerance=e}else this.m_tolerance=NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;let t=new s.P,e=new s.P,i=new n.Envelope2D,r=!1;for(;!r;){for(;-1!==this.m_currentElementHandle;){let s=this.m_quadTree.getData_(this.m_currentElementHandle);if(i.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(s)}),i.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){r=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),i.inflateCoords(this.m_tolerance,this.m_tolerance),i.clipLine(t,e)>0){r=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){let i=this.m_quadsStack.at(-1),s=this.m_extentsStack.at(-1);V.setChildExtents_(s,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let s=0;s<4;s++){let r=this.m_quadTree.getChild_(i,s);if(-1!==r&&this.m_quadTree.getSubTreeElementCount(r)>0&&this.m_childExtents[s].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);let i=new n.Envelope2D;i.setCoords({env2D:this.m_childExtents[s]}),i.inflateCoords(this.m_tolerance,this.m_tolerance),i.clipLine(t,e)>0&&(this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[s].clone()))}else this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[s].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return(0,r.g)(0),{}}}class k{m_bucketSort=new L;m_sortedHandles=new R(0);m_quadTreeIteratorImpl;m_index=-1;constructor(t){this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);let e=this;this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),{userSort(t,i,s){s.sort(t,i,(t,i)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(i))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)})}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return(0,r.g)(0),{}}}class G{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}m_bNotifyOnActions;onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class Z{static st_nullNode(){return-1}constructor(){}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||=((0,r.g)(this.m_treapCount<=1),this.rebalance(-1),!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing||(-1===t&&(t=this.m_defaultTreap),0===this.size(t)))return;let e=[];for(let i=this.getFirst(t);-1!==i;i=this.getNext(i))e.push(i),this.setParent_(i,-1),this.setRight_(i,-1),this.setLeft_(i,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(let i of e)this.addBiggestElement_(i,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){let e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);let i=this.newNode_(t);return this.addBiggestElement_(i,e),i}addElementAtPosition(t,e,i,r,n,o=-1){if(-1===o&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),o=this.m_defaultTreap),this.getRoot_(o)===Z.st_nullNode()){let t=this.newNode_(i);return this.setRoot_(t,o),this.addToList_(-1,t,o),t}let a,l,h,m,u;if(n?(a=e===Z.st_nullNode()?-1:this.m_comparator.compare(this,i,e),l=t===Z.st_nullNode()?1:this.m_comparator.compare(this,i,t)):(a=-1,l=1),r&&(0===a||0===l)){this.m_comparator.onAddUniqueElementFailedImpl(i);let s=0===a?e:t;return this.setDuplicateElement_(s,o),-1}u=e!==Z.st_nullNode()&&t!==Z.st_nullNode()?this.m_random>(0,s.Q)(this.m_random)>>1:e!==Z.st_nullNode(),u?(m=a,h=e):(m=l,h=t);let d=-1,g=-1,c=!0;for(;;){if(m<0){let t=this.getLeft(h);if(t===Z.st_nullNode()){g=h,d=this.newNode_(i),this.setLeft_(h,d),this.setParent_(d,h);break}h=t}else{let t=this.getRight(h);if(t===Z.st_nullNode()){g=this.getNext(h),d=this.newNode_(i),this.setRight_(h,d),this.setParent_(d,h);break}h=t}c&&=(m*=-1,!1)}return this.bubbleUp_(d),this.getParent(d)===Z.st_nullNode()&&this.setRoot_(d,o),this.addToList_(g,d,o),d}replaceElementAtPosition(t,e,i,s,r=-1){if(s){let s=this.getNext(t),n=-1;s!==Z.st_nullNode()&&(n=this.m_comparator.compare(this,e,s));let o=this.getPrev(t),a=-1;if(o!==Z.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),i&&(0===n||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);let t=0===n?s:o;return r===Z.st_nullNode()&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),r=this.m_defaultTreap),this.setDuplicateElement_(t,r),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let i=this.getRoot(e);for(;i!==Z.st_nullNode();){let e=this.m_comparator.compare(this,t,i);if(!e)return i;i=e<0?this.getLeft(i):this.getRight(i)}return this.m_comparator.onEndSearchImpl(t),Z.st_nullNode()}searchLowerBound(t,e=-1){let i=this.getRoot(e),s=-1;for(;i!==Z.st_nullNode();){let e=t.compare(this,i);if(!e)return i;e<0?i=this.getLeft(i):(s=i,i=this.getRight(i))}return s}searchUpperBound(t,e=-1){let i=this.getRoot(e),s=-1;for(;i!==Z.st_nullNode();){let e=t.compare(this,i);if(!e)return i;e<0?(s=i,i=this.getLeft(i)):i=this.getRight(i)}return s}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=Z.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,i){let s;-1===t?s=this.getLast_(i):(s=this.getPrev(t),this.setPrev_(t,e)),this.setPrev_(e,s),-1!==s&&this.setNext_(s,e),this.setNext_(e,t),t===this.getFirst_(i)&&this.setFirst_(e,i),-1===t&&this.setLast_(e,i),this.setSize_(this.getSize_(i)+1,i)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return z.isValidElement(t)}m_defaultTreap=-1;m_random=124234251;m_comparator=null;m_treapData=new z(7);m_treapCount=0;m_maxDepthEver=0;m_bBalancing=!0;dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),i=this.getRight(t),r=this.getPriority_(t);for(;e!==Z.st_nullNode()||i!==Z.st_nullNode();){let n=e===Z.st_nullNode()?(0,s.j)():this.getPriority_(e),o=i===Z.st_nullNode()?(0,s.j)():this.getPriority_(i);if(r<=Math.min(n,o))return;n<=o?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),i=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;let e=this.getPriority_(t),i=this.getParent(t);for(;i!==Z.st_nullNode()&&this.getPriority_(i)>e;)this.getLeft(i)===t?this.rotateRight_(t):this.rotateLeft_(i),i=this.getParent(t)}rotateLeft_(t){let e,i=t,s=this.getRight(t);this.setParent_(s,this.getParent(i)),this.setParent_(i,s),e=this.getLeft(s),this.setRight_(i,e),e!==Z.st_nullNode()&&this.setParent_(e,i),this.setLeft_(s,i),e=this.getParent(s),e!==Z.st_nullNode()&&(this.getLeft(e)===i?this.setLeft_(e,s):this.setRight_(e,s))}rotateRight_(t){let e,i=this.getParent(t),s=t;this.setParent_(s,this.getParent(i)),this.setParent_(i,s),e=this.getRight(s),this.setLeft_(i,e),e!==Z.st_nullNode()&&this.setParent_(e,i),this.setRight_(s,i),e=this.getParent(s),e!==Z.st_nullNode()&&(this.getLeft(e)===i?this.setLeft_(e,s):this.setRight_(e,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){let e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==Z.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=(0,s.Q)(this.m_random),this.m_random&(0,s.j)()>>1}maxPriority(){return(0,r.g)(0),0}getMaxDepthHelper_(t){return t===Z.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,i){if(this.getRoot(i)===Z.st_nullNode()){let e=this.newNode_(t);return this.setRoot_(e,i),this.addToList_(-1,e,i),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let s=this.getRoot_(i),r=-1,n=-1,o=1;for(;;){let a=-1===e?1:this.m_comparator.compare(this,t,s);if(a<0){let e=this.getLeft(s);if(e===Z.st_nullNode()){n=s,r=this.newNode_(t),this.setLeft_(s,r),this.setParent_(r,s);break}s=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(s,i),-1;let o=this.getRight(s);if(o===Z.st_nullNode()){n=this.getNext(s),r=this.newNode_(t),this.setRight_(s,r),this.setParent_(r,s);break}s=o}o++}return this.bubbleUp_(r),this.getParent(r)===Z.st_nullNode()&&this.setRoot_(r,i),this.addToList_(n,r,i),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),r}removeFromList_(t,e){let i=this.getPrev(t),s=this.getNext(t);-1===i?this.setFirst_(s,e):this.setNext_(i,s),-1===s?this.setLast_(i,e):this.setPrev_(s,i),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let i=this.getLeft(t),r=this.getRight(t),n=this.getParent(t),o=t;if(-1!==i&&-1!==r){let a;this.m_random=(0,s.Q)(this.m_random),a=this.m_random>(0,s.j)()>>1?this.getNext(t):this.getPrev(t);let l=this.getParent(a)===t;this.m_treapData.swapField(t,a,0),this.m_treapData.swapField(t,a,1),this.m_treapData.swapField(t,a,2),-1===n?this.setRoot_(a,e):this.getLeft(n)===t?this.setLeft_(n,a):this.setRight_(n,a),l?(i===a?(this.setLeft_(a,t),this.setParent_(r,a)):r===a&&(this.setRight_(a,t),this.setParent_(i,a)),this.setParent_(t,a),n=a):(this.setParent_(i,a),this.setParent_(r,a),n=this.getParent(t),o=a),i=this.getLeft(t),r=this.getRight(t),-1!==i&&this.setParent_(i,t),-1!==r&&this.setParent_(r,t)}let a=-1===i?r:i;-1===n?this.setRoot_(a,e):this.getLeft(n)===o?this.setLeft_(n,a):this.setRight_(n,a),-1!==a&&this.setParent_(a,n),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,(0,s.j)());let i=Z.st_nullNode(),r=Z.st_nullNode(),n=this.getRoot_(e),o=n===t;if(o&&(i=this.getLeft(n),r=this.getRight(n),i===Z.st_nullNode()&&r===Z.st_nullNode()))return this.removeFromList_(n,e),this.freeNode_(n,e),void this.setRoot_(Z.st_nullNode(),e);this.bubbleDown_(t);let a=this.getParent(t);a!==Z.st_nullNode()&&(this.getLeft(a)===t?this.setLeft_(a,Z.st_nullNode()):this.setRight_(a,Z.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),o&&this.setRoot_(i===Z.st_nullNode()||this.getParent(i)!==Z.st_nullNode()?r:i,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===Z.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);let i=this.getLast_(e);this.setRight_(i,t),this.setParent_(t,i),this.bubbleUp_(t),this.getParent(t)===Z.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class H{m_listNodes;m_lists;m_listOfLists;m_bStoreListIndexWithNode;constructor(t){this.m_lists=new z(6),this.m_listOfLists=H.st_nullNode(),void 0===t?(this.m_listNodes=new z(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new z(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){(0,r.g)(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(t,e){(0,r.g)(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){(0,r.g)(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){let e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==H.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);let e=this.m_lists.getField(t,2),i=this.m_lists.getField(t,3);return e===H.st_nullNode()?this.m_listOfLists=i:this.setNextList_(e,i),i!==H.st_nullNode()&&this.setPrevList_(i,e),this.freeList_(t),i}reserveLists(t){(0,r.g)(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return(0,r.g)(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,i){let s=this.newNode_(),r=-1;if(e!==H.st_nullNode()&&(r=this.getPrev(e),this.setPrev_(e,s)),this.setNext_(s,e),r!==H.st_nullNode()&&this.setNext_(r,s),e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,s),e===H.st_nullNode()){let e=this.m_lists.getField(t,1);this.setPrev_(s,e),-1!==e&&this.setNext_(e,s),this.m_lists.setField(t,1,s)}return this.setData(s,i),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(s,t),s}deleteElement(t,e){let i=this.getPrev(e),s=this.getNext(e);return i===H.st_nullNode()?this.m_lists.setField(t,0,s):this.setNext_(i,s),s===H.st_nullNode()?this.m_lists.setField(t,1,i):this.setPrev_(s,i),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),s}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==H.st_nullNode();){let t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let t=this.getFirstList();-1!==t;)t=this.deleteList(t)}isEmpty(t){return(0,r.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class W extends G{m_intervalTree;constructor(t){super(),this.m_intervalTree=t}compare(t,e,i){let s=t.getElement(i),r=this.m_intervalTree.getValue_(e),n=this.m_intervalTree.getValue_(s);return r<n?-1:r===n?j.isLeft_(e)&&j.isRight_(s)?-1:j.isLeft_(s)&&j.isRight_(e)?1:0:1}}class j{m_bEnvelopesRef=!1;m_bOfflineDynamic;m_intervals=[];m_envelopesRef=null;m_tertiaryNodes;m_intervalNodes=new z(3);m_intervalHandles=[];m_secondaryLists;m_secondaryTreaps;m_endIndicesUnique=[];m_cCount=-1;m_root=-1;m_bSortIntervals=!1;m_bConstructing=!1;m_bConstructionEnded=!1;constructor(t){this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new z(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new Z,this.m_secondaryTreaps.setComparator(new W(this)),this.m_secondaryLists=new H}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||(0,r.q)(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){(0,r.g)(0)}endConstruction(){this.m_bConstructing||(0,r.q)(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if((!this.m_bOfflineDynamic||!this.m_bConstructionEnded)&&(0,r.q)(""),-1===this.m_root){let t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){let e=new R(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}let e=this.insertIntervalEnd_(t<<1,this.m_root),i=this.getSecondaryFromInterval_(e),s=this.m_secondaryTreaps.addElement(1+(t<<1),i);this.setRightEnd_(e,s),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){(!this.m_bOfflineDynamic||!this.m_bConstructionEnded)&&(0,r.q)("");let e=this.m_intervalHandles[t];-1===e&&(0,r.a)("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let i,s=this.getSecondaryFromInterval_(e),n=-1;n=this.m_secondaryTreaps.getTreapData(s),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),s),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),s),i=this.m_secondaryTreaps.size(s),0===i&&(this.m_secondaryTreaps.deleteTreap(s),this.setSecondaryToTertiary_(n,-1)),this.m_intervalNodes.deleteElement(e);let o=this.getPptr_(n),a=this.getLptr_(n),l=this.getRptr_(n);for(;!(i>0||n===this.m_root||-1!==a&&-1!==l);)n===this.getLptr_(o)?-1===a?-1===l?(this.setLptr_(o,-1),this.setPptr_(n,-1)):(this.setLptr_(o,l),this.setPptr_(l,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setLptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1===a?-1===l?(this.setRptr_(o,-1),this.setPptr_(n,-1)):(this.setRptr_(o,l),this.setPptr_(l,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setRptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)),this.m_tertiaryNodes.deleteElement(n),n=o,s=this.getSecondaryFromTertiary_(n),i=-1===s?0:this.m_secondaryTreaps.size(s),a=this.getLptr_(n),l=this.getRptr_(n),o=this.getPptr_(n)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof s.E?new U(this,t,e):((0,r.g)(0),{})}getIterator(){return new U(this)}querySortedEndPointIndices_(t){let e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let i=0;i<2*e;i++)t.add(i);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=NaN;for(let i=0;i<t.size();i++){let s=t.read(i),r=this.getValue_(s);r!==e&&(this.m_endIndicesUnique.push(s),e=r)}}insertIntervalsStatic_(){let t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new R(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);let i=(0,s.d)(t,-1);this.m_root=this.createRoot_();for(let t=0;t<e.size();t++){let s=e.read(t),r=i[s>>1];if(-1!==r){let t=this.getSecondaryFromInterval_(r);this.setRightEnd_(r,this.m_secondaryLists.addElement(t,s))}else r=this.insertIntervalEnd_(s,this.m_root),i[s>>1]=r}}createRoot_(){let t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let i=-1,s=e,r=-1,n=-1,o=0,a=this.m_endIndicesUnique.length-1,l=0,h=t>>1,m=NaN,u=NaN,d=!0,g=this.getMin_(h),c=this.getMax_(h),_=-1;for(;d;){l=o+(a-o>>1),_=this.calculateDiscriminantIndex1_(o,a);let e=this.getDiscriminantFromIndex1_(_);if(c<e){if(-1!==s)if(_===this.getDiscriminantIndex1_(s))i=s,m=e,s=this.getLptr_(s),u=-1===s?NaN:this.getDiscriminant_(s);else if(u>e){let t=this.createTertiaryNode_(_);e<m?this.setLptr_(i,t):this.setRptr_(i,t),this.setRptr_(t,s),this.m_bOfflineDynamic&&(this.setPptr_(t,i),this.setPptr_(s,t)),i=t,m=e,s=-1,u=NaN}a=l;continue}if(g>e){if(-1!==s)if(_===this.getDiscriminantIndex1_(s))i=s,m=e,s=this.getRptr_(s),u=-1===s?NaN:this.getDiscriminant_(s);else if(u<e){let t=this.createTertiaryNode_(_);e<m?this.setLptr_(i,t):this.setRptr_(i,t),this.setLptr_(t,s),this.m_bOfflineDynamic&&(this.setPptr_(t,i),this.setPptr_(s,t)),i=t,m=e,s=-1,u=NaN}o=l+1;continue}let h=-1;h=-1===s||_!==this.getDiscriminantIndex1_(s)?this.createTertiaryNode_(_):s,r=this.getSecondaryFromTertiary_(h),-1===r&&(r=this.createSecondary_(h),this.setSecondaryToTertiary_(h,r));let p=this.addEndIndex_(r,t);n=this.createIntervalNode_(),this.setSecondaryToInterval_(n,r),this.setLeftEnd_(n,p),(-1===s||_!==this.getDiscriminantIndex1_(s))&&(e<m?this.setLptr_(i,h):this.setRptr_(i,h),this.m_bOfflineDynamic&&this.setPptr_(h,i),-1!==s&&(u<e?this.setLptr_(h,s):this.setRptr_(h,s),this.m_bOfflineDynamic&&this.setPptr_(s,h))),d=!1;break}return n}createTertiaryNode_(t){let e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){(!this.m_bOfflineDynamic||!this.m_bConstructionEnded)&&(0,r.q)(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){let e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return NaN;if(t>0){let e=t-2,i=this.m_endIndicesUnique[e],s=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(i)+this.getValue_(s))}let e=-t-2,i=this.m_endIndicesUnique[e];return this.getValue_(i)}calculateDiscriminantIndex1_(t,e){let i;return i=t<e?t+(e-t>>1)+2:-(t+2),i}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let i=-1;return i=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),i}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,i){let s=this;(new L).sort(t,e,i,{userSort(t,e,i){s.sortEndIndicesHelper_(i,t,e)},getValue:t=>s.getValue_(t)})}sortEndIndicesHelper_(t,e,i){t.sort(e,i,(t,e)=>{let i=this.getValue_(t),s=this.getValue_(e);return i<s||i===s&&j.isLeft_(t)&&j.isRight_(e)?-1:1})}getValue_(t){if(!this.m_bEnvelopesRef){let e=this.m_intervals[t>>1];return j.isLeft_(t)?e.vmin:e.vmax}let e=this.m_envelopesRef[t>>1];return j.isLeft_(t)?e.xmin:e.xmax}}class U{m_intervalTree;m_query=s.E.constructEmpty();m_tertiaryHandle=-1;m_nextTertiaryHandle=-1;m_forkedHandle=-1;m_currentEndHandle=-1;m_nextEndHandle=-1;m_tertiaryStack=[];m_functionIndex=0;m_functionStack;m_fi;constructor(t,e,i){this.m_intervalTree=t,this.m_functionStack=[,,],this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,i)}nullFunc_(){return(0,r.d)("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){let i=new s.E;i.setCoords(t,t),this.resetIterator(i,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||(0,r.q)(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1===this.m_currentEndHandle?-1:this.getCurrentEndIndex_()>>1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;let t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;let e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);let e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;let t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}let e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);let i=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==i&&this.m_tertiaryStack.push(i),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class O{m_tolerance=0;m_sweepIndexRed=-1;m_sweepIndexBlue=-1;m_envelopeHandleA=-1;m_envelopeHandleB=-1;m_intervalTreeRed=null;m_intervalTreeBlue=null;m_iteratorRed=null;m_iteratorBlue=null;m_envelopesRed=[];m_envelopesBlue=[];m_elementsRed=[];m_elementsBlue=[];m_sortedEndIndicesRed=new R(0);m_sortedEndIndicesBlue=new R(0);m_queuedListRed=-1;m_queuedListBlue=-1;m_queuedEnvelopes=new H;m_queuedIndicesRed=[];m_queuedIndicesBlue=[];m_bAddRed=!1;m_bAddBlue=!1;m_bAddRedRed=!1;m_bDone=!0;m_function;constructor(){this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new n.Envelope2D(e))}endConstruction(){this.m_bAddRedRed||(0,r.q)(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||(0,r.q)(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||(0,r.q)(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||(0,r.q)(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||=new j(!0),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||=new j(!0),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||=new j(!0),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),this.m_iteratorBlue??=this.m_intervalTreeBlue.getIterator(),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||=new j(!0),this.m_intervalTreeBlue||=new j(!0),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){let t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);let i=s.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(i,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){let t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),i=this.getAdjustedValue_(t,!0),s=this.getAdjustedValue_(e,!1);return i>s?this.sweepRed_():i<s?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){let t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){let e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;let i=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=i}}if(this.m_intervalTreeBlue.size()>0){let t=s.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&((0,s.x)(this.m_queuedIndicesRed,this.m_envelopesRed.length,-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){let t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){let e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;let i=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=i}}if(this.m_intervalTreeRed.size()>0){let t=s.E.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&((0,s.x)(this.m_queuedIndicesBlue,this.m_envelopesBlue.length,-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;let t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;let t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;let t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;let t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;let t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return(0,r.d)("should not be called"),!1}sortYEndIndices_(t,e,i,s){let r=this;(new L).sort(t,e,i,{userSort(t,e,i){r.sortYEndIndicesHelper_(i,t,e,s)},getValue:t=>r.getAdjustedValue_(t,s)})}sortYEndIndicesHelper_(t,e,i,s){t.sort(e,i,(t,e)=>{let i=this.getAdjustedValue_(t,s),r=this.getAdjustedValue_(e,s);return i<r||i===r&&this.isBottom_(t)&&this.isTop_(e)?-1:1})}getAdjustedValue_(t,e){let i=.5*this.m_tolerance;if(e){let e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-i:e.ymax+i}let s=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?s.ymin-i:s.ymax+i}}var Q=d;class K{tolerance;resolution;constructor(t,e){this.tolerance=void 0===t?NaN:t,this.resolution=void 0===e?NaN:e}add(t){return new K(this.tolerance+t,this.resolution)}scale(t){return new K(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function J(t,e,i,r,n){let o=r*r,a=t.sub(e),l=i.sub(e),h=a.sqrLength(),m=l.sqrLength();if(h<=o||m<=o)return!0;let u=(0,s.a)(a.crossProduct(l));return(u<=o*h||u<=o*m)&&a.dotProduct(l)>=0}function $(t,e,i){return s=>0===i?(s+t)*e:1*(s-t*e)/e}function tt(t,e){let i=new n.Envelope2D;return t.queryLooseEnvelope(i),i.mergeEnvelope2D(e),i}function et(t,e){let i=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(i);let s=n.Envelope2D.constructEmpty();return e.queryLooseEnvelope(s),i.mergeEnvelope2D(s),i}function it(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function st(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function rt(t,e,i){let s=n.Envelope2D.constructEmpty();return s.setFromPoints(t,e),ut(0,null,s.calculateToleranceFromEnvelope(),i,!1)}function nt(t,e,i){return ut(0,t,e.calculateToleranceFromEnvelope(),i,!1)}function ot(t,e,i){return ut(1,t,e.calculateToleranceFromEnvelope(),i,!1)}function at(t,e,i){return ot(t,e.queryInterval(1,0),i)}function lt(t,e,i){let s=n.Envelope2D.constructEmpty();return e.queryEnvelope(s),nt(t,s,i)}function ht(t,e,i=!1){return ut(0,t,e.calculateToleranceFromEnvelope(),i,!0).total()}function mt(t,e,i){let s=n.Envelope2D.constructEmpty();return e.queryEnvelope(s),ht(t,s,i)}function ut(t,e,i,s,r){let n=new K(0,0);return null!==e&&(n.tolerance=e.getTolerance(t),(!r||s)&&null!==e&&(n.resolution=e.getResolution(t),s&&(n.resolution*=2))),s&&(i*=4,n.tolerance*=1.01,n.resolution*=1.01),n.total()<i?new K(i,0):n}function dt(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function gt(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function ct(t){return t>=3}function _t(t,e){return t.getImpl().getIsSimple(e,[0])>=3}function pt(t,e){t.getImpl().setIsSimple(3,e)}function ft(t,e,i,r){if((0,s.a)(e.x-t.x)+(0,s.a)(e.y-t.y)<=i*i){let i=t.z,n=e.z;return(0,s.a8)(i,n,r)}return!1}function yt(t){return t>=4}function Pt(t,e){return t===r.G.enumPolygon?ct(e):e>=1}function xt(t,e,i){let s=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(s),e.queryLooseEnvelope(r),s.inflateCoords(i,i),r.inflateCoords(i,i);let o=n.Envelope2D.constructEmpty();o.setCoords({env2D:s}),o.intersect(r);let a=t.querySegmentIterator(),l=e.querySegmentIterator(),h=n.Envelope2D.constructEmpty(),m=n.Envelope2D.constructEmpty(),u=new O;u.setTolerance(i);let d=!1;for(u.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(h),h.isIntersecting(o)&&(d=!0,u.addRedEnvelope(a.getStartPointIndex(),h));if(u.endRedConstruction(),!d)return null;let g=!1;for(u.startBlueConstruction();l.nextPath();)for(;l.hasNextSegment();)l.nextSegment().queryLooseEnvelope(m),m.isIntersecting(o)&&(g=!0,u.addBlueEnvelope(l.getStartPointIndex(),m));return u.endBlueConstruction(),g?u:null}function vt(t,e,i,s,r){t.getGeometryType(),e.getGeometryType();let o=n.Envelope2D.constructEmpty(),a=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(o),e.queryLooseEnvelope(a),o.inflateCoords(i,i),a.inflateCoords(i,i);let l=n.Envelope2D.constructEmpty();l.setCoords({env2D:o}),l.intersect(a);let h=new O;h.setTolerance(i);let m=!1;h.startRedConstruction();for(let e=0,i=t.getPathCount();e<i;e++)t.queryLoosePathEnvelope(e,o),o.isIntersecting(l)&&(m=!0,h.addRedEnvelope(e,o));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let t=0,i=e.getPathCount();t<i;t++)e.queryLoosePathEnvelope(t,a),a.isIntersecting(l)&&(u=!0,h.addBlueEnvelope(t,a));return h.endBlueConstruction(),u?h:null}function Ct(t,e,i){let s=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(s),e.queryEnvelope(r),s.inflateCoords(i,i),r.inflateCoords(i,i);let o=n.Envelope2D.constructEmpty();o.setCoords({env2D:s}),o.intersect(r);let a=t.querySegmentIterator(),l=new O;l.setTolerance(i);let h=!1;for(l.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(s),s.isIntersecting(o)&&(h=!0,l.addRedEnvelope(a.getStartPointIndex(),s));if(l.endRedConstruction(),!h)return null;let m=!1;l.startBlueConstruction();for(let t=0,i=e.getPointCount();t<i;t++){let i=e.getXY(t);o.contains(i)&&(m=!0,l.addBlueEnvelope(t,n.Envelope2D.construct(i.x,i.y,i.x,i.y)))}return l.endBlueConstruction(),m?l:null}function Et(t,e,i){let r=n.Envelope2D.constructEmpty(),o=n.Envelope2D.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(i,i),o.inflateCoords(i,i);let a=n.Envelope2D.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);let l=new O;l.setTolerance(i);let h=!1;l.startRedConstruction();let m=new s.P;for(let e=0,i=t.getPointCount();e<i;e++)t.queryXY(e,m),a.contains(m)&&(h=!0,l.addRedEnvelope(e,n.Envelope2D.construct(m.x,m.y,m.x,m.y)));if(l.endRedConstruction(),!h)return null;let u=!1;l.startBlueConstruction();let d=new s.P;for(let t=0,i=e.getPointCount();t<i;t++)e.queryXY(t,d),a.contains(d)&&(u=!0,l.addBlueEnvelope(t,n.Envelope2D.construct(d.x,d.y,d.x,d.y)));return l.endBlueConstruction(),u?l:null}function bt(t){let e=new n.Envelope2D;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),function(t,e){let i=new n.Envelope2D;if(t.queryLooseEnvelope(i),i.isEmpty())return null;t.getGeometryType();let s=new V(i,8),o=-1,a=new n.Envelope2D,l=!1;do{for(let n=0,h=t.getPathCount();n<h;n++)if(t.queryLoosePathEnvelope(n,a),a.isIntersecting(e)){if(o=s.insertEx(n,a,o),-1===o){l&&(0,r.d)("build_quad_tree_for_paths"),i.assign(t.calculateEnvelope2D(!1)),l=!0,s.reset(i,8);break}l=!1}}while(l);return s}(t,e)}function Dt(t,e){if(!e){let e=new n.Envelope2D;t.queryLooseEnvelope(e);let i=new V(e,8),s=-1,o=new n.Envelope2D,a=t.querySegmentIterator(),l=!1;for(;a.nextPath();)for(;a.hasNextSegment();){let n=a.nextSegment(),h=a.getStartPointIndex();if(n.queryLooseEnvelope(o),s=i.insertEx(h,o,s),-1===s){l&&(0,r.d)(""),e.assign(t.calculateEnvelope2D(!1)),l=!0,i.reset(e,8),a.resetToFirstPath();break}}return i}let i=new n.Envelope2D;t.queryLooseEnvelope(i);let s=new V(i,8),o=-1,a=new n.Envelope2D,l=t.querySegmentIterator(),h=!1;for(;l.nextPath();)for(;l.hasNextSegment();){let n=l.nextSegment(),m=l.getStartPointIndex();if(n.queryLooseEnvelope(a),a.isIntersecting(e)&&(o=s.insertEx(m,a,o),-1===o)){h&&(0,r.d)(""),i.assign(t.calculateEnvelope2D(!1)),h=!0,s.reset(i,8),l.resetToFirstPath();break}}return s}function wt(t,e){if(e){let i=new V(e,8),o=new s.P,a=new n.Envelope2D,l=!1;for(let s=0;s<t.getPointCount();s++)if(o.setCoordsPoint2D(t.getXY(s)),e.contains(o)&&(a.setCoords({pt:o}),-1===i.insert(s,a))){l&&(0,r.d)(""),l=!0,i.reset(t.calculateEnvelope2D(),8),s=-1;continue}return i}return(0,r.t)("no-extent version not yet impl"),null}function St(t,e,i,s,r){let n=!1,o=r.vmin,a=r.vmax;for(let r=i;r<e;r+=s){let e=t.read(r);e<o?(n=!0,t.write(r,o)):e>a&&(n=!0,t.write(r,a))}return n}function At(t,e,i,s){if(!t.hasAttribute(i))return!1;let n=t.getGeometryType();if(n===r.G.enumGeometryCollection){let r=t,n=r.getGeometryCount(),o=0;for(let t=0;t<n;++t)o|=+!!At(r.getGeometry(t),e,i,s);return!!o}if((0,r.i)(n)){let n=t,o=Q.getPersistence(i),a=Q.getComponentCount(i),l=n.getPointCount();if(1===o){let t=St(n.getAttributeStreamRef(i),l*a,s,a,e);return t&&n.notifyModified(),t}if(2===o){let t=St(n.getAttributeStreamRef(i),l*a,s,a,e);return t&&n.notifyModified(),t}(0,r.d)("snap_coordinate not implemented")}if(n===r.G.enumEnvelope){let r=t,n=r.queryInterval(i,s),o=!1;return n.vmin<e.vmin&&(o=!0,n.vmin=e.vmin),n.vmax>e.vmax&&(o=!0,n.vmax=e.vmax),o&&r.setIntervalEnvelope(i,s,n),o}if(n===r.G.enumPoint){let r=t,n=r.getAttributeAsDbl(i,s),o=!1;return n<e.vmin&&(o=!0,n=e.vmin),n>e.vmax&&(o=!0,n=e.vmax),o&&r.setAttributeBasic(i,s,n),o}if((0,r.h)(n)){let r=t,n=r.getStartAttributeAsDbl(i,s),o=!1;return n<e.vmin&&(o=!0,n=e.vmin),n>e.vmax&&(o=!0,n=e.vmax),o&&r.setStartAttribute(i,s,n),n=r.getEndAttributeAsDbl(i,s),n<e.vmin&&(o=!0,n=e.vmin),n>e.vmax&&(o=!0,n=e.vmax),o&&r.setEndAttribute(i,s,n),o}(0,r.d)("snap_coordinate not implemented")}var Tt=d;class It{static type=r.G.enumPoint;m_description=null;x=NaN;y=NaN;m_attribs=null;constructor(t){if(t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=x(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=v(),this.ensureAttributes(),this.setXYZ(new E(t.x,t.y,t.z))):(this.m_description=x(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=x()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new s.P(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){let t=new E;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:Tt.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}isEqualXYCoords(t,e,i){return void 0===i&&(i=0),Math.abs(t-this.x)<=i&&Math.abs(e-this.y)<=i}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;(0,r.r)("")}let i=Tt.getComponentCount(t);(e<0||e>=i)&&(0,r.r)("");let s=this.m_description.getAttributeIndex(t);return s>=0?this.m_attribs[this.m_description.getPointAttributeOffset(s)-2+e]:Tt.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,i){if(0===t)return void(0===e?this.x=i:1===e?this.y=i:(0,r.r)(""));let s=Tt.getComponentCount(t);(e<0||e>=s)&&(0,r.r)("");let n=this.m_description.getAttributeIndex(t);n<0&&(this.addAttribute(t),n=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]=i}copyAttributesFrom(t,e){if(this===t)return;let i=t.getDescription(),s=e&&i.hasZ()?2:1;for(let e=s,r=i.getAttributeCount();e<r;++e){let s=i.getSemantics(e),r=Tt.getComponentCount(s);for(let e=0;e<r;++e){let i=t.getAttributeAsDbl(s,e);this.setAttributeBasic(s,e,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(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;let e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=P(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=x();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return r.G.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof Rt)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof b){if(this.isEmpty())return void t.setEmpty();let e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){let i=new s.E;if(this.isEmpty())return i.setEmpty(),i;let r=this.getAttributeAsDbl(t,e);return i.vmin=r,i.vmax=r,i}applyTransformation(t){if(!this.isEmpty()){if(1===t.m_TransformationType){let e=this.getXY();return t.transformInPlace(e),void this.setXY(e)}(0,r.t)("3d not impl")}}transformAttribute(t,e,i,s,r){if(this.isEmpty())return;this.addAttribute(t);let n=this.getAttributeAsDbl(t,e),o=$(i,s,r);this.setAttributeBasic(t,e,o(n))}createInstance(){return new It({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)();let e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=x(),this.releaseAttributes()),this.x=NaN,this.y=NaN,this.m_attribs&&(0,s.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==r.G.enumPoint)return!1;let i=t;if(this.m_description!==i.m_description||this.isEmpty()!==i.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-i.x)>e||Math.abs(this.y-i.y)>e)return!1;for(let t=0,r=this.m_description.getTotalComponentCount()-2;t<r;t++)if(!(0,s.a8)(this.m_attribs[t],i.m_attribs[t],e))return!1;return!0}getBoundary(){return null}clone(){let t=new It({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.a)("wrong geometry type");let e=t;e.m_description=(0,s.c)(this.m_description,this.m_description=e.m_description),e.x=(0,s.c)(this.x,this.x=e.x),e.y=(0,s.c)(this.y,this.y=e.y),e.m_attribs=(0,s.c)(this.m_attribs,this.m_attribs=e.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=Tt.getComponentCount(t);for(let s=0;s<i;s++){let i=this.getAttributeAsDbl(t,s);Number.isNaN(i)&&this.setAttributeBasic(t,s,e)}}lerp(t,e,i){if(t.getDescription()!==e.getDescription()&&(0,r.a)("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||e.isEmpty())return this.setEmpty(),this;this.ensureAttributes();let n=u();t.queryValues(n,n.length);let o=u();e.queryValues(o,o.length);let a=u(),l=n,h=o,m=a,d=0;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),r=Tt.getInterpolation(e),n=Tt.getComponentCount(e),o=Tt.getDefaultValue(e);(0,s.a4)(r,l,h,m,d,n,i,o),l=l.slice(n),h=h.slice(n),d+=n}return this.setValues(a,d),this}static lerp(t,e,i,s){s.lerp(t,e,i)}setDefaultAttributeValues(){let t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?(0,s.b)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return s.P.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){let e=f(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||=x();let e=c();C(t,this.m_description,e);let i=null;t.getTotalComponentCount()-2>0&&(i=t.getDefaultPointAttributes().slice(2));for(let s=1,r=t.getAttributeCount();s<r;s++){let r=e[s];if(-1!==r){let e=this.m_description.getPointAttributeOffset(r)-2,n=t.getPointAttributeOffset(s)-2,o=Tt.getComponentCount(t.getSemantics(s));for(let t=0;t<o;t++)i[n+t]=this.m_attribs[e+t]}}this.m_attribs=i,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){let i=this.m_description.getTotalComponentCount();(0,r.g)(i<=e),t[0]=this.x,t[1]=this.y,(0,s.b)(t,this.m_attribs,2,0,i-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;let e=t.getDescription();if(e===this.m_description)this.m_attribs&&(0,s.b)(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let i=0;for(let s=1,r=e.getAttributeCount();s<r;s++){let r=e.getSemantics(s),n=Tt.getComponentCount(r);if(this.m_description.hasAttribute(r)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(r))-2;for(;0!==n;)t.m_attribs[i++]=this.m_attribs[e++],n--}else{let e=Tt.getDefaultValue(r);for(;0!==n;)t.m_attribs[i++]=e,n--}}}}setValues(t,e){let i=this.m_description.getTotalComponentCount();(0,r.g)(i<=e),this.x=t[0],this.y=t[1],(0,s.b)(this.m_attribs,t,0,2,i-2)}dbgDefaultAttribs(){}toFlatGeometry(){let t=Float64Array.of(this.getX(),this.getY(),this.getZ(),this.getM());return{type:"point",vertexCount:1,vertexXY:t.subarray(0,2),vertexZ:this.hasAttribute(1)?t.subarray(2,3):void 0,vertexM:this.hasAttribute(2)?t.subarray(3,4):void 0,...F}}}var Mt=d;function qt(t,e){return e*(t.getTotalComponentCount()-2)}class Nt{m_envelope2D;m_attributes;constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new n.Envelope2D(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new n.Envelope2D(t.env2D);else if(t.move)this.m_envelope2D=new n.Envelope2D(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw Error("unrecognized EnvelopeData constructor options");{let e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new n.Envelope2D(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=n.Envelope2D.constructEmpty()}ensureAttributes(t){let e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=(0,s.d)(2*e,NaN),this.m_attributes.fill(NaN))}copyTo(t,e){let i=e,o=t.getTotalComponentCount()-2;if(i.m_description!==t&&(i.releaseAttributes_(),i.m_description=t,o&&(i.m_data.m_attributes=(0,s.d)(2*o,NaN))),o){(0,r.g)(this.m_attributes&&i.m_data.m_attributes);let t=2*o;(0,s.b)(i.m_data.m_attributes,this.m_attributes,0,0,t)}i.m_data.m_envelope2D=new n.Envelope2D(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new n.Envelope2D(this.m_envelope2D),e.releaseAttributes(),t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}transformAttribute(t,e,i,s,n){(0,r.g)(0)}queryInterval(t,e,i,s){if(this.isEmpty())return void s.setEmpty();if(0===e)return void(0===i?this.m_envelope2D.queryIntervalX(s):1===i?this.m_envelope2D.queryIntervalY(s):(0,r.r)(""));let n=Mt.getComponentCount(e);(i<0||i>=n)&&(0,r.r)("");let o=t.getAttributeIndex(e);if(o>=0)return s.vmin=this.m_attributes[qt(t,0)+t.getPointAttributeOffset(o)-2+i],void(s.vmax=this.m_attributes[qt(t,1)+t.getPointAttributeOffset(o)-2+i]);{let t=Mt.getDefaultValue(e);return void s.setCoords(t,t)}}queryEnvelope3D(t,e){let i=new s.E;this.queryInterval(t,1,0,i),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,i.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,i.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();let e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=(0,s.d)(2*e,NaN),this.m_attributes.fill(NaN))}dbgAssertSize(t){}}let Rt=class t{static type=r.G.enumEnvelope;m_EnvelopeType=4;m_description;m_data;constructor(t){if(this.m_description=x(),void 0===t)this.m_data=new Nt;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Nt,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Nt({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Nt({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new Nt,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new Nt({move:t.move.m_data});else{if(!t.centerPoint)throw Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new Nt,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new Nt({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,i,s,n){(0,r.g)(0)}setAttributeBasic(t,e,i){if(this.addAttribute(t),this.m_data.isEmpty())return;let s=this.queryInterval(t,e);s.vmin=i,s.vmax=i,this.setIntervalEnvelope(t,e,s)}mergeVertexDescriptionImpl(t){let e=f(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new n.Envelope2D(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return r.G.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?NaN:this.m_data.m_envelope2D.height()}getCenterXY(){return this.m_data.isEmpty()?new s.P:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();let e=this.m_description.getAttributeCount();for(let i=1;i<e;i++){let e=this.m_description.getSemantics(i),s=Mt.getComponentCount(e);for(let i=0;i<s;i++){let s=.5*(this.getAttributeAsDblImpl(0,e,i)+this.getAttributeAsDblImpl(1,e,i));t.setAttributeBasic(e,i,s)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,i,s){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:i,ymax:s})}setEnvelope(t){if(t instanceof n.Envelope2D)this.m_data.m_envelope2D=new n.Envelope2D(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();let e=s.E.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){if(e instanceof n.Envelope2D)return e.isValid()||(0,r.a)(""),void this.m_data.m_envelope2D.mergeEnvelope2D(e);if(e instanceof t){if(e.m_data.isEmpty())return;let t=e.getDescription();this.mergeVertexDescription(t),this.m_data.m_envelope2D.mergeEnvelope2D(e.m_data.m_envelope2D);for(let i=1,s=t.getAttributeCount();i<s;i++){let s=t.getSemantics(i),r=Mt.getComponentCount(s);for(let t=0;t<r;t++){let i=e.queryInterval(s,t),r=this.queryInterval(s,t);r.merge(i),this.setIntervalEnvelope(s,t,r)}}return}if(e instanceof It){let t=e;if(t.isEmpty())return;let i=t.getDescription();if(this.mergeVertexDescription(i),this.m_data.isEmpty())return void this.setFromPoint(t);this.m_data.m_envelope2D.merge(t.getXY());for(let e=1,s=i.getAttributeCount();e<s;e++){let s=i.getSemantics(e),r=Mt.getComponentCount(s);for(let e=0;e<r;e++){let i=t.getAttributeAsDbl(s,e),r=this.queryInterval(s,e);r.mergeCoordinate(i),this.setIntervalEnvelope(s,e,r)}}return}(0,r.t)("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;let e=t.getDescription();this.mergeVertexDescription(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e),s=Mt.getComponentCount(i);for(let e=0;e<s;e++){let s=t.queryInterval(i,e),r=this.queryInterval(i,e);r.intersect(s),this.setIntervalEnvelope(i,e,r)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;let e=t.getDescription();for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i);if(!e.hasAttribute(s))continue;let r=Mt.getComponentCount(s);for(let e=0;e<r;e++){let i=t.queryInterval(s,e),r=this.queryInterval(s,e);r.intersect(i),this.setIntervalEnvelope(s,e,r)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,i){if(this.addAttribute(t),this.m_data.isEmpty())return;let n=new s.E(i);if(n.normalize(),0===t){if(n.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=n.vmin,this.m_data.m_envelope2D.xmax=n.vmax):1===e?(this.m_data.m_envelope2D.ymin=n.vmin,this.m_data.m_envelope2D.ymax=n.vmax):(0,r.r)("")}else this.setAttributeAsDblImpl(0,t,e,n.vmin),this.setAttributeAsDblImpl(1,t,e,n.vmax)}setInterval(t,e,i,r){this.setIntervalEnvelope(t,e,new s.E(i,r))}queryInterval(t,e){let i=new s.E;return this.m_data.queryInterval(this.m_description,t,e,i),i}queryEnvelope(t){2!==t.m_EnvelopeType?3!==t.m_EnvelopeType?4!==t.m_EnvelopeType?(0,r.t)("unrecognized type for queryEnveloper"):this.copyTo(t):this.m_data.queryEnvelope3D(this.m_description,t):t.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?(0,r.g)(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new t({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||=x(),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return(0,r.g)(0),0}equals(t,e){if(t===this)return!0;let i=t;if(this.m_description!==i.m_description||this.m_data.isEmpty()!==i.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-i.m_data.m_envelope2D.xmin)>e||Math.abs(this.m_data.m_envelope2D.ymin-i.m_data.m_envelope2D.ymin)>e||Math.abs(this.m_data.m_envelope2D.xmax-i.m_data.m_envelope2D.xmax)>e||Math.abs(this.m_data.m_envelope2D.ymax-i.m_data.m_envelope2D.ymax)>e)return!1;for(let t=0,r=2*(this.m_description.getTotalComponentCount()-2);t<r;t++)if(!(0,s.a8)(this.m_data.m_attributes[t],i.m_data.m_attributes[t],e))return!1;return!0}getBoundary(){return(0,r.t)("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new t({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumEnvelope&&(0,r.a)("wrong geometry type");let e=t;e.m_description=(0,s.c)(this.m_description,this.m_description=e.m_description),e.m_data.m_envelope2D=(0,s.c)(this.m_data.m_envelope2D,this.m_data.m_envelope2D=e.m_data.m_envelope2D),e.m_data.m_attributes=(0,s.c)(this.m_data.m_attributes,this.m_data.m_attributes=e.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&(0,r.a)(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&(0,r.r)(""),e.assignVertexDescription(this.m_description);let i=this.getDescription().getAttributeCount();for(let s=1;s<i;s++){let i=this.m_description.getSemantics(s),r=Mt.getComponentCount(i);for(let s=0;s<r;s++)e.setAttributeBasic(i,s,this.getAttributeAsDblImpl(t%2,i,s))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&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;let e=y(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=P(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=x();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;let i=Mt.getComponentCount(t);for(let s=0;s<i;s++){let i=this.queryInterval(t,s);i.isEmpty()&&(i.vmin=e,i.vmax=e,this.setIntervalEnvelope(t,s,i))}}getImpl(){return this}setFromPoint(t,e,i){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:i??0});let s=t.getDescription();for(let e=1,i=s.getAttributeCount();e<i;e++){let i=s.getSemantics(e),r=Mt.getComponentCount(i);for(let e=0;e<r;e++){let s=t.getAttributeAsDbl(i,e);this.setInterval(i,e,s,s)}}}assignVertexDescriptionImpl(t){let e=c();C(t,this.m_description,e);let i=null,r=t.getTotalComponentCount()-2,n=this.m_description?this.m_description.getTotalComponentCount()-2:0;r>0&&(i=(0,s.d)(2*r,NaN));for(let o=1;o<t.getAttributeCount();o++){let a=e[o];if(-1!==a){let e=t.getPointAttributeOffset(o)-2,l=Mt.getComponentCount(t.getSemantics(o)),h=this.m_description.getPointAttributeOffset(a)-2;(0,s.b)(i,this.m_data.m_attributes,e,h,l),(0,s.b)(i,this.m_data.m_attributes,r+e,n+h,l)}}this.releaseAttributes_(),this.m_data.m_attributes=i,this.m_description=t}getAttributeAsDblImpl(t,e,i){if(this.m_data.isEmpty()&&(0,r.C)(""),0===e)return t?i?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:i?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;i>=Mt.getComponentCount(e)&&(0,r.r)("");let s=this.m_description.getAttributeIndex(e);return s>=0?this.m_data.m_attributes[qt(this.m_description,t)+this.m_description.getPointAttributeOffset(s)-2+i]:d.getDefaultValue(e)}setAttributeAsDblImpl(t,e,i,s){0===e&&(t?1===i?this.m_data.m_envelope2D.ymax=s:0===i?this.m_data.m_envelope2D.xmax=s:(0,r.r)(""):1===i?this.m_data.m_envelope2D.ymin=s:0===i?this.m_data.m_envelope2D.xmin=s:(0,r.r)(""));let n=Mt.getComponentCount(e);(i<0||i>=n)&&(0,r.r)(""),this.addAttribute(e);let o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[qt(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+i]=s}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}};Object.freeze(Object.defineProperty({__proto__:null,Envelope:Rt,EnvelopeData:Nt},Symbol.toStringTag,{value:"Module"})),i.d(e,["G",0,-559038737,"_",0,F])},88885(t,e,i){i.d(e,{$:()=>Sn,A:()=>St,B:()=>Dn,C:()=>pi,D:()=>qr,E:()=>mi,F:()=>Ir,H:()=>Mr,I:()=>vs,J:()=>dr,K:()=>cn,L:()=>Yn,M:()=>_,N:()=>W,O:()=>S,P:()=>ni,Q:()=>Ut,R:()=>m,S:()=>Xn,T:()=>wn,U:()=>B,V:()=>li,W:()=>Tn,X:()=>rt,Y:()=>C,Z:()=>x,_:()=>Zr,a:()=>Dt,a0:()=>An,a1:()=>qn,a2:()=>hi,a3:()=>wr,a4:()=>Er,a5:()=>hn,a6:()=>mn,a7:()=>en,a8:()=>Lr,a9:()=>yt,b:()=>Cr,c:()=>At,d:()=>Tr,e:()=>ci,f:()=>ui,g:()=>O,i:()=>gi,l:()=>Ar,s:()=>u,x:()=>fe,y:()=>ct,z:()=>_t});var s=i(55537),r=i(95213),n=i(83661),o=i(79187),a=i(11878),l=i(61691);class h{posStream=null;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=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 m(t,e,i){if(t)for(let t=e.length-1;t>=0;--t)i(e[t]);else e.forEach(i)}function u(t,e){let i=(0,n.Q)(t),s=e.length/(0,n.i)();for(let t=0;t<e.length;++t){let t=Math.trunc(i*s);i=(0,n.Q)(i);let r=Math.trunc(i*s),o=e[t];e[t]=e[r],e[r]=o}}var d=r.V;const g="can not assign an empty point to a vertex";class c{constructor(t){if(void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=(0,r.K)(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new h,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new r.L,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{let e=void 0!==t&&t.vd?t.vd:(0,r.K)();this.m_description=e,this.m_vertexAttributes=new h,this.m_envelopeData=new r.L,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!(0,s.i)(t.getGeometryType()))return!1;let i=t;if(this===i)return!0;if(!this.m_description.equals(i.getDescription())||this.isEmptyImpl()!==i.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;let r=this.getPointCount();if(r!==i.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){let s=this.m_description.getSemantics(t),n=this.getAttributeStreamRef(s),o=i.getAttributeStreamRef(s),a=d.getComponentCount(s);if(!n.equals(o,0,r*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,i,n,o){if(this.addAttribute(t),!this.isEmpty()&&(0!==i||1!==n)){if(0===t){let t=new a.T;return 0===o?0===e?(t.setShiftCoords(i,0),t.scale(n,1)):1===e?(t.setShiftCoords(0,i),t.scale(1,n)):(0,s.a)(""):0===e?(t.setScaleCoords(1/n,1),t.shiftCoords(-i,0)):1===e?(t.setScaleCoords(1,1/n),t.shiftCoords(0,-i)):(0,s.a)(""),void this.applyTransformation(t)}(function(t,e,i,r,n){(e<0||i<0||r<1||e+r*(i-1)+1>t.size())&&(0,s.a)("Index out of bound");for(let s=e,o=e+r*(i-1)+1;s<o;s+=r)t.writeAsDbl(s,n(t.readAsDbl(s)))})(this.getAttributeStreamRef(t),e,this.getPointCount(),d.getComponentCount(t),(0,r.Z)(i,n,o)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.M)(e,t);this.assignVertexDescription(i)}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;let e=(0,r.N)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.O)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.K)();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,s.a)("AttributeStream : Geometry does not have the attribute");let e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,s.a)("stream"),e&&d.getPersistence(t)!==e.getPersistence()&&(0,s.a)(""),this.addAttribute(t);let i=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(i,e),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){let i=e;i.assignVertexDescription(this.m_description);for(let e=0;e<this.m_description.getAttributeCount();e++){let s=this.m_description.getSemantics(e);for(let r=0,n=d.getComponentCount(s);r<n;r++){let o=this.m_vertexAttributes.get(e).readAsDbl(n*t+r);i.setAttributeBasic(s,r,o)}}}setPointByValNoCurves(t,e){let i=e;i.isEmpty()&&(0,s.a)(g);let r=i.getDescription();r!==this.m_description&&this.mergeVertexDescription(r);let n=this.m_vertexAttributes.get(0);n.write(2*t,i.getX()),n.write(2*t+1,i.getY());for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){let s=this.m_description.getSemantics(e),r=d.getComponentCount(s);for(let n=0;n<r;n++){let o=i.getAttributeAsDbl(s,n);this.m_vertexAttributes.get(e).writeAsDbl(t*r+n,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,i,r){(0,s.g)(0)}getPointByValAsArray(t,e,i,r){(0,s.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,i){let r=d.getComponentCount(t);i>=r&&(0,s.r)("");let n=this.m_description.getAttributeIndex(t);return n>=0?this.m_vertexAttributes.get(n).readAsDbl(e*r+i):d.getDefaultValue(t)}queryAttributeAsDbl(t,e,i,r){let n=d.getComponentCount(t);r<n&&(0,s.r)("");let o=this.m_description.getAttributeIndex(t);if(o>=0){let t=e*n,s=this.m_vertexAttributes.get(o);for(let e=0;e<n;e++)i[e]=s.readAsDbl(t+e)}else{let e=d.getDefaultValue(t);for(let t=0;t<n;t++)i[t]=e}}getAttributeAsInt(t,e,i){return Math.trunc(this.getAttributeAsDbl(t,e,i))}queryAttributeAsInt(t,e,i,r){(0,s.g)(0)}setAttributeNoCurves(t,e,i,r){let n=d.getComponentCount(t);i>=n&&(0,s.r)(""),this.addAttribute(t);let o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*n+i,r)}setAttributeFromArrayNoCurves(t,e,i,r){(e<0||e>=this.m_pointCount)&&(0,s.r)("");let n=d.getComponentCount(t);r<n&&(0,s.r)(""),this.addAttribute(t);let o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);let a=this.m_vertexAttributes.get(o);for(let t=0;t<n;++t)a.writeAsDbl(e*n+t,i[t])}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,i){let s=this.m_vertexAttributes.get(0);s.write(2*t,e),s.write(2*t+1,i),this.notifyModifiedFlags(2001)}getXYZ(t){let e=this.m_vertexAttributes.get(0),i=r.k.getNAN();return i.x=e.read(2*t),i.y=e.read(2*t+1),i.z=this.m_description.hasAttribute(1)?this.m_vertexAttributes.get(1).read(t):d.getDefaultValue(1),i}setXYZNoCurves(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);let i=this.m_vertexAttributes.get(0);i.write(2*t,e.x),i.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o.Envelope2D||t instanceof r.r?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){let i=n.E.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,i)),i}setAttributeBasic(t,e,i){this.setAttributeImpl(t,e,i)}setAttributeImpl(t,e,i){if(this.addAttribute(t),this.isEmpty())return;let s=!1,r=d.getComponentCount(t),n=this.getAttributeStreamRef(t),o=Number.isNaN(i);if(1===n.getPersistence()){let t=n;for(let n=e,a=this.m_pointCount*r;n<a;n+=r){let e=t.read(n);(!o&&e!==i||!Number.isNaN(e))&&(t.write(n,i),s=!0)}}else for(let t=e,o=this.m_pointCount*r;t<o;t+=r)n.readAsDbl(t)!==i&&(n.writeAsDbl(t,i),s=!0);s&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=!1,s=d.getComponentCount(t),r=this.getAttributeStreamRef(t);for(let t=0;t<s;t++)if(1===r.getPersistence()){let t=r;for(let r=0,n=this.m_pointCount*s;r<n;r++){let s=t.read(r);Number.isNaN(s)&&(t.write(r,e),i=!0)}}else for(let t=0,n=this.m_pointCount*s;t<n;t++){let s=r.readAsDbl(t);Number.isNaN(s)&&(r.writeAsDbl(t,e),i=!0)}i&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,s.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||(0,s.a)(""),this.m_envelopeData=new r.L({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,s.a)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,i,r){let n=r<0?this.m_pointCount:r;if(n=Math.min(n,i+e),(i<0||n<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.a)(""),0===this.m_pointCount)return n;let o=this.getAttributeStreamRef(0);for(let e=2*i,s=2*n,r=0;e<s;e+=2,r++)o.queryPoint2D(e,t[r]);return n}queryCoordinates3D(t,e,i,r){let n=r<0?this.m_pointCount:r;if(n=Math.min(n,i+e),(i<0||n<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.a)(""),0===this.m_pointCount)return n;let o=this.getAttributeStreamRef(0),a=null,l=d.getDefaultValue(1),h=this.m_description.hasAttribute(1);h&&(a=this.getAttributeStreamRef(1));let m=0;for(let e=i;e<n;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=h?a.read(e):l;return n}clearAndSetDirtyFlagProtected(t,e){let i=0,s=t&~e,r=e|s;i=this.m_flags,(i&r)!==e&&(this.m_flags=i&~s|e)}getIsSimple(t,e){e[0]=0;let i=-1,s=this.m_flags,r=this.m_simpleTolerance;return 1&s||(i=(14&s)>>1,e[0]=r,r<t&&(i=-1)),i}setIsSimple(t,e,i=!1){if(2===t?(0,s.g)(this.getGeometryType()===s.G.enumPolyline):1===t?(0,s.g)(this.getGeometryType()===s.G.enumMultiPoint||this.getGeometryType()===s.G.enumPolyline):3===t&&(0,s.g)(this.getGeometryType()===s.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;i||(s|=16),this.clearAndSetDirtyFlagProtected(31,s),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();let 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)&&(0,s.B)("Cannot do shallow clone on unprepared geometry");let i=t,r=this.getGeometryType(),n=i.getGeometryType();(0,s.g)(r===n||r===s.G.enumPolygon&&n===s.G.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();let o=this.m_description.getAttributeCount(),a=new h;if(!this.m_vertexAttributes.empty()){a.destroyAndSetSize(o);for(let t=0;t<o;t++)if(this.m_vertexAttributes.get(t))if(e)a.set(t,this.m_vertexAttributes.get(t));else{let e=d.getComponentCount(this.m_description.getSemantics(t));a.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,r!==n){let t=[NaN];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(a),a.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)||i.m_vertexAttributes.empty()?((0,s.g)(!e||0===i.m_pointCount),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,e)}catch(t){throw i.setEmpty(),t}i.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){let t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,i,o){(t<0||t>=this.m_pointCount)&&(0,s.r)(""),(e<0||e>=this.m_pointCount)&&(0,s.r)(""),o.assignVertexDescription(this.m_description);let a=(0,n.d)(d.maxComponentCount(),NaN),l=(0,n.d)(d.maxComponentCount(),NaN),h=(0,r.Q)(),m=0;for(let r=0;r<this.m_description.getAttributeCount();r++){let o=this.m_description.getSemantics(r),u=d.getInterpolation(o),g=d.getComponentCount(o),c=d.getDefaultValue(o);this.queryAttributeAsDbl(o,t,a,g),this.queryAttributeAsDbl(o,e,l,g),(0,s.g)(m+g<=25),(0,n.a4)(u,a,l,h,m,g,i,c),m+=g}!function(t,e){let i=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),(0,n.b)(t.getAttributeArray(),e,0,2,i-2)}(o,h)}getShortestDistance(t,e){return n.P.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return n.P.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&(0,s.a)(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;let e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}m_description;m_vertexAttributes;m_envelopeData;m_pointCount;m_reservedPointCount;m_flags;m_bFillRule;m_bPathStarted;m_bPolygon;m_simpleTolerance;m_accelerators=null;assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){let e=(0,r.R)();(0,r.U)(t,this.m_description,e);let i=new h;i.destroyAndSetSize(t.getAttributeCount());for(let s=0;s<t.getAttributeCount();s++){let t=e[s];-1===t?this.m_reservedPointCount=-1:i.set(s,this.m_vertexAttributes.get(t))}i.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=2**53-1,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 i=0;i<this.m_description.getAttributeCount();i++){let s=this.m_description.getSemantics(i),n=0;if(null!==this.m_vertexAttributes.get(i)){let t=d.getComponentCount(s);n=this.m_vertexAttributes.get(i).size()/t,n<this.m_pointCount&&(this.m_vertexAttributes.get(i).resize(e*t,d.getDefaultValue(s)),n=e)}else this.m_vertexAttributes.set(i,(0,r.W)(s,e)),n=e;n<t&&(t=n)}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);let e=this.updateXYImpl(t),i=new r.E({vd:this.m_description});i.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){let e=this.m_description.getSemantics(t),s=d.getComponentCount(e),r=this.m_vertexAttributes.get(t);for(let t=0;t<s;t++){let o=new n.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){let i=r.readAsDbl(e*s+t);o.mergeCoordinate(i)}i.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new r.L({moveEnv:i}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){let e=o.Envelope2D.constructEmpty(),i=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(i,0,this.m_pointCount),e}updateEnvelope3D(t){(0,s.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o.Envelope2D?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,e){if(t<0&&(0,s.a)(""),0===t)return;let i=t=Math.ceil(t);if(this.m_reservedPointCount<i){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,(0,r.X)(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*i),i=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,(0,r.X)(0,i)):this.m_vertexAttributes.get(0).resize(2*i);for(let t=1;t<this.m_description.getAttributeCount();t++){let e=this.m_description.getSemantics(t),s=d.getComponentCount(e);null===this.m_vertexAttributes.get(t)?this.m_vertexAttributes.set(t,(0,r.X)(e,i)):this.m_vertexAttributes.get(t).resize(i*s)}this.reserveImplImpl(i,e),this.m_reservedPointCount=i}}reserveRounded(t){t<0&&(0,s.a)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,s.C)("")}exportVertexAttributes(){let t=this.getPointCount(),e=this.m_description.getAttributeIndex(1),i=this.m_description.getAttributeIndex(2),s=this.m_vertexAttributes.posStream,r=e>0?this.m_vertexAttributes.get(e):void 0,n=i>0?this.m_vertexAttributes.get(i):void 0;return{vertexCount:t,vertexXY:s?.getArray()??new Float64Array,vertexZ:r?.getArray(),vertexM:n?.getArray()}}}class _ extends c{static type=s.G.enumMultiPoint;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,e){t>this.getPointCount()&&(0,s.a)("invalid point index"),t<0&&(t=this.getPointCount());let i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let s=0,n=this.m_description.getAttributeCount();s<n;s++){let n=this.m_description.getSemantics(s),o=r.V.getComponentCount(n);if(0===n)this.m_vertexAttributes.get(s).insert(o*t,e,o*i);else{let e=r.V.getDefaultValue(n);this.m_vertexAttributes.get(s).insertRange(o*t,e,o,o*i)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,s.a)(g),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());let i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let s=0,n=this.m_description.getAttributeCount();s<n;s++){let n=this.m_description.getSemantics(s),o=r.V.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(s).insertAttributes(o*t,e,n,o*i);else{let e=r.V.getDefaultValue(n);this.m_vertexAttributes.get(s).insertRange(o*t,e,o,o*i)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,i){if((t>this.getPointCount()||i<0)&&(0,s.r)(""),t<0&&(t=this.getPointCount()),0===i)return;let n=e[0].getDescription();this.mergeVertexDescription(n);let o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let s=0,a=this.m_description.getAttributeCount();s<a;s++){let a=this.m_description.getSemantics(s),l=r.V.getComponentCount(a);if(this.m_vertexAttributes.get(s))if(n.hasAttribute(a))this.m_vertexAttributes.get(s).insertAttributesFromPoints(t*l,e,i,a,o*l);else{let e=r.V.getDefaultValue(a);this.m_vertexAttributes.get(s).insertRange(l*t,e,l*i,l*o)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,i){if((t>this.getPointCount()||i<0)&&(0,s.a)("invalid point index"),t<0&&(t=this.getPointCount()),0===i)return;let n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let s=0,o=this.m_description.getAttributeCount();s<o;s++){let o=this.m_description.getSemantics(s),a=r.V.getComponentCount(o);if(this.m_vertexAttributes.get(s))if(0===o)this.m_vertexAttributes.get(s).insertRangeFromPoints(a*t,e,0,i,!0,a*n);else{let e=r.V.getDefaultValue(o);this.m_vertexAttributes.get(s).insertRange(a*t,e,a,a*n)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,s.r)("remove_points"),0!==e){for(let i=0,s=this.m_description.getAttributeCount();i<s;i++)if(this.m_vertexAttributes.get(i)){let s=this.m_description.getSemantics(i),n=r.V.getComponentCount(s);this.m_vertexAttributes.get(i).eraseRange(n*t,n*e,n*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,i=this.m_description.getAttributeCount();e<i;e++)if(this.m_vertexAttributes.get(e)){let i=this.m_description.getSemantics(e),s=r.V.getComponentCount(i);this.m_vertexAttributes.get(e).eraseRange(s*t,s,s*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){let e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=r.V.getDefaultValue(i),n=r.V.getComponentCount(i);this.m_vertexAttributes.get(t).insertRange(n*e,s,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(t,e,i,n){let o=n<0?this.m_pointCount:n;if(o=Math.min(o,i+e),(i<0||o<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.a)(""),0===this.m_pointCount)return o;let a=this.getAttributeStreamRef(0),l=null,h=r.V.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(l=this.getAttributeStreamRef(1));let u=0;for(let e=i;e<o;e++,u++)t[u].x=a.read(2*e),t[u].y=a.read(2*e+1),t[u].z=m?l.read(e):h;return o}queryAttributeAsInt(t,e,i,r){(0,s.g)(0)}add(t){t.isEmpty()&&(0,s.a)(g),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);let i=new n.P(t,e);this.setXYNoCurves(this.m_pointCount-1,i)}addXYZ(t,e,i){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);let s=new r.k;s.setCoords(t,e,i),this.setXYZNoCurves(this.m_pointCount-1,s)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,i){this===t&&(0,s.a)("Multi_point_impl.add");let n=i<0?t.getPointCount():i;if((e<0||e>t.getPointCount()||n<e)&&(0,s.a)(""),e===n)return;let o=t.getDescription();this.mergeVertexDescription(o);let a=n-e,l=this.m_pointCount;this.resizeNoInit(this.m_pointCount+a);for(let i=0,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),n=r.V.getComponentCount(s),h=this.getAttributeStreamRef(s);if(o.hasAttribute(s)){let i=t.getAttributeStreamRef(s);h.insertRangeFromStream(l*n,i,e*n,a*n,!0,1,l*n)}else{let t=r.V.getDefaultValue(s);h.insertRange(l*n,t,a*n,l*n)}}}addPoints2D(t,e,i,r){let n=e,o=r<0?n:r;if((n<0||i<0||i>n||o<i)&&(0,s.a)(""),i===o)return;n=o-i;let a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+n);let l=this.getAttributeStreamRef(0);for(let e=0;e<n;++e)l.writePoint2D(2*(a+e),t[i+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,i,r){let o=e,a=r<0?o:r;if((o<0||i<0||i>o||a<i)&&(0,s.a)(""),this.addAttribute(1),i===a)return;o=a-i;let l=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);let h=this.getAttributeStreamRef(0),m=new n.P;for(let e=0;e<o;e++)m.x=t[i+e].x,m.y=t[i+e].y,h.writePoint2D(2*(l+e),m);let u=this.getAttributeStreamRef(1);for(let e=0;e<o;e++)u.write(l+e,t[i+e].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,i){this.setXYCoordsNoCurves(t,e,i)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,i,s){this.setAttributeNoCurves(t,e,i,s)}getGeometryType(){return s.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new _({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty()||t.isIdentity())return;let e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,s.t)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===s.G.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):(0,s.t)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){let t=this.createInstance();return this.copyTo(t),t}swap(t){(0,s.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,s.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}toFlatGeometry(){return{type:"multipoint",...this.exportVertexAttributes(),...r._}}}class p{m_EnvelopeType=5;envAabb=o.Envelope2D.constructEmpty();envRot=o.Envelope2D.constructEmpty();static constructEmpty(){return new p}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:f(t),y:y(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(f(t),y(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let i=0;i<e;){if(!this.envRot.isEmpty()){for(let s=i;s<e;s++){let e=f(t[s]),i=y(t[s]);this.envRot.mergeNeCoords(e,i)}break}{let e=f(t[i]),s=y(t[i]);this.envRot.setCoords({x:e,y:s}),i++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(f(t),y(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){let e=this.envAabb.intersect(t.envAabb),i=this.envRot.intersect(t.envRot);return e&&!i&&this.envAabb.setEmpty(),i&&!e&&this.envRot.setEmpty(),e&&i}inflate(t){this.envAabb.inflateCoords(t,t);let e=t*(0,n.a6)();this.envRot.inflateCoords(e,e),e<0&&p.st_reduceEmpty(this)}static st_reduceEmpty(t){let e=t.envAabb.isEmpty(),i=t.envRot.isEmpty();e&&!i?t.envRot.setEmpty():i&&!e&&t.envAabb.setEmpty()}sqrMaxMinDistance(t){let e=this.envAabb.sqrMaxMinDistance(t),i=this.envRot.sqrMaxMinDistance(P(t))/2;return Math.max(e,i)}sqrMinDistance(t){let e=this.envAabb.sqrMinDistance(t),i=this.envRot.sqrMinDistance(P(t))/2;return Math.max(e,i)}sqrMaxDistance(t){let e=this.envAabb.sqrMaxDistance(t),i=this.envRot.sqrMaxDistance(P(t))/2;return Math.max(e,i)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){let i=function(t,e){return t-e}(t.x,t.y),s=function(t,e){return t+e}(t.x,t.y);e.setCoords(i,s)}}function f(t){return t.x-t.y}function y(t){return t.x+t.y}function P(t){return new n.P(f(t),y(t))}class x{x=n.Z.getNAN();y=n.Z.getNAN();static getNAN(){return new x}static constructPoint2D(t){let e=new x;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){let i=new x;return i.x.set(t),i.y.set(e),i}static constructCoordsE(t,e){let i=new x;return i.setCoordsE(t,e),i}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 x).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(){let t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){let e=new x;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){let e=new x;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(){let t=this.length();0===t.value()?(this.x=n.a9.clone(),this.y=n.T.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){let i=this.x.mulE(t).subThisE(this.y.mulE(e)),s=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(i),this.y.setE(s),this}rotateReverse(t,e){let i=this.x.mulE(t).addThisE(this.y.mulE(e)),s=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(i),this.y.setE(s),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 n.P.construct(this.x.value(),this.y.value())}}class v{a11=new n.Z(1);a12=new n.Z(0);a21=new n.Z(0);a22=new n.Z(1);clone(){let t=new v;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){let e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),i=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),s=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),r=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=i,this.a21=s,this.a22=r,this}mulLeftThis(t){let e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){let t=this.det();if(0!==t.value()){let e=this.a22.divE(t),i=this.a12.negate().divThisE(t),s=this.a21.negate().divThisE(t),r=this.a11.divE(t);this.a11=e,this.a12=i,this.a21=s,this.a22=r}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=(0,n.c)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){let i=this.a12.clone();i.addThisE(this.a21),i.mulThisByPower2(.5);let s=new n.Z(1),r=new n.Z(0);if(i.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{let e=new n.Z(1);if(this.a11.ne(this.a22)){let o=this.a11.subE(this.a22).divE(i);o.mulThisByPower2(.5);let a=o.sqr();e.setE(o),e.absThis(),e.subThisE(a.add(1).sqrtThis()),o.gt(n.T)&&e.negateThis();let l=e.sqr().addThis(1).sqrtThis().invThis();r=e.mulE(l),s.setE(l);let h=e.mulE(i);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else s=new n.Z(1/Math.sqrt(2)),r=s.clone(),t[0]=this.a11.addE(i),t[1]=this.a22.subE(i)}e[0].x=s.toDouble(),e[0].y=r.toDouble(),e[1].x=r.negate().toDouble(),e[1].y=s.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,n.c)(t[0],t[0]=t[1]),e[1]=(0,n.c)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class C{x;y;static constructPoint2D(t){return new C(n.M.constructDouble(t.x),n.M.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new n.M).setNAN(),void(this.y=(new n.M).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 n.P(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){let t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new C(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new C(this.x.add(t.x),this.y.add(t.y))}sub(t){return new C(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 E=r.V;function b(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.a7)(t[0][i],t[3][i]);s>0?((0,n.a7)(t[0][i],t[1][i])<0&&(t[1][i]=t[0][i],e=!0),(0,n.a7)(t[1][i],t[3][i])<0&&(t[1][i]=t[3][i],e=!0),(0,n.a7)(t[0][i],t[2][i])<0&&(t[2][i]=t[0][i],e=!0),(0,n.a7)(t[2][i],t[3][i])<0&&(t[2][i]=t[3][i],e=!0),(0,n.a7)(t[1][i],t[2][i])<0&&(t[2][i]=t[1][i],e=!0)):s<0?((0,n.a7)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.a7)(t[1][i],t[3][i])>0&&(t[1][i]=t[3][i],e=!0),(0,n.a7)(t[0][i],t[2][i])>0&&(t[2][i]=t[0][i],e=!0),(0,n.a7)(t[2][i],t[3][i])>0&&(t[2][i]=t[3][i],e=!0),(0,n.a7)(t[1][i],t[2][i])>0&&(t[2][i]=t[1][i],e=!0)):(t[1][i]!==t[0][i]||t[2][i]!==t[0][i])&&(t[1][i]=t[0][i],t[2][i]=t[0][i],e=!0)}return e}function D(t,e){let i=t.getStartXY();if(i.equals(e.getStartXY())||i.equals(e.getEndXY()))return!0;let s=t.getEndXY();return!(!s.equals(e.getStartXY())&&!s.equals(e.getEndXY()))}function w(t,e){let i=t.calculateLowerLength2D();return!(i>e)&&(!!(t.isLine()||(i=t.calculateUpperLength2D(),i<=e))||0!==e&&t.calculateLength2D()<=e)}function S(t,e,i){let r=(0,n.m)(n.P,4),o=t.queryControlPointsHelper(r),a=(0,n.m)(n.P,4),l=e.queryControlPointsHelper(a);r[0].equals(a[0])||(0,s.A)("");let h=t.getGeometryType();if(h===e.getGeometryType()&&r.map((t,e)=>a[e].equals(t)).reduce((t,e)=>t&&e)){if(h!==s.G.enumRationalBezier2)return 0;{let i=e,s=[0,0,0],r=[0,0,0];if(t.queryWeights(s),i.queryWeights(r),s.map((t,e)=>r[e]===t).reduce((t,e)=>t&&e))return 0}}for(;o>2&&r[1].equals(r[0]);)r.splice(1,1),o--;for(;l>2&&a[1].equals(a[0]);)a.splice(1,1),l--;(r[1].equals(r[0])||a[1].equals(r[0]))&&(0,s.A)("");let m=n.P.compareVectorsOrigin(r[0],r[1],a[1]);if(0===m){let i=C.constructPoint2D(r[0]),s=new C;t.queryCoord2DMP(1e-16,s),s.sub(i);let n=new C;return e.queryCoord2DMP(1e-16,n),n.sub(i),n.crossProduct(s).sign()}return m}function A(t,e,i,r,o,a,l,h){let m=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),d=t,g=e,c=!1;m>u&&(g=(0,n.c)(d,d=g),r=(0,n.c)(i,i=r),u=(0,n.c)(m,m=u),c=!0);let _=0===i;{l[0]=+!!_;let t=d.getCoord2D(l[0]);h[0]=g.getClosestCoordinate(t,!1);let e=g.getCoord2D(h[0]);if(n.P.distance(t,e)<=o){let e=[.5,.75,.25,.1,.9],i=!0;for(let s=0;s<e.length;s++)if(t.assign(d.getCoord2D(e[s])),!g.isCloserThanDistance(t,new n.E(0,1),o)){i=!1;break}if(i)return c&&(h[0]=(0,n.c)(l[0],l[0]=h[0])),1}}if(m<=3*o)return 0;let p=(0,n.s)(Math.max(o/m,.1),0,.5),f=.01*o,y=0,P=0,x=p,v=-1,C=0,E=1/32;for(let t=0;;t++){(0,s.g)(t<4095);let e=_?p:1-p,i=d.getCoord2D(e),m=g.getClosestCoordinate(i,!1);if(m===r)return C;let u=g.getCoord2D(m),b=n.P.distance(i,u);if(0===t&&(v=b),b<=f?(E=.5,P=b,y=p):(x=p,v=b),Math.abs(P-v)>.1*f&&x-y>1e-16)p=(0,n.r)(y,x,E);else{if(l[C]=e,h[C]=m,c&&(h[C]=(0,n.c)(l[C],l[C]=h[C])),1===a||1===C)return 1===C&&l[0]>l[1]&&(l[1]=(0,n.c)(l[0],l[0]=l[1]),h[1]=(0,n.c)(h[0],h[0]=h[1])),C+1;C++,y=x,P=v,x=.8,v=-1,p=.8,E=1/32,f=10*o,t=0}}}function T(t,e,i,s,r,o,a,l,h){if((0,n.ab)(i,0,1)&&(0,n.ab)(s,0,1)&&0===n.P.distance(t.getCoord2D(i),e.getCoord2D(s))){let h=1e-12,m=new x,u=(0,n.I)();if(t.queryDerivative(new n.Z(i,u),m),m.isTrueZero()){let e=1===i?-1e-12:h;t.queryDerivative(new n.Z(i,u).add(e),m)}1===i&&m.negateThis();let d=new x;if(e.queryDerivative(new n.Z(s,u),d),d.isTrueZero()){let t=1===i?-1e-12:h;e.queryDerivative(new n.Z(s,u).add(t),d)}1===s&&d.negateThis(),m.isZero()||m.normalize(),d.isZero()||d.normalize();let g=m.dotProduct(d),c=m.crossProduct(d);if(c.scaleError(3),g.ge(n.T)&&(c.isZero()||Math.abs(c.value())<(()=>{{let i=t.calculateUpperLength2D(),s=e.calculateUpperLength2D();return Math.min(.01*r/Math.min(i,s),1e-10)}})()))return A(t,e,i,s,r,o,a,l)}return 0}function I(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function M(t,e,i){t.m_XStart=e,t.m_YStart=i}function q(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function N(t,e,i){t.m_XEnd=e,t.m_YEnd=i}function R(t,e){let i=new r.k;return e?(i.x=t.m_XEnd,i.y=t.m_YEnd):(i.x=t.m_XStart,i.y=t.m_YStart),i.z=function(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:E.getDefaultValue(1)}(t,e),i}function Y(t,e,i){t.m_description.hasZ()||t.addAttribute(1),e?(t.m_XEnd!==i.x||t.m_YEnd!==i.y)&&(t.m_XEnd=i.x,t.m_YEnd=i.y,t.endPointModified()):(t.m_XStart!==i.x||t.m_YStart!==i.y)&&(t.m_XStart=i.x,t.m_YStart=i.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=i.z}function X(t,e,i){i.assignVertexDescription(t.m_description);let s=0===e?t.m_XStart:t.m_XEnd,r=0===e?t.m_YStart:t.m_YEnd;i.setXYCoords(s,r);for(let s=1;s<t.m_description.getAttributeCount();s++){let r=t.m_description.getSemantics(s);for(let s=0,n=E.getComponentCount(r);s<n;s++){let n=L(t,e,r,s);i.setAttributeBasic(r,s,n)}}}function F(t,e,i){i.isEmpty()&&(0,s.C)(""),function(t,e,i){e?(t.m_XEnd!==i.x||t.m_YEnd!==i.y)&&(t.m_XEnd=i.x,t.m_YEnd=i.y,t.endPointModified()):(t.m_XStart!==i.x||t.m_YStart!==i.y)&&(t.m_XStart=i.x,t.m_YStart=i.y,t.endPointModified())}(t,e,i.getXY());let r=i.getDescription();r!==t.m_description&&t.mergeVertexDescription(r);for(let s=1,n=r.getAttributeCount();s<n;s++){let n=r.getSemantics(s),o=E.getComponentCount(n);for(let s=0;s<o;s++)z(t,e,n,s,i.getAttributeAsDbl(n,s))}}function L(t,e,i,r){if((e<0||e>1)&&(0,s.r)(""),0===i)return(r<0||r>=2)&&(0,s.r)(""),0===e?0===r?t.m_XStart:t.m_YStart:0===r?t.m_XEnd:t.m_YEnd;let n=E.getComponentCount(i);(r<0||r>=n)&&(0,s.r)("");let o=t.m_description.getAttributeIndex(i);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+r]:E.getDefaultValue(i)}function z(t,e,i,r,n){if((e<0||e>1)&&(0,s.r)(""),0===i)return 0===e?0===r?t.m_XStart=n:1===r?t.m_YStart=n:(0,s.r)(""):1===e?0===r?t.m_XEnd=n:1===r?t.m_YEnd=n:(0,s.r)(""):(0,s.r)(""),void t.endPointModified();let o=E.getComponentCount(i);(r<0||r>=o)&&(0,s.r)("");let a=t.m_description.getAttributeIndex(i);a<0&&(t.addAttribute(i),a=t.m_description.getAttributeIndex(i)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+r]=n}function V(t,e){if(t===e)return;e.isEmpty()&&(0,s.C)("");let i=e.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let s=1,r=i.getAttributeCount();s<r;s++){let r=i.getSemantics(s),n=E.getComponentCount(r);for(let i=0;i<n;i++){let s=L(e,0,r,i);z(t,0,r,i,s),s=L(e,1,r,i),z(t,1,r,i,s)}}}function B(t){return t.absNorm()*(0,n.g)()}function k(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,n.g)()}function G(t,e,i){let s=new p;t.queryEnvelopeW(n.E.unit(),s);let r=new p;return e.queryEnvelopeW(n.E.unit(),r),r.inflate(i),!s.isIntersectingW(r)}function Z(t,e,i){let s=(0,n.aa)(t,i),r=(0,n.aa)(e,i);s.sort((t,e)=>t.compare(e)),r.sort((t,e)=>t.compare(e));for(let t=0;t<3;t++){if(s[t].compare(r[t])<0)return-1;if(0!==s[t].compare(r[t]))return 1}return 0}var H=r.V;class W{m_XStart;m_YStart;m_XEnd;m_YEnd;m_attributes;m_description;constructor(t){return t.copy?(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,void(this.m_description&&this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice()))):t.move?(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)):void 0!==t.XStart?(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:(0,r.K)(),void(t.vd&&this.setDefaultAttributeValues())):void 0!==t.ZStart?(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:(0,r.$)(),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])):t.start?(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=(0,r.K)())):t.start3D?(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:(0,r.$)(),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])):((0,s.d)("bad constructor params"),void(this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=NaN))}setDefaultAttributeValues(){let t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=(0,n.d)(2*t,NaN)),(0,n.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,n.b)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,s.t)("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return(0,s.t)("not implemented"),!1}setCoordsForIntersector3D(t,e,i){(0,s.t)("not implemented")}transformAttribute(t,e,i,r,n){(0,s.t)("")}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.M)(e,t);this.assignVertexDescription(i)}changeEndPoints(t,e){let i=t.getXY(),s=e.getXY();this.changeEndPoints2D(i,s);let r=t.getDescription();r!==this.getDescription()&&this.mergeVertexDescription(r),r=e.getDescription(),r!==this.getDescription()&&this.mergeVertexDescription(r);for(let i=1,s=r.getAttributeCount();i<s;i++){let s=r.getSemantics(i),n=H.getComponentCount(s);for(let i=0;i<n;i++)z(this,0,s,i,t.getAttributeAsDbl(s,i)),z(this,1,s,i,e.getAttributeAsDbl(s,i))}}getStartXY(){return new n.P(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 R(this,0)}setStartXYZ(t){Y(this,0,t)}setStartXYZCoords(t,e,i){Y(this,0,r.k.construct(t,e,i))}queryStart(t){X(this,0,t)}setStart(t){F(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return L(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,s.g)(0),0}setStartAttribute(t,e,i){z(this,0,t,e,i)}setStartAttributesFromPoint(t,e){let i=t.getDescription(),s=e&&i.hasZ()?2:1;for(let e=s,r=i.getAttributeCount();e<r;++e){let s=i.getSemantics(e),r=H.getComponentCount(s);for(let e=0;e<r;++e){let i=t.getAttributeAsDbl(s,e);this.setStartAttribute(s,e,i)}}}setEndAttributesFromPoint(t,e){let i=t.getDescription(),s=e&&i.hasZ()?2:1;for(let e=s,r=i.getAttributeCount();e<r;++e){let s=i.getSemantics(e),r=H.getComponentCount(s);for(let e=0;e<r;++e){let i=t.getAttributeAsDbl(s,e);this.setEndAttribute(s,e,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,s.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,s.g)(0),0}getEndXY(){return new n.P(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 R(this,1)}setEndXYZ(t){Y(this,1,t)}setEndXYZCoords(t,e,i){Y(this,1,r.k.construct(t,e,i))}queryEnd(t){X(this,1,t)}setEnd(t){F(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return L(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,s.g)(0),0}setEndAttribute(t,e,i){z(this,1,t,e,i)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,s.a)("");let e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&(0,n.b)(e.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),e.m_XStart=this.m_XStart,e.m_YStart=this.m_YStart,e.m_XEnd=this.m_XEnd,e.m_YEnd=this.m_YEnd,this.copyToImpl(e)}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){let i=n.E.constructEmpty();return i.vmin=L(this,0,t,e),i.vmax=i.vmin,i.mergeNeCoordinate(L(this,1,t,e)),i}calculateLength3D(t){return(0,s.g)(0),0}getCoord3D(t){return(0,s.g)(0),{}}getCoord2D(t){let e=n.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,s.g)(0)}getCoordZ(t){return(0,s.g)(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),r=H.getComponentCount(s);for(let i=0;i<r;i++){let r=this.getAttributeAsDbl(t,s,i);e.setAttributeBasic(s,i,r)}}}isCloserThanDistance(t,e,i){let s=o.Envelope2D.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,s),s.distance(t)>i)return!1;let r=this.getClosestCoordinateOnInterval(t,e,i);return!Number.isNaN(r)&&n.P.distance(t,this.getCoord2D(r))<=i}isMonotoneQuickAndDirty(){return!1}static s_maxMonotonicPartParams=8;isTrue3D(){return!1}getReversed(){let t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,n.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t);for(let t=0,i=H.getComponentCount(e);t<i;t++){let i=L(this,0,e,t);z(this,0,e,t,L(this,1,e,t)),z(this,1,e,t,i)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,i,r){if(!e&&this.isIntersecting(t,0,!1)){if(null!==i||null!==r){let e=(0,n.d)(9,NaN),o=(0,n.d)(9,NaN),a=this.intersect(t,null,e,o,0);(0,s.g)(a<=9),0===a&&(0,s.d)(""),null!==i&&(i[0]=e[0]),null!==r&&(r[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,l=-1,h=a;return o=this.getStartXY(),l=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==r&&(r[0]=l),null!==i&&(i[0]=0)),o=this.getEndXY(),l=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==r&&(r[0]=l),null!==i&&(i[0]=1)),o=t.getStartXY(),l=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==i&&(i[0]=l),null!==r&&(r[0]=0)),o=t.getEndXY(),l=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==i&&(i[0]=l),null!==r&&(r[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,i){return(0,n.r)(t,e,i)}moveTo(t){let e=this.isClosed(),i=new a.T;i.setShift(t.sub(this.getStartXY())),this.applyTransformation(i),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){(0,s.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){let i=(0,r.R)();(0,r.U)(e,t.m_description,i);let s=null,o=e.getTotalComponentCount()-2,a=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(o>0&&(s=(0,n.d)(2*o,NaN),(0,n.b)(s,e.getDefaultPointAttributes(),0,2,o),(0,n.b)(s,e.getDefaultPointAttributes(),o,2,o),null!==t.m_description))for(let r=1;r<e.getAttributeCount();r++){let n=i[r];if(-1!==n){let i=t.m_description.getPointAttributeOffset(n)-2,l=e.getPointAttributeOffset(r)-2,h=E.getComponentCount(e.getSemantics(r));for(let e=0;e<h;++e)s[l]=t.m_attributes[i],s[o+l]=t.m_attributes[a+i]}}t.m_attributes=s,t.m_description=e}(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;let e=(0,r.N)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.O)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.K)();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,s.a)("wrong geometry type");let e=t;e.m_description=(0,n.c)(this.m_description,this.m_description=e.m_description),e.m_XStart=(0,n.c)(this.m_XStart,this.m_XStart=e.m_XStart),e.m_YStart=(0,n.c)(this.m_YStart,this.m_YStart=e.m_YStart),e.m_XEnd=(0,n.c)(this.m_XEnd,this.m_XEnd=e.m_XEnd),e.m_YEnd=(0,n.c)(this.m_YEnd,this.m_YEnd=e.m_YEnd),e.m_attributes=(0,n.c)(this.m_attributes,this.m_attributes=e.m_attributes),this.swapImpl(e)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;let i=void 0===e;i&&(e=0);let s=t;if(this===s)return!0;if(this.m_description!==s.m_description||Math.abs(this.m_XStart-s.m_XStart)>e||Math.abs(this.m_XEnd-s.m_XEnd)>e||Math.abs(this.m_YStart-s.m_YStart)>e||Math.abs(this.m_YEnd-s.m_YEnd)>e)return!1;for(let t=0,i=2*(this.m_description.getTotalComponentCount()-2);t<i;t++)if(!(0,n.a8)(this.m_attributes[t],s.m_attributes[t],e))return!1;return i?this.equalsImpl(s):this.equalsImplTol(s,e)}getImpl(){return this}setAttributeBasic(t,e,i){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,s.a)("");let t=new a.T,r=0===e?i:0,n=1===e?i:0;t.setShiftCoords(r,n),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,e,i),this.setEndAttribute(t,e,i)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=H.getComponentCount(t);for(let s=0;s<i;s++){let i=this.getStartAttributeAsDbl(t,s);Number.isNaN(i)&&this.setStartAttribute(t,s,e);let r=this.getEndAttributeAsDbl(t,s);Number.isNaN(r)&&this.setEndAttribute(t,s,e)}}}class j extends l.G{m_index;gc;dim;constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount()||(this.m_index++,this.m_index===this.gc.getGeometryCount()))return null;let 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 U{static type=s.G.enumGeometryCollection;m_description;m_geoms=[];constructor(t){if(this.m_description=(0,r.K)(),t){if(t.vd)return void(this.m_description=t.vd);if(t.copy)return void t.copy.copyTo(this);(0,s.a)("constructor argument not recognized")}}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===s.G.enumGeometryCollection){let e=t;for(let t=0,i=e.getGeometryCount();t<i;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)&&(0,s.a)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return s.G.enumGeometryCollection}getDimension(){let t=0;for(let 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(let 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;let e=(0,r.N)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.O)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.K)();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let i=new n.E,s=new n.E;s.setEmpty();for(let r of this.m_geoms)i=r.queryInterval(t,e),s.merge(i);return s}queryEnvelope(t){if(4===t.m_EnvelopeType){let e=new r.E;t.setEmpty(),t.assignVertexDescription(this.m_description);for(let i of this.m_geoms)i.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){let e=new o.Envelope2D;t.setEmpty();for(let i of this.m_geoms)i.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,s.t)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){let e=new o.Envelope2D;t.setEmpty();for(let i of this.m_geoms)i.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,s.t)("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(let e of this.m_geoms)e.applyTransformation(t);(0,s.t)("3d xform not impl")}transformAttribute(t,e,i,s,r){for(let n of this.m_geoms)n.transformAttribute(t,e,i,s,r)}createInstance(){return new U({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==s.G.enumGeometryCollection&&(0,s.a)("");let e=t;if(e!==this){e.m_geoms.length=0,e.assignVertexDescription(this.m_description);for(let t of this.m_geoms)e.m_geoms.push(t.clone())}}calculateArea2D(){let t=new n.K(0);for(let e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){let t=new n.K(0);for(let e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return(0,s.g)(0),0}getBoundary(){let t=this.createInstance(),e=t;for(let t of this.m_geoms){let i=t.getBoundary();i&&e.m_geoms.push(i)}return t}clone(){return new U({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==s.G.enumGeometryCollection)return!1;let i=t;if(this.m_description!==i.m_description||this.m_geoms.length!==i.m_geoms.length)return!1;for(let t=0;t<this.m_geoms.length;++t)if(!this.m_geoms[t].equals(i.m_geoms[t],e))return!1;return!0}swap(t){t.getGeometryType()!==s.G.enumGeometryCollection&&(0,s.a)("");let e=t;e!==this&&(this.m_geoms=(0,n.c)(e.m_geoms,e.m_geoms=this.m_geoms))}setAttributeBasic(t,e,i){for(let s of this.m_geoms)s.setAttributeBasic(t,e,i)}replaceNaNs(t,e){for(let i of this.m_geoms)i.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.M)(e,t);this.assignVertexDescription(i)}}function O(t,e=-1){return new j(t,e)}class Q extends W{constructor(t){super(t)}}class K extends Q{isTrue3D(){return!0}constructor(t){super(t)}}function J(t,e,i){$(e,t.getStartXY(),t.getEndXY(),i)}function $(t,e,i,s){(0,n.J)(e,i,t,s)}function tt(t,e){return(0,n.r)(t.m_XStart,t.m_XEnd,e)}function et(t,e){return(0,n.r)(t.m_YStart,t.m_YEnd,e)}function it(t,e,i){e.value()<=.5?(0,n.ao)(2,x.constructPoint2D(t.getStartXY()),x.constructPoint2D(t.getEndXY()),e,i):(0,n.ap)(2,x.constructPoint2D(t.getStartXY()),x.constructPoint2D(t.getEndXY()),e,i)}function st(t,e,i){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,t.afterCompletedModification()}function rt(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=(0,n.c)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,n.c)(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,i=t.m_description.getTotalComponentCount()-2;e<i;e++)t.m_attributes[e+i]=(0,n.c)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+i])}}function nt(t,e,i,s){let r=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)&&(r++,!s))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(r++,2===r)return 2;if(!s)return 1}return e.isIntersectingPoint(t.getStartXY(),i,!0)||e.isIntersectingPoint(t.getEndXY(),i,!0)||t.isIntersectingPoint(e.getStartXY(),i,!0)||t.isIntersectingPoint(e.getEndXY(),i,!0)?4:s&&r?0:function(t,e){let i=lt(t,e.m_XStart,e.m_YStart),s=lt(t,e.m_XEnd,e.m_YEnd);if(i<0&&s<0||i>0&&s>0)return!1;let r=lt(e,t.m_XStart,t.m_YStart),n=lt(e,t.m_XEnd,t.m_YEnd);return!(r<0&&n<0||r>0&&n>0)&&(ut(t)>ut(e)?mt(t,e):mt(e,t))}(t,e)?4:0}function ot(t,e,i,s,r,o,a,l){null!==s&&(0,n.x)(s,2,NaN),null!==r&&(0,n.x)(r,2,NaN),null!==i&&(0,n.ay)(i,n.P,2);let h=function(t,e,i,s,r,o,a,l,h){let m=at(t,e.getStartXY(),a,!1),u=at(t,e.getEndXY(),a,!1),d=at(e,t.getStartXY(),a,!1),g=at(e,t.getEndXY(),a,!1),c=0,_=0;if(!Number.isNaN(m)){let i=!1;l&&(0,n.ab)(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getStartXY())&&(c++,i=!0),i||(r&&(r[_]=m),o&&(o[_]=0),s&&s[_].setCoords(e.m_XStart,e.m_YStart),_++)}if(!Number.isNaN(u)){let i=!1;l&&(0,n.ab)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(c++,i=!0),i||(2>_&&(r&&(r[_]=u),o&&(o[_]=1),s&&s[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(!(2===_||Number.isNaN(d)||0===m&&0===d||0===u&&1===d)){let i=!1;l&&(0,n.ab)(d,0,1)&&e.getCoord2D(d).isEqualPoint2D(t.getStartXY())&&(c++,i=!0),i||(2>_&&(r&&(r[_]=0),o&&(o[_]=d),s&&s[_].setCoords(t.m_XStart,t.m_YStart)),_++)}if(!(2===_||Number.isNaN(g)||1===m&&0===g||1===u&&1===g)){let i=!1;l&&(0,n.ab)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getEndXY())&&(c++,i=!0),i||(2>_&&(r&&(r[_]=1),o&&(o[_]=g),s&&s[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(_>0)return h&&(o=(0,n.c)(r,r=o)),2===_&&r&&r[0]>r[1]&&(r[1]=(0,n.c)(r[0],r[0]=r[1]),o&&(o[1]=(0,n.c)(o[0],o[0]=o[1])),s&&(s[1]=(0,n.c)(s[0],s[0]=s[1]))),_;if(c>0)return 0;let p=function(t,e,i){let s=t.m_XEnd-t.m_XStart,r=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,l=o*r-s*a;if(0===l)return n.P.getNAN();let h=4*(0,n.I)()*(Math.abs(o*r)+Math.abs(s*a)),m=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,d=o*u-m*a,g=4*(0,n.I)()*(Math.abs(o*u)+Math.abs(m*a)),c=d/l,_=Math.abs(l),p=(g*_+h*Math.abs(d))/(l*l)+(0,n.I)()*Math.abs(c);if(c<-p||c>1+p)return n.P.getNAN();let f=s*u-m*r,y=f/l,P=(4*(0,n.I)()*(Math.abs(s*u)+Math.abs(m*r))*_+h*Math.abs(f))/(l*l)+(0,n.I)()*Math.abs(y);if(y<-P||y>1+P)return n.P.getNAN();let x=(0,n.s)(c,0,1),v=(0,n.s)(y,0,1),C=n.P.getNAN();J(t,x,C);let E=n.P.getNAN();if(J(e,v,E),!i||n.P.distance(C,E)>i){let s=n.P.getNAN();(0,n.J)(C,E,.5,s),x=t.getClosestCoordinate(s,!1),v=e.getClosestCoordinate(s,!1);let r=n.P.getNAN();J(t,x,r);let o=n.P.getNAN();J(e,v,o),r.subThis(o);let a=r.length(),l=(t.absNorm()+e.absNorm())*(0,n.g)();if(a>Math.max(i,l))return n.P.getNAN()}return new n.P(x,v)}(t,e,a);return Number.isNaN(p.x)?0:(s&&(s[0]=t.getCoord2D(p.x)),r&&(r[0]=p.x),o&&(o[0]=p.y),1)}(t,e,0,i,s,r,o,a,l);return s&&(s.length=h),r&&(r.length=h),i&&(i.length=h),h}function at(t,e,i,s){let r=n.P.getNAN(),o=n.P.getNAN(),a=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(r.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(r.setCoords(t.m_XStart,t.m_YStart),o.setCoords(t.m_XEnd,t.m_YEnd));let l=+!!a,h=+!a,m=n.P.getNAN();m.setSub(e,r);let u=m.length(),d=3*u*(0,n.I)();if(u<=Math.max(i,d))return s&&0===u?NaN:l;if(m.setSub(e,o),u=m.length(),d=3*u*(0,n.I)(),u<=Math.max(i,d))return s&&0===u?NaN:h;m.setCoords(o.x-r.x,o.y-r.y);let g=m.length();if(g>0){let t=1/g;m.scale(t);let s=n.P.getNAN();s.setSub(e,r);let u=s.dotProduct(m),d=8*s.dotProductAbs(m)*(0,n.I)();m.leftPerpendicularThis();let c=s.dotProduct(m),_=8*s.dotProductAbs(m)*(0,n.I)(),p=Math.max(i,d);if(u<-p||u>g+p)return NaN;if(Math.abs(c)<=Math.max(i,_)){let s=u*t;s=(0,n.s)(s,0,1);let m=n.P.getNAN();if($(s,r,o,m),n.P.distance(m,e)<=i){if(s<.5){if(n.P.distance(m,r)<=i&&n.P.distance(e,r)<=i)return l}else if(n.P.distance(m,o)<=i&&n.P.distance(e,o)<=i)return h;return a?1-s:s}}}return NaN}function lt(t,e,i){let s=n.P.getNAN();s.setCoords(e,i),s.subThis(t.getStartXY());let r=n.P.getNAN();r.setSub(t.getEndXY(),t.getStartXY());let o=r.crossProduct(s),a=4*(0,n.I)()*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?-1:+(o<-a)}function ht(t,e,i,s){let r=s?t.m_XStart:t.m_XEnd,o=s?t.m_YStart:t.m_YEnd,a=n.P.getNAN();return a.x=e.getEndX()-r,a.y=e.getEndY()-o,!(i.dotProduct(a)>3*(0,n.I)()*i.dotProductAbs(a))||(a.x=e.getStartX()-r,a.y=e.getStartY()-o,i.dotProduct(a)<=3*(0,n.I)()*i.dotProductAbs(a))}function mt(t,e){let i=n.P.getNAN();return i.x=t.m_XEnd-t.m_XStart,i.y=t.m_YEnd-t.m_YStart,!(!ht(t,e,i,!1)||(i.negateThis(),!ht(t,e,i,!0)))}function ut(t){let e=t.m_XStart-t.m_XEnd,i=t.m_YStart-t.m_YEnd;return e*e+i*i}class dt{constructor(t){if(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())&&(0,s.r)("");let 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)&&(0,s.r)("");let e=+!t.parent.isClosedPath(t.pathIndex);t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,s.r)(""),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())&&(0,s.r)(""),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&&(0,s.q)(""),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()){let 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 i;i=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=i+1,this.m_currentPathIndex=i,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(i),this.m_segmentCount=this.getSegmentCount(i),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&&(0,s.r)("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&&(0,s.r)(""),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;let 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&&(0,s.r)(""),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)&&(0,s.r)(""),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(){return null!==this.m_segFlagStream&&1!=(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}m_buffer;m_currentSegmentIndex;m_nextSegmentIndex;m_nextPathIndex;m_currentPathIndex;m_parent;m_segFlagStream=null;m_xyStream=null;m_description;m_segmentCount;m_pathBegin;m_bCurrentPathClosed;m_bCirculator=!1;m_bStripAttributes;m_prevPathIndex;m_prevSegmentIndex;m_bNeedsUpdate}class gt{m_rasterizedGeometry=null;m_quadTree=null;m_quadTreeForPaths=null;m_refCount=1;constructor(t){t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,s.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){let t=new gt;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){(0,s.g)(this.uniqueUse())}setQuadTree(t){(0,s.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,s.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function ct(t){return!(t.isEmpty()||t.getGeometryType()!==s.G.enumPolyline&&t.getGeometryType()!==s.G.enumPolygon||t.getPointCount()<20)}function _t(t){return!(t.isEmpty()||t.getGeometryType()!==s.G.enumPolyline&&t.getGeometryType()!==s.G.enumPolygon||t.getPointCount()<20)}function pt(t,e){return t.readPoint2D(e+4)}function ft(t){let e=t.getGeometryType();return e===s.G.enumEllipticArc?10:e===s.G.enumBezier?4:e===s.G.enumRationalBezier2?5:e===s.G.enumBezier2?2:void(0,s.d)("")}function yt(t){let e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Pt(t,e,i,s){let r=t.getPathStart(e),o=t.getPathEnd(e);if(o-r<3)return;let a=2*r,l=n.P.getNAN();i.queryPoint2D(a,l);let h=l.x,m=l.y,u=n.P.getNAN();i.queryPoint2D(a+2,u);let d=n.P.getNAN();for(let t=a+4,e=2*o;t<e;t+=2)i.queryPoint2D(t,d),s.pe((d.x-l.x)*(u.y-m)),l.setCoordsPoint2D(u),u.setCoordsPoint2D(d);s.pe((h-l.x)*(u.y-m))}function xt(t,e,i){for(;e.hasNextSegment();){let t=e.nextCurve();if(null===t)break;i.pe(2*t.calculateArea2DHelper())}}var vt=r.V;class Ct{m_segmentFlags=null;m_segmentParamIndex=null;m_segmentParams=null;static toSegType(t){let e=0;switch(t){case s.G.enumLine:e=1;break;case s.G.enumBezier:e=2;break;case s.G.enumEllipticArc:e=4;break;case s.G.enumRationalBezier2:e=8;break;case s.G.enumBezier2:e=16;break;default:(0,s.d)("")}return e}m_curveCount;m_bezierCount;m_arcCount;m_rbezier2Count;m_bezier2Count;m_curveParamWritePoint;constructor(){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 Et extends c{constructor(t){super(t),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?s.G.enumPolygon:s.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,s.g)(this.m_bPolygon);let e=this.getPathIndexFromPointIndex(t),i=this.getPathStart(e);if(i===t)return;let r=this.getPathEnd(e);(t>=r||t<i)&&(0,s.a)("change_ring_start_point");for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){let s=this.m_description.getSemantics(e),n=vt.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}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;let t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);let e=new r.A(t),i=new n.K(0),s=new n.K(0);if(0!==this.m_pointCount){let r=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){let t=new dt({parent:this});for(t.stripAttributes();t.nextPath();){s.reset();let n=t.getPathIndex();Pt(this,n,r,s),xt(0,t,s);let o=.5*s.getResult();i.add(o),e.write(n,o)}}else for(let n=0;n<t;n++){s.reset(),Pt(this,n,r,s);let t=.5*s.getResult();i.add(t),e.write(n,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=i.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0,e=this.getPathCount();for(let i=0;i<e;i++)8&this.m_pathFlags.read(i)&&t++;return t}getHashCodeImpl(){return(0,s.g)(0),0}equalsImpl(t){let e=t,i=this.getPathCount();if(i!==e.getPathCount())return!1;let s=this.hasNonLinearSegments();if(s!==e.hasNonLinearSegments()||s&&(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount||this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)||this.m_paths&&!this.m_paths.equals(e.m_paths,0,i+1)||this.m_bFillRule!==e.m_bFillRule||!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,i))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,i=this.getPointCount();t<i;t++){let i=this.m_curveData.m_segmentFlags.read(t);if(!Et.isNonLinearSegmentFlag(i))continue;let s=this.m_curveData.m_segmentParamIndex.read(t),r=e.m_curveData.m_segmentParamIndex.read(t),o=yt(i);for(let t=0;t<o;t++){let i=this.m_curveData.m_segmentParams.read(s+t),o=e.m_curveData.m_segmentParams.read(r+t);if(!(0,n.G)(i,o))return!1}}}return!0}equalsImplTol(t,e){let i=t,s=this.getPathCount();if(s!==i.getPathCount())return!1;let r=this.hasNonLinearSegments();if(r!==i.hasNonLinearSegments()||r&&(this.m_curveData.m_curveCount!==i.m_curveData.m_curveCount||this.m_curveData.m_bezierCount!==i.m_curveData.m_bezierCount)||this.m_paths&&!this.m_paths.equals(i.m_paths,0,s+1)||this.m_bFillRule!==i.m_bFillRule||!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(i.m_pathFlags,0,s))return!1;if(!r)return!0;if(!this.m_curveData.m_segmentFlags.equals(i.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;let n=this.querySegmentIterator(),o=i.querySegmentIterator();for(;n.nextPath();){if(!o.nextPath())return!1;for(;n.hasNextSegment();){let t=n.nextCurve(),i=o.nextCurve();if(!(t&&i&&t.equals(i,e))){if(!t&&!i)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=(0,r.a0)(1,0),this.m_pathFlags=(0,r.a1)(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){let i=t;i.m_bPathStarted=!1,i.m_bFillRule=this.m_bFillRule,i.m_paths=this.m_paths?e?this.m_paths:this.m_paths.clone():null,i.m_pathFlags=this.m_pathFlags?e?this.m_pathFlags:this.m_pathFlags.clone():null,this.m_curveData&&(i.m_curveData||=new Ct,i.m_curveData.assignCopy(this.m_curveData),i.m_curveData.m_curveCount=0,i.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?i.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():i.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?i.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():i.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?i.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():i.m_curveData.m_segmentParams=null)),i.hasDirtyFlag(512)||(i.m_cachedLength2D=this.m_cachedLength2D),i.m_cachedRingAreas2D=null,i.hasDirtyFlag(1024)||(i.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(i.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;let t=this.querySegmentIterator(),e=new n.K(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){let e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),i=new n.K(0);for(;e.hasNextSegment();)i.add(e.nextSegment().calculateLength2D());return i.getResult()}calculateLength3D(t){return(0,s.g)(0),0}calculatePathLength3D(t,e){return(0,s.g)(0),0}copyTo(t){(0,s.j)(t.getGeometryType())||(0,s.a)(""),this!==t&&super.copyTo(t)}swap(t){(0,s.g)(0)}setPointByVal(t,e){this.setPointByValWithCurves(t,e)}setPointByValWithCurves(t,e){if(this.hasNonLinearSegments()){let i=e.getXY();if(this.setXYCoordsWithCurves(t,i.x,i.y),1===this.m_description.getAttributeCount())return}this.setPointByValNoCurves(t,e)}setXYCoordsWithCurves(t,e,i){if(this.hasNonLinearSegments()){let s=Et.getPathIndexFromPointIndexImpl(this.m_paths,this.getPathCount(),t,this.m_currentPathIndex);this.m_currentPathIndex=s;let r=this.getPrevSegmentTypeFromPath(s,t),o=this.getNextSegmentType(t);if(1!==r||1!==o){let a=t-1,l=new Xn;1!==r&&(this.isClosedPath(s)&&t===this.getPathStart(s)&&(a=this.getPathEnd(s)-1),this.getSegmentBuffer(a,l,!0));let h=new Xn;1!==o&&this.getSegmentBuffer(t,h,!0);let m=t+1;this.setXYCoordsNoCurves(t,e,i);let u=new n.P(e,i);return 1!==r&&(l.get().changeEndPoints2D(l.get().getStartXY(),u),this.replaceSegmentImpl(a,t,l.get(),!0)),void(1!==o&&(h.get().changeEndPoints2D(u,h.get().getEndXY()),this.replaceSegmentImpl(t,m,h.get(),!0)))}}this.setXYCoordsNoCurves(t,e,i)}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,i,s){if(0===t&&this.hasNonLinearSegments()){let t=this.getXY(e);0===i?t.x=s:t.y=s,this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeNoCurves(t,e,i,s)}setXY(t,e){this.setXYCoordsWithCurves(t,e.x,e.y)}setXYCoords(t,e,i){this.setXYCoordsWithCurves(t,e,i)}setXYZ(t,e){this.setXYZWithCurves(t,e)}setAttribute(t,e,i,s){this.setAttributeWithCurves(t,e,i,s)}setAttributeWithCurvesFromArray(t,e,i,r){if(0===t&&this.hasNonLinearSegments()){r<2&&(0,s.r)("");let t=this.getXY(e);t.x=i[0],t.y=i[1],this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeFromArrayNoCurves(t,e,i,r)}setAttributeFromArray(t,e,i,s){this.setAttributeWithCurvesFromArray(t,e,i,s)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,i=this.getPathCount();e<i;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&(0,s.a)("Multi_path_impl::add");for(let i=0,s=t.getPathCount();i<s;i++)this.addPath(t,i,!e)}addPath(t,e,i){this.insertPath(-1,t,e,i)}addPathPoint2D(t,e,i){this.insertPath2D(-1,t,0,e,i)}addPathMultiPoint(t,e,i,s){i<0&&(i=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,i,s)}addSegmentsFromPath(t,e,i,r,n){if(this===t&&(0,s.a)("Multi_path_impl.add_segments_from_path"),!n&&0===this.getPathCount()&&(n=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||i<0||r<0||i+r>t.getSegmentCountPath(e))&&(0,s.r)("add_segments_from_path"),0===r)return;let o=t.getPathStart(e),a=t.isClosedPath(e)&&i+r===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let l=r,h=o+i,m=h+1;n&&(l++,m--),!n&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(h)&&(t.getXY(h).equals(this.getXY(this.m_pointCount-1))||(0,s.a)("add_segments_from_path: start point mismatch"));let u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange(),n){if(0===l)return;this.m_paths.add(this.m_pointCount);let i=t.m_pathFlags.read(e);this.m_bPolygon&&(i|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,i),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);let d=a?l-1:l;for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e),s=vt.getComponentCount(i),r=t.m_description.getAttributeIndex(i);if(d>0){if(r<0||!t.m_vertexAttributes.get(r)){let t=vt.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(s*u,t,d*s,s*u),a&&this.m_vertexAttributes.get(e).insertRange(s*u+d*s,t,s,s*u);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(s*u,t.m_vertexAttributes.get(r),s*m,d*s,!0,s,s*u)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(s*(u+d),t.m_vertexAttributes.get(r),s*o,s,!0,s,s*(u+d))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let i=0,s=h;i<r;i++)e+=yt(t.m_curveData.m_segmentFlags.read(s)),s++;if(e>0){this.initSegmentData(e);let i=h,s=u-+!n,o=0;for(let e=0;e<r;e++){let e=t.m_curveData.m_segmentFlags.read(i);if(this.m_curveData.m_segmentFlags.write(s,e),Et.isNonLinearSegmentFlag(e)){o++;let r=t.m_curveData.m_segmentParamIndex.read(i),n=yt(e);this.m_curveData.m_segmentParamIndex.write(s,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<n;e++){let 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(s,-1);s++,i++}this.modifyCurveCounter(o)}}if(a){let t=this.getPathCount()-1,e=this.getPathStart(t),i=this.getPathEnd(t)-1,s=this.getXY(e),r=this.getXY(i);s.isEqualPoint2D(r)&&(--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()&&(0,s.a)("");let e=this.getPathSize(t);if(0===e)return;let i=this.getPathStart(t),r=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=i,s=new this.m_segmentBufferCTor,n=!1;for(let i=0;i<e;i++,t++){let e=this.m_curveData.m_segmentFlags.read(t);if(!Et.isNonLinearSegmentFlag(e))continue;n=!0,this.querySegment(t,s,!0),s.get().reverse();let i=this.m_curveData.m_segmentParamIndex.read(t);s.get().writeInBufferStream(this.m_curveData.m_segmentParams,i)}if(n){let t=+!r;this.m_curveData.m_segmentFlags.reverseRange(i,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(i,e-t,1)}}let n=+!!r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++)if(this.m_vertexAttributes.get(t)){let s=this.m_description.getSemantics(t),r=vt.getComponentCount(s);this.m_vertexAttributes.get(t).reverseRange(r*(i+n),r*(e-n),r)}let 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){let e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,s.a)("");let i=this.getPathStart(t),r=this.getPathSize(t);for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){let e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*i,s*r,s*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=i,s=i+r;e<s;e++){let i=this.m_curveData.m_segmentFlags.read(e);Et.isNonLinearSegmentFlag(i)&&(this.incCurveType(i,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(i,r,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(i,r,this.m_pointCount)}for(let i=t+1;i<=e;i++){let t=this.m_paths.read(i);this.m_paths.write(i-1,t-r)}if(this.m_pathFlags)for(let i=t+1;i<=e;i++){let t=this.m_pathFlags.read(i);this.m_pathFlags.write(i-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=r,this.m_reservedPointCount-=r,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,i,n){this===e&&(0,s.a)("Multi_path_impl::insert_path");let o=this.getPathCount();if(!n&&e.hasNonLinearSegmentsPath(i))return t=this.insertPath(t,e,i,!0),this.reversePath(t),t;i>=e.getPathCount()&&(0,s.a)(""),t>o&&(0,s.a)(""),t<0&&(t=o),i<0&&(i=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());let a=e.getPathStart(i),l=e.getPathSize(i);if(0===l)return this.insertPath2D(t,null,0,0,!0);let h=this.m_pointCount,m=e.isClosedPath(i)&&!n?1:0;this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange();let u=t<o?this.getPathStart(t):h;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=e.getDescription().getAttributeIndex(i),r=vt.getComponentCount(i);if(s>=0&&e.m_vertexAttributes.get(s))0!==m&&this.m_vertexAttributes.get(t).insertRangeFromStream(u*r,e.m_vertexAttributes.get(s),r*a,r,!0,r,r*h),this.m_vertexAttributes.get(t).insertRangeFromStream((u+m)*r,e.m_vertexAttributes.get(s),r*(a+m),r*(l-m),n,r,r*(h+m));else{let e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(u*r,e,r*l,r*h)}}let d=h+l;this.m_paths.add(d);for(let e=o;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+l)}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)}let g=e.getPathFlagsStreamRef().read(i);if(g&=-9,this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),e.hasNonLinearSegments()){this.initSegmentData(0);let t=a,i=0;for(let s=0;s<l;s++)i+=yt(e.m_curveData.m_segmentFlags.read(t)),t++;if(i>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=(0,r.a1)(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=(0,r.a0)(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(u,1,l,h),this.m_curveData.m_segmentParamIndex.insertRange(u,-1,l,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+i):this.m_curveData.m_segmentParams=(0,r.a2)(i),t=a;let s=u,n=0;for(let i=0;i<l;i++){let i=e.m_curveData.m_segmentFlags.read(t);if(Et.isNonLinearSegmentFlag(i)){this.m_curveData.m_segmentFlags.write(s,i),this.m_curveData.m_segmentParamIndex.write(s,this.m_curveData.m_curveParamWritePoint);let r=yt(i),o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){let t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}n++,this.incCurveType(i,1)}t++,s++}this.modifyCurveCounter(n)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,i,r,n){let o=this.getPathCount();(t>o||i<0)&&(0,s.a)(""),t<0&&(t=o),this.m_bPathStarted=!1;let a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),0===r&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();let l=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*l,e,i,r,n,2*a);else{let t=vt.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*l,t,2*r,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e),s=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(l*i,s,i*r,i*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+r)}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(l,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(l,-1,r,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,i,r,n){let o=e.getImpl(),a=this.getPathCount();(t>a||i<0)&&(0,s.a)("");let l=r<0?o.getPointCount()-i:r;if(l>o.getPointCount()&&(0,s.a)(""),i>=o.getPointCount()&&(0,s.a)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===l)return void this.insertPath2D(t,null,0,0,!0);let h=this.m_pointCount,m=i;this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange();let u=t<a?this.getPathStart(t):h;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=o.getDescription().getAttributeIndex(e),s=vt.getComponentCount(e);if(i>=0){let i=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(u*s,i,s*m,s*l,n,s,s*h)}else{let i=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(u*s,i,s*l,s*h)}}let d=h+l;this.m_paths.add(d);for(let e=a;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+l)}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,e,i,r,n,o,a){if(this===i&&(0,s.a)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),r<0&&(r=i.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||r>=i.getPathCount()||o>i.getPathSize(r))&&(0,s.r)(""),!o)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)}e<0&&(e=this.getPathSize(t));let l=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();let h=this.getPathStart(t),m=h+e;o<0&&(o=i.getPathSize(r));let u=i.getPathStart(r),d=u+o;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){let s=this.m_description.getSemantics(t),r=vt.getComponentCount(s),g=i.m_description.getAttributeIndex(s);if(g<0||!i.m_vertexAttributes.get(g)){let e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(r*m,e,d*r,r*l);continue}this.m_vertexAttributes.get(t)?.insertRangeFromStream(r*(h+e),i.m_vertexAttributes.get(g),r*(u+n),o*r,a,r,r*l)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,o,l),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,o,l),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 e=t+1,i=this.getPathCount();e<=i;e++){let t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,i,r,n,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||r<0)&&(0,s.r)(""),!n)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));let a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),this.verifyAllStreamsAfterSizeChange();let l=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(l+e),i,r,n,o,2*a);for(let t=1,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=vt.getComponentCount(i),r=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange((l+e)*s,r,s*n,s*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l+e,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(l+e,-1,n,a),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 e=t+1,i=this.getPathCount();e<=i;e++)this.m_paths.write(e,this.m_paths.read(e)+n);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,i,r,n,o){let a=i.getImpl(),l=this.getPathCount();t<0&&(t=this.getPathCount());let h=a.getPointCount();if((r<0||r>h)&&(0,s.r)(""),(n<0||r+n>h)&&(n=h-r),e<0&&(e=t<l?this.getPathSize(t):0),(t>l||t<l&&e>this.getPathSize(t)||t===l&&e>0||n<0)&&(0,s.r)(""),!n)return;this.mergeVertexDescription(a.getDescription()),t===l&&(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));let m=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),this.verifyAllStreamsAfterSizeChange();let u=this.getPathStart(t),d=u+e,g=0+n;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=vt.getComponentCount(i);if(a.getDescription().getAttributeIndex(i)<0){let e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(s*d,e,g*s,s*m);continue}let l=a.getAttributeStreamRef(i);this.m_vertexAttributes.get(t).insertRangeFromStream(s*(u+e),l,s*(0+r),n*s,o,s,s*m)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(u+e,1,n,m),this.m_curveData.m_segmentParamIndex.insertRange(u+e,-1,n,m),e>0&&this.isNonLinearSegment(u+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(u+e-1),-1),this.m_curveData.m_segmentFlags.write(u+e-1,1),this.m_curveData.m_segmentParamIndex.write(u+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,i=this.getPathCount();e<=i;e++){let t=this.m_paths.read(e);this.m_paths.write(e,t+n)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,i){let r=this.getPathCount();t<0&&(t=r),(t>r||t<r&&e>this.getPathSize(t))&&(0,s.r)(""),t===r&&this.addPathPoint2D(null,0,!0);let n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();let o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,l=this.m_vertexAttributes.get(0);if(a===n)this.m_paths.write(t+1,n+1),l.writePoint2D(2*a,i);else{l.insert(2*a,i,2*n);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e),s=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(i*a,s,i,i*n)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,n));for(let e=t+1,i=r;e<=i;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,i){let r=this.getPathCount();t<0&&(t=r),(t>r||t<r&&e>this.getPathSize(t))&&(0,s.r)(""),t===r&&this.addPathPoint2D(null,0,!0);let n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();let o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===n)this.m_paths.write(t+1,n+1),this.setPointByValNoCurves(a,i);else{let e=i.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){let s=this.m_description.getSemantics(t),r=vt.getComponentCount(s);if(e.hasAttribute(s))this.m_vertexAttributes.get(t).insertAttributes(r*a,i,s,r*n);else{let e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(r*a,e,r,r*n)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,n));for(let e=t+1,i=r;e<=i;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)}removePointFromPath(t,e){let i=this.getPathCount();t<0&&(t=i-1),(t>=i||e>=this.getPathSize(t))&&(0,s.r)("Multi_path.remove_point");let r=this.getPathStart(t),n=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,s.r)("Multi_path.remove_point");let o=r+e;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(i*o,i,i*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>r&&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{let i=this.getPathEnd(t);n&&r+1<i&&this.isNonLinearSegment(i-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(i-1),-1),this.m_curveData.m_segmentFlags.write(i-1,1),this.m_curveData.m_segmentParamIndex.write(i-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 e=i;e>=t+1;e--){let t=this.m_paths.read(e);this.m_paths.write(e,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;let i=this.getPathStart(t);if(e>i)return this.m_curveData.m_segmentFlags.read(e-1);if(e===i){if(this.isClosedPath(t)){let e=this.getPathEnd(t);return this.m_curveData.m_segmentFlags.read(e-1)}return 1}(0,s.d)("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let i=this.getPathStart(t),s=this.getPathEnd(t);i<s;i++)Et.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(i))&&++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);let i=this.getPathCount(),s=Et.getPathIndexFromPointIndexImpl(this.m_paths,i,t,e);return this.m_currentPathIndex=s,s}startPathCoords(t,e){this.startPathPoint(new r.P({x:t,y:e}))}startPath(t){this.startPathPoint(new r.P({pt:t}))}startPath3D(t){this.startPathPoint(new r.P({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,i){this.startPathPoint(new r.P({x:t,y:e,z:i}))}startPathPoint(t){t.isEmpty()&&(0,s.a)("");let e,i=t.getDescription();if(this.m_description!==i){this.mergeVertexDescription(i);let s=new r.P({vd:this.m_description});t.copyCommonAttributesTo(s),e=s}else e=t;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,e):(this.insertPoint(-1,-1,e),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=(0,r.a0)(2),this.m_paths.write(0,0),this.m_pathFlags=(0,r.a1)(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null===this.m_paths?this.beforeNewSegmentHelper2():(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1))}beforeNewSegment(t){0===this.m_pointCount&&!this.m_bPathStarted&&this.startPathCoords(0,0);let e=this.m_pointCount,i=this.m_paths.size()-1,s=e+t;this.m_paths.write(i,s),this.resizeImpl(s),this.m_bPathStarted&&=!1}finishLineTo(){if(this.hasNonLinearSegments()){let 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{let i=(0,r.Q)(),s=new r.P({vd:this.m_description,attribBuffer:i,initDefaultValues:!0});s.setXYCoords(t,e),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);let e=(0,r.M)(this.m_description,(0,r.$)()),i=(0,r.Q)(),s=new r.P({vd:e,attribBuffer:i,initDefaultValues:!0});s.setXYZ(t),this.setPointByValNoCurves(this.m_pointCount-1,s),this.finishLineTo()}lineTo3DCoords(t,e,i){this.lineTo3D(new r.k(t,e,i))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByValNoCurves(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());let e=(0,r.Q)(),i=new r.P({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(i),this.setPointByValNoCurves(this.m_pointCount-1,i)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&(0,s.d)("");let e=this.getPathCount();if(t>e&&(0,s.a)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,s.d)("");let i=this.m_pointCount,r=this.getPathStart(t),n=this.getPathEnd(t);if(n-r!==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)){let e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*n,this.m_vertexAttributes.get(t),s*r,s,!0,1,s*i)}for(let i=e;i>t;i--){let t=this.m_paths.read(i);this.m_paths.write(i,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(n,1,1,i),this.m_curveData.m_segmentParamIndex.insertRange(n,-1,1,i)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,s.d)(""),t>this.getPathCount()&&(0,s.a)(""),this.m_pathFlags||(0,s.d)(""),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&&(0,s.d)(""),this.isEmpty())return;this.m_pathFlags||(0,s.d)("");let t=0,e=this.getPathCount();for(let i=0;i<e;i++)this.isClosedPath(i)&&(this.getPathSize(i)>0?t++:this.m_pathFlags.clearBits(i,1));if(0===t)return;let i=this.hasNonLinearSegments(),n=0,o=this.getPathCount(),a=this.m_description.getAttributeCount(),l=Array(a),h=null,m=null;for(let e=0;e<o;++e){let s=this.getPathStart(e),o=this.getPathSize(e),u=this.isClosedPath(e);if(o>0){let e=s+n;for(let i=0;i<a;i++)if(this.m_vertexAttributes.get(i)){let n=this.m_description.getSemantics(i),a=vt.getComponentCount(n);if(!l[i]){let e=a*(this.m_pointCount+t),s=(0,r.X)(n,e);l[i]=s}l[i].writeRange(e*a,o*a,this.m_vertexAttributes.get(i),s*a,!0,1),u&&l[i].writeRange((e+o)*a,a,this.m_vertexAttributes.get(i),s*a,!0,1)}if(i){if(null===h){let e=this.m_pointCount+t;h=(0,r.a1)(e),m=(0,r.a0)(e)}h.writeRange(e,o,this.m_curveData.m_segmentFlags,s,!0,1),m.writeRange(e,o,this.m_curveData.m_segmentParamIndex,s,!0,1),u&&(h.write(e+o,1),m.write(e+o,-1))}}this.m_paths.write(e,s+n),u&&(this.m_pathFlags.clearBits(e,1),++n)}this.m_paths.write(o,this.m_pointCount+t),this.m_pathFlags.clearBits(o,1);for(let t=0;t<a;t++)this.m_vertexAttributes.get(t)&&this.m_vertexAttributes.set(t,l[t]);i&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=m),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())&&(0,s.a)("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);let e=this.m_pathFlags.read(t);if(1&e||this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){let e=this.getPathEnd(t)-1,i=this.m_curveData.m_segmentFlags.read(e);1!==i&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(i,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,s.a)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,s.a)("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());let i=e.getStartXY(),r=this.getPathEnd(t)-1;i.equals(this.getXY(r))||(0,s.a)("close_path_with_segment: start point mismatch");let n=e.getGeometryType();if(n===s.G.enumLine)return void this.closePathWithLine(t);{let t=ft(e);this.initSegmentData(t);let i=Ct.toSegType(n),s=this.m_curveData.m_segmentFlags.read(r);if(s!==i)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(i,1),1===s?this.modifyCurveCounter(1):this.incCurveType(s,-1);else{let t=this.m_curveData.m_segmentParamIndex.read(r);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,i)}}let i=this.m_pathFlags.read(t);1&i||this.m_pathFlags.write(t,1|i),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,i=this.m_paths.size()-1;e<i;e++){if(this.isClosedPath(e))continue;let i=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|i),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;let e=this.getPathStart(t),i=this.getPathEnd(t)-1;if(e>i)return!1;let s=this.getXY(e),r=this.getXY(i);return s.isEqualPoint2D(r)}isClosedPathIn3D(t){return(0,s.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),i=this.getPathEnd(t);e<i;e++)if(Et.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;let i=0===this.m_pointCount;if(t instanceof o.Envelope2D)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{let i=t.getDescription(),s=(0,r.Q)(),n=new r.P({vd:i,attribBuffer:s,initDefaultValues:!1});for(let i=0;i<4;i++){let s=e?4-i-1:i;t.queryCornerByVal(s,n),0===i?this.startPathPoint(n):this.lineToPoint(n)}}this.closePathWithLine(),this.m_bPathStarted=!1,i&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||(0,s.a)("add_path_from_closedSegment: segment must be closed"),e){let e=t.getReversed(),i=new r.P;e.queryStart(i),this.startPathPoint(i),this.closeLastPathWithSegment(e)}else{let e=new r.P;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){let i=t.getDescription();this.mergeVertexDescription(i);let n=(0,r.Q)(),o=new r.P({vd:i,attribBuffer:n,initDefaultValues:!1}),a=t.getGeometryType();if(a===s.G.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let i=!1;if((e||this.isEmptyImpl())&&(i=!0),i||t.getStartXY().equals(this.getXY(this.m_pointCount-1))||(0,s.a)("add_segment: start point mismatch"),i&&(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{let t=(0,r.Q)(),e=new r.P({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}let n=ft(t);this.initSegmentData(n),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+=n;let l=Ct.toSegType(a);this.incCurveType(l,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,l)}}addSegment(t,e,i){i?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,e,i,r){for(let e=t;e<i-1;e++)this.isClosedPath(e)&&(0,s.a)("cannot interpolate across closed paths");let n=this.m_description.getAttributeCount();if(1===n)return;let o=this.calculateSubLength2D(t,e,i,r);if(0!==o)for(let s=1;s<n;s++){let n=this.m_description.getSemantics(s);this.interpolateAttributesSemanticsImpl(n,t,e,i,r,o)}}interpolateAttributesSemantics(t,e,i,r,n){if(0===t)return;this.hasAttribute(t)||(0,s.a)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,s.a)("angular interpolation");for(let t=e;t<r-1;t++)this.isClosedPath(t)&&(0,s.a)("cannot interpolate across closed paths");let o=this.calculateSubLength2D(e,i,r,n);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,i,r,n,o)}interpolateAttributesPath(t,e,i){let s=this.m_description.getAttributeCount();if(1===s||e===i)return;let r=this.calculatePathSubLength2D(t,e,i);for(let n=1;n<s;n++){let s=this.m_description.getSemantics(n);this.interpolateAttributesSemanticsPathImpl(s,t,e,i,r)}}interpolateAttributesSemanticsPath(t,e,i,r){if(0===t)return;this.hasAttribute(t)||(0,s.a)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,s.a)("angular interpolation");let n=this.calculatePathSubLength2D(e,i,r);0!==n&&this.interpolateAttributesSemanticsPathImpl(t,e,i,r,n)}interpolateAttributesSemanticsImpl(t,e,i,s,r,o){let a=this.querySegmentIterator(),l=this.getPathStart(e)+i,h=this.getPathStart(s)+r,m=vt.getComponentCount(t),u=(0,n.d)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,l,u,m);let d=(0,n.d)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,h,d,m);let g=(0,n.d)(vt.maxComponentCount(),NaN);(0,n.b)(g,u,0,0,m);let c=0,_=vt.getDefaultValue(t),p=vt.getInterpolation(t);a.resetToVertex(l,e);do{if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===h)return;this.setAttributeFromArray(t,a.getStartPointIndex(),g,m),a.previousSegment();do{let e=a.nextSegment();if(a.getEndPointIndex()===h)return;c+=e.calculateLength2D();let i=c/o;(0,n.a4)(p,u,d,g,0,m,i,_),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),g,m)}while(a.hasNextSegment())}}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,i,r,o){(0,s.g)(0!==t);let a=this.querySegmentIterator(),l=vt.getInterpolation(t),h=this.getPathStart(e)+i,m=this.getPathStart(e)+r;if(m===h)return;let u=vt.getComponentCount(t),d=(0,n.d)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,h,d,u);let g=(0,n.d)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,m,g,u);let c=new n.K(0);a.resetToVertex(h,e),a.setCirculator(this.isClosedPath(e));let _=vt.getDefaultValue(t),p=(0,n.d)(vt.maxComponentCount(),NaN);(0,n.b)(p,d,0,0,u);let f=0===o,y=.5;do{let e=a.nextSegment();if(this.setAttributeFromArrayNoCurves(t,a.getStartPointIndex(),p,u),!f){let t=e.calculateLength2D();c.pe(t),y=c.getResult()/o}(0,n.a4)(l,d,g,p,0,u,y,_)}while(a.getEndPointIndex()!==m)}querySegment(t,e,i){let r=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(r);n>=this.getSegmentCountPath(r)&&(0,s.a)("get_segment"),this.getSegmentFromPath(r,n,e,i)}getSegment(t,e){let i=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,i,e),i.releaseSegment()}getSegmentType(t){let e=this.getPathIndexFromPointIndex(t),i=t-this.getPathStart(e);return i>=this.getSegmentCountPath(e)&&(0,s.a)("get_segment"),this.getSegmentTypeFromPath(e,i)}getSegmentFromPath(t,e,i,n){let o=this.getPathStart(t)+e,a=this.getSegmentFlagsStreamRef(),l=1;switch(a&&(l=31&a.read(o)),l){case 1:i.createLine();break;case 2:i.createCubicBezier();break;case 4:i.createEllipticArc();break;case 8:i.createQuadraticRationalBezier();break;case 16:i.createQuadraticBezier();break;default:(0,s.d)("")}let h,m=i.get(),u=null;if(n?(u=(0,r.K)(),m.assignVertexDescription(u)):m.assignVertexDescription(this.m_description),h=o===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):o+1,I(m,this.getXY(o)),q(m,this.getXY(h)),!n)for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);for(let t=0;t<i;t++){let i=this.getAttributeAsDbl(e,o,t);m.setStartAttribute(e,t,i);let s=this.getAttributeAsDbl(e,h,t);m.setEndAttribute(e,t,s)}}if(Et.isNonLinearSegmentFlag(l)){let t=this.m_curveData.m_segmentParamIndex.read(o);m.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments()||0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,i=this.getPointCount();e<i;e++)if(4===this.m_curveData.m_segmentFlags.read(e)){let i=this.m_curveData.m_segmentParamIndex.read(e);pt(this.m_curveData.m_segmentParams,i).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,e,i,r=!1){let o={iSegment:-1},a=r?o:{tSegment:0};if(i.setEmpty(),this.isEmpty()||((t<0||t>=this.getPathCount())&&(0,s.a)("query_point_along_path"),e<0))return o;let l=this.getPathSize(t);if(0===l)return o;if(1===l)return this.getPointByVal(this.getPathStart(t),i),a.tSegment=0,o.iSegment=this.getPathStart(t),o;let h=this.querySegmentIteratorAtVertex(this.getPathStart(t)),m=new n.K(0);for(;h.hasNextSegment();){let t=h.nextSegment(),s=t.calculateLength2D(),r=m.getResult();if(m.add(s),m.getResult()>=e){let n=e-r;n>s&&(n=s);let l=t.lengthToT(n);return t.queryCoord(l,i),a.tSegment=l,o.iSegment=h.getStartPointIndex(),o}}if(this.isClosedPath(t)){let e=this.getPathStart(t);return this.getPointByVal(e,i),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}{let e=this.getPathEnd(t)-1;return this.getPointByVal(e,i),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2,o):(a.tSegment=0,o.iSegment=this.getPathStart(t),o)}}queryPointsAlongPath(t,e,i,r,o,a){{let t=0;for(let n=0;n<e;++n)r&&r[n].setEmpty(),o&&(o[n]=-1),a&&(a[n]=0),t>i[n]&&(0,s.a)("query_points_along"),t=i[n]}let l=this.getPathSize(t);if(0===e||0===l)return 0;if(1===l){let e=this.getPathStart(t);return r&&this.getPointByVal(e,r[0]),a&&(a[0]=0),o&&(o[0]=e),1}let h=this.getPathStart(t),m=new n.K(0),u=this.querySegmentIteratorAtVertex(h),d=0,g=0,c=i[d];for(;u.hasNextSegment();){let t=u.nextSegment(),s=t.calculateLength2D(),n=m.getResult();for(m.add(s);m.getResult()>=c;){let l=c-n;l>s&&(l=s);let h=t.lengthToT(l);if(r&&t.queryCoord(h,r[g]),a&&(a[g]=h),o&&(o[g]=u.getStartPointIndex()),g++,d++,c=i[d],d===e)return g}}if(this.isClosedPath(t)){let e=this.getPathStart(t);r&&this.getPointByVal(e,r[g]),a&&(a[g]=0),o&&(o[g]=e),g++}else if(this.getPathSize(t)>1){let e=this.getPathEnd(t)-2;r&&this.getPointByVal(e+1,r[g]),a&&(a[g]=1),o&&(o[g]=e),g++}return g}queryPointsAlong(t,e,i,r,o){{let n=0;for(let a=0;a<t;++a)i&&i[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),n>e[a]&&(0,s.a)("query_points_along"),n=e[a]}if(0===t)return 0;let a=new n.K(0),l=this.querySegmentIterator(),h=-1,m=0,u=0,d=e[m];for(;l.nextPath();)for(;l.hasNextSegment();){h=l.getPathIndex();let s=l.nextSegment(),n=s.calculateLength2D(),g=a.getResult();for(a.add(n);a.getResult()>=d;){let a=d-g;a>n&&(a=n);let h=s.lengthToT(a);if(i&&s.queryCoord(h,i[u]),o&&(o[u]=h),r&&(r[u]=l.getStartPointIndex()),u++,m++,d=e[m],m===t)return u}}if(h<0)return 0;if(this.isClosedPath(h)){let t=this.getPathStart(h);i&&this.getPointByVal(t,i[u]),o&&(o[u]=0),r&&(r[u]=t),u++}else if(this.getPathSize(h)>1){let t=this.getPathEnd(h)-2;i&&this.getPointByVal(t+1,i[u]),o&&(o[u]=1),r&&(r[u]=t),u++}return u}querySegmentIterator(){return new dt({parent:this})}querySegmentIteratorAtVertex(t){return new dt({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,e,i){if(e instanceof r.E&&(0,s.g)(0,"not implemented for Envelope"),e instanceof r.r&&(0,s.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,s.a)(""),this.isEmpty())return void e.setEmpty();let n=this.getAttributeStreamRef(0),a=o.Envelope2D.constructEmpty();a.setEmpty();for(let e=2*this.getPathStart(t),i=2*this.getPathEnd(t);e<i;){let t=i-e;(0,s.g)(!(1&t)),a.mergePointsInterleaved(n,e/2,t/2),e+=t}if(e.setCoords({env2D:a}),this.hasNonLinearSegmentsPath(t)){let r=this.querySegmentIterator();if(r.resetToPath(t),r.nextPath())for(;r.hasNextSegment();){let t=r.nextCurve();if(!t)break;{let s=o.Envelope2D.constructEmpty();i?t.queryEnvelope(s):t.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}else(0,s.g)(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams||this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;let t=yt(4)*this.m_curveData.m_arcCount+yt(2)*this.m_curveData.m_bezierCount+yt(8)*this.m_curveData.m_rbezier2Count+yt(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*t>>1,10)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let e=0,i=this.getPointCount();e<i;e++){let i=this.m_curveData.m_segmentFlags.read(e);Et.isNonLinearSegmentFlag(i)&&(t+=yt(i))}let e=(0,r.a2)(t),i=0;for(let t=0,s=this.getPointCount();t<s;t++){let s=this.m_curveData.m_segmentFlags.read(t);if(Et.isNonLinearSegmentFlag(s)){let r=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,i);let n=yt(s);for(let t=0;t<n;t++)e.write(i,this.m_curveData.m_segmentParams.read(r)),i++,r++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=i}setEmpty(){this.m_curveData&&=(this.removeAllCurvesFromGlobalCounter(),null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){(0,s.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=(0,r.a0)(0),this.m_pathFlags=(0,r.a1)(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))}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=(0,r.a0)(0),this.m_pathFlags=(0,r.a1)(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)))}clone(){let t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new bt(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null==this.m_curveData?null:this.m_curveData.m_segmentFlags}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null===this.m_curveData?null:this.m_curveData.m_segmentParamIndex}getSegmentDataStreamRef(){return this.throwIfEmpty(),null===this.m_curveData?null:this.m_curveData.m_segmentParams}setSegmentData(t,e,i,s){this.m_curveData||=new Ct,this.m_curveData.m_segmentFlags=i,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=s}static getPathIndexFromPointIndexImpl(t,e,i,r){if(r>=0&&r<e){if(i>=t.read(r)){if(i<t.read(r+1))return r;r++}else r--;if(r>=0&&r<e&&i>=t.read(r)&&i<t.read(r+1))return r}if(e<5){for(let s=0;s<e;s++)if(i<t.read(s+1))return s;(0,s.o)("")}let n=0,o=e-1;for(;o>n;){let e=n+(o-n>>1);if(i<t.read(e))o=e-1;else{if(!(i>=t.read(e+1)))return e;n=e+1}}return n}getHighestPointIndex(t){(0,s.g)(t>=0&&t<this.getPathCount());let e=this.getAttributeStreamRef(0),i=this.getPathEnd(t),r=this.getPathStart(t),o=-1,a=new n.P;a.y=-1/0,a.x=-1/0;for(let t=r+0;t<i;t++){let i=e.readPoint2D(2*t);-1===a.compare(i)&&(o=t,a.setCoordsPoint2D(i))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,s.a)("apply_transformation"),this.isEmpty()||t.isIdentity())return;let i=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let s,r;return e<0?(s=0,r=this.m_pointCount):(s=this.getPathStart(e),r=this.getPathEnd(e)),i.applyTransformation(t,2*s,r-s),void this.notifyModifiedFlags(2001)}let r=new this.m_segmentBufferCTor,o=this.getPathCount(),a=e<0?0:e;do{let s=this.getPathStart(a),o=this.getPathEnd(a),l=this.isClosedPath(a),h=i.readPoint2D(2*s);if(!this.hasNonLinearSegmentsPath(a)){i.applyTransformation(t,2*s,o-s);continue}let m=n.P.getNAN();for(let e=s;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){let n=l&&e+1===o;n&&i.writePoint2D(2*s,h),this.getSegmentBuffer(e,r,!0),r.get().applyTransformation(t);let a=this.m_curveData.m_segmentParamIndex.read(e);r.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),i.writePoint2D(2*e,r.get().getStartXY()),n&&i.writePoint2D(2*s,r.get().getEndXY());continue}let n=2*e;i.queryPoint2D(n,m),t.transformInPlace(m),i.writePoint2D(n,m)}if(a===e)break}while(++a<o);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,i,r){let n=this.getPathStart(t)+e,o=this.getPathStart(i)+r;(o<n||n<0||o>this.getPointCount()-1)&&(0,s.q)("");let a=this.querySegmentIterator(),l=0;a.resetToVertex(n,t);do{for(;a.hasNextSegment();){let t=a.nextSegment();if(a.getStartPointIndex()===o)break;l+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return l}calculatePathSubLength2D(t,e,i){let r=this.getPathStart(t)+e,n=this.getPathStart(t)+i;(r<0||n>this.getPointCount()-1)&&(0,s.q)("");let o=this.querySegmentIterator();if(r>n&&(this.isClosedPath(t)||(0,s.a)("cannot iterate across an open path"),o.setCirculator(!0)),r===n)return 0;let a=0,l=0;o.resetToVertex(r,t);do{l+=a,a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==n);return l}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){let e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){let i=o.Envelope2D.constructEmpty(),s=this.querySegmentIterator();for(;s.nextPath();)for(;s.hasNextSegment();){let r=s.nextCurve();if(!r)break;t?r.queryEnvelope(i):r.queryLooseEnvelope(i),e.mergeEnvelope2D(i)}}return e}notifyModifiedAllImpl(){this.m_pointCount=null!==this.m_paths&&this.m_paths.size()?this.m_paths.read(this.m_paths.size()-1):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,e){this===t&&(0,s.a)("Multi_path_impl::add");let i=this.getPathCount();for(let s=0,r=t.getPathCount();s<r;s++)this.addPath(t,s,!e),this.openPathAndDuplicateStartVertex(i),i++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,i){let r=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(r);n>=this.getSegmentCountPath(r)&&(0,s.a)("getSegmentBuffer"),this.getSegmentFromPath(r,n,e,i)}getSegmentTypeFromPath(t,e){let i=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef(),n=1;switch(r&&(n=31&r.read(i)),n){case 1:return s.G.enumLine;case 2:return s.G.enumBezier;case 4:return s.G.enumEllipticArc;case 8:return s.G.enumRationalBezier2;case 16:return s.G.enumBezier2;default:(0,s.d)("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,i=this.getPathCount();e<i;e++){let i=this.getPathStart(e),r=this.getPathEnd(e),o=r-i;for(let e=i;e<r;e++){let r=31&this.m_curveData.m_segmentFlags.read(e);if(1===r)continue;2!==r&&(0,s.t)("ensure_xy_monotone_segments");let a=(e-i+1)%o+i,l=this.m_curveData.m_segmentParamIndex.read(e),h=(0,n.m)(n.P,4);h[0]=this.getXY(e),h[3]=this.getXY(a),h[1].x=this.m_curveData.m_segmentParams.read(l),h[1].y=this.m_curveData.m_segmentParams.read(l+1),h[2].x=this.m_curveData.m_segmentParams.read(l+2),h[2].y=this.m_curveData.m_segmentParams.read(l+3),b(h)&&(t=!0,this.m_curveData.m_segmentParams.write(l,h[1].x),this.m_curveData.m_segmentParams.write(l+1,h[1].y),this.m_curveData.m_segmentParams.write(l+2,h[2].x),this.m_curveData.m_segmentParams.write(l+3,h[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||=new gt,null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);let e=(0,r.u)(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||=new gt,null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);let e=(0,r.a3)(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Et.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||=new Ct,Et.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||=new Ct,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?0:this.m_curveData.m_curveParamWritePoint}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Ct);let e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=(0,r.a1)(e,1),this.m_curveData.m_segmentParamIndex=(0,r.a0)(e,-1));let i=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=(0,r.a2)(i):i!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(i,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 Ct),this.m_curveData.m_curveParamWritePoint=t}static st_totalCurveCount=0;updateOGCFlagsHelper(){let t=this.getPathCount();if(0===t)return;let e=this.m_pathFlags,i=0;for(let s=0;s<t;s++){let t=this.m_cachedRingAreas2D.read(s);0===i&&(i=(0,n.e)(t)),t*i>0||0===i?e.setBits(s,8):e.clearBits(s,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,e,i){(t<0||t>=this.getPointCount())&&(0,s.a)("Multi_path_impl.replace_segment"),(0,s.g)(e.isCurve());let r=this.getPathIndexFromPointIndex(t),n=this.getPathStart(r),o=(t-n+1)%this.getPathSize(r)+n;{let i=this.getXY(t),r=this.getXY(o),n=!i.isEqualPoint2D(e.getStartXY())||!r.isEqualPoint2D(e.getEndXY());(0,s.g)(!n)}this.replaceSegmentImpl(t,o,e,i)}replaceSegmentImpl(t,e,i,o){let a=i.getDescription();this.mergeVertexDescription(a);let l,h=(0,n.d)(32,NaN),m=new r.P({vd:a,attribBuffer:h,initDefaultValues:!1}),u=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),d=yt(u),g=ft(i),c=!1;d>=g?((0,s.g)(null!==this.m_curveData),c=!0,l=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(g),c=!1,l=this.m_curveData.m_curveParamWritePoint);let _=i.getGeometryType(),p=Ct.toSegType(_);o||(i.queryStart(m),this.setPointByValNoCurves(t,m),i.queryEnd(m),this.setPointByValNoCurves(e,m)),this.m_curveData.m_segmentParamIndex.write(t,1===p?-1:l),this.m_curveData.m_segmentFlags.write(t,p),1!==p&&i.writeInBufferStream(this.m_curveData.m_segmentParams,l),c||(this.m_curveData.m_curveParamWritePoint+=g),u!==p&&(this.incCurveType(u,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===u?1:-1))}setAttributeImpl(t,e,i){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,s.a)("");let t=new a.T,r=0===e?i:0,n=0===e?0:1;t.setShiftCoords(r,n),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,i)}toFlatGeometry(){let t,e,i,s=this.m_bPolygon?"polygon":"polyline",r=this.getPathCount(),n=this.m_paths?this.m_paths.getArray():new Int32Array,o=this.m_paths?this.m_pathFlags.getArray():new Int8Array,a=0,l=0;if(this.m_curveData){let{m_segmentFlags:s,m_segmentParamIndex:r,m_segmentParams:n}=this.m_curveData;t=s?.getArray()??new Int8Array,e=r?.getArray()??new Int32Array,i=n?.getArray()??new Float64Array,a=this.m_curveData.m_arcCount,l=this.m_curveData.m_bezierCount}return{type:s,...this.exportVertexAttributes(),partCount:r,partOffsets:n,partFlags:o,segmentFlags:t,segmentIndices:e,segmentParams:i,segmentCountArc:a,segmentCountBezier:l}}m_cachedLength2D;m_cachedArea2D;m_currentPathIndex;m_cachedRingAreas2D=null;m_paths=null;m_pathFlags=null;m_curveData=null;m_segmentBufferCTor}class bt{constructor(t,e){this.m_extentOfInterest=new o.Envelope2D(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()}m_extentOfInterest;m_bfirst;m_prevIndex;m_parent;m_segIter=null;m_quadTree=null;m_qtIter=null;prepare_(){let 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;let t=this.m_qtIter.next();if(-1===t)return null;let e=this.m_quadTree.getElement(t);return(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e),this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){let t=this.m_segIter.nextSegment(),e=o.Envelope2D.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 Dt extends Et{static type=s.G.enumPolyline;constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Xn):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Xn,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Xn):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Xn,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Xn,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,s.d)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Xn)}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Dt.type}getDimension(){return 1}createInstance(){return new Dt({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}var wt=s.G;function St(t,e){if(t.isEmpty())return!1;let i=t.getGeometryType();if(i===wt.enumPolygon)return 0!==t.calculateArea2D();if(i===wt.enumPolyline)return Tt(t.getImpl(),0,!0).bNotEmpty;if(i===wt.enumEnvelope)return!0;if((0,s.h)(i))return!!t.isClosed();if((0,s.f)(i))return!1;if(i===wt.enumGeometryCollection){let i=t;for(let t=0,s=i.getGeometryCount();t<s;t++)if(St(i.getGeometry(t),e))return!0;return!1}(0,s.t)("")}function At(t,e){let i=t.getGeometryType();if(i===wt.enumPolygon){let e=new Dt({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(i===wt.enumPolyline)return Tt(t.getImpl(),0,!1).boundary;if(i===wt.enumEnvelope){let e=new Dt({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,s.h)(i)){let e=new _({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){let i=new r.P;e.reserve(2),t.queryStart(i),e.add(i),t.queryEnd(i),e.add(i)}return e}if(i===wt.enumGeometryCollection){let i=t,s=null;for(let r=0,n=i.getGeometryCount();r<n;r++){let n=At(i.getGeometry(r),e);if(null!==n){null===s&&(s=t.createInstance());let e=n;s.addGeometry(e)}}return s}if((0,s.f)(i))return new r.P({vd:t.getDescription()});(0,s.t)("")}function Tt(t,e,i){let s=t,o=null;if(i||(o=new _({vd:s.getDescription()})),!s.isEmpty()){let t=new r.a(0);for(let e=0,i=s.getPathCount();e<i;e++)if(s.getPathSize(e)>0&&!s.isClosedPathInXYPlane(e)){let i=s.getPathStart(e);t.add(i);let r=s.getPathEnd(e)-1;t.add(r)}if(t.size()>0){let e=new r.B,a=s.getAttributeStreamRef(0);e.sort(t,0,t.size(),{userSort(t,e,i){let s=n.P.getNAN(),r=n.P.getNAN();i.sort(t,e,(t,e)=>(a.queryPoint2D(2*t,s),a.queryPoint2D(2*e,r),s.compare(r)))},getValue:t=>a.read(2*t+1)});let l=a.readPoint2D(2*t.read(0)),h=0,m=1,u=new r.P;for(let e=1,s=t.size();e<s;e++){let s=a.readPoint2D(2*t.read(e));if(s.isEqualPoint2D(l))t.read(h)>t.read(e)?(t.write(h,(0,n.j)()),h=e):t.write(e,(0,n.j)()),m++;else{if(1&m){if(i)return{bNotEmpty:!0,boundary:new _({})}}else t.write(h,(0,n.j)());l=s,h=e,m=1}}if(1&m){if(i)return{bNotEmpty:!0,boundary:new _({})}}else t.write(h,(0,n.j)());if(!i){t.sort(0,t.size());for(let e=0,i=t.size();e<i&&t.read(e)!==(0,n.j)();e++)s.getPointByVal(t.read(e),u),o.add(u)}}}return i?{bNotEmpty:!1,boundary:new _({})}:{bNotEmpty:!1,boundary:o}}function It(t,e,i,r){let o=4*(0,n.I)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,n.I)();if(1===t.getMaxDerivative()){(0,s.g)(i>0);let a=Rt(t,0,e,(0,n.I)(),o);return r[0]=a.root,a.cRoots}let l,h=[],m=new n.E(e.vmin-o,e.vmax+o);h.push(new n.P(m.vmin,m.vmax));let u=0;for(let s=t.getMaxDerivative()-1;s>=0;s--){l=h,h=[];for(let m=0,d=l.length;m<d;m++){if(l[m][0]<l[m][1]){let d,g,c;if(s===t.getMaxDerivative()-1?({root:d,funcAtRoot:g,cRoots:c}=Rt(t,s,n.E.construct(l[m][0],l[m][1]),a,.5*o)):({root:d,funcAtRoot:g,cRoots:c}=Yt(t,s,n.E.construct(l[m][0],l[m][1]),0,.5*o)),1===c){if(0===s)u<i&&(l[m][0]<=e.vmin&&l[m][1]>=e.vmin&&d!==e.vmin&&0===t.getValue(0,e.vmin)&&(d=e.vmin),l[m][0]<=e.vmax&&l[m][1]>=e.vmax&&d!==e.vmax&&0===t.getValue(0,e.vmax)&&(d=e.vmax),r[u]=e.snapClip(d),u>0?r[u]-r[u-1]>o&&u++:u++);else{let t=n.P.getNAN();t[0]=l[m][0],t[1]=d,h.push(t);let e=n.P.getNAN();e[0]=d,e[1]=l[m][1],h.push(e)}continue}}h.push(l[m])}}return u}function Mt(t,e,i,s,r,o){let a=(0,n.m)(n.Z,2),l=Lt(new n.Z(t),new n.Z(e),new n.Z(i),s,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),l}function qt(t,e,i,s,r,o,a){let l=(0,n.m)(n.Z,3),h=zt(new n.Z(t),new n.Z(e),new n.Z(i),new n.Z(s),r,o,l);return a[0]=l[0].value(),a[1]=l[1].value(),a[2]=l[2].value(),h}function Nt(t,e,i,s,r,o,a,l){return function(t,e,i,s,r,o,a,l){let h=(0,n.d)(i*i,NaN);h.fill(0),(0,n.b)(l,s,0,0,i);let m=(0,n.d)(i,NaN),u=(0,n.d)(i,NaN),d=(0,n.d)(i,NaN),g=t(l,i,e),c=0;for(c=0;c<100;c++){let s=g;for(let t=0;t<i;++t)u[t]=l[t];if(c%i===0){h.fill(0);for(let t=0;t<i;t++)h[t*i+t]=1}let a=0,_=0;for(let s=0;s<i;++s){for(let t=0;t<i;++t)m[t]=h[s*i+t];let n=g;g=Xt(t,e,l,m,r,o,i);let u=n-g;u>a&&(_=s,a=u)}for(let t=0;t<i;t++)m[t]=l[t]-u[t],d[t]=l[t]+(l[t]-u[t]);let p=t(d,i,e);if(p<s&&2*(s-2*g+p)*(0,n.a)(s-g-a)<(0,n.a)(s-p)*a){g=Xt(t,e,l,m,r,o,i);for(let t=0;t<i;++t)h[_*i+t]=h[(i-1)*i+t],h[(i-1)*i+t]=m[t]}if(s<=g)return t(l,i,e)}return g}(t,e,i,s,r,o,0,l)}function Rt(t,e,i,r,o){let a={root:0,funcAtRoot:0,cRoots:0},l=i.vmin,h=i.vmax,m=0,u=Number.MAX_VALUE,d=t.getValue(e,l),g=t.getValue(e,h),c=0,_=0,p=0;if(d>=0&&g>=0||d<=0&&g<=0)return Math.abs(d)<Math.abs(g)?(a.funcAtRoot=d,a.root=l,a.cRoots=+(0===d),a):(a.funcAtRoot=g,a.root=h,a.cRoots=+(0===g),a);Math.abs(d)<Math.abs(g)&&(h=(0,n.c)(l,l=h),g=(0,n.c)(d,d=g)),m=l,c=d;let f=!0,y=0;for(;0!==g&&Math.abs(l-h)>r*Math.abs(h)+o;y++){let i=y>64;if(!i){_=d!==c&&g!==c?l*g*c/((d-g)*(d-c))+h*d*c/((g-d)*(g-c))+m*d*g/((c-d)*(c-g)):h-g*(h-l)/(g-d);let t=(3*l+h)/4;if(i=!(_>t&&_<h||_>h&&_<t),!i){let t=r*Math.abs(h)+o;if(f){let e=Math.abs(h-m);i=Math.abs(_-h)>=.5*e||e<t}else{let e=Math.abs(m-u);i=Math.abs(_-h)>=.5*e||e<t}}}if(i?(_=(l+h)/2,f=!0):f=!1,p=t.getValue(e,_),0===p)return a.root=_,a.funcAtRoot=p,a.cRoots=1,a;if(!i){let i=l-_,s=_-h;if(Math.abs(i)>10*Math.abs(s)){let i=h+3*s;for(let s=0;s<2;s++){let s=t.getValue(e,i);(0,n.e)(d)*(0,n.e)(s)>0?(l=i,d=s):i=(0,n.r)(l,h,.75)}}else if(Math.abs(s)>10*Math.abs(i)){let s=l-3*i;for(let i=0;i<2;++i){let i=t.getValue(e,s);(0,n.e)(g)*(0,n.e)(i)>0?(h=s,g=i):s=(0,n.r)(l,h,.25)}}}u=m,m=h,c=g,(0,n.e)(d)*(0,n.e)(p)<0?(h=_,g=p):(l=_,d=p),Math.abs(d)<Math.abs(g)&&(h=(0,n.c)(l,l=h),g=(0,n.c)(d,d=g)),128===y&&(0,s.d)("Root_finder iterations exceeded")}return a.root=h,a.funcAtRoot=g,a.cRoots=1,a}function Yt(t,e,i,r,o){let a={root:0,funcAtRoot:0,cRoots:0},l=i.vmin,h=t.getValue(e,l),m=i.vmax,u=t.getValue(e,m);if(h>=0&&u>=0||h<=0&&u<=0)return Math.abs(h)<Math.abs(u)?(a.funcAtRoot=h,a.root=l,a.cRoots=+(0===h),a):(a.funcAtRoot=u,a.root=m,a.cRoots=+(0===u),a);u<0&&(u=(0,n.c)(h,h=u),m=(0,n.c)(l,l=m));let d=.5*(l+m),g=Math.abs(m-l),c=g,_=t.getValue(e,d),p=t.getValue(e+1,d),f=4,y=1,P=0,x=0,v=1,C=0;for(;++C<100;){C>32||0===p||2===v&&P>1||1===v&&f<4?(v=1,y>1&&y--):(v=2,x>1&&Math.abs(2*_)>Math.abs(g*p)&&y++),g=c;let i,s=!1;if(1===v)do{if(x>2){let t=16*Math.abs(g);if(.5*Math.abs(l-m)>t){let e=Math.min(l,m),s=Math.max(l,m);if(d===e){i=d,d=e+t,c=d-i;break}if(d===s){i=d,d=s-t,c=d-i;break}}}c=.5*(m-l),i=d,d=l+c,s=l===d||m===d}while(0);else for(;;){c=y*_/p,i=d,d-=c,s=d===i;let t=Math.min(l,m),e=Math.max(l,m);if(d<t){if(y>1){d=i,y--;continue}c=i-t,d=t}else if(d>e){if(y>1){d=i,y--;continue}c=i-e,d=e}break}if(s||Math.abs(c)<o){i!==d&&(_=t.getValue(e,d));break}_=t.getValue(e,d),p=t.getValue(e+1,d);let r=l,n=m;_<0?(h=_,l=d):(u=_,m=d),2===v&&(l===r&&m===n||x>1&&Math.abs(c)>=.5001*Math.abs(g))?P++:P=0,1===v?(f++,x=0):(f=0,x++)}return 100===C&&(0,s.d)("Root_finder iterations exceeded"),a.root=d,a.funcAtRoot=_,a.cRoots=1,a}function Xt(t,e,i,s,r,o,a){let l=s.slice(0,a),h=0;for(let t=0;t<a;t++)h+=s[t]*s[t];if(h=Math.sqrt(h),h>0)for(let t=0;t<a;t++)l[t]/=h;let m=-1/0,u=1/0;{let t=(0,n.d)(a,0);for(let e=0;e<a;e++)t[e]=e;t.sort((t,e)=>{let i=Math.abs(l[t]),s=Math.abs(l[e]);return i<s?-1:+(i>s)});for(let e=0;e<a;e++){let s=t[e];if(0===l[s])continue;let a=(r[s]-i[s])/l[s],h=(o[s]-i[s])/l[s];h<a&&(h=(0,n.c)(a,a=h)),a>m&&(m=a),h<u&&(u=h)}}let d=0,g=(Math.abs(m)+Math.abs(u))*(0,n.I)()*100,c=(0,n.d)(a,NaN),_=l.slice();function p(s,r){for(let t=0,e=a;t<e;t++)c[t]=i[t]+s*_[t];return t(c,a,e)}g>0&&(d=function(t,e,i,s,r,o){return function(t,e,i,s,r,o){let a=(0,n.a2)(),l=s,h=t(l,e),m=i,u=r,d=t(m,e),g=t(u,e);h>d&&(h=d,l=m),h>g&&(h=g,l=u);let c=m,_=u,p=d,f=g;p>f&&(p=(0,n.c)(f,f=p),_=(0,n.c)(c,c=_));let y=l-c,P=c-_,x=.5*Math.min(o,u-m),v=2*x,C=0,E=0;for(;E<100&&!(u-m<=v);++E){let i=m+.5*(u-m),s=C>0;if(!s&&Math.abs(P)<=x&&(s=!0,C=3),!s){let t=l-c,e=l-_,i=t*(h-f),r=e*(h-p),n=e*r-t*i;r=2*(r-i),r>0&&(n=-n),r=Math.abs(r),0===r||Math.abs(n)>=Math.abs(r*P/2)||n<=r*(m-l)||n>=r*(u-l)?(s=!0,C=3):(P=y,y=n/r)}s&&(P=l>=i?m-l:u-l,y=a*P,C--);let r=l+y;r<m+x?r=m+x:r>u-x&&(r=u-x);let n=t(r,e);n<h?(r>=l?(m=l,d=h):(u=l,g=h),_=c,c=l,l=r,f=p,p=h,h=n):(r<l?(m=r,d=n):(u=r,g=n),n<=p||c===l?(_=c,c=r,f=p,p=n):(n<=f||_===l||_===c)&&(_=r,f=n))}return l}(t,e,i,s,r,o)}(p,null,m,0,u,g));let f=p(d);for(let t=0,e=a;t<e;t++)i[t]=(0,n.s)(c[t],r[t],o[t]);return f}function Ft(t,e,i,s){return t.isZero()?e.isZero()?-1:0:(s.setE(e.clone().negateThis().divThisE(t)),+!!i.containsCoordinate(s.value()))}function Lt(t,e,i,s,r,o){if(0===t.value())return r?(o[0].set(1),+!!s.containsCoordinate(o[0].value())):Ft(e,i,s,o[0]);if(r){let e=2;return o[0].set(1),o[1].setE(i).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),s.containsCoordinate(o[1].value())||(e=1),s.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,n.c)(o[0],o[0]=o[1])),e}let a=e.clone().sqrThis().subThisE(t.clone().mulThisE(i).mulThisE(n.aq));if(a.lt(n.T))return 0;let l=new n.Z(e.value()>=0?1:-1),h=a.clone().sqrtThis(),m=new n.Z(-.5).mulThisE(e.clone().addThisE(l.clone().mulThisE(h))),u=0;o[0].setE(m.divE(t));let d=new n.Z(o[0].value()),g=new n.Z(t.value()).mulE(d).addE(new n.Z(e.value()).mulE(d).addE(new n.Z(i.value())));return g.isZero()||Wt(o[0],t,e,i,o[0]),s.containsCoordinate(o[0].value())&&u++,0!==h.value()&&0!==m.value()?(o[u].assign(i.divE(m)),d.set(o[u].value()),g.assign(new n.Z(t.value()).mulE(d).addE(new n.Z(e.value()).mulE(d).addE(new n.Z(i.value())))),g.isZero()||Wt(o[u],t,e,i,o[u]),s.containsCoordinate(o[u].value())&&u++,2===u&&o[0].value()>o[1].value()&&(o[1]=(0,n.c)(o[0],o[0]=o[1])),u):u}function zt(t,e,i,r,o,a,l){if(0===t.value())return Lt(e,i,r,o,a,l);if(a){let i=1;l[0].set(1);let s=l.slice(i),a=Lt(t,e.addE(t),r.negate(),o,!1,s);if(a>0){i+=a;for(let t=1;t<i;t++)l[t].eq(n.a9)&&(l[i-1]=(0,n.c)(l[t],l[t]=l[i-1]),i--)}let h=l.slice(0,i);h.sort((t,e)=>t.value()<e.value()?-1:+(t.value()>e.value()));for(let t=0;t<i;++t)l[t]=h[t];return i}return function(t,e,i,r,o,a){let l=(0,n.m)(n.Z,3),h=0,m=e.negate().divThisE(t.clone().mulThis(3));o.containsCoordinate(m.value())&&(l[0].setE(m),h=1);let u=(0,n.m)(n.Z,2),d=Lt(t.mul(3),e.mul(2),i,o,!1,u);if(d<0)return r.isZero()?-1:0;for(let t=0;t<d;t++)o.containsCoordinate(u[t].value())&&l[h++].setE(u[t]);(0,n.a5)(l,0,h,(t,e)=>t.value()<e.value()?-1:+(t.value()>e.value()));let g=(0,n.m)(n.Z,5);g[0].set(o.vmin);for(let t=0;t<h;t++)g[1+t].setE(l[t]);g[1+h].set(o.vmax);let c=h+2,_=1,p=0;{let s=g[0].clone();if(t.clone().mulThisE(s).addThisE(e).mulThisE(s).addThisE(i).mulThisE(s).addThisE(r).isZero()){let n=Bt(t,e,i,r);s.setError(n.estimateError(s.value())),a[p]=s,p++,_++}}for(let n=_;n<c;n++){let l=g[n].clone(),h=t.clone().mulThisE(l).addThisE(e).mulThisE(l).addThisE(i).mulThisE(l).addThisE(r).isZero();if(h||!g[n].eq(g[n-1])){if(h||Zt(g[n-1].value(),g[n].value(),g[n-1].clone().addThisE(g[n]).divThisByPower2(2),t,e,i,r,l)){if(p>0&&l.eq(a[p-1]))continue;if(p>=3&&(0,s.d)("cubic_polynomial_solver_too_many_roots"),h){let s=Bt(t,e,i,r);l.setError(s.estimateError(l.value()))}a[p]=l,p++}if(g[n].value()===o.vmax)break;if(h){n++;continue}}}return p}(t,e,i,r,o,l)}function Vt(t,e,i,r,o,a){return(a<e||e<0)&&(0,s.a)("nth_degree_real_roots"),function(t,e,i,s,r){let o=new kt(t,e,i,(0,n.I)()),a=0;if(2===o.truePower)a=Lt(t[2],t[1],t[0],i,s,r);else if(1===o.truePower)a=Ft(t[1],t[0],i,r[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{let t=[];t.length=e,a=It(o,i,e,t);for(let e=0;e<a;e++)r[e].set(t[e])}}for(let t=0;t<a;t++)r[t].setError(o.getError(r[t].value()));return a}(t,e,i,r,o)}function Bt(t,e,i,s){return{coef0:t.clone(),coef1:e.clone(),coef2:i.clone(),coef3:s.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){let e=Math.abs(t),i=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),s=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(s.isZero()){let e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){let t=this.coef0.clone().mulThis(6);return(6*i/Math.abs(t.value()))**(1/3)}return Math.sqrt(2*i/Math.abs(e.value()))}return i/Math.abs(s.value())}}}class kt{coefs;derivCoefs1=[];derivCoefs2=[];lastDeriv1=-1;lastDeriv2=-1;lastUsed=-1;curCoefs=null;power;truePower;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 i=0,s=this.truePower-t;i<=s;++i){e.push(this.coefs[i+t].clone());let s=i+t,r=s--;for(let e=1;e<t;e++)r*=s--;e[i].mulThis(r)}this.curCoefs=e}constructor(t,e,i,s){this.coefs=t,this.power=e,this.truePower=0;for(let t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let i=this.coefs;0===t?i=this.coefs:(this.updateCoefs(t),i=this.curCoefs);let s=new n.K(0),r=1;for(let n=0,o=this.truePower-t;n<=o;++n)s.pe(r*i[n].value()),r*=e;return s.getResult()}getError(t){let e=Math.abs(t),i=new n.K(0),s=new n.Z(1),r=new n.Z(0);for(let t=0,n=this.power;t<=n;++t)r.addThisE(this.coefs[t].mulE(s)),i.pe(s.value()*this.coefs[t].eps()),s.mulThis(e);i.pe(r.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);let s=new n.Z(1),r=new n.Z(0);for(let i=0,n=this.truePower-e;i<=n;++i)r.addThisE(this.curCoefs[i].mulE(s)),s.mulThis(t);if(!r.isZero())return(o*i.getResult()/Math.abs(r.value()))**(1/e)}return 0}}function Gt(t,e,i,s,r,o){let a=t,l=e,h=l-a;if(!o){let i=s.calcF(t).value(),r=s.calcF(e).value();if((i>0||i>r)&&(l=(0,n.c)(a,a=l),r=(0,n.c)(i,i=r)),i>=0||r<=0)return!1}let m,u=!1,d=i,g=0;for(;g<100;g++){let t=s.calcF(d);if(m=s.calcDF(d),m.isZero())return!1;if(!t.value()||g>3&&t.isZero()){u=!0;break}o||(t.value()<0?a=d:l=d);let e=t.value()/m.value(),i=d-e;o||(i>=a&&i<=l||i>=l&&i<=a)&&Math.abs(e)<=.5*h?(d=i,h=Math.abs(e)):(h=Math.abs(.5*(l-a)),d=.5*(a+l))}return!!u&&(r.set(d,s.estimateError(d)),!0)}function Zt(t,e,i,s,r,n,o,a){return Gt(t,e,i.value(),Bt(s,r,n,o),a,!1)}class Ht{coefs=(0,n.m)(n.Z,3);constructor(t,e,i){this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(i)}calcF(t){let e=new n.Z(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){let e=new n.Z(t);return n.Z.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){let e=Math.abs(t),i=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),s=new n.Z(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(s.isZero()){let t=this.coefs[0].value();return Math.sqrt(i/Math.abs(t))}return i/Math.abs(s.value())}}function Wt(t,e,i,s,r){return Gt(0,0,t.value(),new Ht(e,i,s),r,!0)}var jt=r.V;class Ut extends Q{static type=s.G.enumRationalBezier2;m_cp;m_weights;m_cachedValues;constructor(t){return void 0===t||(0,n.af)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(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)&&(0,s.a)("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(0,s.t)("unexpected constructor param"))}getBoundary(){return At(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,i,s){this.dropAllAttributes(),this.setCpsAndWeights(t,e,i,1,s,1),As(this)}constructWeights(t,e,i,s,r,n){this.dropAllAttributes(),this.setCpsAndWeights(t,e,i,s,r,n),As(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),As(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return s.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o.Envelope2D){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;let e=Bs(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i)}else{let e=[],i=(0,n.m)(n.P,3);this.queryControlPoints(i),Is(i,this.m_weights,e);let s=new n.P;for(let i of e)this.queryCoord2D(i,s),t.mergeNe(s)}}}applyTransformation(t){if(t instanceof a.T){let e=(0,n.m)(n.P,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 Ut({vd:this.m_description})}calculateLength2D(){return Ms(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return this.m_weights[1]>0?n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp):n.P.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){!function(t,e,i){let s=(0,n.m)(n.P,3);t.queryControlPoints(s);let r=[0,0,0];t.queryWeights(r),function(t,e,i,s){if(0===i.value())return void s.setE(t[0]);if(1===i.value())return void s.setE(t[2]);let r=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],o=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],a=[e[0].clone(),e[1].clone(),e[2].clone()],l=new n.Z,h=new n.Z,m=new n.Z;if(i.value()<=.5){let t=(0,n.az)(r[0],r[1],i),e=(0,n.az)(r[1],r[2],i);l.setE((0,n.az)(t,e,i));let s=(0,n.az)(o[0],o[1],i),u=(0,n.az)(o[1],o[2],i);h.setE((0,n.az)(s,u,i));let d=(0,n.az)(a[0],a[1],i),g=(0,n.az)(a[1],a[2],i);m.setE((0,n.az)(d,g,i))}else{let t=(0,n.aA)(r[0],r[1],i),e=(0,n.aA)(r[1],r[2],i);l.setE((0,n.aA)(t,e,i));let s=(0,n.aA)(o[0],o[1],i),u=(0,n.aA)(o[1],o[2],i);h.setE((0,n.aA)(s,u,i));let d=(0,n.aA)(a[0],a[1],i),g=(0,n.aA)(a[1],a[2],i);m.setE((0,n.aA)(d,g,i))}l.divThisE(m),h.divThisE(m);let u=new n.P(l.value(),h.value());fr([t[0].value(),t[1].value(),t[2].value()],u),s.x.set(u.x,l.eps()),s.y.set(u.y,h.eps())}([x.constructPoint2D(s[0]),x.constructPoint2D(s[1]),x.constructPoint2D(s[2])],[new n.Z(r[0]),new n.Z(r[1]),new n.Z(r[2])],e,i)}(this,t,e)}queryCoord2DExtension(t,e,i){if(i){if(t<0)return void J(new Yn({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void J(new Yn({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}let s=(0,n.m)(n.P,3);this.queryControlPoints(s),mr(s,this.m_weights,t,e)}getCoordX(t){let e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){let e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=jt.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=jt.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){!function(t,e,i){let r=(0,n.m)(n.P,3);t.queryControlPoints(r);let o=(0,n.d)(3,NaN);t.queryWeights(o),function(t,e,i,r){i.value()<0&&i.set(0,i.eps()),i.value()>1&&i.set(1,i.eps());let o=(0,n.m)(x,4);(function(t,e,i,r,o){let a=[x.constructPoint2D(t[0]),x.constructPoint2D(t[1]),x.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,i,r,o){(0,s.g)(!0);let a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=x.constructCoords(0,0)}let l=Ys(a,e,0,r),h=function(t,e,i){if(i.toDouble()<=.5){let e=(0,n.az)(t[0],t[1],i),s=(0,n.az)(t[1],t[2],i);return(0,n.az)(e,s,i)}{let e=(0,n.aA)(t[0],t[1],i),s=(0,n.aA)(t[1],t[2],i);return(0,n.aA)(e,s,i)}}(e,0,r),m=l.divE(h);o[0].setE(m);let u=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],d=Ys([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,r).mul(2),g=h.sqr(),c=d.divE(g);o[1].setE(c)}(a,[new n.Z(e[0]),new n.Z(e[1]),new n.Z(e[2])],0,r,o)})(t,e,0,i,o),r.setE(o[1])}(r,o,e,i)}(this,t,e)}cutBezierIgnoreAttributes(t,e,i){(t<0||e>1||t>e)&&(0,s.a)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");let r=(0,n.m)(n.P,3);this.queryControlPoints(r);let o=[0,0,0];Ks(r,this.m_weights,t,e,r,o),i.setControlPointsAndWeights(r,o)}splitBezierIgnoreAttributes(t,e,i){}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=jt.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(o,a,l,r,jt.getDefaultValue(e))}getClosestCoordinate(t,e){return Gs(this,t,n.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,i=-1){return Gs(this,t,0,!1,i)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.a)("");let i=Ts(this),r=0;if(2===i.specialPointsCount())return 0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)Us(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){i&&(i.length=9),s&&(s.length=9);let r=[,,,],o=(0,n.m)(n.Z,2),a=new n.E(0,1),l=0,h=(0,n.m)(n.P,3);if(this.queryControlPoints(h),t){if(r[0]=new n.Z(h[0].y).sub(e).mul(this.m_weights[0]),r[1]=new n.Z(h[1].y).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.Z(h[2].y).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.Z(h[0].x).sub(e).mul(this.m_weights[0]),r[1]=new n.Z(h[1].x).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.Z(h[2].x).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordY(o[t].value());if(s)for(let t=0;t<l;t++)s[t]=o[t].value();else i&&(0,n.a5)(i,0,l,n.X);return l}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[NaN,NaN],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isDegenerate(t){return w(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o.Envelope2D)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);let i=n.E.constructEmpty();return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.m)(n.P,3);this.queryControlPoints(i),Ks(i,this.m_weights,t.vmin,t.vmax,i,[0,0,0]),e.setFromPoints(i,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp.isEqual(this.m_XStart,this.m_YStart),s=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp.setCoordsPoint2D(t):s&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Ms(this,t,!0)}lengthToT(t){return function(t,e){let i=Ms(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;let r=[0];return 1!==It(new Ls(t,e),n.E.unit(),1,r)&&(0,s.d)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=function(t){let e=(0,n.m)(n.P,3),i=[0,0,0];return t.queryControlPoints(e),t.queryWeights(i),function(t,e){let i=dr(e);if(1===i){let e=(0,n.m)(n.P,3);Oe(t,e);let i=e[2].clone(),s=e[1].clone(),r=new n.P,o=i.y*s.x-i.x*s.y;return r.x=-(4*i.x+5*s.x)*o/60,r.y=-(4*i.y+5*s.y)*o/60,r}if(0===i)return new n.P(0,0);(0,s.g)(i>0);let r=t[1].sub(t[0]),o=t[2].sub(t[0]);if(i<1){let t=Math.sqrt(1-i),e=Math.sqrt(1+i),s=(r.y*o.x-r.x*o.y)*i/(t*e)**5/12,n=Math.atan2(t,e),a=i*t*e,l=i*i,h=r.mul(2*(2+l)),m=o.mul(2*l-5),u=h.add(m).mul(a),d=o.sub(r.mul(2*l)).mul(6*n);return u.add(d).mul(s)}{let t=Math.sqrt(i-1),e=Math.sqrt(i+1),s=(r.y*o.x-r.x*o.y)*i/(t*e)**5/12,n=Math.atanh(t/e),a=i*t*e,l=i*i,h=r.mul(4).sub(o.mul(5)),m=r.add(o).mul(2*l),u=h.add(m).mul(a),d=o.sub(r.mul(2*l)).mul(6*n);return u.add(d).mul(s)}}(e,i)}(this),i=zs(this);return e.x+=(this.getStartX()-t.x)*i,e.y+=(this.getStartY()-t.y)*i,e}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){if(0===t.m_weights[1])return!0;let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=2**-52*8*i}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.a)("calculate_sub_weighted_centroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=Ts(t),a=Vs(t),l=a/t.calculateUpperLength2D(),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),n=Ss(t,h,s,l,a);if(r.addThis(n),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(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){let i=(0,n.m)(n.P,3);return this.queryControlPoints(i),function(t,e,i,s){let r=i.lte(n.ar)?n.M.lerpLo:n.M.lerpHi,[o,a,l]=[e.map((e,i)=>t[i].x.mul(e)),e.map((e,i)=>t[i].y.mul(e)),e].map(([t,e,s])=>r(r(t,e,i),r(e,s,i),i)),h=new n.P(o.divThis(l).value(),a.divThis(l).value());fr(t.map(t=>t.asPoint2D()),h),s.x=n.M.constructDouble(h.x),s.y=n.M.constructDouble(h.y)}(i.map(t=>C.constructPoint2D(t)),this.m_weights.map(t=>n.M.constructDouble(t)),n.M.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){let e=(0,n.m)(n.P,3);return this.queryControlPoints(e),Fs(e,this.m_weights,t)}getDerivative(t){let e=(0,n.s)(t,0,1),i=(0,n.m)(n.P,4);return qs(this,1,e,i),i[1]}getCurvature(t){let e=(0,n.m)(n.P,4);qs(this,2,t,e);let i=e[1].sqrLength();return 0===i?NaN:(e[1].divThis(Math.sqrt(i)),e[1].crossProduct(e[2])/i)}isIntersecting(t,e,i){return!1}isIntersectingPoint(t,e,i){return!1}isIntersectingPoint3D(t,e,i,s,r=1){return!1}isMonotoneQuickAndDirty(){let t=(0,n.m)(n.P,3);return this.queryControlPoints(t),js(t)}getMonotonicPartParams(t,e){let i=Ts(this),r=i.specialPointsCount();if(!e)return i.specialPointsCount();t<r&&(0,s.a)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.c)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,n.c)(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]=(0,n.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=e[2].sub(e[0]),s=i.length();if(n.P.distance(e[0],e[1])+n.P.distance(e[2],e[1])-s>t)return!1;let r=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(i))/s>r)}copyIgnoreAttributes(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=[0,0,0];this.queryWeights(i),t.setControlPointsAndWeights(e,i)}calculateArea2DHelper(){return zs(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,s.g)(0),0}queryEnvelopeW(t,e){Hs(this,t,e)}setSegmentFromCoordsForStitcher(t,e){let i=[0,0,0];this.queryWeights(i),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],i[0],i[1],i[2])}writeInBufferStream(t,e){let i=new Float64Array(5);return i[0]=this.m_cp.x,i[1]=this.m_cp.y,i[2]=this.m_weights[0],i[3]=this.m_weights[1],i[4]=this.m_weights[2],t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(5);t.queryRange(e,i.length,i,!0,1),this.m_cp.x=i[0],this.m_cp.y=i[1],this.m_weights[0]=i[2],this.m_weights[1]=i[3],this.m_weights[2]=i[4],this.m_cachedValues=null}snapControlPoints(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=n.P.sqrDistance(e[1],e[0]),s=n.P.sqrDistance(e[1],e[2]),r=e[0].clone(),o=i;i>s&&(r=e[2].clone(),o=s);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(r)),a}needsSnapControlPoints(t){if(!t)return!1;let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=n.P.sqrDistance(e[1],e[0]),s=n.P.sqrDistance(e[1],e[2]);e[0].clone();let r=i;return i>s&&(e[2].clone(),r=s),r<=t&&0!==r}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Us(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.m)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformInPlace(t.m_cp):(0,n.J)(e,i,.5,t.m_cp),t.changeEndPoints2D(e,i),r&&Us(t)}(this,t,e,i)}copyToImpl(t){let 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],ks(e,Bs(this))}reverseImpl(){this.m_weights[2]=(0,n.c)(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){let e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let t=0;t<3;t++)if(this.m_weights[t]!==e.m_weights[t])return!1;return!0}equalsImplTol(t,e){let i=t;if(!this.m_cp.isEqualPoint2D(i.m_cp,e))return!1;let s=(0,n.m)(n.P,3);this.queryControlPoints(s);let o=(0,n.m)(n.P,3);i.queryControlPoints(o);let a=[i.m_weights[0],i.m_weights[1],i.m_weights[2]];for(let t=0;t<3;t++){let i=new r.k;i.setCoordsPoint2DZ(s[t].mul(this.m_weights[t]),this.m_weights[t]);let n=new r.k;if(n.setCoordsPoint2DZ(o[t].mul(a[t]),a[t]),!i.isEqual(n,e))return!1}return!0}swapImpl(t){let e=t;e.m_cp=(0,n.c)(this.m_cp,this.m_cp=e.m_cp),e.m_weights=(0,n.c)(this.m_weights,this.m_weights=e.m_weights),function(t,e){e.m_cachedValues=(0,n.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){As(this)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,r){let o=new p;if(Hs(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;let a=Ts(t),l=0,h=[],m=a.specialPoints[0];for(let i=1,r=a.specialPoints.length;i<r;++i){let r=a.specialPoints[i],n=ws(t,e,m,r);if(0===h.length)h.push(n);else if(n.t===n.tmin)(0,s.g)(h.at(-1).d<=n.d),h.at(-1).tmax=n.tmax;else if(h.at(-1).t===h.at(-1).tmax){(0,s.g)(h.at(-1).d>=n.d);let t=h.at(-1).tmin;h[h.length-1]=n,h.at(-1).tmin=t}else h.push(n);m=r}for(let t of h)if(t.d<=r){let e=t.t;i&&(i[l]=e),l++}return l}(this,t,e,i)}endPointModified(){As(this)}clearEndPointModified(){}setCpsAndWeights(t,e,i,r,n,o){(r<=0||o<=0||n<0)&&(0,s.a)("weights"),(t.isNAN()||e.isNAN()||i.isNAN())&&(0,s.a)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=r,this.m_weights[1]=n,this.m_weights[2]=o,this.setEndXY(i)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}var Ot=r.V;class Qt extends Q{static type=s.G.enumBezier2;constructor(t){void 0===t||(0,n.af)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(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()):(0,s.d)("unexpected constructor args")}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,i){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(i),Ee(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),Ee(this)}getGeometryType(){return s.G.enumBezier2}queryEnvelope(t){if(2===t.m_EnvelopeType){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;let e=Re(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i)}else{let e=[];De(this,e);let i=new n.P;for(let s of e)this.queryCoord2D(s,i),t.mergeNe(i)}return}(0,s.t)("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){let e=(0,n.m)(n.P,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()}(0,s.g)(0)}createInstance(){return new Qt({vd:this.m_description})}calculateLength2D(){return we(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,i){let s=(0,n.m)(n.P,3);this.queryControlPoints(s),Ke(s,t,e,i)}queryCoord2DE(t,e){!function(t,e,i){let s=(0,n.m)(n.P,3);t.queryControlPoints(s),function(t,e,i){if(e.value()<=.5){let s=x.constructPoint2D(t[1]),r=new x;(0,n.ao)(2,x.constructPoint2D(t[0]),s,e,r);let o=new x;(0,n.ao)(2,s,x.constructPoint2D(t[2]),e,o);let a=new x;(0,n.ao)(2,r,o,e,a),i.setE(a)}else{let s=x.constructPoint2D(t[1]),r=new x;(0,n.ap)(2,x.constructPoint2D(t[0]),s,e,r);let o=new x;(0,n.ap)(2,s,x.constructPoint2D(t[2]),e,o);let a=new x;(0,n.ap)(2,r,o,e,a),i.setE(a)}}(s,e,i)}(this,t,e)}queryCoord2DMP(t,e){(0,s.g)(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){let e=(0,n.ag)(this.getStartX(),this.m_cp.x,t),i=(0,n.ag)(this.m_cp.x,this.getEndX(),t);return(0,n.ag)(e,i,t)}{let e=(0,n.ah)(this.getStartX(),this.m_cp.x,t),i=(0,n.ah)(this.m_cp.x,this.getEndX(),t);return(0,n.ah)(e,i,t)}}getCoordY(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){let e=(0,n.ag)(this.getStartX(),this.m_cp.x,t),i=(0,n.ag)(this.m_cp.x,this.getEndX(),t);return(0,n.ag)(e,i,t)}{let e=(0,n.ah)(this.getStartY(),this.m_cp.y,t),i=(0,n.ah)(this.m_cp.y,this.getEndY(),t);return(0,n.ah)(e,i,t)}}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=Ot.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=Ot.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){!function(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),function(t,e,i){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),i.setE(function(t,e,i){{let e=x.constructPoint2D(t[1]).subE(x.constructPoint2D(t[0])),s=new n.Z(1).subE(i),r=x.constructPoint2D(t[2]).subE(x.constructPoint2D(t[1])),o=e.mulE(s).addE(r.mulE(i));return o.mulThisE(new n.Z(2)),o}}(t,0,e))}(s,e,i)}(this,t,e)}cutBezierIgnoreAttributes(t,e,i){if((t<0||e>1||t>e)&&(0,s.a)("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return i.setStartXY(this.getStartXY()),i.m_cp.assign(this.m_cp),void i.setEndXY(this.getEndXY());let r=(0,n.m)(n.P,3);this.queryControlPoints(r),Ge(r,t,e,r),i.constructPoints(r)}splitBezierIgnoreAttributes(t,e,i){(0,s.g)(0)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=Ot.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(o,a,l,r,Ot.getDefaultValue(e))}getClosestCoordinate(t,e){return Xe(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,i=-1){return Xe(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.a)("");let i=be(this),r=0;if(2===i.specialPointsCount())return 0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)Ve(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){let r=(0,n.m)(n.Z,3),o=(0,n.m)(n.Z,2),a=new n.E(0,1),l=0;if(t){if(r[0]=new n.Z(this.getStartY()).sub(e),r[1]=new n.Z(this.m_cp.y).subE(new n.Z(this.getStartY())).mulThisByPower2(2),r[2]=new n.Z(this.getStartY()).add(this.getEndY()).subE(new n.Z(this.m_cp.y).mulThisByPower2(2)),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.Z(this.getStartX()).sub(e),r[1]=new n.Z(this.m_cp.x).subE(new n.Z(this.getStartX())).mulThisByPower2(2),r[2]=new n.Z(this.getStartX()).add(this.getEndX()).subE(new n.Z(this.m_cp.x).mulThisByPower2(2)),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordY(o[t].value());if(s)for(let t=0;t<l;t++)s[t]=o[t].value();else i&&(0,n.ai)(i,l);return l}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return w(this,t)}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,s.g)(0)}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=new o.Envelope2D;this.queryEnvelope(t);let i=new n.E;return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.m)(n.P,4);this.queryControlPoints(i),Ge(i,t.vmin,t.vmax,i),e.setFromPoints(i,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp.isEqual(this.m_XStart,this.m_YStart),s=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp.setCoordsPoint2D(t):s&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return we(this,t,!0)}lengthToT(t){return function(t,e){let i=we(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;let r=[0];return 1!==It(new ve(t,e),n.E.unit(),1,r)&&(0,s.d)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=(0,n.m)(n.P,3);!function(t,e,i=!1){let s=(0,n.m)(n.P,3);t.queryControlPoints(s),Oe(s,e,i)}(this,e);let i=e[2],s=e[1],r=new n.P,o=i.y*s.x-i.x*s.y;r.x=-(4*i.x+5*s.x)*o/60,r.y=-(4*i.y+5*s.y)*o/60;let a=qe(this);return r.x+=(e[0].x-t.x)*a,r.y+=(e[0].y-t.y)*a,r}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=2**-52*8*i}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.a)("calculate_sub_weighted_centroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=be(t),a=B(t),l=Math.min(a/t.calculateUpperLength2D(),1e-7),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),n=Ce(t,h,s,l,a);if(r.addThis(n),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(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 e=0;e<3;e++)t[e].isNAN()&&(0,s.a)("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){let e=(0,n.s)(t,0,1),i=Ie(this,1,e);return i.isZero()&&(i=Ie(this,2,e),1===e&&i.negateThis()),i}getDerivative(t){return Ie(this,1,(0,n.s)(t,0,1))}getCurvature(t){let e=Ie(this,1,t),i=Ie(this,2,t),s=e.sqrLength();return 0===s?NaN:(e.divThis(Math.sqrt(s)),e.crossProduct(i)/s)}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}isIntersectingPoint(t,e,i){if(i&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;let s=new o.Envelope2D;if(this.queryLooseEnvelope(s),s.inflateCoords(e,e),!s.contains(t))return!1;let r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){let i=be(this),r=i.specialPointsCount();if(!e)return i.specialPointsCount();t<r&&(0,s.a)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){(0,n.c)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,n.c)(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]=(0,n.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=e[2].sub(e[0]),s=i.length();if(n.P.distance(e[0],e[1])+n.P.distance(e[2],e[1])-s>t)return!1;let r=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(i))/s>r)}copyIgnoreAttributes(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return qe(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1);var t}queryEnvelopeW(t,e){let i=(0,n.m)(n.P,3);this.queryControlPoints(i),Le(i,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return function(t,e){let i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=n.P.sqrDistance(i[1],i[0]),r=n.P.sqrDistance(i[1],i[2]),o=i[0].clone(),a=s;s>r&&(o=i[2].clone(),a=r);let l=!1;return a<=e&&0!==a&&(l=!0,t.setControlPoint1(o)),l}(this,t)}writeInBufferStream(t,e){let i=new Float64Array(2);return i[0]=this.m_cp.x,i[1]=this.m_cp.y,t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(2);t.queryRange(e,i.length,i,!0,1),this.m_cp.x=i[0],this.m_cp.y=i[1],this.m_cachedValues=null}needsSnapControlPoints(t){return function(t,e){if(!e)return!1;let i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=n.P.sqrDistance(i[1],i[0]),r=n.P.sqrDistance(i[1],i[2]);i[0].clone();let o=s;return s>r&&(i[2].clone(),o=r),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ve(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.m)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformInPlace(t.m_cp):(0,n.J)(e,i,.5,t.m_cp),t.changeEndPoints2D(e,i),r&&Ve(t)}(this,t,e,i)}copyToImpl(t){let e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Ye(e,Re(this))}reverseImpl(){}equalsImplTol(t,e){let i=t;return!!this.m_cp.isEqualPoint2D(i.m_cp,e)}equalsImpl(t){let e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){let e=t;e.m_cp=(0,n.c)(this.m_cp,this.m_cp=e.m_cp),function(t,e){e.m_cachedValues=(0,n.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Ee(this)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,s,r){let o=new p;if(function(t,e,i){let s=(0,n.m)(n.P,3);t.queryControlPoints(s),Le(s,e,i)}(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;let a=new n.P,l=Xe(t,e,n.E.unit(),!1);return t.queryCoord2D(l,a),n.P.distance(a,e)<=r?(s&&(s[0]=l),1):0}(this,t,e.length,e,i)}endPointModified(){Ee(this)}clearEndPointModified(){}m_cp;m_cachedValues}class Kt{m_elements;m_zeroCtor;constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),(0,s.g)(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){let i=e;i.subThis(t);let s=this.power();for(let e=0;e<=s;e++){let r=new this.m_zeroCtor;for(let i=e;i<=s;i++){let s=this.m_elements[i];s.mulDoubleThis((0,n.aJ)(i,e));let o=t.pow(i-e);s.mulThis(o),r.addThis(s)}let o=i.pow(e);r.mulThis(o),this.m_elements[e]=r}}fmSubThis(t,e){return(0,s.g)(0),this}addThis(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].addThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return(0,s.g)(0),this}sub(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s].clone(),this.m_elements[s].negateThis();return this.updatePower(),this}sub0(t){return(0,s.g)(0),this}subNumber0(t){return(0,s.g)(0),this}subShifted(t,e){let i=this.power(),s=t.power()+e,r=Math.min(this.power(),s),n=0;for(let i=e;i<=r;++i)this.m_elements[i].subThis(t.m_elements[n]),n++;if(s<=i)return this.updatePower(),this;this.m_elements.length=s+1;for(let t=i+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=r+1;e<=s;++e)this.m_elements[e].subThis(t.m_elements[n++]);return this.updatePower(),this}subShiftedWithCoef(t,e,i){let s=this.power(),r=t.power()+i,n=Math.min(this.power(),r),o=0;for(let s=i;s<=n;++s)this.m_elements[s].fmSubThis(t.m_elements[o],e),o++;if(r<=s)return this.updatePower(),this;this.m_elements.length=r+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let i=n+1;i<=r;++i)this.m_elements[i].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){let e=t,i=[];for(let t=0,s=this.power();t<=s;t++)for(let s=0,r=e.power();s<=r;s++){let r=this.m_elements[t].clone();r.mulThis(e.m_elements[s]),t+s<i.length?i[t+s].addThis(r):i.push(r)}this.m_elements=i}else for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulDoubleThis(t){for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulDoubleThis(t);return this.updatePower(),this}mulNumber0(t){return(0,s.g)(0),this}mulBigint0(t){return(0,s.g)(0),this}mulBigIntThis(t){return(0,s.g)(0),this}mulInt320(t){return(0,s.g)(0),this}div0(t){return(0,s.g)(0),this}absThis(){return(0,s.g)(0),this}div(t,e,i){if(this.power()<t.power())return i.assignCopy(this),void e.setZero();i.setZero(),e.setZero();let s=t.getElement(t.power()),r=this.clone(),o=r.power(),a=r.power()-t.power(),l=a;for(e.m_elements=(0,n.m)(e.m_zeroCtor,a+1);;){if(o<t.power()){i.assignMove(r);break}if(o===r.power()){let i=r.getElement(r.power());i.divThis(s),r.subShiftedWithCoef(t,i,r.power()-t.power()),e.m_elements[l]=i.clone()}l--,o--}i.updatePower(),e.updatePower()}divThis(t){return(0,s.g)(0),this}subThis(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s].clone(),this.m_elements[s].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){(0,s.g)(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){let e=this.power(),i=this.m_elements[e].clone();for(let s=e-1;s>=0;--s)i.mulThis(t),i.addThis(this.m_elements[s]);return i}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();let e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let i=t,s=this.power();i<=s;i++){let s=BigInt(i);for(let e=i-1,r=i-t;e>r;--e)s*=BigInt(e);e.m_elements[i-t].mulBigIntThis(s)}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(n.M.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)=>{let i=e.hiBitIndex();return t<i?i:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}evaluateDerivative(t){let e=this.power(),i=this.m_elements[e];i.mulDoubleThis(e);for(let s=e-1;s>=1;--s){i.mulThis(t);let e=this.m_elements[s];e.mulDoubleThis(s),i.addThis(e)}return i}static evaluateCoefs(t,e,i){let s=t.power();i.construct0(t.getElement(0).evaluate(e));for(let r=1;r<=s;++r)i.addElement(t.getElement(r).evaluate(e));i.updatePower()}}class Jt extends Kt{constructor(t){super(void 0===t?{zeroCtor:n.M}:{...t,zeroCtor:n.M})}clone(){return new Jt({copy:this})}absEvaluate(t){let e=this.power(),i=this.m_elements[e].clone();i.absThis();let s=t.clone();s.absThis();for(let t=e-1;t>=0;--t)i.mulThis(s),i.addThis(this.m_elements[t].abs());return i}}class $t extends Kt{constructor(t){super(void 0===t?{zeroCtor:Jt}:{...t,zeroCtor:Jt})}clone(){return new $t({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let i=0;i<=e;++i)this.m_elements.push(new Jt({coef0:t[i]}));return this.updatePower(),this}}function te(t,e,i,r,o,a,l,h,m,u,d,g,c,_,p,f,y,P,x,v=!1){let C={polypoly1:new $t,polypoly2:new $t,polyX2:new Jt,polyY2:new Jt,polyX2Deriv:new Jt,polyY2Deriv:new Jt,polypolyX1:new $t,polypolyY1:new $t,polypolyX1Deriv:new $t,polypolyY1Deriv:new $t,lazyPolypolyD1:new $t,lazyPolypolyD1Deriv:new $t,lazyPolyD2:new Jt,lazyPolyD2Deriv:null,polypoly11:new $t,polypoly12:new $t,tempPp:new $t,tempPp1:new $t,tempPp2:new $t,tempP:new Jt,tempP1:new Jt,tempP2:new Jt};C.polyX2.construct(l,h),C.polyY2.construct(m,u),C.polypolyX1.constructFromMPValues(t,e),C.polypolyY1.constructFromMPValues(i,r),C.polypoly11.assignCopy(C.polypolyX1),C.polypoly12.assignCopy(C.polypolyY1),d&&(C.lazyPolyD2.construct(d,g),C.polypoly11.mulElementThis(C.lazyPolyD2),C.polypoly12.mulElementThis(C.lazyPolyD2)),o?(C.lazyPolypolyD1.constructFromMPValues(o,a),C.lazyPolypolyD1Deriv=new $t({copy:C.lazyPolypolyD1}),C.lazyPolypolyD1Deriv.derivative1This(),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyX2),C.polypoly11.subThis(C.tempPp),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyY2),C.polypoly12.subThis(C.tempPp)):(C.polypoly11.sub0This(C.polyX2),C.polypoly12.sub0This(C.polyY2)),C.polypolyX1Deriv.assignCopy(C.polypolyX1),C.polypolyX1Deriv.derivative1This(),C.polypolyY1Deriv.assignCopy(C.polypolyY1),C.polypolyY1Deriv.derivative1This(),o&&(C.polypolyX1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyX1),C.polypolyX1Deriv.subThis(C.tempPp2),C.polypolyY1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyY1),C.polypolyY1Deriv.subThis(C.tempPp2)),C.polyX2Deriv.assignCopy(C.polyX2),C.polyX2Deriv.derivative1This(),C.polyY2Deriv.assignCopy(C.polyY2),C.polyY2Deriv.derivative1This(),d&&((0,s.g)(null===C.lazyPolyD2Deriv),C.lazyPolyD2Deriv=new Jt({copy:C.lazyPolyD2}),C.lazyPolyD2Deriv.derivative1This(),C.polyX2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyX2),C.polyX2Deriv.subThis(C.tempP1),C.polyY2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyY2),C.polyY2Deriv.subThis(C.tempP1)),C.polypoly1.assignCopy(C.polypoly11),C.polypoly1.mulElementThis(C.polyX2Deriv),C.tempPp.assignCopy(C.polypoly12),C.tempPp.mulElementThis(C.polyY2Deriv),C.polypoly1.addThis(C.tempPp),C.polypoly2.assignCopy(C.polypolyX1Deriv),C.polypoly2.mulElementThis(C.polyY2Deriv),C.tempPp.assignCopy(C.polypolyY1Deriv),C.tempPp.mulElementThis(C.polyX2Deriv),C.polypoly2.subThis(C.tempPp);let E=[],b=[];y||=[],f||=[],le(C.polypoly11,C.polypoly12,C.tempP);let D=n.ae.ldexp(-59).toDouble(),w=[],S=he(C.tempP,0,p,D,64,w,P,P);if(S<0)return-1;for(let t=0;t<S;t++){let e=C.tempP1,i=C.tempP2;Jt.evaluateCoefs(C.polypoly11,w[t],e);let r=(0,n.aE)(e.m_elements,e.power()+1);r.sort((t,e)=>t.compare(e)),Jt.evaluateCoefs(C.polypoly12,w[t],i);let o=(0,n.aE)(i.m_elements,i.power()+1);o.sort((t,e)=>t.compare(e));let a=r[0],l=r.at(-1),h=o[0],m=o.at(-1);l.subThis(a),m.subThis(h);let u,d=l.subThis(m).GEZ(),g=[];if(u=he(d?e:i,0,_,n.ae.ldexp(-59).toDouble(),58,g,P,P),u<0&&(0,s.d)("mp_curve_proximity"),u>0){let r=d?i:e;for(let e=0;e<u;e++){let i;if(d){let s=C.tempP;Jt.evaluateCoefs(C.polypoly12,w[t].addDouble(2**-52),s),i=s.evaluate(g[e])}else{let s=C.tempP;Jt.evaluateCoefs(C.polypoly11,w[t].addDouble(2**-52),s),i=s.evaluate(g[e])}let o=r.evaluateDerivative(g[e]).abs().mulDoubleThis(2**-52),a=r.evaluate(g[e]);o.addThis(i.sub(a).absThis()),o.ldexpThis(3),a.absThis(),a.lt(o)?b.push((0,n.o)(g[e].toDouble(),w[t].toDouble())):(0,s.g)(a.gte(o))}}}S=b.length,le(C.polypoly1,C.polypoly2,C.tempP);let A=[],T=he(C.tempP,0,p,D,64,A);T<0&&(T=0);for(let t=0;t<T;t++){Jt.evaluateCoefs(C.polypoly1,A[t],C.tempP1);let e=[],i=he(C.tempP1,0,_,D,64,e);if(0!==i)if(Jt.evaluateCoefs(C.polypoly2,A[t],C.tempP2),i<0){if(i=he(C.tempP2,0,_,D,64,e),i<0)continue;for(let s=0;s<i;s++)E.push((0,n.o)(e[s].toDouble(),A[t].toDouble()))}else{let s=C.tempP2.absEvaluate(n.ae);s.mulThis(n.M.constructDouble(1e-12));for(let r=0;r<i;r++){let i=C.tempP2.evaluate(e[r]);i.absThis(),i.lt(s)&&E.push((0,n.o)(e[r].toDouble(),A[t].toDouble()))}}}if(T=E.length,0===S&&0===T)return 0;E=E.concat(b),E.sort((t,e)=>v?(0,n.X)(t.second,e.second):(0,n.X)(t.first,e.first));let I=(0,n.v)(E,(t,e)=>t.first===e.first&&t.second===e.second);E=E.slice(0,I),f.length=0,y.length=0;for(let t of E)f.push(t.first),y.push(t.second);return(0,s.g)(f.length===y.length),y.length}function ee(t,e,i,s,r,o,a,l,h,m,u,d,g){let c={polyIntersect:new Jt,polyX1:new Jt,polyY1:new Jt,polyX1Deriv:new Jt,polyY1Deriv:new Jt,lazyPolyD1:new Jt,lazyPolyD1Deriv:new Jt,tempP:new Jt,tempP1:new Jt,tempP2:new Jt,polypoly1Proximity:new $t,polypoly2Proximity:new $t};c.polyX1.construct(t,e),c.polyY1.construct(i,s),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.polyIntersect.assignCopy(c.polyX1),c.polyIntersect.mulThis(c.polyX1),c.polyIntersect.mulElementThis(a[0]),c.tempP.assignCopy(c.polyY1),c.tempP.mulThis(c.polyY1),c.tempP.mulElementThis(a[1]),c.polyIntersect.addThis(c.tempP),r?(c.lazyPolyD1.construct(r,o),c.tempP.assignCopy(c.lazyPolyD1),c.tempP.mulThis(c.lazyPolyD1),c.tempP.mulElementThis(a[2]),c.polyIntersect.addThis(c.tempP)):c.polyIntersect.add0(a[2]);{let r=a[0].clone(),o=r.clone();o.sqrThis();let l=a[1].clone(),h=l.clone();h.sqrThis();let m=a[2].clone(),u=r.clone();u.subThis(l),c.polyX1.construct(t,e),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1.construct(i,s),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(h),c.tempP.mulElementThis(m),c.polypoly1Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(l.mul(u).mul(m).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(r.mul(h)),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1),c.tempP1.mulElementThis(o.mul(l)),c.tempP.addThis(c.tempP1),c.tempP.add0(u.mul(u).mul(m)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulElementThis(u.mul(r).mul(l).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.construct0(r.mul(u).mul(u)),c.polypoly1Proximity.addElement(c.tempP),c.polypoly1Proximity.updatePower(),c.tempP.construct0(n.aD),c.polypoly2Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1Deriv),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1Deriv),c.tempP.addThis(c.tempP1),c.tempP.mulElementThis(r.mul(l)),c.polypoly2Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1Deriv),c.tempP.mulElementThis(u.mul(r)),c.polypoly2Proximity.addElement(c.tempP),c.polypoly2Proximity.updatePower()}let _=[],p=[];null===u&&(u=[]);let f=2*c.polyIntersect.power()+58,y=2**-52*.5,P=[],x=he(c.polyIntersect,0,h,y,f,P,d,d);if(x<0)return-1;for(let t of P)p.push(t.toDouble());le(c.polypoly1Proximity,c.polypoly2Proximity,c.tempP),f=2*c.tempP.power()+58,P.length=0;let v=he(c.tempP,0,h,y,f,P);if(v<0&&(v=0),0===x&&0===v)return 0;for(let t of P)_.push(t.toDouble());let C=_.concat(p);u.length=C.length,(0,n.b)(u,C,0,0,C.length),(0,n.w)(u);let E=(0,n.v)(u,(t,e)=>0===(0,n.X)(t,e));return u.length=E,u.length}function ie(t,e,i,s){return t.isZero()?e.isZero()?-1:0:(s.setThis(e),s.negateThis(),s.divThis(t),i.isEmpty()?1:+!!i.containsCoordinate(s.value()))}function se(t,e,i,s,r,o,a){if(t.isZero())return o?(a[0].setInt32(1),+!!r.containsCoordinate(1)):ie(e,i,r,a[0]);if(o){let e=2;return a[0].setInt32(1),i.equals(t)?(a[1].setInt32(1),e=1):a[1].setThis(i.div(t)),r.containsCoordinate(a[1].value())||(e=1),r.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,n.c)(a[0],a[0]=a[1])),e}let l=e.clone();l.sqrThis();let h=t.clone();if(h.mulThis(i).ldexpThis(2).negateThis().addThis(l),h.LZ())return 0;let m=s+2,u=n.M.sqrt(h,m),d=u.clone();e.LZ()&&d.negateThis(),d.addThis(e).limitPrecisionThis(m).ldexpThis(-1).negateThis();let g=0;return a[0].setThis(d).divThis(n.M.constructAssign(t,m)).limitPrecisionThis(s),(r.isEmpty()||r.containsCoordinate(a[0].value()))&&g++,u.isZero()||d.isZero()||(a[g].setThis(i).divThis(d).limitPrecisionThis(s),(r.isEmpty()||r.containsCoordinate(a[g].value()))&&g++,2===g&&a[0].gt(a[1])&&(a[1]=(0,n.c)(a[0],a[0]=a[1]))),g}function re(t,e,i,r,o,a,l,h){if(t.isZero())return se(e,i,r,o,a,l,h);let m=(t,e)=>{if(t>0){let i=e+t;for(let t=1;t<i;t++)h[t].equals(h[0])&&(h[i-1]=(0,n.c)(h[t],h[t]=h[i-1]),i--);e=i}return(0,n.a5)(h,0,e,(t,e)=>t.compare(e)),e};if(r.isZero()){let s=0;return a.containsCoordinate(0)&&(h[0].setInt32(0),s=1),m(se(t,e,i,o,a,l,h.slice(1)),s)}if(l){let i=0;a.containsCoordinate(1)&&(h[0].setInt32(1),i=1);let s=e.add(t),n=r.negate();return m(se(t,s,n,o,a,t.add(s).add(n).isZero(),h.slice(i)),i)}let u=new n.M,d=new n.M,g=new n.M,c=e.clone();if(c.isZero())d.setThis(i),d.divThis(t),g.setThis(r),g.divThis(t);else{c.divThis(t).divDoubleThis(3).negateThis();let s=e.clone();s.sqrThis();let n=t.clone();n.sqrThis(),d.setThis(t),d.mulThis(i).mulDoubleThis(3).subThis(s).divThis(n).divDoubleThis(3),g.setThis(s),g.mulThis(e),g.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(i).mulDoubleThis(9),g.subThis(u),u.setThis(n),u.mulThis(r).mulDoubleThis(27),g.addThis(u),g.divThis(n).divThis(t).divDoubleThis(27)}if(d.isZero()){let t=g.clone();return t.negateThis(),t.isZero()?(h[0].setThis(c),pe(a,o,h,1)):(h[0].setThis(n.M.cubicRoot(t,o).add(c)),pe(a,o,h,1))}let _=g.clone();if(_.sqrThis().ldexpThis(-2),u.setThis(d.clone()),u.sqrThis().mulThis(d).divDoubleThis(27),_.addThis(u),_.isZero())return h[0].setThis(g),h[0].mulDoubleThis(3).divThis(d),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(c),h[1].addThis(c),pe(a,o,h,2);if(_.GZ())return _.setThis(n.M.sqrt(_,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.addThis(_),h[0].setThis(n.M.cubicRoot(u,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.subThis(_),h[0].addThis(n.M.cubicRoot(u,o+8)),h[0].addThis(c),pe(a,o,h,1);u.setThis(d),u.divDoubleThis(3).negateThis(),(0,s.g)(u.GEZ());let p=n.M.sqrt(u,o+8),f=p.clone();f.negateThis(),f.addThis(c),p.addThis(c);let y=n.M.constructDouble(a.isEmpty()?-Number.MAX_VALUE:a.vmin),P=n.M.constructDouble(a.isEmpty()?Number.MAX_VALUE:a.vmax),x=new Jt({zeroCtor:n.M});x.construct0(r),x.addElement(i),x.addElement(e),x.addElement(t);let v=new Jt({copy:x});v.derivative1This();let C=0,E=(0,n.m)(n.M,4);E[C++].setThis(y),f.gt(y)&&f.lt(P)&&E[C++].setThis(f),p.gt(y)&&p.lt(P)&&E[C++].setThis(p),E[C++].setThis(P);let b=3*o,D=52,w=2**-52;for(;D<b;)2*D<=b?(w*=w,D*=2):(w*=2**-52,D+=52);D+=2;let S=0,A=!1;for(let t=1;t<C;t++)if(de(x,v,E[t-1],E[t],w,D,h[0])){S=1,A=t+1<C;break}if(!S)return 0;if(A){let t=new Jt({zeroCtor:n.M,coef0:h[0]});t.negateThis(),t.addElement(n.ae);let e=new Jt({zeroCtor:n.M}),i=new Jt({zeroCtor:n.M});x.div(t,e,i),(0,s.g)(2===e.power()),(0,s.g)(0===i.power());let r=se(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,h.slice(1));(0,s.g)(r>=0&&r<=2),S+=r}return pe(a,o,h,S)}function ne(t,e,i,s,r,o,a,l,h){if(t.isZero())return re(e,i,s,r,o,a,l,h);let m=(t,e)=>{if(t>0){let i=e+t;for(let t=1;t<i;t++)h[t].equals(h[0])&&(h[i-1]=(0,n.c)(h[t],h[t]=h[i-1]),i--);e=i}return(0,n.a5)(h,0,e,(t,e)=>t.compare(e)),e};if(r.isZero()){let r=0;return a.containsCoordinate(0)&&(h[0].setInt32(0),r=1),m(re(t,e,i,s,o,a,l,h.slice(r)),r)}let u=new Jt({zeroCtor:n.M,coef0:r});if(u.addElement(s),u.addElement(i),u.addElement(e),u.addElement(t),l){let t=0;a.containsCoordinate(1)&&(h[0].setInt32(1),t=1);let e=new Jt({zeroCtor:n.M,coef0:n.M.constructInt32(-1)});e.addElement(n.M.constructInt32(1));let i=new Jt({zeroCtor:n.M}),s=new Jt({zeroCtor:n.M});return u.div(e,i,s),m(re(3===i.power()?i.getElement(3):n.aD.clone(),i.power()>=2?i.getElement(2):n.aD.clone(),i.power()>=1?i.getElement(1):n.aD.clone(),i.getElement(0),o,a,i.evaluate(n.ae).isZero(),h.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(a.containsCoordinate(0)&&(t=1,h[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);let e=re(3===u.power()?u.getElement(3):n.aD.clone(),u.power()>=2?u.getElement(2):n.aD.clone(),u.power()>=1?u.getElement(1):n.aD.clone(),u.getElement(0),o,a,!1,h.slice(t));return e>0&&(t+=e),(0,n.a5)(h,0,t,(t,e)=>t.compare(e)),t}let d=52,g=2**-52;for(;d<o;)2*d<=o?(g*=g,d*=2):(g*=2**-52,d+=52);d+=2;let c=_e(u),_=n.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return g=(c.lt(_)?c:_).mul(n.M.constructDouble(g)).toDouble(),ce(u,a,g,d,l,0,h,4)}function oe(t,e){let i=t,s=e;s.power()>i.power()&&(s=(0,n.c)(i,i=s));let r=i.power()-s.power(),o=new Jt({copy:i.getElement(i.power())});i.mulThis(s.getElement(s.power()));for(let t=0,e=i.power();t<e;t++)if(t>=r){let e=new Jt({copy:s.getElement(t-r)});e.mulThis(o);let n=i.getElement(t).sub(e);i.setElement(t,n)}i.setElement(i.power(),i.getElement(i.power()).setZero()),i.updatePower(),ae(i)}function ae(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function le(t,e,i){let s=t.clone(),r=e.clone();for(ae(s),ae(r);0!==s.power()||0!==r.power();)oe(s,r);i.assignMove(s.getElement(0))}function he(t,e,i,s,r,o,a=!1,l=!1){o.length=0;let h=t.power(),m=(0,n.m)(n.M,2*h+4),u=function(t,e,i,s,r,o,a){if(0===t.power())return t.isZero()?-1:0;let l=t.evaluate(n.M.constructInt32(1)).isZero();if(1===t.power()){let i=ie(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(s),1===i?(o[0].limitPrecisionThis(s),1):0}return 2===t.power()?se(t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):3===t.power()?re(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):4===t.power()?ne(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):ce(t,e,i,s,l,0,o,a)}(t,i||n.E.unit(),s,r,0,m,m.length);if(u>0){o.length=0;for(let t=0;t<u;t++){let e=m[t];t>0&&e.lte(o.at(-1))||o.push(e.clone())}return o.length}return u}function me(t,e,i){if((0,s.g)(i>=1),0===t.power())return t.isZero()?-1:0;let r=t.getElement(0);return r.negateThis(),r.divThis(t.getElement(1)),e[0].setThis(r),1}function ue(t,e,i,r){if(t.power()<2)return me(t,i,r);(0,s.g)(r>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));let a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){let s=t.getElement(1);return s.negateThis(),s.divThis(t.getElement(2)),s.ldexpThis(-1),s.limitPrecisionThis(e),i[0].setThis(s),1}(0,s.g)(r>=2),o=n.M.sqrt(o,e+8);let l=t.getElement(1);l.negateThis();let h=l.clone();h.subThis(o),h.divThis(t.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(e);let m=l.clone();return m.addThis(o),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e),h.lt(m)?(i[0].setThis(h),i[1].setThis(m)):(i[1].setThis(h),i[0].setThis(m)),2}function de(t,e,i,r,o,a,l){let h=i.clone(),m=r.clone();h.limitPrecisionThis(a),m.limitPrecisionThis(a);let u=t.evaluate(h);u.limitPrecisionThis(a+2);let d=t.evaluate(m);if(d.limitPrecisionThis(a+2),u.GEZ()&&d.GEZ()||u.LEZ()&&d.LEZ())return u.absLessAbs(d)?(l=h,u.isZero()):(l=m,d.isZero());let g=d.LZ();g&&(d=(0,n.c)(u,u=d),m=(0,n.c)(h,h=m));let c=g?m:h,_=g?h:m,p=h.add(m).ldexpThis(-1);p.limitPrecisionThis(a);let f=m.sub(h);f.limitPrecisionThis(a),f.absThis();let y=f.clone(),P=t.evaluate(p),x=e.evaluate(p),v=new Jt({copy:t}),C=new Jt({copy:e});{let i=Math.max(t.hiBitIndex(),e.hiBitIndex()),s=n.ae.clone();s.ldexpThis(-(a+2));for(let r=64;r<i;){v.limitPrecisionThis(r),C.limitPrecisionThis(r);let n=v.evaluate(p),o=C.evaluate(p),a=n.sub(P),l=o.sub(x);if(a.divThis(P).absThis().lt(s)&&(x.isZero()||l.divThis(x).absThis().lt(s)))break;v.assignCopy(t),C.assignCopy(e),r=Math.min(r+64,i)}P.limitPrecisionThis(a+2),x.limitPrecisionThis(a+2)}let E=4,b=1,D=0,w=0,S=1,A=n.M.constructDouble(.25*o),T=n.M.constructDouble(.5001),I=0;for(;++I<300;){if(I>32&&D>0||x.isZero()||2===S&&D>1||1===S&&E<4)S=1,b>1&&b--;else if(S=2,w>1){let t=f.mul(x);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&b++}f.setThis(y);let t=new n.M,e=!1;if(1===S)do{if(w>2){let e=f.clone();if(e.absThis(),e.ldexpThis(4),_.sub(c).ldexpThis(-1).gt(e)){if(p.equals(c)){t.setThis(p),p.setThis(c.add(e)),p.limitPrecisionThis(a),y.setThis(p.sub(t));break}if(p.equals(_)){t.setThis(p),p.setThis(_.sub(e)),p.limitPrecisionThis(a),y.setThis(p.sub(t));break}}}y.setThis(m.sub(h)),y.ldexpThis(-1),y.limitPrecisionThis(a),t.setThis(p),p.setThis(h.add(y)),p.limitPrecisionThis(a),p.lt(c)?p.setThis(c):p.gt(_)&&p.setThis(_),e=h.equals(p)||m.equals(p)}while(0);else for(;;){if(y.setThis(P.div(x)),y.limitPrecisionThis(a),1!==b&&y.mulDoubleThis(b),t.setThis(p),p.subThis(y),p.limitPrecisionThis(a),e=p.equals(t),p.lt(c)){if(b>1){p.setThis(t),b--;continue}y.setThis(t.sub(c)),p.setThis(c)}else if(p.gt(_)){if(b>1){p.setThis(t),b--;continue}y.setThis(t.sub(_)),p.setThis(_)}break}if(e||y.absLessAbs(A)){t.equals(p)||(P=v.evaluate(p),P.limitPrecisionThis(a+2));break}P=v.evaluate(p),P.limitPrecisionThis(a+2),x=C.evaluate(p),x.limitPrecisionThis(a+2);let i=h.clone(),s=m.clone();P.LZ()?(u.setThis(P),h.setThis(p)):(d.setThis(P),m.setThis(p)),2===S&&(h.equals(i)&&m.equals(s)||w>1&&!y.absLessAbs(T.mul(f)))?D++:D=0,1===S?(E++,w=0):(E=0,w++)}return I>=300&&(0,s.d)("Root_finder iterations exceeded"),l.setThis(p),!0}function ge(t,e,i,s,r){let o=t.evaluate(i);if(o.isZero())return!0;let a=n.M.constructDouble(.5*s),l=i.clone();l.subThis(a);let h=t.evaluate(l),m=i.clone();m.addThis(a);let u=t.evaluate(m);if(h.LZ()&&u.GZ()||h.GZ()&&u.LZ()||(o.GZ()?h.LEZ()||u.LEZ():h.GEZ()||u.GEZ()))return!0;let d=h.LEZ()&&u.LEZ(),g=h.GEZ()&&u.GEZ(),c=!1;return d?o.gt(h)&&o.gt(u)&&(c=!0):g&&o.lt(h)&&o.lt(u)&&(c=!0),!!c&&o.absThis().lt(n.M.constructDouble(1e-17))}function ce(t,e,i,r,o,a,l,h){(0,s.g)(i>0),(0,s.g)(h>=t.power());let m=l,u=[],d=[],g=new Jt({zeroCtor:t.m_zeroCtor}),c=new Jt({zeroCtor:t.m_zeroCtor}),_=new Jt({zeroCtor:t.m_zeroCtor}),p=n.M.constructDouble(i),f=n.M.constructDouble(e.vmin),y=n.M.constructDouble(e.vmax),P=f.sub(p),x=y.add(p),v=_e(t),C=v.clone();if(C.negateThis(),P.lt(C))P.setThis(C.sub(p));else if(P.gt(v))return 0;if(x.gt(v))x.setThis(v.add(p));else if(x.lt(C))return 0;let E=t,b=null;if(o){let e=new Jt({coef0:n.M.constructInt32(-1)});e.addElement(n.ae),b=new Jt,E=b;let i=new Jt,s=new Jt;for(t.div(e,i,s),b.assignCopy(i);E.evaluate(n.ae).isZero();)E.div(e,i,s),b.assignCopy(i)}let D=!1;if(E.power()>0&&E.getElement(0).isZero())for(D=!0,b||(b=new Jt({copy:E}),E=b);E.getElement(0).isZero();)b.shiftRight(1);let w=r+2*E.power()+2,S=i/2**(E.power()+2),A=w;if(n.aD.gt(P)&&n.aD.lt(x))for(let t=0,e=E.power();t<e;t++)if(E.getElement(t).isZero()){u.push(n.aD.clone());break}for(let t=E.power()-1;t>0;t--)if(S*=2,w-=2,A-=2,E.power()-t!==1){if(E.power()-t===2){c.assignMove(E.derivative(t));let e=ue(c,w,m,h);(0,s.g)(e>=0&&e<=2);for(let t=0;t<e;t++)m[t].gt(P)&&m[t].lt(x)&&!m[t].isZero()&&u.push(m[t].clone());if(u.length>1&&u.sort((t,e)=>t.compare(e)),u.length>0){let t=u[0].sub(p);t.limitPrecisionThis(A),d.push((0,n.o)(P.clone(),t));let e=1===u.length?x.clone():u[1].sub(p);t=u[0].add(p),t.limitPrecisionThis(A),e.limitPrecisionThis(A),d.push((0,n.o)(t,e)),u.length>1&&(e=2===u.length?x.clone():u[2].sub(p),e.limitPrecisionThis(A),t=u[1].add(p),t.limitPrecisionThis(A),d.push((0,n.o)(t,e)),u.length>2&&(t=u[2].add(p),t.limitPrecisionThis(A),d.push((0,n.o)(t,x.clone()))))}else d.push((0,n.o)(P.clone(),x.clone()));g.assignCopy(c),_.assignMove(E.derivative(t-1));continue}{c.assignMove(_),_.assignMove(E.derivative(t-1));let e=[];for(let t=0,i=d.length;t<i;++t)if(d[t].first.lte(d[t].second)){let i=new n.M;if(de(c,g,d[t].first,d[t].second,S,w,i)){u.push(i);let s=i.sub(p);s.limitPrecisionThis(A),e.push((0,n.o)(d[t].first,s)),s=i.add(p),s.limitPrecisionThis(A),e.push((0,n.o)(s,d[t].second))}else e.push(d[t])}d=e,e=[],g.assignMove(c)}}else c.assignMove(E.derivative(t)),1===me(c,m,h)&&(m[0].gt(P)&&m[0].lt(x)&&!m[0].isZero()&&u.push(m[0].clone()),g.assignMove(c),_.assignMove(E.derivative(t-1)));u.sort((t,e)=>t.compare(e)),0===d.length&&(g.assignMove(E.derivative(E.power())),g.isZero()||d.push((0,n.o)(P.clone(),x.clone())));let T=0,I=0,M=0,q=new n.M;for(;;){if(I<d.length){if(d[I].first.gt(d[I].second)){I++;continue}let t=!1;if(M<u.length&&u[M].lt(d[I].first)&&(t=!0),!t){de(E,g,d[I].first,d[I].second,i,r,q)&&(q.lt(f)?m[T++].setThis(f):q.gt(y)?m[T++].setThis(y):m[T++].setThis(q)),I++;continue}}if(!(M<u.length))break;(0===M||!u[M-1].equals(u[M]))&&ge(E,0,u[M],i)&&(q.setThis(u[M]),q.lt(f)?q.setThis(f):q.gt(y)&&q.setThis(y),(0===T||!m[T].equals(q))&&m[T++].setThis(q)),M++}return D&&n.aD.gt(P)&&n.aD.lt(x)&&(m[T++].setThis(n.aD),(0,n.a5)(m,0,T,(t,e)=>t.compare(e))),o&&n.ae.gt(P)&&n.ae.lt(x)&&(m[T++].setThis(n.ae),(0,n.a5)(m,0,T,(t,e)=>t.compare(e))),T}function _e(t){let e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();let i=n.aD.clone();for(let e=0,s=t.power();e<s;e++){let s=t.getElement(e);s.limitPrecisionThis(53),s.gt(i)&&i.setThis(s)}return i.divThis(e),i.addThis(n.ae),i.mulThis(n.M.constructDouble(1+2**-52*100)),i}function pe(t,e,i,s){let r=s;if(!t.isEmpty()){r=0;for(let e=0;e<s;++e)t.containsCoordinate(i[e].value())&&(r!==e&&i[r].setThis(i[e]),r++)}r>1&&(i[0].gt(i[1])&&(i[1]=(0,n.c)(i[0],i[0]=i[1])),r>2&&(i[0].gt(i[2])&&(i[2]=(0,n.c)(i[0],i[0]=i[2])),i[1].gt(i[2])&&(i[2]=(0,n.c)(i[1],i[1]=i[2]))));for(let t=0;t<r;++t)i[t].limitPrecisionThis(e);return r}function fe(t,e,i,r,o,a){return function(t,e,i,r,o,a){if(i<e&&(0,s.a)("xTo < xFrom"),i===e)return 0;let l=[0],h=Number.MAX_VALUE,m=[Number.MAX_VALUE],u=0,d=(0,n.d)(33,NaN),g=(0,n.d)(33,NaN),c=[0];d[0]=1;let _=0,p=0;for(let n=0;n<32;n++){if(u=ye(e,i,r,0===n,u,c),g[n]=u,n+1>=t){Pe(n+1-t,t,d,g,0,l,m)||(0,s.d)("polynomial_interpolation");let e=o*Math.abs(l[0])+a,i=Math.abs(h-l[0]);if(i<=e&&Math.abs(m[0])<=e){if(_++,_>1&&(i<=.1*p||0===p||_>2))return l[0]}else _=0;p=i,h=l[0]}g[n+1]=g[n],d[n+1]=.25*d[n]}return l[0]}(t,e,i,a,r,o)}function ye(t,e,i,s,r,o){let a=r;if(s)return o[0]=1,a=.5*(e-t)*(i(t)+i(e)),a;let l=o[0],h=(e-t)/l,m=t,u=new n.K(0);for(let t=1;t<=o[0];++t){let e=(t-.5)*h;u.add(i(m+e))}return a=.5*(a+(e-t)*u.getResult()/l),o[0]*=2,a}function Pe(t,e,i,s,r,o,a){let l=0,h=Math.abs(r-i[t]),m=(0,n.d)(e,NaN),u=(0,n.d)(e,NaN);for(let n=0;n<e;++n){let e=Math.abs(r-i[t+n]);e<h&&(l=n,h=e),m[n]=s[t+n],u[n]=s[t+n]}let d=0,g=0,c=0;o[0]=s[t+l],l--;for(let s=1;s<e;s++){for(let n=0;n<e-s;n++){if(g=i[t+n]-r,c=i[t+n+s]-r,d=g-c,0===d)return!1;let e=(m[n+1]-u[n])/d;m[n]=g*e,u[n]=c*e}2*(l+1)<e-s?a[0]=m[l+1]:(a[0]=u[l],l--),o[0]+=a[0]}return!0}class xe{specialPoints;specialPointsLength;area;centroid_x;centroid_y;constructor(){this.area=NaN,this.centroid_x=NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let ve=class{b;len;constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-we(this.b,e,!1):0}getError(t){return(0,s.g)(0),0}};function Ce(t,e,i,s,r){let o=!0,a=(0,n.m)(n.P,3);t.queryControlPoints(a);let l=+!o,h=a[1][l]-a[0][l],m=a[2][l]-a[0][l],u=fe(5,e,i,s,r,t=>{let e;if(t<=.5){let i=(0,n.ag)(0,h,t),s=(0,n.ag)(h,m,t);e=(0,n.ag)(i,s,t)}else{let i=(0,n.ah)(0,h,t),s=(0,n.ah)(h,m,t);e=(0,n.ah)(i,s,t)}return e*Me(a,1,t).length()});o=!1,l=+!o,h=a[1][l]-a[0][l],m=a[2][l]-a[0][l];let d=fe(5,e,i,s,r,t=>{let e;if(t<=.5){let i=(0,n.ag)(0,h,t),s=(0,n.ag)(h,m,t);e=(0,n.ag)(i,s,t)}else{let i=(0,n.ah)(0,h,t),s=(0,n.ah)(h,m,t);e=(0,n.ah)(i,s,t)}return e*Me(a,1,t).length()});return new n.P(u,d)}function Ee(t){t.m_cachedValues=null}function be(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new xe;return De(t,e.specialPoints),Ye(t,e),e}function De(t,e){let i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=(0,n.m)(n.Z,8);s[0].set(0);let r=1;{let t=(0,n.m)(n.Z,3);!function(t,e,i=!1){let s=new n.Z(t[1][0]).subE(new n.Z(t[0][0]));e[1]=s.mul(2),e[2]=new n.Z(t[2][0]).subE(new n.Z(t[1][0])).subE(s),i?e[0].set(0):e[0].set(t[0][0])}(i,t,!1);let e=(0,n.m)(n.Z,2),o=new n.E(0,1),a=Ft(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.ab)(e[t].value(),0,1)||(s[r]=e[t],r++)}{let t=(0,n.m)(n.Z,3);!function(t,e,i=!1){let s=new n.Z(t[1][1]).subE(new n.Z(t[0][1]));e[1]=s.mul(2),e[2]=new n.Z(t[2][1]).subE(new n.Z(t[1][1])).subE(s),i?e[0].set(0):e[0].set(t[0][1])}(i,t,!1);let e=(0,n.m)(n.Z,2),o=new n.E(0,1),a=Ft(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.ab)(e[t].value(),0,1)||(s[r]=e[t],r++)}if(s[r].set(1),r++,r>2){(0,n.a5)(s,0,r,(t,e)=>t.value()-e.value());let t=0,e=s[0].value(),i=1;for(let n=1;n<r;n++)s[n].eq(s[n-1])?(e+=s[n].value(),i++):(i>1&&(e/=i,s[t].set(e)),t++,s[t]=s[n],e=s[n].value(),i=1);t++,r=t}s[0].set(0),s[r-1].set(1),e.length=r;for(let t=0;t<r;t++)e[t]=s[t].value()}function we(t,e,i){let s=(0,n.m)(n.P,3);return t.queryControlPoints(s),Se(s,e,i)}function Se(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+Se(t,1,!1)}if(1===e)return Ae(t);let s=(0,n.m)(n.P,3);return ke(t,e,s,null),Ae(s)}function Ae(t){if(t[0].equals(t[1]))return n.P.distance(t[2],t[0]);if(t[1].equals(t[2]))return n.P.distance(t[0],t[2]);let e=n.P.distance(t[0],t[1])+n.P.distance(t[2],t[1]),i=n.P.distance(t[0],t[2]);if(e-i<=e*2**-52)return i;let s=(0,n.m)(n.P,3);Oe(t,s,!0);let r=4*((0,n.a)(s[2].x)+(0,n.a)(s[2].y)),o=2*(s[2].x*s[1].x+s[2].y*s[1].y),a=(0,n.a)(s[1].x)+(0,n.a)(s[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r))return 1e-14*Math.abs(a)>=Math.abs(o)?1*Math.sqrt(a):2/(3*o)*((1*o+a)**1.5-a**1.5);let l=o/r,h=a/r,m=h-l*l,u=1+l;if(0===m)return l>=0&&u>=0||l<=0&&u<=0?Math.abs(.5*Math.sqrt(r)*(u*u-l*l)):.5*Math.sqrt(r)*(u*u+l*l);let d=Math.sqrt(m+u*u),g=Math.sqrt(h);return.5*Math.sqrt(r)*(u*d-l*g+m*Math.log(Math.abs((u+d)/(l+g))))}function Te(t,e){let i=(0,n.s)(e,0,1),s=Me(t,1,i);return s.isZero()&&(s=Me(t,2,i)),s}function Ie(t,e,i){let s=(0,n.m)(n.P,3);return t.queryControlPoints(s),Me(s,e,i)}function Me(t,e,i){if(1===e){let e=t[1].sub(t[0]).mul(1-i).add(t[2].sub(t[1]).mul(i));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):n.P.construct(0,0)}function qe(t){let e=(0,n.m)(n.P,3);return t.queryControlPoints(e),Ne(e)}function Ne(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Re(t){return t.m_cachedValues}function Ye(t,e){t.m_cachedValues=e}function Xe(t,e,i,r,o){(0,s.D)(n.E.unit().contains(i),"QuadraticBezierHelper::getClosestCoordinateSegment");let a=(0,n.m)(n.P,3);t.queryControlPoints(a);let l=Number.MAX_VALUE,h=[0],m=Fe(a,e,h);if(i.containsCoordinate(h[0]))l=n.P.distance(e,m);else{h[0]=i.vmin,Ke(a,h[0],m),l=n.P.distance(m,e);let t=new n.P;Ke(a,i.vmax,t);let s=n.P.distance(t,e);l>s&&(m.setCoordsPoint2D(t),h[0]=i.vmax,l=s)}if(!r)return h[0];if(i.vmin<=0){let s=new n.P;t.queryCoord2DExtended(-1,s,!0);let r=new n.P;t.queryCoord2D(i.vmin,r);let o=new Yn({start:s,end:r}),a=o.getClosestCoordinate(e,!0);if(a<1){let t=o.getCoord2D(a),i=n.P.distance(t,e);i<l&&(l=i,h[0]=a-1,m.assign(t))}}if(i.vmin>=1){let s=new n.P;t.queryCoord2DExtended(2,s,!0);let r=new n.P;t.queryCoord2D(i.vmax,r);let o=new Yn({start:r,end:s}),a=o.getClosestCoordinate(e,!0);if(a>0){let t=o.getCoord2D(a),i=n.P.distance(t,e);i<l&&(l=i,h[0]=1+a,m.assign(t))}}return h[0]}function Fe(t,e,i){let s=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(r),l=o.dotProduct(s)+2*r.dotProduct(r),h=3*r.dotProduct(s),m=s.dotProduct(s),u=(0,n.d)(3,NaN),d=qt(m,h,l,a,n.E.unit(),!1,u),g=t[0].clone(),c=0,_=n.P.sqrDistance(t[0],e),p=n.P.sqrDistance(t[2],e);p<_&&(c=1,g.assign(t[2]),_=p);for(let i=0;i<d;i++){let s=new n.P;Ke(t,u[i],s),p=n.P.sqrDistance(s,e),p<_&&(_=p,g.assign(s),c=u[i])}return i&&(i[0]=c),g}function Le(t,e,i){if(e.equalsRange(0,1))return void i.setFromPoints(t,3);let s=(0,n.m)(n.P,3);Ge(t,e.vmin,e.vmax,s),i.setFromPoints(s,3)}function ze(t,e,i){i.setEmpty();let s=[];s.push(new n.E(0,1));let r=.5*Math.max(e.width(),e.height());for(;s.length;){let o=s.at(-1);s.pop();let a=new p;if(Le(t,o,a),a.isIntersectingW(e)){let t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=r||o.width()<1e-12)i.merge(o);else{let t=o.getCenter();s.push(n.E.construct(o.vmin,t)),s.push(n.E.construct(t,o.vmax))}}}}function Ve(t){let e=(0,n.m)(n.P,3);t.queryControlPoints(e);let i=Be(e);return i&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),i}function Be(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.a7)(t[0][i],t[2][i]);s>0?((0,n.a7)(t[0][i],t[1][i])<0&&(t[1][i]=t[0][i],e=!0),(0,n.a7)(t[1][i],t[2][i])<0&&(t[1][i]=t[2][i],e=!0)):s<0?((0,n.a7)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.a7)(t[1][i],t[2][i])>0&&(t[1][i]=t[2][i],e=!0)):t[1][i]!==t[0][i]&&(t[1][i]=t[0][i],e=!0)}return e}function ke(t,e,i,s){(new n.P).setCoordsPoint2D(t[0]),(new n.P).setCoordsPoint2D(t[1]),(new n.P).setCoordsPoint2D(t[2]);let r=new n.P,o=new n.P,a=new n.P;if((0,n.J)(t[0],t[1],e,r),(0,n.J)(t[1],t[2],e,o),(0,n.J)(r,o,e,a),i&&(i[0].assign(t[0]),i[1].assign(r),i[2].assign(a)),s){let e=t[2];s[0].assign(a),s[1].assign(o),s[2].assign(e)}}function Ge(t,e,i,s){if(e===i){let i=new n.P;return Ke(t,e,i),s[0]=i,s[1]=i,void(s[2]=i)}let r=(0,n.m)(n.P,3);ke(t,i,r,null),ke(r,e/i,null,r),Ke(t,e,r[0]),Ke(t,i,r[2]),s[0].setCoordsPoint2D(r[0]),s[1].setCoordsPoint2D(r[1]),s[2].setCoordsPoint2D(r[2])}function Ze(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===We(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function He(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===je(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function We(t,e,i,r,o,a,l,h,m,u){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),i.isDegenerate(0)){let t=[0,0],s=e.intersectPoint(i.getStartXY(),t,l);if(s>0){if(null!==o)for(let e=0;e<s;e++)o.push(t[e]);if(null!==a)for(let t=0;t<s;t++)a.push(0);if(null!==r)for(let i=0;i<s;i++){let s=new n.P;e.queryCoord2D(t[i],s),r.push(s)}}return s}let d=k(e,i);if(l=Math.max(l,d),e.isDegenerateToLineHelper(d)){let t=new Yn({start:e.getStartXY(),end:e.getEndXY()}),s=ot(t,i,r,o,a,l,h,u);if(o)for(let i=0;i<s;++i){let s=t.getCoord2D(o[i]);o[i]=e.getClosestCoordinate(s,!1)}return s}if(G(e,i,l))return 0;let g=C.constructPoint2D(i.getStartXY()),c=C.constructPoint2D(i.getEndXY()).sub(g),_=c.clone();_.leftPerpendicularThis();let p=C.constructPoint2D(e.m_cp).sub(C.constructPoint2D(e.getStartXY())),f=C.constructPoint2D(e.getEndXY()).sub(C.constructPoint2D(e.m_cp)),y=p.dotProduct(_).toDouble(),P=f.sub(p).dotProduct(_).toDouble(),x=(0,n.d)(12,NaN),v=(0,n.d)(12,NaN),E=function(t,e,i,s){let r=new n.Z,o=Ft(new n.Z(t),new n.Z(e),i,r);return s[0]=r.value(),o}(P,y,n.E.unit(),x);E<0&&(x[0]=0,x[1]=1,E=2);let b=0;for(let t=0,s=b;t<E;++t){let r=e.getCoord2D(x[t+s]);v[b]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(v[b]))<=l&&(x[b]=x[t+s],b++)}let D,w=(0,n.m)(n.P,3);e.queryControlPoints(w);{let t=(0,n.m)(C,3);if(Qe(w,t,!1),t[0]=t[0].sub(g),c.x.abs().gte(c.y.abs())){let e=c.y.div(c.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),y=t[1].y.sub(t[1].x.mul(e)).toDouble(),D=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{let e=c.x.div(c.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),y=t[1].x.sub(t[1].y.mul(e)).toDouble(),D=t[0].x.sub(t[0].y.mul(e)).toDouble()}}let S=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),A=[0,0];E=Mt(P,y,D,n.E.unit(),S,A);for(let t=0,s=b;t<E;++t){x[t+s]=A[t];let r=e.getCoord2D(x[t+s]);v[b]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(v[b]))<=l&&(x[b]=x[t+s],b++)}(0,s.g)(b<x.length+4),E=e.intersectPoint(i.getStartXY(),A,l);for(let t=0;t<E;t++)x[b]=A[t],v[b++]=0;E=e.intersectPoint(i.getEndXY(),A,l);for(let t=0;t<E;t++)x[b]=A[t],v[b++]=1;E=i.intersectPoint(e.getStartXY(),A,l);for(let t=0;t<E;t++)v[b]=A[t],x[b++]=0;E=i.intersectPoint(e.getEndXY(),A,l);for(let t=0;t<E;t++)v[b]=A[t],x[b++]=0;return 0===b?0:Mn(t,e,i,x,v,b,r,o,a,l,h,0,u)}function je(t,e,i,s,r,o,l,h,m,u){if(Kr(i))return We(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,0,u);let d=k(e,i);if(G(e,i,l=Math.max(l,d)))return 0;let g=[],c=[],_=(0,n.m)(n.P,3);{e.queryControlPoints(_);let t=(0,n.m)(n.P,3),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(_,3,t);let o=(0,n.m)(C,3);Qe(t,o);let m=[o[0].x,o[1].x,o[2].x],u=[o[0].y,o[1].y,o[2].y],d=(0,n.m)(n.M,3);d[0].setDouble(i.getSemiMinorAxis()),d[0].sqrThis(),d[1].setDouble(i.getSemiMajorAxis()),d[1].sqrThis(),d[2]=d[0],d[2].mul(d[1]),d[2].negate();let p=ee(m,2,u,2,null,0,d,0,n.E.unit(),n.E.unit(),g,h);if(p>0){let t=0;for(let s=0;s<p;s++){let r=new n.P;e.queryCoord2D(g[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(g[t]=g[s],c.push(o),t++)}g.length=t}}let p=[0,1];for(let t=0;t<2;t++){let e=0===t?i.getStartXY():i.getEndXY(),s=[0];Fe(_,e,s);let r=new n.P;Ke(_,s[0],r),n.P.distance(e,r)<=l&&(g.push(s[0]),c.push(p[t]))}for(let t=0;t<2;t++){let e=[0,2];{let s=i.getClosestCoordinate(_[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(_[e[t]],r)<=l&&(g.push(p[t]),c.push(s))}}return Mn(t,e,i,g,c,g.length,s,r,o,l,h,0,u)}function Ue(t,e,i,s,r,o,a,l,h,m){let u=(0,n.m)(n.P,3);e.queryControlPoints(u);let d=(0,n.m)(n.P,3);if(i.queryControlPoints(d),Z(u,d,3)<0)return Ue(t,i,e,s,o,r,a,l,h,!m);let g=k(e,i);if(G(e,i,a=Math.max(a,g)))return 0;if(function(t,e,i,s,r,o,a,l,h){let m=(0,n.m)(n.P,3);t.queryControlPoints(m);let u=(0,n.m)(n.P,3);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2]))return i&&(i.length=0,i.push(m[0]),i.push(m[2])),s&&(s.length=0,s.push(0),s.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!m[0].equals(u[2]))return!1}return!!(m[0].equals(u[2])&&m[1].equals(u[1])&&m[2].equals(u[0]))&&(s&&(s.length=0,s.push(0),s.push(1),h&&(s[1]=(0,n.c)(s[0],s[0]=s[1]))),r&&(r.length=0,r.push(1),r.push(0),h&&(r[1]=(0,n.c)(r[0],r[0]=r[1]))),i&&(i.length=0,i.push(m[0]),i.push(m[2]),h&&(i[1]=(0,n.c)(i[0],i[0]=i[1]))),!0)}(e,i,s,r,o,0,0,0,m))return 2;let c=new n.E(0,1),_=new n.E(0,1);{let t=new p;Le(u,n.E.unit(),t);let e=new p;Le(d,n.E.unit(),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(ze(u,t,c),ze(d,t,_),c.isEmpty()||_.isEmpty())return 0;Ge(u,c.vmin,c.vmax,u),Ge(d,_.vmin,_.vmax,d)}}let f=Nn(u,2,d,2,a);if(0===f)return 0;let y=[],P=[];if(-1===f){let t=(0,n.m)(C,3);Qe(u,t);let e=[t[0].x,t[1].x,t[2].x],i=[t[0].y,t[1].y,t[2].y],s=(0,n.m)(C,3);Qe(d,s);let r=te(e,2,i,2,null,0,[s[0].x,s[1].x,s[2].x],2,[s[0].y,s[1].y,s[2].y],2,null,0,0,n.E.unit(),n.E.unit(),y,P,m,0,m);if(r>0){let t=0;for(let e=0;e<r;e++){let i=new n.P,s=new n.P;Ke(d,P[e],s),Ke(u,y[e],i),n.P.distance(i,s)<=a&&(y[t]=y[e],P[t]=P[e],t++)}y.length=t,P.length=t}}for(let t=0;t<2;t++){let e=0===t?u:d,i=0===t?d:u;for(let s=0;s<2;s++){let r=0===s?0:2,o=[0];Fe(i,e[r],o);let l=new n.P;Ke(i,o[0],l),n.P.distance(e[r],l)<=a&&(0===t?(y.push(0===r?0:1),P.push(o[0])):(P.push(0===r?0:1),y.push(o[0])))}}if(0===y.length)return 0;if(!c.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=Qt.recalculateParentT(c.vmin,c.vmax,y[t]);if(!_.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=Qt.recalculateParentT(_.vmin,_.vmax,P[t]);return Mn(t,e,i,y,P,y.length,s,r,o,a,l,0,m)}function Oe(t,e,i=!1){let s=t[1].sub(t[0]);e[1].assign(s.mul(2)),e[2].assign(t[2].sub(t[1]).sub(s)),i?e[0].setCoords(0,0):e[0].assign(t[0])}function Qe(t,e,i=!1){let s=C.constructPoint2D(t[1]),r=s.sub(C.constructPoint2D(t[0]));e[1]=r.mul(n.M.constructInt32(2)),e[2]=C.constructPoint2D(t[2]).sub(s).sub(r),e[0]=i?new C(n.aD,n.aD):C.constructPoint2D(t[0])}function Ke(t,e,i,s){if(s){if(e<0)return void J(new Yn({start:t[0],end:t[0].add(Te(t,0).getUnitVector())}),e,i);if(e>1)return void J(new Yn({start:t[2],end:t[2].add(Te(t,1).getUnitVector())}),e-1,i)}if(e<=.5){let s=t[1].clone(),r=new n.P;(0,n.as)(2,t[0],s,e,r);let o=new n.P;(0,n.as)(2,s,t[2],e,o);let a=new n.P;(0,n.as)(2,r,o,e,a),i.assign(a)}else{let s=t[1].clone(),r=new n.P;(0,n.at)(2,t[0],s,e,r);let o=new n.P;(0,n.at)(2,s,t[2],e,o);let a=new n.P;(0,n.at)(2,r,o,e,a),i.assign(a)}}const Je=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],$e=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],ti=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],ei=[[.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]],ii=[[.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]],si=[[.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 ri(t,e,i,s){let r=.5*(s-i),o=i+r,a=new n.K(0);for(let i=0,s=Math.trunc(t/2);i<s;++i){let s,l;switch(t){case 4:s=Je[i][0],l=Je[i][1];break;case 8:s=$e[i][0],l=$e[i][1];break;case 16:s=ti[i][0],l=ti[i][1];break;case 32:s=ei[i][0],l=ei[i][1];break;case 64:s=ii[i][0],l=ii[i][1];break;case 128:s=si[i][0],l=si[i][1];break;default:throw Error("Quadrature_integral: invalid n")}let h=(0,n.aH)(-r,s,o),m=(0,n.aH)(r,s,o);a.pe(e(h)*l),a.pe(e(m)*l)}return a.getResult()*r}class ni extends Et{static type=s.G.enumPolygon;constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Xn):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Xn,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Xn):t.envelope?(0,s.t)("envelope constructor not impl"):(0,s.d)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Xn)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return At(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return ni.type}getDimension(){return 2}createInstance(){return new ni({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}var oi=r.V;class ai{m_shape;constructor(t){this.m_shape=t}userSort(t,e,i){this.m_shape.sortVerticesSimpleByYHelper(i,t,e)}getValue(t){return this.m_shape.getY(t)}}class li{m_parent;m_geometry;m_path;m_vertex;m_firstVertex;m_index;m_bFirst;m_bSkipMultiPoints;m_selection;m_bOneGeom;constructor(t){!function(t){return void 0!==t.parent}(t)?(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):(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)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;-1!==this.m_geometry;){for(;-1!==this.m_path;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,-1!==this.m_vertex)return this.m_vertex;if(this.m_bOneGeom)return-1;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),-1===this.m_geometry)break;(!this.m_bSkipMultiPoints||(0,s.j)(this.m_parent.getGeometryType(this.m_geometry)))&&(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return-1}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){let t=this.m_parent.m_selectedVertices[this.m_index++];if(-1!==t&&(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-1}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):-1===this.m_vertex?-1:(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,-1!==this.m_vertex&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper())}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,i,s,r,n,o,a,l){return new li({parent:t,geometry:e,path:i,vertex:s,firstVertex:r,index:n,bSkipMultiPoints:o,selection:a,bOneGeom:l})}}class hi{parentage;constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class mi{m_pathCount;m_pointCount;m_firstGeometry;m_lastGeometry;m_vertexIndexList;m_verticesMp=null;m_vertices=null;m_xyStream=null;m_vertexDescription=null;m_bHasAttributes;m_segments=null;m_weights=null;m_ranks=null;m_segmentWeights=null;m_segmentRanks=null;m_indices=[];m_deletedIndices=[];m_pathIndexList;m_pathAreas=[];m_pathLengths=[];m_pathindices=[];m_deletedPathIndices=[];m_geometryIndexList;m_geometryIndices=[];m_selectedVertices=[];m_selectedCount;m_selectionIndex;m_selection;m_bucketSort;m_helperPoint=null;m_forceSetEnvelope=r.r.constructEmpty();m_hasForceSetEnvelope=0;m_workPoint2D=n.P.getNAN();m_workPoint2_2D=n.P.getNAN();m_segmentParentageIndex;m_curveStitcher=null;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){let 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){let e=this.m_pathIndexList.newElement(),i=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,i),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),i>=this.m_pathAreas.length){let t=Math.trunc(i<16?16:3*i/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[i]=0,this.m_pathLengths[i]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){let e=this.m_vertexIndexList.newElement(),i=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,i),t<0){if(i>=this.m_vertices.getPointCount()){let t=Math.trunc(i<16?16:3*i/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[i]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);let e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let t=0,i=this.m_indices.length;t<i;t++){if(t===this.m_selectionIndex)continue;let i=this.m_indices[t];null!==i&&i.size()>e&&i.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,1),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,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,i,s){this.m_hasForceSetEnvelope=0;let r=-1===e?this.getLastVertex(t):this.getPrevVertex(e),n=-1===r?-1:this.getNextVertex(r),o=this.newVertex(null===i?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==i&&this.m_vertices.setPointByValNoCurves(a,i),this.setPathToVertex(o,t),this.setNextVertex(o,n),this.setPrevVertex(o,r),-1!==n&&this.setPrevVertex(n,o),-1!==r&&this.setNextVertex(r,o);let l=this.isClosedPath(t),h=this.getFirstVertex(t);-1===e&&this.setLastVertex(t,o),e===h&&(!l||!s||-1===h)&&this.setFirstVertex(t,o),l&&-1===n&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);let m=this.getGeometryFromPath(t);return this.setGeometryVertexCount(m,this.getPointCount(m)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new r.P({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){let i=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(i,t,e),i}addPoint_(t,e){let i=this.createGeometry(s.G.enumMultiPoint,t.getDescription());return this.appendPoint(i,t,e),i}appendMultiPath_(t,e){if(e.isEmpty())return;let i=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i.getPointCount()),this.m_verticesMp.addPoints(e,0,i.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);let s=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+i.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+i.getPathCount());for(let e=0,r=i.getPathCount();e<r;e++){if(0===i.getPathSize(e))continue;let r=this.insertPath(t,-1);this.setClosedPath(r,i.isClosedPath(e));for(let t=i.getPathStart(e),n=i.getPathEnd(e);t<n;t++){let e=this.insertVertex_(r,-1,null,!1);if(s){let s=this.getVertexIndex(e);if(1&i.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{let e=new Xn;i.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}i.isStrongPathStart(e)&&this.setStrongPathStart(r,!0),i.isStrongPathEnd(e)&&this.setStrongPathEnd(r,!0)}}addMultiPath(t,e){let i=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===s.G.enumPolygon&&this.setFillRule(i,t.getFillRule()),this.appendMultiPath(i,t,e),i}appendMultiPathPolyline(t,e,i){let s=e.getImpl(),r=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef(),n=new o.Envelope2D;e.queryEnvelope(n);{let n=i.clone(),o=s.getPointCount(),a=s.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(n,0,s.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;let i=s.queryLimitedSegmentIterator(n),a=-1,l=-100,h=-1,m=0,u=-1,d=-1,g=!1,c=i.nextSegment();if(null!==c)for(;;c=i.nextSegment()){let n=null===c,o=null===c?a:i.getPathIndex(),_=null===c?l:i.getStartPointIndex();if(n||(a===o&&l+1===_?m++:n=!0),n){if(-1!==u){let t=-1,i=-1;if(m===h){this.setClosedPath(d,g);let r=s.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+r-u),this.m_verticesMp.addPoints(e,u,r),i=s.getPathSize(a),t=r-1}else if(!g||l+1<s.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l+2-u),this.m_verticesMp.addPoints(e,u,l+2),i=l-u+2,t=l;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l+2-u),this.m_verticesMp?.addPoints(e,u,l+1),t=l,i=l-u+1;let r=s.getPathStart(a);this.m_verticesMp.addPoints(e,r,r+1),i+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,n=u;e<i;e++,n++){let e=this.insertVertex_(d,-1,null,!1);if(r){let i=this.getVertexIndex(e);if(1&s.getSegmentFlags(n)||n>t)this.setSegmentToIndex(i,null);else{let t=new Xn;s.getSegmentBuffer(n,t,!0),this.setSegmentToIndex(i,t.releaseSegment())}}}}if(null===c)break;m=1,u=_,a===o?d=this.insertPath(t,-1):(d=this.insertPath(t,-1),this.setClosedPath(d,!1),h=s.getSegmentCountPath(o),g=s.isClosedPath(o),a=o)}l=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,i){let r=e.getImpl(),a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef(),l=o.Envelope2D.constructEmpty();e.queryEnvelope(l),(0,s.g)(i.isIntersecting(l)&&!i.containsEnvelope(l));let h=o.Envelope2D.construct(-1/0,i.ymin,1/0,i.ymax),m=o.Envelope2D.construct(i.xmin,-1/0,i.xmax,1/0),u=r.getAccelerators();if(u&&u.getQuadTree()){let t=u.getQuadTree(),e=t.getIntersectionCount(h,0,0);e>t.getIntersectionCount(m,0,e+1)&&(m=(0,n.c)(h,h=m))}else h.height()>m.width()&&(m=(0,n.c)(h,h=m));let d=[],g=r.queryLimitedSegmentIterator(h),c=-1,_=-100,p=-1,f=0,y=-1,P=-1,x=-1,v=!0,C=g.nextSegment();if(null!==C)for(;;C=g.nextSegment()){let i=null===C,l=null===C?c:g.getPathIndex(),h=null===C?_:g.getStartPointIndex();if(i||(l===c?_+1===h?f++:i=!0:(i=c>=0,c<0&&(c=l,p=r.getSegmentCountPath(c),y=h,x=-1,f=1))),i){if(0!==d.length||p!==f){(0===d.length||d[0].first!==y)&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,y,y+1),-1===P&&(P=y),-1===x&&(x=this.insertPath(t,-1),this.setClosedPath(x,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(x,-1,null,!1));for(let{first:i,second:n}of d){-1===P&&(P=i);let o=-1,l=-1,h=i+n-1;if(n===p){let t=h+1;l=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l),this.m_verticesMp.addPoints(e,i,t),o=h,(0,s.g)(1===d.length)}else if(h+1<r.getPathEnd(c)){let t=h+2;l=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l),this.m_verticesMp.addPoints(e,i,t),o=h}else{let t=r.getPathStart(c),s=t===P?0:1,n=h+1;l=n-i+s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(n-i)+s),this.m_verticesMp.addPoints(e,i,n),o=h,s>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),-1===x&&(x=this.insertPath(t,-1),this.setClosedPath(x,!0));for(let t=0,e=i;t<l;t++,e++){let t=this.insertVertex_(x,-1,null,!1);if(a){let i=this.getVertexIndex(t);if(1&r.getSegmentFlags(e)||e>o)this.setSegmentToIndex(i,null);else{let t=new Xn;r.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(i,t.releaseSegment())}}}}if(0===d.length||d.at(-1).first+d.at(-1).second!==y+f){let t=y+f;t===e.getPathEnd(c)&&(t=e.getPathStart(c)),P!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(x,-1,null,!1))}}d.length=0,v=!0,l!==c&&(c=l,p=r.getSegmentCountPath(c),x=-1,P=-1),y=h,f=1}if(!C)break;{let t=o.Envelope2D.constructEmpty();C.queryLooseEnvelope(t),m.isIntersecting(t)?(v?d.push((0,n.o)(h,1)):d.at(-1).second++,v=!1):v=!0}_=h}}appendMultiPath(t,e,i){if(void 0===i)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;let r=e.getGeometryType()===s.G.enumPolygon,n=o.Envelope2D.constructEmpty();e.queryEnvelope(n),i.isIntersecting(n)&&(!i.containsEnvelope(n)&&e.getPointCount()>10?r?this.appendMultiPathPolygon(t,e,i):this.appendMultiPathPolyline(t,e,i):this.appendMultiPath_(t,e))}appendPoint(t,e,i){if(e.isEmpty()||void 0!==i&&!i.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);let s=this.insertPath(t,-1);this.insertVertex_(s,-1,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());let i=this.insertPath(t,-1);for(let t=0,s=e.getPointCount();t<s;t++)this.insertVertex_(i,-1,null,!1)}appendMultiPoint(t,e,i){if(void 0===i)return void this.appendMultiPoint_(t,e);let s=e.getAttributeStreamRef(0),r=0;for(let t=0,n=e.getPointCount();t<n;t++){let e=s.readPoint2D(2*t);i.contains(e)&&r++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+r);let n=-1,o=-1,a=0;for(let t=0,r=e.getPointCount();t<r;t++){let r=s.readPoint2D(2*t);i.contains(r)?(-1===n&&(n=t,o=t),o++):n>=0&&(this.m_verticesMp.addPoints(e,n,o-n),n=-1,a++)}if(n>0&&(this.m_verticesMp.addPoints(e,n,o-n),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+r);let l=this.insertPath(t,-1);for(let t=0,r=e.getPointCount();t<r;t++){let e=s.readPoint2D(2*t);i.contains(e)&&this.insertVertex_(l,-1,null,!1)}}splitSegmentForward(t,e,i,r,n){let o=this.getNextVertex(t);-1===o&&(0,s.a)("Edit_shape.split_segment_forward_");let a=this.getHelperPoint(),l=this.getPathFromVertex(t),h=t,m=this.hasSegmentParentage();for(let t=0,r=e.getResultSegmentCount(i);t<r;t++){let u=this.getVertexIndex(h),d=this.getNextVertex(h),g=e.getResultSegment(i,t),c=null;if(g.getGeometryType()!==s.G.enumLine&&(c=g.clone(),c.dropAllAttributes()),0===t&&(g.queryStart(a),this.setSegmentToIndex(u,null),this.setPointEx(h,a,e.getResultSegmentStartPointRank(i,t),e.getResultSegmentStartPointWeight(i,t),n)),this.setSegmentRank(h,e.getResultSegmentInteriorRank(i,t)),this.setSegmentWeight(h,e.getResultSegmentInteriorWeight(i,t)),m){let s=e.getResultSegmentSegmentParentage(i,t),r=e.getResultSegmentStartPointIsBreak(i,t);this.setSegmentParentageAndBreak(h,s,r)}if(g.queryEnd(a),t<r-1){this.setSegmentToIndex(u,c);let s=this.insertVertex(l,d,a);this.setWeight(s,e.getResultSegmentEndPointWeight(i,t)),this.setRank(s,e.getResultSegmentEndPointRank(i,t)),this.select(s),h=s}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(i,t),e.getResultSegmentEndPointWeight(i,t),n);let s=e.getResultSegmentEndPointIsBreak(i,t);this.setSegmentParentageBreakVertex(o,s),this.setSegmentToIndex(u,c)}}}splitSegmentBackward(t,e,i,r,n){let o=this.getNextVertex(t);-1===o&&(0,s.a)("Edit_shape.split_segment_backward_");let a=this.getHelperPoint(),l=this.getPathFromVertex(t),h=t,m=this.hasSegmentParentage();for(let t=0,r=e.getResultSegmentCount(i);t<r;t++){let u=r-t-1,d=this.getVertexIndex(h),g=this.getNextVertex(h),c=e.getResultSegment(i,u),_=null;if(c.getGeometryType()!==s.G.enumLine&&(_=c.clone(),_.reverse(),_.dropAllAttributes()),0===t&&(c.queryEnd(a),this.setSegmentToIndex(d,null),this.setPointEx(h,a,e.getResultSegmentEndPointRank(i,u),e.getResultSegmentEndPointWeight(i,u),n),this.setSegmentParentageAndBreak(h,e.getResultSegmentSegmentParentage(i,u),e.getResultSegmentEndPointIsBreak(i,u))),c.getGeometryType()===s.G.enumLine?this.setSegmentToIndex(d,null):this.setSegmentToIndex(d,_),this.setSegmentRank(h,e.getResultSegmentInteriorRank(i,u)),this.setSegmentWeight(h,e.getResultSegmentInteriorWeight(i,u)),c.queryStart(a),t<r-1){let t=this.insertVertex(l,g,a);this.setWeight(t,e.getResultSegmentStartPointWeight(i,u)),this.setRank(t,e.getResultSegmentStartPointRank(i,u)),this.select(t),h=t,m&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(i,u),e.getResultSegmentEndPointIsBreak(i,u))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(i,u),e.getResultSegmentStartPointWeight(i,u),n)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){let e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?(0,r.a0)(0,-1):(0,r.a0)(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){let t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return(0,r.a0)(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,i){let s=this.getNextVertex(t),r=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,r),this.setPrevVertex(r,t),this.setNextVertex(e,s),this.setPrevVertex(s,e),this.m_segments){let t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let i=this.getSegmentParentage(e),s=this.getSegmentParentage(t);(-1!==i||-1!==s)&&(s=(0,n.c)(i,i=s),this.setSegmentParentageAndBreak(t,s),this.setSegmentParentageAndBreak(e,i))}if(i){let e=this.getPathFromVertex(t),i=this.getGeometryFromPath(e),n=[!1],o=this.insertClosedPath(i,-1,s,this.getFirstVertex(e),n);n[0]&&this.setFirstVertex(e,r);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return-1}sortVerticesSimpleByYHelper(t,e,i){t.sort(e,i,(t,e)=>{let i=this.compareVerticesSimpleY(t,e);if(0===i){let s=this.getPathInternalIndexFromVertex(t),r=this.getPathInternalIndexFromVertex(e);i=s<r?-1:+(s>r)}return i})}sortVerticesSimpleByYHelper3D(t,e,i){(0,s.g)(0)}constructor(){this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=-1,this.m_lastGeometry=-1,this.m_vertexIndexList=new r.S(5),this.m_pathIndexList=new r.S(8),this.m_geometryIndexList=new r.S(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new r.B,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o.Envelope2D(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);let e=this.hasCurves(),i=o.Envelope2D.constructEmpty(),s=this.queryVertexIterator(),r=!0;for(let t=s.next();-1!==t;t=s.next()){if(r?i.merge(this.getXY(t)):i.mergeNe(this.getXY(t)),e){let e=this.getSegment(t);if(null!==e){let t=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(t),i.mergeEnvelope2D(t)}}r=!1}return i}getEnvelope3D(t){return(0,s.g)(0),r.r.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,s.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){let i=t.getGeometryType();if((0,s.j)(i))return this.addMultiPath(t,e);if(i===s.G.enumMultiPoint)return this.addMultiPoint(t,e);if(i===s.G.enumPoint)return this.addPoint_(t,e);if(i===s.G.enumEnvelope){let i=new ni;return i.addEnvelope(t,!1),this.addMultiPath(i,e)}(0,s.a)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());let i=e.getGeometryType();(0,s.j)(i)?this.appendMultiPath(t,e):i!==s.G.enumMultiPoint?(0,s.a)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);let i=this.queryVertexIterator();for(let t=i.next();-1!==t;t=i.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(s.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=-1,i=-1,r=-1;for(let n=this.getFirstGeometry();-1!==n;){if(t===s.G.enumUnknown||this.getGeometryType(n)===t){if(-1===e){e=n,i=this.getPathCount(e),r=this.getPointCount(e),n=this.getNextGeometry(n);continue}for(let t=this.getFirstPath(n);-1!==t;t=this.getNextPath(t))this.setPathGeometry(t,e);i+=this.getPathCount(n),r+=this.getPointCount(n);let t=this.getLastPath(e),s=this.getFirstPath(n);-1===t?this.setFirstPath(e,s):this.setNextPath(t,s),-1!==s&&(this.setPrevPath(s,t),this.setLastPath(e,this.getLastPath(n))),this.setFirstPath(n,-1),this.setLastPath(n,-1);let o=n;n=this.getNextGeometry(n),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}n=this.getNextGeometry(n)}return-1!==e&&(this.setGeometryVertexCount(e,r),this.setGeometryPathCount(e,i),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let i=this.m_geometryIndexList.getField(t,2);i&=-134217729,i|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,i)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let i=this.m_geometryIndexList.getField(t,2);!!(67108864&i)!==e&&(i&=-67108865,i|=e?67108864:0,this.m_geometryIndexList.setField(t,2,i))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){let i=this.getPathFromVertex(t),s=this.getGeometryFromPath(i);this.setGeometryModified(s,e)}getGeometryModifiedWithVertex(t){let e=this.getPathFromVertex(t),i=this.getGeometryFromPath(e);return this.getGeometryModified(i)}swapGeometry(t,e){let i=this.getFirstPath(t),s=this.getFirstPath(e),r=this.getLastPath(t),n=this.getLastPath(e);for(let i=this.getFirstPath(t);-1!==i;i=this.getNextPath(i))this.setPathGeometry(i,e);for(let i=this.getFirstPath(e);-1!==i;i=this.getNextPath(i))this.setPathGeometry(i,t);this.setFirstPath(t,s),this.setFirstPath(e,i),this.setLastPath(t,n),this.setLastPath(e,r);let o=this.getPointCount(t),a=this.getPathCount(t),l=this.getPointCount(e),h=this.getPathCount(e);this.setGeometryVertexCount(t,l),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,h),this.setGeometryPathCount(e,a);let m=this.m_geometryIndexList.getField(t,2),u=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,u),this.m_geometryIndexList.setField(e,2,m)}addPathFromMultiPath(t,e,i){let r=this.createGeometry(i?s.G.enumPolygon:s.G.enumPolyline,t.getDescription()),n=t.getImpl();if(t.getPathSize(e)<2)return r;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),n.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);let o=this.insertPath(r,-1);this.setClosedPath(o,n.isClosedPath(e)||i);let a=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef();for(let t=n.getPathStart(e),i=n.getPathEnd(e);t<i;t++){let e=this.insertVertex_(o,-1,null,!1);if(a){let i=this.getVertexIndex(e);if(1&n.getSegmentFlags(t))this.setSegmentToIndex(i,null);else{let e=new Xn;n.querySegment(t,e,!0),this.setSegmentToIndex(i,e.releaseSegment())}}}return n.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),n.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),r}getGeometry(t){let e=this.getGeometryType(t),i=function(t,e){let i,n=e,o=null;switch(n||=(o=(0,s.k)(t)?(0,r.$)():(0,r.K)(),o),t){case s.G.enumPoint:i=new r.P({vd:n});break;case s.G.enumLine:i=new Yn({vd:n});break;case s.G.enumBezier:i=new vs({vd:n});break;case s.G.enumEllipticArc:i=new Ar({vd:n});break;case s.G.enumRationalBezier2:i=new Ut({vd:n});break;case s.G.enumBezier2:i=new Qt({vd:n});break;case s.G.enumEnvelope:i=new r.E({vd:n});break;case s.G.enumMultiPoint:i=new _({vd:n});break;case s.G.enumPolyline:i=new Dt({vd:n});break;case s.G.enumPolygon:i=new ni({vd:n});break;case s.G.enumMultipatch:(0,s.t)("multipatch not impl");break;case s.G.enumGeometryCollection:i=new U({vd:n});break;default:(0,s.a)("Geometry.create")}return i}(e,this.m_verticesMp.getDescription()),n=this.getPointCount(t);if(0===n)return i;if((0,s.j)(e)){let e=i.getImpl(),s=this.getPathCount(t),o=(0,r.a0)(s+1),a=(0,r.a1)(s+1,0),l=i.getDescription(),h=this.hasCurves();for(let i=0,h=l.getAttributeCount();i<h;i++){let h=l.getSemantics(i),m=oi.getComponentCount(h),u=(0,r.W)(h,n),d=this.m_vertices.getAttributeStreamRef(h),g=0,c=0,_=0;for(let e=this.getFirstPath(t);-1!==e;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&&a.setBits(c,t);let i=this.getPathSize(e);if(o.write(c++,_),_+=i,0===h){let t,i=d,s=u;for(let r=this.getFirstVertex(e);g<_;r=this.getNextVertex(r),g++){let e=this.getVertexIndex(r);t=i.readPoint2D(2*e),s.writePoint2D(2*g,t)}}else for(let t=this.getFirstVertex(e);g<_;t=this.getNextVertex(t),g++){let e=this.getVertexIndex(t);for(let t=0;t<m;t++){let i=d.readAsDbl(e*m+t);u.writeAsDbl(g*m+t,i)}}}e.setAttributeStreamRef(h,u),o.write(s,n)}if(e.setPathFlagsStreamRef(a),e.setPathStreamRef(o),e.notifyModifiedFlags(65535),h){let i=0,s=0;for(let r=this.getFirstPath(t);-1!==r;r=this.getNextPath(r)){i+=this.getPathSize(r);for(let t=this.getFirstVertex(r);s<i;t=this.getNextVertex(t)){let i=this.getSegment(t);null!==i&&i.isCurve()&&e.replaceSegment(s,i,!0),s++}}}}else if(e===s.G.enumMultiPoint){let e=i.getImpl(),s=i.getDescription();e.reserve(n),e.resizeNoInit(n);for(let i=0,r=s.getAttributeCount();i<r;i++){let r=s.getSemantics(i),n=oi.getComponentCount(r),o=e.getAttributeStreamRef(r),a=this.m_vertices.getAttributeStreamRef(r),l=0,h=this.getFirstPath(t),m=this.getPathSize(h);for(let t=this.getFirstVertex(h);l<m;t=this.getNextVertex(t),l++){let e=this.getVertexIndex(t);for(let t=0;t<n;t++){let i=a.readAsDbl(e*n+t);o.writeAsDbl(l*n+t,i)}}e.setAttributeStreamRef(r,o)}e.notifyModifiedFlags(65535)}else(0,s.d)("getGeometry");return i}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==s.G.enumMultiPoint&&(0,s.a)("get_point_geometry_only");let i=this.getPointCount(t);if(i>1&&(0,s.a)("get_point_geometry_only"),0===i)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();let r=this.getFirstPath(t),n=this.getFirstVertex(r);this.queryPoint(n,e)}removeGeometry(t){for(let e=this.getFirstPath(t);-1!==e;e=this.removePath(e));let e=this.getPrevGeometry(t),i=this.getNextGeometry(t);return-1===e?this.m_firstGeometry=i:this.setNextGeometry(e,i),-1===i?this.m_lastGeometry=e:this.setPrevGeometry(i,e),this.freeGeometry(t),i}createGeometry(t,e){void 0===e&&(e=(0,r.K)());let i=this.newGeometry(t);return this.m_vertices||=(this.m_verticesMp=new _({vd:e}),this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),-1===this.m_firstGeometry?(this.m_firstGeometry=i,this.m_lastGeometry=i):(this.setPrevGeometry(i,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,i),this.m_lastGeometry=i),i}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,i){let s=this.m_geometryIndices[e],r=this.getGeometryIndex(t);r>=s.size()&&s.resize(Math.max(1.25*r,16),-1),s.write(r,i)}getGeometryUserIndex(t,e){let i=this.getGeometryIndex(t),s=this.m_geometryIndices[e];return i<s.size()?s.read(i):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=(0,r.a0)(0),t;this.m_geometryIndices.push((0,r.a0)(0));let t=this.m_geometryIndices.length-1;return(0,s.g)(t>=0&&t<=2**53-1),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();-1!==t;t=this.getNextGeometry(t))if(!(0,s.j)(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,i,r,o){let a=t*t,l=0,h=this.hasCurves(),m=this.hasSegmentParentage();for(let t=-1===o?this.getFirstGeometry():o;-1!==t;t=-1===o?this.getNextGeometry(t):-1){let o=this.getGeometryType(t);if(!(0,s.j)(o)||i&&o!==s.G.enumPolygon)continue;let u=this.getGeometryType(t)===s.G.enumPolygon,d=this.getGeometryModified(t);for(let i=this.getFirstPath(t);-1!==i;){let o=0;for(let e=this.getFirstVertex(i);o<Math.trunc(this.getPathSize(i)/2);){let u=this.getNextVertex(e);if(-1===u)break;let g=this.getXY(e),c=this.getXY(u),_=n.P.sqrDistance(g,c),p=!0;do{if(_<=a){if(h){let t=this.getSegment(e);if(null!==t){let e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===l&&(l=-1):l=1,u!==this.getLastVertex(i)){let i=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(u));if(this.transferAllDataToTheVertex(u,e,!0),this.removeVertex(u,!1),r&&!d&&(this.setGeometryModified(t,!0),d=!0),m&&e!==u){this.setSegmentParentageBreakVertex(e,i);let t=this.getNextVertex(e);(0,s.g)(-1!==t),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}p=!1}}while(0);p&&(e=this.getNextVertex(e)),o++}let g=this.getFirstVertex(i);for(let e=this.isClosedPath(i)?g:this.getLastVertex(i);this.getPathSize(i)>0;){let o=this.getPrevVertex(e);if(-1===o)break;{let u=this.getXY(o),c=this.getXY(e),_=n.P.sqrDistance(u,c),p=!0;do{if(_<=a){if(h){let t=this.getSegment(o);if(null!==t){let e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===l&&(l=-1):l=1,m){(0,s.g)(this.m_segmentParentageIndex>=0);let t=this.getUserIndex(e,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(o,e,!0),this.setUserIndex(e,this.m_segmentParentageIndex,t)}else this.transferAllDataToTheVertex(o,e,!0);let n=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(o));this.removeVertex(o,!0),r&&!d&&(this.setGeometryModified(t,!0),d=!0),m&&o!==e&&(n||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),g===o&&(g=this.getFirstVertex(i)),p=!1}}while(0);if(p&&(e=this.getPrevVertex(e),e===g))break}}let c=this.getPathSize(i),_=e&&c<(u?3:2);_&&u&&2===c&&h&&(_=!this.pathHasCurves(i)),_?(i=this.removePath(i),0===l&&(l=-1),r&&!d&&(this.setGeometryModified(t,!0),d=!0)):i=this.getNextPath(i)}}return l}filterClosePoints3D(t,e,i,r,n,o){return(0,s.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();-1!==e;e=this.getNextGeometry(e))if((0,s.j)(this.getGeometryType(e)))for(let i=this.getFirstPath(e);-1!==i;){let e=this.getPathSize(i);if(0===e)return!0;let s=this.getFirstVertex(i);for(let i=0;i<e;i++){let e=this.getNextVertex(s);if(-1===e)break;let i=this.getVertexIndex(s),r=this.getSegmentFromIndex(i),n=0;if(null!==r){if(n=r.calculateLowerLength2D(),n<=t&&(n=r.calculateUpperLength2D(),n<=t||(n=r.calculateLength2D(),n<=t)))return!0}else{let s=this.getVertexIndex(e);if(n=this.m_vertices.getShortestDistance(i,s),n<=t)return!0}s=e}i=this.getNextPath(i)}return!1}hasDegenerateSegments3D(t,e){return(0,s.g)(0),!1}transferAllDataToTheVertex(t,e,i=!1){let s=this.getVertexIndex(t),r=this.getVertexIndex(e);if(i){let t=1,e=1;if(this.m_ranks&&(t=this.getRankWithIndex(s),e=this.getRankWithIndex(r)),t>e&&this.setRankWithIndex(r,t),t>=e&&this.m_weights){let i=this.getWeightWithIndex(s),n=this.getWeightWithIndex(r);(t>e||i>n)&&this.setWeightWithIndex(r,i)}}else{if(this.m_weights){let t=this.getWeightWithIndex(s);this.setWeightWithIndex(r,t)}if(this.m_ranks){let t=this.getRankWithIndex(s);this.setRankWithIndex(r,t)}}if(this.m_segmentWeights){let t=this.getSegmentWeightWithIndex(s);this.setSegmentWeightWithIndex(r,t)}if(this.m_segmentRanks){let t=this.getSegmentRankWithIndex(s);this.setSegmentRankWithIndex(r,t)}for(let i=0,s=this.m_indices.length;i<s;i++)if(i!==this.m_selectionIndex&&null!==this.m_indices[i]){let s=this.getUserIndex(t,i);this.setUserIndex(e,i,s)}let n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,i,r,n){let o=0,a=this.getNextVertex(t);-1===a&&(0,s.a)("");let l=this.getVertexIndex(t),h=this.getVertexIndex(a),m=this.getSegmentFromIndex(l),u=this.m_vertices.getShortestDistance(l,h),d=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&m&&(u=m.calculateLength2D());let c=this.getSegmentParentage(t),_=this.getHelperPoint();if(m){let t=0,s=0,n=-1;for(let p=0;p<i;p++){let i=e[p];if(t<i&&i<1){let e=m.cut(t,i);if(null!==r&&(p>0&&e.setStartXY(r[p-1]),e.setEndXY(r[p]),e.normalizeAfterEndpointChange(),s=p),g){let t=u>0?m.calculateSubLengthFromStart(i)/u:0;this.m_vertices.interpolateTwoVertices(l,h,t,_)}_.setXY(e.getEndXY()),n=this.insertVertex(d,a,_),o++;let f=this.getPrevVertex(n),y=this.getVertexIndex(f);this.setSegmentToIndex(y,e),-1!==c&&this.setSegmentParentageAndBreak(n,c,!1),t=i}}if(-1!==n){let e=m.cut(t,1);null!==r&&(e.setStartXY(r[s]),e.normalizeAfterEndpointChange());let i=this.getVertexIndex(n);this.setSegmentToIndex(i,e)}}else{let t=0;for(let s=0;s<i;s++){let i=e[s];if(t<i&&i<1){this.m_vertices.interpolateTwoVertices(l,h,i,_);let t=this.insertVertex(d,a,_);o++,-1!==c&&this.setSegmentParentageAndBreak(t,c,!1)}t=i}}return o}splitSegment(t,e,i,s=null){return this.splitSegmentAxisAware(t,e,i,s,-1)}snapControlPoints(t,e,i){-1===this.getNextVertex(t)&&(0,s.a)("");let r=t,n=!1;for(let t=0;t<e;++t){let t=this.getVertexIndex(r),e=this.getSegmentFromIndex(t);if(e){let t=e.snapControlPoints(i);n||=t}r=this.getNextVertex(r)}return n}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0,i=this.queryVertexIteratorOnSelection();for(let s=i.next();-1!==s;s=i.next()){let i=this.getVertexIndex(s),r=this.getSegmentFromIndex(i);r&&(e|=+!!r.snapControlPoints(t))}return 0!==e}calculateSubLength2D(t,e,i){return(0,s.g)(0),0}setPoint(t,e,i){if(this.setPointOnly(t,e),null!==this.m_segments){let s=this.getVertexIndex(t),r=this.getSegmentFromIndex(s);null!==r&&(r.setStartXY(e.getXY()),r.normalizeAfterEndpointChange(),i&&r.ensureXYMonotone());let n=this.getPrevVertex(t);if(-1!==n){let t=this.getVertexIndex(n),s=this.getSegmentFromIndex(t);null!==s&&(s.setEndXY(e.getXY()),s.normalizeAfterEndpointChange(),i&&s.ensureXYMonotone())}}}setPointEx(t,e,i,s,r){this.setPoint(t,e,r);let n=this.getVertexIndex(t);this.setWeightWithIndex(n,s),this.setRankWithIndex(n,i)}setPointOnly(t,e){let i=this.getVertexIndex(t);this.m_vertices.setPointByValNoCurves(i,e)}setPointOnlyEx(t,e,i,r){(0,s.g)(0)}queryPoint(t,e){let i=this.getVertexIndex(t);this.m_vertices.getPointByVal(i,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,i){let s=this.getVertexIndex(t);if(this.m_vertices?.setXYCoordsNoCurves(s,e,i),null!==this.m_segments){let r=this.getSegmentFromIndex(s);null!==r&&(r.setStartXYCoords(e,i),r.normalizeAfterEndpointChange());let n=this.getPrevVertex(t);if(-1!==n){let t=this.getVertexIndex(n),s=this.getSegmentFromIndex(t);null!=s&&(s.setEndXYCoords(e,i),s.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,i){let s=this.getVertexIndex(t);if(this.m_vertices.setXYCoordsNoCurves(s,e,i),null!==this.m_segments){let r=this.getSegmentFromIndex(s);if(null!==r){let t=r.getEndXY();r.setCoordsForIntersector(new n.P(e,i),t,!1),r.ensureXYMonotone()}let o=this.getPrevVertex(t);if(-1!==o){let t=this.getVertexIndex(o),s=this.getSegmentFromIndex(t);if(null!==s){let t=s.getStartXY();s.setCoordsForIntersector(t,new n.P(e,i),!1),s.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){let i=this.getVertexIndex(t);return this.m_vertices.queryXY(i,e)}getXY(t){let e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,i){(0,s.g)(0)}setXYZ(t,e,i){(0,s.g)(0)}setXYZCoords(t,e,i,r){(0,s.g)(0)}queryXYZ(t,e){(0,s.g)(0)}getXYZ(t){return(0,s.g)(0),r.k.getNAN()}getXYZWithIndex(t){return(0,s.g)(0),r.k.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){(0,s.g)(0)}getAttributeAsDbl(t,e,i){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),i)}queryAttributeAsDbl(t,e,i,r){(0,s.g)(0)}setAttribute(t,e,i,r){(0,s.g)(0)}setAttributeInt(t,e,i,r){(0,s.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,s.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){let 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(0,s.g)(0),!1}setWeight(t,e){e<1&&(e=1);let i=1===e;if(null==this.m_weights){if(i)return;this.m_weights=(0,r.a2)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_weights.size()){if(i)return;this.m_weights.resize(s+1,1)}this.m_weights.write(s,e)}setWeightWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_weights){if(i)return;this.m_weights=(0,r.a2)(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(i)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;let 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 1;let e=this.getVertexIndex(t);return e>=this.m_ranks.size()?1:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?1:this.m_ranks.read(t)}setRank(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_ranks){if(i)return;this.m_ranks=(0,r.a0)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_ranks.size()){if(i)return;this.m_ranks.resize(s+1,1)}this.m_ranks.write(s,e)}setRankWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_ranks){if(i)return;this.m_ranks=(0,r.a0)(this.m_vertices.getPointCount(),1)}if(t>=this.m_ranks.size()){if(i)return;this.m_ranks.resize(t+1,1)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentWeights){if(i)return;this.m_segmentWeights=(0,r.a2)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_segmentWeights.size()){if(i)return;this.m_segmentWeights.resize(s+1,1)}this.m_segmentWeights.write(s,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null==this.m_segmentWeights){if(i)return;this.m_segmentWeights=(0,r.a2)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(i)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;let 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 mi.st_defaultRank;let e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?mi.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?1:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentRanks){if(i)return;this.m_segmentRanks=(0,r.a0)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_segmentRanks.size()){if(i)return;this.m_segmentRanks.resize(s+1,1)}this.m_segmentRanks.write(s,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentRanks){if(i)return;this.m_segmentRanks=(0,r.a0)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(i)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}static st_defaultRank=1;removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,i){let s=this.m_indices[e],r=this.getVertexIndex(t);if(s.size()<=r){if(-1===i)return;s.resize(this.m_vertices.getPointCount(),-1)}s.write(r,i)}getUserIndex(t,e){let i=this.getVertexIndex(t),s=this.m_indices[e];return i<s.size()?s.read(i):-1}addToUserIndex(t,e,i){let s=this.m_indices[e],r=this.getVertexIndex(t);s.size()<=r&&s.resize(this.m_vertices.getPointCount(),-1);let n=s.read(r);s.write(r,n+i)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());let t=this.m_indices.length-1;return(0,s.g)(t>=0&&t<=(0,n.i)()),t}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));let t=this.m_indices.length-1;return(0,s.g)(t>=0&&t<=2**53-1),t}fillUserIndexForGeometry(t,e,i){let s=this.m_indices[e],r=s.size();for(let e=this.getFirstPath(t);-1!==e;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let n=0,o=this.getPathSize(e);n<o;n++,t=this.getNextVertex(t)){let e=this.getVertexIndex(t);e<r&&s.write(e,i)}}}fillUserIndexForSelection(t,e){(0,s.g)(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){let e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,i=!1){let s=this.getNextVertex(t);if(-1===s)return!1;if(!this.m_bHasAttributes||i){let i=this.getXY(t);e.setStartXY(i);let r=this.getXY(s);e.setEndXY(r)}else{let i=new r.P({vd:this.getVertexDescription()});this.queryPoint(t,i),e.setStart(i),this.queryPoint(s,i),e.setEnd(i)}return!0}queryLineConnector3D(t,e,i=!1){return(0,s.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,s.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;let e=this.getFirstVertex(t);if(-1===e)return!1;let i=this.getPathSize(t),r=e;for(let t=0;t<i;t++,r=this.getNextVertex(r)){let t=this.getSegment(r);if(null!==t&&t.getGeometryType()!==s.G.enumLine)return!0}return!1}insertPath(t,e){let i=-1;-1===e?i=this.getLastPath(t):(t!==this.getGeometryFromPath(e)&&(0,s.a)(""),i=this.getPrevPath(e));let r=this.newPath(t);return-1!==e&&this.setPrevPath(e,r),this.setNextPath(r,e),this.setPrevPath(r,i),-1===i?this.setFirstPath(t,r):this.setNextPath(i,r),-1===e&&this.setLastPath(t,r),this.setGeometryPathCount(t,this.getPathCount(t)+1),r}removePath(t){let e=this.getPrevPath(t),i=this.getNextPath(t),s=this.getGeometryFromPath(t);return-1===e?this.setFirstPath(s,i):this.setNextPath(e,i),-1===i?this.setLastPath(s,e):this.setPrevPath(i,e),this.clearPath(t),this.setGeometryPathCount(s,this.getPathCount(s)-1),this.freePath(t),i}clearPath(t){let e=this.getFirstVertex(t);if(-1!==e){let i=e;for(let e=0,s=this.getPathSize(t);e<s;e++){let t=i;i=this.getNextVertex(i),this.freeVertex(t)}let s=this.getGeometryFromPath(t);this.setGeometryVertexCount(s,this.getPointCount(s)-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){let i=this.getFirstVertex(t),s=this.getLastVertex(t);if(e){this.setNextVertex(s,i),this.setPrevVertex(i,s);let t=this.getVertexIndex(s);this.setSegmentToIndex(t,null)}else{this.setNextVertex(s,-1),this.setPrevVertex(i,-1);let t=this.getVertexIndex(s);this.setSegmentToIndex(t,null)}}let i=(1|this.getPathFlags(t))-1;this.setPathFlags(t,i|+!!e)}closeAllPaths(t){(0,s.g)(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){let i=(8|this.getPathFlags(t))-8;this.setPathFlags(t,i|(e?8:0))}setStrongPathEnd(t,e){let i=(16|this.getPathFlags(t))-16;this.setPathFlags(t,i|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){let i=(2|this.getPathFlags(t))-2;this.setPathFlags(t,i|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];let e=this.getFirstVertex(t);if(-1===e)return 0;let i=this.getXY(e),r=new n.K(0),o=this.getPathSize(t);if(o>2){let t=i.clone(),s=t.x,a=t.y,l=this.getNextVertex(e),h=this.getXY(l);l=this.getNextVertex(l);let m=n.P.getNAN();for(let e=2;e<o;e++,l=this.getNextVertex(l))this.queryXY(l,m),r.pe((m.x-t.x)*(h.y-a)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(m);r.pe((s-t.x)*(h.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){let e=this.getSegment(t);if(null===e||e.getGeometryType()===s.G.enumLine)continue;let i=2*e.calculateArea2DHelper();r.pe(i)}}this.setRingAreaValid(t,!0);let a=.5*r.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,i){let s=this.m_pathindices[e],r=this.getPathIndex(t);s.size()<this.m_pathAreas.length&&s.resize(this.m_pathAreas.length,-1),s.write(r,i)}getPathUserIndex(t,e){let i=this.getPathIndex(t),s=this.m_pathindices[e];return i<s.size()?s.read(i):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());let t=this.m_pathindices.length-1;return(0,s.g)(t>=0&&t<=2**53-1),t}fillPathUserIndexForGeometry(t,e,i){let s=this.m_pathindices[e],r=s.size();for(let e=this.getFirstPath(t);-1!==e;e=this.getNextPath(e)){let t=this.getPathIndex(e);t<r&&s.write(t,i)}}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,e,i){if(-1===i&&(0,s.a)(""),e===i)return;let r=this.getNextPath(i),n=this.getPrevPath(i),o=this.getGeometryFromPath(i);-1===n?this.setFirstPath(o,r):this.setNextPath(n,r),-1===r?this.setLastPath(o,n):this.setPrevPath(r,n),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(i)),this.setGeometryPathCount(o,this.getPathCount(o)-1),n=-1===e?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(i,n),this.setNextPath(i,e),-1===e?this.setLastPath(t,i):this.setPrevPath(e,i),-1===n?this.setFirstPath(t,i):this.setNextPath(n,i),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(i)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(i,t)}addVertex(t,e){return this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint()),this.insertVertex_(t,-1,this.getHelperPoint(),!1)}insertVertex(t,e,i){return this.insertVertex_(t,e,i,!0)}removeVertex(t,e){let i=this.getPathFromVertex(t),s=this.getPrevVertex(t),r=this.getNextVertex(t);-1!==s&&this.setNextVertex(s,r);let n=this.getPathSize(i);if(t===this.getFirstVertex(i)&&this.setFirstVertex(i,n>1?r:-1),-1!==r&&this.setPrevVertex(r,s),t===this.getLastVertex(i)&&this.setLastVertex(i,n>1?s:-1),this.hasCurves()&&-1!==s&&-1!==r){let i=this.getVertexIndex(t),n=this.getVertexIndex(s),o=this.getVertexIndex(r);if(e){let t=this.getSegmentFromIndex(n);if(null!==t){let e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(i,null)}else{let t=this.getSegmentFromIndex(i);if(this.setSegmentToIndex(i,null),null!==t){let e=this.m_vertices.getXY(n);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,t)}}this.setPathSize(i,n-1);let o=this.getGeometryFromPath(i);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),r}removeVertices(t,e){(0,s.g)(t!==e);let i=this.getPathFromVertex(t),r=this.getPrevVertex(t),n=this.getPrevVertex(e);-1!==r&&this.setNextVertex(r,e);let o=this.getPathSize(i),a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,r),this.setPrevVertex(t,-1),this.setNextVertex(n,-1);let l=0,h=t,m=this.getFirstVertex(i),u=!1;for(;;){let t=this.getNextVertex(h);if(u||=m===h,this.freeVertex(h),l++,h===n)break;h=t}o-=l,u&&this.setFirstVertex(i,o>0?e:-1),this.setPathSize(i,o);let d=this.getGeometryFromPath(i);this.setGeometryVertexCount(d,this.getPointCount(d)-l)}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,-1,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,s.d)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();-1!==t;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);-1!==e;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let i=0,s=this.getPathSize(e);i<s;i++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=-1){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=-1){let i=-1,r=-1,n=-1,o=-1,a=0,l=!1;for(i=-1===e?this.getFirstGeometry():e;-1!==i;i=this.getNextGeometry(i))if(!t||(0,s.j)(this.getGeometryType(i))){for(r=this.getFirstPath(i);-1!==r;r=this.getNextPath(r))if(n=this.getFirstVertex(r),o=n,a=0,-1!==n){l=!0;break}if(l||-1!==e)break}return l||(i=-1),li.create_(this,i,r,n,o,a,t,!1,-1!==e)}queryVertexIteratorOnSelection(t=-1){return this.m_selection?li.create_(this,t,-1,-1,-1,-1,!1,!0,-1!==t):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,s.g)(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;let e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=-1,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(0,s.g)(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,i=this.m_segments.length;e<i;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,i,s,r){s?this.splitSegmentForward(t,e,i,!0,r):this.splitSegmentBackward(t,e,i,!0,r)}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){let e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){if(null===this.m_segments)return!1;let e=this.getVertexIndex(t);return this.m_segments.length>e&&null!==this.m_segments[e]}querySegment(t,e,i=!0,s=!1){let r=this.getNextVertex(t);if(-1===r)return!1;let n=this.getSegment(t);if(!n)return!i&&(this.queryLineConnector(t,e.createLine(),s),!0);if(e.copyFrom(n,!0),s)return!0;if(this.m_vertexDescription.getAttributeCount()>1){let i=this.getHelperPoint();this.queryPoint(t,i),e.get().setStart(i),this.queryPoint(r,i),e.get().setEnd(i)}return!0}getSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||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(0,s.g)(0),!1}reverseRingInternal(t){let e=this.hasCurves(),i=this.hasSegmentParentage(),s=null,r=-1,n=t;if(e){let t=this.getVertexIndex(n);s=this.getAndClearSegmentFromIndex(t)}i&&(r=this.getSegmentParentage(n));do{let t=this.getPrevVertex(n),o=this.getNextVertex(n);if(this.setNextVertex(n,t),this.setPrevVertex(n,o),e){let t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);s&&s.reverse(),this.setSegmentToIndex(t,s),s=e}if(i){let t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,r),r=t}n=o}while(n!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){let e=this.getPrevPath(t),i=this.getNextPath(t),s=this.getGeometryFromPath(t);-1===e?this.setFirstPath(s,i):this.setNextPath(e,i),-1===i?this.setLastPath(s,e):this.setPrevPath(i,e),this.setFirstVertex(t,-1),this.setLastVertex(t,-1),this.freePath(t)}insertClosedPath(t,e,i,s,r){let n=this.insertPath(t,-1),o=0,a=i;for(r[0]=!1;;){a===s&&(r[0]=!0),this.setPathToVertex(a,n),o++;let t=this.getNextVertex(a);if(t===i)break;a=t}return this.setClosedPath(n,!0),this.setPathSize(n,o),r[0]&&(i=s),this.setFirstVertex(n,i),this.setLastVertex(n,this.getPrevVertex(i)),this.setRingAreaValid(n,!1),n}findVertex2D(t,e){return(0,s.g)(0),0}findVertex3D(t,e,i){return(0,s.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}getNextNthVertex(t,e){if(0===e)return t;let i=t;for(let t=0;t<e;++t)if(i=e>0?this.getNextVertex(i):this.getPrevVertex(i),-1===i)return-1;return i}removeVertexInternal(t,e){let i=this.getPrevVertex(t),s=this.getNextVertex(t);if(-1!==i&&this.setNextVertex(i,s),-1!==s&&this.setPrevVertex(s,i),this.hasCurves()&&-1!==i&&-1!==s){let r=this.getVertexIndex(t),n=this.getVertexIndex(i),o=this.getVertexIndex(s);if(e){let t=this.getSegmentFromIndex(n);if(null!==t){let e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,null)}else{let t=this.getSegmentFromIndex(r);if(this.setSegmentToIndex(r,null),null!==t){let e=this.m_vertices.getXY(n);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,t)}}return this.freeVertex(t),s}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){let i=(4|this.getPathFlags(t))-4;this.setPathFlags(t,i|(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){(0,s.g)(0)}sortVerticesSimpleByY(t,e,i){this.m_bucketSort.sort(t,e,i,new ai(this))}sortVerticesSimpleByX(t,e,i){(0,s.g)(0)}sortVerticesSimpleByY3D(t,e,i){(0,s.g)(0)}snapVertexForPoleClipping(t,e){let i=this.getPrevVertex(t);-1!==i&&this.replaceCurveWithLine(i),-1!==this.getNextVertex(t)&&this.replaceCurveWithLine(t);let s=new n.P;this.queryXY(t,s),s.y=e,this.setXY(t,s)}setSegmentParentageAndBreak(t,e,i=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,s.g)(e<=(0,n.j)()>>1),e<<=1,e|=+!!i),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,s.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,s.g)(e<=(0,n.j)()>>1),e<<=1,e|=+!!this.getSegmentParentageBreakVertex(t)),this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;let e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){let e=this.getSegmentParentage(t);return new hi(e)}return new hi(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let i=this.getUserIndex(t,this.m_segmentParentageIndex);i<0||!!(1&i)!==e&&(e?i|=1:i&=(0,n.j)()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,i))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;let e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){let e=this.getPrevVertex(t);return-1!==e&&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 ui(t){if(t.isEmpty())return new ni({vd:t.getDescription()});if((0,s.j)(t.getGeometryType())&&t.hasNonLinearSegments())return function(t){(0,s.g)(t.hasNonLinearSegments()&&!t.isEmpty());let e=new pi;return e.addGeometry(t),e.getBoundingGeometry()}(t);let e=t.getImpl(),i=e.getPointCount();if(i<=2){if(1===i||e.getXY(0).equals(e.getXY(1))){let t=new r.P({vd:e.getDescription()});return e.getPointByVal(0,t),t}{let t=new r.P,i=new Dt({vd:e.getDescription()});return e.getPointByVal(0,t),i.startPathPoint(t),e.getPointByVal(1,t),i.lineToPoint(t),i}}let o=e.getAttributeStreamRef(0),a=new pi({stream:o,n:i}),l=1,h=o.readPoint2D(0),m=new n.P;for(;l<i&&o.queryPoint2D(l<<1,m).equals(h);)l++;if(a.m_treeHull.addElement(0),l<i){a.m_treeHull.addBiggestElement(l);let t=new n.P;for(let i=l+1;i<e.getPointCount();i++){o.queryPoint2D(i<<1,t);let e=a.treeHull(t);-1!==e&&a.m_treeHull.setElement(e,i)}}let u=e.getDescription(),d=u.getAttributeCount()>1,g=a.m_treeHull.size(),c=null;if(g>=2){c=g>=3?new ni({vd:u}):new Dt({vd:u});let t=c.getImpl();t.reserve(a.m_treeHull.size()),t.addPathPoint2D(null,0,!0);let i=new n.P;for(let s=a.m_treeHull.getFirst();-1!==s;s=a.m_treeHull.getNext(s))if(d){let i=new r.P;e.getPointByVal(a.m_treeHull.getElement(s),i),t.insertPoint(0,-1,i)}else o.queryPoint2D(a.m_treeHull.getElement(s)<<1,i),t.insertPoint2D(0,-1,i)}else if(d){let t=new r.P({vd:u});e.getPointByVal(a.m_treeHull.getElement(a.m_treeHull.getFirst()),t),c=t}else{let t=o.readPoint2D(a.m_treeHull.getElement(a.m_treeHull.getFirst())<<1);c=new r.P(t)}return c}function di(t,e,i,s=!1){if(e<=262144)return function(t,e,i,s){let n=new r.a(0);for(let t=0;t<e;t++)n.add(t);s||r.B.sortEx(n,0,e,{userSort(e,i,s){s.sort(e,i,(e,i)=>t[e].compareX(t[i]))},getValue:e=>t[e].x});let o=0;t:for(let s=0;s<e;++s){let e=n.read(s);for(;o>=2;){let r=i[o-2],a=i[o-1];if(t[a].equals(t[e])){n.write(s,-1);continue t}if(!(fi(t[r],t[a],t[e])>=0)){a===n.read(s-1)&&n.write(s-1,-1);break}o--}i[o++]=e,2===o&&t[e].equals(t[i[0]])&&(n.write(1,-1),o--)}let a=o+1;t:for(let s=e-2;s>=0;--s){let e=n.read(s);if(!(e<0)){for(;o>=a;){let s=i[o-2],r=i[o-1];if(t[r].equals(t[e]))continue t;if(!(yi(t[s],t[r],t[e])>=0))break;o--}if(0!==s){let s=i[o-1];i[o++]=e,t[e].equals(t[s])&&o--}}}return o>1&&t[i[0]].equals(t[i[o-1]])&&o--,o}(t,e,i,s);let n=new pi({points:t,n:e}),o=1,a=t[0];for(;o<e&&t[o].equals(a);)o++;if(n.m_treeHull.addElement(0),o<e){n.m_treeHull.addBiggestElement(o);for(let i=o+1;i<e;i++){let e=t[i],s=n.treeHull(e);-1!==s&&n.m_treeHull.setElement(s,i)}}let l=0;for(let t=n.m_treeHull.getFirst();-1!==t;t=n.m_treeHull.getNext(t))i[l++]=n.m_treeHull.getElement(t);return l}function gi(t,e,i){if((e<0||e>=t.getPathCount())&&(0,s.a)("path index"),t.hasNonLinearSegmentsPath(e))return!1;let r=t.getImpl(),o=r.getPathStart(e),a=r.getPathEnd(e),l=!r.isClosedPath(e)&&r.isClosedPathInXYPlane(e),h=r.getAttributeStreamRef(0),m=2*o,u=2*a;if(l&&(u-=2),u-m<6)return!0;let d=h.readPoint2D(m),g=h.readPoint2D(m+2),c=h.readPoint2D(m+4);if(!Pi(n.P.orientationRobust(g,c,d)))return!1;let _=g.clone(),p=new n.P;for(let t=m+6;t<u;t+=2)if(p.assign(g),g.assign(c),h.queryPoint2D(t,c),!Pi(n.P.orientationRobust(g,c,d))||!Pi(n.P.orientationRobust(_,c,d))||!Pi(n.P.orientationRobust(g,c,p)))return!1;return!0}function ci(t,e,i,r,o){if(function(t,e,i){t.setNAN(),e.setCoords(1,0),i.setCoords(0,0)}(i,r,o),t.isEmpty())return;if(t.getGeometryType()===s.G.enumPoint)return void i.assign(t.getXY());let a=t,l=a.getPointCount();if(0!==l){if(1===l)return void i.assign(a.getXY(0));!function(t,e,i,s,r,o){if(2===e){let e=t.getXY(0),i=t.getXY(1);s.assign(e.add(i).mul(.5));let n=i.sub(e);r=Ci(n),o.setCoords(.5*n.length(),0)}else{let a=Number.MAX_VALUE,l=[0,1,0,0],h=new n.am(4,2);for(h.set(0,0,0),h.set(0,1,1),h.set(1,0,1),h.set(1,1,2);l[0]<e;++l[0],Ei(h,0,e)){l[1]===l[0]&&(++l[1],Ei(h,1,e));for(let i=1;;++i){for(;;){let s=bi(t.getXY(h.get(0,0)),t.getXY(h.get(0,1)),t.getXY(h.get(i,0)),t.getXY(h.get(i,1)),2^i);if(s>0||(++l[i],Ei(h,i,e),0===s))break}if(3===i)break;l[i+1]<l[i]&&(l[i+1]=l[i],h.set(i+1,0,h.get(i,0)),h.set(i+1,1,h.get(i,1)))}let m,u,d=t.getXY(h.get(0,0)).add(t.getXY(h.get(2,0))).mul(.5),g=Ci(t.getXY(h.get(0,1)).sub(t.getXY(h.get(0,0)))),c=new n.P;if(c.x=Math.max(0,g.dotProduct(t.getXY(h.get(1,0)).sub(t.getXY(h.get(3,0))))),c.y=Math.max(0,g.crossProduct(t.getXY(h.get(0,0)).sub(t.getXY(h.get(2,0))))),i?(m=c.x*c.y,u=m<a):(m=c.y,u=m<a),u){a=m;let e=t.getXY(h.get(1,0)),i=t.getXY(h.get(3,0)),n=e.add(i).mul(.5).sub(d);s.assign(d.add(g.mul(g.dotProduct(n)))),r.assign(g),o.assign(c)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,n.c)(o.x,o.x=o.y),r.leftPerpendicularThis())}r.y<0?r.negateThis():0===r.y&&(r.x=1)}(a,l,e,i,r,o)}}class _i{m_convexHull;m_handleP=-1;m_handleQ=-1;m_currentSupport=-1;m_area=0;m_bDone=!0;m_function;constructor(t){(0,s.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,s.g)(0),!1}get_vertex_handle_p(){return(0,s.g)(0),0}get_vertex_handle_q(){return(0,s.g)(0),0}get_current_support(){return(0,s.g)(0),0}getNext(t){return(0,s.g)(0),0}getPrev(t){return(0,s.g)(0),0}intialize_(){return(0,s.g)(0),!1}increment_(){return(0,s.g)(0),!1}increment_q_(){return(0,s.g)(0),!1}increment_p_(){return(0,s.g)(0),!1}parallel_edge_with_q_support_(){return(0,s.g)(0),!1}parallel_edge_with_p_support_(){return(0,s.g)(0),!1}done_(){return(0,s.g)(0),!1}}class pi{m_treeHull=new r.T;m_shape=null;m_stream=null;m_points=null;m_geometryHandle=-1;m_pathHandle=-1;m_getXY=this.nullGetXY;m_deleteNode=this.nullDeleteNode;nullGetXY(t){return(0,s.d)("m_getXY is null"),{}}nullDeleteNode(t){(0,s.d)("m_deleteNode is null")}constructor(t){return 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=-1,void(this.m_pathHandle=-1)):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=-1,void(this.m_pathHandle=-1)):void(0,s.q)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new mi,this.m_geometryHandle=this.m_shape.createGeometry(s.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,-1),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(0,s.g)(0),new n.P}deleteNodeShape(t){let 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){(0,s.g)(0)}addGeometry(t){if(t.isEmpty())return;let e=t.getGeometryType();if(e===s.G.enumGeometryCollection){let e=t;for(let t=0,i=e.getGeometryCount();t<i;t++)this.addGeometry(e.getGeometry(t))}else(0,s.i)(e)?this.addMultiVertexGeometry(t):(0,s.h)(e)?this.addSegment(t,!1):e===s.G.enumEnvelope?this.addEnvelope(t):e===s.G.enumPoint?this.addPoint(t):(0,s.a)("Convex_hull: geometry not supported")}getBoundingGeometry(){let t=new r.P,e=this.m_treeHull.getFirst(),i=new ni({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return i;i.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),i.startPathPoint(t);for(let s=this.m_treeHull.getNext(e);-1!==s;s=this.m_treeHull.getNext(s))this.m_shape.queryPoint(this.m_treeHull.getElement(s),t),i.lineToPoint(t);return i}getAntipodalPairsIterator(){return(0,s.g)(0),new _i(this)}getXY(t){return(0,s.g)(0),new n.P}getXYWithIndex(t){return(0,s.g)(0),new n.P}getFirst(){return(0,s.g)(0),0}getLast(){return(0,s.g)(0),0}getNext(t){return(0,s.g)(0),0}getPrev(t){return(0,s.g)(0),0}getVertexIndex(t){return(0,s.g)(0),0}getPointCount(){return(0,s.g)(0),0}addMultiVertexGeometry(t){let e=new r.P,i=t.getImpl(),o=new n.P;for(let s=0;s<t.getPointCount();s++){i.queryXY(s,o);let r=this.addPoint2D(o);if(-1!==r){t.getPointByVal(s,e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,i)}}if((0,s.j)(t.getGeometryType())){let e=t;if(e.hasNonLinearSegments()){let t=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){let e=t.nextCurve();null!==e&&this.addSegment(e,!0)}}}}addEnvelope(t){let e=new r.P;for(let i=0;i<4;i++){let s=new n.P;t.queryCorner(i,s);let r=this.addPoint2D(s);if(-1!==r){t.queryCornerByVal(i,e);let s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}}static querySegmentControlPoints(t,e,i){let o=t.getGeometryType();if((0,s.g)(o!==s.G.enumLine),o===s.G.enumEllipticArc){let i=t,s=60*Math.PI/180,o=Math.abs(i.getSweepAngle());if(o>s){let t=Math.min(6,Math.ceil(o/s)),a=1/t,l=new Xn;i.queryStart(e[0]);let h=1;for(let s=0;s<t;s++){i.queryCut(s*a,(s+1)*a,l);let o=(0,n.m)(n.P,3);dn(l.get(),o);let m=n.P.calculateLength(o,3),u=n.P.calculateLength(o,2),d=m>0?u/m:.5;s<t-1?l.get().queryEnd(e[h+1]):i.queryEnd(e[h+1]),r.P.lerp(e[h-1],e[h+1],d,e[h]),e[h].setXY(o[1]),h+=2}return h}{let i=(0,n.m)(n.P,3);dn(t,i);let s=n.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[2]);let o=n.P.calculateLength(i,2),a=s>0?o/s:.5;return r.P.lerp(e[0],e[2],a,e[1]),e[1].setXY(i[1]),3}}if(o===s.G.enumBezier){let i=t,s=(0,n.m)(n.P,4);i.queryControlPoints(s);let o=n.P.calculateLength(s,4),a=n.P.calculateLength(s,2),l=n.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[3]);let h=o>0?a/o:.5;r.P.lerp(e[0],e[3],h,e[1]),e[1].setXY(s[1]);let m=o>0?l/o:.5;return r.P.lerp(e[0],e[3],m,e[2]),e[2].setXY(s[2]),4}if(o===s.G.enumBezier2){let i=t,s=(0,n.m)(n.P,3);i.queryControlPoints(s);let o=n.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[2]);let a=n.P.calculateLength(s,2),l=o>0?a/o:.5;return r.P.lerp(e[0],e[2],l,e[1]),e[1].setXY(s[1]),3}if(o===s.G.enumRationalBezier2){let i=t,s=(0,n.m)(n.P,3);i.queryControlPoints(s);let o=n.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[2]);let a=n.P.calculateLength(s,2),l=o>0?a/o:.5;return r.P.lerp(e[0],e[2],l,e[1]),e[1].setXY(s[1]),3}(0,s.a)("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){let e=new r.P,i=t.getStartXY(),s=this.addPoint2D(i);if(-1!==s){t.queryStart(e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(s,i)}let n=t.getEndXY(),o=this.addPoint2D(n);if(-1!==o){t.queryEnd(e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(o,i)}}if(t.isCurve()){let e=(0,n.m)(r.P,13),i=pi.querySegmentControlPoints(t,e,e.length);for(let t=1,s=i-1;t<s;++t){let i=e[t].getXY(),s=this.addPoint2D(i);if(-1!==s){let i=this.m_shape.addPoint(this.m_pathHandle,e[t]);this.m_treeHull.setElement(s,i)}}}}addPoint(t){let e=t.getXY(),i=this.addPoint2D(e);if(-1!==i){let e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(i,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()){let i=this.m_treeHull.getElement(this.m_treeHull.getFirst()),s=this.m_shape.getXY(i);return t.equals(s)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{let i=this.m_treeHull.getFirst(),s=this.m_treeHull.getLast(),r=this.m_treeHull.getElement(i),o=this.m_treeHull.getElement(s),a=this.m_getXY(r),l=this.m_getXY(o),h=n.P.orientationRobust(l,t,a);if(Pi(h)){e=this.m_treeHull.addBiggestElement(-1);let r=this.treeHullWalkBackward(t,s,i);r!==i&&this.treeHullWalkForward(t,i,this.m_treeHull.getPrev(r));break}if(xi(h)){let r=this.m_treeHull.getRoot(),o=this.m_treeHull.getFirst(),l=this.m_treeHull.getLast(),h=-1,m=-1,u=-1;for(;o!==this.m_treeHull.getPrev(l);){m=this.m_treeHull.getElement(r);let e=this.m_getXY(m);xi(n.P.orientationRobust(e,t,a))?(l=r,r=this.m_treeHull.getLeft(r)):(o=r,r=this.m_treeHull.getRight(r))}r=l,h=o,m=this.m_treeHull.getElement(r),u=this.m_treeHull.getElement(h);let d=this.m_getXY(m),g=this.m_getXY(u);if(h!==i&&!Pi(n.P.orientationRobust(g,t,d)))break;e=this.m_treeHull.addElementAtPosition(h,r,-2,!0,!1),this.treeHullWalkForward(t,r,s),this.treeHullWalkBackward(t,h,i);break}{let r=vi(t,l,a);if(-1===r){let r=this.m_treeHull.getPrev(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,r,i)}else if(1===r){let r=this.m_treeHull.getNext(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addElementAtPosition(-1,r,-3,!0,!1),this.treeHullWalkForward(t,r,s)}break}}while(0);return e}treeHullWalkForward(t,e,i){if(e===i)return i;let s=e,r=this.m_treeHull.getElement(s),o=this.m_treeHull.getNext(s),a=this.m_getXY(r);for(;s!==i&&this.m_treeHull.size()>2;){let e=this.m_treeHull.getElement(o),i=this.m_getXY(e);if(Pi(n.P.orientationRobust(i,t,a)))break;let l=s;s=o,r=e,a.assign(i),o=this.m_treeHull.getNext(s),this.m_deleteNode(l)}return s}treeHullWalkBackward(t,e,i){if(e===i)return i;let s=e,r=this.m_treeHull.getElement(s),o=this.m_treeHull.getPrev(s),a=this.m_getXY(r);for(;s!==i&&this.m_treeHull.size()>2;){let e=this.m_treeHull.getElement(o),i=this.m_getXY(e);if(Pi(n.P.orientationRobust(a,t,i)))break;let l=s;s=o,r=e,a.assign(i),o=this.m_treeHull.getPrev(s),this.m_deleteNode(l)}return s}}function fi(t,e,i){let s=e.sub(t),r=i.sub(e);if(0===s.x)return r.x>0?-1:0;if(0===s.y)return r.y>0?1:r.y<0?-1:0;let o=s.crossProduct(r),a=4*2**-52*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,i)}function yi(t,e,i){let s=e.sub(t),r=i.sub(e);if(0===s.x)return r.x<0?-1:0;if(0===s.y)return r.y>0?-1:+(r.y<0);let o=s.crossProduct(r),a=4*2**-52*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,i)}function Pi(t){return t<0}function xi(t){return t>0}function vi(t,e,i){let s=-1;s=e.y===i.y?0:e.x===i.x?1:Math.abs(e.x-i.x)>=Math.abs(e.y-i.y)?0:1;let r=-1;return r=e[s]<i[s]?t[s]<e[s]?-1:+(i[s]<t[s]):e[s]<t[s]?-1:+(t[s]<i[s]),r}function Ci(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function Ei(t,e,i){t.inc(e,0)===i&&t.set(e,0,0),t.inc(e,1)===i&&t.set(e,1,0)}function bi(t,e,i,r,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,s.a)("")}return n.P.orientationRobustEx(t,e,i,r)}class Di{specialPoints;length;constructor(){this.length=NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function wi(t){return function(t){return 256*(0,n.I)()*t}(t.calculateUpperLength2D())}function Si(t,e,i=!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]),i?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Ai(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),Ii(s,e,i)}function Ti(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),Mi(s,e,i)}function Ii(t,e,i){let s=t[1].x;s-=t[0].x,s*=3;let r=t[2].x;r-=t[1].x,r*=3;let n=t[3].x;n-=t[0].x,n-=r,r-=s,e[3].setWithEps(n),e[2].setWithEps(r),e[1].setWithEps(s),i?e[0].set(0):e[0].set(t[0].x)}function Mi(t,e,i){let s=t[1].y;s-=t[0].y,s*=3;let r=t[2].y;r-=t[1].y,r*=3;let n=t[3].y;n-=t[0].y,n-=r,r-=s,e[3].setWithEps(n),e[2].setWithEps(r),e[1].setWithEps(s),i?e[0].set(0):e[0].set(t[0].y)}function qi(t,e,i=!1){let s=(0,n.m)(C,4);s[0].assignPoint2D(t[0]),s[1].assignPoint2D(t[1]),s[2].assignPoint2D(t[2]),s[3].assignPoint2D(t[3]),e[1].setCoords(s[1].x.sub(s[0].x),s[1].y.sub(s[0].y)),e[1].mulThis(n.M.constructInt32(3)),e[2].setCoords(s[2].x.sub(s[1].x),s[2].y.sub(s[1].y)),e[2].mulThis(n.M.constructInt32(3)),e[3]=s[3].sub(s[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),i?e[0].setCoords(n.aD,n.aD):e[0]=s[0].clone()}function Ni(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+Ni(t,1,!1)}if(t.isDegenerate(0))return 0;let s=1===e,r=Ri(t);if(s&&!Number.isNaN(r.length)&&!Number.isNaN(r.length))return r.length;let n=wi(t),o=n/t.calculateUpperLength2D(),a=0,l=0;for(let i=1,s=r.specialPointsCount();i<s;i++){let s=r.specialPoints[i];if(a+=fs(t,l,Math.min(e,s),o,n),e<=s)break;l=s}return s&&(r.length=a),a}function Ri(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new Di,i=(0,n.m)(n.Z,8),s=(0,n.m)(n.P,4);t.queryControlPoints(s);let r=ds(s,i);e.specialPoints=[];for(let t=0;t<r;t++)e.specialPoints.push(i[t].value());return Xi(t,e),e}function Yi(t){let e=null;return e=t.m_cachedValues,e}function Xi(t,e){t.m_cachedValues=e}function Fi(t){t.m_cachedValues=null}function Li(t,e,i,s){let r=(0,n.m)(n.P,4);t.queryControlPoints(r);let o=(0,n.d)(18,NaN),a=It(new ls(r,e,NaN),n.E.construct(i,s),18,o),l=new n.P;t.queryCoord2D(i,l);let h=i,m=n.P.distance(l,e),u=new n.P;t.queryCoord2D(s,u);let d=n.P.distance(u,e);d<m&&(m=d,h=s,l.assign(u));for(let i=0;i<a;i++){t.queryCoord2D(o[i],u);let s=n.P.distance(u,e);s<m&&(m=s,h=o[i],l.assign(u))}return function(t,e,i,s,r){return{tmin:t,tmax:e,t:i,d:s,pt:r.clone()}}(i,s,h,m,l)}function zi(t,e){let i=(0,n.m)(n.Z,4);Ai(t,i,!0);let r=(0,n.m)(n.Z,4);Ti(t,r,!0);let o=i[3].clone(),a=i[2].clone(),l=i[1].clone(),h=r[3].clone(),m=r[2].clone(),u=r[1].clone(),d=a.mulE(l).addE(m.mulE(u)).mul(4),g=a.mulE(a).mul(8).addE(o.mulE(l).mul(12)).addE(m.mulE(m).mul(8).addE(h.mulE(u).mul(12))),c=o.mulE(a).addE(h.mulE(m)).mul(36),_=o.mulE(o).addE(h.mulE(h)).mul(36),p=(0,n.m)(n.Z,3),f=zt(_,c,g,d,new n.E(0,1),!1,p);if((0,s.g)(f<=3),f>0){let i=Bi(t,1,0).sqrLength(),s=Bi(t,1,1).sqrLength(),r=i;e.set(0),r<s&&(r=s,e.set(1));for(let i=0;i<f;i++){let s=Bi(t,1,p[i].value()).sqrLength();s<r&&(r=s,e=p[i])}}}function Vi(t,e,i){let s=new n.P;return function(t,e,i,s){if(1===e){let e=1-i,r=e*e,n=i*i,o=t[1].sub(t[0]),a=t[2].sub(t[1]),l=t[3].sub(t[2]),h=o.mul(r).add(a.mul(2*e*i)).add(l.mul(n));s.assign(h.mul(3))}else if(2===e){let e=1-i,r=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=r.mul(e).add(n.mul(i));s.assign(o.mul(6))}else if(3===e){let e=t[2].sub(t[1]),i=t[3].sub(e.mul(3)).sub(t[0]);s.assign(i.mul(6))}else s.setCoords(0,0)}(t,e,i,s),s}function Bi(t,e,i){let s=(0,n.m)(n.P,4);return t.queryControlPoints(s),Vi(s,e,i)}function ki(t){let e=t.m_cp[0].sub(t.getStartXY()),i=t.m_cp[1].sub(t.m_cp[0]),s=t.getEndXY().sub(t.getStartXY());return e.mulThis(3),i.mulThis(3),s.subThis(i),i.subThis(e),(3*s.x*(2*i.y+5*e.y)-3*s.y*(2*i.x+5*e.x)+10*(i.x*e.y-i.y*e.x))/60}function Gi(t){let e=(0,n.m)(n.P,4);t.queryControlPoints(e);let i=Zi(e);return i&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),i}function Zi(t){return b(t)}function Hi(t,e,i){let s=new n.P,r=new n.P,o=new n.P,a=new n.P,l=new n.P;e<=.5?((0,n.as)(2,t[0],t[1],e,s),(0,n.as)(2,t[1],t[2],e,r),(0,n.as)(2,t[2],t[3],e,o),(0,n.as)(2,s,r,e,a),(0,n.as)(2,r,o,e,l),(0,n.as)(2,a,l,e,i)):((0,n.at)(2,t[0],t[1],e,s),(0,n.at)(2,t[1],t[2],e,r),(0,n.at)(2,t[2],t[3],e,o),(0,n.at)(2,s,r,e,a),(0,n.at)(2,r,o,e,l),(0,n.at)(2,a,l,e,i))}function Wi(t,e,i,r){(0,s.g)(e>=0&&e<=1);let o=new n.P,a=new n.P,l=new n.P,h=new n.P,m=new n.P,u=new n.P;e<=.5?((0,n.as)(2,t[0],t[1],e,o),(0,n.as)(2,t[1],t[2],e,a),(0,n.as)(2,t[2],t[3],e,l),(0,n.as)(2,o,a,e,h),(0,n.as)(2,a,l,e,m),(0,n.as)(2,h,m,e,u)):((0,n.at)(2,t[0],t[1],e,o),(0,n.at)(2,t[1],t[2],e,a),(0,n.at)(2,t[2],t[3],e,l),(0,n.at)(2,o,a,e,h),(0,n.at)(2,a,l,e,m),(0,n.at)(2,h,m,e,u));let d=t[3].clone();i&&(i[0].assign(t[0]),i[1].assign(o),i[2].assign(h),i[3].assign(u)),r&&(r[0].assign(u),r[1].assign(m),r[2].assign(l),r[3].assign(d))}function ji(t,e,i,r){if((0,s.g)(e>=0&&i<=1&&e<=i),e===i){let i=new n.P;return Ui(t,e,i),r[0].assign(i),r[1].assign(i),r[2].assign(i),void r[3].assign(i)}if(0===e&&1===i){for(let e=0;e<4;++e)r[e].assign(t[e]);return}let o=(0,n.m)(n.P,4);Wi(t,i,o,null),Wi(o,i>0?e/i:0,null,o),Ui(t,e,o[0]),Ui(t,i,o[3]),r[0].setCoordsPoint2D(o[0]),r[1].setCoordsPoint2D(o[1]),r[2].setCoordsPoint2D(o[2]),r[3].setCoordsPoint2D(o[3])}function Ui(t,e,i,s){if(s){if(e<0)return void J(new Yn({start:t[0],end:t[0].add(Oi(t,0).getUnitVector())}),e,i);if(e>1)return void J(new Yn({start:t[3],end:t[3].add(Oi(t,1).getUnitVector())}),e-1,i)}if(e<=.5){let s=new n.P;(0,n.as)(2,t[0],t[1],e,s);let r=new n.P;(0,n.as)(2,t[1],t[2],e,r);let o=new n.P;(0,n.as)(2,t[2],t[3],e,o);let a=new n.P;(0,n.as)(2,s,r,e,a);let l=new n.P;(0,n.as)(2,r,o,e,l),(0,n.as)(2,a,l,e,i)}else{let s=new n.P;(0,n.at)(2,t[0],t[1],e,s);let r=new n.P;(0,n.at)(2,t[1],t[2],e,r);let o=new n.P;(0,n.at)(2,t[2],t[3],e,o);let a=new n.P;(0,n.at)(2,s,r,e,a);let l=new n.P;(0,n.at)(2,r,o,e,l),(0,n.at)(2,a,l,e,i)}}function Oi(t,e){let i=(0,n.s)(e,0,1),s=Vi(t,1,i);return s.isZero()&&(s=Vi(t,2,i),s.isZero()?s=Vi(t,3,i):1===i&&s.negateThis()),s}function Qi(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),function(t,e,i){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),i.setE(function(t,e,i){let s=[x.constructPoint2D(t[0]),x.constructPoint2D(t[1]),x.constructPoint2D(t[2]),x.constructPoint2D(t[3])],r=new x;return function(t,e,i,s){{let e=n.a9.subE(i),r=e.sqr(),o=i.sqr(),a=t[1].subE(t[0]).mulE(r).addE(t[2].subE(t[1]).mulE(new n.Z(2).mulE(e).mulE(i))).addE(t[3].subE(t[2]).mulE(o));s.setE(a.mulE(new n.Z(3)))}}(s,0,i,r),r}(t,0,e))}(s,e,i)}function Ki(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===es(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function Ji(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===is(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function $i(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===rs(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function ts(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===ns(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function es(t,e,i,s,r,o,a,l,h,m){if(null!==r&&(r.length=0),null!=o&&(o.length=0),null!==s&&(s.length=0),i.isDegenerate(0)){let t=[0,0,0],l=e.intersectPoint(i.getStartXY(),t,a);if(l>0){if(null!==r)for(let e=0;e<l;e++)r.push(t[e]);if(null!==o)for(let t=0;t<l;t++)o.push(0);if(null!=s)for(let i=0;i<l;i++){let r=new n.P;e.queryCoord2D(t[i],r),s.push(r)}}return l}let u=k(e,i);if(G(e,i,a=Math.max(a,u)))return 0;let d=(0,n.m)(n.P,4);Si(e,d);let g=i.getEndXY();g.subThis(i.getStartXY());let c=g.clone();c.leftPerpendicularThis();let _=3*d[3].dotProduct(c),p=2*d[2].dotProduct(c),f=d[1].dotProduct(c),y=(0,n.d)(15,NaN),P=(0,n.d)(15,NaN),x=Mt(_,p,f,n.E.unit(),!1,y);x<0&&(y[0]=0,y[1]=1,x=2);let v,C=0;for(let t=0,s=C;t<x;++t){let r=e.getCoord2D(y[t+s]);P[C]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(P[C]))<=a&&(y[C]=y[t+s],C++)}if(d[0].subThis(i.getStartXY()),Math.abs(g.x)>=Math.abs(g.y)){let t=g.y/g.x;_=d[3].y-d[3].x*t,p=d[2].y-d[2].x*t,f=d[1].y-d[1].x*t,v=d[0].y-d[0].x*t}else{let t=g.x/g.y;_=d[3].x-d[3].y*t,p=d[2].x-d[2].y*t,f=d[1].x-d[1].y*t,v=d[0].x-d[0].y*t}let E=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),b=[0,0,0];x=qt(_,p,f,v,n.E.unit(),E,b);for(let t=0,s=C;t<x;++t){y[t+s]=b[t];let r=e.getCoord2D(y[t+s]);P[C]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(P[C]))<=a&&(y[C]=y[t+s],C++)}x=e.intersectPoint(i.getStartXY(),b,a);for(let t=0;t<x;t++)y[C]=b[t],P[C++]=0;x=e.intersectPoint(i.getEndXY(),b,a);for(let t=0;t<x;t++)y[C]=b[t],P[C++]=1;return 0!==i.intersectPoint(e.getStartXY(),b,a)&&(P[C]=b[0],y[C++]=0),0!==i.intersectPoint(e.getEndXY(),b,a)&&(P[C]=b[0],y[C++]=1),0===C?0:Mn(t,e,i,y,P,C,s,r,o,a,l,0,m)}function is(t,e,i,s,r,o,l,h,m,u){if(Kr(i))return es(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,0,u);let d=k(e,i);if(G(e,i,l=Math.max(l,d)))return 0;let g=[],c=[],_=[],p=(0,n.m)(n.P,4);{e.queryControlPoints(p);let t=(0,n.m)(n.P,4),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(p,4,t);let o=(0,n.m)(C,4);qi(t,o);let m=[o[0].x,o[1].x,o[2].x,o[3].x],u=[o[0].y,o[1].y,o[2].y,o[3].y],d=(0,n.m)(n.M,3);d[0].setDouble(i.getSemiMinorAxis()),d[0].sqrThis(),d[1].setDouble(i.getSemiMajorAxis()),d[1].sqrThis(),d[2].setThis(d[0]),d[2].mulThis(d[1]),d[2].negateThis();let f=ee(m,3,u,3,null,0,d,0,n.E.unit(),n.E.unit(),c,h);if(f>0){let t=0;for(let s=0;s<f;s++){let r=new n.P;e.queryCoord2D(c[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(g.push(r.clone()),c[t]=c[s],_.push(o),t++)}c.length=t,g.length=t}}let f=[0,1];for(let t=0;t<2;t++){let e=0===t?i.getStartXY():i.getEndXY(),s=[0];hs(p,e,n.E.unit(),!1,-1,1,s);let r=new n.P;Ui(p,s[0],r),n.P.distance(e,r)<=l&&(c.push(s[0]),_.push(f[t]),g.push(r.clone()))}for(let t=0;t<2;t++){let e=[0,3];{let s=i.getClosestCoordinate(p[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(p[e[t]],r)<=l&&(c.push(f[t]),_.push(s),g.push(r.clone()))}}return Mn(t,e,i,c,_,c.length,s,r,o,l,h,0,u)}function ss(t,e,i,r,o,a,l,h,m,u){let d=(0,n.m)(n.P,4);e.queryControlPoints(d);let g=(0,n.m)(n.P,4);if(i.queryControlPoints(g),Z(d,g,4)<0)return ss(t,i,e,r,a,o,l,h,m,!u);let c=k(e,i);if(G(e,i,l=Math.max(l,c)))return 0;if(function(t,e,i,s,r,o,a,l,h){let m=(0,n.m)(n.P,4);t.queryControlPoints(m);let u=(0,n.m)(n.P,4);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2])&&m[3].equals(u[3]))return i&&(i.length=0,i.push(m[0]),i.push(m[3])),s&&(s.length=0,s.push(0),s.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!m[0].equals(u[3]))return!1}return!!(m[0].equals(u[3])&&m[1].equals(u[2])&&m[2].equals(u[1])&&m[3].equals(u[0]))&&(s&&(s.length=0,s.push(0),s.push(1),h&&(s[1]=(0,n.c)(s[0],s[0]=s[1]))),r&&(r.length=0,r.push(1),r.push(0),h&&(r[1]=(0,n.c)(r[0],r[0]=r[1]))),i&&(i.length=0,i.push(m[0]),i.push(m[3]),h&&(i[1]=(0,n.c)(i[0],i[0]=i[1]))),!0)}(e,i,r,o,a,0,0,0,u))return 2;let _=new n.E(0,1),f=new n.E(0,1);{let t=new p;as(d,new n.E(0,1),t);let e=new p;as(g,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(cs(d,t,_),_.isEmpty()||(cs(g,t,f),f.isEmpty()))return 0;ji(d,_.vmin,_.vmax,d),ji(g,f.vmin,f.vmax,g)}}let y=Nn(d,3,g,3,l);if(0===y)return 0;let P=[],x=[],v=[],E=!1;if(-1===y){let t=(0,n.m)(C,4);qi(d,t);let e=[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],s=(0,n.m)(C,4);qi(g,s);let r=[],o=[],a=te(e,3,i,3,null,0,[s[0].x,s[1].x,s[2].x,s[3].x],3,[s[0].y,s[1].y,s[2].y,s[3].y],3,null,0,0,n.E.unit(),n.E.unit(),r,o,m);if(a>0)for(let t=0;t<a;t++){let e=new n.P;Ui(g,o[t],e);let i=new n.P;Ui(d,r[t],i),n.P.distance(i,e)<=l&&(P.push(i.clone()),v.push(o[t]),x.push(r[t]))}else-1===a&&(E=!0)}for(let t=0;t<2;t++){let e=0===t?d:g,i=0===t?g:d;for(let s=0;s<2;s++){let r=0===s?0:3,o=[0];hs(i,e[r],n.E.unit(),!1,-1,1,o);let a=new n.P;Ui(i,o[0],a),n.P.distance(e[r],a)<=l&&(0===t?(x.push(0===r?0:1),v.push(o[0])):(v.push(0===r?0:1),x.push(o[0])),P.push(a.clone()))}}if(0===x.length&&E){let t=e.calculateUpperLength2D()>i.calculateUpperLength2D();{let r=[0,0];if(2===us(t?e:i,r,!0)&&((0,s.g)(n.E.unit().containsCoordinate(r[0])),!n.E.unit().containsCoordinate(r[1]))){let e=new n.P;Ui(t?d:g,r[0],e);let i=[0,0];1===hs(t?g:d,e,n.E.unit(),!1,-1,2,i)&&(P.push(e.clone()),x.push(t?r[0]:i[0]),v.push(t?i[0]:r[0]))}}}if(0===x.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<x.length;++t)x[t]=vs.recalculateParentT(_.vmin,_.vmax,x[t]);if(!f.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=vs.recalculateParentT(f.vmin,f.vmax,v[t]);return Mn(t,e,i,x,v,x.length,r,o,a,l,h,0,u)}function rs(t,e,i,r,o,a,l,h,m,u){let d=k(e,i);if(i.isDegenerateToLineHelper(d)){let s=new Yn({start:i.getStartXY(),end:i.getEndXY()}),n=es(t,e,s,r,o,a,l,h,0,u);if(a)for(let t=0;t<n;++t){let e=s.getCoord2D(a[t]);a[t]=i.getClosestCoordinate(e,!1)}return n}if(G(e,i,l=Math.max(l,d)))return 0;let g=(0,n.m)(n.P,4);e.queryControlPoints(g);let c=(0,n.m)(n.P,3);i.queryControlPoints(c);let _=new n.E(0,1),f=new n.E(0,1),y=[0,0,0];i.queryWeights(y);let P=[1,dr(y),1];{let t=new p;as(g,new n.E(0,1),t);let e=new p;Ws(c,P,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(cs(g,t,_),_.isEmpty()||(ur(c,P,t,f),f.isEmpty()))return 0;ji(g,_.vmin,_.vmax,g),Ks(c,P,f.vmin,f.vmax,c,P)}}let x=Nn(g,3,c,2,l);if(0===x)return 0;let v=[],E=[],b=[];if(-1===x){let t=(0,n.m)(C,4);qi(g,t);let e=[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],s=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=(0,n.m)(n.M,3);or(c,P,s,r,o);let a=[],h=[],u=te(s,2,r,2,o,2,e,3,i,3,null,0,0,n.E.unit(),n.E.unit(),h,a,m);if(u>0)for(let t=0;t<u;t++){let e=new n.P;Ui(g,a[t],e);let i=new n.P;mr(c,P,h[t],i),n.P.distance(e,i)<=l&&(v.push(e.clone()),E.push(a[t]),b.push(h[t]))}}for(let t=0;t<2;t++){let e,i;0===t?(e=g,i=c):(i=g,e=c);for(let r=0;r<2;r++){let o=0===r?0:e.length-1,a=[0],h=new n.P;if(0===t){let t=Zs(i,P,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),mr(i,P,a[0],h)}else{let t=hs(i,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),Ui(i,a[0],h)}n.P.distance(e[o],h)<=l&&(0===t?(E.push(0===o?0:1),b.push(a[0])):(b.push(0===o?0:1),E.push(a[0])),v.push(h.clone()))}}if(0===E.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=vs.recalculateParentT(_.vmin,_.vmax,E[t]);if(!f.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=Ut.recalculateParentT(f.vmin,f.vmax,b[t]);for(let t=0;t<b.length;++t)b[t]=gr(y,b[t]);return Mn(t,e,i,E,b,E.length,r,o,a,l,h,0,u)}function ns(t,e,i,r,o,a,l,h,m,u){let d=k(e,i);if(G(e,i,l=Math.max(l,d)))return 0;let g=(0,n.m)(n.P,4);e.queryControlPoints(g);let c=(0,n.m)(n.P,3);i.queryControlPoints(c);let _=Nn(g,3,c,2,l);if(0===_)return 0;let p=[],f=[],y=[];if(-1===_){let t=(0,n.m)(C,4);qi(g,t);let s=[t[0].x,t[1].x,t[2].x,t[3].x],r=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,n.m)(C,3);Qe(c,o);let a=te([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,s,3,r,3,null,0,0,n.E.unit(),n.E.unit(),y,f,h);if(a>0){let t=0;for(let s=0;s<a;s++){let r=new n.P;e.queryCoord2D(f[s],r);let o=new n.P;i.queryCoord2D(y[s],o),n.P.distance(r,o)<=l&&(p.push(r.clone()),f[t]=f[s],y[t]=y[s],t++)}f.length=t,p.length=t}}for(let t=0;t<2;t++){let e,i;0===t?(e=g,i=c):(i=g,e=c);for(let r=0;r<2;r++){let o=0===r?0:e.length-1,a=[0],h=new n.P;if(0===t)Fe(i,e[o],a),Ke(i,a[0],h);else{let t=hs(i,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),Ui(i,a[0],h)}n.P.distance(e[o],h)<=l&&(0===t?(f.push(0===o?0:1),y.push(a[0])):(y.push(0===o?0:1),f.push(a[0])),p.push(h.clone()))}}return Mn(t,e,i,f,y,f.length,r,o,a,l,h,0,u)}function os(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),as(s,e,i)}function as(t,e,i){if(e.equalsRange(0,1))return void i.setFromPoints(t,4);let s=(0,n.m)(n.P,4);ji(t,e.vmin,e.vmax,s),i.setFromPoints(s,4)}let ls=class{controlPoints;point;maxDistance;dbgCounter=0;constructor(t,e,i){this.controlPoints=t,this.point=e.clone(),this.maxDistance=i}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{let t=new n.P;Ui(this.controlPoints,e,t);let i=Vi(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(i)}case 1:{let t=new n.P;Ui(this.controlPoints,e,t);let i=Vi(this.controlPoints,1,e),s=Vi(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(s)+i.dotProduct(i))}case 2:{let t=new n.P;Ui(this.controlPoints,e,t);let i=Vi(this.controlPoints,1,e),s=Vi(this.controlPoints,2,e),r=Vi(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(r)+3*i.dotProduct(s))}case 3:{let t=Vi(this.controlPoints,1,e),i=Vi(this.controlPoints,2,e),s=Vi(this.controlPoints,3,e);return 2*(4*t.dotProduct(s)+3*i.sqrLength())}case 4:{let t=Vi(this.controlPoints,2,e),i=Vi(this.controlPoints,3,e);return 10*t.dotProduct(i)*2}case 5:{let t=Vi(this.controlPoints,3,e);return 10*t.dotProduct(t)*2}default:return 0}}getError(t){return 0}isInterestingInterval(t,e){if(t>=0&&e<=1){let i=(0,n.m)(n.P,4);ji(this.controlPoints,t,e,i);let s=new p;if(s.setFromPoints(i,4),Math.sqrt(s.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function hs(t,e,i,o,a,l,h){(0,s.D)(n.E.unit().contains(i)&&l>0,"getClosestCoordinate"),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);let m=[],u=new n.P;Ui(t,i.vmin,u);let d=n.P.distance(u,e);if(d<=a&&m.push(new n.P(i.vmin,d)),i.vmin!==i.vmax&&(Ui(t,i.vmax,u),d=n.P.distance(u,e),d<=a&&m.push(new n.P(i.vmax,d))),i.width()>0){let s=(0,n.d)(18,NaN),r=It(new ls(t,e,a),i,18,s);for(let i=0;i<r;i++)Ui(t,s[i],u),d=n.P.distance(u,e),!(d>a)&&m.push(new n.P(s[i],d))}if(o){(0,s.g)(i.equals(n.E.unit()));{Ui(t,-1,u,!0);let i=new n.P;Ui(t,0,i);let s=new Yn({start:u,end:i}),r=s.getClosestCoordinate(e,!0);r<1&&(u.assign(s.getCoord2D(r)),d=n.P.distance(u,e),d<=a&&m.push(new n.P(r-1,d)))}{Ui(t,2,u,!0);let s=new n.P;Ui(t,i.vmax,s);let r=new Yn({start:s,end:u}),o=r.getClosestCoordinate(e,!0);o>0&&(u.assign(r.getCoord2D(o)),d=n.P.distance(u,e),d<=a&&m.push(new n.P(1+o,d)))}}if(!m.length)return 0;m.sort((t,e)=>t.compare(e));let g=0,c=m[0].x;if(h[g++]=c,g<l){let e=(0,r.a4)(t,4,!1).total(),i=m[0].y;for(let t=1,s=m.length;t<s;t++)if(m[t].y>i+e){m.length=t;break}m.sort((t,e)=>(0,n.X)(t.x,e.x)),g=0,h[g++]=m[0].x;for(let t=1,e=m.length;t<e;t++)m[t].x!==h[g-1]&&g<l&&(h[g++]=m[t].x)}return g}function ms(t,e,i,s,r,o,a){let l=(0,n.m)(n.P,4);return t.queryControlPoints(l),hs(l,e,i,s,r,o,a)}function us(t,e,i=!1){let s=(0,n.m)(n.P,4);t.queryControlPoints(s);let r=(0,n.m)(C,4);qi(s,r,!0);let o,a,l,h=r[3].x.isZero(),m=r[3].y.isZero();if(h||m)if(h&&!m){if(r[2].x.isZero())return 0;o=r[1].x.div(r[2].x).negate(),a=r[2].y.div(r[3].y),l=r[1].y.div(r[3].y)}else{if(h||!m)return 0;if(r[2].y.isZero())return 0;o=r[1].y.div(r[2].y).negate(),a=r[2].x.div(r[3].x),l=r[1].x.div(r[3].x)}else{r[2].x.divThis(r[3].x),r[1].x.divThis(r[3].x),r[2].y.divThis(r[3].y),r[1].y.divThis(r[3].y);let t=r[2].x.sub(r[2].y);if(t.isZero())return 0;o=r[1].x.sub(r[1].y).div(t).negate(),a=r[2].x.clone(),l=r[1].x.clone()}if(!i&&o.abs().value()>2)return 0;let u=[0,0],d=t.getStartXY().equals(t.getEndXY()),g=Mt(1,-o.toDouble(),o.add(a).mul(o).add(l).toDouble(),n.E.unit(),d,u);if(0===g)return 0;if(u[0]>=0&&u[0]<=1){let t=o.toDouble()-u[0];if(i||t>=0&&t<=1)return e[0]=u[0],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.c)(e[0],e[0]=e[1])),2}if(2===g&&u[1]>=0&&u[1]<=1){let t=o.toDouble()-u[1];if(i||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.c)(e[0],e[0]=e[1])),2}return 0}function ds(t,e){e[0].set(0);let i=1,r=(0,n.m)(n.Z,4);Ii(t,r,!0);let o=(0,n.m)(n.Z,4);Mi(t,o,!0);{let t=r[3].mul(3),s=r[2].mul(2),o=r[1].clone(),a=(0,n.m)(n.Z,2),l=Lt(t,s,o,new n.E(0,1),!1,a);l<0&&(l=0);for(let t=0;t<l;t++)(0,n.ab)(a[t].value(),0,1)||(e[i]=a[t],i++)}{let t=o[3].mul(3),s=o[2].mul(2),r=o[1].clone(),a=(0,n.m)(n.Z,2),l=Lt(t,s,r,new n.E(0,1),!1,a);l<0&&(l=0);for(let t=0;t<l;t++)(0,n.ab)(a[t].value(),0,1)||(e[i]=a[t],i++)}let a=function(t,e,i){let s=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),r=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),o=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),a=(0,n.m)(n.Z,2),l=Lt(o,r,s,new n.E(0,1),!1,a);l<0&&(l=0);let h=0;for(let t=0;t<l;t++)(0,n.ab)(a[t].value(),0,1)||(i[h].setE(a[t]),h++);return h}(r,o,e.slice(i));if(i+=a,e[i].set(1),i++,i>2){(0,n.a5)(e,0,i,(t,e)=>{let i=t.value(),s=e.value();return i<s?-1:+(i>s)});let s=0,r=e[0].clone(),o=0,a=function(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}(t)*(0,n.I)(),l=new n.P;Hi(t,e[0].value(),l);for(let h=1;h<i;h++){let i=new n.P;if(Hi(t,e[h].value(),i),e[h].eq(r)||i.isEqualPoint2D(l,a)){if(0!==s){if(0===e[h].eps())r.setE(e[h]),o=0;else if(0!==o){let t=(0,n.a)(1/e[h].eps()),i=1/o,s=t+i;r.set((e[h].value()*t+r.value()*i)/s),o=1/s,r.setError(Math.sqrt(o))}e[s].setE(r),Hi(t,r.value(),l)}}else s++,e[s].setE(e[h]),r.setE(e[h]),Hi(t,r.value(),l),o=(0,n.a)(e[h].eps())}s++,i=s}return 1===i&&(i=2,e[1].set(1)),(0,s.g)(0===e[0].value()),(0,s.g)(1===e[i-1].value()),i}function gs(t,e,i,s){let r=(0,n.m)(n.P,i);for(let t=0;t<i;++t)r[t]=new n.P(t/(i-1),0);let o=(t,e,i,s)=>{let r=new n.Z(e.x).subE(new n.Z(t.x)).divE(new n.Z(e.y).subE(new n.Z(t.y))).mulE(new n.Z(i).subE(new n.Z(t.y))).addE(new n.Z(t.x));if(r.eps()>.1){let s=(e.x-t.x)/(e.y-t.y)*(i-t.y)+t.x;r.set(s,(0,n.I)())}if(r.lt(new n.Z(0))||r.gt(new n.Z(1)))return!1;let o=r.value()-r.eps();o=(0,n.s)(o,0,1);let a=r.value()+r.eps();return a=(0,n.s)(a,0,1),s.mergeCoordinate(o),s.mergeCoordinate(a),!0},a=[];{let e=(t,e)=>{a.length=i;let s=di(r,i,a,!0),l=new n.E;l.setEmpty();let h=i=>i.y<t?-1:+(i.y>e),m=r[a[0]],u=h(m);0===u&&l.mergeCoordinate(m.x);for(let i=1;i<=s;++i){let n=r[a[i%s]],d=h(n);0===d&&l.mergeCoordinate(n.x);let g=0;d!==u&&(g=d*u===0?1===d||1===u?2:1:3,1&g&&o(m,n,t,l),2&g&&o(m,n,e,l)),m=n,u=d}return l};for(let e=0;e<i;++e)r[e].y=t[e].x;let l=e(s.xmin,s.xmax);if(l.isEmpty())return new n.E(l);for(let e=0;e<i;++e)r[e].y=t[e].y;let h=e(s.ymin,s.ymax);return l.intersect(new n.E(h)),new n.E(l)}}function cs(t,e,i){i.setEmpty(),i.merge(function(t,e,i,s){let r=gs(t,0,4,s.getEnvelope2D());if(r.isEmpty())return new n.E(r);let o=(0,n.m)(n.P,4);for(let e=0;e<4;++e)s.xyRot(t[e],o[e]);let a=gs(o,0,4,s.getRotatedEnvelope2D());return r.intersect(new n.E(a)),new n.E(r)}(t,0,0,e))}class _s{b;len;constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ni(this.b,e,!1):0}getError(t){return 0}}function ps(t,e,i,r,o,a,l){for(;;){let h=n.P.distance(e[0],e[3]),m=n.P.distance(e[0],e[1])+n.P.distance(e[1],e[2])+n.P.distance(e[2],e[3]);if(m-h<=r+i*m)return t+(0,n.r)(h,m,.5);let u=t=>Vi(e,1,t).length();{(0,s.g)(l<12);let h=u(0),d=u(1);o[0]+=2,h>d&&(d=(0,n.c)(h,h=d),e[3]=(0,n.c)(e[0],e[0]=e[3]),e[2]=(0,n.c)(e[1],e[1]=e[2]));let g=h/(h+d),c=1,_=m;for(;g<1/32&&_>=32*(r+i*_);){c/=4;let t=u(c);o[0]++,g=h/(t+h);let i=new n.P;if(Ui(e,.5*c,i),_=n.P.distance(i,e[0]),_<=r){let t=new n.P;Ui(e,c,t),_+=n.P.distance(t,i)}}if(1!==c){let s=(0,n.m)(n.P,4);Wi(e,c,e,s),t=ps(t,s,i,r,o,0,l+1),a++,l++;continue}}o[0]+=8;let d=ri(8,u,0,1);o[0]+=16;let g=ri(16,u,0,1),c=Math.abs(d-g)>r+i*m;if(!c)return t+g;if(a<3){let s=(0,n.m)(n.P,4);Wi(e,.5,e,s),t=ps(t,s,i,r,o,a+1,l+1),a++,l++;continue}o[0]+=32;let _=ri(32,u,0,1);if(c=Math.abs(g-_)>r+i*m,!c)return t+_;o[0]+=64;let p=ri(64,u,0,1);if(c=Math.abs(_-p)>r+i*m,!c)return t+p;o[0]+=128;let f=ri(128,u,0,1);return c=Math.abs(p-f)>r+i*m,t+f}}function fs(t,e,i,s,r){if(i===e)return 0;let o=(0,n.m)(n.P,4);t.queryControlPoints(o);let a=(0,n.m)(n.P,4);return ji(o,e,i,a),ps(0,a,s,r,[0],0,0)}function ys(t,e,i,s,r){let o=!0,a=fe(5,e,i,s,r,e=>{let i=Bi(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*i.length()});o=!1;let l=fe(5,e,i,s,r,e=>{let i=Bi(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*i.length()});return new n.P(a,l)}function Ps(t,e,i,r,o,a,l,h,m,u,d,g){(0,s.g)(u+2===g);let c=0,_=0,p=0,f=0,y=0,P=0,x=0,v=(t,e)=>{let s=1-e,l=i.mul((0,n.aI)(s)),h=r.mul(3*e*s*s),m=o.mul(3*e*e*s),u=a.mul((0,n.aI)(e));return l.add(h).add(m).add(u).sub(d[t]).sqrLength()};for(let e=1,s=g-1;e<s;e++){let s=m[e-1];if(t){e>2?(s=(0,n.s)(2*m[e-2]-m[e-3],0,1),m[e-1]=s):2===e&&(s=(0,n.s)(2*m[e-2],0,1),m[e-1]=s);let t=(t,e,s)=>{let l=-1;for(let h=0;!(Math.abs(e-l)<1e-12||10===h);h++){let h=e*e,m=1-e,u=m*m,g=u*m,c=i.x-2*r.x+o.x,_=i.x-3*r.x+3*o.x-a.x,p=i.y-2*r.y+o.y,f=i.y-3*r.y+3*o.y-a.y,y=i.x-r.x-2*c*e+_*h,P=-d[t].x+i.x*g+e*(3*r.x*u+e*(3*o.x*m+a.x*e)),x=i.y-r.y-2*p*e+f*h,v=-d[t].y+i.y*g+e*(3*r.y*u+e*(3*o.y*m+a.y*e)),C=-6*(y*P+x*v),E=6*(3*(0,n.a)(y)-(-2*c+2*_*e)*P)+6*(3*(0,n.a)(x)-(-2*p+2*f*e)*v);if(l=e,0===E)break;{let t=e-C/E;e=(0,n.s)(t,s,1)}}return l};{let i=v(e,m[e-1]),s=t(e,m[e-1],0),r=v(e,s);if(1.01*i<r){let i=e>1?m[e-2]:0,n=t(e,.3*(m[e-1]-i)+i,0),o=v(e,n);o<r&&(r=o,s=n)}i>r&&(m[e-1]=s)}}let l=m[e-1],h=l*l,u=h*l,g=1-l,C=g*g,E=C*g;c+=3*h*C*C,_+=3*u*E,p+=3*h*h*C;let b=-(E*i.x+u*a.x-d[e].x);f+=b*l*C,y+=b*h*g;let D=-(E*i.y+u*a.y-d[e].y);P+=D*l*C,x+=D*h*g}if(e){let t=c*p-_*_;Math.abs(t)>=1e-12*(Math.abs(c*p)+Math.abs(_*_))+1e-10?(l||(r.x=(f*p-y*_)/t,r.y=(P*p-x*_)/t),h||(o.x=(c*y-_*f)/t,o.y=(c*x-_*P)/t)):((0,n.J)(i,a,.3,r),(0,n.J)(i,a,.6,o))}let C=0;for(let t=1,e=g-1;t<e;t++)C+=v(t,m[t-1]);return C}var xs=r.V;class vs extends Q{static type=s.G.enumBezier;constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||(0,n.af)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=(0,n.m)(n.P,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=(0,n.m)(n.P,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}),(0,s.d)("unrecognized constructor params"),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return At(this)}construct(t,e,i,s){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=s.x,this.m_YEnd=s.y,this.m_cp[0].assign(e),this.m_cp[1].assign(i),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){let e=(0,n.m)(n.P,4);(function(t,e){e[0].assign(t[0]),e[3].assign(t[2]),(0,n.J)(t[0],t[1],2/3,e[1]),(0,n.J)(t[1],t[2],1/3,e[2])})(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(),(0,n.aj)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,n.aj)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),V(this,t)}getGeometryType(){return s.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,s.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;let e=Yi(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i);return}let i=(0,n.m)(n.Z,8),r=(0,n.m)(n.P,4);this.queryControlPoints(r);let o=ds(r,i),a=new n.P;for(let e=1;e<o-1;e++)this.queryCoord2D(i[e].value(),a),t.mergeNe(a)}applyTransformation(t){if(1===t.m_TransformationType){let e=(0,n.m)(n.P,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 Fi(this)}(0,s.g)(0)}createInstance(){return new vs({vd:this.m_description})}calculateLength2D(){return Ni(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return n.P.distance(this.getStartXY(),this.m_cp[0])+n.P.distance(this.m_cp[0],this.m_cp[1])+n.P.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){(0,s.g)(0)}queryCoord2DExtends(t,e,i){let s=(0,n.m)(n.P,4);this.queryControlPoints(s),Ui(s,t,e,i)}queryCoord2DE(t,e){!function(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),function(t,e,i){if(e.value()<=.5){let s=new x;(0,n.ao)(2,x.constructPoint2D(t[0]),x.constructPoint2D(t[1]),e,s);let r=new x;(0,n.ao)(2,x.constructPoint2D(t[1]),x.constructPoint2D(t[2]),e,r);let o=new x;(0,n.ao)(2,x.constructPoint2D(t[2]),x.constructPoint2D(t[3]),e,o);let a=new x;(0,n.ao)(2,s,r,e,a);let l=new x;(0,n.ao)(2,r,o,e,l),(0,n.ao)(2,a,l,e,i)}else{let s=new x;(0,n.ap)(2,x.constructPoint2D(t[0]),x.constructPoint2D(t[1]),e,s);let r=new x;(0,n.ap)(2,x.constructPoint2D(t[1]),x.constructPoint2D(t[2]),e,r);let o=new x;(0,n.ap)(2,x.constructPoint2D(t[2]),x.constructPoint2D(t[3]),e,o);let a=new x;(0,n.ap)(2,s,r,e,a);let l=new x;(0,n.ap)(2,r,o,e,l),(0,n.ap)(2,a,l,e,i)}}(s,e,i)}(this,t,e)}getCoordX(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.x}let e=(0,n.r)(this.getStartX(),this.m_cp[0].x,t),i=(0,n.r)(this.m_cp[0].x,this.m_cp[1].x,t),s=(0,n.r)(this.m_cp[1].x,this.getEndX(),t),r=(0,n.r)(e,i,t),o=(0,n.r)(i,s,t);return(0,n.r)(r,o,t)}getCoordY(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.y}let e=(0,n.r)(this.getStartY(),this.m_cp[0].y,t),i=(0,n.r)(this.m_cp[0].y,this.m_cp[1].y,t),s=(0,n.r)(this.m_cp[1].y,this.getEndY(),t),r=(0,n.r)(e,i,t),o=(0,n.r)(i,s,t);return(0,n.r)(r,o,t)}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=xs.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=xs.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){Qi(this,t,e)}cutBezierIgnoreAttributes(t,e,i){(t<0||e>1||t>e)&&(0,s.a)("Cubic_bezier.cut_bezier_ignore_attributes");let r=(0,n.m)(n.P,4);this.queryControlPoints(r);let o=(0,n.m)(n.P,4);ji(r,t,e,o),i.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,i){this===e&&this===i&&(0,s.a)("Cubic_bezier.split_bezier_ignore_attributes");let r=(0,n.m)(n.P,4);this.queryControlPoints(r);let o=(0,n.m)(n.P,4),a=(0,n.m)(n.P,4);Wi(r,t,o,a),e&&e.setControlPoints(o),i&&i.setControlPoints(a)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,i);if(1===t)return this.getEndAttributeAsDbl(e,i);let s=this.getStartAttributeAsDbl(e,i),r=this.getEndAttributeAsDbl(e,i),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,l=xs.getInterpolation(e);return(0,n.ac)(l,s,r,a,xs.getDefaultValue(e))}getClosestCoordinate(t,e){let i=[NaN];return ms(this,t,n.E.unit(),e,-1,1,i),i[0]}getClosestCoordinateOnInterval(t,e,i=-1){let s=[NaN];return 0===ms(this,t,e,!1,i,1,s)?NaN:s[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.a)("");let i=Ri(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)Gi(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){let r=(0,n.m)(n.P,4);return this.queryControlPoints(r),function(t,e,i,s,r){let o=(0,n.m)(n.Z,4),a=(0,n.m)(n.Z,3),l=new n.E(0,1),h=0;if(e){if(Mi(t,o,!1),h=zt(o[3],o[2],o[1],o[0].sub(i),l,!1,a),s)for(let e=0;e<h;e++){let i=new n.P;Ui(t,a[e].value(),i),s[e]=i.x}}else if(Ii(t,o,!1),h=zt(o[3],o[2],o[1],o[0].sub(i),l,!1,a),s)for(let e=0;e<h;e++){let i=new n.P;Ui(t,a[e].value(),i),s[e]=i.y}if(r)for(let t=0;t<h;t++)r[t]=a[t].value();else s&&(0,n.a5)(s,0,h,n.X);return h}(r,t,e,i,s)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isDegenerate(t){return w(this,t)}isDegenerate3D(t,e){return(0,s.g)(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());(0,s.g)(0)}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);let i=n.E.constructEmpty();return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.m)(n.P,4);this.queryControlPoints(i),ji(i,t.vmin,t.vmax,i),e.setFromPoints(i,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),s=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),r=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),n=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp[0].setCoordsPoint2D(t):s&&this.m_cp[0].setCoordsPoint2D(e),n?this.m_cp[1].setCoordsPoint2D(e):r&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ni(this,t,!0)}lengthToT(t){return function(t,e){let i=Ni(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;let r=[0];return 1!==It(new _s(t,e),n.E.unit(),1,r)&&(0,s.d)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=(0,n.m)(n.P,4);Si(this,e);let i=e[3],s=e[2],r=e[1],o=new n.P;o.x=(5*i.x*i.x*(7*s.y+16*r.y)+i.x*(-35*i.y*s.x+40*s.x*s.y-80*i.y*r.x+140*s.x*r.y+112*r.x*r.y)-2*(i.y*(20*s.x*s.x+70*s.x*r.x+56*r.x*r.x)-7*(4*s.x+5*r.x)*(-s.y*r.x+s.x*r.y)))/840,o.y=(-5*i.y*i.y*(7*s.x+16*r.x)+i.y*(5*i.x*(7*s.y+16*r.y)-4*(10*s.x*s.y+35*s.y*r.x+28*r.x*r.y))+2*(-7*(4*s.y+5*r.y)*(s.y*r.x-s.x*r.y)+i.x*(20*s.y*s.y+70*s.y*r.y+56*r.y*r.y)))/840;let a=ki(this);return o.x+=(e[0].x-t.x)*a,o.y+=(e[0].y-t.y)*a,o}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=2**-52*8*i}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.a)("calculate_sub_weightedCentroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=Ri(t),a=wi(t),l=a/t.calculateUpperLength2D(),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),n=ys(t,h,s,l,a);if(r.addThis(n),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(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 e=0;e<4;e++)t[e].isNAN()&&(0,s.a)("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){let e=(0,n.m)(n.P,4);return this.queryControlPoints(e),Oi(e,t)}getDerivative(t){let e=(0,n.m)(n.P,4);return this.queryControlPoints(e),Vi(e,1,t)}getCurvature(t){let e=Bi(this,1,t),i=Bi(this,2,t),s=e.sqrLength();return 0===s?NaN:(e.divThis(Math.sqrt(s)),e.crossProduct(i)/s)}isIntersectingPoint(t,e,i){if(i&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;let s=new o.Envelope2D;if(this.queryLooseEnvelope(s),s.inflateCoords(e,e),!s.contains(t))return!1;let r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}isMonotoneQuickAndDirty(){let t=(0,n.m)(n.P,4);return this.queryControlPoints(t),function(t){return function(t){let e=(0,n.a7)(t[0].y,t[1].y),i=(0,n.a7)(t[1].y,t[2].y),s=(0,n.a7)(t[2].y,t[3].y);if(e>=0&&i>=0&&s>=0||e<=0&&i<=0&&s<=0){let e=(0,n.a7)(t[0].x,t[1].x),i=(0,n.a7)(t[1].x,t[2].x),s=(0,n.a7)(t[2].x,t[3].x);if(e>=0&&i>=0&&s>=0||e<=0&&i<=0&&s<=0)return!0}return!1}(t)}(t)}getMonotonicPartParams(t,e){let i=Ri(this),r=i.specialPointsCount();if((0,s.g)(W.s_maxMonotonicPartParams>=r),!e)return i.specialPointsCount();t<r&&(0,s.a)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.c)(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]=(0,n.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,n.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){let t=new n.Z;return zi(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){let e=(0,n.m)(n.P,4);this.queryControlPoints(e);let i=e[3].sub(e[0]),s=i.length();if(n.P.distance(e[0],e[1])+n.P.distance(e[2],e[1])+n.P.distance(e[2],e[3])-s>t)return!1;let r=t,o=e[1].clone();o.subThis(e[0]);let a=Math.abs(o.crossProduct(i))/s;return!(a>r||(o=e[2].clone(),o.subThis(e[1]),a=Math.abs(o.crossProduct(i))/s,a>r))}copyIgnoreAttributes(t){let e=(0,n.m)(n.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return ki(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1);var t}queryEnvelopeW(t,e){os(this,t,e)}setSegmentFromCoordsForStitcher(t,e){!function(t,e,i){if((0,s.g)(i>=2),2===i){let s=new n.P;(0,n.J)(e[0],e[i-1],1/3,s);let r=new n.P;return(0,n.J)(e[0],e[i-1],2/3,r),void t.construct(e[0],s,r,e[i-1])}let r=e[0],o=e[i-1],a=[0,0],l=ms(t,r,n.E.unit(),!1,NaN,2,a),h=[0,0],m=ms(t,o,n.E.unit(),!1,NaN,2,h),u=[];for(let s=0;s<l;s++)for(let l=0;l<m;l++){let m=a[s],d=h[l],g=m>d,c=(s,a)=>{let l=(0,n.d)(i-2,NaN),h=()=>{let t=0;for(let s=1,r=i-1;s<r;s++){t+=n.P.distance(e[s-1],e[s]);let i=t;l[s-1]=i}t+=n.P.distance(e[i-2],e[i-1]),g&&l.reverse();for(let e=1,s=i-1;e<s;e++)l[e-1]/=t,g&&(l[e-1]=1-l[e-1])},u=!1,c=!1;{let e=new Xn;g?(t.queryCut(d,m,e,!0),s.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())):(t.queryCut(m,d,e,!0),s.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())),r.equals(s)&&(u=!0),o.equals(a)&&(c=!0)}h();let _=Number.MAX_VALUE,p=s.clone(),f=a.clone();for(let t=0;t<5;t++)_=Ps(!0,!1,r,p,f,o,u,c,l,i-2,e,i);for(let t=0;t<30;t++){let t=p.clone();f.clone();let s=Ps(!0,!0,r,p,f,o,u,c,l,i-2,e,i);if(_<=s&&t.equals(p)&&t.equals(f))break;_=s}h();let y=!1,P=Number.MAX_VALUE,x=s.clone(),v=a.clone();for(let t=0;t<30;t++){let t=x.clone();v.clone();let s=Ps(y,!0,r,x,v,o,u,c,l,i-2,e,i);if(P<=s&&t.equals(x)&&t.equals(v))break;y=!0,P=s}return P<_?(s.assign(x),a.assign(v)):(s.assign(p),a.assign(f),P=_),P},_=new n.P,p=new n.P,f=[c(_,p),n.P.distance(r,_)+n.P.distance(_,p)+n.P.distance(p,o),_.x,_.y,p.x,p.y];u.splice(u.length,0,...f)}let d=u[0],g=u[1],c=0;for(let t=6;t<u.length;t+=6)u[t]<d&&(d=u[t],g=u[t+1],c=t);let _=c;for(let t=0;t<u.length;t+=6)t!==c&&u[t+1]<g&&Math.abs(d-u[t])<10*d&&(g=u[t+1],_=t);t.construct(r,new n.P(u[_+2],u[_+3]),new n.P(u[_+4],u[_+5]),o)}(this,t,e)}writeInBufferStream(t,e){let i=new Float64Array(4);return this.writeInBuffer_(i),t.writeRangeFromArray(e,i.length,i,!0,1),e+i.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){let i=new Float64Array(4);t.queryRange(e,i.length,i,!0,1),this.readFromBuffer_(i)}readFromBuffer_(t){this.m_cp=(0,n.m)(n.P,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){let e=(0,n.m)(n.P,4);this.queryControlPoints(e);let i=(e,i,s)=>{let r=!1;return n.P.sqrDistance(e,s)<=t&&(r=!e.equals(s),e.setCoordsPoint2D(s),n.P.sqrDistance(i,s)<=t&&(r||=!i.equals(s),i.setCoordsPoint2D(s))),r},s=i(e[1],e[2],e[0]),r=i(e[2],e[1],e[3]);return(s||r)&&this.setControlPoints(e),s||r}needsSnapControlPoints(t){if(!t)return!1;let e=(0,n.m)(n.P,4);this.queryControlPoints(e);let i=(e,i,s)=>{let r=!1;return n.P.sqrDistance(e,s)<=t&&(r=!e.equals(s),e.setCoordsPoint2D(s),n.P.sqrDistance(i,s)<=t&&(r||=!i.equals(s),i.setCoordsPoint2D(s))),r},s=i(e[1],e[2],e[0]),r=i(e[2],e[1],e[3]);return s||r}calculateSpecialPointsForCracking(t,e){return function(t,e,i){i.length=0;{let e=new n.Z;zi(t,e);let s=new x;if(Qi(t,e,s),s.isZero())return e.isZero()||e.eq(new n.Z(1))?0:(i.push(e.value()),1)}let s=(0,n.m)(n.Z,4);Ai(t,s,!0);let r=(0,n.m)(n.Z,4);Ti(t,r,!0);let o=(0,n.m)(n.Z,6),a=s[3].negate().mulE(r[1]).addE(s[2].mulE(r[2]).mul(2)).addE(s[1].mulE(r[3])),l=s[3].negate().mulE(r[1]).subE(s[2].mulE(r[2]).mul(2)).addE(s[1].mulE(r[3])),h=s[2].mulE(s[2]).subE(r[2].mulE(r[2]));o[0]=r[1].mulE(r[1]).mulE(a).addE(s[1].mulE(s[1]).mulE(l)).addE(s[1].mulE(r[1]).mulE(h).mul(2)).mul(6),o[1]=s[2].mulE(r[1]).subE(s[1].mulE(r[2])).mulE(s[2].mulE(s[2]).addE(s[1].mulE(s[3]).mul(2)).addE(r[2].mulE(r[2])).addE(r[1].mulE(r[3]).mul(2))).mul(24);let m=s[1].mulE(r[2]).mulE(r[2]).mulE(r[3]),u=s[2].mulE(s[2]).mulE(s[3]).mulE(r[1]).subE(m).mul(156),d=s[3].mulE(r[1]).subE(s[1].mulE(r[3])),g=s[3].mulE(r[1]).subE(s[1].mulE(r[3])),c=s[1].mulE(s[3]).mulE(g).addE(r[1].mulE(r[3]).mulE(d)).mul(72),_=r[1].mulE(r[3]).subE(s[1].mulE(s[3])),p=s[2].mulE(r[2]).mulE(_).mul(120),f=s[1].mulE(s[2]).mulE(s[2]).mulE(r[3]),y=s[3].mulE(r[1]).mulE(r[2]).mulE(r[2]).subE(f).mul(36);o[2]=u.addE(c).addE(p).addE(y);let P=s[2].mulE(s[3]).mulE(s[3]).mulE(r[1]).subE(s[1].mulE(r[2]).mulE(r[3]).mulE(r[3])).mul(360),v=s[2].mulE(r[2]).mulE(s[2].mulE(s[3]).subE(r[2].mulE(r[3]))).addE(s[3].mulE(r[2]).mulE(r[2]).mulE(r[2])).subE(s[2].mulE(s[2]).mulE(s[2]).mulE(r[3])).mul(24),C=s[2].mulE(r[1]).mulE(r[3]).mulE(r[3]).subE(s[1].mulE(s[3]).mulE(s[3]).mulE(r[2])).mul(72),E=s[3].mulE(r[3]).mulE(r[1].mulE(r[2]).subE(s[1].mulE(s[2]))).mul(288);o[3]=P.addE(v).addE(C).addE(E),o[4]=r[3].mulE(r[3]).addE(s[3].mulE(s[3])).mulE(s[3].mulE(r[1]).subE(s[1].mulE(r[3]))).mul(270).addE(s[3].mulE(r[2]).subE(s[2].mulE(r[3]))).mulE(s[2].mulE(s[3]).addE(r[2].mulE(r[3]))).mul(180),o[5]=s[3].mulE(r[2]).subE(s[2].mulE(r[3])).mulE(s[3].mulE(s[3]).addE(r[3].mulE(r[3]))).mul(216);let b=(0,n.m)(n.Z,5),D=Vt(o,5,new n.E(0,1),!1,b,5);if(D>0){let s=Math.abs(t.getCurvature(0)),r=0,o=Math.abs(t.getCurvature(1));(o>s||!Number.isFinite(o))&&(r=1);for(let e=0;e<D;e++){let i=Math.abs(t.getCurvature(b[e].value()));t.getCoord2D(b[e].value()),(i>s||!Number.isFinite(i))&&(s=i,r=b[e].value())}if((!Number.isFinite(s)||1/s<e)&&!(0,n.ab)(r,0,1)){let e=t.getCoord2D(r);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return i.push(r),1}}if(!t.isClosed()){let e=[0,0],s=us(t,e,!1);for(let t=0;t<s;t++)e[t]>0&&e[t]<1&&i.push(e[t]);return i.length}return 0}(this,t,e)}ensureXYMonotone(){return Gi(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.m)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformPoints2D(t.m_cp,2,t.m_cp):((0,n.J)(e,i,1/3,t.m_cp[0]),(0,n.J)(e,i,2/3,t.m_cp[1])),t.changeEndPoints2D(e,i),r&&Gi(t)}(this,t,e,i)}copyToImpl(t){let e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Xi(e,Yi(this))}reverseImpl(){this.m_cp[1]=(0,n.c)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){let e=t;return!(!this.m_cp[0].equals(e.m_cp[0])||!this.m_cp[1].equals(e.m_cp[1]))}equalsImplTol(t,e){let i=t;return!(!this.m_cp[0].isEqualPoint2D(i.m_cp[0],e)||!this.m_cp[1].isEqualPoint2D(i.m_cp[1],e))}swapImpl(t){let e=t;e.m_cp[0]=(0,n.c)(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=(0,n.c)(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),function(t,e){e.m_cachedValues=(0,n.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Fi(this)}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,r){let o=new p;if(os(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;let a=Ri(t),l=0,h=a.specialPoints[0],m=[];for(let i=1,r=a.specialPoints.length;i<r;++i){let r=a.specialPoints[i],n=Li(t,e,h,r);if(0===m.length)m.push(n);else if(n.t===n.tmin)(0,s.g)(m.at(-1).d<=n.d),m.at(-1).tmax=n.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,s.g)(m.at(-1).d>=n.d);let t=m.at(-1).tmin;m[m.length-1]=n,m.at(-1).tmin=t}else m.push(n);h=r}for(let t of m)if(t.d<=r){let e=t.t;i?(l>=i.length&&(0,s.r)(""),i[l]=e,l++):l++}return l}(this,t,e,i)}endPointModified(){Fi(this)}clearEndPointModified(){}m_cp;m_cachedValues}class Cs{specialPoints;specialPointsLength;length;area;centroidX;centroidY;constructor(){this.length=NaN,this.area=NaN,this.centroidX=NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function Es(t,e,i,r,o,a,l,h){for(;;){let m=n.P.distance(e[0],e[2]),u=n.P.distance(e[0],e[1])+n.P.distance(e[1],e[2]);if(u-m<=o+r*u)return t+(0,n.r)(m,u,.5);let d=(0,n.m)(n.P,4),g=t=>(Ns(e,i,1,t,d),d[1].length());if(0===l&&h<8){(0,s.g)(h<8);let m=g(0),d=g(1);a[0]+=2,m>d&&(d=(0,n.c)(m,m=d),e[2]=(0,n.c)(e[0],e[0]=e[2]),i[2]=(0,n.c)(i[0],i[0]=i[2]));let c=m/(m+d),_=1,p=u;for(;c<1/32&&p>=o+r*p;){_/=4;let t=g(_);a[0]++,c=m/(t+m);let s=new n.P;if(mr(e,i,.5*_,s),p=n.P.distance(s,e[0]),p<=o){let t=new n.P;mr(e,i,_,t),p+=n.P.distance(t,s)}}if(1!==_){let s=(0,n.m)(n.P,3),m=[0,0,0];Qs(e,i,_,e,i,s,m),t=Es(t,s,m,r,o,a,0,h+1),l++,h++;continue}}let c=!1;a[0]+=8;let _=ri(8,g,0,1);a[0]+=16;let p=ri(16,g,0,1);if(c=Math.abs(_-p)>o+r*u,!c)return t+p;if(l<8&&h<9){let s=(0,n.m)(n.P,3),m=[0,0,0];Qs(e,i,.5,e,i,s,m),t=Es(t,s,m,r,o,a,l+1,h+1),l++,h++;continue}a[0]+=32;let f=ri(32,g,0,1);if(c=Math.abs(p-f)>o+r*u,!c)return t+f;a[0]+=64;let y=ri(64,g,0,1);if(c=Math.abs(f-y)>o+r*u,!c)return t+y;a[0]+=128;let P=ri(128,g,0,1);return c=Math.abs(y-P)>o+r*u,t+P}}function bs(t,e,i,s,r){if(i===e)return 0;let o=(0,n.m)(n.P,3),a=[0,0,0];t.queryControlPoints(o),t.queryWeights(a);let l=[0,0,0],h=(0,n.m)(n.P,3);return Ks(o,a,e,i,h,l),Es(0,h,l,s,r,[0],0,0)}class Ds{controlPoints;weights;point;constructor(t,e,i){this.controlPoints=(0,n.aa)(t,3),this.weights=[0,0,0],(0,n.b)(this.weights,e,0,0,3),this.point=i.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){let t=new n.P;mr(this.controlPoints,this.weights,e,t);let i=(0,n.m)(n.P,4);return Ns(this.controlPoints,this.weights,1,e,i),2*t.sub(this.point).dotProduct(i[1])}if(1===t){let t=new n.P;mr(this.controlPoints,this.weights,e,t);let i=(0,n.m)(n.P,4);return Ns(this.controlPoints,this.weights,2,e,i),2*(t.sub(this.point).dotProduct(i[2])+i[1].dotProduct(i[1]))}if(2===t){let t=new n.P;mr(this.controlPoints,this.weights,e,t);let i=(0,n.m)(n.P,4);return Ns(this.controlPoints,this.weights,3,e,i),2*(t.sub(this.point).dotProduct(i[3])+3*i[1].dotProduct(i[2]))}return 0}getError(t){return(0,s.g)(0),0}}function ws(t,e,i,s){let r=function(t,e,i,s,r){return{tmin:0,tmax:0,t:0,d:0,pt:r.clone()}}(0,0,0,0,n.P.getNAN()),o=(0,n.d)(18,NaN),a=(0,n.m)(n.P,3);t.queryControlPoints(a),a[2].subThis(e),a[1].subThis(e),a[0].subThis(e);let l=[0,0,0];t.queryWeights(l);let h=[1,dr(l),1],m=cr(l,i),u=cr(l,s),d=It(new Ds(a,h,new n.P(0,0)),n.E.construct(m,u),18,o);mr(a,h,m,r.pt),r.t=m,r.d=n.P.distance(r.pt,new n.P(0,0));let g=new n.P;mr(a,h,u,g);let c=n.P.distance(g,new n.P(0,0));c<r.d&&(r.d=c,r.t=u,r.pt.assign(g));for(let t=0;t<d;t++){mr(a,h,o[t],g);let e=n.P.distance(g,new n.P(0,0));e<r.d&&(r.d=e,r.t=gr(l,o[t]),r.pt.assign(g))}return r}function Ss(t,e,i,s,r){let o=!0,a=(0,n.m)(n.P,4),l=fe(5,e,i,s,r,e=>(qs(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));o=!1;let h=fe(5,e,i,s,r,e=>(qs(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));return new n.P(l,h)}function As(t){t.m_cachedValues=null}function Ts(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new Cs,i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=[0,0,0];return t.queryWeights(s),Is(i,s,e.specialPoints),ks(t,e),e}function Is(t,e,i){if(0===e[1])return i.length=0,i.push(0),void i.push(1);let s=(0,n.m)(n.Z,8);s[0].set(0);let r=1;{let i=new n.Z(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new n.Z(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=i.subE(o).addThisE(new n.Z(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(i.mul(2));let l=(0,n.m)(n.Z,2),h=Lt(a,o,i,new n.E(0,1),!1,l);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.ab)(l[t].value(),0,1)||(s[r]=l[t],r++)}{let i=new n.Z(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new n.Z(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=i.subE(o).addThisE(new n.Z(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(i.mul(2));let l=(0,n.m)(n.Z,2),h=Lt(a,o,i,new n.E(0,1),!1,l);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.ab)(l[t].value(),0,1)||(s[r]=l[t],r++)}if(s[r].set(1),r++,r>2){(0,n.a5)(s,0,r,(t,e)=>(0,n.X)(t.value(),e.value()));let t=0,e=s[0].value(),i=1;for(let n=1;n<r;n++)s[n].eq(s[n-1])?(e+=s[n].value(),i++):(i>1&&(e/=i,s[t].set(e)),t++,s[t]=s[n],e=s[n].value(),i=1);t++,r=t}s[0].set(0),s[r-1].set(1),i.length=r;for(let t=0;t<r;t++)i[t]=s[t].value()}function Ms(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+Ms(t,1,!1)}if(t.isDegenerate(0))return 0;let s=1===e,r=Ts(t);if(s&&!Number.isNaN(r.length))return r.length;let n=Vs(t),o=n/t.calculateUpperLength2D(),a=0,l=0;for(let i=1,s=r.specialPointsCount();i<s;i++){let s=r.specialPoints[i];if(a+=bs(t,l,Math.min(e,s),o,n),e<=s)break;l=s}return s&&(r.length=a),a}function qs(t,e,i,s){let r=(0,n.m)(n.P,3);t.queryControlPoints(r);let o=[0,0,0];t.queryWeights(o),Ns(r,o,e,i,s)}function Ns(t,e,i,r,o){let a=[t[0],t[1],t[2]],l=[e[0],e[1],e[2]],h=(0,n.m)(n.P,4);!function(t,e,i,r,n){(0,s.g)(i>0);let 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)}let a=Rs(o,e,0,r),l=Xs(e,0,r),h=a.divide(l);if(n[0].assign(h),0===i)return;let m=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],u=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],d=l*l,g=Rs(u,m,0,r).mul(2).divide(d);if(n[1].assign(g),1===i)return;let c=Xs(e,1,r),_=2*l*c,p=Rs(u,m,1,r).mul(2).sub(g.mul(_)).divide(d);if(n[2].assign(p),2===i)return;let f=Rs(u,m,2,r).mul(2),y=2*(c*c+l*Xs(e,2,r)),P=f.sub(p.mul(_).mul(2)).sub(g.mul(y)).divide(d);n[3].assign(P),3!==i&&(0,s.d)("")}(a,l,i,r,h);for(let t=0;t<=i;t++)o[t].setCoords(h[t].x,h[t].y)}function Rs(t,e,i,r){if(0===i){if(r<=.5){let i=new n.P;(0,n.as)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,i);let s=new n.P;(0,n.as)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,s);let o=new n.P;return(0,n.as)(2,i,s,r,o),o}{let i=new n.P;(0,n.at)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,i);let s=new n.P;(0,n.at)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,s);let o=new n.P;return(0,n.at)(2,i,s,r,o),o}}if(1===i){let i=t[1].mul(e[1]),s=i.sub(t[0].mul(e[0])).mul(1-r).add(t[2].mul(e[2]).sub(i).mul(r));return s.mulThis(2),s}if(2===i){let i=t[1].mul(e[1]),s=t[2].mul(e[2]).sub(i).sub(i.sub(t[0].mul(e[0])));return s.mulThis(2),s}(0,s.d)("")}function Ys(t,e,i,s){if(s.toDouble()<=.5){let i=new x;(0,n.ao)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),s,i);let r=new x;(0,n.ao)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),s,r);let o=new x;return(0,n.ao)(2,i,r,s,o),o}{let i=new x;(0,n.ap)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),s,i);let r=new x;(0,n.ap)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),s,r);let o=new x;return(0,n.ap)(2,i,r,s,o),o}}function Xs(t,e,i){if(0===e){let e=(0,n.r)(t[0],t[1],i),s=(0,n.r)(t[1],t[2],i);return(0,n.r)(e,s,i)}return 1===e?2*((1-i)*(t[1]-t[0])+(t[2]-t[1])*i):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,s.d)("")}function Fs(t,e,i){let s=(0,n.s)(i,0,1),r=(0,n.m)(n.P,4);if(Ns(t,e,3,s,r),r[1].isZero()){if(r[2].isZero())return r[3];{let t=r[2].clone();return 1===s&&t.negateThis(),t}}return r[1]}class Ls{b;len=0;constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ms(this.b,e,!1):0}getError(t){return(0,s.g)(0),0}}function zs(t){let e=(0,n.m)(n.P,3),i=[0,0,0];return t.queryControlPoints(e),t.queryWeights(i),function(t,e){let i=dr(e);if(1===i)return Ne(t);if(0===i)return 0;let r=[new n.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=r[1].crossProduct(r[2]);if(i<1){(0,s.g)(i>0);let t,e=1-i;if(e<.01)t=-1/3+e*(2/15+e*(3/35+e*(16/315+e*(20/693+e*(16/1001+56/6435*e)))));else{let s=e*(1+i),r=Math.atan2(Math.sqrt(e),Math.sqrt(1+i));t=i*(.5*i-(0,n.aK)(s)*r)/s}return o*t}{let t=(i-1)*(i+1);return.25*i/t**1.5*(-2*i*Math.sqrt(t)*o-4*r[1].y*r[2].x*Math.atanh(Math.sqrt((i-1)/(i+1)))-r[1].x*r[2].y*Math.log(2*i*(i-Math.sqrt(t))-1))}}(e,i)}function Vs(t){return function(t){return 256*(0,n.I)()*t}(t.calculateUpperLength2D())}function Bs(t){return t.m_cachedValues}function ks(t,e){t.m_cachedValues=e}function Gs(t,e,i,s,r){let o=(0,n.m)(n.P,3);t.queryControlPoints(o);let a=[0,0,0];t.queryWeights(a);let l=[0];return 1===Zs(o,a,e,n.E.unit(),s,r,1,l)?l[0]:NaN}function Zs(t,e,i,o,a,l,h,m){(0,s.D)(n.E.unit().contains(o)&&h>0,""),(l<0||Number.isNaN(l))&&(l=Number.MAX_VALUE);let u=[,,,];for(let e=0;e<3;++e)u[e]=t[e].sub(i);let d=dr(e),g=C.constructPoint2D(u[0]),c=C.constructPoint2D(u[1]),_=C.constructPoint2D(u[2]),p=n.M.constructDouble(d),f=p.clone();f.ldexpThis(1);let y=g.dotProduct(c.sub(g)).mul(p),P=p.mul(p.addDouble(2)),x=_.sub(c.mul(P.ldexp(1))),v=c.sqrLength().mul(p.mul(p).ldexp(1)).add(g.sqrLength().mul(p.ldexp(2).subDouble(1))).add(g.dotProduct(x)),E=_.sub(c.mul(f)).add(g.mul(f.subDouble(1))),b=c.mul(p).sub(g).dotProduct(E).mulDouble(3),D=c.dotProduct(_).mul(p.subDouble(3).mul(p)).ldexp(1),w=c.sqrLength().mul(p.mul(p).ldexp(2)),S=g.sqrLength().mul(p.ldexp(2).subDouble(3)),A=g.dotProduct(_.sub(c.mul(p.mulDouble(3).subDouble(1)).mul(p))).ldexp(1),T=_.sqrLength().addThis(D).addThis(w).addThis(S).addThis(A),I=g.add(_).sub(c.mul(f)),M=p.subDouble(1),q=_.sub(g).dotProduct(I).mul(M),N=new n.P(0,0),R=[],Y=new n.P;mr(u,e,o.vmin,Y);let X=n.P.distance(Y,N);if(X<=l&&R.push(new n.P(o.vmin,X)),o.vmin!==o.vmax&&(mr(u,e,o.vmax,Y),X=n.P.distance(Y,N),X<=l&&R.push(new n.P(o.vmax,X))),o.width()>0){let t=u[2].isZero(),i=(0,n.m)(n.M,4),s=ne(q,T,b,v,y,58,o,t,i);for(let t=0;t<s;t++){if(!o.containsExclusiveCoordinate(i[t].toDouble()))continue;let s=i[t].toDouble();s=gr(e,s);let r=new n.P;mr(u,e,s,r),X=n.P.distance(r,N),X<=l&&R.push(new n.P(s,X))}}if(a){(0,s.g)(o.equals(n.E.unit()));{mr(u,e,-1,Y,!0);let t=new n.P;mr(u,e,0,t);let i=new Yn({start:Y,end:t}),s=i.getClosestCoordinate(N,!0);s<1&&(Y=i.getCoord2D(s),X=n.P.distance(Y,N),X<=l&&R.push(new n.P(s-1,X)))}{mr(u,e,2,Y,!0);let t=new n.P;mr(u,e,o.vmax,t);let i=new Yn({start:t,end:Y}),s=i.getClosestCoordinate(N,!0);s>0&&(Y=i.getCoord2D(s),X=n.P.distance(Y,N),X<=l&&R.push(new n.P(1+s,X)))}}if(!R.length)return 0;R.sort((t,e)=>t.compare(e));let F=0,L=R[0].x;if(m[F++]=L,F<h){let t=(0,r.a4)(u,4,!1).total(),e=R[0].y;for(let i=1,s=R.length;i<s;i++)if(R[i].y>e+t){R.length=i;break}R.sort((t,e)=>(0,n.X)(t.x,e.x)),F=0,m[F++]=R[0].x;for(let t=1,e=R.length;t<e;t++)R[t].x!==m[F-1]&&F<h&&(m[F++]=R[t].x)}return F}function Hs(t,e,i){let s=(0,n.m)(n.P,3);t.queryControlPoints(s);let r=[0,0,0];t.queryWeights(r),Ws(s,r,e,i)}function Ws(t,e,i,s){if(i.equalsRange(0,1))return void s.setFromPoints(t,3);let r=(0,n.m)(n.P,3);Ks(t,e,i.vmin,i.vmax,r,[0,0,0]),s.setFromPoints(r,3)}function js(t){let e=(0,n.a7)(t[0].y,t[1].y),i=(0,n.a7)(t[1].y,t[2].y);if(e>=0&&i>=0||e<=0&&i<=0){let e=(0,n.a7)(t[0].x,t[1].x),i=(0,n.a7)(t[1].x,t[2].x);if(e>=0&&i>=0||e<=0&&i<=0)return!0}return!1}function Us(t){let e=(0,n.m)(n.P,3);t.queryControlPoints(e);let i=Os(e);return i&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),i}function Os(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.a7)(t[0][i],t[2][i]);s>0?((0,n.a7)(t[0][i],t[1][i])<0&&(t[1][i]=t[0][i],e=!0),(0,n.a7)(t[1][i],t[2][i])<0&&(t[1][i]=t[2][i],e=!0)):s<0?((0,n.a7)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.a7)(t[1][i],t[2][i])>0&&(t[1][i]=t[2][i],e=!0)):t[1][i]!==t[0][i]&&(t[1][i]=t[0][i],e=!0)}return e}function Qs(t,e,i,o,a,l,h){(0,s.g)(i>=0&&i<=1&&o!==l&&a!==h),(0,s.g)(e[0]>0&&e[2]>0&&e[1]>=0);let m=[1,dr(e),1],u=cr(e,i),d=(0,n.aa)(t,3),g=(0,n.m)(r.k,3);ar(d,m,g);let c=(0,n.m)(r.k,3),_=(0,n.m)(r.k,3);_r(g,u,o?c:null,l?_:null),pr(e,i,a,h);let p=js(d);if(o){for(let t=0;t<3;++t)hr(c[t],o[t]);yr(d,o),p&&Os(o)}if(l){for(let t=0;t<3;++t)hr(_[t],l[t]);yr(d,l),p&&Os(l)}}function Ks(t,e,i,o,a,l){if((0,s.g)(i>=0&&o<=1&&i<=o),i===o){let s=new n.P,r=lr(t,e,i,s);return fr(t,s),a[0].assign(s),a[1].assign(s),a[2].assign(s),l[0]=r,l[1]=r,void(l[2]=r)}if(0===i&&1===o)return a[0].assign(t[0]),a[1].assign(t[1]),a[2].assign(t[2]),l[0]=e[0],l[1]=e[1],void(l[2]=e[2]);let h=(0,n.m)(r.k,3);{let s=[1,dr(e),1],r=cr(e,i),n=cr(e,o);ar(t,s,h),_r(h,n,h,null),_r(h,r>=n?1:r/n,null,h)}let m=[0,0,0];pr(e,o,m,null),pr(m,i/o,null,m);let u=js(t),d=(0,n.m)(n.P,3);hr(h[1],d[1]),mr(t,e,i,d[0]),mr(t,e,o,d[2]),yr(t,d);for(let t=0;t<3;++t)a[t].assign(d[t]),l[t]=m[t];u&&Os(a)}function Js(t,e,i){let s=dr(e),r=[1,s,1],o=4*s/(3*(1+s));i[0].assign(t[0]),i[3].assign(t[2]),(0,n.J)(t[0],t[1],o,i[1]),(0,n.J)(t[2],t[1],o,i[2]),new vs({cp:i}),new Ut({points:t,weight:s});let a=0,l=.1,h=0;for(let e=0;e<9;e++,l+=.1){let e=new n.P;mr(t,r,l,e);let s=new n.P;Ui(i,l,s);let o=n.P.sqrDistance(e,s);o>a&&(a=o,h=l)}{let e=new n.P;mr(t,r,h,e);let s=[0];hs(i,e,n.E.unit(),!1,-1,1,s);let o=new n.P;return Ui(i,s[0],o),a=n.P.sqrDistance(e,o),Math.sqrt(a)}}function $s(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===ir(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function tr(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===sr(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function er(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(D(e,i))return 1;return 0===nr(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function ir(t,e,i,r,o,a,l,h,m,u){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),i.isDegenerate(0)){let t=[0,0],s=e.intersectPoint(i.getStartXY(),t,l);if(s>0){if(null!==o)for(let e=0;e<s;e++)o.push(t[e]);if(null!=a)for(let t=0;t<s;t++)a.push(0);if(null!=r)for(let i=0;i<s;i++){let s=new n.P;e.queryCoord2D(t[i],s),r.push(s)}}return s}let d=k(e,i);if(l=Math.max(l,d),e.isDegenerateToLineHelper(d)){let t=new Yn({start:e.getStartXY(),end:e.getEndXY()}),s=ot(t,i,r,o,a,l,h,u);if(o)for(let i=0;i<s;++i){let s=t.getCoord2D(o[i]);o[i]=e.getClosestCoordinate(s,!1)}return s}if(G(e,i,l))return 0;let g=(0,n.m)(n.P,3);e.queryControlPoints(g);let c=[0,0,0];e.queryWeights(c);let _=[1,dr(c),1],p=i.getEndXY().sub(i.getStartXY()),f=p.clone();f.leftPerpendicularThis();let y=g[0].clone(),P=g[1].clone(),x=g[2].clone(),v=P.sub(y),C=x.sub(y),E=x.sub(P),b=_[0],D=_[1],w=_[2],S=b*D,A=b*w,T=D*w,I=v.dotProduct(f)*S,M=C.dotProduct(f)*A,q=I,N=M-2*I,R=E.dotProduct(f)*T+M-M,Y=(0,n.d)(13,NaN),X=(0,n.d)(13,NaN),F=Mt(R,N,q,n.E.unit(),!1,Y);F<0&&(Y[0]=0,Y[1]=1,F=2);let L=0;for(let t=0,e=L;t<F;++t){let s=new n.P;mr(g,_,Y[t+e],s),X[L]=i.getClosestCoordinate(s,!1),n.P.distance(s,i.getCoord2D(X[L]))<=l&&(Y[L]=Y[t+e],L++)}let z=(0,n.m)(n.P,3),V=(0,n.m)(n.P,3);if(e.queryControlPoints(V),V[0].subThis(i.getStartXY()),V[1].subThis(i.getStartXY()),V[2].subThis(i.getStartXY()),function(t,e,i,s=!1){let r=(0,n.m)(n.P,3);s?(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[1].subThis(r[0]),r[2].setCoordsPoint2D(t[2]),r[2].subThis(r[0]),r[0].setCoords(0,0)):(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[2].setCoordsPoint2D(t[2])),r[0].mulThis(e[0]),r[1].mulThis(e[1]),r[2].mulThis(e[2]),i[1].setCoords(r[1].x-r[0].x,r[1].y-r[0].y),i[2].setCoordsPoint2D(r[2].sub(r[1])),i[2].subThis(i[1]),i[1].x*=2,i[1].y*=2,i[0].setCoordsPoint2D(r[0])}(V,_,z,!1),Math.abs(p.x)>=Math.abs(p.y)){let t=p.y/p.x;R=z[2].y-z[2].x*t,N=z[1].y-z[1].x*t,q=z[0].y-z[0].x*t}else{let t=p.x/p.y;R=z[2].x-z[2].y*t,N=z[1].x-z[1].y*t,q=z[0].x-z[0].y*t}let B=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),Z=[0,0];F=Mt(R,N,q,n.E.unit(),B,Z);for(let t=0,e=L;t<F;++t){Y[t+e]=Z[t];let s=new n.P;mr(g,_,Y[t+e],s),X[L]=i.getClosestCoordinate(s,!1),n.P.distance(s,i.getCoord2D(X[L]))<=l&&(Y[L]=Y[t+e],L++)}(0,s.g)(L<Y.length+4);for(let t=0;t<L;t++)Y[t]=gr(c,Y[t]);F=e.intersectPoint(i.getStartXY(),Z,l);for(let t=0;t<F;t++)Y[L]=Z[t],X[L++]=0;F=e.intersectPoint(i.getEndXY(),Z,l);for(let t=0;t<F;t++)Y[L]=Z[t],X[L++]=1;F=i.intersectPoint(e.getStartXY(),Z,l);for(let t=0;t<F;t++)X[L]=Z[t],Y[L++]=0;F=i.intersectPoint(e.getEndXY(),Z,l);for(let t=0;t<F;t++)X[L]=Z[t],Y[L++]=1;return 0===L?0:Mn(t,e,i,Y,X,L,r,o,a,l,h,0,u)}function sr(t,e,i,s,r,o,l,h,m,u){if(Kr(i))return ir(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,0,u);let d=k(e,i);if(G(e,i,l=Math.max(l,d)))return 0;let g=[],c=[],_=(0,n.m)(n.P,4);{e.queryControlPoints(_);let t=(0,n.m)(n.P,4),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(_,4,t);let o=(0,n.m)(n.M,3),m=(0,n.m)(n.M,3),u=(0,n.m)(n.M,3),d=[0,0,0];e.queryWeights(d),or(t,d,o,m,u);let p=(0,n.m)(n.M,3);p[0].setDouble(i.getSemiMinorAxis()),p[0].sqrThis(),p[1].setDouble(i.getSemiMajorAxis()),p[1].sqrThis(),p[2].setThis(p[0]),p[2].mulThis(p[1]),p[2].negateThis();let f=ee(o,2,m,2,u,2,p,0,n.E.unit(),n.E.unit(),g,h);if(f>0){let t=0;for(let s=0;s<f;s++){let r=new n.P;e.queryCoord2D(g[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(g[t]=g[s],c.push(o),t++)}g.length=t}}let p=[0,1];for(let t=0;t<2;t++){let s=0===t?i.getStartXY():i.getEndXY(),r=Gs(e,s,n.E.unit(),!1,-1),o=new n.P;e.queryCoord2D(r,o),n.P.distance(s,o)<=l&&(g.push(r),c.push(p[t]))}for(let t=0;t<2;t++){let e=[0,3];{let s=i.getClosestCoordinate(_[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(_[e[t]],r)<=l&&(g.push(p[t]),c.push(s))}}return Mn(t,e,i,g,c,g.length,s,r,o,l,h,0,u)}function rr(t,e,i,r,o,a,l,h,m,u){let d=(0,n.m)(n.P,3);e.queryControlPoints(d);let g=(0,n.m)(n.P,3);if(i.queryControlPoints(g),Z(d,g,3)<0)return rr(t,i,e,r,a,o,l,h,m,!u);let c=k(e,i);if(e.isDegenerateToLineHelper(c)){let s=new Yn({start:e.getStartXY(),end:e.getEndXY()}),n=ir(t,i,s,r,a,o,l,h,0,!u);if(o)for(let t=0;t<n;++t){let i=s.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(i,!1)}return n}if(i.isDegenerateToLineHelper(c)){let s=new Yn({start:i.getStartXY(),end:i.getEndXY()}),n=ir(t,e,s,r,o,a,l,h,0,u);if(a)for(let t=0;t<n;++t){let e=s.getCoord2D(a[t]);a[t]=i.getClosestCoordinate(e,!1)}return n}if(G(e,i,l=Math.max(l,c)))return 0;let _=(0,n.d)(3,NaN);e.queryWeights(_);let f=(0,n.d)(3,NaN);i.queryWeights(f);let y=[1,dr(_),1],P=[1,dr(f),1],x=new n.E(0,1),v=new n.E(0,1);{let t=p.constructEmpty();Ws(d,y,new n.E(0,1),t);let e=p.constructEmpty();Ws(g,P,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(ur(d,y,t,x),ur(g,P,t,v),x.isEmpty()||v.isEmpty())return 0;Ks(d,y,x.vmin,x.vmax,d,y),Ks(g,P,v.vmin,v.vmax,g,P)}}let C=Nn(d,2,g,2,l);if(0===C)return 0;let E=[],b=[];if(-1===C){let t=(0,n.m)(n.M,3),e=(0,n.m)(n.M,3),i=(0,n.m)(n.M,3);or(d,y,t,e,i);let s=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=(0,n.m)(n.M,3);or(g,P,s,r,o);let a=[],m=[],c=te(t,2,e,2,i,2,s,2,r,2,o,2,0,n.E.unit(),n.E.unit(),a,m,h,0,u);if(c>0)for(let t=0;t<c;t++){let e=new n.P;mr(g,P,m[t],e);let i=new n.P;mr(d,y,a[t],i),n.P.distance(i,e)<=l&&(E.push(a[t]),b.push(m[t]))}}for(let t=0;t<2;t++){let e,i,r;0===t?(e=d,i=g,r=P):(e=g,i=d,r=y);for(let o=0;o<2;o++){let a=0===o?0:e.length-1,h=new n.P,m=[0],u=Zs(i,r,e[a],n.E.unit(),!1,-1,1,m);(0,s.g)(1===u),mr(i,r,m[0],h),n.P.distance(e[a],h)<=l&&(0===t?(E.push(0===a?0:1),b.push(m[0])):(b.push(0===a?0:1),E.push(m[0])))}}if(0===E.length)return 0;if(!x.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=Ut.recalculateParentT(x.vmin,x.vmax,E[t]);if(!v.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=Ut.recalculateParentT(v.vmin,v.vmax,b[t]);for(let t=0;t<E.length;++t)E[t]=gr(_,E[t]);for(let t=0;t<b.length;++t)b[t]=gr(f,b[t]);return Mn(t,e,i,E,b,E.length,r,o,a,l,h,0,u)}function nr(t,e,i,s,r,o,a,l,h,m){if(e.isLine())return We(t,i,new Yn({start:e.getStartXY(),end:e.getEndXY()}),s,o,r,a,l,0,!m);if(i.isLine())return ir(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,a,l,0,m);let u=k(e,i);if(G(e,i,a=Math.max(a,u)))return 0;let d=(0,n.m)(n.P,3);e.queryControlPoints(d);let g=(0,n.m)(n.P,3);i.queryControlPoints(g);let c=Nn(d,2,g,2,a);if(0===c)return 0;let _=[],p=[];if(-1===c){let t=(0,n.m)(n.M,3),s=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=[0,0,0];e.queryWeights(o),or(d,o,t,s,r);let h=(0,n.m)(C,3);Qe(g,h);let u=te(t,2,s,2,r,2,[h[0].x,h[1].x,h[2].x],2,[h[0].y,h[1].y,h[2].y],2,null,0,0,n.E.unit(),n.E.unit(),_,p,l,0,m);if(u>0){let t=0;for(let s=0;s<u;s++){let r=new n.P;i.queryCoord2D(p[s],r);let o=new n.P;e.queryCoord2D(_[s],o),n.P.distance(o,r)<=a&&(_[t]=_[s],p[t]=p[s],t++)}_.length=t,p.length=t}}for(let t=0;t<2;t++){let s;s=0===t?d:g;for(let r=0;r<2;r++){let o,l=0===r?0:s.length-1,h=new n.P;0===t?(o=Xe(i,s[l],n.E.unit(),!1),i.queryCoord2D(o,h)):(o=Gs(e,s[l],n.E.unit(),!1,-1),e.queryCoord2D(o,h)),n.P.distance(s[l],h)<=a&&(0===t?(_.push(0===l?0:1),p.push(o)):(p.push(0===l?0:1),_.push(o)))}}return Mn(t,e,i,_,p,_.length,s,r,o,a,l,0,m)}function or(t,e,i,s,r){let o=n.M.constructDouble(e[0]),a=n.M.constructDouble(e[1]),l=n.M.constructDouble(e[2]);i[0].setDouble(t[0].x),i[0].mulThis(o),i[1].setDouble(t[1].x),i[1].mulThis(a),i[2].setDouble(t[2].x),i[2].mulThis(l),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),s[0].setDouble(t[0].y),s[0].mulThis(o),s[1].setDouble(t[1].y),s[1].mulThis(a),s[2].setDouble(t[2].y),s[2].mulThis(l),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),r[0].setDouble(e[0]),r[1].setDouble(e[1]),r[2].setThis(r[1]),r[2].ldexpThis(1),r[2].negateThis(),r[2].addThis(r[0]),r[2].addDoubleThis(e[2]),r[1].subThis(r[0]),r[1].ldexpThis(1)}function ar(t,e,i){for(let s=0;s<3;++s)i[s].setCoordsPoint2DZ(t[s].mul(e[s]),e[s])}function lr(t,e,i,s){if(0===i)return s.assign(t[0]),e[0];if(1===i)return s.assign(t[2]),e[2];let r,o,a,l=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],h=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],m=[e[0],e[1],e[2]],u=i;if(i<=.5){let t=(0,n.ag)(l[0],l[1],u),e=(0,n.ag)(l[1],l[2],u);r=(0,n.r)(t,e,u);let i=(0,n.ag)(h[0],h[1],u),s=(0,n.ag)(h[1],h[2],u);o=(0,n.r)(i,s,u);let d=(0,n.ag)(m[0],m[1],u),g=(0,n.ag)(m[1],m[2],u);a=(0,n.ag)(d,g,u)}else{let t=(0,n.ah)(l[0],l[1],u),e=(0,n.ah)(l[1],l[2],u);r=(0,n.ah)(t,e,u);let i=(0,n.ah)(h[0],h[1],u),s=(0,n.ah)(h[1],h[2],u);o=(0,n.ah)(i,s,u);let d=(0,n.ah)(m[0],m[1],u),g=(0,n.ah)(m[1],m[2],u);a=(0,n.ah)(d,g,u)}return r/=a,o/=a,s.setCoords(r,o),fr(t,s),a}function hr(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function mr(t,e,i,s,r){if(r){if(i<0)return void J(new Yn({start:t[0],end:t[0].add(Fs(t,e,0).getUnitVector())}),i,s);if(i>1)return void J(new Yn({start:t[2],end:t[2].add(Fs(t,e,1).getUnitVector())}),i-1,s)}lr(t,e,i,s)}function ur(t,e,i,s){s.setEmpty();let r=[];r.push(new n.E(0,1));let o=.5*Math.max(i.width(),i.height());for(;r.length;){let a=r.at(-1);r.pop();let l=new p;if(Ws(t,e,a,l),l.isIntersectingW(i)){let t=Math.max(l.width(),l.height());if(i.containsW(l)||t<=o||a.width()<1e-12)s.merge(a);else{let t=a.getCenter();r.push(n.E.construct(a.vmin,t)),r.push(n.E.construct(t,a.vmax))}}}}function dr(t){return t[1]/Math.sqrt(t[0]*t[2])}function gr(t,e){let i=Math.sqrt(t[2]/t[0]);return e/(0,n.r)(i,1,e)}function cr(t,e){let i=Math.sqrt(t[0]/t[2]);return e/(0,n.r)(i,1,e)}function _r(t,e,i,o){(0,s.g)(e>=0&&e<=1),(new r.k).setCoordsPoint3D(t[0]),(new r.k).setCoordsPoint3D(t[1]),(new r.k).setCoordsPoint3D(t[2]);let a=new r.k,l=new r.k,h=new r.k;(0,n.aj)(3,t[0],t[1],e,a),(0,n.aj)(3,t[1],t[2],e,l),(0,n.aj)(3,a,l,e,h);let m=t[2].clone();i&&(i[0].assign(t[0]),i[1].assign(a),i[2].assign(h)),o&&(o[0].assign(h),o[1].assign(l),o[2].assign(m))}function pr(t,e,i,r){let o=[t[0],t[1],t[2]];(0,s.g)(e>=0&&e<=1&&i!==r);let a=(0,n.r)(o[0],o[1],e),l=(0,n.r)(o[1],o[2],e),h=(0,n.r)(a,l,e);i&&(i[0]=o[0],i[1]=a,i[2]=h),r&&(r[0]=h,r[1]=l,r[2]=o[2])}function fr(t,e){let i=n.E.constructEmpty();i.vmin=i.vmax=t[0].x,i.mergeNeCoordinate(t[1].x),i.mergeNeCoordinate(t[2].x),e.x=(0,n.s)(e.x,i.vmin,i.vmax),i.vmin=i.vmax=t[0].y,i.mergeNeCoordinate(t[1].y),i.mergeNeCoordinate(t[2].y),e.y=(0,n.s)(e.y,i.vmin,i.vmax)}function yr(t,e){let i=new n.E;i.vmin=i.vmax=t[0].x,i.mergeNeCoordinate(t[1].x),i.mergeNeCoordinate(t[2].x),e[0].x=(0,n.s)(e[0].x,i.vmin,i.vmax),e[1].x=(0,n.s)(e[1].x,i.vmin,i.vmax),e[2].x=(0,n.s)(e[2].x,i.vmin,i.vmax),i.vmin=i.vmax=t[0].y,i.mergeNeCoordinate(t[1].y),i.mergeNeCoordinate(t[2].y),e[0].y=(0,n.s)(e[0].y,i.vmin,i.vmax),e[1].y=(0,n.s)(e[1].y,i.vmin,i.vmax),e[2].y=(0,n.s)(e[2].y,i.vmin,i.vmax)}const Pr=n.aC/180,xr=180/n.aC;function vr(t){let e=t;return e=function(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=(0,n.p)(e,360),e<0&&(e+=360),e)}(e),e>180&&(e-=360),e}function Cr(t){return t*Pr}function Er(t){return t*xr}function br(t){let e=(0,n.av)(),i=t;return i>=-e&&i<2*e?(i<0&&(i+=e),i>=e&&(i-=e),i):(i=(0,n.p)(i,e),i<0&&(i+=e),i)}function Dr(t){let e=(0,n.ak)(),i=t;return i>-e&&i<=e||(i=br(i),i>e&&(i-=(0,n.av)())),i}function wr(t,e){return vr(e-t)}var Sr=r.V;class Ar extends Q{static type=s.G.enumEllipticArc;m_semiMajorAxis;m_minorMajorRatio;m_rotation;m_cosr;m_sinr;m_center;m_sweepAngle;m_startAngle;m_interior;m_bits;m_cachedValues;constructor(t){if(void 0===t||(0,n.af)(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 n.P(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new n.P(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new n.P(0,0),this.m_interior=new n.P(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 n.P(0,0),this.m_interior=new n.P(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 n.P(0,0),this.m_interior=new n.P(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 At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,i=!1){return this.constructEllipse(t,1,e,0,i),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,i=!1){let s=n.P.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,s,1,0,!0,i,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,i=!1){let s=n.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(s,t,i),this}constructLineEllipticArc(t,e){return Qr(this,t,e,1),this}constructLineCircularArc(t,e){return Qr(this,t,e,0),this}constructEllipse(t,e,i,s,r=!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);let o=new n.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(s),l=Math.sin(s);return o.rotateDirect(a,l),o.addThis(i),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,s,!0,r,i),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){let t=new a.T;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{let t=new a.T;this.canonicToWorldTransformation(t);let i=t.clone();i.invertPreciseThis(),i.scale(e,e),i.multiply(t),this.applyTransformation(i)}}constructEnclosingCircle(t,e,i=!1){return function(t,e,i,r){0===i&&(0,s.a)("construct_enclosing_circle");let o=[0,0,0],a=function(t,e,i){let s=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&u(t,e)}(e,s),function(t,e,i,s){let r=0,o=[0,0,0],a=0,l=0;for(let h=0;h<3;++h){let m=!1;for(;l<i;){let i=t.at(e[l]),u=1;if(3===r?u=n.P.inCircleRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]),i):2===r?u=n.P.inCircleRobust3Point(t.at(s[0]),t.at(s[1]),i):1===r&&i.equals(t.at(s[0]))&&(u=0),u<=0){if(u<0&&h+1<3){e[a]=(0,n.c)(e[l],e[l]=e[a]);for(let t=0;t<r;t++)if(s[t]===e[l]){o[t]=l;break}a++}l++;continue}m=!0;let d=0;for(let t=0;t<r;t++)o[t]>l&&(s[d]=s[t],o[d]=o[t],d++);r=d,s[r]=e[l],o[r]=l,r++,r<3?l=a:(1===n.P.orientationRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]))&&(s[2]=(0,n.c)(s[0],s[0]=s[2]),o[2]=(0,n.c)(o[0],o[0]=o[2])),l++)}if(!m)break;if(h+1<3){a=0;let i=!1;for(let t=0;t<r;t++)for(let e=t+1;e<r;e++)o[t]>o[e]&&(o[e]=(0,n.c)(o[t],o[t]=o[e]),s[e]=(0,n.c)(s[t],s[t]=s[e]),i=!0);for(let t=0;t<r;t++)e[o[t]]=(0,n.c)(e[t],e[t]=e[o[t]]),o[t]=t;i&&3===r&&1===n.P.orientationRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]))&&(s[2]=(0,n.c)(s[0],s[0]=s[2]),o[2]=(0,n.c)(o[0],o[0]=o[2]))}l=r}return r}(t,s,e,i)}(e,i,o);if(1===a)t.constructCircleRadius(0,e[o[0]],r);else if(2===a){let i=n.P.lerp(e[o[0]],e[o[1]],.5),s=n.P.distance(e[o[0]],i),a=n.P.distance(e[o[1]],i);t.constructCircleRadius(Math.max(s,a),i,r)}else if(3===a){let i=n.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),s=n.P.distance(e[o[0]],i),a=n.P.distance(e[o[1]],i),l=n.P.distance(e[o[2]],i);t.constructCircleRadius(Math.max(s,a,l),i,r)}else(0,s.d)("unexpected")}(this,t,e,i),this}constructThreePointCircle(t,e,i,s=!1){if(!t.equals(e)&&!e.equals(i)&&!t.equals(i)){let r=n.P.calculateCircleCenterFromThreePoints(t,e,i);if(!r.isFinite()||!Number.isFinite(n.P.distance(t,r))){let s=n.P.distance(t,e),r=n.P.distance(t,i);this.constructLineCircularArc(t,s>=r?e:i)}return this.constructCircleCenterAndPoint(r,t,s)}{let r=t.clone(),n=e.clone(),o=i.clone();return r.equals(n)&&n.assign(o),this.constructTwoPointCircle(r,n,s)}}constructCircularArcThreePoint(t,e,i){let s=new n.Z(t.x),r=new n.Z(e.x),o=new n.Z(i.x),a=new n.Z(t.y),l=new n.Z(e.y),h=new n.Z(i.y),m=new n.Z(.5),u=r.subE(s),d=l.subE(a),g=o.subE(s),c=h.subE(a),_=u.mulE(c).subThisE(d.mulE(g));if(_.scaleError(10),_.isZero()){if(!u.isZero()||!d.isZero())return Qr(this,t,e,0),this;{let s=t.clone().addThis(e).mulThis(.5).addThis(i).mulThis(.5),r=i.sub(s).length();this.constructEllipticArcEndPointsCenter(t,e,r,1,0,!0,!1,s),this.m_interior.assign(i)}return this.setProjectionBehavior(0),this}let p=u.sqr().addThisE(d.sqr()).mulThisE(m),f=g.sqr().addThisE(c.sqr()).mulThisE(m),y=p.mulE(c).subThisE(f.mulE(d)),P=u.mulE(f).subThisE(g.mulE(p));y.divThisE(_),P.divThisE(_);let x=y.sqr().addThisE(P.sqr());x.sqrtThis();let v=y.addE(s),C=P.addE(a),E=t.x-v.value(),b=t.y-C.value(),D=Math.atan2(b,E);E=e.x-v.value(),b=e.y-C.value();let w=Math.atan2(b,E);E=i.x-v.value(),b=i.y-C.value();let S=Math.atan2(b,E),A=S-2*(0,n.ak)();for(;A<D;)A+=2*(0,n.ak)();let T=w-2*(0,n.ak)();for(;T<A;)T+=2*(0,n.ak)();let I=S+2*(0,n.ak)();for(;I>D;)I-=2*(0,n.ak)();let M,q=w+2*(0,n.ak)();for(;q>I;)q-=2*(0,n.ak)();M=T-D<D-q?T-D:q-D;let N=new n.P(v.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,x.value(),1,0,Math.abs(M)>(0,n.ak)(),M>0,N),this.m_interior.assign(i),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,i,s){return this.constructEllipticArcGeneral(t,1,e,i,s,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,i,s,r,n,o){return Or(this,t,e,i,s,r,n,o)}constructEllipticArcEndPointsCenter(t,e,i,s,r,n,o,a){return Or(this,t,e,i,s,r,n,o,a)}constructEllipticArcGeneral(t,e,i,s,r,o){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);let a=Dr(o),l=Math.cos(a),h=Math.sin(a),m=new n.P(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=n.P.getNAN(),d=Dr(s);u.x=m.x*Math.cos(d),u.y=m.y*Math.sin(d),u.rotateDirect(l,h),u.addThis(i);let g=(0,n.au)(r,(0,n.av)()),c=g;Math.abs(c)===(0,n.av)()&&(c=0);let _=n.P.getNAN();return _.x=m.x*Math.cos(d+c),_.y=m.y*Math.sin(d+c),_.rotateDirect(l,h),_.addThis(i),this.constructEllipticArcEndPointsCenter(u,_,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(g)>(0,n.ak)(),g>0,i)}constructEllipticArcAsNURB(t,e,i,r){return(r>=1||r<0)&&(0,s.a)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,s.a)("construct_elliptic_arc_as_NURB: control_point"),gn([t,e,i],r*r,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,fn(this),this.afterCompletedModification(),t!==this&&V(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;let e=this.getEndXY().sub(this.getStartXY()).length();return!(this.calculateLength2D()-e>t)}isDegenerateToLine(){return Kr(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){let 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 n.P.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!on(this)}isMajor(){return ln(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return s.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);let e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e);for(let s=Sr.getComponentCount(i);e<s;e++){let e=this.queryInterval(i,0);t.setIntervalEnvelope(i,0,e)}}}else 2===t.m_EnvelopeType?vn(this,n.E.unit(),t):(0,s.t)("3d not impl")}applyTransformation(t){tn(this,t,!1,null,null)}createInstance(){return new Ar}calculateLength2D(){return function(t){if(Kr(t))return 1*n.P.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(-1*t.getSweepAngle())*t.m_semiMajorAxis;let e=Jr(t,0);return Jr(t,1)-e}(this)}queryControlPointsHelper(t){(0,s.d)("")}queryCoord2D(t,e){if(Kr(this))$(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(n.P.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(n.P.construct(this.m_XEnd,this.m_YEnd));else{let i=Zr(this,t),s=new n.P(this.m_semiMajorAxis*Math.cos(i),this.getSemiMinorAxis()*Math.sin(i));s.rotateDirect(this.m_cosr,this.m_sinr),s.addThis(this.m_center),e.assign(s)}}queryCoord2DE(t,e){!function(t,e,i){if(Kr(t))it(new Yn({start:t.getStartXY(),end:t.getEndXY()}),e,i);else if(0===e.value())i.set(t.getStartXY());else if(1===e.value())i.set(t.getEndXY());else{let s=new n.Z;Hr(t,e,s);let r=new n.Z,o=new n.Z;n.Z.st_cosAndSin(s,r,o);let a=x.constructCoordsE(new n.Z(t.m_semiMajorAxis).mulThisE(r),new n.Z(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),l=new n.Z(t.m_rotation);n.Z.st_cosAndSin(l,r,o),a.rotateDirect(r,o),a.addThisE(x.constructPoint2D(t.m_center)),i.setE(a)}}(this,t,e)}queryCoord2DMP(t,e){(0,s.t)("")}getCoordX(t){let e=new n.P;return this.queryCoord2D(t,e),e.x}getCoordY(t){let e=new n.P;return this.queryCoord2D(t,e),e.y}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createEllipticArc();s&&r.dropAllAttributes();let o=0===t&&1===e;if(o&&!s)return void this.copyTo(r);let a=n.P.getNAN();this.queryCoord2D(t,a);let l=n.P.getNAN();if(this.queryCoord2D(e,l),!o)if(a.equals(l))e-t>.5&&this.isMajor()&&this.isClosed()?(o=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&a.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&l.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),o=0===t&&1===e,o&&!s)return void this.copyTo(r);if(r.m_center.assign(this.m_center),r.m_semiMajorAxis=this.m_semiMajorAxis,r.m_minorMajorRatio=this.m_minorMajorRatio,r.m_interior.assign(this.m_interior),r.m_rotation=this.m_rotation,r.m_cosr=this.m_cosr,r.m_sinr=this.m_sinr,r.m_sweepAngle=this.m_sweepAngle,r.m_startAngle=this.m_startAngle,r.m_bits=this.m_bits,M(r,a.x,a.y),N(r,l.x,l.y),o)return void sn(r,Wr(this));r.m_startAngle=Zr(this,t),r.m_sweepAngle=Zr(this,e)-r.m_startAngle,r.m_startAngle=zr(r.m_startAngle),an(r,Math.abs(r.m_sweepAngle)>(0,n.ak)()),s&&r.assignVertexDescription(this.m_description),fn(r),kr(r);let h=this.m_description.getAttributeCount();if(h>1&&!s){for(let e=1;e<h;e++){let i=this.m_description.getSemantics(e),s=Sr.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<h;t++){let i=this.m_description.getSemantics(t),s=Sr.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}r.afterCompletedModification()}queryDerivative(t,e){!function(t,e,i){if(Kr(t))i.setE(x.constructPoint2D(t.getEndXY()).subE(x.constructPoint2D(t.getStartXY())));else{let s=new n.Z;Hr(t,e,s);let r=new x;if(r.setCoordsE(new n.Z(t.m_semiMajorAxis).negate().mulE((new n.Z).setSin(s)),new n.Z(t.getSemiMinorAxis()).mulE((new n.Z).setCos(s))),t.m_rotation){let e=new n.Z(t.m_rotation);r.rotateDirect((new n.Z).setCos(e),(new n.Z).setSin(e))}r.scaleThis(new n.Z(t.getSweepAngle())),i.setE(r)}}(this,t,e)}cutArcIgnoreAttributes(t,e,i){let s=0===t&&1===e,r=new n.P;this.queryCoord2D(t,r);let o=new n.P;this.queryCoord2D(e,o),s||(r.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(s=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&r.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),s=0===t&&1===e)),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,M(i,r.x,r.y),N(i,o.x,o.y),s?sn(i,Wr(this)):(i.m_startAngle=Zr(this,t),i.m_sweepAngle=Zr(this,e)-i.m_startAngle,i.m_startAngle=zr(i.m_startAngle),an(i,Math.abs(i.m_sweepAngle)>Math.PI),fn(i),i.afterCompletedModification())}changeEndPoints2D(t,e){Ur(this,t,e,!1)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,i);if(1===t)return this.getEndAttributeAsDbl(e,i);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=Sr.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(o,a,l,r,Sr.getDefaultValue(e))}getClosestCoordinate(t,e){return Cn(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,i=-1){return Cn(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,s.a)("");let i=this.getSemiAxes(),r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),o=r+(0,n.ak)(),a=(0,n.d)(3,NaN),l=0;if(a[0]=Gr(this,r),a[0]>0&&a[0]<1&&l++,a[1]=Gr(this,o),a[1]>0&&a[1]<1&&(a[l]=a[1],l++),0===l)return 0;a[l]=1,l++,(0,s.g)(t.length>=l);let h=0;for(let i=0;i<l;i++){let s=a[i];this.queryCut(h,s,t[i],e),h=s}return l}getMonotonicParts(t,e){if(t.length<4&&(0,s.a)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;let i=this.getSemiAxes(),r=(0,n.d)(4,NaN);r[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r[1]=r[0]+(0,n.ak)(),r[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),r[3]=r[2]+(0,n.ak)();let o=(0,n.d)(5,NaN),a=0;for(let t=0;t<4;t++)o[a]=Gr(this,r[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,n.ai)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,s.g)(t.length>=a);let l=0;for(let i=0;i<a;i++){let s=o[i];this.queryCut(l,s,t[i],e),l=s}return a}intersectionWithAxis2D(t,e,i,s){if(Kr(this))return new Yn({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,i,s);let r,o,a=new n.Z(e),l=this.getSemiAxes();if(t){if(e>this.m_center.y+l.x||e<this.m_center.y-l.x)return 0;r=new n.Z(l.x).mulThis(this.m_sinr),o=new n.Z(l.y).mulThis(this.m_cosr),a.subThis(this.m_center.y)}else{if(e>this.m_center.x+l.x||e<this.m_center.x-l.x)return 0;r=new n.Z(l.x).mulThis(this.m_cosr),o=new n.Z(l.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}let h=r.sqr(),m=o.sqr(),u=h.addE(m),d=o.mulE(a).mulThis(-2),g=a.sqr().subThisE(h),c=d.sqr().subThisE(u.mulE(g).mulThis(4)),_=r.mulE(a).mulThis(-2),p=a.sqr().subThisE(m),f=_.sqr().subThisE(u.mulE(p).mulThis(4)),y=c.eps()*Math.abs(f.value())<=f.eps()*Math.abs(c.value());y?r.isZero()&&(y=!1):o.isZero()&&(y=!0),y||(d.setE(_),g.setE(p));let P=(0,n.m)(n.Z,2),x=Lt(u,d,g,n.E.construct(-1,1),!1,P);if(0===x)return 0;let v=[0,0],C=0;for(let t=0;t<x;t++){let e=new n.Z,i=new n.Z;y?(e.setE(P[t]),i.setE(a.subE(o.mulE(P[t])).divThisE(r))):(i.setE(P[t]),e.setE(a.subE(r.mulE(P[t])).divThisE(o)));let s=Gr(this,Math.atan2(e.value(),i.value()));s>=0&&s<=1&&(v[C]=s,C++)}return x=C,0===x?0:(2===x&&v[0]>v[1]&&(v[1]=(0,n.c)(v[0],v[0]=v[1])),s&&(0,n.b)(s,v,0,0,x),i&&(i[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),x>1&&(i[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!s&&i[0]>i[1]&&(i[1]=(0,n.c)(i[0],i[0]=i[1])))),x)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0];return-1===this.intersectionWithAxis2D(!0,t,i,null)?e:i[0]}isCurve(){return!0}isDegenerate(t){return w(this,t)}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new n.E(0,1),t):(0,s.t)("3d not impl")}clone(t){let e=new Ar;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Kr(this))return 0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.construct(this.getStartY(),this.getEndY());let t,i=this.getSemiAxes();t=0===e?Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr):Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr);let s=t+Math.PI,r=[0,0];r[0]=Gr(this,t),r[1]=Gr(this,s);let o=0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.construct(this.getStartY(),this.getEndY()),a=new n.P;for(let t=0;t<2;t++){let i=r[t];i>0&&i<1&&(this.queryCoord2D(i,a),o.mergeNeCoordinate(0===e?a.x:a.y))}return o}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=new n.E(0,1);if(i.intersect(t),i.isEmpty())return void e.setEmpty();if(Kr(this))return e.setCoords(this.getCoord2D(i.vmin)),void e.mergeNe(this.getCoord2D(i.vmax));let s=this.getCoord2D(i.vmin),r=this.getCoord2D(i.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*i.width()<=n.l){let t=n.P.lerp(s,r,.5),i=t.sub(this.m_center);return i.normalize(),t=t.add(i.mul(.5*n.P.distance(s,r))),e.setCoords(s),e.mergeNe(r),void e.mergeNe(t)}vn(this,i,e)}tToLength(t){return Kr(this)?t*n.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Jr(this,t)}parametricAngleToT(t){return Gr(this,t)}tToParametricAngle(t){return Zr(this,t)}lengthToT(t){if(Kr(this)){let e=n.P.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){let e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return function(t,e){if(Kr(t)){let i=n.P.distance(t.getStartXY(),t.getEndXY());return 0===i?0:e/i}if(1===t.m_minorMajorRatio){let i=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===i?0:e/i}if(0===e)return 0;let i=t.getSweepAngle();if(0===i)return.5;let s=jr(t),r=(0,n.an)(),o=$r(t);i<0&&(e=-e);let a=e/t.m_semiMajorAxis+o,l=(0,n.ax)(a,s.e2,s.completeE);return l-=r,l-=t.getStartAngle(),l/i}(this,t)}calculateWeightedAreaCentroid2D(t){if(Kr(this)){let t=new n.P;return t.setCoords(0,0),t}let e=pn(this),i=this.getStartXY().sub(this.m_center),s=this.getEndXY().sub(this.m_center),r=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,l=new n.P;l.x=r*o*(r*this.m_cosr*(-Math.sin(a)+Math.sin(this.m_startAngle))+o*(-Math.cos(a)+Math.cos(this.m_startAngle))*this.m_sinr)/3,l.y=r*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+r*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;let h=s.add(i).mul(s.crossProduct(i)/6);return l.x-=h.x,l.y-=h.y,l.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){let t=new n.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Kr(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,i=this.m_startAngle+this.m_sweepAngle;if(i<e){let t=e;e=i,i=t}let s=Math.sin(e),r=Math.sin(i),o=Math.cos(e),a=Math.cos(i);if(1===this.m_minorMajorRatio){let e=this.getSemiMajorAxis(),i=e*e,n=i*(r-s),l=i*(o-a);t.setCoords(n,l)}else{let e=this.getSemiMajorAxis(),i=this.getSemiMinorAxis(),n=e*e,l=i*i,h=e*i,m=n-l,u=m/l,d=m/n,g=Math.sqrt(u),c=Math.sqrt(d),_=.5*h*(Math.asinh(g*r)/g+r*Math.sqrt(1+u*r*r))-.5*h*(Math.asinh(g*s)/g+s*Math.sqrt(1+u*s*s)),p=-.5*h*(Math.asin(c*a)/c+a*Math.sqrt(1-d*a*a))- -.5*h*(Math.asin(c*o)/c+o*Math.sqrt(1-d*o*o));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,i){if(i&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Kr(this)){let i=n.P.distance(t,this.m_center),s=this.getSemiAxes();if(i<s.x-e||i>s.y+e)return!1}let s=this.getClosestCoordinate(t,!1),r=new n.P;return this.queryCoord2D(s,r),n.P.distance(r,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}getTangent(t){if(Kr(this))return this.getEndXY().sub(this.getStartXY());{let e=Zr(this,t),i=new n.P;return i.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&i.rotateDirect(this.m_cosr,this.m_sinr),i.scale(this.getSweepAngle()),i}}getDerivative(t){if(Kr(this))return this.getEndXY().sub(this.getStartXY());{let e=Zr(this,t),i=new n.P;return i.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&i.rotateDirect(this.m_cosr,this.m_sinr),i.scale(this.getSweepAngle()),i}}normalizeAfterEndpointChange(){return!!hn(this)&&(Kr(this)?(mn(this),!1):un(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){let e=new n.P(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){let e=new n.P(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){let e=Zr(this,t),i=new n.P,s=this.getSemiMinorAxis();i.setCoords(-this.m_semiMajorAxis*Math.sin(e),s*Math.cos(e));let r=new n.P;r.setCoords(-this.m_semiMajorAxis*Math.cos(e),-s*Math.sin(e)),this.m_rotation&&(i.rotateDirect(this.m_cosr,this.m_sinr),r.rotateDirect(this.m_cosr,this.m_sinr));let o=i.sqrLength();if(0===o)return NaN;let a=Math.sqrt(o);return i.divThis(a),i.crossProduct(r)/o}getMonotonicPartParams(t,e){let i=(0,n.d)(6,NaN);i[0]=0;let r=1;if(this.isDegenerateToLine())i[1]=1,r=2;else{let t=this.getSemiAxes(),e=(0,n.d)(4,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]=(0,n.al)());for(let t=0;t<4;t++){let s=Gr(this,e[t]);s>0&&s<1&&(i[r]=s,r++)}r>2&&(0,n.ai)(i,r),i[r]=1,r++}if(e){t<r&&(0,s.a)("");for(let t=0;t<r;t++)e[t]=i[t]}return r}calculateLowerLength2D(){let t=n.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;let e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){let t=n.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;let 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=(0,n.c)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.c)(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]=(0,n.c)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle+=this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Kr(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,rn(t)}calculateArea2DHelper(){return pn(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)),Kr(this))return;let i=this.getSemiAxes(),s=(0,n.d)(8,NaN);{let t=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),e=t+Math.PI,r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),n=r+Math.PI;s[0]=Gr(this,t),s[1]=Gr(this,e),s[2]=Gr(this,r),s[3]=Gr(this,n)}{let t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,r=Math.atan2(-i.y*t,i.x*e),n=r+Math.PI,o=Math.atan2(i.y*e,i.x*t),a=o+Math.PI;s[4]=Gr(this,r),s[5]=Gr(this,n),s[6]=Gr(this,o),s[7]=Gr(this,a)}let r=n.P.getNAN();for(let i=0;i<8;i++){let n=s[i];t.containsExclusiveCoordinate(n)&&(this.queryCoord2D(n,r),e.mergeNe(r))}}setSegmentFromCoordsForStitcher(t,e){!function(t,e,i){let s=0===t.projectionBehavior();if(i<=2)return void Qr(t,e[0],e[i-1],+!s);if(s){t.constructCircularArcThreePoint(e[0],e[i-1],e[Math.trunc(i/2)]);let s=new n.P;return t.queryCoord2D(.5,s),void t.m_interior.setCoordsPoint2D(s)}let r=t.getSemiMajorAxis(),o=t.getMinorMajorRatio(),a=t.getAxisXRotation(),l=t.getCenter(),h=[,,,,];h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];let m=[,,,,];m[0]=t.isClockwise(),m[1]=m[0],m[2]=!m[0],m[3]=!m[0];let u=Math.trunc(i<5?1:(i+4)/5),d=(0,n.m)(Ar,4),g=(0,n.d)(4,NaN),c=0;for(let t=0;t<4;t++){d[t].constructEllipticArcEndPointsCenter(e[0],e[i-1],r,o,a,h[t],m[t],l),g[t]=0;let s=0;for(let r=u;r<i-1;r+=u){let i=d[t].getClosestCoordinate(e[r],!1);g[t]+=n.P.sqrDistance(d[t].getCoord2D(i),e[r]),s++}g[t]/=s,g[t]<g[c]&&(c=t)}t.assignCopy(d[c])}(this,t,e)}writeInBufferStream(t,e){let i=new Float64Array(10);return i[0]=this.m_bits,i[1]=this.m_semiMajorAxis,i[2]=this.m_minorMajorRatio,i[3]=this.m_rotation,i[4]=this.m_center.x,i[5]=this.m_center.y,i[6]=this.m_sweepAngle,i[7]=this.m_startAngle,i[8]=this.m_interior.x,i[9]=this.m_interior.y,t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(10);t.queryRange(e,i.length,i,!0,1),this.m_bits=i[0],this.m_semiMajorAxis=i[1],this.m_minorMajorRatio=i[2],this.m_rotation=i[3],this.m_center.x=i[4],this.m_center.y=i[5],this.m_sweepAngle=i[6],this.m_startAngle=i[7],this.m_interior.x=i[8],this.m_interior.y=i[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(0,s.d)("should not1; be called"),0}ensureXYMonotone(){if(Kr(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return Qr(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;let t=(0,n.m)(n.P,3),e=dn(this,t);if(Os(t)){let i=!1;if(0===this.projectionBehavior()){let s=new o.Envelope2D;s.setCoords({pt:t[0]}),s.mergeNe(t[2]);let r=new n.P;r.setSub(t[2],t[0]),r.leftPerpendicularThis(),r.normalize(),r.scale(n.P.distance(t[2],t[0]));let a=n.P.lerp(t[2],t[0],.5),l=a.sub(r),h=a.add(r);s.clipLine(l,h);let m=n.P.getClosestCoordinate(l,h,t[1],!1);t[1]=n.P.lerp(l,h,m);let u=t[2].sub(t[1]),d=t[0].sub(t[1]),g=u.crossProduct(d),c=u.dotProduct(d);e=(0,n.an)()-Math.abs(.5*Math.atan2(g,c)),i=!0}return gn(t,e*e,null,i,this),!0}return!1}setCoordsForIntersector(t,e,i){Ur(this,t,e,i)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){let 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,sn(e,Wr(this))}reverseImpl(){nn(this,!on(this)),kr(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&fn(this)}equalsImpl(t){let e=t;if(this.m_bits!==e.m_bits||this.m_semiMajorAxis!==e.m_semiMajorAxis||this.m_minorMajorRatio!==e.m_minorMajorRatio||!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN())||this.m_rotation!==e.m_rotation||!this.m_interior.equals(e.m_interior))return!1;let i=e.m_sweepAngle;if(this.m_sweepAngle!==i)return!1;let s=e.m_startAngle;return this.m_startAngle===s}equalsImplTol(t,e){let i=t;if(this.m_bits!==i.m_bits)return!1;if(this.m_center.isNAN()&&i.m_center.isNAN())return!0;if(this.m_center.isNAN()!==i.m_center.isNAN()||!this.getSemiAxes().isEqualPoint2D(i.getSemiAxes(),e)||!this.m_center.isEqualPoint2D(i.m_center,e))return!1;let s=Math.abs(Cr(vr(Er(this.m_rotation-i.m_rotation)))),r=Math.abs((0,n.ak)()-s),o=Math.min(s,r);if(this.m_semiMajorAxis*Math.abs(o)>e)return!1;let a=this.getCoord2D(.5),l=i.getCoord2D(.5);return!!a.isEqualPoint2D(l,e)}swapImpl(t){let e=t;this.m_center=(0,n.c)(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=(0,n.c)(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,n.c)(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,n.c)(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=(0,n.c)(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=(0,n.c)(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=(0,n.c)(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=(0,n.c)(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,n.c)(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=(0,n.c)(e.m_bits,e.m_bits=this.m_bits),function(t,e){e.m_cachedValues=(0,n.c)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){mn(this),rn(this)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){if(e.length<2&&(0,s.r)(""),Kr(this))return new Yn({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,i);{let e=n.P.distance(t,this.m_center);if(e>this.m_semiMajorAxis+i||e<this.getSemiMinorAxis()-i)return 0}let r=this.getClosestCoordinate(t,!1),o=n.P.getNAN();return this.queryCoord2D(r,o),n.P.distance(o,t)<=i?(0,n.ab)(r,0,1)&&(this.queryCoord2D(+(0===r),o),n.P.distance(o,t)<=i)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=r),1):0}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}endPointModified(){this.m_bits|=8,rn(this)}clearEndPointModified(){mn(this)}}function Tr(t,e,i,s,r,o){return new qr(0,0,0,null,!1,(0,n.i)()).densifyEx(t,e,i,s,!1,o)}function Ir(t,e,i,r,o,a,l,h){a&&(a.length=0),l&&(l.length=0);let m=t.getGeometryType();if(m===s.G.enumLine)return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(n.P.getNAN()),a.push(t.getEndXY())),l&&(l.push(0),l.push(1)),1;if(m===s.G.enumBezier){if(!r)return a&&(a.push(t.getStartXY()),a.push(t.getControlPoint1()),a.push(t.getControlPoint2()),a.push(t.getEndXY())),l&&(l.push(0),l.push(1)),1;let e=(0,n.d)(9,NaN),s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Nr(t,i,e),2===s&&o&&(e[1]=.5,e.push(1),s=3),l&&l.splice(0,0,...e.slice(0,s)),a){let i=new Xn;for(let r=1;r<s;r++){let s=e[r-1],n=e[r];t.queryCut(s,n,i,!0);let o=i.get();Gi(o),1===r&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getControlPoint2()),a.push(o.getEndXY())}}return s-1}if(m===s.G.enumEllipticArc){let h=t;if(h.isDegenerateToLine()||h.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(n.P.getNAN()),a.push(t.getEndXY())),l&&(l.push(0),l.push(1)),1;if(r&&(o||!h.isMonotoneQuickAndDirty())){let m=(0,n.d)(6,NaN),u=h.getMonotonicPartParams(m.length,m);m.length=u,u=Nr(t,i,m),2===u&&o&&(m[1]=.5,m.push(1),u=3);let d=0;if(u>2){let t=new Xn,n=l||[],o=0;for(let g=1;g<u;g++){let c=m[o],_=m[g];if(h.queryCut(c,_,t,!0),t.get().isDegenerate(0))continue;let p=n.length,f=Rr(1===g,t.get(),e,i,r,a,l);(0,s.g)(f>0),d+=f;let y=g===u-1,P=m[o],x=t.get().getSweepAngle()/h.getSweepAngle();for(let t=p,e=n.length;t<e;t++)if(n[t]=!y||t+1<e?P+n[t]*x:1,a){let e=3*t,i=h.getCoord2D(n[t]);a[e].setCoordsPoint2D(i),e>0&&Zi(a.slice(e-3))}o=g}return d}}return Rr(!0,h,e,i,r,a,l)}if(m===s.G.enumRationalBezier2){let s=t;if(r&&(o||!s.isMonotoneQuickAndDirty())){let r=(0,n.d)(6,NaN),h=s.getMonotonicPartParams(r.length,r);r.length=h,h=Nr(t,i,r),2===h&&o&&(r[1]=.5,r.push(1),h=3);let m=0;if(h>2){let t=new Xn,n=l||[];for(let o=1;o<h;o++){let u=r[o-1],d=r[o];s.queryCut(u,d,t,!0);let g=n.length;m+=Yr(1===o,t.get(),e,i,!1,a,l);let c=o===h-1,_=r[o-1];for(let t=g,e=n.length;t<e;t++)if(n[t]=!c||t+1<e?_+n[t]:1,a){let e=3*t,i=s.getCoord2D(n[t]);a[e].setCoordsPoint2D(i),e>0&&Be(a.slice(e-3))}}return m}}return Yr(!0,s,e,i,r,a,l)}if(m===s.G.enumBezier2){let s=t,h=(0,n.m)(n.P,3);s.queryControlPoints(h);let m=new vs;m.constructFromQuadratic(h);let u=Ir(m,e,i,r,o,a,l);if(null!=a&&null!=l)for(let t=1,e=0;t<u;++t,e+=3){let i=new n.P;s.queryCoord2D(l[t],i);let o=a[e+3];i.equals(o)||(a[e+3].setCoordsPoint2D(i),r&&Zi(a.slice(e,e+4)))}return u}(0,s.t)("")}function Mr(t,e,i,r,o,a,l,h,m){let u=t.getGeometryType();if(a&&(a.length=0,l.length=0),h&&(h.length=0),u===s.G.enumEllipticArc){let e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(t.getEndXY()),l.push(NaN),l.push(NaN),l.push(NaN)),h&&(h.push(0),h.push(1)),1}let d,g=(0,n.d)(9,NaN);if(o)d=t.getMonotonicPartParams(g.length,g),g.length=d,d=Nr(t,i,g);else{if(d=2,g[0]=0,g[1]=1,u===Ar.type){let e=t.getSweepAngle();e>.9*Math.PI&&(Math.min(3,Math.trunc(e/(2*Math.PI/3)+.5))>2?(g[0]=0,g[1]=1/3,g[2]=2/3,g[3]=1,d=4):(g[0]=0,g[1]=.5,g[2]=1,d=3))}else(0,s.g)(u===Ut.type);g.length=d}if(2===d&&r&&(g[1]=.5,g.push(1),d=3),a){let e=new Xn,i=1;for(;i<d;){let r=g[i-1],h=g[i];t.queryCut(r,h,e,!0);let m=(0,n.m)(n.P,3),c=[1,1,1];if(u===s.G.enumEllipticArc){let t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){let t=(h-r)/3;g.splice(i,0,r+t),g.splice(i+1,0,r+2*t),d+=2;continue}c[1]=dn(t,m)}else{let t=e.get();t.queryControlPoints(m),t.queryWeights(c)}o&&Os(m),1===i&&(a.push(m[0].clone()),l.push(c[0])),a.push(m[1].clone()),a.push(m[2].clone()),l.push(c[1]),l.push(c[2]),i++}}return h&&(h.length=d,(0,n.b)(h,g,0,0,d)),d-1}class qr{m_maxLength;m_maxDeviation;m_maxAngle;m_cosMaxAngle;m_minStep;m_maxSegmentsPerCurve;m_segmentBuffer=null;m_dummyPoint=new r.P;m_progressTracker;m_progressCounter=0;m_bSetDensifyFlag;m_bOnlyCurveDensify;static constructDefault(t){return new qr(0,0,0,t,!1,(0,n.i)())}constructor(t,e,i,r,o,a){this.m_progressTracker=r,this.m_bSetDensifyFlag=o,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=i>(0,n.an)()?(0,n.an)():i,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=a,(0,s.D)(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,i,r,o,a){return this.m_maxLength=e,this.m_maxDeviation=i,this.m_maxAngle=r>(0,n.an)()?(0,n.an)():r,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,s.D)(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;let e=t.getGeometryType();return(0,s.k)(e)?t:(0,s.j)(e)?this.densifyMultiPath(t):(0,s.h)(e)?this.densifySegmentImpl(t):e===s.G.enumEnvelope?this.densifyEnvelope(t):void(0,s.d)("")}densifySegmentEx(t,e,i,r,n){let o=t.getGeometryType();if(!(this.m_maxLength>0)&&(!this.m_bOnlyCurveDensify||o===s.G.enumLine)&&(!r||i))return void(e?o===s.G.enumLine?e.addSegment(t,i):(i&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(i&&n.push(0),n.push(1)));if(o===s.G.enumBezier)return void this.densifyCubicBezier(t,e,i,r,n);if(o===s.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,i,r,n);if(o===s.G.enumBezier2)return void this.densifyBezier2(t,e,i,r,n);if(o===s.G.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,i,r,n);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,i,r,n)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}let e=t.createInstance();e.getGeometryType()===s.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());let i=t.getImpl().querySegmentIterator();for(;i.nextPath();){let t=!0;for(;i.hasNextSegment();){let s=i.nextSegment(),r=i.isClosingSegment();this.densifySegmentEx(s,e,t,r,null),r&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){let e=new Dt({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){let e=new ni({vd:t.getDescription()});e.addEnvelope(t,!1);let i=o.Envelope2D.constructEmpty();t.queryEnvelope(i);let s=i.width(),r=i.height();return!(this.m_maxLength>0)||s<=this.m_maxLength&&r<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;let e=t.createInstance();e.getGeometryType()===s.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());let i=e.getImpl(),r=t.getImpl(),o=r.getAttributeStreamRef(0),a=new Yn;for(let t=0,s=r.getPathCount();t<s;t++){let s=r.isClosedPath(t);if(0===r.getPathSize(t))continue;let l=r.getPathStart(t),h=o.readPoint2D(2*l),m=h.clone();i.startPath(h);for(let s=l+1,h=r.getPathEnd(t);s<h;s++){let t=o.readPoint2D(2*s),r=n.P.distance(m,t);if(r>this.m_maxLength){let e=Math.ceil(r/this.m_maxLength);e>(0,n.i)()&&(e=(0,n.i)());let s,o,l,h=1/e;m.compare(t)<0?(a.setStartXY(m),a.setEndXY(t),s=0,o=1):(a.setStartXY(t),a.setEndXY(m),s=e-2,o=-1);for(let t=0,r=e-1;t<r;t++,s+=o){this.progress_(),l=h*(s+1);let t=new n.P;a.queryCoord2D(l,t),i.lineTo(t),this.m_bSetDensifyFlag&&i.setAttributeNoCurves(10,i.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),m.assign(t)}if(s){let t=n.P.distance(m,h);if(t>this.m_maxLength){let e=h,s=Math.ceil(t/this.m_maxLength);s>(0,n.i)()&&(s=(0,n.i)());let r,o,l=1/s;m.compare(e)<0?(a.setStartXY(m),a.setEndXY(e),r=0,o=1):(a.setStartXY(e),a.setEndXY(m),r=s-2,o=-1);let u,d=new n.P(0,0);for(let t=0,e=s-1;t<e;t++,r+=o)this.progress_(),u=l*(r+1),a.queryCoord2D(u,d),i.lineTo(d),this.m_bSetDensifyFlag&&i.setAttributeNoCurves(10,i.getPointCount()-1,0,1)}i.closePathWithLine()}}return e}densifySegmentByLength(t,e,i,r,o,a){(0,s.g)(t.getGeometryType()!==s.G.enumBezier);let l=t.getStartXY().compare(t.getEndXY());0===l&&e<1&&(t.getGeometryType()===s.G.enumEllipticArc?l=t.getSweepAngle()<0?1:-1:(0,s.t)("densify segment by length"));let h=0;if(r&&(i?(t.queryStart(this.m_dummyPoint),i.startPathPoint(this.m_dummyPoint)):a.push(0),++h),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||=new Xn;let s=Math.ceil(1/e);s>(0,n.i)()&&(s=(0,n.i)()),e=1/s,this.m_segmentBuffer.create(t.getGeometryType());let r,o,m=t;l<0?(r=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),r=s-2,o=-1,m=this.m_segmentBuffer.get());let u,d=s-1;for(let t=0;t<d;t++,r+=o)u=e*(r+1),i?(m.queryCoord(u,this.m_dummyPoint),i.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==u&&0!==u&&i.setAttribute(10,i.getPointCount()-1,0,1)):a.push(l>0?1-u:u),this.progress_();u=1,h+=d}(!o||o&&r&&h<2)&&(i?(t.queryEnd(this.m_dummyPoint),i.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,i,s,r){let o=new vs,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());if(0===h&&l>0){let e=(0,n.m)(n.P,4);t.queryControlPoints(e),h=e[1].compare(e[2]),0===h&&(h=e[1].compare(e[0]))}h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=[],d=[],g=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=!0,_=0;if(h>0)for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),d.push(0);u.length;){this.progress_();let t=u.at(-1),o=d.at(-1),l=t[4].x,h=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){c&&=(_=a.findMinDeriv(),!1);let e=.5*(l+h);Math.abs(_-e)<.4*(h-l)&&(e=_);let i=(e-l)/(h-l),s=t[0].mul(1-i).add(t[1].mul(i)),r=t[1].mul(1-i).add(t[2].mul(i)),m=t[2].mul(1-i).add(t[3].mul(i)),g=s.mul(1-i).add(r.mul(i)),p=r.mul(1-i).add(m.mul(i)),f=g.mul(1-i).add(p.mul(i)),y=t[3];t[1]=s,t[2]=g,t[3]=f,t[4].setCoords(l,e);let P=[f,p,m,y,new n.P(e,h)];u.push(P),d[d.length-1]=o+1,d.push(o+1);continue}u.pop(),d.pop(),(u.length>0||!s||s&&i&&m<2)&&(e?(a.queryCoord(l,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==l&&0!==l&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(1-l),++m)}else for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),d.push(0);u.length;){this.progress_();let t=u.at(-1),o=d.at(-1),l=t[4].x,h=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){c&&=(_=a.findMinDeriv(),!1);let e=.5*(l+h);Math.abs(_-e)<.4*(h-l)&&(e=_);let i=(e-l)/(h-l),s=t[0].mul(1-i).add(t[1].mul(i)),r=t[1].mul(1-i).add(t[2].mul(i)),m=t[2].mul(1-i).add(t[3].mul(i)),g=s.mul(1-i).add(r.mul(i)),p=r.mul(1-i).add(m.mul(i)),f=g.mul(1-i).add(p.mul(i)),y=t[0];t[0]=f,t[1]=p,t[2]=m,t[4].setCoords(e,h);let P=[y,s,g,f,new n.P(l,e)];u.push(P),d[d.length-1]=o+1,d.push(o+1);continue}u.pop(),d.pop(),(u.length>0||!s||s&&i&&m<2)&&(e?(a.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)):r.push(h),++m)}}densifyRationalBezier2(t,e,i,s,r){let o=new Ut,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=0),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),d=new Ut,g=[],c=[];for(g.push(new n.E(0,1)),c.push(0);g.length;){this.progress_();let t=g.at(-1).clone(),o=c.at(-1);if(o<u&&this.rationalBezier2NeedsSplit(a,d,t.vmin,t.vmax)){let e=t.getCenter();h>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),c[c.length-1]=o+1,c.push(o+1);continue}if(g.pop(),c.pop(),g.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}densifyBezier2(t,e,i,s,r){let o=new Qt,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=0),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),d=new Qt,g=[],c=[];for(g.push(new n.E(0,1)),c.push(0);g.length;){this.progress_();let t=g.at(-1).clone(),o=c.at(-1);if(o<u&&this.bezier2NeedsSplit(a,d,t.vmin,t.vmax)){let e=t.getCenter();h>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),c[c.length-1]=o+1,c.push(o+1);continue}if(g.pop(),c.pop(),g.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}densifyEllipticArc(t,e,i,s,r){let o=new Ar,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=+!t.isClockwise()),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),d=new Ar,g=[],c=[];for(g.push(new n.E(0,1)),c.push(0);g.length;){this.progress_();let t=g.at(-1).clone(),o=c.at(-1);if(o<u&&this.ellipticArcNeedsSplit(a,d,t.vmin,t.vmax)){let e=t.getCenter();h>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),c[c.length-1]=o+1,c.push(o+1);continue}if(g.pop(),c.pop(),g.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}calculateLengthSubdivisionStep(t,e){let i=t.calculateUpperLength2D();if(!t.isCurve())return i?e/i:1;if(t.getGeometryType()===s.G.enumEllipticArc){let s=t;if(s.isCircular()||s.isDegenerate(0)||s.isDegenerateToLine()){let t=e/i;return t<this.m_minStep&&(t=this.m_minStep),t}return e/i*s.getSemiAxes().y/s.getSemiAxes().x}t.getGeometryType()===s.G.enumBezier&&(0,s.t)(""),(0,s.t)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===s.G.enumEllipticArc){let i=t;if(i.isDegenerate(0)||i.isDegenerateToLine())return 1;{let s=i.getSemiMajorAxis(),r=1-e/s,n=Math.PI/2;if(r>0){let t=4*Math.sqrt(e/s*.5);n=Math.min(Math.PI/2,Math.abs(t))}n=Math.max(n,2*Math.PI/this.m_maxSegmentsPerCurve);let o=n*s;return this.calculateLengthSubdivisionStep(t,o)}}(0,s.t)("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===s.G.enumEllipticArc){let i=t;return i.isDegenerate(0)||i.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*i.getSemiMinorAxis())}(0,s.t)("")}rationalBezier2NeedsSplit(t,e,i,s){t.cutBezierIgnoreAttributes(i,s,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;let o=(0,n.m)(n.P,3);e.queryControlPoints(o);let a=[0,0,0];return e.queryWeights(a),!r&&this.m_maxDeviation>0&&(r=!qr.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!qr.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),r}bezier2NeedsSplit(t,e,i,s){t.cutBezierIgnoreAttributes(i,s,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;let o=(0,n.m)(n.P,3);return e.queryControlPoints(o),!r&&this.m_maxDeviation>0&&(r=!qr.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!qr.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),r}ellipticArcNeedsSplit(t,e,i,s){t.cutArcIgnoreAttributes(i,s,e);let r=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(r=!0,!0):(!r&&this.m_maxDeviation>0&&(r=!qr.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!qr.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),r)}bezierNeedsSplit(t){let e=!1;return this.m_maxLength>0&&n.P.distance(t[0],t[1])+n.P.distance(t[1],t[2])+n.P.distance(t[2],t[3])>this.m_maxLength?(e=!0,!0):(!e&&this.m_maxDeviation>0&&(e=!qr.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!qr.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){let i=t[3].sub(t[0]);if(i.sqrLength()>0){let s=i.clone();s.leftPerpendicularThis(),s.normalize();let r=s.dotProduct(t[0].sub(t[1])),o=s.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(r),Math.abs(o))<=e){let e=new n.P;Ui(t,.5,e,!1);let s=e.sub(t[0]).dotProduct(i);return s>=0&&s<=i.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]));let i=t[3].sub(t[0]);i.normalize();{let s=t[1].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}{let s=t[2].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}{let s=t[2].sub(t[1]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,i){if(0===e[1])return!1;let s=t[2].sub(t[0]);if(s.sqrLength()>0){let e=s.clone();e.leftPerpendicularThis(),e.normalize();let r=e.dotProduct(t[0].sub(t[1]));if(Math.abs(r)<=i){let e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=i*i}static checkRationalBezier2MaxAngle(t,e,i){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);let s=t[2].sub(t[0]);s.normalize();{let e=t[1].sub(t[0]),r=e.dotProduct(s);if(r<0||e.length()*i>r)return!1}return!0}static checkBezier2MaxDeviation(t,e){let i=t[2].sub(t[0]);if(i.sqrLength()>0){let s=i.clone();s.leftPerpendicularThis(),s.normalize();let r=s.dotProduct(t[0].sub(t[1]));if(Math.abs(r)<=e){let e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.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]);let i=t[2].sub(t[0]);i.normalize();{let s=t[1].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){let i=t.getEndXY().sub(t.getStartXY()),r=[0,0];if(1===function(t,e,i){(0,s.g)(!Kr(t));let r=new a.T;r.setRotateAngle(-t.getAxisXRotation());let o=new n.P;r.queryTransform(e,o);let l=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),h=l+(0,n.ak)(),m=Gr(t,l),u=Gr(t,h);u<m&&(u=(0,n.c)(m,m=u));let d=0;return m>=0&&m<=1&&(i[d++]=m),u>=0&&u<=1&&(i[d++]=u),d}(t,i,r)){let i=t.getCoord2D(r[0]),s=n.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),i),o=new n.P;return(0,n.J)(t.getStartXY(),t.getEndXY(),s,o),n.P.distance(i,o)<=e}}let i=t.getCoord2D(.5),r=new n.P;return(0,n.J)(t.getEndXY(),t.getStartXY(),.5,r),n.P.distance(i,r)<=e}static checkEllipticArcMaxAngle(t,e){let i=t.getTangent(0),s=t.getTangent(1),r=i.dotProduct(s);return!(r<0||i.length()*s.length()*e>r)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==s.G.enumEllipticArc||t.isCircular())}}function Nr(t,e,i){let s=i.length;if(e<=0||s<=2)return s;let r=0,o=(0,n.d)(s-1,NaN);for(let e=1,n=s;e<n;e++){let s=t.tToLength(i[e]);o[e-1]=s-r,r=s}for(;o.length>1;){let t=o.findIndex(t=>t<=2*e);if(-1===t)break;let s=t+1,r=t+1;if(t>0){let e=t-1;(r===o.length||o[e]>o[r])&&(r=e,s--)}o[r]+=o[t],o.splice(t,1),i.splice(s,1)}return i.length}function Rr(t,e,i,s,r,l,h,m){let u=e.clone();u.dropAllAttributes();let d=(t,e,i,s)=>(e&&(t&&e.push(s.getStartXY()),e.push(n.P.getNAN()),e.push(n.P.getNAN()),e.push(s.getEndXY())),i&&(t&&i.push(0),i.push(1)),1);if(u.isDegenerateToLine()||u.isDegenerate(0))return d(t,l,h,e);let g=u.getStartXY(),c=u.getEndXY(),_=u.getSemiAxes(),p=new a.T;if(u.isCircular())p.setIdentity();else{let t=u.getAxisXRotation();p.setScaleCoords(1,u.getMinorMajorRatio()),p.rotateAngle(t)}let f=u.getCenter();p.shift(f);let y=p.clone();y.invertThis(),u.applyTransformation(y);let P=u.getSweepAngle();if(0===P)return d(t,l,h,e);let x=o.Envelope2D.constructEmpty();x.setCoords({center:f,width:2*_.x,height:2*_.x});let v=.05*x.calculateToleranceFromEnvelope(),C=4*(Math.max(i/_.x,v/_.x)/.0741)**(1/6);C=Math.min(C,Math.PI/2);let E=br(u.getStartAngle()),b=P>0?Math.floor(E/C):Math.ceil(E/C);b*=C;let D=P>0?C:-C;b+D===E&&(b+=D);let w=4/3*Math.tan(Math.abs(C)/4);P>0&&(w=-w),h&&t&&h.push(0);let S=C/Math.abs(P),A=(b-E)/P,T=g.clone(),I=new n.P;u.queryCoord2D(0,I);let M=I.clone(),q=1-.01*S,N=0,R=0;for(;A<1;){let i;if(A+=S,R>0&&A<q)i=w;else{A>=q&&(A=1);let t=(A-R)*P;i=4/3*Math.tan(Math.abs(t)/4),P>0&&(i=-i)}u.queryCoord2D(A,I);let o=new n.P;p.queryTransform(I,o);let a=e.getClosestCoordinate(o,!1);if(e.queryCoord2D(a,o),1!==A&&(n.P.distance(T,o)<=2*s||n.P.distance(o,c)<=2*s))continue;T.setCoordsPoint2D(o);let m=(0,n.m)(n.P,4);m[0].assign(M),m[3].assign(I),m[1].rightPerpendicularOther(M),m[1].scaleAddThis(i,M),m[2].leftPerpendicularOther(I),m[2].scaleAddThis(i,I),p.transformPoints2D(m,3,m),m[3].assign(o),0===R&&m[0].setCoordsPoint2D(g),1===A&&m[3].setCoordsPoint2D(c),r&&Zi(m);let d=!0;for(let t=1;t<4;t++)if(!m[t].isEqualPoint2D(m[0])){d=!1;break}d||(h&&h.push(a),l&&(0===R&&t&&l.push(m[0].clone()),l.push(m[1].clone()),l.push(m[2].clone()),l.push(m[3].clone())),N++),R=A,M.setCoordsPoint2D(I)}return N}function Yr(t,e,i,s,r,a,l,h){e.clone().dropAllAttributes();let m=new o.Envelope2D;e.queryLooseEnvelope(m);let u=.05*m.calculateToleranceFromEnvelope(),d=Math.max(i,u);l&&t&&l.push(0);let g=0,c=(0,n.m)(n.P,3);e.queryControlPoints(c);let _=[0,0,0];e.queryWeights(_);let p=[],f=(0,n.d)(9,NaN),y=0;r?(y=e.getMonotonicPartParams(f.length,f),f.length=y,y=Nr(e,s,f)):(f.length=2,y=2,f[0]=0,f[1]=1);let P=0,x=t;for(let t=1;t<y;t++){let e=f[t];for(p.length=0,p.push(e),p.push(P);p.length>1;){let t=p.at(-1);p.pop();let e=p.at(-1),i=(0,n.m)(n.P,3),s=[0,0,0];Ks(c,_,t,e,i,s);let r=(0,n.m)(n.P,4),o=Js(i,s,r),h=p.length>16;d>=o||h?(l.push(e),a&&(x&&=(a.push(r[0]),!1),a.push(r[1]),a.push(r[2]),a.push(r[3])),g++):(p.push(.5*(t+e)),p.push(t))}P=e}return g}class Xr{m_arc;m_sqrChordLength;constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?n.P.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function Fr(t,e){return t.convertToCanonic(e)}function Lr(t,e,i,s){let r=t.m_startAngle,o=t.m_sweepAngle,a=1e-12;for(;r>(0,n.ak)();)r-=2*(0,n.ak)();for(;r<=-(0,n.ak)();)r+=2*(0,n.ak)();if(!Number.isNaN(e)){for(;e>(0,n.ak)();)e-=2*(0,n.ak)();for(;e<=-(0,n.ak)();)e+=2*(0,n.ak)();!i&&e>r&&(e-=2*(0,n.ak)()),i&&e<r&&(e+=2*(0,n.ak)()),o=e-r,Math.abs(o)<a&&!s&&(o=i?2*(0,n.ak)():-2*(0,n.ak)()),Math.abs(o)>2*(0,n.ak)()-a&&s&&(o=0)}Math.abs(o)>2*(0,n.ak)()-a&&(o=o>=0?2*(0,n.ak)():-2*(0,n.ak)(),t.setEndXY(t.getStartXY())),Math.abs(o)<a&&(o=0,t.setEndXY(t.getStartXY())),s=Math.abs(o)<=(0,n.ak)(),o&&(i=o>0),t.m_startAngle=zr(r),t.m_sweepAngle=o,an(t,!s),nn(t,i)}function zr(t){let e=t,i=!1;return e<=-(0,n.ak)()?(e+=(0,n.av)(),i=!0):e>(0,n.ak)()&&(e-=(0,n.av)(),i=!0),e<=-(0,n.ak)()?(e=(0,n.p)(e,(0,n.av)()),e<=-(0,n.ak)()&&(e+=(0,n.av)()),i=!0):e>(0,n.ak)()&&(e=(0,n.p)(e,(0,n.av)()),e>(0,n.ak)()&&(e-=(0,n.av)()),i=!0),i&&(e>(0,n.ak)()||e<=-(0,n.ak)())&&(e=(0,n.ak)()),e}function Vr(t,e,i){let s=i,r=s.getSemiAxes(),o=new n.P(r.x*Math.cos(t[0]),r.y*Math.sin(t[0]));return o=s.convertFromCanonic(o),n.P.sqrDistance(o,s.getStartXY())}function Br(t,e,i){let s=i,r=s.getSemiAxes(),o=t[0]+s.getStartAngle(),a=new n.P(r.x*Math.cos(o),r.y*Math.sin(o));return a=s.convertFromCanonic(a),n.P.sqrDistance(a,s.getEndXY())}function kr(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);let e=t.getStartXY(),i=t.getEndXY(),s=e.equals(i),r=ln(t),o=on(t),a=t.projectionBehavior();if(s){let i=t.convertToCanonic(e),s=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=s.x,i.y/=s.y,t.m_startAngle=zr(Math.atan2(i.y,i.x)),t.m_sweepAngle=r?o?(0,n.av)():-(0,n.av)():0}else{let s=t.convertToCanonic(e),l=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=l.x,s.y/=l.y;let h=t.convertToCanonic(i);h.x/=l.x,h.y/=l.y,t.m_startAngle=Math.atan2(s.y,s.x),t.m_sweepAngle=n.P.calculateAngle(s,h),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,n.av)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,n.av)()),t.m_startAngle=zr(t.m_startAngle);let m=Vr([t.m_startAngle],0,t);if(m=Math.sqrt(m),m>.25*B(t)){let e=t.m_startAngle-1e-4,i=t.m_startAngle+1e-4,s=[0];Nt(Vr,t,1,[t.m_startAngle],[e],[i],0,s),t.m_startAngle=zr(s[0])}if(m=Br([t.m_sweepAngle],0,t),m=Math.sqrt(m),m>.25*B(t)){let e=t.m_sweepAngle-1e-4,i=t.m_sweepAngle+1e-4,s=[0];Nt(Br,t,1,[t.m_sweepAngle],[e],[i],0,s),t.m_sweepAngle=s[0]}let u=Math.abs(t.m_sweepAngle)>(0,n.ak)();if(an(t,u),r!==u&&!r&&Math.abs(t.m_sweepAngle)>1.5*(0,n.ak)())return void Qr(t,e,i,a);if(0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void Qr(t,e,i,a)}}function Gr(t,e){return(function(t,e){let i=new n.E(t.getStartAngle(),t.getEndAngle());i.normalize();let s=(0,n.av)(),r=(0,n.p)(e,s);if(r<i.vmin){let t=r+s;for(;t<i.vmin;)t+=s;return i.containsCoordinate(t)?t:i.vmin-r<t-i.vmax?r:t}if(r>i.vmax){let t=r-s;for(;t>i.vmax;)t-=s;return i.containsCoordinate(t)||i.vmin-t<r-i.vmax?t:r}return r}(t,e)-t.getStartAngle())/t.getSweepAngle()}function Zr(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Hr(t,e,i){i.assign(new n.Z(t.m_startAngle).addE(e.mulE(new n.Z(t.m_sweepAngle))))}function Wr(t){return t.m_cachedValues}function jr(t){if(t.m_cachedValues)return t.m_cachedValues;let e={e2:0,completeE:0};return e.e2=function(t){return 1-(0,n.a)(t.m_minorMajorRatio)}(t),e.completeE=(0,n.aB)(e.e2),t.m_cachedValues=e,e}function Ur(t,e,i,s){if(!e.isEqual(t.m_XStart,t.m_YStart)||!i.isEqual(t.m_XEnd,t.m_YEnd)){if(Kr(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,fn(t),void t.afterCompletedModification();if(s&&Math.abs(t.getSweepAngle())<=1.01*(0,n.an)()){let s=(0,n.m)(n.P,3),r=dn(t,s);if(js(s)){if(s[0].assign(e),s[2].assign(i),Os(s),0!==t.projectionBehavior())gn(s,r*r,null,!1,t);else{let e=0,i=2;n.P.sqrDistance(s[1],s[0])<n.P.sqrDistance(s[1],s[2])&&(i=(0,n.c)(e,e=i));let r=s[i].sub(s[e]),o=r.length();r.divThis(o);let a=s[1].sub(s[e]),l=a.length(),h=a.dotProduct(r)/l,m=a.crossProduct(r)/l,u=new n.P;(0,n.J)(s[e],s[i],.5,u);let d=.5*o/m*(0,n.s)(1-h,0,1),g=s[1].side(s[e],s[i]),c=r.clone();g?c.leftPerpendicularThis():c.rightPerpendicularThis();let _=u.sub(c.mul(d));t.constructCircularArcThreePoint(s[0],s[2],_)}return}}0===t.projectionBehavior()?function(t,e,i){let s=t.getStartXY(),r=t.getEndXY(),o=s.equals(r),l=e.equals(i);if(!o&&!l){let o=new a.T;o.setShiftCoords(-t.m_XStart,-t.m_YStart);let l=n.P.distance(e,i),h=n.P.distance(s,r),m=l/h;o.scale(m,m);let u=r.sub(s);u.divThis(h);let d=i.sub(e);d.divThis(l);let g=u.crossProduct(d),c=d.dotProduct(u);return o.rotate(c,g),o.shiftCoords(e.x,e.y),void tn(t,o,!0,e,i)}let h=new n.P;if(t.queryCoord2D(.5,h),l){if(o){let r=t.m_center.add(e.sub(s));t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),r),t.setProjectionBehavior(0)}else if(t.isMajor()){let s=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,i,s)}else t.constructCircularArcThreePoint(e,i,e);return}let m=e.add(i).mul(.5),u=i.sub(e);u.rightPerpendicularThis();let d=m.add(u),g=n.P.getClosestCoordinate(m,d,t.getCenter(),!0),c=new n.P;(0,n.J)(m,d,g,c);let _=n.P.distance(e,c);t.constructEllipticArcEndPointsCenter(e,i,_,1,0,!0,!t.isClockwise(),c),t.setProjectionBehavior(0)}(t,e,i):bn(t,e,i)}}function Or(t,e,i,s,r,n,o,a,l){return t.m_bits=0,t.m_rotation=n,I(t,e),q(t,i),t.m_cosr=Math.cos(n),t.m_sinr=Math.sin(n),an(t,o),nn(t,a),void 0===l?t.m_center.setNAN():t.m_center.assign(l),t.setProjectionBehavior(1),t.m_semiMajorAxis=s,t.m_minorMajorRatio=r,un(t,void 0===l)}function Qr(t,e,i,s){t.m_bits=0,t.m_rotation=0,I(t,e),q(t,i),t.m_interior.assign(e.add(i).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,an(t,!1),nn(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(s),t.afterCompletedModification()}function Kr(t){return t.m_center.isNAN()}function Jr(t,e){if(0===e)return 0;let i=jr(t),s=Zr(t,e),r=(0,n.an)(),o=$r(t),a=(0,n.aw)(s+r,i.e2,i.completeE),l=t.m_semiMajorAxis*(a-o);return Math.abs(l)}function $r(t){let e=jr(t);return(0,n.aw)(t.getStartAngle()+(0,n.an)(),e.e2,e.completeE)}function tn(t,e,i,r,o){if(2===e.m_TransformationType)return void(0,s.g)(0);if((0,s.g)(!hn(t)),e.isIdentity()&&(!r||r.equals(t.getStartXY())&&o.equals(t.getEndXY())))return;rn(t);let a=n.P.getNAN(),l=n.P.getNAN();if(null===r?(a.x=t.m_XStart,a.y=t.m_YStart,e.transformInPlace(a),l.x=t.m_XEnd,l.y=t.m_YEnd,e.transformInPlace(l)):(a=r,l=o),Kr(t))return t.m_XStart=a.x,t.m_YStart=a.y,t.m_XEnd=l.x,void(t.m_YEnd=l.y);let h=t.m_center.clone();if(e.transformInPlace(h),i||e.isUniformNoRotation()){let i=on(t);if(e.isReflective()&&(i=!i),0===t.projectionBehavior()){if(!a.equals(l)){let i=t.m_interior.clone();return e.transformInPlace(i),void t.constructCircularArcThreePoint(a,l,i)}return void en(t,a,l,h,i,!1)}let s=new n.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(s);let r=Math.atan2(s.y,s.x),o=t.getSemiAxes();e.transformWithoutTranslateInPlace(o);let m=t.m_center.clone();return e.transformInPlace(m),void t.constructEllipticArcEndPointsCenter(a,l,o.x,o.y/o.x,r,t.isMajor(),i,m)}{{let i=[,,,,];!function(t,e){let i=new n.Z(t.m_cosr).sqrThis(),s=new n.Z(t.m_sinr).sqrThis(),r=new n.Z(t.m_minorMajorRatio),o=new n.Z(1/t.m_minorMajorRatio),a=r.mulE(i).addThisE(o.mulE(s)),l=r.subE(o).mulThis(2*t.m_cosr*t.m_sinr),h=r.mulE(s).addThisE(o.mulE(i));e[0]=a,e[1]=l,e[2]=h,e[3]=new n.Z(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,i);let s=new v;if(s.a11.setE(i[0]),s.a12.setE(i[1]),s.a12.mulThisByPower2(.5),s.a21.setE(s.a12),s.a22.setE(i[2]),!s.det().isZero()){let r=new v;if(r.a11.set(e.xx),r.a12.set(e.xy),r.a21.set(e.yx),r.a22.set(e.yy),r.invertThis()){let o=r.clone();o.transposeThis();let m=s.clone();if(m.mulThis(r),m.mulLeftThis(o),!m.det().isZero()){let s=(0,n.m)(n.Z,4);s[0].setE(m.a11),s[1].setE(m.a12),s[1].mulThisByPower2(2),s[2].setE(m.a22),s[3].setE(i[3]);let r=n.P.getNAN(),o=function(t,e){let i=new v;i.a11.setE(t[0]),i.a12=n.Z.st_mulByPower2(t[1],.5),i.a21.setE(i.a12),i.a22.setE(t[2]);let s=[n.P.getNAN(),n.P.getNAN()],r=[new n.Z,new n.Z];i.eigenSymmetric(r,s);let o=t[3].clone();return o.negateThis(),o.invThis(),r[0].mulThisE(o),r[1].mulThisE(o),r[0].sqrtThis().invThis(),r[1].sqrtThis().invThis(),e.x=r[0].toDouble(),e.y=r[1].toDouble(),Math.atan2(s[0].y,s[0].x)}(s,r),u=on(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(a,l,r.x,r.y/r.x,o,t.isMajor(),u,h)}}}}let i=[n.P.getNAN(),n.P.getNAN(),n.P.getNAN()];i[0].setCoords(t.getSemiMajorAxis(),0),i[0].rotateDirect(t.m_cosr,t.m_sinr),i[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),i[1].rotateDirect(t.m_cosr,t.m_sinr),i[2].setCoords(0,t.getSemiMinorAxis()),i[2].rotateDirect(t.m_cosr,t.m_sinr);let s=t.isClockwise();s&&(i[2]=(0,n.c)(i[0],i[0]=i[2])),e.transformWithoutTranslateArray(i,3,i),e.isReflective()&&(s=!s);let r=new n.P(0,0),o=t.createInstance();gn(i,.5,r,!1,o),t.constructEllipticArcEndPointsCenter(a,l,o.getSemiMajorAxis(),o.getMinorMajorRatio(),o.getAxisXRotation(),t.isMajor(),!s,h)}}function en(t,e,i,s,r,n){let o=.5*(s.sub(e).length()+s.sub(i).length());t.m_center.assign(s),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x),Lr(t,Math.atan2(i.y-t.m_center.y,i.x-t.m_center.x),r,n);let a=t.constructEllipticArcEndPointsCenter(e,i,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,s);return t.setProjectionBehavior(0),a}function sn(t,e){t.m_cachedValues=e}function rn(t){t.m_cachedValues=null}function nn(t,e){let i=+!!e;t.m_bits=-2&t.m_bits|i}function on(t){return!!(1&t.m_bits)}function an(t,e){let i=+!!e;t.m_bits=-3&t.m_bits|i<<1}function ln(t){return!!(2&t.m_bits)}function hn(t){return!!(8&t.m_bits)}function mn(t){t.m_bits&=-9}function un(t,e){mn(t);let i=t.getStartXY(),r=t.getEndXY(),o=!1,a=ln(t),l=on(t),h=t.projectionBehavior(),m=i.equals(r),u=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,s.o)("NAN minor major ratio and non-zero major axis")),u||=e?m:t.m_center.isNAN(),u)return Qr(t,i,r,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);let d=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if((0,s.g)(d.y>0&&d.x>=d.y),m){let e=t.convertToCanonic(i);(0,s.g)(!d.isZero()),e.x/=d.x,e.y/=d.y;let r=Math.sqrt((0,n.a)(e.x)+(0,n.a)(e.y));if(o=1!==r,t.m_semiMajorAxis*=r,d.mulThis(r),t.m_startAngle=zr(Math.atan2(e.y,e.x)),!a)return t.m_interior.assign(i),t.m_sweepAngle=0,t.afterCompletedModification(),o;t.m_sweepAngle=l?(0,n.av)():-(0,n.av)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;let e=new x;e.setWithEps(t.getStartXY(),8),e.subThisE((new x).setWithEps(t.m_center,8));let i=new n.Z;i.setWithEps(t.m_rotation,8);let s=new n.Z,r=new n.Z;n.Z.st_cosAndSin(i,s,r),e.rotateReverse(s,r);let o=new x;o.setWithEps(t.getEndXY()),o.subThisE(x.constructPoint2D(t.m_center)),o.rotateReverse(s,r);let a=new n.Z;a.setWithEps(t.m_semiMajorAxis,8);let l=a.clone(),h=new n.Z;h.setWithEps(t.m_minorMajorRatio),l.mulThisE(h),e.x.divThisE(a),e.y.divThisE(l),o.x.divThisE(a),o.y.divThisE(l);let m=e.x.sqr().addThisE(e.y.sqr()).subThisE(n.a9),u=o.x.sqr().addThisE(o.y.sqr()).subThisE(n.a9);return!m.isZero()||!u.isZero()}(t);if(!e){let s=t.convertToCanonic(i);s.x/=d.x,s.y/=d.y;let o=new n.P(1,0);t.m_startAngle=n.P.calculateAngle(o,s);let a=t.convertToCanonic(r);a.x/=d.x,a.y/=d.y,t.m_sweepAngle=n.P.calculateAngle(s,a),e=!_n(t)}if(e){o=!0;let e=i.sub(r).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let s=(0,n.a)(e.x/d.x)+(0,n.a)(e.y/d.y);s>1&&(s=Math.sqrt(s),t.m_semiMajorAxis*=s,d.mulThis(s));let h=new n.P(0,0);{let t=d.x*d.x,i=d.y*d.y,s=t*e.y*e.y+i*e.x*e.x,r=t*i-s;if(r>0){let t=Math.sqrt(r/s);h.setCoords(d.x*e.y/d.y,-d.y*e.x/d.x),h.mulThis(t),a===l&&h.negateThis()}}{let e=new n.P(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(i.add(r).mulThis(.5)),t.m_center.assign(e)}}if(kr(t),!_n(t))return Qr(t,i,r,h),!0}return fn(t),t.afterCompletedModification(),o}function dn(t,e){(0,s.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);let i,r=t.getSemiMajorAxis(),o=t.getSemiMinorAxis();if(0===r)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),i=1,i;if(0===o)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=n.P.lerp(e[0],e[2],.5),i=1,i;let a=t.getSweepAngle(),l=t.getStartAngle(),h=l+a,m=new n.P(-r*Math.sin(l),o*Math.cos(l)),u=new n.P(-r*Math.sin(h),o*Math.cos(h));m.normalize(),u.normalize(),m.rotateDirect(t.m_cosr,t.m_sinr),u.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);let d=m.crossProduct(u);return e[1].assign(m.mul(e[1].crossProduct(u)/d)),e[1].addThis(e[0]),i=Math.cos(.5*a),i}function gn(t,e,i,r,o){if(r){let i=.5,s=Math.sqrt(e),r=(0,n.a)(.5)+2*s*i*.5+(0,n.a)(i),a=t[0].mul((0,n.a)(.5)).add(t[1].mul(2*s*i*.5)).add(t[2].mul((0,n.a)(i))).divThis(r);return o.constructCircularArcThreePoint(t[0],t[2],a),!0}let a=t[0].sub(t[1]),l=t[2].sub(t[1]),h=a.crossProduct(l),m=a.dotProduct(l),u=e;(0,s.g)(u<=1),(0,s.g)(u>0);let d=.5/(1-u),g=a.sqrLength(),c=m,_=l.sqrLength(),p=(0,n.a)(h),f=a.sub(l).sqrLength();if(0===p||m<=-Math.sqrt(g)*Math.sqrt(_))return Qr(o,t[0],t[2],1),!1;let y=[0,0],P=new n.E;P.setInfinite();let x=Mt(2*p,-(f/u+4*c),2*(1-u)/u,P,!1,y);if(0===x)return Qr(o,t[0],t[2],1),!1;1===x&&(y[1]=y[0]);let v=Math.sqrt(d/y[0]),C=Math.sqrt(d/y[1]),E=.5/u,b=E-_*y[0],D=E-g*y[0];Math.abs(b)>Math.abs(D)?D=c*y[0]-E+1:b=c*y[0]-E+1;let w=a.mul(b).add(l.mul(D)),S=w.norm(1)<1e-15*v?0:Math.atan2(w.y,w.x)+Math.PI,A=a.add(l),T=i?i.clone():t[1].add(A.mul(d)),I=t[0].sub(T),M=t[2].sub(T),q=I.crossProduct(M)<0;return new Ar,o.constructEllipticArcEndPointsCenter(t[0],t[2],v,C/v,S,!1,!q,T)}function cn(t,e,i,s,r){return gn(t,e,i,s,r)}function _n(t){let e=B(t),i=!1;{let s=new n.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center),i=n.P.distance(t.getStartXY(),s)>e}let s=!1;if(!i){let i=new n.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));i.rotateDirect(t.m_cosr,t.m_sinr),i.addThis(t.m_center),s=n.P.distance(t.getEndXY(),i)>e}return!i&&!s}function pn(t){if(Kr(t)||t.isDegenerate(0))return 0;let e=t.m_semiMajorAxis,i=t.getSemiMinorAxis(),s=e*e+i*i,r=t.getStartAngle(),n=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,l=t.m_sinr,h=1,m=0;t.m_rotation&&(h=(a-l)*(a+l),m=2*a*l);let u=((-.5*(n-r)+.25*h*(2*Math.cos(n+r)*Math.sin(n-r)))*i+-2*Math.sin(.5*(n+r))*Math.sin(.5*(n-r))*a*o)*e/s,d=0;return t.m_rotation&&(d=-2*Math.sin(n+r)*Math.sin(n-r)*.125*m-i*o/s*(2*Math.cos(.5*(n+r))*Math.sin(.5*(n-r)))*l),s*(u+d)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function fn(t){t.queryCoord2D(.5,t.m_interior)}function yn(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(D(e,i))return 1;return 0===Pn(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function Pn(t,e,i,r,o,a,l,h,m,u){if(Kr(e))return ot(new Yn({start:e.getStartXY(),end:e.getEndXY()}),i,r,o,a,l,h,u);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0);let d=k(e,i);if(G(e,i,l=Math.max(d,l)))return 0;let g=i.getStartXY();g.subThis(e.m_center);let c=i.getEndXY();c.subThis(e.m_center),g.rotateReverse(e.m_cosr,e.m_sinr),c.rotateReverse(e.m_cosr,e.m_sinr);let _=c.clone();_.subThis(g);let p=e.m_semiMajorAxis,f=1/p,y=e.getSemiMinorAxis(),P=1/y,x=_.clone();x.leftPerpendicularThis();let v=Math.atan2(y*x.y,p*x.x),C=(0,n.d)(16,NaN),E=(0,n.d)(16,NaN),b=0,D=[v,v+Math.PI];for(let t=0;t<2;++t){let s=Gr(e,D[t]);if(s>=0&&s<=1){C[b]=s;let t=e.getCoord2D(C[b]);E[b]=i.getClosestCoordinate(t,!1),n.P.distance(t,i.getCoord2D(E[b]))<=l&&b++}}let w=g.x*f,S=g.y*P,A=_.x*f,T=_.y*P,I=Mt(A*A+T*T,2*(w*A+S*T),w*w+S*S-1,n.E.unit(),!1,E);(0,s.g)(I>=0);for(let t=0;t<I;t++){let s=_.mul(E[t]).add(g);s.x*=f,s.y*=P;let r=Gr(e,Math.atan2(s.y,s.x));if(r>=0&&r<=1){C[b]=r;let t=e.getCoord2D(r);E[b]=i.getClosestCoordinate(t,!1),n.P.distance(t,i.getCoord2D(E[b]))<=l&&b++}}(0,s.g)(b<C.length+4);let M=(0,n.d)(16,NaN);I=e.intersectPoint(i.getStartXY(),M,l);for(let t=0;t<I;t++,b++)C[b]=M[t],E[b]=0;I=e.intersectPoint(i.getEndXY(),M,l);for(let t=0;t<I;t++,b++)C[b]=M[t],E[b]=1;I=i.intersectPoint(e.getStartXY(),M,l);for(let t=0;t<I;t++,b++)C[b]=0,E[b]=M[t];I=i.intersectPoint(e.getEndXY(),M,l);for(let t=0;t<I;t++,b++)C[b]=1,E[b]=M[t];return 0===b?0:Mn(t,e,i,C,E,b,r,o,a,l,h,0,u)}function xn(t,e,i,r,o,a,l,h,m,u){if(Kr(e))return Pn(t,i,new Yn({start:e.getStartXY(),end:e.getEndXY()}),r,a,o,l,h,0,!u);if(Kr(i))return Pn(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),r,o,a,l,h,0,u);let d=k(e,i);l=Math.max(l,d);let g=!1;{let t=e.getSemiAxes(),r=e.getCenter(),u=i.getSemiAxes(),d=i.getCenter(),c=n.P.distance(d,r),_=t.x+u.x;if(c>_+l)return 0;if(t.y>u.x){if(c+u.x+l<t.y)return 0}else if(u.y>t.x&&c+t.x+l<u.y)return 0;if(m&&!h){let r=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),n=1===i.m_minorMajorRatio&&i.isClosed()&&i.isMajor();if(r&&n&&(g=!0,c<=_&&Math.max(t.x,u.x)<=Math.min(t.x,u.x)+c))return(0,s.g)(!o&&!a),1}}if(!g&&G(e,i,l))return 0;let c=[],_=[],p=Mr(e,0,0,!1,!1,c,_,null),f=[],y=[],P=Mr(i,0,0,!1,!1,f,y,null);if(1===p&&1===P){let t=new Ut({points:c,weights:_}),s=new Ut({points:f,weights:y}),d=[],g=[],p=rr(!1,t,s,r,null===o?null:d,null===a?null:g,l,h,m,u);if(p>0&&null!==o||null!==a){o&&(o.length=0),a&&(a.length=0);for(let r=0;r<p;++r){if(o)if((0,n.ab)(d[r],0,1))o.push(d[r]);else{let i=t.tToLength(d[r]),s=e.lengthToT(i);o.push(s)}if(a)if((0,n.ab)(g[r],0,1))a.push(g[r]);else{let t=s.tToLength(g[r]),e=i.lengthToT(t);a.push(e)}}}return p}let x=[],v=[],C=0,E=m&&!h;for(let t=0;t<p;t++){let s=new Ut({points:c.slice(2*t,2*t+3),weights:_.slice(2*t,2*t+3)}),r=0;for(let o=0;o<P;o++){v.length<=o&&v.push(new Ut({points:f.slice(2*o,2*o+3),weights:y.slice(2*o,2*o+3)}));let a=[],h=[],m=E?null:a,u=E?null:h,d=rr(!1,s,v[o],null,m,u,l,!1,E,!1);if(d>0&&E)return 1;for(let l=0;l<d;++l){if(0===a[l]&&0===t)a[l]=0;else if(1===a[l]&&t===p-1)a[l]=1;else{let t=s.tToLength(a[l])+C,i=e.lengthToT(t);a[l]=i}if(0===h[l]&&0===o)h[l]=0;else if(1===h[l]&&o===P-1)h[l]=1;else{let t=v[o].tToLength(h[l])+r,e=i.lengthToT(t);h[l]=e}x.push((0,n.o)(a[l],h[l]))}r+=v[o].calculateLength2D()}C+=s.calculateLength2D()}if(0===x.length)return 0;if(h&&(x=x.filter(t=>!(0,n.ab)(t.first,0,1)||!(0,n.ab)(t.second,0,1)||!e.getCoord2D(t.first).equals(i.getCoord2D(t.second)))),m)return x.length;let b=[],D=[];for(let t of x)b.push(t.first),D.push(t.second);return Mn(t,e,i,b,D,b.length,r,o,a,l,h,0,u)}function vn(t,e,i){if(i.setCoords(t.getCoord2D(e.vmin)),i.mergeNe(t.getCoord2D(e.vmax)),Kr(t))return;let s=t.getSemiAxes(),r=[0,0,0,0];{let e=Math.atan2(-s.y*t.m_sinr,s.x*t.m_cosr),i=e+Math.PI,n=Math.atan2(s.y*t.m_cosr,s.x*t.m_sinr),o=n+Math.PI;r[0]=Gr(t,e),r[1]=Gr(t,i),r[2]=Gr(t,n),r[3]=Gr(t,o)}let o=new n.P;for(let s=0;s<4;s++){let n=r[s];e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,o),i.mergeNe(o))}}function Cn(t,e,i,r,o){if(0===t.m_semiMajorAxis)return i.vmin;let a=n.P.getNAN();t.queryCoord2D(i.vmin,a);let l=n.P.getNAN();if(t.queryCoord2D(i.vmax,l),Kr(t))return new Yn({start:a,end:l}).getClosestCoordinate(e,r);let h=Fr(t,e);if(a=Fr(t,a),l=Fr(t,l),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return i.vmin;let e=Gr(t,Math.atan2(h.y,h.x));return r||i.containsCoordinate(e)?e:n.P.distance(h,a)<=n.P.distance(h,l)?i.vmin:i.vmax}let m=t.getSemiMajorAxis(),u=t.getSemiMinorAxis(),d=(m-u)*(m+u),g=(0,n.a)(d),c=h.x,_=h.y,p=(0,n.a)(u*_),f=u*d*_*2,y=[new n.Z(p),new n.Z(f),new n.Z(g-(0,n.a)(m*c)-p),new n.Z(-f),new n.Z(-g)],P=(0,n.m)(n.Z,4),x=Vt(y,4,new n.E(-1,1),!1,P,4),v=i.vmin,C=n.P.sqrDistance(h,a);{let t=n.P.sqrDistance(h,l);t<C&&(v=i.vmax,C=t)}(0,s.g)(!r);let E=(0,n.d)(8,NaN);for(let e=0;e<x;++e){let i=P[e].value(),s=Math.sqrt(1-i*i),r=Math.atan2(i,s),n=Math.atan2(i,-s);E[2*e]=Gr(t,r),E[2*e+1]=Gr(t,n)}E=E.slice(0,2*x),(0,n.w)(E);for(let s=0,r=2*x;s<r;++s)if(E[s]>i.vmin&&E[s]<i.vmax){let i=n.P.sqrDistance(e,t.getCoord2D(E[s]));C>i&&(C=i,v=E[s])}return v}function En(t,e,i){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)&&(i?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise())}function bn(t,e,i,r){let o=t.getStartXY(),l=t.getEndXY(),h=o.equals(l),m=e.equals(i);if(!h&&!m){let s=new a.T;return s.initializeFromTwoPoints(o,l,e,i),tn(t,s,!0,e,i),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void Qr(t,e,i,1);if(h&&m){let s=t.m_center.add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),s)}if(!h){let s=.5*((0,n.av)()-Math.abs(t.getSweepAngle())),r=(t.getSweepAngle()+s*(0,n.e)(t.getSweepAngle()))/t.getSweepAngle(),o=new n.P;t.queryCoord2D(r,o),t.constructEllipticArcEndPointsCenter(o,o,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());let a=t.getCenter().add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),a)}let u=n.P.sqrDistance(e,i),d=.25,g=.75;if(u<n.P.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){let e=[0],i=It(new Xr(t,u),n.E.construct(0,.25),1,e);i>0&&((0,s.g)(1===i),d=e[0],g=1-e[0])}let c=t.getCoord2D(d),_=t.getCoord2D(g);(0,s.g)(!c.equals(_)),t.constructEllipticArcEndPointsCenter(c,_,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),bn(t,e,i)}function Dn(t,e,i,s,r){return wn(t,!1,e,i,s,r)}function wn(t,e,i,r,n,o){let a=i.getGeometryType(),l=r.getGeometryType(),h=Math.max(n,k(i,r));if(a===s.G.enumLine&&l===s.G.enumLine)return nt(i,r,h,o);let m=i,u=r,d=i.getStartXY(),g=i.getEndXY();if(d.compare(g)>0&&(m=i.clone().reverse()),d=r.getStartXY(),g=r.getEndXY(),d.compare(g)>0&&(u=r.clone().reverse()),e){if(i.equals(r))return 2;if(function(t,e,i){return(0,s.g)(t.isCurve()||e.isCurve()),!!(t.getStartXY().equals(e.getStartXY())&&T(t,e,0,0,i,2,[0,0],[0,0])||t.getEndXY().equals(e.getEndXY())&&T(t,e,1,1,i,2,[0,0],[0,0])||t.getStartXY().equals(e.getEndXY())&&T(t,e,0,1,i,2,[0,0],[0,0])||t.getEndXY().equals(e.getStartXY())&&T(t,e,1,0,i,2,[0,0],[0,0]))}(i,r,h))return 4}switch(a){case s.G.enumLine:switch(l){case s.G.enumEllipticArc:return yn(t,u,m,h,o);case s.G.enumBezier:return Ki(t,u,m,h,o);case s.G.enumRationalBezier2:return $s(t,u,m,h,o);case s.G.enumBezier2:return Ze(t,u,m,h,o);default:(0,s.d)("")}break;case s.G.enumEllipticArc:switch(l){case s.G.enumLine:return yn(t,m,u,h,o);case s.G.enumEllipticArc:return function(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(D(e,i))return 1;return 0===xn(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}(t,m,u,h,o);case s.G.enumBezier:return Ji(t,u,m,h,o);case s.G.enumRationalBezier2:return tr(t,u,m,h,o);case s.G.enumBezier2:return He(t,u,m,h,o);default:(0,s.d)("")}break;case s.G.enumBezier:switch(l){case s.G.enumLine:return Ki(t,m,u,h,o);case s.G.enumEllipticArc:return Ji(t,m,u,h,o);case s.G.enumBezier:return function(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(D(e,i))return 1;return 0===ss(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}(t,m,u,h,o);case s.G.enumRationalBezier2:return $i(t,m,u,h,o);case s.G.enumBezier2:return ts(t,m,u,h,o);default:(0,s.d)("")}break;case s.G.enumRationalBezier2:switch(l){case s.G.enumLine:return $s(t,m,u,h,o);case s.G.enumEllipticArc:return tr(t,m,u,h,o);case s.G.enumBezier:return $i(t,u,m,h,o);case s.G.enumRationalBezier2:return function(t,e,i,s,r){if(r){let s=Sn(e,i);if(0!==s){if(t){if(1===s){if(e.m_weights[0]===i.m_weights[0]&&e.m_weights[1]===i.m_weights[1]&&e.m_weights[2]===i.m_weights[2])return 2}else if(e.m_weights[0]===i.m_weights[2]&&e.m_weights[1]===i.m_weights[1]&&e.m_weights[2]===i.m_weights[0])return 2;return 4}return 2}}else if(D(e,i))return 1;return 0===rr(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}(t,m,u,h,o);case s.G.enumBezier2:return er(t,m,u,h,o);default:(0,s.d)("")}break;case s.G.enumBezier2:switch(l){case s.G.enumLine:return Ze(t,m,u,h,o);case s.G.enumEllipticArc:return He(t,m,u,h,o);case s.G.enumBezier:return ts(t,u,m,h,o);case s.G.enumRationalBezier2:return er(t,u,m,h,o);case s.G.enumBezier2:return function(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(D(e,i))return 1;return 0===Ue(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}(t,m,u,h,o);default:(0,s.d)("")}break;default:(0,s.d)("")}}function Sn(t,e,i=!0){if(!i&&!An(t,e))return 0;let r=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){if(r)return 1;let i=t.getGeometryType();if(i!==e.getGeometryType())return 0;if(i===s.G.enumBezier){let i=t,s=e;return i.getControlPoint1().equals(s.getControlPoint1())&&i.getControlPoint2().equals(s.getControlPoint2())?1:0}if(i===s.G.enumEllipticArc)return+!!En(t,e,!1);if(i===s.G.enumRationalBezier2){let i=t,s=e;if(i.getControlPoint1().equals(s.getControlPoint1())&&i.getStandardFormWeight()===s.getStandardFormWeight())return 1}else if(i===s.G.enumBezier2){let i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return 1}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){if(r)return-1;let i=t.getGeometryType();if(i!==e.getGeometryType())return 0;if(i===s.G.enumBezier){let i=t,s=e;return i.getControlPoint1().equals(s.getControlPoint2())&&i.getControlPoint2().equals(s.getControlPoint1())?-1:0}if(i===s.G.enumEllipticArc)return En(t,e,!0),-1;if(i===s.G.enumRationalBezier2){let i=t,s=e;if(i.getControlPoint1().equals(s.getControlPoint1())&&i.getStandardFormWeight()===s.getStandardFormWeight())return-1}else if(i===s.G.enumBezier2){let i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return-1}return 0}return 0}function An(t,e){let i=t.getGeometryType();return!(i!==e.getGeometryType()||i===s.G.enumEllipticArc&&t.projectionBehavior()!==e.projectionBehavior())}function Tn(t,e,i,r,n,o,a){!n&&o&&(0,s.a)("");let l=e.getGeometryType(),h=i.getGeometryType(),m=Math.max(a,k(e,i));if(r&&(r.length=0),n&&(n.length=0),o&&(o.length=0),l===s.G.enumLine&&h===s.G.enumLine)return ot(e,i,r,n,o,m,!1,!1);let u=e,d=i,g=e.getStartXY(),c=e.getEndXY(),_=!1,p=!1;g.compare(c)>0&&(u=e.clone(!0).reverse(),_=!0),g=i.getStartXY(),c=i.getEndXY(),g.compare(c)>0&&(d=i.clone(!0).reverse(),p=!0);let f=0;switch(l){case s.G.enumLine:switch(h){case s.G.enumEllipticArc:f=Pn(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier:f=es(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumRationalBezier2:f=ir(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier2:f=We(t,d,u,r,o,n,m,!1,0,!0);break;default:(0,s.d)("")}break;case s.G.enumEllipticArc:switch(h){case s.G.enumLine:f=Pn(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=xn(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier:f=is(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumRationalBezier2:f=sr(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier2:f=je(t,d,u,r,o,n,m,!1,0,!0);break;default:(0,s.d)("")}break;case s.G.enumRationalBezier2:switch(h){case s.G.enumLine:f=ir(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=sr(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumBezier:f=rs(t,d,u,r,o,n,m,!1,!1,!0);break;case s.G.enumRationalBezier2:f=rr(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier2:f=nr(t,u,d,r,n,o,m,!1,0,!1);break;default:(0,s.d)("")}break;case s.G.enumBezier2:switch(h){case s.G.enumLine:f=We(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=je(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumBezier:f=ns(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumRationalBezier2:f=nr(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier2:f=Ue(t,u,d,r,n,o,m,!1,!1,!1);break;default:(0,s.d)("")}break;case s.G.enumBezier:switch(h){case s.G.enumLine:f=es(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=is(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumBezier:f=ss(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumRationalBezier2:f=rs(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier2:f=ns(t,u,d,r,n,o,m,!1,0,!1);break;default:(0,s.d)("")}break;default:(0,s.d)("")}if(_){if(n){for(let t=0;t<f;t++)n[t]=1-n[t];n.reverse()}r&&r.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function In(t,e,i){return e===i?0:(e>i&&(i=(0,n.c)(e,e=i)),t.cut(e,i,!0).calculateUpperLength2D())}function Mn(t,e,i,s,r,o,a,l,h,m,u,d,g){if(!o)return 0;let c=(t,e)=>{for(let i=0;i<o;++i){let s=e[i];if((0,n.ab)(s,0,1)){s=(0,n.aF)(s);continue}let r=t.getCoord2D(s);s<.5?r.equals(t.getStartXY())&&In(t,0,s)<=B(t)&&(e[i]=0):r.equals(t.getEndXY())&&In(t,s,1)<=B(t)&&(e[i]=1)}};c(e,s),c(i,r),function(t,e,i,s,r){let o=[],a=[],l=[];for(let h=0,m=r;h<m;h++)o.push(t.calculateSubLengthFromStart(i[h])),a.push(e.calculateSubLengthFromStart(s[h])),(0,n.ab)(i[h],0,1)&&(0,n.ab)(s[h],0,1)&&t.getCoord2D(i[h]).equals(e.getCoord2D(s[h]))&&l.push(h);if(0===l.length||l.length===r)return;l.sort((t,e)=>i[t]<i[e]?-1:i[t]>i[e]?1:s[t]<s[e]?-1:+(s[t]>s[e]));let h=-1;for(let m of l){if(h>=0&&i[m]===i[h]&&i[m]===i[h]){h=m;continue}h=m;let l=[];l.length=r;for(let t=0;t<l.length;++t)l[t]=t;l.sort((t,e)=>{let i=o[m],s=a[m],r=o[t]-i,n=a[t]-s,l=r*r+n*n,h=o[e]-i,u=a[e]-s,d=h*h+u*u;return l<d?-1:+(l>d)});for(let o=0;o<r;o++){let r=l[o];if(r===m||i[r]===i[m]&&s[r]===s[m]||(0,n.ab)(i[r],0,1)&&(0,n.ab)(s[r],0,1))continue;let a=(i,s,r,o)=>{let a=new x,l=new n.Z;l.setWithEps(1);let h=new n.Z;h.set(s,l.eps()),t.queryCoord2DE(h,a);let m=new x;t.queryCoord2DE(new n.Z(i),m);let u=!1;return a.eq(m)&&(h.set(o,l.eps()),e.queryCoord2DE(h,a),e.queryCoord2DE(new n.Z(r),m),u=a.eq(m)),!u},h=n.P.getNAN();t.queryCoord2D(i[r],h);let u=n.P.getNAN();if(e.queryCoord2D(s[r],u),0===n.P.distance(h,u)&&a(i[m],i[r],s[m],s[r]))break;let d=new n.E(s[r],s[m]);d.normalizeNoNAN();let g=new n.E(i[r],i[m]);g.normalizeNoNAN();let c=-1,_=1/0,p=1/0,f=i[r];h.assign(t.getCoord2D(f));for(let o=0;o<5;o++){let o=e.getClosestCoordinateOnInterval(h,d,-1);u.assign(e.getCoord2D(o));let l=n.P.distance(h,u);if(f=t.getClosestCoordinateOnInterval(u,g,-1),f===i[m]&&o===s[m]){c=1;break}h.assign(t.getCoord2D(f));let y=n.P.distance(u,h);if(!(y<p&&l<_)){c=0;break}if(0===y&&0===l){a(i[m],i[r],s[m],s[r])?(i[r]=f,s[r]=o,c=0):c=1;break}p=y,_=l}if(-1===c&&(c=(0,n.ab)(i[r],0,1)||(0,n.ab)(s[r],0,1)?0:1),1!==c)break;i[r]=i[m],s[r]=s[m]}}}(e,i,s,r,o);let _=[];for(let t=0,e=o;t<e;t++)_.push(t);let p=(t,e)=>g?(0,n.aG)(r[t],s[t],r[e],s[e]):(0,n.aG)(s[t],r[t],s[e],r[e]);if(_.length>1){_.sort(p);let t=Math.max(B(e),B(i)),o=0;for(let a=1,l=_.length;a<l;a++){let l=s[_[o]],h=s[_[a]],m=r[_[o]],u=r[_[a]];if(l!==h||m!==u){if(In(e,l,h)<=t&&In(i,m,u)<=t&&!((0,n.ab)(l,0,1)&&(0,n.ab)(m,0,1)||(0,n.ab)(h,0,1)&&(0,n.ab)(u,0,1))){let t=n.P.distance(e.getCoord2D(l),i.getCoord2D(m)),s=n.P.distance(e.getCoord2D(h),i.getCoord2D(u));if(t<=s)continue;if(s<t){_[o]=_[a];continue}continue}o++,_[o]=_[a]}}if(_.length=o+1,1===_.length&&0!==_[0]&&(s[0]=s[_[0]],r[0]=r[_[0]],_[0]=0),_.length>2){let t=n.E.constructEmpty(),o=n.E.constructEmpty();t.setCoords(s[_[0]],s[_.at(-1)]),o.setCoords(r[_[0]],r[_.at(-1)]);let a=!0;for(let e=1,i=_.length-1;e<i;e++)if(!t.containsCoordinate(s[_[e]])||!o.containsCoordinate(r[_[e]])){a=!1;break}if(a){let s=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let r=0;r<s.length;r++){let l=(0,n.r)(t.vmin,t.vmax,s[r]),h=e.getCoord2D(l);if(!i.isCloserThanDistance(h,o,m)){a=!1;break}l=(0,n.r)(o.vmin,o.vmax,s[r]);let u=i.getCoord2D(l);if(!e.isCloserThanDistance(u,t,m)){a=!1;break}}}a&&(_[1]=_.at(-1),_.length=2)}}if(1===_.length&&t&&T(e,i,s[0],r[0],m,1,[0],[0])&&(_.push(1),s[1]=0,r[1]=0,_.sort(p)),u&&1===_.length){let t=!0;for(let o=0,a=_.length;o<a;o++)if(!(0,n.ab)(s[_[o]],0,1)||!(0,n.ab)(r[_[o]],0,1)||0!==n.P.distance(e.getCoord2D(s[_[o]]),i.getCoord2D(r[_[o]]))){t=!1;break}if(t)return 0}let f=0;for(let t=0,i=_.length;t<i;t++){if(l&&l.push(s[_[t]]),h&&h.push(r[_[t]]),a){let i=n.P.getNAN();e.queryCoord2D(s[_[t]],i),a.push(i)}f++}return f}function qn(t,e,i,s,r,o,a,l,h){if((0,n.ab)(i,0,1)&&(0,n.ab)(s,0,1)&&0===n.P.distance(t.getCoord2D(i),e.getCoord2D(s))){let m=1e-12,u=new x,d=2**-52;if(t.queryDerivative(new n.Z(i,d),u),u.isTrueZero()){let e=1===i?-1e-12:m;t.queryDerivative(new n.Z(i,d).add(e),u)}1===i&&u.negateThis();let g=new x;if(e.queryDerivative(new n.Z(s,d),g),g.isTrueZero()){let t=1===i?-1e-12:m;e.queryDerivative(new n.Z(s,d).add(t),g)}1===s&&g.negateThis(),u.isZero()||u.normalize(),g.isZero()||g.normalize();let c=u.dotProduct(g),_=u.crossProduct(g);if(_.scaleError(3),c.ge(n.T)&&(_.isZero()||Math.abs(_.value())<(()=>{if(h)return.001;{let i=t.calculateUpperLength2D(),s=e.calculateUpperLength2D();return Math.min(.01*r/Math.min(i,s),1e-10)}})()))return A(t,e,i,s,r,o,a,l)}return 0}function Nn(t,e,i,r,o){let a=-1,l=-1,h=-1,m=-1;{let s=[0,e],n=[e,0],o=[0,r],u=[r,0];for(let e=0;e<2&&-1===a;++e)for(let r=0;r<2;++r)if(t[s[e]].equals(i[o[r]])){a=s[e],l=n[e],h=o[r],m=u[r];break}}if(-1===a){let s=new p;s.setFromPoints(t,e+1);let n=new p;return n.setFromPoints(i,r+1),n.inflate(o),s.isIntersectingW(n)?-1:0}{let u=(0,n.d)(e+1,NaN),d=di(t,e+1,u);(0,s.g)(d>1);let g=0,c=0;for(let t=0;t<d;++t)a===u[t]&&(c=t,g++),l===u[t]&&g++;if(2!==g)return-1;let _=(0,n.d)(r+1,NaN),p=di(i,r+1,_);(0,s.g)(p>1),g=0;let f=0;for(let t=0;t<p;++t)h===_[t]&&(f=t,g++),m===_[t]&&g++;if(2!==g)return-1;let y=t[u[(c+d-1)%d]],P=t[u[(c+1)%d]],x=i[_[(f+p-1)%p]],v=i[_[(f+1)%p]],C=t[a],E=[y,P,x,v],b=[0,1,2,3];b.sort((t,e)=>n.P.compareVectorsOrigin(C,E[t],E[e]));let D=b[0];for(let t=1;t<4;t++){if(b[t]!==(D+1)%4)return-1;D=b[t]}{let t=y.sub(C),e=v.sub(C),i=e.dotProduct(t);if(i>0){let s=e.crossProduct(t),r=Math.abs(Math.atan2(s,i)),n=r*t.length(),a=r*e.length();if(n<=o||a<=o)return-1}}{let t=P.sub(C),e=x.sub(C),i=e.dotProduct(t);if(i>0){let s=e.crossProduct(t),r=Math.abs(Math.atan2(s,i)),n=r*t.length(),a=r*e.length();if(n<=o||a<=o)return-1}}return 1}}var Rn=r.V;class Yn extends K{static type=s.G.enumLine;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=NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return(0,s.g)(0),0}calculateUpperLength3D(){return(0,s.g)(0),0}changeEndPoints3D(t,e){(0,s.g)(0)}getClosestCoordinate3D(t,e,i){return(0,s.g)(0),0}getBoundary(){return At(this)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?tt(this,t):et(this,t);let s=Rn.getInterpolation(e),r=this.getStartAttributeAsDbl(e,i),o=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(s,r,o,t,Rn.getDefaultValue(e))}constructFromCoords(t,e,i,s){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(i,s)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){(0,s.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return Yn.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);let e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e);for(let s=Rn.getComponentCount(i);e<s;e++){let e=this.queryInterval(i,0);t.setIntervalEnvelope(i,0,e)}}}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,L(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,L(this,1,1,0))):(0,s.t)("env type not impl")}applyTransformation(t){(0,s.g)(t instanceof a.T);let e=new n.P;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 Yn({vd:this.m_description})}calculateLength2D(){return Math.sqrt(ut(this))}calculateLength3D(t){return(0,s.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return(0,s.g)(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return J(this,t,e)}queryCoord3D(t,e){(0,s.g)(0)}getCoordZ(t){return function(t,e){let i=t.getStartZ(),s=t.getEndZ();return(0,n.r)(i,s,e)}(this,t)}queryCoord2DE(t,e){it(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());let i=C.constructPoint2D(this.getEndXY());i.subThis(e),i.mulThis(n.M.constructDouble(t)),e.addThis(i)}getCoordX(t){return tt(this,t)}getCoordY(t){return et(this,t)}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createLine();s&&r.assignVertexDescription(this.m_description);let o=n.P.getNAN();if(J(this,t,o),r.setStartXYCoords(o.x,o.y),J(this,e,o),r.setEndXYCoords(o.x,o.y),!s)for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),n=Rn.getComponentCount(s);for(let i=0;i<n;i++){let n=this.getAttributeAsDbl(t,s,i);r.setStartAttribute(s,i,n);let o=this.getAttributeAsDbl(e,s,i);r.setEndAttribute(s,i,o)}}}queryDerivative(t,e){!function(t,e,i){let s=x.constructPoint2D(t.getStartXY()),r=x.constructPoint2D(t.getEndXY());i.setCoordsE(r.x.subE(s.x),r.y.subE(s.y))}(this,0,e)}getClosestCoordinate(t,e){return n.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,i=-1){let s=new n.P;this.queryCoord2D(e.vmin,s);let r=new n.P;this.queryCoord2D(e.vmax,r);let o=n.P.getClosestCoordinate(s,r,t,!1);return W.recalculateParentT(e.vmin,e.vmax,o)}intersectionOfYMonotonicWithAxisX(t,e){let i=this.m_YEnd-this.m_YStart;if(!i)return t===this.m_YEnd?e:NaN;let s=(t-this.m_YStart)/i,r=tt(this,s);return 1===s&&(r=this.m_XEnd),r}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){let e=this.m_XStart-this.m_XEnd,i=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+i*i)<=t}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){let e=new Yn;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){let e=this.calculateLength2D();return 0===e?0:t/e}calculateWeightedAreaCentroid2D(t){let e=new n.P;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){let e=n.P.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){let e=new n.P;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,i){return at(this,t,e,i)>=0}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,s.a)(""),e[0]=0,e[1]=1),2}intersectionWithAxis2D(t,e,i,s){if(t){let t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;let r=(e-this.m_YStart)/t;return r<0||r>1?0:(i&&(i[0]=tt(this,r)),s&&(s[0]=r),1)}{let t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;let r=(e-this.m_XStart)/t;return r<0||r>1?0:(i&&(i[0]=et(this,r)),s&&(s[0]=r),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let i=(0,n.s)(t.vmin,0,1),s=new n.P;return this.queryCoord2D(i,s),e.setCoords({pt:s}),i=(0,n.s)(t.vmax,0,1),this.queryCoord2D(i,s),void e.mergeNe(s)}(0,s.t)("3d dst not impl")}orientBottomUp(){rt(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 function(t,e){let i=t.getStartXYZ();i.z*=e;let s=t.getEndXYZ();return s.z*=e,i.norm(1)+s.norm(1)}(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){st(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,s.g)(0),0}readFromBufferStream(t,e){(0,s.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,i){st(this,t,e)}static isIntersectingLineLine(t,e,i,s){return nt(t,e,i,s)}static isIntersectingLineLine_(t,e,i,s){return nt(t,e,i,s)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){e.length<1&&(0,s.r)("");let r=at(this,t,i,!1);return r>=0?(e&&(e[0]=r),1):0}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}static segmentIntersectRobust(t,e,i,s,r,a){function l(t,e,i){return o.Envelope2D.construct(t.x,t.y,e.x,e.x).contains(i)}a.length=0;let h=x.constructPoint2D(t),m=x.constructPoint2D(e),u=x.constructPoint2D(i),d=x.constructPoint2D(s),g=m.subThisE(h),c=u.subE(d),_=u.subThisE(h),p=g.crossProduct(c);if(p.eps()<.5*Math.abs(p.value())){let t=_.crossProduct(c).divE(p),e=g.crossProduct(_).divE(p);if(!e.isInInterval(n.ad)||!t.isInInterval(n.ad))return 0;if(e.isInIntervalExclusive(n.ad)&&t.isInIntervalExclusive(n.ad)&&e.eps()<r&&t.eps()<r)return a.push(t.value(),e.value()),1}let f=C.constructPoint2D(t),y=C.constructPoint2D(e),P=C.constructPoint2D(i),v=C.constructPoint2D(s),E=y.subThis(f),b=P.sub(v),D=P.subThis(f),w=E.crossProduct(b);if(w.isZero())return l(t,e,i)||l(t,e,s)||l(i,s,t)||l(i,s,e)?-1:0;let S=D.crossProduct(b).div(w),A=E.crossProduct(D).div(w);return S.GEZ()&&A.GEZ()&&S.lte(n.ae)&&A.lte(n.ae)?(a.push(S.toDouble(),A.toDouble()),1):0}}class Xn{m_seg=null;m_curves=null;m_lineBuffer=new Yn;m_mask=0;m_active=0;constructor(t){if(void 0!==t){if(t.copy)return void t.copy.copyTo(this,!1);if(t.move)return void this.assignMove(t.move);if(t.segment)return void this.copyFrom(t.segment,!!t.bIgnoreAttributes);(0,s.d)("bad constructor params")}}assignCopy(t){return t instanceof Xn?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Xn){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:(0,s.d)("")}}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){if(this!==t){if(this.empty())return void(t.m_seg=null);t.copyFrom(this.m_seg,e)}}copyToWithZ(t,e){(0,s.g)(0)}createImpl(t){switch(t){case s.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new Yn,this.m_mask|=1,this.m_active=1);break;case s.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new Ar,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case s.G.enumBezier:4&this.m_mask||(this.m_curves=new vs,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case s.G.enumBezier2:8&this.m_mask||(this.m_curves=new Qt,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case s.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Ut,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,s.a)("")}}create(t){t===s.G.enumLine?this.createLine():t===s.G.enumEllipticArc?this.createEllipticArc():t===s.G.enumBezier?this.createCubicBezier():t===s.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===s.G.enumBezier2?this.createQuadraticBezier():(0,s.a)("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){(0,s.g)(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(s.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(s.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(s.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(s.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(s.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&(0,s.d)("releaseSegment"),1&this.m_active){let t=this.line();return--this.m_mask,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():(0,s.d)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Xn?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,s.t)("seg comparison not yet impl"),!1)}}},11878(t,e,i){i.d(e,{T:()=>a});var s=i(55537),r=i(83661);class n{data;N;M;constructor(t,e,i){if(t instanceof n)return this.data=t.data,this.N=t.N,this.M=t.M,t.data=null,t.N=0,void(t.M=0);this.data=t,this.N=e,this.M=i}assignCopy(t){return this===t||((0,s.g)(this.N*this.M===t.N*t.M),this.data.set(t.data),this.N=t.N,this.M=t.M),this}setZero(){return this.data?.fill(0),this}setIdentity(){for(let t=0;t<this.N;t++)for(let e=0;e<this.M;e++)this.setRowCol(t,e,+(t===e));return this}rows(){return this.N}cols(){return this.M}row(t){return(0,s.g)(0),{}}set(t,e){return this.data[t]=e,this}setRowCol(t,e,i){return this.data[t*this.M+e]=i,this}at(t){return this.data[t]}atRowCol(t,e){return this.data[t*this.M+e]}mulScalar(t,e){(0,s.g)(0)}mul(t,e){if((0,s.g)(this.M===t.rows()),(0,s.g)(this.N===e.rows()),(0,s.g)(t.cols()===e.cols()),e===this){let i=new Float64Array(this.N*this.M),s=new n(i,this.N,this.M);return this.mul(t,s),void e.assignCopy(s)}if(e===t){let i=new Float64Array(t.N*t.M),s=new n(i,t.N,t.M);return this.mul(t,s),void e.assignCopy(s)}let i=t.cols();for(let s=0;s<this.N;s++)for(let r=0;r<i;r++){let i=0;for(let e=0;e<this.M;e++)i+=this.atRowCol(s,e)*t.atRowCol(e,r);e.setRowCol(s,r,i)}}mulTranspose(t,e){if((0,s.g)(this.M===t.cols()),(0,s.g)(this.N===e.rows()),(0,s.g)(t.rows()===e.cols()),e===this){let i=new Float64Array(this.N*this.M),s=new n(i,this.N,this.M);return this.mulTranspose(t,s),void e.assignCopy(s)}if(e===t){let i=new Float64Array(t.N*t.M),s=new n(i,t.N,t.M);return this.mulTranspose(t,s),void e.assignCopy(s)}let i=t.rows();for(let s=0;s<this.N;s++)for(let r=0;r<i;r++){let i=0;for(let e=0;e<this.M;e++)i+=this.atRowCol(s,e)*t.atRowCol(r,e);e.setRowCol(s,r,i)}}mulLeft(t,e){(0,s.g)(0)}mulLeftTranspose(t,e){(0,s.g)(0)}mulDiag(t,e){if((0,s.g)(this.M===t.N*t.M),(0,s.g)(this.N===e.rows()),(0,s.g)(this.M===e.cols()),e===this){let i=new Float64Array(this.N*this.M),s=new n(i,this.N,this.M);return this.mulDiag(t,s),void e.assignCopy(s)}let i=this.M;for(let s=0;s<this.N;s++)for(let r=0;r<i;r++)e.setRowCol(s,r,this.atRowCol(s,r)*t.at(r))}transposeInPlace(){if(this.N===this.M){for(let t=0;t<this.N;t++)for(let e=t+1;e<this.M;e++){let i=this.atRowCol(t,e);this.setRowCol(t,e,this.atRowCol(e,t)),this.setRowCol(e,t,i)}return this}let t=new Float64Array(this.N*this.M),e=new n(t,this.N,this.M);return e.assignCopy(this),this.M=(0,r.c)(this.N,this.N=this.M),e.transpose(this),this}transpose(t){if(this!==t){n.checkDims(t,this.M,this.N);for(let e=0;e<this.N;e++)for(let i=0;i<this.M;i++)t.setRowCol(i,e,this.atRowCol(e,i))}else t.transposeInPlace()}add(t,e){}svd(t,e,i,r=!1){if(n.checkDims(t,this.N,this.M),n.checkDims(e,this.M,1),n.checkDims(i,this.M,this.M),r){if((0,s.g)(this.N===this.M),!this.symmetricEigen(e,i))return!1;for(let t=0;t<this.M;++t)e.at(t)<0&&e.set(t,0);return t.assignCopy(i),!0}let o,a,l,h,m,u,d,g=0,c=0,_=0,p=0,f=0,y=this.M,P=this.N;t.assignCopy(this);let x=new Float64Array(y),v=new n(x,y,1),C=(t,e)=>e>=0?Math.abs(t):-Math.abs(t),E=(t,e)=>{if((t=Math.abs(t))>(e=Math.abs(e))){let i=e/t;return t*Math.sqrt(i*i+1)}if(e>0){let i=t/e;return e*Math.sqrt(i*i+1)}return 0};for(let i=0;i<y;i++){if(g=i+1,v.set(i,p*_),_=h=p=0,i<P){for(let e=i;e<P;e++)p+=Math.abs(t.atRowCol(e,i));if(p){for(let e=i;e<P;e++)t.setRowCol(e,i,t.atRowCol(e,i)/p),h+=t.atRowCol(e,i)*t.atRowCol(e,i);a=t.atRowCol(i,i),_=-C(Math.sqrt(h),a),l=a*_-h,t.setRowCol(i,i,a-_);for(let e=g;e<y;e++){h=0;for(let s=i;s<P;s++)h+=t.atRowCol(s,i)*t.atRowCol(s,e);a=h/l;for(let s=i;s<P;s++)t.setRowCol(s,e,t.atRowCol(s,e)+a*t.atRowCol(s,i))}for(let e=i;e<P;e++)t.setRowCol(e,i,t.atRowCol(e,i)*p)}}if(e.set(i,p*_),_=h=p=0,i<P&&i!==y-1){for(let e=g;e<y;e++)p+=Math.abs(t.atRowCol(i,e));if(p){for(let e=g;e<y;e++)t.setRowCol(i,e,t.atRowCol(i,e)/p),h+=t.atRowCol(i,e)*t.atRowCol(i,e);a=t.atRowCol(i,g),_=-C(Math.sqrt(h),a),l=a*_-h,t.setRowCol(i,g,a-_);for(let e=g;e<y;e++)v.set(e,t.atRowCol(i,e)/l);for(let e=g;e<P;e++){h=0;for(let s=g;s<y;s++)h+=t.atRowCol(e,s)*t.atRowCol(i,s);for(let i=g;i<y;i++)t.setRowCol(e,i,t.atRowCol(e,i)+h*v.at(i))}for(let e=g;e<y;e++)t.setRowCol(i,e,t.atRowCol(i,e)*p)}}let s=Math.abs(e.at(i))+Math.abs(v.at(i));f=s>f?s:f}for(let e=y-1;e>=0;e--){if(e<y-1){if(_){for(let s=g;s<y;s++)i.setRowCol(s,e,t.atRowCol(e,s)/t.atRowCol(e,g)/_);for(let s=g;s<y;s++){h=0;for(let r=g;r<y;r++)h+=t.atRowCol(e,r)*i.atRowCol(r,s);for(let t=g;t<y;t++)i.setRowCol(t,s,i.atRowCol(t,s)+h*i.atRowCol(t,e))}}for(let t=g;t<y;t++)i.setRowCol(e,t,0),i.setRowCol(t,e,0)}i.setRowCol(e,e,1),_=v.at(e),g=e}for(let i=(P<y?P:y)-1;i>=0;i--){g=i+1,_=e.at(i);for(let e=g;e<y;e++)t.setRowCol(i,e,0);if(_){_=1/_;for(let e=g;e<y;e++){h=0;for(let s=g;s<P;s++)h+=t.atRowCol(s,i)*t.atRowCol(s,e);a=h/t.atRowCol(i,i)*_;for(let s=i;s<P;s++)t.setRowCol(s,e,t.atRowCol(s,e)+a*t.atRowCol(s,i))}for(let e=i;e<P;e++)t.setRowCol(e,i,t.atRowCol(e,i)*_)}else for(let e=i;e<P;e++)t.setRowCol(e,i,0);t.setRowCol(i,i,t.atRowCol(i,i)+1)}for(let s=y-1;s>=0;s--)for(let r=1;;r++){let n=1;for(g=s;g>=0;g--){if(c=g-1,Math.abs(v.at(g))+f===f){n=0;break}if(Math.abs(e.at(c))+f===f)break}if(n){o=0,h=1;for(let i=g;i<=s&&(a=h*v.at(i),v.set(i,v.at(i)*o),Math.abs(a)+f!==f);i++){_=e.at(i),l=E(a,_),e.set(i,l),l=1/l,o=_*l,h=-a*l;for(let e=0;e<P;e++)u=t.atRowCol(e,c),d=t.atRowCol(e,i),t.setRowCol(e,c,u*o+d*h),t.setRowCol(e,i,d*o-u*h)}}if(d=e.at(s),g===s){if(d<0){e.set(s,-d);for(let t=0;t<y;t++)i.setRowCol(t,s,-i.atRowCol(t,s))}break}if(100===r)return!1;m=e.at(g),c=s-1,u=e.at(c),_=v.at(c),l=v.at(s),a=((u-d)*(u+d)+(_-l)*(_+l))/(2*l*u),_=E(a,1),a=((m-d)*(m+d)+l*(u/(a+C(_,a))-l))/m,o=h=1;for(let s=g;s<=c;s++){let r=s+1;_=v.at(r),u=e.at(r),l=h*_,_*=o,d=E(a,l),v.set(s,d),o=a/d,h=l/d,a=m*o+_*h,_=_*o-m*h,l=u*h,u*=o;for(let t=0;t<y;t++)m=i.atRowCol(t,s),d=i.atRowCol(t,r),i.setRowCol(t,s,m*o+d*h),i.setRowCol(t,r,d*o-m*h);d=E(a,l),e.set(s,d),d&&(d=1/d,o=a*d,h=l*d),a=o*_+h*u,m=o*u-h*_;for(let e=0;e<P;e++)u=t.atRowCol(e,s),d=t.atRowCol(e,r),t.setRowCol(e,s,u*o+d*h),t.setRowCol(e,r,d*o-u*h)}v.set(g,0),v.set(s,a),e.set(s,m)}let b=new Float64Array(this.N),D=new Float64Array(this.M),w=new n(b,this.N,1),S=new n(D,this.M,1),A=1;do{A*=3,A++}while(A<=this.M);do{A/=3,A=Math.trunc(A);for(let s=A;s<this.M;s++){let r=e.at(s);for(let e=0;e<this.N;e++)w.set(e,t.atRowCol(e,s));for(let t=0;t<this.M;t++)S.set(t,i.atRowCol(t,s));let n=s;for(;e.at(n-A)<r;){e.set(n,e.at(n-A));for(let e=0;e<this.N;e++)t.setRowCol(e,n,t.atRowCol(e,n-A));for(let t=0;t<this.M;t++)i.setRowCol(t,n,i.atRowCol(t,n-A));if(n-=A,n<A)break}e.set(n,r);for(let e=0;e<this.N;e++)t.setRowCol(e,n,w.at(e));for(let t=0;t<this.M;t++)i.setRowCol(t,n,S.at(t))}}while(A>1);for(let e=0;e<this.M;e++){let s=0;for(let i=0;i<this.N;i++)t.atRowCol(i,e)<0&&s++;for(let t=0;t<this.M;t++)i.atRowCol(t,e)<0&&s++;if(s>Math.trunc((this.N+this.M)/2)){for(let i=0;i<this.N;i++)t.setRowCol(i,e,-t.atRowCol(i,e));for(let t=0;t<this.M;t++)i.setRowCol(t,e,-i.atRowCol(t,e))}}return!0}isSymmetric(){if(this.N!==this.M)return!1;for(let t=0;t<this.N;t++)for(let e=t+1;e<this.M;e++)if(this.atRowCol(t,e)!==this.atRowCol(e,t))return!1;return!0}isZero(){return(0,s.g)(0),!1}isIdentity(){return(0,s.g)(0),!1}equals(t,e){if(void 0!==e&&(0,s.g)(0),this.N!==t.N||this.M!==t.M)return!1;for(let e=0;e<this.N*this.M;e++)if(this.data[e]!==t.data[e])return!1;return!0}maxElement(){return(0,s.g)(0),0}minElement(){return(0,s.g)(0),0}determinant(){if((0,s.g)(this.N===this.M),1===this.N)return this.data[0];if(2===this.N)return this.data[0]*this.data[3]-this.data[1]*this.data[2];if(3===this.N){let t=this;return t.atRowCol(0,0)*(t.atRowCol(1,1)*t.atRowCol(2,2)-t.atRowCol(1,2)*t.atRowCol(2,1))-t.atRowCol(0,1)*(t.atRowCol(1,0)*t.atRowCol(2,2)-t.atRowCol(2,0)*t.atRowCol(1,2))+t.atRowCol(0,2)*(t.atRowCol(1,0)*t.atRowCol(2,1)-t.atRowCol(1,1)*t.atRowCol(2,0))}let t=new Float64Array(this.N*this.N),e=new n(t,this.N,this.N),i=new Float64Array(this.N);if(!this.luDecomposition(e,i))return 0;let r=1;for(let t=0;t<this.N;t++)r*=e.atRowCol(t,t),i[t]!==t&&(r=-r);return r}submatrix(t,e,i){(0,s.g)(0)}inverse(t){(0,s.g)(0)}pseudoInverse(t,e=!1,i=2220446049250313e-31){if(t.setZero(),1===this.N&&1===this.M)return 0===this.atRowCol(0,0)?t.setRowCol(0,0,0):t.setRowCol(0,0,1/this.atRowCol(0,0)),!0;if(2===this.N&&2===this.M){let e=this.atRowCol(0,0)*this.atRowCol(1,1)-this.atRowCol(0,1)*this.atRowCol(1,0),i=1e-5*(Math.abs(this.atRowCol(0,0)*this.atRowCol(1,1))+Math.abs(this.atRowCol(0,1)*this.atRowCol(1,0)));if(Math.abs(e)>i)return t.setRowCol(0,0,this.atRowCol(1,1)/e),t.setRowCol(0,1,-this.atRowCol(0,1)/e),t.setRowCol(1,0,-this.atRowCol(1,0)/e),t.setRowCol(1,1,this.atRowCol(0,0)/e),!0}let s=new Float64Array(this.N*this.M),r=new n(s,this.N,this.M),o=new Float64Array(this.M),a=new n(o,this.M,1),l=new Float64Array(this.M*this.M),h=new n(l,this.M,this.M);if(!this.svd(r,a,h,e))return!1;let m=Math.max(this.N,this.M),u=i*Math.abs(a.at(0))*m;for(let t=0;t<this.M;t++)a.at(t)>u?a.set(t,1/a.at(t)):a.set(t,0);return h.mulDiag(a,t),t.mulTranspose(r,t),!0}luDecomposition(t,e){return(0,s.g)(0),!1}symmetricEigen(t,e){(0,s.g)(this.rows()===this.cols()),(0,s.g)(this.rows()===t.rows()),(0,s.g)(e.rows()===e.cols()&&e.rows()===this.rows()),(0,s.g)(this.isSymmetric());let i=new Float64Array(this.N*this.M),r=new n(i,this.N,this.M);r.assignCopy(this);let o=100/2**-52,a=this.rows(),l=new Float64Array(a),h=new Float64Array(a),m=new n(l,a,1),u=new n(h,a,1);for(let e=0;e<a;e++)m.set(e,r.atRowCol(e,e)),t.set(e,r.atRowCol(e,e)),u.set(e,0);e.setIdentity();let d=()=>{let i=m;e.transposeInPlace();let s=1;do{s*=3,s++}while(s<=a);do{s/=3,s=Math.trunc(s);for(let r=s;r<a;r++){let n=t.at(r),o=Math.abs(n);for(let t=0;t<this.M;t++)i.set(t,e.atRowCol(t,r));let a=r;for(;Math.abs(t.at(a-s))<o;){t.set(a,t.at(a-s));for(let t=0;t<this.M;t++)e.setRowCol(t,a,e.atRowCol(t,a-s));if(a-=s,a<s)break}if(a!==r){t.set(a,n);for(let t=0;t<this.M;t++)e.setRowCol(t,a,i.at(t))}}}while(s>1)};for(let i=1;;i++){let s=0;for(let t=1;t<a;t++)for(let e=0;e<t;e++)s+=Math.abs(r.atRowCol(t,e));if(0===s)return d(),!0;let n=i<4?.2*s/(a*a):0;for(let s=0;s<a;s++)for(let l=s+1;l<a;l++){let h=o*Math.abs(r.atRowCol(l,s));if(i>4&&h<=Math.abs(t.at(s))&&h<=Math.abs(t.at(l)))r.setRowCol(l,s,0);else if(Math.abs(r.atRowCol(l,s))>n){let i,n=t.at(l)-t.at(s);if(h<Math.abs(n))i=r.atRowCol(l,s)/n;else{let t=.5*n/r.atRowCol(l,s);i=1/(Math.abs(t)+Math.sqrt(1+t*t)),t<0&&(i=-i)}let o=1/Math.sqrt(1+i*i),m=i*o,d=m/(1+o);n=i*r.atRowCol(l,s),u.set(s,u.at(s)-n),u.set(l,u.at(l)+n),t.set(s,t.at(s)-n),t.set(l,t.at(l)+n),r.setRowCol(l,s,0);let g=0;for(;g<s;g++)h=r.atRowCol(s,g),n=r.atRowCol(l,g),r.setRowCol(s,g,h-m*(n+h*d)),r.setRowCol(l,g,n+m*(h-n*d));for(g++;g<l;g++)h=r.atRowCol(g,s),n=r.atRowCol(l,g),r.setRowCol(g,s,h-m*(n+h*d)),r.setRowCol(l,g,n+m*(h-n*d));for(g++;g<a;g++)h=r.atRowCol(g,s),n=r.atRowCol(g,l),r.setRowCol(g,s,h-m*(n+h*d)),r.setRowCol(g,l,n+m*(h-n*d));for(g=0;g<a;g++)h=e.atRowCol(s,g),n=e.atRowCol(l,g),e.setRowCol(s,g,h-m*(n+h*d)),e.setRowCol(l,g,n+m*(h-n*d))}}for(let e=0;e<a;e++)m.set(e,m.at(e)+u.at(e)),t.set(e,m.at(e)),u.set(e,0)}}static checkDims(t,e,i){(0,s.g)(t.rows()===e&&t.cols()===i)}}class o extends n{buffer;constructor(t){if(t.copy){let e=new Float64Array(t.copy.N*t.copy.M);return super(e,t.copy.N,t.copy.M),this.buffer=e,void this.assignCopy(t.copy)}let e=new Float64Array(t.NN*t.MM);super(e,t.NN,t.MM),this.buffer=e,t.initializerList&&(0,r.b)(this.buffer,t.initializerList,0,0,t.initializerList.length)}assignCopy(t){return this===t||super.assignCopy(t),this}}class a{m_TransformationType=1;xx;xy;xd;yx;yy;yd;constructor(t){void 0===t?this.setIdentity():t instanceof a?this.set(t):this.setScale(t)}set(t){return this.xx=t.xx,this.xy=t.xy,this.xd=t.xd,this.yx=t.yx,this.yy=t.yy,this.yd=t.yd,this}clone(){return(new a).set(this)}setZero(){this.xx=0,this.yy=0,this.xy=0,this.yx=0,this.xd=0,this.yd=0}isEqual(t){return this===t||this.xx===t.xx&&this.xy===t.xy&&this.xd===t.xd&&this.yx===t.yx&&this.yy===t.yy&&this.yd===t.yd}transformInPlace(t){let e=this.xx*t.x+this.xy*t.y+this.xd,i=this.yx*t.x+this.yy*t.y+this.yd;t.x=e,t.y=i}transform(t){let e=t.clone();return this.transformInPlace(e),e}queryTransform(t,e){let i=this.xx*t.x+this.xy*t.y+this.xd,s=this.yx*t.x+this.yy*t.y+this.yd;e.setCoords(i,s)}transformEnvInPlace(t){if(t.isEmpty())return;let e=(0,r.m)(r.P,4);t.queryCorners(e),this.transformPoints2D(e,4,e),t.setFromPoints(e,4)}queryTransformEnv(t,e){(0,s.g)(0)}transformPoints2D(t,e,i){for(let s=0;s<e;++s)this.queryTransform(t[s],i[s])}transformInterleavedPoints(t,e,i){e*=2;let s=r.P.getNAN();for(let r=0;r<e;r+=2)s.x=t[r],s.y=t[r+1],this.transformInPlace(s),i[r]=s.x,i[r+1]=s.y}multiply(t){return a.st_multiply(this,t,this),this}mulLeft(t){return(0,s.g)(0),this}static st_multiply(t,e,i){let s=t.xx*e.xx+t.yx*e.xy,r=t.xy*e.xx+t.yy*e.xy,n=t.xd*e.xx+t.yd*e.xy+e.xd,o=t.xx*e.yx+t.yx*e.yy,a=t.xy*e.yx+t.yy*e.yy,l=t.xd*e.yx+t.yd*e.yy+e.yd;i.xx=s,i.xy=r,i.xd=n,i.yx=o,i.yy=a,i.yd=l}getCoefficients(t){(0,s.g)(t.length>=6),t[0]=this.xx,t[1]=this.xy,t[2]=this.xd,t[3]=this.yx,t[4]=this.yy,t[5]=this.yd}setCoefficients(t){(0,s.g)(t.length>=6),this.xx=t[0],this.xy=t[1],this.xd=t[2],this.yx=t[3],this.yy=t[4],this.yd=t[5]}copyTo(t){(0,s.g)(0)}initializeFromRect(t,e){t.isEmpty()||e.isEmpty()||!t.width()||!t.height()?this.setZero():(this.xy=this.yx=0,this.xx=e.width()/t.width(),this.yy=e.height()/t.height(),this.xd=e.xmin-t.xmin*this.xx,this.yd=e.ymin-t.ymin*this.yy)}initializeFromRectIsotropic(t,e){if(t.isEmpty()||!t.width()||!t.height()||e.isEmpty())this.setZero();else{this.yx=0,this.xy=0,this.xx=e.width()/t.width(),this.yy=e.height()/t.height(),this.xx>this.yy?this.xx=this.yy:this.yy=this.xx;let i=e.getCenter(),s=t.getCenter();this.xd=i.x-s.x*this.xx,this.yd=i.y-s.y*this.yy}}initializeFromTwoPointsArray(t,e){if(t[0].equals(e[0])&&t[1].equals(e[1]))return void this.setIdentity();if(t[0].equals(t[1])){if(e[0].equals(e[1]))return void this.setShift(e[0].sub(t[0]));(0,s.a)("")}if(!t[0].equals(t[1])&&e[0].equals(e[1]))return this.setZero(),void this.shift(e[0]);this.setShiftCoords(-t[0].x,-t[0].y);let i=r.P.distance(t[0],t[1]),n=r.P.distance(e[0],e[1]),o=n/i;this.scale(o,o);let a=t[1].sub(t[0]);a.divThis(i);let l=e[1].sub(e[0]);l.divThis(n);let h=a.crossProduct(l),m=a.dotProduct(l);this.rotate(m,h),this.shiftCoords(e[0].x,e[0].y)}initializeFromTwoPoints(t,e,i,s){let r=[t,e],n=[i,s];this.initializeFromTwoPointsArray(r,n)}transformSizeInPlace(t){(0,s.g)(0)}transformSize(t,e){(0,s.g)(0)}transformTol(t){return(0,s.g)(0),0}transformWithoutTranslateArray(t,e,i){for(let s=0;s<e;++s)this.transformWithoutTranslate(t[s],i[s])}transformWithoutTranslateInPlace(t){let e=this.xx*t.x+this.xy*t.y,i=this.yx*t.x+this.yy*t.y;t.setCoords(e,i)}transformWithoutTranslate(t,e){let i=this.xx*t.x+this.xy*t.y,s=this.yx*t.x+this.yy*t.y;e.setCoords(i,s)}setIdentity(){this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=1,this.yd=0}isIdentity(){return!(1!==this.xx||1!==this.yy||this.xy||this.xd||this.yx||this.yd)}isIdentityTol(t){let e=t*t;return!((0,r.a)(this.xd)+(0,r.a)(this.yd)>e||(0,r.a)(this.xy+this.xd)+(0,r.a)(this.yy+this.yd-1)>e||(0,r.a)(this.xx+this.xd-1)+(0,r.a)(this.yx+this.yd)>e)}isReflective(){return this.xx*this.yy-this.yx*this.xy<0}isUniform(t){let e=this.xx*this.xx+this.yx*this.yx,i=this.xy*this.xy+this.yy*this.yy,s=(e+i)*t;return Math.abs(e-i)<=s&&Math.abs(this.xx*this.xy+this.yx*this.yy)<=s}isUniformNoRotation(){return 0!==this.xx&&Math.abs(this.xx)===Math.abs(this.yy)&&0===this.xy&&0===this.yx}isTranslate(){return 1===this.xx&&1===this.yy&&!this.xy&&!this.yx}isTranslateTol(t){let e=new r.P;return e.setCoords(0,1),this.transformWithoutTranslateInPlace(e),--e.y,!(e.sqrLength()>t*t)&&(e.setCoords(1,0),this.transformWithoutTranslateInPlace(e),--e.x,e.sqrLength()<=t*t)}isOrthonormal(t){let e=new a;return e.xx=this.xx*this.xx+this.xy*this.xy,e.xy=this.xx*this.yx+this.xy*this.yy,e.yx=this.yx*this.xx+this.yy*this.xy,e.yy=this.yx*this.yx+this.yy*this.yy,e.xd=0,e.yd=0,e.isIdentityTol(t)}isDegenerate(t){return Math.abs(this.xx*this.yy-this.yx*this.xy)<=2*t*(Math.abs(this.xx*this.yy)+Math.abs(this.yx*this.xy))}isZero(){return 0===this.xx&&0===this.yy&&0===this.xy&&0===this.yx&&0===this.xd&&0===this.yd}isScaleAndTranslateTol(t){return this.xy*this.xy+this.yx*this.yx<=(this.xx*this.xx+this.yy*this.yy)*t}setTranslate(t,e){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=e,this}setShiftCoords(t,e){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=e,this}setShift(t){return this.xx=1,this.xy=0,this.xd=t.x,this.yx=0,this.yy=1,this.yd=t.y,this}setScaleCoords(t,e){return this.xx=t,this.xy=0,this.xd=0,this.yx=0,this.yy=e,this.yd=0,this}setScale(t){return this.setScaleCoords(t,t),this}setFlipX(t,e){return this.xx=-1,this.xy=0,this.xd=t+e,this.yx=0,this.yy=1,this.yd=0,this}setFlipY(t,e){return this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=-1,this.yd=t+e,this}setShear(t,e){return this.xx=1,this.xy=t,this.xd=0,this.yx=e,this.yy=1,this.yd=0,this}scale(t,e){return this.xx*=t,this.xy*=t,this.xd*=t,this.yx*=e,this.yy*=e,this.yd*=e,this}setRotateAngle(t){return this.setRotate(Math.cos(t),Math.sin(t))}setRotate(t,e){return this.xx=t,this.xy=-e,this.xd=0,this.yx=e,this.yy=t,this.yd=0,this}setRotateAngleAbout(t,e){return this.setRotateAbout(Math.cos(t),Math.sin(t),e)}setRotateAbout(t,e,i){return this.setTranslate(-i.x,-i.y),this.rotate(t,e),this.translate(i.x,i.y)}setSwapCoordinates(){return this.xx=0,this.xy=1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}setRotateCw90(){return this.xx=0,this.xy=1,this.xd=0,this.yx=-1,this.yy=0,this.yd=0,this}setRotateCcw90(){return this.xx=0,this.xy=-1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}shiftCoords(t,e){return this.xd+=t,this.yd+=e,this}shift(t){return this.xd+=t.x,this.yd+=t.y,this}translate(t,e){return this.xd+=t,this.yd+=e,this}flipX(t,e){return this.xx=-this.xx,this.xy=-this.xy,this.xd=t+e-this.xd,this}flipY(t,e){return this.yx=-this.yx,this.yy=-this.yy,this.yd=t+e-this.yd,this}shear(t,e){let i=new a;return i.setShear(t,e),this.multiply(i)}rotateAngle(t){let e=new a;return e.setRotateAngle(t),this.multiply(e)}rotate(t,e){let i=new a;return i.setRotate(t,e),this.multiply(i)}rotateAbout(t,e,i){return this.translate(-i.x,-i.y),this.rotate(t,e),this.translate(i.x,i.y)}rotateAngleAbout(t,e){return this.rotateAbout(Math.cos(t),Math.sin(t),e)}setInvert(t){return this.set(t),this.invertThis()}invertThis(){let t=this.xx*this.yy-this.xy*this.yx;if(0===t)return this.setZero(),this;t=1/t;let e=(this.xy*this.yd-this.xd*this.yy)*t,i=(this.xd*this.yx-this.xx*this.yd)*t,s=this.yy*t,r=-this.xy*t,n=-this.yx*t,o=this.xx*t;return this.xd=e,this.yd=i,this.xx=s,this.yy=o,this.xy=r,this.yx=n,this}invertPrecise(t){return this.set(t),this.invertPreciseThis()}invertPreciseThis(){let t=r.M.constructDouble(this.xy),e=r.M.constructDouble(this.xx),i=e.mulDouble(this.yy).sub(t.mulDouble(this.yx));if(i.isZero())return this.setZero(),this;let s=i.clone();s.invertThis();let n=r.M.constructDouble(this.xd),o=t.mulDouble(this.yd).sub(n.mulDouble(this.yy)).mul(s).toDouble(),a=n.mulDouble(this.yx).sub(e.mulDouble(this.yd)).mul(s).toDouble(),l=s.mulDouble(this.yy).toDouble(),h=s.mulDouble(-this.xy).toDouble(),m=s.mulDouble(-this.yx).toDouble(),u=s.mulDouble(this.xx).toDouble();return this.xd=o,this.yd=a,this.xx=l,this.yy=u,this.xy=h,this.yx=m,this}extractScaleTransform(t,e){let i=Math.sqrt(this.xx*this.xx+this.xy*this.xy),s=Math.sqrt(this.yx*this.yx+this.yy*this.yy);e.setScaleCoords(1/i,1/s),e.multiply(this),t.setScaleCoords(i,s)}setFromTwoTriangles(t,e){let i=!0;for(let s=0;s<3;++s)i&&=t[s].equals(e[s]);if(i)return this.setIdentity(),!0;let s=new r.P;s.setSub(t[0],t[1]);let n=new r.P;n.setSub(t[0],t[2]);let o=new r.P;o.setSub(e[0],e[1]);let a=new r.P;a.setSub(e[0],e[2]);let l=4*2**-52*(Math.abs(s.x*n.y)+Math.abs(n.x*s.y)),h=s.x*n.y-s.y*n.x;return Math.abs(h)>l?(h=1/h,this.xx=(o.x*n.y-s.y*a.x)*h,this.xy=(s.x*a.x-o.x*n.x)*h,this.yx=(o.y*n.y-s.y*a.y)*h,this.yy=(s.x*a.y-o.y*n.x)*h,this.xd=e[0].x-(this.xx*t[0].x+this.xy*t[0].y),this.yd=e[0].y-(this.yx*t[0].x+this.yy*t[0].y),!0):(this.setZero(),!1)}initializeFromControlPoints(t,e,i,n,m=null){return 0===e?(this.setIdentity(),void(m&&m.setIdentity())):1===e?(this.setShift(n[0].sub(i[0])),void(m&&m.setShift(i[0].sub(n[0])))):(e<3&&(t=1),void(4===t&&e>2?function(t,e,i,n,a){let l=r.P.average(i,e),m=r.P.average(n,e),u=new o({NN:2,MM:2});u.setZero();let d=new o({NN:2,MM:2});d.setZero();for(let t=0;t<e;++t)u.setRowCol(0,0,u.atRowCol(0,0)+(i[t].x-l.x)*(i[t].x-l.x)),u.setRowCol(0,1,u.atRowCol(0,1)+(i[t].x-l.x)*(i[t].y-l.y)),u.setRowCol(1,1,u.atRowCol(1,1)+(i[t].y-l.y)*(i[t].y-l.y)),d.setRowCol(0,0,d.atRowCol(0,0)+(n[t].x-m.x)*(i[t].x-l.x)),d.setRowCol(0,1,d.atRowCol(0,1)+(n[t].x-m.x)*(i[t].y-l.y)),d.setRowCol(1,0,d.atRowCol(1,0)+(n[t].y-m.y)*(i[t].x-l.x)),d.setRowCol(1,1,d.atRowCol(1,1)+(n[t].y-m.y)*(i[t].y-l.y));u.setRowCol(1,0,u.atRowCol(0,1));let g=new o({NN:2,MM:2});u.pseudoInverse(g,!0)||(0,s.b)("Failed to compute pseudo inverse"),d.mul(g,d),h(t,d);let c=l.clone();t.transformInPlace(c),t.xd=m.x-c.x,t.yd=m.y-c.y,a&&(d.pseudoInverse(g,!1)||(0,s.b)("Failed to compute pseudo inverse"),h(a,g),a.transformInPlace(m),a.xd=l.x-m.x,a.yd=l.y-m.y)}(this,e,i,n,m):function(t,e,i,n,m,u){(0,s.g)(1===t||0===t||2===t||3===t),e.setIdentity();let d=r.P.average(n,i),g=r.P.average(m,i);if((0,s.g)(t<l.length&&t>0),8&l[t]){let r=new o({NN:2,MM:2});r.setZero();for(let t=0;t<i;++t)r.setRowCol(0,0,r.atRowCol(0,0)+(m[t].x-g.x)*(n[t].x-d.x)),r.setRowCol(1,0,r.atRowCol(1,0)+(m[t].x-g.x)*(n[t].y-d.y)),r.setRowCol(0,1,r.atRowCol(0,1)+(m[t].y-g.y)*(n[t].x-d.x)),r.setRowCol(1,1,r.atRowCol(1,1)+(m[t].y-g.y)*(n[t].y-d.y));let u=new o({NN:2,MM:2}),c=new o({NN:2,MM:1}),_=new o({NN:2,MM:2});r.svd(u,c,_)||(0,s.b)("Failed to compute svd");let p=new o({NN:2,MM:2});u.transpose(p);let f=new o({NN:2,MM:2});_.mul(p,f),32&l[t]||f.determinant()<0&&(p.setRowCol(1,0,-p.atRowCol(1,0)),p.setRowCol(1,1,-p.atRowCol(1,1)),_.mul(p,f));let y=new a;h(y,f),e.set(y)}if(2&l[t]){let t=0,s=0;for(let r=0;r<i;++r){let i=n[r].sub(d);t+=i.sqrLength(),e.transformInPlace(i),s+=i.dotProduct(m[r].sub(g))}if(0===t)0===s?e.setIdentity():e.setZero();else{let i=s/t;e.scale(i,i)}}else(0,s.g)(!(4&l[t]));let c=d.clone();e.transformInPlace(c),e.xd=g.x-c.x,e.yd=g.y-c.y,u&&(u.set(e),u.invertThis(),u.isZero()&&(u.xd=d.x,u.yd=d.y))}(t,this,e,i,n,m)))}calculateErrors(t,e,i,n){(0,s.g)(t>0&&null!==e&&null!==i);let o=0;for(let s=0;s<t;++s){let t=this.transform(e[s]),a=r.P.sqrDistance(i[s],t);o+=a,n&&(n[s]=Math.sqrt(a))}return Math.sqrt(o/t)}}const l=[43,11,41,9,61];function h(t,e){(0,s.g)(!(2!==e.rows()&&3!==e.rows()||2!==e.cols()&&3!==e.rows())),t.xx=e.atRowCol(0,0),t.xy=e.atRowCol(0,1),t.yx=e.atRowCol(1,0),t.yy=e.atRowCol(1,1),3===e.cols()?(t.xd=e.atRowCol(0,2),t.yd=e.atRowCol(1,2)):(t.xd=0,t.yd=0)}}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8885],{95213(t,e,i){i.d(e,{A:()=>X,B:()=>L,C:()=>K,D:()=>O,E:()=>Rt,F:()=>G,H:()=>J,I:()=>H,J:()=>At,K:()=>v,L:()=>C,M:()=>y,N:()=>P,O:()=>x,P:()=>It,Q:()=>_,R:()=>b,S:()=>z,T:()=>Z,U:()=>Nt,V:()=>d,W:()=>u,X:()=>S,Y:()=>A,_:()=>$,a:()=>R,a0:()=>T,a1:()=>I,a2:()=>M,a3:()=>Et,a4:()=>rt,a5:()=>it,a6:()=>st,a7:()=>w,b:()=>N,c:()=>nt,d:()=>ht,e:()=>lt,f:()=>dt,g:()=>et,h:()=>tt,i:()=>yt,j:()=>_t,k:()=>g,l:()=>Pt,m:()=>mt,n:()=>gt,o:()=>at,p:()=>ft,q:()=>ct,r:()=>E,s:()=>pt,t:()=>ot,u:()=>Dt,v:()=>wt,w:()=>xt,x:()=>Ct,y:()=>bt,z:()=>vt});var s=i(83661),r=i(55537),n=i(79187);const o=[0,0,NaN,0,0,0,0,0,-1,-1,0,0,0,0],a=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],l=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],h=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],m=[4,8,4,8,1];function u(){return(0,s.c)(25,NaN)}let d=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return l[t]}static getPersistence(t){return h[t]}static getPersistenceSize(t){return m[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return a[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return o[t]}static isDefaultValue(t,e){return(0,s.G)(o[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=(0,s.c)(25,NaN),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let i=0,r=1,n=14;for(;i<n;i++)e&r&&(this.m_semanticsToIndexMap[i]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=i,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(i)),r<<=1;let o=0;for(i=0,n=this.getAttributeCount();i<n;i++){let e=this.getSemantics(i),s=t.getComponentCount(e),r=t.getDefaultValue(e);this.m_pointAttributeOffsets[i]=o;for(let t=0;t<s;t++)this.m_defaultPointAttributes[o]=r,o++}}m_semanticsBitArray;m_attributeCount;m_totalComponentCount;m_semanticsToIndexMap;m_indexToSemantics;m_pointAttributeOffsets;m_defaultPointAttributes};class g{x;y;z;static construct(t,e,i){return new g(t,e,i)}constructor(t,e,i){void 0!==t?(this.x=t,this.y=e,this.z=i):this.x=this.y=this.z=NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new g(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,i){return this.x=t,this.y=e,this.z=i,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){let t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){let t=new g;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return(0,r.g)(0),0}static sqrDistance(t,e){return(0,s.e)(t.x-e.x)+(0,s.e)(t.y-e.y)+(0,s.e)(t.z-e.z)}static sqrDistanceCoords(t,e,i,r,n,o){return(0,s.e)(t-r)+(0,s.e)(e-n)+(0,s.e)(i-o)}static distance(t,e){return Math.sqrt(g.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&(0,s.a6)(this.z,t.z,e)}static compareByLength(t,e,i,s){return(0,r.g)(0),0}isEqualCoords(t,e,i,s){return(0,r.g)(0),this.x===t&&this.y===e&&this.z===i}isEqualsTols(t,e,i){return(0,r.g)(0),!1}isEqualCoordsTols(t,e,i,s,n){return(0,r.g)(0),!1}static st_isEqual(t,e,i,s){return(0,r.g)(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,i){return(0,r.g)(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}sub(t){return g.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return g.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){let e=this.y*t.z-t.y*this.z,i=t.x*this.z-this.x*t.z,s=this.x*t.y-t.x*this.y;return new g(e,i,s)}setCrossProductVector(t,e){let i=t.y*e.z-e.y*t.z,s=e.x*t.z-t.x*e.z,r=t.x*e.y-e.x*t.y;return this.x=i,this.y=s,this.z=r,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return(0,r.g)(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return g.construct(NaN,NaN,NaN)}isFinite(){return(0,r.g)(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return(0,r.g)(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return(0,r.g)(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,i,s=!1){return(0,r.g)(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:+(this.z>t.z)}compareXYZ(t){return(0,r.g)(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return(0,r.g)(0),{}}static average(t,e){return(0,r.g)(0),{}}static dimensions=3;static size(){return g.dimensions}static lerp(t,e,i){let r=new g;return(0,s.y)(t,e,i,r),r}static slerp(t,e,i){return(0,r.g)(0),{}}static compareVectors(t,e){return(0,r.g)(0),0}static selectRightHandedBasisFromNormal(t,e,i){let s=t.getUnitVector(),r=s.createAPerpendicular(),n=new g;n.setCrossProductVector(s,r),n.normalizeThis(),e.setCoordsPoint3D(r),i.setCoordsPoint3D(n)}createAPerpendicular(){let t=[this.crossProductVector(new g(0,0,1)),this.crossProductVector(new g(1,0,0)),this.crossProductVector(new g(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],i=t[e.reduce((t,i,s)=>e[t]>e[s]?t:s,0)];return i.normalizeThis(),i}calculateAngle(t){return(0,r.g)(0),0}static crossDotSign(t,e,i){return(0,r.g)(0),0}static isBisectorRobust(t,e,i){return(0,r.g)(0),0}static compareZOrder(t,e){return(0,r.g)(0),!1}}var c=d;function _(){return(0,s.c)(14,0)}class p{m_map;m_vd2D;m_vd3D;static s_thisInstance;static{p.s_thisInstance=new p}static getInstance(){return p.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new c(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new c(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();let e=this.m_map.get(t);if(e)return e;let i=new c(t);return this.m_map.set(t,i),i}}function f(t){return p.getInstance().FindOrAdd(t)}function y(t,e){if(!t||!e)return e||t;let i=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(i&t.getSemanticsBitArray())===i?t:(i&e.getSemanticsBitArray())===i?e:f(i)}function P(t,e){let i=t.getSemanticsBitArray()|1<<e;return(i&t.getSemanticsBitArray())===i?t:f(i)}function x(t,e){let i=(t.getSemanticsBitArray()|1<<e)-(1<<e);return i===t.getSemanticsBitArray()?t:f(i)}function v(){return p.getInstance().GetVD2D()}function C(){return p.getInstance().GetVD3D()}function b(t,e,i){if(i.fill(-1),null!==t&&null!==e)for(let s=0,r=t.getAttributeCount();s<r;s++)i[s]=e.getAttributeIndex(t.getSemantics(s))}class E{m_EnvelopeType=3;xmin;ymin;zmin;xmax;ymax;zmax;static constructEmpty(){return new E(NaN,NaN,NaN,NaN,NaN,NaN)}constructor(t,e,i,s,r,n){this.xmin=t,this.ymin=e,this.zmin=i,this.xmax=s,this.ymax=r,this.zmax=n,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,i){(0,r.g)(0)}getEnvelope2D(){return new n.Envelope2D(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new s.E(this.zmin,this.zmax)}setEmptyZ(){this.zmin=NaN,this.zmax=NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=(0,s.s)(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=(0,s.s)(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=(0,s.s)(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=NaN,this.ymin=NaN,this.zmin=NaN,this.xmax=NaN,this.ymax=NaN,this.zmax=NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,i){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>i?this.zmin=i:this.zmax<i&&(this.zmax=i)}mergeCoords(t,e,i){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=i,this.zmax=i):(this.isEmptyZ()&&(this.zmin=i,this.zmax=i),this.mergeNeCoords(t,e,i))}setCoords(t,e,i,s,r,n){this.xmin=t,this.ymin=e,this.zmin=i,this.xmax=s,this.ymax=r,this.zmax=n,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,i,s=1){return(0,r.g)(0),0}sqrMaxDistance(t,e=1){return(0,r.g)(0),0}}var D=d;function w(t,e,i){switch(t){case 0:return new Y(e,i);case 1:return new X(e,i);case 2:return new R(e,i);case 3:throw Error("64 bit int attribute stream not implemented");case 4:return new N(e,i);default:(0,r.b)("")}}function S(t,e){let i=D.getComponentCount(t);return w(D.getPersistence(t),e*i,D.getDefaultValue(t))}function A(t,e){let i=D.getComponentCount(t);return w(D.getPersistence(t),e*i)}function T(t,e){return new R(t,e)}function I(t,e){return new N(t,e)}function M(t,e){return new X(t,e)}class q{static s_constructMin=2;static s_resizeMin=30;size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;let i=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>q.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),i&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){let s=1.25*t,r=new this.m_a.constructor(s);r.set(this.m_a),this.m_a=r,i&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,i){(e<0||i<0||i+e>this.size())&&(0,r.b)(),this.m_a.fill(t,e,e+i)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){let i=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,i)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),i))}getArray(){return this.m_a}equals(t,e,i,r){return this.getPersistence()===t.getPersistence()&&function(t,e,i,r,n){if(t.getPersistence()!==e.getPersistence())return!1;let o=t.getPersistence()<=1,a=t.size(),l=e.size();if(r>a||r>l)return!1;if(n)if(o){for(let o=i;o<r;o++)if(!(0,s.a6)(t.read(o),e.read(o),n))return!1}else for(let s=i;s<r;s++){let i=t.read(s)-e.read(s);if(i<0&&(i=-i),i>n)return!1}else for(let s=i;s<r;s++){let i=t.read(s),r=e.read(s);if(i!==r){if(o&&Number.isNaN(i)&&Number.isNaN(r))continue;return!1}}return!0}(this,t,e,i,r)}insertRange(t,e,i,s){let r=this.m_size;this.checkResize(Math.max(0,s)+i),this.m_a.copyWithin(t+i,t,s>=0?s:r),this.m_a.fill(e,t,t+i)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,i,s,n,o,a){(0,r.g)(this.getPersistence()===e.getPersistence());let l=e,h=this.m_size;s&&this.checkResize(Math.max(0,a)+s),this.m_a.copyWithin(t+s,t,a>=0?a:h),this.m_a.set(l.readRange(i,s),t),n||this.reverseRange(t,s,o)}writeRange(t,e,i,s,n,o){(0,r.g)(this.getPersistence()===i.getPersistence());let a=i;if((t<0||e<0||s<0)&&(0,r.b)(),a.size()<s+e&&(0,r.b)(),0===e)return;this.size()<e+t&&this.resize(e+t);let l=a.m_a.subarray(s,s+e);!function(t,e,i,s){if((e<0||i<0)&&(0,r.b)(),0===i)return;if(1===i)return void(t[e]=s[0]);let n=s;i<s.length&&(n=s.subarray(0,i)),t.set(n,e)}(this.m_a,t,e,l)}insertAttributes(t,e,i,s){let r=D.getComponentCount(i);this.m_a.copyWithin(t+r,t,s>=0?s:this.m_size);for(let s=0;s<r;s++)this.m_a[t+s]=e.getAttributeAsDbl(i,s)}insertAttributesFromPoints(t,e,i,n,o){(0,r.g)(D.getPersistence(n)===this.getPersistence());let a=D.getComponentCount(n),l=this.m_size;if(this.checkResize(Math.max(0,o)+a*i),this.m_a.copyWithin(t+a*i,t,o>=0?o:l),0===n){let r=new s.P;for(let s=t,n=0;n<i;n++,s+=2)e[n].queryXY(r),this.m_a[s]=r.x,this.m_a[s+1]=r.y}else if(1===a)for(let s=t,r=0;r<i;r++,s++)this.m_a[s]=e[r].getAttributeAsDbl(n,0);else for(let s=t,r=0;r<i;r++,s+=a)for(let t=0;t<a;t++)this.m_a[s+t]=e[r].getAttributeAsDbl(n,t)}eraseRange(t,e,i){this.m_size<t+e&&(0,r.b)(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,i){if((i<1||e%i!==0)&&(0,r.b)(),this.m_a.subarray(t,t+e).reverse(),i>1)for(let s=t,r=t+e;s<r;s+=i){let t=s,e=s+i-1;for(;t<e;){let i=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=i,t++,e--}}}rotate(t,e,i){(e<t||e>i||t>i)&&(0,r.r)("rotate"),e!==t&&e!==i&&(this.reverseRange(t,e-t,1),this.reverseRange(e,i-e,1),this.reverseRange(t,i-t,1))}sort(t,e,i){this.m_a.subarray(t,e).sort(i)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.fromArray)this.m_a=t.fromArray,this.m_size=t.size??t.fromArray.length;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{let e=Math.max(t.size,q.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}m_a;m_size}class N extends q{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new N({ctor:Int8Array,copy:this})}restrictedClone(t){return new N({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class R extends q{getPersistence(){return 2}clone(){return new R({ctor:Int32Array,copy:this})}restrictedClone(t){return new R({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){(0,r.g)(e<=(0,s.i)()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class Y extends q{getPersistence(){return 0}clone(){return new Y({ctor:Float32Array,copy:this})}restrictedClone(t){return new Y({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class X extends q{getPersistence(){return 1}applyTransformation(t,e,i){(1&e||e+2*i>this.size())&&(0,r.b)();let s=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(s,i,s)}readPoint2D(t){let e=this.m_a[t],i=this.m_a[t+1];return new s.P(e,i)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,i){this.checkResize(i+2),this.m_a.copyWithin(t+2,t,i),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,i,s,r,n){let o=this.m_size;if(this.checkResize(Math.max(n,0)+2*s),this.m_a.copyWithin(t+2*s,t,n>=0?n:o),r)for(let r=i,n=t,o=0;o<s;++o,++r){let t=e[r];this.m_a[n++]=t.x,this.m_a[n++]=t.y}else for(let r=i+s-1,n=t,o=0;o<s;++o,--r){let t=e[r];this.m_a[n++]=t.x,this.m_a[n++]=t.y}}queryRange(t,e,i,s,n){if((t<0||e<0)&&(0,r.b)(),!s&&(n<=0||e%n!==0)&&(0,r.b)(),0===e)return;if(1===e)return void(i[0]=this.m_a[t]);let o=this.m_a.subarray(t,t+e);i.set(o)}writeRangeFromArray(t,e,i,s,n){if((t<0||e<0)&&(0,r.b)(),0===e)return;if(1===e)return void(this.m_a[t]=i[0]);let o=i;e<i.length&&(o=i.subarray(0,e)),this.m_a.set(o,t)}clone(){return new X({ctor:Float64Array,copy:this})}restrictedClone(t){return new X({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}const F={partCount:0,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:0,segmentCountBezier:0};class L{m_buckets;m_bucketedIndices;static c_maxBuckets=65536;m_minValue=-1;m_maxValue=-1;m_dy=NaN;constructor(){this.m_buckets=new R(0),this.m_bucketedIndices=new R(0)}static sortEx(t,e,i,s,r=32){i-e<=r?s.userSort(e,i,t):(new L).sort(t,e,i,s,r)}sort(t,e,i,s,r=32){if(i-e<=r)return void s.userSort(e,i,t);let n=!0,o=1/0,a=-1/0;for(let r=e;r<i;r++){let e=s.getValue(t.read(r));e<o&&(o=e),e>a&&(a=e)}if(this.reset(i-e,o,a,i-e)){for(let r=e;r<i;r++){let i=t.read(r),n=s.getValue(i),o=this.getBucket(n);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(r-e,i)}let r=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){let e=this.m_buckets.read(t);this.m_buckets.write(t,r),r+=e}for(let r=e;r<i;r++){let i=this.m_bucketedIndices.read(r-e),n=s.getValue(i),o=this.getBucket(n),a=this.m_buckets.read(o);t.write(a+e,i),this.m_buckets.write(o,a+1)}n=!1}if(n)return void s.userSort(e,i,t);let l=0;for(let i=0,r=this.m_buckets.size();i<r;i++){let r=l;l=this.m_buckets.read(i),l>r&&s.userSort(e+r,e+l,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,i,s){if(t<2||i===e)return!1;let r=Math.min(L.c_maxBuckets,t);return this.m_buckets.resize(r),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=i,this.m_bucketedIndices.resize(s),this.m_dy=(i-e)/(r-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}class z{m_buffer=new Int32Array;m_firstFree=-1;m_last=0;size_=0;capacity_=0;stride;capacity(){return this.capacity_}constructor(t){this.stride=t}size(){return this.size_}deleteElement(t){t<this.m_last?(this.m_buffer[t*this.stride]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.size_--}getField(t,e){return this.m_buffer[t*this.stride+e]}setField(t,e,i){this.m_buffer[t*this.stride+e]=i}elementToIndex(t){return t}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.capacity_){let t=0===this.capacity_?1:Math.trunc(3*(this.capacity_+1)/2);if(t>2**53-1&&(t=2**53-1),t===this.capacity_)throw Error("index out of bounds");this.grow_(t)}t=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[t*this.stride];this.size_++;for(let e=t*this.stride;e<t*this.stride+this.stride;e++)this.m_buffer[e]=-1;return t}newElementPset(t){let e=this.m_firstFree;if(-1===e){if(this.m_last===this.capacity_){let t=0===this.capacity_?1:Math.trunc(3*(this.capacity_+1)/2);if(t>2**53-1&&(t=2**53-1),t===this.capacity_)throw Error("index out of bounds");this.grow_(t)}e=this.m_last,this.m_last++}else this.m_firstFree=this.m_buffer[e*this.stride];this.size_++;let i=e*this.stride;for(let e=0;e<t.length;e++)this.m_buffer[i+e]=t[e];return e}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.size_=0,t&&(this.m_buffer=new Int32Array,this.capacity_=0)}setCapacity(t){t>this.capacity_&&this.grow_(t)}swap(t,e){let i=t*this.stride,s=e*this.stride;for(let t=0;t<this.stride;t++){let e=this.m_buffer[s+t];this.m_buffer[s+t]=this.m_buffer[i+t],this.m_buffer[i+t]=e}}swapField(t,e,i){let s=this.m_buffer[this.stride*e+i];this.m_buffer[this.stride*e+i]=this.m_buffer[this.stride*t+i],this.m_buffer[this.stride*t+i]=s}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}grow_(t){this.m_buffer??=new Int32Array;let e=this.stride*t,i=new Int32Array(e);i.set(this.m_buffer,0),this.m_buffer=i,this.capacity_=t}}class V{m_extent=new n.Envelope2D;m_dataExtent=new n.Envelope2D;m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D];m_quadTreeNodes;m_elementNodes=new z(4);m_data=[];m_freeData=[];m_root=-1;m_height=8;m_bStoreDuplicates;static m_quadrantMask=3;static m_heightBitShift=2;static m_flushingCount=5;constructor(t,e,i){void 0===i&&(i=!1),this.m_quadTreeNodes=new z(i?11:10),this.m_bStoreDuplicates=i,this.reset_(t,e)}reset(t,e){this.m_quadTreeNodes.deleteAll(!1),this.m_elementNodes.deleteAll(!1),this.m_data.length=0,this.m_freeData.length=0,this.reset_(t,e)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){let i=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==i&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),i}let i=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==i&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),i}insertEx(t,e,i){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){let i=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==i&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),i}let s;s=-1===i?this.m_root:this.getQuad_(i);let r=this.getHeight(s),n=this.getExtent(s),o=this.insert_(t,e,r,n,s,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){(0,r.g)(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return(0,r.g)(0),0}getElementExtent(t){let e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return(0,r.g)(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return(0,r.g)(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>V.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){let e=new n.Envelope2D;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;let i=[],s=t;do{i.push(this.getQuadrant_(s)),s=this.getParent_(s)}while(s!==this.m_root);let r=i.length;for(let t=0;t<r;t++){let t=i.at(-1);i.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,i){if(-1===this.m_root)return 0;let r=new n.Envelope2D;r.setCoords({env2D:t}),r.inflateCoords(e,e);let o=[],a=[];o.push(this.m_root),a.push(this.m_extent.clone());let l=(0,s.d)(n.Envelope2D,4),h=0;for(;o.length>0;){let t=!1,e=o.at(-1),s=a.at(-1);if(o.pop(),a.pop(),r.containsEnvelope(s)){if(h+=this.getSubTreeElementCount(e),i>0&&h>=i)return i}else if(r.isIntersecting(s)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){let e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(r)&&(h++,i>0&&h>=i))return i}t=this.getHeight(e)+1<=this.m_height}if(t){V.setChildExtents_(s,l);for(let t=0;t<4;t++){let i=this.getChild_(e,t);-1!==i&&this.getSubTreeElementCount_(i)>0&&r.isIntersecting(l[t])&&(o.push(i),a.push(l[t].clone()))}}}return h}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new B(this,t,e)}getIteratorForQT(){return new B(this)}getSortedIterator(t,e){return new k(this.getIterator(t,e))}getSortedIteratorForQT(){return new k(this.getIteratorForQT())}visitLeavesNearest(t,e,i,s){(0,r.g)(0)}reset_(t,e){(e<0||e>127)&&(0,r.b)("invalid height"),this.m_height=e,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,i,s,r,o,a){if(!s.containsEnvelope(e))return 0===i?-1:this.insert_(t,e,0,this.m_extent,this.m_root,o,a);if(!o)for(let t=r;-1!==t;t=this.getParent_(t))this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1);let l=new n.Envelope2D;l.setCoords({env2D:s});let h,m=r;for(h=i;h<this.m_height&&this.canPushDown_(m);h++){V.setChildExtents_(l,this.m_childExtents);let t=!1;for(let i=0;i<4;i++)if(this.m_childExtents[i].containsEnvelope(e)){t=!0;let e=this.getChild_(m,i);-1===e&&(e=this.createChild_(m,i)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),m=e,l.setCoords({env2D:this.m_childExtents[i]});break}if(!t)break}return this.insertAtQuad_(t,e,h,l,m,o,r,a,-1)}insertDuplicates_(t,e,i,r,o,a,l){if(!a){if(!r.containsEnvelope(e))return-1;this.setSubTreeElementCount_(o,this.getSubTreeElementCount_(o)+1),this.setContainedSubTreeElementCount_(o,this.getContainedSubTreeElementCount_(o)+1)}let h=Math.max(e.width(),e.height()),m=-1,u=[],d=[],g=[];u.push(o),d.push(r.clone()),g.push(i);let c=(0,s.d)(n.Envelope2D,4);for(;u.length>0;){let i=!1,s=u.at(-1),r=d.at(-1),n=g.at(-1);if(u.pop(),d.pop(),g.pop(),n+1<this.m_height&&this.canPushDown_(s)&&h<=Math.max(r.width(),r.height())/2&&(i=!0),i){V.setChildExtents_(r,c);let t=!1;for(let i=0;i<4;i++)if(t=c[i].containsEnvelope(e),t){let t=this.getChild_(s,i);-1===t&&(t=this.createChild_(s,i)),u.push(t),d.push(c[i].clone()),g.push(n+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let t=0;t<4;t++)if(c[t].isIntersecting(e)){let e=this.getChild_(s,t);-1===e&&(e=this.createChild_(s,t)),u.push(e),d.push(c[t].clone()),g.push(n+1),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1)}}else m=this.insertAtQuad_(t,e,n,r,s,a,o,l,m),a=!1}return 0}insertAtQuad_(t,e,i,s,r,n,o,a,l){this.getFirstElement_(r);let h=this.getLastElement_(r),m=-1;if(n){if(r===o)return a;this.disconnectElementHandle_(a),m=a}else-1===l?(m=this.createElement_(),this.setDataValues_(this.getData_(m),t,e)):m=this.createElementFromDuplicate_(l);return this.setQuad_(m,r),-1===h?this.setFirstElement_(r,m):(this.setPrevElement_(m,h),this.setNextElement_(h,m)),this.setLastElement_(r,m),this.setLocalElementCount_(r,this.getLocalElementCount_(r)+1),this.canFlush_(r)&&this.flush_(i,s,r),m}static setChildExtents_(t,e){let i=.5*(t.xmin+t.xmax),s=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:i,ymin:s,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:s,xmax:i,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:i,ymax:s}),e[3].setCoords({xmin:i,ymin:t.ymin,xmax:t.xmax,ymax:s})}disconnectElementHandle_(t){let e=this.getQuad_(t),i=this.getFirstElement_(e),s=this.getLastElement_(e),r=this.getPrevElement_(t),n=this.getNextElement_(t);i===t?(-1===n?this.setLastElement_(e,-1):this.setPrevElement_(n,-1),this.setFirstElement_(e,n)):s===t?(this.setNextElement_(r,-1),this.setLastElement_(e,r)):(this.setPrevElement_(n,r),this.setNextElement_(r,n)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===V.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,i){let s,r=new n.Envelope2D,o=this.getFirstElement_(i),a=-1,l=-1;do{l=this.getData_(o),s=this.getElementValue_(l),r.setCoords({env2D:this.getBoundingBoxValue_(l)}),a=this.getNextElement_(o),this.m_bStoreDuplicates?this.insertDuplicates_(s,r,t,e,i,!0,o):this.insert_(s,r,t,e,i,!0,o),o=a}while(-1!==o)}canPushDown_(t){return this.getLocalElementCount_(t)>=V.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){let i=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,i),this.setSubTreeElementCount_(i,0),this.setLocalElementCount_(i,0),this.setParent_(i,t),this.setHeightAndQuadrant_(i,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(i,0),i}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){let t,e=this.m_elementNodes.newElement();return this.m_freeData.length>0?(t=this.m_freeData.at(-1),this.m_freeData.pop()):(t=this.m_data.length,this.m_data.length=t+1),this.setData_(e,t),e}createElementFromDuplicate_(t){let e=this.m_elementNodes.newElement(),i=this.getData_(t);return this.setData_(e,i),e}freeElementAndBoxNode_(t){(0,r.g)(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,i){this.m_quadTreeNodes.setField(t,e,i)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&V.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>V.m_heightBitShift}setHeightAndQuadrant_(t,e,i){let s=e<<V.m_heightBitShift|i;this.m_quadTreeNodes.setField(t,6,s)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,i){this.m_data[t]=function(t,e){return{element:t,box:e.clone()}}(e,i)}}class B{m_bLinear=!1;m_queryStart=new s.P;m_queryEnd=new s.P;m_queryBox=new n.Envelope2D;m_tolerance=0;m_currentElementHandle=-1;m_nextElementHandle=-1;m_quadTree;m_quadsStack=[];m_extentsStack=[];m_childExtents=[new n.Envelope2D,new n.Envelope2D,new n.Envelope2D,new n.Envelope2D];constructor(t,e,i){this.m_quadTree=t,e&&this.resetIterator(e,i)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof n.Envelope2D)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){let i=t.getGeometryType();if(this.m_bLinear=i===r.G.enumLine,this.m_bLinear){let i=t;this.m_queryStart.assign(i.getStartXY()),this.m_queryEnd.assign(i.getEndXY()),this.m_tolerance=e}else this.m_tolerance=NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;let t=new s.P,e=new s.P,i=new n.Envelope2D,r=!1;for(;!r;){for(;-1!==this.m_currentElementHandle;){let s=this.m_quadTree.getData_(this.m_currentElementHandle);if(i.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(s)}),i.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){r=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),i.inflateCoords(this.m_tolerance,this.m_tolerance),i.clipLine(t,e)>0){r=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){let i=this.m_quadsStack.at(-1),s=this.m_extentsStack.at(-1);V.setChildExtents_(s,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let s=0;s<4;s++){let r=this.m_quadTree.getChild_(i,s);if(-1!==r&&this.m_quadTree.getSubTreeElementCount(r)>0&&this.m_childExtents[s].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);let i=new n.Envelope2D;i.setCoords({env2D:this.m_childExtents[s]}),i.inflateCoords(this.m_tolerance,this.m_tolerance),i.clipLine(t,e)>0&&(this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[s].clone()))}else this.m_quadsStack.push(r),this.m_extentsStack.push(this.m_childExtents[s].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return(0,r.g)(0),{}}}class k{m_bucketSort=new L;m_sortedHandles=new R(0);m_quadTreeIteratorImpl;m_index=-1;constructor(t){this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);let e=this;this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),{userSort(t,i,s){s.sort(t,i,(t,i)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(i))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)})}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return(0,r.g)(0),{}}}class G{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}m_bNotifyOnActions;onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class Z{static st_nullNode(){return-1}constructor(){}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||=((0,r.g)(this.m_treapCount<=1),this.rebalance(-1),!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing||(-1===t&&(t=this.m_defaultTreap),0===this.size(t)))return;let e=[];for(let i=this.getFirst(t);-1!==i;i=this.getNext(i))e.push(i),this.setParent_(i,-1),this.setRight_(i,-1),this.setLeft_(i,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(let i of e)this.addBiggestElement_(i,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){let e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);let i=this.newNode_(t);return this.addBiggestElement_(i,e),i}addElementAtPosition(t,e,i,r,n,o=-1){if(-1===o&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),o=this.m_defaultTreap),this.getRoot_(o)===Z.st_nullNode()){let t=this.newNode_(i);return this.setRoot_(t,o),this.addToList_(-1,t,o),t}let a,l,h,m,u;if(n?(a=e===Z.st_nullNode()?-1:this.m_comparator.compare(this,i,e),l=t===Z.st_nullNode()?1:this.m_comparator.compare(this,i,t)):(a=-1,l=1),r&&(0===a||0===l)){this.m_comparator.onAddUniqueElementFailedImpl(i);let s=0===a?e:t;return this.setDuplicateElement_(s,o),-1}u=e!==Z.st_nullNode()&&t!==Z.st_nullNode()?this.m_random>(0,s.Q)(this.m_random)>>1:e!==Z.st_nullNode(),u?(m=a,h=e):(m=l,h=t);let d=-1,g=-1,c=!0;for(;;){if(m<0){let t=this.getLeft(h);if(t===Z.st_nullNode()){g=h,d=this.newNode_(i),this.setLeft_(h,d),this.setParent_(d,h);break}h=t}else{let t=this.getRight(h);if(t===Z.st_nullNode()){g=this.getNext(h),d=this.newNode_(i),this.setRight_(h,d),this.setParent_(d,h);break}h=t}c&&=(m*=-1,!1)}return this.bubbleUp_(d),this.getParent(d)===Z.st_nullNode()&&this.setRoot_(d,o),this.addToList_(g,d,o),d}replaceElementAtPosition(t,e,i,s,r=-1){if(s){let s=this.getNext(t),n=-1;s!==Z.st_nullNode()&&(n=this.m_comparator.compare(this,e,s));let o=this.getPrev(t),a=-1;if(o!==Z.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),i&&(0===n||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);let t=0===n?s:o;return r===Z.st_nullNode()&&(this.m_defaultTreap===Z.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),r=this.m_defaultTreap),this.setDuplicateElement_(t,r),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let i=this.getRoot(e);for(;i!==Z.st_nullNode();){let e=this.m_comparator.compare(this,t,i);if(!e)return i;i=e<0?this.getLeft(i):this.getRight(i)}return this.m_comparator.onEndSearchImpl(t),Z.st_nullNode()}searchLowerBound(t,e=-1){let i=this.getRoot(e),s=-1;for(;i!==Z.st_nullNode();){let e=t.compare(this,i);if(!e)return i;e<0?i=this.getLeft(i):(s=i,i=this.getRight(i))}return s}searchUpperBound(t,e=-1){let i=this.getRoot(e),s=-1;for(;i!==Z.st_nullNode();){let e=t.compare(this,i);if(!e)return i;e<0?(s=i,i=this.getLeft(i)):i=this.getRight(i)}return s}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=Z.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,i){let s;-1===t?s=this.getLast_(i):(s=this.getPrev(t),this.setPrev_(t,e)),this.setPrev_(e,s),-1!==s&&this.setNext_(s,e),this.setNext_(e,t),t===this.getFirst_(i)&&this.setFirst_(e,i),-1===t&&this.setLast_(e,i),this.setSize_(this.getSize_(i)+1,i)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return z.isValidElement(t)}m_defaultTreap=-1;m_random=124234251;m_comparator=null;m_treapData=new z(7);m_treapCount=0;m_maxDepthEver=0;m_bBalancing=!0;dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),i=this.getRight(t),r=this.getPriority_(t);for(;e!==Z.st_nullNode()||i!==Z.st_nullNode();){let n=e===Z.st_nullNode()?(0,s.b)():this.getPriority_(e),o=i===Z.st_nullNode()?(0,s.b)():this.getPriority_(i);if(r<=Math.min(n,o))return;n<=o?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),i=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;let e=this.getPriority_(t),i=this.getParent(t);for(;i!==Z.st_nullNode()&&this.getPriority_(i)>e;)this.getLeft(i)===t?this.rotateRight_(t):this.rotateLeft_(i),i=this.getParent(t)}rotateLeft_(t){let e,i=t,s=this.getRight(t);this.setParent_(s,this.getParent(i)),this.setParent_(i,s),e=this.getLeft(s),this.setRight_(i,e),e!==Z.st_nullNode()&&this.setParent_(e,i),this.setLeft_(s,i),e=this.getParent(s),e!==Z.st_nullNode()&&(this.getLeft(e)===i?this.setLeft_(e,s):this.setRight_(e,s))}rotateRight_(t){let e,i=this.getParent(t),s=t;this.setParent_(s,this.getParent(i)),this.setParent_(i,s),e=this.getRight(s),this.setLeft_(i,e),e!==Z.st_nullNode()&&this.setParent_(e,i),this.setRight_(s,i),e=this.getParent(s),e!==Z.st_nullNode()&&(this.getLeft(e)===i?this.setLeft_(e,s):this.setRight_(e,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?Z.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){let e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==Z.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=(0,s.Q)(this.m_random),this.m_random&(0,s.b)()>>1}maxPriority(){return(0,r.g)(0),0}getMaxDepthHelper_(t){return t===Z.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,i){if(this.getRoot(i)===Z.st_nullNode()){let e=this.newNode_(t);return this.setRoot_(e,i),this.addToList_(-1,e,i),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let s=this.getRoot_(i),r=-1,n=-1,o=1;for(;;){let a=-1===e?1:this.m_comparator.compare(this,t,s);if(a<0){let e=this.getLeft(s);if(e===Z.st_nullNode()){n=s,r=this.newNode_(t),this.setLeft_(s,r),this.setParent_(r,s);break}s=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(s,i),-1;let o=this.getRight(s);if(o===Z.st_nullNode()){n=this.getNext(s),r=this.newNode_(t),this.setRight_(s,r),this.setParent_(r,s);break}s=o}o++}return this.bubbleUp_(r),this.getParent(r)===Z.st_nullNode()&&this.setRoot_(r,i),this.addToList_(n,r,i),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),r}removeFromList_(t,e){let i=this.getPrev(t),s=this.getNext(t);-1===i?this.setFirst_(s,e):this.setNext_(i,s),-1===s?this.setLast_(i,e):this.setPrev_(s,i),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let i=this.getLeft(t),r=this.getRight(t),n=this.getParent(t),o=t;if(-1!==i&&-1!==r){let a;this.m_random=(0,s.Q)(this.m_random),a=this.m_random>(0,s.b)()>>1?this.getNext(t):this.getPrev(t);let l=this.getParent(a)===t;this.m_treapData.swapField(t,a,0),this.m_treapData.swapField(t,a,1),this.m_treapData.swapField(t,a,2),-1===n?this.setRoot_(a,e):this.getLeft(n)===t?this.setLeft_(n,a):this.setRight_(n,a),l?(i===a?(this.setLeft_(a,t),this.setParent_(r,a)):r===a&&(this.setRight_(a,t),this.setParent_(i,a)),this.setParent_(t,a),n=a):(this.setParent_(i,a),this.setParent_(r,a),n=this.getParent(t),o=a),i=this.getLeft(t),r=this.getRight(t),-1!==i&&this.setParent_(i,t),-1!==r&&this.setParent_(r,t)}let a=-1===i?r:i;-1===n?this.setRoot_(a,e):this.getLeft(n)===o?this.setLeft_(n,a):this.setRight_(n,a),-1!==a&&this.setParent_(a,n),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,(0,s.b)());let i=Z.st_nullNode(),r=Z.st_nullNode(),n=this.getRoot_(e),o=n===t;if(o&&(i=this.getLeft(n),r=this.getRight(n),i===Z.st_nullNode()&&r===Z.st_nullNode()))return this.removeFromList_(n,e),this.freeNode_(n,e),void this.setRoot_(Z.st_nullNode(),e);this.bubbleDown_(t);let a=this.getParent(t);a!==Z.st_nullNode()&&(this.getLeft(a)===t?this.setLeft_(a,Z.st_nullNode()):this.setRight_(a,Z.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),o&&this.setRoot_(i===Z.st_nullNode()||this.getParent(i)!==Z.st_nullNode()?r:i,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===Z.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);let i=this.getLast_(e);this.setRight_(i,t),this.setParent_(t,i),this.bubbleUp_(t),this.getParent(t)===Z.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class H{m_listNodes;m_lists;m_listOfLists;m_bStoreListIndexWithNode;constructor(t){this.m_lists=new z(6),this.m_listOfLists=H.st_nullNode(),void 0===t?(this.m_listNodes=new z(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new z(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){(0,r.g)(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(t,e){(0,r.g)(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){(0,r.g)(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){let e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==H.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);let e=this.m_lists.getField(t,2),i=this.m_lists.getField(t,3);return e===H.st_nullNode()?this.m_listOfLists=i:this.setNextList_(e,i),i!==H.st_nullNode()&&this.setPrevList_(i,e),this.freeList_(t),i}reserveLists(t){(0,r.g)(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return(0,r.g)(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,i){let s=this.newNode_(),r=-1;if(e!==H.st_nullNode()&&(r=this.getPrev(e),this.setPrev_(e,s)),this.setNext_(s,e),r!==H.st_nullNode()&&this.setNext_(r,s),e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,s),e===H.st_nullNode()){let e=this.m_lists.getField(t,1);this.setPrev_(s,e),-1!==e&&this.setNext_(e,s),this.m_lists.setField(t,1,s)}return this.setData(s,i),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(s,t),s}deleteElement(t,e){let i=this.getPrev(e),s=this.getNext(e);return i===H.st_nullNode()?this.m_lists.setField(t,0,s):this.setNext_(i,s),s===H.st_nullNode()?this.m_lists.setField(t,1,i):this.setPrev_(s,i),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),s}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==H.st_nullNode();){let t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let t=this.getFirstList();-1!==t;)t=this.deleteList(t)}isEmpty(t){return(0,r.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class W extends G{m_intervalTree;constructor(t){super(),this.m_intervalTree=t}compare(t,e,i){let s=t.getElement(i),r=this.m_intervalTree.getValue_(e),n=this.m_intervalTree.getValue_(s);return r<n?-1:r===n?j.isLeft_(e)&&j.isRight_(s)?-1:j.isLeft_(s)&&j.isRight_(e)?1:0:1}}class j{m_bEnvelopesRef=!1;m_bOfflineDynamic;m_intervals=[];m_envelopesRef=null;m_tertiaryNodes;m_intervalNodes=new z(3);m_intervalHandles=[];m_secondaryLists;m_secondaryTreaps;m_endIndicesUnique=[];m_cCount=-1;m_root=-1;m_bSortIntervals=!1;m_bConstructing=!1;m_bConstructionEnded=!1;constructor(t){this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new z(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new Z,this.m_secondaryTreaps.setComparator(new W(this)),this.m_secondaryLists=new H}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||(0,r.q)(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){(0,r.g)(0)}endConstruction(){this.m_bConstructing||(0,r.q)(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if((!this.m_bOfflineDynamic||!this.m_bConstructionEnded)&&(0,r.q)(""),-1===this.m_root){let t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){let e=new R(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}let e=this.insertIntervalEnd_(t<<1,this.m_root),i=this.getSecondaryFromInterval_(e),s=this.m_secondaryTreaps.addElement(1+(t<<1),i);this.setRightEnd_(e,s),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){(!this.m_bOfflineDynamic||!this.m_bConstructionEnded)&&(0,r.q)("");let e=this.m_intervalHandles[t];-1===e&&(0,r.b)("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let i,s=this.getSecondaryFromInterval_(e),n=-1;n=this.m_secondaryTreaps.getTreapData(s),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),s),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),s),i=this.m_secondaryTreaps.size(s),0===i&&(this.m_secondaryTreaps.deleteTreap(s),this.setSecondaryToTertiary_(n,-1)),this.m_intervalNodes.deleteElement(e);let o=this.getPptr_(n),a=this.getLptr_(n),l=this.getRptr_(n);for(;!(i>0||n===this.m_root||-1!==a&&-1!==l);)n===this.getLptr_(o)?-1===a?-1===l?(this.setLptr_(o,-1),this.setPptr_(n,-1)):(this.setLptr_(o,l),this.setPptr_(l,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setLptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1===a?-1===l?(this.setRptr_(o,-1),this.setPptr_(n,-1)):(this.setRptr_(o,l),this.setPptr_(l,o),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setRptr_(o,a),this.setPptr_(a,o),this.setLptr_(n,-1),this.setPptr_(n,-1)),this.m_tertiaryNodes.deleteElement(n),n=o,s=this.getSecondaryFromTertiary_(n),i=-1===s?0:this.m_secondaryTreaps.size(s),a=this.getLptr_(n),l=this.getRptr_(n),o=this.getPptr_(n)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof s.E?new U(this,t,e):((0,r.g)(0),{})}getIterator(){return new U(this)}querySortedEndPointIndices_(t){let e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let i=0;i<2*e;i++)t.add(i);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=NaN;for(let i=0;i<t.size();i++){let s=t.read(i),r=this.getValue_(s);r!==e&&(this.m_endIndicesUnique.push(s),e=r)}}insertIntervalsStatic_(){let t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new R(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);let i=(0,s.c)(t,-1);this.m_root=this.createRoot_();for(let t=0;t<e.size();t++){let s=e.read(t),r=i[s>>1];if(-1!==r){let t=this.getSecondaryFromInterval_(r);this.setRightEnd_(r,this.m_secondaryLists.addElement(t,s))}else r=this.insertIntervalEnd_(s,this.m_root),i[s>>1]=r}}createRoot_(){let t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let i=-1,s=e,r=-1,n=-1,o=0,a=this.m_endIndicesUnique.length-1,l=0,h=t>>1,m=NaN,u=NaN,d=!0,g=this.getMin_(h),c=this.getMax_(h),_=-1;for(;d;){l=o+(a-o>>1),_=this.calculateDiscriminantIndex1_(o,a);let e=this.getDiscriminantFromIndex1_(_);if(c<e){if(-1!==s)if(_===this.getDiscriminantIndex1_(s))i=s,m=e,s=this.getLptr_(s),u=-1===s?NaN:this.getDiscriminant_(s);else if(u>e){let t=this.createTertiaryNode_(_);e<m?this.setLptr_(i,t):this.setRptr_(i,t),this.setRptr_(t,s),this.m_bOfflineDynamic&&(this.setPptr_(t,i),this.setPptr_(s,t)),i=t,m=e,s=-1,u=NaN}a=l;continue}if(g>e){if(-1!==s)if(_===this.getDiscriminantIndex1_(s))i=s,m=e,s=this.getRptr_(s),u=-1===s?NaN:this.getDiscriminant_(s);else if(u<e){let t=this.createTertiaryNode_(_);e<m?this.setLptr_(i,t):this.setRptr_(i,t),this.setLptr_(t,s),this.m_bOfflineDynamic&&(this.setPptr_(t,i),this.setPptr_(s,t)),i=t,m=e,s=-1,u=NaN}o=l+1;continue}let h=-1;h=-1===s||_!==this.getDiscriminantIndex1_(s)?this.createTertiaryNode_(_):s,r=this.getSecondaryFromTertiary_(h),-1===r&&(r=this.createSecondary_(h),this.setSecondaryToTertiary_(h,r));let p=this.addEndIndex_(r,t);n=this.createIntervalNode_(),this.setSecondaryToInterval_(n,r),this.setLeftEnd_(n,p),(-1===s||_!==this.getDiscriminantIndex1_(s))&&(e<m?this.setLptr_(i,h):this.setRptr_(i,h),this.m_bOfflineDynamic&&this.setPptr_(h,i),-1!==s&&(u<e?this.setLptr_(h,s):this.setRptr_(h,s),this.m_bOfflineDynamic&&this.setPptr_(s,h))),d=!1;break}return n}createTertiaryNode_(t){let e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){(!this.m_bOfflineDynamic||!this.m_bConstructionEnded)&&(0,r.q)(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){let e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return NaN;if(t>0){let e=t-2,i=this.m_endIndicesUnique[e],s=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(i)+this.getValue_(s))}let e=-t-2,i=this.m_endIndicesUnique[e];return this.getValue_(i)}calculateDiscriminantIndex1_(t,e){let i;return i=t<e?t+(e-t>>1)+2:-(t+2),i}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let i=-1;return i=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),i}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,i){let s=this;(new L).sort(t,e,i,{userSort(t,e,i){s.sortEndIndicesHelper_(i,t,e)},getValue:t=>s.getValue_(t)})}sortEndIndicesHelper_(t,e,i){t.sort(e,i,(t,e)=>{let i=this.getValue_(t),s=this.getValue_(e);return i<s||i===s&&j.isLeft_(t)&&j.isRight_(e)?-1:1})}getValue_(t){if(!this.m_bEnvelopesRef){let e=this.m_intervals[t>>1];return j.isLeft_(t)?e.vmin:e.vmax}let e=this.m_envelopesRef[t>>1];return j.isLeft_(t)?e.xmin:e.xmax}}class U{m_intervalTree;m_query=s.E.constructEmpty();m_tertiaryHandle=-1;m_nextTertiaryHandle=-1;m_forkedHandle=-1;m_currentEndHandle=-1;m_nextEndHandle=-1;m_tertiaryStack=[];m_functionIndex=0;m_functionStack;m_fi;constructor(t,e,i){this.m_intervalTree=t,this.m_functionStack=[,,],this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,i)}nullFunc_(){return(0,r.d)("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){let i=new s.E;i.setCoords(t,t),this.resetIterator(i,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||(0,r.q)(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1===this.m_currentEndHandle?-1:this.getCurrentEndIndex_()>>1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;let t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;let e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);let e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;let t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}let e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);let i=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==i&&this.m_tertiaryStack.push(i),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();let t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&j.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class O{m_tolerance=0;m_sweepIndexRed=-1;m_sweepIndexBlue=-1;m_envelopeHandleA=-1;m_envelopeHandleB=-1;m_intervalTreeRed=null;m_intervalTreeBlue=null;m_iteratorRed=null;m_iteratorBlue=null;m_envelopesRed=[];m_envelopesBlue=[];m_elementsRed=[];m_elementsBlue=[];m_sortedEndIndicesRed=new R(0);m_sortedEndIndicesBlue=new R(0);m_queuedListRed=-1;m_queuedListBlue=-1;m_queuedEnvelopes=new H;m_queuedIndicesRed=[];m_queuedIndicesBlue=[];m_bAddRed=!1;m_bAddBlue=!1;m_bAddRedRed=!1;m_bDone=!0;m_function;constructor(){this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new n.Envelope2D(e))}endConstruction(){this.m_bAddRedRed||(0,r.q)(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||(0,r.q)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||(0,r.q)(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||(0,r.q)(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||(0,r.q)(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||=new j(!0),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||=new j(!0),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||=new j(!0),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),this.m_iteratorBlue??=this.m_intervalTreeBlue.getIterator(),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||=new j(!0),this.m_intervalTreeBlue||=new j(!0),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){let t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);let i=s.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(i,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1===--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){let t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),i=this.getAdjustedValue_(t,!0),s=this.getAdjustedValue_(e,!1);return i>s?this.sweepRed_():i<s?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){let t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){let e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;let i=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=i}}if(this.m_intervalTreeBlue.size()>0){let t=s.E.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&((0,s.x)(this.m_queuedIndicesRed,this.m_envelopesRed.length,-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){let t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){let e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;let i=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=i}}if(this.m_intervalTreeRed.size()>0){let t=s.E.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&((0,s.x)(this.m_queuedIndicesBlue,this.m_envelopesBlue.length,-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;let t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;let t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;let t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;let t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1===--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;let t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return(0,r.d)("should not be called"),!1}sortYEndIndices_(t,e,i,s){let r=this;(new L).sort(t,e,i,{userSort(t,e,i){r.sortYEndIndicesHelper_(i,t,e,s)},getValue:t=>r.getAdjustedValue_(t,s)})}sortYEndIndicesHelper_(t,e,i,s){t.sort(e,i,(t,e)=>{let i=this.getAdjustedValue_(t,s),r=this.getAdjustedValue_(e,s);return i<r||i===r&&this.isBottom_(t)&&this.isTop_(e)?-1:1})}getAdjustedValue_(t,e){let i=.5*this.m_tolerance;if(e){let e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-i:e.ymax+i}let s=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?s.ymin-i:s.ymax+i}}var Q=d;class K{tolerance;resolution;constructor(t,e){this.tolerance=void 0===t?NaN:t,this.resolution=void 0===e?NaN:e}add(t){return new K(this.tolerance+t,this.resolution)}scale(t){return new K(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function J(t,e,i,r,n){let o=r*r,a=t.sub(e),l=i.sub(e),h=a.sqrLength(),m=l.sqrLength();if(h<=o||m<=o)return!0;let u=(0,s.e)(a.crossProduct(l));return(u<=o*h||u<=o*m)&&a.dotProduct(l)>=0}function $(t,e,i){return s=>0===i?(s+t)*e:1*(s-t*e)/e}function tt(t,e){let i=new n.Envelope2D;return t.queryLooseEnvelope(i),i.mergeEnvelope2D(e),i}function et(t,e){let i=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(i);let s=n.Envelope2D.constructEmpty();return e.queryLooseEnvelope(s),i.mergeEnvelope2D(s),i}function it(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function st(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function rt(t,e,i){let s=n.Envelope2D.constructEmpty();return s.setFromPoints(t,e),ut(0,null,s.calculateToleranceFromEnvelope(),i,!1)}function nt(t,e,i){return ut(0,t,e.calculateToleranceFromEnvelope(),i,!1)}function ot(t,e,i){return ut(1,t,e.calculateToleranceFromEnvelope(),i,!1)}function at(t,e,i){return ot(t,e.queryInterval(1,0),i)}function lt(t,e,i){let s=n.Envelope2D.constructEmpty();return e.queryEnvelope(s),nt(t,s,i)}function ht(t,e,i=!1){return ut(0,t,e.calculateToleranceFromEnvelope(),i,!0).total()}function mt(t,e,i){let s=n.Envelope2D.constructEmpty();return e.queryEnvelope(s),ht(t,s,i)}function ut(t,e,i,s,r){let n=new K(0,0);return null!==e&&(n.tolerance=e.getTolerance(t),(!r||s)&&null!==e&&(n.resolution=e.getResolution(t),s&&(n.resolution*=2))),s&&(i*=4,n.tolerance*=1.01,n.resolution*=1.01),n.total()<i?new K(i,0):n}function dt(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function gt(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function ct(t){return t>=3}function _t(t,e){return t.getImpl().getIsSimple(e,[0])>=3}function pt(t,e){t.getImpl().setIsSimple(3,e)}function ft(t,e,i,r){if((0,s.e)(e.x-t.x)+(0,s.e)(e.y-t.y)<=i*i){let i=t.z,n=e.z;return(0,s.a6)(i,n,r)}return!1}function yt(t){return t>=4}function Pt(t,e){return t===r.G.enumPolygon?ct(e):e>=1}function xt(t,e,i){let s=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(s),e.queryLooseEnvelope(r),s.inflateCoords(i,i),r.inflateCoords(i,i);let o=n.Envelope2D.constructEmpty();o.setCoords({env2D:s}),o.intersect(r);let a=t.querySegmentIterator(),l=e.querySegmentIterator(),h=n.Envelope2D.constructEmpty(),m=n.Envelope2D.constructEmpty(),u=new O;u.setTolerance(i);let d=!1;for(u.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(h),h.isIntersecting(o)&&(d=!0,u.addRedEnvelope(a.getStartPointIndex(),h));if(u.endRedConstruction(),!d)return null;let g=!1;for(u.startBlueConstruction();l.nextPath();)for(;l.hasNextSegment();)l.nextSegment().queryLooseEnvelope(m),m.isIntersecting(o)&&(g=!0,u.addBlueEnvelope(l.getStartPointIndex(),m));return u.endBlueConstruction(),g?u:null}function vt(t,e,i,s,r){t.getGeometryType(),e.getGeometryType();let o=n.Envelope2D.constructEmpty(),a=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(o),e.queryLooseEnvelope(a),o.inflateCoords(i,i),a.inflateCoords(i,i);let l=n.Envelope2D.constructEmpty();l.setCoords({env2D:o}),l.intersect(a);let h=new O;h.setTolerance(i);let m=!1;h.startRedConstruction();for(let e=0,i=t.getPathCount();e<i;e++)t.queryLoosePathEnvelope(e,o),o.isIntersecting(l)&&(m=!0,h.addRedEnvelope(e,o));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let t=0,i=e.getPathCount();t<i;t++)e.queryLoosePathEnvelope(t,a),a.isIntersecting(l)&&(u=!0,h.addBlueEnvelope(t,a));return h.endBlueConstruction(),u?h:null}function Ct(t,e,i){let s=n.Envelope2D.constructEmpty(),r=n.Envelope2D.constructEmpty();t.queryLooseEnvelope(s),e.queryEnvelope(r),s.inflateCoords(i,i),r.inflateCoords(i,i);let o=n.Envelope2D.constructEmpty();o.setCoords({env2D:s}),o.intersect(r);let a=t.querySegmentIterator(),l=new O;l.setTolerance(i);let h=!1;for(l.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(s),s.isIntersecting(o)&&(h=!0,l.addRedEnvelope(a.getStartPointIndex(),s));if(l.endRedConstruction(),!h)return null;let m=!1;l.startBlueConstruction();for(let t=0,i=e.getPointCount();t<i;t++){let i=e.getXY(t);o.contains(i)&&(m=!0,l.addBlueEnvelope(t,n.Envelope2D.construct(i.x,i.y,i.x,i.y)))}return l.endBlueConstruction(),m?l:null}function bt(t,e,i){let r=n.Envelope2D.constructEmpty(),o=n.Envelope2D.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(i,i),o.inflateCoords(i,i);let a=n.Envelope2D.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);let l=new O;l.setTolerance(i);let h=!1;l.startRedConstruction();let m=new s.P;for(let e=0,i=t.getPointCount();e<i;e++)t.queryXY(e,m),a.contains(m)&&(h=!0,l.addRedEnvelope(e,n.Envelope2D.construct(m.x,m.y,m.x,m.y)));if(l.endRedConstruction(),!h)return null;let u=!1;l.startBlueConstruction();let d=new s.P;for(let t=0,i=e.getPointCount();t<i;t++)e.queryXY(t,d),a.contains(d)&&(u=!0,l.addBlueEnvelope(t,n.Envelope2D.construct(d.x,d.y,d.x,d.y)));return l.endBlueConstruction(),u?l:null}function Et(t){let e=new n.Envelope2D;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),function(t,e){let i=new n.Envelope2D;if(t.queryLooseEnvelope(i),i.isEmpty())return null;t.getGeometryType();let s=new V(i,8),o=-1,a=new n.Envelope2D,l=!1;do{for(let n=0,h=t.getPathCount();n<h;n++)if(t.queryLoosePathEnvelope(n,a),a.isIntersecting(e)){if(o=s.insertEx(n,a,o),-1===o){l&&(0,r.d)("build_quad_tree_for_paths"),i.assign(t.calculateEnvelope2D(!1)),l=!0,s.reset(i,8);break}l=!1}}while(l);return s}(t,e)}function Dt(t,e){if(!e){let e=new n.Envelope2D;t.queryLooseEnvelope(e);let i=new V(e,8),s=-1,o=new n.Envelope2D,a=t.querySegmentIterator(),l=!1;for(;a.nextPath();)for(;a.hasNextSegment();){let n=a.nextSegment(),h=a.getStartPointIndex();if(n.queryLooseEnvelope(o),s=i.insertEx(h,o,s),-1===s){l&&(0,r.d)(""),e.assign(t.calculateEnvelope2D(!1)),l=!0,i.reset(e,8),a.resetToFirstPath();break}}return i}let i=new n.Envelope2D;t.queryLooseEnvelope(i);let s=new V(i,8),o=-1,a=new n.Envelope2D,l=t.querySegmentIterator(),h=!1;for(;l.nextPath();)for(;l.hasNextSegment();){let n=l.nextSegment(),m=l.getStartPointIndex();if(n.queryLooseEnvelope(a),a.isIntersecting(e)&&(o=s.insertEx(m,a,o),-1===o)){h&&(0,r.d)(""),i.assign(t.calculateEnvelope2D(!1)),h=!0,s.reset(i,8),l.resetToFirstPath();break}}return s}function wt(t,e){if(e){let i=new V(e,8),o=new s.P,a=new n.Envelope2D,l=!1;for(let s=0;s<t.getPointCount();s++)if(o.setCoordsPoint2D(t.getXY(s)),e.contains(o)&&(a.setCoords({pt:o}),-1===i.insert(s,a))){l&&(0,r.d)(""),l=!0,i.reset(t.calculateEnvelope2D(),8),s=-1;continue}return i}return(0,r.a)("no-extent version not yet impl"),null}function St(t,e,i,s,r){let n=!1,o=r.vmin,a=r.vmax;for(let r=i;r<e;r+=s){let e=t.read(r);e<o?(n=!0,t.write(r,o)):e>a&&(n=!0,t.write(r,a))}return n}function At(t,e,i,s){if(!t.hasAttribute(i))return!1;let n=t.getGeometryType();if(n===r.G.enumGeometryCollection){let r=t,n=r.getGeometryCount(),o=0;for(let t=0;t<n;++t)o|=+!!At(r.getGeometry(t),e,i,s);return!!o}if((0,r.i)(n)){let n=t,o=Q.getPersistence(i),a=Q.getComponentCount(i),l=n.getPointCount();if(1===o){let t=St(n.getAttributeStreamRef(i),l*a,s,a,e);return t&&n.notifyModified(),t}if(2===o){let t=St(n.getAttributeStreamRef(i),l*a,s,a,e);return t&&n.notifyModified(),t}(0,r.d)("snap_coordinate not implemented")}if(n===r.G.enumEnvelope){let r=t,n=r.queryInterval(i,s),o=!1;return n.vmin<e.vmin&&(o=!0,n.vmin=e.vmin),n.vmax>e.vmax&&(o=!0,n.vmax=e.vmax),o&&r.setIntervalEnvelope(i,s,n),o}if(n===r.G.enumPoint){let r=t,n=r.getAttributeAsDbl(i,s),o=!1;return n<e.vmin&&(o=!0,n=e.vmin),n>e.vmax&&(o=!0,n=e.vmax),o&&r.setAttributeBasic(i,s,n),o}if((0,r.h)(n)){let r=t,n=r.getStartAttributeAsDbl(i,s),o=!1;return n<e.vmin&&(o=!0,n=e.vmin),n>e.vmax&&(o=!0,n=e.vmax),o&&r.setStartAttribute(i,s,n),n=r.getEndAttributeAsDbl(i,s),n<e.vmin&&(o=!0,n=e.vmin),n>e.vmax&&(o=!0,n=e.vmax),o&&r.setEndAttribute(i,s,n),o}(0,r.d)("snap_coordinate not implemented")}var Tt=d;class It{static type=r.G.enumPoint;m_description=null;x=NaN;y=NaN;m_attribs=null;constructor(t){if(t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=v(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=C(),this.ensureAttributes(),this.setXYZ(new g(t.x,t.y,t.z))):(this.m_description=v(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=v()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new s.P(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){let t=new g;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:Tt.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}isEqualXYCoords(t,e,i){return void 0===i&&(i=0),Math.abs(t-this.x)<=i&&Math.abs(e-this.y)<=i}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;(0,r.r)("")}let i=Tt.getComponentCount(t);(e<0||e>=i)&&(0,r.r)("");let s=this.m_description.getAttributeIndex(t);return s>=0?this.m_attribs[this.m_description.getPointAttributeOffset(s)-2+e]:Tt.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,i){if(0===t)return void(0===e?this.x=i:1===e?this.y=i:(0,r.r)(""));let s=Tt.getComponentCount(t);(e<0||e>=s)&&(0,r.r)("");let n=this.m_description.getAttributeIndex(t);n<0&&(this.addAttribute(t),n=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]=i}copyAttributesFrom(t,e){if(this===t)return;let i=t.getDescription(),s=e&&i.hasZ()?2:1;for(let e=s,r=i.getAttributeCount();e<r;++e){let s=i.getSemantics(e),r=Tt.getComponentCount(s);for(let e=0;e<r;++e){let i=t.getAttributeAsDbl(s,e);this.setAttributeBasic(s,e,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(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;let e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=v();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return r.G.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof Rt)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof E){if(this.isEmpty())return void t.setEmpty();let e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){let i=new s.E;if(this.isEmpty())return i.setEmpty(),i;let r=this.getAttributeAsDbl(t,e);return i.vmin=r,i.vmax=r,i}applyTransformation(t){if(!this.isEmpty()){if(1===t.m_TransformationType){let e=this.getXY();return t.transformInPlace(e),void this.setXY(e)}(0,r.a)("3d not impl")}}transformAttribute(t,e,i,s,r){if(this.isEmpty())return;this.addAttribute(t);let n=this.getAttributeAsDbl(t,e),o=$(i,s,r);this.setAttributeBasic(t,e,o(n))}createInstance(){return new It({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.b)();let e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=v(),this.releaseAttributes()),this.x=NaN,this.y=NaN,this.m_attribs&&(0,s.f)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==r.G.enumPoint)return!1;let i=t;if(this.m_description!==i.m_description||this.isEmpty()!==i.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-i.x)>e||Math.abs(this.y-i.y)>e)return!1;for(let t=0,r=this.m_description.getTotalComponentCount()-2;t<r;t++)if(!(0,s.a6)(this.m_attribs[t],i.m_attribs[t],e))return!1;return!0}getBoundary(){return null}clone(){let t=new It({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumPoint&&(0,r.b)("wrong geometry type");let e=t;e.m_description=(0,s.s)(this.m_description,this.m_description=e.m_description),e.x=(0,s.s)(this.x,this.x=e.x),e.y=(0,s.s)(this.y,this.y=e.y),e.m_attribs=(0,s.s)(this.m_attribs,this.m_attribs=e.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=Tt.getComponentCount(t);for(let s=0;s<i;s++){let i=this.getAttributeAsDbl(t,s);Number.isNaN(i)&&this.setAttributeBasic(t,s,e)}}lerp(t,e,i){if(t.getDescription()!==e.getDescription()&&(0,r.b)("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||e.isEmpty())return this.setEmpty(),this;this.ensureAttributes();let n=u();t.queryValues(n,n.length);let o=u();e.queryValues(o,o.length);let a=u(),l=n,h=o,m=a,d=0;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),r=Tt.getInterpolation(e),n=Tt.getComponentCount(e),o=Tt.getDefaultValue(e);(0,s.aa)(r,l,h,m,d,n,i,o),l=l.slice(n),h=h.slice(n),d+=n}return this.setValues(a,d),this}static lerp(t,e,i,s){s.lerp(t,e,i)}setDefaultAttributeValues(){let t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?(0,s.f)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return s.P.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){let e=y(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||=v();let e=_();b(t,this.m_description,e);let i=null;t.getTotalComponentCount()-2>0&&(i=t.getDefaultPointAttributes().slice(2));for(let s=1,r=t.getAttributeCount();s<r;s++){let r=e[s];if(-1!==r){let e=this.m_description.getPointAttributeOffset(r)-2,n=t.getPointAttributeOffset(s)-2,o=Tt.getComponentCount(t.getSemantics(s));for(let t=0;t<o;t++)i[n+t]=this.m_attribs[e+t]}}this.m_attribs=i,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){let i=this.m_description.getTotalComponentCount();(0,r.g)(i<=e),t[0]=this.x,t[1]=this.y,(0,s.f)(t,this.m_attribs,2,0,i-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;let e=t.getDescription();if(e===this.m_description)this.m_attribs&&(0,s.f)(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let i=0;for(let s=1,r=e.getAttributeCount();s<r;s++){let r=e.getSemantics(s),n=Tt.getComponentCount(r);if(this.m_description.hasAttribute(r)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(r))-2;for(;0!==n;)t.m_attribs[i++]=this.m_attribs[e++],n--}else{let e=Tt.getDefaultValue(r);for(;0!==n;)t.m_attribs[i++]=e,n--}}}}setValues(t,e){let i=this.m_description.getTotalComponentCount();(0,r.g)(i<=e),this.x=t[0],this.y=t[1],(0,s.f)(this.m_attribs,t,0,2,i-2)}dbgDefaultAttribs(){}toFlatGeometry(){let t=Float64Array.of(this.getX(),this.getY(),this.getZ(),this.getM());return{type:"point",vertexCount:1,vertexXY:t.subarray(0,2),vertexZ:this.hasAttribute(1)?t.subarray(2,3):void 0,vertexM:this.hasAttribute(2)?t.subarray(3,4):void 0,...F}}}var Mt=d;function qt(t,e){return e*(t.getTotalComponentCount()-2)}class Nt{m_envelope2D;m_attributes;constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new n.Envelope2D(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new n.Envelope2D(t.env2D);else if(t.move)this.m_envelope2D=new n.Envelope2D(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw Error("unrecognized EnvelopeData constructor options");{let e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new n.Envelope2D(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=n.Envelope2D.constructEmpty()}ensureAttributes(t){let e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=(0,s.c)(2*e,NaN),this.m_attributes.fill(NaN))}copyTo(t,e){let i=e,o=t.getTotalComponentCount()-2;if(i.m_description!==t&&(i.releaseAttributes_(),i.m_description=t,o&&(i.m_data.m_attributes=(0,s.c)(2*o,NaN))),o){(0,r.g)(this.m_attributes&&i.m_data.m_attributes);let t=2*o;(0,s.f)(i.m_data.m_attributes,this.m_attributes,0,0,t)}i.m_data.m_envelope2D=new n.Envelope2D(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new n.Envelope2D(this.m_envelope2D),e.releaseAttributes(),t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}transformAttribute(t,e,i,s,n){(0,r.g)(0)}queryInterval(t,e,i,s){if(this.isEmpty())return void s.setEmpty();if(0===e)return void(0===i?this.m_envelope2D.queryIntervalX(s):1===i?this.m_envelope2D.queryIntervalY(s):(0,r.r)(""));let n=Mt.getComponentCount(e);(i<0||i>=n)&&(0,r.r)("");let o=t.getAttributeIndex(e);if(o>=0)return s.vmin=this.m_attributes[qt(t,0)+t.getPointAttributeOffset(o)-2+i],void(s.vmax=this.m_attributes[qt(t,1)+t.getPointAttributeOffset(o)-2+i]);{let t=Mt.getDefaultValue(e);return void s.setCoords(t,t)}}queryEnvelope3D(t,e){let i=new s.E;this.queryInterval(t,1,0,i),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,i.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,i.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();let e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=(0,s.c)(2*e,NaN),this.m_attributes.fill(NaN))}dbgAssertSize(t){}}let Rt=class t{static type=r.G.enumEnvelope;m_EnvelopeType=4;m_description;m_data;constructor(t){if(this.m_description=v(),void 0===t)this.m_data=new Nt;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Nt,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Nt({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Nt({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new Nt,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new Nt({move:t.move.m_data});else{if(!t.centerPoint)throw Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new Nt,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new Nt({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,i,s,n){(0,r.g)(0)}setAttributeBasic(t,e,i){if(this.addAttribute(t),this.m_data.isEmpty())return;let s=this.queryInterval(t,e);s.vmin=i,s.vmax=i,this.setIntervalEnvelope(t,e,s)}mergeVertexDescriptionImpl(t){let e=y(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new n.Envelope2D(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return r.G.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?NaN:this.m_data.m_envelope2D.height()}getCenterXY(){return this.m_data.isEmpty()?new s.P:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();let e=this.m_description.getAttributeCount();for(let i=1;i<e;i++){let e=this.m_description.getSemantics(i),s=Mt.getComponentCount(e);for(let i=0;i<s;i++){let s=.5*(this.getAttributeAsDblImpl(0,e,i)+this.getAttributeAsDblImpl(1,e,i));t.setAttributeBasic(e,i,s)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,i,s){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:i,ymax:s})}setEnvelope(t){if(t instanceof n.Envelope2D)this.m_data.m_envelope2D=new n.Envelope2D(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();let e=s.E.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){if(e instanceof n.Envelope2D)return e.isValid()||(0,r.b)(""),void this.m_data.m_envelope2D.mergeEnvelope2D(e);if(e instanceof t){if(e.m_data.isEmpty())return;let t=e.getDescription();this.mergeVertexDescription(t),this.m_data.m_envelope2D.mergeEnvelope2D(e.m_data.m_envelope2D);for(let i=1,s=t.getAttributeCount();i<s;i++){let s=t.getSemantics(i),r=Mt.getComponentCount(s);for(let t=0;t<r;t++){let i=e.queryInterval(s,t),r=this.queryInterval(s,t);r.merge(i),this.setIntervalEnvelope(s,t,r)}}return}if(e instanceof It){let t=e;if(t.isEmpty())return;let i=t.getDescription();if(this.mergeVertexDescription(i),this.m_data.isEmpty())return void this.setFromPoint(t);this.m_data.m_envelope2D.merge(t.getXY());for(let e=1,s=i.getAttributeCount();e<s;e++){let s=i.getSemantics(e),r=Mt.getComponentCount(s);for(let e=0;e<r;e++){let i=t.getAttributeAsDbl(s,e),r=this.queryInterval(s,e);r.mergeCoordinate(i),this.setIntervalEnvelope(s,e,r)}}return}(0,r.a)("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;let e=t.getDescription();this.mergeVertexDescription(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e),s=Mt.getComponentCount(i);for(let e=0;e<s;e++){let s=t.queryInterval(i,e),r=this.queryInterval(i,e);r.intersect(s),this.setIntervalEnvelope(i,e,r)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;let e=t.getDescription();for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i);if(!e.hasAttribute(s))continue;let r=Mt.getComponentCount(s);for(let e=0;e<r;e++){let i=t.queryInterval(s,e),r=this.queryInterval(s,e);r.intersect(i),this.setIntervalEnvelope(s,e,r)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,i){if(this.addAttribute(t),this.m_data.isEmpty())return;let n=new s.E(i);if(n.normalize(),0===t){if(n.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=n.vmin,this.m_data.m_envelope2D.xmax=n.vmax):1===e?(this.m_data.m_envelope2D.ymin=n.vmin,this.m_data.m_envelope2D.ymax=n.vmax):(0,r.r)("")}else this.setAttributeAsDblImpl(0,t,e,n.vmin),this.setAttributeAsDblImpl(1,t,e,n.vmax)}setInterval(t,e,i,r){this.setIntervalEnvelope(t,e,new s.E(i,r))}queryInterval(t,e){let i=new s.E;return this.m_data.queryInterval(this.m_description,t,e,i),i}queryEnvelope(t){2!==t.m_EnvelopeType?3!==t.m_EnvelopeType?4!==t.m_EnvelopeType?(0,r.a)("unrecognized type for queryEnveloper"):this.copyTo(t):this.m_data.queryEnvelope3D(this.m_description,t):t.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?(0,r.g)(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new t({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||=v(),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return(0,r.g)(0),0}equals(t,e){if(t===this)return!0;let i=t;if(this.m_description!==i.m_description||this.m_data.isEmpty()!==i.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-i.m_data.m_envelope2D.xmin)>e||Math.abs(this.m_data.m_envelope2D.ymin-i.m_data.m_envelope2D.ymin)>e||Math.abs(this.m_data.m_envelope2D.xmax-i.m_data.m_envelope2D.xmax)>e||Math.abs(this.m_data.m_envelope2D.ymax-i.m_data.m_envelope2D.ymax)>e)return!1;for(let t=0,r=2*(this.m_description.getTotalComponentCount()-2);t<r;t++)if(!(0,s.a6)(this.m_data.m_attributes[t],i.m_data.m_attributes[t],e))return!1;return!0}getBoundary(){return(0,r.a)("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new t({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==r.G.enumEnvelope&&(0,r.b)("wrong geometry type");let e=t;e.m_description=(0,s.s)(this.m_description,this.m_description=e.m_description),e.m_data.m_envelope2D=(0,s.s)(this.m_data.m_envelope2D,this.m_data.m_envelope2D=e.m_data.m_envelope2D),e.m_data.m_attributes=(0,s.s)(this.m_data.m_attributes,this.m_data.m_attributes=e.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&(0,r.b)(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&(0,r.r)(""),e.assignVertexDescription(this.m_description);let i=this.getDescription().getAttributeCount();for(let s=1;s<i;s++){let i=this.m_description.getSemantics(s),r=Mt.getComponentCount(i);for(let s=0;s<r;s++)e.setAttributeBasic(i,s,this.getAttributeAsDblImpl(t%2,i,s))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&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;let e=P(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=x(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=v();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;let i=Mt.getComponentCount(t);for(let s=0;s<i;s++){let i=this.queryInterval(t,s);i.isEmpty()&&(i.vmin=e,i.vmax=e,this.setIntervalEnvelope(t,s,i))}}getImpl(){return this}setFromPoint(t,e,i){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:i??0});let s=t.getDescription();for(let e=1,i=s.getAttributeCount();e<i;e++){let i=s.getSemantics(e),r=Mt.getComponentCount(i);for(let e=0;e<r;e++){let s=t.getAttributeAsDbl(i,e);this.setInterval(i,e,s,s)}}}assignVertexDescriptionImpl(t){let e=_();b(t,this.m_description,e);let i=null,r=t.getTotalComponentCount()-2,n=this.m_description?this.m_description.getTotalComponentCount()-2:0;r>0&&(i=(0,s.c)(2*r,NaN));for(let o=1;o<t.getAttributeCount();o++){let a=e[o];if(-1!==a){let e=t.getPointAttributeOffset(o)-2,l=Mt.getComponentCount(t.getSemantics(o)),h=this.m_description.getPointAttributeOffset(a)-2;(0,s.f)(i,this.m_data.m_attributes,e,h,l),(0,s.f)(i,this.m_data.m_attributes,r+e,n+h,l)}}this.releaseAttributes_(),this.m_data.m_attributes=i,this.m_description=t}getAttributeAsDblImpl(t,e,i){if(this.m_data.isEmpty()&&(0,r.B)(""),0===e)return t?i?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:i?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;i>=Mt.getComponentCount(e)&&(0,r.r)("");let s=this.m_description.getAttributeIndex(e);return s>=0?this.m_data.m_attributes[qt(this.m_description,t)+this.m_description.getPointAttributeOffset(s)-2+i]:d.getDefaultValue(e)}setAttributeAsDblImpl(t,e,i,s){0===e&&(t?1===i?this.m_data.m_envelope2D.ymax=s:0===i?this.m_data.m_envelope2D.xmax=s:(0,r.r)(""):1===i?this.m_data.m_envelope2D.ymin=s:0===i?this.m_data.m_envelope2D.xmin=s:(0,r.r)(""));let n=Mt.getComponentCount(e);(i<0||i>=n)&&(0,r.r)(""),this.addAttribute(e);let o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[qt(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+i]=s}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}};Object.freeze(Object.defineProperty({__proto__:null,Envelope:Rt,EnvelopeData:Nt},Symbol.toStringTag,{value:"Module"})),i.d(e,["$",0,F,"G",0,-559038737])},88885(t,e,i){i.d(e,{$:()=>Sn,A:()=>St,B:()=>Dn,C:()=>pi,D:()=>qr,E:()=>mi,F:()=>Ir,H:()=>Mr,I:()=>vs,J:()=>dr,K:()=>cn,L:()=>Yn,M:()=>W,N:()=>z,O:()=>x,P:()=>ni,Q:()=>Ut,R:()=>B,S:()=>Xn,T:()=>wn,U:()=>R,V:()=>li,W:()=>Tn,X:()=>rt,Y:()=>_,Z:()=>g,_:()=>Zr,a:()=>Dt,a0:()=>An,a1:()=>qn,a2:()=>hi,a3:()=>wr,a4:()=>br,a5:()=>hn,a6:()=>mn,a7:()=>en,a8:()=>Lr,a9:()=>yt,b:()=>Cr,c:()=>At,d:()=>Tr,e:()=>ci,f:()=>ui,g:()=>O,i:()=>gi,l:()=>Ar,s:()=>k,x:()=>fe,y:()=>ct,z:()=>_t});var s=i(55537),r=i(95213),n=i(83661),o=i(79187),a=i(11878),l=i(61691);class h{m_EnvelopeType=5;envAabb=o.Envelope2D.constructEmpty();envRot=o.Envelope2D.constructEmpty();static constructEmpty(){return new h}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:m(t),y:u(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(m(t),u(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let i=0;i<e;){if(!this.envRot.isEmpty()){for(let s=i;s<e;s++){let e=m(t[s]),i=u(t[s]);this.envRot.mergeNeCoords(e,i)}break}{let e=m(t[i]),s=u(t[i]);this.envRot.setCoords({x:e,y:s}),i++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(m(t),u(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){let e=this.envAabb.intersect(t.envAabb),i=this.envRot.intersect(t.envRot);return e&&!i&&this.envAabb.setEmpty(),i&&!e&&this.envRot.setEmpty(),e&&i}inflate(t){this.envAabb.inflateCoords(t,t);let e=t*(0,n.a4)();this.envRot.inflateCoords(e,e),e<0&&h.st_reduceEmpty(this)}static st_reduceEmpty(t){let e=t.envAabb.isEmpty(),i=t.envRot.isEmpty();e&&!i?t.envRot.setEmpty():i&&!e&&t.envAabb.setEmpty()}sqrMaxMinDistance(t){let e=this.envAabb.sqrMaxMinDistance(t),i=this.envRot.sqrMaxMinDistance(d(t))/2;return Math.max(e,i)}sqrMinDistance(t){let e=this.envAabb.sqrMinDistance(t),i=this.envRot.sqrMinDistance(d(t))/2;return Math.max(e,i)}sqrMaxDistance(t){let e=this.envAabb.sqrMaxDistance(t),i=this.envRot.sqrMaxDistance(d(t))/2;return Math.max(e,i)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){let i=function(t,e){return t-e}(t.x,t.y),s=function(t,e){return t+e}(t.x,t.y);e.setCoords(i,s)}}function m(t){return t.x-t.y}function u(t){return t.x+t.y}function d(t){return new n.P(m(t),u(t))}class g{x=n.Z.getNAN();y=n.Z.getNAN();static getNAN(){return new g}static constructPoint2D(t){let e=new g;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){let i=new g;return i.x.set(t),i.y.set(e),i}static constructCoordsE(t,e){let i=new g;return i.setCoordsE(t,e),i}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 g).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(){let t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){let e=new g;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){let e=new g;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(){let t=this.length();0===t.value()?(this.x=n.a7.clone(),this.y=n.T.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){let i=this.x.mulE(t).subThisE(this.y.mulE(e)),s=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(i),this.y.setE(s),this}rotateReverse(t,e){let i=this.x.mulE(t).addThisE(this.y.mulE(e)),s=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(i),this.y.setE(s),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 n.P.construct(this.x.value(),this.y.value())}}class c{a11=new n.Z(1);a12=new n.Z(0);a21=new n.Z(0);a22=new n.Z(1);clone(){let t=new c;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){let e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),i=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),s=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),r=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=i,this.a21=s,this.a22=r,this}mulLeftThis(t){let e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){let t=this.det();if(0!==t.value()){let e=this.a22.divE(t),i=this.a12.negate().divThisE(t),s=this.a21.negate().divThisE(t),r=this.a11.divE(t);this.a11=e,this.a12=i,this.a21=s,this.a22=r}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=(0,n.s)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){let i=this.a12.clone();i.addThisE(this.a21),i.mulThisByPower2(.5);let s=new n.Z(1),r=new n.Z(0);if(i.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{let e=new n.Z(1);if(this.a11.ne(this.a22)){let o=this.a11.subE(this.a22).divE(i);o.mulThisByPower2(.5);let a=o.sqr();e.setE(o),e.absThis(),e.subThisE(a.add(1).sqrtThis()),o.gt(n.T)&&e.negateThis();let l=e.sqr().addThis(1).sqrtThis().invThis();r=e.mulE(l),s.setE(l);let h=e.mulE(i);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else s=new n.Z(1/Math.sqrt(2)),r=s.clone(),t[0]=this.a11.addE(i),t[1]=this.a22.subE(i)}e[0].x=s.toDouble(),e[0].y=r.toDouble(),e[1].x=r.negate().toDouble(),e[1].y=s.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,n.s)(t[0],t[0]=t[1]),e[1]=(0,n.s)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class _{x;y;static constructPoint2D(t){return new _(n.M.constructDouble(t.x),n.M.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new n.M).setNAN(),void(this.y=(new n.M).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 n.P(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){let t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new _(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new _(this.x.add(t.x),this.y.add(t.y))}sub(t){return new _(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 p=r.V;function f(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.a5)(t[0][i],t[3][i]);s>0?((0,n.a5)(t[0][i],t[1][i])<0&&(t[1][i]=t[0][i],e=!0),(0,n.a5)(t[1][i],t[3][i])<0&&(t[1][i]=t[3][i],e=!0),(0,n.a5)(t[0][i],t[2][i])<0&&(t[2][i]=t[0][i],e=!0),(0,n.a5)(t[2][i],t[3][i])<0&&(t[2][i]=t[3][i],e=!0),(0,n.a5)(t[1][i],t[2][i])<0&&(t[2][i]=t[1][i],e=!0)):s<0?((0,n.a5)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.a5)(t[1][i],t[3][i])>0&&(t[1][i]=t[3][i],e=!0),(0,n.a5)(t[0][i],t[2][i])>0&&(t[2][i]=t[0][i],e=!0),(0,n.a5)(t[2][i],t[3][i])>0&&(t[2][i]=t[3][i],e=!0),(0,n.a5)(t[1][i],t[2][i])>0&&(t[2][i]=t[1][i],e=!0)):(t[1][i]!==t[0][i]||t[2][i]!==t[0][i])&&(t[1][i]=t[0][i],t[2][i]=t[0][i],e=!0)}return e}function y(t,e){let i=t.getStartXY();if(i.equals(e.getStartXY())||i.equals(e.getEndXY()))return!0;let s=t.getEndXY();return!(!s.equals(e.getStartXY())&&!s.equals(e.getEndXY()))}function P(t,e){let i=t.calculateLowerLength2D();return!(i>e)&&(!!(t.isLine()||(i=t.calculateUpperLength2D(),i<=e))||0!==e&&t.calculateLength2D()<=e)}function x(t,e,i){let r=(0,n.d)(n.P,4),o=t.queryControlPointsHelper(r),a=(0,n.d)(n.P,4),l=e.queryControlPointsHelper(a);r[0].equals(a[0])||(0,s.A)("");let h=t.getGeometryType();if(h===e.getGeometryType()&&r.map((t,e)=>a[e].equals(t)).reduce((t,e)=>t&&e)){if(h!==s.G.enumRationalBezier2)return 0;{let i=e,s=[0,0,0],r=[0,0,0];if(t.queryWeights(s),i.queryWeights(r),s.map((t,e)=>r[e]===t).reduce((t,e)=>t&&e))return 0}}for(;o>2&&r[1].equals(r[0]);)r.splice(1,1),o--;for(;l>2&&a[1].equals(a[0]);)a.splice(1,1),l--;(r[1].equals(r[0])||a[1].equals(r[0]))&&(0,s.A)("");let m=n.P.compareVectorsOrigin(r[0],r[1],a[1]);if(0===m){let i=_.constructPoint2D(r[0]),s=new _;t.queryCoord2DMP(1e-16,s),s.sub(i);let n=new _;return e.queryCoord2DMP(1e-16,n),n.sub(i),n.crossProduct(s).sign()}return m}function v(t,e,i,r,o,a,l,h){let m=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),d=t,g=e,c=!1;m>u&&(g=(0,n.s)(d,d=g),r=(0,n.s)(i,i=r),u=(0,n.s)(m,m=u),c=!0);let _=0===i;{l[0]=+!!_;let t=d.getCoord2D(l[0]);h[0]=g.getClosestCoordinate(t,!1);let e=g.getCoord2D(h[0]);if(n.P.distance(t,e)<=o){let e=[.5,.75,.25,.1,.9],i=!0;for(let s=0;s<e.length;s++)if(t.assign(d.getCoord2D(e[s])),!g.isCloserThanDistance(t,new n.E(0,1),o)){i=!1;break}if(i)return c&&(h[0]=(0,n.s)(l[0],l[0]=h[0])),1}}if(m<=3*o)return 0;let p=(0,n.a)(Math.max(o/m,.1),0,.5),f=.01*o,y=0,P=0,x=p,v=-1,C=0,b=1/32;for(let t=0;;t++){(0,s.g)(t<4095);let e=_?p:1-p,i=d.getCoord2D(e),m=g.getClosestCoordinate(i,!1);if(m===r)return C;let u=g.getCoord2D(m),E=n.P.distance(i,u);if(0===t&&(v=E),E<=f?(b=.5,P=E,y=p):(x=p,v=E),Math.abs(P-v)>.1*f&&x-y>1e-16)p=(0,n.r)(y,x,b);else{if(l[C]=e,h[C]=m,c&&(h[C]=(0,n.s)(l[C],l[C]=h[C])),1===a||1===C)return 1===C&&l[0]>l[1]&&(l[1]=(0,n.s)(l[0],l[0]=l[1]),h[1]=(0,n.s)(h[0],h[0]=h[1])),C+1;C++,y=x,P=v,x=.8,v=-1,p=.8,b=1/32,f=10*o,t=0}}}function C(t,e,i,s,r,o,a,l,h){if((0,n.a9)(i,0,1)&&(0,n.a9)(s,0,1)&&0===n.P.distance(t.getCoord2D(i),e.getCoord2D(s))){let h=1e-12,m=new g,u=(0,n.I)();if(t.queryDerivative(new n.Z(i,u),m),m.isTrueZero()){let e=1===i?-1e-12:h;t.queryDerivative(new n.Z(i,u).add(e),m)}1===i&&m.negateThis();let d=new g;if(e.queryDerivative(new n.Z(s,u),d),d.isTrueZero()){let t=1===i?-1e-12:h;e.queryDerivative(new n.Z(s,u).add(t),d)}1===s&&d.negateThis(),m.isZero()||m.normalize(),d.isZero()||d.normalize();let c=m.dotProduct(d),_=m.crossProduct(d);if(_.scaleError(3),c.ge(n.T)&&(_.isZero()||Math.abs(_.value())<(()=>{{let i=t.calculateUpperLength2D(),s=e.calculateUpperLength2D();return Math.min(.01*r/Math.min(i,s),1e-10)}})()))return v(t,e,i,s,r,o,a,l)}return 0}function b(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function E(t,e,i){t.m_XStart=e,t.m_YStart=i}function D(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function w(t,e,i){t.m_XEnd=e,t.m_YEnd=i}function S(t,e){let i=new r.k;return e?(i.x=t.m_XEnd,i.y=t.m_YEnd):(i.x=t.m_XStart,i.y=t.m_YStart),i.z=function(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:p.getDefaultValue(1)}(t,e),i}function A(t,e,i){t.m_description.hasZ()||t.addAttribute(1),e?(t.m_XEnd!==i.x||t.m_YEnd!==i.y)&&(t.m_XEnd=i.x,t.m_YEnd=i.y,t.endPointModified()):(t.m_XStart!==i.x||t.m_YStart!==i.y)&&(t.m_XStart=i.x,t.m_YStart=i.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=i.z}function T(t,e,i){i.assignVertexDescription(t.m_description);let s=0===e?t.m_XStart:t.m_XEnd,r=0===e?t.m_YStart:t.m_YEnd;i.setXYCoords(s,r);for(let s=1;s<t.m_description.getAttributeCount();s++){let r=t.m_description.getSemantics(s);for(let s=0,n=p.getComponentCount(r);s<n;s++){let n=M(t,e,r,s);i.setAttributeBasic(r,s,n)}}}function I(t,e,i){i.isEmpty()&&(0,s.B)(""),function(t,e,i){e?(t.m_XEnd!==i.x||t.m_YEnd!==i.y)&&(t.m_XEnd=i.x,t.m_YEnd=i.y,t.endPointModified()):(t.m_XStart!==i.x||t.m_YStart!==i.y)&&(t.m_XStart=i.x,t.m_YStart=i.y,t.endPointModified())}(t,e,i.getXY());let r=i.getDescription();r!==t.m_description&&t.mergeVertexDescription(r);for(let s=1,n=r.getAttributeCount();s<n;s++){let n=r.getSemantics(s),o=p.getComponentCount(n);for(let s=0;s<o;s++)q(t,e,n,s,i.getAttributeAsDbl(n,s))}}function M(t,e,i,r){if((e<0||e>1)&&(0,s.r)(""),0===i)return(r<0||r>=2)&&(0,s.r)(""),0===e?0===r?t.m_XStart:t.m_YStart:0===r?t.m_XEnd:t.m_YEnd;let n=p.getComponentCount(i);(r<0||r>=n)&&(0,s.r)("");let o=t.m_description.getAttributeIndex(i);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+r]:p.getDefaultValue(i)}function q(t,e,i,r,n){if((e<0||e>1)&&(0,s.r)(""),0===i)return 0===e?0===r?t.m_XStart=n:1===r?t.m_YStart=n:(0,s.r)(""):1===e?0===r?t.m_XEnd=n:1===r?t.m_YEnd=n:(0,s.r)(""):(0,s.r)(""),void t.endPointModified();let o=p.getComponentCount(i);(r<0||r>=o)&&(0,s.r)("");let a=t.m_description.getAttributeIndex(i);a<0&&(t.addAttribute(i),a=t.m_description.getAttributeIndex(i)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+r]=n}function N(t,e){if(t===e)return;e.isEmpty()&&(0,s.B)("");let i=e.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let s=1,r=i.getAttributeCount();s<r;s++){let r=i.getSemantics(s),n=p.getComponentCount(r);for(let i=0;i<n;i++){let s=M(e,0,r,i);q(t,0,r,i,s),s=M(e,1,r,i),q(t,1,r,i,s)}}}function R(t){return t.absNorm()*(0,n.g)()}function Y(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,n.g)()}function X(t,e,i){let s=new h;t.queryEnvelopeW(n.E.unit(),s);let r=new h;return e.queryEnvelopeW(n.E.unit(),r),r.inflate(i),!s.isIntersectingW(r)}function F(t,e,i){let s=(0,n.a8)(t,i),r=(0,n.a8)(e,i);s.sort((t,e)=>t.compare(e)),r.sort((t,e)=>t.compare(e));for(let t=0;t<3;t++){if(s[t].compare(r[t])<0)return-1;if(0!==s[t].compare(r[t]))return 1}return 0}var L=r.V;class z{m_XStart;m_YStart;m_XEnd;m_YEnd;m_attributes;m_description;constructor(t){return t.copy?(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,void(this.m_description&&this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice()))):t.move?(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)):void 0!==t.XStart?(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:(0,r.K)(),void(t.vd&&this.setDefaultAttributeValues())):void 0!==t.ZStart?(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:(0,r.L)(),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])):t.start?(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=(0,r.K)())):t.start3D?(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:(0,r.L)(),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])):((0,s.d)("bad constructor params"),void(this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=NaN))}setDefaultAttributeValues(){let t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=(0,n.c)(2*t,NaN)),(0,n.f)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,n.f)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,s.a)("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return(0,s.a)("not implemented"),!1}setCoordsForIntersector3D(t,e,i){(0,s.a)("not implemented")}transformAttribute(t,e,i,r,n){(0,s.a)("")}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.M)(e,t);this.assignVertexDescription(i)}changeEndPoints(t,e){let i=t.getXY(),s=e.getXY();this.changeEndPoints2D(i,s);let r=t.getDescription();r!==this.getDescription()&&this.mergeVertexDescription(r),r=e.getDescription(),r!==this.getDescription()&&this.mergeVertexDescription(r);for(let i=1,s=r.getAttributeCount();i<s;i++){let s=r.getSemantics(i),n=L.getComponentCount(s);for(let i=0;i<n;i++)q(this,0,s,i,t.getAttributeAsDbl(s,i)),q(this,1,s,i,e.getAttributeAsDbl(s,i))}}getStartXY(){return new n.P(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 S(this,0)}setStartXYZ(t){A(this,0,t)}setStartXYZCoords(t,e,i){A(this,0,r.k.construct(t,e,i))}queryStart(t){T(this,0,t)}setStart(t){I(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return M(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,s.g)(0),0}setStartAttribute(t,e,i){q(this,0,t,e,i)}setStartAttributesFromPoint(t,e){let i=t.getDescription(),s=e&&i.hasZ()?2:1;for(let e=s,r=i.getAttributeCount();e<r;++e){let s=i.getSemantics(e),r=L.getComponentCount(s);for(let e=0;e<r;++e){let i=t.getAttributeAsDbl(s,e);this.setStartAttribute(s,e,i)}}}setEndAttributesFromPoint(t,e){let i=t.getDescription(),s=e&&i.hasZ()?2:1;for(let e=s,r=i.getAttributeCount();e<r;++e){let s=i.getSemantics(e),r=L.getComponentCount(s);for(let e=0;e<r;++e){let i=t.getAttributeAsDbl(s,e);this.setEndAttribute(s,e,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,s.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,s.g)(0),0}getEndXY(){return new n.P(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 S(this,1)}setEndXYZ(t){A(this,1,t)}setEndXYZCoords(t,e,i){A(this,1,r.k.construct(t,e,i))}queryEnd(t){T(this,1,t)}setEnd(t){I(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return M(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,s.g)(0),0}setEndAttribute(t,e,i){q(this,1,t,e,i)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,s.b)("");let e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&(0,n.f)(e.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),e.m_XStart=this.m_XStart,e.m_YStart=this.m_YStart,e.m_XEnd=this.m_XEnd,e.m_YEnd=this.m_YEnd,this.copyToImpl(e)}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){let i=n.E.constructEmpty();return i.vmin=M(this,0,t,e),i.vmax=i.vmin,i.mergeNeCoordinate(M(this,1,t,e)),i}calculateLength3D(t){return(0,s.g)(0),0}getCoord3D(t){return(0,s.g)(0),{}}getCoord2D(t){let e=n.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,s.g)(0)}getCoordZ(t){return(0,s.g)(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),r=L.getComponentCount(s);for(let i=0;i<r;i++){let r=this.getAttributeAsDbl(t,s,i);e.setAttributeBasic(s,i,r)}}}isCloserThanDistance(t,e,i){let s=o.Envelope2D.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,s),s.distance(t)>i)return!1;let r=this.getClosestCoordinateOnInterval(t,e,i);return!Number.isNaN(r)&&n.P.distance(t,this.getCoord2D(r))<=i}isMonotoneQuickAndDirty(){return!1}static s_maxMonotonicPartParams=8;isTrue3D(){return!1}getReversed(){let t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,n.s)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.s)(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t);for(let t=0,i=L.getComponentCount(e);t<i;t++){let i=M(this,0,e,t);q(this,0,e,t,M(this,1,e,t)),q(this,1,e,t,i)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,i,r){if(!e&&this.isIntersecting(t,0,!1)){if(null!==i||null!==r){let e=(0,n.c)(9,NaN),o=(0,n.c)(9,NaN),a=this.intersect(t,null,e,o,0);(0,s.g)(a<=9),0===a&&(0,s.d)(""),null!==i&&(i[0]=e[0]),null!==r&&(r[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,l=-1,h=a;return o=this.getStartXY(),l=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==r&&(r[0]=l),null!==i&&(i[0]=0)),o=this.getEndXY(),l=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==r&&(r[0]=l),null!==i&&(i[0]=1)),o=t.getStartXY(),l=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==i&&(i[0]=l),null!==r&&(r[0]=0)),o=t.getEndXY(),l=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(l)),h=o.length(),h<a&&(a=h,null!==i&&(i[0]=l),null!==r&&(r[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,i){return(0,n.r)(t,e,i)}moveTo(t){let e=this.isClosed(),i=new a.T;i.setShift(t.sub(this.getStartXY())),this.applyTransformation(i),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){(0,s.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){let i=(0,r.Q)();(0,r.R)(e,t.m_description,i);let s=null,o=e.getTotalComponentCount()-2,a=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(o>0&&(s=(0,n.c)(2*o,NaN),(0,n.f)(s,e.getDefaultPointAttributes(),0,2,o),(0,n.f)(s,e.getDefaultPointAttributes(),o,2,o),null!==t.m_description))for(let r=1;r<e.getAttributeCount();r++){let n=i[r];if(-1!==n){let i=t.m_description.getPointAttributeOffset(n)-2,l=e.getPointAttributeOffset(r)-2,h=p.getComponentCount(e.getSemantics(r));for(let e=0;e<h;++e)s[l]=t.m_attributes[i],s[o+l]=t.m_attributes[a+i]}}t.m_attributes=s,t.m_description=e}(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;let e=(0,r.N)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.O)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.K)();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,s.b)("wrong geometry type");let e=t;e.m_description=(0,n.s)(this.m_description,this.m_description=e.m_description),e.m_XStart=(0,n.s)(this.m_XStart,this.m_XStart=e.m_XStart),e.m_YStart=(0,n.s)(this.m_YStart,this.m_YStart=e.m_YStart),e.m_XEnd=(0,n.s)(this.m_XEnd,this.m_XEnd=e.m_XEnd),e.m_YEnd=(0,n.s)(this.m_YEnd,this.m_YEnd=e.m_YEnd),e.m_attributes=(0,n.s)(this.m_attributes,this.m_attributes=e.m_attributes),this.swapImpl(e)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;let i=void 0===e;i&&(e=0);let s=t;if(this===s)return!0;if(this.m_description!==s.m_description||Math.abs(this.m_XStart-s.m_XStart)>e||Math.abs(this.m_XEnd-s.m_XEnd)>e||Math.abs(this.m_YStart-s.m_YStart)>e||Math.abs(this.m_YEnd-s.m_YEnd)>e)return!1;for(let t=0,i=2*(this.m_description.getTotalComponentCount()-2);t<i;t++)if(!(0,n.a6)(this.m_attributes[t],s.m_attributes[t],e))return!1;return i?this.equalsImpl(s):this.equalsImplTol(s,e)}getImpl(){return this}setAttributeBasic(t,e,i){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,s.b)("");let t=new a.T,r=0===e?i:0,n=1===e?i:0;t.setShiftCoords(r,n),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,e,i),this.setEndAttribute(t,e,i)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=L.getComponentCount(t);for(let s=0;s<i;s++){let i=this.getStartAttributeAsDbl(t,s);Number.isNaN(i)&&this.setStartAttribute(t,s,e);let r=this.getEndAttributeAsDbl(t,s);Number.isNaN(r)&&this.setEndAttribute(t,s,e)}}}class V{posStream=null;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=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 B(t,e,i){if(t)for(let t=e.length-1;t>=0;--t)i(e[t]);else e.forEach(i)}function k(t,e){let i=(0,n.Q)(t),s=e.length/(0,n.i)();for(let t=0;t<e.length;++t){let t=Math.trunc(i*s);i=(0,n.Q)(i);let r=Math.trunc(i*s),o=e[t];e[t]=e[r],e[r]=o}}var G=r.V;const Z="can not assign an empty point to a vertex";class H{constructor(t){if(void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=(0,r.K)(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new V,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new r.U,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{let e=void 0!==t&&t.vd?t.vd:(0,r.K)();this.m_description=e,this.m_vertexAttributes=new V,this.m_envelopeData=new r.U,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!(0,s.i)(t.getGeometryType()))return!1;let i=t;if(this===i)return!0;if(!this.m_description.equals(i.getDescription())||this.isEmptyImpl()!==i.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;let r=this.getPointCount();if(r!==i.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){let s=this.m_description.getSemantics(t),n=this.getAttributeStreamRef(s),o=i.getAttributeStreamRef(s),a=G.getComponentCount(s);if(!n.equals(o,0,r*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,i,n,o){if(this.addAttribute(t),!this.isEmpty()&&(0!==i||1!==n)){if(0===t){let t=new a.T;return 0===o?0===e?(t.setShiftCoords(i,0),t.scale(n,1)):1===e?(t.setShiftCoords(0,i),t.scale(1,n)):(0,s.b)(""):0===e?(t.setScaleCoords(1/n,1),t.shiftCoords(-i,0)):1===e?(t.setScaleCoords(1,1/n),t.shiftCoords(0,-i)):(0,s.b)(""),void this.applyTransformation(t)}(function(t,e,i,r,n){(e<0||i<0||r<1||e+r*(i-1)+1>t.size())&&(0,s.b)("Index out of bound");for(let s=e,o=e+r*(i-1)+1;s<o;s+=r)t.writeAsDbl(s,n(t.readAsDbl(s)))})(this.getAttributeStreamRef(t),e,this.getPointCount(),G.getComponentCount(t),(0,r._)(i,n,o)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.M)(e,t);this.assignVertexDescription(i)}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;let e=(0,r.N)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.O)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.K)();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,s.b)("AttributeStream : Geometry does not have the attribute");let e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,s.b)("stream"),e&&G.getPersistence(t)!==e.getPersistence()&&(0,s.b)(""),this.addAttribute(t);let i=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(i,e),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){let i=e;i.assignVertexDescription(this.m_description);for(let e=0;e<this.m_description.getAttributeCount();e++){let s=this.m_description.getSemantics(e);for(let r=0,n=G.getComponentCount(s);r<n;r++){let o=this.m_vertexAttributes.get(e).readAsDbl(n*t+r);i.setAttributeBasic(s,r,o)}}}setPointByValNoCurves(t,e){let i=e;i.isEmpty()&&(0,s.b)(Z);let r=i.getDescription();r!==this.m_description&&this.mergeVertexDescription(r);let n=this.m_vertexAttributes.get(0);n.write(2*t,i.getX()),n.write(2*t+1,i.getY());for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){let s=this.m_description.getSemantics(e),r=G.getComponentCount(s);for(let n=0;n<r;n++){let o=i.getAttributeAsDbl(s,n);this.m_vertexAttributes.get(e).writeAsDbl(t*r+n,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,i,r){(0,s.g)(0)}getPointByValAsArray(t,e,i,r){(0,s.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,i){let r=G.getComponentCount(t);i>=r&&(0,s.r)("");let n=this.m_description.getAttributeIndex(t);return n>=0?this.m_vertexAttributes.get(n).readAsDbl(e*r+i):G.getDefaultValue(t)}queryAttributeAsDbl(t,e,i,r){let n=G.getComponentCount(t);r<n&&(0,s.r)("");let o=this.m_description.getAttributeIndex(t);if(o>=0){let t=e*n,s=this.m_vertexAttributes.get(o);for(let e=0;e<n;e++)i[e]=s.readAsDbl(t+e)}else{let e=G.getDefaultValue(t);for(let t=0;t<n;t++)i[t]=e}}getAttributeAsInt(t,e,i){return Math.trunc(this.getAttributeAsDbl(t,e,i))}queryAttributeAsInt(t,e,i,r){(0,s.g)(0)}setAttributeNoCurves(t,e,i,r){let n=G.getComponentCount(t);i>=n&&(0,s.r)(""),this.addAttribute(t);let o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*n+i,r)}setAttributeFromArrayNoCurves(t,e,i,r){(e<0||e>=this.m_pointCount)&&(0,s.r)("");let n=G.getComponentCount(t);r<n&&(0,s.r)(""),this.addAttribute(t);let o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);let a=this.m_vertexAttributes.get(o);for(let t=0;t<n;++t)a.writeAsDbl(e*n+t,i[t])}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,i){let s=this.m_vertexAttributes.get(0);s.write(2*t,e),s.write(2*t+1,i),this.notifyModifiedFlags(2001)}getXYZ(t){let e=this.m_vertexAttributes.get(0),i=r.k.getNAN();return i.x=e.read(2*t),i.y=e.read(2*t+1),i.z=this.m_description.hasAttribute(1)?this.m_vertexAttributes.get(1).read(t):G.getDefaultValue(1),i}setXYZNoCurves(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);let i=this.m_vertexAttributes.get(0);i.write(2*t,e.x),i.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o.Envelope2D||t instanceof r.r?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){let i=n.E.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,i)),i}setAttributeBasic(t,e,i){this.setAttributeImpl(t,e,i)}setAttributeImpl(t,e,i){if(this.addAttribute(t),this.isEmpty())return;let s=!1,r=G.getComponentCount(t),n=this.getAttributeStreamRef(t),o=Number.isNaN(i);if(1===n.getPersistence()){let t=n;for(let n=e,a=this.m_pointCount*r;n<a;n+=r){let e=t.read(n);(!o&&e!==i||!Number.isNaN(e))&&(t.write(n,i),s=!0)}}else for(let t=e,o=this.m_pointCount*r;t<o;t+=r)n.readAsDbl(t)!==i&&(n.writeAsDbl(t,i),s=!0);s&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=!1,s=G.getComponentCount(t),r=this.getAttributeStreamRef(t);for(let t=0;t<s;t++)if(1===r.getPersistence()){let t=r;for(let r=0,n=this.m_pointCount*s;r<n;r++){let s=t.read(r);Number.isNaN(s)&&(t.write(r,e),i=!0)}}else for(let t=0,n=this.m_pointCount*s;t<n;t++){let s=r.readAsDbl(t);Number.isNaN(s)&&(r.writeAsDbl(t,e),i=!0)}i&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,s.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||(0,s.b)(""),this.m_envelopeData=new r.U({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,s.b)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,i,r){let n=r<0?this.m_pointCount:r;if(n=Math.min(n,i+e),(i<0||n<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.b)(""),0===this.m_pointCount)return n;let o=this.getAttributeStreamRef(0);for(let e=2*i,s=2*n,r=0;e<s;e+=2,r++)o.queryPoint2D(e,t[r]);return n}queryCoordinates3D(t,e,i,r){let n=r<0?this.m_pointCount:r;if(n=Math.min(n,i+e),(i<0||n<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.b)(""),0===this.m_pointCount)return n;let o=this.getAttributeStreamRef(0),a=null,l=G.getDefaultValue(1),h=this.m_description.hasAttribute(1);h&&(a=this.getAttributeStreamRef(1));let m=0;for(let e=i;e<n;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=h?a.read(e):l;return n}clearAndSetDirtyFlagProtected(t,e){let i=0,s=t&~e,r=e|s;i=this.m_flags,(i&r)!==e&&(this.m_flags=i&~s|e)}getIsSimple(t,e){e[0]=0;let i=-1,s=this.m_flags,r=this.m_simpleTolerance;return 1&s||(i=(14&s)>>1,e[0]=r,r<t&&(i=-1)),i}setIsSimple(t,e,i=!1){if(2===t?(0,s.g)(this.getGeometryType()===s.G.enumPolyline):1===t?(0,s.g)(this.getGeometryType()===s.G.enumMultiPoint||this.getGeometryType()===s.G.enumPolyline):3===t&&(0,s.g)(this.getGeometryType()===s.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;i||(s|=16),this.clearAndSetDirtyFlagProtected(31,s),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();let 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)&&(0,s.C)("Cannot do shallow clone on unprepared geometry");let i=t,r=this.getGeometryType(),n=i.getGeometryType();(0,s.g)(r===n||r===s.G.enumPolygon&&n===s.G.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();let o=this.m_description.getAttributeCount(),a=new V;if(!this.m_vertexAttributes.empty()){a.destroyAndSetSize(o);for(let t=0;t<o;t++)if(this.m_vertexAttributes.get(t))if(e)a.set(t,this.m_vertexAttributes.get(t));else{let e=G.getComponentCount(this.m_description.getSemantics(t));a.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,r!==n){let t=[NaN];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(a),a.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)||i.m_vertexAttributes.empty()?((0,s.g)(!e||0===i.m_pointCount),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,e)}catch(t){throw i.setEmpty(),t}i.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){let t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,i,o){(t<0||t>=this.m_pointCount)&&(0,s.r)(""),(e<0||e>=this.m_pointCount)&&(0,s.r)(""),o.assignVertexDescription(this.m_description);let a=(0,n.c)(G.maxComponentCount(),NaN),l=(0,n.c)(G.maxComponentCount(),NaN),h=(0,r.W)(),m=0;for(let r=0;r<this.m_description.getAttributeCount();r++){let o=this.m_description.getSemantics(r),u=G.getInterpolation(o),d=G.getComponentCount(o),g=G.getDefaultValue(o);this.queryAttributeAsDbl(o,t,a,d),this.queryAttributeAsDbl(o,e,l,d),(0,s.g)(m+d<=25),(0,n.aa)(u,a,l,h,m,d,i,g),m+=d}!function(t,e){let i=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),(0,n.f)(t.getAttributeArray(),e,0,2,i-2)}(o,h)}getShortestDistance(t,e){return n.P.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return n.P.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&(0,s.b)(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;let e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}m_description;m_vertexAttributes;m_envelopeData;m_pointCount;m_reservedPointCount;m_flags;m_bFillRule;m_bPathStarted;m_bPolygon;m_simpleTolerance;m_accelerators=null;assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){let e=(0,r.Q)();(0,r.R)(t,this.m_description,e);let i=new V;i.destroyAndSetSize(t.getAttributeCount());for(let s=0;s<t.getAttributeCount();s++){let t=e[s];-1===t?this.m_reservedPointCount=-1:i.set(s,this.m_vertexAttributes.get(t))}i.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=2**53-1,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 i=0;i<this.m_description.getAttributeCount();i++){let s=this.m_description.getSemantics(i),n=0;if(null!==this.m_vertexAttributes.get(i)){let t=G.getComponentCount(s);n=this.m_vertexAttributes.get(i).size()/t,n<this.m_pointCount&&(this.m_vertexAttributes.get(i).resize(e*t,G.getDefaultValue(s)),n=e)}else this.m_vertexAttributes.set(i,(0,r.X)(s,e)),n=e;n<t&&(t=n)}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);let e=this.updateXYImpl(t),i=new r.E({vd:this.m_description});i.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){let e=this.m_description.getSemantics(t),s=G.getComponentCount(e),r=this.m_vertexAttributes.get(t);for(let t=0;t<s;t++){let o=new n.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){let i=r.readAsDbl(e*s+t);o.mergeCoordinate(i)}i.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new r.U({moveEnv:i}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){let e=o.Envelope2D.constructEmpty(),i=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(i,0,this.m_pointCount),e}updateEnvelope3D(t){(0,s.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o.Envelope2D?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,e){if(t<0&&(0,s.b)(""),0===t)return;let i=t=Math.ceil(t);if(this.m_reservedPointCount<i){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,(0,r.Y)(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*i),i=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,(0,r.Y)(0,i)):this.m_vertexAttributes.get(0).resize(2*i);for(let t=1;t<this.m_description.getAttributeCount();t++){let e=this.m_description.getSemantics(t),s=G.getComponentCount(e);null===this.m_vertexAttributes.get(t)?this.m_vertexAttributes.set(t,(0,r.Y)(e,i)):this.m_vertexAttributes.get(t).resize(i*s)}this.reserveImplImpl(i,e),this.m_reservedPointCount=i}}reserveRounded(t){t<0&&(0,s.b)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,s.B)("")}exportVertexAttributes(){let t=this.getPointCount(),e=this.m_description.getAttributeIndex(1),i=this.m_description.getAttributeIndex(2),s=this.m_vertexAttributes.posStream,r=e>0?this.m_vertexAttributes.get(e):void 0,n=i>0?this.m_vertexAttributes.get(i):void 0;return{vertexCount:t,vertexXY:s?.getArray()??new Float64Array,vertexZ:r?.getArray(),vertexM:n?.getArray()}}}class W extends H{static type=s.G.enumMultiPoint;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,e){t>this.getPointCount()&&(0,s.b)("invalid point index"),t<0&&(t=this.getPointCount());let i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let s=0,n=this.m_description.getAttributeCount();s<n;s++){let n=this.m_description.getSemantics(s),o=r.V.getComponentCount(n);if(0===n)this.m_vertexAttributes.get(s).insert(o*t,e,o*i);else{let e=r.V.getDefaultValue(n);this.m_vertexAttributes.get(s).insertRange(o*t,e,o,o*i)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,s.b)(Z),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());let i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let s=0,n=this.m_description.getAttributeCount();s<n;s++){let n=this.m_description.getSemantics(s),o=r.V.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(s).insertAttributes(o*t,e,n,o*i);else{let e=r.V.getDefaultValue(n);this.m_vertexAttributes.get(s).insertRange(o*t,e,o,o*i)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,i){if((t>this.getPointCount()||i<0)&&(0,s.r)(""),t<0&&(t=this.getPointCount()),0===i)return;let n=e[0].getDescription();this.mergeVertexDescription(n);let o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let s=0,a=this.m_description.getAttributeCount();s<a;s++){let a=this.m_description.getSemantics(s),l=r.V.getComponentCount(a);if(this.m_vertexAttributes.get(s))if(n.hasAttribute(a))this.m_vertexAttributes.get(s).insertAttributesFromPoints(t*l,e,i,a,o*l);else{let e=r.V.getDefaultValue(a);this.m_vertexAttributes.get(s).insertRange(l*t,e,l*i,l*o)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,i){if((t>this.getPointCount()||i<0)&&(0,s.b)("invalid point index"),t<0&&(t=this.getPointCount()),0===i)return;let n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let s=0,o=this.m_description.getAttributeCount();s<o;s++){let o=this.m_description.getSemantics(s),a=r.V.getComponentCount(o);if(this.m_vertexAttributes.get(s))if(0===o)this.m_vertexAttributes.get(s).insertRangeFromPoints(a*t,e,0,i,!0,a*n);else{let e=r.V.getDefaultValue(o);this.m_vertexAttributes.get(s).insertRange(a*t,e,a,a*n)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,s.r)("remove_points"),0!==e){for(let i=0,s=this.m_description.getAttributeCount();i<s;i++)if(this.m_vertexAttributes.get(i)){let s=this.m_description.getSemantics(i),n=r.V.getComponentCount(s);this.m_vertexAttributes.get(i).eraseRange(n*t,n*e,n*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,i=this.m_description.getAttributeCount();e<i;e++)if(this.m_vertexAttributes.get(e)){let i=this.m_description.getSemantics(e),s=r.V.getComponentCount(i);this.m_vertexAttributes.get(e).eraseRange(s*t,s,s*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){let e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=r.V.getDefaultValue(i),n=r.V.getComponentCount(i);this.m_vertexAttributes.get(t).insertRange(n*e,s,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(t,e,i,n){let o=n<0?this.m_pointCount:n;if(o=Math.min(o,i+e),(i<0||o<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.b)(""),0===this.m_pointCount)return o;let a=this.getAttributeStreamRef(0),l=null,h=r.V.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(l=this.getAttributeStreamRef(1));let u=0;for(let e=i;e<o;e++,u++)t[u].x=a.read(2*e),t[u].y=a.read(2*e+1),t[u].z=m?l.read(e):h;return o}queryAttributeAsInt(t,e,i,r){(0,s.g)(0)}add(t){t.isEmpty()&&(0,s.b)(Z),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);let i=new n.P(t,e);this.setXYNoCurves(this.m_pointCount-1,i)}addXYZ(t,e,i){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);let s=new r.k;s.setCoords(t,e,i),this.setXYZNoCurves(this.m_pointCount-1,s)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,i){this===t&&(0,s.b)("Multi_point_impl.add");let n=i<0?t.getPointCount():i;if((e<0||e>t.getPointCount()||n<e)&&(0,s.b)(""),e===n)return;let o=t.getDescription();this.mergeVertexDescription(o);let a=n-e,l=this.m_pointCount;this.resizeNoInit(this.m_pointCount+a);for(let i=0,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),n=r.V.getComponentCount(s),h=this.getAttributeStreamRef(s);if(o.hasAttribute(s)){let i=t.getAttributeStreamRef(s);h.insertRangeFromStream(l*n,i,e*n,a*n,!0,1,l*n)}else{let t=r.V.getDefaultValue(s);h.insertRange(l*n,t,a*n,l*n)}}}addPoints2D(t,e,i,r){let n=e,o=r<0?n:r;if((n<0||i<0||i>n||o<i)&&(0,s.b)(""),i===o)return;n=o-i;let a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+n);let l=this.getAttributeStreamRef(0);for(let e=0;e<n;++e)l.writePoint2D(2*(a+e),t[i+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,i,r){let o=e,a=r<0?o:r;if((o<0||i<0||i>o||a<i)&&(0,s.b)(""),this.addAttribute(1),i===a)return;o=a-i;let l=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);let h=this.getAttributeStreamRef(0),m=new n.P;for(let e=0;e<o;e++)m.x=t[i+e].x,m.y=t[i+e].y,h.writePoint2D(2*(l+e),m);let u=this.getAttributeStreamRef(1);for(let e=0;e<o;e++)u.write(l+e,t[i+e].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,i){this.setXYCoordsNoCurves(t,e,i)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,i,s){this.setAttributeNoCurves(t,e,i,s)}getGeometryType(){return s.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new W({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty()||t.isIdentity())return;let e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,s.a)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===s.G.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):(0,s.a)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){let t=this.createInstance();return this.copyTo(t),t}swap(t){(0,s.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,s.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}toFlatGeometry(){return{type:"multipoint",...this.exportVertexAttributes(),...r.$}}}class j extends l.G{m_index;gc;dim;constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount()||(this.m_index++,this.m_index===this.gc.getGeometryCount()))return null;let 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 U{static type=s.G.enumGeometryCollection;m_description;m_geoms=[];constructor(t){if(this.m_description=(0,r.K)(),t){if(t.vd)return void(this.m_description=t.vd);if(t.copy)return void t.copy.copyTo(this);(0,s.b)("constructor argument not recognized")}}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===s.G.enumGeometryCollection){let e=t;for(let t=0,i=e.getGeometryCount();t<i;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)&&(0,s.b)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return s.G.enumGeometryCollection}getDimension(){let t=0;for(let 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(let 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;let e=(0,r.N)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.O)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.K)();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let i=new n.E,s=new n.E;s.setEmpty();for(let r of this.m_geoms)i=r.queryInterval(t,e),s.merge(i);return s}queryEnvelope(t){if(4===t.m_EnvelopeType){let e=new r.E;t.setEmpty(),t.assignVertexDescription(this.m_description);for(let i of this.m_geoms)i.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){let e=new o.Envelope2D;t.setEmpty();for(let i of this.m_geoms)i.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,s.a)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){let e=new o.Envelope2D;t.setEmpty();for(let i of this.m_geoms)i.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,s.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(let e of this.m_geoms)e.applyTransformation(t);(0,s.a)("3d xform not impl")}transformAttribute(t,e,i,s,r){for(let n of this.m_geoms)n.transformAttribute(t,e,i,s,r)}createInstance(){return new U({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==s.G.enumGeometryCollection&&(0,s.b)("");let e=t;if(e!==this){e.m_geoms.length=0,e.assignVertexDescription(this.m_description);for(let t of this.m_geoms)e.m_geoms.push(t.clone())}}calculateArea2D(){let t=new n.K(0);for(let e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){let t=new n.K(0);for(let e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return(0,s.g)(0),0}getBoundary(){let t=this.createInstance(),e=t;for(let t of this.m_geoms){let i=t.getBoundary();i&&e.m_geoms.push(i)}return t}clone(){return new U({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==s.G.enumGeometryCollection)return!1;let i=t;if(this.m_description!==i.m_description||this.m_geoms.length!==i.m_geoms.length)return!1;for(let t=0;t<this.m_geoms.length;++t)if(!this.m_geoms[t].equals(i.m_geoms[t],e))return!1;return!0}swap(t){t.getGeometryType()!==s.G.enumGeometryCollection&&(0,s.b)("");let e=t;e!==this&&(this.m_geoms=(0,n.s)(e.m_geoms,e.m_geoms=this.m_geoms))}setAttributeBasic(t,e,i){for(let s of this.m_geoms)s.setAttributeBasic(t,e,i)}replaceNaNs(t,e){for(let i of this.m_geoms)i.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.M)(e,t);this.assignVertexDescription(i)}}function O(t,e=-1){return new j(t,e)}class Q extends z{constructor(t){super(t)}}class K extends Q{isTrue3D(){return!0}constructor(t){super(t)}}function J(t,e,i){$(e,t.getStartXY(),t.getEndXY(),i)}function $(t,e,i,s){(0,n.J)(e,i,t,s)}function tt(t,e){return(0,n.r)(t.m_XStart,t.m_XEnd,e)}function et(t,e){return(0,n.r)(t.m_YStart,t.m_YEnd,e)}function it(t,e,i){e.value()<=.5?(0,n.ao)(2,g.constructPoint2D(t.getStartXY()),g.constructPoint2D(t.getEndXY()),e,i):(0,n.ap)(2,g.constructPoint2D(t.getStartXY()),g.constructPoint2D(t.getEndXY()),e,i)}function st(t,e,i){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,t.afterCompletedModification()}function rt(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=(0,n.s)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,n.s)(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,i=t.m_description.getTotalComponentCount()-2;e<i;e++)t.m_attributes[e+i]=(0,n.s)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+i])}}function nt(t,e,i,s){let r=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)&&(r++,!s))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(r++,2===r)return 2;if(!s)return 1}return e.isIntersectingPoint(t.getStartXY(),i,!0)||e.isIntersectingPoint(t.getEndXY(),i,!0)||t.isIntersectingPoint(e.getStartXY(),i,!0)||t.isIntersectingPoint(e.getEndXY(),i,!0)?4:s&&r?0:function(t,e){let i=lt(t,e.m_XStart,e.m_YStart),s=lt(t,e.m_XEnd,e.m_YEnd);if(i<0&&s<0||i>0&&s>0)return!1;let r=lt(e,t.m_XStart,t.m_YStart),n=lt(e,t.m_XEnd,t.m_YEnd);return!(r<0&&n<0||r>0&&n>0)&&(ut(t)>ut(e)?mt(t,e):mt(e,t))}(t,e)?4:0}function ot(t,e,i,s,r,o,a,l){null!==s&&(0,n.x)(s,2,NaN),null!==r&&(0,n.x)(r,2,NaN),null!==i&&(0,n.ay)(i,n.P,2);let h=function(t,e,i,s,r,o,a,l,h){let m=at(t,e.getStartXY(),a,!1),u=at(t,e.getEndXY(),a,!1),d=at(e,t.getStartXY(),a,!1),g=at(e,t.getEndXY(),a,!1),c=0,_=0;if(!Number.isNaN(m)){let i=!1;l&&(0,n.a9)(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getStartXY())&&(c++,i=!0),i||(r&&(r[_]=m),o&&(o[_]=0),s&&s[_].setCoords(e.m_XStart,e.m_YStart),_++)}if(!Number.isNaN(u)){let i=!1;l&&(0,n.a9)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(c++,i=!0),i||(2>_&&(r&&(r[_]=u),o&&(o[_]=1),s&&s[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(!(2===_||Number.isNaN(d)||0===m&&0===d||0===u&&1===d)){let i=!1;l&&(0,n.a9)(d,0,1)&&e.getCoord2D(d).isEqualPoint2D(t.getStartXY())&&(c++,i=!0),i||(2>_&&(r&&(r[_]=0),o&&(o[_]=d),s&&s[_].setCoords(t.m_XStart,t.m_YStart)),_++)}if(!(2===_||Number.isNaN(g)||1===m&&0===g||1===u&&1===g)){let i=!1;l&&(0,n.a9)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getEndXY())&&(c++,i=!0),i||(2>_&&(r&&(r[_]=1),o&&(o[_]=g),s&&s[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(_>0)return h&&(o=(0,n.s)(r,r=o)),2===_&&r&&r[0]>r[1]&&(r[1]=(0,n.s)(r[0],r[0]=r[1]),o&&(o[1]=(0,n.s)(o[0],o[0]=o[1])),s&&(s[1]=(0,n.s)(s[0],s[0]=s[1]))),_;if(c>0)return 0;let p=function(t,e,i){let s=t.m_XEnd-t.m_XStart,r=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,l=o*r-s*a;if(0===l)return n.P.getNAN();let h=4*(0,n.I)()*(Math.abs(o*r)+Math.abs(s*a)),m=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,d=o*u-m*a,g=4*(0,n.I)()*(Math.abs(o*u)+Math.abs(m*a)),c=d/l,_=Math.abs(l),p=(g*_+h*Math.abs(d))/(l*l)+(0,n.I)()*Math.abs(c);if(c<-p||c>1+p)return n.P.getNAN();let f=s*u-m*r,y=f/l,P=(4*(0,n.I)()*(Math.abs(s*u)+Math.abs(m*r))*_+h*Math.abs(f))/(l*l)+(0,n.I)()*Math.abs(y);if(y<-P||y>1+P)return n.P.getNAN();let x=(0,n.a)(c,0,1),v=(0,n.a)(y,0,1),C=n.P.getNAN();J(t,x,C);let b=n.P.getNAN();if(J(e,v,b),!i||n.P.distance(C,b)>i){let s=n.P.getNAN();(0,n.J)(C,b,.5,s),x=t.getClosestCoordinate(s,!1),v=e.getClosestCoordinate(s,!1);let r=n.P.getNAN();J(t,x,r);let o=n.P.getNAN();J(e,v,o),r.subThis(o);let a=r.length(),l=(t.absNorm()+e.absNorm())*(0,n.g)();if(a>Math.max(i,l))return n.P.getNAN()}return new n.P(x,v)}(t,e,a);return Number.isNaN(p.x)?0:(s&&(s[0]=t.getCoord2D(p.x)),r&&(r[0]=p.x),o&&(o[0]=p.y),1)}(t,e,0,i,s,r,o,a,l);return s&&(s.length=h),r&&(r.length=h),i&&(i.length=h),h}function at(t,e,i,s){let r=n.P.getNAN(),o=n.P.getNAN(),a=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(r.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(r.setCoords(t.m_XStart,t.m_YStart),o.setCoords(t.m_XEnd,t.m_YEnd));let l=+!!a,h=+!a,m=n.P.getNAN();m.setSub(e,r);let u=m.length(),d=3*u*(0,n.I)();if(u<=Math.max(i,d))return s&&0===u?NaN:l;if(m.setSub(e,o),u=m.length(),d=3*u*(0,n.I)(),u<=Math.max(i,d))return s&&0===u?NaN:h;m.setCoords(o.x-r.x,o.y-r.y);let g=m.length();if(g>0){let t=1/g;m.scale(t);let s=n.P.getNAN();s.setSub(e,r);let u=s.dotProduct(m),d=8*s.dotProductAbs(m)*(0,n.I)();m.leftPerpendicularThis();let c=s.dotProduct(m),_=8*s.dotProductAbs(m)*(0,n.I)(),p=Math.max(i,d);if(u<-p||u>g+p)return NaN;if(Math.abs(c)<=Math.max(i,_)){let s=u*t;s=(0,n.a)(s,0,1);let m=n.P.getNAN();if($(s,r,o,m),n.P.distance(m,e)<=i){if(s<.5){if(n.P.distance(m,r)<=i&&n.P.distance(e,r)<=i)return l}else if(n.P.distance(m,o)<=i&&n.P.distance(e,o)<=i)return h;return a?1-s:s}}}return NaN}function lt(t,e,i){let s=n.P.getNAN();s.setCoords(e,i),s.subThis(t.getStartXY());let r=n.P.getNAN();r.setSub(t.getEndXY(),t.getStartXY());let o=r.crossProduct(s),a=4*(0,n.I)()*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?-1:+(o<-a)}function ht(t,e,i,s){let r=s?t.m_XStart:t.m_XEnd,o=s?t.m_YStart:t.m_YEnd,a=n.P.getNAN();return a.x=e.getEndX()-r,a.y=e.getEndY()-o,!(i.dotProduct(a)>3*(0,n.I)()*i.dotProductAbs(a))||(a.x=e.getStartX()-r,a.y=e.getStartY()-o,i.dotProduct(a)<=3*(0,n.I)()*i.dotProductAbs(a))}function mt(t,e){let i=n.P.getNAN();return i.x=t.m_XEnd-t.m_XStart,i.y=t.m_YEnd-t.m_YStart,!(!ht(t,e,i,!1)||(i.negateThis(),!ht(t,e,i,!0)))}function ut(t){let e=t.m_XStart-t.m_XEnd,i=t.m_YStart-t.m_YEnd;return e*e+i*i}class dt{constructor(t){if(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())&&(0,s.r)("");let 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)&&(0,s.r)("");let e=+!t.parent.isClosedPath(t.pathIndex);t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,s.r)(""),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())&&(0,s.r)(""),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&&(0,s.q)(""),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()){let 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 i;i=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=i+1,this.m_currentPathIndex=i,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(i),this.m_segmentCount=this.getSegmentCount(i),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&&(0,s.r)("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&&(0,s.r)(""),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;let 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&&(0,s.r)(""),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)&&(0,s.r)(""),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(){return null!==this.m_segFlagStream&&1!=(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}m_buffer;m_currentSegmentIndex;m_nextSegmentIndex;m_nextPathIndex;m_currentPathIndex;m_parent;m_segFlagStream=null;m_xyStream=null;m_description;m_segmentCount;m_pathBegin;m_bCurrentPathClosed;m_bCirculator=!1;m_bStripAttributes;m_prevPathIndex;m_prevSegmentIndex;m_bNeedsUpdate}class gt{m_rasterizedGeometry=null;m_quadTree=null;m_quadTreeForPaths=null;m_refCount=1;constructor(t){t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,s.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){let t=new gt;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){(0,s.g)(this.uniqueUse())}setQuadTree(t){(0,s.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,s.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function ct(t){return!(t.isEmpty()||t.getGeometryType()!==s.G.enumPolyline&&t.getGeometryType()!==s.G.enumPolygon||t.getPointCount()<20)}function _t(t){return!(t.isEmpty()||t.getGeometryType()!==s.G.enumPolyline&&t.getGeometryType()!==s.G.enumPolygon||t.getPointCount()<20)}function pt(t,e){return t.readPoint2D(e+4)}function ft(t){let e=t.getGeometryType();return e===s.G.enumEllipticArc?10:e===s.G.enumBezier?4:e===s.G.enumRationalBezier2?5:e===s.G.enumBezier2?2:void(0,s.d)("")}function yt(t){let e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Pt(t,e,i,s){let r=t.getPathStart(e),o=t.getPathEnd(e);if(o-r<3)return;let a=2*r,l=n.P.getNAN();i.queryPoint2D(a,l);let h=l.x,m=l.y,u=n.P.getNAN();i.queryPoint2D(a+2,u);let d=n.P.getNAN();for(let t=a+4,e=2*o;t<e;t+=2)i.queryPoint2D(t,d),s.pe((d.x-l.x)*(u.y-m)),l.setCoordsPoint2D(u),u.setCoordsPoint2D(d);s.pe((h-l.x)*(u.y-m))}function xt(t,e,i){for(;e.hasNextSegment();){let t=e.nextCurve();if(null===t)break;i.pe(2*t.calculateArea2DHelper())}}var vt=r.V;class Ct{m_segmentFlags=null;m_segmentParamIndex=null;m_segmentParams=null;static toSegType(t){let e=0;switch(t){case s.G.enumLine:e=1;break;case s.G.enumBezier:e=2;break;case s.G.enumEllipticArc:e=4;break;case s.G.enumRationalBezier2:e=8;break;case s.G.enumBezier2:e=16;break;default:(0,s.d)("")}return e}m_curveCount;m_bezierCount;m_arcCount;m_rbezier2Count;m_bezier2Count;m_curveParamWritePoint;constructor(){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 bt extends H{constructor(t){super(t),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?s.G.enumPolygon:s.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,s.g)(this.m_bPolygon);let e=this.getPathIndexFromPointIndex(t),i=this.getPathStart(e);if(i===t)return;let r=this.getPathEnd(e);(t>=r||t<i)&&(0,s.b)("change_ring_start_point");for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){let s=this.m_description.getSemantics(e),n=vt.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}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;let t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);let e=new r.A(t),i=new n.K(0),s=new n.K(0);if(0!==this.m_pointCount){let r=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){let t=new dt({parent:this});for(t.stripAttributes();t.nextPath();){s.reset();let n=t.getPathIndex();Pt(this,n,r,s),xt(0,t,s);let o=.5*s.getResult();i.add(o),e.write(n,o)}}else for(let n=0;n<t;n++){s.reset(),Pt(this,n,r,s);let t=.5*s.getResult();i.add(t),e.write(n,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=i.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0,e=this.getPathCount();for(let i=0;i<e;i++)8&this.m_pathFlags.read(i)&&t++;return t}getHashCodeImpl(){return(0,s.g)(0),0}equalsImpl(t){let e=t,i=this.getPathCount();if(i!==e.getPathCount())return!1;let s=this.hasNonLinearSegments();if(s!==e.hasNonLinearSegments()||s&&(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount||this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)||this.m_paths&&!this.m_paths.equals(e.m_paths,0,i+1)||this.m_bFillRule!==e.m_bFillRule||!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,i))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,i=this.getPointCount();t<i;t++){let i=this.m_curveData.m_segmentFlags.read(t);if(!bt.isNonLinearSegmentFlag(i))continue;let s=this.m_curveData.m_segmentParamIndex.read(t),r=e.m_curveData.m_segmentParamIndex.read(t),o=yt(i);for(let t=0;t<o;t++){let i=this.m_curveData.m_segmentParams.read(s+t),o=e.m_curveData.m_segmentParams.read(r+t);if(!(0,n.G)(i,o))return!1}}}return!0}equalsImplTol(t,e){let i=t,s=this.getPathCount();if(s!==i.getPathCount())return!1;let r=this.hasNonLinearSegments();if(r!==i.hasNonLinearSegments()||r&&(this.m_curveData.m_curveCount!==i.m_curveData.m_curveCount||this.m_curveData.m_bezierCount!==i.m_curveData.m_bezierCount)||this.m_paths&&!this.m_paths.equals(i.m_paths,0,s+1)||this.m_bFillRule!==i.m_bFillRule||!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(i.m_pathFlags,0,s))return!1;if(!r)return!0;if(!this.m_curveData.m_segmentFlags.equals(i.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;let n=this.querySegmentIterator(),o=i.querySegmentIterator();for(;n.nextPath();){if(!o.nextPath())return!1;for(;n.hasNextSegment();){let t=n.nextCurve(),i=o.nextCurve();if(!(t&&i&&t.equals(i,e))){if(!t&&!i)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=(0,r.a0)(1,0),this.m_pathFlags=(0,r.a1)(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){let i=t;i.m_bPathStarted=!1,i.m_bFillRule=this.m_bFillRule,i.m_paths=this.m_paths?e?this.m_paths:this.m_paths.clone():null,i.m_pathFlags=this.m_pathFlags?e?this.m_pathFlags:this.m_pathFlags.clone():null,this.m_curveData&&(i.m_curveData||=new Ct,i.m_curveData.assignCopy(this.m_curveData),i.m_curveData.m_curveCount=0,i.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?i.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():i.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?i.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():i.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?i.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():i.m_curveData.m_segmentParams=null)),i.hasDirtyFlag(512)||(i.m_cachedLength2D=this.m_cachedLength2D),i.m_cachedRingAreas2D=null,i.hasDirtyFlag(1024)||(i.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(i.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;let t=this.querySegmentIterator(),e=new n.K(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){let e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),i=new n.K(0);for(;e.hasNextSegment();)i.add(e.nextSegment().calculateLength2D());return i.getResult()}calculateLength3D(t){return(0,s.g)(0),0}calculatePathLength3D(t,e){return(0,s.g)(0),0}copyTo(t){(0,s.j)(t.getGeometryType())||(0,s.b)(""),this!==t&&super.copyTo(t)}swap(t){(0,s.g)(0)}setPointByVal(t,e){this.setPointByValWithCurves(t,e)}setPointByValWithCurves(t,e){if(this.hasNonLinearSegments()){let i=e.getXY();if(this.setXYCoordsWithCurves(t,i.x,i.y),1===this.m_description.getAttributeCount())return}this.setPointByValNoCurves(t,e)}setXYCoordsWithCurves(t,e,i){if(this.hasNonLinearSegments()){let s=bt.getPathIndexFromPointIndexImpl(this.m_paths,this.getPathCount(),t,this.m_currentPathIndex);this.m_currentPathIndex=s;let r=this.getPrevSegmentTypeFromPath(s,t),o=this.getNextSegmentType(t);if(1!==r||1!==o){let a=t-1,l=new Xn;1!==r&&(this.isClosedPath(s)&&t===this.getPathStart(s)&&(a=this.getPathEnd(s)-1),this.getSegmentBuffer(a,l,!0));let h=new Xn;1!==o&&this.getSegmentBuffer(t,h,!0);let m=t+1;this.setXYCoordsNoCurves(t,e,i);let u=new n.P(e,i);return 1!==r&&(l.get().changeEndPoints2D(l.get().getStartXY(),u),this.replaceSegmentImpl(a,t,l.get(),!0)),void(1!==o&&(h.get().changeEndPoints2D(u,h.get().getEndXY()),this.replaceSegmentImpl(t,m,h.get(),!0)))}}this.setXYCoordsNoCurves(t,e,i)}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,i,s){if(0===t&&this.hasNonLinearSegments()){let t=this.getXY(e);0===i?t.x=s:t.y=s,this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeNoCurves(t,e,i,s)}setXY(t,e){this.setXYCoordsWithCurves(t,e.x,e.y)}setXYCoords(t,e,i){this.setXYCoordsWithCurves(t,e,i)}setXYZ(t,e){this.setXYZWithCurves(t,e)}setAttribute(t,e,i,s){this.setAttributeWithCurves(t,e,i,s)}setAttributeWithCurvesFromArray(t,e,i,r){if(0===t&&this.hasNonLinearSegments()){r<2&&(0,s.r)("");let t=this.getXY(e);t.x=i[0],t.y=i[1],this.setXYCoordsWithCurves(e,t.x,t.y)}else this.setAttributeFromArrayNoCurves(t,e,i,r)}setAttributeFromArray(t,e,i,s){this.setAttributeWithCurvesFromArray(t,e,i,s)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,i=this.getPathCount();e<i;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&(0,s.b)("Multi_path_impl::add");for(let i=0,s=t.getPathCount();i<s;i++)this.addPath(t,i,!e)}addPath(t,e,i){this.insertPath(-1,t,e,i)}addPathPoint2D(t,e,i){this.insertPath2D(-1,t,0,e,i)}addPathMultiPoint(t,e,i,s){i<0&&(i=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,i,s)}addSegmentsFromPath(t,e,i,r,n){if(this===t&&(0,s.b)("Multi_path_impl.add_segments_from_path"),!n&&0===this.getPathCount()&&(n=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||i<0||r<0||i+r>t.getSegmentCountPath(e))&&(0,s.r)("add_segments_from_path"),0===r)return;let o=t.getPathStart(e),a=t.isClosedPath(e)&&i+r===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let l=r,h=o+i,m=h+1;n&&(l++,m--),!n&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(h)&&(t.getXY(h).equals(this.getXY(this.m_pointCount-1))||(0,s.b)("add_segments_from_path: start point mismatch"));let u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange(),n){if(0===l)return;this.m_paths.add(this.m_pointCount);let i=t.m_pathFlags.read(e);this.m_bPolygon&&(i|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,i),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);let d=a?l-1:l;for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e),s=vt.getComponentCount(i),r=t.m_description.getAttributeIndex(i);if(d>0){if(r<0||!t.m_vertexAttributes.get(r)){let t=vt.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(s*u,t,d*s,s*u),a&&this.m_vertexAttributes.get(e).insertRange(s*u+d*s,t,s,s*u);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(s*u,t.m_vertexAttributes.get(r),s*m,d*s,!0,s,s*u)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(s*(u+d),t.m_vertexAttributes.get(r),s*o,s,!0,s,s*(u+d))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let i=0,s=h;i<r;i++)e+=yt(t.m_curveData.m_segmentFlags.read(s)),s++;if(e>0){this.initSegmentData(e);let i=h,s=u-+!n,o=0;for(let e=0;e<r;e++){let e=t.m_curveData.m_segmentFlags.read(i);if(this.m_curveData.m_segmentFlags.write(s,e),bt.isNonLinearSegmentFlag(e)){o++;let r=t.m_curveData.m_segmentParamIndex.read(i),n=yt(e);this.m_curveData.m_segmentParamIndex.write(s,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<n;e++){let 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(s,-1);s++,i++}this.modifyCurveCounter(o)}}if(a){let t=this.getPathCount()-1,e=this.getPathStart(t),i=this.getPathEnd(t)-1,s=this.getXY(e),r=this.getXY(i);s.isEqualPoint2D(r)&&(--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()&&(0,s.b)("");let e=this.getPathSize(t);if(0===e)return;let i=this.getPathStart(t),r=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=i,s=new this.m_segmentBufferCTor,n=!1;for(let i=0;i<e;i++,t++){let e=this.m_curveData.m_segmentFlags.read(t);if(!bt.isNonLinearSegmentFlag(e))continue;n=!0,this.querySegment(t,s,!0),s.get().reverse();let i=this.m_curveData.m_segmentParamIndex.read(t);s.get().writeInBufferStream(this.m_curveData.m_segmentParams,i)}if(n){let t=+!r;this.m_curveData.m_segmentFlags.reverseRange(i,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(i,e-t,1)}}let n=+!!r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++)if(this.m_vertexAttributes.get(t)){let s=this.m_description.getSemantics(t),r=vt.getComponentCount(s);this.m_vertexAttributes.get(t).reverseRange(r*(i+n),r*(e-n),r)}let 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){let e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,s.b)("");let i=this.getPathStart(t),r=this.getPathSize(t);for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){let e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*i,s*r,s*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=i,s=i+r;e<s;e++){let i=this.m_curveData.m_segmentFlags.read(e);bt.isNonLinearSegmentFlag(i)&&(this.incCurveType(i,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(i,r,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(i,r,this.m_pointCount)}for(let i=t+1;i<=e;i++){let t=this.m_paths.read(i);this.m_paths.write(i-1,t-r)}if(this.m_pathFlags)for(let i=t+1;i<=e;i++){let t=this.m_pathFlags.read(i);this.m_pathFlags.write(i-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=r,this.m_reservedPointCount-=r,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,i,n){this===e&&(0,s.b)("Multi_path_impl::insert_path");let o=this.getPathCount();if(!n&&e.hasNonLinearSegmentsPath(i))return t=this.insertPath(t,e,i,!0),this.reversePath(t),t;i>=e.getPathCount()&&(0,s.b)(""),t>o&&(0,s.b)(""),t<0&&(t=o),i<0&&(i=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());let a=e.getPathStart(i),l=e.getPathSize(i);if(0===l)return this.insertPath2D(t,null,0,0,!0);let h=this.m_pointCount,m=e.isClosedPath(i)&&!n?1:0;this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange();let u=t<o?this.getPathStart(t):h;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=e.getDescription().getAttributeIndex(i),r=vt.getComponentCount(i);if(s>=0&&e.m_vertexAttributes.get(s))0!==m&&this.m_vertexAttributes.get(t).insertRangeFromStream(u*r,e.m_vertexAttributes.get(s),r*a,r,!0,r,r*h),this.m_vertexAttributes.get(t).insertRangeFromStream((u+m)*r,e.m_vertexAttributes.get(s),r*(a+m),r*(l-m),n,r,r*(h+m));else{let e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(u*r,e,r*l,r*h)}}let d=h+l;this.m_paths.add(d);for(let e=o;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+l)}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)}let g=e.getPathFlagsStreamRef().read(i);if(g&=-9,this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),e.hasNonLinearSegments()){this.initSegmentData(0);let t=a,i=0;for(let s=0;s<l;s++)i+=yt(e.m_curveData.m_segmentFlags.read(t)),t++;if(i>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=(0,r.a1)(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=(0,r.a0)(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(u,1,l,h),this.m_curveData.m_segmentParamIndex.insertRange(u,-1,l,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+i):this.m_curveData.m_segmentParams=(0,r.a2)(i),t=a;let s=u,n=0;for(let i=0;i<l;i++){let i=e.m_curveData.m_segmentFlags.read(t);if(bt.isNonLinearSegmentFlag(i)){this.m_curveData.m_segmentFlags.write(s,i),this.m_curveData.m_segmentParamIndex.write(s,this.m_curveData.m_curveParamWritePoint);let r=yt(i),o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){let t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}n++,this.incCurveType(i,1)}t++,s++}this.modifyCurveCounter(n)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,i,r,n){let o=this.getPathCount();(t>o||i<0)&&(0,s.b)(""),t<0&&(t=o),this.m_bPathStarted=!1;let a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),0===r&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();let l=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*l,e,i,r,n,2*a);else{let t=vt.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*l,t,2*r,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e),s=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(l*i,s,i*r,i*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+r)}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(l,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(l,-1,r,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,i,r,n){let o=e.getImpl(),a=this.getPathCount();(t>a||i<0)&&(0,s.b)("");let l=r<0?o.getPointCount()-i:r;if(l>o.getPointCount()&&(0,s.b)(""),i>=o.getPointCount()&&(0,s.b)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===l)return void this.insertPath2D(t,null,0,0,!0);let h=this.m_pointCount,m=i;this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange();let u=t<a?this.getPathStart(t):h;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=o.getDescription().getAttributeIndex(e),s=vt.getComponentCount(e);if(i>=0){let i=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(u*s,i,s*m,s*l,n,s,s*h)}else{let i=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(u*s,i,s*l,s*h)}}let d=h+l;this.m_paths.add(d);for(let e=a;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+l)}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,e,i,r,n,o,a){if(this===i&&(0,s.b)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),r<0&&(r=i.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||r>=i.getPathCount()||o>i.getPathSize(r))&&(0,s.r)(""),!o)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)}e<0&&(e=this.getPathSize(t));let l=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();let h=this.getPathStart(t),m=h+e;o<0&&(o=i.getPathSize(r));let u=i.getPathStart(r),d=u+o;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){let s=this.m_description.getSemantics(t),r=vt.getComponentCount(s),g=i.m_description.getAttributeIndex(s);if(g<0||!i.m_vertexAttributes.get(g)){let e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(r*m,e,d*r,r*l);continue}this.m_vertexAttributes.get(t)?.insertRangeFromStream(r*(h+e),i.m_vertexAttributes.get(g),r*(u+n),o*r,a,r,r*l)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,o,l),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,o,l),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 e=t+1,i=this.getPathCount();e<=i;e++){let t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,i,r,n,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||r<0)&&(0,s.r)(""),!n)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));let a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),this.verifyAllStreamsAfterSizeChange();let l=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(l+e),i,r,n,o,2*a);for(let t=1,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=vt.getComponentCount(i),r=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange((l+e)*s,r,s*n,s*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l+e,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(l+e,-1,n,a),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 e=t+1,i=this.getPathCount();e<=i;e++)this.m_paths.write(e,this.m_paths.read(e)+n);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,i,r,n,o){let a=i.getImpl(),l=this.getPathCount();t<0&&(t=this.getPathCount());let h=a.getPointCount();if((r<0||r>h)&&(0,s.r)(""),(n<0||r+n>h)&&(n=h-r),e<0&&(e=t<l?this.getPathSize(t):0),(t>l||t<l&&e>this.getPathSize(t)||t===l&&e>0||n<0)&&(0,s.r)(""),!n)return;this.mergeVertexDescription(a.getDescription()),t===l&&(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));let m=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),this.verifyAllStreamsAfterSizeChange();let u=this.getPathStart(t),d=u+e,g=0+n;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=vt.getComponentCount(i);if(a.getDescription().getAttributeIndex(i)<0){let e=vt.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(s*d,e,g*s,s*m);continue}let l=a.getAttributeStreamRef(i);this.m_vertexAttributes.get(t).insertRangeFromStream(s*(u+e),l,s*(0+r),n*s,o,s,s*m)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(u+e,1,n,m),this.m_curveData.m_segmentParamIndex.insertRange(u+e,-1,n,m),e>0&&this.isNonLinearSegment(u+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(u+e-1),-1),this.m_curveData.m_segmentFlags.write(u+e-1,1),this.m_curveData.m_segmentParamIndex.write(u+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,i=this.getPathCount();e<=i;e++){let t=this.m_paths.read(e);this.m_paths.write(e,t+n)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,i){let r=this.getPathCount();t<0&&(t=r),(t>r||t<r&&e>this.getPathSize(t))&&(0,s.r)(""),t===r&&this.addPathPoint2D(null,0,!0);let n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();let o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,l=this.m_vertexAttributes.get(0);if(a===n)this.m_paths.write(t+1,n+1),l.writePoint2D(2*a,i);else{l.insert(2*a,i,2*n);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e),s=vt.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(i*a,s,i,i*n)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,n));for(let e=t+1,i=r;e<=i;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,i){let r=this.getPathCount();t<0&&(t=r),(t>r||t<r&&e>this.getPathSize(t))&&(0,s.r)(""),t===r&&this.addPathPoint2D(null,0,!0);let n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();let o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===n)this.m_paths.write(t+1,n+1),this.setPointByValNoCurves(a,i);else{let e=i.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){let s=this.m_description.getSemantics(t),r=vt.getComponentCount(s);if(e.hasAttribute(s))this.m_vertexAttributes.get(t).insertAttributes(r*a,i,s,r*n);else{let e=vt.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(r*a,e,r,r*n)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,n));for(let e=t+1,i=r;e<=i;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)}removePointFromPath(t,e){let i=this.getPathCount();t<0&&(t=i-1),(t>=i||e>=this.getPathSize(t))&&(0,s.r)("Multi_path.remove_point");let r=this.getPathStart(t),n=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,s.r)("Multi_path.remove_point");let o=r+e;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(i*o,i,i*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>r&&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{let i=this.getPathEnd(t);n&&r+1<i&&this.isNonLinearSegment(i-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(i-1),-1),this.m_curveData.m_segmentFlags.write(i-1,1),this.m_curveData.m_segmentParamIndex.write(i-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 e=i;e>=t+1;e--){let t=this.m_paths.read(e);this.m_paths.write(e,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;let i=this.getPathStart(t);if(e>i)return this.m_curveData.m_segmentFlags.read(e-1);if(e===i){if(this.isClosedPath(t)){let e=this.getPathEnd(t);return this.m_curveData.m_segmentFlags.read(e-1)}return 1}(0,s.d)("")}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let i=this.getPathStart(t),s=this.getPathEnd(t);i<s;i++)bt.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(i))&&++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);let i=this.getPathCount(),s=bt.getPathIndexFromPointIndexImpl(this.m_paths,i,t,e);return this.m_currentPathIndex=s,s}startPathCoords(t,e){this.startPathPoint(new r.P({x:t,y:e}))}startPath(t){this.startPathPoint(new r.P({pt:t}))}startPath3D(t){this.startPathPoint(new r.P({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,i){this.startPathPoint(new r.P({x:t,y:e,z:i}))}startPathPoint(t){t.isEmpty()&&(0,s.b)("");let e,i=t.getDescription();if(this.m_description!==i){this.mergeVertexDescription(i);let s=new r.P({vd:this.m_description});t.copyCommonAttributesTo(s),e=s}else e=t;this.m_bPathStarted?this.setPointByValNoCurves(this.m_pointCount-1,e):(this.insertPoint(-1,-1,e),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=(0,r.a0)(2),this.m_paths.write(0,0),this.m_pathFlags=(0,r.a1)(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null===this.m_paths?this.beforeNewSegmentHelper2():(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1))}beforeNewSegment(t){0===this.m_pointCount&&!this.m_bPathStarted&&this.startPathCoords(0,0);let e=this.m_pointCount,i=this.m_paths.size()-1,s=e+t;this.m_paths.write(i,s),this.resizeImpl(s),this.m_bPathStarted&&=!1}finishLineTo(){if(this.hasNonLinearSegments()){let 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{let i=(0,r.W)(),s=new r.P({vd:this.m_description,attribBuffer:i,initDefaultValues:!0});s.setXYCoords(t,e),this.setPointByValNoCurves(this.m_pointCount-1,s)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);let e=(0,r.M)(this.m_description,(0,r.L)()),i=(0,r.W)(),s=new r.P({vd:e,attribBuffer:i,initDefaultValues:!0});s.setXYZ(t),this.setPointByValNoCurves(this.m_pointCount-1,s),this.finishLineTo()}lineTo3DCoords(t,e,i){this.lineTo3D(new r.k(t,e,i))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByValNoCurves(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());let e=(0,r.W)(),i=new r.P({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(i),this.setPointByValNoCurves(this.m_pointCount-1,i)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&(0,s.d)("");let e=this.getPathCount();if(t>e&&(0,s.b)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,s.d)("");let i=this.m_pointCount,r=this.getPathStart(t),n=this.getPathEnd(t);if(n-r!==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)){let e=this.m_description.getSemantics(t),s=vt.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*n,this.m_vertexAttributes.get(t),s*r,s,!0,1,s*i)}for(let i=e;i>t;i--){let t=this.m_paths.read(i);this.m_paths.write(i,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(n,1,1,i),this.m_curveData.m_segmentParamIndex.insertRange(n,-1,1,i)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,s.d)(""),t>this.getPathCount()&&(0,s.b)(""),this.m_pathFlags||(0,s.d)(""),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&&(0,s.d)(""),this.isEmpty())return;this.m_pathFlags||(0,s.d)("");let t=0,e=this.getPathCount();for(let i=0;i<e;i++)this.isClosedPath(i)&&(this.getPathSize(i)>0?t++:this.m_pathFlags.clearBits(i,1));if(0===t)return;let i=this.hasNonLinearSegments(),n=0,o=this.getPathCount(),a=this.m_description.getAttributeCount(),l=Array(a),h=null,m=null;for(let e=0;e<o;++e){let s=this.getPathStart(e),o=this.getPathSize(e),u=this.isClosedPath(e);if(o>0){let e=s+n;for(let i=0;i<a;i++)if(this.m_vertexAttributes.get(i)){let n=this.m_description.getSemantics(i),a=vt.getComponentCount(n);if(!l[i]){let e=a*(this.m_pointCount+t),s=(0,r.Y)(n,e);l[i]=s}l[i].writeRange(e*a,o*a,this.m_vertexAttributes.get(i),s*a,!0,1),u&&l[i].writeRange((e+o)*a,a,this.m_vertexAttributes.get(i),s*a,!0,1)}if(i){if(null===h){let e=this.m_pointCount+t;h=(0,r.a1)(e),m=(0,r.a0)(e)}h.writeRange(e,o,this.m_curveData.m_segmentFlags,s,!0,1),m.writeRange(e,o,this.m_curveData.m_segmentParamIndex,s,!0,1),u&&(h.write(e+o,1),m.write(e+o,-1))}}this.m_paths.write(e,s+n),u&&(this.m_pathFlags.clearBits(e,1),++n)}this.m_paths.write(o,this.m_pointCount+t),this.m_pathFlags.clearBits(o,1);for(let t=0;t<a;t++)this.m_vertexAttributes.get(t)&&this.m_vertexAttributes.set(t,l[t]);i&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=m),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())&&(0,s.b)("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);let e=this.m_pathFlags.read(t);if(1&e||this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){let e=this.getPathEnd(t)-1,i=this.m_curveData.m_segmentFlags.read(e);1!==i&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(i,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,s.b)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,s.b)("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());let i=e.getStartXY(),r=this.getPathEnd(t)-1;i.equals(this.getXY(r))||(0,s.b)("close_path_with_segment: start point mismatch");let n=e.getGeometryType();if(n===s.G.enumLine)return void this.closePathWithLine(t);{let t=ft(e);this.initSegmentData(t);let i=Ct.toSegType(n),s=this.m_curveData.m_segmentFlags.read(r);if(s!==i)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(i,1),1===s?this.modifyCurveCounter(1):this.incCurveType(s,-1);else{let t=this.m_curveData.m_segmentParamIndex.read(r);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,i)}}let i=this.m_pathFlags.read(t);1&i||this.m_pathFlags.write(t,1|i),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,i=this.m_paths.size()-1;e<i;e++){if(this.isClosedPath(e))continue;let i=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|i),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;let e=this.getPathStart(t),i=this.getPathEnd(t)-1;if(e>i)return!1;let s=this.getXY(e),r=this.getXY(i);return s.isEqualPoint2D(r)}isClosedPathIn3D(t){return(0,s.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),i=this.getPathEnd(t);e<i;e++)if(bt.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;let i=0===this.m_pointCount;if(t instanceof o.Envelope2D)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{let i=t.getDescription(),s=(0,r.W)(),n=new r.P({vd:i,attribBuffer:s,initDefaultValues:!1});for(let i=0;i<4;i++){let s=e?4-i-1:i;t.queryCornerByVal(s,n),0===i?this.startPathPoint(n):this.lineToPoint(n)}}this.closePathWithLine(),this.m_bPathStarted=!1,i&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||(0,s.b)("add_path_from_closedSegment: segment must be closed"),e){let e=t.getReversed(),i=new r.P;e.queryStart(i),this.startPathPoint(i),this.closeLastPathWithSegment(e)}else{let e=new r.P;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){let i=t.getDescription();this.mergeVertexDescription(i);let n=(0,r.W)(),o=new r.P({vd:i,attribBuffer:n,initDefaultValues:!1}),a=t.getGeometryType();if(a===s.G.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let i=!1;if((e||this.isEmptyImpl())&&(i=!0),i||t.getStartXY().equals(this.getXY(this.m_pointCount-1))||(0,s.b)("add_segment: start point mismatch"),i&&(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{let t=(0,r.W)(),e=new r.P({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}let n=ft(t);this.initSegmentData(n),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+=n;let l=Ct.toSegType(a);this.incCurveType(l,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,l)}}addSegment(t,e,i){i?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,e,i,r){for(let e=t;e<i-1;e++)this.isClosedPath(e)&&(0,s.b)("cannot interpolate across closed paths");let n=this.m_description.getAttributeCount();if(1===n)return;let o=this.calculateSubLength2D(t,e,i,r);if(0!==o)for(let s=1;s<n;s++){let n=this.m_description.getSemantics(s);this.interpolateAttributesSemanticsImpl(n,t,e,i,r,o)}}interpolateAttributesSemantics(t,e,i,r,n){if(0===t)return;this.hasAttribute(t)||(0,s.b)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,s.b)("angular interpolation");for(let t=e;t<r-1;t++)this.isClosedPath(t)&&(0,s.b)("cannot interpolate across closed paths");let o=this.calculateSubLength2D(e,i,r,n);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,i,r,n,o)}interpolateAttributesPath(t,e,i){let s=this.m_description.getAttributeCount();if(1===s||e===i)return;let r=this.calculatePathSubLength2D(t,e,i);for(let n=1;n<s;n++){let s=this.m_description.getSemantics(n);this.interpolateAttributesSemanticsPathImpl(s,t,e,i,r)}}interpolateAttributesSemanticsPath(t,e,i,r){if(0===t)return;this.hasAttribute(t)||(0,s.b)("does not have the given attribute"),2===vt.getInterpolation(t)&&(0,s.b)("angular interpolation");let n=this.calculatePathSubLength2D(e,i,r);0!==n&&this.interpolateAttributesSemanticsPathImpl(t,e,i,r,n)}interpolateAttributesSemanticsImpl(t,e,i,s,r,o){let a=this.querySegmentIterator(),l=this.getPathStart(e)+i,h=this.getPathStart(s)+r,m=vt.getComponentCount(t),u=(0,n.c)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,l,u,m);let d=(0,n.c)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,h,d,m);let g=(0,n.c)(vt.maxComponentCount(),NaN);(0,n.f)(g,u,0,0,m);let c=0,_=vt.getDefaultValue(t),p=vt.getInterpolation(t);a.resetToVertex(l,e);do{if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===h)return;this.setAttributeFromArray(t,a.getStartPointIndex(),g,m),a.previousSegment();do{let e=a.nextSegment();if(a.getEndPointIndex()===h)return;c+=e.calculateLength2D();let i=c/o;(0,n.aa)(p,u,d,g,0,m,i,_),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),g,m)}while(a.hasNextSegment())}}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,i,r,o){(0,s.g)(0!==t);let a=this.querySegmentIterator(),l=vt.getInterpolation(t),h=this.getPathStart(e)+i,m=this.getPathStart(e)+r;if(m===h)return;let u=vt.getComponentCount(t),d=(0,n.c)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,h,d,u);let g=(0,n.c)(vt.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,m,g,u);let c=new n.K(0);a.resetToVertex(h,e),a.setCirculator(this.isClosedPath(e));let _=vt.getDefaultValue(t),p=(0,n.c)(vt.maxComponentCount(),NaN);(0,n.f)(p,d,0,0,u);let f=0===o,y=.5;do{let e=a.nextSegment();if(this.setAttributeFromArrayNoCurves(t,a.getStartPointIndex(),p,u),!f){let t=e.calculateLength2D();c.pe(t),y=c.getResult()/o}(0,n.aa)(l,d,g,p,0,u,y,_)}while(a.getEndPointIndex()!==m)}querySegment(t,e,i){let r=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(r);n>=this.getSegmentCountPath(r)&&(0,s.b)("get_segment"),this.getSegmentFromPath(r,n,e,i)}getSegment(t,e){let i=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,i,e),i.releaseSegment()}getSegmentType(t){let e=this.getPathIndexFromPointIndex(t),i=t-this.getPathStart(e);return i>=this.getSegmentCountPath(e)&&(0,s.b)("get_segment"),this.getSegmentTypeFromPath(e,i)}getSegmentFromPath(t,e,i,n){let o=this.getPathStart(t)+e,a=this.getSegmentFlagsStreamRef(),l=1;switch(a&&(l=31&a.read(o)),l){case 1:i.createLine();break;case 2:i.createCubicBezier();break;case 4:i.createEllipticArc();break;case 8:i.createQuadraticRationalBezier();break;case 16:i.createQuadraticBezier();break;default:(0,s.d)("")}let h,m=i.get(),u=null;if(n?(u=(0,r.K)(),m.assignVertexDescription(u)):m.assignVertexDescription(this.m_description),h=o===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):o+1,b(m,this.getXY(o)),D(m,this.getXY(h)),!n)for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=vt.getComponentCount(e);for(let t=0;t<i;t++){let i=this.getAttributeAsDbl(e,o,t);m.setStartAttribute(e,t,i);let s=this.getAttributeAsDbl(e,h,t);m.setEndAttribute(e,t,s)}}if(bt.isNonLinearSegmentFlag(l)){let t=this.m_curveData.m_segmentParamIndex.read(o);m.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments()||0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,i=this.getPointCount();e<i;e++)if(4===this.m_curveData.m_segmentFlags.read(e)){let i=this.m_curveData.m_segmentParamIndex.read(e);pt(this.m_curveData.m_segmentParams,i).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,e,i,r=!1){let o={iSegment:-1},a=r?o:{tSegment:0};if(i.setEmpty(),this.isEmpty()||((t<0||t>=this.getPathCount())&&(0,s.b)("query_point_along_path"),e<0))return o;let l=this.getPathSize(t);if(0===l)return o;if(1===l)return this.getPointByVal(this.getPathStart(t),i),a.tSegment=0,o.iSegment=this.getPathStart(t),o;let h=this.querySegmentIteratorAtVertex(this.getPathStart(t)),m=new n.K(0);for(;h.hasNextSegment();){let t=h.nextSegment(),s=t.calculateLength2D(),r=m.getResult();if(m.add(s),m.getResult()>=e){let n=e-r;n>s&&(n=s);let l=t.lengthToT(n);return t.queryCoord(l,i),a.tSegment=l,o.iSegment=h.getStartPointIndex(),o}}if(this.isClosedPath(t)){let e=this.getPathStart(t);return this.getPointByVal(e,i),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}{let e=this.getPathEnd(t)-1;return this.getPointByVal(e,i),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2,o):(a.tSegment=0,o.iSegment=this.getPathStart(t),o)}}queryPointsAlongPath(t,e,i,r,o,a){{let t=0;for(let n=0;n<e;++n)r&&r[n].setEmpty(),o&&(o[n]=-1),a&&(a[n]=0),t>i[n]&&(0,s.b)("query_points_along"),t=i[n]}let l=this.getPathSize(t);if(0===e||0===l)return 0;if(1===l){let e=this.getPathStart(t);return r&&this.getPointByVal(e,r[0]),a&&(a[0]=0),o&&(o[0]=e),1}let h=this.getPathStart(t),m=new n.K(0),u=this.querySegmentIteratorAtVertex(h),d=0,g=0,c=i[d];for(;u.hasNextSegment();){let t=u.nextSegment(),s=t.calculateLength2D(),n=m.getResult();for(m.add(s);m.getResult()>=c;){let l=c-n;l>s&&(l=s);let h=t.lengthToT(l);if(r&&t.queryCoord(h,r[g]),a&&(a[g]=h),o&&(o[g]=u.getStartPointIndex()),g++,d++,c=i[d],d===e)return g}}if(this.isClosedPath(t)){let e=this.getPathStart(t);r&&this.getPointByVal(e,r[g]),a&&(a[g]=0),o&&(o[g]=e),g++}else if(this.getPathSize(t)>1){let e=this.getPathEnd(t)-2;r&&this.getPointByVal(e+1,r[g]),a&&(a[g]=1),o&&(o[g]=e),g++}return g}queryPointsAlong(t,e,i,r,o){{let n=0;for(let a=0;a<t;++a)i&&i[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),n>e[a]&&(0,s.b)("query_points_along"),n=e[a]}if(0===t)return 0;let a=new n.K(0),l=this.querySegmentIterator(),h=-1,m=0,u=0,d=e[m];for(;l.nextPath();)for(;l.hasNextSegment();){h=l.getPathIndex();let s=l.nextSegment(),n=s.calculateLength2D(),g=a.getResult();for(a.add(n);a.getResult()>=d;){let a=d-g;a>n&&(a=n);let h=s.lengthToT(a);if(i&&s.queryCoord(h,i[u]),o&&(o[u]=h),r&&(r[u]=l.getStartPointIndex()),u++,m++,d=e[m],m===t)return u}}if(h<0)return 0;if(this.isClosedPath(h)){let t=this.getPathStart(h);i&&this.getPointByVal(t,i[u]),o&&(o[u]=0),r&&(r[u]=t),u++}else if(this.getPathSize(h)>1){let t=this.getPathEnd(h)-2;i&&this.getPointByVal(t+1,i[u]),o&&(o[u]=1),r&&(r[u]=t),u++}return u}querySegmentIterator(){return new dt({parent:this})}querySegmentIteratorAtVertex(t){return new dt({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,e,i){if(e instanceof r.E&&(0,s.g)(0,"not implemented for Envelope"),e instanceof r.r&&(0,s.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,s.b)(""),this.isEmpty())return void e.setEmpty();let n=this.getAttributeStreamRef(0),a=o.Envelope2D.constructEmpty();a.setEmpty();for(let e=2*this.getPathStart(t),i=2*this.getPathEnd(t);e<i;){let t=i-e;(0,s.g)(!(1&t)),a.mergePointsInterleaved(n,e/2,t/2),e+=t}if(e.setCoords({env2D:a}),this.hasNonLinearSegmentsPath(t)){let r=this.querySegmentIterator();if(r.resetToPath(t),r.nextPath())for(;r.hasNextSegment();){let t=r.nextCurve();if(!t)break;{let s=o.Envelope2D.constructEmpty();i?t.queryEnvelope(s):t.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}else(0,s.g)(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams||this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;let t=yt(4)*this.m_curveData.m_arcCount+yt(2)*this.m_curveData.m_bezierCount+yt(8)*this.m_curveData.m_rbezier2Count+yt(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*t>>1,10)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let e=0,i=this.getPointCount();e<i;e++){let i=this.m_curveData.m_segmentFlags.read(e);bt.isNonLinearSegmentFlag(i)&&(t+=yt(i))}let e=(0,r.a2)(t),i=0;for(let t=0,s=this.getPointCount();t<s;t++){let s=this.m_curveData.m_segmentFlags.read(t);if(bt.isNonLinearSegmentFlag(s)){let r=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,i);let n=yt(s);for(let t=0;t<n;t++)e.write(i,this.m_curveData.m_segmentParams.read(r)),i++,r++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=i}setEmpty(){this.m_curveData&&=(this.removeAllCurvesFromGlobalCounter(),null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){(0,s.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=(0,r.a0)(0),this.m_pathFlags=(0,r.a1)(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))}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=(0,r.a0)(0),this.m_pathFlags=(0,r.a1)(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)))}clone(){let t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new Et(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null==this.m_curveData?null:this.m_curveData.m_segmentFlags}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null===this.m_curveData?null:this.m_curveData.m_segmentParamIndex}getSegmentDataStreamRef(){return this.throwIfEmpty(),null===this.m_curveData?null:this.m_curveData.m_segmentParams}setSegmentData(t,e,i,s){this.m_curveData||=new Ct,this.m_curveData.m_segmentFlags=i,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=s}static getPathIndexFromPointIndexImpl(t,e,i,r){if(r>=0&&r<e){if(i>=t.read(r)){if(i<t.read(r+1))return r;r++}else r--;if(r>=0&&r<e&&i>=t.read(r)&&i<t.read(r+1))return r}if(e<5){for(let s=0;s<e;s++)if(i<t.read(s+1))return s;(0,s.o)("")}let n=0,o=e-1;for(;o>n;){let e=n+(o-n>>1);if(i<t.read(e))o=e-1;else{if(!(i>=t.read(e+1)))return e;n=e+1}}return n}getHighestPointIndex(t){(0,s.g)(t>=0&&t<this.getPathCount());let e=this.getAttributeStreamRef(0),i=this.getPathEnd(t),r=this.getPathStart(t),o=-1,a=new n.P;a.y=-1/0,a.x=-1/0;for(let t=r+0;t<i;t++){let i=e.readPoint2D(2*t);-1===a.compare(i)&&(o=t,a.setCoordsPoint2D(i))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,s.b)("apply_transformation"),this.isEmpty()||t.isIdentity())return;let i=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let s,r;return e<0?(s=0,r=this.m_pointCount):(s=this.getPathStart(e),r=this.getPathEnd(e)),i.applyTransformation(t,2*s,r-s),void this.notifyModifiedFlags(2001)}let r=new this.m_segmentBufferCTor,o=this.getPathCount(),a=e<0?0:e;do{let s=this.getPathStart(a),o=this.getPathEnd(a),l=this.isClosedPath(a),h=i.readPoint2D(2*s);if(!this.hasNonLinearSegmentsPath(a)){i.applyTransformation(t,2*s,o-s);continue}let m=n.P.getNAN();for(let e=s;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){let n=l&&e+1===o;n&&i.writePoint2D(2*s,h),this.getSegmentBuffer(e,r,!0),r.get().applyTransformation(t);let a=this.m_curveData.m_segmentParamIndex.read(e);r.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),i.writePoint2D(2*e,r.get().getStartXY()),n&&i.writePoint2D(2*s,r.get().getEndXY());continue}let n=2*e;i.queryPoint2D(n,m),t.transformInPlace(m),i.writePoint2D(n,m)}if(a===e)break}while(++a<o);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,i,r){let n=this.getPathStart(t)+e,o=this.getPathStart(i)+r;(o<n||n<0||o>this.getPointCount()-1)&&(0,s.q)("");let a=this.querySegmentIterator(),l=0;a.resetToVertex(n,t);do{for(;a.hasNextSegment();){let t=a.nextSegment();if(a.getStartPointIndex()===o)break;l+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return l}calculatePathSubLength2D(t,e,i){let r=this.getPathStart(t)+e,n=this.getPathStart(t)+i;(r<0||n>this.getPointCount()-1)&&(0,s.q)("");let o=this.querySegmentIterator();if(r>n&&(this.isClosedPath(t)||(0,s.b)("cannot iterate across an open path"),o.setCirculator(!0)),r===n)return 0;let a=0,l=0;o.resetToVertex(r,t);do{l+=a,a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==n);return l}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){let e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){let i=o.Envelope2D.constructEmpty(),s=this.querySegmentIterator();for(;s.nextPath();)for(;s.hasNextSegment();){let r=s.nextCurve();if(!r)break;t?r.queryEnvelope(i):r.queryLooseEnvelope(i),e.mergeEnvelope2D(i)}}return e}notifyModifiedAllImpl(){this.m_pointCount=null!==this.m_paths&&this.m_paths.size()?this.m_paths.read(this.m_paths.size()-1):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,e){this===t&&(0,s.b)("Multi_path_impl::add");let i=this.getPathCount();for(let s=0,r=t.getPathCount();s<r;s++)this.addPath(t,s,!e),this.openPathAndDuplicateStartVertex(i),i++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,i){let r=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(r);n>=this.getSegmentCountPath(r)&&(0,s.b)("getSegmentBuffer"),this.getSegmentFromPath(r,n,e,i)}getSegmentTypeFromPath(t,e){let i=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef(),n=1;switch(r&&(n=31&r.read(i)),n){case 1:return s.G.enumLine;case 2:return s.G.enumBezier;case 4:return s.G.enumEllipticArc;case 8:return s.G.enumRationalBezier2;case 16:return s.G.enumBezier2;default:(0,s.d)("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,i=this.getPathCount();e<i;e++){let i=this.getPathStart(e),r=this.getPathEnd(e),o=r-i;for(let e=i;e<r;e++){let r=31&this.m_curveData.m_segmentFlags.read(e);if(1===r)continue;2!==r&&(0,s.a)("ensure_xy_monotone_segments");let a=(e-i+1)%o+i,l=this.m_curveData.m_segmentParamIndex.read(e),h=(0,n.d)(n.P,4);h[0]=this.getXY(e),h[3]=this.getXY(a),h[1].x=this.m_curveData.m_segmentParams.read(l),h[1].y=this.m_curveData.m_segmentParams.read(l+1),h[2].x=this.m_curveData.m_segmentParams.read(l+2),h[2].y=this.m_curveData.m_segmentParams.read(l+3),f(h)&&(t=!0,this.m_curveData.m_segmentParams.write(l,h[1].x),this.m_curveData.m_segmentParams.write(l+1,h[1].y),this.m_curveData.m_segmentParams.write(l+2,h[2].x),this.m_curveData.m_segmentParams.write(l+3,h[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||=new gt,null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);let e=(0,r.u)(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||=new gt,null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);let e=(0,r.a3)(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(bt.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||=new Ct,bt.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||=new Ct,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?0:this.m_curveData.m_curveParamWritePoint}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Ct);let e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=(0,r.a1)(e,1),this.m_curveData.m_segmentParamIndex=(0,r.a0)(e,-1));let i=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=(0,r.a2)(i):i!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(i,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 Ct),this.m_curveData.m_curveParamWritePoint=t}static st_totalCurveCount=0;updateOGCFlagsHelper(){let t=this.getPathCount();if(0===t)return;let e=this.m_pathFlags,i=0;for(let s=0;s<t;s++){let t=this.m_cachedRingAreas2D.read(s);0===i&&(i=(0,n.h)(t)),t*i>0||0===i?e.setBits(s,8):e.clearBits(s,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,e,i){(t<0||t>=this.getPointCount())&&(0,s.b)("Multi_path_impl.replace_segment"),(0,s.g)(e.isCurve());let r=this.getPathIndexFromPointIndex(t),n=this.getPathStart(r),o=(t-n+1)%this.getPathSize(r)+n;{let i=this.getXY(t),r=this.getXY(o),n=!i.isEqualPoint2D(e.getStartXY())||!r.isEqualPoint2D(e.getEndXY());(0,s.g)(!n)}this.replaceSegmentImpl(t,o,e,i)}replaceSegmentImpl(t,e,i,o){let a=i.getDescription();this.mergeVertexDescription(a);let l,h=(0,n.c)(32,NaN),m=new r.P({vd:a,attribBuffer:h,initDefaultValues:!1}),u=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),d=yt(u),g=ft(i),c=!1;d>=g?((0,s.g)(null!==this.m_curveData),c=!0,l=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(g),c=!1,l=this.m_curveData.m_curveParamWritePoint);let _=i.getGeometryType(),p=Ct.toSegType(_);o||(i.queryStart(m),this.setPointByValNoCurves(t,m),i.queryEnd(m),this.setPointByValNoCurves(e,m)),this.m_curveData.m_segmentParamIndex.write(t,1===p?-1:l),this.m_curveData.m_segmentFlags.write(t,p),1!==p&&i.writeInBufferStream(this.m_curveData.m_segmentParams,l),c||(this.m_curveData.m_curveParamWritePoint+=g),u!==p&&(this.incCurveType(u,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===u?1:-1))}setAttributeImpl(t,e,i){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,s.b)("");let t=new a.T,r=0===e?i:0,n=0===e?0:1;t.setShiftCoords(r,n),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,i)}toFlatGeometry(){let t,e,i,s=this.m_bPolygon?"polygon":"polyline",r=this.getPathCount(),n=this.m_paths?this.m_paths.getArray():new Int32Array,o=this.m_paths?this.m_pathFlags.getArray():new Int8Array,a=0,l=0;if(this.m_curveData){let{m_segmentFlags:s,m_segmentParamIndex:r,m_segmentParams:n}=this.m_curveData;t=s?.getArray()??new Int8Array,e=r?.getArray()??new Int32Array,i=n?.getArray()??new Float64Array,a=this.m_curveData.m_arcCount,l=this.m_curveData.m_bezierCount}return{type:s,...this.exportVertexAttributes(),partCount:r,partOffsets:n,partFlags:o,segmentFlags:t,segmentIndices:e,segmentParams:i,segmentCountArc:a,segmentCountBezier:l}}m_cachedLength2D;m_cachedArea2D;m_currentPathIndex;m_cachedRingAreas2D=null;m_paths=null;m_pathFlags=null;m_curveData=null;m_segmentBufferCTor}class Et{constructor(t,e){this.m_extentOfInterest=new o.Envelope2D(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()}m_extentOfInterest;m_bfirst;m_prevIndex;m_parent;m_segIter=null;m_quadTree=null;m_qtIter=null;prepare_(){let 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;let t=this.m_qtIter.next();if(-1===t)return null;let e=this.m_quadTree.getElement(t);return(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e),this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){let t=this.m_segIter.nextSegment(),e=o.Envelope2D.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 Dt extends bt{static type=s.G.enumPolyline;constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=Xn):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Xn,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Xn):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=Xn,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=Xn,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,s.d)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=Xn)}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Dt.type}getDimension(){return 1}createInstance(){return new Dt({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}var wt=s.G;function St(t,e){if(t.isEmpty())return!1;let i=t.getGeometryType();if(i===wt.enumPolygon)return 0!==t.calculateArea2D();if(i===wt.enumPolyline)return Tt(t.getImpl(),0,!0).bNotEmpty;if(i===wt.enumEnvelope)return!0;if((0,s.h)(i))return!!t.isClosed();if((0,s.f)(i))return!1;if(i===wt.enumGeometryCollection){let i=t;for(let t=0,s=i.getGeometryCount();t<s;t++)if(St(i.getGeometry(t),e))return!0;return!1}(0,s.a)("")}function At(t,e){let i=t.getGeometryType();if(i===wt.enumPolygon){let e=new Dt({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(i===wt.enumPolyline)return Tt(t.getImpl(),0,!1).boundary;if(i===wt.enumEnvelope){let e=new Dt({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,s.h)(i)){let e=new W({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){let i=new r.P;e.reserve(2),t.queryStart(i),e.add(i),t.queryEnd(i),e.add(i)}return e}if(i===wt.enumGeometryCollection){let i=t,s=null;for(let r=0,n=i.getGeometryCount();r<n;r++){let n=At(i.getGeometry(r),e);if(null!==n){null===s&&(s=t.createInstance());let e=n;s.addGeometry(e)}}return s}if((0,s.f)(i))return new r.P({vd:t.getDescription()});(0,s.a)("")}function Tt(t,e,i){let s=t,o=null;if(i||(o=new W({vd:s.getDescription()})),!s.isEmpty()){let t=new r.a(0);for(let e=0,i=s.getPathCount();e<i;e++)if(s.getPathSize(e)>0&&!s.isClosedPathInXYPlane(e)){let i=s.getPathStart(e);t.add(i);let r=s.getPathEnd(e)-1;t.add(r)}if(t.size()>0){let e=new r.B,a=s.getAttributeStreamRef(0);e.sort(t,0,t.size(),{userSort(t,e,i){let s=n.P.getNAN(),r=n.P.getNAN();i.sort(t,e,(t,e)=>(a.queryPoint2D(2*t,s),a.queryPoint2D(2*e,r),s.compare(r)))},getValue:t=>a.read(2*t+1)});let l=a.readPoint2D(2*t.read(0)),h=0,m=1,u=new r.P;for(let e=1,s=t.size();e<s;e++){let s=a.readPoint2D(2*t.read(e));if(s.isEqualPoint2D(l))t.read(h)>t.read(e)?(t.write(h,(0,n.b)()),h=e):t.write(e,(0,n.b)()),m++;else{if(1&m){if(i)return{bNotEmpty:!0,boundary:new W({})}}else t.write(h,(0,n.b)());l=s,h=e,m=1}}if(1&m){if(i)return{bNotEmpty:!0,boundary:new W({})}}else t.write(h,(0,n.b)());if(!i){t.sort(0,t.size());for(let e=0,i=t.size();e<i&&t.read(e)!==(0,n.b)();e++)s.getPointByVal(t.read(e),u),o.add(u)}}}return i?{bNotEmpty:!1,boundary:new W({})}:{bNotEmpty:!1,boundary:o}}function It(t,e,i,r){let o=4*(0,n.I)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,n.I)();if(1===t.getMaxDerivative()){(0,s.g)(i>0);let a=Rt(t,0,e,(0,n.I)(),o);return r[0]=a.root,a.cRoots}let l,h=[],m=new n.E(e.vmin-o,e.vmax+o);h.push(new n.P(m.vmin,m.vmax));let u=0;for(let s=t.getMaxDerivative()-1;s>=0;s--){l=h,h=[];for(let m=0,d=l.length;m<d;m++){if(l[m][0]<l[m][1]){let d,g,c;if(s===t.getMaxDerivative()-1?({root:d,funcAtRoot:g,cRoots:c}=Rt(t,s,n.E.construct(l[m][0],l[m][1]),a,.5*o)):({root:d,funcAtRoot:g,cRoots:c}=Yt(t,s,n.E.construct(l[m][0],l[m][1]),0,.5*o)),1===c){if(0===s)u<i&&(l[m][0]<=e.vmin&&l[m][1]>=e.vmin&&d!==e.vmin&&0===t.getValue(0,e.vmin)&&(d=e.vmin),l[m][0]<=e.vmax&&l[m][1]>=e.vmax&&d!==e.vmax&&0===t.getValue(0,e.vmax)&&(d=e.vmax),r[u]=e.snapClip(d),u>0?r[u]-r[u-1]>o&&u++:u++);else{let t=n.P.getNAN();t[0]=l[m][0],t[1]=d,h.push(t);let e=n.P.getNAN();e[0]=d,e[1]=l[m][1],h.push(e)}continue}}h.push(l[m])}}return u}function Mt(t,e,i,s,r,o){let a=(0,n.d)(n.Z,2),l=Lt(new n.Z(t),new n.Z(e),new n.Z(i),s,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),l}function qt(t,e,i,s,r,o,a){let l=(0,n.d)(n.Z,3),h=zt(new n.Z(t),new n.Z(e),new n.Z(i),new n.Z(s),r,o,l);return a[0]=l[0].value(),a[1]=l[1].value(),a[2]=l[2].value(),h}function Nt(t,e,i,s,r,o,a,l){return function(t,e,i,s,r,o,a,l){let h=(0,n.c)(i*i,NaN);h.fill(0),(0,n.f)(l,s,0,0,i);let m=(0,n.c)(i,NaN),u=(0,n.c)(i,NaN),d=(0,n.c)(i,NaN),g=t(l,i,e),c=0;for(c=0;c<100;c++){let s=g;for(let t=0;t<i;++t)u[t]=l[t];if(c%i===0){h.fill(0);for(let t=0;t<i;t++)h[t*i+t]=1}let a=0,_=0;for(let s=0;s<i;++s){for(let t=0;t<i;++t)m[t]=h[s*i+t];let n=g;g=Xt(t,e,l,m,r,o,i);let u=n-g;u>a&&(_=s,a=u)}for(let t=0;t<i;t++)m[t]=l[t]-u[t],d[t]=l[t]+(l[t]-u[t]);let p=t(d,i,e);if(p<s&&2*(s-2*g+p)*(0,n.e)(s-g-a)<(0,n.e)(s-p)*a){g=Xt(t,e,l,m,r,o,i);for(let t=0;t<i;++t)h[_*i+t]=h[(i-1)*i+t],h[(i-1)*i+t]=m[t]}if(s<=g)return t(l,i,e)}return g}(t,e,i,s,r,o,0,l)}function Rt(t,e,i,r,o){let a={root:0,funcAtRoot:0,cRoots:0},l=i.vmin,h=i.vmax,m=0,u=Number.MAX_VALUE,d=t.getValue(e,l),g=t.getValue(e,h),c=0,_=0,p=0;if(d>=0&&g>=0||d<=0&&g<=0)return Math.abs(d)<Math.abs(g)?(a.funcAtRoot=d,a.root=l,a.cRoots=+(0===d),a):(a.funcAtRoot=g,a.root=h,a.cRoots=+(0===g),a);Math.abs(d)<Math.abs(g)&&(h=(0,n.s)(l,l=h),g=(0,n.s)(d,d=g)),m=l,c=d;let f=!0,y=0;for(;0!==g&&Math.abs(l-h)>r*Math.abs(h)+o;y++){let i=y>64;if(!i){_=d!==c&&g!==c?l*g*c/((d-g)*(d-c))+h*d*c/((g-d)*(g-c))+m*d*g/((c-d)*(c-g)):h-g*(h-l)/(g-d);let t=(3*l+h)/4;if(i=!(_>t&&_<h||_>h&&_<t),!i){let t=r*Math.abs(h)+o;if(f){let e=Math.abs(h-m);i=Math.abs(_-h)>=.5*e||e<t}else{let e=Math.abs(m-u);i=Math.abs(_-h)>=.5*e||e<t}}}if(i?(_=(l+h)/2,f=!0):f=!1,p=t.getValue(e,_),0===p)return a.root=_,a.funcAtRoot=p,a.cRoots=1,a;if(!i){let i=l-_,s=_-h;if(Math.abs(i)>10*Math.abs(s)){let i=h+3*s;for(let s=0;s<2;s++){let s=t.getValue(e,i);(0,n.h)(d)*(0,n.h)(s)>0?(l=i,d=s):i=(0,n.r)(l,h,.75)}}else if(Math.abs(s)>10*Math.abs(i)){let s=l-3*i;for(let i=0;i<2;++i){let i=t.getValue(e,s);(0,n.h)(g)*(0,n.h)(i)>0?(h=s,g=i):s=(0,n.r)(l,h,.25)}}}u=m,m=h,c=g,(0,n.h)(d)*(0,n.h)(p)<0?(h=_,g=p):(l=_,d=p),Math.abs(d)<Math.abs(g)&&(h=(0,n.s)(l,l=h),g=(0,n.s)(d,d=g)),128===y&&(0,s.d)("Root_finder iterations exceeded")}return a.root=h,a.funcAtRoot=g,a.cRoots=1,a}function Yt(t,e,i,r,o){let a={root:0,funcAtRoot:0,cRoots:0},l=i.vmin,h=t.getValue(e,l),m=i.vmax,u=t.getValue(e,m);if(h>=0&&u>=0||h<=0&&u<=0)return Math.abs(h)<Math.abs(u)?(a.funcAtRoot=h,a.root=l,a.cRoots=+(0===h),a):(a.funcAtRoot=u,a.root=m,a.cRoots=+(0===u),a);u<0&&(u=(0,n.s)(h,h=u),m=(0,n.s)(l,l=m));let d=.5*(l+m),g=Math.abs(m-l),c=g,_=t.getValue(e,d),p=t.getValue(e+1,d),f=4,y=1,P=0,x=0,v=1,C=0;for(;++C<100;){C>32||0===p||2===v&&P>1||1===v&&f<4?(v=1,y>1&&y--):(v=2,x>1&&Math.abs(2*_)>Math.abs(g*p)&&y++),g=c;let i,s=!1;if(1===v)do{if(x>2){let t=16*Math.abs(g);if(.5*Math.abs(l-m)>t){let e=Math.min(l,m),s=Math.max(l,m);if(d===e){i=d,d=e+t,c=d-i;break}if(d===s){i=d,d=s-t,c=d-i;break}}}c=.5*(m-l),i=d,d=l+c,s=l===d||m===d}while(0);else for(;;){c=y*_/p,i=d,d-=c,s=d===i;let t=Math.min(l,m),e=Math.max(l,m);if(d<t){if(y>1){d=i,y--;continue}c=i-t,d=t}else if(d>e){if(y>1){d=i,y--;continue}c=i-e,d=e}break}if(s||Math.abs(c)<o){i!==d&&(_=t.getValue(e,d));break}_=t.getValue(e,d),p=t.getValue(e+1,d);let r=l,n=m;_<0?(h=_,l=d):(u=_,m=d),2===v&&(l===r&&m===n||x>1&&Math.abs(c)>=.5001*Math.abs(g))?P++:P=0,1===v?(f++,x=0):(f=0,x++)}return 100===C&&(0,s.d)("Root_finder iterations exceeded"),a.root=d,a.funcAtRoot=_,a.cRoots=1,a}function Xt(t,e,i,s,r,o,a){let l=s.slice(0,a),h=0;for(let t=0;t<a;t++)h+=s[t]*s[t];if(h=Math.sqrt(h),h>0)for(let t=0;t<a;t++)l[t]/=h;let m=-1/0,u=1/0;{let t=(0,n.c)(a,0);for(let e=0;e<a;e++)t[e]=e;t.sort((t,e)=>{let i=Math.abs(l[t]),s=Math.abs(l[e]);return i<s?-1:+(i>s)});for(let e=0;e<a;e++){let s=t[e];if(0===l[s])continue;let a=(r[s]-i[s])/l[s],h=(o[s]-i[s])/l[s];h<a&&(h=(0,n.s)(a,a=h)),a>m&&(m=a),h<u&&(u=h)}}let d=0,g=(Math.abs(m)+Math.abs(u))*(0,n.I)()*100,c=(0,n.c)(a,NaN),_=l.slice();function p(s,r){for(let t=0,e=a;t<e;t++)c[t]=i[t]+s*_[t];return t(c,a,e)}g>0&&(d=function(t,e,i,s,r,o){return function(t,e,i,s,r,o){let a=(0,n.a2)(),l=s,h=t(l,e),m=i,u=r,d=t(m,e),g=t(u,e);h>d&&(h=d,l=m),h>g&&(h=g,l=u);let c=m,_=u,p=d,f=g;p>f&&(p=(0,n.s)(f,f=p),_=(0,n.s)(c,c=_));let y=l-c,P=c-_,x=.5*Math.min(o,u-m),v=2*x,C=0,b=0;for(;b<100&&!(u-m<=v);++b){let i=m+.5*(u-m),s=C>0;if(!s&&Math.abs(P)<=x&&(s=!0,C=3),!s){let t=l-c,e=l-_,i=t*(h-f),r=e*(h-p),n=e*r-t*i;r=2*(r-i),r>0&&(n=-n),r=Math.abs(r),0===r||Math.abs(n)>=Math.abs(r*P/2)||n<=r*(m-l)||n>=r*(u-l)?(s=!0,C=3):(P=y,y=n/r)}s&&(P=l>=i?m-l:u-l,y=a*P,C--);let r=l+y;r<m+x?r=m+x:r>u-x&&(r=u-x);let n=t(r,e);n<h?(r>=l?(m=l,d=h):(u=l,g=h),_=c,c=l,l=r,f=p,p=h,h=n):(r<l?(m=r,d=n):(u=r,g=n),n<=p||c===l?(_=c,c=r,f=p,p=n):(n<=f||_===l||_===c)&&(_=r,f=n))}return l}(t,e,i,s,r,o)}(p,null,m,0,u,g));let f=p(d);for(let t=0,e=a;t<e;t++)i[t]=(0,n.a)(c[t],r[t],o[t]);return f}function Ft(t,e,i,s){return t.isZero()?e.isZero()?-1:0:(s.setE(e.clone().negateThis().divThisE(t)),+!!i.containsCoordinate(s.value()))}function Lt(t,e,i,s,r,o){if(0===t.value())return r?(o[0].set(1),+!!s.containsCoordinate(o[0].value())):Ft(e,i,s,o[0]);if(r){let e=2;return o[0].set(1),o[1].setE(i).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),s.containsCoordinate(o[1].value())||(e=1),s.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,n.s)(o[0],o[0]=o[1])),e}let a=e.clone().sqrThis().subThisE(t.clone().mulThisE(i).mulThisE(n.aq));if(a.lt(n.T))return 0;let l=new n.Z(e.value()>=0?1:-1),h=a.clone().sqrtThis(),m=new n.Z(-.5).mulThisE(e.clone().addThisE(l.clone().mulThisE(h))),u=0;o[0].setE(m.divE(t));let d=new n.Z(o[0].value()),g=new n.Z(t.value()).mulE(d).addE(new n.Z(e.value()).mulE(d).addE(new n.Z(i.value())));return g.isZero()||Wt(o[0],t,e,i,o[0]),s.containsCoordinate(o[0].value())&&u++,0!==h.value()&&0!==m.value()?(o[u].assign(i.divE(m)),d.set(o[u].value()),g.assign(new n.Z(t.value()).mulE(d).addE(new n.Z(e.value()).mulE(d).addE(new n.Z(i.value())))),g.isZero()||Wt(o[u],t,e,i,o[u]),s.containsCoordinate(o[u].value())&&u++,2===u&&o[0].value()>o[1].value()&&(o[1]=(0,n.s)(o[0],o[0]=o[1])),u):u}function zt(t,e,i,r,o,a,l){if(0===t.value())return Lt(e,i,r,o,a,l);if(a){let i=1;l[0].set(1);let s=l.slice(i),a=Lt(t,e.addE(t),r.negate(),o,!1,s);if(a>0){i+=a;for(let t=1;t<i;t++)l[t].eq(n.a7)&&(l[i-1]=(0,n.s)(l[t],l[t]=l[i-1]),i--)}let h=l.slice(0,i);h.sort((t,e)=>t.value()<e.value()?-1:+(t.value()>e.value()));for(let t=0;t<i;++t)l[t]=h[t];return i}return function(t,e,i,r,o,a){let l=(0,n.d)(n.Z,3),h=0,m=e.negate().divThisE(t.clone().mulThis(3));o.containsCoordinate(m.value())&&(l[0].setE(m),h=1);let u=(0,n.d)(n.Z,2),d=Lt(t.mul(3),e.mul(2),i,o,!1,u);if(d<0)return r.isZero()?-1:0;for(let t=0;t<d;t++)o.containsCoordinate(u[t].value())&&l[h++].setE(u[t]);(0,n.ab)(l,0,h,(t,e)=>t.value()<e.value()?-1:+(t.value()>e.value()));let g=(0,n.d)(n.Z,5);g[0].set(o.vmin);for(let t=0;t<h;t++)g[1+t].setE(l[t]);g[1+h].set(o.vmax);let c=h+2,_=1,p=0;{let s=g[0].clone();if(t.clone().mulThisE(s).addThisE(e).mulThisE(s).addThisE(i).mulThisE(s).addThisE(r).isZero()){let n=Bt(t,e,i,r);s.setError(n.estimateError(s.value())),a[p]=s,p++,_++}}for(let n=_;n<c;n++){let l=g[n].clone(),h=t.clone().mulThisE(l).addThisE(e).mulThisE(l).addThisE(i).mulThisE(l).addThisE(r).isZero();if(h||!g[n].eq(g[n-1])){if(h||Zt(g[n-1].value(),g[n].value(),g[n-1].clone().addThisE(g[n]).divThisByPower2(2),t,e,i,r,l)){if(p>0&&l.eq(a[p-1]))continue;if(p>=3&&(0,s.d)("cubic_polynomial_solver_too_many_roots"),h){let s=Bt(t,e,i,r);l.setError(s.estimateError(l.value()))}a[p]=l,p++}if(g[n].value()===o.vmax)break;if(h){n++;continue}}}return p}(t,e,i,r,o,l)}function Vt(t,e,i,r,o,a){return(a<e||e<0)&&(0,s.b)("nth_degree_real_roots"),function(t,e,i,s,r){let o=new kt(t,e,i,(0,n.I)()),a=0;if(2===o.truePower)a=Lt(t[2],t[1],t[0],i,s,r);else if(1===o.truePower)a=Ft(t[1],t[0],i,r[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{let t=[];t.length=e,a=It(o,i,e,t);for(let e=0;e<a;e++)r[e].set(t[e])}}for(let t=0;t<a;t++)r[t].setError(o.getError(r[t].value()));return a}(t,e,i,r,o)}function Bt(t,e,i,s){return{coef0:t.clone(),coef1:e.clone(),coef2:i.clone(),coef3:s.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){let e=Math.abs(t),i=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),s=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(s.isZero()){let e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){let t=this.coef0.clone().mulThis(6);return(6*i/Math.abs(t.value()))**(1/3)}return Math.sqrt(2*i/Math.abs(e.value()))}return i/Math.abs(s.value())}}}class kt{coefs;derivCoefs1=[];derivCoefs2=[];lastDeriv1=-1;lastDeriv2=-1;lastUsed=-1;curCoefs=null;power;truePower;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 i=0,s=this.truePower-t;i<=s;++i){e.push(this.coefs[i+t].clone());let s=i+t,r=s--;for(let e=1;e<t;e++)r*=s--;e[i].mulThis(r)}this.curCoefs=e}constructor(t,e,i,s){this.coefs=t,this.power=e,this.truePower=0;for(let t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let i=this.coefs;0===t?i=this.coefs:(this.updateCoefs(t),i=this.curCoefs);let s=new n.K(0),r=1;for(let n=0,o=this.truePower-t;n<=o;++n)s.pe(r*i[n].value()),r*=e;return s.getResult()}getError(t){let e=Math.abs(t),i=new n.K(0),s=new n.Z(1),r=new n.Z(0);for(let t=0,n=this.power;t<=n;++t)r.addThisE(this.coefs[t].mulE(s)),i.pe(s.value()*this.coefs[t].eps()),s.mulThis(e);i.pe(r.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);let s=new n.Z(1),r=new n.Z(0);for(let i=0,n=this.truePower-e;i<=n;++i)r.addThisE(this.curCoefs[i].mulE(s)),s.mulThis(t);if(!r.isZero())return(o*i.getResult()/Math.abs(r.value()))**(1/e)}return 0}}function Gt(t,e,i,s,r,o){let a=t,l=e,h=l-a;if(!o){let i=s.calcF(t).value(),r=s.calcF(e).value();if((i>0||i>r)&&(l=(0,n.s)(a,a=l),r=(0,n.s)(i,i=r)),i>=0||r<=0)return!1}let m,u=!1,d=i,g=0;for(;g<100;g++){let t=s.calcF(d);if(m=s.calcDF(d),m.isZero())return!1;if(!t.value()||g>3&&t.isZero()){u=!0;break}o||(t.value()<0?a=d:l=d);let e=t.value()/m.value(),i=d-e;o||(i>=a&&i<=l||i>=l&&i<=a)&&Math.abs(e)<=.5*h?(d=i,h=Math.abs(e)):(h=Math.abs(.5*(l-a)),d=.5*(a+l))}return!!u&&(r.set(d,s.estimateError(d)),!0)}function Zt(t,e,i,s,r,n,o,a){return Gt(t,e,i.value(),Bt(s,r,n,o),a,!1)}class Ht{coefs=(0,n.d)(n.Z,3);constructor(t,e,i){this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(i)}calcF(t){let e=new n.Z(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){let e=new n.Z(t);return n.Z.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){let e=Math.abs(t),i=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),s=new n.Z(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(s.isZero()){let t=this.coefs[0].value();return Math.sqrt(i/Math.abs(t))}return i/Math.abs(s.value())}}function Wt(t,e,i,s,r){return Gt(0,0,t.value(),new Ht(e,i,s),r,!0)}var jt=r.V;class Ut extends Q{static type=s.G.enumRationalBezier2;m_cp;m_weights;m_cachedValues;constructor(t){return void 0===t||(0,n.af)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(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)&&(0,s.b)("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(0,s.a)("unexpected constructor param"))}getBoundary(){return At(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,i,s){this.dropAllAttributes(),this.setCpsAndWeights(t,e,i,1,s,1),As(this)}constructWeights(t,e,i,s,r,n){this.dropAllAttributes(),this.setCpsAndWeights(t,e,i,s,r,n),As(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),As(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return s.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o.Envelope2D){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;let e=Bs(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i)}else{let e=[],i=(0,n.d)(n.P,3);this.queryControlPoints(i),Is(i,this.m_weights,e);let s=new n.P;for(let i of e)this.queryCoord2D(i,s),t.mergeNe(s)}}}applyTransformation(t){if(t instanceof a.T){let e=(0,n.d)(n.P,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 Ut({vd:this.m_description})}calculateLength2D(){return Ms(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return this.m_weights[1]>0?n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp):n.P.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){!function(t,e,i){let s=(0,n.d)(n.P,3);t.queryControlPoints(s);let r=[0,0,0];t.queryWeights(r),function(t,e,i,s){if(0===i.value())return void s.setE(t[0]);if(1===i.value())return void s.setE(t[2]);let r=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],o=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],a=[e[0].clone(),e[1].clone(),e[2].clone()],l=new n.Z,h=new n.Z,m=new n.Z;if(i.value()<=.5){let t=(0,n.az)(r[0],r[1],i),e=(0,n.az)(r[1],r[2],i);l.setE((0,n.az)(t,e,i));let s=(0,n.az)(o[0],o[1],i),u=(0,n.az)(o[1],o[2],i);h.setE((0,n.az)(s,u,i));let d=(0,n.az)(a[0],a[1],i),g=(0,n.az)(a[1],a[2],i);m.setE((0,n.az)(d,g,i))}else{let t=(0,n.aA)(r[0],r[1],i),e=(0,n.aA)(r[1],r[2],i);l.setE((0,n.aA)(t,e,i));let s=(0,n.aA)(o[0],o[1],i),u=(0,n.aA)(o[1],o[2],i);h.setE((0,n.aA)(s,u,i));let d=(0,n.aA)(a[0],a[1],i),g=(0,n.aA)(a[1],a[2],i);m.setE((0,n.aA)(d,g,i))}l.divThisE(m),h.divThisE(m);let u=new n.P(l.value(),h.value());fr([t[0].value(),t[1].value(),t[2].value()],u),s.x.set(u.x,l.eps()),s.y.set(u.y,h.eps())}([g.constructPoint2D(s[0]),g.constructPoint2D(s[1]),g.constructPoint2D(s[2])],[new n.Z(r[0]),new n.Z(r[1]),new n.Z(r[2])],e,i)}(this,t,e)}queryCoord2DExtension(t,e,i){if(i){if(t<0)return void J(new Yn({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void J(new Yn({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}let s=(0,n.d)(n.P,3);this.queryControlPoints(s),mr(s,this.m_weights,t,e)}getCoordX(t){let e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){let e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=jt.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=jt.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){!function(t,e,i){let r=(0,n.d)(n.P,3);t.queryControlPoints(r);let o=(0,n.c)(3,NaN);t.queryWeights(o),function(t,e,i,r){i.value()<0&&i.set(0,i.eps()),i.value()>1&&i.set(1,i.eps());let o=(0,n.d)(g,4);(function(t,e,i,r,o){let a=[g.constructPoint2D(t[0]),g.constructPoint2D(t[1]),g.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,i,r,o){(0,s.g)(!0);let a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=g.constructCoords(0,0)}let l=Ys(a,e,0,r),h=function(t,e,i){if(i.toDouble()<=.5){let e=(0,n.az)(t[0],t[1],i),s=(0,n.az)(t[1],t[2],i);return(0,n.az)(e,s,i)}{let e=(0,n.aA)(t[0],t[1],i),s=(0,n.aA)(t[1],t[2],i);return(0,n.aA)(e,s,i)}}(e,0,r),m=l.divE(h);o[0].setE(m);let u=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],d=Ys([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,r).mul(2),c=h.sqr(),_=d.divE(c);o[1].setE(_)}(a,[new n.Z(e[0]),new n.Z(e[1]),new n.Z(e[2])],0,r,o)})(t,e,0,i,o),r.setE(o[1])}(r,o,e,i)}(this,t,e)}cutBezierIgnoreAttributes(t,e,i){(t<0||e>1||t>e)&&(0,s.b)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");let r=(0,n.d)(n.P,3);this.queryControlPoints(r);let o=[0,0,0];Ks(r,this.m_weights,t,e,r,o),i.setControlPointsAndWeights(r,o)}splitBezierIgnoreAttributes(t,e,i){}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=jt.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(o,a,l,r,jt.getDefaultValue(e))}getClosestCoordinate(t,e){return Gs(this,t,n.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,i=-1){return Gs(this,t,0,!1,i)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.b)("");let i=Ts(this),r=0;if(2===i.specialPointsCount())return 0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)Us(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){i&&(i.length=9),s&&(s.length=9);let r=[,,,],o=(0,n.d)(n.Z,2),a=new n.E(0,1),l=0,h=(0,n.d)(n.P,3);if(this.queryControlPoints(h),t){if(r[0]=new n.Z(h[0].y).sub(e).mul(this.m_weights[0]),r[1]=new n.Z(h[1].y).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.Z(h[2].y).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.Z(h[0].x).sub(e).mul(this.m_weights[0]),r[1]=new n.Z(h[1].x).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.Z(h[2].x).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordY(o[t].value());if(s)for(let t=0;t<l;t++)s[t]=o[t].value();else i&&(0,n.ab)(i,0,l,n.X);return l}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[NaN,NaN],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isDegenerate(t){return P(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o.Envelope2D)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);let i=n.E.constructEmpty();return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.d)(n.P,3);this.queryControlPoints(i),Ks(i,this.m_weights,t.vmin,t.vmax,i,[0,0,0]),e.setFromPoints(i,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp.isEqual(this.m_XStart,this.m_YStart),s=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp.setCoordsPoint2D(t):s&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Ms(this,t,!0)}lengthToT(t){return function(t,e){let i=Ms(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;let r=[0];return 1!==It(new Ls(t,e),n.E.unit(),1,r)&&(0,s.d)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=function(t){let e=(0,n.d)(n.P,3),i=[0,0,0];return t.queryControlPoints(e),t.queryWeights(i),function(t,e){let i=dr(e);if(1===i){let e=(0,n.d)(n.P,3);Oe(t,e);let i=e[2].clone(),s=e[1].clone(),r=new n.P,o=i.y*s.x-i.x*s.y;return r.x=-(4*i.x+5*s.x)*o/60,r.y=-(4*i.y+5*s.y)*o/60,r}if(0===i)return new n.P(0,0);(0,s.g)(i>0);let r=t[1].sub(t[0]),o=t[2].sub(t[0]);if(i<1){let t=Math.sqrt(1-i),e=Math.sqrt(1+i),s=(r.y*o.x-r.x*o.y)*i/(t*e)**5/12,n=Math.atan2(t,e),a=i*t*e,l=i*i,h=r.mul(2*(2+l)),m=o.mul(2*l-5),u=h.add(m).mul(a),d=o.sub(r.mul(2*l)).mul(6*n);return u.add(d).mul(s)}{let t=Math.sqrt(i-1),e=Math.sqrt(i+1),s=(r.y*o.x-r.x*o.y)*i/(t*e)**5/12,n=Math.atanh(t/e),a=i*t*e,l=i*i,h=r.mul(4).sub(o.mul(5)),m=r.add(o).mul(2*l),u=h.add(m).mul(a),d=o.sub(r.mul(2*l)).mul(6*n);return u.add(d).mul(s)}}(e,i)}(this),i=zs(this);return e.x+=(this.getStartX()-t.x)*i,e.y+=(this.getStartY()-t.y)*i,e}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){if(0===t.m_weights[1])return!0;let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=2**-52*8*i}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.b)("calculate_sub_weighted_centroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=Ts(t),a=Vs(t),l=a/t.calculateUpperLength2D(),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),n=Ss(t,h,s,l,a);if(r.addThis(n),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(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){let i=(0,n.d)(n.P,3);return this.queryControlPoints(i),function(t,e,i,s){let r=i.lte(n.ar)?n.M.lerpLo:n.M.lerpHi,[o,a,l]=[e.map((e,i)=>t[i].x.mul(e)),e.map((e,i)=>t[i].y.mul(e)),e].map(([t,e,s])=>r(r(t,e,i),r(e,s,i),i)),h=new n.P(o.divThis(l).value(),a.divThis(l).value());fr(t.map(t=>t.asPoint2D()),h),s.x=n.M.constructDouble(h.x),s.y=n.M.constructDouble(h.y)}(i.map(t=>_.constructPoint2D(t)),this.m_weights.map(t=>n.M.constructDouble(t)),n.M.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){let e=(0,n.d)(n.P,3);return this.queryControlPoints(e),Fs(e,this.m_weights,t)}getDerivative(t){let e=(0,n.a)(t,0,1),i=(0,n.d)(n.P,4);return qs(this,1,e,i),i[1]}getCurvature(t){let e=(0,n.d)(n.P,4);qs(this,2,t,e);let i=e[1].sqrLength();return 0===i?NaN:(e[1].divThis(Math.sqrt(i)),e[1].crossProduct(e[2])/i)}isIntersecting(t,e,i){return!1}isIntersectingPoint(t,e,i){return!1}isIntersectingPoint3D(t,e,i,s,r=1){return!1}isMonotoneQuickAndDirty(){let t=(0,n.d)(n.P,3);return this.queryControlPoints(t),js(t)}getMonotonicPartParams(t,e){let i=Ts(this),r=i.specialPointsCount();if(!e)return i.specialPointsCount();t<r&&(0,s.b)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.s)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.s)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,n.s)(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]=(0,n.s)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){let e=(0,n.d)(n.P,3);this.queryControlPoints(e);let i=e[2].sub(e[0]),s=i.length();if(n.P.distance(e[0],e[1])+n.P.distance(e[2],e[1])-s>t)return!1;let r=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(i))/s>r)}copyIgnoreAttributes(t){let e=(0,n.d)(n.P,3);this.queryControlPoints(e);let i=[0,0,0];this.queryWeights(i),t.setControlPointsAndWeights(e,i)}calculateArea2DHelper(){return zs(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,s.g)(0),0}queryEnvelopeW(t,e){Hs(this,t,e)}setSegmentFromCoordsForStitcher(t,e){let i=[0,0,0];this.queryWeights(i),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],i[0],i[1],i[2])}writeInBufferStream(t,e){let i=new Float64Array(5);return i[0]=this.m_cp.x,i[1]=this.m_cp.y,i[2]=this.m_weights[0],i[3]=this.m_weights[1],i[4]=this.m_weights[2],t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(5);t.queryRange(e,i.length,i,!0,1),this.m_cp.x=i[0],this.m_cp.y=i[1],this.m_weights[0]=i[2],this.m_weights[1]=i[3],this.m_weights[2]=i[4],this.m_cachedValues=null}snapControlPoints(t){let e=(0,n.d)(n.P,3);this.queryControlPoints(e);let i=n.P.sqrDistance(e[1],e[0]),s=n.P.sqrDistance(e[1],e[2]),r=e[0].clone(),o=i;i>s&&(r=e[2].clone(),o=s);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(r)),a}needsSnapControlPoints(t){if(!t)return!1;let e=(0,n.d)(n.P,3);this.queryControlPoints(e);let i=n.P.sqrDistance(e[1],e[0]),s=n.P.sqrDistance(e[1],e[2]);e[0].clone();let r=i;return i>s&&(e[2].clone(),r=s),r<=t&&0!==r}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Us(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.d)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.d)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformInPlace(t.m_cp):(0,n.J)(e,i,.5,t.m_cp),t.changeEndPoints2D(e,i),r&&Us(t)}(this,t,e,i)}copyToImpl(t){let 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],ks(e,Bs(this))}reverseImpl(){this.m_weights[2]=(0,n.s)(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){let e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let t=0;t<3;t++)if(this.m_weights[t]!==e.m_weights[t])return!1;return!0}equalsImplTol(t,e){let i=t;if(!this.m_cp.isEqualPoint2D(i.m_cp,e))return!1;let s=(0,n.d)(n.P,3);this.queryControlPoints(s);let o=(0,n.d)(n.P,3);i.queryControlPoints(o);let a=[i.m_weights[0],i.m_weights[1],i.m_weights[2]];for(let t=0;t<3;t++){let i=new r.k;i.setCoordsPoint2DZ(s[t].mul(this.m_weights[t]),this.m_weights[t]);let n=new r.k;if(n.setCoordsPoint2DZ(o[t].mul(a[t]),a[t]),!i.isEqual(n,e))return!1}return!0}swapImpl(t){let e=t;e.m_cp=(0,n.s)(this.m_cp,this.m_cp=e.m_cp),e.m_weights=(0,n.s)(this.m_weights,this.m_weights=e.m_weights),function(t,e){e.m_cachedValues=(0,n.s)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){As(this)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,r){let o=new h;if(Hs(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;let a=Ts(t),l=0,m=[],u=a.specialPoints[0];for(let i=1,r=a.specialPoints.length;i<r;++i){let r=a.specialPoints[i],n=ws(t,e,u,r);if(0===m.length)m.push(n);else if(n.t===n.tmin)(0,s.g)(m.at(-1).d<=n.d),m.at(-1).tmax=n.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,s.g)(m.at(-1).d>=n.d);let t=m.at(-1).tmin;m[m.length-1]=n,m.at(-1).tmin=t}else m.push(n);u=r}for(let t of m)if(t.d<=r){let e=t.t;i&&(i[l]=e),l++}return l}(this,t,e,i)}endPointModified(){As(this)}clearEndPointModified(){}setCpsAndWeights(t,e,i,r,n,o){(r<=0||o<=0||n<0)&&(0,s.b)("weights"),(t.isNAN()||e.isNAN()||i.isNAN())&&(0,s.b)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=r,this.m_weights[1]=n,this.m_weights[2]=o,this.setEndXY(i)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}var Ot=r.V;class Qt extends Q{static type=s.G.enumBezier2;constructor(t){void 0===t||(0,n.af)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(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()):(0,s.d)("unexpected constructor args")}getBoundary(){return At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,i){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(i),be(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),be(this)}getGeometryType(){return s.G.enumBezier2}queryEnvelope(t){if(2===t.m_EnvelopeType){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;let e=Re(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i)}else{let e=[];De(this,e);let i=new n.P;for(let s of e)this.queryCoord2D(s,i),t.mergeNe(i)}return}(0,s.a)("env type not impl")}applyTransformation(t){if(1===t.m_TransformationType){let e=(0,n.d)(n.P,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()}(0,s.g)(0)}createInstance(){return new Qt({vd:this.m_description})}calculateLength2D(){return we(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,i){let s=(0,n.d)(n.P,3);this.queryControlPoints(s),Ke(s,t,e,i)}queryCoord2DE(t,e){!function(t,e,i){let s=(0,n.d)(n.P,3);t.queryControlPoints(s),function(t,e,i){if(e.value()<=.5){let s=g.constructPoint2D(t[1]),r=new g;(0,n.ao)(2,g.constructPoint2D(t[0]),s,e,r);let o=new g;(0,n.ao)(2,s,g.constructPoint2D(t[2]),e,o);let a=new g;(0,n.ao)(2,r,o,e,a),i.setE(a)}else{let s=g.constructPoint2D(t[1]),r=new g;(0,n.ap)(2,g.constructPoint2D(t[0]),s,e,r);let o=new g;(0,n.ap)(2,s,g.constructPoint2D(t[2]),e,o);let a=new g;(0,n.ap)(2,r,o,e,a),i.setE(a)}}(s,e,i)}(this,t,e)}queryCoord2DMP(t,e){(0,s.g)(!1,"bernstein polynomials not ported")}getCoordX(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){let e=(0,n.ag)(this.getStartX(),this.m_cp.x,t),i=(0,n.ag)(this.m_cp.x,this.getEndX(),t);return(0,n.ag)(e,i,t)}{let e=(0,n.ah)(this.getStartX(),this.m_cp.x,t),i=(0,n.ah)(this.m_cp.x,this.getEndX(),t);return(0,n.ah)(e,i,t)}}getCoordY(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){let e=(0,n.ag)(this.getStartX(),this.m_cp.x,t),i=(0,n.ag)(this.m_cp.x,this.getEndX(),t);return(0,n.ag)(e,i,t)}{let e=(0,n.ah)(this.getStartY(),this.m_cp.y,t),i=(0,n.ah)(this.m_cp.y,this.getEndY(),t);return(0,n.ah)(e,i,t)}}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=Ot.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=Ot.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){!function(t,e,i){let s=(0,n.d)(n.P,4);t.queryControlPoints(s),function(t,e,i){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),i.setE(function(t,e,i){{let e=g.constructPoint2D(t[1]).subE(g.constructPoint2D(t[0])),s=new n.Z(1).subE(i),r=g.constructPoint2D(t[2]).subE(g.constructPoint2D(t[1])),o=e.mulE(s).addE(r.mulE(i));return o.mulThisE(new n.Z(2)),o}}(t,0,e))}(s,e,i)}(this,t,e)}cutBezierIgnoreAttributes(t,e,i){if((t<0||e>1||t>e)&&(0,s.b)("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return i.setStartXY(this.getStartXY()),i.m_cp.assign(this.m_cp),void i.setEndXY(this.getEndXY());let r=(0,n.d)(n.P,3);this.queryControlPoints(r),Ge(r,t,e,r),i.constructPoints(r)}splitBezierIgnoreAttributes(t,e,i){(0,s.g)(0)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=Ot.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(o,a,l,r,Ot.getDefaultValue(e))}getClosestCoordinate(t,e){return Xe(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,i=-1){return Xe(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.b)("");let i=Ee(this),r=0;if(2===i.specialPointsCount())return 0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)Ve(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){let r=(0,n.d)(n.Z,3),o=(0,n.d)(n.Z,2),a=new n.E(0,1),l=0;if(t){if(r[0]=new n.Z(this.getStartY()).sub(e),r[1]=new n.Z(this.m_cp.y).subE(new n.Z(this.getStartY())).mulThisByPower2(2),r[2]=new n.Z(this.getStartY()).add(this.getEndY()).subE(new n.Z(this.m_cp.y).mulThisByPower2(2)),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.Z(this.getStartX()).sub(e),r[1]=new n.Z(this.m_cp.x).subE(new n.Z(this.getStartX())).mulThisByPower2(2),r[2]=new n.Z(this.getStartX()).add(this.getEndX()).subE(new n.Z(this.m_cp.x).mulThisByPower2(2)),l=Lt(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordY(o[t].value());if(s)for(let t=0;t<l;t++)s[t]=o[t].value();else i&&(0,n.ai)(i,l);return l}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return P(this,t)}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,s.g)(0)}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=new o.Envelope2D;this.queryEnvelope(t);let i=new n.E;return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.d)(n.P,4);this.queryControlPoints(i),Ge(i,t.vmin,t.vmax,i),e.setFromPoints(i,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp.isEqual(this.m_XStart,this.m_YStart),s=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp.setCoordsPoint2D(t):s&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return we(this,t,!0)}lengthToT(t){return function(t,e){let i=we(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;let r=[0];return 1!==It(new ve(t,e),n.E.unit(),1,r)&&(0,s.d)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=(0,n.d)(n.P,3);!function(t,e,i=!1){let s=(0,n.d)(n.P,3);t.queryControlPoints(s),Oe(s,e,i)}(this,e);let i=e[2],s=e[1],r=new n.P,o=i.y*s.x-i.x*s.y;r.x=-(4*i.x+5*s.x)*o/60,r.y=-(4*i.y+5*s.y)*o/60;let a=qe(this);return r.x+=(e[0].x-t.x)*a,r.y+=(e[0].y-t.y)*a,r}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=2**-52*8*i}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.b)("calculate_sub_weighted_centroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=Ee(t),a=R(t),l=Math.min(a/t.calculateUpperLength2D(),1e-7),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),n=Ce(t,h,s,l,a);if(r.addThis(n),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(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 e=0;e<3;e++)t[e].isNAN()&&(0,s.b)("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){let e=(0,n.a)(t,0,1),i=Ie(this,1,e);return i.isZero()&&(i=Ie(this,2,e),1===e&&i.negateThis()),i}getDerivative(t){return Ie(this,1,(0,n.a)(t,0,1))}getCurvature(t){let e=Ie(this,1,t),i=Ie(this,2,t),s=e.sqrLength();return 0===s?NaN:(e.divThis(Math.sqrt(s)),e.crossProduct(i)/s)}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}isIntersectingPoint(t,e,i){if(i&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;let s=new o.Envelope2D;if(this.queryLooseEnvelope(s),s.inflateCoords(e,e),!s.contains(t))return!1;let r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){let i=Ee(this),r=i.specialPointsCount();if(!e)return i.specialPointsCount();t<r&&(0,s.b)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){(0,n.s)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,n.s)(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]=(0,n.s)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){let e=(0,n.d)(n.P,3);this.queryControlPoints(e);let i=e[2].sub(e[0]),s=i.length();if(n.P.distance(e[0],e[1])+n.P.distance(e[2],e[1])-s>t)return!1;let r=t,o=e[1].clone();return o.subThis(e[0]),!(Math.abs(o.crossProduct(i))/s>r)}copyIgnoreAttributes(t){let e=(0,n.d)(n.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return qe(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1);var t}queryEnvelopeW(t,e){let i=(0,n.d)(n.P,3);this.queryControlPoints(i),Le(i,t,e)}setSegmentFromCoordsForStitcher(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return function(t,e){let i=(0,n.d)(n.P,3);t.queryControlPoints(i);let s=n.P.sqrDistance(i[1],i[0]),r=n.P.sqrDistance(i[1],i[2]),o=i[0].clone(),a=s;s>r&&(o=i[2].clone(),a=r);let l=!1;return a<=e&&0!==a&&(l=!0,t.setControlPoint1(o)),l}(this,t)}writeInBufferStream(t,e){let i=new Float64Array(2);return i[0]=this.m_cp.x,i[1]=this.m_cp.y,t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(2);t.queryRange(e,i.length,i,!0,1),this.m_cp.x=i[0],this.m_cp.y=i[1],this.m_cachedValues=null}needsSnapControlPoints(t){return function(t,e){if(!e)return!1;let i=(0,n.d)(n.P,3);t.queryControlPoints(i);let s=n.P.sqrDistance(i[1],i[0]),r=n.P.sqrDistance(i[1],i[2]);i[0].clone();let o=s;return s>r&&(i[2].clone(),o=r),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ve(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.d)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.d)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformInPlace(t.m_cp):(0,n.J)(e,i,.5,t.m_cp),t.changeEndPoints2D(e,i),r&&Ve(t)}(this,t,e,i)}copyToImpl(t){let e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Ye(e,Re(this))}reverseImpl(){}equalsImplTol(t,e){let i=t;return!!this.m_cp.isEqualPoint2D(i.m_cp,e)}equalsImpl(t){let e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){let e=t;e.m_cp=(0,n.s)(this.m_cp,this.m_cp=e.m_cp),function(t,e){e.m_cachedValues=(0,n.s)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){be(this)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,s,r){let o=new h;if(function(t,e,i){let s=(0,n.d)(n.P,3);t.queryControlPoints(s),Le(s,e,i)}(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;let a=new n.P,l=Xe(t,e,n.E.unit(),!1);return t.queryCoord2D(l,a),n.P.distance(a,e)<=r?(s&&(s[0]=l),1):0}(this,t,e.length,e,i)}endPointModified(){be(this)}clearEndPointModified(){}m_cp;m_cachedValues}class Kt{m_elements;m_zeroCtor;constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),(0,s.g)(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){let i=e;i.subThis(t);let s=this.power();for(let e=0;e<=s;e++){let r=new this.m_zeroCtor;for(let i=e;i<=s;i++){let s=this.m_elements[i];s.mulDoubleThis((0,n.aJ)(i,e));let o=t.pow(i-e);s.mulThis(o),r.addThis(s)}let o=i.pow(e);r.mulThis(o),this.m_elements[e]=r}}fmSubThis(t,e){return(0,s.g)(0),this}addThis(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].addThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return(0,s.g)(0),this}sub(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s].clone(),this.m_elements[s].negateThis();return this.updatePower(),this}sub0(t){return(0,s.g)(0),this}subNumber0(t){return(0,s.g)(0),this}subShifted(t,e){let i=this.power(),s=t.power()+e,r=Math.min(this.power(),s),n=0;for(let i=e;i<=r;++i)this.m_elements[i].subThis(t.m_elements[n]),n++;if(s<=i)return this.updatePower(),this;this.m_elements.length=s+1;for(let t=i+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=r+1;e<=s;++e)this.m_elements[e].subThis(t.m_elements[n++]);return this.updatePower(),this}subShiftedWithCoef(t,e,i){let s=this.power(),r=t.power()+i,n=Math.min(this.power(),r),o=0;for(let s=i;s<=n;++s)this.m_elements[s].fmSubThis(t.m_elements[o],e),o++;if(r<=s)return this.updatePower(),this;this.m_elements.length=r+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let i=n+1;i<=r;++i)this.m_elements[i].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){let e=t,i=[];for(let t=0,s=this.power();t<=s;t++)for(let s=0,r=e.power();s<=r;s++){let r=this.m_elements[t].clone();r.mulThis(e.m_elements[s]),t+s<i.length?i[t+s].addThis(r):i.push(r)}this.m_elements=i}else for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulDoubleThis(t){for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulDoubleThis(t);return this.updatePower(),this}mulNumber0(t){return(0,s.g)(0),this}mulBigint0(t){return(0,s.g)(0),this}mulBigIntThis(t){return(0,s.g)(0),this}mulInt320(t){return(0,s.g)(0),this}div0(t){return(0,s.g)(0),this}absThis(){return(0,s.g)(0),this}div(t,e,i){if(this.power()<t.power())return i.assignCopy(this),void e.setZero();i.setZero(),e.setZero();let s=t.getElement(t.power()),r=this.clone(),o=r.power(),a=r.power()-t.power(),l=a;for(e.m_elements=(0,n.d)(e.m_zeroCtor,a+1);;){if(o<t.power()){i.assignMove(r);break}if(o===r.power()){let i=r.getElement(r.power());i.divThis(s),r.subShiftedWithCoef(t,i,r.power()-t.power()),e.m_elements[l]=i.clone()}l--,o--}i.updatePower(),e.updatePower()}divThis(t){return(0,s.g)(0),this}subThis(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s].clone(),this.m_elements[s].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){(0,s.g)(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){let e=this.power(),i=this.m_elements[e].clone();for(let s=e-1;s>=0;--s)i.mulThis(t),i.addThis(this.m_elements[s]);return i}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();let e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let i=t,s=this.power();i<=s;i++){let s=BigInt(i);for(let e=i-1,r=i-t;e>r;--e)s*=BigInt(e);e.m_elements[i-t].mulBigIntThis(s)}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(n.M.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)=>{let i=e.hiBitIndex();return t<i?i:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}evaluateDerivative(t){let e=this.power(),i=this.m_elements[e];i.mulDoubleThis(e);for(let s=e-1;s>=1;--s){i.mulThis(t);let e=this.m_elements[s];e.mulDoubleThis(s),i.addThis(e)}return i}static evaluateCoefs(t,e,i){let s=t.power();i.construct0(t.getElement(0).evaluate(e));for(let r=1;r<=s;++r)i.addElement(t.getElement(r).evaluate(e));i.updatePower()}}class Jt extends Kt{constructor(t){super(void 0===t?{zeroCtor:n.M}:{...t,zeroCtor:n.M})}clone(){return new Jt({copy:this})}absEvaluate(t){let e=this.power(),i=this.m_elements[e].clone();i.absThis();let s=t.clone();s.absThis();for(let t=e-1;t>=0;--t)i.mulThis(s),i.addThis(this.m_elements[t].abs());return i}}class $t extends Kt{constructor(t){super(void 0===t?{zeroCtor:Jt}:{...t,zeroCtor:Jt})}clone(){return new $t({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let i=0;i<=e;++i)this.m_elements.push(new Jt({coef0:t[i]}));return this.updatePower(),this}}function te(t,e,i,r,o,a,l,h,m,u,d,g,c,_,p,f,y,P,x,v=!1){let C={polypoly1:new $t,polypoly2:new $t,polyX2:new Jt,polyY2:new Jt,polyX2Deriv:new Jt,polyY2Deriv:new Jt,polypolyX1:new $t,polypolyY1:new $t,polypolyX1Deriv:new $t,polypolyY1Deriv:new $t,lazyPolypolyD1:new $t,lazyPolypolyD1Deriv:new $t,lazyPolyD2:new Jt,lazyPolyD2Deriv:null,polypoly11:new $t,polypoly12:new $t,tempPp:new $t,tempPp1:new $t,tempPp2:new $t,tempP:new Jt,tempP1:new Jt,tempP2:new Jt};C.polyX2.construct(l,h),C.polyY2.construct(m,u),C.polypolyX1.constructFromMPValues(t,e),C.polypolyY1.constructFromMPValues(i,r),C.polypoly11.assignCopy(C.polypolyX1),C.polypoly12.assignCopy(C.polypolyY1),d&&(C.lazyPolyD2.construct(d,g),C.polypoly11.mulElementThis(C.lazyPolyD2),C.polypoly12.mulElementThis(C.lazyPolyD2)),o?(C.lazyPolypolyD1.constructFromMPValues(o,a),C.lazyPolypolyD1Deriv=new $t({copy:C.lazyPolypolyD1}),C.lazyPolypolyD1Deriv.derivative1This(),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyX2),C.polypoly11.subThis(C.tempPp),C.tempPp.assignCopy(C.lazyPolypolyD1),C.tempPp.mulElementThis(C.polyY2),C.polypoly12.subThis(C.tempPp)):(C.polypoly11.sub0This(C.polyX2),C.polypoly12.sub0This(C.polyY2)),C.polypolyX1Deriv.assignCopy(C.polypolyX1),C.polypolyX1Deriv.derivative1This(),C.polypolyY1Deriv.assignCopy(C.polypolyY1),C.polypolyY1Deriv.derivative1This(),o&&(C.polypolyX1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyX1),C.polypolyX1Deriv.subThis(C.tempPp2),C.polypolyY1Deriv.mulThis(C.lazyPolypolyD1),C.tempPp2.assignCopy(C.lazyPolypolyD1Deriv),C.tempPp2.mulThis(C.polypolyY1),C.polypolyY1Deriv.subThis(C.tempPp2)),C.polyX2Deriv.assignCopy(C.polyX2),C.polyX2Deriv.derivative1This(),C.polyY2Deriv.assignCopy(C.polyY2),C.polyY2Deriv.derivative1This(),d&&((0,s.g)(null===C.lazyPolyD2Deriv),C.lazyPolyD2Deriv=new Jt({copy:C.lazyPolyD2}),C.lazyPolyD2Deriv.derivative1This(),C.polyX2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyX2),C.polyX2Deriv.subThis(C.tempP1),C.polyY2Deriv.mulThis(C.lazyPolyD2),C.tempP1.assignCopy(C.lazyPolyD2Deriv),C.tempP1.mulThis(C.polyY2),C.polyY2Deriv.subThis(C.tempP1)),C.polypoly1.assignCopy(C.polypoly11),C.polypoly1.mulElementThis(C.polyX2Deriv),C.tempPp.assignCopy(C.polypoly12),C.tempPp.mulElementThis(C.polyY2Deriv),C.polypoly1.addThis(C.tempPp),C.polypoly2.assignCopy(C.polypolyX1Deriv),C.polypoly2.mulElementThis(C.polyY2Deriv),C.tempPp.assignCopy(C.polypolyY1Deriv),C.tempPp.mulElementThis(C.polyX2Deriv),C.polypoly2.subThis(C.tempPp);let b=[],E=[];y||=[],f||=[],le(C.polypoly11,C.polypoly12,C.tempP);let D=n.ae.ldexp(-59).toDouble(),w=[],S=he(C.tempP,0,p,D,64,w,P,P);if(S<0)return-1;for(let t=0;t<S;t++){let e=C.tempP1,i=C.tempP2;Jt.evaluateCoefs(C.polypoly11,w[t],e);let r=(0,n.aE)(e.m_elements,e.power()+1);r.sort((t,e)=>t.compare(e)),Jt.evaluateCoefs(C.polypoly12,w[t],i);let o=(0,n.aE)(i.m_elements,i.power()+1);o.sort((t,e)=>t.compare(e));let a=r[0],l=r.at(-1),h=o[0],m=o.at(-1);l.subThis(a),m.subThis(h);let u,d=l.subThis(m).GEZ(),g=[];if(u=he(d?e:i,0,_,n.ae.ldexp(-59).toDouble(),58,g,P,P),u<0&&(0,s.d)("mp_curve_proximity"),u>0){let r=d?i:e;for(let e=0;e<u;e++){let i;if(d){let s=C.tempP;Jt.evaluateCoefs(C.polypoly12,w[t].addDouble(2**-52),s),i=s.evaluate(g[e])}else{let s=C.tempP;Jt.evaluateCoefs(C.polypoly11,w[t].addDouble(2**-52),s),i=s.evaluate(g[e])}let o=r.evaluateDerivative(g[e]).abs().mulDoubleThis(2**-52),a=r.evaluate(g[e]);o.addThis(i.sub(a).absThis()),o.ldexpThis(3),a.absThis(),a.lt(o)?E.push((0,n.o)(g[e].toDouble(),w[t].toDouble())):(0,s.g)(a.gte(o))}}}S=E.length,le(C.polypoly1,C.polypoly2,C.tempP);let A=[],T=he(C.tempP,0,p,D,64,A);T<0&&(T=0);for(let t=0;t<T;t++){Jt.evaluateCoefs(C.polypoly1,A[t],C.tempP1);let e=[],i=he(C.tempP1,0,_,D,64,e);if(0!==i)if(Jt.evaluateCoefs(C.polypoly2,A[t],C.tempP2),i<0){if(i=he(C.tempP2,0,_,D,64,e),i<0)continue;for(let s=0;s<i;s++)b.push((0,n.o)(e[s].toDouble(),A[t].toDouble()))}else{let s=C.tempP2.absEvaluate(n.ae);s.mulThis(n.M.constructDouble(1e-12));for(let r=0;r<i;r++){let i=C.tempP2.evaluate(e[r]);i.absThis(),i.lt(s)&&b.push((0,n.o)(e[r].toDouble(),A[t].toDouble()))}}}if(T=b.length,0===S&&0===T)return 0;b=b.concat(E),b.sort((t,e)=>v?(0,n.X)(t.second,e.second):(0,n.X)(t.first,e.first));let I=(0,n.v)(b,(t,e)=>t.first===e.first&&t.second===e.second);b=b.slice(0,I),f.length=0,y.length=0;for(let t of b)f.push(t.first),y.push(t.second);return(0,s.g)(f.length===y.length),y.length}function ee(t,e,i,s,r,o,a,l,h,m,u,d,g){let c={polyIntersect:new Jt,polyX1:new Jt,polyY1:new Jt,polyX1Deriv:new Jt,polyY1Deriv:new Jt,lazyPolyD1:new Jt,lazyPolyD1Deriv:new Jt,tempP:new Jt,tempP1:new Jt,tempP2:new Jt,polypoly1Proximity:new $t,polypoly2Proximity:new $t};c.polyX1.construct(t,e),c.polyY1.construct(i,s),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.polyIntersect.assignCopy(c.polyX1),c.polyIntersect.mulThis(c.polyX1),c.polyIntersect.mulElementThis(a[0]),c.tempP.assignCopy(c.polyY1),c.tempP.mulThis(c.polyY1),c.tempP.mulElementThis(a[1]),c.polyIntersect.addThis(c.tempP),r?(c.lazyPolyD1.construct(r,o),c.tempP.assignCopy(c.lazyPolyD1),c.tempP.mulThis(c.lazyPolyD1),c.tempP.mulElementThis(a[2]),c.polyIntersect.addThis(c.tempP)):c.polyIntersect.add0(a[2]);{let r=a[0].clone(),o=r.clone();o.sqrThis();let l=a[1].clone(),h=l.clone();h.sqrThis();let m=a[2].clone(),u=r.clone();u.subThis(l),c.polyX1.construct(t,e),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1.construct(i,s),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(h),c.tempP.mulElementThis(m),c.polypoly1Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(l.mul(u).mul(m).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(r.mul(h)),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1),c.tempP1.mulElementThis(o.mul(l)),c.tempP.addThis(c.tempP1),c.tempP.add0(u.mul(u).mul(m)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulElementThis(u.mul(r).mul(l).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.construct0(r.mul(u).mul(u)),c.polypoly1Proximity.addElement(c.tempP),c.polypoly1Proximity.updatePower(),c.tempP.construct0(n.aD),c.polypoly2Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1Deriv),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1Deriv),c.tempP.addThis(c.tempP1),c.tempP.mulElementThis(r.mul(l)),c.polypoly2Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1Deriv),c.tempP.mulElementThis(u.mul(r)),c.polypoly2Proximity.addElement(c.tempP),c.polypoly2Proximity.updatePower()}let _=[],p=[];null===u&&(u=[]);let f=2*c.polyIntersect.power()+58,y=2**-52*.5,P=[],x=he(c.polyIntersect,0,h,y,f,P,d,d);if(x<0)return-1;for(let t of P)p.push(t.toDouble());le(c.polypoly1Proximity,c.polypoly2Proximity,c.tempP),f=2*c.tempP.power()+58,P.length=0;let v=he(c.tempP,0,h,y,f,P);if(v<0&&(v=0),0===x&&0===v)return 0;for(let t of P)_.push(t.toDouble());let C=_.concat(p);u.length=C.length,(0,n.f)(u,C,0,0,C.length),(0,n.w)(u);let b=(0,n.v)(u,(t,e)=>0===(0,n.X)(t,e));return u.length=b,u.length}function ie(t,e,i,s){return t.isZero()?e.isZero()?-1:0:(s.setThis(e),s.negateThis(),s.divThis(t),i.isEmpty()?1:+!!i.containsCoordinate(s.value()))}function se(t,e,i,s,r,o,a){if(t.isZero())return o?(a[0].setInt32(1),+!!r.containsCoordinate(1)):ie(e,i,r,a[0]);if(o){let e=2;return a[0].setInt32(1),i.equals(t)?(a[1].setInt32(1),e=1):a[1].setThis(i.div(t)),r.containsCoordinate(a[1].value())||(e=1),r.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,n.s)(a[0],a[0]=a[1])),e}let l=e.clone();l.sqrThis();let h=t.clone();if(h.mulThis(i).ldexpThis(2).negateThis().addThis(l),h.LZ())return 0;let m=s+2,u=n.M.sqrt(h,m),d=u.clone();e.LZ()&&d.negateThis(),d.addThis(e).limitPrecisionThis(m).ldexpThis(-1).negateThis();let g=0;return a[0].setThis(d).divThis(n.M.constructAssign(t,m)).limitPrecisionThis(s),(r.isEmpty()||r.containsCoordinate(a[0].value()))&&g++,u.isZero()||d.isZero()||(a[g].setThis(i).divThis(d).limitPrecisionThis(s),(r.isEmpty()||r.containsCoordinate(a[g].value()))&&g++,2===g&&a[0].gt(a[1])&&(a[1]=(0,n.s)(a[0],a[0]=a[1]))),g}function re(t,e,i,r,o,a,l,h){if(t.isZero())return se(e,i,r,o,a,l,h);let m=(t,e)=>{if(t>0){let i=e+t;for(let t=1;t<i;t++)h[t].equals(h[0])&&(h[i-1]=(0,n.s)(h[t],h[t]=h[i-1]),i--);e=i}return(0,n.ab)(h,0,e,(t,e)=>t.compare(e)),e};if(r.isZero()){let s=0;return a.containsCoordinate(0)&&(h[0].setInt32(0),s=1),m(se(t,e,i,o,a,l,h.slice(1)),s)}if(l){let i=0;a.containsCoordinate(1)&&(h[0].setInt32(1),i=1);let s=e.add(t),n=r.negate();return m(se(t,s,n,o,a,t.add(s).add(n).isZero(),h.slice(i)),i)}let u=new n.M,d=new n.M,g=new n.M,c=e.clone();if(c.isZero())d.setThis(i),d.divThis(t),g.setThis(r),g.divThis(t);else{c.divThis(t).divDoubleThis(3).negateThis();let s=e.clone();s.sqrThis();let n=t.clone();n.sqrThis(),d.setThis(t),d.mulThis(i).mulDoubleThis(3).subThis(s).divThis(n).divDoubleThis(3),g.setThis(s),g.mulThis(e),g.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(i).mulDoubleThis(9),g.subThis(u),u.setThis(n),u.mulThis(r).mulDoubleThis(27),g.addThis(u),g.divThis(n).divThis(t).divDoubleThis(27)}if(d.isZero()){let t=g.clone();return t.negateThis(),t.isZero()?(h[0].setThis(c),pe(a,o,h,1)):(h[0].setThis(n.M.cubicRoot(t,o).add(c)),pe(a,o,h,1))}let _=g.clone();if(_.sqrThis().ldexpThis(-2),u.setThis(d.clone()),u.sqrThis().mulThis(d).divDoubleThis(27),_.addThis(u),_.isZero())return h[0].setThis(g),h[0].mulDoubleThis(3).divThis(d),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(c),h[1].addThis(c),pe(a,o,h,2);if(_.GZ())return _.setThis(n.M.sqrt(_,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.addThis(_),h[0].setThis(n.M.cubicRoot(u,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.subThis(_),h[0].addThis(n.M.cubicRoot(u,o+8)),h[0].addThis(c),pe(a,o,h,1);u.setThis(d),u.divDoubleThis(3).negateThis(),(0,s.g)(u.GEZ());let p=n.M.sqrt(u,o+8),f=p.clone();f.negateThis(),f.addThis(c),p.addThis(c);let y=n.M.constructDouble(a.isEmpty()?-Number.MAX_VALUE:a.vmin),P=n.M.constructDouble(a.isEmpty()?Number.MAX_VALUE:a.vmax),x=new Jt({zeroCtor:n.M});x.construct0(r),x.addElement(i),x.addElement(e),x.addElement(t);let v=new Jt({copy:x});v.derivative1This();let C=0,b=(0,n.d)(n.M,4);b[C++].setThis(y),f.gt(y)&&f.lt(P)&&b[C++].setThis(f),p.gt(y)&&p.lt(P)&&b[C++].setThis(p),b[C++].setThis(P);let E=3*o,D=52,w=2**-52;for(;D<E;)2*D<=E?(w*=w,D*=2):(w*=2**-52,D+=52);D+=2;let S=0,A=!1;for(let t=1;t<C;t++)if(de(x,v,b[t-1],b[t],w,D,h[0])){S=1,A=t+1<C;break}if(!S)return 0;if(A){let t=new Jt({zeroCtor:n.M,coef0:h[0]});t.negateThis(),t.addElement(n.ae);let e=new Jt({zeroCtor:n.M}),i=new Jt({zeroCtor:n.M});x.div(t,e,i),(0,s.g)(2===e.power()),(0,s.g)(0===i.power());let r=se(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,h.slice(1));(0,s.g)(r>=0&&r<=2),S+=r}return pe(a,o,h,S)}function ne(t,e,i,s,r,o,a,l,h){if(t.isZero())return re(e,i,s,r,o,a,l,h);let m=(t,e)=>{if(t>0){let i=e+t;for(let t=1;t<i;t++)h[t].equals(h[0])&&(h[i-1]=(0,n.s)(h[t],h[t]=h[i-1]),i--);e=i}return(0,n.ab)(h,0,e,(t,e)=>t.compare(e)),e};if(r.isZero()){let r=0;return a.containsCoordinate(0)&&(h[0].setInt32(0),r=1),m(re(t,e,i,s,o,a,l,h.slice(r)),r)}let u=new Jt({zeroCtor:n.M,coef0:r});if(u.addElement(s),u.addElement(i),u.addElement(e),u.addElement(t),l){let t=0;a.containsCoordinate(1)&&(h[0].setInt32(1),t=1);let e=new Jt({zeroCtor:n.M,coef0:n.M.constructInt32(-1)});e.addElement(n.M.constructInt32(1));let i=new Jt({zeroCtor:n.M}),s=new Jt({zeroCtor:n.M});return u.div(e,i,s),m(re(3===i.power()?i.getElement(3):n.aD.clone(),i.power()>=2?i.getElement(2):n.aD.clone(),i.power()>=1?i.getElement(1):n.aD.clone(),i.getElement(0),o,a,i.evaluate(n.ae).isZero(),h.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(a.containsCoordinate(0)&&(t=1,h[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);let e=re(3===u.power()?u.getElement(3):n.aD.clone(),u.power()>=2?u.getElement(2):n.aD.clone(),u.power()>=1?u.getElement(1):n.aD.clone(),u.getElement(0),o,a,!1,h.slice(t));return e>0&&(t+=e),(0,n.ab)(h,0,t,(t,e)=>t.compare(e)),t}let d=52,g=2**-52;for(;d<o;)2*d<=o?(g*=g,d*=2):(g*=2**-52,d+=52);d+=2;let c=_e(u),_=n.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return g=(c.lt(_)?c:_).mul(n.M.constructDouble(g)).toDouble(),ce(u,a,g,d,l,0,h,4)}function oe(t,e){let i=t,s=e;s.power()>i.power()&&(s=(0,n.s)(i,i=s));let r=i.power()-s.power(),o=new Jt({copy:i.getElement(i.power())});i.mulThis(s.getElement(s.power()));for(let t=0,e=i.power();t<e;t++)if(t>=r){let e=new Jt({copy:s.getElement(t-r)});e.mulThis(o);let n=i.getElement(t).sub(e);i.setElement(t,n)}i.setElement(i.power(),i.getElement(i.power()).setZero()),i.updatePower(),ae(i)}function ae(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function le(t,e,i){let s=t.clone(),r=e.clone();for(ae(s),ae(r);0!==s.power()||0!==r.power();)oe(s,r);i.assignMove(s.getElement(0))}function he(t,e,i,s,r,o,a=!1,l=!1){o.length=0;let h=t.power(),m=(0,n.d)(n.M,2*h+4),u=function(t,e,i,s,r,o,a){if(0===t.power())return t.isZero()?-1:0;let l=t.evaluate(n.M.constructInt32(1)).isZero();if(1===t.power()){let i=ie(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(s),1===i?(o[0].limitPrecisionThis(s),1):0}return 2===t.power()?se(t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):3===t.power()?re(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):4===t.power()?ne(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):ce(t,e,i,s,l,0,o,a)}(t,i||n.E.unit(),s,r,0,m,m.length);if(u>0){o.length=0;for(let t=0;t<u;t++){let e=m[t];t>0&&e.lte(o.at(-1))||o.push(e.clone())}return o.length}return u}function me(t,e,i){if((0,s.g)(i>=1),0===t.power())return t.isZero()?-1:0;let r=t.getElement(0);return r.negateThis(),r.divThis(t.getElement(1)),e[0].setThis(r),1}function ue(t,e,i,r){if(t.power()<2)return me(t,i,r);(0,s.g)(r>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));let a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){let s=t.getElement(1);return s.negateThis(),s.divThis(t.getElement(2)),s.ldexpThis(-1),s.limitPrecisionThis(e),i[0].setThis(s),1}(0,s.g)(r>=2),o=n.M.sqrt(o,e+8);let l=t.getElement(1);l.negateThis();let h=l.clone();h.subThis(o),h.divThis(t.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(e);let m=l.clone();return m.addThis(o),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e),h.lt(m)?(i[0].setThis(h),i[1].setThis(m)):(i[1].setThis(h),i[0].setThis(m)),2}function de(t,e,i,r,o,a,l){let h=i.clone(),m=r.clone();h.limitPrecisionThis(a),m.limitPrecisionThis(a);let u=t.evaluate(h);u.limitPrecisionThis(a+2);let d=t.evaluate(m);if(d.limitPrecisionThis(a+2),u.GEZ()&&d.GEZ()||u.LEZ()&&d.LEZ())return u.absLessAbs(d)?(l=h,u.isZero()):(l=m,d.isZero());let g=d.LZ();g&&(d=(0,n.s)(u,u=d),m=(0,n.s)(h,h=m));let c=g?m:h,_=g?h:m,p=h.add(m).ldexpThis(-1);p.limitPrecisionThis(a);let f=m.sub(h);f.limitPrecisionThis(a),f.absThis();let y=f.clone(),P=t.evaluate(p),x=e.evaluate(p),v=new Jt({copy:t}),C=new Jt({copy:e});{let i=Math.max(t.hiBitIndex(),e.hiBitIndex()),s=n.ae.clone();s.ldexpThis(-(a+2));for(let r=64;r<i;){v.limitPrecisionThis(r),C.limitPrecisionThis(r);let n=v.evaluate(p),o=C.evaluate(p),a=n.sub(P),l=o.sub(x);if(a.divThis(P).absThis().lt(s)&&(x.isZero()||l.divThis(x).absThis().lt(s)))break;v.assignCopy(t),C.assignCopy(e),r=Math.min(r+64,i)}P.limitPrecisionThis(a+2),x.limitPrecisionThis(a+2)}let b=4,E=1,D=0,w=0,S=1,A=n.M.constructDouble(.25*o),T=n.M.constructDouble(.5001),I=0;for(;++I<300;){if(I>32&&D>0||x.isZero()||2===S&&D>1||1===S&&b<4)S=1,E>1&&E--;else if(S=2,w>1){let t=f.mul(x);t.absThis(),t.ldexpThis(-3),t.absLessAbs(P)&&E++}f.setThis(y);let t=new n.M,e=!1;if(1===S)do{if(w>2){let e=f.clone();if(e.absThis(),e.ldexpThis(4),_.sub(c).ldexpThis(-1).gt(e)){if(p.equals(c)){t.setThis(p),p.setThis(c.add(e)),p.limitPrecisionThis(a),y.setThis(p.sub(t));break}if(p.equals(_)){t.setThis(p),p.setThis(_.sub(e)),p.limitPrecisionThis(a),y.setThis(p.sub(t));break}}}y.setThis(m.sub(h)),y.ldexpThis(-1),y.limitPrecisionThis(a),t.setThis(p),p.setThis(h.add(y)),p.limitPrecisionThis(a),p.lt(c)?p.setThis(c):p.gt(_)&&p.setThis(_),e=h.equals(p)||m.equals(p)}while(0);else for(;;){if(y.setThis(P.div(x)),y.limitPrecisionThis(a),1!==E&&y.mulDoubleThis(E),t.setThis(p),p.subThis(y),p.limitPrecisionThis(a),e=p.equals(t),p.lt(c)){if(E>1){p.setThis(t),E--;continue}y.setThis(t.sub(c)),p.setThis(c)}else if(p.gt(_)){if(E>1){p.setThis(t),E--;continue}y.setThis(t.sub(_)),p.setThis(_)}break}if(e||y.absLessAbs(A)){t.equals(p)||(P=v.evaluate(p),P.limitPrecisionThis(a+2));break}P=v.evaluate(p),P.limitPrecisionThis(a+2),x=C.evaluate(p),x.limitPrecisionThis(a+2);let i=h.clone(),s=m.clone();P.LZ()?(u.setThis(P),h.setThis(p)):(d.setThis(P),m.setThis(p)),2===S&&(h.equals(i)&&m.equals(s)||w>1&&!y.absLessAbs(T.mul(f)))?D++:D=0,1===S?(b++,w=0):(b=0,w++)}return I>=300&&(0,s.d)("Root_finder iterations exceeded"),l.setThis(p),!0}function ge(t,e,i,s,r){let o=t.evaluate(i);if(o.isZero())return!0;let a=n.M.constructDouble(.5*s),l=i.clone();l.subThis(a);let h=t.evaluate(l),m=i.clone();m.addThis(a);let u=t.evaluate(m);if(h.LZ()&&u.GZ()||h.GZ()&&u.LZ()||(o.GZ()?h.LEZ()||u.LEZ():h.GEZ()||u.GEZ()))return!0;let d=h.LEZ()&&u.LEZ(),g=h.GEZ()&&u.GEZ(),c=!1;return d?o.gt(h)&&o.gt(u)&&(c=!0):g&&o.lt(h)&&o.lt(u)&&(c=!0),!!c&&o.absThis().lt(n.M.constructDouble(1e-17))}function ce(t,e,i,r,o,a,l,h){(0,s.g)(i>0),(0,s.g)(h>=t.power());let m=l,u=[],d=[],g=new Jt({zeroCtor:t.m_zeroCtor}),c=new Jt({zeroCtor:t.m_zeroCtor}),_=new Jt({zeroCtor:t.m_zeroCtor}),p=n.M.constructDouble(i),f=n.M.constructDouble(e.vmin),y=n.M.constructDouble(e.vmax),P=f.sub(p),x=y.add(p),v=_e(t),C=v.clone();if(C.negateThis(),P.lt(C))P.setThis(C.sub(p));else if(P.gt(v))return 0;if(x.gt(v))x.setThis(v.add(p));else if(x.lt(C))return 0;let b=t,E=null;if(o){let e=new Jt({coef0:n.M.constructInt32(-1)});e.addElement(n.ae),E=new Jt,b=E;let i=new Jt,s=new Jt;for(t.div(e,i,s),E.assignCopy(i);b.evaluate(n.ae).isZero();)b.div(e,i,s),E.assignCopy(i)}let D=!1;if(b.power()>0&&b.getElement(0).isZero())for(D=!0,E||(E=new Jt({copy:b}),b=E);b.getElement(0).isZero();)E.shiftRight(1);let w=r+2*b.power()+2,S=i/2**(b.power()+2),A=w;if(n.aD.gt(P)&&n.aD.lt(x))for(let t=0,e=b.power();t<e;t++)if(b.getElement(t).isZero()){u.push(n.aD.clone());break}for(let t=b.power()-1;t>0;t--)if(S*=2,w-=2,A-=2,b.power()-t!==1){if(b.power()-t===2){c.assignMove(b.derivative(t));let e=ue(c,w,m,h);(0,s.g)(e>=0&&e<=2);for(let t=0;t<e;t++)m[t].gt(P)&&m[t].lt(x)&&!m[t].isZero()&&u.push(m[t].clone());if(u.length>1&&u.sort((t,e)=>t.compare(e)),u.length>0){let t=u[0].sub(p);t.limitPrecisionThis(A),d.push((0,n.o)(P.clone(),t));let e=1===u.length?x.clone():u[1].sub(p);t=u[0].add(p),t.limitPrecisionThis(A),e.limitPrecisionThis(A),d.push((0,n.o)(t,e)),u.length>1&&(e=2===u.length?x.clone():u[2].sub(p),e.limitPrecisionThis(A),t=u[1].add(p),t.limitPrecisionThis(A),d.push((0,n.o)(t,e)),u.length>2&&(t=u[2].add(p),t.limitPrecisionThis(A),d.push((0,n.o)(t,x.clone()))))}else d.push((0,n.o)(P.clone(),x.clone()));g.assignCopy(c),_.assignMove(b.derivative(t-1));continue}{c.assignMove(_),_.assignMove(b.derivative(t-1));let e=[];for(let t=0,i=d.length;t<i;++t)if(d[t].first.lte(d[t].second)){let i=new n.M;if(de(c,g,d[t].first,d[t].second,S,w,i)){u.push(i);let s=i.sub(p);s.limitPrecisionThis(A),e.push((0,n.o)(d[t].first,s)),s=i.add(p),s.limitPrecisionThis(A),e.push((0,n.o)(s,d[t].second))}else e.push(d[t])}d=e,e=[],g.assignMove(c)}}else c.assignMove(b.derivative(t)),1===me(c,m,h)&&(m[0].gt(P)&&m[0].lt(x)&&!m[0].isZero()&&u.push(m[0].clone()),g.assignMove(c),_.assignMove(b.derivative(t-1)));u.sort((t,e)=>t.compare(e)),0===d.length&&(g.assignMove(b.derivative(b.power())),g.isZero()||d.push((0,n.o)(P.clone(),x.clone())));let T=0,I=0,M=0,q=new n.M;for(;;){if(I<d.length){if(d[I].first.gt(d[I].second)){I++;continue}let t=!1;if(M<u.length&&u[M].lt(d[I].first)&&(t=!0),!t){de(b,g,d[I].first,d[I].second,i,r,q)&&(q.lt(f)?m[T++].setThis(f):q.gt(y)?m[T++].setThis(y):m[T++].setThis(q)),I++;continue}}if(!(M<u.length))break;(0===M||!u[M-1].equals(u[M]))&&ge(b,0,u[M],i)&&(q.setThis(u[M]),q.lt(f)?q.setThis(f):q.gt(y)&&q.setThis(y),(0===T||!m[T].equals(q))&&m[T++].setThis(q)),M++}return D&&n.aD.gt(P)&&n.aD.lt(x)&&(m[T++].setThis(n.aD),(0,n.ab)(m,0,T,(t,e)=>t.compare(e))),o&&n.ae.gt(P)&&n.ae.lt(x)&&(m[T++].setThis(n.ae),(0,n.ab)(m,0,T,(t,e)=>t.compare(e))),T}function _e(t){let e=t.getElement(t.power());e.limitPrecisionThis(53),e.absThis();let i=n.aD.clone();for(let e=0,s=t.power();e<s;e++){let s=t.getElement(e);s.limitPrecisionThis(53),s.gt(i)&&i.setThis(s)}return i.divThis(e),i.addThis(n.ae),i.mulThis(n.M.constructDouble(1+2**-52*100)),i}function pe(t,e,i,s){let r=s;if(!t.isEmpty()){r=0;for(let e=0;e<s;++e)t.containsCoordinate(i[e].value())&&(r!==e&&i[r].setThis(i[e]),r++)}r>1&&(i[0].gt(i[1])&&(i[1]=(0,n.s)(i[0],i[0]=i[1])),r>2&&(i[0].gt(i[2])&&(i[2]=(0,n.s)(i[0],i[0]=i[2])),i[1].gt(i[2])&&(i[2]=(0,n.s)(i[1],i[1]=i[2]))));for(let t=0;t<r;++t)i[t].limitPrecisionThis(e);return r}function fe(t,e,i,r,o,a){return function(t,e,i,r,o,a){if(i<e&&(0,s.b)("xTo < xFrom"),i===e)return 0;let l=[0],h=Number.MAX_VALUE,m=[Number.MAX_VALUE],u=0,d=(0,n.c)(33,NaN),g=(0,n.c)(33,NaN),c=[0];d[0]=1;let _=0,p=0;for(let n=0;n<32;n++){if(u=ye(e,i,r,0===n,u,c),g[n]=u,n+1>=t){Pe(n+1-t,t,d,g,0,l,m)||(0,s.d)("polynomial_interpolation");let e=o*Math.abs(l[0])+a,i=Math.abs(h-l[0]);if(i<=e&&Math.abs(m[0])<=e){if(_++,_>1&&(i<=.1*p||0===p||_>2))return l[0]}else _=0;p=i,h=l[0]}g[n+1]=g[n],d[n+1]=.25*d[n]}return l[0]}(t,e,i,a,r,o)}function ye(t,e,i,s,r,o){let a=r;if(s)return o[0]=1,a=.5*(e-t)*(i(t)+i(e)),a;let l=o[0],h=(e-t)/l,m=t,u=new n.K(0);for(let t=1;t<=o[0];++t){let e=(t-.5)*h;u.add(i(m+e))}return a=.5*(a+(e-t)*u.getResult()/l),o[0]*=2,a}function Pe(t,e,i,s,r,o,a){let l=0,h=Math.abs(r-i[t]),m=(0,n.c)(e,NaN),u=(0,n.c)(e,NaN);for(let n=0;n<e;++n){let e=Math.abs(r-i[t+n]);e<h&&(l=n,h=e),m[n]=s[t+n],u[n]=s[t+n]}let d=0,g=0,c=0;o[0]=s[t+l],l--;for(let s=1;s<e;s++){for(let n=0;n<e-s;n++){if(g=i[t+n]-r,c=i[t+n+s]-r,d=g-c,0===d)return!1;let e=(m[n+1]-u[n])/d;m[n]=g*e,u[n]=c*e}2*(l+1)<e-s?a[0]=m[l+1]:(a[0]=u[l],l--),o[0]+=a[0]}return!0}class xe{specialPoints;specialPointsLength;area;centroid_x;centroid_y;constructor(){this.area=NaN,this.centroid_x=NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let ve=class{b;len;constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-we(this.b,e,!1):0}getError(t){return(0,s.g)(0),0}};function Ce(t,e,i,s,r){let o=!0,a=(0,n.d)(n.P,3);t.queryControlPoints(a);let l=+!o,h=a[1][l]-a[0][l],m=a[2][l]-a[0][l],u=fe(5,e,i,s,r,t=>{let e;if(t<=.5){let i=(0,n.ag)(0,h,t),s=(0,n.ag)(h,m,t);e=(0,n.ag)(i,s,t)}else{let i=(0,n.ah)(0,h,t),s=(0,n.ah)(h,m,t);e=(0,n.ah)(i,s,t)}return e*Me(a,1,t).length()});o=!1,l=+!o,h=a[1][l]-a[0][l],m=a[2][l]-a[0][l];let d=fe(5,e,i,s,r,t=>{let e;if(t<=.5){let i=(0,n.ag)(0,h,t),s=(0,n.ag)(h,m,t);e=(0,n.ag)(i,s,t)}else{let i=(0,n.ah)(0,h,t),s=(0,n.ah)(h,m,t);e=(0,n.ah)(i,s,t)}return e*Me(a,1,t).length()});return new n.P(u,d)}function be(t){t.m_cachedValues=null}function Ee(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new xe;return De(t,e.specialPoints),Ye(t,e),e}function De(t,e){let i=(0,n.d)(n.P,3);t.queryControlPoints(i);let s=(0,n.d)(n.Z,8);s[0].set(0);let r=1;{let t=(0,n.d)(n.Z,3);!function(t,e,i=!1){let s=new n.Z(t[1][0]).subE(new n.Z(t[0][0]));e[1]=s.mul(2),e[2]=new n.Z(t[2][0]).subE(new n.Z(t[1][0])).subE(s),i?e[0].set(0):e[0].set(t[0][0])}(i,t,!1);let e=(0,n.d)(n.Z,2),o=new n.E(0,1),a=Ft(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.a9)(e[t].value(),0,1)||(s[r]=e[t],r++)}{let t=(0,n.d)(n.Z,3);!function(t,e,i=!1){let s=new n.Z(t[1][1]).subE(new n.Z(t[0][1]));e[1]=s.mul(2),e[2]=new n.Z(t[2][1]).subE(new n.Z(t[1][1])).subE(s),i?e[0].set(0):e[0].set(t[0][1])}(i,t,!1);let e=(0,n.d)(n.Z,2),o=new n.E(0,1),a=Ft(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.a9)(e[t].value(),0,1)||(s[r]=e[t],r++)}if(s[r].set(1),r++,r>2){(0,n.ab)(s,0,r,(t,e)=>t.value()-e.value());let t=0,e=s[0].value(),i=1;for(let n=1;n<r;n++)s[n].eq(s[n-1])?(e+=s[n].value(),i++):(i>1&&(e/=i,s[t].set(e)),t++,s[t]=s[n],e=s[n].value(),i=1);t++,r=t}s[0].set(0),s[r-1].set(1),e.length=r;for(let t=0;t<r;t++)e[t]=s[t].value()}function we(t,e,i){let s=(0,n.d)(n.P,3);return t.queryControlPoints(s),Se(s,e,i)}function Se(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+Se(t,1,!1)}if(1===e)return Ae(t);let s=(0,n.d)(n.P,3);return ke(t,e,s,null),Ae(s)}function Ae(t){if(t[0].equals(t[1]))return n.P.distance(t[2],t[0]);if(t[1].equals(t[2]))return n.P.distance(t[0],t[2]);let e=n.P.distance(t[0],t[1])+n.P.distance(t[2],t[1]),i=n.P.distance(t[0],t[2]);if(e-i<=e*2**-52)return i;let s=(0,n.d)(n.P,3);Oe(t,s,!0);let r=4*((0,n.e)(s[2].x)+(0,n.e)(s[2].y)),o=2*(s[2].x*s[1].x+s[2].y*s[1].y),a=(0,n.e)(s[1].x)+(0,n.e)(s[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r))return 1e-14*Math.abs(a)>=Math.abs(o)?1*Math.sqrt(a):2/(3*o)*((1*o+a)**1.5-a**1.5);let l=o/r,h=a/r,m=h-l*l,u=1+l;if(0===m)return l>=0&&u>=0||l<=0&&u<=0?Math.abs(.5*Math.sqrt(r)*(u*u-l*l)):.5*Math.sqrt(r)*(u*u+l*l);let d=Math.sqrt(m+u*u),g=Math.sqrt(h);return.5*Math.sqrt(r)*(u*d-l*g+m*Math.log(Math.abs((u+d)/(l+g))))}function Te(t,e){let i=(0,n.a)(e,0,1),s=Me(t,1,i);return s.isZero()&&(s=Me(t,2,i)),s}function Ie(t,e,i){let s=(0,n.d)(n.P,3);return t.queryControlPoints(s),Me(s,e,i)}function Me(t,e,i){if(1===e){let e=t[1].sub(t[0]).mul(1-i).add(t[2].sub(t[1]).mul(i));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):n.P.construct(0,0)}function qe(t){let e=(0,n.d)(n.P,3);return t.queryControlPoints(e),Ne(e)}function Ne(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Re(t){return t.m_cachedValues}function Ye(t,e){t.m_cachedValues=e}function Xe(t,e,i,r,o){(0,s.D)(n.E.unit().contains(i),"QuadraticBezierHelper::getClosestCoordinateSegment");let a=(0,n.d)(n.P,3);t.queryControlPoints(a);let l=Number.MAX_VALUE,h=[0],m=Fe(a,e,h);if(i.containsCoordinate(h[0]))l=n.P.distance(e,m);else{h[0]=i.vmin,Ke(a,h[0],m),l=n.P.distance(m,e);let t=new n.P;Ke(a,i.vmax,t);let s=n.P.distance(t,e);l>s&&(m.setCoordsPoint2D(t),h[0]=i.vmax,l=s)}if(!r)return h[0];if(i.vmin<=0){let s=new n.P;t.queryCoord2DExtended(-1,s,!0);let r=new n.P;t.queryCoord2D(i.vmin,r);let o=new Yn({start:s,end:r}),a=o.getClosestCoordinate(e,!0);if(a<1){let t=o.getCoord2D(a),i=n.P.distance(t,e);i<l&&(l=i,h[0]=a-1,m.assign(t))}}if(i.vmin>=1){let s=new n.P;t.queryCoord2DExtended(2,s,!0);let r=new n.P;t.queryCoord2D(i.vmax,r);let o=new Yn({start:r,end:s}),a=o.getClosestCoordinate(e,!0);if(a>0){let t=o.getCoord2D(a),i=n.P.distance(t,e);i<l&&(l=i,h[0]=1+a,m.assign(t))}}return h[0]}function Fe(t,e,i){let s=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(r),l=o.dotProduct(s)+2*r.dotProduct(r),h=3*r.dotProduct(s),m=s.dotProduct(s),u=(0,n.c)(3,NaN),d=qt(m,h,l,a,n.E.unit(),!1,u),g=t[0].clone(),c=0,_=n.P.sqrDistance(t[0],e),p=n.P.sqrDistance(t[2],e);p<_&&(c=1,g.assign(t[2]),_=p);for(let i=0;i<d;i++){let s=new n.P;Ke(t,u[i],s),p=n.P.sqrDistance(s,e),p<_&&(_=p,g.assign(s),c=u[i])}return i&&(i[0]=c),g}function Le(t,e,i){if(e.equalsRange(0,1))return void i.setFromPoints(t,3);let s=(0,n.d)(n.P,3);Ge(t,e.vmin,e.vmax,s),i.setFromPoints(s,3)}function ze(t,e,i){i.setEmpty();let s=[];s.push(new n.E(0,1));let r=.5*Math.max(e.width(),e.height());for(;s.length;){let o=s.at(-1);s.pop();let a=new h;if(Le(t,o,a),a.isIntersectingW(e)){let t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=r||o.width()<1e-12)i.merge(o);else{let t=o.getCenter();s.push(n.E.construct(o.vmin,t)),s.push(n.E.construct(t,o.vmax))}}}}function Ve(t){let e=(0,n.d)(n.P,3);t.queryControlPoints(e);let i=Be(e);return i&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),i}function Be(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.a5)(t[0][i],t[2][i]);s>0?((0,n.a5)(t[0][i],t[1][i])<0&&(t[1][i]=t[0][i],e=!0),(0,n.a5)(t[1][i],t[2][i])<0&&(t[1][i]=t[2][i],e=!0)):s<0?((0,n.a5)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.a5)(t[1][i],t[2][i])>0&&(t[1][i]=t[2][i],e=!0)):t[1][i]!==t[0][i]&&(t[1][i]=t[0][i],e=!0)}return e}function ke(t,e,i,s){(new n.P).setCoordsPoint2D(t[0]),(new n.P).setCoordsPoint2D(t[1]),(new n.P).setCoordsPoint2D(t[2]);let r=new n.P,o=new n.P,a=new n.P;if((0,n.J)(t[0],t[1],e,r),(0,n.J)(t[1],t[2],e,o),(0,n.J)(r,o,e,a),i&&(i[0].assign(t[0]),i[1].assign(r),i[2].assign(a)),s){let e=t[2];s[0].assign(a),s[1].assign(o),s[2].assign(e)}}function Ge(t,e,i,s){if(e===i){let i=new n.P;return Ke(t,e,i),s[0]=i,s[1]=i,void(s[2]=i)}let r=(0,n.d)(n.P,3);ke(t,i,r,null),ke(r,e/i,null,r),Ke(t,e,r[0]),Ke(t,i,r[2]),s[0].setCoordsPoint2D(r[0]),s[1].setCoordsPoint2D(r[1]),s[2].setCoordsPoint2D(r[2])}function Ze(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===We(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function He(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===je(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function We(t,e,i,r,o,a,l,h,m,u){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),i.isDegenerate(0)){let t=[0,0],s=e.intersectPoint(i.getStartXY(),t,l);if(s>0){if(null!==o)for(let e=0;e<s;e++)o.push(t[e]);if(null!==a)for(let t=0;t<s;t++)a.push(0);if(null!==r)for(let i=0;i<s;i++){let s=new n.P;e.queryCoord2D(t[i],s),r.push(s)}}return s}let d=Y(e,i);if(l=Math.max(l,d),e.isDegenerateToLineHelper(d)){let t=new Yn({start:e.getStartXY(),end:e.getEndXY()}),s=ot(t,i,r,o,a,l,h,u);if(o)for(let i=0;i<s;++i){let s=t.getCoord2D(o[i]);o[i]=e.getClosestCoordinate(s,!1)}return s}if(X(e,i,l))return 0;let g=_.constructPoint2D(i.getStartXY()),c=_.constructPoint2D(i.getEndXY()).sub(g),p=c.clone();p.leftPerpendicularThis();let f=_.constructPoint2D(e.m_cp).sub(_.constructPoint2D(e.getStartXY())),y=_.constructPoint2D(e.getEndXY()).sub(_.constructPoint2D(e.m_cp)),P=f.dotProduct(p).toDouble(),x=y.sub(f).dotProduct(p).toDouble(),v=(0,n.c)(12,NaN),C=(0,n.c)(12,NaN),b=function(t,e,i,s){let r=new n.Z,o=Ft(new n.Z(t),new n.Z(e),i,r);return s[0]=r.value(),o}(x,P,n.E.unit(),v);b<0&&(v[0]=0,v[1]=1,b=2);let E=0;for(let t=0,s=E;t<b;++t){let r=e.getCoord2D(v[t+s]);C[E]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(C[E]))<=l&&(v[E]=v[t+s],E++)}let D,w=(0,n.d)(n.P,3);e.queryControlPoints(w);{let t=(0,n.d)(_,3);if(Qe(w,t,!1),t[0]=t[0].sub(g),c.x.abs().gte(c.y.abs())){let e=c.y.div(c.x);x=t[2].y.sub(t[2].x.mul(e)).toDouble(),P=t[1].y.sub(t[1].x.mul(e)).toDouble(),D=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{let e=c.x.div(c.y);x=t[2].x.sub(t[2].y.mul(e)).toDouble(),P=t[1].x.sub(t[1].y.mul(e)).toDouble(),D=t[0].x.sub(t[0].y.mul(e)).toDouble()}}let S=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),A=[0,0];b=Mt(x,P,D,n.E.unit(),S,A);for(let t=0,s=E;t<b;++t){v[t+s]=A[t];let r=e.getCoord2D(v[t+s]);C[E]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(C[E]))<=l&&(v[E]=v[t+s],E++)}(0,s.g)(E<v.length+4),b=e.intersectPoint(i.getStartXY(),A,l);for(let t=0;t<b;t++)v[E]=A[t],C[E++]=0;b=e.intersectPoint(i.getEndXY(),A,l);for(let t=0;t<b;t++)v[E]=A[t],C[E++]=1;b=i.intersectPoint(e.getStartXY(),A,l);for(let t=0;t<b;t++)C[E]=A[t],v[E++]=0;b=i.intersectPoint(e.getEndXY(),A,l);for(let t=0;t<b;t++)C[E]=A[t],v[E++]=0;return 0===E?0:Mn(t,e,i,v,C,E,r,o,a,l,h,0,u)}function je(t,e,i,s,r,o,l,h,m,u){if(Kr(i))return We(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,0,u);let d=Y(e,i);if(X(e,i,l=Math.max(l,d)))return 0;let g=[],c=[],p=(0,n.d)(n.P,3);{e.queryControlPoints(p);let t=(0,n.d)(n.P,3),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(p,3,t);let o=(0,n.d)(_,3);Qe(t,o);let m=[o[0].x,o[1].x,o[2].x],u=[o[0].y,o[1].y,o[2].y],d=(0,n.d)(n.M,3);d[0].setDouble(i.getSemiMinorAxis()),d[0].sqrThis(),d[1].setDouble(i.getSemiMajorAxis()),d[1].sqrThis(),d[2]=d[0],d[2].mul(d[1]),d[2].negate();let f=ee(m,2,u,2,null,0,d,0,n.E.unit(),n.E.unit(),g,h);if(f>0){let t=0;for(let s=0;s<f;s++){let r=new n.P;e.queryCoord2D(g[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(g[t]=g[s],c.push(o),t++)}g.length=t}}let f=[0,1];for(let t=0;t<2;t++){let e=0===t?i.getStartXY():i.getEndXY(),s=[0];Fe(p,e,s);let r=new n.P;Ke(p,s[0],r),n.P.distance(e,r)<=l&&(g.push(s[0]),c.push(f[t]))}for(let t=0;t<2;t++){let e=[0,2];{let s=i.getClosestCoordinate(p[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(p[e[t]],r)<=l&&(g.push(f[t]),c.push(s))}}return Mn(t,e,i,g,c,g.length,s,r,o,l,h,0,u)}function Ue(t,e,i,s,r,o,a,l,m,u){let d=(0,n.d)(n.P,3);e.queryControlPoints(d);let g=(0,n.d)(n.P,3);if(i.queryControlPoints(g),F(d,g,3)<0)return Ue(t,i,e,s,o,r,a,l,m,!u);let c=Y(e,i);if(X(e,i,a=Math.max(a,c)))return 0;if(function(t,e,i,s,r,o,a,l,h){let m=(0,n.d)(n.P,3);t.queryControlPoints(m);let u=(0,n.d)(n.P,3);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2]))return i&&(i.length=0,i.push(m[0]),i.push(m[2])),s&&(s.length=0,s.push(0),s.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!m[0].equals(u[2]))return!1}return!!(m[0].equals(u[2])&&m[1].equals(u[1])&&m[2].equals(u[0]))&&(s&&(s.length=0,s.push(0),s.push(1),h&&(s[1]=(0,n.s)(s[0],s[0]=s[1]))),r&&(r.length=0,r.push(1),r.push(0),h&&(r[1]=(0,n.s)(r[0],r[0]=r[1]))),i&&(i.length=0,i.push(m[0]),i.push(m[2]),h&&(i[1]=(0,n.s)(i[0],i[0]=i[1]))),!0)}(e,i,s,r,o,0,0,0,u))return 2;let p=new n.E(0,1),f=new n.E(0,1);{let t=new h;Le(d,n.E.unit(),t);let e=new h;Le(g,n.E.unit(),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(ze(d,t,p),ze(g,t,f),p.isEmpty()||f.isEmpty())return 0;Ge(d,p.vmin,p.vmax,d),Ge(g,f.vmin,f.vmax,g)}}let y=Nn(d,2,g,2,a);if(0===y)return 0;let P=[],x=[];if(-1===y){let t=(0,n.d)(_,3);Qe(d,t);let e=[t[0].x,t[1].x,t[2].x],i=[t[0].y,t[1].y,t[2].y],s=(0,n.d)(_,3);Qe(g,s);let r=te(e,2,i,2,null,0,[s[0].x,s[1].x,s[2].x],2,[s[0].y,s[1].y,s[2].y],2,null,0,0,n.E.unit(),n.E.unit(),P,x,u,0,u);if(r>0){let t=0;for(let e=0;e<r;e++){let i=new n.P,s=new n.P;Ke(g,x[e],s),Ke(d,P[e],i),n.P.distance(i,s)<=a&&(P[t]=P[e],x[t]=x[e],t++)}P.length=t,x.length=t}}for(let t=0;t<2;t++){let e=0===t?d:g,i=0===t?g:d;for(let s=0;s<2;s++){let r=0===s?0:2,o=[0];Fe(i,e[r],o);let l=new n.P;Ke(i,o[0],l),n.P.distance(e[r],l)<=a&&(0===t?(P.push(0===r?0:1),x.push(o[0])):(x.push(0===r?0:1),P.push(o[0])))}}if(0===P.length)return 0;if(!p.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=Qt.recalculateParentT(p.vmin,p.vmax,P[t]);if(!f.equalsRange(0,1))for(let t=0;t<x.length;++t)x[t]=Qt.recalculateParentT(f.vmin,f.vmax,x[t]);return Mn(t,e,i,P,x,P.length,s,r,o,a,l,0,u)}function Oe(t,e,i=!1){let s=t[1].sub(t[0]);e[1].assign(s.mul(2)),e[2].assign(t[2].sub(t[1]).sub(s)),i?e[0].setCoords(0,0):e[0].assign(t[0])}function Qe(t,e,i=!1){let s=_.constructPoint2D(t[1]),r=s.sub(_.constructPoint2D(t[0]));e[1]=r.mul(n.M.constructInt32(2)),e[2]=_.constructPoint2D(t[2]).sub(s).sub(r),e[0]=i?new _(n.aD,n.aD):_.constructPoint2D(t[0])}function Ke(t,e,i,s){if(s){if(e<0)return void J(new Yn({start:t[0],end:t[0].add(Te(t,0).getUnitVector())}),e,i);if(e>1)return void J(new Yn({start:t[2],end:t[2].add(Te(t,1).getUnitVector())}),e-1,i)}if(e<=.5){let s=t[1].clone(),r=new n.P;(0,n.as)(2,t[0],s,e,r);let o=new n.P;(0,n.as)(2,s,t[2],e,o);let a=new n.P;(0,n.as)(2,r,o,e,a),i.assign(a)}else{let s=t[1].clone(),r=new n.P;(0,n.at)(2,t[0],s,e,r);let o=new n.P;(0,n.at)(2,s,t[2],e,o);let a=new n.P;(0,n.at)(2,r,o,e,a),i.assign(a)}}const Je=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],$e=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],ti=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],ei=[[.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]],ii=[[.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]],si=[[.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 ri(t,e,i,s){let r=.5*(s-i),o=i+r,a=new n.K(0);for(let i=0,s=Math.trunc(t/2);i<s;++i){let s,l;switch(t){case 4:s=Je[i][0],l=Je[i][1];break;case 8:s=$e[i][0],l=$e[i][1];break;case 16:s=ti[i][0],l=ti[i][1];break;case 32:s=ei[i][0],l=ei[i][1];break;case 64:s=ii[i][0],l=ii[i][1];break;case 128:s=si[i][0],l=si[i][1];break;default:throw Error("Quadrature_integral: invalid n")}let h=(0,n.aH)(-r,s,o),m=(0,n.aH)(r,s,o);a.pe(e(h)*l),a.pe(e(m)*l)}return a.getResult()*r}class ni extends bt{static type=s.G.enumPolygon;constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=Xn):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=Xn,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=Xn):t.envelope?(0,s.a)("envelope constructor not impl"):(0,s.d)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=Xn)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return At(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return ni.type}getDimension(){return 2}createInstance(){return new ni({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}var oi=r.V;class ai{m_shape;constructor(t){this.m_shape=t}userSort(t,e,i){this.m_shape.sortVerticesSimpleByYHelper(i,t,e)}getValue(t){return this.m_shape.getY(t)}}class li{m_parent;m_geometry;m_path;m_vertex;m_firstVertex;m_index;m_bFirst;m_bSkipMultiPoints;m_selection;m_bOneGeom;constructor(t){!function(t){return void 0!==t.parent}(t)?(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):(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)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;-1!==this.m_geometry;){for(;-1!==this.m_path;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,-1!==this.m_vertex)return this.m_vertex;if(this.m_bOneGeom)return-1;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),-1===this.m_geometry)break;(!this.m_bSkipMultiPoints||(0,s.j)(this.m_parent.getGeometryType(this.m_geometry)))&&(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return-1}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){let t=this.m_parent.m_selectedVertices[this.m_index++];if(-1!==t&&(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-1}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):-1===this.m_vertex?-1:(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,-1!==this.m_vertex&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper())}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,i,s,r,n,o,a,l){return new li({parent:t,geometry:e,path:i,vertex:s,firstVertex:r,index:n,bSkipMultiPoints:o,selection:a,bOneGeom:l})}}class hi{parentage;constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class mi{m_pathCount;m_pointCount;m_firstGeometry;m_lastGeometry;m_vertexIndexList;m_verticesMp=null;m_vertices=null;m_xyStream=null;m_vertexDescription=null;m_bHasAttributes;m_segments=null;m_weights=null;m_ranks=null;m_segmentWeights=null;m_segmentRanks=null;m_indices=[];m_deletedIndices=[];m_pathIndexList;m_pathAreas=[];m_pathLengths=[];m_pathindices=[];m_deletedPathIndices=[];m_geometryIndexList;m_geometryIndices=[];m_selectedVertices=[];m_selectedCount;m_selectionIndex;m_selection;m_bucketSort;m_helperPoint=null;m_forceSetEnvelope=r.r.constructEmpty();m_hasForceSetEnvelope=0;m_workPoint2D=n.P.getNAN();m_workPoint2_2D=n.P.getNAN();m_segmentParentageIndex;m_curveStitcher=null;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){let 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){let e=this.m_pathIndexList.newElement(),i=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,i),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),i>=this.m_pathAreas.length){let t=Math.trunc(i<16?16:3*i/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[i]=0,this.m_pathLengths[i]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){let e=this.m_vertexIndexList.newElement(),i=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,i),t<0){if(i>=this.m_vertices.getPointCount()){let t=Math.trunc(i<16?16:3*i/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[i]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);let e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let t=0,i=this.m_indices.length;t<i;t++){if(t===this.m_selectionIndex)continue;let i=this.m_indices[t];null!==i&&i.size()>e&&i.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,1),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,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,i,s){this.m_hasForceSetEnvelope=0;let r=-1===e?this.getLastVertex(t):this.getPrevVertex(e),n=-1===r?-1:this.getNextVertex(r),o=this.newVertex(null===i?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==i&&this.m_vertices.setPointByValNoCurves(a,i),this.setPathToVertex(o,t),this.setNextVertex(o,n),this.setPrevVertex(o,r),-1!==n&&this.setPrevVertex(n,o),-1!==r&&this.setNextVertex(r,o);let l=this.isClosedPath(t),h=this.getFirstVertex(t);-1===e&&this.setLastVertex(t,o),e===h&&(!l||!s||-1===h)&&this.setFirstVertex(t,o),l&&-1===n&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);let m=this.getGeometryFromPath(t);return this.setGeometryVertexCount(m,this.getPointCount(m)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new r.P({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){let i=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(i,t,e),i}addPoint_(t,e){let i=this.createGeometry(s.G.enumMultiPoint,t.getDescription());return this.appendPoint(i,t,e),i}appendMultiPath_(t,e){if(e.isEmpty())return;let i=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i.getPointCount()),this.m_verticesMp.addPoints(e,0,i.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);let s=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+i.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+i.getPathCount());for(let e=0,r=i.getPathCount();e<r;e++){if(0===i.getPathSize(e))continue;let r=this.insertPath(t,-1);this.setClosedPath(r,i.isClosedPath(e));for(let t=i.getPathStart(e),n=i.getPathEnd(e);t<n;t++){let e=this.insertVertex_(r,-1,null,!1);if(s){let s=this.getVertexIndex(e);if(1&i.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{let e=new Xn;i.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}i.isStrongPathStart(e)&&this.setStrongPathStart(r,!0),i.isStrongPathEnd(e)&&this.setStrongPathEnd(r,!0)}}addMultiPath(t,e){let i=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===s.G.enumPolygon&&this.setFillRule(i,t.getFillRule()),this.appendMultiPath(i,t,e),i}appendMultiPathPolyline(t,e,i){let s=e.getImpl(),r=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef(),n=new o.Envelope2D;e.queryEnvelope(n);{let n=i.clone(),o=s.getPointCount(),a=s.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(n,0,s.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;let i=s.queryLimitedSegmentIterator(n),a=-1,l=-100,h=-1,m=0,u=-1,d=-1,g=!1,c=i.nextSegment();if(null!==c)for(;;c=i.nextSegment()){let n=null===c,o=null===c?a:i.getPathIndex(),_=null===c?l:i.getStartPointIndex();if(n||(a===o&&l+1===_?m++:n=!0),n){if(-1!==u){let t=-1,i=-1;if(m===h){this.setClosedPath(d,g);let r=s.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+r-u),this.m_verticesMp.addPoints(e,u,r),i=s.getPathSize(a),t=r-1}else if(!g||l+1<s.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l+2-u),this.m_verticesMp.addPoints(e,u,l+2),i=l-u+2,t=l;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l+2-u),this.m_verticesMp?.addPoints(e,u,l+1),t=l,i=l-u+1;let r=s.getPathStart(a);this.m_verticesMp.addPoints(e,r,r+1),i+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,n=u;e<i;e++,n++){let e=this.insertVertex_(d,-1,null,!1);if(r){let i=this.getVertexIndex(e);if(1&s.getSegmentFlags(n)||n>t)this.setSegmentToIndex(i,null);else{let t=new Xn;s.getSegmentBuffer(n,t,!0),this.setSegmentToIndex(i,t.releaseSegment())}}}}if(null===c)break;m=1,u=_,a===o?d=this.insertPath(t,-1):(d=this.insertPath(t,-1),this.setClosedPath(d,!1),h=s.getSegmentCountPath(o),g=s.isClosedPath(o),a=o)}l=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,i){let r=e.getImpl(),a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef(),l=o.Envelope2D.constructEmpty();e.queryEnvelope(l),(0,s.g)(i.isIntersecting(l)&&!i.containsEnvelope(l));let h=o.Envelope2D.construct(-1/0,i.ymin,1/0,i.ymax),m=o.Envelope2D.construct(i.xmin,-1/0,i.xmax,1/0),u=r.getAccelerators();if(u&&u.getQuadTree()){let t=u.getQuadTree(),e=t.getIntersectionCount(h,0,0);e>t.getIntersectionCount(m,0,e+1)&&(m=(0,n.s)(h,h=m))}else h.height()>m.width()&&(m=(0,n.s)(h,h=m));let d=[],g=r.queryLimitedSegmentIterator(h),c=-1,_=-100,p=-1,f=0,y=-1,P=-1,x=-1,v=!0,C=g.nextSegment();if(null!==C)for(;;C=g.nextSegment()){let i=null===C,l=null===C?c:g.getPathIndex(),h=null===C?_:g.getStartPointIndex();if(i||(l===c?_+1===h?f++:i=!0:(i=c>=0,c<0&&(c=l,p=r.getSegmentCountPath(c),y=h,x=-1,f=1))),i){if(0!==d.length||p!==f){(0===d.length||d[0].first!==y)&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,y,y+1),-1===P&&(P=y),-1===x&&(x=this.insertPath(t,-1),this.setClosedPath(x,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(x,-1,null,!1));for(let{first:i,second:n}of d){-1===P&&(P=i);let o=-1,l=-1,h=i+n-1;if(n===p){let t=h+1;l=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l),this.m_verticesMp.addPoints(e,i,t),o=h,(0,s.g)(1===d.length)}else if(h+1<r.getPathEnd(c)){let t=h+2;l=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l),this.m_verticesMp.addPoints(e,i,t),o=h}else{let t=r.getPathStart(c),s=t===P?0:1,n=h+1;l=n-i+s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(n-i)+s),this.m_verticesMp.addPoints(e,i,n),o=h,s>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),-1===x&&(x=this.insertPath(t,-1),this.setClosedPath(x,!0));for(let t=0,e=i;t<l;t++,e++){let t=this.insertVertex_(x,-1,null,!1);if(a){let i=this.getVertexIndex(t);if(1&r.getSegmentFlags(e)||e>o)this.setSegmentToIndex(i,null);else{let t=new Xn;r.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(i,t.releaseSegment())}}}}if(0===d.length||d.at(-1).first+d.at(-1).second!==y+f){let t=y+f;t===e.getPathEnd(c)&&(t=e.getPathStart(c)),P!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(x,-1,null,!1))}}d.length=0,v=!0,l!==c&&(c=l,p=r.getSegmentCountPath(c),x=-1,P=-1),y=h,f=1}if(!C)break;{let t=o.Envelope2D.constructEmpty();C.queryLooseEnvelope(t),m.isIntersecting(t)?(v?d.push((0,n.o)(h,1)):d.at(-1).second++,v=!1):v=!0}_=h}}appendMultiPath(t,e,i){if(void 0===i)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;let r=e.getGeometryType()===s.G.enumPolygon,n=o.Envelope2D.constructEmpty();e.queryEnvelope(n),i.isIntersecting(n)&&(!i.containsEnvelope(n)&&e.getPointCount()>10?r?this.appendMultiPathPolygon(t,e,i):this.appendMultiPathPolyline(t,e,i):this.appendMultiPath_(t,e))}appendPoint(t,e,i){if(e.isEmpty()||void 0!==i&&!i.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);let s=this.insertPath(t,-1);this.insertVertex_(s,-1,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());let i=this.insertPath(t,-1);for(let t=0,s=e.getPointCount();t<s;t++)this.insertVertex_(i,-1,null,!1)}appendMultiPoint(t,e,i){if(void 0===i)return void this.appendMultiPoint_(t,e);let s=e.getAttributeStreamRef(0),r=0;for(let t=0,n=e.getPointCount();t<n;t++){let e=s.readPoint2D(2*t);i.contains(e)&&r++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+r);let n=-1,o=-1,a=0;for(let t=0,r=e.getPointCount();t<r;t++){let r=s.readPoint2D(2*t);i.contains(r)?(-1===n&&(n=t,o=t),o++):n>=0&&(this.m_verticesMp.addPoints(e,n,o-n),n=-1,a++)}if(n>0&&(this.m_verticesMp.addPoints(e,n,o-n),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+r);let l=this.insertPath(t,-1);for(let t=0,r=e.getPointCount();t<r;t++){let e=s.readPoint2D(2*t);i.contains(e)&&this.insertVertex_(l,-1,null,!1)}}splitSegmentForward(t,e,i,r,n){let o=this.getNextVertex(t);-1===o&&(0,s.b)("Edit_shape.split_segment_forward_");let a=this.getHelperPoint(),l=this.getPathFromVertex(t),h=t,m=this.hasSegmentParentage();for(let t=0,r=e.getResultSegmentCount(i);t<r;t++){let u=this.getVertexIndex(h),d=this.getNextVertex(h),g=e.getResultSegment(i,t),c=null;if(g.getGeometryType()!==s.G.enumLine&&(c=g.clone(),c.dropAllAttributes()),0===t&&(g.queryStart(a),this.setSegmentToIndex(u,null),this.setPointEx(h,a,e.getResultSegmentStartPointRank(i,t),e.getResultSegmentStartPointWeight(i,t),n)),this.setSegmentRank(h,e.getResultSegmentInteriorRank(i,t)),this.setSegmentWeight(h,e.getResultSegmentInteriorWeight(i,t)),m){let s=e.getResultSegmentSegmentParentage(i,t),r=e.getResultSegmentStartPointIsBreak(i,t);this.setSegmentParentageAndBreak(h,s,r)}if(g.queryEnd(a),t<r-1){this.setSegmentToIndex(u,c);let s=this.insertVertex(l,d,a);this.setWeight(s,e.getResultSegmentEndPointWeight(i,t)),this.setRank(s,e.getResultSegmentEndPointRank(i,t)),this.select(s),h=s}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(i,t),e.getResultSegmentEndPointWeight(i,t),n);let s=e.getResultSegmentEndPointIsBreak(i,t);this.setSegmentParentageBreakVertex(o,s),this.setSegmentToIndex(u,c)}}}splitSegmentBackward(t,e,i,r,n){let o=this.getNextVertex(t);-1===o&&(0,s.b)("Edit_shape.split_segment_backward_");let a=this.getHelperPoint(),l=this.getPathFromVertex(t),h=t,m=this.hasSegmentParentage();for(let t=0,r=e.getResultSegmentCount(i);t<r;t++){let u=r-t-1,d=this.getVertexIndex(h),g=this.getNextVertex(h),c=e.getResultSegment(i,u),_=null;if(c.getGeometryType()!==s.G.enumLine&&(_=c.clone(),_.reverse(),_.dropAllAttributes()),0===t&&(c.queryEnd(a),this.setSegmentToIndex(d,null),this.setPointEx(h,a,e.getResultSegmentEndPointRank(i,u),e.getResultSegmentEndPointWeight(i,u),n),this.setSegmentParentageAndBreak(h,e.getResultSegmentSegmentParentage(i,u),e.getResultSegmentEndPointIsBreak(i,u))),c.getGeometryType()===s.G.enumLine?this.setSegmentToIndex(d,null):this.setSegmentToIndex(d,_),this.setSegmentRank(h,e.getResultSegmentInteriorRank(i,u)),this.setSegmentWeight(h,e.getResultSegmentInteriorWeight(i,u)),c.queryStart(a),t<r-1){let t=this.insertVertex(l,g,a);this.setWeight(t,e.getResultSegmentStartPointWeight(i,u)),this.setRank(t,e.getResultSegmentStartPointRank(i,u)),this.select(t),h=t,m&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(i,u),e.getResultSegmentEndPointIsBreak(i,u))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(i,u),e.getResultSegmentStartPointWeight(i,u),n)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){let e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?(0,r.a0)(0,-1):(0,r.a0)(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){let t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return(0,r.a0)(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,i){let s=this.getNextVertex(t),r=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,r),this.setPrevVertex(r,t),this.setNextVertex(e,s),this.setPrevVertex(s,e),this.m_segments){let t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let i=this.getSegmentParentage(e),s=this.getSegmentParentage(t);(-1!==i||-1!==s)&&(s=(0,n.s)(i,i=s),this.setSegmentParentageAndBreak(t,s),this.setSegmentParentageAndBreak(e,i))}if(i){let e=this.getPathFromVertex(t),i=this.getGeometryFromPath(e),n=[!1],o=this.insertClosedPath(i,-1,s,this.getFirstVertex(e),n);n[0]&&this.setFirstVertex(e,r);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return-1}sortVerticesSimpleByYHelper(t,e,i){t.sort(e,i,(t,e)=>{let i=this.compareVerticesSimpleY(t,e);if(0===i){let s=this.getPathInternalIndexFromVertex(t),r=this.getPathInternalIndexFromVertex(e);i=s<r?-1:+(s>r)}return i})}sortVerticesSimpleByYHelper3D(t,e,i){(0,s.g)(0)}constructor(){this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=-1,this.m_lastGeometry=-1,this.m_vertexIndexList=new r.S(5),this.m_pathIndexList=new r.S(8),this.m_geometryIndexList=new r.S(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new r.B,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o.Envelope2D(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);let e=this.hasCurves(),i=o.Envelope2D.constructEmpty(),s=this.queryVertexIterator(),r=!0;for(let t=s.next();-1!==t;t=s.next()){if(r?i.merge(this.getXY(t)):i.mergeNe(this.getXY(t)),e){let e=this.getSegment(t);if(null!==e){let t=o.Envelope2D.constructEmpty();e.queryLooseEnvelope(t),i.mergeEnvelope2D(t)}}r=!1}return i}getEnvelope3D(t){return(0,s.g)(0),r.r.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,s.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){let i=t.getGeometryType();if((0,s.j)(i))return this.addMultiPath(t,e);if(i===s.G.enumMultiPoint)return this.addMultiPoint(t,e);if(i===s.G.enumPoint)return this.addPoint_(t,e);if(i===s.G.enumEnvelope){let i=new ni;return i.addEnvelope(t,!1),this.addMultiPath(i,e)}(0,s.b)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());let i=e.getGeometryType();(0,s.j)(i)?this.appendMultiPath(t,e):i!==s.G.enumMultiPoint?(0,s.b)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);let i=this.queryVertexIterator();for(let t=i.next();-1!==t;t=i.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(s.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=-1,i=-1,r=-1;for(let n=this.getFirstGeometry();-1!==n;){if(t===s.G.enumUnknown||this.getGeometryType(n)===t){if(-1===e){e=n,i=this.getPathCount(e),r=this.getPointCount(e),n=this.getNextGeometry(n);continue}for(let t=this.getFirstPath(n);-1!==t;t=this.getNextPath(t))this.setPathGeometry(t,e);i+=this.getPathCount(n),r+=this.getPointCount(n);let t=this.getLastPath(e),s=this.getFirstPath(n);-1===t?this.setFirstPath(e,s):this.setNextPath(t,s),-1!==s&&(this.setPrevPath(s,t),this.setLastPath(e,this.getLastPath(n))),this.setFirstPath(n,-1),this.setLastPath(n,-1);let o=n;n=this.getNextGeometry(n),this.setGeometryVertexCount(o,0),this.removeGeometry(o);continue}n=this.getNextGeometry(n)}return-1!==e&&(this.setGeometryVertexCount(e,r),this.setGeometryPathCount(e,i),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let i=this.m_geometryIndexList.getField(t,2);i&=-134217729,i|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,i)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let i=this.m_geometryIndexList.getField(t,2);!!(67108864&i)!==e&&(i&=-67108865,i|=e?67108864:0,this.m_geometryIndexList.setField(t,2,i))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){let i=this.getPathFromVertex(t),s=this.getGeometryFromPath(i);this.setGeometryModified(s,e)}getGeometryModifiedWithVertex(t){let e=this.getPathFromVertex(t),i=this.getGeometryFromPath(e);return this.getGeometryModified(i)}swapGeometry(t,e){let i=this.getFirstPath(t),s=this.getFirstPath(e),r=this.getLastPath(t),n=this.getLastPath(e);for(let i=this.getFirstPath(t);-1!==i;i=this.getNextPath(i))this.setPathGeometry(i,e);for(let i=this.getFirstPath(e);-1!==i;i=this.getNextPath(i))this.setPathGeometry(i,t);this.setFirstPath(t,s),this.setFirstPath(e,i),this.setLastPath(t,n),this.setLastPath(e,r);let o=this.getPointCount(t),a=this.getPathCount(t),l=this.getPointCount(e),h=this.getPathCount(e);this.setGeometryVertexCount(t,l),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,h),this.setGeometryPathCount(e,a);let m=this.m_geometryIndexList.getField(t,2),u=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,u),this.m_geometryIndexList.setField(e,2,m)}addPathFromMultiPath(t,e,i){let r=this.createGeometry(i?s.G.enumPolygon:s.G.enumPolyline,t.getDescription()),n=t.getImpl();if(t.getPathSize(e)<2)return r;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),n.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);let o=this.insertPath(r,-1);this.setClosedPath(o,n.isClosedPath(e)||i);let a=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef();for(let t=n.getPathStart(e),i=n.getPathEnd(e);t<i;t++){let e=this.insertVertex_(o,-1,null,!1);if(a){let i=this.getVertexIndex(e);if(1&n.getSegmentFlags(t))this.setSegmentToIndex(i,null);else{let e=new Xn;n.querySegment(t,e,!0),this.setSegmentToIndex(i,e.releaseSegment())}}}return n.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),n.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),r}getGeometry(t){let e=this.getGeometryType(t),i=function(t,e){let i,n=e,o=null;switch(n||=(o=(0,s.k)(t)?(0,r.L)():(0,r.K)(),o),t){case s.G.enumPoint:i=new r.P({vd:n});break;case s.G.enumLine:i=new Yn({vd:n});break;case s.G.enumBezier:i=new vs({vd:n});break;case s.G.enumEllipticArc:i=new Ar({vd:n});break;case s.G.enumRationalBezier2:i=new Ut({vd:n});break;case s.G.enumBezier2:i=new Qt({vd:n});break;case s.G.enumEnvelope:i=new r.E({vd:n});break;case s.G.enumMultiPoint:i=new W({vd:n});break;case s.G.enumPolyline:i=new Dt({vd:n});break;case s.G.enumPolygon:i=new ni({vd:n});break;case s.G.enumMultipatch:(0,s.a)("multipatch not impl");break;case s.G.enumGeometryCollection:i=new U({vd:n});break;default:(0,s.b)("Geometry.create")}return i}(e,this.m_verticesMp.getDescription()),n=this.getPointCount(t);if(0===n)return i;if((0,s.j)(e)){let e=i.getImpl(),s=this.getPathCount(t),o=(0,r.a0)(s+1),a=(0,r.a1)(s+1,0),l=i.getDescription(),h=this.hasCurves();for(let i=0,h=l.getAttributeCount();i<h;i++){let h=l.getSemantics(i),m=oi.getComponentCount(h),u=(0,r.X)(h,n),d=this.m_vertices.getAttributeStreamRef(h),g=0,c=0,_=0;for(let e=this.getFirstPath(t);-1!==e;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&&a.setBits(c,t);let i=this.getPathSize(e);if(o.write(c++,_),_+=i,0===h){let t,i=d,s=u;for(let r=this.getFirstVertex(e);g<_;r=this.getNextVertex(r),g++){let e=this.getVertexIndex(r);t=i.readPoint2D(2*e),s.writePoint2D(2*g,t)}}else for(let t=this.getFirstVertex(e);g<_;t=this.getNextVertex(t),g++){let e=this.getVertexIndex(t);for(let t=0;t<m;t++){let i=d.readAsDbl(e*m+t);u.writeAsDbl(g*m+t,i)}}}e.setAttributeStreamRef(h,u),o.write(s,n)}if(e.setPathFlagsStreamRef(a),e.setPathStreamRef(o),e.notifyModifiedFlags(65535),h){let i=0,s=0;for(let r=this.getFirstPath(t);-1!==r;r=this.getNextPath(r)){i+=this.getPathSize(r);for(let t=this.getFirstVertex(r);s<i;t=this.getNextVertex(t)){let i=this.getSegment(t);null!==i&&i.isCurve()&&e.replaceSegment(s,i,!0),s++}}}}else if(e===s.G.enumMultiPoint){let e=i.getImpl(),s=i.getDescription();e.reserve(n),e.resizeNoInit(n);for(let i=0,r=s.getAttributeCount();i<r;i++){let r=s.getSemantics(i),n=oi.getComponentCount(r),o=e.getAttributeStreamRef(r),a=this.m_vertices.getAttributeStreamRef(r),l=0,h=this.getFirstPath(t),m=this.getPathSize(h);for(let t=this.getFirstVertex(h);l<m;t=this.getNextVertex(t),l++){let e=this.getVertexIndex(t);for(let t=0;t<n;t++){let i=a.readAsDbl(e*n+t);o.writeAsDbl(l*n+t,i)}}e.setAttributeStreamRef(r,o)}e.notifyModifiedFlags(65535)}else(0,s.d)("getGeometry");return i}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==s.G.enumMultiPoint&&(0,s.b)("get_point_geometry_only");let i=this.getPointCount(t);if(i>1&&(0,s.b)("get_point_geometry_only"),0===i)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();let r=this.getFirstPath(t),n=this.getFirstVertex(r);this.queryPoint(n,e)}removeGeometry(t){for(let e=this.getFirstPath(t);-1!==e;e=this.removePath(e));let e=this.getPrevGeometry(t),i=this.getNextGeometry(t);return-1===e?this.m_firstGeometry=i:this.setNextGeometry(e,i),-1===i?this.m_lastGeometry=e:this.setPrevGeometry(i,e),this.freeGeometry(t),i}createGeometry(t,e){void 0===e&&(e=(0,r.K)());let i=this.newGeometry(t);return this.m_vertices||=(this.m_verticesMp=new W({vd:e}),this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),-1===this.m_firstGeometry?(this.m_firstGeometry=i,this.m_lastGeometry=i):(this.setPrevGeometry(i,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,i),this.m_lastGeometry=i),i}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,i){let s=this.m_geometryIndices[e],r=this.getGeometryIndex(t);r>=s.size()&&s.resize(Math.max(1.25*r,16),-1),s.write(r,i)}getGeometryUserIndex(t,e){let i=this.getGeometryIndex(t),s=this.m_geometryIndices[e];return i<s.size()?s.read(i):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=(0,r.a0)(0),t;this.m_geometryIndices.push((0,r.a0)(0));let t=this.m_geometryIndices.length-1;return(0,s.g)(t>=0&&t<=2**53-1),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();-1!==t;t=this.getNextGeometry(t))if(!(0,s.j)(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,i,r,o){let a=t*t,l=0,h=this.hasCurves(),m=this.hasSegmentParentage();for(let t=-1===o?this.getFirstGeometry():o;-1!==t;t=-1===o?this.getNextGeometry(t):-1){let o=this.getGeometryType(t);if(!(0,s.j)(o)||i&&o!==s.G.enumPolygon)continue;let u=this.getGeometryType(t)===s.G.enumPolygon,d=this.getGeometryModified(t);for(let i=this.getFirstPath(t);-1!==i;){let o=0;for(let e=this.getFirstVertex(i);o<Math.trunc(this.getPathSize(i)/2);){let u=this.getNextVertex(e);if(-1===u)break;let g=this.getXY(e),c=this.getXY(u),_=n.P.sqrDistance(g,c),p=!0;do{if(_<=a){if(h){let t=this.getSegment(e);if(null!==t){let e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===l&&(l=-1):l=1,u!==this.getLastVertex(i)){let i=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(u));if(this.transferAllDataToTheVertex(u,e,!0),this.removeVertex(u,!1),r&&!d&&(this.setGeometryModified(t,!0),d=!0),m&&e!==u){this.setSegmentParentageBreakVertex(e,i);let t=this.getNextVertex(e);(0,s.g)(-1!==t),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}p=!1}}while(0);p&&(e=this.getNextVertex(e)),o++}let g=this.getFirstVertex(i);for(let e=this.isClosedPath(i)?g:this.getLastVertex(i);this.getPathSize(i)>0;){let o=this.getPrevVertex(e);if(-1===o)break;{let u=this.getXY(o),c=this.getXY(e),_=n.P.sqrDistance(u,c),p=!0;do{if(_<=a){if(h){let t=this.getSegment(o);if(null!==t){let e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===l&&(l=-1):l=1,m){(0,s.g)(this.m_segmentParentageIndex>=0);let t=this.getUserIndex(e,this.m_segmentParentageIndex);this.transferAllDataToTheVertex(o,e,!0),this.setUserIndex(e,this.m_segmentParentageIndex,t)}else this.transferAllDataToTheVertex(o,e,!0);let n=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(o));this.removeVertex(o,!0),r&&!d&&(this.setGeometryModified(t,!0),d=!0),m&&o!==e&&(n||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),g===o&&(g=this.getFirstVertex(i)),p=!1}}while(0);if(p&&(e=this.getPrevVertex(e),e===g))break}}let c=this.getPathSize(i),_=e&&c<(u?3:2);_&&u&&2===c&&h&&(_=!this.pathHasCurves(i)),_?(i=this.removePath(i),0===l&&(l=-1),r&&!d&&(this.setGeometryModified(t,!0),d=!0)):i=this.getNextPath(i)}}return l}filterClosePoints3D(t,e,i,r,n,o){return(0,s.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();-1!==e;e=this.getNextGeometry(e))if((0,s.j)(this.getGeometryType(e)))for(let i=this.getFirstPath(e);-1!==i;){let e=this.getPathSize(i);if(0===e)return!0;let s=this.getFirstVertex(i);for(let i=0;i<e;i++){let e=this.getNextVertex(s);if(-1===e)break;let i=this.getVertexIndex(s),r=this.getSegmentFromIndex(i),n=0;if(null!==r){if(n=r.calculateLowerLength2D(),n<=t&&(n=r.calculateUpperLength2D(),n<=t||(n=r.calculateLength2D(),n<=t)))return!0}else{let s=this.getVertexIndex(e);if(n=this.m_vertices.getShortestDistance(i,s),n<=t)return!0}s=e}i=this.getNextPath(i)}return!1}hasDegenerateSegments3D(t,e){return(0,s.g)(0),!1}transferAllDataToTheVertex(t,e,i=!1){let s=this.getVertexIndex(t),r=this.getVertexIndex(e);if(i){let t=1,e=1;if(this.m_ranks&&(t=this.getRankWithIndex(s),e=this.getRankWithIndex(r)),t>e&&this.setRankWithIndex(r,t),t>=e&&this.m_weights){let i=this.getWeightWithIndex(s),n=this.getWeightWithIndex(r);(t>e||i>n)&&this.setWeightWithIndex(r,i)}}else{if(this.m_weights){let t=this.getWeightWithIndex(s);this.setWeightWithIndex(r,t)}if(this.m_ranks){let t=this.getRankWithIndex(s);this.setRankWithIndex(r,t)}}if(this.m_segmentWeights){let t=this.getSegmentWeightWithIndex(s);this.setSegmentWeightWithIndex(r,t)}if(this.m_segmentRanks){let t=this.getSegmentRankWithIndex(s);this.setSegmentRankWithIndex(r,t)}for(let i=0,s=this.m_indices.length;i<s;i++)if(i!==this.m_selectionIndex&&null!==this.m_indices[i]){let s=this.getUserIndex(t,i);this.setUserIndex(e,i,s)}let n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,i,r,n){let o=0,a=this.getNextVertex(t);-1===a&&(0,s.b)("");let l=this.getVertexIndex(t),h=this.getVertexIndex(a),m=this.getSegmentFromIndex(l),u=this.m_vertices.getShortestDistance(l,h),d=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&m&&(u=m.calculateLength2D());let c=this.getSegmentParentage(t),_=this.getHelperPoint();if(m){let t=0,s=0,n=-1;for(let p=0;p<i;p++){let i=e[p];if(t<i&&i<1){let e=m.cut(t,i);if(null!==r&&(p>0&&e.setStartXY(r[p-1]),e.setEndXY(r[p]),e.normalizeAfterEndpointChange(),s=p),g){let t=u>0?m.calculateSubLengthFromStart(i)/u:0;this.m_vertices.interpolateTwoVertices(l,h,t,_)}_.setXY(e.getEndXY()),n=this.insertVertex(d,a,_),o++;let f=this.getPrevVertex(n),y=this.getVertexIndex(f);this.setSegmentToIndex(y,e),-1!==c&&this.setSegmentParentageAndBreak(n,c,!1),t=i}}if(-1!==n){let e=m.cut(t,1);null!==r&&(e.setStartXY(r[s]),e.normalizeAfterEndpointChange());let i=this.getVertexIndex(n);this.setSegmentToIndex(i,e)}}else{let t=0;for(let s=0;s<i;s++){let i=e[s];if(t<i&&i<1){this.m_vertices.interpolateTwoVertices(l,h,i,_);let t=this.insertVertex(d,a,_);o++,-1!==c&&this.setSegmentParentageAndBreak(t,c,!1)}t=i}}return o}splitSegment(t,e,i,s=null){return this.splitSegmentAxisAware(t,e,i,s,-1)}snapControlPoints(t,e,i){-1===this.getNextVertex(t)&&(0,s.b)("");let r=t,n=!1;for(let t=0;t<e;++t){let t=this.getVertexIndex(r),e=this.getSegmentFromIndex(t);if(e){let t=e.snapControlPoints(i);n||=t}r=this.getNextVertex(r)}return n}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0,i=this.queryVertexIteratorOnSelection();for(let s=i.next();-1!==s;s=i.next()){let i=this.getVertexIndex(s),r=this.getSegmentFromIndex(i);r&&(e|=+!!r.snapControlPoints(t))}return 0!==e}calculateSubLength2D(t,e,i){return(0,s.g)(0),0}setPoint(t,e,i){if(this.setPointOnly(t,e),null!==this.m_segments){let s=this.getVertexIndex(t),r=this.getSegmentFromIndex(s);null!==r&&(r.setStartXY(e.getXY()),r.normalizeAfterEndpointChange(),i&&r.ensureXYMonotone());let n=this.getPrevVertex(t);if(-1!==n){let t=this.getVertexIndex(n),s=this.getSegmentFromIndex(t);null!==s&&(s.setEndXY(e.getXY()),s.normalizeAfterEndpointChange(),i&&s.ensureXYMonotone())}}}setPointEx(t,e,i,s,r){this.setPoint(t,e,r);let n=this.getVertexIndex(t);this.setWeightWithIndex(n,s),this.setRankWithIndex(n,i)}setPointOnly(t,e){let i=this.getVertexIndex(t);this.m_vertices.setPointByValNoCurves(i,e)}setPointOnlyEx(t,e,i,r){(0,s.g)(0)}queryPoint(t,e){let i=this.getVertexIndex(t);this.m_vertices.getPointByVal(i,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,i){let s=this.getVertexIndex(t);if(this.m_vertices?.setXYCoordsNoCurves(s,e,i),null!==this.m_segments){let r=this.getSegmentFromIndex(s);null!==r&&(r.setStartXYCoords(e,i),r.normalizeAfterEndpointChange());let n=this.getPrevVertex(t);if(-1!==n){let t=this.getVertexIndex(n),s=this.getSegmentFromIndex(t);null!=s&&(s.setEndXYCoords(e,i),s.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,i){let s=this.getVertexIndex(t);if(this.m_vertices.setXYCoordsNoCurves(s,e,i),null!==this.m_segments){let r=this.getSegmentFromIndex(s);if(null!==r){let t=r.getEndXY();r.setCoordsForIntersector(new n.P(e,i),t,!1),r.ensureXYMonotone()}let o=this.getPrevVertex(t);if(-1!==o){let t=this.getVertexIndex(o),s=this.getSegmentFromIndex(t);if(null!==s){let t=s.getStartXY();s.setCoordsForIntersector(t,new n.P(e,i),!1),s.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){let i=this.getVertexIndex(t);return this.m_vertices.queryXY(i,e)}getXY(t){let e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,i){(0,s.g)(0)}setXYZ(t,e,i){(0,s.g)(0)}setXYZCoords(t,e,i,r){(0,s.g)(0)}queryXYZ(t,e){(0,s.g)(0)}getXYZ(t){return(0,s.g)(0),r.k.getNAN()}getXYZWithIndex(t){return(0,s.g)(0),r.k.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){(0,s.g)(0)}getAttributeAsDbl(t,e,i){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),i)}queryAttributeAsDbl(t,e,i,r){(0,s.g)(0)}setAttribute(t,e,i,r){(0,s.g)(0)}setAttributeInt(t,e,i,r){(0,s.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,s.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){let 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(0,s.g)(0),!1}setWeight(t,e){e<1&&(e=1);let i=1===e;if(null==this.m_weights){if(i)return;this.m_weights=(0,r.a2)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_weights.size()){if(i)return;this.m_weights.resize(s+1,1)}this.m_weights.write(s,e)}setWeightWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_weights){if(i)return;this.m_weights=(0,r.a2)(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(i)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;let 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 1;let e=this.getVertexIndex(t);return e>=this.m_ranks.size()?1:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?1:this.m_ranks.read(t)}setRank(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_ranks){if(i)return;this.m_ranks=(0,r.a0)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_ranks.size()){if(i)return;this.m_ranks.resize(s+1,1)}this.m_ranks.write(s,e)}setRankWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_ranks){if(i)return;this.m_ranks=(0,r.a0)(this.m_vertices.getPointCount(),1)}if(t>=this.m_ranks.size()){if(i)return;this.m_ranks.resize(t+1,1)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentWeights){if(i)return;this.m_segmentWeights=(0,r.a2)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_segmentWeights.size()){if(i)return;this.m_segmentWeights.resize(s+1,1)}this.m_segmentWeights.write(s,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null==this.m_segmentWeights){if(i)return;this.m_segmentWeights=(0,r.a2)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(i)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;let 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 mi.st_defaultRank;let e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?mi.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?1:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentRanks){if(i)return;this.m_segmentRanks=(0,r.a0)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_segmentRanks.size()){if(i)return;this.m_segmentRanks.resize(s+1,1)}this.m_segmentRanks.write(s,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentRanks){if(i)return;this.m_segmentRanks=(0,r.a0)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(i)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}static st_defaultRank=1;removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,i){let s=this.m_indices[e],r=this.getVertexIndex(t);if(s.size()<=r){if(-1===i)return;s.resize(this.m_vertices.getPointCount(),-1)}s.write(r,i)}getUserIndex(t,e){let i=this.getVertexIndex(t),s=this.m_indices[e];return i<s.size()?s.read(i):-1}addToUserIndex(t,e,i){let s=this.m_indices[e],r=this.getVertexIndex(t);s.size()<=r&&s.resize(this.m_vertices.getPointCount(),-1);let n=s.read(r);s.write(r,n+i)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());let t=this.m_indices.length-1;return(0,s.g)(t>=0&&t<=(0,n.i)()),t}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));let t=this.m_indices.length-1;return(0,s.g)(t>=0&&t<=2**53-1),t}fillUserIndexForGeometry(t,e,i){let s=this.m_indices[e],r=s.size();for(let e=this.getFirstPath(t);-1!==e;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let n=0,o=this.getPathSize(e);n<o;n++,t=this.getNextVertex(t)){let e=this.getVertexIndex(t);e<r&&s.write(e,i)}}}fillUserIndexForSelection(t,e){(0,s.g)(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){let e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,i=!1){let s=this.getNextVertex(t);if(-1===s)return!1;if(!this.m_bHasAttributes||i){let i=this.getXY(t);e.setStartXY(i);let r=this.getXY(s);e.setEndXY(r)}else{let i=new r.P({vd:this.getVertexDescription()});this.queryPoint(t,i),e.setStart(i),this.queryPoint(s,i),e.setEnd(i)}return!0}queryLineConnector3D(t,e,i=!1){return(0,s.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,s.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;let e=this.getFirstVertex(t);if(-1===e)return!1;let i=this.getPathSize(t),r=e;for(let t=0;t<i;t++,r=this.getNextVertex(r)){let t=this.getSegment(r);if(null!==t&&t.getGeometryType()!==s.G.enumLine)return!0}return!1}insertPath(t,e){let i=-1;-1===e?i=this.getLastPath(t):(t!==this.getGeometryFromPath(e)&&(0,s.b)(""),i=this.getPrevPath(e));let r=this.newPath(t);return-1!==e&&this.setPrevPath(e,r),this.setNextPath(r,e),this.setPrevPath(r,i),-1===i?this.setFirstPath(t,r):this.setNextPath(i,r),-1===e&&this.setLastPath(t,r),this.setGeometryPathCount(t,this.getPathCount(t)+1),r}removePath(t){let e=this.getPrevPath(t),i=this.getNextPath(t),s=this.getGeometryFromPath(t);return-1===e?this.setFirstPath(s,i):this.setNextPath(e,i),-1===i?this.setLastPath(s,e):this.setPrevPath(i,e),this.clearPath(t),this.setGeometryPathCount(s,this.getPathCount(s)-1),this.freePath(t),i}clearPath(t){let e=this.getFirstVertex(t);if(-1!==e){let i=e;for(let e=0,s=this.getPathSize(t);e<s;e++){let t=i;i=this.getNextVertex(i),this.freeVertex(t)}let s=this.getGeometryFromPath(t);this.setGeometryVertexCount(s,this.getPointCount(s)-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){let i=this.getFirstVertex(t),s=this.getLastVertex(t);if(e){this.setNextVertex(s,i),this.setPrevVertex(i,s);let t=this.getVertexIndex(s);this.setSegmentToIndex(t,null)}else{this.setNextVertex(s,-1),this.setPrevVertex(i,-1);let t=this.getVertexIndex(s);this.setSegmentToIndex(t,null)}}let i=(1|this.getPathFlags(t))-1;this.setPathFlags(t,i|+!!e)}closeAllPaths(t){(0,s.g)(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){let i=(8|this.getPathFlags(t))-8;this.setPathFlags(t,i|(e?8:0))}setStrongPathEnd(t,e){let i=(16|this.getPathFlags(t))-16;this.setPathFlags(t,i|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){let i=(2|this.getPathFlags(t))-2;this.setPathFlags(t,i|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];let e=this.getFirstVertex(t);if(-1===e)return 0;let i=this.getXY(e),r=new n.K(0),o=this.getPathSize(t);if(o>2){let t=i.clone(),s=t.x,a=t.y,l=this.getNextVertex(e),h=this.getXY(l);l=this.getNextVertex(l);let m=n.P.getNAN();for(let e=2;e<o;e++,l=this.getNextVertex(l))this.queryXY(l,m),r.pe((m.x-t.x)*(h.y-a)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(m);r.pe((s-t.x)*(h.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){let e=this.getSegment(t);if(null===e||e.getGeometryType()===s.G.enumLine)continue;let i=2*e.calculateArea2DHelper();r.pe(i)}}this.setRingAreaValid(t,!0);let a=.5*r.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,i){let s=this.m_pathindices[e],r=this.getPathIndex(t);s.size()<this.m_pathAreas.length&&s.resize(this.m_pathAreas.length,-1),s.write(r,i)}getPathUserIndex(t,e){let i=this.getPathIndex(t),s=this.m_pathindices[e];return i<s.size()?s.read(i):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());let t=this.m_pathindices.length-1;return(0,s.g)(t>=0&&t<=2**53-1),t}fillPathUserIndexForGeometry(t,e,i){let s=this.m_pathindices[e],r=s.size();for(let e=this.getFirstPath(t);-1!==e;e=this.getNextPath(e)){let t=this.getPathIndex(e);t<r&&s.write(t,i)}}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,e,i){if(-1===i&&(0,s.b)(""),e===i)return;let r=this.getNextPath(i),n=this.getPrevPath(i),o=this.getGeometryFromPath(i);-1===n?this.setFirstPath(o,r):this.setNextPath(n,r),-1===r?this.setLastPath(o,n):this.setPrevPath(r,n),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(i)),this.setGeometryPathCount(o,this.getPathCount(o)-1),n=-1===e?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(i,n),this.setNextPath(i,e),-1===e?this.setLastPath(t,i):this.setPrevPath(e,i),-1===n?this.setFirstPath(t,i):this.setNextPath(n,i),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(i)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(i,t)}addVertex(t,e){return this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint()),this.insertVertex_(t,-1,this.getHelperPoint(),!1)}insertVertex(t,e,i){return this.insertVertex_(t,e,i,!0)}removeVertex(t,e){let i=this.getPathFromVertex(t),s=this.getPrevVertex(t),r=this.getNextVertex(t);-1!==s&&this.setNextVertex(s,r);let n=this.getPathSize(i);if(t===this.getFirstVertex(i)&&this.setFirstVertex(i,n>1?r:-1),-1!==r&&this.setPrevVertex(r,s),t===this.getLastVertex(i)&&this.setLastVertex(i,n>1?s:-1),this.hasCurves()&&-1!==s&&-1!==r){let i=this.getVertexIndex(t),n=this.getVertexIndex(s),o=this.getVertexIndex(r);if(e){let t=this.getSegmentFromIndex(n);if(null!==t){let e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(i,null)}else{let t=this.getSegmentFromIndex(i);if(this.setSegmentToIndex(i,null),null!==t){let e=this.m_vertices.getXY(n);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,t)}}this.setPathSize(i,n-1);let o=this.getGeometryFromPath(i);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),r}removeVertices(t,e){(0,s.g)(t!==e);let i=this.getPathFromVertex(t),r=this.getPrevVertex(t),n=this.getPrevVertex(e);-1!==r&&this.setNextVertex(r,e);let o=this.getPathSize(i),a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,r),this.setPrevVertex(t,-1),this.setNextVertex(n,-1);let l=0,h=t,m=this.getFirstVertex(i),u=!1;for(;;){let t=this.getNextVertex(h);if(u||=m===h,this.freeVertex(h),l++,h===n)break;h=t}o-=l,u&&this.setFirstVertex(i,o>0?e:-1),this.setPathSize(i,o);let d=this.getGeometryFromPath(i);this.setGeometryVertexCount(d,this.getPointCount(d)-l)}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,-1,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,s.d)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();-1!==t;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);-1!==e;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let i=0,s=this.getPathSize(e);i<s;i++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=-1){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=-1){let i=-1,r=-1,n=-1,o=-1,a=0,l=!1;for(i=-1===e?this.getFirstGeometry():e;-1!==i;i=this.getNextGeometry(i))if(!t||(0,s.j)(this.getGeometryType(i))){for(r=this.getFirstPath(i);-1!==r;r=this.getNextPath(r))if(n=this.getFirstVertex(r),o=n,a=0,-1!==n){l=!0;break}if(l||-1!==e)break}return l||(i=-1),li.create_(this,i,r,n,o,a,t,!1,-1!==e)}queryVertexIteratorOnSelection(t=-1){return this.m_selection?li.create_(this,t,-1,-1,-1,-1,!1,!0,-1!==t):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,s.g)(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;let e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=-1,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(0,s.g)(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,i=this.m_segments.length;e<i;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,i,s,r){s?this.splitSegmentForward(t,e,i,!0,r):this.splitSegmentBackward(t,e,i,!0,r)}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){let e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){if(null===this.m_segments)return!1;let e=this.getVertexIndex(t);return this.m_segments.length>e&&null!==this.m_segments[e]}querySegment(t,e,i=!0,s=!1){let r=this.getNextVertex(t);if(-1===r)return!1;let n=this.getSegment(t);if(!n)return!i&&(this.queryLineConnector(t,e.createLine(),s),!0);if(e.copyFrom(n,!0),s)return!0;if(this.m_vertexDescription.getAttributeCount()>1){let i=this.getHelperPoint();this.queryPoint(t,i),e.get().setStart(i),this.queryPoint(r,i),e.get().setEnd(i)}return!0}getSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||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(0,s.g)(0),!1}reverseRingInternal(t){let e=this.hasCurves(),i=this.hasSegmentParentage(),s=null,r=-1,n=t;if(e){let t=this.getVertexIndex(n);s=this.getAndClearSegmentFromIndex(t)}i&&(r=this.getSegmentParentage(n));do{let t=this.getPrevVertex(n),o=this.getNextVertex(n);if(this.setNextVertex(n,t),this.setPrevVertex(n,o),e){let t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);s&&s.reverse(),this.setSegmentToIndex(t,s),s=e}if(i){let t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,r),r=t}n=o}while(n!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){let e=this.getPrevPath(t),i=this.getNextPath(t),s=this.getGeometryFromPath(t);-1===e?this.setFirstPath(s,i):this.setNextPath(e,i),-1===i?this.setLastPath(s,e):this.setPrevPath(i,e),this.setFirstVertex(t,-1),this.setLastVertex(t,-1),this.freePath(t)}insertClosedPath(t,e,i,s,r){let n=this.insertPath(t,-1),o=0,a=i;for(r[0]=!1;;){a===s&&(r[0]=!0),this.setPathToVertex(a,n),o++;let t=this.getNextVertex(a);if(t===i)break;a=t}return this.setClosedPath(n,!0),this.setPathSize(n,o),r[0]&&(i=s),this.setFirstVertex(n,i),this.setLastVertex(n,this.getPrevVertex(i)),this.setRingAreaValid(n,!1),n}findVertex2D(t,e){return(0,s.g)(0),0}findVertex3D(t,e,i){return(0,s.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}getNextNthVertex(t,e){if(0===e)return t;let i=t;for(let t=0;t<e;++t)if(i=e>0?this.getNextVertex(i):this.getPrevVertex(i),-1===i)return-1;return i}removeVertexInternal(t,e){let i=this.getPrevVertex(t),s=this.getNextVertex(t);if(-1!==i&&this.setNextVertex(i,s),-1!==s&&this.setPrevVertex(s,i),this.hasCurves()&&-1!==i&&-1!==s){let r=this.getVertexIndex(t),n=this.getVertexIndex(i),o=this.getVertexIndex(s);if(e){let t=this.getSegmentFromIndex(n);if(null!==t){let e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,null)}else{let t=this.getSegmentFromIndex(r);if(this.setSegmentToIndex(r,null),null!==t){let e=this.m_vertices.getXY(n);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,t)}}return this.freeVertex(t),s}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){let i=(4|this.getPathFlags(t))-4;this.setPathFlags(t,i|(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){(0,s.g)(0)}sortVerticesSimpleByY(t,e,i){this.m_bucketSort.sort(t,e,i,new ai(this))}sortVerticesSimpleByX(t,e,i){(0,s.g)(0)}sortVerticesSimpleByY3D(t,e,i){(0,s.g)(0)}snapVertexForPoleClipping(t,e){let i=this.getPrevVertex(t);-1!==i&&this.replaceCurveWithLine(i),-1!==this.getNextVertex(t)&&this.replaceCurveWithLine(t);let s=new n.P;this.queryXY(t,s),s.y=e,this.setXY(t,s)}setSegmentParentageAndBreak(t,e,i=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,s.g)(e<=(0,n.b)()>>1),e<<=1,e|=+!!i),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,s.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,s.g)(e<=(0,n.b)()>>1),e<<=1,e|=+!!this.getSegmentParentageBreakVertex(t)),this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;let e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){let e=this.getSegmentParentage(t);return new hi(e)}return new hi(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let i=this.getUserIndex(t,this.m_segmentParentageIndex);i<0||!!(1&i)!==e&&(e?i|=1:i&=(0,n.b)()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,i))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;let e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){let e=this.getPrevVertex(t);return-1!==e&&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 ui(t){if(t.isEmpty())return new ni({vd:t.getDescription()});if((0,s.j)(t.getGeometryType())&&t.hasNonLinearSegments())return function(t){(0,s.g)(t.hasNonLinearSegments()&&!t.isEmpty());let e=new pi;return e.addGeometry(t),e.getBoundingGeometry()}(t);let e=t.getImpl(),i=e.getPointCount();if(i<=2){if(1===i||e.getXY(0).equals(e.getXY(1))){let t=new r.P({vd:e.getDescription()});return e.getPointByVal(0,t),t}{let t=new r.P,i=new Dt({vd:e.getDescription()});return e.getPointByVal(0,t),i.startPathPoint(t),e.getPointByVal(1,t),i.lineToPoint(t),i}}let o=e.getAttributeStreamRef(0),a=new pi({stream:o,n:i}),l=1,h=o.readPoint2D(0),m=new n.P;for(;l<i&&o.queryPoint2D(l<<1,m).equals(h);)l++;if(a.m_treeHull.addElement(0),l<i){a.m_treeHull.addBiggestElement(l);let t=new n.P;for(let i=l+1;i<e.getPointCount();i++){o.queryPoint2D(i<<1,t);let e=a.treeHull(t);-1!==e&&a.m_treeHull.setElement(e,i)}}let u=e.getDescription(),d=u.getAttributeCount()>1,g=a.m_treeHull.size(),c=null;if(g>=2){c=g>=3?new ni({vd:u}):new Dt({vd:u});let t=c.getImpl();t.reserve(a.m_treeHull.size()),t.addPathPoint2D(null,0,!0);let i=new n.P;for(let s=a.m_treeHull.getFirst();-1!==s;s=a.m_treeHull.getNext(s))if(d){let i=new r.P;e.getPointByVal(a.m_treeHull.getElement(s),i),t.insertPoint(0,-1,i)}else o.queryPoint2D(a.m_treeHull.getElement(s)<<1,i),t.insertPoint2D(0,-1,i)}else if(d){let t=new r.P({vd:u});e.getPointByVal(a.m_treeHull.getElement(a.m_treeHull.getFirst()),t),c=t}else{let t=o.readPoint2D(a.m_treeHull.getElement(a.m_treeHull.getFirst())<<1);c=new r.P(t)}return c}function di(t,e,i,s=!1){if(e<=262144)return function(t,e,i,s){let n=new r.a(0);for(let t=0;t<e;t++)n.add(t);s||r.B.sortEx(n,0,e,{userSort(e,i,s){s.sort(e,i,(e,i)=>t[e].compareX(t[i]))},getValue:e=>t[e].x});let o=0;t:for(let s=0;s<e;++s){let e=n.read(s);for(;o>=2;){let r=i[o-2],a=i[o-1];if(t[a].equals(t[e])){n.write(s,-1);continue t}if(!(fi(t[r],t[a],t[e])>=0)){a===n.read(s-1)&&n.write(s-1,-1);break}o--}i[o++]=e,2===o&&t[e].equals(t[i[0]])&&(n.write(1,-1),o--)}let a=o+1;t:for(let s=e-2;s>=0;--s){let e=n.read(s);if(!(e<0)){for(;o>=a;){let s=i[o-2],r=i[o-1];if(t[r].equals(t[e]))continue t;if(!(yi(t[s],t[r],t[e])>=0))break;o--}if(0!==s){let s=i[o-1];i[o++]=e,t[e].equals(t[s])&&o--}}}return o>1&&t[i[0]].equals(t[i[o-1]])&&o--,o}(t,e,i,s);let n=new pi({points:t,n:e}),o=1,a=t[0];for(;o<e&&t[o].equals(a);)o++;if(n.m_treeHull.addElement(0),o<e){n.m_treeHull.addBiggestElement(o);for(let i=o+1;i<e;i++){let e=t[i],s=n.treeHull(e);-1!==s&&n.m_treeHull.setElement(s,i)}}let l=0;for(let t=n.m_treeHull.getFirst();-1!==t;t=n.m_treeHull.getNext(t))i[l++]=n.m_treeHull.getElement(t);return l}function gi(t,e,i){if((e<0||e>=t.getPathCount())&&(0,s.b)("path index"),t.hasNonLinearSegmentsPath(e))return!1;let r=t.getImpl(),o=r.getPathStart(e),a=r.getPathEnd(e),l=!r.isClosedPath(e)&&r.isClosedPathInXYPlane(e),h=r.getAttributeStreamRef(0),m=2*o,u=2*a;if(l&&(u-=2),u-m<6)return!0;let d=h.readPoint2D(m),g=h.readPoint2D(m+2),c=h.readPoint2D(m+4);if(!Pi(n.P.orientationRobust(g,c,d)))return!1;let _=g.clone(),p=new n.P;for(let t=m+6;t<u;t+=2)if(p.assign(g),g.assign(c),h.queryPoint2D(t,c),!Pi(n.P.orientationRobust(g,c,d))||!Pi(n.P.orientationRobust(_,c,d))||!Pi(n.P.orientationRobust(g,c,p)))return!1;return!0}function ci(t,e,i,r,o){if(function(t,e,i){t.setNAN(),e.setCoords(1,0),i.setCoords(0,0)}(i,r,o),t.isEmpty())return;if(t.getGeometryType()===s.G.enumPoint)return void i.assign(t.getXY());let a=t,l=a.getPointCount();if(0!==l){if(1===l)return void i.assign(a.getXY(0));!function(t,e,i,s,r,o){if(2===e){let e=t.getXY(0),i=t.getXY(1);s.assign(e.add(i).mul(.5));let n=i.sub(e);r=Ci(n),o.setCoords(.5*n.length(),0)}else{let a=Number.MAX_VALUE,l=[0,1,0,0],h=new n.am(4,2);for(h.set(0,0,0),h.set(0,1,1),h.set(1,0,1),h.set(1,1,2);l[0]<e;++l[0],bi(h,0,e)){l[1]===l[0]&&(++l[1],bi(h,1,e));for(let i=1;;++i){for(;;){let s=Ei(t.getXY(h.get(0,0)),t.getXY(h.get(0,1)),t.getXY(h.get(i,0)),t.getXY(h.get(i,1)),2^i);if(s>0||(++l[i],bi(h,i,e),0===s))break}if(3===i)break;l[i+1]<l[i]&&(l[i+1]=l[i],h.set(i+1,0,h.get(i,0)),h.set(i+1,1,h.get(i,1)))}let m,u,d=t.getXY(h.get(0,0)).add(t.getXY(h.get(2,0))).mul(.5),g=Ci(t.getXY(h.get(0,1)).sub(t.getXY(h.get(0,0)))),c=new n.P;if(c.x=Math.max(0,g.dotProduct(t.getXY(h.get(1,0)).sub(t.getXY(h.get(3,0))))),c.y=Math.max(0,g.crossProduct(t.getXY(h.get(0,0)).sub(t.getXY(h.get(2,0))))),i?(m=c.x*c.y,u=m<a):(m=c.y,u=m<a),u){a=m;let e=t.getXY(h.get(1,0)),i=t.getXY(h.get(3,0)),n=e.add(i).mul(.5).sub(d);s.assign(d.add(g.mul(g.dotProduct(n)))),r.assign(g),o.assign(c)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,n.s)(o.x,o.x=o.y),r.leftPerpendicularThis())}r.y<0?r.negateThis():0===r.y&&(r.x=1)}(a,l,e,i,r,o)}}class _i{m_convexHull;m_handleP=-1;m_handleQ=-1;m_currentSupport=-1;m_area=0;m_bDone=!0;m_function;constructor(t){(0,s.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,s.g)(0),!1}get_vertex_handle_p(){return(0,s.g)(0),0}get_vertex_handle_q(){return(0,s.g)(0),0}get_current_support(){return(0,s.g)(0),0}getNext(t){return(0,s.g)(0),0}getPrev(t){return(0,s.g)(0),0}intialize_(){return(0,s.g)(0),!1}increment_(){return(0,s.g)(0),!1}increment_q_(){return(0,s.g)(0),!1}increment_p_(){return(0,s.g)(0),!1}parallel_edge_with_q_support_(){return(0,s.g)(0),!1}parallel_edge_with_p_support_(){return(0,s.g)(0),!1}done_(){return(0,s.g)(0),!1}}class pi{m_treeHull=new r.T;m_shape=null;m_stream=null;m_points=null;m_geometryHandle=-1;m_pathHandle=-1;m_getXY=this.nullGetXY;m_deleteNode=this.nullDeleteNode;nullGetXY(t){return(0,s.d)("m_getXY is null"),{}}nullDeleteNode(t){(0,s.d)("m_deleteNode is null")}constructor(t){return 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=-1,void(this.m_pathHandle=-1)):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=-1,void(this.m_pathHandle=-1)):void(0,s.q)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new mi,this.m_geometryHandle=this.m_shape.createGeometry(s.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,-1),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(0,s.g)(0),new n.P}deleteNodeShape(t){let 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){(0,s.g)(0)}addGeometry(t){if(t.isEmpty())return;let e=t.getGeometryType();if(e===s.G.enumGeometryCollection){let e=t;for(let t=0,i=e.getGeometryCount();t<i;t++)this.addGeometry(e.getGeometry(t))}else(0,s.i)(e)?this.addMultiVertexGeometry(t):(0,s.h)(e)?this.addSegment(t,!1):e===s.G.enumEnvelope?this.addEnvelope(t):e===s.G.enumPoint?this.addPoint(t):(0,s.b)("Convex_hull: geometry not supported")}getBoundingGeometry(){let t=new r.P,e=this.m_treeHull.getFirst(),i=new ni({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return i;i.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),i.startPathPoint(t);for(let s=this.m_treeHull.getNext(e);-1!==s;s=this.m_treeHull.getNext(s))this.m_shape.queryPoint(this.m_treeHull.getElement(s),t),i.lineToPoint(t);return i}getAntipodalPairsIterator(){return(0,s.g)(0),new _i(this)}getXY(t){return(0,s.g)(0),new n.P}getXYWithIndex(t){return(0,s.g)(0),new n.P}getFirst(){return(0,s.g)(0),0}getLast(){return(0,s.g)(0),0}getNext(t){return(0,s.g)(0),0}getPrev(t){return(0,s.g)(0),0}getVertexIndex(t){return(0,s.g)(0),0}getPointCount(){return(0,s.g)(0),0}addMultiVertexGeometry(t){let e=new r.P,i=t.getImpl(),o=new n.P;for(let s=0;s<t.getPointCount();s++){i.queryXY(s,o);let r=this.addPoint2D(o);if(-1!==r){t.getPointByVal(s,e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,i)}}if((0,s.j)(t.getGeometryType())){let e=t;if(e.hasNonLinearSegments()){let t=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){let e=t.nextCurve();null!==e&&this.addSegment(e,!0)}}}}addEnvelope(t){let e=new r.P;for(let i=0;i<4;i++){let s=new n.P;t.queryCorner(i,s);let r=this.addPoint2D(s);if(-1!==r){t.queryCornerByVal(i,e);let s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}}static querySegmentControlPoints(t,e,i){let o=t.getGeometryType();if((0,s.g)(o!==s.G.enumLine),o===s.G.enumEllipticArc){let i=t,s=60*Math.PI/180,o=Math.abs(i.getSweepAngle());if(o>s){let t=Math.min(6,Math.ceil(o/s)),a=1/t,l=new Xn;i.queryStart(e[0]);let h=1;for(let s=0;s<t;s++){i.queryCut(s*a,(s+1)*a,l);let o=(0,n.d)(n.P,3);dn(l.get(),o);let m=n.P.calculateLength(o,3),u=n.P.calculateLength(o,2),d=m>0?u/m:.5;s<t-1?l.get().queryEnd(e[h+1]):i.queryEnd(e[h+1]),r.P.lerp(e[h-1],e[h+1],d,e[h]),e[h].setXY(o[1]),h+=2}return h}{let i=(0,n.d)(n.P,3);dn(t,i);let s=n.P.calculateLength(i,3);t.queryStart(e[0]),t.queryEnd(e[2]);let o=n.P.calculateLength(i,2),a=s>0?o/s:.5;return r.P.lerp(e[0],e[2],a,e[1]),e[1].setXY(i[1]),3}}if(o===s.G.enumBezier){let i=t,s=(0,n.d)(n.P,4);i.queryControlPoints(s);let o=n.P.calculateLength(s,4),a=n.P.calculateLength(s,2),l=n.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[3]);let h=o>0?a/o:.5;r.P.lerp(e[0],e[3],h,e[1]),e[1].setXY(s[1]);let m=o>0?l/o:.5;return r.P.lerp(e[0],e[3],m,e[2]),e[2].setXY(s[2]),4}if(o===s.G.enumBezier2){let i=t,s=(0,n.d)(n.P,3);i.queryControlPoints(s);let o=n.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[2]);let a=n.P.calculateLength(s,2),l=o>0?a/o:.5;return r.P.lerp(e[0],e[2],l,e[1]),e[1].setXY(s[1]),3}if(o===s.G.enumRationalBezier2){let i=t,s=(0,n.d)(n.P,3);i.queryControlPoints(s);let o=n.P.calculateLength(s,3);t.queryStart(e[0]),t.queryEnd(e[2]);let a=n.P.calculateLength(s,2),l=o>0?a/o:.5;return r.P.lerp(e[0],e[2],l,e[1]),e[1].setXY(s[1]),3}(0,s.b)("Convex_hull: segment type not supported")}addSegment(t,e){if(!e){let e=new r.P,i=t.getStartXY(),s=this.addPoint2D(i);if(-1!==s){t.queryStart(e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(s,i)}let n=t.getEndXY(),o=this.addPoint2D(n);if(-1!==o){t.queryEnd(e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(o,i)}}if(t.isCurve()){let e=(0,n.d)(r.P,13),i=pi.querySegmentControlPoints(t,e,e.length);for(let t=1,s=i-1;t<s;++t){let i=e[t].getXY(),s=this.addPoint2D(i);if(-1!==s){let i=this.m_shape.addPoint(this.m_pathHandle,e[t]);this.m_treeHull.setElement(s,i)}}}}addPoint(t){let e=t.getXY(),i=this.addPoint2D(e);if(-1!==i){let e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(i,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()){let i=this.m_treeHull.getElement(this.m_treeHull.getFirst()),s=this.m_shape.getXY(i);return t.equals(s)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{let i=this.m_treeHull.getFirst(),s=this.m_treeHull.getLast(),r=this.m_treeHull.getElement(i),o=this.m_treeHull.getElement(s),a=this.m_getXY(r),l=this.m_getXY(o),h=n.P.orientationRobust(l,t,a);if(Pi(h)){e=this.m_treeHull.addBiggestElement(-1);let r=this.treeHullWalkBackward(t,s,i);r!==i&&this.treeHullWalkForward(t,i,this.m_treeHull.getPrev(r));break}if(xi(h)){let r=this.m_treeHull.getRoot(),o=this.m_treeHull.getFirst(),l=this.m_treeHull.getLast(),h=-1,m=-1,u=-1;for(;o!==this.m_treeHull.getPrev(l);){m=this.m_treeHull.getElement(r);let e=this.m_getXY(m);xi(n.P.orientationRobust(e,t,a))?(l=r,r=this.m_treeHull.getLeft(r)):(o=r,r=this.m_treeHull.getRight(r))}r=l,h=o,m=this.m_treeHull.getElement(r),u=this.m_treeHull.getElement(h);let d=this.m_getXY(m),g=this.m_getXY(u);if(h!==i&&!Pi(n.P.orientationRobust(g,t,d)))break;e=this.m_treeHull.addElementAtPosition(h,r,-2,!0,!1),this.treeHullWalkForward(t,r,s),this.treeHullWalkBackward(t,h,i);break}{let r=vi(t,l,a);if(-1===r){let r=this.m_treeHull.getPrev(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,r,i)}else if(1===r){let r=this.m_treeHull.getNext(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addElementAtPosition(-1,r,-3,!0,!1),this.treeHullWalkForward(t,r,s)}break}}while(0);return e}treeHullWalkForward(t,e,i){if(e===i)return i;let s=e,r=this.m_treeHull.getElement(s),o=this.m_treeHull.getNext(s),a=this.m_getXY(r);for(;s!==i&&this.m_treeHull.size()>2;){let e=this.m_treeHull.getElement(o),i=this.m_getXY(e);if(Pi(n.P.orientationRobust(i,t,a)))break;let l=s;s=o,r=e,a.assign(i),o=this.m_treeHull.getNext(s),this.m_deleteNode(l)}return s}treeHullWalkBackward(t,e,i){if(e===i)return i;let s=e,r=this.m_treeHull.getElement(s),o=this.m_treeHull.getPrev(s),a=this.m_getXY(r);for(;s!==i&&this.m_treeHull.size()>2;){let e=this.m_treeHull.getElement(o),i=this.m_getXY(e);if(Pi(n.P.orientationRobust(a,t,i)))break;let l=s;s=o,r=e,a.assign(i),o=this.m_treeHull.getPrev(s),this.m_deleteNode(l)}return s}}function fi(t,e,i){let s=e.sub(t),r=i.sub(e);if(0===s.x)return r.x>0?-1:0;if(0===s.y)return r.y>0?1:r.y<0?-1:0;let o=s.crossProduct(r),a=4*2**-52*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,i)}function yi(t,e,i){let s=e.sub(t),r=i.sub(e);if(0===s.x)return r.x<0?-1:0;if(0===s.y)return r.y>0?-1:+(r.y<0);let o=s.crossProduct(r),a=4*2**-52*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,i)}function Pi(t){return t<0}function xi(t){return t>0}function vi(t,e,i){let s=-1;s=e.y===i.y?0:e.x===i.x?1:Math.abs(e.x-i.x)>=Math.abs(e.y-i.y)?0:1;let r=-1;return r=e[s]<i[s]?t[s]<e[s]?-1:+(i[s]<t[s]):e[s]<t[s]?-1:+(t[s]<i[s]),r}function Ci(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function bi(t,e,i){t.inc(e,0)===i&&t.set(e,0,0),t.inc(e,1)===i&&t.set(e,1,0)}function Ei(t,e,i,r,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,s.b)("")}return n.P.orientationRobustEx(t,e,i,r)}class Di{specialPoints;length;constructor(){this.length=NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function wi(t){return function(t){return 256*(0,n.I)()*t}(t.calculateUpperLength2D())}function Si(t,e,i=!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]),i?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Ai(t,e,i){let s=(0,n.d)(n.P,4);t.queryControlPoints(s),Ii(s,e,i)}function Ti(t,e,i){let s=(0,n.d)(n.P,4);t.queryControlPoints(s),Mi(s,e,i)}function Ii(t,e,i){let s=t[1].x;s-=t[0].x,s*=3;let r=t[2].x;r-=t[1].x,r*=3;let n=t[3].x;n-=t[0].x,n-=r,r-=s,e[3].setWithEps(n),e[2].setWithEps(r),e[1].setWithEps(s),i?e[0].set(0):e[0].set(t[0].x)}function Mi(t,e,i){let s=t[1].y;s-=t[0].y,s*=3;let r=t[2].y;r-=t[1].y,r*=3;let n=t[3].y;n-=t[0].y,n-=r,r-=s,e[3].setWithEps(n),e[2].setWithEps(r),e[1].setWithEps(s),i?e[0].set(0):e[0].set(t[0].y)}function qi(t,e,i=!1){let s=(0,n.d)(_,4);s[0].assignPoint2D(t[0]),s[1].assignPoint2D(t[1]),s[2].assignPoint2D(t[2]),s[3].assignPoint2D(t[3]),e[1].setCoords(s[1].x.sub(s[0].x),s[1].y.sub(s[0].y)),e[1].mulThis(n.M.constructInt32(3)),e[2].setCoords(s[2].x.sub(s[1].x),s[2].y.sub(s[1].y)),e[2].mulThis(n.M.constructInt32(3)),e[3]=s[3].sub(s[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),i?e[0].setCoords(n.aD,n.aD):e[0]=s[0].clone()}function Ni(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+Ni(t,1,!1)}if(t.isDegenerate(0))return 0;let s=1===e,r=Ri(t);if(s&&!Number.isNaN(r.length)&&!Number.isNaN(r.length))return r.length;let n=wi(t),o=n/t.calculateUpperLength2D(),a=0,l=0;for(let i=1,s=r.specialPointsCount();i<s;i++){let s=r.specialPoints[i];if(a+=fs(t,l,Math.min(e,s),o,n),e<=s)break;l=s}return s&&(r.length=a),a}function Ri(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new Di,i=(0,n.d)(n.Z,8),s=(0,n.d)(n.P,4);t.queryControlPoints(s);let r=ds(s,i);e.specialPoints=[];for(let t=0;t<r;t++)e.specialPoints.push(i[t].value());return Xi(t,e),e}function Yi(t){let e=null;return e=t.m_cachedValues,e}function Xi(t,e){t.m_cachedValues=e}function Fi(t){t.m_cachedValues=null}function Li(t,e,i,s){let r=(0,n.d)(n.P,4);t.queryControlPoints(r);let o=(0,n.c)(18,NaN),a=It(new ls(r,e,NaN),n.E.construct(i,s),18,o),l=new n.P;t.queryCoord2D(i,l);let h=i,m=n.P.distance(l,e),u=new n.P;t.queryCoord2D(s,u);let d=n.P.distance(u,e);d<m&&(m=d,h=s,l.assign(u));for(let i=0;i<a;i++){t.queryCoord2D(o[i],u);let s=n.P.distance(u,e);s<m&&(m=s,h=o[i],l.assign(u))}return function(t,e,i,s,r){return{tmin:t,tmax:e,t:i,d:s,pt:r.clone()}}(i,s,h,m,l)}function zi(t,e){let i=(0,n.d)(n.Z,4);Ai(t,i,!0);let r=(0,n.d)(n.Z,4);Ti(t,r,!0);let o=i[3].clone(),a=i[2].clone(),l=i[1].clone(),h=r[3].clone(),m=r[2].clone(),u=r[1].clone(),d=a.mulE(l).addE(m.mulE(u)).mul(4),g=a.mulE(a).mul(8).addE(o.mulE(l).mul(12)).addE(m.mulE(m).mul(8).addE(h.mulE(u).mul(12))),c=o.mulE(a).addE(h.mulE(m)).mul(36),_=o.mulE(o).addE(h.mulE(h)).mul(36),p=(0,n.d)(n.Z,3),f=zt(_,c,g,d,new n.E(0,1),!1,p);if((0,s.g)(f<=3),f>0){let i=Bi(t,1,0).sqrLength(),s=Bi(t,1,1).sqrLength(),r=i;e.set(0),r<s&&(r=s,e.set(1));for(let i=0;i<f;i++){let s=Bi(t,1,p[i].value()).sqrLength();s<r&&(r=s,e=p[i])}}}function Vi(t,e,i){let s=new n.P;return function(t,e,i,s){if(1===e){let e=1-i,r=e*e,n=i*i,o=t[1].sub(t[0]),a=t[2].sub(t[1]),l=t[3].sub(t[2]),h=o.mul(r).add(a.mul(2*e*i)).add(l.mul(n));s.assign(h.mul(3))}else if(2===e){let e=1-i,r=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=r.mul(e).add(n.mul(i));s.assign(o.mul(6))}else if(3===e){let e=t[2].sub(t[1]),i=t[3].sub(e.mul(3)).sub(t[0]);s.assign(i.mul(6))}else s.setCoords(0,0)}(t,e,i,s),s}function Bi(t,e,i){let s=(0,n.d)(n.P,4);return t.queryControlPoints(s),Vi(s,e,i)}function ki(t){let e=t.m_cp[0].sub(t.getStartXY()),i=t.m_cp[1].sub(t.m_cp[0]),s=t.getEndXY().sub(t.getStartXY());return e.mulThis(3),i.mulThis(3),s.subThis(i),i.subThis(e),(3*s.x*(2*i.y+5*e.y)-3*s.y*(2*i.x+5*e.x)+10*(i.x*e.y-i.y*e.x))/60}function Gi(t){let e=(0,n.d)(n.P,4);t.queryControlPoints(e);let i=Zi(e);return i&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),i}function Zi(t){return f(t)}function Hi(t,e,i){let s=new n.P,r=new n.P,o=new n.P,a=new n.P,l=new n.P;e<=.5?((0,n.as)(2,t[0],t[1],e,s),(0,n.as)(2,t[1],t[2],e,r),(0,n.as)(2,t[2],t[3],e,o),(0,n.as)(2,s,r,e,a),(0,n.as)(2,r,o,e,l),(0,n.as)(2,a,l,e,i)):((0,n.at)(2,t[0],t[1],e,s),(0,n.at)(2,t[1],t[2],e,r),(0,n.at)(2,t[2],t[3],e,o),(0,n.at)(2,s,r,e,a),(0,n.at)(2,r,o,e,l),(0,n.at)(2,a,l,e,i))}function Wi(t,e,i,r){(0,s.g)(e>=0&&e<=1);let o=new n.P,a=new n.P,l=new n.P,h=new n.P,m=new n.P,u=new n.P;e<=.5?((0,n.as)(2,t[0],t[1],e,o),(0,n.as)(2,t[1],t[2],e,a),(0,n.as)(2,t[2],t[3],e,l),(0,n.as)(2,o,a,e,h),(0,n.as)(2,a,l,e,m),(0,n.as)(2,h,m,e,u)):((0,n.at)(2,t[0],t[1],e,o),(0,n.at)(2,t[1],t[2],e,a),(0,n.at)(2,t[2],t[3],e,l),(0,n.at)(2,o,a,e,h),(0,n.at)(2,a,l,e,m),(0,n.at)(2,h,m,e,u));let d=t[3].clone();i&&(i[0].assign(t[0]),i[1].assign(o),i[2].assign(h),i[3].assign(u)),r&&(r[0].assign(u),r[1].assign(m),r[2].assign(l),r[3].assign(d))}function ji(t,e,i,r){if((0,s.g)(e>=0&&i<=1&&e<=i),e===i){let i=new n.P;return Ui(t,e,i),r[0].assign(i),r[1].assign(i),r[2].assign(i),void r[3].assign(i)}if(0===e&&1===i){for(let e=0;e<4;++e)r[e].assign(t[e]);return}let o=(0,n.d)(n.P,4);Wi(t,i,o,null),Wi(o,i>0?e/i:0,null,o),Ui(t,e,o[0]),Ui(t,i,o[3]),r[0].setCoordsPoint2D(o[0]),r[1].setCoordsPoint2D(o[1]),r[2].setCoordsPoint2D(o[2]),r[3].setCoordsPoint2D(o[3])}function Ui(t,e,i,s){if(s){if(e<0)return void J(new Yn({start:t[0],end:t[0].add(Oi(t,0).getUnitVector())}),e,i);if(e>1)return void J(new Yn({start:t[3],end:t[3].add(Oi(t,1).getUnitVector())}),e-1,i)}if(e<=.5){let s=new n.P;(0,n.as)(2,t[0],t[1],e,s);let r=new n.P;(0,n.as)(2,t[1],t[2],e,r);let o=new n.P;(0,n.as)(2,t[2],t[3],e,o);let a=new n.P;(0,n.as)(2,s,r,e,a);let l=new n.P;(0,n.as)(2,r,o,e,l),(0,n.as)(2,a,l,e,i)}else{let s=new n.P;(0,n.at)(2,t[0],t[1],e,s);let r=new n.P;(0,n.at)(2,t[1],t[2],e,r);let o=new n.P;(0,n.at)(2,t[2],t[3],e,o);let a=new n.P;(0,n.at)(2,s,r,e,a);let l=new n.P;(0,n.at)(2,r,o,e,l),(0,n.at)(2,a,l,e,i)}}function Oi(t,e){let i=(0,n.a)(e,0,1),s=Vi(t,1,i);return s.isZero()&&(s=Vi(t,2,i),s.isZero()?s=Vi(t,3,i):1===i&&s.negateThis()),s}function Qi(t,e,i){let s=(0,n.d)(n.P,4);t.queryControlPoints(s),function(t,e,i){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),i.setE(function(t,e,i){let s=[g.constructPoint2D(t[0]),g.constructPoint2D(t[1]),g.constructPoint2D(t[2]),g.constructPoint2D(t[3])],r=new g;return function(t,e,i,s){{let e=n.a7.subE(i),r=e.sqr(),o=i.sqr(),a=t[1].subE(t[0]).mulE(r).addE(t[2].subE(t[1]).mulE(new n.Z(2).mulE(e).mulE(i))).addE(t[3].subE(t[2]).mulE(o));s.setE(a.mulE(new n.Z(3)))}}(s,0,i,r),r}(t,0,e))}(s,e,i)}function Ki(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===es(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function Ji(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===is(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function $i(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===rs(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function ts(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===ns(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function es(t,e,i,s,r,o,a,l,h,m){if(null!==r&&(r.length=0),null!=o&&(o.length=0),null!==s&&(s.length=0),i.isDegenerate(0)){let t=[0,0,0],l=e.intersectPoint(i.getStartXY(),t,a);if(l>0){if(null!==r)for(let e=0;e<l;e++)r.push(t[e]);if(null!==o)for(let t=0;t<l;t++)o.push(0);if(null!=s)for(let i=0;i<l;i++){let r=new n.P;e.queryCoord2D(t[i],r),s.push(r)}}return l}let u=Y(e,i);if(X(e,i,a=Math.max(a,u)))return 0;let d=(0,n.d)(n.P,4);Si(e,d);let g=i.getEndXY();g.subThis(i.getStartXY());let c=g.clone();c.leftPerpendicularThis();let _=3*d[3].dotProduct(c),p=2*d[2].dotProduct(c),f=d[1].dotProduct(c),y=(0,n.c)(15,NaN),P=(0,n.c)(15,NaN),x=Mt(_,p,f,n.E.unit(),!1,y);x<0&&(y[0]=0,y[1]=1,x=2);let v,C=0;for(let t=0,s=C;t<x;++t){let r=e.getCoord2D(y[t+s]);P[C]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(P[C]))<=a&&(y[C]=y[t+s],C++)}if(d[0].subThis(i.getStartXY()),Math.abs(g.x)>=Math.abs(g.y)){let t=g.y/g.x;_=d[3].y-d[3].x*t,p=d[2].y-d[2].x*t,f=d[1].y-d[1].x*t,v=d[0].y-d[0].x*t}else{let t=g.x/g.y;_=d[3].x-d[3].y*t,p=d[2].x-d[2].y*t,f=d[1].x-d[1].y*t,v=d[0].x-d[0].y*t}let b=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),E=[0,0,0];x=qt(_,p,f,v,n.E.unit(),b,E);for(let t=0,s=C;t<x;++t){y[t+s]=E[t];let r=e.getCoord2D(y[t+s]);P[C]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(P[C]))<=a&&(y[C]=y[t+s],C++)}x=e.intersectPoint(i.getStartXY(),E,a);for(let t=0;t<x;t++)y[C]=E[t],P[C++]=0;x=e.intersectPoint(i.getEndXY(),E,a);for(let t=0;t<x;t++)y[C]=E[t],P[C++]=1;return 0!==i.intersectPoint(e.getStartXY(),E,a)&&(P[C]=E[0],y[C++]=0),0!==i.intersectPoint(e.getEndXY(),E,a)&&(P[C]=E[0],y[C++]=1),0===C?0:Mn(t,e,i,y,P,C,s,r,o,a,l,0,m)}function is(t,e,i,s,r,o,l,h,m,u){if(Kr(i))return es(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,0,u);let d=Y(e,i);if(X(e,i,l=Math.max(l,d)))return 0;let g=[],c=[],p=[],f=(0,n.d)(n.P,4);{e.queryControlPoints(f);let t=(0,n.d)(n.P,4),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(f,4,t);let o=(0,n.d)(_,4);qi(t,o);let m=[o[0].x,o[1].x,o[2].x,o[3].x],u=[o[0].y,o[1].y,o[2].y,o[3].y],d=(0,n.d)(n.M,3);d[0].setDouble(i.getSemiMinorAxis()),d[0].sqrThis(),d[1].setDouble(i.getSemiMajorAxis()),d[1].sqrThis(),d[2].setThis(d[0]),d[2].mulThis(d[1]),d[2].negateThis();let y=ee(m,3,u,3,null,0,d,0,n.E.unit(),n.E.unit(),c,h);if(y>0){let t=0;for(let s=0;s<y;s++){let r=new n.P;e.queryCoord2D(c[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(g.push(r.clone()),c[t]=c[s],p.push(o),t++)}c.length=t,g.length=t}}let y=[0,1];for(let t=0;t<2;t++){let e=0===t?i.getStartXY():i.getEndXY(),s=[0];hs(f,e,n.E.unit(),!1,-1,1,s);let r=new n.P;Ui(f,s[0],r),n.P.distance(e,r)<=l&&(c.push(s[0]),p.push(y[t]),g.push(r.clone()))}for(let t=0;t<2;t++){let e=[0,3];{let s=i.getClosestCoordinate(f[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(f[e[t]],r)<=l&&(c.push(y[t]),p.push(s),g.push(r.clone()))}}return Mn(t,e,i,c,p,c.length,s,r,o,l,h,0,u)}function ss(t,e,i,r,o,a,l,m,u,d){let g=(0,n.d)(n.P,4);e.queryControlPoints(g);let c=(0,n.d)(n.P,4);if(i.queryControlPoints(c),F(g,c,4)<0)return ss(t,i,e,r,a,o,l,m,u,!d);let p=Y(e,i);if(X(e,i,l=Math.max(l,p)))return 0;if(function(t,e,i,s,r,o,a,l,h){let m=(0,n.d)(n.P,4);t.queryControlPoints(m);let u=(0,n.d)(n.P,4);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2])&&m[3].equals(u[3]))return i&&(i.length=0,i.push(m[0]),i.push(m[3])),s&&(s.length=0,s.push(0),s.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!m[0].equals(u[3]))return!1}return!!(m[0].equals(u[3])&&m[1].equals(u[2])&&m[2].equals(u[1])&&m[3].equals(u[0]))&&(s&&(s.length=0,s.push(0),s.push(1),h&&(s[1]=(0,n.s)(s[0],s[0]=s[1]))),r&&(r.length=0,r.push(1),r.push(0),h&&(r[1]=(0,n.s)(r[0],r[0]=r[1]))),i&&(i.length=0,i.push(m[0]),i.push(m[3]),h&&(i[1]=(0,n.s)(i[0],i[0]=i[1]))),!0)}(e,i,r,o,a,0,0,0,d))return 2;let f=new n.E(0,1),y=new n.E(0,1);{let t=new h;as(g,new n.E(0,1),t);let e=new h;as(c,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(cs(g,t,f),f.isEmpty()||(cs(c,t,y),y.isEmpty()))return 0;ji(g,f.vmin,f.vmax,g),ji(c,y.vmin,y.vmax,c)}}let P=Nn(g,3,c,3,l);if(0===P)return 0;let x=[],v=[],C=[],b=!1;if(-1===P){let t=(0,n.d)(_,4);qi(g,t);let e=[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],s=(0,n.d)(_,4);qi(c,s);let r=[],o=[],a=te(e,3,i,3,null,0,[s[0].x,s[1].x,s[2].x,s[3].x],3,[s[0].y,s[1].y,s[2].y,s[3].y],3,null,0,0,n.E.unit(),n.E.unit(),r,o,u);if(a>0)for(let t=0;t<a;t++){let e=new n.P;Ui(c,o[t],e);let i=new n.P;Ui(g,r[t],i),n.P.distance(i,e)<=l&&(x.push(i.clone()),C.push(o[t]),v.push(r[t]))}else-1===a&&(b=!0)}for(let t=0;t<2;t++){let e=0===t?g:c,i=0===t?c:g;for(let s=0;s<2;s++){let r=0===s?0:3,o=[0];hs(i,e[r],n.E.unit(),!1,-1,1,o);let a=new n.P;Ui(i,o[0],a),n.P.distance(e[r],a)<=l&&(0===t?(v.push(0===r?0:1),C.push(o[0])):(C.push(0===r?0:1),v.push(o[0])),x.push(a.clone()))}}if(0===v.length&&b){let t=e.calculateUpperLength2D()>i.calculateUpperLength2D();{let r=[0,0];if(2===us(t?e:i,r,!0)&&((0,s.g)(n.E.unit().containsCoordinate(r[0])),!n.E.unit().containsCoordinate(r[1]))){let e=new n.P;Ui(t?g:c,r[0],e);let i=[0,0];1===hs(t?c:g,e,n.E.unit(),!1,-1,2,i)&&(x.push(e.clone()),v.push(t?r[0]:i[0]),C.push(t?i[0]:r[0]))}}}if(0===v.length)return 0;if(!f.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=vs.recalculateParentT(f.vmin,f.vmax,v[t]);if(!y.equalsRange(0,1))for(let t=0;t<C.length;++t)C[t]=vs.recalculateParentT(y.vmin,y.vmax,C[t]);return Mn(t,e,i,v,C,v.length,r,o,a,l,m,0,d)}function rs(t,e,i,r,o,a,l,m,u,d){let g=Y(e,i);if(i.isDegenerateToLineHelper(g)){let s=new Yn({start:i.getStartXY(),end:i.getEndXY()}),n=es(t,e,s,r,o,a,l,m,0,d);if(a)for(let t=0;t<n;++t){let e=s.getCoord2D(a[t]);a[t]=i.getClosestCoordinate(e,!1)}return n}if(X(e,i,l=Math.max(l,g)))return 0;let c=(0,n.d)(n.P,4);e.queryControlPoints(c);let p=(0,n.d)(n.P,3);i.queryControlPoints(p);let f=new n.E(0,1),y=new n.E(0,1),P=[0,0,0];i.queryWeights(P);let x=[1,dr(P),1];{let t=new h;as(c,new n.E(0,1),t);let e=new h;Ws(p,x,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(cs(c,t,f),f.isEmpty()||(ur(p,x,t,y),y.isEmpty()))return 0;ji(c,f.vmin,f.vmax,c),Ks(p,x,y.vmin,y.vmax,p,x)}}let v=Nn(c,3,p,2,l);if(0===v)return 0;let C=[],b=[],E=[];if(-1===v){let t=(0,n.d)(_,4);qi(c,t);let e=[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],s=(0,n.d)(n.M,3),r=(0,n.d)(n.M,3),o=(0,n.d)(n.M,3);or(p,x,s,r,o);let a=[],h=[],m=te(s,2,r,2,o,2,e,3,i,3,null,0,0,n.E.unit(),n.E.unit(),h,a,u);if(m>0)for(let t=0;t<m;t++){let e=new n.P;Ui(c,a[t],e);let i=new n.P;mr(p,x,h[t],i),n.P.distance(e,i)<=l&&(C.push(e.clone()),b.push(a[t]),E.push(h[t]))}}for(let t=0;t<2;t++){let e,i;0===t?(e=c,i=p):(i=c,e=p);for(let r=0;r<2;r++){let o=0===r?0:e.length-1,a=[0],h=new n.P;if(0===t){let t=Zs(i,x,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),mr(i,x,a[0],h)}else{let t=hs(i,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),Ui(i,a[0],h)}n.P.distance(e[o],h)<=l&&(0===t?(b.push(0===o?0:1),E.push(a[0])):(E.push(0===o?0:1),b.push(a[0])),C.push(h.clone()))}}if(0===b.length)return 0;if(!f.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=vs.recalculateParentT(f.vmin,f.vmax,b[t]);if(!y.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=Ut.recalculateParentT(y.vmin,y.vmax,E[t]);for(let t=0;t<E.length;++t)E[t]=gr(P,E[t]);return Mn(t,e,i,b,E,b.length,r,o,a,l,m,0,d)}function ns(t,e,i,r,o,a,l,h,m,u){let d=Y(e,i);if(X(e,i,l=Math.max(l,d)))return 0;let g=(0,n.d)(n.P,4);e.queryControlPoints(g);let c=(0,n.d)(n.P,3);i.queryControlPoints(c);let p=Nn(g,3,c,2,l);if(0===p)return 0;let f=[],y=[],P=[];if(-1===p){let t=(0,n.d)(_,4);qi(g,t);let s=[t[0].x,t[1].x,t[2].x,t[3].x],r=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,n.d)(_,3);Qe(c,o);let a=te([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,s,3,r,3,null,0,0,n.E.unit(),n.E.unit(),P,y,h);if(a>0){let t=0;for(let s=0;s<a;s++){let r=new n.P;e.queryCoord2D(y[s],r);let o=new n.P;i.queryCoord2D(P[s],o),n.P.distance(r,o)<=l&&(f.push(r.clone()),y[t]=y[s],P[t]=P[s],t++)}y.length=t,f.length=t}}for(let t=0;t<2;t++){let e,i;0===t?(e=g,i=c):(i=g,e=c);for(let r=0;r<2;r++){let o=0===r?0:e.length-1,a=[0],h=new n.P;if(0===t)Fe(i,e[o],a),Ke(i,a[0],h);else{let t=hs(i,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),Ui(i,a[0],h)}n.P.distance(e[o],h)<=l&&(0===t?(y.push(0===o?0:1),P.push(a[0])):(P.push(0===o?0:1),y.push(a[0])),f.push(h.clone()))}}return Mn(t,e,i,y,P,y.length,r,o,a,l,h,0,u)}function os(t,e,i){let s=(0,n.d)(n.P,4);t.queryControlPoints(s),as(s,e,i)}function as(t,e,i){if(e.equalsRange(0,1))return void i.setFromPoints(t,4);let s=(0,n.d)(n.P,4);ji(t,e.vmin,e.vmax,s),i.setFromPoints(s,4)}let ls=class{controlPoints;point;maxDistance;dbgCounter=0;constructor(t,e,i){this.controlPoints=t,this.point=e.clone(),this.maxDistance=i}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{let t=new n.P;Ui(this.controlPoints,e,t);let i=Vi(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(i)}case 1:{let t=new n.P;Ui(this.controlPoints,e,t);let i=Vi(this.controlPoints,1,e),s=Vi(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(s)+i.dotProduct(i))}case 2:{let t=new n.P;Ui(this.controlPoints,e,t);let i=Vi(this.controlPoints,1,e),s=Vi(this.controlPoints,2,e),r=Vi(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(r)+3*i.dotProduct(s))}case 3:{let t=Vi(this.controlPoints,1,e),i=Vi(this.controlPoints,2,e),s=Vi(this.controlPoints,3,e);return 2*(4*t.dotProduct(s)+3*i.sqrLength())}case 4:{let t=Vi(this.controlPoints,2,e),i=Vi(this.controlPoints,3,e);return 10*t.dotProduct(i)*2}case 5:{let t=Vi(this.controlPoints,3,e);return 10*t.dotProduct(t)*2}default:return 0}}getError(t){return 0}isInterestingInterval(t,e){if(t>=0&&e<=1){let i=(0,n.d)(n.P,4);ji(this.controlPoints,t,e,i);let s=new h;if(s.setFromPoints(i,4),Math.sqrt(s.sqrMinDistance(this.point))>this.maxDistance)return!1}return!0}};function hs(t,e,i,o,a,l,h){(0,s.D)(n.E.unit().contains(i)&&l>0,"getClosestCoordinate"),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);let m=[],u=new n.P;Ui(t,i.vmin,u);let d=n.P.distance(u,e);if(d<=a&&m.push(new n.P(i.vmin,d)),i.vmin!==i.vmax&&(Ui(t,i.vmax,u),d=n.P.distance(u,e),d<=a&&m.push(new n.P(i.vmax,d))),i.width()>0){let s=(0,n.c)(18,NaN),r=It(new ls(t,e,a),i,18,s);for(let i=0;i<r;i++)Ui(t,s[i],u),d=n.P.distance(u,e),!(d>a)&&m.push(new n.P(s[i],d))}if(o){(0,s.g)(i.equals(n.E.unit()));{Ui(t,-1,u,!0);let i=new n.P;Ui(t,0,i);let s=new Yn({start:u,end:i}),r=s.getClosestCoordinate(e,!0);r<1&&(u.assign(s.getCoord2D(r)),d=n.P.distance(u,e),d<=a&&m.push(new n.P(r-1,d)))}{Ui(t,2,u,!0);let s=new n.P;Ui(t,i.vmax,s);let r=new Yn({start:s,end:u}),o=r.getClosestCoordinate(e,!0);o>0&&(u.assign(r.getCoord2D(o)),d=n.P.distance(u,e),d<=a&&m.push(new n.P(1+o,d)))}}if(!m.length)return 0;m.sort((t,e)=>t.compare(e));let g=0,c=m[0].x;if(h[g++]=c,g<l){let e=(0,r.a4)(t,4,!1).total(),i=m[0].y;for(let t=1,s=m.length;t<s;t++)if(m[t].y>i+e){m.length=t;break}m.sort((t,e)=>(0,n.X)(t.x,e.x)),g=0,h[g++]=m[0].x;for(let t=1,e=m.length;t<e;t++)m[t].x!==h[g-1]&&g<l&&(h[g++]=m[t].x)}return g}function ms(t,e,i,s,r,o,a){let l=(0,n.d)(n.P,4);return t.queryControlPoints(l),hs(l,e,i,s,r,o,a)}function us(t,e,i=!1){let s=(0,n.d)(n.P,4);t.queryControlPoints(s);let r=(0,n.d)(_,4);qi(s,r,!0);let o,a,l,h=r[3].x.isZero(),m=r[3].y.isZero();if(h||m)if(h&&!m){if(r[2].x.isZero())return 0;o=r[1].x.div(r[2].x).negate(),a=r[2].y.div(r[3].y),l=r[1].y.div(r[3].y)}else{if(h||!m)return 0;if(r[2].y.isZero())return 0;o=r[1].y.div(r[2].y).negate(),a=r[2].x.div(r[3].x),l=r[1].x.div(r[3].x)}else{r[2].x.divThis(r[3].x),r[1].x.divThis(r[3].x),r[2].y.divThis(r[3].y),r[1].y.divThis(r[3].y);let t=r[2].x.sub(r[2].y);if(t.isZero())return 0;o=r[1].x.sub(r[1].y).div(t).negate(),a=r[2].x.clone(),l=r[1].x.clone()}if(!i&&o.abs().value()>2)return 0;let u=[0,0],d=t.getStartXY().equals(t.getEndXY()),g=Mt(1,-o.toDouble(),o.add(a).mul(o).add(l).toDouble(),n.E.unit(),d,u);if(0===g)return 0;if(u[0]>=0&&u[0]<=1){let t=o.toDouble()-u[0];if(i||t>=0&&t<=1)return e[0]=u[0],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.s)(e[0],e[0]=e[1])),2}if(2===g&&u[1]>=0&&u[1]<=1){let t=o.toDouble()-u[1];if(i||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.s)(e[0],e[0]=e[1])),2}return 0}function ds(t,e){e[0].set(0);let i=1,r=(0,n.d)(n.Z,4);Ii(t,r,!0);let o=(0,n.d)(n.Z,4);Mi(t,o,!0);{let t=r[3].mul(3),s=r[2].mul(2),o=r[1].clone(),a=(0,n.d)(n.Z,2),l=Lt(t,s,o,new n.E(0,1),!1,a);l<0&&(l=0);for(let t=0;t<l;t++)(0,n.a9)(a[t].value(),0,1)||(e[i]=a[t],i++)}{let t=o[3].mul(3),s=o[2].mul(2),r=o[1].clone(),a=(0,n.d)(n.Z,2),l=Lt(t,s,r,new n.E(0,1),!1,a);l<0&&(l=0);for(let t=0;t<l;t++)(0,n.a9)(a[t].value(),0,1)||(e[i]=a[t],i++)}let a=function(t,e,i){let s=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),r=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),o=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),a=(0,n.d)(n.Z,2),l=Lt(o,r,s,new n.E(0,1),!1,a);l<0&&(l=0);let h=0;for(let t=0;t<l;t++)(0,n.a9)(a[t].value(),0,1)||(i[h].setE(a[t]),h++);return h}(r,o,e.slice(i));if(i+=a,e[i].set(1),i++,i>2){(0,n.ab)(e,0,i,(t,e)=>{let i=t.value(),s=e.value();return i<s?-1:+(i>s)});let s=0,r=e[0].clone(),o=0,a=function(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}(t)*(0,n.I)(),l=new n.P;Hi(t,e[0].value(),l);for(let h=1;h<i;h++){let i=new n.P;if(Hi(t,e[h].value(),i),e[h].eq(r)||i.isEqualPoint2D(l,a)){if(0!==s){if(0===e[h].eps())r.setE(e[h]),o=0;else if(0!==o){let t=(0,n.e)(1/e[h].eps()),i=1/o,s=t+i;r.set((e[h].value()*t+r.value()*i)/s),o=1/s,r.setError(Math.sqrt(o))}e[s].setE(r),Hi(t,r.value(),l)}}else s++,e[s].setE(e[h]),r.setE(e[h]),Hi(t,r.value(),l),o=(0,n.e)(e[h].eps())}s++,i=s}return 1===i&&(i=2,e[1].set(1)),(0,s.g)(0===e[0].value()),(0,s.g)(1===e[i-1].value()),i}function gs(t,e,i,s){let r=(0,n.d)(n.P,i);for(let t=0;t<i;++t)r[t]=new n.P(t/(i-1),0);let o=(t,e,i,s)=>{let r=new n.Z(e.x).subE(new n.Z(t.x)).divE(new n.Z(e.y).subE(new n.Z(t.y))).mulE(new n.Z(i).subE(new n.Z(t.y))).addE(new n.Z(t.x));if(r.eps()>.1){let s=(e.x-t.x)/(e.y-t.y)*(i-t.y)+t.x;r.set(s,(0,n.I)())}if(r.lt(new n.Z(0))||r.gt(new n.Z(1)))return!1;let o=r.value()-r.eps();o=(0,n.a)(o,0,1);let a=r.value()+r.eps();return a=(0,n.a)(a,0,1),s.mergeCoordinate(o),s.mergeCoordinate(a),!0},a=[];{let e=(t,e)=>{a.length=i;let s=di(r,i,a,!0),l=new n.E;l.setEmpty();let h=i=>i.y<t?-1:+(i.y>e),m=r[a[0]],u=h(m);0===u&&l.mergeCoordinate(m.x);for(let i=1;i<=s;++i){let n=r[a[i%s]],d=h(n);0===d&&l.mergeCoordinate(n.x);let g=0;d!==u&&(g=d*u===0?1===d||1===u?2:1:3,1&g&&o(m,n,t,l),2&g&&o(m,n,e,l)),m=n,u=d}return l};for(let e=0;e<i;++e)r[e].y=t[e].x;let l=e(s.xmin,s.xmax);if(l.isEmpty())return new n.E(l);for(let e=0;e<i;++e)r[e].y=t[e].y;let h=e(s.ymin,s.ymax);return l.intersect(new n.E(h)),new n.E(l)}}function cs(t,e,i){i.setEmpty(),i.merge(function(t,e,i,s){let r=gs(t,0,4,s.getEnvelope2D());if(r.isEmpty())return new n.E(r);let o=(0,n.d)(n.P,4);for(let e=0;e<4;++e)s.xyRot(t[e],o[e]);let a=gs(o,0,4,s.getRotatedEnvelope2D());return r.intersect(new n.E(a)),new n.E(r)}(t,0,0,e))}class _s{b;len;constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ni(this.b,e,!1):0}getError(t){return 0}}function ps(t,e,i,r,o,a,l){for(;;){let h=n.P.distance(e[0],e[3]),m=n.P.distance(e[0],e[1])+n.P.distance(e[1],e[2])+n.P.distance(e[2],e[3]);if(m-h<=r+i*m)return t+(0,n.r)(h,m,.5);let u=t=>Vi(e,1,t).length();{(0,s.g)(l<12);let h=u(0),d=u(1);o[0]+=2,h>d&&(d=(0,n.s)(h,h=d),e[3]=(0,n.s)(e[0],e[0]=e[3]),e[2]=(0,n.s)(e[1],e[1]=e[2]));let g=h/(h+d),c=1,_=m;for(;g<1/32&&_>=32*(r+i*_);){c/=4;let t=u(c);o[0]++,g=h/(t+h);let i=new n.P;if(Ui(e,.5*c,i),_=n.P.distance(i,e[0]),_<=r){let t=new n.P;Ui(e,c,t),_+=n.P.distance(t,i)}}if(1!==c){let s=(0,n.d)(n.P,4);Wi(e,c,e,s),t=ps(t,s,i,r,o,0,l+1),a++,l++;continue}}o[0]+=8;let d=ri(8,u,0,1);o[0]+=16;let g=ri(16,u,0,1),c=Math.abs(d-g)>r+i*m;if(!c)return t+g;if(a<3){let s=(0,n.d)(n.P,4);Wi(e,.5,e,s),t=ps(t,s,i,r,o,a+1,l+1),a++,l++;continue}o[0]+=32;let _=ri(32,u,0,1);if(c=Math.abs(g-_)>r+i*m,!c)return t+_;o[0]+=64;let p=ri(64,u,0,1);if(c=Math.abs(_-p)>r+i*m,!c)return t+p;o[0]+=128;let f=ri(128,u,0,1);return c=Math.abs(p-f)>r+i*m,t+f}}function fs(t,e,i,s,r){if(i===e)return 0;let o=(0,n.d)(n.P,4);t.queryControlPoints(o);let a=(0,n.d)(n.P,4);return ji(o,e,i,a),ps(0,a,s,r,[0],0,0)}function ys(t,e,i,s,r){let o=!0,a=fe(5,e,i,s,r,e=>{let i=Bi(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*i.length()});o=!1;let l=fe(5,e,i,s,r,e=>{let i=Bi(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*i.length()});return new n.P(a,l)}function Ps(t,e,i,r,o,a,l,h,m,u,d,g){(0,s.g)(u+2===g);let c=0,_=0,p=0,f=0,y=0,P=0,x=0,v=(t,e)=>{let s=1-e,l=i.mul((0,n.aI)(s)),h=r.mul(3*e*s*s),m=o.mul(3*e*e*s),u=a.mul((0,n.aI)(e));return l.add(h).add(m).add(u).sub(d[t]).sqrLength()};for(let e=1,s=g-1;e<s;e++){let s=m[e-1];if(t){e>2?(s=(0,n.a)(2*m[e-2]-m[e-3],0,1),m[e-1]=s):2===e&&(s=(0,n.a)(2*m[e-2],0,1),m[e-1]=s);let t=(t,e,s)=>{let l=-1;for(let h=0;!(Math.abs(e-l)<1e-12||10===h);h++){let h=e*e,m=1-e,u=m*m,g=u*m,c=i.x-2*r.x+o.x,_=i.x-3*r.x+3*o.x-a.x,p=i.y-2*r.y+o.y,f=i.y-3*r.y+3*o.y-a.y,y=i.x-r.x-2*c*e+_*h,P=-d[t].x+i.x*g+e*(3*r.x*u+e*(3*o.x*m+a.x*e)),x=i.y-r.y-2*p*e+f*h,v=-d[t].y+i.y*g+e*(3*r.y*u+e*(3*o.y*m+a.y*e)),C=-6*(y*P+x*v),b=6*(3*(0,n.e)(y)-(-2*c+2*_*e)*P)+6*(3*(0,n.e)(x)-(-2*p+2*f*e)*v);if(l=e,0===b)break;{let t=e-C/b;e=(0,n.a)(t,s,1)}}return l};{let i=v(e,m[e-1]),s=t(e,m[e-1],0),r=v(e,s);if(1.01*i<r){let i=e>1?m[e-2]:0,n=t(e,.3*(m[e-1]-i)+i,0),o=v(e,n);o<r&&(r=o,s=n)}i>r&&(m[e-1]=s)}}let l=m[e-1],h=l*l,u=h*l,g=1-l,C=g*g,b=C*g;c+=3*h*C*C,_+=3*u*b,p+=3*h*h*C;let E=-(b*i.x+u*a.x-d[e].x);f+=E*l*C,y+=E*h*g;let D=-(b*i.y+u*a.y-d[e].y);P+=D*l*C,x+=D*h*g}if(e){let t=c*p-_*_;Math.abs(t)>=1e-12*(Math.abs(c*p)+Math.abs(_*_))+1e-10?(l||(r.x=(f*p-y*_)/t,r.y=(P*p-x*_)/t),h||(o.x=(c*y-_*f)/t,o.y=(c*x-_*P)/t)):((0,n.J)(i,a,.3,r),(0,n.J)(i,a,.6,o))}let C=0;for(let t=1,e=g-1;t<e;t++)C+=v(t,m[t-1]);return C}var xs=r.V;class vs extends Q{static type=s.G.enumBezier;constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=(0,n.d)(n.P,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||(0,n.af)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=(0,n.d)(n.P,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=(0,n.d)(n.P,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}),(0,s.d)("unrecognized constructor params"),this.m_cp=(0,n.d)(n.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return At(this)}construct(t,e,i,s){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=s.x,this.m_YEnd=s.y,this.m_cp[0].assign(e),this.m_cp[1].assign(i),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){let e=(0,n.d)(n.P,4);(function(t,e){e[0].assign(t[0]),e[3].assign(t[2]),(0,n.J)(t[0],t[1],2/3,e[1]),(0,n.J)(t[1],t[2],1/3,e[2])})(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(),(0,n.aj)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,n.aj)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),N(this,t)}getGeometryType(){return s.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,s.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;let e=Yi(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i);return}let i=(0,n.d)(n.Z,8),r=(0,n.d)(n.P,4);this.queryControlPoints(r);let o=ds(r,i),a=new n.P;for(let e=1;e<o-1;e++)this.queryCoord2D(i[e].value(),a),t.mergeNe(a)}applyTransformation(t){if(1===t.m_TransformationType){let e=(0,n.d)(n.P,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 Fi(this)}(0,s.g)(0)}createInstance(){return new vs({vd:this.m_description})}calculateLength2D(){return Ni(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return n.P.distance(this.getStartXY(),this.m_cp[0])+n.P.distance(this.m_cp[0],this.m_cp[1])+n.P.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DMP(t,e){(0,s.g)(0)}queryCoord2DExtends(t,e,i){let s=(0,n.d)(n.P,4);this.queryControlPoints(s),Ui(s,t,e,i)}queryCoord2DE(t,e){!function(t,e,i){let s=(0,n.d)(n.P,4);t.queryControlPoints(s),function(t,e,i){if(e.value()<=.5){let s=new g;(0,n.ao)(2,g.constructPoint2D(t[0]),g.constructPoint2D(t[1]),e,s);let r=new g;(0,n.ao)(2,g.constructPoint2D(t[1]),g.constructPoint2D(t[2]),e,r);let o=new g;(0,n.ao)(2,g.constructPoint2D(t[2]),g.constructPoint2D(t[3]),e,o);let a=new g;(0,n.ao)(2,s,r,e,a);let l=new g;(0,n.ao)(2,r,o,e,l),(0,n.ao)(2,a,l,e,i)}else{let s=new g;(0,n.ap)(2,g.constructPoint2D(t[0]),g.constructPoint2D(t[1]),e,s);let r=new g;(0,n.ap)(2,g.constructPoint2D(t[1]),g.constructPoint2D(t[2]),e,r);let o=new g;(0,n.ap)(2,g.constructPoint2D(t[2]),g.constructPoint2D(t[3]),e,o);let a=new g;(0,n.ap)(2,s,r,e,a);let l=new g;(0,n.ap)(2,r,o,e,l),(0,n.ap)(2,a,l,e,i)}}(s,e,i)}(this,t,e)}getCoordX(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.x}let e=(0,n.r)(this.getStartX(),this.m_cp[0].x,t),i=(0,n.r)(this.m_cp[0].x,this.m_cp[1].x,t),s=(0,n.r)(this.m_cp[1].x,this.getEndX(),t),r=(0,n.r)(e,i,t),o=(0,n.r)(i,s,t);return(0,n.r)(r,o,t)}getCoordY(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.y}let e=(0,n.r)(this.getStartY(),this.m_cp[0].y,t),i=(0,n.r)(this.m_cp[0].y,this.m_cp[1].y,t),s=(0,n.r)(this.m_cp[1].y,this.getEndY(),t),r=(0,n.r)(e,i,t),o=(0,n.r)(i,s,t);return(0,n.r)(r,o,t)}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=xs.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=xs.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){Qi(this,t,e)}cutBezierIgnoreAttributes(t,e,i){(t<0||e>1||t>e)&&(0,s.b)("Cubic_bezier.cut_bezier_ignore_attributes");let r=(0,n.d)(n.P,4);this.queryControlPoints(r);let o=(0,n.d)(n.P,4);ji(r,t,e,o),i.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,i){this===e&&this===i&&(0,s.b)("Cubic_bezier.split_bezier_ignore_attributes");let r=(0,n.d)(n.P,4);this.queryControlPoints(r);let o=(0,n.d)(n.P,4),a=(0,n.d)(n.P,4);Wi(r,t,o,a),e&&e.setControlPoints(o),i&&i.setControlPoints(a)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,i);if(1===t)return this.getEndAttributeAsDbl(e,i);let s=this.getStartAttributeAsDbl(e,i),r=this.getEndAttributeAsDbl(e,i),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,l=xs.getInterpolation(e);return(0,n.ac)(l,s,r,a,xs.getDefaultValue(e))}getClosestCoordinate(t,e){let i=[NaN];return ms(this,t,n.E.unit(),e,-1,1,i),i[0]}getClosestCoordinateOnInterval(t,e,i=-1){let s=[NaN];return 0===ms(this,t,e,!1,i,1,s)?NaN:s[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.b)("");let i=Ri(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)Gi(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){let r=(0,n.d)(n.P,4);return this.queryControlPoints(r),function(t,e,i,s,r){let o=(0,n.d)(n.Z,4),a=(0,n.d)(n.Z,3),l=new n.E(0,1),h=0;if(e){if(Mi(t,o,!1),h=zt(o[3],o[2],o[1],o[0].sub(i),l,!1,a),s)for(let e=0;e<h;e++){let i=new n.P;Ui(t,a[e].value(),i),s[e]=i.x}}else if(Ii(t,o,!1),h=zt(o[3],o[2],o[1],o[0].sub(i),l,!1,a),s)for(let e=0;e<h;e++){let i=new n.P;Ui(t,a[e].value(),i),s[e]=i.y}if(r)for(let t=0;t<h;t++)r[t]=a[t].value();else s&&(0,n.ab)(s,0,h,n.X);return h}(r,t,e,i,s)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isDegenerate(t){return P(this,t)}isDegenerate3D(t,e){return(0,s.g)(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());(0,s.g)(0)}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=o.Envelope2D.constructEmpty();this.queryEnvelope(t);let i=n.E.constructEmpty();return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.d)(n.P,4);this.queryControlPoints(i),ji(i,t.vmin,t.vmax,i),e.setFromPoints(i,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),s=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),r=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),n=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp[0].setCoordsPoint2D(t):s&&this.m_cp[0].setCoordsPoint2D(e),n?this.m_cp[1].setCoordsPoint2D(e):r&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ni(this,t,!0)}lengthToT(t){return function(t,e){let i=Ni(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;let r=[0];return 1!==It(new _s(t,e),n.E.unit(),1,r)&&(0,s.d)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=(0,n.d)(n.P,4);Si(this,e);let i=e[3],s=e[2],r=e[1],o=new n.P;o.x=(5*i.x*i.x*(7*s.y+16*r.y)+i.x*(-35*i.y*s.x+40*s.x*s.y-80*i.y*r.x+140*s.x*r.y+112*r.x*r.y)-2*(i.y*(20*s.x*s.x+70*s.x*r.x+56*r.x*r.x)-7*(4*s.x+5*r.x)*(-s.y*r.x+s.x*r.y)))/840,o.y=(-5*i.y*i.y*(7*s.x+16*r.x)+i.y*(5*i.x*(7*s.y+16*r.y)-4*(10*s.x*s.y+35*s.y*r.x+28*r.x*r.y))+2*(-7*(4*s.y+5*r.y)*(s.y*r.x-s.x*r.y)+i.x*(20*s.y*s.y+70*s.y*r.y+56*r.y*r.y)))/840;let a=ki(this);return o.x+=(e[0].x-t.x)*a,o.y+=(e[0].y-t.y)*a,o}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=2**-52*8*i}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.b)("calculate_sub_weightedCentroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=Ri(t),a=wi(t),l=a/t.calculateUpperLength2D(),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),n=ys(t,h,s,l,a);if(r.addThis(n),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(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 e=0;e<4;e++)t[e].isNAN()&&(0,s.b)("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){let e=(0,n.d)(n.P,4);return this.queryControlPoints(e),Oi(e,t)}getDerivative(t){let e=(0,n.d)(n.P,4);return this.queryControlPoints(e),Vi(e,1,t)}getCurvature(t){let e=Bi(this,1,t),i=Bi(this,2,t),s=e.sqrLength();return 0===s?NaN:(e.divThis(Math.sqrt(s)),e.crossProduct(i)/s)}isIntersectingPoint(t,e,i){if(i&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;let s=new o.Envelope2D;if(this.queryLooseEnvelope(s),s.inflateCoords(e,e),!s.contains(t))return!1;let r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}isMonotoneQuickAndDirty(){let t=(0,n.d)(n.P,4);return this.queryControlPoints(t),function(t){return function(t){let e=(0,n.a5)(t[0].y,t[1].y),i=(0,n.a5)(t[1].y,t[2].y),s=(0,n.a5)(t[2].y,t[3].y);if(e>=0&&i>=0&&s>=0||e<=0&&i<=0&&s<=0){let e=(0,n.a5)(t[0].x,t[1].x),i=(0,n.a5)(t[1].x,t[2].x),s=(0,n.a5)(t[2].x,t[3].x);if(e>=0&&i>=0&&s>=0||e<=0&&i<=0&&s<=0)return!0}return!1}(t)}(t)}getMonotonicPartParams(t,e){let i=Ri(this),r=i.specialPointsCount();if((0,s.g)(z.s_maxMonotonicPartParams>=r),!e)return i.specialPointsCount();t<r&&(0,s.b)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.s)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.s)(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]=(0,n.s)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,n.s)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){let t=new n.Z;return zi(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){let e=(0,n.d)(n.P,4);this.queryControlPoints(e);let i=e[3].sub(e[0]),s=i.length();if(n.P.distance(e[0],e[1])+n.P.distance(e[2],e[1])+n.P.distance(e[2],e[3])-s>t)return!1;let r=t,o=e[1].clone();o.subThis(e[0]);let a=Math.abs(o.crossProduct(i))/s;return!(a>r||(o=e[2].clone(),o.subThis(e[1]),a=Math.abs(o.crossProduct(i))/s,a>r))}copyIgnoreAttributes(t){let e=(0,n.d)(n.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return ki(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1);var t}queryEnvelopeW(t,e){os(this,t,e)}setSegmentFromCoordsForStitcher(t,e){!function(t,e,i){if((0,s.g)(i>=2),2===i){let s=new n.P;(0,n.J)(e[0],e[i-1],1/3,s);let r=new n.P;return(0,n.J)(e[0],e[i-1],2/3,r),void t.construct(e[0],s,r,e[i-1])}let r=e[0],o=e[i-1],a=[0,0],l=ms(t,r,n.E.unit(),!1,NaN,2,a),h=[0,0],m=ms(t,o,n.E.unit(),!1,NaN,2,h),u=[];for(let s=0;s<l;s++)for(let l=0;l<m;l++){let m=a[s],d=h[l],g=m>d,c=(s,a)=>{let l=(0,n.c)(i-2,NaN),h=()=>{let t=0;for(let s=1,r=i-1;s<r;s++){t+=n.P.distance(e[s-1],e[s]);let i=t;l[s-1]=i}t+=n.P.distance(e[i-2],e[i-1]),g&&l.reverse();for(let e=1,s=i-1;e<s;e++)l[e-1]/=t,g&&(l[e-1]=1-l[e-1])},u=!1,c=!1;{let e=new Xn;g?(t.queryCut(d,m,e,!0),s.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())):(t.queryCut(m,d,e,!0),s.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())),r.equals(s)&&(u=!0),o.equals(a)&&(c=!0)}h();let _=Number.MAX_VALUE,p=s.clone(),f=a.clone();for(let t=0;t<5;t++)_=Ps(!0,!1,r,p,f,o,u,c,l,i-2,e,i);for(let t=0;t<30;t++){let t=p.clone();f.clone();let s=Ps(!0,!0,r,p,f,o,u,c,l,i-2,e,i);if(_<=s&&t.equals(p)&&t.equals(f))break;_=s}h();let y=!1,P=Number.MAX_VALUE,x=s.clone(),v=a.clone();for(let t=0;t<30;t++){let t=x.clone();v.clone();let s=Ps(y,!0,r,x,v,o,u,c,l,i-2,e,i);if(P<=s&&t.equals(x)&&t.equals(v))break;y=!0,P=s}return P<_?(s.assign(x),a.assign(v)):(s.assign(p),a.assign(f),P=_),P},_=new n.P,p=new n.P,f=[c(_,p),n.P.distance(r,_)+n.P.distance(_,p)+n.P.distance(p,o),_.x,_.y,p.x,p.y];u.splice(u.length,0,...f)}let d=u[0],g=u[1],c=0;for(let t=6;t<u.length;t+=6)u[t]<d&&(d=u[t],g=u[t+1],c=t);let _=c;for(let t=0;t<u.length;t+=6)t!==c&&u[t+1]<g&&Math.abs(d-u[t])<10*d&&(g=u[t+1],_=t);t.construct(r,new n.P(u[_+2],u[_+3]),new n.P(u[_+4],u[_+5]),o)}(this,t,e)}writeInBufferStream(t,e){let i=new Float64Array(4);return this.writeInBuffer_(i),t.writeRangeFromArray(e,i.length,i,!0,1),e+i.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){let i=new Float64Array(4);t.queryRange(e,i.length,i,!0,1),this.readFromBuffer_(i)}readFromBuffer_(t){this.m_cp=(0,n.d)(n.P,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){let e=(0,n.d)(n.P,4);this.queryControlPoints(e);let i=(e,i,s)=>{let r=!1;return n.P.sqrDistance(e,s)<=t&&(r=!e.equals(s),e.setCoordsPoint2D(s),n.P.sqrDistance(i,s)<=t&&(r||=!i.equals(s),i.setCoordsPoint2D(s))),r},s=i(e[1],e[2],e[0]),r=i(e[2],e[1],e[3]);return(s||r)&&this.setControlPoints(e),s||r}needsSnapControlPoints(t){if(!t)return!1;let e=(0,n.d)(n.P,4);this.queryControlPoints(e);let i=(e,i,s)=>{let r=!1;return n.P.sqrDistance(e,s)<=t&&(r=!e.equals(s),e.setCoordsPoint2D(s),n.P.sqrDistance(i,s)<=t&&(r||=!i.equals(s),i.setCoordsPoint2D(s))),r},s=i(e[1],e[2],e[0]),r=i(e[2],e[1],e[3]);return s||r}calculateSpecialPointsForCracking(t,e){return function(t,e,i){i.length=0;{let e=new n.Z;zi(t,e);let s=new g;if(Qi(t,e,s),s.isZero())return e.isZero()||e.eq(new n.Z(1))?0:(i.push(e.value()),1)}let s=(0,n.d)(n.Z,4);Ai(t,s,!0);let r=(0,n.d)(n.Z,4);Ti(t,r,!0);let o=(0,n.d)(n.Z,6),a=s[3].negate().mulE(r[1]).addE(s[2].mulE(r[2]).mul(2)).addE(s[1].mulE(r[3])),l=s[3].negate().mulE(r[1]).subE(s[2].mulE(r[2]).mul(2)).addE(s[1].mulE(r[3])),h=s[2].mulE(s[2]).subE(r[2].mulE(r[2]));o[0]=r[1].mulE(r[1]).mulE(a).addE(s[1].mulE(s[1]).mulE(l)).addE(s[1].mulE(r[1]).mulE(h).mul(2)).mul(6),o[1]=s[2].mulE(r[1]).subE(s[1].mulE(r[2])).mulE(s[2].mulE(s[2]).addE(s[1].mulE(s[3]).mul(2)).addE(r[2].mulE(r[2])).addE(r[1].mulE(r[3]).mul(2))).mul(24);let m=s[1].mulE(r[2]).mulE(r[2]).mulE(r[3]),u=s[2].mulE(s[2]).mulE(s[3]).mulE(r[1]).subE(m).mul(156),d=s[3].mulE(r[1]).subE(s[1].mulE(r[3])),c=s[3].mulE(r[1]).subE(s[1].mulE(r[3])),_=s[1].mulE(s[3]).mulE(c).addE(r[1].mulE(r[3]).mulE(d)).mul(72),p=r[1].mulE(r[3]).subE(s[1].mulE(s[3])),f=s[2].mulE(r[2]).mulE(p).mul(120),y=s[1].mulE(s[2]).mulE(s[2]).mulE(r[3]),P=s[3].mulE(r[1]).mulE(r[2]).mulE(r[2]).subE(y).mul(36);o[2]=u.addE(_).addE(f).addE(P);let x=s[2].mulE(s[3]).mulE(s[3]).mulE(r[1]).subE(s[1].mulE(r[2]).mulE(r[3]).mulE(r[3])).mul(360),v=s[2].mulE(r[2]).mulE(s[2].mulE(s[3]).subE(r[2].mulE(r[3]))).addE(s[3].mulE(r[2]).mulE(r[2]).mulE(r[2])).subE(s[2].mulE(s[2]).mulE(s[2]).mulE(r[3])).mul(24),C=s[2].mulE(r[1]).mulE(r[3]).mulE(r[3]).subE(s[1].mulE(s[3]).mulE(s[3]).mulE(r[2])).mul(72),b=s[3].mulE(r[3]).mulE(r[1].mulE(r[2]).subE(s[1].mulE(s[2]))).mul(288);o[3]=x.addE(v).addE(C).addE(b),o[4]=r[3].mulE(r[3]).addE(s[3].mulE(s[3])).mulE(s[3].mulE(r[1]).subE(s[1].mulE(r[3]))).mul(270).addE(s[3].mulE(r[2]).subE(s[2].mulE(r[3]))).mulE(s[2].mulE(s[3]).addE(r[2].mulE(r[3]))).mul(180),o[5]=s[3].mulE(r[2]).subE(s[2].mulE(r[3])).mulE(s[3].mulE(s[3]).addE(r[3].mulE(r[3]))).mul(216);let E=(0,n.d)(n.Z,5),D=Vt(o,5,new n.E(0,1),!1,E,5);if(D>0){let s=Math.abs(t.getCurvature(0)),r=0,o=Math.abs(t.getCurvature(1));(o>s||!Number.isFinite(o))&&(r=1);for(let e=0;e<D;e++){let i=Math.abs(t.getCurvature(E[e].value()));t.getCoord2D(E[e].value()),(i>s||!Number.isFinite(i))&&(s=i,r=E[e].value())}if((!Number.isFinite(s)||1/s<e)&&!(0,n.a9)(r,0,1)){let e=t.getCoord2D(r);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return i.push(r),1}}if(!t.isClosed()){let e=[0,0],s=us(t,e,!1);for(let t=0;t<s;t++)e[t]>0&&e[t]<1&&i.push(e[t]);return i.length}return 0}(this,t,e)}ensureXYMonotone(){return Gi(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.d)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.d)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformPoints2D(t.m_cp,2,t.m_cp):((0,n.J)(e,i,1/3,t.m_cp[0]),(0,n.J)(e,i,2/3,t.m_cp[1])),t.changeEndPoints2D(e,i),r&&Gi(t)}(this,t,e,i)}copyToImpl(t){let e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Xi(e,Yi(this))}reverseImpl(){this.m_cp[1]=(0,n.s)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){let e=t;return!(!this.m_cp[0].equals(e.m_cp[0])||!this.m_cp[1].equals(e.m_cp[1]))}equalsImplTol(t,e){let i=t;return!(!this.m_cp[0].isEqualPoint2D(i.m_cp[0],e)||!this.m_cp[1].isEqualPoint2D(i.m_cp[1],e))}swapImpl(t){let e=t;e.m_cp[0]=(0,n.s)(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=(0,n.s)(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),function(t,e){e.m_cachedValues=(0,n.s)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Fi(this)}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,r){let o=new h;if(os(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;let a=Ri(t),l=0,m=a.specialPoints[0],u=[];for(let i=1,r=a.specialPoints.length;i<r;++i){let r=a.specialPoints[i],n=Li(t,e,m,r);if(0===u.length)u.push(n);else if(n.t===n.tmin)(0,s.g)(u.at(-1).d<=n.d),u.at(-1).tmax=n.tmax;else if(u.at(-1).t===u.at(-1).tmax){(0,s.g)(u.at(-1).d>=n.d);let t=u.at(-1).tmin;u[u.length-1]=n,u.at(-1).tmin=t}else u.push(n);m=r}for(let t of u)if(t.d<=r){let e=t.t;i?(l>=i.length&&(0,s.r)(""),i[l]=e,l++):l++}return l}(this,t,e,i)}endPointModified(){Fi(this)}clearEndPointModified(){}m_cp;m_cachedValues}class Cs{specialPoints;specialPointsLength;length;area;centroidX;centroidY;constructor(){this.length=NaN,this.area=NaN,this.centroidX=NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function bs(t,e,i,r,o,a,l,h){for(;;){let m=n.P.distance(e[0],e[2]),u=n.P.distance(e[0],e[1])+n.P.distance(e[1],e[2]);if(u-m<=o+r*u)return t+(0,n.r)(m,u,.5);let d=(0,n.d)(n.P,4),g=t=>(Ns(e,i,1,t,d),d[1].length());if(0===l&&h<8){(0,s.g)(h<8);let m=g(0),d=g(1);a[0]+=2,m>d&&(d=(0,n.s)(m,m=d),e[2]=(0,n.s)(e[0],e[0]=e[2]),i[2]=(0,n.s)(i[0],i[0]=i[2]));let c=m/(m+d),_=1,p=u;for(;c<1/32&&p>=o+r*p;){_/=4;let t=g(_);a[0]++,c=m/(t+m);let s=new n.P;if(mr(e,i,.5*_,s),p=n.P.distance(s,e[0]),p<=o){let t=new n.P;mr(e,i,_,t),p+=n.P.distance(t,s)}}if(1!==_){let s=(0,n.d)(n.P,3),m=[0,0,0];Qs(e,i,_,e,i,s,m),t=bs(t,s,m,r,o,a,0,h+1),l++,h++;continue}}let c=!1;a[0]+=8;let _=ri(8,g,0,1);a[0]+=16;let p=ri(16,g,0,1);if(c=Math.abs(_-p)>o+r*u,!c)return t+p;if(l<8&&h<9){let s=(0,n.d)(n.P,3),m=[0,0,0];Qs(e,i,.5,e,i,s,m),t=bs(t,s,m,r,o,a,l+1,h+1),l++,h++;continue}a[0]+=32;let f=ri(32,g,0,1);if(c=Math.abs(p-f)>o+r*u,!c)return t+f;a[0]+=64;let y=ri(64,g,0,1);if(c=Math.abs(f-y)>o+r*u,!c)return t+y;a[0]+=128;let P=ri(128,g,0,1);return c=Math.abs(y-P)>o+r*u,t+P}}function Es(t,e,i,s,r){if(i===e)return 0;let o=(0,n.d)(n.P,3),a=[0,0,0];t.queryControlPoints(o),t.queryWeights(a);let l=[0,0,0],h=(0,n.d)(n.P,3);return Ks(o,a,e,i,h,l),bs(0,h,l,s,r,[0],0,0)}class Ds{controlPoints;weights;point;constructor(t,e,i){this.controlPoints=(0,n.a8)(t,3),this.weights=[0,0,0],(0,n.f)(this.weights,e,0,0,3),this.point=i.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){let t=new n.P;mr(this.controlPoints,this.weights,e,t);let i=(0,n.d)(n.P,4);return Ns(this.controlPoints,this.weights,1,e,i),2*t.sub(this.point).dotProduct(i[1])}if(1===t){let t=new n.P;mr(this.controlPoints,this.weights,e,t);let i=(0,n.d)(n.P,4);return Ns(this.controlPoints,this.weights,2,e,i),2*(t.sub(this.point).dotProduct(i[2])+i[1].dotProduct(i[1]))}if(2===t){let t=new n.P;mr(this.controlPoints,this.weights,e,t);let i=(0,n.d)(n.P,4);return Ns(this.controlPoints,this.weights,3,e,i),2*(t.sub(this.point).dotProduct(i[3])+3*i[1].dotProduct(i[2]))}return 0}getError(t){return(0,s.g)(0),0}}function ws(t,e,i,s){let r=function(t,e,i,s,r){return{tmin:0,tmax:0,t:0,d:0,pt:r.clone()}}(0,0,0,0,n.P.getNAN()),o=(0,n.c)(18,NaN),a=(0,n.d)(n.P,3);t.queryControlPoints(a),a[2].subThis(e),a[1].subThis(e),a[0].subThis(e);let l=[0,0,0];t.queryWeights(l);let h=[1,dr(l),1],m=cr(l,i),u=cr(l,s),d=It(new Ds(a,h,new n.P(0,0)),n.E.construct(m,u),18,o);mr(a,h,m,r.pt),r.t=m,r.d=n.P.distance(r.pt,new n.P(0,0));let g=new n.P;mr(a,h,u,g);let c=n.P.distance(g,new n.P(0,0));c<r.d&&(r.d=c,r.t=u,r.pt.assign(g));for(let t=0;t<d;t++){mr(a,h,o[t],g);let e=n.P.distance(g,new n.P(0,0));e<r.d&&(r.d=e,r.t=gr(l,o[t]),r.pt.assign(g))}return r}function Ss(t,e,i,s,r){let o=!0,a=(0,n.d)(n.P,4),l=fe(5,e,i,s,r,e=>(qs(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));o=!1;let h=fe(5,e,i,s,r,e=>(qs(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()));return new n.P(l,h)}function As(t){t.m_cachedValues=null}function Ts(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new Cs,i=(0,n.d)(n.P,3);t.queryControlPoints(i);let s=[0,0,0];return t.queryWeights(s),Is(i,s,e.specialPoints),ks(t,e),e}function Is(t,e,i){if(0===e[1])return i.length=0,i.push(0),void i.push(1);let s=(0,n.d)(n.Z,8);s[0].set(0);let r=1;{let i=new n.Z(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new n.Z(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=i.subE(o).addThisE(new n.Z(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(i.mul(2));let l=(0,n.d)(n.Z,2),h=Lt(a,o,i,new n.E(0,1),!1,l);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.a9)(l[t].value(),0,1)||(s[r]=l[t],r++)}{let i=new n.Z(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new n.Z(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=i.subE(o).addThisE(new n.Z(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(i.mul(2));let l=(0,n.d)(n.Z,2),h=Lt(a,o,i,new n.E(0,1),!1,l);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.a9)(l[t].value(),0,1)||(s[r]=l[t],r++)}if(s[r].set(1),r++,r>2){(0,n.ab)(s,0,r,(t,e)=>(0,n.X)(t.value(),e.value()));let t=0,e=s[0].value(),i=1;for(let n=1;n<r;n++)s[n].eq(s[n-1])?(e+=s[n].value(),i++):(i>1&&(e/=i,s[t].set(e)),t++,s[t]=s[n],e=s[n].value(),i=1);t++,r=t}s[0].set(0),s[r-1].set(1),i.length=r;for(let t=0;t<r;t++)i[t]=s[t].value()}function Ms(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+Ms(t,1,!1)}if(t.isDegenerate(0))return 0;let s=1===e,r=Ts(t);if(s&&!Number.isNaN(r.length))return r.length;let n=Vs(t),o=n/t.calculateUpperLength2D(),a=0,l=0;for(let i=1,s=r.specialPointsCount();i<s;i++){let s=r.specialPoints[i];if(a+=Es(t,l,Math.min(e,s),o,n),e<=s)break;l=s}return s&&(r.length=a),a}function qs(t,e,i,s){let r=(0,n.d)(n.P,3);t.queryControlPoints(r);let o=[0,0,0];t.queryWeights(o),Ns(r,o,e,i,s)}function Ns(t,e,i,r,o){let a=[t[0],t[1],t[2]],l=[e[0],e[1],e[2]],h=(0,n.d)(n.P,4);!function(t,e,i,r,n){(0,s.g)(i>0);let 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)}let a=Rs(o,e,0,r),l=Xs(e,0,r),h=a.divide(l);if(n[0].assign(h),0===i)return;let m=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],u=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],d=l*l,g=Rs(u,m,0,r).mul(2).divide(d);if(n[1].assign(g),1===i)return;let c=Xs(e,1,r),_=2*l*c,p=Rs(u,m,1,r).mul(2).sub(g.mul(_)).divide(d);if(n[2].assign(p),2===i)return;let f=Rs(u,m,2,r).mul(2),y=2*(c*c+l*Xs(e,2,r)),P=f.sub(p.mul(_).mul(2)).sub(g.mul(y)).divide(d);n[3].assign(P),3!==i&&(0,s.d)("")}(a,l,i,r,h);for(let t=0;t<=i;t++)o[t].setCoords(h[t].x,h[t].y)}function Rs(t,e,i,r){if(0===i){if(r<=.5){let i=new n.P;(0,n.as)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,i);let s=new n.P;(0,n.as)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,s);let o=new n.P;return(0,n.as)(2,i,s,r,o),o}{let i=new n.P;(0,n.at)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,i);let s=new n.P;(0,n.at)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,s);let o=new n.P;return(0,n.at)(2,i,s,r,o),o}}if(1===i){let i=t[1].mul(e[1]),s=i.sub(t[0].mul(e[0])).mul(1-r).add(t[2].mul(e[2]).sub(i).mul(r));return s.mulThis(2),s}if(2===i){let i=t[1].mul(e[1]),s=t[2].mul(e[2]).sub(i).sub(i.sub(t[0].mul(e[0])));return s.mulThis(2),s}(0,s.d)("")}function Ys(t,e,i,s){if(s.toDouble()<=.5){let i=new g;(0,n.ao)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),s,i);let r=new g;(0,n.ao)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),s,r);let o=new g;return(0,n.ao)(2,i,r,s,o),o}{let i=new g;(0,n.ap)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),s,i);let r=new g;(0,n.ap)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),s,r);let o=new g;return(0,n.ap)(2,i,r,s,o),o}}function Xs(t,e,i){if(0===e){let e=(0,n.r)(t[0],t[1],i),s=(0,n.r)(t[1],t[2],i);return(0,n.r)(e,s,i)}return 1===e?2*((1-i)*(t[1]-t[0])+(t[2]-t[1])*i):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,s.d)("")}function Fs(t,e,i){let s=(0,n.a)(i,0,1),r=(0,n.d)(n.P,4);if(Ns(t,e,3,s,r),r[1].isZero()){if(r[2].isZero())return r[3];{let t=r[2].clone();return 1===s&&t.negateThis(),t}}return r[1]}class Ls{b;len=0;constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ms(this.b,e,!1):0}getError(t){return(0,s.g)(0),0}}function zs(t){let e=(0,n.d)(n.P,3),i=[0,0,0];return t.queryControlPoints(e),t.queryWeights(i),function(t,e){let i=dr(e);if(1===i)return Ne(t);if(0===i)return 0;let r=[new n.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=r[1].crossProduct(r[2]);if(i<1){(0,s.g)(i>0);let t,e=1-i;if(e<.01)t=-1/3+e*(2/15+e*(3/35+e*(16/315+e*(20/693+e*(16/1001+56/6435*e)))));else{let s=e*(1+i),r=Math.atan2(Math.sqrt(e),Math.sqrt(1+i));t=i*(.5*i-(0,n.aK)(s)*r)/s}return o*t}{let t=(i-1)*(i+1);return.25*i/t**1.5*(-2*i*Math.sqrt(t)*o-4*r[1].y*r[2].x*Math.atanh(Math.sqrt((i-1)/(i+1)))-r[1].x*r[2].y*Math.log(2*i*(i-Math.sqrt(t))-1))}}(e,i)}function Vs(t){return function(t){return 256*(0,n.I)()*t}(t.calculateUpperLength2D())}function Bs(t){return t.m_cachedValues}function ks(t,e){t.m_cachedValues=e}function Gs(t,e,i,s,r){let o=(0,n.d)(n.P,3);t.queryControlPoints(o);let a=[0,0,0];t.queryWeights(a);let l=[0];return 1===Zs(o,a,e,n.E.unit(),s,r,1,l)?l[0]:NaN}function Zs(t,e,i,o,a,l,h,m){(0,s.D)(n.E.unit().contains(o)&&h>0,""),(l<0||Number.isNaN(l))&&(l=Number.MAX_VALUE);let u=[,,,];for(let e=0;e<3;++e)u[e]=t[e].sub(i);let d=dr(e),g=_.constructPoint2D(u[0]),c=_.constructPoint2D(u[1]),p=_.constructPoint2D(u[2]),f=n.M.constructDouble(d),y=f.clone();y.ldexpThis(1);let P=g.dotProduct(c.sub(g)).mul(f),x=f.mul(f.addDouble(2)),v=p.sub(c.mul(x.ldexp(1))),C=c.sqrLength().mul(f.mul(f).ldexp(1)).add(g.sqrLength().mul(f.ldexp(2).subDouble(1))).add(g.dotProduct(v)),b=p.sub(c.mul(y)).add(g.mul(y.subDouble(1))),E=c.mul(f).sub(g).dotProduct(b).mulDouble(3),D=c.dotProduct(p).mul(f.subDouble(3).mul(f)).ldexp(1),w=c.sqrLength().mul(f.mul(f).ldexp(2)),S=g.sqrLength().mul(f.ldexp(2).subDouble(3)),A=g.dotProduct(p.sub(c.mul(f.mulDouble(3).subDouble(1)).mul(f))).ldexp(1),T=p.sqrLength().addThis(D).addThis(w).addThis(S).addThis(A),I=g.add(p).sub(c.mul(y)),M=f.subDouble(1),q=p.sub(g).dotProduct(I).mul(M),N=new n.P(0,0),R=[],Y=new n.P;mr(u,e,o.vmin,Y);let X=n.P.distance(Y,N);if(X<=l&&R.push(new n.P(o.vmin,X)),o.vmin!==o.vmax&&(mr(u,e,o.vmax,Y),X=n.P.distance(Y,N),X<=l&&R.push(new n.P(o.vmax,X))),o.width()>0){let t=u[2].isZero(),i=(0,n.d)(n.M,4),s=ne(q,T,E,C,P,58,o,t,i);for(let t=0;t<s;t++){if(!o.containsExclusiveCoordinate(i[t].toDouble()))continue;let s=i[t].toDouble();s=gr(e,s);let r=new n.P;mr(u,e,s,r),X=n.P.distance(r,N),X<=l&&R.push(new n.P(s,X))}}if(a){(0,s.g)(o.equals(n.E.unit()));{mr(u,e,-1,Y,!0);let t=new n.P;mr(u,e,0,t);let i=new Yn({start:Y,end:t}),s=i.getClosestCoordinate(N,!0);s<1&&(Y=i.getCoord2D(s),X=n.P.distance(Y,N),X<=l&&R.push(new n.P(s-1,X)))}{mr(u,e,2,Y,!0);let t=new n.P;mr(u,e,o.vmax,t);let i=new Yn({start:t,end:Y}),s=i.getClosestCoordinate(N,!0);s>0&&(Y=i.getCoord2D(s),X=n.P.distance(Y,N),X<=l&&R.push(new n.P(1+s,X)))}}if(!R.length)return 0;R.sort((t,e)=>t.compare(e));let F=0,L=R[0].x;if(m[F++]=L,F<h){let t=(0,r.a4)(u,4,!1).total(),e=R[0].y;for(let i=1,s=R.length;i<s;i++)if(R[i].y>e+t){R.length=i;break}R.sort((t,e)=>(0,n.X)(t.x,e.x)),F=0,m[F++]=R[0].x;for(let t=1,e=R.length;t<e;t++)R[t].x!==m[F-1]&&F<h&&(m[F++]=R[t].x)}return F}function Hs(t,e,i){let s=(0,n.d)(n.P,3);t.queryControlPoints(s);let r=[0,0,0];t.queryWeights(r),Ws(s,r,e,i)}function Ws(t,e,i,s){if(i.equalsRange(0,1))return void s.setFromPoints(t,3);let r=(0,n.d)(n.P,3);Ks(t,e,i.vmin,i.vmax,r,[0,0,0]),s.setFromPoints(r,3)}function js(t){let e=(0,n.a5)(t[0].y,t[1].y),i=(0,n.a5)(t[1].y,t[2].y);if(e>=0&&i>=0||e<=0&&i<=0){let e=(0,n.a5)(t[0].x,t[1].x),i=(0,n.a5)(t[1].x,t[2].x);if(e>=0&&i>=0||e<=0&&i<=0)return!0}return!1}function Us(t){let e=(0,n.d)(n.P,3);t.queryControlPoints(e);let i=Os(e);return i&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),i}function Os(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.a5)(t[0][i],t[2][i]);s>0?((0,n.a5)(t[0][i],t[1][i])<0&&(t[1][i]=t[0][i],e=!0),(0,n.a5)(t[1][i],t[2][i])<0&&(t[1][i]=t[2][i],e=!0)):s<0?((0,n.a5)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.a5)(t[1][i],t[2][i])>0&&(t[1][i]=t[2][i],e=!0)):t[1][i]!==t[0][i]&&(t[1][i]=t[0][i],e=!0)}return e}function Qs(t,e,i,o,a,l,h){(0,s.g)(i>=0&&i<=1&&o!==l&&a!==h),(0,s.g)(e[0]>0&&e[2]>0&&e[1]>=0);let m=[1,dr(e),1],u=cr(e,i),d=(0,n.a8)(t,3),g=(0,n.d)(r.k,3);ar(d,m,g);let c=(0,n.d)(r.k,3),_=(0,n.d)(r.k,3);_r(g,u,o?c:null,l?_:null),pr(e,i,a,h);let p=js(d);if(o){for(let t=0;t<3;++t)hr(c[t],o[t]);yr(d,o),p&&Os(o)}if(l){for(let t=0;t<3;++t)hr(_[t],l[t]);yr(d,l),p&&Os(l)}}function Ks(t,e,i,o,a,l){if((0,s.g)(i>=0&&o<=1&&i<=o),i===o){let s=new n.P,r=lr(t,e,i,s);return fr(t,s),a[0].assign(s),a[1].assign(s),a[2].assign(s),l[0]=r,l[1]=r,void(l[2]=r)}if(0===i&&1===o)return a[0].assign(t[0]),a[1].assign(t[1]),a[2].assign(t[2]),l[0]=e[0],l[1]=e[1],void(l[2]=e[2]);let h=(0,n.d)(r.k,3);{let s=[1,dr(e),1],r=cr(e,i),n=cr(e,o);ar(t,s,h),_r(h,n,h,null),_r(h,r>=n?1:r/n,null,h)}let m=[0,0,0];pr(e,o,m,null),pr(m,i/o,null,m);let u=js(t),d=(0,n.d)(n.P,3);hr(h[1],d[1]),mr(t,e,i,d[0]),mr(t,e,o,d[2]),yr(t,d);for(let t=0;t<3;++t)a[t].assign(d[t]),l[t]=m[t];u&&Os(a)}function Js(t,e,i){let s=dr(e),r=[1,s,1],o=4*s/(3*(1+s));i[0].assign(t[0]),i[3].assign(t[2]),(0,n.J)(t[0],t[1],o,i[1]),(0,n.J)(t[2],t[1],o,i[2]),new vs({cp:i}),new Ut({points:t,weight:s});let a=0,l=.1,h=0;for(let e=0;e<9;e++,l+=.1){let e=new n.P;mr(t,r,l,e);let s=new n.P;Ui(i,l,s);let o=n.P.sqrDistance(e,s);o>a&&(a=o,h=l)}{let e=new n.P;mr(t,r,h,e);let s=[0];hs(i,e,n.E.unit(),!1,-1,1,s);let o=new n.P;return Ui(i,s[0],o),a=n.P.sqrDistance(e,o),Math.sqrt(a)}}function $s(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===ir(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function tr(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===sr(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function er(t,e,i,s,r){if(r){if(0!==Sn(e,i))return t?4:2}else if(y(e,i))return 1;return 0===nr(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}function ir(t,e,i,r,o,a,l,h,m,u){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),i.isDegenerate(0)){let t=[0,0],s=e.intersectPoint(i.getStartXY(),t,l);if(s>0){if(null!==o)for(let e=0;e<s;e++)o.push(t[e]);if(null!=a)for(let t=0;t<s;t++)a.push(0);if(null!=r)for(let i=0;i<s;i++){let s=new n.P;e.queryCoord2D(t[i],s),r.push(s)}}return s}let d=Y(e,i);if(l=Math.max(l,d),e.isDegenerateToLineHelper(d)){let t=new Yn({start:e.getStartXY(),end:e.getEndXY()}),s=ot(t,i,r,o,a,l,h,u);if(o)for(let i=0;i<s;++i){let s=t.getCoord2D(o[i]);o[i]=e.getClosestCoordinate(s,!1)}return s}if(X(e,i,l))return 0;let g=(0,n.d)(n.P,3);e.queryControlPoints(g);let c=[0,0,0];e.queryWeights(c);let _=[1,dr(c),1],p=i.getEndXY().sub(i.getStartXY()),f=p.clone();f.leftPerpendicularThis();let y=g[0].clone(),P=g[1].clone(),x=g[2].clone(),v=P.sub(y),C=x.sub(y),b=x.sub(P),E=_[0],D=_[1],w=_[2],S=E*D,A=E*w,T=D*w,I=v.dotProduct(f)*S,M=C.dotProduct(f)*A,q=I,N=M-2*I,R=b.dotProduct(f)*T+M-M,F=(0,n.c)(13,NaN),L=(0,n.c)(13,NaN),z=Mt(R,N,q,n.E.unit(),!1,F);z<0&&(F[0]=0,F[1]=1,z=2);let V=0;for(let t=0,e=V;t<z;++t){let s=new n.P;mr(g,_,F[t+e],s),L[V]=i.getClosestCoordinate(s,!1),n.P.distance(s,i.getCoord2D(L[V]))<=l&&(F[V]=F[t+e],V++)}let B=(0,n.d)(n.P,3),k=(0,n.d)(n.P,3);if(e.queryControlPoints(k),k[0].subThis(i.getStartXY()),k[1].subThis(i.getStartXY()),k[2].subThis(i.getStartXY()),function(t,e,i,s=!1){let r=(0,n.d)(n.P,3);s?(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[1].subThis(r[0]),r[2].setCoordsPoint2D(t[2]),r[2].subThis(r[0]),r[0].setCoords(0,0)):(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[2].setCoordsPoint2D(t[2])),r[0].mulThis(e[0]),r[1].mulThis(e[1]),r[2].mulThis(e[2]),i[1].setCoords(r[1].x-r[0].x,r[1].y-r[0].y),i[2].setCoordsPoint2D(r[2].sub(r[1])),i[2].subThis(i[1]),i[1].x*=2,i[1].y*=2,i[0].setCoordsPoint2D(r[0])}(k,_,B,!1),Math.abs(p.x)>=Math.abs(p.y)){let t=p.y/p.x;R=B[2].y-B[2].x*t,N=B[1].y-B[1].x*t,q=B[0].y-B[0].x*t}else{let t=p.x/p.y;R=B[2].x-B[2].y*t,N=B[1].x-B[1].y*t,q=B[0].x-B[0].y*t}let G=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),Z=[0,0];z=Mt(R,N,q,n.E.unit(),G,Z);for(let t=0,e=V;t<z;++t){F[t+e]=Z[t];let s=new n.P;mr(g,_,F[t+e],s),L[V]=i.getClosestCoordinate(s,!1),n.P.distance(s,i.getCoord2D(L[V]))<=l&&(F[V]=F[t+e],V++)}(0,s.g)(V<F.length+4);for(let t=0;t<V;t++)F[t]=gr(c,F[t]);z=e.intersectPoint(i.getStartXY(),Z,l);for(let t=0;t<z;t++)F[V]=Z[t],L[V++]=0;z=e.intersectPoint(i.getEndXY(),Z,l);for(let t=0;t<z;t++)F[V]=Z[t],L[V++]=1;z=i.intersectPoint(e.getStartXY(),Z,l);for(let t=0;t<z;t++)L[V]=Z[t],F[V++]=0;z=i.intersectPoint(e.getEndXY(),Z,l);for(let t=0;t<z;t++)L[V]=Z[t],F[V++]=1;return 0===V?0:Mn(t,e,i,F,L,V,r,o,a,l,h,0,u)}function sr(t,e,i,s,r,o,l,h,m,u){if(Kr(i))return ir(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,0,u);let d=Y(e,i);if(X(e,i,l=Math.max(l,d)))return 0;let g=[],c=[],_=(0,n.d)(n.P,4);{e.queryControlPoints(_);let t=(0,n.d)(n.P,4),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(_,4,t);let o=(0,n.d)(n.M,3),m=(0,n.d)(n.M,3),u=(0,n.d)(n.M,3),d=[0,0,0];e.queryWeights(d),or(t,d,o,m,u);let p=(0,n.d)(n.M,3);p[0].setDouble(i.getSemiMinorAxis()),p[0].sqrThis(),p[1].setDouble(i.getSemiMajorAxis()),p[1].sqrThis(),p[2].setThis(p[0]),p[2].mulThis(p[1]),p[2].negateThis();let f=ee(o,2,m,2,u,2,p,0,n.E.unit(),n.E.unit(),g,h);if(f>0){let t=0;for(let s=0;s<f;s++){let r=new n.P;e.queryCoord2D(g[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(g[t]=g[s],c.push(o),t++)}g.length=t}}let p=[0,1];for(let t=0;t<2;t++){let s=0===t?i.getStartXY():i.getEndXY(),r=Gs(e,s,n.E.unit(),!1,-1),o=new n.P;e.queryCoord2D(r,o),n.P.distance(s,o)<=l&&(g.push(r),c.push(p[t]))}for(let t=0;t<2;t++){let e=[0,3];{let s=i.getClosestCoordinate(_[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(_[e[t]],r)<=l&&(g.push(p[t]),c.push(s))}}return Mn(t,e,i,g,c,g.length,s,r,o,l,h,0,u)}function rr(t,e,i,r,o,a,l,m,u,d){let g=(0,n.d)(n.P,3);e.queryControlPoints(g);let c=(0,n.d)(n.P,3);if(i.queryControlPoints(c),F(g,c,3)<0)return rr(t,i,e,r,a,o,l,m,u,!d);let _=Y(e,i);if(e.isDegenerateToLineHelper(_)){let s=new Yn({start:e.getStartXY(),end:e.getEndXY()}),n=ir(t,i,s,r,a,o,l,m,0,!d);if(o)for(let t=0;t<n;++t){let i=s.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(i,!1)}return n}if(i.isDegenerateToLineHelper(_)){let s=new Yn({start:i.getStartXY(),end:i.getEndXY()}),n=ir(t,e,s,r,o,a,l,m,0,d);if(a)for(let t=0;t<n;++t){let e=s.getCoord2D(a[t]);a[t]=i.getClosestCoordinate(e,!1)}return n}if(X(e,i,l=Math.max(l,_)))return 0;let p=(0,n.c)(3,NaN);e.queryWeights(p);let f=(0,n.c)(3,NaN);i.queryWeights(f);let y=[1,dr(p),1],P=[1,dr(f),1],x=new n.E(0,1),v=new n.E(0,1);{let t=h.constructEmpty();Ws(g,y,new n.E(0,1),t);let e=h.constructEmpty();Ws(c,P,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(ur(g,y,t,x),ur(c,P,t,v),x.isEmpty()||v.isEmpty())return 0;Ks(g,y,x.vmin,x.vmax,g,y),Ks(c,P,v.vmin,v.vmax,c,P)}}let C=Nn(g,2,c,2,l);if(0===C)return 0;let b=[],E=[];if(-1===C){let t=(0,n.d)(n.M,3),e=(0,n.d)(n.M,3),i=(0,n.d)(n.M,3);or(g,y,t,e,i);let s=(0,n.d)(n.M,3),r=(0,n.d)(n.M,3),o=(0,n.d)(n.M,3);or(c,P,s,r,o);let a=[],h=[],u=te(t,2,e,2,i,2,s,2,r,2,o,2,0,n.E.unit(),n.E.unit(),a,h,m,0,d);if(u>0)for(let t=0;t<u;t++){let e=new n.P;mr(c,P,h[t],e);let i=new n.P;mr(g,y,a[t],i),n.P.distance(i,e)<=l&&(b.push(a[t]),E.push(h[t]))}}for(let t=0;t<2;t++){let e,i,r;0===t?(e=g,i=c,r=P):(e=c,i=g,r=y);for(let o=0;o<2;o++){let a=0===o?0:e.length-1,h=new n.P,m=[0],u=Zs(i,r,e[a],n.E.unit(),!1,-1,1,m);(0,s.g)(1===u),mr(i,r,m[0],h),n.P.distance(e[a],h)<=l&&(0===t?(b.push(0===a?0:1),E.push(m[0])):(E.push(0===a?0:1),b.push(m[0])))}}if(0===b.length)return 0;if(!x.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=Ut.recalculateParentT(x.vmin,x.vmax,b[t]);if(!v.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=Ut.recalculateParentT(v.vmin,v.vmax,E[t]);for(let t=0;t<b.length;++t)b[t]=gr(p,b[t]);for(let t=0;t<E.length;++t)E[t]=gr(f,E[t]);return Mn(t,e,i,b,E,b.length,r,o,a,l,m,0,d)}function nr(t,e,i,s,r,o,a,l,h,m){if(e.isLine())return We(t,i,new Yn({start:e.getStartXY(),end:e.getEndXY()}),s,o,r,a,l,0,!m);if(i.isLine())return ir(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,a,l,0,m);let u=Y(e,i);if(X(e,i,a=Math.max(a,u)))return 0;let d=(0,n.d)(n.P,3);e.queryControlPoints(d);let g=(0,n.d)(n.P,3);i.queryControlPoints(g);let c=Nn(d,2,g,2,a);if(0===c)return 0;let p=[],f=[];if(-1===c){let t=(0,n.d)(n.M,3),s=(0,n.d)(n.M,3),r=(0,n.d)(n.M,3),o=[0,0,0];e.queryWeights(o),or(d,o,t,s,r);let h=(0,n.d)(_,3);Qe(g,h);let u=te(t,2,s,2,r,2,[h[0].x,h[1].x,h[2].x],2,[h[0].y,h[1].y,h[2].y],2,null,0,0,n.E.unit(),n.E.unit(),p,f,l,0,m);if(u>0){let t=0;for(let s=0;s<u;s++){let r=new n.P;i.queryCoord2D(f[s],r);let o=new n.P;e.queryCoord2D(p[s],o),n.P.distance(o,r)<=a&&(p[t]=p[s],f[t]=f[s],t++)}p.length=t,f.length=t}}for(let t=0;t<2;t++){let s;s=0===t?d:g;for(let r=0;r<2;r++){let o,l=0===r?0:s.length-1,h=new n.P;0===t?(o=Xe(i,s[l],n.E.unit(),!1),i.queryCoord2D(o,h)):(o=Gs(e,s[l],n.E.unit(),!1,-1),e.queryCoord2D(o,h)),n.P.distance(s[l],h)<=a&&(0===t?(p.push(0===l?0:1),f.push(o)):(f.push(0===l?0:1),p.push(o)))}}return Mn(t,e,i,p,f,p.length,s,r,o,a,l,0,m)}function or(t,e,i,s,r){let o=n.M.constructDouble(e[0]),a=n.M.constructDouble(e[1]),l=n.M.constructDouble(e[2]);i[0].setDouble(t[0].x),i[0].mulThis(o),i[1].setDouble(t[1].x),i[1].mulThis(a),i[2].setDouble(t[2].x),i[2].mulThis(l),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),s[0].setDouble(t[0].y),s[0].mulThis(o),s[1].setDouble(t[1].y),s[1].mulThis(a),s[2].setDouble(t[2].y),s[2].mulThis(l),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),r[0].setDouble(e[0]),r[1].setDouble(e[1]),r[2].setThis(r[1]),r[2].ldexpThis(1),r[2].negateThis(),r[2].addThis(r[0]),r[2].addDoubleThis(e[2]),r[1].subThis(r[0]),r[1].ldexpThis(1)}function ar(t,e,i){for(let s=0;s<3;++s)i[s].setCoordsPoint2DZ(t[s].mul(e[s]),e[s])}function lr(t,e,i,s){if(0===i)return s.assign(t[0]),e[0];if(1===i)return s.assign(t[2]),e[2];let r,o,a,l=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],h=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],m=[e[0],e[1],e[2]],u=i;if(i<=.5){let t=(0,n.ag)(l[0],l[1],u),e=(0,n.ag)(l[1],l[2],u);r=(0,n.r)(t,e,u);let i=(0,n.ag)(h[0],h[1],u),s=(0,n.ag)(h[1],h[2],u);o=(0,n.r)(i,s,u);let d=(0,n.ag)(m[0],m[1],u),g=(0,n.ag)(m[1],m[2],u);a=(0,n.ag)(d,g,u)}else{let t=(0,n.ah)(l[0],l[1],u),e=(0,n.ah)(l[1],l[2],u);r=(0,n.ah)(t,e,u);let i=(0,n.ah)(h[0],h[1],u),s=(0,n.ah)(h[1],h[2],u);o=(0,n.ah)(i,s,u);let d=(0,n.ah)(m[0],m[1],u),g=(0,n.ah)(m[1],m[2],u);a=(0,n.ah)(d,g,u)}return r/=a,o/=a,s.setCoords(r,o),fr(t,s),a}function hr(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function mr(t,e,i,s,r){if(r){if(i<0)return void J(new Yn({start:t[0],end:t[0].add(Fs(t,e,0).getUnitVector())}),i,s);if(i>1)return void J(new Yn({start:t[2],end:t[2].add(Fs(t,e,1).getUnitVector())}),i-1,s)}lr(t,e,i,s)}function ur(t,e,i,s){s.setEmpty();let r=[];r.push(new n.E(0,1));let o=.5*Math.max(i.width(),i.height());for(;r.length;){let a=r.at(-1);r.pop();let l=new h;if(Ws(t,e,a,l),l.isIntersectingW(i)){let t=Math.max(l.width(),l.height());if(i.containsW(l)||t<=o||a.width()<1e-12)s.merge(a);else{let t=a.getCenter();r.push(n.E.construct(a.vmin,t)),r.push(n.E.construct(t,a.vmax))}}}}function dr(t){return t[1]/Math.sqrt(t[0]*t[2])}function gr(t,e){let i=Math.sqrt(t[2]/t[0]);return e/(0,n.r)(i,1,e)}function cr(t,e){let i=Math.sqrt(t[0]/t[2]);return e/(0,n.r)(i,1,e)}function _r(t,e,i,o){(0,s.g)(e>=0&&e<=1),(new r.k).setCoordsPoint3D(t[0]),(new r.k).setCoordsPoint3D(t[1]),(new r.k).setCoordsPoint3D(t[2]);let a=new r.k,l=new r.k,h=new r.k;(0,n.aj)(3,t[0],t[1],e,a),(0,n.aj)(3,t[1],t[2],e,l),(0,n.aj)(3,a,l,e,h);let m=t[2].clone();i&&(i[0].assign(t[0]),i[1].assign(a),i[2].assign(h)),o&&(o[0].assign(h),o[1].assign(l),o[2].assign(m))}function pr(t,e,i,r){let o=[t[0],t[1],t[2]];(0,s.g)(e>=0&&e<=1&&i!==r);let a=(0,n.r)(o[0],o[1],e),l=(0,n.r)(o[1],o[2],e),h=(0,n.r)(a,l,e);i&&(i[0]=o[0],i[1]=a,i[2]=h),r&&(r[0]=h,r[1]=l,r[2]=o[2])}function fr(t,e){let i=n.E.constructEmpty();i.vmin=i.vmax=t[0].x,i.mergeNeCoordinate(t[1].x),i.mergeNeCoordinate(t[2].x),e.x=(0,n.a)(e.x,i.vmin,i.vmax),i.vmin=i.vmax=t[0].y,i.mergeNeCoordinate(t[1].y),i.mergeNeCoordinate(t[2].y),e.y=(0,n.a)(e.y,i.vmin,i.vmax)}function yr(t,e){let i=new n.E;i.vmin=i.vmax=t[0].x,i.mergeNeCoordinate(t[1].x),i.mergeNeCoordinate(t[2].x),e[0].x=(0,n.a)(e[0].x,i.vmin,i.vmax),e[1].x=(0,n.a)(e[1].x,i.vmin,i.vmax),e[2].x=(0,n.a)(e[2].x,i.vmin,i.vmax),i.vmin=i.vmax=t[0].y,i.mergeNeCoordinate(t[1].y),i.mergeNeCoordinate(t[2].y),e[0].y=(0,n.a)(e[0].y,i.vmin,i.vmax),e[1].y=(0,n.a)(e[1].y,i.vmin,i.vmax),e[2].y=(0,n.a)(e[2].y,i.vmin,i.vmax)}const Pr=n.aC/180,xr=180/n.aC;function vr(t){let e=t;return e=function(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=(0,n.p)(e,360),e<0&&(e+=360),e)}(e),e>180&&(e-=360),e}function Cr(t){return t*Pr}function br(t){return t*xr}function Er(t){let e=(0,n.av)(),i=t;return i>=-e&&i<2*e?(i<0&&(i+=e),i>=e&&(i-=e),i):(i=(0,n.p)(i,e),i<0&&(i+=e),i)}function Dr(t){let e=(0,n.ak)(),i=t;return i>-e&&i<=e||(i=Er(i),i>e&&(i-=(0,n.av)())),i}function wr(t,e){return vr(e-t)}var Sr=r.V;class Ar extends Q{static type=s.G.enumEllipticArc;m_semiMajorAxis;m_minorMajorRatio;m_rotation;m_cosr;m_sinr;m_center;m_sweepAngle;m_startAngle;m_interior;m_bits;m_cachedValues;constructor(t){if(void 0===t||(0,n.af)(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 n.P(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new n.P(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new n.P(0,0),this.m_interior=new n.P(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 n.P(0,0),this.m_interior=new n.P(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 n.P(0,0),this.m_interior=new n.P(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 At(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,i=!1){return this.constructEllipse(t,1,e,0,i),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,i=!1){let s=n.P.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,s,1,0,!0,i,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,i=!1){let s=n.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(s,t,i),this}constructLineEllipticArc(t,e){return Qr(this,t,e,1),this}constructLineCircularArc(t,e){return Qr(this,t,e,0),this}constructEllipse(t,e,i,s,r=!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);let o=new n.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(s),l=Math.sin(s);return o.rotateDirect(a,l),o.addThis(i),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,s,!0,r,i),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){let t=new a.T;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{let t=new a.T;this.canonicToWorldTransformation(t);let i=t.clone();i.invertPreciseThis(),i.scale(e,e),i.multiply(t),this.applyTransformation(i)}}constructEnclosingCircle(t,e,i=!1){return function(t,e,i,r){0===i&&(0,s.b)("construct_enclosing_circle");let o=[0,0,0],a=function(t,e,i){let s=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&k(t,e)}(e,s),function(t,e,i,s){let r=0,o=[0,0,0],a=0,l=0;for(let h=0;h<3;++h){let m=!1;for(;l<i;){let i=t.at(e[l]),u=1;if(3===r?u=n.P.inCircleRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]),i):2===r?u=n.P.inCircleRobust3Point(t.at(s[0]),t.at(s[1]),i):1===r&&i.equals(t.at(s[0]))&&(u=0),u<=0){if(u<0&&h+1<3){e[a]=(0,n.s)(e[l],e[l]=e[a]);for(let t=0;t<r;t++)if(s[t]===e[l]){o[t]=l;break}a++}l++;continue}m=!0;let d=0;for(let t=0;t<r;t++)o[t]>l&&(s[d]=s[t],o[d]=o[t],d++);r=d,s[r]=e[l],o[r]=l,r++,r<3?l=a:(1===n.P.orientationRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]))&&(s[2]=(0,n.s)(s[0],s[0]=s[2]),o[2]=(0,n.s)(o[0],o[0]=o[2])),l++)}if(!m)break;if(h+1<3){a=0;let i=!1;for(let t=0;t<r;t++)for(let e=t+1;e<r;e++)o[t]>o[e]&&(o[e]=(0,n.s)(o[t],o[t]=o[e]),s[e]=(0,n.s)(s[t],s[t]=s[e]),i=!0);for(let t=0;t<r;t++)e[o[t]]=(0,n.s)(e[t],e[t]=e[o[t]]),o[t]=t;i&&3===r&&1===n.P.orientationRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]))&&(s[2]=(0,n.s)(s[0],s[0]=s[2]),o[2]=(0,n.s)(o[0],o[0]=o[2]))}l=r}return r}(t,s,e,i)}(e,i,o);if(1===a)t.constructCircleRadius(0,e[o[0]],r);else if(2===a){let i=n.P.lerp(e[o[0]],e[o[1]],.5),s=n.P.distance(e[o[0]],i),a=n.P.distance(e[o[1]],i);t.constructCircleRadius(Math.max(s,a),i,r)}else if(3===a){let i=n.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),s=n.P.distance(e[o[0]],i),a=n.P.distance(e[o[1]],i),l=n.P.distance(e[o[2]],i);t.constructCircleRadius(Math.max(s,a,l),i,r)}else(0,s.d)("unexpected")}(this,t,e,i),this}constructThreePointCircle(t,e,i,s=!1){if(!t.equals(e)&&!e.equals(i)&&!t.equals(i)){let r=n.P.calculateCircleCenterFromThreePoints(t,e,i);if(!r.isFinite()||!Number.isFinite(n.P.distance(t,r))){let s=n.P.distance(t,e),r=n.P.distance(t,i);this.constructLineCircularArc(t,s>=r?e:i)}return this.constructCircleCenterAndPoint(r,t,s)}{let r=t.clone(),n=e.clone(),o=i.clone();return r.equals(n)&&n.assign(o),this.constructTwoPointCircle(r,n,s)}}constructCircularArcThreePoint(t,e,i){let s=new n.Z(t.x),r=new n.Z(e.x),o=new n.Z(i.x),a=new n.Z(t.y),l=new n.Z(e.y),h=new n.Z(i.y),m=new n.Z(.5),u=r.subE(s),d=l.subE(a),g=o.subE(s),c=h.subE(a),_=u.mulE(c).subThisE(d.mulE(g));if(_.scaleError(10),_.isZero()){if(!u.isZero()||!d.isZero())return Qr(this,t,e,0),this;{let s=t.clone().addThis(e).mulThis(.5).addThis(i).mulThis(.5),r=i.sub(s).length();this.constructEllipticArcEndPointsCenter(t,e,r,1,0,!0,!1,s),this.m_interior.assign(i)}return this.setProjectionBehavior(0),this}let p=u.sqr().addThisE(d.sqr()).mulThisE(m),f=g.sqr().addThisE(c.sqr()).mulThisE(m),y=p.mulE(c).subThisE(f.mulE(d)),P=u.mulE(f).subThisE(g.mulE(p));y.divThisE(_),P.divThisE(_);let x=y.sqr().addThisE(P.sqr());x.sqrtThis();let v=y.addE(s),C=P.addE(a),b=t.x-v.value(),E=t.y-C.value(),D=Math.atan2(E,b);b=e.x-v.value(),E=e.y-C.value();let w=Math.atan2(E,b);b=i.x-v.value(),E=i.y-C.value();let S=Math.atan2(E,b),A=S-2*(0,n.ak)();for(;A<D;)A+=2*(0,n.ak)();let T=w-2*(0,n.ak)();for(;T<A;)T+=2*(0,n.ak)();let I=S+2*(0,n.ak)();for(;I>D;)I-=2*(0,n.ak)();let M,q=w+2*(0,n.ak)();for(;q>I;)q-=2*(0,n.ak)();M=T-D<D-q?T-D:q-D;let N=new n.P(v.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,x.value(),1,0,Math.abs(M)>(0,n.ak)(),M>0,N),this.m_interior.assign(i),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,i,s){return this.constructEllipticArcGeneral(t,1,e,i,s,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,i,s,r,n,o){return Or(this,t,e,i,s,r,n,o)}constructEllipticArcEndPointsCenter(t,e,i,s,r,n,o,a){return Or(this,t,e,i,s,r,n,o,a)}constructEllipticArcGeneral(t,e,i,s,r,o){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);let a=Dr(o),l=Math.cos(a),h=Math.sin(a),m=new n.P(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=n.P.getNAN(),d=Dr(s);u.x=m.x*Math.cos(d),u.y=m.y*Math.sin(d),u.rotateDirect(l,h),u.addThis(i);let g=(0,n.au)(r,(0,n.av)()),c=g;Math.abs(c)===(0,n.av)()&&(c=0);let _=n.P.getNAN();return _.x=m.x*Math.cos(d+c),_.y=m.y*Math.sin(d+c),_.rotateDirect(l,h),_.addThis(i),this.constructEllipticArcEndPointsCenter(u,_,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(g)>(0,n.ak)(),g>0,i)}constructEllipticArcAsNURB(t,e,i,r){return(r>=1||r<0)&&(0,s.b)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,s.b)("construct_elliptic_arc_as_NURB: control_point"),gn([t,e,i],r*r,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,fn(this),this.afterCompletedModification(),t!==this&&N(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;let e=this.getEndXY().sub(this.getStartXY()).length();return!(this.calculateLength2D()-e>t)}isDegenerateToLine(){return Kr(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){let 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 n.P.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!on(this)}isMajor(){return ln(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return s.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);let e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e);for(let s=Sr.getComponentCount(i);e<s;e++){let e=this.queryInterval(i,0);t.setIntervalEnvelope(i,0,e)}}}else 2===t.m_EnvelopeType?vn(this,n.E.unit(),t):(0,s.a)("3d not impl")}applyTransformation(t){tn(this,t,!1,null,null)}createInstance(){return new Ar}calculateLength2D(){return function(t){if(Kr(t))return 1*n.P.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(-1*t.getSweepAngle())*t.m_semiMajorAxis;let e=Jr(t,0);return Jr(t,1)-e}(this)}queryControlPointsHelper(t){(0,s.d)("")}queryCoord2D(t,e){if(Kr(this))$(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(n.P.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(n.P.construct(this.m_XEnd,this.m_YEnd));else{let i=Zr(this,t),s=new n.P(this.m_semiMajorAxis*Math.cos(i),this.getSemiMinorAxis()*Math.sin(i));s.rotateDirect(this.m_cosr,this.m_sinr),s.addThis(this.m_center),e.assign(s)}}queryCoord2DE(t,e){!function(t,e,i){if(Kr(t))it(new Yn({start:t.getStartXY(),end:t.getEndXY()}),e,i);else if(0===e.value())i.set(t.getStartXY());else if(1===e.value())i.set(t.getEndXY());else{let s=new n.Z;Hr(t,e,s);let r=new n.Z,o=new n.Z;n.Z.st_cosAndSin(s,r,o);let a=g.constructCoordsE(new n.Z(t.m_semiMajorAxis).mulThisE(r),new n.Z(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),l=new n.Z(t.m_rotation);n.Z.st_cosAndSin(l,r,o),a.rotateDirect(r,o),a.addThisE(g.constructPoint2D(t.m_center)),i.setE(a)}}(this,t,e)}queryCoord2DMP(t,e){(0,s.a)("")}getCoordX(t){let e=new n.P;return this.queryCoord2D(t,e),e.x}getCoordY(t){let e=new n.P;return this.queryCoord2D(t,e),e.y}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createEllipticArc();s&&r.dropAllAttributes();let o=0===t&&1===e;if(o&&!s)return void this.copyTo(r);let a=n.P.getNAN();this.queryCoord2D(t,a);let l=n.P.getNAN();if(this.queryCoord2D(e,l),!o)if(a.equals(l))e-t>.5&&this.isMajor()&&this.isClosed()?(o=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&a.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&l.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),o=0===t&&1===e,o&&!s)return void this.copyTo(r);if(r.m_center.assign(this.m_center),r.m_semiMajorAxis=this.m_semiMajorAxis,r.m_minorMajorRatio=this.m_minorMajorRatio,r.m_interior.assign(this.m_interior),r.m_rotation=this.m_rotation,r.m_cosr=this.m_cosr,r.m_sinr=this.m_sinr,r.m_sweepAngle=this.m_sweepAngle,r.m_startAngle=this.m_startAngle,r.m_bits=this.m_bits,E(r,a.x,a.y),w(r,l.x,l.y),o)return void sn(r,Wr(this));r.m_startAngle=Zr(this,t),r.m_sweepAngle=Zr(this,e)-r.m_startAngle,r.m_startAngle=zr(r.m_startAngle),an(r,Math.abs(r.m_sweepAngle)>(0,n.ak)()),s&&r.assignVertexDescription(this.m_description),fn(r),kr(r);let h=this.m_description.getAttributeCount();if(h>1&&!s){for(let e=1;e<h;e++){let i=this.m_description.getSemantics(e),s=Sr.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<h;t++){let i=this.m_description.getSemantics(t),s=Sr.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}r.afterCompletedModification()}queryDerivative(t,e){!function(t,e,i){if(Kr(t))i.setE(g.constructPoint2D(t.getEndXY()).subE(g.constructPoint2D(t.getStartXY())));else{let s=new n.Z;Hr(t,e,s);let r=new g;if(r.setCoordsE(new n.Z(t.m_semiMajorAxis).negate().mulE((new n.Z).setSin(s)),new n.Z(t.getSemiMinorAxis()).mulE((new n.Z).setCos(s))),t.m_rotation){let e=new n.Z(t.m_rotation);r.rotateDirect((new n.Z).setCos(e),(new n.Z).setSin(e))}r.scaleThis(new n.Z(t.getSweepAngle())),i.setE(r)}}(this,t,e)}cutArcIgnoreAttributes(t,e,i){let s=0===t&&1===e,r=new n.P;this.queryCoord2D(t,r);let o=new n.P;this.queryCoord2D(e,o),s||(r.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(s=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&r.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),s=0===t&&1===e)),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,E(i,r.x,r.y),w(i,o.x,o.y),s?sn(i,Wr(this)):(i.m_startAngle=Zr(this,t),i.m_sweepAngle=Zr(this,e)-i.m_startAngle,i.m_startAngle=zr(i.m_startAngle),an(i,Math.abs(i.m_sweepAngle)>Math.PI),fn(i),i.afterCompletedModification())}changeEndPoints2D(t,e){Ur(this,t,e,!1)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,i);if(1===t)return this.getEndAttributeAsDbl(e,i);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=Sr.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(o,a,l,r,Sr.getDefaultValue(e))}getClosestCoordinate(t,e){return Cn(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,i=-1){return Cn(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,s.b)("");let i=this.getSemiAxes(),r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),o=r+(0,n.ak)(),a=(0,n.c)(3,NaN),l=0;if(a[0]=Gr(this,r),a[0]>0&&a[0]<1&&l++,a[1]=Gr(this,o),a[1]>0&&a[1]<1&&(a[l]=a[1],l++),0===l)return 0;a[l]=1,l++,(0,s.g)(t.length>=l);let h=0;for(let i=0;i<l;i++){let s=a[i];this.queryCut(h,s,t[i],e),h=s}return l}getMonotonicParts(t,e){if(t.length<4&&(0,s.b)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;let i=this.getSemiAxes(),r=(0,n.c)(4,NaN);r[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r[1]=r[0]+(0,n.ak)(),r[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),r[3]=r[2]+(0,n.ak)();let o=(0,n.c)(5,NaN),a=0;for(let t=0;t<4;t++)o[a]=Gr(this,r[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,n.ai)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,s.g)(t.length>=a);let l=0;for(let i=0;i<a;i++){let s=o[i];this.queryCut(l,s,t[i],e),l=s}return a}intersectionWithAxis2D(t,e,i,s){if(Kr(this))return new Yn({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,i,s);let r,o,a=new n.Z(e),l=this.getSemiAxes();if(t){if(e>this.m_center.y+l.x||e<this.m_center.y-l.x)return 0;r=new n.Z(l.x).mulThis(this.m_sinr),o=new n.Z(l.y).mulThis(this.m_cosr),a.subThis(this.m_center.y)}else{if(e>this.m_center.x+l.x||e<this.m_center.x-l.x)return 0;r=new n.Z(l.x).mulThis(this.m_cosr),o=new n.Z(l.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}let h=r.sqr(),m=o.sqr(),u=h.addE(m),d=o.mulE(a).mulThis(-2),g=a.sqr().subThisE(h),c=d.sqr().subThisE(u.mulE(g).mulThis(4)),_=r.mulE(a).mulThis(-2),p=a.sqr().subThisE(m),f=_.sqr().subThisE(u.mulE(p).mulThis(4)),y=c.eps()*Math.abs(f.value())<=f.eps()*Math.abs(c.value());y?r.isZero()&&(y=!1):o.isZero()&&(y=!0),y||(d.setE(_),g.setE(p));let P=(0,n.d)(n.Z,2),x=Lt(u,d,g,n.E.construct(-1,1),!1,P);if(0===x)return 0;let v=[0,0],C=0;for(let t=0;t<x;t++){let e=new n.Z,i=new n.Z;y?(e.setE(P[t]),i.setE(a.subE(o.mulE(P[t])).divThisE(r))):(i.setE(P[t]),e.setE(a.subE(r.mulE(P[t])).divThisE(o)));let s=Gr(this,Math.atan2(e.value(),i.value()));s>=0&&s<=1&&(v[C]=s,C++)}return x=C,0===x?0:(2===x&&v[0]>v[1]&&(v[1]=(0,n.s)(v[0],v[0]=v[1])),s&&(0,n.f)(s,v,0,0,x),i&&(i[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),x>1&&(i[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!s&&i[0]>i[1]&&(i[1]=(0,n.s)(i[0],i[0]=i[1])))),x)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0];return-1===this.intersectionWithAxis2D(!0,t,i,null)?e:i[0]}isCurve(){return!0}isDegenerate(t){return P(this,t)}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new n.E(0,1),t):(0,s.a)("3d not impl")}clone(t){let e=new Ar;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Kr(this))return 0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.construct(this.getStartY(),this.getEndY());let t,i=this.getSemiAxes();t=0===e?Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr):Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr);let s=t+Math.PI,r=[0,0];r[0]=Gr(this,t),r[1]=Gr(this,s);let o=0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.construct(this.getStartY(),this.getEndY()),a=new n.P;for(let t=0;t<2;t++){let i=r[t];i>0&&i<1&&(this.queryCoord2D(i,a),o.mergeNeCoordinate(0===e?a.x:a.y))}return o}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=new n.E(0,1);if(i.intersect(t),i.isEmpty())return void e.setEmpty();if(Kr(this))return e.setCoords(this.getCoord2D(i.vmin)),void e.mergeNe(this.getCoord2D(i.vmax));let s=this.getCoord2D(i.vmin),r=this.getCoord2D(i.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*i.width()<=n.l){let t=n.P.lerp(s,r,.5),i=t.sub(this.m_center);return i.normalize(),t=t.add(i.mul(.5*n.P.distance(s,r))),e.setCoords(s),e.mergeNe(r),void e.mergeNe(t)}vn(this,i,e)}tToLength(t){return Kr(this)?t*n.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Jr(this,t)}parametricAngleToT(t){return Gr(this,t)}tToParametricAngle(t){return Zr(this,t)}lengthToT(t){if(Kr(this)){let e=n.P.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){let e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return function(t,e){if(Kr(t)){let i=n.P.distance(t.getStartXY(),t.getEndXY());return 0===i?0:e/i}if(1===t.m_minorMajorRatio){let i=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===i?0:e/i}if(0===e)return 0;let i=t.getSweepAngle();if(0===i)return.5;let s=jr(t),r=(0,n.an)(),o=$r(t);i<0&&(e=-e);let a=e/t.m_semiMajorAxis+o,l=(0,n.ax)(a,s.e2,s.completeE);return l-=r,l-=t.getStartAngle(),l/i}(this,t)}calculateWeightedAreaCentroid2D(t){if(Kr(this)){let t=new n.P;return t.setCoords(0,0),t}let e=pn(this),i=this.getStartXY().sub(this.m_center),s=this.getEndXY().sub(this.m_center),r=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,l=new n.P;l.x=r*o*(r*this.m_cosr*(-Math.sin(a)+Math.sin(this.m_startAngle))+o*(-Math.cos(a)+Math.cos(this.m_startAngle))*this.m_sinr)/3,l.y=r*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+r*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;let h=s.add(i).mul(s.crossProduct(i)/6);return l.x-=h.x,l.y-=h.y,l.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){let t=new n.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Kr(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,i=this.m_startAngle+this.m_sweepAngle;if(i<e){let t=e;e=i,i=t}let s=Math.sin(e),r=Math.sin(i),o=Math.cos(e),a=Math.cos(i);if(1===this.m_minorMajorRatio){let e=this.getSemiMajorAxis(),i=e*e,n=i*(r-s),l=i*(o-a);t.setCoords(n,l)}else{let e=this.getSemiMajorAxis(),i=this.getSemiMinorAxis(),n=e*e,l=i*i,h=e*i,m=n-l,u=m/l,d=m/n,g=Math.sqrt(u),c=Math.sqrt(d),_=.5*h*(Math.asinh(g*r)/g+r*Math.sqrt(1+u*r*r))-.5*h*(Math.asinh(g*s)/g+s*Math.sqrt(1+u*s*s)),p=-.5*h*(Math.asin(c*a)/c+a*Math.sqrt(1-d*a*a))- -.5*h*(Math.asin(c*o)/c+o*Math.sqrt(1-d*o*o));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,i){if(i&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Kr(this)){let i=n.P.distance(t,this.m_center),s=this.getSemiAxes();if(i<s.x-e||i>s.y+e)return!1}let s=this.getClosestCoordinate(t,!1),r=new n.P;return this.queryCoord2D(s,r),n.P.distance(r,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}getTangent(t){if(Kr(this))return this.getEndXY().sub(this.getStartXY());{let e=Zr(this,t),i=new n.P;return i.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&i.rotateDirect(this.m_cosr,this.m_sinr),i.scale(this.getSweepAngle()),i}}getDerivative(t){if(Kr(this))return this.getEndXY().sub(this.getStartXY());{let e=Zr(this,t),i=new n.P;return i.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&i.rotateDirect(this.m_cosr,this.m_sinr),i.scale(this.getSweepAngle()),i}}normalizeAfterEndpointChange(){return!!hn(this)&&(Kr(this)?(mn(this),!1):un(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){let e=new n.P(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){let e=new n.P(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){let e=Zr(this,t),i=new n.P,s=this.getSemiMinorAxis();i.setCoords(-this.m_semiMajorAxis*Math.sin(e),s*Math.cos(e));let r=new n.P;r.setCoords(-this.m_semiMajorAxis*Math.cos(e),-s*Math.sin(e)),this.m_rotation&&(i.rotateDirect(this.m_cosr,this.m_sinr),r.rotateDirect(this.m_cosr,this.m_sinr));let o=i.sqrLength();if(0===o)return NaN;let a=Math.sqrt(o);return i.divThis(a),i.crossProduct(r)/o}getMonotonicPartParams(t,e){let i=(0,n.c)(6,NaN);i[0]=0;let r=1;if(this.isDegenerateToLine())i[1]=1,r=2;else{let t=this.getSemiAxes(),e=(0,n.c)(4,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]=(0,n.al)());for(let t=0;t<4;t++){let s=Gr(this,e[t]);s>0&&s<1&&(i[r]=s,r++)}r>2&&(0,n.ai)(i,r),i[r]=1,r++}if(e){t<r&&(0,s.b)("");for(let t=0;t<r;t++)e[t]=i[t]}return r}calculateLowerLength2D(){let t=n.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;let e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){let t=n.P.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;let 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=(0,n.s)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.s)(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]=(0,n.s)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle+=this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Kr(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,rn(t)}calculateArea2DHelper(){return pn(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)),Kr(this))return;let i=this.getSemiAxes(),s=(0,n.c)(8,NaN);{let t=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),e=t+Math.PI,r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),n=r+Math.PI;s[0]=Gr(this,t),s[1]=Gr(this,e),s[2]=Gr(this,r),s[3]=Gr(this,n)}{let t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,r=Math.atan2(-i.y*t,i.x*e),n=r+Math.PI,o=Math.atan2(i.y*e,i.x*t),a=o+Math.PI;s[4]=Gr(this,r),s[5]=Gr(this,n),s[6]=Gr(this,o),s[7]=Gr(this,a)}let r=n.P.getNAN();for(let i=0;i<8;i++){let n=s[i];t.containsExclusiveCoordinate(n)&&(this.queryCoord2D(n,r),e.mergeNe(r))}}setSegmentFromCoordsForStitcher(t,e){!function(t,e,i){let s=0===t.projectionBehavior();if(i<=2)return void Qr(t,e[0],e[i-1],+!s);if(s){t.constructCircularArcThreePoint(e[0],e[i-1],e[Math.trunc(i/2)]);let s=new n.P;return t.queryCoord2D(.5,s),void t.m_interior.setCoordsPoint2D(s)}let r=t.getSemiMajorAxis(),o=t.getMinorMajorRatio(),a=t.getAxisXRotation(),l=t.getCenter(),h=[,,,,];h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];let m=[,,,,];m[0]=t.isClockwise(),m[1]=m[0],m[2]=!m[0],m[3]=!m[0];let u=Math.trunc(i<5?1:(i+4)/5),d=(0,n.d)(Ar,4),g=(0,n.c)(4,NaN),c=0;for(let t=0;t<4;t++){d[t].constructEllipticArcEndPointsCenter(e[0],e[i-1],r,o,a,h[t],m[t],l),g[t]=0;let s=0;for(let r=u;r<i-1;r+=u){let i=d[t].getClosestCoordinate(e[r],!1);g[t]+=n.P.sqrDistance(d[t].getCoord2D(i),e[r]),s++}g[t]/=s,g[t]<g[c]&&(c=t)}t.assignCopy(d[c])}(this,t,e)}writeInBufferStream(t,e){let i=new Float64Array(10);return i[0]=this.m_bits,i[1]=this.m_semiMajorAxis,i[2]=this.m_minorMajorRatio,i[3]=this.m_rotation,i[4]=this.m_center.x,i[5]=this.m_center.y,i[6]=this.m_sweepAngle,i[7]=this.m_startAngle,i[8]=this.m_interior.x,i[9]=this.m_interior.y,t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(10);t.queryRange(e,i.length,i,!0,1),this.m_bits=i[0],this.m_semiMajorAxis=i[1],this.m_minorMajorRatio=i[2],this.m_rotation=i[3],this.m_center.x=i[4],this.m_center.y=i[5],this.m_sweepAngle=i[6],this.m_startAngle=i[7],this.m_interior.x=i[8],this.m_interior.y=i[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(0,s.d)("should not1; be called"),0}ensureXYMonotone(){if(Kr(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return Qr(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;let t=(0,n.d)(n.P,3),e=dn(this,t);if(Os(t)){let i=!1;if(0===this.projectionBehavior()){let s=new o.Envelope2D;s.setCoords({pt:t[0]}),s.mergeNe(t[2]);let r=new n.P;r.setSub(t[2],t[0]),r.leftPerpendicularThis(),r.normalize(),r.scale(n.P.distance(t[2],t[0]));let a=n.P.lerp(t[2],t[0],.5),l=a.sub(r),h=a.add(r);s.clipLine(l,h);let m=n.P.getClosestCoordinate(l,h,t[1],!1);t[1]=n.P.lerp(l,h,m);let u=t[2].sub(t[1]),d=t[0].sub(t[1]),g=u.crossProduct(d),c=u.dotProduct(d);e=(0,n.an)()-Math.abs(.5*Math.atan2(g,c)),i=!0}return gn(t,e*e,null,i,this),!0}return!1}setCoordsForIntersector(t,e,i){Ur(this,t,e,i)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){let 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,sn(e,Wr(this))}reverseImpl(){nn(this,!on(this)),kr(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&fn(this)}equalsImpl(t){let e=t;if(this.m_bits!==e.m_bits||this.m_semiMajorAxis!==e.m_semiMajorAxis||this.m_minorMajorRatio!==e.m_minorMajorRatio||!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN())||this.m_rotation!==e.m_rotation||!this.m_interior.equals(e.m_interior))return!1;let i=e.m_sweepAngle;if(this.m_sweepAngle!==i)return!1;let s=e.m_startAngle;return this.m_startAngle===s}equalsImplTol(t,e){let i=t;if(this.m_bits!==i.m_bits)return!1;if(this.m_center.isNAN()&&i.m_center.isNAN())return!0;if(this.m_center.isNAN()!==i.m_center.isNAN()||!this.getSemiAxes().isEqualPoint2D(i.getSemiAxes(),e)||!this.m_center.isEqualPoint2D(i.m_center,e))return!1;let s=Math.abs(Cr(vr(br(this.m_rotation-i.m_rotation)))),r=Math.abs((0,n.ak)()-s),o=Math.min(s,r);if(this.m_semiMajorAxis*Math.abs(o)>e)return!1;let a=this.getCoord2D(.5),l=i.getCoord2D(.5);return!!a.isEqualPoint2D(l,e)}swapImpl(t){let e=t;this.m_center=(0,n.s)(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=(0,n.s)(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,n.s)(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,n.s)(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=(0,n.s)(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=(0,n.s)(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=(0,n.s)(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=(0,n.s)(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,n.s)(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=(0,n.s)(e.m_bits,e.m_bits=this.m_bits),function(t,e){e.m_cachedValues=(0,n.s)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){mn(this),rn(this)}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){if(e.length<2&&(0,s.r)(""),Kr(this))return new Yn({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,i);{let e=n.P.distance(t,this.m_center);if(e>this.m_semiMajorAxis+i||e<this.getSemiMinorAxis()-i)return 0}let r=this.getClosestCoordinate(t,!1),o=n.P.getNAN();return this.queryCoord2D(r,o),n.P.distance(o,t)<=i?(0,n.a9)(r,0,1)&&(this.queryCoord2D(+(0===r),o),n.P.distance(o,t)<=i)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=r),1):0}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}endPointModified(){this.m_bits|=8,rn(this)}clearEndPointModified(){mn(this)}}function Tr(t,e,i,s,r,o){return new qr(0,0,0,null,!1,(0,n.i)()).densifyEx(t,e,i,s,!1,o)}function Ir(t,e,i,r,o,a,l,h){a&&(a.length=0),l&&(l.length=0);let m=t.getGeometryType();if(m===s.G.enumLine)return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(n.P.getNAN()),a.push(t.getEndXY())),l&&(l.push(0),l.push(1)),1;if(m===s.G.enumBezier){if(!r)return a&&(a.push(t.getStartXY()),a.push(t.getControlPoint1()),a.push(t.getControlPoint2()),a.push(t.getEndXY())),l&&(l.push(0),l.push(1)),1;let e=(0,n.c)(9,NaN),s=t.getMonotonicPartParams(e.length,e);if(e.length=s,s=Nr(t,i,e),2===s&&o&&(e[1]=.5,e.push(1),s=3),l&&l.splice(0,0,...e.slice(0,s)),a){let i=new Xn;for(let r=1;r<s;r++){let s=e[r-1],n=e[r];t.queryCut(s,n,i,!0);let o=i.get();Gi(o),1===r&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getControlPoint2()),a.push(o.getEndXY())}}return s-1}if(m===s.G.enumEllipticArc){let h=t;if(h.isDegenerateToLine()||h.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(n.P.getNAN()),a.push(t.getEndXY())),l&&(l.push(0),l.push(1)),1;if(r&&(o||!h.isMonotoneQuickAndDirty())){let m=(0,n.c)(6,NaN),u=h.getMonotonicPartParams(m.length,m);m.length=u,u=Nr(t,i,m),2===u&&o&&(m[1]=.5,m.push(1),u=3);let d=0;if(u>2){let t=new Xn,n=l||[],o=0;for(let g=1;g<u;g++){let c=m[o],_=m[g];if(h.queryCut(c,_,t,!0),t.get().isDegenerate(0))continue;let p=n.length,f=Rr(1===g,t.get(),e,i,r,a,l);(0,s.g)(f>0),d+=f;let y=g===u-1,P=m[o],x=t.get().getSweepAngle()/h.getSweepAngle();for(let t=p,e=n.length;t<e;t++)if(n[t]=!y||t+1<e?P+n[t]*x:1,a){let e=3*t,i=h.getCoord2D(n[t]);a[e].setCoordsPoint2D(i),e>0&&Zi(a.slice(e-3))}o=g}return d}}return Rr(!0,h,e,i,r,a,l)}if(m===s.G.enumRationalBezier2){let s=t;if(r&&(o||!s.isMonotoneQuickAndDirty())){let r=(0,n.c)(6,NaN),h=s.getMonotonicPartParams(r.length,r);r.length=h,h=Nr(t,i,r),2===h&&o&&(r[1]=.5,r.push(1),h=3);let m=0;if(h>2){let t=new Xn,n=l||[];for(let o=1;o<h;o++){let u=r[o-1],d=r[o];s.queryCut(u,d,t,!0);let g=n.length;m+=Yr(1===o,t.get(),e,i,!1,a,l);let c=o===h-1,_=r[o-1];for(let t=g,e=n.length;t<e;t++)if(n[t]=!c||t+1<e?_+n[t]:1,a){let e=3*t,i=s.getCoord2D(n[t]);a[e].setCoordsPoint2D(i),e>0&&Be(a.slice(e-3))}}return m}}return Yr(!0,s,e,i,r,a,l)}if(m===s.G.enumBezier2){let s=t,h=(0,n.d)(n.P,3);s.queryControlPoints(h);let m=new vs;m.constructFromQuadratic(h);let u=Ir(m,e,i,r,o,a,l);if(null!=a&&null!=l)for(let t=1,e=0;t<u;++t,e+=3){let i=new n.P;s.queryCoord2D(l[t],i);let o=a[e+3];i.equals(o)||(a[e+3].setCoordsPoint2D(i),r&&Zi(a.slice(e,e+4)))}return u}(0,s.a)("")}function Mr(t,e,i,r,o,a,l,h,m){let u=t.getGeometryType();if(a&&(a.length=0,l.length=0),h&&(h.length=0),u===s.G.enumEllipticArc){let e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(t.getEndXY()),l.push(NaN),l.push(NaN),l.push(NaN)),h&&(h.push(0),h.push(1)),1}let d,g=(0,n.c)(9,NaN);if(o)d=t.getMonotonicPartParams(g.length,g),g.length=d,d=Nr(t,i,g);else{if(d=2,g[0]=0,g[1]=1,u===Ar.type){let e=t.getSweepAngle();e>.9*Math.PI&&(Math.min(3,Math.trunc(e/(2*Math.PI/3)+.5))>2?(g[0]=0,g[1]=1/3,g[2]=2/3,g[3]=1,d=4):(g[0]=0,g[1]=.5,g[2]=1,d=3))}else(0,s.g)(u===Ut.type);g.length=d}if(2===d&&r&&(g[1]=.5,g.push(1),d=3),a){let e=new Xn,i=1;for(;i<d;){let r=g[i-1],h=g[i];t.queryCut(r,h,e,!0);let m=(0,n.d)(n.P,3),c=[1,1,1];if(u===s.G.enumEllipticArc){let t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){let t=(h-r)/3;g.splice(i,0,r+t),g.splice(i+1,0,r+2*t),d+=2;continue}c[1]=dn(t,m)}else{let t=e.get();t.queryControlPoints(m),t.queryWeights(c)}o&&Os(m),1===i&&(a.push(m[0].clone()),l.push(c[0])),a.push(m[1].clone()),a.push(m[2].clone()),l.push(c[1]),l.push(c[2]),i++}}return h&&(h.length=d,(0,n.f)(h,g,0,0,d)),d-1}class qr{m_maxLength;m_maxDeviation;m_maxAngle;m_cosMaxAngle;m_minStep;m_maxSegmentsPerCurve;m_segmentBuffer=null;m_dummyPoint=new r.P;m_progressTracker;m_progressCounter=0;m_bSetDensifyFlag;m_bOnlyCurveDensify;static constructDefault(t){return new qr(0,0,0,t,!1,(0,n.i)())}constructor(t,e,i,r,o,a){this.m_progressTracker=r,this.m_bSetDensifyFlag=o,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=i>(0,n.an)()?(0,n.an)():i,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=a,(0,s.D)(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,i,r,o,a){return this.m_maxLength=e,this.m_maxDeviation=i,this.m_maxAngle=r>(0,n.an)()?(0,n.an)():r,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,s.D)(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;let e=t.getGeometryType();return(0,s.k)(e)?t:(0,s.j)(e)?this.densifyMultiPath(t):(0,s.h)(e)?this.densifySegmentImpl(t):e===s.G.enumEnvelope?this.densifyEnvelope(t):void(0,s.d)("")}densifySegmentEx(t,e,i,r,n){let o=t.getGeometryType();if(!(this.m_maxLength>0)&&(!this.m_bOnlyCurveDensify||o===s.G.enumLine)&&(!r||i))return void(e?o===s.G.enumLine?e.addSegment(t,i):(i&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(i&&n.push(0),n.push(1)));if(o===s.G.enumBezier)return void this.densifyCubicBezier(t,e,i,r,n);if(o===s.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,i,r,n);if(o===s.G.enumBezier2)return void this.densifyBezier2(t,e,i,r,n);if(o===s.G.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,i,r,n);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,i,r,n)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}let e=t.createInstance();e.getGeometryType()===s.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());let i=t.getImpl().querySegmentIterator();for(;i.nextPath();){let t=!0;for(;i.hasNextSegment();){let s=i.nextSegment(),r=i.isClosingSegment();this.densifySegmentEx(s,e,t,r,null),r&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){let e=new Dt({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){let e=new ni({vd:t.getDescription()});e.addEnvelope(t,!1);let i=o.Envelope2D.constructEmpty();t.queryEnvelope(i);let s=i.width(),r=i.height();return!(this.m_maxLength>0)||s<=this.m_maxLength&&r<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;let e=t.createInstance();e.getGeometryType()===s.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());let i=e.getImpl(),r=t.getImpl(),o=r.getAttributeStreamRef(0),a=new Yn;for(let t=0,s=r.getPathCount();t<s;t++){let s=r.isClosedPath(t);if(0===r.getPathSize(t))continue;let l=r.getPathStart(t),h=o.readPoint2D(2*l),m=h.clone();i.startPath(h);for(let s=l+1,h=r.getPathEnd(t);s<h;s++){let t=o.readPoint2D(2*s),r=n.P.distance(m,t);if(r>this.m_maxLength){let e=Math.ceil(r/this.m_maxLength);e>(0,n.i)()&&(e=(0,n.i)());let s,o,l,h=1/e;m.compare(t)<0?(a.setStartXY(m),a.setEndXY(t),s=0,o=1):(a.setStartXY(t),a.setEndXY(m),s=e-2,o=-1);for(let t=0,r=e-1;t<r;t++,s+=o){this.progress_(),l=h*(s+1);let t=new n.P;a.queryCoord2D(l,t),i.lineTo(t),this.m_bSetDensifyFlag&&i.setAttributeNoCurves(10,i.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),m.assign(t)}if(s){let t=n.P.distance(m,h);if(t>this.m_maxLength){let e=h,s=Math.ceil(t/this.m_maxLength);s>(0,n.i)()&&(s=(0,n.i)());let r,o,l=1/s;m.compare(e)<0?(a.setStartXY(m),a.setEndXY(e),r=0,o=1):(a.setStartXY(e),a.setEndXY(m),r=s-2,o=-1);let u,d=new n.P(0,0);for(let t=0,e=s-1;t<e;t++,r+=o)this.progress_(),u=l*(r+1),a.queryCoord2D(u,d),i.lineTo(d),this.m_bSetDensifyFlag&&i.setAttributeNoCurves(10,i.getPointCount()-1,0,1)}i.closePathWithLine()}}return e}densifySegmentByLength(t,e,i,r,o,a){(0,s.g)(t.getGeometryType()!==s.G.enumBezier);let l=t.getStartXY().compare(t.getEndXY());0===l&&e<1&&(t.getGeometryType()===s.G.enumEllipticArc?l=t.getSweepAngle()<0?1:-1:(0,s.a)("densify segment by length"));let h=0;if(r&&(i?(t.queryStart(this.m_dummyPoint),i.startPathPoint(this.m_dummyPoint)):a.push(0),++h),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||=new Xn;let s=Math.ceil(1/e);s>(0,n.i)()&&(s=(0,n.i)()),e=1/s,this.m_segmentBuffer.create(t.getGeometryType());let r,o,m=t;l<0?(r=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),r=s-2,o=-1,m=this.m_segmentBuffer.get());let u,d=s-1;for(let t=0;t<d;t++,r+=o)u=e*(r+1),i?(m.queryCoord(u,this.m_dummyPoint),i.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==u&&0!==u&&i.setAttribute(10,i.getPointCount()-1,0,1)):a.push(l>0?1-u:u),this.progress_();u=1,h+=d}(!o||o&&r&&h<2)&&(i?(t.queryEnd(this.m_dummyPoint),i.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,i,s,r){let o=new vs,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());if(0===h&&l>0){let e=(0,n.d)(n.P,4);t.queryControlPoints(e),h=e[1].compare(e[2]),0===h&&(h=e[1].compare(e[0]))}h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=[],d=[],g=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=!0,_=0;if(h>0)for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),d.push(0);u.length;){this.progress_();let t=u.at(-1),o=d.at(-1),l=t[4].x,h=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){c&&=(_=a.findMinDeriv(),!1);let e=.5*(l+h);Math.abs(_-e)<.4*(h-l)&&(e=_);let i=(e-l)/(h-l),s=t[0].mul(1-i).add(t[1].mul(i)),r=t[1].mul(1-i).add(t[2].mul(i)),m=t[2].mul(1-i).add(t[3].mul(i)),g=s.mul(1-i).add(r.mul(i)),p=r.mul(1-i).add(m.mul(i)),f=g.mul(1-i).add(p.mul(i)),y=t[3];t[1]=s,t[2]=g,t[3]=f,t[4].setCoords(l,e);let P=[f,p,m,y,new n.P(e,h)];u.push(P),d[d.length-1]=o+1,d.push(o+1);continue}u.pop(),d.pop(),(u.length>0||!s||s&&i&&m<2)&&(e?(a.queryCoord(l,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==l&&0!==l&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(1-l),++m)}else for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),d.push(0);u.length;){this.progress_();let t=u.at(-1),o=d.at(-1),l=t[4].x,h=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){c&&=(_=a.findMinDeriv(),!1);let e=.5*(l+h);Math.abs(_-e)<.4*(h-l)&&(e=_);let i=(e-l)/(h-l),s=t[0].mul(1-i).add(t[1].mul(i)),r=t[1].mul(1-i).add(t[2].mul(i)),m=t[2].mul(1-i).add(t[3].mul(i)),g=s.mul(1-i).add(r.mul(i)),p=r.mul(1-i).add(m.mul(i)),f=g.mul(1-i).add(p.mul(i)),y=t[0];t[0]=f,t[1]=p,t[2]=m,t[4].setCoords(e,h);let P=[y,s,g,f,new n.P(l,e)];u.push(P),d[d.length-1]=o+1,d.push(o+1);continue}u.pop(),d.pop(),(u.length>0||!s||s&&i&&m<2)&&(e?(a.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)):r.push(h),++m)}}densifyRationalBezier2(t,e,i,s,r){let o=new Ut,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=0),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),d=new Ut,g=[],c=[];for(g.push(new n.E(0,1)),c.push(0);g.length;){this.progress_();let t=g.at(-1).clone(),o=c.at(-1);if(o<u&&this.rationalBezier2NeedsSplit(a,d,t.vmin,t.vmax)){let e=t.getCenter();h>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),c[c.length-1]=o+1,c.push(o+1);continue}if(g.pop(),c.pop(),g.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}densifyBezier2(t,e,i,s,r){let o=new Qt,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=0),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),d=new Qt,g=[],c=[];for(g.push(new n.E(0,1)),c.push(0);g.length;){this.progress_();let t=g.at(-1).clone(),o=c.at(-1);if(o<u&&this.bezier2NeedsSplit(a,d,t.vmin,t.vmax)){let e=t.getCenter();h>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),c[c.length-1]=o+1,c.push(o+1);continue}if(g.pop(),c.pop(),g.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}densifyEllipticArc(t,e,i,s,r){let o=new Ar,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=+!t.isClockwise()),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),d=new Ar,g=[],c=[];for(g.push(new n.E(0,1)),c.push(0);g.length;){this.progress_();let t=g.at(-1).clone(),o=c.at(-1);if(o<u&&this.ellipticArcNeedsSplit(a,d,t.vmin,t.vmax)){let e=t.getCenter();h>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),c[c.length-1]=o+1,c.push(o+1);continue}if(g.pop(),c.pop(),g.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}calculateLengthSubdivisionStep(t,e){let i=t.calculateUpperLength2D();if(!t.isCurve())return i?e/i:1;if(t.getGeometryType()===s.G.enumEllipticArc){let s=t;if(s.isCircular()||s.isDegenerate(0)||s.isDegenerateToLine()){let t=e/i;return t<this.m_minStep&&(t=this.m_minStep),t}return e/i*s.getSemiAxes().y/s.getSemiAxes().x}t.getGeometryType()===s.G.enumBezier&&(0,s.a)(""),(0,s.a)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===s.G.enumEllipticArc){let i=t;if(i.isDegenerate(0)||i.isDegenerateToLine())return 1;{let s=i.getSemiMajorAxis(),r=1-e/s,n=Math.PI/2;if(r>0){let t=4*Math.sqrt(e/s*.5);n=Math.min(Math.PI/2,Math.abs(t))}n=Math.max(n,2*Math.PI/this.m_maxSegmentsPerCurve);let o=n*s;return this.calculateLengthSubdivisionStep(t,o)}}(0,s.a)("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===s.G.enumEllipticArc){let i=t;return i.isDegenerate(0)||i.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*i.getSemiMinorAxis())}(0,s.a)("")}rationalBezier2NeedsSplit(t,e,i,s){t.cutBezierIgnoreAttributes(i,s,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;let o=(0,n.d)(n.P,3);e.queryControlPoints(o);let a=[0,0,0];return e.queryWeights(a),!r&&this.m_maxDeviation>0&&(r=!qr.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!qr.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),r}bezier2NeedsSplit(t,e,i,s){t.cutBezierIgnoreAttributes(i,s,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;let o=(0,n.d)(n.P,3);return e.queryControlPoints(o),!r&&this.m_maxDeviation>0&&(r=!qr.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!qr.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),r}ellipticArcNeedsSplit(t,e,i,s){t.cutArcIgnoreAttributes(i,s,e);let r=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(r=!0,!0):(!r&&this.m_maxDeviation>0&&(r=!qr.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!qr.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),r)}bezierNeedsSplit(t){let e=!1;return this.m_maxLength>0&&n.P.distance(t[0],t[1])+n.P.distance(t[1],t[2])+n.P.distance(t[2],t[3])>this.m_maxLength?(e=!0,!0):(!e&&this.m_maxDeviation>0&&(e=!qr.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!qr.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){let i=t[3].sub(t[0]);if(i.sqrLength()>0){let s=i.clone();s.leftPerpendicularThis(),s.normalize();let r=s.dotProduct(t[0].sub(t[1])),o=s.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(r),Math.abs(o))<=e){let e=new n.P;Ui(t,.5,e,!1);let s=e.sub(t[0]).dotProduct(i);return s>=0&&s<=i.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]));let i=t[3].sub(t[0]);i.normalize();{let s=t[1].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}{let s=t[2].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}{let s=t[2].sub(t[1]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,i){if(0===e[1])return!1;let s=t[2].sub(t[0]);if(s.sqrLength()>0){let e=s.clone();e.leftPerpendicularThis(),e.normalize();let r=e.dotProduct(t[0].sub(t[1]));if(Math.abs(r)<=i){let e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=i*i}static checkRationalBezier2MaxAngle(t,e,i){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);let s=t[2].sub(t[0]);s.normalize();{let e=t[1].sub(t[0]),r=e.dotProduct(s);if(r<0||e.length()*i>r)return!1}return!0}static checkBezier2MaxDeviation(t,e){let i=t[2].sub(t[0]);if(i.sqrLength()>0){let s=i.clone();s.leftPerpendicularThis(),s.normalize();let r=s.dotProduct(t[0].sub(t[1]));if(Math.abs(r)<=e){let e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.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]);let i=t[2].sub(t[0]);i.normalize();{let s=t[1].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){let i=t.getEndXY().sub(t.getStartXY()),r=[0,0];if(1===function(t,e,i){(0,s.g)(!Kr(t));let r=new a.T;r.setRotateAngle(-t.getAxisXRotation());let o=new n.P;r.queryTransform(e,o);let l=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),h=l+(0,n.ak)(),m=Gr(t,l),u=Gr(t,h);u<m&&(u=(0,n.s)(m,m=u));let d=0;return m>=0&&m<=1&&(i[d++]=m),u>=0&&u<=1&&(i[d++]=u),d}(t,i,r)){let i=t.getCoord2D(r[0]),s=n.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),i),o=new n.P;return(0,n.J)(t.getStartXY(),t.getEndXY(),s,o),n.P.distance(i,o)<=e}}let i=t.getCoord2D(.5),r=new n.P;return(0,n.J)(t.getEndXY(),t.getStartXY(),.5,r),n.P.distance(i,r)<=e}static checkEllipticArcMaxAngle(t,e){let i=t.getTangent(0),s=t.getTangent(1),r=i.dotProduct(s);return!(r<0||i.length()*s.length()*e>r)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==s.G.enumEllipticArc||t.isCircular())}}function Nr(t,e,i){let s=i.length;if(e<=0||s<=2)return s;let r=0,o=(0,n.c)(s-1,NaN);for(let e=1,n=s;e<n;e++){let s=t.tToLength(i[e]);o[e-1]=s-r,r=s}for(;o.length>1;){let t=o.findIndex(t=>t<=2*e);if(-1===t)break;let s=t+1,r=t+1;if(t>0){let e=t-1;(r===o.length||o[e]>o[r])&&(r=e,s--)}o[r]+=o[t],o.splice(t,1),i.splice(s,1)}return i.length}function Rr(t,e,i,s,r,l,h,m){let u=e.clone();u.dropAllAttributes();let d=(t,e,i,s)=>(e&&(t&&e.push(s.getStartXY()),e.push(n.P.getNAN()),e.push(n.P.getNAN()),e.push(s.getEndXY())),i&&(t&&i.push(0),i.push(1)),1);if(u.isDegenerateToLine()||u.isDegenerate(0))return d(t,l,h,e);let g=u.getStartXY(),c=u.getEndXY(),_=u.getSemiAxes(),p=new a.T;if(u.isCircular())p.setIdentity();else{let t=u.getAxisXRotation();p.setScaleCoords(1,u.getMinorMajorRatio()),p.rotateAngle(t)}let f=u.getCenter();p.shift(f);let y=p.clone();y.invertThis(),u.applyTransformation(y);let P=u.getSweepAngle();if(0===P)return d(t,l,h,e);let x=o.Envelope2D.constructEmpty();x.setCoords({center:f,width:2*_.x,height:2*_.x});let v=.05*x.calculateToleranceFromEnvelope(),C=4*(Math.max(i/_.x,v/_.x)/.0741)**(1/6);C=Math.min(C,Math.PI/2);let b=Er(u.getStartAngle()),E=P>0?Math.floor(b/C):Math.ceil(b/C);E*=C;let D=P>0?C:-C;E+D===b&&(E+=D);let w=4/3*Math.tan(Math.abs(C)/4);P>0&&(w=-w),h&&t&&h.push(0);let S=C/Math.abs(P),A=(E-b)/P,T=g.clone(),I=new n.P;u.queryCoord2D(0,I);let M=I.clone(),q=1-.01*S,N=0,R=0;for(;A<1;){let i;if(A+=S,R>0&&A<q)i=w;else{A>=q&&(A=1);let t=(A-R)*P;i=4/3*Math.tan(Math.abs(t)/4),P>0&&(i=-i)}u.queryCoord2D(A,I);let o=new n.P;p.queryTransform(I,o);let a=e.getClosestCoordinate(o,!1);if(e.queryCoord2D(a,o),1!==A&&(n.P.distance(T,o)<=2*s||n.P.distance(o,c)<=2*s))continue;T.setCoordsPoint2D(o);let m=(0,n.d)(n.P,4);m[0].assign(M),m[3].assign(I),m[1].rightPerpendicularOther(M),m[1].scaleAddThis(i,M),m[2].leftPerpendicularOther(I),m[2].scaleAddThis(i,I),p.transformPoints2D(m,3,m),m[3].assign(o),0===R&&m[0].setCoordsPoint2D(g),1===A&&m[3].setCoordsPoint2D(c),r&&Zi(m);let d=!0;for(let t=1;t<4;t++)if(!m[t].isEqualPoint2D(m[0])){d=!1;break}d||(h&&h.push(a),l&&(0===R&&t&&l.push(m[0].clone()),l.push(m[1].clone()),l.push(m[2].clone()),l.push(m[3].clone())),N++),R=A,M.setCoordsPoint2D(I)}return N}function Yr(t,e,i,s,r,a,l,h){e.clone().dropAllAttributes();let m=new o.Envelope2D;e.queryLooseEnvelope(m);let u=.05*m.calculateToleranceFromEnvelope(),d=Math.max(i,u);l&&t&&l.push(0);let g=0,c=(0,n.d)(n.P,3);e.queryControlPoints(c);let _=[0,0,0];e.queryWeights(_);let p=[],f=(0,n.c)(9,NaN),y=0;r?(y=e.getMonotonicPartParams(f.length,f),f.length=y,y=Nr(e,s,f)):(f.length=2,y=2,f[0]=0,f[1]=1);let P=0,x=t;for(let t=1;t<y;t++){let e=f[t];for(p.length=0,p.push(e),p.push(P);p.length>1;){let t=p.at(-1);p.pop();let e=p.at(-1),i=(0,n.d)(n.P,3),s=[0,0,0];Ks(c,_,t,e,i,s);let r=(0,n.d)(n.P,4),o=Js(i,s,r),h=p.length>16;d>=o||h?(l.push(e),a&&(x&&=(a.push(r[0]),!1),a.push(r[1]),a.push(r[2]),a.push(r[3])),g++):(p.push(.5*(t+e)),p.push(t))}P=e}return g}class Xr{m_arc;m_sqrChordLength;constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?n.P.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function Fr(t,e){return t.convertToCanonic(e)}function Lr(t,e,i,s){let r=t.m_startAngle,o=t.m_sweepAngle,a=1e-12;for(;r>(0,n.ak)();)r-=2*(0,n.ak)();for(;r<=-(0,n.ak)();)r+=2*(0,n.ak)();if(!Number.isNaN(e)){for(;e>(0,n.ak)();)e-=2*(0,n.ak)();for(;e<=-(0,n.ak)();)e+=2*(0,n.ak)();!i&&e>r&&(e-=2*(0,n.ak)()),i&&e<r&&(e+=2*(0,n.ak)()),o=e-r,Math.abs(o)<a&&!s&&(o=i?2*(0,n.ak)():-2*(0,n.ak)()),Math.abs(o)>2*(0,n.ak)()-a&&s&&(o=0)}Math.abs(o)>2*(0,n.ak)()-a&&(o=o>=0?2*(0,n.ak)():-2*(0,n.ak)(),t.setEndXY(t.getStartXY())),Math.abs(o)<a&&(o=0,t.setEndXY(t.getStartXY())),s=Math.abs(o)<=(0,n.ak)(),o&&(i=o>0),t.m_startAngle=zr(r),t.m_sweepAngle=o,an(t,!s),nn(t,i)}function zr(t){let e=t,i=!1;return e<=-(0,n.ak)()?(e+=(0,n.av)(),i=!0):e>(0,n.ak)()&&(e-=(0,n.av)(),i=!0),e<=-(0,n.ak)()?(e=(0,n.p)(e,(0,n.av)()),e<=-(0,n.ak)()&&(e+=(0,n.av)()),i=!0):e>(0,n.ak)()&&(e=(0,n.p)(e,(0,n.av)()),e>(0,n.ak)()&&(e-=(0,n.av)()),i=!0),i&&(e>(0,n.ak)()||e<=-(0,n.ak)())&&(e=(0,n.ak)()),e}function Vr(t,e,i){let s=i,r=s.getSemiAxes(),o=new n.P(r.x*Math.cos(t[0]),r.y*Math.sin(t[0]));return o=s.convertFromCanonic(o),n.P.sqrDistance(o,s.getStartXY())}function Br(t,e,i){let s=i,r=s.getSemiAxes(),o=t[0]+s.getStartAngle(),a=new n.P(r.x*Math.cos(o),r.y*Math.sin(o));return a=s.convertFromCanonic(a),n.P.sqrDistance(a,s.getEndXY())}function kr(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);let e=t.getStartXY(),i=t.getEndXY(),s=e.equals(i),r=ln(t),o=on(t),a=t.projectionBehavior();if(s){let i=t.convertToCanonic(e),s=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=s.x,i.y/=s.y,t.m_startAngle=zr(Math.atan2(i.y,i.x)),t.m_sweepAngle=r?o?(0,n.av)():-(0,n.av)():0}else{let s=t.convertToCanonic(e),l=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=l.x,s.y/=l.y;let h=t.convertToCanonic(i);h.x/=l.x,h.y/=l.y,t.m_startAngle=Math.atan2(s.y,s.x),t.m_sweepAngle=n.P.calculateAngle(s,h),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,n.av)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,n.av)()),t.m_startAngle=zr(t.m_startAngle);let m=Vr([t.m_startAngle],0,t);if(m=Math.sqrt(m),m>.25*R(t)){let e=t.m_startAngle-1e-4,i=t.m_startAngle+1e-4,s=[0];Nt(Vr,t,1,[t.m_startAngle],[e],[i],0,s),t.m_startAngle=zr(s[0])}if(m=Br([t.m_sweepAngle],0,t),m=Math.sqrt(m),m>.25*R(t)){let e=t.m_sweepAngle-1e-4,i=t.m_sweepAngle+1e-4,s=[0];Nt(Br,t,1,[t.m_sweepAngle],[e],[i],0,s),t.m_sweepAngle=s[0]}let u=Math.abs(t.m_sweepAngle)>(0,n.ak)();if(an(t,u),r!==u&&!r&&Math.abs(t.m_sweepAngle)>1.5*(0,n.ak)())return void Qr(t,e,i,a);if(0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void Qr(t,e,i,a)}}function Gr(t,e){return(function(t,e){let i=new n.E(t.getStartAngle(),t.getEndAngle());i.normalize();let s=(0,n.av)(),r=(0,n.p)(e,s);if(r<i.vmin){let t=r+s;for(;t<i.vmin;)t+=s;return i.containsCoordinate(t)?t:i.vmin-r<t-i.vmax?r:t}if(r>i.vmax){let t=r-s;for(;t>i.vmax;)t-=s;return i.containsCoordinate(t)||i.vmin-t<r-i.vmax?t:r}return r}(t,e)-t.getStartAngle())/t.getSweepAngle()}function Zr(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Hr(t,e,i){i.assign(new n.Z(t.m_startAngle).addE(e.mulE(new n.Z(t.m_sweepAngle))))}function Wr(t){return t.m_cachedValues}function jr(t){if(t.m_cachedValues)return t.m_cachedValues;let e={e2:0,completeE:0};return e.e2=function(t){return 1-(0,n.e)(t.m_minorMajorRatio)}(t),e.completeE=(0,n.aB)(e.e2),t.m_cachedValues=e,e}function Ur(t,e,i,s){if(!e.isEqual(t.m_XStart,t.m_YStart)||!i.isEqual(t.m_XEnd,t.m_YEnd)){if(Kr(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,fn(t),void t.afterCompletedModification();if(s&&Math.abs(t.getSweepAngle())<=1.01*(0,n.an)()){let s=(0,n.d)(n.P,3),r=dn(t,s);if(js(s)){if(s[0].assign(e),s[2].assign(i),Os(s),0!==t.projectionBehavior())gn(s,r*r,null,!1,t);else{let e=0,i=2;n.P.sqrDistance(s[1],s[0])<n.P.sqrDistance(s[1],s[2])&&(i=(0,n.s)(e,e=i));let r=s[i].sub(s[e]),o=r.length();r.divThis(o);let a=s[1].sub(s[e]),l=a.length(),h=a.dotProduct(r)/l,m=a.crossProduct(r)/l,u=new n.P;(0,n.J)(s[e],s[i],.5,u);let d=.5*o/m*(0,n.a)(1-h,0,1),g=s[1].side(s[e],s[i]),c=r.clone();g?c.leftPerpendicularThis():c.rightPerpendicularThis();let _=u.sub(c.mul(d));t.constructCircularArcThreePoint(s[0],s[2],_)}return}}0===t.projectionBehavior()?function(t,e,i){let s=t.getStartXY(),r=t.getEndXY(),o=s.equals(r),l=e.equals(i);if(!o&&!l){let o=new a.T;o.setShiftCoords(-t.m_XStart,-t.m_YStart);let l=n.P.distance(e,i),h=n.P.distance(s,r),m=l/h;o.scale(m,m);let u=r.sub(s);u.divThis(h);let d=i.sub(e);d.divThis(l);let g=u.crossProduct(d),c=d.dotProduct(u);return o.rotate(c,g),o.shiftCoords(e.x,e.y),void tn(t,o,!0,e,i)}let h=new n.P;if(t.queryCoord2D(.5,h),l){if(o){let r=t.m_center.add(e.sub(s));t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),r),t.setProjectionBehavior(0)}else if(t.isMajor()){let s=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,i,s)}else t.constructCircularArcThreePoint(e,i,e);return}let m=e.add(i).mul(.5),u=i.sub(e);u.rightPerpendicularThis();let d=m.add(u),g=n.P.getClosestCoordinate(m,d,t.getCenter(),!0),c=new n.P;(0,n.J)(m,d,g,c);let _=n.P.distance(e,c);t.constructEllipticArcEndPointsCenter(e,i,_,1,0,!0,!t.isClockwise(),c),t.setProjectionBehavior(0)}(t,e,i):En(t,e,i)}}function Or(t,e,i,s,r,n,o,a,l){return t.m_bits=0,t.m_rotation=n,b(t,e),D(t,i),t.m_cosr=Math.cos(n),t.m_sinr=Math.sin(n),an(t,o),nn(t,a),void 0===l?t.m_center.setNAN():t.m_center.assign(l),t.setProjectionBehavior(1),t.m_semiMajorAxis=s,t.m_minorMajorRatio=r,un(t,void 0===l)}function Qr(t,e,i,s){t.m_bits=0,t.m_rotation=0,b(t,e),D(t,i),t.m_interior.assign(e.add(i).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,an(t,!1),nn(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(s),t.afterCompletedModification()}function Kr(t){return t.m_center.isNAN()}function Jr(t,e){if(0===e)return 0;let i=jr(t),s=Zr(t,e),r=(0,n.an)(),o=$r(t),a=(0,n.aw)(s+r,i.e2,i.completeE),l=t.m_semiMajorAxis*(a-o);return Math.abs(l)}function $r(t){let e=jr(t);return(0,n.aw)(t.getStartAngle()+(0,n.an)(),e.e2,e.completeE)}function tn(t,e,i,r,o){if(2===e.m_TransformationType)return void(0,s.g)(0);if((0,s.g)(!hn(t)),e.isIdentity()&&(!r||r.equals(t.getStartXY())&&o.equals(t.getEndXY())))return;rn(t);let a=n.P.getNAN(),l=n.P.getNAN();if(null===r?(a.x=t.m_XStart,a.y=t.m_YStart,e.transformInPlace(a),l.x=t.m_XEnd,l.y=t.m_YEnd,e.transformInPlace(l)):(a=r,l=o),Kr(t))return t.m_XStart=a.x,t.m_YStart=a.y,t.m_XEnd=l.x,void(t.m_YEnd=l.y);let h=t.m_center.clone();if(e.transformInPlace(h),i||e.isUniformNoRotation()){let i=on(t);if(e.isReflective()&&(i=!i),0===t.projectionBehavior()){if(!a.equals(l)){let i=t.m_interior.clone();return e.transformInPlace(i),void t.constructCircularArcThreePoint(a,l,i)}return void en(t,a,l,h,i,!1)}let s=new n.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(s);let r=Math.atan2(s.y,s.x),o=t.getSemiAxes();e.transformWithoutTranslateInPlace(o);let m=t.m_center.clone();return e.transformInPlace(m),void t.constructEllipticArcEndPointsCenter(a,l,o.x,o.y/o.x,r,t.isMajor(),i,m)}{{let i=[,,,,];!function(t,e){let i=new n.Z(t.m_cosr).sqrThis(),s=new n.Z(t.m_sinr).sqrThis(),r=new n.Z(t.m_minorMajorRatio),o=new n.Z(1/t.m_minorMajorRatio),a=r.mulE(i).addThisE(o.mulE(s)),l=r.subE(o).mulThis(2*t.m_cosr*t.m_sinr),h=r.mulE(s).addThisE(o.mulE(i));e[0]=a,e[1]=l,e[2]=h,e[3]=new n.Z(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,i);let s=new c;if(s.a11.setE(i[0]),s.a12.setE(i[1]),s.a12.mulThisByPower2(.5),s.a21.setE(s.a12),s.a22.setE(i[2]),!s.det().isZero()){let r=new c;if(r.a11.set(e.xx),r.a12.set(e.xy),r.a21.set(e.yx),r.a22.set(e.yy),r.invertThis()){let o=r.clone();o.transposeThis();let m=s.clone();if(m.mulThis(r),m.mulLeftThis(o),!m.det().isZero()){let s=(0,n.d)(n.Z,4);s[0].setE(m.a11),s[1].setE(m.a12),s[1].mulThisByPower2(2),s[2].setE(m.a22),s[3].setE(i[3]);let r=n.P.getNAN(),o=function(t,e){let i=new c;i.a11.setE(t[0]),i.a12=n.Z.st_mulByPower2(t[1],.5),i.a21.setE(i.a12),i.a22.setE(t[2]);let s=[n.P.getNAN(),n.P.getNAN()],r=[new n.Z,new n.Z];i.eigenSymmetric(r,s);let o=t[3].clone();return o.negateThis(),o.invThis(),r[0].mulThisE(o),r[1].mulThisE(o),r[0].sqrtThis().invThis(),r[1].sqrtThis().invThis(),e.x=r[0].toDouble(),e.y=r[1].toDouble(),Math.atan2(s[0].y,s[0].x)}(s,r),u=on(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(a,l,r.x,r.y/r.x,o,t.isMajor(),u,h)}}}}let i=[n.P.getNAN(),n.P.getNAN(),n.P.getNAN()];i[0].setCoords(t.getSemiMajorAxis(),0),i[0].rotateDirect(t.m_cosr,t.m_sinr),i[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),i[1].rotateDirect(t.m_cosr,t.m_sinr),i[2].setCoords(0,t.getSemiMinorAxis()),i[2].rotateDirect(t.m_cosr,t.m_sinr);let s=t.isClockwise();s&&(i[2]=(0,n.s)(i[0],i[0]=i[2])),e.transformWithoutTranslateArray(i,3,i),e.isReflective()&&(s=!s);let r=new n.P(0,0),o=t.createInstance();gn(i,.5,r,!1,o),t.constructEllipticArcEndPointsCenter(a,l,o.getSemiMajorAxis(),o.getMinorMajorRatio(),o.getAxisXRotation(),t.isMajor(),!s,h)}}function en(t,e,i,s,r,n){let o=.5*(s.sub(e).length()+s.sub(i).length());t.m_center.assign(s),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x),Lr(t,Math.atan2(i.y-t.m_center.y,i.x-t.m_center.x),r,n);let a=t.constructEllipticArcEndPointsCenter(e,i,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,s);return t.setProjectionBehavior(0),a}function sn(t,e){t.m_cachedValues=e}function rn(t){t.m_cachedValues=null}function nn(t,e){let i=+!!e;t.m_bits=-2&t.m_bits|i}function on(t){return!!(1&t.m_bits)}function an(t,e){let i=+!!e;t.m_bits=-3&t.m_bits|i<<1}function ln(t){return!!(2&t.m_bits)}function hn(t){return!!(8&t.m_bits)}function mn(t){t.m_bits&=-9}function un(t,e){mn(t);let i=t.getStartXY(),r=t.getEndXY(),o=!1,a=ln(t),l=on(t),h=t.projectionBehavior(),m=i.equals(r),u=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,s.o)("NAN minor major ratio and non-zero major axis")),u||=e?m:t.m_center.isNAN(),u)return Qr(t,i,r,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);let d=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if((0,s.g)(d.y>0&&d.x>=d.y),m){let e=t.convertToCanonic(i);(0,s.g)(!d.isZero()),e.x/=d.x,e.y/=d.y;let r=Math.sqrt((0,n.e)(e.x)+(0,n.e)(e.y));if(o=1!==r,t.m_semiMajorAxis*=r,d.mulThis(r),t.m_startAngle=zr(Math.atan2(e.y,e.x)),!a)return t.m_interior.assign(i),t.m_sweepAngle=0,t.afterCompletedModification(),o;t.m_sweepAngle=l?(0,n.av)():-(0,n.av)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;let e=new g;e.setWithEps(t.getStartXY(),8),e.subThisE((new g).setWithEps(t.m_center,8));let i=new n.Z;i.setWithEps(t.m_rotation,8);let s=new n.Z,r=new n.Z;n.Z.st_cosAndSin(i,s,r),e.rotateReverse(s,r);let o=new g;o.setWithEps(t.getEndXY()),o.subThisE(g.constructPoint2D(t.m_center)),o.rotateReverse(s,r);let a=new n.Z;a.setWithEps(t.m_semiMajorAxis,8);let l=a.clone(),h=new n.Z;h.setWithEps(t.m_minorMajorRatio),l.mulThisE(h),e.x.divThisE(a),e.y.divThisE(l),o.x.divThisE(a),o.y.divThisE(l);let m=e.x.sqr().addThisE(e.y.sqr()).subThisE(n.a7),u=o.x.sqr().addThisE(o.y.sqr()).subThisE(n.a7);return!m.isZero()||!u.isZero()}(t);if(!e){let s=t.convertToCanonic(i);s.x/=d.x,s.y/=d.y;let o=new n.P(1,0);t.m_startAngle=n.P.calculateAngle(o,s);let a=t.convertToCanonic(r);a.x/=d.x,a.y/=d.y,t.m_sweepAngle=n.P.calculateAngle(s,a),e=!_n(t)}if(e){o=!0;let e=i.sub(r).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let s=(0,n.e)(e.x/d.x)+(0,n.e)(e.y/d.y);s>1&&(s=Math.sqrt(s),t.m_semiMajorAxis*=s,d.mulThis(s));let h=new n.P(0,0);{let t=d.x*d.x,i=d.y*d.y,s=t*e.y*e.y+i*e.x*e.x,r=t*i-s;if(r>0){let t=Math.sqrt(r/s);h.setCoords(d.x*e.y/d.y,-d.y*e.x/d.x),h.mulThis(t),a===l&&h.negateThis()}}{let e=new n.P(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(i.add(r).mulThis(.5)),t.m_center.assign(e)}}if(kr(t),!_n(t))return Qr(t,i,r,h),!0}return fn(t),t.afterCompletedModification(),o}function dn(t,e){(0,s.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);let i,r=t.getSemiMajorAxis(),o=t.getSemiMinorAxis();if(0===r)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),i=1,i;if(0===o)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=n.P.lerp(e[0],e[2],.5),i=1,i;let a=t.getSweepAngle(),l=t.getStartAngle(),h=l+a,m=new n.P(-r*Math.sin(l),o*Math.cos(l)),u=new n.P(-r*Math.sin(h),o*Math.cos(h));m.normalize(),u.normalize(),m.rotateDirect(t.m_cosr,t.m_sinr),u.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);let d=m.crossProduct(u);return e[1].assign(m.mul(e[1].crossProduct(u)/d)),e[1].addThis(e[0]),i=Math.cos(.5*a),i}function gn(t,e,i,r,o){if(r){let i=.5,s=Math.sqrt(e),r=(0,n.e)(.5)+2*s*i*.5+(0,n.e)(i),a=t[0].mul((0,n.e)(.5)).add(t[1].mul(2*s*i*.5)).add(t[2].mul((0,n.e)(i))).divThis(r);return o.constructCircularArcThreePoint(t[0],t[2],a),!0}let a=t[0].sub(t[1]),l=t[2].sub(t[1]),h=a.crossProduct(l),m=a.dotProduct(l),u=e;(0,s.g)(u<=1),(0,s.g)(u>0);let d=.5/(1-u),g=a.sqrLength(),c=m,_=l.sqrLength(),p=(0,n.e)(h),f=a.sub(l).sqrLength();if(0===p||m<=-Math.sqrt(g)*Math.sqrt(_))return Qr(o,t[0],t[2],1),!1;let y=[0,0],P=new n.E;P.setInfinite();let x=Mt(2*p,-(f/u+4*c),2*(1-u)/u,P,!1,y);if(0===x)return Qr(o,t[0],t[2],1),!1;1===x&&(y[1]=y[0]);let v=Math.sqrt(d/y[0]),C=Math.sqrt(d/y[1]),b=.5/u,E=b-_*y[0],D=b-g*y[0];Math.abs(E)>Math.abs(D)?D=c*y[0]-b+1:E=c*y[0]-b+1;let w=a.mul(E).add(l.mul(D)),S=w.norm(1)<1e-15*v?0:Math.atan2(w.y,w.x)+Math.PI,A=a.add(l),T=i?i.clone():t[1].add(A.mul(d)),I=t[0].sub(T),M=t[2].sub(T),q=I.crossProduct(M)<0;return new Ar,o.constructEllipticArcEndPointsCenter(t[0],t[2],v,C/v,S,!1,!q,T)}function cn(t,e,i,s,r){return gn(t,e,i,s,r)}function _n(t){let e=R(t),i=!1;{let s=new n.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center),i=n.P.distance(t.getStartXY(),s)>e}let s=!1;if(!i){let i=new n.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));i.rotateDirect(t.m_cosr,t.m_sinr),i.addThis(t.m_center),s=n.P.distance(t.getEndXY(),i)>e}return!i&&!s}function pn(t){if(Kr(t)||t.isDegenerate(0))return 0;let e=t.m_semiMajorAxis,i=t.getSemiMinorAxis(),s=e*e+i*i,r=t.getStartAngle(),n=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,l=t.m_sinr,h=1,m=0;t.m_rotation&&(h=(a-l)*(a+l),m=2*a*l);let u=((-.5*(n-r)+.25*h*(2*Math.cos(n+r)*Math.sin(n-r)))*i+-2*Math.sin(.5*(n+r))*Math.sin(.5*(n-r))*a*o)*e/s,d=0;return t.m_rotation&&(d=-2*Math.sin(n+r)*Math.sin(n-r)*.125*m-i*o/s*(2*Math.cos(.5*(n+r))*Math.sin(.5*(n-r)))*l),s*(u+d)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function fn(t){t.queryCoord2D(.5,t.m_interior)}function yn(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(y(e,i))return 1;return 0===Pn(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}function Pn(t,e,i,r,o,a,l,h,m,u){if(Kr(e))return ot(new Yn({start:e.getStartXY(),end:e.getEndXY()}),i,r,o,a,l,h,u);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0);let d=Y(e,i);if(X(e,i,l=Math.max(d,l)))return 0;let g=i.getStartXY();g.subThis(e.m_center);let c=i.getEndXY();c.subThis(e.m_center),g.rotateReverse(e.m_cosr,e.m_sinr),c.rotateReverse(e.m_cosr,e.m_sinr);let _=c.clone();_.subThis(g);let p=e.m_semiMajorAxis,f=1/p,y=e.getSemiMinorAxis(),P=1/y,x=_.clone();x.leftPerpendicularThis();let v=Math.atan2(y*x.y,p*x.x),C=(0,n.c)(16,NaN),b=(0,n.c)(16,NaN),E=0,D=[v,v+Math.PI];for(let t=0;t<2;++t){let s=Gr(e,D[t]);if(s>=0&&s<=1){C[E]=s;let t=e.getCoord2D(C[E]);b[E]=i.getClosestCoordinate(t,!1),n.P.distance(t,i.getCoord2D(b[E]))<=l&&E++}}let w=g.x*f,S=g.y*P,A=_.x*f,T=_.y*P,I=Mt(A*A+T*T,2*(w*A+S*T),w*w+S*S-1,n.E.unit(),!1,b);(0,s.g)(I>=0);for(let t=0;t<I;t++){let s=_.mul(b[t]).add(g);s.x*=f,s.y*=P;let r=Gr(e,Math.atan2(s.y,s.x));if(r>=0&&r<=1){C[E]=r;let t=e.getCoord2D(r);b[E]=i.getClosestCoordinate(t,!1),n.P.distance(t,i.getCoord2D(b[E]))<=l&&E++}}(0,s.g)(E<C.length+4);let M=(0,n.c)(16,NaN);I=e.intersectPoint(i.getStartXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=M[t],b[E]=0;I=e.intersectPoint(i.getEndXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=M[t],b[E]=1;I=i.intersectPoint(e.getStartXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=0,b[E]=M[t];I=i.intersectPoint(e.getEndXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=1,b[E]=M[t];return 0===E?0:Mn(t,e,i,C,b,E,r,o,a,l,h,0,u)}function xn(t,e,i,r,o,a,l,h,m,u){if(Kr(e))return Pn(t,i,new Yn({start:e.getStartXY(),end:e.getEndXY()}),r,a,o,l,h,0,!u);if(Kr(i))return Pn(t,e,new Yn({start:i.getStartXY(),end:i.getEndXY()}),r,o,a,l,h,0,u);let d=Y(e,i);l=Math.max(l,d);let g=!1;{let t=e.getSemiAxes(),r=e.getCenter(),u=i.getSemiAxes(),d=i.getCenter(),c=n.P.distance(d,r),_=t.x+u.x;if(c>_+l)return 0;if(t.y>u.x){if(c+u.x+l<t.y)return 0}else if(u.y>t.x&&c+t.x+l<u.y)return 0;if(m&&!h){let r=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),n=1===i.m_minorMajorRatio&&i.isClosed()&&i.isMajor();if(r&&n&&(g=!0,c<=_&&Math.max(t.x,u.x)<=Math.min(t.x,u.x)+c))return(0,s.g)(!o&&!a),1}}if(!g&&X(e,i,l))return 0;let c=[],_=[],p=Mr(e,0,0,!1,!1,c,_,null),f=[],y=[],P=Mr(i,0,0,!1,!1,f,y,null);if(1===p&&1===P){let t=new Ut({points:c,weights:_}),s=new Ut({points:f,weights:y}),d=[],g=[],p=rr(!1,t,s,r,null===o?null:d,null===a?null:g,l,h,m,u);if(p>0&&null!==o||null!==a){o&&(o.length=0),a&&(a.length=0);for(let r=0;r<p;++r){if(o)if((0,n.a9)(d[r],0,1))o.push(d[r]);else{let i=t.tToLength(d[r]),s=e.lengthToT(i);o.push(s)}if(a)if((0,n.a9)(g[r],0,1))a.push(g[r]);else{let t=s.tToLength(g[r]),e=i.lengthToT(t);a.push(e)}}}return p}let x=[],v=[],C=0,b=m&&!h;for(let t=0;t<p;t++){let s=new Ut({points:c.slice(2*t,2*t+3),weights:_.slice(2*t,2*t+3)}),r=0;for(let o=0;o<P;o++){v.length<=o&&v.push(new Ut({points:f.slice(2*o,2*o+3),weights:y.slice(2*o,2*o+3)}));let a=[],h=[],m=b?null:a,u=b?null:h,d=rr(!1,s,v[o],null,m,u,l,!1,b,!1);if(d>0&&b)return 1;for(let l=0;l<d;++l){if(0===a[l]&&0===t)a[l]=0;else if(1===a[l]&&t===p-1)a[l]=1;else{let t=s.tToLength(a[l])+C,i=e.lengthToT(t);a[l]=i}if(0===h[l]&&0===o)h[l]=0;else if(1===h[l]&&o===P-1)h[l]=1;else{let t=v[o].tToLength(h[l])+r,e=i.lengthToT(t);h[l]=e}x.push((0,n.o)(a[l],h[l]))}r+=v[o].calculateLength2D()}C+=s.calculateLength2D()}if(0===x.length)return 0;if(h&&(x=x.filter(t=>!(0,n.a9)(t.first,0,1)||!(0,n.a9)(t.second,0,1)||!e.getCoord2D(t.first).equals(i.getCoord2D(t.second)))),m)return x.length;let E=[],D=[];for(let t of x)E.push(t.first),D.push(t.second);return Mn(t,e,i,E,D,E.length,r,o,a,l,h,0,u)}function vn(t,e,i){if(i.setCoords(t.getCoord2D(e.vmin)),i.mergeNe(t.getCoord2D(e.vmax)),Kr(t))return;let s=t.getSemiAxes(),r=[0,0,0,0];{let e=Math.atan2(-s.y*t.m_sinr,s.x*t.m_cosr),i=e+Math.PI,n=Math.atan2(s.y*t.m_cosr,s.x*t.m_sinr),o=n+Math.PI;r[0]=Gr(t,e),r[1]=Gr(t,i),r[2]=Gr(t,n),r[3]=Gr(t,o)}let o=new n.P;for(let s=0;s<4;s++){let n=r[s];e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,o),i.mergeNe(o))}}function Cn(t,e,i,r,o){if(0===t.m_semiMajorAxis)return i.vmin;let a=n.P.getNAN();t.queryCoord2D(i.vmin,a);let l=n.P.getNAN();if(t.queryCoord2D(i.vmax,l),Kr(t))return new Yn({start:a,end:l}).getClosestCoordinate(e,r);let h=Fr(t,e);if(a=Fr(t,a),l=Fr(t,l),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return i.vmin;let e=Gr(t,Math.atan2(h.y,h.x));return r||i.containsCoordinate(e)?e:n.P.distance(h,a)<=n.P.distance(h,l)?i.vmin:i.vmax}let m=t.getSemiMajorAxis(),u=t.getSemiMinorAxis(),d=(m-u)*(m+u),g=(0,n.e)(d),c=h.x,_=h.y,p=(0,n.e)(u*_),f=u*d*_*2,y=[new n.Z(p),new n.Z(f),new n.Z(g-(0,n.e)(m*c)-p),new n.Z(-f),new n.Z(-g)],P=(0,n.d)(n.Z,4),x=Vt(y,4,new n.E(-1,1),!1,P,4),v=i.vmin,C=n.P.sqrDistance(h,a);{let t=n.P.sqrDistance(h,l);t<C&&(v=i.vmax,C=t)}(0,s.g)(!r);let b=(0,n.c)(8,NaN);for(let e=0;e<x;++e){let i=P[e].value(),s=Math.sqrt(1-i*i),r=Math.atan2(i,s),n=Math.atan2(i,-s);b[2*e]=Gr(t,r),b[2*e+1]=Gr(t,n)}b=b.slice(0,2*x),(0,n.w)(b);for(let s=0,r=2*x;s<r;++s)if(b[s]>i.vmin&&b[s]<i.vmax){let i=n.P.sqrDistance(e,t.getCoord2D(b[s]));C>i&&(C=i,v=b[s])}return v}function bn(t,e,i){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)&&(i?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise())}function En(t,e,i,r){let o=t.getStartXY(),l=t.getEndXY(),h=o.equals(l),m=e.equals(i);if(!h&&!m){let s=new a.T;return s.initializeFromTwoPoints(o,l,e,i),tn(t,s,!0,e,i),t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void Qr(t,e,i,1);if(h&&m){let s=t.m_center.add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),s)}if(!h){let s=.5*((0,n.av)()-Math.abs(t.getSweepAngle())),r=(t.getSweepAngle()+s*(0,n.h)(t.getSweepAngle()))/t.getSweepAngle(),o=new n.P;t.queryCoord2D(r,o),t.constructEllipticArcEndPointsCenter(o,o,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());let a=t.getCenter().add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),a)}let u=n.P.sqrDistance(e,i),d=.25,g=.75;if(u<n.P.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){let e=[0],i=It(new Xr(t,u),n.E.construct(0,.25),1,e);i>0&&((0,s.g)(1===i),d=e[0],g=1-e[0])}let c=t.getCoord2D(d),_=t.getCoord2D(g);(0,s.g)(!c.equals(_)),t.constructEllipticArcEndPointsCenter(c,_,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),En(t,e,i)}function Dn(t,e,i,s,r){return wn(t,!1,e,i,s,r)}function wn(t,e,i,r,n,o){let a=i.getGeometryType(),l=r.getGeometryType(),h=Math.max(n,Y(i,r));if(a===s.G.enumLine&&l===s.G.enumLine)return nt(i,r,h,o);let m=i,u=r,d=i.getStartXY(),g=i.getEndXY();if(d.compare(g)>0&&(m=i.clone().reverse()),d=r.getStartXY(),g=r.getEndXY(),d.compare(g)>0&&(u=r.clone().reverse()),e){if(i.equals(r))return 2;if(function(t,e,i){return(0,s.g)(t.isCurve()||e.isCurve()),!!(t.getStartXY().equals(e.getStartXY())&&C(t,e,0,0,i,2,[0,0],[0,0])||t.getEndXY().equals(e.getEndXY())&&C(t,e,1,1,i,2,[0,0],[0,0])||t.getStartXY().equals(e.getEndXY())&&C(t,e,0,1,i,2,[0,0],[0,0])||t.getEndXY().equals(e.getStartXY())&&C(t,e,1,0,i,2,[0,0],[0,0]))}(i,r,h))return 4}switch(a){case s.G.enumLine:switch(l){case s.G.enumEllipticArc:return yn(t,u,m,h,o);case s.G.enumBezier:return Ki(t,u,m,h,o);case s.G.enumRationalBezier2:return $s(t,u,m,h,o);case s.G.enumBezier2:return Ze(t,u,m,h,o);default:(0,s.d)("")}break;case s.G.enumEllipticArc:switch(l){case s.G.enumLine:return yn(t,m,u,h,o);case s.G.enumEllipticArc:return function(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(y(e,i))return 1;return 0===xn(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}(t,m,u,h,o);case s.G.enumBezier:return Ji(t,u,m,h,o);case s.G.enumRationalBezier2:return tr(t,u,m,h,o);case s.G.enumBezier2:return He(t,u,m,h,o);default:(0,s.d)("")}break;case s.G.enumBezier:switch(l){case s.G.enumLine:return Ki(t,m,u,h,o);case s.G.enumEllipticArc:return Ji(t,m,u,h,o);case s.G.enumBezier:return function(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(y(e,i))return 1;return 0===ss(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}(t,m,u,h,o);case s.G.enumRationalBezier2:return $i(t,m,u,h,o);case s.G.enumBezier2:return ts(t,m,u,h,o);default:(0,s.d)("")}break;case s.G.enumRationalBezier2:switch(l){case s.G.enumLine:return $s(t,m,u,h,o);case s.G.enumEllipticArc:return tr(t,m,u,h,o);case s.G.enumBezier:return $i(t,u,m,h,o);case s.G.enumRationalBezier2:return function(t,e,i,s,r){if(r){let s=Sn(e,i);if(0!==s){if(t){if(1===s){if(e.m_weights[0]===i.m_weights[0]&&e.m_weights[1]===i.m_weights[1]&&e.m_weights[2]===i.m_weights[2])return 2}else if(e.m_weights[0]===i.m_weights[2]&&e.m_weights[1]===i.m_weights[1]&&e.m_weights[2]===i.m_weights[0])return 2;return 4}return 2}}else if(y(e,i))return 1;return 0===rr(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1)?0:4}(t,m,u,h,o);case s.G.enumBezier2:return er(t,m,u,h,o);default:(0,s.d)("")}break;case s.G.enumBezier2:switch(l){case s.G.enumLine:return Ze(t,m,u,h,o);case s.G.enumEllipticArc:return He(t,m,u,h,o);case s.G.enumBezier:return ts(t,u,m,h,o);case s.G.enumRationalBezier2:return er(t,u,m,h,o);case s.G.enumBezier2:return function(t,e,i,s,r){if(r){if(0!==Sn(e,i))return 2}else if(y(e,i))return 1;return 0===Ue(t,e,i,null,null,null,s,r??!1,!0,!1)?0:4}(t,m,u,h,o);default:(0,s.d)("")}break;default:(0,s.d)("")}}function Sn(t,e,i=!0){if(!i&&!An(t,e))return 0;let r=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){if(r)return 1;let i=t.getGeometryType();if(i!==e.getGeometryType())return 0;if(i===s.G.enumBezier){let i=t,s=e;return i.getControlPoint1().equals(s.getControlPoint1())&&i.getControlPoint2().equals(s.getControlPoint2())?1:0}if(i===s.G.enumEllipticArc)return+!!bn(t,e,!1);if(i===s.G.enumRationalBezier2){let i=t,s=e;if(i.getControlPoint1().equals(s.getControlPoint1())&&i.getStandardFormWeight()===s.getStandardFormWeight())return 1}else if(i===s.G.enumBezier2){let i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return 1}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){if(r)return-1;let i=t.getGeometryType();if(i!==e.getGeometryType())return 0;if(i===s.G.enumBezier){let i=t,s=e;return i.getControlPoint1().equals(s.getControlPoint2())&&i.getControlPoint2().equals(s.getControlPoint1())?-1:0}if(i===s.G.enumEllipticArc)return bn(t,e,!0),-1;if(i===s.G.enumRationalBezier2){let i=t,s=e;if(i.getControlPoint1().equals(s.getControlPoint1())&&i.getStandardFormWeight()===s.getStandardFormWeight())return-1}else if(i===s.G.enumBezier2){let i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return-1}return 0}return 0}function An(t,e){let i=t.getGeometryType();return!(i!==e.getGeometryType()||i===s.G.enumEllipticArc&&t.projectionBehavior()!==e.projectionBehavior())}function Tn(t,e,i,r,n,o,a){!n&&o&&(0,s.b)("");let l=e.getGeometryType(),h=i.getGeometryType(),m=Math.max(a,Y(e,i));if(r&&(r.length=0),n&&(n.length=0),o&&(o.length=0),l===s.G.enumLine&&h===s.G.enumLine)return ot(e,i,r,n,o,m,!1,!1);let u=e,d=i,g=e.getStartXY(),c=e.getEndXY(),_=!1,p=!1;g.compare(c)>0&&(u=e.clone(!0).reverse(),_=!0),g=i.getStartXY(),c=i.getEndXY(),g.compare(c)>0&&(d=i.clone(!0).reverse(),p=!0);let f=0;switch(l){case s.G.enumLine:switch(h){case s.G.enumEllipticArc:f=Pn(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier:f=es(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumRationalBezier2:f=ir(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier2:f=We(t,d,u,r,o,n,m,!1,0,!0);break;default:(0,s.d)("")}break;case s.G.enumEllipticArc:switch(h){case s.G.enumLine:f=Pn(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=xn(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier:f=is(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumRationalBezier2:f=sr(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier2:f=je(t,d,u,r,o,n,m,!1,0,!0);break;default:(0,s.d)("")}break;case s.G.enumRationalBezier2:switch(h){case s.G.enumLine:f=ir(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=sr(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumBezier:f=rs(t,d,u,r,o,n,m,!1,!1,!0);break;case s.G.enumRationalBezier2:f=rr(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier2:f=nr(t,u,d,r,n,o,m,!1,0,!1);break;default:(0,s.d)("")}break;case s.G.enumBezier2:switch(h){case s.G.enumLine:f=We(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=je(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumBezier:f=ns(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumRationalBezier2:f=nr(t,d,u,r,o,n,m,!1,0,!0);break;case s.G.enumBezier2:f=Ue(t,u,d,r,n,o,m,!1,!1,!1);break;default:(0,s.d)("")}break;case s.G.enumBezier:switch(h){case s.G.enumLine:f=es(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumEllipticArc:f=is(t,u,d,r,n,o,m,!1,0,!1);break;case s.G.enumBezier:f=ss(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumRationalBezier2:f=rs(t,u,d,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier2:f=ns(t,u,d,r,n,o,m,!1,0,!1);break;default:(0,s.d)("")}break;default:(0,s.d)("")}if(_){if(n){for(let t=0;t<f;t++)n[t]=1-n[t];n.reverse()}r&&r.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function In(t,e,i){return e===i?0:(e>i&&(i=(0,n.s)(e,e=i)),t.cut(e,i,!0).calculateUpperLength2D())}function Mn(t,e,i,s,r,o,a,l,h,m,u,d,c){if(!o)return 0;let _=(t,e)=>{for(let i=0;i<o;++i){let s=e[i];if((0,n.a9)(s,0,1)){s=(0,n.aF)(s);continue}let r=t.getCoord2D(s);s<.5?r.equals(t.getStartXY())&&In(t,0,s)<=R(t)&&(e[i]=0):r.equals(t.getEndXY())&&In(t,s,1)<=R(t)&&(e[i]=1)}};_(e,s),_(i,r),function(t,e,i,s,r){let o=[],a=[],l=[];for(let h=0,m=r;h<m;h++)o.push(t.calculateSubLengthFromStart(i[h])),a.push(e.calculateSubLengthFromStart(s[h])),(0,n.a9)(i[h],0,1)&&(0,n.a9)(s[h],0,1)&&t.getCoord2D(i[h]).equals(e.getCoord2D(s[h]))&&l.push(h);if(0===l.length||l.length===r)return;l.sort((t,e)=>i[t]<i[e]?-1:i[t]>i[e]?1:s[t]<s[e]?-1:+(s[t]>s[e]));let h=-1;for(let m of l){if(h>=0&&i[m]===i[h]&&i[m]===i[h]){h=m;continue}h=m;let l=[];l.length=r;for(let t=0;t<l.length;++t)l[t]=t;l.sort((t,e)=>{let i=o[m],s=a[m],r=o[t]-i,n=a[t]-s,l=r*r+n*n,h=o[e]-i,u=a[e]-s,d=h*h+u*u;return l<d?-1:+(l>d)});for(let o=0;o<r;o++){let r=l[o];if(r===m||i[r]===i[m]&&s[r]===s[m]||(0,n.a9)(i[r],0,1)&&(0,n.a9)(s[r],0,1))continue;let a=(i,s,r,o)=>{let a=new g,l=new n.Z;l.setWithEps(1);let h=new n.Z;h.set(s,l.eps()),t.queryCoord2DE(h,a);let m=new g;t.queryCoord2DE(new n.Z(i),m);let u=!1;return a.eq(m)&&(h.set(o,l.eps()),e.queryCoord2DE(h,a),e.queryCoord2DE(new n.Z(r),m),u=a.eq(m)),!u},h=n.P.getNAN();t.queryCoord2D(i[r],h);let u=n.P.getNAN();if(e.queryCoord2D(s[r],u),0===n.P.distance(h,u)&&a(i[m],i[r],s[m],s[r]))break;let d=new n.E(s[r],s[m]);d.normalizeNoNAN();let c=new n.E(i[r],i[m]);c.normalizeNoNAN();let _=-1,p=1/0,f=1/0,y=i[r];h.assign(t.getCoord2D(y));for(let o=0;o<5;o++){let o=e.getClosestCoordinateOnInterval(h,d,-1);u.assign(e.getCoord2D(o));let l=n.P.distance(h,u);if(y=t.getClosestCoordinateOnInterval(u,c,-1),y===i[m]&&o===s[m]){_=1;break}h.assign(t.getCoord2D(y));let g=n.P.distance(u,h);if(!(g<f&&l<p)){_=0;break}if(0===g&&0===l){a(i[m],i[r],s[m],s[r])?(i[r]=y,s[r]=o,_=0):_=1;break}f=g,p=l}if(-1===_&&(_=(0,n.a9)(i[r],0,1)||(0,n.a9)(s[r],0,1)?0:1),1!==_)break;i[r]=i[m],s[r]=s[m]}}}(e,i,s,r,o);let p=[];for(let t=0,e=o;t<e;t++)p.push(t);let f=(t,e)=>c?(0,n.aG)(r[t],s[t],r[e],s[e]):(0,n.aG)(s[t],r[t],s[e],r[e]);if(p.length>1){p.sort(f);let t=Math.max(R(e),R(i)),o=0;for(let a=1,l=p.length;a<l;a++){let l=s[p[o]],h=s[p[a]],m=r[p[o]],u=r[p[a]];if(l!==h||m!==u){if(In(e,l,h)<=t&&In(i,m,u)<=t&&!((0,n.a9)(l,0,1)&&(0,n.a9)(m,0,1)||(0,n.a9)(h,0,1)&&(0,n.a9)(u,0,1))){let t=n.P.distance(e.getCoord2D(l),i.getCoord2D(m)),s=n.P.distance(e.getCoord2D(h),i.getCoord2D(u));if(t<=s)continue;if(s<t){p[o]=p[a];continue}continue}o++,p[o]=p[a]}}if(p.length=o+1,1===p.length&&0!==p[0]&&(s[0]=s[p[0]],r[0]=r[p[0]],p[0]=0),p.length>2){let t=n.E.constructEmpty(),o=n.E.constructEmpty();t.setCoords(s[p[0]],s[p.at(-1)]),o.setCoords(r[p[0]],r[p.at(-1)]);let a=!0;for(let e=1,i=p.length-1;e<i;e++)if(!t.containsCoordinate(s[p[e]])||!o.containsCoordinate(r[p[e]])){a=!1;break}if(a){let s=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let r=0;r<s.length;r++){let l=(0,n.r)(t.vmin,t.vmax,s[r]),h=e.getCoord2D(l);if(!i.isCloserThanDistance(h,o,m)){a=!1;break}l=(0,n.r)(o.vmin,o.vmax,s[r]);let u=i.getCoord2D(l);if(!e.isCloserThanDistance(u,t,m)){a=!1;break}}}a&&(p[1]=p.at(-1),p.length=2)}}if(1===p.length&&t&&C(e,i,s[0],r[0],m,1,[0],[0])&&(p.push(1),s[1]=0,r[1]=0,p.sort(f)),u&&1===p.length){let t=!0;for(let o=0,a=p.length;o<a;o++)if(!(0,n.a9)(s[p[o]],0,1)||!(0,n.a9)(r[p[o]],0,1)||0!==n.P.distance(e.getCoord2D(s[p[o]]),i.getCoord2D(r[p[o]]))){t=!1;break}if(t)return 0}let y=0;for(let t=0,i=p.length;t<i;t++){if(l&&l.push(s[p[t]]),h&&h.push(r[p[t]]),a){let i=n.P.getNAN();e.queryCoord2D(s[p[t]],i),a.push(i)}y++}return y}function qn(t,e,i,s,r,o,a,l,h){if((0,n.a9)(i,0,1)&&(0,n.a9)(s,0,1)&&0===n.P.distance(t.getCoord2D(i),e.getCoord2D(s))){let m=1e-12,u=new g,d=2**-52;if(t.queryDerivative(new n.Z(i,d),u),u.isTrueZero()){let e=1===i?-1e-12:m;t.queryDerivative(new n.Z(i,d).add(e),u)}1===i&&u.negateThis();let c=new g;if(e.queryDerivative(new n.Z(s,d),c),c.isTrueZero()){let t=1===i?-1e-12:m;e.queryDerivative(new n.Z(s,d).add(t),c)}1===s&&c.negateThis(),u.isZero()||u.normalize(),c.isZero()||c.normalize();let _=u.dotProduct(c),p=u.crossProduct(c);if(p.scaleError(3),_.ge(n.T)&&(p.isZero()||Math.abs(p.value())<(()=>{if(h)return.001;{let i=t.calculateUpperLength2D(),s=e.calculateUpperLength2D();return Math.min(.01*r/Math.min(i,s),1e-10)}})()))return v(t,e,i,s,r,o,a,l)}return 0}function Nn(t,e,i,r,o){let a=-1,l=-1,m=-1,u=-1;{let s=[0,e],n=[e,0],o=[0,r],h=[r,0];for(let e=0;e<2&&-1===a;++e)for(let r=0;r<2;++r)if(t[s[e]].equals(i[o[r]])){a=s[e],l=n[e],m=o[r],u=h[r];break}}if(-1===a){let s=new h;s.setFromPoints(t,e+1);let n=new h;return n.setFromPoints(i,r+1),n.inflate(o),s.isIntersectingW(n)?-1:0}{let h=(0,n.c)(e+1,NaN),d=di(t,e+1,h);(0,s.g)(d>1);let g=0,c=0;for(let t=0;t<d;++t)a===h[t]&&(c=t,g++),l===h[t]&&g++;if(2!==g)return-1;let _=(0,n.c)(r+1,NaN),p=di(i,r+1,_);(0,s.g)(p>1),g=0;let f=0;for(let t=0;t<p;++t)m===_[t]&&(f=t,g++),u===_[t]&&g++;if(2!==g)return-1;let y=t[h[(c+d-1)%d]],P=t[h[(c+1)%d]],x=i[_[(f+p-1)%p]],v=i[_[(f+1)%p]],C=t[a],b=[y,P,x,v],E=[0,1,2,3];E.sort((t,e)=>n.P.compareVectorsOrigin(C,b[t],b[e]));let D=E[0];for(let t=1;t<4;t++){if(E[t]!==(D+1)%4)return-1;D=E[t]}{let t=y.sub(C),e=v.sub(C),i=e.dotProduct(t);if(i>0){let s=e.crossProduct(t),r=Math.abs(Math.atan2(s,i)),n=r*t.length(),a=r*e.length();if(n<=o||a<=o)return-1}}{let t=P.sub(C),e=x.sub(C),i=e.dotProduct(t);if(i>0){let s=e.crossProduct(t),r=Math.abs(Math.atan2(s,i)),n=r*t.length(),a=r*e.length();if(n<=o||a<=o)return-1}}return 1}}var Rn=r.V;class Yn extends K{static type=s.G.enumLine;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=NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return(0,s.g)(0),0}calculateUpperLength3D(){return(0,s.g)(0),0}changeEndPoints3D(t,e){(0,s.g)(0)}getClosestCoordinate3D(t,e,i){return(0,s.g)(0),0}getBoundary(){return At(this)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?tt(this,t):et(this,t);let s=Rn.getInterpolation(e),r=this.getStartAttributeAsDbl(e,i),o=this.getEndAttributeAsDbl(e,i);return(0,n.ac)(s,r,o,t,Rn.getDefaultValue(e))}constructFromCoords(t,e,i,s){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(i,s)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){(0,s.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return Yn.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);let e=o.Envelope2D.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e);for(let s=Rn.getComponentCount(i);e<s;e++){let e=this.queryInterval(i,0);t.setIntervalEnvelope(i,0,e)}}}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,M(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,M(this,1,1,0))):(0,s.a)("env type not impl")}applyTransformation(t){(0,s.g)(t instanceof a.T);let e=new n.P;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 Yn({vd:this.m_description})}calculateLength2D(){return Math.sqrt(ut(this))}calculateLength3D(t){return(0,s.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryControlPointsHelper(t){return(0,s.g)(t.length>=2),t[0]=this.getStartXY(),t[1]=this.getEndXY(),2}queryCoord2D(t,e){return J(this,t,e)}queryCoord3D(t,e){(0,s.g)(0)}getCoordZ(t){return function(t,e){let i=t.getStartZ(),s=t.getEndZ();return(0,n.r)(i,s,e)}(this,t)}queryCoord2DE(t,e){it(this,t,e)}queryCoord2DMP(t,e){e.assignPoint2D(this.getStartXY());let i=_.constructPoint2D(this.getEndXY());i.subThis(e),i.mulThis(n.M.constructDouble(t)),e.addThis(i)}getCoordX(t){return tt(this,t)}getCoordY(t){return et(this,t)}cut(t,e,i){let s=new Xn;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createLine();s&&r.assignVertexDescription(this.m_description);let o=n.P.getNAN();if(J(this,t,o),r.setStartXYCoords(o.x,o.y),J(this,e,o),r.setEndXYCoords(o.x,o.y),!s)for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),n=Rn.getComponentCount(s);for(let i=0;i<n;i++){let n=this.getAttributeAsDbl(t,s,i);r.setStartAttribute(s,i,n);let o=this.getAttributeAsDbl(e,s,i);r.setEndAttribute(s,i,o)}}}queryDerivative(t,e){!function(t,e,i){let s=g.constructPoint2D(t.getStartXY()),r=g.constructPoint2D(t.getEndXY());i.setCoordsE(r.x.subE(s.x),r.y.subE(s.y))}(this,0,e)}getClosestCoordinate(t,e){return n.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,i=-1){let s=new n.P;this.queryCoord2D(e.vmin,s);let r=new n.P;this.queryCoord2D(e.vmax,r);let o=n.P.getClosestCoordinate(s,r,t,!1);return z.recalculateParentT(e.vmin,e.vmax,o)}intersectionOfYMonotonicWithAxisX(t,e){let i=this.m_YEnd-this.m_YStart;if(!i)return t===this.m_YEnd?e:NaN;let s=(t-this.m_YStart)/i,r=tt(this,s);return 1===s&&(r=this.m_XEnd),r}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){let e=this.m_XStart-this.m_XEnd,i=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+i*i)<=t}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){let e=new Yn;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){let e=this.calculateLength2D();return 0===e?0:t/e}calculateWeightedAreaCentroid2D(t){let e=new n.P;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){let e=n.P.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){let e=new n.P;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,i){return at(this,t,e,i)>=0}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,s.b)(""),e[0]=0,e[1]=1),2}intersectionWithAxis2D(t,e,i,s){if(t){let t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;let r=(e-this.m_YStart)/t;return r<0||r>1?0:(i&&(i[0]=tt(this,r)),s&&(s[0]=r),1)}{let t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;let r=(e-this.m_XStart)/t;return r<0||r>1?0:(i&&(i[0]=et(this,r)),s&&(s[0]=r),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let i=(0,n.a)(t.vmin,0,1),s=new n.P;return this.queryCoord2D(i,s),e.setCoords({pt:s}),i=(0,n.a)(t.vmax,0,1),this.queryCoord2D(i,s),void e.mergeNe(s)}(0,s.a)("3d dst not impl")}orientBottomUp(){rt(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 function(t,e){let i=t.getStartXYZ();i.z*=e;let s=t.getEndXYZ();return s.z*=e,i.norm(1)+s.norm(1)}(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){st(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,s.g)(0),0}readFromBufferStream(t,e){(0,s.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,i){st(this,t,e)}static isIntersectingLineLine(t,e,i,s){return nt(t,e,i,s)}static isIntersectingLineLine_(t,e,i,s){return nt(t,e,i,s)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,i,s,r){return Tn(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){e.length<1&&(0,s.r)("");let r=at(this,t,i,!1);return r>=0?(e&&(e[0]=r),1):0}isIntersecting(t,e,i){return 0!==Dn(!1,this,t,e,i)}static segmentIntersectRobust(t,e,i,s,r,a){function l(t,e,i){return o.Envelope2D.construct(t.x,t.y,e.x,e.x).contains(i)}a.length=0;let h=g.constructPoint2D(t),m=g.constructPoint2D(e),u=g.constructPoint2D(i),d=g.constructPoint2D(s),c=m.subThisE(h),p=u.subE(d),f=u.subThisE(h),y=c.crossProduct(p);if(y.eps()<.5*Math.abs(y.value())){let t=f.crossProduct(p).divE(y),e=c.crossProduct(f).divE(y);if(!e.isInInterval(n.ad)||!t.isInInterval(n.ad))return 0;if(e.isInIntervalExclusive(n.ad)&&t.isInIntervalExclusive(n.ad)&&e.eps()<r&&t.eps()<r)return a.push(t.value(),e.value()),1}let P=_.constructPoint2D(t),x=_.constructPoint2D(e),v=_.constructPoint2D(i),C=_.constructPoint2D(s),b=x.subThis(P),E=v.sub(C),D=v.subThis(P),w=b.crossProduct(E);if(w.isZero())return l(t,e,i)||l(t,e,s)||l(i,s,t)||l(i,s,e)?-1:0;let S=D.crossProduct(E).div(w),A=b.crossProduct(D).div(w);return S.GEZ()&&A.GEZ()&&S.lte(n.ae)&&A.lte(n.ae)?(a.push(S.toDouble(),A.toDouble()),1):0}}class Xn{m_seg=null;m_curves=null;m_lineBuffer=new Yn;m_mask=0;m_active=0;constructor(t){if(void 0!==t){if(t.copy)return void t.copy.copyTo(this,!1);if(t.move)return void this.assignMove(t.move);if(t.segment)return void this.copyFrom(t.segment,!!t.bIgnoreAttributes);(0,s.d)("bad constructor params")}}assignCopy(t){return t instanceof Xn?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof Xn){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:(0,s.d)("")}}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){if(this!==t){if(this.empty())return void(t.m_seg=null);t.copyFrom(this.m_seg,e)}}copyToWithZ(t,e){(0,s.g)(0)}createImpl(t){switch(t){case s.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new Yn,this.m_mask|=1,this.m_active=1);break;case s.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new Ar,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case s.G.enumBezier:4&this.m_mask||(this.m_curves=new vs,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case s.G.enumBezier2:8&this.m_mask||(this.m_curves=new Qt,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case s.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new Ut,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,s.b)("")}}create(t){t===s.G.enumLine?this.createLine():t===s.G.enumEllipticArc?this.createEllipticArc():t===s.G.enumBezier?this.createCubicBezier():t===s.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===s.G.enumBezier2?this.createQuadraticBezier():(0,s.b)("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){(0,s.g)(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(s.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(s.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(s.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(s.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(s.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&(0,s.d)("releaseSegment"),1&this.m_active){let t=this.line();return--this.m_mask,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():(0,s.d)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof Xn?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,s.a)("seg comparison not yet impl"),!1)}}},11878(t,e,i){i.d(e,{T:()=>a});var s=i(55537),r=i(83661);class n{data;N;M;constructor(t,e,i){if(t instanceof n)return this.data=t.data,this.N=t.N,this.M=t.M,t.data=null,t.N=0,void(t.M=0);this.data=t,this.N=e,this.M=i}assignCopy(t){return this===t||((0,s.g)(this.N*this.M===t.N*t.M),this.data.set(t.data),this.N=t.N,this.M=t.M),this}setZero(){return this.data?.fill(0),this}setIdentity(){for(let t=0;t<this.N;t++)for(let e=0;e<this.M;e++)this.setRowCol(t,e,+(t===e));return this}rows(){return this.N}cols(){return this.M}row(t){return(0,s.g)(0),{}}set(t,e){return this.data[t]=e,this}setRowCol(t,e,i){return this.data[t*this.M+e]=i,this}at(t){return this.data[t]}atRowCol(t,e){return this.data[t*this.M+e]}mulScalar(t,e){(0,s.g)(0)}mul(t,e){if((0,s.g)(this.M===t.rows()),(0,s.g)(this.N===e.rows()),(0,s.g)(t.cols()===e.cols()),e===this){let i=new Float64Array(this.N*this.M),s=new n(i,this.N,this.M);return this.mul(t,s),void e.assignCopy(s)}if(e===t){let i=new Float64Array(t.N*t.M),s=new n(i,t.N,t.M);return this.mul(t,s),void e.assignCopy(s)}let i=t.cols();for(let s=0;s<this.N;s++)for(let r=0;r<i;r++){let i=0;for(let e=0;e<this.M;e++)i+=this.atRowCol(s,e)*t.atRowCol(e,r);e.setRowCol(s,r,i)}}mulTranspose(t,e){if((0,s.g)(this.M===t.cols()),(0,s.g)(this.N===e.rows()),(0,s.g)(t.rows()===e.cols()),e===this){let i=new Float64Array(this.N*this.M),s=new n(i,this.N,this.M);return this.mulTranspose(t,s),void e.assignCopy(s)}if(e===t){let i=new Float64Array(t.N*t.M),s=new n(i,t.N,t.M);return this.mulTranspose(t,s),void e.assignCopy(s)}let i=t.rows();for(let s=0;s<this.N;s++)for(let r=0;r<i;r++){let i=0;for(let e=0;e<this.M;e++)i+=this.atRowCol(s,e)*t.atRowCol(r,e);e.setRowCol(s,r,i)}}mulLeft(t,e){(0,s.g)(0)}mulLeftTranspose(t,e){(0,s.g)(0)}mulDiag(t,e){if((0,s.g)(this.M===t.N*t.M),(0,s.g)(this.N===e.rows()),(0,s.g)(this.M===e.cols()),e===this){let i=new Float64Array(this.N*this.M),s=new n(i,this.N,this.M);return this.mulDiag(t,s),void e.assignCopy(s)}let i=this.M;for(let s=0;s<this.N;s++)for(let r=0;r<i;r++)e.setRowCol(s,r,this.atRowCol(s,r)*t.at(r))}transposeInPlace(){if(this.N===this.M){for(let t=0;t<this.N;t++)for(let e=t+1;e<this.M;e++){let i=this.atRowCol(t,e);this.setRowCol(t,e,this.atRowCol(e,t)),this.setRowCol(e,t,i)}return this}let t=new Float64Array(this.N*this.M),e=new n(t,this.N,this.M);return e.assignCopy(this),this.M=(0,r.s)(this.N,this.N=this.M),e.transpose(this),this}transpose(t){if(this!==t){n.checkDims(t,this.M,this.N);for(let e=0;e<this.N;e++)for(let i=0;i<this.M;i++)t.setRowCol(i,e,this.atRowCol(e,i))}else t.transposeInPlace()}add(t,e){}svd(t,e,i,r=!1){if(n.checkDims(t,this.N,this.M),n.checkDims(e,this.M,1),n.checkDims(i,this.M,this.M),r){if((0,s.g)(this.N===this.M),!this.symmetricEigen(e,i))return!1;for(let t=0;t<this.M;++t)e.at(t)<0&&e.set(t,0);return t.assignCopy(i),!0}let o,a,l,h,m,u,d,g=0,c=0,_=0,p=0,f=0,y=this.M,P=this.N;t.assignCopy(this);let x=new Float64Array(y),v=new n(x,y,1),C=(t,e)=>e>=0?Math.abs(t):-Math.abs(t),b=(t,e)=>{if((t=Math.abs(t))>(e=Math.abs(e))){let i=e/t;return t*Math.sqrt(i*i+1)}if(e>0){let i=t/e;return e*Math.sqrt(i*i+1)}return 0};for(let i=0;i<y;i++){if(g=i+1,v.set(i,p*_),_=h=p=0,i<P){for(let e=i;e<P;e++)p+=Math.abs(t.atRowCol(e,i));if(p){for(let e=i;e<P;e++)t.setRowCol(e,i,t.atRowCol(e,i)/p),h+=t.atRowCol(e,i)*t.atRowCol(e,i);a=t.atRowCol(i,i),_=-C(Math.sqrt(h),a),l=a*_-h,t.setRowCol(i,i,a-_);for(let e=g;e<y;e++){h=0;for(let s=i;s<P;s++)h+=t.atRowCol(s,i)*t.atRowCol(s,e);a=h/l;for(let s=i;s<P;s++)t.setRowCol(s,e,t.atRowCol(s,e)+a*t.atRowCol(s,i))}for(let e=i;e<P;e++)t.setRowCol(e,i,t.atRowCol(e,i)*p)}}if(e.set(i,p*_),_=h=p=0,i<P&&i!==y-1){for(let e=g;e<y;e++)p+=Math.abs(t.atRowCol(i,e));if(p){for(let e=g;e<y;e++)t.setRowCol(i,e,t.atRowCol(i,e)/p),h+=t.atRowCol(i,e)*t.atRowCol(i,e);a=t.atRowCol(i,g),_=-C(Math.sqrt(h),a),l=a*_-h,t.setRowCol(i,g,a-_);for(let e=g;e<y;e++)v.set(e,t.atRowCol(i,e)/l);for(let e=g;e<P;e++){h=0;for(let s=g;s<y;s++)h+=t.atRowCol(e,s)*t.atRowCol(i,s);for(let i=g;i<y;i++)t.setRowCol(e,i,t.atRowCol(e,i)+h*v.at(i))}for(let e=g;e<y;e++)t.setRowCol(i,e,t.atRowCol(i,e)*p)}}let s=Math.abs(e.at(i))+Math.abs(v.at(i));f=s>f?s:f}for(let e=y-1;e>=0;e--){if(e<y-1){if(_){for(let s=g;s<y;s++)i.setRowCol(s,e,t.atRowCol(e,s)/t.atRowCol(e,g)/_);for(let s=g;s<y;s++){h=0;for(let r=g;r<y;r++)h+=t.atRowCol(e,r)*i.atRowCol(r,s);for(let t=g;t<y;t++)i.setRowCol(t,s,i.atRowCol(t,s)+h*i.atRowCol(t,e))}}for(let t=g;t<y;t++)i.setRowCol(e,t,0),i.setRowCol(t,e,0)}i.setRowCol(e,e,1),_=v.at(e),g=e}for(let i=(P<y?P:y)-1;i>=0;i--){g=i+1,_=e.at(i);for(let e=g;e<y;e++)t.setRowCol(i,e,0);if(_){_=1/_;for(let e=g;e<y;e++){h=0;for(let s=g;s<P;s++)h+=t.atRowCol(s,i)*t.atRowCol(s,e);a=h/t.atRowCol(i,i)*_;for(let s=i;s<P;s++)t.setRowCol(s,e,t.atRowCol(s,e)+a*t.atRowCol(s,i))}for(let e=i;e<P;e++)t.setRowCol(e,i,t.atRowCol(e,i)*_)}else for(let e=i;e<P;e++)t.setRowCol(e,i,0);t.setRowCol(i,i,t.atRowCol(i,i)+1)}for(let s=y-1;s>=0;s--)for(let r=1;;r++){let n=1;for(g=s;g>=0;g--){if(c=g-1,Math.abs(v.at(g))+f===f){n=0;break}if(Math.abs(e.at(c))+f===f)break}if(n){o=0,h=1;for(let i=g;i<=s&&(a=h*v.at(i),v.set(i,v.at(i)*o),Math.abs(a)+f!==f);i++){_=e.at(i),l=b(a,_),e.set(i,l),l=1/l,o=_*l,h=-a*l;for(let e=0;e<P;e++)u=t.atRowCol(e,c),d=t.atRowCol(e,i),t.setRowCol(e,c,u*o+d*h),t.setRowCol(e,i,d*o-u*h)}}if(d=e.at(s),g===s){if(d<0){e.set(s,-d);for(let t=0;t<y;t++)i.setRowCol(t,s,-i.atRowCol(t,s))}break}if(100===r)return!1;m=e.at(g),c=s-1,u=e.at(c),_=v.at(c),l=v.at(s),a=((u-d)*(u+d)+(_-l)*(_+l))/(2*l*u),_=b(a,1),a=((m-d)*(m+d)+l*(u/(a+C(_,a))-l))/m,o=h=1;for(let s=g;s<=c;s++){let r=s+1;_=v.at(r),u=e.at(r),l=h*_,_*=o,d=b(a,l),v.set(s,d),o=a/d,h=l/d,a=m*o+_*h,_=_*o-m*h,l=u*h,u*=o;for(let t=0;t<y;t++)m=i.atRowCol(t,s),d=i.atRowCol(t,r),i.setRowCol(t,s,m*o+d*h),i.setRowCol(t,r,d*o-m*h);d=b(a,l),e.set(s,d),d&&(d=1/d,o=a*d,h=l*d),a=o*_+h*u,m=o*u-h*_;for(let e=0;e<P;e++)u=t.atRowCol(e,s),d=t.atRowCol(e,r),t.setRowCol(e,s,u*o+d*h),t.setRowCol(e,r,d*o-u*h)}v.set(g,0),v.set(s,a),e.set(s,m)}let E=new Float64Array(this.N),D=new Float64Array(this.M),w=new n(E,this.N,1),S=new n(D,this.M,1),A=1;do{A*=3,A++}while(A<=this.M);do{A/=3,A=Math.trunc(A);for(let s=A;s<this.M;s++){let r=e.at(s);for(let e=0;e<this.N;e++)w.set(e,t.atRowCol(e,s));for(let t=0;t<this.M;t++)S.set(t,i.atRowCol(t,s));let n=s;for(;e.at(n-A)<r;){e.set(n,e.at(n-A));for(let e=0;e<this.N;e++)t.setRowCol(e,n,t.atRowCol(e,n-A));for(let t=0;t<this.M;t++)i.setRowCol(t,n,i.atRowCol(t,n-A));if(n-=A,n<A)break}e.set(n,r);for(let e=0;e<this.N;e++)t.setRowCol(e,n,w.at(e));for(let t=0;t<this.M;t++)i.setRowCol(t,n,S.at(t))}}while(A>1);for(let e=0;e<this.M;e++){let s=0;for(let i=0;i<this.N;i++)t.atRowCol(i,e)<0&&s++;for(let t=0;t<this.M;t++)i.atRowCol(t,e)<0&&s++;if(s>Math.trunc((this.N+this.M)/2)){for(let i=0;i<this.N;i++)t.setRowCol(i,e,-t.atRowCol(i,e));for(let t=0;t<this.M;t++)i.setRowCol(t,e,-i.atRowCol(t,e))}}return!0}isSymmetric(){if(this.N!==this.M)return!1;for(let t=0;t<this.N;t++)for(let e=t+1;e<this.M;e++)if(this.atRowCol(t,e)!==this.atRowCol(e,t))return!1;return!0}isZero(){return(0,s.g)(0),!1}isIdentity(){return(0,s.g)(0),!1}equals(t,e){if(void 0!==e&&(0,s.g)(0),this.N!==t.N||this.M!==t.M)return!1;for(let e=0;e<this.N*this.M;e++)if(this.data[e]!==t.data[e])return!1;return!0}maxElement(){return(0,s.g)(0),0}minElement(){return(0,s.g)(0),0}determinant(){if((0,s.g)(this.N===this.M),1===this.N)return this.data[0];if(2===this.N)return this.data[0]*this.data[3]-this.data[1]*this.data[2];if(3===this.N){let t=this;return t.atRowCol(0,0)*(t.atRowCol(1,1)*t.atRowCol(2,2)-t.atRowCol(1,2)*t.atRowCol(2,1))-t.atRowCol(0,1)*(t.atRowCol(1,0)*t.atRowCol(2,2)-t.atRowCol(2,0)*t.atRowCol(1,2))+t.atRowCol(0,2)*(t.atRowCol(1,0)*t.atRowCol(2,1)-t.atRowCol(1,1)*t.atRowCol(2,0))}let t=new Float64Array(this.N*this.N),e=new n(t,this.N,this.N),i=new Float64Array(this.N);if(!this.luDecomposition(e,i))return 0;let r=1;for(let t=0;t<this.N;t++)r*=e.atRowCol(t,t),i[t]!==t&&(r=-r);return r}submatrix(t,e,i){(0,s.g)(0)}inverse(t){(0,s.g)(0)}pseudoInverse(t,e=!1,i=2220446049250313e-31){if(t.setZero(),1===this.N&&1===this.M)return 0===this.atRowCol(0,0)?t.setRowCol(0,0,0):t.setRowCol(0,0,1/this.atRowCol(0,0)),!0;if(2===this.N&&2===this.M){let e=this.atRowCol(0,0)*this.atRowCol(1,1)-this.atRowCol(0,1)*this.atRowCol(1,0),i=1e-5*(Math.abs(this.atRowCol(0,0)*this.atRowCol(1,1))+Math.abs(this.atRowCol(0,1)*this.atRowCol(1,0)));if(Math.abs(e)>i)return t.setRowCol(0,0,this.atRowCol(1,1)/e),t.setRowCol(0,1,-this.atRowCol(0,1)/e),t.setRowCol(1,0,-this.atRowCol(1,0)/e),t.setRowCol(1,1,this.atRowCol(0,0)/e),!0}let s=new Float64Array(this.N*this.M),r=new n(s,this.N,this.M),o=new Float64Array(this.M),a=new n(o,this.M,1),l=new Float64Array(this.M*this.M),h=new n(l,this.M,this.M);if(!this.svd(r,a,h,e))return!1;let m=Math.max(this.N,this.M),u=i*Math.abs(a.at(0))*m;for(let t=0;t<this.M;t++)a.at(t)>u?a.set(t,1/a.at(t)):a.set(t,0);return h.mulDiag(a,t),t.mulTranspose(r,t),!0}luDecomposition(t,e){return(0,s.g)(0),!1}symmetricEigen(t,e){(0,s.g)(this.rows()===this.cols()),(0,s.g)(this.rows()===t.rows()),(0,s.g)(e.rows()===e.cols()&&e.rows()===this.rows()),(0,s.g)(this.isSymmetric());let i=new Float64Array(this.N*this.M),r=new n(i,this.N,this.M);r.assignCopy(this);let o=100/2**-52,a=this.rows(),l=new Float64Array(a),h=new Float64Array(a),m=new n(l,a,1),u=new n(h,a,1);for(let e=0;e<a;e++)m.set(e,r.atRowCol(e,e)),t.set(e,r.atRowCol(e,e)),u.set(e,0);e.setIdentity();let d=()=>{let i=m;e.transposeInPlace();let s=1;do{s*=3,s++}while(s<=a);do{s/=3,s=Math.trunc(s);for(let r=s;r<a;r++){let n=t.at(r),o=Math.abs(n);for(let t=0;t<this.M;t++)i.set(t,e.atRowCol(t,r));let a=r;for(;Math.abs(t.at(a-s))<o;){t.set(a,t.at(a-s));for(let t=0;t<this.M;t++)e.setRowCol(t,a,e.atRowCol(t,a-s));if(a-=s,a<s)break}if(a!==r){t.set(a,n);for(let t=0;t<this.M;t++)e.setRowCol(t,a,i.at(t))}}}while(s>1)};for(let i=1;;i++){let s=0;for(let t=1;t<a;t++)for(let e=0;e<t;e++)s+=Math.abs(r.atRowCol(t,e));if(0===s)return d(),!0;let n=i<4?.2*s/(a*a):0;for(let s=0;s<a;s++)for(let l=s+1;l<a;l++){let h=o*Math.abs(r.atRowCol(l,s));if(i>4&&h<=Math.abs(t.at(s))&&h<=Math.abs(t.at(l)))r.setRowCol(l,s,0);else if(Math.abs(r.atRowCol(l,s))>n){let i,n=t.at(l)-t.at(s);if(h<Math.abs(n))i=r.atRowCol(l,s)/n;else{let t=.5*n/r.atRowCol(l,s);i=1/(Math.abs(t)+Math.sqrt(1+t*t)),t<0&&(i=-i)}let o=1/Math.sqrt(1+i*i),m=i*o,d=m/(1+o);n=i*r.atRowCol(l,s),u.set(s,u.at(s)-n),u.set(l,u.at(l)+n),t.set(s,t.at(s)-n),t.set(l,t.at(l)+n),r.setRowCol(l,s,0);let g=0;for(;g<s;g++)h=r.atRowCol(s,g),n=r.atRowCol(l,g),r.setRowCol(s,g,h-m*(n+h*d)),r.setRowCol(l,g,n+m*(h-n*d));for(g++;g<l;g++)h=r.atRowCol(g,s),n=r.atRowCol(l,g),r.setRowCol(g,s,h-m*(n+h*d)),r.setRowCol(l,g,n+m*(h-n*d));for(g++;g<a;g++)h=r.atRowCol(g,s),n=r.atRowCol(g,l),r.setRowCol(g,s,h-m*(n+h*d)),r.setRowCol(g,l,n+m*(h-n*d));for(g=0;g<a;g++)h=e.atRowCol(s,g),n=e.atRowCol(l,g),e.setRowCol(s,g,h-m*(n+h*d)),e.setRowCol(l,g,n+m*(h-n*d))}}for(let e=0;e<a;e++)m.set(e,m.at(e)+u.at(e)),t.set(e,m.at(e)),u.set(e,0)}}static checkDims(t,e,i){(0,s.g)(t.rows()===e&&t.cols()===i)}}class o extends n{buffer;constructor(t){if(t.copy){let e=new Float64Array(t.copy.N*t.copy.M);return super(e,t.copy.N,t.copy.M),this.buffer=e,void this.assignCopy(t.copy)}let e=new Float64Array(t.NN*t.MM);super(e,t.NN,t.MM),this.buffer=e,t.initializerList&&(0,r.f)(this.buffer,t.initializerList,0,0,t.initializerList.length)}assignCopy(t){return this===t||super.assignCopy(t),this}}class a{m_TransformationType=1;xx;xy;xd;yx;yy;yd;constructor(t){void 0===t?this.setIdentity():t instanceof a?this.set(t):this.setScale(t)}set(t){return this.xx=t.xx,this.xy=t.xy,this.xd=t.xd,this.yx=t.yx,this.yy=t.yy,this.yd=t.yd,this}clone(){return(new a).set(this)}setZero(){this.xx=0,this.yy=0,this.xy=0,this.yx=0,this.xd=0,this.yd=0}isEqual(t){return this===t||this.xx===t.xx&&this.xy===t.xy&&this.xd===t.xd&&this.yx===t.yx&&this.yy===t.yy&&this.yd===t.yd}transformInPlace(t){let e=this.xx*t.x+this.xy*t.y+this.xd,i=this.yx*t.x+this.yy*t.y+this.yd;t.x=e,t.y=i}transform(t){let e=t.clone();return this.transformInPlace(e),e}queryTransform(t,e){let i=this.xx*t.x+this.xy*t.y+this.xd,s=this.yx*t.x+this.yy*t.y+this.yd;e.setCoords(i,s)}transformEnvInPlace(t){if(t.isEmpty())return;let e=(0,r.d)(r.P,4);t.queryCorners(e),this.transformPoints2D(e,4,e),t.setFromPoints(e,4)}queryTransformEnv(t,e){(0,s.g)(0)}transformPoints2D(t,e,i){for(let s=0;s<e;++s)this.queryTransform(t[s],i[s])}transformInterleavedPoints(t,e,i){e*=2;let s=r.P.getNAN();for(let r=0;r<e;r+=2)s.x=t[r],s.y=t[r+1],this.transformInPlace(s),i[r]=s.x,i[r+1]=s.y}multiply(t){return a.st_multiply(this,t,this),this}mulLeft(t){return(0,s.g)(0),this}static st_multiply(t,e,i){let s=t.xx*e.xx+t.yx*e.xy,r=t.xy*e.xx+t.yy*e.xy,n=t.xd*e.xx+t.yd*e.xy+e.xd,o=t.xx*e.yx+t.yx*e.yy,a=t.xy*e.yx+t.yy*e.yy,l=t.xd*e.yx+t.yd*e.yy+e.yd;i.xx=s,i.xy=r,i.xd=n,i.yx=o,i.yy=a,i.yd=l}getCoefficients(t){(0,s.g)(t.length>=6),t[0]=this.xx,t[1]=this.xy,t[2]=this.xd,t[3]=this.yx,t[4]=this.yy,t[5]=this.yd}setCoefficients(t){(0,s.g)(t.length>=6),this.xx=t[0],this.xy=t[1],this.xd=t[2],this.yx=t[3],this.yy=t[4],this.yd=t[5]}copyTo(t){(0,s.g)(0)}initializeFromRect(t,e){t.isEmpty()||e.isEmpty()||!t.width()||!t.height()?this.setZero():(this.xy=this.yx=0,this.xx=e.width()/t.width(),this.yy=e.height()/t.height(),this.xd=e.xmin-t.xmin*this.xx,this.yd=e.ymin-t.ymin*this.yy)}initializeFromRectIsotropic(t,e){if(t.isEmpty()||!t.width()||!t.height()||e.isEmpty())this.setZero();else{this.yx=0,this.xy=0,this.xx=e.width()/t.width(),this.yy=e.height()/t.height(),this.xx>this.yy?this.xx=this.yy:this.yy=this.xx;let i=e.getCenter(),s=t.getCenter();this.xd=i.x-s.x*this.xx,this.yd=i.y-s.y*this.yy}}initializeFromTwoPointsArray(t,e){if(t[0].equals(e[0])&&t[1].equals(e[1]))return void this.setIdentity();if(t[0].equals(t[1])){if(e[0].equals(e[1]))return void this.setShift(e[0].sub(t[0]));(0,s.b)("")}if(!t[0].equals(t[1])&&e[0].equals(e[1]))return this.setZero(),void this.shift(e[0]);this.setShiftCoords(-t[0].x,-t[0].y);let i=r.P.distance(t[0],t[1]),n=r.P.distance(e[0],e[1]),o=n/i;this.scale(o,o);let a=t[1].sub(t[0]);a.divThis(i);let l=e[1].sub(e[0]);l.divThis(n);let h=a.crossProduct(l),m=a.dotProduct(l);this.rotate(m,h),this.shiftCoords(e[0].x,e[0].y)}initializeFromTwoPoints(t,e,i,s){let r=[t,e],n=[i,s];this.initializeFromTwoPointsArray(r,n)}transformSizeInPlace(t){(0,s.g)(0)}transformSize(t,e){(0,s.g)(0)}transformTol(t){return(0,s.g)(0),0}transformWithoutTranslateArray(t,e,i){for(let s=0;s<e;++s)this.transformWithoutTranslate(t[s],i[s])}transformWithoutTranslateInPlace(t){let e=this.xx*t.x+this.xy*t.y,i=this.yx*t.x+this.yy*t.y;t.setCoords(e,i)}transformWithoutTranslate(t,e){let i=this.xx*t.x+this.xy*t.y,s=this.yx*t.x+this.yy*t.y;e.setCoords(i,s)}setIdentity(){this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=1,this.yd=0}isIdentity(){return!(1!==this.xx||1!==this.yy||this.xy||this.xd||this.yx||this.yd)}isIdentityTol(t){let e=t*t;return!((0,r.e)(this.xd)+(0,r.e)(this.yd)>e||(0,r.e)(this.xy+this.xd)+(0,r.e)(this.yy+this.yd-1)>e||(0,r.e)(this.xx+this.xd-1)+(0,r.e)(this.yx+this.yd)>e)}isReflective(){return this.xx*this.yy-this.yx*this.xy<0}isUniform(t){let e=this.xx*this.xx+this.yx*this.yx,i=this.xy*this.xy+this.yy*this.yy,s=(e+i)*t;return Math.abs(e-i)<=s&&Math.abs(this.xx*this.xy+this.yx*this.yy)<=s}isUniformNoRotation(){return 0!==this.xx&&Math.abs(this.xx)===Math.abs(this.yy)&&0===this.xy&&0===this.yx}isTranslate(){return 1===this.xx&&1===this.yy&&!this.xy&&!this.yx}isTranslateTol(t){let e=new r.P;return e.setCoords(0,1),this.transformWithoutTranslateInPlace(e),--e.y,!(e.sqrLength()>t*t)&&(e.setCoords(1,0),this.transformWithoutTranslateInPlace(e),--e.x,e.sqrLength()<=t*t)}isOrthonormal(t){let e=new a;return e.xx=this.xx*this.xx+this.xy*this.xy,e.xy=this.xx*this.yx+this.xy*this.yy,e.yx=this.yx*this.xx+this.yy*this.xy,e.yy=this.yx*this.yx+this.yy*this.yy,e.xd=0,e.yd=0,e.isIdentityTol(t)}isDegenerate(t){return Math.abs(this.xx*this.yy-this.yx*this.xy)<=2*t*(Math.abs(this.xx*this.yy)+Math.abs(this.yx*this.xy))}isZero(){return 0===this.xx&&0===this.yy&&0===this.xy&&0===this.yx&&0===this.xd&&0===this.yd}isScaleAndTranslateTol(t){return this.xy*this.xy+this.yx*this.yx<=(this.xx*this.xx+this.yy*this.yy)*t}setTranslate(t,e){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=e,this}setShiftCoords(t,e){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=e,this}setShift(t){return this.xx=1,this.xy=0,this.xd=t.x,this.yx=0,this.yy=1,this.yd=t.y,this}setScaleCoords(t,e){return this.xx=t,this.xy=0,this.xd=0,this.yx=0,this.yy=e,this.yd=0,this}setScale(t){return this.setScaleCoords(t,t),this}setFlipX(t,e){return this.xx=-1,this.xy=0,this.xd=t+e,this.yx=0,this.yy=1,this.yd=0,this}setFlipY(t,e){return this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=-1,this.yd=t+e,this}setShear(t,e){return this.xx=1,this.xy=t,this.xd=0,this.yx=e,this.yy=1,this.yd=0,this}scale(t,e){return this.xx*=t,this.xy*=t,this.xd*=t,this.yx*=e,this.yy*=e,this.yd*=e,this}setRotateAngle(t){return this.setRotate(Math.cos(t),Math.sin(t))}setRotate(t,e){return this.xx=t,this.xy=-e,this.xd=0,this.yx=e,this.yy=t,this.yd=0,this}setRotateAngleAbout(t,e){return this.setRotateAbout(Math.cos(t),Math.sin(t),e)}setRotateAbout(t,e,i){return this.setTranslate(-i.x,-i.y),this.rotate(t,e),this.translate(i.x,i.y)}setSwapCoordinates(){return this.xx=0,this.xy=1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}setRotateCw90(){return this.xx=0,this.xy=1,this.xd=0,this.yx=-1,this.yy=0,this.yd=0,this}setRotateCcw90(){return this.xx=0,this.xy=-1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}shiftCoords(t,e){return this.xd+=t,this.yd+=e,this}shift(t){return this.xd+=t.x,this.yd+=t.y,this}translate(t,e){return this.xd+=t,this.yd+=e,this}flipX(t,e){return this.xx=-this.xx,this.xy=-this.xy,this.xd=t+e-this.xd,this}flipY(t,e){return this.yx=-this.yx,this.yy=-this.yy,this.yd=t+e-this.yd,this}shear(t,e){let i=new a;return i.setShear(t,e),this.multiply(i)}rotateAngle(t){let e=new a;return e.setRotateAngle(t),this.multiply(e)}rotate(t,e){let i=new a;return i.setRotate(t,e),this.multiply(i)}rotateAbout(t,e,i){return this.translate(-i.x,-i.y),this.rotate(t,e),this.translate(i.x,i.y)}rotateAngleAbout(t,e){return this.rotateAbout(Math.cos(t),Math.sin(t),e)}setInvert(t){return this.set(t),this.invertThis()}invertThis(){let t=this.xx*this.yy-this.xy*this.yx;if(0===t)return this.setZero(),this;t=1/t;let e=(this.xy*this.yd-this.xd*this.yy)*t,i=(this.xd*this.yx-this.xx*this.yd)*t,s=this.yy*t,r=-this.xy*t,n=-this.yx*t,o=this.xx*t;return this.xd=e,this.yd=i,this.xx=s,this.yy=o,this.xy=r,this.yx=n,this}invertPrecise(t){return this.set(t),this.invertPreciseThis()}invertPreciseThis(){let t=r.M.constructDouble(this.xy),e=r.M.constructDouble(this.xx),i=e.mulDouble(this.yy).sub(t.mulDouble(this.yx));if(i.isZero())return this.setZero(),this;let s=i.clone();s.invertThis();let n=r.M.constructDouble(this.xd),o=t.mulDouble(this.yd).sub(n.mulDouble(this.yy)).mul(s).toDouble(),a=n.mulDouble(this.yx).sub(e.mulDouble(this.yd)).mul(s).toDouble(),l=s.mulDouble(this.yy).toDouble(),h=s.mulDouble(-this.xy).toDouble(),m=s.mulDouble(-this.yx).toDouble(),u=s.mulDouble(this.xx).toDouble();return this.xd=o,this.yd=a,this.xx=l,this.yy=u,this.xy=h,this.yx=m,this}extractScaleTransform(t,e){let i=Math.sqrt(this.xx*this.xx+this.xy*this.xy),s=Math.sqrt(this.yx*this.yx+this.yy*this.yy);e.setScaleCoords(1/i,1/s),e.multiply(this),t.setScaleCoords(i,s)}setFromTwoTriangles(t,e){let i=!0;for(let s=0;s<3;++s)i&&=t[s].equals(e[s]);if(i)return this.setIdentity(),!0;let s=new r.P;s.setSub(t[0],t[1]);let n=new r.P;n.setSub(t[0],t[2]);let o=new r.P;o.setSub(e[0],e[1]);let a=new r.P;a.setSub(e[0],e[2]);let l=4*2**-52*(Math.abs(s.x*n.y)+Math.abs(n.x*s.y)),h=s.x*n.y-s.y*n.x;return Math.abs(h)>l?(h=1/h,this.xx=(o.x*n.y-s.y*a.x)*h,this.xy=(s.x*a.x-o.x*n.x)*h,this.yx=(o.y*n.y-s.y*a.y)*h,this.yy=(s.x*a.y-o.y*n.x)*h,this.xd=e[0].x-(this.xx*t[0].x+this.xy*t[0].y),this.yd=e[0].y-(this.yx*t[0].x+this.yy*t[0].y),!0):(this.setZero(),!1)}initializeFromControlPoints(t,e,i,n,m=null){return 0===e?(this.setIdentity(),void(m&&m.setIdentity())):1===e?(this.setShift(n[0].sub(i[0])),void(m&&m.setShift(i[0].sub(n[0])))):(e<3&&(t=1),void(4===t&&e>2?function(t,e,i,n,a){let l=r.P.average(i,e),m=r.P.average(n,e),u=new o({NN:2,MM:2});u.setZero();let d=new o({NN:2,MM:2});d.setZero();for(let t=0;t<e;++t)u.setRowCol(0,0,u.atRowCol(0,0)+(i[t].x-l.x)*(i[t].x-l.x)),u.setRowCol(0,1,u.atRowCol(0,1)+(i[t].x-l.x)*(i[t].y-l.y)),u.setRowCol(1,1,u.atRowCol(1,1)+(i[t].y-l.y)*(i[t].y-l.y)),d.setRowCol(0,0,d.atRowCol(0,0)+(n[t].x-m.x)*(i[t].x-l.x)),d.setRowCol(0,1,d.atRowCol(0,1)+(n[t].x-m.x)*(i[t].y-l.y)),d.setRowCol(1,0,d.atRowCol(1,0)+(n[t].y-m.y)*(i[t].x-l.x)),d.setRowCol(1,1,d.atRowCol(1,1)+(n[t].y-m.y)*(i[t].y-l.y));u.setRowCol(1,0,u.atRowCol(0,1));let g=new o({NN:2,MM:2});u.pseudoInverse(g,!0)||(0,s.c)("Failed to compute pseudo inverse"),d.mul(g,d),h(t,d);let c=l.clone();t.transformInPlace(c),t.xd=m.x-c.x,t.yd=m.y-c.y,a&&(d.pseudoInverse(g,!1)||(0,s.c)("Failed to compute pseudo inverse"),h(a,g),a.transformInPlace(m),a.xd=l.x-m.x,a.yd=l.y-m.y)}(this,e,i,n,m):function(t,e,i,n,m,u){(0,s.g)(1===t||0===t||2===t||3===t),e.setIdentity();let d=r.P.average(n,i),g=r.P.average(m,i);if((0,s.g)(t<l.length&&t>0),8&l[t]){let r=new o({NN:2,MM:2});r.setZero();for(let t=0;t<i;++t)r.setRowCol(0,0,r.atRowCol(0,0)+(m[t].x-g.x)*(n[t].x-d.x)),r.setRowCol(1,0,r.atRowCol(1,0)+(m[t].x-g.x)*(n[t].y-d.y)),r.setRowCol(0,1,r.atRowCol(0,1)+(m[t].y-g.y)*(n[t].x-d.x)),r.setRowCol(1,1,r.atRowCol(1,1)+(m[t].y-g.y)*(n[t].y-d.y));let u=new o({NN:2,MM:2}),c=new o({NN:2,MM:1}),_=new o({NN:2,MM:2});r.svd(u,c,_)||(0,s.c)("Failed to compute svd");let p=new o({NN:2,MM:2});u.transpose(p);let f=new o({NN:2,MM:2});_.mul(p,f),32&l[t]||f.determinant()<0&&(p.setRowCol(1,0,-p.atRowCol(1,0)),p.setRowCol(1,1,-p.atRowCol(1,1)),_.mul(p,f));let y=new a;h(y,f),e.set(y)}if(2&l[t]){let t=0,s=0;for(let r=0;r<i;++r){let i=n[r].sub(d);t+=i.sqrLength(),e.transformInPlace(i),s+=i.dotProduct(m[r].sub(g))}if(0===t)0===s?e.setIdentity():e.setZero();else{let i=s/t;e.scale(i,i)}}else(0,s.g)(!(4&l[t]));let c=d.clone();e.transformInPlace(c),e.xd=g.x-c.x,e.yd=g.y-c.y,u&&(u.set(e),u.invertThis(),u.isZero()&&(u.xd=d.x,u.yd=d.y))}(t,this,e,i,n,m)))}calculateErrors(t,e,i,n){(0,s.g)(t>0&&null!==e&&null!==i);let o=0;for(let s=0;s<t;++s){let t=this.transform(e[s]),a=r.P.sqrDistance(i[s],t);o+=a,n&&(n[s]=Math.sqrt(a))}return Math.sqrt(o/t)}}const l=[43,11,41,9,61];function h(t,e){(0,s.g)(!(2!==e.rows()&&3!==e.rows()||2!==e.cols()&&3!==e.rows())),t.xx=e.atRowCol(0,0),t.xy=e.atRowCol(0,1),t.yx=e.atRowCol(1,0),t.yy=e.atRowCol(1,1),3===e.cols()?(t.xd=e.atRowCol(0,2),t.yd=e.atRowCol(1,2)):(t.xd=0,t.yd=0)}}}]);