@arcgis/core 5.0.0-next.7 → 5.0.0-next.8
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/KnowledgeStudio/resourceSerializationUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{8f56f298e7c1a283f407.js → 0030d68d9edf42b4af57.js} +1 -1
- package/assets/esri/core/workers/chunks/01d460398f3ba6767a37.js +1 -0
- package/assets/esri/core/workers/chunks/{17d5f8dba6ebb1184506.js → 042cd64e1f4eb326c30f.js} +1 -1
- package/assets/esri/core/workers/chunks/05429f9d292a7a714309.js +316 -0
- package/assets/esri/core/workers/chunks/{66db5f77e09d25e33951.js → 063905fbf9a0c6586949.js} +1 -1
- package/assets/esri/core/workers/chunks/{9486032af3e934d85582.js → 0a5d74414dd02a2fb8e1.js} +1 -1
- package/assets/esri/core/workers/chunks/{3815ffa13e7b439bca6e.js → 0d5212f59e9b62c16164.js} +1 -1
- package/assets/esri/core/workers/chunks/{73487b9d85e726e9c012.js → 1257c37bf04d39c27b62.js} +1 -1
- package/assets/esri/core/workers/chunks/{398f356b11fd33bd3831.js → 136a7d781dad05a7463b.js} +1 -1
- package/assets/esri/core/workers/chunks/{1e4e7aedf4b779241a02.js → 15c7c10ff9ac63f0e792.js} +1 -1
- package/assets/esri/core/workers/chunks/17784cf16fa91504b9ea.js +1 -0
- package/assets/esri/core/workers/chunks/{a395373e3173e6458a56.js → 1ab37e13947d0e2e4181.js} +1 -1
- package/assets/esri/core/workers/chunks/{f03635ddf56e2ef90e4c.js → 1d06fcae4c2f02fb1c95.js} +1 -1
- package/assets/esri/core/workers/chunks/{020c8913d8e35d63080b.js → 1d15d1b20dc10fde6def.js} +1 -1
- package/assets/esri/core/workers/chunks/1dfca37f95f2b968aa54.js +1 -0
- package/assets/esri/core/workers/chunks/20975513be0a3a1da286.js +1 -0
- package/assets/esri/core/workers/chunks/{285762ff92d5388b6024.js → 2166238a7ad63a2d43c7.js} +1 -1
- package/assets/esri/core/workers/chunks/{620a94b54be3ed78350d.js → 22ca80f491e070b2a5e7.js} +1 -1
- package/assets/esri/core/workers/chunks/{88074189fa10c335370b.js → 24cd7b84cd0f3de4bff2.js} +1 -1
- package/assets/esri/core/workers/chunks/{9fac5a12e878cd745354.js → 28020063048e644f17a5.js} +1 -1
- package/assets/esri/core/workers/chunks/{95c594a87b732f5c4979.js → 2a8dff8521e1e6a10cf6.js} +1 -1
- package/assets/esri/core/workers/chunks/{7e43c105f1cfc44b7bd0.js → 2fa01bd3f3608616fd7f.js} +1 -1
- package/assets/esri/core/workers/chunks/30e220f4f843681a4cdd.js +1 -0
- package/assets/esri/core/workers/chunks/{5d3661d1fe46dd29aae9.js → 311b564e44ae637c960d.js} +1 -1
- package/assets/esri/core/workers/chunks/31c7ce65e16f7858400f.js +1 -0
- package/assets/esri/core/workers/chunks/{8a314b3790313e6dc5db.js → 333b62dad3811cff0f14.js} +1 -1
- package/assets/esri/core/workers/chunks/36d067c8d03d7a894f5f.js +1 -0
- package/assets/esri/core/workers/chunks/{e31192ae920e3e19b6aa.js → 37c1f155da14de91565a.js} +1 -1
- package/assets/esri/core/workers/chunks/{aa54b6f2aba6952af149.js → 38cc18fd93c18815ded0.js} +1 -1
- package/assets/esri/core/workers/chunks/{c55c096669677321a227.js → 38cd3648932bf2534b0f.js} +1 -1
- package/assets/esri/core/workers/chunks/{ac26e3e77df4302f47a2.js → 3afb83f5de033dda89ec.js} +1 -1
- package/assets/esri/core/workers/chunks/{f5e47eea8720ba84665b.js → 3c07aa2015ab1dff5f7b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e9311386f58f3cb95c22.js → 42a1e71d09e8583a7327.js} +1 -1
- package/assets/esri/core/workers/chunks/443dfe7029ec208f670c.js +1 -0
- package/assets/esri/core/workers/chunks/{b75930d60449eceb0f1c.js → 4baf6f6e7ddedb25f806.js} +1 -1
- package/assets/esri/core/workers/chunks/{bb5484b5eeacc9ad2ceb.js → 4d0cbf9584446f411a37.js} +1 -1
- package/assets/esri/core/workers/chunks/{17103e6542aae53c7301.js → 4e3e27673d0671fc2b58.js} +1 -1
- package/assets/esri/core/workers/chunks/{5fc7b61f467f1d60a284.js → 51ab2acac4ecc1ca9c34.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc4417d1260b717a9385.js → 52282f767bd0e99ddca0.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc06014fb484fc8c697e.js → 53654edd766d9b4ef750.js} +1 -1
- package/assets/esri/core/workers/chunks/{90f8b4bda28af43ea019.js → 538f509d7fc8337d37ac.js} +1 -1
- package/assets/esri/core/workers/chunks/{ed8a85efbd90241512bb.js → 588533c3abe876f20f62.js} +1 -1
- package/assets/esri/core/workers/chunks/{c8733cd621105afab2ac.js → 59d3cac32ad6dad941dc.js} +1 -1
- package/assets/esri/core/workers/chunks/{72846fb9c87c6642daf0.js → 5e2ce34def5e053913b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c056eac35d05d9524b7.js → 5f29422a051311ef9b3c.js} +1 -1
- package/assets/esri/core/workers/chunks/5f402b3c00bc4afc77b2.js +1 -0
- package/assets/esri/core/workers/chunks/{ff35a077ac6776469805.js → 61d970ed75c2c358b1e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{7a6a96edc892d7060b7d.js → 629127877042ad784ad2.js} +1 -1
- package/assets/esri/core/workers/chunks/{fd2efd1d1cf9d95a87e6.js → 63a6f3e70d2b6ea57e40.js} +1 -1
- package/assets/esri/core/workers/chunks/{90b2b43b8b54c9a1ec35.js → 664ae441617afe4b17ec.js} +1 -1
- package/assets/esri/core/workers/chunks/{c4e4da69969499a89a2c.js → 695cdef5057e5461078a.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c5a7249a311070d8f43.js → 6af18d7a0d314d7c1756.js} +1 -1
- package/assets/esri/core/workers/chunks/{f35aaa04cca676c2d3f8.js → 6b59f94040c7d2f6728a.js} +1 -1
- package/assets/esri/core/workers/chunks/{811d4c46c75cf6a63e78.js → 6bb7dbc46787b8e34bd9.js} +1 -1
- package/assets/esri/core/workers/chunks/6d9f2b113d6bde936a04.js +1 -0
- package/assets/esri/core/workers/chunks/{5132ca68e8c7af111a47.js → 6e22b02a9715c10578d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{cd1930f08e1fc8b30b14.js → 6ee2f0f708494102a493.js} +1 -1
- package/assets/esri/core/workers/chunks/{f0e0a63962784acb4ba1.js → 6f0aec7428021e440ac9.js} +1 -1
- package/assets/esri/core/workers/chunks/{deb2854bb7d082a26f52.js → 7005d956c990a04ee8b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3991ae8caa713d4ddcd.js → 731f7b552dde0fb325cd.js} +1 -1
- package/assets/esri/core/workers/chunks/{464d42bebb365287808d.js → 773f2c6c9d38db76dfed.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f3d492f1093b7832aab.js → 7803495f8862d9025bcd.js} +1 -1
- package/assets/esri/core/workers/chunks/78694ad8229347903f41.js +1 -0
- package/assets/esri/core/workers/chunks/7e4c14d4502e3f06d94b.js +1 -0
- package/assets/esri/core/workers/chunks/{7544316a75dbd981aea6.js → 86cb097deec50b0da3f3.js} +1 -1
- package/assets/esri/core/workers/chunks/8a40ed2ee4b032822c30.js +1 -0
- package/assets/esri/core/workers/chunks/{09de8be660174a229efb.js → 8cbb28476151a37ae958.js} +1 -1
- package/assets/esri/core/workers/chunks/{62a49cfd9a2508950e9f.js → 8fedfd33c37172dba6bf.js} +1 -1
- package/assets/esri/core/workers/chunks/90cbd627d4113db3b686.js +1 -0
- package/assets/esri/core/workers/chunks/91aa1157da32f650983b.js +1 -0
- package/assets/esri/core/workers/chunks/{e7638b9ab6674bc8a18f.js → 91dfd29e2dba200eab09.js} +1 -1
- package/assets/esri/core/workers/chunks/{794748fd1edc29a621cd.js → 9698f36c143953a975d4.js} +1 -1
- package/assets/esri/core/workers/chunks/98584902c9db6faa3e4d.js +1 -0
- package/assets/esri/core/workers/chunks/9e5e05d6430712b0b1bc.js +1 -0
- package/assets/esri/core/workers/chunks/{6f4bd0ee85e7e5a74340.js → a31635a6366347dcef0f.js} +1 -1
- package/assets/esri/core/workers/chunks/a6ee40dfc471d6612f3c.js +1 -0
- package/assets/esri/core/workers/chunks/{ccc0da0e01f023c8aa1f.js → a876d6159ca120c1567e.js} +1 -1
- package/assets/esri/core/workers/chunks/{a4db5c9a90107e097df8.js → af47272aaaef0ea57e71.js} +1 -1
- package/assets/esri/core/workers/chunks/{d1fe816b6990918c13c7.js → afc13d5b842275db7dbc.js} +1 -1
- package/assets/esri/core/workers/chunks/aff8e40a641c6822af1d.js +1 -0
- package/assets/esri/core/workers/chunks/{22d6b8102e75bdef204c.js → b0365cbc3d2a41969e3b.js} +1 -1
- package/assets/esri/core/workers/chunks/{79968c183135281d2a6f.js → b3613a38178cad2ebc82.js} +1 -1
- package/assets/esri/core/workers/chunks/b548910e820d731ffe8a.js +1 -0
- package/assets/esri/core/workers/chunks/{5bd36dbf46c25bd961c8.js → b708792c84620b73c847.js} +1 -1
- package/assets/esri/core/workers/chunks/c29486c4eeb3e72effff.js +1 -0
- package/assets/esri/core/workers/chunks/{2b94623cabc6ae0f86ce.js → c37f7756d48ff9af2656.js} +1 -1
- package/assets/esri/core/workers/chunks/{1c52999a6392370844a6.js → c4090a60d149a5962179.js} +1 -1
- package/assets/esri/core/workers/chunks/{73c1d43070b4fe1e5c1e.js → c8e686efe344a33a0258.js} +1 -1
- package/assets/esri/core/workers/chunks/{6bb5158de43c4b59107f.js → c9b16fd41cd59d452522.js} +1 -1
- package/assets/esri/core/workers/chunks/ce98416437cc1a89d8ea.js +1 -0
- package/assets/esri/core/workers/chunks/{279366e6b743f9680603.js → cfff044859e6e6dcc75d.js} +1 -1
- package/assets/esri/core/workers/chunks/d07f911d40bf05fc0306.js +1 -0
- package/assets/esri/core/workers/chunks/{8833c3d168951be4bf20.js → d0d79dd3e88eecf5c314.js} +1 -1
- package/assets/esri/core/workers/chunks/{76ae1702fecc7ad7017c.js → d1e97cce5047f1791e22.js} +1 -1
- package/assets/esri/core/workers/chunks/{17acde0245ecd956306c.js → d233cc33497a663450f9.js} +1 -1
- package/assets/esri/core/workers/chunks/{36fe6b8228e622407ec2.js → d8793eead02491136841.js} +1 -1
- package/assets/esri/core/workers/chunks/{dedc4583b5f32a278124.js → d88f2fe680b8d5603ef8.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d599008e1ea42321b37.js → da24ad57747714ac5eda.js} +1 -1
- package/assets/esri/core/workers/chunks/{facb3886714222772ab2.js → ddfd01bb9ba8577c3ffc.js} +1 -1
- package/assets/esri/core/workers/chunks/{50d9f69d5255af4b29bb.js → df5afa06c6deb6b40109.js} +1 -1
- package/assets/esri/core/workers/chunks/e25c4b4a03270d48f408.js +1 -0
- package/assets/esri/core/workers/chunks/e3294318daf1192b8319.js +1 -0
- package/assets/esri/core/workers/chunks/{da573ecc68e6aa8f6da9.js → e767f83f9e2de6650f80.js} +1 -1
- package/assets/esri/core/workers/chunks/e9d4cae2144974489d6e.js +1 -0
- package/assets/esri/core/workers/chunks/{91df8638b8b904e6d8c5.js → ead8d0cbcebd12dbfad7.js} +1 -1
- package/assets/esri/core/workers/chunks/{f9324e88c359c03f35aa.js → eb9c166db0db6fa60e95.js} +1 -1
- package/assets/esri/core/workers/chunks/{8ffd4710d168c2fcfd96.js → ebf23b46db56aaa88841.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc241c7735e4efba734a.js → f34e3fa0c5b28531e289.js} +1 -1
- package/assets/esri/core/workers/chunks/f64037a88ab03662dc2a.js +1 -0
- package/assets/esri/core/workers/chunks/{d97fadbc69e055d183a0.js → f77f4bd6a577b92cf66f.js} +1 -1
- package/assets/esri/core/workers/chunks/{16d66770ef841564ee3f.js → f89c90f98c85667b0ebc.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c4227b0ea21a5e429ab.js → fb192de7e4fa152342bb.js} +1 -1
- package/assets/esri/core/workers/chunks/fbd8d2f61f8a15bcf3db.js +1 -0
- package/assets/esri/core/workers/chunks/{2f78861afe0e9037dd8d.js → fe49321dca22dc60d105.js} +1 -1
- package/assets/esri/core/workers/chunks/{fe77ae6cf232a7a3298e.js → fef45bc59c71f88c60b5.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/Point2D.js +1 -1
- package/chunks/UnitFactory.js +1 -1
- package/config.js +1 -1
- package/core/QueueProcessor.js +1 -1
- package/core/SetUtils.js +1 -1
- package/core/has.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/identity/Credential.js +1 -1
- package/identity/IdentityManager.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/interfaces.d.ts +67 -27
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/support/fieldConfigUtils.js +1 -1
- package/layers/support/rasterDatasets/pixelReader.js +1 -1
- package/layers/support/source/DataLayerSource.js +1 -1
- package/package.json +3 -3
- package/popup/FieldInfo.js +1 -1
- package/processRequest.js +5 -0
- package/request.js +1 -1
- package/requestConfig.js +5 -0
- package/requestQueue.js +5 -0
- package/rest/query/executeForCount.js +1 -1
- package/rest/query/executeForExtent.js +1 -1
- package/rest/query/executeForIds.js +1 -1
- package/rest/query/executeQueryJSON.js +1 -1
- package/rest/query/executeQueryPBF.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/support/BaseImageMeasureResultValue.js +5 -0
- package/rest/support/ImageAreaResult.js +1 -1
- package/rest/support/ImageDistanceResult.js +1 -1
- package/rest/support/ImageHeightResult.js +1 -1
- package/rest/support/ImageMeasureResultAngleValue.js +5 -0
- package/rest/support/ImageMeasureResultAreaValue.js +5 -0
- package/rest/support/ImageMeasureResultLengthValue.js +5 -0
- package/rest/support/ImageWithType.js +5 -0
- package/rest/support/imageMeasureUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/{3d/support/ImageWithType.js → 2d/layers/features/sources/strategies/constants.js} +1 -1
- package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/volumeMeasurementErrors.js +1 -1
- package/views/3d/glTF/DefaultLoadingContext.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
- package/views/3d/layers/ElevationLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/graphics/FeatureGraphics3DGraphicsPipeline.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
- package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/I3SDataRequester.js +5 -0
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/MediaLayerInteractionOptions.js +1 -1
- package/views/3d/layers/support/MediaLayerInteractionReshapeOptions.js +5 -0
- package/views/3d/layers/support/SampledGeometryMaxDistanceRatio.js +5 -0
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/layers/support/fetchTile.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/support/SharedSymbolResources.js +1 -1
- package/views/3d/support/StreamTextureCollection.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +6 -0
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/views/draw/MultipointDrawAction.js +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/input/CursorUpdateEvents.js +5 -0
- package/views/draw/input/DrawCompleteEvent.js +5 -0
- package/views/draw/input/VertexAddEvent.js +5 -0
- package/views/draw/input/VertexRemoveEvent.js +5 -0
- package/views/draw/input/VertexUpdateEvent.js +5 -0
- package/views/interactive/editGeometry/CheckpointingEditGeometryOperations.js +5 -0
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/operations/ReplayableAppendVertex.js +5 -0
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTilesSimple.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicZoomManager.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
- package/widgets/PanoramicViewer/support/getVisibleTiles.js +5 -0
- package/widgets/Sketch/CreateToolVisibilityMap.js +5 -0
- package/widgets/Sketch/SelectionToolVisibilityMap.js +5 -0
- package/widgets/Sketch/VisibleElements.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/02e69f0c63d97661da60.js +0 -1
- package/assets/esri/core/workers/chunks/05eee334d58a0b9f6316.js +0 -1
- package/assets/esri/core/workers/chunks/087973e7c4fea5fcfa5e.js +0 -1
- package/assets/esri/core/workers/chunks/326a76a4e80269d4029d.js +0 -1
- package/assets/esri/core/workers/chunks/377a66034e7c1bad5599.js +0 -1
- package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +0 -1
- package/assets/esri/core/workers/chunks/459a67928bde4a62b6a4.js +0 -1
- package/assets/esri/core/workers/chunks/53bd8996e8812f1ad7b2.js +0 -1
- package/assets/esri/core/workers/chunks/557960763695abee4a83.js +0 -1
- package/assets/esri/core/workers/chunks/6201356f7f91e5c06425.js +0 -1
- package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +0 -1
- package/assets/esri/core/workers/chunks/7413e582bc2b16af6a0f.js +0 -1
- package/assets/esri/core/workers/chunks/7461124454bfb4fb6474.js +0 -1
- package/assets/esri/core/workers/chunks/75bf27271a31e26e1b21.js +0 -1
- package/assets/esri/core/workers/chunks/7aaaebbabee27690283c.js +0 -1
- package/assets/esri/core/workers/chunks/7c4a63aeead2505d6f02.js +0 -1
- package/assets/esri/core/workers/chunks/90250e9239c173aace88.js +0 -1
- package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +0 -1
- package/assets/esri/core/workers/chunks/99859dce1925b406ccd0.js +0 -1
- package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +0 -1
- package/assets/esri/core/workers/chunks/9e8dceef4c961f56940d.js +0 -1
- package/assets/esri/core/workers/chunks/a06bac9b8f9e18874de8.js +0 -316
- package/assets/esri/core/workers/chunks/a712cdff78fc826acd8c.js +0 -1
- package/assets/esri/core/workers/chunks/d305a21666b1ed5bf33d.js +0 -1
- package/assets/esri/core/workers/chunks/d40f57f9fc47f9a9f97c.js +0 -1
- package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +0 -1
- package/assets/esri/core/workers/chunks/f4d0ae6be1b3984228d0.js +0 -1
- package/assets/esri/core/workers/chunks/f6c8beb60f6d29945a2e.js +0 -1
- package/assets/esri/core/workers/chunks/f746e3f7ebff2bbdf333.js +0 -1
- package/views/3d/layers/i3s/I3SStreamDataController.js +0 -5
- package/views/3d/support/StreamDataLoader.js +0 -5
- package/views/3d/support/StreamDataRequester.js +0 -5
- package/views/3d/support/downloadSlots.js +0 -5
- package/views/draw/input/DrawEvents.js +0 -5
package/chunks/UnitFactory.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{a as e,c as t,G as s,f as n,d as r,h as i,g as o,s as a,u as h,v as m,w as l,t as g,p as u,r as c,i as _,e as d,x as p,y as f,o as x,z as y,l as P,q as E,A as S}from"./Geometry.js";import{Envelope2D as C}from"./Envelope2D.js";import{P as I,y as b,z as w,a as v,M as N,A as T,E as G,c as D,g as V,S as F,L as H,B as k,F as A,n as M,H as U,I as q,J as B,Q as O,D as Y,l as R,K as X,N as L,O as z,V as W,R as j,T as Z,U as K,W as Q,X as J,Y as $,Z as ee,_ as te,$ as se,a0 as ne,a1 as re,a2 as ie,a3 as oe,a4 as ae,b as he}from"./MultiPathImpl.js";import{b as me,a as le,j as ge,k as ue,i as ce,g as _e,c as de,E as pe,P as fe,C as xe,e as ye,I as Pe,T as Ee,l as Se,A as Ce,B as Ie,m as be,n as we,o as ve,V as Ne,p as Te,q as Ge,r as De,t as Ve,u as Fe,v as He,w as ke,x as Ae,y as Me,h as Ue,z as qe,S as Be,D as Oe,F as Ye,d as Re,G as Xe,H as Le,J as ze,f as We}from"./Envelope.js";import{A as je,B as Ze,d as Ke,P as Qe,C as Je,v as $e,D as et,n as tt,F as st,G as nt,c as rt,e as it,r as ot,E as at,H as ht,l as mt,m as lt,K as gt,a as ut,I as ct,J as _t,L as dt,S as pt,q as ft,f as xt,N as yt,O as Pt,g as Et,Q as St,o as Ct,s as It,j as bt,b as wt,i as vt,h as Nt,k as Tt,R as Gt,T as Dt,M as Vt,U as Ft,V as Ht,W as kt,X as At,Y as Mt,Z as Ut,_ as qt,$ as Bt,a0 as Ot,a1 as Yt,y as Rt,a2 as Xt,p as Lt}from"./Point2D.js";import{__addDisposableResource as zt,__disposeResources as Wt}from"tslib";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(t){return this.getUnitType()!==t.getUnitType()&&e("unit type mismatch"),this.getUnitToBaseFactor()/t.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return je(Ze(this.getUnitType()),Ze(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,10799,10800,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,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,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,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,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,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(t){return t.getType()===bc.PE_TYPE_LINUNIT?new bu(t):t.getType()===bc.PE_TYPE_ANGUNIT?new os(t):void e("peUnit")}function ms(t){const s=Hc(null);return t.getType()===bc.PE_TYPE_PROJCS||t.getType()===bc.PE_TYPE_GEOGCS?s.reset(t.getUnit()):e("PE_coord_sys"),s.get()||r("cannot create units from coord sys"),hs(s.get())}class ls{constructor(t,s,n){void 0===t?(this.x=new At,this.y=new At,this.z=new At):t instanceof Re?(this.x=new At(t.x),this.y=new At(t.y),this.z=new At(t.z)):t instanceof At?(this.x=t.clone(),this.y=s.clone(),this.z=n.clone()):e("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 Re.construct(this.x.value(),this.y.value(),this.z.value())}}class gs{constructor(e){if(this.m_origin=new Re,this.m_normal=new Re,this.m_axisX=new Re,this.m_axisY=new Re,!e)return this.m_origin=new Re,this.m_normal=new Re(0,0,1),this.m_axisX=new Re(1,0,0),void(this.m_axisY=new Re(0,1,0));e.pt0&&e.pt1&&e.pt2?this.setFromPoints(e.pt0,e.pt1,e.pt2):o(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return o(0),this}set(e,t,s,n){o(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 o(0),{}}getCoord2D(e){return o(0),{}}getCoordX(e,t){return o(0),0}getCoordY(e,t){return o(0),0}getCoordZ(e,t){return o(0),0}setPreferredAxisX(e){o(0)}getOrigin(){return o(0),{}}getNormal(){return o(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){o(0)}setAxisY(e,t=!1){o(0)}recalculateAxisY(){o(0)}setOrigin(e){o(0)}setNormal(e,t){o(0)}intersect(e,t){return o(0),!1}intersectLine(e){return o(0),0}intersectLineEx(e,t){return o(0),0}closestCoordinate(e){const t=e.sub(this.m_origin),s=new Qe;return s.x=t.dotProduct(this.m_axisX),s.y=t.dotProduct(this.m_axisY),s}projectVector(e){return o(0),{}}signedDistance(e){return o(0),0}distance(e){return o(0),0}}function us(e,t){return!1}function cs(e,t,s,n,r=100,i=us){let a,h,m,l,g,u,c,_,d;o(n>0);let p,f,x,y=0,P=0;const E=Yt();t>s&&(s=rt(t,t=s));const S=e(t),C=e(s);S<C?(a=h=m=t,l=g=u=S):(a=h=m=s,l=g=u=C);let I=0;for(;I<r&&(x=.5*(s-t),d=t+x,p=n*(Math.abs(a)+.25),f=2*p,!(i(a,l)||Math.abs(a-d)<=f-x));++I){if(Math.abs(P)>p){const e=(a-h)*(l-u);let n=(a-m)*(l-g),r=(a-m)*n-(a-h)*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-a)||r>=n*(s-a)?(P=a>=d?t-a:s-a,y=Yt()*P):(y=r/n,_=a+y,(_-t<f||s-_<f)&&(y=d-a<0?-Math.abs(p):Math.abs(p)))}else P=a>=d?t-a:s-a,y=P*E;_=a+y,c=e(_),c<l?(_>=a?t=a:s=a,m=h,h=a,a=_,u=g,g=l,l=c):(_<a?t=_:s=_,c<=g||h===a?(m=h,h=_,u=g,g=c):(c<=u||m===a||m===h)&&(m=_,u=c))}return mt(a,l)}function _s(e,t,s){if(e>s){e-=Math.ceil((e-s)/Lt)*Lt}else if(e<t){e+=Math.ceil((t-e)/Lt)*Lt}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 Re.construct(m,l,g)}function ys(e,t,s){const n=new At,r=new At,i=new At,o=new At;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 At(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 Qe.construct(o,h)}function Es(e,t,s){const n=1-t,r=e/Math.sqrt(ut(s.x)+ut(s.y)+ut(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,Re.lerp(i,o,r))}function Cs(e,t,s){const n=new Re;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 Re;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(e,t,s,n){const r={stack:[],error:void 0,hasError:!1};try{const i=zt(r,new Cc,!1);return Dc.geodeticDistance(e,t,s.x,s.y,n.x,n.y,i,null,null,bc.PE_LINETYPE_GEODESIC),i.val}catch(i){r.error=i,r.hasError=!0}finally{Wt(r)}}function ws(e,t,s,n,r){switch(o(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 Re.distance(r,i)}default:g("")}}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,Re.lerp(n,r,s));return ws(e,t,a,o,i)},m=Re.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,Re.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 Re(0,0,0),pt1:n,pt2:r}),h=i.closestCoordinate(s),m=i.closestCoordinate(n),l=i.closestCoordinate(r),g=Qe.getClosestCoordinate(m,l,h),u=Es(e,t,Re.lerp(n,r,g)),c=Re.distance(u,a);return o&&o.assign(u),mt(g,c)}const h=s=>{const i=Es(e,t,Re.lerp(n,r,s));return Re.distance(i,a)},m=Re.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,Re.lerp(n,r,i))),mt(i,a)}{const e=Re.distance(s,n);return o&&o.assign(s),mt(.5,e)}}function Ts(e,t,s,n){const r={stack:[],error:void 0,hasError:!1};try{const n=zt(r,new Cc,!1);return Dc.greatEllipticDistance(e,t,s.x,s.y,s.x,s.y,n,null,null),n.val}catch(i){r.error=i,r.hasError=!0}finally{Wt(r)}}function Gs(e,t,s,n,r){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>Ct||Math.abs(n.y)>Ct)return Number.NaN;if((Math.abs(s.y)===Ct||Math.abs(n.y)===Ct)&&s.x!==n.x)return Number.NaN;const{first:i,second:o}=kt(s.x,n.x);let a=r;a=_s(a,i,o);if(!at.construct(s.x,n.x).containsCoordinate(a))return Number.NaN;const h=J.constructPoint2D(s),m=J.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,Qe.construct(a,f)),y=Re.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)>Ct||Math.abs(n.y)>Ct)return 0;if((Math.abs(s.y)===Ct||Math.abs(n.y)===Ct)&&s.x!==n.x)return 0;if(Math.abs(r)>=Ct)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=J.constructPoint2D(s),a=J.constructPoint2D(n),h=ys(1,t,o),m=ys(1,t,a),l=h.crossProductVector(m);if(l.z.isZero()){return at.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]),o(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=It(n,-Ct,Ct),r=It(r,-Ct,Ct);const i=Ct-.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=ut(t)/(e-1);for(let e=o.length-1;e>=0;--e)s=o[e]+s*n;return s*=-ut(t/(1-e)),s},h=a(Ct-t);return(a(Ct-s)-h)*n}{const e=Ct-t,r=Ct-s,i=-4*ut(Math.sin(e/2));return(-4*ut(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*Rt(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*Ut()/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)=>Pt(e,t),Ze(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 Ye{constructor(e){super(),this.m_bufferLeft=new F,this.m_bufferRight=new F,this.m_intervalLeft=at.constructEmpty(),this.m_intervalRight=at.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 F,this.m_point=Qe.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 at;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!==M;){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!==M;){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 Be(8),this.m_clusterVertices=new Be(2),this.m_firstCluster=M,this.m_lastCluster=M,this.m_halfEdgeData=new Be(8),this.m_chainData=new Be(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,n=null,r=!1){const i=[];i.push(t),this.m_simplifiedGeometry=t,r?this.setEditShapeImpl3D_(e,Zs.enumInputModeSimplifyAlternate,i,n,!1):this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyAlternate,i,n,e.getGeometryType(t)===s.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=M,this.m_lastCluster=M,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=M,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){o(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 Ce(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){o(0)}getHalfEdgeToXYZ(e,t){o(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 Ce(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 o(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,M),this.setChainHalfEdge_(i,M),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return o(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return o(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return o(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return o(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return o(0),!1}doesClusterBelongToAPolygonInterior(e,t){return o(0),!1}doesClusterBelongToAPolygonExterior(e,t){return o(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return o(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 o(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 Ce(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,n,r){const i=t===M?e.createGeometry(s.enumPolygon):t,o=new F;this.extractPolygonPathFromChain_(e,i,n,r,o);for(let s=this.getChainFirstIsland(n);s!==M;s=this.getChainNextInParent(s))this.extractPolygonPathFromChain_(e,i,s,r,o);return i}getGeometryID(e){const t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return o(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(o(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const t=this.getChainUserIndex(e,this.m_chainBitSetIndex);o(t>=0);let s=this.m_chainBitSets.at(t);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(e){o(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!==M;n=this.getChainNextInParent(n))s(e);return t}getChainPolygons(e){return o(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!==M;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())o(this.m_geometryMapID.has(n)),t.push(this.m_geometryMapID.get(n));return t}getVertexDominant(e,t){if(t===M)return e;const s=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(s,t)}getVertexDominantFromCluster(e,t){if(t!==M){let s=M;for(let n=this.getClusterVertexIterator(e);n!==M;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);s===M&&(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!==M){return this.getVertexFromVertexIterator(t)}return M}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}setBreakNode(e,t){o(-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 o(0),!1}getHalfEdgeConnector(e,t){const s=this.getClusterHalfEdge(e);if(s===M)return M;let n=s,r=M,i=M;do{if(this.getHalfEdgeTo(n)===t)return n;if(r===M){if(r=this.getClusterHalfEdge(t),r===M)return M;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 M}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=Qe.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 F,r=new F;this.querySegmentXY(e,n),this.querySegmentXY(t,r);const i=n.get(),a=r.get();if(i.equals(a))return 0;const h=new Qe;this.getHalfEdgeFromXY(e,h);const m=new Qe;this.getHalfEdgeToXY(e,m);const l=new Qe;this.getHalfEdgeToXY(t,l),o(!m.isEqualPoint2D(l));return q(i,a)}compareEdgeAnglesHelper_(e,t,s){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,s);const n=Qe.getNAN();this.getHalfEdgeToXY(e,n);const r=Qe.getNAN();if(this.getHalfEdgeToXY(t,r),n.isEqualPoint2D(r))return 0;const i=Qe.getNAN();this.getHalfEdgeFromXY(e,i);const o=Qe.getNAN();o.setSub(n,i);const a=Qe.getNAN();if(a.setSub(r,i),!s||a.y>=0&&o.y>0){return Qe.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 o(0),0}compareEdgeAnglesForPair3D_(e,t){return o(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){const t=this.getHalfEdgeChain(e),s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(s);o(n===t),o(e===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(e));let r=this.getHalfEdgeNext(e);r===s&&(r=this.getHalfEdgeNext(r),r===e&&(r=M));const i=this.getChainIndex_(t),a=this.m_chainAreas.read(i);Number.isNaN(a)||(this.setChainArea_(t,Number.NaN),this.setChainPerimeter_(t,Number.NaN));const h=this.getChainHalfEdge(t);h!==e&&h!==s||this.setChainHalfEdge_(t,r),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,s){let n=t!==M?t:this.getClusterHalfEdge(e);if(n===M)return M;const r=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const e=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(e===r)return M;n=e}}removeSpikes_(){let e=!1;const t=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==M;s=this.getNextCluster(s)){let n=M;for(;;){let r=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,t);if(r===M)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=M),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 o(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?M:e;for(let n=this.getHalfEdgeVertexIterator(e);n!==M;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(e,t){e!==M&&(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 gt(0),n=new gt(0),r=this.getChainHalfEdge(e),i=Qe.getNAN(),o=Qe.getNAN(),a=Qe.getNAN();this.getHalfEdgeFromXY(r,i),o.setCoordsPoint2D(i);let h=r;do{this.getHalfEdgeToXY(h,a),t&&this.isCurveEdge(h)||n.pe(Qe.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 F;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 o(0),0}planeSweepParentage_(e,t){const s=new Ws(this),n=new Ee;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const r=[],i=this.createUserIndexForHalfEdges();let o=null;const a=Qe.getNAN();for(let h=this.getFirstCluster();h!==M;h=this.getNextCluster(h)){this.progress_(t);const m=this.getClusterHalfEdge(h);if(m!==M){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,Be.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)===M){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!==M&&(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)!==M)return;const i=this.getLeftSkipPolylines_(e,t),a=this.getHalfEdgeTwin(n),h=this.getHalfEdgeChain(a);let m=this.getChainParent(r),l=this.getChainParent(h);if(i===M)m===M&&(h===r?(this.setChainParent_(h,this.m_universeChain),l=this.m_universeChain,m=l):(l===M&&(this.setChainParent_(h,this.m_universeChain),l=this.m_universeChain),this.setChainParent_(r,h),m=h));else{const e=this.getHalfEdgeChain(i);if(l===M){if(this.getChainArea(e)<=0){const t=this.getChainParent(e);this.setChainParent_(h,t),l=t}else this.setChainParent_(h,e),l=e;h===r&&(m=l)}}m===M&&(this.trySetChainParentFromTwin_(r,h),m=this.getChainParent(r)),o(m!==M),s===Zs.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,n,i):s===Zs.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,n,i,a,r,h):s===Zs.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,n,i,a,r,h)}propagateParentageBuildGraph_(e,t,s,n){let r,i=t;n===M?(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,a){if(i===a)return;let h=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);h+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);let m=0;const l=[],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),m+=e;let i=!1;0!==l.length&&l.at(-1)===r&&(g.pop(),l.pop(),i=!0),o(this.getChainParent(r)!==M),i&&this.getChainParent(r)===n||(g.push(m),l.push(n))}}if(m+=h,0!==l.length&&l.at(-1)===a&&(g.pop(),l.pop()),0!==m){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===M){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=M,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!==M)return!1;a=i}h++,i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(r!==i);return a!==M&&-1!==o&&(this.setHalfEdgeUserIndex(e.getElement(o),t,Be.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!==M)return this.setChainParent_(e,s),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let n=0,r=t.size();n<r;n++){const r=t.read(n),o=this.m_shape.getUserIndex(r,this.m_clusterIndex),a=this.m_shape.getPathFromVertex(r),h=this.m_shape.getGeometryFromPath(a),m=this.m_shape.getGeometryType(h);if(i(m)){const t=this.m_shape.getNextVertex(r);if(t===M)continue;const n=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(o===n)continue;const i=this.newHalfEdgePair_(),a=this.getHalfEdgeTwin(i),l=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(l,0,r),this.m_clusterVertices.setField(l,1,-1),this.setHalfEdgeVertexIterator_(i,l),this.m_shape.setUserIndex(r,this.m_halfEdgeIndex,i),this.setHalfEdgeOrigin_(i,o);const g=this.getClusterHalfEdge(o);if(g===M)this.setClusterHalfEdge_(o,i),this.setHalfEdgePrev_(i,a),this.setHalfEdgeNext_(a,i);else{const e=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,a),this.setHalfEdgeNext_(a,g),this.setHalfEdgeNext_(e,i),this.setHalfEdgePrev_(i,e)}this.setHalfEdgeOrigin_(a,n);const u=this.getClusterHalfEdge(n);if(u===M)this.setClusterHalfEdge_(n,a),this.setHalfEdgeNext_(i,a),this.setHalfEdgePrev_(a,i);else{const e=this.getHalfEdgePrev(u);this.setHalfEdgePrev_(u,i),this.setHalfEdgeNext_(i,u),this.setHalfEdgeNext_(e,a),this.setHalfEdgePrev_(a,e)}const c=this.getGeometryID(h);if(e===Zs.enumInputModeBuildGraph){const e=m===s.enumPolygon?c:0;if(this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const e=new Ls,t=this.m_shape.getGeometryUserIndex(h,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(i,e),this.setEdgeBitSet_(a,null),this.setLeftEdgeBitSet_(a,e),this.setLeftEdgeBitSet_(i,null)}}else if(e===Zs.enumInputModeSimplifyWinding){const e=this.m_shape.getXY(r),s=this.m_shape.getXY(t);let n=0,o=0;e.compare(s)<0?n=1:o=-1,this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex,n),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,o)}else e===Zs.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const _=m===s.enumPolygon?tn.c_EdgeBitMask:0;this.setHalfEdgeParentage_(i,c|_),this.setHalfEdgeParentage_(a,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!==M&&(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!==M){const n=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(e,s),this.setHalfEdgeVertexIterator_(t,M)}}const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeTwin(t);{const e=this.getHalfEdgeVertexIterator(n);if(e!==M){const t=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(s,e),this.setHalfEdgeVertexIterator_(n,M)}}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!==M;s=this.getNextCluster(s)){t.length=0;const n=this.getClusterHalfEdge(s);if(n!==M){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]=rt(t[0],t[0]=t[1]):r=!1;let i=t[0],o=i,a=this.getHalfEdgeTo(o),h=this.getHalfEdgeTwin(o),m=M;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=M,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]=M,n===i&&(t[0]=M,i=M)}}if(this.updateVertexToHalfEdgeConnection_(m,!1),m=M,!r){i=M;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s!==M){i=s;break}}n!==i&&this.setClusterHalfEdge_(s,i);continue}i=M;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s===M)continue;if(i===M){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){o(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,M);let t=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==M;n=this.getNextCluster(n)){const e=this.getClusterHalfEdge(n);if(e!==M){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 Oe(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new Oe(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){o(0)}simplifyAlternate_(){o(0)}simplifyWinding_(){o(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 Ce(0);let a=0,h=0;{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==M;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,h++);for(let t=this.m_shape.getFirstPath(e);t!==M;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)}d(this.m_shape.getGeometryType(e))||(a+=this.m_shape.getPathCount(e)),null!=s?(e=t<s.length?s[t]:M,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=Qe.getNAN();let l=0;const g=Qe.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=M,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!==M&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===M&&(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!==M;){for(let t=this.m_shape.getFirstPath(e);t!==M;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]:M,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){o(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_(){o(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,M));const a=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(a)===n&&(t!==n?this.setClusterHalfEdge_(a,t):this.setClusterHalfEdge_(a,M)),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 M;{const t=e.getElement(s);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}}}checkStructureAfterDirtySweep_(){const e=ut(this.m_checkDirtyPlanesweepTolerance),t=new Qe,s=new Qe,n=new Qe,r=new Qe,i=new Qe;for(let o=this.getFirstCluster();o!==M;o=this.getNextCluster(o)){const a=this.getClusterHalfEdge(o);if(a!==M){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=M;const m=new fe;do{const o=this.getHalfEdgeTwin(a);if(this.getHalfEdgeChain(o)!==s){let s=M;const o=this.getHalfEdgeOrigin(a);if(n===M){const e=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(o);e!==M;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);s===M&&(s=t);const r=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(r)===n){s=t;break}}let l;if(h===M&&(h=e.insertPath(t,M),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;o(-1!==this.m_clusterBreakNodeIndex),o(-1===this.m_segmentParentageIndex);for(let n=this.getFirstCluster();n!==M;n=this.getNextCluster(n)){let e=0;const t=this.getClusterHalfEdge(n);if(t!==M){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!==M;n=this.getNextCluster(n)){const r=this.getClusterHalfEdge(n);if(r!==M){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=rt(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 o(t>=0),o(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return o(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){o(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){o(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){o(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){o(0)}constructor(e){this.m_listNodes=new Be(2),this.m_listOfLists=sn.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===e&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new Be(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){o(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 o(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 H,m_segment:null,m_segmentInfo:new re(-1),m_env:new at(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}const rn=67;class on extends Ye{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=M,this.m_prev2=M,this.m_vertex1=M,this.m_vertex2=M,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 Qe,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&bt())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){const t=(e&bt())%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&bt())%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++){St(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=Qe.getNAN();s.setSub(t.getEndXY(),t.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=Qe.getNAN();n.setSub(e.getStartXY(),t.getStartXY());const r=Qe.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=M,this.m_prev2=M,this.m_vertex1=M,this.m_vertex2=M;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=M),r&&t===this.m_prev2?o=this.m_prevX2:(o=Number.NaN,this.m_prev2=M),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=j(!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=M,this.m_prev2=M,this.m_vertex1=M,this.m_vertex2=M}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=Qe.getNAN(),this.m_line1=new H,this.m_seg1=null,this.m_env=at.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,s){let n,r=this.m_shape.getSegment(s),i=!0;if(null==r)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),r=this.m_line1,n=this.m_line1.getStartY()===this.m_line1.getEndY();else{const e=C.constructEmpty();r.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),n=0===e.height(),i=!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(n)return this.m_currentNode=t,this.m_bIntersectionDetected=!0,0;let o=0;if(i){Q(this.m_line1);const e=this.m_line1.getStartXY(),t=new Qe;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();const s=new Qe;s.setSub(this.m_pointOfInterest,e),o=t.dotProduct(s),o/=t.length()}else{o=r.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x}if(o<10*-this.m_tolerance)return-1;if(o>10*this.m_tolerance)return 1;if(r.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)){Math.abs(o)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=o),this.m_bIntersectionDetected=!0}return o<0?-1:o>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(t,s){void 0===s&&(s=this.m_hash.getHash(t));const n=s%this.m_hashBuckets.length,r=this.m_hashBuckets[n];r===sn.st_nullNode()&&e("");let i=this.m_lists.getFirst(r),o=sn.st_nullNode();for(;i!==sn.st_nullNode();){const e=this.m_lists.getData(i),s=this.m_lists.getNext(i);e===t?(this.m_lists.deleteElementDirect(r,o,i),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[n]=sn.st_nullNode())):o=i,i=s}}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(t){const s=this.getElement(t),n=this.m_hash.getHash(s)%this.m_hashBuckets.length,r=this.m_hashBuckets[n];r===sn.st_nullNode()&&e(""),this.m_lists.deleteElementSearch(r,t),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[n]=sn.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return sn.st_nullNode()}clear(){o(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 Qe,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=Xt(e);return Mt(s,t)}class pn{constructor(e,t,s,n,r){this.m_workPt=new Qe,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 o(0),!1}}class fn{constructor(e){this.m_origin=Qe.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=M,this.m_bucketArray=Ke(4,Number.NaN),this.m_bucketHash=Ke(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=Qe.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=Qe.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,Be.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=Qe.getNAN();this.m_shape.queryXY(e,s);const n=Qe.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 e={stack:[],error:void 0,hasError:!1};try{zt(e,Nt(()=>{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(),s=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(s.getLowerLeft());const n=Math.max(s.height(),s.width())/(vt()-1);this.m_cellSize<n&&(this.m_cellSize=n,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 r=!1;for(let e=0;e<2;e++){const t=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==M;n=s.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===Be.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],i=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,i))return this.m_nsr=new ts(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(i)),r=!0,r;this.mergeClusters(n,i,!1)}t.length=0}0===e&&this.m_hashTable.addElement(n,s)}}return r}catch(t){e.error=t,e.hasError=!0}finally{Wt(e)}}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())/(vt()-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!==M;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!==M;s=t.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===Be.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=Qe.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 fe,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&&r(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;const s=ut(e*xn.c_smallToleranceFactor);let n=!1;const i=this.m_inputParts[0],o=this.m_inputParts[1],a=this.m_inputSegments[i.segmentIndex],h=this.m_inputSegments[o.segmentIndex];if(t||5&U(!0,a,h,e,!0)){const t=Z(!0,a,h,null,this.m_param1,this.m_param2,e);0===t&&r("");const m=new Array(t);for(let e=0;e<t;++e)m[e]=Qe.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],r=this.m_param2[e];let _,d=i.rankInterior,p=i.weightInterior;0===t?(d=i.rankStart,p=i.weightStart,_=i.u.bBreakStart):1===t?(d=i.rankEnd,p=i.weightEnd,_=i.u.bBreakEnd):(this.m_changed1=!0,_=!1);let f,x=o.rankInterior,y=o.weightInterior;0===r?(x=o.rankStart,y=o.weightStart,f=o.u.bBreakStart):1===r?(x=o.rankEnd,y=o.weightEnd,f=o.u.bBreakEnd):(this.m_changed2=!0,f=!1);const P=d,E=x;let S=1,C=0,I=Qe.getNAN();if(P===E){const n=a.getCoord2D(t),i=h.getCoord2D(r);S=p+y;C=d,St(n,i,y/S,I);const o=Qe.sqrDistance(I,n),m=Qe.sqrDistance(I,i);u[e].bBigMove=o>s,c[e].bBigMove=m>s,this.m_changed1||n.equals(I)||(this.m_changed1=!0),this.m_changed2||i.equals(I)||(this.m_changed2=!0)}else if(P>E){I=a.getCoord2D(t);const n=h.getCoord2D(r);S=p,C=d;const i=Qe.sqrDistance(I,n);u[e].bBigMove=!1,c[e].bBigMove=i>s,this.m_changed2||n.equals(I)||(this.m_changed2=!0)}else{I=h.getCoord2D(r),S=y,C=x;const n=a.getCoord2D(t),i=Qe.sqrDistance(I,n);u[e].bBigMove=i>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 _=i.rankInterior,d=i.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 r=this.allocResultSegment(),o=this.m_resultSegments[r];let h,c,x,y;a.queryCut(p,n,o,!1),o.get().snapControlPoints(e*e);let P=!1,E=!1,S=!1,C=!1,I=!1,b=Qe.getNAN(),w=Qe.getNAN();-1!==f?(c=g[f],h=l[f],P=u[f].bBigMove,b.assign(m[f]),S=u[f].bIsBreak,I=!0):(h=i.weightStart,c=i.rankStart,b=o.get().getStartXY(),S=i.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=i.weightEnd,y=i.rankEnd,w=o.get().getEndXY(),C=i.u.bBreakEnd),I&&o.get().setCoordsForIntersector(b,w,!0),this.m_resultParts1.push(this.newIntersectionPart_(r,h,c,x,y,d,_,S,C,i.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=Ke(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),$e(this.m_param2)):2===t&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=rt(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),x[1]=rt(x[0],x[0]=x[1]));const y=o.rankInterior,P=o.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(),i=this.m_resultSegments[r];let a,u,_,d;h.queryCut(p,n,i,!1),i.get().snapControlPoints(e*e);let E=Qe.getNAN(),S=Qe.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=o.weightStart,u=o.rankStart,E=i.get().getStartXY(),C=o.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 _=o.weightEnd,d=o.rankEnd,S=i.get().getEndXY(),I=o.u.bBreakEnd;v&&i.get().setCoordsForIntersector(E,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(r,a,u,_,d,P,y,C,I,o.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 o(0),1}intersect2D(e,t){const n=this.m_inputParts[0],r=this.m_inputParts[1],i=this.m_inputSegments[n.segmentIndex].getGeometryType(),o=this.m_inputSegments[r.segmentIndex].getGeometryType();if(i!==s.enumLine||o!==s.enumLine){return new bn(this).intersectCurves(e,t)}return this.intersectLines(e,t)}intersect2DEx(e,t,s,n,i){this.m_point.assignCopy(t),1!==this.m_inputSegments.length&&r(""),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;const o=ut(e*xn.c_smallToleranceFactor);let a=!1;const h=this.m_inputParts[0],m=this.m_inputSegments[h.segmentIndex];if(i||m.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=Ke(16,Number.NaN);const r=m.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=r;let i=h.rankInterior,l=h.weightInterior;0===r?(i=h.rankStart,l=h.weightStart):1===r?(i=h.rankEnd,l=h.weightEnd):this.m_changed1=!0;let g=i;const u=s,c=n;g===u&&m.isCurve()&&(g=u+1);let _=1,d=0;const p=new Qe;if(g===u){const e=m.getCoord2D(r),s=t.getXY();_=l+c,d=i;St(e,s,c/_,p),this.m_changed1||e.equals(p)||(this.m_changed1=!0),this.m_changed2||s.equals(p)||(this.m_changed2=!0);a=Qe.sqrDistance(p,e)>o}else if(g>u)p.assign(m.getCoord2D(r)),_=l,d=i,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);a=Qe.sqrDistance(p,t.getXY())>o}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,a?3:2}return 0}intersect3D(e,t,s,n){return o(0),1}intersect3DEx(e,t,s,n,r,i,a){return o(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 F,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 F({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 F({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 fe;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 Qe,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 Qe,this.m_cell=new Qe,this.parent=e}addSegment(e,t,s,n,r,i,a,h,m,l,g){const u=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),s,n,m),c=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),r,i,l);this.newEdge(u,c,e,a,h,g),null===this.m_chainOrigin1?this.m_chainOrigin1=u:null===this.m_chainOrigin2?this.m_chainOrigin2=u:o(0)}intersectCurvesHelper(e,t,n,i,a){const h=this.getSegment(e).get(),m=this.getSegment(t).get();if(h.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(e,t,n,i);if(0!==l)return l;const g=ut(.01*n);let u=!1,c=this.processSharpCorners(h,m,n,a>4);const _=c>0;if(!_){if(!(i||5&j(!0,!1,h,m,n,!0)))return 0;c=Z(!0,h,m,null,this.parent.m_param1,this.parent.m_param2,n)}0===c&&r("");const d=h.getGeometryType(),p=m.getGeometryType(),f=lt(Qe,c),x=lt(Qe,c),y=Ke(c,Number.NaN),P=Ke(c,Number.NaN),E=Ke(c,Number.NaN),S=Ke(c,Number.NaN),C=Tt(En,c),I=Tt(En,c);let b=!1,w=!1;for(let s=0;s<c;s++){const r=this.parent.m_param1[s],i=this.parent.m_param2[s];let o=e.rank,a=e.weight,l=!0,c=!1;0===r?(o=e.start.rank,a=e.start.weight,c=e.start.bIsBreak):1===r?(o=e.end.rank,a=e.end.weight,c=e.end.bIsBreak):(b=!0,l=!1);let v=t.rank,N=t.weight,T=!1,G=!0;0===i?(v=t.start.rank,N=t.start.weight,T=t.start.bIsBreak):1===i?(v=t.end.rank,N=t.end.weight,T=t.end.bIsBreak):(w=!0,G=!1);let D=o,V=v;if(D===V&&(D*=xn.c_maxGeometryTypeToRankDelta,V*=xn.c_maxGeometryTypeToRankDelta,D+=wn(d,h,!1),V+=wn(p,m,!1)),l&&G&&V===D){const e=h.getCoord2D(r),t=m.getCoord2D(i);e.equals(t)&&(V=D-1)}let F=1,H=0,k=1,A=0;const M=new Qe,U=new Qe,q=h.getCoord2D(r),B=m.getCoord2D(i);if(_&&Qe.distance(q,B)>n)M.setCoordsPoint2D(q),U.setCoordsPoint2D(B),F=a,k=N,H=o,A=v,C[s].bBigMove=!1,I[s].bBigMove=!1,c=!0,T=!0;else if(D===V){k=F=a+N,A=H=o;St(q,B,N/F,M),U.setCoordsPoint2D(M);const e=Qe.sqrDistance(M,q),t=Qe.sqrDistance(M,B);C[s].bBigMove=e>g,I[s].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=a,A=H=o;const e=Qe.sqrDistance(M,B);C[s].bBigMove=!1,I[s].bBigMove=e>g,w||B.equals(U)||(w=!0)}else{U.setCoordsPoint2D(B),M.setCoordsPoint2D(U),k=F=N,A=H=v;const e=Qe.sqrDistance(M,q);C[s].bBigMove=e>g,I[s].bBigMove=!1,b||q.equals(M)||(b=!0)}f[s].assign(M),x[s].assign(U),y[s]=F,P[s]=k,E[s]=H,S[s]=A,C[s].bIsBreak=c||T,I[s].bIsBreak=c||T,u||=C[s].bBigMove||I[s].bBigMove,s>0&&(r!==this.parent.m_param1[s-1]&&i!==this.parent.m_param2[s-1]||(E[s]<=E[s-1]?(f[s].assign(x[s-1]),y[s]=P[s-1],E[s]=S[s-1],x[s].assign(x[s-1]),P[s]=P[s-1],S[s]=S[s-1],C[s].bBigMove||=C[s-1].bBigMove,I[s].bBigMove||=I[s-1].bBigMove,C[s].bIsBreak||=C[s-1].bIsBreak,I[s].bIsBreak||=I[s-1].bIsBreak):(f[s-1].assign(f[s]),y[s-1]=y[s],E[s-1]=E[s],x[s-1].assign(x[s]),P[s-1]=P[s],S[s-1]=S[s],C[s-1].bBigMove||=C[s].bBigMove,I[s-1].bBigMove||=I[s].bBigMove,C[s-1].bIsBreak||=C[s].bIsBreak,I[s-1].bIsBreak||=I[s].bIsBreak)))}if(!(b||w||2!==c||d===s.enumLine&&p===s.enumLine)){if(this.processDoublyConnectedEdges(e,t,a+1,n))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;o(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 s=0;s<=c;s++){const t=s<c?this.parent.m_param1[s]:1;if(t!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,a,m,l;h.queryCut(V,t,i,!1),i.get().snapControlPoints(n*n);let g=!1,u=!1,_=!1,d=!1;const p=new Qe,x=new Qe;-1!==F?(a=E[F],o=y[F],_=C[F].bBigMove,g=C[F].bIsBreak,p.assign(f[F])):(o=e.start.weight,a=e.start.rank,_=e.start.bBigMove,g=e.start.bIsBreak,p.assign(i.get().getStartXY())),s<c?(l=E[s],m=y[s],d=C[s].bBigMove,u=C[s].bIsBreak,x.assign(f[s])):(m=N,l=T,d=G,u=D,x.assign(i.get().getEndXY()));let P=v;t<1&&(this.splitEdgeInPlace(v),P=v.getNextInChain()),this.updateSegmentOnly(v,r),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=o,v.start.rank=a,v.end.weight=m,v.end.rank=l,v=P,V=t,F=s}else-1===F&&(F=s)}const H=v.getNextInChain(),k=[];k.length=c;for(let s=0;s<c;s++)k[s]=s;c>2?(k.sort((e,t)=>Gt(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(Gt)):2===c&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=rt(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),k[1]=rt(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 s=0;s<=c;s++){const e=s<c?this.parent.m_param2[s]:1;if(e!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,a,h,l;m.queryCut(V,e,i,!1),i.get().snapControlPoints(n*n);const g=new Qe,u=new Qe;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(i.get().getStartXY());if(s!==c){const e=k[s];h=P[e],l=S[e],u.assign(x[e]),f=I[e].bBigMove,d=I[e].bIsBreak}else h=N,l=T,f=G,d=D,u.assign(i.get().getEndXY());let y=v;e<1&&(this.splitEdgeInPlace(v),y=v.getNextInChain()),this.updateSegmentOnly(v,r),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=h,v.end.rank=l,v=y,V=e,F=s}else-1===F&&(F=s)}const A=v.getNextInChain();return this.postProcessResultPartsForCurves(e,H,t,A,a+1),u?3:2}intersectCurves(e,t){2!==this.parent.m_inputSegments.length&&r(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=Je(16);const s=C.constructEmpty();for(let r=0;r<2;r++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[r].segmentIndex]),t=C.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[r].segmentIndex].queryLooseEnvelope(t),s.mergeEnvelope2D(t);const n=this.parent.m_inputParts[r];this.addSegment(e,0,n.weightStart,n.rankStart,n.weightEnd,n.rankEnd,n.weightInterior,n.rankInterior,n.u.bBreakStart,n.u.bBreakEnd,n.segmentParentage)}s.inflateCoords(100*e,100*e),this.m_origin.assign(s.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 n=0,i=!0;for(;this.m_pairs.length;){const t=this.m_pairs.at(-1);this.m_pairs.pop(),o(t.recursion>=0),o(t.recursion<=256),this.clusterNodes(e);const s=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);i&&(i=!1,n=s)}for(let r=0;r<2;r++){const e=0===r?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let t=(0===r?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 n}tryOverlapIntersectCurves(e,t,s,n){const r=this.parent.m_resultSegments[e.segmentIndex].get(),i=this.parent.m_resultSegments[t.segmentIndex].get(),a=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY()),h=r.getStartXY().equals(i.getEndXY())&&r.getEndXY().equals(i.getStartXY());if(!a&&!h)return 0;const m=$(r,i,!0);if(0!==m&&ee(r,i)&&e.segmentParentage===t.segmentParentage){let e=!1;if(m>0)e=r.equals(i);else{o(-1===m);const t=new F({segment:i});t.get().reverse(),e=r.equals(t.get())}if(e)return 1}const l=s*xn.c_smallToleranceFactor;let g=!1;if(0===m){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 Qe;r.queryCoord2D(n,o);const a=i.getClosestCoordinate(o,!1),h=new Qe;i.queryCoord2D(a,h);const m=Qe.distance(o,h);if(m>s)return 0;g||=m>l}for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new Qe;i.queryCoord2D(n,o);const a=r.getClosestCoordinate(o,!1),h=new Qe;r.queryCoord2D(a,h);const m=Qe.distance(o,h);if(m>s)return 0;g||=m>l}}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,a),t.transferAttributes(this,r,a)):c>u?(e.copyFromWhenOverlap(this,t,a),e.transferAttributes(this,i,a)):e.segmentParentage<=t.segmentParentage?(e.weight=e.weight+t.weight,t.copyFromWhenOverlap(this,e,a),t.transferAttributes(this,r,a)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,a),e.transferAttributes(this,i,a)),g?3:2}postProcessResultPartsForCurves(e,t,s,n,i){i===Dt()&&r("curve_helper");for(let r=e;r!==t;r=r.getNextInChain())this.updateSegmentToNodes(r);for(let r=s;r!==n;r=r.getNextInChain())this.updateSegmentToNodes(r);for(let o=e;o!==t;o=o.getNextInChain()){const e=o.end.pt.sub(o.start.pt);for(let t=s;t!==n;t=t.getNextInChain()){let s=0;if(o.start.pt.equals(t.start.pt)&&o.end.pt.equals(t.end.pt)?s=1:o.start.pt.equals(t.end.pt)&&o.end.pt.equals(t.start.pt)&&(s=-1),!s){let s=o.start.pt.equals(t.start.pt)?1:0;if(s||(s=o.end.pt.equals(t.end.pt)?2:0,s||(s=o.end.pt.equals(t.start.pt)?3:0,s||(s=o.start.pt.equals(t.end.pt)?4:0))),s){const n=t.end.pt.sub(t.start.pt),a=e.dotProduct(n);let h;switch(s){case 1:case 2:h=a>0;break;case 3:case 4:h=a<0;break;default:r("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(In(o,t,i,!1))}continue}const n=this.parent.m_resultSegments[o.segmentIndex],a=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 Qe;n.get().queryCoord2D(t,r);const i=a.get().getClosestCoordinate(r,!1),o=new Qe;a.get().queryCoord2D(i,o);if(Qe.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(o,t,i,!1));continue}for(let e=0,t=h.length;e<t;++e){const t=h[e],r=new Qe;a.get().queryCoord2D(t,r);const i=n.get().getClosestCoordinate(r,!1),o=new Qe;n.get().queryCoord2D(i,o);if(Qe.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(o,t,i,!1));continue}o.equalEdge=t,t.equalEdge=o;let m=o.rank,l=t.rank;m===l&&(m*=xn.c_maxGeometryTypeToRankDelta,l*=xn.c_maxGeometryTypeToRankDelta,m+=wn(n.get().getGeometryType(),n.get(),!0),l+=wn(a.get().getGeometryType(),a.get(),!0)),m>l||m===l&&o.segmentParentage<=t.segmentParentage?(n.copyTo(a,!1),t.segmentParentage=o.segmentParentage,-1===s&&a.get().reverse()):(a.copyTo(n,!1),o.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===Dt()&&r("curve_helper");const i=this.getSegment(e).get(),o=this.getSegment(t).get(),a=i.getStartXY().equals(o.getStartXY())&&i.getEndXY().equals(o.getEndXY())?1:i.getEndXY().equals(o.getStartXY())&&i.getStartXY().equals(o.getEndXY())?-1:0;if(0!==a){const r=new F;i.queryCut(0,.5,r),r.get().snapControlPoints(n*n);const h=new F;i.queryCut(.5,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(e),e.end.pt=r.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(r),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h);let m=o.getClosestCoordinate(e.end.pt,!1);return Math.abs(m-.5)>.2&&(m=.5),o.queryCut(0,m,r),r.get().snapControlPoints(n*n),o.queryCut(m,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(t),t.end.pt=r.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(r),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h),a>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=Je(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;Qe.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=Je(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=vt()-1,i=Math.round(It(s,-r,r)),o=Math.round(It(n,-r,r));let a=i|o<<32;a=Ze(a),t[0]=this.m_hashTableOfEquals[a%this.m_hashTableOfEquals.length];let h=i+1|o<<32;h=Ze(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=Ze(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=Ze(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=vt()-1;let r=Math.round(It(t,-n,n))|Math.round(It(s,-n,n))<<32;return r=Ze(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=te(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=te(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=te(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=te(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,n){let i=0;switch(e){case s.enumLine:i=0;break;case s.enumBezier:i=2;break;case s.enumRationalBezier2:i=3;break;case s.enumBezier2:i=1;break;case s.enumEllipticArc:i=0===t.projectionBehavior()?5:4;break;default:r("")}return n?5-i:i}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 Ye{constructor(e){super(),this.pt1=Qe.getNAN(),this.pt2=Qe.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=Qe.getNAN(),this.m_pt=Qe.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 Be(8),this.m_clusters=new Be(5),this.m_clusterVertices=new sn(!1),this.m_edgeVertices=new sn(!1),this.m_helperPoint=new fe,this.m_eventQ=new Ee,this.m_sweepStructure=new Ee,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 F,this.m_segBuf2=new F,this.m_sweepPoint=new Qe(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,M);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!==M&&(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&&yt(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):r(""),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=Be.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);Be.isValidElement(s)&&(this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(e,-1));const n=Be.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);Be.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),t++):r!==Be.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(Qe.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?Be.impossibleIndex2():-1}fillEventQueue(){const e=new Ce(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let r=t.next();r!==M;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=Qe.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 Ce(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);Be.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=Be.impossibleIndex2(),r=Be.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!==M;t=this.m_shape.getNextGeometry(t)){if(i(this.m_shape.getGeometryType(t)))for(let s=this.m_shape.getFirstPath(t);s!==M;s=this.m_shape.getNextPath(s)){const t=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===M)continue;let r=this.m_shape.getNextVertex(n);if(r===M||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!==M;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 Ce(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 o=e.getFirstPath(t);o!==M;o=e.getNextPath(o)){let t=e.getFirstVertex(o);for(let s=0,n=e.getPathSize(o);s<n;s++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let o=0,g=this.m_points.size();o<g;++o)e.setUserIndex(this.m_points.read(o),this.m_pointsIndex,o);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 a=[];for(let o=1;o<this.m_points.size();o++){const t=this.m_points.read(o);if(t===M)continue;if(-1===e.getUserIndex(t,this.m_pointsIndex))continue;const h=e.getXY(t);if(h.isEqualPoint2D(n))r++;else{if(r>1){for(let t=i;t<o;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);a.push(e)}if(s!==i&&i!==r&&!e.isEqualXYPoint2D(i,n)){const e=Fn(s,i,-1);a.push(e)}}a.length>0&&this.processBunch_(a,n)}s=t,n.assign(h),r=1,i=o}}if(0===this.m_dissolvedEdges)return e.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let h=e.getPointCount(t);for(let o=0;o<this.m_points.size();o++){const t=this.m_points.read(o);if(t===M)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,M),e.freeVertex(t),this.m_points.write(o,M),h--}const m=e.createPathUserIndex();let l=e.getPathCount(t);for(let g=0,u=this.m_points.size();g<u;++g){if(this.m_points.read(g)===M)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,m)){n=M;for(let t=e.getNextVertex(s);t!==s;t=e.getNextVertex(t)){const r=e.getPathFromVertex(t);if(2!==e.getPathUserIndex(r,m)){n=r,s=t;break}}n===M&&(n=e.insertPath(t,M),e.setClosedPath(n,!0),l++),o(n!==M)}e.setPathUserIndex(n,m,2),r=e.getFirstVertex(n);let i=0,a=!1,h=s;do{r===h&&(a=!0),e.setUserIndex(h,this.m_pointsIndex,1);const t=e.getPathFromVertex(h);t!==n&&(2!==e.getPathUserIndex(t,m)&&(e.setPathUserIndex(t,m,1),e.setFirstVertex(t,M)),e.setPathToVertex(h,n)),i++,h=e.getNextVertex(h)}while(h!==s);a||e.setFirstVertex(n,s),e.setPathSize(n,i)}for(let o=e.getFirstPath(t);o!==M;){const t=e.getNextPath(o);1!==e.getPathUserIndex(o,m)&&e.getFirstVertex(o)!==M||(e.removePathOnly(o),l--),o=t}e.setGeometryVertexCount(t,h),e.setGeometryPathCount(t,l),e.removePathUserIndex(m),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=Qe.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!==M;t=e.getNextGeometry(t))if(i(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(i(r)){return new Bn(n).crackAWithBMultiPath_(e,t,s)}g("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 F,s=new F,n=C.constructEmpty(),r=C.constructEmpty(),i=!1,a=new fe,h=new xn,m=this.m_shape.getTotalPointCount(),l=m*m*2,g=this.m_shape.queryVertexIteratorOnSelection();for(let u=g.next();u!==M;u=g.next()){const m=this.m_shape.getGeometryType(g.currentGeometry());let c=1,_=1,p=1,f=0,x=0,y=0;const P=this.m_shape.getSegmentParentage(u);let E=!1,S=!1,C=null,I=!1;if(d(m))c=this.m_shape.getWeight(u),f=this.m_shape.getRank(u);else{if(C=this.getSegment_(u,t),null===C)continue;const e=this.m_shape.getVertexIndex(u);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(u);{const e=this.m_shape.getNextVertex(u);_=this.m_shape.getWeight(e),x=this.m_shape.getRank(e),S=this.m_shape.getSegmentParentageBreakVertex(e)}if(C.queryLooseEnvelope(n),n.inflateCoords(this.m_tolerance,this.m_tolerance),C.isDegenerate(this.m_tolerance)){if(!C.isDegenerate(0))continue;I=!0,C=null}}const b=new W({copy:g});let w=b.next();w!==M&&(w=b.next());let v=0;for(;w!==M;w=b.next()){if(0!==v){v--;continue}if(this.m_shape.getTotalPointCount()>l)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,U=!1;const q=this.m_shape.getSegmentParentage(w);if(d(m))G=this.m_shape.getWeight(w),F=this.m_shape.getRank(w);else{if(N=this.getSegment_(w,s),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),U=this.m_shape.getSegmentParentageBreakVertex(e)}if(N.queryLooseEnvelope(r),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(n.isIntersectingNe(r)){0!==j(!0,!0,C,N,this.m_tolerance,!0)&&(h.pushSegment(C,c,f,_,x,p,y,E,S,P),h.pushSegment(N,G,F,D,H,V,k,A,U,q),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(u,h,0,!0,!0),this.m_shape.splitSegmentWithIntersector(w,h,1,!0,!0),this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(u,!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(n.contains(t)){if(h.pushSegment(C,c,f,_,x,p,y,E,S,P),this.m_shape.queryPoint(w,a),h.intersect2DEx(this.m_tolerance,a,F,G,i),e||=h.getSegmentChanged(0)||h.getResultPointChanged(),B=h.getResultSegmentCount(0),B>0)if(this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(u,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0)),this.m_shape.splitSegmentWithIntersector(u,h,0,!0,!0),T){let e=M;for(let t=this.m_shape.getNextVertex(w);t!==M&&t!==w&&(N=this.getSegment_(t,s),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=w;t!==M&&(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(u);if(r.inflateCoords(this.m_tolerance,this.m_tolerance),r.contains(t)){if(h.pushSegment(N,G,F,D,H,V,k,A,U,q),this.m_shape.queryPoint(u,a),h.intersect2DEx(this.m_tolerance,a,f,c,i),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(u,!0)),this.m_shape.splitSegmentWithIntersector(w,h,0,!0,!0),v+=O-1,I){let e=M;for(let t=this.m_shape.getNextVertex(u);t!==M&&t!==u&&(N=this.getSegment_(t,s),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=u;t!==M&&(this.m_shape.setPoint(t,h.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(u,h.getResultPoint(),!0);h.clear()}}}if(B+O!==0&&0!==B){let e=!1;for(;C=this.getSegment_(u,t),null!=C&&(C.queryEnvelope(n),C.isDegenerate(this.m_tolerance));){if(!(B>1)){e=!0;break}u=g.next(),B--,o(u!==M)}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 Ce(0);t.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let r=0,g=s.next();g!==M;++r,g=s.next())t.write(r,g);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(M);const n=this.m_shape.createUserIndex(),i=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 o=null;const a=[],h=[];let m=0;const l=new Qe;for(let g=t.read(m++);g!==M;){this.m_shape.queryXY(g,l);let s=!1;do{let e=this.m_shape.getNextVertex(g),r=this.m_shape.getPrevVertex(g);s||=e!==M||r!==M,e===M||this.m_shape.selected(e)||(e=M),r===M||this.m_shape.selected(r)||(r=M),e!==M&&this.m_shape.compareVerticesSimpleY(g,e)<0&&(h.push(g),h.push(e)),r!==M&&this.m_shape.compareVerticesSimpleY(g,r)<0&&(h.push(r),h.push(r));const o=this.m_shape.getUserIndex(g,n);-1!==o&&(a.push(o),this.m_shape.setUserIndex(g,n,-1));const l=this.m_shape.getUserIndex(g,i);-1!==l&&(a.push(l),this.m_shape.setUserIndex(g,i,-1)),g=t.read(m++)}while(g!==M&&this.m_shape.isEqualXYPoint2D(g,l));if(!s&&(null===o&&(o=new an(this.m_shape,this.m_tolerance)),o.setPoint(l),this.m_sweepStructure.searchUpperBound(o),o.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&(r("needsCrackingIMpl_"),this.m_nonSimpleResult=new ts(6,-1,-1));break}let u=1===a.length&&2===h.length;const c=32;a.length>c&&$e(a);let _=-1,d=-1;if(!u)for(let t=0,n=a.length;t<n;t++){const s=a[t],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===a.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===a.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=a.length;e<t;e++){const t=a[e];this.m_sweepStructure.deleteNode(t)}a.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,r=h.length;t<r;t+=2){const s=h[t],r=h[t+1];let o;if(u?(o=this.m_sweepStructure.replaceElementAtPosition(a[0],s,!0,!0),a.length=0,u=!1):o=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(r,n)?this.m_shape.setUserIndex(r,n,o):this.m_shape.setUserIndex(r,i,o)}if(e)break;h.length=0}return this.m_shape.removeUserIndex(n),this.m_shape.removeUserIndex(i),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=C.constructEmpty();e.queryLooseEnvelope(r);const i=C.constructEmpty();if(t.queryLooseEnvelope(i),i.inflateCoords(n,n),!i.isIntersecting(r))return e;const a=e.getImpl(),h=a.getAccelerators();let l=null,g=null;h&&(g=h.getQuadTree()),On(e,m(t))&&(l=Ve(a,i),g=l);const u=g?g.getIteratorForQT():null,c=t.querySegmentIterator(),_=e.querySegmentIterator(),d=Ke(15,Number.NaN),p=[];for(;c.nextPath();)for(;c.hasNextSegment();){const e=c.nextSegment();if(g){u.resetIterator(e,n);for(let t=u.next();-1!==t;t=u.next()){this.progress_();const s=g.getElement(t);if(_.resetToVertex(s,-1),_.hasNextSegment()){const t=_.nextSegment().intersect(e,null,d,null,n);for(let e=0;e<t;e++){const t=d[e];if(0===t||1===t)continue;const s=qn(t,_.getStartPointIndex());p.push(s)}}}}else{const t=C.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(n,n),!r.isIntersecting(t))continue;for(_.resetToFirstPath();_.nextPath();)for(;_.hasNextSegment();){const s=_.nextSegment(),r=C.constructEmpty();if(s.queryLooseEnvelope(r),!r.isIntersecting(t))continue;const i=s.intersect(e,null,d,null,n);for(let e=0;e<i;e++){const t=d[e];if(0===t||1===t)continue;const s=qn(t,_.getStartPointIndex());p.push(s)}}}}if(0===p.length)return e;p.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 f=e.createInstance();if(f.getGeometryType()===s.enumPolygon){f.setFillRule(e.getFillRule())}for(_.resetToFirstPath();_.nextPath()&&!_.hasNextSegment(););o(_.hasNextSegment());let x=_.nextSegment();const y=new F;let P=-1;for(let s=0,m=p.length;s<m;){const e=p[s].index;let t=s+1;for(;t<m&&p[t].index===e;)++t;for(;_.getStartPointIndex()<e;){this.progress_();const e=_.hasNextSegment(),t=_.getPathIndex();if((e||!_.isClosingSegment()||_.isCurve())&&(o(null!==x),f.addSegment(x,P!==t)),P=t,!e){for(_.isPathClosed();_.nextPath()&&!_.hasNextSegment(););o(_.hasNextSegment())}x=_.nextSegment()}let n=0;for(let i=s;i<t;i++){const e=p[i].t;if(e===n)continue;o(null!==x),x.queryCut(n,e,y),n=e;const t=_.getPathIndex();f.addSegment(y.get(),P!==t),P=t}const r=_.hasNextSegment();if((r||!_.isClosingSegment()||_.isCurve())&&(o(null!=x),x.queryCut(n,1,y),f.addSegment(y.get(),!1)),r)x=_.nextSegment();else{for(;_.nextPath()&&!_.hasNextSegment(););x=_.hasNextSegment()?_.nextSegment():null}s=t}if(null!==x){const e=_.getPathIndex();(_.hasNextSegment()||!_.isClosingSegment()||_.isCurve())&&f.addSegment(x,P!==e),P=e}let E=_.hasNextSegment();for(;;){if(!E){for(;_.nextPath()&&(E=_.hasNextSegment(),!E););if(!E)break}x=_.nextSegment();const e=_.getPathIndex();E=_.hasNextSegment();(E||!_.isClosingSegment()||_.isCurve())&&f.addSegment(x,P!==e),P=e}return f}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 Ee,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=lt(F,16),this.m_xOrds=Ke(16,Number.NaN),this.m_inputPoint=Qe.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,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 Qe.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),o(this.m_monotoneParts.length>=s)),s>0)for(let n=0;n<s;n++){const e=this.m_monotoneParts[n].get(),t=at.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 o(0),2}}function Rn(e,t,s,n){const r=new C;e.queryLooseEnvelope(r),r.inflateCoords(n,n);const i=0===e.getFillRule(),o=new Yn(i,n);o.setInputPoint(s);const a=r.clone();a.xmax=s.x+n,a.ymin=s.y-n,a.ymax=s.y+n;const h=e.getImpl().querySegmentIterator(),m=t.getIterator(a,n);for(let l=m.next();-1!==l;l=m.next())if(h.resetToVertex(t.getElement(l),-1),h.hasNextSegment()){const e=h.nextSegment();if(o.processSegment(e))return-1}return o._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,s){if(e.isEmpty())return 0;const n=C.constructEmpty();if(e.queryLooseEnvelope(n),n.inflateCoords(s,s),!n.contains(t))return 0;const r=e.getImpl().getAccelerators();if(r){r.getRasterizedGeometry()&&o(0);const n=r.getQuadTree();if(n)return Rn(e,n,t,s)}return Xn(e,t,s)}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=rt(t,t=s));const n=Qe.getNAN(),r=Qe.getNAN();return this.m_shape.queryXY(t,n),this.m_shape.queryXY(s,r),o(!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 Ye{constructor(e){super(),this.m_line1=new H,this.m_line2=new H,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&&y("")}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 M;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 M}}class $n{constructor(e){this.m_edges=null,this.m_shape=null,this.m_AET=new Ee,this.m_yScanline=0,this.m_geometry=M,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!==M&&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 a=M;if(0===i){let s=this.m_AET.getPrev(e),n=e,r=!1;for(;s!==Ee.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)){a=t;break}n=s,s=this.m_AET.getPrev(s)}if(s===Ee.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(a,this.m_pathOrientationIndex);2===e?(a=this.m_shape.getPathUserIndex(a,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(a,this.m_pathOrientationIndex),o(3===e)):o(3===e);const t=this.m_shape.getPathUserIndex(a,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(a,this.m_pathParentageIndex,i),this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(i,this.m_pathParentsIndex,a)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}a=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]=M):i=-1!==n?n:r,-1!==i&&(this.insertEdge_(s,i)||this.m_AET.deleteNode(i),e[t]=M)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){const s=Qe.getNAN(),n=Qe.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 Qe;let i=M,a=M,h=-1;const m=new Jn(this);for(let o=m.next();o!==M;o=m.next()){const m=new Qe;this.m_shape.queryXY(o,m);const l=this.m_shape.getPathFromVertex(o);if(r.equals(m)&&a===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===h){h=t.length,this.m_shape.setUserIndex(i,n,h),t.push(1);-1===this.m_shape.getPathUserIndex(l,s)&&(this.m_shape.setPathUserIndex(l,s,i),e.push(l))}this.m_shape.setUserIndex(o,n,h),t[t.length-1]++}else h=-1,r.assign(m);i=o,a=l}if(0===e.length)return!1;o(-1!==s);for(let o=0,l=e.length;o<l;o++){const r=e[o];let i=this.m_shape.getPathUserIndex(r,s);const a=this.m_shape.getUserIndex(i,n),h=[],m=[];h.push(i),m.push(a);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===m.length){m.push(r),h.push(s);continue}if(m.at(-1)===r){const o=h.at(-1);this.m_shape.peelALoopIntoAPath(o,s),this.m_shape.setUserIndex(e,n,-1),t[r]--,1===t[r]&&(t[r]=0,m.pop(),h.pop()),i=o,e=o}else h.push(e),m.push(r)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(n),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){const e={stack:[],error:void 0,hasError:!1};try{let t,s=!1;const n=zt(e,Nt(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const e=this.m_shape.getPointCount(this.m_geometry);t=new Ce(0);for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==M;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 n.bForget=!0;if(this.m_bFixSelfTangency&&(s=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!==M;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 r=[];this.m_yScanline=Number.NaN;const i=Qe.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 o=new Jn(this);for(let e=o.next();e!==M&&(this.progress_(),this.m_shape.queryXY(e,i),i.y!==this.m_yScanline&&r.length&&(s=this.processBunchForRingOrientationTest_(r)||s,this.m_sweepComparator.reset(),r.length=0),r.push(e),this.m_yScanline=i.y,0!==this.m_unknownRingOrientationCount);e=o.next());return this.m_unknownRingOrientationCount>0&&(s=this.processBunchForRingOrientationTest_(r)||s,r.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),s}catch(t){e.error=t,e.hasError=!0}finally{Wt(e)}}fixRingOrientationImplSimplify_(){const e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==M;)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!==M;){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!==M;e=this.m_shape.getNextPath(e),--n){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==t){s=M;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,ze),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!==M;)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!==M;){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!==M;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==n){r=M;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,ze)}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=M,this.m_sortedVertices=new Pe,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=M,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 Qe;this.m_shape.queryXY(s,n);const r=new Qe,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 Qe;this.m_shape.queryXY(o,a);const h=this.m_bunchEdgeCenterPoints[t],m=new Qe;this.m_shape.queryXY(h,m);const l=new Qe;l.setSub(n,a);const g=new Qe;g.setSub(r,m),(l.isZero()||g.isZero())&&y("");return Qe.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 F),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new F),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 q(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!==M){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,M),this.m_shape.setLastVertex(t,M)}}}}processBunch_(){let e=!1;const t=new Qe(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)!==ze&&(this.m_bunchEdgeEndPoints.push(i),this.m_shape.setUserIndex(i,this.m_userIndexSortedAngleIndexToVertex,ze),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++));this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==ze&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,ze),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)===s.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),n=new Ce(0);this.m_shape.dbgVerifyMonotone();for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==M;s=this.m_shape.getNextPath(s)){let e=this.m_shape.getFirstVertex(s);for(let t=0,r=this.m_shape.getPathSize(s);t<r;t++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),n.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(n,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 s=0;s<t;s++){const e=n.read(s),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 i=0,o=!1;do{o=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const t=new Qe(0,0);this.m_firstCoincidentVertex!==Pe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let s=0,n=this.m_firstCoincidentVertex;for(;n!==Pe.st_nullNode()&&(n=this.m_sortedVertices.getNext(n),n!==Pe.st_nullNode());){this.progress_();const e=this.m_sortedVertices.getData(n),r=Qe.getNAN();if(this.m_shape.queryXY(e,r),t.equals(r))s++;else{if(s>0){this.m_nextVertexToProcess=n;const e=this.processBunch_();n=this.m_nextVertexToProcess,n!==Pe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(n),r),e&&(o=!0)}t.setCoordsPoint2D(r),this.m_firstCoincidentVertex=n,s=0}}if(this.m_nextVertexToProcess=-1,s>0){this.processBunch_()&&(o=!0)}i++>10&&r(""),o&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(o=!0),e||=o}while(o);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=Ke(8,Number.NaN),c=Ke(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=rt(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=rt(s,s=r),i=rt(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!==M;){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===M)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:M,bModified:!1};let n=this.m_shape.getPrevVertex(t),r=this.m_shape.getNextVertex(t),i=M,o=M;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===M)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!==M?this.m_shape.movePath(this.m_polylineDegeneracies,M,e):this.m_shape.removePath(e),s.v=M,s;{const e=this.m_shape.peelALoopIntoAPath(i,o);this.m_polylineDegeneracies!==M?this.m_shape.movePath(this.m_polylineDegeneracies,M,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=M,r=M;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===M)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===M)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,M,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,M)}let t=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==M;){const s=this.m_shape.getFirstVertex(n);if(s===M||this.m_shape.getPathFromVertex(s)!==M){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)!==M)continue;const r=[!1],i=this.m_shape.insertClosedPath(this.m_geometry,M,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!==M;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(t,n,r,i,o,a=!0){switch(ir(i)){case 0:break;case 1:e("relation string length has to be 9 characters");break;default:e("relation string")}if(a){const e=xr(i,t.getDimension(),n.getDimension());if(0!==e)return kr(t,n,r,e,o)}let h=0;if("number"==typeof r)h=r;else{const e=C.constructEmpty();t.queryEnvelope(e);const s=C.constructEmpty();n.queryEnvelope(s);const i=C.constructEmpty();i.setCoords({env2D:e}),i.mergeEnvelope2D(s),h=le(r,i,!1)}const m=Tr(t,h),l=Tr(n,h);if(m.isEmpty()||l.isEmpty())return fr(m,l,i);const g=m.getGeometryType(),u=l.getGeometryType();let c=!1;switch(g){case s.enumPolygon:switch(u){case s.enumPolygon:c=or(m,l,h,i,o);break;case s.enumPolyline:c=ar(m,l,h,i,o);break;case s.enumPoint:c=ur(m,l,h,i);break;case s.enumMultiPoint:c=hr(m,l,h,i,o)}break;case s.enumPolyline:switch(u){case s.enumPolygon:c=ar(l,m,h,Gr(i),o);break;case s.enumPolyline:c=mr(m,l,h,i,o);break;case s.enumPoint:c=cr(m,l,h,i,o);break;case s.enumMultiPoint:c=lr(m,l,h,i,o)}break;case s.enumPoint:switch(u){case s.enumPolygon:c=ur(l,m,h,Gr(i));break;case s.enumPolyline:c=cr(l,m,h,Gr(i),o);break;case s.enumPoint:c=dr(m,l,h,i);break;case s.enumMultiPoint:c=_r(l,m,h,Gr(i))}break;case s.enumMultiPoint:switch(u){case s.enumPolygon:c=hr(l,m,h,Gr(i),o);break;case s.enumPolyline:c=lr(l,m,h,Gr(i),o);break;case s.enumMultiPoint:c=gr(m,l,h,i,o);break;case s.enumPoint:c=_r(m,l,h,i)}break;default:c=!1}return c}function nr(e,t,s,n){const r=new vr;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaAreaPredicates_();const i=C.constructEmpty(),o=C.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);let a=!1;if(qr(i,o,s)&&(r.areaAreaDisjointPredicates_(e,t),a=!0),a||Br(e,t),a){return pr(r.m_matrix,r.m_scl)}let h=new G,m=h.addGeometry(e),l=h.addGeometry(t),g=null,u=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){g=new fa;const e=_a(s,h.getEnvelope2D(n));u=pa(e,0),aa(h,e,s,12e3,g,null,n)}ya(h,new xe(s,0).add(u),n,!1,!1);const c=h.getGeometry(l).getBoundary();if(h.filterClosePoints(0,!0,!0,!1,M),er(h,m,-1,!1,M,n),0===h.getPointCount(m))return!1;er(h,l,-1,!1,M,n),r.setEditShape_(h,n);const _=0===h.getPointCount(l);if(!_){r.computeMatrixTopoGraphHalfEdges_(m,l),r.m_topoGraph.removeShape();const e=pr(r.m_matrix,r.m_scl);if(!e)return e}const d=h.getGeometry(m);h=new G,m=h.addGeometry(d),l=h.addGeometry(c),r.setEditShape_(h,n),r.m_predicateCount=0,r.resetMatrix_(),r.setPredicates_(_?"T*****F**":"******F**"),r.setAreaLinePredicates_(),r.computeMatrixTopoGraphHalfEdges_(m,l),r.m_topoGraph.removeShape();return pr(r.m_matrix,r.m_scl)}function rr(e,t,s,n){const r=new vr;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaLinePredicates_();const i=C.constructEmpty(),o=C.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);let a=!1;if(qr(i,o,s)&&(r.areaLineDisjointPredicates_(e,t),a=!0),a||Br(e,t),a){return pr(r.m_matrix,r.m_scl)}const h=new G,m=h.addGeometry(e),l=h.addGeometry(t);if(r.setEditShapeCrackAndCluster_(h,new xe(s,0),n),0===h.getPointCount(m))return!1;r.computeMatrixTopoGraphHalfEdges_(m,l),r.m_topoGraph.removeShape();return pr(r.m_matrix,r.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,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaAreaPredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.areaAreaDisjointPredicates_(e,t),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function ar(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaLinePredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.areaLineDisjointPredicates_(e,t),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.m_clusterIndexB=i.m_topoGraph.createUserIndexForClusters(),wr(a,i.m_topoGraph,i.m_clusterIndexB),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexB),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function hr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaPointPredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.areaPointDisjointPredicates_(e),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function mr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLineLinePredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.lineLineDisjointPredicates_(e,t),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.m_clusterIndexA=i.m_topoGraph.createUserIndexForClusters(),i.m_clusterIndexB=i.m_topoGraph.createUserIndexForClusters(),wr(o,i.m_topoGraph,i.m_clusterIndexA),wr(a,i.m_topoGraph,i.m_clusterIndexB),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexA),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexB),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function lr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLinePointPredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.linePointDisjointPredicates_(e),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.m_clusterIndexA=i.m_topoGraph.createUserIndexForClusters(),wr(o,i.m_topoGraph,i.m_clusterIndexA),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexA),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function gr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setPointPointPredicates_();const o=new C,a=new C;e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.pointPointDisjointPredicates_(),h=!0),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function ur(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaPointPredicates_();const o=C.constructEmpty();e.queryEnvelope(o);const a=t.getXY();let h=!1;if(Or(a,o,s)&&(i.areaPointDisjointPredicates_(e),h=!0),!h){const t=Lo(e,a,s);if(1===t)i.m_matrix[0]=0,i.m_matrix[2]=2,i.m_matrix[3]=-1,i.m_matrix[5]=1,i.m_matrix[6]=-1;else if(2===t){i.m_matrix[6]=-1;if(0!==e.calculateArea2D())i.m_matrix[0]=-1,i.m_matrix[3]=0,i.m_matrix[2]=2,i.m_matrix[5]=1;else{i.m_matrix[0]=0,i.m_matrix[3]=-1,i.m_matrix[5]=-1;const t=C.constructEmpty();e.queryEnvelope(t),i.m_matrix[2]=t.height()||t.width()?1:-1}}else i.areaPointDisjointPredicates_(e)}return pr(i.m_matrix,n)}function cr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLinePointPredicates_();const o=C.constructEmpty();e.queryEnvelope(o);let a=!1;if(Or(t.getXY(),o,s)&&(i.linePointDisjointPredicates_(e),a=!0),!a){let n=null,o=!1,a=!1;if(i.m_performPredicates[0]||i.m_performPredicates[6]){!kr(e,t,s,4,r)?(i.m_performPredicates[0]&&(n=D(e),a=!kr(n,t,s,4,r),o=!0,i.m_matrix[0]=a?-1:0),i.m_matrix[6]=-1):(i.m_matrix[0]=-1,i.m_matrix[6]=0)}if(i.m_performPredicates[3]&&(null!==n&&n.isEmpty()?i.m_matrix[3]=-1:(o||(null==n&&(n=D(e)),a=!kr(n,t,s,4,r),o=!0),i.m_matrix[3]=a?0:-1)),i.m_performPredicates[5])if(null!==n&&n.isEmpty())i.m_matrix[5]=-1;else if(o&&!a)i.m_matrix[5]=0;else{null===n&&(n=D(e));const o=kr(n,t,s,3,r);i.m_matrix[5]=o?-1:0}if(i.m_performPredicates[2]){if(0!==e.calculateLength2D())i.m_matrix[2]=1;else{const n=new N({vd:e.getDescription()});n.addPoints(e,0,e.getPointCount());const o=kr(n,t,s,3,r);i.m_matrix[2]=o?-1:0}}}return pr(i.m_matrix,i.m_scl)}function _r(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setPointPointPredicates_();const o=C.constructEmpty();e.queryEnvelope(o);const a=t.getXY(),h=new Qe;let m=!1;if(Or(a,o,s)&&(i.pointPointDisjointPredicates_(),m=!0),!m){let t=!1,n=!0;const r=s*s;for(let s=0;s<e.getPointCount()&&(e.queryXY(s,h),Qe.sqrDistance(h,a)<=r?t=!0:n=!1,!t||n);s++);t?(i.m_matrix[0]=0,i.m_matrix[2]=n?-1:0,i.m_matrix[6]=-1):(i.m_matrix[0]=-1,i.m_matrix[2]=0,i.m_matrix[6]=0)}return pr(i.m_matrix,n)}function dr(e,t,s,n,r){const i=e.getXY(),o=t.getXY(),a=Ke(9,-1);Qe.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=Ke(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 h=o.getGeometryType();if(i(h))if(h===s.enumPolygon){if(0!==o.calculateArea2D())r[2]=2,r[5]=1;else{r[5]=-1;const e=C.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]=T(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!==M;r=t.getNextCluster(r)){if(0===(t.getClusterParentage(r)&n))continue;const e=t.getClusterHalfEdge(r);if(e===M){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 r("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=Ke(9,0),this.m_maxDim=Ke(9,0),this.m_performPredicates=Ke(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,s,n,r){const i=-1!==t,o=-1!==n;if(i||o){if(!("T"!==s&&"F"!==s&&i||"T"!==r&&"F"!==r&&o)||0!==e.calculateArea2D())i&&(this.m_matrix[t]=2),o&&(this.m_matrix[n]=1);else if(o&&(this.m_matrix[n]=-1),i){const s=C.constructEmpty();e.queryEnvelope(s),this.m_matrix[t]=s.height()||s.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=T(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=T(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=T(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=T(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=T(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!==M;i=this.m_topoGraph.getNextCluster(i)){const e=this.m_topoGraph.getClusterHalfEdge(i);if(e===M){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!==M&&(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,n){let r=0;if(e.hasCurves()){const s=new fa,i=e.getEnvelope2D(n),o=_a(t.total(),i);r=pa(o,0),aa(e,o,t.total(),12e3,s,null,n),s.clearStitcher(e)}ya(e,t.add(r),n,!1,!1),e.filterClosePoints(0,!0,!0,!1,M);for(let i=e.getFirstGeometry();i!==M;i=e.getNextGeometry(i))e.getGeometryType(i)===s.enumPolygon&&er(e,i,-1,!1,M,n);this.setEditShape_(e,n)}}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,r){const i=e.getGeometryType();if(n(i)){const t=new I({vd:e.getDescription()});return t.addSegment(e,!0),t}if(i===s.enumEnvelope){const s=e,n=C.constructEmpty();if(e.queryEnvelope(n),n.height()<=t&&n.width()<=t){const t=new fe({vd:e.getDescription()});return s.getCenter(t),t}if(n.height()<=t||n.width()<=t){const t=new I({vd:e.getDescription()}),n=new fe;return s.queryCornerByVal(0,n),t.startPathPoint(n),s.queryCornerByVal(2,n),t.lineToPoint(n),t}const r=new v({vd:e.getDescription()});return r.addEnvelope(s,!1),r}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 r("should not be called"),!1}constructor(e,t,s,n=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=C.constructEmpty(),this.m_envInter=C.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const r=e.getAccelerators();let o=null;null!=r&&(o=n?r.getQuadTreeForPaths():r.getQuadTree());const a=t.getAccelerators();let h=null;if(null!=a&&(h=n?a.getQuadTreeForPaths():a.getQuadTree()),null===o&&null===h&&!n){const n=e.getPointCount(),r=t.getPointCount();if(n>10&&r>10){const a=C.constructEmpty(),m=C.constructEmpty(),l=C.constructEmpty();e.queryLooseEnvelope(a),t.queryLooseEnvelope(m),a.inflateCoords(s,s),m.inflateCoords(s,s),l.setCoords({env2D:a}),l.intersect(m),n>=r?o=i(e.getGeometryType())?Ve(e,l):Fe(e,l):h=i(t.getGeometryType())?Ve(t,l):Fe(t,l)}}this.construct_(e,o,t,h,s,n)}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):i(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?i(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||u(""),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||u(""),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 h=C.constructEmpty(),m=C.constructEmpty();e.queryLooseEnvelope(h),n.queryLooseEnvelope(m),h.inflateCoords(o,o),m.inflateCoords(o,o),this.m_envInter.setCoords({env2D:h}),this.m_envInter.intersect(m),this.m_multiVertexImplA=e,this.m_multiVertexImplB=n;const l=e.getGeometryType(),g=n.getGeometryType();this.m_bPaths=a,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=s.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,i(g)?(this.m_queryType=g,this.m_function=this.nextPath_,a?this.m_pathIndex=n.getPathCount():this.m_segIter=n.querySegmentIterator()):(this.m_queryType=g,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,i(l)?(this.m_queryType=l,this.m_function=this.nextPath_,a?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=l,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(a&&i(l)&&i(g)?this.m_intersector=Me(e,n,o):i(l)&&i(g)?(this.m_intersector=He(e,n,o),this.m_bSwapElements=!1):i(l)&&!i(g)?(this.m_intersector=ke(e,n,o),this.m_bSwapElements=!1):!i(l)&&i(g)?(this.m_intersector=ke(n,e,o),this.m_bSwapElements=!0):(this.m_intersector=Ae(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 C;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 Qe;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(C.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&&(i(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,s){let n;if(e instanceof oc||null===e){const r=C.constructEmpty();r.setCoords({pt:t}),r.mergeEnvelope2D(s),n=le(e,r,!1)}else n=e;return n}function Hr(e,t,s){let n;if(e instanceof oc||null===e){const r=C.constructEmpty();r.setCoords({env2D:t}),r.mergeEnvelope2D(s),n=le(e,r,!1)}else n=e;return n}function kr(e,r,i,o,a){if(e.isEmpty()||r.isEmpty())return 4===o;t(e),t(r);let h=e.getGeometryType(),m=r.getGeometryType();if(h===s.enumEnvelope){if(m===s.enumEnvelope)return Ar(e,r,i,o);if(m===s.enumPoint)return Mr(r,e,i,Vr(o))}else if(h===s.enumPoint){if(m===s.enumEnvelope)return Mr(e,r,i,o);if(m===s.enumPoint)return Ur(e,r,i,o)}const l=C.constructEmpty();e.queryEnvelope(l);const g=C.constructEmpty();r.queryEnvelope(g);const u=Hr(i,l,g);if(qr(l,g,u))return 4===o;let c=!1,_=null,d=null,p=null,f=null;switch(n(h)?(_=new I({vd:e.getDescription()}),_.addSegment(e,!0),p=_,h=s.enumPolyline):p=e,n(m)?(d=new I({vd:r.getDescription()}),d.addSegment(r,!0),f=d,m=s.enumPolyline):f=r,h!==s.enumEnvelope&&m!==s.enumEnvelope?(p.getDimension()<f.getDimension()||h===s.enumPoint&&m===s.enumMultiPoint)&&(o=Vr(o)):h!==s.enumPolygon&&m!==s.enumEnvelope&&(o=Vr(o)),h){case s.enumPolygon:switch(m){case s.enumPolygon:c=Yr(p,f,u,o,a);break;case s.enumPolyline:c=Rr(p,f,u,o,a);break;case s.enumPoint:c=Xr(p,f,u,o);break;case s.enumMultiPoint:c=Lr(p,f,u,o);break;case s.enumEnvelope:c=zr(p,f,u,o,a)}break;case s.enumPolyline:switch(m){case s.enumPolygon:c=Rr(f,p,u,o,a);break;case s.enumPolyline:c=Wr(p,f,u,o,a);break;case s.enumPoint:c=jr(p,f,u,o);break;case s.enumMultiPoint:c=Zr(p,f,u,o);break;case s.enumEnvelope:c=Kr(p,f,u,o,a)}break;case s.enumPoint:switch(m){case s.enumPolygon:c=Xr(f,p,u,o);break;case s.enumPolyline:c=jr(f,p,u,o);break;case s.enumMultiPoint:c=Jr(f,p,u,o)}break;case s.enumMultiPoint:switch(m){case s.enumPolygon:c=Lr(f,p,u,o);break;case s.enumPolyline:c=Zr(f,p,u,o);break;case s.enumMultiPoint:c=Qr(p,f,u,o);break;case s.enumPoint:c=Jr(p,f,u,o);break;case s.enumEnvelope:c=$r(p,f,u,o)}break;case s.enumEnvelope:switch(m){case s.enumPolygon:c=zr(f,p,u,o,a);break;case s.enumPolyline:c=Kr(f,p,u,o,a);break;case s.enumMultiPoint:c=$r(f,p,u,o)}}return c}function Ar(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=C.constructEmpty();e.queryEnvelope(i);const o=C.constructEmpty();t.queryEnvelope(o);const a=Hr(s,i,o);switch(n){case 4:return qr(i,o,a);case 2:return go(o,i,a,!1);case 128:return go(o,i,a,!0);case 1:return go(i,o,a,!1);case 64:return go(i,o,a,!0);case 3:return ho(i,o,a);case 8:return mo(i,o,a);case 32:return lo(i,o,a);case 16:return!1}return!1}function Mr(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=C.constructEmpty();t.queryEnvelope(o);const a=Fr(s,i,o);switch(n){case 4:return Or(i,o,a);case 2:case 128:return ao(i,o,a);case 1:case 64:return!1;case 3:return io(i,o,a);case 8:return oo(i,o,a)}return!1}function Ur(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=t.getXY();let a;if(s instanceof oc||null===s){const e=C.constructEmpty();e.setCoords({pt:i}),e.merge(o),a=le(s,e,!1)}else a=s;switch(n){case 4:return no(i,o,a);case 2:case 128:return ro(o,i,a);case 1:case 64:return ro(i,o,a);case 3:return so(i,o,a)}return!1}function qr(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!e.isIntersecting(n)}function Br(e,t,s,n=!1){const r=e.getGeometryType(),i=t.getGeometryType();if(_(r)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();o(null===e)}}if(_(i)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();o(null===t)}}return 0}function Or(e,t,s,n){const r=C.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(s,s),!r.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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!ho(r,i,s))return!1;if(Br(e,t),yo(e,t,s))return!0;const o=e.calculateLength2D(),a=t.calculateLength2D(),h=Math.max(e.getPointCount(),t.getPointCount());if(Math.abs(o-a)>4*h*s)return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"**F**FFF*",n,!1)}return So(e,t,s,!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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),Vo(e,t,s,n))}function ii(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),2===uo(e,t,s,!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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),ko(e,t,s,n))}function li(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),2===uo(e,t,s,!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,s,n){Br(e,t);const r=C.constructEmpty();e.queryEnvelope(r),r.inflateCoords(s,s);const i=new Qe;let o=!1;const a=e.getImpl(),h=new v;let m=e,l=!1;for(let g=0;g<t.getPointCount();g++){if(t.queryXY(g,i),r.contains(i)){const e=Lo(m,i,s);if(2===e)o=!0;else if(1===e)return!1}l||(!Wn(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?m=e:(e.copyTo(h),h.getImpl().buildQuadTreeAccelerator(1),m=h),l=!0)}return!!o}function pi(e,t,s,n){Br(e,t);const r=new C,i=new C,o=new C;e.queryEnvelope(r),t.queryEnvelope(o),i.setCoords({env2D:r}),i.inflateCoords(s,s);let a=!1,h=!1;const m=new Qe,l=e.getImpl(),g=new v;let u=e,c=!1;for(let _=0;_<t.getPointCount();_++){if(t.queryXY(_,m),i.contains(m)){const e=Lo(u,m,s);0===e?h=!0:1===e&&(a=!0)}else h=!0;if(a&&h)return!0;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!1}function fi(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);let a=!1;const h=new Qe,m=e.getImpl(),l=new v;let g=e,u=!1;for(let c=0;c<t.getPointCount();c++){if(t.queryXY(c,h),!i.contains(h))return!1;const r=Lo(g,h,s);if(1===r)a=!0;else if(0===r)return!1;if(n&&2===r)return!1;u||(!Wn(e,t.getPointCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?g=e:(e.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),g=l),u=!0)}return a}function xi(e,t,s,n){const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),!ho(r,i,s))return!1;const o=new v;return o.addEnvelope(t,!1),ei(e,o,s,n)}function yi(e,t,s,n){Br(e,t);const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;return 0===Lo(e,i.getLowerLeft(),0)&&(!i.contains(e.getXY(0))&&!To(e,i,s))}function Pi(e,t,s,n){Br(e,t);const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new v;return o.addEnvelope(t,!1),Go(e,o,s,n)}function Ei(e,t,s,n){Br(e,t);const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new v;return o.addEnvelope(t,!1),Do(e,o,s,n)}function Si(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),n?fo(o,i,s):po(o,i,s)}function Ci(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);const a=new v;return a.addEnvelope(t,!1),n?2===uo(e,a,s,!1):Vo(e,a,s,r)}function Ii(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!ho(r,i,s))return!1;if(Br(e,t),yo(e,t,s))return!0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"**F**FFF*",n,!1)}return So(e,t,s,!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,s,n){Br(e,t);const r=[],i=bo(e,t,s,r);if(-2===i){const r=C.constructEmpty(),i=C.constructEmpty(),o=C.constructEmpty();let a,h;if(e.queryEnvelope(r),t.queryEnvelope(i),r.inflateCoords(1e3*s,1e3*s),i.inflateCoords(1e3*s,1e3*s),o.setCoords({env2D:r}),o.intersect(i),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;if(t.getPointCount()>10){if(h=Zt(t,o,s,0,n),h.isEmpty())return!1}else h=t;return sr(a,h,s,"F********",n,!1)}if(0!==i)return!1;const o=new N;for(let m=0;m<r.length;m+=2){const e=r[m],t=r[m+1];o.addXY(e,t)}const a=e.getBoundary(),h=t.getBoundary();return a.addPoints(h,0,h.getPointCount()),!a.isEmpty()&&zi(a,o,s)}function vi(e,t,s,n){Br(e,t);const r=[],i=bo(e,t,s,r);if(-2===i){const r=C.constructEmpty(),i=C.constructEmpty(),o=C.constructEmpty();let a,h;if(e.queryEnvelope(r),t.queryEnvelope(i),r.inflateCoords(1e3*s,1e3*s),i.inflateCoords(1e3*s,1e3*s),o.setCoords({env2D:r}),o.intersect(i),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;if(t.getPointCount()>10){if(h=Zt(t,o,s,0,n),h.isEmpty())return!1}else h=t;return sr(a,h,s,"0********",n,!1)}if(0!==i)return!1;const o=new N;for(let m=0;m<r.length;m+=2){const e=r[m],t=r[m+1];o.addXY(e,t)}const a=e.getBoundary(),h=t.getBoundary();return a.addPoints(h,0,h.getPointCount()),!!a.isEmpty()||!zi(a,o,s)}function Ni(e,t,s,n){Br(e,t);const r=C.constructEmpty(),i=C.constructEmpty();e.queryEnvelope(r),t.queryEnvelope(i);const o=xo(r,i,s),a=xo(i,r,s),h=e.hasNonLinearSegments(),m=t.hasNonLinearSegments(),l=bo(e,t,s,null);if(-1===l)return!1;if(1===l){if(o&&a)return!0;if(!h&&!m)return o&&!a?!Co(t,e,s,!1):a&&!o?!Co(e,t,s,!1):!Co(e,t,s,!1)&&!Co(t,e,s,!1)}const g=C.constructEmpty(),u=C.constructEmpty(),c=C.constructEmpty();let _,d;g.setCoords({env2D:r}),g.inflateCoords(1e3*s,1e3*s),u.setCoords({env2D:i}),u.inflateCoords(1e3*s,1e3*s),c.setCoords({env2D:g}),c.intersect(u);let p="";if(p+="1*",o){if(t.getPointCount()>10){if(d=Zt(t,c,s,0,n),d.isEmpty())return!1}else d=t;p+="****"}else d=t,p+="T***";if(a){if(e.getPointCount()>10){if(_=Zt(e,c,s,0,n),_.isEmpty())return!1}else _=e;p+="***"}else _=e,p+="T**";return sr(_,d,s,p,n,!1)}function Ti(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!po(r,i,s))return!1;if(Br(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"******FF*",n,!1)}return Co(t,e,s,!1)}function Gi(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!po(r,i,s))return!1;Br(e,t);return sr(e,t,s,"T**FF*FF*",n,!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 N,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=Ke(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 N;for(let _=0;_<o;_++)a[_]&&c.addPoint2D(i.getXY(_));return!zi(u,c,s)}function Mi(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);const a=wo(e,t,s,!0);if(!a)return a;const h=e.getBoundary();return h.isEmpty()?a:!zi(h,t,s)}function Ui(e,t,s,n){const r=new C,i=new C;return e.queryEnvelope(r),t.queryEnvelope(i),!(i.height()>s&&i.width()>s)&&ho(r,i,s)}function qi(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();e.queryEnvelope(r),t.queryEnvelope(i);const o=Bo(i,r,s);return 0===o?!To(e,i,s):4===o}function Bi(e,t,n,i){const o=new C,a=new C;if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;const h=new C,m=new C;if(h.setCoords({env2D:a}),m.setCoords({env2D:a}),h.inflateCoords(n,n),m.inflateCoords(-n,-n),m.containsEnvelope(o)||!o.isIntersecting(h))return!1;const l=e.getImpl().querySegmentIterator();l.stripAttributes();const g=e.getImpl().getAccelerators();let u=null,c=null;null!==g&&(u=g.getQuadTree(),null!==u&&(c=u.getIterator(a,n))),c||l.nextPath()||r("relational_operations");let _=!1,d=null;const p=new Qe,f=new Qe,x=e.hasNonLinearSegments();let y=!1;for(;;){if(null!==c){const e=c.next();if(-1===e)break;l.resetToVertex(u.getElement(e),-1),d=l.nextSegment()}else{for(;!l.hasNextSegment()&&l.nextPath(););if(!l.hasNextSegment())break;d=l.nextSegment()}if(x&&d.getGeometryType()!==s.enumLine){const e=new C;if(d.queryEnvelope(e),m.containsEnvelope(e))return!1;if(h.isIntersecting(e)){y=!0;break}}else{p.assign(d.getStartXY()),f.assign(d.getEndXY());let e=m.clipLine(p,f);if(0!==e)return!1;_||(e=h.clipLine(p,f),0!==e&&(_=!0))}}if(!y)return _;const P=new v;return P.addEnvelope(a,!1),ai(P,e,n,i)}function Oi(e,t,n,i,o){const a=C.constructEmpty(),h=C.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(h),h.height()<=n||h.width()<=n)return!1;if(i)return fo(h,a,n);if(!po(h,a,n))return!1;const m=C.constructEmpty();m.setCoords({env2D:h}),m.inflateCoords(-n,-n);const l=C.constructEmpty();if(l.setCoords({env2D:h}),l.inflateCoords(n,n),m.containsEnvelope(a))return!0;const g=e.getImpl().querySegmentIterator();g.stripAttributes(),g.nextPath()||r("relational_operations");let u,c,_,d,p,f,x=!1;const y=e.hasNonLinearSegments();for(y&&(_=new H,d=new H,p=new H,f=new H,m.querySide(0,_),m.querySide(1,d),m.querySide(2,p),m.querySide(3,f));;){for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;const e=g.nextSegment();if(y&&e.getGeometryType()!==s.enumLine){if(e.isIntersecting(_,n)){x=!0;break}if(e.isIntersecting(d,n)){x=!0;break}if(e.isIntersecting(p,n)){x=!0;break}if(e.isIntersecting(f,n)){x=!0;break}}else{u=e.getStartXY(),c=e.getEndXY();if(0!==m.clipLine(u,c)){x=!0;break}}}return x}function Yi(e,t,n,r){const i=new C,a=new C;if(e.queryEnvelope(i),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;const h=new C;if(h.setCoords({env2D:a}),h.inflateCoords(n,n),h.containsEnvelope(i))return!1;const m=!0,l=new C;if(l.setCoords({env2D:a}),l.inflateCoords(-n,-n),!l.isIntersecting(i))return!1;const g=e.getImpl().querySegmentIterator();g.stripAttributes();const u=e.getImpl().getAccelerators();let c=null,_=null;if(null!==u&&(c=u.getQuadTree(),null!==c&&(_=c.getIterator(a,n))),!_){const e=g.nextPath();o(e)}let d=!1,p=null;const f=new Qe,x=new Qe;let y=null,P=null,E=null,S=null;for(e.hasNonLinearSegments()&&(y=new H,P=new H,E=new H,S=new H,l.querySide(0,y),l.querySide(1,P),l.querySide(2,E),l.querySide(3,S));;){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(p.getGeometryType()===s.enumLine){f.assign(p.getStartXY()),x.assign(p.getEndXY());if(0!==l.clipLine(f,x)){d=!0;break}}else{if(y.isIntersecting(p,n)){d=!0;break}if(P.isIntersecting(p,n)){d=!0;break}if(E.isIntersecting(p,n)){d=!0;break}if(S.isIntersecting(p,n)){d=!0;break}}}return d&&m}function Ri(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!ho(r,i,s)&&(!!Po(e,t,s)||Eo(e,t,s,!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 Qe,m=new Qe;for(;o.next();){const e=o.getRedElement(),t=o.getBlueElement();if(r.queryXY(e,h),i.queryXY(t,m),Qe.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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&Eo(t,e,s,!0,!1,!1)}function Wi(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),ho(r,i,s)}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,s,n){const r=new C,i=new C;return e.queryEnvelope(r),t.queryEnvelope(i),!(i.height()>s||i.width()>s)&&ho(r,i,s)}function Ji(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;const o=C.constructEmpty();o.setCoords({env2D:i}),o.inflateCoords(s,s);const a=new Qe;for(let h=0;h<e.getPointCount();h++)if(e.queryXY(h,a),o.contains(a))return!1;return!0}function $i(e,t,s,n){const r=new C,i=new C,o=new C;if(t.queryEnvelope(r),r.height()<=s||r.width()<=s)return!1;i.setCoords({env2D:r}),o.setCoords({env2D:r}),i.inflateCoords(s,s),o.inflateCoords(-s,-s);const a=new Qe;let h=!1;for(let m=0;m<e.getPointCount();m++)if(e.queryXY(m,a),i.contains(a)){if(o.containsExclusive(a))return!1;h=!0}return h}function eo(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),o.height()<=s||o.width()<=s)return!1;if(n)return fo(o,i,s);if(!po(o,i,s))return!1;let a=!1;const h=C.constructEmpty(),m=C.constructEmpty();h.setCoords({env2D:o}),m.setCoords({env2D:o}),h.inflateCoords(-s,-s),m.inflateCoords(s,s);const l=new Qe;for(let g=0;g<e.getPointCount();g++){if(e.queryXY(g,l),!m.contains(l))return!1;h.containsExclusive(l)&&(a=!0)}return a}function to(e,t,s,n){const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new C,a=new C;o.setCoords({env2D:i}),o.inflateCoords(-s,-s),a.setCoords({env2D:i}),a.inflateCoords(s,s);const h=new Qe;let m=!1,l=!1;for(let g=0;g<e.getPointCount();g++)if(e.queryXY(g,h),!m&&o.containsExclusive(h)&&(m=!0),l||a.contains(h)||(l=!0),m&&l)return!0;return!1}function so(e,t,s,n){return Qe.sqrDistance(e,t)<=s*s}function no(e,t,s,n){return Qe.sqrDistance(e,t)>s*s}function ro(e,t,s,n){return so(e,t,s)}function io(e,t,s,n){const r=new C;return r.setCoords({pt:e}),ho(r,t,s)}function oo(e,t,s,n){if(t.height()<=s||t.width()<=s)return!1;const r=new C,i=new C;return r.setCoords({env2D:t}),r.inflateCoords(s,s),!!r.contains(e)&&(i.setCoords({env2D:t}),i.inflateCoords(-s,-s),!i.containsExclusive(e))}function ao(e,t,s,n){if(t.height()<=s||t.width()<=s)return!1;const r=C.constructEmpty();r.setCoords({env2D:t}),r.inflateCoords(-s,-s);return r.containsExclusive(e)}function ho(e,t,s,n){return po(e,t,s)&&po(t,e,s)}function mo(e,t,s,n){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;const r=new C;return r.setCoords({env2D:e}),r.inflateCoords(-s,-s),r.intersect(t),!(!r.isEmpty()&&r.height()>s&&r.width()>s)&&(r.setCoords({env2D:e}),r.inflateCoords(s,s),r.intersect(t),!r.isEmpty())}function lo(e,t,s,n){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;if(po(e,t,s))return!1;if(po(t,e,s))return!1;const r=new C;return r.setCoords({env2D:e}),r.inflateCoords(-s,-s),r.intersect(t),!r.isEmpty()&&(r.height()>s||r.width()>s)}function go(e,t,s,n,r){if(e.height()<=s||e.width()<=s)return!1;if(n)return fo(e,t,s);if(!po(e,t,s))return!1;const i=C.constructEmpty();return i.setCoords({env2D:e}),i.inflateCoords(-s,-s),i.intersect(t),!i.isEmpty()}function uo(e,t,n,r,i){const o=new Qe,a=new Qe,h=C.constructEmpty(),m=C.constructEmpty(),l=e.getImpl(),g=t.getImpl(),u=g.getGeometryType(),c=new Dr(l,g,n,!0);if(!c.next())return 1;if(Io(e,t,n))return r?4:0;const _=new v;let d=e;const p=new v;let f=null;u===s.enumPolygon&&(f=t);const x=u===s.enumPolygon?Ke(l.getPathCount(),!1):[],y=Ke(g.getPathCount(),!1);let P=!1,E=!1,S=!1,I=!1,b=!1,w=!1;do{if(S&&b||I&&w)break;if(S&&I)break;const i=c.getRedElement(),C=c.getBlueElement();if(!y[C]&&(a.assign(t.getXY(t.getPathStart(C))),h.setCoords({env2D:c.getRedEnvelope()}),h.inflateCoords(n,n),h.contains(a))){if(0!==Lo(d,a,0)){if(I=!0,r)return 4}else w=!0;y[C]=!0}if(u===s.enumPolygon&&!x[i]&&(o.assign(e.getXY(e.getPathStart(i))),m.setCoords({env2D:c.getBlueEnvelope()}),m.inflateCoords(n,n),m.contains(o))){if(0!==Lo(f,o,0)){if(S=!0,r)return 4}else b=!0;x[i]=!0}if(P||(!Wn(e,t.getPathCount()-1)||null!==l.getAccelerators()&&null!==l.getAccelerators().getQuadTree()?d=e:(e.copyTo(_),_.getImpl().buildQuadTreeAccelerator(1),d=_),P=!0),u===s.enumPolygon&&!E){const s=t;!Wn(s,e.getPathCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?f=t:(s.copyTo(p),p.getImpl().buildQuadTreeAccelerator(1),f=p),E=!0}}while(c.next());if(!S&&!I)return 1;if(!b||!w){if(u===s.enumPolygon)for(let e=0,t=l.getPathCount();e<t;e++)if(!x[e]){b=!0;break}for(let e=0,t=g.getPathCount();e<t;e++)if(!y[e]){w=!0;break}}return S&&b||I&&w||S&&I?4:I?2:3}function co(e,t,s,n,r){const i=C.constructEmpty();e.queryEnvelope(i),i.inflateCoords(s,s);const o=new Qe,a=e.getImpl(),h=new v;let m=e,l=!1,g=!1,u=!1;for(let c=0;c<t.getPointCount();c++){if(t.queryXY(c,o),i.contains(o)){const e=Lo(m,o,s);if(1===e)return g=!0,4;if(2===e)return 4;u=!0}else u=!0;l||(!Wn(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!=a.getAccelerators().getQuadTree()?m=e:(e.copyTo(h),h.getImpl().buildQuadTreeAccelerator(1),m=h),l=!0)}return g?u?4:2:1}function _o(e,t,n,r,i){r[0]=!1;const a=e.getImpl(),h=t.getImpl(),m=a.querySegmentIterator(),l=h.querySegmentIterator(),g=[0,0],u=[0,0],c=new Dr(a,h,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(),i=l.nextSegment();let o=0;if(Oo(s,i)?!_&&i.isIntersecting(s,n)&&(_=!0):o=i.intersect(s,null,u,g,n),0!==o&&(_=!0,1===o)){const e=g[0],t=u[0];if(e>0&&e<1&&t>0&&t<1)return r[0]=!0,!1}}if(!_){r[0]=!0;const i=C.constructEmpty();e.queryEnvelope(i),i.inflateCoords(n,n);const m=new v;let l=e,g=!1;for(let s=0,n=t.getPathCount();s<n;s++)if(t.getPathSize(s)>0){const n=C.constructEmpty();if(t.queryPathEnvelope(s,n),!i.isIntersecting(n))return!1;{const e=zn(l,t.getXY(t.getPathStart(s)),0);if(o(-1!==e),0===e)return!1}g||(!Wn(e,t.getPathCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}if(1===e.getPathCount()||t.getGeometryType()===s.enumPolyline)return!0;const u=t,c=C.constructEmpty();u.queryEnvelope(c),c.inflateCoords(n,n);const _=new v;let d=u,p=!1;for(let t=0,s=e.getPathCount();t<s;t++)if(e.getPathSize(t)>0){const s=C.constructEmpty();if(e.queryPathEnvelope(t,s),c.isIntersecting(s)){const s=zn(d,e.getXY(e.getPathStart(t)),0);if(o(-1!==s),1===s)return!1}p||(!Wn(u,e.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?d=u:(u.copyTo(_),_.getImpl().buildQuadTreeAccelerator(1),d=_),p=!0)}return!0}return!1}function po(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)}function fo(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),e.containsExclusiveEnvelope(n)}function xo(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!n.contains(e.getLowerLeft())||(!n.contains(e.getLowerRight())||(!n.contains(e.getUpperLeft())||!n.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 Qe,i=new Qe;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),Qe.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 Qe,i=new Qe;let o=!0;const a=s*s;for(let h=0;h<e.getPointCount();h++)if(e.queryXY(h,r),t.queryXY(h,i),Qe.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=Ke(m,!1),u=r||i?Ke(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);Qe.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,s,n){if(x(e),x(t),t.isEmpty())return!1;let i=!0;const o=Ke(2,Number.NaN),a=Ke(2,Number.NaN),h=[],m=new Ro;let l;const g=C.constructEmpty(),u=C.constructEmpty(),c=C.constructEmpty();e.queryEnvelope(g),t.queryEnvelope(u),g.inflateCoords(s,s),u.inflateCoords(s,s),c.setCoords({env2D:g}),c.intersect(u);const _=e.getImpl().querySegmentIterator(),d=t.getImpl().querySegmentIterator(),p=t.getImpl().getAccelerators();let f=null,y=null,P=null,E=null;if(null!==p&&(f=p.getQuadTree(),y=p.getQuadTreeForPaths(),null!==y&&(E=y.getIteratorForQT())),null===f){const s=e.getPointCount(),n=t.getPointCount();s>10&&n>10&&(f=Ve(t.getImpl(),c))}for(null!==f&&(P=f.getIteratorForQT());_.nextPath();)for(;_.hasNextSegment();){let e=_.nextSegment();if(e.queryEnvelope(g),!g.isIntersecting(c))return i=!1,!1;if(null!==E&&(E.resetIterator(g,s),-1===E.next()))continue;let t=0,p=null;if(null!=P)P.resetIterator(e,s);else if(d.resetToFirstPath(),!d.nextPath())return i=!1,!1;do{if(t=0,null!==P){const n=P.next();if(-1===n)return i=!1,!1;d.resetToVertex(f.getElement(n),-1),p=d.nextSegment(),t=e.intersect(p,null,o,a,s)}else{for(;!d.hasNextSegment();)if(!d.nextPath())return i=!1,!1;p=d.nextSegment(),p.queryEnvelope(u),u.inflateCoords(s,s),g.isIntersecting(u)&&(t=e.intersect(p,null,o,a,s))}}while(2!==t||0!==o[0]||n&&!(a[0]<=a[1]));let x=Number.NaN,y=!1;do{let n=!1;if(1===o[1]){if(!_.hasNextSegment()){y=!0;break}e=_.nextSegment(),n=!0}if(1===a[1]&&a[0]<=a[1]){if(-1===x)break;if(x=1,!d.hasNextSegment())break;p=d.nextSegment(),n=!0}if(0===a[1]&&a[0]>a[1]){if(1===x)break;if(Number.isNaN(x)){if(!d.hasPreviousSegment())break;d.previousSegment(),x=-1}if(!d.hasPreviousSegment())break;p=d.previousSegment(),n=!0}if(!n)break;t=e.intersect(p,null,o,a,s)}while(2===t&&(!n||a[0]<=a[1]));if(y)continue;const S=e.calculateLength2D();e.queryEnvelope(g),h.length=0,m.m_overlapEvents.length=0;let C=!1,I=!1,b=0;const w=le(null,g,!0);for(null!==P?P.resetIterator(e,s):(d.resetToFirstPath(),d.nextPath()||r("relational_operations"));;){if(t=0,null!==P){const n=P.next();if(-1===n)break;d.resetToVertex(f.getElement(n),-1),p=d.nextSegment(),t=e.intersect(p,null,o,a,s)}else{for(;!d.hasNextSegment()&&d.nextPath(););if(!d.hasNextSegment())break;p=d.nextSegment(),p.queryEnvelope(u),u.inflateCoords(s,s),g.isIntersecting(u)&&(t=e.intersect(p,null,o,a,s))}if(2===t&&(!n||a[0]<=a[1])){const e=_.getStartPointIndex(),t=_.getPathIndex(),n=d.getStartPointIndex(),r=d.getPathIndex();if(l=Yo(e,t,o[0],o[1],n,r,a[0],a[1]),m.m_overlapEvents.push(l),h.push(h.length),!(C||l.m_scalarA0<b&&l.m_scalarA1<b))if(0===b&&S*(l.m_scalarA0-b)>s)C=!0;else if(0!==b&&S*(l.m_scalarA0-b)>w)C=!0;else if(b=l.m_scalarA1,S*(1-b)<=s||1===b){I=!0;break}}}if(!I){if(!C)return i=!1,!1;h.length>1&&h.sort((e,t)=>m.compareOverlapEvents(e,t)),b=0;for(let e=0;e<m.m_overlapEvents.length;e++)if(l=m.m_overlapEvents[h[e]],!(l.m_scalarA0<b&&l.m_scalarA1<b)){if(0===b&&S*(l.m_scalarA0-b)>s)return i=!1,!1;if(0!==b&&S*(l.m_scalarA0-b)>w)return i=!1,!1;if(b=l.m_scalarA1,S*(1-b)<=s||1===b)break}if(S*(1-b)>s)return i=!1,!1;h.length=0,m.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=Ke(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 Qe;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?Ke(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,s){const n=new Qe,r=s*s,i=e.querySegmentIterator(),o=e.getImpl().getAccelerators();if(null!==o){const e=o.getQuadTree();if(null!==e){const o=C.constructEmpty();o.setCoords({pt:t});const a=e.getIterator(o,s);for(let s=a.next();-1!==s;s=a.next())if(i.resetToVertex(e.getElement(s),-1),i.hasNextSegment()){const e=i.nextSegment(),s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,n),Qe.sqrDistance(t,n)<=r)return!0}return!1}}const a=C.constructEmpty();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(e.queryEnvelope(a),a.inflateCoords(s,s),!a.contains(t))continue;const o=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(o,n),Qe.sqrDistance(t,n)<=r)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 i=e.querySegmentIterator(),o=e.getImpl().getAccelerators(),a=e.hasNonLinearSegments();let h=null,m=null,l=null,g=null;if(null!==o){const e=o.getQuadTree();if(null!==e){const r=e.getIterator(t,n);a&&(h=new H,m=new H,l=new H,g=new H,t.querySide(0,h),t.querySide(1,m),t.querySide(2,l),t.querySide(3,g));const o=C.constructEmpty();o.setCoords({env2D:t}),o.inflateCoords(n,n);for(let a=r.next();-1!==a;a=r.next())if(i.resetToVertex(e.getElement(a),-1),i.hasNextSegment()){const e=i.nextSegment();if(e.getGeometryType()===s.enumLine){const t=e.getStartXY(),s=e.getEndXY();if(o.clipLine(t,s))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(h,n))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0}return!1}}if(a){h=new H,m=new H,l=new H,g=new H,t.querySide(0,h),t.querySide(1,m),t.querySide(2,l),t.querySide(3,g);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(h,n))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0}}else{const s=C.constructEmpty();s.setCoords({env2D:t}),s.inflateCoords(n,n);const r=e.getImpl(),i=r.getAttributeStreamRef(0),o=new Qe;for(let e=0,t=r.getPathCount();e<t;e++){let t=!0;const n=new Qe,a=new Qe,h=new Qe,m=r.getPathStart(e),l=new Qe;for(let g=m,u=r.getPathEnd(e);g<u;g++)if(t)i.queryPoint2D(2*g,n),l.assign(n),t=!1;else{if(i.queryPoint2D(2*g,o),a.setCoordsPoint2D(n),h.setCoordsPoint2D(o),s.clipLine(a,h))return!0;n.assign(o)}if(r.isClosedPath(e)&&!t&&(a.setCoordsPoint2D(n),h.setCoordsPoint2D(l),s.clipLine(a,h)))return!0}}return!1}function Go(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=[0],a=Te(r.getIsSimple(0,o))&&Te(i.getIsSimple(0,o)),h=r.querySegmentIterator(),m=i.querySegmentIterator(),l=Ke(2,0),g=Ke(2,0),u=new Dr(r,i,s);let c=!1;for(;u.next();){const e=u.getRedElement(),t=u.getBlueElement();h.resetToVertex(e,-1),m.resetToVertex(t,-1);const n=h.nextSegment(),r=m.nextSegment();let i=0;if(Oo(n,r)){if(r.isIntersecting(n,s)){c=!0;break}}else i=r.intersect(n,null,g,l,s);if(2===i){const e=l[0],t=l[1],r=n.calculateLength2D();if(a&&(t-e)*r>s)return!1;c=!0}else if(i){const e=l[0],t=g[0];if(e>0&&e<1&&t>0&&t<1)return!1;c=!0}}if(!c)return!1;const _=C.constructEmpty(),d=C.constructEmpty(),p=C.constructEmpty();let f,x;if(e.queryEnvelope(_),t.queryEnvelope(d),_.inflateCoords(1e3*s,1e3*s),d.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:_}),p.intersect(d),e.getPointCount()>10){if(f=Zt(e,p,s,0,n),f.isEmpty())return!1}else f=e;if(t.getPointCount()>10){if(x=Zt(t,p,s,0,n),x.isEmpty())return!1}else x=t;return sr(f,x,s,"F********",n,!1)}function Do(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=[0],a=Te(r.getIsSimple(0,o))&&Te(i.getIsSimple(0,o)),h=C.constructEmpty(),m=C.constructEmpty(),l=C.constructEmpty();e.queryEnvelope(h),t.queryEnvelope(m);let g=!1;const u=xo(h,m,s),c=xo(m,h,s),_=r.querySegmentIterator(),d=i.querySegmentIterator(),p=Ke(2,Number.NaN),f=Ke(2,Number.NaN),x=new Dr(r,i,s);for(;x.next();){const e=x.getRedElement(),t=x.getBlueElement();_.resetToVertex(e,-1),d.resetToVertex(t,-1);const n=_.nextSegment(),r=d.nextSegment();let i=0;if(Oo(n,r)){if(r.isIntersecting(n,s))break}else i=r.intersect(n,null,f,p,s);if(2===i){const e=p[0],t=p[1],r=n.calculateLength2D();if(a&&(t-e)*r>s&&(g=!0,u&&c))return!0}else if(i){const e=p[0],t=f[0];if(e>0&&e<1&&t>0&&t<1)return!0}}const y=C.constructEmpty(),P=C.constructEmpty();let E,S;y.setCoords({env2D:h}),y.inflateCoords(1e3*s,1e3*s),P.setCoords({env2D:m}),P.inflateCoords(1e3*s,1e3*s),l.setCoords({env2D:y}),l.intersect(P);let I="";if(I+=g?"**":"T*",u){if(t.getPointCount()>10){if(S=Zt(t,l,s,0,n),S.isEmpty())return!1}else S=t;I+="****"}else S=t,I+="T***";if(c){if(e.getPointCount()>10){if(E=Zt(e,l,s,0,n),E.isEmpty())return!1}else E=e;I+="***"}else E=e,I+="T**";return sr(E,S,s,I,n,!1)}function Vo(e,t,s,n){const r=[!1],i=_o(e,t,s,r);if(r[0])return i;const o=C.constructEmpty();let a;if(t.queryEnvelope(o),o.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;return nr(a,t,s,n)}function Fo(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),h=Ke(2,Number.NaN),m=Ke(2,Number.NaN),l=new Dr(r,i,s);let g=!1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const n=o.nextSegment(),r=a.nextSegment();let i=0;if(Oo(n,r)?!g&&r.isIntersecting(n,s)&&(g=!0):i=r.intersect(n,null,m,h,s),2===i)g=!0;else if(i){const e=h[0],t=m[0];if(e>0&&e<1&&t>0&&t<1)return!1;g=!0}}if(!g)return!1;const u=C.constructEmpty(),c=C.constructEmpty(),_=C.constructEmpty();let d,p;if(e.queryEnvelope(u),t.queryEnvelope(c),u.inflateCoords(1e3*s,1e3*s),c.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:u}),_.intersect(c),e.getPointCount()>10){if(d=Zt(e,_,s,0,n),d.isEmpty())return!1}else d=e;if(t.getPointCount()>10){if(p=Zt(t,_,s,0,n),p.isEmpty())return!1}else p=t;return sr(d,p,s,"F********",n,!1)}function Ho(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),h=Ke(2,Number.NaN),m=Ke(2,Number.NaN),l=new Dr(r,i,s);let g=!1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const n=o.nextSegment(),r=a.nextSegment();let i=0;if(Oo(n,r)?!g&&r.isIntersecting(n,s)&&(g=!0):i=r.intersect(n,null,m,h,s),2===i)g=!0;else if(i){const e=h[0],t=m[0];if(e>0&&e<1&&t>0&&t<1)return!0;g=!0}}if(!g)return!1;const u=C.constructEmpty(),c=C.constructEmpty(),_=C.constructEmpty(),d=C.constructEmpty(),p=C.constructEmpty();if(e.queryEnvelope(u),t.queryEnvelope(c),xo(c,u,s)){let r,i;if(_.setCoords({env2D:u}),_.inflateCoords(1e3*s,1e3*s),d.setCoords({env2D:c}),d.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:_}),p.intersect(d),e.getPointCount()>10){if(r=Zt(e,p,s,0,n),r.isEmpty())return!1}else r=e;if(t.getPointCount()>10){if(i=Zt(t,p,s,0,n),i.isEmpty())return!1}else i=t;return sr(r,i,s,"T********",n,!1)}return sr(e,t,s,"T*****T**",n,!1)}function ko(e,t,s,n){const r=[!1],i=_o(e,t,s,r);if(r[0])return i;const o=C.constructEmpty();let a;if(t.queryEnvelope(o),o.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;return rr(a,t,s,n)}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 Qe,i=s*s;for(let o=0;o<e.getPointCount();o++)if(e.queryXY(o,r),Qe.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,s){const n=C.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)?1073741824:n.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()!==s.enumLine||t.getGeometryType()!==s.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,i){if(e.getGeometryType()===s.enumPolygon)zo(e,t,n,r,i);else if(e.getGeometryType()===s.enumEnvelope){const s=C.constructEmpty();e.queryEnvelope(s),Zo(s,t,n,r,i)}else u("")}function jo(e,t,r,i,o){const a=e.getGeometryType();a===s.enumPolyline?$o(e,t,r,i,o):n(a)?Jo():u("")}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 s.enumMultiPoint:return e.getImpl().getPointCount();case s.enumPolyline:return e.getImpl().getPathCount();case s.enumPolygon:return e.getImpl().getOGCPolygonCount();case s.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 Qe;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){o(0)}function $o(e,t,s,n,r){const i=e.getImpl(),a=i.getAccelerators();let h=null;a&&(h=a.getRasterizedGeometry());let m=s;for(let l=0;l<s;l++)r[l]=1,h&&o(0);if(m){if(a){let e=null;null!==a&&null!==a.getQuadTree()&&(e=a.getQuadTree());const o=i.getPointCount();if(null===e&&o>20&&o*s>4*o+Math.log(o)*s&&(e=Ve(i)),e){let o=null;const a=i.querySegmentIterator(),h=new C;for(let i=0;i<s&&m;i++)if(1===r[i]){h.setCoords(t[i]),null===o?o=e.getIterator(h,n):o.resetIterator(h,n);let s=-1;for(let h=o.next();-1!==h;h=o.next()){a.resetToVertex(e.getElement(h),s),s=a.getPathIndex();if(a.nextSegment().isIntersectingPoint(t[i],n)){r[i]=2,m--;break}r[i]=0}}return}}const e=i.querySegmentIterator();for(;e.nextPath()&&m;)for(;e.hasNextSegment()&&m;){const i=e.nextSegment();for(let e=0;e<s&&m;e++)1===r[e]&&i.isIntersectingPoint(t[e],n)&&(r[e]=2,m--)}}for(let o=0;o<s;o++)1===r[o]&&(r[o]=0)}function ea(e,t,s,n,r){const i=K(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 Qe,ptEnd:new Qe,center:new J,radius:new At,fcenter:new se,fradius2:new Vt,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=Vt.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 se).assignPoint2D(i.ptStart),h=(new se).assignPoint2D(i.ptEnd).sub(a),m=(new se).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=J.constructPoint2D(i.ptStart).subE(i.center),x=J.constructPoint2D(i.ptEnd).subE(i.center);if(!f.dotProduct(x).gt(Ft))return!1;const y=this.maxCircleApproximationError(e,t,i);return i.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===s.enumEllipticArc){const s=e,n=ne(s,t.vmin),r=ne(s,t.vmax);return!(Math.abs(r-n)>.5*Ct)}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,n){const r=[.25,.75],i=[.1,.25,.75,.9];let o,a;e.getGeometryType()===s.enumEllipticArc?(o=r,a=r.length):(o=i,a=i.length);let h=0;for(let s=0;s<a;++s){const r=new Qe;e.queryCoord2D(ft(t.vmin,t.vmax,o[s]),r);const i=r.sub(n.center.value()).length(),a=Math.abs(i-n.radius.value());a>h&&(h=a)}return h}approximateWithCirclesImpl(e,t){let s=1;t&&t.push(0);const n=Ke(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 Qe(0,0);for(let h=1;h<r;h++){const e=new at(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 at;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,wt(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),i.length=0}return s}approximateWithCirclesImplPolyline(e){const t=new I,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 Qe;this.m_left.queryCoord2D(s[i],e);const o=new Qe;this.m_left.queryCoord2D(.5*(s[i]+n),o);const a=new R;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,n,r){if(!i(e.getGeometryType()))return e;const o=e.getImpl();if(!o.hasNonLinearSegments())return e;const a=e.createInstance();if(a.getGeometryType()===s.enumPolygon){a.setFillRule(e.getFillRule())}new G;const h=new fe,m=new F,l=[],g=[],u=[],c=e.getDescription().getAttributeCount()>1,_=o.querySegmentIterator();for(;_.nextPath();){let e=!0;for(;_.hasNextSegment();){const r=_.isClosingSegment(),i=_.nextSegment();if(!i.isCurve()){a.addSegment(i,e,r),e=!1;continue}let o,d=!1;const p=!0,f=!0;switch(i.getGeometryType()){case s.enumEllipticArc:case s.enumRationalBezier2:o=A(i,t,n,p,f,g,u,l),d=!0;break;default:o=k(i,t,n,!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&&(i.queryCoord(l[0],h),m.get().setStart(h)),c&&(i.queryCoord(l[1],h),m.get().setEnd(h)),a.addSegment(m.get(),e,r&&1===o),e=!1;for(let e=1,t=o,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&&(i.queryCoord(l[e+1],h),m.get().setEnd(h)),a.addSegment(m.get(),!1,r&&e+1===t)}}return a}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!==M;s=t.next())if(!e.getSegmentParentageBreakVertex(s)){e.getPathFromVertex(s);const t=e.getPrevVertex(s),n=t!==M?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 Ce(0),s=e.queryVertexIteratorOnSelection();for(let o=s.next();o!==M;o=s.next())t.add(o);if(0===t.size())return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(M);const n=Qe.getNAN();e.queryXY(t.read(0),n);let r=0;const i=Qe.getNAN();for(let o=1,a=t.size();o<a;o++){{const s=t.read(o);s!==M?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!==M?s.assign(e.getXY(r)):s.setNAN(),i!==M?n.assign(e.getXY(i)):n.setNAN()},i=new Qe,a=new Qe;n(t.read(r),i,a);for(let e=r+1;e<o;++e){const r=t.read(e);if(r===M)continue;const o=new Qe,h=new Qe;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:de(null,t,!0).total();return s>e&&(s=e),.125*s}function _a(e,t){return t||(t=C.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,n,r){const i=!1,a=!0;if(!e.hasCurves())return;o(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=n;const h=new fe,m=new F,l=[],g=[],u=[];for(let c=e.getFirstGeometry();c!==M;c=e.getNextGeometry(c))for(let r=e.getFirstPath(c);r!==M;r=e.getNextPath(r)){let c=e.getPathSize(r),_=e.getFirstVertex(r),d=0,p=-1;for(let f=0;f<c;f++){let x=e.getNextVertex(_);if(!e.querySegment(_,m,!0,!1)){_=x;continue}if(0===d){p=e.getVertexIndex(_);const t=xa.regularizeCurve(e,m.get(),_,n);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(r),x=e.getNextVertex(_);const s=e.querySegment(_,m,!0,!1);o(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(m.get().getGeometryType()){case s.enumEllipticArc:case s.enumRationalBezier2:P=A(m.get(),t,n,i,a,g,u,l),E=!0;break;default:{const e=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();P=k(m.get(),t,n,e,i,g,l)}}const S=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(_,S,!0),!g[1].isNAN()){let t=null;t=E?new O({points:g,weights:u}):new B({cp:g}),t.snapControlPoints(n*n),e.setSegmentToIndex(y,t)}const C=E?2:3;for(let t=1,s=P,i=C;t<s;++t,i+=C){m.get().queryCoord(l[t],h);const s=e.insertVertex(r,x,h);if(-1!==this.m_originalVertexIndex&&e.setUserIndex(s,this.m_originalVertexIndex,p),!g[i+1].isNAN())if(E){const t=new O({points:g.slice(i),weights:u.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(s),t)}else{const t=new B({cp:g.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(s),t)}e.setSegmentParentageAndBreak(s,S,!1)}P>1&&(f+=P-1,c=e.getPathSize(r)),this.m_originalPlanarSegments.push(m.releaseSegment()),_=x}}}buildLinearSegmentParentage(e,t,s,n,r){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=n,!e.hasCurves())return;o(!e.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());const i=new fe,a=new F,h=new Y(0,t,0,this.m_progressTracker,!1,n),m=[];for(let l=e.getFirstGeometry();l!==M;l=e.getNextGeometry(l))for(let t=e.getFirstPath(l);t!==M;t=e.getNextPath(t)){let n=e.getPathSize(t),r=e.getFirstVertex(t);for(let l=0;l<n;l++){let l=e.getNextVertex(r);if(!e.querySegment(r,a,!0,!1)){r=l;continue}if(xa.regularizeCurve(e,a.get(),r,s)>=0){n=e.getPathSize(t),l=e.getNextVertex(r);const s=e.querySegment(r,a,!0,!1);o(s)}const g=e.getVertexIndex(r);-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,g),e.setSegmentToIndex(g,null),m.length=0,h.densifySegment(a.get(),m),this.progress_();const u=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(r,u,!0);for(let s=1,n=m.length-1;s<n;++s){a.get().queryCoord(m[s],i);const n=e.insertVertex(t,l,i);e.setSegmentParentageAndBreak(n,u,!1),-1!==this.m_originalVertexIndex&&e.setUserIndex(n,this.m_originalVertexIndex,g)}this.m_originalPlanarSegments.push(a.releaseSegment()),r=l}}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,M,0,!0)}getOriginalVertexIndex(e,t){return-1!==this.m_originalVertexIndex&&t!==M?e.getUserIndex(t,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(e){if(-1!==e){const t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case s.enumEllipticArc:return 0===t.projectionBehavior()?0:1;case s.enumBezier:return 2;case s.enumBezier2:return 3;case s.enumLine:return-1;case s.enumRationalBezier2:return 4;default:g("")}}return-1}progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,s,n,r,i,a){if(t===s&&0===n)return o(e.getNextVertex(t)===M),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const h=e.getNextVertex(t),m=e.getXY(t),l=e.getXY(s);let g,u=0;{let t=2,r=m;for(let n=h;n!==s;n=e.getNextVertex(n)){const s=e.getXY(n);u+=Qe.distance(s,r),r=s,t++}u+=Qe.distance(l,r),o(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(h,s);const c=a;let _=r.getClosestCoordinate(m,!1),d=r.getClosestCoordinate(l,!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=Qe.distance(r.getStartXY(),r.getEndXY());e<=c&&p>5*e&&(S=!0)}if(S){let i,a,h=new Qe;if(2===n)h=Qe.lerp(m,l,.5),i=r.getClosestCoordinate(h,!1),a=r.tToLength(i);else{let s=e.getNextNthVertex(t,(n-1)/2);h=e.getXY(s),i=r.getClosestCoordinate(h,!1),a=r.tToLength(i);let o=Math.abs(a)>10*c&&Math.abs(a-p)>10*c;if(!o&&(n-1>=4&&(s=e.getNextNthVertex(t,(n-1)/4),i=r.getClosestCoordinate(h,!1),a=r.tToLength(i),o=Math.abs(a)>10*c&&Math.abs(a-p)>10*c),!o))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=m,h=e.getXY(e.getNextNthVertex(t,i)),l=e.getXY(e.getNextNthVertex(t,o));u=-Qe.orientationNonRobust(a,h,l)*it(r.calculateArea2DHelper())>0}else P?y?u=a>f:a<x?(f=0,_=0):(f=p,_=1):a>f?(x=p,d=1):(x=0,d=0);if(S)g=r.clone(),g.dropAllAttributes(),u||g.reverse(),o(m.equals(l));else{let e=!1;_>d&&(e=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.getDescription().getAttributeCount(),e&&g.reverse()}g.setCoordsForIntersector(m,l,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else if(y||P){if(!y||!P){if(Qe.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,h=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(m,l,!1),o[e]=i[e].calculateLength2D();const s=Math.abs(u-o[e]);s<a&&(a=s,h=e)}return g=i[h],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(m,l,!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=It(s,e,1),g=g.cut(e,s,!0)}g.setCoordsForIntersector(m,l,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}}processSpanCurves_(e,t,s,n,r,i,a){if(t===s&&0===n)return o(e.getNextVertex(t)===M),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const h=e.getNextVertex(t);{let t=2;for(let n=h;n!==s;n=e.getNextVertex(n))t++;o(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(h,s);const m=e.getXY(t),l=e.getXY(s);if(r.isClosed()){if(m.isEqualPoint2D(l)&&m.isEqualPoint2D(r.getStartXY())){let o;if(o=this.verifySegmentFitnessCurves(e,t,s,n,r,i,a)){const n=r.clone();return n.dropAllAttributes(),o<0&&n.reverse(),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),n)}}}else if(m.isEqualPoint2D(r.getStartXY())){if(l.isEqualPoint2D(r.getEndXY())){const h=r.clone();h.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,h,i,a);if(m)return o(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),h)}}else if(l.isEqualPoint2D(r.getStartXY())&&m.isEqualPoint2D(r.getEndXY())){const h=r.getReversed();h.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,h,i,a);if(m)return o(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),h)}this.processSpanSplitSegmentCurves(e,t,s,n,r,i,a)}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 _=Qe.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=Qe.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 F;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 gt(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,n,i,o){const a=new F;if(!e.querySegment(t,a,!0,!1))return;const h=n.getGeometryType();if(h!==a.get().getGeometryType()){if(h===s.enumEllipticArc){if(a.get().getGeometryType()!==s.enumRationalBezier2)return;if(0===n.projectionBehavior()){const s=[];ea(!1,a.get(),o,s,this.m_progressTracker);const n=e.getNextVertex(t),r=e.getPathFromVertex(t),i=new fe;let h=t;for(let t=1,o=s.length;t<o;t++){const o=s[t],m=a.get().getCoord2D(s[t-1]),l=a.get().getCoord2D(ft(s[t-1],o,.5));a.get().queryCoord(o,i);const g=i.getXY(),u=new R;u.constructCircularArcThreePoint(m,g,l);let c=M;o<1&&(c=e.insertVertex(r,n,i)),e.setSegmentToIndex(e.getVertexIndex(h),u),h=c}return}{const s=lt(Qe,3);a.get().queryControlPoints(s);const n=[0,0,0];a.get().queryWeights(n);const r=X(n),i=new R;return L(s,r*r,null,!1,i),void e.setSegmentToIndex(e.getVertexIndex(t),i)}}r("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=Ke(z.s_maxMonotonicPartParams,Number.NaN);let g=r.getMonotonicPartParams(l.length,l);g--;const u=new H,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,at.unit(),o))return 0}if(g>1)for(let e=1;e<g;){const t=r.getCoord2D(l[e]);n.isCloserThanDistance(t,at.unit(),o)?(l[g-1]=rt(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===M?t.getFirstGeometry():s;for(;i!==M;)if(P(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==M;s=t.getNextPath(s)){let i=t.getPathSize(s);const a=t.isClosedPath(s);a&&(i+=1);let h=t.getFirstVertex(s);const m=t.getSegmentParentage(h);if(a){if(-1!==m&&!t.getSegmentParentageBreakVertex(h)){let e=t.getPrevVertex(h);const s=h;for(let n=0;;n++){const r=t.getSegmentParentage(e);if(m!==r){o(-1===r);break}if(h=e,t.getSegmentParentageBreakVertex(e))break;if(e===s){h=s,t.setSegmentParentageBreakVertex(h,!0);break}e=t.getPrevVertex(e),o(n<i)}}}else o(-1===m||t.getSegmentParentageBreakVertex(h));let l=h;for(let s=0;s<i&&l!==M;){const a=t.getSegmentParentage(l);if(-1===a){if(s++,l=t.getNextVertex(l),l===h)break;continue}let m=0,g=M;const u=l;m=1;let c=t.getNextVertex(u);for(;s<i&&c!==M;){s++,g=c,m++;const e=t.getSegmentParentage(c);if(-1===e||t.getSegmentParentageBreakVertex(c))break;o(e===a),c=t.getNextVertex(c)}if(g===M){o(0);break}if(!r){const s=e.m_originalPlanarSegments[a];e.processSpan_(t,u,g,m,s,a,n)}if(l=g,l===h)break}}if(s!==M)break;i=t.getNextGeometry(i)}else i=s===M?t.getNextGeometry(i):M}static st_stitchCurvesFromLinesImpl(e,t,s,n,r){let i=s===M?t.getFirstGeometry():s;for(;i!==M;){for(let s=t.getFirstPath(i);s!==M;s=t.getNextPath(s)){let i=t.getPathSize(s);t.isClosedPath(s)&&(i+=1);let a=!0,h=!1;const m=t.getFirstVertex(s);let l=m;for(let s=0;s<i&&l!==M;){let g=t.getSegmentParentage(l);if(-1===g||a){a=!1,s++,l=t.getNextVertex(l),h=!0;continue}let u,c,_=0;if(h?(u=t.getPrevVertex(l),c=l,o(u!==M),o(c!==u),o(-1===t.getSegmentParentage(u)||m===u)):(u=l,c=t.getNextVertex(u),s++,o(c!==M),o(c!==u),g=t.getSegmentParentage(c)),_=2,h=!1,-1===g||t.getSegmentParentageBreakVertex(c)){l=c;continue}let d=t.getNextVertex(c);for(s++;s<i&&d!==M;){c=d,_++;const e=t.getSegmentParentage(d);if(-1===e||t.getSegmentParentageBreakVertex(d))break;o(e===g),s++,d=t.getNextVertex(d)}if(!r){const s=e.m_originalPlanarSegments[g];e.processSpan_(t,u,c,_,s,g,n)}l=c}}if(s!==M)break;i=t.getNextGeometry(i)}}static st_stitchCurvesFromCurvesImpl(e,t,s,n,r){let i=s===M?t.getFirstGeometry():s;for(;i!==M;)if(P(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==M;s=t.getNextPath(s)){let i=t.getPathSize(s);const a=t.isClosedPath(s);a&&(i+=1);let h=t.getFirstVertex(s);if(a){if(-1!==t.getSegmentParentage(h)){let e=h;for(let n=0;!t.getSegmentParentageBreakVertex(e);n++){if(n===i){h=t.getFirstVertex(s),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else o(-1===t.getSegmentParentage(h)||t.getSegmentParentageBreakVertex(h));let m=h;for(let s=0;s<i&&m!==M;){const a=t.getSegmentParentage(m);if(-1===a){s++,m=t.getNextVertex(m);continue}let h=0,l=M;const g=m;h=1;let u=t.getNextVertex(g);for(;s<i&&u!==M;){s++,l=u,h++;const e=t.getSegmentParentage(u);if(-1===e||t.getSegmentParentageBreakVertex(u))break;o(e===a),u=t.getNextVertex(u)}if(l===M)break;if(!r){const s=e.m_originalPlanarSegments[a];e.processSpan_(t,g,l,h,s,a,n)}m=l}}if(s!==M)break;i=t.getNextGeometry(i)}else i=s===M?t.getNextGeometry(i):M}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()===B.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))*Et(),s=Qe.distance(a[e-1],a[e]);if(s<t&&s>0){const t=new Qe;St(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=ye(e);return ln(t.getX(),t.getY(),s.getX(),s.getY(),ut(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 fe;return cn(e,t,s,n,r,i,h,a,o),h}function Sa(e,t,s){const n=ye(t),r=Se(t);return!!_n(e,n,M,null,s)||Mn(!0,e,r,null,s)}function Ca(e,t,s){return ba.fixCurveTwoPointLoops(e,t,s)}function Ia(e){return ye(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 xe(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=1e-5,s=1e-6,n=Ia(e);let i=Se(e);const o=i*(1+t);i*=1+s;let a=!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&&r("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let e=-1;0===l&&(e=this.firstCrack_(),a||=e>0);const t=this.cluster_(n);if(this.m_shape.dbgVerifyMonotone(),a||=t,this.m_bFilterDegenerateSegments){const e=0!==this.m_shape.filterClosePoints(n,!0,!1,this.m_bTrackChanges,M);a||=e,this.m_shape.dbgVerifyMonotone()}const s=this.m_shape.snapControlPointsOnSelection(o*o);a||=s,this.m_shape.dbgCheckSelection();let g=!1;if((0===l&&-1===e||m||Mn(!0,this.m_shape,i,null,this.m_progressTracker))&&(g=this.crack_(o),a||=g,this.m_shape.dbgVerifyMonotone()),!g&&!ba.fixCurveTwoPointLoops(this.m_shape,n,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return a&&ua(this.m_shape),a}cluster_(e){return mn(this.m_shape,e,M,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 Ce(0),i=e.queryVertexIteratorOnSelection();for(let o=i.next();o!==M;o=i.next())r.add(o),e.setUserIndex(o,n,-1);if(0===r.size())return!1;r.add(M),e.sortVerticesSimpleByY(r,0,r.size()-1);let a=0;const h=e.getXY(r.read(a)),m=new Qe(Number.NaN,Number.NaN),l=[];for(let o=1,g=r.size();o<g;++o){const t=r.read(o),s=t!==M?e.getXY(t):m;if(s.equals(h))continue;const i=[];for(let m=a;m<o;m++){const t=r.read(m),s=e.getPrevVertex(t);if(s!==M&&-1===e.getUserIndex(s,n)){const t=wa(e.getXY(s),e.getSegment(s));0!==Qe.sqrDistance(h,t.otherPt)&&(t.vert=s,t.dir=-1,i.push(t)),e.setUserIndex(s,n,1)}const o=e.getNextVertex(t);if(o!==M&&-1===e.getUserIndex(t,n)){const s=wa(e.getXY(o),e.getSegment(t));0!==Qe.sqrDistance(h,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(m.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++)l.push(i[r].vert)}t=s}}a=o,h.setCoordsPoint2D(s)}for(const g of l){const s=e.getSegment(g);o(null!==s);const n=e.getXY(g),r=e.getXY(e.getNextVertex(g));if(Qe.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),l.length>0}firstCrack_(){const e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=de(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,M));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(o(e.otherPt.equals(t.otherPt)),null===e.seg)return null===t.seg;if(null===t.seg)return!1;const n=e.seg.getGeometryType();if(n!==t.seg.getGeometryType())return!1;if(n===s.enumBezier){const s=e.seg,n=t.seg;let r=s.getControlPoint1(),i=s.getControlPoint2();-1===e.dir&&(i=rt(r,r=i));let o=n.getControlPoint1(),a=n.getControlPoint2();return-1===t.dir&&(a=rt(o,o=a)),r.equals(o)&&i.equals(a)}if(n===s.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]=rt(o[0],o[0]=o[2]));const a=[0,0,0];return n.queryWeights(a),-1===t.dir&&(a[2]=rt(a[0],a[0]=a[2])),o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}r("")}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=i,Da=n,Va=h;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:o(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,n,r,i,o,a){const h=new Ka(i);h.m_bOGCOutput=!0;const m=e.getGeometryType()===s.enumPolygon&&1===e.getFillRule()&&!Te(r);return h.planarSimplifyImpl_(e,t,m,n,r,i,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 G,a=i.addGeometry(t),h=r.planarSimplifyNoCrackingAndCluster(e,i,a,s);o(h,"planar_simplify_no_cracking_and_cluster");return i.getGeometry(a)}function qa(e,t,s,n,r,i,a){return o(0),{}}function Ba(e,t,s,n){return o(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 i=new C;e.queryEnvelope(i);const o=new C;t.queryEnvelope(o);const a=new C;a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const h=de(n,a,!0),m=o.clone(),l=ye(h);if(m.inflateCoords(l,l),!i.isIntersecting(m))return $a(eh(e),e,t,"-");const g=new Ka(r),u=new G,c=u.addGeometry(eh(e)),_=u.addGeometry(eh(t));let d=0,p=0,f=null;if(u.hasCurves()){f=new fa;const e=u.getEnvelope2D(r);p=da(h.total());const t=_a(h.total(),e);d=pa(t,p),aa(u,t,h.total(),12e3,f,null,r)}g.setEditShapeCrackAndCluster(u,h.add(d));const x=g.difference(c,_);null!==f&&f.stitchCurves(u,x,p,!0);const y=$a(u.getGeometry(x),e,t,"-");return Ga(y.getGeometryType())&&(y.getImpl().setIsSimple(4,h.total()),y.getGeometryType()===s.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}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 i=new C;e.queryEnvelope(i);const o=new C;t.queryEnvelope(o);const a=new C;a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const h=de(n,a,!0),m=new Ka(r),l=new G,g=l.addGeometry(eh(e)),u=l.addGeometry(eh(t));let c=0,_=null;if(l.hasCurves()){_=new fa;const e=l.getEnvelope2D(r);c=da(h.total());aa(l,_a(h.total(),e),h.total(),12e3,_,null,r)}m.setEditShapeCrackAndCluster(l,h);const d=m.symmetricDifference(g,u);null!==_&&_.stitchCurves(l,d,c,!0);const p=$a(l.getGeometry(d),e,t,"^");return Ga(p.getGeometryType())&&(p.getImpl().setIsSimple(4,h.total()),p.getGeometryType()===s.enumPolygon&&p.getImpl().updateOGCFlagsProtected()),p}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 fe({copy:Ea(e,t)}):e.createInstance()}function za(e,t,n,r){const i=C.constructEmpty();e.queryEnvelope(i);const o=C.constructEmpty();t.queryEnvelope(o);const a=C.constructEmpty();a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const h=de(n,a,!0),m=new C(o),l=ye(h);if(m.inflateCoords(l,l),!i.isIntersecting(m)){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 g=new Ka(r),u=new G,c=u.addGeometry(eh(e)),_=u.addGeometry(eh(t));let d=0,p=0,f=null;if(u.hasCurves()){f=new fa;const e=u.getEnvelope2D(r);p=da(h.total());const t=_a(h.total(),e);d=pa(t,p),aa(u,t,h.total(),12e3,f,null,r)}g.setEditShapeCrackAndCluster(u,h.add(d));const x=g.intersection(c,_);null!==f&&f.stitchCurves(u,x,p,!0);const y=$a(u.getGeometry(x),e,t,"&");return Ga(y.getGeometryType())&&(y.getImpl().setIsSimple(4,h.total()),y.getGeometryType()===s.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function Wa(e,t,n,r){const i=new Array(3),o=C.constructEmpty();e.queryEnvelope(o);const a=C.constructEmpty();t.queryEnvelope(a);const h=C.constructEmpty();h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=de(n,h,!0),l=new C(a),g=ye(m);if(l.inflateCoords(g,g),!o.isIntersecting(l)){if(e.getDimension()<=t.getDimension()){const s=$a(eh(e.createInstance()),e,t,"&");return i[s.getDimension()]=s,i}if(e.getDimension()>t.getDimension()){const s=$a(eh(t.createInstance()),e,t,"&");return i[s.getDimension()]=s,i}}const u=new Ka(r),c=new G,_=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)),c.dbgVerifyCurves();const y=u.intersectionEx(_,d);for(const P of y){null!==x&&x.stitchCurves(c,P,f,!1);const n=$a(c.getGeometry(P),e,t,"&");Ga(n.getGeometryType())&&(n.getImpl().setIsSimple(4,m.total()),n.getGeometryType()===s.enumPolygon&&n.getImpl().updateOGCFlagsProtected()),i[n.getDimension()]=n}return null!==x&&x.clearStitcher(c),i}function ja(t,s,n,r,i,o=!1){0===s&&e("not enough geometries to dissolve");let a=0;for(let e=0,d=s;e<d;e++)a=Math.max(t[e].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!1,t,s,n,i,o);let h=0,m=-1;for(let e=0,d=s;e<d;e++)t[e].getDimension()===a&&(-1===m&&(m=e),t[e].isEmpty()||(m=e,h++));if(h<2)return eh(t[m]);const l=Ge.constructEmpty(),g=new G;let u=M;for(let e=0,d=s;e<d;e++)if(t[e].getDimension()===a&&!t[e].isEmpty()){u===M?u=g.addGeometry(eh(t[e])):g.appendGeometry(u,eh(t[e]));const s=Ge.constructEmpty();t[e].queryLooseEnvelope(s),l.mergeEnv3D(s)}const c=de(n,l.getEnvelope2D(),!0),_=new Ka(r);if(o){const e=De(n,l.getEnvelopeZs(),!0);return _.planarSimplify3DImpl_(g,c,e,0,!0)}return _.m_bOGCOutput=!0,_.planarSimplifyMultiPoints(g,c,!1,-1)}function Za(t,s,n,r,i,o=!1){s<2&&e("not enough geometries to dissolve");let a=0;for(let e=0,p=s;e<p;e++)a=Math.max(t[e].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!0,t,s,n,i,o);const h=Ge.constructEmpty(),m=new G;let l=M,g=0,u=-1;for(let e=0,p=s;e<p;e++)if(t[e].getDimension()===a&&(-1===u&&(u=e),!t[e].isEmpty())){u=e,l===M?l=m.addGeometry(eh(t[e])):m.appendGeometry(l,eh(t[e]));const s=Ge.constructEmpty();t[e].queryLooseEnvelope(s),h.mergeEnv3D(s),g++}if(g<2)return eh(t[u]);const c=0===a?n:null,_=de(c,h.getEnvelope2D(),!0),d=new Ka(r);if(o){const e=De(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=Qe.getNAN(),this.m_dummyPt2=Qe.getNAN(),this.m_fromEdgeForPolylines=M,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!==M;h=this.m_topoGraph.getChainNextInParent(h))this.m_topoGraph.setChainUserIndex(h,i,1);const a=[];for(let h=this.m_topoGraph.getFirstChain();h!==M;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!==M;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,M,h,M);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!==M;l=this.m_topoGraph.getChainNextInParent(l))this.m_topoGraph.setChainUserIndex(l,a,1);const m=[];for(let l=this.m_topoGraph.getFirstChain();l!==M;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!==M;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,M,l,M);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 n=e.getFirstGeometry();n!==M;n=e.getNextGeometry(n))e.getGeometryType(n)===s.enumPolygon&&er(e,n,-1,this.m_bOGCOutput,M,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==M;n=s.getNextGeometry(n))if(n===t)for(let t=s.getFirstPath(n);t!==M;t=s.getNextPath(t)){let n=s.getFirstVertex(t);if(n===M)continue;let r=s.getNextVertex(n);for(;r!==M;){const t=this.m_topoGraph.getClusterFromVertex(n),i=this.m_topoGraph.getClusterFromVertex(r),o=this.m_topoGraph.getHalfEdgeConnector(t,i);if(o!==M){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 F,i=s.insertPath(e,M);t.push(t[0]);const o=t.length;let a=M;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,n,r){const i=this.m_topoGraph.getGeometryID(n),o=this.m_topoGraph.getGeometryID(r),a=[],h=this.m_topoGraph.getShape(),m=this.m_topoGraph.createUserIndexForHalfEdges();for(let l=this.m_topoGraph.getFirstCluster();l!==M;l=this.m_topoGraph.getNextCluster(l)){const n=this.m_topoGraph.getClusterHalfEdge(l);if(n===M)continue;let r=n;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(r,m)){let n=r,l=r,g=!1,u=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(n,m,1),!g){if(0!==(this.m_topoGraph.getHalfEdgeParentage(n)&o)){0!==(this.m_topoGraph.getHalfEdgeFaceParentage(n)&i)&&(l=n,g=!0)}}if(g){const t=this.m_topoGraph.getHalfEdgeOrigin(n),s=this.m_topoGraph.getClusterVertexIterator(t),r=this.m_topoGraph.getVertexFromVertexIterator(s);if(a.push(r),-1!==e){if(0!==(this.m_topoGraph.getHalfEdgeParentage(n)&o)){u|=this.m_topoGraph.getHalfEdgeUserIndex(n,e)}}}n=this.m_topoGraph.getHalfEdgeNext(n)}while(n!==l);if(g&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(l))>0){const e=h.createGeometry(s.enumPolygon);this.flushVertices_(e,a),-1!==t&&h.setGeometryUserIndex(e,t,u)}a.length=0}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==n)}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!==M;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,i){const o=this.m_topoGraph.getShape().getGeometryType(s),a=this.m_topoGraph.getShape().getGeometryType(n),m=h(o),l=h(a);if(2!==m||1!==l){if(1===m&&1===l){return void new sh(this,e,t,s,n,i).Do()}r("")}else this.cutPolygonPolyline_(t,s,n,i)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(t){const r=t.getGeometryType();if(r===s.enumEnvelope){const e=new v({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(r===s.enumPoint){const e=new N({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(n(r)){const e=new I({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return r!==s.enumMultiPoint&&r!==s.enumPolyline&&r!==s.enumPolygon&&e("Unexpected geometry type"),t}dissolveNonSimplePolygons(e,t,s,n){o(t>0);const r=new G;let i=0,a=-1;for(let o=0,h=t;o<h;o++)2===e[o].getDimension()&&(-1===a&&(a=o),e[o].isEmpty()||(i++,r.addGeometry(e[o])));return 0===i?(o(a>=0),this.normalizeInputGeometry(e[a])):this.planarSimplifyPolygons(r,s,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,r,a,h,l,g){o(e>=1&&e<=2),o(a>0);const u=8&l?1:2,c=Ge.constructEmpty();let _=0,d=-1,p=!0;for(let n=0,i=a;n<i;n++)if(r[n].getDimension()===e&&(-1===d&&(d=n),!r[n].isEmpty())){d=n,_++;const t=Ge.constructEmpty();if(r[n].queryLooseEnvelope(t),c.mergeEnv3D(t),2===e&&p&&r[n].getGeometryType()===s.enumPolygon)if(16&l){const e=[0],t=r[n].getImpl().getIsSimple(0,e),s=this.m_bOGCOutput?5===t:ce(t);p&&=s}else{const e=Ue(r[n],0);p&&=e}}if(_<2&&(o(d>=0),0===_||!(16&l)))return this.normalizeInputGeometry(r[d]);if(!p){const e=de(t?null:h,c.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(r,a,e,l)}const f=r.slice(0,a),x=de(h,c.getEnvelope2D(),!0),y=10*ye(x);let P=new xe(0,0);if(g&&(P=De(h,c.getEnvelopeZs(),!0)),1===_&&1===e&&2===u&&!t)return g?qa():this.m_bOGCOutput?Aa(f[d],x,!1,-1,this.m_progressTracker,u,!1):Ma(f[d],x,!1,!1,-1,this.m_progressTracker,u,!1);const E=new qe;E.startConstruction();let S=2===e?3:4,b=0;for(let m=0,I=a;m<I;m++){if(f[m].getDimension()!==e||f[m].isEmpty())continue;let r=f[m].getGeometryType();if(r!==s.enumEnvelope){if(n(r)?(f[m]=this.normalizeInputGeometry(f[m]),r=s.enumPolyline):o(i(r)),1===e){o(r===s.enumPolyline);let e=-1;if(g)o(0,"3d not implemented yet");else{const t=[0];e=f[m].getImpl().getIsSimple(x.total(),t)}if(this.m_bOGCOutput?5!==e:!ce(e))if(t)S=-1;else{g?o(0,"3d not implemented yet"):this.m_bOGCOutput?f[m]=Aa(f[m],x,!1,-1,this.m_progressTracker,u,!1):f[m]=Ma(f[m],x,!1,!1,-1,this.m_progressTracker,u,!1);const e=[0];o(ce(f[m].getImpl().getIsSimple(x.total(),e)))}}else{o(r===s.enumPolygon);const e=[0],t=f[m].getImpl().getIsSimple(0,e);o(Te(t))}const a=f[m].getImpl();for(let e=0,t=a.getPathCount();e<t;e++){const t=C.constructEmpty();a.queryLoosePathEnvelope(e,t),t.inflateCoords(y,y),E.addEnvelope(b,t),b++}}else{o(r===s.enumEnvelope);const e=C.constructEmpty();f[m].queryLooseEnvelope(e),e.inflateCoords(y,y),E.addEnvelope(b,e),b++,S=-1}}E.endConstruction();const w=b,N=Ke(w,-2147483647),T=Ke(w,-1);let D=0;d=-1,b=0;for(let n=0,m=a;n<m;n++){if(f[n].getDimension()!==e)continue;if(-1===d&&(d=n),f[n].isEmpty())continue;d=n,D++;const t=f[n].getGeometryType();if(i(t)){for(let e=0,t=f[n].getPathCount();e<t;e++)T[b]=n,N[b]=-e-1,b++}else o(t===s.enumEnvelope),T[b]=n,N[b]=-1,b++}if(D<2&&2===e)return o(d>=0),this.normalizeInputGeometry(f[d]);let V=w;for(;E.next()&&V>0;){this.progress_();const e=E.getHandleA(),t=E.getHandleB(),s=E.getElement(e),n=E.getElement(t);T[s]!==T[n]&&(N[s]<0&&(V--,N[s]=-(N[s]+1)),N[n]<0&&(V--,N[n]=-(N[n]+1)))}const F=new G;let H=!1,k=0;for(let n=0,C=a;n<C;n++){if(f[n].getDimension()!==e||f[n].isEmpty())continue;const t=f[n].getGeometryType(),r=k;let a=0,h=0;const l=i(t)?f[n]:null;for(let e=r,s=N.length;e<s&&T[e]===n;e++)N[e]>=0&&(a++,h+=l?l.getPathSize(N[e]):m(f[n])),k++;if(h>.95*m(f[n])){F.addGeometry(this.normalizeInputGeometry(f[n]));for(let e=r;e<k;e++)N[e]<0&&(N[e]=-(N[e]+1))}else{if(0===a){H=!0;continue}{H=!0,o(i(t)),o(null!=l);const e=new v({vd:f[n].getDescription()}),a=new I({vd:f[n].getDescription()}),h=t===s.enumPolygon?e:a;for(let t=r;t<k;t++)N[t]>=0&&h.addPath(l,N[t],!0);F.addGeometry(h)}}}let A;if(F.getFirstGeometry()!==M){const s=2===e,n=t?de(null,c.getEnvelope2D(),!0):x;let r=new xe(0,0);if(g&&(r=t?De(null,c.getEnvelopeZs(),!0):P),2===e&&!(2&l)){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,M,e,!0)}if(g)A=this.planarSimplify3DImpl_(F,n,r,u,!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=u,A=this.planarSimplifyPolylines(F,n,t,e,-1)}if(!H){const e=[0];S=A.getImpl().getIsSimple(n.total(),e)}}else o(H),o(d>=0),A=2===e?new v({vd:f[d].getDescription()}):new I({vd:f[d].getDescription()});if(H){let e=0;for(let t=0,s=N.length;t<s;t++){const s=T[t];if(!(s<0)&&N[t]<0){const n=f[s].getGeometryType(),r=i(n)?f[s]:null;if(r){const s=-(N[t]+1);e+=r.getPathSize(s)}else e+=4}}A.reserve(A.getPointCount()+e);for(let t=0,r=N.length;t<r;t++){const e=T[t];if(!(e<0)&&N[t]<0){const r=f[e].getGeometryType(),a=i(r)?f[e]:null;if(a){const e=-(N[t]+1);A.addPath(a,e,!0)}else r===s.enumEnvelope?A.addEnvelope(f[e],!1):(o(n(r)),A.addSegment(f[e],!0))}}}let U=0;if(2===e?-1!==S&&(S=3,U=t?0:x.total()):(o(1===e),t||-1===S||(U=x.total())),g||A.getImpl().setIsSimple(S,U),!t&&H)if(2===e){if(!g)return(new Eh).execute(A,h,!1,this.m_progressTracker);o(0,"3d not yet implemented")}else 1===e&&1!==u&&(A=g?Ba():Ua(this.m_bOGCOutput,A,u,this.m_progressTracker),A.getImpl().setIsSimple(S,U));return A}dissolveTopoGraphCommonEdges_(){const e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let r=n;if(n!==M)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=bt(),i=M;for(let o=this.m_topoGraph.getClusterVertexIterator(e);o!==M;o=this.m_topoGraph.incrementVertexIterator(o)){const e=this.m_topoGraph.getVertexFromVertexIterator(o),n=t.getUserIndex(e,s);n>=0&&n<r&&(r=n,i=e)}o(i!==M);let a=t.getUserIndex(i,n);return a>0&&(t.setUserIndex(i,n,--a),0===a&&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,n,r,i){const o=this.m_topoGraph.getShape();if(o.getGeometryType(e)!==s.enumPolygon)return;const a=o.hasSegmentParentage(),h=new F;for(let s=o.getFirstPath(e);s!==M;s=o.getNextPath(s)){const e=o.getFirstVertex(s);this.m_topoGraph.getClusterFromVertex(e);const m=this.m_topoGraph.getHalfEdgeFromVertex(e);if(m===M)continue;const l=this.m_topoGraph.getHalfEdgeUserIndex(m,n);if(1===l||2===l)continue;const g=this.m_topoGraph.getHalfEdgeFaceParentage(m);if(!this.isGoodParentage(g)){this.m_topoGraph.setHalfEdgeUserIndex(m,n,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(m,n,1);const u=o.insertPath(t,M);o.setClosedPath(u,!0);let c=m,_=e,d=this.m_topoGraph.getClusterFromVertex(_),p=1;do{this.progress_();const e=this.chooseVertexFromVertexCluster_(_,i),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 s,m;-1!==r&&this.m_topoGraph.setClusterUserIndex(d,r,1),this.m_topoGraph.setHalfEdgeUserIndex(c,n,1),c=this.m_topoGraph.getHalfEdgeNext(c);do{s=1===p?o.getNextVertex(_):o.getPrevVertex(_),m=s!==M?this.m_topoGraph.getClusterFromVertex(s):M}while(m===d);const l=this.m_topoGraph.getHalfEdgeOrigin(c);if(l!==m){do{s=1===p?o.getPrevVertex(_):o.getNextVertex(_),m=s!==M?this.m_topoGraph.getClusterFromVertex(s):M}while(m===d);if(l!==m){m=l;const e=this.m_topoGraph.getClusterVertexIterator(m);s=this.m_topoGraph.getVertexFromVertexIterator(e)}else p=-p}d=m,_=s}while(c!==m)}}topoOperationPolygonPolygonHelper_(e,t,s,n,r,i){this.progress_(!0),e!==M&&this.collectPolygonPathsPreservingFrom_(e,s,r,i,n),t!==M&&this.collectPolygonPathsPreservingFrom_(t,s,r,i,n);const o=new F,a=this.m_topoGraph.getShape();a.dbgVerifyCurves();const h=a.hasSegmentParentage();for(let m=this.m_topoGraph.getFirstCluster();m!==M;m=this.m_topoGraph.getNextCluster(m)){const e=this.m_topoGraph.getClusterHalfEdge(m);if(e===M)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,M);a.setClosedPath(e,!0);let m=t;do{const t=this.m_topoGraph.getHalfEdgeVertexIterator(m);let s=M;if(t!==M)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,n,r=!1){this.dissolveTopoGraphCommonEdges_();const i=this.m_topoGraph.getShape(),o=i.createGeometry(s.enumPolygon),a=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,o,n,a,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(a),r||er(i,o,3,this.m_bOGCOutput,M,this.m_progressTracker),o}topoOperationPolyline_(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(M,e,!1,s).first}topoOperationMultiPoint_(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(s.enumMultiPoint),n=e.insertPath(t,M);for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const t=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(t)){let t=M;for(let n=this.m_topoGraph.getClusterVertexIterator(s);n!==M;n=this.m_topoGraph.incrementVertexIterator(n)){const s=this.m_topoGraph.getVertexFromVertexIterator(n);t===M&&(t=s);const r=e.getGeometryFromPath(e.getPathFromVertex(s)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=s;break}}e.addVertex(n,t)}}return t}intersection(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=h(s),a=h(n),m=this.m_topoGraph.getGeometryID(e),l=this.m_topoGraph.getGeometryID(t);o(m>=0),o(l>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(m|l),this.m_maskLookup[m|l]=!0;let g=M;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(g=e),2===i&&2===a?this.topoOperationPolygonPolygon_(e,t,g):1===i&&a>0||1===a&&i>0?this.topoOperationPolyline_(g,this.m_bOGCOutput):0===i||0===a?this.topoOperationMultiPoint_():void r("")}topoOperationPolygonPolygonEx(e,t,n){const r=this.m_topoGraph.getShape(),i=r.createGeometry(s.enumPolygon),o=r.createGeometry(s.enumPolyline),a=r.createGeometry(s.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let h=M;const m=this.m_topoGraph.createUserIndexForHalfEdges(),l=this.m_topoGraph.createUserIndexForClusters();r.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,i,n,m,l),r.dbgVerifyCurves();const g=r.hasSegmentParentage(),u=new F;for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const e=this.m_topoGraph.getClusterHalfEdge(s);if(e===M)continue;let t=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(t,m),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),m),a=e|i;if(2===a){let h=this.m_topoGraph.getHalfEdgeParentage(t);if(this.isGoodParentage(h)){const c=r.insertPath(o,M);let _=t;const d=this.chooseVertexFromCluster_(s,n);let p=r.addVertex(c,d);if(g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);r.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,u),r.setSegmentToIndex(r.getVertexIndex(p),u.get().clone())),this.m_topoGraph.setClusterUserIndex(s,l,1);do{this.progress_();const s=this.m_topoGraph.getHalfEdgeTo(_),o=this.chooseVertexFromCluster_(s,n);if(p=r.addVertex(c,o),g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);r.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(s,l,1),_=this.m_topoGraph.getHalfEdgeNext(_),e=this.m_topoGraph.getHalfEdgeUserIndex(_,m),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m),a=e|i,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),r.setSegmentToIndex(r.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 s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){this.progress_();if(1===this.m_topoGraph.getClusterUserIndex(s,l))continue;const e=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(e)){h===M&&(h=r.insertPath(a,M));const e=this.m_topoGraph.getClusterVertexIterator(s);let t=M;if(e!==M){t=this.m_topoGraph.getVertexFromVertexIterator(e);const s=this.chooseVertexFromVertexCluster_(t,n);r.addVertex(h,s)}}}this.m_topoGraph.deleteUserIndexForClusters(l),this.m_topoGraph.deleteUserIndexForHalfEdges(m),r.dbgVerifyCurves(),er(r,i,3,this.m_bOGCOutput,M,this.m_progressTracker);const c=[M,M,M];return c[0]=a,c[1]=o,c[2]=i,c}topoOperationPolylinePolylineOrPolygonEx(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(M,e,!0,s)}topoOperationMultiPoint(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(s.enumMultiPoint),n=e.insertPath(t,M);for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const t=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(t)){let t=M;for(let n=this.m_topoGraph.getClusterVertexIterator(s);n!==M;n=this.m_topoGraph.incrementVertexIterator(n)){const s=this.m_topoGraph.getVertexFromVertexIterator(n);t===M&&(t=s);const r=e.getGeometryFromPath(e.getPathFromVertex(s)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=s;break}}e.addVertex(n,t)}}return t}intersectionEx(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=Va(s),a=Va(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);o(h>=0),o(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=M;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===i&&2===a)return this.topoOperationPolygonPolygonEx(e,t,l);if(1===i&&a>0||1===a&&i>0){const{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[t,e]}if(0===i||0===a){const e=[];return e.push(this.topoOperationMultiPoint()),e}r("")}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!==M;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!==M&&this.m_topoGraph.getClusterFromVertex(c)===r){if(i++,u){if(this.m_fromEdgeForPolylines===M&&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!==M&&this.m_topoGraph.getClusterFromVertex(s)===r&&(i--,u)){if(this.m_fromEdgeForPolylines===M&&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)*Qe.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 M;const t=this.m_topoGraph.getHalfEdgeTwin(e);if(n===this.m_topoGraph.getHalfEdgeNext(t))return s}let r=n,i=M;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==M)return M;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 M;if(n===this.m_topoGraph.getHalfEdgePrev(t))return s}let r=n,i=M;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==M)return M;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}r("is_on_a_loop_")}restorePolylineParts(e,t,s,n,r,i,a,h,m,l){o(r===M&&i>=0&&a>=0||-1===i&&-1===a),o(-1===h&&1!==l.unsplitBehavior||-1!==h&&1===l.unsplitBehavior);const g=l.ogcRule,u=l.allCrossRoadsImpassable,c=1===l.unsplitBehavior,_=0===l.unsplitBehavior,d=this.m_topoGraph.getShape(),p=d.hasSegmentParentage();let f=e,x=this.m_topoGraph.getHalfEdgeTwin(f);const y=new F;this.m_fromEdgeForPolylines=M;let P=this.prevailingDirection(d,f),E=f,S=M,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===M){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===M){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!==h){const e=this.m_topoGraph.getHalfEdgeOrigin(x);if(1===this.m_topoGraph.getClusterUserIndex(e,h)){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===M){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!==M){E=e,S=this.tryMoveThroughCrossroadBackwards(E,!1),o(S!==M);const t=this.m_topoGraph.getHalfEdgeTwin(E);this.m_topoGraph.getHalfEdgeNext(t)}let w=I;I||b||m&&(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&&(o(!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=rt(E,E=S),S=this.m_topoGraph.getHalfEdgeTwin(S),E=this.m_topoGraph.getHalfEdgeTwin(E));let G=d.insertPath(t,M);f=E;const D=this.m_topoGraph.getHalfEdgeOrigin(E);let V;V=-1!==i?this.chooseVertexByOrder(D,d,i,a):this.chooseVertexFromCluster_(D,r),this.m_topoGraph.isStrongPathNode(D)&&d.setStrongPathStart(G,!0);let H=d.addVertex(G,V),k=H;-1!==n&&this.m_topoGraph.setClusterUserIndex(D,n,1);let A=0;const U=N?Math.trunc((T+1)/2):-1;let q=M,B=!0,O=M;for(;;){if(p){const e=this.m_topoGraph.getSegmentParentage(f),t=this.m_topoGraph.getHalfEdgeOrigin(f);d.setSegmentParentageAndBreak(k,e,B||this.m_topoGraph.isBreakNode(t))}B=!1,this.m_topoGraph.isHalfEdgeCurve(f)&&(this.m_topoGraph.querySegmentXY(f,y),d.setSegmentToIndex(d.getVertexIndex(k),y.get().clone())),q!==M&&-1!==a&&d.addToUserIndex(q,a,-1);const e=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1),s=this.m_topoGraph.getHalfEdgeTo(f);let o;if(o=-1!==i?this.chooseVertexByOrder(s,d,i,a):this.chooseVertexFromCluster_(s,r),H=d.addVertex(G,o),O=s,-1!==n&&this.m_topoGraph.setClusterUserIndex(s,n,1),p&&this.m_topoGraph.isBreakNode(s)&&d.setSegmentParentageBreakVertex(H,!0),q=o,A++,N&&A===U&&(G=d.insertPath(t,M),H=d.addVertex(G,o),B=!0,-1!==a&&d.addToUserIndex(o,a,-1),q=M),f===S)break;f=e,k=H}O!==M&&this.m_topoGraph.isStrongPathNode(O)&&d.setStrongPathEnd(G,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,M,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,n,r){o(t===M||e===M);const i=this.m_topoGraph.getShape(),a=t=>t=e===M?t===M?i.getFirstGeometry():i.getNextGeometry(t):t===M?e:M,h=i.createGeometry(s.enumPolyline);let m=-1;n&&(m=this.m_topoGraph.createUserIndexForClusters());const l=this.m_topoGraph.createUserIndexForHalfEdges(),g=t===M?i.createUserIndex():-1,u=t===M?i.createUserIndex():-1;let c=-1;if(1===r.unsplitBehavior){c=this.m_topoGraph.createUserIndexForClusters();for(let e=a(M);e!==M;e=a(e))for(let t=i.getFirstPath(e);t!==M;t=i.getNextPath(t)){{const e=i.getFirstVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}if(!i.isClosedPath(t)){const e=i.getLastVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}}}if(t===M){let e=0;for(let t=a(M);t!==M;t=a(t))for(let s=i.getFirstPath(t);s!==M;s=i.getNextPath(s)){if(i.isClosedPath(s)){let t=i.getFirstVertex(s);for(let n=0,r=i.getPathSize(s);n<r;n++,t=i.getNextVertex(t))i.setUserIndex(t,g,e++),i.setUserIndex(t,u,2)}else{const t=i.getFirstVertex(s);i.setUserIndex(t,g,e++),i.setUserIndex(t,u,1);let n=i.getNextVertex(t);for(let r=1,o=i.getPathSize(s)-1;r<o;++r)i.setUserIndex(n,g,e++),i.setUserIndex(n,u,2),n=i.getNextVertex(n);i.setUserIndex(n,g,e++),i.setUserIndex(n,u,1)}}}for(let s=a(M);s!==M;s=a(s))for(let e=i.getFirstPath(s);e!==M;e=i.getNextPath(e)){let s=i.getFirstVertex(e);for(let n=0,o=i.getPathSize(e);n<o;n++,s=i.getNextVertex(s)){const e=this.m_topoGraph.getHalfEdgeFromVertex(s);if(e===M)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(e,l))continue;const i=this.getCombinedHalfEdgeParentage(e);if(this.isGoodParentage(i)){const s=0===n;this.restorePolylineParts(e,h,l,m,t,g,u,c,s,r)}}}let _=M;if(n){_=i.createGeometry(s.enumMultiPoint);let e=M;for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){this.progress_();if(1!==this.m_topoGraph.getClusterUserIndex(s,m)){const n=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(n)){e===M&&(e=i.insertPath(_,M));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==M){let r;this.m_topoGraph.getVertexFromVertexIterator(n),r=-1!==g?this.chooseVertexByOrder(s,i,g,u):this.chooseVertexFromCluster_(s,t),i.addVertex(e,r)}}}}}return-1!==u&&i.removeUserIndex(u),-1!==g&&i.removeUserIndex(g),-1!==m&&i.removeUserIndex(m),this.m_topoGraph.deleteUserIndexForHalfEdges(l),mt(h,_)}difference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=h(s),o=h(n);if(i>o)return e;const a=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(a|m),this.m_maskLookup[a]=!0,2===i&&2===o){let s=M;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=e),this.topoOperationPolygonPolygon_(e,t,s)}if(1===i&&2===o){const t=Ha();return t.allCrossRoadsImpassable=!1,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,M,!1,t).first}if(1===i&&1===o){const t=Ha();return t.allCrossRoadsImpassable=!0,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,M,!1,t).first}if(0===i)return this.topoOperationMultiPoint_();r("")}symmetricDifference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=Va(s),a=Va(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);return o(h>=0),o(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h]=!0,this.m_maskLookup[h]=!0,this.m_maskLookup[m]=!0,2===i&&2===a?this.topoOperationPolygonPolygon_(e,t,M):1===i&&1===a?this.topoOperationPolyline_(M,this.m_bOGCOutput):0===i&&0===a?this.topoOperationMultiPoint():void r("")}planarSimplifyNoCrackingAndCluster(e,t,n,i){this.m_bOGCOutput=e,this.m_topoGraph=new tn;const a=t.getFillRule(n),h=t.getGeometryType(n);if(1!==a||h===s.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,n,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,n,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const m=this.m_topoGraph.getGeometryID(n);if(o(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=m+1,this.m_maskLookup[m]=!0,t.getGeometryType(n)===s.enumPolygon||1===a&&t.getGeometryType(n)!==s.enumMultiPoint){t.setFillRule(n,0);const s=this.topoOperationPolygonPolygon_(n,M,M);if(t.swapGeometry(s,n),t.removeGeometry(s),1===a&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,n,i)}else if(t.getGeometryType(n)===s.enumPolyline){const e=Ha();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=i;const s=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(s,n),t.removeGeometry(s)}else if(t.getGeometryType(n)===s.enumMultiPoint){const e=this.topoOperationMultiPoint_();t.swapGeometry(e,n),t.removeGeometry(e)}else r("");return!0}unsplitPolylineExact(e){return o(0),new I}planarSimplifyPolylines(e,t,n,r,i){for(let _=e.getFirstGeometry();_!==M;_=e.getNextGeometry(_)){const t=e.getGeometryType(_);o(t===s.enumPolyline)}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)}{const s=Ia(t.add(a));e.filterClosePoints(s,!1,!1,!1,M)}if(this.m_topoGraph=new tn,4!==i&&5!==i)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;else n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const l=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,l,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return o(n&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,r,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(l);o(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0;const u=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),r);null!==m&&m.stitchCurves(e,u,h,!0);const c=e.getGeometry(u);return n||c.getImpl().setIsSimple(4,t.total()),c}planarSimplifyMultiPoints(e,t,n,r){for(let l=e.getFirstGeometry();l!==M;l=e.getNextGeometry(l)){const t=e.getGeometryType(l);o(t===s.enumMultiPoint)}this.m_topoGraph=new tn,4!==r&&5!==r?(ya(e,t,this.m_progressTracker,!0,!1),n=!1):n=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();const i=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,i,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return o(n),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const a=this.m_topoGraph.getGeometryID(i);o(a>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=a+1,this.m_maskLookup[a]=!0;const h=this.topoOperationMultiPoint(),m=e.getGeometry(h);return n||m.getImpl().setIsSimple(4,t.total()),m}planarSimplifyPolygons(e,t,n,r,i,a){for(let f=e.getFirstGeometry();f!==M;f=e.getNextGeometry(f)){const t=e.getGeometryType(f);o(t===s.enumPolygon||t===s.enumPolyline&&n)}let h=0,m=0,l=null;if(e.hasCurves()&&!e.hasSegmentParentage()){l=new fa;const s=e.getEnvelope2D(this.m_progressTracker);m=da(t.total());const n=_a(t.total(),s);h=pa(n,m),aa(e,n,t.total(),12e3,l,null,this.m_progressTracker)}if(a){ya(e,t.add(h),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==M;t=e.getNextGeometry(t))e.getGeometryType(t)===s.enumPolygon&&er(e,t,-1,!1,M,this.m_progressTracker)}if(this.m_topoGraph=new tn,a||4===i||5===i)r=!1;else if(null===l&&r){const s=new Dn(this.m_progressTracker,!1);s.sweepVertical(e,t.total()),s.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),r=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(h),this.m_progressTracker,!0,!1),r=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const g=e.getFirstGeometry();if(n?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,g,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,g,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return o(r&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,n,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const u=this.m_topoGraph.getGeometryID(g);o(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&&n,_=c;let d=this.topoOperationPolygonPolygon_(g,M,M,_);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,M,M,!1)}null!==l&&l.stitchCurves(e,d,m,!0);const p=e.getGeometry(d);return p.setFillRule(0),r?p.getImpl().setIsSimple(3,0):(p.getImpl().setIsSimple(4,t.total()),p.getImpl().updateOGCFlagsProtected()),p}planarSimplify3DImpl_(e,t,s,n,r){return o(0),{}}planarSimplifyImpl_(e,t,n,i,o,a,h,m){if(e.isEmpty())return e.clone();const l=e.getGeometryType(),g=new G,u=g.addGeometry(e);if(Te(o)&&l===s.enumPolygon&&(n=!1,g.setFillRule(u,0)),m&&(e.hasAttribute(1)&&g.replaceNaNs(1,0),g.removeNaNVertices()),l===s.enumPolygon||l===s.enumPolyline&&n)return this.planarSimplifyPolygons(g,t,n,i,o,!1);if(l===I.type){const e=Ha();return e.allCrossRoadsImpassable=!0,e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=h,this.planarSimplifyPolylines(g,t,i,e,o)}if(l===s.enumMultiPoint)return this.planarSimplifyMultiPoints(g,t,i,o);r("what else?")}}function Qa(e,t,s,n){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return n?e.createInstance():new fe({copy:e});const i=[new Qe],o=[0],a=2===t.getDimension();return 1!==t.getDimension()&&2!==t.getDimension()&&r(""),i[0]=e.getXY(),a?Wo(t,i,1,s.total(),o):jo(t,i,1,s.total(),o),0===o[0]?e.createInstance():e}function Ja(e,t,s,n){const i=e.createInstance(),o=lt(Qe,100),a=new Array(100),h=e.getPointCount();let m=!0;const l=2===t.getDimension();1!==t.getDimension()&&2!==t.getDimension()&&r("");for(let r=0;r<h;){const n=e.queryCoordinates(o,o.length,r,-1)-r;l?Wo(t,o,n,s.total(),a):jo(t,o,n,s.total(),a);let h=0;for(let t=0;t<n;t++){0===a[t]&&(m&&(m=!1,i.addPoints(e,0,r)),h!==t&&i.addPoints(e,r+h,r+t),h=t+1)}m||h===n||i.addPoints(e,r+h,r+n),r+=n}return m?e:i}function $a(e,t,n,r){const i=e.getGeometryType();if(i===s.enumEnvelope){const t=new v({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(i===s.enumPoint&&("|"===r||"^"===r)){const t=new N({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(i===s.enumLine){const t=new I({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(i===s.enumMultiPoint&&"-"===r&&t.getGeometryType()===s.enumPoint){const t=new fe({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(i===s.enumMultiPoint&&"&"===r&&t.getGeometryType()===s.enumPoint){const t=new fe({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function eh(t){const n=t.getGeometryType();if(n===s.enumEnvelope){const e=new v({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(n===s.enumPoint){const e=new N({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(Da(n)){const e=new I({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return n!==s.enumMultiPoint&&n!==s.enumPolyline&&n!==s.enumPolygon&&e("Unexpected geometry type"),t}function th(e,t,s,n){const r=s===M?e.getClusterHalfEdge(t):s;let i=r;o(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!==M;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===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===M?M: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===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),h=s===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),m=n===M?M: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===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;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!==M){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!==M;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===M||o===M?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 s=this.m_rShape.getFirstPath(this.m_cuttee);s!==M;s=this.m_rShape.getNextPath(s)){const e=this.m_rShape.getPathSize(s);let t=this.m_rShape.getFirstVertex(s);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(s);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 s=this.m_rShape.getFirstPath(this.m_cuttee);s!==M;s=this.m_rShape.getNextPath(s)){let t=this.m_rShape.getFirstVertex(s);const n=this.m_rShape.isClosedPath(s),r=this.m_rShape.getPathSize(s)+(n?1:0);let i=1,o=32;for(let s=this.m_rShape.getNextVertex(t);i<r;++i,t=s,s=this.m_rShape.getNextVertex(s)){const n=e(t,s);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=n),32!==o&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,o|n)}t=this.m_rShape.getLastVertex(s);let a=32;i=1;for(let s=this.m_rShape.getPrevVertex(t);i<r;++i,t=s,s=this.m_rShape.getPrevVertex(s)){const n=e(s,t);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=n),32!==a&&this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,a|n)}}let t=M,n=M,r=32;const i=this.m_rShape.hasSegmentParentage(),o=new F;for(let a=this.m_rShape.getFirstPath(this.m_cuttee);a!==M;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=M,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!==r?(t!==M&&(g=this.m_rShape.addVertex(n,l),i&&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,r)),t=this.m_rShape.createGeometry(s.enumPolyline),n=this.m_rShape.insertPath(t,M),r=e,u=!0):this.m_rShape.getUserIndex(l,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==e&&(g=this.m_rShape.addVertex(n,l),i&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),n=this.m_rShape.insertPath(t,M),u=!0),g=this.m_rShape.addVertex(n,l);const h=this.m_rTopoGraph.getClusterFromVertex(l);!u&&i&&this.m_rTopoGraph.isBreakNode(h)&&this.m_rShape.setSegmentParentageBreakVertex(g,!0);const m=this.m_rTopoGraph.getHalfEdgeFromVertex(l);if(i){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(n,l),i&&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,r),t=M,n=M,r=32}}}function nh(e,t,s){return new Ka(s).linesToPolygonsImpl(e,t)}function rh(e,t,i,o,a){if(o&&(o.m_reason=0,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),e.isEmpty())return 5;const h=e.getGeometryType();if(h===s.enumPoint)return mh(e,o);const m=me(t,e,!1).total();if(h===s.enumEnvelope){const t=e,s=new C;return t.queryEnvelope(s),s.isDegenerate(m)?(o&&(o.m_reason=4,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),0):5}if(n(h)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),oh(n,t,i,o,a)}const l=[0],g=e.getImpl().getIsSimple(m,l);let u=i?-1:g;if(ce(u)||0===u)return u;const c=new Ph(e,t,u,a,!1);h===s.enumMultiPoint||h===s.enumPolyline||h===s.enumPolygon?u=c.isSimplePlanarImpl():r("");return e.getImpl().setIsSimple(u,m),o&&o.assign(c.m_nonSimpleResult),u}function ih(e,t,i,o,a){if(o&&(o.m_reason=0,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),e.isEmpty())return 5;const h=e.getGeometryType();if(h===s.enumPoint)return mh(e,o);const m=me(t,e,!1).total();if(h===s.enumEnvelope){const t=e,s=new C;return t.queryEnvelope(s),s.isDegenerate(m)?(o&&(o.m_reason=4,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),0):5}if(n(h)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),ih(n,t,i,o,a)}p(h),_(h)||g("OGC simplify is not implemented for this geometry type");const l=[0],u=e.getImpl().getIsSimple(m,l);let c=i?-1:u;if(5===c||0===c)return c;const d=new Ph(e,t,c,a,!0);h===s.enumMultiPoint||h===s.enumPolyline||h===s.enumPolygon?(c=d.isSimplePlanarImpl(),ce(c)&&(c=5)):r("");return e.getImpl().setIsSimple(c,m),o&&o.assign(d.m_nonSimpleResult),c}function oh(e,t,i,o,a){if(o&&(o.m_reason=0,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),e.isEmpty())return 5;const h=e.getGeometryType();if(h===s.enumPoint)return mh(e,o);const m=me(t,e,!1).total();if(h===s.enumEnvelope){const t=e,s=C.constructEmpty();return t.queryEnvelope(s),s.isDegenerate(m)?(o&&(o.m_reason=4,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),0):5}if(n(h)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),oh(n,t,i,o,a)}const l=[0],g=e.getImpl().getIsSimple(m,l);let u=i?-1:g;if(-1!==u)return u;const c=new Ph(e,t,u,a,!1);return h===s.enumMultiPoint?u=c.multipointIsSimpleAsFeature():h===s.enumPolyline?u=c.polylineIsSimpleAsFeature():h===s.enumPolygon?u=c.polygonIsSimpleAsFeature():r(""),e.getImpl().setIsSimple(u,m),o&&o.assign(c.m_nonSimpleResult),u}function ah(e,t,i,o){if(e.isEmpty())return e;const a=e.getGeometryType();if(a===s.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===s.enumEnvelope){const s=me(t,e,!0).total(),n=e,r=C.constructEmpty();return n.queryEnvelope(r),r.isDegenerate(s)?n.createInstance():e}if(n(a)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),ah(n,t,i,o)}p(a);const h=me(t,e,!1).total(),m=[0],l=e.getImpl().getIsSimple(h,m),g=i?-1:l;if(ce(g)){if(a===s.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}if((a===s.enumMultiPoint||a===s.enumPolyline)&&g>=1)return e;const u=new Ph(e,t,g,o,!1);let c;return a===s.enumMultiPoint?c=u.multipointSimplifyAsFeature():a===s.enumPolyline?c=u.polylineSimplifyAsFeature():a===s.enumPolygon?c=u.polygonSimplifyAsFeature():r(""),c}function hh(e,t,r,i){if(e.isEmpty())return e;const o=e.getGeometryType();if(o===s.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(o===s.enumEnvelope){const s=e,n=new C;s.queryEnvelope(n);const r=me(t,e,!0).total();return n.isDegenerate(r)?s.createInstance():e}if(n(o)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),hh(n,t,r,i)}p(o),_(o)||g("OGC simplify is not implemented for this geometry type");const a=me(t,e,!1).total(),h=[0],m=e.getImpl().getIsSimple(a,h),l=r?-1:m;if(5===l){if(o===s.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}return Aa(e,me(t,e,!0),!1,l,i,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 Ye{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 Ye{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 Pe,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new Ee,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=me(t,e,!1);this.m_toleranceIsSimple=i,this.m_toleranceIsSimpleClustering=ye(i),this.m_toleranceIsSimpleCracking=Se(i),this.m_toleranceSimplify=me(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 i(e)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?i(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===s.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return o(0),7}generateSortedPairs(e){let t=null;i(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 Ce(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let i=0;i<n;i++)if(this.m_pairs.push(2*i),this.m_pairs.push(2*i+1),this.m_pairIndices.add(2*i),this.m_pairIndices.add(2*i+1),s){for(;i>=t.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const o=new Ie,a={parent:this,workPt:new Qe,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)}};o.sort(this.m_pairIndices,0,2*n,a)}_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(i(e)){const e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===s.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(_(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?be(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 o(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!==Ee.st_nullNode()&&s!==Ee.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!==Ee.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!==Ee.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 G,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new fa;const e=C.constructEmpty();this.m_geometry.queryEnvelope(e);const t=_a(this.m_toleranceSimplify.total(),e),s=new ts;if(la(this.m_editShape,t,this.m_toleranceSimplify.total(),12e3,s,this.m_curveStitcher,null,this.m_progressTracker),0!==s.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(s),!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=U(!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 o(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 Pe(!0);t.fill(-1);let a=-1;const h=new Qe;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 we(e.getPathCount(),0),this.m_pathParentage=new Ce(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 Ce(n,Ee.st_nullNode()),this.m_xyToNode2=new Ce(n,Ee.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!==Ee.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,Ee.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==Ee.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,Ee.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)===Ee.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)===Ee.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!==Ee.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===Ee.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,n,r){let i;return e.getGeometryType()===s.enumLine?i=this.createEdgeLine(e):(i=new lh,i.m_segment=e.clone()),i.m_vertexIndex=t,i.m_pathIndex=n,i.m_flags=0,i.setReversed(r),i}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()===s.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 ve(s,i,n,r)}{const s=e.getXY(),r=t.getXY();return Qe.sqrDistance(s,r)<=n*n}}removeDegenerateSegmentsFromCurvedPath(e,t,s,n){const r=e.hasAttribute(1),i=e.querySegmentIterator();i.resetToPath(t),o(i.nextPath());const a=this.m_toleranceSimplify.total();let h=!1,m=!0;const l=new fe,g=new fe,u=new Qe;for(;i.hasNextSegment();){this.progress_();const e=i.nextSegment();if(Ph.isShortSegment(e,r,a,s))if(h){if(e.queryEnd(g),Ph.isShortSegmentPoints(l,g,r,a,s))continue;m&&(n.startPathPoint(l),m=!1),e.queryEnd(l),n.lineToPoint(l),h=!1}else u.assign(e.getStartXY()),e.queryStart(l),h=!0;else if(h)if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(u,e.getEndXY(),!1),t.setStart(l),Ph.isShortSegment(t,r,a,s))continue;n.addSegment(t,m),m=!1,h=!1}else{if(e.queryEnd(g),Ph.isShortSegmentPoints(l,g,r,a,s))continue;m&&(n.startPathPoint(l),m=!1),n.lineToPoint(g),h=!1}else n.addSegment(e,m),m=!1}if(m)return;if(!h)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),l):e.getPointByVal(e.getPathEnd(t)-1,l);const c=n.querySegmentIterator();c.resetToLastPath(),c.resetToLastSegment();const _=n.getDescription().getAttributeCount()>1;for(o(c.previousPath());c.hasPreviousSegment();){const e=c.previousSegment();if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),l.getXY(),!1),!Ph.isShortSegment(t,r,a,s)){_&&t.setEnd(l);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,l,r,a,s)){const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.lineToPoint(l)}}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=Ke(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,Ne.getDefaultValue(1)),n=s),this.m_multiVertexGeom=e;const r=e.getPointCount(),i=Ke(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?be(this.m_sr,e,!0).total():0,a=[],h=[];let m=null;i&&(m=e.getAttributeStreamRef(1));const l=new fe,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 Qe;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 Qe;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()&&!Te(this.m_knownSimpleResult))return Ma(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const e=new G;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 s=C.constructEmpty();this.m_geometry.queryEnvelope(s);const i=_a(this.m_toleranceSimplify.total(),s);n=da(this.m_toleranceSimplify.total()),r=pa(i,n),aa(e,i,this.m_toleranceSimplify.total(),12e3,t,null,this.m_progressTracker)}if(!Te(this.m_knownSimpleResult)){ya(e,this.m_toleranceSimplify.add(r),this.m_progressTracker,!0,!1)}this.m_geometry.getGeometryType()===s.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()===s.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 it(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=Ne.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=ot(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 ue(e.getGeometryType(),i)}isSimplePlanarDONOTUSE(e,t,s,n,r){const i=rh(e,t,s,n,r);return ce(i)}executeMany(e,t,s,n){return new Sh(e,t,s,n)}execute(e,t,s,n){const i=new $t([e]),o=this.executeMany(i,t,s,n).next();return o||r("null geometry"),o}}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(t){if(t||e(""),t.getGeometryType()===s.enumGeometryCollection){const e=V(t,-1),s=(new Eh).executeMany(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=t.createInstance();for(let t=s.next();null!=t;t=s.next())n.addGeometry(t);return n}return ah(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}function Ch(e,t,n){const r=new C;e.queryEnvelope(r);const i=new C;t.queryEnvelope(i);const o=new C(i);if(o.inflate(2*n),!o.isIntersecting(r))return 4;const a=e.getGeometryType(),h=t.getGeometryType();if(a===s.enumEnvelope&&r.containsEnvelope(o))return 1;if(h===s.enumEnvelope){const e=new C(r);if(e.inflate(2*n),i.containsEnvelope(e))return 2}return 0}class Ih{constructor(e,t,n,r){this.m_intersectorGeom=null,this.m_sr=null,this.m_dimensionMask=-1,this.m_progressTracker=null,this.m_intersectorGeomType=s.enumUnknown,this.m_geomIntersectorEmptyGeom=null,this.m_intersectorGeom=e,this.m_sr=t,this.m_dimensionMask=n,this.m_progressTracker=r,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){const t=this.tryFastImplementation(e);if(null!==t)return t;const s=_e(this.m_intersectorGeom,e),n=de(this.m_sr,s,!0).total(),r=C.constructEmpty();this.m_intersectorGeom.queryEnvelope(r);const i=C.constructEmpty();e.queryEnvelope(i),r.inflateCoords(2*n,2*n),r.intersect(i),r.inflateCoords(100*n,100*n);const o=0;let a=Zt(this.m_intersectorGeom,r,o,0,this.m_progressTracker),h=Zt(e,r,o,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(a=rt(h,h=a)),za(h,a,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 s=_e(this.m_intersectorGeom,e),n=de(this.m_sr,s,!0).total(),r=C.constructEmpty();this.m_intersectorGeom.queryEnvelope(r);const i=C.constructEmpty();e.queryEnvelope(i),r.inflateCoords(2*n,2*n),r.intersect(i),r.inflateCoords(100*n,100*n);const o=0;let a=Zt(this.m_intersectorGeom,r,o,0,this.m_progressTracker),h=Zt(e,r,o,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(a=rt(h,h=a));const m=Wa(h,a,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,m)}init(e,t,s,n=null){o(0)}static intersectPoints(e,t,s){const n=_e(e,t);return La(e,t,de(s,n,!0))}tryFastImplementation(e){const t=e.getGeometryType();if(this.m_intersectorGeomType===s.enumPoint&&t===s.enumPoint){const t=Ih.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const e=new N({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===s.enumEnvelope&&this.m_intersectorGeomType===s.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const t=e,s=this.m_intersectorGeom,n=new pe({copy:t});return n.intersect(s),n}const n=_e(e,this.m_intersectorGeom),i=de(this.m_sr,n,!0),o=e.isEmpty(),a=this.m_intersectorGeom.isEmpty();let m=o||a;if(!m){const t=Ch(this.m_intersectorGeom,e,i.total());if(4===t)m=!0;else{if(2&t)return this.m_intersectorGeom;if(1&t)return e}}if(m){const n=h(t),r=h(this.m_intersectorGeomType);return n<r?Ih.ReturnEmpty(e,o):n>r||0===n&&t===s.enumMultiPoint&&this.m_intersectorGeomType===s.enumPoint?this.ReturnEmptyIntersector():Ih.ReturnEmpty(e,o)}if(t===s.enumEnvelope&&0===h(this.m_intersectorGeomType)||this.m_intersectorGeomType===s.enumEnvelope&&0===h(t)){const n=t===s.enumEnvelope?e:this.m_intersectorGeom,r=t===s.enumEnvelope?this.m_intersectorGeom:e,o=C.constructEmpty();return n.queryEnvelope(o),Zt(r,o,i.total(),0,this.m_progressTracker)}if(0===h(t)&&h(this.m_intersectorGeomType)>0||h(t)>0&&0===h(this.m_intersectorGeomType)){if(t===s.enumMultiPoint)return Oa(e,this.m_intersectorGeom,i);if(t===s.enumPoint)return Xa(e,this.m_intersectorGeom,i);if(this.m_intersectorGeomType===s.enumMultiPoint)return Oa(this.m_intersectorGeom,e,i);if(this.m_intersectorGeomType===s.enumPoint)return Xa(this.m_intersectorGeom,e,i);r("")}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 N({vd:e})),n++):s.shift(),2&t?(s[n]||(s[n]=new I({vd:e})),n++):s.splice(n,1),4&t?s[n]||(s[n]=new v({vd:e})):s.splice(n,1),new $t(s)}}class bh extends es{constructor(t,s,n,r,i){super(),this.m_smallCursor=null,this.m_progressTracker=r,this.m_geomIntersector=s.next(),this.m_intersector=new Ih(this.m_geomIntersector,n,i,r),this.m_index=-1,this.m_inputGeoms=t,this.m_dimensionMask=i,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&e("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(t(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,n){if(!this.canAccelerateGeometry(e))return!1;me(t,e,!0);let r=0;return e.getGeometryType()!==s.enumPolygon&&e.getGeometryType()!==s.enumPolyline||!b(e)||0===n||(r|=e.getImpl().buildQuadTreeAccelerator(n)?1:0),!!r}canAccelerateGeometry(e){return b(e)}supportsCurves(){return!0}executeMany(e,t,s,n,r=-1){return new bh(e,t,s,n,r)}execute(e,t,n,i){if(e.getGeometryType()===s.enumPoint&&t.getGeometryType()===s.enumPoint)return Ih.intersectPoints(e,t,n);const o=new $t([e]),a=new $t([t]),h=this.executeMany(o,a,n,i,-1).next();return h||r("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(t,r,o,a){if(t&&r&&r.isPannable()||e("fold_into_360_range_geodetic"),t.isEmpty())return t;if(4===o)return Dh(t,r,a);let h=t;const m=h.getGeometryType();if(i(m)){h=Al(t,r);const e=new C;h.queryEnvelope(e);const s=de(r,e,!1).total(),n=r.getPannableExtent();let i=Math.floor((e.xmin-n.xmin)/n.width())*n.width()+n.xmin,a=h;for(;i<e.xmax;)i>e.xmin+s&&i<e.xmax-s&&(a=Hl(a,r,o,!0,i)),i+=n.width();h=a}else{if(m===s.enumEnvelope){const e=new v({vd:h.getDescription()});return e.addEnvelope(h,!1),Gh(e,r,o,a)}if(n(m)){const e=new I({vd:h.getDescription()});return e.addSegment(h,!0),Gh(e,r,o,a)}}return Dh(h,r,a)}function Dh(t,r,i){if(t&&r&&r.isPannable()||e(""),t.isEmpty())return t;let o;const a=t.getGeometryType();if(a===s.enumEnvelope){const e=new v({vd:t.getDescription()});e.addEnvelope(t,!1),o=e}else if(n(a)){const e=new I({vd:t.getDescription()});e.addSegment(t,!0),o=e}else o=t;const h=Al(o,r);return h.isEmpty()?h:vl(h,r,0,h!==t,0,i)}function Vh(e,t,s){if(!t.isPannable()||e.isEmpty())return e;const n=t.getPannableExtent().width(),r=.5*n,o=e.queryInterval(0,0);if(o.width()<r||!_(e.getGeometryType())){if(Number.isNaN(s))return e;const t=o.getCenter();if(Math.abs(t-s)<=r)return e;{const r=new jt,i=nt((s-t)/n)*n;r.setShiftCoords(i,0);const o=e.clone();return o.applyTransformation(r),o}}const a=e.getGeometryType(),h=e,m=h.getAttributeStreamRef(0),l=e.clone(),g=l.getAttributeStreamRef(0);let u=0,c=0,d=0,p=i(a)?0:-1;const f=at.constructEmpty();let x=!1;for(let _=0,y=h.getPointCount();_<y;_++){const e=m.read(2*_);_===c&&(i(a)?(0===p&&Number.isNaN(s)&&(x=!0),p>0&&Number.isNaN(s)&&(s=f.getCenter(),x=!1),c=h.getPathEnd(p),p++):c=h.getPointCount(),Number.isNaN(s)?d=e:(d=s,u=0));let t=e-d;Math.abs(t)>r&&(t=nt(t/n)*n,u-=t,Math.abs(u)<.1*n&&(u=0));const o=e+u;g.write(2*_,o),x&&f.mergeCoordinate(o),d=e}return l.notifyModified(),l}const Fh="missing implementation";function Hh(e,t,s,n){const i=t.getCoordinateSystemType();if(0===i){const n=new ac;return t.queryPrecisionDescriptor(n),kh(e,n,t,s)}let o=e;2!==n&&3!==n||!t.isPannable()||(o=Dh(o,t,s));const a=new ac;if(t.queryPrecisionDescriptor(a),o=kh(o,a,t,s),0===n||o.isEmpty())return o;if(1===i){if(1===n){const e=new C;o.queryLooseEnvelope(e);const n=t.getPannableExtent(),r=.01*n.width();return n.xmin=e.xmin-r,n.xmax=e.xmax+r,(new Kt).execute(o,n,t,s)}return o}if(2===i){const e=t.getPCSHorizon();if(1===n||2===n){const n=(new wh).execute(o,e,t,s);return n===e?n.clone():n}return o}if(3===i)return o;r(Fh)}function kh(e,t,s,n){const r=t.getXYGridRange(),i=e.hasAttribute(1),o=e.hasAttribute(2);let a=new at,h=new at;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()),Le(m,a,1,0))}if(o){const t=m.queryInterval(2,0);h.contains(t)||(e===m&&(m=m.clone()),Le(m,h,2,0))}return m}class Ah{constructor(t){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,t||e(""),this.m_projTransform=t,this.m_bClipOutCurvedPoles=!1;const s=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=s.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(s.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),s.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!s.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,s.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!s.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=s.centralMeridianOfOutputGCS,this.m_densificationStepInput=s.densificationStep;const n=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=n.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=n.hasFlag(1073741824),this.m_bClipOutCurvedPoles=n.hasFlag(536870912)}project(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;const n=e.getGeometryType();if(n===s.enumPoint)return this.projectPoint(e,t);const i=this.m_projTransform.getInputSR().getCoordinateSystemType(),o=this.m_projTransform.getOutputSR().getCoordinateSystemType(),a=this.m_projTransform.getInputSR(),h=this.m_projTransform.getOutputSR();if(0===i&&i===o){const t=Uh(a,h),s=e.clone();return s.applyTransformation(t),s}switch(n){case s.enumPolyline:case s.enumPolygon:return this.projectMultiPath(e,t);case s.enumMultiPoint:return this.projectMultiPoint(e,t);case s.enumEnvelope:return this.projectEnvelope(e,t);case s.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:r("")}}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 N({copy:e});const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),a=r.getCoordinateSystemType();if(3===i&&o(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 h=0;3===a&&o(0);const m=2===a;return m?h=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(h=this.m_centralMeridianOfOutputGCS),m&&0!==this.m_outputPCSHorizonClipOption||(s=vl(s,Zu(r),h,!1,0,t)),m&&(s=Sl(s,r,this.m_outputPCSHorizonClipOption,t),Kl(r,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(e,t){const n=e.getGeometryType();return n===s.enumPolygon?this.projectPolygon(e,t):n===s.enumPolyline?this.projectPolyline(e,t):void r("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=at.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){o(e.getGeometryType()===s.enumPolygon),o(!this.m_projTransform.isIdentity()),o(!e.isEmpty());const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),a=r.getCoordinateSystemType(),h=new v({copy:e});3===i&&o(0),3===a&&o(0);const m=2===i,l=2===a,g=m?n.getGCS():n,u=l?r.getGCS():r,c=!l&&!this.m_bDontHackPolesInGeogToGeog;let _=!1,d=Xl(h,n,this.m_inputPCSHorizonClipOption,t);if(d.isEmpty())return d;let p=this.m_densificationStepInput;const f=!Number.isNaN(p);let x;f&&(d=(new Jt).execute(d,p,0,0,t));let y=l?r.getPCSInfo():null,P=Number.NaN;m&&(P=n.getCentralMeridian());const E=null!==r.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const e=d;if(m&&(hg(n,P,e),f)){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,c),f){const e=n.getGCS().getUnitsPerMillimeter();p*=r.getGCS().getUnitsPerMillimeter()/e}x=e}else{let e=new I({vd:d.getDescription()});if(e.addAndExplicitlyOpenAllPaths(d,!1),m){if(hg(n,P,e),f){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(this.m_bClipOutCurvedPoles){const s=n.getPCSInfo(),r=s.getSouthPoleGeometry()===Nc.PE_POLE_LINE_CURVED,i=s.getNorthPoleGeometry()===Nc.PE_POLE_LINE_CURVED;if(r||i){const s=C.constructEmpty();e.queryLooseEnvelope(s),s.inflateCoords(1,1);const n=89.9999*g.getOneDegreeGCSUnit();r&&(s.ymin=-n),i&&(s.ymax=n),e=Qt(e,s,g,0,0,t)}}}if(cg(this.m_projTransform,e,c),f){const e=Zu(n).getUnitsPerMillimeter();p*=Zu(r).getUnitsPerMillimeter()/e}let s=Number.NaN;l?(y=r.getPCSInfo(),s=r.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(s=this.m_centralMeridianOfOutputGCS);let i=Mh(n)|Mh(r),o=10*u.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=10*u.getTolerance(0)),x=Vl(d,n,e,u,s,t,i,o,this.m_bNormalizeOutputGeometry),i=0}if(E&&(o(!r.isPannable()),x=cl(x,r,t)),l){if(!_){const e=u.getPannableExtent().width();if(x.queryInterval(0,0).width()>=e-10*u.getTolerance(0)){const e=y.getNorthPoleLocation(),t=y.getSouthPoleLocation(),s=y.getNorthPoleGeometry(),n=y.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),_||=0!==r}}x=Sl(x,r,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(r,x,this.m_bNormalizeOutputGeometry)}return x.isEmpty()||_&&(x=(new Eh).execute(x,r,!1,t)),x}projectPolyline(e,t){o(e.getGeometryType()===s.enumPolyline),o(!this.m_projTransform.isIdentity()),o(!e.isEmpty());const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),a=r.getCoordinateSystemType(),h=new I({copy:e});3===i&&o(0),3===a&&o(0);const m=2===i,l=2===a;m&&n.getGCS();const g=l?r.getGCS():r,u=!l&&!this.m_bDontHackPolesInGeogToGeog;let c=Xl(h,n,this.m_inputPCSHorizonClipOption,t);if(c.isEmpty())return c;let _=Number.NaN;m&&(_=n.getCentralMeridian());const d=null!==r.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(m&&(hg(n,_,c),f)){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,c,u),f){const e=n.getGCS().getUnitsPerMillimeter();p*=r.getGCS().getUnitsPerMillimeter()/e}x=c}else{const e=new I({vd:c.getDescription()});if(e.addAndExplicitlyOpenAllPaths(c,!1),m&&(hg(n,_,e),f)){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,u),f){const e=n.getGCS().getUnitsPerMillimeter();p*=r.getGCS().getUnitsPerMillimeter()/e}let s=Number.NaN;l?s=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(s=this.m_centralMeridianOfOutputGCS);let i=Mh(n)|Mh(r),o=10*g.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=0),x=Fl(c,n,e,g,s,t,i,o,this.m_bNormalizeOutputGeometry),i=0}return d&&(o(!r.isPannable()),x=cl(x,r,t)),l&&(x=Sl(x,r,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(r,x,this.m_bNormalizeOutputGeometry)),x.isEmpty(),x}projectGeometryCollection(e,t){return o(0),{}}projectEnvelopeHelper(e,t){const s=(e.height()+e.width())/400;if(0!==s){const n=(new Jt).execute(e,s,0,0,t),r=this.projectMultiPath(n,t),i=new pe({vd:e.getDescription()});if(r.isEmpty()){const s=Math.min(e.height(),e.width()),r=me(this.m_projTransform.getInputSR(),e,!0).total();if(s>100*r){const e=C.constructEmpty(),t=de(this.m_projTransform.getOutputSR(),e,!0).total(),n=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(s>100*Math.max(r,t*n))return i}const o=new I;o.addAndExplicitlyOpenAllPaths(n,!1);this.projectMultiPath(o,t).queryEnvelope(i);const a=new N({vd:e.getDescription()});a.reserve(4);const h=new fe;for(let t=0;t<4;t++)e.queryCornerByVal(t,h),a.add(h);const m=this.projectMultiPoint(a,t),l=new pe;return m.queryEnvelope(l),i.merge(l),i}return r.queryEnvelope(i),i}{const s=e.getCenterXY(),n=new fe(s),r=this.projectPoint(n,t),i=new pe({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 o(0),0}transformInPlaceZ(e,t,s,n,r,i){if(this.m_projTransform.isIdentity())return e!==n&&et(n,e,s),t!==r&&wt(r,t,0,0,s),s;const a=this.m_projTransform,h=a.getInputSR(),m=a.getOutputSR(),l=h.getCoordinateSystemType(),u=m.getCoordinateSystemType();if(0===l&&l===u){return Uh(h,m).transformPoints2D(e,s,n),a.isVertical()&&o(0),s}3===l&&g("image: transform_in_place_"),3===u&&g("image: transform_in_place_"),Ll(e,s,n,h,this.m_inputPCSHorizonClipOption),r!==t&&wt(r,t,0,0,s),2===l&&mg(h,0,n,s),fg(this.m_projTransform,n,r,s,!1);let c=0;const _=2===u;_?c=m.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(c=this.m_centralMeridianOfOutputGCS),_&&0!==this.m_outputPCSHorizonClipOption||Nl(n,s,m.getGCS(),c),_&&(wl(n,s,m,this.m_outputPCSHorizonClipOption),Wl(m,n,s,!1));let d=s;for(let o=0;o<s;++o)n[o].isNAN()&&(r&&(r[o]=Number.NaN),d--);return d}}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 o(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(t,s,n){super(),this.m_projTrans=s,this.m_progressTracker=n,this.m_index=-1,t||e(""),this.m_inputGeoms=t}next(){const e=this.m_inputGeoms.next();return null!=e?(x(e),t(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(r,a,h,m,l,g,u=!1){r||e("Geometry.Geodetic_densify.densify");let c=r.getGeometryType();if(t(r),r.isEmpty()||d(c))return r;const _=new Wh;_.m_sr=a,_.m_gcs=a.getGCS(),_.m_transform=_.m_gcs!==a?a.getSRToGCSTransform():null,_.m_progressTracker=g;const p=Hu();let f,x,y;if(_.m_gcs.querySpheroidData(p),_.m_a=p.majorSemiAxis,_.m_eSquared=p.e2,_.m_rpu=_.m_gcs.getUnit().getUnitToBaseFactor(),_.m_gcsTolerance=_.m_gcs.getTolerance(0),_.m_radTolerance=_.m_gcsTolerance*_.m_rpu,_.m_maxLength=m,_.m_maxDeviation=l,_.m_curveType=h,c===s.enumEnvelope){const e=new v({vd:r.getDescription()});e.addEnvelope(r,!1),f=e,c=s.enumPolygon}else if(n(c)){const e=new I({vd:r.getDescription()});e.addSegment(r,!0),f=e,c=s.enumPolyline}else f=r;if(4!==_.m_curveType){if(o(i(c)),x=_.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(f),x.isEmpty())return x;x=Yh(_.m_rpu,x);let e=_.geodeticDensify(x);u||(e=(new qh).foldInto360RangeGeodetic(e,_.m_gcs,_.m_curveType)),y=_.m_transform&&!_.m_transform.isIdentity()?(new qh).execute(e,_.m_transform.getInverse(),g):e}else{let e;if(o(i(c)),a.isPannable())e=Al(f,a);else{const t=a.getPCSHorizon();e=(new wh).execute(f,t,a,g),e===t&&(e=t.clone())}if(x=e,x.isEmpty())return x;y=_.shapePreservingDensify(x)}return y}function Yh(e,t){const s=new C;if(t.queryLooseEnvelope(s),s.width()*e<Math.PI)return t;let n=!1;const r=t.querySegmentIterator(),i=new Qe,o=new Qe;for(;r.nextPath();)for(;r.hasNextSegment();){const t=r.nextSegment();if(i.setCoordsPoint2D(t.getStartXY()),o.setCoordsPoint2D(t.getEndXY()),i.scale(e),o.scale(e),Math.abs(i.x-o.x)>Math.PI){if(!Xh(i,o)){n=!0;break}if(Math.abs(i.x-o.x)>2*Math.PI){n=!0;break}}}if(!n)return t;const a=t.createInstance();a.reserve(t.getPointCount());const h=t.getDescription().getAttributeCount()>1,m=new Qe,l=new Qe,g=new Qe(0,0),u=new Qe(0,0),c=new fe;for(r.resetToFirstPath();r.nextPath();){let t=Number.NaN,s=0;for(;r.hasNextSegment();){const n=r.nextSegment();i.setCoordsPoint2D(n.getStartXY()),o.setCoordsPoint2D(n.getEndXY()),i.scale(e),o.scale(e),Number.isNaN(t)?(s=im(i.x,Number.NaN,s),g.setCoordsPoint2D(i)):g.setCoordsPoint2D(u),t=g.x;if(Xh(i,o)){if(o.x-i.x>2*Math.PI)for(;o.x-i.x>2*Math.PI;)o.x-=2*Math.PI;else if(o.x-i.x<2*-Math.PI)for(;o.x-i.x<2*-Math.PI;)o.x+=2*Math.PI;s=im(o.x,Number.NaN,s),u.setCoordsPoint2D(o)}else m.setCoordsPoint2D(o),gm(m),s=im(m.x,t,s),u.setCoords(s+m.x,m.y);if(Math.abs(u.x-o.x)<.5&&u.setCoordsPoint2D(o),h){n.queryCoord(0,c),l.setCoordsPoint2D(g),l.scale(1/e),c.setXY(l);r.isFirstSegmentInPath()?a.startPathPoint(c):a.lineToPoint(c),r.isLastSegmentInPath()&&!r.isPathClosed()&&(n.queryCoord(1,c),l.setCoordsPoint2D(u),l.scale(1/e),c.setXY(l),a.lineToPoint(c))}else{r.isFirstSegmentInPath()&&a.insertPath2D(-1,null,0,0,!0);const t=a.getPathCount()-1;l.setCoordsPoint2D(g),l.scale(1/e),a.insertPoint2D(t,-1,l),r.isLastSegmentInPath()&&!r.isPathClosed()&&(l.setCoordsPoint2D(u),l.scale(1/e),a.insertPoint2D(t,-1,l))}}}return a}function Rh(e,t,s,n,r,i,o,a,h,m,l,g){const u=new Qe,c=new Qe,_=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,Ct)||!Pc(t.y,Ct))||!(!Pc(e.y,-Ct)||!Pc(t.y,-Ct))}function Lh(e,t){return!(!Pc(e.y,Ct)||Pc(t.y,Ct))||!(!Pc(e.y,-Ct)||Pc(t.y,-Ct))}function zh(e,t){return!(!Pc(t.y,Ct)||Pc(e.y,Ct))||!(!Pc(t.y,-Ct)||Pc(e.y,-Ct))}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 F,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 Qe,g=new Qe,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 F,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 N;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 fe;e.getPointByVal(r,s),t.add(s),a=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(o&&!a){const s=new fe;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 fe;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(e,t,s,n,r,i,o,a,h,m,l,g,u){const c={stack:[],error:void 0,hasError:!1};try{const _=zt(c,new Cc,!1),d=zt(c,new Cc,!1),p=zt(c,new Cc,!1);Dc.geodeticDistance(e,t,n.x,n.y,r.x,r.y,p,_,d,s);const f=p.val,x=_.val,y=d.val;let P=x,E=y;P<0&&(P+=2*Math.PI),E<0&&(E+=2*Math.PI),h&&(h[0]=P),m&&(m[0]=E);let S=Number.NaN,C=Number.NaN;if(null!==l){const s=Vc.q90(e,t),r=Vc.q(e,t,n.y);S=(s-r)/f,C=(s+r)/f}const I=Lh(n,r),b=zh(n,r),w=I||b,v=mm(n,r,a),N=zt(c,new pt(new Cc,new Cc),!1),T=new Qe,G=new Qe,D=new Qe;u[0]=im(n.x,Number.NaN,u[0]);let V=u[0];if(f<=i)return g.push(n.clone()),u[0]=im(r.x,Number.NaN,u[0]),null!=l&&l.push(0),w?(I&&om(n,r,l,g),b&&am(n,r,l,g)):v?hm(n,r,x,S,C,l,g):o>0&&(G.setCoords(n.x-V,n.y),T.setCoords(r.x-u[0],r.y),V=Jh()),g.push(r.clone()),f;const F=1+Math.ceil(f/i),H=f/(F-1),k=new Qe;g.push(n.clone()),k.setCoordsPoint2D(n),G.setCoords(n.x-u[0],n.y),null!==l&&l.push(0);for(let i=1;i<F;i++){let h;if(i<F-1){const r=i*H;Dc.geodeticCoordinate(e,t,n.x,n.y,r,x,N.at(0),N.at(1),s),T.setCoords(N.at(0).val,N.at(1).val),u[0]=im(T.x,k.x,u[0]),D.setCoords(u[0]+T.x,T.y),h=i/(F-1)}else u[0]=im(r.x,Number.NaN,u[0]),T.setCoords(r.x-u[0],r.y),D.setCoordsPoint2D(r),h=1;w?(1===i&&I&&om(n,D,l,g),i===F-1&&b&&am(k,r,l,g)):v?lm(k,D,a)&&(n.x<r.x?k.x>D.x&&(u[0]+=2*Math.PI,D.setCoords(u[0]+T.x,T.y)):k.x<D.x&&(u[0]-=2*Math.PI,D.setCoords(u[0]+T.x,T.y)),hm(k,D,x,S,C,l,g)):o>0&&Jh(),g.push(D.clone()),null!=l&&l.push(h),k.setCoordsPoint2D(D),G.setCoordsPoint2D(T),V=u[0]}return f}catch(_){c.error=_,c.hasError=!0}finally{Wt(c)}}function Qh(e,t,s,n,r,i,a,h,m,l){o(0)}function Jh(e,t,s,n,r,i,a,h,m,l,g,u,c,_,d){return o(0),0}function $h(e,t,s,n){const r=ds(e,t,s),i=ds(e,t,n);return Re.distance(r,i)}function em(e,t,s,n,r,i,a,h){const m=new Array,l=lt(Array,8);let g=2,u=r.getCoord2D(i);l[0][0]=u.x,l[0][1]=u.y,u=r.getCoord2D(a),l[1][0]=u.x,l[1][1]=u.y;const c=e=>{if(null!==s){const t=wc.projToGeog(s,e,l);o(t===e)}for(const t of l)t[0]*=n,t[1]*=n};c(2),m.push(ds(e,t,new Qe(l[0][0],l[0][1]))),m.push(ds(e,t,new Qe(l[1][0],l[1][1])));let _=Re.distance(m[0],m[1]);if(_>h)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=ft(i,a,e*s);r.queryCoord2D(t,u),l[n][0]=u.x,l[n][1]=u.y,n++}c(n);let p=1;for(let r=0;r<n;++r)m.splice(p,0,ds(e,t,new Qe(l[r][0],l[r][1]))),p++;p=0;let f=m[p];p++;let x=0;for(;p!==m.length;++p){const e=m[p];x+=Re.distance(f,e),f=e}if(x>h)return x;if(d=x-_,o(d>=0||Math.abs(d)<1e-14*x),d<0&&(d=0),_=x,x+d<=h)return x+d;g=2*g-1}return _+d}function tm(e,t,s,n,r,i,a,h,m){const l=n.isCurve(),g=Fs(e,t)*Math.PI*179/180;let u=i;i>0&&!(i>g)||(u=g);const c=a,_=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 Qe,S=new Qe;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),m.push(y.clone()),null!==h&&h.push(I);const N=r.isPannable(),T=y.clone(),G=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let D=5;l||(_?(G[0]=.5,G[1]=.25,G[2]=.75,D=3):D=1),o(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 a=v.at(-1);let g=!1,c=Number.NaN;const y=em(e,t,f,s,n,I,a,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 Qe,H=new Qe;let k=!1;if(!_&&P&&P&&(k=!0),n.calculateSubLength(I,a)<=x&&(k=!0),!k)for(let h=0;h<D;h++){const m=ft(I,a,G[h]),u=new Qe;n.queryCoord2D(m,u);const f=V(u);if(0===h&&(c=m,F.setCoordsPoint2D(u),H.setCoordsPoint2D(f),!P)){g=!0;break}if(o(_),p&&Math.abs(E.x-f.x)>=Math.PI){g=!0;break}let x=new Qe,y=new Qe;l?(x=Qe.lerp(T,i,G[h]),y=V(x)):(x=u.clone(),y=f.clone());const C=Ss(e,t,E,S,G[h]),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=ft(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 at(I,a),-1);let i=n.getCoord2D(s);i=V(i);let o=$h(e,t,i,C);if(o>d){if(o<4*d){const s=ds(e,t,i),n=ds(e,t,E),r=ds(e,t,S),{second:a}=vs(e,t,s,n,r,2,null);o=a}if(o>d){g=!0;break}}else if(l){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(),m.push(i.clone()),C+=y,null!==h&&h.push(C),T.setCoordsPoint2D(i),E.setCoordsPoint2D(S),I=a)}if(null!==h){const e=1/C;for(let t=0;t<h.length;t++)h[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 Qe;r.setCoords(t.x,Ct),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}else{const r=new Qe;r.setCoords(t.x,-Ct),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 Qe;r.setCoords(e.x,Ct),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}else{const r=new Qe;r.setCoords(e.x,-Ct),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(Ct-e.y>0){const t=new Qe;t.setCoords(e.x,Ct),o.push(t),null!==i&&i.push(n)}if(Ct-t.y>0){const e=new Qe;e.setCoords(t.x,Ct),o.push(e),null!==i&&i.push(n)}}else{if(Ct+e.y>0){const t=new Qe;t.setCoords(e.x,-Ct),o.push(t),null!==i&&i.push(r)}if(Ct+t.y>0){const e=new Qe;e.setCoords(t.x,-Ct),o.push(e),null!==i&&i.push(r)}}}function mm(e,t,s){return!(!lm(e,t,s)||Pc(e.y,Ct)||Pc(e.y,-Ct)||Pc(t.y,Ct)||Pc(t.y,-Ct))}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(e,t,s,n){const r={stack:[],error:void 0,hasError:!1};try{const i=[s.x],o=[s.y-n],a=[s.x],h=[s.y+n];Vs(i,o),Vs(a,h);const m=zt(r,new Cc,!1),l=zt(r,new Cc,!1);Dc.greatEllipticDistance(e,t,s.x,s.y,i[0],o[0],m,null,null),Dc.greatEllipticDistance(e,t,s.x,s.y,a[0],h[0],l,null,null);return Math.min(m.val,l.val)}catch(i){r.error=i,r.hasError=!0}finally{Wt(r)}}function cm(e,t,s,n,r){const i=new C;s.queryEnvelope(i);const o=me(null,s,!0).total();if(t.xmin-i.xmin<=o&&i.xmax-t.xmax<=o)return s;const a=t.width();let h=0;for(;t.xmin+h*a<i.xmin;)h++;for(;t.xmin+h*a>i.xmin;)h--;const m=h*a,l=new jt;l.setShiftCoords(-m,0);const g=s;g.applyTransformation(l);const u=new C;g.queryEnvelope(u);let c=null;if(u.xmax>t.xmax){let s=0;const n=new C;n.setCoords({env2D:t}),n.ymin-=1,n.ymax+=1;let i=g;for(;n.xmin<u.xmax;){u.xmax>n.xmax&&(i=Hl(i,e,2,!0,n.xmax));const o=We(i,n),h=de(null,o,!0).total(),m=Zt(i,n,h,Number.NaN,r);null===c?c=m===i?m.clone():m:(l.setShiftCoords(-s*a,0),m.applyTransformation(l),c.add(m,!1)),s++,n.xmin=n.xmax,n.xmax=t.xmax+s*a}}else c=g;return c}class _m{constructor(e,t){this.m_basisX=new Re,this.m_basisY=new Re,this.m_normal=new Re,o(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),a=Math.sin(n),h=Math.cos(r),m=Math.sin(r);this.m_cartCenter3D=fs(this.m_a,this.m_e2,i,a,h,m),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),Re.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(Qe.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(Qe.construct(0,.5*-Math.PI/this.m_rpu))}project(t){const s=t.getGeometryType();if(_(s)){x(t);const e=t;return this.projectMultiVertex(e)}e("Gnomonic.project")}unproject(t,n,r){const o=t.getGeometryType();if(_(o)){x(t);let e=t;const a=[];if(o===s.enumPolygon){const t=e.getPathCount();for(let s=0;s<t;s++){const t=e.calculateRingArea2D(s);a.push(t)}}return this.unprojectMultiVertex(n,e),i(o)?(Cm(this.m_gcs,0,e),dm(a,this.m_gcs,0,e,r)):e=vl(e,this.m_gcs,0,!0,0,r),e}e("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 Qe.construct(Number.NaN,Number.NaN);const r=this.m_d/n,i=s.mul(r).sub(this.m_cartCenter3D),o=new Qe;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 Qe,r=new Qe;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 Qe;r&&Qe.sqrDistance(e,this.m_northPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*Math.PI),t.scale(1/this.m_rpu)):i&&Qe.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,i){const o=r.getGeometryType(),a=t.getPannableExtent();let h=r,m=!1,l=!1;if(o===s.enumPolygon){const s=new C,r=Qe.construct(n,0);s.setCoords({env2D:a}),s.centerAt(r),m=pm(e,t,s,h,i);const o=Sm(t,s,h,i);o!==h&&(l=!0),h=o}else h=(new qh).foldInto360RangeGeodetic(h,t,2);o===s.enumPolygon&&(m||l)&&(h=(new Eh).execute(h,t,!1,i)),h!==r&&(r.setEmpty(),r.add(h,!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 s=new C;t.queryEnvelope(s);const n=Pc(e.ymax,s.ymax),r=Pc(e.ymin,s.ymin),i=n||r;return!!i&&(ym(e,t),i)}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 v({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 s=new v,n=new C;for(let r=0;r<t.getPathCount();r++){t.queryPathEnvelope(r,n);let i=Pc(e.ymax,n.ymax),o=Pc(e.ymin,n.ymin);if(!(i||o)){s.addPath(t,r,!0);continue}s.insertPath2D(-1,null,0,0,!0);const a=t.getPathStart(r),h=t.getPathEnd(r),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 n=t.getXY(g);i=Pc(e.ymax,n.y),o=Pc(e.ymin,n.y);const h=a+(g+1-a)%m;if(i||o){let i=Qe.construct(c,n.y);s.insertPoint2D(r,-1,i);const o=t.getXY(h),a=Pc(e.ymax,o.y),m=Pc(e.ymin,o.y);a||m||(i=Qe.construct(o.x,n.y),u?s.setXYNoCurves(s.getPointCount()-1,i):s.insertPoint2D(r,-1,i)),u=!0}else s.insertPoint2D(r,-1,n),c=n.x,u=!1;g=h}while(g!==l)}t.setEmpty(),t.add(s,!1)}function Pm(e,t,s,n,r,i){const o=new v,a=new v,h=new jt,m=r.getXY(r.getPathStart(n)),l=r.getXY(r.getPathEnd(n)-1),g=s.width(),u=.5*g,c=new C;r.queryEnvelope(c);const _=Math.ceil(c.width()/g)+1;let d,p;m.x>l.x?(d=-g,p=e?s.ymin:s.ymax):(d=g,p=e?s.ymax:s.ymin),h.setShiftCoords(d,0),o.addPath(r,n,!0),a.add(o,!1);const f=new fe;for(let C=0;C<_;C++)a.applyTransformation(h),a.getPointByVal(0,f),o.lineToPoint(f),o.addSegmentsFromPath(a,0,0,a.getSegmentCount()-1,!1);const x=o.getXY(0),y=o.getXY(o.getPointCount()-1);x.y=p,y.y=p,o.lineTo(y);const P=new Qe;for(P.setCoordsPoint2D(y),P.x-=.5*d;Math.abs(P.x-x.x)>u;)o.lineTo(P),P.x-=.5*d;o.lineTo(x);const E=s.getCenter().x,S=new C;o.queryEnvelope(S);let I=0;const b=S.getCenter().x;b-E>u?I=-Math.ceil((b-E-u)/g):E-b>u&&(I=Math.ceil((E-b-u)/g)),0!==I&&(h.setShiftCoords(I*g,0),o.applyTransformation(h));const w=new G,N=w.addGeometry(o);kl(w,N,t,0,2,!0,s.xmin),kl(w,N,t,0,2,!0,s.xmax);const T=w.getGeometry(N),D=We(T,s);D.inflateCoords(0,1);const V=de(null,D,!0);return Zt(T,s,V.total(),Number.NaN,i)}function Em(e,t,s,n,r){const i=t.width(),o=.5*i,a=t.getCenter().x,h=new C;n.queryPathEnvelope(s,h);let m,l=0,g=h.getCenter().x;if(g-a>o?l=-Math.ceil((g-a-o)/i):a-g>o&&(l=Math.ceil((a-g-o)/i)),0!==l){const e=new jt;e.setShiftCoords(l*i,0),n.getImpl().applyTransformationToPath(e,s),n.queryPathEnvelope(s,h),g=h.getCenter().x}const u=new C;t.containsExclusiveEnvelope(h)?(m=!1,u.setCoords({env2D:t})):(m=!0,u.setCoords({env2D:t}),u.xmin-=i,u.xmax+=i);let c=n.createInstance();c.addPathPoint2D(null,0,!0);const _=new Qe;if(_.setCoords(u.xmin,u.ymin),c.insertPoint2D(0,-1,_),_.setCoords(u.xmin,u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(.5*(u.xmin+u.xmax),u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(u.xmax,u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(u.xmax,u.ymin),c.insertPoint2D(0,-1,_),_.setCoords(.5*(u.xmin+u.xmax),u.ymin),c.insertPoint2D(0,-1,_),m){c.addPath(n,s,!0);const o=new jt;g<a?o.setShiftCoords(i,0):o.setShiftCoords(-i,0),n.getImpl().applyTransformationToPath(o,s),c.addPath(n,s,!0);const h=new G,m=h.addGeometry(c);kl(h,m,e,0,2,!0,t.xmin),kl(h,m,e,0,2,!0,t.xmax),c=h.getGeometry(m);const l=We(c,t);l.inflateCoords(0,1);const u=de(null,l,!0).total();c=Zt(c,t,u,Number.NaN,r)}else c.addPath(n,s,!0);return c}function Sm(e,t,s,n){const r=new C;s.queryEnvelope(r);const i=me(null,s,!0).total();if(t.xmin-r.xmin<=i&&r.xmax-t.xmax<=i)return s;const o=s.createInstance();let a=s.createInstance();const h=new C,m=s.getPathCount();for(let l=0;l<m;l++)s.queryPathEnvelope(l,h),t.xmin-h.xmin<=i&&h.xmax-t.xmax<=i?o.addPath(s,l,!0):(a.setEmpty(),a.addPath(s,l,!0),a=cm(e,t,a,!0,n),o.add(a,!0));return o}function Cm(e,t,s){const n=e.getPannableExtent(),r=Qe.construct(t,0);n.centerAt(r);const i=n.width(),o=.5*i,a=new Qe;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 Qe;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 G,u=g.addGeometry(t),c=g.getFirstPath(u);let _=-1,d=!0;const p=new Qe,f=new fe;let x=M;const y=Gm*r/360;for(let P=g.getFirstVertex(c);P!==M;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!==M?g.getNextVertex(x):g.getFirstVertex(c);const t=g.getPrevVertex(P);for(;e!==t;)e=g.removeVertex(e,!1);if(x!==M){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=ft(e.x,s.x,.5),g.setXY(n,e)}}}x=M}if(e&&(m.y=xt(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!==M){let e=g.getNextVertex(x);for(;e!==M;)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,M,f),Math.abs(s.x-n.x)>y)){const e=g.insertVertex(c,t,f);s.x=ft(s.x,n.x,.5),g.setXY(e,s)}}return t.assignCopy(g.getGeometry(u)),!0}function wm(e,t){let s=new v({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=lt(Qe,100),o=new Re(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,n,i,o){if(!t.isPannable()||e.isEmpty())return e;const a=e.getGeometryType();a===s.enumGeometryCollection&&g("not yet impl for geometry collection");const h=t.getPannableExtent();Number.isNaN(n)&&(n=h.getCenterX());const m=h.width(),l=.5*m,u=o>0,c=e.queryInterval(0,0);if(!u&&c.width()<l||!_(e.getGeometryType())){const t=c.getCenter();if(Math.abs(t-n)<=l)return e;{const s=new jt,r=nt((n-t)/m)*m;s.setShiftCoords(r,0);const i=e.clone();return i.applyTransformation(s),i}}if(a===s.enumPolygon){let s=new I({vd:e.getDescription()});s.addAndExplicitlyOpenAllPaths(e,!1),u&&(s=Oh(s,t,2,o,Number.NaN,null,!0));const r=[];if(!i){{let n=e;u&&(n=new v,n.add(s,!1));const i=Nm(e,t,r);if(i)i<0&&s.reverseAllPaths();else{const e=n.getPathCount();for(let t=0;t<e;t++)r.push(n.calculateRingArea2D(t)>0)}}i=r}return new Dm(null,i,s,null,t,n,3,0,null).geoNormalizePolygonGeometry(!0)}if(a===s.enumPolyline){let s=new I({vd:e.getDescription()});s.addAndExplicitlyOpenAllPaths(e,!1),u&&(s=Oh(s,t,2,o,Number.NaN,null,!0));return new Dm(null,null,s,null,t,n,3,0,null).geoNormalizePolylineGeometry(!0)}if(a===s.enumMultiPoint){const t=e,s=t.getAttributeStreamRef(0);let r,i=null,o=n,a=0;const h=.1*m;for(let n=0,g=t.getPointCount();n<g;n++){const t=s.read(2*n);let g=t-o;if(Math.abs(g)>l&&(g=nt(g/m)*m,a-=g,Math.abs(a)<h&&(a=0)),0!==a){i||(r=e.clone(),i=r.getAttributeStreamRef(0));const s=t+a;i.write(2*n,s)}o=t}return i?(r.notifyModified(),r):e}r("")}const Gm=210;class Dm{constructor(e,t,s,n,r,i,a,h,m){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=m,this.m_originalGeometry=e,this.m_originalSR=n,this.m_polygonRingFlags=t,this.m_pannableSR=r,this.m_poleSnappingTolerance=h,this.m_poleFlags=a,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,o(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(e,t,s,n,i,a,h){let m=s;const l=new I({vd:this.m_inputPoly.getDescription()});l.addPath(this.m_inputPoly,e,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(!0,l,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(m=!1));let g=-1;m&&(g=this.m_originalGeometry.getPathStart(e));const u=l.getAttributeStreamRef(0),c=l.getPointCount();let _=0,d=u.read(0),p=0;const f=3*this.m_pannableSR.getTolerance(0);let x=!1;const y=new Qe,P=new Qe;let E=!1;const S=l.hasNonLinearSegments(),C=new Qe;for(let o=1;o<c;++o){u.queryPoint2D(2*o,C);const e=C.x;let t=e+_;const s=t-d;if(C.x=t,Math.abs(s)>this.m_GCSLargeDelta){if(m){const e=g+o-1,t=g+(o+1<c?o:0),r=a.read(2*e),i=(a.read(2*t)-r)*n;Math.abs(s-i)>1*this.m_degree&&(m=!1)}if(!m){_-=xt(this.m_width360,t-d),t=e+_,++p,E=0!==_,C.x=t}}else x||Xe(y,P,C,f)&&(x=!0);E&&(S&&r("error in geonormalize_ring_ for curves"),u.write(2*o,t)),d=t,y.setCoordsPoint2D(P),P.setCoordsPoint2D(C)}p&&l.notifyModified();const b=l.getXY(0),w=l.getXY(c-1);if(Qe.distance(b,w)<f){const e=this.finalizeGeoNormalizeClosedRing(l,x,i);h.add(e,!1)}else{if(t<0)if(null!==this.m_originalGeometry){o(null!==this.m_originalGeometry);t=this.m_originalGeometry.calculateRingArea2D(e)>0?1:0}else t=1;const s=this.finalizeGeoNormalizeOpenedRing(t>0,l);h.add(s,!1)}}geoNormalizePolygonGeometry(e){o(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),o(this.m_pannableSR.isPannable());let t=null,s=Number.NaN;const n=!!this.m_originalSR&&this.m_originalSR.isPannable();n&&(t=this.m_originalGeometry.getAttributeStreamRef(0),s=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const r=new v({vd:this.m_inputPoly.getDescription()});for(let o=0,_=this.m_inputPoly.getPathCount();o<_;++o){const i=this.m_polygonRingFlags?this.m_polygonRingFlags[o]?1:0:-1;this.geonormalizeRing(o,i,n,s,e,t,r)}const i=this.m_pannableSR.getTolerance(0),a=this.m_pannableExtent.width()/180;Ol(r,this.m_pannableExtent,.1*i,!1);const h=C.constructEmpty();if(h.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;const t=C.constructEmpty();for(let s=0,n=r.getPathCount();s<n;s++)if(r.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(r,h,i,a,this.m_progressTracker),l=r!==m;const g=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,u=m.calculateArea2D();let c=0;if(u>0&&g<0)c=1;else if(u<=0&&g>0)if(0===u){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()),g>.99*e&&(c=-1)}}else c=-1;if(0!==c){const e=wm(m.getDescription(),h);e.add(m,!1),l=!0,m=e}return l&&(m=(new Eh).execute(m,this.m_pannableSR,!1,this.m_progressTracker)),m}geoNormalizePolylineGeometry(e){o(this.m_pannableSR.isPannable());let t=null;const s=this.m_originalSR&&this.m_originalSR.isPannable();let n=1;s&&(o(this.m_originalGeometry),n=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));const i=this.m_pannableExtent.width(),a=i*ht()*4;let h=e,m=Number.NaN;const l=at.constructEmpty();this.m_bAdjustedAtPoles=0;let g=new I({vd:this.m_inputPoly.getDescription()});for(let _=0,d=this.m_inputPoly.getPathCount();_<d;++_){let e=s;const u=new I({vd:this.m_inputPoly.getDescription()});u.addPath(this.m_inputPoly,_,!0);const c=this.m_inputPoly.isClosedPath(_);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(c,u,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,i,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(e=!1));let d=-1;const p=u.getPointCount();let f=!1;e&&(d=this.m_originalGeometry.getPathStart(_),f=this.m_originalGeometry.isClosedPath(_));const x=u.getAttributeStreamRef(0);let y=0,P=x.read(0),E=0;const S=new Qe,b=new Qe;let w=!1;const v=u.hasNonLinearSegments(),N=new Qe;for(let s=1;s<p;++s){x.queryPoint2D(2*s,N);const i=N.x;let o=i+y;const a=o-P;if(N.x=o,Math.abs(a)>this.m_GCSLargeDelta){if(e){const r=d+s-1;let i=d;(!f||s+1<p)&&(i+=s);const o=t.read(2*r),h=(t.read(2*i)-o)*n;Math.abs(a-h)>1*this.m_degree&&(e=!1)}if(!e){y-=xt(this.m_width360,o-P),o=i+y,++E,w=0!==y,N.x=o}}w&&(v&&r("error in geonormalize_ring_ for curves"),x.write(2*s,o)),P=o,S.setCoordsPoint2D(b),b.setCoordsPoint2D(N)}if(E&&u.notifyModified(),h){let e=!1;if(!u.isEmpty()){const t=C.constructEmpty();if(u.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),o(m<=e),m<e&&(m+=i),o(m>=e)}let s=Math.round((m-t.xmin)/i)*i;if(t.xmin+s>m+a&&(s-=i),t.xmin+s<m-a&&(s+=i),l.mergeCoordinate(t.xmin+s),l.mergeCoordinate(t.xmax+s),e=l.width()>=i,!e){const e=new jt;e.setShiftCoords(s,0),u.applyTransformation(e)}}}g.add(u,!1),e&&(g=(()=>{const e=new I({vd:g.getDescription()});for(let t=0,s=g.getPathCount();t<s;++t){const s=new I({vd:g.getDescription()});s.addPath(g,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(u,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);g.add(e,!1)}}if(h)return g;const u=this.m_pannableSR.getTolerance(0),c=this.m_pannableExtent.width()/180;Ol(g,this.m_pannableExtent,.1*u,!1);return Zt(g,this.m_pannableExtent,u,c,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){const s=t.getPointCount(),n=t.getXY(0),r=t.getXY(s-1);{const e=Math.abs(r.x-n.x),t=Math.round(e/this.m_width360)*this.m_width360;o(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}const i=it(r.x-n.x),a=C.constructEmpty();t.queryLooseEnvelope(a);const h=this.m_pannableExtent.getCenterX();let m=0,l=h-this.m_width360,g=h+this.m_width360;if(i>=0){let e=Math.ceil((l-a.xmin)/this.m_width360);for(e*=this.m_width360;l>a.xmin+e;)e+=this.m_width360;for(;l<a.xmax+e;)e-=this.m_width360;for(m=e,a.width()>720&&(g=l+360*Math.ceil(a.width()/360));g<a.xmax;)g+=this.m_width360}else{let e=Math.ceil((g-a.xmax)/this.m_width360);for(e*=this.m_width360;g<a.xmax+e;)e-=this.m_width360;for(;g>a.xmin+e;)e+=this.m_width360;for(m=e,a.width()>720&&(l=g-360*Math.ceil(a.width()/360));l>a.xmin;)l-=this.m_width360}const u=Math.round(Math.abs(r.x-n.x)/this.m_width360)*this.m_width360,c=i*u,_=a.clone();_.move(m,0);const d=new Qe(0,0),p=new jt;p.setShiftCoords(m,0),t.applyTransformation(p);const f=new I({vd:t.getDescription()});f.add(t,!1),d.assign(t.getXY(s-1));let x=0,y=f.getXY(0).x;for(;i>0?_.xmax<g:_.xmin>l;)_.move(c,0),p.xd=c,t.applyTransformation(p),y+=c,this.m_pannableExtent.xmin<=y&&this.m_pannableExtent.xmax>=y&&(x=f.getPointCount()-1),t.setXY(0,d),d.assign(t.getXY(s-1)),f.addSegmentsFromPath(t,0,0,s-1,!1);const P=new v({vd:f.getDescription()});P.add(f,!1);const E=f.getXY(0),S=f.getXY(f.getPointCount()-1),b=i<0?e:!e,w=P.getPointCount()-1;if(b){const e=new Qe(S.x,this.m_pannableExtent.ymax);P.lineTo(e);const t=new Qe(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);P.lineTo(t);const s=new Qe(E.x,this.m_pannableExtent.ymax);P.lineTo(s)}else{const e=new Qe(S.x,this.m_pannableExtent.ymin);P.lineTo(e);const t=new Qe(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);P.lineTo(t);const s=new Qe(E.x,this.m_pannableExtent.ymin);P.lineTo(s)}if(P.interpolateAttributesPath(0,w,0),P.getImpl().changeRingStartPoint(x),u>this.m_width360){const e=new v({copy:P});p.setShiftCoords(this.m_width360,0),e.applyTransformation(p),P.add(e,!1)}return P}finalizeGeoNormalizeClosedRing(e,t,n){const r=new v({vd:e.getDescription()});r.add(e,!1);const i=()=>{const e=r.getPointCount()-2;return r.getSegmentType(e)!==s.enumLine};if(r.hasNonLinearSegments()&&i()){const e=new F,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 o=C.constructEmpty();r.queryLooseEnvelope(o);let a=Math.ceil((this.m_pannableExtent.xmin-o.xmin)/this.m_width360);for(a*=this.m_width360;this.m_pannableExtent.xmin>o.xmin+a;)a+=this.m_width360;for(;this.m_pannableExtent.xmin<o.xmax+a;)a-=this.m_width360;if(a+=this.m_width360,0!==a){o.move(a,0);const e=new jt;e.setShiftCoords(a,0),r.applyTransformation(e)}if(this.m_pannableExtent.xmin<=o.xmin&&this.m_pannableExtent.xmax>=o.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();it(e)!==it(s)&&t.reverseAllPaths(),r.assignMove(t)}}let e;if(e=new v(n?{copy:r}:{move:r}),n)for(;o.xmin<this.m_pannableExtent.xmax;){o.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 h=new v({vd:e.getDescription()});h.add(r,!1);const m=t||o.width()>this.m_width360-10*this.m_pannableSR.getTolerance(0);for(;o.xmin<this.m_pannableExtent.xmax;){o.move(this.m_width360,0);const e=new jt;e.setShiftCoords(this.m_width360,0),r.applyTransformation(e),h.add(r,!1)}if(m){const e=h.calculateArea2D();h.setFillRule(1),h=(new Eh).execute(h,this.m_pannableSR,!0,this.m_progressTracker);const t=h.calculateArea2D();it(e)!==it(t)&&h.reverseAllPaths()}return h}geonormalize_ring_(e,t,s,n,r,i,a){o(0)}}function Vm(e){o(0);const t=ou(e),s=new km;return s.setVertProj_(t),s}function Fm(e,t=!0){return o(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 o(0),0}getID(){return o(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return o(0),""}getTextExtended(e){return o(0),""}getText2(e){return o(0),""}getUnit(){return o(0),{}}equals(e){return o(0),!1}equalForProjection(e){return o(0),!1}getPeVertcsCopy(){return o(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return o(0),0}isDepth(){return o(0),!1}getVerticalShift(){return o(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=he(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 st(this.m_heightSign,e.m_heightSign)&&st(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&st(this.m_heightZ0,e.m_heightZ0)&&st(this.m_XYToRadians,e.m_XYToRadians)&&st(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&&o(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 pe,this.m_inputUnitParams=Mm(),this.m_outputUnitParams=Mm(),o(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():(o(0),"")}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(-1===t){if(!e){this.m_geogTran||r("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?Ze(this.m_latestID):ct(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():(g("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 o(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)o(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;ge(t,e,!1);let n=0;const r=e.getGeometryType();return i(r)&&b(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),i(r)&&w(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),n>0}function Wm(e){return b(e)||w(e)}class jm extends Lm{getOperatorType(){return 8}execute(e,t,s,n){return kr(e,t,s,1,n)}}function Zm(t,r,i,o){if(t.isEmpty()||r.isEmpty())return t;const a=t.getDimension(),h=r.getDimension();if(a>h)return t;const m=t.getGeometryType(),l=r.getGeometryType(),g=new C,u=new C,c=new C;t.queryEnvelope(g),r.queryEnvelope(u),c.setCoords({env2D:g}),c.mergeEnvelope2D(u);const _=de(i,c,!0),d=ye(_),p=new C;if(p.setCoords({env2D:g}),p.inflateCoords(d,d),!p.isIntersecting(u))return t;if(1===a&&2===h){const e=ol(t,r,l,i,o);if(e)return e}if(m===s.enumPoint){let i;switch(n(l)?(i=new I({vd:r.getDescription()}),i.addSegment(r,!0)):i=r,l){case s.enumPolygon:return Jm(t,i,_);case s.enumPolyline:return $m(t,i,_);case s.enumMultiPoint:return el(t,i,_);case s.enumEnvelope:return tl(t,i,_);case s.enumPoint:return sl(t,i,_);default:e("invalid shape type")}}else if(m===s.enumMultiPoint)switch(l){case s.enumPolygon:return nl(t,r,_);case s.enumEnvelope:return rl(t,r,_);case s.enumPoint:return il(t,r,_)}const f=new C(g);f.inflate(100*_.total());return Ya(t,Zt(r,f,0,0,o),i,o)}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 v}next(){const e=this.m_inputGeoms.next();return e?(t(e),a(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,s,n){const r=e.getXY(),i=t.querySegmentIterator(),o=ye(s),a=o*o;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment(),n=new C;if(t.queryEnvelope(n),n.inflateCoords(o,o),!n.contains(r))continue;if(t.isIntersectingPoint(r,s.total()))return e.createInstance();let h=t.getStartXY();if(Qe.sqrDistance(r,h)<=a)return e.createInstance();if(h=t.getEndXY(),Qe.sqrDistance(r,h)<=a)return e.createInstance()}return e}function el(e,t,s,n){const r=t.getImpl().getAttributeStreamRef(0),i=t.getPointCount(),o=e.getXY(),a=ye(s),h=a*a,m=new Qe;for(let l=0;l<i;l++){r.queryPoint2D(2*l,m);if(Qe.sqrDistance(m,o)<=h)return e.createInstance()}return e}function tl(e,t,s,n){const r=new C;t.queryEnvelope(r),r.inflate(s.total());const i=e.getXY();return r.contains(i)?e.createInstance():e}function sl(e,t,s,n){const r=ye(s),i=r*r,o=e.getXY(),a=t.getXY();return Qe.sqrDistance(o,a)<=i?e.createInstance():e}function nl(e,t,s,n){const r=new C;t.queryEnvelope(r),r.inflate(s.total());const i=e.getPointCount();let o=!1;const a=Ke(i,!1),h=new Qe;for(let l=0;l<i;l++){if(e.queryXY(l,h),!r.contains(h))continue;0!==Lo(t,h,s.total())&&(o=!0,a[l]=!0)}if(!o)return e;const m=e.createInstance();for(let l=0;l<i;l++)a[l]||m.addPoints(e,l,l+1);return m}function rl(e,t,s,n){const r=new C;t.queryEnvelope(r),r.inflate(s.total());const i=e.getPointCount();let o=!1;const a=Ke(i,!1),h=new Qe;for(let l=0;l<i;l++)e.queryXY(l,h),r.contains(h)&&(o=!0,a[l]=!0);if(!o)return e;const m=e.createInstance();for(let l=0;l<i;l++)a[l]||m.addPoints(e,l,l+1);return m}function il(e,t,s,n){const r=e.getImpl().getAttributeStreamRef(0),i=e.getPointCount(),o=t.getXY();let a=!1;const h=Ke(i,!1),m=ye(s),l=m*m,g=new Qe;for(let c=0;c<i;c++){r.queryPoint2D(2*c,g);Qe.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,i){const o=new pe;e.queryEnvelope(o);const a=new C;t.queryEnvelope(a),o.merge(a);const h=.1*o.width(),m=.1*o.height();o.inflateCoords(h,m);const l=new v;l.addEnvelope(o,!1);const g=l.getImpl();if(n===s.enumPolygon){const e=t.getImpl();g.add(e,!0)}else g.addEnvelope(t,!0);return new Ih(l,r,-1,i).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 i=new $t([e,t]),o=new gl(i,s,n,0).next();return o||r("null output"),o}}function hl(){return{geom:null,vertexCount:-1,bUnioned:!1,location:new Qe}}function ml(e,t){return Qe.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=Je(4),this.m_dimGeomCounts=Ke(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=Ke(4,!1),this.m_complexUnionGeoms=Je(4),this.m_totalNonEmptyGeomCounters=Ke(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?o(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)&&r(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===s.enumPoint){const e=new N({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,n){let r=t;if(!n)return 16&this.m_options?(r=ja([r],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),r):r;if(1&this.m_options)return r;if(1===e){if(!(8&this.m_options)&&(!!(16&this.m_options)||this.m_totalNonEmptyGeomCounters[e]>1)){r=ja([r],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const e=[0],t=r.getImpl().getIsSimple(0,e);o(this.m_bIs3D||ce(t))}else 1===this.m_totalNonEmptyGeomCounters[e]&&(this.m_bIs3D?o(0):r=(new Eh).execute(r,this.m_spatialReference,!1,this.m_progressTracker))}else this.m_bIs3D?o(0):r=(new Eh).execute(r,this.m_spatialReference,!1,this.m_progressTracker);if(0===e&&r.getGeometryType()===s.enumPoint){const e=new N({vd:r.getDescription()});r.isEmpty()||e.add(r),r=e}return r}static getLevel(e){const t=4,s=m(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&&(o(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,s){const n=hl();n.geom=s;const r=m(s);n.vertexCount=r;const i=C.constructEmpty();s.queryEnvelope(i),n.location=r>0?i.getCenter():new Qe(0,0);const o=gl.getLevel(s);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let a=null;const h=this.m_unionBins[e].get(o);h&&(a=h),null===a&&(a=new ll,this.m_unionBins[e].set(o,a)),n.bUnioned=t,a.addPair(n),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);$e(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(s){this.m_bIs3D&&(s.getDimension()>1&&l(),s.hasAttribute(1)||e("Geometry must have Zs")),t(s)}}class ul extends Lm{getOperatorType(){return 3}execute(e,t,s,n=null){return kr(e,t,s,4,n)}}function cl(e,t,s){const n=t.getGCSSplitLines();if(null===n)return e;const r=t.getGCS(),i=r.getPannableExtent().width(),o=C.constructEmpty();e.queryLooseEnvelope(o);const a=at.constructEmpty();o.queryIntervalX(a);const h=n.querySegmentIterator();let m=null;const l=new jt;for(;h.nextPath();)for(;h.hasNextSegment();){const e=h.nextSegment(),t=e.queryInterval(0,0),s=at.constructEmpty();s.setCoordsFromEnvelope(t);let n=0;for(;s.vmax>a.vmin;)s.move(-i),n--;for(;s.vmin<=a.vmax;){if(s.isIntersecting(a)){null===m&&(m=new I);const t=new H({start:e.getStartXY(),end:e.getEndXY()});0!==n&&(l.setShiftCoords(n*i,0),t.applyTransformation(l)),m.addSegment(t,!0)}s.move(i),++n}}if(null!==m){const t=me(r,m,!0);return Un(e,m,ye(t),s)}return e}function _l(e,t,s){let n=e.getName();return ic(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 o(0),""}function pl(t,s=-1){if((s>1||s<-1)&&e("verbosity"),-1===s)return t.toString();{const e=0===s?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return t.toString(e)}}function fl(t,s){(s>1||s<-1)&&e("verbosity");let n=bc.PE_STR_FMT_WKT2;return-1!==s&&(n|=0===s?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL),t.toString(n)}function xl(e){return o(0),""}function yl(e){return e.toLocaleUpperCase("en-US")}function Pl(t,n,r){const i=t.getPCSHorizon();if(i.getGeometryType()===s.enumPolygon){const e=t.getDefaultPrecisionSR().getTolerance(0),s=i;for(let t=0;t<r;t++)1!==Lo(s,n[t],e)&&n[t].setNAN();return}if(i.getGeometryType()===s.enumEnvelope){const e=i;for(let t=0;t<r;t++)e.contains(n[t])||n[t].setNAN();return}e("")}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,o){if(e.isEmpty()||1===n)return e;const a=e.getGeometryType();if(a===s.enumPoint){const s=e,r=s.getXY();return 0===wl([r],1,t,n)||r.isNAN()?s.setEmpty():s.setXY(r),e}if(a===s.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 fe,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 h=e;const m=t.getOneDegreeGCSUnit(),l=90*m,g=180*m,u=360*m,c=t.getCentralMeridian(),_=.5*m,d=C.constructEmpty();h.queryEnvelope(d);const p=t.getGCSHorizon(),f=t.getGCSHorisonIsInclusive(),x=p.getGeometryType()===s.enumEnvelope,y=C.constructEmpty();p.queryEnvelope(y);const P=t.getGCS();if(2!==n&&4!==n||(y.xmin=c-g,y.xmax=y.xmin+u),4===n){if(!(d.width()>u-m)){const e=C.constructEmpty();e.setCoords({xmin:d.xmin-m,ymin:y.ymin,xmax:d.xmax+m,ymax:y.ymax}),h=(new Kt).execute(h,e,P,o);let t=Math.floor((c-d.getCenterX())/u);for(d.move(t*u,0);d.xmin>y.xmax;)t-=1,d.move(-u,0);for(;d.xmin<y.xmin;)t+=1,d.move(u,0);if(0!==t){const e=new jt;e.setShiftCoords(t*u,0),h.applyTransformation(e)}return h}n=2}if(2===n&&(y.xmin=c-g,y.xmax=y.xmin+u),d.ymin<-l||d.ymax>l){const e=C.constructEmpty();if(e.setCoords({xmin:d.xmin-m,ymin:-l,xmax:d.xmax+m,ymax:l}),h=(new Kt).execute(h,e,P,o),h.isEmpty())return h;h.queryEnvelope(d)}if(f&&(y.ymax<d.ymin||y.ymin>d.ymax))return h.createInstance();d.width()>u&&(h=ql(h,c-g,u,P,!0,0,!0,o),h.queryEnvelope(d));let E=Ul(d.xmin,d.xmax,y.xmin,y.xmax,u);if(0!==E&&d.move(E,0),d.xmax>y.xmax||d.xmin<y.xmin){if(d.xmax>y.xmax)for(;d.xmin>=y.xmax;)d.move(-u,0),E-=u;for(;d.xmin<y.xmax-u;)d.move(u,0),E+=u}const S=ge(P,p,!1);if(0!==E){const e=new jt;e.setShiftCoords(E,0),h.applyTransformation(e),E=0}if(f){if(x&&y.containsEnvelope(d))return h;const e=new Array(2);for(let t=0;t<2;t++){let s;if(x?s=i(a)?Zt(h,y,S,_,o):Zt(h,y,S,0,o):(s=(new wh).execute(h,p,P,o),s===p&&(s=s.clone())),y.xmin<=d.xmin&&y.xmax>=d.xmax)return s;if(y.xmin>=d.xmin&&y.xmax<=d.xmax)return s;if(e[t]=s,0===t){d.move(-u,0);const e=new jt;e.setShiftCoords(-u,0),h.applyTransformation(e)}}return i(a)?e[0].add(e[1],!1):r("intersect_with_GCS_horizon: unexpected geometry type"),e[0]}{if(y.ymax<d.ymin||y.ymin>d.ymax)return h;let e=0;for(;!h.isEmpty()&&d.xmax>y.xmin;){if(0!==e){const t=new jt;t.setShiftCoords(e,0),h.applyTransformation(t)}if(!(new ul).execute(h,p,P,o)){h=(new Km).execute(h,p,P,o),p===h&&(h=h.clone())}if(0!==e){const t=new jt;t.setShiftCoords(-e,0),h.applyTransformation(t)}e-=u,d.move(-u,0)}return h}}function Cl(e,t,s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{if(2===i){return Gs(e,t,s,n,r)}if(Math.abs(s.x-n.x)>=Math.PI||!Fg(s.x,n.x,r))return Number.NaN;s.x>n.x&&(n=rt(s,s=n));const a=zt(o,new Cc,!1),h=zt(o,new Cc,!1),m=zt(o,new Cc,!1),l=s.clone();Dc.geodeticDistance(e,t,s.x,s.y,n.x,n.y,h,a,null,i);const g=h.val;let u=0,c=1;for(;g*(c-u)>1e-12*e;){const o=.5*(u+c);if(Dc.geodeticCoordinate(e,t,s.x,s.y,g*o,a.val,h,m,i),l.x=h.val,l.y=m.val,l.x===r)return l.y;if(Fg(s.x,l.x,r))c=o;else{if(!Fg(n.x,l.x,r))return Number.NaN;u=o}}return l.y}catch(a){o.error=a,o.hasError=!0}finally{Wt(o)}}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 i=Il(e,t);if(2===r){const s=n.getPannableExtentInGCS();let r=t;for(let e=0,n=2*t;e<n;e+=2)(i[e+1]>s.ymax||i[e+1]<s.ymin)&&(i[e]=Number.NaN,r--);return r?(Bl(i,t,s.xmin,s.width(),!0),e!==i&&bl(i,e,0,t),r):(e!==i&&bl(i,e,0,t),0)}const o=n.getOneDegreeGCSUnit(),a=90*o,h=180*o,m=360*o;let l=t;for(let s=0,p=2*t;s<p;s+=2)(i[s+1]>a||i[s+1]<-a)&&(i[s]=Number.NaN,l--);if(!l)return e!==i&&bl(i,e,0,t),0;const g=C.constructEmpty();g.setFromPoints(i,t);const u=n.getGCSHorizon(),c=n.getGCSHorisonIsInclusive(),_=u.getGeometryType()===s.enumEnvelope,d=C.constructEmpty();if(u.queryEnvelope(d),c&&(d.ymax<g.ymin||d.ymin>g.ymax))return e!==i&&bl(i,e,0,t),0;if(c){if(Bl(i,t,d.getCenterX()-h,m,!0),l=t,_)for(let e=0,s=2*t;e<s;e+=2)d.containsCoords(i[e],i[e+1])||(i[e]=Number.NaN,l--);else{const e=ge(n.getGCS(),u,!1),s=new Qe;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(i[n],i[n+1]);0!==Lo(u,s,e)||(i[n]=Number.NaN,l--)}}}else{Bl(i,t,-h,m,!0),l=t;const e=ge(n.getGCS(),u,!1),s=new Qe;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(i[n],i[n+1]),s.isNAN()&&l--;const t=Ml(s.x,d.xmin,d.xmax,m);s.x+=t;0!==Lo(u,s,e)&&(i[n]=Number.NaN,l--)}}return e!==i&&bl(i,e,0,t),l}function vl(t,s,n,r,i,o){if(s.isPannable()||e("fold_into_360_degree_range"),t.isEmpty())return t;let a,h;if(2===s.getCoordinateSystemType()){const e=s.getPannableExtent();h=e.xmin,a=e.width()}else{const e=s.getOneDegreeGCSUnit();a=360*e,h=n-180*e}return ql(t,h,a,s,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=tt(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 G,o=i.addGeometry(e);return kl(i,o,t,ge(t,e,!1),s,n,r),i.getGeometry(o)}function kl(e,t,s,n,r,i,a){const h={stack:[],error:void 0,hasError:!1};try{o(Uu()),s.isPannable()||u("insert_geodetic_points");const m=s.getPannableExtent(),l=s.getGCS(),g=Hu();l.querySpheroidData(g);const c=l.getUnit().getUnitToBaseFactor(),_=g.majorSemiAxis,d=g.e2;let p=0;const f=new at;m.queryIntervalX(f);let x=null;const y=Ke(4,Number.NaN);2===s.getCoordinateSystemType()?(x=s.getPECoordSys(),i?(y[0]=Tl(a,f),y[1]=m.getCenterY(),wc.projToGeog(x,1,y),p=y[0]*c):(y[0]=m.getCenterX(),y[1]=a,wc.projToGeog(x,1,y),p=y[1]*c)):p=a*c,i||0===p||2===r||u("insert_geodetic_points: 1");const P=zt(h,new Cc,!1),E=new Qe,S=new Qe,C=new Qe,I=new Qe,b=new Qe,w=new Qe;for(let o=e.getFirstPath(t);o!==M;o=e.getNextPath(o)){const t=e.getFirstVertex(o);e.queryXY(t,C);let h=!1;const m=e.getNextVertex(t);for(let o=m;o!==M;o=e.getNextVertex(o)){if(o===m){if(h)break;h=!0}if(e.queryXY(o,I),i&&(n<a-C.x&&I.x-a>n||n<a-I.x&&C.x-a>n)||!i&&(0!==a||n<-C.y&&I.y>n||n<-I.y&&C.y>n))do{if(Math.abs(C.x-I.x)>=.5*f.width())break;2===s.getCoordinateSystemType()?(y[0]=Tl(C.x,f),y[1]=C.y,y[2]=Tl(I.x,f),y[3]=I.y,ag(x,2,y,0),b.x=y[0]*c,b.y=y[1]*c,w.y=y[3]*c):(b.x=C.x*c,b.y=C.y*c,w.y=I.y*c),w.x=(I.x-C.x)*Math.PI*2/f.width()+b.x;let t=0;const n=lt(Qe,2);if(i){if(S.x=p,S.y=Cl(_,d,b,w,p,r),Number.isNaN(S.y))break;n[0]=S,t=1}else if(2===r){const e=[0,0];if(t=Ds(_,d,b,w,p,e),!t)break;n[0].x=e[0],n[0].y=p,2===t&&(n[1].x=e[1],n[1].y=p)}else{if(S.x=Hg(_,d,b,w,r),Number.isNaN(S.x))break;S.y=0,n[0]=S,t=1}let h=-1;for(let m=0;m<t;m++){Dc.geodeticDistance(_,d,b.x,b.y,w.x,w.y,P,null,null,r);const t=P.val;Dc.geodeticDistance(_,d,b.x,b.y,n[m].x,n[m].y,P,null,null,r);const l=P.val;2===s.getCoordinateSystemType()?(y[0]=n[m].x/c,y[1]=n[m].y/c,wc.geogToProj(x,1,y),i?(E.y=y[1],E.x=a):(E.x=kg(y[0],C.x,I.x,f),E.y=a)):i?(E.x=a,E.y=n[m].y/c):(E.x=kg(n[m].x/c,C.x,I.x,f),E.y=a);const g=t>0?It(l/t,0,1):.5;if(0===g||1===g)continue;if(h>g)continue;const u=e.getPrevVertex(o);e.splitSegment(u,[g],1);const p=e.getNextVertex(u);e.setXYCoords(p,E.x,E.y),h=g}}while(0);C.setCoordsPoint2D(I)}}}catch(m){h.error=m,h.hasError=!0}finally{Wt(h)}}function Al(e,t){o(t.isPannable());const n=t.getPannableExtent();if(e.getGeometryType()===s.enumPoint){const t=e.getY();return n.ymin<=t&&t<=n.ymax?e:e.createInstance()}const r=C.constructEmpty();e.queryEnvelope(r);const i=C.constructEmpty();i.setCoords({env2D:n}),i.xmin=r.xmin,i.xmax=r.xmax,i.inflateCoords(.01*i.height(),0);const a=le(t,r,!1);let h;return h=i.containsEnvelope(r)?e:Zt(e,i,a,0,null),h}function Ml(e,t,s,n){return nt((.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,i,o,a,h){const m=e.getGeometryType(),l=at.constructEmpty();l.setCoords(t,t+n);const g=[0];if(m===s.enumPoint){const t=e;if(g[0]=t.getX(),Dl(g,l,a)){const t=i?e:e.clone();return t.setX(g[0]),t}return e}const u=C.constructEmpty();if(e.queryEnvelope(u),u.isEmpty())return e;if(m===s.enumMultiPoint){const t=i?e:e.clone(),s=t.getImpl(),n=s.getAttributeStreamRef(0),r=2*s.getPointCount();let o=!1;for(let e=0;e<r;e+=2)g[0]=n.read(e),Dl(g,l,a)&&(n.write(e,g[0]),o=!0);return o&&s.notifyModifiedFlags(2001),t}const c=at.constructEmpty();if(u.queryIntervalX(c),l.contains(c))return l.vmax,c.vmax,e;const _=C.constructEmpty();if(_.setCoords({env2D:u}),0===c.width()){let t=c.vmin;t+=Math.ceil((l.vmin-t)/n)*n,t=l.snapClip(t);const s=i?e:e.clone();return s.setAttributeBasic(0,0,t),s}if(m===s.enumEnvelope){const t=i?e:e.clone();return u.intersect(_),t.setEnvelope(u),t}const d=.1*Math.max(u.height(),u.width())*1;_.inflateCoords(0,d);let p=e;const f=r.getTolerance(0),x=new jt;for(;;){const e=Math.floor((c.vmin-t)/n),i=Math.ceil((c.vmax-t)/n);if(!(i-e>3))break;{const a=Math.floor(.5*(i+e));_.xmin=u.xmin-d,_.xmax=t+n*a;const l=Zt(p,_,f,o,h);_.xmin=_.xmax,_.xmax=u.xmax+d;const g=Zt(p,_,f,o,h);x.setShiftCoords((a-i)*n,0),g.applyTransformation(x),m===s.enumPolygon?p=(new al).execute(l,g,r,h):(p=l,p.add(g,!1)),p.queryEnvelope(u),u.queryIntervalX(c)}}_.xmin=t,_.xmax=t+n;const y=C.constructEmpty();y.setCoords({env2D:_}),y.inflateCoords(f,0);const P=Math.floor((u.xmin-_.xmin)/n)*n;let E;P?(_.move(P,0),x.setShiftCoords(-P,0)):x.setIdentity(),E=m===s.enumPolyline?new I({vd:p.getDescription()}):new v({vd:p.getDescription()});const S=C.constructEmpty(),b=C.constructEmpty();for(;u.xmax>_.xmin;){const e=Zt(p,_,f,0,h);e.queryEnvelope(b);let t=!1;t=m===s.enumPolyline?!e.isEmpty()&&(b.width()>f||b.height()>f):!e.isEmpty()&&(m!==s.enumPolygon||b.width()>f),t&&(e.applyTransformation(x),e.queryEnvelope(b),E.queryEnvelope(S),S.inflateCoords(f,f),S.isIntersecting(b)&&m===s.enumPolygon?E=(new al).execute(E,e,r,h):E.add(e,!1)),_.move(n,0),x.shiftCoords(-n,0)}return E}function Bl(e,t,s,n,r=!0){const i=new at;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,a=!0){if(e.isEmpty())return;const h=e.getGeometryType();if(!a||h!==s.enumPolygon)if(_(h)){let s=!1;if(i(h)&&e.hasNonLinearSegments()){const r=e.getImpl(),i=r.getAttributeStreamRef(0),a=r.getSegmentFlagsStreamRef();o(null!==a);for(let e=0,o=r.getPathCount();e<o;e++){let o=!0;const h=r.isClosedPath(e),m=r.getPathEnd(e);if(h&&r.getPathSize(e)>0){o=1===(31&a.read(m-1))}for(let l=r.getPathStart(e);l<m;l++){if(1===(31&a.read(l))){if(o){const e=i.read(2*l),r=Gl(e,t,n);r!==e&&(s=!0,i.write(2*l,r))}o=!0}else o=!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(h===s.enumEnvelope){const s=e,r=C.constructEmpty();s.queryEnvelope(r),r.xmin=Gl(r.xmin,t,n),r.xmax=Gl(r.xmax,t,n),s.setEnvelope(r)}else if(h===s.enumPoint){const s=e;s.setX(Gl(s.getX(),t,n))}else r("")}function Yl(e,t,s){const n=new Qe;return n.x=Gl(e.x,t,s),n.y=e.y,n}function Rl(e,t){if(t.isEmpty())return 0;const s=e.getPECoordSys();if(s.getProjection().getCode()===bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=Hu();e.querySpheroidData(n);const r=s.getParameters();if(null===r[bc.PE_PARM_LAM0])return 0;if(null===r[bc.PE_PARM_PHI0])return 0;const i=[r[bc.PE_PARM_LAM0].getValue(),r[bc.PE_PARM_PHI0].getValue()];wc.geogToProj(s,1,i);const o=new Qe(i[0],i[1]),a=C.constructEmpty();t.queryEnvelope(a);const h=lt(Qe,4);a.queryCorners(h);let m=0;const l=e.getOneMeter();let g=Math.max(n.majorSemiAxis,n.minorSemiAxis)*Math.PI,u=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;u-=g/180,g*=l,u*=l;for(let e=0;e<4;e++){const t=Qe.distance(h[e],o);if(t>g)m++;else if(t>u)return-1}if(0===m)return 1;if(4===m){const e=C.constructEmpty();return e.setCoords({center:o,width:g,height:g}),a.isIntersectingNe(e)?-1:0}return-1}return-1}function Xl(e,t,n,r){const i=e.getGeometryType();o(i===s.enumPolygon||i===s.enumPolyline||i===s.enumMultiPoint);const a=t.getCoordinateSystemType();if(2===a){let o=e;if(0===n){const n=Rl(t,e);if(0===n)return e.createInstance();if(1===n)return e;const i=t.getPCSHorizon(),a=i.getGeometryType(),h=t.getDefaultPrecisionSR();if(a===s.enumEnvelope){const s=C.constructEmpty();i.queryEnvelope(s);const n=le(h,s,!1);o=Zt(e,s,n,5e4*t.getOneMeterPCSUnit(),r)}else(new jm).execute(i,e,h,r)||(o=(new wh).execute(o,i,h,r),o===i&&(o=o.clone()))}else if(t.isPannable()){const e=C.constructEmpty();o.queryEnvelope(e);const a=t.getPannableExtent();a.containsEnvelope(e)||(Ol(o,a,t.getTolerance(0)),2!==n&&4!==n||(o=Al(o,t)),4!==n?o=vl(o,t,0,!0,1e5*t.getOneMeterPCSUnit(),r):i===s.enumPolygon&&e.width()>2*a.width()&&(o=ql(o,-2*a.width(),2*a.width(),t,!0,0,!0,r)))}return o}if(o(1===a),i===s.enumMultiPoint)return Ol(e,t.getPannableExtent(),t.getTolerance(0)),e;{const n=C.constructEmpty();e.queryEnvelope(n);let o=e;const a=t.getPannableExtent();if(n.ymin<a.ymin||n.ymax>a.ymax){const e=Math.max(1,n.calculateToleranceFromEnvelope()),s=new C(n.xmin-e,a.ymin,n.xmax+e,a.ymax);if(o=(new Kt).execute(o,s,t,r),o.isEmpty())return o}return i===s.enumPolygon&&n.width()>2*a.width()&&(o=ql(o,-2*a.width(),2*a.width(),t,!0,0,!0,r)),o}}function Ll(e,t,s,n,r,i){const a=n.getCoordinateSystemType();if(2===a){if(0===r)s!==e&&et(s,e,t),Pl(n,s,t);else if(s!==e&&et(s,e,t),n.isPannable()){const e=n.getTolerance(0);El(s,t,n.getPannableExtent(),e),Nl(s,t,n,0)}}else{o(1===a);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=it(r),m=t[s].x-h;i*it(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,s,n){const r=new N({vd:t.getDescription()});let i;r.addPoints(t,0,-1),i=(new qh).execute(r,e,n);const o=t.getPointCount();if(s.setEmpty(),e.getInputSR().isPannable()){if(o!==i.getPointCount())return!1;const n=new C;t.queryEnvelope(n);const r=new C;i.queryEnvelope(r);const a=n.width(),h=r.width();if(0!==a&&0!==h){const t=h/a,s=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/s-1)>1e-10)return!1}else if(0!==a||0!==h)return!1;s.add(t,!1);for(let e=0;e<o;e++){const t=i.getXY(e);s.setXY(e,t)}return!0}return!1}function Kl(e,t,s){o(!s||e.isPannable());const n=t.getPointCount();if(!n)return;const r=t.getImpl(),i=r.getAttributeStreamRef(0),a=e.getPECoordSys();let h=0;const m=i.readRange(0,2*n);let l=()=>{wc.geogToProj(a,n,m)};const g=e.isPannable()&&!s,u=g?e.getPannableExtent().width():0,c=179*u/360;if(e.isPannable()&&(h=e.getCentralMeridian(),s)){const t=e.m_peCoordSysVal.getGeogToProjFactors(),s=t.first,r=t.second;l=()=>{wc.geogToProj(a,n,m);for(let e=0;e<n;e++){const t=e<<1,n=i.read(t),o=s*(n-h)+r;m[t]=o}}}if(l(),g)for(let o=0;o<n;o++){const e=o<<1,t=m[e],s=it(t),n=i.read(e)-h;s*it(n)<0&&Math.abs(t)>c&&(m[e]+=-s*u)}i.writeRangeFromArray(0,2*n,m,!0,1),r.notifyModifiedFlags(2001)}function Ql(e,t,n){switch(t.getGeometryType()){case s.enumLine:return void Ig(e,t,n);case s.enumBezier:return void Gg(e,t,n);case s.enumEllipticArc:return void wg(e,t,n);case s.enumBezier2:return void Dg();case s.enumRationalBezier2:return void Vg();default:r("")}}function Jl(e,t,s){if(!t.hasNonLinearSegments())return void Kl(e,t,s);if(o(!s||e.isPannable()),t.isEmpty())return;const n=0,r=e.getPECoordSys(),i=e.isPannable(),a=i?e.getPannableExtent().width():0,h=179*a/360;let m=0;i&&(m=e.getCentralMeridian());const l=t.createInstance();l.reserveParts(t.getPointCount(),t.getPathCount());const g=t.getImpl(),u=new F;for(let o=0,c=t.getPathCount();o<c;++o)if(g.hasNonLinearSegmentsPath(o)){let t=!0,n=-1;const r=g.getPathStart(o),i=r+g.getSegmentCountPath(o);g.isClosedPath(o)&&(n=i-1);const a=new Qe;for(let o=r;o<i;++o){if(g.getSegmentBuffer(o,u,!1),Ql(e,u.get(),s),!t){u.get().getStartXY().equals(a)||u.get().moveTo(a)}if(o!==n)l.addSegment(u.get(),t);else{if(t){const e=new fe;u.get().queryStart(e),l.startPathPoint(e)}l.closeLastPathWithSegment(u.get())}a.assign(u.get().getEndXY()),t=!1}}else{const e=1024;let s,u=g.getPathSize(o),c=Math.min(u,e);l.insertPath(-1,t,o,!0);const _=g.getAttributeStreamRef(0),d=l.getAttributeStreamRef(0);for(let t=g.getPathStart(o),l=g.getPathEnd(o);t<l;){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=it(r),o=_.read(2*(n+e))-m;i*it(o)<0&&Math.abs(r)>h&&(s[t]+=-i*a)}d.writeRangeFromArray(t,c,s,!0,1),t+=c,u-=c,c=Math.min(u,e)}}t.assignMove(l)}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=it(n),i=o.read(2*(h+e));r*it(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,n){switch(n.getGeometryType()){case s.enumLine:return void tg(e,t,n);case s.enumBezier:return void rg(e,t,n);case s.enumEllipticArc:return void sg(e,t,n);case s.enumBezier2:return void ig();case s.enumRationalBezier2:return void og();default:r("")}}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=lt(Qe,4);s.queryControlPoints(n),vg(e,t,n,4),s.setControlPoints(n)}function ig(e,t,s){o(0)}function og(e,t,s){o(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;o(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 F;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 Qe;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 fe;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=it(r),m=c.read(2*s);h*it(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=it(o);m*it(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){o(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|=Ht(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=Ke(d,Number.NaN),f=Ke(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]=xt(P,i),f[s]=xt(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,n){switch(t.getGeometryType()){case s.enumLine:return xg(e,t,n);case s.enumBezier:return Eg(e,t,n);case s.enumEllipticArc:return yg(e,t,n);case s.enumBezier2:return Sg();case s.enumRationalBezier2:return Cg();default:r("")}}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 F;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 Qe;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 fe;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|=Ht(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|=Ht(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=Ke(f,Number.NaN),y=Ke(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=xt(E,r),y[s]=xt(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 o(0),0}function pg(e,t,s,n,r){o(null===n),o(t<2147483647);const i=Array.isArray(s);let a;a=i?qt(s):s;const h=vc.geogToGeog(e,t,a,null,r);return i&&Bt(a,s),h}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=lt(Qe,3),i=lt(Qe,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]=ft(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 Qe;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=ft(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=lt(Qe,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]=ft(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 o(0),!1}function Cg(e,t,s){return o(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,s,n){mg(e,t,s,n);const r=new C;r.setFromPoints(s,n);const i=e.getOneDegreeGCSUnit(),o=360*i,a=180*i;if(r.width()>a){for(let e=0;e<n;e++)for(;s[e].x<t;)s[e].x+=o;if(r.setFromPoints(s,n),r.xmax>a+t)for(let e=0;e<n;e++)s[e].x-=o}}function Ng(e,t,s,n,r){const i=lt(Qe,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=lt(Qe,4);t.queryControlPoints(n),bg(e,n,4,s),t.setControlPoints(n)}function Dg(e,t,s){o(0)}function Vg(e,t,s){o(0)}function Fg(e,t,s){const n=oe(e),r=oe(t),i=ie(n,r),o=ie(n,oe(s));return 0===o||(i>0&&o>0&&o<=i||i<0&&o<0&&o>=i)}function Hg(e,t,s,n,r){const i={stack:[],error:void 0,hasError:!1};try{const a=s.clone(),h=n.clone();if(2===r){const s=[0,0];return Ds(e,t,a,h,0,s),s[0]}if(a.y>h.y){const e=new Qe;e.assign(a),a.assign(h),h.assign(e)}const m=zt(i,new Cc,!1),l=zt(i,new Cc,!1),g=zt(i,new Cc,!1),u=new at;if(u.setCoords(a.y,h.y),!u.containsCoordinate(0)||Math.abs(a.x-h.x)>=Math.PI)return Number.NaN;if(a.x===h.x)return a.x;Dc.geodeticDistance(e,t,a.x,a.y,h.x,h.y,l,m,null,r);const c=l.val;let _=0,d=1;const p=a.clone();for(;c*(d-_)>1e-12*e;){const s=.5*(_+d);if(Dc.geodeticCoordinate(e,t,a.x,a.y,c*s,m.val,l,g,r),p.x=l.val,p.y=g.val,u.setCoords(a.y,p.y),0===p.y)return p.x;if(u.containsCoordinate(0))d=s;else{if(u.setCoords(h.y,p.y),!u.containsCoordinate(0))return o(!1),Number.NaN;_=s}}return p.x}catch(a){i.error=a,i.hasError=!0}finally{Wt(i)}}function kg(e,t,s,n){const r=new at;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(t,s=!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=Qe.getNAN(),this.m_southPole=Qe.getNAN(),this.m_polesUpdated=0,this.m_domain=C.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=C.constructEmpty(),this.m_pannableExtentGCS=C.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=t,this.m_WKID=Ic.getCode(t),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=_l(t,0,!0),this.m_hashCode=ct(this.m_canonicalWkt)):this.m_hashCode=_t(this.m_WKID);const n=this.m_peCoordSys.getType();this.m_csType=n===bc.PE_TYPE_PROJCS?2:1,o(n===bc.PE_TYPE_PROJCS||n===bc.PE_TYPE_GEOGCS),n===bc.PE_TYPE_PROJCS&&(t.loadConstants()||e("PeProjcs.loadConstants failed"));const i=n===bc.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();n!==bc.PE_TYPE_GEOGCS&&Ic.getCode(i),this.m_unit=ms(t),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(n===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||r("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 o(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,s=t.getGeogcs(),n=t.horizonGcsGenerate();if(!n)return;o(n.length>0);const r=n[0].getNump(),i=n[0].getKind();let a,h;e=n[0].getInclusive()>0;const m=this.getOneDegreeGCSUnit(),l=90*m,g=360*m,u=370*m,c=180*m*bc.PE_HORIZON_DELTA/Math.PI,_=C.constructEmpty();let d=null;if(r>1)for(let o=1;o<r;o++)if(n[o].getKind()===bc.PE_HORIZON_LINE){d||(d=new I);const e=n[o].getCoord();d.startPathCoords(e[0][0],e[0][1]),d.lineToCoords(e[1][0],e[1][1])}if(i===bc.PE_HORIZON_RECT){const t=n[0].getCoord();if(_.setFromPoints([new Qe(t[0][0],t[0][1]),new Qe(t[1][0],t[1][1])],2),Math.abs(_.ymax-l)<1e-7*c&&(_.ymax=l),Math.abs(_.ymin+l)<1e-7*c&&(_.ymin=-l),_.width()>u){const e=-400*m,t=e+5*g;_.setCoords({xmin:e,ymin:_.ymin,xmax:t,ymax:_.ymax})}const s=new pe({env2D:_});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap();const i=Ru(s,null,null,1),u=[],c=new at;for(let e=0;e<r;e++){if(n[e].getKind()!==bc.PE_HORIZON_POLY)continue;a=n[e].getSize();const t=n[e].getCoord(),s=C.constructEmpty();s.setFromPoints(dt(t),a),u.push(new at(s.xmin,s.xmax)),s.width(),c.merge(u.at(-1))}let _=!1;const p=new at;c.width()>g&&u.length>1?(p.vmin=this.getCentralMeridian()-g,p.vmax=p.vmin+2*g,_=!0,t=!0):(p.vmin=c.vmin,p.vmax=p.vmin+g);const f=e=>{let t=0;for(;u[e].vmin+t<p.vmin;)t+=g;for(;u[e].vmax+t-g>p.vmin;)t-=g;return t};let x=new v;if(t){const e=new Ag,t=(new al).executeMany(e,i,null);for(let s=0;s<r;s++){if(n[s].getKind()!==bc.PE_HORIZON_POLY)continue;a=n[s].getSize();const r=n[s].getCoord();h=n[s].getInclusive()>0;const i=new v;if(i.addPathPoint2D(dt(r),a-1,!0),_){const t=f(s),n=u[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+=g,n.move(g)}while(n.vmin<p.vmax)}else e.tick(i),t.tock()}x=t.next()}else{x=new v;for(let t=0;t<r;t++){if(n[t].getKind()!==bc.PE_HORIZON_POLY)continue;a=n[t].getSize();const s=n[t].getCoord();if(h=n[t].getInclusive()>0,o(h===e),_){const e=new v;e.addPathPoint2D(dt(s),a-1,!0);const n=f(t),r=u[t].clone();r.move(n);let i=n;const o=new jt;do{if(0!==i){o.setShiftCoords(i,0);const t=new v({copy:e});t.applyTransformation(o),x.addPath(t,0,!0)}else x.addPath(e,0,!0);i+=g,r.move(g)}while(r.vmin<p.vmax)}else x.addPathPoint2D(dt(s),a-1,!0)}}_&&(x=(new Kt).execute(x,new C(p.vmin,-l-m,p.vmax,l+m),i,null)),e?(new wh).accelerateGeometry(x,i,1):(new Km).accelerateGeometry(x,i,1),(new ul).accelerateGeometry(x,i,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=x,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=d)}}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 s=e[0].getKind();e[0].getInclusive();const n=C.constructEmpty(),r=e[0].getNump();let i=!1;if(s===bc.PE_HORIZON_RECT){const s=e[0].getCoord();n.setFromPoints(dt(s),2),t=new pe({env2D:n})}else{let s=-1;for(let t=0;t<r;t++)e[t].getKind()===bc.PE_HORIZON_POLY&&(s=t);o(s>=0);const n=e[s].getSize()-1,a=e[s].getCoord(),h=new v;t=h,h.addPathPoint2D(dt(a),n,!0),i=!0}if(this.getPCSInfo().isDensificationNeeded()){o(s!==bc.PE_HORIZON_RECT);const e=1e5*this.getOneMeterPCSUnit();t=(new Jt).execute(t,e,0,0,null)}if(i){{const e=new pe;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(),s=e.getGeogcs();s||r("");const n=[t+1/s.getUnit().getUnitFactor()*Math.PI,0];wc.geogToProj(e,1,n);const i=n[0],o=e.getParameters()[bc.PE_PARM_X0].getValue(),a=this.getPCSHorizon(),h=C.constructEmpty();a.queryEnvelope(h);const m=Math.abs(i-o),l=m+o,g=-1*m+o,u=h.ymax,c=h.ymin;this.m_pannableExtent.setCoords({xmin:g,ymin:c,xmax:l,ymax:u})}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 r("")}updatePannableExtentGCS(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.m_centralMeridian,s=e.getGeogcs();s||r("");const n=1/s.getUnit().getUnitFactor()*Math.PI,i=this.getGCSHorizon(),o=C.constructEmpty();i.queryEnvelope(o),this.m_pannableExtentGCS.setCoords({xmin:t-n,ymin:o.ymin,xmax:t+n,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 r("")}updateDomain(){if(1===this.m_csType){const e=400*this.getOneDegreeGCSUnit();this.m_domain=C.construct(-e,-e,e,e)}else{o(2===this.m_csType);const e=Nc.generate(this.m_peCoordSys,Nc.PE_PCSINFO_OPTION_DOMAIN);e||r("generate pcs info failed");const t=new C(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);o(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)||r("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,s){return Yg(e,t,C.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()||c("cannot create projection transformation");return t.hasVCS()&&s.hasVCS()?jg():Zg(t,s,n)}function Lg(e,t,s,n,r,i){return Uu()||c("cannot create projection transformation"),new eu(e?2:1,t,s,n,r,i)}function zg(t,s,n,r,i,o=!1){s&&n||e(""),Uu()||c("cannot obtain geotransformation list");if(1===t&&s.hasVCS()&&n.hasVCS())return g("hv xform not impl"),[];{const e=Qc(s,n,r,i,o),t=[];for(const s of e)t.push(s);return t}}function Wg(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return st(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&st(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 o(0),{}}function Zg(t,s,n,r){t&&s||e("!inputSR || !outputSR");const i=t.getLatestID(),o=s.getLatestID();if(3857===i&&4326===o){if(t.m_bDefaultDescriptor&&s.m_bDefaultDescriptor)return pu()}else if(4326===i&&3857===o&&t.m_bDefaultDescriptor&&s.m_bDefaultDescriptor)return fu();const a=C.constructEmpty();a.setCoords({env2D:n});const h=t.getCoordinateSystemType(),m=s.getCoordinateSystemType();if(0===h||0===m)return Kg(t,s);const l=t.getGCS().getLatestID(),g=s.getGCS().getLatestID();if(l>0&&l===g)return Kg(t,s);const u=new mu(t,s,n);{const e=gu(u);if(e)return e}const c=zg(0,t,s,a,1,!0);return uu(u,Kg(t,s,c.length?c[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(t,s,n,r,i,a){let h,m;this.m_datumTran=null,this.m_bIdentity=!0,this.m_bIdentityGeogToGeog=!0,this.m_bVertical=!1,this.m_bNormalize=!1,s&&n||e("!inputSR || !outputSR"),r&&0===r.getType()&&(r.m_bReadOnly=!0),this.m_bNormalize=!1,1!==t&&(h=s.getVCS(),m=n.getVCS(),this.m_bVertical=null!=h&&null!=m),this.m_inputSR=s,this.m_outputSR=n,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,o(!this.m_params),i&&(this.m_params=Jg(),this.m_params.m_extendedParams=i),a&&(this.m_params||(this.m_params=Jg()),this.m_params.m_extendedParamsInternal=a);let l=!1;const g=null!=r,u=s.getCoordinateSystemType(),c=n.getCoordinateSystemType();if(n.isPannable()&&0!==u&&i){const e=i.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&n.isPannable()){const t=n.getPannableExtent(),s=t.getCenterX();if(s!==e){const n=Math.ceil(t.width());e+n!==s+n&&(l=!0)}}}const _=i&&i.normalizeResultGeometry;if(s.equals(n))return this.m_bIdentity=!l,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const d=!g&&s.equalForProjection(n,this.m_bVertical);this.m_bIdentity=d&&!l,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 o(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return o(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&&f(e);{const t=Iu(e);if(t)return t}const t=Hc(Ic.coordsys(e));t.get()||f(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()||S(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=je(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=je(this.m_hashCode,Ot(this.m_env.xmin)),this.m_hashCode=je(this.m_hashCode,Ot(this.m_env.xmax)),this.m_hashCode=je(this.m_hashCode,Ot(this.m_env.ymin)),this.m_hashCode=je(this.m_hashCode,Ot(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=Ke(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){o(n>>5<r.length);let i=t,a=s;for(let o=n;o>=0;o-=2){const t=31&o,s=.5*(a+i);e>=s?(r[o>>5]|=1<<t,i=s):a=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 o(Bu()),dc(e,void 0===t?0:t,null,!1)}function Yu(e,t){o(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(t,s,n,r,i){t||e("!PE_coord_sys");const o=new oc;let a;return a=i?ru(t):new qg(t,!1),uc(o.m_precisionDescriptor,a,s,r),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=s,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}function Lu(t,s,n=!1){3===t.getCoordinateSystemType()&&e("image spatial reference cannot be altered");const r=new oc,i=t;return r.m_peCoordSysVal=i.m_peCoordSysVal,r.m_vertcs=i.m_vertcs,r.m_unit=i.m_unit,r.m_precisionDescriptor.assign(s),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,n&&(r.m_bDefaultDescriptor=!0),r.calculateHashCode(),r.initDbgName(),r}function zu(e,t,s){return{}}function Wu(t,s,n){void 0===s&&(s=1),(s<=0||!Number.isFinite(s))&&e(""),t||1===s||e("null Unit has to have z_to_xy_factor equal to 1");const r=new oc;r.m_unit=t;const i=t||new bu(9001);return _c(r.m_precisionDescriptor,i,null,1),r.m_bDefaultDescriptor=!0,Number.isNaN(r.m_precisionDescriptor.m_falseX)&&e("NAN false X/Y are not allowed here"),r.m_localZToXYFactor=s,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&&o(0),e.getGCS())}function Ku(e){return o(Bu()),qu()?Bc(e):Eu(e)}function Qu(e){if(Uu()){return null!==Hc(Ic.fromString(bc.PE_TYPE_COORDSYS,e)).get()}try{return Ac(e),!0}catch(t){}return!1}let Ju;function $u(){return Ju||(Ju=(()=>{const e=Math.trunc(Math.random()*vt()),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,tc,sc,nc=0;function rc(e=""){let t=`${$u()}${nc++}`;return""!==e&&(t+=`|${e}`),t}function ic(e){return e.startsWith($u())}class oc{destroy(){hu(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():r("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=je(e,t),this.m_hashCode=je(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(),o(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 g("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return g("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),o(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()):(u("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?xl():""}getVerticalUnit(){return g("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const e=this.getCoordinateSystemType();if(0===e)u(Vu);else{if(1===e)return this;3===e&&u("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===hc()||this===mc())t=lc();else{o(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||r(""),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(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(t,s){if(0===t.length)return 0;t.length>s.length&&e("coordsSrc.size() > coordsDst.size()");const n=this.getCoordinateSystemType();if(0===n&&u(Vu),1===n)return et(s,t,t.length),t.length;o(this.m_peCoordSysVal);const r=this.getSRToGCSTransform();return(new qh).transform(r,t,t.length,s)}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=tt(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=tt(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&&(o(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||e("!is_pannable"),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||e("!is_pannable"),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const t=this.getCoordinateSystemType();1!==t&&2!==t&&e("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),o(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()||c("cannot query precision descriptor"),o(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?g("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(o(!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;o(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 o(0),!1}equalVerticalVCS(e){return o(0),!1}convergenceAngle(e){return o(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const e=this.m_peCoordSysVal.m_peCoordSys;return e||r("cannot clone coord sys"),e}return null}getPeVertcsCopy(){return o(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&e(Vu)}getPrimeMeridian(){return this.throwIfLocal(),o(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(),o(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(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),o(this.m_peCoordSysVal);const t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=t.getFlattening();ku(e,t.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&u(""),o(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(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),o(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(_(t))return this.snapMultiVertex_(e);if(t===s.enumPoint)return this.snapPoint_(e);if(t===s.enumEnvelope)return this.snapEnvelope_(e);if(n(t))return this.snapSegment_(e);if(t===s.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}r("what else?")}snapMultiVertex_(e){if(o(!e.isEmpty()),o(2!==this.m_precisionDescriptor.getPrecision()),i(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){o(!e.isEmpty()),o(2!==this.m_precisionDescriptor.getPrecision());const t=new ac;this.queryPrecisionDescriptor(t);const s=e.getStartXY(),n=new Qe;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(),a=new Qe;a.x=pc(i.x,t.getFalseX(),t.getGridUnitsXY()),a.y=pc(i.y,t.getFalseY(),t.getGridUnitsXY()),r||=!a.equals(i),r&&e.changeEndPoints2D(n,a);const h=(t,s,n)=>{let r=!1;{const i=e.getStartAttributeAsDbl(t,0),o=pc(i,s,n),a=!st(o,i);r||=a,a&&e.setStartAttribute(t,0,o)}{const i=e.getEndAttributeAsDbl(t,0),o=pc(i,s,n),a=!st(o,i);r||=a,a&&e.setEndAttribute(t,0,o)}return r};let m=r?1:0;return e.hasAttribute(1)&&(m|=h(1,t.getFalseZ(),t.getGridUnitsZ())?1:0),e.hasAttribute(2)&&(m|=h(2,t.getFalseM(),t.getGridUnitsM())?1:0),!!m}snapGeometryWithCurves_(e){o(!e.isEmpty()),o(2!==this.m_precisionDescriptor.getPrecision());const t=e.createInstance(),s=new F;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 fe;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(e,t,s,n){let r=!1;const i=new ac;if(this.queryPrecisionDescriptor(i),0===e){const e=t;for(let t=s;t<n;t++){const s=e.read(2*t),n=oc.s_SnapValue(s,i.getFalseX(),i.getGridUnitsXY()),o=e.read(2*t+1),a=oc.s_SnapValue(o,i.getFalseY(),i.getGridUnitsXY());r=r||n!==s||a!==o,r&&(e.write(2*t,n),e.write(2*t+1,a))}}else if(1===e){const e=t;for(let t=s;t<n;t++){const s=e.read(t),n=oc.s_SnapValue(s,i.getFalseZ(),i.getGridUnitsZ());r=r||!st(n,s),r&&e.write(t,n)}}else if(2===e){const e=t;for(let t=s;t<n;t++){const s=e.read(t),n=oc.s_SnapValue(s,i.getFalseM(),i.getGridUnitsM());r=r||!st(n,s),r&&e.write(t,n)}}return r}static s_SnapValue(e,t,s){return nt((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=je(t,this.m_falseM),t=je(t,this.m_unitsM),e=je(e,this.m_unitsXY),t=je(t,this.m_toleranceXY),e=je(e,this.m_falseZ),t=je(t,this.m_toleranceZ),e=je(e,this.m_unitsZ),t=je(t,this.m_toleranceM),e=je(e,this.m_precision),je(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 C;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(),r("")}return e}getZGridRange(){const e=new at;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(),r("")}return e}getMGridRange(){const e=new at;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(),r("")}return e}setTolerance(t,s){switch(s<0&&e("tol < 0"),Number.isFinite(s)||e("tol is not finite"),t){case 0:this.m_toleranceXY=s;break;case 1:this.m_toleranceZ=s;break;case 2:this.m_toleranceM=s;break;default:e("cannot set tolerance for this attribute")}}setGridParams(t,s,n){Number.isFinite(t)&&Number.isFinite(s)&&Number.isFinite(n)||e("grid params are not finite"),n<1&&e("grid units cannot be smaller than 1.0"),this.m_falseX=t,this.m_falseY=s,this.m_unitsXY=n}setZParams(t,s){Number.isFinite(t)&&Number.isFinite(s)||e("grid params are not finite"),s<1&&e("grid units cannot be smaller than 1.0"),this.m_falseZ=t,this.m_unitsZ=s}setMParams(t,s){Number.isFinite(t)&&Number.isFinite(s)||e("grid params are not finite"),s<1&&e("grid units cannot be smaller than 1.0"),this.m_falseM=t,this.m_unitsM=s}setPrecision(e){}equals(e){return this===e||st(this.m_falseX,e.m_falseX)&&st(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(!ec||Uu()&&null===ec.getPECoordSys())&&(ec=dc(3857,0,null,!0)),ec}function mc(){return(!tc||Uu()&&null===tc.getPECoordSys())&&(tc=dc(102100,0,null,!0)),tc}function lc(){return(!sc||Uu()&&null===sc.getPECoordSys())&&(sc=dc(4326,0,null,!0)),sc}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*ht(),e.m_toleranceZ=100*ht(),e.m_toleranceM=100*ht(),e.m_precision=2}function uc(t,s,n,r){const i=s instanceof qg;gc(t),t.m_precision=r,t.m_falseX=Number.NaN,t.m_falseY=Number.NaN;const o=1e-4,a=.001,h=i?s.m_csType:s.isPCS?2:1;if(1===h){const e=(0===r?1/18e5:1e-9)*(i?s.getOneDegreeGCSUnit():Math.PI/s.metersOrRadiansPerUnit/180);t.m_unitsXY=1/e}else if(2===h){const e=(0===r?a:o)*(i?s.getOneMeterPCSUnit():1/s.metersOrRadiansPerUnit);t.m_unitsXY=1/e}else e("unrecognized cs type");t.m_falseM=-1e5,t.m_unitsM=1/(0===r?a:o),t.m_unitsM=Math.max(1,t.m_unitsM),t.m_unitsXY=Math.max(1,t.m_unitsXY);let m=0,l=0;0!==r&&1!==r||(m=2/t.m_unitsXY,l=2/t.m_unitsM),t.m_toleranceXY=Math.max(m,i?s.getUnitsPerMillimeter():2===h?.001/s.metersOrRadiansPerUnit:.001/(s.semiMajor*s.metersOrRadiansPerUnit)),t.m_toleranceM=Math.max(a,l),cc(t,n)}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 nt((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){o(kc);const t=kc(e);return t.semiMajor=t.isPCS?Number.NaN:Rc(e),t}function Mc(e){kc=e,o(kc)}function Uc(e){const t=e;Ic=t.PeFactory,o(Ic),Fc=t.PeGCSExtent,o(Fc),Dc=t.PeLineType,o(Dc),Vc=t.PeMath,o(Vc),Cc=t.PeDouble,o(Cc),bc=t.PeDefs,o(bc),wc=t.PeCSTransformations,o(wc),vc=t.PeGTTransformations,o(vc),Nc=t.PePCSInfo,o(Nc),Tc=t.PeGTlistExtended,o(Tc),Ic.initialize(),Gc=t.PeGTlistExtendedEntry,o(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){o(qu());return!!kc(e).isPCS||Oc(e)}function Oc(e){return Ic&&u("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(t){if(Ic&&u("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof t){const s=t.match(Yc);s&&2===s.length||e("bad gcs wkt");const n=Number.parseFloat(s[1]);return Number.isFinite(n)||e("bad gcs wkt"),n}return fc||Xc(),fc.has(t)||u("gcs wkid not found"),fc.get(t)}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||f(e);return new Kc(s,t)}function zc(e,t){const s=Ic.fromString(bc.PE_TYPE_GEOGTRAN,e);s||S(e);return new Kc(s,t)}function Wc(e,t){return new Kc(e,t)}const jc=Ze(0),Zc=Ze(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=je(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc));this.m_geogTranWrapper=new Um(e),this.m_bInverted=t,this.m_hashCode=je(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(e,t,s,n,r){const i=e.getGCS(),a=t.getGCS(),h=i.getPECoordSys(),m=a.getPECoordSys();let l=null;if(!s.isEmpty()){const t=s.clone();if(!t.isEmpty()&&2===e.getCoordinateSystemType()){let s=new pe({env2D:t});const n=Rg(e,i,null);s=(new qh).execute(s,n,null),s.queryEnvelope(t)}if(!t.isEmpty()){const e=h.getPrimem().getLongitude(),s=h.getUnit().getUnitFactor();l=new Fc(t.xmin,t.ymin,t.xmax,t.ymax,e,s)}}let g=n;g>=vt()&&(g=0);const u=[];let c=Tc.PE_GTLIST_OPTS_COMMON;r||(c&=~Tc.PE_GTLIST_OPTS_USABLE);for(let _=0;_<2;_++){u.length=0;const e=g,t=Tc.getGTlist(h,m,2,c,l,e);let s=!1;if(t&&t.length>0)for(let i=0,a=t.length;i<a;i++){const e=$c([t[i]]);if(o(e),r&&e.referencesMissingData())s=!0;else if(u.push(e),n>0&&u.length===n)break}if(!s)break;0===g||(g=0)}return l&&l.destroy(),u}function Jc(){return new e_([],null,null,null)}function $c(e){o(null!==e);const t=new t_,s=e[0].getSteps();if(s){const n=e[0].getEntries();for(let e=0;e<s;e++){const s=0!==n[e].getDirection(),r=Wc(n[e].getGeogtran(),s);t.add(r)}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=je(e,this.m_transforms[t].getHashCode());return e}equals(e){return o(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 o(0),!1}validateTransformation(e,t){return o(0),!1}nameIsSet(){return o(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&E(""),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=rt(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 ae(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())&&E(""),this.m_transforms[e]}setStep(e,t){o(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){o(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}}export{t_ as $,Wg as A,Qg as B,zg as C,Eh as D,jm as E,ul as F,wh as G,Lo as H,Lm as I,kr as J,Km as K,al as L,ih as M,hh as N,qh as O,eu as P,da as Q,_a as R,oc as S,aa as T,Ka as U,Fa as V,fa as W,Ma as X,la as Y,Zn as Z,Ko as _,ac as a,Lc as a0,zc as a1,Jc as a2,Al as a3,Tl as a4,Zl as a5,Cc as a6,Dc as a7,wc as a8,ds as a9,Cs as aA,jl as aB,bc as aC,cl as aD,fg as aE,sr as aF,ir as aG,zm as aH,Wm as aI,ha as aJ,Ra as aK,ka as aL,er as aM,Sa as aN,ya as aO,pa as aP,nh as aQ,tn as aR,sn as aS,Ys as aT,Ic as aU,zl as aV,ks as aW,Hm as aX,ss as aY,Wl as aa,mg as ab,cs as ac,Xl as ad,ql as ae,Wo as af,Ps as ag,Vc as ah,Oh as ai,Yh as aj,as as ak,Ag as al,cm as am,kl as an,Pc as ao,um as ap,Lh as aq,zh as ar,Rh as as,Xh as at,_m as au,qs as av,Is as aw,vs as ax,Th as ay,Us as az,Yu as b,Ou as c,Ru as d,Wu as e,Lu as f,zu as g,Zu as h,rc as i,qu as j,Uu as k,Mu as l,Au as m,Bu as n,ic as o,Ku as p,Qu as q,Hu as r,ju as s,mc as t,lc as u,Og as v,hc as w,Rg as x,Yg as y,Lg as z};
|
|
5
|
+
import{a as e,c as t,G as s,f as n,d as r,h as i,g as o,s as a,u as h,v as m,w as l,t as g,p as u,r as c,i as _,e as d,x as p,y as f,o as x,z as y,l as P,q as E,A as S}from"./Geometry.js";import{Envelope2D as C}from"./Envelope2D.js";import{P as I,y as b,z as w,a as v,M as N,A as T,E as G,c as D,g as V,S as F,L as H,B as k,F as A,n as M,H as U,I as q,J as B,Q as O,D as Y,l as R,K as X,N as L,O as z,V as W,R as j,T as Z,U as K,W as Q,X as J,Y as $,Z as ee,_ as te,$ as se,a0 as ne,a1 as re,a2 as ie,a3 as oe,a4 as ae,b as he}from"./MultiPathImpl.js";import{b as me,a as le,j as ge,k as ue,i as ce,g as _e,c as de,E as pe,P as fe,C as xe,e as ye,I as Pe,T as Ee,l as Se,A as Ce,B as Ie,m as be,n as we,o as ve,V as Ne,p as Te,q as Ge,r as De,t as Ve,u as Fe,v as He,w as ke,x as Ae,y as Me,h as Ue,z as qe,S as Be,D as Oe,F as Ye,d as Re,G as Xe,H as Le,J as ze,f as We}from"./Envelope.js";import{A as je,B as Ze,d as Ke,P as Qe,C as Je,v as $e,D as et,n as tt,F as st,G as nt,c as rt,e as it,r as ot,E as at,H as ht,l as mt,m as lt,K as gt,a as ut,I as ct,J as _t,L as dt,S as pt,q as ft,f as xt,N as yt,O as Pt,g as Et,Q as St,o as Ct,s as It,j as bt,b as wt,i as vt,h as Nt,k as Tt,R as Gt,T as Dt,M as Vt,U as Ft,V as Ht,W as kt,X as At,Y as Mt,Z as Ut,_ as qt,$ as Bt,a0 as Ot,a1 as Yt,y as Rt,a2 as Xt,p as Lt}from"./Point2D.js";import{__addDisposableResource as zt,__disposeResources as Wt}from"tslib";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(t){return this.getUnitType()!==t.getUnitType()&&e("unit type mismatch"),this.getUnitToBaseFactor()/t.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return je(Ze(this.getUnitType()),Ze(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,10799,10800,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,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,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,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,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,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(t){return t.getType()===bc.PE_TYPE_LINUNIT?new bu(t):t.getType()===bc.PE_TYPE_ANGUNIT?new os(t):void e("peUnit")}function ms(t){const s=Hc(null);return t.getType()===bc.PE_TYPE_PROJCS||t.getType()===bc.PE_TYPE_GEOGCS?s.reset(t.getUnit()):e("PE_coord_sys"),s.get()||r("cannot create units from coord sys"),hs(s.get())}class ls{constructor(t,s,n){void 0===t?(this.x=new At,this.y=new At,this.z=new At):t instanceof Re?(this.x=new At(t.x),this.y=new At(t.y),this.z=new At(t.z)):t instanceof At?(this.x=t.clone(),this.y=s.clone(),this.z=n.clone()):e("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 Re.construct(this.x.value(),this.y.value(),this.z.value())}}class gs{constructor(e){if(this.m_origin=new Re,this.m_normal=new Re,this.m_axisX=new Re,this.m_axisY=new Re,!e)return this.m_origin=new Re,this.m_normal=new Re(0,0,1),this.m_axisX=new Re(1,0,0),void(this.m_axisY=new Re(0,1,0));e.pt0&&e.pt1&&e.pt2?this.setFromPoints(e.pt0,e.pt1,e.pt2):o(0,`unimplemented constructor options ${JSON.stringify(e)}`)}assign(e){return o(0),this}set(e,t,s,n){o(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 o(0),{}}getCoord2D(e){return o(0),{}}getCoordX(e,t){return o(0),0}getCoordY(e,t){return o(0),0}getCoordZ(e,t){return o(0),0}setPreferredAxisX(e){o(0)}getOrigin(){return o(0),{}}getNormal(){return o(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(e,t=!1){o(0)}setAxisY(e,t=!1){o(0)}recalculateAxisY(){o(0)}setOrigin(e){o(0)}setNormal(e,t){o(0)}intersect(e,t){return o(0),!1}intersectLine(e){return o(0),0}intersectLineEx(e,t){return o(0),0}closestCoordinate(e){const t=e.sub(this.m_origin),s=new Qe;return s.x=t.dotProduct(this.m_axisX),s.y=t.dotProduct(this.m_axisY),s}projectVector(e){return o(0),{}}signedDistance(e){return o(0),0}distance(e){return o(0),0}}function us(e,t){return!1}function cs(e,t,s,n,r=100,i=us){let a,h,m,l,g,u,c,_,d;o(n>0);let p,f,x,y=0,P=0;const E=Yt();t>s&&(s=rt(t,t=s));const S=e(t),C=e(s);S<C?(a=h=m=t,l=g=u=S):(a=h=m=s,l=g=u=C);let I=0;for(;I<r&&(x=.5*(s-t),d=t+x,p=n*(Math.abs(a)+.25),f=2*p,!(i(a,l)||Math.abs(a-d)<=f-x));++I){if(Math.abs(P)>p){const e=(a-h)*(l-u);let n=(a-m)*(l-g),r=(a-m)*n-(a-h)*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-a)||r>=n*(s-a)?(P=a>=d?t-a:s-a,y=Yt()*P):(y=r/n,_=a+y,(_-t<f||s-_<f)&&(y=d-a<0?-Math.abs(p):Math.abs(p)))}else P=a>=d?t-a:s-a,y=P*E;_=a+y,c=e(_),c<l?(_>=a?t=a:s=a,m=h,h=a,a=_,u=g,g=l,l=c):(_<a?t=_:s=_,c<=g||h===a?(m=h,h=_,u=g,g=c):(c<=u||m===a||m===h)&&(m=_,u=c))}return mt(a,l)}function _s(e,t,s){if(e>s){e-=Math.ceil((e-s)/Lt)*Lt}else if(e<t){e+=Math.ceil((t-e)/Lt)*Lt}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 Re.construct(m,l,g)}function ys(e,t,s){const n=new At,r=new At,i=new At,o=new At;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 At(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 Qe.construct(o,h)}function Es(e,t,s){const n=1-t,r=e/Math.sqrt(ut(s.x)+ut(s.y)+ut(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,Re.lerp(i,o,r))}function Cs(e,t,s){const n=new Re;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 Re;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(e,t,s,n){const r={stack:[],error:void 0,hasError:!1};try{const i=zt(r,new Cc,!1);return Dc.geodeticDistance(e,t,s.x,s.y,n.x,n.y,i,null,null,bc.PE_LINETYPE_GEODESIC),i.val}catch(i){r.error=i,r.hasError=!0}finally{Wt(r)}}function ws(e,t,s,n,r){switch(o(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 Re.distance(r,i)}default:g("")}}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,Re.lerp(n,r,s));return ws(e,t,a,o,i)},m=Re.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,Re.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 Re(0,0,0),pt1:n,pt2:r}),h=i.closestCoordinate(s),m=i.closestCoordinate(n),l=i.closestCoordinate(r),g=Qe.getClosestCoordinate(m,l,h),u=Es(e,t,Re.lerp(n,r,g)),c=Re.distance(u,a);return o&&o.assign(u),mt(g,c)}const h=s=>{const i=Es(e,t,Re.lerp(n,r,s));return Re.distance(i,a)},m=Re.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,Re.lerp(n,r,i))),mt(i,a)}{const e=Re.distance(s,n);return o&&o.assign(s),mt(.5,e)}}function Ts(e,t,s,n){const r={stack:[],error:void 0,hasError:!1};try{const n=zt(r,new Cc,!1);return Dc.greatEllipticDistance(e,t,s.x,s.y,s.x,s.y,n,null,null),n.val}catch(i){r.error=i,r.hasError=!0}finally{Wt(r)}}function Gs(e,t,s,n,r){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>Ct||Math.abs(n.y)>Ct)return Number.NaN;if((Math.abs(s.y)===Ct||Math.abs(n.y)===Ct)&&s.x!==n.x)return Number.NaN;const{first:i,second:o}=kt(s.x,n.x);let a=r;a=_s(a,i,o);if(!at.construct(s.x,n.x).containsCoordinate(a))return Number.NaN;const h=J.constructPoint2D(s),m=J.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,Qe.construct(a,f)),y=Re.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)>Ct||Math.abs(n.y)>Ct)return 0;if((Math.abs(s.y)===Ct||Math.abs(n.y)===Ct)&&s.x!==n.x)return 0;if(Math.abs(r)>=Ct)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=J.constructPoint2D(s),a=J.constructPoint2D(n),h=ys(1,t,o),m=ys(1,t,a),l=h.crossProductVector(m);if(l.z.isZero()){return at.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]),o(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=It(n,-Ct,Ct),r=It(r,-Ct,Ct);const i=Ct-.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=ut(t)/(e-1);for(let e=o.length-1;e>=0;--e)s=o[e]+s*n;return s*=-ut(t/(1-e)),s},h=a(Ct-t);return(a(Ct-s)-h)*n}{const e=Ct-t,r=Ct-s,i=-4*ut(Math.sin(e/2));return(-4*ut(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*Rt(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*Ut()/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)=>Pt(e,t),Ze(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 Ye{constructor(e){super(),this.m_bufferLeft=new F,this.m_bufferRight=new F,this.m_intervalLeft=at.constructEmpty(),this.m_intervalRight=at.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 F,this.m_point=Qe.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 at;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!==M;){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!==M;){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 Be(8),this.m_clusterVertices=new Be(2),this.m_firstCluster=M,this.m_lastCluster=M,this.m_halfEdgeData=new Be(8),this.m_chainData=new Be(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,n=null,r=!1){const i=[];i.push(t),this.m_simplifiedGeometry=t,r?this.setEditShapeImpl3D_(e,Zs.enumInputModeSimplifyAlternate,i,n,!1):this.setEditShapeImpl_(e,Zs.enumInputModeSimplifyAlternate,i,n,e.getGeometryType(t)===s.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=M,this.m_lastCluster=M,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=M,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){o(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 Ce(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){o(0)}getHalfEdgeToXYZ(e,t){o(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 Ce(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 o(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,M),this.setChainHalfEdge_(i,M),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(e,t){return o(0),!1}doesHalfEdgeBelongToAPolygonExterior(e,t){return o(0),!1}doesHalfEdgeBelongToAPolygonBoundary(e,t){return o(0),!1}doesHalfEdgeBelongToAPolylineInterior(e,t){return o(0),!1}doesHalfEdgeBelongToAPolylineExterior(e,t){return o(0),!1}doesClusterBelongToAPolygonInterior(e,t){return o(0),!1}doesClusterBelongToAPolygonExterior(e,t){return o(0),!1}doesClusterBelongToAPolygonBoundary(e,t){return o(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 o(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 Ce(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,n,r){const i=t===M?e.createGeometry(s.enumPolygon):t,o=new F;this.extractPolygonPathFromChain_(e,i,n,r,o);for(let s=this.getChainFirstIsland(n);s!==M;s=this.getChainNextInParent(s))this.extractPolygonPathFromChain_(e,i,s,r,o);return i}getGeometryID(e){const t=this.m_shape.getGeometryUserIndex(e,this.m_geometryIDIndex);return o(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(o(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const t=this.getChainUserIndex(e,this.m_chainBitSetIndex);o(t>=0);let s=this.m_chainBitSets.at(t);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(e){o(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!==M;n=this.getChainNextInParent(n))s(e);return t}getChainPolygons(e){return o(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!==M;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())o(this.m_geometryMapID.has(n)),t.push(this.m_geometryMapID.get(n));return t}getVertexDominant(e,t){if(t===M)return e;const s=this.getClusterFromVertex(e);return this.getVertexDominantFromCluster(s,t)}getVertexDominantFromCluster(e,t){if(t!==M){let s=M;for(let n=this.getClusterVertexIterator(e);n!==M;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);s===M&&(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!==M){return this.getVertexFromVertexIterator(t)}return M}}isBreakNode(e){return this.hasClusterUserIndexFlags(e,this.m_clusterBreakNodeIndex,Ks.enumSegmentParentageBreakNode)}setBreakNode(e,t){o(-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 o(0),!1}getHalfEdgeConnector(e,t){const s=this.getClusterHalfEdge(e);if(s===M)return M;let n=s,r=M,i=M;do{if(this.getHalfEdgeTo(n)===t)return n;if(r===M){if(r=this.getClusterHalfEdge(t),r===M)return M;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 M}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=Qe.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 F,r=new F;this.querySegmentXY(e,n),this.querySegmentXY(t,r);const i=n.get(),a=r.get();if(i.equals(a))return 0;const h=new Qe;this.getHalfEdgeFromXY(e,h);const m=new Qe;this.getHalfEdgeToXY(e,m);const l=new Qe;this.getHalfEdgeToXY(t,l),o(!m.isEqualPoint2D(l));return q(i,a)}compareEdgeAnglesHelper_(e,t,s){if(e===t)return 0;if(this.isHalfEdgeCurve(e)||this.isHalfEdgeCurve(t))return this.compareEdgeAnglesCurveHelper_(e,t,s);const n=Qe.getNAN();this.getHalfEdgeToXY(e,n);const r=Qe.getNAN();if(this.getHalfEdgeToXY(t,r),n.isEqualPoint2D(r))return 0;const i=Qe.getNAN();this.getHalfEdgeFromXY(e,i);const o=Qe.getNAN();o.setSub(n,i);const a=Qe.getNAN();if(a.setSub(r,i),!s||a.y>=0&&o.y>0){return Qe.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 o(0),0}compareEdgeAnglesForPair3D_(e,t){return o(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(e,t){}deleteEdgeInternal_(e){const t=this.getHalfEdgeChain(e),s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(s);o(n===t),o(e===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(e));let r=this.getHalfEdgeNext(e);r===s&&(r=this.getHalfEdgeNext(r),r===e&&(r=M));const i=this.getChainIndex_(t),a=this.m_chainAreas.read(i);Number.isNaN(a)||(this.setChainArea_(t,Number.NaN),this.setChainPerimeter_(t,Number.NaN));const h=this.getChainHalfEdge(t);h!==e&&h!==s||this.setChainHalfEdge_(t,r),this.updateVertexToHalfEdgeConnection_(e,!0),this.deleteEdgeImpl_(e)}getFirstUnvisitedHalfEdgeOnCluster_(e,t,s){let n=t!==M?t:this.getClusterHalfEdge(e);if(n===M)return M;const r=n;for(;;){if(1!==this.getHalfEdgeUserIndex(n,s))return n;const e=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));if(e===r)return M;n=e}}removeSpikes_(){let e=!1;const t=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==M;s=this.getNextCluster(s)){let n=M;for(;;){let r=this.getFirstUnvisitedHalfEdgeOnCluster_(s,n,t);if(r===M)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=M),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 o(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?M:e;for(let n=this.getHalfEdgeVertexIterator(e);n!==M;n=this.incrementVertexIterator(n)){const e=this.getVertexFromVertexIterator(n);this.m_shape.setUserIndex(e,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(e,t){e!==M&&(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 gt(0),n=new gt(0),r=this.getChainHalfEdge(e),i=Qe.getNAN(),o=Qe.getNAN(),a=Qe.getNAN();this.getHalfEdgeFromXY(r,i),o.setCoordsPoint2D(i);let h=r;do{this.getHalfEdgeToXY(h,a),t&&this.isCurveEdge(h)||n.pe(Qe.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 F;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 o(0),0}planeSweepParentage_(e,t){const s=new Ws(this),n=new Ee;n.setCapacity(Math.trunc(this.m_pointCount/2)),n.setComparator(s);const r=[],i=this.createUserIndexForHalfEdges();let o=null;const a=Qe.getNAN();for(let h=this.getFirstCluster();h!==M;h=this.getNextCluster(h)){this.progress_(t);const m=this.getClusterHalfEdge(h);if(m!==M){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,Be.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)===M){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!==M&&(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)!==M)return;const i=this.getLeftSkipPolylines_(e,t),a=this.getHalfEdgeTwin(n),h=this.getHalfEdgeChain(a);let m=this.getChainParent(r),l=this.getChainParent(h);if(i===M)m===M&&(h===r?(this.setChainParent_(h,this.m_universeChain),l=this.m_universeChain,m=l):(l===M&&(this.setChainParent_(h,this.m_universeChain),l=this.m_universeChain),this.setChainParent_(r,h),m=h));else{const e=this.getHalfEdgeChain(i);if(l===M){if(this.getChainArea(e)<=0){const t=this.getChainParent(e);this.setChainParent_(h,t),l=t}else this.setChainParent_(h,e),l=e;h===r&&(m=l)}}m===M&&(this.trySetChainParentFromTwin_(r,h),m=this.getChainParent(r)),o(m!==M),s===Zs.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(e,t,n,i):s===Zs.enumInputModeSimplifyWinding?this.propagateParentageWinding_(e,t,n,i,a,r,h):s===Zs.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(e,t,n,i,a,r,h)}propagateParentageBuildGraph_(e,t,s,n){let r,i=t;n===M?(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,a){if(i===a)return;let h=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);h+=this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);let m=0;const l=[],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),m+=e;let i=!1;0!==l.length&&l.at(-1)===r&&(g.pop(),l.pop(),i=!0),o(this.getChainParent(r)!==M),i&&this.getChainParent(r)===n||(g.push(m),l.push(n))}}if(m+=h,0!==l.length&&l.at(-1)===a&&(g.pop(),l.pop()),0!==m){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===M){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=M,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!==M)return!1;a=i}h++,i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i))}while(r!==i);return a!==M&&-1!==o&&(this.setHalfEdgeUserIndex(e.getElement(o),t,Be.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!==M)return this.setChainParent_(e,s),!0}return!1}createHalfEdges_(e,t){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let n=0,r=t.size();n<r;n++){const r=t.read(n),o=this.m_shape.getUserIndex(r,this.m_clusterIndex),a=this.m_shape.getPathFromVertex(r),h=this.m_shape.getGeometryFromPath(a),m=this.m_shape.getGeometryType(h);if(i(m)){const t=this.m_shape.getNextVertex(r);if(t===M)continue;const n=this.m_shape.getUserIndex(t,this.m_clusterIndex);if(o===n)continue;const i=this.newHalfEdgePair_(),a=this.getHalfEdgeTwin(i),l=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(l,0,r),this.m_clusterVertices.setField(l,1,-1),this.setHalfEdgeVertexIterator_(i,l),this.m_shape.setUserIndex(r,this.m_halfEdgeIndex,i),this.setHalfEdgeOrigin_(i,o);const g=this.getClusterHalfEdge(o);if(g===M)this.setClusterHalfEdge_(o,i),this.setHalfEdgePrev_(i,a),this.setHalfEdgeNext_(a,i);else{const e=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,a),this.setHalfEdgeNext_(a,g),this.setHalfEdgeNext_(e,i),this.setHalfEdgePrev_(i,e)}this.setHalfEdgeOrigin_(a,n);const u=this.getClusterHalfEdge(n);if(u===M)this.setClusterHalfEdge_(n,a),this.setHalfEdgeNext_(i,a),this.setHalfEdgePrev_(a,i);else{const e=this.getHalfEdgePrev(u);this.setHalfEdgePrev_(u,i),this.setHalfEdgeNext_(i,u),this.setHalfEdgeNext_(e,a),this.setHalfEdgePrev_(a,e)}const c=this.getGeometryID(h);if(e===Zs.enumInputModeBuildGraph){const e=m===s.enumPolygon?c:0;if(this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndex,e),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,e),this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const e=new Ls,t=this.m_shape.getGeometryUserIndex(h,this.m_geometryIDIndex);e.setBit(t),this.setEdgeBitSet_(i,e),this.setEdgeBitSet_(a,null),this.setLeftEdgeBitSet_(a,e),this.setLeftEdgeBitSet_(i,null)}}else if(e===Zs.enumInputModeSimplifyWinding){const e=this.m_shape.getXY(r),s=this.m_shape.getXY(t);let n=0,o=0;e.compare(s)<0?n=1:o=-1,this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex,n),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,o)}else e===Zs.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(i,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const _=m===s.enumPolygon?tn.c_EdgeBitMask:0;this.setHalfEdgeParentage_(i,c|_),this.setHalfEdgeParentage_(a,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!==M&&(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!==M){const n=this.getHalfEdgeVertexIterator(e);this.m_clusterVertices.setField(s,1,n),this.setHalfEdgeVertexIterator_(e,s),this.setHalfEdgeVertexIterator_(t,M)}}const s=this.getHalfEdgeTwin(e),n=this.getHalfEdgeTwin(t);{const e=this.getHalfEdgeVertexIterator(n);if(e!==M){const t=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(e,1,t),this.setHalfEdgeVertexIterator_(s,e),this.setHalfEdgeVertexIterator_(n,M)}}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!==M;s=this.getNextCluster(s)){t.length=0;const n=this.getClusterHalfEdge(s);if(n!==M){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]=rt(t[0],t[0]=t[1]):r=!1;let i=t[0],o=i,a=this.getHalfEdgeTo(o),h=this.getHalfEdgeTwin(o),m=M;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=M,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]=M,n===i&&(t[0]=M,i=M)}}if(this.updateVertexToHalfEdgeConnection_(m,!1),m=M,!r){i=M;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s!==M){i=s;break}}n!==i&&this.setClusterHalfEdge_(s,i);continue}i=M;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s===M)continue;if(i===M){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){o(0)}buildChains_(e){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,M);let t=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let n=this.getFirstCluster();n!==M;n=this.getNextCluster(n)){const e=this.getClusterHalfEdge(n);if(e!==M){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 Oe(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new Oe(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){o(0)}simplifyAlternate_(){o(0)}simplifyWinding_(){o(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 Ce(0);let a=0,h=0;{let e=null!=s?s[0]:this.m_shape.getFirstGeometry(),t=1;for(;e!==M;){this.m_shape.setGeometryUserIndex(e,this.m_geometryIDIndex,h++);for(let t=this.m_shape.getFirstPath(e);t!==M;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)}d(this.m_shape.getGeometryType(e))||(a+=this.m_shape.getPathCount(e)),null!=s?(e=t<s.length?s[t]:M,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=Qe.getNAN();let l=0;const g=Qe.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=M,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!==M&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===M&&(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!==M;){for(let t=this.m_shape.getFirstPath(e);t!==M;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]:M,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){o(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_(){o(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,M));const a=this.getHalfEdgeOrigin(n);this.getClusterHalfEdge(a)===n&&(t!==n?this.setClusterHalfEdge_(a,t):this.setClusterHalfEdge_(a,M)),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 M;{const t=e.getElement(s);if(this.getHalfEdgeChain(t)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(t)))return t}}}checkStructureAfterDirtySweep_(){const e=ut(this.m_checkDirtyPlanesweepTolerance),t=new Qe,s=new Qe,n=new Qe,r=new Qe,i=new Qe;for(let o=this.getFirstCluster();o!==M;o=this.getNextCluster(o)){const a=this.getClusterHalfEdge(o);if(a!==M){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=M;const m=new fe;do{const o=this.getHalfEdgeTwin(a);if(this.getHalfEdgeChain(o)!==s){let s=M;const o=this.getHalfEdgeOrigin(a);if(n===M){const e=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(e)}else for(let e=this.getClusterVertexIterator(o);e!==M;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);s===M&&(s=t);const r=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(r)===n){s=t;break}}let l;if(h===M&&(h=e.insertPath(t,M),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;o(-1!==this.m_clusterBreakNodeIndex),o(-1===this.m_segmentParentageIndex);for(let n=this.getFirstCluster();n!==M;n=this.getNextCluster(n)){let e=0;const t=this.getClusterHalfEdge(n);if(t!==M){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!==M;n=this.getNextCluster(n)){const r=this.getClusterHalfEdge(n);if(r!==M){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=rt(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 o(t>=0),o(this.m_edgeBitSets.at(t)),this.m_edgeBitSets.at(t)}getEdgeBitSet_(e){const t=this.getHalfEdgeUserIndex(e,this.m_edgeBitSetIndex);return o(t>=0),this.m_edgeBitSets.at(t)}setEdgeBitSet_(e,t){o(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){o(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){o(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){o(0)}constructor(e){this.m_listNodes=new Be(2),this.m_listOfLists=sn.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===e&&(e=!0),this.m_bAllowNavigationBetweenLists=e,this.m_lists=new Be(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){o(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 o(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 H,m_segment:null,m_segmentInfo:new re(-1),m_env:new at(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}const rn=67;class on extends Ye{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=M,this.m_prev2=M,this.m_vertex1=M,this.m_vertex2=M,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 Qe,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&bt())%this.m_simpleEdgesCache.length];return t&&t.m_value===e?t:null}tryDeleteCachedEdge_(e){const t=(e&bt())%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&bt())%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++){St(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=Qe.getNAN();s.setSub(t.getEndXY(),t.getStartXY()),s.rightPerpendicularThis(),s.normalize();const n=Qe.getNAN();n.setSub(e.getStartXY(),t.getStartXY());const r=Qe.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=M,this.m_prev2=M,this.m_vertex1=M,this.m_vertex2=M;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=M),r&&t===this.m_prev2?o=this.m_prevX2:(o=Number.NaN,this.m_prev2=M),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=j(!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=M,this.m_prev2=M,this.m_vertex1=M,this.m_vertex2=M}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=Qe.getNAN(),this.m_line1=new H,this.m_seg1=null,this.m_env=at.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,s){let n,r=this.m_shape.getSegment(s),i=!0;if(null==r)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),r=this.m_line1,n=this.m_line1.getStartY()===this.m_line1.getEndY();else{const e=C.constructEmpty();r.queryLooseEnvelope(e),e.queryIntervalX(this.m_env),n=0===e.height(),i=!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(n)return this.m_currentNode=t,this.m_bIntersectionDetected=!0,0;let o=0;if(i){Q(this.m_line1);const e=this.m_line1.getStartXY(),t=new Qe;t.setSub(this.m_line1.getEndXY(),e),t.rightPerpendicularThis();const s=new Qe;s.setSub(this.m_pointOfInterest,e),o=t.dotProduct(s),o/=t.length()}else{o=r.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x}if(o<10*-this.m_tolerance)return-1;if(o>10*this.m_tolerance)return 1;if(r.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)){Math.abs(o)<this.m_minDist&&(this.m_currentNode=t,this.m_minDist=o),this.m_bIntersectionDetected=!0}return o<0?-1:o>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(t,s){void 0===s&&(s=this.m_hash.getHash(t));const n=s%this.m_hashBuckets.length,r=this.m_hashBuckets[n];r===sn.st_nullNode()&&e("");let i=this.m_lists.getFirst(r),o=sn.st_nullNode();for(;i!==sn.st_nullNode();){const e=this.m_lists.getData(i),s=this.m_lists.getNext(i);e===t?(this.m_lists.deleteElementDirect(r,o,i),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[n]=sn.st_nullNode())):o=i,i=s}}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(t){const s=this.getElement(t),n=this.m_hash.getHash(s)%this.m_hashBuckets.length,r=this.m_hashBuckets[n];r===sn.st_nullNode()&&e(""),this.m_lists.deleteElementSearch(r,t),this.m_lists.getFirst(r)===sn.st_nullNode()&&(this.m_lists.deleteList(r),this.m_hashBuckets[n]=sn.st_nullNode())}getElement(e){return this.m_lists.getData(e)}static st_nullNode(){return sn.st_nullNode()}clear(){o(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 Qe,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=Xt(e);return Mt(s,t)}class pn{constructor(e,t,s,n,r){this.m_workPt=new Qe,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 o(0),!1}}class fn{constructor(e){this.m_origin=Qe.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=M,this.m_bucketArray=Ke(4,Number.NaN),this.m_bucketHash=Ke(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=Qe.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=Qe.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,Be.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=Qe.getNAN();this.m_shape.queryXY(e,s);const n=Qe.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 e={stack:[],error:void 0,hasError:!1};try{zt(e,Nt(()=>{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(),s=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(s.getLowerLeft());const n=Math.max(s.height(),s.width())/(vt()-1);this.m_cellSize<n&&(this.m_cellSize=n,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 r=!1;for(let e=0;e<2;e++){const t=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==M;n=s.next()){if(this.progress_(),e>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===Be.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],i=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,i))return this.m_nsr=new ts(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(i)),r=!0,r;this.mergeClusters(n,i,!1)}t.length=0}0===e&&this.m_hashTable.addElement(n,s)}}return r}catch(t){e.error=t,e.hasError=!0}finally{Wt(e)}}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())/(vt()-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!==M;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!==M;s=t.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===Be.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=Qe.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 fe,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&&r(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=e;const s=ut(e*xn.c_smallToleranceFactor);let n=!1;const i=this.m_inputParts[0],o=this.m_inputParts[1],a=this.m_inputSegments[i.segmentIndex],h=this.m_inputSegments[o.segmentIndex];if(t||5&U(!0,a,h,e,!0)){const t=Z(!0,a,h,null,this.m_param1,this.m_param2,e);0===t&&r("");const m=new Array(t);for(let e=0;e<t;++e)m[e]=Qe.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],r=this.m_param2[e];let _,d=i.rankInterior,p=i.weightInterior;0===t?(d=i.rankStart,p=i.weightStart,_=i.u.bBreakStart):1===t?(d=i.rankEnd,p=i.weightEnd,_=i.u.bBreakEnd):(this.m_changed1=!0,_=!1);let f,x=o.rankInterior,y=o.weightInterior;0===r?(x=o.rankStart,y=o.weightStart,f=o.u.bBreakStart):1===r?(x=o.rankEnd,y=o.weightEnd,f=o.u.bBreakEnd):(this.m_changed2=!0,f=!1);const P=d,E=x;let S=1,C=0,I=Qe.getNAN();if(P===E){const n=a.getCoord2D(t),i=h.getCoord2D(r);S=p+y;C=d,St(n,i,y/S,I);const o=Qe.sqrDistance(I,n),m=Qe.sqrDistance(I,i);u[e].bBigMove=o>s,c[e].bBigMove=m>s,this.m_changed1||n.equals(I)||(this.m_changed1=!0),this.m_changed2||i.equals(I)||(this.m_changed2=!0)}else if(P>E){I=a.getCoord2D(t);const n=h.getCoord2D(r);S=p,C=d;const i=Qe.sqrDistance(I,n);u[e].bBigMove=!1,c[e].bBigMove=i>s,this.m_changed2||n.equals(I)||(this.m_changed2=!0)}else{I=h.getCoord2D(r),S=y,C=x;const n=a.getCoord2D(t),i=Qe.sqrDistance(I,n);u[e].bBigMove=i>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 _=i.rankInterior,d=i.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 r=this.allocResultSegment(),o=this.m_resultSegments[r];let h,c,x,y;a.queryCut(p,n,o,!1),o.get().snapControlPoints(e*e);let P=!1,E=!1,S=!1,C=!1,I=!1,b=Qe.getNAN(),w=Qe.getNAN();-1!==f?(c=g[f],h=l[f],P=u[f].bBigMove,b.assign(m[f]),S=u[f].bIsBreak,I=!0):(h=i.weightStart,c=i.rankStart,b=o.get().getStartXY(),S=i.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=i.weightEnd,y=i.rankEnd,w=o.get().getEndXY(),C=i.u.bBreakEnd),I&&o.get().setCoordsForIntersector(b,w,!0),this.m_resultParts1.push(this.newIntersectionPart_(r,h,c,x,y,d,_,S,C,i.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=Ke(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),$e(this.m_param2)):2===t&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=rt(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),x[1]=rt(x[0],x[0]=x[1]));const y=o.rankInterior,P=o.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(),i=this.m_resultSegments[r];let a,u,_,d;h.queryCut(p,n,i,!1),i.get().snapControlPoints(e*e);let E=Qe.getNAN(),S=Qe.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=o.weightStart,u=o.rankStart,E=i.get().getStartXY(),C=o.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 _=o.weightEnd,d=o.rankEnd,S=i.get().getEndXY(),I=o.u.bBreakEnd;v&&i.get().setCoordsForIntersector(E,S,!0),this.m_resultParts2.push(this.newIntersectionPart_(r,a,u,_,d,P,y,C,I,o.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 o(0),1}intersect2D(e,t){const n=this.m_inputParts[0],r=this.m_inputParts[1],i=this.m_inputSegments[n.segmentIndex].getGeometryType(),o=this.m_inputSegments[r.segmentIndex].getGeometryType();if(i!==s.enumLine||o!==s.enumLine){return new bn(this).intersectCurves(e,t)}return this.intersectLines(e,t)}intersect2DEx(e,t,s,n,i){this.m_point.assignCopy(t),1!==this.m_inputSegments.length&&r(""),this.m_tolerance=e,this.m_changed1=!1,this.m_changed2=!1;const o=ut(e*xn.c_smallToleranceFactor);let a=!1;const h=this.m_inputParts[0],m=this.m_inputSegments[h.segmentIndex];if(i||m.isIntersectingPoint(t.getXY(),e,!0)){this.m_param1=Ke(16,Number.NaN);const r=m.getClosestCoordinate(t.getXY(),!1);this.m_param1[0]=r;let i=h.rankInterior,l=h.weightInterior;0===r?(i=h.rankStart,l=h.weightStart):1===r?(i=h.rankEnd,l=h.weightEnd):this.m_changed1=!0;let g=i;const u=s,c=n;g===u&&m.isCurve()&&(g=u+1);let _=1,d=0;const p=new Qe;if(g===u){const e=m.getCoord2D(r),s=t.getXY();_=l+c,d=i;St(e,s,c/_,p),this.m_changed1||e.equals(p)||(this.m_changed1=!0),this.m_changed2||s.equals(p)||(this.m_changed2=!0);a=Qe.sqrDistance(p,e)>o}else if(g>u)p.assign(m.getCoord2D(r)),_=l,d=i,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);a=Qe.sqrDistance(p,t.getXY())>o}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,a?3:2}return 0}intersect3D(e,t,s,n){return o(0),1}intersect3DEx(e,t,s,n,r,i,a){return o(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 F,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 F({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 F({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 fe;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 Qe,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 Qe,this.m_cell=new Qe,this.parent=e}addSegment(e,t,s,n,r,i,a,h,m,l,g){const u=this.newNode(this.parent.m_resultSegments[e].get().getStartXY(),s,n,m),c=this.newNode(this.parent.m_resultSegments[e].get().getEndXY(),r,i,l);this.newEdge(u,c,e,a,h,g),null===this.m_chainOrigin1?this.m_chainOrigin1=u:null===this.m_chainOrigin2?this.m_chainOrigin2=u:o(0)}intersectCurvesHelper(e,t,n,i,a){const h=this.getSegment(e).get(),m=this.getSegment(t).get();if(h.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(e,t,n,i);if(0!==l)return l;const g=ut(.01*n);let u=!1,c=this.processSharpCorners(h,m,n,a>4);const _=c>0;if(!_){if(!(i||5&j(!0,!1,h,m,n,!0)))return 0;c=Z(!0,h,m,null,this.parent.m_param1,this.parent.m_param2,n)}0===c&&r("");const d=h.getGeometryType(),p=m.getGeometryType(),f=lt(Qe,c),x=lt(Qe,c),y=Ke(c,Number.NaN),P=Ke(c,Number.NaN),E=Ke(c,Number.NaN),S=Ke(c,Number.NaN),C=Tt(En,c),I=Tt(En,c);let b=!1,w=!1;for(let s=0;s<c;s++){const r=this.parent.m_param1[s],i=this.parent.m_param2[s];let o=e.rank,a=e.weight,l=!0,c=!1;0===r?(o=e.start.rank,a=e.start.weight,c=e.start.bIsBreak):1===r?(o=e.end.rank,a=e.end.weight,c=e.end.bIsBreak):(b=!0,l=!1);let v=t.rank,N=t.weight,T=!1,G=!0;0===i?(v=t.start.rank,N=t.start.weight,T=t.start.bIsBreak):1===i?(v=t.end.rank,N=t.end.weight,T=t.end.bIsBreak):(w=!0,G=!1);let D=o,V=v;if(D===V&&(D*=xn.c_maxGeometryTypeToRankDelta,V*=xn.c_maxGeometryTypeToRankDelta,D+=wn(d,h,!1),V+=wn(p,m,!1)),l&&G&&V===D){const e=h.getCoord2D(r),t=m.getCoord2D(i);e.equals(t)&&(V=D-1)}let F=1,H=0,k=1,A=0;const M=new Qe,U=new Qe,q=h.getCoord2D(r),B=m.getCoord2D(i);if(_&&Qe.distance(q,B)>n)M.setCoordsPoint2D(q),U.setCoordsPoint2D(B),F=a,k=N,H=o,A=v,C[s].bBigMove=!1,I[s].bBigMove=!1,c=!0,T=!0;else if(D===V){k=F=a+N,A=H=o;St(q,B,N/F,M),U.setCoordsPoint2D(M);const e=Qe.sqrDistance(M,q),t=Qe.sqrDistance(M,B);C[s].bBigMove=e>g,I[s].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=a,A=H=o;const e=Qe.sqrDistance(M,B);C[s].bBigMove=!1,I[s].bBigMove=e>g,w||B.equals(U)||(w=!0)}else{U.setCoordsPoint2D(B),M.setCoordsPoint2D(U),k=F=N,A=H=v;const e=Qe.sqrDistance(M,q);C[s].bBigMove=e>g,I[s].bBigMove=!1,b||q.equals(M)||(b=!0)}f[s].assign(M),x[s].assign(U),y[s]=F,P[s]=k,E[s]=H,S[s]=A,C[s].bIsBreak=c||T,I[s].bIsBreak=c||T,u||=C[s].bBigMove||I[s].bBigMove,s>0&&(r!==this.parent.m_param1[s-1]&&i!==this.parent.m_param2[s-1]||(E[s]<=E[s-1]?(f[s].assign(x[s-1]),y[s]=P[s-1],E[s]=S[s-1],x[s].assign(x[s-1]),P[s]=P[s-1],S[s]=S[s-1],C[s].bBigMove||=C[s-1].bBigMove,I[s].bBigMove||=I[s-1].bBigMove,C[s].bIsBreak||=C[s-1].bIsBreak,I[s].bIsBreak||=I[s-1].bIsBreak):(f[s-1].assign(f[s]),y[s-1]=y[s],E[s-1]=E[s],x[s-1].assign(x[s]),P[s-1]=P[s],S[s-1]=S[s],C[s-1].bBigMove||=C[s].bBigMove,I[s-1].bBigMove||=I[s].bBigMove,C[s-1].bIsBreak||=C[s].bIsBreak,I[s-1].bIsBreak||=I[s].bIsBreak)))}if(!(b||w||2!==c||d===s.enumLine&&p===s.enumLine)){if(this.processDoublyConnectedEdges(e,t,a+1,n))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;o(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 s=0;s<=c;s++){const t=s<c?this.parent.m_param1[s]:1;if(t!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,a,m,l;h.queryCut(V,t,i,!1),i.get().snapControlPoints(n*n);let g=!1,u=!1,_=!1,d=!1;const p=new Qe,x=new Qe;-1!==F?(a=E[F],o=y[F],_=C[F].bBigMove,g=C[F].bIsBreak,p.assign(f[F])):(o=e.start.weight,a=e.start.rank,_=e.start.bBigMove,g=e.start.bIsBreak,p.assign(i.get().getStartXY())),s<c?(l=E[s],m=y[s],d=C[s].bBigMove,u=C[s].bIsBreak,x.assign(f[s])):(m=N,l=T,d=G,u=D,x.assign(i.get().getEndXY()));let P=v;t<1&&(this.splitEdgeInPlace(v),P=v.getNextInChain()),this.updateSegmentOnly(v,r),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=o,v.start.rank=a,v.end.weight=m,v.end.rank=l,v=P,V=t,F=s}else-1===F&&(F=s)}const H=v.getNextInChain(),k=[];k.length=c;for(let s=0;s<c;s++)k[s]=s;c>2?(k.sort((e,t)=>Gt(this.parent.m_param2[e],this.parent.m_param2[t])),this.parent.m_param2.sort(Gt)):2===c&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=rt(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),k[1]=rt(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 s=0;s<=c;s++){const e=s<c?this.parent.m_param2[s]:1;if(e!==V){const r=this.parent.allocResultSegment(),i=this.parent.m_resultSegments[r];let o,a,h,l;m.queryCut(V,e,i,!1),i.get().snapControlPoints(n*n);const g=new Qe,u=new Qe;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(i.get().getStartXY());if(s!==c){const e=k[s];h=P[e],l=S[e],u.assign(x[e]),f=I[e].bBigMove,d=I[e].bIsBreak}else h=N,l=T,f=G,d=D,u.assign(i.get().getEndXY());let y=v;e<1&&(this.splitEdgeInPlace(v),y=v.getNextInChain()),this.updateSegmentOnly(v,r),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=h,v.end.rank=l,v=y,V=e,F=s}else-1===F&&(F=s)}const A=v.getNextInChain();return this.postProcessResultPartsForCurves(e,H,t,A,a+1),u?3:2}intersectCurves(e,t){2!==this.parent.m_inputSegments.length&&r(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=e,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=Je(16);const s=C.constructEmpty();for(let r=0;r<2;r++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[r].segmentIndex]),t=C.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[r].segmentIndex].queryLooseEnvelope(t),s.mergeEnvelope2D(t);const n=this.parent.m_inputParts[r];this.addSegment(e,0,n.weightStart,n.rankStart,n.weightEnd,n.rankEnd,n.weightInterior,n.rankInterior,n.u.bBreakStart,n.u.bBreakEnd,n.segmentParentage)}s.inflateCoords(100*e,100*e),this.m_origin.assign(s.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 n=0,i=!0;for(;this.m_pairs.length;){const t=this.m_pairs.at(-1);this.m_pairs.pop(),o(t.recursion>=0),o(t.recursion<=256),this.clusterNodes(e);const s=this.intersectCurvesHelper(t.edge1,t.edge2,e,t.bIsIntersecting,t.recursion);i&&(i=!1,n=s)}for(let r=0;r<2;r++){const e=0===r?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let t=(0===r?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 n}tryOverlapIntersectCurves(e,t,s,n){const r=this.parent.m_resultSegments[e.segmentIndex].get(),i=this.parent.m_resultSegments[t.segmentIndex].get(),a=r.getStartXY().equals(i.getStartXY())&&r.getEndXY().equals(i.getEndXY()),h=r.getStartXY().equals(i.getEndXY())&&r.getEndXY().equals(i.getStartXY());if(!a&&!h)return 0;const m=$(r,i,!0);if(0!==m&&ee(r,i)&&e.segmentParentage===t.segmentParentage){let e=!1;if(m>0)e=r.equals(i);else{o(-1===m);const t=new F({segment:i});t.get().reverse(),e=r.equals(t.get())}if(e)return 1}const l=s*xn.c_smallToleranceFactor;let g=!1;if(0===m){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 Qe;r.queryCoord2D(n,o);const a=i.getClosestCoordinate(o,!1),h=new Qe;i.queryCoord2D(a,h);const m=Qe.distance(o,h);if(m>s)return 0;g||=m>l}for(let t=0,n=e.length;t<n;++t){const n=e[t],o=new Qe;i.queryCoord2D(n,o);const a=r.getClosestCoordinate(o,!1),h=new Qe;r.queryCoord2D(a,h);const m=Qe.distance(o,h);if(m>s)return 0;g||=m>l}}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,a),t.transferAttributes(this,r,a)):c>u?(e.copyFromWhenOverlap(this,t,a),e.transferAttributes(this,i,a)):e.segmentParentage<=t.segmentParentage?(e.weight=e.weight+t.weight,t.copyFromWhenOverlap(this,e,a),t.transferAttributes(this,r,a)):(t.weight=e.weight+t.weight,e.copyFromWhenOverlap(this,t,a),e.transferAttributes(this,i,a)),g?3:2}postProcessResultPartsForCurves(e,t,s,n,i){i===Dt()&&r("curve_helper");for(let r=e;r!==t;r=r.getNextInChain())this.updateSegmentToNodes(r);for(let r=s;r!==n;r=r.getNextInChain())this.updateSegmentToNodes(r);for(let o=e;o!==t;o=o.getNextInChain()){const e=o.end.pt.sub(o.start.pt);for(let t=s;t!==n;t=t.getNextInChain()){let s=0;if(o.start.pt.equals(t.start.pt)&&o.end.pt.equals(t.end.pt)?s=1:o.start.pt.equals(t.end.pt)&&o.end.pt.equals(t.start.pt)&&(s=-1),!s){let s=o.start.pt.equals(t.start.pt)?1:0;if(s||(s=o.end.pt.equals(t.end.pt)?2:0,s||(s=o.end.pt.equals(t.start.pt)?3:0,s||(s=o.start.pt.equals(t.end.pt)?4:0))),s){const n=t.end.pt.sub(t.start.pt),a=e.dotProduct(n);let h;switch(s){case 1:case 2:h=a>0;break;case 3:case 4:h=a<0;break;default:r("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(In(o,t,i,!1))}continue}const n=this.parent.m_resultSegments[o.segmentIndex],a=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 Qe;n.get().queryCoord2D(t,r);const i=a.get().getClosestCoordinate(r,!1),o=new Qe;a.get().queryCoord2D(i,o);if(Qe.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(o,t,i,!1));continue}for(let e=0,t=h.length;e<t;++e){const t=h[e],r=new Qe;a.get().queryCoord2D(t,r);const i=n.get().getClosestCoordinate(r,!1),o=new Qe;n.get().queryCoord2D(i,o);if(Qe.distance(r,o)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(In(o,t,i,!1));continue}o.equalEdge=t,t.equalEdge=o;let m=o.rank,l=t.rank;m===l&&(m*=xn.c_maxGeometryTypeToRankDelta,l*=xn.c_maxGeometryTypeToRankDelta,m+=wn(n.get().getGeometryType(),n.get(),!0),l+=wn(a.get().getGeometryType(),a.get(),!0)),m>l||m===l&&o.segmentParentage<=t.segmentParentage?(n.copyTo(a,!1),t.segmentParentage=o.segmentParentage,-1===s&&a.get().reverse()):(a.copyTo(n,!1),o.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===Dt()&&r("curve_helper");const i=this.getSegment(e).get(),o=this.getSegment(t).get(),a=i.getStartXY().equals(o.getStartXY())&&i.getEndXY().equals(o.getEndXY())?1:i.getEndXY().equals(o.getStartXY())&&i.getStartXY().equals(o.getEndXY())?-1:0;if(0!==a){const r=new F;i.queryCut(0,.5,r),r.get().snapControlPoints(n*n);const h=new F;i.queryCut(.5,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(e),e.end.pt=r.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(r),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h);let m=o.getClosestCoordinate(e.end.pt,!1);return Math.abs(m-.5)>.2&&(m=.5),o.queryCut(0,m,r),r.get().snapControlPoints(n*n),o.queryCut(m,1,h),h.get().snapControlPoints(n*n),this.splitEdgeInPlace(t),t.end.pt=r.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(r),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(h),a>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=Je(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;Qe.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=Je(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=vt()-1,i=Math.round(It(s,-2147483646,r)),o=Math.round(It(n,-2147483646,r));let a=i|o<<32;a=Ze(a),t[0]=this.m_hashTableOfEquals[a%this.m_hashTableOfEquals.length];let h=i+1|o<<32;h=Ze(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=Ze(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=Ze(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=vt()-1;let r=Math.round(It(t,-2147483646,n))|Math.round(It(s,-2147483646,n))<<32;return r=Ze(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=te(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=te(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=te(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=te(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,n){let i=0;switch(e){case s.enumLine:i=0;break;case s.enumBezier:i=2;break;case s.enumRationalBezier2:i=3;break;case s.enumBezier2:i=1;break;case s.enumEllipticArc:i=0===t.projectionBehavior()?5:4;break;default:r("")}return n?5-i:i}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 Ye{constructor(e){super(),this.pt1=Qe.getNAN(),this.pt2=Qe.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=Qe.getNAN(),this.m_pt=Qe.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 Be(8),this.m_clusters=new Be(5),this.m_clusterVertices=new sn(!1),this.m_edgeVertices=new sn(!1),this.m_helperPoint=new fe,this.m_eventQ=new Ee,this.m_sweepStructure=new Ee,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 F,this.m_segBuf2=new F,this.m_sweepPoint=new Qe(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,M);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!==M&&(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&&yt(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):r(""),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=Be.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);Be.isValidElement(s)&&(this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(e,-1));const n=Be.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);Be.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),t++):r!==Be.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(Qe.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?Be.impossibleIndex2():-1}fillEventQueue(){const e=new Ce(0),t=this.m_shape.queryVertexIteratorOnSelection();for(let r=t.next();r!==M;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=Qe.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 Ce(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);Be.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=Be.impossibleIndex2(),r=Be.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!==M;t=this.m_shape.getNextGeometry(t)){if(i(this.m_shape.getGeometryType(t)))for(let s=this.m_shape.getFirstPath(t);s!==M;s=this.m_shape.getNextPath(s)){const t=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===M)continue;let r=this.m_shape.getNextVertex(n);if(r===M||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!==M;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 Ce(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 o=e.getFirstPath(t);o!==M;o=e.getNextPath(o)){let t=e.getFirstVertex(o);for(let s=0,n=e.getPathSize(o);s<n;s++,t=e.getNextVertex(t))this.m_points.add(t)}this.m_pointsIndex=e.createUserIndex();for(let o=0,g=this.m_points.size();o<g;++o)e.setUserIndex(this.m_points.read(o),this.m_pointsIndex,o);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 a=[];for(let o=1;o<this.m_points.size();o++){const t=this.m_points.read(o);if(t===M)continue;if(-1===e.getUserIndex(t,this.m_pointsIndex))continue;const h=e.getXY(t);if(h.isEqualPoint2D(n))r++;else{if(r>1){for(let t=i;t<o;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);a.push(e)}if(s!==i&&i!==r&&!e.isEqualXYPoint2D(i,n)){const e=Fn(s,i,-1);a.push(e)}}a.length>0&&this.processBunch_(a,n)}s=t,n.assign(h),r=1,i=o}}if(0===this.m_dissolvedEdges)return e.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let h=e.getPointCount(t);for(let o=0;o<this.m_points.size();o++){const t=this.m_points.read(o);if(t===M)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,M),e.freeVertex(t),this.m_points.write(o,M),h--}const m=e.createPathUserIndex();let l=e.getPathCount(t);for(let g=0,u=this.m_points.size();g<u;++g){if(this.m_points.read(g)===M)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,m)){n=M;for(let t=e.getNextVertex(s);t!==s;t=e.getNextVertex(t)){const r=e.getPathFromVertex(t);if(2!==e.getPathUserIndex(r,m)){n=r,s=t;break}}n===M&&(n=e.insertPath(t,M),e.setClosedPath(n,!0),l++),o(n!==M)}e.setPathUserIndex(n,m,2),r=e.getFirstVertex(n);let i=0,a=!1,h=s;do{r===h&&(a=!0),e.setUserIndex(h,this.m_pointsIndex,1);const t=e.getPathFromVertex(h);t!==n&&(2!==e.getPathUserIndex(t,m)&&(e.setPathUserIndex(t,m,1),e.setFirstVertex(t,M)),e.setPathToVertex(h,n)),i++,h=e.getNextVertex(h)}while(h!==s);a||e.setFirstVertex(n,s),e.setPathSize(n,i)}for(let o=e.getFirstPath(t);o!==M;){const t=e.getNextPath(o);1!==e.getPathUserIndex(o,m)&&e.getFirstVertex(o)!==M||(e.removePathOnly(o),l--),o=t}e.setGeometryVertexCount(t,h),e.setGeometryPathCount(t,l),e.removePathUserIndex(m),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=Qe.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!==M;t=e.getNextGeometry(t))if(i(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(i(r)){return new Bn(n).crackAWithBMultiPath_(e,t,s)}g("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 F,s=new F,n=C.constructEmpty(),r=C.constructEmpty(),i=!1,a=new fe,h=new xn,m=this.m_shape.getTotalPointCount(),l=m*m*2,g=this.m_shape.queryVertexIteratorOnSelection();for(let u=g.next();u!==M;u=g.next()){const m=this.m_shape.getGeometryType(g.currentGeometry());let c=1,_=1,p=1,f=0,x=0,y=0;const P=this.m_shape.getSegmentParentage(u);let E=!1,S=!1,C=null,I=!1;if(d(m))c=this.m_shape.getWeight(u),f=this.m_shape.getRank(u);else{if(C=this.getSegment_(u,t),null===C)continue;const e=this.m_shape.getVertexIndex(u);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(u);{const e=this.m_shape.getNextVertex(u);_=this.m_shape.getWeight(e),x=this.m_shape.getRank(e),S=this.m_shape.getSegmentParentageBreakVertex(e)}if(C.queryLooseEnvelope(n),n.inflateCoords(this.m_tolerance,this.m_tolerance),C.isDegenerate(this.m_tolerance)){if(!C.isDegenerate(0))continue;I=!0,C=null}}const b=new W({copy:g});let w=b.next();w!==M&&(w=b.next());let v=0;for(;w!==M;w=b.next()){if(0!==v){v--;continue}if(this.m_shape.getTotalPointCount()>l)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,U=!1;const q=this.m_shape.getSegmentParentage(w);if(d(m))G=this.m_shape.getWeight(w),F=this.m_shape.getRank(w);else{if(N=this.getSegment_(w,s),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),U=this.m_shape.getSegmentParentageBreakVertex(e)}if(N.queryLooseEnvelope(r),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(n.isIntersectingNe(r)){0!==j(!0,!0,C,N,this.m_tolerance,!0)&&(h.pushSegment(C,c,f,_,x,p,y,E,S,P),h.pushSegment(N,G,F,D,H,V,k,A,U,q),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(u,h,0,!0,!0),this.m_shape.splitSegmentWithIntersector(w,h,1,!0,!0),this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(u,!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(n.contains(t)){if(h.pushSegment(C,c,f,_,x,p,y,E,S,P),this.m_shape.queryPoint(w,a),h.intersect2DEx(this.m_tolerance,a,F,G,i),e||=h.getSegmentChanged(0)||h.getResultPointChanged(),B=h.getResultSegmentCount(0),B>0)if(this.m_bTrackChanges&&(h.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(u,!0),h.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(w,!0)),this.m_shape.splitSegmentWithIntersector(u,h,0,!0,!0),T){let e=M;for(let t=this.m_shape.getNextVertex(w);t!==M&&t!==w&&(N=this.getSegment_(t,s),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=w;t!==M&&(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(u);if(r.inflateCoords(this.m_tolerance,this.m_tolerance),r.contains(t)){if(h.pushSegment(N,G,F,D,H,V,k,A,U,q),this.m_shape.queryPoint(u,a),h.intersect2DEx(this.m_tolerance,a,f,c,i),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(u,!0)),this.m_shape.splitSegmentWithIntersector(w,h,0,!0,!0),v+=O-1,I){let e=M;for(let t=this.m_shape.getNextVertex(u);t!==M&&t!==u&&(N=this.getSegment_(t,s),e=t,null!=N&&N.isDegenerate(0));t=this.m_shape.getNextVertex(t));for(let t=u;t!==M&&(this.m_shape.setPoint(t,h.getResultPoint(),!0),t!==e);t=this.m_shape.getNextVertex(t));}else this.m_shape.setPoint(u,h.getResultPoint(),!0);h.clear()}}}if(B+O!==0&&0!==B){let e=!1;for(;C=this.getSegment_(u,t),null!=C&&(C.queryEnvelope(n),C.isDegenerate(this.m_tolerance));){if(!(B>1)){e=!0;break}u=g.next(),B--,o(u!==M)}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 Ce(0);t.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let r=0,g=s.next();g!==M;++r,g=s.next())t.write(r,g);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),t.add(M);const n=this.m_shape.createUserIndex(),i=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 o=null;const a=[],h=[];let m=0;const l=new Qe;for(let g=t.read(m++);g!==M;){this.m_shape.queryXY(g,l);let s=!1;do{let e=this.m_shape.getNextVertex(g),r=this.m_shape.getPrevVertex(g);s||=e!==M||r!==M,e===M||this.m_shape.selected(e)||(e=M),r===M||this.m_shape.selected(r)||(r=M),e!==M&&this.m_shape.compareVerticesSimpleY(g,e)<0&&(h.push(g),h.push(e)),r!==M&&this.m_shape.compareVerticesSimpleY(g,r)<0&&(h.push(r),h.push(r));const o=this.m_shape.getUserIndex(g,n);-1!==o&&(a.push(o),this.m_shape.setUserIndex(g,n,-1));const l=this.m_shape.getUserIndex(g,i);-1!==l&&(a.push(l),this.m_shape.setUserIndex(g,i,-1)),g=t.read(m++)}while(g!==M&&this.m_shape.isEqualXYPoint2D(g,l));if(!s&&(null===o&&(o=new an(this.m_shape,this.m_tolerance)),o.setPoint(l),this.m_sweepStructure.searchUpperBound(o),o.intersectionDetected())){e=!0,this.m_bNeedsNonSimpleResult&&(r("needsCrackingIMpl_"),this.m_nonSimpleResult=new ts(6,-1,-1));break}let u=1===a.length&&2===h.length;const c=32;a.length>c&&$e(a);let _=-1,d=-1;if(!u)for(let t=0,n=a.length;t<n;t++){const s=a[t],n=this.m_sweepStructure.getPrev(s);if(-1!==n&&-1===a.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===a.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=a.length;e<t;e++){const t=a[e];this.m_sweepStructure.deleteNode(t)}a.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,r=h.length;t<r;t+=2){const s=h[t],r=h[t+1];let o;if(u?(o=this.m_sweepStructure.replaceElementAtPosition(a[0],s,!0,!0),a.length=0,u=!1):o=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(r,n)?this.m_shape.setUserIndex(r,n,o):this.m_shape.setUserIndex(r,i,o)}if(e)break;h.length=0}return this.m_shape.removeUserIndex(n),this.m_shape.removeUserIndex(i),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=C.constructEmpty();e.queryLooseEnvelope(r);const i=C.constructEmpty();if(t.queryLooseEnvelope(i),i.inflateCoords(n,n),!i.isIntersecting(r))return e;const a=e.getImpl(),h=a.getAccelerators();let l=null,g=null;h&&(g=h.getQuadTree()),On(e,m(t))&&(l=Ve(a,i),g=l);const u=g?g.getIteratorForQT():null,c=t.querySegmentIterator(),_=e.querySegmentIterator(),d=Ke(15,Number.NaN),p=[];for(;c.nextPath();)for(;c.hasNextSegment();){const e=c.nextSegment();if(g){u.resetIterator(e,n);for(let t=u.next();-1!==t;t=u.next()){this.progress_();const s=g.getElement(t);if(_.resetToVertex(s,-1),_.hasNextSegment()){const t=_.nextSegment().intersect(e,null,d,null,n);for(let e=0;e<t;e++){const t=d[e];if(0===t||1===t)continue;const s=qn(t,_.getStartPointIndex());p.push(s)}}}}else{const t=C.constructEmpty();if(e.queryLooseEnvelope(t),t.inflateCoords(n,n),!r.isIntersecting(t))continue;for(_.resetToFirstPath();_.nextPath();)for(;_.hasNextSegment();){const s=_.nextSegment(),r=C.constructEmpty();if(s.queryLooseEnvelope(r),!r.isIntersecting(t))continue;const i=s.intersect(e,null,d,null,n);for(let e=0;e<i;e++){const t=d[e];if(0===t||1===t)continue;const s=qn(t,_.getStartPointIndex());p.push(s)}}}}if(0===p.length)return e;p.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 f=e.createInstance();if(f.getGeometryType()===s.enumPolygon){f.setFillRule(e.getFillRule())}for(_.resetToFirstPath();_.nextPath()&&!_.hasNextSegment(););o(_.hasNextSegment());let x=_.nextSegment();const y=new F;let P=-1;for(let s=0,m=p.length;s<m;){const e=p[s].index;let t=s+1;for(;t<m&&p[t].index===e;)++t;for(;_.getStartPointIndex()<e;){this.progress_();const e=_.hasNextSegment(),t=_.getPathIndex();if((e||!_.isClosingSegment()||_.isCurve())&&(o(null!==x),f.addSegment(x,P!==t)),P=t,!e){for(_.isPathClosed();_.nextPath()&&!_.hasNextSegment(););o(_.hasNextSegment())}x=_.nextSegment()}let n=0;for(let i=s;i<t;i++){const e=p[i].t;if(e===n)continue;o(null!==x),x.queryCut(n,e,y),n=e;const t=_.getPathIndex();f.addSegment(y.get(),P!==t),P=t}const r=_.hasNextSegment();if((r||!_.isClosingSegment()||_.isCurve())&&(o(null!=x),x.queryCut(n,1,y),f.addSegment(y.get(),!1)),r)x=_.nextSegment();else{for(;_.nextPath()&&!_.hasNextSegment(););x=_.hasNextSegment()?_.nextSegment():null}s=t}if(null!==x){const e=_.getPathIndex();(_.hasNextSegment()||!_.isClosingSegment()||_.isCurve())&&f.addSegment(x,P!==e),P=e}let E=_.hasNextSegment();for(;;){if(!E){for(;_.nextPath()&&(E=_.hasNextSegment(),!E););if(!E)break}x=_.nextSegment();const e=_.getPathIndex();E=_.hasNextSegment();(E||!_.isClosingSegment()||_.isCurve())&&f.addSegment(x,P!==e),P=e}return f}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 Ee,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=lt(F,16),this.m_xOrds=Ke(16,Number.NaN),this.m_inputPoint=Qe.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,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 Qe.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),o(this.m_monotoneParts.length>=s)),s>0)for(let n=0;n<s;n++){const e=this.m_monotoneParts[n].get(),t=at.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 o(0),2}}function Rn(e,t,s,n){const r=new C;e.queryLooseEnvelope(r),r.inflateCoords(n,n);const i=0===e.getFillRule(),o=new Yn(i,n);o.setInputPoint(s);const a=r.clone();a.xmax=s.x+n,a.ymin=s.y-n,a.ymax=s.y+n;const h=e.getImpl().querySegmentIterator(),m=t.getIterator(a,n);for(let l=m.next();-1!==l;l=m.next())if(h.resetToVertex(t.getElement(l),-1),h.hasNextSegment()){const e=h.nextSegment();if(o.processSegment(e))return-1}return o._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,s){if(e.isEmpty())return 0;const n=C.constructEmpty();if(e.queryLooseEnvelope(n),n.inflateCoords(s,s),!n.contains(t))return 0;const r=e.getImpl().getAccelerators();if(r){r.getRasterizedGeometry()&&o(0);const n=r.getQuadTree();if(n)return Rn(e,n,t,s)}return Xn(e,t,s)}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=rt(t,t=s));const n=Qe.getNAN(),r=Qe.getNAN();return this.m_shape.queryXY(t,n),this.m_shape.queryXY(s,r),o(!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 Ye{constructor(e){super(),this.m_line1=new H,this.m_line2=new H,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&&y("")}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 M;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 M}}class $n{constructor(e){this.m_edges=null,this.m_shape=null,this.m_AET=new Ee,this.m_yScanline=0,this.m_geometry=M,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!==M&&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 a=M;if(0===i){let s=this.m_AET.getPrev(e),n=e,r=!1;for(;s!==Ee.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)){a=t;break}n=s,s=this.m_AET.getPrev(s)}if(s===Ee.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(a,this.m_pathOrientationIndex);2===e?(a=this.m_shape.getPathUserIndex(a,this.m_pathParentsIndex),e=this.m_shape.getPathUserIndex(a,this.m_pathOrientationIndex),o(3===e)):o(3===e);const t=this.m_shape.getPathUserIndex(a,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(a,this.m_pathParentageIndex,i),this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,t),this.m_shape.setPathUserIndex(i,this.m_pathParentsIndex,a)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return t}a=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]=M):i=-1!==n?n:r,-1!==i&&(this.insertEdge_(s,i)||this.m_AET.deleteNode(i),e[t]=M)}}dbgVerifyRingOrientation_(){}insertEdge_(e,t){const s=Qe.getNAN(),n=Qe.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 Qe;let i=M,a=M,h=-1;const m=new Jn(this);for(let o=m.next();o!==M;o=m.next()){const m=new Qe;this.m_shape.queryXY(o,m);const l=this.m_shape.getPathFromVertex(o);if(r.equals(m)&&a===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===h){h=t.length,this.m_shape.setUserIndex(i,n,h),t.push(1);-1===this.m_shape.getPathUserIndex(l,s)&&(this.m_shape.setPathUserIndex(l,s,i),e.push(l))}this.m_shape.setUserIndex(o,n,h),t[t.length-1]++}else h=-1,r.assign(m);i=o,a=l}if(0===e.length)return!1;o(-1!==s);for(let o=0,l=e.length;o<l;o++){const r=e[o];let i=this.m_shape.getPathUserIndex(r,s);const a=this.m_shape.getUserIndex(i,n),h=[],m=[];h.push(i),m.push(a);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===m.length){m.push(r),h.push(s);continue}if(m.at(-1)===r){const o=h.at(-1);this.m_shape.peelALoopIntoAPath(o,s),this.m_shape.setUserIndex(e,n,-1),t[r]--,1===t[r]&&(t[r]=0,m.pop(),h.pop()),i=o,e=o}else h.push(e),m.push(r)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(n),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(e=!1){}fixRingOrientationImplMain_(){const e={stack:[],error:void 0,hasError:!1};try{let t,s=!1;const n=zt(e,Nt(()=>{this.m_sortedVerticesArray=null}),!1);if(null===this.m_sortedVertices){const e=this.m_shape.getPointCount(this.m_geometry);t=new Ce(0);for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==M;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 n.bForget=!0;if(this.m_bFixSelfTangency&&(s=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!==M;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 r=[];this.m_yScanline=Number.NaN;const i=Qe.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 o=new Jn(this);for(let e=o.next();e!==M&&(this.progress_(),this.m_shape.queryXY(e,i),i.y!==this.m_yScanline&&r.length&&(s=this.processBunchForRingOrientationTest_(r)||s,this.m_sweepComparator.reset(),r.length=0),r.push(e),this.m_yScanline=i.y,0!==this.m_unknownRingOrientationCount);e=o.next());return this.m_unknownRingOrientationCount>0&&(s=this.processBunchForRingOrientationTest_(r)||s,r.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),s}catch(t){e.error=t,e.hasError=!0}finally{Wt(e)}}fixRingOrientationImplSimplify_(){const e=[];for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==M;)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!==M;){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!==M;e=this.m_shape.getNextPath(e),--n){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==t){s=M;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,ze),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!==M;)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!==M;){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!==M;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==n){r=M;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,ze)}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=M,this.m_sortedVertices=new Pe,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=M,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 Qe;this.m_shape.queryXY(s,n);const r=new Qe,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 Qe;this.m_shape.queryXY(o,a);const h=this.m_bunchEdgeCenterPoints[t],m=new Qe;this.m_shape.queryXY(h,m);const l=new Qe;l.setSub(n,a);const g=new Qe;g.setSub(r,m),(l.isZero()||g.isZero())&&y("");return Qe.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 F),this.m_sorterSegmentBuffer2||(this.m_sorterSegmentBuffer2=new F),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 q(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!==M){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,M),this.m_shape.setLastVertex(t,M)}}}}processBunch_(){let e=!1;const t=new Qe(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)!==ze&&(this.m_bunchEdgeEndPoints.push(i),this.m_shape.setUserIndex(i,this.m_userIndexSortedAngleIndexToVertex,ze),this.m_bunchEdgeCenterPoints.push(e),this.m_bunchEdgeIndices.push(n++));this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==ze&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,ze),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)===s.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),n=new Ce(0);this.m_shape.dbgVerifyMonotone();for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==M;s=this.m_shape.getNextPath(s)){let e=this.m_shape.getFirstVertex(s);for(let t=0,r=this.m_shape.getPathSize(s);t<r;t++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),n.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(n,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 s=0;s<t;s++){const e=n.read(s),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 i=0,o=!1;do{o=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const t=new Qe(0,0);this.m_firstCoincidentVertex!==Pe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),t);let s=0,n=this.m_firstCoincidentVertex;for(;n!==Pe.st_nullNode()&&(n=this.m_sortedVertices.getNext(n),n!==Pe.st_nullNode());){this.progress_();const e=this.m_sortedVertices.getData(n),r=Qe.getNAN();if(this.m_shape.queryXY(e,r),t.equals(r))s++;else{if(s>0){this.m_nextVertexToProcess=n;const e=this.processBunch_();n=this.m_nextVertexToProcess,n!==Pe.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(n),r),e&&(o=!0)}t.setCoordsPoint2D(r),this.m_firstCoincidentVertex=n,s=0}}if(this.m_nextVertexToProcess=-1,s>0){this.processBunch_()&&(o=!0)}i++>10&&r(""),o&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(o=!0),e||=o}while(o);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=Ke(8,Number.NaN),c=Ke(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=rt(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=rt(s,s=r),i=rt(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!==M;){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===M)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:M,bModified:!1};let n=this.m_shape.getPrevVertex(t),r=this.m_shape.getNextVertex(t),i=M,o=M;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===M)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!==M?this.m_shape.movePath(this.m_polylineDegeneracies,M,e):this.m_shape.removePath(e),s.v=M,s;{const e=this.m_shape.peelALoopIntoAPath(i,o);this.m_polylineDegeneracies!==M?this.m_shape.movePath(this.m_polylineDegeneracies,M,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=M,r=M;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===M)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===M)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,M,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,M)}let t=0;for(let n=this.m_shape.getFirstPath(this.m_geometry);n!==M;){const s=this.m_shape.getFirstVertex(n);if(s===M||this.m_shape.getPathFromVertex(s)!==M){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)!==M)continue;const r=[!1],i=this.m_shape.insertClosedPath(this.m_geometry,M,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!==M;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(t,n,r,i,o,a=!0){switch(ir(i)){case 0:break;case 1:e("relation string length has to be 9 characters");break;default:e("relation string")}if(a){const e=xr(i,t.getDimension(),n.getDimension());if(0!==e)return kr(t,n,r,e,o)}let h=0;if("number"==typeof r)h=r;else{const e=C.constructEmpty();t.queryEnvelope(e);const s=C.constructEmpty();n.queryEnvelope(s);const i=C.constructEmpty();i.setCoords({env2D:e}),i.mergeEnvelope2D(s),h=le(r,i,!1)}const m=Tr(t,h),l=Tr(n,h);if(m.isEmpty()||l.isEmpty())return fr(m,l,i);const g=m.getGeometryType(),u=l.getGeometryType();let c=!1;switch(g){case s.enumPolygon:switch(u){case s.enumPolygon:c=or(m,l,h,i,o);break;case s.enumPolyline:c=ar(m,l,h,i,o);break;case s.enumPoint:c=ur(m,l,h,i);break;case s.enumMultiPoint:c=hr(m,l,h,i,o)}break;case s.enumPolyline:switch(u){case s.enumPolygon:c=ar(l,m,h,Gr(i),o);break;case s.enumPolyline:c=mr(m,l,h,i,o);break;case s.enumPoint:c=cr(m,l,h,i,o);break;case s.enumMultiPoint:c=lr(m,l,h,i,o)}break;case s.enumPoint:switch(u){case s.enumPolygon:c=ur(l,m,h,Gr(i));break;case s.enumPolyline:c=cr(l,m,h,Gr(i),o);break;case s.enumPoint:c=dr(m,l,h,i);break;case s.enumMultiPoint:c=_r(l,m,h,Gr(i))}break;case s.enumMultiPoint:switch(u){case s.enumPolygon:c=hr(l,m,h,Gr(i),o);break;case s.enumPolyline:c=lr(l,m,h,Gr(i),o);break;case s.enumMultiPoint:c=gr(m,l,h,i,o);break;case s.enumPoint:c=_r(m,l,h,i)}break;default:c=!1}return c}function nr(e,t,s,n){const r=new vr;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaAreaPredicates_();const i=C.constructEmpty(),o=C.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);let a=!1;if(qr(i,o,s)&&(r.areaAreaDisjointPredicates_(e,t),a=!0),a||Br(e,t),a){return pr(r.m_matrix,r.m_scl)}let h=new G,m=h.addGeometry(e),l=h.addGeometry(t),g=null,u=0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){g=new fa;const e=_a(s,h.getEnvelope2D(n));u=pa(e,0),aa(h,e,s,12e3,g,null,n)}ya(h,new xe(s,0).add(u),n,!1,!1);const c=h.getGeometry(l).getBoundary();if(h.filterClosePoints(0,!0,!0,!1,M),er(h,m,-1,!1,M,n),0===h.getPointCount(m))return!1;er(h,l,-1,!1,M,n),r.setEditShape_(h,n);const _=0===h.getPointCount(l);if(!_){r.computeMatrixTopoGraphHalfEdges_(m,l),r.m_topoGraph.removeShape();const e=pr(r.m_matrix,r.m_scl);if(!e)return e}const d=h.getGeometry(m);h=new G,m=h.addGeometry(d),l=h.addGeometry(c),r.setEditShape_(h,n),r.m_predicateCount=0,r.resetMatrix_(),r.setPredicates_(_?"T*****F**":"******F**"),r.setAreaLinePredicates_(),r.computeMatrixTopoGraphHalfEdges_(m,l),r.m_topoGraph.removeShape();return pr(r.m_matrix,r.m_scl)}function rr(e,t,s,n){const r=new vr;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaLinePredicates_();const i=C.constructEmpty(),o=C.constructEmpty();e.queryEnvelope(i),t.queryEnvelope(o);let a=!1;if(qr(i,o,s)&&(r.areaLineDisjointPredicates_(e,t),a=!0),a||Br(e,t),a){return pr(r.m_matrix,r.m_scl)}const h=new G,m=h.addGeometry(e),l=h.addGeometry(t);if(r.setEditShapeCrackAndCluster_(h,new xe(s,0),n),0===h.getPointCount(m))return!1;r.computeMatrixTopoGraphHalfEdges_(m,l),r.m_topoGraph.removeShape();return pr(r.m_matrix,r.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,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaAreaPredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.areaAreaDisjointPredicates_(e,t),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function ar(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaLinePredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.areaLineDisjointPredicates_(e,t),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.m_clusterIndexB=i.m_topoGraph.createUserIndexForClusters(),wr(a,i.m_topoGraph,i.m_clusterIndexB),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexB),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function hr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaPointPredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.areaPointDisjointPredicates_(e),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function mr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLineLinePredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.lineLineDisjointPredicates_(e,t),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.m_clusterIndexA=i.m_topoGraph.createUserIndexForClusters(),i.m_clusterIndexB=i.m_topoGraph.createUserIndexForClusters(),wr(o,i.m_topoGraph,i.m_clusterIndexA),wr(a,i.m_topoGraph,i.m_clusterIndexB),i.computeMatrixTopoGraphHalfEdges_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexA),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexB),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function lr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLinePointPredicates_();const o=C.constructEmpty(),a=C.constructEmpty();e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.linePointDisjointPredicates_(e),h=!0),h||Br(e,t),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.m_clusterIndexA=i.m_topoGraph.createUserIndexForClusters(),wr(o,i.m_topoGraph,i.m_clusterIndexA),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.deleteUserIndexForClusters(i.m_clusterIndexA),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function gr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setPointPointPredicates_();const o=new C,a=new C;e.queryEnvelope(o),t.queryEnvelope(a);let h=!1;if(qr(o,a,s)&&(i.pointPointDisjointPredicates_(),h=!0),!h){const n=new G,o=n.addGeometry(e),a=n.addGeometry(t);i.setEditShapeCrackAndCluster_(n,new xe(s,0),r),i.computeMatrixTopoGraphClusters_(o,a),i.m_topoGraph.removeShape()}return pr(i.m_matrix,i.m_scl)}function ur(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setAreaPointPredicates_();const o=C.constructEmpty();e.queryEnvelope(o);const a=t.getXY();let h=!1;if(Or(a,o,s)&&(i.areaPointDisjointPredicates_(e),h=!0),!h){const t=Lo(e,a,s);if(1===t)i.m_matrix[0]=0,i.m_matrix[2]=2,i.m_matrix[3]=-1,i.m_matrix[5]=1,i.m_matrix[6]=-1;else if(2===t){i.m_matrix[6]=-1;if(0!==e.calculateArea2D())i.m_matrix[0]=-1,i.m_matrix[3]=0,i.m_matrix[2]=2,i.m_matrix[5]=1;else{i.m_matrix[0]=0,i.m_matrix[3]=-1,i.m_matrix[5]=-1;const t=C.constructEmpty();e.queryEnvelope(t),i.m_matrix[2]=t.height()||t.width()?1:-1}}else i.areaPointDisjointPredicates_(e)}return pr(i.m_matrix,n)}function cr(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setLinePointPredicates_();const o=C.constructEmpty();e.queryEnvelope(o);let a=!1;if(Or(t.getXY(),o,s)&&(i.linePointDisjointPredicates_(e),a=!0),!a){let n=null,o=!1,a=!1;if(i.m_performPredicates[0]||i.m_performPredicates[6]){!kr(e,t,s,4,r)?(i.m_performPredicates[0]&&(n=D(e),a=!kr(n,t,s,4,r),o=!0,i.m_matrix[0]=a?-1:0),i.m_matrix[6]=-1):(i.m_matrix[0]=-1,i.m_matrix[6]=0)}if(i.m_performPredicates[3]&&(null!==n&&n.isEmpty()?i.m_matrix[3]=-1:(o||(null==n&&(n=D(e)),a=!kr(n,t,s,4,r),o=!0),i.m_matrix[3]=a?0:-1)),i.m_performPredicates[5])if(null!==n&&n.isEmpty())i.m_matrix[5]=-1;else if(o&&!a)i.m_matrix[5]=0;else{null===n&&(n=D(e));const o=kr(n,t,s,3,r);i.m_matrix[5]=o?-1:0}if(i.m_performPredicates[2]){if(0!==e.calculateLength2D())i.m_matrix[2]=1;else{const n=new N({vd:e.getDescription()});n.addPoints(e,0,e.getPointCount());const o=kr(n,t,s,3,r);i.m_matrix[2]=o?-1:0}}}return pr(i.m_matrix,i.m_scl)}function _r(e,t,s,n,r){const i=new vr;i.resetMatrix_(),i.setPredicates_(n),i.setPointPointPredicates_();const o=C.constructEmpty();e.queryEnvelope(o);const a=t.getXY(),h=new Qe;let m=!1;if(Or(a,o,s)&&(i.pointPointDisjointPredicates_(),m=!0),!m){let t=!1,n=!0;const r=s*s;for(let s=0;s<e.getPointCount()&&(e.queryXY(s,h),Qe.sqrDistance(h,a)<=r?t=!0:n=!1,!t||n);s++);t?(i.m_matrix[0]=0,i.m_matrix[2]=n?-1:0,i.m_matrix[6]=-1):(i.m_matrix[0]=-1,i.m_matrix[2]=0,i.m_matrix[6]=0)}return pr(i.m_matrix,n)}function dr(e,t,s,n,r){const i=e.getXY(),o=t.getXY(),a=Ke(9,-1);Qe.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=Ke(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 h=o.getGeometryType();if(i(h))if(h===s.enumPolygon){if(0!==o.calculateArea2D())r[2]=2,r[5]=1;else{r[5]=-1;const e=C.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]=T(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!==M;r=t.getNextCluster(r)){if(0===(t.getClusterParentage(r)&n))continue;const e=t.getClusterHalfEdge(r);if(e===M){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 r("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=Ke(9,0),this.m_maxDim=Ke(9,0),this.m_performPredicates=Ke(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,s,n,r){const i=-1!==t,o=-1!==n;if(i||o){if(!("T"!==s&&"F"!==s&&i||"T"!==r&&"F"!==r&&o)||0!==e.calculateArea2D())i&&(this.m_matrix[t]=2),o&&(this.m_matrix[n]=1);else if(o&&(this.m_matrix[n]=-1),i){const s=C.constructEmpty();e.queryEnvelope(s),this.m_matrix[t]=s.height()||s.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=T(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=T(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=T(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=T(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=T(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!==M;i=this.m_topoGraph.getNextCluster(i)){const e=this.m_topoGraph.getClusterHalfEdge(i);if(e===M){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!==M&&(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,n){let r=0;if(e.hasCurves()){const s=new fa,i=e.getEnvelope2D(n),o=_a(t.total(),i);r=pa(o,0),aa(e,o,t.total(),12e3,s,null,n),s.clearStitcher(e)}ya(e,t.add(r),n,!1,!1),e.filterClosePoints(0,!0,!0,!1,M);for(let i=e.getFirstGeometry();i!==M;i=e.getNextGeometry(i))e.getGeometryType(i)===s.enumPolygon&&er(e,i,-1,!1,M,n);this.setEditShape_(e,n)}}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,r){const i=e.getGeometryType();if(n(i)){const t=new I({vd:e.getDescription()});return t.addSegment(e,!0),t}if(i===s.enumEnvelope){const s=e,n=C.constructEmpty();if(e.queryEnvelope(n),n.height()<=t&&n.width()<=t){const t=new fe({vd:e.getDescription()});return s.getCenter(t),t}if(n.height()<=t||n.width()<=t){const t=new I({vd:e.getDescription()}),n=new fe;return s.queryCornerByVal(0,n),t.startPathPoint(n),s.queryCornerByVal(2,n),t.lineToPoint(n),t}const r=new v({vd:e.getDescription()});return r.addEnvelope(s,!1),r}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 r("should not be called"),!1}constructor(e,t,s,n=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=C.constructEmpty(),this.m_envInter=C.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const r=e.getAccelerators();let o=null;null!=r&&(o=n?r.getQuadTreeForPaths():r.getQuadTree());const a=t.getAccelerators();let h=null;if(null!=a&&(h=n?a.getQuadTreeForPaths():a.getQuadTree()),null===o&&null===h&&!n){const n=e.getPointCount(),r=t.getPointCount();if(n>10&&r>10){const a=C.constructEmpty(),m=C.constructEmpty(),l=C.constructEmpty();e.queryLooseEnvelope(a),t.queryLooseEnvelope(m),a.inflateCoords(s,s),m.inflateCoords(s,s),l.setCoords({env2D:a}),l.intersect(m),n>=r?o=i(e.getGeometryType())?Ve(e,l):Fe(e,l):h=i(t.getGeometryType())?Ve(t,l):Fe(t,l)}}this.construct_(e,o,t,h,s,n)}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):i(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?i(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||u(""),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||u(""),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 h=C.constructEmpty(),m=C.constructEmpty();e.queryLooseEnvelope(h),n.queryLooseEnvelope(m),h.inflateCoords(o,o),m.inflateCoords(o,o),this.m_envInter.setCoords({env2D:h}),this.m_envInter.intersect(m),this.m_multiVertexImplA=e,this.m_multiVertexImplB=n;const l=e.getGeometryType(),g=n.getGeometryType();this.m_bPaths=a,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=s.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,i(g)?(this.m_queryType=g,this.m_function=this.nextPath_,a?this.m_pathIndex=n.getPathCount():this.m_segIter=n.querySegmentIterator()):(this.m_queryType=g,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,i(l)?(this.m_queryType=l,this.m_function=this.nextPath_,a?this.m_pathIndex=e.getPathCount():this.m_segIter=e.querySegmentIterator()):(this.m_queryType=l,this.m_function=this.nextPoint_,this.m_pointIndex=e.getPointCount())),this.m_bQuadTree||(a&&i(l)&&i(g)?this.m_intersector=Me(e,n,o):i(l)&&i(g)?(this.m_intersector=He(e,n,o),this.m_bSwapElements=!1):i(l)&&!i(g)?(this.m_intersector=ke(e,n,o),this.m_bSwapElements=!1):!i(l)&&i(g)?(this.m_intersector=ke(n,e,o),this.m_bSwapElements=!0):(this.m_intersector=Ae(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 C;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 Qe;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(C.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&&(i(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,s){let n;if(e instanceof oc||null===e){const r=C.constructEmpty();r.setCoords({pt:t}),r.mergeEnvelope2D(s),n=le(e,r,!1)}else n=e;return n}function Hr(e,t,s){let n;if(e instanceof oc||null===e){const r=C.constructEmpty();r.setCoords({env2D:t}),r.mergeEnvelope2D(s),n=le(e,r,!1)}else n=e;return n}function kr(e,r,i,o,a){if(e.isEmpty()||r.isEmpty())return 4===o;t(e),t(r);let h=e.getGeometryType(),m=r.getGeometryType();if(h===s.enumEnvelope){if(m===s.enumEnvelope)return Ar(e,r,i,o);if(m===s.enumPoint)return Mr(r,e,i,Vr(o))}else if(h===s.enumPoint){if(m===s.enumEnvelope)return Mr(e,r,i,o);if(m===s.enumPoint)return Ur(e,r,i,o)}const l=C.constructEmpty();e.queryEnvelope(l);const g=C.constructEmpty();r.queryEnvelope(g);const u=Hr(i,l,g);if(qr(l,g,u))return 4===o;let c=!1,_=null,d=null,p=null,f=null;switch(n(h)?(_=new I({vd:e.getDescription()}),_.addSegment(e,!0),p=_,h=s.enumPolyline):p=e,n(m)?(d=new I({vd:r.getDescription()}),d.addSegment(r,!0),f=d,m=s.enumPolyline):f=r,h!==s.enumEnvelope&&m!==s.enumEnvelope?(p.getDimension()<f.getDimension()||h===s.enumPoint&&m===s.enumMultiPoint)&&(o=Vr(o)):h!==s.enumPolygon&&m!==s.enumEnvelope&&(o=Vr(o)),h){case s.enumPolygon:switch(m){case s.enumPolygon:c=Yr(p,f,u,o,a);break;case s.enumPolyline:c=Rr(p,f,u,o,a);break;case s.enumPoint:c=Xr(p,f,u,o);break;case s.enumMultiPoint:c=Lr(p,f,u,o);break;case s.enumEnvelope:c=zr(p,f,u,o,a)}break;case s.enumPolyline:switch(m){case s.enumPolygon:c=Rr(f,p,u,o,a);break;case s.enumPolyline:c=Wr(p,f,u,o,a);break;case s.enumPoint:c=jr(p,f,u,o);break;case s.enumMultiPoint:c=Zr(p,f,u,o);break;case s.enumEnvelope:c=Kr(p,f,u,o,a)}break;case s.enumPoint:switch(m){case s.enumPolygon:c=Xr(f,p,u,o);break;case s.enumPolyline:c=jr(f,p,u,o);break;case s.enumMultiPoint:c=Jr(f,p,u,o)}break;case s.enumMultiPoint:switch(m){case s.enumPolygon:c=Lr(f,p,u,o);break;case s.enumPolyline:c=Zr(f,p,u,o);break;case s.enumMultiPoint:c=Qr(p,f,u,o);break;case s.enumPoint:c=Jr(p,f,u,o);break;case s.enumEnvelope:c=$r(p,f,u,o)}break;case s.enumEnvelope:switch(m){case s.enumPolygon:c=zr(f,p,u,o,a);break;case s.enumPolyline:c=Kr(f,p,u,o,a);break;case s.enumMultiPoint:c=$r(f,p,u,o)}}return c}function Ar(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=C.constructEmpty();e.queryEnvelope(i);const o=C.constructEmpty();t.queryEnvelope(o);const a=Hr(s,i,o);switch(n){case 4:return qr(i,o,a);case 2:return go(o,i,a,!1);case 128:return go(o,i,a,!0);case 1:return go(i,o,a,!1);case 64:return go(i,o,a,!0);case 3:return ho(i,o,a);case 8:return mo(i,o,a);case 32:return lo(i,o,a);case 16:return!1}return!1}function Mr(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=C.constructEmpty();t.queryEnvelope(o);const a=Fr(s,i,o);switch(n){case 4:return Or(i,o,a);case 2:case 128:return ao(i,o,a);case 1:case 64:return!1;case 3:return io(i,o,a);case 8:return oo(i,o,a)}return!1}function Ur(e,t,s,n,r){if(e.isEmpty()||t.isEmpty())return 4===n;const i=e.getXY(),o=t.getXY();let a;if(s instanceof oc||null===s){const e=C.constructEmpty();e.setCoords({pt:i}),e.merge(o),a=le(s,e,!1)}else a=s;switch(n){case 4:return no(i,o,a);case 2:case 128:return ro(o,i,a);case 1:case 64:return ro(i,o,a);case 3:return so(i,o,a)}return!1}function qr(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!e.isIntersecting(n)}function Br(e,t,s,n=!1){const r=e.getGeometryType(),i=t.getGeometryType();if(_(r)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();o(null===e)}}if(_(i)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();o(null===t)}}return 0}function Or(e,t,s,n){const r=C.constructEmpty();return r.setCoords({env2D:t}),r.inflateCoords(s,s),!r.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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!ho(r,i,s))return!1;if(Br(e,t),yo(e,t,s))return!0;const o=e.calculateLength2D(),a=t.calculateLength2D(),h=Math.max(e.getPointCount(),t.getPointCount());if(Math.abs(o-a)>4*h*s)return!1;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"**F**FFF*",n,!1)}return So(e,t,s,!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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),Vo(e,t,s,n))}function ii(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),2===uo(e,t,s,!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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),ko(e,t,s,n))}function li(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&(Br(e,t),2===uo(e,t,s,!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,s,n){Br(e,t);const r=C.constructEmpty();e.queryEnvelope(r),r.inflateCoords(s,s);const i=new Qe;let o=!1;const a=e.getImpl(),h=new v;let m=e,l=!1;for(let g=0;g<t.getPointCount();g++){if(t.queryXY(g,i),r.contains(i)){const e=Lo(m,i,s);if(2===e)o=!0;else if(1===e)return!1}l||(!Wn(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?m=e:(e.copyTo(h),h.getImpl().buildQuadTreeAccelerator(1),m=h),l=!0)}return!!o}function pi(e,t,s,n){Br(e,t);const r=new C,i=new C,o=new C;e.queryEnvelope(r),t.queryEnvelope(o),i.setCoords({env2D:r}),i.inflateCoords(s,s);let a=!1,h=!1;const m=new Qe,l=e.getImpl(),g=new v;let u=e,c=!1;for(let _=0;_<t.getPointCount();_++){if(t.queryXY(_,m),i.contains(m)){const e=Lo(u,m,s);0===e?h=!0:1===e&&(a=!0)}else h=!0;if(a&&h)return!0;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!1}function fi(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);let a=!1;const h=new Qe,m=e.getImpl(),l=new v;let g=e,u=!1;for(let c=0;c<t.getPointCount();c++){if(t.queryXY(c,h),!i.contains(h))return!1;const r=Lo(g,h,s);if(1===r)a=!0;else if(0===r)return!1;if(n&&2===r)return!1;u||(!Wn(e,t.getPointCount()-1)||null!==m.getAccelerators()&&null!==m.getAccelerators().getQuadTree()?g=e:(e.copyTo(l),l.getImpl().buildQuadTreeAccelerator(1),g=l),u=!0)}return a}function xi(e,t,s,n){const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),!ho(r,i,s))return!1;const o=new v;return o.addEnvelope(t,!1),ei(e,o,s,n)}function yi(e,t,s,n){Br(e,t);const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;return 0===Lo(e,i.getLowerLeft(),0)&&(!i.contains(e.getXY(0))&&!To(e,i,s))}function Pi(e,t,s,n){Br(e,t);const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new v;return o.addEnvelope(t,!1),Go(e,o,s,n)}function Ei(e,t,s,n){Br(e,t);const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new v;return o.addEnvelope(t,!1),Do(e,o,s,n)}function Si(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();return e.queryEnvelope(i),t.queryEnvelope(o),n?fo(o,i,s):po(o,i,s)}function Ci(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);const a=new v;return a.addEnvelope(t,!1),n?2===uo(e,a,s,!1):Vo(e,a,s,r)}function Ii(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!ho(r,i,s))return!1;if(Br(e,t),yo(e,t,s))return!0;if(e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"**F**FFF*",n,!1)}return So(e,t,s,!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,s,n){Br(e,t);const r=[],i=bo(e,t,s,r);if(-2===i){const r=C.constructEmpty(),i=C.constructEmpty(),o=C.constructEmpty();let a,h;if(e.queryEnvelope(r),t.queryEnvelope(i),r.inflateCoords(1e3*s,1e3*s),i.inflateCoords(1e3*s,1e3*s),o.setCoords({env2D:r}),o.intersect(i),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;if(t.getPointCount()>10){if(h=Zt(t,o,s,0,n),h.isEmpty())return!1}else h=t;return sr(a,h,s,"F********",n,!1)}if(0!==i)return!1;const o=new N;for(let m=0;m<r.length;m+=2){const e=r[m],t=r[m+1];o.addXY(e,t)}const a=e.getBoundary(),h=t.getBoundary();return a.addPoints(h,0,h.getPointCount()),!a.isEmpty()&&zi(a,o,s)}function vi(e,t,s,n){Br(e,t);const r=[],i=bo(e,t,s,r);if(-2===i){const r=C.constructEmpty(),i=C.constructEmpty(),o=C.constructEmpty();let a,h;if(e.queryEnvelope(r),t.queryEnvelope(i),r.inflateCoords(1e3*s,1e3*s),i.inflateCoords(1e3*s,1e3*s),o.setCoords({env2D:r}),o.intersect(i),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;if(t.getPointCount()>10){if(h=Zt(t,o,s,0,n),h.isEmpty())return!1}else h=t;return sr(a,h,s,"0********",n,!1)}if(0!==i)return!1;const o=new N;for(let m=0;m<r.length;m+=2){const e=r[m],t=r[m+1];o.addXY(e,t)}const a=e.getBoundary(),h=t.getBoundary();return a.addPoints(h,0,h.getPointCount()),!!a.isEmpty()||!zi(a,o,s)}function Ni(e,t,s,n){Br(e,t);const r=C.constructEmpty(),i=C.constructEmpty();e.queryEnvelope(r),t.queryEnvelope(i);const o=xo(r,i,s),a=xo(i,r,s),h=e.hasNonLinearSegments(),m=t.hasNonLinearSegments(),l=bo(e,t,s,null);if(-1===l)return!1;if(1===l){if(o&&a)return!0;if(!h&&!m)return o&&!a?!Co(t,e,s,!1):a&&!o?!Co(e,t,s,!1):!Co(e,t,s,!1)&&!Co(t,e,s,!1)}const g=C.constructEmpty(),u=C.constructEmpty(),c=C.constructEmpty();let _,d;g.setCoords({env2D:r}),g.inflateCoords(1e3*s,1e3*s),u.setCoords({env2D:i}),u.inflateCoords(1e3*s,1e3*s),c.setCoords({env2D:g}),c.intersect(u);let p="";if(p+="1*",o){if(t.getPointCount()>10){if(d=Zt(t,c,s,0,n),d.isEmpty())return!1}else d=t;p+="****"}else d=t,p+="T***";if(a){if(e.getPointCount()>10){if(_=Zt(e,c,s,0,n),_.isEmpty())return!1}else _=e;p+="***"}else _=e,p+="T**";return sr(_,d,s,p,n,!1)}function Ti(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!po(r,i,s))return!1;if(Br(e,t),e.hasNonLinearSegments()||t.hasNonLinearSegments()){return sr(e,t,s,"******FF*",n,!1)}return Co(t,e,s,!1)}function Gi(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),!po(r,i,s))return!1;Br(e,t);return sr(e,t,s,"T**FF*FF*",n,!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 N,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=Ke(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 N;for(let _=0;_<o;_++)a[_]&&c.addPoint2D(i.getXY(_));return!zi(u,c,s)}function Mi(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),!po(i,o,s))return!1;Br(e,t);const a=wo(e,t,s,!0);if(!a)return a;const h=e.getBoundary();return h.isEmpty()?a:!zi(h,t,s)}function Ui(e,t,s,n){const r=new C,i=new C;return e.queryEnvelope(r),t.queryEnvelope(i),!(i.height()>s&&i.width()>s)&&ho(r,i,s)}function qi(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();e.queryEnvelope(r),t.queryEnvelope(i);const o=Bo(i,r,s);return 0===o?!To(e,i,s):4===o}function Bi(e,t,n,i){const o=new C,a=new C;if(e.queryEnvelope(o),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;const h=new C,m=new C;if(h.setCoords({env2D:a}),m.setCoords({env2D:a}),h.inflateCoords(n,n),m.inflateCoords(-n,-n),m.containsEnvelope(o)||!o.isIntersecting(h))return!1;const l=e.getImpl().querySegmentIterator();l.stripAttributes();const g=e.getImpl().getAccelerators();let u=null,c=null;null!==g&&(u=g.getQuadTree(),null!==u&&(c=u.getIterator(a,n))),c||l.nextPath()||r("relational_operations");let _=!1,d=null;const p=new Qe,f=new Qe,x=e.hasNonLinearSegments();let y=!1;for(;;){if(null!==c){const e=c.next();if(-1===e)break;l.resetToVertex(u.getElement(e),-1),d=l.nextSegment()}else{for(;!l.hasNextSegment()&&l.nextPath(););if(!l.hasNextSegment())break;d=l.nextSegment()}if(x&&d.getGeometryType()!==s.enumLine){const e=new C;if(d.queryEnvelope(e),m.containsEnvelope(e))return!1;if(h.isIntersecting(e)){y=!0;break}}else{p.assign(d.getStartXY()),f.assign(d.getEndXY());let e=m.clipLine(p,f);if(0!==e)return!1;_||(e=h.clipLine(p,f),0!==e&&(_=!0))}}if(!y)return _;const P=new v;return P.addEnvelope(a,!1),ai(P,e,n,i)}function Oi(e,t,n,i,o){const a=C.constructEmpty(),h=C.constructEmpty();if(e.queryEnvelope(a),t.queryEnvelope(h),h.height()<=n||h.width()<=n)return!1;if(i)return fo(h,a,n);if(!po(h,a,n))return!1;const m=C.constructEmpty();m.setCoords({env2D:h}),m.inflateCoords(-n,-n);const l=C.constructEmpty();if(l.setCoords({env2D:h}),l.inflateCoords(n,n),m.containsEnvelope(a))return!0;const g=e.getImpl().querySegmentIterator();g.stripAttributes(),g.nextPath()||r("relational_operations");let u,c,_,d,p,f,x=!1;const y=e.hasNonLinearSegments();for(y&&(_=new H,d=new H,p=new H,f=new H,m.querySide(0,_),m.querySide(1,d),m.querySide(2,p),m.querySide(3,f));;){for(;!g.hasNextSegment()&&g.nextPath(););if(!g.hasNextSegment())break;const e=g.nextSegment();if(y&&e.getGeometryType()!==s.enumLine){if(e.isIntersecting(_,n)){x=!0;break}if(e.isIntersecting(d,n)){x=!0;break}if(e.isIntersecting(p,n)){x=!0;break}if(e.isIntersecting(f,n)){x=!0;break}}else{u=e.getStartXY(),c=e.getEndXY();if(0!==m.clipLine(u,c)){x=!0;break}}}return x}function Yi(e,t,n,r){const i=new C,a=new C;if(e.queryEnvelope(i),t.queryEnvelope(a),a.height()<=n||a.width()<=n)return!1;const h=new C;if(h.setCoords({env2D:a}),h.inflateCoords(n,n),h.containsEnvelope(i))return!1;const m=!0,l=new C;if(l.setCoords({env2D:a}),l.inflateCoords(-n,-n),!l.isIntersecting(i))return!1;const g=e.getImpl().querySegmentIterator();g.stripAttributes();const u=e.getImpl().getAccelerators();let c=null,_=null;if(null!==u&&(c=u.getQuadTree(),null!==c&&(_=c.getIterator(a,n))),!_){const e=g.nextPath();o(e)}let d=!1,p=null;const f=new Qe,x=new Qe;let y=null,P=null,E=null,S=null;for(e.hasNonLinearSegments()&&(y=new H,P=new H,E=new H,S=new H,l.querySide(0,y),l.querySide(1,P),l.querySide(2,E),l.querySide(3,S));;){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(p.getGeometryType()===s.enumLine){f.assign(p.getStartXY()),x.assign(p.getEndXY());if(0!==l.clipLine(f,x)){d=!0;break}}else{if(y.isIntersecting(p,n)){d=!0;break}if(P.isIntersecting(p,n)){d=!0;break}if(E.isIntersecting(p,n)){d=!0;break}if(S.isIntersecting(p,n)){d=!0;break}}}return d&&m}function Ri(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!ho(r,i,s)&&(!!Po(e,t,s)||Eo(e,t,s,!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 Qe,m=new Qe;for(;o.next();){const e=o.getRedElement(),t=o.getBlueElement();if(r.queryXY(e,h),i.queryXY(t,m),Qe.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,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),!!po(r,i,s)&&Eo(t,e,s,!0,!1,!1)}function Wi(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();return e.queryEnvelope(r),t.queryEnvelope(i),ho(r,i,s)}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,s,n){const r=new C,i=new C;return e.queryEnvelope(r),t.queryEnvelope(i),!(i.height()>s||i.width()>s)&&ho(r,i,s)}function Ji(e,t,s,n){const r=C.constructEmpty(),i=C.constructEmpty();if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;const o=C.constructEmpty();o.setCoords({env2D:i}),o.inflateCoords(s,s);const a=new Qe;for(let h=0;h<e.getPointCount();h++)if(e.queryXY(h,a),o.contains(a))return!1;return!0}function $i(e,t,s,n){const r=new C,i=new C,o=new C;if(t.queryEnvelope(r),r.height()<=s||r.width()<=s)return!1;i.setCoords({env2D:r}),o.setCoords({env2D:r}),i.inflateCoords(s,s),o.inflateCoords(-s,-s);const a=new Qe;let h=!1;for(let m=0;m<e.getPointCount();m++)if(e.queryXY(m,a),i.contains(a)){if(o.containsExclusive(a))return!1;h=!0}return h}function eo(e,t,s,n,r){const i=C.constructEmpty(),o=C.constructEmpty();if(e.queryEnvelope(i),t.queryEnvelope(o),o.height()<=s||o.width()<=s)return!1;if(n)return fo(o,i,s);if(!po(o,i,s))return!1;let a=!1;const h=C.constructEmpty(),m=C.constructEmpty();h.setCoords({env2D:o}),m.setCoords({env2D:o}),h.inflateCoords(-s,-s),m.inflateCoords(s,s);const l=new Qe;for(let g=0;g<e.getPointCount();g++){if(e.queryXY(g,l),!m.contains(l))return!1;h.containsExclusive(l)&&(a=!0)}return a}function to(e,t,s,n){const r=new C,i=new C;if(e.queryEnvelope(r),t.queryEnvelope(i),po(i,r,s))return!1;if(i.height()<=s||i.width()<=s)return!1;const o=new C,a=new C;o.setCoords({env2D:i}),o.inflateCoords(-s,-s),a.setCoords({env2D:i}),a.inflateCoords(s,s);const h=new Qe;let m=!1,l=!1;for(let g=0;g<e.getPointCount();g++)if(e.queryXY(g,h),!m&&o.containsExclusive(h)&&(m=!0),l||a.contains(h)||(l=!0),m&&l)return!0;return!1}function so(e,t,s,n){return Qe.sqrDistance(e,t)<=s*s}function no(e,t,s,n){return Qe.sqrDistance(e,t)>s*s}function ro(e,t,s,n){return so(e,t,s)}function io(e,t,s,n){const r=new C;return r.setCoords({pt:e}),ho(r,t,s)}function oo(e,t,s,n){if(t.height()<=s||t.width()<=s)return!1;const r=new C,i=new C;return r.setCoords({env2D:t}),r.inflateCoords(s,s),!!r.contains(e)&&(i.setCoords({env2D:t}),i.inflateCoords(-s,-s),!i.containsExclusive(e))}function ao(e,t,s,n){if(t.height()<=s||t.width()<=s)return!1;const r=C.constructEmpty();r.setCoords({env2D:t}),r.inflateCoords(-s,-s);return r.containsExclusive(e)}function ho(e,t,s,n){return po(e,t,s)&&po(t,e,s)}function mo(e,t,s,n){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;const r=new C;return r.setCoords({env2D:e}),r.inflateCoords(-s,-s),r.intersect(t),!(!r.isEmpty()&&r.height()>s&&r.width()>s)&&(r.setCoords({env2D:e}),r.inflateCoords(s,s),r.intersect(t),!r.isEmpty())}function lo(e,t,s,n){if(e.height()<=s||e.width()<=s||t.height()<=s||t.width()<=s)return!1;if(po(e,t,s))return!1;if(po(t,e,s))return!1;const r=new C;return r.setCoords({env2D:e}),r.inflateCoords(-s,-s),r.intersect(t),!r.isEmpty()&&(r.height()>s||r.width()>s)}function go(e,t,s,n,r){if(e.height()<=s||e.width()<=s)return!1;if(n)return fo(e,t,s);if(!po(e,t,s))return!1;const i=C.constructEmpty();return i.setCoords({env2D:e}),i.inflateCoords(-s,-s),i.intersect(t),!i.isEmpty()}function uo(e,t,n,r,i){const o=new Qe,a=new Qe,h=C.constructEmpty(),m=C.constructEmpty(),l=e.getImpl(),g=t.getImpl(),u=g.getGeometryType(),c=new Dr(l,g,n,!0);if(!c.next())return 1;if(Io(e,t,n))return r?4:0;const _=new v;let d=e;const p=new v;let f=null;u===s.enumPolygon&&(f=t);const x=u===s.enumPolygon?Ke(l.getPathCount(),!1):[],y=Ke(g.getPathCount(),!1);let P=!1,E=!1,S=!1,I=!1,b=!1,w=!1;do{if(S&&b||I&&w)break;if(S&&I)break;const i=c.getRedElement(),C=c.getBlueElement();if(!y[C]&&(a.assign(t.getXY(t.getPathStart(C))),h.setCoords({env2D:c.getRedEnvelope()}),h.inflateCoords(n,n),h.contains(a))){if(0!==Lo(d,a,0)){if(I=!0,r)return 4}else w=!0;y[C]=!0}if(u===s.enumPolygon&&!x[i]&&(o.assign(e.getXY(e.getPathStart(i))),m.setCoords({env2D:c.getBlueEnvelope()}),m.inflateCoords(n,n),m.contains(o))){if(0!==Lo(f,o,0)){if(S=!0,r)return 4}else b=!0;x[i]=!0}if(P||(!Wn(e,t.getPathCount()-1)||null!==l.getAccelerators()&&null!==l.getAccelerators().getQuadTree()?d=e:(e.copyTo(_),_.getImpl().buildQuadTreeAccelerator(1),d=_),P=!0),u===s.enumPolygon&&!E){const s=t;!Wn(s,e.getPathCount()-1)||null!==g.getAccelerators()&&null!==g.getAccelerators().getQuadTree()?f=t:(s.copyTo(p),p.getImpl().buildQuadTreeAccelerator(1),f=p),E=!0}}while(c.next());if(!S&&!I)return 1;if(!b||!w){if(u===s.enumPolygon)for(let e=0,t=l.getPathCount();e<t;e++)if(!x[e]){b=!0;break}for(let e=0,t=g.getPathCount();e<t;e++)if(!y[e]){w=!0;break}}return S&&b||I&&w||S&&I?4:I?2:3}function co(e,t,s,n,r){const i=C.constructEmpty();e.queryEnvelope(i),i.inflateCoords(s,s);const o=new Qe,a=e.getImpl(),h=new v;let m=e,l=!1,g=!1,u=!1;for(let c=0;c<t.getPointCount();c++){if(t.queryXY(c,o),i.contains(o)){const e=Lo(m,o,s);if(1===e)return g=!0,4;if(2===e)return 4;u=!0}else u=!0;l||(!Wn(e,t.getPointCount()-1)||null!==a.getAccelerators()&&null!=a.getAccelerators().getQuadTree()?m=e:(e.copyTo(h),h.getImpl().buildQuadTreeAccelerator(1),m=h),l=!0)}return g?u?4:2:1}function _o(e,t,n,r,i){r[0]=!1;const a=e.getImpl(),h=t.getImpl(),m=a.querySegmentIterator(),l=h.querySegmentIterator(),g=[0,0],u=[0,0],c=new Dr(a,h,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(),i=l.nextSegment();let o=0;if(Oo(s,i)?!_&&i.isIntersecting(s,n)&&(_=!0):o=i.intersect(s,null,u,g,n),0!==o&&(_=!0,1===o)){const e=g[0],t=u[0];if(e>0&&e<1&&t>0&&t<1)return r[0]=!0,!1}}if(!_){r[0]=!0;const i=C.constructEmpty();e.queryEnvelope(i),i.inflateCoords(n,n);const m=new v;let l=e,g=!1;for(let s=0,n=t.getPathCount();s<n;s++)if(t.getPathSize(s)>0){const n=C.constructEmpty();if(t.queryPathEnvelope(s,n),!i.isIntersecting(n))return!1;{const e=zn(l,t.getXY(t.getPathStart(s)),0);if(o(-1!==e),0===e)return!1}g||(!Wn(e,t.getPathCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?l=e:(e.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),g=!0)}if(1===e.getPathCount()||t.getGeometryType()===s.enumPolyline)return!0;const u=t,c=C.constructEmpty();u.queryEnvelope(c),c.inflateCoords(n,n);const _=new v;let d=u,p=!1;for(let t=0,s=e.getPathCount();t<s;t++)if(e.getPathSize(t)>0){const s=C.constructEmpty();if(e.queryPathEnvelope(t,s),c.isIntersecting(s)){const s=zn(d,e.getXY(e.getPathStart(t)),0);if(o(-1!==s),1===s)return!1}p||(!Wn(u,e.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?d=u:(u.copyTo(_),_.getImpl().buildQuadTreeAccelerator(1),d=_),p=!0)}return!0}return!1}function po(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)}function fo(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),e.containsExclusiveEnvelope(n)}function xo(e,t,s){const n=C.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),!n.contains(e.getLowerLeft())||(!n.contains(e.getLowerRight())||(!n.contains(e.getUpperLeft())||!n.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 Qe,i=new Qe;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),Qe.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 Qe,i=new Qe;let o=!0;const a=s*s;for(let h=0;h<e.getPointCount();h++)if(e.queryXY(h,r),t.queryXY(h,i),Qe.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=Ke(m,!1),u=r||i?Ke(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);Qe.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,s,n){if(x(e),x(t),t.isEmpty())return!1;let i=!0;const o=Ke(2,Number.NaN),a=Ke(2,Number.NaN),h=[],m=new Ro;let l;const g=C.constructEmpty(),u=C.constructEmpty(),c=C.constructEmpty();e.queryEnvelope(g),t.queryEnvelope(u),g.inflateCoords(s,s),u.inflateCoords(s,s),c.setCoords({env2D:g}),c.intersect(u);const _=e.getImpl().querySegmentIterator(),d=t.getImpl().querySegmentIterator(),p=t.getImpl().getAccelerators();let f=null,y=null,P=null,E=null;if(null!==p&&(f=p.getQuadTree(),y=p.getQuadTreeForPaths(),null!==y&&(E=y.getIteratorForQT())),null===f){const s=e.getPointCount(),n=t.getPointCount();s>10&&n>10&&(f=Ve(t.getImpl(),c))}for(null!==f&&(P=f.getIteratorForQT());_.nextPath();)for(;_.hasNextSegment();){let e=_.nextSegment();if(e.queryEnvelope(g),!g.isIntersecting(c))return i=!1,!1;if(null!==E&&(E.resetIterator(g,s),-1===E.next()))continue;let t=0,p=null;if(null!=P)P.resetIterator(e,s);else if(d.resetToFirstPath(),!d.nextPath())return i=!1,!1;do{if(t=0,null!==P){const n=P.next();if(-1===n)return i=!1,!1;d.resetToVertex(f.getElement(n),-1),p=d.nextSegment(),t=e.intersect(p,null,o,a,s)}else{for(;!d.hasNextSegment();)if(!d.nextPath())return i=!1,!1;p=d.nextSegment(),p.queryEnvelope(u),u.inflateCoords(s,s),g.isIntersecting(u)&&(t=e.intersect(p,null,o,a,s))}}while(2!==t||0!==o[0]||n&&!(a[0]<=a[1]));let x=Number.NaN,y=!1;do{let n=!1;if(1===o[1]){if(!_.hasNextSegment()){y=!0;break}e=_.nextSegment(),n=!0}if(1===a[1]&&a[0]<=a[1]){if(-1===x)break;if(x=1,!d.hasNextSegment())break;p=d.nextSegment(),n=!0}if(0===a[1]&&a[0]>a[1]){if(1===x)break;if(Number.isNaN(x)){if(!d.hasPreviousSegment())break;d.previousSegment(),x=-1}if(!d.hasPreviousSegment())break;p=d.previousSegment(),n=!0}if(!n)break;t=e.intersect(p,null,o,a,s)}while(2===t&&(!n||a[0]<=a[1]));if(y)continue;const S=e.calculateLength2D();e.queryEnvelope(g),h.length=0,m.m_overlapEvents.length=0;let C=!1,I=!1,b=0;const w=le(null,g,!0);for(null!==P?P.resetIterator(e,s):(d.resetToFirstPath(),d.nextPath()||r("relational_operations"));;){if(t=0,null!==P){const n=P.next();if(-1===n)break;d.resetToVertex(f.getElement(n),-1),p=d.nextSegment(),t=e.intersect(p,null,o,a,s)}else{for(;!d.hasNextSegment()&&d.nextPath(););if(!d.hasNextSegment())break;p=d.nextSegment(),p.queryEnvelope(u),u.inflateCoords(s,s),g.isIntersecting(u)&&(t=e.intersect(p,null,o,a,s))}if(2===t&&(!n||a[0]<=a[1])){const e=_.getStartPointIndex(),t=_.getPathIndex(),n=d.getStartPointIndex(),r=d.getPathIndex();if(l=Yo(e,t,o[0],o[1],n,r,a[0],a[1]),m.m_overlapEvents.push(l),h.push(h.length),!(C||l.m_scalarA0<b&&l.m_scalarA1<b))if(0===b&&S*(l.m_scalarA0-b)>s)C=!0;else if(0!==b&&S*(l.m_scalarA0-b)>w)C=!0;else if(b=l.m_scalarA1,S*(1-b)<=s||1===b){I=!0;break}}}if(!I){if(!C)return i=!1,!1;h.length>1&&h.sort((e,t)=>m.compareOverlapEvents(e,t)),b=0;for(let e=0;e<m.m_overlapEvents.length;e++)if(l=m.m_overlapEvents[h[e]],!(l.m_scalarA0<b&&l.m_scalarA1<b)){if(0===b&&S*(l.m_scalarA0-b)>s)return i=!1,!1;if(0!==b&&S*(l.m_scalarA0-b)>w)return i=!1,!1;if(b=l.m_scalarA1,S*(1-b)<=s||1===b)break}if(S*(1-b)>s)return i=!1,!1;h.length=0,m.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=Ke(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 Qe;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?Ke(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,s){const n=new Qe,r=s*s,i=e.querySegmentIterator(),o=e.getImpl().getAccelerators();if(null!==o){const e=o.getQuadTree();if(null!==e){const o=C.constructEmpty();o.setCoords({pt:t});const a=e.getIterator(o,s);for(let s=a.next();-1!==s;s=a.next())if(i.resetToVertex(e.getElement(s),-1),i.hasNextSegment()){const e=i.nextSegment(),s=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(s,n),Qe.sqrDistance(t,n)<=r)return!0}return!1}}const a=C.constructEmpty();for(;i.nextPath();)for(;i.hasNextSegment();){const e=i.nextSegment();if(e.queryEnvelope(a),a.inflateCoords(s,s),!a.contains(t))continue;const o=e.getClosestCoordinate(t,!1);if(e.queryCoord2D(o,n),Qe.sqrDistance(t,n)<=r)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 i=e.querySegmentIterator(),o=e.getImpl().getAccelerators(),a=e.hasNonLinearSegments();let h=null,m=null,l=null,g=null;if(null!==o){const e=o.getQuadTree();if(null!==e){const r=e.getIterator(t,n);a&&(h=new H,m=new H,l=new H,g=new H,t.querySide(0,h),t.querySide(1,m),t.querySide(2,l),t.querySide(3,g));const o=C.constructEmpty();o.setCoords({env2D:t}),o.inflateCoords(n,n);for(let a=r.next();-1!==a;a=r.next())if(i.resetToVertex(e.getElement(a),-1),i.hasNextSegment()){const e=i.nextSegment();if(e.getGeometryType()===s.enumLine){const t=e.getStartXY(),s=e.getEndXY();if(o.clipLine(t,s))return!0;continue}if(t.contains(e.getStartXY())||t.contains(e.getEndXY()))return!0;if(e.isIntersecting(h,n))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0}return!1}}if(a){h=new H,m=new H,l=new H,g=new H,t.querySide(0,h),t.querySide(1,m),t.querySide(2,l),t.querySide(3,g);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(h,n))return!0;if(e.isIntersecting(m,n))return!0;if(e.isIntersecting(l,n))return!0;if(e.isIntersecting(g,n))return!0}}else{const s=C.constructEmpty();s.setCoords({env2D:t}),s.inflateCoords(n,n);const r=e.getImpl(),i=r.getAttributeStreamRef(0),o=new Qe;for(let e=0,t=r.getPathCount();e<t;e++){let t=!0;const n=new Qe,a=new Qe,h=new Qe,m=r.getPathStart(e),l=new Qe;for(let g=m,u=r.getPathEnd(e);g<u;g++)if(t)i.queryPoint2D(2*g,n),l.assign(n),t=!1;else{if(i.queryPoint2D(2*g,o),a.setCoordsPoint2D(n),h.setCoordsPoint2D(o),s.clipLine(a,h))return!0;n.assign(o)}if(r.isClosedPath(e)&&!t&&(a.setCoordsPoint2D(n),h.setCoordsPoint2D(l),s.clipLine(a,h)))return!0}}return!1}function Go(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=[0],a=Te(r.getIsSimple(0,o))&&Te(i.getIsSimple(0,o)),h=r.querySegmentIterator(),m=i.querySegmentIterator(),l=Ke(2,0),g=Ke(2,0),u=new Dr(r,i,s);let c=!1;for(;u.next();){const e=u.getRedElement(),t=u.getBlueElement();h.resetToVertex(e,-1),m.resetToVertex(t,-1);const n=h.nextSegment(),r=m.nextSegment();let i=0;if(Oo(n,r)){if(r.isIntersecting(n,s)){c=!0;break}}else i=r.intersect(n,null,g,l,s);if(2===i){const e=l[0],t=l[1],r=n.calculateLength2D();if(a&&(t-e)*r>s)return!1;c=!0}else if(i){const e=l[0],t=g[0];if(e>0&&e<1&&t>0&&t<1)return!1;c=!0}}if(!c)return!1;const _=C.constructEmpty(),d=C.constructEmpty(),p=C.constructEmpty();let f,x;if(e.queryEnvelope(_),t.queryEnvelope(d),_.inflateCoords(1e3*s,1e3*s),d.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:_}),p.intersect(d),e.getPointCount()>10){if(f=Zt(e,p,s,0,n),f.isEmpty())return!1}else f=e;if(t.getPointCount()>10){if(x=Zt(t,p,s,0,n),x.isEmpty())return!1}else x=t;return sr(f,x,s,"F********",n,!1)}function Do(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=[0],a=Te(r.getIsSimple(0,o))&&Te(i.getIsSimple(0,o)),h=C.constructEmpty(),m=C.constructEmpty(),l=C.constructEmpty();e.queryEnvelope(h),t.queryEnvelope(m);let g=!1;const u=xo(h,m,s),c=xo(m,h,s),_=r.querySegmentIterator(),d=i.querySegmentIterator(),p=Ke(2,Number.NaN),f=Ke(2,Number.NaN),x=new Dr(r,i,s);for(;x.next();){const e=x.getRedElement(),t=x.getBlueElement();_.resetToVertex(e,-1),d.resetToVertex(t,-1);const n=_.nextSegment(),r=d.nextSegment();let i=0;if(Oo(n,r)){if(r.isIntersecting(n,s))break}else i=r.intersect(n,null,f,p,s);if(2===i){const e=p[0],t=p[1],r=n.calculateLength2D();if(a&&(t-e)*r>s&&(g=!0,u&&c))return!0}else if(i){const e=p[0],t=f[0];if(e>0&&e<1&&t>0&&t<1)return!0}}const y=C.constructEmpty(),P=C.constructEmpty();let E,S;y.setCoords({env2D:h}),y.inflateCoords(1e3*s,1e3*s),P.setCoords({env2D:m}),P.inflateCoords(1e3*s,1e3*s),l.setCoords({env2D:y}),l.intersect(P);let I="";if(I+=g?"**":"T*",u){if(t.getPointCount()>10){if(S=Zt(t,l,s,0,n),S.isEmpty())return!1}else S=t;I+="****"}else S=t,I+="T***";if(c){if(e.getPointCount()>10){if(E=Zt(e,l,s,0,n),E.isEmpty())return!1}else E=e;I+="***"}else E=e,I+="T**";return sr(E,S,s,I,n,!1)}function Vo(e,t,s,n){const r=[!1],i=_o(e,t,s,r);if(r[0])return i;const o=C.constructEmpty();let a;if(t.queryEnvelope(o),o.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;return nr(a,t,s,n)}function Fo(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),h=Ke(2,Number.NaN),m=Ke(2,Number.NaN),l=new Dr(r,i,s);let g=!1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const n=o.nextSegment(),r=a.nextSegment();let i=0;if(Oo(n,r)?!g&&r.isIntersecting(n,s)&&(g=!0):i=r.intersect(n,null,m,h,s),2===i)g=!0;else if(i){const e=h[0],t=m[0];if(e>0&&e<1&&t>0&&t<1)return!1;g=!0}}if(!g)return!1;const u=C.constructEmpty(),c=C.constructEmpty(),_=C.constructEmpty();let d,p;if(e.queryEnvelope(u),t.queryEnvelope(c),u.inflateCoords(1e3*s,1e3*s),c.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:u}),_.intersect(c),e.getPointCount()>10){if(d=Zt(e,_,s,0,n),d.isEmpty())return!1}else d=e;if(t.getPointCount()>10){if(p=Zt(t,_,s,0,n),p.isEmpty())return!1}else p=t;return sr(d,p,s,"F********",n,!1)}function Ho(e,t,s,n){const r=e.getImpl(),i=t.getImpl(),o=r.querySegmentIterator(),a=i.querySegmentIterator(),h=Ke(2,Number.NaN),m=Ke(2,Number.NaN),l=new Dr(r,i,s);let g=!1;for(;l.next();){const e=l.getRedElement(),t=l.getBlueElement();o.resetToVertex(e,-1),a.resetToVertex(t,-1);const n=o.nextSegment(),r=a.nextSegment();let i=0;if(Oo(n,r)?!g&&r.isIntersecting(n,s)&&(g=!0):i=r.intersect(n,null,m,h,s),2===i)g=!0;else if(i){const e=h[0],t=m[0];if(e>0&&e<1&&t>0&&t<1)return!0;g=!0}}if(!g)return!1;const u=C.constructEmpty(),c=C.constructEmpty(),_=C.constructEmpty(),d=C.constructEmpty(),p=C.constructEmpty();if(e.queryEnvelope(u),t.queryEnvelope(c),xo(c,u,s)){let r,i;if(_.setCoords({env2D:u}),_.inflateCoords(1e3*s,1e3*s),d.setCoords({env2D:c}),d.inflateCoords(1e3*s,1e3*s),p.setCoords({env2D:_}),p.intersect(d),e.getPointCount()>10){if(r=Zt(e,p,s,0,n),r.isEmpty())return!1}else r=e;if(t.getPointCount()>10){if(i=Zt(t,p,s,0,n),i.isEmpty())return!1}else i=t;return sr(r,i,s,"T********",n,!1)}return sr(e,t,s,"T*****T**",n,!1)}function ko(e,t,s,n){const r=[!1],i=_o(e,t,s,r);if(r[0])return i;const o=C.constructEmpty();let a;if(t.queryEnvelope(o),o.inflateCoords(1e3*s,1e3*s),e.getPointCount()>10){if(a=Zt(e,o,s,0,n),a.isEmpty())return!1}else a=e;return rr(a,t,s,n)}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 Qe,i=s*s;for(let o=0;o<e.getPointCount();o++)if(e.queryXY(o,r),Qe.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,s){const n=C.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),n.containsEnvelope(t)?1073741824:n.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()!==s.enumLine||t.getGeometryType()!==s.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,i){if(e.getGeometryType()===s.enumPolygon)zo(e,t,n,r,i);else if(e.getGeometryType()===s.enumEnvelope){const s=C.constructEmpty();e.queryEnvelope(s),Zo(s,t,n,r,i)}else u("")}function jo(e,t,r,i,o){const a=e.getGeometryType();a===s.enumPolyline?$o(e,t,r,i,o):n(a)?Jo():u("")}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 s.enumMultiPoint:return e.getImpl().getPointCount();case s.enumPolyline:return e.getImpl().getPathCount();case s.enumPolygon:return e.getImpl().getOGCPolygonCount();case s.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 Qe;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){o(0)}function $o(e,t,s,n,r){const i=e.getImpl(),a=i.getAccelerators();let h=null;a&&(h=a.getRasterizedGeometry());let m=s;for(let l=0;l<s;l++)r[l]=1,h&&o(0);if(m){if(a){let e=null;null!==a&&null!==a.getQuadTree()&&(e=a.getQuadTree());const o=i.getPointCount();if(null===e&&o>20&&o*s>4*o+Math.log(o)*s&&(e=Ve(i)),e){let o=null;const a=i.querySegmentIterator(),h=new C;for(let i=0;i<s&&m;i++)if(1===r[i]){h.setCoords(t[i]),null===o?o=e.getIterator(h,n):o.resetIterator(h,n);let s=-1;for(let h=o.next();-1!==h;h=o.next()){a.resetToVertex(e.getElement(h),s),s=a.getPathIndex();if(a.nextSegment().isIntersectingPoint(t[i],n)){r[i]=2,m--;break}r[i]=0}}return}}const e=i.querySegmentIterator();for(;e.nextPath()&&m;)for(;e.hasNextSegment()&&m;){const i=e.nextSegment();for(let e=0;e<s&&m;e++)1===r[e]&&i.isIntersectingPoint(t[e],n)&&(r[e]=2,m--)}}for(let o=0;o<s;o++)1===r[o]&&(r[o]=0)}function ea(e,t,s,n,r){const i=K(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 Qe,ptEnd:new Qe,center:new J,radius:new At,fcenter:new se,fradius2:new Vt,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=Vt.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 se).assignPoint2D(i.ptStart),h=(new se).assignPoint2D(i.ptEnd).sub(a),m=(new se).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=J.constructPoint2D(i.ptStart).subE(i.center),x=J.constructPoint2D(i.ptEnd).subE(i.center);if(!f.dotProduct(x).gt(Ft))return!1;const y=this.maxCircleApproximationError(e,t,i);return i.maxError=y,y<=this.m_eps}static checkSweepAngle(e,t){if(e.getGeometryType()===s.enumEllipticArc){const s=e,n=ne(s,t.vmin),r=ne(s,t.vmax);return!(Math.abs(r-n)>.5*Ct)}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,n){const r=[.25,.75],i=[.1,.25,.75,.9];let o,a;e.getGeometryType()===s.enumEllipticArc?(o=r,a=r.length):(o=i,a=i.length);let h=0;for(let s=0;s<a;++s){const r=new Qe;e.queryCoord2D(ft(t.vmin,t.vmax,o[s]),r);const i=r.sub(n.center.value()).length(),a=Math.abs(i-n.radius.value());a>h&&(h=a)}return h}approximateWithCirclesImpl(e,t){let s=1;t&&t.push(0);const n=Ke(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 Qe(0,0);for(let h=1;h<r;h++){const e=new at(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 at;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,wt(t,o.reverse(),t.length-o.length,0,o.length),o.length=0),i.length=0}return s}approximateWithCirclesImplPolyline(e){const t=new I,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 Qe;this.m_left.queryCoord2D(s[i],e);const o=new Qe;this.m_left.queryCoord2D(.5*(s[i]+n),o);const a=new R;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,n,r){if(!i(e.getGeometryType()))return e;const o=e.getImpl();if(!o.hasNonLinearSegments())return e;const a=e.createInstance();if(a.getGeometryType()===s.enumPolygon){a.setFillRule(e.getFillRule())}new G;const h=new fe,m=new F,l=[],g=[],u=[],c=e.getDescription().getAttributeCount()>1,_=o.querySegmentIterator();for(;_.nextPath();){let e=!0;for(;_.hasNextSegment();){const r=_.isClosingSegment(),i=_.nextSegment();if(!i.isCurve()){a.addSegment(i,e,r),e=!1;continue}let o,d=!1;const p=!0,f=!0;switch(i.getGeometryType()){case s.enumEllipticArc:case s.enumRationalBezier2:o=A(i,t,n,p,f,g,u,l),d=!0;break;default:o=k(i,t,n,!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&&(i.queryCoord(l[0],h),m.get().setStart(h)),c&&(i.queryCoord(l[1],h),m.get().setEnd(h)),a.addSegment(m.get(),e,r&&1===o),e=!1;for(let e=1,t=o,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&&(i.queryCoord(l[e+1],h),m.get().setEnd(h)),a.addSegment(m.get(),!1,r&&e+1===t)}}return a}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!==M;s=t.next())if(!e.getSegmentParentageBreakVertex(s)){e.getPathFromVertex(s);const t=e.getPrevVertex(s),n=t!==M?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 Ce(0),s=e.queryVertexIteratorOnSelection();for(let o=s.next();o!==M;o=s.next())t.add(o);if(0===t.size())return;e.sortVerticesSimpleByY(t,0,t.size()),t.add(M);const n=Qe.getNAN();e.queryXY(t.read(0),n);let r=0;const i=Qe.getNAN();for(let o=1,a=t.size();o<a;o++){{const s=t.read(o);s!==M?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!==M?s.assign(e.getXY(r)):s.setNAN(),i!==M?n.assign(e.getXY(i)):n.setNAN()},i=new Qe,a=new Qe;n(t.read(r),i,a);for(let e=r+1;e<o;++e){const r=t.read(e);if(r===M)continue;const o=new Qe,h=new Qe;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:de(null,t,!0).total();return s>e&&(s=e),.125*s}function _a(e,t){return t||(t=C.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,n,r){const i=!1,a=!0;if(!e.hasCurves())return;o(!e.hasSegmentParentage()),this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex()),this.m_tolerance=n;const h=new fe,m=new F,l=[],g=[],u=[];for(let c=e.getFirstGeometry();c!==M;c=e.getNextGeometry(c))for(let r=e.getFirstPath(c);r!==M;r=e.getNextPath(r)){let c=e.getPathSize(r),_=e.getFirstVertex(r),d=0,p=-1;for(let f=0;f<c;f++){let x=e.getNextVertex(_);if(!e.querySegment(_,m,!0,!1)){_=x;continue}if(0===d){p=e.getVertexIndex(_);const t=xa.regularizeCurve(e,m.get(),_,n);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(r),x=e.getNextVertex(_);const s=e.querySegment(_,m,!0,!1);o(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(m.get().getGeometryType()){case s.enumEllipticArc:case s.enumRationalBezier2:P=A(m.get(),t,n,i,a,g,u,l),E=!0;break;default:{const e=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();P=k(m.get(),t,n,e,i,g,l)}}const S=this.m_originalPlanarSegments.length;if(e.setSegmentParentageAndBreak(_,S,!0),!g[1].isNAN()){let t=null;t=E?new O({points:g,weights:u}):new B({cp:g}),t.snapControlPoints(n*n),e.setSegmentToIndex(y,t)}const C=E?2:3;for(let t=1,s=P,i=C;t<s;++t,i+=C){m.get().queryCoord(l[t],h);const s=e.insertVertex(r,x,h);if(-1!==this.m_originalVertexIndex&&e.setUserIndex(s,this.m_originalVertexIndex,p),!g[i+1].isNAN())if(E){const t=new O({points:g.slice(i),weights:u.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(s),t)}else{const t=new B({cp:g.slice(i)});t.snapControlPoints(n*n),e.setSegmentToIndex(e.getVertexIndex(s),t)}e.setSegmentParentageAndBreak(s,S,!1)}P>1&&(f+=P-1,c=e.getPathSize(r)),this.m_originalPlanarSegments.push(m.releaseSegment()),_=x}}}buildLinearSegmentParentage(e,t,s,n,r){if(this.m_type=0,this.m_densificationDeviation=t,this.m_maxSegmentsPerCurve=n,!e.hasCurves())return;o(!e.hasSegmentParentage()),this.m_tolerance=s,this.m_originalPlanarSegments=[],this.m_bIsSimple&&(this.m_originalVertexIndex=e.createUserIndex());const i=new fe,a=new F,h=new Y(0,t,0,this.m_progressTracker,!1,n),m=[];for(let l=e.getFirstGeometry();l!==M;l=e.getNextGeometry(l))for(let t=e.getFirstPath(l);t!==M;t=e.getNextPath(t)){let n=e.getPathSize(t),r=e.getFirstVertex(t);for(let l=0;l<n;l++){let l=e.getNextVertex(r);if(!e.querySegment(r,a,!0,!1)){r=l;continue}if(xa.regularizeCurve(e,a.get(),r,s)>=0){n=e.getPathSize(t),l=e.getNextVertex(r);const s=e.querySegment(r,a,!0,!1);o(s)}const g=e.getVertexIndex(r);-1!==this.m_originalVertexIndex&&e.setUserIndex(r,this.m_originalVertexIndex,g),e.setSegmentToIndex(g,null),m.length=0,h.densifySegment(a.get(),m),this.progress_();const u=this.m_originalPlanarSegments.length;e.setSegmentParentageAndBreak(r,u,!0);for(let s=1,n=m.length-1;s<n;++s){a.get().queryCoord(m[s],i);const n=e.insertVertex(t,l,i);e.setSegmentParentageAndBreak(n,u,!1),-1!==this.m_originalVertexIndex&&e.setUserIndex(n,this.m_originalVertexIndex,g)}this.m_originalPlanarSegments.push(a.releaseSegment()),r=l}}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,M,0,!0)}getOriginalVertexIndex(e,t){return-1!==this.m_originalVertexIndex&&t!==M?e.getUserIndex(t,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(e){if(-1!==e){const t=this.m_originalPlanarSegments[e];switch(t.getGeometryType()){case s.enumEllipticArc:return 0===t.projectionBehavior()?0:1;case s.enumBezier:return 2;case s.enumBezier2:return 3;case s.enumLine:return-1;case s.enumRationalBezier2:return 4;default:g("")}}return-1}progress_(e=!1){this.m_progressCounter++}processSpanSmartTe_(e,t,s,n,r,i,a){if(t===s&&0===n)return o(e.getNextVertex(t)===M),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const h=e.getNextVertex(t),m=e.getXY(t),l=e.getXY(s);let g,u=0;{let t=2,r=m;for(let n=h;n!==s;n=e.getNextVertex(n)){const s=e.getXY(n);u+=Qe.distance(s,r),r=s,t++}u+=Qe.distance(l,r),o(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(h,s);const c=a;let _=r.getClosestCoordinate(m,!1),d=r.getClosestCoordinate(l,!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=Qe.distance(r.getStartXY(),r.getEndXY());e<=c&&p>5*e&&(S=!0)}if(S){let i,a,h=new Qe;if(2===n)h=Qe.lerp(m,l,.5),i=r.getClosestCoordinate(h,!1),a=r.tToLength(i);else{let s=e.getNextNthVertex(t,(n-1)/2);h=e.getXY(s),i=r.getClosestCoordinate(h,!1),a=r.tToLength(i);let o=Math.abs(a)>10*c&&Math.abs(a-p)>10*c;if(!o&&(n-1>=4&&(s=e.getNextNthVertex(t,(n-1)/4),i=r.getClosestCoordinate(h,!1),a=r.tToLength(i),o=Math.abs(a)>10*c&&Math.abs(a-p)>10*c),!o))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=m,h=e.getXY(e.getNextNthVertex(t,i)),l=e.getXY(e.getNextNthVertex(t,o));u=-Qe.orientationNonRobust(a,h,l)*it(r.calculateArea2DHelper())>0}else P?y?u=a>f:a<x?(f=0,_=0):(f=p,_=1):a>f?(x=p,d=1):(x=0,d=0);if(S)g=r.clone(),g.dropAllAttributes(),u||g.reverse(),o(m.equals(l));else{let e=!1;_>d&&(e=!0,[_,d]=[d,_]),g=r.cut(_,d,!0),g.getDescription().getAttributeCount(),e&&g.reverse()}g.setCoordsForIntersector(m,l,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}else if(y||P){if(!y||!P){if(Qe.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,h=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(m,l,!1),o[e]=i[e].calculateLength2D();const s=Math.abs(u-o[e]);s<a&&(a=s,h=e)}return g=i[h],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(m,l,!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=It(s,e,1),g=g.cut(e,s,!0)}g.setCoordsForIntersector(m,l,!1),g=E(g),g&&(this.removeSpanBetween(e,t,s),e.setSegmentToIndex(e.getVertexIndex(t),g))}}processSpanCurves_(e,t,s,n,r,i,a){if(t===s&&0===n)return o(e.getNextVertex(t)===M),e.setSegmentToIndex(e.getVertexIndex(t),null),void e.setSegmentParentageAndBreak(t,-1);const h=e.getNextVertex(t);{let t=2;for(let n=h;n!==s;n=e.getNextVertex(n))t++;o(t===n)}if(null===r)return e.setSegmentToIndex(e.getVertexIndex(t),null),void e.removeVertices(h,s);const m=e.getXY(t),l=e.getXY(s);if(r.isClosed()){if(m.isEqualPoint2D(l)&&m.isEqualPoint2D(r.getStartXY())){let o;if(o=this.verifySegmentFitnessCurves(e,t,s,n,r,i,a)){const n=r.clone();return n.dropAllAttributes(),o<0&&n.reverse(),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),n)}}}else if(m.isEqualPoint2D(r.getStartXY())){if(l.isEqualPoint2D(r.getEndXY())){const h=r.clone();h.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,h,i,a);if(m)return o(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),h)}}else if(l.isEqualPoint2D(r.getStartXY())&&m.isEqualPoint2D(r.getEndXY())){const h=r.getReversed();h.dropAllAttributes();const m=this.verifySegmentFitnessCurves(e,t,s,n,h,i,a);if(m)return o(m>0),this.removeSpanBetween(e,t,s),void e.setSegmentToIndex(e.getVertexIndex(t),h)}this.processSpanSplitSegmentCurves(e,t,s,n,r,i,a)}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 _=Qe.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=Qe.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 F;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 gt(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,n,i,o){const a=new F;if(!e.querySegment(t,a,!0,!1))return;const h=n.getGeometryType();if(h!==a.get().getGeometryType()){if(h===s.enumEllipticArc){if(a.get().getGeometryType()!==s.enumRationalBezier2)return;if(0===n.projectionBehavior()){const s=[];ea(!1,a.get(),o,s,this.m_progressTracker);const n=e.getNextVertex(t),r=e.getPathFromVertex(t),i=new fe;let h=t;for(let t=1,o=s.length;t<o;t++){const o=s[t],m=a.get().getCoord2D(s[t-1]),l=a.get().getCoord2D(ft(s[t-1],o,.5));a.get().queryCoord(o,i);const g=i.getXY(),u=new R;u.constructCircularArcThreePoint(m,g,l);let c=M;o<1&&(c=e.insertVertex(r,n,i)),e.setSegmentToIndex(e.getVertexIndex(h),u),h=c}return}{const s=lt(Qe,3);a.get().queryControlPoints(s);const n=[0,0,0];a.get().queryWeights(n);const r=X(n),i=new R;return L(s,r*r,null,!1,i),void e.setSegmentToIndex(e.getVertexIndex(t),i)}}r("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=Ke(z.s_maxMonotonicPartParams,Number.NaN);let g=r.getMonotonicPartParams(l.length,l);g--;const u=new H,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,at.unit(),o))return 0}if(g>1)for(let e=1;e<g;){const t=r.getCoord2D(l[e]);n.isCloserThanDistance(t,at.unit(),o)?(l[g-1]=rt(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===M?t.getFirstGeometry():s;for(;i!==M;)if(P(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==M;s=t.getNextPath(s)){let i=t.getPathSize(s);const a=t.isClosedPath(s);a&&(i+=1);let h=t.getFirstVertex(s);const m=t.getSegmentParentage(h);if(a){if(-1!==m&&!t.getSegmentParentageBreakVertex(h)){let e=t.getPrevVertex(h);const s=h;for(let n=0;;n++){const r=t.getSegmentParentage(e);if(m!==r){o(-1===r);break}if(h=e,t.getSegmentParentageBreakVertex(e))break;if(e===s){h=s,t.setSegmentParentageBreakVertex(h,!0);break}e=t.getPrevVertex(e),o(n<i)}}}else o(-1===m||t.getSegmentParentageBreakVertex(h));let l=h;for(let s=0;s<i&&l!==M;){const a=t.getSegmentParentage(l);if(-1===a){if(s++,l=t.getNextVertex(l),l===h)break;continue}let m=0,g=M;const u=l;m=1;let c=t.getNextVertex(u);for(;s<i&&c!==M;){s++,g=c,m++;const e=t.getSegmentParentage(c);if(-1===e||t.getSegmentParentageBreakVertex(c))break;o(e===a),c=t.getNextVertex(c)}if(g===M){o(0);break}if(!r){const s=e.m_originalPlanarSegments[a];e.processSpan_(t,u,g,m,s,a,n)}if(l=g,l===h)break}}if(s!==M)break;i=t.getNextGeometry(i)}else i=s===M?t.getNextGeometry(i):M}static st_stitchCurvesFromLinesImpl(e,t,s,n,r){let i=s===M?t.getFirstGeometry():s;for(;i!==M;){for(let s=t.getFirstPath(i);s!==M;s=t.getNextPath(s)){let i=t.getPathSize(s);t.isClosedPath(s)&&(i+=1);let a=!0,h=!1;const m=t.getFirstVertex(s);let l=m;for(let s=0;s<i&&l!==M;){let g=t.getSegmentParentage(l);if(-1===g||a){a=!1,s++,l=t.getNextVertex(l),h=!0;continue}let u,c,_=0;if(h?(u=t.getPrevVertex(l),c=l,o(u!==M),o(c!==u),o(-1===t.getSegmentParentage(u)||m===u)):(u=l,c=t.getNextVertex(u),s++,o(c!==M),o(c!==u),g=t.getSegmentParentage(c)),_=2,h=!1,-1===g||t.getSegmentParentageBreakVertex(c)){l=c;continue}let d=t.getNextVertex(c);for(s++;s<i&&d!==M;){c=d,_++;const e=t.getSegmentParentage(d);if(-1===e||t.getSegmentParentageBreakVertex(d))break;o(e===g),s++,d=t.getNextVertex(d)}if(!r){const s=e.m_originalPlanarSegments[g];e.processSpan_(t,u,c,_,s,g,n)}l=c}}if(s!==M)break;i=t.getNextGeometry(i)}}static st_stitchCurvesFromCurvesImpl(e,t,s,n,r){let i=s===M?t.getFirstGeometry():s;for(;i!==M;)if(P(t.getGeometryType(i))){for(let s=t.getFirstPath(i);s!==M;s=t.getNextPath(s)){let i=t.getPathSize(s);const a=t.isClosedPath(s);a&&(i+=1);let h=t.getFirstVertex(s);if(a){if(-1!==t.getSegmentParentage(h)){let e=h;for(let n=0;!t.getSegmentParentageBreakVertex(e);n++){if(n===i){h=t.getFirstVertex(s),t.setSegmentParentageBreakVertex(e,!0);break}e=t.getPrevVertex(e)}}}else o(-1===t.getSegmentParentage(h)||t.getSegmentParentageBreakVertex(h));let m=h;for(let s=0;s<i&&m!==M;){const a=t.getSegmentParentage(m);if(-1===a){s++,m=t.getNextVertex(m);continue}let h=0,l=M;const g=m;h=1;let u=t.getNextVertex(g);for(;s<i&&u!==M;){s++,l=u,h++;const e=t.getSegmentParentage(u);if(-1===e||t.getSegmentParentageBreakVertex(u))break;o(e===a),u=t.getNextVertex(u)}if(l===M)break;if(!r){const s=e.m_originalPlanarSegments[a];e.processSpan_(t,g,l,h,s,a,n)}m=l}}if(s!==M)break;i=t.getNextGeometry(i)}else i=s===M?t.getNextGeometry(i):M}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()===B.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))*Et(),s=Qe.distance(a[e-1],a[e]);if(s<t&&s>0){const t=new Qe;St(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=ye(e);return ln(t.getX(),t.getY(),s.getX(),s.getY(),ut(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 fe;return cn(e,t,s,n,r,i,h,a,o),h}function Sa(e,t,s){const n=ye(t),r=Se(t);return!!_n(e,n,M,null,s)||Mn(!0,e,r,null,s)}function Ca(e,t,s){return ba.fixCurveTwoPointLoops(e,t,s)}function Ia(e){return ye(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 xe(this.m_tolerance.tolerance,this.m_tolerance.resolution),t=1e-5,s=1e-6,n=Ia(e);let i=Se(e);const o=i*(1+t);i*=1+s;let a=!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&&r("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let e=-1;0===l&&(e=this.firstCrack_(),a||=e>0);const t=this.cluster_(n);if(this.m_shape.dbgVerifyMonotone(),a||=t,this.m_bFilterDegenerateSegments){const e=0!==this.m_shape.filterClosePoints(n,!0,!1,this.m_bTrackChanges,M);a||=e,this.m_shape.dbgVerifyMonotone()}const s=this.m_shape.snapControlPointsOnSelection(o*o);a||=s,this.m_shape.dbgCheckSelection();let g=!1;if((0===l&&-1===e||m||Mn(!0,this.m_shape,i,null,this.m_progressTracker))&&(g=this.crack_(o),a||=g,this.m_shape.dbgVerifyMonotone()),!g&&!ba.fixCurveTwoPointLoops(this.m_shape,n,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return a&&ua(this.m_shape),a}cluster_(e){return mn(this.m_shape,e,M,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 Ce(0),i=e.queryVertexIteratorOnSelection();for(let o=i.next();o!==M;o=i.next())r.add(o),e.setUserIndex(o,n,-1);if(0===r.size())return!1;r.add(M),e.sortVerticesSimpleByY(r,0,r.size()-1);let a=0;const h=e.getXY(r.read(a)),m=new Qe(Number.NaN,Number.NaN),l=[];for(let o=1,g=r.size();o<g;++o){const t=r.read(o),s=t!==M?e.getXY(t):m;if(s.equals(h))continue;const i=[];for(let m=a;m<o;m++){const t=r.read(m),s=e.getPrevVertex(t);if(s!==M&&-1===e.getUserIndex(s,n)){const t=wa(e.getXY(s),e.getSegment(s));0!==Qe.sqrDistance(h,t.otherPt)&&(t.vert=s,t.dir=-1,i.push(t)),e.setUserIndex(s,n,1)}const o=e.getNextVertex(t);if(o!==M&&-1===e.getUserIndex(t,n)){const s=wa(e.getXY(o),e.getSegment(t));0!==Qe.sqrDistance(h,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(m.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++)l.push(i[r].vert)}t=s}}a=o,h.setCoordsPoint2D(s)}for(const g of l){const s=e.getSegment(g);o(null!==s);const n=e.getXY(g),r=e.getXY(e.getNextVertex(g));if(Qe.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),l.length>0}firstCrack_(){const e=this.m_shape.getEnvelope2D(this.m_progressTracker),t=de(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,M));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(o(e.otherPt.equals(t.otherPt)),null===e.seg)return null===t.seg;if(null===t.seg)return!1;const n=e.seg.getGeometryType();if(n!==t.seg.getGeometryType())return!1;if(n===s.enumBezier){const s=e.seg,n=t.seg;let r=s.getControlPoint1(),i=s.getControlPoint2();-1===e.dir&&(i=rt(r,r=i));let o=n.getControlPoint1(),a=n.getControlPoint2();return-1===t.dir&&(a=rt(o,o=a)),r.equals(o)&&i.equals(a)}if(n===s.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]=rt(o[0],o[0]=o[2]));const a=[0,0,0];return n.queryWeights(a),-1===t.dir&&(a[2]=rt(a[0],a[0]=a[2])),o[0]===a[0]&&o[1]===a[1]&&o[2]===a[2]}r("")}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=i,Da=n,Va=h;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:o(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,n,r,i,o,a){const h=new Ka(i);h.m_bOGCOutput=!0;const m=e.getGeometryType()===s.enumPolygon&&1===e.getFillRule()&&!Te(r);return h.planarSimplifyImpl_(e,t,m,n,r,i,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 G,a=i.addGeometry(t),h=r.planarSimplifyNoCrackingAndCluster(e,i,a,s);o(h,"planar_simplify_no_cracking_and_cluster");return i.getGeometry(a)}function qa(e,t,s,n,r,i,a){return o(0),{}}function Ba(e,t,s,n){return o(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 i=new C;e.queryEnvelope(i);const o=new C;t.queryEnvelope(o);const a=new C;a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const h=de(n,a,!0),m=o.clone(),l=ye(h);if(m.inflateCoords(l,l),!i.isIntersecting(m))return $a(eh(e),e,t,"-");const g=new Ka(r),u=new G,c=u.addGeometry(eh(e)),_=u.addGeometry(eh(t));let d=0,p=0,f=null;if(u.hasCurves()){f=new fa;const e=u.getEnvelope2D(r);p=da(h.total());const t=_a(h.total(),e);d=pa(t,p),aa(u,t,h.total(),12e3,f,null,r)}g.setEditShapeCrackAndCluster(u,h.add(d));const x=g.difference(c,_);null!==f&&f.stitchCurves(u,x,p,!0);const y=$a(u.getGeometry(x),e,t,"-");return Ga(y.getGeometryType())&&(y.getImpl().setIsSimple(4,h.total()),y.getGeometryType()===s.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}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 i=new C;e.queryEnvelope(i);const o=new C;t.queryEnvelope(o);const a=new C;a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const h=de(n,a,!0),m=new Ka(r),l=new G,g=l.addGeometry(eh(e)),u=l.addGeometry(eh(t));let c=0,_=null;if(l.hasCurves()){_=new fa;const e=l.getEnvelope2D(r);c=da(h.total());aa(l,_a(h.total(),e),h.total(),12e3,_,null,r)}m.setEditShapeCrackAndCluster(l,h);const d=m.symmetricDifference(g,u);null!==_&&_.stitchCurves(l,d,c,!0);const p=$a(l.getGeometry(d),e,t,"^");return Ga(p.getGeometryType())&&(p.getImpl().setIsSimple(4,h.total()),p.getGeometryType()===s.enumPolygon&&p.getImpl().updateOGCFlagsProtected()),p}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 fe({copy:Ea(e,t)}):e.createInstance()}function za(e,t,n,r){const i=C.constructEmpty();e.queryEnvelope(i);const o=C.constructEmpty();t.queryEnvelope(o);const a=C.constructEmpty();a.setCoords({env2D:i}),a.mergeEnvelope2D(o);const h=de(n,a,!0),m=new C(o),l=ye(h);if(m.inflateCoords(l,l),!i.isIntersecting(m)){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 g=new Ka(r),u=new G,c=u.addGeometry(eh(e)),_=u.addGeometry(eh(t));let d=0,p=0,f=null;if(u.hasCurves()){f=new fa;const e=u.getEnvelope2D(r);p=da(h.total());const t=_a(h.total(),e);d=pa(t,p),aa(u,t,h.total(),12e3,f,null,r)}g.setEditShapeCrackAndCluster(u,h.add(d));const x=g.intersection(c,_);null!==f&&f.stitchCurves(u,x,p,!0);const y=$a(u.getGeometry(x),e,t,"&");return Ga(y.getGeometryType())&&(y.getImpl().setIsSimple(4,h.total()),y.getGeometryType()===s.enumPolygon&&y.getImpl().updateOGCFlagsProtected()),y}function Wa(e,t,n,r){const i=new Array(3),o=C.constructEmpty();e.queryEnvelope(o);const a=C.constructEmpty();t.queryEnvelope(a);const h=C.constructEmpty();h.setCoords({env2D:o}),h.mergeEnvelope2D(a);const m=de(n,h,!0),l=new C(a),g=ye(m);if(l.inflateCoords(g,g),!o.isIntersecting(l)){if(e.getDimension()<=t.getDimension()){const s=$a(eh(e.createInstance()),e,t,"&");return i[s.getDimension()]=s,i}if(e.getDimension()>t.getDimension()){const s=$a(eh(t.createInstance()),e,t,"&");return i[s.getDimension()]=s,i}}const u=new Ka(r),c=new G,_=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)),c.dbgVerifyCurves();const y=u.intersectionEx(_,d);for(const P of y){null!==x&&x.stitchCurves(c,P,f,!1);const n=$a(c.getGeometry(P),e,t,"&");Ga(n.getGeometryType())&&(n.getImpl().setIsSimple(4,m.total()),n.getGeometryType()===s.enumPolygon&&n.getImpl().updateOGCFlagsProtected()),i[n.getDimension()]=n}return null!==x&&x.clearStitcher(c),i}function ja(t,s,n,r,i,o=!1){0===s&&e("not enough geometries to dissolve");let a=0;for(let e=0,d=s;e<d;e++)a=Math.max(t[e].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!1,t,s,n,i,o);let h=0,m=-1;for(let e=0,d=s;e<d;e++)t[e].getDimension()===a&&(-1===m&&(m=e),t[e].isEmpty()||(m=e,h++));if(h<2)return eh(t[m]);const l=Ge.constructEmpty(),g=new G;let u=M;for(let e=0,d=s;e<d;e++)if(t[e].getDimension()===a&&!t[e].isEmpty()){u===M?u=g.addGeometry(eh(t[e])):g.appendGeometry(u,eh(t[e]));const s=Ge.constructEmpty();t[e].queryLooseEnvelope(s),l.mergeEnv3D(s)}const c=de(n,l.getEnvelope2D(),!0),_=new Ka(r);if(o){const e=De(n,l.getEnvelopeZs(),!0);return _.planarSimplify3DImpl_(g,c,e,0,!0)}return _.m_bOGCOutput=!0,_.planarSimplifyMultiPoints(g,c,!1,-1)}function Za(t,s,n,r,i,o=!1){s<2&&e("not enough geometries to dissolve");let a=0;for(let e=0,p=s;e<p;e++)a=Math.max(t[e].getDimension(),a);if(2===a||1===a)return new Ka(r).dissolveMultiPaths_(a,!0,t,s,n,i,o);const h=Ge.constructEmpty(),m=new G;let l=M,g=0,u=-1;for(let e=0,p=s;e<p;e++)if(t[e].getDimension()===a&&(-1===u&&(u=e),!t[e].isEmpty())){u=e,l===M?l=m.addGeometry(eh(t[e])):m.appendGeometry(l,eh(t[e]));const s=Ge.constructEmpty();t[e].queryLooseEnvelope(s),h.mergeEnv3D(s),g++}if(g<2)return eh(t[u]);const c=0===a?n:null,_=de(c,h.getEnvelope2D(),!0),d=new Ka(r);if(o){const e=De(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=Qe.getNAN(),this.m_dummyPt2=Qe.getNAN(),this.m_fromEdgeForPolylines=M,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!==M;h=this.m_topoGraph.getChainNextInParent(h))this.m_topoGraph.setChainUserIndex(h,i,1);const a=[];for(let h=this.m_topoGraph.getFirstChain();h!==M;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!==M;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,M,h,M);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!==M;l=this.m_topoGraph.getChainNextInParent(l))this.m_topoGraph.setChainUserIndex(l,a,1);const m=[];for(let l=this.m_topoGraph.getFirstChain();l!==M;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!==M;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,M,l,M);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 n=e.getFirstGeometry();n!==M;n=e.getNextGeometry(n))e.getGeometryType(n)===s.enumPolygon&&er(e,n,-1,this.m_bOGCOutput,M,this.m_progressTracker);this.setEditShape(e)}setHalfEdgeOrientations_(e,t){const s=this.m_topoGraph.getShape();for(let n=s.getFirstGeometry();n!==M;n=s.getNextGeometry(n))if(n===t)for(let t=s.getFirstPath(n);t!==M;t=s.getNextPath(t)){let n=s.getFirstVertex(t);if(n===M)continue;let r=s.getNextVertex(n);for(;r!==M;){const t=this.m_topoGraph.getClusterFromVertex(n),i=this.m_topoGraph.getClusterFromVertex(r),o=this.m_topoGraph.getHalfEdgeConnector(t,i);if(o!==M){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 F,i=s.insertPath(e,M);t.push(t[0]);const o=t.length;let a=M;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,n,r){const i=this.m_topoGraph.getGeometryID(n),o=this.m_topoGraph.getGeometryID(r),a=[],h=this.m_topoGraph.getShape(),m=this.m_topoGraph.createUserIndexForHalfEdges();for(let l=this.m_topoGraph.getFirstCluster();l!==M;l=this.m_topoGraph.getNextCluster(l)){const n=this.m_topoGraph.getClusterHalfEdge(l);if(n===M)continue;let r=n;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(r,m)){let n=r,l=r,g=!1,u=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(n,m,1),!g){if(0!==(this.m_topoGraph.getHalfEdgeParentage(n)&o)){0!==(this.m_topoGraph.getHalfEdgeFaceParentage(n)&i)&&(l=n,g=!0)}}if(g){const t=this.m_topoGraph.getHalfEdgeOrigin(n),s=this.m_topoGraph.getClusterVertexIterator(t),r=this.m_topoGraph.getVertexFromVertexIterator(s);if(a.push(r),-1!==e){if(0!==(this.m_topoGraph.getHalfEdgeParentage(n)&o)){u|=this.m_topoGraph.getHalfEdgeUserIndex(n,e)}}}n=this.m_topoGraph.getHalfEdgeNext(n)}while(n!==l);if(g&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(l))>0){const e=h.createGeometry(s.enumPolygon);this.flushVertices_(e,a),-1!==t&&h.setGeometryUserIndex(e,t,u)}a.length=0}r=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(r))}while(r!==n)}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!==M;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,i){const o=this.m_topoGraph.getShape().getGeometryType(s),a=this.m_topoGraph.getShape().getGeometryType(n),m=h(o),l=h(a);if(2!==m||1!==l){if(1===m&&1===l){return void new sh(this,e,t,s,n,i).Do()}r("")}else this.cutPolygonPolyline_(t,s,n,i)}progress_(e=!1){}isGoodParentage(e){return e>=0&&e<this.m_maskLookup.length&&this.m_maskLookup[e]}normalizeInputGeometry(t){const r=t.getGeometryType();if(r===s.enumEnvelope){const e=new v({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(r===s.enumPoint){const e=new N({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(n(r)){const e=new I({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return r!==s.enumMultiPoint&&r!==s.enumPolyline&&r!==s.enumPolygon&&e("Unexpected geometry type"),t}dissolveNonSimplePolygons(e,t,s,n){o(t>0);const r=new G;let i=0,a=-1;for(let o=0,h=t;o<h;o++)2===e[o].getDimension()&&(-1===a&&(a=o),e[o].isEmpty()||(i++,r.addGeometry(e[o])));return 0===i?(o(a>=0),this.normalizeInputGeometry(e[a])):this.planarSimplifyPolygons(r,s,!0,!1,-1,!0)}dissolveMultiPaths_(e,t,r,a,h,l,g){o(e>=1&&e<=2),o(a>0);const u=8&l?1:2,c=Ge.constructEmpty();let _=0,d=-1,p=!0;for(let n=0,i=a;n<i;n++)if(r[n].getDimension()===e&&(-1===d&&(d=n),!r[n].isEmpty())){d=n,_++;const t=Ge.constructEmpty();if(r[n].queryLooseEnvelope(t),c.mergeEnv3D(t),2===e&&p&&r[n].getGeometryType()===s.enumPolygon)if(16&l){const e=[0],t=r[n].getImpl().getIsSimple(0,e),s=this.m_bOGCOutput?5===t:ce(t);p&&=s}else{const e=Ue(r[n],0);p&&=e}}if(_<2&&(o(d>=0),0===_||!(16&l)))return this.normalizeInputGeometry(r[d]);if(!p){const e=de(t?null:h,c.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(r,a,e,l)}const f=r.slice(0,a),x=de(h,c.getEnvelope2D(),!0),y=10*ye(x);let P=new xe(0,0);if(g&&(P=De(h,c.getEnvelopeZs(),!0)),1===_&&1===e&&2===u&&!t)return g?qa():this.m_bOGCOutput?Aa(f[d],x,!1,-1,this.m_progressTracker,u,!1):Ma(f[d],x,!1,!1,-1,this.m_progressTracker,u,!1);const E=new qe;E.startConstruction();let S=2===e?3:4,b=0;for(let m=0,I=a;m<I;m++){if(f[m].getDimension()!==e||f[m].isEmpty())continue;let r=f[m].getGeometryType();if(r!==s.enumEnvelope){if(n(r)?(f[m]=this.normalizeInputGeometry(f[m]),r=s.enumPolyline):o(i(r)),1===e){o(r===s.enumPolyline);let e=-1;if(g)o(0,"3d not implemented yet");else{const t=[0];e=f[m].getImpl().getIsSimple(x.total(),t)}if(this.m_bOGCOutput?5!==e:!ce(e))if(t)S=-1;else{g?o(0,"3d not implemented yet"):this.m_bOGCOutput?f[m]=Aa(f[m],x,!1,-1,this.m_progressTracker,u,!1):f[m]=Ma(f[m],x,!1,!1,-1,this.m_progressTracker,u,!1);const e=[0];o(ce(f[m].getImpl().getIsSimple(x.total(),e)))}}else{o(r===s.enumPolygon);const e=[0],t=f[m].getImpl().getIsSimple(0,e);o(Te(t))}const a=f[m].getImpl();for(let e=0,t=a.getPathCount();e<t;e++){const t=C.constructEmpty();a.queryLoosePathEnvelope(e,t),t.inflateCoords(y,y),E.addEnvelope(b,t),b++}}else{o(r===s.enumEnvelope);const e=C.constructEmpty();f[m].queryLooseEnvelope(e),e.inflateCoords(y,y),E.addEnvelope(b,e),b++,S=-1}}E.endConstruction();const w=b,N=Ke(w,-2147483647),T=Ke(w,-1);let D=0;d=-1,b=0;for(let n=0,m=a;n<m;n++){if(f[n].getDimension()!==e)continue;if(-1===d&&(d=n),f[n].isEmpty())continue;d=n,D++;const t=f[n].getGeometryType();if(i(t)){for(let e=0,t=f[n].getPathCount();e<t;e++)T[b]=n,N[b]=-e-1,b++}else o(t===s.enumEnvelope),T[b]=n,N[b]=-1,b++}if(D<2&&2===e)return o(d>=0),this.normalizeInputGeometry(f[d]);let V=w;for(;E.next()&&V>0;){this.progress_();const e=E.getHandleA(),t=E.getHandleB(),s=E.getElement(e),n=E.getElement(t);T[s]!==T[n]&&(N[s]<0&&(V--,N[s]=-(N[s]+1)),N[n]<0&&(V--,N[n]=-(N[n]+1)))}const F=new G;let H=!1,k=0;for(let n=0,C=a;n<C;n++){if(f[n].getDimension()!==e||f[n].isEmpty())continue;const t=f[n].getGeometryType(),r=k;let a=0,h=0;const l=i(t)?f[n]:null;for(let e=r,s=N.length;e<s&&T[e]===n;e++)N[e]>=0&&(a++,h+=l?l.getPathSize(N[e]):m(f[n])),k++;if(h>.95*m(f[n])){F.addGeometry(this.normalizeInputGeometry(f[n]));for(let e=r;e<k;e++)N[e]<0&&(N[e]=-(N[e]+1))}else{if(0===a){H=!0;continue}{H=!0,o(i(t)),o(null!=l);const e=new v({vd:f[n].getDescription()}),a=new I({vd:f[n].getDescription()}),h=t===s.enumPolygon?e:a;for(let t=r;t<k;t++)N[t]>=0&&h.addPath(l,N[t],!0);F.addGeometry(h)}}}let A;if(F.getFirstGeometry()!==M){const s=2===e,n=t?de(null,c.getEnvelope2D(),!0):x;let r=new xe(0,0);if(g&&(r=t?De(null,c.getEnvelopeZs(),!0):P),2===e&&!(2&l)){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,M,e,!0)}if(g)A=this.planarSimplify3DImpl_(F,n,r,u,!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=u,A=this.planarSimplifyPolylines(F,n,t,e,-1)}if(!H){const e=[0];S=A.getImpl().getIsSimple(n.total(),e)}}else o(H),o(d>=0),A=2===e?new v({vd:f[d].getDescription()}):new I({vd:f[d].getDescription()});if(H){let e=0;for(let t=0,s=N.length;t<s;t++){const s=T[t];if(!(s<0)&&N[t]<0){const n=f[s].getGeometryType(),r=i(n)?f[s]:null;if(r){const s=-(N[t]+1);e+=r.getPathSize(s)}else e+=4}}A.reserve(A.getPointCount()+e);for(let t=0,r=N.length;t<r;t++){const e=T[t];if(!(e<0)&&N[t]<0){const r=f[e].getGeometryType(),a=i(r)?f[e]:null;if(a){const e=-(N[t]+1);A.addPath(a,e,!0)}else r===s.enumEnvelope?A.addEnvelope(f[e],!1):(o(n(r)),A.addSegment(f[e],!0))}}}let U=0;if(2===e?-1!==S&&(S=3,U=t?0:x.total()):(o(1===e),t||-1===S||(U=x.total())),g||A.getImpl().setIsSimple(S,U),!t&&H)if(2===e){if(!g)return(new Eh).execute(A,h,!1,this.m_progressTracker);o(0,"3d not yet implemented")}else 1===e&&1!==u&&(A=g?Ba():Ua(this.m_bOGCOutput,A,u,this.m_progressTracker),A.getImpl().setIsSimple(S,U));return A}dissolveTopoGraphCommonEdges_(){const e=this.m_topoGraph.createUserIndexForHalfEdges(),t=[];for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const n=this.m_topoGraph.getClusterHalfEdge(s);let r=n;if(n!==M)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=bt(),i=M;for(let o=this.m_topoGraph.getClusterVertexIterator(e);o!==M;o=this.m_topoGraph.incrementVertexIterator(o)){const e=this.m_topoGraph.getVertexFromVertexIterator(o),n=t.getUserIndex(e,s);n>=0&&n<r&&(r=n,i=e)}o(i!==M);let a=t.getUserIndex(i,n);return a>0&&(t.setUserIndex(i,n,--a),0===a&&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,n,r,i){const o=this.m_topoGraph.getShape();if(o.getGeometryType(e)!==s.enumPolygon)return;const a=o.hasSegmentParentage(),h=new F;for(let s=o.getFirstPath(e);s!==M;s=o.getNextPath(s)){const e=o.getFirstVertex(s);this.m_topoGraph.getClusterFromVertex(e);const m=this.m_topoGraph.getHalfEdgeFromVertex(e);if(m===M)continue;const l=this.m_topoGraph.getHalfEdgeUserIndex(m,n);if(1===l||2===l)continue;const g=this.m_topoGraph.getHalfEdgeFaceParentage(m);if(!this.isGoodParentage(g)){this.m_topoGraph.setHalfEdgeUserIndex(m,n,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(m,n,1);const u=o.insertPath(t,M);o.setClosedPath(u,!0);let c=m,_=e,d=this.m_topoGraph.getClusterFromVertex(_),p=1;do{this.progress_();const e=this.chooseVertexFromVertexCluster_(_,i),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 s,m;-1!==r&&this.m_topoGraph.setClusterUserIndex(d,r,1),this.m_topoGraph.setHalfEdgeUserIndex(c,n,1),c=this.m_topoGraph.getHalfEdgeNext(c);do{s=1===p?o.getNextVertex(_):o.getPrevVertex(_),m=s!==M?this.m_topoGraph.getClusterFromVertex(s):M}while(m===d);const l=this.m_topoGraph.getHalfEdgeOrigin(c);if(l!==m){do{s=1===p?o.getPrevVertex(_):o.getNextVertex(_),m=s!==M?this.m_topoGraph.getClusterFromVertex(s):M}while(m===d);if(l!==m){m=l;const e=this.m_topoGraph.getClusterVertexIterator(m);s=this.m_topoGraph.getVertexFromVertexIterator(e)}else p=-p}d=m,_=s}while(c!==m)}}topoOperationPolygonPolygonHelper_(e,t,s,n,r,i){this.progress_(!0),e!==M&&this.collectPolygonPathsPreservingFrom_(e,s,r,i,n),t!==M&&this.collectPolygonPathsPreservingFrom_(t,s,r,i,n);const o=new F,a=this.m_topoGraph.getShape();a.dbgVerifyCurves();const h=a.hasSegmentParentage();for(let m=this.m_topoGraph.getFirstCluster();m!==M;m=this.m_topoGraph.getNextCluster(m)){const e=this.m_topoGraph.getClusterHalfEdge(m);if(e===M)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,M);a.setClosedPath(e,!0);let m=t;do{const t=this.m_topoGraph.getHalfEdgeVertexIterator(m);let s=M;if(t!==M)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,n,r=!1){this.dissolveTopoGraphCommonEdges_();const i=this.m_topoGraph.getShape(),o=i.createGeometry(s.enumPolygon),a=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(e,t,o,n,a,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(a),r||er(i,o,3,this.m_bOGCOutput,M,this.m_progressTracker),o}topoOperationPolyline_(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(M,e,!1,s).first}topoOperationMultiPoint_(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(s.enumMultiPoint),n=e.insertPath(t,M);for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const t=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(t)){let t=M;for(let n=this.m_topoGraph.getClusterVertexIterator(s);n!==M;n=this.m_topoGraph.incrementVertexIterator(n)){const s=this.m_topoGraph.getVertexFromVertexIterator(n);t===M&&(t=s);const r=e.getGeometryFromPath(e.getPathFromVertex(s)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=s;break}}e.addVertex(n,t)}}return t}intersection(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=h(s),a=h(n),m=this.m_topoGraph.getGeometryID(e),l=this.m_topoGraph.getGeometryID(t);o(m>=0),o(l>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(m|l),this.m_maskLookup[m|l]=!0;let g=M;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(g=e),2===i&&2===a?this.topoOperationPolygonPolygon_(e,t,g):1===i&&a>0||1===a&&i>0?this.topoOperationPolyline_(g,this.m_bOGCOutput):0===i||0===a?this.topoOperationMultiPoint_():void r("")}topoOperationPolygonPolygonEx(e,t,n){const r=this.m_topoGraph.getShape(),i=r.createGeometry(s.enumPolygon),o=r.createGeometry(s.enumPolyline),a=r.createGeometry(s.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let h=M;const m=this.m_topoGraph.createUserIndexForHalfEdges(),l=this.m_topoGraph.createUserIndexForClusters();r.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(e,t,i,n,m,l),r.dbgVerifyCurves();const g=r.hasSegmentParentage(),u=new F;for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const e=this.m_topoGraph.getClusterHalfEdge(s);if(e===M)continue;let t=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(t,m),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(t),m),a=e|i;if(2===a){let h=this.m_topoGraph.getHalfEdgeParentage(t);if(this.isGoodParentage(h)){const c=r.insertPath(o,M);let _=t;const d=this.chooseVertexFromCluster_(s,n);let p=r.addVertex(c,d);if(g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);r.setSegmentParentageAndBreak(p,e,this.m_topoGraph.isBreakNode(s))}this.m_topoGraph.isHalfEdgeCurve(t)&&(this.m_topoGraph.querySegmentXY(t,u),r.setSegmentToIndex(r.getVertexIndex(p),u.get().clone())),this.m_topoGraph.setClusterUserIndex(s,l,1);do{this.progress_();const s=this.m_topoGraph.getHalfEdgeTo(_),o=this.chooseVertexFromCluster_(s,n);if(p=r.addVertex(c,o),g){const e=this.m_topoGraph.getSegmentParentage(t),s=this.m_topoGraph.getHalfEdgeOrigin(t);r.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(s,l,1),_=this.m_topoGraph.getHalfEdgeNext(_),e=this.m_topoGraph.getHalfEdgeUserIndex(_,m),i=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(_),m),a=e|i,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),r.setSegmentToIndex(r.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 s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){this.progress_();if(1===this.m_topoGraph.getClusterUserIndex(s,l))continue;const e=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(e)){h===M&&(h=r.insertPath(a,M));const e=this.m_topoGraph.getClusterVertexIterator(s);let t=M;if(e!==M){t=this.m_topoGraph.getVertexFromVertexIterator(e);const s=this.chooseVertexFromVertexCluster_(t,n);r.addVertex(h,s)}}}this.m_topoGraph.deleteUserIndexForClusters(l),this.m_topoGraph.deleteUserIndexForHalfEdges(m),r.dbgVerifyCurves(),er(r,i,3,this.m_bOGCOutput,M,this.m_progressTracker);const c=[M,M,M];return c[0]=a,c[1]=o,c[2]=i,c}topoOperationPolylinePolylineOrPolygonEx(e,t){const s=Ha();return s.allCrossRoadsImpassable=!1,s.ogcRule=t,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(M,e,!0,s)}topoOperationMultiPoint(){const e=this.m_topoGraph.getShape(),t=e.createGeometry(s.enumMultiPoint),n=e.insertPath(t,M);for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){const t=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(t)){let t=M;for(let n=this.m_topoGraph.getClusterVertexIterator(s);n!==M;n=this.m_topoGraph.incrementVertexIterator(n)){const s=this.m_topoGraph.getVertexFromVertexIterator(n);t===M&&(t=s);const r=e.getGeometryFromPath(e.getPathFromVertex(s)),i=this.m_topoGraph.getGeometryID(r);if(this.isGoodParentage(i)){t=s;break}}e.addVertex(n,t)}}return t}intersectionEx(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=Va(s),a=Va(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);o(h>=0),o(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h|m]=!0;let l=M;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=e),2===i&&2===a)return this.topoOperationPolygonPolygonEx(e,t,l);if(1===i&&a>0||1===a&&i>0){const{first:e,second:t}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[t,e]}if(0===i||0===a){const e=[];return e.push(this.topoOperationMultiPoint()),e}r("")}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!==M;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!==M&&this.m_topoGraph.getClusterFromVertex(c)===r){if(i++,u){if(this.m_fromEdgeForPolylines===M&&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!==M&&this.m_topoGraph.getClusterFromVertex(s)===r&&(i--,u)){if(this.m_fromEdgeForPolylines===M&&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)*Qe.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 M;const t=this.m_topoGraph.getHalfEdgeTwin(e);if(n===this.m_topoGraph.getHalfEdgeNext(t))return s}let r=n,i=M;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==M)return M;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 M;if(n===this.m_topoGraph.getHalfEdgePrev(t))return s}let r=n,i=M;for(;r!==e;){const e=this.getCombinedHalfEdgeParentage(r);if(this.isGoodParentage(e)){if(i!==M)return M;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}r("is_on_a_loop_")}restorePolylineParts(e,t,s,n,r,i,a,h,m,l){o(r===M&&i>=0&&a>=0||-1===i&&-1===a),o(-1===h&&1!==l.unsplitBehavior||-1!==h&&1===l.unsplitBehavior);const g=l.ogcRule,u=l.allCrossRoadsImpassable,c=1===l.unsplitBehavior,_=0===l.unsplitBehavior,d=this.m_topoGraph.getShape(),p=d.hasSegmentParentage();let f=e,x=this.m_topoGraph.getHalfEdgeTwin(f);const y=new F;this.m_fromEdgeForPolylines=M;let P=this.prevailingDirection(d,f),E=f,S=M,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===M){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===M){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!==h){const e=this.m_topoGraph.getHalfEdgeOrigin(x);if(1===this.m_topoGraph.getClusterUserIndex(e,h)){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===M){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!==M){E=e,S=this.tryMoveThroughCrossroadBackwards(E,!1),o(S!==M);const t=this.m_topoGraph.getHalfEdgeTwin(E);this.m_topoGraph.getHalfEdgeNext(t)}let w=I;I||b||m&&(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&&(o(!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=rt(E,E=S),S=this.m_topoGraph.getHalfEdgeTwin(S),E=this.m_topoGraph.getHalfEdgeTwin(E));let G=d.insertPath(t,M);f=E;const D=this.m_topoGraph.getHalfEdgeOrigin(E);let V;V=-1!==i?this.chooseVertexByOrder(D,d,i,a):this.chooseVertexFromCluster_(D,r),this.m_topoGraph.isStrongPathNode(D)&&d.setStrongPathStart(G,!0);let H=d.addVertex(G,V),k=H;-1!==n&&this.m_topoGraph.setClusterUserIndex(D,n,1);let A=0;const U=N?Math.trunc((T+1)/2):-1;let q=M,B=!0,O=M;for(;;){if(p){const e=this.m_topoGraph.getSegmentParentage(f),t=this.m_topoGraph.getHalfEdgeOrigin(f);d.setSegmentParentageAndBreak(k,e,B||this.m_topoGraph.isBreakNode(t))}B=!1,this.m_topoGraph.isHalfEdgeCurve(f)&&(this.m_topoGraph.querySegmentXY(f,y),d.setSegmentToIndex(d.getVertexIndex(k),y.get().clone())),q!==M&&-1!==a&&d.addToUserIndex(q,a,-1);const e=u?this.m_topoGraph.getHalfEdgeNext(f):this.tryMoveThroughCrossroadForward(f,!1),s=this.m_topoGraph.getHalfEdgeTo(f);let o;if(o=-1!==i?this.chooseVertexByOrder(s,d,i,a):this.chooseVertexFromCluster_(s,r),H=d.addVertex(G,o),O=s,-1!==n&&this.m_topoGraph.setClusterUserIndex(s,n,1),p&&this.m_topoGraph.isBreakNode(s)&&d.setSegmentParentageBreakVertex(H,!0),q=o,A++,N&&A===U&&(G=d.insertPath(t,M),H=d.addVertex(G,o),B=!0,-1!==a&&d.addToUserIndex(o,a,-1),q=M),f===S)break;f=e,k=H}O!==M&&this.m_topoGraph.isStrongPathNode(O)&&d.setStrongPathEnd(G,!0)}topoOperationPolylineSimplify_(e,t){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,M,!1,t).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,t,n,r){o(t===M||e===M);const i=this.m_topoGraph.getShape(),a=t=>t=e===M?t===M?i.getFirstGeometry():i.getNextGeometry(t):t===M?e:M,h=i.createGeometry(s.enumPolyline);let m=-1;n&&(m=this.m_topoGraph.createUserIndexForClusters());const l=this.m_topoGraph.createUserIndexForHalfEdges(),g=t===M?i.createUserIndex():-1,u=t===M?i.createUserIndex():-1;let c=-1;if(1===r.unsplitBehavior){c=this.m_topoGraph.createUserIndexForClusters();for(let e=a(M);e!==M;e=a(e))for(let t=i.getFirstPath(e);t!==M;t=i.getNextPath(t)){{const e=i.getFirstVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}if(!i.isClosedPath(t)){const e=i.getLastVertex(t),s=this.m_topoGraph.getClusterFromVertex(e);this.m_topoGraph.setClusterUserIndex(s,c,1)}}}if(t===M){let e=0;for(let t=a(M);t!==M;t=a(t))for(let s=i.getFirstPath(t);s!==M;s=i.getNextPath(s)){if(i.isClosedPath(s)){let t=i.getFirstVertex(s);for(let n=0,r=i.getPathSize(s);n<r;n++,t=i.getNextVertex(t))i.setUserIndex(t,g,e++),i.setUserIndex(t,u,2)}else{const t=i.getFirstVertex(s);i.setUserIndex(t,g,e++),i.setUserIndex(t,u,1);let n=i.getNextVertex(t);for(let r=1,o=i.getPathSize(s)-1;r<o;++r)i.setUserIndex(n,g,e++),i.setUserIndex(n,u,2),n=i.getNextVertex(n);i.setUserIndex(n,g,e++),i.setUserIndex(n,u,1)}}}for(let s=a(M);s!==M;s=a(s))for(let e=i.getFirstPath(s);e!==M;e=i.getNextPath(e)){let s=i.getFirstVertex(e);for(let n=0,o=i.getPathSize(e);n<o;n++,s=i.getNextVertex(s)){const e=this.m_topoGraph.getHalfEdgeFromVertex(s);if(e===M)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(e,l))continue;const i=this.getCombinedHalfEdgeParentage(e);if(this.isGoodParentage(i)){const s=0===n;this.restorePolylineParts(e,h,l,m,t,g,u,c,s,r)}}}let _=M;if(n){_=i.createGeometry(s.enumMultiPoint);let e=M;for(let s=this.m_topoGraph.getFirstCluster();s!==M;s=this.m_topoGraph.getNextCluster(s)){this.progress_();if(1!==this.m_topoGraph.getClusterUserIndex(s,m)){const n=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(n)){e===M&&(e=i.insertPath(_,M));const n=this.m_topoGraph.getClusterVertexIterator(s);if(n!==M){let r;this.m_topoGraph.getVertexFromVertexIterator(n),r=-1!==g?this.chooseVertexByOrder(s,i,g,u):this.chooseVertexFromCluster_(s,t),i.addVertex(e,r)}}}}}return-1!==u&&i.removeUserIndex(u),-1!==g&&i.removeUserIndex(g),-1!==m&&i.removeUserIndex(m),this.m_topoGraph.deleteUserIndexForHalfEdges(l),mt(h,_)}difference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=h(s),o=h(n);if(i>o)return e;const a=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(a|m),this.m_maskLookup[a]=!0,2===i&&2===o){let s=M;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=e),this.topoOperationPolygonPolygon_(e,t,s)}if(1===i&&2===o){const t=Ha();return t.allCrossRoadsImpassable=!1,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,M,!1,t).first}if(1===i&&1===o){const t=Ha();return t.allCrossRoadsImpassable=!0,t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(e,M,!1,t).first}if(0===i)return this.topoOperationMultiPoint_();r("")}symmetricDifference(e,t){const s=this.m_topoGraph.getShape().getGeometryType(e),n=this.m_topoGraph.getShape().getGeometryType(t),i=Va(s),a=Va(n),h=this.m_topoGraph.getGeometryID(e),m=this.m_topoGraph.getGeometryID(t);return o(h>=0),o(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(h|m),this.m_maskLookup[h]=!0,this.m_maskLookup[h]=!0,this.m_maskLookup[m]=!0,2===i&&2===a?this.topoOperationPolygonPolygon_(e,t,M):1===i&&1===a?this.topoOperationPolyline_(M,this.m_bOGCOutput):0===i&&0===a?this.topoOperationMultiPoint():void r("")}planarSimplifyNoCrackingAndCluster(e,t,n,i){this.m_bOGCOutput=e,this.m_topoGraph=new tn;const a=t.getFillRule(n),h=t.getGeometryType(n);if(1!==a||h===s.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,n,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(t,n,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const m=this.m_topoGraph.getGeometryID(n);if(o(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=m+1,this.m_maskLookup[m]=!0,t.getGeometryType(n)===s.enumPolygon||1===a&&t.getGeometryType(n)!==s.enumMultiPoint){t.setFillRule(n,0);const s=this.topoOperationPolygonPolygon_(n,M,M);if(t.swapGeometry(s,n),t.removeGeometry(s),1===a&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(e,t,n,i)}else if(t.getGeometryType(n)===s.enumPolyline){const e=Ha();e.ogcRule=this.m_bOGCOutput,e.allCrossRoadsImpassable=!0,e.unsplitBehavior=i;const s=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),e);t.swapGeometry(s,n),t.removeGeometry(s)}else if(t.getGeometryType(n)===s.enumMultiPoint){const e=this.topoOperationMultiPoint_();t.swapGeometry(e,n),t.removeGeometry(e)}else r("");return!0}unsplitPolylineExact(e){return o(0),new I}planarSimplifyPolylines(e,t,n,r,i){for(let _=e.getFirstGeometry();_!==M;_=e.getNextGeometry(_)){const t=e.getGeometryType(_);o(t===s.enumPolyline)}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)}{const s=Ia(t.add(a));e.filterClosePoints(s,!1,!1,!1,M)}if(this.m_topoGraph=new tn,4!==i&&5!==i)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;else n=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const l=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,l,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return o(n&&null===m),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(e,t,!1,r,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(l);o(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0;const u=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),r);null!==m&&m.stitchCurves(e,u,h,!0);const c=e.getGeometry(u);return n||c.getImpl().setIsSimple(4,t.total()),c}planarSimplifyMultiPoints(e,t,n,r){for(let l=e.getFirstGeometry();l!==M;l=e.getNextGeometry(l)){const t=e.getGeometryType(l);o(t===s.enumMultiPoint)}this.m_topoGraph=new tn,4!==r&&5!==r?(ya(e,t,this.m_progressTracker,!0,!1),n=!1):n=!1,e.removeSelection(),e.collapseAllGeometriesToFirst();const i=e.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,i,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return o(n),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(e,t,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const a=this.m_topoGraph.getGeometryID(i);o(a>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=a+1,this.m_maskLookup[a]=!0;const h=this.topoOperationMultiPoint(),m=e.getGeometry(h);return n||m.getImpl().setIsSimple(4,t.total()),m}planarSimplifyPolygons(e,t,n,r,i,a){for(let f=e.getFirstGeometry();f!==M;f=e.getNextGeometry(f)){const t=e.getGeometryType(f);o(t===s.enumPolygon||t===s.enumPolyline&&n)}let h=0,m=0,l=null;if(e.hasCurves()&&!e.hasSegmentParentage()){l=new fa;const s=e.getEnvelope2D(this.m_progressTracker);m=da(t.total());const n=_a(t.total(),s);h=pa(n,m),aa(e,n,t.total(),12e3,l,null,this.m_progressTracker)}if(a){ya(e,t.add(h),this.m_progressTracker,!0,!1);for(let t=e.getFirstGeometry();t!==M;t=e.getNextGeometry(t))e.getGeometryType(t)===s.enumPolygon&&er(e,t,-1,!1,M,this.m_progressTracker)}if(this.m_topoGraph=new tn,a||4===i||5===i)r=!1;else if(null===l&&r){const s=new Dn(this.m_progressTracker,!1);s.sweepVertical(e,t.total()),s.hadComplications()?(ya(e,t,this.m_progressTracker,!0,!1),r=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(t.total())}else ya(e,t.add(h),this.m_progressTracker,!0,!1),r=!1;e.removeSelection(),e.collapseAllGeometriesToFirst();const g=e.getFirstGeometry();if(n?this.m_topoGraph.setAndSimplifyEditShapeWinding(e,g,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,g,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return o(r&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(e,t,n,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const u=this.m_topoGraph.getGeometryID(g);o(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&&n,_=c;let d=this.topoOperationPolygonPolygon_(g,M,M,_);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,M,M,!1)}null!==l&&l.stitchCurves(e,d,m,!0);const p=e.getGeometry(d);return p.setFillRule(0),r?p.getImpl().setIsSimple(3,0):(p.getImpl().setIsSimple(4,t.total()),p.getImpl().updateOGCFlagsProtected()),p}planarSimplify3DImpl_(e,t,s,n,r){return o(0),{}}planarSimplifyImpl_(e,t,n,i,o,a,h,m){if(e.isEmpty())return e.clone();const l=e.getGeometryType(),g=new G,u=g.addGeometry(e);if(Te(o)&&l===s.enumPolygon&&(n=!1,g.setFillRule(u,0)),m&&(e.hasAttribute(1)&&g.replaceNaNs(1,0),g.removeNaNVertices()),l===s.enumPolygon||l===s.enumPolyline&&n)return this.planarSimplifyPolygons(g,t,n,i,o,!1);if(l===I.type){const e=Ha();return e.allCrossRoadsImpassable=!0,e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=h,this.planarSimplifyPolylines(g,t,i,e,o)}if(l===s.enumMultiPoint)return this.planarSimplifyMultiPoints(g,t,i,o);r("what else?")}}function Qa(e,t,s,n){if(e.isEmpty())return e.createInstance();if(t.isEmpty())return n?e.createInstance():new fe({copy:e});const i=[new Qe],o=[0],a=2===t.getDimension();return 1!==t.getDimension()&&2!==t.getDimension()&&r(""),i[0]=e.getXY(),a?Wo(t,i,1,s.total(),o):jo(t,i,1,s.total(),o),0===o[0]?e.createInstance():e}function Ja(e,t,s,n){const i=e.createInstance(),o=lt(Qe,100),a=new Array(100),h=e.getPointCount();let m=!0;const l=2===t.getDimension();1!==t.getDimension()&&2!==t.getDimension()&&r("");for(let r=0;r<h;){const n=e.queryCoordinates(o,o.length,r,-1)-r;l?Wo(t,o,n,s.total(),a):jo(t,o,n,s.total(),a);let h=0;for(let t=0;t<n;t++){0===a[t]&&(m&&(m=!1,i.addPoints(e,0,r)),h!==t&&i.addPoints(e,r+h,r+t),h=t+1)}m||h===n||i.addPoints(e,r+h,r+n),r+=n}return m?e:i}function $a(e,t,n,r){const i=e.getGeometryType();if(i===s.enumEnvelope){const t=new v({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(i===s.enumPoint&&("|"===r||"^"===r)){const t=new N({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}if(i===s.enumLine){const t=new I({vd:e.getDescription()});return e.isEmpty()||t.addSegment(e,!0),t}if(i===s.enumMultiPoint&&"-"===r&&t.getGeometryType()===s.enumPoint){const t=new fe({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}if(i===s.enumMultiPoint&&"&"===r&&t.getGeometryType()===s.enumPoint){const t=new fe({vd:e.getDescription()});return e.isEmpty()||e.getPointByVal(0,t),t}return e}function eh(t){const n=t.getGeometryType();if(n===s.enumEnvelope){const e=new v({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(n===s.enumPoint){const e=new N({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(Da(n)){const e=new I({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return n!==s.enumMultiPoint&&n!==s.enumPolyline&&n!==s.enumPolygon&&e("Unexpected geometry type"),t}function th(e,t,s,n){const r=s===M?e.getClusterHalfEdge(t):s;let i=r;o(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!==M;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===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===M?M: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===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(r)),a=i===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(i)),h=s===M?M:this.m_rTopoGraph.getHalfEdgeConnector(t,this.m_rTopoGraph.getClusterFromVertex(s)),m=n===M?M: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===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;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!==M){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!==M;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===M||o===M?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 s=this.m_rShape.getFirstPath(this.m_cuttee);s!==M;s=this.m_rShape.getNextPath(s)){const e=this.m_rShape.getPathSize(s);let t=this.m_rShape.getFirstVertex(s);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(s);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 s=this.m_rShape.getFirstPath(this.m_cuttee);s!==M;s=this.m_rShape.getNextPath(s)){let t=this.m_rShape.getFirstVertex(s);const n=this.m_rShape.isClosedPath(s),r=this.m_rShape.getPathSize(s)+(n?1:0);let i=1,o=32;for(let s=this.m_rShape.getNextVertex(t);i<r;++i,t=s,s=this.m_rShape.getNextVertex(s)){const n=e(t,s);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=n),32!==o&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,o|n)}t=this.m_rShape.getLastVertex(s);let a=32;i=1;for(let s=this.m_rShape.getPrevVertex(t);i<r;++i,t=s,s=this.m_rShape.getPrevVertex(s)){const n=e(s,t);this.m_rShape.getUserIndex(t,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=n),32!==a&&this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,a|n)}}let t=M,n=M,r=32;const i=this.m_rShape.hasSegmentParentage(),o=new F;for(let a=this.m_rShape.getFirstPath(this.m_cuttee);a!==M;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=M,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!==r?(t!==M&&(g=this.m_rShape.addVertex(n,l),i&&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,r)),t=this.m_rShape.createGeometry(s.enumPolyline),n=this.m_rShape.insertPath(t,M),r=e,u=!0):this.m_rShape.getUserIndex(l,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==e&&(g=this.m_rShape.addVertex(n,l),i&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(l))&&this.m_rShape.setSegmentParentageBreakVertex(g,!0),n=this.m_rShape.insertPath(t,M),u=!0),g=this.m_rShape.addVertex(n,l);const h=this.m_rTopoGraph.getClusterFromVertex(l);!u&&i&&this.m_rTopoGraph.isBreakNode(h)&&this.m_rShape.setSegmentParentageBreakVertex(g,!0);const m=this.m_rTopoGraph.getHalfEdgeFromVertex(l);if(i){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(n,l),i&&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,r),t=M,n=M,r=32}}}function nh(e,t,s){return new Ka(s).linesToPolygonsImpl(e,t)}function rh(e,t,i,o,a){if(o&&(o.m_reason=0,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),e.isEmpty())return 5;const h=e.getGeometryType();if(h===s.enumPoint)return mh(e,o);const m=me(t,e,!1).total();if(h===s.enumEnvelope){const t=e,s=new C;return t.queryEnvelope(s),s.isDegenerate(m)?(o&&(o.m_reason=4,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),0):5}if(n(h)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),oh(n,t,i,o,a)}const l=[0],g=e.getImpl().getIsSimple(m,l);let u=i?-1:g;if(ce(u)||0===u)return u;const c=new Ph(e,t,u,a,!1);h===s.enumMultiPoint||h===s.enumPolyline||h===s.enumPolygon?u=c.isSimplePlanarImpl():r("");return e.getImpl().setIsSimple(u,m),o&&o.assign(c.m_nonSimpleResult),u}function ih(e,t,i,o,a){if(o&&(o.m_reason=0,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),e.isEmpty())return 5;const h=e.getGeometryType();if(h===s.enumPoint)return mh(e,o);const m=me(t,e,!1).total();if(h===s.enumEnvelope){const t=e,s=new C;return t.queryEnvelope(s),s.isDegenerate(m)?(o&&(o.m_reason=4,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),0):5}if(n(h)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),ih(n,t,i,o,a)}p(h),_(h)||g("OGC simplify is not implemented for this geometry type");const l=[0],u=e.getImpl().getIsSimple(m,l);let c=i?-1:u;if(5===c||0===c)return c;const d=new Ph(e,t,c,a,!0);h===s.enumMultiPoint||h===s.enumPolyline||h===s.enumPolygon?(c=d.isSimplePlanarImpl(),ce(c)&&(c=5)):r("");return e.getImpl().setIsSimple(c,m),o&&o.assign(d.m_nonSimpleResult),c}function oh(e,t,i,o,a){if(o&&(o.m_reason=0,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),e.isEmpty())return 5;const h=e.getGeometryType();if(h===s.enumPoint)return mh(e,o);const m=me(t,e,!1).total();if(h===s.enumEnvelope){const t=e,s=C.constructEmpty();return t.queryEnvelope(s),s.isDegenerate(m)?(o&&(o.m_reason=4,o.m_vertexIndex1=-1,o.m_vertexIndex2=-1),0):5}if(n(h)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),oh(n,t,i,o,a)}const l=[0],g=e.getImpl().getIsSimple(m,l);let u=i?-1:g;if(-1!==u)return u;const c=new Ph(e,t,u,a,!1);return h===s.enumMultiPoint?u=c.multipointIsSimpleAsFeature():h===s.enumPolyline?u=c.polylineIsSimpleAsFeature():h===s.enumPolygon?u=c.polygonIsSimpleAsFeature():r(""),e.getImpl().setIsSimple(u,m),o&&o.assign(c.m_nonSimpleResult),u}function ah(e,t,i,o){if(e.isEmpty())return e;const a=e.getGeometryType();if(a===s.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===s.enumEnvelope){const s=me(t,e,!0).total(),n=e,r=C.constructEmpty();return n.queryEnvelope(r),r.isDegenerate(s)?n.createInstance():e}if(n(a)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),ah(n,t,i,o)}p(a);const h=me(t,e,!1).total(),m=[0],l=e.getImpl().getIsSimple(h,m),g=i?-1:l;if(ce(g)){if(a===s.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}if((a===s.enumMultiPoint||a===s.enumPolyline)&&g>=1)return e;const u=new Ph(e,t,g,o,!1);let c;return a===s.enumMultiPoint?c=u.multipointSimplifyAsFeature():a===s.enumPolyline?c=u.polylineSimplifyAsFeature():a===s.enumPolygon?c=u.polygonSimplifyAsFeature():r(""),c}function hh(e,t,r,i){if(e.isEmpty())return e;const o=e.getGeometryType();if(o===s.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(o===s.enumEnvelope){const s=e,n=new C;s.queryEnvelope(n);const r=me(t,e,!0).total();return n.isDegenerate(r)?s.createInstance():e}if(n(o)){const s=e,n=new I({vd:s.getDescription()});return n.addSegment(s,!0),hh(n,t,r,i)}p(o),_(o)||g("OGC simplify is not implemented for this geometry type");const a=me(t,e,!1).total(),h=[0],m=e.getImpl().getIsSimple(a,h),l=r?-1:m;if(5===l){if(o===s.enumPolygon&&0!==e.getFillRule()){const t=e.clone();return t.setFillRule(0),t}return e}return Aa(e,me(t,e,!0),!1,l,i,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 Ye{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 Ye{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 Pe,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new Ee,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=me(t,e,!1);this.m_toleranceIsSimple=i,this.m_toleranceIsSimpleClustering=ye(i),this.m_toleranceIsSimpleCracking=Se(i),this.m_toleranceSimplify=me(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 i(e)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?i(e)?this._CheckCracking()?this.m_geometry.getGeometryType()===s.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return o(0),7}generateSortedPairs(e){let t=null;i(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 Ce(0),s&&(this.m_pathsForOGCTests.length=0);let r=0;for(let i=0;i<n;i++)if(this.m_pairs.push(2*i),this.m_pairs.push(2*i+1),this.m_pairIndices.add(2*i),this.m_pairIndices.add(2*i+1),s){for(;i>=t.getPathEnd(r);)r++;this.m_pathsForOGCTests.push(r)}const o=new Ie,a={parent:this,workPt:new Qe,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)}};o.sort(this.m_pairIndices,0,2*n,a)}_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(i(e)){const e=this.m_geometry.getImpl(),t=this.m_geometry.getGeometryType()===s.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(_(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?be(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 o(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!==Ee.st_nullNode()&&s!==Ee.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!==Ee.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!==Ee.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 G,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new fa;const e=C.constructEmpty();this.m_geometry.queryEnvelope(e);const t=_a(this.m_toleranceSimplify.total(),e),s=new ts;if(la(this.m_editShape,t,this.m_toleranceSimplify.total(),12e3,s,this.m_curveStitcher,null,this.m_progressTracker),0!==s.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(s),!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=U(!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 o(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 Pe(!0);t.fill(-1);let a=-1;const h=new Qe;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 we(e.getPathCount(),0),this.m_pathParentage=new Ce(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 Ce(n,Ee.st_nullNode()),this.m_xyToNode2=new Ce(n,Ee.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!==Ee.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,Ee.st_nullNode())}if(n=this.m_xyToNode2.read(s),n!==Ee.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,Ee.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)===Ee.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)===Ee.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!==Ee.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===Ee.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,n,r){let i;return e.getGeometryType()===s.enumLine?i=this.createEdgeLine(e):(i=new lh,i.m_segment=e.clone()),i.m_vertexIndex=t,i.m_pathIndex=n,i.m_flags=0,i.setReversed(r),i}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()===s.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 ve(s,i,n,r)}{const s=e.getXY(),r=t.getXY();return Qe.sqrDistance(s,r)<=n*n}}removeDegenerateSegmentsFromCurvedPath(e,t,s,n){const r=e.hasAttribute(1),i=e.querySegmentIterator();i.resetToPath(t),o(i.nextPath());const a=this.m_toleranceSimplify.total();let h=!1,m=!0;const l=new fe,g=new fe,u=new Qe;for(;i.hasNextSegment();){this.progress_();const e=i.nextSegment();if(Ph.isShortSegment(e,r,a,s))if(h){if(e.queryEnd(g),Ph.isShortSegmentPoints(l,g,r,a,s))continue;m&&(n.startPathPoint(l),m=!1),e.queryEnd(l),n.lineToPoint(l),h=!1}else u.assign(e.getStartXY()),e.queryStart(l),h=!0;else if(h)if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(u,e.getEndXY(),!1),t.setStart(l),Ph.isShortSegment(t,r,a,s))continue;n.addSegment(t,m),m=!1,h=!1}else{if(e.queryEnd(g),Ph.isShortSegmentPoints(l,g,r,a,s))continue;m&&(n.startPathPoint(l),m=!1),n.lineToPoint(g),h=!1}else n.addSegment(e,m),m=!1}if(m)return;if(!h)return;e.isClosedPath(t)?e.getPointByVal(e.getPathStart(t),l):e.getPointByVal(e.getPathEnd(t)-1,l);const c=n.querySegmentIterator();c.resetToLastPath(),c.resetToLastSegment();const _=n.getDescription().getAttributeCount()>1;for(o(c.previousPath());c.hasPreviousSegment();){const e=c.previousSegment();if(e.isCurve()){const t=e.clone();if(t.setCoordsForIntersector(e.getStartXY(),l.getXY(),!1),!Ph.isShortSegment(t,r,a,s)){_&&t.setEnd(l);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,l,r,a,s)){const e=c.getEndPointIndex();for(let t=n.getPointCount()-1;t>=e;t--)n.removePoint(t);return void n.lineToPoint(l)}}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=Ke(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,Ne.getDefaultValue(1)),n=s),this.m_multiVertexGeom=e;const r=e.getPointCount(),i=Ke(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?be(this.m_sr,e,!0).total():0,a=[],h=[];let m=null;i&&(m=e.getAttributeStreamRef(1));const l=new fe,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 Qe;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 Qe;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()&&!Te(this.m_knownSimpleResult))return Ma(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const e=new G;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 s=C.constructEmpty();this.m_geometry.queryEnvelope(s);const i=_a(this.m_toleranceSimplify.total(),s);n=da(this.m_toleranceSimplify.total()),r=pa(i,n),aa(e,i,this.m_toleranceSimplify.total(),12e3,t,null,this.m_progressTracker)}if(!Te(this.m_knownSimpleResult)){ya(e,this.m_toleranceSimplify.add(r),this.m_progressTracker,!0,!1)}this.m_geometry.getGeometryType()===s.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()===s.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 it(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=Ne.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=ot(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 ue(e.getGeometryType(),i)}isSimplePlanarDONOTUSE(e,t,s,n,r){const i=rh(e,t,s,n,r);return ce(i)}executeMany(e,t,s,n){return new Sh(e,t,s,n)}execute(e,t,s,n){const i=new $t([e]),o=this.executeMany(i,t,s,n).next();return o||r("null geometry"),o}}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(t){if(t||e(""),t.getGeometryType()===s.enumGeometryCollection){const e=V(t,-1),s=(new Eh).executeMany(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),n=t.createInstance();for(let t=s.next();null!=t;t=s.next())n.addGeometry(t);return n}return ah(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}function Ch(e,t,n){const r=new C;e.queryEnvelope(r);const i=new C;t.queryEnvelope(i);const o=new C(i);if(o.inflate(2*n),!o.isIntersecting(r))return 4;const a=e.getGeometryType(),h=t.getGeometryType();if(a===s.enumEnvelope&&r.containsEnvelope(o))return 1;if(h===s.enumEnvelope){const e=new C(r);if(e.inflate(2*n),i.containsEnvelope(e))return 2}return 0}class Ih{constructor(e,t,n,r){this.m_intersectorGeom=null,this.m_sr=null,this.m_dimensionMask=-1,this.m_progressTracker=null,this.m_intersectorGeomType=s.enumUnknown,this.m_geomIntersectorEmptyGeom=null,this.m_intersectorGeom=e,this.m_sr=t,this.m_dimensionMask=n,this.m_progressTracker=r,this.m_intersectorGeomType=e.getGeometryType()}intersect(e){const t=this.tryFastImplementation(e);if(null!==t)return t;const s=_e(this.m_intersectorGeom,e),n=de(this.m_sr,s,!0).total(),r=C.constructEmpty();this.m_intersectorGeom.queryEnvelope(r);const i=C.constructEmpty();e.queryEnvelope(i),r.inflateCoords(2*n,2*n),r.intersect(i),r.inflateCoords(100*n,100*n);const o=0;let a=Zt(this.m_intersectorGeom,r,o,0,this.m_progressTracker),h=Zt(e,r,o,0,this.m_progressTracker);return e.getDimension()>this.m_intersectorGeom.getDimension()&&(a=rt(h,h=a)),za(h,a,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 s=_e(this.m_intersectorGeom,e),n=de(this.m_sr,s,!0).total(),r=C.constructEmpty();this.m_intersectorGeom.queryEnvelope(r);const i=C.constructEmpty();e.queryEnvelope(i),r.inflateCoords(2*n,2*n),r.intersect(i),r.inflateCoords(100*n,100*n);const o=0;let a=Zt(this.m_intersectorGeom,r,o,0,this.m_progressTracker),h=Zt(e,r,o,0,this.m_progressTracker);e.getDimension()>this.m_intersectorGeom.getDimension()&&(a=rt(h,h=a));const m=Wa(h,a,this.m_sr,this.m_progressTracker);return this.prepareVector(e.getDescription(),this.m_dimensionMask,m)}init(e,t,s,n=null){o(0)}static intersectPoints(e,t,s){const n=_e(e,t);return La(e,t,de(s,n,!0))}tryFastImplementation(e){const t=e.getGeometryType();if(this.m_intersectorGeomType===s.enumPoint&&t===s.enumPoint){const t=Ih.intersectPoints(e,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const e=new N({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}return t}if(t===s.enumEnvelope&&this.m_intersectorGeomType===s.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const t=e,s=this.m_intersectorGeom,n=new pe({copy:t});return n.intersect(s),n}const n=_e(e,this.m_intersectorGeom),i=de(this.m_sr,n,!0),o=e.isEmpty(),a=this.m_intersectorGeom.isEmpty();let m=o||a;if(!m){const t=Ch(this.m_intersectorGeom,e,i.total());if(4===t)m=!0;else{if(2&t)return this.m_intersectorGeom;if(1&t)return e}}if(m){const n=h(t),r=h(this.m_intersectorGeomType);return n<r?Ih.ReturnEmpty(e,o):n>r||0===n&&t===s.enumMultiPoint&&this.m_intersectorGeomType===s.enumPoint?this.ReturnEmptyIntersector():Ih.ReturnEmpty(e,o)}if(t===s.enumEnvelope&&0===h(this.m_intersectorGeomType)||this.m_intersectorGeomType===s.enumEnvelope&&0===h(t)){const n=t===s.enumEnvelope?e:this.m_intersectorGeom,r=t===s.enumEnvelope?this.m_intersectorGeom:e,o=C.constructEmpty();return n.queryEnvelope(o),Zt(r,o,i.total(),0,this.m_progressTracker)}if(0===h(t)&&h(this.m_intersectorGeomType)>0||h(t)>0&&0===h(this.m_intersectorGeomType)){if(t===s.enumMultiPoint)return Oa(e,this.m_intersectorGeom,i);if(t===s.enumPoint)return Xa(e,this.m_intersectorGeom,i);if(this.m_intersectorGeomType===s.enumMultiPoint)return Oa(this.m_intersectorGeom,e,i);if(this.m_intersectorGeomType===s.enumPoint)return Xa(this.m_intersectorGeom,e,i);r("")}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 N({vd:e})),n++):s.shift(),2&t?(s[n]||(s[n]=new I({vd:e})),n++):s.splice(n,1),4&t?s[n]||(s[n]=new v({vd:e})):s.splice(n,1),new $t(s)}}class bh extends es{constructor(t,s,n,r,i){super(),this.m_smallCursor=null,this.m_progressTracker=r,this.m_geomIntersector=s.next(),this.m_intersector=new Ih(this.m_geomIntersector,n,i,r),this.m_index=-1,this.m_inputGeoms=t,this.m_dimensionMask=i,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&e("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(t(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,n){if(!this.canAccelerateGeometry(e))return!1;me(t,e,!0);let r=0;return e.getGeometryType()!==s.enumPolygon&&e.getGeometryType()!==s.enumPolyline||!b(e)||0===n||(r|=e.getImpl().buildQuadTreeAccelerator(n)?1:0),!!r}canAccelerateGeometry(e){return b(e)}supportsCurves(){return!0}executeMany(e,t,s,n,r=-1){return new bh(e,t,s,n,r)}execute(e,t,n,i){if(e.getGeometryType()===s.enumPoint&&t.getGeometryType()===s.enumPoint)return Ih.intersectPoints(e,t,n);const o=new $t([e]),a=new $t([t]),h=this.executeMany(o,a,n,i,-1).next();return h||r("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(t,r,o,a){if(t&&r&&r.isPannable()||e("fold_into_360_range_geodetic"),t.isEmpty())return t;if(4===o)return Dh(t,r,a);let h=t;const m=h.getGeometryType();if(i(m)){h=Al(t,r);const e=new C;h.queryEnvelope(e);const s=de(r,e,!1).total(),n=r.getPannableExtent();let i=Math.floor((e.xmin-n.xmin)/n.width())*n.width()+n.xmin,a=h;for(;i<e.xmax;)i>e.xmin+s&&i<e.xmax-s&&(a=Hl(a,r,o,!0,i)),i+=n.width();h=a}else{if(m===s.enumEnvelope){const e=new v({vd:h.getDescription()});return e.addEnvelope(h,!1),Gh(e,r,o,a)}if(n(m)){const e=new I({vd:h.getDescription()});return e.addSegment(h,!0),Gh(e,r,o,a)}}return Dh(h,r,a)}function Dh(t,r,i){if(t&&r&&r.isPannable()||e(""),t.isEmpty())return t;let o;const a=t.getGeometryType();if(a===s.enumEnvelope){const e=new v({vd:t.getDescription()});e.addEnvelope(t,!1),o=e}else if(n(a)){const e=new I({vd:t.getDescription()});e.addSegment(t,!0),o=e}else o=t;const h=Al(o,r);return h.isEmpty()?h:vl(h,r,0,h!==t,0,i)}function Vh(e,t,s){if(!t.isPannable()||e.isEmpty())return e;const n=t.getPannableExtent().width(),r=.5*n,o=e.queryInterval(0,0);if(o.width()<r||!_(e.getGeometryType())){if(Number.isNaN(s))return e;const t=o.getCenter();if(Math.abs(t-s)<=r)return e;{const r=new jt,i=nt((s-t)/n)*n;r.setShiftCoords(i,0);const o=e.clone();return o.applyTransformation(r),o}}const a=e.getGeometryType(),h=e,m=h.getAttributeStreamRef(0),l=e.clone(),g=l.getAttributeStreamRef(0);let u=0,c=0,d=0,p=i(a)?0:-1;const f=at.constructEmpty();let x=!1;for(let _=0,y=h.getPointCount();_<y;_++){const e=m.read(2*_);_===c&&(i(a)?(0===p&&Number.isNaN(s)&&(x=!0),p>0&&Number.isNaN(s)&&(s=f.getCenter(),x=!1),c=h.getPathEnd(p),p++):c=h.getPointCount(),Number.isNaN(s)?d=e:(d=s,u=0));let t=e-d;Math.abs(t)>r&&(t=nt(t/n)*n,u-=t,Math.abs(u)<.1*n&&(u=0));const o=e+u;g.write(2*_,o),x&&f.mergeCoordinate(o),d=e}return l.notifyModified(),l}const Fh="missing implementation";function Hh(e,t,s,n){const i=t.getCoordinateSystemType();if(0===i){const n=new ac;return t.queryPrecisionDescriptor(n),kh(e,n,t,s)}let o=e;2!==n&&3!==n||!t.isPannable()||(o=Dh(o,t,s));const a=new ac;if(t.queryPrecisionDescriptor(a),o=kh(o,a,t,s),0===n||o.isEmpty())return o;if(1===i){if(1===n){const e=new C;o.queryLooseEnvelope(e);const n=t.getPannableExtent(),r=.01*n.width();return n.xmin=e.xmin-r,n.xmax=e.xmax+r,(new Kt).execute(o,n,t,s)}return o}if(2===i){const e=t.getPCSHorizon();if(1===n||2===n){const n=(new wh).execute(o,e,t,s);return n===e?n.clone():n}return o}if(3===i)return o;r(Fh)}function kh(e,t,s,n){const r=t.getXYGridRange(),i=e.hasAttribute(1),o=e.hasAttribute(2);let a=new at,h=new at;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()),Le(m,a,1,0))}if(o){const t=m.queryInterval(2,0);h.contains(t)||(e===m&&(m=m.clone()),Le(m,h,2,0))}return m}class Ah{constructor(t){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,t||e(""),this.m_projTransform=t,this.m_bClipOutCurvedPoles=!1;const s=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=s.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(s.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),s.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!s.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,s.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!s.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=s.centralMeridianOfOutputGCS,this.m_densificationStepInput=s.densificationStep;const n=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=n.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=n.hasFlag(1073741824),this.m_bClipOutCurvedPoles=n.hasFlag(536870912)}project(e,t){if(this.m_projTransform.isIdentity()||e.isEmpty())return e;const n=e.getGeometryType();if(n===s.enumPoint)return this.projectPoint(e,t);const i=this.m_projTransform.getInputSR().getCoordinateSystemType(),o=this.m_projTransform.getOutputSR().getCoordinateSystemType(),a=this.m_projTransform.getInputSR(),h=this.m_projTransform.getOutputSR();if(0===i&&i===o){const t=Uh(a,h),s=e.clone();return s.applyTransformation(t),s}switch(n){case s.enumPolyline:case s.enumPolygon:return this.projectMultiPath(e,t);case s.enumMultiPoint:return this.projectMultiPoint(e,t);case s.enumEnvelope:return this.projectEnvelope(e,t);case s.enumGeometryCollection:return this.projectGeometryCollection(e,t);default:r("")}}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 N({copy:e});const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),a=r.getCoordinateSystemType();if(3===i&&o(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 h=0;3===a&&o(0);const m=2===a;return m?h=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(h=this.m_centralMeridianOfOutputGCS),m&&0!==this.m_outputPCSHorizonClipOption||(s=vl(s,Zu(r),h,!1,0,t)),m&&(s=Sl(s,r,this.m_outputPCSHorizonClipOption,t),Kl(r,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(e,t){const n=e.getGeometryType();return n===s.enumPolygon?this.projectPolygon(e,t):n===s.enumPolyline?this.projectPolyline(e,t):void r("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=at.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){o(e.getGeometryType()===s.enumPolygon),o(!this.m_projTransform.isIdentity()),o(!e.isEmpty());const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),a=r.getCoordinateSystemType(),h=new v({copy:e});3===i&&o(0),3===a&&o(0);const m=2===i,l=2===a,g=m?n.getGCS():n,u=l?r.getGCS():r,c=!l&&!this.m_bDontHackPolesInGeogToGeog;let _=!1,d=Xl(h,n,this.m_inputPCSHorizonClipOption,t);if(d.isEmpty())return d;let p=this.m_densificationStepInput;const f=!Number.isNaN(p);let x;f&&(d=(new Jt).execute(d,p,0,0,t));let y=l?r.getPCSInfo():null,P=Number.NaN;m&&(P=n.getCentralMeridian());const E=null!==r.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const e=d;if(m&&(hg(n,P,e),f)){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,c),f){const e=n.getGCS().getUnitsPerMillimeter();p*=r.getGCS().getUnitsPerMillimeter()/e}x=e}else{let e=new I({vd:d.getDescription()});if(e.addAndExplicitlyOpenAllPaths(d,!1),m){if(hg(n,P,e),f){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(this.m_bClipOutCurvedPoles){const s=n.getPCSInfo(),r=s.getSouthPoleGeometry()===Nc.PE_POLE_LINE_CURVED,i=s.getNorthPoleGeometry()===Nc.PE_POLE_LINE_CURVED;if(r||i){const s=C.constructEmpty();e.queryLooseEnvelope(s),s.inflateCoords(1,1);const n=89.9999*g.getOneDegreeGCSUnit();r&&(s.ymin=-n),i&&(s.ymax=n),e=Qt(e,s,g,0,0,t)}}}if(cg(this.m_projTransform,e,c),f){const e=Zu(n).getUnitsPerMillimeter();p*=Zu(r).getUnitsPerMillimeter()/e}let s=Number.NaN;l?(y=r.getPCSInfo(),s=r.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(s=this.m_centralMeridianOfOutputGCS);let i=Mh(n)|Mh(r),o=10*u.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=10*u.getTolerance(0)),x=Vl(d,n,e,u,s,t,i,o,this.m_bNormalizeOutputGeometry),i=0}if(E&&(o(!r.isPannable()),x=cl(x,r,t)),l){if(!_){const e=u.getPannableExtent().width();if(x.queryInterval(0,0).width()>=e-10*u.getTolerance(0)){const e=y.getNorthPoleLocation(),t=y.getSouthPoleLocation(),s=y.getNorthPoleGeometry(),n=y.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),_||=0!==r}}x=Sl(x,r,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(r,x,this.m_bNormalizeOutputGeometry)}return x.isEmpty()||_&&(x=(new Eh).execute(x,r,!1,t)),x}projectPolyline(e,t){o(e.getGeometryType()===s.enumPolyline),o(!this.m_projTransform.isIdentity()),o(!e.isEmpty());const n=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),i=n.getCoordinateSystemType(),a=r.getCoordinateSystemType(),h=new I({copy:e});3===i&&o(0),3===a&&o(0);const m=2===i,l=2===a;m&&n.getGCS();const g=l?r.getGCS():r,u=!l&&!this.m_bDontHackPolesInGeogToGeog;let c=Xl(h,n,this.m_inputPCSHorizonClipOption,t);if(c.isEmpty())return c;let _=Number.NaN;m&&(_=n.getCentralMeridian());const d=null!==r.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(m&&(hg(n,_,c),f)){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,c,u),f){const e=n.getGCS().getUnitsPerMillimeter();p*=r.getGCS().getUnitsPerMillimeter()/e}x=c}else{const e=new I({vd:c.getDescription()});if(e.addAndExplicitlyOpenAllPaths(c,!1),m&&(hg(n,_,e),f)){const e=n.getUnitsPerMillimeter();p*=n.getGCS().getUnitsPerMillimeter()/e}if(cg(this.m_projTransform,e,u),f){const e=n.getGCS().getUnitsPerMillimeter();p*=r.getGCS().getUnitsPerMillimeter()/e}let s=Number.NaN;l?s=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(s=this.m_centralMeridianOfOutputGCS);let i=Mh(n)|Mh(r),o=10*g.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(i=3,o=0),x=Fl(c,n,e,g,s,t,i,o,this.m_bNormalizeOutputGeometry),i=0}return d&&(o(!r.isPannable()),x=cl(x,r,t)),l&&(x=Sl(x,r,this.m_outputPCSHorizonClipOption,t),f&&(x=(new Jt).execute(x,p,0,0,t)),Jl(r,x,this.m_bNormalizeOutputGeometry)),x.isEmpty(),x}projectGeometryCollection(e,t){return o(0),{}}projectEnvelopeHelper(e,t){const s=(e.height()+e.width())/400;if(0!==s){const n=(new Jt).execute(e,s,0,0,t),r=this.projectMultiPath(n,t),i=new pe({vd:e.getDescription()});if(r.isEmpty()){const s=Math.min(e.height(),e.width()),r=me(this.m_projTransform.getInputSR(),e,!0).total();if(s>100*r){const e=C.constructEmpty(),t=de(this.m_projTransform.getOutputSR(),e,!0).total(),n=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(s>100*Math.max(r,t*n))return i}const o=new I;o.addAndExplicitlyOpenAllPaths(n,!1);this.projectMultiPath(o,t).queryEnvelope(i);const a=new N({vd:e.getDescription()});a.reserve(4);const h=new fe;for(let t=0;t<4;t++)e.queryCornerByVal(t,h),a.add(h);const m=this.projectMultiPoint(a,t),l=new pe;return m.queryEnvelope(l),i.merge(l),i}return r.queryEnvelope(i),i}{const s=e.getCenterXY(),n=new fe(s),r=this.projectPoint(n,t),i=new pe({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 o(0),0}transformInPlaceZ(e,t,s,n,r,i){if(this.m_projTransform.isIdentity())return e!==n&&et(n,e,s),t!==r&&wt(r,t,0,0,s),s;const a=this.m_projTransform,h=a.getInputSR(),m=a.getOutputSR(),l=h.getCoordinateSystemType(),u=m.getCoordinateSystemType();if(0===l&&l===u){return Uh(h,m).transformPoints2D(e,s,n),a.isVertical()&&o(0),s}3===l&&g("image: transform_in_place_"),3===u&&g("image: transform_in_place_"),Ll(e,s,n,h,this.m_inputPCSHorizonClipOption),r!==t&&wt(r,t,0,0,s),2===l&&mg(h,0,n,s),fg(this.m_projTransform,n,r,s,!1);let c=0;const _=2===u;_?c=m.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(c=this.m_centralMeridianOfOutputGCS),_&&0!==this.m_outputPCSHorizonClipOption||Nl(n,s,m.getGCS(),c),_&&(wl(n,s,m,this.m_outputPCSHorizonClipOption),Wl(m,n,s,!1));let d=s;for(let o=0;o<s;++o)n[o].isNAN()&&(r&&(r[o]=Number.NaN),d--);return d}}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 o(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(t,s,n){super(),this.m_projTrans=s,this.m_progressTracker=n,this.m_index=-1,t||e(""),this.m_inputGeoms=t}next(){const e=this.m_inputGeoms.next();return null!=e?(x(e),t(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(r,a,h,m,l,g,u=!1){r||e("Geometry.Geodetic_densify.densify");let c=r.getGeometryType();if(t(r),r.isEmpty()||d(c))return r;const _=new Wh;_.m_sr=a,_.m_gcs=a.getGCS(),_.m_transform=_.m_gcs!==a?a.getSRToGCSTransform():null,_.m_progressTracker=g;const p=Hu();let f,x,y;if(_.m_gcs.querySpheroidData(p),_.m_a=p.majorSemiAxis,_.m_eSquared=p.e2,_.m_rpu=_.m_gcs.getUnit().getUnitToBaseFactor(),_.m_gcsTolerance=_.m_gcs.getTolerance(0),_.m_radTolerance=_.m_gcsTolerance*_.m_rpu,_.m_maxLength=m,_.m_maxDeviation=l,_.m_curveType=h,c===s.enumEnvelope){const e=new v({vd:r.getDescription()});e.addEnvelope(r,!1),f=e,c=s.enumPolygon}else if(n(c)){const e=new I({vd:r.getDescription()});e.addSegment(r,!0),f=e,c=s.enumPolyline}else f=r;if(4!==_.m_curveType){if(o(i(c)),x=_.replaceCurvesWithLinesAndProjectToGCSAsMultiPoint_(f),x.isEmpty())return x;x=Yh(_.m_rpu,x);let e=_.geodeticDensify(x);u||(e=(new qh).foldInto360RangeGeodetic(e,_.m_gcs,_.m_curveType)),y=_.m_transform&&!_.m_transform.isIdentity()?(new qh).execute(e,_.m_transform.getInverse(),g):e}else{let e;if(o(i(c)),a.isPannable())e=Al(f,a);else{const t=a.getPCSHorizon();e=(new wh).execute(f,t,a,g),e===t&&(e=t.clone())}if(x=e,x.isEmpty())return x;y=_.shapePreservingDensify(x)}return y}function Yh(e,t){const s=new C;if(t.queryLooseEnvelope(s),s.width()*e<Math.PI)return t;let n=!1;const r=t.querySegmentIterator(),i=new Qe,o=new Qe;for(;r.nextPath();)for(;r.hasNextSegment();){const t=r.nextSegment();if(i.setCoordsPoint2D(t.getStartXY()),o.setCoordsPoint2D(t.getEndXY()),i.scale(e),o.scale(e),Math.abs(i.x-o.x)>Math.PI){if(!Xh(i,o)){n=!0;break}if(Math.abs(i.x-o.x)>2*Math.PI){n=!0;break}}}if(!n)return t;const a=t.createInstance();a.reserve(t.getPointCount());const h=t.getDescription().getAttributeCount()>1,m=new Qe,l=new Qe,g=new Qe(0,0),u=new Qe(0,0),c=new fe;for(r.resetToFirstPath();r.nextPath();){let t=Number.NaN,s=0;for(;r.hasNextSegment();){const n=r.nextSegment();i.setCoordsPoint2D(n.getStartXY()),o.setCoordsPoint2D(n.getEndXY()),i.scale(e),o.scale(e),Number.isNaN(t)?(s=im(i.x,Number.NaN,s),g.setCoordsPoint2D(i)):g.setCoordsPoint2D(u),t=g.x;if(Xh(i,o)){if(o.x-i.x>2*Math.PI)for(;o.x-i.x>2*Math.PI;)o.x-=2*Math.PI;else if(o.x-i.x<2*-Math.PI)for(;o.x-i.x<2*-Math.PI;)o.x+=2*Math.PI;s=im(o.x,Number.NaN,s),u.setCoordsPoint2D(o)}else m.setCoordsPoint2D(o),gm(m),s=im(m.x,t,s),u.setCoords(s+m.x,m.y);if(Math.abs(u.x-o.x)<.5&&u.setCoordsPoint2D(o),h){n.queryCoord(0,c),l.setCoordsPoint2D(g),l.scale(1/e),c.setXY(l);r.isFirstSegmentInPath()?a.startPathPoint(c):a.lineToPoint(c),r.isLastSegmentInPath()&&!r.isPathClosed()&&(n.queryCoord(1,c),l.setCoordsPoint2D(u),l.scale(1/e),c.setXY(l),a.lineToPoint(c))}else{r.isFirstSegmentInPath()&&a.insertPath2D(-1,null,0,0,!0);const t=a.getPathCount()-1;l.setCoordsPoint2D(g),l.scale(1/e),a.insertPoint2D(t,-1,l),r.isLastSegmentInPath()&&!r.isPathClosed()&&(l.setCoordsPoint2D(u),l.scale(1/e),a.insertPoint2D(t,-1,l))}}}return a}function Rh(e,t,s,n,r,i,o,a,h,m,l,g){const u=new Qe,c=new Qe,_=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,Ct)||!Pc(t.y,Ct))||!(!Pc(e.y,-Ct)||!Pc(t.y,-Ct))}function Lh(e,t){return!(!Pc(e.y,Ct)||Pc(t.y,Ct))||!(!Pc(e.y,-Ct)||Pc(t.y,-Ct))}function zh(e,t){return!(!Pc(t.y,Ct)||Pc(e.y,Ct))||!(!Pc(t.y,-Ct)||Pc(e.y,-Ct))}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 F,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 Qe,g=new Qe,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 F,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 N;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 fe;e.getPointByVal(r,s),t.add(s),a=!0}if(this.m_transform&&!this.m_transform.isIdentity()){if(o&&!a){const s=new fe;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 fe;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(e,t,s,n,r,i,o,a,h,m,l,g,u){const c={stack:[],error:void 0,hasError:!1};try{const _=zt(c,new Cc,!1),d=zt(c,new Cc,!1),p=zt(c,new Cc,!1);Dc.geodeticDistance(e,t,n.x,n.y,r.x,r.y,p,_,d,s);const f=p.val,x=_.val,y=d.val;let P=x,E=y;P<0&&(P+=2*Math.PI),E<0&&(E+=2*Math.PI),h&&(h[0]=P),m&&(m[0]=E);let S=Number.NaN,C=Number.NaN;if(null!==l){const s=Vc.q90(e,t),r=Vc.q(e,t,n.y);S=(s-r)/f,C=(s+r)/f}const I=Lh(n,r),b=zh(n,r),w=I||b,v=mm(n,r,a),N=zt(c,new pt(new Cc,new Cc),!1),T=new Qe,G=new Qe,D=new Qe;u[0]=im(n.x,Number.NaN,u[0]);let V=u[0];if(f<=i)return g.push(n.clone()),u[0]=im(r.x,Number.NaN,u[0]),null!=l&&l.push(0),w?(I&&om(n,r,l,g),b&&am(n,r,l,g)):v?hm(n,r,x,S,C,l,g):o>0&&(G.setCoords(n.x-V,n.y),T.setCoords(r.x-u[0],r.y),V=Jh()),g.push(r.clone()),f;const F=1+Math.ceil(f/i),H=f/(F-1),k=new Qe;g.push(n.clone()),k.setCoordsPoint2D(n),G.setCoords(n.x-u[0],n.y),null!==l&&l.push(0);for(let i=1;i<F;i++){let h;if(i<F-1){const r=i*H;Dc.geodeticCoordinate(e,t,n.x,n.y,r,x,N.at(0),N.at(1),s),T.setCoords(N.at(0).val,N.at(1).val),u[0]=im(T.x,k.x,u[0]),D.setCoords(u[0]+T.x,T.y),h=i/(F-1)}else u[0]=im(r.x,Number.NaN,u[0]),T.setCoords(r.x-u[0],r.y),D.setCoordsPoint2D(r),h=1;w?(1===i&&I&&om(n,D,l,g),i===F-1&&b&&am(k,r,l,g)):v?lm(k,D,a)&&(n.x<r.x?k.x>D.x&&(u[0]+=2*Math.PI,D.setCoords(u[0]+T.x,T.y)):k.x<D.x&&(u[0]-=2*Math.PI,D.setCoords(u[0]+T.x,T.y)),hm(k,D,x,S,C,l,g)):o>0&&Jh(),g.push(D.clone()),null!=l&&l.push(h),k.setCoordsPoint2D(D),G.setCoordsPoint2D(T),V=u[0]}return f}catch(_){c.error=_,c.hasError=!0}finally{Wt(c)}}function Qh(e,t,s,n,r,i,a,h,m,l){o(0)}function Jh(e,t,s,n,r,i,a,h,m,l,g,u,c,_,d){return o(0),0}function $h(e,t,s,n){const r=ds(e,t,s),i=ds(e,t,n);return Re.distance(r,i)}function em(e,t,s,n,r,i,a,h){const m=new Array,l=lt(Array,8);let g=2,u=r.getCoord2D(i);l[0][0]=u.x,l[0][1]=u.y,u=r.getCoord2D(a),l[1][0]=u.x,l[1][1]=u.y;const c=e=>{if(null!==s){const t=wc.projToGeog(s,e,l);o(t===e)}for(const t of l)t[0]*=n,t[1]*=n};c(2),m.push(ds(e,t,new Qe(l[0][0],l[0][1]))),m.push(ds(e,t,new Qe(l[1][0],l[1][1])));let _=Re.distance(m[0],m[1]);if(_>h)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=ft(i,a,e*s);r.queryCoord2D(t,u),l[n][0]=u.x,l[n][1]=u.y,n++}c(n);let p=1;for(let r=0;r<n;++r)m.splice(p,0,ds(e,t,new Qe(l[r][0],l[r][1]))),p++;p=0;let f=m[p];p++;let x=0;for(;p!==m.length;++p){const e=m[p];x+=Re.distance(f,e),f=e}if(x>h)return x;if(d=x-_,o(d>=0||Math.abs(d)<1e-14*x),d<0&&(d=0),_=x,x+d<=h)return x+d;g=2*g-1}return _+d}function tm(e,t,s,n,r,i,a,h,m){const l=n.isCurve(),g=Fs(e,t)*Math.PI*179/180;let u=i;i>0&&!(i>g)||(u=g);const c=a,_=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 Qe,S=new Qe;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),m.push(y.clone()),null!==h&&h.push(I);const N=r.isPannable(),T=y.clone(),G=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let D=5;l||(_?(G[0]=.5,G[1]=.25,G[2]=.75,D=3):D=1),o(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 a=v.at(-1);let g=!1,c=Number.NaN;const y=em(e,t,f,s,n,I,a,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 Qe,H=new Qe;let k=!1;if(!_&&P&&P&&(k=!0),n.calculateSubLength(I,a)<=x&&(k=!0),!k)for(let h=0;h<D;h++){const m=ft(I,a,G[h]),u=new Qe;n.queryCoord2D(m,u);const f=V(u);if(0===h&&(c=m,F.setCoordsPoint2D(u),H.setCoordsPoint2D(f),!P)){g=!0;break}if(o(_),p&&Math.abs(E.x-f.x)>=Math.PI){g=!0;break}let x=new Qe,y=new Qe;l?(x=Qe.lerp(T,i,G[h]),y=V(x)):(x=u.clone(),y=f.clone());const C=Ss(e,t,E,S,G[h]),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=ft(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 at(I,a),-1);let i=n.getCoord2D(s);i=V(i);let o=$h(e,t,i,C);if(o>d){if(o<4*d){const s=ds(e,t,i),n=ds(e,t,E),r=ds(e,t,S),{second:a}=vs(e,t,s,n,r,2,null);o=a}if(o>d){g=!0;break}}else if(l){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(),m.push(i.clone()),C+=y,null!==h&&h.push(C),T.setCoordsPoint2D(i),E.setCoordsPoint2D(S),I=a)}if(null!==h){const e=1/C;for(let t=0;t<h.length;t++)h[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 Qe;r.setCoords(t.x,Ct),Pc(e.x,r.x)||Pc(t.y,r.y)||(n.push(r),null!==s&&s.push(0))}else{const r=new Qe;r.setCoords(t.x,-Ct),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 Qe;r.setCoords(e.x,Ct),Pc(t.x,r.x)||Pc(e.y,r.y)||(n.push(r),null!==s&&s.push(1))}else{const r=new Qe;r.setCoords(e.x,-Ct),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(Ct-e.y>0){const t=new Qe;t.setCoords(e.x,Ct),o.push(t),null!==i&&i.push(n)}if(Ct-t.y>0){const e=new Qe;e.setCoords(t.x,Ct),o.push(e),null!==i&&i.push(n)}}else{if(Ct+e.y>0){const t=new Qe;t.setCoords(e.x,-Ct),o.push(t),null!==i&&i.push(r)}if(Ct+t.y>0){const e=new Qe;e.setCoords(t.x,-Ct),o.push(e),null!==i&&i.push(r)}}}function mm(e,t,s){return!(!lm(e,t,s)||Pc(e.y,Ct)||Pc(e.y,-Ct)||Pc(t.y,Ct)||Pc(t.y,-Ct))}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(e,t,s,n){const r={stack:[],error:void 0,hasError:!1};try{const i=[s.x],o=[s.y-n],a=[s.x],h=[s.y+n];Vs(i,o),Vs(a,h);const m=zt(r,new Cc,!1),l=zt(r,new Cc,!1);Dc.greatEllipticDistance(e,t,s.x,s.y,i[0],o[0],m,null,null),Dc.greatEllipticDistance(e,t,s.x,s.y,a[0],h[0],l,null,null);return Math.min(m.val,l.val)}catch(i){r.error=i,r.hasError=!0}finally{Wt(r)}}function cm(e,t,s,n,r){const i=new C;s.queryEnvelope(i);const o=me(null,s,!0).total();if(t.xmin-i.xmin<=o&&i.xmax-t.xmax<=o)return s;const a=t.width();let h=0;for(;t.xmin+h*a<i.xmin;)h++;for(;t.xmin+h*a>i.xmin;)h--;const m=h*a,l=new jt;l.setShiftCoords(-m,0);const g=s;g.applyTransformation(l);const u=new C;g.queryEnvelope(u);let c=null;if(u.xmax>t.xmax){let s=0;const n=new C;n.setCoords({env2D:t}),n.ymin-=1,n.ymax+=1;let i=g;for(;n.xmin<u.xmax;){u.xmax>n.xmax&&(i=Hl(i,e,2,!0,n.xmax));const o=We(i,n),h=de(null,o,!0).total(),m=Zt(i,n,h,Number.NaN,r);null===c?c=m===i?m.clone():m:(l.setShiftCoords(-s*a,0),m.applyTransformation(l),c.add(m,!1)),s++,n.xmin=n.xmax,n.xmax=t.xmax+s*a}}else c=g;return c}class _m{constructor(e,t){this.m_basisX=new Re,this.m_basisY=new Re,this.m_normal=new Re,o(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),a=Math.sin(n),h=Math.cos(r),m=Math.sin(r);this.m_cartCenter3D=fs(this.m_a,this.m_e2,i,a,h,m),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),Re.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(Qe.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(Qe.construct(0,.5*-Math.PI/this.m_rpu))}project(t){const s=t.getGeometryType();if(_(s)){x(t);const e=t;return this.projectMultiVertex(e)}e("Gnomonic.project")}unproject(t,n,r){const o=t.getGeometryType();if(_(o)){x(t);let e=t;const a=[];if(o===s.enumPolygon){const t=e.getPathCount();for(let s=0;s<t;s++){const t=e.calculateRingArea2D(s);a.push(t)}}return this.unprojectMultiVertex(n,e),i(o)?(Cm(this.m_gcs,0,e),dm(a,this.m_gcs,0,e,r)):e=vl(e,this.m_gcs,0,!0,0,r),e}e("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 Qe.construct(Number.NaN,Number.NaN);const r=this.m_d/n,i=s.mul(r).sub(this.m_cartCenter3D),o=new Qe;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 Qe,r=new Qe;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 Qe;r&&Qe.sqrDistance(e,this.m_northPolePcs)<=n?(t.setCoords(this.m_curvCenterRad.x,.5*Math.PI),t.scale(1/this.m_rpu)):i&&Qe.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,i){const o=r.getGeometryType(),a=t.getPannableExtent();let h=r,m=!1,l=!1;if(o===s.enumPolygon){const s=new C,r=Qe.construct(n,0);s.setCoords({env2D:a}),s.centerAt(r),m=pm(e,t,s,h,i);const o=Sm(t,s,h,i);o!==h&&(l=!0),h=o}else h=(new qh).foldInto360RangeGeodetic(h,t,2);o===s.enumPolygon&&(m||l)&&(h=(new Eh).execute(h,t,!1,i)),h!==r&&(r.setEmpty(),r.add(h,!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 s=new C;t.queryEnvelope(s);const n=Pc(e.ymax,s.ymax),r=Pc(e.ymin,s.ymin),i=n||r;return!!i&&(ym(e,t),i)}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 v({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 s=new v,n=new C;for(let r=0;r<t.getPathCount();r++){t.queryPathEnvelope(r,n);let i=Pc(e.ymax,n.ymax),o=Pc(e.ymin,n.ymin);if(!(i||o)){s.addPath(t,r,!0);continue}s.insertPath2D(-1,null,0,0,!0);const a=t.getPathStart(r),h=t.getPathEnd(r),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 n=t.getXY(g);i=Pc(e.ymax,n.y),o=Pc(e.ymin,n.y);const h=a+(g+1-a)%m;if(i||o){let i=Qe.construct(c,n.y);s.insertPoint2D(r,-1,i);const o=t.getXY(h),a=Pc(e.ymax,o.y),m=Pc(e.ymin,o.y);a||m||(i=Qe.construct(o.x,n.y),u?s.setXYNoCurves(s.getPointCount()-1,i):s.insertPoint2D(r,-1,i)),u=!0}else s.insertPoint2D(r,-1,n),c=n.x,u=!1;g=h}while(g!==l)}t.setEmpty(),t.add(s,!1)}function Pm(e,t,s,n,r,i){const o=new v,a=new v,h=new jt,m=r.getXY(r.getPathStart(n)),l=r.getXY(r.getPathEnd(n)-1),g=s.width(),u=.5*g,c=new C;r.queryEnvelope(c);const _=Math.ceil(c.width()/g)+1;let d,p;m.x>l.x?(d=-g,p=e?s.ymin:s.ymax):(d=g,p=e?s.ymax:s.ymin),h.setShiftCoords(d,0),o.addPath(r,n,!0),a.add(o,!1);const f=new fe;for(let C=0;C<_;C++)a.applyTransformation(h),a.getPointByVal(0,f),o.lineToPoint(f),o.addSegmentsFromPath(a,0,0,a.getSegmentCount()-1,!1);const x=o.getXY(0),y=o.getXY(o.getPointCount()-1);x.y=p,y.y=p,o.lineTo(y);const P=new Qe;for(P.setCoordsPoint2D(y),P.x-=.5*d;Math.abs(P.x-x.x)>u;)o.lineTo(P),P.x-=.5*d;o.lineTo(x);const E=s.getCenter().x,S=new C;o.queryEnvelope(S);let I=0;const b=S.getCenter().x;b-E>u?I=-Math.ceil((b-E-u)/g):E-b>u&&(I=Math.ceil((E-b-u)/g)),0!==I&&(h.setShiftCoords(I*g,0),o.applyTransformation(h));const w=new G,N=w.addGeometry(o);kl(w,N,t,0,2,!0,s.xmin),kl(w,N,t,0,2,!0,s.xmax);const T=w.getGeometry(N),D=We(T,s);D.inflateCoords(0,1);const V=de(null,D,!0);return Zt(T,s,V.total(),Number.NaN,i)}function Em(e,t,s,n,r){const i=t.width(),o=.5*i,a=t.getCenter().x,h=new C;n.queryPathEnvelope(s,h);let m,l=0,g=h.getCenter().x;if(g-a>o?l=-Math.ceil((g-a-o)/i):a-g>o&&(l=Math.ceil((a-g-o)/i)),0!==l){const e=new jt;e.setShiftCoords(l*i,0),n.getImpl().applyTransformationToPath(e,s),n.queryPathEnvelope(s,h),g=h.getCenter().x}const u=new C;t.containsExclusiveEnvelope(h)?(m=!1,u.setCoords({env2D:t})):(m=!0,u.setCoords({env2D:t}),u.xmin-=i,u.xmax+=i);let c=n.createInstance();c.addPathPoint2D(null,0,!0);const _=new Qe;if(_.setCoords(u.xmin,u.ymin),c.insertPoint2D(0,-1,_),_.setCoords(u.xmin,u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(.5*(u.xmin+u.xmax),u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(u.xmax,u.ymax),c.insertPoint2D(0,-1,_),_.setCoords(u.xmax,u.ymin),c.insertPoint2D(0,-1,_),_.setCoords(.5*(u.xmin+u.xmax),u.ymin),c.insertPoint2D(0,-1,_),m){c.addPath(n,s,!0);const o=new jt;g<a?o.setShiftCoords(i,0):o.setShiftCoords(-i,0),n.getImpl().applyTransformationToPath(o,s),c.addPath(n,s,!0);const h=new G,m=h.addGeometry(c);kl(h,m,e,0,2,!0,t.xmin),kl(h,m,e,0,2,!0,t.xmax),c=h.getGeometry(m);const l=We(c,t);l.inflateCoords(0,1);const u=de(null,l,!0).total();c=Zt(c,t,u,Number.NaN,r)}else c.addPath(n,s,!0);return c}function Sm(e,t,s,n){const r=new C;s.queryEnvelope(r);const i=me(null,s,!0).total();if(t.xmin-r.xmin<=i&&r.xmax-t.xmax<=i)return s;const o=s.createInstance();let a=s.createInstance();const h=new C,m=s.getPathCount();for(let l=0;l<m;l++)s.queryPathEnvelope(l,h),t.xmin-h.xmin<=i&&h.xmax-t.xmax<=i?o.addPath(s,l,!0):(a.setEmpty(),a.addPath(s,l,!0),a=cm(e,t,a,!0,n),o.add(a,!0));return o}function Cm(e,t,s){const n=e.getPannableExtent(),r=Qe.construct(t,0);n.centerAt(r);const i=n.width(),o=.5*i,a=new Qe;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 Qe;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 G,u=g.addGeometry(t),c=g.getFirstPath(u);let _=-1,d=!0;const p=new Qe,f=new fe;let x=M;const y=Gm*r/360;for(let P=g.getFirstVertex(c);P!==M;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!==M?g.getNextVertex(x):g.getFirstVertex(c);const t=g.getPrevVertex(P);for(;e!==t;)e=g.removeVertex(e,!1);if(x!==M){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=ft(e.x,s.x,.5),g.setXY(n,e)}}}x=M}if(e&&(m.y=xt(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!==M){let e=g.getNextVertex(x);for(;e!==M;)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,M,f),Math.abs(s.x-n.x)>y)){const e=g.insertVertex(c,t,f);s.x=ft(s.x,n.x,.5),g.setXY(e,s)}}return t.assignCopy(g.getGeometry(u)),!0}function wm(e,t){let s=new v({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=lt(Qe,100),o=new Re(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,n,i,o){if(!t.isPannable()||e.isEmpty())return e;const a=e.getGeometryType();a===s.enumGeometryCollection&&g("not yet impl for geometry collection");const h=t.getPannableExtent();Number.isNaN(n)&&(n=h.getCenterX());const m=h.width(),l=.5*m,u=o>0,c=e.queryInterval(0,0);if(!u&&c.width()<l||!_(e.getGeometryType())){const t=c.getCenter();if(Math.abs(t-n)<=l)return e;{const s=new jt,r=nt((n-t)/m)*m;s.setShiftCoords(r,0);const i=e.clone();return i.applyTransformation(s),i}}if(a===s.enumPolygon){let s=new I({vd:e.getDescription()});s.addAndExplicitlyOpenAllPaths(e,!1),u&&(s=Oh(s,t,2,o,Number.NaN,null,!0));const r=[];if(!i){{let n=e;u&&(n=new v,n.add(s,!1));const i=Nm(e,t,r);if(i)i<0&&s.reverseAllPaths();else{const e=n.getPathCount();for(let t=0;t<e;t++)r.push(n.calculateRingArea2D(t)>0)}}i=r}return new Dm(null,i,s,null,t,n,3,0,null).geoNormalizePolygonGeometry(!0)}if(a===s.enumPolyline){let s=new I({vd:e.getDescription()});s.addAndExplicitlyOpenAllPaths(e,!1),u&&(s=Oh(s,t,2,o,Number.NaN,null,!0));return new Dm(null,null,s,null,t,n,3,0,null).geoNormalizePolylineGeometry(!0)}if(a===s.enumMultiPoint){const t=e,s=t.getAttributeStreamRef(0);let r,i=null,o=n,a=0;const h=.1*m;for(let n=0,g=t.getPointCount();n<g;n++){const t=s.read(2*n);let g=t-o;if(Math.abs(g)>l&&(g=nt(g/m)*m,a-=g,Math.abs(a)<h&&(a=0)),0!==a){i||(r=e.clone(),i=r.getAttributeStreamRef(0));const s=t+a;i.write(2*n,s)}o=t}return i?(r.notifyModified(),r):e}r("")}const Gm=210;class Dm{constructor(e,t,s,n,r,i,a,h,m){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=m,this.m_originalGeometry=e,this.m_originalSR=n,this.m_polygonRingFlags=t,this.m_pannableSR=r,this.m_poleSnappingTolerance=h,this.m_poleFlags=a,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,o(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(e,t,s,n,i,a,h){let m=s;const l=new I({vd:this.m_inputPoly.getDescription()});l.addPath(this.m_inputPoly,e,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(!0,l,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(m=!1));let g=-1;m&&(g=this.m_originalGeometry.getPathStart(e));const u=l.getAttributeStreamRef(0),c=l.getPointCount();let _=0,d=u.read(0),p=0;const f=3*this.m_pannableSR.getTolerance(0);let x=!1;const y=new Qe,P=new Qe;let E=!1;const S=l.hasNonLinearSegments(),C=new Qe;for(let o=1;o<c;++o){u.queryPoint2D(2*o,C);const e=C.x;let t=e+_;const s=t-d;if(C.x=t,Math.abs(s)>this.m_GCSLargeDelta){if(m){const e=g+o-1,t=g+(o+1<c?o:0),r=a.read(2*e),i=(a.read(2*t)-r)*n;Math.abs(s-i)>1*this.m_degree&&(m=!1)}if(!m){_-=xt(this.m_width360,t-d),t=e+_,++p,E=0!==_,C.x=t}}else x||Xe(y,P,C,f)&&(x=!0);E&&(S&&r("error in geonormalize_ring_ for curves"),u.write(2*o,t)),d=t,y.setCoordsPoint2D(P),P.setCoordsPoint2D(C)}p&&l.notifyModified();const b=l.getXY(0),w=l.getXY(c-1);if(Qe.distance(b,w)<f){const e=this.finalizeGeoNormalizeClosedRing(l,x,i);h.add(e,!1)}else{if(t<0)if(null!==this.m_originalGeometry){o(null!==this.m_originalGeometry);t=this.m_originalGeometry.calculateRingArea2D(e)>0?1:0}else t=1;const s=this.finalizeGeoNormalizeOpenedRing(t>0,l);h.add(s,!1)}}geoNormalizePolygonGeometry(e){o(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),o(this.m_pannableSR.isPannable());let t=null,s=Number.NaN;const n=!!this.m_originalSR&&this.m_originalSR.isPannable();n&&(t=this.m_originalGeometry.getAttributeStreamRef(0),s=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const r=new v({vd:this.m_inputPoly.getDescription()});for(let o=0,_=this.m_inputPoly.getPathCount();o<_;++o){const i=this.m_polygonRingFlags?this.m_polygonRingFlags[o]?1:0:-1;this.geonormalizeRing(o,i,n,s,e,t,r)}const i=this.m_pannableSR.getTolerance(0),a=this.m_pannableExtent.width()/180;Ol(r,this.m_pannableExtent,.1*i,!1);const h=C.constructEmpty();if(h.setCoords({env2D:this.m_pannableExtent}),e){let e=!0;for(let t=0;t<2;t++){e=!0;const t=C.constructEmpty();for(let s=0,n=r.getPathCount();s<n;s++)if(r.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(r,h,i,a,this.m_progressTracker),l=r!==m;const g=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,u=m.calculateArea2D();let c=0;if(u>0&&g<0)c=1;else if(u<=0&&g>0)if(0===u){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()),g>.99*e&&(c=-1)}}else c=-1;if(0!==c){const e=wm(m.getDescription(),h);e.add(m,!1),l=!0,m=e}return l&&(m=(new Eh).execute(m,this.m_pannableSR,!1,this.m_progressTracker)),m}geoNormalizePolylineGeometry(e){o(this.m_pannableSR.isPannable());let t=null;const s=this.m_originalSR&&this.m_originalSR.isPannable();let n=1;s&&(o(this.m_originalGeometry),n=this.m_width360/this.m_originalSR.getPannableExtent().width(),t=this.m_originalGeometry.getAttributeStreamRef(0));const i=this.m_pannableExtent.width(),a=i*ht()*4;let h=e,m=Number.NaN;const l=at.constructEmpty();this.m_bAdjustedAtPoles=0;let g=new I({vd:this.m_inputPoly.getDescription()});for(let _=0,d=this.m_inputPoly.getPathCount();_<d;++_){let e=s;const u=new I({vd:this.m_inputPoly.getDescription()});u.addPath(this.m_inputPoly,_,!0);const c=this.m_inputPoly.isClosedPath(_);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=bm(c,u,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,i,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(e=!1));let d=-1;const p=u.getPointCount();let f=!1;e&&(d=this.m_originalGeometry.getPathStart(_),f=this.m_originalGeometry.isClosedPath(_));const x=u.getAttributeStreamRef(0);let y=0,P=x.read(0),E=0;const S=new Qe,b=new Qe;let w=!1;const v=u.hasNonLinearSegments(),N=new Qe;for(let s=1;s<p;++s){x.queryPoint2D(2*s,N);const i=N.x;let o=i+y;const a=o-P;if(N.x=o,Math.abs(a)>this.m_GCSLargeDelta){if(e){const r=d+s-1;let i=d;(!f||s+1<p)&&(i+=s);const o=t.read(2*r),h=(t.read(2*i)-o)*n;Math.abs(a-h)>1*this.m_degree&&(e=!1)}if(!e){y-=xt(this.m_width360,o-P),o=i+y,++E,w=0!==y,N.x=o}}w&&(v&&r("error in geonormalize_ring_ for curves"),x.write(2*s,o)),P=o,S.setCoordsPoint2D(b),b.setCoordsPoint2D(N)}if(E&&u.notifyModified(),h){let e=!1;if(!u.isEmpty()){const t=C.constructEmpty();if(u.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),o(m<=e),m<e&&(m+=i),o(m>=e)}let s=Math.round((m-t.xmin)/i)*i;if(t.xmin+s>m+a&&(s-=i),t.xmin+s<m-a&&(s+=i),l.mergeCoordinate(t.xmin+s),l.mergeCoordinate(t.xmax+s),e=l.width()>=i,!e){const e=new jt;e.setShiftCoords(s,0),u.applyTransformation(e)}}}g.add(u,!1),e&&(g=(()=>{const e=new I({vd:g.getDescription()});for(let t=0,s=g.getPathCount();t<s;++t){const s=new I({vd:g.getDescription()});s.addPath(g,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(u,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);g.add(e,!1)}}if(h)return g;const u=this.m_pannableSR.getTolerance(0),c=this.m_pannableExtent.width()/180;Ol(g,this.m_pannableExtent,.1*u,!1);return Zt(g,this.m_pannableExtent,u,c,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(e,t){const s=t.getPointCount(),n=t.getXY(0),r=t.getXY(s-1);{const e=Math.abs(r.x-n.x),t=Math.round(e/this.m_width360)*this.m_width360;o(Math.abs(e-t)<this.m_pannableSR.getTolerance(0))}const i=it(r.x-n.x),a=C.constructEmpty();t.queryLooseEnvelope(a);const h=this.m_pannableExtent.getCenterX();let m=0,l=h-this.m_width360,g=h+this.m_width360;if(i>=0){let e=Math.ceil((l-a.xmin)/this.m_width360);for(e*=this.m_width360;l>a.xmin+e;)e+=this.m_width360;for(;l<a.xmax+e;)e-=this.m_width360;for(m=e,a.width()>720&&(g=l+360*Math.ceil(a.width()/360));g<a.xmax;)g+=this.m_width360}else{let e=Math.ceil((g-a.xmax)/this.m_width360);for(e*=this.m_width360;g<a.xmax+e;)e-=this.m_width360;for(;g>a.xmin+e;)e+=this.m_width360;for(m=e,a.width()>720&&(l=g-360*Math.ceil(a.width()/360));l>a.xmin;)l-=this.m_width360}const u=Math.round(Math.abs(r.x-n.x)/this.m_width360)*this.m_width360,c=i*u,_=a.clone();_.move(m,0);const d=new Qe(0,0),p=new jt;p.setShiftCoords(m,0),t.applyTransformation(p);const f=new I({vd:t.getDescription()});f.add(t,!1),d.assign(t.getXY(s-1));let x=0,y=f.getXY(0).x;for(;i>0?_.xmax<g:_.xmin>l;)_.move(c,0),p.xd=c,t.applyTransformation(p),y+=c,this.m_pannableExtent.xmin<=y&&this.m_pannableExtent.xmax>=y&&(x=f.getPointCount()-1),t.setXY(0,d),d.assign(t.getXY(s-1)),f.addSegmentsFromPath(t,0,0,s-1,!1);const P=new v({vd:f.getDescription()});P.add(f,!1);const E=f.getXY(0),S=f.getXY(f.getPointCount()-1),b=i<0?e:!e,w=P.getPointCount()-1;if(b){const e=new Qe(S.x,this.m_pannableExtent.ymax);P.lineTo(e);const t=new Qe(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);P.lineTo(t);const s=new Qe(E.x,this.m_pannableExtent.ymax);P.lineTo(s)}else{const e=new Qe(S.x,this.m_pannableExtent.ymin);P.lineTo(e);const t=new Qe(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);P.lineTo(t);const s=new Qe(E.x,this.m_pannableExtent.ymin);P.lineTo(s)}if(P.interpolateAttributesPath(0,w,0),P.getImpl().changeRingStartPoint(x),u>this.m_width360){const e=new v({copy:P});p.setShiftCoords(this.m_width360,0),e.applyTransformation(p),P.add(e,!1)}return P}finalizeGeoNormalizeClosedRing(e,t,n){const r=new v({vd:e.getDescription()});r.add(e,!1);const i=()=>{const e=r.getPointCount()-2;return r.getSegmentType(e)!==s.enumLine};if(r.hasNonLinearSegments()&&i()){const e=new F,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 o=C.constructEmpty();r.queryLooseEnvelope(o);let a=Math.ceil((this.m_pannableExtent.xmin-o.xmin)/this.m_width360);for(a*=this.m_width360;this.m_pannableExtent.xmin>o.xmin+a;)a+=this.m_width360;for(;this.m_pannableExtent.xmin<o.xmax+a;)a-=this.m_width360;if(a+=this.m_width360,0!==a){o.move(a,0);const e=new jt;e.setShiftCoords(a,0),r.applyTransformation(e)}if(this.m_pannableExtent.xmin<=o.xmin&&this.m_pannableExtent.xmax>=o.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();it(e)!==it(s)&&t.reverseAllPaths(),r.assignMove(t)}}let e;if(e=new v(n?{copy:r}:{move:r}),n)for(;o.xmin<this.m_pannableExtent.xmax;){o.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 h=new v({vd:e.getDescription()});h.add(r,!1);const m=t||o.width()>this.m_width360-10*this.m_pannableSR.getTolerance(0);for(;o.xmin<this.m_pannableExtent.xmax;){o.move(this.m_width360,0);const e=new jt;e.setShiftCoords(this.m_width360,0),r.applyTransformation(e),h.add(r,!1)}if(m){const e=h.calculateArea2D();h.setFillRule(1),h=(new Eh).execute(h,this.m_pannableSR,!0,this.m_progressTracker);const t=h.calculateArea2D();it(e)!==it(t)&&h.reverseAllPaths()}return h}geonormalize_ring_(e,t,s,n,r,i,a){o(0)}}function Vm(e){o(0);const t=ou(e),s=new km;return s.setVertProj_(t),s}function Fm(e,t=!0){return o(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 o(0),0}getID(){return o(0),0}getLatestID(){return this.m_peVertSysVal?this.m_peVertSysVal.getLatestID():0}getOldID(){return this.m_peVertSysVal?this.m_peVertSysVal.getOldID():0}getText(){return o(0),""}getTextExtended(e){return o(0),""}getText2(e){return o(0),""}getUnit(){return o(0),{}}equals(e){return o(0),!1}equalForProjection(e){return o(0),!1}getPeVertcsCopy(){return o(0),{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return o(0),0}isDepth(){return o(0),!1}getVerticalShift(){return o(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=he(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 st(this.m_heightSign,e.m_heightSign)&&st(this.m_heightMetersPerUnit,e.m_heightMetersPerUnit)&&st(this.m_heightZ0,e.m_heightZ0)&&st(this.m_XYToRadians,e.m_XYToRadians)&&st(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&&o(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 pe,this.m_inputUnitParams=Mm(),this.m_outputUnitParams=Mm(),o(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():(o(0),"")}getGeogtran(){return this.m_geogTran}getVerttran(){return null}loadConstants(e){let t=this.m_constantsLoaded;if(-1===t){if(!e){this.m_geogTran||r("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?Ze(this.m_latestID):ct(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():(g("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 o(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)o(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;ge(t,e,!1);let n=0;const r=e.getGeometryType();return i(r)&&b(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeAccelerator(s)?1:0),i(r)&&w(e)&&0!==s&&(n|=e.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),n>0}function Wm(e){return b(e)||w(e)}class jm extends Lm{getOperatorType(){return 8}execute(e,t,s,n){return kr(e,t,s,1,n)}}function Zm(t,r,i,o){if(t.isEmpty()||r.isEmpty())return t;const a=t.getDimension(),h=r.getDimension();if(a>h)return t;const m=t.getGeometryType(),l=r.getGeometryType(),g=new C,u=new C,c=new C;t.queryEnvelope(g),r.queryEnvelope(u),c.setCoords({env2D:g}),c.mergeEnvelope2D(u);const _=de(i,c,!0),d=ye(_),p=new C;if(p.setCoords({env2D:g}),p.inflateCoords(d,d),!p.isIntersecting(u))return t;if(1===a&&2===h){const e=ol(t,r,l,i,o);if(e)return e}if(m===s.enumPoint){let i;switch(n(l)?(i=new I({vd:r.getDescription()}),i.addSegment(r,!0)):i=r,l){case s.enumPolygon:return Jm(t,i,_);case s.enumPolyline:return $m(t,i,_);case s.enumMultiPoint:return el(t,i,_);case s.enumEnvelope:return tl(t,i,_);case s.enumPoint:return sl(t,i,_);default:e("invalid shape type")}}else if(m===s.enumMultiPoint)switch(l){case s.enumPolygon:return nl(t,r,_);case s.enumEnvelope:return rl(t,r,_);case s.enumPoint:return il(t,r,_)}const f=new C(g);f.inflate(100*_.total());return Ya(t,Zt(r,f,0,0,o),i,o)}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 v}next(){const e=this.m_inputGeoms.next();return e?(t(e),a(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,s,n){const r=e.getXY(),i=t.querySegmentIterator(),o=ye(s),a=o*o;for(;i.nextPath();)for(;i.hasNextSegment();){const t=i.nextSegment(),n=new C;if(t.queryEnvelope(n),n.inflateCoords(o,o),!n.contains(r))continue;if(t.isIntersectingPoint(r,s.total()))return e.createInstance();let h=t.getStartXY();if(Qe.sqrDistance(r,h)<=a)return e.createInstance();if(h=t.getEndXY(),Qe.sqrDistance(r,h)<=a)return e.createInstance()}return e}function el(e,t,s,n){const r=t.getImpl().getAttributeStreamRef(0),i=t.getPointCount(),o=e.getXY(),a=ye(s),h=a*a,m=new Qe;for(let l=0;l<i;l++){r.queryPoint2D(2*l,m);if(Qe.sqrDistance(m,o)<=h)return e.createInstance()}return e}function tl(e,t,s,n){const r=new C;t.queryEnvelope(r),r.inflate(s.total());const i=e.getXY();return r.contains(i)?e.createInstance():e}function sl(e,t,s,n){const r=ye(s),i=r*r,o=e.getXY(),a=t.getXY();return Qe.sqrDistance(o,a)<=i?e.createInstance():e}function nl(e,t,s,n){const r=new C;t.queryEnvelope(r),r.inflate(s.total());const i=e.getPointCount();let o=!1;const a=Ke(i,!1),h=new Qe;for(let l=0;l<i;l++){if(e.queryXY(l,h),!r.contains(h))continue;0!==Lo(t,h,s.total())&&(o=!0,a[l]=!0)}if(!o)return e;const m=e.createInstance();for(let l=0;l<i;l++)a[l]||m.addPoints(e,l,l+1);return m}function rl(e,t,s,n){const r=new C;t.queryEnvelope(r),r.inflate(s.total());const i=e.getPointCount();let o=!1;const a=Ke(i,!1),h=new Qe;for(let l=0;l<i;l++)e.queryXY(l,h),r.contains(h)&&(o=!0,a[l]=!0);if(!o)return e;const m=e.createInstance();for(let l=0;l<i;l++)a[l]||m.addPoints(e,l,l+1);return m}function il(e,t,s,n){const r=e.getImpl().getAttributeStreamRef(0),i=e.getPointCount(),o=t.getXY();let a=!1;const h=Ke(i,!1),m=ye(s),l=m*m,g=new Qe;for(let c=0;c<i;c++){r.queryPoint2D(2*c,g);Qe.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,i){const o=new pe;e.queryEnvelope(o);const a=new C;t.queryEnvelope(a),o.merge(a);const h=.1*o.width(),m=.1*o.height();o.inflateCoords(h,m);const l=new v;l.addEnvelope(o,!1);const g=l.getImpl();if(n===s.enumPolygon){const e=t.getImpl();g.add(e,!0)}else g.addEnvelope(t,!0);return new Ih(l,r,-1,i).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 i=new $t([e,t]),o=new gl(i,s,n,0).next();return o||r("null output"),o}}function hl(){return{geom:null,vertexCount:-1,bUnioned:!1,location:new Qe}}function ml(e,t){return Qe.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=Je(4),this.m_dimGeomCounts=Ke(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=Ke(4,!1),this.m_complexUnionGeoms=Je(4),this.m_totalNonEmptyGeomCounters=Ke(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?o(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)&&r(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===s.enumPoint){const e=new N({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,n){let r=t;if(!n)return 16&this.m_options?(r=ja([r],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),r):r;if(1&this.m_options)return r;if(1===e){if(!(8&this.m_options)&&(!!(16&this.m_options)||this.m_totalNonEmptyGeomCounters[e]>1)){r=ja([r],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const e=[0],t=r.getImpl().getIsSimple(0,e);o(this.m_bIs3D||ce(t))}else 1===this.m_totalNonEmptyGeomCounters[e]&&(this.m_bIs3D?o(0):r=(new Eh).execute(r,this.m_spatialReference,!1,this.m_progressTracker))}else this.m_bIs3D?o(0):r=(new Eh).execute(r,this.m_spatialReference,!1,this.m_progressTracker);if(0===e&&r.getGeometryType()===s.enumPoint){const e=new N({vd:r.getDescription()});r.isEmpty()||e.add(r),r=e}return r}static getLevel(e){const t=4,s=m(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&&(o(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,s){const n=hl();n.geom=s;const r=m(s);n.vertexCount=r;const i=C.constructEmpty();s.queryEnvelope(i),n.location=r>0?i.getCenter():new Qe(0,0);const o=gl.getLevel(s);if(e+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,e+1);)this.m_unionBins.push(new Map);let a=null;const h=this.m_unionBins[e].get(o);h&&(a=h),null===a&&(a=new ll,this.m_unionBins[e].set(o,a)),n.bUnioned=t,a.addPair(n),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);$e(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(s){this.m_bIs3D&&(s.getDimension()>1&&l(),s.hasAttribute(1)||e("Geometry must have Zs")),t(s)}}class ul extends Lm{getOperatorType(){return 3}execute(e,t,s,n=null){return kr(e,t,s,4,n)}}function cl(e,t,s){const n=t.getGCSSplitLines();if(null===n)return e;const r=t.getGCS(),i=r.getPannableExtent().width(),o=C.constructEmpty();e.queryLooseEnvelope(o);const a=at.constructEmpty();o.queryIntervalX(a);const h=n.querySegmentIterator();let m=null;const l=new jt;for(;h.nextPath();)for(;h.hasNextSegment();){const e=h.nextSegment(),t=e.queryInterval(0,0),s=at.constructEmpty();s.setCoordsFromEnvelope(t);let n=0;for(;s.vmax>a.vmin;)s.move(-i),n--;for(;s.vmin<=a.vmax;){if(s.isIntersecting(a)){null===m&&(m=new I);const t=new H({start:e.getStartXY(),end:e.getEndXY()});0!==n&&(l.setShiftCoords(n*i,0),t.applyTransformation(l)),m.addSegment(t,!0)}s.move(i),++n}}if(null!==m){const t=me(r,m,!0);return Un(e,m,ye(t),s)}return e}function _l(e,t,s){let n=e.getName();return ic(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 o(0),""}function pl(t,s=-1){if((s>1||s<-1)&&e("verbosity"),-1===s)return t.toString();{const e=0===s?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL;return t.toString(e)}}function fl(t,s){(s>1||s<-1)&&e("verbosity");let n=bc.PE_STR_FMT_WKT2;return-1!==s&&(n|=0===s?bc.PE_STR_AUTH_TOP:bc.PE_STR_AUTH_ALL),t.toString(n)}function xl(e){return o(0),""}function yl(e){return e.toLocaleUpperCase("en-US")}function Pl(t,n,r){const i=t.getPCSHorizon();if(i.getGeometryType()===s.enumPolygon){const e=t.getDefaultPrecisionSR().getTolerance(0),s=i;for(let t=0;t<r;t++)1!==Lo(s,n[t],e)&&n[t].setNAN();return}if(i.getGeometryType()===s.enumEnvelope){const e=i;for(let t=0;t<r;t++)e.contains(n[t])||n[t].setNAN();return}e("")}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,o){if(e.isEmpty()||1===n)return e;const a=e.getGeometryType();if(a===s.enumPoint){const s=e,r=s.getXY();return 0===wl([r],1,t,n)||r.isNAN()?s.setEmpty():s.setXY(r),e}if(a===s.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 fe,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 h=e;const m=t.getOneDegreeGCSUnit(),l=90*m,g=180*m,u=360*m,c=t.getCentralMeridian(),_=.5*m,d=C.constructEmpty();h.queryEnvelope(d);const p=t.getGCSHorizon(),f=t.getGCSHorisonIsInclusive(),x=p.getGeometryType()===s.enumEnvelope,y=C.constructEmpty();p.queryEnvelope(y);const P=t.getGCS();if(2!==n&&4!==n||(y.xmin=c-g,y.xmax=y.xmin+u),4===n){if(!(d.width()>u-m)){const e=C.constructEmpty();e.setCoords({xmin:d.xmin-m,ymin:y.ymin,xmax:d.xmax+m,ymax:y.ymax}),h=(new Kt).execute(h,e,P,o);let t=Math.floor((c-d.getCenterX())/u);for(d.move(t*u,0);d.xmin>y.xmax;)t-=1,d.move(-u,0);for(;d.xmin<y.xmin;)t+=1,d.move(u,0);if(0!==t){const e=new jt;e.setShiftCoords(t*u,0),h.applyTransformation(e)}return h}n=2}if(2===n&&(y.xmin=c-g,y.xmax=y.xmin+u),d.ymin<-l||d.ymax>l){const e=C.constructEmpty();if(e.setCoords({xmin:d.xmin-m,ymin:-l,xmax:d.xmax+m,ymax:l}),h=(new Kt).execute(h,e,P,o),h.isEmpty())return h;h.queryEnvelope(d)}if(f&&(y.ymax<d.ymin||y.ymin>d.ymax))return h.createInstance();d.width()>u&&(h=ql(h,c-g,u,P,!0,0,!0,o),h.queryEnvelope(d));let E=Ul(d.xmin,d.xmax,y.xmin,y.xmax,u);if(0!==E&&d.move(E,0),d.xmax>y.xmax||d.xmin<y.xmin){if(d.xmax>y.xmax)for(;d.xmin>=y.xmax;)d.move(-u,0),E-=u;for(;d.xmin<y.xmax-u;)d.move(u,0),E+=u}const S=ge(P,p,!1);if(0!==E){const e=new jt;e.setShiftCoords(E,0),h.applyTransformation(e),E=0}if(f){if(x&&y.containsEnvelope(d))return h;const e=new Array(2);for(let t=0;t<2;t++){let s;if(x?s=i(a)?Zt(h,y,S,_,o):Zt(h,y,S,0,o):(s=(new wh).execute(h,p,P,o),s===p&&(s=s.clone())),y.xmin<=d.xmin&&y.xmax>=d.xmax)return s;if(y.xmin>=d.xmin&&y.xmax<=d.xmax)return s;if(e[t]=s,0===t){d.move(-u,0);const e=new jt;e.setShiftCoords(-u,0),h.applyTransformation(e)}}return i(a)?e[0].add(e[1],!1):r("intersect_with_GCS_horizon: unexpected geometry type"),e[0]}{if(y.ymax<d.ymin||y.ymin>d.ymax)return h;let e=0;for(;!h.isEmpty()&&d.xmax>y.xmin;){if(0!==e){const t=new jt;t.setShiftCoords(e,0),h.applyTransformation(t)}if(!(new ul).execute(h,p,P,o)){h=(new Km).execute(h,p,P,o),p===h&&(h=h.clone())}if(0!==e){const t=new jt;t.setShiftCoords(-e,0),h.applyTransformation(t)}e-=u,d.move(-u,0)}return h}}function Cl(e,t,s,n,r,i){const o={stack:[],error:void 0,hasError:!1};try{if(2===i){return Gs(e,t,s,n,r)}if(Math.abs(s.x-n.x)>=Math.PI||!Fg(s.x,n.x,r))return Number.NaN;s.x>n.x&&(n=rt(s,s=n));const a=zt(o,new Cc,!1),h=zt(o,new Cc,!1),m=zt(o,new Cc,!1),l=s.clone();Dc.geodeticDistance(e,t,s.x,s.y,n.x,n.y,h,a,null,i);const g=h.val;let u=0,c=1;for(;g*(c-u)>1e-12*e;){const o=.5*(u+c);if(Dc.geodeticCoordinate(e,t,s.x,s.y,g*o,a.val,h,m,i),l.x=h.val,l.y=m.val,l.x===r)return l.y;if(Fg(s.x,l.x,r))c=o;else{if(!Fg(n.x,l.x,r))return Number.NaN;u=o}}return l.y}catch(a){o.error=a,o.hasError=!0}finally{Wt(o)}}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 i=Il(e,t);if(2===r){const s=n.getPannableExtentInGCS();let r=t;for(let e=0,n=2*t;e<n;e+=2)(i[e+1]>s.ymax||i[e+1]<s.ymin)&&(i[e]=Number.NaN,r--);return r?(Bl(i,t,s.xmin,s.width(),!0),e!==i&&bl(i,e,0,t),r):(e!==i&&bl(i,e,0,t),0)}const o=n.getOneDegreeGCSUnit(),a=90*o,h=180*o,m=360*o;let l=t;for(let s=0,p=2*t;s<p;s+=2)(i[s+1]>a||i[s+1]<-a)&&(i[s]=Number.NaN,l--);if(!l)return e!==i&&bl(i,e,0,t),0;const g=C.constructEmpty();g.setFromPoints(i,t);const u=n.getGCSHorizon(),c=n.getGCSHorisonIsInclusive(),_=u.getGeometryType()===s.enumEnvelope,d=C.constructEmpty();if(u.queryEnvelope(d),c&&(d.ymax<g.ymin||d.ymin>g.ymax))return e!==i&&bl(i,e,0,t),0;if(c){if(Bl(i,t,d.getCenterX()-h,m,!0),l=t,_)for(let e=0,s=2*t;e<s;e+=2)d.containsCoords(i[e],i[e+1])||(i[e]=Number.NaN,l--);else{const e=ge(n.getGCS(),u,!1),s=new Qe;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(i[n],i[n+1]);0!==Lo(u,s,e)||(i[n]=Number.NaN,l--)}}}else{Bl(i,t,-h,m,!0),l=t;const e=ge(n.getGCS(),u,!1),s=new Qe;for(let n=0,r=2*t;n<r;n+=2){s.setCoords(i[n],i[n+1]),s.isNAN()&&l--;const t=Ml(s.x,d.xmin,d.xmax,m);s.x+=t;0!==Lo(u,s,e)&&(i[n]=Number.NaN,l--)}}return e!==i&&bl(i,e,0,t),l}function vl(t,s,n,r,i,o){if(s.isPannable()||e("fold_into_360_degree_range"),t.isEmpty())return t;let a,h;if(2===s.getCoordinateSystemType()){const e=s.getPannableExtent();h=e.xmin,a=e.width()}else{const e=s.getOneDegreeGCSUnit();a=360*e,h=n-180*e}return ql(t,h,a,s,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=tt(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 G,o=i.addGeometry(e);return kl(i,o,t,ge(t,e,!1),s,n,r),i.getGeometry(o)}function kl(e,t,s,n,r,i,a){const h={stack:[],error:void 0,hasError:!1};try{o(Uu()),s.isPannable()||u("insert_geodetic_points");const m=s.getPannableExtent(),l=s.getGCS(),g=Hu();l.querySpheroidData(g);const c=l.getUnit().getUnitToBaseFactor(),_=g.majorSemiAxis,d=g.e2;let p=0;const f=new at;m.queryIntervalX(f);let x=null;const y=Ke(4,Number.NaN);2===s.getCoordinateSystemType()?(x=s.getPECoordSys(),i?(y[0]=Tl(a,f),y[1]=m.getCenterY(),wc.projToGeog(x,1,y),p=y[0]*c):(y[0]=m.getCenterX(),y[1]=a,wc.projToGeog(x,1,y),p=y[1]*c)):p=a*c,i||0===p||2===r||u("insert_geodetic_points: 1");const P=zt(h,new Cc,!1),E=new Qe,S=new Qe,C=new Qe,I=new Qe,b=new Qe,w=new Qe;for(let o=e.getFirstPath(t);o!==M;o=e.getNextPath(o)){const t=e.getFirstVertex(o);e.queryXY(t,C);let h=!1;const m=e.getNextVertex(t);for(let o=m;o!==M;o=e.getNextVertex(o)){if(o===m){if(h)break;h=!0}if(e.queryXY(o,I),i&&(n<a-C.x&&I.x-a>n||n<a-I.x&&C.x-a>n)||!i&&(0!==a||n<-C.y&&I.y>n||n<-I.y&&C.y>n))do{if(Math.abs(C.x-I.x)>=.5*f.width())break;2===s.getCoordinateSystemType()?(y[0]=Tl(C.x,f),y[1]=C.y,y[2]=Tl(I.x,f),y[3]=I.y,ag(x,2,y,0),b.x=y[0]*c,b.y=y[1]*c,w.y=y[3]*c):(b.x=C.x*c,b.y=C.y*c,w.y=I.y*c),w.x=(I.x-C.x)*Math.PI*2/f.width()+b.x;let t=0;const n=lt(Qe,2);if(i){if(S.x=p,S.y=Cl(_,d,b,w,p,r),Number.isNaN(S.y))break;n[0]=S,t=1}else if(2===r){const e=[0,0];if(t=Ds(_,d,b,w,p,e),!t)break;n[0].x=e[0],n[0].y=p,2===t&&(n[1].x=e[1],n[1].y=p)}else{if(S.x=Hg(_,d,b,w,r),Number.isNaN(S.x))break;S.y=0,n[0]=S,t=1}let h=-1;for(let m=0;m<t;m++){Dc.geodeticDistance(_,d,b.x,b.y,w.x,w.y,P,null,null,r);const t=P.val;Dc.geodeticDistance(_,d,b.x,b.y,n[m].x,n[m].y,P,null,null,r);const l=P.val;2===s.getCoordinateSystemType()?(y[0]=n[m].x/c,y[1]=n[m].y/c,wc.geogToProj(x,1,y),i?(E.y=y[1],E.x=a):(E.x=kg(y[0],C.x,I.x,f),E.y=a)):i?(E.x=a,E.y=n[m].y/c):(E.x=kg(n[m].x/c,C.x,I.x,f),E.y=a);const g=t>0?It(l/t,0,1):.5;if(0===g||1===g)continue;if(h>g)continue;const u=e.getPrevVertex(o);e.splitSegment(u,[g],1);const p=e.getNextVertex(u);e.setXYCoords(p,E.x,E.y),h=g}}while(0);C.setCoordsPoint2D(I)}}}catch(m){h.error=m,h.hasError=!0}finally{Wt(h)}}function Al(e,t){o(t.isPannable());const n=t.getPannableExtent();if(e.getGeometryType()===s.enumPoint){const t=e.getY();return n.ymin<=t&&t<=n.ymax?e:e.createInstance()}const r=C.constructEmpty();e.queryEnvelope(r);const i=C.constructEmpty();i.setCoords({env2D:n}),i.xmin=r.xmin,i.xmax=r.xmax,i.inflateCoords(.01*i.height(),0);const a=le(t,r,!1);let h;return h=i.containsEnvelope(r)?e:Zt(e,i,a,0,null),h}function Ml(e,t,s,n){return nt((.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,i,o,a,h){const m=e.getGeometryType(),l=at.constructEmpty();l.setCoords(t,t+n);const g=[0];if(m===s.enumPoint){const t=e;if(g[0]=t.getX(),Dl(g,l,a)){const t=i?e:e.clone();return t.setX(g[0]),t}return e}const u=C.constructEmpty();if(e.queryEnvelope(u),u.isEmpty())return e;if(m===s.enumMultiPoint){const t=i?e:e.clone(),s=t.getImpl(),n=s.getAttributeStreamRef(0),r=2*s.getPointCount();let o=!1;for(let e=0;e<r;e+=2)g[0]=n.read(e),Dl(g,l,a)&&(n.write(e,g[0]),o=!0);return o&&s.notifyModifiedFlags(2001),t}const c=at.constructEmpty();if(u.queryIntervalX(c),l.contains(c))return l.vmax,c.vmax,e;const _=C.constructEmpty();if(_.setCoords({env2D:u}),0===c.width()){let t=c.vmin;t+=Math.ceil((l.vmin-t)/n)*n,t=l.snapClip(t);const s=i?e:e.clone();return s.setAttributeBasic(0,0,t),s}if(m===s.enumEnvelope){const t=i?e:e.clone();return u.intersect(_),t.setEnvelope(u),t}const d=.1*Math.max(u.height(),u.width())*1;_.inflateCoords(0,d);let p=e;const f=r.getTolerance(0),x=new jt;for(;;){const e=Math.floor((c.vmin-t)/n),i=Math.ceil((c.vmax-t)/n);if(!(i-e>3))break;{const a=Math.floor(.5*(i+e));_.xmin=u.xmin-d,_.xmax=t+n*a;const l=Zt(p,_,f,o,h);_.xmin=_.xmax,_.xmax=u.xmax+d;const g=Zt(p,_,f,o,h);x.setShiftCoords((a-i)*n,0),g.applyTransformation(x),m===s.enumPolygon?p=(new al).execute(l,g,r,h):(p=l,p.add(g,!1)),p.queryEnvelope(u),u.queryIntervalX(c)}}_.xmin=t,_.xmax=t+n;const y=C.constructEmpty();y.setCoords({env2D:_}),y.inflateCoords(f,0);const P=Math.floor((u.xmin-_.xmin)/n)*n;let E;P?(_.move(P,0),x.setShiftCoords(-P,0)):x.setIdentity(),E=m===s.enumPolyline?new I({vd:p.getDescription()}):new v({vd:p.getDescription()});const S=C.constructEmpty(),b=C.constructEmpty();for(;u.xmax>_.xmin;){const e=Zt(p,_,f,0,h);e.queryEnvelope(b);let t=!1;t=m===s.enumPolyline?!e.isEmpty()&&(b.width()>f||b.height()>f):!e.isEmpty()&&(m!==s.enumPolygon||b.width()>f),t&&(e.applyTransformation(x),e.queryEnvelope(b),E.queryEnvelope(S),S.inflateCoords(f,f),S.isIntersecting(b)&&m===s.enumPolygon?E=(new al).execute(E,e,r,h):E.add(e,!1)),_.move(n,0),x.shiftCoords(-n,0)}return E}function Bl(e,t,s,n,r=!0){const i=new at;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,a=!0){if(e.isEmpty())return;const h=e.getGeometryType();if(!a||h!==s.enumPolygon)if(_(h)){let s=!1;if(i(h)&&e.hasNonLinearSegments()){const r=e.getImpl(),i=r.getAttributeStreamRef(0),a=r.getSegmentFlagsStreamRef();o(null!==a);for(let e=0,o=r.getPathCount();e<o;e++){let o=!0;const h=r.isClosedPath(e),m=r.getPathEnd(e);if(h&&r.getPathSize(e)>0){o=1===(31&a.read(m-1))}for(let l=r.getPathStart(e);l<m;l++){if(1===(31&a.read(l))){if(o){const e=i.read(2*l),r=Gl(e,t,n);r!==e&&(s=!0,i.write(2*l,r))}o=!0}else o=!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(h===s.enumEnvelope){const s=e,r=C.constructEmpty();s.queryEnvelope(r),r.xmin=Gl(r.xmin,t,n),r.xmax=Gl(r.xmax,t,n),s.setEnvelope(r)}else if(h===s.enumPoint){const s=e;s.setX(Gl(s.getX(),t,n))}else r("")}function Yl(e,t,s){const n=new Qe;return n.x=Gl(e.x,t,s),n.y=e.y,n}function Rl(e,t){if(t.isEmpty())return 0;const s=e.getPECoordSys();if(s.getProjection().getCode()===bc.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=Hu();e.querySpheroidData(n);const r=s.getParameters();if(null===r[bc.PE_PARM_LAM0])return 0;if(null===r[bc.PE_PARM_PHI0])return 0;const i=[r[bc.PE_PARM_LAM0].getValue(),r[bc.PE_PARM_PHI0].getValue()];wc.geogToProj(s,1,i);const o=new Qe(i[0],i[1]),a=C.constructEmpty();t.queryEnvelope(a);const h=lt(Qe,4);a.queryCorners(h);let m=0;const l=e.getOneMeter();let g=Math.max(n.majorSemiAxis,n.minorSemiAxis)*Math.PI,u=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;u-=g/180,g*=l,u*=l;for(let e=0;e<4;e++){const t=Qe.distance(h[e],o);if(t>g)m++;else if(t>u)return-1}if(0===m)return 1;if(4===m){const e=C.constructEmpty();return e.setCoords({center:o,width:g,height:g}),a.isIntersectingNe(e)?-1:0}return-1}return-1}function Xl(e,t,n,r){const i=e.getGeometryType();o(i===s.enumPolygon||i===s.enumPolyline||i===s.enumMultiPoint);const a=t.getCoordinateSystemType();if(2===a){let o=e;if(0===n){const n=Rl(t,e);if(0===n)return e.createInstance();if(1===n)return e;const i=t.getPCSHorizon(),a=i.getGeometryType(),h=t.getDefaultPrecisionSR();if(a===s.enumEnvelope){const s=C.constructEmpty();i.queryEnvelope(s);const n=le(h,s,!1);o=Zt(e,s,n,5e4*t.getOneMeterPCSUnit(),r)}else(new jm).execute(i,e,h,r)||(o=(new wh).execute(o,i,h,r),o===i&&(o=o.clone()))}else if(t.isPannable()){const e=C.constructEmpty();o.queryEnvelope(e);const a=t.getPannableExtent();a.containsEnvelope(e)||(Ol(o,a,t.getTolerance(0)),2!==n&&4!==n||(o=Al(o,t)),4!==n?o=vl(o,t,0,!0,1e5*t.getOneMeterPCSUnit(),r):i===s.enumPolygon&&e.width()>2*a.width()&&(o=ql(o,-2*a.width(),2*a.width(),t,!0,0,!0,r)))}return o}if(o(1===a),i===s.enumMultiPoint)return Ol(e,t.getPannableExtent(),t.getTolerance(0)),e;{const n=C.constructEmpty();e.queryEnvelope(n);let o=e;const a=t.getPannableExtent();if(n.ymin<a.ymin||n.ymax>a.ymax){const e=Math.max(1,n.calculateToleranceFromEnvelope()),s=new C(n.xmin-e,a.ymin,n.xmax+e,a.ymax);if(o=(new Kt).execute(o,s,t,r),o.isEmpty())return o}return i===s.enumPolygon&&n.width()>2*a.width()&&(o=ql(o,-2*a.width(),2*a.width(),t,!0,0,!0,r)),o}}function Ll(e,t,s,n,r,i){const a=n.getCoordinateSystemType();if(2===a){if(0===r)s!==e&&et(s,e,t),Pl(n,s,t);else if(s!==e&&et(s,e,t),n.isPannable()){const e=n.getTolerance(0);El(s,t,n.getPannableExtent(),e),Nl(s,t,n,0)}}else{o(1===a);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=it(r),m=t[s].x-h;i*it(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,s,n){const r=new N({vd:t.getDescription()});let i;r.addPoints(t,0,-1),i=(new qh).execute(r,e,n);const o=t.getPointCount();if(s.setEmpty(),e.getInputSR().isPannable()){if(o!==i.getPointCount())return!1;const n=new C;t.queryEnvelope(n);const r=new C;i.queryEnvelope(r);const a=n.width(),h=r.width();if(0!==a&&0!==h){const t=h/a,s=e.getOutputSR().getPannableExtent().width()/e.getInputSR().getPannableExtent().width();if(Math.abs(t/s-1)>1e-10)return!1}else if(0!==a||0!==h)return!1;s.add(t,!1);for(let e=0;e<o;e++){const t=i.getXY(e);s.setXY(e,t)}return!0}return!1}function Kl(e,t,s){o(!s||e.isPannable());const n=t.getPointCount();if(!n)return;const r=t.getImpl(),i=r.getAttributeStreamRef(0),a=e.getPECoordSys();let h=0;const m=i.readRange(0,2*n);let l=()=>{wc.geogToProj(a,n,m)};const g=e.isPannable()&&!s,u=g?e.getPannableExtent().width():0,c=179*u/360;if(e.isPannable()&&(h=e.getCentralMeridian(),s)){const t=e.m_peCoordSysVal.getGeogToProjFactors(),s=t.first,r=t.second;l=()=>{wc.geogToProj(a,n,m);for(let e=0;e<n;e++){const t=e<<1,n=i.read(t),o=s*(n-h)+r;m[t]=o}}}if(l(),g)for(let o=0;o<n;o++){const e=o<<1,t=m[e],s=it(t),n=i.read(e)-h;s*it(n)<0&&Math.abs(t)>c&&(m[e]+=-s*u)}i.writeRangeFromArray(0,2*n,m,!0,1),r.notifyModifiedFlags(2001)}function Ql(e,t,n){switch(t.getGeometryType()){case s.enumLine:return void Ig(e,t,n);case s.enumBezier:return void Gg(e,t,n);case s.enumEllipticArc:return void wg(e,t,n);case s.enumBezier2:return void Dg();case s.enumRationalBezier2:return void Vg();default:r("")}}function Jl(e,t,s){if(!t.hasNonLinearSegments())return void Kl(e,t,s);if(o(!s||e.isPannable()),t.isEmpty())return;const n=0,r=e.getPECoordSys(),i=e.isPannable(),a=i?e.getPannableExtent().width():0,h=179*a/360;let m=0;i&&(m=e.getCentralMeridian());const l=t.createInstance();l.reserveParts(t.getPointCount(),t.getPathCount());const g=t.getImpl(),u=new F;for(let o=0,c=t.getPathCount();o<c;++o)if(g.hasNonLinearSegmentsPath(o)){let t=!0,n=-1;const r=g.getPathStart(o),i=r+g.getSegmentCountPath(o);g.isClosedPath(o)&&(n=i-1);const a=new Qe;for(let o=r;o<i;++o){if(g.getSegmentBuffer(o,u,!1),Ql(e,u.get(),s),!t){u.get().getStartXY().equals(a)||u.get().moveTo(a)}if(o!==n)l.addSegment(u.get(),t);else{if(t){const e=new fe;u.get().queryStart(e),l.startPathPoint(e)}l.closeLastPathWithSegment(u.get())}a.assign(u.get().getEndXY()),t=!1}}else{const e=1024;let s,u=g.getPathSize(o),c=Math.min(u,e);l.insertPath(-1,t,o,!0);const _=g.getAttributeStreamRef(0),d=l.getAttributeStreamRef(0);for(let t=g.getPathStart(o),l=g.getPathEnd(o);t<l;){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=it(r),o=_.read(2*(n+e))-m;i*it(o)<0&&Math.abs(r)>h&&(s[t]+=-i*a)}d.writeRangeFromArray(t,c,s,!0,1),t+=c,u-=c,c=Math.min(u,e)}}t.assignMove(l)}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=it(n),i=o.read(2*(h+e));r*it(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,n){switch(n.getGeometryType()){case s.enumLine:return void tg(e,t,n);case s.enumBezier:return void rg(e,t,n);case s.enumEllipticArc:return void sg(e,t,n);case s.enumBezier2:return void ig();case s.enumRationalBezier2:return void og();default:r("")}}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=lt(Qe,4);s.queryControlPoints(n),vg(e,t,n,4),s.setControlPoints(n)}function ig(e,t,s){o(0)}function og(e,t,s){o(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;o(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 F;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 Qe;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 fe;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=it(r),m=c.read(2*s);h*it(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=it(o);m*it(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){o(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|=Ht(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=Ke(d,Number.NaN),f=Ke(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]=xt(P,i),f[s]=xt(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,n){switch(t.getGeometryType()){case s.enumLine:return xg(e,t,n);case s.enumBezier:return Eg(e,t,n);case s.enumEllipticArc:return yg(e,t,n);case s.enumBezier2:return Sg();case s.enumRationalBezier2:return Cg();default:r("")}}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 F;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 Qe;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 fe;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|=Ht(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|=Ht(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=Ke(f,Number.NaN),y=Ke(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=xt(E,r),y[s]=xt(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 o(0),0}function pg(e,t,s,n,r){o(null===n),o(t<2147483647);const i=Array.isArray(s);let a;a=i?qt(s):s;const h=vc.geogToGeog(e,t,a,null,r);return i&&Bt(a,s),h}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=lt(Qe,3),i=lt(Qe,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]=ft(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 Qe;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=ft(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=lt(Qe,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]=ft(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 o(0),!1}function Cg(e,t,s){return o(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,s,n){mg(e,t,s,n);const r=new C;r.setFromPoints(s,n);const i=e.getOneDegreeGCSUnit(),o=360*i,a=180*i;if(r.width()>a){for(let e=0;e<n;e++)for(;s[e].x<t;)s[e].x+=o;if(r.setFromPoints(s,n),r.xmax>a+t)for(let e=0;e<n;e++)s[e].x-=o}}function Ng(e,t,s,n,r){const i=lt(Qe,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=lt(Qe,4);t.queryControlPoints(n),bg(e,n,4,s),t.setControlPoints(n)}function Dg(e,t,s){o(0)}function Vg(e,t,s){o(0)}function Fg(e,t,s){const n=oe(e),r=oe(t),i=ie(n,r),o=ie(n,oe(s));return 0===o||(i>0&&o>0&&o<=i||i<0&&o<0&&o>=i)}function Hg(e,t,s,n,r){const i={stack:[],error:void 0,hasError:!1};try{const a=s.clone(),h=n.clone();if(2===r){const s=[0,0];return Ds(e,t,a,h,0,s),s[0]}if(a.y>h.y){const e=new Qe;e.assign(a),a.assign(h),h.assign(e)}const m=zt(i,new Cc,!1),l=zt(i,new Cc,!1),g=zt(i,new Cc,!1),u=new at;if(u.setCoords(a.y,h.y),!u.containsCoordinate(0)||Math.abs(a.x-h.x)>=Math.PI)return Number.NaN;if(a.x===h.x)return a.x;Dc.geodeticDistance(e,t,a.x,a.y,h.x,h.y,l,m,null,r);const c=l.val;let _=0,d=1;const p=a.clone();for(;c*(d-_)>1e-12*e;){const s=.5*(_+d);if(Dc.geodeticCoordinate(e,t,a.x,a.y,c*s,m.val,l,g,r),p.x=l.val,p.y=g.val,u.setCoords(a.y,p.y),0===p.y)return p.x;if(u.containsCoordinate(0))d=s;else{if(u.setCoords(h.y,p.y),!u.containsCoordinate(0))return o(!1),Number.NaN;_=s}}return p.x}catch(a){i.error=a,i.hasError=!0}finally{Wt(i)}}function kg(e,t,s,n){const r=new at;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(t,s=!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=Qe.getNAN(),this.m_southPole=Qe.getNAN(),this.m_polesUpdated=0,this.m_domain=C.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=C.constructEmpty(),this.m_pannableExtentGCS=C.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=t,this.m_WKID=Ic.getCode(t),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=_l(t,0,!0),this.m_hashCode=ct(this.m_canonicalWkt)):this.m_hashCode=_t(this.m_WKID);const n=this.m_peCoordSys.getType();this.m_csType=n===bc.PE_TYPE_PROJCS?2:1,o(n===bc.PE_TYPE_PROJCS||n===bc.PE_TYPE_GEOGCS),n===bc.PE_TYPE_PROJCS&&(t.loadConstants()||e("PeProjcs.loadConstants failed"));const i=n===bc.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();n!==bc.PE_TYPE_GEOGCS&&Ic.getCode(i),this.m_unit=ms(t),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(n===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||r("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 o(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,s=t.getGeogcs(),n=t.horizonGcsGenerate();if(!n)return;o(n.length>0);const r=n[0].getNump(),i=n[0].getKind();let a,h;e=n[0].getInclusive()>0;const m=this.getOneDegreeGCSUnit(),l=90*m,g=360*m,u=370*m,c=180*m*bc.PE_HORIZON_DELTA/Math.PI,_=C.constructEmpty();let d=null;if(r>1)for(let o=1;o<r;o++)if(n[o].getKind()===bc.PE_HORIZON_LINE){d||(d=new I);const e=n[o].getCoord();d.startPathCoords(e[0][0],e[0][1]),d.lineToCoords(e[1][0],e[1][1])}if(i===bc.PE_HORIZON_RECT){const t=n[0].getCoord();if(_.setFromPoints([new Qe(t[0][0],t[0][1]),new Qe(t[1][0],t[1][1])],2),Math.abs(_.ymax-l)<1e-7*c&&(_.ymax=l),Math.abs(_.ymin+l)<1e-7*c&&(_.ymin=-l),_.width()>u){const e=-400*m,t=e+5*g;_.setCoords({xmin:e,ymin:_.ymin,xmax:t,ymax:_.ymax})}const s=new pe({env2D:_});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=e)}else{let t=this.getPCSInfo().isGcsHorizonMultiOverlap();const i=Ru(s,null,null,1),u=[],c=new at;for(let e=0;e<r;e++){if(n[e].getKind()!==bc.PE_HORIZON_POLY)continue;a=n[e].getSize();const t=n[e].getCoord(),s=C.constructEmpty();s.setFromPoints(dt(t),a),u.push(new at(s.xmin,s.xmax)),s.width(),c.merge(u.at(-1))}let _=!1;const p=new at;c.width()>g&&u.length>1?(p.vmin=this.getCentralMeridian()-g,p.vmax=p.vmin+2*g,_=!0,t=!0):(p.vmin=c.vmin,p.vmax=p.vmin+g);const f=e=>{let t=0;for(;u[e].vmin+t<p.vmin;)t+=g;for(;u[e].vmax+t-g>p.vmin;)t-=g;return t};let x=new v;if(t){const e=new Ag,t=(new al).executeMany(e,i,null);for(let s=0;s<r;s++){if(n[s].getKind()!==bc.PE_HORIZON_POLY)continue;a=n[s].getSize();const r=n[s].getCoord();h=n[s].getInclusive()>0;const i=new v;if(i.addPathPoint2D(dt(r),a-1,!0),_){const t=f(s),n=u[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+=g,n.move(g)}while(n.vmin<p.vmax)}else e.tick(i),t.tock()}x=t.next()}else{x=new v;for(let t=0;t<r;t++){if(n[t].getKind()!==bc.PE_HORIZON_POLY)continue;a=n[t].getSize();const s=n[t].getCoord();if(h=n[t].getInclusive()>0,o(h===e),_){const e=new v;e.addPathPoint2D(dt(s),a-1,!0);const n=f(t),r=u[t].clone();r.move(n);let i=n;const o=new jt;do{if(0!==i){o.setShiftCoords(i,0);const t=new v({copy:e});t.applyTransformation(o),x.addPath(t,0,!0)}else x.addPath(e,0,!0);i+=g,r.move(g)}while(r.vmin<p.vmax)}else x.addPathPoint2D(dt(s),a-1,!0)}}_&&(x=(new Kt).execute(x,new C(p.vmin,-l-m,p.vmax,l+m),i,null)),e?(new wh).accelerateGeometry(x,i,1):(new Km).accelerateGeometry(x,i,1),(new ul).accelerateGeometry(x,i,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=x,this.m_bGCSHorisonIsInclusive=e,this.m_GCSSplitLines=d)}}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 s=e[0].getKind();e[0].getInclusive();const n=C.constructEmpty(),r=e[0].getNump();let i=!1;if(s===bc.PE_HORIZON_RECT){const s=e[0].getCoord();n.setFromPoints(dt(s),2),t=new pe({env2D:n})}else{let s=-1;for(let t=0;t<r;t++)e[t].getKind()===bc.PE_HORIZON_POLY&&(s=t);o(s>=0);const n=e[s].getSize()-1,a=e[s].getCoord(),h=new v;t=h,h.addPathPoint2D(dt(a),n,!0),i=!0}if(this.getPCSInfo().isDensificationNeeded()){o(s!==bc.PE_HORIZON_RECT);const e=1e5*this.getOneMeterPCSUnit();t=(new Jt).execute(t,e,0,0,null)}if(i){{const e=new pe;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(),s=e.getGeogcs();s||r("");const n=[t+1/s.getUnit().getUnitFactor()*Math.PI,0];wc.geogToProj(e,1,n);const i=n[0],o=e.getParameters()[bc.PE_PARM_X0].getValue(),a=this.getPCSHorizon(),h=C.constructEmpty();a.queryEnvelope(h);const m=Math.abs(i-o),l=m+o,g=-1*m+o,u=h.ymax,c=h.ymin;this.m_pannableExtent.setCoords({xmin:g,ymin:c,xmax:l,ymax:u})}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 r("")}updatePannableExtentGCS(){const e=this.m_peCoordSys.getType();if(e===bc.PE_TYPE_PROJCS){const e=this.m_peCoordSys,t=this.m_centralMeridian,s=e.getGeogcs();s||r("");const n=1/s.getUnit().getUnitFactor()*Math.PI,i=this.getGCSHorizon(),o=C.constructEmpty();i.queryEnvelope(o),this.m_pannableExtentGCS.setCoords({xmin:t-n,ymin:o.ymin,xmax:t+n,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 r("")}updateDomain(){if(1===this.m_csType){const e=400*this.getOneDegreeGCSUnit();this.m_domain=C.construct(-e,-e,e,e)}else{o(2===this.m_csType);const e=Nc.generate(this.m_peCoordSys,Nc.PE_PCSINFO_OPTION_DOMAIN);e||r("generate pcs info failed");const t=new C(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);o(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)||r("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,s){return Yg(e,t,C.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()||c("cannot create projection transformation");return t.hasVCS()&&s.hasVCS()?jg():Zg(t,s,n)}function Lg(e,t,s,n,r,i){return Uu()||c("cannot create projection transformation"),new eu(e?2:1,t,s,n,r,i)}function zg(t,s,n,r,i,o=!1){s&&n||e(""),Uu()||c("cannot obtain geotransformation list");if(1===t&&s.hasVCS()&&n.hasVCS())return g("hv xform not impl"),[];{const e=Qc(s,n,r,i,o),t=[];for(const s of e)t.push(s);return t}}function Wg(){return{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(e){return st(this.centralMeridianOfOutputGCS,e.centralMeridianOfOutputGCS)&&st(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 o(0),{}}function Zg(t,s,n,r){t&&s||e("!inputSR || !outputSR");const i=t.getLatestID(),o=s.getLatestID();if(3857===i&&4326===o){if(t.m_bDefaultDescriptor&&s.m_bDefaultDescriptor)return pu()}else if(4326===i&&3857===o&&t.m_bDefaultDescriptor&&s.m_bDefaultDescriptor)return fu();const a=C.constructEmpty();a.setCoords({env2D:n});const h=t.getCoordinateSystemType(),m=s.getCoordinateSystemType();if(0===h||0===m)return Kg(t,s);const l=t.getGCS().getLatestID(),g=s.getGCS().getLatestID();if(l>0&&l===g)return Kg(t,s);const u=new mu(t,s,n);{const e=gu(u);if(e)return e}const c=zg(0,t,s,a,1,!0);return uu(u,Kg(t,s,c.length?c[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(t,s,n,r,i,a){let h,m;this.m_datumTran=null,this.m_bIdentity=!0,this.m_bIdentityGeogToGeog=!0,this.m_bVertical=!1,this.m_bNormalize=!1,s&&n||e("!inputSR || !outputSR"),r&&0===r.getType()&&(r.m_bReadOnly=!0),this.m_bNormalize=!1,1!==t&&(h=s.getVCS(),m=n.getVCS(),this.m_bVertical=null!=h&&null!=m),this.m_inputSR=s,this.m_outputSR=n,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,o(!this.m_params),i&&(this.m_params=Jg(),this.m_params.m_extendedParams=i),a&&(this.m_params||(this.m_params=Jg()),this.m_params.m_extendedParamsInternal=a);let l=!1;const g=null!=r,u=s.getCoordinateSystemType(),c=n.getCoordinateSystemType();if(n.isPannable()&&0!==u&&i){const e=i.centralMeridianOfOutputGCS;if(!Number.isNaN(e)&&n.isPannable()){const t=n.getPannableExtent(),s=t.getCenterX();if(s!==e){const n=Math.ceil(t.width());e+n!==s+n&&(l=!0)}}}const _=i&&i.normalizeResultGeometry;if(s.equals(n))return this.m_bIdentity=!l,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const d=!g&&s.equalForProjection(n,this.m_bVertical);this.m_bIdentity=d&&!l,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 o(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(e,t){return o(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&&f(e);{const t=Iu(e);if(t)return t}const t=Hc(Ic.coordsys(e));t.get()||f(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()||S(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=je(this.m_hashCode,this.m_outputSR.getHashCode()),this.m_env.isEmpty()||(this.m_hashCode=je(this.m_hashCode,Ot(this.m_env.xmin)),this.m_hashCode=je(this.m_hashCode,Ot(this.m_env.xmax)),this.m_hashCode=je(this.m_hashCode,Ot(this.m_env.ymin)),this.m_hashCode=je(this.m_hashCode,Ot(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=Ke(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){o(n>>5<r.length);let i=t,a=s;for(let o=n;o>=0;o-=2){const t=31&o,s=.5*(a+i);e>=s?(r[o>>5]|=1<<t,i=s):a=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 o(Bu()),dc(e,void 0===t?0:t,null,!1)}function Yu(e,t){o(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(t,s,n,r,i){t||e("!PE_coord_sys");const o=new oc;let a;return a=i?ru(t):new qg(t,!1),uc(o.m_precisionDescriptor,a,s,r),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=s,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}function Lu(t,s,n=!1){3===t.getCoordinateSystemType()&&e("image spatial reference cannot be altered");const r=new oc,i=t;return r.m_peCoordSysVal=i.m_peCoordSysVal,r.m_vertcs=i.m_vertcs,r.m_unit=i.m_unit,r.m_precisionDescriptor.assign(s),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,n&&(r.m_bDefaultDescriptor=!0),r.calculateHashCode(),r.initDbgName(),r}function zu(e,t,s){return{}}function Wu(t,s,n){void 0===s&&(s=1),(s<=0||!Number.isFinite(s))&&e(""),t||1===s||e("null Unit has to have z_to_xy_factor equal to 1");const r=new oc;r.m_unit=t;const i=t||new bu(9001);return _c(r.m_precisionDescriptor,i,null,1),r.m_bDefaultDescriptor=!0,Number.isNaN(r.m_precisionDescriptor.m_falseX)&&e("NAN false X/Y are not allowed here"),r.m_localZToXYFactor=s,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&&o(0),e.getGCS())}function Ku(e){return o(Bu()),qu()?Bc(e):Eu(e)}function Qu(e){if(Uu()){return null!==Hc(Ic.fromString(bc.PE_TYPE_COORDSYS,e)).get()}try{return Ac(e),!0}catch(t){}return!1}let Ju;function $u(){return Ju||(Ju=(()=>{const e=Math.trunc(Math.random()*vt()),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,tc,sc,nc=0;function rc(e=""){let t=`${$u()}${nc++}`;return""!==e&&(t+=`|${e}`),t}function ic(e){return e.startsWith($u())}class oc{destroy(){hu(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():r("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=je(e,t),this.m_hashCode=je(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(),o(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 g("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return g("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(e){return this.throwIfNotGCSOrPCS(),o(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()):(u("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?xl():""}getVerticalUnit(){return g("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const e=this.getCoordinateSystemType();if(0===e)u(Vu);else{if(1===e)return this;3===e&&u("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let t;if(this===hc()||this===mc())t=lc();else{o(this.m_peCoordSysVal);const e=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();e||r(""),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(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(t,s){if(0===t.length)return 0;t.length>s.length&&e("coordsSrc.size() > coordsDst.size()");const n=this.getCoordinateSystemType();if(0===n&&u(Vu),1===n)return et(s,t,t.length),t.length;o(this.m_peCoordSysVal);const r=this.getSRToGCSTransform();return(new qh).transform(r,t,t.length,s)}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=tt(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=tt(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&&(o(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||e("!is_pannable"),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||e("!is_pannable"),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const t=this.getCoordinateSystemType();1!==t&&2!==t&&e("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),o(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()||c("cannot query precision descriptor"),o(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?g("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(o(!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;o(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 o(0),!1}equalVerticalVCS(e){return o(0),!1}convergenceAngle(e){return o(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const e=this.m_peCoordSysVal.m_peCoordSys;return e||r("cannot clone coord sys"),e}return null}getPeVertcsCopy(){return o(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&e(Vu)}getPrimeMeridian(){return this.throwIfLocal(),o(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(),o(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(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(e){this.throwIfNotGCSOrPCS(),o(this.m_peCoordSysVal);const t=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=t.getFlattening();ku(e,t.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&u(""),o(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(),o(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),o(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(_(t))return this.snapMultiVertex_(e);if(t===s.enumPoint)return this.snapPoint_(e);if(t===s.enumEnvelope)return this.snapEnvelope_(e);if(n(t))return this.snapSegment_(e);if(t===s.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}r("what else?")}snapMultiVertex_(e){if(o(!e.isEmpty()),o(2!==this.m_precisionDescriptor.getPrecision()),i(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){o(!e.isEmpty()),o(2!==this.m_precisionDescriptor.getPrecision());const t=new ac;this.queryPrecisionDescriptor(t);const s=e.getStartXY(),n=new Qe;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(),a=new Qe;a.x=pc(i.x,t.getFalseX(),t.getGridUnitsXY()),a.y=pc(i.y,t.getFalseY(),t.getGridUnitsXY()),r||=!a.equals(i),r&&e.changeEndPoints2D(n,a);const h=(t,s,n)=>{let r=!1;{const i=e.getStartAttributeAsDbl(t,0),o=pc(i,s,n),a=!st(o,i);r||=a,a&&e.setStartAttribute(t,0,o)}{const i=e.getEndAttributeAsDbl(t,0),o=pc(i,s,n),a=!st(o,i);r||=a,a&&e.setEndAttribute(t,0,o)}return r};let m=r?1:0;return e.hasAttribute(1)&&(m|=h(1,t.getFalseZ(),t.getGridUnitsZ())?1:0),e.hasAttribute(2)&&(m|=h(2,t.getFalseM(),t.getGridUnitsM())?1:0),!!m}snapGeometryWithCurves_(e){o(!e.isEmpty()),o(2!==this.m_precisionDescriptor.getPrecision());const t=e.createInstance(),s=new F;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 fe;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(e,t,s,n){let r=!1;const i=new ac;if(this.queryPrecisionDescriptor(i),0===e){const e=t;for(let t=s;t<n;t++){const s=e.read(2*t),n=oc.s_SnapValue(s,i.getFalseX(),i.getGridUnitsXY()),o=e.read(2*t+1),a=oc.s_SnapValue(o,i.getFalseY(),i.getGridUnitsXY());r=r||n!==s||a!==o,r&&(e.write(2*t,n),e.write(2*t+1,a))}}else if(1===e){const e=t;for(let t=s;t<n;t++){const s=e.read(t),n=oc.s_SnapValue(s,i.getFalseZ(),i.getGridUnitsZ());r=r||!st(n,s),r&&e.write(t,n)}}else if(2===e){const e=t;for(let t=s;t<n;t++){const s=e.read(t),n=oc.s_SnapValue(s,i.getFalseM(),i.getGridUnitsM());r=r||!st(n,s),r&&e.write(t,n)}}return r}static s_SnapValue(e,t,s){return nt((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=je(t,this.m_falseM),t=je(t,this.m_unitsM),e=je(e,this.m_unitsXY),t=je(t,this.m_toleranceXY),e=je(e,this.m_falseZ),t=je(t,this.m_toleranceZ),e=je(e,this.m_unitsZ),t=je(t,this.m_toleranceM),e=je(e,this.m_precision),je(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 C;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(),r("")}return e}getZGridRange(){const e=new at;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(),r("")}return e}getMGridRange(){const e=new at;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(),r("")}return e}setTolerance(t,s){switch(s<0&&e("tol < 0"),Number.isFinite(s)||e("tol is not finite"),t){case 0:this.m_toleranceXY=s;break;case 1:this.m_toleranceZ=s;break;case 2:this.m_toleranceM=s;break;default:e("cannot set tolerance for this attribute")}}setGridParams(t,s,n){Number.isFinite(t)&&Number.isFinite(s)&&Number.isFinite(n)||e("grid params are not finite"),n<1&&e("grid units cannot be smaller than 1.0"),this.m_falseX=t,this.m_falseY=s,this.m_unitsXY=n}setZParams(t,s){Number.isFinite(t)&&Number.isFinite(s)||e("grid params are not finite"),s<1&&e("grid units cannot be smaller than 1.0"),this.m_falseZ=t,this.m_unitsZ=s}setMParams(t,s){Number.isFinite(t)&&Number.isFinite(s)||e("grid params are not finite"),s<1&&e("grid units cannot be smaller than 1.0"),this.m_falseM=t,this.m_unitsM=s}setPrecision(e){}equals(e){return this===e||st(this.m_falseX,e.m_falseX)&&st(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(!ec||Uu()&&null===ec.getPECoordSys())&&(ec=dc(3857,0,null,!0)),ec}function mc(){return(!tc||Uu()&&null===tc.getPECoordSys())&&(tc=dc(102100,0,null,!0)),tc}function lc(){return(!sc||Uu()&&null===sc.getPECoordSys())&&(sc=dc(4326,0,null,!0)),sc}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*ht(),e.m_toleranceZ=100*ht(),e.m_toleranceM=100*ht(),e.m_precision=2}function uc(t,s,n,r){const i=s instanceof qg;gc(t),t.m_precision=r,t.m_falseX=Number.NaN,t.m_falseY=Number.NaN;const o=1e-4,a=.001,h=i?s.m_csType:s.isPCS?2:1;if(1===h){const e=(0===r?1/18e5:1e-9)*(i?s.getOneDegreeGCSUnit():Math.PI/s.metersOrRadiansPerUnit/180);t.m_unitsXY=1/e}else if(2===h){const e=(0===r?a:o)*(i?s.getOneMeterPCSUnit():1/s.metersOrRadiansPerUnit);t.m_unitsXY=1/e}else e("unrecognized cs type");t.m_falseM=-1e5,t.m_unitsM=1/(0===r?a:o),t.m_unitsM=Math.max(1,t.m_unitsM),t.m_unitsXY=Math.max(1,t.m_unitsXY);let m=0,l=0;0!==r&&1!==r||(m=2/t.m_unitsXY,l=2/t.m_unitsM),t.m_toleranceXY=Math.max(m,i?s.getUnitsPerMillimeter():2===h?.001/s.metersOrRadiansPerUnit:.001/(s.semiMajor*s.metersOrRadiansPerUnit)),t.m_toleranceM=Math.max(a,l),cc(t,n)}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 nt((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){o(kc);const t=kc(e);return t.semiMajor=t.isPCS?Number.NaN:Rc(e),t}function Mc(e){kc=e,o(kc)}function Uc(e){const t=e;Ic=t.PeFactory,o(Ic),Fc=t.PeGCSExtent,o(Fc),Dc=t.PeLineType,o(Dc),Vc=t.PeMath,o(Vc),Cc=t.PeDouble,o(Cc),bc=t.PeDefs,o(bc),wc=t.PeCSTransformations,o(wc),vc=t.PeGTTransformations,o(vc),Nc=t.PePCSInfo,o(Nc),Tc=t.PeGTlistExtended,o(Tc),Ic.initialize(),Gc=t.PeGTlistExtendedEntry,o(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){o(qu());return!!kc(e).isPCS||Oc(e)}function Oc(e){return Ic&&u("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(t){if(Ic&&u("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof t){const s=t.match(Yc);s&&2===s.length||e("bad gcs wkt");const n=Number.parseFloat(s[1]);return Number.isFinite(n)||e("bad gcs wkt"),n}return fc||Xc(),fc.has(t)||u("gcs wkid not found"),fc.get(t)}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||f(e);return new Kc(s,t)}function zc(e,t){const s=Ic.fromString(bc.PE_TYPE_GEOGTRAN,e);s||S(e);return new Kc(s,t)}function Wc(e,t){return new Kc(e,t)}const jc=Ze(0),Zc=Ze(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=je(this.m_geogTranWrapper.getHashCode(),this.m_bInverted?Zc:jc));this.m_geogTranWrapper=new Um(e),this.m_bInverted=t,this.m_hashCode=je(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(e,t,s,n,r){const i=e.getGCS(),a=t.getGCS(),h=i.getPECoordSys(),m=a.getPECoordSys();let l=null;if(!s.isEmpty()){const t=s.clone();if(!t.isEmpty()&&2===e.getCoordinateSystemType()){let s=new pe({env2D:t});const n=Rg(e,i,null);s=(new qh).execute(s,n,null),s.queryEnvelope(t)}if(!t.isEmpty()){const e=h.getPrimem().getLongitude(),s=h.getUnit().getUnitFactor();l=new Fc(t.xmin,t.ymin,t.xmax,t.ymax,e,s)}}let g=n;g>=vt()&&(g=0);const u=[];let c=Tc.PE_GTLIST_OPTS_COMMON;r||(c&=~Tc.PE_GTLIST_OPTS_USABLE);for(let _=0;_<2;_++){u.length=0;const e=g,t=Tc.getGTlist(h,m,2,c,l,e);let s=!1;if(t&&t.length>0)for(let i=0,a=t.length;i<a;i++){const e=$c([t[i]]);if(o(e),r&&e.referencesMissingData())s=!0;else if(u.push(e),n>0&&u.length===n)break}if(!s)break;0===g||(g=0)}return l&&l.destroy(),u}function Jc(){return new e_([],null,null,null)}function $c(e){o(null!==e);const t=new t_,s=e[0].getSteps();if(s){const n=e[0].getEntries();for(let e=0;e<s;e++){const s=0!==n[e].getDirection(),r=Wc(n[e].getGeogtran(),s);t.add(r)}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=je(e,this.m_transforms[t].getHashCode());return e}equals(e){return o(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 o(0),!1}validateTransformation(e,t){return o(0),!1}nameIsSet(){return o(0),!1}getInputSpatialReference(){return this.m_inputSr}getOutputSpatialReference(){return this.m_outputSr}getStep(e){return(e<0||e>this.count())&&E(""),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=rt(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 ae(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())&&E(""),this.m_transforms[e]}setStep(e,t){o(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){o(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}}export{t_ as $,Wg as A,Qg as B,zg as C,Eh as D,jm as E,ul as F,wh as G,Lo as H,Lm as I,kr as J,Km as K,al as L,ih as M,hh as N,qh as O,eu as P,da as Q,_a as R,oc as S,aa as T,Ka as U,Fa as V,fa as W,Ma as X,la as Y,Zn as Z,Ko as _,ac as a,Lc as a0,zc as a1,Jc as a2,Al as a3,Tl as a4,Zl as a5,Cc as a6,Dc as a7,wc as a8,ds as a9,Cs as aA,jl as aB,bc as aC,cl as aD,fg as aE,sr as aF,ir as aG,zm as aH,Wm as aI,ha as aJ,Ra as aK,ka as aL,er as aM,Sa as aN,ya as aO,pa as aP,nh as aQ,tn as aR,sn as aS,Ys as aT,Ic as aU,zl as aV,ks as aW,Hm as aX,ss as aY,Wl as aa,mg as ab,cs as ac,Xl as ad,ql as ae,Wo as af,Ps as ag,Vc as ah,Oh as ai,Yh as aj,as as ak,Ag as al,cm as am,kl as an,Pc as ao,um as ap,Lh as aq,zh as ar,Rh as as,Xh as at,_m as au,qs as av,Is as aw,vs as ax,Th as ay,Us as az,Yu as b,Ou as c,Ru as d,Wu as e,Lu as f,zu as g,Zu as h,rc as i,qu as j,Uu as k,Mu as l,Au as m,Bu as n,ic as o,Ku as p,Qu as q,Hu as r,ju as s,mc as t,lc as u,Og as v,hc as w,Rg as x,Yg as y,Lg as z};
|