@arcgis/core 5.0.0-next.49 → 5.0.0-next.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/Components/baUtils.js +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0000781c850b1b4828b3.js +1 -0
- package/assets/esri/core/workers/chunks/00f044370bf3bb6b24d7.js +1 -0
- package/assets/esri/core/workers/chunks/0136cd1a5da204b6daeb.js +1 -0
- package/assets/esri/core/workers/chunks/044a0ccd89741c1ae770.js +1 -0
- package/assets/esri/core/workers/chunks/090dad5579f0148d6486.js +1 -0
- package/assets/esri/core/workers/chunks/09bd9bd37a339802907a.js +1 -0
- package/assets/esri/core/workers/chunks/0bc01d71ed1ab8c3af3c.js +1 -0
- package/assets/esri/core/workers/chunks/0d9904ba62558686c289.js +1 -0
- package/assets/esri/core/workers/chunks/0fcb40204db8ee5571c3.js +1 -0
- package/assets/esri/core/workers/chunks/1065fd655bb7cee243fd.js +1 -0
- package/assets/esri/core/workers/chunks/11ab10668632648b2ba7.js +1 -0
- package/assets/esri/core/workers/chunks/13167bdd486b41163147.js +1 -0
- package/assets/esri/core/workers/chunks/{d8db2c51b2fb42f37b2a.js → 1363345f31f4f5051132.js} +1 -1
- package/assets/esri/core/workers/chunks/13be94357dcf5afc4fcb.js +1 -0
- package/assets/esri/core/workers/chunks/{e66bcdfd75e0113d1cec.js → 13ce8e8d45779b11ee12.js} +1 -1
- package/assets/esri/core/workers/chunks/1693f19f1c37e0a2087e.js +1 -0
- package/assets/esri/core/workers/chunks/18ab5959ebf8689f8fe8.js +1 -0
- package/assets/esri/core/workers/chunks/18c4cd160a4052b05831.js +1 -0
- package/assets/esri/core/workers/chunks/1bf4b5e5402790ccb450.js +1 -0
- package/assets/esri/core/workers/chunks/1db058f91a8e17b24db6.js +1 -0
- package/assets/esri/core/workers/chunks/1dc3ab52fcde7bff0f23.js +1 -0
- package/assets/esri/core/workers/chunks/{a7cd795042ebb8585906.js → 1f0c7ab33e466a37c7f9.js} +1 -1
- package/assets/esri/core/workers/chunks/224f01b11fdba9250b1e.js +1 -0
- package/assets/esri/core/workers/chunks/{a1a7b0e7ca488c895cb7.js → 22c115ec003351c7d8ee.js} +1 -1
- package/assets/esri/core/workers/chunks/24c35a46cf8ed11b774d.js +1 -0
- package/assets/esri/core/workers/chunks/27794d48c04a5875fd22.js +1 -0
- package/assets/esri/core/workers/chunks/294acaaebfedb05fe81e.js +1 -0
- package/assets/esri/core/workers/chunks/2a66841243975cac3e3c.js +1 -0
- package/assets/esri/core/workers/chunks/2c12848e4934e9bb2bd0.js +1 -0
- package/assets/esri/core/workers/chunks/2d61b6efa17e8c5832da.js +1 -0
- package/assets/esri/core/workers/chunks/2d6fa00273a73d44297d.js +1 -0
- package/assets/esri/core/workers/chunks/2da13c2269ab90281143.js +1 -0
- package/assets/esri/core/workers/chunks/2dfaead2ec6434513d45.js +1 -0
- package/assets/esri/core/workers/chunks/2fae37f34b28a46841e3.js +1 -0
- package/assets/esri/core/workers/chunks/{3298e96d3f2e49e338d2.js → 308fb48d080e01499a26.js} +1 -1
- package/assets/esri/core/workers/chunks/30dd4a7c93b33988a270.js +1 -0
- package/assets/esri/core/workers/chunks/355c8d0eadfff9f62dfb.js +1 -0
- package/assets/esri/core/workers/chunks/35961e71f69ae1d24b9e.js +1 -0
- package/assets/esri/core/workers/chunks/36a04be40369111a633d.js +1 -0
- package/assets/esri/core/workers/chunks/36d9208895abd1ba4ff1.js +1 -0
- package/assets/esri/core/workers/chunks/395a0773ccafd1f24c4d.js +1 -0
- package/assets/esri/core/workers/chunks/{81a60dfa600b690098f9.js → 3a612f873e29348370b2.js} +1 -1
- package/assets/esri/core/workers/chunks/3b1471f908fdecec2815.js +1 -0
- package/assets/esri/core/workers/chunks/{da1e61f355fb943085dc.js → 3c66dd52ad156711a6a2.js} +1 -1
- package/assets/esri/core/workers/chunks/3dd0db77a05263000bd8.js +1 -0
- package/assets/esri/core/workers/chunks/{08c1ea29678da27136f3.js → 44fb1184eeed0636704a.js} +1 -1
- package/assets/esri/core/workers/chunks/46d430a6983b81ba7556.js +1 -0
- package/assets/esri/core/workers/chunks/472d290f8eb1c1a85724.js +1 -0
- package/assets/esri/core/workers/chunks/47338472f5a8e004a671.js +1 -0
- package/assets/esri/core/workers/chunks/48b3906ac3ec57253d90.js +1 -0
- package/assets/esri/core/workers/chunks/{2a41283bba2361afa1fd.js → 495af366ec1defd89a72.js} +1 -1
- package/assets/esri/core/workers/chunks/49b581782f63abb6dd9f.js +1 -0
- package/assets/esri/core/workers/chunks/49df576f0215618aa651.js +1 -0
- package/assets/esri/core/workers/chunks/4abe2c56aecc9e9b8e86.js +1 -0
- package/assets/esri/core/workers/chunks/4e01e509a761a9d00b52.js +1 -0
- package/assets/esri/core/workers/chunks/{9d0f0d055ec25af037e0.js → 51093e552e31344cefa5.js} +1 -1
- package/assets/esri/core/workers/chunks/521aac8a665e98e4ca78.js +1 -0
- package/assets/esri/core/workers/chunks/54666586754949bfa584.js +1 -0
- package/assets/esri/core/workers/chunks/549f4ab9e285deaf04fb.js +1 -0
- package/assets/esri/core/workers/chunks/553ca1e55e9f1359839c.js +1 -0
- package/assets/esri/core/workers/chunks/{6f3943bebe2d5f4994f7.js → 58242447b72cc60a5040.js} +1 -1
- package/assets/esri/core/workers/chunks/58419d362f24b35003c1.js +1 -0
- package/assets/esri/core/workers/chunks/5aa354854219361f722b.js +1 -0
- package/assets/esri/core/workers/chunks/{aab93e885b6c7c6aa76e.js → 5ce524e0060053f35592.js} +19 -19
- package/assets/esri/core/workers/chunks/5d244fcf5c075afccdc6.js +1 -0
- package/assets/esri/core/workers/chunks/5e9fdd4eff7189f45932.js +1 -0
- package/assets/esri/core/workers/chunks/60954ab810dbbf36e5e1.js +1 -0
- package/assets/esri/core/workers/chunks/62ed6b45482e39d67785.js +1 -0
- package/assets/esri/core/workers/chunks/63b8193ad90b2ebe6884.js +1 -0
- package/assets/esri/core/workers/chunks/63c91421a71ae3b3599e.js +1 -0
- package/assets/esri/core/workers/chunks/63cf702cde83692126be.js +1 -0
- package/assets/esri/core/workers/chunks/687d2b761dc5b5cf0c31.js +1 -0
- package/assets/esri/core/workers/chunks/6cfcfebe9a4c491e453a.js +1 -0
- package/assets/esri/core/workers/chunks/{88aa71f02f43bb069345.js → 7033fa18b7dd7bd3e49c.js} +1 -1
- package/assets/esri/core/workers/chunks/710b29729f252f11115d.js +1 -0
- package/assets/esri/core/workers/chunks/72a520802b8accfd4512.js +1 -0
- package/assets/esri/core/workers/chunks/{72fbee59d5d909615408.js → 73892ac79b24b05e6863.js} +1 -1
- package/assets/esri/core/workers/chunks/73c3ee2697265b0f7208.js +1 -0
- package/assets/esri/core/workers/chunks/73f9cbf0f919b6adc2d5.js +1 -0
- package/assets/esri/core/workers/chunks/75e9759290f0f67b2128.js +1 -0
- package/assets/esri/core/workers/chunks/7737e69da604d2521da8.js +1 -0
- package/assets/esri/core/workers/chunks/{8e8d5422f57269d8c8d2.js → 7891825d5cdca03d2db0.js} +1 -1
- package/assets/esri/core/workers/chunks/7cd0ab01933bfb2c6e43.js +1 -0
- package/assets/esri/core/workers/chunks/81c2cc77c275a5b555c0.js +1 -0
- package/assets/esri/core/workers/chunks/82ace0195b63790b22c9.js +1 -0
- package/assets/esri/core/workers/chunks/8892bf3d2367e35de001.js +1 -0
- package/assets/esri/core/workers/chunks/8a132d91077ecf849248.js +1 -0
- package/assets/esri/core/workers/chunks/8a6e50d95539b46f629c.js +1 -0
- package/assets/esri/core/workers/chunks/8d941204425571b656ec.js +1 -0
- package/assets/esri/core/workers/chunks/914746077017fa50933f.js +1 -0
- package/assets/esri/core/workers/chunks/{004c2a1a37b99a184b13.js → 91fba3bebd78cb956941.js} +1 -1
- package/assets/esri/core/workers/chunks/92ec96aa743cabc9475d.js +1 -0
- package/assets/esri/core/workers/chunks/{5b290d18de61789417f9.js → 9361834d2c3064eb41fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{44f036cc21e3a2308f69.js → 93b139be6488a1b4ba19.js} +1 -1
- package/assets/esri/core/workers/chunks/95057105f1b3bf805140.js +1 -0
- package/assets/esri/core/workers/chunks/968335b28b895e19913b.js +1 -0
- package/assets/esri/core/workers/chunks/973bf2ed34d57f299472.js +1 -0
- package/assets/esri/core/workers/chunks/9b6e2099aabf67b9f9f2.js +1 -0
- package/assets/esri/core/workers/chunks/{97b01803d0c38541aa08.js → 9c93eadbd19bef1191b4.js} +1 -1
- package/assets/esri/core/workers/chunks/a1594486177015e8a6c3.js +1 -0
- package/assets/esri/core/workers/chunks/{df458ad51be27df3d79d.js → a1f264abbd6354c333bf.js} +1 -1
- package/assets/esri/core/workers/chunks/a3407ca77b0ff62c0e75.js +1 -0
- package/assets/esri/core/workers/chunks/{8be61e13530fd0dc2fd1.js → a4f89568205d78d91cfe.js} +1 -1
- package/assets/esri/core/workers/chunks/a5e7c9517939f762c518.js +1 -0
- package/assets/esri/core/workers/chunks/a63ff3e9a9f3853d12f3.js +1 -0
- package/assets/esri/core/workers/chunks/a81a7cba815adb575c36.js +1 -0
- package/assets/esri/core/workers/chunks/{fe6fa1f2c2d54d41645e.js → a8dfd246c797f3b979f5.js} +1 -1
- package/assets/esri/core/workers/chunks/a8f7e44657083f6aa3fd.js +1 -0
- package/assets/esri/core/workers/chunks/a8fd635d1165db8616ab.js +1 -0
- package/assets/esri/core/workers/chunks/a92c1171314a68504c1b.js +1 -0
- package/assets/esri/core/workers/chunks/aa297e0931213341f51b.js +1 -0
- package/assets/esri/core/workers/chunks/aa7a1705266eec353cb6.js +1 -0
- package/assets/esri/core/workers/chunks/ab5e2f823960c33cefe4.js +1 -0
- package/assets/esri/core/workers/chunks/{f11453f24c0b728669d2.js → ac6f002cfad42e60de8f.js} +1 -1
- package/assets/esri/core/workers/chunks/b11c0e80e583f2b7c5de.js +1 -0
- package/assets/esri/core/workers/chunks/b14f9a46e583e1625a2b.js +1 -0
- package/assets/esri/core/workers/chunks/{8c271e9272e4eaf1325a.js → b1d3d2c93c189e215f67.js} +1 -1
- package/assets/esri/core/workers/chunks/b2425f6af7df6902dfc4.js +1 -0
- package/assets/esri/core/workers/chunks/b638ce18b93d3cfb9967.js +1 -0
- package/assets/esri/core/workers/chunks/b648a1e641cf5c772d67.js +1 -0
- package/assets/esri/core/workers/chunks/{1c58064ea80e6a4a4a3b.js → b907d16e82ac908bb896.js} +1 -1
- package/assets/esri/core/workers/chunks/b91c13f44f4d1bac5799.js +1 -0
- package/assets/esri/core/workers/chunks/ba7e97b1e324118b8156.js +1 -0
- package/assets/esri/core/workers/chunks/bb4aefaf9b0327dda738.js +1 -0
- package/assets/esri/core/workers/chunks/{9664d9e679abc41f6c42.js → bce81df760f5e34c01d7.js} +1 -1
- package/assets/esri/core/workers/chunks/be6a05d5375e80968877.js +1 -0
- package/assets/esri/core/workers/chunks/c02b09f16241db233103.js +1 -0
- package/assets/esri/core/workers/chunks/c09cba77ee60a3d765e2.js +1 -0
- package/assets/esri/core/workers/chunks/c0d6336c10b4081c4e32.js +1 -0
- package/assets/esri/core/workers/chunks/c27842a34e73ccb46116.js +1 -0
- package/assets/esri/core/workers/chunks/c7802c144959d60e774a.js +1 -0
- package/assets/esri/core/workers/chunks/c91201b37d1cb3875fb4.js +1 -0
- package/assets/esri/core/workers/chunks/cc4ae105e727d9211d82.js +1 -0
- package/assets/esri/core/workers/chunks/cd39a53ef74f47604977.js +1 -0
- package/assets/esri/core/workers/chunks/d22e0d733bfe821c0510.js +1 -0
- package/assets/esri/core/workers/chunks/{d7878fba02814adaf19f.js → d57577c02fb2932e8305.js} +1 -1
- package/assets/esri/core/workers/chunks/d62193323c67b379dee3.js +1 -0
- package/assets/esri/core/workers/chunks/d7a62504e00989202c45.js +1 -0
- package/assets/esri/core/workers/chunks/{adfe28c1c1619cdd3ca1.js → d8511e71c5108a0ba9eb.js} +2 -2
- package/assets/esri/core/workers/chunks/da922e861d5845ae0979.js +1 -0
- package/assets/esri/core/workers/chunks/dbe55d4731227d6e9571.js +1 -0
- package/assets/esri/core/workers/chunks/de05c59da6d67716795d.js +1 -0
- package/assets/esri/core/workers/chunks/de60421029fbcebe2950.js +1 -0
- package/assets/esri/core/workers/chunks/e00d56ae5e68267fe269.js +1 -0
- package/assets/esri/core/workers/chunks/{fecae7495e53bb05f282.js → e25be3b6b67ce6b03011.js} +1 -1
- package/assets/esri/core/workers/chunks/e2973e5626e5039209f9.js +1 -0
- package/assets/esri/core/workers/chunks/e2c7c269be93c552dc5b.js +1 -0
- package/assets/esri/core/workers/chunks/e4d593ddcbcf06010ab0.js +1 -0
- package/assets/esri/core/workers/chunks/e5ac9b048b16fef9840c.js +1 -0
- package/assets/esri/core/workers/chunks/{f7163048146ddaedfc36.js → e668ddc7332e5e560e78.js} +1 -1
- package/assets/esri/core/workers/chunks/e6bab7b739bfbb39f6cd.js +1 -0
- package/assets/esri/core/workers/chunks/{8b578ffc3a83089aa782.js → e7c08a03772f7fccd949.js} +1 -1
- package/assets/esri/core/workers/chunks/e8e4d48ab4024e17108d.js +1 -0
- package/assets/esri/core/workers/chunks/e9e0f1c355f963cbea74.js +1 -0
- package/assets/esri/core/workers/chunks/ec7e6427d99cf3148a61.js +1 -0
- package/assets/esri/core/workers/chunks/edd3cf415955309b4ca4.js +1 -0
- package/assets/esri/core/workers/chunks/ee361690b456c12c30d8.js +1 -0
- package/assets/esri/core/workers/chunks/efa95c50d1ed8e74219f.js +1 -0
- package/assets/esri/core/workers/chunks/f142c5cbdd16f1768275.js +1 -0
- package/assets/esri/core/workers/chunks/f286f13686f003c5eec5.js +1 -0
- package/assets/esri/core/workers/chunks/f379fd459a103f42d447.js +1 -0
- package/assets/esri/core/workers/chunks/{f2ba50eb29f93df885d6.js → f3d8d5fe15501220792d.js} +1 -1
- package/assets/esri/core/workers/chunks/f56906c443ce8ff68a27.js +1 -0
- package/assets/esri/core/workers/chunks/fb6670a929b7333f1764.js +1 -0
- package/assets/esri/core/workers/chunks/fbdf553253cf8f22c022.js +1 -0
- package/assets/esri/core/workers/chunks/fc10c738bae304721ab2.js +1 -0
- package/assets/esri/core/workers/chunks/ff79c2cb28db7e0a1fc4.js +1 -0
- package/assets/esri/core/workers/chunks/ffdf1cbc1e54414d0f96.js +1 -0
- package/assets/esri/themes/base/widgets/_Attribution.scss +7 -4
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/Bufferer-Dw9Qi4T1.js +1 -1
- package/chunks/Distance2DCalculator-CXhBP-8I.js +1 -1
- package/chunks/Envelope.js +1 -1
- package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +1 -1
- package/chunks/GeodeticUtils.js +1 -1
- package/chunks/Geometry.js +1 -1
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorCrosses.js +1 -1
- package/chunks/OperatorCut.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorIntersects.js +1 -1
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorOverlaps.js +1 -1
- package/chunks/OperatorProject.js +1 -1
- package/chunks/OperatorProximity.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/OperatorSimplifyOGC.js +1 -1
- package/chunks/OperatorTouches.js +1 -1
- package/chunks/OperatorWithin.js +1 -1
- package/chunks/Point2D.js +1 -1
- package/chunks/ProjectionTransformation.js +1 -1
- package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
- package/chunks/SpatialReference.js +1 -1
- package/chunks/boundedPlane.js +1 -1
- package/chunks/containsOperator.js +1 -1
- package/chunks/disjointOperator.js +1 -1
- package/chunks/equalsOperator.js +1 -1
- package/chunks/pe.js +1 -1
- package/chunks/relateOperator.js +1 -1
- package/config.js +1 -1
- package/core/units.js +1 -1
- package/core/workers/workerFactory.js +1 -1
- package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
- package/editing/sharedTemplates/executor/builders/support/offsetUtils.js +1 -1
- package/editing/sharedTemplates/executor/createTemplateExecutor.js +1 -1
- package/geometry/FlatGeometry.js +1 -1
- package/geometry/GeometryCursor.js +1 -1
- package/geometry/operators/containsOperator.js +1 -1
- package/geometry/operators/disjointOperator.js +1 -1
- package/geometry/operators/gx/geodeticUtils.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorBuffer.js +1 -1
- package/geometry/operators/gx/operatorDifference.js +1 -1
- package/geometry/operators/gx/operatorGeodesicBuffer.js +1 -1
- package/geometry/operators/gx/operatorGeodeticArea.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDensify.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
- package/geometry/operators/gx/operatorGeodeticLength.js +1 -1
- package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorIntersection.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorProject.js +1 -1
- package/geometry/operators/gx/operatorProximityGeodesic.js +1 -1
- package/geometry/operators/gx/operatorShapePreservingProject.js +1 -1
- package/geometry/operators/gx/operatorSimplify.js +1 -1
- package/geometry/operators/gx/operatorSinglePartToMultiPart.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/gx/operatorUnion.js +1 -1
- package/geometry/operators/json/containsOperator.js +1 -1
- package/geometry/operators/json/disjointOperator.js +1 -1
- package/geometry/operators/json/projectOperator.js +1 -1
- package/geometry/operators/projectOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/support/geographicTransformationUtils.js +1 -1
- package/geometry/operators/support/initNoPeFactory.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/geometry/operators/support/projectionTransformation.js +1 -1
- package/geometry/operators/support/projectionZScaling.js +5 -0
- package/geometry/projection/projectPointToVector.js +1 -1
- package/geometry/projectionUtils.js +1 -1
- package/geometry/support/boundedPlane.js +1 -1
- package/geometry/support/jsonTypeUtils.js +5 -0
- package/geometry/support/jsonUtils.js +1 -1
- package/geometry/support/normalizeUtilsCommon.js +1 -1
- package/geometry/support/normalizeUtilsSync.js +1 -1
- package/geometry/support/quantizationUtils.js +1 -1
- package/geometry/support/zscale.js +1 -1
- package/interfaces.d.ts +84 -17
- package/kernel.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/queryUtils.js +1 -1
- package/layers/graphics/data/spatialQuerySupport.js +1 -1
- package/layers/graphics/featureConversionUtils.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/graphics/sources/support/uploadAssets.js +1 -1
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/support/ControlPointsGeoreference.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/package.json +4 -4
- package/renderers/support/DictionaryLoader.js +1 -1
- package/renderers/support/pointCloud/PointSizeFixedSizeAlgorithm.js +1 -1
- package/renderers/support/pointCloud/PointSizeSplatAlgorithm.js +1 -1
- package/rest/geometryService/cut.js +1 -1
- package/rest/geometryService/difference.js +1 -1
- package/rest/geometryService/intersect.js +1 -1
- package/rest/geometryService/project.js +1 -1
- package/rest/geometryService/reshape.js +1 -1
- package/rest/geometryService/simplify.js +1 -1
- package/rest/geometryService/utils.js +1 -1
- package/rest/knowledgeGraph/DataModel.js +1 -1
- package/rest/operations/generalize.js +1 -1
- package/rest/operations/identify.js +1 -1
- package/rest/operations/offset.js +1 -1
- package/rest/operations/relation.js +1 -1
- package/rest/query/operations/queryAttributeBins.js +1 -1
- package/rest/query/operations/queryTopFeatures.js +1 -1
- package/rest/query/operations/queryUtils.js +1 -1
- package/rest/support/BaseImageMeasureResultValue.js +1 -1
- package/rest/support/BufferParameters.js +1 -1
- package/rest/support/DensifyParameters.js +1 -1
- package/rest/support/DistanceParameters.js +1 -1
- package/rest/support/FeatureSet.js +1 -1
- package/rest/support/IdentifyParameters.js +1 -1
- package/rest/support/ImageAreaParameters.js +1 -1
- package/rest/support/ImageDistanceParameters.js +1 -1
- package/rest/support/ImageGPSInfoParameters.js +1 -1
- package/rest/support/ImageHeightParameters.js +1 -1
- package/rest/support/ImageHistogramParameters.js +1 -1
- package/rest/support/ImageIdentifyParameters.js +1 -1
- package/rest/support/ImageMeasureResultAngleValue.js +1 -1
- package/rest/support/ImageMeasureResultAreaValue.js +1 -1
- package/rest/support/ImageMeasureResultLengthValue.js +1 -1
- package/rest/support/ImagePointParameters.js +1 -1
- package/rest/support/ImageSampleParameters.js +1 -1
- package/rest/support/ImageToMapMultirayParameters.js +1 -1
- package/rest/support/ImageToMapParameters.js +1 -1
- package/rest/support/ImageVolumeParameters.js +1 -1
- package/rest/support/MapToImageParameters.js +1 -1
- package/rest/support/MeasureFromImageParameters.js +1 -1
- package/rest/support/ProjectParameters.js +1 -1
- package/support/modeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/support/tests/serviceMockDependencies.js +1 -1
- package/symbols/MarkerSymbol.js +1 -1
- package/symbols/PictureMarkerSymbol.js +1 -1
- package/symbols/SimpleFillSymbol.js +1 -1
- package/symbols/SimpleMarkerSymbol.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/CIMSymbolRasterizer.js +1 -1
- package/symbols/cim/SDFHelper.js +1 -1
- package/symbols/cim/effects/EffectOffset.js +1 -1
- package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
- package/symbols/support/ObjectSymbol3DLayerResource.js +1 -1
- package/views/2d/analysis/ElevationProfile/ElevationProfileVisualization2D.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/layers/graphics/GraphicStoreItem.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/ShadowCast/analysisViewRegister.js +5 -0
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/Slice/SliceController.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
- package/views/3d/analysis/support/projectionUtils.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
- package/views/3d/layers/DynamicLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/GraphicsLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/RouteLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/support/featureReference.js +1 -1
- package/views/3d/state/ScreenSizePerspective.js +1 -1
- package/views/3d/support/ViewSlice.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowPresets.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/SliceHelper.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/Attribution.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/PopupView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/View.js +1 -1
- package/views/View2D.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +1 -1
- package/views/draw/DrawAction.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
- package/views/layers/CatalogFootprintLayerView.js +1 -1
- package/views/layers/LayerView.js +1 -1
- package/views/support/attributionUtils.js +1 -1
- package/views/support/projectionUtils.js +1 -1
- package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
- package/widgets/OrientedImageryViewer/support/NonPanoramicMedia.js +5 -0
- package/widgets/OrientedImageryViewer/support/NonPanoramicMediaCollection.js +5 -0
- package/widgets/OrientedImageryViewer/support/urlUtils.js +5 -0
- package/widgets/OrientedImageryViewer/utils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/PanoramicViewer.js +1 -1
- package/widgets/Slice.js +1 -1
- package/widgets/Swipe/SwipeViewModel.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/Track.js +1 -1
- package/widgets/UtilityNetworkAssociations.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
- package/widgets/Weather.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js +1 -1
- package/assets/esri/core/workers/chunks/00ff4ca88c9d291d82c3.js +0 -1
- package/assets/esri/core/workers/chunks/0271a2ca4e9b1e4fd284.js +0 -1
- package/assets/esri/core/workers/chunks/02a65563779b4c64b2cf.js +0 -1
- package/assets/esri/core/workers/chunks/02d1c48e874dfd985bc4.js +0 -1
- package/assets/esri/core/workers/chunks/05b7720ab6bf0874f27c.js +0 -1
- package/assets/esri/core/workers/chunks/061def9163a09c804b5c.js +0 -1
- package/assets/esri/core/workers/chunks/06221ebadab32111e2c6.js +0 -1
- package/assets/esri/core/workers/chunks/063045ac5553e91c0c4c.js +0 -1
- package/assets/esri/core/workers/chunks/06d52a570d5d44f8c86e.js +0 -1
- package/assets/esri/core/workers/chunks/0a58b57e1777a8b0ea23.js +0 -1
- package/assets/esri/core/workers/chunks/0e4d0213d568f50c231f.js +0 -1
- package/assets/esri/core/workers/chunks/103153951ba312dc5e9e.js +0 -1
- package/assets/esri/core/workers/chunks/169be08394c5e7703628.js +0 -1
- package/assets/esri/core/workers/chunks/1a6f3531ef3d671e0289.js +0 -1
- package/assets/esri/core/workers/chunks/1c816aff8613d1e4bf38.js +0 -1
- package/assets/esri/core/workers/chunks/1e2d42e9984ed3437ba2.js +0 -1
- package/assets/esri/core/workers/chunks/2008b22f76071a2dde4e.js +0 -1
- package/assets/esri/core/workers/chunks/20e4243ea563d05a5256.js +0 -1
- package/assets/esri/core/workers/chunks/2107c93d1fe87f3b8dfa.js +0 -1
- package/assets/esri/core/workers/chunks/21f37a4b8d1857369203.js +0 -1
- package/assets/esri/core/workers/chunks/229e1ed4282005aa0b83.js +0 -1
- package/assets/esri/core/workers/chunks/22b8eaa6afab0e5ffc47.js +0 -1
- package/assets/esri/core/workers/chunks/231c0b583fa97f2ca675.js +0 -1
- package/assets/esri/core/workers/chunks/233f9eb617f3d72995b5.js +0 -1
- package/assets/esri/core/workers/chunks/2463cebf904a3c46c639.js +0 -1
- package/assets/esri/core/workers/chunks/249504f7d356be80d214.js +0 -1
- package/assets/esri/core/workers/chunks/2550d2ba935cfdf30236.js +0 -1
- package/assets/esri/core/workers/chunks/273ac1066095d63d6a6f.js +0 -1
- package/assets/esri/core/workers/chunks/28db329528def851efd7.js +0 -1
- package/assets/esri/core/workers/chunks/2de32649f8b0c6404d7c.js +0 -1
- package/assets/esri/core/workers/chunks/2e2867bc66c94aba7dc7.js +0 -1
- package/assets/esri/core/workers/chunks/30c4af16e3a2acc25589.js +0 -1
- package/assets/esri/core/workers/chunks/32d32d3c3b38a215d20d.js +0 -1
- package/assets/esri/core/workers/chunks/3386d4392f465b807b94.js +0 -1
- package/assets/esri/core/workers/chunks/34613b288cf174983f8b.js +0 -1
- package/assets/esri/core/workers/chunks/35f086a2ae0585348ae6.js +0 -1
- package/assets/esri/core/workers/chunks/37ea150dec5e491f691e.js +0 -1
- package/assets/esri/core/workers/chunks/3ac8de121a07c70bae0f.js +0 -1
- package/assets/esri/core/workers/chunks/3c94db7ecdcd38eeb1b1.js +0 -1
- package/assets/esri/core/workers/chunks/3f7749f06ae54a4437d9.js +0 -1
- package/assets/esri/core/workers/chunks/40a722933af28823953b.js +0 -1
- package/assets/esri/core/workers/chunks/444026d1938c1078ca97.js +0 -1
- package/assets/esri/core/workers/chunks/44f759d723ae05bb1b19.js +0 -1
- package/assets/esri/core/workers/chunks/456684b1c1417ed0e611.js +0 -1
- package/assets/esri/core/workers/chunks/48e2737182c75005fb8f.js +0 -1
- package/assets/esri/core/workers/chunks/48f805929fe6241952f5.js +0 -1
- package/assets/esri/core/workers/chunks/4a48b8ec5f3f2fd139b5.js +0 -1
- package/assets/esri/core/workers/chunks/4b084f985bc4100e7aec.js +0 -1
- package/assets/esri/core/workers/chunks/4b1de1fcd13677b615a8.js +0 -1
- package/assets/esri/core/workers/chunks/4d933de84afb2e3b7d18.js +0 -1
- package/assets/esri/core/workers/chunks/4f0de45a0a295d66d446.js +0 -1
- package/assets/esri/core/workers/chunks/4ff771942531fb2755c4.js +0 -1
- package/assets/esri/core/workers/chunks/513a4ef960e27500f986.js +0 -1
- package/assets/esri/core/workers/chunks/56b693baa376bb990925.js +0 -1
- package/assets/esri/core/workers/chunks/57fd5e1260269002d18a.js +0 -1
- package/assets/esri/core/workers/chunks/5b73c77587772120b209.js +0 -1
- package/assets/esri/core/workers/chunks/5fe40bb0e9ab333f6854.js +0 -1
- package/assets/esri/core/workers/chunks/61373d2fa7e7638d3395.js +0 -1
- package/assets/esri/core/workers/chunks/6202922b1c2637e9aaa5.js +0 -1
- package/assets/esri/core/workers/chunks/633368ae6fbb46373328.js +0 -1
- package/assets/esri/core/workers/chunks/6d0fe4db6b94f3d2c53a.js +0 -1
- package/assets/esri/core/workers/chunks/6d702cb26cef46a76963.js +0 -1
- package/assets/esri/core/workers/chunks/6e8925412fb90f88d688.js +0 -1
- package/assets/esri/core/workers/chunks/6e8c20ff1d28ef2fe72c.js +0 -1
- package/assets/esri/core/workers/chunks/708aba69a1870ea41a61.js +0 -1
- package/assets/esri/core/workers/chunks/74b1028e95f7cfff387b.js +0 -1
- package/assets/esri/core/workers/chunks/755ce019c97f5d527772.js +0 -1
- package/assets/esri/core/workers/chunks/780f60210878a8286633.js +0 -1
- package/assets/esri/core/workers/chunks/78fccea3445fb2f9120a.js +0 -1
- package/assets/esri/core/workers/chunks/7d3c2a063598bdd015e2.js +0 -1
- package/assets/esri/core/workers/chunks/7eab0bb42f9f062522ef.js +0 -1
- package/assets/esri/core/workers/chunks/804958f3f4ff47a4eff5.js +0 -1
- package/assets/esri/core/workers/chunks/82ba4140e30f083fbc87.js +0 -1
- package/assets/esri/core/workers/chunks/833fd2bc42c5cb459084.js +0 -1
- package/assets/esri/core/workers/chunks/83c8e5a92d8d6193cb32.js +0 -1
- package/assets/esri/core/workers/chunks/83da9ee6544ee9d3c124.js +0 -1
- package/assets/esri/core/workers/chunks/870022661376442411e4.js +0 -1
- package/assets/esri/core/workers/chunks/897ce6fc9cefb1e14a64.js +0 -1
- package/assets/esri/core/workers/chunks/898ab7db220e81e921c6.js +0 -1
- package/assets/esri/core/workers/chunks/8b75861196d1ce5cba63.js +0 -1
- package/assets/esri/core/workers/chunks/8c07396e9ea3007d6404.js +0 -1
- package/assets/esri/core/workers/chunks/8e26831f71634288f834.js +0 -1
- package/assets/esri/core/workers/chunks/8ec238b5b59ef18a1713.js +0 -1
- package/assets/esri/core/workers/chunks/90b8ccee883738917a6d.js +0 -1
- package/assets/esri/core/workers/chunks/90bc9c299ae0e8b8b5e5.js +0 -1
- package/assets/esri/core/workers/chunks/9100330ed4b4437c819d.js +0 -1
- package/assets/esri/core/workers/chunks/933dce4d4ff8b90219c8.js +0 -1
- package/assets/esri/core/workers/chunks/934bc1028b287f8df4aa.js +0 -1
- package/assets/esri/core/workers/chunks/94dc8b0fa129f1e168c4.js +0 -1
- package/assets/esri/core/workers/chunks/96055de47831e59a28bf.js +0 -1
- package/assets/esri/core/workers/chunks/963ba863e0f87abfca25.js +0 -1
- package/assets/esri/core/workers/chunks/987e19af8a525e77883f.js +0 -1
- package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.js +0 -1
- package/assets/esri/core/workers/chunks/9aa8d60483ad905fe13b.js +0 -1
- package/assets/esri/core/workers/chunks/9c0efd06c9000ccbd62d.js +0 -1
- package/assets/esri/core/workers/chunks/9f1d3c0b53bef07e39bf.js +0 -1
- package/assets/esri/core/workers/chunks/9fed9946241bb2a5cfa4.js +0 -1
- package/assets/esri/core/workers/chunks/a2662e98857f0abf8e82.js +0 -1
- package/assets/esri/core/workers/chunks/a59dab47a58695c639da.js +0 -1
- package/assets/esri/core/workers/chunks/a5a9b0a35849b9f2e86d.js +0 -1
- package/assets/esri/core/workers/chunks/a60006c9ccf6817fc0d2.js +0 -1
- package/assets/esri/core/workers/chunks/a627b7eb94b7fca33210.js +0 -1
- package/assets/esri/core/workers/chunks/a651dc3b8f1fc1ab34cc.js +0 -1
- package/assets/esri/core/workers/chunks/a96742e678a506c461ab.js +0 -1
- package/assets/esri/core/workers/chunks/af663e81c851bcf142f1.js +0 -1
- package/assets/esri/core/workers/chunks/af8d6e6949930d0e6c7b.js +0 -1
- package/assets/esri/core/workers/chunks/b59be95949445ff5afab.js +0 -1
- package/assets/esri/core/workers/chunks/b6dec5dfdeca54bae88d.js +0 -1
- package/assets/esri/core/workers/chunks/b88dc7d8ae105747e6a4.js +0 -1
- package/assets/esri/core/workers/chunks/b90c786dd474ea1a409c.js +0 -1
- package/assets/esri/core/workers/chunks/b92e9e5df8154a128982.js +0 -1
- package/assets/esri/core/workers/chunks/bbdfa8ffcf084cbd9938.js +0 -1
- package/assets/esri/core/workers/chunks/bff814d34b38ec80c44d.js +0 -1
- package/assets/esri/core/workers/chunks/c36d699a75b6e8fb93eb.js +0 -1
- package/assets/esri/core/workers/chunks/c50fdf723f2d4316862e.js +0 -1
- package/assets/esri/core/workers/chunks/c5e8ff4721b15ac3c6eb.js +0 -1
- package/assets/esri/core/workers/chunks/ca61077e0a598654f33f.js +0 -1
- package/assets/esri/core/workers/chunks/ca81be5bdb88ef557bf3.js +0 -1
- package/assets/esri/core/workers/chunks/ced12ad98f8f48d0dc00.js +0 -1
- package/assets/esri/core/workers/chunks/d0320ca67abca4f8b0d2.js +0 -1
- package/assets/esri/core/workers/chunks/d561624ddb9388732b25.js +0 -1
- package/assets/esri/core/workers/chunks/d5fd6d0eaf96edfab123.js +0 -1
- package/assets/esri/core/workers/chunks/d705410c369bd03b1875.js +0 -1
- package/assets/esri/core/workers/chunks/d82e17522ed946c2d809.js +0 -1
- package/assets/esri/core/workers/chunks/dc29cb16704e2e4d0a46.js +0 -1
- package/assets/esri/core/workers/chunks/dc5075b2326c79130baa.js +0 -1
- package/assets/esri/core/workers/chunks/dd105d6e0fcedee32644.js +0 -1
- package/assets/esri/core/workers/chunks/defc6b50df5018bd9e86.js +0 -1
- package/assets/esri/core/workers/chunks/e1148067ceae7d9eaaf8.js +0 -1
- package/assets/esri/core/workers/chunks/e5a6a646f27715152714.js +0 -1
- package/assets/esri/core/workers/chunks/e8c2e2fbe9cef4c8a8c6.js +0 -1
- package/assets/esri/core/workers/chunks/efc293c8bbc12156096d.js +0 -1
- package/assets/esri/core/workers/chunks/f693a4d97b2762d0e6ff.js +0 -1
- package/assets/esri/core/workers/chunks/f7f53567b0c5b35d6aea.js +0 -1
- package/assets/esri/core/workers/chunks/f92a78ce5510e0d0d0f7.js +0 -1
- package/assets/esri/core/workers/chunks/fb76b43181077c55a207.js +0 -1
- package/assets/esri/core/workers/chunks/fc61443546f21869f8ba.js +0 -1
- package/assets/esri/core/workers/chunks/fdaa10a588db394e2f65.js +0 -1
- package/chunks/UnitFactory.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./Envelope2D.js";import"./Geometry.js";import"./MultiPathImpl.js";import"./Envelope.js";import"./Point2D.js";export{S as SpatialReference,a as SpatialReferencePrecisionDescriptor,c as create,b as createFromWKT,d as createImplFromPe,e as createLocal,f as createWithNewPrecision,g as createWithNewVCS,h as getGCS,i as getTempName,j as hasNoPe,k as hasPe,l as injectNoPe,m as injectPe,n as isInitialized,o as isTempName,p as isValidWkid,q as isValidWkt,r as makeSpheroidData,s as snapGeometry,w as webMercator,t as webMercator102100,u as wgs84}from"./UnitFactory.js";
|
|
5
|
+
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{Envelope2D as s}from"./Envelope2D.js";import{a as n,c as r,G as i,f as o,d as a,h,y as m,g as l,z as g,v as u,A as c,e as _,t as d,p,r as f,i as x,B as y,o as P,C as E,u as S,l as C,D as I,q as b}from"./Geometry.js";import{P as w,I as v,J as N,a as T,M as G,K as D,E as V,c as F,g as H,S as k,L as A,N as M,O as U,n as q,Q as B,R as O,y as Y,T as R,D as X,l as L,U as z,V as W,W as j,X as Z,Y as K,Z as Q,_ as J,$,a0 as ee,a1 as te,a2 as se,a3 as ne,a4 as re,a5 as ie,a6 as oe,a7 as ae,a8 as he,a9 as me,b as le}from"./MultiPathImpl.js";import{b as ge,a as ue,N as ce,Q as _e,i as de,g as pe,c as fe,E as xe,P as ye,C as Pe,e as Ee,R as Se,T as Ce,U as Ie,A as be,B as we,W as ve,J as Ne,X as Te,V as Ge,Y as De,q as Ve,Z as Fe,G as He,_ as ke,$ as Ae,a0 as Me,a1 as Ue,a2 as qe,h as Be,a3 as Oe,S as Ye,y as Re,a4 as Xe,d as Le,a5 as ze,a6 as We,a7 as je,f as Ze}from"./Envelope.js";import{at as Ke,au as Qe,d as Je,P as $e,av as et,v as tt,n as st,aw as nt,Q as rt,ax as it,c as ot,e as at,r as ht,l as mt,E as lt,J as gt,m as ut,K as ct,a as _t,S as dt,q as pt,f as ft,ay as xt,az as yt,g as Pt,U as Et,o as St,s as Ct,aA as It,N as bt,aB as wt,j as vt,b as Nt,i as Tt,h as Gt,k as Dt,a8 as Vt,aC as Ft,M as Ht,G as kt,aD as At,aE as Mt,D as Ut,aF as qt,aG as Bt,aH as Ot,aI as Yt,aJ as Rt,aq as Xt,y as Lt,aK as zt,p as Wt}from"./Point2D.js";import{T as jt}from"./Transformation2D.js";import{c as Zt,O as Kt,a as Qt}from"./OperatorClip.js";import{O as Jt}from"./OperatorDensify.js";import{S as $t,G as es}from"./SimpleGeometryCursor.js";import{NonSimpleResult as ts}from"./OperatorDefinitions.js";class ss{constructor(e){if(this.m_geom=this.m_sr=null,e){if(e.move)return this.m_geom=e.move.m_geom,e.move.m_geom=null,this.m_sr=e.move.m_sr,void(e.move.m_sr=null);if(e.copy)return this.m_geom=e.copy.m_geom?e.copy.m_geom.clone():null,void(this.m_sr=e.copy.m_sr);e.geom&&(this.m_geom=e.geom),e.sr&&(this.m_sr=e.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(e){this.m_geom=e}setSpatialReference(e){this.m_sr=e}equals(e,t){const s=e;return!(!this.m_sr&&s.m_sr)&&(!(this.m_sr&&!s.m_sr)&&(!(!this.m_geom&&s.m_geom)&&(!(this.m_geom&&!s.m_geom)&&(!(this.m_sr&&s.m_sr&&!this.m_sr.equals(s.m_sr))&&!(this.m_geom&&s.m_geom&&!this.m_geom.equals(s.m_geom,t))))))}clone(){let e=null;return this.m_geom&&(e=this.m_geom.clone()),new ss({geom:e,sr:this.m_sr})}hasGeom(){return!!this.m_geom}}class ns{constructor(e){this.m_factor=1,this.m_wkid=0,this.m_peUnit=null,e&&(this.m_peUnit=e,this.m_factor=e.getUnitFactor(),this.m_wkid=e.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit?this.m_peUnit.getName():""}getID(){return this.m_wkid}getConversionFactor(e){return this.getUnitType()!==e.getUnitType()&&n("unit type mismatch"),this.getUnitToBaseFactor()/e.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return Ke(Qe(this.getUnitType()),Qe(this.getUnitToBaseFactor()))}equals(e){return!!e&&(this.getUnitType()===e.getUnitType()&&this.getUnitToBaseFactor()===e.getUnitToBaseFactor()&&this.getID()===e.getID()&&this.getName()===e.getName())}static isValidWkid(e){return!1}}const rs={330:104878,500:104879,1300:104899,1450:104986,2230:104988,3800:104978,5e3:104919,6200:104906,8200:104909,9500:104927,9600:104977,1e4:[104911,104936],11e3:104941,11080:104872,11100:104907,12e3:104920,12400:104995,13e3:104948,14e3:[104923,104989],15e3:[104913,104954],15100:104976,16e3:[104926,104931],18e3:[104922,104982],21e3:104947,21500:104877,27e3:[104950,104957],29e3:104964,3e4:104921,31e3:104949,33e3:104946,4e4:[104914,104967],40600:104897,41900:104937,42e3:104951,43100:104993,49300:104924,50100:104939,54e3:104955,58200:104981,59500:104930,74e3:104961,77e3:104956,79e3:104962,83500:104910,85e3:104917,88800:104934,89200:104985,96e3:104997,104e3:104963,106500:104898,11e4:104938,133e3:104932,135e3:104983,17e4:104965,198200:104987,198630:104935,208e3:104966,235800:104952,249400:104929,252100:104980,255e3:104973,47e4:104972,529800:104942,531e3:104996,56e4:104928,561400:104979,578900:104945,584700:104959,593e3:104970,606e3:104999,718e3:104933,745700:104984,761400:104953,763500:104994,764e3:104940,788900:104958,1188300:104998,1195e3:104969,1352600:104968,1560800:104874,1562090:104915,1737400:104903,1821460:104918,1821490:104876,2409300:104912,2410300:104873,2439400:104974,2439700:104900,2575e3:104943,2631200:104875,2632345:104916,3393400:104904,3396190:[104905,104971],6051e3:104901,6051800:104902,637e4:104128,6370997:[4052,37008],6371e3:4035,6371007:4047,6371228:[4053,10346],6376045:[8042,8043],6376523:[4027,4901,4902],6376896:37007,6378135:[4122,4322,4324,4720,4985,4987],6378136:[4740,4923,7678,7680,9474,9475,104017,104018],6378137:[3823,3824,3888,3889,4017,4019,4023,4031,4040,4046,4055,4074,4075,4080,4081,4121,4126,4130,4133,4140,4141,4148,4151,4152,4163,4166,4167,4170,4171,4172,4173,4176,4180,4189,4190,4258,4269,4283,4318,4319,4326,4463,4466,4469,4470,4480,4482,4483,4490,4557,4558,4612,4617,4619,4624,4627,4659,4661,4667,4669,4670,4674,4686,4687,4693,4694,4702,4737,4742,4747,4749,4750,4755,4756,4757,4758,4759,4761,4762,4763,4764,4765,4883,4885,4887,4889,4893,4895,4898,4907,4909,4921,4925,4927,4929,4931,4933,4935,4937,4939,4941,4943,4945,4947,4949,4951,4953,4955,4957,4959,4961,4963,4965,4967,4971,4975,4977,4979,4981,4983,4989,4997,4999,5012,5013,5245,5246,5251,5252,5263,5264,5323,5324,5340,5342,5353,5354,5359,5360,5364,5365,5370,5371,5372,5373,5380,5381,5392,5393,5488,5489,5545,5546,5592,5593,5885,5886,6134,6135,6310,6311,6318,6319,6321,6322,6324,6325,6364,6365,6667,6668,6705,6706,6782,6783,6980,6982,6983,6987,6989,6990,7034,7035,7036,7037,7038,7039,7040,7041,7042,7072,7073,7084,7085,7086,7087,7133,7135,7136,7138,7139,7372,7373,7657,7659,7661,7663,7665,7685,7686,7797,7798,7816,7843,7844,7880,7881,7885,7886,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7915,7917,7919,7921,7923,7925,7927,7929,7931,8085,8086,8231,8232,8235,8237,8239,8240,8244,8246,8248,8249,8251,8252,8254,8255,8399,8403,8426,8427,8449,8542,8544,8545,8684,8685,8698,8699,8817,8818,8860,8888,8899,8900,8901,8902,8906,8907,8916,8918,8920,8922,8924,8926,8928,8930,8932,8934,8936,8938,8940,8942,8944,8946,8948,8949,8972,8973,8974,8975,8976,8977,8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,8993,8994,8995,8996,8997,8998,8999,9e3,9002,9003,9005,9006,9008,9009,9011,9012,9013,9014,9016,9017,9018,9019,9053,9054,9055,9056,9057,9059,9060,9061,9062,9063,9064,9065,9066,9067,9068,9069,9071,9072,9074,9075,9139,9140,9147,9148,9152,9153,9183,9184,9293,9294,9299,9308,9309,9332,9333,9364,9372,9379,9380,9384,9453,9469,9470,9546,9547,9695,9696,9701,9702,9739,9754,9755,9758,9763,9776,9777,9778,9779,9781,9782,9783,9784,9866,9871,9939,9964,9969,9974,9989,9990,10175,10177,10178,10185,10191,10196,10204,10209,10214,10219,10224,10229,10237,10272,10277,10283,10284,10298,10299,10300,10304,10305,10307,10309,10310,10311,10312,10327,10328,10413,10414,10468,10474,10475,10570,10571,10605,10606,10623,10628,10638,10639,10670,10671,10672,10673,10689,10690,10724,10725,10738,10739,10761,10762,10780,10781,10784,10785,10790,10791,10799,10800,10830,10831,10849,10860,10909,10910,10940,10941,10951,10952,10955,10956,10958,10959,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104030,104031,104033,104048,104049,104050,104100,104107,104108,104110,104111,104114,104115,104116,104117,104118,104119,104120,104121,104122,104123,104124,104129,104133,104134,104137,104141,104142,104143,104144,104145,104179,104180,104181,104182,104183,104184,104185,104186,104199,104220,104221,104223,104257,104258,104259,104260,104286,104287,104602,104613,104644,104645,104646,104647,104653,104804,104896,104991],6378140:4610,6378145:[4025,4276,4760,4891,37001],6378150:37003,6378155:[37004,37207],6378160:[3821,4003,4021,4036,4202,4203,4237,4238,4291,4618,4708,5527,37231,104023,104136],6378166:37002,6378200:[4020,4229,4286,4303,4706],6378245:[4024,4147,4164,4178,4179,4191,4200,4205,4214,4284,4317,4555,4676,4677,4678,4991,4993,5560,5561,37257,104135],6378270:[4732,37005,37229],6378273:[4054,10345],6378300:[4029,4168,4174],6378388:[4022,4123,4153,4154,4158,4159,4160,4161,4165,4181,4182,4183,4184,4185,4192,4194,4195,4196,4199,4204,4207,4208,4215,4218,4221,4224,4225,4230,4231,4233,4235,4236,4247,4248,4249,4254,4255,4259,4264,4265,4271,4272,4274,4285,4287,4288,4292,4297,4309,4311,4313,4316,4472,4475,4611,4614,4615,4616,4621,4622,4623,4625,4626,4628,4629,4630,4631,4632,4633,4636,4637,4639,4641,4642,4643,4644,4645,4646,4658,4660,4662,4663,4664,4665,4668,4672,4673,4684,4688,4689,4690,4691,4692,4698,4704,4705,4707,4709,4710,4711,4712,4714,4715,4716,4718,4719,4721,4722,4724,4725,4727,4728,4729,4730,4733,4734,4735,4739,4741,4753,4754,4802,4803,4806,4809,4810,4823,4824,4900,5524,6883,8428,8430,8431,9248,9251,9253,9403,9893,10158,10249,10252,10635,10636,10735,10736,10758,37e3,37201,37204,37205,37212,37213,37214,37215,37216,37217,37218,37219,37221,37222,37224,37226,37227,37230,37232,37233,37234,37235,37237,37238,37241,37242,37245,37246,37247,37249,37250,37251,37253,37259,104104,104106,104125,104126,104127,104130,104138,104248],6378523:104786,24764e3:104960,25559e3:104944,60268e3:104925,71492e3:104908,6957e5:104975,6377397.155:[3819,3906,4004,4120,4124,4125,4149,4150,4156,4162,4211,4219,4257,4262,4280,4289,4294,4295,4301,4306,4308,4312,4314,4613,4666,4745,4746,4801,4804,4805,4808,4813,4814,4815,4818,4820,4904,5132,5228,5229,5681,5830,8351,9267,10268,10898,37255,104101,104102,104105,104131,104648,104696,104697,104990,104992],6377563.396:[4001,4188,4277,4278,4279],6377340.189:[4002,4299,4300],6377492.018:[4005,4273,4817],6377483.865280418:[4006,4293],6378293.645208759:[4007,4157,4302,4738,5464],6378206.4:[4008,4127,4128,4129,4135,4136,4137,4138,4139,4169,4216,4242,4253,4267,4608,4609,4638,4675,4683,4695,4717,4723,4726,4995,5451,5467,37220,37239,37243,37252,37260,104e3,104109,104112,104113,104132],6378450.047:[4009,4268],6378300.789:[4010,4281],6378249.2:[4011,4014,4155,4193,4206,4213,4223,4226,4227,4228,4252,4261,4266,4275,4282,4296,4304,4310,4315,4671,4807,4811,4816,4821,37223,37225,104139,104140,104261,104304],6378249.145:[4012,4013,4132,4134,4142,4143,4175,4197,4198,4201,4209,4210,4212,4220,4222,4232,4234,4246,4250,4251,4256,4260,4263,4270,4305,4307,4600,4601,4602,4603,4604,4605,4606,4607,4620,4679,4680,4696,4697,4699,4700,4701,4703,4713,4731,4736,4743,4744,4812,4819,6881,6882,6892,6894,8694,37206,37208,37211,37228,37240,37254,104025,104026,104032,104103,104305],6377276.345:[4015,4131,4144,4239,4240,4244,4682,5233,6207,37202,104256,104664,104693],6377298.556:[4016,4298],6377304.063:[4018,4245],6378298.3:[4028,4903],6378136.2:4032,6378136.3:4033,6378249.144808011:[4034,4241],20922931.8:[4042,4243],6377301.243:[4044,4145,37203],6377299.151:[4045,4146],6377019.27:[4657,10256,10260,10265],6378306.3696:[4748,4752],6377295.664:[4751,37006],6378136.5:[7682,7683],6371008.7714:104047,6378418.941:[104700,104726,104760],6378586.581:[104701,104743],6378505.809:104702,6378544.823:104703,6378490.569:104704,6378470.757:[104705,104776],6378403.701:[104706,104750],6378434.181:[104707,104724,104739,104764],6378454.907:104708,6378400.653:104709,6378567.378:104710,6378546.957:[104711,104717,104780],6378476.853:[104712,104736],6378411.321:[104713,104728],6378647.541:[104714,104715],6378514.953:[104716,104782],6378421.989:[104718,104770],6378481.425:[104719,104753,104774,104781],6378518.001:[104720,104725],6378521.049:[104721,104723,104731,104745,104748],6378464.661:104722,6378436.619:104727,6378574.389:[104729,104730],6378472.281:[104732,104756],6378498.189:[104733,104746],6378449.421:[104734,104766],6378525.621:[104735,104754],6378466.185:104737,6378496.665:104738,6378643.579:104740,6378559.758:104741,6378414.369:[104742,104763,104772],6378441.801:104744,6378502.761:[104747,104759,104773,104775],6378617.061:104749,6378624.681:[104751,104765],6378468.623:104752,6378445.763:[104755,104758,104761],6378670.401:104757,6378438.753:104762,6378543.909:104767,6378605.783:104768,6378540.861:104769,6378443.325:[104771,104784],6378548.481:104777,6378463.746:104778,6378426.561:104779,6378453.688:104783,6378530.193:104785,6378376.271:[104800,104828],6378471.92:104801,6378472.931:104802,6378411.351:104803,6378380.991:104805,6378414.96:104806,6378345.09:[104807,104819,104844,104870],6378412.542:104808,6378470.401:104809,6378376.331:104810,6378379.031:104811,6378407.621:104812,6378376.811:[104813,104827],6378313.92:104814,6378414.93:104815,6378413.021:104816,6378380.381:104817,6378530.851:104818,6378591.521:104820,6378378.881:104821,6378408.481:[104822,104832],6378375.601:[104823,104838],6378408.041:104824,6378655.071:104825,6378409.151:104826,6378315.7:[104829,104840,104845,104851],6378285.86:[104830,104835,104859],6378379.301:104831,6378560.121:104833,6378531.821:104834,6378500.6:104836,6378376.041:104837,6378406.601:104839,6378438.991:104841,6378345.42:104842,6378593.86:104843,6378381.271:[104846,104847],6378413.671:104848,6378344.377:104849,6378563.891:104850,6378408.091:104852,6378377.671:104853,6378472.751:104854,6378412.511:104855,6378407.281:104856,6378534.451:104857,6378406.051:104858,6378532.921:104860,6378380.091:104861,6378408.941:104862,6378624.171:104863,6378377.411:104864,6378474.591:104865,6378407.141:104866,6378376.871:104867,6378375.251:104868,6378405.971:104869,6378437.651:104871};function is(){for(const e in rs)delete rs[e]}class os extends ns{constructor(e){if("number"==typeof e)return super(),this.m_factor=e,void(this.m_wkid=0);super(e)}getUnitType(){return 1}convertFromRadians(e){return e/this.getUnitToBaseFactor()}convertToRadians(e){return e*this.getUnitToBaseFactor()}}function as(e){return new bu}function hs(e){return e.getType()===bc.PE_TYPE_LINUNIT?new bu(e):e.getType()===bc.PE_TYPE_ANGUNIT?new os(e):void n("peUnit")}function ms(e){const t=Hc(null);return e.getType()===bc.PE_TYPE_PROJCS||e.getType()===bc.PE_TYPE_GEOGCS?t.reset(e.getUnit()):n("PE_coord_sys"),t.get()||a("cannot create units from coord sys"),hs(t.get())}class ls{constructor(e,t,s){void 0===e?(this.x=new Ut,this.y=new Ut,this.z=new Ut):e instanceof Le?(this.x=new Ut(e.x),this.y=new Ut(e.y),this.z=new Ut(e.z)):e instanceof Ut?(this.x=e.clone(),this.y=t.clone(),this.z=s.clone()):n("EPoint3D constructor")}dotProduct(e){return this.x.mulE(e.x).addE(this.y.mulE(e.y)).addE(this.z.mulE(e.z))}crossProduct(e){return new ls(this.y.mulE(e.z).subE(this.z.mulE(e.y)),this.z.mulE(e.x).subE(this.x.mulE(e.z)),this.x.mulE(e.y).subE(this.y.mulE(e.x)))}crossProductVector(e){const t=this.y.mulE(e.z).subE(e.y.mulE(this.z)),s=e.x.mulE(this.z).subE(this.x.mulE(e.z)),n=this.x.mulE(e.y).subE(e.x.mulE(this.y));return new ls(t,s,n)}sqrLength(){return this.x.mulE(this.x).addE(this.y.mulE(this.y)).addE(this.z.mulE(this.z))}length(){return this.sqrLength().sqrt()}static distance(e,t){return e.sub(t).length()}negate(){return new ls(this.x.negate(),this.y.negate(),this.z.negate())}add(e){return new ls(this.x.addE(e.x),this.y.addE(e.y),this.z.addE(e.z))}sub(e){return new ls(this.x.subE(e.x),this.y.subE(e.y),this.z.subE(e.z))}subThis(e){return this.x.subThisE(e.x),this.y.subThisE(e.y),this.z.subThisE(e.z),this}addThis(e){return this.x.addThisE(e.x),this.y.addThisE(e.y),this.z.addThisE(e.z),this}mul(e){return new ls(this.x.mulE(e),this.y.mulE(e),this.z.mulE(e))}div(e){return new ls(this.x.divE(e),this.y.divE(e),this.z.divE(e))}eq(e){return this.x.eq(e.x)&&this.y.eq(e.y)&&this.z.eq(e.z)}isZero(){return this.x.isZero()&&this.y.isZero()&&this.z.isZero()}value(){return Le.construct(this.x.value(),this.y.value(),this.z.value())}}class gs{constructor(e){if(this.m_origin=new Le,this.m_normal=new Le,this.m_axisX=new Le,this.m_axisY=new Le,!e)return this.m_origin=new Le,this.m_normal=new Le(0,0,1),this.m_axisX=new Le(1,0,0),void(this.m_axisY=new Le(0,1,0));e.pt0&&e.pt1&&e.pt2?this.setFromPoints(e.pt0,e.pt1,e.pt2):l(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return l(0),this}set(e,t,s,n){l(0)}setFromPoints(e,t,s){let n=t.sub(e);const r=s.sub(e);this.m_normal=n.crossProductVector(r);let i=!0;if(this.m_normal.isZero()){if(i=!1,n.isZero()&&(n=r),n.isZero()){const t=0,s=1;return this.m_normal.setCoords(t,t,s),this.m_axisX.setCoords(s,t,t),this.m_axisY.setCoords(t,s,t),this.m_origin=e,!1}this.m_axisX=n.getUnitVector(),this.m_normal=this.m_axisX.createAPerpendicular()}else this.m_normal.normalizeThis(),this.m_axisX=n.getUnitVector();return this.m_axisY=this.m_normal.crossProductVector(this.m_axisX),this.m_origin=e,i}getCoord(e,t){return l(0),{}}getCoord2D(e){return l(0),{}}getCoordX(e,t){return l(0),0}getCoordY(e,t){return l(0),0}getCoordZ(e,t){return l(0),0}setPreferredAxisX(e){l(0)}getOrigin(){return l(0),{}}getNormal(){return l(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){l(0)}setAxisY(e,t=!1){l(0)}recalculateAxisY(){l(0)}setOrigin(e){l(0)}setNormal(e,t){l(0)}intersect(e,t){return l(0),!1}intersectLine(e){return l(0),0}intersectLineEx(e,t){return l(0),0}closestCoordinate(e){const t=e.sub(this.m_origin),s=new $e;return s.x=t.dotProduct(this.m_axisX),s.y=t.dotProduct(this.m_axisY),s}projectVector(e){return l(0),{}}signedDistance(e){return l(0),0}distance(e){return l(0),0}}function us(e,t){return!1}function cs(e,t,s,n,r=100,i=us){let o,a,h,m,g,u,c,_,d;l(n>0);let p,f,x,y=0,P=0;const E=Xt();t>s&&(s=ot(t,t=s));const S=e(t),C=e(s);S<C?(o=a=h=t,m=g=u=S):(o=a=h=s,m=g=u=C);let I=0;for(;I<r&&(x=.5*(s-t),d=t+x,p=n*(Math.abs(o)+.25),f=2*p,!(i(o,m)||Math.abs(o-d)<=f-x));++I){if(Math.abs(P)>p){const e=(o-a)*(m-u);let n=(o-h)*(m-g),r=(o-h)*n-(o-a)*e;n=2*(n-e),n>0&&(r=-r),n=Math.abs(n);const i=P;P=y,Math.abs(r)>=Math.abs(n*i*.5)||r<=n*(t-o)||r>=n*(s-o)?(P=o>=d?t-o:s-o,y=Xt()*P):(y=r/n,_=o+y,(_-t<f||s-_<f)&&(y=d-o<0?-Math.abs(p):Math.abs(p)))}else P=o>=d?t-o:s-o,y=P*E;_=o+y,c=e(_),c<m?(_>=o?t=o:s=o,h=a,a=o,o=_,u=g,g=m,m=c):(_<o?t=_:s=_,c<=g||a===o?(h=a,a=_,u=g,g=c):(c<=u||h===o||h===a)&&(h=_,u=c))}return mt(o,m)}function _s(e,t,s){if(e>s){e-=Math.ceil((e-s)/Wt)*Wt}else if(e<t){e+=Math.ceil((t-e)/Wt)*Wt}return e}function ds(e,t,s){return ps(e,t,s,0)}function ps(e,t,s,n){const r=s.x,i=s.y;return xs(e,t,Math.cos(r),Math.sin(r),Math.cos(i),Math.sin(i),n)}function fs(e,t,s,n,r,i){return xs(e,t,s,n,r,i,0)}function xs(e,t,s,n,r,i,o){const a=e/Math.sqrt(1-t*i*i),h=a+o,m=h*r*s,l=h*r*n,g=(a*(1-t)+o)*i;return Le.construct(m,l,g)}function ys(e,t,s){const n=new Ut,r=new Ut,i=new Ut,o=new Ut;n.setCos(s.x),r.setSin(s.x),i.setCos(s.y),o.setSin(s.y);const a=o.negate().mulE(o.mul(t)).add(1).sqrt(),h=new Ut(e).divE(a),m=h.mulE(i).mulE(n),l=h.mulE(i).mulE(r),g=h.mul(1-t).mulE(o);return new ls(m,l,g)}function Ps(e,t,s){const n=s.x,r=s.y,i=s.z,o=Math.atan2(r,n),a=Math.sqrt(n*n+r*r),h=Math.atan2(i,(1-t)*a);return $e.construct(o,h)}function Es(e,t,s){const n=1-t,r=e/Math.sqrt(_t(s.x)+_t(s.y)+_t(s.z)/n);return s.mul(r)}function Ss(e,t,s,n,r){const i=ds(e,t,s),o=ds(e,t,n);return Ps(e,t,Le.lerp(i,o,r))}function Cs(e,t,s){const n=new Le;return n.setCrossProductVector(t,s),Math.abs(Math.atan2(n.length(),t.dotProduct(s)))*e}function Is(e,t,s,n,r){const i=s.getUnitVector(),o=n.getUnitVector(),a=t.getUnitVector(),h=new Le;if(h.setCrossProductVector(i,o),!h.isZero()){h.normalizeThis();const t=a.sub(h.mul(h.dotProduct(a)));if(!t.isZero()){t.normalizeThis();const s=i.add(o).mul(.5);if(s.dotProduct(t)>s.dotProduct(i)){const s=Math.abs(h.dotProduct(a)),n=Math.asin(s);return r.assign(t.getUnitVector().mul(e)),n*e}}}const m=Cs(1,i,a),l=Cs(1,o,a);return m<=l?(r.assign(s),m*e):(r.assign(n),l*e)}function bs(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,new Cc,!1);return Dc.geodeticDistance(s,n,r.x,r.y,i.x,i.y,t,null,null,bc.PE_LINETYPE_GEODESIC),t.val}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function ws(e,t,s,n,r){switch(l(s.isFinite()&&n.isFinite()),r){case 0:return bs(e,t,s,n);case 1:return Ts(e,t,s);case 2:case 3:{const r=ds(e,t,s),i=ds(e,t,n);return Le.distance(r,i)}default:d("")}}function vs(e,t,s,n,r,i=0,o){if(2===i||3===i)return Ns(e,t,s,n,r,3===i,o);const a=Ps(e,t,s),h=s=>{const o=Ps(e,t,Le.lerp(n,r,s));return ws(e,t,a,o,i)},m=Le.distance(n,r);if(m>0){const s=Os(e,m),{first:i,second:a}=cs(h,0,1,s);return o&&o.assign(Es(e,t,Le.lerp(n,r,i))),mt(i,a)}{const e=h(0);return o&&o.assign(n),mt(.5,e)}}function Ns(e,t,s,n,r,i=!1,o){const a=Es(e,t,s);if(i){const i=new gs({pt0:new Le(0,0,0),pt1:n,pt2:r}),h=i.closestCoordinate(s),m=i.closestCoordinate(n),l=i.closestCoordinate(r),g=$e.getClosestCoordinate(m,l,h),u=Es(e,t,Le.lerp(n,r,g)),c=Le.distance(u,a);return o&&o.assign(u),mt(g,c)}const h=s=>{const i=Es(e,t,Le.lerp(n,r,s));return Le.distance(i,a)},m=Le.distance(n,r);if(m>0){const s=Os(e,m),{first:i,second:a}=cs(h,0,1,s);return o&&o.assign(Es(e,t,Le.lerp(n,r,i))),mt(i,a)}{const e=Le.distance(s,n);return o&&o.assign(s),mt(.5,e)}}function Ts(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,new Cc,!1);return Dc.greatEllipticDistance(s,n,r.x,r.y,r.x,r.y,t,null,null),t.val}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function Gs(e,t,s,n,r){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>St||Math.abs(n.y)>St)return Number.NaN;if((Math.abs(s.y)===St||Math.abs(n.y)===St)&&s.x!==n.x)return Number.NaN;const{first:i,second:o}=Mt(s.x,n.x);let a=r;a=_s(a,i,o);if(!lt.construct(s.x,n.x).containsCoordinate(a))return Number.NaN;const h=ee.constructPoint2D(s),m=ee.constructPoint2D(n),l=ys(1,t,h),g=ys(1,t,m),u=l.crossProductVector(g);if(u.z.isZero()){return s.y}const c=u.x.divE(u.z.negate()),_=u.y.divE(u.z.negate()),d=c.mulE(c).addE(_.mulE(_)).sqrt();if(d.isZero()||c.isZero()&&_.isZero()){return s.y}const p=Math.atan2(_.value(),c.value());let f=Math.atan2(d.value()*Math.cos(p-a),1-t);const x=ds(1,t,$e.construct(a,f)),y=Le.construct(x.x,x.y,-x.z),P=u.value().dotProduct(x),E=u.value().dotProduct(y);return Math.abs(E)<Math.abs(P)&&(f=-f),f}function Ds(e,t,s,n,r,i){if(i[0]=Number.NaN,i[1]=Number.NaN,Math.abs(s.x-n.x)>Math.PI)return 0;if(Math.abs(s.y)>St||Math.abs(n.y)>St)return 0;if((Math.abs(s.y)===St||Math.abs(n.y)===St)&&s.x!==n.x)return 0;if(Math.abs(r)>=St)return 0;if(s.y>0&&n.y>0&&s.y>r&&n.y>r||s.y<0&&n.y<0&&s.y<r&&n.y<r)return 0;const o=ee.constructPoint2D(s),a=ee.constructPoint2D(n),h=ys(1,t,o),m=ys(1,t,a),l=h.crossProductVector(m);if(l.z.isZero()){return lt.construct(s.y,n.y).containsCoordinate(r)?(i[0]=s.x,1):0}const g=l.x.divE(l.z.negate()),u=l.y.divE(l.z.negate()),c=g.mulE(g).addE(u.mulE(u)).sqrt();if(c.isZero()||g.isZero()&&u.isZero())return 0===r?(i[0]=s.x,i[1]=n.x,2):0;const _=(1-t)*Math.tan(r)/c.value();if(Math.abs(_)>1)return 0;const d=Math.acos(_),p=Math.atan2(u.value(),g.value()),f=p-d;let x=p+d;const y=Math.min(s.x,n.x),P=Math.max(s.x,n.x);_s(f,y,P),0!==r?_s(x,y,P):x=f;let E=0;return y<=f&&f<=P&&(i[E]=f,E++),x!==f&&y<=x&&x<=P&&(i[E]=x,E++),E}function Vs(e,t){t[0]>.5*Math.PI?(e[0]+=Math.PI,t[0]=Math.PI-t[0]):t[0]<.5*-Math.PI&&(e[0]-=Math.PI,t[0]=-Math.PI-t[0]),l(t[0]>=.5*-Math.PI&&t[0]<=.5*Math.PI)}function Fs(e,t){return e*Math.sqrt(1-t)}function Hs(e){return 1-e}function ks(e,t,s,n,r){n=Ct(n,-St,St),r=Ct(r,-St,St);const i=St-.03;let o;o=n>i&&r>i||n<-i&&r<-i?As(e,n,r):Ms(e,r)-Ms(e,n);return.5*(s-t)*o*Hs(e)}function As(e,t,s){let n=1;if(t<0&&(n=-1,t=-t,s=-s),0!==e){const r=e*e,i=r*e,o=[1,(1+11*e)/12,(1+118*e+241*r)/360,(1+1089*e+10419*r+8651*i)/20160,(1+9836*e+318246*r+1027436*i+458881*(i*e))/1814400],a=t=>{let s=0;const n=_t(t)/(e-1);for(let e=o.length-1;e>=0;--e)s=o[e]+s*n;return s*=-_t(t/(1-e)),s},h=a(St-t);return(a(St-s)-h)*n}{const e=St-t,r=St-s,i=-4*_t(Math.sin(e/2));return(-4*_t(Math.sin(r/2))-i)*n}}function Ms(e,t){if(0===t)return 0;const s=Math.sin(t);let n=s,r=s;if(0!==e){n/=1-e*s*s;const t=Math.sqrt(e);r=s*Lt(t*s)}return n+r}function Us(e,t){return e/Math.sqrt(1-t)}function qs(e,t){return(1-t)*e}function Bs(e,t,s){const n=s/(2*qs(e,t)),r=n*n;return s*(1-r*(.16666666666666666-.008333333333333333*r))}function Os(e,t){if(0!==t){const s=e*Bt()/t;return Math.min(s,1e-10)}return 0}class Ys{constructor(e){this.m_currentShift=63n,this.m_currentElt=0n,this.m_iCurrentElt=-1,this.m_parent=e,this.m_aiSetElts=e.m_bits.flatMap((e,t)=>t)}next(){if(this.m_currentShift++,64n===this.m_currentShift){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return Ys.npos();this.m_currentShift=0n,this.m_currentElt=this.m_parent.m_bits[this.m_aiSetElts[this.m_iCurrentElt]]}for(;this.m_currentShift<63n&&!(this.m_currentElt&1n<<this.m_currentShift);)this.m_currentShift++;return this.m_currentElt&1n<<this.m_currentShift?64*this.m_aiSetElts[this.m_iCurrentElt]+Number(this.m_currentShift):this.next()}static npos(){return Number.MAX_SAFE_INTEGER}}function Rs(e){return 1n<<(0x3fn&BigInt(e))}function Xs(e){return e>>6}class Ls{constructor(e){this.m_bits=[],void 0!==e&&e.copy&&(this.m_bits=e.copy.m_bits.slice())}assignMove(){return this}assignCopy(){return this}hasBit(e){const t=Rs(e),s=Xs(e);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&t)}setBit(e){const t=Rs(e),s=Xs(e);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=t}clearBit(e){}flipBit(e){const t=Rs(e),s=Xs(e);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=t,0n!==(this.m_bits[s]&t)}clear(){this.m_bits.length=0}isZero(){let e=0;return this.m_bits.forEach(t=>{e|=t?2:1}),!(2&e)}equals(e){if(this===e)return!0;if(this.m_bits.length!==e.m_bits.length)return!1;let t=0;return this.m_bits.forEach((s,n)=>{t|=s===e.m_bits[n]?2:1}),!(1&t)&&(e.m_bits.forEach((e,s)=>{t|=e===this.m_bits[s]?2:1}),!(1&t))}notEquals(e){return!this.equals(e)}assignOr(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]|=e}),this}assignSubtract(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=~e)}),this}assignAnd(e){return e.m_bits.forEach((e,t)=>{void 0!==this.m_bits[t]&&(this.m_bits[t]&=e)}),this}assignXor(e){return e.m_bits.forEach((e,t)=>{void 0===this.m_bits[t]?this.m_bits[t]=e:this.m_bits[t]^=e}),this}getHashCode(){return this.m_bits.reduce((e,t)=>yt(e,t),Qe(0))}getUnorderedBitIterator(){return new Ys(this)}}class zs{constructor(e,t){this.m_map=new Map,this.m_hf=e,this.m_ef=t}add(e){const t=this.m_hf(e);if(!this.m_map.has(t))return this.m_map.set(t,e),this;const s=this.m_map.get(t);return s instanceof Array?s.find(t=>this.m_ef(t,e))||s.push(e):this.m_ef(s,e)||this.m_map.set(t,[s,e]),this}clear(){this.m_map.clear()}delete(e){return!1}has(e){const t=this.m_hf(e);if(!this.m_map.has(t))return!1;const s=this.m_map.get(t);return s instanceof Array?void 0!==s.find(t=>this.m_ef(t,e)):this.m_ef(s,e)}get(e){const t=this.m_hf(e),s=this.m_map.get(t);if(void 0!==s)return s instanceof Array?s.find(t=>this.m_ef(t,e)):s}get size(){let e=0;for(const t of this.m_map.values())e+=t instanceof Array?t.length:1;return e}forEach(e,t){}[Symbol.iterator](){return(new Set)[Symbol.iterator]()}entries(){return(new Set).entries()}keys(){return(new Set).keys()}values(){return(new Set).values()}get[Symbol.toStringTag](){return"ValueSet"}}class Ws extends Xe{constructor(e){super(),this.m_bufferLeft=new k,this.m_bufferRight=new k,this.m_intervalLeft=lt.constructEmpty(),this.m_intervalRight=lt.constructEmpty(),this.m_yScanline=Number.NaN,this.m_helper=e}compare(e,t,s){const n=t,r=e.getElement(s);this.m_helper.querySegmentXY(n,this.m_bufferLeft),this.m_helper.querySegmentXY(r,this.m_bufferRight);const i=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(i.getStartX(),i.getEndX()),this.m_intervalRight.setCoords(o.getStartX(),o.getEndX()),this.m_intervalLeft.vmax<this.m_intervalRight.vmin)return-1;if(this.m_intervalLeft.vmin>this.m_intervalRight.vmax)return 1;const a=i.getStartY()===i.getEndY(),h=o.getStartY()===o.getEndY();if(a||h){if(a&&h)return 0;if(i.getStartY()===o.getStartY()&&i.getStartX()===o.getStartX())return a?1:-1;if(i.getEndY()===o.getEndY()&&i.getEndX()===o.getEndX())return a?-1:1}let m=i.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(m===l){const e=i.getEndY(),t=o.getEndY(),s=Math.min(e,t);let n=.5*(s+this.m_yScanline);n===this.m_yScanline&&(n=s),m=i.intersectionOfYMonotonicWithAxisX(n,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(n,this.m_intervalRight.vmin)}return m<l?-1:m>l?1:0}setY(e){this.m_yScanline=e}}class js{constructor(e){this.m_segmentBuffer=new k,this.m_point=$e.getNAN(),this.m_parent=e}setPointXY(e){this.m_point.assign(e)}compare(e,t){const s=e.getElement(t);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const n=this.m_segmentBuffer.get(),r=new lt;if(r.setCoords(n.getStartX(),n.getEndX()),this.m_point.x<r.vmin)return-1;if(this.m_point.x>r.vmax)return 1;const i=n.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<i?-1:this.m_point.x>i?1:0}}var Zs,Ks;function Qs(e,t){return{parentage:e,rank:t}}function Js(e,t){const s=e.length;if(s!==t.length)return!1;const n=e[0].parentage;if(n!==t[0].parentage)return!1;if(-1===n)return!0;for(let r=1;r<s;++r)if(e[r].parentage!==t[r].parentage)return!1;return!0}function $s(e,t,s){s.length=0;let n=!1;{let r=e.getHalfEdgeVertexIterator(t);for(;r!==q;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(Qs(o,i)),r=e.incrementVertexIterator(r)}}{let r=e.getHalfEdgeVertexIterator(e.getHalfEdgeTwin(t));for(;r!==q;){const t=e.getVertexFromVertexIterator(r),i=e.getShape().getSegmentRank(t),o=e.getShape().getSegmentParentage(t);n||=o>=0,s.push(Qs(o,i)),r=e.incrementVertexIterator(r)}}n&&s.sort((e,t)=>e.rank>t.rank?-1:e.rank<t.rank?1:e.parentage<t.parentage?-1:e.parentage>t.parentage?1:0),-1===s[0].parentage&&(s.length=1)}function en(){return new zs(e=>e.getHashCode(),(e,t)=>e.equals(t))}!function(e){e[e.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",e[e.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",e[e.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding"}(Zs||(Zs={})),function(e){e[e.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",e[e.enumPathBreakNode=2]="enumPathBreakNode"}(Ks||(Ks={}));class tn{constructor(){this.m_shape=null,this.m_clusterData=new Ye(8),this.m_clusterVertices=new Ye(2),this.m_firstCluster=q,this.m_lastCluster=q,this.m_halfEdgeData=new Ye(8),this.m_chainData=new Ye(8),this.m_chainAreas=null,this.m_chainPerimeters=null,this.m_universeChain=-1,this.m_simplifiedGeometry=-1,this.m_edgeIndices=[],this.m_clusterIndices=[],this.m_chainIndices=[],this.m_bBuildGeometryParentageSets=!1,this.m_chainBitSetIndex=-1,this.m_edgeBitSetIndex=-1,this.m_edgeBitSetIndexLeft=-1,this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_uniqueBitSets=null,this.m_chainBitSets=[],this.m_edgeBitSets=[],this.m_checkDirtyPlanesweepTolerance=Number.NaN,this.m_geometryIDIndex=-1,this.m_clusterIndex=-1,this.m_halfEdgeIndex=-1,this.m_tmpHalfEdgeParentageIndex=-1,this.m_tmpHalfEdgeParentageIndexLeft=-1,this.m_tmpHalfEdgeWindingNumberIndex=-1,this.m_tmpHalfEdgeOddEvenNumberIndex=-1,this.m_segmentParentageIndex=-1,this.m_segmentIndexHe=-1,this.m_clusterBreakNodeIndex=-1,this.m_universeGeomID=-1,this.m_pointCount=0,this.m_progressCounter=0,this.m_bBuildChains=!0,this.m_bDirtyCheckFailed=!1}setCheckDirtyPlanesweepTolerance(e){this.m_checkDirtyPlanesweepTolerance=e}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(e,t,s=!0,n=!1){n?this.setEditShapeImpl3D_(e,Zs.enumInputModeBuildGraph,null,t,!1):this.setEditShapeImpl_(e,Zs.enumInputModeBuildGraph,null,t,s)}setAndSimplifyEditShapeAlternate(e,t,s=null,n=!1){const r=[];r.push(t),this.m_simplifiedGeometry=t,n?this.setEditShapeImpl3D_(e,Zs.enumInputModeSimplifyAlternate,r,s,!1):this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyAlternate,r,s,e.getGeometryType(t)===i.enumPolygon)}setAndSimplifyEditShapeWinding(e,t,s=null){const n=[];n.push(t),this.m_simplifiedGeometry=t,this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyWinding,n,s,!0)}removeShape(){null!==this.m_shape&&(-1!==this.m_geometryIDIndex&&(this.m_shape.removeGeometryUserIndex(this.m_geometryIDIndex),this.m_geometryIDIndex=-1),-1!==this.m_clusterIndex&&(this.m_shape.removeUserIndex(this.m_clusterIndex),this.m_clusterIndex=-1),-1!==this.m_halfEdgeIndex&&(this.m_shape.removeUserIndex(this.m_halfEdgeIndex),this.m_halfEdgeIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1),-1!==this.m_segmentParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),-1!==this.m_segmentIndexHe&&(this.deleteUserIndexForHalfEdges(this.m_segmentIndexHe),this.m_segmentIndexHe=-1),-1!==this.m_clusterBreakNodeIndex&&(this.deleteUserIndexForClusters(this.m_clusterBreakNodeIndex),this.m_clusterBreakNodeIndex=-1),this.deleteEdgeBitSets_(),this.deleteChainBitSets_(),this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_shape=null,this.m_clusterData.deleteAll(!0),this.m_clusterVertices.deleteAll(!0),this.m_firstCluster=q,this.m_lastCluster=q,this.m_halfEdgeData.deleteAll(!0),this.m_edgeIndices.length=0,this.m_clusterIndices.length=0,this.m_chainIndices.length=0,this.m_chainData.deleteAll(!0),this.m_universeChain=q,this.m_chainAreas=null)}getClusterHalfEdge(e){return this.m_clusterData.getField(e,2)}queryXY(e,t){const s=this.getClusterVertexIndex_(e);t.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(e,t){l(0)}getClusterParentage(e){return this.m_clusterData.getField(e,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(e){return this.m_clusterData.getField(e,3)}getNextCluster(e){return this.m_clusterData.getField(e,4)}getClusterChain(e){return this.m_clusterData.getField(e,6)}getClusterVertexIterator(e){return this.m_clusterData.getField(e,7)}incrementVertexIterator(e){return this.m_clusterVertices.getField(e,1)}getVertexFromVertexIterator(e){return this.m_clusterVertices.getField(e,0)}getClusterUserIndex(e,t){const s=this.getClusterIndex_(e),n=this.m_clusterIndices[t];return n.size()<=s?-1:n.read(s)}setClusterUserIndex(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1),r.write(n,s)}hasClusterUserIndexFlags(e,t,s){if(-1===t)return!1;const n=this.getClusterUserIndex(e,t);return-1!==n&&0!==(s&n)}setClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,s|i)}clearClusterUserIndexFlags(e,t,s){const n=this.getClusterIndex_(e),r=this.m_clusterIndices[t];r.size()<=n&&r.resize(this.m_clusterData.size(),-1);let i=r.read(n);-1===i&&(i=0),r.write(n,~s&i)}createUserIndexForClusters(e=-1){const t=new be(this.m_clusterData.capacity(),e);for(let s=0,n=this.m_clusterIndices.length;s<n;s++)if(null===this.m_clusterIndices[s])return this.m_clusterIndices[s]=t,s;this.m_clusterIndices.push(t);return this.m_clusterIndices.length-1}deleteUserIndexForClusters(e){this.m_clusterIndices[e]=null}getHalfEdgeOrigin(e){return this.m_halfEdgeData.getField(e,1)}getHalfEdgeTo(e){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(e))}getHalfEdgeTwin(e){return this.m_halfEdgeData.getField(e,4)}getHalfEdgePrev(e){return this.m_halfEdgeData.getField(e,5)}getHalfEdgeNext(e){return this.m_halfEdgeData.getField(e,6)}getHalfEdgeChain(e){return this.m_halfEdgeData.getField(e,2)}getHalfEdgeFaceParentage(e){return this.getChainParentage(this.getHalfEdgeChain(e))}getHalfEdgeVertexIterator(e){return this.m_halfEdgeData.getField(e,7)}getHalfEdgeFromXY(e,t){this.queryXY(this.getHalfEdgeOrigin(e),t)}getHalfEdgeToXY(e,t){this.queryXY(this.getHalfEdgeTo(e),t)}isHalfEdgeCurve(e){if(-1!==this.m_segmentIndexHe){return-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}return!1}getHalfEdgeFromXYZ(e,t){l(0)}getHalfEdgeToXYZ(e,t){l(0)}getHalfEdgeParentage(e){return this.m_halfEdgeData.getField(e,3)&tn.c_EdgeParentageMask}getHalfEdgeUserIndex(e,t){const s=this.getHalfEdgeIndex_(e),n=this.m_edgeIndices[t];return n.size()<=s?-1:n.read(s)}setHalfEdgeUserIndex(e,t,s){const n=this.getHalfEdgeIndex_(e),r=this.m_edgeIndices[t];r.size()<=n&&r.resize(this.m_halfEdgeData.size(),-1),r.write(n,s)}createUserIndexForHalfEdges(e){void 0===e&&(e=-1);const t=new be(this.m_halfEdgeData.capacity(),e);for(let n=0,r=this.m_edgeIndices.length;n<r;n++)if(null===this.m_edgeIndices[n])return this.m_edgeIndices[n]=t,n;this.m_edgeIndices.push(t);const s=this.m_edgeIndices.length-1;return l(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(e){this.m_edgeIndices[e]=null}deleteEdgesBreakFaces_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.getHalfEdgeChain(s),r=this.getHalfEdgeTwin(s),i=this.getHalfEdgeChain(r);this.setChainHalfEdge_(n,q),this.setChainHalfEdge_(i,q),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return l(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return l(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return l(0),!1}doesClusterBelongToAPolygonInterior(e,t){return l(0),!1}doesClusterBelongToAPolygonExterior(e,t){return l(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return l(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(e){return this.m_chainData.getField(e,1)}getChainParentage(e){return this.m_chainData.getField(e,2)}getChainParent(e){return this.m_chainData.getField(e,3)}getChainFirstIsland(e){return this.m_chainData.getField(e,4)}getChainNextInParent(e){return this.m_chainData.getField(e,5)}getChainNext(e){return this.m_chainData.getField(e,7)}getChainArea(e){const t=this.getChainIndex_(e);let s=this.m_chainAreas.read(t);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(e),s=this.m_chainAreas.read(t)),s}getChainPerimeter(e){return l(0),0}getChainUserIndex(e,t){const s=this.getChainIndex_(e),n=this.m_chainIndices[t];return n.size()<=s?-1:n.read(s)}setChainUserIndex(e,t,s){const n=this.getChainIndex_(e),r=this.m_chainIndices[t];r.size()<=n&&r.resize(this.m_chainData.size(),-1),r.write(n,s)}createUserIndexForChains(){const e=new be(this.m_chainData.capacity(),-1);for(let t=0,s=this.m_chainIndices.length;t<s;t++)if(null===this.m_chainIndices[t])return this.m_chainIndices[t]=e,t;this.m_chainIndices.push(e);return this.m_chainIndices.length-1}deleteUserIndexForChains(e){this.m_chainIndices[e]=null}extractPolygonFromChainAndIslands(e,t,s,n){const r=t===q?e.createGeometry(i.enumPolygon):t,o=new k;this.extractPolygonPathFromChain_(e,r,s,n,o);for(let i=this.getChainFirstIsland(s);i!==q;i=this.getChainNextInParent(i))this.extractPolygonPathFromChain_(e,r,i,n,o);return r}getGeometryID(e){const t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return l(t>=0),1<<Math.min(t,31)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_clusterIndex)}getHalfEdgeFromVertex(e){return this.m_shape.getUserIndex(e,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(e){if(l(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const t=this.getChainUserIndex(e,this.m_chainBitSetIndex);l(t>=0);let s=this.m_chainBitSets.at(t);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(e){l(this.m_bBuildGeometryParentageSets);const t=new Ls,s=e=>{const s=this.getChainHalfEdge(e);let n=s;do{const e=this.getEdgeBitSet_(n);null!==e&&t.assignOr(e);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(n));null!==s&&t.assignOr(s),n=this.getHalfEdgeNext(n)}while(n!==s)};s(e);for(let n=this.getChainFirstIsland(e);n!==q;n=this.getChainNextInParent(n))s(e);return t}getChainPolygons(e){return l(0),[]}getGeometriesFromBits(e){if(!this.m_bBuildGeometryParentageSets||null===e)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let e=this.m_shape.getFirstGeometry();e!==q;e=this.m_shape.getNextGeometry(e))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex),e)}const t=[],s=e.getUnorderedBitIterator();for(let n=s.next();n!==Ys.npos();n=s.next())l(this.m_geometryMapID.has(n)),t.push(this.m_geometryMapID.get(n));return t}getVertexDominant(e,t){if(t===q)return e;const s=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(s,t)}getVertexDominantFromCluster(e,t){if(t!==q){let s=q;for(let n=this.getClusterVertexIterator(e);n!==q;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);s===q&&(s=e);const r=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(r)===t){s=e;break}}return s}{const t=this.getClusterVertexIterator(e);if(t!==q){return this.getVertexFromVertexIterator(t)}return q}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}setBreakNode(e,t){l(-1!==this.m_clusterBreakNodeIndex),t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}isStrongPathNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode)}setStrongPathNode(e,t){if(-1===this.m_clusterBreakNodeIndex){if(!t)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}t?this.setClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode):this.clearClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumPathBreakNode)}getSegmentParentage(e){if(-1===this.m_segmentParentageIndex)return-1;const t=this.getHalfEdgeUserIndex(e,this.m_segmentParentageIndex);return t>=0?t:-1}isCrossroadAhead(e){const t=this.getHalfEdgeNext(e);if(this.isStrongPathNode(this.getHalfEdgeOrigin(t)))return!0;const s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeNext(s);return e!==this.getHalfEdgeTwin(n)}isCrossroadBehind(e){return l(0),!1}getHalfEdgeConnector(e,t){const s=this.getClusterHalfEdge(e);if(s===q)return q;let n=s,r=q,i=q;do{if(this.getHalfEdgeTo(n)===t)return n;if(r===q){if(r=this.getClusterHalfEdge(t),r===q)return q;i=r}if(this.getHalfEdgeTo(i)===e)return n=this.getHalfEdgeTwin(i),n;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n)),i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(n!==s&&i!==r);return q}querySegmentXY(e,t){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const e=this.m_shape.getSegmentFromIndex(s);t.copyFrom(e,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe);const n=this.m_shape.getSegmentFromIndex(s);t.copyFrom(n,!0),t.get().reverse()}return}}t.createLine();const s=t.get(),n=$e.getNAN();this.getHalfEdgeFromXY(e,n),s.setStartXY(n),this.getHalfEdgeToXY(e,n),s.setEndXY(n)}isCurveEdge(e){if(-1!==this.m_segmentIndexHe){return-1!==this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe)}return!1}compareEdgeAnglesCurveHelper_(e,t,s){const n=new k,r=new k;this.querySegmentXY(e,n),this.querySegmentXY(t,r);const i=n.get(),o=r.get();if(i.equals(o))return 0;const a=new $e;this.getHalfEdgeFromXY(e,a);const h=new $e;this.getHalfEdgeToXY(e,h);const m=new $e;this.getHalfEdgeToXY(t,m),l(!h.isEqualPoint2D(m));return O(i,o)}compareEdgeAnglesHelper_(e,t,s){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,s);const n=$e.getNAN();this.getHalfEdgeToXY(e,n);const r=$e.getNAN();if(this.getHalfEdgeToXY(t,r),n.isEqualPoint2D(r))return 0;const i=$e.getNAN();this.getHalfEdgeFromXY(e,i);const o=$e.getNAN();o.setSub(n,i);const a=$e.getNAN();if(a.setSub(r,i),!s||a.y>=0&&o.y>0){return $e.compareVectors(o,a)}return 0}compareEdgeAngles_(e,t){return this.compareEdgeAnglesHelper_(e,t,!1)}compareEdgeAnglesForPair_(e,t){return this.compareEdgeAnglesHelper_(e,t,!0)}compareEdgeAngles3D_(e,t){return l(0),0}compareEdgeAnglesForPair3D_(e,t){return l(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){const t=this.getHalfEdgeChain(e),s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(s);l(n===t),l(e===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(e));let r=this.getHalfEdgeNext(e);r===s&&(r=this.getHalfEdgeNext(r),r===e&&(r=q));const i=this.getChainIndex_(t),o=this.m_chainAreas.read(i);Number.isNaN(o)||(this.setChainArea_(t,Number.NaN),this.setChainPerimeter_(t,Number.NaN));const a=this.getChainHalfEdge(t);a!==e&&a!==s||this.setChainHalfEdge_(t,r),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,s){let n=t!==q?t:this.getClusterHalfEdge(e);if(n===q)return q;const r=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const e=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(e===r)return q;n=e}}removeSpikes_(){let e=!1;const t=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==q;s=this.getNextCluster(s)){let n=q;for(;;){let r=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,t);if(r===q)break;n=this.getHalfEdgeNext(this.getHalfEdgeTwin(r));let i=r;for(;;){const s=this.getHalfEdgeNext(i),o=this.getHalfEdgePrev(i),a=this.getHalfEdgeTwin(i);if(o===a){if(this.deleteEdgeInternal_(i),e=!0,n!==i&&n!==a||(n=q),i===r||o===r){if(r=s,i===r||o===r)break;i=s;continue}}else this.setHalfEdgeUserIndex(i,t,1);if(i=s,i===r)break}}}return this.deleteUserIndexForHalfEdges(t),e}progress_(e,t=!1){}newCluster_(){const e=this.m_clusterData.newElement();return this.m_clusterData.setField(e,1,0),e}newHalfEdgePair_(){const e=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0);const t=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0),this.setHalfEdgeTwin_(e,t),this.setHalfEdgeTwin_(t,e),e}newChain_(){const e=this.m_chainData.newElement();return this.m_chainData.setField(e,2,0),e}deleteChain_(e){return l(0),0}getClusterIndex_(e){return this.m_clusterData.elementToIndex(e)}setClusterVertexIterator_(e,t){this.m_clusterData.setField(e,7,t)}setClusterHalfEdge_(e,t){this.m_clusterData.setField(e,2,t)}setClusterParentage_(e,t){this.m_clusterData.setField(e,1,t)}setPrevCluster_(e,t){this.m_clusterData.setField(e,3,t)}setNextCluster_(e,t){this.m_clusterData.setField(e,4,t)}setClusterVertexIndex_(e,t){this.m_clusterData.setField(e,5,t)}getClusterVertexIndex_(e){return this.m_clusterData.getField(e,5)}setClusterChain_(e,t){this.m_clusterData.setField(e,6,t)}addClusterToExteriorChain_(e,t){this.setClusterChain_(t,e)}getHalfEdgeIndex_(e){return this.m_halfEdgeData.elementToIndex(e)}setHalfEdgeOrigin_(e,t){this.m_halfEdgeData.setField(e,1,t)}setHalfEdgeTwin_(e,t){this.m_halfEdgeData.setField(e,4,t)}setHalfEdgePrev_(e,t){this.m_halfEdgeData.setField(e,5,t)}setHalfEdgeNext_(e,t){this.m_halfEdgeData.setField(e,6,t)}setHalfEdgeChain_(e,t){this.m_halfEdgeData.setField(e,2,t)}setHalfEdgeParentage_(e,t){this.m_halfEdgeData.setField(e,3,t)}getHalfEdgeParentageMask_(e){return this.m_halfEdgeData.getField(e,3)}setHalfEdgeVertexIterator_(e,t){this.m_halfEdgeData.setField(e,7,t)}updateVertexToHalfEdgeConnectionHelper_(e,t){const s=t?q:e;for(let n=this.getHalfEdgeVertexIterator(e);n!==q;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(e,t){e!==q&&(this.updateVertexToHalfEdgeConnectionHelper_(e,t),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(e),t))}getChainIndex_(e){return this.m_chainData.elementToIndex(e)}setChainHalfEdge_(e,t){this.m_chainData.setField(e,1,t)}setChainParentage_(e,t){this.m_chainData.setField(e,2,t)}setChainParent_(e,t){this.m_chainData.setField(e,3,t);const s=this.getChainFirstIsland(t);this.setChainNextInParent_(e,s),this.setChainFirstIsland_(t,e)}setChainFirstIsland_(e,t){this.m_chainData.setField(e,4,t)}setChainNextInParent_(e,t){this.m_chainData.setField(e,5,t)}setChainPrev_(e,t){this.m_chainData.setField(e,6,t)}setChainNext_(e,t){this.m_chainData.setField(e,7,t)}setChainArea_(e,t){const s=this.getChainIndex_(e);this.m_chainAreas.write(s,t)}setChainPerimeter_(e,t){const s=this.getChainIndex_(e);this.m_chainPerimeters.write(s,t)}updateChainAreaAndPerimeter_(e){const t=this.m_shape.hasCurves(),s=new ct(0),n=new ct(0),r=this.getChainHalfEdge(e),i=$e.getNAN(),o=$e.getNAN(),a=$e.getNAN();this.getHalfEdgeFromXY(r,i),o.setCoordsPoint2D(i);let h=r;do{this.getHalfEdgeToXY(h,a),t&&this.isCurveEdge(h)||n.pe($e.distance(o,a));this.getHalfEdgeChain(this.getHalfEdgeTwin(h))!==e&&s.pe((a.x-i.x-(o.x-i.x))*(a.y-i.y+(o.y-i.y))*.5),o.setCoordsPoint2D(a),h=this.getHalfEdgeNext(h)}while(h!==r);if(t){const t=new k;h=r;do{this.getHalfEdgeToXY(h,a);const r=this.isCurveEdge(h);r&&(this.querySegmentXY(h,t),n.pe(t.get().calculateLength2D()));if(this.getHalfEdgeChain(this.getHalfEdgeTwin(h))!==e&&r){const e=t.get().calculateArea2DHelper();s.pe(e)}h=this.getHalfEdgeNext(h)}while(h!==r)}const m=this.getChainIndex_(e);this.m_chainAreas.write(m,s.getResult()),this.m_chainPerimeters.write(m,n.getResult())}getChainTopmostEdge_(e){return l(0),0}planeSweepParentage_(e,t){const s=new Ws(this),n=new Ce;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const r=[],i=this.createUserIndexForHalfEdges();let o=null;const a=$e.getNAN();for(let h=this.getFirstCluster();h!==q;h=this.getNextCluster(h)){this.progress_(t);const m=this.getClusterHalfEdge(h);if(m!==q){if(r.length=0,!this.tryOptimizedInsertion_(n,i,r,h,m)){this.queryXY(h,a),s.setY(a.y);let e=m;do{const t=this.getHalfEdgeUserIndex(e,i);-1!==t&&(n.deleteNode(t),this.setHalfEdgeUserIndex(e,i,Ye.impossibleIndex2())),e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(m!==e);e=m;do{if(-1===this.getHalfEdgeUserIndex(e,i)){const t=n.addElement(e);r.push(t)}e=this.getHalfEdgeNext(this.getHalfEdgeTwin(e))}while(m!==e)}for(let t=r.length-1;t>=0;t--){const s=r[t],o=n.getElement(s),a=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(a,i,s),this.planeSweepParentagePropagateParentage_(n,s,e)}}else if(this.getClusterChain(h)===q){null===o&&(o=new js(this)),this.queryXY(h,a),o.setPointXY(a);const e=n.searchLowerBound(o);let t=this.m_universeChain;if(-1!==e){let s=n.getElement(e);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(n,e)),s!==q&&(t=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(t,h)}}this.deleteUserIndexForHalfEdges(i)}planeSweepParentagePropagateParentage_(e,t,s){const n=e.getElement(t),r=this.getHalfEdgeChain(n);if(this.getChainParent(r)!==q)return;const i=this.getLeftSkipPolylines_(e,t),o=this.getHalfEdgeTwin(n),a=this.getHalfEdgeChain(o);let h=this.getChainParent(r),m=this.getChainParent(a);if(i===q)h===q&&(a===r?(this.setChainParent_(a,this.m_universeChain),m=this.m_universeChain,h=m):(m===q&&(this.setChainParent_(a,this.m_universeChain),m=this.m_universeChain),this.setChainParent_(r,a),h=a));else{const e=this.getHalfEdgeChain(i);if(m===q){if(this.getChainArea(e)<=0){const t=this.getChainParent(e);this.setChainParent_(a,t),m=t}else this.setChainParent_(a,e),m=e;a===r&&(h=m)}}h===q&&(this.trySetChainParentFromTwin_(r,a),h=this.getChainParent(r)),l(h!==q),s===Zs.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,n,i):s===Zs.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,n,i,o,r,a):s===Zs.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,n,i,o,r,a)}propagateParentageBuildGraph_(e,t,s,n){let r,i=t;n===q?(i=e.getNext(i),r=this.getHalfEdgeChain(s)):r=this.getHalfEdgeChain(n);let o=null,a=this.getChainParentage(r);for(this.m_bBuildGeometryParentageSets&&(o=this.getChainBitSet(r));-1!==i;i=e.getNext(i)){const t=e.getElement(i),s=this.getHalfEdgeTwin(t);r=this.getHalfEdgeChain(t);const n=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let e=this.getChainBitSet(n);e=new Ls({copy:e}),e.assignOr(o),this.setChainBitSet_(n,e);let s=this.getChainBitSet(r);const i=this.getLeftEdgeBitSet_(t),a=new Ls({copy:o});if(a.assignSubtract(i),a.isZero())break;s=new Ls({copy:s}),s.assignOr(a),this.setChainBitSet_(r,s),o=s}const h=this.getChainParentage(n),m=h|a;m!==h&&this.setChainParentage_(n,m);let l=this.getChainParentage(r);const g=a&~this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeParentageIndexLeft);if(g&&(l|=g,this.setChainParentage_(r,l)),0===g)break;a=l}}propagateParentageWinding_(e,t,s,n,r,i,o){if(i===o)return;let a=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);a+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);let h=0;const m=[],g=[];g.push(0);for(let u=e.getFirst();u!==t;u=e.getNext(u)){const t=e.getElement(u),s=this.getHalfEdgeTwin(t),n=this.getHalfEdgeChain(t),r=this.getHalfEdgeChain(s);if(n!==r){let e=this.getHalfEdgeUserIndex(t,this.m_tmpHalfEdgeWindingNumberIndex);e+=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex),h+=e;let i=!1;0!==m.length&&m.at(-1)===r&&(g.pop(),m.pop(),i=!0),l(this.getChainParent(r)!==q),i&&this.getChainParent(r)===n||(g.push(h),m.push(n))}}if(h+=a,0!==m.length&&m.at(-1)===o&&(g.pop(),m.pop()),0!==h){if(0===g.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(i,t)}}else if(0!==g.at(-1)){const e=this.m_simplifiedGeometry,t=this.getGeometryID(e);this.setChainParentage_(i,t)}}propagateParentageAlternate_(e,t,s,n,r,i,o){const a=this.m_simplifiedGeometry,h=this.getGeometryID(a);if(n===q){this.setChainParentage_(o,this.m_universeGeomID);1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,h):this.setChainParentage_(i,this.m_universeGeomID)}else{const e=this.getChainParentage(o);if(0===e){const e=this.getHalfEdgeChain(n),t=this.getChainParentage(e);this.setChainParentage_(o,t);1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,t===h?this.m_universeGeomID:h):this.setChainParentage_(i,t)}else{1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(i,e===h?this.m_universeGeomID:h):this.setChainParentage_(i,e)}}}tryOptimizedInsertion_(e,t,s,n,r){let i=r,o=-1,a=q,h=0;do{if(2===h)return!1;const e=this.getHalfEdgeUserIndex(i,t);if(-1!==e){if(-1!==o)return!1;o=e}else{if(a!==q)return!1;a=i}h++,i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(r!==i);return a!==q&&-1!==o&&(this.setHalfEdgeUserIndex(e.getElement(o),t,Ye.impossibleIndex2()),e.setElement(o,a),s.push(o),!0)}trySetChainParentFromTwin_(e,t){const s=this.getChainArea(e);if(0===s)return!1;const n=this.getChainArea(t);if(s>0&&n<0||s<0&&n>0)return this.setChainParent_(e,t),!0;{const s=this.getChainParent(t);if(s!==q)return this.setChainParent_(e,s),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,n=t.size();s<n;s++){const n=t.read(s),r=this.m_shape.getUserIndex(n,this.m_clusterIndex),o=this.m_shape.getPathFromVertex(n),a=this.m_shape.getGeometryFromPath(o),m=this.m_shape.getGeometryType(a);if(h(m)){const t=this.m_shape.getNextVertex(n);if(t===q)continue;const s=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(r===s)continue;const o=this.newHalfEdgePair_(),h=this.getHalfEdgeTwin(o),l=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(l,0,n),this.m_clusterVertices.setField(l,1,-1),this.setHalfEdgeVertexIterator_(o,l),this.m_shape.setUserIndex(n,this.m_halfEdgeIndex,o),this.setHalfEdgeOrigin_(o,r);const g=this.getClusterHalfEdge(r);if(g===q)this.setClusterHalfEdge_(r,o),this.setHalfEdgePrev_(o,h),this.setHalfEdgeNext_(h,o);else{const e=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,h),this.setHalfEdgeNext_(h,g),this.setHalfEdgeNext_(e,o),this.setHalfEdgePrev_(o,e)}this.setHalfEdgeOrigin_(h,s);const u=this.getClusterHalfEdge(s);if(u===q)this.setClusterHalfEdge_(s,h),this.setHalfEdgeNext_(o,h),this.setHalfEdgePrev_(h,o);else{const e=this.getHalfEdgePrev(u);this.setHalfEdgePrev_(u,o),this.setHalfEdgeNext_(o,u),this.setHalfEdgeNext_(e,h),this.setHalfEdgePrev_(h,e)}const c=this.getGeometryID(a);if(e===Zs.enumInputModeBuildGraph){const e=m===i.enumPolygon?c:0;if(this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const e=new Ls,t=this.m_shape.getGeometryUserIndex(a,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(o,e),this.setEdgeBitSet_(h,null),this.setLeftEdgeBitSet_(h,e),this.setLeftEdgeBitSet_(o,null)}}else if(e===Zs.enumInputModeSimplifyWinding){const e=this.m_shape.getXY(n),s=this.m_shape.getXY(t);let r=0,i=0;e.compare(s)<0?r=1:i=-1,this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,r),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex,i)}else e===Zs.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const _=m===i.enumPolygon?tn.c_EdgeBitMask:0;this.setHalfEdgeParentage_(o,c|_),this.setHalfEdgeParentage_(h,c|_)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let e=0,s=t.size();e<s;e++){const s=t.read(e);if(this.m_shape.getSegment(s)){const e=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);e!==q&&(this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(e),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(e,t){{const s=this.getHalfEdgeVertexIterator(t);if(s!==q){const n=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(e,s),this.setHalfEdgeVertexIterator_(t,q)}}const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeTwin(t);{const e=this.getHalfEdgeVertexIterator(n);if(e!==q){const t=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(s,e),this.setHalfEdgeVertexIterator_(n,q)}}if(-1!==this.m_segmentIndexHe){let r=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);if(-1!==r){if(-2===r){const s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(e,this.m_segmentIndexHe,s)}if(r=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===r){const e=this.getHalfEdgeUserIndex(n,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,e)}}}}sortHalfEdgesByAngle_(e){const t=[];for(let s=this.getFirstCluster();s!==q;s=this.getNextCluster(s)){t.length=0;const n=this.getClusterHalfEdge(s);if(n!==q){let r=n;do{t.push(r),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n);if(t.length>1){let r=!0;t.length>2?(t.sort((e,t)=>this.compareEdgeAngles_(e,t)),t.push(t[0])):this.compareEdgeAnglesForPair_(t[0],t[1])>0?t[1]=ot(t[0],t[0]=t[1]):r=!1;let i=t[0],o=i,a=this.getHalfEdgeTo(o),h=this.getHalfEdgeTwin(o),m=q;for(let s=1,n=t.length;s<n;s++){const n=t[s],r=this.getHalfEdgeTwin(n),l=this.getHalfEdgeOrigin(r);if(l!==a||n===o)this.updateVertexToHalfEdgeConnection_(m,!1),m=q,o=n,a=l,h=r;else{if(e===Zs.enumInputModeBuildGraph){const e=this.getHalfEdgeParentageMask_(o)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(o,e),this.setHalfEdgeParentage_(h,e),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let e,t,s;e=this.getEdgeBitSet_(o),t=this.getEdgeBitSet_(n),s=new Ls({copy:e}),s.assignOr(t),this.setEdgeBitSet_(o,s),e=this.getEdgeBitSet_(h),t=this.getEdgeBitSet_(r),s=new Ls({copy:e}),s.assignOr(t),this.setEdgeBitSet_(h,s),e=this.getLeftEdgeBitSet_(o),t=this.getLeftEdgeBitSet_(n),s=new Ls({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(o,s),e=this.getLeftEdgeBitSet_(h),t=this.getLeftEdgeBitSet_(r),s=new Ls({copy:e}),s.assignOr(t),this.setLeftEdgeBitSet_(h,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),t=this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,e),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeWindingNumberIndex,t)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const e=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),t=this.getHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,e),this.setHalfEdgeUserIndex(h,this.m_tmpHalfEdgeOddEvenNumberIndex,t)}this.mergeVertexListsOfEdges_(o,n),this.deleteEdgeImpl_(n),m=o,t[s]=q,n===i&&(t[0]=q,i=q)}}if(this.updateVertexToHalfEdgeConnection_(m,!1),m=q,!r){i=q;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s!==q){i=s;break}}n!==i&&this.setClusterHalfEdge_(s,i);continue}i=q;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s===q)continue;if(i===q){i=s,o=i,a=this.getHalfEdgeTo(o),h=this.getHalfEdgeTwin(o);continue}if(s===o)continue;const n=this.getHalfEdgeTwin(s),r=this.getHalfEdgeOrigin(n);this.setHalfEdgeNext_(h,s),this.setHalfEdgePrev_(s,h),o=s,a=r,h=n}this.setClusterHalfEdge_(s,i)}}}}sortHalfEdgesByAngle3D_(e){l(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,q);let t=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==q;n=this.getNextCluster(n)){const e=this.getClusterHalfEdge(n);if(e!==q){let n=e;do{if(1!==this.getHalfEdgeUserIndex(n,s)){const e=this.newChain_();this.setChainHalfEdge_(e,n),this.setChainPrev_(e,t),this.setChainNext_(t,e);let r=null;this.m_bBuildGeometryParentageSets&&(r=new Ls),t=e;let i=0,o=n;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(i|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&r.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,e),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==n);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(e,r),this.setChainParentage_(e,i)}n=this.getHalfEdgeNext(this.getHalfEdgeTwin(n))}while(n!==e)}}this.m_chainAreas=new Re(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new Re(this.m_chainData.size(),Number.NaN),this.setChainArea_(this.m_universeChain,Number.POSITIVE_INFINITY),this.setChainPerimeter_(this.m_universeChain,Number.POSITIVE_INFINITY),this.deleteUserIndexForHalfEdges(s)}simplify_(e){l(0)}simplifyAlternate_(){l(0)}simplifyWinding_(){l(0)}setEditShapeImpl_(e,t,s,n,r){this.removeShape(),this.m_bBuildChains=r,this.m_shape=e,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let i=this.m_shape.getTotalPointCount();if(s){i=0;for(let e=0,t=s.length;e<t;e++)i+=this.m_shape.getPointCount(s[e])}const o=new be(0);let a=0,h=0;{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==q;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,h++);for(let t=this.m_shape.getFirstPath(e);t!==q;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let s=0,n=this.m_shape.getPathSize(t);s<n;s++)o.add(e),e=this.m_shape.getNextVertex(e)}_(this.m_shape.getGeometryType(e))||(a+=this.m_shape.getPathCount(e)),null!=s?(e=t<s.length?s[t]:q,t++):e=this.m_shape.getNextGeometry(e)}}this.m_universeGeomID=1<<Math.min(h,31),this.m_pointCount=o.size(),this.m_shape.sortVerticesSimpleByY(o,0,this.m_pointCount),this.m_clusterVertices.setCapacity(this.m_pointCount),this.progress_(n,!0),this.m_clusterData.setCapacity(this.m_pointCount+10),this.m_halfEdgeData.setCapacity(2*this.m_pointCount+32),this.m_chainData.setCapacity(Math.max(32,a)),this.m_clusterIndex=this.m_shape.createUserIndex();const m=$e.getNAN();let l=0;const g=$e.getNAN();for(let u=0;u<=this.m_pointCount;u++){if(u<this.m_pointCount){const e=o.read(u);this.m_shape.queryXY(e,g)}else g.setNAN();if(!m.isEqualPoint2D(g)){if(l<u){const e=this.newCluster_();let t=q,s=-1;for(let n=l;n<u;n++){s=o.read(n),this.m_shape.setUserIndex(s,this.m_clusterIndex,e);const r=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(r,0,s),this.m_clusterVertices.setField(r,1,t),t=r;const i=this.m_shape.getPathFromVertex(s),a=this.m_shape.getGeometryFromPath(i),h=this.getGeometryID(a);this.setClusterParentage_(e,this.getClusterParentage(e)|h)}this.setClusterVertexIterator_(e,t),this.setClusterVertexIndex_(e,this.m_shape.getVertexIndex(s)),this.m_lastCluster!==q&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===q&&(this.m_firstCluster=e)}l=u,m.setCoordsPoint2D(g)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let e=0;e<this.m_pointCount;e++){const t=o.read(e);if(this.m_shape.getSegmentParentageBreakVertex(t)){const e=this.getClusterFromVertex(t);this.setBreakNode(e,!0)}}}this.progress_(n,!0);{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==q;){for(let t=this.m_shape.getFirstPath(e);t!==q;t=this.m_shape.getNextPath(t)){if(this.m_shape.isStrongPathStart(t)){const e=this.m_shape.getFirstVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(t)){const e=this.m_shape.isClosedPath(t)?this.m_shape.getFirstVertex(t):this.m_shape.getLastVertex(t),s=this.getClusterFromVertex(e);this.setStrongPathNode(s,!0)}}null!=s?(e=t<s.length?s[t]:q,t++):e=this.m_shape.getNextGeometry(e)}}if(t===Zs.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),t===Zs.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),t===Zs.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(t,o),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(t),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(t),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(t,n),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(e,t,s,n,r){l(0)}cleanSetEditShapeImpl_(){-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1)}cleanSetEditShapeImpl3D_(){l(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(e){const t=this.getHalfEdgeNext(e),s=this.getHalfEdgePrev(e),n=this.getHalfEdgeTwin(e),r=this.getHalfEdgeNext(n),i=this.getHalfEdgePrev(n);t!==n&&(this.setHalfEdgeNext_(i,t),this.setHalfEdgePrev_(t,i)),s!==n&&(this.setHalfEdgeNext_(s,r),this.setHalfEdgePrev_(r,s));const o=this.getHalfEdgeOrigin(e);this.getClusterHalfEdge(o)===e&&(r!==e?this.setClusterHalfEdge_(o,r):this.setClusterHalfEdge_(o,q));const a=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(a)===n&&(t!==n?this.setClusterHalfEdge_(a,t):this.setClusterHalfEdge_(a,q)),this.m_halfEdgeData.deleteElement(e),this.m_halfEdgeData.deleteElement(n)}getLeftSkipPolylines_(e,t){let s=t;for(;;){if(s=e.getPrev(s),-1===s)return q;{const t=e.getElement(s);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}}}checkStructureAfterDirtySweep_(){const e=_t(this.m_checkDirtyPlanesweepTolerance),t=new $e,s=new $e,n=new $e,r=new $e,i=new $e;for(let o=this.getFirstCluster();o!==q;o=this.getNextCluster(o)){const a=this.getClusterHalfEdge(o);if(a!==q){let o=a;this.getHalfEdgeFromXY(o,t),this.getHalfEdgeToXY(o,s),n.setSub(s,t);let h=n.sqrLength();do{const a=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==a){this.getHalfEdgeToXY(o,r),i.setSub(r,t);const a=i.sqrLength(),m=i.crossProduct(n),l=m*m/(a*h);if(Math.min(a,h)*l<=e){if(i.dotProduct(n)>=0)return!1}n.assign(i),h=a,s.assign(r)}}while(o!==a)}}return!0}extractPolygonPathFromChain_(e,t,s,n,r){const i=this.m_shape.hasSegmentParentage(),o=this.getChainHalfEdge(s);let a=o,h=q;const m=new ye;do{const o=this.getHalfEdgeTwin(a);if(this.getHalfEdgeChain(o)!==s){let s=q;const o=this.getHalfEdgeOrigin(a);if(n===q){const e=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(o);e!==q;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);s===q&&(s=t);const r=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(r)===n){s=t;break}}let l;if(h===q&&(h=e.insertPath(t,q),e.setClosedPath(h,!0)),this.m_shape===e?l=e.addVertex(h,s):(this.m_shape.queryPoint(s,m),l=e.addPoint(h,m)),this.isHalfEdgeCurve(a)&&(this.querySegmentXY(a,r),e.setSegmentToIndex(e.getVertexIndex(l),r.get().clone())),i){const t=this.getSegmentParentage(a);e.setSegmentParentageAndBreak(l,t,this.isBreakNode(o))}}a=this.getHalfEdgeNext(a)}while(a!==o)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;l(-1!==this.m_clusterBreakNodeIndex),l(-1===this.m_segmentParentageIndex);for(let n=this.getFirstCluster();n!==q;n=this.getNextCluster(n)){let e=0;const t=this.getClusterHalfEdge(n);if(t!==q){let s=t;do{e++,s=this.getHalfEdgeNext(this.getHalfEdgeTwin(s))}while(s!==t&&e<3)}2!==e&&this.setBreakNode(n,!0)}let e=[],t=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==q;n=this.getNextCluster(n)){const r=this.getClusterHalfEdge(n);if(r!==q){let n=!1,i=r;do{let r=i;for(;-1===this.getHalfEdgeUserIndex(r,s);){const i=this.getHalfEdgeNext(r),o=this.getHalfEdgeTwin(r);$s(this,r,t);const a=t.at(-1).parentage;if(!n){const t=this.getHalfEdgeOrigin(r);if(!this.isBreakNode(t)){const t=this.getHalfEdgePrev(r);r!==t&&($s(this,t,e),n=!0)}}if(n&&!Js(t,e)){const e=this.getHalfEdgeOrigin(r);this.setBreakNode(e,!0)}e=ot(t,t=e),n=!0;const h=this.getHalfEdgeOrigin(i);this.isBreakNode(h)&&(n=!1),this.setHalfEdgeUserIndex(r,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(r,s,1),this.setHalfEdgeUserIndex(o,s,1),r=i}i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(i!==r)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(e){if(null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=en(),this.m_uniqueBitSets.add(this.getEmptySet())),null===e)return this.getEmptySet();return this.m_uniqueBitSets.has(e)?this.m_uniqueBitSets.get(e):(this.m_uniqueBitSets.add(e),e)}getLeftEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);return l(t>=0),l(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return l(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setLeftEdgeBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=t:(this.setHalfEdgeUserIndex(e,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(t))}setChainBitSet_(e,t){l(this.m_bBuildGeometryParentageSets),t=this.registerNewBitSet(t),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(e,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=t:(this.setChainUserIndex(e,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(t))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new Ls),this.m_emptyBitSet}deleteEdgeBitSets_(){-1!==this.m_edgeBitSetIndex&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),-1!==this.m_edgeBitSetIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){-1!==this.m_chainBitSetIndex&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(e){}dbgVerifyEdgeSegment(e){}}tn.c_EdgeParentageMask=~(1<<31),tn.c_EdgeBitMask=1<<31;class sn{freeNode_(e){this.m_listNodes.deleteElement(e)}newNode_(){return this.m_listNodes.newElement()}freeList_(e){this.m_lists.deleteElement(e)}newList_(){return this.m_lists.newElement()}Init_(e){l(0)}constructor(e){this.m_listNodes=new Ye(2),this.m_listOfLists=sn.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===e&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new Ye(this.m_bAllowNavigationBetweenLists?4:2)}createList(){const e=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(e,3,this.m_listOfLists),this.m_listOfLists!==sn.st_nullNode()&&this.m_lists.setField(this.m_listOfLists,2,e),this.m_listOfLists=e),e}deleteList(e){let t=this.getFirst(e);for(;t!==sn.st_nullNode();){const e=t;t=this.getNext(t),this.freeNode_(e)}if(this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==sn.st_nullNode()?this.m_lists.setField(t,3,s):this.m_listOfLists=s,s!==sn.st_nullNode()&&this.m_lists.setField(s,2,t)}this.freeList_(e)}reserveLists(e){this.m_lists.setCapacity(e)}addElement(e,t){this.m_lists.getField(e,0);const s=this.m_lists.getField(e,1),n=this.newNode_();return s!==sn.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,n)):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,n)),this.m_listNodes.setField(n,0,t),n}reserveNodes(e){this.m_listNodes.setCapacity(e)}deleteElementDirect(e,t,s){t!==sn.st_nullNode()?(this.m_listNodes.setField(t,1,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,t)):(this.m_lists.setField(e,0,this.m_listNodes.getField(s,1)),this.m_lists.getField(e,1)===s&&this.m_lists.setField(e,1,sn.st_nullNode())),this.freeNode_(s)}deleteElementSearch(e,t){let s=-1,n=this.getFirst(e);for(;n!==t;)s=n,n=this.getNext(n);this.deleteElementDirect(e,s,t)}concatenateLists(e,t){const s=this.m_lists.getField(e,1),n=this.m_lists.getField(t,0);if(n!==sn.st_nullNode()&&(s!==sn.st_nullNode()?(this.m_listNodes.setField(s,1,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1))):(this.m_lists.setField(e,0,n),this.m_lists.setField(e,1,this.m_lists.getField(t,1)))),this.m_bAllowNavigationBetweenLists){const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);e!==sn.st_nullNode()?this.m_lists.setField(e,3,s):this.m_listOfLists=s,s!==sn.st_nullNode()&&this.m_lists.setField(s,2,e)}return this.freeList_(t),e}getElement(e){return this.m_listNodes.getField(e,0)}getData(e){return this.getElement(e)}setElement(e,t){l(0)}getNext(e){return this.m_listNodes.getField(e,1)}getFirst(e){return this.m_lists.getField(e,0)}getFirstElement(e){const t=this.getFirst(e);return this.getElement(t)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=sn.st_nullNode()}isEmpty(e){return l(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(e){return this.m_lists.getField(e,3)}}function nn(e=-1){return{m_value:e,m_line:new A,m_segment:null,m_segmentInfo:new oe(-1),m_env:new lt(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}const rn=67;class on extends Xe{constructor(e,t,s){super(!0),this.m_bIntersectionDetected=!1,this.m_nonSimpleResult=new ts,this.m_tempSimpleEdge1=nn(),this.m_tempSimpleEdge2=nn(),this.m_prev1=q,this.m_prev2=q,this.m_vertex1=q,this.m_vertex2=q,this.m_currentNode=-1,this.m_prevX1=Number.NaN,this.m_prevX2=Number.NaN,this.m_prevY=Number.NaN,this.m_prevX=0,this.m_sweepY=Number.NaN,this.m_sweepX=0,this.m_ptSweep=new $e,this.m_simpleEdgesCache=[],this.m_simpleEdgesRecycle=[],this.m_cOutstandingConstructedEdges=0,this.m_shape=e,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=t,this.m_tolerance10=10*t,this.m_bIsSimple=s;const n=Math.trunc(Math.min(3*e.getTotalPointCount()/2,rn)),r=Math.min(7,n);this.m_simpleEdgesCache.length=r}tryGetCachedEdge_(e){const t=this.m_simpleEdgesCache[(e&vt())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){const t=(e&vt())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[t];s&&s.m_value===e&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[t]=null)}tryCreateCachedEdge_(e){const t=(e&vt())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[t];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=nn(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=e,this.m_simpleEdgesCache[t]=s,s)}initSimpleEdge_(e,t){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(e,t)||e.m_bCurve||(this.m_shape.queryLineConnector(t,e.m_line,!0),e.m_segment=e.m_line,e.m_env.setCoordsNoNAN(e.m_line.getStartX(),e.m_line.getEndX()),e.m_env.vmax+=this.m_tolerance,e.m_line.orientBottomUp(),e.m_bHorizontal=e.m_line.getEndY()===e.m_line.getStartY(),e.m_bHorizontal||(e.m_dxdy=(e.m_line.getEndX()-e.m_line.getStartX())/(e.m_line.getEndY()-e.m_line.getStartY())))}initSimpleEdgeHelper_(e,t){if(e.m_segment=this.m_shape.getSegment(t),e.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(t),e.m_bCurve=null!==e.m_segment,e.m_bCurve){const t=e.m_segment.clone();return t.orientBottomUp(),e.m_segment=t,e.m_env=e.m_segment.queryInterval(0,0),e.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(e,t){const s=e.getStartXY(),n=e.getEndXY(),r=t.getStartXY(),i=t.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(r)&&this.m_sweepY===s.y){this.m_ptSweep.assign(n.compare(i)<0?n:i);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-r)>this.m_tolerance)return s<r?-1:1}const o=s.compare(r)<0?r:s,a=n.compare(i)<0?n:i;let h=0,m=0;for(let l=1;l<5;l++){Et(o,a,l/5,this.m_ptSweep);const s=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),n=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),r=Math.abs(s-n);r>h&&(h=r,m=s<n?-1:1)}return 0===m?this.errorCracking():m}compareNonHorizontal_(e,t){if(e.m_line.getStartY()===t.m_line.getStartY()&&e.m_line.getStartX()===t.m_line.getStartX())return e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(e,t);if(e.m_line.getEndY()===t.m_line.getEndY()&&e.m_line.getEndX()===t.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(e,t);const s=this.compareNonHorizontalLowerEnd_(e,t),n=this.compareNonHorizontalUpperEnd_(e,t);return s<0&&n<0?-1:s>0&&n>0?1:this.errorCracking()}compareHorizontal1Case1_(e,t){if(e.getEndX()>t.getEndX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else{if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getEndX()-e.getStartX())<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}return 1}compareHorizontal1Case2_(e,t){if(e.getStartX()<t.getStartX()){if(t.getEndX()>t.getStartX()&&t.getEndY()-t.getStartY()<2*this.m_tolerance&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else{if((t.getEndY()-t.getStartY())/(t.getEndX()-t.getStartX())*(e.getStartX()-e.getEndX())<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}return-1}compareHorizontal1Case3_(e,t){const s=$e.getNAN();s.setSub(t.getEndXY(),t.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=$e.getNAN();n.setSub(e.getStartXY(),t.getStartXY());const r=$e.getNAN();r.setSub(e.getEndXY(),t.getStartXY());const i=n.dotProduct(s),o=r.dotProduct(s),a=Math.abs(i),h=Math.abs(o);if(a<h){if(a<this.m_tolerance10&&t.isIntersectingPoint(e.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(h<this.m_tolerance10&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return i<0&&o<0?-1:i>0&&o>0?1:this.errorCracking()}compareHorizontal1_(e,t){return e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.compareHorizontal1Case1_(e,t):e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()?this.compareHorizontal1Case2_(e,t):this.compareHorizontal1Case3_(e,t)}compareHorizontal2_(e,t){return e.getEndY()===t.getEndY()&&e.getEndX()===t.getEndX()&&e.getStartY()===t.getStartY()&&e.getStartX()===t.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(e,t){let s=1;if(e.m_line.getStartY()<t.m_line.getStartY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getStartX()-r.getStartX(),o=t.m_dxdy*(n.getStartY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getStartXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}compareNonHorizontalUpperEnd_(e,t){let s=1;if(t.m_line.getEndY()<e.m_line.getEndY()){s=-1;const n=e;e=t,t=n}const n=e.m_line,r=t.m_line,i=n.getEndX()-r.getStartX(),o=t.m_dxdy*(n.getEndY()-r.getStartY()),a=this.m_tolerance10;return i<o-a?-s:i>o+a?s:r.isIntersectingPoint(n.getEndXY(),this.m_tolerance,!0)?this.errorCracking():i<o?-s:s}errorCoincident(){this.m_bIntersectionDetected=!0;const e=7;return this.m_nonSimpleResult=new ts(e,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const e=6;this.m_nonSimpleResult=new ts(e,this.m_vertex1,this.m_vertex2)}else this.m_prev1=q,this.m_prev2=q,this.m_vertex1=q,this.m_vertex2=q;return-1}compareSegments_(e,t,s,n){if(s.m_env.vmax<n.m_env.vmin)return-1;if(n.m_env.vmax<s.m_env.vmin)return 1;if(!s.m_bCurve&&!n.m_bCurve){let e=s.m_bHorizontal?1:0;return e|=n.m_bHorizontal?2:0,0===e?this.compareNonHorizontal_(s,n):1===e?this.compareHorizontal1_(s.m_line,n.m_line):2===e?-1*this.compareHorizontal1_(n.m_line,s.m_line):this.compareHorizontal2_(s.m_line,n.m_line)}if(this.m_bIntersectionDetected)return-1;const r=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX;let i,o;if(r&&e===this.m_prev1?i=this.m_prevX1:(i=Number.NaN,this.m_prev1=q),r&&t===this.m_prev2?o=this.m_prevX2:(o=Number.NaN,this.m_prev2=q),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(i)){this.m_prev1=e;const t=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);i=t,this.m_prevX1=t}if(Number.isNaN(o)){this.m_prev2=t;const e=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);o=e,this.m_prevX2=e}const a=K(!0,!0,s.m_segment,n.m_segment,this.m_tolerance,!0);return 0!==a?2===a?this.m_bIsSimple?this.errorCoincident():s.m_segmentInfo.equals(n.m_segmentInfo)?0:this.errorCracking():this.errorCracking():Math.abs(i-o)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,n.m_segment):i<o?-1:i>o?1:0}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(e,t){this.m_sweepY=e,this.m_sweepX=t,this.m_prev1=q,this.m_prev2=q,this.m_vertex1=q,this.m_vertex2=q}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=t;return this.m_currentNode=s,this.compareSegments(r,r,n,n)}compareSegments(e,t,s,n){let r=this.tryGetCachedEdge_(e);null===r?this.m_vertex1===t?r=this.m_tempSimpleEdge1:(this.m_vertex1=t,r=this.tryCreateCachedEdge_(e),null===r&&(r=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=e),this.initSimpleEdge_(r,t)):this.m_vertex1=t;let i=this.tryGetCachedEdge_(s);return null===i?this.m_vertex2===n?i=this.m_tempSimpleEdge2:(this.m_vertex2=n,i=this.tryCreateCachedEdge_(s),null===i&&(i=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(i,n)):this.m_vertex2=n,this.compareSegments_(t,n,r,i)}onDelete(e){this.tryDeleteCachedEdge_(e)}onSet(e){this.tryDeleteCachedEdge_(e)}onEndSearch(e){this.tryDeleteCachedEdge_(e)}onAddUniqueElementFailed(e){this.tryDeleteCachedEdge_(e)}}class an{constructor(e,t){this.m_bIntersectionDetected=!1,this.m_pointOfInterest=$e.getNAN(),this.m_line1=new A,this.m_seg1=null,this.m_env=lt.constructEmpty(),this.m_vertex1=-1,this.m_currentNode=-1,this.m_minDist=Number.MAX_VALUE,this.m_shape=e,this.m_tolerance=t}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(e){this.m_pointOfInterest.assign(e)}compare(e,t){const s=e.getElement(t);return this.compareVertex(e,t,s)}compareVertex(e,t,n){let r,i=this.m_shape.getSegment(n),o=!0;if(null==i)this.m_shape.queryLineConnector(n,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),i=this.m_line1,r=this.m_line1.getStartY()===this.m_line1.getEndY();else{const e=s.constructEmpty();i.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),r=0===e.height(),o=!1}if(this.m_pointOfInterest.x+this.m_tolerance<this.m_env.vmin)return-1;if(this.m_pointOfInterest.x-this.m_tolerance>this.m_env.vmax)return 1;if(r)return this.m_currentNode=t,this.m_bIntersectionDetected=!0,0;let a=0;if(o){$(this.m_line1);const e=this.m_line1.getStartXY(),t=new $e;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();const s=new $e;s.setSub(this.m_pointOfInterest,e),a=t.dotProduct(s),a/=t.length()}else{a=i.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x}if(a<10*-this.m_tolerance)return-1;if(a>10*this.m_tolerance)return 1;if(i.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)){Math.abs(a)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=a),this.m_bIntersectionDetected=!0}return a<0?-1:a>0?1:0}}class hn{constructor(e,t){this.m_lists=new sn(!1),this.m_hash=t,this.m_hashBuckets=new Int32Array(e),this.m_hashBuckets.fill(hn.st_nullNode()),this.m_bitFilter=new Int32Array(10*e+31>>5)}reserveElements(e){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,e)),this.m_lists.reserveNodes(e)}addElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const n=t%this.m_hashBuckets.length;let r=this.m_hashBuckets[n];r===sn.st_nullNode()&&(r=this.m_lists.createList(),this.m_hashBuckets[n]=r);return this.m_lists.addElement(r,e)}deleteElement(e,t){void 0===t&&(t=this.m_hash.getHash(e));const s=t%this.m_hashBuckets.length,r=this.m_hashBuckets[s];r===sn.st_nullNode()&&n("");let i=this.m_lists.getFirst(r),o=sn.st_nullNode();for(;i!==sn.st_nullNode();){const t=this.m_lists.getData(i),n=this.m_lists.getNext(i);t===e?(this.m_lists.deleteElementDirect(r,o,i),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[s]=sn.st_nullNode())):o=i,i=n}}getFirstInBucket(e){const t=e%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[t>>5]&1<<(31&t)))return sn.st_nullNode();const s=e%this.m_hashBuckets.length,n=this.m_hashBuckets[s];return n===sn.st_nullNode()?sn.st_nullNode():this.m_lists.getFirst(n)}getNextInBucket(e){return this.m_lists.getNext(e)}findNode(e){const t=this.m_hash.getHash(e);let s=this.getFirstInBucket(t);for(;s!==sn.st_nullNode();){const t=this.m_lists.getData(s);if(this.m_hash.equal(t,e))return s;s=this.m_lists.getNext(s)}return sn.st_nullNode()}deleteNode(e){const t=this.getElement(e),s=this.m_hash.getHash(t)%this.m_hashBuckets.length,r=this.m_hashBuckets[s];r===sn.st_nullNode()&&n(""),this.m_lists.deleteElementSearch(r,e),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[s]=sn.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return sn.st_nullNode()}clear(){l(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function mn(e,t,s,n,r){const i=new fn(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=n,i.m_bHasSegmentParentage=e.hasSegmentParentage(),i.clusterNonReciprocal()}function ln(e,t,s,n,r){const i=e-s,o=t-n;return i*i+o*o<=r}function gn(){return{pt:new $e,weight:0,rank:0,bMerged:!1}}function un(e,t,s,n,r,i){const o=gn(),a=s+r;let h=!1,m=e.x;e.x!==t.x&&(n===i&&(m=(e.x*s+t.x*r)/a),h=!0);let l=e.y;return e.y!==t.y&&(n===i&&(l=(e.y*s+t.y*r)/a),h=!0),n!==i?n>i?(o.rank=n,o.weight=s,o.pt=e):(o.rank=i,o.weight=r,o.pt=t):(o.pt.setCoords(m,l),o.weight=a,o.rank=n),o.bMerged=h,o}function cn(e,t,s,n,r,i,o,a,h){const m=e.equals(t);if(n>i)return o.assignCopy(e),h[0]=n,a[0]=s,m;if(i>n)return o=t,h[0]=i,a[0]=r,m;o.assignCopy(e);const l=un(e.getXY(),t.getXY(),s,n,r,i);return o.setXY(l.pt),a[0]=l.weight,h[0]=l.rank,m}function _n(e,t,s,n,r){const i=new fn(r);return i.m_shape=e,i.m_sqrTolerance=t*t,i.m_cellSize=2*t,i.m_invCellSize=1/i.m_cellSize,i.m_geometry=s,i.m_bTrackChanges=!1,i.needsClustering()}function dn(e,t){const s=zt(e);return qt(s,t)}class pn{constructor(e,t,s,n,r){this.m_workPt=new $e,this.m_shape=e,this.m_sqrTolerance=s,this.m_invCellSize=n,this.m_origin=t.clone(),this.m_hashValues=r}getHash(e){return this.m_shape.getUserIndex(e,this.m_hashValues)}calculateHashFromVertex(e){this.m_shape.queryXY(e,this.m_workPt);const t=this.m_workPt.x-this.m_origin.x,s=Math.trunc(t*this.m_invCellSize+.5),n=this.m_workPt.y-this.m_origin.y;return dn(s,Math.trunc(n*this.m_invCellSize+.5))}equal(e,t){return l(0),!1}}class fn{constructor(e){this.m_origin=$e.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=q,this.m_bucketArray=Je(4,Number.NaN),this.m_bucketHash=Je(4,Number.NaN),this.m_dbgCandidateCheckCount=0,this.m_nsr=new ts,this.m_hashValues=-1,this.m_newClusters=-1,this.m_bTrackChanges=!1,this.m_bHasSegmentParentage=!1,this.m_shape=null,this.m_clusters=new sn,this.m_hashFunction=null,this.m_hashTable=null,this.m_progressCounter=0,this.m_progressTracker=e}progress_(){}collectClusterCandidates(e,t){const s=$e.getNAN();this.m_shape.queryXY(e,s);const n=(s.x-this.m_origin.x)*this.m_invCellSize,r=(s.y-this.m_origin.y)*this.m_invCellSize,i=Math.trunc(n),o=Math.trunc(r);let a=0;for(let h=0;h<=1;h+=1)for(let e=0;e<=1;e+=1){const t=dn(i+h,o+e),s=this.m_hashTable.getFirstInBucket(t);s!==hn.st_nullNode()&&(this.m_bucketArray[a]=s,this.m_bucketHash[a]=t,a++)}for(let h=a-1;h>=1;h--){const e=this.m_bucketArray[h];for(let t=h-1;t>=0;t--)if(e===this.m_bucketArray[t]){this.m_bucketHash[t]=-1,a--,h!==a&&(this.m_bucketHash[h]=this.m_bucketHash[a],this.m_bucketArray[h]=this.m_bucketArray[a]);break}}for(let h=0;h<a;h++)this.collectNearestNeighbourCandidates(e,this.m_bucketHash[h],s,this.m_bucketArray[h],t)}collectNearestNeighbourCandidates(e,t,s,n,r){const i=$e.getNAN();for(let o=n;o!==hn.st_nullNode();o=this.m_hashTable.getNextInBucket(o)){const n=this.m_hashTable.getElement(o);e===n||-1!==t&&this.m_shape.getUserIndex(n,this.m_hashValues)!==t||(this.m_shape.queryXY(n,i),ln(s.x,s.y,i.x,i.y,this.m_sqrTolerance)&&r.push(o))}}mergeClusters(e,t,s){let n=this.m_shape.getUserIndex(e,this.m_newClusters);const r=this.m_shape.getUserIndex(t,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,e),this.m_shape.setUserIndex(e,this.m_newClusters,n)),-1===r?this.m_clusters.addElement(n,t):this.m_clusters.concatenateLists(n,r),this.m_shape.setUserIndex(t,this.m_newClusters,Ye.impossibleIndex2());const i=this.mergeVertices(e,t);if(s){const t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t)}return i}mergeVertices(e,t){const s=$e.getNAN();this.m_shape.queryXY(e,s);const n=$e.getNAN();this.m_shape.queryXY(t,n);const r=this.m_shape.getRank(e),i=this.m_shape.getRank(t),o=this.m_shape.getWeight(e),a=this.m_shape.getWeight(t);let h,m,l,g,u=!1;if(r===i?(h=r,m=o+a,l=s.x,s.x!==n.x&&(l=(s.x*o+n.x*a)/m,u=!0),g=s.y,s.y!==n.y&&(g=(s.y*o+n.y*a)/m,u=!0)):(r>i?(l=s.x,g=s.y,m=o,h=r):(l=n.x,g=n.y,m=a,h=i),u=!s.equals(n)),u&&(this.m_shape.setXYMonotonic(e,l,g),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(e,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(e)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(e,s),this.m_shape.setSegmentParentageBreakVertex(t,s)}return this.m_shape.setWeight(e,m),this.m_shape.setRank(e,h),u}needsClustering(){const s={stack:[],error:void 0,hasError:!1};try{e(s,Gt(()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)}),!1);const t=this.m_shape.getSelectedCount(),n=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(n.getLowerLeft());const r=Math.max(n.height(),n.width())/(Tt()-1);this.m_cellSize<r&&(this.m_cellSize=r,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(this.m_shape.getSelectedCount()/3+1),this.m_clusters.reserveNodes(this.m_shape.getSelectedCount()/3+1),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new pn(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new hn(4*t/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let i=!1;for(let e=0;e<2;e++){const t=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==q;n=s.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===Ye.impossibleIndex2())continue;let s;if(0===e?(s=this.m_hashFunction.calculateHashFromVertex(n),this.m_shape.setUserIndex(n,this.m_hashValues,s)):s=this.m_shape.getUserIndex(n,this.m_hashValues),this.collectClusterCandidates(n,t),0!==t.length){for(let e=0,s=t.length;e<s;e++){this.progress_();const s=t[e],r=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,r))return this.m_nsr=new ts(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(r)),i=!0,i;this.mergeClusters(n,r,!1)}t.length=0}0===e&&this.m_hashTable.addElement(n,s)}}return i}catch(n){s.error=n,s.hasError=!0}finally{t(s)}}clusterNonReciprocal(){const e=this.m_shape.getSelectedCount(),t=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=t.getLowerLeft();const s=Math.max(t.height(),t.width())/(Tt()-1);this.m_cellSize<s&&(this.m_cellSize=s,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_clusters.reserveNodes(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new pn(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new hn(Math.trunc(4*e/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let n=!1;{const e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let t=e.next();t!==q;t=e.next()){this.progress_();const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e),this.m_hashTable.addElement(t,e)}}{const e=[],t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let s=t.next();s!==q;s=t.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===Ye.impossibleIndex2())continue;let t=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,t);let r=!1;for(;this.collectClusterCandidates(s,e),0!==e.length;){let t=0;for(let n=0,r=e.length;n<r;n++){this.progress_();const i=e[n],o=this.m_hashTable.getElement(i);this.m_hashTable.deleteNode(i);const a=n+1===r;t|=this.mergeClusters(s,o,a)?1:0}if(r||=0!==t,n||=0!==t,e.length=0,!t)break}r&&(t=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,t)}e.length=0}return n&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),n}applyClusterPositions_(){const e=$e.getNAN();for(let t=this.m_clusters.getFirstList();t!==sn.st_nullNode();t=this.m_clusters.getNextList(t)){let s=this.m_clusters.getFirst(t);const n=this.m_clusters.getElement(s);this.m_shape.queryXY(n,e);const r=this.m_shape.getRank(n),i=this.m_shape.getWeight(n);for(s=this.m_clusters.getNext(s);s!==sn.st_nullNode();s=this.m_clusters.getNext(s)){const t=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(t,e)||(this.m_shape.setXYMonotonicPoint2D(t,e),this.m_shape.setGeometryModifiedWithVertex(t,!0)):this.m_shape.setXYMonotonicPoint2D(t,e),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentageBreakVertex(n)||this.m_shape.getSegmentParentageBreakVertex(t);this.m_shape.setSegmentParentageBreakVertex(n,e),this.m_shape.setSegmentParentageBreakVertex(t,e)}this.m_shape.setWeight(t,i),this.m_shape.setRank(t,r)}}}}class xn{constructor(){this.m_inputParts=[],this.m_resultParts1=[],this.m_resultParts2=[],this.m_resultSegments=[],this.m_freeSegments=[],this.m_inputSegments=[],this.m_param1=[],this.m_param2=[],this.m_tolerance=0,this.m_toleranceZ=0,this.m_point=new ye,this.m_pointWeight=1,this.m_maxDensifyLimit=0,this.m_pointRank=0,this.m_changed1=!1,this.m_changed2=!1,this.m_adaptiveDensify=!1}clear(){this.freeAllResultSegments(),this.m_inputSegments.length=0,this.m_inputParts.length=0,this.m_resultParts1.length=0,this.m_resultParts2.length=0,this.m_param1.length=0,this.m_param2.length=0,this.m_adaptiveDensify=!1,this.m_changed1=!1,this.m_changed2=!1}newIntersectionPart_(e,t,s,n,r,i,o,a,h,m){return Pn(e,t,s,n,r,i,o,a,h,m)}pushSegment(e,t,s,n,r,i,o,a,h,m){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,t,s,n,r,i,o,a,h,m)),this.m_inputSegments.push(e),this.m_inputParts.length-1}getResultSegmentCount(e){return this.m_adaptiveDensify?0===e?this.m_param1.length-1:this.m_param2.length-1:0===e?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(e,t){return 0===e?this.m_resultParts1[t]:this.m_resultParts2[t]}getResultSegment(e,t){return this.m_resultSegments[this.getResultPart_(e,t).segmentIndex].get()}getSegmentChanged(e){return 0===e?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(e,t){return this.getResultPart_(e,t).weightStart}getResultSegmentStartPointRank(e,t){return this.getResultPart_(e,t).rankStart}getResultSegmentSegmentParentage(e,t){return this.getResultPart_(e,t).segmentParentage}getResultSegmentStartPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakStart}getResultSegmentEndPointWeight(e,t){return this.getResultPart_(e,t).weightEnd}getResultSegmentEndPointRank(e,t){return this.getResultPart_(e,t).rankEnd}getResultSegmentEndPointIsBreak(e,t){return this.getResultPart_(e,t).u.bBreakEnd}getResultSegmentInteriorRank(e,t){return this.getResultPart_(e,t).rankInterior}getResultSegmentInteriorWeight(e,t){return this.getResultPart_(e,t).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(e,t){2!==this.m_inputSegments.length&&a(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;const s=_t(e*xn.c_smallToleranceFactor);let n=!1;const r=this.m_inputParts[0],i=this.m_inputParts[1],o=this.m_inputSegments[r.segmentIndex],h=this.m_inputSegments[i.segmentIndex];if(t||5&B(!0,o,h,e,!0)){const t=Q(!0,o,h,null,this.m_param1,this.m_param2,e);0===t&&a("");const m=new Array(t);for(let e=0;e<t;++e)m[e]=$e.getNAN();const l=new Float64Array(t),g=new Int32Array(t),u=new Array(t),c=new Array(t);for(let e=0;e<t;++e)u[e]=En(),c[e]=En();for(let e=0;e<t;e++){const t=this.m_param1[e],a=this.m_param2[e];let _,d=r.rankInterior,p=r.weightInterior;0===t?(d=r.rankStart,p=r.weightStart,_=r.u.bBreakStart):1===t?(d=r.rankEnd,p=r.weightEnd,_=r.u.bBreakEnd):(this.m_changed1=!0,_=!1);let f,x=i.rankInterior,y=i.weightInterior;0===a?(x=i.rankStart,y=i.weightStart,f=i.u.bBreakStart):1===a?(x=i.rankEnd,y=i.weightEnd,f=i.u.bBreakEnd):(this.m_changed2=!0,f=!1);const P=d,E=x;let S=1,C=0,I=$e.getNAN();if(P===E){const n=o.getCoord2D(t),r=h.getCoord2D(a);S=p+y;C=d,Et(n,r,y/S,I);const i=$e.sqrDistance(I,n),m=$e.sqrDistance(I,r);u[e].bBigMove=i>s,c[e].bBigMove=m>s,this.m_changed1||n.equals(I)||(this.m_changed1=!0),this.m_changed2||r.equals(I)||(this.m_changed2=!0)}else if(P>E){I=o.getCoord2D(t);const n=h.getCoord2D(a);S=p,C=d;const r=$e.sqrDistance(I,n);u[e].bBigMove=!1,c[e].bBigMove=r>s,this.m_changed2||n.equals(I)||(this.m_changed2=!0)}else{I=h.getCoord2D(a),S=y,C=x;const n=o.getCoord2D(t),r=$e.sqrDistance(I,n);u[e].bBigMove=r>s,c[e].bBigMove=!1,this.m_changed1||n.equals(I)||(this.m_changed1=!0)}m[e].assign(I),l[e]=S,g[e]=C,u[e].bIsBreak=_||f,c[e].bIsBreak=_||f,n||=u[e].bBigMove||c[e].bBigMove}const _=r.rankInterior,d=r.weightInterior;let p=0,f=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param1[s]:1;if(n!==p){const i=this.allocResultSegment(),a=this.m_resultSegments[i];let h,c,x,y;o.queryCut(p,n,a,!1),a.get().snapControlPoints(e*e);let P=!1,E=!1,S=!1,C=!1,I=!1,b=$e.getNAN(),w=$e.getNAN();-1!==f?(c=g[f],h=l[f],P=u[f].bBigMove,b.assign(m[f]),S=u[f].bIsBreak,I=!0):(h=r.weightStart,c=r.rankStart,b=a.get().getStartXY(),S=r.u.bBreakStart),s<t?(y=g[s],x=l[s],E=u[s].bBigMove,w.assign(m[s]),C=u[s].bIsBreak,I=!0):(x=r.weightEnd,y=r.rankEnd,w=a.get().getEndXY(),C=r.u.bBreakEnd),I&&a.get().setCoordsForIntersector(b,w,!0),this.m_resultParts1.push(this.newIntersectionPart_(i,h,c,x,y,d,_,S,C,r.segmentParentage));const v=this.m_resultParts1.at(-1);v.u.bBigMoveStart=P,v.u.bBigMoveEnd=E,p=n,f=s}else-1===f&&(f=s)}const x=Je(t,0);for(let e=0;e<t;e++)x[e]=e;t>2?(x.sort((e,t)=>this.m_param2[e]<this.m_param2[t]?-1:this.m_param2[e]>this.m_param2[t]?1:0),tt(this.m_param2)):2===t&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=ot(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),x[1]=ot(x[0],x[0]=x[1]));const y=i.rankInterior,P=i.weightInterior;p=0,f=-1;for(let s=0;s<=t;s++){const n=s<t?this.m_param2[s]:1;if(n!==p){const r=this.allocResultSegment(),o=this.m_resultSegments[r];let a,u,_,d;h.queryCut(p,n,o,!1),o.get().snapControlPoints(e*e);let E=$e.getNAN(),S=$e.getNAN(),C=!1,I=!1,b=!1,w=!1,v=!1;if(-1!==f){const e=x[f];a=l[e],u=g[e],E.assign(m[e]),b=c[e].bBigMove,C=c[e].bIsBreak,v=!0}else a=i.weightStart,u=i.rankStart,E=o.get().getStartXY(),C=i.u.bBreakStart;if(s!==t){const e=x[s];_=l[e],d=g[e],S.assign(m[e]),w=c[e].bBigMove,I=c[e].bIsBreak,v=!0}else _=i.weightEnd,d=i.rankEnd,S=o.get().getEndXY(),I=i.u.bBreakEnd;v&&o.get().setCoordsForIntersector(E,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(r,a,u,_,d,P,y,C,I,i.segmentParentage));const N=this.m_resultParts2.at(-1);N.u.bBigMoveStart=b,N.u.bBigMoveEnd=w,p=n,f=s}else-1===f&&(f=s)}return n?3:2}return 0}intersectLines3D(e,t,s,n){return l(0),1}intersect2D(e,t){const s=this.m_inputParts[0],n=this.m_inputParts[1],r=this.m_inputSegments[s.segmentIndex].getGeometryType(),o=this.m_inputSegments[n.segmentIndex].getGeometryType();if(r!==i.enumLine||o!==i.enumLine){return new bn(this).intersectCurves(e,t)}return this.intersectLines(e,t)}intersect2DEx(e,t,s,n,r){this.m_point.assignCopy(t),1!==this.m_inputSegments.length&&a(""),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;const i=_t(e*xn.c_smallToleranceFactor);let o=!1;const h=this.m_inputParts[0],m=this.m_inputSegments[h.segmentIndex];if(r||m.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=Je(16,Number.NaN);const r=m.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=r;let a=h.rankInterior,l=h.weightInterior;0===r?(a=h.rankStart,l=h.weightStart):1===r?(a=h.rankEnd,l=h.weightEnd):this.m_changed1=!0;let g=a;const u=s,c=n;g===u&&m.isCurve()&&(g=u+1);let _=1,d=0;const p=new $e;if(g===u){const e=m.getCoord2D(r),s=t.getXY();_=l+c,d=a;Et(e,s,c/_,p),this.m_changed1||e.equals(p)||(this.m_changed1=!0),this.m_changed2||s.equals(p)||(this.m_changed2=!0);o=$e.sqrDistance(p,e)>i}else if(g>u)p.assign(m.getCoord2D(r)),_=l,d=a,this.m_changed2||p.equals(t.getXY())||(this.m_changed2=!0);else{p.assign(m.getCoord2D(r)),_=c,d=u,this.m_changed1||p.equals(t.getXY())||(this.m_changed1=!0);o=$e.sqrDistance(p,t.getXY())>i}let f=0,x=-1;const y=1;for(let t=0;t<=y;t++){const s=t<y?this.m_param1[0]:1;if(s!==f){const n=this.allocResultSegment(),r=this.m_resultSegments[n];m.queryCut(f,s,r),r.get().snapControlPoints(e*e);let i=h.weightStart,o=h.weightEnd,a=h.rankStart,l=h.rankEnd;const g=h.rankInterior,u=h.weightInterior;let c=h.u.bBreakStart,P=h.u.bBreakEnd;-1!==x&&(i=_,a=d,c=!0,r.get().setCoordsForIntersector(p,r.get().getEndXY(),!0)),t!==y&&(o=_,l=d,P=!0,r.get().setCoordsForIntersector(r.get().getStartXY(),p,!0)),f=s,this.m_resultParts1.push(this.newIntersectionPart_(n,i,a,o,l,u,g,c,P,h.segmentParentage))}x=t}return this.m_point.setXY(p),this.m_pointWeight=_,this.m_pointRank=d,o?3:2}return 0}intersect3D(e,t,s,n){return l(0),1}intersect3DEx(e,t,s,n,r,i,o){return l(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(e){this.m_freeSegments.push(e)}allocResultSegment(){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const e=new k,t=this.m_resultSegments.length;return this.m_resultSegments.push(e),t}allocResultSegmentFromBuffer(e){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const t=new k({copy:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}allocResultSegmentFromSegment(e){if(this.m_freeSegments.length){return this.m_freeSegments.pop()}const t=new k({segment:e}),s=this.m_resultSegments.length;return this.m_resultSegments.push(t),s}}function yn(e,t){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:e,bBreakEnd:t}}function Pn(e,t,s,n,r,i,o,a,h,m){return{segmentIndex:e,weightStart:t,rankStart:s,weightEnd:n,rankEnd:r,weightInterior:i,rankInterior:o,segmentParentage:m,u:yn(a,h)}}function En(){return{bBigMove:!1,bIsBreak:!1}}xn.maxWeight=.1*Number.MAX_VALUE,xn.c_smallToleranceFactor=.01,xn.c_maxGeometryTypeToRankDelta=8;let Sn=class{constructor(){this.start=null,this.end=null,this.equalEdge=null,this.segmentIndex=-1,this.segmentParentage=-1,this.weight=0,this.rank=0}hasSegment(){return this.segmentIndex>=0}transferAttributes(e,t,s){if(1===t.getDescription().getAttributeCount())return;const n=e.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),r=e.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),i=new ye;t.queryStart(i),s?(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i)):(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)),t.queryEnd(i),s?(i.setXY(r),e.parent.m_resultSegments[this.segmentIndex].get().setEnd(i)):(i.setXY(n),e.parent.m_resultSegments[this.segmentIndex].get().setStart(i))}copyFromWhenOverlap(e,t,s){this.equalEdge=t,t.equalEdge=this,this.segmentIndex=e.parent.allocResultSegmentFromBuffer(e.parent.m_resultSegments[t.segmentIndex]),this.segmentParentage=t.segmentParentage,this.weight=t.weight,this.rank=t.rank,s?(this.start.copyFrom(t.start),this.end.copyFrom(t.end)):(this.start.copyFrom(t.end),this.end.copyFrom(t.start),e.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}};class Cn{constructor(){this.hash=0,this.pt=new $e,this.prevInChain=null,this.nextInChain=null,this.prevInHash=null,this.nextInHash=null,this.prevEqual=null,this.nextEqual=null,this.weight=0,this.rank=0,this.bBigMove=!1,this.bIsBreak=!1}copyFrom(e){this.pt.assign(e.pt),this.weight=e.weight,this.rank=e.rank,this.bBigMove=e.bBigMove,this.bIsBreak=e.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let e=this;for(;null!==e.prevEqual;e=e.prevEqual);return e}}function In(e,t,s,n){return{edge1:e,edge2:t,recursion:s,bIsIntersecting:n}}class bn{constructor(e){this.m_pairs=[],this.m_chainOrigin1=null,this.m_chainOrigin2=null,this.m_newNodes=[],this.m_hashTableOfEquals=[],this.m_hashTableOfEqualsSize=0,this.m_origin=new $e,this.m_cell=new $e,this.parent=e}addSegment(e,t,s,n,r,i,o,a,h,m,g){const u=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),s,n,h),c=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),r,i,m);this.newEdge(u,c,e,o,a,g),null===this.m_chainOrigin1?this.m_chainOrigin1=u:null===this.m_chainOrigin2?this.m_chainOrigin2=u:l(0)}intersectCurvesHelper(e,t,s,n,r){const o=this.getSegment(e).get(),h=this.getSegment(t).get();if(o.isDegenerate(0)||h.isDegenerate(0))return 0;const m=this.tryOverlapIntersectCurves(e,t,s,n);if(0!==m)return m;const g=_t(.01*s);let u=!1,c=this.processSharpCorners(o,h,s,r>4);const _=c>0;if(!_){if(!(n||5&K(!0,!1,o,h,s,!0)))return 0;c=Q(!0,o,h,null,this.parent.m_param1,this.parent.m_param2,s)}0===c&&a("");const d=o.getGeometryType(),p=h.getGeometryType(),f=ut($e,c),x=ut($e,c),y=Je(c,Number.NaN),P=Je(c,Number.NaN),E=Je(c,Number.NaN),S=Je(c,Number.NaN),C=Dt(En,c),I=Dt(En,c);let b=!1,w=!1;for(let i=0;i<c;i++){const n=this.parent.m_param1[i],r=this.parent.m_param2[i];let a=e.rank,m=e.weight,l=!0,c=!1;0===n?(a=e.start.rank,m=e.start.weight,c=e.start.bIsBreak):1===n?(a=e.end.rank,m=e.end.weight,c=e.end.bIsBreak):(b=!0,l=!1);let v=t.rank,N=t.weight,T=!1,G=!0;0===r?(v=t.start.rank,N=t.start.weight,T=t.start.bIsBreak):1===r?(v=t.end.rank,N=t.end.weight,T=t.end.bIsBreak):(w=!0,G=!1);let D=a,V=v;if(D===V&&(D*=xn.c_maxGeometryTypeToRankDelta,V*=xn.c_maxGeometryTypeToRankDelta,D+=wn(d,o,!1),V+=wn(p,h,!1)),l&&G&&V===D){const e=o.getCoord2D(n),t=h.getCoord2D(r);e.equals(t)&&(V=D-1)}let F=1,H=0,k=1,A=0;const M=new $e,U=new $e,q=o.getCoord2D(n),B=h.getCoord2D(r);if(_&&$e.distance(q,B)>s)M.setCoordsPoint2D(q),U.setCoordsPoint2D(B),F=m,k=N,H=a,A=v,C[i].bBigMove=!1,I[i].bBigMove=!1,c=!0,T=!0;else if(D===V){k=F=m+N,A=H=a;Et(q,B,N/F,M),U.setCoordsPoint2D(M);const e=$e.sqrDistance(M,q),t=$e.sqrDistance(M,B);C[i].bBigMove=e>g,I[i].bBigMove=t>g,b||q.equals(M)||(b=!0),w||B.equals(U)||(w=!0)}else if(D>V){M.setCoordsPoint2D(q),U.setCoordsPoint2D(M),k=F=m,A=H=a;const e=$e.sqrDistance(M,B);C[i].bBigMove=!1,I[i].bBigMove=e>g,w||B.equals(U)||(w=!0)}else{U.setCoordsPoint2D(B),M.setCoordsPoint2D(U),k=F=N,A=H=v;const e=$e.sqrDistance(M,q);C[i].bBigMove=e>g,I[i].bBigMove=!1,b||q.equals(M)||(b=!0)}f[i].assign(M),x[i].assign(U),y[i]=F,P[i]=k,E[i]=H,S[i]=A,C[i].bIsBreak=c||T,I[i].bIsBreak=c||T,u||=C[i].bBigMove||I[i].bBigMove,i>0&&(n!==this.parent.m_param1[i-1]&&r!==this.parent.m_param2[i-1]||(E[i]<=E[i-1]?(f[i].assign(x[i-1]),y[i]=P[i-1],E[i]=S[i-1],x[i].assign(x[i-1]),P[i]=P[i-1],S[i]=S[i-1],C[i].bBigMove||=C[i-1].bBigMove,I[i].bBigMove||=I[i-1].bBigMove,C[i].bIsBreak||=C[i-1].bIsBreak,I[i].bIsBreak||=I[i-1].bIsBreak):(f[i-1].assign(f[i]),y[i-1]=y[i],E[i-1]=E[i],x[i-1].assign(x[i]),P[i-1]=P[i],S[i-1]=S[i],C[i-1].bBigMove||=C[i].bBigMove,I[i-1].bBigMove||=I[i].bBigMove,C[i-1].bIsBreak||=C[i].bIsBreak,I[i-1].bIsBreak||=I[i].bIsBreak)))}if(!(b||w||2!==c||d===i.enumLine&&p===i.enumLine)){if(this.processDoublyConnectedEdges(e,t,r+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;l(0)}this.parent.m_changed1||=b,this.parent.m_changed2||=w;let v=e,N=e.end.weight,T=e.end.rank,G=e.end.bBigMove,D=e.end.bIsBreak,V=0,F=-1;for(let i=0;i<=c;i++){const t=i<c?this.parent.m_param1[i]:1;if(t!==V){const n=this.parent.allocResultSegment(),r=this.parent.m_resultSegments[n];let a,h,m,l;o.queryCut(V,t,r,!1),r.get().snapControlPoints(s*s);let g=!1,u=!1,_=!1,d=!1;const p=new $e,x=new $e;-1!==F?(h=E[F],a=y[F],_=C[F].bBigMove,g=C[F].bIsBreak,p.assign(f[F])):(a=e.start.weight,h=e.start.rank,_=e.start.bBigMove,g=e.start.bIsBreak,p.assign(r.get().getStartXY())),i<c?(l=E[i],m=y[i],d=C[i].bBigMove,u=C[i].bIsBreak,x.assign(f[i])):(m=N,l=T,d=G,u=D,x.assign(r.get().getEndXY()));let P=v;t<1&&(this.splitEdgeInPlace(v),P=v.getNextInChain()),this.updateSegmentOnly(v,n),0===v.start.hash||v.start.pt.equals(p)||(this.m_newNodes.push(v.start),this.removeNodeFromHash(v.start),v.start.hash=0),0===v.end.hash||v.end.pt.equals(x)||(this.m_newNodes.push(v.end),this.removeNodeFromHash(v.end),v.end.hash=0),v.start.pt.assign(p),v.end.pt.assign(x),v.start.bBigMove||=_,v.end.bBigMove||=d,v.start.bIsBreak||=g,v.end.bIsBreak||=u,v.start.weight=a,v.start.rank=h,v.end.weight=m,v.end.rank=l,v=P,V=t,F=i}else-1===F&&(F=i)}const H=v.getNextInChain(),k=[];k.length=c;for(let i=0;i<c;i++)k[i]=i;c>2?(k.sort((e,t)=>Vt(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(Vt)):2===c&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=ot(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),k[1]=ot(k[0],k[0]=k[1])),v=t,N=t.end.weight,T=t.end.rank,G=t.end.bBigMove,D=t.end.bIsBreak,V=0,F=-1;for(let i=0;i<=c;i++){const e=i<c?this.parent.m_param2[i]:1;if(e!==V){const n=this.parent.allocResultSegment(),r=this.parent.m_resultSegments[n];let o,a,m,l;h.queryCut(V,e,r,!1),r.get().snapControlPoints(s*s);const g=new $e,u=new $e;let _=!1,d=!1,p=!1,f=!1;if(-1!==F){const e=k[F];o=P[e],a=S[e],g.assign(x[e]),p=I[e].bBigMove,_=I[e].bIsBreak}else o=t.start.weight,a=t.start.rank,p=t.start.bBigMove,_=t.start.bIsBreak,g.assign(r.get().getStartXY());if(i!==c){const e=k[i];m=P[e],l=S[e],u.assign(x[e]),f=I[e].bBigMove,d=I[e].bIsBreak}else m=N,l=T,f=G,d=D,u.assign(r.get().getEndXY());let y=v;e<1&&(this.splitEdgeInPlace(v),y=v.getNextInChain()),this.updateSegmentOnly(v,n),0===v.start.hash||v.start.pt.equals(g)||(this.m_newNodes.push(v.start),this.removeNodeFromHash(v.start),v.start.hash=0),0===v.end.hash||v.end.pt.equals(u)||(this.m_newNodes.push(v.end),this.removeNodeFromHash(v.end),v.end.hash=0),v.start.pt.assign(g),v.end.pt.assign(u),v.start.bBigMove||=p,v.end.bBigMove||=f,v.start.bIsBreak||=_,v.end.bIsBreak||=d,v.start.weight=o,v.start.rank=a,v.end.weight=m,v.end.rank=l,v=y,V=e,F=i}else-1===F&&(F=i)}const A=v.getNextInChain();return this.postProcessResultPartsForCurves(e,H,t,A,r+1),u?3:2}intersectCurves(e,t){2!==this.parent.m_inputSegments.length&&a(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=et(16);const n=s.constructEmpty();for(let o=0;o<2;o++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[o].segmentIndex]),t=s.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[o].segmentIndex].queryLooseEnvelope(t),n.mergeEnvelope2D(t);const r=this.parent.m_inputParts[o];this.addSegment(e,0,r.weightStart,r.rankStart,r.weightEnd,r.rankEnd,r.weightInterior,r.rankInterior,r.u.bBreakStart,r.u.bBreakEnd,r.segmentParentage)}n.inflateCoords(100*e,100*e),this.m_origin.assign(n.getLowerLeft()),this.m_cell.setCoords(2*e,2*e),this.m_pairs.push(In(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,t));let r=0,i=!0;for(;this.m_pairs.length;){const t=this.m_pairs.at(-1);this.m_pairs.pop(),l(t.recursion>=0),l(t.recursion<=256),this.clusterNodes(e);const s=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);i&&(i=!1,r=s)}for(let s=0;s<2;s++){const e=0===s?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let t=(0===s?this.m_chainOrigin1:this.m_chainOrigin2).nextInChain;null!=t;t=t.getNextInChain())e.push(this.parent.newIntersectionPart_(t.segmentIndex,t.start.weight,t.start.rank,t.end.weight,t.end.rank,t.weight,t.rank,t.start.bIsBreak,t.end.bIsBreak,t.segmentParentage)),e.at(-1).u.bBigMoveStart=t.start.bBigMove,e.at(-1).u.bBigMoveEnd=t.end.bBigMove}return r}tryOverlapIntersectCurves(e,t,s,n){const r=this.parent.m_resultSegments[e.segmentIndex].get(),i=this.parent.m_resultSegments[t.segmentIndex].get(),o=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY()),a=r.getStartXY().equals(i.getEndXY())&&r.getEndXY().equals(i.getStartXY());if(!o&&!a)return 0;const h=te(r,i,!0);if(0!==h&&se(r,i)&&e.segmentParentage===t.segmentParentage){let e=!1;if(h>0)e=r.equals(i);else{l(-1===h);const t=new k({segment:i});t.get().reverse(),e=r.equals(t.get())}if(e)return 1}const m=s*xn.c_smallToleranceFactor;let g=!1;if(0===h){const e=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new $e;r.queryCoord2D(n,o);const a=i.getClosestCoordinate(o,!1),h=new $e;i.queryCoord2D(a,h);const l=$e.distance(o,h);if(l>s)return 0;g||=l>m}for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new $e;i.queryCoord2D(n,o);const a=r.getClosestCoordinate(o,!1),h=new $e;r.queryCoord2D(a,h);const l=$e.distance(o,h);if(l>s)return 0;g||=l>m}}let u=e.rank,c=t.rank;return u===c&&(u*=xn.c_maxGeometryTypeToRankDelta,c*=xn.c_maxGeometryTypeToRankDelta,u+=wn(r.getGeometryType(),r,!0),c+=wn(i.getGeometryType(),i,!0)),u>c?(t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,r,o)):c>u?(e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,i,o)):e.segmentParentage<=t.segmentParentage?(e.weight=e.weight+t.weight,t.copyFromWhenOverlap(this,e,o),t.transferAttributes(this,r,o)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,o),e.transferAttributes(this,i,o)),g?3:2}postProcessResultPartsForCurves(e,t,s,n,r){r===Ft()&&a("curve_helper");for(let i=e;i!==t;i=i.getNextInChain())this.updateSegmentToNodes(i);for(let i=s;i!==n;i=i.getNextInChain())this.updateSegmentToNodes(i);for(let i=e;i!==t;i=i.getNextInChain()){const e=i.end.pt.sub(i.start.pt);for(let t=s;t!==n;t=t.getNextInChain()){let s=0;if(i.start.pt.equals(t.start.pt)&&i.end.pt.equals(t.end.pt)?s=1:i.start.pt.equals(t.end.pt)&&i.end.pt.equals(t.start.pt)&&(s=-1),!s){let s=i.start.pt.equals(t.start.pt)?1:0;if(s||(s=i.end.pt.equals(t.end.pt)?2:0,s||(s=i.end.pt.equals(t.start.pt)?3:0,s||(s=i.start.pt.equals(t.end.pt)?4:0))),s){const n=t.end.pt.sub(t.start.pt),o=e.dotProduct(n);let h;switch(s){case 1:case 2:h=o>0;break;case 3:case 4:h=o<0;break;default:a("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(In(i,t,r,!1))}continue}const n=this.parent.m_resultSegments[i.segmentIndex],o=this.parent.m_resultSegments[t.segmentIndex],h=[.5,.25,.75];for(let e=0,t=h.length;e<t;++e){const t=h[e],r=new $e;n.get().queryCoord2D(t,r);const i=o.get().getClosestCoordinate(r,!1),a=new $e;o.get().queryCoord2D(i,a);if($e.distance(r,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(i,t,r,!1));continue}for(let e=0,t=h.length;e<t;++e){const t=h[e],r=new $e;o.get().queryCoord2D(t,r);const i=n.get().getClosestCoordinate(r,!1),a=new $e;n.get().queryCoord2D(i,a);if($e.distance(r,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(i,t,r,!1));continue}i.equalEdge=t,t.equalEdge=i;let m=i.rank,l=t.rank;m===l&&(m*=xn.c_maxGeometryTypeToRankDelta,l*=xn.c_maxGeometryTypeToRankDelta,m+=wn(n.get().getGeometryType(),n.get(),!0),l+=wn(o.get().getGeometryType(),o.get(),!0)),m>l||m===l&&i.segmentParentage<=t.segmentParentage?(n.copyTo(o,!1),t.segmentParentage=i.segmentParentage,-1===s&&o.get().reverse()):(o.copyTo(n,!1),i.segmentParentage=t.segmentParentage,-1===s&&n.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(e.start),t&&this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(s.start),n&&this.updateAttachedEdgesAfterNodeChange(n.start)}processDoublyConnectedEdges(e,t,s,n){s===Ft()&&a("curve_helper");const r=this.getSegment(e).get(),i=this.getSegment(t).get(),o=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY())?1:r.getEndXY().equals(i.getStartXY())&&r.getStartXY().equals(i.getEndXY())?-1:0;if(0!==o){const a=new k;r.queryCut(0,.5,a),a.get().snapControlPoints(n*n);const h=new k;r.queryCut(.5,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(e),e.end.pt=a.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(a),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h);let m=i.getClosestCoordinate(e.end.pt,!1);return Math.abs(m-.5)>.2&&(m=.5),i.queryCut(0,m,a),a.get().snapControlPoints(n*n),i.queryCut(m,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(t),t.end.pt=a.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(a),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h),o>0?(this.m_pairs.push(In(e,t,s,!1)),this.m_pairs.push(In(e.getNextInChain(),t.getNextInChain(),s,!1))):(this.m_pairs.push(In(e,t.getNextInChain(),s,!1)),this.m_pairs.push(In(e.getNextInChain(),t,s,!1))),!0}return!1}newNode(e,t,s,n){const r=new Cn;return this.m_newNodes.push(r),r.pt=e,r.rank=s,r.weight=t,r.bIsBreak=n,r}newEdge(e,t,s,n,r,i){const o=new Sn;return o.start=e,o.end=t,e.nextInChain=o,t.prevInChain=o,o.segmentIndex=s,o.segmentParentage=i,o.rank=r,o.weight=n,o}splitEdgeInPlace(e){e.segmentIndex=-1;const t=new Sn,s=new Cn;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=t,s.prevInChain=e,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=e.weight,s.rank=e.rank,s.bIsBreak=!1,s.bBigMove=!1,t.start=s,t.segmentIndex=-1,t.end=e.end,t.end.prevInChain=t,t.rank=e.rank,t.weight=e.weight,t.segmentParentage=e.segmentParentage,e.end=s,e.equalEdge&&(e.equalEdge.equalEdge=null),e.equalEdge=null}updateSegmentOnly(e,t){e.segmentIndex=t}updateAttachedEdgesAfterNodeChange(e){for(let t=e.equalListHead();null!==t;t=t.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(t)}updateAttachedEdgesAfterNodeChangeImpl(e){const t=e.prevInChain;if(t&&t.hasSegment()){const s=this.getSegment(t).get();e.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(t.start.pt,t.end.pt,!1),s.ensureXYMonotone())}const s=e.nextInChain;if(s&&s.hasSegment()){const t=this.getSegment(s).get();e.pt.equals(t.getStartXY())||(t.setCoordsForIntersector(s.start.pt,s.end.pt,!1),t.ensureXYMonotone())}}updateSegmentToNodes(e){const t=this.getSegment(e).get();e.start.pt.equals(t.getStartXY())&&e.end.pt.equals(t.getEndXY())||(t.setCoordsForIntersector(e.start.pt,e.end.pt,!1),t.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(e.end)}getSegment(e){return this.parent.m_resultSegments[e.segmentIndex]}clusterNodes(e){let t=!1;const s=[],n=[],r=[];for(let i=0,o=this.m_newNodes.length;i<o;i++){const e=this.m_newNodes[i];if(null===e)continue;let t=e;for(let s=i+1;s<o;s++){const n=this.m_newNodes[s];null!==n&&(e.pt.equals(n.pt)&&(t.nextInHash=n,n.prevInHash=t,t=n,this.m_newNodes[s]=null))}}for(let i=0,o=this.m_newNodes.length;i<o;i++){const o=this.m_newNodes[i];if(null==o)continue;for(o.hash=this.calculateHash(o.pt);;){const i=et(4),a=this.hashTableBinsToCheck(o,i);for(let t=0;t<a;t++)if(null!==i[t])for(let a=i[t];null!==a;){const t=a.nextInHash;$e.distance(o.pt,a.pt)<=e&&(s.push(a),this.removeNodeFromHash(a),a.hash=0,r.push(a),n.push(a)),a=t}let h=!1;for(const e of s)if(!o.pt.equals(e.pt)){const s=un(o.pt,e.pt,o.weight,o.rank,e.weight,e.rank);o.pt.assign(s.pt),o.weight=s.weight,o.rank=s.rank,h=!0,t=!0}if(s.length=0,!h)break;o.hash=this.calculateHash(o.pt)}r.push(o),n.push(o);for(let e=o.nextInHash;null!==e;){e.prevInHash=null;const t=e.nextInHash;e.nextInHash=null,r.push(e),n.push(e),e=t}const a=o.hash;let h=null,m=null;for(const e of n)o!==e&&(e.hash=a,e.pt.assign(o.pt),e.rank=o.rank,e.weight=o.weight),e.prevInHash=h,h&&(h.nextInHash=e),e.prevEqual=m,e.nextEqual=null,m&&(m.nextEqual=e),m=e,h=e;const l=a%this.m_hashTableOfEquals.length;h.nextInHash=this.m_hashTableOfEquals[l],null!==this.m_hashTableOfEquals[l]&&(this.m_hashTableOfEquals[l].prevInHash=h),this.m_hashTableOfEquals[l]=n[0],this.m_hashTableOfEqualsSize+=n.length,n.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,t)for(const i of r)this.updateAttachedEdgesAfterNodeChange(i)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const e=this.m_hashTableOfEquals;this.m_hashTableOfEquals=et(2*e.length),this.m_hashTableOfEqualsSize=0;for(const t of e){let e=t;for(;e;){const t=e.nextInHash;e.nextInHash=null,e.prevInHash=null,this.addNodeToHashImpl(e),e=t}}}}addNodeToHashImpl(e){const t=e.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[t];e.nextInHash=s,null!==s&&(s.prevInHash=e),this.m_hashTableOfEquals[t]=e,this.m_hashTableOfEqualsSize++}removeNodeFromHash(e){const t=e.hash%this.m_hashTableOfEquals.length,s=e.prevInHash,n=e.nextInHash;s?s.nextInHash=n:this.m_hashTableOfEquals[t]=n,n&&(n.prevInHash=s),this.m_hashTableOfEqualsSize--,e.prevInHash=null,e.nextInHash=null}hashTableBinsToCheck(e,t){const s=(e.pt.x-this.m_origin.x)/this.m_cell.x,n=(e.pt.y-this.m_origin.y)/this.m_cell.y,r=Tt()-1,i=Math.round(Ct(s,-r,r)),o=Math.round(Ct(n,-r,r));let a=i|o<<32;a=Qe(a),t[0]=this.m_hashTableOfEquals[a%this.m_hashTableOfEquals.length];let h=i+1|o<<32;h=Qe(h);let m=1;t[1]=this.m_hashTableOfEquals[h%this.m_hashTableOfEquals.length],t[1]!==t[0]&&(m=2);let l=i+1|o+1<<32;l=Qe(l),t[m]=this.m_hashTableOfEquals[l%this.m_hashTableOfEquals.length];for(let u=0;u<m;u++)if(t[m]===t[u]){m--;break}m++;let g=i|o+1<<32;g=Qe(g),t[m]=this.m_hashTableOfEquals[g%this.m_hashTableOfEquals.length];for(let u=0;u<m;u++)if(t[m]===t[u]){m--;break}return m++,m}calculateHash(e){const t=(e.x-this.m_origin.x)/this.m_cell.x,s=(e.y-this.m_origin.y)/this.m_cell.y,n=Tt()-1;let r=Math.round(Ct(t,-n,n))|Math.round(Ct(s,-n,n))<<32;return r=Qe(r),0===r&&(r=1),r}processSharpCorners(e,t,s,n){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,e.getStartXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],o=ne(e,t,0,0,s,2,r,i,n);if(o){this.parent.m_param1.push(0),this.parent.m_param2.push(0);for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return o+1}}if(e.getEndXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],o=ne(e,t,1,1,s,2,r,i,n);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),o+1}}if(e.getStartXY().equals(t.getEndXY())){const r=[0,0],i=[0,0],o=ne(e,t,0,1,s,2,r,i,n);if(o){this.parent.m_param1.push(0),this.parent.m_param2.push(1);for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return o+1}}if(e.getEndXY().equals(t.getStartXY())){const r=[0,0],i=[0,0],o=ne(e,t,1,0,s,2,r,i,n);if(o){for(let e=0;e<o;e++)this.parent.m_param1.push(r[e]),this.parent.m_param2.push(i[e]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),o+1}}return 0}}function wn(e,t,s){let n=0;switch(e){case i.enumLine:n=0;break;case i.enumBezier:n=2;break;case i.enumRationalBezier2:n=3;break;case i.enumBezier2:n=1;break;case i.enumEllipticArc:n=0===t.projectionBehavior()?5:4;break;default:a("")}return s?5-n:n}class vn extends on{constructor(e){super(e.m_shape,e.m_tolerance,!1),this.m_parent=e}compare(e,t,s){if(this.m_bIntersectionDetected)return-1;const n=e.getElement(s),r=this.m_parent.getEdgeOriginVertices(t),i=this.m_parent.m_edgeVertices.getFirstElement(r),o=this.m_parent.getEdgeOriginVertices(n),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(t,i,n,a)}}class Nn extends an{constructor(e){super(e.m_shape,e.m_tolerance),this.m_parent=e}compare(e,t){if(this.m_bIntersectionDetected)return-1;const s=e.getElement(t),n=this.m_parent.getEdgeOriginVertices(s),r=this.m_parent.m_edgeVertices.getFirstElement(n);return this.m_currentNode=t,this.compareVertex(e,t,r)}}class Tn extends Xe{constructor(e){super(),this.pt1=$e.getNAN(),this.pt2=$e.getNAN(),this.m_shape=e}compare(e,t,s){this.m_shape.queryXY(t,this.pt1);const n=e.getElement(s);return this.m_shape.queryXY(n,this.pt2),this.pt1.compare(this.pt2)}}class Gn{constructor(e){this.m_point=$e.getNAN(),this.m_pt=$e.getNAN(),this.m_shape=e}setPoint(e){this.m_point.setCoordsPoint2D(e)}compare(e,t){const s=e.getElement(t);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class Dn{constructor(e,t){this.m_shape=null,this.m_progressTracker=null,this.m_edges=new Ye(8),this.m_clusters=new Ye(5),this.m_clusterVertices=new sn(!1),this.m_edgeVertices=new sn(!1),this.m_helperPoint=new ye,this.m_eventQ=new Ce,this.m_sweepStructure=new Ce,this.m_bComplications=!1,this.m_sweepComparator=null,this.m_tempEdgeBuffer=[],this.m_modifiedClusters=[],this.m_edgesToInsertInSweepStructure=[],this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1,this.m_progressCounter=0,this.m_segmentIntersector=new xn,this.m_segBuf1=new k,this.m_segBuf2=new k,this.m_sweepPoint=new $e(0,0),this.m_tolerance=0,this.m_toleranceSqr=0,this.m_sweepPointCluster=-1,this.m_vertexClusterIndex=-1,this.m_bCracked=!1,this.m_bSweepPointClusterWasModified=!1,this.m_progressTracker=e,this.m_bTrackChanges=t}hadComplications(){return this.m_bComplications}sweep(e,t){const s=new jt;s.setSwapCoordinates(),e.applyTransformation(s),this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t;let n=this.sweepImpl_();return e.applyTransformation(s),n||(this.fillEventQueuePass2(),n=this.sweepImpl_()||n),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(e,t){this.setEditShape_(e),this.m_bCracked=!1,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const n=e.filterClosePoints(t,!0,!1,this.m_bTrackChanges,q);this.m_bComplications=1===n,s||=1===n}return-1!==this.m_vertexClusterIndex&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,s}getEdgeCluster(e,t){return this.m_edges.getField(e,0+t)}setEdgeCluster_(e,t,s){this.m_edges.setField(e,0+t,s)}getEdgeOriginVertices(e){return this.m_edges.getField(e,2)}setEdgeOriginVertices_(e,t){this.m_edges.setField(e,2,t)}getNextEdgeEx(e,t){return this.m_edges.getField(e,3+t)}setNextEdgeEx_(e,t,s){this.m_edges.setField(e,3+t,s)}getEdgeSweepNode(e){return this.m_edges.getField(e,7)}setEdgeSweepNode_(e,t){this.m_edges.setField(e,7,t)}getNextEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,3+s)}setNextEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,3+n,s)}getPrevEdge(e,t){const s=this.getEdgeEnd(e,t);return this.m_edges.getField(e,5+s)}setPrevEdge_(e,t,s){const n=this.getEdgeEnd(e,t);this.m_edges.setField(e,5+n,s)}getClusterVertices(e){return this.m_clusters.getField(e,0)}setClusterVertices_(e,t){this.m_clusters.setField(e,0,t)}getClusterSweepEdgeList(e){return this.m_clusters.getField(e,2)}setClusterSweepEdgeList_(e,t){this.m_clusters.setField(e,2,t)}getClusterFirstEdge(e){return this.m_clusters.getField(e,1)}setClusterFirstEdge_(e,t){this.m_clusters.setField(e,1,t)}getClusterEventQNode(e){return this.m_clusters.getField(e,3)}setClusterEventQNode_(e,t){this.m_clusters.setField(e,3,t)}newCluster_(e){const t=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(t,s),e!==q&&(this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)),t}deleteCluster_(e){this.m_clusters.deleteElement(e)}addVertexToCluster_(e,t){const s=this.getClusterVertices(e);this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}newEdge_(e){const t=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(t,s),-1!==e&&this.m_edgeVertices.addElement(s,e),t}addVertexToEdge_(e,t){const s=this.getEdgeOriginVertices(e);this.m_edgeVertices.addElement(s,t)}deleteEdge_(e){this.m_edges.deleteElement(e);const t=this.m_edgesToInsertInSweepStructure.findIndex(t=>t===e);t>=0&&xt(this.m_edgesToInsertInSweepStructure,t)}addEdgeToCluster(e,t){-1===this.getEdgeCluster(e,0)?this.setEdgeCluster_(e,0,t):-1===this.getEdgeCluster(e,1)?this.setEdgeCluster_(e,1,t):a(""),this.addEdgeToClusterImpl_(e,t)}addEdgeToClusterImpl_(e,t){const s=this.getClusterFirstEdge(t);if(-1!==s){const n=this.getNextEdge(s,t);this.setPrevEdge_(n,t,e),this.setNextEdge_(e,t,n),this.setNextEdge_(s,t,e),this.setPrevEdge_(e,t,s)}else this.setPrevEdge_(e,t,e),this.setNextEdge_(e,t,e),this.setClusterFirstEdge_(t,e)}getEdgeEnd(e,t){return this.getEdgeCluster(e,0)===t?0:1}mergeClusters_(e,t){this.dbgCheckCluster_(e),this.dbgCheckCluster_(t);const s=this.getClusterEventQNode(t);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(t,-1));let n=this.getClusterFirstEdge(e),r=this.getClusterFirstEdge(t);if(-1!==r){let s=r,i=r,o=!1;do{this.dbgCheckEdge_(s),o=!1;const n=this.getEdgeEnd(s,t),a=this.getNextEdgeEx(s,n);if(this.getEdgeCluster(s,n+1&1)===e){this.disconnectEdge_(s);const e=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(e),this.deleteEdge_(s),s===a){r=-1;break}r===s&&(r=this.getClusterFirstEdge(t),i=a,o=!0)}s=a}while(s!==i||o);if(-1!==r){do{const n=this.getEdgeEnd(s,t),r=this.getNextEdgeEx(s,n);this.setEdgeCluster_(s,n,e),s=r}while(s!==i);if(n=this.getClusterFirstEdge(e),-1!==n){const t=this.getNextEdge(n,e),s=this.getNextEdge(r,e);t===n?(this.setClusterFirstEdge_(e,r),this.addEdgeToClusterImpl_(n,e),this.setClusterFirstEdge_(e,n)):s===r&&this.addEdgeToClusterImpl_(r,e),this.setNextEdge_(r,e,t),this.setPrevEdge_(t,e,r),this.setNextEdge_(n,e,s),this.setPrevEdge_(s,e,n)}else this.setClusterFirstEdge_(e,r)}}const i=this.getClusterVertices(e),o=this.getClusterVertices(t);for(let a=this.m_clusterVertices.getFirst(o);-1!==a;a=this.m_clusterVertices.getNext(a)){const t=this.m_clusterVertices.getElement(a);this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)}this.m_clusterVertices.concatenateLists(i,o),this.deleteCluster_(t),this.dbgCheckCluster_(e)}mergeEdges_(e,t){this.dbgCheckEdge_(e),this.dbgCheckEdge_(t);const s=this.getEdgeCluster(e,0),n=this.getEdgeCluster(e,1),r=this.getEdgeCluster(t,0),i=this.getEdgeCluster(t,1),o=this.getEdgeOriginVertices(e),a=this.getEdgeOriginVertices(t);if(this.m_edgeVertices.concatenateLists(o,a),t===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,e),t===this.getClusterFirstEdge(n)&&this.setClusterFirstEdge_(n,e),this.disconnectEdge_(t),this.deleteEdge_(t),!(s===r&&n===i||n===r&&s===i)){const e=this.getClusterXY(s),t=this.getClusterXY(r);e.isEqualPoint2D(t)?(s!==r&&this.mergeClusters_(s,r),n!==i&&this.mergeClusters_(n,i)):(n!==r&&this.mergeClusters_(n,r),s!==i&&this.mergeClusters_(s,i))}this.dbgCheckEdge_(e)}disconnectEdge_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1);this.disconnectEdgeFromCluster_(e,t),this.disconnectEdgeFromCluster_(e,s)}disconnectEdgeFromCluster_(e,t){const s=this.getNextEdge(e,t),n=this.getPrevEdge(e,t),r=this.getClusterFirstEdge(t);s!==e?(this.setNextEdge_(n,t,s),this.setPrevEdge_(s,t,n),r===e&&this.setClusterFirstEdge_(t,s)):this.setClusterFirstEdge_(t,-1)}applyIntersectorToEditShape_(e,t,s){let n=this.m_edgeVertices.getFirst(e);const r=this.m_edgeVertices.getElement(n),i=this.getClusterFromVertex(r),o=this.m_shape.getNextVertex(r),a=this.getClusterFromVertex(o),h=this.m_shape.getXY(r),m=this.m_shape.getXY(o);let l=!1,g=!1;const u=t.getResultSegment(s,0).getStartXY(),c=t.getResultSegment(s,t.getResultSegmentCount(s)-1).getEndXY();h.equals(u)||(l=!0),m.equals(c)||(g=!0),this.m_shape.splitSegmentWithIntersector(r,t,s,!0,!0);const _=this.m_bTrackChanges&&t.getSegmentChanged(s);for(_&&this.m_shape.setGeometryModifiedWithVertex(r,!0),n=this.m_edgeVertices.getNext(n);-1!==n;n=this.m_edgeVertices.getNext(n)){const e=this.m_edgeVertices.getElement(n),r=this.getClusterFromVertex(e)===i;this.m_shape.splitSegmentWithIntersector(e,t,s,r,!0),_&&this.m_shape.setGeometryModifiedWithVertex(e,!0)}if(l&&this.updateClusterXY(!0,i,u,t.getResultSegmentStartPointWeight(s,0),t.getResultSegmentStartPointRank(s,0)),g){const e=t.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,c,t.getResultSegmentEndPointWeight(s,e),t.getResultSegmentEndPointRank(s,e))}}createEdgesAndClustersFromSplitEdge_(e,t,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(e),r=this.getEdgeCluster(e,0),i=this.getEdgeCluster(e,1);let o=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(o);const a=Ye.impossibleIndex3();this.setEdgeSweepNode_(o,a),this.m_tempEdgeBuffer.push(o),this.addEdgeToCluster(o,r);const h=t.getResultSegmentCount(s);for(let m=1;m<h;m++){const e=this.newCluster_(-1);this.m_modifiedClusters.push(e),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(o,e);const t=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(t),this.setEdgeSweepNode_(t,a),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(t,e),o=t}this.addEdgeToCluster(o,i);for(let m=this.m_edgeVertices.getFirst(n);-1!==m;m=this.m_edgeVertices.getNext(m)){let e=this.m_edgeVertices.getElement(m);if(this.getClusterFromVertex(e)===r){let t=0;const s=this.m_tempEdgeBuffer.length;do{if(t>0){const s=this.m_tempEdgeBuffer[t-1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t+=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t<s)}else{let t=this.m_tempEdgeBuffer.length-1;do{if(t<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[t+1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t-=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}getClusterFromVertex(e){return this.m_shape.getUserIndex(e,this.m_vertexClusterIndex)}processSplitHelper1_(e,t,s){const n=this.getEdgeCluster(t,0),r=this.getClusterXY(n),i=this.getEdgeCluster(t,1),o=this.getClusterXY(i),a=s.getResultSegmentCount(e);let h=s.getResultSegment(e,0);const m=h.getStartXY();if(!r.isEqualPoint2D(m)){if(!this.m_bComplications){r.compare(this.m_sweepPoint)*m.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0)}this.getAffectedEdges(n,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(n)}if(!this.m_bComplications&&a>1){const e=r.compare(o),t=h.getEndXY();(r.compare(t)!==e||t.compare(o)!==e||t.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}h=s.getResultSegment(e,a-1);const l=h.getEndXY();if(!o.isEqualPoint2D(l)){if(!this.m_bComplications){o.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0)}this.getAffectedEdges(i,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(i)}this.m_tempEdgeBuffer.push(t);for(let g=0,u=this.m_tempEdgeBuffer.length;g<u;g++){const e=this.m_tempEdgeBuffer[g],s=this.getEdgeSweepNode(e);Ye.isValidElement(s)&&(this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(e,-1));const n=Ye.impossibleIndex3();e!==t&&this.getEdgeSweepNode(e)!==n&&(this.m_edgesToInsertInSweepStructure.push(e),this.setEdgeSweepNode_(e,n))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(e,t){const s=this.m_sweepStructure.getElement(e);return this.m_sweepComparator.compare(this.m_sweepStructure,s,t),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(e,t),!0)}fixIntersection_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e),n=this.m_sweepStructure.getElement(t);let r=null,i=null;const o=this.getEdgeOriginVertices(s),a=this.m_edgeVertices.getFirstElement(o),h=this.getEdgeOriginVertices(n),m=this.m_edgeVertices.getFirstElement(h);this.m_shape.querySegment(a,this.m_segBuf1,!1,!1),r=this.m_segBuf1.get();const l=this.m_shape.getNextVertex(a),g=this.m_shape.getWeight(a),u=this.m_shape.getSegmentParentageBreakVertex(a),c=this.m_shape.getWeight(l),_=this.m_shape.getSegmentParentageBreakVertex(l),d=this.m_shape.getSegmentWeight(a),p=this.m_shape.getRank(a),f=this.m_shape.getRank(l),x=this.m_shape.getSegmentRank(a),y=this.m_shape.getSegmentParentage(a);this.m_shape.querySegment(m,this.m_segBuf2,!1,!1),i=this.m_segBuf2.get();const P=this.m_shape.getNextVertex(m),E=this.m_shape.getWeight(m),S=this.m_shape.getSegmentParentageBreakVertex(m),C=this.m_shape.getWeight(P),I=this.m_shape.getSegmentParentageBreakVertex(P),b=this.m_shape.getSegmentWeight(m),w=this.m_shape.getRank(m),v=this.m_shape.getRank(P),N=this.m_shape.getSegmentRank(m),T=this.m_shape.getSegmentParentage(m);this.m_segmentIntersector.pushSegment(r,g,p,c,f,d,x,u,_,y),this.m_segmentIntersector.pushSegment(i,E,w,C,v,b,N,S,I,T),3===this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)&&(this.m_bComplications=!0),this.splitEdge_(s,n,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(e,t){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t);let n=null;const r=this.getEdgeOriginVertices(s),i=this.m_edgeVertices.getFirstElement(r);this.m_shape.querySegment(i,this.m_segBuf1,!1,!1),n=this.m_segBuf1.get();const o=this.m_shape.getNextVertex(i),a=this.m_shape.getWeight(i),h=this.m_shape.getSegmentParentageBreakVertex(i),m=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),g=this.m_shape.getSegmentWeight(i),u=this.m_shape.getRank(i),c=this.m_shape.getRank(o),_=this.m_shape.getSegmentRank(i),d=this.m_shape.getSegmentParentage(i),p=this.getClusterFirstVertex(e);this.m_segmentIntersector.pushSegment(n,a,u,m,c,g,_,h,l,d),this.m_shape.queryPoint(p,this.m_helperPoint);const f=this.m_shape.getWeight(p),x=this.m_shape.getRank(p);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,x,f,!0),this.splitEdge_(s,-1,e,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let e=!0,t=0;const s=this.m_edgesToInsertInSweepStructure.length,n=Math.max(2*s+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||t>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,e=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const r=this.isEdgeOnSweepLine_(s);Ye.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),t++):r!==Ye.impossibleIndex2()&&(e=!1),this.m_bContinuingSegmentChainOptimization=!1}return e}insertNewEdgeToSweepStructure_(e,t){let s;if(this.m_bContinuingSegmentChainOptimization?(s=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,e,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):s=this.m_sweepStructure.addUniqueElement(e),-1===s){const t=this.m_sweepStructure.getDuplicateElement(),s=this.m_sweepStructure.getElement(t);return this.mergeEdges_(s,e),!1}if(this.setEdgeSweepNode_(e,s),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();const e=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===e&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===e&&(this.m_nextNeighbour=-1),this.fixIntersection_(e,s),!0}return!1}isEdgeOnSweepLine_(e){const t=this.getEdgeCluster(e,0),s=this.getEdgeCluster(e,1),n=this.getClusterXY(t),r=this.getClusterXY(s);if($e.sqrDistance(n,r)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const i=n.compare(this.m_sweepPoint),o=r.compare(this.m_sweepPoint);return i<=0&&o>0?s:o<=0&&i>0?t:i>0&&o>0?Ye.impossibleIndex2():-1}fillEventQueue(){const e=new be(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let r=t.next();r!==q;r=t.next())-1!==this.m_shape.getUserIndex(r,this.m_vertexClusterIndex)&&e.add(r);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0),this.m_eventQ.clear(),this.m_eventQ.setCapacity(e.size()),this.m_eventQ.setComparator(new Tn(this.m_shape));const s=$e.getNAN();s.setNAN();let n=-1;for(let r=0,i=e.size();r<i;r++){const t=e.read(r);if(this.m_shape.getXY(t).isEqualPoint2D(s)){const e=this.m_shape.getUserIndex(t,this.m_vertexClusterIndex);this.mergeClusters_(n,e);continue}n=this.getClusterFromVertex(t),this.m_shape.queryXY(t,s);const i=this.m_eventQ.addBiggestElement(t);this.setClusterEventQNode_(n,i)}}fillEventQueuePass2(){const e=new be(0);for(let t=this.m_eventQ.getFirst();-1!==t;t=this.m_eventQ.getNext(t)){const s=this.m_eventQ.getElement(t);e.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(e,0,e.size()),this.progress_(!0);for(let t=0,s=e.size();t<s;t++){const s=e.read(t),n=this.getClusterFromVertex(s),r=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(n,r)}}getAffectedEdges(e,t){const s=this.getClusterFirstEdge(e);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);Ye.isValidElement(s)&&t.push(n),n=this.getNextEdge(n,e)}while(n!==s)}updateClusterXY(e,t,s,n,r){const i=this.getClusterVertices(t);for(let o=this.m_clusterVertices.getFirst(i);-1!==o;o=this.m_clusterVertices.getNext(o)){const t=this.m_clusterVertices.getElement(o);this.m_shape.setXYMonotonicPoint2D(t,s),this.m_shape.setWeight(t,n),this.m_shape.setRank(t,r),e&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(t,!0),this.m_shape.setSegmentParentageBreakVertex(t,!0)}}splitEdge_(e,t,s,n){this.dbgCheckEdge_(e),-1!==t&&this.dbgCheckEdge_(t),this.disconnectEdge_(e),-1!==t&&this.disconnectEdge_(t),this.processSplitHelper1_(0,e,n),-1!==t&&this.processSplitHelper1_(1,t,n),-1!==s&&n.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let o=0,a=this.m_modifiedClusters.length;o<a;o++){const e=this.m_modifiedClusters[o],t=this.getClusterEventQNode(e);-1!==t&&(this.m_eventQ.deleteNode(t),this.setClusterEventQNode_(e,-1))}const r=this.getEdgeOriginVertices(e),i=-1!==t?this.getEdgeOriginVertices(t):-1;if(this.applyIntersectorToEditShape_(r,n,0),-1!==i)this.applyIntersectorToEditShape_(i,n,1);else{const e=n.getResultPoint().getXY();this.updateClusterXY(n.getResultPointChanged(),s,e,n.getResultPointWeight(),n.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(e,n,0),-1!==t&&this.createEdgesAndClustersFromSplitEdge_(t,n,1),this.m_edgeVertices.deleteList(r),this.deleteEdge_(e),-1!==t&&(this.m_edgeVertices.deleteList(i),this.deleteEdge_(t));for(let o=0,a=this.m_modifiedClusters.length;o<a;o++){const e=this.m_modifiedClusters[o];e===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let t=this.getClusterEventQNode(e);if(-1===t){const s=this.getClusterFirstVertex(e);if(t=this.m_eventQ.addUniqueElement(s),-1===t){const t=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(t),n=this.getClusterFromVertex(s);this.mergeClusters_(n,e)}else this.setClusterEventQNode_(e,t)}}this.m_modifiedClusters.length=0}getClusterXY(e){const t=this.getClusterFirstVertex(e);return this.m_shape.getXY(t)}getClusterFirstVertex(e){const t=this.getClusterVertices(e);return this.m_clusterVertices.getFirstElement(t)}dbgCheckEdge_(e){}dbgCheckCluster_(e){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(e){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new vn(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const e=[];let t=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=Ye.impossibleIndex2(),r=Ye.impossibleIndex3();for(let i=this.m_eventQ.getFirst();-1!==i;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;const o=this.m_eventQ.getElement(i);this.m_sweepPointCluster=this.getClusterFromVertex(o),this.m_shape.queryXY(o,this.m_sweepPoint),this.m_sweepComparator.setSweepY(this.m_sweepPoint.y,this.m_sweepPoint.x);let a=!1;{const t=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===t,!a){let s=t;do{const t=this.getEdgeSweepNode(s);-1===t?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r)):t!==r&&e.push(t),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==t)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),e.length>0){this.m_bContinuingSegmentChainOptimization=1===e.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let r=0,i=e.length;r<i;r++){const t=this.m_sweepStructure.getElement(e[r]);this.setEdgeSweepNode_(t,n)}let t=n,s=n;for(let r=0,i=e.length;r<i;r++){const i=e[r];if(t===n){const e=this.m_sweepStructure.getPrev(i);if(-1!==e){const s=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(s)!==n&&(t=e)}else t=-1}if(s===n){const e=this.m_sweepStructure.getNext(i);if(-1!==e){const t=this.m_sweepStructure.getElement(e);this.getEdgeSweepNode(t)!==n&&(s=e)}else s=-1}if(t!==n&&s!==n)break}for(let n=0,r=e.length;n<r;n++){const t=e[n],s=this.m_sweepStructure.getElement(t);this.m_sweepStructure.deleteNode(t),this.setEdgeSweepNode_(s,-1)}e.length=0,this.m_prevNeighbour=t,this.m_nextNeighbour=s,-1!==t&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(t,s):-1===t&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===t&&(t=new Nn(this)),t.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(t),t.intersectionDetected()&&(t.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,t.getCurrentNode())));const h=this.m_bContinuingSegmentChainOptimization;!this.insertNewEdges_()&&h&&-1!==this.m_prevNeighbour&&-1!==this.m_nextNeighbour&&this.checkAndFixIntersection_(this.m_prevNeighbour,this.m_nextNeighbour),this.m_bSweepPointClusterWasModified?(this.m_bSweepPointClusterWasModified=!1,null===s&&(s=new Gn(this.m_shape)),s.setPoint(this.m_sweepPoint),i=this.m_eventQ.searchUpperBound(s)):i=this.m_eventQ.getNext(i)}return this.m_bCracked}setEditShape_(e){this.m_shape=e,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(e.getSelectedCount()+32),this.m_clusters.setCapacity(e.getSelectedCount()),this.m_clusterVertices.reserveLists(e.getSelectedCount()),this.m_clusterVertices.reserveNodes(e.getSelectedCount()),this.m_edgeVertices.reserveLists(e.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(e.getSelectedCount()+32);for(let t=this.m_shape.getFirstGeometry();t!==q;t=this.m_shape.getNextGeometry(t)){if(h(this.m_shape.getGeometryType(t)))for(let s=this.m_shape.getFirstPath(t);s!==q;s=this.m_shape.getNextPath(s)){const t=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===q)continue;let r=this.m_shape.getNextVertex(n);if(r===q||r===n)continue;let i=-1;e.selected(n)&&(i=this.newCluster_(n));let o=-1;-1!==i&&e.selected(r)&&(o=this.newEdge_(n),this.addEdgeToCluster(o,i));let a=o;for(let e=0,s=t-2;e<s;e++){const e=this.m_shape.getNextVertex(r);let t=-1;if(this.m_shape.selected(r)){const s=this.newCluster_(r);-1!==a&&this.addEdgeToCluster(a,s),this.m_shape.selected(e)&&(t=this.newEdge_(r),this.addEdgeToCluster(t,s))}a=t,r=e}if(this.m_shape.isClosedPath(s)){const e=this.m_shape.getNextVertex(r);if(this.m_shape.selected(r)){const t=this.newCluster_(r);if(-1!==a&&this.addEdgeToCluster(a,t),this.m_shape.selected(e)){const e=this.newEdge_(r);this.addEdgeToCluster(e,t),this.addEdgeToCluster(e,i)}}}else{let e=-1;this.m_shape.selected(r)&&(e=this.newCluster_(r),-1!==a&&this.addEdgeToCluster(a,e))}}else for(let e=this.m_shape.getFirstPath(t);e!==q;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let s=0,n=this.m_shape.getPathSize(e);s<n;s++)this.m_shape.selected(t)&&this.newCluster_(t),t=this.m_shape.getNextVertex(t)}}this.fillEventQueue()}progress_(e=!1){}dbgCheckSweepStructure_(){}}function Vn(e,t,s,n){s>0&&mn(e,s,t,!1,n);new Hn(n).executeImpl_(e,t)}function Fn(e,t,s){return{vertex0:e,vertex1:t,dir:s}}class Hn{constructor(e){this.m_shape=null,this.m_spikes=[],this.m_points=new be(0),this.m_pointsIndex=-1,this.m_dissolvedEdges=0,this.m_progressTracker=e}executeImpl_(e,t){if(this.m_shape=e,e.getPathCount(t)<2&&e.getPointCount(t)<6)return;this.m_points.resize(0);for(let l=e.getFirstPath(t);l!==q;l=e.getNextPath(l)){let t=e.getFirstVertex(l);for(let s=0,n=e.getPathSize(l);s<n;s++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let l=0,g=this.m_points.size();l<g;++l)e.setUserIndex(this.m_points.read(l),this.m_pointsIndex,l);e.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const n=e.getXY(s);let r=1,i=0;const o=[];for(let l=1;l<this.m_points.size();l++){const t=this.m_points.read(l);if(t===q)continue;if(-1===e.getUserIndex(t,this.m_pointsIndex))continue;const a=e.getXY(t);if(a.isEqualPoint2D(n))r++;else{if(r>1){for(let t=i;t<l;t++){const s=this.m_points.read(t);if(-1===e.getUserIndex(s,this.m_pointsIndex))continue;const r=e.getNextVertex(s),i=e.getPrevVertex(s);if(s!==r&&!e.isEqualXYPoint2D(r,n)){const e=Fn(s,r,1);o.push(e)}if(s!==i&&i!==r&&!e.isEqualXYPoint2D(i,n)){const e=Fn(s,i,-1);o.push(e)}}o.length>0&&this.processBunch_(o,n)}s=t,n.assign(a),r=1,i=l}}if(0===this.m_dissolvedEdges)return e.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let a=e.getPointCount(t);for(let l=0;l<this.m_points.size();l++){const t=this.m_points.read(l);if(t===q)continue;if(-1!==e.getUserIndex(t,this.m_pointsIndex)){e.setUserIndex(t,this.m_pointsIndex,-1);continue}const s=e.getPathFromVertex(t);e.getFirstVertex(s)===t&&e.setFirstVertex(s,q),e.freeVertex(t),this.m_points.write(l,q),a--}const h=e.createPathUserIndex();let m=e.getPathCount(t);for(let g=0,u=this.m_points.size();g<u;++g){if(this.m_points.read(g)===q)continue;let s=this.m_points.read(g);if(-1!==e.getUserIndex(s,this.m_pointsIndex))continue;let n=e.getPathFromVertex(s),r=-1;if(2===e.getPathUserIndex(n,h)){n=q;for(let t=e.getNextVertex(s);t!==s;t=e.getNextVertex(t)){const r=e.getPathFromVertex(t);if(2!==e.getPathUserIndex(r,h)){n=r,s=t;break}}n===q&&(n=e.insertPath(t,q),e.setClosedPath(n,!0),m++),l(n!==q)}e.setPathUserIndex(n,h,2),r=e.getFirstVertex(n);let i=0,o=!1,a=s;do{r===a&&(o=!0),e.setUserIndex(a,this.m_pointsIndex,1);const t=e.getPathFromVertex(a);t!==n&&(2!==e.getPathUserIndex(t,h)&&(e.setPathUserIndex(t,h,1),e.setFirstVertex(t,q)),e.setPathToVertex(a,n)),i++,a=e.getNextVertex(a)}while(a!==s);o||e.setFirstVertex(n,s),e.setPathSize(n,i)}for(let l=e.getFirstPath(t);l!==q;){const t=e.getNextPath(l);1!==e.getPathUserIndex(l,h)&&e.getFirstVertex(l)!==q||(e.removePathOnly(l),m--),l=t}e.setGeometryVertexCount(t,a),e.setGeometryPathCount(t,m),e.removePathUserIndex(h),e.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,e.dbgVerifyVertexCounts(),e.filterClosePoints(0,!0,!1,!1,t)}processBunch_(e,t){e.sort((e,s)=>{const n=this.m_shape.getXY(e.vertex1).sub(t),r=this.m_shape.getXY(s.vertex1).sub(t),i=$e.compareVectors(n,r);return 0===i?e.dir<s.dir?-1:1:i});let s=0;const n=this.m_shape.getXY(e[0].vertex1);let r=1;const i=this.m_shape.hasCurves();for(let o=1,a=e.length;o<a;o++){const t=this.m_shape.getXY(e[o].vertex1);if(!(t.isEqualPoint2D(n)&&(r++,o+1<a))){if(2===r){const t=e[s],n=e[s+1],r=t.dir;if(r!==n.dir){let e=!0;if(i&&(e=!this.m_shape.isCurve(1===t.dir?t.vertex0:t.vertex1)&&!this.m_shape.isCurve(1===n.dir?n.vertex0:n.vertex1)),e){if(1===r){const e=t.vertex0,s=n.vertex0;this.m_shape.setNextVertex(e,s),this.m_shape.setPrevVertex(s,e),this.m_shape.getPrevVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setPrevVertex(r,i),this.m_shape.setNextVertex(i,r),this.m_shape.getNextVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}else{const e=t.vertex0,s=n.vertex0;this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(s,e),this.m_shape.getNextVertex(e)===s&&(this.m_shape.setUserIndex(e,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const r=t.vertex1,i=n.vertex1;this.m_shape.setNextVertex(r,i),this.m_shape.setPrevVertex(i,r),this.m_shape.getPrevVertex(r)===i&&(this.m_shape.setUserIndex(r,this.m_pointsIndex,-1),this.m_shape.setUserIndex(i,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}n.assign(t),s=o,r=1}}e.length=0}}function kn(e){for(let t=e.getFirstGeometry();t!==q;t=e.getNextGeometry(t))if(h(e.getGeometryType(t)))return!0;return!1}function An(e,t,s,n){if(!kn(e))return!1;const r=new Bn(n);r.m_shape=e,r.m_tolerance=t,r.m_bTrackChanges=s;let i=!1;const o=e.hasCurves()?5:15;return i=e.getTotalPointCount()<o?r.crackBruteForce_():r.crackerPlaneSweep_(),i}function Mn(e,t,s,n,r){if(!kn(t))return!1;let i=new Bn(r);if(i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n,i.needsCrackingImpl_())return n&&n.assign(i.m_nonSimpleResult),!0;const o=new jt;o.setSwapCoordinates(),t.applyTransformation(o),i=new Bn(r),i.m_shape=t,i.m_tolerance=s,i.m_bAllowCoincident=e,i.m_bNeedsNonSimpleResult=null!==n;const a=i.needsCrackingImpl_();return t.applyTransformation(o),!!a&&(n&&n.assign(i.m_nonSimpleResult),!0)}function Un(e,t,s,n){const r=t.getGeometryType();if(h(r)){return new Bn(n).crackAWithBMultiPath_(e,t,s)}d("crack_A_with_B")}function qn(e,t){return{t:e,index:t}}class Bn{crackBruteForce_(){let e=this.crackBruteForceImpl_();if(!e&&this.m_shape.hasCurves()){const t=new jt;t.setSwapCoordinates(),this.m_shape.applyTransformation(t),e=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(t)}return e}crackBruteForceImpl_(){let e=!1;const t=new k,n=new k,r=s.constructEmpty(),i=s.constructEmpty(),o=!1,a=new ye,h=new xn,m=this.m_shape.getTotalPointCount(),g=m*m*2,u=this.m_shape.queryVertexIteratorOnSelection();for(let s=u.next();s!==q;s=u.next()){const m=this.m_shape.getGeometryType(u.currentGeometry());let c=1,d=1,p=1,f=0,x=0,y=0;const P=this.m_shape.getSegmentParentage(s);let E=!1,S=!1,C=null,I=!1;if(_(m))c=this.m_shape.getWeight(s),f=this.m_shape.getRank(s);else{if(C=this.getSegment_(s,t),null===C)continue;const e=this.m_shape.getVertexIndex(s);c=this.m_shape.getWeightWithIndex(e),f=this.m_shape.getRankWithIndex(e),p=this.m_shape.getSegmentWeightWithIndex(e),y=this.m_shape.getSegmentRankWithIndex(e),E=this.m_shape.getSegmentParentageBreakVertex(s);{const e=this.m_shape.getNextVertex(s);d=this.m_shape.getWeight(e),x=this.m_shape.getRank(e),S=this.m_shape.getSegmentParentageBreakVertex(e)}if(C.queryLooseEnvelope(r),r.inflateCoords(this.m_tolerance,this.m_tolerance),C.isDegenerate(this.m_tolerance)){if(!C.isDegenerate(0))continue;I=!0,C=null}}const b=new Z({copy:u});let w=b.next();w!==q&&(w=b.next());let v=0;for(;w!==q;w=b.next()){if(0!==v){v--;continue}if(this.m_shape.getTotalPointCount()>g)return e;this.progress_();const m=this.m_shape.getGeometryType(b.currentGeometry());let N=null,T=!1,G=0,D=0,V=0,F=0,H=0,k=0,A=!1,M=!1;const U=this.m_shape.getSegmentParentage(w);if(_(m))G=this.m_shape.getWeight(w),F=this.m_shape.getRank(w);else{if(N=this.getSegment_(w,n),null===N)continue;const e=this.m_shape.getVertexIndex(w);G=this.m_shape.getWeightWithIndex(e),F=this.m_shape.getRankWithIndex(e),V=this.m_shape.getSegmentWeightWithIndex(e),k=this.m_shape.getSegmentRankWithIndex(e),A=this.m_shape.getSegmentParentageBreakVertex(w);{const e=this.m_shape.getNextVertex(w);D=this.m_shape.getWeight(e),H=this.m_shape.getRank(e),M=this.m_shape.getSegmentParentageBreakVertex(e)}if(N.queryLooseEnvelope(i),N.isDegenerate(this.m_tolerance)){if(!N.isDegenerate(0))continue;T=!0,N=null}}let B=0,O=0;if(null!==C&&null!==N){if(r.isIntersectingNe(i)){0!==K(!0,!0,C,N,this.m_tolerance,!0)&&(h.pushSegment(C,c,f,d,x,p,y,E,S,P),h.pushSegment(N,G,F,D,H,V,k,A,M,U),h.intersect2D(this.m_tolerance,!0),e||=h.getSegmentChanged(0)||h.getSegmentChanged(1),B=h.getResultSegmentCount(0),O=h.getResultSegmentCount(1),B+O>0&&(this.m_shape.splitSegmentWithIntersector(s,h,0,!0,!0),this.m_shape.splitSegmentWithIntersector(w,h,1,!0,!0),this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0))),O>1&&(v+=O-1),h.clear())}}else if(null!==C){const t=this.m_shape.getXY(w);if(r.contains(t)){if(h.pushSegment(C,c,f,d,x,p,y,E,S,P),this.m_shape.queryPoint(w,a),h.intersect2DEx(this.m_tolerance,a,F,G,o),e||=h.getSegmentChanged(0)||h.getResultPointChanged(),B=h.getResultSegmentCount(0),B>0)if(this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(s,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0)),this.m_shape.splitSegmentWithIntersector(s,h,0,!0,!0),T){let e=q;for(let t=this.m_shape.getNextVertex(w);t!==q&&t!==w&&(N=this.getSegment_(t,n),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=w;t!==q&&(this.m_shape.setPoint(t,h.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(w,h.getResultPoint(),!0);h.clear()}}else{if(null===N)continue;{const t=this.m_shape.getXY(s);if(i.inflateCoords(this.m_tolerance,this.m_tolerance),i.contains(t)){if(h.pushSegment(N,G,F,D,H,V,k,A,M,U),this.m_shape.queryPoint(s,a),h.intersect2DEx(this.m_tolerance,a,f,c,o),e||=h.getSegmentChanged(0)||h.getResultPointChanged(),O=h.getResultSegmentCount(0),O>0)if(this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(w,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(s,!0)),this.m_shape.splitSegmentWithIntersector(w,h,0,!0,!0),v+=O-1,I){let e=q;for(let t=this.m_shape.getNextVertex(s);t!==q&&t!==s&&(N=this.getSegment_(t,n),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=s;t!==q&&(this.m_shape.setPoint(t,h.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(s,h.getResultPoint(),!0);h.clear()}}}if(B+O!==0&&0!==B){let e=!1;for(;C=this.getSegment_(s,t),null!=C&&(C.queryEnvelope(r),C.isDegenerate(this.m_tolerance));){if(!(B>1)){e=!0;break}s=u.next(),B--,l(s!==q)}if(e)break}}}return e}crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Dn(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let e=!1;const t=new be(0);t.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let a=0,g=s.next();g!==q;++a,g=s.next())t.write(a,g);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(q);const n=this.m_shape.createUserIndex(),r=this.m_shape.createUserIndex();this.m_sweepComparator=new on(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let i=null;const o=[],h=[];let m=0;const l=new $e;for(let g=t.read(m++);g!==q;){this.m_shape.queryXY(g,l);let s=!1;do{let e=this.m_shape.getNextVertex(g),i=this.m_shape.getPrevVertex(g);s||=e!==q||i!==q,e===q||this.m_shape.selected(e)||(e=q),i===q||this.m_shape.selected(i)||(i=q),e!==q&&this.m_shape.compareVerticesSimpleY(g,e)<0&&(h.push(g),h.push(e)),i!==q&&this.m_shape.compareVerticesSimpleY(g,i)<0&&(h.push(i),h.push(i));const a=this.m_shape.getUserIndex(g,n);-1!==a&&(o.push(a),this.m_shape.setUserIndex(g,n,-1));const l=this.m_shape.getUserIndex(g,r);-1!==l&&(o.push(l),this.m_shape.setUserIndex(g,r,-1)),g=t.read(m++)}while(g!==q&&this.m_shape.isEqualXYPoint2D(g,l));if(!s&&(null===i&&(i=new an(this.m_shape,this.m_tolerance)),i.setPoint(l),this.m_sweepStructure.searchUpperBound(i),i.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&(a("needsCrackingIMpl_"),this.m_nonSimpleResult=new ts(6,-1,-1));break}let u=1===o.length&&2===h.length;const c=32;o.length>c&&tt(o);let _=-1,d=-1;if(!u)for(let t=0,n=o.length;t<n;t++){const s=o[t],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===o.indexOf(n))if(-1===_)_=n;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new ts(6,-1,-1)}const r=this.m_sweepStructure.getNext(s);if(-1!==r&&-1===o.indexOf(r))if(-1===d)d=r;else{if(e=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new ts(6,-1,-1)}if(-1!==_&&-1!==d)break}if(e&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(l.y,l.x),!u){for(let e=0,t=o.length;e<t;e++){const t=o[e];this.m_sweepStructure.deleteNode(t)}o.length=0}if(!u&&-1!==_&&-1!==d&&this.checkForIntersections_(_,d)){e=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let t=0,i=h.length;t<i;t+=2){const s=h[t],i=h[t+1];let a;if(u?(a=this.m_sweepStructure.replaceElementAtPosition(o[0],s,!0,!0),o.length=0,u=!1):a=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),e=!0;break}-1===this.m_shape.getUserIndex(i,n)?this.m_shape.setUserIndex(i,n,a):this.m_shape.setUserIndex(i,r,a)}if(e)break;h.length=0}return this.m_shape.removeUserIndex(n),this.m_shape.removeUserIndex(r),e}checkForIntersections_(e,t){const s=this.m_sweepStructure.getElement(e);this.m_sweepComparator.compare(this.m_sweepStructure,s,t);const n=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),n}getSegment_(e,t){return Bn.st_getSegment(this.m_shape,e,t)}static st_getSegment(e,t,s){return e.querySegment(t,s,!1,!1)?s.get():null}dbgPrintSweepEdge(e){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(e=null){}dbgCheckSweepStructure(){}progress_(e=!1){this.m_progressCounter++}crackAWithBMultiPath_(e,t,n){const r=s.constructEmpty();e.queryLooseEnvelope(r);const o=s.constructEmpty();if(t.queryLooseEnvelope(o),o.inflateCoords(n,n),!o.isIntersecting(r))return e;const a=e.getImpl(),h=a.getAccelerators();let m=null,g=null;h&&(g=h.getQuadTree()),On(e,u(t))&&(m=He(a,o),g=m);const c=g?g.getIteratorForQT():null,_=t.querySegmentIterator(),d=e.querySegmentIterator(),p=Je(15,Number.NaN),f=[];for(;_.nextPath();)for(;_.hasNextSegment();){const e=_.nextSegment();if(g){c.resetIterator(e,n);for(let t=c.next();-1!==t;t=c.next()){this.progress_();const s=g.getElement(t);if(d.resetToVertex(s,-1),d.hasNextSegment()){const t=d.nextSegment().intersect(e,null,p,null,n);for(let e=0;e<t;e++){const t=p[e];if(0===t||1===t)continue;const s=qn(t,d.getStartPointIndex());f.push(s)}}}}else{const t=s.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(n,n),!r.isIntersecting(t))continue;for(d.resetToFirstPath();d.nextPath();)for(;d.hasNextSegment();){const r=d.nextSegment(),i=s.constructEmpty();if(r.queryLooseEnvelope(i),!i.isIntersecting(t))continue;const o=r.intersect(e,null,p,null,n);for(let e=0;e<o;e++){const t=p[e];if(0===t||1===t)continue;const s=qn(t,d.getStartPointIndex());f.push(s)}}}}if(0===f.length)return e;f.sort((e,t)=>e.index<t.index?-1:e.index>t.index?1:e.t<t.t?-1:e.t>t.t?1:0);const x=e.createInstance();if(x.getGeometryType()===i.enumPolygon){x.setFillRule(e.getFillRule())}for(d.resetToFirstPath();d.nextPath()&&!d.hasNextSegment(););l(d.hasNextSegment());let y=d.nextSegment();const P=new k;let E=-1;for(let s=0,i=f.length;s<i;){const e=f[s].index;let t=s+1;for(;t<i&&f[t].index===e;)++t;for(;d.getStartPointIndex()<e;){this.progress_();const e=d.hasNextSegment(),t=d.getPathIndex();if((e||!d.isClosingSegment()||d.isCurve())&&(l(null!==y),x.addSegment(y,E!==t)),E=t,!e){for(d.isPathClosed();d.nextPath()&&!d.hasNextSegment(););l(d.hasNextSegment())}y=d.nextSegment()}let n=0;for(let i=s;i<t;i++){const e=f[i].t;if(e===n)continue;l(null!==y),y.queryCut(n,e,P),n=e;const t=d.getPathIndex();x.addSegment(P.get(),E!==t),E=t}const r=d.hasNextSegment();if((r||!d.isClosingSegment()||d.isCurve())&&(l(null!=y),y.queryCut(n,1,P),x.addSegment(P.get(),!1)),r)y=d.nextSegment();else{for(;d.nextPath()&&!d.hasNextSegment(););y=d.hasNextSegment()?d.nextSegment():null}s=t}if(null!==y){const e=d.getPathIndex();(d.hasNextSegment()||!d.isClosingSegment()||d.isCurve())&&x.addSegment(y,E!==e),E=e}let S=d.hasNextSegment();for(;;){if(!S){for(;d.nextPath()&&(S=d.hasNextSegment(),!S););if(!S)break}y=d.nextSegment();const e=d.getPathIndex();S=d.hasNextSegment();(S||!d.isClosingSegment()||d.isCurve())&&x.addSegment(y,E!==e),E=e}return x}constructor(e){this.m_shape=null,this.m_progressTracker=null,this.m_nonSimpleResult=new ts,this.m_tolerance=0,this.m_sweepComparator=null,this.m_progressCounter=0,this.m_bTrackChanges=!1,this.m_bNeedsNonSimpleResult=!1,this.m_bAllowCoincident=!0,this.m_sweepStructure=new Ce,this.m_progressTracker=e}}function On(e,t){const s=e.getPointCount();if(s<16)return!1;const n=1;return 2*s+1*(Math.log(s)/Math.log(2))*t<n*s*t}Bn.s_bForceBruteForce=!0;class Yn{constructor(e,t){this.m_monotoneParts=ut(k,16),this.m_xOrds=Je(16,Number.NaN),this.m_inputPoint=$e.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=e,this.m_tolerance=t,this.m_toleranceSqr=t*t,this.m_bTestBorder=t>0,this.m_bBreak=!1}_DoOne(e){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(e.getStartXY())||this.m_inputPoint.equals(e.getEndXY())))return void(this.m_bBreak=!0);if(e.getStartY()===this.m_inputPoint.y&&e.getStartY()===e.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const t=Math.min(e.getStartX(),e.getEndX()),s=Math.max(e.getStartX(),e.getEndX());this.m_inputPoint.x>t&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let t=!1;const s=Math.max(e.getStartX(),e.getEndX());if(this.m_inputPoint.x>s)t=!0;else if(this.m_inputPoint.x>=Math.min(e.getStartX(),e.getEndX())){const n=e.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);t=!Number.isNaN(n)&&n<=this.m_inputPoint.x}if(t){if(this.m_inputPoint.y===e.getStartY()){if(this.m_inputPoint.y<e.getEndY())return}else if(this.m_inputPoint.y===e.getEndY()&&this.m_inputPoint.y<e.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=e.getStartY()>e.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(e){const t=e.getClosestCoordinate(this.m_inputPoint,!1),s=e.getCoord2D(t);return $e.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(e){this.m_inputPoint.setCoordsPoint2D(e),this.m_miny=e.y-this.m_tolerance,this.m_maxy=e.y+this.m_tolerance}processSegment(e){const t=e.queryInterval(0,1);if(t.vmin>this.m_maxy||t.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(e))return!0;if(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)return!1;let s=0;if(e.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=e.getMonotonicParts(this.m_monotoneParts,!0),l(this.m_monotoneParts.length>=s)),s>0)for(let n=0;n<s;n++){const e=this.m_monotoneParts[n].get(),t=lt.construct(e.getStartY(),e.getEndY());if(!(t.vmin>this.m_inputPoint.y||t.vmax<this.m_inputPoint.y)&&(this._DoOne(e),this.m_bBreak))return!0}else if(this._DoOne(e),this.m_bBreak)return!0;return!1}result(){return l(0),2}}function Rn(e,t,n,r){const i=new s;e.queryLooseEnvelope(i),i.inflateCoords(r,r);const o=0===e.getFillRule(),a=new Yn(o,r);a.setInputPoint(n);const h=i.clone();h.xmax=n.x+r,h.ymin=n.y-r,h.ymax=n.y+r;const m=e.getImpl().querySegmentIterator(),l=t.getIterator(h,r);for(let s=l.next();-1!==s;s=l.next())if(m.resetToVertex(t.getElement(s),-1),m.hasNextSegment()){const e=m.nextSegment();if(a.processSegment(e))return-1}return a._Result()?1:0}function Xn(e,t,s){const n=0===e.getFillRule(),r=new Yn(n,s);r.setInputPoint(t);const i=e.getImpl().querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(r.processSegment(e))return-1}return r._Result()?1:0}function Ln(e,t,s){return t.isEmpty()?0:zn(e,t.getXY(),s)}function zn(e,t,n){if(e.isEmpty())return 0;const r=s.constructEmpty();if(e.queryLooseEnvelope(r),r.inflateCoords(n,n),!r.contains(t))return 0;const i=e.getImpl().getAccelerators();if(i){i.getRasterizedGeometry()&&l(0);const s=i.getQuadTree();if(s)return Rn(e,s,t,n)}return Xn(e,t,n)}function Wn(e,t){const s=e.getPointCount();if(s<16)return!1;const n=1;return 2*s+1*(Math.log(s)/Math.log(2))*t<n*s*t}function jn(e,t,s,n,r){const i=new $n(r);return i.m_shape=e,i.m_geometry=t,i.m_sortedVertices=s,i.m_bFixSelfTangency=n,i.fixRingOrientation_()}function Zn(e,t,s){const n=new $n(s);return n.m_shape=e,n.m_geometry=t,n.m_sortedVertices=null,n.m_bFixSelfTangency=!1,n.fixRingOrientationForMp2sp_()}class Kn{getDirection_(e){return this.m_shape.getNextVertex(this.getEnd1(e))===this.getEnd2(e)}getEnd_(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?s:t}constructor(e){this.m_end1Nodes=[],this.m_end2Nodes=[],this.m_directions=[],this.m_shape=e,this.m_firstFree=-1}getSegment(e){return this.m_shape.getSegment(this.getStart(e))}isBottomUp(e){let t=this.getEnd1(e),s=this.getEnd2(e);this.m_shape.getPrevVertex(t)===s&&(s=ot(t,t=s));const n=$e.getNAN(),r=$e.getNAN();return this.m_shape.queryXY(t,n),this.m_shape.queryXY(s,r),l(!n.equals(r)),n.y<r.y}getStart(e){const t=this.getEnd1(e),s=this.getEnd2(e);return this.m_shape.getNextVertex(t)===s?t:s}getEnd1(e){return this.m_end1Nodes[e]}getEnd2(e){return this.m_end2Nodes[e]}freeEdge(e){this.m_end1Nodes[e]=this.m_firstFree,this.m_firstFree=e}newEdge(e){if(-1!==this.m_firstFree){const t=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[t],this.m_end1Nodes[t]=e,this.m_end2Nodes[t]=this.m_shape.getNextVertex(e),t}const t=this.m_end1Nodes.length;return this.m_end1Nodes.push(e),this.m_end2Nodes.push(this.m_shape.getNextVertex(e)),t}getShape(){return this.m_shape}getPath(e){return this.m_shape.getPathFromVertex(this.getEnd1(e))}}let Qn=class extends Xe{constructor(e){super(),this.m_line1=new A,this.m_line2=new A,this.m_leftElm=-1,this.m_leftx=0,this.m_seg1=null,this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges;let i;if(this.m_leftElm===t)i=this.m_leftx;else{if(this.m_seg1=r.getSegment(t),this.m_seg1)i=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);else{r.getShape().queryLineConnector(r.getStart(t),this.m_line1,!0),this.m_seg1=this.m_line1,i=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)}this.m_leftx=i,this.m_leftElm=t}let o,a=r.getSegment(n);if(a)o=a.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);else{r.getShape().queryLineConnector(r.getStart(n),this.m_line2,!0),a=this.m_line2,o=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)}if(i===o){const e=r.isBottomUp(t),s=r.isBottomUp(n),h=e?this.m_seg1.getEndY():this.m_seg1.getStartY(),m=s?a.getEndY():a.getStartY(),l=Math.min(h,m);let g=.5*(l+this.m_helper.m_yScanline);g===this.m_helper.m_yScanline&&(g=l),i=this.m_seg1.intersectionOfYMonotonicWithAxisX(g,0),o=a.intersectionOfYMonotonicWithAxisX(g,0),i===o&&S("")}return i<o?-1:i>o?1:0}reset(){this.m_leftElm=-1}};class Jn{constructor(e){this.m_node=-1,this.m_index=0,this.m_sortedVertices=e.m_sortedVertices,this.m_sortedVerticesArray=e.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){const e=this.m_node;if(-1===e)return q;const t=this.m_sortedVertices.getData(e);return this.m_node=this.m_sortedVertices.getNext(e),t}if(this.m_index<this.m_sortedVerticesArray.size()){const e=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,e}return q}}class $n{constructor(e){this.m_edges=null,this.m_shape=null,this.m_AET=new Ce,this.m_yScanline=0,this.m_geometry=q,this.m_unknownRingOrientationCount=-1,this.m_sortedVertices=null,this.m_sortedVerticesArray=null,this.m_unknownNodes=[],this.m_node1UserIndex=-1,this.m_node2UserIndex=-1,this.m_pathOrientationIndex=-1,this.m_pathParentageIndex=-1,this.m_pathParentsIndex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_progressTracker=e,this.m_AET.disableBalancing(),this.m_sweepComparator=new Qn(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){const e=this.fixRingOrientationImplMain_();return-1===this.m_pathOrientationIndex||this.fixRingOrientationImplSimplify_(),e}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),-1===this.m_pathOrientationIndex?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(e){return this.processBunchForRingOrientationTestOddEven_(e)}processBunchForRingOrientationTestOddEven_(e){let t=!1;if(this.m_edges||(this.m_edges=new Kn(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(e),!this.m_AET.isAutoBalancing()){let t=0;for(let s=0,n=e.length;s<n;s++){-1!==e[s]&&t++}(t>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let s=0,n=e.length;s<n;s++){const t=e[s];t!==q&&this.insertEdge_(t,-1)}for(let s=0;s<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;s++){const e=this.m_unknownNodes[s],n=this.m_AET.getElement(e),r=this.m_edges.getPath(n),i=this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex);let o=q;if(0===i){let s=this.m_AET.getPrev(e),n=e,r=!1;for(;s!==Ce.st_nullNode();){const e=this.m_AET.getElement(s),t=this.m_edges.getPath(e);if(0!==this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){o=t;break}n=s,s=this.m_AET.getPrev(s)}if(s===Ce.st_nullNode())r=!0,s=n;else{const e=this.m_AET.getElement(s);r=this.m_edges.isBottomUp(e),s=this.m_AET.getNext(s),r=!r}do{const e=this.m_AET.getElement(s),i=this.m_edges.getPath(e);if(0===this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)){if(r!==this.m_edges.isBottomUp(e)){const e=this.m_shape.getFirstVertex(i);this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(i,this.m_shape.getPrevVertex(e)),t=!0}if(this.m_shape.setPathUserIndex(i,this.m_pathOrientationIndex,r?3:2),!r){let e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex);2===e?(o=this.m_shape.getPathUserIndex(o,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex),l(3===e)):l(3===e);const t=this.m_shape.getPathUserIndex(o,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,i),this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(i,this.m_pathParentsIndex,o)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}o=i,n=s,s=this.m_AET.getNext(s),r=!r}while(n!==e)}}return t}processBunchForRingOrientationRemoveEdges_(e){for(let t=0,s=e.length;t<s;t++){const s=e[t],n=this.m_shape.getUserIndex(s,this.m_node1UserIndex),r=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==n){const e=this.m_AET.getElement(n);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==r){const e=this.m_AET.getElement(r);this.m_edges.freeEdge(e),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let i=-1;-1!==n&&-1!==r?(this.m_AET.deleteNode(n),this.m_AET.deleteNode(r),e[t]=q):i=-1!==n?n:r,-1!==i&&(this.insertEdge_(s,i)||this.m_AET.deleteNode(i),e[t]=q)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){const s=$e.getNAN(),n=$e.getNAN();this.m_shape.queryXY(e,s);const r=this.m_shape.getNextVertex(e);this.m_shape.queryXY(r,n);let i=!1;if(s.y<n.y){i=!0;const s=this.m_edges.newEdge(e);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s));-1===this.m_shape.getUserIndex(r,this.m_node1UserIndex)?this.m_shape.setUserIndex(r,this.m_node1UserIndex,n):this.m_shape.setUserIndex(r,this.m_node2UserIndex,n);const o=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}const o=this.m_shape.getPrevVertex(e);if(this.m_shape.queryXY(o,n),s.y<n.y){i=!0;const s=this.m_edges.newEdge(o);let n;-1===t?n=this.m_AET.addElement(s):(n=t,this.m_AET.setElement(n,s));-1===this.m_shape.getUserIndex(o,this.m_node1UserIndex)?this.m_shape.setUserIndex(o,this.m_node1UserIndex,n):this.m_shape.setUserIndex(o,this.m_node2UserIndex,n);const r=this.m_shape.getPathFromVertex(e);0===this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(n)}return i}fixRingSelfTangency_(){const e=[],t=[];let s=-1,n=-1;const r=new $e;let i=q,o=q,a=-1;const h=new Jn(this);for(let m=h.next();m!==q;m=h.next()){const h=new $e;this.m_shape.queryXY(m,h);const l=this.m_shape.getPathFromVertex(m);if(r.equals(h)&&o===l){if(-1===n&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),n=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,n,-1)),-1===a){a=t.length,this.m_shape.setUserIndex(i,n,a),t.push(1);-1===this.m_shape.getPathUserIndex(l,s)&&(this.m_shape.setPathUserIndex(l,s,i),e.push(l))}this.m_shape.setUserIndex(m,n,a),t[t.length-1]++}else a=-1,r.assign(h);i=m,o=l}if(0===e.length)return!1;l(-1!==s);for(let m=0,l=e.length;m<l;m++){const r=e[m];let i=this.m_shape.getPathUserIndex(r,s);const o=this.m_shape.getUserIndex(i,n),a=[],h=[];a.push(i),h.push(o);for(let e=this.m_shape.getNextVertex(i);e!==i;e=this.m_shape.getNextVertex(e)){const s=e,r=this.m_shape.getUserIndex(s,n);if(-1!==r){if(0===h.length){h.push(r),a.push(s);continue}if(h.at(-1)===r){const o=a.at(-1);this.m_shape.peelALoopIntoAPath(o,s),this.m_shape.setUserIndex(e,n,-1),t[r]--,1===t[r]&&(t[r]=0,h.pop(),a.pop()),i=o,e=o}else a.push(e),h.push(r)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(n),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){const s={stack:[],error:void 0,hasError:!1};try{let t,n=!1;const r=e(s,Gt(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const e=this.m_shape.getPointCount(this.m_geometry);t=new be(0);for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==q;s=this.m_shape.getNextPath(s)){let e=this.m_shape.getFirstVertex(s);for(let n=0,r=this.m_shape.getPathSize(s);n<r;n++)t.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(t,0,e),this.progress_(!0),this.m_sortedVerticesArray=t}else r.bForget=!0;if(this.m_bFixSelfTangency&&(n=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const e=this.m_shape.getFirstPath(this.m_geometry),t=this.m_shape.getRingArea(e);if(this.m_shape.setExterior(e,!0),t<0){const t=this.m_shape.getFirstVertex(e);return this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(e,this.m_shape.getPrevVertex(t)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==q;e=this.m_shape.getNextPath(e))this.m_shape.setPathUserIndex(e,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(e,this.m_pathParentsIndex,-1);const i=[];this.m_yScanline=Number.NaN;const o=$e.getNAN();this.m_unknownRingOrientationCount=this.m_shape.getPathCount(this.m_geometry),this.m_node1UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node1UserIndex,-1),this.m_node2UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node2UserIndex,-1);const a=new Jn(this);for(let e=a.next();e!==q&&(this.progress_(),this.m_shape.queryXY(e,o),o.y!==this.m_yScanline&&i.length&&(n=this.processBunchForRingOrientationTest_(i)||n,this.m_sweepComparator.reset(),i.length=0),i.push(e),this.m_yScanline=o.y,0!==this.m_unknownRingOrientationCount);e=a.next());return this.m_unknownRingOrientationCount>0&&(n=this.processBunchForRingOrientationTest_(i)||n,i.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),n}catch(n){s.error=n,s.hasError=!0}finally{t(s)}}fixRingOrientationImplSimplify_(){const e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==q;)if(this.progress_(),3===this.m_shape.getPathUserIndex(t,this.m_pathOrientationIndex)){this.m_shape.setExterior(t,!0);for(let r=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);r!==q;){const s=this.m_shape.getPathUserIndex(r,this.m_pathParentageIndex);e.push(r),this.m_shape.setExterior(r,!1),this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,t),r=s}let s=t,n=e.length;for(let e=this.m_shape.getNextPath(t);n>0&&e!==q;e=this.m_shape.getNextPath(e),--n){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==t){s=q;break}s=e}if(0!==n){s=t;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,je),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),n),s=n}}e.length=0,t=this.m_shape.getNextPath(s)}else t=this.m_shape.getNextPath(t);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const e=this.m_shape.createPathUserIndex();let t=0;const s=[];for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==q;)if(this.progress_(),3===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)){this.m_shape.setExterior(n,!0),this.m_shape.setPathUserIndex(n,e,t),t++;for(let e=this.m_shape.getPathUserIndex(n,this.m_pathParentageIndex);e!==q;){const t=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s.push(e),this.m_shape.setExterior(e,!1),this.m_shape.setPathUserIndex(e,this.m_pathParentageIndex,n),e=t}let r=n,i=s.length,o=t;for(let t=this.m_shape.getNextPath(n);i>0&&t!==q;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==n){r=q;break}r=t,this.m_shape.setPathUserIndex(t,e,-o),o++}if(0!==i){r=n,o=t;for(let t=0,n=s.length;t<n;t++){const n=s[t];this.m_shape.setPathUserIndex(n,e,-o),o++,this.m_shape.setPathUserIndex(n,this.m_pathParentageIndex,je)}r=n}t=o,s.length=0,n=this.m_shape.getNextPath(r)}else n=this.m_shape.getNextPath(n);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),e}}function er(e,t,s,n,r,i){const o=new tr(i);return o.m_shape=e,o.m_geometry=t,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=n,o.m_polylineDegeneracies=r,o.m_bHasSegmentParentage=e.hasSegmentParentage(),o.m_bHasSegments=e.hasCurves(),o.simplify_()}class tr{constructor(e){this.m_shape=null,this.m_geometry=q,this.m_sortedVertices=new Se,this.m_bunchEdgeEndPoints=[],this.m_bunchEdgeCenterPoints=[],this.m_bunchEdgeIndices=[],this.m_sorterSegmentBuffer1=null,this.m_sorterSegmentBuffer2=null,this.m_knownSimpleResult=-1,this.m_sortedVerticesListIndex=-1,this.m_polylineDegeneracies=q,this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_bHasSegmentParentage=!1,this.m_bHasSegments=!1,this.m_progressTracker=e}compareAngles_(e,t){return this.m_bHasSegments?this.compareAnglesCurves_(e,t):this.compareAnglesLines_(e,t)}compareAnglesLines_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=new $e;this.m_shape.queryXY(s,n);const r=new $e,i=this.m_bunchEdgeEndPoints[t];if(this.m_shape.queryXY(i,r),n.equals(r))return 0;const o=this.m_bunchEdgeCenterPoints[e],a=new $e;this.m_shape.queryXY(o,a);const h=this.m_bunchEdgeCenterPoints[t],m=new $e;this.m_shape.queryXY(h,m);const l=new $e;l.setSub(n,a);const g=new $e;g.setSub(r,m),(l.isZero()||g.isZero())&&S("");return $e.compareVectors(l,g)}compareAnglesCurves_(e,t){const s=this.m_bunchEdgeEndPoints[e],n=this.m_bunchEdgeEndPoints[t],r=this.m_bunchEdgeCenterPoints[e],i=this.m_bunchEdgeCenterPoints[t],o=this.m_shape.getNextVertex(r)===s,a=this.m_shape.getNextVertex(i)===n,h=o?this.m_shape.isCurve(r):this.m_shape.isCurve(s),m=a?this.m_shape.isCurve(i):this.m_shape.isCurve(n);if(!h&&!m)return this.compareAnglesLines_(e,t);this.m_sorterSegmentBuffer1||(this.m_sorterSegmentBuffer1=new k),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new k),o?this.m_shape.querySegment(r,this.m_sorterSegmentBuffer1,!1,!0):(this.m_shape.querySegment(s,this.m_sorterSegmentBuffer1,!1,!0),this.m_sorterSegmentBuffer1.get().reverse()),a?this.m_shape.querySegment(i,this.m_sorterSegmentBuffer2,!1,!0):(this.m_shape.querySegment(n,this.m_sorterSegmentBuffer2,!1,!0),this.m_sorterSegmentBuffer2.get().reverse());return O(this.m_sorterSegmentBuffer1.get(),this.m_sorterSegmentBuffer2.get())}beforeRemoveVertex_(e,t){const s=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===s&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===s&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,s),this.removeAngleSortInfo_(e),t){const t=this.m_shape.getPathFromVertex(e);if(t!==q){if(this.m_shape.getFirstVertex(t)===e){const s=this.m_shape.getNextVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s);{const s=this.m_shape.getPrevVertex(e);if(s!==e){if(this.m_shape.getPathFromVertex(s)===t)return void this.m_shape.setFirstVertex(t,s)}}}this.m_shape.setFirstVertex(t,q),this.m_shape.setLastVertex(t,q)}}}}processBunch_(){let e=!1;const t=new $e(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let s=this.m_firstCoincidentVertex,n=0,r=!0;for(;s!==this.m_nextVertexToProcess;){const e=this.m_sortedVertices.getData(s);r&&(this.m_shape.queryXY(e,t),r=!1);const i=this.m_shape.getPrevVertex(e),o=this.m_shape.getNextVertex(e);this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex)!==je&&(this.m_bunchEdgeEndPoints.push(i),this.m_shape.setUserIndex(i,this.m_userIndexSortedAngleIndexToVertex,je),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++));this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==je&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,je),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++)),s=this.m_sortedVertices.getNext(s)}if(this.m_bunchEdgeEndPoints.length<2){1===this.m_bunchEdgeEndPoints.length&&this.m_shape.setUserIndex(this.m_bunchEdgeEndPoints[0],this.m_userIndexSortedAngleIndexToVertex,-1);break}this.m_bunchEdgeIndices.sort((e,t)=>this.compareAngles_(e,t));for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e],s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,e)}const i=this.processCrossOvers_(t);for(let e=0,t=this.m_bunchEdgeIndices.length;e<t;e++){const t=this.m_bunchEdgeIndices[e];if(-1===t)continue;const s=this.m_bunchEdgeEndPoints[t];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!i)break;e=!0}return e}processCrossOvers_(e){let t=!1,s=!0;for(;s;){s=!1;let n=0;-1===this.m_bunchEdgeIndices[n]&&(n=this.getNextEdgeIndex_(n));let r=this.getNextEdgeIndex_(n);for(let i=0,o=this.m_bunchEdgeIndices.length;i<o&&-1!==n&&-1!==r&&n!==r;i++){const i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeIndices[r],a=this.m_bunchEdgeEndPoints[i],h=this.m_bunchEdgeEndPoints[o];let m=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a),l=!0);let g=this.m_shape.getNextVertex(h),u=!1;this.m_shape.isEqualXYPoint2D(g,e)||(g=this.m_shape.getPrevVertex(h),u=!0);const c=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=u?this.m_shape.getPrevVertex(g):this.m_shape.getNextVertex(g);let d=!1;(this.removeSpike_(m)||this.removeSpike_(g)||this.removeSpike_(a)||this.removeSpike_(h)||this.removeSpike_(c)||this.removeSpike_(_))&&(d=!0),m!==g&&(!d&&this.m_shape.isEqualXY(a,h)&&(d=this.resolveOverlap_(l,u,m,a,g,h)),!d&&this.m_shape.isEqualXY(c,_)&&(d=this.resolveOverlap_(!l,!u,m,c,g,_)),!d&&this.m_shape.isEqualXY(a,_)&&(d=this.resolveOverlap_(l,!u,m,a,g,_)),!d&&this.m_shape.isEqualXY(c,h)&&(d=this.resolveOverlap_(!l,u,m,c,g,h))),d&&(t=!0),s||=d,n=d?this.getNextEdgeIndex_(n):r,r=this.getNextEdgeIndex_(n)}}if(!t){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let n=this.getNextEdgeIndex_(s);for(let r=0,i=this.m_bunchEdgeIndices.length;r<i&&-1!==s&&-1!==n&&s!==n;r++){const r=this.m_bunchEdgeIndices[s],i=this.m_bunchEdgeIndices[n],o=this.m_bunchEdgeEndPoints[r],a=this.m_bunchEdgeEndPoints[i];let h=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(h,e)||(h=this.m_shape.getPrevVertex(o));let m=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(m,e)||(m=this.m_shape.getPrevVertex(a));const l=this.getDirection_(h,o),g=this.getDirection_(m,a),u=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),c=g?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=this.detectAndResolveCrossOver_(l,g,o,h,u,a,m,c);1!==_?0===_?(s=this.getNextEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),n=this.getNextEdgeIndex_(s)):t=!0}}return t}simplify_(){if(this.m_shape.getGeometryType(this.m_geometry)===i.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)){new Ka(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0)}let e=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();const t=this.m_shape.getPointCount(this.m_geometry),s=new be(0);this.m_shape.dbgVerifyMonotone();for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==q;i=this.m_shape.getNextPath(i)){let e=this.m_shape.getFirstVertex(i);for(let t=0,n=this.m_shape.getPathSize(i);t<n;t++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(s,0,t),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(t),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let i=0;i<t;i++){const e=s.read(i),t=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,e);this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,t)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(e=!0);let n=0,r=!1;do{r=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const t=new $e(0,0);this.m_firstCoincidentVertex!==Se.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let s=0,i=this.m_firstCoincidentVertex;for(;i!==Se.st_nullNode()&&(i=this.m_sortedVertices.getNext(i),i!==Se.st_nullNode());){this.progress_();const e=this.m_sortedVertices.getData(i),n=$e.getNAN();if(this.m_shape.queryXY(e,n),t.equals(n))s++;else{if(s>0){this.m_nextVertexToProcess=i;const e=this.processBunch_();i=this.m_nextVertexToProcess,i!==Se.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(i),n),e&&(r=!0)}t.setCoordsPoint2D(n),this.m_firstCoincidentVertex=i,s=0}}if(this.m_nextVertexToProcess=-1,s>0){this.processBunch_()&&(r=!0)}n++>10&&a(""),r&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(r=!0),e||=r}while(r);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),e=jn(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||e,this.m_shape.dbgVerifyCurves(),e}getDirection_(e,t){return this.m_shape.getNextVertex(t)!==e}detectAndResolveCrossOver_(e,t,s,n,r,i,o,a){if(n===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(i),-1;const h=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),m=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),l=this.m_shape.getUserIndex(i,this.m_userIndexSortedAngleIndexToVertex),g=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),u=Je(8,Number.NaN),c=Je(4,Number.NaN);u[0]=0,c[0]=h,u[1]=0,c[1]=m,u[2]=1,c[2]=l,u[3]=1,c[3]=g;for(let d=1;d<4;d++){const e=c[d],t=u[d];let s=d-1;for(;s>=0&&c[s]>e;)c[s+1]=c[s],u[s+1]=u[s],s--;c[s+1]=e,u[s+1]=t}let _=0;if(u[0]&&(_|=1),u[1]&&(_|=2),u[2]&&(_|=4),u[3]&&(_|=8),5!==_&&10!==_)return 0;if(e!==t&&(a=ot(i,i=a)),e)this.m_shape.setNextVertex(a,n),this.m_shape.setPrevVertex(n,a),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(a,n),this.m_shape.setNextVertex(n,a),this.m_shape.setPrevVertex(r,o),this.m_shape.setNextVertex(o,r),this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(n),t=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageAndBreak(o,e,!0)}if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(n),t=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const r=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,r),this.m_shape.setSegmentToIndex(t,s)}}return 1}resolveOverlap_(e,t,s,n,r,i){return this.resolveOverlapOddEven_(e,t,s,n,r,i)}resolveOverlapOddEven_(e,t,s,n,r,i){if(e!==t){e||(r=ot(s,s=r),i=ot(n,n=i));const t=this.m_shape.getNextVertex(r),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,t),this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(r,o),this.m_shape.setPrevVertex(o,r),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(s),t=this.m_shape.getVertexIndex(r),n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null);const i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null),this.m_shape.setSegmentToIndex(e,i),this.m_shape.setSegmentToIndex(t,n)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(s),t=this.m_shape.getSegmentParentage(r);this.m_shape.setSegmentParentageAndBreak(s,t,!0),this.m_shape.setSegmentParentageAndBreak(r,e,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0)}this.removeSpike_(r)}else{const o=e?s:n,a=t?r:i,h=e?n:s,m=t?i:r;let l=null;if(this.m_bHasSegments){const e=this.m_shape.getVertexIndex(m);l=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null);const t=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(t,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let g=-1;this.m_bHasSegmentParentage&&(g=this.m_shape.getSegmentParentage(m));let u=!1;this.m_shape.setNextVertex(o,a),this.m_shape.setNextVertex(a,o),this.m_shape.setPrevVertex(h,m),this.m_shape.setPrevVertex(m,h);let c=m;for(;c!==a;){const e=this.m_shape.getPrevVertex(c),t=this.m_shape.getNextVertex(c);if(this.m_shape.setPrevVertex(c,t),this.m_shape.setNextVertex(c,e),u||=c===o,this.m_bHasSegments&&c!==o){const e=this.m_shape.getVertexIndex(t),s=l;l=this.m_shape.getSegmentFromIndex(e),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(e,s)}if(this.m_bHasSegmentParentage){const e=this.m_shape.getSegmentParentage(t);this.m_shape.setSegmentParentagePreserveBreak(t,g),g=e}c=t}let _=null;if(!u){const e=this.m_shape.getPrevVertex(a),t=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,t),this.m_shape.setNextVertex(a,e),this.m_bHasSegments){const e=this.m_shape.getVertexIndex(a);_=this.m_shape.getSegmentFromIndex(e),this.m_shape.setSegmentToIndex(e,null)}}let d=-1,p=-1;if(this.m_bHasSegmentParentage&&(d=u?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),p=this.m_shape.getSegmentParentage(h)),this.transferVertexData_(a,o),this.beforeRemoveVertex_(a,!0),this.m_shape.removeVertexInternal(a,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(m,h),this.beforeRemoveVertex_(m,!0),this.m_shape.removeVertexInternal(m,!0),this.removeAngleSortInfo_(h),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,d,!0),this.m_shape.setSegmentParentageAndBreak(h,p,!0)),_){const e=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(e,_)}}return!0}cleanupSpikes_(){let e=!1;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==q;){const s=this.m_shape.getNextPath(t);let n=this.m_shape.getFirstVertex(t);for(let r=0,i=this.m_shape.getPathSize(t);r<i&&i>1;){this.progress_();const{v:s,bModified:o}=this.checkAndCleanupSpike_(t,n);if(s===q)break;o?(e=!0,n=s,r=0,i=this.m_shape.getPathSize(t)):(n=s,r++)}t=s}return e}checkAndCleanupSpike_(e,t){const s={v:q,bModified:!1};let n=this.m_shape.getPrevVertex(t),r=this.m_shape.getNextVertex(t),i=q,o=q;for(;this.m_shape.isEqualXY(n,r)&&(i=n,o=r,r!==t);)n=this.m_shape.getPrevVertex(n),r=this.m_shape.getNextVertex(r);if(i===q)return s.v=r,s;s.bModified=!0;for(let a=this.m_shape.getNextVertex(i);this.beforeRemoveVertex_(a,!1),a!==o;a=this.m_shape.getNextVertex(a));if(i===t)return this.m_polylineDegeneracies!==q?this.m_shape.movePath(this.m_polylineDegeneracies,q,e):this.m_shape.removePath(e),s.v=q,s;{const e=this.m_shape.peelALoopIntoAPath(i,o);this.m_polylineDegeneracies!==q?this.m_shape.movePath(this.m_polylineDegeneracies,q,e):this.m_shape.removePath(e)}return s.v=i,s}removeSpike_(e){let t=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(e),n=q,r=q;for(;this.m_shape.isEqualXY(t,s)&&(n=t,r=s,s!==e);)t=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(s);if(n===q)return!1;if(this.m_shape.peelALoop(n,r),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(n,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)),this.removeAngleSortInfo_(n),this.m_polylineDegeneracies===q)for(let i=this.m_shape.getNextVertex(r);;){const e=this.m_shape.getNextVertex(i);if(this.removeAngleSortInfo_(i),this.beforeRemoveVertex_(i,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(i),null),this.m_shape.removeVertexInternal(i,!1),i===r)break;i=e}else{for(let t=r;;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!1),t=e,t===r)break}const e=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,q,r,r,e)}return!0}fixOrphanVertices_(){let e=0;for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==n;n=this.m_sortedVertices.getNext(n)){const e=this.m_sortedVertices.getData(n);this.m_shape.setPathToVertex(e,q)}let t=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==q;){const s=this.m_shape.getFirstVertex(n);if(s===q||this.m_shape.getPathFromVertex(s)!==q){const e=n;n=this.m_shape.getNextPath(n),this.m_shape.removePathOnly(e);continue}this.m_shape.setPathToVertex(s,n);let r=1;for(let e=this.m_shape.getNextVertex(s);e!==s;e=this.m_shape.getNextVertex(e))this.m_shape.setPathToVertex(e,n),r++;this.m_shape.setRingAreaValid(n,!1),this.m_shape.setPathSize(n,r),this.m_shape.setLastVertex(n,this.m_shape.getPrevVertex(s)),t+=r,e++,n=this.m_shape.getNextPath(n)}for(let n=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==n;n=this.m_sortedVertices.getNext(n)){const s=this.m_sortedVertices.getData(n);if(this.m_shape.getPathFromVertex(s)!==q)continue;const r=[!1],i=this.m_shape.insertClosedPath(this.m_geometry,q,s,s,r);t+=this.m_shape.getPathSize(i),e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,t);let s=0;for(let n=this.m_shape.getFirstGeometry();n!==q;n=this.m_shape.getNextGeometry(n))s+=this.m_shape.getPointCount(n);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(e+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}getPrevEdgeIndex_(e){if(-1===e)return-1;for(let t=0,s=this.m_bunchEdgeIndices.length-1;t<s;t++)if(e=(this.m_bunchEdgeIndices.length+e-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[e])return e;return-1}transferVertexData_(e,t){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex),n=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(e,t),this.m_shape.setUserIndex(t,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,n)}removeAngleSortInfo_(e){const t=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);-1!==t&&(this.m_bunchEdgeIndices[t]=-1,this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(e=!1){}}function sr(e,t,r,o,a,h=!0){switch(ir(o)){case 0:break;case 1:n("relation string length has to be 9 characters");break;default:n("relation string")}if(h){const s=xr(o,e.getDimension(),t.getDimension());if(0!==s)return kr(e,t,r,s,a)}let m=0;if("number"==typeof r)m=r;else{const n=s.constructEmpty();e.queryEnvelope(n);const i=s.constructEmpty();t.queryEnvelope(i);const o=s.constructEmpty();o.setCoords({env2D:n}),o.mergeEnvelope2D(i),m=ue(r,o,!1)}const l=Tr(e,m),g=Tr(t,m);if(l.isEmpty()||g.isEmpty())return fr(l,g,o);const u=l.getGeometryType(),c=g.getGeometryType();let _=!1;switch(u){case i.enumPolygon:switch(c){case i.enumPolygon:_=or(l,g,m,o,a);break;case i.enumPolyline:_=ar(l,g,m,o,a);break;case i.enumPoint:_=ur(l,g,m,o);break;case i.enumMultiPoint:_=hr(l,g,m,o,a)}break;case i.enumPolyline:switch(c){case i.enumPolygon:_=ar(g,l,m,Gr(o),a);break;case i.enumPolyline:_=mr(l,g,m,o,a);break;case i.enumPoint:_=cr(l,g,m,o,a);break;case i.enumMultiPoint:_=lr(l,g,m,o,a)}break;case i.enumPoint:switch(c){case i.enumPolygon:_=ur(g,l,m,Gr(o));break;case i.enumPolyline:_=cr(g,l,m,Gr(o),a);break;case i.enumPoint:_=dr(l,g,m,o);break;case i.enumMultiPoint:_=_r(g,l,m,Gr(o))}break;case i.enumMultiPoint:switch(c){case i.enumPolygon:_=hr(g,l,m,Gr(o),a);break;case i.enumPolyline:_=lr(g,l,m,Gr(o),a);break;case i.enumMultiPoint:_=gr(l,g,m,o,a);break;case i.enumPoint:_=_r(l,g,m,o)}break;default:_=!1}return _}function nr(e,t,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaAreaPredicates_();const o=s.constructEmpty(),a=s.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,n)&&(i.areaAreaDisjointPredicates_(e,t),h=!0),h||Br(e,t),h){return pr(i.m_matrix,i.m_scl)}let m=new V,l=m.addGeometry(e),g=m.addGeometry(t),u=null,c=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){u=new fa;const e=_a(n,m.getEnvelope2D(r));c=pa(e,0),aa(m,e,n,12e3,u,null,r)}ya(m,new Pe(n,0).add(c),r,!1,!1);const _=m.getGeometry(g).getBoundary();if(m.filterClosePoints(0,!0,!0,!1,q),er(m,l,-1,!1,q,r),0===m.getPointCount(l))return!1;er(m,g,-1,!1,q,r),i.setEditShape_(m,r);const d=0===m.getPointCount(g);if(!d){i.computeMatrixTopoGraphHalfEdges_(l,g),i.m_topoGraph.removeShape();const e=pr(i.m_matrix,i.m_scl);if(!e)return e}const p=m.getGeometry(l);m=new V,l=m.addGeometry(p),g=m.addGeometry(_),i.setEditShape_(m,r),i.m_predicateCount=0,i.resetMatrix_(),i.setPredicates_(d?"T*****F**":"******F**"),i.setAreaLinePredicates_(),i.computeMatrixTopoGraphHalfEdges_(l,g),i.m_topoGraph.removeShape();return pr(i.m_matrix,i.m_scl)}function rr(e,t,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_("T*****F**"),i.setAreaLinePredicates_();const o=s.constructEmpty(),a=s.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,n)&&(i.areaLineDisjointPredicates_(e,t),h=!0),h||Br(e,t),h){return pr(i.m_matrix,i.m_scl)}const m=new V,l=m.addGeometry(e),g=m.addGeometry(t);if(i.setEditShapeCrackAndCluster_(m,new Pe(n,0),r),0===m.getPointCount(l))return!1;i.computeMatrixTopoGraphHalfEdges_(l,g),i.m_topoGraph.removeShape();return pr(i.m_matrix,i.m_scl)}function ir(e){if(9!==e.length)return 1;for(let t=0;t<9;t++){const s=e[t];if("*"!==s&&"T"!==s&&"F"!==s&&"0"!==s&&"1"!==s&&"2"!==s)return 2}return 0}function or(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaAreaPredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.areaAreaDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.computeMatrixTopoGraphHalfEdges_(r,a),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function ar(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaLinePredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.areaLineDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.m_clusterIndexB=o.m_topoGraph.createUserIndexForClusters(),wr(a,o.m_topoGraph,o.m_clusterIndexB),o.computeMatrixTopoGraphHalfEdges_(r,a),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexB),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function hr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaPointPredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.areaPointDisjointPredicates_(e),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.computeMatrixTopoGraphClusters_(r,a),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function mr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setLineLinePredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.lineLineDisjointPredicates_(e,t),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.m_clusterIndexA=o.m_topoGraph.createUserIndexForClusters(),o.m_clusterIndexB=o.m_topoGraph.createUserIndexForClusters(),wr(r,o.m_topoGraph,o.m_clusterIndexA),wr(a,o.m_topoGraph,o.m_clusterIndexB),o.computeMatrixTopoGraphHalfEdges_(r,a),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexA),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexB),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function lr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setLinePointPredicates_();const a=s.constructEmpty(),h=s.constructEmpty();e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.linePointDisjointPredicates_(e),m=!0),m||Br(e,t),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.m_clusterIndexA=o.m_topoGraph.createUserIndexForClusters(),wr(r,o.m_topoGraph,o.m_clusterIndexA),o.computeMatrixTopoGraphClusters_(r,a),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexA),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function gr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setPointPointPredicates_();const a=new s,h=new s;e.queryEnvelope(a),t.queryEnvelope(h);let m=!1;if(qr(a,h,n)&&(o.pointPointDisjointPredicates_(),m=!0),!m){const s=new V,r=s.addGeometry(e),a=s.addGeometry(t);o.setEditShapeCrackAndCluster_(s,new Pe(n,0),i),o.computeMatrixTopoGraphClusters_(r,a),o.m_topoGraph.removeShape()}return pr(o.m_matrix,o.m_scl)}function ur(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setAreaPointPredicates_();const a=s.constructEmpty();e.queryEnvelope(a);const h=t.getXY();let m=!1;if(Or(h,a,n)&&(o.areaPointDisjointPredicates_(e),m=!0),!m){const t=Lo(e,h,n);if(1===t)o.m_matrix[0]=0,o.m_matrix[2]=2,o.m_matrix[3]=-1,o.m_matrix[5]=1,o.m_matrix[6]=-1;else if(2===t){o.m_matrix[6]=-1;if(0!==e.calculateArea2D())o.m_matrix[0]=-1,o.m_matrix[3]=0,o.m_matrix[2]=2,o.m_matrix[5]=1;else{o.m_matrix[0]=0,o.m_matrix[3]=-1,o.m_matrix[5]=-1;const t=s.constructEmpty();e.queryEnvelope(t),o.m_matrix[2]=t.height()||t.width()?1:-1}}else o.areaPointDisjointPredicates_(e)}return pr(o.m_matrix,r)}function cr(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setLinePointPredicates_();const a=s.constructEmpty();e.queryEnvelope(a);let h=!1;if(Or(t.getXY(),a,n)&&(o.linePointDisjointPredicates_(e),h=!0),!h){let s=null,r=!1,a=!1;if(o.m_performPredicates[0]||o.m_performPredicates[6]){!kr(e,t,n,4,i)?(o.m_performPredicates[0]&&(s=F(e),a=!kr(s,t,n,4,i),r=!0,o.m_matrix[0]=a?-1:0),o.m_matrix[6]=-1):(o.m_matrix[0]=-1,o.m_matrix[6]=0)}if(o.m_performPredicates[3]&&(null!==s&&s.isEmpty()?o.m_matrix[3]=-1:(r||(null==s&&(s=F(e)),a=!kr(s,t,n,4,i),r=!0),o.m_matrix[3]=a?0:-1)),o.m_performPredicates[5])if(null!==s&&s.isEmpty())o.m_matrix[5]=-1;else if(r&&!a)o.m_matrix[5]=0;else{null===s&&(s=F(e));const r=kr(s,t,n,3,i);o.m_matrix[5]=r?-1:0}if(o.m_performPredicates[2]){if(0!==e.calculateLength2D())o.m_matrix[2]=1;else{const s=new G({vd:e.getDescription()});s.addPoints(e,0,e.getPointCount());const r=kr(s,t,n,3,i);o.m_matrix[2]=r?-1:0}}}return pr(o.m_matrix,o.m_scl)}function _r(e,t,n,r,i){const o=new vr;o.resetMatrix_(),o.setPredicates_(r),o.setPointPointPredicates_();const a=s.constructEmpty();e.queryEnvelope(a);const h=t.getXY(),m=new $e;let l=!1;if(Or(h,a,n)&&(o.pointPointDisjointPredicates_(),l=!0),!l){let t=!1,s=!0;const r=n*n;for(let n=0;n<e.getPointCount()&&(e.queryXY(n,m),$e.sqrDistance(m,h)<=r?t=!0:s=!1,!t||s);n++);t?(o.m_matrix[0]=0,o.m_matrix[2]=s?-1:0,o.m_matrix[6]=-1):(o.m_matrix[0]=-1,o.m_matrix[2]=0,o.m_matrix[6]=0)}return pr(o.m_matrix,r)}function dr(e,t,s,n,r){const i=e.getXY(),o=t.getXY(),a=Je(9,-1);$e.sqrDistance(i,o)<=s*s?a[0]=0:(a[2]=0,a[6]=0),a[8]=2;return pr(a,n)}function pr(e,t){for(let s=0;s<9;s++)switch(t[s]){case"T":if(-1===e[s])return!1;break;case"F":if(-1!==e[s])return!1;break;case"0":if(0!==e[s])return!1;break;case"1":if(1!==e[s])return!1;break;case"2":if(2!==e[s])return!1}return!0}function fr(e,t,n){const r=Je(9,-1);if(e.isEmpty()&&t.isEmpty())return pr(r,n);let o,a=!1;e.isEmpty()?(o=t,a=!0):o=e,r[0]=-1,r[1]=-1,r[3]=-1,r[4]=-1,r[6]=-1,r[7]=-1,r[8]=2;const m=o.getGeometryType();if(h(m))if(m===i.enumPolygon){if(0!==o.calculateArea2D())r[2]=2,r[5]=1;else{r[5]=-1;const e=s.constructEmpty();o.queryEnvelope(e),r[2]=e.height()||e.width()?1:0}}else{const e=0!==o.calculateLength2D();r[2]=e?1:0,r[5]=D(o)?0:-1}else r[2]=0,r[5]=-1;return a&&Nr(r),pr(r,n)}function xr(e,t,s){return yr(e)?3:Pr(e)?4:Er(e,t,s)?8:Sr(e,t,s)?16:Ir(e)?64:Cr(e)?1:br(e,t,s)?32:0}function yr(e){return"T*F**FFF*"===e}function Pr(e){return"FF*FF****"===e}function Er(e,t,s){return(0!==t||0!==s)&&(2===t&&2===s?"F***T****"===e:(2===t||1===t)&&0===s&&"F**T*****"===e)}function Sr(e,t,s){return t>s?"T*****T**"===e:1===t&&1===s&&"0********"===e}function Cr(e){return"T*****FF*"===e}function Ir(e){return"T**FF*FF*"===e}function br(e,t,s){return t===s&&(1!==t?"T*T***T**"===e:"1*T***T**"===e)}function wr(e,t,s){const n=t.getGeometryID(e);for(let r=t.getFirstCluster();r!==q;r=t.getNextCluster(r)){if(0===(t.getClusterParentage(r)&n))continue;const e=t.getClusterHalfEdge(r);if(e===q){t.setClusterUserIndex(r,s,0);continue}let i=e,o=0;do{const e=i;0!==(t.getHalfEdgeParentage(e)&n)&&o++,i=t.getHalfEdgeNext(t.getHalfEdgeTwin(e))}while(i!==e);t.setClusterUserIndex(r,s,o)}}class vr{nullFunc(){return a("should not be called"),!1}constructor(){this.m_clusterIndexA=-1,this.m_clusterIndexB=-1,this.m_visitedIndex=-1,this.m_topoGraph=new tn,this.m_matrix=Je(9,0),this.m_maxDim=Je(9,0),this.m_performPredicates=Je(9,!1),this.m_scl="",this.m_predicateCount=0,this.m_predicatesHalfEdge=this.nullFunc,this.m_predicatesCluster=this.nullFunc}resetMatrix_(){this.m_matrix.fill(-2),this.m_maxDim.fill(-2)}setPredicates_(e){this.m_scl=e;for(let t=0;t<9;t++)"*"!==this.m_scl[t]?(this.m_performPredicates[t]=!0,this.m_predicateCount++):this.m_performPredicates[t]=!1}setRemainingPredicatesToFalse_(){for(let e=0;e<9;e++)this.m_performPredicates[e]&&-2===this.m_matrix[e]&&(this.m_matrix[e]=-1,this.m_performPredicates[e]=!1)}isPredicateKnown_(e){return-2!==this.m_matrix[e]&&(-1===this.m_matrix[e]?(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):"T"!==this.m_scl[e]&&"F"!==this.m_scl[e]?!(this.m_matrix[e]<this.m_maxDim[e])&&(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0):(this.m_performPredicates[e]=!1,this.m_predicateCount--,!0))}setAreaAreaPredicates_(){this.m_predicatesHalfEdge=this.areaAreaPredicates_,this.m_maxDim[0]=2,this.m_maxDim[1]=1,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=1,this.m_maxDim[5]=1,this.m_maxDim[6]=2,this.m_maxDim[7]=1,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaLinePredicates_(){this.m_predicatesHalfEdge=this.areaLinePredicates_,this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=0,this.m_maxDim[5]=1,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLineLinePredicates_(){this.m_predicatesHalfEdge=this.lineLinePredicates_,this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=0,this.m_maxDim[5]=0,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaPointPredicates_(){this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=2,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLinePointPredicates_(){this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=0,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setPointPointPredicates_(){this.m_predicatesCluster=this.pointPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=0,this.m_maxDim[3]=-1,this.m_maxDim[4]=-1,this.m_maxDim[5]=-1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[3]&&(this.m_matrix[3]=-1,this.m_performPredicates[3]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[5]&&(this.m_matrix[5]=-1,this.m_performPredicates[5]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}areaAreaDisjointPredicates_(e,t){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(e,t,n,r,i){const o=-1!==t,a=-1!==r;if(o||a){if(!("T"!==n&&"F"!==n&&o||"T"!==i&&"F"!==i&&a)||0!==e.calculateArea2D())o&&(this.m_matrix[t]=2),a&&(this.m_matrix[r]=1);else if(a&&(this.m_matrix[r]=-1),o){const n=s.constructEmpty();e.queryEnvelope(n),this.m_matrix[t]=n.height()||n.width()?1:0}}}areaAreaContainsPredicates_(e){this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[0]?0:-1,this.m_scl[0],this.m_performPredicates[1]?1:-1,this.m_scl[1])}areaAreaWithinPredicates_(e){this.areaAreaContainsPredicates_(e),Nr(this.m_matrix)}areaLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=D(t);this.m_matrix[7]=e?0:-1}this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(e,t){if(this.m_performPredicates[0]){const e=this.m_scl[0],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[0]=s?1:0}if(this.m_performPredicates[1]){const e=D(t);this.m_matrix[1]=e?0:-1}this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1}areaPointDisjointPredicates_(e){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(e){this.m_matrix[0]=0,this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1}lineLineDisjointPredicates_(e,t){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=D(e);this.m_matrix[5]=t?0:-1}if(this.m_performPredicates[6]){const e=this.m_scl[6],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const e=D(t);this.m_matrix[7]=e?0:-1}}linePointDisjointPredicates_(e){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){const t=this.m_scl[2],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const t=D(e);this.m_matrix[5]=t?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(e,t,1);const s=this.isPredicateKnown_(1);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(e,s,3);const t=this.isPredicateKnown_(3);n&&=t}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(e,t,s);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(e,t,s,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(e,s,t,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(e,t,s);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(e,t);const s=this.isPredicateKnown_(6);n&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(e,t,s,this.m_clusterIndexB);const r=this.isPredicateKnown_(7);n&&=r}return n}lineLinePredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const r=this.isPredicateKnown_(1);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(e,s,t,this.m_clusterIndexB,this.m_clusterIndexA,3);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(e,t,s,this.m_clusterIndexA,this.m_clusterIndexB);const r=this.isPredicateKnown_(4);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(e,t,s,this.m_clusterIndexA,5);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(e,s,t,this.m_clusterIndexB,7);const r=this.isPredicateKnown_(7);n&&=r}return n}areaPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(0);n&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(2);n&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(e,t);const s=this.isPredicateKnown_(5);n&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(e,t);const s=this.isPredicateKnown_(6);n&&=s}return n}linePointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(3);n&&=r}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(e,t,s,this.m_clusterIndexA);const r=this.isPredicateKnown_(5);n&&=r}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(6);n&&=r}return n}pointPointPredicates_(e,t,s){let n=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(e,t,s);const r=this.isPredicateKnown_(0);n&&=r}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(e,t,s,2);const r=this.isPredicateKnown_(2);n&&=r}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(e,s,t,6);const r=this.isPredicateKnown_(6);n&&=r}return n}interiorAreaInteriorArea_(e,t,s){if(2===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(n&t)&&0!==(n&s)&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[s])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(e,t,s,n){if(2===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=2)}boundaryAreaBoundaryArea_(e,t,s){if(1===this.m_matrix[4])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(n&t)||0===(n&s)){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(e),r=this.m_topoGraph.getClusterParentage(n);if(0!==(r&t)&&0!==(r&s))return void(this.m_matrix[4]=0)}}else this.m_matrix[4]=1}boundaryAreaExteriorArea_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeFaceParentage(e),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(r&s)&&0===(i&s)&&(this.m_matrix[n]=1)}interiorAreaInteriorLine_(e,t,s){if(1===this.m_matrix[0])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(e),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0!==(n&t)&&0!==(r&t)&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)){if(0!==(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[1]=0)}}}}interiorAreaExteriorLine_(e,t,s){if(2===this.m_matrix[2])return;0!==(this.m_topoGraph.getHalfEdgeParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(e,t,s,n){if(1===this.m_matrix[3])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(r&t)||0===(r&s)){if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2==0)return void(this.m_matrix[3]=0)}}}else this.m_matrix[3]=1}boundaryAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0!==(i&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(e,t,s){if(1===this.m_matrix[5])return;const n=this.m_topoGraph.getHalfEdgeParentage(e);0!==(n&t)&&0===(n&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(e,t){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(e),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e));0===(s&t)&&0===(n&t)&&(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(e,t,s,n){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(e),i=this.m_topoGraph.getClusterParentage(r);if(0===(i&t)){if(0===(this.m_topoGraph.getHalfEdgeFaceParentage(e)&t)){const e=this.m_topoGraph.getClusterUserIndex(r,n);if(0!==(i&s)&&e%2!=0)return void(this.m_matrix[7]=0)}}}}interiorLineInteriorLine_(e,t,s,n,r){if(1===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeParentage(e);if(0===(i&t)||0===(i&s)){if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2==0&&t%2==0)return void(this.m_matrix[0]=0)}}}else this.m_matrix[0]=1}interiorLineBoundaryLine_(e,t,s,n,r,i){if(0!==this.m_matrix[i]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(e),a=this.m_topoGraph.getClusterParentage(o);if(0!==(a&t)&&0!==(a&s)){const e=this.m_topoGraph.getClusterUserIndex(o,n),t=this.m_topoGraph.getClusterUserIndex(o,r);if(e%2==0&&t%2!=0)return void(this.m_matrix[i]=0)}}}interiorLineExteriorLine_(e,t,s,n){if(1===this.m_matrix[n])return;const r=this.m_topoGraph.getHalfEdgeParentage(e);0!==(r&t)&&0===(r&s)&&(this.m_matrix[n]=1)}boundaryLineBoundaryLine_(e,t,s,n,r){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(e),o=this.m_topoGraph.getClusterParentage(i);if(0!==(o&t)&&0!==(o&s)){const e=this.m_topoGraph.getClusterUserIndex(i,n),t=this.m_topoGraph.getClusterUserIndex(i,r);if(e%2!=0&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(e,t,s,n,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(e)),this.m_visitedIndex)){const t=this.m_topoGraph.getHalfEdgeTo(e);if(0===(this.m_topoGraph.getClusterParentage(t)&s)){if(this.m_topoGraph.getClusterUserIndex(t,n)%2!=0)return void(this.m_matrix[r]=0)}}}interiorAreaInteriorPoint_(e,t){if(0===this.m_matrix[0])return;if(0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0!==(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(e,t){if(2===this.m_matrix[2])return;0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(e,t,s){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(e,t){if(1===this.m_matrix[5])return;0!==(this.m_topoGraph.getClusterParentage(e)&t)&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(e,t){if(0===this.m_matrix[6])return;if(0===(this.m_topoGraph.getClusterParentage(e)&t)){const s=this.m_topoGraph.getClusterChain(e);if(0===(this.m_topoGraph.getChainParentage(s)&t))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[0])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0!==(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2==0)return void(this.m_matrix[0]=0)}}interiorLineExteriorPoint_(e,t,s,n){if(1===this.m_matrix[2])return;if(-1===this.m_topoGraph.getClusterHalfEdge(e)){if(0!==this.m_matrix[2]){if(0===(this.m_topoGraph.getClusterParentage(e)&s))return void(this.m_matrix[2]=0)}}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(e,t,s,n){if(0===this.m_matrix[3])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0!==(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2!=0)return void(this.m_matrix[3]=0)}}boundaryLineExteriorPoint_(e,t,s,n){if(0===this.m_matrix[5])return;const r=this.m_topoGraph.getClusterParentage(e);if(0!==(r&t)&&0===(r&s)){if(this.m_topoGraph.getClusterUserIndex(e,n)%2!=0)return void(this.m_matrix[5]=0)}}exteriorLineInteriorPoint_(e,t,s){if(0===this.m_matrix[6])return;const n=this.m_topoGraph.getClusterParentage(e);0!==(n&t)||0===(n&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(e,t,s){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(e);0===(n&t)||0===(n&s)||(this.m_matrix[0]=0)}interiorPointExteriorPoint_(e,t,s,n){if(0===this.m_matrix[n])return;const r=this.m_topoGraph.getClusterParentage(e);0===(r&t)||0!==(r&s)||(this.m_matrix[n]=0)}computeMatrixTopoGraphHalfEdges_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let i=this.m_topoGraph.getFirstCluster();i!==q;i=this.m_topoGraph.getNextCluster(i)){const e=this.m_topoGraph.getClusterHalfEdge(i);if(e===q){if(null!==this.m_predicatesCluster&&(s=this.m_predicatesCluster(i,n,r),s))break;continue}let t=e;do{let e=t;if(1!==this.m_topoGraph.getHalfEdgeUserIndex(e,this.m_visitedIndex))do{if(s=this.m_predicatesHalfEdge(e,n,r),s)break;this.m_topoGraph.setHalfEdgeUserIndex(e,this.m_visitedIndex,1),e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==t&&!s);if(s)break;t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(e))}while(t!==e);if(s)break}s||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(e,t){let s=!1;const n=this.m_topoGraph.getGeometryID(e),r=this.m_topoGraph.getGeometryID(t);for(let i=this.m_topoGraph.getFirstCluster();i!==q&&(s=this.m_predicatesCluster(i,n,r),!s);i=this.m_topoGraph.getNextCluster(i));s||this.setRemainingPredicatesToFalse_()}setEditShape_(e,t){this.m_topoGraph.setEditShape(e,t)}setEditShapeCrackAndCluster_(e,t,s){let n=0;if(e.hasCurves()){const r=new fa,i=e.getEnvelope2D(s),o=_a(t.total(),i);n=pa(o,0),aa(e,o,t.total(),12e3,r,null,s),r.clearStitcher(e)}ya(e,t.add(n),s,!1,!1),e.filterClosePoints(0,!0,!0,!1,q);for(let r=e.getFirstGeometry();r!==q;r=e.getNextGeometry(r))e.getGeometryType(r)===i.enumPolygon&&er(e,r,-1,!1,q,s);this.setEditShape_(e,s)}}function Nr(e){const t=e[1],s=e[2],n=e[5];e[1]=e[3],e[2]=e[6],e[5]=e[7],e[3]=t,e[6]=s,e[7]=n}function Tr(e,t,n){const r=e.getGeometryType();if(o(r)){const t=new w({vd:e.getDescription()});return t.addSegment(e,!0),t}if(r===i.enumEnvelope){const n=e,r=s.constructEmpty();if(e.queryEnvelope(r),r.height()<=t&&r.width()<=t){const t=new ye({vd:e.getDescription()});return n.getCenter(t),t}if(r.height()<=t||r.width()<=t){const t=new w({vd:e.getDescription()}),s=new ye;return n.queryCornerByVal(0,s),t.startPathPoint(s),n.queryCornerByVal(2,s),t.lineToPoint(s),t}const i=new T({vd:e.getDescription()});return i.addEnvelope(n,!1),i}return e}function Gr(e){return`${e[0]}${e[3]}${e[6]}${e[1]}${e[4]}${e[7]}${e[2]}${e[5]}${e[8]}`}class Dr{nullFunc(){return a("should not be called"),!1}constructor(e,t,n,r=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=s.constructEmpty(),this.m_envInter=s.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const i=e.getAccelerators();let o=null;null!=i&&(o=r?i.getQuadTreeForPaths():i.getQuadTree());const a=t.getAccelerators();let m=null;if(null!=a&&(m=r?a.getQuadTreeForPaths():a.getQuadTree()),null===o&&null===m&&!r){const r=e.getPointCount(),i=t.getPointCount();if(r>10&&i>10){const a=s.constructEmpty(),l=s.constructEmpty(),g=s.constructEmpty();e.queryLooseEnvelope(a),t.queryLooseEnvelope(l),a.inflateCoords(n,n),l.inflateCoords(n,n),g.setCoords({env2D:a}),g.intersect(l),r>=i?o=h(e.getGeometryType())?He(e,g):ke(e,g):m=h(t.getGeometryType())?He(t,g):ke(t,g)}}this.construct_(e,o,t,m,n,r)}next(){if(this.m_bQuadTree){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}return!!this.m_intersector&&this.m_intersector.next()}getRedElement(){return this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElement(this.m_elementHandle):h(this.m_queryType)?this.m_bPaths?this.m_pathIndex:this.m_segIter.getStartPointIndex():this.m_pointIndex:this.m_bSwapElements?this.m_intersector.getBlueElement(this.m_intersector.getHandleB()):this.m_intersector.getRedElement(this.m_intersector.getHandleA())}getBlueElement(){return this.m_bQuadTree?this.m_bSwapElements?h(this.m_queryType)?this.m_bPaths?this.m_pathIndex:this.m_segIter.getStartPointIndex():this.m_pointIndex:this.m_quadTree.getElement(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedElement(this.m_intersector.getHandleA()):this.m_intersector.getBlueElement(this.m_intersector.getHandleB())}getRedEnvelope(){return this.m_bPaths||p(""),this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_query:this.m_bSwapElements?this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB()):this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA())}getBlueEnvelope(){return this.m_bPaths||p(""),this.m_bQuadTree?this.m_bSwapElements?this.m_query:this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA()):this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB())}construct_(e,t,n,r,o,a){const m=s.constructEmpty(),l=s.constructEmpty();e.queryLooseEnvelope(m),n.queryLooseEnvelope(l),m.inflateCoords(o,o),l.inflateCoords(o,o),this.m_envInter.setCoords({env2D:m}),this.m_envInter.intersect(l),this.m_multiVertexImplA=e,this.m_multiVertexImplB=n;const g=e.getGeometryType(),u=n.getGeometryType();this.m_bPaths=a,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=i.enumUnknown,this.m_bQuadTree=!1,null!==t&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=t,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,h(u)?(this.m_queryType=u,this.m_function=this.nextPath_,a?this.m_pathIndex=n.getPathCount():this.m_segIter=n.querySegmentIterator()):(this.m_queryType=u,this.m_function=this.nextPoint_,this.m_pointIndex=n.getPointCount())),this.m_bQuadTree||null!==r&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=r,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!1,h(g)?(this.m_queryType=g,this.m_function=this.nextPath_,a?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=g,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(a&&h(g)&&h(u)?this.m_intersector=qe(e,n,o):h(g)&&h(u)?(this.m_intersector=Ae(e,n,o),this.m_bSwapElements=!1):h(g)&&!h(u)?(this.m_intersector=Me(e,n,o),this.m_bSwapElements=!1):!h(g)&&h(u)?(this.m_intersector=Me(n,e,o),this.m_bSwapElements=!0):(this.m_intersector=Ue(e,n,o),this.m_bSwapElements=!1))}nextPath_(){return this.m_bPaths?-1===--this.m_pathIndex?(this.m_bDone=!0,!1):(this.m_bSwapElements?this.m_multiVertexImplB.queryPathEnvelope(this.m_pathIndex,this.m_query):this.m_multiVertexImplA.queryPathEnvelope(this.m_pathIndex,this.m_query),this.m_qtIter.resetIterator(this.m_query,this.m_tolerance),this.m_function=this.iterate_,!0):this.m_segIter.nextPath()?(this.m_function=this.nextSegment_,!0):(this.m_bDone=!0,!1)}nextSegment_(){if(!this.m_segIter.hasNextSegment())return this.m_function=this.nextPath_,!0;const e=this.m_segIter.nextSegment(),t=new s;return e.queryLooseEnvelope(t),!t.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(e,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(-1===--this.m_pointIndex)return this.m_bDone=!0,!1;const e=new $e;if(this.m_bSwapElements){const t=this.m_multiVertexImplB.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}else{const t=this.m_multiVertexImplA.getXY(this.m_pointIndex);e.setCoordsPoint2D(t)}return!this.m_envInter.contains(e)||(this.m_qtIter.resetIterator(s.construct(e.x,e.y,e.x,e.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),-1===this.m_elementHandle&&(h(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0))}}function Vr(e){return 2===e?1:1===e?2:128===e?64:64===e?128:e}function Fr(e,t,n){let r;if(e instanceof oc||null===e){const i=s.constructEmpty();i.setCoords({pt:t}),i.mergeEnvelope2D(n),r=ue(e,i,!1)}else r=e;return r}function Hr(e,t,n){let r;if(e instanceof oc||null===e){const i=s.constructEmpty();i.setCoords({env2D:t}),i.mergeEnvelope2D(n),r=ue(e,i,!1)}else r=e;return r}function kr(e,t,n,a,h){if(e.isEmpty()||t.isEmpty())return 4===a;r(e),r(t);let m=e.getGeometryType(),l=t.getGeometryType();if(m===i.enumEnvelope){if(l===i.enumEnvelope)return Ar(e,t,n,a);if(l===i.enumPoint)return Mr(t,e,n,Vr(a))}else if(m===i.enumPoint){if(l===i.enumEnvelope)return Mr(e,t,n,a);if(l===i.enumPoint)return Ur(e,t,n,a)}const g=s.constructEmpty();e.queryEnvelope(g);const u=s.constructEmpty();t.queryEnvelope(u);const c=Hr(n,g,u);if(qr(g,u,c))return 4===a;let _=!1,d=null,p=null,f=null,x=null;switch(o(m)?(d=new w({vd:e.getDescription()}),d.addSegment(e,!0),f=d,m=i.enumPolyline):f=e,o(l)?(p=new w({vd:t.getDescription()}),p.addSegment(t,!0),x=p,l=i.enumPolyline):x=t,m!==i.enumEnvelope&&l!==i.enumEnvelope?(f.getDimension()<x.getDimension()||m===i.enumPoint&&l===i.enumMultiPoint)&&(a=Vr(a)):m!==i.enumPolygon&&l!==i.enumEnvelope&&(a=Vr(a)),m){case i.enumPolygon:switch(l){case i.enumPolygon:_=Yr(f,x,c,a,h);break;case i.enumPolyline:_=Rr(f,x,c,a,h);break;case i.enumPoint:_=Xr(f,x,c,a);break;case i.enumMultiPoint:_=Lr(f,x,c,a);break;case i.enumEnvelope:_=zr(f,x,c,a,h)}break;case i.enumPolyline:switch(l){case i.enumPolygon:_=Rr(x,f,c,a,h);break;case i.enumPolyline:_=Wr(f,x,c,a,h);break;case i.enumPoint:_=jr(f,x,c,a);break;case i.enumMultiPoint:_=Zr(f,x,c,a);break;case i.enumEnvelope:_=Kr(f,x,c,a,h)}break;case i.enumPoint:switch(l){case i.enumPolygon:_=Xr(x,f,c,a);break;case i.enumPolyline:_=jr(x,f,c,a);break;case i.enumMultiPoint:_=Jr(x,f,c,a)}break;case i.enumMultiPoint:switch(l){case i.enumPolygon:_=Lr(x,f,c,a);break;case i.enumPolyline:_=Zr(x,f,c,a);break;case i.enumMultiPoint:_=Qr(f,x,c,a);break;case i.enumPoint:_=Jr(f,x,c,a);break;case i.enumEnvelope:_=$r(f,x,c,a)}break;case i.enumEnvelope:switch(l){case i.enumPolygon:_=zr(x,f,c,a,h);break;case i.enumPolyline:_=Kr(x,f,c,a,h);break;case i.enumMultiPoint:_=$r(x,f,c,a)}}return _}function Ar(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return 4===r;const o=s.constructEmpty();e.queryEnvelope(o);const a=s.constructEmpty();t.queryEnvelope(a);const h=Hr(n,o,a);switch(r){case 4:return qr(o,a,h);case 2:return go(a,o,h,!1);case 128:return go(a,o,h,!0);case 1:return go(o,a,h,!1);case 64:return go(o,a,h,!0);case 3:return ho(o,a,h);case 8:return mo(o,a,h);case 32:return lo(o,a,h);case 16:return!1}return!1}function Mr(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return 4===r;const o=e.getXY(),a=s.constructEmpty();t.queryEnvelope(a);const h=Fr(n,o,a);switch(r){case 4:return Or(o,a,h);case 2:case 128:return ao(o,a,h);case 1:case 64:return!1;case 3:return io(o,a,h);case 8:return oo(o,a,h)}return!1}function Ur(e,t,n,r,i){if(e.isEmpty()||t.isEmpty())return 4===r;const o=e.getXY(),a=t.getXY();let h;if(n instanceof oc||null===n){const e=s.constructEmpty();e.setCoords({pt:o}),e.merge(a),h=ue(n,e,!1)}else h=n;switch(r){case 4:return no(o,a,h);case 2:case 128:return ro(a,o,h);case 1:case 64:return ro(o,a,h);case 3:return so(o,a,h)}return!1}function qr(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),!e.isIntersecting(r)}function Br(e,t,s,n=!1){const r=e.getGeometryType(),i=t.getGeometryType();if(x(r)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();l(null===e)}}if(x(i)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();l(null===t)}}return 0}function Or(e,t,n,r){const i=s.constructEmpty();return i.setCoords({env2D:t}),i.inflateCoords(n,n),!i.contains(e)}function Yr(e,t,s,n,r){switch(n){case 4:return ti(e,t,s);case 2:return ri(t,e,s,r);case 128:return ii(t,e,s);case 1:return ri(e,t,s,r);case 64:return ii(e,t,s);case 3:return ei(e,t,s,r);case 8:return si(e,t,s);case 32:return ni(e,t,s,r)}return!1}function Rr(e,t,s,n,r){switch(n){case 4:return oi(e,t,s);case 1:return mi(e,t,s,r);case 64:return li(e,t,s);case 8:return ai(e,t,s,r);case 16:return hi(e,t,s)}return!1}function Xr(e,t,s,n,r){switch(n){case 4:return gi(e,t,s);case 1:case 64:return ci(e,t,s);case 8:return ui(e,t,s)}return!1}function Lr(e,t,s,n,r){switch(n){case 4:return _i(e,t,s);case 1:return fi(e,t,s,!1);case 64:return fi(e,t,s,!0);case 8:return di(e,t,s);case 16:return pi(e,t,s)}return!1}function zr(e,t,s,n,r){if(yi(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return Si(e,t,s,!1);case 128:return Si(e,t,s,!0);case 1:return Ci(e,t,s,!1,r);case 64:return Ci(e,t,s,!0,r);case 3:return xi(e,t,s,r);case 8:return Pi(e,t,s,r);case 32:return Ei(e,t,s,r);case 16:return!1}return!1}function Wr(e,t,s,n,r){switch(n){case 4:return bi(e,t,s);case 2:return Ti(t,e,s,r);case 128:return Gi(t,e,s,r);case 1:return Ti(e,t,s,r);case 64:return Gi(e,t,s,r);case 3:return Ii(e,t,s,r);case 8:return wi(e,t,s,r);case 32:return Ni(e,t,s,r);case 16:return vi(e,t,s,r)}return!1}function jr(e,t,s,n,r){switch(n){case 4:return Di(e,t,s);case 1:case 64:return Fi(e,t,s);case 8:return Vi(e,t,s)}return!1}function Zr(e,t,s,n,r){switch(n){case 4:return Hi(e,t,s);case 1:case 64:return Mi(e,t,s);case 8:return ki(e,t,s);case 16:return Ai(e,t,s)}return!1}function Kr(e,t,s,n,r){if(qi(e,t,s))return 4===n;if(4===n)return!1;switch(n){case 2:return Oi(e,t,s,!1);case 128:return Oi(e,t,s,!0);case 1:case 64:case 32:return!1;case 3:return Ui(e,t,s);case 8:return Bi(e,t,s,r);case 16:return Yi(e,t,s)}return!1}function Qr(e,t,s,n,r){switch(n){case 4:return Xi(e,t,s);case 2:case 128:return zi(t,e,s);case 1:case 64:return zi(e,t,s);case 3:return Ri(e,t,s);case 32:return Li(e,t,s)}return!1}function Jr(e,t,s,n,r){switch(n){case 4:return ji(e,t,s);case 2:case 128:return Zi(e,t,s);case 1:case 64:return Ki(e,t,s);case 3:return Wi(e,t,s)}return!1}function $r(e,t,s,n,r){switch(n){case 4:return Ji(e,t,s);case 2:return eo(e,t,s,!1);case 128:return eo(e,t,s,!0);case 1:case 64:return!1;case 3:return Qi(e,t,s);case 8:return $i(e,t,s);case 16:return to(e,t,s)}return!1}function ei(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!ho(i,o,n))return!1;if(Br(e,t),yo(e,t,n))return!0;const a=e.calculateLength2D(),h=t.calculateLength2D(),m=Math.max(e.getPointCount(),t.getPointCount());if(Math.abs(a-h)>4*m*n)return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,n,"**F**FFF*",r,!1)}return So(e,t,n,!0)}function ti(e,t,s,n){Br(e,t,s,!0);return 1===uo(e,t,s,!0)}function si(e,t,s,n){return Br(e,t),Go(e,t,s,null)}function ni(e,t,s,n){return Br(e,t),Do(e,t,s,n)}function ri(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),Vo(e,t,n,r))}function ii(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),2===uo(e,t,n,!1))}function oi(e,t,s,n){Br(e,t,s,!0);return 1===uo(e,t,s,!0)}function ai(e,t,s,n){return Br(e,t),Fo(e,t,s,n)}function hi(e,t,s,n){return Br(e,t),Ho(e,t,s,null)}function mi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),ko(e,t,n,r))}function li(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&(Br(e,t),2===uo(e,t,n,!1))}function gi(e,t,s,n){return 0===Xo(e,t,s)}function ui(e,t,s,n){return Mo(e,t.getXY(),s)}function ci(e,t,s,n){return Ao(e,t.getXY(),s)}function _i(e,t,s,n,r){Br(e,t);return 1===co(e,t,s)}function di(e,t,n,r){Br(e,t);const i=s.constructEmpty();e.queryEnvelope(i),i.inflateCoords(n,n);const o=new $e;let a=!1;const h=e.getImpl(),m=new T;let l=e,g=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,o),i.contains(o)){const e=Lo(l,o,n);if(2===e)a=!0;else if(1===e)return!1}g||(!Wn(e,t.getPointCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}return!!a}function pi(e,t,n,r){Br(e,t);const i=new s,o=new s,a=new s;e.queryEnvelope(i),t.queryEnvelope(a),o.setCoords({env2D:i}),o.inflateCoords(n,n);let h=!1,m=!1;const l=new $e,g=e.getImpl(),u=new T;let c=e,_=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,l),o.contains(l)){const e=Lo(c,l,n);0===e?m=!0:1===e&&(h=!0)}else m=!0;if(h&&m)return!0;_||(!Wn(e,t.getPointCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?c=e:(e.copyTo(u),u.getImpl().buildQuadTreeAccelerator(1),c=u),_=!0)}return!1}function fi(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),!po(o,a,n))return!1;Br(e,t);let h=!1;const m=new $e,l=e.getImpl(),g=new T;let u=e,c=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,m),!o.contains(m))return!1;const i=Lo(u,m,n);if(1===i)h=!0;else if(0===i)return!1;if(r&&2===i)return!1;c||(!Wn(e,t.getPointCount()-1)||null!==l.getAccelerators()&&null!==l.getAccelerators().getQuadTree()?u=e:(e.copyTo(g),g.getImpl().buildQuadTreeAccelerator(1),u=g),c=!0)}return h}function xi(e,t,n,r){const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),!ho(i,o,n))return!1;const a=new T;return a.addEnvelope(t,!1),ei(e,a,n,r)}function yi(e,t,n,r){Br(e,t);const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;return 0===Lo(e,o.getLowerLeft(),0)&&(!o.contains(e.getXY(0))&&!To(e,o,n))}function Pi(e,t,n,r){Br(e,t);const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;if(o.height()<=n||o.width()<=n)return!1;const a=new T;return a.addEnvelope(t,!1),Go(e,a,n,r)}function Ei(e,t,n,r){Br(e,t);const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;if(o.height()<=n||o.width()<=n)return!1;const a=new T;return a.addEnvelope(t,!1),Do(e,a,n,r)}function Si(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();return e.queryEnvelope(o),t.queryEnvelope(a),r?fo(a,o,n):po(a,o,n)}function Ci(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),!po(o,a,n))return!1;Br(e,t);const h=new T;return h.addEnvelope(t,!1),r?2===uo(e,h,n,!1):Vo(e,h,n,i)}function Ii(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!ho(i,o,n))return!1;if(Br(e,t),yo(e,t,n))return!0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,n,"**F**FFF*",r,!1)}return So(e,t,n,!1)}function bi(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl();return!new Dr(r,i,s,!0).next()||!Io(e,t,s)}function wi(e,t,n,r){Br(e,t);const i=[],o=bo(e,t,n,i);if(-2===o){const i=s.constructEmpty(),o=s.constructEmpty(),a=s.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*n,1e3*n),o.inflateCoords(1e3*n,1e3*n),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=Zt(t,a,n,0,r),m.isEmpty())return!1}else m=t;return sr(h,m,n,"F********",r,!1)}if(0!==o)return!1;const a=new G;for(let s=0;s<i.length;s+=2){const e=i[s],t=i[s+1];a.addXY(e,t)}const h=e.getBoundary(),m=t.getBoundary();return h.addPoints(m,0,m.getPointCount()),!h.isEmpty()&&zi(h,a,n)}function vi(e,t,n,r){Br(e,t);const i=[],o=bo(e,t,n,i);if(-2===o){const i=s.constructEmpty(),o=s.constructEmpty(),a=s.constructEmpty();let h,m;if(e.queryEnvelope(i),t.queryEnvelope(o),i.inflateCoords(1e3*n,1e3*n),o.inflateCoords(1e3*n,1e3*n),a.setCoords({env2D:i}),a.intersect(o),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;if(t.getPointCount()>10){if(m=Zt(t,a,n,0,r),m.isEmpty())return!1}else m=t;return sr(h,m,n,"0********",r,!1)}if(0!==o)return!1;const a=new G;for(let s=0;s<i.length;s+=2){const e=i[s],t=i[s+1];a.addXY(e,t)}const h=e.getBoundary(),m=t.getBoundary();return h.addPoints(m,0,m.getPointCount()),!!h.isEmpty()||!zi(h,a,n)}function Ni(e,t,n,r){Br(e,t);const i=s.constructEmpty(),o=s.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);const a=xo(i,o,n),h=xo(o,i,n),m=e.hasNonLinearSegments(),l=t.hasNonLinearSegments(),g=bo(e,t,n,null);if(-1===g)return!1;if(1===g){if(a&&h)return!0;if(!m&&!l)return a&&!h?!Co(t,e,n,!1):h&&!a?!Co(e,t,n,!1):!Co(e,t,n,!1)&&!Co(t,e,n,!1)}const u=s.constructEmpty(),c=s.constructEmpty(),_=s.constructEmpty();let d,p;u.setCoords({env2D:i}),u.inflateCoords(1e3*n,1e3*n),c.setCoords({env2D:o}),c.inflateCoords(1e3*n,1e3*n),_.setCoords({env2D:u}),_.intersect(c);let f="";if(f+="1*",a){if(t.getPointCount()>10){if(p=Zt(t,_,n,0,r),p.isEmpty())return!1}else p=t;f+="****"}else p=t,f+="T***";if(h){if(e.getPointCount()>10){if(d=Zt(e,_,n,0,r),d.isEmpty())return!1}else d=e;f+="***"}else d=e,f+="T**";return sr(d,p,n,f,r,!1)}function Ti(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,n))return!1;if(Br(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,n,"******FF*",r,!1)}return Co(t,e,n,!1)}function Gi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,n))return!1;Br(e,t);return sr(e,t,n,"T**FF*FF*",r,!1)}function Di(e,t,s,n){Br(e,t);return!vo(e,t.getXY(),s)}function Vi(e,t,s,n){Br(e,t);return qo(e,t.getXY(),s)}function Fi(e,t,s,n){Br(e,t);return No(e,t.getXY(),s)}function Hi(e,t,s,n){return Br(e,t),!wo(e,t,s,!1)}function ki(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl(),o=new G,a=new Dr(r,i,s,!1),h=r.querySegmentIterator();let m=!1;for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();h.resetToVertex(e,-1);const n=h.nextSegment(),r=i.getXY(t);n.isIntersectingPoint(r,s)&&(m=!0,o.addPoint2D(r))}if(!m)return!1;const l=e.getBoundary();return!l.isEmpty()&&zi(l,o,s)}function Ai(e,t,s,n){Br(e,t);const r=e.getImpl(),i=t.getImpl(),o=i.getPointCount(),a=Je(o,!1),h=new Dr(r,i,s,!1),m=r.querySegmentIterator();let l=!1;for(;h.next();){const e=h.getRedElement(),t=h.getBlueElement();m.resetToVertex(e,-1);const n=m.nextSegment(),r=i.getXY(t);n.isIntersectingPoint(r,s)&&(l=!0,a[t]=!0)}if(!l)return!1;let g=!1;for(let _=0;_<o;_++)if(!a[_]){g=!0;break}if(!g)return!1;const u=e.getBoundary();if(u.isEmpty())return!0;const c=new G;for(let _=0;_<o;_++)a[_]&&c.addPoint2D(i.getXY(_));return!zi(u,c,s)}function Mi(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),!po(o,a,n))return!1;Br(e,t);const h=wo(e,t,n,!0);if(!h)return h;const m=e.getBoundary();return m.isEmpty()?h:!zi(m,t,n)}function Ui(e,t,n,r){const i=new s,o=new s;return e.queryEnvelope(i),t.queryEnvelope(o),!(o.height()>n&&o.width()>n)&&ho(i,o,n)}function qi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);const a=Bo(o,i,n);return 0===a?!To(e,o,n):4===a}function Bi(e,t,n,r){const o=new s,h=new s;if(e.queryEnvelope(o),t.queryEnvelope(h),h.height()<=n||h.width()<=n)return!1;const m=new s,l=new s;if(m.setCoords({env2D:h}),l.setCoords({env2D:h}),m.inflateCoords(n,n),l.inflateCoords(-n,-n),l.containsEnvelope(o)||!o.isIntersecting(m))return!1;const g=e.getImpl().querySegmentIterator();g.stripAttributes();const u=e.getImpl().getAccelerators();let c=null,_=null;null!==u&&(c=u.getQuadTree(),null!==c&&(_=c.getIterator(h,n))),_||g.nextPath()||a("relational_operations");let d=!1,p=null;const f=new $e,x=new $e,y=e.hasNonLinearSegments();let P=!1;for(;;){if(null!==_){const e=_.next();if(-1===e)break;g.resetToVertex(c.getElement(e),-1),p=g.nextSegment()}else{for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;p=g.nextSegment()}if(y&&p.getGeometryType()!==i.enumLine){const e=new s;if(p.queryEnvelope(e),l.containsEnvelope(e))return!1;if(m.isIntersecting(e)){P=!0;break}}else{f.assign(p.getStartXY()),x.assign(p.getEndXY());let e=l.clipLine(f,x);if(0!==e)return!1;d||(e=m.clipLine(f,x),0!==e&&(d=!0))}}if(!P)return d;const E=new T;return E.addEnvelope(h,!1),ai(E,e,n,r)}function Oi(e,t,n,r,o){const h=s.constructEmpty(),m=s.constructEmpty();if(e.queryEnvelope(h),t.queryEnvelope(m),m.height()<=n||m.width()<=n)return!1;if(r)return fo(m,h,n);if(!po(m,h,n))return!1;const l=s.constructEmpty();l.setCoords({env2D:m}),l.inflateCoords(-n,-n);const g=s.constructEmpty();if(g.setCoords({env2D:m}),g.inflateCoords(n,n),l.containsEnvelope(h))return!0;const u=e.getImpl().querySegmentIterator();u.stripAttributes(),u.nextPath()||a("relational_operations");let c,_,d,p,f,x,y=!1;const P=e.hasNonLinearSegments();for(P&&(d=new A,p=new A,f=new A,x=new A,l.querySide(0,d),l.querySide(1,p),l.querySide(2,f),l.querySide(3,x));;){for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;const e=u.nextSegment();if(P&&e.getGeometryType()!==i.enumLine){if(e.isIntersecting(d,n)){y=!0;break}if(e.isIntersecting(p,n)){y=!0;break}if(e.isIntersecting(f,n)){y=!0;break}if(e.isIntersecting(x,n)){y=!0;break}}else{c=e.getStartXY(),_=e.getEndXY();if(0!==l.clipLine(c,_)){y=!0;break}}}return y}function Yi(e,t,n,r){const o=new s,a=new s;if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;const h=new s;if(h.setCoords({env2D:a}),h.inflateCoords(n,n),h.containsEnvelope(o))return!1;const m=!0,g=new s;if(g.setCoords({env2D:a}),g.inflateCoords(-n,-n),!g.isIntersecting(o))return!1;const u=e.getImpl().querySegmentIterator();u.stripAttributes();const c=e.getImpl().getAccelerators();let _=null,d=null;if(null!==c&&(_=c.getQuadTree(),null!==_&&(d=_.getIterator(a,n))),!d){const e=u.nextPath();l(e)}let p=!1,f=null;const x=new $e,y=new $e;let P=null,E=null,S=null,C=null;for(e.hasNonLinearSegments()&&(P=new A,E=new A,S=new A,C=new A,g.querySide(0,P),g.querySide(1,E),g.querySide(2,S),g.querySide(3,C));;){if(null!==d){const e=d.next();if(-1===e)break;u.resetToVertex(_.getElement(e),-1),f=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;f=u.nextSegment()}if(f.getGeometryType()===i.enumLine){x.assign(f.getStartXY()),y.assign(f.getEndXY());if(0!==g.clipLine(x,y)){p=!0;break}}else{if(P.isIntersecting(f,n)){p=!0;break}if(E.isIntersecting(f,n)){p=!0;break}if(S.isIntersecting(f,n)){p=!0;break}if(C.isIntersecting(f,n)){p=!0;break}}}return p&&m}function Ri(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!ho(i,o,n)&&(!!Po(e,t,n)||Eo(e,t,n,!1,!0,!1))}function Xi(e,t,s,n){const r=e,i=t,o=new Dr(r,i,s,!1),a=s*s,h=new $e,m=new $e;for(;o.next();){const e=o.getRedElement(),t=o.getBlueElement();if(r.queryXY(e,h),i.queryXY(t,m),$e.sqrDistance(h,m)<=a)return!1}return!0}function Li(e,t,s,n){return Eo(e,t,s,!1,!1,!0)}function zi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),!!po(i,o,n)&&Eo(t,e,n,!0,!1,!1)}function Wi(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),ho(i,o,n)}function ji(e,t,s,n){return Uo(e,t.getXY(),s)}function Zi(e,t,s,n){return Wi(e,t,s)}function Ki(e,t,s,n){return!ji(e,t,s)}function Qi(e,t,n,r){const i=new s,o=new s;return e.queryEnvelope(i),t.queryEnvelope(o),!(o.height()>n||o.width()>n)&&ho(i,o,n)}function Ji(e,t,n,r){const i=s.constructEmpty(),o=s.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;const a=s.constructEmpty();a.setCoords({env2D:o}),a.inflateCoords(n,n);const h=new $e;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,h),a.contains(h))return!1;return!0}function $i(e,t,n,r){const i=new s,o=new s,a=new s;if(t.queryEnvelope(i),i.height()<=n||i.width()<=n)return!1;o.setCoords({env2D:i}),a.setCoords({env2D:i}),o.inflateCoords(n,n),a.inflateCoords(-n,-n);const h=new $e;let m=!1;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,h),o.contains(h)){if(a.containsExclusive(h))return!1;m=!0}return m}function eo(e,t,n,r,i){const o=s.constructEmpty(),a=s.constructEmpty();if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;if(r)return fo(a,o,n);if(!po(a,o,n))return!1;let h=!1;const m=s.constructEmpty(),l=s.constructEmpty();m.setCoords({env2D:a}),l.setCoords({env2D:a}),m.inflateCoords(-n,-n),l.inflateCoords(n,n);const g=new $e;for(let s=0;s<e.getPointCount();s++){if(e.queryXY(s,g),!l.contains(g))return!1;m.containsExclusive(g)&&(h=!0)}return h}function to(e,t,n,r){const i=new s,o=new s;if(e.queryEnvelope(i),t.queryEnvelope(o),po(o,i,n))return!1;if(o.height()<=n||o.width()<=n)return!1;const a=new s,h=new s;a.setCoords({env2D:o}),a.inflateCoords(-n,-n),h.setCoords({env2D:o}),h.inflateCoords(n,n);const m=new $e;let l=!1,g=!1;for(let s=0;s<e.getPointCount();s++)if(e.queryXY(s,m),!l&&a.containsExclusive(m)&&(l=!0),g||h.contains(m)||(g=!0),l&&g)return!0;return!1}function so(e,t,s,n){return $e.sqrDistance(e,t)<=s*s}function no(e,t,s,n){return $e.sqrDistance(e,t)>s*s}function ro(e,t,s,n){return so(e,t,s)}function io(e,t,n,r){const i=new s;return i.setCoords({pt:e}),ho(i,t,n)}function oo(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;const i=new s,o=new s;return i.setCoords({env2D:t}),i.inflateCoords(n,n),!!i.contains(e)&&(o.setCoords({env2D:t}),o.inflateCoords(-n,-n),!o.containsExclusive(e))}function ao(e,t,n,r){if(t.height()<=n||t.width()<=n)return!1;const i=s.constructEmpty();i.setCoords({env2D:t}),i.inflateCoords(-n,-n);return i.containsExclusive(e)}function ho(e,t,s,n){return po(e,t,s)&&po(t,e,s)}function mo(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n)return!1;const i=new s;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!(!i.isEmpty()&&i.height()>n&&i.width()>n)&&(i.setCoords({env2D:e}),i.inflateCoords(n,n),i.intersect(t),!i.isEmpty())}function lo(e,t,n,r){if(e.height()<=n||e.width()<=n||t.height()<=n||t.width()<=n)return!1;if(po(e,t,n))return!1;if(po(t,e,n))return!1;const i=new s;return i.setCoords({env2D:e}),i.inflateCoords(-n,-n),i.intersect(t),!i.isEmpty()&&(i.height()>n||i.width()>n)}function go(e,t,n,r,i){if(e.height()<=n||e.width()<=n)return!1;if(r)return fo(e,t,n);if(!po(e,t,n))return!1;const o=s.constructEmpty();return o.setCoords({env2D:e}),o.inflateCoords(-n,-n),o.intersect(t),!o.isEmpty()}function uo(e,t,n,r,o){const a=new $e,h=new $e,m=s.constructEmpty(),l=s.constructEmpty(),g=e.getImpl(),u=t.getImpl(),c=u.getGeometryType(),_=new Dr(g,u,n,!0);if(!_.next())return 1;if(Io(e,t,n))return r?4:0;const d=new T;let p=e;const f=new T;let x=null;c===i.enumPolygon&&(x=t);const y=c===i.enumPolygon?Je(g.getPathCount(),!1):[],P=Je(u.getPathCount(),!1);let E=!1,S=!1,C=!1,I=!1,b=!1,w=!1;do{if(C&&b||I&&w)break;if(C&&I)break;const s=_.getRedElement(),o=_.getBlueElement();if(!P[o]&&(h.assign(t.getXY(t.getPathStart(o))),m.setCoords({env2D:_.getRedEnvelope()}),m.inflateCoords(n,n),m.contains(h))){if(0!==Lo(p,h,0)){if(I=!0,r)return 4}else w=!0;P[o]=!0}if(c===i.enumPolygon&&!y[s]&&(a.assign(e.getXY(e.getPathStart(s))),l.setCoords({env2D:_.getBlueEnvelope()}),l.inflateCoords(n,n),l.contains(a))){if(0!==Lo(x,a,0)){if(C=!0,r)return 4}else b=!0;y[s]=!0}if(E||(!Wn(e,t.getPathCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?p=e:(e.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),p=d),E=!0),c===i.enumPolygon&&!S){const s=t;!Wn(s,e.getPathCount()-1)||null!==u.getAccelerators()&&null!==u.getAccelerators().getQuadTree()?x=t:(s.copyTo(f),f.getImpl().buildQuadTreeAccelerator(1),x=f),S=!0}}while(_.next());if(!C&&!I)return 1;if(!b||!w){if(c===i.enumPolygon)for(let e=0,t=g.getPathCount();e<t;e++)if(!y[e]){b=!0;break}for(let e=0,t=u.getPathCount();e<t;e++)if(!P[e]){w=!0;break}}return C&&b||I&&w||C&&I?4:I?2:3}function co(e,t,n,r,i){const o=s.constructEmpty();e.queryEnvelope(o),o.inflateCoords(n,n);const a=new $e,h=e.getImpl(),m=new T;let l=e,g=!1,u=!1,c=!1;for(let s=0;s<t.getPointCount();s++){if(t.queryXY(s,a),o.contains(a)){const e=Lo(l,a,n);if(1===e)return u=!0,4;if(2===e)return 4;c=!0}else c=!0;g||(!Wn(e,t.getPointCount()-1)||null!==h.getAccelerators()&&null!=h.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}return u?c?4:2:1}function _o(e,t,n,r,o){r[0]=!1;const a=e.getImpl(),h=t.getImpl(),m=a.querySegmentIterator(),g=h.querySegmentIterator(),u=[0,0],c=[0,0],_=new Dr(a,h,n);let d=!1;for(;_.next();){const e=_.getRedElement(),t=_.getBlueElement();m.resetToVertex(e,-1),g.resetToVertex(t,-1);const s=m.nextSegment(),i=g.nextSegment();let o=0;if(Oo(s,i)?!d&&i.isIntersecting(s,n)&&(d=!0):o=i.intersect(s,null,c,u,n),0!==o&&(d=!0,1===o)){const e=u[0],t=c[0];if(e>0&&e<1&&t>0&&t<1)return r[0]=!0,!1}}if(!d){r[0]=!0;const o=s.constructEmpty();e.queryEnvelope(o),o.inflateCoords(n,n);const m=new T;let g=e,u=!1;for(let n=0,r=t.getPathCount();n<r;n++)if(t.getPathSize(n)>0){const r=s.constructEmpty();if(t.queryPathEnvelope(n,r),!o.isIntersecting(r))return!1;{const e=zn(g,t.getXY(t.getPathStart(n)),0);if(l(-1!==e),0===e)return!1}u||(!Wn(e,t.getPathCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?g=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),g=m),u=!0)}if(1===e.getPathCount()||t.getGeometryType()===i.enumPolyline)return!0;const c=t,_=s.constructEmpty();c.queryEnvelope(_),_.inflateCoords(n,n);const d=new T;let p=c,f=!1;for(let t=0,n=e.getPathCount();t<n;t++)if(e.getPathSize(t)>0){const n=s.constructEmpty();if(e.queryPathEnvelope(t,n),_.isIntersecting(n)){const s=zn(p,e.getXY(e.getPathStart(t)),0);if(l(-1!==s),1===s)return!1}f||(!Wn(c,e.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?p=c:(c.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),p=d),f=!0)}return!0}return!1}function po(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(n,n),r.containsEnvelope(t)}function fo(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),e.containsExclusiveEnvelope(r)}function xo(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(n,n),!r.contains(e.getLowerLeft())||(!r.contains(e.getLowerRight())||(!r.contains(e.getUpperLeft())||!r.contains(e.getUpperRight())))}function yo(e,t,s,n){if(e.getPathCount()!==t.getPathCount()||e.getPointCount()!==t.getPointCount())return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments())return e.equals(t);const r=new $e,i=new $e;let o=!0;const a=s*s;for(let h=0;h<e.getPathCount();h++){if(e.getPathEnd(h)!==t.getPathEnd(h)){o=!1;break}for(let s=e.getPathStart(h);s<t.getPathEnd(h);s++)if(e.queryXY(s,r),t.queryXY(s,i),$e.sqrDistance(r,i)>a){o=!1;break}if(!o)break}return!!o}function Po(e,t,s,n){if(e.getPointCount()!==t.getPointCount())return!1;const r=new $e,i=new $e;let o=!0;const a=s*s;for(let h=0;h<e.getPointCount();h++)if(e.queryXY(h,r),t.queryXY(h,i),$e.sqrDistance(r,i)>a){o=!1;break}return!!o}function Eo(e,t,s,n,r,i,o){const a=e.getImpl(),h=t.getImpl(),m=a.getPointCount(),l=h.getPointCount(),g=Je(m,!1),u=r||i?Je(l,!1):[],c=s*s,_=new Dr(a,h,s);for(;_.next();){const e=_.getRedElement(),t=_.getBlueElement(),s=a.getXY(e),n=h.getXY(t);$e.sqrDistance(s,n)<=c&&(g[e]=!0,(r||i)&&(u[t]=!0))}let d=!1,p=!1;for(let y=0;y<m;y++){const e=g[y];if(d||=!e,p||=e,(r||n)&&d)return!1}if(n)return!0;let f=!1,x=!1;for(let y=0;y<l;y++){const e=u[y];if(f||=!e,x||=e,r&&f)return!1}return!!r||d&&p&&f&&x}function So(e,t,s,n){return Co(e,t,s,n)&&Co(t,e,s,n)}function Co(e,t,n,r){if(P(e),P(t),t.isEmpty())return!1;let i=!0;const o=Je(2,Number.NaN),h=Je(2,Number.NaN),m=[],l=new Ro;let g;const u=s.constructEmpty(),c=s.constructEmpty(),_=s.constructEmpty();e.queryEnvelope(u),t.queryEnvelope(c),u.inflateCoords(n,n),c.inflateCoords(n,n),_.setCoords({env2D:u}),_.intersect(c);const d=e.getImpl().querySegmentIterator(),p=t.getImpl().querySegmentIterator(),f=t.getImpl().getAccelerators();let x=null,y=null,E=null,S=null;if(null!==f&&(x=f.getQuadTree(),y=f.getQuadTreeForPaths(),null!==y&&(S=y.getIteratorForQT())),null===x){const s=e.getPointCount(),n=t.getPointCount();s>10&&n>10&&(x=He(t.getImpl(),_))}for(null!==x&&(E=x.getIteratorForQT());d.nextPath();)for(;d.hasNextSegment();){let e=d.nextSegment();if(e.queryEnvelope(u),!u.isIntersecting(_))return i=!1,!1;if(null!==S&&(S.resetIterator(u,n),-1===S.next()))continue;let t=0,s=null;if(null!=E)E.resetIterator(e,n);else if(p.resetToFirstPath(),!p.nextPath())return i=!1,!1;do{if(t=0,null!==E){const r=E.next();if(-1===r)return i=!1,!1;p.resetToVertex(x.getElement(r),-1),s=p.nextSegment(),t=e.intersect(s,null,o,h,n)}else{for(;!p.hasNextSegment();)if(!p.nextPath())return i=!1,!1;s=p.nextSegment(),s.queryEnvelope(c),c.inflateCoords(n,n),u.isIntersecting(c)&&(t=e.intersect(s,null,o,h,n))}}while(2!==t||0!==o[0]||r&&!(h[0]<=h[1]));let f=Number.NaN,y=!1;do{let r=!1;if(1===o[1]){if(!d.hasNextSegment()){y=!0;break}e=d.nextSegment(),r=!0}if(1===h[1]&&h[0]<=h[1]){if(-1===f)break;if(f=1,!p.hasNextSegment())break;s=p.nextSegment(),r=!0}if(0===h[1]&&h[0]>h[1]){if(1===f)break;if(Number.isNaN(f)){if(!p.hasPreviousSegment())break;p.previousSegment(),f=-1}if(!p.hasPreviousSegment())break;s=p.previousSegment(),r=!0}if(!r)break;t=e.intersect(s,null,o,h,n)}while(2===t&&(!r||h[0]<=h[1]));if(y)continue;const P=e.calculateLength2D();e.queryEnvelope(u),m.length=0,l.m_overlapEvents.length=0;let C=!1,I=!1,b=0;const w=ue(null,u,!0);for(null!==E?E.resetIterator(e,n):(p.resetToFirstPath(),p.nextPath()||a("relational_operations"));;){if(t=0,null!==E){const r=E.next();if(-1===r)break;p.resetToVertex(x.getElement(r),-1),s=p.nextSegment(),t=e.intersect(s,null,o,h,n)}else{for(;!p.hasNextSegment()&&p.nextPath(););if(!p.hasNextSegment())break;s=p.nextSegment(),s.queryEnvelope(c),c.inflateCoords(n,n),u.isIntersecting(c)&&(t=e.intersect(s,null,o,h,n))}if(2===t&&(!r||h[0]<=h[1])){const e=d.getStartPointIndex(),t=d.getPathIndex(),s=p.getStartPointIndex(),r=p.getPathIndex();if(g=Yo(e,t,o[0],o[1],s,r,h[0],h[1]),l.m_overlapEvents.push(g),m.push(m.length),!(C||g.m_scalarA0<b&&g.m_scalarA1<b))if(0===b&&P*(g.m_scalarA0-b)>n)C=!0;else if(0!==b&&P*(g.m_scalarA0-b)>w)C=!0;else if(b=g.m_scalarA1,P*(1-b)<=n||1===b){I=!0;break}}}if(!I){if(!C)return i=!1,!1;m.length>1&&m.sort((e,t)=>l.compareOverlapEvents(e,t)),b=0;for(let e=0;e<l.m_overlapEvents.length;e++)if(g=l.m_overlapEvents[m[e]],!(g.m_scalarA0<b&&g.m_scalarA1<b)){if(0===b&&P*(g.m_scalarA0-b)>n)return i=!1,!1;if(0!==b&&P*(g.m_scalarA0-b)>w)return i=!1,!1;if(b=g.m_scalarA1,P*(1-b)<=n||1===b)break}if(P*(1-b)>n)return i=!1,!1;m.length=0,l.m_overlapEvents.length=0}}return i}function Io(e,t,s){const n=e.getImpl(),r=t.getImpl(),i=n.querySegmentIterator(),o=r.querySegmentIterator(),a=new Dr(n,r,s);for(;a.next();){const e=a.getRedElement(),t=a.getBlueElement();i.resetToVertex(e,-1),o.resetToVertex(t,-1);const n=i.nextSegment();if(o.nextSegment().isIntersecting(n,s))return!0}return!1}function bo(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),h=Je(2,Number.NaN),m=new Dr(r,i,s);let l=!1,g=-1;for(;m.next();){const e=m.getRedElement(),t=m.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const r=o.nextSegment(),i=a.nextSegment();let u=0;if(Oo(r,i)){if(i.isIntersecting(r,s))return-2}else u=r.intersect(i,null,h,null,s);if(u)if(2===u){const e=r.calculateLength2D(),t=h[0];if(e*(h[1]-t)>s)return g=1,g;l=!0}else if(g=0,n){const e=h[0],t=new $e;r.queryCoord2D(e,t),n.push(t.x),n.push(t.y)}}return l?-2:g}function wo(e,t,s,n){const r=e.getImpl(),i=t,o=i.getPointCount(),a=n?Je(o,!1):[],h=new Dr(r,i,s,!1),m=r.querySegmentIterator();for(;h.next();){const e=h.getRedElement(),t=h.getBlueElement();m.resetToVertex(e,-1);const r=m.nextSegment(),o=i.getXY(t);if(r.isIntersectingPoint(o,s)){if(!n)return!0;a[t]=!0}}if(!n)return!1;for(let l=0;l<o;l++)if(!a[l])return!1;return!0}function vo(e,t,n){const r=new $e,i=n*n,o=e.querySegmentIterator(),a=e.getImpl().getAccelerators();if(null!==a){const e=a.getQuadTree();if(null!==e){const a=s.constructEmpty();a.setCoords({pt:t});const h=e.getIterator(a,n);for(let s=h.next();-1!==s;s=h.next())if(o.resetToVertex(e.getElement(s),-1),o.hasNextSegment()){const e=o.nextSegment(),s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,r),$e.sqrDistance(t,r)<=i)return!0}return!1}}const h=s.constructEmpty();for(;o.nextPath();)for(;o.hasNextSegment();){const e=o.nextSegment();if(e.queryEnvelope(h),h.inflateCoords(n,n),!h.contains(t))continue;const s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,r),$e.sqrDistance(t,r)<=i)return!0}return!1}function No(e,t,s){return vo(e,t,s)&&!qo(e,t,s)}function To(e,t,n,r){const o=e.querySegmentIterator(),a=e.getImpl().getAccelerators(),h=e.hasNonLinearSegments();let m=null,l=null,g=null,u=null;if(null!==a){const e=a.getQuadTree();if(null!==e){const r=e.getIterator(t,n);h&&(m=new A,l=new A,g=new A,u=new A,t.querySide(0,m),t.querySide(1,l),t.querySide(2,g),t.querySide(3,u));const a=s.constructEmpty();a.setCoords({env2D:t}),a.inflateCoords(n,n);for(let s=r.next();-1!==s;s=r.next())if(o.resetToVertex(e.getElement(s),-1),o.hasNextSegment()){const e=o.nextSegment();if(e.getGeometryType()===i.enumLine){const t=e.getStartXY(),s=e.getEndXY();if(a.clipLine(t,s))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0;if(e.isIntersecting(u,n))return!0}return!1}}if(h){m=new A,l=new A,g=new A,u=new A,t.querySide(0,m),t.querySide(1,l),t.querySide(2,g),t.querySide(3,u);const s=e.querySegmentIterator();for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment();if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0;if(e.isIntersecting(u,n))return!0}}else{const r=s.constructEmpty();r.setCoords({env2D:t}),r.inflateCoords(n,n);const i=e.getImpl(),o=i.getAttributeStreamRef(0),a=new $e;for(let e=0,t=i.getPathCount();e<t;e++){let t=!0;const s=new $e,n=new $e,h=new $e,m=i.getPathStart(e),l=new $e;for(let g=m,u=i.getPathEnd(e);g<u;g++)if(t)o.queryPoint2D(2*g,s),l.assign(s),t=!1;else{if(o.queryPoint2D(2*g,a),n.setCoordsPoint2D(s),h.setCoordsPoint2D(a),r.clipLine(n,h))return!0;s.assign(a)}if(i.isClosedPath(e)&&!t&&(n.setCoordsPoint2D(s),h.setCoordsPoint2D(l),r.clipLine(n,h)))return!0}}return!1}function Go(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=[0],h=De(i.getIsSimple(0,a))&&De(o.getIsSimple(0,a)),m=i.querySegmentIterator(),l=o.querySegmentIterator(),g=Je(2,0),u=Je(2,0),c=new Dr(i,o,n);let _=!1;for(;c.next();){const e=c.getRedElement(),t=c.getBlueElement();m.resetToVertex(e,-1),l.resetToVertex(t,-1);const s=m.nextSegment(),r=l.nextSegment();let i=0;if(Oo(s,r)){if(r.isIntersecting(s,n)){_=!0;break}}else i=r.intersect(s,null,u,g,n);if(2===i){const e=g[0],t=g[1],r=s.calculateLength2D();if(h&&(t-e)*r>n)return!1;_=!0}else if(i){const e=g[0],t=u[0];if(e>0&&e<1&&t>0&&t<1)return!1;_=!0}}if(!_)return!1;const d=s.constructEmpty(),p=s.constructEmpty(),f=s.constructEmpty();let x,y;if(e.queryEnvelope(d),t.queryEnvelope(p),d.inflateCoords(1e3*n,1e3*n),p.inflateCoords(1e3*n,1e3*n),f.setCoords({env2D:d}),f.intersect(p),e.getPointCount()>10){if(x=Zt(e,f,n,0,r),x.isEmpty())return!1}else x=e;if(t.getPointCount()>10){if(y=Zt(t,f,n,0,r),y.isEmpty())return!1}else y=t;return sr(x,y,n,"F********",r,!1)}function Do(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=[0],h=De(i.getIsSimple(0,a))&&De(o.getIsSimple(0,a)),m=s.constructEmpty(),l=s.constructEmpty(),g=s.constructEmpty();e.queryEnvelope(m),t.queryEnvelope(l);let u=!1;const c=xo(m,l,n),_=xo(l,m,n),d=i.querySegmentIterator(),p=o.querySegmentIterator(),f=Je(2,Number.NaN),x=Je(2,Number.NaN),y=new Dr(i,o,n);for(;y.next();){const e=y.getRedElement(),t=y.getBlueElement();d.resetToVertex(e,-1),p.resetToVertex(t,-1);const s=d.nextSegment(),r=p.nextSegment();let i=0;if(Oo(s,r)){if(r.isIntersecting(s,n))break}else i=r.intersect(s,null,x,f,n);if(2===i){const e=f[0],t=f[1],r=s.calculateLength2D();if(h&&(t-e)*r>n&&(u=!0,c&&_))return!0}else if(i){const e=f[0],t=x[0];if(e>0&&e<1&&t>0&&t<1)return!0}}const P=s.constructEmpty(),E=s.constructEmpty();let S,C;P.setCoords({env2D:m}),P.inflateCoords(1e3*n,1e3*n),E.setCoords({env2D:l}),E.inflateCoords(1e3*n,1e3*n),g.setCoords({env2D:P}),g.intersect(E);let I="";if(I+=u?"**":"T*",c){if(t.getPointCount()>10){if(C=Zt(t,g,n,0,r),C.isEmpty())return!1}else C=t;I+="****"}else C=t,I+="T***";if(_){if(e.getPointCount()>10){if(S=Zt(e,g,n,0,r),S.isEmpty())return!1}else S=e;I+="***"}else S=e,I+="T**";return sr(S,C,n,I,r,!1)}function Vo(e,t,n,r){const i=[!1],o=_o(e,t,n,i);if(i[0])return o;const a=s.constructEmpty();let h;if(t.queryEnvelope(a),a.inflateCoords(1e3*n,1e3*n),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;return nr(h,t,n,r)}function Fo(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),h=o.querySegmentIterator(),m=Je(2,Number.NaN),l=Je(2,Number.NaN),g=new Dr(i,o,n);let u=!1;for(;g.next();){const e=g.getRedElement(),t=g.getBlueElement();a.resetToVertex(e,-1),h.resetToVertex(t,-1);const s=a.nextSegment(),r=h.nextSegment();let i=0;if(Oo(s,r)?!u&&r.isIntersecting(s,n)&&(u=!0):i=r.intersect(s,null,l,m,n),2===i)u=!0;else if(i){const e=m[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!1;u=!0}}if(!u)return!1;const c=s.constructEmpty(),_=s.constructEmpty(),d=s.constructEmpty();let p,f;if(e.queryEnvelope(c),t.queryEnvelope(_),c.inflateCoords(1e3*n,1e3*n),_.inflateCoords(1e3*n,1e3*n),d.setCoords({env2D:c}),d.intersect(_),e.getPointCount()>10){if(p=Zt(e,d,n,0,r),p.isEmpty())return!1}else p=e;if(t.getPointCount()>10){if(f=Zt(t,d,n,0,r),f.isEmpty())return!1}else f=t;return sr(p,f,n,"F********",r,!1)}function Ho(e,t,n,r){const i=e.getImpl(),o=t.getImpl(),a=i.querySegmentIterator(),h=o.querySegmentIterator(),m=Je(2,Number.NaN),l=Je(2,Number.NaN),g=new Dr(i,o,n);let u=!1;for(;g.next();){const e=g.getRedElement(),t=g.getBlueElement();a.resetToVertex(e,-1),h.resetToVertex(t,-1);const s=a.nextSegment(),r=h.nextSegment();let i=0;if(Oo(s,r)?!u&&r.isIntersecting(s,n)&&(u=!0):i=r.intersect(s,null,l,m,n),2===i)u=!0;else if(i){const e=m[0],t=l[0];if(e>0&&e<1&&t>0&&t<1)return!0;u=!0}}if(!u)return!1;const c=s.constructEmpty(),_=s.constructEmpty(),d=s.constructEmpty(),p=s.constructEmpty(),f=s.constructEmpty();if(e.queryEnvelope(c),t.queryEnvelope(_),xo(_,c,n)){let s,i;if(d.setCoords({env2D:c}),d.inflateCoords(1e3*n,1e3*n),p.setCoords({env2D:_}),p.inflateCoords(1e3*n,1e3*n),f.setCoords({env2D:d}),f.intersect(p),e.getPointCount()>10){if(s=Zt(e,f,n,0,r),s.isEmpty())return!1}else s=e;if(t.getPointCount()>10){if(i=Zt(t,f,n,0,r),i.isEmpty())return!1}else i=t;return sr(s,i,n,"T********",r,!1)}return sr(e,t,n,"T*****T**",r,!1)}function ko(e,t,n,r){const i=[!1],o=_o(e,t,n,i);if(i[0])return o;const a=s.constructEmpty();let h;if(t.queryEnvelope(a),a.inflateCoords(1e3*n,1e3*n),e.getPointCount()>10){if(h=Zt(e,a,n,0,r),h.isEmpty())return!1}else h=e;return rr(h,t,n,r)}function Ao(e,t,s,n){return 1===Lo(e,t,s)}function Mo(e,t,s,n){return 2===Lo(e,t,s)}function Uo(e,t,s,n){const r=new $e,i=s*s;for(let o=0;o<e.getPointCount();o++)if(e.queryXY(o,r),$e.sqrDistance(r,t)<=i)return!1;return!0}function qo(e,t,s){const n=e.getBoundary();return!n.isEmpty()&&!Uo(n,t,s)}function Bo(e,t,n){const r=s.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(n,n),r.containsEnvelope(t)?1073741824:r.isIntersecting(t)?e.isIntersecting(t)?e.xmin<t.xmin&&t.xmax<e.xmax?t.ymin<e.ymin&&t.ymax>e.ymax?0:1073741824:e.ymin<t.ymin&&t.ymax<e.ymax?t.xmin<e.xmin&&t.xmax>e.xmax?0:1073741824:0:0:4}function Oo(e,t){return e.getGeometryType()!==i.enumLine||t.getGeometryType()!==i.enumLine}function Yo(e,t,s,n,r,i,o,a){return{m_ivertexA:e,m_ipathA:t,m_scalarA0:s,m_scalarA1:n,m_ivertexB:r,m_ipathB:i,m_scalarB0:o,m_scalarB1:a}}class Ro{constructor(){this.m_overlapEvents=[]}compareOverlapEvents(e,t){const s=this.m_overlapEvents[e],n=this.m_overlapEvents[t];if(s.m_ipathA<n.m_ipathA)return-1;if(s.m_ipathA===n.m_ipathA){if(s.m_ivertexA<n.m_ivertexA)return-1;if(s.m_ivertexA===n.m_ivertexA){if(s.m_scalarA0<n.m_scalarA0)return-1;if(s.m_scalarA0===n.m_scalarA0){if(s.m_scalarA1<n.m_scalarA1)return-1;if(s.m_scalarA1===n.m_scalarA1&&s.m_ivertexB<n.m_ivertexB)return-1}}}return 1}}function Xo(e,t,s){const n=Ln(e,t,s);return n?1===n?1:2:0}function Lo(e,t,s){const n=zn(e,t,s);return n?1===n?1:2:0}function zo(e,t,s,n,r){for(let i=0;i<s;i++)r[i]=Lo(e,t[i],n)}function Wo(e,t,n,r,o){if(e.getGeometryType()===i.enumPolygon)zo(e,t,n,r,o);else if(e.getGeometryType()===i.enumEnvelope){const i=s.constructEmpty();e.queryEnvelope(i),Zo(i,t,n,r,o)}else p("")}function jo(e,t,s,n,r){const a=e.getGeometryType();a===i.enumPolyline?$o(e,t,s,n,r):o(a)?Jo():p("")}function Zo(e,t,s,n,r){if(e.isEmpty()){for(let e=0;e<s;e++)r[e]=0;return}const i=e.clone();i.inflateCoords(.5*-n,.5*-n);const o=e.clone();o.inflateCoords(.5*n,.5*n);for(let a=0;a<s;a++)i.contains(t[a])?r[a]=1:o.contains(t[a])?r[a]=2:r[a]=0}function Ko(e){if(e.isEmpty())return 0;switch(e.getGeometryType()){case i.enumMultiPoint:return e.getImpl().getPointCount();case i.enumPolyline:return e.getImpl().getPathCount();case i.enumPolygon:return e.getImpl().getOGCPolygonCount();case i.enumGeometryCollection:return e.getGeometryCount()}return 1}function Qo(e,t,s){if(s.reset(),t<3)return;const n=e[0].clone(),r=n.x,i=n.y,o=e[1].clone(),a=new $e;for(let h=2;h<t;h++)a.assign(e[h]),s.pe((a.x-n.x)*(o.y-i)),n.assign(o),o.assign(a);s.pe((r-n.x)*(o.y-i))}function Jo(e,t,s,n,r){l(0)}function $o(e,t,n,r,i){const o=e.getImpl(),a=o.getAccelerators();let h=null;a&&(h=a.getRasterizedGeometry());let m=n;for(let s=0;s<n;s++)i[s]=1,h&&l(0);if(m){if(a){let e=null;null!==a&&null!==a.getQuadTree()&&(e=a.getQuadTree());const h=o.getPointCount();if(null===e&&h>20&&h*n>4*h+Math.log(h)*n&&(e=He(o)),e){let a=null;const h=o.querySegmentIterator(),l=new s;for(let s=0;s<n&&m;s++)if(1===i[s]){l.setCoords(t[s]),null===a?a=e.getIterator(l,r):a.resetIterator(l,r);let n=-1;for(let o=a.next();-1!==o;o=a.next()){h.resetToVertex(e.getElement(o),n),n=h.getPathIndex();if(h.nextSegment().isIntersectingPoint(t[s],r)){i[s]=2,m--;break}i[s]=0}}return}}const e=o.querySegmentIterator();for(;e.nextPath()&&m;)for(;e.hasNextSegment()&&m;){const s=e.nextSegment();for(let e=0;e<n&&m;e++)1===i[e]&&s.isIntersectingPoint(t[e],r)&&(i[e]=2,m--)}}for(let s=0;s<n;s++)1===i[s]&&(i[s]=0)}function ea(e,t,s,n,r){const i=J(t),o=Math.max(4*i,s);return new oa(t,null,o,Number.NaN,r).approximateWithCirclesImpl(e,n)}function ta(){return Number.isNaN(this.radius.value())}function sa(){return{ptStart:new $e,ptEnd:new $e,center:new ee,radius:new Ut,fcenter:new re,fradius2:new Ht,maxError:Number.NaN,isLine:ta}}const na=5,ra=1/8;function ia(e,t,s,n){return{pt:e.clone(),t,err:s,checkCount:n}}class oa{constructor(e,t,s,n,r){this.m_left=e,this.m_tracker=r,this.m_eps=s,this.m_trackerCounter=0,this.m_tolerance=n,this.m_circleCheckCounter=0,this.m_bReversedLeft=!1,this.m_leftArc=sa()}closeToCircularArc(e,t,s,n,r,i){if(this.m_circleCheckCounter++,i.maxError=0,!oa.checkSweepAngle(e,t))return!1;if(i.ptStart.setCoordsPoint2D(s),i.ptEnd.setCoordsPoint2D(r),e.isCircular()){const t=e;return i.fradius2=Ht.constructDouble(t.getSemiMajorAxis()).mulDouble(t.getSemiMajorAxis()),i.radius.set(t.getSemiMajorAxis()),i.fcenter.assignPoint2D(t.getCenter()),i.center.set(t.getCenter()),!0}const o=i.ptEnd.sub(i.ptStart).clone();o.leftPerpendicularThis(),o.normalize();if(Math.abs(o.dotProduct(n.sub(i.ptStart)))<=this.m_eps)return!!this.confirmIsLine(i,o)&&(i.radius.set(Number.NaN),i.center.setCoords(0,0),!0);{const s=i.ptEnd.sub(i.ptStart),r=n.sub(i.ptStart),o=s.crossProduct(r);if(0===o)return!1;const a=.5*s.sqrLength(),h=.5*r.sqrLength();let m=a*r.y-h*s.y;m/=o;let l=s.x*h-r.x*a;l/=o;const g=Math.sqrt(m*m+l*l);if(4*Number.EPSILON*g>this.m_eps)return!1;const u=m+i.ptStart.x,c=l+i.ptStart.y;i.radius.set(g),i.center.setCoords(u,c);const _=this.maxCircleApproximationError(e,t,i);if(_>this.m_eps)return i.maxError=_,!1}const a=(new re).assignPoint2D(i.ptStart),h=(new re).assignPoint2D(i.ptEnd).sub(a),m=(new re).assignPoint2D(n).sub(a),l=h.crossProduct(m);if(l.isZero())return!1;const g=h.sqrLength().mulDouble(.5),u=m.sqrLength().mulDouble(.5),c=g.mul(m.y).sub(u.mul(h.y)),_=h.x.mul(u).sub(m.x.mul(g)),d=c.mul(c).add(_.mul(_)),p=l.clone();p.invertThis(),i.fradius2=d.mul(p).mul(p),i.fcenter.setCoords(c.mul(p).add(a.x),_.mul(p).add(a.y)),i.center.setWithEps(i.fcenter.asPoint2D()),i.radius.setWithEps(Math.sqrt(i.fradius2.toDouble()));const f=ee.constructPoint2D(i.ptStart).subE(i.center),x=ee.constructPoint2D(i.ptEnd).subE(i.center);if(!f.dotProduct(x).gt(kt))return!1;const y=this.maxCircleApproximationError(e,t,i);return i.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===i.enumEllipticArc){const s=e,n=ie(s,t.vmin),r=ie(s,t.vmax);return!(Math.abs(r-n)>.5*St)}return!0}confirmIsLine(e,t){const s=e.ptEnd.sub(e.ptStart);return!(Math.abs(t.dotProduct(s.mul(.25)))>this.m_eps)&&!(Math.abs(t.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(e,t,s){const n=[.25,.75],r=[.1,.25,.75,.9];let o,a;e.getGeometryType()===i.enumEllipticArc?(o=n,a=n.length):(o=r,a=r.length);let h=0;for(let i=0;i<a;++i){const n=new $e;e.queryCoord2D(pt(t.vmin,t.vmax,o[i]),n);const r=n.sub(s.center.value()).length(),a=Math.abs(r-s.radius.value());a>h&&(h=a)}return h}approximateWithCirclesImpl(e,t){let s=1;t&&t.push(0);const n=Je(9,Number.NaN);let r;e?r=this.m_left.getMonotonicPartParams(n.length,n):(n[0]=0,n[1]=1,r=2);const i=[],o=[],a=new $e(0,0);for(let h=1;h<r;h++){const e=new lt(n[h-1],n[h]);for(this.m_bReversedLeft=!oa.goodOrientation(this.m_left,e),this.m_bReversedLeft?(i.push(ia(a,e.vmin,0,0)),i.push(ia(a,e.vmax,0,0))):(i.push(ia(a,e.vmax,0,0)),i.push(ia(a,e.vmin,0,0))),i[0].pt=this.m_left.getCoord2D(i[0].t),i[1].pt=this.m_left.getCoord2D(i[1].t);i.length>1;){this.progress_();const e=i.at(-1);let n=e.checkCount,r=e.err;const a=e.pt.clone(),h=e.t,m=i[i.length-2].t,l=.5*(h+m),g=this.m_left.getCoord2D(l);if(r<=this.m_eps||n>=na){const e=new lt;if(e.setCoords(h,m),this.closeToCircularArc(this.m_left,e,a,g,i[i.length-2].pt,this.m_leftArc)){t&&(this.m_bReversedLeft?o.push(h):t.push(m)),s++,i.pop();continue}n=0,r=this.m_leftArc.maxError}e.t=l,e.pt.setCoordsPoint2D(g),r*=ra,n++,e.err=r,e.checkCount=n,i.push(ia(a,h,r,n))}this.m_bReversedLeft&&t&&(t.length=t.length+o.length,Nt(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),i.length=0}return s}approximateWithCirclesImplPolyline(e){const t=new w,s=[];if(!this.approximateWithCirclesImpl(!0,s))return t;let n=0;const r=this.m_left.getStartXY();t.startPath(r);for(let i=1;i<s.length;++i)if(e)t.lineTo(this.m_left.getCoord2D(s[i]));else{const e=new $e;this.m_left.queryCoord2D(s[i],e);const o=new $e;this.m_left.queryCoord2D(.5*(s[i]+n),o);const a=new L;a.constructCircularArcThreePoint(r,e,o),t.addSegment(a,!1),r.assign(e),n=s[i]}return t}static goodOrientation(e,t){const s=e.getCoord2D(t.vmin),n=e.getCoord2D(t.vmax);return s.compare(n)<0}progress_(e=!1){}}function aa(e,t,s,n,r,i,o){ma(e,t,s,r,i,o),Ca(e,s,o)}function ha(e,t,s,n){if(!h(e.getGeometryType()))return e;const r=e.getImpl();if(!r.hasNonLinearSegments())return e;const o=e.createInstance();if(o.getGeometryType()===i.enumPolygon){o.setFillRule(e.getFillRule())}new V;const a=new ye,m=new k,l=[],g=[],u=[],c=e.getDescription().getAttributeCount()>1,_=r.querySegmentIterator();for(;_.nextPath();){let e=!0;for(;_.hasNextSegment();){const n=_.isClosingSegment(),r=_.nextSegment();if(!r.isCurve()){o.addSegment(r,e,n),e=!1;continue}let h,d=!1;const p=!0,f=!0;switch(r.getGeometryType()){case i.enumEllipticArc:case i.enumRationalBezier2:h=U(r,t,s,p,f,g,u,l),d=!0;break;default:h=M(r,t,s,!0,p,g,l)}const x=d?2:3;g[1].isNAN()?(m.createLine(),m.get().construct(g[0],g[x])):d?(m.createQuadraticRationalBezier(),m.get().constructArrayWeights(g,u)):(m.createCubicBezier(),m.get().constructPoints(g)),c&&e&&(r.queryCoord(l[0],a),m.get().setStart(a)),c&&(r.queryCoord(l[1],a),m.get().setEnd(a)),o.addSegment(m.get(),e,n&&1===h),e=!1;for(let e=1,t=h,s=x;e<t;++e,s+=x)g[s+1].isNAN()?(m.createLine(),m.get().construct(g[s],g[s+x])):d?(m.createQuadraticRationalBezier(),m.get().constructArrayWeights(g.slice(s),u.slice(s))):(m.createCubicBezier(),m.get().constructPoints(g.slice(s))),c&&(r.queryCoord(l[e+1],a),m.get().setEnd(a)),o.addSegment(m.get(),!1,n&&e+1===t)}}return o}function ma(e,t,s,n,r,i){e.hasCurves()?(e.setCurveStitcherPointer(n),n.m_impl=new xa(i,!1,null),n.m_impl.buildMonotonicCurveParentage(e,t,s,r)):n.m_impl=null}function la(e,t,s,n,r,i,o,a){e.hasCurves()?(e.setCurveStitcherPointer(i),i.m_impl=new xa(a,!0,r),i.m_impl.buildMonotonicCurveParentage(e,t,s,o),Ca(e,s,a)):i.m_impl=null}function ga(e){if(!e.hasSegmentParentage())return;const t=e.queryVertexIteratorOnSelection();for(let s=t.next();s!==q;s=t.next())if(!e.getSegmentParentageBreakVertex(s)){e.getPathFromVertex(s);const t=e.getPrevVertex(s),n=t!==q?e.getSegmentParentage(t):-1,r=e.getSegmentParentage(s);-1!==r&&-1!==n&&r!==n&&e.setSegmentParentageBreakVertex(s,!0)}}function ua(e){if(!e.hasSegmentParentage())return;ga(e);const t=new be(0),s=e.queryVertexIteratorOnSelection();for(let o=s.next();o!==q;o=s.next())t.add(o);if(0===t.size())return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(q);const n=$e.getNAN();e.queryXY(t.read(0),n);let r=0;const i=$e.getNAN();for(let o=1,a=t.size();o<a;o++){{const s=t.read(o);s!==q?e.queryXY(s,i):i.setNAN()}if(!i.isEqualPoint2D(n)){if(o-r>1){let s=!1;for(let n=r;n<o;++n){const r=t.read(n);if(e.getSegmentParentageBreakVertex(r)){s=!0;break}}if(!s){const n=(t,s,n)=>{const r=e.getPrevVertex(t),i=e.getNextVertex(t);r!==q?s.assign(e.getXY(r)):s.setNAN(),i!==q?n.assign(e.getXY(i)):n.setNAN()},i=new $e,a=new $e;n(t.read(r),i,a);for(let e=r+1;e<o;++e){const r=t.read(e);if(r===q)continue;const o=new $e,h=new $e;n(r,o,h);const m=(e,t)=>!!(e.equals(t)||e.isNAN()&&t.isNAN());if(!(m(o,i)&&m(h,a)||m(h,i)&&m(o,a))){s=!0;break}}}if(s)for(let n=r;n<o;++n)e.setSegmentParentageBreakVertex(t.read(n),!0)}n.setCoordsPoint2D(i),r=o}}}function ca(e,t){let s=t.isEmpty()?e:fe(null,t,!0).total();return s>e&&(s=e),.125*s}function _a(e,t){return t||(t=s.constructEmpty()),ca(e,t)}function da(e,t){return.125*e}function pa(e,t){return 3*e+3*t}class fa{constructor(){this.m_impl=null}stitchCurves(e,t,s,n){this.m_impl&&(this.m_impl.stitchCurves(e,t,s),n&&this.clearStitcher(e))}clearStitcher(e){this.m_impl&&(this.m_impl.clearStitcher(e),this.m_impl=null)}getOriginalVertexIndex(e,t){return this.m_impl.getOriginalVertexIndex(e,t)}getOriginalSegmentTypeInfo(e){return this.m_impl.getOriginalSegmentTypeInfo(e)}}class xa{constructor(e,t,s){this.m_originalPlanarSegments=[],this.m_progressTracker=null,this.m_nsr=null,this.m_progressTracker=e,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=1,this.m_progressCounter=0,this.m_bIsSimple=t,this.m_densificationDeviation=NaN,this.m_maxSegmentsPerCurve=-1}buildMonotonicCurveParentage(e,t,s,n){const r=!1,o=!0;if(!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=s;const a=new ye,h=new k,m=[],g=[],u=[];for(let c=e.getFirstGeometry();c!==q;c=e.getNextGeometry(c))for(let n=e.getFirstPath(c);n!==q;n=e.getNextPath(n)){let c=e.getPathSize(n),_=e.getFirstVertex(n),d=0,p=-1;for(let f=0;f<c;f++){let x=e.getNextVertex(_);if(!e.querySegment(_,h,!0,!1)){_=x;continue}if(0===d){p=e.getVertexIndex(_);const t=xa.regularizeCurve(e,h.get(),_,s);if(t>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new ts(13,p,-1)),d=t,c=e.getPathSize(n),x=e.getNextVertex(_);const s=e.querySegment(_,h,!0,!1);l(s)}}else d--;const y=e.getVertexIndex(_);let P;-1!==this.m_originalVertexIndex&&e.setUserIndex(_,this.m_originalVertexIndex,p),e.setSegmentToIndex(y,null);let E=!1;switch(h.get().getGeometryType()){case i.enumEllipticArc:case i.enumRationalBezier2:P=U(h.get(),t,s,r,o,g,u,m),E=!0;break;default:{const e=!this.m_bIsSimple||!h.get().isMonotoneQuickAndDirty();P=M(h.get(),t,s,e,r,g,m)}}const S=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(_,S,!0),!g[1].isNAN()){let t=null;t=E?new R({points:g,weights:u}):new Y({cp:g}),t.snapControlPoints(s*s),e.setSegmentToIndex(y,t)}const C=E?2:3;for(let t=1,r=P,i=C;t<r;++t,i+=C){h.get().queryCoord(m[t],a);const r=e.insertVertex(n,x,a);if(-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,p),!g[i+1].isNAN())if(E){const t=new R({points:g.slice(i),weights:u.slice(i)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(r),t)}else{const t=new Y({cp:g.slice(i)});t.snapControlPoints(s*s),e.setSegmentToIndex(e.getVertexIndex(r),t)}e.setSegmentParentageAndBreak(r,S,!1)}P>1&&(f+=P-1,c=e.getPathSize(n)),this.m_originalPlanarSegments.push(h.releaseSegment()),_=x}}}buildLinearSegmentParentage(e,t,s,n,r){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=n,!e.hasCurves())return;l(!e.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());const i=new ye,o=new k,a=new X(0,t,0,this.m_progressTracker,!1,n),h=[];for(let m=e.getFirstGeometry();m!==q;m=e.getNextGeometry(m))for(let t=e.getFirstPath(m);t!==q;t=e.getNextPath(t)){let n=e.getPathSize(t),r=e.getFirstVertex(t);for(let m=0;m<n;m++){let m=e.getNextVertex(r);if(!e.querySegment(r,o,!0,!1)){r=m;continue}if(xa.regularizeCurve(e,o.get(),r,s)>=0){n=e.getPathSize(t),m=e.getNextVertex(r);const s=e.querySegment(r,o,!0,!1);l(s)}const g=e.getVertexIndex(r);-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,g),e.setSegmentToIndex(g,null),h.length=0,a.densifySegment(o.get(),h),this.progress_();const u=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(r,u,!0);for(let s=1,n=h.length-1;s<n;++s){o.get().queryCoord(h[s],i);const n=e.insertVertex(t,m,i);e.setSegmentParentageAndBreak(n,u,!1),-1!==this.m_originalVertexIndex&&e.setUserIndex(n,this.m_originalVertexIndex,g)}this.m_originalPlanarSegments.push(o.releaseSegment()),r=m}}e.clearSegments()}stitchCurves(e,t,s){xa.st_stitchCurvesImpl(this,e,t,s,!1)}clearStitcher(e){this.m_originalPlanarSegments.length=0,-1!==this.m_originalVertexIndex&&(e.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),e.deleteSegmentParentage()}static st_verifyParentage(e){xa.st_stitchCurvesImpl(null,e,q,0,!0)}getOriginalVertexIndex(e,t){return-1!==this.m_originalVertexIndex&&t!==q?e.getUserIndex(t,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(e){if(-1!==e){const t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case i.enumEllipticArc:return 0===t.projectionBehavior()?0:1;case i.enumBezier:return 2;case i.enumBezier2:return 3;case i.enumLine:return-1;case i.enumRationalBezier2:return 4;default:d("")}}return-1}progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,s,n,r,i,o){if(t===s&&0===n)return l(e.getNextVertex(t)===q),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const a=e.getNextVertex(t),h=e.getXY(t),m=e.getXY(s);let g,u=0;{let t=2,r=h;for(let n=a;n!==s;n=e.getNextVertex(n)){const s=e.getXY(n);u+=$e.distance(s,r),r=s,t++}u+=$e.distance(m,r),l(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(a,s);const c=o;let _=r.getClosestCoordinate(h,!1),d=r.getClosestCoordinate(m,!1);const p=r.calculateLength2D();let f=r.tToLength(_),x=r.tToLength(d);const y=Math.abs(f)>10*c&&Math.abs(f-p)>10*c,P=Math.abs(x)>10*c&&Math.abs(x-p)>10*c,E=e=>{const t=e.calculateLength2D();return Math.abs(t-u)>Math.max(.2*u,4*c)?null:e};let S=r.isClosed();if(!S){const e=$e.distance(r.getStartXY(),r.getEndXY());e<=c&&p>5*e&&(S=!0)}if(S){let i,o,a=new $e;if(2===n)a=$e.lerp(h,m,.5),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i);else{let s=e.getNextNthVertex(t,(n-1)/2);a=e.getXY(s),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i);let h=Math.abs(o)>10*c&&Math.abs(o-p)>10*c;if(!h&&(n-1>=4&&(s=e.getNextNthVertex(t,(n-1)/4),i=r.getClosestCoordinate(a,!1),o=r.tToLength(i),h=Math.abs(o)>10*c&&Math.abs(o-p)>10*c),!h))return}let u=!1;const S=f===x;if(S){const s=0;let i=2,o=4;n-1<=4&&(i=s+1,o=s+2);const a=h,m=e.getXY(e.getNextNthVertex(t,i)),l=e.getXY(e.getNextNthVertex(t,o));u=-$e.orientationNonRobust(a,m,l)*at(r.calculateArea2DHelper())>0}else P?y?u=o>f:o<x?(f=0,_=0):(f=p,_=1):o>f?(x=p,d=1):(x=0,d=0);if(S)g=r.clone(),g.dropAllAttributes(),u||g.reverse(),l(h.equals(m));else{let e=!1;_>d&&(e=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.getDescription().getAttributeCount(),e&&g.reverse()}g.setCoordsForIntersector(h,m,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else if(y||P){if(!y||!P){if($e.distance(r.getStartXY(),r.getEndXY())<10*c){const n=[mt(_,d),mt(_,d),mt(_,d)];y?(n[1].second=0,n[2].second=1):(n[1].first=1,n[2].first=0);const i=[null,null,null],o=[0,0,0];let a=Number.MAX_VALUE,l=0;for(let e=0;e<3;e++){let t=!1;if(n[e].first>n[e].second){t=!0;const s=n[e].first;n[e].first=n[e].second,n[e].second=s}i[e]=r.cut(n[e].first,n[e].second,!0),i[e].dropAllAttributes(),t&&i[e].reverse(),i[e].setCoordsForIntersector(h,m,!1),o[e]=i[e].calculateLength2D();const s=Math.abs(u-o[e]);s<a&&(a=s,l=e)}return g=i[l],g=E(g),void(g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g)))}}let n=!1;_>d&&(n=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.dropAllAttributes(),n&&g.reverse(),g.setCoordsForIntersector(h,m,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else{if(g=r.clone(),g.dropAllAttributes(),f>x&&g.reverse(),u<Math.max(.75*p,p-this.m_densificationDeviation*(n-1))){const e=_>d?d:_,t=g.tToLength(e)+u;let s=g.lengthToT(t);s=Ct(s,e,1),g=g.cut(e,s,!0)}g.setCoordsForIntersector(h,m,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}}processSpanCurves_(e,t,s,n,r,i,o){if(t===s&&0===n)return l(e.getNextVertex(t)===q),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const a=e.getNextVertex(t);{let t=2;for(let n=a;n!==s;n=e.getNextVertex(n))t++;l(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(a,s);const h=e.getXY(t),m=e.getXY(s);if(r.isClosed()){if(h.isEqualPoint2D(m)&&h.isEqualPoint2D(r.getStartXY())){let a;if(a=this.verifySegmentFitnessCurves(e,t,s,n,r,i,o)){const n=r.clone();return n.dropAllAttributes(),a<0&&n.reverse(),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),n)}}}else if(h.isEqualPoint2D(r.getStartXY())){if(m.isEqualPoint2D(r.getEndXY())){const a=r.clone();a.dropAllAttributes();const h=this.verifySegmentFitnessCurves(e,t,s,n,a,i,o);if(h)return l(h>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),a)}}else if(m.isEqualPoint2D(r.getStartXY())&&h.isEqualPoint2D(r.getEndXY())){const a=r.getReversed();a.dropAllAttributes();const h=this.verifySegmentFitnessCurves(e,t,s,n,a,i,o);if(h)return l(h>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),a)}this.processSpanSplitSegmentCurves(e,t,s,n,r,i,o)}processSpan_(e,t,s,n,r,i,o){return 0===this.m_type?void this.processSpanSmartTe_(e,t,s,n,r,i,o):void this.processSpanCurves_(e,t,s,n,r,i,o)}processSpanSplitSegmentCurves(e,t,s,n,r,i,o){if(r.isLine())return;if(this.fitSegmentToSpanCurves(e,t,s,n,r,i,o))return;const a=o*o;let h=n,m=t;const l=e.getXY(t);let g=r.getClosestCoordinate(l,!1);const u=r.getCoord2D(g);let c=!1;const _=$e.sqrDistance(l,u);if(_>a){const n=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),n===s)return;m=n,c=!0,h-=1}let d=s;const p=e.getXY(s);g=r.getClosestCoordinate(p,!1);const f=r.getCoord2D(g);let x=!1;const y=$e.sqrDistance(p,f);if(y>a){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===m)return;d=t,x=!0,h-=1}if((c||x)&&this.fitSegmentToSpanCurves(e,m,d,h,r,i,o))return;let P=!1;if(!c&&_>0){const s=e.getNextVertex(t);if(this.approximateSpanSectionCurves(e,t,r,i,o),s===d)return;m=s,c=!0,P=!0,h-=1}if(!x&&y>0){const t=e.getPrevVertex(s);if(this.approximateSpanSectionCurves(e,t,r,i,o),t===m)return;d=t,x=!0,P=!0,h-=1}if(P&&this.fitSegmentToSpanCurves(e,m,d,h,r,i,o))return;let E=m;for(;;){const t=e.getNextVertex(E);if(this.approximateSpanSectionCurves(e,E,r,i,o),E=t,E===d)return}}fitSegmentToSpanCurves(e,t,s,n,r,i,o){const a=[];a.push(e.getXY(t));let h=t;const m=new k;for(;;){e.querySegment(h,m,!1,!0);const t=[.1,.25,.4,.5,.6,.75,.9,1];let r=0;for(const e of t){(2===n||1&r)&&a.push(m.get().getCoord2D(e)),r++}if(h=e.getNextVertex(h),h===s)break}const l=(()=>{let e=a[0].compare(a.at(-1));if(0===e){const t=new ct(0);Qo(a,a.length,t),e=t.getResult()>=0?-1:1}return e>0})();l&&a.reverse();const g=r.clone();if(g.dropAllAttributes(),l&&g.reverse(),g.setSegmentFromCoordsForStitcher(a,a.length),l&&g.reverse(),g.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitnessCurves(e,t,s,n,g,i,o)){this.removeSpanBetween(e,t,s);const n=e.getVertexIndex(t);return e.setSegmentToIndex(n,g),!0}return!1}approximateSpanSectionCurves(e,t,s,n,r){const o=new k;if(!e.querySegment(t,o,!0,!1))return;const h=s.getGeometryType();if(h!==o.get().getGeometryType()){if(h===i.enumEllipticArc){if(o.get().getGeometryType()!==i.enumRationalBezier2)return;if(0===s.projectionBehavior()){const s=[];ea(!1,o.get(),r,s,this.m_progressTracker);const n=e.getNextVertex(t),i=e.getPathFromVertex(t),a=new ye;let h=t;for(let t=1,r=s.length;t<r;t++){const r=s[t],m=o.get().getCoord2D(s[t-1]),l=o.get().getCoord2D(pt(s[t-1],r,.5));o.get().queryCoord(r,a);const g=a.getXY(),u=new L;u.constructCircularArcThreePoint(m,g,l);let c=q;r<1&&(c=e.insertVertex(i,n,a)),e.setSegmentToIndex(e.getVertexIndex(h),u),h=c}return}{const s=ut($e,3);o.get().queryControlPoints(s);const n=[0,0,0];o.get().queryWeights(n);const r=z(n),i=new L;return W(s,r*r,null,!1,i),void e.setSegmentToIndex(e.getVertexIndex(t),i)}}a("approximate_span_section_")}}verifySegmentFitnessCurves(e,t,s,n,r,i,o){const a=e.getXY(t),h=e.getXY(s);if(!a.isEqualPoint2D(r.getStartXY())||!h.isEqualPoint2D(r.getEndXY()))return 0;let m=0;if(r.isClosed()){const e=r.getCoord2D(.1).sub(a);m=r.getCoord2D(.7).sub(a).crossProduct(e)>=0?1:-1}const l=Je(j.s_maxMonotonicPartParams,Number.NaN);let g=r.getMonotonicPartParams(l.length,l);g--;const u=new A,c=[1,.5,.75,.25];let _=0,d=t;const p=a.clone();for(;;){const t=e.getNextVertex(d);let n=e.getSegment(d);null===n&&(e.queryLineConnector(d,u,!0),n=u);for(let e=t===s?1:0;e<c.length;e++){const t=n.getCoord2D(c[e]);if(!r.isCloserThanDistance(t,lt.unit(),o))return 0}if(g>1)for(let e=1;e<g;){const t=r.getCoord2D(l[e]);n.isCloserThanDistance(t,lt.unit(),o)?(l[g-1]=ot(l[e],l[e]=l[g-1]),g--):e++}if(m){const e=n.getCoord2D(.25);_+=e.sub(a).crossProduct(p.sub(a)),p.assign(e),e.assign(n.getCoord2D(.75)),_+=e.sub(a).crossProduct(p.sub(a)),p.assign(e)}if(d=t,d===s)return g>1?0:m?_<0?-m:m:1}}removeSpanBetween(e,t,s){e.setSegmentToIndex(e.getVertexIndex(t),null);const n=e.getNextVertex(t);n!==s&&e.removeVertices(n,s)}static st_stitchCurvesImpl(e,t,s,n,r){if(!t.hasSegmentParentage())return;ga(t);let i=s===q?t.getFirstGeometry():s;for(;i!==q;)if(C(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==q;s=t.getNextPath(s)){let i=t.getPathSize(s);const o=t.isClosedPath(s);o&&(i+=1);let a=t.getFirstVertex(s);const h=t.getSegmentParentage(a);if(o){if(-1!==h&&!t.getSegmentParentageBreakVertex(a)){let e=t.getPrevVertex(a);const s=a;for(let n=0;;n++){const r=t.getSegmentParentage(e);if(h!==r){l(-1===r);break}if(a=e,t.getSegmentParentageBreakVertex(e))break;if(e===s){a=s,t.setSegmentParentageBreakVertex(a,!0);break}e=t.getPrevVertex(e),l(n<i)}}}else l(-1===h||t.getSegmentParentageBreakVertex(a));let m=a;for(let s=0;s<i&&m!==q;){const o=t.getSegmentParentage(m);if(-1===o){if(s++,m=t.getNextVertex(m),m===a)break;continue}let h=0,g=q;const u=m;h=1;let c=t.getNextVertex(u);for(;s<i&&c!==q;){s++,g=c,h++;const e=t.getSegmentParentage(c);if(-1===e||t.getSegmentParentageBreakVertex(c))break;l(e===o),c=t.getNextVertex(c)}if(g===q){l(0);break}if(!r){const s=e.m_originalPlanarSegments[o];e.processSpan_(t,u,g,h,s,o,n)}if(m=g,m===a)break}}if(s!==q)break;i=t.getNextGeometry(i)}else i=s===q?t.getNextGeometry(i):q}static st_stitchCurvesFromLinesImpl(e,t,s,n,r){let i=s===q?t.getFirstGeometry():s;for(;i!==q;){for(let s=t.getFirstPath(i);s!==q;s=t.getNextPath(s)){let i=t.getPathSize(s);t.isClosedPath(s)&&(i+=1);let o=!0,a=!1;const h=t.getFirstVertex(s);let m=h;for(let s=0;s<i&&m!==q;){let g=t.getSegmentParentage(m);if(-1===g||o){o=!1,s++,m=t.getNextVertex(m),a=!0;continue}let u,c,_=0;if(a?(u=t.getPrevVertex(m),c=m,l(u!==q),l(c!==u),l(-1===t.getSegmentParentage(u)||h===u)):(u=m,c=t.getNextVertex(u),s++,l(c!==q),l(c!==u),g=t.getSegmentParentage(c)),_=2,a=!1,-1===g||t.getSegmentParentageBreakVertex(c)){m=c;continue}let d=t.getNextVertex(c);for(s++;s<i&&d!==q;){c=d,_++;const e=t.getSegmentParentage(d);if(-1===e||t.getSegmentParentageBreakVertex(d))break;l(e===g),s++,d=t.getNextVertex(d)}if(!r){const s=e.m_originalPlanarSegments[g];e.processSpan_(t,u,c,_,s,g,n)}m=c}}if(s!==q)break;i=t.getNextGeometry(i)}}static st_stitchCurvesFromCurvesImpl(e,t,s,n,r){let i=s===q?t.getFirstGeometry():s;for(;i!==q;)if(C(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==q;s=t.getNextPath(s)){let i=t.getPathSize(s);const o=t.isClosedPath(s);o&&(i+=1);let a=t.getFirstVertex(s);if(o){if(-1!==t.getSegmentParentage(a)){let e=a;for(let n=0;!t.getSegmentParentageBreakVertex(e);n++){if(n===i){a=t.getFirstVertex(s),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else l(-1===t.getSegmentParentage(a)||t.getSegmentParentageBreakVertex(a));let h=a;for(let s=0;s<i&&h!==q;){const o=t.getSegmentParentage(h);if(-1===o){s++,h=t.getNextVertex(h);continue}let a=0,m=q;const g=h;a=1;let u=t.getNextVertex(g);for(;s<i&&u!==q;){s++,m=u,a++;const e=t.getSegmentParentage(u);if(-1===e||t.getSegmentParentageBreakVertex(u))break;l(e===o),u=t.getNextVertex(u)}if(m===q)break;if(!r){const s=e.m_originalPlanarSegments[o];e.processSpan_(t,g,m,a,s,o,n)}h=m}}if(s!==q)break;i=t.getNextGeometry(i)}else i=s===q?t.getNextGeometry(i):q}static regularizeCurve(e,t,s,n){let r=t.snapControlPoints(n*n);if(r){const n=e.getVertexIndex(s),r=t.clone();e.setSegmentToIndex(n,r)}if(t.getGeometryType()===Y.type){const i=[],o=t.calculateSpecialPointsForCracking(n,i);if(o>0){const a=[];if(o>1)for(let e=0;e<o;e++)if(a.push(t.getCoord2D(i[e])),e>0){const t=(Math.abs(a[e].x)+Math.abs(a[e].y))*Pt(),s=$e.distance(a[e-1],a[e]);if(s<t&&s>0){const t=new $e;Et(a[e-1],a[e],.5,t),a[e-1]=t,a[e]=t}}e.splitSegment(s,i,o),r=e.snapControlPoints(s,o+1,n*n)||r;for(let t=0;t<o;t++)s=e.getNextVertex(s),e.setSegmentParentageBreakVertex(s,!0);return o}}return r?0:-1}}function ya(e,t,s,n,r){return new ba(e,s,t,n,r).do_()}function Pa(e,t,s){const n=Ee(e);return ln(t.getX(),t.getY(),s.getX(),s.getY(),_t(n))}function Ea(e,t,s=1,n=1,r=1,i=1){if(n>i)return e;if(i>n)return t;const o=[0],a=[0],h=new ye;return cn(e,t,s,n,r,i,h,a,o),h}function Sa(e,t,s){const n=Ee(t),r=Ie(t);return!!_n(e,n,q,null,s)||Mn(!0,e,r,null,s)}function Ca(e,t,s){return ba.fixCurveTwoPointLoops(e,t,s)}function Ia(e){return Ee(e)}class ba{constructor(e,t,s,n,r){this.m_shape=e,this.m_progressTracker=t,this.m_tolerance=s,this.m_bFilterDegenerateSegments=n,this.m_bTrackChanges=r,this.m_progressCounter=0}do_(){const e=new Pe(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=1e-5,s=1e-6,n=Ia(e);let r=Ie(e);const i=r*(1+t);r*=1+s;let o=!1;const h=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),m=this.m_shape.hasPointFeatures();for(let l=0;;l++){this.m_shape.dbgCheckSelection(),l>h&&a("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let e=-1;0===l&&(e=this.firstCrack_(),o||=e>0);const t=this.cluster_(n);if(this.m_shape.dbgVerifyMonotone(),o||=t,this.m_bFilterDegenerateSegments){const e=0!==this.m_shape.filterClosePoints(n,!0,!1,this.m_bTrackChanges,q);o||=e,this.m_shape.dbgVerifyMonotone()}const s=this.m_shape.snapControlPointsOnSelection(i*i);o||=s,this.m_shape.dbgCheckSelection();let g=!1;if((0===l&&-1===e||m||Mn(!0,this.m_shape,r,null,this.m_progressTracker))&&(g=this.crack_(i),o||=g,this.m_shape.dbgVerifyMonotone()),!g&&!ba.fixCurveTwoPointLoops(this.m_shape,n,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return o&&ua(this.m_shape),o}cluster_(e){return mn(this.m_shape,e,q,this.m_bTrackChanges,this.m_progressTracker)}crack_(e){return An(this.m_shape,e,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(e,t,s){if(!e.hasCurves())return!1;e.dbgVerifyCurves();const n=e.createUserIndexUninitialized(),r=new be(0),i=e.queryVertexIteratorOnSelection();for(let l=i.next();l!==q;l=i.next())r.add(l),e.setUserIndex(l,n,-1);if(0===r.size())return!1;r.add(q),e.sortVerticesSimpleByY(r,0,r.size()-1);let o=0;const a=e.getXY(r.read(o)),h=new $e(Number.NaN,Number.NaN),m=[];for(let l=1,g=r.size();l<g;++l){const t=r.read(l),s=t!==q?e.getXY(t):h;if(s.equals(a))continue;const i=[];for(let h=o;h<l;h++){const t=r.read(h),s=e.getPrevVertex(t);if(s!==q&&-1===e.getUserIndex(s,n)){const t=wa(e.getXY(s),e.getSegment(s));0!==$e.sqrDistance(a,t.otherPt)&&(t.vert=s,t.dir=-1,i.push(t)),e.setUserIndex(s,n,1)}const o=e.getNextVertex(t);if(o!==q&&-1===e.getUserIndex(t,n)){const s=wa(e.getXY(o),e.getSegment(t));0!==$e.sqrDistance(a,s.otherPt)&&(s.vert=t,s.dir=1,i.push(s)),e.setUserIndex(t,n,1)}}if(i.length>1){i.sort((e,t)=>Ta(e,t));const e=wa(h.clone(),null);i.push(e);let t=0;for(let s=1,n=i.length;s<n;s++)if(!i[s].otherPt.equals(i[s-1].otherPt)){if(s-t>1&&null!==i[t].seg){let e=!1;const n=t;for(let r=t+1;r<s;r++)if(!va(i[n],i[r])){e=!0;break}if(e)for(let r=t;r<s&&null!==i[r].seg;r++)m.push(i[r].vert)}t=s}}o=l,a.setCoordsPoint2D(s)}for(const g of m){const s=e.getSegment(g);l(null!==s);const n=e.getXY(g),r=e.getXY(e.getNextVertex(g));if($e.distance(n,r)<3*t)e.setSegmentToIndex(e.getVertexIndex(g),null);else{const t=s.lengthToT(.5*s.calculateLength2D());e.splitSegment(g,[t],1)}}return e.removeUserIndex(n),m.length>0}firstCrack_(){const e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=fe(null,e,!0).total();if(4*t<this.m_tolerance.total()){let e=!1;const s=1.1*t,n=t,r=this.cluster_(s);e||=r;let i=0;this.m_bFilterDegenerateSegments&&(i=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,q));const o=this.crack_(n);return e||=o,e?1:i?2:0}return-1}progress_(e=!1){this.m_progressCounter++,!e&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function wa(e,t){return{otherPt:e,seg:t,vert:-1,dir:0}}function va(e,t){if(l(e.otherPt.equals(t.otherPt)),null===e.seg)return null===t.seg;if(null===t.seg)return!1;const s=e.seg.getGeometryType();if(s!==t.seg.getGeometryType())return!1;if(s===i.enumBezier){const s=e.seg,n=t.seg;let r=s.getControlPoint1(),i=s.getControlPoint2();-1===e.dir&&(i=ot(r,r=i));let o=n.getControlPoint1(),a=n.getControlPoint2();return-1===t.dir&&(a=ot(o,o=a)),r.equals(o)&&i.equals(a)}if(s===i.enumRationalBezier2){const s=e.seg,n=t.seg,r=s.getControlPoint1(),i=n.getControlPoint1();if(!r.equals(i))return!1;const o=[0,0,0];s.queryWeights(o),-1===e.dir&&(o[2]=ot(o[0],o[0]=o[2]));const a=[0,0,0];return n.queryWeights(a),-1===t.dir&&(a[2]=ot(a[0],a[0]=a[2])),o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}a("")}function Na(e,t){if(null===e.seg||null===t.seg)return null!==e.seg?-1:null!==t.seg?1:0;const s=e.seg.getGeometryType(),n=t.seg.getGeometryType();return s<n?-1:s>n?1:0}function Ta(e,t){const s=e.otherPt.compare(t.otherPt);return 0!==s?s:Na(e,t)}var Ga=h,Da=o,Va=g;function Fa(e){switch(e){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:l(0,"unrecognized cut side")}return 3}function Ha(){return{unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1}}function ka(e,t,s,n){return new Ka(n).autoCompleteImpl(e,t,s)}function Aa(e,t,s,n,r,o,a){const h=new Ka(r);h.m_bOGCOutput=!0;const m=e.getGeometryType()===i.enumPolygon&&1===e.getFillRule()&&!De(n);return h.planarSimplifyImpl_(e,t,m,s,n,r,o,a)}function Ma(e,t,s,n,r,i,o,a){return new Ka(i).planarSimplifyImpl_(e,t,s,n,r,i,o,a)}function Ua(e,t,s,n){const r=new Ka(n),i=new V,o=i.addGeometry(t),a=r.planarSimplifyNoCrackingAndCluster(e,i,o,s);l(a,"planar_simplify_no_cracking_and_cluster");return i.getGeometry(o)}function qa(e,t,s,n,r,i,o){return l(0),{}}function Ba(e,t,s,n){return l(0),{}}function Oa(e,t,s){return Ja(e,t,s)}function Ya(e,t,n,r){if(e.isEmpty()||t.isEmpty()||e.getDimension()>t.getDimension())return $a(eh(e),e,t,"-");const o=new s;e.queryEnvelope(o);const a=new s;t.queryEnvelope(a);const h=new s;h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=fe(n,h,!0),l=a.clone(),g=Ee(m);if(l.inflateCoords(g,g),!o.isIntersecting(l))return $a(eh(e),e,t,"-");const u=new Ka(r),c=new V,_=c.addGeometry(eh(e)),d=c.addGeometry(eh(t));let p=0,f=0,x=null;if(c.hasCurves()){x=new fa;const e=c.getEnvelope2D(r);f=da(m.total());const t=_a(m.total(),e);p=pa(t,f),aa(c,t,m.total(),12e3,x,null,r)}u.setEditShapeCrackAndCluster(c,m.add(p));const y=u.difference(_,d);null!==x&&x.stitchCurves(c,y,f,!0);const P=$a(c.getGeometry(y),e,t,"-");return Ga(P.getGeometryType())&&(P.getImpl().setIsSimple(4,m.total()),P.getGeometryType()===i.enumPolygon&&P.getImpl().updateOGCFlagsProtected()),P}function Ra(e,t,n,r){if(e.getDimension()>t.getDimension())return $a(eh(e),e,t,"^");if(e.getDimension()<t.getDimension())return $a(eh(t),e,t,"^");if(e.isEmpty())return $a(eh(t),e,t,"^");if(t.isEmpty())return $a(eh(e),e,t,"^");const o=new s;e.queryEnvelope(o);const a=new s;t.queryEnvelope(a);const h=new s;h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=fe(n,h,!0),l=new Ka(r),g=new V,u=g.addGeometry(eh(e)),c=g.addGeometry(eh(t));let _=0,d=null;if(g.hasCurves()){d=new fa;const e=g.getEnvelope2D(r);_=da(m.total());aa(g,_a(m.total(),e),m.total(),12e3,d,null,r)}l.setEditShapeCrackAndCluster(g,m);const p=l.symmetricDifference(u,c);null!==d&&d.stitchCurves(g,p,_,!0);const f=$a(g.getGeometry(p),e,t,"^");return Ga(f.getGeometryType())&&(f.getImpl().setIsSimple(4,m.total()),f.getGeometryType()===i.enumPolygon&&f.getImpl().updateOGCFlagsProtected()),f}function Xa(e,t,s){return Qa(e,t,s,!0)}function La(e,t,s){return e.isEmpty()||t.isEmpty()?e.createInstance():Pa(s,e,t)?new ye({copy:Ea(e,t)}):e.createInstance()}function za(e,t,n,r){const o=s.constructEmpty();e.queryEnvelope(o);const a=s.constructEmpty();t.queryEnvelope(a);const h=s.constructEmpty();h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=fe(n,h,!0),l=new s(a),g=Ee(m);if(l.inflateCoords(g,g),!o.isIntersecting(l)){if(e.getDimension()<=t.getDimension())return $a(eh(e.createInstance()),e,t,"&");if(e.getDimension()>t.getDimension())return $a(eh(t.createInstance()),e,t,"&")}const u=new Ka(r),c=new V,_=c.addGeometry(eh(e)),d=c.addGeometry(eh(t));let p=0,f=0,x=null;if(c.hasCurves()){x=new fa;const e=c.getEnvelope2D(r);f=da(m.total());const t=_a(m.total(),e);p=pa(t,f),aa(c,t,m.total(),12e3,x,null,r)}u.setEditShapeCrackAndCluster(c,m.add(p));const y=u.intersection(_,d);null!==x&&x.stitchCurves(c,y,f,!0);const P=$a(c.getGeometry(y),e,t,"&");return Ga(P.getGeometryType())&&(P.getImpl().setIsSimple(4,m.total()),P.getGeometryType()===i.enumPolygon&&P.getImpl().updateOGCFlagsProtected()),P}function Wa(e,t,n,r){const o=new Array(3),a=s.constructEmpty();e.queryEnvelope(a);const h=s.constructEmpty();t.queryEnvelope(h);const m=s.constructEmpty();m.setCoords({env2D:a}),m.mergeEnvelope2D(h);const l=fe(n,m,!0),g=new s(h),u=Ee(l);if(g.inflateCoords(u,u),!a.isIntersecting(g)){if(e.getDimension()<=t.getDimension()){const s=$a(eh(e.createInstance()),e,t,"&");return o[s.getDimension()]=s,o}if(e.getDimension()>t.getDimension()){const s=$a(eh(t.createInstance()),e,t,"&");return o[s.getDimension()]=s,o}}const c=new Ka(r),_=new V,d=_.addGeometry(eh(e)),p=_.addGeometry(eh(t));let f=0,x=0,y=null;if(_.hasCurves()){y=new fa;const e=_.getEnvelope2D(r);x=da(l.total());const t=_a(l.total(),e);f=pa(t,x),aa(_,t,l.total(),12e3,y,null,r)}c.setEditShapeCrackAndCluster(_,l.add(f)),_.dbgVerifyCurves();const P=c.intersectionEx(d,p);for(const s of P){null!==y&&y.stitchCurves(_,s,x,!1);const n=$a(_.getGeometry(s),e,t,"&");Ga(n.getGeometryType())&&(n.getImpl().setIsSimple(4,l.total()),n.getGeometryType()===i.enumPolygon&&n.getImpl().updateOGCFlagsProtected()),o[n.getDimension()]=n}return null!==y&&y.clearStitcher(_),o}function ja(e,t,s,r,i,o=!1){0===t&&n("not enough geometries to dissolve");let a=0;for(let n=0,d=t;n<d;n++)a=Math.max(e[n].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!1,e,t,s,i,o);let h=0,m=-1;for(let n=0,d=t;n<d;n++)e[n].getDimension()===a&&(-1===m&&(m=n),e[n].isEmpty()||(m=n,h++));if(h<2)return eh(e[m]);const l=Ve.constructEmpty(),g=new V;let u=q;for(let n=0,d=t;n<d;n++)if(e[n].getDimension()===a&&!e[n].isEmpty()){u===q?u=g.addGeometry(eh(e[n])):g.appendGeometry(u,eh(e[n]));const t=Ve.constructEmpty();e[n].queryLooseEnvelope(t),l.mergeEnv3D(t)}const c=fe(s,l.getEnvelope2D(),!0),_=new Ka(r);if(o){const e=Fe(s,l.getEnvelopeZs(),!0);return _.planarSimplify3DImpl_(g,c,e,0,!0)}return _.m_bOGCOutput=!0,_.planarSimplifyMultiPoints(g,c,!1,-1)}function Za(e,t,s,r,i,o=!1){t<2&&n("not enough geometries to dissolve");let a=0;for(let n=0,p=t;n<p;n++)a=Math.max(e[n].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!0,e,t,s,i,o);const h=Ve.constructEmpty(),m=new V;let l=q,g=0,u=-1;for(let n=0,p=t;n<p;n++)if(e[n].getDimension()===a&&(-1===u&&(u=n),!e[n].isEmpty())){u=n,l===q?l=m.addGeometry(eh(e[n])):m.appendGeometry(l,eh(e[n]));const t=Ve.constructEmpty();e[n].queryLooseEnvelope(t),h.mergeEnv3D(t),g++}if(g<2)return eh(e[u]);const c=0===a?s:null,_=fe(c,h.getEnvelope2D(),!0),d=new Ka(r);if(o){const e=Fe(c,h.getEnvelopeZs(),!0);return d.m_bOGCOutput=!0,d.planarSimplify3DImpl_(m,_,e,0,!0)}return d.planarSimplifyMultiPoints(m,_,!0,-1)}class Ka{constructor(e){this.m_topoGraph=null,this.m_maskLookup=[],this.m_dummyPt1=$e.getNAN(),this.m_dummyPt2=$e.getNAN(),this.m_fromEdgeForPolylines=q,this.m_progressCounter=0,this.m_bOGCOutput=!1,this.m_progressTracker=e}linesToPolygonsImpl(e,t){let s=0,n=0,r=null;if(e.hasCurves()){r=new fa;const i=e.getEnvelope2D(this.m_progressTracker);n=da(t.total());const o=_a(t.total(),i);s=pa(o,n),aa(e,o,t.total(),12e3,r,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,t.add(s));const i=this.m_topoGraph.createUserIndexForChains(),o=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(o,i,1);for(let h=this.m_topoGraph.getChainFirstIsland(o);h!==q;h=this.m_topoGraph.getChainNextInParent(h))this.m_topoGraph.setChainUserIndex(h,i,1);const a=[];for(let h=this.m_topoGraph.getFirstChain();h!==q;h=this.m_topoGraph.getChainNext(h)){if(1===this.m_topoGraph.getChainUserIndex(h,i))continue;this.m_topoGraph.setChainUserIndex(h,i,1);for(let e=this.m_topoGraph.getChainFirstIsland(h);e!==q;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,i,1);if(0===this.m_topoGraph.getChainArea(h))continue;const t=this.m_topoGraph.extractPolygonFromChainAndIslands(e,q,h,q);null!=r&&r.stitchCurves(e,t,n,!1);const s=e.getGeometry(t);a.push(s)}return new $t(a)}autoCompleteImpl(e,t,s){let n=0,r=0,i=null;if(e.hasCurves()){i=new fa;const t=e.getEnvelope2D(this.m_progressTracker);r=da(s.total());const o=_a(s.total(),t);n=pa(o,r),aa(e,o,s.total(),12e3,i,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(e,s.add(n));const o=this.m_topoGraph.getGeometryID(t),a=this.m_topoGraph.createUserIndexForChains(),h=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(h,a,1);for(let l=this.m_topoGraph.getChainFirstIsland(h);l!==q;l=this.m_topoGraph.getChainNextInParent(l))this.m_topoGraph.setChainUserIndex(l,a,1);const m=[];for(let l=this.m_topoGraph.getFirstChain();l!==q;l=this.m_topoGraph.getChainNext(l)){if(1===this.m_topoGraph.getChainUserIndex(l,a))continue;this.m_topoGraph.setChainUserIndex(l,a,1);for(let e=this.m_topoGraph.getChainFirstIsland(l);e!==q;e=this.m_topoGraph.getChainNextInParent(e))this.m_topoGraph.setChainUserIndex(e,a,1);if(0!==this.m_topoGraph.getChainParentage(l))continue;const t=this.m_topoGraph.getChainHalfEdge(l);let s=t,n=!1;do{const e=this.m_topoGraph.getHalfEdgeTwin(s);if(this.m_topoGraph.getHalfEdgeChain(e)!==l&&0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){n=!0;break}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==t);if(!n)continue;if(0===this.m_topoGraph.getChainArea(l))continue;const h=this.m_topoGraph.extractPolygonFromChainAndIslands(e,q,l,q);null!==i&&i.stitchCurves(e,h,r,!1);const g=e.getGeometry(h);m.push(g)}return new $t(m)}setEditShape(e,t=!1){null===this.m_topoGraph&&(this.m_topoGraph=new tn),this.m_topoGraph.setEditShape(e,this.m_progressTracker,!0,t)}setEditShapeCrackAndCluster(e,t){ya(e,t,this.m_progressTracker,!0,!1);for(let s=e.getFirstGeometry();s!==q;s=e.getNextGeometry(s))e.getGeometryType(s)===i.enumPolygon&&er(e,s,-1,this.m_bOGCOutput,q,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==q;n=s.getNextGeometry(n))if(n===t)for(let t=s.getFirstPath(n);t!==q;t=s.getNextPath(t)){let n=s.getFirstVertex(t);if(n===q)continue;let r=s.getNextVertex(n);for(;r!==q;){const t=this.m_topoGraph.getClusterFromVertex(n),i=this.m_topoGraph.getClusterFromVertex(r),o=this.m_topoGraph.getHalfEdgeConnector(t,i);if(o!==q){const t=this.m_topoGraph.getHalfEdgeTwin(o);this.m_topoGraph.setHalfEdgeUserIndex(o,e,1),this.m_topoGraph.setHalfEdgeUserIndex(t,e,2)}n=r,r=s.getNextVertex(n)}}}flushVertices_(e,t){const s=this.m_topoGraph.getShape(),n=s.hasSegmentParentage(),r=new k,i=s.insertPath(e,q);t.push(t[0]);const o=t.length;let a=q;for(let h=0;h<o;h++){const e=t[h];if(a=s.addVertex(i,e),!n)continue;const m=this.m_topoGraph.getClusterFromVertex(e);if(h>0&&this.m_topoGraph.isBreakNode(m)&&s.setSegmentParentageBreakVertex(a,!0),h<o-1){const e=this.m_topoGraph.getHalfEdgeConnector(m,this.m_topoGraph.getClusterFromVertex(t[h+1])),n=this.m_topoGraph.getSegmentParentage(e);s.setSegmentParentageAndBreak(a,n,h>0||this.m_topoGraph.isBreakNode(m)),this.m_topoGraph.isHalfEdgeCurve(e)&&(this.m_topoGraph.querySegmentXY(e,r),s.setSegmentToIndex(s.getVertexIndex(a),r.get().clone()))}}if(n){const e=this.m_topoGraph.getClusterFromVertex(t[o-1]);this.m_topoGraph.isBreakNode(e)&&s.setSegmentParentageBreakVertex(a,!0)}s.setClosedPath(i,!0)}processPolygonCuts_(e,t,s,n){const r=this.m_topoGraph.getGeometryID(s),o=this.m_topoGraph.getGeometryID(n),a=[],h=this.m_topoGraph.getShape(),m=this.m_topoGraph.createUserIndexForHalfEdges();for(let l=this.m_topoGraph.getFirstCluster();l!==q;l=this.m_topoGraph.getNextCluster(l)){const s=this.m_topoGraph.getClusterHalfEdge(l);if(s===q)continue;let n=s;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(n,m)){let s=n,l=n,g=!1,u=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,m,1),!g){if(0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){0!==(this.m_topoGraph.getHalfEdgeFaceParentage(s)&r)&&(l=s,g=!0)}}if(g){const t=this.m_topoGraph.getHalfEdgeOrigin(s),n=this.m_topoGraph.getClusterVertexIterator(t),r=this.m_topoGraph.getVertexFromVertexIterator(n);if(a.push(r),-1!==e){if(0!==(this.m_topoGraph.getHalfEdgeParentage(s)&o)){u|=this.m_topoGraph.getHalfEdgeUserIndex(s,e)}}}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==l);if(g&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(l))>0){const e=h.createGeometry(i.enumPolygon);this.flushVertices_(e,a),-1!==t&&h.setGeometryUserIndex(e,t,u)}a.length=0}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==s)}this.m_topoGraph.deleteUserIndexForHalfEdges(m)}cutPolygonPolyline_(e,t,s,n){this.m_topoGraph.removeSpikes_();let r=-1;-1!==e&&(r=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(r,s)),this.processPolygonCuts_(r,e,t,s),-1!==r&&(this.m_topoGraph.deleteUserIndexForHalfEdges(r),r=-1);const i=this.m_topoGraph.getShape();for(let o=i.getFirstGeometry();o!==q;o=i.getNextGeometry(o))o!==t&&o!==s&&n.push(o);n.sort((e,t)=>{const s=i.getFirstPath(e),n=i.getRingArea(s),r=i.getFirstPath(t),o=i.getRingArea(r);return n<o?-1:n>o?1:0})}cut(e,t,s,n,r){const i=this.m_topoGraph.getShape().getGeometryType(s),o=this.m_topoGraph.getShape().getGeometryType(n),h=g(i),m=g(o);if(2!==h||1!==m){if(1===h&&1===m){return void new sh(this,e,t,s,n,r).Do()}a("")}else this.cutPolygonPolyline_(t,s,n,r)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(e){const t=e.getGeometryType();if(t===i.enumEnvelope){const t=new T({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){const t=new G({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(o(t)){const t=new w({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.enumMultiPoint&&t!==i.enumPolyline&&t!==i.enumPolygon&&n("Unexpected geometry type"),e}dissolveNonSimplePolygons(e,t,s,n){l(t>0);const r=new V;let i=0,o=-1;for(let a=0,h=t;a<h;a++)2===e[a].getDimension()&&(-1===o&&(o=a),e[a].isEmpty()||(i++,r.addGeometry(e[a])));return 0===i?(l(o>=0),this.normalizeInputGeometry(e[o])):this.planarSimplifyPolygons(r,s,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,n,r,a,m,g){l(e>=1&&e<=2),l(r>0);const c=8&m?1:2,_=Ve.constructEmpty();let d=0,p=-1,f=!0;for(let s=0,o=r;s<o;s++)if(n[s].getDimension()===e&&(-1===p&&(p=s),!n[s].isEmpty())){p=s,d++;const t=Ve.constructEmpty();if(n[s].queryLooseEnvelope(t),_.mergeEnv3D(t),2===e&&f&&n[s].getGeometryType()===i.enumPolygon)if(16&m){const e=[0],t=n[s].getImpl().getIsSimple(0,e),r=this.m_bOGCOutput?5===t:de(t);f&&=r}else{const e=Be(n[s],0);f&&=e}}if(d<2&&(l(p>=0),0===d||!(16&m)))return this.normalizeInputGeometry(n[p]);if(!f){const e=fe(t?null:a,_.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(n,r,e,m)}const x=n.slice(0,r),y=fe(a,_.getEnvelope2D(),!0),P=10*Ee(y);let E=new Pe(0,0);if(g&&(E=Fe(a,_.getEnvelopeZs(),!0)),1===d&&1===e&&2===c&&!t)return g?qa():this.m_bOGCOutput?Aa(x[p],y,!1,-1,this.m_progressTracker,c,!1):Ma(x[p],y,!1,!1,-1,this.m_progressTracker,c,!1);const S=new Oe;S.startConstruction();let C=2===e?3:4,I=0;for(let u=0,w=r;u<w;u++){if(x[u].getDimension()!==e||x[u].isEmpty())continue;let n=x[u].getGeometryType();if(n!==i.enumEnvelope){if(o(n)?(x[u]=this.normalizeInputGeometry(x[u]),n=i.enumPolyline):l(h(n)),1===e){l(n===i.enumPolyline);let e=-1;if(g)l(0,"3d not implemented yet");else{const t=[0];e=x[u].getImpl().getIsSimple(y.total(),t)}if(this.m_bOGCOutput?5!==e:!de(e))if(t)C=-1;else{g?l(0,"3d not implemented yet"):this.m_bOGCOutput?x[u]=Aa(x[u],y,!1,-1,this.m_progressTracker,c,!1):x[u]=Ma(x[u],y,!1,!1,-1,this.m_progressTracker,c,!1);const e=[0];l(de(x[u].getImpl().getIsSimple(y.total(),e)))}}else{l(n===i.enumPolygon);const e=[0],t=x[u].getImpl().getIsSimple(0,e);l(De(t))}const r=x[u].getImpl();for(let e=0,t=r.getPathCount();e<t;e++){const t=s.constructEmpty();r.queryLoosePathEnvelope(e,t),t.inflateCoords(P,P),S.addEnvelope(I,t),I++}}else{l(n===i.enumEnvelope);const e=s.constructEmpty();x[u].queryLooseEnvelope(e),e.inflateCoords(P,P),S.addEnvelope(I,e),I++,C=-1}}S.endConstruction();const b=I,v=Je(b,-2147483647),N=Je(b,-1);let G=0;p=-1,I=0;for(let s=0,o=r;s<o;s++){if(x[s].getDimension()!==e)continue;if(-1===p&&(p=s),x[s].isEmpty())continue;p=s,G++;const t=x[s].getGeometryType();if(h(t)){for(let e=0,t=x[s].getPathCount();e<t;e++)N[I]=s,v[I]=-e-1,I++}else l(t===i.enumEnvelope),N[I]=s,v[I]=-1,I++}if(G<2&&2===e)return l(p>=0),this.normalizeInputGeometry(x[p]);let D=b;for(;S.next()&&D>0;){this.progress_();const e=S.getHandleA(),t=S.getHandleB(),s=S.getElement(e),n=S.getElement(t);N[s]!==N[n]&&(v[s]<0&&(D--,v[s]=-(v[s]+1)),v[n]<0&&(D--,v[n]=-(v[n]+1)))}const F=new V;let H=!1,k=0;for(let s=0,o=r;s<o;s++){if(x[s].getDimension()!==e||x[s].isEmpty())continue;const t=x[s].getGeometryType(),n=k;let r=0,o=0;const a=h(t)?x[s]:null;for(let e=n,i=v.length;e<i&&N[e]===s;e++)v[e]>=0&&(r++,o+=a?a.getPathSize(v[e]):u(x[s])),k++;if(o>.95*u(x[s])){F.addGeometry(this.normalizeInputGeometry(x[s]));for(let e=n;e<k;e++)v[e]<0&&(v[e]=-(v[e]+1))}else{if(0===r){H=!0;continue}{H=!0,l(h(t)),l(null!=a);const e=new T({vd:x[s].getDescription()}),r=new w({vd:x[s].getDescription()}),o=t===i.enumPolygon?e:r;for(let t=n;t<k;t++)v[t]>=0&&o.addPath(a,v[t],!0);F.addGeometry(o)}}}let A;if(F.getFirstGeometry()!==q){const s=2===e,n=t?fe(null,_.getEnvelope2D(),!0):y;let r=new Pe(0,0);if(g&&(r=t?Fe(null,_.getEnvelopeZs(),!0):E),2===e&&!(2&m)){F.collapseAllGeometriesToFirst();let e=0,t=null;if(F.hasCurves()&&!F.hasSegmentParentage()){t=new fa;const s=F.getEnvelope2D(this.m_progressTracker);e=da(n.total());aa(F,_a(n.total(),s),n.total(),12e3,t,null,this.m_progressTracker)}Vn(F,F.getFirstGeometry(),n.total(),this.m_progressTracker),null!==t&&t.stitchCurves(F,q,e,!0)}if(g)A=this.planarSimplify3DImpl_(F,n,r,c,!0);else if(2===e)A=this.planarSimplifyPolygons(F,n,s,t,-1,!1);else{const e=Ha();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=c,A=this.planarSimplifyPolylines(F,n,t,e,-1)}if(!H){const e=[0];C=A.getImpl().getIsSimple(n.total(),e)}}else l(H),l(p>=0),A=2===e?new T({vd:x[p].getDescription()}):new w({vd:x[p].getDescription()});if(H){let e=0;for(let t=0,s=v.length;t<s;t++){const s=N[t];if(!(s<0)&&v[t]<0){const n=x[s].getGeometryType(),r=h(n)?x[s]:null;if(r){const s=-(v[t]+1);e+=r.getPathSize(s)}else e+=4}}A.reserve(A.getPointCount()+e);for(let t=0,s=v.length;t<s;t++){const e=N[t];if(!(e<0)&&v[t]<0){const s=x[e].getGeometryType(),n=h(s)?x[e]:null;if(n){const e=-(v[t]+1);A.addPath(n,e,!0)}else s===i.enumEnvelope?A.addEnvelope(x[e],!1):(l(o(s)),A.addSegment(x[e],!0))}}}let M=0;if(2===e?-1!==C&&(C=3,M=t?0:y.total()):(l(1===e),t||-1===C||(M=y.total())),g||A.getImpl().setIsSimple(C,M),!t&&H)if(2===e){if(!g)return(new Eh).execute(A,a,!1,this.m_progressTracker);l(0,"3d not yet implemented")}else 1===e&&1!==c&&(A=g?Ba():Ua(this.m_bOGCOutput,A,c,this.m_progressTracker),A.getImpl().setIsSimple(C,M));return A}dissolveTopoGraphCommonEdges_(){const e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let s=this.m_topoGraph.getFirstCluster();s!==q;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let r=n;if(n!==q)do{this.progress_();if(1!==this.m_topoGraph.getHalfEdgeUserIndex(r,e)){const s=this.m_topoGraph.getHalfEdgeTwin(r);this.m_topoGraph.setHalfEdgeUserIndex(s,e,1),this.m_topoGraph.setHalfEdgeUserIndex(r,e,1);const n=this.m_topoGraph.getHalfEdgeFaceParentage(r);if(this.isGoodParentage(n)){const e=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(e)&&t.push(r)}}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==n)}this.m_topoGraph.deleteUserIndexForHalfEdges(e),this.m_topoGraph.deleteEdgesBreakFaces_(t)}chooseVertexByOrder(e,t,s,n){let r=vt(),i=q;for(let a=this.m_topoGraph.getClusterVertexIterator(e);a!==q;a=this.m_topoGraph.incrementVertexIterator(a)){const e=this.m_topoGraph.getVertexFromVertexIterator(a),n=t.getUserIndex(e,s);n>=0&&n<r&&(r=n,i=e)}l(i!==q);let o=t.getUserIndex(i,n);return o>0&&(t.setUserIndex(i,n,--o),0===o&&t.setUserIndex(i,s,-1)),i}chooseVertexFromCluster_(e,t){return this.m_topoGraph.getVertexDominantFromCluster(e,t)}chooseVertexFromVertexCluster_(e,t){return this.m_topoGraph.getVertexDominant(e,t)}collectPolygonPathsPreservingFrom_(e,t,s,n,r){const o=this.m_topoGraph.getShape();if(o.getGeometryType(e)!==i.enumPolygon)return;const a=o.hasSegmentParentage(),h=new k;for(let i=o.getFirstPath(e);i!==q;i=o.getNextPath(i)){const e=o.getFirstVertex(i);this.m_topoGraph.getClusterFromVertex(e);const m=this.m_topoGraph.getHalfEdgeFromVertex(e);if(m===q)continue;const l=this.m_topoGraph.getHalfEdgeUserIndex(m,s);if(1===l||2===l)continue;const g=this.m_topoGraph.getHalfEdgeFaceParentage(m);if(!this.isGoodParentage(g)){this.m_topoGraph.setHalfEdgeUserIndex(m,s,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(m,s,1);const u=o.insertPath(t,q);o.setClosedPath(u,!0);let c=m,_=e,d=this.m_topoGraph.getClusterFromVertex(_),p=1;do{this.progress_();const e=this.chooseVertexFromVertexCluster_(_,r),t=o.addVertex(u,e);if(this.m_topoGraph.isHalfEdgeCurve(c)&&(this.m_topoGraph.querySegmentXY(c,h),o.setSegmentToIndex(o.getVertexIndex(t),h.get().clone())),a){const e=this.m_topoGraph.getSegmentParentage(c);o.setSegmentParentageAndBreak(t,e,this.m_topoGraph.isBreakNode(d))}let i,m;-1!==n&&this.m_topoGraph.setClusterUserIndex(d,n,1),this.m_topoGraph.setHalfEdgeUserIndex(c,s,1),c=this.m_topoGraph.getHalfEdgeNext(c);do{i=1===p?o.getNextVertex(_):o.getPrevVertex(_),m=i!==q?this.m_topoGraph.getClusterFromVertex(i):q}while(m===d);const l=this.m_topoGraph.getHalfEdgeOrigin(c);if(l!==m){do{i=1===p?o.getPrevVertex(_):o.getNextVertex(_),m=i!==q?this.m_topoGraph.getClusterFromVertex(i):q}while(m===d);if(l!==m){m=l;const e=this.m_topoGraph.getClusterVertexIterator(m);i=this.m_topoGraph.getVertexFromVertexIterator(e)}else p=-p}d=m,_=i}while(c!==m)}}topoOperationPolygonPolygonHelper_(e,t,s,n,r,i){this.progress_(!0),e!==q&&this.collectPolygonPathsPreservingFrom_(e,s,r,i,n),t!==q&&this.collectPolygonPathsPreservingFrom_(t,s,r,i,n);const o=new k,a=this.m_topoGraph.getShape();a.dbgVerifyCurves();const h=a.hasSegmentParentage();for(let m=this.m_topoGraph.getFirstCluster();m!==q;m=this.m_topoGraph.getNextCluster(m)){const e=this.m_topoGraph.getClusterHalfEdge(m);if(e===q)continue;let t=e;do{this.progress_();const e=this.m_topoGraph.getHalfEdgeUserIndex(t,r);if(1!==e&&2!==e){const e=this.m_topoGraph.getHalfEdgeFaceParentage(t);if(this.isGoodParentage(e)){const e=a.insertPath(s,q);a.setClosedPath(e,!0);let m=t;do{const t=this.m_topoGraph.getHalfEdgeVertexIterator(m);let s=q;if(t!==q)s=this.m_topoGraph.getVertexFromVertexIterator(t);else{const e=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(m));s=this.m_topoGraph.getVertexFromVertexIterator(e),s=a.getNextVertex(s)}const l=this.chooseVertexFromVertexCluster_(s,n),g=a.addVertex(e,l);if(h){const e=this.m_topoGraph.getSegmentParentage(m),t=this.m_topoGraph.getHalfEdgeOrigin(m);a.setSegmentParentageAndBreak(g,e,this.m_topoGraph.isBreakNode(t))}if(this.m_topoGraph.isHalfEdgeCurve(m)&&(this.m_topoGraph.querySegmentXY(m,o),a.setSegmentToIndex(a.getVertexIndex(g),o.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(m,r,1),-1!==i){const e=this.m_topoGraph.getClusterFromVertex(l);this.m_topoGraph.setClusterUserIndex(e,i,1)}m=this.m_topoGraph.getHalfEdgeNext(m)}while(m!==t)}else this.m_topoGraph.setHalfEdgeUserIndex(t,r,2)}t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(t!==e)}}topoOperationPolygonPolygon_(e,t,s,n=!1){this.dissolveTopoGraphCommonEdges_();const r=this.m_topoGraph.getShape(),o=r.createGeometry(i.enumPolygon),a=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,o,s,a,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(a),n||er(r,o,3,this.m_bOGCOutput,q,this.m_progressTracker),o}topoOperationPolyline_(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(q,e,!1,s).first}topoOperationMultiPoint_(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),s=e.insertPath(t,q);for(let n=this.m_topoGraph.getFirstCluster();n!==q;n=this.m_topoGraph.getNextCluster(n)){const t=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(t)){let t=q;for(let s=this.m_topoGraph.getClusterVertexIterator(n);s!==q;s=this.m_topoGraph.incrementVertexIterator(s)){const n=this.m_topoGraph.getVertexFromVertexIterator(s);t===q&&(t=n);const r=e.getGeometryFromPath(e.getPathFromVertex(n)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=n;break}}e.addVertex(s,t)}}return t}intersection(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=g(s),i=g(n),o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);l(o>=0),l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o|h]=!0;let m=q;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(m=e),2===r&&2===i?this.topoOperationPolygonPolygon_(e,t,m):1===r&&i>0||1===i&&r>0?this.topoOperationPolyline_(m,this.m_bOGCOutput):0===r||0===i?this.topoOperationMultiPoint_():void a("")}topoOperationPolygonPolygonEx(e,t,s){const n=this.m_topoGraph.getShape(),r=n.createGeometry(i.enumPolygon),o=n.createGeometry(i.enumPolyline),a=n.createGeometry(i.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let h=q;const m=this.m_topoGraph.createUserIndexForHalfEdges(),l=this.m_topoGraph.createUserIndexForClusters();n.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,r,s,m,l),n.dbgVerifyCurves();const g=n.hasSegmentParentage(),u=new k;for(let i=this.m_topoGraph.getFirstCluster();i!==q;i=this.m_topoGraph.getNextCluster(i)){const e=this.m_topoGraph.getClusterHalfEdge(i);if(e===q)continue;let t=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(t,m),r=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),m),a=e|r;if(2===a){let h=this.m_topoGraph.getHalfEdgeParentage(t);if(this.isGoodParentage(h)){const c=n.insertPath(o,q);let _=t;const d=this.chooseVertexFromCluster_(i,s);let p=n.addVertex(c,d);if(g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);n.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,u),n.setSegmentToIndex(n.getVertexIndex(p),u.get().clone())),this.m_topoGraph.setClusterUserIndex(i,l,1);do{this.progress_();const i=this.m_topoGraph.getHalfEdgeTo(_),o=this.chooseVertexFromCluster_(i,s);if(p=n.addVertex(c,o),g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);n.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.setHalfEdgeUserIndex(_,m,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m,1),this.m_topoGraph.setClusterUserIndex(i,l,1),_=this.m_topoGraph.getHalfEdgeNext(_),e=this.m_topoGraph.getHalfEdgeUserIndex(_,m),r=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m),a=e|r,2!==a)break;if(h=this.m_topoGraph.getHalfEdgeParentage(_),!this.isGoodParentage(h)){this.m_topoGraph.setHalfEdgeUserIndex(_,m,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m,1);break}this.m_topoGraph.isHalfEdgeCurve(t)&&_!==t&&(this.m_topoGraph.querySegmentXY(t,u),n.setSegmentToIndex(n.getVertexIndex(p),u.get().clone()))}while(_!==t)}else this.m_topoGraph.setHalfEdgeUserIndex(t,m,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),m,1)}t=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(t!==e)}for(let i=this.m_topoGraph.getFirstCluster();i!==q;i=this.m_topoGraph.getNextCluster(i)){this.progress_();if(1===this.m_topoGraph.getClusterUserIndex(i,l))continue;const e=this.m_topoGraph.getClusterParentage(i);if(this.isGoodParentage(e)){h===q&&(h=n.insertPath(a,q));const e=this.m_topoGraph.getClusterVertexIterator(i);let t=q;if(e!==q){t=this.m_topoGraph.getVertexFromVertexIterator(e);const r=this.chooseVertexFromVertexCluster_(t,s);n.addVertex(h,r)}}}this.m_topoGraph.deleteUserIndexForClusters(l),this.m_topoGraph.deleteUserIndexForHalfEdges(m),n.dbgVerifyCurves(),er(n,r,3,this.m_bOGCOutput,q,this.m_progressTracker);const c=[q,q,q];return c[0]=a,c[1]=o,c[2]=r,c}topoOperationPolylinePolylineOrPolygonEx(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(q,e,!0,s)}topoOperationMultiPoint(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(i.enumMultiPoint),s=e.insertPath(t,q);for(let n=this.m_topoGraph.getFirstCluster();n!==q;n=this.m_topoGraph.getNextCluster(n)){const t=this.m_topoGraph.getClusterParentage(n);if(this.isGoodParentage(t)){let t=q;for(let s=this.m_topoGraph.getClusterVertexIterator(n);s!==q;s=this.m_topoGraph.incrementVertexIterator(s)){const n=this.m_topoGraph.getVertexFromVertexIterator(s);t===q&&(t=n);const r=e.getGeometryFromPath(e.getPathFromVertex(n)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=n;break}}e.addVertex(s,t)}}return t}intersectionEx(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Va(s),i=Va(n),o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);l(o>=0),l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o|h]=!0;let m=q;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(m=e),2===r&&2===i)return this.topoOperationPolygonPolygonEx(e,t,m);if(1===r&&i>0||1===i&&r>0){const{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(m,this.m_bOGCOutput);return[t,e]}if(0===r||0===i){const e=[];return e.push(this.topoOperationMultiPoint()),e}a("")}getCombinedHalfEdgeParentage(e){return this.m_topoGraph.getHalfEdgeParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(e)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(e))}prevailingDirection(e,t){const s=this.getCombinedHalfEdgeParentage(t),n=this.m_topoGraph.getHalfEdgeOrigin(t),r=this.m_topoGraph.getHalfEdgeTo(t);let i=0,o=0;for(let a=this.m_topoGraph.getClusterVertexIterator(n);a!==q;a=this.m_topoGraph.incrementVertexIterator(a)){const n=this.m_topoGraph.getVertexFromVertexIterator(a),h=e.getPathFromVertex(n),m=e.getGeometryFromPath(h),l=this.m_topoGraph.getGeometryID(m),g=e.getFirstVertex(h),u=0!==(l&s);u&&g===n&&(this.m_fromEdgeForPolylines=t);const c=e.getNextVertex(n);if(c!==q&&this.m_topoGraph.getClusterFromVertex(c)===r){if(i++,u){if(this.m_fromEdgeForPolylines===q&&g===c){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o++}}else{const s=e.getPrevVertex(n);if(s!==q&&this.m_topoGraph.getClusterFromVertex(s)===r&&(i--,u)){if(this.m_fromEdgeForPolylines===q&&g===s){const e=this.m_topoGraph.getHalfEdgeNext(t);this.isGoodParentage(this.getCombinedHalfEdgeParentage(e))&&(this.m_fromEdgeForPolylines=e)}o--}}}this.m_topoGraph.queryXY(n,this.m_dummyPt1),this.m_topoGraph.queryXY(r,this.m_dummyPt2);return(0!==o?o:i)*$e.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(e,t){const s=this.m_topoGraph.getHalfEdgePrev(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return q;const t=this.m_topoGraph.getHalfEdgeTwin(e);if(n===this.m_topoGraph.getHalfEdgeNext(t))return s}let r=n,i=q;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==q)return q;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(r))}return i}tryMoveThroughCrossroadForward(e,t){const s=this.m_topoGraph.getHalfEdgeNext(e),n=this.m_topoGraph.getHalfEdgeTwin(s);if(!t){const t=this.m_topoGraph.getHalfEdgeTwin(e);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return q;if(n===this.m_topoGraph.getHalfEdgePrev(t))return s}let r=n,i=q;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==q)return q;i=this.m_topoGraph.getHalfEdgeTwin(r)}r=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(r))}return i}isOnALoop(e,t){let s=e;const n=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let r=0;r<n;r++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,t))return!1;const n=this.m_topoGraph.getHalfEdgeNext(s);if(n===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=n,s===e)return!0}a("is_on_a_loop_")}restorePolylineParts(e,t,s,n,r,i,o,a,h,m){l(r===q&&i>=0&&o>=0||-1===i&&-1===o),l(-1===a&&1!==m.unsplitBehavior||-1!==a&&1===m.unsplitBehavior);const g=m.ogcRule,u=m.allCrossRoadsImpassable,c=1===m.unsplitBehavior,_=0===m.unsplitBehavior,d=this.m_topoGraph.getShape(),p=d.hasSegmentParentage();let f=e,x=this.m_topoGraph.getHalfEdgeTwin(f);const y=new k;this.m_fromEdgeForPolylines=q;let P=this.prevailingDirection(d,f),E=f,S=q,C=!1,I=!1,b=!1;if(!c)for(;;){const t=this.m_topoGraph.getHalfEdgePrev(f);if(t===x){b=!0;break}const n=this.m_topoGraph.getHalfEdgeNext(x);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(n))){C=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(t)!==n){if(u){C=!0;break}if(f=this.tryMoveThroughCrossroadBackwards(f,!0),f===q){C=!0;break}x=this.m_topoGraph.getHalfEdgeTwin(f)}else f=t,x=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(f,s)){b=!0;break}if(f===e){S=e,I=!0;break}const r=this.getCombinedHalfEdgeParentage(f);if(!this.isGoodParentage(r))break;E=f,P+=this.prevailingDirection(d,f)}if(S===q){for(f=e,x=this.m_topoGraph.getHalfEdgeTwin(f),S=f;;){const e=this.m_topoGraph.getHalfEdgeNext(f),t=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e));if(t){C=!0;break}if(e===x){b=!0;break}if(-1!==a){const e=this.m_topoGraph.getHalfEdgeOrigin(x);if(1===this.m_topoGraph.getClusterUserIndex(e,a)){C=!0;break}}const n=this.m_topoGraph.getHalfEdgePrev(x);if(this.m_topoGraph.getHalfEdgeTwin(e)!==n){if(t||u){C=!0;break}if(f=this.tryMoveThroughCrossroadForward(f,!0),f===q){C=!0;break}x=this.m_topoGraph.getHalfEdgeTwin(f)}else f=e,x=n;if(1===this.m_topoGraph.getHalfEdgeUserIndex(f,s)){b=!0;break}const r=this.getCombinedHalfEdgeParentage(f);if(!this.isGoodParentage(r))break;S=f,P+=this.prevailingDirection(d,f)}const t=this.m_topoGraph.getHalfEdgeOrigin(E);I=this.m_topoGraph.getHalfEdgeTo(S)===t}else if(this.m_fromEdgeForPolylines!==q){E=e,S=this.tryMoveThroughCrossroadBackwards(E,!1),l(S!==q);const t=this.m_topoGraph.getHalfEdgeTwin(E);this.m_topoGraph.getHalfEdgeNext(t)}let w=I;I||b||h&&(w=this.isOnALoop(e,s),w||(w=this.isOnALoop(x,s)));const v=P>=0;let N=!1;w&&C&&(I?(N=g,v&&(N||c||_)&&E!==e&&(l(!c),E=e,N=!1)):(c||v&&_)&&(E=e));let T=0;for(f=E;x=this.m_topoGraph.getHalfEdgeTwin(f),this.m_topoGraph.setHalfEdgeUserIndex(f,s,1),this.m_topoGraph.setHalfEdgeUserIndex(x,s,1),T++,f!==S;)f=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1);v||(S=ot(E,E=S),S=this.m_topoGraph.getHalfEdgeTwin(S),E=this.m_topoGraph.getHalfEdgeTwin(E));let G=d.insertPath(t,q);f=E;const D=this.m_topoGraph.getHalfEdgeOrigin(E);let V;V=-1!==i?this.chooseVertexByOrder(D,d,i,o):this.chooseVertexFromCluster_(D,r),this.m_topoGraph.isStrongPathNode(D)&&d.setStrongPathStart(G,!0);let F=d.addVertex(G,V),H=F;-1!==n&&this.m_topoGraph.setClusterUserIndex(D,n,1);let A=0;const M=N?Math.trunc((T+1)/2):-1;let U=q,B=!0,O=q;for(;;){if(p){const e=this.m_topoGraph.getSegmentParentage(f),t=this.m_topoGraph.getHalfEdgeOrigin(f);d.setSegmentParentageAndBreak(H,e,B||this.m_topoGraph.isBreakNode(t))}B=!1,this.m_topoGraph.isHalfEdgeCurve(f)&&(this.m_topoGraph.querySegmentXY(f,y),d.setSegmentToIndex(d.getVertexIndex(H),y.get().clone())),U!==q&&-1!==o&&d.addToUserIndex(U,o,-1);const e=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1),s=this.m_topoGraph.getHalfEdgeTo(f);let a;if(a=-1!==i?this.chooseVertexByOrder(s,d,i,o):this.chooseVertexFromCluster_(s,r),F=d.addVertex(G,a),O=s,-1!==n&&this.m_topoGraph.setClusterUserIndex(s,n,1),p&&this.m_topoGraph.isBreakNode(s)&&d.setSegmentParentageBreakVertex(F,!0),U=a,A++,N&&A===M&&(G=d.insertPath(t,q),F=d.addVertex(G,a),B=!0,-1!==o&&d.addToUserIndex(a,o,-1),U=q),f===S)break;f=e,H=F}O!==q&&this.m_topoGraph.isStrongPathNode(O)&&d.setStrongPathEnd(G,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,q,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,s,n){l(t===q||e===q);const r=this.m_topoGraph.getShape(),o=t=>t=e===q?t===q?r.getFirstGeometry():r.getNextGeometry(t):t===q?e:q,a=r.createGeometry(i.enumPolyline);let h=-1;s&&(h=this.m_topoGraph.createUserIndexForClusters());const m=this.m_topoGraph.createUserIndexForHalfEdges(),g=t===q?r.createUserIndex():-1,u=t===q?r.createUserIndex():-1;let c=-1;if(1===n.unsplitBehavior){c=this.m_topoGraph.createUserIndexForClusters();for(let e=o(q);e!==q;e=o(e))for(let t=r.getFirstPath(e);t!==q;t=r.getNextPath(t)){{const e=r.getFirstVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}if(!r.isClosedPath(t)){const e=r.getLastVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}}}if(t===q){let e=0;for(let t=o(q);t!==q;t=o(t))for(let s=r.getFirstPath(t);s!==q;s=r.getNextPath(s)){if(r.isClosedPath(s)){let t=r.getFirstVertex(s);for(let n=0,i=r.getPathSize(s);n<i;n++,t=r.getNextVertex(t))r.setUserIndex(t,g,e++),r.setUserIndex(t,u,2)}else{const t=r.getFirstVertex(s);r.setUserIndex(t,g,e++),r.setUserIndex(t,u,1);let n=r.getNextVertex(t);for(let i=1,o=r.getPathSize(s)-1;i<o;++i)r.setUserIndex(n,g,e++),r.setUserIndex(n,u,2),n=r.getNextVertex(n);r.setUserIndex(n,g,e++),r.setUserIndex(n,u,1)}}}for(let i=o(q);i!==q;i=o(i))for(let e=r.getFirstPath(i);e!==q;e=r.getNextPath(e)){let s=r.getFirstVertex(e);for(let i=0,o=r.getPathSize(e);i<o;i++,s=r.getNextVertex(s)){const e=this.m_topoGraph.getHalfEdgeFromVertex(s);if(e===q)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(e,m))continue;const r=this.getCombinedHalfEdgeParentage(e);if(this.isGoodParentage(r)){const s=0===i;this.restorePolylineParts(e,a,m,h,t,g,u,c,s,n)}}}let _=q;if(s){_=r.createGeometry(i.enumMultiPoint);let e=q;for(let s=this.m_topoGraph.getFirstCluster();s!==q;s=this.m_topoGraph.getNextCluster(s)){this.progress_();if(1!==this.m_topoGraph.getClusterUserIndex(s,h)){const n=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(n)){e===q&&(e=r.insertPath(_,q));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==q){let i;this.m_topoGraph.getVertexFromVertexIterator(n),i=-1!==g?this.chooseVertexByOrder(s,r,g,u):this.chooseVertexFromCluster_(s,t),r.addVertex(e,i)}}}}}return-1!==u&&r.removeUserIndex(u),-1!==g&&r.removeUserIndex(g),-1!==h&&r.removeUserIndex(h),this.m_topoGraph.deleteUserIndexForHalfEdges(m),mt(a,_)}difference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=g(s),i=g(n);if(r>i)return e;const o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o]=!0,2===r&&2===i){let s=q;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=e),this.topoOperationPolygonPolygon_(e,t,s)}if(1===r&&2===i){const t=Ha();return t.allCrossRoadsImpassable=!1,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,q,!1,t).first}if(1===r&&1===i){const t=Ha();return t.allCrossRoadsImpassable=!0,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,q,!1,t).first}if(0===r)return this.topoOperationMultiPoint_();a("")}symmetricDifference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),r=Va(s),i=Va(n),o=this.m_topoGraph.getGeometryID(e),h=this.m_topoGraph.getGeometryID(t);return l(o>=0),l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|h),this.m_maskLookup[o]=!0,this.m_maskLookup[o]=!0,this.m_maskLookup[h]=!0,2===r&&2===i?this.topoOperationPolygonPolygon_(e,t,q):1===r&&1===i?this.topoOperationPolyline_(q,this.m_bOGCOutput):0===r&&0===i?this.topoOperationMultiPoint():void a("")}planarSimplifyNoCrackingAndCluster(e,t,s,n){this.m_bOGCOutput=e,this.m_topoGraph=new tn;const r=t.getFillRule(s),o=t.getGeometryType(s);if(1!==r||o===i.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const h=this.m_topoGraph.getGeometryID(s);if(l(h>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=h+1,this.m_maskLookup[h]=!0,t.getGeometryType(s)===i.enumPolygon||1===r&&t.getGeometryType(s)!==i.enumMultiPoint){t.setFillRule(s,0);const i=this.topoOperationPolygonPolygon_(s,q,q);if(t.swapGeometry(i,s),t.removeGeometry(i),1===r&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,s,n)}else if(t.getGeometryType(s)===i.enumPolyline){const e=Ha();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=n;const r=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(r,s),t.removeGeometry(r)}else if(t.getGeometryType(s)===i.enumMultiPoint){const e=this.topoOperationMultiPoint_();t.swapGeometry(e,s),t.removeGeometry(e)}else a("");return!0}unsplitPolylineExact(e){return l(0),new w}planarSimplifyPolylines(e,t,s,n,r){for(let _=e.getFirstGeometry();_!==q;_=e.getNextGeometry(_)){const t=e.getGeometryType(_);l(t===i.enumPolyline)}let o=0,a=0,h=null;if(e.hasCurves()&&!e.hasSegmentParentage()){h=new fa;const s=e.getEnvelope2D(this.m_progressTracker);a=da(t.total());const n=_a(t.total(),s);o=pa(n,a),aa(e,n,t.total(),12e3,h,null,this.m_progressTracker)}{const s=Ia(t.add(o));e.filterClosePoints(s,!1,!1,!1,q)}if(this.m_topoGraph=new tn,4!==r&&5!==r)if(null===h&&s){const n=new Dn(this.m_progressTracker,!1);n.sweepVertical(e,t.total()),n.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(o),this.m_progressTracker,!0,!1),s=!1;else s=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const m=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,m,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(s&&null===h),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,n,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(m);l(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0;const u=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),n);null!==h&&h.stitchCurves(e,u,a,!0);const c=e.getGeometry(u);return s||c.getImpl().setIsSimple(4,t.total()),c}planarSimplifyMultiPoints(e,t,s,n){for(let m=e.getFirstGeometry();m!==q;m=e.getNextGeometry(m)){const t=e.getGeometryType(m);l(t===i.enumMultiPoint)}this.m_topoGraph=new tn,4!==n&&5!==n?(ya(e,t,this.m_progressTracker,!0,!1),s=!1):s=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();const r=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,r,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const o=this.m_topoGraph.getGeometryID(r);l(o>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=o+1,this.m_maskLookup[o]=!0;const a=this.topoOperationMultiPoint(),h=e.getGeometry(a);return s||h.getImpl().setIsSimple(4,t.total()),h}planarSimplifyPolygons(e,t,s,n,r,o){for(let f=e.getFirstGeometry();f!==q;f=e.getNextGeometry(f)){const t=e.getGeometryType(f);l(t===i.enumPolygon||t===i.enumPolyline&&s)}let a=0,h=0,m=null;if(e.hasCurves()&&!e.hasSegmentParentage()){m=new fa;const s=e.getEnvelope2D(this.m_progressTracker);h=da(t.total());const n=_a(t.total(),s);a=pa(n,h),aa(e,n,t.total(),12e3,m,null,this.m_progressTracker)}if(o){ya(e,t.add(a),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==q;t=e.getNextGeometry(t))e.getGeometryType(t)===i.enumPolygon&&er(e,t,-1,!1,q,this.m_progressTracker)}if(this.m_topoGraph=new tn,o||4===r||5===r)n=!1;else if(null===m&&n){const s=new Dn(this.m_progressTracker,!1);s.sweepVertical(e,t.total()),s.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),n=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(a),this.m_progressTracker,!0,!1),n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const g=e.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,g,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,g,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return l(n&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const u=this.m_topoGraph.getGeometryID(g);l(u>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=u+1,this.m_maskLookup[u]=!0,e.setFillRule(g,0);const c=this.m_bOGCOutput&&s,_=c;let d=this.topoOperationPolygonPolygon_(g,q,q,_);if(c){this.m_topoGraph.removeShape(),this.m_topoGraph=null,e.removeGeometry(g),this.m_topoGraph=new tn,this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,d,this.m_progressTracker);d=this.topoOperationPolygonPolygon_(d,q,q,!1)}null!==m&&m.stitchCurves(e,d,h,!0);const p=e.getGeometry(d);return p.setFillRule(0),n?p.getImpl().setIsSimple(3,0):(p.getImpl().setIsSimple(4,t.total()),p.getImpl().updateOGCFlagsProtected()),p}planarSimplify3DImpl_(e,t,s,n,r){return l(0),{}}planarSimplifyImpl_(e,t,s,n,r,o,h,m){if(e.isEmpty())return e.clone();const l=e.getGeometryType(),g=new V,u=g.addGeometry(e);if(De(r)&&l===i.enumPolygon&&(s=!1,g.setFillRule(u,0)),m&&(e.hasAttribute(1)&&g.replaceNaNs(1,0),g.removeNaNVertices()),l===i.enumPolygon||l===i.enumPolyline&&s)return this.planarSimplifyPolygons(g,t,s,n,r,!1);if(l===w.type){const e=Ha();return e.allCrossRoadsImpassable=!0,e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=h,this.planarSimplifyPolylines(g,t,n,e,r)}if(l===i.enumMultiPoint)return this.planarSimplifyMultiPoints(g,t,n,r);a("what else?")}}function Qa(e,t,s,n){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return n?e.createInstance():new ye({copy:e});const r=[new $e],i=[0],o=2===t.getDimension();return 1!==t.getDimension()&&2!==t.getDimension()&&a(""),r[0]=e.getXY(),o?Wo(t,r,1,s.total(),i):jo(t,r,1,s.total(),i),0===i[0]?e.createInstance():e}function Ja(e,t,s,n){const r=e.createInstance(),i=ut($e,100),o=new Array(100),h=e.getPointCount();let m=!0;const l=2===t.getDimension();1!==t.getDimension()&&2!==t.getDimension()&&a("");for(let a=0;a<h;){const n=e.queryCoordinates(i,i.length,a,-1)-a;l?Wo(t,i,n,s.total(),o):jo(t,i,n,s.total(),o);let h=0;for(let t=0;t<n;t++){0===o[t]&&(m&&(m=!1,r.addPoints(e,0,a)),h!==t&&r.addPoints(e,a+h,a+t),h=t+1)}m||h===n||r.addPoints(e,a+h,a+n),a+=n}return m?e:r}function $a(e,t,s,n){const r=e.getGeometryType();if(r===i.enumEnvelope){const t=new T({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(r===i.enumPoint&&("|"===n||"^"===n)){const t=new G({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(r===i.enumLine){const t=new w({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(r===i.enumMultiPoint&&"-"===n&&t.getGeometryType()===i.enumPoint){const t=new ye({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(r===i.enumMultiPoint&&"&"===n&&t.getGeometryType()===i.enumPoint){const t=new ye({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function eh(e){const t=e.getGeometryType();if(t===i.enumEnvelope){const t=new T({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(t===i.enumPoint){const t=new G({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(Da(t)){const t=new w({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}return t!==i.enumMultiPoint&&t!==i.enumPolyline&&t!==i.enumPolygon&&n("Unexpected geometry type"),e}function th(e,t,s,n){const r=s===q?e.getClusterHalfEdge(t):s;let i=r;l(e.getHalfEdgeOrigin(r)===t);do{n(i),i=e.getHalfEdgeNext(e.getHalfEdgeTwin(i))}while(i!==r)}class sh{constructor(e,t,s,n,r,i){this.m_rParent=e,this.m_rTopoGraph=e.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(n),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(r),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=t,this.m_sideIndex=s,this.m_cuttee=n,this.m_cutter=r,this.m_rCutHandles=i,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let o=this.m_rShape.getFirstPath(this.m_cuttee);o!==q;o=this.m_rShape.getNextPath(o)){let e=0;const t=this.m_rShape.getPathSize(o);for(let s=this.m_rShape.getFirstVertex(o);e<t;e++,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(s)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(e){return 8|e}classifyStandardCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),o=r===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),h=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),m=this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));let l=1,g=32,u=32;if(th(this.m_rTopoGraph,t,m,e=>{e===h&&(l=2),e===o&&(g=l),e===a&&(u=l)}),this.m_bConsiderTouch)32!==g&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|g),32!==u&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u);else{if(32===g||32===u)return 1;if(g===u&&!(o===h||o===m||a===h||a===m))return 1;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|g),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|u)}return 0}classifyTouchCut(e,t,s,n){const r=this.m_rShape.getPrevVertex(e),i=this.m_rShape.getNextVertex(e),o=r===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),h=s===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),m=n===q?q:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(n));if(!this.m_bConsiderTouch){let t;return(t=h===o||m===o)?this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))):(t=h===a||m===a)&&this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),t?0:1}if(o===q)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===q)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;if(o===a)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(m!==q){if(o===m)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===m)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=1;th(this.m_rTopoGraph,t,m,t=>{if(t===o){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=2}else if(t===a){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=2}})}else{if(o===h)return this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex))),0;if(a===h)return this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex))),0;let s=2;th(this.m_rTopoGraph,t,h,t=>{if(t===o){const e=this.m_rShape.getUserIndex(r,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(r,this.m_cutteeBreadcrumbsIndex,e),s=1}else if(t===a){const t=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,t),s=1}})}return 0}classifyCutVertex(e,t){let s=0,n=0;for(let r=this.m_rTopoGraph.getClusterVertexIterator(t);r!==q;r=this.m_rTopoGraph.incrementVertexIterator(r)){const i=this.m_rTopoGraph.getVertexFromVertexIterator(r);if(this.m_rShape.getGeometryFromVertex(i)===this.m_cutter){n++;const r=this.m_rShape.getPrevVertex(i),o=this.m_rShape.getNextVertex(i);s+=r===q||o===q?this.classifyTouchCut(e,t,r,o):this.classifyStandardCut(e,t,r,o)}}n&&s===n&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(e,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let i=this.m_rShape.getFirstPath(this.m_cuttee);i!==q;i=this.m_rShape.getNextPath(i)){const e=this.m_rShape.getPathSize(i);let t=this.m_rShape.getFirstVertex(i);for(let s=0;s<e;++s,t=this.m_rShape.getNextVertex(t))this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,0);t=this.m_rShape.getFirstVertex(i);for(let s=0;s<e;++s,t=this.m_rShape.getNextVertex(t)){const e=this.m_rTopoGraph.getClusterFromVertex(t);this.m_rTopoGraph.getClusterParentage(e)===this.m_IDBoth&&this.classifyCutVertex(t,e)}}const e=(e,t)=>{let s=this.m_rShape.getUserIndex(e,this.m_cutteeBreadcrumbsIndex);const n=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(e),this.m_rTopoGraph.getClusterFromVertex(t));return(this.m_rTopoGraph.getHalfEdgeParentage(n)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let i=this.m_rShape.getFirstPath(this.m_cuttee);i!==q;i=this.m_rShape.getNextPath(i)){let t=this.m_rShape.getFirstVertex(i);const s=this.m_rShape.isClosedPath(i),n=this.m_rShape.getPathSize(i)+(s?1:0);let r=1,o=32;for(let i=this.m_rShape.getNextVertex(t);r<n;++r,t=i,i=this.m_rShape.getNextVertex(i)){const s=e(t,i);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=s),32!==o&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,o|s)}t=this.m_rShape.getLastVertex(i);let a=32;r=1;for(let i=this.m_rShape.getPrevVertex(t);r<n;++r,t=i,i=this.m_rShape.getPrevVertex(i)){const s=e(i,t);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=s),32!==a&&this.m_rShape.setUserIndex(i,this.m_cutteeBreadcrumbsIndex,a|s)}}let t=q,s=q,n=32;const r=this.m_rShape.hasSegmentParentage(),o=new k;for(let a=this.m_rShape.getFirstPath(this.m_cuttee);a!==q;a=this.m_rShape.getNextPath(a)){const e=this.m_rShape.isClosedPath(a),h=this.m_rShape.getPathSize(a)+(e?1:0);let m=1,l=this.m_rShape.getFirstVertex(a),g=q,u=!0;for(let a=this.m_rShape.getNextVertex(l);m<h;++m,a=this.m_rShape.getNextVertex(a)){let e=this.m_rShape.getUserIndex(l,this.m_cutteeBreadcrumbsIndex);8===e?e=3:(e&=-9,4&e?e=4:3&~e||(e=3)),e!==n?(t!==q&&(g=this.m_rShape.addVertex(s,l),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n)),t=this.m_rShape.createGeometry(i.enumPolyline),s=this.m_rShape.insertPath(t,q),n=e,u=!0):this.m_rShape.getUserIndex(l,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==e&&(g=this.m_rShape.addVertex(s,l),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),s=this.m_rShape.insertPath(t,q),u=!0),g=this.m_rShape.addVertex(s,l);const h=this.m_rTopoGraph.getClusterFromVertex(l);!u&&r&&this.m_rTopoGraph.isBreakNode(h)&&this.m_rShape.setSegmentParentageBreakVertex(g,!0);const m=this.m_rTopoGraph.getHalfEdgeFromVertex(l);if(r){const e=this.m_rTopoGraph.getSegmentParentage(m);this.m_rShape.setSegmentParentageAndBreak(g,e,u||this.m_rTopoGraph.isBreakNode(h))}this.m_rTopoGraph.isHalfEdgeCurve(m)&&(this.m_rTopoGraph.querySegmentXY(m,o),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(g),o.get().clone())),l=a,u=!1}g=this.m_rShape.addVertex(s,l),r&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),this.m_rCutHandles.push(t),this.m_rShape.setGeometryUserIndex(t,this.m_sideIndex,n),t=q,s=q,n=32}}}function nh(e,t,s){return new Ka(s).linesToPolygonsImpl(e,t)}function rh(e,t,n,r,h){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.enumPoint)return mh(e,r);const l=ge(t,e,!1).total();if(m===i.enumEnvelope){const t=e,n=new s;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(o(m)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),oh(i,t,n,r,h)}const g=[0],u=e.getImpl().getIsSimple(l,g);let c=n?-1:u;if(de(c)||0===c)return c;const _=new Ph(e,t,c,h,!1);m===i.enumMultiPoint||m===i.enumPolyline||m===i.enumPolygon?c=_.isSimplePlanarImpl():a("");return e.getImpl().setIsSimple(c,l),r&&r.assign(_.m_nonSimpleResult),c}function ih(e,t,n,r,h){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.enumPoint)return mh(e,r);const l=ge(t,e,!1).total();if(m===i.enumEnvelope){const t=e,n=new s;return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(o(m)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),ih(i,t,n,r,h)}y(m),x(m)||d("OGC simplify is not implemented for this geometry type");const g=[0],u=e.getImpl().getIsSimple(l,g);let c=n?-1:u;if(5===c||0===c)return c;const _=new Ph(e,t,c,h,!0);m===i.enumMultiPoint||m===i.enumPolyline||m===i.enumPolygon?(c=_.isSimplePlanarImpl(),de(c)&&(c=5)):a("");return e.getImpl().setIsSimple(c,l),r&&r.assign(_.m_nonSimpleResult),c}function oh(e,t,n,r,h){if(r&&(r.m_reason=0,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),e.isEmpty())return 5;const m=e.getGeometryType();if(m===i.enumPoint)return mh(e,r);const l=ge(t,e,!1).total();if(m===i.enumEnvelope){const t=e,n=s.constructEmpty();return t.queryEnvelope(n),n.isDegenerate(l)?(r&&(r.m_reason=4,r.m_vertexIndex1=-1,r.m_vertexIndex2=-1),0):5}if(o(m)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),oh(i,t,n,r,h)}const g=[0],u=e.getImpl().getIsSimple(l,g);let c=n?-1:u;if(-1!==c)return c;const _=new Ph(e,t,c,h,!1);return m===i.enumMultiPoint?c=_.multipointIsSimpleAsFeature():m===i.enumPolyline?c=_.polylineIsSimpleAsFeature():m===i.enumPolygon?c=_.polygonIsSimpleAsFeature():a(""),e.getImpl().setIsSimple(c,l),r&&r.assign(_.m_nonSimpleResult),c}function ah(e,t,n,r){if(e.isEmpty())return e;const h=e.getGeometryType();if(h===i.enumPoint){const t=new ts;if(mh(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(h===i.enumEnvelope){const n=ge(t,e,!0).total(),r=e,i=s.constructEmpty();return r.queryEnvelope(i),i.isDegenerate(n)?r.createInstance():e}if(o(h)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),ah(i,t,n,r)}y(h);const m=ge(t,e,!1).total(),l=[0],g=e.getImpl().getIsSimple(m,l),u=n?-1:g;if(de(u)){if(h===i.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}if((h===i.enumMultiPoint||h===i.enumPolyline)&&u>=1)return e;const c=new Ph(e,t,u,r,!1);let _;return h===i.enumMultiPoint?_=c.multipointSimplifyAsFeature():h===i.enumPolyline?_=c.polylineSimplifyAsFeature():h===i.enumPolygon?_=c.polygonSimplifyAsFeature():a(""),_}function hh(e,t,n,r){if(e.isEmpty())return e;const a=e.getGeometryType();if(a===i.enumPoint){const t=new ts;if(mh(e,t),3===t.m_reason){const t=e.clone();return t.replaceNaNs(1,0),t}return 2===t.m_reason?e.createInstance():e}if(a===i.enumEnvelope){const n=e,r=new s;n.queryEnvelope(r);const i=ge(t,e,!0).total();return r.isDegenerate(i)?n.createInstance():e}if(o(a)){const s=e,i=new w({vd:s.getDescription()});return i.addSegment(s,!0),hh(i,t,n,r)}y(a),x(a)||d("OGC simplify is not implemented for this geometry type");const h=ge(t,e,!1).total(),m=[0],l=e.getImpl().getIsSimple(h,m),g=n?-1:l;if(5===g){if(a===i.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}return Aa(e,ge(t,e,!0),!1,g,r,0,!0)}function mh(e,t){const s=e.getX(),n=e.getY();if(!Number.isFinite(s)||!Number.isFinite(n))return t&&(t.m_reason=2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0;if(e.hasAttribute(1)){const s=e.getZ();if(!Number.isFinite(s))return t&&(t.m_reason=Number.isNaN(s)?3:2,t.m_vertexIndex1=-1,t.m_vertexIndex2=-1),0}return 5}class lh{constructor(){this.m_segment=null,this.m_vertexIndex=-1,this.m_pathIndex=-1,this.m_flags=0}setReversed(e){this.m_flags&=-2,this.m_flags=this.m_flags|(e?1:0)}getReversed(){return!!(1&this.m_flags)}getRightSide(){return this.getReversed()?0:1}}function gh(){return{x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1}}function uh(e,t,s,n,r){return{x:e,y:t,ipath:s,ivertex:n,ipolygon:r}}function ch(e,t){return e.x===t.x&&e.y===t.y&&e.ipath===t.ipath&&e.ivertex===t.ivertex&&e.ipolygon===t.ipolygon}function _h(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.ipolygon=t.ipolygon}function dh(){return{x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1}}function ph(e,t,s,n,r,i){return{x:e,y:t,ipath:s,ivertex:n,bBoundary:r,bEndPoint:i}}function fh(e,t){e.x=t.x,e.y=t.y,e.ipath=t.ipath,e.ivertex=t.ivertex,e.bBoundary=t.bBoundary,e.bEndPoint=t.bEndPoint}class xh extends Xe{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_xy.read(2*t)-this.m_helper.m_xy.read(2*n);return r<0?-1:r>0?1:0}}class yh extends Xe{constructor(e){super(),this.m_helper=e}compare(e,t,s){const n=e.getElement(s),r=this.m_helper.m_edges[t],i=this.m_helper.m_edges[n],o=r.getReversed(),a=i.getReversed();let h=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(h===m){const e=o?r.m_segment.getStartY():r.m_segment.getEndY(),t=a?i.m_segment.getStartY():i.m_segment.getEndY(),s=Math.min(e,t);let n=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;n===this.m_helper.m_yScanline&&(n=s),h=r.m_segment.intersectionOfYMonotonicWithAxisX(n,0),m=i.m_segment.intersectionOfYMonotonicWithAxisX(n,0)}return h<m?-1:h>m?1:0}}class Ph{constructor(e,t,s,n,r){this.m_multiVertexGeom=null,this.m_edges=[],this.m_freeEdges=[],this.m_lineEdgesRecycle=[],this.m_newEdges=[],this.m_recycledSegIter=null,this.m_crossOverHelperList=new Se,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new Ce,this.m_xyToNode1=null,this.m_xyToNode2=null,this.m_pathOrientations=null,this.m_pathParentage=null,this.m_xy=null,this.m_pairs=[],this.m_pairIndices=null,this.m_pathsForOGCTests=[],this.m_curveStitcher=null,this.m_editShape=null,this.m_multiPathStitcher=null,this.m_nonSimpleResult=new ts,this.m_progressCounter=0,this.m_progressTracker=n,this.m_geometry=e,this.m_knownSimpleResult=s,this.m_sr=t;const i=ge(t,e,!1);this.m_toleranceIsSimple=i,this.m_toleranceIsSimpleClustering=Ee(i),this.m_toleranceIsSimpleCracking=Ie(i),this.m_toleranceSimplify=ge(t,e,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=r,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;const e=this.m_geometry.getGeometryType();return h(e)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?h(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===i.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return l(0),7}generateSortedPairs(e){let t=null;h(e.getGeometryType())&&(t=e);const s=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&null!==t,n=e.getPointCount();this.m_xy=e.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new be(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let a=0;a<n;a++)if(this.m_pairs.push(2*a),this.m_pairs.push(2*a+1),this.m_pairIndices.add(2*a),this.m_pairIndices.add(2*a+1),s){for(;a>=t.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const i=new we,o={parent:this,workPt:new $e,userSort(e,t,n){n.sort(e,t,(e,t)=>this.parent.compareVerticesForPlanarClustering(e,t,s))},getValue(e){const t=this.parent.m_pairs[e],s=t>>1;this.parent.m_xy.queryPoint2D(2*s,this.workPt);return this.workPt.y+(1&t?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};i.sort(this.m_pairIndices,0,2*n,o)}_TestToleranceDistancePlanar(e,t){const s=this.m_xy.read(2*e),n=this.m_xy.read(2*e+1),r=this.m_xy.read(2*t),i=this.m_xy.read(2*t+1);if(!!ln(s,n,r,i,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)){if(0===this.m_geometry.getDimension())return!1;return s===r&&n===i}return!0}checkStructure(){const e=this.m_geometry.getGeometryType();if(h(e)){const e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===i.enumPolygon?3:2;for(let s=0,n=e.getPathCount();s<n;s++)if(e.getPathSize(s)<t){if(e.hasNonLinearSegments()&&e.hasNonLinearSegmentsPath(s)&&e.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new ts(1,s,0),!1}}if(x(e)){const e=this.m_geometry.getImpl(),t=e.getAttributeStreamRef(0);for(let s=0,n=e.getPointCount();s<n;s++){if(!t.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new ts(2,s,0),!1}if(this.m_geometry.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(!Number.isFinite(e))return Number.isNaN(e)?this.m_nonSimpleResult=new ts(3,s,0):this.m_nonSimpleResult=new ts(2,s,0),!1}}}return!0}checkDegenerateSegments(e){const t=this.m_geometry.getImpl(),s=t.querySegmentIterator(),n=t.hasAttribute(1),r=n?ve(this.m_sr,t,!1).total():0,i=t.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const t=s.nextSegment();let a=t.calculateLowerLength2D();if(!(a>o)&&!(i&&t.isCurve()&&(a=t.calculateLength2D(),a>o))){if(e&&n){const e=t.getStartAttributeAsDbl(1,0),s=t.getEndAttributeAsDbl(1,0);if(Math.abs(s-e)>r)continue}return this.m_nonSimpleResult=new ts(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return l(0),!1}_CheckClustering(){const e=this.m_geometry.getImpl();this.generateSortedPairs(e);const t=e.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new xh(this)),this.m_AET.setCapacity(t);for(let s=0,n=2*t;s<n;s++){this.progress_();const e=this.m_pairIndices.read(s),t=this.m_pairs[e],n=t>>1;if(1&t){const e=this.m_AET.search(n),t=this.m_AET.getPrev(e),s=this.m_AET.getNext(e);if(this.m_AET.deleteNode(e),t!==Ce.st_nullNode()&&s!==Ce.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new ts(5,this.m_AET.getElement(t),this.m_AET.getElement(s)),!1}else{const e=this.m_AET.addElement(n),t=this.m_AET.getPrev(e);if(t!==Ce.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(t),n))return this.m_nonSimpleResult=new ts(5,n,this.m_AET.getElement(t)),!1;const s=this.m_AET.getNext(e);if(s!==Ce.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),n))return this.m_nonSimpleResult=new ts(5,n,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const e=this.m_geometry.getImpl(),t=e.getPointCount();return!e.hasNonLinearSegments()&&t<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new V,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new fa;const e=s.constructEmpty();this.m_geometry.queryEnvelope(e);const t=_a(this.m_toleranceSimplify.total(),e),n=new ts;if(la(this.m_editShape,t,this.m_toleranceSimplify.total(),12e3,n,this.m_curveStitcher,null,this.m_progressTracker),0!==n.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(n),!1}const e=new ts;return Mn(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,e,this.m_progressTracker)?(null!=this.m_curveStitcher?(e.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex1),e.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,e.m_vertexIndex2),this.m_curveStitcher=null):(e.m_vertexIndex1=this.m_editShape.getVertexIndex(e.m_vertexIndex1),e.m_vertexIndex2=this.m_editShape.getVertexIndex(e.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(e),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator();for(;t.nextPath();)for(;t.hasNextSegment();){const e=t.nextSegment();if(!t.isLastSegmentInPath()||!t.isLastPath()){s.resetTo(t);do{for(;s.hasNextSegment();){const n=s.nextSegment(),r=B(!0,e,n,this.m_toleranceIsSimpleCracking,!0);if(r){const e=2===r?7:6;return this.m_nonSimpleResult=new ts(e,t.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let e=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),e=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(e)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=e.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const t=[],s=e.getPointCount();let n=Number.NaN,r=0;for(let i=0,o=2*s;i<o;i++){this.progress_();const e=this.m_pairIndices.read(i),s=this.m_pairs[e];if(1&s)continue;const o=s>>1,a=this.m_xy.read(2*o),h=this.m_xy.read(2*o+1);if(t.length&&(a!==n||h!==r)){if(!this.processBunchForSelfIntersectionTest(t))return!1;t.length=0}t.push(o),n=a,r=h}return!!this.processBunchForSelfIntersectionTest(t)}checkSelfIntersectionsPolylinePlanar(){const e=this.m_geometry.getImpl(),t=[];for(let o=0,a=e.getPathCount();o<a;o++)t.push(e.isClosedPathInXYPlane(o));const s=dh();let n,r,i;{const o=this.m_pairIndices.read(0),a=this.m_pairs[o]>>1,h=this.m_xy.readPoint2D(2*a),m=this.m_pathsForOGCTests[a];n=t[m],r=e.getPathStart(m),i=e.getPathEnd(m)-1,s.bEndPoint=a===r||a===i,this.m_bOGCRestrictions?s.bBoundary=!n&&s.bEndPoint:s.bBoundary=s.bEndPoint,s.ipath=m,s.x=h.x,s.y=h.y,s.ivertex=a}for(let o=1,a=this.m_pairIndices.size();o<a;o++){const a=this.m_pairIndices.read(o),h=this.m_pairs[a];if(1&h)continue;const m=h>>1,l=this.m_xy.readPoint2D(2*m),g=this.m_pathsForOGCTests[m];let u;g!==s.ipath&&(n=t[g],r=e.getPathStart(g),i=e.getPathEnd(g)-1);const c=m===r||m===i;u=this.m_bOGCRestrictions?!n&&c:c;const _=ph(l.x,l.y,g,m,u,c);if(_.x===s.x&&_.y===s.y)if(this.m_bOGCRestrictions){if(!(_.bBoundary&&s.bBoundary||_.ipath===s.ipath&&_.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new ts(10,_.ivertex,s.ivertex),!1}else if(!_.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new ts(7,_.ivertex,s.ivertex),!1;fh(s,_)}return!0}checkSelfIntersectionsPolylinePlanar3D(e){return l(0),!1}checkSelfIntersectionsPolygonsOGC(){const e=this.m_geometry.getImpl(),t=[];let s=-1,n=!1;for(let l=0,g=e.getPathCount();l<g;l++)e.isExteriorRingOGC(l)&&(n=!1,s++,l<g-1&&(e.isExteriorRingOGC(l+1)||(n=!0))),t.push(n?s:-1);const r=gh();{const e=this.m_pairIndices.read(0),s=this.m_pairs[e]>>1,n=this.m_xy.readPoint2D(2*s),i=this.m_pathsForOGCTests[s];r.ipath=i,r.x=n.x,r.y=n.y,r.ivertex=s,r.ipolygon=t[i]}const i=[];for(let l=1,g=this.m_pairIndices.size();l<g;l++){const e=this.m_pairIndices.read(l),s=this.m_pairs[e];if(1&s)continue;const n=s>>1,o=this.m_xy.readPoint2D(2*n),a=this.m_pathsForOGCTests[n],h=uh(o.x,o.y,a,n,t[a]);if(h.x===r.x&&h.y===r.y){if(h.ipath===r.ipath)return this.m_nonSimpleResult=new ts(11,h.ivertex,r.ivertex),!1;t[h.ipath]>=0&&t[h.ipath]===t[r.ipath]&&(0!==i.length&&ch(i.at(-1),r)||i.push({...r}),i.push(h))}_h(r,h)}if(0===i.length)return!0;const o=new Se(!0);t.fill(-1);let a=-1;const h=new $e;for(let l=0,g=i.length;l<g;l++){const e=i[l];e.x===h.x&&e.y===h.y||(a=o.createList(0),h.x=e.x,h.y=e.y);let s=t[e.ipath];-1===s&&(s=o.createList(2),t[e.ipath]=s),o.addElement(s,a),o.addElement(a,s)}const m=[];for(let l=o.getFirstList();-1!==l;l=o.getNextList(l)){const e=o.getListData(l);if(1&e||!(2&e))continue;let s=-1;for(m.push(l),m.push(-1);m.length;){const e=m.at(-1);m.pop();const t=m.at(-1);m.pop();const n=o.getListData(t);if(1&n){s=2&n?t:e;break}o.setListData(t,1|n);for(let s=o.getFirst(t);-1!==s;s=o.getNext(s)){const n=o.getData(s);n!==e&&(m.push(n),m.push(t))}}if(-1!==s){const e=t.indexOf(s);return this.m_nonSimpleResult=new ts(12,e,-1),!1}}return!0}_CheckValidRingOrientation(){const e=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(e.calculateArea2D()<=0)return this.m_nonSimpleResult=new ts(8,1===e.getPathCount()?1:-1,-1),0;if(1===e.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new Ne(e.getPathCount(),0),this.m_pathParentage=new be(e.getPathCount(),-1);let t=-1,s=0;for(let i=0,o=e.getPathCount();i<o;i++){const n=e.calculateRingArea2D(i);if(this.m_pathOrientations.write(i,n<0?0:8),n>0)t=i,s=n;else{if(0===n)return this.m_nonSimpleResult=new ts(8,i,-1),0;if((t<0||s<Math.abs(n))&&(this.m_nonSimpleResult=new ts(9,i,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(i,t)}}this.m_unknownOrientationPathCount=e.getPathCount(),this.m_newEdges.length=0;const n=e.getPointCount();this.m_yScanline=Number.NaN;const r=[];this.m_xyToNode1=new be(n,Ce.st_nullNode()),this.m_xyToNode2=new be(n,Ce.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new yh(this));for(let i=0,o=2*n;this.m_unknownOrientationPathCount>0&&i<o;i++){const e=this.m_pairIndices.read(i),t=this.m_pairs[e];if(1&t)continue;const s=t>>1,n=this.m_xy.read(2*s+1);if(n!==this.m_yScanline&&r.length){if(!this.processBunchForRingOrientationTest(r))return 0;r.length=0}r.push(s),this.m_yScanline=n}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(r)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(e){if(1===e.length)return!0;for(let o=0,a=e.length;o<a;o++){const t=e[o];this.m_recycledSegIter.resetToVertex(t,-1);const s=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(s,t,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const n=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(n,t,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort((e,t)=>this.edgeAngleCompare(e,t));let t=this.m_crossOverHelperList.getFirstList();-1===t&&(t=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let o=0,a=this.m_edges.length;o<a;o++)this.m_crossOverHelperList.addElement(t,o);let s=!0,n=-1,r=-1;for(;s;){s=!1;let e=this.m_crossOverHelperList.getFirst(t);if(-1===e)break;let i=this.m_crossOverHelperList.getNext(e);for(;-1!==i;){const o=this.m_crossOverHelperList.getData(e),a=this.m_crossOverHelperList.getData(i);if(n=this.m_edges[o].m_vertexIndex,r=this.m_edges[a].m_vertexIndex,n!==r)e=i,i=this.m_crossOverHelperList.getNext(e);else if(s=!0,this.m_crossOverHelperList.deleteElement(t,e),e=this.m_crossOverHelperList.getPrev(i),i=this.m_crossOverHelperList.deleteElement(t,i),-1===i||-1===e)break}}const i=this.m_crossOverHelperList.getListSize(t);if(this.m_crossOverHelperList.clear(t),i>0)return this.m_nonSimpleResult=new ts(7,n,r),!1;for(let o=0,a=e.length;o<a;o++)this.recycleEdge(this.m_edges[o]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(e){for(let t=0,s=e.length;t<s;t++){const s=e[t];let n=this.m_xyToNode1.read(s);if(n!==Ce.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode1.write(s,Ce.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==Ce.st_nullNode()){const e=this.m_AET.getElement(n);this.m_freeEdges.push(e),this.m_AET.deleteNode(n),this.recycleEdge(this.m_edges[e]),this.m_edges[e]=null,this.m_xyToNode2.write(s,Ce.st_nullNode())}}for(let t=0,s=e.length;t<s;t++){const s=e[t];this.m_recycledSegIter.resetToVertex(s,-1);const n=this.m_recycledSegIter.previousSegment();if(n.getStartY()>n.getEndY()){const e=this.m_recycledSegIter.getStartPointIndex(),t=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!0);let r;this.m_freeEdges.length>0?(r=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[r]=t):(r=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(r);this.m_xyToNode1.read(e)===Ce.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}this.m_recycledSegIter.nextSegment();const r=this.m_recycledSegIter.nextSegment();if(r.getStartY()<r.getEndY()){const e=this.m_recycledSegIter.getEndPointIndex(),t=this.createEdge(r,s,this.m_recycledSegIter.getPathIndex(),!1);let n;this.m_freeEdges.length>0?(n=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[n]=t):(n=this.m_edges.length,this.m_edges.push(t));const i=this.m_AET.addElement(n);this.m_xyToNode1.read(e)===Ce.st_nullNode()?this.m_xyToNode1.write(e,i):this.m_xyToNode2.write(e,i),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(i)}}for(let t=0,s=this.m_newEdges.length;t<s&&this.m_unknownOrientationPathCount>0;t++){const e=this.m_newEdges[t],s=this.m_AET.getElement(e),n=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(n))){let t=-1,s=this.m_AET.getPrev(e),n=e,r=0;{let e=-1,i=null,o=-1,a=0;for(;s!==Ce.st_nullNode()&&(e=this.m_AET.getElement(s),i=this.m_edges[e],o=i.m_pathIndex,a=this.m_pathOrientations.read(o),!(3&a));)n=s,s=this.m_AET.getPrev(s);s===Ce.st_nullNode()?(r=1,s=n):(t=1==(3&a)?o:this.m_pathParentage.read(o),r=i.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const e=this.m_AET.getElement(s),i=this.m_edges[e],o=i.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(r!==i.getRightSide())return this.m_nonSimpleResult=new ts(8,o,-1),!1;const e=r&&!i.getReversed()?1:2;if(a=-4&a|e,this.m_pathOrientations.write(o,a),2===e&&0===this.m_nonSimpleResult.m_reason){const e=this.m_pathParentage.read(o);if(e!==t&&(this.m_nonSimpleResult=new ts(9,o,e),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}t=1==(3&a)?o:this.m_pathParentage.read(o),n=s,s=this.m_AET.getNext(s),r=r?0:1}while(n!==e)}}return this.m_newEdges.length=0,!0}createEdge(e,t,s,n){let r;return e.getGeometryType()===i.enumLine?r=this.createEdgeLine(e):(r=new lh,r.m_segment=e.clone()),r.m_vertexIndex=t,r.m_pathIndex=s,r.m_flags=0,r.setReversed(n),r}createEdgeLine(e){let t;return this.m_lineEdgesRecycle.length>0?(t=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),e.copyTo(t.m_segment)):(t=new lh,t.m_segment=e.clone()),t}recycleEdge(e){e.m_segment.getGeometryType()===i.enumLine&&this.m_lineEdgesRecycle.push(e)}static isShortSegment(e,t,s,n){let r=e.calculateLowerLength2D();if(r<=s){let i=!0;if(e.isCurve()&&(r=e.calculateLength2D(),i=r<=s),i){if(t){let t=e.getEndAttributeAsDbl(1,0);Number.isNaN(t)&&(t=0);let s=e.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-t)<=n}return!0}return!1}return!1}static isShortSegmentPoints(e,t,s,n,r){if(s){const s=e.getXYZ(),i=t.getXYZ();return Te(s,i,n,r)}{const s=e.getXY(),r=t.getXY();return $e.sqrDistance(s,r)<=n*n}}removeDegenerateSegmentsFromCurvedPath(e,t,s,n){const r=e.hasAttribute(1),i=e.querySegmentIterator();i.resetToPath(t),l(i.nextPath());const o=this.m_toleranceSimplify.total();let a=!1,h=!0;const m=new ye,g=new ye,u=new $e;for(;i.hasNextSegment();){this.progress_();const e=i.nextSegment();if(Ph.isShortSegment(e,r,o,s))if(a){if(e.queryEnd(g),Ph.isShortSegmentPoints(m,g,r,o,s))continue;h&&(n.startPathPoint(m),h=!1),e.queryEnd(m),n.lineToPoint(m),a=!1}else u.assign(e.getStartXY()),e.queryStart(m),a=!0;else if(a)if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(u,e.getEndXY(),!1),t.setStart(m),Ph.isShortSegment(t,r,o,s))continue;n.addSegment(t,h),h=!1,a=!1}else{if(e.queryEnd(g),Ph.isShortSegmentPoints(m,g,r,o,s))continue;h&&(n.startPathPoint(m),h=!1),n.lineToPoint(g),a=!1}else n.addSegment(e,h),h=!1}if(h)return;if(!a)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),m):e.getPointByVal(e.getPathEnd(t)-1,m);const c=n.querySegmentIterator();c.resetToLastPath(),c.resetToLastSegment();const _=n.getDescription().getAttributeCount()>1;for(l(c.previousPath());c.hasPreviousSegment();){const e=c.previousSegment();if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),m.getXY(),!1),!Ph.isShortSegment(t,r,o,s)){_&&t.setEnd(m);const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.addSegment(t,!1)}}else if(e.queryStart(g),!Ph.isShortSegmentPoints(g,m,r,o,s)){const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.lineToPoint(m)}}n.removePath(n.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const e=this.m_geometry.getImpl();this.m_multiVertexGeom=e;const t=e.getPointCount(),s=Je(t,0);for(let n=0;n<t;n++)s[n]=n;s.sort((e,t)=>this.compareVerticesMultiPoint(e,t));for(let n=1;n<t;n++)if(0===this.compareVerticesMultiPoint(s[n-1],s[n]))return this.m_nonSimpleResult=new ts(5,s[n-1],s[n]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let e=this.m_geometry.getImpl();const t=Ph.hasNanZs(e);let s,n=this.m_geometry;t&&(s=this.m_geometry.clone(),e=s.getImpl(),s.replaceNaNs(1,Ge.getDefaultValue(1)),n=s),this.m_multiVertexGeom=e;const r=e.getPointCount(),i=Je(r,0);for(let g=0;g<r;g++)i[g]=g;i.sort((e,t)=>this.compareVerticesMultiPoint(e,t));const o=new Array(r);o.fill(!1);let a=-1;for(let g=0;g<r;g++){const t=i[g];e.getXY(t).isFinite()&&((a<0||0!==this.compareVerticesMultiPoint(a,t))&&(o[t]=!0),a=t)}const h=this.m_geometry.createInstance();let m=0,l=0;for(let g=0;g<r;g++)o[g]?l=g+1:(m<l&&h.addPoints(n,m,l),m=g+1);return m<l&&h.addPoints(n,m,l),h.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),h}polylineSimplifyAsFeature(){const e=this.m_geometry.getImpl(),t=e.querySegmentIterator(),s=e.querySegmentIterator(),n=this.m_geometry.createInstance(),r=this.m_geometry,i=e.hasAttribute(1),o=i?ve(this.m_sr,e,!0).total():0,a=[],h=[];let m=null;i&&(m=e.getAttributeStreamRef(1));const l=new ye,g=e.hasNonLinearSegments(),u=this.m_toleranceSimplify.total();for(;t.nextPath();){if(s.nextPath(),e.getPathSize(t.getPathIndex())<2)continue;if(g&&e.hasNonLinearSegmentsPath(t.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(e,t.getPathIndex(),o,n);continue}s.resetToLastSegment();let c=0,_=0,d=!0,p=!0;for(;t.hasNextSegment();){this.progress_();const n=t.nextSegment(),r=s.previousSegment();if(t.getStartPointIndex()>s.getStartPointIndex())break;if(d){const s=t.getStartPointIndex();e.getXY(s).isNAN()||(d=!1,a.push(s))}if(p){const t=s.getEndPointIndex();e.getXY(t).isNAN()||(h.push(t),p=!1)}if(!d){const s=a.at(-1),r=t.getEndPointIndex();if(r-s>1){const t=new $e;t.setSub(e.getXY(s),e.getXY(r)),c=t.length()}else c=n.calculateLength2D();if(c>u)a.push(r),c=0;else if(i){let e=m.read(s);Number.isNaN(e)&&(e=0);let t=m.read(r);Number.isNaN(t)&&(t=0),Math.abs(t-e)>o&&(a.push(r),c=0)}}if(!p){const t=h.at(-1),n=s.getStartPointIndex();if(n-t>1){const s=new $e;s.setSub(e.getXY(t),e.getXY(n)),_=s.length()}else _=r.calculateLength2D();if(_>u)h.push(n),_=0;else if(i){let e=m.read(t);Number.isNaN(e)&&(e=0);let s=m.read(n);Number.isNaN(s)&&(s=0),Math.abs(s-e)>o&&(h.push(n),_=0)}}}if(a.length>0&&h.length>0&&(a.at(-1)<h.at(-1)?a.length>h.length?a.pop():h.pop():(a.at(-1)===h.at(-1)||h.pop(),h.pop())),h.length+a.length>=2){let e=!1;for(let t=0,s=a.length;t<s;t++)r.getPointByVal(a[t],l),e?n.lineToPoint(l):(n.startPathPoint(l),e=!0);for(let t=h.length-1;t>0;t--)r.getPointByVal(h[t],l),e?n.lineToPoint(l):(n.startPathPoint(l),e=!0);r.isClosedPath(t.getPathIndex())?n.closePathWithLine():h.length>0&&(r.getPointByVal(h[0],l),n.lineToPoint(l))}a.length=0,h.length=0}return i&&n.replaceNaNs(1,0),n.getImpl().setIsSimple(1,u),n}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!De(this.m_knownSimpleResult))return Ma(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const e=new V;if(e.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&e.replaceNaNs(1,0),e.removeNaNVertices(),0!==e.getTotalPointCount()){let t=null,n=0,r=0;if(e.hasCurves()){t=new fa;const i=s.constructEmpty();this.m_geometry.queryEnvelope(i);const o=_a(this.m_toleranceSimplify.total(),i);n=da(this.m_toleranceSimplify.total()),r=pa(o,n),aa(e,o,this.m_toleranceSimplify.total(),12e3,t,null,this.m_progressTracker)}if(!De(this.m_knownSimpleResult)){ya(e,this.m_toleranceSimplify.add(r),this.m_progressTracker,!0,!1)}this.m_geometry.getGeometryType()===i.enumPolygon&&er(e,e.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==t&&t.stitchCurves(e,e.getFirstGeometry(),n,!0)}const t=e.getGeometry(e.getFirstGeometry());return t.getGeometryType()===i.enumPolygon&&(t.getImpl().updateOGCFlagsProtected(),t.setFillRule(0)),t.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),t}progress_(){}static hasNanZs(e){if(e.hasAttribute(1)){const t=e.getAttributeStreamRef(1);for(let s=0,n=e.getPointCount();s<n;s++){const e=t.read(s);if(Number.isNaN(e))return!0}}return!1}compareVerticesForPlanarClustering(e,t,s){if(e===t)return 0;const n=this.m_pairs[e],r=this.m_pairs[t],i=n>>1,o=r>>1,a=this.m_xy.readPoint2D(2*i);a.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const h=this.m_xy.readPoint2D(2*o);h.y+=1&r?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=a.compare(h);if(0===m&&s){const e=this.m_pathsForOGCTests[i]-this.m_pathsForOGCTests[o];return at(e)}return m}compareVerticesMultiPoint(e,t){if(e===t)return 0;const s=this.m_multiVertexGeom.getXY(e),n=this.m_multiVertexGeom.getXY(t),r=!s.isFinite(),i=!n.isFinite();if(r||i)return r<i?-1:r>i?1:0;if(s.y<n.y)return-1;if(s.y>n.y)return 1;if(s.x<n.x)return-1;if(s.x>n.x)return 1;for(let o=1;o<this.m_attributeCount;o++){const s=this.m_description.getSemantics(o),n=Ge.getComponentCount(s);for(let r=0;r<n;r++){const n=this.m_multiVertexGeom.getAttributeAsDbl(s,e,r),i=this.m_multiVertexGeom.getAttributeAsDbl(s,t,r),o=ht(n,i);if(0!==o)return o}}return 0}edgeAngleCompare(e,t){if(e===t)return 0;const s=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&s.negateThis();const n=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&n.negateThis();const r=s.getQuarter(),i=n.getQuarter();if(i===r){const e=s.crossProduct(n);return e<0?1:e>0?-1:0}return r<i?-1:1}}class Eh{getOperatorType(){return 10103}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}supportsCurves(){return!0}isSimpleAsFeature(e,t,s,n,r){const i=oh(e,t,s,n,r);return _e(e.getGeometryType(),i)}isSimplePlanarDONOTUSE(e,t,s,n,r){const i=rh(e,t,s,n,r);return de(i)}executeMany(e,t,s,n){return new Sh(e,t,s,n)}execute(e,t,s,n){const r=new $t([e]),i=this.executeMany(r,t,s,n).next();return i||a("null geometry"),i}}class Sh extends es{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=e,this.m_spatialReference=t}next(){const e=this.m_inputGeometryCursor.next();return e?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(e)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(e){if(e||n(""),e.getGeometryType()===i.enumGeometryCollection){const t=H(e,-1),s=(new Eh).executeMany(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=e.createInstance();for(let e=s.next();null!=e;e=s.next())n.addGeometry(e);return n}return ah(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}function Ch(e,t,n){const r=new s;e.queryEnvelope(r);const o=new s;t.queryEnvelope(o);const a=new s(o);if(a.inflate(2*n),!a.isIntersecting(r))return 4;const h=e.getGeometryType(),m=t.getGeometryType();if(h===i.enumEnvelope&&r.containsEnvelope(a))return 1;if(m===i.enumEnvelope){const e=new s(r);if(e.inflate(2*n),o.containsEnvelope(e))return 2}return 0}class Ih{constructor(e,t,s,n){this.m_intersectorGeom=null,this.m_sr=null,this.m_dimensionMask=-1,this.m_progressTracker=null,this.m_intersectorGeomType=i.enumUnknown,this.m_geomIntersectorEmptyGeom=null,this.m_intersectorGeom=e,this.m_sr=t,this.m_dimensionMask=s,this.m_progressTracker=n,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){const t=this.tryFastImplementation(e);if(null!==t)return t;const n=pe(this.m_intersectorGeom,e),r=fe(this.m_sr,n,!0).total(),i=s.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);const o=s.constructEmpty();e.queryEnvelope(o),i.inflateCoords(2*r,2*r),i.intersect(o),i.inflateCoords(100*r,100*r);const a=0;let h=Zt(this.m_intersectorGeom,i,a,0,this.m_progressTracker),m=Zt(e,i,a,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(h=ot(m,m=h)),za(m,h,this.m_sr,this.m_progressTracker)}intersectEx(e){const t=this.tryFastImplementation(e);if(null!==t){const s=[];return s.length=3,s[t.getDimension()]=t,this.prepareVector(e.getDescription(),this.m_dimensionMask,s)}const n=pe(this.m_intersectorGeom,e),r=fe(this.m_sr,n,!0).total(),i=s.constructEmpty();this.m_intersectorGeom.queryEnvelope(i);const o=s.constructEmpty();e.queryEnvelope(o),i.inflateCoords(2*r,2*r),i.intersect(o),i.inflateCoords(100*r,100*r);const a=0;let h=Zt(this.m_intersectorGeom,i,a,0,this.m_progressTracker),m=Zt(e,i,a,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(h=ot(m,m=h));const l=Wa(m,h,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,l)}init(e,t,s,n=null){l(0)}static intersectPoints(e,t,s){const n=pe(e,t);return La(e,t,fe(s,n,!0))}tryFastImplementation(e){const t=e.getGeometryType();if(this.m_intersectorGeomType===i.enumPoint&&t===i.enumPoint){const t=Ih.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const e=new G({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===i.enumEnvelope&&this.m_intersectorGeomType===i.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const t=e,s=this.m_intersectorGeom,n=new xe({copy:t});return n.intersect(s),n}const n=pe(e,this.m_intersectorGeom),r=fe(this.m_sr,n,!0),o=e.isEmpty(),h=this.m_intersectorGeom.isEmpty();let m=o||h;if(!m){const t=Ch(this.m_intersectorGeom,e,r.total());if(4===t)m=!0;else{if(2&t)return this.m_intersectorGeom;if(1&t)return e}}if(m){const s=g(t),n=g(this.m_intersectorGeomType);return s<n?Ih.ReturnEmpty(e,o):s>n||0===s&&t===i.enumMultiPoint&&this.m_intersectorGeomType===i.enumPoint?this.ReturnEmptyIntersector():Ih.ReturnEmpty(e,o)}if(t===i.enumEnvelope&&0===g(this.m_intersectorGeomType)||this.m_intersectorGeomType===i.enumEnvelope&&0===g(t)){const n=t===i.enumEnvelope?e:this.m_intersectorGeom,o=t===i.enumEnvelope?this.m_intersectorGeom:e,a=s.constructEmpty();return n.queryEnvelope(a),Zt(o,a,r.total(),0,this.m_progressTracker)}if(0===g(t)&&g(this.m_intersectorGeomType)>0||g(t)>0&&0===g(this.m_intersectorGeomType)){if(t===i.enumMultiPoint)return Oa(e,this.m_intersectorGeom,r);if(t===i.enumPoint)return Xa(e,this.m_intersectorGeom,r);if(this.m_intersectorGeomType===i.enumMultiPoint)return Oa(this.m_intersectorGeom,e,r);if(this.m_intersectorGeomType===i.enumPoint)return Xa(this.m_intersectorGeom,e,r);a("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(e,t){return t?e:e.createInstance()}prepareVector(e,t,s){let n=0;return 1&t?(s[0]||(s[0]=new G({vd:e})),n++):s.shift(),2&t?(s[n]||(s[n]=new w({vd:e})),n++):s.splice(n,1),4&t?s[n]||(s[n]=new T({vd:e})):s.splice(n,1),new $t(s)}}class bh extends es{constructor(e,t,s,r,i){super(),this.m_smallCursor=null,this.m_progressTracker=r,this.m_geomIntersector=t.next(),this.m_intersector=new Ih(this.m_geomIntersector,s,i,r),this.m_index=-1,this.m_inputGeoms=e,this.m_dimensionMask=i,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&n("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let e;if(null!==this.m_smallCursor){if(e=this.m_smallCursor.next(),e)return e;this.m_smallCursor=null}for(;e=this.m_inputGeoms.next();){if(r(e),this.m_index=this.m_inputGeoms.getGeometryID(),-1===this.m_dimensionMask){return this.m_intersector.intersect(e)}this.m_smallCursor=this.m_intersector.intersectEx(e);return this.m_smallCursor.next()}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class wh{getOperatorType(){return 1e4}accelerateGeometry(e,t,s){if(!this.canAccelerateGeometry(e))return!1;ge(t,e,!0);let n=0;return e.getGeometryType()!==i.enumPolygon&&e.getGeometryType()!==i.enumPolyline||!v(e)||0===s||(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),!!n}canAccelerateGeometry(e){return v(e)}supportsCurves(){return!0}executeMany(e,t,s,n,r=-1){return new bh(e,t,s,n,r)}execute(e,t,s,n){if(e.getGeometryType()===i.enumPoint&&t.getGeometryType()===i.enumPoint)return Ih.intersectPoints(e,t,s);const r=new $t([e]),o=new $t([t]),h=this.executeMany(r,o,s,n,-1).next();return h||a("null output"),h}}function vh(e,t,s){return t.m_projector.project(e,s)}function Nh(e,t,s,n,r){e.m_projector.transformInPlaceZ(t,null,s,n,null,r);const i=n.slice(0,s).filter(e=>!e.isNAN());for(let o=0,a=i.length;o<a;++o)n[o].assign(i[o]);return i.length}function Th(e,t,s,n,r){return e.m_projector.transformInPlaceZ(t,null,s,n,null,r)}function Gh(e,t,r,a){if(e&&t&&t.isPannable()||n("fold_into_360_range_geodetic"),e.isEmpty())return e;if(4===r)return Dh(e,t,a);let m=e;const l=m.getGeometryType();if(h(l)){m=Al(e,t);const n=new s;m.queryEnvelope(n);const i=fe(t,n,!1).total(),o=t.getPannableExtent();let a=Math.floor((n.xmin-o.xmin)/o.width())*o.width()+o.xmin,h=m;for(;a<n.xmax;)a>n.xmin+i&&a<n.xmax-i&&(h=Hl(h,t,r,!0,a)),a+=o.width();m=h}else{if(l===i.enumEnvelope){const e=new T({vd:m.getDescription()});return e.addEnvelope(m,!1),Gh(e,t,r,a)}if(o(l)){const e=new w({vd:m.getDescription()});return e.addSegment(m,!0),Gh(e,t,r,a)}}return Dh(m,t,a)}function Dh(e,t,s){if(e&&t&&t.isPannable()||n(""),e.isEmpty())return e;let r;const a=e.getGeometryType();if(a===i.enumEnvelope){const t=new T({vd:e.getDescription()});t.addEnvelope(e,!1),r=t}else if(o(a)){const t=new w({vd:e.getDescription()});t.addSegment(e,!0),r=t}else r=e;const h=Al(r,t);return h.isEmpty()?h:vl(h,t,0,h!==e,0,s)}function Vh(e,t,s){if(!t.isPannable()||e.isEmpty())return e;const n=t.getPannableExtent().width(),r=.5*n,i=e.queryInterval(0,0);if(i.width()<r||!x(e.getGeometryType())){if(Number.isNaN(s))return e;const t=i.getCenter();if(Math.abs(t-s)<=r)return e;{const r=new jt,i=it((s-t)/n)*n;r.setShiftCoords(i,0);const o=e.clone();return o.applyTransformation(r),o}}const o=e.getGeometryType(),a=e,m=a.getAttributeStreamRef(0),l=e.clone(),g=l.getAttributeStreamRef(0);let u=0,c=0,_=0,d=h(o)?0:-1;const p=lt.constructEmpty();let f=!1;for(let x=0,y=a.getPointCount();x<y;x++){const e=m.read(2*x);x===c&&(h(o)?(0===d&&Number.isNaN(s)&&(f=!0),d>0&&Number.isNaN(s)&&(s=p.getCenter(),f=!1),c=a.getPathEnd(d),d++):c=a.getPointCount(),Number.isNaN(s)?_=e:(_=s,u=0));let t=e-_;Math.abs(t)>r&&(t=it(t/n)*n,u-=t,Math.abs(u)<.1*n&&(u=0));const i=e+u;g.write(2*x,i),f&&p.mergeCoordinate(i),_=e}return l.notifyModified(),l}const Fh="missing implementation";function Hh(e,t,n,r){const i=t.getCoordinateSystemType();if(0===i){const s=new ac;return t.queryPrecisionDescriptor(s),kh(e,s,t,n)}let o=e;2!==r&&3!==r||!t.isPannable()||(o=Dh(o,t,n));const h=new ac;if(t.queryPrecisionDescriptor(h),o=kh(o,h,t,n),0===r||o.isEmpty())return o;if(1===i){if(1===r){const e=new s;o.queryLooseEnvelope(e);const r=t.getPannableExtent(),i=.01*r.width();return r.xmin=e.xmin-i,r.xmax=e.xmax+i,(new Kt).execute(o,r,t,n)}return o}if(2===i){const e=t.getPCSHorizon();if(1===r||2===r){const s=(new wh).execute(o,e,t,n);return s===e?s.clone():s}return o}if(3===i)return o;a(Fh)}function kh(e,t,s,n){const r=t.getXYGridRange(),i=e.hasAttribute(1),o=e.hasAttribute(2);let a=new lt,h=new lt;i&&(a=t.getZGridRange()),o&&(h=t.getMGridRange());let m=(new Kt).execute(e,r,s,n);if(i){const t=m.queryInterval(1,0);a.contains(t)||(e===m&&(m=m.clone()),We(m,a,1,0))}if(o){const t=m.queryInterval(2,0);h.contains(t)||(e===m&&(m=m.clone()),We(m,h,2,0))}return m}class Ah{constructor(e){this.m_inputPCSHorizonClipOption=0,this.m_outputPCSHorizonClipOption=0,this.m_bDontGeonormalizePolygon=!1,this.m_bClipOutCurvedPoles=!1,this.m_bNormalizeOutputGeometry=!1,this.m_bDontHackPolesInGeogToGeog=!1,this.m_centralMeridianOfOutputGCS=0,this.m_densificationStepInput=0,e||n(""),this.m_projTransform=e,this.m_bClipOutCurvedPoles=!1;const t=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=t.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(t.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),t.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,t.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!t.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=t.centralMeridianOfOutputGCS,this.m_densificationStepInput=t.densificationStep;const s=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=s.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=s.hasFlag(1073741824),this.m_bClipOutCurvedPoles=s.hasFlag(536870912)}project(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;const s=e.getGeometryType();if(s===i.enumPoint)return this.projectPoint(e,t);const n=this.m_projTransform.getInputSR().getCoordinateSystemType(),r=this.m_projTransform.getOutputSR().getCoordinateSystemType(),o=this.m_projTransform.getInputSR(),h=this.m_projTransform.getOutputSR();if(0===n&&n===r){const t=Uh(o,h),s=e.clone();return s.applyTransformation(t),s}switch(s){case i.enumPolyline:case i.enumPolygon:return this.projectMultiPath(e,t);case i.enumMultiPoint:return this.projectMultiPoint(e,t);case i.enumEnvelope:return this.projectEnvelope(e,t);case i.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:a("")}}projectPoint(e,t){const s=[e.getXY()];let n,r=null;(n=e.hasAttribute(1))&&(r=[e.getZ()]),this.transformInPlaceZ(s,r,1,s,r,null);const i=e.clone();return i.setXY(s[0]),n&&i.setZ(r[0]),i}projectMultiPoint(e,t){let s=new G({copy:e});const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),o=r.getCoordinateSystemType();if(3===i&&l(0),s=Xl(s,n,this.m_inputPCSHorizonClipOption,t),s.isEmpty())return s;2===i&&$l(n,0,s),gg(this.m_projTransform,s,!1);let a=0;3===o&&l(0);const h=2===o;return h?a=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(a=this.m_centralMeridianOfOutputGCS),h&&0!==this.m_outputPCSHorizonClipOption||(s=vl(s,Zu(r),a,!1,0,t)),h&&(s=Sl(s,r,this.m_outputPCSHorizonClipOption,t),Kl(r,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(e,t){const s=e.getGeometryType();return s===i.enumPolygon?this.projectPolygon(e,t):s===i.enumPolyline?this.projectPolyline(e,t):void a("project_multi_path_")}projectEnvelope(e,t){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&e.hasAttribute(1);let n=lt.constructEmpty();if(s&&(n=e.queryInterval(1,0)),n.width()>0){const s=e.clone();s.setInterval(1,0,n.vmin,n.vmin);const r=this.projectEnvelopeHelper(s,t);s.setInterval(1,0,n.vmax,n.vmax);const i=this.projectEnvelopeHelper(s,t);return r.merge(i),r}return this.projectEnvelopeHelper(e,t)}projectPolygon(e,t){l(e.getGeometryType()===i.enumPolygon),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),o=n.getCoordinateSystemType(),a=r.getCoordinateSystemType(),h=new T({copy:e});3===o&&l(0),3===a&&l(0);const m=2===o,g=2===a,u=m?n.getGCS():n,c=g?r.getGCS():r,_=!g&&!this.m_bDontHackPolesInGeogToGeog;let d=!1,p=Xl(h,n,this.m_inputPCSHorizonClipOption,t);if(p.isEmpty())return p;let f=this.m_densificationStepInput;const x=!Number.isNaN(f);let y;x&&(p=(new Jt).execute(p,f,0,0,t));let P=g?r.getPCSInfo():null,E=Number.NaN;m&&(E=n.getCentralMeridian());const S=null!==r.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const e=p;if(m&&(hg(n,E,e),x)){const e=n.getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,_),x){const e=n.getGCS().getUnitsPerMillimeter();f*=r.getGCS().getUnitsPerMillimeter()/e}y=e}else{let e=new w({vd:p.getDescription()});if(e.addAndExplicitlyOpenAllPaths(p,!1),m){if(hg(n,E,e),x){const e=n.getUnitsPerMillimeter();f*=n.getGCS().getUnitsPerMillimeter()/e}if(this.m_bClipOutCurvedPoles){const r=n.getPCSInfo(),i=r.getSouthPoleGeometry()===Nc.PE_POLE_LINE_CURVED,o=r.getNorthPoleGeometry()===Nc.PE_POLE_LINE_CURVED;if(i||o){const n=s.constructEmpty();e.queryLooseEnvelope(n),n.inflateCoords(1,1);const r=89.9999*u.getOneDegreeGCSUnit();i&&(n.ymin=-r),o&&(n.ymax=r),e=Qt(e,n,u,0,0,t)}}}if(cg(this.m_projTransform,e,_),x){const e=Zu(n).getUnitsPerMillimeter();f*=Zu(r).getUnitsPerMillimeter()/e}let i=Number.NaN;g?(P=r.getPCSInfo(),i=r.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(i=this.m_centralMeridianOfOutputGCS);let o=Mh(n)|Mh(r),a=10*c.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(o=3,a=10*c.getTolerance(0)),y=Vl(p,n,e,c,i,t,o,a,this.m_bNormalizeOutputGeometry),o=0}if(S&&(l(!r.isPannable()),y=cl(y,r,t)),g){if(!d){const e=c.getPannableExtent().width();if(y.queryInterval(0,0).width()>=e-10*c.getTolerance(0)){const e=P.getNorthPoleLocation(),t=P.getSouthPoleLocation(),s=P.getNorthPoleGeometry(),n=P.getSouthPoleGeometry();let r=0;s===Nc.PE_POLE_POINT&&e!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(r=1),n===Nc.PE_POLE_POINT&&t!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(r|=2),d||=0!==r}}y=Sl(y,r,this.m_outputPCSHorizonClipOption,t),x&&(y=(new Jt).execute(y,f,0,0,t)),Jl(r,y,this.m_bNormalizeOutputGeometry)}return y.isEmpty()||d&&(y=(new Eh).execute(y,r,!1,t)),y}projectPolyline(e,t){l(e.getGeometryType()===i.enumPolyline),l(!this.m_projTransform.isIdentity()),l(!e.isEmpty());const s=this.m_projTransform.getInputSR(),n=this.m_projTransform.getOutputSR(),r=s.getCoordinateSystemType(),o=n.getCoordinateSystemType(),a=new w({copy:e});3===r&&l(0),3===o&&l(0);const h=2===r,m=2===o;h&&s.getGCS();const g=m?n.getGCS():n,u=!m&&!this.m_bDontHackPolesInGeogToGeog;let c=Xl(a,s,this.m_inputPCSHorizonClipOption,t);if(c.isEmpty())return c;let _=Number.NaN;h&&(_=s.getCentralMeridian());const d=null!==n.getGCSSplitLines();let p=this.m_densificationStepInput;const f=!Number.isNaN(p);let x;if(f&&(c=(new Jt).execute(c,p,0,0,t)),this.m_bDontGeonormalizePolygon){if(h&&(hg(s,_,c),f)){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,c,u),f){const e=s.getGCS().getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}x=c}else{const e=new w({vd:c.getDescription()});if(e.addAndExplicitlyOpenAllPaths(c,!1),h&&(hg(s,_,e),f)){const e=s.getUnitsPerMillimeter();p*=s.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,u),f){const e=s.getGCS().getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}let r=Number.NaN;m?r=n.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(r=this.m_centralMeridianOfOutputGCS);let i=Mh(s)|Mh(n),o=10*g.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=0),x=Fl(c,s,e,g,r,t,i,o,this.m_bNormalizeOutputGeometry),i=0}return d&&(l(!n.isPannable()),x=cl(x,n,t)),m&&(x=Sl(x,n,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(n,x,this.m_bNormalizeOutputGeometry)),x.isEmpty(),x}projectGeometryCollection(e,t){return l(0),{}}projectEnvelopeHelper(e,t){const n=(e.height()+e.width())/400;if(0!==n){const r=(new Jt).execute(e,n,0,0,t),i=this.projectMultiPath(r,t),o=new xe({vd:e.getDescription()});if(i.isEmpty()){const n=Math.min(e.height(),e.width()),i=ge(this.m_projTransform.getInputSR(),e,!0).total();if(n>100*i){const e=s.constructEmpty(),t=fe(this.m_projTransform.getOutputSR(),e,!0).total(),r=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(n>100*Math.max(i,t*r))return o}const a=new w;a.addAndExplicitlyOpenAllPaths(r,!1);this.projectMultiPath(a,t).queryEnvelope(o);const h=new G({vd:e.getDescription()});h.reserve(4);const m=new ye;for(let t=0;t<4;t++)e.queryCornerByVal(t,m),h.add(m);const l=this.projectMultiPoint(h,t),g=new xe;return l.queryEnvelope(g),o.merge(g),o}return i.queryEnvelope(o),o}{const s=e.getCenterXY(),n=new ye(s),r=this.projectPoint(n,t),i=new xe({vd:e.getDescription()});if(r.isEmpty())i.setEmpty();else{e.copyTo(i);const t=r.getXY();i.setCoords(t.x,t.y,t.x,t.y)}return i}}transformInPlace(e,t,s,n){return l(0),0}transformInPlaceZ(e,t,s,n,r,i){if(this.m_projTransform.isIdentity())return e!==n&&nt(n,e,s),t!==r&&Nt(r,t,0,0,s),s;const o=this.m_projTransform,a=o.getInputSR(),h=o.getOutputSR(),m=a.getCoordinateSystemType(),g=h.getCoordinateSystemType();if(0===m&&m===g){return Uh(a,h).transformPoints2D(e,s,n),o.isVertical()&&l(0),s}3===m&&d("image: transform_in_place_"),3===g&&d("image: transform_in_place_"),Ll(e,s,n,a,this.m_inputPCSHorizonClipOption),r!==t&&Nt(r,t,0,0,s),2===m&&mg(a,0,n,s),fg(this.m_projTransform,n,r,s,!1);let u=0;const c=2===g;c?u=h.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(u=this.m_centralMeridianOfOutputGCS),c&&0!==this.m_outputPCSHorizonClipOption||Nl(n,s,h.getGCS(),u),c&&(wl(n,s,h,this.m_outputPCSHorizonClipOption),Wl(h,n,s,!1));let _=s;for(let l=0;l<s;++l)n[l].isNAN()&&(r&&(r[l]=Number.NaN),_--);return _}}function Mh(e){if(2!==e.getCoordinateSystemType())return 0;let t=0;const s=e.getPCSInfo(),n=s.getNorthPoleLocation(),r=s.getSouthPoleLocation(),i=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return i===Nc.PE_POLE_POINT&&n!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(t=1),o===Nc.PE_POLE_POINT&&r!==Nc.PE_POLE_OUTSIDE_BOUNDARY&&(t|=2),t}function Uh(e,t){const s=e.getHorzUnitFactor(),n=t.getHorzUnitFactor();let r=1,i=1;const o=20015077/180;1===e.getUnit().getUnitType()&&(r=o),1===t.getUnit().getUnitType()&&(i=o);const a=s/n*(r!==i?r/i:1),h=new jt;return h.setScaleCoords(a,a),h}class qh{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s){return!t||t.isIdentity()?e:new Bh(e,t,s)}execute(e,t,s){return t.isIdentity()?e:vh(e,t,s)}transform(e,t,s,n,r=!0){return r?Nh(e,t,s,n,null):Th(e,t,s,n,null)}transform3D(e,t,s,n,r=!0){return l(0),0}foldInto360Range(e,t){return Dh(e,t,null)}foldInto360RangeGeodetic(e,t,s){return Gh(e,t,s,null)}normalizeGeometryEx(e,t,s,n,r=0){return Tm(e,t,s,n,r)}normalizeGeometry(e,t,s){return Vh(e,t,s)}clipToSpatialReference(e,t,s,n=0){return Hh(e,t,s,n)}}class Bh extends es{constructor(e,t,s){super(),this.m_projTrans=t,this.m_progressTracker=s,this.m_index=-1,e||n(""),this.m_inputGeoms=e}next(){const e=this.m_inputGeoms.next();return null!=e?(P(e),r(e),this.m_index=this.m_inputGeoms.getGeometryID(),vh(e,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Oh(e,t,s,a,m,g,u=!1){e||n("Geometry.Geodetic_densify.densify");let c=e.getGeometryType();if(r(e),e.isEmpty()||_(c))return e;const d=new Wh;d.m_sr=t,d.m_gcs=t.getGCS(),d.m_transform=d.m_gcs!==t?t.getSRToGCSTransform():null,d.m_progressTracker=g;const p=Hu();let f,x,y;if(d.m_gcs.querySpheroidData(p),d.m_a=p.majorSemiAxis,d.m_eSquared=p.e2,d.m_rpu=d.m_gcs.getUnit().getUnitToBaseFactor(),d.m_gcsTolerance=d.m_gcs.getTolerance(0),d.m_radTolerance=d.m_gcsTolerance*d.m_rpu,d.m_maxLength=a,d.m_maxDeviation=m,d.m_curveType=s,c===i.enumEnvelope){const t=new T({vd:e.getDescription()});t.addEnvelope(e,!1),f=t,c=i.enumPolygon}else if(o(c)){const t=new w({vd:e.getDescription()});t.addSegment(e,!0),f=t,c=i.enumPolyline}else f=e;if(4!==d.m_curveType){if(l(h(c)),x=d.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(f),x.isEmpty())return x;x=Yh(d.m_rpu,x);let e=d.geodeticDensify(x);u||(e=(new qh).foldInto360RangeGeodetic(e,d.m_gcs,d.m_curveType)),y=d.m_transform&&!d.m_transform.isIdentity()?(new qh).execute(e,d.m_transform.getInverse(),g):e}else{let e;if(l(h(c)),t.isPannable())e=Al(f,t);else{const s=t.getPCSHorizon();e=(new wh).execute(f,s,t,g),e===s&&(e=s.clone())}if(x=e,x.isEmpty())return x;y=d.shapePreservingDensify(x)}return y}function Yh(e,t){const n=new s;if(t.queryLooseEnvelope(n),n.width()*e<Math.PI)return t;let r=!1;const i=t.querySegmentIterator(),o=new $e,a=new $e;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment();if(o.setCoordsPoint2D(t.getStartXY()),a.setCoordsPoint2D(t.getEndXY()),o.scale(e),a.scale(e),Math.abs(o.x-a.x)>Math.PI){if(!Xh(o,a)){r=!0;break}if(Math.abs(o.x-a.x)>2*Math.PI){r=!0;break}}}if(!r)return t;const h=t.createInstance();h.reserve(t.getPointCount());const m=t.getDescription().getAttributeCount()>1,l=new $e,g=new $e,u=new $e(0,0),c=new $e(0,0),_=new ye;for(i.resetToFirstPath();i.nextPath();){let t=Number.NaN,s=0;for(;i.hasNextSegment();){const n=i.nextSegment();o.setCoordsPoint2D(n.getStartXY()),a.setCoordsPoint2D(n.getEndXY()),o.scale(e),a.scale(e),Number.isNaN(t)?(s=im(o.x,Number.NaN,s),u.setCoordsPoint2D(o)):u.setCoordsPoint2D(c),t=u.x;if(Xh(o,a)){if(a.x-o.x>2*Math.PI)for(;a.x-o.x>2*Math.PI;)a.x-=2*Math.PI;else if(a.x-o.x<2*-Math.PI)for(;a.x-o.x<2*-Math.PI;)a.x+=2*Math.PI;s=im(a.x,Number.NaN,s),c.setCoordsPoint2D(a)}else l.setCoordsPoint2D(a),gm(l),s=im(l.x,t,s),c.setCoords(s+l.x,l.y);if(Math.abs(c.x-a.x)<.5&&c.setCoordsPoint2D(a),m){n.queryCoord(0,_),g.setCoordsPoint2D(u),g.scale(1/e),_.setXY(g);i.isFirstSegmentInPath()?h.startPathPoint(_):h.lineToPoint(_),i.isLastSegmentInPath()&&!i.isPathClosed()&&(n.queryCoord(1,_),g.setCoordsPoint2D(c),g.scale(1/e),_.setXY(g),h.lineToPoint(_))}else{i.isFirstSegmentInPath()&&h.insertPath2D(-1,null,0,0,!0);const t=h.getPathCount()-1;g.setCoordsPoint2D(u),g.scale(1/e),h.insertPoint2D(t,-1,g),i.isLastSegmentInPath()&&!i.isPathClosed()&&(g.setCoordsPoint2D(c),g.scale(1/e),h.insertPoint2D(t,-1,g))}}}return h}function Rh(e,t,s,n,r,i,o,a,h,m,l,g){const u=new $e,c=new $e,_=n.compare(r)>0;nm(_,n,r,u,c);const d=Kh(e,t,s,u,c,i,o,a,h,m,null,l,g);return _&&sm(h,m,null,l),d}function Xh(e,t){return!(!Pc(e.y,St)||!Pc(t.y,St))||!(!Pc(e.y,-St)||!Pc(t.y,-St))}function Lh(e,t){return!(!Pc(e.y,St)||Pc(t.y,St))||!(!Pc(e.y,-St)||Pc(t.y,-St))}function zh(e,t){return!(!Pc(t.y,St)||Pc(e.y,St))||!(!Pc(t.y,-St)||Pc(e.y,-St))}class Wh{constructor(){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_progressTracker=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_gcsTolerance=0,this.m_radTolerance=0,this.m_maxLength=0,this.m_maxDeviation=0,this.m_curveType=0}geodeticDensify(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new k,o=e.getDescription().getAttributeCount()>1;for(;s.nextPath();){const e=[0];for(;s.hasNextSegment();){const a=s.nextSegment(),h=a.getStartXY(),m=a.getEndXY();h.scale(this.m_rpu),m.scale(this.m_rpu);const l=new $e,g=new $e,u=h.compare(m)>0;nm(u,h,m,l,g),n.length=0,r.length=0,this.m_maxLength>0?Kh(this.m_a,this.m_eSquared,this.m_curveType,l,g,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,o?r:null,n,e):Qh(),u&&sm(null,null,o?r:null,n),n[0].setCoordsPoint2D(a.getStartXY()),n.at(-1).setCoordsPoint2D(a.getEndXY());const c=1/this.m_rpu;for(let e=1,t=n.length-1;e<t;e++)n[e].scale(c);if(o){const e=rm(u,a,i);Zh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),a,e,r,n,t)}else jh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}}return t}shapePreservingDensify(e){const t=e.createInstance(),s=e.querySegmentIterator(),n=[],r=[],i=new k,o=e.getDescription().getAttributeCount()>1;for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment(),a=e.getStartXY(),h=e.getEndXY(),m=a.compare(h)>0,l=rm(m,e,i);n.length=0,r.length=0,tm(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,o?r:null,n),m&&sm(null,null,o?r:null,n),o?Zh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),e,l,r,n,t):jh(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,t)}return t}replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(e){const t=e.hasNonLinearSegments();if((!this.m_transform||this.m_transform.isIdentity())&&(e=Al(e,this.m_gcs),!t))return e;const s=e.createInstance();s.reserveParts(e.getPointCount(),e.getPathCount());for(let n=0,r=e.getPathCount();n<r;++n){let t=new G;const r=e.getPathStart(n),i=e.getPathEnd(n);t.addPoints(e,r,i);const o=e.isClosedPath(n);let a=!1;if(o&&i-r===1&&e.hasNonLinearSegmentsPath(n)){const s=new ye;e.getPointByVal(r,s),t.add(s),a=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(o&&!a){const s=new ye;e.getPointByVal(r,s),t.add(s)}if(t=(new qh).execute(t,this.m_transform,this.m_progressTracker),o&&t.getPointCount()>1){const e=t.getXY(0),s=t.getXY(t.getPointCount()-1);e.equals(s)&&t.removePoint(t.getPointCount()-1)}}t.getPointCount()>1&&(s.addPathMultiPoint(t,0,-1,!0),o&&s.closePathWithLine())}return s}}function jh(e,t,s,n){e&&n.insertPath2D(-1,null,0,0,!0);const r=n.getPathCount()-1;n.insertPointsFromPoints(r,-1,s,0,s.length-1,!0),t&&n.insertPoint2D(r,-1,s.at(-1))}function Zh(e,t,s,n,r,i,o){o.reserve(o.getPointCount()+i.length-1);const a=new ye;if(s.queryStart(a),e?o.startPathPoint(a):o.lineToPoint(a),i.length>2){const e=n.calculateLength2D();for(let t=1;t<i.length-1;t++){const s=n.lengthToT(r[t]*e);n.queryCoord(s,a),a.setXY(i[t]),o.lineToPoint(a)}}t&&(s.queryEnd(a),o.lineToPoint(a))}function Kh(s,n,r,i,o,a,h,m,l,g,u,c,_){const d={stack:[],error:void 0,hasError:!1};try{const t=e(d,new Cc,!1),p=e(d,new Cc,!1),f=e(d,new Cc,!1);Dc.geodeticDistance(s,n,i.x,i.y,o.x,o.y,f,t,p,r);const x=f.val,y=t.val,P=p.val;let E=y,S=P;E<0&&(E+=2*Math.PI),S<0&&(S+=2*Math.PI),l&&(l[0]=E),g&&(g[0]=S);let C=Number.NaN,I=Number.NaN;if(null!==u){const e=Vc.q90(s,n),t=Vc.q(s,n,i.y);C=(e-t)/x,I=(e+t)/x}const b=Lh(i,o),w=zh(i,o),v=b||w,N=mm(i,o,m),T=e(d,new dt(new Cc,new Cc),!1),G=new $e,D=new $e,V=new $e;_[0]=im(i.x,Number.NaN,_[0]);let F=_[0];if(x<=a)return c.push(i.clone()),_[0]=im(o.x,Number.NaN,_[0]),null!=u&&u.push(0),v?(b&&om(i,o,u,c),w&&am(i,o,u,c)):N?hm(i,o,y,C,I,u,c):h>0&&(D.setCoords(i.x-F,i.y),G.setCoords(o.x-_[0],o.y),F=Jh()),c.push(o.clone()),x;const H=1+Math.ceil(x/a),k=x/(H-1),A=new $e;c.push(i.clone()),A.setCoordsPoint2D(i),D.setCoords(i.x-_[0],i.y),null!==u&&u.push(0);for(let e=1;e<H;e++){let t;if(e<H-1){const o=e*k;Dc.geodeticCoordinate(s,n,i.x,i.y,o,y,T.at(0),T.at(1),r),G.setCoords(T.at(0).val,T.at(1).val),_[0]=im(G.x,A.x,_[0]),V.setCoords(_[0]+G.x,G.y),t=e/(H-1)}else _[0]=im(o.x,Number.NaN,_[0]),G.setCoords(o.x-_[0],o.y),V.setCoordsPoint2D(o),t=1;v?(1===e&&b&&om(i,V,u,c),e===H-1&&w&&am(A,o,u,c)):N?lm(A,V,m)&&(i.x<o.x?A.x>V.x&&(_[0]+=2*Math.PI,V.setCoords(_[0]+G.x,G.y)):A.x<V.x&&(_[0]-=2*Math.PI,V.setCoords(_[0]+G.x,G.y)),hm(A,V,y,C,I,u,c)):h>0&&Jh(),c.push(V.clone()),null!=u&&u.push(t),A.setCoordsPoint2D(V),D.setCoordsPoint2D(G),F=_[0]}return x}catch(p){d.error=p,d.hasError=!0}finally{t(d)}}function Qh(e,t,s,n,r,i,o,a,h,m){l(0)}function Jh(e,t,s,n,r,i,o,a,h,m,g,u,c,_,d){return l(0),0}function $h(e,t,s,n){const r=ds(e,t,s),i=ds(e,t,n);return Le.distance(r,i)}function em(e,t,s,n,r,i,o,a){const h=new Array,m=ut(Array,8);let g=2,u=r.getCoord2D(i);m[0][0]=u.x,m[0][1]=u.y,u=r.getCoord2D(o),m[1][0]=u.x,m[1][1]=u.y;const c=e=>{if(null!==s){const t=wc.projToGeog(s,e,m);l(t===e)}for(const t of m)t[0]*=n,t[1]*=n};c(2),h.push(ds(e,t,new $e(m[0][0],m[0][1]))),h.push(ds(e,t,new $e(m[1][0],m[1][1])));let _=Le.distance(h[0],h[1]);if(_>a)return _;let d=0;for(g=3;g<=17;){const s=1/(g-1);let n=0;for(let e=1;e<g;++e)if(1&e){const t=pt(i,o,e*s);r.queryCoord2D(t,u),m[n][0]=u.x,m[n][1]=u.y,n++}c(n);let p=1;for(let r=0;r<n;++r)h.splice(p,0,ds(e,t,new $e(m[r][0],m[r][1]))),p++;p=0;let f=h[p];p++;let x=0;for(;p!==h.length;++p){const e=h[p];x+=Le.distance(f,e),f=e}if(x>a)return x;if(d=x-_,l(d>=0||Math.abs(d)<1e-14*x),d<0&&(d=0),_=x,x+d<=a)return x+d;g=2*g-1}return _+d}function tm(e,t,s,n,r,i,o,a,h){const m=n.isCurve(),g=Fs(e,t)*Math.PI*179/180;let u=i;i>0&&!(i>g)||(u=g);const c=o,_=c>0;let d=Number.NaN;_&&(d=Bs(e,t,c));const p=1===r.getCoordinateSystemType();let f=null;p||(f=r.getPECoordSys());const x=r.getTolerance(0),y=n.getStartXY(),P=n.getEndXY(),E=new $e,S=new $e;if(p)E.setCoordsPoint2D(y),E.scale(s),S.setCoordsPoint2D(P),S.scale(s);else{const e=[y.x,y.y,P.x,P.y];wc.projToGeog(f,2,e),E.setCoords(e[0],e[1]),E.scale(s),S.setCoords(e[2],e[3]),S.scale(s)}let C=0,I=0;const b=[],w=[],v=[];b.push(P.clone()),w.push(S.clone()),v.push(1),h.push(y.clone()),null!==a&&a.push(I);const N=r.isPannable(),T=y.clone(),G=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let D=5;m||(_?(G[0]=.5,G[1]=.25,G[2]=.75,D=3):D=1),l(u>0);const V=e=>{if(e=e.clone(),null!==f){const t=[e.x,e.y];wc.projToGeog(f,1,t),e.setCoords(t[0],t[1])}return e.scale(s),e};for(;w.length>0;){const i=b.at(-1).clone();S.assign(w.at(-1));const o=v.at(-1);let g=!1,c=Number.NaN;const y=em(e,t,f,s,n,I,o,u);let P=u>=y&&Math.abs(E.y-S.y)<.9*Math.PI;p&&P&&(P=Math.abs(E.x-S.x)<.9*Math.PI);const F=new $e,H=new $e;let k=!1;if(!_&&P&&P&&(k=!0),n.calculateSubLength(I,o)<=x&&(k=!0),!k)for(let a=0;a<D;a++){const h=pt(I,o,G[a]),u=new $e;n.queryCoord2D(h,u);const f=V(u);if(0===a&&(c=h,F.setCoordsPoint2D(u),H.setCoordsPoint2D(f),!P)){g=!0;break}if(l(_),p&&Math.abs(E.x-f.x)>=Math.PI){g=!0;break}let x=new $e,y=new $e;m?(x=$e.lerp(T,i,G[a]),y=V(x)):(x=u.clone(),y=f.clone());const C=Ss(e,t,E,S,G[a]),b=C.clone();if(p?(b.x/=s,b.y/=s):(b.x/=s,b.y/=s,Th(r.getGCSToSRTransform(),[b],1,[b],null)),b.isNAN()){const s=ds(e,t,f),n=ds(e,t,E),r=ds(e,t,S),{second:i}=vs(e,t,s,n,r,2,null);if(i>d){g=!0;break}}else{if(N){const e=r.getPannableExtent().width(),t=pt(n.getStartX(),n.getEndX(),.5);for(;b.x<t-.5*e;)b.x+=e;for(;b.x>=t+.5*e;)b.x-=e}const s=n.getClosestCoordinateOnInterval(b,new lt(I,o),-1);let i=n.getCoord2D(s);i=V(i);let a=$h(e,t,i,C);if(a>d){if(a<4*d){const s=ds(e,t,i),n=ds(e,t,E),r=ds(e,t,S),{second:o}=vs(e,t,s,n,r,2,null);a=o}if(a>d){g=!0;break}}else if(m){let s=ds(e,t,f);const n=ds(e,t,E),r=ds(e,t,S);let{second:i}=vs(e,t,s,n,r,3,null);if(i<=d){s=ds(e,t,y);const{second:o}=vs(e,t,s,n,r,3,null);i=o}if(i>d){g=!0;break}}}}g?(b.push(F.clone()),w.push(H.clone()),v.push(c)):(b.pop(),w.pop(),v.pop(),h.push(i.clone()),C+=y,null!==a&&a.push(C),T.setCoordsPoint2D(i),E.setCoordsPoint2D(S),I=o)}if(null!==a){const e=1/C;for(let t=0;t<a.length;t++)a[t]*=e}}function sm(e,t,s,n){if(n.reverse(),null!==s&&s.reverse(),e){const s=e[0],n=t[0];e[0]=n,t[0]=s}}function nm(e,t,s,n,r){e?(n.setCoordsPoint2D(s),r.setCoordsPoint2D(t)):(n.setCoordsPoint2D(t),r.setCoordsPoint2D(s))}function rm(e,t,s){return e?(s.create(t.getGeometryType()),t.copyTo(s.get()),s.get().reverse(),s.get()):t}function im(e,t,s){if(Number.isNaN(t)){for(;s-e>Math.PI;)s-=2*Math.PI;for(;e-s>Math.PI;)s+=2*Math.PI;return s}return s+e-t>Math.PI?s-=2*Math.PI:t-(s+e)>Math.PI&&(s+=2*Math.PI),s}function om(e,t,s,n){if(e.y>0){const r=new $e;r.setCoords(t.x,St),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}else{const r=new $e;r.setCoords(t.x,-St),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}}function am(e,t,s,n){if(t.y>0){const r=new $e;r.setCoords(e.x,St),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}else{const r=new $e;r.setCoords(e.x,-St),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}}function hm(e,t,s,n,r,i,o){if(Sc(s)){if(St-e.y>0){const t=new $e;t.setCoords(e.x,St),o.push(t),null!==i&&i.push(n)}if(St-t.y>0){const e=new $e;e.setCoords(t.x,St),o.push(e),null!==i&&i.push(n)}}else{if(St+e.y>0){const t=new $e;t.setCoords(e.x,-St),o.push(t),null!==i&&i.push(r)}if(St+t.y>0){const e=new $e;e.setCoords(t.x,-St),o.push(e),null!==i&&i.push(r)}}}function mm(e,t,s){return!(!lm(e,t,s)||Pc(e.y,St)||Pc(e.y,-St)||Pc(t.y,St)||Pc(t.y,-St))}function lm(e,t,s){return Math.abs(Math.abs(e.x-t.x)-Math.PI)<=s}function gm(e){if(e.x<-Math.PI)for(;e.x<-Math.PI;)e.x+=2*Math.PI;else if(e.x>Math.PI)for(;e.x>Math.PI;)e.x-=2*Math.PI}function um(s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{const t=[r.x],a=[r.y-i],h=[r.x],m=[r.y+i];Vs(t,a),Vs(h,m);const l=e(o,new Cc,!1),g=e(o,new Cc,!1);Dc.greatEllipticDistance(s,n,r.x,r.y,t[0],a[0],l,null,null),Dc.greatEllipticDistance(s,n,r.x,r.y,h[0],m[0],g,null,null);return Math.min(l.val,g.val)}catch(a){o.error=a,o.hasError=!0}finally{t(o)}}function cm(e,t,n,r,i){const o=new s;n.queryEnvelope(o);const a=ge(null,n,!0).total();if(t.xmin-o.xmin<=a&&o.xmax-t.xmax<=a)return n;const h=t.width();let m=0;for(;t.xmin+m*h<o.xmin;)m++;for(;t.xmin+m*h>o.xmin;)m--;const l=m*h,g=new jt;g.setShiftCoords(-l,0);const u=n;u.applyTransformation(g);const c=new s;u.queryEnvelope(c);let _=null;if(c.xmax>t.xmax){let n=0;const r=new s;r.setCoords({env2D:t}),r.ymin-=1,r.ymax+=1;let o=u;for(;r.xmin<c.xmax;){c.xmax>r.xmax&&(o=Hl(o,e,2,!0,r.xmax));const s=Ze(o,r),a=fe(null,s,!0).total(),m=Zt(o,r,a,Number.NaN,i);null===_?_=m===o?m.clone():m:(g.setShiftCoords(-n*h,0),m.applyTransformation(g),_.add(m,!1)),n++,r.xmin=r.xmax,r.xmax=t.xmax+n*h}}else _=u;return _}class _m{constructor(e,t){this.m_basisX=new Le,this.m_basisY=new Le,this.m_normal=new Le,l(1===e.getCoordinateSystemType()),this.m_gcs=e;const s=Hu();e.querySpheroidData(s),this.m_a=s.majorSemiAxis,this.m_e2=s.e2,this.m_rpu=e.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=t.mul(this.m_rpu);const n=this.m_curvCenterRad.x,r=this.m_curvCenterRad.y,i=Math.cos(n),o=Math.sin(n),a=Math.cos(r),h=Math.sin(r);this.m_cartCenter3D=fs(this.m_a,this.m_e2,i,o,a,h),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),Le.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint($e.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint($e.construct(0,.5*-Math.PI/this.m_rpu))}project(e){const t=e.getGeometryType();if(x(t)){P(e);const t=e;return this.projectMultiVertex(t)}n("Gnomonic.project")}unproject(e,t,s){const r=e.getGeometryType();if(x(r)){P(e);let n=e;const o=[];if(r===i.enumPolygon){const e=n.getPathCount();for(let t=0;t<e;t++){const e=n.calculateRingArea2D(t);o.push(e)}}return this.unprojectMultiVertex(t,n),h(r)?(Cm(this.m_gcs,0,n),dm(o,this.m_gcs,0,n,s)):n=vl(n,this.m_gcs,0,!0,0,s),n}n("Gnomonic.unproject")}projectPoint(e){const t=e.mul(this.m_rpu),s=ds(this.m_a,this.m_e2,t),n=this.m_normal.dotProduct(s);if(n<=0)return $e.construct(Number.NaN,Number.NaN);const r=this.m_d/n,i=s.mul(r).sub(this.m_cartCenter3D),o=new $e;return o.x=this.m_basisX.dotProduct(i),o.y=this.m_basisY.dotProduct(i),o}unprojectPoint(e){const t=this.m_cartCenter3D.add(this.m_basisX.mul(e.x).add(this.m_basisY.mul(e.y)));return Ps(this.m_a,this.m_e2,t).divide(this.m_rpu)}projectMultiVertex(e){const t=e.getImpl();let s=!0;const n=new $e,r=new $e;for(let i=0,o=t.getPointCount();i<o;i++)t.queryXY(i,n),n.y*this.m_rpu>.5*Math.PI?r.assign(this.m_northPolePcs):n.y*this.m_rpu<.5*-Math.PI?r.assign(this.m_southPolePcs):r.assign(this.projectPoint(n)),t.setXYNoCurves(i,r),r.isNAN()&&(s=!1);return t.notifyModifiedFlags(2001),s}unprojectMultiVertex(e,t){const s=t.getImpl(),n=e*e,r=!this.m_northPolePcs.isNAN(),i=!this.m_southPolePcs.isNAN();for(let o=0,a=s.getPointCount();o<a;o++){const e=s.getXY(o);let t=new $e;r&&$e.sqrDistance(e,this.m_northPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*Math.PI),t.scale(1/this.m_rpu)):i&&$e.sqrDistance(e,this.m_southPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),t.scale(1/this.m_rpu)):t=this.unprojectPoint(e),s.setXYNoCurves(o,t)}s.notifyModifiedFlags(2001)}}function dm(e,t,n,r,o){const a=r.getGeometryType(),h=t.getPannableExtent();let m=r,l=!1,g=!1;if(a===i.enumPolygon){const r=new s,i=$e.construct(n,0);r.setCoords({env2D:h}),r.centerAt(i),l=pm(e,t,r,m,o);const a=Sm(t,r,m,o);a!==m&&(g=!0),m=a}else m=(new qh).foldInto360RangeGeodetic(m,t,2);a===i.enumPolygon&&(l||g)&&(m=(new Eh).execute(m,t,!1,o)),m!==r&&(r.setEmpty(),r.add(m,!1))}function pm(e,t,s,n,r){const i=fm(s,n),o=xm(e,t,s,n,r);return i||o}function fm(e,t){const n=new s;t.queryEnvelope(n);const r=Pc(e.ymax,n.ymax),i=Pc(e.ymin,n.ymin),o=r||i;return!!o&&(ym(e,t),o)}function xm(e,t,s,n,r){const i=[],o=[],a=.5*s.width();for(let g=0;g<n.getPathCount();g++){const h=n.getXY(n.getPathStart(g)),m=n.getXY(n.getPathEnd(g)-1),l=e[g]<0;if(Math.abs(h.x-m.x)>a){const e=Pm(l,t,s,g,n,r);i.push(e),o.push(g)}else if(!l){if(n.calculateRingArea2D(g)<0){const e=Em(t,s,g,n,r);i.push(e),o.push(g)}}}if(0===i.length)return!1;const h=new T({vd:n.getDescription()});let m=0,l=o[m];for(let g=0;g<n.getPathCount();g++)g===l?(h.add(i[m],!1),m++,m<o.length&&(l=o[m])):h.addPath(n,g,!0);return n.setEmpty(),n.add(h,!1),!0}function ym(e,t){const n=new T,r=new s;for(let s=0;s<t.getPathCount();s++){t.queryPathEnvelope(s,r);let i=Pc(e.ymax,r.ymax),o=Pc(e.ymin,r.ymin);if(!(i||o)){n.addPath(t,s,!0);continue}n.insertPath2D(-1,null,0,0,!0);const a=t.getPathStart(s),h=t.getPathEnd(s),m=h-a;let l=-1;for(l=a;l<h;l++){const s=t.getXY(l);if(i=Pc(e.ymax,s.y),o=Pc(e.ymin,s.y),!i&&!o)break}let g=l,u=!1,c=Number.NaN;do{const r=t.getXY(g);i=Pc(e.ymax,r.y),o=Pc(e.ymin,r.y);const h=a+(g+1-a)%m;if(i||o){let i=$e.construct(c,r.y);n.insertPoint2D(s,-1,i);const o=t.getXY(h),a=Pc(e.ymax,o.y),m=Pc(e.ymin,o.y);a||m||(i=$e.construct(o.x,r.y),u?n.setXYNoCurves(n.getPointCount()-1,i):n.insertPoint2D(s,-1,i)),u=!0}else n.insertPoint2D(s,-1,r),c=r.x,u=!1;g=h}while(g!==l)}t.setEmpty(),t.add(n,!1)}function Pm(e,t,n,r,i,o){const a=new T,h=new T,m=new jt,l=i.getXY(i.getPathStart(r)),g=i.getXY(i.getPathEnd(r)-1),u=n.width(),c=.5*u,_=new s;i.queryEnvelope(_);const d=Math.ceil(_.width()/u)+1;let p,f;l.x>g.x?(p=-u,f=e?n.ymin:n.ymax):(p=u,f=e?n.ymax:n.ymin),m.setShiftCoords(p,0),a.addPath(i,r,!0),h.add(a,!1);const x=new ye;for(let s=0;s<d;s++)h.applyTransformation(m),h.getPointByVal(0,x),a.lineToPoint(x),a.addSegmentsFromPath(h,0,0,h.getSegmentCount()-1,!1);const y=a.getXY(0),P=a.getXY(a.getPointCount()-1);y.y=f,P.y=f,a.lineTo(P);const E=new $e;for(E.setCoordsPoint2D(P),E.x-=.5*p;Math.abs(E.x-y.x)>c;)a.lineTo(E),E.x-=.5*p;a.lineTo(y);const S=n.getCenter().x,C=new s;a.queryEnvelope(C);let I=0;const b=C.getCenter().x;b-S>c?I=-Math.ceil((b-S-c)/u):S-b>c&&(I=Math.ceil((S-b-c)/u)),0!==I&&(m.setShiftCoords(I*u,0),a.applyTransformation(m));const w=new V,v=w.addGeometry(a);kl(w,v,t,0,2,!0,n.xmin),kl(w,v,t,0,2,!0,n.xmax);const N=w.getGeometry(v),G=Ze(N,n);G.inflateCoords(0,1);const D=fe(null,G,!0);return Zt(N,n,D.total(),Number.NaN,o)}function Em(e,t,n,r,i){const o=t.width(),a=.5*o,h=t.getCenter().x,m=new s;r.queryPathEnvelope(n,m);let l,g=0,u=m.getCenter().x;if(u-h>a?g=-Math.ceil((u-h-a)/o):h-u>a&&(g=Math.ceil((h-u-a)/o)),0!==g){const e=new jt;e.setShiftCoords(g*o,0),r.getImpl().applyTransformationToPath(e,n),r.queryPathEnvelope(n,m),u=m.getCenter().x}const c=new s;t.containsExclusiveEnvelope(m)?(l=!1,c.setCoords({env2D:t})):(l=!0,c.setCoords({env2D:t}),c.xmin-=o,c.xmax+=o);let _=r.createInstance();_.addPathPoint2D(null,0,!0);const d=new $e;if(d.setCoords(c.xmin,c.ymin),_.insertPoint2D(0,-1,d),d.setCoords(c.xmin,c.ymax),_.insertPoint2D(0,-1,d),d.setCoords(.5*(c.xmin+c.xmax),c.ymax),_.insertPoint2D(0,-1,d),d.setCoords(c.xmax,c.ymax),_.insertPoint2D(0,-1,d),d.setCoords(c.xmax,c.ymin),_.insertPoint2D(0,-1,d),d.setCoords(.5*(c.xmin+c.xmax),c.ymin),_.insertPoint2D(0,-1,d),l){_.addPath(r,n,!0);const s=new jt;u<h?s.setShiftCoords(o,0):s.setShiftCoords(-o,0),r.getImpl().applyTransformationToPath(s,n),_.addPath(r,n,!0);const a=new V,m=a.addGeometry(_);kl(a,m,e,0,2,!0,t.xmin),kl(a,m,e,0,2,!0,t.xmax),_=a.getGeometry(m);const l=Ze(_,t);l.inflateCoords(0,1);const g=fe(null,l,!0).total();_=Zt(_,t,g,Number.NaN,i)}else _.addPath(r,n,!0);return _}function Sm(e,t,n,r){const i=new s;n.queryEnvelope(i);const o=ge(null,n,!0).total();if(t.xmin-i.xmin<=o&&i.xmax-t.xmax<=o)return n;const a=n.createInstance();let h=n.createInstance();const m=new s,l=n.getPathCount();for(let s=0;s<l;s++)n.queryPathEnvelope(s,m),t.xmin-m.xmin<=o&&m.xmax-t.xmax<=o?a.addPath(n,s,!0):(h.setEmpty(),h.addPath(n,s,!0),h=cm(e,t,h,!0,r),a.add(h,!0));return a}function Cm(e,t,s){const n=e.getPannableExtent(),r=$e.construct(t,0);n.centerAt(r);const i=n.width(),o=.5*i,a=new $e;a.setNAN();let h=Number.NaN;for(let m=0;m<s.getPathCount();m++)for(let e=s.getPathStart(m);e<s.getPathEnd(m);e++){const t=s.getXY(e),r=Pc(t.y,n.ymax)||Pc(n.ymin,t.y);e===s.getPathStart(m)?(a.setNAN(),h=0):a.isNAN()||r||(h=Im(t.x,a.x,o,i,h)),t.x+=h,s.setXYNoCurves(e,t),r||a.setCoordsPoint2D(t)}s.getImpl().notifyModifiedFlags(2001)}function Im(e,t,s,n,r){return r+e-t>s?r-=n:t-(r+e)>s&&(r+=n),r}function bm(e,t,s,n,r,i){const o=t.getAttributeStreamRef(0),a=t.getPointCount();let h=!1;const m=new $e;for(let P=0;P<a;++P){if(o.queryPoint2D(2*P,m),1&i&&m.y>=s){h=!0;break}if(2&i&&m.y<=-s){h=!0;break}}if(!h)return!1;let l=!1;e&&(l=t.getImpl().isClosedPathInXYPlane(0));const g=new V,u=g.addGeometry(t),c=g.getFirstPath(u);let _=-1,d=!0;const p=new $e,f=new ye;let x=q;const y=Gm*r/360;for(let P=g.getFirstVertex(c);P!==q;P=g.getNextVertex(P)){g.queryXY(P,m);let e=1&i&&m.y>=s?1:0;if(e|=2&i&&m.y<=-s?2:0,_>0&&_!==e){if(p.x!==m.x){const e=g.getPrevVertex(P);g.queryPoint(e,f);const t=g.insertVertex(c,P,f);p.x=m.x,g.setXY(t,p)}if(l){let e=x!==q?g.getNextVertex(x):g.getFirstVertex(c);const t=g.getPrevVertex(P);for(;e!==t;)e=g.removeVertex(e,!1);if(x!==q){const e=g.getXY(x),s=g.getXY(t);if(Math.abs(e.x-s.x)>y){g.queryPoint(x,f);const n=g.insertVertex(c,t,f);e.x=pt(e.x,s.x,.5),g.setXY(n,e)}}}x=q}if(e&&(m.y=ft(n,m.y),g.setXY(P,m),!d&&_!==e))if(m.x!==p.x){g.queryPoint(P,f);const e=g.insertVertex(c,P,f);g.setXYCoords(e,p.x,m.y),x=e}else x=P;_=e,p.assign(m),d=!1}if(l){if(x!==q){let e=g.getNextVertex(x);for(;e!==q;)e=g.removeVertex(e,!1)}const e=g.getFirstVertex(c);let t=g.getLastVertex(c);const s=g.getXY(e),n=g.getXY(t);if(!s.equals(n)&&(g.queryPoint(e,f),t=g.insertVertex(c,q,f),Math.abs(s.x-n.x)>y)){const e=g.insertVertex(c,t,f);s.x=pt(s.x,n.x,.5),g.setXY(e,s)}}return t.assignCopy(g.getGeometry(u)),!0}function wm(e,t){let s=new T({vd:e});s.addEnvelope(t,!1);const n=t.width()/180;return s=(new Jt).execute(s,n,0,0,null),s}function vm(e,t){const s=e.getPannableExtent();return Number.isNaN(t)||s.centerAtCoords(t,0),s}function Nm(e,t,s){const n=Hu();t.querySpheroidData(n);const r=t.getGCS()!==t?t.getSRToGCSTransform():null,i=ut($e,100),o=new Le(0,0,0),a=e.getPointCount(),h=t.getGCS().getUnit().getUnitToBaseFactor();for(let u=0,c=a;u<c;){const t=Math.min(100,c-u);e.queryCoordinates(i,t,u,u+t),r&&(new qh).transform(r,i,t,i,!1);for(let e=0;e<t;e++){if(i[e].isNAN())continue;i[e].scale(h);const t=ds(n.majorSemiAxis,n.e2,i[e]);o.addThis(t)}u+=t}const m=Ps(n.majorSemiAxis,n.e2,o);m.scale(1/h);const l=e;if(!new _m(t.getGCS(),m).project(l))return 0;s.length=e.getPathCount();const g=l.calculateArea2D()<0;for(let u=0,c=e.getPathCount();u<c;u++){const e=l.calculateRingArea2D(u),t=g?e<0:e>0;s[u]=t}return g?-1:1}function Tm(e,t,s,n,r){if(!t.isPannable()||e.isEmpty())return e;const o=e.getGeometryType();o===i.enumGeometryCollection&&d("not yet impl for geometry collection");const h=t.getPannableExtent();Number.isNaN(s)&&(s=h.getCenterX());const m=h.width(),l=.5*m,g=r>0,u=e.queryInterval(0,0);if(!g&&u.width()<l||!x(e.getGeometryType())){const t=u.getCenter();if(Math.abs(t-s)<=l)return e;{const n=new jt,r=it((s-t)/m)*m;n.setShiftCoords(r,0);const i=e.clone();return i.applyTransformation(n),i}}if(o===i.enumPolygon){let i=new w({vd:e.getDescription()});i.addAndExplicitlyOpenAllPaths(e,!1),g&&(i=Oh(i,t,2,r,Number.NaN,null,!0));const o=[];if(!n){{let s=e;g&&(s=new T,s.add(i,!1));const n=Nm(e,t,o);if(n)n<0&&i.reverseAllPaths();else{const e=s.getPathCount();for(let t=0;t<e;t++)o.push(s.calculateRingArea2D(t)>0)}}n=o}return new Dm(null,n,i,null,t,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(o===i.enumPolyline){let n=new w({vd:e.getDescription()});n.addAndExplicitlyOpenAllPaths(e,!1),g&&(n=Oh(n,t,2,r,Number.NaN,null,!0));return new Dm(null,null,n,null,t,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(o===i.enumMultiPoint){const t=e,n=t.getAttributeStreamRef(0);let r,i=null,o=s,a=0;const h=.1*m;for(let s=0,g=t.getPointCount();s<g;s++){const t=n.read(2*s);let g=t-o;if(Math.abs(g)>l&&(g=it(g/m)*m,a-=g,Math.abs(a)<h&&(a=0)),0!==a){i||(r=e.clone(),i=r.getAttributeStreamRef(0));const n=t+a;i.write(2*s,n)}o=t}return i?(r.notifyModified(),r):e}a("")}const Gm=210;class Dm{constructor(e,t,s,n,r,i,o,a,h){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=h,this.m_originalGeometry=e,this.m_originalSR=n,this.m_polygonRingFlags=t,this.m_pannableSR=r,this.m_poleSnappingTolerance=a,this.m_poleFlags=o,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=vm(this.m_pannableSR,i),this.m_centralLongitude=Number.isNaN(i)?this.m_pannableExtent.getCenterX():i,this.m_width360=this.m_pannableExtent.width(),this.m_degree=this.m_width360/360,this.m_GCSLargeDelta=Gm*this.m_degree,l(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(e,t,s,n,r,i,o){let h=s;const m=new w({vd:this.m_inputPoly.getDescription()});m.addPath(this.m_inputPoly,e,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(!0,m,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(h=!1));let g=-1;h&&(g=this.m_originalGeometry.getPathStart(e));const u=m.getAttributeStreamRef(0),c=m.getPointCount();let _=0,d=u.read(0),p=0;const f=3*this.m_pannableSR.getTolerance(0);let x=!1;const y=new $e,P=new $e;let E=!1;const S=m.hasNonLinearSegments(),C=new $e;for(let l=1;l<c;++l){u.queryPoint2D(2*l,C);const e=C.x;let t=e+_;const s=t-d;if(C.x=t,Math.abs(s)>this.m_GCSLargeDelta){if(h){const e=g+l-1,t=g+(l+1<c?l:0),r=i.read(2*e),o=(i.read(2*t)-r)*n;Math.abs(s-o)>1*this.m_degree&&(h=!1)}if(!h){_-=ft(this.m_width360,t-d),t=e+_,++p,E=0!==_,C.x=t}}else x||ze(y,P,C,f)&&(x=!0);E&&(S&&a("error in geonormalize_ring_ for curves"),u.write(2*l,t)),d=t,y.setCoordsPoint2D(P),P.setCoordsPoint2D(C)}p&&m.notifyModified();const I=m.getXY(0),b=m.getXY(c-1);if($e.distance(I,b)<f){const e=this.finalizeGeoNormalizeClosedRing(m,x,r);o.add(e,!1)}else{if(t<0)if(null!==this.m_originalGeometry){l(null!==this.m_originalGeometry);t=this.m_originalGeometry.calculateRingArea2D(e)>0?1:0}else t=1;const s=this.finalizeGeoNormalizeOpenedRing(t>0,m);o.add(s,!1)}}geoNormalizePolygonGeometry(e){l(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),l(this.m_pannableSR.isPannable());let t=null,n=Number.NaN;const r=!!this.m_originalSR&&this.m_originalSR.isPannable();r&&(t=this.m_originalGeometry.getAttributeStreamRef(0),n=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const i=new T({vd:this.m_inputPoly.getDescription()});for(let s=0,l=this.m_inputPoly.getPathCount();s<l;++s){const o=this.m_polygonRingFlags?this.m_polygonRingFlags[s]?1:0:-1;this.geonormalizeRing(s,o,r,n,e,t,i)}const o=this.m_pannableSR.getTolerance(0),a=this.m_pannableExtent.width()/180;Ol(i,this.m_pannableExtent,.1*o,!1);const h=s.constructEmpty();if(h.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;const t=s.constructEmpty();for(let s=0,n=i.getPathCount();s<n;s++)if(i.queryPathEnvelope(s,t),!(h.xmin<=t.xmin&&h.xmax>=t.xmax||t.xmin>=h.xmax||t.xmax<=h.xmin)){e=!1;break}if(e)break;h.move(.5*this.m_width360,0)}e||h.setCoords({env2D:this.m_pannableExtent})}let m=Zt(i,h,o,a,this.m_progressTracker),g=i!==m;const u=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,c=m.calculateArea2D();let _=0;if(c>0&&u<0)_=1;else if(c<=0&&u>0)if(0===c){if(this.m_originalSR){let e=Number.NaN;2===this.m_originalSR.getCoordinateSystemType()?e=this.m_originalSR.getPCSHorizon().calculateArea2D():1===this.m_originalSR.getCoordinateSystemType()&&(e=this.m_originalSR.getPannableExtent().getArea()),u>.99*e&&(_=-1)}}else _=-1;if(0!==_){const e=wm(m.getDescription(),h);e.add(m,!1),g=!0,m=e}return g&&(m=(new Eh).execute(m,this.m_pannableSR,!1,this.m_progressTracker)),m}geoNormalizePolylineGeometry(e){l(this.m_pannableSR.isPannable());let t=null;const n=this.m_originalSR&&this.m_originalSR.isPannable();let r=1;n&&(l(this.m_originalGeometry),r=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));const i=this.m_pannableExtent.width(),o=i*gt()*4;let h=e,m=Number.NaN;const g=lt.constructEmpty();this.m_bAdjustedAtPoles=0;let u=new w({vd:this.m_inputPoly.getDescription()});for(let d=0,p=this.m_inputPoly.getPathCount();d<p;++d){let e=n;const c=new w({vd:this.m_inputPoly.getDescription()});c.addPath(this.m_inputPoly,d,!0);const _=this.m_inputPoly.isClosedPath(d);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(_,c,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,i,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(e=!1));let p=-1;const f=c.getPointCount();let x=!1;e&&(p=this.m_originalGeometry.getPathStart(d),x=this.m_originalGeometry.isClosedPath(d));const y=c.getAttributeStreamRef(0);let P=0,E=y.read(0),S=0;const C=new $e,I=new $e;let b=!1;const v=c.hasNonLinearSegments(),N=new $e;for(let s=1;s<f;++s){y.queryPoint2D(2*s,N);const n=N.x;let i=n+P;const o=i-E;if(N.x=i,Math.abs(o)>this.m_GCSLargeDelta){if(e){const n=p+s-1;let i=p;(!x||s+1<f)&&(i+=s);const a=t.read(2*n),h=(t.read(2*i)-a)*r;Math.abs(o-h)>1*this.m_degree&&(e=!1)}if(!e){P-=ft(this.m_width360,i-E),i=n+P,++S,b=0!==P,N.x=i}}b&&(v&&a("error in geonormalize_ring_ for curves"),y.write(2*s,i)),E=i,C.setCoordsPoint2D(I),I.setCoordsPoint2D(N)}if(S&&c.notifyModified(),h){let e=!1;if(!c.isEmpty()){const t=s.constructEmpty();if(c.queryEnvelope(t),t.width()>=i||t.ymin<=this.m_pannableExtent.ymin||t.ymax>=this.m_pannableExtent.ymax)e=!0;else{if(Number.isNaN(m)){const e=this.m_centralLongitude-.5*i;m=t.xmin,m+=Math.round((e-t.xmin)/i)*i,m>e&&(m-=i),l(m<=e),m<e&&(m+=i),l(m>=e)}let s=Math.round((m-t.xmin)/i)*i;if(t.xmin+s>m+o&&(s-=i),t.xmin+s<m-o&&(s+=i),g.mergeCoordinate(t.xmin+s),g.mergeCoordinate(t.xmax+s),e=g.width()>=i,!e){const e=new jt;e.setShiftCoords(s,0),c.applyTransformation(e)}}}u.add(c,!1),e&&(u=(()=>{const e=new w({vd:u.getDescription()});for(let t=0,s=u.getPathCount();t<s;++t){const s=new w({vd:u.getDescription()});s.addPath(u,t,!0);const n=vl(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);e.add(n,!1)}return e})(),h=!1)}else{const e=vl(c,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);u.add(e,!1)}}if(h)return u;const c=this.m_pannableSR.getTolerance(0),_=this.m_pannableExtent.width()/180;Ol(u,this.m_pannableExtent,.1*c,!1);return Zt(u,this.m_pannableExtent,c,_,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){const n=t.getPointCount(),r=t.getXY(0),i=t.getXY(n-1);{const e=Math.abs(i.x-r.x),t=Math.round(e/this.m_width360)*this.m_width360;l(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}const o=at(i.x-r.x),a=s.constructEmpty();t.queryLooseEnvelope(a);const h=this.m_pannableExtent.getCenterX();let m=0,g=h-this.m_width360,u=h+this.m_width360;if(o>=0){let e=Math.ceil((g-a.xmin)/this.m_width360);for(e*=this.m_width360;g>a.xmin+e;)e+=this.m_width360;for(;g<a.xmax+e;)e-=this.m_width360;for(m=e,a.width()>720&&(u=g+360*Math.ceil(a.width()/360));u<a.xmax;)u+=this.m_width360}else{let e=Math.ceil((u-a.xmax)/this.m_width360);for(e*=this.m_width360;u<a.xmax+e;)e-=this.m_width360;for(;u>a.xmin+e;)e+=this.m_width360;for(m=e,a.width()>720&&(g=u-360*Math.ceil(a.width()/360));g>a.xmin;)g-=this.m_width360}const c=Math.round(Math.abs(i.x-r.x)/this.m_width360)*this.m_width360,_=o*c,d=a.clone();d.move(m,0);const p=new $e(0,0),f=new jt;f.setShiftCoords(m,0),t.applyTransformation(f);const x=new w({vd:t.getDescription()});x.add(t,!1),p.assign(t.getXY(n-1));let y=0,P=x.getXY(0).x;for(;o>0?d.xmax<u:d.xmin>g;)d.move(_,0),f.xd=_,t.applyTransformation(f),P+=_,this.m_pannableExtent.xmin<=P&&this.m_pannableExtent.xmax>=P&&(y=x.getPointCount()-1),t.setXY(0,p),p.assign(t.getXY(n-1)),x.addSegmentsFromPath(t,0,0,n-1,!1);const E=new T({vd:x.getDescription()});E.add(x,!1);const S=x.getXY(0),C=x.getXY(x.getPointCount()-1),I=o<0?e:!e,b=E.getPointCount()-1;if(I){const e=new $e(C.x,this.m_pannableExtent.ymax);E.lineTo(e);const t=new $e(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);E.lineTo(t);const s=new $e(S.x,this.m_pannableExtent.ymax);E.lineTo(s)}else{const e=new $e(C.x,this.m_pannableExtent.ymin);E.lineTo(e);const t=new $e(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);E.lineTo(t);const s=new $e(S.x,this.m_pannableExtent.ymin);E.lineTo(s)}if(E.interpolateAttributesPath(0,b,0),E.getImpl().changeRingStartPoint(y),c>this.m_width360){const e=new T({copy:E});f.setShiftCoords(this.m_width360,0),e.applyTransformation(f),E.add(e,!1)}return E}finalizeGeoNormalizeClosedRing(e,t,n){const r=new T({vd:e.getDescription()});r.add(e,!1);const o=()=>{const e=r.getPointCount()-2;return r.getSegmentType(e)!==i.enumLine};if(r.hasNonLinearSegments()&&o()){const e=new k,t=r.getPointCount()-2;r.getSegmentBuffer(t,e,!1),r.removePointFromPath(0,t+1),r.closeLastPathWithSegment(e.get())}else r.removePointFromPath(0,r.getPointCount()-1);const a=s.constructEmpty();r.queryLooseEnvelope(a);let h=Math.ceil((this.m_pannableExtent.xmin-a.xmin)/this.m_width360);for(h*=this.m_width360;this.m_pannableExtent.xmin>a.xmin+h;)h+=this.m_width360;for(;this.m_pannableExtent.xmin<a.xmax+h;)h-=this.m_width360;if(h+=this.m_width360,0!==h){a.move(h,0);const e=new jt;e.setShiftCoords(h,0),r.applyTransformation(e)}if(this.m_pannableExtent.xmin<=a.xmin&&this.m_pannableExtent.xmax>=a.xmax){if(t){const e=r.calculateArea2D(),t=(new Eh).execute(r,this.m_pannableSR,!0,this.m_progressTracker);if(t!==r){const s=t.calculateArea2D();at(e)!==at(s)&&t.reverseAllPaths(),r.assignMove(t)}}let e;if(e=new T(n?{copy:r}:{move:r}),n)for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const t=new jt;t.setShiftCoords(this.m_width360,0),r.applyTransformation(t),e.add(r,!1)}return e}let m=new T({vd:e.getDescription()});m.add(r,!1);const l=t||a.width()>this.m_width360-10*this.m_pannableSR.getTolerance(0);for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const e=new jt;e.setShiftCoords(this.m_width360,0),r.applyTransformation(e),m.add(r,!1)}if(l){const e=m.calculateArea2D();m.setFillRule(1),m=(new Eh).execute(m,this.m_pannableSR,!0,this.m_progressTracker);const t=m.calculateArea2D();at(e)!==at(t)&&m.reverseAllPaths()}return m}geonormalize_ring_(e,t,s,n,r,i,o){l(0)}}function Vm(e){l(0);const t=ou(e),s=new km;return s.setVertProj_(t),s}function Fm(e,t=!0){return l(0),{}}function Hm(e){return Su()}class km{constructor(){this.m_hashCode=0,this.m_peVertSysVal=null,this.m_verticalUnit=new bu,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.m_bIsDepth=!1}getType(){return l(0),0}getID(){return l(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return l(0),""}getTextExtended(e){return l(0),""}getText2(e){return l(0),""}getUnit(){return l(0),{}}equals(e){return l(0),!1}equalForProjection(e){return l(0),!1}getPeVertcsCopy(){return l(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return l(0),0}isDepth(){return l(0),!1}getVerticalShift(){return l(0),0}isCustomWkid(){return!!this.m_peVertSysVal&&this.m_peVertSysVal.isCustomWkid()}getHashCode(){return this.m_hashCode}setVertProj_(e){this.m_peVertSysVal=e}getPEVerticalCoordSys(){return this.m_peVertSysVal?this.m_peVertSysVal.m_peVertcs:null}}function Am(e,t,s,n,r){if(e.equals(t))return!1;if(n){let s=1,i=0,o=1,a=1,h=0,m=1;Number.isNaN(e.m_heightMetersPerUnit)||(s=e.m_heightMetersPerUnit,i=e.m_heightZ0,o=e.m_heightSign,a=t.m_heightMetersPerUnit,h=t.m_heightZ0,m=t.m_heightSign);const l=o*m*s/a;for(let e=0;e<r;e++)n[e]=(n[e]-i)*l+h}let i=1,o=0;if(Number.isNaN(e.m_XYToRadians)||(i=e.m_XYToRadians/t.m_XYToRadians,o=e.m_PrimeMeridianDegrees-t.m_PrimeMeridianDegrees,0!==o&&(o=le(o),o/=t.m_XYToRadians)),Array.isArray(s)){const e=s;for(let t=0;t<r;t++)e[t][0]=e[t][0]*i+o,e[t][1]=e[t][1]*i}else{const e=s;for(let t=0;t<r;t++){const s=t<<1;e[s]=e[s]*i+o,e[s+1]=e[s+1]*i}}return!0}function Mm(){return{m_heightMetersPerUnit:0,m_heightSign:0,m_heightZ0:0,m_XYToRadians:0,m_PrimeMeridianDegrees:0,assign(e){this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0,this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees},equals(e){return rt(this.m_heightSign,e.m_heightSign)&&rt(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&rt(this.m_heightZ0,e.m_heightZ0)&&rt(this.m_XYToRadians,e.m_XYToRadians)&&rt(this.m_PrimeMeridianDegrees,e.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(e,t){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,t&&l(0),e&&(this.m_XYToRadians=e.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=e.getPrimem().getLongitude())},initFromGcsAndVcs(e,t){const s=e?e.getPECoordSys():null,n=t?t.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,n)},processUnitParams(e){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=e.m_heightMetersPerUnit,this.m_heightSign=e.m_heightSign,this.m_heightZ0=e.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=e.m_XYToRadians,this.m_PrimeMeridianDegrees=e.m_PrimeMeridianDegrees)}}}class Um{constructor(e){this.m_constantsLoaded=-1,this.m_isUsable=-1,this.m_inputSR=null,this.m_outputSR=null,this.m_inputSRHorz=null,this.m_outputSRHorz=null,this.m_inputVCS=null,this.m_outputVCS=null,this.m_hashCode=0,this.m_areaOfUse=new xe,this.m_inputUnitParams=Mm(),this.m_outputUnitParams=Mm(),l(e),this.m_geogTran=e,this.m_vertTran=null,this.m_latestID=Ic.getCode(this.m_geogTran),this.m_latestID<0&&(this.m_latestID=0);const t=this.m_geogTran.getGeogcs1();Ic.getCode(t);const s=this.m_geogTran.getGeogcs2();Ic.getCode(s),this.initUnitParams()}getLatestId(){return this.m_latestID}getText(){return this.m_geogTran?this.m_geogTran.toString():(l(0),"")}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(-1===t){if(!e){this.m_geogTran||a("vcs not impl");const t=this.m_geogTran.getParameters();null!==t[bc.PE_PARM_ND]&&(e=0===t[bc.PE_PARM_ND].getValue())}t=this.m_geogTran.loadConstants()?1:0,this.m_constantsLoaded=t}return 0!==t}isUsable(){let e=this.m_isUsable;return-1===e&&(this.m_geogTran?this.m_isUsable=e=this.m_geogTran?1:0:this.m_isUsable=e=this.m_vertTran?1:0),1===e}getInputSr(e){return this.updateSrs(),e?this.m_inputSR:this.m_inputSRHorz}getOutputSr(e){return this.updateSrs(),e?this.m_outputSR:this.m_outputSRHorz}getHashCode(){let e=this.m_hashCode;return 0===e&&(e=this.m_latestID>0?Qe(this.m_latestID):It(this.getText()),0===e&&(e=345),this.m_hashCode=e),e}isGeogtran(){return null!==this.m_geogTran}prepareOrThrow(){}getName(){return this.isGeogtran()?this.getGeogtran().getName():(d("vcs not impl"),"")}updateSrs(){if(this.m_inputSR||this.m_inputVCS)return;let e,t,s,n,r,i;if(this.m_geogTran){const o=this.m_geogTran.getGeogcs1(),a=ru(o),h=this.m_geogTran.getGeogcs2(),m=ru(h);let l=-1,g=-1;l=a.getVcsCode(),g=m.getVcsCode(),s=Ru(o,null,null,1),n=Ru(h,null,null,1),l>0&&g>0?(r=Vm(l),i=Vm(g),e=zu(),t=zu()):(e=s,t=n)}else l(0);this.m_inputSR||this.m_inputVCS||(this.m_inputSR=e,this.m_outputSR=t,this.m_inputSRHorz=s,this.m_outputSRHorz=n,this.m_inputVCS=r,this.m_outputVCS=i)}initUnitParams(){if(this.m_inputUnitParams.m_heightSign=1,this.m_inputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_inputUnitParams.m_heightZ0=0,this.m_outputUnitParams.m_heightSign=1,this.m_outputUnitParams.m_heightMetersPerUnit=Number.NaN,this.m_outputUnitParams.m_heightZ0=0,this.m_inputUnitParams.m_XYToRadians=Number.NaN,this.m_inputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_outputUnitParams.m_XYToRadians=Number.NaN,this.m_outputUnitParams.m_PrimeMeridianDegrees=Number.NaN,this.m_vertTran)l(0);else if(this.m_geogTran){const e=this.m_geogTran;let t=e.getGeogcs1();this.m_inputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_inputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude(),t=e.getGeogcs2(),this.m_outputUnitParams.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_outputUnitParams.m_PrimeMeridianDegrees=t.getPrimem().getLongitude()}}}function qm(e,t,s,n,r,i,o){let a=null;if(t){a=t.getPEVerticalCoordSys()}let h=null;if(e){h=e.getPECoordSys()}let m=null;if(n){m=n.getPEVerticalCoordSys()}let l=null;if(s){l=s.getPECoordSys()}if(!(h||a||l||m))return!1;const g=Mm();g.initFromGcsAndVcsPe(h,a);const u=Mm();return u.initFromGcsAndVcsPe(l,m),Am(g,u,r,i,o)}function Bm(e,t,s,n,r,i,o,a){const h=t,m=e,l=Mm();l.initFromGcsAndVcsPe(m,h),a.assign(n?s.m_outputUnitParams:s.m_inputUnitParams),a.processUnitParams(l),l.processUnitParams(a),o>0&&Am(l,a,r,i,o)}function Om(e,t,s,n,r,i,o,a){const h=Mm();h.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),h.processUnitParams(e);let m=null,l=null;if(n){l=n.getPECoordSys()}const g=Mm();g.initFromGcsAndVcsPe(l,m),g.processUnitParams(h),h.processUnitParams(g),a>0&&Am(h,g,i,o,a)}function Ym(e,t,s,n,r,i,o,a,h){const m=Mm(),l=Mm();m.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),l.assign(r?n.m_outputUnitParams:n.m_inputUnitParams),m.processUnitParams(e),l.processUnitParams(m),m.processUnitParams(l),a>0&&Am(m,l,i,o,a),h.assign(l)}function Rm(e,t,s,n,r,i,o){const a=t.getVerttran(),h=t.getGeogtran();if(o.assign(s?t.m_inputUnitParams:t.m_outputUnitParams),o.processUnitParams(e),i>0){t.prepareOrThrow();const e=s?bc.PE_TRANSFORM_2_TO_1:bc.PE_TRANSFORM_1_TO_2;a?dg():pg(h,i,n,r,e)}}function Xm(e,t,s,n,r){const i=e.getVerttran(),o=e.getGeogtran();if(r>0){e.prepareOrThrow();const a=t?bc.PE_TRANSFORM_2_TO_1:bc.PE_TRANSFORM_1_TO_2;i?dg():pg(o,r,s,n,a)}}class Lm{supportsCurves(){return!0}accelerateGeometry(e,t,s){return zm(e,t,s)}canAccelerateGeometry(e){return Wm(e)}}function zm(e,t,s){if(!Wm(e))return!1;ce(t,e,!1);let n=0;const r=e.getGeometryType();return h(r)&&v(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),h(r)&&N(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),n>0}function Wm(e){return v(e)||N(e)}class jm extends Lm{getOperatorType(){return 8}execute(e,t,s,n){return kr(e,t,s,1,n)}}function Zm(e,t,r,a){if(e.isEmpty()||t.isEmpty())return e;const h=e.getDimension(),m=t.getDimension();if(h>m)return e;const l=e.getGeometryType(),g=t.getGeometryType(),u=new s,c=new s,_=new s;e.queryEnvelope(u),t.queryEnvelope(c),_.setCoords({env2D:u}),_.mergeEnvelope2D(c);const d=fe(r,_,!0),p=Ee(d),f=new s;if(f.setCoords({env2D:u}),f.inflateCoords(p,p),!f.isIntersecting(c))return e;if(1===h&&2===m){const s=ol(e,t,g,r,a);if(s)return s}if(l===i.enumPoint){let s;switch(o(g)?(s=new w({vd:t.getDescription()}),s.addSegment(t,!0)):s=t,g){case i.enumPolygon:return Jm(e,s,d);case i.enumPolyline:return $m(e,s,d);case i.enumMultiPoint:return el(e,s,d);case i.enumEnvelope:return tl(e,s,d);case i.enumPoint:return sl(e,s,d);default:n("invalid shape type")}}else if(l===i.enumMultiPoint)switch(g){case i.enumPolygon:return nl(e,t,d);case i.enumEnvelope:return rl(e,t,d);case i.enumPoint:return il(e,t,d)}const x=new s(u);x.inflate(100*d.total());return Ya(e,Zt(t,x,0,0,a),r,a)}class Km{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n){return new Qm(e,t,s,n)}execute(e,t,s,n){return this.executeMany(new $t([e]),new $t([t]),s,n).next()}}class Qm extends es{constructor(e,t,s,n){super(),this.m_progressTracker=n,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=s;const r=t.next();this.m_geomSubtractor=r||new T}next(){const e=this.m_inputGeoms.next();return e?(r(e),m(e),this.m_index=this.m_inputGeoms.getGeometryID(),Zm(e,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function Jm(e,t,s,n){return 0===Xo(t,e,s.total())?e:e.createInstance()}function $m(e,t,n,r){const i=e.getXY(),o=t.querySegmentIterator(),a=Ee(n),h=a*a;for(;o.nextPath();)for(;o.hasNextSegment();){const t=o.nextSegment(),r=new s;if(t.queryEnvelope(r),r.inflateCoords(a,a),!r.contains(i))continue;if(t.isIntersectingPoint(i,n.total()))return e.createInstance();let m=t.getStartXY();if($e.sqrDistance(i,m)<=h)return e.createInstance();if(m=t.getEndXY(),$e.sqrDistance(i,m)<=h)return e.createInstance()}return e}function el(e,t,s,n){const r=t.getImpl().getAttributeStreamRef(0),i=t.getPointCount(),o=e.getXY(),a=Ee(s),h=a*a,m=new $e;for(let l=0;l<i;l++){r.queryPoint2D(2*l,m);if($e.sqrDistance(m,o)<=h)return e.createInstance()}return e}function tl(e,t,n,r){const i=new s;t.queryEnvelope(i),i.inflate(n.total());const o=e.getXY();return i.contains(o)?e.createInstance():e}function sl(e,t,s,n){const r=Ee(s),i=r*r,o=e.getXY(),a=t.getXY();return $e.sqrDistance(o,a)<=i?e.createInstance():e}function nl(e,t,n,r){const i=new s;t.queryEnvelope(i),i.inflate(n.total());const o=e.getPointCount();let a=!1;const h=Je(o,!1),m=new $e;for(let s=0;s<o;s++){if(e.queryXY(s,m),!i.contains(m))continue;0!==Lo(t,m,n.total())&&(a=!0,h[s]=!0)}if(!a)return e;const l=e.createInstance();for(let s=0;s<o;s++)h[s]||l.addPoints(e,s,s+1);return l}function rl(e,t,n,r){const i=new s;t.queryEnvelope(i),i.inflate(n.total());const o=e.getPointCount();let a=!1;const h=Je(o,!1),m=new $e;for(let s=0;s<o;s++)e.queryXY(s,m),i.contains(m)&&(a=!0,h[s]=!0);if(!a)return e;const l=e.createInstance();for(let s=0;s<o;s++)h[s]||l.addPoints(e,s,s+1);return l}function il(e,t,s,n){const r=e.getImpl().getAttributeStreamRef(0),i=e.getPointCount(),o=t.getXY();let a=!1;const h=Je(i,!1),m=Ee(s),l=m*m,g=new $e;for(let c=0;c<i;c++){r.queryPoint2D(2*c,g);$e.sqrDistance(g,o)<=l&&(a=!0,h[c]=!0)}if(!a)return e;const u=e.createInstance();for(let c=0;c<i;c++)h[c]||u.addPoints(e,c,c+1);return u}function ol(e,t,n,r,o){const a=new xe;e.queryEnvelope(a);const h=new s;t.queryEnvelope(h),a.merge(h);const m=.1*a.width(),l=.1*a.height();a.inflateCoords(m,l);const g=new T;g.addEnvelope(a,!1);const u=g.getImpl();if(n===i.enumPolygon){const e=t.getImpl();u.add(e,!0)}else u.addEnvelope(t,!0);return new Ih(g,r,-1,o).tryFastImplementation(e)}class al{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(e,t,s){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,s,n=0){return new gl(e,t,s,n)}execute(e,t,s,n){const r=new $t([e,t]),i=new gl(r,s,n,0).next();return i||a("null output"),i}}function hl(){return{geom:null,vertexCount:-1,bUnioned:!1,location:new $e}}function ml(e,t){return $e.compareZorder(e.location,t.location)?-1:e.location.equals(t.location)?0:1}class ll{constructor(){this.binVertexCount=0,this.geometries=[]}addPair(e){this.binVertexCount+=e.vertexCount,this.geometries.push(e)}sort(){this.geometries.sort((e,t)=>ml(e,t))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class gl extends es{constructor(e,t,s,n,r=!1){super(),this.m_index=-1,this.m_currentDim=-1,this.m_bDone=!1,this.m_unionBins=[],this.m_readyGeoms=et(4),this.m_dimGeomCounts=Je(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=Je(4,!1),this.m_complexUnionGeoms=et(4),this.m_totalNonEmptyGeomCounters=Je(4,0),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&n),this.m_bPreserveAllPathEnds=!!(8&n),this.m_inputGeoms=e,this.m_spatialReference=t,this.m_options=n,this.m_bIs3D=r}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(-1===this.m_maxDimension)return null;if(this.m_bUnionAllDimensions){if(-1===this.m_currentDim)for(let e=0;e<=this.m_maxDimension;e++)if(this.m_bHadGeometry[e]){this.m_complexUnionGeoms[e]=this.getResultGeometry(e);for(let t=e+1;t<=this.m_maxDimension;t++)this.m_complexUnionGeoms[t]=this.getResultGeometry(t),this.m_bHadGeometry[t]&&!this.m_complexUnionGeoms[t].isEmpty()&&(this.m_bIs3D?l(0):this.m_complexUnionGeoms[e]=(new Km).execute(this.m_complexUnionGeoms[e],this.m_complexUnionGeoms[t],this.m_spatialReference,this.m_progressTracker))}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&a(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===i.enumPoint){const e=new G({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||e.add(this.m_complexUnionGeoms[this.m_currentDim]),e}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(e){return this.m_readyGeoms[e]}finishDim(e,t,s){let n=t;if(!s)return 16&this.m_options?(n=ja([n],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),n):n;if(1&this.m_options)return n;if(1===e){if(!(8&this.m_options)&&(!!(16&this.m_options)||this.m_totalNonEmptyGeomCounters[e]>1)){n=ja([n],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const e=[0],t=n.getImpl().getIsSimple(0,e);l(this.m_bIs3D||de(t))}else 1===this.m_totalNonEmptyGeomCounters[e]&&(this.m_bIs3D?l(0):n=(new Eh).execute(n,this.m_spatialReference,!1,this.m_progressTracker))}else this.m_bIs3D?l(0):n=(new Eh).execute(n,this.m_spatialReference,!1,this.m_progressTracker);if(0===e&&n.getGeometryType()===i.enumPoint){const e=new G({vd:n.getDescription()});n.isEmpty()||e.add(n),n=e}return n}static getLevel(e){const t=4,s=u(e);let n=s>0?(Math.log(s)-Math.log(32))/Math.log(t):0;return n<0&&(n=0),Math.floor(n)}step_(){if(this.m_bDone)return!0;let e;if(this.m_inputGeoms?(e=this.m_inputGeoms.next(),null===e?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(e),e.isEmpty()||this.m_totalNonEmptyGeomCounters[e.getDimension()]++)):e=null,null!==e){const t=e.getDimension();this.m_bHadGeometry[t]=!0,(t>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(t,!1,e),t>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(t))}if(this.m_addedGeoms>0)for(let t=0;t<=this.m_maxDimension;t++){for(;this.m_dimGeomCounts[t]>1;){const e=this.collectGeometriesToUnion(t);if(null===e)break;{let s;s=1&this.m_options?ja(e,e.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):Za(e,e.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(t,!0,s)}}if(this.m_bDone&&(l(this.m_dimGeomCounts[t]<=1),0!==this.m_dimGeomCounts[t])){const e=this.m_unionBins[t].entries().next().value,s=e[1].geomPairs()[0].geom,n=e[1].geomPairs()[0].bUnioned;this.m_unionBins[t].clear(),this.m_readyGeoms[t]=this.finishDim(t,s,n)}}return this.m_bDone}addGeom(e,t,n){const r=hl();r.geom=n;const i=u(n);r.vertexCount=i;const o=s.constructEmpty();n.queryEnvelope(o),r.location=i>0?o.getCenter():new $e(0,0);const a=gl.getLevel(n);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let h=null;const m=this.m_unionBins[e].get(a);m&&(h=m),null===h&&(h=new ll,this.m_unionBins[e].set(a,h)),r.bUnioned=t,h.addPair(r),this.m_dimGeomCounts[e]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,e)}removeAllBinsWithLowerDimension(e){for(let t=0;t<e;t++)this.m_unionBins[t].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[t],this.m_dimGeomCounts[t]=0}collectGeometriesToUnion(e){if(1&this.m_options&&!this.m_bDone)return null;let t=null;const s=[];for(const n of this.m_unionBins[e].keys())s.push(n);tt(s);for(let n=0;n<s.length;n++){if(-1===s[n])continue;const r=this.m_unionBins[e].get(s[n]);{const i=5e3,o=4,a=r.getBinVertexCount()>i&&r.geomCount()>=o;if(this.m_bDone||a){for(let r=0;r<n;r++){if(-1===s[r])continue;const n=this.m_unionBins[e].get(s[r]);n.sort(),this.m_dimGeomCounts[e]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const e of n.geomPairs())t||(t=new Array),t.push(e.geom);n.clear(),this.m_unionBins[e].delete(s[r]),s[r]=-1}r.sort(),this.m_dimGeomCounts[e]-=r.geomCount(),this.m_addedGeoms-=r.geomCount();for(const e of r.geomPairs())t||(t=new Array),t.push(e.geom);if(r.clear(),this.m_unionBins[e].delete(s[n]),s[n]=-1,!this.m_bDone)break}}}return t}checkAndThrow(e){this.m_bIs3D&&(e.getDimension()>1&&c(),e.hasAttribute(1)||n("Geometry must have Zs")),r(e)}}class ul extends Lm{getOperatorType(){return 3}execute(e,t,s,n=null){return kr(e,t,s,4,n)}}function cl(e,t,n){const r=t.getGCSSplitLines();if(null===r)return e;const i=t.getGCS(),o=i.getPannableExtent().width(),a=s.constructEmpty();e.queryLooseEnvelope(a);const h=lt.constructEmpty();a.queryIntervalX(h);const m=r.querySegmentIterator();let l=null;const g=new jt;for(;m.nextPath();)for(;m.hasNextSegment();){const e=m.nextSegment(),t=e.queryInterval(0,0),s=lt.constructEmpty();s.setCoordsFromEnvelope(t);let n=0;for(;s.vmax>h.vmin;)s.move(-o),n--;for(;s.vmin<=h.vmax;){if(s.isIntersecting(h)){null===l&&(l=new w);const t=new A({start:e.getStartXY(),end:e.getEndXY()});0!==n&&(g.setShiftCoords(n*o,0),t.applyTransformation(g)),l.addSegment(t,!0)}s.move(o),++n}}if(null!==l){const t=ge(i,l,!0);return Un(e,l,Ee(t),n)}return e}function _l(e,t,s){let n=e.getName();return sc(n)||(s||t>0?(n=e.toString(bc.PE_STR_NAME_CANON|bc.PE_STR_AUTH_NONE),n=yl(n)):n=e.toString(bc.PE_STR_AUTH_TOP)),n}function dl(e,t,s,n){return l(0),""}function pl(e,t=-1){if((t>1||t<-1)&&n("verbosity"),-1===t)return e.toString();{const s=0===t?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return e.toString(s)}}function fl(e,t){(t>1||t<-1)&&n("verbosity");let s=bc.PE_STR_FMT_WKT2;return-1!==t&&(s|=0===t?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL),e.toString(s)}function xl(e){return l(0),""}function yl(e){return e.toLocaleUpperCase("en-US")}function Pl(e,t,s){const r=e.getPCSHorizon();if(r.getGeometryType()===i.enumPolygon){const n=e.getDefaultPrecisionSR().getTolerance(0),i=r;for(let e=0;e<s;e++)1!==Lo(i,t[e],n)&&t[e].setNAN();return}if(r.getGeometryType()===i.enumEnvelope){const e=r;for(let n=0;n<s;n++)e.contains(t[n])||t[n].setNAN();return}n("")}function El(e,t,s,n){for(let r=0;r<t;r++){if(e[r].y<s.ymin||e[r].y>s.ymax){e[r].setNAN();continue}const t=e[r].x;e[r].x=Gl(t,s,n)}}function Sl(e,t,n,r){if(e.isEmpty()||1===n)return e;const o=e.getGeometryType();if(o===i.enumPoint){const s=e,r=s.getXY();return 0===wl([r],1,t,n)||r.isNAN()?s.setEmpty():s.setXY(r),e}if(o===i.enumMultiPoint){const s=e,r=e.createInstance(),i=s.getPointCount();r.reserve(i);const o=s.getAttributeStreamRef(0),a=s.getDescription().getAttributeCount()>1,h=new ye,m=Float64Array.from(o.getArray());if(wl(m,i,t,n)>0)for(let e=0,t=2*i;e<t;e+=2)Number.isNaN(m[e])||(a?(s.getPointByVal(e>>1,h),h.setXYCoords(m[e],m[e+1]),r.add(h)):r.addXY(m[e],m[e+1]));return r}let m=e;const l=t.getOneDegreeGCSUnit(),g=90*l,u=180*l,c=360*l,_=t.getCentralMeridian(),d=.5*l,p=s.constructEmpty();m.queryEnvelope(p);const f=t.getGCSHorizon(),x=t.getGCSHorisonIsInclusive(),y=f.getGeometryType()===i.enumEnvelope,P=s.constructEmpty();f.queryEnvelope(P);const E=t.getGCS();if(2!==n&&4!==n||(P.xmin=_-u,P.xmax=P.xmin+c),4===n){if(!(p.width()>c-l)){const e=s.constructEmpty();e.setCoords({xmin:p.xmin-l,ymin:P.ymin,xmax:p.xmax+l,ymax:P.ymax}),m=(new Kt).execute(m,e,E,r);let t=Math.floor((_-p.getCenterX())/c);for(p.move(t*c,0);p.xmin>P.xmax;)t-=1,p.move(-c,0);for(;p.xmin<P.xmin;)t+=1,p.move(c,0);if(0!==t){const e=new jt;e.setShiftCoords(t*c,0),m.applyTransformation(e)}return m}n=2}if(2===n&&(P.xmin=_-u,P.xmax=P.xmin+c),p.ymin<-g||p.ymax>g){const e=s.constructEmpty();if(e.setCoords({xmin:p.xmin-l,ymin:-g,xmax:p.xmax+l,ymax:g}),m=(new Kt).execute(m,e,E,r),m.isEmpty())return m;m.queryEnvelope(p)}if(x&&(P.ymax<p.ymin||P.ymin>p.ymax))return m.createInstance();p.width()>c&&(m=ql(m,_-u,c,E,!0,0,!0,r),m.queryEnvelope(p));let S=Ul(p.xmin,p.xmax,P.xmin,P.xmax,c);if(0!==S&&p.move(S,0),p.xmax>P.xmax||p.xmin<P.xmin){if(p.xmax>P.xmax)for(;p.xmin>=P.xmax;)p.move(-c,0),S-=c;for(;p.xmin<P.xmax-c;)p.move(c,0),S+=c}const C=ce(E,f,!1);if(0!==S){const e=new jt;e.setShiftCoords(S,0),m.applyTransformation(e),S=0}if(x){if(y&&P.containsEnvelope(p))return m;const e=new Array(2);for(let t=0;t<2;t++){let s;if(y?s=h(o)?Zt(m,P,C,d,r):Zt(m,P,C,0,r):(s=(new wh).execute(m,f,E,r),s===f&&(s=s.clone())),P.xmin<=p.xmin&&P.xmax>=p.xmax)return s;if(P.xmin>=p.xmin&&P.xmax<=p.xmax)return s;if(e[t]=s,0===t){p.move(-c,0);const e=new jt;e.setShiftCoords(-c,0),m.applyTransformation(e)}}return h(o)?e[0].add(e[1],!1):a("intersect_with_GCS_horizon: unexpected geometry type"),e[0]}{if(P.ymax<p.ymin||P.ymin>p.ymax)return m;let e=0;for(;!m.isEmpty()&&p.xmax>P.xmin;){if(0!==e){const t=new jt;t.setShiftCoords(e,0),m.applyTransformation(t)}if(!(new ul).execute(m,f,E,r)){m=(new Km).execute(m,f,E,r),f===m&&(m=m.clone())}if(0!==e){const t=new jt;t.setShiftCoords(-e,0),m.applyTransformation(t)}e-=c,p.move(-c,0)}return m}}function Cl(s,n,r,i,o,a){const h={stack:[],error:void 0,hasError:!1};try{if(2===a){return Gs(s,n,r,i,o)}if(Math.abs(r.x-i.x)>=Math.PI||!Fg(r.x,i.x,o))return Number.NaN;r.x>i.x&&(i=ot(r,r=i));const t=e(h,new Cc,!1),m=e(h,new Cc,!1),l=e(h,new Cc,!1),g=r.clone();Dc.geodeticDistance(s,n,r.x,r.y,i.x,i.y,m,t,null,a);const u=m.val;let c=0,_=1;for(;u*(_-c)>1e-12*s;){const e=.5*(c+_);if(Dc.geodeticCoordinate(s,n,r.x,r.y,u*e,t.val,m,l,a),g.x=m.val,g.y=l.val,g.x===o)return g.y;if(Fg(r.x,g.x,o))_=e;else{if(!Fg(i.x,g.x,o))return Number.NaN;c=e}}return g.y}catch(m){h.error=m,h.hasError=!0}finally{t(h)}}function Il(e,t){let s;if(Array.isArray(e)){const n=e;s=new Float64Array(2*t);for(let e=0,r=0;e<t;e++,r+=2)s[r]=n[e].x,s[r+1]=n[e].y}else s=e;return s}function bl(e,t,s,n){for(let r=0,i=0;r<n;r++,i+=2)t[s+r].x=e[i],t[s+r].y=e[i+1]}function wl(e,t,n,r){if(0===t||1===r)return t;const o=Il(e,t);if(2===r){const s=n.getPannableExtentInGCS();let r=t;for(let e=0,n=2*t;e<n;e+=2)(o[e+1]>s.ymax||o[e+1]<s.ymin)&&(o[e]=Number.NaN,r--);return r?(Bl(o,t,s.xmin,s.width(),!0),e!==o&&bl(o,e,0,t),r):(e!==o&&bl(o,e,0,t),0)}const a=n.getOneDegreeGCSUnit(),h=90*a,m=180*a,l=360*a;let g=t;for(let s=0,i=2*t;s<i;s+=2)(o[s+1]>h||o[s+1]<-h)&&(o[s]=Number.NaN,g--);if(!g)return e!==o&&bl(o,e,0,t),0;const u=s.constructEmpty();u.setFromPoints(o,t);const c=n.getGCSHorizon(),_=n.getGCSHorisonIsInclusive(),d=c.getGeometryType()===i.enumEnvelope,p=s.constructEmpty();if(c.queryEnvelope(p),_&&(p.ymax<u.ymin||p.ymin>u.ymax))return e!==o&&bl(o,e,0,t),0;if(_){if(Bl(o,t,p.getCenterX()-m,l,!0),g=t,d)for(let e=0,s=2*t;e<s;e+=2)p.containsCoords(o[e],o[e+1])||(o[e]=Number.NaN,g--);else{const e=ce(n.getGCS(),c,!1),s=new $e;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(o[n],o[n+1]);0!==Lo(c,s,e)||(o[n]=Number.NaN,g--)}}}else{Bl(o,t,-m,l,!0),g=t;const e=ce(n.getGCS(),c,!1),s=new $e;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(o[n],o[n+1]),s.isNAN()&&g--;const t=Ml(s.x,p.xmin,p.xmax,l);s.x+=t;0!==Lo(c,s,e)&&(o[n]=Number.NaN,g--)}}return e!==o&&bl(o,e,0,t),g}function vl(e,t,s,r,i,o){if(t.isPannable()||n("fold_into_360_degree_range"),e.isEmpty())return e;let a,h;if(2===t.getCoordinateSystemType()){const e=t.getPannableExtent();h=e.xmin,a=e.width()}else{const e=t.getOneDegreeGCSUnit();a=360*e,h=s-180*e}return ql(e,h,a,t,r,i,!0,o)}function Nl(e,t,s,n){let r,i;if(2===s.getCoordinateSystemType()){const e=s.getPannableExtent();r=e.xmin,i=e.width()}else{const e=s.getOneDegreeGCSUnit();i=360*e,r=n-180*e}Bl(e,t,r,i)}function Tl(e,t){const s=t.width();let n=st(e-t.vmin,s);n<0&&(n+=s);return t.snapClip(n+t.vmin)}function Gl(e,t,s){return e>t.xmax&&e-t.xmax<s?t.xmax:e<t.xmin&&t.xmin-e<s?t.xmin:e}function Dl(e,t,s){if(e[0]<t.vmin||e[0]>t.vmax||s&&e[0]===t.vmax){const s=t.width();return e[0]+=Math.ceil((t.vmin-e[0])/s)*s,e[0]=t.snapClip(e[0]),!0}return!1}function Vl(e,t,s,n,r,i,o,a,h){return new Dm(e,null,s,t,n,r,o,a,i).geoNormalizePolygonGeometry(h)}function Fl(e,t,s,n,r,i,o,a,h){return new Dm(e,null,s,t,n,r,o,a,i).geoNormalizePolylineGeometry(h)}function Hl(e,t,s,n,r){const i=new V,o=i.addGeometry(e);return kl(i,o,t,ce(t,e,!1),s,n,r),i.getGeometry(o)}function kl(s,n,r,i,o,a,h){const m={stack:[],error:void 0,hasError:!1};try{l(Uu()),r.isPannable()||p("insert_geodetic_points");const t=r.getPannableExtent(),g=r.getGCS(),u=Hu();g.querySpheroidData(u);const c=g.getUnit().getUnitToBaseFactor(),_=u.majorSemiAxis,d=u.e2;let f=0;const x=new lt;t.queryIntervalX(x);let y=null;const P=Je(4,Number.NaN);2===r.getCoordinateSystemType()?(y=r.getPECoordSys(),a?(P[0]=Tl(h,x),P[1]=t.getCenterY(),wc.projToGeog(y,1,P),f=P[0]*c):(P[0]=t.getCenterX(),P[1]=h,wc.projToGeog(y,1,P),f=P[1]*c)):f=h*c,a||0===f||2===o||p("insert_geodetic_points: 1");const E=e(m,new Cc,!1),S=new $e,C=new $e,I=new $e,b=new $e,w=new $e,v=new $e;for(let e=s.getFirstPath(n);e!==q;e=s.getNextPath(e)){const t=s.getFirstVertex(e);s.queryXY(t,I);let n=!1;const m=s.getNextVertex(t);for(let e=m;e!==q;e=s.getNextVertex(e)){if(e===m){if(n)break;n=!0}if(s.queryXY(e,b),a&&(i<h-I.x&&b.x-h>i||i<h-b.x&&I.x-h>i)||!a&&(0!==h||i<-I.y&&b.y>i||i<-b.y&&I.y>i))do{if(Math.abs(I.x-b.x)>=.5*x.width())break;2===r.getCoordinateSystemType()?(P[0]=Tl(I.x,x),P[1]=I.y,P[2]=Tl(b.x,x),P[3]=b.y,ag(y,2,P,0),w.x=P[0]*c,w.y=P[1]*c,v.y=P[3]*c):(w.x=I.x*c,w.y=I.y*c,v.y=b.y*c),v.x=(b.x-I.x)*Math.PI*2/x.width()+w.x;let t=0;const n=ut($e,2);if(a){if(C.x=f,C.y=Cl(_,d,w,v,f,o),Number.isNaN(C.y))break;n[0]=C,t=1}else if(2===o){const e=[0,0];if(t=Ds(_,d,w,v,f,e),!t)break;n[0].x=e[0],n[0].y=f,2===t&&(n[1].x=e[1],n[1].y=f)}else{if(C.x=Hg(_,d,w,v,o),Number.isNaN(C.x))break;C.y=0,n[0]=C,t=1}let i=-1;for(let m=0;m<t;m++){Dc.geodeticDistance(_,d,w.x,w.y,v.x,v.y,E,null,null,o);const t=E.val;Dc.geodeticDistance(_,d,w.x,w.y,n[m].x,n[m].y,E,null,null,o);const l=E.val;2===r.getCoordinateSystemType()?(P[0]=n[m].x/c,P[1]=n[m].y/c,wc.geogToProj(y,1,P),a?(S.y=P[1],S.x=h):(S.x=kg(P[0],I.x,b.x,x),S.y=h)):a?(S.x=h,S.y=n[m].y/c):(S.x=kg(n[m].x/c,I.x,b.x,x),S.y=h);const g=t>0?Ct(l/t,0,1):.5;if(0===g||1===g)continue;if(i>g)continue;const u=s.getPrevVertex(e);s.splitSegment(u,[g],1);const p=s.getNextVertex(u);s.setXYCoords(p,S.x,S.y),i=g}}while(0);I.setCoordsPoint2D(b)}}}catch(g){m.error=g,m.hasError=!0}finally{t(m)}}function Al(e,t){l(t.isPannable());const n=t.getPannableExtent();if(e.getGeometryType()===i.enumPoint){const t=e.getY();return n.ymin<=t&&t<=n.ymax?e:e.createInstance()}const r=s.constructEmpty();e.queryEnvelope(r);const o=s.constructEmpty();o.setCoords({env2D:n}),o.xmin=r.xmin,o.xmax=r.xmax,o.inflateCoords(.01*o.height(),0);const a=ue(t,r,!1);let h;return h=o.containsEnvelope(r)?e:Zt(e,o,a,0,null),h}function Ml(e,t,s,n){return it((.5*(s+t)-e)/n)*n}function Ul(e,t,s,n,r){if(e>=s&&t<=n)return 0;return Ml(.5*(t+e),s,n,r)}function ql(e,t,n,r,o,a,h,m){const l=e.getGeometryType(),g=lt.constructEmpty();g.setCoords(t,t+n);const u=[0];if(l===i.enumPoint){const t=e;if(u[0]=t.getX(),Dl(u,g,h)){const t=o?e:e.clone();return t.setX(u[0]),t}return e}const c=s.constructEmpty();if(e.queryEnvelope(c),c.isEmpty())return e;if(l===i.enumMultiPoint){const t=o?e:e.clone(),s=t.getImpl(),n=s.getAttributeStreamRef(0),r=2*s.getPointCount();let i=!1;for(let e=0;e<r;e+=2)u[0]=n.read(e),Dl(u,g,h)&&(n.write(e,u[0]),i=!0);return i&&s.notifyModifiedFlags(2001),t}const _=lt.constructEmpty();if(c.queryIntervalX(_),g.contains(_))return g.vmax,_.vmax,e;const d=s.constructEmpty();if(d.setCoords({env2D:c}),0===_.width()){let t=_.vmin;t+=Math.ceil((g.vmin-t)/n)*n,t=g.snapClip(t);const s=o?e:e.clone();return s.setAttributeBasic(0,0,t),s}if(l===i.enumEnvelope){const t=o?e:e.clone();return c.intersect(d),t.setEnvelope(c),t}const p=.1*Math.max(c.height(),c.width())*1;d.inflateCoords(0,p);let f=e;const x=r.getTolerance(0),y=new jt;for(;;){const e=Math.floor((_.vmin-t)/n),s=Math.ceil((_.vmax-t)/n);if(!(s-e>3))break;{const o=Math.floor(.5*(s+e));d.xmin=c.xmin-p,d.xmax=t+n*o;const h=Zt(f,d,x,a,m);d.xmin=d.xmax,d.xmax=c.xmax+p;const g=Zt(f,d,x,a,m);y.setShiftCoords((o-s)*n,0),g.applyTransformation(y),l===i.enumPolygon?f=(new al).execute(h,g,r,m):(f=h,f.add(g,!1)),f.queryEnvelope(c),c.queryIntervalX(_)}}d.xmin=t,d.xmax=t+n;const P=s.constructEmpty();P.setCoords({env2D:d}),P.inflateCoords(x,0);const E=Math.floor((c.xmin-d.xmin)/n)*n;let S;E?(d.move(E,0),y.setShiftCoords(-E,0)):y.setIdentity(),S=l===i.enumPolyline?new w({vd:f.getDescription()}):new T({vd:f.getDescription()});const C=s.constructEmpty(),I=s.constructEmpty();for(;c.xmax>d.xmin;){const e=Zt(f,d,x,0,m);e.queryEnvelope(I);let t=!1;t=l===i.enumPolyline?!e.isEmpty()&&(I.width()>x||I.height()>x):!e.isEmpty()&&(l!==i.enumPolygon||I.width()>x),t&&(e.applyTransformation(y),e.queryEnvelope(I),S.queryEnvelope(C),C.inflateCoords(x,x),C.isIntersecting(I)&&l===i.enumPolygon?S=(new al).execute(S,e,r,m):S.add(e,!1)),d.move(n,0),y.shiftCoords(-n,0)}return S}function Bl(e,t,s,n,r=!0){const i=new lt;i.setCoords(s,s+n);const o=[0];if(Array.isArray(e)){const s=e;for(let e=0;e<t;e++)i.containsRightExclusive(s[e].x)||(o[0]=s[e].x,Dl(o,i,r),s[e].x=o[0])}else{const s=e;for(let e=0;e<t;e++){const t=e<<1;i.containsRightExclusive(s[t])||(o[0]=s[t],Dl(o,i,r),s[t]=o[0])}}}function Ol(e,t,n,r=!0){if(e.isEmpty())return;const o=e.getGeometryType();if(!r||o!==i.enumPolygon)if(x(o)){let s=!1;if(h(o)&&e.hasNonLinearSegments()){const r=e.getImpl(),i=r.getAttributeStreamRef(0),o=r.getSegmentFlagsStreamRef();l(null!==o);for(let e=0,a=r.getPathCount();e<a;e++){let a=!0;const h=r.isClosedPath(e),m=r.getPathEnd(e);if(h&&r.getPathSize(e)>0){a=1===(31&o.read(m-1))}for(let l=r.getPathStart(e);l<m;l++){if(1===(31&o.read(l))){if(a){const e=i.read(2*l),r=Gl(e,t,n);r!==e&&(s=!0,i.write(2*l,r))}a=!0}else a=!1}}}else{const r=e.getImpl(),i=r.getAttributeStreamRef(0);for(let e=0,o=r.getPointCount();e<o;e++){const r=i.read(2*e),o=Gl(r,t,n);o!==r&&(s=!0,i.write(2*e,o))}}s&&e.getImpl().notifyModifiedFlags(2001)}else if(o===i.enumEnvelope){const r=e,i=s.constructEmpty();r.queryEnvelope(i),i.xmin=Gl(i.xmin,t,n),i.xmax=Gl(i.xmax,t,n),r.setEnvelope(i)}else if(o===i.enumPoint){const s=e;s.setX(Gl(s.getX(),t,n))}else a("")}function Yl(e,t,s){const n=new $e;return n.x=Gl(e.x,t,s),n.y=e.y,n}function Rl(e,t){if(t.isEmpty())return 0;const n=e.getPECoordSys();if(n.getProjection().getCode()===bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const r=Hu();e.querySpheroidData(r);const i=n.getParameters();if(null===i[bc.PE_PARM_LAM0])return 0;if(null===i[bc.PE_PARM_PHI0])return 0;const o=[i[bc.PE_PARM_LAM0].getValue(),i[bc.PE_PARM_PHI0].getValue()];wc.geogToProj(n,1,o);const a=new $e(o[0],o[1]),h=s.constructEmpty();t.queryEnvelope(h);const m=ut($e,4);h.queryCorners(m);let l=0;const g=e.getOneMeter();let u=Math.max(r.majorSemiAxis,r.minorSemiAxis)*Math.PI,c=Math.min(r.majorSemiAxis,r.minorSemiAxis)*Math.PI;c-=u/180,u*=g,c*=g;for(let e=0;e<4;e++){const t=$e.distance(m[e],a);if(t>u)l++;else if(t>c)return-1}if(0===l)return 1;if(4===l){const e=s.constructEmpty();return e.setCoords({center:a,width:u,height:u}),h.isIntersectingNe(e)?-1:0}return-1}return-1}function Xl(e,t,n,r){const o=e.getGeometryType();l(o===i.enumPolygon||o===i.enumPolyline||o===i.enumMultiPoint);const a=t.getCoordinateSystemType();if(2===a){let a=e;if(0===n){const n=Rl(t,e);if(0===n)return e.createInstance();if(1===n)return e;const o=t.getPCSHorizon(),h=o.getGeometryType(),m=t.getDefaultPrecisionSR();if(h===i.enumEnvelope){const n=s.constructEmpty();o.queryEnvelope(n);const i=ue(m,n,!1);a=Zt(e,n,i,5e4*t.getOneMeterPCSUnit(),r)}else(new jm).execute(o,e,m,r)||(a=(new wh).execute(a,o,m,r),a===o&&(a=a.clone()))}else if(t.isPannable()){const e=s.constructEmpty();a.queryEnvelope(e);const h=t.getPannableExtent();h.containsEnvelope(e)||(Ol(a,h,t.getTolerance(0)),2!==n&&4!==n||(a=Al(a,t)),4!==n?a=vl(a,t,0,!0,1e5*t.getOneMeterPCSUnit(),r):o===i.enumPolygon&&e.width()>2*h.width()&&(a=ql(a,-2*h.width(),2*h.width(),t,!0,0,!0,r)))}return a}if(l(1===a),o===i.enumMultiPoint)return Ol(e,t.getPannableExtent(),t.getTolerance(0)),e;{const n=s.constructEmpty();e.queryEnvelope(n);let a=e;const h=t.getPannableExtent();if(n.ymin<h.ymin||n.ymax>h.ymax){const e=Math.max(1,n.calculateToleranceFromEnvelope()),i=new s(n.xmin-e,h.ymin,n.xmax+e,h.ymax);if(a=(new Kt).execute(a,i,t,r),a.isEmpty())return a}return o===i.enumPolygon&&n.width()>2*h.width()&&(a=ql(a,-2*h.width(),2*h.width(),t,!0,0,!0,r)),a}}function Ll(e,t,s,n,r,i){const o=n.getCoordinateSystemType();if(2===o){if(0===r)s!==e&&nt(s,e,t),Pl(n,s,t);else if(s!==e&&nt(s,e,t),n.isPannable()){const e=n.getTolerance(0);El(s,t,n.getPannableExtent(),e),Nl(s,t,n,0)}}else{l(1===o);const r=n.getTolerance(0),i=n.getPannableExtent();for(let n=0;n<t;n++)s[n].assign(Yl(e[n],i,r))}}function zl(e,t){const s=t.getPointCount();if(!s)return;const n=t.getImpl(),r=n.getAttributeStreamRef(0),i=e;wc.geogToProj(i,s,r.getArray()),n.notifyModifiedFlags(2001)}function Wl(e,t,s,n){if(!s)return;const r=e.getPECoordSys();if(1===s){if(t[0].isNAN())return;const s=[t[0].x,t[0].y];if(wc.geogToProj(r,1,s),n){const{first:n,second:r}=e.m_peCoordSysVal.getGeogToProjFactors();s[0]=n*(t[0].x-e.getCentralMeridian())+r}return void t[0].setCoords(s[0],s[1])}const i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let h=0;i&&(h=e.getCentralMeridian());const m=256,l=new Float64Array(2*m);for(let g=0;g<s;){for(let e=g;e<s&&t[e].isNAN();++e)g++;let u=Math.min(m,s-g);if(u>0){for(let e=1,s=g+1;e<u;++e,++s)if(t[s].isNAN()){u=e;break}for(let e=0;e<u;++e){const s=e<<1;l[s]=t[g+e].x,l[s+1]=t[g+e].y}if(wc.geogToProj(r,u,l),n){const{first:s,second:n}=e.m_peCoordSysVal.getGeogToProjFactors();for(let e=0;e<u;++e){l[e<<1]=s*(t[g+e].x-h)+n}}if(i)for(let e=0,s=g;e<u;e++,s++){const n=e<<1,r=l[n],i=at(r),m=t[s].x-h;i*at(m)<0&&Math.abs(r)>a&&(l[n]-=i*o)}bl(l,t,g,u),g+=u}}}function jl(e,t,s,n){const r=e.getSRToGCSTransform();return(new qh).transform(r,t,s,n,!1)}function Zl(e,t,n,r){const i=new G({vd:t.getDescription()});let o;i.addPoints(t,0,-1),o=(new qh).execute(i,e,r);const a=t.getPointCount();if(n.setEmpty(),e.getInputSR().isPannable()){if(a!==o.getPointCount())return!1;const r=new s;t.queryEnvelope(r);const i=new s;o.queryEnvelope(i);const h=r.width(),m=i.width();if(0!==h&&0!==m){const t=m/h,s=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/s-1)>1e-10)return!1}else if(0!==h||0!==m)return!1;n.add(t,!1);for(let e=0;e<a;e++){const t=o.getXY(e);n.setXY(e,t)}return!0}return!1}function Kl(e,t,s){l(!s||e.isPannable());const n=t.getPointCount();if(!n)return;const r=t.getImpl(),i=r.getAttributeStreamRef(0),o=e.getPECoordSys();let a=0;const h=i.readRange(0,2*n);let m=()=>{wc.geogToProj(o,n,h)};const g=e.isPannable()&&!s,u=g?e.getPannableExtent().width():0,c=179*u/360;if(e.isPannable()&&(a=e.getCentralMeridian(),s)){const t=e.m_peCoordSysVal.getGeogToProjFactors(),s=t.first,r=t.second;m=()=>{wc.geogToProj(o,n,h);for(let e=0;e<n;e++){const t=e<<1,n=i.read(t),o=s*(n-a)+r;h[t]=o}}}if(m(),g)for(let l=0;l<n;l++){const e=l<<1,t=h[e],s=at(t),n=i.read(e)-a;s*at(n)<0&&Math.abs(t)>c&&(h[e]+=-s*u)}i.writeRangeFromArray(0,2*n,h,!0,1),r.notifyModifiedFlags(2001)}function Ql(e,t,s){switch(t.getGeometryType()){case i.enumLine:return void Ig(e,t,s);case i.enumBezier:return void Gg(e,t,s);case i.enumEllipticArc:return void wg(e,t,s);case i.enumBezier2:return void Dg();case i.enumRationalBezier2:return void Vg();default:a("")}}function Jl(e,t,s){if(!t.hasNonLinearSegments())return void Kl(e,t,s);if(l(!s||e.isPannable()),t.isEmpty())return;const n=0,r=e.getPECoordSys(),i=e.isPannable(),o=i?e.getPannableExtent().width():0,a=179*o/360;let h=0;i&&(h=e.getCentralMeridian());const m=t.createInstance();m.reserveParts(t.getPointCount(),t.getPathCount());const g=t.getImpl(),u=new k;for(let l=0,c=t.getPathCount();l<c;++l)if(g.hasNonLinearSegmentsPath(l)){let t=!0,n=-1;const r=g.getPathStart(l),i=r+g.getSegmentCountPath(l);g.isClosedPath(l)&&(n=i-1);const o=new $e;for(let a=r;a<i;++a){if(g.getSegmentBuffer(a,u,!1),Ql(e,u.get(),s),!t){u.get().getStartXY().equals(o)||u.get().moveTo(o)}if(a!==n)m.addSegment(u.get(),t);else{if(t){const e=new ye;u.get().queryStart(e),m.startPathPoint(e)}m.closeLastPathWithSegment(u.get())}o.assign(u.get().getEndXY()),t=!1}}else{const e=1024;let s,u=g.getPathSize(l),c=Math.min(u,e);m.insertPath(-1,t,l,!0);const _=g.getAttributeStreamRef(0),d=m.getAttributeStreamRef(0);for(let t=g.getPathStart(l),m=g.getPathEnd(l);t<m;){if(s=_.readRange(t,c),wc.geogToProj(r,c,s),i)for(let e=0;e<c;e++){const t=e<<1,r=s[t],i=at(r),m=_.read(2*(n+e))-h;i*at(m)<0&&Math.abs(r)>a&&(s[t]+=-i*o)}d.writeRangeFromArray(t,c,s,!0,1),t+=c,u-=c,c=Math.min(u,e)}}t.assignMove(m)}function $l(e,t,s){const n=1e3;let r=s.getPointCount();if(!r)return;const i=s.getImpl(),o=i.getAttributeStreamRef(0);let a=Math.min(r,n),h=0;const m=e.getPECoordSys();Number.isNaN(t)&&(t=0);const l=e.isPannable(),g=e.getOneDegreeGCSUnit(),u=360*g,c=179*g;let _;for(;r;){if(_=o.readRange(2*h,2*a),ag(m,a,_,t),l)for(let e=0;e<a;e++){const s=e<<1,n=_[s]-t,r=at(n),i=o.read(2*(h+e));r*at(i)<0&&Math.abs(n)>c&&(_[s]+=-r*u)}o.writeRangeFromArray(2*h,2*a,_,!0,1),h+=a,r-=a,a=Math.min(r,n)}i.notifyModifiedFlags(2001)}function eg(e,t,s){switch(s.getGeometryType()){case i.enumLine:return void tg(e,t,s);case i.enumBezier:return void rg(e,t,s);case i.enumEllipticArc:return void sg(e,t,s);case i.enumBezier2:return void ig();case i.enumRationalBezier2:return void og();default:a("")}}function tg(e,t,s){const n=[s.getStartXY(),s.getEndXY()];mg(e,t,n,2),s.setStartXY(n[0]),s.setEndXY(n[1]),s.normalizeAfterEndpointChange()}function sg(e,t,s){if(0===s.projectionBehavior())ng(e,t,s);else{const n=s.isClosed()&&s.isMajor(),r=[s.getStartXY(),n?s.getCenter():s.getEndXY()],i=[r[0].clone(),r[1].clone()];vg(e,t,i,2);const o=new jt;o.initializeFromTwoPointsArray(r,i),s.applyTransformation(o);const a=n?0:1;s.setCoordsForIntersector(i[0],i[a],!1)}}function ng(e,t,s){Ng(!1,e,t,s,!1)}function rg(e,t,s){const n=ut($e,4);s.queryControlPoints(n),vg(e,t,n,4),s.setControlPoints(n)}function ig(e,t,s){l(0)}function og(e,t,s){l(0)}function ag(e,t,s,n){const r=wc.projToGeogCenter(e,t,s,n);for(let i=0;i<t;++i){const e=i<<1;l(Number.isFinite(s[e]+s[e+1]))}return r}function hg(e,t,s){if(!s.hasNonLinearSegments())return void $l(e,t,s);if(s.isEmpty())return;const n=e.getPECoordSys();Number.isNaN(t)&&(t=0);const r=e.isPannable(),i=e.getOneDegreeGCSUnit(),o=360*i,a=179*i,h=s.createInstance();h.reserveParts(s.getPointCount(),s.getPathCount());const m=s.getImpl(),l=new k;for(let g=0,u=s.getPathCount();g<u;++g)if(m.hasNonLinearSegmentsPath(g)){let s=!0,n=-1;const r=m.getPathStart(g),i=r+m.getSegmentCountPath(g);m.isClosedPath(g)&&(n=i-1);const o=new $e;for(let a=r;a<i;++a){if(m.getSegmentBuffer(a,l,!1),eg(e,t,l.get()),!s){l.get().getStartXY().equals(o)||l.get().moveTo(o)}if(a!==n)h.addSegment(l.get(),s);else{if(s){const e=new ye;l.get().queryStart(e),h.startPathPoint(e)}h.closeLastPathWithSegment(l.get())}o.assign(l.get().getEndXY()),s=!1}}else{const e=1e3;let i,l=m.getPathSize(g),u=Math.min(l,e);h.insertPath(-1,s,g,!0);const c=m.getAttributeStreamRef(0),_=h.getAttributeStreamRef(0);for(let s=m.getPathStart(g),h=m.getPathEnd(g);s<h;){if(i=c.readRange(2*s,2*u),ag(n,u,i,t),r)for(let e=0;e<u;e++){const n=e<<1,r=i[n]-t,h=at(r),m=c.read(2*s);h*at(m)<0&&Math.abs(r)>a&&(i[n]+=-h*o)}_.writeRangeFromArray(2*s,2*u,i,!0,1),s+=u,l-=u,u=Math.min(l,e)}}s.assignMove(h)}function mg(e,t,s,n){const r=e.getPECoordSys();Number.isNaN(t)&&(t=0);const i=e.isPannable(),o=e.getOneDegreeGCSUnit(),a=360*o,h=179*o,m=256,l=new Float64Array(2*m);for(let g=0;g<n;){for(let t=g;t<n&&s[t].isNAN();++t)g++;let e=Math.min(m,n-g);if(e>0){for(let t=1,n=g+1;t<e;++t,++n)if(s[n].isNAN()){e=t;break}for(let t=0;t<e;t++){const e=t<<1;l[e]=s[g+t].x,l[e+1]=s[g+t].y}if(ag(r,e,l,t),i)for(let n=0,r=g;n<e;++n,++r){const e=n<<1,i=s[r].x,o=l[e]-t,m=at(o);m*at(i)<0&&Math.abs(o)>h&&(l[e]-=m*a)}for(let t=0;t<e;t++){const e=t<<1;s[g+t].x=l[e],s[g+t].y=l[e+1]}g+=e}}}function lg(e,t,s,n){l(0)}function gg(e,t,s){let n=t.getPointCount();if(!n)return!1;const r=t.getImpl(),i=r.getAttributeStreamRef(0);let o=null;const a=e.getInputSR(),h=e.getOutputSR();a.getVCS(),h.getVCS();const m=a.getOneDegreeGCSUnit(),l=h.getOneDegreeGCSUnit(),g=e.isVertical();g&&t.hasAttribute(1)&&(o=r.getAttributeStreamRef(1));const u=e.getDatumTransformation(),c=!!u&&1===u.getType();if(c||null===o||(lg(o.getArray()),o=null),!u||0===u.count()){const e=a.getGcsUnitFactor()/h.getGcsUnitFactor(),t=(a.getPrimeMeridian()-h.getPrimeMeridian())*l,s=-90*m,o=90*m;let g=0;const u=i.getArray(),c=[0];for(let r=1,i=2*n;r<i;)c[0]=u[r],g|=At(c,s,o)?1:0,u[r]=c[0],r+=2;if(0!==t||1!==e){g=1;const s=i.getArray();for(let r=0,i=2*n;r<i;){let n=s[r];n*=e,n+=t,s[r]=n,s[r+1]*=e,r+=2}}return 0!==g&&r.notifyModifiedFlags(2001),!!g}const _=1e3;let d=Math.min(n,_);const p=Je(d,Number.NaN),f=Je(d,Number.NaN);let x=null;null!==o&&(x=new Float64Array(d));let y=0,P=Number.NaN,E=Number.NaN;const S=360*l,C=l/m;s&&(E=90*l,P=89.9*m,f.fill(0));let I=!0,b=0;for(;n;){let e=!1;const t=i.readRange(2*y,2*d);for(let s=0;s<d;s++)p[s]=t[s<<1];if(s)for(let s=0;s<d;s++){const n=1+(s<<1),r=Math.abs(t[n])-P;if(r>0){const i=t[n];t[n]=ft(P,i),f[s]=ft(r,i),e=!0}}const r=t[0];if(c){const e=u;x&&o.queryRange(y,d,x,!0,1),e.transform(!1,t,x,d),x&&o.writeRangeFromArray(y,d,x,!0,1)}else{u.transform(!1,t,d)}I&&(b=t[0]-C*r,I=!1);for(let s=0;s<d;s++){const e=s<<1,n=t[e]-p[s]*C-b;Math.abs(n)>200&&(t[e]+=n>0?-S:S)}if(e){for(let e=0;e<d;e++)if(f[e]){const s=1+(e<<1);t[s]+=C*f[e],t[s]>E?t[s]=E:t[s]<-E&&(t[s]=-E)}f.fill(0)}i.writeRangeFromArray(2*y,2*d,t,!0,1),g&&o&&o.writeRangeFromArray(y,d,x,!0,1),y+=d,n-=d,d=Math.min(n,_)}return r.notifyModifiedFlags(2001),!0}function ug(e,t,s){switch(t.getGeometryType()){case i.enumLine:return xg(e,t,s);case i.enumBezier:return Eg(e,t,s);case i.enumEllipticArc:return yg(e,t,s);case i.enumBezier2:return Sg();case i.enumRationalBezier2:return Cg();default:a("")}}function cg(e,t,s){if(!t.hasNonLinearSegments())return gg(e,t,s);if(t.isEmpty())return!1;const n=t.createInstance();n.reserveParts(t.getPointCount(),t.getPathCount());const r=t.getImpl(),i=new k;for(let o=0,a=t.getPathCount();o<a;++o){let t=!0,a=-1;const h=r.getPathStart(o),m=h+r.getSegmentCountPath(o);r.isClosedPath(o)&&(a=m-1);const l=new $e;for(let o=h;o<m;++o){if(r.getSegmentBuffer(o,i,!1),ug(e,i.get(),s),!t){i.get().getStartXY().equals(l)||i.get().moveTo(l)}if(o!==a)n.addSegment(i.get(),t);else{if(t){const e=new ye;i.get().queryStart(e),n.startPathPoint(e)}n.closeLastPathWithSegment(i.get())}l.assign(i.get().getEndXY()),t=!1}}return t.assignMove(n),!0}function _g(e,t,s,n,r,i){if(e.isIdentityGeogToGeog()){const s=90*e.getInputSR().getOneDegreeGCSUnit();let r=0;const i=[0];for(let e=0;e<n;e++)i[0]=t[e].y,r|=At(i,-s,s)?1:0,t[e].y=i[0];return r}const o=e.getInputSR(),a=e.getOutputSR(),h=o.getVCS(),m=a.getVCS(),l=o.getOneDegreeGCSUnit(),g=90*l,u=a.getOneDegreeGCSUnit(),c=e.isVertical(),_=e.getDatumTransformation(),d=!!_&&1===_.getType();if(c||(s=null),!_||0===_.count()){let e=0;const r=[0];for(let s=0;s<n;s++)r[0]=t[s].y,e|=At(r,-g,g)?1:0,t[s].y=r[0];return e|=qm(o.getGCS(),h,a.getGCS(),m,t,s,n)?1:0,e}d||null===s||lg();const p=1024;let f=Math.min(n,p);const x=Je(f,Number.NaN),y=Je(f,Number.NaN);let P=0,E=Number.NaN,S=Number.NaN;const C=360*u,I=u/l;r&&(S=90*u,E=89.9*l);let b=!0,w=0,v=n;for(;v;){let e=!1;for(let s=0;s<f;s++)x[s]=t[s+P].x;if(r)for(let s=0;s<f;s++){const n=Math.abs(t[s+P].y)-E;if(n>0){const r=t[s+P].y;t[s+P].y=ft(E,r),y[s]=ft(n,r),e=!0}}const n=t[0].x;if(d){_.transform(!1,t,s,f)}else{_.transform(!1,t,f)}b&&(w=t[0].x-I*n,b=!1);for(let s=0;s<f;s++){const e=t[P+s].x-x[s]*I-w;Math.abs(e)>200&&(e>0?t[P+s].x-=C:t[P+s].x+=C)}if(e){for(let e=0;e<f;e++)y[e]&&(t[P+e].y+=I*y[e],t[P+e].y>S?t[P+e].y=S:t[P+e].y<-S&&(t[P+e].y=-S));y.fill(0,0,f)}P+=f,v-=f,f=Math.min(v,p)}return 1}function dg(e,t,s,n,r){return l(0),0}function pg(e,t,s,n,r){l(null===n),l(t<2147483647);const i=Array.isArray(s);let o;o=i?Ot(s):s;const a=vc.geogToGeog(e,t,o,null,r);return i&&Yt(o,s),a}function fg(e,t,s,n,r,i){let o=0,a=!0,h=0;for(let m=0;m<n;++m)t[m].isNAN()?a||(o|=_g(e,t.slice(h,m-h),s?s.slice(h,m-h):null,m-h,r),h=m,a=!0):a&&(h=m,a=!1);return a||(o|=_g(e,0===h?t:t.slice(h),s?0===h?s:s.slice(h):null,n-h,r)),0!==o}function xg(e,t,s){const n=[t.getStartXY(),t.getEndXY()],r=[0,0];let i=null;t.hasAttribute(1)&&(i=r,i[0]=t.getAttributeAsDbl(0,1,0),i[1]=t.getAttributeAsDbl(1,1,0));const o=fg(e,n,i,2,s);return t.setStartXY(n[0]),t.setEndXY(n[1]),i&&(t.setStartAttribute(1,0,i[0]),t.setEndAttribute(1,0,i[1])),t.normalizeAfterEndpointChange(),o}function yg(e,t,s){if(0===t.projectionBehavior())return Pg(e,t,s);const n=t.getStartXY().equals(t.getEndXY()),r=ut($e,3),i=ut($e,3),o=[0,0,0];let a=null;r[0].assign(t.getStartXY()),r[1].assign(n?t.getCenter():t.getEndXY());let h=!1;t.hasAttribute(1)&&(a=o,a[0]=t.getAttributeAsDbl(0,1,0),a[1]=t.getAttributeAsDbl(1,1,0),a[2]=pt(a[0],a[1],.5),n&&(a[1]=a[2])),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]);const m=new jt;if(n||t.isDegenerateToLine())h=fg(e,i,a,2,s),m.initializeFromTwoPoints(r[0],r[1],i[0],i[1]);else{const n=new $e;t.queryCoord2D(.5,n),r[2].setCoordsPoint2D(n),i[2].setCoordsPoint2D(n),h=fg(e,i,a,3,s),m.setFromTwoTriangles(r,i)}return m.isIdentity()||(t.applyTransformation(m),t.setStartXY(i[0]),t.setEndXY(n?i[0]:i[1]),t.normalizeAfterEndpointChange()),a&&(t.setStartAttribute(1,0,a[0]),t.setEndAttribute(1,0,n?a[0]:a[1])),h}function Pg(e,t,s){const n=[t.getStartXY(),t.getEndXY(),t.getInteriorPoint(),t.getCenter()];let r=4;t.isDegenerateToLine()&&(r=2);const i=[0,0,0,0];let o=null;if(t.hasAttribute(1)){o=i,o[0]=t.getAttributeAsDbl(0,1,0),o[1]=t.getAttributeAsDbl(1,1,0);const e=pt(o[0],o[1],.5);o[2]=e,o[3]=e}const a=t.getStartXY().equals(t.getEndXY())&&!t.isDegenerateToLine(),h=fg(e,n,o,r,s);return a?t.constructCircleCenterAndPoint(n[3],n[0],!t.isClockwise()):t.isDegenerateToLine()?t.constructLineCircularArc(n[0],n[1]):t.constructCircularArcThreePoint(n[0],n[1],n[2]),o&&(t.setStartAttribute(1,0,o[0]),t.setEndAttribute(1,0,o[1])),h}function Eg(e,t,s){const n=ut($e,4);t.queryControlPoints(n);const r=[0,0,0,0];let i=null;t.hasAttribute(1)&&(i=r,i[0]=t.getAttributeAsDbl(0,1,0),i[3]=t.getAttributeAsDbl(1,1,0),i[1]=pt(i[0],i[3],.5),i[2]=i[1]);const o=fg(e,n,i||null,n.length,s);return t.setControlPoints(n),i&&(t.setStartAttribute(1,0,i[0]),t.setEndAttribute(1,0,i[3])),t.normalizeAfterEndpointChange(),o}function Sg(e,t,s){return l(0),!1}function Cg(e,t,s){return l(0),!1}function Ig(e,t,s){const n=[t.getStartXY(),t.getEndXY()];Wl(e,n,2,s),t.setStartXY(n[0]),t.setEndXY(n[1]),t.normalizeAfterEndpointChange()}function bg(e,t,s,n){Wl(e,t,s,n)}function wg(e,t,s){if(0===t.projectionBehavior())Tg(e,t,s);else{const n=t.isClosed()&&t.isMajor(),r=[t.getStartXY(),n?t.getCenter():t.getEndXY()],i=[r[0].clone(),r[1].clone()];bg(e,i,2,s);const o=new jt;o.initializeFromTwoPointsArray(r,i),t.applyTransformation(o);const a=n?0:1;t.setCoordsForIntersector(i[0],i[a],!1)}}function vg(e,t,n,r){mg(e,t,n,r);const i=new s;i.setFromPoints(n,r);const o=e.getOneDegreeGCSUnit(),a=360*o,h=180*o;if(i.width()>h){for(let e=0;e<r;e++)for(;n[e].x<t;)n[e].x+=a;if(i.setFromPoints(n,r),i.xmax>h+t)for(let e=0;e<r;e++)n[e].x-=a}}function Ng(e,t,s,n,r){const i=ut($e,3);let o=0,a=!1,h=!1;const m=n.isDegenerateToLine();m?(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].setCoords(0,0),o=2):n.isClosed()&&n.isMajor()?(a=!0,h=!n.isClockwise(),i[0].assign(n.getStartXY()),i[1].assign(n.getCenter()),i[2].setCoords(0,0),o=2):(i[0].assign(n.getStartXY()),i[1].assign(n.getEndXY()),i[2].assign(n.getInteriorPoint()),o=3),e?bg(t,i,o,r):vg(t,s,i,o),m?n.constructLineCircularArc(i[0],i[1]):a?n.constructCircleCenterAndPoint(i[1],i[0],h):n.constructCircularArcThreePoint(i[0],i[1],i[2])}function Tg(e,t,s){Ng(!0,e,0,t,s)}function Gg(e,t,s){const n=ut($e,4);t.queryControlPoints(n),bg(e,n,4,s),t.setControlPoints(n)}function Dg(e,t,s){l(0)}function Vg(e,t,s){l(0)}function Fg(e,t,s){const n=he(e),r=he(t),i=ae(n,r),o=ae(n,he(s));return 0===o||(i>0&&o>0&&o<=i||i<0&&o<0&&o>=i)}function Hg(s,n,r,i,o){const a={stack:[],error:void 0,hasError:!1};try{const t=r.clone(),h=i.clone();if(2===o){const e=[0,0];return Ds(s,n,t,h,0,e),e[0]}if(t.y>h.y){const e=new $e;e.assign(t),t.assign(h),h.assign(e)}const m=e(a,new Cc,!1),g=e(a,new Cc,!1),u=e(a,new Cc,!1),c=new lt;if(c.setCoords(t.y,h.y),!c.containsCoordinate(0)||Math.abs(t.x-h.x)>=Math.PI)return Number.NaN;if(t.x===h.x)return t.x;Dc.geodeticDistance(s,n,t.x,t.y,h.x,h.y,g,m,null,o);const _=g.val;let d=0,p=1;const f=t.clone();for(;_*(p-d)>1e-12*s;){const e=.5*(d+p);if(Dc.geodeticCoordinate(s,n,t.x,t.y,_*e,m.val,g,u,o),f.x=g.val,f.y=u.val,c.setCoords(t.y,f.y),0===f.y)return f.x;if(c.containsCoordinate(0))p=e;else{if(c.setCoords(h.y,f.y),!c.containsCoordinate(0))return l(!1),Number.NaN;d=e}}return f.x}catch(h){a.error=h,a.hasError=!0}finally{t(a)}}function kg(e,t,s,n){const r=new lt;r.setCoords(t,s);const i=n.width();let o=Math.floor((e-t)/i)*i+e;const a=r.getCenter();for(;Math.abs(o-a)>Math.abs(o+i-a);)o+=i;return o}class Ag extends es{constructor(){super(),this.m_geometryDeque=[],this.m_index=-1}next(){if(this.m_geometryDeque.length>0){this.m_index++;const e=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),e}return null}getGeometryID(){return this.m_index}tick(e){this.m_geometryDeque.push(e)}tock(){return!0}getRank(){return 1}}function Mg(e,t){return e===t||null!==e&&null!==t&&(e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?e.m_hashCode===t.m_hashCode&&e.m_canonicalWkt===t.m_canonicalWkt:e.m_WKID===t.m_WKID))}function Ug(e,t){return e===t||null!==e&&null!==t&&(e.m_csType===t.m_csType&&(0===e.m_WKID&&0===t.m_WKID?1===e.m_csType?e.m_peCoordSys.isEqual(t.m_peCoordSys):e.m_peCoordSys===t.m_peCoordSys:e.m_WKID===t.m_WKID))}class qg{constructor(e,t=!0){this.m_PCSHorizon=null,this.m_GCSHorizon=null,this.m_GCSSplitLines=null,this.m_bGCSHorisonIsInclusive=!1,this.m_oneMeterPCS=0,this.m_oneDegreeGCS=0,this.m_gcsUnitFactor=0,this.m_northPole=$e.getNAN(),this.m_southPole=$e.getNAN(),this.m_polesUpdated=0,this.m_domain=s.constructEmpty(),this.m_primeMeridian=Number.NaN,this.m_geogToProjFactor=1,this.m_geogToProjOffset=0,this.m_geogToProjFactorsUpdated=0,this.m_oneMillimeter=0,this.m_centralMeridian=0,this.m_pPCSInfoNoDomain=null,this.m_oldWKID=-1973,this.m_vcsWKID=-1,this.m_bIsPannable=!1,this.m_bCached=!1,this.m_pannableExtent=s.constructEmpty(),this.m_pannableExtentGCS=s.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=e,this.m_WKID=Ic.getCode(e),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=_l(e,0,!0),this.m_hashCode=It(this.m_canonicalWkt)):this.m_hashCode=bt(this.m_WKID);const r=this.m_peCoordSys.getType();this.m_csType=r===bc.PE_TYPE_PROJCS?2:1,l(r===bc.PE_TYPE_PROJCS||r===bc.PE_TYPE_GEOGCS),r===bc.PE_TYPE_PROJCS&&(e.loadConstants()||n("PeProjcs.loadConstants failed"));const i=r===bc.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();r!==bc.PE_TYPE_GEOGCS&&Ic.getCode(i),this.m_unit=ms(e),this.m_primeMeridian=i.getPrimem().getLongitude();{const e=i.getUnit().getUnitFactor();this.m_gcsUnitFactor=e;let t=Math.PI/(180*e);Math.abs(t-1)<1e-10&&(t=1),this.m_oneDegreeGCS=t}if(r===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=e.getUnit().getUnitFactor();this.m_oneMeterPCS=1/t,this.m_oneMillimeter=.001/t,this.m_pPCSInfoNoDomain=Nc.generate(e,Nc.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||a("cannot create pcs info"),this.m_bIsPannable=this.m_pPCSInfoNoDomain.isPannableRectangle(),this.m_centralMeridian=this.m_pPCSInfoNoDomain.getCentralMeridian()}else{this.m_bIsPannable=!0,this.m_polesUpdated=1,this.m_oneMeterPCS=0;const e=1/i.getUnit().getUnitFactor(),t=i.getDatum().getSpheroid().getAxis();this.m_oneMillimeter=.001/t*e,this.m_centralMeridian=0}this.m_bIsPannable&&(this.updateGCSHorizon(),this.updatePCSHorizon(),this.updatePoles(),this.updateDomain(),this.updatePannableExtent(),this.updatePannableExtentGCS())}[Symbol.dispose](){}getHashCode(){return this.m_hashCode}getPCSHorizonPannable(){return this.m_PCSHorizon}getGCSHorizonPannable(){return this.m_GCSHorizon}getPCSInfo(){return l(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==bc.PE_TYPE_PROJCS)return;let e=!0;const t=this.m_peCoordSys,n=t.getGeogcs(),r=t.horizonGcsGenerate();if(!r)return;l(r.length>0);const i=r[0].getNump(),o=r[0].getKind();let a,h;e=r[0].getInclusive()>0;const m=this.getOneDegreeGCSUnit(),g=90*m,u=360*m,c=370*m,_=180*m*bc.PE_HORIZON_DELTA/Math.PI,d=s.constructEmpty();let p=null;if(i>1)for(let s=1;s<i;s++)if(r[s].getKind()===bc.PE_HORIZON_LINE){p||(p=new w);const e=r[s].getCoord();p.startPathCoords(e[0][0],e[0][1]),p.lineToCoords(e[1][0],e[1][1])}if(o===bc.PE_HORIZON_RECT){const t=r[0].getCoord();if(d.setFromPoints([new $e(t[0][0],t[0][1]),new $e(t[1][0],t[1][1])],2),Math.abs(d.ymax-g)<1e-7*_&&(d.ymax=g),Math.abs(d.ymin+g)<1e-7*_&&(d.ymin=-g),d.width()>c){const e=-400*m,t=e+5*u;d.setCoords({xmin:e,ymin:d.ymin,xmax:t,ymax:d.ymax})}const s=new xe({env2D:d});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap();const o=Ru(n,null,null,1),c=[],_=new lt;for(let e=0;e<i;e++){if(r[e].getKind()!==bc.PE_HORIZON_POLY)continue;a=r[e].getSize();const t=r[e].getCoord(),n=s.constructEmpty();n.setFromPoints(wt(t),a),c.push(new lt(n.xmin,n.xmax)),n.width(),_.merge(c.at(-1))}let d=!1;const f=new lt;_.width()>u&&c.length>1?(f.vmin=this.getCentralMeridian()-u,f.vmax=f.vmin+2*u,d=!0,t=!0):(f.vmin=_.vmin,f.vmax=f.vmin+u);const x=e=>{let t=0;for(;c[e].vmin+t<f.vmin;)t+=u;for(;c[e].vmax+t-u>f.vmin;)t-=u;return t};let y=new T;if(t){const e=new Ag,t=(new al).executeMany(e,o,null);for(let s=0;s<i;s++){if(r[s].getKind()!==bc.PE_HORIZON_POLY)continue;a=r[s].getSize();const n=r[s].getCoord();h=r[s].getInclusive()>0;const i=new T;if(i.addPathPoint2D(wt(n),a-1,!0),d){const t=x(s),n=c[s].clone();n.move(t);let r=t;const o=new jt;do{o.setShiftCoords(r,0);const t=i.clone();t.applyTransformation(o),e.tick(t),e.tock(),r+=u,n.move(u)}while(n.vmin<f.vmax)}else e.tick(i),t.tock()}y=t.next()}else{y=new T;for(let t=0;t<i;t++){if(r[t].getKind()!==bc.PE_HORIZON_POLY)continue;a=r[t].getSize();const s=r[t].getCoord();if(h=r[t].getInclusive()>0,l(h===e),d){const e=new T;e.addPathPoint2D(wt(s),a-1,!0);const n=x(t),r=c[t].clone();r.move(n);let i=n;const o=new jt;do{if(0!==i){o.setShiftCoords(i,0);const t=new T({copy:e});t.applyTransformation(o),y.addPath(t,0,!0)}else y.addPath(e,0,!0);i+=u,r.move(u)}while(r.vmin<f.vmax)}else y.addPathPoint2D(wt(s),a-1,!0)}}d&&(y=(new Kt).execute(y,new s(f.vmin,-g-m,f.vmax,g+m),o,null)),e?(new wh).accelerateGeometry(y,o,1):(new Km).accelerateGeometry(y,o,1),(new ul).accelerateGeometry(y,o,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=y,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=p)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==bc.PE_TYPE_PROJCS)return;const e=this.m_peCoordSys.horizonPcsGenerate();if(!e)return;let t;this.getPCSInfo();const n=e[0].getKind();e[0].getInclusive();const r=s.constructEmpty(),i=e[0].getNump();let o=!1;if(n===bc.PE_HORIZON_RECT){const s=e[0].getCoord();r.setFromPoints(wt(s),2),t=new xe({env2D:r})}else{let s=-1;for(let t=0;t<i;t++)e[t].getKind()===bc.PE_HORIZON_POLY&&(s=t);l(s>=0);const n=e[s].getSize()-1,r=e[s].getCoord(),a=new T;t=a,a.addPathPoint2D(wt(r),n,!0),o=!0}if(this.getPCSInfo().isDensificationNeeded()){l(n!==bc.PE_HORIZON_RECT);const e=1e5*this.getOneMeterPCSUnit();t=(new Jt).execute(t,e,0,0,null)}if(o){{const e=new xe;t.queryEnvelope(e),t.calculateArea2D(),t.calculateLength2D(),t.getExteriorRingCount()}(new wh).accelerateGeometry(t,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=t)}updatePannableExtent(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.getPCSInfo().getCentralMeridian(),n=e.getGeogcs();n||a("");const r=[t+1/n.getUnit().getUnitFactor()*Math.PI,0];wc.geogToProj(e,1,r);const i=r[0],o=e.getParameters()[bc.PE_PARM_X0].getValue(),h=this.getPCSHorizon(),m=s.constructEmpty();h.queryEnvelope(m);const l=Math.abs(i-o),g=l+o,u=-1*l+o,c=m.ymax,_=m.ymin;this.m_pannableExtent.setCoords({xmin:u,ymin:_,xmax:g,ymax:c})}else if(e===bc.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else a("")}updatePannableExtentGCS(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.m_centralMeridian,n=e.getGeogcs();n||a("");const r=1/n.getUnit().getUnitFactor()*Math.PI,i=this.getGCSHorizon(),o=s.constructEmpty();i.queryEnvelope(o),this.m_pannableExtentGCS.setCoords({xmin:t-r,ymin:o.ymin,xmax:t+r,ymax:o.ymax})}else if(e===bc.PE_TYPE_GEOGCS){const e=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-e,ymin:-e/2,xmax:e,ymax:e/2})}else a("")}updateDomain(){if(1===this.m_csType){const e=400*this.getOneDegreeGCSUnit();this.m_domain=s.construct(-e,-e,e,e)}else{l(2===this.m_csType);const e=Nc.generate(this.m_peCoordSys,Nc.PE_PCSINFO_OPTION_DOMAIN);e||a("generate pcs info failed");const t=new s(e.getDomainMinx(),e.getDomainMiny(),e.getDomainMaxx(),e.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:t})}}updatePoles(){if(this.m_peCoordSys.getType()===bc.PE_TYPE_PROJCS){const e=90*this.getOneDegreeGCSUnit(),t=[[0,e],[0,-e]];wc.geogToProj(this.m_peCoordSys,2,t);const s=this.getPCSInfo().getNorthPoleLocation()!==Nc.PE_POLE_OUTSIDE_BOUNDARY,n=this.getPCSInfo().getSouthPoleLocation()!==Nc.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(t[0][0],t[0][1]),n&&this.m_southPole.setCoords(t[1][0],t[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===bc.PE_TYPE_PROJCS){const e=this.getOneDegreeGCSUnit(),t=this.m_pPCSInfoNoDomain.getCentralMeridian(),s=[0,0,0,0];s[0]=t,s[1]=0,s[2]=t+e,s[3]=0;const n=wc.geogToProj(this.m_peCoordSys,2,s);l(2===n);const r=(s[2]-s[0])/e,i=s[0];0===this.m_geogToProjFactorsUpdated&&(this.m_geogToProjFactor=r,this.m_geogToProjOffset=i,this.m_geogToProjFactorsUpdated=1)}else this.m_geogToProjFactorsUpdated=1}getOneMeterPCSUnit(){return this.m_oneMeterPCS}getOneDegreeGCSUnit(){return this.m_oneDegreeGCS}getGcsUnitFactor(){return this.m_gcsUnitFactor}getUnitsPerMillimeter(){return this.m_oneMillimeter}getGCSSplitLines(){return this.m_bIsPannable?null:(this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSSplitLines)}getGCSHorizon(){return this.m_bIsPannable?this.getGCSHorizonPannable():(null!==this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSHorizon)}getGCSHorisonIsInclusive(){return this.m_bIsPannable||this.getGCSHorizon(),this.m_bGCSHorisonIsInclusive}getPCSHorizon(){return this.m_bIsPannable?this.getPCSHorizonPannable():(null!==this.m_PCSHorizon||this.updatePCSHorizon(),this.m_PCSHorizon)}getPole(e){return this.m_bIsPannable||0!==this.m_polesUpdated||this.updatePoles(),e?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return 0===this.m_geogToProjFactorsUpdated&&this.updateGeogToProjFactors(),mt(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let e=!1;return e=this.m_domain.isEmpty(),e&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;if(e<0){if(e=0,this.m_WKID>0){const t=[0],s=[0];qc(this.m_peCoordSys.getType(),this.m_WKID,t,s)||a("query_code_change"),e=t[0]}this.m_oldWKID=e}return e}isCustomWkid(){return!1}isPannable(){return this.m_bIsPannable}getPannableExtent(){return this.m_pannableExtent.clone()}getPannableExtentGCS(){return this.m_pannableExtentGCS.clone()}getAreaOfUse(){return null!==this.m_areaOfUse?this.m_areaOfUse:this.updateAreaOfUse()}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_bCached=!0}getCached(){return this.m_bCached}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}class Bg{constructor(e,t=!0){this.m_oneMeter=0,this.m_WKID=-1,this.m_oldWKID=-1,this.m_canonicalWkt="not yet implemented",this.m_model=0,this.m_unit=new bu,this.m_cached=!1}setCached(e=!0){this.m_cached=e}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let e=this.m_oldWKID;return e<0&&(e=0,this.m_WKID>0&&(e=this.m_WKID),this.m_oldWKID=e),e}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(e,t){return!1}static equal_for_projection(e,t){return!1}}function Og(e,t,n){return Yg(e,t,s.constructEmpty())}function Yg(e,t,s,n){return Xg(!0,e,t,s)}function Rg(e,t,s,n){return Lg(!0,e,t,s,n)}function Xg(e,t,s,n,r){Uu()||f("cannot create projection transformation");return t.hasVCS()&&s.hasVCS()?jg():Zg(t,s,n)}function Lg(e,t,s,n,r,i){return Uu()||f("cannot create projection transformation"),new eu(e?2:1,t,s,n,r,i)}function zg(e,t,s,r,i,o=!1){t&&s||n(""),Uu()||f("cannot obtain geotransformation list");if(1===e&&t.hasVCS()&&s.hasVCS())return d("hv xform not impl"),[];{const e=Qc(t,s,r,i,o),n=[];for(const t of e)n.push(t);return n}}function Wg(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return rt(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&rt(this.densificationStep,e.densificationStep)&&this.clipWithInputHorizon===e.clipWithInputHorizon&&this.clipWithOutputHorizon===e.clipWithOutputHorizon&&this.legacyHorizonClipping===e.legacyHorizonClipping&&this.normalizeResultGeometry===e.normalizeResultGeometry}}}function jg(e,t,s,n){return l(0),{}}function Zg(e,t,r,i){e&&t||n("!inputSR || !outputSR");const o=e.getLatestID(),a=t.getLatestID();if(3857===o&&4326===a){if(e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return pu()}else if(4326===o&&3857===a&&e.m_bDefaultDescriptor&&t.m_bDefaultDescriptor)return fu();const h=s.constructEmpty();h.setCoords({env2D:r});const m=e.getCoordinateSystemType(),l=t.getCoordinateSystemType();if(0===m||0===l)return Kg(e,t);const g=e.getGCS().getLatestID(),u=t.getGCS().getLatestID();if(g>0&&g===u)return Kg(e,t);const c=new mu(e,t,r);{const e=gu(c);if(e)return e}const _=zg(0,e,t,h,1,!0);return uu(c,Kg(e,t,_.length?_[0]:void 0))}function Kg(e,t,s,n,r){return new eu(1,e,t,s,n,r)}function Qg(){return{flagsMask:0,setFlag(e,t){t?this.flagsMask|=e:this.flagsMask&=~e},hasFlag(e){return 0!==(this.flagsMask&e)}}}function Jg(){return{m_extendedParams:Wg(),m_extendedParamsInternal:Qg()}}function $g(){return Jg()}class eu{constructor(e,t,s,r,i,o){let a,h;this.m_datumTran=null,this.m_bIdentity=!0,this.m_bIdentityGeogToGeog=!0,this.m_bVertical=!1,this.m_bNormalize=!1,t&&s||n("!inputSR || !outputSR"),r&&0===r.getType()&&(r.m_bReadOnly=!0),this.m_bNormalize=!1,1!==e&&(a=t.getVCS(),h=s.getVCS(),this.m_bVertical=null!=a&&null!=h),this.m_inputSR=t,this.m_outputSR=s,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,l(!this.m_params),i&&(this.m_params=Jg(),this.m_params.m_extendedParams=i),o&&(this.m_params||(this.m_params=Jg()),this.m_params.m_extendedParamsInternal=o);let m=!1;const g=null!=r,u=t.getCoordinateSystemType(),c=s.getCoordinateSystemType();if(s.isPannable()&&0!==u&&i){const e=i.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&s.isPannable()){const t=s.getPannableExtent(),n=t.getCenterX();if(n!==e){const s=Math.ceil(t.width());e+s!==n+s&&(m=!0)}}}const _=i&&i.normalizeResultGeometry;if(t.equals(s))return this.m_bIdentity=!m,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const d=!g&&t.equalForProjection(s,this.m_bVertical);this.m_bIdentity=d&&!m,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==u&&0!==c&&(_&&this.m_outputSR.isPannable()&&(this.m_bNormalize=_),this.m_datumTran=r||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||0===this.m_datumTran.count())&&this.m_inputSR.getGCS().equalForProjection(this.m_outputSR.getGCS(),this.m_bVertical)),this.updateProjector()}getInputSR(){return this.m_inputSR}getOutputSR(){return this.m_outputSR}getDatumTransformation(){return this.m_datumTran}getInverse(){const e=new eu(1,this.m_outputSR,this.m_inputSR,this.m_datumTran?.createInverse());return e.m_bIdentity=this.m_bIdentity,e.m_bVertical=this.m_bVertical,e.m_bIdentityGeogToGeog=this.m_bIdentityGeogToGeog,e.updateProjector(),e}isIdentity(){return this.m_bIdentity}getExtendedParams(){return this.m_params?this.m_params.m_extendedParams:$g().m_extendedParams}equals(e){return l(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return l(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:$g().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:$g().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new Ah(this)}}const tu=new Map,su=new Map,nu=new Map;function ru(e){let t=e.getCode();if(t>0){const e=Iu(t);return e||Cu(Ic.coordsys(t))}const s=e.getName();if(su.has(s)){const t=su.get(s);if(t&&t.deref()){const s=t.deref();if(s.m_peCoordSys.isEqual(e))return s}}return t=Ic.getCode(e),Cu(t>0?Ic.coordsys(t):e)}function iu(e){e<=0&&I(e);{const t=Iu(e);if(t)return t}const t=Hc(Ic.coordsys(e));t.get()||I(e);const s=Cu(t.release());return s.getLatestID()!==e&&tu.set(e,new WeakRef(s)),s}function ou(e){const t=new Bg({},!0);return t.m_WKID=e,t}function au(e){const t=Hc(Ic.fromString(bc.PE_TYPE_COORDSYS,e));return t.get()||E(e),ru(t.release())}function hu(e){su.delete(e.m_peCoordSys.getName()),nu.delete(_l(e.m_peCoordSys,0,!1))}class mu{constructor(e,t,s){this.m_hashCode=-1,e&&(this.m_inputSR=e,this.m_outputSR=t,this.m_env=s.clone(),this.m_hashCode=this.m_inputSR.getHashCode(),this.m_hashCode=Ke(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=Ke(this.m_hashCode,Rt(this.m_env.xmin)),this.m_hashCode=Ke(this.m_hashCode,Rt(this.m_env.xmax)),this.m_hashCode=Ke(this.m_hashCode,Rt(this.m_env.ymin)),this.m_hashCode=Ke(this.m_hashCode,Rt(this.m_env.ymax))))}getHashCode(){return this.m_hashCode}equals(e){return!(this.m_inputSR&&!e.m_inputSR||!this.m_inputSR&&e.m_inputSR)&&(this.m_env.equals(e.m_env)&&this.m_inputSR.equals(e.m_inputSR)&&this.m_outputSR.equals(e.m_outputSR))}clear(){this.m_inputSR=void 0,this.m_outputSR=void 0,this.m_hashCode=-1,this.m_env=void 0}}const lu=new Map;function gu(e){if(lu.has(e.getHashCode()))return lu.get(e.getHashCode())}function uu(e,t){return lu.set(e.getHashCode(),t),t}let cu,_u,du;function pu(){return cu||(cu=Rg(hc(),lc())),cu}function fu(){return _u||(_u=pu().getInverse()),_u}function xu(){return du||(du=Ic.unit(9001)),du}function yu(e){return null!==Hc(Ic.coordsys(e)).get()}const Pu=new Map;function Eu(e){if(Pu.has(e))return Pu.get(e);{const t=yu(e);return Pu.set(e,t),t}}function Su(e){return!1}function Cu(e){const t=Hc(e),s=e.getCode();if(s>0){const e=Iu(s);if(e)return e}const n=e.getName();let r=su.get(n);if(r){const t=r.deref();if(t&&t.m_peCoordSys.isEqual(e))return t}const i=new qg(t.release());if(s>0)return i.setCached(),tu.set(s,new WeakRef(i)),su.set(n,new WeakRef(i)),i;const o=_l(e,0,!1);if(r=nu.get(o),r){const e=r.deref();if(e)return e}return i.setCached(),nu.set(o,new WeakRef(i)),i}function Iu(e){const t=tu.get(e);if(t)return t.deref()}class bu extends ns{constructor(e){return void 0===e?(super(),this.m_wkid=9001,void(this.m_peUnit=null)):"number"==typeof e?(super(),this.m_factor=e,void(this.m_wkid=0)):(super(e),void(e||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=xu())))}getUnitType(){return 0}convertFromMeters(e){return e/this.getUnitToBaseFactor()}convertToMeters(e){return e*this.getUnitToBaseFactor()}}const wu=["0","1","2","3","4","5","6","7","8","9","b","c","d","e","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z"];function vu(e,t,s){const n=Je(t,"R");let r=0,i=0;for(let o=0;o<t;o++){let s=e[r]>>i&31;if(i+=5,i>31){const t=37-i;s&=(1<<t)-1,i-=32,r++,s|=(e[r]&(1<<i)-1)<<t}const a=wu[s];n[t-1-o]=a}return s>t?n.push(..."0".repeat(s-t)):s<t&&(n.length=s),n.join("")}function Nu(e,t,s,n,r){l(n>>5<r.length);let i=t,o=s;for(let a=n;a>=0;a-=2){const t=31&a,s=.5*(o+i);e>=s?(r[a>>5]|=1<<t,i=s):o=s}}let Tu=new Set;const Gu=2147483645n,Du=9007199254740990n,Vu="operation is not supported for unknown coordinate systems";var Fu;function Hu(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function ku(e,t,s){e.majorSemiAxis=t,e.minorSemiAxis=t*(1-s),e.e2=s*(2-s),e.flattening=s}function Au(e){if(Ic)return;Uc(e);const t=Tu;Tu=null,t.forEach(e=>{const t=e.deref();t&&t.attachToPe()})}function Mu(e){Mc(e)}function Uu(){return!!Ic}function qu(){return!!kc}function Bu(){return!!Ic||!!kc}function Ou(e,t,s){return l(Bu()),dc(e,void 0===t?0:t,null,!1)}function Yu(e,t){l(Bu());const s=new oc;let n;return Uu()?(n=au(e),s.setHorzProj_(n),s.m_vertcs=null,s.m_userWKID=n.getLatestID()):(n=Ac(e),s.m_unit=n.isPCS?new bu(n.metersOrRadiansPerUnit):new os(n.metersOrRadiansPerUnit)),uc(s.m_precisionDescriptor,n,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=e,s.calculateHashCode(),s.initDbgName(),s}function Ru(e,t,s,n,r=!0){let i=null;return t&&(i=Fm(t,r)),Xu(e,i,s,n,r)}function Xu(e,t,s,r,i){e||n("!PE_coord_sys");const o=new oc;let a;return a=i?ru(e):new qg(e,!1),uc(o.m_precisionDescriptor,a,t,r),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=t,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}function Lu(e,t,s=!1){3===e.getCoordinateSystemType()&&n("image spatial reference cannot be altered");const r=new oc,i=e;return r.m_peCoordSysVal=i.m_peCoordSysVal,r.m_vertcs=i.m_vertcs,r.m_unit=i.m_unit,r.m_precisionDescriptor.assign(t),r.m_localZToXYFactor=i.m_localZToXYFactor,(Number.isNaN(r.m_precisionDescriptor.m_falseX)||Number.isNaN(r.m_precisionDescriptor.m_falseY))&&(r.m_precisionDescriptor.m_falseX=i.m_precisionDescriptor.m_falseX,r.m_precisionDescriptor.m_falseY=i.m_precisionDescriptor.m_falseY),r.m_precisionDescriptor.snapPrecision(),r.m_precisionDescriptor.fixTolerance(),r.m_userWKID=i.m_userWKID,r.m_precisionDescriptor.equals(i.m_precisionDescriptor)?r.m_bDefaultDescriptor=i.m_bDefaultDescriptor:r.m_bDefaultDescriptor=!1,s&&(r.m_bDefaultDescriptor=!0),r.calculateHashCode(),r.initDbgName(),r}function zu(e,t,s){return{}}function Wu(e,t,s){void 0===t&&(t=1),(t<=0||!Number.isFinite(t))&&n(""),e||1===t||n("null Unit has to have z_to_xy_factor equal to 1");const r=new oc;r.m_unit=e;const i=e||new bu(9001);return _c(r.m_precisionDescriptor,i,null,1),r.m_bDefaultDescriptor=!0,Number.isNaN(r.m_precisionDescriptor.m_falseX)&&n("NAN false X/Y are not allowed here"),r.m_localZToXYFactor=t,r.calculateHashCode(),r.initDbgName(),r}function ju(e,t){return e.snapGeometry(t)}function Zu(e){const t=e.getCoordinateSystemType();return 1===t?e:(3===t&&l(0),e.getGCS())}function Ku(e){return l(Bu()),qu()?Bc(e):Eu(e)}function Qu(s){if(Uu()){const r={stack:[],error:void 0,hasError:!1};try{return null!==e(r,Ic.fromString(bc.PE_TYPE_COORDSYS,s,!0),!1)}catch(n){r.error=n,r.hasError=!0}finally{t(r)}}try{return Ac(s),!0}catch(r){}return!1}let Ju;function $u(){return Ju||(Ju=(()=>{const e=Math.trunc(Math.random()*Tt()),t=Date.now();return`|abba_000|${e.toString(16)}|${t.toString(16)}|`})()),Ju}!function(e){e[e.utmDefault=0]="utmDefault",e[e.utmNorthSouth=1]="utmNorthSouth"}(Fu||(Fu={}));let ec=0;function tc(e=""){let t=`${$u()}${ec++}`;return""!==e&&(t+=`|${e}`),t}function sc(e){return e.startsWith($u())}let nc,rc,ic,oc=class e{destroy(){hu(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():a("SpatialReference.destroy")}constructor(){this.m_vertcs=null,this.m_peCoordSysVal=null,this.m_userWKID=0,this.m_userWKT=null,this.m_geogSpatialReference=null,this.m_srToGcs=null,this.m_gcsToSr=null,this.m_defaultPrecisionSR=null,this.m_localZToXYFactor=-1,this.m_precisionDescriptor=new ac,this.m_hashCode=0,this.m_bDefaultDescriptor=!1,gc(this.m_precisionDescriptor),Tu&&Tu.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?Ou(this.m_userWKID):Yu(this.m_userWKT)).copyTo(this,!1)}copyTo(e,t=!0){(t||e.m_bDefaultDescriptor)&&(e.m_bDefaultDescriptor=this.m_bDefaultDescriptor,e.m_precisionDescriptor.assign(this.m_precisionDescriptor)),e.m_defaultPrecisionSR=null,e.m_gcsToSr=this.m_gcsToSr,e.m_geogSpatialReference=this.m_geogSpatialReference,e.m_hashCode=this.m_hashCode,e.m_localZToXYFactor=this.m_localZToXYFactor,e.m_peCoordSysVal=this.m_peCoordSysVal,e.m_srToGcs=this.m_srToGcs,e.m_userWKID=this.m_userWKID,e.m_userWKT=this.m_userWKT,e.m_vertcs=this.m_vertcs,e.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let e=0;return e=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,e}updateTransform(e){if(1===this.getCoordinateSystemType())return Rg(this,this,null);let t=e?this.m_srToGcs:this.m_gcsToSr;if(t)return t;const s=this.getGCS(),n=this;t=e?Rg(n,s,null):Rg(s,n,null);const r=t,i=e?this.m_srToGcs:this.m_gcsToSr;return i||(e?this.m_srToGcs=r:this.m_gcsToSr=r,t)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let e=this.getHashCodeHorizontal();const t=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();e=Ke(e,t),this.m_hashCode=Ke(e,s)}initDbgName(){}setHorzProj_(e){this.m_peCoordSysVal=e,this.m_unit=this.m_peCoordSysVal.getUnit()}getTolerance(e=0){return this.m_precisionDescriptor.getTolerance(e)}getResolution(e=0){return this.m_precisionDescriptor.getResolution(e)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){if(this.throwIfNotGCSOrPCS(),1===this.getCoordinateSystemType())return 0;return this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){const e=this.getPECoordSys();if(e){switch(e.getType()){case bc.PE_TYPE_GEOGCS:return 1;case bc.PE_TYPE_PROJCS:return 2;default:return 0}}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof bu)return 2;if(this.m_unit instanceof os)return 1}return 0}getID(){return this.m_userWKID}getLatestID(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getLatestID():this.m_userWKID}getOldID(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getOldID():this.m_userWKID}getVerticalID(){return d("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return d("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(e)}getText(){const e=this.getPECoordSys();return e?pl(e):this.m_userWKT??""}getTextExtended(e){const t=this.getPECoordSys();return t?this.getPEVerticalCoordSys()?dl(null,t,this.getPEVerticalCoordSys()):pl(t,e):this.m_userWKT??""}getText2(e=-1){const t=this.getPECoordSys();return t?fl(t,e):this.m_userWKT??""}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof bu?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof os?.001/(Ac(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):(p("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?xl():""}getVerticalUnit(){return d("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const e=this.getCoordinateSystemType();if(0===e)p(Vu);else{if(1===e)return this;3===e&&p("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===hc()||this===mc())t=lc();else{l(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||a(""),t=Ru(e,this.m_vertcs,null,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?t=this.m_geogSpatialReference:this.m_geogSpatialReference=t,t}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(e,t){if(0===e.length)return 0;e.length>t.length&&n("coordsSrc.size() > coordsDst.size()");const s=this.getCoordinateSystemType();if(0===s&&p(Vu),1===s)return nt(t,e,e.length),e.length;l(this.m_peCoordSysVal);const r=this.getSRToGCSTransform();return(new qh).transform(r,e,e.length,t)}toGeohash(e,t=8){const s=e.clone();s.scale(9102===this.getGCS().getUnit().getID()?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),s.x<-180?(s.x=st(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=st(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const n=5*t,r=new Uint32Array(4);Nu(s.x,-180,180,n-1,r),Nu(s.y,-90,90,n-2,r);return vu(r,t,t)}isPannable(){const e=this.getCoordinateSystemType();return 0!==e&&3!==e&&(l(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||n("!is_pannable"),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||n("!is_pannable"),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const e=this.getCoordinateSystemType();1!==e&&2!==e&&n("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(e){if(e.assign(this.m_precisionDescriptor),Number.isNaN(e.m_falseX))if(Uu()||f("cannot query precision descriptor"),l(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const t=this.m_peCoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(e){e.assign(this.m_precisionDescriptor),e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(e){if(this.m_bDefaultDescriptor)e.assign(this.m_precisionDescriptor);else{const t=this.getCoordinateSystemType();0===t?_c(e,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===t?d("image cs"):uc(e,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}e.m_falseX=Number.NaN,e.m_falseY=Number.NaN}horizontalEqual(e){return Mg(this.m_peCoordSysVal,e.m_peCoordSysVal)}verticalEqual(e){return null!==this.m_vertcs==(null!==e.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(e.m_vertcs))}equals(e){const t=e;if(this===t)return!0;if(!this.horizontalEqual(t)||!this.verticalEqual(t))return!1;if(!t.m_peCoordSysVal){if(l(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==t.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(t.m_unit))return!1;if(this.m_localZToXYFactor!==t.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!t.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(t.m_precisionDescriptor))return!1;l(t.m_peCoordSysVal);let e=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(e)){const t=this.m_peCoordSysVal.getDomainXY();e=t.xmin,s=t.ymin}let n=t.m_precisionDescriptor.m_falseX,r=t.m_precisionDescriptor.m_falseY;if(Number.isNaN(n)){const e=t.m_peCoordSysVal.getDomainXY();n=e.xmin,r=e.ymin}return e===n&&s===r}return this.m_precisionDescriptor.equals(t.m_precisionDescriptor)}return!0}equalForProjection(e,t){if(this===e)return!0;const s=this.getCoordinateSystemType(),n=e.getCoordinateSystemType();if(0===s||0===n)return 0===s&&0===n?(!t||this.getZToXYFactor()===e.getZToXYFactor())&&(!this.getUnit()||!e.getUnit()||this.getUnit().equals(e.getUnit())):3!==s&&3!==n&&(null===this.getUnit()||null===e.getUnit()||(!t||this.getZToXYFactor()===e.getZToXYFactor())&&this.getUnit().equals(e.getUnit()));if(s!==n)return!1;if(3===s)return this.equals(e);if(Ug(this.m_peCoordSysVal,e.m_peCoordSysVal)){if(!t)return!0;if(null!==this.m_vertcs==(null!==e.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(e.m_vertcs)}return!1}equalHorizontal(e){return this.horizontalEqual(e)}equalVertical(e){return l(0),!1}equalVerticalVCS(e){return l(0),!1}convergenceAngle(e){return l(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const e=this.m_peCoordSysVal.m_peCoordSys;return e||a("cannot clone coord sys"),e}return null}getPeVertcsCopy(){return l(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&n(Vu)}getPrimeMeridian(){return this.throwIfLocal(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPrimeMeridian()}getSRToGCSTransform(){return this.updateTransform(!0)}getGCSToSRTransform(){return this.updateTransform(!1)}getOneMeter(){return 1e3*this.getUnitsPerMillimeter()}getOneMeterPCSUnit(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(null===this.m_defaultPrecisionSR){const e=new ac;this.queryDefaultPrecisionDescriptorWithoutFalseXY(e),this.m_defaultPrecisionSR=Lu(this,e,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal);const t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=t.getFlattening();ku(e,t.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&p(""),l(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.getAreaOfUse();return null===e?new ss:new ss({geom:e.clone(),sr:Ou(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),l(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(e){if(e.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const t=e.getGeometryType();if(x(t))return this.snapMultiVertex_(e);if(t===i.enumPoint)return this.snapPoint_(e);if(t===i.enumEnvelope)return this.snapEnvelope_(e);if(o(t))return this.snapSegment_(e);if(t===i.enumGeometryCollection){const t=e;let s=!1;for(let e=0,n=t.getGeometryCount();e<n;++e)s=this.snapGeometry(t.getGeometry(e))||s;return s}a("what else?")}snapMultiVertex_(e){if(l(!e.isEmpty()),l(2!==this.m_precisionDescriptor.getPrecision()),h(e.getGeometryType())){const t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}const t=e.getImpl(),s=t.getDescription();let n=!1;for(let r=0,i=s.getAttributeCount();r<i;r++){const e=s.getSemantics(r),i=t.getAttributeStreamRef(e);n=this.snapAttributes(e,i,0,t.getPointCount())||n}return n&&t.notifyModifiedFlags(2001),n}snapPoint_(e){return!1}snapEnvelope_(e){return!1}snapSegment_(e){l(!e.isEmpty()),l(2!==this.m_precisionDescriptor.getPrecision());const t=new ac;this.queryPrecisionDescriptor(t);const s=e.getStartXY(),n=new $e;n.x=pc(s.x,t.getFalseX(),t.getGridUnitsXY()),n.y=pc(s.y,t.getFalseY(),t.getGridUnitsXY());let r=!n.equals(s);const i=e.getEndXY(),o=new $e;o.x=pc(i.x,t.getFalseX(),t.getGridUnitsXY()),o.y=pc(i.y,t.getFalseY(),t.getGridUnitsXY()),r||=!o.equals(i),r&&e.changeEndPoints2D(n,o);const a=(t,s,n)=>{let r=!1;{const i=e.getStartAttributeAsDbl(t,0),o=pc(i,s,n),a=!rt(o,i);r||=a,a&&e.setStartAttribute(t,0,o)}{const i=e.getEndAttributeAsDbl(t,0),o=pc(i,s,n),a=!rt(o,i);r||=a,a&&e.setEndAttribute(t,0,o)}return r};let h=r?1:0;return e.hasAttribute(1)&&(h|=a(1,t.getFalseZ(),t.getGridUnitsZ())?1:0),e.hasAttribute(2)&&(h|=a(2,t.getFalseM(),t.getGridUnitsM())?1:0),!!h}snapGeometryWithCurves_(e){l(!e.isEmpty()),l(2!==this.m_precisionDescriptor.getPrecision());const t=e.createInstance(),s=new k;let n=0;for(let r=0,i=e.getPathCount();r<i;++r){const i=e.getSegmentCountPath(r);if(0===i){if(t.addPath(e,r,!0),1===t.getPathSize(r)){const e=new ye;t.getPointByVal(t.getPointCount()-1,e),n|=this.snapGeometry(e)?1:0,t.setPointByVal(t.getPointCount()-1,e)}continue}const o=e.isClosedPath(r);for(let a=0,h=o?i-1:i;a<h;++a)e.getSegmentFromPath(r,a,s,!1),n|=this.snapGeometry(s.get())?1:0,t.addSegment(s.get(),0===a);o&&(e.getSegmentFromPath(r,i-1,s,!1),n|=this.snapGeometry(s.get())?1:0,1===i?t.addPathFromClosedSegment(s.get(),!1):t.closeLastPathWithSegment(s.get()))}return n&&t.copyTo(e),!!n}snapAttributes(t,s,n,r){let i=!1;const o=new ac;if(this.queryPrecisionDescriptor(o),0===t){const t=s;for(let s=n;s<r;s++){const n=t.read(2*s),r=e.s_SnapValue(n,o.getFalseX(),o.getGridUnitsXY()),a=t.read(2*s+1),h=e.s_SnapValue(a,o.getFalseY(),o.getGridUnitsXY());i=i||r!==n||h!==a,i&&(t.write(2*s,r),t.write(2*s+1,h))}}else if(1===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseZ(),o.getGridUnitsZ());i=i||!rt(r,n),i&&t.write(s,r)}}else if(2===t){const t=s;for(let s=n;s<r;s++){const n=t.read(s),r=e.s_SnapValue(n,o.getFalseM(),o.getGridUnitsM());i=i||!rt(r,n),i&&t.write(s,r)}}return i}static s_SnapValue(e,t,s){return it((e-t)*s)/s+t}};class ac{constructor(){const e=Du,t=1e-4,s=.001,n=t*Number(e)*.5;this.m_precision=1,this.m_falseX=-n,this.m_falseY=-n,this.m_unitsXY=Number(e)/(2*n),this.m_falseM=-1e5,this.m_unitsM=1/t,this.m_falseZ=-1e5,this.m_unitsZ=1/t,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}getHashCode(){let e=7777,t=7777;return t=Ke(t,this.m_falseM),t=Ke(t,this.m_unitsM),e=Ke(e,this.m_unitsXY),t=Ke(t,this.m_toleranceXY),e=Ke(e,this.m_falseZ),t=Ke(t,this.m_toleranceZ),e=Ke(e,this.m_unitsZ),t=Ke(t,this.m_toleranceM),e=Ke(e,this.m_precision),Ke(e,t)}clone(){const e=new ac;return e.m_falseX=this.m_falseX,e.m_falseY=this.m_falseY,e.m_unitsXY=this.m_unitsXY,e.m_falseZ=this.m_falseZ,e.m_unitsZ=this.m_unitsZ,e.m_falseM=this.m_falseM,e.m_unitsM=this.m_unitsM,e.m_toleranceXY=this.m_toleranceXY,e.m_toleranceZ=this.m_toleranceZ,e.m_toleranceM=this.m_toleranceM,e.m_precision=this.m_precision,e}assign(e){return this.m_falseX=e.m_falseX,this.m_falseY=e.m_falseY,this.m_unitsXY=e.m_unitsXY,this.m_falseZ=e.m_falseZ,this.m_unitsZ=e.m_unitsZ,this.m_falseM=e.m_falseM,this.m_unitsM=e.m_unitsM,this.m_toleranceXY=e.m_toleranceXY,this.m_toleranceZ=e.m_toleranceZ,this.m_toleranceM=e.m_toleranceM,this.m_precision=e.m_precision,this}initialize2D(e,t){}getTolerance(e){switch(e){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(e){if(2===this.m_precision)return 0;switch(e){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXY(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){const e=new s;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 1:{const t=Number(ac.getLimit64())/this.getGridUnitsXY();e.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+t,ymax:this.getFalseY()+t})}break;case 2:e.setCoords({xmin:-Number.MAX_VALUE,ymin:-Number.MAX_VALUE,xmax:Number.MAX_VALUE,ymax:Number.MAX_VALUE});break;default:e.setEmpty(),a("")}return e}getZGridRange(){const e=new lt;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 1:{const t=Number(ac.getLimit64())/this.getGridUnitsZ();e.setCoords(this.getFalseZ(),this.getFalseZ()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),a("")}return e}getMGridRange(){const e=new lt;switch(this.m_precision){case 0:{const t=ac.getLimit32()/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 1:{const t=Number(ac.getLimit64())/this.getGridUnitsM();e.setCoords(this.getFalseM(),this.getFalseM()+t)}break;case 2:e.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:e.setEmpty(),a("")}return e}setTolerance(e,t){switch(t<0&&n("tol < 0"),Number.isFinite(t)||n("tol is not finite"),e){case 0:this.m_toleranceXY=t;break;case 1:this.m_toleranceZ=t;break;case 2:this.m_toleranceM=t;break;default:n("cannot set tolerance for this attribute")}}setGridParams(e,t,s){Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(s)||n("grid params are not finite"),s<1&&n("grid units cannot be smaller than 1.0"),this.m_falseX=e,this.m_falseY=t,this.m_unitsXY=s}setZParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||n("grid params are not finite"),t<1&&n("grid units cannot be smaller than 1.0"),this.m_falseZ=e,this.m_unitsZ=t}setMParams(e,t){Number.isFinite(e)&&Number.isFinite(t)||n("grid params are not finite"),t<1&&n("grid units cannot be smaller than 1.0"),this.m_falseM=e,this.m_unitsM=t}setPrecision(e){}equals(e){return this===e||rt(this.m_falseX,e.m_falseX)&&rt(this.m_falseY,e.m_falseY)&&this.equalsWithoutFalseXY(e)}snapPrecision(){if(2===this.m_precision)return;const e=(e,t,s,n)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return s;if(s<1)return 1;if(!n)return s;const r=Number(e)/s;return Math.trunc((t+r-t)*s)>e&&(s=e/(t+r-t)),Math.max(1,s)},t=Number(0===this.m_precision?Gu:Du);this.m_unitsXY=e(t,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=e(t,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=e(t,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=e(t,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const e=(e,t,s,n)=>{if(s<1)return!1;if(!Number.isFinite(t)||!Number.isFinite(s))return!1;if(!n)return!0;const r=Number(e)/s;return!(BigInt((t+r-t)*s)>e)},t=0===this.m_precision?Gu:Du;return!!e(t,this.m_falseX,this.m_unitsXY,!0)&&(!!e(t,this.m_falseY,this.m_unitsXY,!0)&&(!!e(t,this.m_falseZ,this.m_unitsZ,!1)&&!!e(t,this.m_falseM,this.m_unitsM,!1)))}fixTolerance(){2!==this.m_precision&&(this.m_toleranceXY=Math.max(2/this.m_unitsXY,this.m_toleranceXY),this.m_toleranceZ=Math.max(2/this.m_unitsZ,this.m_toleranceZ),this.m_toleranceM=Math.max(2/this.m_unitsM,this.m_toleranceM),(Number.isNaN(this.m_falseX)||Number.isNaN(this.m_falseY))&&(this.m_falseX=this.m_falseY=Number.NaN))}equalsWithoutFalseXY(e){return this===e||this.m_unitsXY===e.m_unitsXY&&this.m_falseZ===e.m_falseZ&&this.m_unitsZ===e.m_unitsZ&&this.m_falseM===e.m_falseM&&this.m_unitsM===e.m_unitsM&&this.m_toleranceXY===e.m_toleranceXY&&this.m_toleranceZ===e.m_toleranceZ&&this.m_toleranceM===e.m_toleranceM&&this.m_precision===e.m_precision}setBestXyDomainFromEnvelope(e,t){}setBestZDomainFromZRange(e,t,s){}setBestMDomainFromMRange(e,t,s){}}function hc(){return(!nc||Uu()&&null===nc.getPECoordSys())&&(nc=dc(3857,0,null,!0)),nc}function mc(){return(!rc||Uu()&&null===rc.getPECoordSys())&&(rc=dc(102100,0,null,!0)),rc}function lc(){return(!ic||Uu()&&null===ic.getPECoordSys())&&(ic=dc(4326,0,null,!0)),ic}function gc(e){e.m_falseX=0,e.m_falseY=0,e.m_unitsXY=1,e.m_falseZ=0,e.m_unitsZ=1,e.m_falseM=0,e.m_unitsM=1,e.m_toleranceXY=100*gt(),e.m_toleranceZ=100*gt(),e.m_toleranceM=100*gt(),e.m_precision=2}function uc(e,t,s,r){const i=t instanceof qg;gc(e),e.m_precision=r,e.m_falseX=Number.NaN,e.m_falseY=Number.NaN;const o=1e-4,a=.001,h=i?t.m_csType:t.isPCS?2:1;if(1===h){const s=(0===r?1/18e5:1e-9)*(i?t.getOneDegreeGCSUnit():Math.PI/t.metersOrRadiansPerUnit/180);e.m_unitsXY=1/s}else if(2===h){const s=(0===r?a:o)*(i?t.getOneMeterPCSUnit():1/t.metersOrRadiansPerUnit);e.m_unitsXY=1/s}else n("unrecognized cs type");e.m_falseM=-1e5,e.m_unitsM=1/(0===r?a:o),e.m_unitsM=Math.max(1,e.m_unitsM),e.m_unitsXY=Math.max(1,e.m_unitsXY);let m=0,l=0;0!==r&&1!==r||(m=2/e.m_unitsXY,l=2/e.m_unitsM),e.m_toleranceXY=Math.max(m,i?t.getUnitsPerMillimeter():2===h?.001/t.metersOrRadiansPerUnit:.001/(t.semiMajor*t.metersOrRadiansPerUnit)),e.m_toleranceM=Math.max(a,l),cc(e,s)}function cc(e,t){const s=1e-4,n=.001;if(e.m_falseZ=-1e5,t){const r=(0===e.m_precision?n:s)*t.getOneMeter();e.m_unitsZ=1/r}else e.m_unitsZ=1/(0===e.m_precision?n:s);e.m_unitsZ=Math.max(1,e.m_unitsZ);let r=0;0!==e.m_precision&&1!==e.m_precision||(r=2/e.m_unitsZ),e.m_toleranceZ=Math.max(t?t.getOneMeter()*n:n,r)}function _c(e,t,s,n){gc(e),e.m_precision=n;const r=0===n?Gu:Du,i=1e-4,o=.001;let a=1,h=1,m=.001;t&&(h=t.getUnitToBaseFactor()),t&&1===t.getUnitType()?(a=400*Math.PI/180,m=8.983152841195215e-9*Math.PI/180/h):(a=(0===n?o:i)*Number(r)*.5,m=o/h),a/=h,e.m_falseX=-a,e.m_falseY=-a,e.m_unitsXY=Number(r)/(2*a),e.m_falseM=-1e5,e.m_unitsM=1/(0===n?o:i),e.m_unitsM=Math.max(1,e.m_unitsM),e.snapPrecision();let l=0,g=0;0!==e.m_precision&&1!==e.m_precision||(g=2/e.m_unitsM,l=2/e.m_unitsXY),e.m_toleranceXY=Math.max(l,m),e.m_toleranceM=Math.max(o,g),cc(e,s)}function dc(e,t,s,n){if(!n&&t<=0){if(3857===e)return hc();if(102100===e)return mc();if(4326===e)return lc()}const r=new oc;let i,o=null;return Uu()?(i=iu(e),t>0?o=null:t=0,r.setHorzProj_(i),r.m_vertcs=o):(i=Ac(e),r.m_unit=i.isPCS?new bu(i.metersOrRadiansPerUnit):new os(i.metersOrRadiansPerUnit)),uc(r.m_precisionDescriptor,i,o,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=e,r.calculateHashCode(),r.initDbgName(),r}function pc(e,t,s){return it((e-t)*s)/s+t}let fc=null;const xc=3552713678800501e-30;function yc(e,t,s){return e===t||Math.abs(e-t)<=s*(1+(Math.abs(e)+Math.abs(t))/2)}function Pc(e,t){return yc(e,t,xc)}function Ec(e,t){return 0===e||Math.abs(e)<=t}function Sc(e){return Ec(e,xc)}let Cc,Ic,bc,wc,vc,Nc,Tc,Gc,Dc,Vc,Fc;function Hc(e){return{_this:e,get(){return this._this},reset(e){this._this=e},release(){const e=this._this;return this._this=null,e}}}let kc=null;function Ac(e){l(kc);const t=kc(e);return t.semiMajor=t.isPCS?Number.NaN:Rc(e),t}function Mc(e){kc=e,l(kc)}function Uc(e){const t=e;Ic=t.PeFactory,l(Ic),Fc=t.PeGCSExtent,l(Fc),Dc=t.PeLineType,l(Dc),Vc=t.PeMath,l(Vc),Cc=t.PeDouble,l(Cc),bc=t.PeDefs,l(bc),wc=t.PeCSTransformations,l(wc),vc=t.PeGTTransformations,l(vc),Nc=t.PePCSInfo,l(Nc),Tc=t.PeGTlistExtended,l(Tc),Ic.initialize(),Gc=t.PeGTlistExtendedEntry,l(Gc),bc.PE_TYPE_ANGUNIT=512,bc.PE_STR_AUTH_ALL=2,Nc.PE_POLE_LINE_STRAIGHT=2,Nc.PE_POLE_LINE_CURVED=3,bc.PE_PARM_LAM0=2,bc.PE_PARM_PHI0=6,bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,bc.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,bc.PE_PRJ_ALBERS=43007,bc.PE_PRJ_CYLINDRICAL_EQAREA=43034,bc.PE_TYPE_VERTCS=8,bc.PE_LINETYPE_GEODESIC=0,bc.PE_LINETYPE_LOXODROME=1,bc.PE_LINETYPE_GREAT_ELLIPTIC=2,bc.PE_LINETYPE_NORMAL_SECTION=3,Tc.PE_GTLIST_OPTS_USABLE=1,kc=null}function qc(e,t,s,n){return t<=0?(s[0]=0,n[0]=0,!1):(s[0]=t,n[0]=t,!0)}function Bc(e){l(qu());return!!kc(e).isPCS||Oc(e)}function Oc(e){return Ic&&p("pe has been loaded. no-pe methods should not be used at this point."),fc||Xc(),fc.has(e)}const Yc=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function Rc(e){if(Ic&&p("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof e){const t=e.match(Yc);t&&2===t.length||n("bad gcs wkt");const s=Number.parseFloat(t[1]);return Number.isFinite(s)||n("bad gcs wkt"),s}return fc||Xc(),fc.has(e)||p("gcs wkid not found"),fc.get(e)}function Xc(){fc=new Map;for(const e in rs){const t=Number.parseFloat(e),s=rs[e];if(Array.isArray(s))for(const e of s)fc.set(e,t);else fc.set(s,t)}is()}function Lc(e,t){const s=Ic.geogtran(e);s||I(e);return new Kc(s,t)}function zc(e,t){const s=Ic.fromString(bc.PE_TYPE_GEOGTRAN,e);s||E(e);return new Kc(s,t)}function Wc(e,t){return new Kc(e,t)}const jc=Qe(0),Zc=Qe(1);class Kc{constructor(e,t){if(e instanceof Kc)return this.m_geogTranWrapper=e.m_geogTranWrapper,this.m_bInverted=t?!e.m_bInverted:e.m_bInverted,void(this.m_hashCode=Ke(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc));this.m_geogTranWrapper=new Um(e),this.m_bInverted=t,this.m_hashCode=Ke(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc)}getID(){return this.m_geogTranWrapper.getLatestId()}getLatestID(){return this.m_geogTranWrapper.getLatestId()}getText(){return this.m_geogTranWrapper.getText()}getTextExtended(e){if(!this.m_geogTranWrapper.getGeogtran())return"";if(-1===e)return this.m_geogTranWrapper.getGeogtran().toString();{const t=0===e?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return this.m_geogTranWrapper.getGeogtran().toString(t)}}getText2(e=-1){let t=bc.PE_STR_FMT_WKT2;return-1!==e&&(t|=0===e?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL),this.m_geogTranWrapper.getGeogtran().toString(t)}getName(){return this.m_geogTranWrapper&&this.m_geogTranWrapper.getGeogtran()?this.m_geogTranWrapper.getGeogtran().getName():""}getInputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getOutputSr(!1):this.m_geogTranWrapper.getInputSr(!1)}getOutputSpatialReference(){return this.m_bInverted?this.m_geogTranWrapper.getInputSr(!1):this.m_geogTranWrapper.getOutputSr(!1)}getInverse(){return new Kc(this,!0)}isInverted(){return this.m_bInverted}getHashCode(){return this.m_hashCode}GetPeGeogtran(){return this.m_geogTranWrapper.getGeogtran()}equals(e){const t=e;return t===this||this.m_bInverted===t.m_bInverted&&(this.GetPeGeogtran()===t.GetPeGeogtran()||this.getID()===t.getID()&&!(0===this.getID()&&!this.GetPeGeogtran().isEqual(t.GetPeGeogtran())))}referencesMissingData(){return!!this.m_geogTranWrapper&&!this.m_geogTranWrapper.isUsable()}getWrapper(){return this.m_geogTranWrapper}}function Qc(s,n,r,i,o){const a=s.getGCS(),h=n.getGCS(),m=a.getPECoordSys(),g=h.getPECoordSys();let u=null;if(!r.isEmpty()){const e=r.clone();if(!e.isEmpty()&&2===s.getCoordinateSystemType()){let t=new xe({env2D:e});const n=Rg(s,a,null);t=(new qh).execute(t,n,null),t.queryEnvelope(e)}if(!e.isEmpty()){const t=m.getPrimem().getLongitude(),s=m.getUnit().getUnitFactor();u=new Fc(e.xmin,e.ymin,e.xmax,e.ymax,t,s)}}let c=i;c>=Tt()&&(c=0);const _=[];let d=Tc.PE_GTLIST_OPTS_COMMON;o||(d&=~Tc.PE_GTLIST_OPTS_USABLE);for(let f=0;f<2;f++){const s={stack:[],error:void 0,hasError:!1};try{_.length=0;const t=Tc.getGTlist(m,g,2,d,u,c);if(null==t||0===t.length)break;e(s,{[Symbol.dispose](){Gc.destroy(t)}},!1);let n=!1;for(const e of t){const t=$c(e);if(l(t),o&&t.referencesMissingData())n=!0,c=0;else if(_.push(t),_.length===i)break}if(!n)break}catch(p){s.error=p,s.hasError=!0}finally{t(s)}}return u&&u.destroy(),_}function Jc(){return new e_([],null,null,null)}function $c(e){const t=new t_,s=e.getSteps();if(s){const n=e.getEntries();for(let e=0;e<s;e++){const s=0!==n[e].getDirection();let r;const i=n[e].getGeogtran().getCode();if(i>=0)r=Ic.geogtran(i);else{const t=n[e].getGeogtran().toString(bc.PE_STR_FMT_WKT);r=Ic.fromString(bc.PE_TYPE_GEOGTRAN,t)}if(null==r)return null;const o=Wc(r,s);t.add(o)}return t.create()}return null}class e_{constructor(e,t,s,n){this.m_bReadOnly=!0,this.m_name="",this.m_fastTrack=-1,this.m_bNameIsSet=!1,this.m_transforms=e,t&&(this.m_name=t,this.m_bNameIsSet=!0),this.m_inputSr=s,this.m_outputSr=n}getType(){return 0}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}createInverse(){return this.getInverse()}getHashCode(){let e=1973;for(let t=0;t<this.m_transforms.length;t++)e=Ke(e,this.m_transforms[t].getHashCode());return e}equals(e){return l(0),!1}referencesMissingData(){if(0===this.m_transforms.length)return!1;for(const e of this.m_transforms)if(e.referencesMissingData())return!0;return!1}isMatchingTransformation(e,t){return l(0),!1}validateTransformation(e,t){return l(0),!1}nameIsSet(){return l(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&b(""),this.m_transforms[e]}getInverse(){const e=new t_;return e.addSteps(this,!0),e.setInputSpatialReference(this.m_outputSr),e.setOutputSpatialReference(this.m_inputSr),e.create()}transform(e,t,s){if(0===this.count())return;let n=this.m_inputSr,r=this.m_outputSr;if(e&&(r=ot(n,n=r)),0===this.m_transforms.length)return void qm(n,null,r,null,t,null,s);let i=this.m_fastTrack;if(1===i)return void me(e,this.m_transforms,n=>{Xm(n.getWrapper(),e!==n.isInverted(),t,null,s)});const o=Mm();-1===i&&o.initFromGcsAndVcs(n,null);const a=Mm();let h=e?this.m_transforms.length-1:0;const m=e?-1:1;for(let g=0,u=this.m_transforms.length;g<u;g++,h+=m){if(0===g){const r=this.m_transforms[h];Bm(n.getPECoordSys(),null,r.getWrapper(),e!==r.isInverted(),t,null,s,a),-1===i&&(o.equals(a)||(i=0)),o.assign(a)}else{const n=this.m_transforms[h-m],r=this.m_transforms[h];Ym(o,n.getWrapper(),e!==n.isInverted(),r.getWrapper(),e!==r.isInverted(),t,null,s,a),-1===i&&(o.equals(a)||(i=0)),o.assign(a)}const r=this.m_transforms[h];Rm(o,r.getWrapper(),e!==r.isInverted(),t,null,s,a),o.assign(a)}const l=this.m_transforms[h-m];Om(o,l.getWrapper(),e!==l.isInverted(),r,null,t,null,s),-1===i&&(a.initFromGcsAndVcs(r,null),o.equals(a)||(i=0)),this.m_fastTrack=0===i?0:1}}class t_{constructor(){this.m_transforms=[],this.m_inputGCS=null,this.m_outputGCS=null,this.m_name="",this.m_bNameIsSet=!1}getInputSpatialReference(){return null!==this.m_inputGCS?this.m_inputGCS:this.count()>0?this.m_transforms[0].getInputSpatialReference():null}setInputSpatialReference(e){this.m_inputGCS=e?e.getGCS():null}getOutputSpatialReference(){return null!==this.m_outputGCS?this.m_outputGCS:this.count()>0?this.m_transforms.at(-1).getOutputSpatialReference():null}setOutputSpatialReference(e){this.m_outputGCS=e?e.getGCS():null}getName(){if(this.m_bNameIsSet)return this.m_name;if(0===this.m_transforms.length)return"";let e="";for(const t of this.m_transforms)e.length>0&&(e+=" + "),t.isInverted()&&(e+="~"),e+=t.getName();return e}count(){return this.m_transforms.length}getStep(e){return(e<0||e>this.count())&&b(""),this.m_transforms[e]}setStep(e,t){l(0)}add(e){this.m_transforms.push(e)}addSteps(e,t){if(t)for(let s=e.count()-1;s>=0;--s)this.add(e.getStep(s).getInverse());else for(let s=0;s<e.count();++s)this.add(e.getStep(s))}clear(){this.m_transforms=[],this.m_name="",this.m_bNameIsSet=!1,this.m_inputGCS=null,this.m_outputGCS=null}remove(e){l(0)}create(){const e=this.getInputSpatialReference(),t=this.getOutputSpatialReference(),s=new e_(this.m_transforms,this.m_bNameIsSet?this.m_name:null,e,t);return s.m_bReadOnly=!0,this.clear(),s}}const s_=Object.freeze(Object.defineProperty({__proto__:null,SpatialReference:oc,SpatialReferencePrecisionDescriptor:ac,create:Ou,createFromWKT:Yu,createImplFromPe:Ru,createLocal:Wu,createWithNewPrecision:Lu,createWithNewVCS:zu,getGCS:Zu,getTempName:tc,hasNoPe:qu,hasPe:Uu,injectNoPe:Mu,injectPe:Au,isInitialized:Bu,isTempName:sc,isValidWkid:Ku,isValidWkt:Qu,makeSpheroidData:Hu,snapGeometry:ju,webMercator:hc,webMercator102100:mc,wgs84:lc},Symbol.toStringTag,{value:"Module"}));export{Yh as $,Zn as A,Ko as B,fa as C,t_ as D,Lc as E,zc as F,Jc as G,Hu as H,Al as I,Tl as J,Zl as K,Cc as L,Dc as M,wc as N,qh as O,eu as P,ds as Q,Wl as R,mg as S,Ka as T,cs as U,Xl as V,ql as W,Wo as X,Ps as Y,Vc as Z,Oh as _,Rg as a,Wu as a0,as as a1,Ag as a2,cm as a3,kl as a4,Pc as a5,um as a6,Lh as a7,zh as a8,Rh as a9,tn as aA,sn as aB,Ys as aC,tc as aD,Yu as aE,Ic as aF,zl as aG,ks as aH,Qu as aI,Ku as aJ,Hm as aK,Ou as aL,ac as aM,Lu as aN,ss as aO,s_ as aP,Xh as aa,_m as ab,qs as ac,Is as ad,vs as ae,Th as af,Us as ag,Cs as ah,jl as ai,bc as aj,Zu as ak,cl as al,fg as am,sr as an,ir as ao,zm as ap,Wm as aq,ha as ar,Ra as as,ka as at,er as au,ju as av,Sa as aw,ya as ax,pa as ay,nh as az,Yg as b,Og as c,Lg as d,Qg as e,Eh as f,jm as g,Uu as h,Mu as i,ul as j,wh as k,Lo as l,Wg as m,Lm as n,Km as o,al as p,zg as q,kr as r,ih as s,hh as t,da as u,_a as v,aa as w,Fa as x,Ma as y,la as z};
|