@arcgis/core 6.0.0-next.54 → 6.0.0-next.55
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/WebScene.js +2 -2
- package/applications/Components/OrientedImageryViewer/shared/constants.js +1 -1
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/featureset/support/sqlUtils.js +1 -1
- package/arcade/validation/arcadeValidator.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0329fa3aa3403f1c243b.js +1 -0
- package/assets/esri/core/workers/chunks/{6602310c3fcd91fb6a2f.js → 07c8ac092e4b9e8d5b3c.js} +1 -1
- package/assets/esri/core/workers/chunks/0a97b1974367382cfdf5.js +1 -0
- package/assets/esri/core/workers/chunks/{db0a7671ab5cbe8afd72.js → 123661019bb69c53f2d3.js} +1 -1
- package/assets/esri/core/workers/chunks/{d14732a57c8e63948c60.js → 14259910f44c08fd5bbd.js} +1 -1
- package/assets/esri/core/workers/chunks/{1b41ba050cde068d2860.js → 193a73a2c7f4f8482c21.js} +1 -1
- package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +1 -0
- package/assets/esri/core/workers/chunks/{e507dfc4788295d9c244.js → 249a687ce1b6d0815242.js} +1 -1
- package/assets/esri/core/workers/chunks/{afb4dfb89fbc8a342cc5.js → 3354f1fa90f8ce4c8fde.js} +1 -1
- package/assets/esri/core/workers/chunks/{9b458b0d1627f22fdd93.js → 3b11e4d2e69b7aea1d65.js} +1 -1
- package/assets/esri/core/workers/chunks/41694ee8990e799da225.js +1 -0
- package/assets/esri/core/workers/chunks/{e592f2483db71230e8e5.js → 4401b3f8ebb658abe789.js} +1 -1
- package/assets/esri/core/workers/chunks/{12add2003631fa314f25.js → 5060be52a380fc4920f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2aa6be0b047a1b25a520.js → 53bbb9aa6e4e4a0a8121.js} +1 -1
- package/assets/esri/core/workers/chunks/{4707aedcc1b3bdf5e987.js → 5c34d49a6c9cc34b7626.js} +1 -1
- package/assets/esri/core/workers/chunks/69a09c6acb5ae03c67f6.js +1 -0
- package/assets/esri/core/workers/chunks/7b156905d168bf973518.js +1 -0
- package/assets/esri/core/workers/chunks/{e83806797979138fd22a.js → 844c593754b2692257f4.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d3e977f3b75474d7ebc.js → 846248697c398468d8e6.js} +1 -1
- package/assets/esri/core/workers/chunks/{f7e33d37dd11fb08f3f8.js → 97107e64407fa6825620.js} +1 -1
- package/assets/esri/core/workers/chunks/{032733b863426c5bde00.js → 9e508f930086d2ef5f22.js} +3 -3
- package/assets/esri/core/workers/chunks/{5118c7269b706089c88e.js → a05a2c2aaf0c288f9681.js} +1 -1
- package/assets/esri/core/workers/chunks/{817bf487df056da1e6ec.js → a116dd204921e7464944.js} +1 -1
- package/assets/esri/core/workers/chunks/{944f17e9c9f681b971fb.js → a12e2a345005189c64be.js} +1 -1
- package/assets/esri/core/workers/chunks/{15b3386ad92a0b4149b8.js → a24dc5350af001db417a.js} +1 -1
- package/assets/esri/core/workers/chunks/{10967a36c77c5188690d.js → a66d6298236d59a615db.js} +1 -1
- package/assets/esri/core/workers/chunks/{255f5b45c4d32f97f86c.js → ac0861014b3d2f1a1de2.js} +1 -1
- package/assets/esri/core/workers/chunks/ace210d313ce53f3ae10.js +1 -0
- package/assets/esri/core/workers/chunks/ae48ee283cfa5b3c14b0.js +1 -0
- package/assets/esri/core/workers/chunks/bbd8fcb0bbba7bde3d9b.js +1 -0
- package/assets/esri/core/workers/chunks/{ac8d38016e4bee37a77c.js → be0b8bb4f09aae6ff5de.js} +1 -1
- package/assets/esri/core/workers/chunks/d0659f1b0495734be4b3.js +1 -0
- package/assets/esri/core/workers/chunks/{b9a2b05ede02c305e865.js → d8ffb1502def5c85740b.js} +1 -1
- package/assets/esri/core/workers/chunks/{7dfe1e78d2e66de6be22.js → d9ef244019954d5a8a27.js} +1 -1
- package/assets/esri/core/workers/chunks/{95403bb27a4ea0a4b7b1.js → ddbfa664e69612295785.js} +1 -1
- package/assets/esri/core/workers/chunks/{c6d82397044e403a1f61.js → e61082f56c08abe54b3a.js} +1 -1
- package/assets/esri/core/workers/chunks/{55d28d3f5b8ced061e39.js → eaf73ce60f39a48ddd2a.js} +1 -1
- package/assets/esri/core/workers/chunks/ed2f2a5da830d058e339.js +1 -0
- package/assets/esri/core/workers/chunks/{944cb751c85d3a127f49.js → f52d081bbde5c95265cf.js} +1 -1
- package/assets/esri/core/workers/chunks/{1de9be7b65109c207bd5.js → fbd5f3b81cd9f061824d.js} +1 -1
- package/assets/esri/layers/raster/formats/blosc-wasm.wasm +0 -0
- package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
- package/basemapGallery/support/basemapCompatibilityUtils.js +1 -1
- package/chunks/CypherParser.js +1 -1
- package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/UnitFactory.js +1 -1
- package/chunks/blosc-wasm.js +2 -0
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/parquet.js +1 -1
- package/chunks/text.js +1 -1
- package/config.js +1 -1
- package/core/sql/SqlInterval.js +1 -1
- package/core/urlUtils.js +1 -1
- package/geometry/geometryEngine.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/support/Ellipsoid.js +1 -1
- package/geometry/support/curves/ellipticArc7Utils.js +1 -1
- package/geometry/support/geodesicConstants.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/effects/parser.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/parquet.js +1 -1
- package/layers/raster/datasets/ZarrRaster.js +1 -1
- package/layers/raster/datasets/wcsCoverageParser.js +1 -1
- package/layers/raster/formats/RasterCodec.js +1 -1
- package/layers/raster/formats/blosc.js +2 -0
- package/layers/support/BuildingFilter.js +1 -1
- package/layers/support/IntegratedMeshSemantics.js +1 -1
- package/layers/support/fieldUtils.d.ts +23 -87
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/layersMapping.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/legend/ActiveLayerInfo.js +1 -1
- package/libs/ajv/ajv.bundle-wrapper.js +1 -1
- package/package.json +4 -4
- package/renderers/types.d.ts +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
- package/smartMapping/statistics/support/attributeDensity.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/support/tests/serviceMockDependencies.js +1 -1
- package/symbols/cim/CIMEffects.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
- package/symbols/cim/rasterizingUtils.js +1 -1
- package/views/2d/PaddedViewState.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
- package/views/2d/engine/vectorTiles/constants.js +1 -1
- package/views/2d/engine/vectorTiles/style/geoJSONVectorTileUtils.js +1 -1
- package/views/2d/engine/webgl/effects/HighlightEffect.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/ParquetLayerView2D.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementVisualization.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/EnvironmentView.js +1 -1
- package/views/3d/focusAreaUtils.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/config.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolFactory.js +1 -1
- package/views/3d/layers/graphics/LabelInfo.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
- package/views/3d/layers/i3s/I3SNode.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/layers/support/Tiles3DLayerViewRegistration.js +1 -1
- package/views/3d/layers/support/selectTiles3DSpatialReference.js +1 -1
- package/views/3d/layers/support/uvUtils.js +1 -1
- package/views/3d/state/Constraints.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/RenderCoordsHelper.js +1 -1
- package/views/3d/support/SweptSphereVolume.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/elevationUpdateExtentUtils.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/support/hitTest.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/terrain/ExtentHelper.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TilingSchemeLogic.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
- package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/MapView.d.ts +1 -0
- package/views/SceneView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/ViewingMode.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileChartBoundsUtils.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/views/draw/DrawAction.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/helpMessageUtils.js +1 -1
- package/views/draw/support/managers/EditSessionManager.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/AddOrUpdatePart.js +1 -1
- package/views/layers/support/editableLayerViews.js +1 -1
- package/views/overlay/TextOverlayItem.js +1 -1
- package/views/support/DefaultsFromMap.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/support/spatialReferenceSupport.js +1 -1
- package/views/webgl/ShaderTranspiler.js +2 -2
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Legend/styles/card/ColorRamp.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Measurement.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageMeasurementWidget.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations.js +1 -1
- package/widgets/Weather/WeatherViewModel.js +1 -1
- package/widgets/Weather/css.js +1 -1
- package/widgets/Weather.js +1 -1
- package/assets/esri/core/workers/chunks/021bd07b9a3e70598840.js +0 -1
- package/assets/esri/core/workers/chunks/170e68624b71ac96de4a.js +0 -1
- package/assets/esri/core/workers/chunks/8a820e303941b351de81.js +0 -1
- package/assets/esri/core/workers/chunks/90d567e920b6982b402d.js +0 -1
- package/assets/esri/core/workers/chunks/97cdcedfe853280f6258.js +0 -1
- package/assets/esri/core/workers/chunks/9ebc6026934400fc1e1f.js +0 -1
- package/assets/esri/core/workers/chunks/b4a325dcf50e276751d7.js +0 -1
- package/assets/esri/core/workers/chunks/be5857b0d1b00faf430b.js +0 -1
- package/assets/esri/core/workers/chunks/cd9100a7c8309dfa7569.js +0 -1
- package/assets/esri/core/workers/chunks/e58f51618251f74aaafd.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import{diff as r}from"../../core/accessorSupport/diffUtils.js";import{EventedAccessor as i}from"../../core/Evented.js";import{clone as a}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as s}from"../../core/maybe.js";import{memoize as c}from"../../core/memoize.js";import{ignoreAbortErrors as l}from"../../core/promiseUtils.js";import u from"../../core/ReactiveSet.js";import{watch as d,syncAndInitial as f}from"../../core/reactiveUtils.js";import{createScreenPoint as p}from"../../core/screenUtils.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{pointEquals as h,pointNear as g}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{createCoordinateHelper as v}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as y,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as x,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import w from"../interactive/options/LabelOptions.js";import{isPoint as T}from"../interactive/sketch/constraints.js";import{getPointConstraint as E,getPolylineOrPolygonConstraint as D,pointToConstraintSpace as O,constraintSpaceToPoint as k}from"../interactive/sketch/constraintUtils.js";import{SnappingContext as A}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as j}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as M}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as N}from"../interactive/snapping/snappingUtils.js";import{defaultDrawingMode as P}from"./drawingModes.js";import{LegacyDrawManipulator as F}from"./LegacyDrawManipulator.js";const I=`crosshair`,L=`progress`,R=Symbol(),z=Symbol();let B=class extends i{constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new u,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new m,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=c(E),this._getPolylineOrPolygonConstraint=c(D),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new w,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,e.elevationInfo??(this.elevationInfo=_(!!e.hasZ))}initializePointer(){let e=this.view.inputManager?.latestPointerInfo;e!=null&&e.type!==`touch`&&this._updatePointer(e.location,e.id,e.type)}initialize(){let{geometryType:e,view:t,spatialReference:n}=this,i=`viewingMode`in t.state?t.state.viewingMode:2,a=e===`segment`||e===`multipoint`?`polyline`:e;this.coordinateHelper=v(this.hasZ,this.hasM,n),this._editGeometryOperations=new C(new x(a,this.coordinateHelper),i),this._snappingOperation=new M({view:t}),this.addHandles([d(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:e,constraint:t},n)=>{let{snappingOptions:r}=this;if(r&&(r.forceDisabled=t!=null&&T(t)),n!=null&&e===n.stagedPoint&&t!==n.constraint)return this._onKeyboardBasedChange();this._processCursor(e??this._screenToMap(this._stagedScreenPoint))},{equals:(e,t)=>e.stagedPoint===t.stagedPoint&&s(e.constraint,t.constraint)}),d(()=>this.view.viewpoint,(e,t)=>{e&&t&&r(e,t)&&this._onKeyboardBasedChange()})]),this._activePart=new S(n,i),this._editGeometryOperations.data.parts.push(this._activePart);let o=this.segmentLabels;o!=null&&(o.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(d(()=>this.labelOptions.enabled,e=>{o.visible=e},f))),this.addHandles(this._editGeometryOperations.on([`vertex-add`,`vertex-update`,`vertex-remove`],e=>{let t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),n=t.map(e=>e.coordinates),r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;h(r,this.firstVertex)||(this.firstVertex=r);let i=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;h(i,this.lastVertex)||(this.lastVertex=i);let a=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(h(a,this.secondToLastVertex)||(this.secondToLastVertex=a),this._processCursor(this.cursorVertex),e.type){case`vertex-add`:this.emit(e.type,{...e,added:n,vertices:t});break;case`vertex-update`:this.emit(e.type,{...e,updated:n,vertices:t});break;case`vertex-remove`:this.emit(e.type,{...e,removed:n,vertices:t})}}));let c=this._manipulator=new F({consumesClicks:!1,grabbableForEvent:e=>this.drawingMode!==`click`||e.pointerType===`touch`&&this._snappingEnabled&&this._pointerDownStates.size===1});this.manipulators.add(c),c.grabbable=e!==`point`&&e!==`multipoint`,this.addHandles([c.events.on(`immediate-click`,e=>this._onImmediateClick(e)),c.events.on(`immediate-double-click`,e=>this._onImmediateDoubleClick(e)),d(()=>this.drawingMode,()=>{this.removeHandles(R),this.addHandles(this._createManipulatorDragPipeline(c),R)},f),d(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:e})=>{c.cursor=e},f)]),N(this,()=>{let e=this.view.inputManager.latestPointerInfo?.type??`mouse`,t=this._getSnappingContext(e);if(this.snappingManager!=null){let e=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,t);this._updatingHandles.consumePromise(l(e))}})}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){let{_stagedPointerId:e,_manipulator:t}=this;return e!=null&&this._pointerDownStates.has(e)||t.grabbing||!t.interactive}get _snappingEnabled(){return this.snappingManager!=null&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){let e=this._updateAndGetEffectiveDrawSurface();return this.view.type===`3d`&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(e=>this.coordinateHelper.vectorToArray(e.pos))}get _constraint(){let{constraints:e,constraintsEnabled:t}=this;if(e&&t)switch(this.geometryType){case`point`:case`multipoint`:return this._getPointConstraint(e);case`polygon`:case`polyline`:return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,e)}}set drawingMode(e){this._set(`drawingMode`,e??P)}get effectiveCursor(){return this.loading?L:this._hideDefaultCursor?null:this.cursor||I}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return this.snappingManager==null?null:this.snappingManager.options}get spatialReference(){return this._get(`spatialReference`)??this.view.spatialReference}get cursorVertex(){return this._get(`cursorVertex`)}get visualizationCursorVertex(){return this._stagedPointerType===`mouse`?this.cursorVertex:null}get committableVertex(){let{cursorVertex:e,lastVertex:t,firstVertex:n,geometryType:r}=this;return r===`polygon`&&g(e,n)||g(e,t)?null:e}get updating(){return this.loading||this._updatingHandles.updating||!!this.segmentLabels?.updating}get geometryIncludingUncommittedVertices(){let{committedVertices:e,committableVertex:t,coordinateHelper:n}=this,r=e.slice();return t!=null&&r.push(n.pointToArray(t)),r}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();let{committableVertex:e}=this;e!=null&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e),this._activePart)}complete(e){let t=e?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();let{geometryType:n,numCommittedVertices:r}=this,i=n===`multipoint`&&r===0||n===`polyline`&&r<2||n===`polygon`&&r<3;(n===`segment`||n===`point`)&&this.commitStagedVertex(),this._createOperationCompleted=!i,(this.isCompleted||t)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit(`complete`,{vertices:this.committedVertices.map((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e})),aborted:t,type:`complete`}))}onInputEvent(e){switch(e.type){case`pointer-down`:this._pointerDownStates.add(e.pointerId);break;case`pointer-up`:this._pointerDownStates.delete(e.pointerId)}switch(e.type){case`pointer-move`:return this._onPointerMove(e);case`hold`:return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){this.snappingManager!=null&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(e){let t=a(this.cursorVertex),n=a(e),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),i=this._snapToClosingVertex(r),o=this._applyConstraints(i);g(t,o)||(this._set(`cursorVertex`,o),this.segmentLabels?.set(`stagedVertex`,o==null?null:this.coordinateHelper.pointToVector(o)),o==null||this._stagedPointerType!==`mouse`?this.emit(`cursor-remove`):this.emit(`cursor-update`,{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:`apply`,type:`vertex-update`}))}_snapToClosingVertex(e){if(e==null||this._isDragging||this.geometryType!==`polygon`||this.numCommittedVertices<=2)return e;let t=this._mapToScreen(e);if(!t)return e;let n=this._activePart;return this._vertexWithinPointerDistance(n.vertices[0].pos,t)?this.firstVertex:this._vertexWithinPointerDistance(n.vertices.at(-1).pos,t)?this.lastVertex:e}_createManipulatorDragPipeline(e){switch(this.drawingMode){case`click`:return this._createManipulatorDragPipelineClick(e);case`freehand`:return this._createManipulatorDragPipelineFreehand(e);case`hybrid`:return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return y(e,(e,t,n,r)=>{let i=r===`touch`&&this._snappingEnabled;if(this.isCompleted||!i)return;let{snappingStep:a,cancelSnapping:o}=j({predicate:()=>i,snappingManager:this.snappingManager,snappingContext:new A({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:r,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});n.next(e=>(i&&this.snappingManager!=null&&this.snappingManager.doneSnapping(),e)).next(o),t.next(this._screenToMapDragEventStep()).next(e=>(e.action===`start`&&(this._processCursor(e.mapStart),(this.geometryType===`segment`||i&&!this.numCommittedVertices)&&this.commitStagedVertex()),e)).next(b(this.view,this.elevationInfo)).next(...a).next(e=>(i&&(this._processCursor(e.mapEnd),e.action===`end`&&this.commitStagedVertex()),e)).next(e=>(e.action===`end`&&(this._stagedPointerType!==`mouse`&&this._snappingOperation.abort(),(this.geometryType===`segment`||this.geometryType===`point`)&&this.complete()),e))})}_createManipulatorDragPipelineFreehand(e){return y(e,(e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next(e=>(e.action===`start`&&(this._snappingOperation.abort(),this.committableVertex??this._processCursor(e.mapStart),this.geometryType===`segment`&&this.commitStagedVertex()),e)).next(e=>{switch(e.action){case`start`:case`update`:this._processCursor(e.mapEnd),(this.geometryType===`polygon`||this.geometryType===`polyline`)&&this.commitStagedVertex();break;case`end`:this.complete()}return e})})}_createManipulatorDragPipelineHybrid(e){return y(e,(e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next(e=>(e.action===`start`&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),z),this._processCursor(e.mapStart),this.commitStagedVertex()),e)).next(e=>{switch(e.action){case`start`:case`update`:this._processCursor(e.mapEnd),(this.geometryType===`polygon`||this.geometryType===`polyline`)&&this.commitStagedVertex();break;case`end`:this._stagedPointerType!==`mouse`&&this._snappingOperation.abort(),this.removeHandles(z),(this.geometryType===`segment`||this.geometryType===`point`)&&this.complete()}return e})})}get _drawAtFixedElevation(){let{constraintsEnabled:e,constraintZ:t,geometryType:n,numCommittedVertices:r}=this;return e?t!=null||n===`segment`&&r>0:(n===`segment`||n===`polygon`)&&r>0}_updateAndGetEffectiveDrawSurface(){let{constraintsEnabled:e,coordinateHelper:t,drawSurface:n,elevationDrawSurface:r,snapToSceneEnabled:i}=this;if(r==null)return n;if(!this.hasZ)return r.defaultZ=null,r;let a=this.elevationInfo?.mode,o=this.defaultZ,s=e||a===`absolute-height`;return i!=null&&(s=i),a===`on-the-ground`&&(s=!1),this._drawAtFixedElevation&&(o=(e?this.constraintZ:null)??t.getZ(this._activePart.vertices[0].pos),s=!1),s?n:(r.defaultZ=o,r)}_mapToScreen(e){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),this.drawingMode===`click`&&e.pointerType===`touch`&&this._snappingEnabled&&this._processCursor(e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if(!(e.pointerType===`mouse`&&e.button===2||this._manipulator.dragging))try{let{drawingMode:t,geometryType:n}=this;this._stagedPointerType=e.pointerType,this._stagedScreenPoint=e.screenPoint;let r=this._screenToMap(e.screenPoint);if(r==null||r==null||t===`freehand`&&n!==`point`&&n!==`multipoint`)return;if(this._snappingEnabled&&this.cursorVertex!=null||this._processCursor(r),this.committableVertex==null){this.complete();return}this.commitStagedVertex(),e.pointerType!==`mouse`&&this._processCursor(null),(t===`freehand`&&this.geometryType!==`multipoint`||n===`point`||n===`segment`&&this.numCommittedVertices===2||n===`segment`&&t===`hybrid`&&this.numCommittedVertices===1)&&this.complete()}finally{e.stopPropagation()}}_onImmediateDoubleClick(e){this._manipulator.dragging||this.geometryType===`point`||(this.complete(),e.stopPropagation())}_onPointerMove(e){let t=p(e.x,e.y);this._updatePointer(t,e.pointerId,e.pointerType)&&e.stopPropagation()}_updatePointer(e,t,n){return this._stagedScreenPoint=e,this._stagedPointerType=n,this._stagedPointerId=t,this._isDragging?(this._snappingOperation.abort(),!1):(this._processCursorMovementRelativeToSurface(e,n),!0)}_onKeyboardBasedChange(){this._stagedPointerType!==`mouse`||!this._stagedScreenPoint||this._stagedPointerId==null||this._isDragging?this._snappingOperation.abort():this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType)}_processCursorMovementRelativeToSurface(e,t){let n=this._snappingOperation,r=this._screenToMap(e),i=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(r==null){this._hideDefaultCursor=!0,this._processCursor(null),n.abort();return}this._hideDefaultCursor=!1;let a=this.snappingManager;if(a==null){this._processCursor(r),n.abort();return}let o=this._getSnappingContext(t);this._updatingHandles.consumePromise(l(n.snap({point:r,scenePoint:i},a,o)))}_applyConstraints(e){let{_constraint:t,constraints:n}=this;if(!e||!n||!t)return e;let{context:r}=n,i=O(e,r),a=i?t.closestTo(i):void 0;if(!a)return e;let o=k(a,e,r),s=this.view.type===`2d`||r.elevationInfo.mode!==`absolute-height`;return o!=null&&s&&this.constraintZ!=null&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(e){return e?this._updateAndGetEffectiveDrawSurface()?.screenToMap(e):null}_screenToMapDragEventStep(){let e=null;return t=>{if(t.action===`start`&&(e=this._screenToMap(t.screenStart)),e==null)return null;let n=this._screenToMap(t.screenEnd);return n==null?null:{...t,mapStart:e,mapEnd:n}}}_vertexWithinPointerDistance(e,t){let n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return n!=null&&V(n,t,25)}_getSnappingContext(e){let t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new A({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:t==null?null:{value:t,elevationInfo:this.elevationInfo},drawConstraints:this.constraints})}};e([t()],B.prototype,`_hideDefaultCursor`,void 0),e([t()],B.prototype,`_stagedPointerId`,void 0),e([t()],B.prototype,`_isDragging`,null),e([t()],B.prototype,`_snappingOperation`,void 0),e([t()],B.prototype,`_snappingEnabled`,null),e([t({constructOnly:!0})],B.prototype,`graphic`,void 0),e([t()],B.prototype,`constraintsEnabled`,void 0),e([t()],B.prototype,`constraints`,void 0),e([t()],B.prototype,`_constraint`,null),e([t()],B.prototype,`constraintZ`,void 0),e([t()],B.prototype,`defaultZ`,void 0),e([t()],B.prototype,`isDraped`,void 0),e([t({value:P})],B.prototype,`drawingMode`,null),e([t({constructOnly:!0})],B.prototype,`elevationDrawSurface`,void 0),e([t({constructOnly:!0})],B.prototype,`elevationInfo`,void 0),e([t({constructOnly:!0,type:w})],B.prototype,`labelOptions`,void 0),e([t({constructOnly:!0})],B.prototype,`geometryType`,void 0),e([t({constructOnly:!0})],B.prototype,`hasM`,void 0),e([t({constructOnly:!0})],B.prototype,`hasZ`,void 0),e([t()],B.prototype,`cursor`,void 0),e([t()],B.prototype,`effectiveCursor`,null),e([t()],B.prototype,`loading`,void 0),e([t({constructOnly:!0})],B.prototype,`manipulators`,void 0),e([t({constructOnly:!0})],B.prototype,`drawSurface`,void 0),e([t({constructOnly:!0})],B.prototype,`segmentLabels`,void 0),e([t({constructOnly:!0})],B.prototype,`snappingManager`,void 0),e([t({constructOnly:!0})],B.prototype,`snappingVisualizer`,void 0),e([t()],B.prototype,`snapToSceneEnabled`,void 0),e([t({constructOnly:!0})],B.prototype,`spatialReference`,null),e([t({readOnly:!0})],B.prototype,`cursorVertex`,null),e([t({readOnly:!0})],B.prototype,`visualizationCursorVertex`,null),e([t()],B.prototype,`committableVertex`,null),e([t()],B.prototype,`firstVertex`,void 0),e([t()],B.prototype,`lastVertex`,void 0),e([t()],B.prototype,`secondToLastVertex`,void 0),e([t()],B.prototype,`updating`,null),e([t({constructOnly:!0})],B.prototype,`view`,void 0),B=e([n(`esri.views.draw.DrawOperation`)],B);function V(e,t,n){let r=e.x-t.x,i=e.y-t.y;return r*r+i*i<=n}export{B as DrawOperation,I as defaultCursor,L as defaultLoadingCursor};
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import{diff as r}from"../../core/accessorSupport/diffUtils.js";import{EventedAccessor as i}from"../../core/Evented.js";import{clone as a}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as s}from"../../core/maybe.js";import{memoize as c}from"../../core/memoize.js";import{ignoreAbortErrors as l}from"../../core/promiseUtils.js";import u from"../../core/ReactiveSet.js";import{watch as d,syncAndInitial as f}from"../../core/reactiveUtils.js";import{createScreenPoint as p}from"../../core/screenUtils.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{pointEquals as h,pointNear as g}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{createCoordinateHelper as v}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as y,sceneSnappingAtLocation as b}from"../interactive/dragEventPipeline.js";import{EditGeometry as x,Part as S}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as C}from"../interactive/editGeometry/EditGeometryOperations.js";import w from"../interactive/options/LabelOptions.js";import{isPoint as T}from"../interactive/sketch/constraints.js";import{getPointConstraint as E,getPolylineOrPolygonConstraint as D,pointToConstraintSpace as O,constraintSpaceToPoint as k}from"../interactive/sketch/constraintUtils.js";import{SnappingContext as A}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as j}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as M}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as N}from"../interactive/snapping/snappingUtils.js";import{defaultDrawingMode as P}from"./drawingModes.js";import{LegacyDrawManipulator as F}from"./LegacyDrawManipulator.js";const I=`crosshair`,L=`progress`,R=Symbol(),z=Symbol();let B=class extends i{constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new u,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new m,this._stagedPointerId=null,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=c(E),this._getPolylineOrPolygonConstraint=c(D),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new w,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,e.elevationInfo??(this.elevationInfo=_(!!e.hasZ))}initializePointer(){let e=this.view.inputManager?.latestPointerInfo;e!=null&&e.type!==`touch`&&this._updatePointer(e.location,e.id,e.type)}initialize(){let{geometryType:e,view:t,spatialReference:n}=this,i=e===`segment`||e===`multipoint`?`polyline`:e;this.coordinateHelper=v(this.hasZ,this.hasM,n),this._editGeometryOperations=new C(new x(i,this.coordinateHelper),t.state.isGlobal),this._snappingOperation=new M({view:t}),this.addHandles([d(()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint}),({stagedPoint:e,constraint:t},n)=>{let{snappingOptions:r}=this;if(r&&(r.forceDisabled=t!=null&&T(t)),n!=null&&e===n.stagedPoint&&t!==n.constraint)return this._onKeyboardBasedChange();this._processCursor(e??this._screenToMap(this._stagedScreenPoint))},{equals:(e,t)=>e.stagedPoint===t.stagedPoint&&s(e.constraint,t.constraint)}),d(()=>this.view.viewpoint,(e,t)=>{e&&t&&r(e,t)&&this._onKeyboardBasedChange()})]),this._activePart=new S(n,t.state.isGlobal),this._editGeometryOperations.data.parts.push(this._activePart);let a=this.segmentLabels;a!=null&&(a.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(d(()=>this.labelOptions.enabled,e=>{a.visible=e},f))),this.addHandles(this._editGeometryOperations.on([`vertex-add`,`vertex-update`,`vertex-remove`],e=>{let t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),n=t.map(e=>e.coordinates),r=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getFirstVertex()?.pos)??null;h(r,this.firstVertex)||(this.firstVertex=r);let i=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.getLastVertex()?.pos)??null;h(i,this.lastVertex)||(this.lastVertex=i);let a=this.coordinateHelper.vectorToDehydratedPoint(this._activePart.segments.at(-1)?.leftVertex?.pos)??null;switch(h(a,this.secondToLastVertex)||(this.secondToLastVertex=a),this._processCursor(this.cursorVertex),e.type){case`vertex-add`:this.emit(e.type,{...e,added:n,vertices:t});break;case`vertex-update`:this.emit(e.type,{...e,updated:n,vertices:t});break;case`vertex-remove`:this.emit(e.type,{...e,removed:n,vertices:t})}}));let o=this._manipulator=new F({consumesClicks:!1,grabbableForEvent:e=>this.drawingMode!==`click`||e.pointerType===`touch`&&this._snappingEnabled&&this._pointerDownStates.size===1});this.manipulators.add(o),o.grabbable=e!==`point`&&e!==`multipoint`,this.addHandles([o.events.on(`immediate-click`,e=>this._onImmediateClick(e)),o.events.on(`immediate-double-click`,e=>this._onImmediateDoubleClick(e)),d(()=>this.drawingMode,()=>{this.removeHandles(R),this.addHandles(this._createManipulatorDragPipeline(o),R)},f),d(()=>({effectiveCursor:this.effectiveCursor}),({effectiveCursor:e})=>{o.cursor=e},f)]),N(this,()=>{let e=this.view.inputManager.latestPointerInfo?.type??`mouse`,t=this._getSnappingContext(e);if(this.snappingManager!=null){let e=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,t);this._updatingHandles.consumePromise(l(e))}})}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _isDragging(){let{_stagedPointerId:e,_manipulator:t}=this;return e!=null&&this._pointerDownStates.has(e)||t.grabbing||!t.interactive}get _snappingEnabled(){return this.snappingManager!=null&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){let e=this._updateAndGetEffectiveDrawSurface();return this.view.type===`3d`&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activePart.vertices.map(e=>this.coordinateHelper.vectorToArray(e.pos))}get _constraint(){let{constraints:e,constraintsEnabled:t}=this;if(e&&t)switch(this.geometryType){case`point`:case`multipoint`:return this._getPointConstraint(e);case`polygon`:case`polyline`:return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,e)}}set drawingMode(e){this._set(`drawingMode`,e??P)}get effectiveCursor(){return this.loading?L:this._hideDefaultCursor?null:this.cursor||I}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activePart.vertices.length}get snappingOptions(){return this.snappingManager==null?null:this.snappingManager.options}get spatialReference(){return this._get(`spatialReference`)??this.view.spatialReference}get cursorVertex(){return this._get(`cursorVertex`)}get visualizationCursorVertex(){return this._stagedPointerType===`mouse`?this.cursorVertex:null}get committableVertex(){let{cursorVertex:e,lastVertex:t,firstVertex:n,geometryType:r}=this;return r===`polygon`&&g(e,n)||g(e,t)?null:e}get updating(){return this.loading||this._updatingHandles.updating||!!this.segmentLabels?.updating}get geometryIncludingUncommittedVertices(){let{committedVertices:e,committableVertex:t,coordinateHelper:n}=this,r=e.slice();return t!=null&&r.push(n.pointToArray(t)),r}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();let{committableVertex:e}=this;e!=null&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e),this._activePart)}complete(e){let t=e?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();let{geometryType:n,numCommittedVertices:r}=this,i=n===`multipoint`&&r===0||n===`polyline`&&r<2||n===`polygon`&&r<3;(n===`segment`||n===`point`)&&this.commitStagedVertex(),this._createOperationCompleted=!i,(this.isCompleted||t)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit(`complete`,{vertices:this.committedVertices.map((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e})),aborted:t,type:`complete`}))}onInputEvent(e){switch(e.type){case`pointer-down`:this._pointerDownStates.add(e.pointerId);break;case`pointer-up`:this._pointerDownStates.delete(e.pointerId)}switch(e.type){case`pointer-move`:return this._onPointerMove(e);case`hold`:return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){this.snappingManager!=null&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(e){let t=a(this.cursorVertex),n=a(e),r=n&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(n)??n),i=this._snapToClosingVertex(r),o=this._applyConstraints(i);g(t,o)||(this._set(`cursorVertex`,o),this.segmentLabels?.set(`stagedVertex`,o==null?null:this.coordinateHelper.pointToVector(o)),o==null||this._stagedPointerType!==`mouse`?this.emit(`cursor-remove`):this.emit(`cursor-update`,{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activePart.vertices.length,coordinates:this.coordinateHelper.pointToArray(o)}],operation:`apply`,type:`vertex-update`}))}_snapToClosingVertex(e){if(e==null||this._isDragging||this.geometryType!==`polygon`||this.numCommittedVertices<=2)return e;let t=this._mapToScreen(e);if(!t)return e;let n=this._activePart;return this._vertexWithinPointerDistance(n.vertices[0].pos,t)?this.firstVertex:this._vertexWithinPointerDistance(n.vertices.at(-1).pos,t)?this.lastVertex:e}_createManipulatorDragPipeline(e){switch(this.drawingMode){case`click`:return this._createManipulatorDragPipelineClick(e);case`freehand`:return this._createManipulatorDragPipelineFreehand(e);case`hybrid`:return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return y(e,(e,t,n,r)=>{let i=r===`touch`&&this._snappingEnabled;if(this.isCompleted||!i)return;let{snappingStep:a,cancelSnapping:o}=j({predicate:()=>i,snappingManager:this.snappingManager,snappingContext:new A({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:r,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});n.next(e=>(i&&this.snappingManager!=null&&this.snappingManager.doneSnapping(),e)).next(o),t.next(this._screenToMapDragEventStep()).next(e=>(e.action===`start`&&(this._processCursor(e.mapStart),(this.geometryType===`segment`||i&&!this.numCommittedVertices)&&this.commitStagedVertex()),e)).next(b(this.view,this.elevationInfo)).next(...a).next(e=>(i&&(this._processCursor(e.mapEnd),e.action===`end`&&this.commitStagedVertex()),e)).next(e=>(e.action===`end`&&(this._stagedPointerType!==`mouse`&&this._snappingOperation.abort(),(this.geometryType===`segment`||this.geometryType===`point`)&&this.complete()),e))})}_createManipulatorDragPipelineFreehand(e){return y(e,(e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next(e=>(e.action===`start`&&(this._snappingOperation.abort(),this.committableVertex??this._processCursor(e.mapStart),this.geometryType===`segment`&&this.commitStagedVertex()),e)).next(e=>{switch(e.action){case`start`:case`update`:this._processCursor(e.mapEnd),(this.geometryType===`polygon`||this.geometryType===`polyline`)&&this.commitStagedVertex();break;case`end`:this.complete()}return e})})}_createManipulatorDragPipelineHybrid(e){return y(e,(e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next(e=>(e.action===`start`&&(this._snappingOperation.abort(),this.addHandles(this._editGeometryOperations.createUndoGroup(),z),this._processCursor(e.mapStart),this.commitStagedVertex()),e)).next(e=>{switch(e.action){case`start`:case`update`:this._processCursor(e.mapEnd),(this.geometryType===`polygon`||this.geometryType===`polyline`)&&this.commitStagedVertex();break;case`end`:this._stagedPointerType!==`mouse`&&this._snappingOperation.abort(),this.removeHandles(z),(this.geometryType===`segment`||this.geometryType===`point`)&&this.complete()}return e})})}get _drawAtFixedElevation(){let{constraintsEnabled:e,constraintZ:t,geometryType:n,numCommittedVertices:r}=this;return e?t!=null||n===`segment`&&r>0:(n===`segment`||n===`polygon`)&&r>0}_updateAndGetEffectiveDrawSurface(){let{constraintsEnabled:e,coordinateHelper:t,drawSurface:n,elevationDrawSurface:r,snapToSceneEnabled:i}=this;if(r==null)return n;if(!this.hasZ)return r.defaultZ=null,r;let a=this.elevationInfo?.mode,o=this.defaultZ,s=e||a===`absolute-height`;return i!=null&&(s=i),a===`on-the-ground`&&(s=!1),this._drawAtFixedElevation&&(o=(e?this.constraintZ:null)??t.getZ(this._activePart.vertices[0].pos),s=!1),s?n:(r.defaultZ=o,r)}_mapToScreen(e){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),this.drawingMode===`click`&&e.pointerType===`touch`&&this._snappingEnabled&&this._processCursor(e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if(!(e.pointerType===`mouse`&&e.button===2||this._manipulator.dragging))try{let{drawingMode:t,geometryType:n}=this;this._stagedPointerType=e.pointerType,this._stagedScreenPoint=e.screenPoint;let r=this._screenToMap(e.screenPoint);if(r==null||r==null||t===`freehand`&&n!==`point`&&n!==`multipoint`)return;if(this._snappingEnabled&&this.cursorVertex!=null||this._processCursor(r),this.committableVertex==null){this.complete();return}this.commitStagedVertex(),e.pointerType!==`mouse`&&this._processCursor(null),(t===`freehand`&&this.geometryType!==`multipoint`||n===`point`||n===`segment`&&this.numCommittedVertices===2||n===`segment`&&t===`hybrid`&&this.numCommittedVertices===1)&&this.complete()}finally{e.stopPropagation()}}_onImmediateDoubleClick(e){this._manipulator.dragging||this.geometryType===`point`||(this.complete(),e.stopPropagation())}_onPointerMove(e){let t=p(e.x,e.y);this._updatePointer(t,e.pointerId,e.pointerType)&&e.stopPropagation()}_updatePointer(e,t,n){return this._stagedScreenPoint=e,this._stagedPointerType=n,this._stagedPointerId=t,this._isDragging?(this._snappingOperation.abort(),!1):(this._processCursorMovementRelativeToSurface(e,n),!0)}_onKeyboardBasedChange(){this._stagedPointerType!==`mouse`||!this._stagedScreenPoint||this._stagedPointerId==null||this._isDragging?this._snappingOperation.abort():this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType)}_processCursorMovementRelativeToSurface(e,t){let n=this._snappingOperation,r=this._screenToMap(e),i=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(r==null){this._hideDefaultCursor=!0,this._processCursor(null),n.abort();return}this._hideDefaultCursor=!1;let a=this.snappingManager;if(a==null){this._processCursor(r),n.abort();return}let o=this._getSnappingContext(t);this._updatingHandles.consumePromise(l(n.snap({point:r,scenePoint:i},a,o)))}_applyConstraints(e){let{_constraint:t,constraints:n}=this;if(!e||!n||!t)return e;let{context:r}=n,i=O(e,r),a=i?t.closestTo(i):void 0;if(!a)return e;let o=k(a,e,r),s=this.view.type===`2d`||r.elevationInfo.mode!==`absolute-height`;return o!=null&&s&&this.constraintZ!=null&&this.hasZ&&(o.z=this.constraintZ),o}_screenToMap(e){return e?this._updateAndGetEffectiveDrawSurface()?.screenToMap(e):null}_screenToMapDragEventStep(){let e=null;return t=>{if(t.action===`start`&&(e=this._screenToMap(t.screenStart)),e==null)return null;let n=this._screenToMap(t.screenEnd);return n==null?null:{...t,mapStart:e,mapEnd:n}}}_vertexWithinPointerDistance(e,t){let n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return n!=null&&V(n,t,25)}_getSnappingContext(e){let t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new A({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:t==null?null:{value:t,elevationInfo:this.elevationInfo},drawConstraints:this.constraints})}};e([t()],B.prototype,`_hideDefaultCursor`,void 0),e([t()],B.prototype,`_stagedPointerId`,void 0),e([t()],B.prototype,`_isDragging`,null),e([t()],B.prototype,`_snappingOperation`,void 0),e([t()],B.prototype,`_snappingEnabled`,null),e([t({constructOnly:!0})],B.prototype,`graphic`,void 0),e([t()],B.prototype,`constraintsEnabled`,void 0),e([t()],B.prototype,`constraints`,void 0),e([t()],B.prototype,`_constraint`,null),e([t()],B.prototype,`constraintZ`,void 0),e([t()],B.prototype,`defaultZ`,void 0),e([t()],B.prototype,`isDraped`,void 0),e([t({value:P})],B.prototype,`drawingMode`,null),e([t({constructOnly:!0})],B.prototype,`elevationDrawSurface`,void 0),e([t({constructOnly:!0})],B.prototype,`elevationInfo`,void 0),e([t({constructOnly:!0,type:w})],B.prototype,`labelOptions`,void 0),e([t({constructOnly:!0})],B.prototype,`geometryType`,void 0),e([t({constructOnly:!0})],B.prototype,`hasM`,void 0),e([t({constructOnly:!0})],B.prototype,`hasZ`,void 0),e([t()],B.prototype,`cursor`,void 0),e([t()],B.prototype,`effectiveCursor`,null),e([t()],B.prototype,`loading`,void 0),e([t({constructOnly:!0})],B.prototype,`manipulators`,void 0),e([t({constructOnly:!0})],B.prototype,`drawSurface`,void 0),e([t({constructOnly:!0})],B.prototype,`segmentLabels`,void 0),e([t({constructOnly:!0})],B.prototype,`snappingManager`,void 0),e([t({constructOnly:!0})],B.prototype,`snappingVisualizer`,void 0),e([t()],B.prototype,`snapToSceneEnabled`,void 0),e([t({constructOnly:!0})],B.prototype,`spatialReference`,null),e([t({readOnly:!0})],B.prototype,`cursorVertex`,null),e([t({readOnly:!0})],B.prototype,`visualizationCursorVertex`,null),e([t()],B.prototype,`committableVertex`,null),e([t()],B.prototype,`firstVertex`,void 0),e([t()],B.prototype,`lastVertex`,void 0),e([t()],B.prototype,`secondToLastVertex`,void 0),e([t()],B.prototype,`updating`,null),e([t({constructOnly:!0})],B.prototype,`view`,void 0),B=e([n(`esri.views.draw.DrawOperation`)],B);function V(e,t,n){let r=e.x-t.x,i=e.y-t.y;return r*r+i*i<=n}export{B as DrawOperation,I as defaultCursor,L as defaultLoadingCursor};
|
package/views/draw/DrawTool.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t,__decorate as n}from"tslib";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{diff as a}from"../../core/accessorSupport/diffUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import{makeHandle as s,disposable as c}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{getOrCreateMapValue as u}from"../../core/MapUtils.js";import{destroyMaybe as d,abortMaybe as f}from"../../core/maybe.js";import{ignoreAbortErrors as ee}from"../../core/promiseUtils.js";import{when as p,initial as m,watch as h,syncAndInitial as g,on as _,sync as v}from"../../core/reactiveUtils.js";import{createScreenPoint as y,screenPointEqual as b}from"../../core/screenUtils.js";import{UpdatingHandles as x}from"../../core/support/UpdatingHandles.js";import{simplifyIsSimple as S,simplifyExecute as te}from"../../geometry/operators/simplifyOperator.js";import C from"../../geometry/Polygon.js";import{isCurvedGeometry as w}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as T}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{isPolygon as E}from"../../geometry/support/typeUtils.js";import{getEffectiveElevationInfo as D}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as O,getMinSegmentsPerCurve as k}from"../2d/layers/graphics/densificationConstants.js";import{ViewEventPriorities as A}from"../input/InputManager.js";import{createCoordinateHelper as j}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as M}from"../interactive/InteractiveToolBase.js";import{KeyBindings as N,mediaKeys as P,sketchKeys as F,advancedSketchKeys as I,tooltipKeys as L}from"../interactive/keybindings.js";import{isInputModeAvailable as R}from"../interactive/tooltip/tooltipCommonUtils.js";import{createSnappingVisualizer as z}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as B,markHandled as V,getPointerType as H,getPointerId as U}from"./support/drawToolUtils.js";import{viewEventToCommand as W}from"./support/input/drawToolInput.js";import{EditSessionManager as G}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as K}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as q}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as J}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as Y}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as X}from"./support/managers/SurfaceManager.js";import{TooltipManager as Z}from"./support/managers/TooltipManager.js";import{PluginContext as ne}from"./support/PluginContext.js";const Q=Symbol();let $=class extends M{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new x,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type=`draw-2.0`,this.automaticManipulatorSelection=!0,this.snappingManager=null,this.toolOptions=null,this.disableTouchDrag=!1,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new J,this.globalStateManager=new K({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new G({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new Y({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.readPluginSetting=null,this.enableVertexVisuals=!0}initialize(){let{view:e}=this;this.interactiveHandleManager=new q({view:e,renderer:this.renderer}),this._override(`manipulators`,this.interactiveHandleManager.manipulators),this.tooltipManager=new Z({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(p(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:`outputGeometry`}),t.addOrUpdateVisual(this._vertexVisualId,{role:`vertex`}),this._updatingHandles.addPromise(z(e,t).then(e=>this._snappingVisualizer=e))},m)),this.addHandles([h(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,n,r,i])=>{this.surfaceManager?.destroy(),this.surfaceManager=new X({spatialReference:t,excludedGraphicsLayer:null,defaultZ:n,hasZ:r,view:e,elevationInfo:i,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},g),p(()=>this.toolOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),h(()=>[this.editGeometryOperations,this.toolOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},m),_(()=>this.editSessionManager,`cancelPlugin`,({plugin:e})=>{this._suspendPlugin(e)},v),_(()=>this.editSessionManager,`restartPlugin`,({restartInfo:e})=>{this._resumePlugin(e)},v),h(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},v),_(()=>this.editGeometryOperations,[`vertex-add`,`vertex-update`,`vertex-remove`],e=>{let t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),n=t.map(e=>e.coordinates);switch(e.type){case`vertex-add`:this._emitWhenReady(e.type,{...e,added:n,vertices:t});break;case`vertex-update`:this._emitWhenReady(e.type,{...e,updated:n,vertices:t});break;case`vertex-remove`:this._emitWhenReady(e.type,{...e,removed:n,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(let e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=d(this.surfaceManager),this.interactiveHandleManager=d(this.interactiveHandleManager),this._segmentLabelsImportTask=f(this._segmentLabelsImportTask),this._segmentLabels=d(this._segmentLabels),this.tooltipManager=d(this.tooltipManager)}get _zOfLastUserInput(){let e=(this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin))?.firstPointAddedBySession?.point;return e?.hasZ?e.z:null}get _tooltipDependencies(){let{defaultZ:e,editGeometryOperations:t,toolOptions:n,directionOptions:r,elevationInfo:i,view:a}=this;return!t||!n||!a?null:{defaultZ:e,directionOptions:r,elevationInfo:i,editGeometryOperations:t,toolOptions:n,view:a,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{let{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}}get _editSessionManagerContext(){let{coordinateHelper:e,view:t}=this;return t?{coordinateHelper:e,viewingMode:t.type===`3d`&&t.viewingMode===`global`?1:2}:null}get _densificationParameters(){let{view:e,coordinateHelper:t}=this,n=t.spatialReference,r=e?.spatialReference,i=e.resolution;if(!n||!r||!i||!Number.isFinite(i))return null;let a=r.metersPerUnit/n.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(i))*O()*a,minSegmentsPerCurve:k()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.snappingManager?.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return j(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){let e=this.editSessionManager.outputGeometry;if(e&&E(e))try{let t=this._densificationParameters,n=w(e)&&t?new C({...T(e,t)}):e;if(!S(n))return te(n)}catch{return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return this.view.type===`3d`&&this.unprocessedGeometry?.type===`point`&&!!this.interactiveHandleManager?.allhandles?.find(e=>e.role===`primary`)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){let e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){let{editGeometryOperations:e,tooltipManager:t,surfaceManager:n,snappingManager:r,interactiveHandleManager:i,_snappingVisualizer:a,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:c},view:l}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:n,interactiveHandleManager:i,snappingManager:r,snappingVisualizer:a,pointerType:`mouse`,hasZ:s,defaultZ:o,view:l,drawAtFixedElevation:c}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??`noTool`}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){let t=this.lifecycleManager;if(e&&t.complete(e),t.pluginStack.length===0){let e=this.unprocessedGeometry,t=!e||e.type===`mesh`||S(e);this.emit(`complete`,{geometry:e,isSimple:t,aborted:!1,type:`complete`,vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){let e=this.pluginStack.toArray().findLast(e=>e.configuration?.hidden!==!0);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return this.interactiveHandleManager?.capturingHandle?.role===`secondary`?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){let t=this.lifecycleManager;t.updating?l.getLogger(this).info(`Ignoring command; arrived while updating:`,`replaceLeaf`):t.replaceLeaf(e)}finishPart(){let e=this.mostUpstreamPlugin?.configuration;if(this.editGeometryOperations&&e&&e.kind?.includes(`multipart`)){let e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:`undo`})}redo(){this._handleCommand({action:`redo`})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,s(()=>{this._commandsSuspended=!1;let e=this.view?.inputManager.latestPointerInfo;if(e){let{x:t,y:n}=e.location;this._handleCommand({action:`manipulator-move-to`,x:t,y:n})}})}addPromise(e){return this._updatingHandles.addPromise(e)}readPluginSettingValue(e,t){return this.readPluginSetting?.(e,t)}getGeometryIfCompleted(){let e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();let{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&=(this.begin(this._pendingBeginRequest),null),this.enableVertexVisuals&&this.addHandles(h(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?B(e):null})},m)),this.addHandles([h(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},m),p(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:b}),h(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{let n=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&n&&this._emitWhenReady(`cursor-update`,{updated:n.pos,type:`vertex-update`,operation:`apply`,vertices:[{componentIndex:n.part.index,vertexIndex:n.index,coordinates:n.pos}]})},v),this._keybindings.register(e,A.TOOL),h(()=>e.viewpoint,(e,t)=>{e&&t&&a(e,t)&&this._handleCommand({action:`viewpoint-moved`})})],Q)}onDeactivate(){super.onDeactivate(),this.removeHandles(Q),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){if(this.disableTouchDrag&&(e.type===`drag`||e.type===`pointer-drag`)&&e.pointerType===`touch`)return;e.type===`pointer-down`?this.interactiveHandleManager?.notePointerDown(e.pointerId,e.pointerType):(e.type===`pointer-up`||e.type===`pointer-leave`)&&this.interactiveHandleManager?.notePointerUp(e.pointerId,e.pointerType);let t=W(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;let n=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(n):n()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||this._queuedFeedbackEvents.length===0)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended){if(this.lifecycleManager.updating)l.getLogger(this).info(`Ignoring command; arrived while updating:`,e.action);else switch(e.action){case`view-drag`:return await this._handleViewDragCommand(e);case`vertex-add`:return this._guardCommand(e,()=>{V(e),this._commitNext()});case`vertex-add-and-finish-part`:return this._handleVertexAddAndFinishPartCommand(e);case`cancel`:return this._guardCommand(e,()=>this.cancel());case`complete`:return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(V(e),this.complete(this.mostUpstreamPlugin))});case`finish-part`:return this._guardCommand(e,()=>this.finishPart());case`undo`:return this._guardCommand(e,()=>this.editSessionManager.undo());case`redo`:return this._guardCommand(e,()=>this.editSessionManager.redo());case`next-manipulator`:return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator(`forward`));case`previous-manipulator`:return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator(`backward`));case`toggle-manipulator-follow`:this.interactiveHandleManager?.toggleFollow()&&V(e);break;case`viewpoint-moved`:return await this._handleViewpointMovedCommand(e);case`manipulator-move-to`:return await this._handleManipulatorMoveToCommand(e);case`manipulator-drag-to`:return await this._handleManipulatorDragToCommand(e);case`vertex-add-at-point`:return await this._handleVertexAddAtPointCommand(e);case`show-tooltip`:return this._guardCommand(e,async()=>{let t=this.tooltipManager?.tooltip;t&&R(t.info)&&(await t.enterInputMode(),V(e))});case`constraint-center`:this.globalStateManager.setCentered(e.enabled);break;case`constraint-aspect`:this.globalStateManager.setPreserveAspectRatio(e.enabled)}}}async _handleViewDragCommand(e){if(!this.editable)return;let t=e.originalEvent,n=this.interactiveHandleManager?.capturingHandle;(t&&`pointerType`in t&&t.pointerType===`touch`&&(n?.captureMode===`capture-always`||n?.captureMode===`capture-when-engaged`)||this.interactiveHandleManager?.capturingHandle?.captureMode===`capture-when-engaged`||this._before(e))&&V(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(V(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){if(!this.editable)return;let t=H(e.originalEvent),n=U(e.originalEvent);await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:t,pointerId:n})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager)}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;let t=H(e.originalEvent),n=U(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(n,t))return;let r=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&V(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(r,{...this.movementCommandContext,pointerType:t,pointerId:n}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;let t=H(e.originalEvent),n=U(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(n,t))return;let r=this._updateLastScreenPosition(e),i=this.interactiveHandleManager?.findHandleByManipulator(r,t);t===`touch`&&i&&e.state===`start`&&this.interactiveHandleManager?.releaseHandle();let a=this.interactiveHandleManager?.findHandleDragging(),o=this.interactiveHandleManager?.capturingHandle,s=a??o??i;s&&!i&&V(e),s?.captureMode===`capture-when-engaged`||s?.captureMode===`capture-always`&&t===`touch`?e.state===`end`?await this._updatingHandles.addPromise(s.noteDragEnd(r,{...this.movementCommandContext,pointerType:t,pointerId:n}).then(()=>{s&&H(e.originalEvent)===`touch`&&s.captureMode!==`grabbable-object`&&s.defaultCaptureMode!==`capture-when-engaged`&&s.role===`primary`&&(this.interactiveHandleManager?.handleCount===1?this._handleCommand({action:`vertex-add`}):this.interactiveHandleManager?.releaseHandle())})):e.state===`start`?await this._updatingHandles.addPromise(s.noteDragStart(r,{...this.movementCommandContext,pointerType:t,pointerId:n}).then(()=>{s&&H(e.originalEvent)===`touch`&&s.captureMode!==`grabbable-object`&&s.defaultCaptureMode!==`capture-when-engaged`&&!s.editSession?.lastPointAddedBySession&&this._handleCommand({action:`vertex-add`})})):await this._updatingHandles.addPromise(s?.moveTo(r,{...this.movementCommandContext,pointerType:t,pointerId:n})):s?.captureMode===`grabbable-object`&&(this.interactiveHandleManager?.releaseHandle(o),await this._updatingHandles.addPromise(s.moveTo(r,{...this.movementCommandContext,pointerType:t,pointerId:n})))}async _handleVertexAddAtPointCommand(e){let t=this._updateLastScreenPosition(e),n=H(e.originalEvent),r=U(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(r,n))return;let i=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,n);this.editable&&i&&(this._before(e)||(V(e),await this._updatingHandles.addPromise(i.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:n,pointerId:r}).finally(()=>this._commitNext()))))}_makeKeyBindings(){let e=new N,t=(t,n)=>{e.addToggle(t,e=>this._handleCommand({action:n,originalEvent:e,enabled:e.type===`key-down`}))},n=(t,n)=>{e.add(t,e=>this._handleCommand({action:n,originalEvent:e}))};return t(P.preserveAspectRatio,`constraint-aspect`),t(F.center,`constraint-center`),n(I.toggleFollowManipulator,`toggle-manipulator-follow`),n(F.undo,`undo`),n(F.redo,`redo`),n(F.complete,`complete`),n(F.vertexAdd,`vertex-add`),n({key:L.enterInputMode,continuePropagation:!0,repeats:!0},`show-tooltip`),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);let t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){let n={stack:[],error:void 0,hasError:!1};try{let t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let r=this.tooltipManager?.getFieldsToUnlockOnVertexPlacement()??[],i=!1,a=this.editGeometryOperations;e(n,a?c(a.on(`vertex-add`,()=>i=!0)):null,!1),t.completeStep?t.completeStep():this.complete(t),i&&this.tooltipManager?.unlockOnVertexPlacement(r)}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){let t=y(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){let n=u(this._pluginContexts,e,()=>new ne({drawTool:this,plugin:e,session:t}));return n.session=t,n}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;let t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,n){return this._before(e)?n?.():t()}async _setupSegmentLabels(){let e=this.editGeometryOperations,t=this.toolOptions?.labels,n=!!t?.enabled,r=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!n){this._segmentLabels=d(this._segmentLabels);return}if(r){this._segmentLabels&&(this._segmentLabels.visible=!1);return}if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t){this._segmentLabels.visible=!0;return}let i=await this._createSegmentLabels(e,t);i&&(this._segmentLabels=d(this._segmentLabels),this._segmentLabels=i)}async _createSegmentLabels(e,t){this._segmentLabelsImportTask?.abort();let n=this._segmentLabelsImportTask=o(async n=>{if(this.view.type===`3d`){let r=import(`../3d/interactive/SegmentLabels3D.js`),{SegmentLabels3D:i}=await this._updatingHandles.addPromise(r);return this._isSegmentLabelsSetupStale(n,e,t)?null:new i({context:{view:this.view,editGeometryOperations:e,elevationInfo:D(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}let r=import(`../2d/interactive/SegmentLabels2D.js`),{SegmentLabels2D:i}=await this._updatingHandles.addPromise(r);return this._isSegmentLabelsSetupStale(n,e,t)?null:new i({context:{view:this.view,editGeometryOperations:e,elevationInfo:D(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})});return ee(n.promise)}_isSegmentLabelsSetupStale(e,t,n){return e.aborted||this.editGeometryOperations!==t||this.toolOptions?.labels!==n||!n.enabled||this.globalStateManager.segmentLabelsDisabled}};n([r()],$.prototype,`_commandsSuspended`,void 0),n([r()],$.prototype,`_zOfLastUserInput`,null),n([r()],$.prototype,`_snappingVisualizer`,void 0),n([r()],$.prototype,`_segmentLabels`,void 0),n([r()],$.prototype,`_segmentLabelsImportTask`,void 0),n([r()],$.prototype,`_tooltipDependencies`,null),n([r()],$.prototype,`_editSessionManagerContext`,null),n([r()],$.prototype,`_densificationParameters`,null),n([r({constructOnly:!0,nonNullable:!0})],$.prototype,`view`,void 0),n([r()],$.prototype,`automaticManipulatorSelection`,void 0),n([r()],$.prototype,`updating`,null),n([r()],$.prototype,`coordinateHelper`,null),n([r()],$.prototype,`editGeometry`,null),n([r()],$.prototype,`editGeometryOperations`,null),n([r()],$.prototype,`unprocessedGeometry`,null),n([r()],$.prototype,`simplifiedGeometryPreview`,null),n([r()],$.prototype,`_suppressCoincidentPointOverlaysIn3D`,null),n([r()],$.prototype,`_shapeVisualGeometry`,null),n([r()],$.prototype,`_vertexVisualGeometry`,null),n([r()],$.prototype,`snappingManager`,void 0),n([r()],$.prototype,`toolOptions`,void 0),n([r()],$.prototype,`disableTouchDrag`,void 0),n([r()],$.prototype,`elevationInfo`,void 0),n([r()],$.prototype,`hasZ`,void 0),n([r()],$.prototype,`defaultZ`,void 0),n([r()],$.prototype,`directionOptions`,void 0),n([r()],$.prototype,`canUndo`,null),n([r()],$.prototype,`canRedo`,null),n([r()],$.prototype,`pluginStack`,null),n([r()],$.prototype,`mostDownstreamPlugin`,null),n([r()],$.prototype,`mostUpstreamPlugin`,null),n([r()],$.prototype,`lastScreenPosition`,void 0),n([r()],$.prototype,`positionOfLastUserInput`,null),n([r()],$.prototype,`tooltipManager`,void 0),n([r()],$.prototype,`measurementManager`,void 0),n([r()],$.prototype,`globalStateManager`,void 0),n([r()],$.prototype,`editSessionManager`,void 0),n([r()],$.prototype,`lifecycleManager`,void 0),n([r()],$.prototype,`surfaceManager`,void 0),n([r()],$.prototype,`interactiveHandleManager`,void 0),n([r()],$.prototype,`renderer`,void 0),n([r()],$.prototype,`readPluginSetting`,void 0),n([r()],$.prototype,`movementCommandContext`,null),n([r()],$.prototype,`tooltip`,null),n([r()],$.prototype,`activeTooltipInfo`,null),n([r()],$.prototype,`helpMessageKey`,null),n([r({constructOnly:!0})],$.prototype,`enableVertexVisuals`,void 0),$=n([i(`esri.views.draw.DrawTool`)],$);export{$ as DrawTool};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as n}from"tslib";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{diff as a}from"../../core/accessorSupport/diffUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import{makeHandle as s,disposable as c}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{getOrCreateMapValue as u}from"../../core/MapUtils.js";import{destroyMaybe as d,abortMaybe as f}from"../../core/maybe.js";import{ignoreAbortErrors as ee}from"../../core/promiseUtils.js";import{when as p,initial as m,watch as h,syncAndInitial as g,on as _,sync as v}from"../../core/reactiveUtils.js";import{createScreenPoint as y,screenPointEqual as b}from"../../core/screenUtils.js";import{UpdatingHandles as x}from"../../core/support/UpdatingHandles.js";import{simplifyIsSimple as S,simplifyExecute as te}from"../../geometry/operators/simplifyOperator.js";import C from"../../geometry/Polygon.js";import{isCurvedGeometry as w}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as T}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{isPolygon as E}from"../../geometry/support/typeUtils.js";import{getEffectiveElevationInfo as D}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as O,getMinSegmentsPerCurve as k}from"../2d/layers/graphics/densificationConstants.js";import{ViewEventPriorities as A}from"../input/InputManager.js";import{createCoordinateHelper as j}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as M}from"../interactive/InteractiveToolBase.js";import{KeyBindings as N,mediaKeys as P,sketchKeys as F,advancedSketchKeys as I,tooltipKeys as L}from"../interactive/keybindings.js";import{isInputModeAvailable as R}from"../interactive/tooltip/tooltipCommonUtils.js";import{createSnappingVisualizer as z}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as B,markHandled as V,getPointerType as H,getPointerId as U}from"./support/drawToolUtils.js";import{viewEventToCommand as W}from"./support/input/drawToolInput.js";import{EditSessionManager as G}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as K}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as q}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as J}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as Y}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as X}from"./support/managers/SurfaceManager.js";import{TooltipManager as Z}from"./support/managers/TooltipManager.js";import{PluginContext as ne}from"./support/PluginContext.js";const Q=Symbol();let $=class extends M{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new x,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type=`draw-2.0`,this.automaticManipulatorSelection=!0,this.snappingManager=null,this.toolOptions=null,this.disableTouchDrag=!1,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new J,this.globalStateManager=new K({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new G({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new Y({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.readPluginSetting=null,this.enableVertexVisuals=!0}initialize(){let{view:e}=this;this.interactiveHandleManager=new q({view:e,renderer:this.renderer}),this._override(`manipulators`,this.interactiveHandleManager.manipulators),this.tooltipManager=new Z({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(p(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:`outputGeometry`}),t.addOrUpdateVisual(this._vertexVisualId,{role:`vertex`}),this._updatingHandles.addPromise(z(e,t).then(e=>this._snappingVisualizer=e))},m)),this.addHandles([h(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,n,r,i])=>{this.surfaceManager?.destroy(),this.surfaceManager=new X({spatialReference:t,excludedGraphicsLayer:null,defaultZ:n,hasZ:r,view:e,elevationInfo:i,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},g),p(()=>this.toolOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),h(()=>[this.editGeometryOperations,this.toolOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},m),_(()=>this.editSessionManager,`cancelPlugin`,({plugin:e})=>{this._suspendPlugin(e)},v),_(()=>this.editSessionManager,`restartPlugin`,({restartInfo:e})=>{this._resumePlugin(e)},v),h(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},v),_(()=>this.editGeometryOperations,[`vertex-add`,`vertex-update`,`vertex-remove`],e=>{let t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),n=t.map(e=>e.coordinates);switch(e.type){case`vertex-add`:this._emitWhenReady(e.type,{...e,added:n,vertices:t});break;case`vertex-update`:this._emitWhenReady(e.type,{...e,updated:n,vertices:t});break;case`vertex-remove`:this._emitWhenReady(e.type,{...e,removed:n,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(let e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=d(this.surfaceManager),this.interactiveHandleManager=d(this.interactiveHandleManager),this._segmentLabelsImportTask=f(this._segmentLabelsImportTask),this._segmentLabels=d(this._segmentLabels),this.tooltipManager=d(this.tooltipManager)}get _zOfLastUserInput(){let e=(this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin))?.firstPointAddedBySession?.point;return e?.hasZ?e.z:null}get _tooltipDependencies(){let{defaultZ:e,editGeometryOperations:t,toolOptions:n,directionOptions:r,elevationInfo:i,view:a}=this;return!t||!n||!a?null:{defaultZ:e,directionOptions:r,elevationInfo:i,editGeometryOperations:t,toolOptions:n,view:a,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{let{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}}get _editSessionManagerContext(){let{coordinateHelper:e,view:t}=this;return t?{coordinateHelper:e,isGlobal:t.state.isGlobal}:null}get _densificationParameters(){let{view:e,coordinateHelper:t}=this,n=t.spatialReference,r=e?.spatialReference,i=e.resolution;if(!n||!r||!i||!Number.isFinite(i))return null;let a=r.metersPerUnit/n.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(i))*O()*a,minSegmentsPerCurve:k()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.snappingManager?.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return j(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){let e=this.editSessionManager.outputGeometry;if(e&&E(e))try{let t=this._densificationParameters,n=w(e)&&t?new C({...T(e,t)}):e;if(!S(n))return te(n)}catch{return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return this.view.type===`3d`&&this.unprocessedGeometry?.type===`point`&&!!this.interactiveHandleManager?.allhandles?.find(e=>e.role===`primary`)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){let e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){let{editGeometryOperations:e,tooltipManager:t,surfaceManager:n,snappingManager:r,interactiveHandleManager:i,_snappingVisualizer:a,defaultZ:o,hasZ:s,globalStateManager:{drawAtFixedElevation:c},view:l}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:n,interactiveHandleManager:i,snappingManager:r,snappingVisualizer:a,pointerType:`mouse`,hasZ:s,defaultZ:o,view:l,drawAtFixedElevation:c}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??`noTool`}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){let t=this.lifecycleManager;if(e&&t.complete(e),t.pluginStack.length===0){let e=this.unprocessedGeometry,t=!e||e.type===`mesh`||S(e);this.emit(`complete`,{geometry:e,isSimple:t,aborted:!1,type:`complete`,vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){let e=this.pluginStack.toArray().findLast(e=>e.configuration?.hidden!==!0);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return this.interactiveHandleManager?.capturingHandle?.role===`secondary`?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){let t=this.lifecycleManager;t.updating?l.getLogger(this).info(`Ignoring command; arrived while updating:`,`replaceLeaf`):t.replaceLeaf(e)}finishPart(){let e=this.mostUpstreamPlugin?.configuration;if(this.editGeometryOperations&&e&&e.kind?.includes(`multipart`)){let e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:`undo`})}redo(){this._handleCommand({action:`redo`})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,s(()=>{this._commandsSuspended=!1;let e=this.view?.inputManager.latestPointerInfo;if(e){let{x:t,y:n}=e.location;this._handleCommand({action:`manipulator-move-to`,x:t,y:n})}})}addPromise(e){return this._updatingHandles.addPromise(e)}readPluginSettingValue(e,t){return this.readPluginSetting?.(e,t)}getGeometryIfCompleted(){let e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();let{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&=(this.begin(this._pendingBeginRequest),null),this.enableVertexVisuals&&this.addHandles(h(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?B(e):null})},m)),this.addHandles([h(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},m),p(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:b}),h(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{let n=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&n&&this._emitWhenReady(`cursor-update`,{updated:n.pos,type:`vertex-update`,operation:`apply`,vertices:[{componentIndex:n.part.index,vertexIndex:n.index,coordinates:n.pos}]})},v),this._keybindings.register(e,A.TOOL),h(()=>e.viewpoint,(e,t)=>{e&&t&&a(e,t)&&this._handleCommand({action:`viewpoint-moved`})})],Q)}onDeactivate(){super.onDeactivate(),this.removeHandles(Q),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){if(this.disableTouchDrag&&(e.type===`drag`||e.type===`pointer-drag`)&&e.pointerType===`touch`)return;e.type===`pointer-down`?this.interactiveHandleManager?.notePointerDown(e.pointerId,e.pointerType):(e.type===`pointer-up`||e.type===`pointer-leave`)&&this.interactiveHandleManager?.notePointerUp(e.pointerId,e.pointerType);let t=W(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;let n=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(n):n()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||this._queuedFeedbackEvents.length===0)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended){if(this.lifecycleManager.updating)l.getLogger(this).info(`Ignoring command; arrived while updating:`,e.action);else switch(e.action){case`view-drag`:return await this._handleViewDragCommand(e);case`vertex-add`:return this._guardCommand(e,()=>{V(e),this._commitNext()});case`vertex-add-and-finish-part`:return this._handleVertexAddAndFinishPartCommand(e);case`cancel`:return this._guardCommand(e,()=>this.cancel());case`complete`:return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(V(e),this.complete(this.mostUpstreamPlugin))});case`finish-part`:return this._guardCommand(e,()=>this.finishPart());case`undo`:return this._guardCommand(e,()=>this.editSessionManager.undo());case`redo`:return this._guardCommand(e,()=>this.editSessionManager.redo());case`next-manipulator`:return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator(`forward`));case`previous-manipulator`:return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator(`backward`));case`toggle-manipulator-follow`:this.interactiveHandleManager?.toggleFollow()&&V(e);break;case`viewpoint-moved`:return await this._handleViewpointMovedCommand(e);case`manipulator-move-to`:return await this._handleManipulatorMoveToCommand(e);case`manipulator-drag-to`:return await this._handleManipulatorDragToCommand(e);case`vertex-add-at-point`:return await this._handleVertexAddAtPointCommand(e);case`show-tooltip`:return this._guardCommand(e,async()=>{let t=this.tooltipManager?.tooltip;t&&R(t.info)&&(await t.enterInputMode(),V(e))});case`constraint-center`:this.globalStateManager.setCentered(e.enabled);break;case`constraint-aspect`:this.globalStateManager.setPreserveAspectRatio(e.enabled)}}}async _handleViewDragCommand(e){if(!this.editable)return;let t=e.originalEvent,n=this.interactiveHandleManager?.capturingHandle;(t&&`pointerType`in t&&t.pointerType===`touch`&&(n?.captureMode===`capture-always`||n?.captureMode===`capture-when-engaged`)||this.interactiveHandleManager?.capturingHandle?.captureMode===`capture-when-engaged`||this._before(e))&&V(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(V(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){if(!this.editable)return;let t=H(e.originalEvent),n=U(e.originalEvent);await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:t,pointerId:n})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager)}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;let t=H(e.originalEvent),n=U(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(n,t))return;let r=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&V(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(r,{...this.movementCommandContext,pointerType:t,pointerId:n}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;let t=H(e.originalEvent),n=U(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(n,t))return;let r=this._updateLastScreenPosition(e),i=this.interactiveHandleManager?.findHandleByManipulator(r,t);t===`touch`&&i&&e.state===`start`&&this.interactiveHandleManager?.releaseHandle();let a=this.interactiveHandleManager?.findHandleDragging(),o=this.interactiveHandleManager?.capturingHandle,s=a??o??i;s&&!i&&V(e),s?.captureMode===`capture-when-engaged`||s?.captureMode===`capture-always`&&t===`touch`?e.state===`end`?await this._updatingHandles.addPromise(s.noteDragEnd(r,{...this.movementCommandContext,pointerType:t,pointerId:n}).then(()=>{s&&H(e.originalEvent)===`touch`&&s.captureMode!==`grabbable-object`&&s.defaultCaptureMode!==`capture-when-engaged`&&s.role===`primary`&&(this.interactiveHandleManager?.handleCount===1?this._handleCommand({action:`vertex-add`}):this.interactiveHandleManager?.releaseHandle())})):e.state===`start`?await this._updatingHandles.addPromise(s.noteDragStart(r,{...this.movementCommandContext,pointerType:t,pointerId:n}).then(()=>{s&&H(e.originalEvent)===`touch`&&s.captureMode!==`grabbable-object`&&s.defaultCaptureMode!==`capture-when-engaged`&&!s.editSession?.lastPointAddedBySession&&this._handleCommand({action:`vertex-add`})})):await this._updatingHandles.addPromise(s?.moveTo(r,{...this.movementCommandContext,pointerType:t,pointerId:n})):s?.captureMode===`grabbable-object`&&(this.interactiveHandleManager?.releaseHandle(o),await this._updatingHandles.addPromise(s.moveTo(r,{...this.movementCommandContext,pointerType:t,pointerId:n})))}async _handleVertexAddAtPointCommand(e){let t=this._updateLastScreenPosition(e),n=H(e.originalEvent),r=U(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(r,n))return;let i=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,n);this.editable&&i&&(this._before(e)||(V(e),await this._updatingHandles.addPromise(i.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:n,pointerId:r}).finally(()=>this._commitNext()))))}_makeKeyBindings(){let e=new N,t=(t,n)=>{e.addToggle(t,e=>this._handleCommand({action:n,originalEvent:e,enabled:e.type===`key-down`}))},n=(t,n)=>{e.add(t,e=>this._handleCommand({action:n,originalEvent:e}))};return t(P.preserveAspectRatio,`constraint-aspect`),t(F.center,`constraint-center`),n(I.toggleFollowManipulator,`toggle-manipulator-follow`),n(F.undo,`undo`),n(F.redo,`redo`),n(F.complete,`complete`),n(F.vertexAdd,`vertex-add`),n({key:L.enterInputMode,continuePropagation:!0,repeats:!0},`show-tooltip`),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);let t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){let n={stack:[],error:void 0,hasError:!1};try{let t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let r=this.tooltipManager?.getFieldsToUnlockOnVertexPlacement()??[],i=!1,a=this.editGeometryOperations;e(n,a?c(a.on(`vertex-add`,()=>i=!0)):null,!1),t.completeStep?t.completeStep():this.complete(t),i&&this.tooltipManager?.unlockOnVertexPlacement(r)}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){let t=y(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){let n=u(this._pluginContexts,e,()=>new ne({drawTool:this,plugin:e,session:t}));return n.session=t,n}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;let t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,n){return this._before(e)?n?.():t()}async _setupSegmentLabels(){let e=this.editGeometryOperations,t=this.toolOptions?.labels,n=!!t?.enabled,r=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!n){this._segmentLabels=d(this._segmentLabels);return}if(r){this._segmentLabels&&(this._segmentLabels.visible=!1);return}if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t){this._segmentLabels.visible=!0;return}let i=await this._createSegmentLabels(e,t);i&&(this._segmentLabels=d(this._segmentLabels),this._segmentLabels=i)}async _createSegmentLabels(e,t){this._segmentLabelsImportTask?.abort();let n=this._segmentLabelsImportTask=o(async n=>{if(this.view.type===`3d`){let r=import(`../3d/interactive/SegmentLabels3D.js`),{SegmentLabels3D:i}=await this._updatingHandles.addPromise(r);return this._isSegmentLabelsSetupStale(n,e,t)?null:new i({context:{view:this.view,editGeometryOperations:e,elevationInfo:D(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}let r=import(`../2d/interactive/SegmentLabels2D.js`),{SegmentLabels2D:i}=await this._updatingHandles.addPromise(r);return this._isSegmentLabelsSetupStale(n,e,t)?null:new i({context:{view:this.view,editGeometryOperations:e,elevationInfo:D(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})});return ee(n.promise)}_isSegmentLabelsSetupStale(e,t,n){return e.aborted||this.editGeometryOperations!==t||this.toolOptions?.labels!==n||!n.enabled||this.globalStateManager.segmentLabelsDisabled}};n([r()],$.prototype,`_commandsSuspended`,void 0),n([r()],$.prototype,`_zOfLastUserInput`,null),n([r()],$.prototype,`_snappingVisualizer`,void 0),n([r()],$.prototype,`_segmentLabels`,void 0),n([r()],$.prototype,`_segmentLabelsImportTask`,void 0),n([r()],$.prototype,`_tooltipDependencies`,null),n([r()],$.prototype,`_editSessionManagerContext`,null),n([r()],$.prototype,`_densificationParameters`,null),n([r({constructOnly:!0,nonNullable:!0})],$.prototype,`view`,void 0),n([r()],$.prototype,`automaticManipulatorSelection`,void 0),n([r()],$.prototype,`updating`,null),n([r()],$.prototype,`coordinateHelper`,null),n([r()],$.prototype,`editGeometry`,null),n([r()],$.prototype,`editGeometryOperations`,null),n([r()],$.prototype,`unprocessedGeometry`,null),n([r()],$.prototype,`simplifiedGeometryPreview`,null),n([r()],$.prototype,`_suppressCoincidentPointOverlaysIn3D`,null),n([r()],$.prototype,`_shapeVisualGeometry`,null),n([r()],$.prototype,`_vertexVisualGeometry`,null),n([r()],$.prototype,`snappingManager`,void 0),n([r()],$.prototype,`toolOptions`,void 0),n([r()],$.prototype,`disableTouchDrag`,void 0),n([r()],$.prototype,`elevationInfo`,void 0),n([r()],$.prototype,`hasZ`,void 0),n([r()],$.prototype,`defaultZ`,void 0),n([r()],$.prototype,`directionOptions`,void 0),n([r()],$.prototype,`canUndo`,null),n([r()],$.prototype,`canRedo`,null),n([r()],$.prototype,`pluginStack`,null),n([r()],$.prototype,`mostDownstreamPlugin`,null),n([r()],$.prototype,`mostUpstreamPlugin`,null),n([r()],$.prototype,`lastScreenPosition`,void 0),n([r()],$.prototype,`positionOfLastUserInput`,null),n([r()],$.prototype,`tooltipManager`,void 0),n([r()],$.prototype,`measurementManager`,void 0),n([r()],$.prototype,`globalStateManager`,void 0),n([r()],$.prototype,`editSessionManager`,void 0),n([r()],$.prototype,`lifecycleManager`,void 0),n([r()],$.prototype,`surfaceManager`,void 0),n([r()],$.prototype,`interactiveHandleManager`,void 0),n([r()],$.prototype,`renderer`,void 0),n([r()],$.prototype,`readPluginSetting`,void 0),n([r()],$.prototype,`movementCommandContext`,null),n([r()],$.prototype,`tooltip`,null),n([r()],$.prototype,`activeTooltipInfo`,null),n([r()],$.prototype,`helpMessageKey`,null),n([r({constructOnly:!0})],$.prototype,`enableVertexVisuals`,void 0),$=n([i(`esri.views.draw.DrawTool`)],$);export{$ as DrawTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import r from"../../geometry/Point.js";import{ViewEventPriorities as i}from"../input/InputManager.js";import{EditGeometry as a,Part as o}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as s}from"../interactive/editGeometry/EditGeometryOperations.js";import{sketchKeys as c}from"../interactive/keybindings.js";import{createScreenPointFromEvent as l}from"../support/screenUtils.js";import u from"./CursorUpdateEvent.js";import d from"./DrawAction.js";import f from"./DrawCompleteEvent.js";import{createViewAlignedCoordinateSystem as p}from"./support/surfaceCoordinateSystems.js";import m from"./VertexAddEvent.js";const h=[`freehand`,`click`];let g=class extends d{constructor(e){super(e),this._isDragging=!1,this._panEnabled=!1,this._addVertexOnPointerUp=!1,this._drawTool=null,this.viewAlignedCoordinateSystem=null,this.mode=`freehand`}initialize(){this.view.type===`2d`?this._addViewHandles():this.addResolvingPromise(this._addDrawTool())}destroy(){this._removeDrawTool(),this.emit(`destroy`)}complete(){this._completeDrawing()}_getGeometryZValue(){return this.hasZ&&this.vertices.length>0?this.vertices[0][2]:this.defaultZ}_addViewHandles(){this.mode===`click`?this.addHandles(this._getClickModeViewHandles()):this.addHandles(this._getDragModeViewHandles())}_getDragModeViewHandles(){return[this.view.on(`immediate-click`,e=>{e.stopPropagation(),e.mapPoint&&!this._panEnabled&&this.getCoordsFromScreenPoint(l(e))!=null&&(this._vertexAddHandler(e),this._drawCompleteHandler(e))},i.TOOL),this.view.on(`pointer-down`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._panEnabled||(this._resetGeometry(),this._addVertexOnPointerUp=!0,this._cursorScreenPoint=l(e),this._activePointerId=e.pointerId,this._vertexAddHandler(e),this._isDragging=!1,e.pointerType===`touch`&&this._updateCursor()))},i.TOOL),this.view.on(`pointer-move`,e=>{this._abortSnapping(),this._activePointerId==null&&e.pointerType!==`touch`&&(this._cursorScreenPoint=l(e),this._updateCursor())},i.TOOL),this.view.on(`pointer-drag`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._isDragging=!0,this._cursorScreenPoint=l(e),this._updateCursor())},i.TOOL),this.view.on(`pointer-up`,e=>{this._shouldHandlePointerEvent(e)&&this._addVertexOnPointerUp&&(this._abortSnapping(),this._activePointerId=null,this._isDragging&&this._vertexAddHandler(e),this._committedVertices.length===2&&this._drawCompleteHandler(e),this._isDragging=!1)},i.TOOL),this.view.on(`key-down`,e=>{e.key===c.complete&&this._cursorScreenPoint?(this._abortSnapping(),this._vertexAddHandler(e),this._drawCompleteHandler(e)):e.key===c.pan&&(this._panEnabled=!0)},i.TOOL),this.view.on(`key-up`,e=>{e.key===c.pan&&(this._panEnabled=!1)},i.TOOL),this.view.on(`drag`,e=>{this._activePointerId!=null&&e.stopPropagation()},i.TOOL),this.view.on(`drag`,[`Shift`],e=>{e.stopPropagation()},i.TOOL)]}_getClickModeViewHandles(){return[this.view.on(`pointer-down`,e=>{this._abortSnapping(),this._cursorScreenPoint=l(e),this._activePointerId=e.pointerId,this._isDragging=!1,e.pointerType===`touch`&&this._updateCursor()},i.TOOL),this.view.on(`pointer-move`,e=>{this._abortSnapping(),this._cursorScreenPoint=l(e),this._activePointerId==null&&e.pointerType!==`touch`&&this._updateCursor()},i.TOOL),this.view.on(`pointer-drag`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._isDragging=!0)},i.TOOL),this.view.on(`pointer-up`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=null,e.stopPropagation(),this._isDragging||this._vertexAddHandler(e),this.vertices.length===2&&!this._isDragging&&this._drawCompleteHandler(e),this._isDragging=!1)},i.TOOL),this.view.on(`key-down`,e=>{e.key===c.vertexAdd&&this._cursorScreenPoint&&(this._vertexAddHandler(e),this.vertices.length===2&&this._drawCompleteHandler(e)),e.key===c.complete&&this._cursorScreenPoint&&this.vertices.length===2&&(this._vertexAddHandler(e),this._drawCompleteHandler(e))},i.TOOL)]}async _addDrawTool(){let{LegacyDrawTool:e}=await import(`./LegacyDrawTool.js`),t=new e({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:`segment`,mode:this.mode});this.destroyed?t.destroy():(this._drawTool=t,this.view.addAndActivateTool(t),this.addHandles([t.on(`vertex-add`,e=>{e.vertices.length===1&&this.emit(`vertex-add`,new m(this.view,e.vertices[0].vertexIndex,t.getVertexCoords()))}),t.on(`cursor-update`,e=>{e.vertices.length===1&&this.emit(`cursor-update`,new u(this.view,e.vertices[0].vertexIndex,t.getVertexCoords()))}),t.on(`complete`,e=>{this.emit(`draw-complete`,new f(t.getVertexCoords())),this._removeDrawTool()}),this.view.on(`key-down`,e=>{e.key===c.vertexAdd&&!e.repeat&&this.mode===`click`?t.drawOperation.numCommittedVertices>0?t.completeCreateOperation():t.drawOperation.commitStagedVertex():e.key===c.complete&&!e.repeat&&t.completeCreateOperation()},i.TOOL)]))}_removeDrawTool(){this._drawTool&&=(this.view.tools.remove(this._drawTool),null)}_addVertex(e){let t=this._coordinateHelper.arrayToVector(e);if(this._isDuplicateOfLastVertex(t))return;this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertexToFirstPart(t),this._committedVertices.length===1&&(this.viewAlignedCoordinateSystem=p(this.view,this._committedVertices[0]));let n=this._committedVertices.length-1,r=new m(this.view,n,this.vertices);this.emit(`vertex-add`,r)}_updateCursor(){if(this._popCursorVertex(),!this._cursorScreenPoint)return;let e=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);e!=null&&this._pushCursorVertex(e.vertex,()=>this.emit(`cursor-update`,new u(this.view,this._activeComponent.vertices.length,this.vertices,this._stagedVertex==null?null:new r(this._stagedVertex))))}_completeDrawing(){if(this._drawTool){this._drawTool.completeCreateOperation(),this.removeAllHandles();return}if(this._activePointerId=null,this._popCursorVertex(),this._cursorScreenPoint=null,this._isDragging=!1,this._abortSnapping(),this._snappingManager!=null&&this._snappingManager.doneSnapping(),this.vertices.length<1)return;let e=new f(this.vertices);this.emit(`draw-complete`,e),e.defaultPrevented||this.removeAllHandles()}_resetGeometry(){this._editGeometryOperations.destroy(),this._editGeometryOperations=new s(new a(`polygon`,this._coordinateHelper),
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import r from"../../geometry/Point.js";import{ViewEventPriorities as i}from"../input/InputManager.js";import{EditGeometry as a,Part as o}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as s}from"../interactive/editGeometry/EditGeometryOperations.js";import{sketchKeys as c}from"../interactive/keybindings.js";import{createScreenPointFromEvent as l}from"../support/screenUtils.js";import u from"./CursorUpdateEvent.js";import d from"./DrawAction.js";import f from"./DrawCompleteEvent.js";import{createViewAlignedCoordinateSystem as p}from"./support/surfaceCoordinateSystems.js";import m from"./VertexAddEvent.js";const h=[`freehand`,`click`];let g=class extends d{constructor(e){super(e),this._isDragging=!1,this._panEnabled=!1,this._addVertexOnPointerUp=!1,this._drawTool=null,this.viewAlignedCoordinateSystem=null,this.mode=`freehand`}initialize(){this.view.type===`2d`?this._addViewHandles():this.addResolvingPromise(this._addDrawTool())}destroy(){this._removeDrawTool(),this.emit(`destroy`)}complete(){this._completeDrawing()}_getGeometryZValue(){return this.hasZ&&this.vertices.length>0?this.vertices[0][2]:this.defaultZ}_addViewHandles(){this.mode===`click`?this.addHandles(this._getClickModeViewHandles()):this.addHandles(this._getDragModeViewHandles())}_getDragModeViewHandles(){return[this.view.on(`immediate-click`,e=>{e.stopPropagation(),e.mapPoint&&!this._panEnabled&&this.getCoordsFromScreenPoint(l(e))!=null&&(this._vertexAddHandler(e),this._drawCompleteHandler(e))},i.TOOL),this.view.on(`pointer-down`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._panEnabled||(this._resetGeometry(),this._addVertexOnPointerUp=!0,this._cursorScreenPoint=l(e),this._activePointerId=e.pointerId,this._vertexAddHandler(e),this._isDragging=!1,e.pointerType===`touch`&&this._updateCursor()))},i.TOOL),this.view.on(`pointer-move`,e=>{this._abortSnapping(),this._activePointerId==null&&e.pointerType!==`touch`&&(this._cursorScreenPoint=l(e),this._updateCursor())},i.TOOL),this.view.on(`pointer-drag`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._isDragging=!0,this._cursorScreenPoint=l(e),this._updateCursor())},i.TOOL),this.view.on(`pointer-up`,e=>{this._shouldHandlePointerEvent(e)&&this._addVertexOnPointerUp&&(this._abortSnapping(),this._activePointerId=null,this._isDragging&&this._vertexAddHandler(e),this._committedVertices.length===2&&this._drawCompleteHandler(e),this._isDragging=!1)},i.TOOL),this.view.on(`key-down`,e=>{e.key===c.complete&&this._cursorScreenPoint?(this._abortSnapping(),this._vertexAddHandler(e),this._drawCompleteHandler(e)):e.key===c.pan&&(this._panEnabled=!0)},i.TOOL),this.view.on(`key-up`,e=>{e.key===c.pan&&(this._panEnabled=!1)},i.TOOL),this.view.on(`drag`,e=>{this._activePointerId!=null&&e.stopPropagation()},i.TOOL),this.view.on(`drag`,[`Shift`],e=>{e.stopPropagation()},i.TOOL)]}_getClickModeViewHandles(){return[this.view.on(`pointer-down`,e=>{this._abortSnapping(),this._cursorScreenPoint=l(e),this._activePointerId=e.pointerId,this._isDragging=!1,e.pointerType===`touch`&&this._updateCursor()},i.TOOL),this.view.on(`pointer-move`,e=>{this._abortSnapping(),this._cursorScreenPoint=l(e),this._activePointerId==null&&e.pointerType!==`touch`&&this._updateCursor()},i.TOOL),this.view.on(`pointer-drag`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._isDragging=!0)},i.TOOL),this.view.on(`pointer-up`,e=>{this._shouldHandlePointerEvent(e)&&(this._abortSnapping(),this._activePointerId=null,e.stopPropagation(),this._isDragging||this._vertexAddHandler(e),this.vertices.length===2&&!this._isDragging&&this._drawCompleteHandler(e),this._isDragging=!1)},i.TOOL),this.view.on(`key-down`,e=>{e.key===c.vertexAdd&&this._cursorScreenPoint&&(this._vertexAddHandler(e),this.vertices.length===2&&this._drawCompleteHandler(e)),e.key===c.complete&&this._cursorScreenPoint&&this.vertices.length===2&&(this._vertexAddHandler(e),this._drawCompleteHandler(e))},i.TOOL)]}async _addDrawTool(){let{LegacyDrawTool:e}=await import(`./LegacyDrawTool.js`),t=new e({view:this.view,elevationInfo:this.elevationInfo,hasZ:this.hasZ,geometryType:`segment`,mode:this.mode});this.destroyed?t.destroy():(this._drawTool=t,this.view.addAndActivateTool(t),this.addHandles([t.on(`vertex-add`,e=>{e.vertices.length===1&&this.emit(`vertex-add`,new m(this.view,e.vertices[0].vertexIndex,t.getVertexCoords()))}),t.on(`cursor-update`,e=>{e.vertices.length===1&&this.emit(`cursor-update`,new u(this.view,e.vertices[0].vertexIndex,t.getVertexCoords()))}),t.on(`complete`,e=>{this.emit(`draw-complete`,new f(t.getVertexCoords())),this._removeDrawTool()}),this.view.on(`key-down`,e=>{e.key===c.vertexAdd&&!e.repeat&&this.mode===`click`?t.drawOperation.numCommittedVertices>0?t.completeCreateOperation():t.drawOperation.commitStagedVertex():e.key===c.complete&&!e.repeat&&t.completeCreateOperation()},i.TOOL)]))}_removeDrawTool(){this._drawTool&&=(this.view.tools.remove(this._drawTool),null)}_addVertex(e){let t=this._coordinateHelper.arrayToVector(e);if(this._isDuplicateOfLastVertex(t))return;this._lastVertexUnsnapped=this._stagedVertexUnsnapped,this._popCursorVertex(),this._editGeometryOperations.appendVertexToFirstPart(t),this._committedVertices.length===1&&(this.viewAlignedCoordinateSystem=p(this.view,this._committedVertices[0]));let n=this._committedVertices.length-1,r=new m(this.view,n,this.vertices);this.emit(`vertex-add`,r)}_updateCursor(){if(this._popCursorVertex(),!this._cursorScreenPoint)return;let e=this.getCoordsAndPointFromScreenPoint(this._cursorScreenPoint);e!=null&&this._pushCursorVertex(e.vertex,()=>this.emit(`cursor-update`,new u(this.view,this._activeComponent.vertices.length,this.vertices,this._stagedVertex==null?null:new r(this._stagedVertex))))}_completeDrawing(){if(this._drawTool){this._drawTool.completeCreateOperation(),this.removeAllHandles();return}if(this._activePointerId=null,this._popCursorVertex(),this._cursorScreenPoint=null,this._isDragging=!1,this._abortSnapping(),this._snappingManager!=null&&this._snappingManager.doneSnapping(),this.vertices.length<1)return;let e=new f(this.vertices);this.emit(`draw-complete`,e),e.defaultPrevented||this.removeAllHandles()}_resetGeometry(){this._editGeometryOperations.destroy(),this._editGeometryOperations=new s(new a(`polygon`,this._coordinateHelper),this.view.state.isGlobal),this._activeComponent=new o(this._coordinateHelper.spatialReference,this.view.state.isGlobal),this._editGeometryOperations.data.parts.push(this._activeComponent)}};e([t({type:h})],g.prototype,`mode`,void 0),g=e([n(`esri.views.draw.SegmentDrawAction`)],g);const _=g;export{_ as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import{createTask as r}from"../../../core/asyncUtils.js";import i from"../../../core/Collection.js";import a from"../../../core/Error.js";import{EventedAccessor as o}from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as c}from"../../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as u,assertIsSome as d}from"../../../core/maybe.js";import{throwIfAborted as f}from"../../../core/promiseUtils.js";import{pausable as p,when as m,watch as h,initial as g,sync as _}from"../../../core/reactiveUtils.js";import{UpdatingHandles as v}from"../../../core/support/UpdatingHandles.js";import y from"../../../geometry/Point.js";import b from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as x,geometryToCoordinates as S}from"../../../geometry/support/coordsUtils.js";import{interpolateCircle as C}from"../../../geometry/support/curves/circleUtils.js";import{deriveCircleFromCircularArc as w}from"../../../geometry/support/curves/circularArcUtils.js";import{getPaths as T,getEndpoint as E,isCircularArc as D,isEllipticArc4 as O,isBezierCurve as k,isCoordinate as A,cloneCurve as ee,isEllipticArc7 as j}from"../../../geometry/support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as M}from"../../../geometry/support/curves/ellipticArc4Utils.js";import{normalizeEllipticArcAfterEndpointChange as N}from"../../../geometry/support/curves/ellipticArc7Utils.js";import{wrapAtan2 as te}from"../../../geometry/support/curves/mathUtils.js";import{fromJSON as ne}from"../../../geometry/support/jsonUtils.js";import{isPoint as P}from"../../../geometry/support/typeUtils.js";import re from"../../../Graphic.js";import ie from"../../../layers/GraphicsLayer.js";import{SnappingVisualizer2D as ae}from"../../2d/interactive/SnappingVisualizer2D.js";import{ViewEventPriorities as oe}from"../../input/InputManager.js";import{createCoordinateHelper as se}from"../../interactive/coordinateHelper.js";import{EditGeometryOperations as ce}from"../../interactive/editGeometry/EditGeometryOperations.js";import{sketchKeys as le}from"../../interactive/keybindings.js";import ue from"../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as de}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as fe,enterInputModeIfAvailable as pe}from"../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as me}from"../../support/GeometryWorkerHandle.js";import{ConnectedReshapeManager as he}from"./ConnectedReshapeManager.js";import{screenDeltaToMapDelta as ge,getZFromVertexSnappingCandidates as _e,cloneMove as ve}from"./drawUtils.js";import F from"./GraphicMover.js";import ye from"./HighlightHelper.js";import{addUniqueLayer as be,isConnectedReshapeSupportedLayer as xe}from"./layerUtils.js";import{createTooltipInfos as Se,connectTooltip as Ce,updateTranslateTooltipInfo as we,updateTranslateVertexTooltipInfo as Te}from"./reshapeTooltipUtils.js";import{defaultSymbols as Ee,createMidpointGraphics as De,createVertexGraphics as I,createCurveControlPointGraphics as Oe,createCurveConstructionLineGraphics as ke,attributeKeys as L,getMidpoint as R,controlPointKinds as z,fastCloneGeometry as B,saveUpdatedCurveOrCoordinate as V,toolIdAttribute as Ae,splitCurve as je,isSingleSegmentCircle as Me,isSingleSegmentEllipse as Ne}from"./reshapeUtils.js";const H=Symbol(),U={mode:`on-the-ground`,offset:0};let W=class extends o{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._primaryGraphicMoving=!1,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this._relatedGraphicIndex=null,this._updatingHandles=new v,this._measurementWorker=new me({preloadGeodetic:!0}),this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=null,this.enableMidpoints=!0,this.enableCurveOnMidpoint=!1,this.enableMovement=!0,this.enableVertices=!0,this.filterVerticesEnabled=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.snappingManager=null,this.symbols=Ee,this.tooltip=null,this.activeTooltipInfo=null,this.toolOptions=new ue,this.type=`reshape`,this.vertexGraphics=new i,this.curveControlPointGraphics=new i,this.constructionLineGraphics=new i,this.midpointGraphics=new i,this.selectedManipulators=new i,this.view=null}initialize(){let e=this.view;this._highlightHelper=new ye({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=p(()=>this.graphic?.geometry,e=>{if(!e||this._primaryGraphicMoving===!0)return;let t=new Set(this.selectedManipulators.map(Q));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(Q(e))).forEach(e=>this._addToSelection(e)),this.curveControlPointGraphics.filter(e=>t.has(Q(e))).forEach(e=>this._addToSelection(e));let{enableMovement:n,_mover:r,graphic:i,midpointGraphics:a,vertexGraphics:o,curveControlPointGraphics:s}=this,c=o.concat(a,s).toArray();n&&c.push(i),r?.set(`graphics`,c)},_),this.tooltip=fe(()=>({view:e,options:this.toolOptions.tooltips})),this.tooltipInfos=Se(this.toolOptions),this.addHandles([m(()=>e?.ready,()=>{let{layer:e,view:t}=this;be(t,e),this.addHandles(t.on(`key-down`,e=>this._keyDownHandler(e),oe.TOOL))},{once:!0,initial:!0}),h(()=>this.graphic,()=>this.refresh()),...this._effectiveFilterVerticesEnabled?[h(()=>[this.view.viewpoint,this.view.stationary],()=>{this.view.stationary&&this.refresh()})]:[],h(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),h(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),h(()=>this.enableMidpoints,()=>this.refresh()),Ce(this.tooltip,()=>this._tooltipsContext,this._updatingHandles),h(()=>this.toolOptions.labels.enabled,e=>{this._segmentLabels?this._segmentLabels.visible=e:this._setUpGeometryHelper()}),h(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),g),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover=l(this._mover),this._connectedReshapeManager=l(this._connectedReshapeManager),this.tooltip=l(this.tooltip),this._segmentLabelsImportTask=u(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this._updatingHandles=l(this._updatingHandles),this._measurementWorker.destroy()}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??se(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _effectiveFilterVerticesEnabled(){return this.view?.type===`2d`&&this.filterVerticesEnabled}get test(){return{segmentLabels:this._segmentLabels}}get _selectedManipulator(){return this.selectedManipulators.length===1?this.selectedManipulators.at(0):void 0}get _tooltipsContext(){let{toolOptions:e,activeTooltipInfo:t,graphic:n}=this;return{toolOptions:e,activeTooltipInfo:t,graphic:n,selectedVertex:this._selectedManipulator,measurementWorker:this._measurementWorker,updateGeometry:(e,t,n,r,i)=>{this._setUpGeometryHelper();let a=e===this.graphic;if(a?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e),this._syncGeometryAfterVertexMove(e,t,r,i,!0),a){let{view:e}=this,r=e.toScreen(n),i=e.toScreen(t),a=(i?.x??0)-(r?.x??0),o=(i?.y??0)-(r?.y??0);this._emitMoveEvent(a,o),this._emitMoveStopEvent(a,o)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e)}}}get state(){let e=this.view.ready,t=!!(this.graphic&&this.layer);return e&&t?`active`:e?`ready`:`disabled`}get updating(){return!!this._updatingHandles?.updating||!!this._connectedReshapeManager?.updating||!!this._segmentLabels?.updating||!!this.snappingManager?.updating}isUIGraphic(e){return e===this.graphic||this._isMidpoint(e)||this._isCurveControlPoint(e)||this._isVertex(e)||this._isConstructionLine(e)}refresh(e){if(this._reset(),this._setup(),e){for(let t of this.vertexGraphics)e.has(Q(t))&&this._addToSelection(t);for(let t of this.curveControlPointGraphics)e.has(Q(t))&&this._addToSelection(t)}}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){let{selectedManipulators:e}=this;e.length&&this._removeVertices(e)}_setup(){let{graphic:e,layer:t}=this;if(!t||e?.geometry==null)return;let n=e.geometry;n.type===`mesh`||n.type===`extent`?this._logGeometryTypeError():(n.type===`polygon`&&x(n),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager(),this._setUpGeometryHelper())}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){let e=this.graphic.geometry;e==null||e.type===`mesh`||e.type===`extent`?(this._segmentLabels=l(this._segmentLabels),this._logGeometryTypeError()):(this._editGeometryOperations?this._syncEditGeometryOperations(e):this._editGeometryOperations=ce.fromGeometry(e,2,{allowCurves:!0}),this._updatingHandles.consumePromise(this._setupSegmentLabels()))}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new ie({listMode:`hide`,internal:!0,title:`Reshape snapping layer`}),this.view.map.layers.add(this._snappingGraphicsLayer);let n=this._editGeometryOperations;d(n),this._snappingContext=new de({editGeometryOperations:n,elevationInfo:U,pointer:t.viewEvent?.pointerType||`mouse`,excludeFeature:this.graphic,feature:this.graphic,visualizer:new ae(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._segmentLabelsImportTask=u(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this._activeOperationInfo=null,this._mover=l(this._mover),this.removeHandles(H),this._connectedReshapeManager?.finish()}_resetSnappingStateVars(){this.snappingManager!=null&&this.snappingManager.doneSnapping(),this._snappingGraphicsLayer!=null&&(this.view.map?.layers.remove(this._snappingGraphicsLayer),l(this._snappingGraphicsLayer)),this._snappingTask=u(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._removeCurveGraphics(e),this._updateTooltip()}_removeMidpointGraphics(e=this.layer){let{midpointGraphics:t}=this;e?.removeMany(t.items),t.drain(l)}_removeVertexGraphics(e=this.layer){let{vertexGraphics:t}=this;this._relatedGraphicIndex=null,e?.removeMany(t.items),t.drain(l)}_removeCurveGraphics(e=this.layer){let{curveControlPointGraphics:t,constructionLineGraphics:n}=this;e?.removeMany(t.items),e?.removeMany(n.items),t.drain(l),n.drain(l)}_setupGraphics(){let e=this.graphic.geometry;if(e!=null&&(e.type===`polyline`||e.type===`polygon`||e.type===`multipoint`)){let t=G(e);this.enableMidpoints&&e.type!==`multipoint`&&this._setUpMidpointGraphics(t),this.enableVertices&&(this._setUpVertexGraphics(t),this._setupCurveGraphics(t))}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();let t=De(e,this.symbols,this._coordinateHelper,this.graphic.geometry?.type===`polygon`,this.filterVerticesEnabled?this.view.extent:null,this.filterVerticesEnabled?this.view.resolution:-1);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){if(this._removeVertexGraphics(),this._effectiveFilterVerticesEnabled){let t=I(e,this.symbols,this._coordinateHelper,this.view.extent,this.view.resolution);this._relatedGraphicIndex=t.graphicIndex,this.vertexGraphics.addMany(t.graphics),this.layer.addMany(t.graphics)}else{let t=I(e,this.symbols,this._coordinateHelper,null,-1).graphics;this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}}_setupCurveGraphics(e){this._removeCurveGraphics();let t=Oe(e,this.symbols,this._coordinateHelper),n=ke(e,this.symbols,this._coordinateHelper);this.curveControlPointGraphics.addMany(t),this.constructionLineGraphics.addMany(n),this.layer.addMany(n),this.layer.addMany(t)}async _setupSegmentLabels(){let e=this._editGeometryOperations,t=this.toolOptions.labels.enabled;if(e&&this._segmentLabels?.context?.editGeometryOperations===e&&t||(this._segmentLabels=l(this._segmentLabels)),!this._segmentLabels&&e&&t){let t=this._segmentLabelsImportTask??=r(async e=>{let t=import(`../../2d/interactive/SegmentLabels2D.js`),{SegmentLabels2D:n}=await this._updatingHandles.addPromise(t);return e.aborted?null:n}),n=await this._updatingHandles.addPromise(t.promise);if(!n)return;this._segmentLabels=l(this._segmentLabels),this._segmentLabels=new n({context:{view:this.view,editGeometryOperations:e,elevationInfo:U,labelOptions:this.toolOptions.labels},visible:!0})}}_updateSymbolsForTheme(){let e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set(`color`,e),hover:this.symbols.vertices.hover?.clone().set(`color`,e)},controlPoints:{...this.symbols.controlPoints,default:this.symbols.controlPoints.default.clone().set(`color`,e),hover:this.symbols.controlPoints.hover?.clone().set(`color`,e)},midpoints:{...this.symbols.midpoints},constructionLines:this.symbols.constructionLines.clone().set(`color`,e)};for(let e of this.vertexGraphics)e.symbol=this._isSelected(e)?this.symbols.vertices.selected:this._hoverGraphic===e?this.symbols.vertices.hover:this.symbols.vertices.default;for(let e of this.curveControlPointGraphics)e.symbol=this._isSelected(e)?this.symbols.controlPoints.selected:this._hoverGraphic===e?this.symbols.controlPoints.hover:this.symbols.controlPoints.default;for(let e of this.constructionLineGraphics)e.symbol=this.symbols.constructionLines}_storeRelatedVertexIndices(){let e=this.vertexGraphics.items;if(!e)return;let t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let n=0;n<t.length;n++){let r=[];for(let e=0;e<t.length;e++){if(n===e)continue;let i=t[n],a=t[e];i.x===a.x&&i.y===a.y&&r.push(e)}e[n].attributes[L.relatedGraphicIndices]=r}}_setupMover(){let{enableMovement:e,graphic:t,midpointGraphics:n,vertexGraphics:r,view:i}=this,a=r.concat(n,this.curveControlPointGraphics).toArray();e&&t.geometry?.type!==`multipoint`&&a.push(t),this._mover=new F({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:a,view:i,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){let{connectedReshapeProviders:e}=this;e!=null&&e.length!==0&&(this._connectedReshapeManager??=new he({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();let t=e.graphic,n=this._isCurveControlPoint(t);if(t===this.graphic)this.clearSelection(),this.emit(`graphic-click`,e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(e.viewEvent.button===2)return;let n=this.graphic.clone(),r=this._handleMidpointClickOrStartMove(e);this.refresh(),r.length&&this._emitVertexAddEvent([t],n,r)}else if(this._isVertex(t)||n){if(e.viewEvent.stopPropagation(),e.viewEvent.button===2){n||this._removeVertices(t);return}e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedManipulators.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){let{graphic:t,dx:n,dy:r}=e,i=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:i?`move`:`reshape`,totalDx:n,totalDy:r}}_onGraphicMoveStartCallback(e){let{dx:t,dy:n,graphic:r}=e,i=this._connectedReshapeManager,a=i?Fe(this.graphic):null;if(r===this.graphic){let{geometry:o}=r;this._primaryGraphicMoving=!0,this._setUpOperation(e),this._emitMoveStartEvent(t,n),a&&i?.startFeatureMove([a]),this._effectiveFilterVerticesEnabled&&this._resetGraphics(this.layer),o!=null&&o.type===`point`&&this._onHandleMove(r,t,n,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,n)});return}let{selectedManipulators:o}=this;if(!o.includes(r)){if(this._clearSelection(),this._isMidpoint(r)){let t=this.graphic.clone(),n=this._handleMidpointClickOrStartMove(e);n.length&&(this._emitVertexAddEvent([r],t,n),this._refreshGraphicIndicesAttributes(n[0]))}this._addToSelection(r)}if(this._setUpOperation(e),a){let e=o.filter(e=>this._isVertex(e));i?.startVertexMove(a,Ie(e))}this._emitReshapeStartEvent(r),this._onHandleMove(r,t,n,e,()=>{this._updateTooltip(r,e.viewEvent),this._emitReshapeEvent(r)})}_onGraphicMoveCallback(e){let t=this._activeOperationInfo;if(!t)return;let{dx:n,dy:r,graphic:i}=e;t.totalDx+=n,t.totalDy+=r;let{operationType:a}=t,{geometry:o}=i;if(o!=null){if(a===`move`){if(o.type===`point`)this._onHandleMove(i,n,r,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(n,r)});else if(o.type===`polyline`||o.type===`polygon`){let{dxMap:t,dyMap:i}=ge(n,r,this.view);if(!this._effectiveFilterVerticesEnabled){let e=G(o);this._updateVertexGraphicLocations(e)}else if(this.selectedManipulators.length>0){let e=this.selectedManipulators.toArray();this.selectedManipulators.removeAll();for(let t of e){if(t.geometry?.type===`point`){let{pathIndex:e,pointIndex:n}=t.attributes,r=T(o)[e][n];if(r){let e=E(r);t.geometry=this._coordinateHelper.arrayToPoint(e)}}this._addToSelection(t.clone())}}this._connectedReshapeManager?.translate(t,i,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(n,r)}this._syncEditGeometryOperations(o)}else this._onHandleMove(i,n,r,e,()=>{this._updateTooltip(i,e.viewEvent),this._emitReshapeEvent(i)})}}_onGraphicMoveStopCallback(e){let t=this._activeOperationInfo;if(this._primaryGraphicMoving=!1,!t)return;let{dx:n,dy:r,graphic:i,x:a,y:o}=e,{operationType:s}=t;t.totalDx+=n,t.totalDy+=r,this._onHandleMove(i,n,r,e,()=>this._handleVertexSnap(i,{x:a,y:o},s))}_afterMoveStop(e,t){if(this._effectiveFilterVerticesEnabled&&t===`move`){let e=new Set;for(let t of this.selectedManipulators)e.add(Q(t));this.refresh(e),this._updateTooltip()}else this._isMidpoint(e)||e.getAttribute(L.curveFromStraightEdgeFlag)?this.refresh():(this._updateTooltip(this._isVertex(e)?e:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_handleVertexSnap(e,t,n){let i=e.geometry,a=this.snappingManager?.getVertexCandidates(),o=this.callbacks.onVertexSnap,s=()=>n===`move`?this._emitMoveStopEvent():this._emitReshapeStopEvent(e);!o||!i||!P(i)||!a||a.length===0?(s(),this._afterMoveStop(e,n)):(u(this._snappingTask),this._snappingTask=r(async r=>{try{let n=await o(i,t,a);f(r);let s=ne(n);this._coordinateHelper.hasZ()||(s.z=void 0),this._syncGeometryAfterVertexMove(e,s,0,0),e.geometry=s}finally{s(),this._afterMoveStop(e,n)}}))}_updateVertexGraphicLocations(e){let{_coordinateHelper:t}=this;for(let n of this.vertexGraphics){let{pathIndex:r,pointIndex:i}=n.attributes;n.geometry=t.arrayToPoint(E(e[r][i]))}this._updateMidpointGraphicLocations(e),this._updateCurveGraphicLocations(e)}_updateMidpointGraphicLocations(e,t){let{_coordinateHelper:n}=this;if(t)for(let r of this.midpointGraphics){let{pathIndex:i,pointIndexStart:a,pointIndexEnd:o}=r.attributes;if(!t.has(i))continue;let s=t.get(i);if(!s.has(a)&&!s.has(o))continue;let c=e[i];r.geometry=new y(R(c[a],c[o],n))}else for(let t of this.midpointGraphics){let{pathIndex:r,pointIndexStart:i,pointIndexEnd:a}=t.attributes,o=e[r];t.geometry=new y(R(o[i],o[a],n))}}_updateCurveGraphicLocations(e){let{spatialReference:t}=this._coordinateHelper,n=new Map;for(let e of this.selectedManipulators){let[t,r]=Z(e);t!=null&&r!=null&&e.getAttribute(L.controlPointKind)&&c(n,t,()=>new Set)?.add(r)}for(let t of this.curveControlPointGraphics){let[r,i]=Z(t);if(n.get(r)?.has(i))continue;let a=e[r][i];if(D(a)||O(a)){let n=E(e[r][i-1]),o=D(a)?w(n,a):M(n,a),[s,c]=C(o,.25);t.geometry=new y({x:s,y:c,spatialReference:this._coordinateHelper.spatialReference})}else if(k(a)){let[e,n]=t.getAttribute(L.controlPointKind)===z.bezier.cp1?a.b[1]:a.b[2];t.geometry=new y({x:e,y:n,spatialReference:this._coordinateHelper.spatialReference})}}for(let n of this.constructionLineGraphics){let r=n.getAttribute(L.controlPointKind),[i,a]=Z(n),o=e[i],s=E(o[a-1]),c=E(o[a]),l=e[i][a];n.geometry=r===z.bezier.line1?new b({paths:[[[s[0],s[1]],[...l.b[1]]]],spatialReference:t}):new b({paths:[[[c[0],c[1]],[...l.b[2]]]],spatialReference:t})}}_refreshGraphicIndicesAttributes(e){let{componentIndex:t,vertexIndex:n}=e,r=e=>{let[r,i]=Z(e);r===t&&i>=n&&e.setAttribute(L.pointIndex,i+1)};this.vertexGraphics.forEach(r),this.curveControlPointGraphics.forEach(r),this.constructionLineGraphics.forEach(r);for(let e of this.midpointGraphics){if(e.getAttribute(L.pathIndex)!==t)continue;let r=e.getAttribute(L.pointIndexStart);r>=n&&(e.setAttribute(L.pointIndexStart,r+1),e.setAttribute(L.pointIndexEnd,e.getAttribute(L.pointIndexEnd)+1))}}_getVertexFromEditGeometry(e){let[t,n]=Z(e);return d(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[n]}_onHandleMove(e,t,n,i,a){u(this._snappingTask);let o=this._snappingContext;if(!o)return;let s=e.geometry,c=i.type===`graphic-move-stop`;if(!s||!P(s))a();else if(this.snappingManager!=null&&this.selectedManipulators.length<2&&!c){let i=this.snappingManager;this._stagedVertex=i.update({point:s,context:o}),this._syncGeometryAfterVertexMove(e,new y(this._stagedVertex),t,n,c),a(),this._snappingTask=r(async r=>{let l=await i.snap({point:s,context:o,signal:r});if(l.valid){let r=l.apply();r.z=this._coordinateHelper.hasZ()?_e(this.snappingManager)??r.z:void 0,this._stagedVertex=r,this._syncGeometryAfterVertexMove(e,new y(this._stagedVertex),t,n,c),a()}}),this._updatingHandles.consumePromise(this._snappingTask.promise)}else{let r=this._stagedVertex==null?s:new y(this._stagedVertex);this._syncGeometryAfterVertexMove(e,r,t,n,c),a()}}_syncGeometryAfterVertexMove(e,t,n,r,i=!1){let a=B(this._editGeometryOperations?.data.geometry);if(!a)return;let{_coordinateHelper:o}=this,s=o.pointToVector(t),c=this._getVertexFromEditGeometry(e),l=null;if(c){let e=o.getZ(s);l=[c.pos[0],c.pos[1]];let t=s[0]-c.pos[0],n=s[1]-c.pos[1],r=e==null?0:e-c.pos[2];(a.type===`point`||a.type===`mesh`)&&this._editGeometryOperations?.moveVertices([c],t,n,r),this._connectedReshapeManager?.translate(t,n,r)}if(a.type===`point`)e.geometry=t;else if(a.type===`mesh`)e.geometry=a.centerAt(t);else{if(e!==this.graphic){l&&!this._isVertex(e)&&(l=null);let[i,s]=Z(e),c=K(a),u=o.pointToArray(t);if(this._updateGeometryFromGraphic(e,c,i,s,u,a.type===`polygon`),this._isVertex(e)||this._isCurveControlPoint(e)){let t=new Map;t.set(i,new Set([s])),c=this._moveRelatedCoordinates(c,e,u,t,l),c=this._moveSelectedHandleCoordinates(c,e,n,r,a.type===`polygon`),this._updateMidpointGraphicLocations(c,t),this._updateCurveGraphicLocations(c)}else this._isMidpoint(e)&&this._updateCurveGraphicLocations(c);V(a,c)}this._updateGraphicGeometry(a),this._syncEditGeometryOperations(a),i&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_syncEditGeometryOperations(e){this._editGeometryOperations?.trySetGeometry(e)||(this._editGeometryOperations=null,this._setUpGeometryHelper())}_moveRelatedCoordinates(e,t,n,r,i){if(this._effectiveFilterVerticesEnabled&&this._relatedGraphicIndex&&i){let a=this._relatedGraphicIndex.search({minX:i[0],maxX:i[0],minY:i[1],maxY:i[1]});for(let o of a)o.coordinate[0]===i[0]&&o.coordinate[1]===i[1]&&o.graphic&&(r&&c(r,o.pathIndex,()=>new Set).add(o.pointIndex),X(e,o.pathIndex,o.pointIndex,n),this._relatedGraphicIndex.remove(o),o.coordinate[0]=t.geometry.x,o.coordinate[1]=t.geometry.y,o.graphic.geometry=t.geometry,this._relatedGraphicIndex.insert(o));return e}let{relatedGraphicIndices:a}=t.attributes;if(!a?.length)return e;for(let i of a){let a=this.vertexGraphics.at(i),[o,s]=Z(a);r&&c(r,o,()=>new Set).add(s),X(e,o,s,n),a.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,n,r,i){for(let a of this.selectedManipulators)if(a!==t){let[t,o]=Z(a),s=a.getAttribute(L.relatedGraphicIndices),c=ve(a.geometry,n,r,this.view),l=S(c);if(a.geometry=c,this._updateGeometryFromGraphic(a,e,t,o,l,i),s?.length)for(let t of s){let n=this.vertexGraphics.at(t),[r,i]=Z(n);X(e,r,i,l),n.geometry=c}}return e}_updateGeometryFromGraphic(e,t,n,r,i,a){let o=t[n].length-1;this._isCurveControlPoint(e)?q(t,n,r,[i[0],i[1]],e.getAttribute(L.controlPointKind)):(X(t,n,r,i),a&&(r===0?X(t,n,o,i):r===o&&(t[n][0]=i)))}_onGraphicPointerOverCallback(e){let t=e.graphic;this._hoverGraphic=t;let n=this._isVertex(t);n&&!this._isSelected(t)?t.symbol=this.symbols.vertices.hover:this._isCurveControlPoint(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.controlPoints.hover),this._updateTooltip(n?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){let t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this._isCurveControlPoint(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.controlPoints.default),this.removeHandles(H),this._updateTooltip()}_handleMidpointClickOrStartMove(e){let{graphic:t}=e,n=this.graphic.geometry;if(n==null||n.type!==`polygon`&&n.type!==`polyline`)return[];let r=B(n),i=[],{[L.pathIndex]:a,[L.pointIndexStart]:o,[L.pointIndexEnd]:s}=t.attributes,c=S(t.geometry),l=s===0?o+1:s;t.attributes={[L.tool]:Ae,[L.pathIndex]:a,[L.pointIndex]:l,[L.relatedGraphicIndices]:[]};let u=K(r),d=u[a][s];if(A(d)){if(this.enableCurveOnMidpoint&&e.viewEvent.native.shiftKey){let e=E(u[a][l]);u[a].splice(l,1,{c:[e,[c[0],c[1]]]}),t.setAttribute(L.controlPointKind,z.circle.interior),t.setAttribute(L.curveFromStraightEdgeFlag,!0),this.midpointGraphics.remove(t),this.curveControlPointGraphics.push(t),V(r,u)}else u[a].splice(l,0,c),i.push({coordinates:u[a][l],componentIndex:a,vertexIndex:l})}else{let e=E(u[a][o]),t=je(e,d,.5,this._coordinateHelper);u[a].splice(s,1,...t),i.push({coordinates:E(u[a][l]),componentIndex:a,vertexIndex:l})}return this._updateGraphicGeometry(r),this._syncEditGeometryOperations(r),i}_addToSelection(e){let t=$(e);for(let e of t)e.symbol=this._isCurveControlPoint(e)?this.symbols.controlPoints.selected:this.symbols.vertices.selected,this.selectedManipulators.add(e),this._updateTooltip(e);this._emitSelectEvent(t)}_removeFromSelection(e,t){if(this._isVertex(e)){let{vertices:n}=this.symbols;e.symbol=t?n.hover:n.default}else if(this._isCurveControlPoint(e)){let{controlPoints:n}=this.symbols;e.symbol=t?n.hover:n.default}this.selectedManipulators.remove(e),this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){let e=this.selectedManipulators.toArray(),{controlPoints:t,vertices:n}=this.symbols;if(e.length>0){for(let r of e)this._isVertex(r)?r.symbol=n.default:this._isCurveControlPoint(r)&&(r.symbol=t.default);this.selectedManipulators.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){this._activeOperationInfo==null&&pe(e,this.tooltip)||le.delete.includes(e.key)&&!e.repeat&&this.selectedManipulators.length&&(this._removeVertices(this.selectedManipulators),e.stopPropagation())}_removeVertices(e){let t=this.graphic.geometry,n=this.vertexGraphics.length;if(t==null||t.type!==`polygon`&&t.type!==`polyline`&&t.type!==`multipoint`||t.type===`polygon`&&n<4||t.type===`multipoint`&&n<2||t.type===`polyline`&&n<3)return;let r=this.graphic.clone(),i=B(t),a=K(i),o=[],s=$(e);for(let e of s){if(this._isCurveControlPoint(e))continue;let{x:t,y:n}=e.geometry;for(let e=0;e<a.length;e++){let r=a[e];for(let i=0;i<r.length;i++){let[s,c]=E(r[i]);if(t===s&&n===c){o.push({coordinates:E(a[e][i]),componentIndex:e,vertexIndex:i}),a[e].splice(Number(i),1);let t=a[e][i];t&&!A(t)&&(a[e][i]=E(t))}}}}if(i.type===`polygon`)a=a.filter(e=>{if(e.length<2)return!1;let[t,n]=E(e[0]),[r,i]=E(e[e.length-1]);return e.length===2&&t===r&&n===i?!1:((t!==r||n!==i)&&e.push(e[0]),!0)});else if(i.type===`polyline`)for(let e of a)e.length===1&&a.splice(a.indexOf(e),1);V(i,a),this._updateGraphicGeometry(i),this.refresh(),this._emitVertexRemoveEvent(s,r,o)}_isVertex(e){return this.vertexGraphics.includes(e)}_isCurveControlPoint(e){return this.curveControlPointGraphics.includes(e)}_isConstructionLine(e){return this.constructionLineGraphics.includes(e)}_isSelected(e){return(this._isVertex(e)||this.curveControlPointGraphics.includes(e))&&this.selectedManipulators.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){let t=this._isMidpoint(e)?`copy`:`move`;this.addHandles(this.view.acquireCursor(t,`high`),H)}_updateTooltip(e,t){let n=null,{graphic:r,view:i,tooltipInfos:a}=this,o=r?.geometry;o?.type===`point`?n=a.movePoint:this._selectedManipulator?n=a.selectedVertex:e===this.graphic?(n=a.translateGraphic,we(n,i,this._tooltipsContext,this._updatingHandles,t)):e&&this.selectedManipulators.length>1&&(n=a.translateVertices,Te(n,i,o,this._tooltipsContext,this._updatingHandles,t)),this.activeTooltipInfo=n}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){let n={type:`move-start`,mover:this.graphic,dx:e,dy:t};this.emit(`move-start`,n),this.callbacks.onMoveStart?.(n)}_emitMoveEvent(e,t){let n={type:`move`,mover:this.graphic,dx:e,dy:t};this.emit(`move`,n),this.callbacks.onMove?.(n)}_emitMoveStopEvent(e,t){if(e==null||t==null){let n=this._activeOperationInfo;if(!n)return;e=n.totalDx,t=n.totalDy}let n={type:`move-stop`,mover:this.graphic,dx:e,dy:t};this.emit(`move-stop`,n),this.callbacks.onMoveStop?.(n)}_emitReshapeStartEvent(e){let t={type:`reshape-start`,graphic:this.graphic,mover:e,selected:this.selectedManipulators.toArray()};this.emit(`reshape-start`,t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){let t={type:`reshape`,graphic:this.graphic,mover:e,selected:this.selectedManipulators.toArray()};this.emit(`reshape`,t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){let t={type:`reshape-stop`,graphic:this.graphic,mover:e,selected:this.selectedManipulators.toArray()};this.emit(`reshape-stop`,t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){let t={type:`vertex-select`,added:e};this.emit(`select`,t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){let t={type:`vertex-deselect`,removed:e};this.emit(`deselect`,t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,n){let r={type:`vertex-add`,added:e,graphic:this.graphic,oldGraphic:t,vertices:n};this.emit(`vertex-add`,r),this.callbacks.onVertexAdd?.(r)}_emitVertexRemoveEvent(e,t,n){let r={type:`vertex-remove`,removed:e,graphic:this.graphic,oldGraphic:t,vertices:n};this.emit(`vertex-remove`,r),this.callbacks.onVertexRemove?.(r)}_logGeometryTypeError(){s.getLogger(this).error(new a(`reshape:invalid-geometry`,`Reshape operation not supported for the provided graphic. The geometry type is not supported.`))}};e([t()],W.prototype,`_activeOperationInfo`,void 0),e([t()],W.prototype,`_connectedReshapeManager`,void 0),e([t()],W.prototype,`_coordinateHelper`,null),e([t()],W.prototype,`_editGeometryOperations`,void 0),e([t()],W.prototype,`_effectiveFilterVerticesEnabled`,null),e([t()],W.prototype,`_primaryGraphicMoving`,void 0),e([t()],W.prototype,`_segmentLabels`,void 0),e([t()],W.prototype,`test`,null),e([t()],W.prototype,`_segmentLabelsImportTask`,void 0),e([t()],W.prototype,`_updatingHandles`,void 0),e([t()],W.prototype,`_selectedManipulator`,null),e([t()],W.prototype,`_tooltipsContext`,null),e([t()],W.prototype,`callbacks`,void 0),e([t()],W.prototype,`connectedReshapeProviders`,void 0),e([t()],W.prototype,`enableMidpoints`,void 0),e([t()],W.prototype,`enableCurveOnMidpoint`,void 0),e([t()],W.prototype,`enableMovement`,void 0),e([t()],W.prototype,`enableVertices`,void 0),e([t()],W.prototype,`filterVerticesEnabled`,void 0),e([t()],W.prototype,`graphic`,void 0),e([t()],W.prototype,`highlightName`,void 0),e([t()],W.prototype,`highlightsEnabled`,void 0),e([t()],W.prototype,`layer`,void 0),e([t()],W.prototype,`snappingManager`,void 0),e([t({readOnly:!0})],W.prototype,`state`,null),e([t()],W.prototype,`symbols`,void 0),e([t()],W.prototype,`tooltip`,void 0),e([t()],W.prototype,`tooltipInfos`,void 0),e([t()],W.prototype,`activeTooltipInfo`,void 0),e([t()],W.prototype,`updating`,null),e([t()],W.prototype,`toolOptions`,void 0),e([t({readOnly:!0})],W.prototype,`type`,void 0),e([t({readOnly:!0})],W.prototype,`vertexGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`curveControlPointGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`constructionLineGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`midpointGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`selectedManipulators`,void 0),e([t()],W.prototype,`view`,void 0),W=e([n(`esri.views.draw.support.Reshape`)],W);function G(e){let t=K(e);t=t.map(e=>e.slice());for(let e of t)for(let t=0;t<e.length;t++)e[t]=ee(e[t]);if(e.type===`polygon`)for(let e of t){let t=e[e.length-1];if(!A(t))continue;let n=e[0];n[0]===t[0]&&n[1]===t[1]&&e.length>2&&e.pop()}return t}function K(e){return e.type===`polygon`?e.curveRings?.slice()??e.rings.slice():e.type===`polyline`?e.curvePaths?.slice()??e.paths.slice():e.points.map(e=>[e])}function Pe(e,t,n,r){let i=e[t][n];if(D(i))i.c[1]=r;else if(O(i)){let i=E(e[t][n]);e[t][n]={c:[i,r]}}}function q(e,t,n,r,i){switch(i){case z.circle.interior:Pe(e,t,n,r);break;case z.bezier.cp1:e[t][n].b[1]=r;break;case z.bezier.cp2:e[t][n].b[2]=r}}function J(e,t){return e<t*1e-8}function Y(e,{cx:t,cy:n,isInvalid:r,thetaStart:i,thetaEnd:a},o,s){let[c,l]=e,[u,d]=o,f=u-c,p=d-l;t-=c,n-=l;let m=s?i>a:i<a,[h,g]=r?[t,n]:m?[-n,t]:[n,-t],[_,v]=[f,p],[y,b]=[h,g],x=_*b-v*y,S=(f**2+p**2)/2;if(J(Math.abs(x),S))return[(c+u)/2,(l+d)/2];let[C,w]=[b/x*S,-y/x*S],T=C**2+w**2,[E,D]=[f/2-C,p/2-w];if(J(E**2+D**2,T)){let[e,t]=m?[-w,C]:[w,-C];return[e+C+c,t+w+l]}let O=Math.sqrt((C**2+w**2)/(E**2+D**2))*Math.sign(f*h+p*g);return[E*O+C+c,D*O+w+l]}function X(e,t,n,r){let i=e[t][n],a=e[t].at(n+1);if(Me(e,t)){let n=e[t][1];e[t][0]=[...r],e[t][1]={a:[[...r],[...n.a[1]],0,0]};return}if(Ne(e,t)){let n=e[t][1],[i,a]=n.a[1],[o,s]=r,c=Math.hypot(o-i,s-a),[l,u]=[o-i,s-a],d=te(u,l);e[t][0]=[...r],e[t][1]={a:[[...r],[...n.a[1]],0,0,d,c,n.a[6]]};return}let o=E(i);if(A(i))i.splice(0,i.length,...r);else if(k(i))i.b[0].splice(0,i.b[0].length,...r);else if(D(i)||O(i)){let a=E(e[t][n-1]),o=D(i)?w(a,i):M(a,i);e[t].splice(n,1,{c:[[...r],Y(a,o,r,!0)]})}else if(j(i)){i.a[0].splice(0,i.a[0].length,...r);let a=E(e[t][n-1]);N(a,i)}if(a&&!A(a)&&!k(i)){if(D(a)||O(a)){let i=E(a),s=D(a)?w(o,a):M(o,a);e[t].splice(n+1,1,{c:[i,Y(i,s,r,!1)]})}else if(j(a)){let e=E(i);N(e,a)}}}function Z({attributes:e}){return[e?.[L.pathIndex]||0,e?.[L.pointIndex]||0]}function Q({attributes:e}){return`${e?.[L.pathIndex]}-${e?.[L.pointIndex]}-${e?.[L.controlPointKind]??`vertex`}`}function $(e){return e instanceof re?[e]:[...e]}function Fe(e){let t=e.sourceLayer??e.layer;return xe(t)?{graphic:e,layer:t}:null}function Ie(e){return e.toArray().map(({attributes:e})=>({pathIndex:e[L.pathIndex],vertexIndex:e[L.pointIndex]}))}const Le=W;export{Le as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../core/accessorSupport/decorators.js";import{createTask as r}from"../../../core/asyncUtils.js";import i from"../../../core/Collection.js";import a from"../../../core/Error.js";import{EventedAccessor as o}from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as c}from"../../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as u,assertIsSome as d}from"../../../core/maybe.js";import{throwIfAborted as f}from"../../../core/promiseUtils.js";import{pausable as p,when as m,watch as h,initial as g,sync as _}from"../../../core/reactiveUtils.js";import{UpdatingHandles as v}from"../../../core/support/UpdatingHandles.js";import y from"../../../geometry/Point.js";import b from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as x,geometryToCoordinates as S}from"../../../geometry/support/coordsUtils.js";import{interpolateCircle as C}from"../../../geometry/support/curves/circleUtils.js";import{deriveCircleFromCircularArc as w}from"../../../geometry/support/curves/circularArcUtils.js";import{getPaths as T,getEndpoint as E,isCircularArc as D,isEllipticArc4 as O,isBezierCurve as k,isCoordinate as A,cloneCurve as ee,isEllipticArc7 as j}from"../../../geometry/support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as M}from"../../../geometry/support/curves/ellipticArc4Utils.js";import{normalizeEllipticArcAfterEndpointChange as N}from"../../../geometry/support/curves/ellipticArc7Utils.js";import{wrapAtan2 as te}from"../../../geometry/support/curves/mathUtils.js";import{fromJSON as ne}from"../../../geometry/support/jsonUtils.js";import{isPoint as P}from"../../../geometry/support/typeUtils.js";import re from"../../../Graphic.js";import ie from"../../../layers/GraphicsLayer.js";import{SnappingVisualizer2D as ae}from"../../2d/interactive/SnappingVisualizer2D.js";import{ViewEventPriorities as oe}from"../../input/InputManager.js";import{createCoordinateHelper as se}from"../../interactive/coordinateHelper.js";import{EditGeometryOperations as ce}from"../../interactive/editGeometry/EditGeometryOperations.js";import{sketchKeys as le}from"../../interactive/keybindings.js";import ue from"../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as de}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as fe,enterInputModeIfAvailable as pe}from"../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as me}from"../../support/GeometryWorkerHandle.js";import{ConnectedReshapeManager as he}from"./ConnectedReshapeManager.js";import{screenDeltaToMapDelta as ge,getZFromVertexSnappingCandidates as _e,cloneMove as ve}from"./drawUtils.js";import F from"./GraphicMover.js";import ye from"./HighlightHelper.js";import{addUniqueLayer as be,isConnectedReshapeSupportedLayer as xe}from"./layerUtils.js";import{createTooltipInfos as Se,connectTooltip as Ce,updateTranslateTooltipInfo as we,updateTranslateVertexTooltipInfo as Te}from"./reshapeTooltipUtils.js";import{defaultSymbols as Ee,createMidpointGraphics as De,createVertexGraphics as I,createCurveControlPointGraphics as Oe,createCurveConstructionLineGraphics as ke,attributeKeys as L,getMidpoint as R,controlPointKinds as z,fastCloneGeometry as B,saveUpdatedCurveOrCoordinate as V,toolIdAttribute as Ae,splitCurve as je,isSingleSegmentCircle as Me,isSingleSegmentEllipse as Ne}from"./reshapeUtils.js";const H=Symbol(),U={mode:`on-the-ground`,offset:0};let W=class extends o{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._primaryGraphicMoving=!1,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this._relatedGraphicIndex=null,this._updatingHandles=new v,this._measurementWorker=new me({preloadGeodetic:!0}),this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=null,this.enableMidpoints=!0,this.enableCurveOnMidpoint=!1,this.enableMovement=!0,this.enableVertices=!0,this.filterVerticesEnabled=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.snappingManager=null,this.symbols=Ee,this.tooltip=null,this.activeTooltipInfo=null,this.toolOptions=new ue,this.type=`reshape`,this.vertexGraphics=new i,this.curveControlPointGraphics=new i,this.constructionLineGraphics=new i,this.midpointGraphics=new i,this.selectedManipulators=new i,this.view=null}initialize(){let e=this.view;this._highlightHelper=new ye({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=p(()=>this.graphic?.geometry,e=>{if(!e||this._primaryGraphicMoving===!0)return;let t=new Set(this.selectedManipulators.map(Q));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(Q(e))).forEach(e=>this._addToSelection(e)),this.curveControlPointGraphics.filter(e=>t.has(Q(e))).forEach(e=>this._addToSelection(e));let{enableMovement:n,_mover:r,graphic:i,midpointGraphics:a,vertexGraphics:o,curveControlPointGraphics:s}=this,c=o.concat(a,s).toArray();n&&c.push(i),r?.set(`graphics`,c)},_),this.tooltip=fe(()=>({view:e,options:this.toolOptions.tooltips})),this.tooltipInfos=Se(this.toolOptions),this.addHandles([m(()=>e?.ready,()=>{let{layer:e,view:t}=this;be(t,e),this.addHandles(t.on(`key-down`,e=>this._keyDownHandler(e),oe.TOOL))},{once:!0,initial:!0}),h(()=>this.graphic,()=>this.refresh()),...this._effectiveFilterVerticesEnabled?[h(()=>[this.view.viewpoint,this.view.stationary],()=>{this.view.stationary&&this.refresh()})]:[],h(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),h(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),h(()=>this.enableMidpoints,()=>this.refresh()),Ce(this.tooltip,()=>this._tooltipsContext,this._updatingHandles),h(()=>this.toolOptions.labels.enabled,e=>{this._segmentLabels?this._segmentLabels.visible=e:this._setUpGeometryHelper()}),h(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),g),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover=l(this._mover),this._connectedReshapeManager=l(this._connectedReshapeManager),this.tooltip=l(this.tooltip),this._segmentLabelsImportTask=u(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this._updatingHandles=l(this._updatingHandles),this._measurementWorker.destroy()}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??se(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _effectiveFilterVerticesEnabled(){return this.view?.type===`2d`&&this.filterVerticesEnabled}get test(){return{segmentLabels:this._segmentLabels}}get _selectedManipulator(){return this.selectedManipulators.length===1?this.selectedManipulators.at(0):void 0}get _tooltipsContext(){let{toolOptions:e,activeTooltipInfo:t,graphic:n}=this;return{toolOptions:e,activeTooltipInfo:t,graphic:n,selectedVertex:this._selectedManipulator,measurementWorker:this._measurementWorker,updateGeometry:(e,t,n,r,i)=>{this._setUpGeometryHelper();let a=e===this.graphic;if(a?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e),this._syncGeometryAfterVertexMove(e,t,r,i,!0),a){let{view:e}=this,r=e.toScreen(n),i=e.toScreen(t),a=(i?.x??0)-(r?.x??0),o=(i?.y??0)-(r?.y??0);this._emitMoveEvent(a,o),this._emitMoveStopEvent(a,o)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e)}}}get state(){let e=this.view.ready,t=!!(this.graphic&&this.layer);return e&&t?`active`:e?`ready`:`disabled`}get updating(){return!!this._updatingHandles?.updating||!!this._connectedReshapeManager?.updating||!!this._segmentLabels?.updating||!!this.snappingManager?.updating}isUIGraphic(e){return e===this.graphic||this._isMidpoint(e)||this._isCurveControlPoint(e)||this._isVertex(e)||this._isConstructionLine(e)}refresh(e){if(this._reset(),this._setup(),e){for(let t of this.vertexGraphics)e.has(Q(t))&&this._addToSelection(t);for(let t of this.curveControlPointGraphics)e.has(Q(t))&&this._addToSelection(t)}}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){let{selectedManipulators:e}=this;e.length&&this._removeVertices(e)}_setup(){let{graphic:e,layer:t}=this;if(!t||e?.geometry==null)return;let n=e.geometry;n.type===`mesh`||n.type===`extent`?this._logGeometryTypeError():(n.type===`polygon`&&x(n),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager(),this._setUpGeometryHelper())}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){let e=this.graphic.geometry;e==null||e.type===`mesh`||e.type===`extent`?(this._segmentLabels=l(this._segmentLabels),this._logGeometryTypeError()):(this._editGeometryOperations?this._syncEditGeometryOperations(e):this._editGeometryOperations=ce.fromGeometry(e,this.view.state.isGlobal,{allowCurves:!0}),this._updatingHandles.consumePromise(this._setupSegmentLabels()))}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new ie({listMode:`hide`,internal:!0,title:`Reshape snapping layer`}),this.view.map.layers.add(this._snappingGraphicsLayer);let n=this._editGeometryOperations;d(n),this._snappingContext=new de({editGeometryOperations:n,elevationInfo:U,pointer:t.viewEvent?.pointerType||`mouse`,excludeFeature:this.graphic,feature:this.graphic,visualizer:new ae(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._segmentLabelsImportTask=u(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this._activeOperationInfo=null,this._mover=l(this._mover),this.removeHandles(H),this._connectedReshapeManager?.finish()}_resetSnappingStateVars(){this.snappingManager!=null&&this.snappingManager.doneSnapping(),this._snappingGraphicsLayer!=null&&(this.view.map?.layers.remove(this._snappingGraphicsLayer),l(this._snappingGraphicsLayer)),this._snappingTask=u(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._removeCurveGraphics(e),this._updateTooltip()}_removeMidpointGraphics(e=this.layer){let{midpointGraphics:t}=this;e?.removeMany(t.items),t.drain(l)}_removeVertexGraphics(e=this.layer){let{vertexGraphics:t}=this;this._relatedGraphicIndex=null,e?.removeMany(t.items),t.drain(l)}_removeCurveGraphics(e=this.layer){let{curveControlPointGraphics:t,constructionLineGraphics:n}=this;e?.removeMany(t.items),e?.removeMany(n.items),t.drain(l),n.drain(l)}_setupGraphics(){let e=this.graphic.geometry;if(e!=null&&(e.type===`polyline`||e.type===`polygon`||e.type===`multipoint`)){let t=G(e);this.enableMidpoints&&e.type!==`multipoint`&&this._setUpMidpointGraphics(t),this.enableVertices&&(this._setUpVertexGraphics(t),this._setupCurveGraphics(t))}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();let t=De(e,this.symbols,this._coordinateHelper,this.graphic.geometry?.type===`polygon`,this.filterVerticesEnabled?this.view.extent:null,this.filterVerticesEnabled?this.view.resolution:-1);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){if(this._removeVertexGraphics(),this._effectiveFilterVerticesEnabled){let t=I(e,this.symbols,this._coordinateHelper,this.view.extent,this.view.resolution);this._relatedGraphicIndex=t.graphicIndex,this.vertexGraphics.addMany(t.graphics),this.layer.addMany(t.graphics)}else{let t=I(e,this.symbols,this._coordinateHelper,null,-1).graphics;this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}}_setupCurveGraphics(e){this._removeCurveGraphics();let t=Oe(e,this.symbols,this._coordinateHelper),n=ke(e,this.symbols,this._coordinateHelper);this.curveControlPointGraphics.addMany(t),this.constructionLineGraphics.addMany(n),this.layer.addMany(n),this.layer.addMany(t)}async _setupSegmentLabels(){let e=this._editGeometryOperations,t=this.toolOptions.labels.enabled;if(e&&this._segmentLabels?.context?.editGeometryOperations===e&&t||(this._segmentLabels=l(this._segmentLabels)),!this._segmentLabels&&e&&t){let t=this._segmentLabelsImportTask??=r(async e=>{let t=import(`../../2d/interactive/SegmentLabels2D.js`),{SegmentLabels2D:n}=await this._updatingHandles.addPromise(t);return e.aborted?null:n}),n=await this._updatingHandles.addPromise(t.promise);if(!n)return;this._segmentLabels=l(this._segmentLabels),this._segmentLabels=new n({context:{view:this.view,editGeometryOperations:e,elevationInfo:U,labelOptions:this.toolOptions.labels},visible:!0})}}_updateSymbolsForTheme(){let e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set(`color`,e),hover:this.symbols.vertices.hover?.clone().set(`color`,e)},controlPoints:{...this.symbols.controlPoints,default:this.symbols.controlPoints.default.clone().set(`color`,e),hover:this.symbols.controlPoints.hover?.clone().set(`color`,e)},midpoints:{...this.symbols.midpoints},constructionLines:this.symbols.constructionLines.clone().set(`color`,e)};for(let e of this.vertexGraphics)e.symbol=this._isSelected(e)?this.symbols.vertices.selected:this._hoverGraphic===e?this.symbols.vertices.hover:this.symbols.vertices.default;for(let e of this.curveControlPointGraphics)e.symbol=this._isSelected(e)?this.symbols.controlPoints.selected:this._hoverGraphic===e?this.symbols.controlPoints.hover:this.symbols.controlPoints.default;for(let e of this.constructionLineGraphics)e.symbol=this.symbols.constructionLines}_storeRelatedVertexIndices(){let e=this.vertexGraphics.items;if(!e)return;let t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let n=0;n<t.length;n++){let r=[];for(let e=0;e<t.length;e++){if(n===e)continue;let i=t[n],a=t[e];i.x===a.x&&i.y===a.y&&r.push(e)}e[n].attributes[L.relatedGraphicIndices]=r}}_setupMover(){let{enableMovement:e,graphic:t,midpointGraphics:n,vertexGraphics:r,view:i}=this,a=r.concat(n,this.curveControlPointGraphics).toArray();e&&t.geometry?.type!==`multipoint`&&a.push(t),this._mover=new F({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:a,view:i,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){let{connectedReshapeProviders:e}=this;e!=null&&e.length!==0&&(this._connectedReshapeManager??=new he({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();let t=e.graphic,n=this._isCurveControlPoint(t);if(t===this.graphic)this.clearSelection(),this.emit(`graphic-click`,e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(e.viewEvent.button===2)return;let n=this.graphic.clone(),r=this._handleMidpointClickOrStartMove(e);this.refresh(),r.length&&this._emitVertexAddEvent([t],n,r)}else if(this._isVertex(t)||n){if(e.viewEvent.stopPropagation(),e.viewEvent.button===2){n||this._removeVertices(t);return}e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedManipulators.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){let{graphic:t,dx:n,dy:r}=e,i=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:i?`move`:`reshape`,totalDx:n,totalDy:r}}_onGraphicMoveStartCallback(e){let{dx:t,dy:n,graphic:r}=e,i=this._connectedReshapeManager,a=i?Fe(this.graphic):null;if(r===this.graphic){let{geometry:o}=r;this._primaryGraphicMoving=!0,this._setUpOperation(e),this._emitMoveStartEvent(t,n),a&&i?.startFeatureMove([a]),this._effectiveFilterVerticesEnabled&&this._resetGraphics(this.layer),o!=null&&o.type===`point`&&this._onHandleMove(r,t,n,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,n)});return}let{selectedManipulators:o}=this;if(!o.includes(r)){if(this._clearSelection(),this._isMidpoint(r)){let t=this.graphic.clone(),n=this._handleMidpointClickOrStartMove(e);n.length&&(this._emitVertexAddEvent([r],t,n),this._refreshGraphicIndicesAttributes(n[0]))}this._addToSelection(r)}if(this._setUpOperation(e),a){let e=o.filter(e=>this._isVertex(e));i?.startVertexMove(a,Ie(e))}this._emitReshapeStartEvent(r),this._onHandleMove(r,t,n,e,()=>{this._updateTooltip(r,e.viewEvent),this._emitReshapeEvent(r)})}_onGraphicMoveCallback(e){let t=this._activeOperationInfo;if(!t)return;let{dx:n,dy:r,graphic:i}=e;t.totalDx+=n,t.totalDy+=r;let{operationType:a}=t,{geometry:o}=i;if(o!=null){if(a===`move`){if(o.type===`point`)this._onHandleMove(i,n,r,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(n,r)});else if(o.type===`polyline`||o.type===`polygon`){let{dxMap:t,dyMap:i}=ge(n,r,this.view);if(!this._effectiveFilterVerticesEnabled){let e=G(o);this._updateVertexGraphicLocations(e)}else if(this.selectedManipulators.length>0){let e=this.selectedManipulators.toArray();this.selectedManipulators.removeAll();for(let t of e){if(t.geometry?.type===`point`){let{pathIndex:e,pointIndex:n}=t.attributes,r=T(o)[e][n];if(r){let e=E(r);t.geometry=this._coordinateHelper.arrayToPoint(e)}}this._addToSelection(t.clone())}}this._connectedReshapeManager?.translate(t,i,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(n,r)}this._syncEditGeometryOperations(o)}else this._onHandleMove(i,n,r,e,()=>{this._updateTooltip(i,e.viewEvent),this._emitReshapeEvent(i)})}}_onGraphicMoveStopCallback(e){let t=this._activeOperationInfo;if(this._primaryGraphicMoving=!1,!t)return;let{dx:n,dy:r,graphic:i,x:a,y:o}=e,{operationType:s}=t;t.totalDx+=n,t.totalDy+=r,this._onHandleMove(i,n,r,e,()=>this._handleVertexSnap(i,{x:a,y:o},s))}_afterMoveStop(e,t){if(this._effectiveFilterVerticesEnabled&&t===`move`){let e=new Set;for(let t of this.selectedManipulators)e.add(Q(t));this.refresh(e),this._updateTooltip()}else this._isMidpoint(e)||e.getAttribute(L.curveFromStraightEdgeFlag)?this.refresh():(this._updateTooltip(this._isVertex(e)?e:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_handleVertexSnap(e,t,n){let i=e.geometry,a=this.snappingManager?.getVertexCandidates(),o=this.callbacks.onVertexSnap,s=()=>n===`move`?this._emitMoveStopEvent():this._emitReshapeStopEvent(e);!o||!i||!P(i)||!a||a.length===0?(s(),this._afterMoveStop(e,n)):(u(this._snappingTask),this._snappingTask=r(async r=>{try{let n=await o(i,t,a);f(r);let s=ne(n);this._coordinateHelper.hasZ()||(s.z=void 0),this._syncGeometryAfterVertexMove(e,s,0,0),e.geometry=s}finally{s(),this._afterMoveStop(e,n)}}))}_updateVertexGraphicLocations(e){let{_coordinateHelper:t}=this;for(let n of this.vertexGraphics){let{pathIndex:r,pointIndex:i}=n.attributes;n.geometry=t.arrayToPoint(E(e[r][i]))}this._updateMidpointGraphicLocations(e),this._updateCurveGraphicLocations(e)}_updateMidpointGraphicLocations(e,t){let{_coordinateHelper:n}=this;if(t)for(let r of this.midpointGraphics){let{pathIndex:i,pointIndexStart:a,pointIndexEnd:o}=r.attributes;if(!t.has(i))continue;let s=t.get(i);if(!s.has(a)&&!s.has(o))continue;let c=e[i];r.geometry=new y(R(c[a],c[o],n))}else for(let t of this.midpointGraphics){let{pathIndex:r,pointIndexStart:i,pointIndexEnd:a}=t.attributes,o=e[r];t.geometry=new y(R(o[i],o[a],n))}}_updateCurveGraphicLocations(e){let{spatialReference:t}=this._coordinateHelper,n=new Map;for(let e of this.selectedManipulators){let[t,r]=Z(e);t!=null&&r!=null&&e.getAttribute(L.controlPointKind)&&c(n,t,()=>new Set)?.add(r)}for(let t of this.curveControlPointGraphics){let[r,i]=Z(t);if(n.get(r)?.has(i))continue;let a=e[r][i];if(D(a)||O(a)){let n=E(e[r][i-1]),o=D(a)?w(n,a):M(n,a),[s,c]=C(o,.25);t.geometry=new y({x:s,y:c,spatialReference:this._coordinateHelper.spatialReference})}else if(k(a)){let[e,n]=t.getAttribute(L.controlPointKind)===z.bezier.cp1?a.b[1]:a.b[2];t.geometry=new y({x:e,y:n,spatialReference:this._coordinateHelper.spatialReference})}}for(let n of this.constructionLineGraphics){let r=n.getAttribute(L.controlPointKind),[i,a]=Z(n),o=e[i],s=E(o[a-1]),c=E(o[a]),l=e[i][a];n.geometry=r===z.bezier.line1?new b({paths:[[[s[0],s[1]],[...l.b[1]]]],spatialReference:t}):new b({paths:[[[c[0],c[1]],[...l.b[2]]]],spatialReference:t})}}_refreshGraphicIndicesAttributes(e){let{componentIndex:t,vertexIndex:n}=e,r=e=>{let[r,i]=Z(e);r===t&&i>=n&&e.setAttribute(L.pointIndex,i+1)};this.vertexGraphics.forEach(r),this.curveControlPointGraphics.forEach(r),this.constructionLineGraphics.forEach(r);for(let e of this.midpointGraphics){if(e.getAttribute(L.pathIndex)!==t)continue;let r=e.getAttribute(L.pointIndexStart);r>=n&&(e.setAttribute(L.pointIndexStart,r+1),e.setAttribute(L.pointIndexEnd,e.getAttribute(L.pointIndexEnd)+1))}}_getVertexFromEditGeometry(e){let[t,n]=Z(e);return d(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[n]}_onHandleMove(e,t,n,i,a){u(this._snappingTask);let o=this._snappingContext;if(!o)return;let s=e.geometry,c=i.type===`graphic-move-stop`;if(!s||!P(s))a();else if(this.snappingManager!=null&&this.selectedManipulators.length<2&&!c){let i=this.snappingManager;this._stagedVertex=i.update({point:s,context:o}),this._syncGeometryAfterVertexMove(e,new y(this._stagedVertex),t,n,c),a(),this._snappingTask=r(async r=>{let l=await i.snap({point:s,context:o,signal:r});if(l.valid){let r=l.apply();r.z=this._coordinateHelper.hasZ()?_e(this.snappingManager)??r.z:void 0,this._stagedVertex=r,this._syncGeometryAfterVertexMove(e,new y(this._stagedVertex),t,n,c),a()}}),this._updatingHandles.consumePromise(this._snappingTask.promise)}else{let r=this._stagedVertex==null?s:new y(this._stagedVertex);this._syncGeometryAfterVertexMove(e,r,t,n,c),a()}}_syncGeometryAfterVertexMove(e,t,n,r,i=!1){let a=B(this._editGeometryOperations?.data.geometry);if(!a)return;let{_coordinateHelper:o}=this,s=o.pointToVector(t),c=this._getVertexFromEditGeometry(e),l=null;if(c){let e=o.getZ(s);l=[c.pos[0],c.pos[1]];let t=s[0]-c.pos[0],n=s[1]-c.pos[1],r=e==null?0:e-c.pos[2];(a.type===`point`||a.type===`mesh`)&&this._editGeometryOperations?.moveVertices([c],t,n,r),this._connectedReshapeManager?.translate(t,n,r)}if(a.type===`point`)e.geometry=t;else if(a.type===`mesh`)e.geometry=a.centerAt(t);else{if(e!==this.graphic){l&&!this._isVertex(e)&&(l=null);let[i,s]=Z(e),c=K(a),u=o.pointToArray(t);if(this._updateGeometryFromGraphic(e,c,i,s,u,a.type===`polygon`),this._isVertex(e)||this._isCurveControlPoint(e)){let t=new Map;t.set(i,new Set([s])),c=this._moveRelatedCoordinates(c,e,u,t,l),c=this._moveSelectedHandleCoordinates(c,e,n,r,a.type===`polygon`),this._updateMidpointGraphicLocations(c,t),this._updateCurveGraphicLocations(c)}else this._isMidpoint(e)&&this._updateCurveGraphicLocations(c);V(a,c)}this._updateGraphicGeometry(a),this._syncEditGeometryOperations(a),i&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_syncEditGeometryOperations(e){this._editGeometryOperations?.trySetGeometry(e)||(this._editGeometryOperations=null,this._setUpGeometryHelper())}_moveRelatedCoordinates(e,t,n,r,i){if(this._effectiveFilterVerticesEnabled&&this._relatedGraphicIndex&&i){let a=this._relatedGraphicIndex.search({minX:i[0],maxX:i[0],minY:i[1],maxY:i[1]});for(let o of a)o.coordinate[0]===i[0]&&o.coordinate[1]===i[1]&&o.graphic&&(r&&c(r,o.pathIndex,()=>new Set).add(o.pointIndex),X(e,o.pathIndex,o.pointIndex,n),this._relatedGraphicIndex.remove(o),o.coordinate[0]=t.geometry.x,o.coordinate[1]=t.geometry.y,o.graphic.geometry=t.geometry,this._relatedGraphicIndex.insert(o));return e}let{relatedGraphicIndices:a}=t.attributes;if(!a?.length)return e;for(let i of a){let a=this.vertexGraphics.at(i),[o,s]=Z(a);r&&c(r,o,()=>new Set).add(s),X(e,o,s,n),a.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,n,r,i){for(let a of this.selectedManipulators)if(a!==t){let[t,o]=Z(a),s=a.getAttribute(L.relatedGraphicIndices),c=ve(a.geometry,n,r,this.view),l=S(c);if(a.geometry=c,this._updateGeometryFromGraphic(a,e,t,o,l,i),s?.length)for(let t of s){let n=this.vertexGraphics.at(t),[r,i]=Z(n);X(e,r,i,l),n.geometry=c}}return e}_updateGeometryFromGraphic(e,t,n,r,i,a){let o=t[n].length-1;this._isCurveControlPoint(e)?q(t,n,r,[i[0],i[1]],e.getAttribute(L.controlPointKind)):(X(t,n,r,i),a&&(r===0?X(t,n,o,i):r===o&&(t[n][0]=i)))}_onGraphicPointerOverCallback(e){let t=e.graphic;this._hoverGraphic=t;let n=this._isVertex(t);n&&!this._isSelected(t)?t.symbol=this.symbols.vertices.hover:this._isCurveControlPoint(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.controlPoints.hover),this._updateTooltip(n?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){let t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this._isCurveControlPoint(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.controlPoints.default),this.removeHandles(H),this._updateTooltip()}_handleMidpointClickOrStartMove(e){let{graphic:t}=e,n=this.graphic.geometry;if(n==null||n.type!==`polygon`&&n.type!==`polyline`)return[];let r=B(n),i=[],{[L.pathIndex]:a,[L.pointIndexStart]:o,[L.pointIndexEnd]:s}=t.attributes,c=S(t.geometry),l=s===0?o+1:s;t.attributes={[L.tool]:Ae,[L.pathIndex]:a,[L.pointIndex]:l,[L.relatedGraphicIndices]:[]};let u=K(r),d=u[a][s];if(A(d)){if(this.enableCurveOnMidpoint&&e.viewEvent.native.shiftKey){let e=E(u[a][l]);u[a].splice(l,1,{c:[e,[c[0],c[1]]]}),t.setAttribute(L.controlPointKind,z.circle.interior),t.setAttribute(L.curveFromStraightEdgeFlag,!0),this.midpointGraphics.remove(t),this.curveControlPointGraphics.push(t),V(r,u)}else u[a].splice(l,0,c),i.push({coordinates:u[a][l],componentIndex:a,vertexIndex:l})}else{let e=E(u[a][o]),t=je(e,d,.5,this._coordinateHelper);u[a].splice(s,1,...t),i.push({coordinates:E(u[a][l]),componentIndex:a,vertexIndex:l})}return this._updateGraphicGeometry(r),this._syncEditGeometryOperations(r),i}_addToSelection(e){let t=$(e);for(let e of t)e.symbol=this._isCurveControlPoint(e)?this.symbols.controlPoints.selected:this.symbols.vertices.selected,this.selectedManipulators.add(e),this._updateTooltip(e);this._emitSelectEvent(t)}_removeFromSelection(e,t){if(this._isVertex(e)){let{vertices:n}=this.symbols;e.symbol=t?n.hover:n.default}else if(this._isCurveControlPoint(e)){let{controlPoints:n}=this.symbols;e.symbol=t?n.hover:n.default}this.selectedManipulators.remove(e),this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){let e=this.selectedManipulators.toArray(),{controlPoints:t,vertices:n}=this.symbols;if(e.length>0){for(let r of e)this._isVertex(r)?r.symbol=n.default:this._isCurveControlPoint(r)&&(r.symbol=t.default);this.selectedManipulators.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){this._activeOperationInfo==null&&pe(e,this.tooltip)||le.delete.includes(e.key)&&!e.repeat&&this.selectedManipulators.length&&(this._removeVertices(this.selectedManipulators),e.stopPropagation())}_removeVertices(e){let t=this.graphic.geometry,n=this.vertexGraphics.length;if(t==null||t.type!==`polygon`&&t.type!==`polyline`&&t.type!==`multipoint`||t.type===`polygon`&&n<4||t.type===`multipoint`&&n<2||t.type===`polyline`&&n<3)return;let r=this.graphic.clone(),i=B(t),a=K(i),o=[],s=$(e);for(let e of s){if(this._isCurveControlPoint(e))continue;let{x:t,y:n}=e.geometry;for(let e=0;e<a.length;e++){let r=a[e];for(let i=0;i<r.length;i++){let[s,c]=E(r[i]);if(t===s&&n===c){o.push({coordinates:E(a[e][i]),componentIndex:e,vertexIndex:i}),a[e].splice(Number(i),1);let t=a[e][i];t&&!A(t)&&(a[e][i]=E(t))}}}}if(i.type===`polygon`)a=a.filter(e=>{if(e.length<2)return!1;let[t,n]=E(e[0]),[r,i]=E(e[e.length-1]);return e.length===2&&t===r&&n===i?!1:((t!==r||n!==i)&&e.push(e[0]),!0)});else if(i.type===`polyline`)for(let e of a)e.length===1&&a.splice(a.indexOf(e),1);V(i,a),this._updateGraphicGeometry(i),this.refresh(),this._emitVertexRemoveEvent(s,r,o)}_isVertex(e){return this.vertexGraphics.includes(e)}_isCurveControlPoint(e){return this.curveControlPointGraphics.includes(e)}_isConstructionLine(e){return this.constructionLineGraphics.includes(e)}_isSelected(e){return(this._isVertex(e)||this.curveControlPointGraphics.includes(e))&&this.selectedManipulators.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){let t=this._isMidpoint(e)?`copy`:`move`;this.addHandles(this.view.acquireCursor(t,`high`),H)}_updateTooltip(e,t){let n=null,{graphic:r,view:i,tooltipInfos:a}=this,o=r?.geometry;o?.type===`point`?n=a.movePoint:this._selectedManipulator?n=a.selectedVertex:e===this.graphic?(n=a.translateGraphic,we(n,i,this._tooltipsContext,this._updatingHandles,t)):e&&this.selectedManipulators.length>1&&(n=a.translateVertices,Te(n,i,o,this._tooltipsContext,this._updatingHandles,t)),this.activeTooltipInfo=n}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){let n={type:`move-start`,mover:this.graphic,dx:e,dy:t};this.emit(`move-start`,n),this.callbacks.onMoveStart?.(n)}_emitMoveEvent(e,t){let n={type:`move`,mover:this.graphic,dx:e,dy:t};this.emit(`move`,n),this.callbacks.onMove?.(n)}_emitMoveStopEvent(e,t){if(e==null||t==null){let n=this._activeOperationInfo;if(!n)return;e=n.totalDx,t=n.totalDy}let n={type:`move-stop`,mover:this.graphic,dx:e,dy:t};this.emit(`move-stop`,n),this.callbacks.onMoveStop?.(n)}_emitReshapeStartEvent(e){let t={type:`reshape-start`,graphic:this.graphic,mover:e,selected:this.selectedManipulators.toArray()};this.emit(`reshape-start`,t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){let t={type:`reshape`,graphic:this.graphic,mover:e,selected:this.selectedManipulators.toArray()};this.emit(`reshape`,t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){let t={type:`reshape-stop`,graphic:this.graphic,mover:e,selected:this.selectedManipulators.toArray()};this.emit(`reshape-stop`,t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){let t={type:`vertex-select`,added:e};this.emit(`select`,t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){let t={type:`vertex-deselect`,removed:e};this.emit(`deselect`,t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,n){let r={type:`vertex-add`,added:e,graphic:this.graphic,oldGraphic:t,vertices:n};this.emit(`vertex-add`,r),this.callbacks.onVertexAdd?.(r)}_emitVertexRemoveEvent(e,t,n){let r={type:`vertex-remove`,removed:e,graphic:this.graphic,oldGraphic:t,vertices:n};this.emit(`vertex-remove`,r),this.callbacks.onVertexRemove?.(r)}_logGeometryTypeError(){s.getLogger(this).error(new a(`reshape:invalid-geometry`,`Reshape operation not supported for the provided graphic. The geometry type is not supported.`))}};e([t()],W.prototype,`_activeOperationInfo`,void 0),e([t()],W.prototype,`_connectedReshapeManager`,void 0),e([t()],W.prototype,`_coordinateHelper`,null),e([t()],W.prototype,`_editGeometryOperations`,void 0),e([t()],W.prototype,`_effectiveFilterVerticesEnabled`,null),e([t()],W.prototype,`_primaryGraphicMoving`,void 0),e([t()],W.prototype,`_segmentLabels`,void 0),e([t()],W.prototype,`test`,null),e([t()],W.prototype,`_segmentLabelsImportTask`,void 0),e([t()],W.prototype,`_updatingHandles`,void 0),e([t()],W.prototype,`_selectedManipulator`,null),e([t()],W.prototype,`_tooltipsContext`,null),e([t()],W.prototype,`callbacks`,void 0),e([t()],W.prototype,`connectedReshapeProviders`,void 0),e([t()],W.prototype,`enableMidpoints`,void 0),e([t()],W.prototype,`enableCurveOnMidpoint`,void 0),e([t()],W.prototype,`enableMovement`,void 0),e([t()],W.prototype,`enableVertices`,void 0),e([t()],W.prototype,`filterVerticesEnabled`,void 0),e([t()],W.prototype,`graphic`,void 0),e([t()],W.prototype,`highlightName`,void 0),e([t()],W.prototype,`highlightsEnabled`,void 0),e([t()],W.prototype,`layer`,void 0),e([t()],W.prototype,`snappingManager`,void 0),e([t({readOnly:!0})],W.prototype,`state`,null),e([t()],W.prototype,`symbols`,void 0),e([t()],W.prototype,`tooltip`,void 0),e([t()],W.prototype,`tooltipInfos`,void 0),e([t()],W.prototype,`activeTooltipInfo`,void 0),e([t()],W.prototype,`updating`,null),e([t()],W.prototype,`toolOptions`,void 0),e([t({readOnly:!0})],W.prototype,`type`,void 0),e([t({readOnly:!0})],W.prototype,`vertexGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`curveControlPointGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`constructionLineGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`midpointGraphics`,void 0),e([t({readOnly:!0})],W.prototype,`selectedManipulators`,void 0),e([t()],W.prototype,`view`,void 0),W=e([n(`esri.views.draw.support.Reshape`)],W);function G(e){let t=K(e);t=t.map(e=>e.slice());for(let e of t)for(let t=0;t<e.length;t++)e[t]=ee(e[t]);if(e.type===`polygon`)for(let e of t){let t=e[e.length-1];if(!A(t))continue;let n=e[0];n[0]===t[0]&&n[1]===t[1]&&e.length>2&&e.pop()}return t}function K(e){return e.type===`polygon`?e.curveRings?.slice()??e.rings.slice():e.type===`polyline`?e.curvePaths?.slice()??e.paths.slice():e.points.map(e=>[e])}function Pe(e,t,n,r){let i=e[t][n];if(D(i))i.c[1]=r;else if(O(i)){let i=E(e[t][n]);e[t][n]={c:[i,r]}}}function q(e,t,n,r,i){switch(i){case z.circle.interior:Pe(e,t,n,r);break;case z.bezier.cp1:e[t][n].b[1]=r;break;case z.bezier.cp2:e[t][n].b[2]=r}}function J(e,t){return e<t*1e-8}function Y(e,{cx:t,cy:n,isInvalid:r,thetaStart:i,thetaEnd:a},o,s){let[c,l]=e,[u,d]=o,f=u-c,p=d-l;t-=c,n-=l;let m=s?i>a:i<a,[h,g]=r?[t,n]:m?[-n,t]:[n,-t],[_,v]=[f,p],[y,b]=[h,g],x=_*b-v*y,S=(f**2+p**2)/2;if(J(Math.abs(x),S))return[(c+u)/2,(l+d)/2];let[C,w]=[b/x*S,-y/x*S],T=C**2+w**2,[E,D]=[f/2-C,p/2-w];if(J(E**2+D**2,T)){let[e,t]=m?[-w,C]:[w,-C];return[e+C+c,t+w+l]}let O=Math.sqrt((C**2+w**2)/(E**2+D**2))*Math.sign(f*h+p*g);return[E*O+C+c,D*O+w+l]}function X(e,t,n,r){let i=e[t][n],a=e[t].at(n+1);if(Me(e,t)){let n=e[t][1];e[t][0]=[...r],e[t][1]={a:[[...r],[...n.a[1]],0,0]};return}if(Ne(e,t)){let n=e[t][1],[i,a]=n.a[1],[o,s]=r,c=Math.hypot(o-i,s-a),[l,u]=[o-i,s-a],d=te(u,l);e[t][0]=[...r],e[t][1]={a:[[...r],[...n.a[1]],0,0,d,c,n.a[6]]};return}let o=E(i);if(A(i))i.splice(0,i.length,...r);else if(k(i))i.b[0].splice(0,i.b[0].length,...r);else if(D(i)||O(i)){let a=E(e[t][n-1]),o=D(i)?w(a,i):M(a,i);e[t].splice(n,1,{c:[[...r],Y(a,o,r,!0)]})}else if(j(i)){i.a[0].splice(0,i.a[0].length,...r);let a=E(e[t][n-1]);N(a,i)}if(a&&!A(a)&&!k(i)){if(D(a)||O(a)){let i=E(a),s=D(a)?w(o,a):M(o,a);e[t].splice(n+1,1,{c:[i,Y(i,s,r,!1)]})}else if(j(a)){let e=E(i);N(e,a)}}}function Z({attributes:e}){return[e?.[L.pathIndex]||0,e?.[L.pointIndex]||0]}function Q({attributes:e}){return`${e?.[L.pathIndex]}-${e?.[L.pointIndex]}-${e?.[L.controlPointKind]??`vertex`}`}function $(e){return e instanceof re?[e]:[...e]}function Fe(e){let t=e.sourceLayer??e.layer;return xe(t)?{graphic:e,layer:t}:null}function Ie(e){return e.toArray().map(({attributes:e})=>({pathIndex:e[L.pathIndex],vertexIndex:e[L.pointIndex]}))}const Le=W;export{Le as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
function e(e,a,o){if(e==null)return`noTool`;switch(e){case`point`:return t();case`multipoint`:return`multipoint`;case`polyline`:return n(a,o);case`polygon`:return r(a,o);case`rectangle`:case`circle`:return i(a,o);default:return}}function t(e){return`point`}function n(e,t){let n=e!=null&&e.type===`polyline`&&e.paths.length?e.paths[0].length:0;return t===`freehand`?n<2?`freehandStart`:`freehandEnd`:n<2?`polylineZeroVertices`:`polylineOneVertex`}function r(e,t){let n=e!=null&&e.type===`polygon`&&e.rings.length?e.rings[0].length:0;if(n<3)switch(t){case`freehand`:return`freehandStart`;case`hybrid`:return`polygonZeroVerticesHybrid`;default:return`polygonZeroVertices`}else if(n<4)
|
|
2
|
+
function e(e,a,o){if(e==null)return`noTool`;switch(e){case`point`:return t();case`multipoint`:return`multipoint`;case`polyline`:return n(a,o);case`polygon`:return r(a,o);case`rectangle`:case`circle`:return i(a,o);default:return}}function t(e){return`point`}function n(e,t){let n=e!=null&&e.type===`polyline`&&e.paths.length?e.paths[0].length:0;return t===`freehand`?n<2?`freehandStart`:`freehandEnd`:n<2?`polylineZeroVertices`:`polylineOneVertex`}function r(e,t){let n=e!=null&&e.type===`polygon`&&e.rings.length?e.rings[0].length:0;if(n<3)switch(t){case`freehand`:return`freehandStart`;case`hybrid`:return`polygonZeroVerticesHybrid`;default:return`polygonZeroVertices`}else if(n<4)return t===`freehand`?`freehandEnd`:`polygonOneVertex`;return`polygonTwoVertices`}function i(e,t){if((e!=null&&e.type===`polygon`&&e.rings.length?e.rings[0].length:0)<3)switch(t){case`freehand`:return`freehandStart`;case`click`:return`shapeStartClick`;default:return`shapeStartHybrid`}switch(t){case`freehand`:return`freehandEnd`;case`click`:return`shapeEndClick`;default:return`shapeEndHybrid`}}export{e as getDrawHelpMessage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import r from"../../../../core/Collection.js";import i from"../../../../core/Error.js";import{EventedAccessor as a}from"../../../../core/Evented.js";import{destroyMaybe as o}from"../../../../core/maybe.js";import{EditGeometry as s}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as c}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{EditSession as l,captureGeometryChangeEvents as u}from"../EditSession.js";let d=class extends a{constructor(e){super(e),this._sessionStack=new r,this._pluginSessionLookup=new WeakMap,this._sharedEditGeometry=null}destroy(){this._sharedEditGeometry=o(this._sharedEditGeometry),this._sessionStack.drain(e=>e.destroy())}get _lastOperableSessionIndex(){let e=this._sessionStack.items.findLastIndex(e=>e.editGeometryOperations===this._sharedEditGeometry);return e>=0?e:null}get editGeometryOperations(){return this._sharedEditGeometry}get outputGeometry(){return this._sharedEditGeometry?.data.geometry}get canUndo(){let e=this._sharedEditGeometry?.canUndo??!1;return this._sessionStack.some(t=>(t.stepUndoStack.length>0||t.operations.size>0&&e)&&!t.automaticRestart)}get canRedo(){return this._sharedEditGeometry?.canRedo||this._sessionStack.some(e=>e.stepRedoStack.length>0)}get test(){return{sessionStack:this._sessionStack}}startSession(e,t,n,r){let i=t?this._sharedEditGeometry??=this._setupEditGeometryOperations(n,this):this._setupEditGeometryOperations(n,e),a=new l({editGeometryOperations:i,plugin:e});return a.restoreState(r),a.addHandles([a.on(`completed`,()=>{this.completeSession(a)}),a.on(`before-apply-operation`,e=>{let t=e.session;if(e.blockApply=!0,t.editGeometryOperations!==this._sharedEditGeometry){e.blockApply=!1;return}let n=this._lastOperableSessionIndex;this._sessionStack.indexOf(t)===n&&(e.blockApply=!1)})]),this._sessionStack.push(a),this._pluginSessionLookup.set(e,a),a}cancelSession(e){let t=this._pluginSessionLookup.get(e);if(!t)return;let n=this._sessionStack.indexOf(t);if(!(n<0))for(let e=this._sessionStack.length-1;e>=n;e--){let t=this._sessionStack.at(e);this._discardSessionOperations(t),this._cleanUpSession(t),this._sessionStack.remove(t)}}completeSession(e){let t=this._sessionStack;for(;t.length>0;){let n=t.pop();if(t.at(-1)?.mergeSession(n),this._cleanUpSession(n),n===e)break}}getSession(e){return this._pluginSessionLookup.get(e)??null}undo(){let e=this._undoAndGetRestartInfo([]);e.length>0&&this._restartSession(e.toReversed())}redo(){let e=this._sharedEditGeometry;if(!e||!this.canRedo||this._sessionStack.length===0)return;let t=e.nextOperation,n=[],r=[],i=null,a=!1;for(let e=0;e<this._sessionStack.length;e++){let n=this._sessionStack.at(e);if(t&&n.undoneOperations.has(t)){i=e,a=!0;break}n.stepRedoStack.length>0&&i===null&&(i=e)}if(i===null)return;for(let e=this._sessionStack.length-1;e>i;e--){let t=this._sessionStack.at(e);if(t.automaticRestart){this._discardSessionOperations(t);let e=this._requestCancelSession(t,`undo`,!1);e&&n.push(e)}else r.push(t)}let o=this._sessionStack.at(i);if(a)this._redoOperation(o,e),r.push(o);else{let e=this._requestCancelSession(o,`redo`,!0);e&&n.push(e)}n.length>0&&this._restartSession(n.toReversed());for(let{plugin:e}of r)e?.afterUndoRedo?.(`redo`)}generatePreviewGeometryForPlugins(e){let t=this.editGeometryOperations,n=t?.data.type;if(!n||n===`mesh`)return null;let r=e.map(e=>this._pluginSessionLookup.get(e)).filter(e=>e?.editGeometryOperations===t),i=r.findLast(e=>e?.endVertex)?.endVertex,a=r.find(e=>e?.startingVertex)?.startingVertex;return!a||!i?null:this.editGeometryOperations?.data.getPartialGeometry(a,i,n)}_discardSessionOperations(e){let t=e.editGeometryOperations;if(!t)return;let n=t.lastOperation;try{for(t.disableDefaultRedoBehavior=!0;n&&e.operations.has(n);)this._undoOperation(e,t),n=t.lastOperation}finally{t.disableDefaultRedoBehavior=!1}}_undoAndGetRestartInfo(e){let t=this._sharedEditGeometry;if(!t||!this.canUndo||this._sessionStack.length===0)return e;let n=t.lastOperation,r=!1;for(let i=this._sessionStack.length-1;i>=0;i--){let a=this._sessionStack.at(i),o=n&&a.operations.has(n);if(a.automaticRestart){this._discardSessionOperations(a);let t=this._requestCancelSession(a,`undo`,!1);t&&e.push(t)}else if(a.stepUndoStack.length>0){let t=this._requestCancelSession(a,`undo`,!0);t&&e.push(t),r=!a.stepUndoStack.length;break}else if(o){this._undoOperation(a,t),a.plugin?.afterUndoRedo?.(`undo`);break}if(o){r=!0;break}}return r&&this._undoAndGetRestartInfo(e),e}_setupEditGeometryOperations(e,t){let{coordinateHelper:n,
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import r from"../../../../core/Collection.js";import i from"../../../../core/Error.js";import{EventedAccessor as a}from"../../../../core/Evented.js";import{destroyMaybe as o}from"../../../../core/maybe.js";import{EditGeometry as s}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as c}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{EditSession as l,captureGeometryChangeEvents as u}from"../EditSession.js";let d=class extends a{constructor(e){super(e),this._sessionStack=new r,this._pluginSessionLookup=new WeakMap,this._sharedEditGeometry=null}destroy(){this._sharedEditGeometry=o(this._sharedEditGeometry),this._sessionStack.drain(e=>e.destroy())}get _lastOperableSessionIndex(){let e=this._sessionStack.items.findLastIndex(e=>e.editGeometryOperations===this._sharedEditGeometry);return e>=0?e:null}get editGeometryOperations(){return this._sharedEditGeometry}get outputGeometry(){return this._sharedEditGeometry?.data.geometry}get canUndo(){let e=this._sharedEditGeometry?.canUndo??!1;return this._sessionStack.some(t=>(t.stepUndoStack.length>0||t.operations.size>0&&e)&&!t.automaticRestart)}get canRedo(){return this._sharedEditGeometry?.canRedo||this._sessionStack.some(e=>e.stepRedoStack.length>0)}get test(){return{sessionStack:this._sessionStack}}startSession(e,t,n,r){let i=t?this._sharedEditGeometry??=this._setupEditGeometryOperations(n,this):this._setupEditGeometryOperations(n,e),a=new l({editGeometryOperations:i,plugin:e});return a.restoreState(r),a.addHandles([a.on(`completed`,()=>{this.completeSession(a)}),a.on(`before-apply-operation`,e=>{let t=e.session;if(e.blockApply=!0,t.editGeometryOperations!==this._sharedEditGeometry){e.blockApply=!1;return}let n=this._lastOperableSessionIndex;this._sessionStack.indexOf(t)===n&&(e.blockApply=!1)})]),this._sessionStack.push(a),this._pluginSessionLookup.set(e,a),a}cancelSession(e){let t=this._pluginSessionLookup.get(e);if(!t)return;let n=this._sessionStack.indexOf(t);if(!(n<0))for(let e=this._sessionStack.length-1;e>=n;e--){let t=this._sessionStack.at(e);this._discardSessionOperations(t),this._cleanUpSession(t),this._sessionStack.remove(t)}}completeSession(e){let t=this._sessionStack;for(;t.length>0;){let n=t.pop();if(t.at(-1)?.mergeSession(n),this._cleanUpSession(n),n===e)break}}getSession(e){return this._pluginSessionLookup.get(e)??null}undo(){let e=this._undoAndGetRestartInfo([]);e.length>0&&this._restartSession(e.toReversed())}redo(){let e=this._sharedEditGeometry;if(!e||!this.canRedo||this._sessionStack.length===0)return;let t=e.nextOperation,n=[],r=[],i=null,a=!1;for(let e=0;e<this._sessionStack.length;e++){let n=this._sessionStack.at(e);if(t&&n.undoneOperations.has(t)){i=e,a=!0;break}n.stepRedoStack.length>0&&i===null&&(i=e)}if(i===null)return;for(let e=this._sessionStack.length-1;e>i;e--){let t=this._sessionStack.at(e);if(t.automaticRestart){this._discardSessionOperations(t);let e=this._requestCancelSession(t,`undo`,!1);e&&n.push(e)}else r.push(t)}let o=this._sessionStack.at(i);if(a)this._redoOperation(o,e),r.push(o);else{let e=this._requestCancelSession(o,`redo`,!0);e&&n.push(e)}n.length>0&&this._restartSession(n.toReversed());for(let{plugin:e}of r)e?.afterUndoRedo?.(`redo`)}generatePreviewGeometryForPlugins(e){let t=this.editGeometryOperations,n=t?.data.type;if(!n||n===`mesh`)return null;let r=e.map(e=>this._pluginSessionLookup.get(e)).filter(e=>e?.editGeometryOperations===t),i=r.findLast(e=>e?.endVertex)?.endVertex,a=r.find(e=>e?.startingVertex)?.startingVertex;return!a||!i?null:this.editGeometryOperations?.data.getPartialGeometry(a,i,n)}_discardSessionOperations(e){let t=e.editGeometryOperations;if(!t)return;let n=t.lastOperation;try{for(t.disableDefaultRedoBehavior=!0;n&&e.operations.has(n);)this._undoOperation(e,t),n=t.lastOperation}finally{t.disableDefaultRedoBehavior=!1}}_undoAndGetRestartInfo(e){let t=this._sharedEditGeometry;if(!t||!this.canUndo||this._sessionStack.length===0)return e;let n=t.lastOperation,r=!1;for(let i=this._sessionStack.length-1;i>=0;i--){let a=this._sessionStack.at(i),o=n&&a.operations.has(n);if(a.automaticRestart){this._discardSessionOperations(a);let t=this._requestCancelSession(a,`undo`,!1);t&&e.push(t)}else if(a.stepUndoStack.length>0){let t=this._requestCancelSession(a,`undo`,!0);t&&e.push(t),r=!a.stepUndoStack.length;break}else if(o){this._undoOperation(a,t),a.plugin?.afterUndoRedo?.(`undo`);break}if(o){r=!0;break}}return r&&this._undoAndGetRestartInfo(e),e}_setupEditGeometryOperations(e,t){let{coordinateHelper:n,isGlobal:r}=this.getContext?.()??{};if(!n||r==null)throw new i(`esri-drawtool:edit-session-missing-context`,`Failed to initialize edit session`);let a=new c(new s(e,n),r,!0);return t.addHandles([a.data.on(`change`,()=>{this.notifyChange(`outputGeometry`)}),a.on(`can-redo-change`,()=>{this.notifyChange(`canRedo`)}),a.on(`can-undo-change`,()=>{this.notifyChange(`canUndo`)}),a.on(`redo-reset`,()=>{this._sessionStack.forEach(e=>e.undoneOperations.clear()),this.notifyChange(`canRedo`)})]),a}_requestCancelSession(e,t,n){try{let r=e.plugin;if(!r)return null;let i=r.configuration,a=r?.suspend?.(),o=null,{stepUndoStack:s,stepRedoStack:c,automaticRestart:l}=e;t===`undo`&&!e.automaticRestart&&n?(o=s.pop(),o&&c.push(o)):t===`redo`&&n&&(o=c.pop(),o&&s.push(o));let u={undoSteps:[...s],redoSteps:[...c],automaticRestart:l,isConnected:e.editGeometryOperations===this._sharedEditGeometry,geometryType:e.editGeometryOperations.data.geometry?.type};return this.emit(`cancelPlugin`,{plugin:r}),i?{pluginConfiguration:i,pluginState:a,sessionState:u,currentInternalStep:s.at(-1),pluginInstance:r}:null}finally{this._cleanUpSession(e)}}_restartSession(e){this.emit(`restartPlugin`,{restartInfo:e}),this.notifyChange(`outputGeometry`)}_cleanUpSession(e){e.plugin=null,e.destroy()}_undoOperation(e,t){let n=null,r=u(t,()=>{n=t.undo()});return e&&(e.syncVertices(r),n&&(e.operations.delete(n),e.undoneOperations.add(n))),n}_redoOperation(e,t){let n=null,r=u(t,()=>{n=t.redo()});return e?.syncVertices(r),e&&n&&(e.operations.add(n),e.undoneOperations.delete(n)),n}};e([t()],d.prototype,`_sharedEditGeometry`,void 0),e([t()],d.prototype,`_lastOperableSessionIndex`,null),e([t()],d.prototype,`editGeometryOperations`,null),e([t()],d.prototype,`outputGeometry`,null),e([t()],d.prototype,`getContext`,void 0),e([t()],d.prototype,`canUndo`,null),e([t()],d.prototype,`canRedo`,null),e([t()],d.prototype,`test`,null),d=e([n(`esri.views.draw.support.managers.EditSessionManager`)],d);export{d as EditSessionManager};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{isSome as e}from"../../core/arrayUtils.js";import"../../core/has.js";import{clone as t}from"../../core/lang.js";import{clamp as n}from"../../core/mathUtils.js";import{createScreenPoint as r}from"../../core/screenUtils.js";import{project as i}from"../../geometry/projectionUtils.js";import{isMeshWithRelativeVertexSpace as a}from"../../geometry/support/meshVertexSpaceUtils.js";import{clonePoint as o}from"../../layers/graphics/hydratedFeatures.js";import{hydratedSpatialReference as s}from"../../layers/graphics/hydratedSpatialReference.js";import{getZForElevationMode as c}from"../../support/elevationInfoUtils.js";import{EditGeometryOperations as l}from"./editGeometry/EditGeometryOperations.js";function u(e,t){let n=null,r=null;return i=>{if(i.action===`cancel`){r!=null&&(r.execute({action:`cancel`}),n=null,r=null);return}let a={action:i.action,screenStart:i.start,screenEnd:i.screenPoint};i.action===`start`&&n==null&&(n=new D,r=new D,t(e,n,r,i.pointerType,a)),n?.execute(a),i.action===`end`&&n!=null&&(n=null,r=null)}}function d(e,t){return e.events.on(`drag`,u(e,t))}function f(e,t){let n=[e.x,e.y,e.z??0],r=t,i=[Math.cos(r),Math.sin(r)],a=Math.sqrt(i[0]*i[0]+i[1]*i[1]);if(a===0)return null;i[0]/=a,i[1]/=a;let o=e=>{let t=(e.x-n[0])*i[0]+(e.y-n[1])*i[1];e.x=n[0]+t*i[0],e.y=n[1]+t*i[1]};return e=>(o(e.mapStart),o(e.mapEnd),{...e,axis:i})}function p(e){let t=null,n=C();return r=>{if(r.action===`start`&&(t=h(e,r.mapStart.spatialReference)),t==null)return null;let i=n(r);if(!i)return null;let{translationX:a,translationY:o,translationZ:s}=i;return t.move(a,o,s,r.action),i}}function m(e,t){return e==null?null:e.spatialReference.equals(t)?e.clone():i(e,t)}function h(e,t){let n=e.operations;if(!n)return null;let r=n.data.geometry,o=s(t);if(r.spatialReference.equals(o))return g(e,n,()=>{});if(r.type!==`mesh`){let t=m(r,o);if(t==null)return null;let a=r.spatialReference,s=l.fromGeometry(t,n.
|
|
2
|
+
import{isSome as e}from"../../core/arrayUtils.js";import"../../core/has.js";import{clone as t}from"../../core/lang.js";import{clamp as n}from"../../core/mathUtils.js";import{createScreenPoint as r}from"../../core/screenUtils.js";import{project as i}from"../../geometry/projectionUtils.js";import{isMeshWithRelativeVertexSpace as a}from"../../geometry/support/meshVertexSpaceUtils.js";import{clonePoint as o}from"../../layers/graphics/hydratedFeatures.js";import{hydratedSpatialReference as s}from"../../layers/graphics/hydratedSpatialReference.js";import{getZForElevationMode as c}from"../../support/elevationInfoUtils.js";import{EditGeometryOperations as l}from"./editGeometry/EditGeometryOperations.js";function u(e,t){let n=null,r=null;return i=>{if(i.action===`cancel`){r!=null&&(r.execute({action:`cancel`}),n=null,r=null);return}let a={action:i.action,screenStart:i.start,screenEnd:i.screenPoint};i.action===`start`&&n==null&&(n=new D,r=new D,t(e,n,r,i.pointerType,a)),n?.execute(a),i.action===`end`&&n!=null&&(n=null,r=null)}}function d(e,t){return e.events.on(`drag`,u(e,t))}function f(e,t){let n=[e.x,e.y,e.z??0],r=t,i=[Math.cos(r),Math.sin(r)],a=Math.sqrt(i[0]*i[0]+i[1]*i[1]);if(a===0)return null;i[0]/=a,i[1]/=a;let o=e=>{let t=(e.x-n[0])*i[0]+(e.y-n[1])*i[1];e.x=n[0]+t*i[0],e.y=n[1]+t*i[1]};return e=>(o(e.mapStart),o(e.mapEnd),{...e,axis:i})}function p(e){let t=null,n=C();return r=>{if(r.action===`start`&&(t=h(e,r.mapStart.spatialReference)),t==null)return null;let i=n(r);if(!i)return null;let{translationX:a,translationY:o,translationZ:s}=i;return t.move(a,o,s,r.action),i}}function m(e,t){return e==null?null:e.spatialReference.equals(t)?e.clone():i(e,t)}function h(e,t){let n=e.operations;if(!n)return null;let r=n.data.geometry,o=s(t);if(r.spatialReference.equals(o))return g(e,n,()=>{});if(r.type!==`mesh`){let t=m(r,o);if(t==null)return null;let a=r.spatialReference,s=l.fromGeometry(t,n.isGlobal);return g(e,s,()=>{let e=s.data.geometry,t=i(e,a);n.trySetGeometry(t)})}if(a(r)){let t=m(r.origin,o);if(!t)return null;let a=r.spatialReference,s=l.fromGeometry(t,n.isGlobal);return g(e,n,()=>{let e=i(s.data.geometry,a),t=e.x-r.origin.x,o=e.y-r.origin.y,c=(e.z??0)-(r.origin.z??0);n.move(t,o,c)})}return null}function g(e,t,n){let r=0,i=0,a=0;return{move:(o,s,c,l)=>{l===`start`&&(r=0,i=0,a=0);let u=o-r,d=s-i,f=c-a;t.move(u,d,f),r+=u,i+=d,a+=f,n(),l===`end`&&e.endInteraction?.()}}}function _(e,t=null,n){let r=null,a=t!=null&&!e.spatialReference?.equals(t)?e=>e==null?e:i(e,t):e=>e,o={exclude:[],...n};return t=>{if(t.action===`start`&&(r=a(e.toMap(t.screenStart,o))),r==null)return null;let n=a(e.toMap(t.screenEnd,o));return n==null?null:{...t,mapStart:r,mapEnd:n}}}function v(t){let n=t.map(e=>p(e)).filter(e),r=C();return e=>{let t=r(e);return n.forEach(t=>t(e)),t}}function y(e,n){let r=new Map;for(let i of n)r.set(i,t(e[i]));return t=>(r.forEach((t,n)=>{e[n]=t}),t)}function b(e){let t=e.operations?.createResetState();return e=>(t?.remove(),e)}function x(e){let t=e.map(e=>b(e)).filter(e=>e!=null);return e=>(t.forEach(t=>t(e)),e)}function S(){let e=0,t=0,n=0;return r=>{r.action===`start`&&(e=r.mapStart.x,t=r.mapStart.y,n=r.mapStart.z??0);let i=r.mapEnd.x-e,a=r.mapEnd.y-t,o=(r.mapEnd.z??0)-n;return e=r.mapEnd.x,t=r.mapEnd.y,n=r.mapEnd.z,{...r,mapDeltaX:i,mapDeltaY:a,mapDeltaZ:o,mapDeltaSpatialReference:r.mapStart.spatialReference}}}function C(){let e=0,t=0,n=0;return r=>{r.action===`start`&&(e=r.mapStart.x,t=r.mapStart.y,n=r.mapStart.z??0);let i=r.mapEnd.x-e,a=r.mapEnd.y-t,o=(r.mapEnd.z??0)-n;return{...r,translationX:i,translationY:a,translationZ:o}}}function w(){let e=0,t=0;return n=>{n.action===`start`&&(e=n.screenStart.x,t=n.screenStart.y);let r=n.screenEnd.x-e,i=n.screenEnd.y-t;return e=n.screenEnd.x,t=n.screenEnd.y,{...n,screenDeltaX:r,screenDeltaY:i}}}function T(e,t){let i=null,a=0,o=0;return s=>{if(s.action===`start`&&(i=e.toScreen?.(t),i!=null&&(i.x<0||i.x>e.width||i.y<0||i.y>e.height?i=null:(a=s.screenStart.x-i.x,o=s.screenStart.y-i.y))),i==null)return null;let c=n(s.screenEnd.x-a,0,e.width),l=n(s.screenEnd.y-o,0,e.height),u=r(c,l);return s.screenStart=i,s.screenEnd=u,s}}const E=()=>{};class D{constructor(){this.execute=E}next(e,t=new D){return e!=null&&(this.execute=n=>{let r=e(n);r!=null&&t.execute(r)}),t}}function O(e,t,n=[]){if(e.type===`2d`)return e=>e;let r=null;return i=>{i.action===`start`&&(r=e.toMap(i.screenStart,{exclude:n}),r!=null&&(r.z=c(r,e,t)));let a=e.toMap(i.screenEnd,{exclude:n});a!=null&&(a.z=c(a,e,t));let o=r!=null&&a!=null?{sceneStart:r,sceneEnd:a}:null;return{...i,scenePoints:o}}}function k(e,t,n){let r=t.elevationProvider.getElevation(e.x,e.y,e.z??0,e.spatialReference,`scene`)??0,i=o(e);return i.z=r,i.hasZ=!0,i.z=c(i,t,n),i}function A(e,t){if(e.type===`2d`)return e=>e;let n=null;return r=>{r.action===`start`&&(n=k(r.mapStart,e,t));let i=k(r.mapEnd,e,t),a=n!=null&&i!=null?{sceneStart:n,sceneEnd:i}:null;return{...r,scenePoints:a}}}export{D as EventPipeline,S as addMapDelta,C as addMapTranslation,w as addScreenDelta,f as constrainToMapAxis,u as createDragEventPipelineCallback,d as createManipulatorDragEventPipeline,T as dragAtLocation,p as dragManipulatedObject,v as dragManipulatedObjectMany,b as resetManipulatedObject,x as resetManipulatedObjectMany,y as resetProperties,O as sceneSnappingAtLocation,A as sceneSnappingAtProjectedLocation,_ as screenToMap};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{numbersEquals as e,pushIfSome as t}from"../../../core/arrayUtils.js";import{Evented as n}from"../../../core/Evented.js";import r from"../../../geometry/Multipoint.js";import i from"../../../geometry/Polygon.js";import a from"../../../geometry/Polyline.js";import{getEndpoint as o,isCoordinate as s,isBezierCurve as c,isCircularArc as l,isEllipticArc4 as u}from"../../../geometry/support/curves/curveUtils.js";import{unnormalize as d}from"../../support/unnormalizationUtils.js";import{createCoordinateHelper as f}from"../coordinateHelper.js";class p{constructor(e){this.part=e,this.leftSegment=null,this.rightSegment=null,this.type=`vertex`,this.index=null}get pos(){return this._pos}set pos(e){this._pos=e,this.part.unnormalizeVertexPositions()}}class m{constructor(e,t,n){this.part=e,this.leftVertex=t,this.rightVertex=n,this.type=`line`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){return[...this.rightVertex.pos]}}class h{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`bezier`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){return{b:[[...this.rightVertex.pos],[...this.curveDefinition.controlPoint1],[...this.curveDefinition.controlPoint2]]}}}class g{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`circular-arc`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){let e=this.rightVertex.pos,{interiorPoint:t}=this.curveDefinition;return{c:[[...e],[...t]]}}}class _{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`elliptic-arc-4`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){let e=this.rightVertex.pos,{centerPoint:t,sweep:n,orientation:r}=this.curveDefinition;return{a:[[...e],[...t],n,r]}}}class v{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`elliptic-arc-7`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){let e=this.rightVertex.pos,{centerPoint:t,sweep:n,orientation:r,rotation:i,semiMajorAxisLength:a,minorMajorAxisRatio:o}=this.curveDefinition;return{a:[[...e],t,n,r,i,a,o]}}}class y{constructor(e,t,n=!1){this._spatialReference=e,this.
|
|
2
|
+
import{numbersEquals as e,pushIfSome as t}from"../../../core/arrayUtils.js";import{Evented as n}from"../../../core/Evented.js";import r from"../../../geometry/Multipoint.js";import i from"../../../geometry/Polygon.js";import a from"../../../geometry/Polyline.js";import{getEndpoint as o,isCoordinate as s,isBezierCurve as c,isCircularArc as l,isEllipticArc4 as u}from"../../../geometry/support/curves/curveUtils.js";import{unnormalize as d}from"../../support/unnormalizationUtils.js";import{createCoordinateHelper as f}from"../coordinateHelper.js";class p{constructor(e){this.part=e,this.leftSegment=null,this.rightSegment=null,this.type=`vertex`,this.index=null}get pos(){return this._pos}set pos(e){this._pos=e,this.part.unnormalizeVertexPositions()}}class m{constructor(e,t,n){this.part=e,this.leftVertex=t,this.rightVertex=n,this.type=`line`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){return[...this.rightVertex.pos]}}class h{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`bezier`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){return{b:[[...this.rightVertex.pos],[...this.curveDefinition.controlPoint1],[...this.curveDefinition.controlPoint2]]}}}class g{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`circular-arc`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){let e=this.rightVertex.pos,{interiorPoint:t}=this.curveDefinition;return{c:[[...e],[...t]]}}}class _{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`elliptic-arc-4`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){let e=this.rightVertex.pos,{centerPoint:t,sweep:n,orientation:r}=this.curveDefinition;return{a:[[...e],[...t],n,r]}}}class v{constructor(e,t,n,r){this.part=e,this.leftVertex=t,this.rightVertex=n,this.curveDefinition=r,this.type=`elliptic-arc-7`,t.rightSegment=this,n.leftSegment=this}toCurveOrCoordinate(){let e=this.rightVertex.pos,{centerPoint:t,sweep:n,orientation:r,rotation:i,semiMajorAxisLength:a,minorMajorAxisRatio:o}=this.curveDefinition;return{a:[[...e],t,n,r,i,a,o]}}}class y{constructor(e,t,n=!1){this._spatialReference=e,this._isGlobal=t,this.autoClose=n,this.vertices=[],this.segments=[],this.index=null}unnormalizeVertexPositions(){this.vertices.length<=1||this._isGlobal&&d(this.vertices,this._spatialReference)}updateVertexIndex(e,t){let{vertices:n}=this;if(n.length===0)return;let r=n[0],i=null,a=e,o=t;do i=a,i.index=o++,a=i.rightSegment?i.rightSegment.rightVertex:null;while(a!=null&&a!==r);i.leftSegment&&i!==n[n.length-1]&&this.swapVertices(n.indexOf(i),n.length-1)}getFirstVertex(){return this.vertices.at(0)}getLastVertex(){return this.vertices.at(-1)}isClosed(){return this.getFirstVertex()?.leftSegment!=null}swapVertices(e,t){let{vertices:n}=this,r=n[e];n[e]=n[t],n[t]=r}*iterateVertices(){let e=this.getFirstVertex(),t=e;if(t)do yield t,t=t.rightSegment?.rightVertex;while(t!==e&&t!=null)}}class b extends n{constructor(e,t){super(),this.type=e,this.coordinateHelper=t,this._geometry=null,this._dirty=!0,this.parts=[]}get geometry(){if(this._dirty){switch(this.type){case`point`:this._geometry=this._toPoint();break;case`multipoint`:this._geometry=this._toMultipoint();break;case`polyline`:this._geometry=this._toPolyline();break;case`polygon`:this._geometry=this._toPolygon();break;case`mesh`:break;default:this.type}this._dirty=!1}return this._geometry}get spatialReference(){return this.coordinateHelper.spatialReference}get allVerticesUnordered(){return Array.from(this.iterateVerticesUnordered())}*iterateVerticesUnordered(){for(let e of this.parts)for(let t of e.vertices)yield t}get allVertices(){return Array.from(this.iterateVertices())}*iterateVertices(){for(let e of this.parts)yield*e.iterateVertices()}notifyChanges(e){this._dirty=!0,this.emit(`change`,e)}getPartialGeometry(e,t,n){let{parts:r,hasCurves:i}=w(this,{startingVertex:e,endingVertexInclusive:t,geometryType:n});return C(r,i,n,this.coordinateHelper)}_toPoint(){let{parts:e,coordinateHelper:t}=this;return e.at(0)?.vertices.length?t.vectorToPoint(e[0].vertices[0].pos):null}_toMultipoint(){let e=[],{coordinateHelper:t,parts:n,spatialReference:i}=this;for(let r of n){let n=r.getFirstVertex();n&&e.push(t.arrayToVector(n.pos))}return new r({hasM:t.hasM(),hasZ:t.hasZ(),spatialReference:i,points:e})}_toPolyline(){let e=[],t=!1;for(let n of this.parts){if(n.vertices.length<1)continue;let r=n.vertices[0],i=[];i.push(r.pos);let a=r.rightSegment;for(;a;)t||=a.type!==`line`,i.push(a.toCurveOrCoordinate()),a=a.rightVertex.rightSegment;e.push(i)}return new a({paths:t?void 0:e,curvePaths:t?e:void 0,spatialReference:this.spatialReference,hasZ:this.coordinateHelper.hasZ(),hasM:this.coordinateHelper.hasM()})}_toPolygon(){let t=[],n=!1;for(let r of this.parts){if(r.vertices.length<1)continue;let i=r.vertices[0],a=[];a.push(i.pos);let c=i.rightSegment;for(;c&&(n||=c.type!==`line`,a.push(c.toCurveOrCoordinate()),c=c.rightVertex.rightSegment,c?.leftVertex!==i););if(r.autoClose&&a.length>1){let t=a.at(-1),n=o(a[0]),r=o(t);a.length===2&&s(t)||e(n,r)||a.push(n)}t.push(a)}return new i({rings:n?void 0:t,curveRings:n?t:void 0,spatialReference:this.spatialReference,hasZ:this.coordinateHelper.hasZ(),hasM:this.coordinateHelper.hasM()})}static fromGeometry(e,t,n){let r=e.spatialReference,i=f(e.hasZ,e.hasM,r),a=new b(e.type,i);switch(e.type){case`polygon`:T(a,e,t,n?.allowCurves??!1);break;case`polyline`:E(a,e,t,n?.allowCurves??!1);break;case`point`:D(a,e,t);break;case`multipoint`:O(a,e,t);break;case`mesh`:D(a,e.origin,t),a._geometry=e,a._dirty=!1}return a}}function x(e,t,n,r){let i=new p(e);e.vertices.push(i);let a=o(r);return i.pos=t.arrayToVector(a),i.index=e.vertices.length-1,n&&e.segments.push(S(e,n,i,r)),i}function S(e,t,n,r){if(s(r))return new m(e,t,n);if(c(r)){let[,i,a]=r.b;return new h(e,t,n,{controlPoint1:[...i],controlPoint2:[...a]})}if(l(r)){let[,i]=r.c;return new g(e,t,n,{interiorPoint:[...i]})}if(u(r)){let[,i,a,o]=r.a;return new _(e,t,n,{centerPoint:[...i],sweep:a,orientation:o})}let[,i,a,o,d,f,p]=r.a;return new v(e,t,n,{centerPoint:[...i],sweep:a,orientation:o,rotation:d,semiMajorAxisLength:f,minorMajorAxisRatio:p})}function C(e,t,n,s){let{spatialReference:c}=s;if(n===`point`){let t=e.at(0)?.at(0);return t?s.arrayToPoint(o(t)):null}return n===`polygon`?new i({rings:t?void 0:e,curveRings:t?e:void 0,spatialReference:c,hasZ:s.hasZ(),hasM:s.hasM()}):n===`multipoint`?new r({spatialReference:c,points:e.flatMap(e=>e.map(e=>o(e))),hasM:s.hasM(),hasZ:s.hasZ()}):new a({paths:t?void 0:e,curvePaths:t?e:void 0,spatialReference:c,hasZ:s.hasZ(),hasM:s.hasM()})}function w(n,r){let i=(r?.geometryType??n.type)===`polygon`,a=[],c=!1,l=!1,u=!1;for(let d of n.parts){let n=null;if(u)break;if(d.vertices.length<1)continue;if(r?.startingVertex){if(d!==r.startingVertex.part&&!l)continue;l=!0}let f=d===r?.startingVertex?.part?r.startingVertex:d.vertices.at(0),p=[];if(t(p,f?.pos),f===r?.endingVertexInclusive){u=!0,n=f,a.push(p);break}let m=f?.rightSegment;for(;m;){if(c||=m.type!==`line`,p.push(m.toCurveOrCoordinate()),n=m.rightVertex,m.rightVertex===r?.endingVertexInclusive){u=!0;break}if(m=m.rightVertex.rightSegment,m?.leftVertex===f)break}let h=p.at(-1),g=d.getFirstVertex(),_=d.getLastVertex();i&&d.autoClose&&h&&n===_&&f===g&&(p.length>2||p.length===2&&!s(h))&&f?.pos&&!e(o(h),f.pos)&&p.push([...f.pos]),a.push(p)}return{parts:a,hasCurves:c}}function T(t,n,r,i){let a=n.spatialReference,s=t.coordinateHelper,{rings:c,curveRings:l}=n,u=l&&i?l:c;for(let n=0;n<u.length;++n){let i=u[n],c=new y(a,r);if(c.index=n,t.parts.push(c),i.length<1)continue;let l=null,d=null;for(let e=0;e<i.length-1;++e)d=x(c,s,d,i[e]),l??=d;i.length>1&&e(o(i[i.length-1]),l?.pos)?d&&l&&c.segments.push(S(c,d,l,i[i.length-1])):d=x(c,s,d,i[i.length-1])}}function E(e,t,n,r){let i=t.spatialReference,a=e.coordinateHelper,{curvePaths:o,paths:s}=t,c=o&&r?o:s;for(let t=0;t<c.length;++t){let r=c[t],o=new y(i,n);if(o.index=t,e.parts.push(o),r.length<1)continue;let s=null;for(let e=0;e<r.length;++e)s=x(o,a,s,r[e])}}function D(e,t,n){let r=t.spatialReference,i=e.coordinateHelper,a=new y(r,n);a.index=0;let o=new p(a);o.index=0,o.pos=i.pointToVector(t),a.vertices.push(o),e.parts.push(a)}function O(e,t,n){let r=t.spatialReference,{coordinateHelper:i,parts:a}=e,o=t.points.map(e=>i.arrayToVector(e));for(let e=0;e<o.length;e++){let t=new y(r,n);t.index=e,a.push(t);let i=new p(t);i.pos=o[e],i.index=0,t.vertices.push(i)}}function k(e){return e.type===`mesh`}function A(e,t){if(e.type!==t.type||e.parts.length!==t.parts.length)return!1;for(let n=0;n<e.parts.length;n++){let r=e.parts[n],i=t.parts[n];if(r.vertices.length!==i.vertices.length)return!1}let n=e.allVertices,r=t.allVertices;for(let e=0;e<n.length;e++)if(n[e].leftSegment?.type!==r[e].leftSegment?.type)return!1;return!0}export{h as BezierSegment,g as CircularArcSegment,b as EditGeometry,_ as EllipticArc4Segment,v as EllipticArc7Segment,m as LineSegment,y as Part,p as Vertex,x as addVertexAndConnectingSegment,S as createConnectingSegment,A as haveCompatibleTopologies,k as isMeshEditGeometry,C as partialCoordsToGeometry,w as toPartialCoords};
|