@arcgis/core 4.24.0-next.20220508 → 4.24.0-next.20220511
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/AggregateGraphic.js +1 -1
- package/analysis/Analysis.js +1 -1
- package/analysis/DimensioningAnalysis.js +1 -1
- package/analysis/LengthDimension.d.ts +4 -0
- package/analysis/LengthDimension.js +5 -0
- package/analysis/dimensionUtils.js +5 -0
- package/arcade/Dictionary.js +1 -1
- package/arcade/Feature.js +1 -1
- package/arcade/arcade.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/credentials.js +1 -1
- package/arcade/featureSetCollection.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/actions/AttributeFilter.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/actions/OrderBy.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/featureset/actions/Top.js +1 -1
- package/arcade/featureset/sources/Empty.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/FeatureSetIterator.js +1 -1
- package/arcade/featureset/support/shared.js +1 -1
- package/arcade/featureset/support/stats.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/arcade/functions/featuresetstats.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade/request.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0564f1cfa3d17ff1aad3.js +1 -0
- package/assets/esri/core/workers/chunks/0806d5d706a864542bfb.js +1 -0
- package/assets/esri/core/workers/chunks/0a6977144ea1abf96fbf.js +1 -0
- package/assets/esri/core/workers/chunks/13387f56acbc3291561a.js +1 -0
- package/assets/esri/core/workers/chunks/16c4e0a32d50d4db984d.js +1 -0
- package/assets/esri/core/workers/chunks/{076d1b1101b59af0d389.js → 1c010202b4c7e1d15f23.js} +1 -1
- package/assets/esri/core/workers/chunks/26827ec144676e6385f8.js +1 -0
- package/assets/esri/core/workers/chunks/287c484fd40eee643f3a.js +1 -0
- package/assets/esri/core/workers/chunks/5210f0b42dba27945226.js +1 -0
- package/assets/esri/core/workers/chunks/{db6c5b3b4efe8d804f9c.js → 52478ee2d2a1354b6900.js} +1 -1
- package/assets/esri/core/workers/chunks/5759af97f96f24c40105.js +1 -0
- package/assets/esri/core/workers/chunks/{b85218d44c6094b7e5e6.js → 6d7e2a23a0a5dd9ded1d.js} +1 -1
- package/assets/esri/core/workers/chunks/70b6356357e7640c4e8b.js +1 -0
- package/assets/esri/core/workers/chunks/7574316b3af61c389e8f.js +1 -0
- package/assets/esri/core/workers/chunks/7bc828fbdd54c0b28aac.js +1 -0
- package/assets/esri/core/workers/chunks/7e5c22b5a32ac74b1b6e.js +1 -0
- package/assets/esri/core/workers/chunks/8102bb78fe96e6197e4e.js +1 -0
- package/assets/esri/core/workers/chunks/88384e7cafbfd2348598.js +1 -0
- package/assets/esri/core/workers/chunks/9d7533aaeac3b8d145c4.js +1 -0
- package/assets/esri/core/workers/chunks/{1eecae5227318f491263.js → 9f4d892abf55e8625bc9.js} +3 -3
- package/assets/esri/core/workers/chunks/{98607a0da63626cc4614.js → a054a52712a118c6d505.js} +1 -1
- package/assets/esri/core/workers/chunks/{69a20e4d9e28c3e599fc.js → a3bb600bfcb0282622f1.js} +1 -1
- package/assets/esri/core/workers/chunks/aa49841b14c6e6df2a07.js +1 -0
- package/assets/esri/core/workers/chunks/b089058b64db3912478f.js +1 -0
- package/assets/esri/core/workers/chunks/b28539c5a6bedb71b038.js +1 -0
- package/assets/esri/core/workers/chunks/b4f171db73355c6f766e.js +1 -0
- package/assets/esri/core/workers/chunks/b7572b0921b23aef8b9d.js +1 -0
- package/assets/esri/core/workers/chunks/b758f3c419edc2306784.js +1 -0
- package/assets/esri/core/workers/chunks/c3e7290fb128d4fefd44.js +1 -0
- package/assets/esri/core/workers/chunks/c51c9b5da855f84b9a48.js +1 -0
- package/assets/esri/core/workers/chunks/c66ac36da6392b6bf331.js +1 -0
- package/assets/esri/core/workers/chunks/d16b328d32a6ddc2fdb9.js +1 -0
- package/assets/esri/core/workers/chunks/d94c5f36d52cf71f0bb9.js +1 -0
- package/assets/esri/core/workers/chunks/db937849b2c1af87b481.js +1 -0
- package/assets/esri/core/workers/chunks/{66cd99e91dad60c5274c.js → dc3ed59f450283d97a19.js} +1 -1
- package/assets/esri/core/workers/chunks/dcd0653191cd4a1ccaae.js +2 -0
- package/assets/esri/core/workers/chunks/{31df729c17470245288c.js.LICENSE.txt → dcd0653191cd4a1ccaae.js.LICENSE.txt} +2 -2
- package/assets/esri/core/workers/chunks/e4fdd1eaf987977d0a51.js +1 -0
- package/assets/esri/core/workers/chunks/e51f0e71f2a55af604d3.js +1 -0
- package/assets/esri/core/workers/chunks/eb3855d3753d6b8334bd.js +1 -0
- package/assets/esri/core/workers/chunks/{7c290763920f52a1f504.js → eeed138930a4a805691d.js} +1 -1
- package/assets/esri/core/workers/chunks/f435dc615fdc8917f6ca.js +1 -0
- package/assets/esri/core/workers/chunks/{d5c5b9f7f5401f36a3a5.js → f7f3dde4c8f9c687cc1e.js} +1 -1
- package/assets/esri/core/workers/chunks/fc6beaf9466ea3898549.js +1 -0
- package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Tooltip.scss +1 -0
- package/assets/esri/themes/base/widgets/_Weather.scss +1 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/BlendLayers.glsl.js +6 -6
- package/chunks/arcade.js +1 -1
- package/chunks/array.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/config.js +1 -1
- package/core/sql/StandardizedFunctions.js +1 -1
- package/geohash/GeohashTree.js +1 -1
- package/geometry/support/contains.js +1 -1
- package/geometry/support/heightModelInfoUtils.js +1 -1
- package/geometry/support/intersects.js +1 -1
- package/geometry/support/intersectsBase.js +1 -1
- package/geometry/support/normalizeUtilsCommon.js +1 -1
- package/geometry/support/spatialReferenceUtils.js +1 -1
- package/interfaces.d.ts +685 -37
- package/layers/MediaLayer.d.ts +4 -0
- package/layers/MediaLayer.js +5 -0
- package/layers/VoxelLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +5 -0
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/data/BoundsStore.js +1 -1
- package/layers/support/CornersGeoreference.d.ts +4 -0
- package/layers/support/CornersGeoreference.js +5 -0
- package/layers/support/ExtentAndRotationGeoreference.d.ts +4 -0
- package/layers/support/ExtentAndRotationGeoreference.js +5 -0
- package/layers/support/FeatureReduction.js +1 -1
- package/layers/support/FeatureReductionBinning.js +5 -0
- package/layers/support/GeoreferenceBase.js +5 -0
- package/layers/support/ImageElement.d.ts +4 -0
- package/layers/support/ImageElement.js +5 -0
- package/layers/support/LocalMediaElementSource.d.ts +4 -0
- package/layers/support/LocalMediaElementSource.js +5 -0
- package/layers/support/MediaElementBase.d.ts +4 -0
- package/layers/support/MediaElementBase.js +5 -0
- package/layers/support/RouteStopSymbols.d.ts +4 -0
- package/layers/support/RouteSymbols.d.ts +4 -0
- package/layers/support/VoxelFormat.d.ts +4 -0
- package/layers/support/VoxelStyle.d.ts +4 -0
- package/layers/support/VoxelVariable.d.ts +4 -0
- package/layers/support/VoxelVolume.d.ts +4 -0
- package/layers/support/VoxelVolumeStyle.d.ts +4 -0
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/featureReductionUtils.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/rasterFormats/Lerc.js +1 -1
- package/package.json +3 -3
- package/request.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/Font.js +1 -1
- package/symbols/support/textUtils.js +1 -1
- package/views/2d/engine/brushes.js +1 -1
- package/views/2d/engine/webgl/FeatureTile.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +5 -0
- package/views/2d/engine/webgl/OverlayContainer.js +5 -0
- package/views/2d/engine/webgl/brushes/BrushOverlay.js +5 -0
- package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
- package/views/2d/engine/webgl/shaders/OverlayPrograms.js +5 -0
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layerViewModuleImportUtils.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/MapImageLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +5 -0
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/WMTSLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureStore2D.js +1 -1
- package/views/2d/layers/features/Pipeline.js +1 -1
- package/views/2d/layers/features/Store2D.js +1 -1
- package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
- package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/views/2d/layers/features/sources/GeoEventSource.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/BinStore.js +5 -0
- package/views/2d/layers/features/support/ClusterStore.js +1 -1
- package/views/2d/layers/features/tileRenderers/support/WGLFeatureView.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/layers/support/clusterUtils.js +1 -1
- package/views/2d/magnifier/MagnifierView2D.js +1 -1
- package/views/2d/navigation/actions/Pinch.js +1 -1
- package/views/2d/viewpointUtils.js +1 -1
- package/views/3d/analysis/AnalysisView3D.js +1 -1
- package/views/3d/analysis/Dimensioning/DimensioningTool.js +5 -0
- package/views/3d/analysis/Dimensioning/DimensioningVisualization.js +1 -1
- package/views/3d/analysis/Dimensioning/LengthDimensionSubTool.js +5 -0
- package/views/3d/analysis/Dimensioning/{LinearDimensionVisualization.js → LengthDimensionVisualization.js} +1 -1
- package/views/3d/analysis/Dimensioning/settings.js +5 -0
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/interactive/SegmentLabels3D.js +5 -0
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/GraphicReshapeTool.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateObjectSymbol3DAdapter.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
- package/views/3d/layerViewModuleImportUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +5 -0
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/i3s/IDBCache.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/local/ZoomController.js +1 -1
- package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendLayers.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/materials/WaterGLMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/ToolViewManager.js +1 -1
- package/views/View.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/InteractiveToolBase.js +1 -1
- package/views/interactive/SegmentLabels.js +5 -0
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/LineSnapper.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/snappingUtils.js +1 -1
- package/views/interactive/support/viewUtils.js +5 -0
- package/views/interactive/tooltip/DrawPointTooltipInfo.js +5 -0
- package/views/interactive/tooltip/DrawPolygonTooltipInfo.js +5 -0
- package/views/interactive/tooltip/DrawPolylineTooltipInfo.js +5 -0
- package/views/interactive/tooltip/Tooltip.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
- package/views/interactive/tooltip/support/measurements.js +5 -0
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/views/overlay/TextOverlayItem.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/support/screenUtils.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/Attribution/AttributionViewModel.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Feature/FeatureAttachments.js +1 -1
- package/widgets/Feature/FeatureContent/FeatureContentViewModel.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/Feature/FeatureExpression.js +1 -1
- package/widgets/Feature/FeatureFields.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/FeatureForm/InputFieldGroup.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +11 -11
- package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/FeatureTemplates/TemplateItem.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/FloorFilter.js +1 -1
- package/widgets/HistogramRangeSlider.js +1 -1
- package/widgets/LayerList/LayerListViewModel.js +1 -1
- package/widgets/LayerList/ListItem.js +1 -1
- package/widgets/LayerList/ListItemPanel.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/styles/Card.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
- package/widgets/Measurement.js +1 -1
- package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
- package/widgets/Popup/PopupViewModel.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/Print/FileLink.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/ScaleBar.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/TableList/ListItem.js +1 -1
- package/widgets/Weather/LabeledSlider.js +1 -1
- package/widgets/Weather/VisibleElements.js +5 -0
- package/widgets/Weather/css.js +1 -1
- package/widgets/Weather.js +1 -1
- package/widgets/support/AnalysisViewModel.js +1 -1
- package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
- package/analysis/LinearDimension.d.ts +0 -4
- package/analysis/LinearDimension.js +0 -5
- package/assets/esri/core/workers/chunks/0018053ac16a09feba70.js +0 -1
- package/assets/esri/core/workers/chunks/042938ca73f0b9e5a7e2.js +0 -1
- package/assets/esri/core/workers/chunks/048645611caa28dca7cd.js +0 -1
- package/assets/esri/core/workers/chunks/0b72d123386dc4ec7538.js +0 -1
- package/assets/esri/core/workers/chunks/13b04d5bf348ab5054c2.js +0 -1
- package/assets/esri/core/workers/chunks/215007e7c44811d90777.js +0 -1
- package/assets/esri/core/workers/chunks/31df729c17470245288c.js +0 -2
- package/assets/esri/core/workers/chunks/36272141b3c33cb19026.js +0 -1
- package/assets/esri/core/workers/chunks/36c8e8de9c3f67d32572.js +0 -1
- package/assets/esri/core/workers/chunks/37c428489c59df4b597b.js +0 -1
- package/assets/esri/core/workers/chunks/493169fd978fd543ef3b.js +0 -1
- package/assets/esri/core/workers/chunks/4f378ad6f4299183df85.js +0 -1
- package/assets/esri/core/workers/chunks/58e4c6ce1580427e7b55.js +0 -1
- package/assets/esri/core/workers/chunks/6c5441da675a8af35be2.js +0 -1
- package/assets/esri/core/workers/chunks/6ea16f6a0df946de480b.js +0 -1
- package/assets/esri/core/workers/chunks/7dfd70f4fa1096e56641.js +0 -1
- package/assets/esri/core/workers/chunks/88193e61072d7bf957f5.js +0 -1
- package/assets/esri/core/workers/chunks/8ccbde593c86c872e525.js +0 -1
- package/assets/esri/core/workers/chunks/9c6be39f1f21ab8b1c2d.js +0 -1
- package/assets/esri/core/workers/chunks/a73795cce722ba15b3da.js +0 -1
- package/assets/esri/core/workers/chunks/a8ed1a938dc164b401d9.js +0 -1
- package/assets/esri/core/workers/chunks/a9a73bc4875a5aeaf1b9.js +0 -1
- package/assets/esri/core/workers/chunks/adcc5bce6c0971c1b592.js +0 -1
- package/assets/esri/core/workers/chunks/afddfe620e6539991e6b.js +0 -1
- package/assets/esri/core/workers/chunks/b340c9bdabdb37995c8f.js +0 -1
- package/assets/esri/core/workers/chunks/b4c23630d6c85f7b59c0.js +0 -1
- package/assets/esri/core/workers/chunks/c180c40838246985479d.js +0 -1
- package/assets/esri/core/workers/chunks/caed2365bd296fcc8a75.js +0 -1
- package/assets/esri/core/workers/chunks/d85b5b73a151c6fbb658.js +0 -1
- package/assets/esri/core/workers/chunks/da6261673c3e1537b6a6.js +0 -1
- package/assets/esri/core/workers/chunks/dafe120243db6648a4ab.js +0 -1
- package/assets/esri/core/workers/chunks/ec6d138e8183e193f977.js +0 -1
- package/assets/esri/core/workers/chunks/ed4519ac9533a4d340f1.js +0 -1
- package/assets/esri/core/workers/chunks/f206300eef4560611728.js +0 -1
- package/assets/esri/core/workers/chunks/f55cbaf5a1d6ee6ac171.js +0 -1
- package/layers/GeoreferencedImageLayer.d.ts +0 -4
- package/layers/GeoreferencedImageLayer.js +0 -5
- package/layers/VoxelWasmManager.js +0 -5
- package/layers/VoxelWasmPerScene.js +0 -5
- package/views/3d/interactive/measurementTools/support/viewUtils.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import r from"../../config.js";import s from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import l from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Handles.js";import h from"../../core/has.js";import p from"../../core/Logger.js";import{unwrap as d,isSome as g,isNone as m}from"../../core/maybe.js";import{eachAlways as y,after as f}from"../../core/promiseUtils.js";import{whenOnce as S}from"../../core/reactiveUtils.js";import{init as _}from"../../core/watchUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/Point.js";import x from"../../geometry/SpatialReference.js";import{onLocaleChange as I}from"../../intl/locale.js";import{fetchMessageBundle as L}from"../../intl/messages.js";import j from"../../portal/Portal.js";import{highlightsSupported as T}from"../../views/support/layerViewUtils.js";import R from"./LayerSearchSource.js";import P from"./LocatorSearchSource.js";import E from"./SearchSource.js";import{getPointFromGeometry as F,getPointWithElevation as A}from"./support/geometryUtils.js";import{isArcGISWorldGeocoder as C,meteredArcGISLocatorUrl as G,isProxiedArcGISWorldGeocoder as O,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import{GoToMixin as k}from"../support/GoTo.js";import B from"../../symbols/PictureMarkerSymbol.js";import J from"../../symbols/SimpleLineSymbol.js";import U from"../../symbols/SimpleFillSymbol.js";import H from"../../symbols/TextSymbol.js";function Q(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const Z=()=>L("esri/widgets/Search/t9n/Search"),q="esri.widgets.Search.SearchViewModel",z=p.getLogger(q),K="highlight",W=l.ofType({key:e=>e.layer?"layer":"locator",base:E,typeMap:{layer:R,locator:P}}),X=x.WGS84,Y="esri/images/search/search-symbol-32.svg",$="esri/images/search/search-symbol-32.png",ee=/<(?:.|\s)*?>/g,te=-1;let re=class extends(k(u.EventedMixin(i))){constructor(e){super(e),this._handles=new c,this._gotoController=null,this._searching=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new W,this.defaultSymbols={point:new B({url:t(h("trident")?$:Y),size:24,width:24,height:24}),polyline:new J({color:[130,130,130,1],width:2}),polygon:new U({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=j.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new W,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await Z();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this._handles.add([_(this,["includeDefaultSources","view","portal"],(()=>this._update())),I(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics(),this._handles.destroy(),this._handles=null}get activeSource(){return this.allSources.getItemAt(this.activeSourceIndex)||null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:te}set activeSourceIndex(e){void 0!==e?this._override("activeSourceIndex",e):this._clearOverride("activeSourceIndex")}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){e?this._override("allPlaceholder",e):this._clearOverride("allPlaceholder")}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new W;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get defaultSymbol(){return a(z,"defaultSymbol",{replacement:"defaultSymbols",version:"4.22"}),this._get("defaultSymbol")}set defaultSymbol(e){a(z,"defaultSymbol",{replacement:"defaultSymbols",version:"4.22"}),this._set("defaultSymbol",e)}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});z.error(e)}this._override("locationEnabled",e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===te)return r;const s=e.getItemAt(t);return s?s.placeholder:""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup(),this.view&&this.view.graphics.remove(this.resultGraphic),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=this.when().then((()=>this._getResultsFromSources(r,t).then((e=>{if(d(t?.signal)?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text,numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=(r.location&&o?o.name:r.text).replace(ee,"");return this._set("searchTerm",i),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce(((e,t)=>e+t.results.length),0)),this.emit("search-complete",s),this._selectFirstResult(o).then((()=>s))})))).then((e=>(this._clearSearching(),e)),(e=>{throw this._clearSearching(),e}));return this._searching=s,s}searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});return z.error(e),Promise.reject(e)}const t=M().then((t=>V({position:t,view:this.view},e))).then((t=>this.search(t,e)));return this._searching=t,t.catch((()=>{})).then((()=>this._clearSearching())),t}select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});return z.error(t),Promise.reject(t)}const{view:t}=this,r=Q(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=this.allSources.getItemAt(r);if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});return z.error(e),Promise.reject(e)}const i=o instanceof R?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=Q(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=Q(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,c=Q(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,h=c?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:p}=e;if(!p){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:p});return z.error(e),Promise.reject(e)}const{attributes:d,geometry:m,layer:f,sourceLayer:S}=p,_=F(m),v={layerViewQuery:this._getLayerView(p),elevationQuery:t&&g(_)?A(_,t).catch((()=>_)):Promise.resolve(_)};return y(v).then((i=>{const n=i.layerViewQuery.value,y=i.elevationQuery.value;l instanceof H&&(l.text=e.name);const _=t&&u?e.target||e.extent:null;return(g(_)?this._goToSearchResult(_):Promise.resolve()).then((()=>{const i=n?p:new s({geometry:m,symbol:l,attributes:d,layer:f,sourceLayer:S,popupTemplate:h}),u=c&&this.view?.popup,g=u&&i.getEffectivePopupTemplate(u.defaultPopupTemplateEnabled);return g&&t.popup.open({features:[i],location:y}),n&&T(n)&&!g&&this._highlightFeature({graphic:i,layerView:n}),!n&&a&&t&&t.graphics.push(i),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",i),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}))}))}suggest(e,t,r){const s=e||this.searchTerm;return this.emit("suggest-start",{searchTerm:s}),this._suggestTimer(t,r).then((()=>this._suggestImmediate(s,r).then((e=>(this._set("suggestions",e.results),this._set("suggestionCount",e.results.reduce(((e,t)=>e+t.results.length),0)),this.emit("suggest-complete",e),e)))))}async when(){await S((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=y([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await S((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=r.apiKey&&C(e.url)?{url:G}:null,s=P.fromJSON({...e,...t}),o=s.url;if(C(o)||O(o)||N(o)){const e=s.outFields||["Addr_type","Match_addr","StAddr","City"],t=s.placeholder||this.messages.placeholder,r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.set({singleLineFieldName:"SingleLine",outFields:e,placeholder:t,defaultZoomScale:r})}return s.singleLineFieldName?s:void 0})).filter(Boolean)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(Boolean).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=R.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(Boolean).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find((e=>e.id===t.subLayer));if(!r)throw new Error;const s=await r.createFeatureLayer();return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}_getLayer(e,t){return"feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type?Promise.resolve(e):"map-image"===e.type?this._getSubLayer(e,t).catch((()=>{const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return z.error(t),null})):"building-scene"===e.type?this._getBuildingSubLayer(e,t):Promise.resolve(null)}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const{selectedFeature:r}=e;r&&r===t&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return f(r,null,t&&t.signal)}_createLocationForSearch(e){return e instanceof s?F(e.geometry):e instanceof w?e:Array.isArray(e)&&2===e.length?new w({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&Q(e,"key")&&Q(e,"text")&&Q(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:d(t),text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){let t=null;return e&&e.some((e=>{const{results:r}=e,s=r[0],o=!!s;return o&&(t=s),o})),t}_selectFirstResult(e){return this.autoSelect&&e?this.select(e):Promise.resolve(null)}_suggestImmediate(e,t){return this.when().then((()=>this._getSuggestionsFromSources(e,t))).then((r=>{if(d(t?.signal)?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e,numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}))}_formatSourceResponse(e,t,r){const s=t&&t.value||[],o=t&&t.error,i=this.allSources.getItemAt(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),z.error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===te){const s=r&&Q(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach(((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}_getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&Q(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:r});return z.error(e),Promise.reject(e)}return s===te?r.forEach(((r,s)=>{o.push(this._getResultsFromSource(e,s,t))})):o.push(this._getResultsFromSource(e,s,t)),y(o)}_getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:r});return z.error(e),Promise.reject(e)}return s===te?r.forEach(((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))})):o.push(this._getSuggestionsFromSource(e,s,t)),y(o)}_getResultsFromSource(e,t,r){const s=this.allSources.getItemAt(t),{location:o=null}=e,i=this.view?.spatialReference||X,l=Q(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof R&&Q(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},r)}_getSuggestionsFromSource(e,t,r){const s=this.allSources.getItemAt(t),o=Q(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e.length,l=Q(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||X,i=Q(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof R&&Q(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return Promise.resolve(null)}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return Q(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){const t=this.results;let r=null;return t.some((t=>t.results.some((s=>s===e&&(r=t.sourceIndex,!0))))),r}async _goToSearchResult(e){const t=!!e;this._abortGoTo();const r=new AbortController;this._gotoController=r;const s={target:{target:e},options:{animate:t,signal:r.signal}};await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(m(r))return null;const s=this._get("defaultSymbol");if(s&&("point"===r.type||"multipoint"===r.type))return s;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this._handles.remove(K)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer.type||"subtype-sublayer"===e.layer.type)return null;const{layer:r}=e;return await t.when(),t.whenLayerView(r)}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o}=t,{objectIdField:i}=o,l=s&&s[i],a=r.highlight(l||t);this._handles.add(a,K)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t.emit("select-result-floor",e)}}};re.ALL_INDEX=te,e([v()],re.prototype,"_searching",void 0),e([v()],re.prototype,"_updatingPromise",void 0),e([v({readOnly:!0,value:null})],re.prototype,"activeSource",null),e([v()],re.prototype,"activeSourceIndex",null),e([v()],re.prototype,"allPlaceholder",null),e([v({readOnly:!0})],re.prototype,"allSources",null),e([v()],re.prototype,"autoNavigate",void 0),e([v()],re.prototype,"autoSelect",void 0),e([v()],re.prototype,"defaultPopupTemplate",void 0),e([v({readOnly:!0})],re.prototype,"defaultSources",void 0),e([v()],re.prototype,"defaultSymbol",null),e([v()],re.prototype,"defaultSymbols",void 0),e([v()],re.prototype,"includeDefaultSources",void 0),e([v()],re.prototype,"locationEnabled",null),e([v()],re.prototype,"maxInputLength",void 0),e([v()],re.prototype,"maxResults",void 0),e([v()],re.prototype,"maxSuggestions",void 0),e([v()],re.prototype,"messages",void 0),e([v()],re.prototype,"minSuggestCharacters",void 0),e([v({readOnly:!0})],re.prototype,"placeholder",null),e([v()],re.prototype,"popupEnabled",void 0),e([v({type:o})],re.prototype,"popupTemplate",void 0),e([v({type:j})],re.prototype,"portal",void 0),e([v()],re.prototype,"resultCount",void 0),e([v()],re.prototype,"resultGraphicEnabled",void 0),e([v({readOnly:!0})],re.prototype,"resultGraphic",void 0),e([v({readOnly:!0})],re.prototype,"results",void 0),e([v({readOnly:!0})],re.prototype,"selectedSuggestion",void 0),e([v()],re.prototype,"searchAllEnabled",void 0),e([v({readOnly:!0})],re.prototype,"selectedResult",void 0),e([v()],re.prototype,"searchTerm",null),e([v({type:W})],re.prototype,"sources",void 0),e([v({readOnly:!0})],re.prototype,"state",null),e([v()],re.prototype,"suggestionDelay",void 0),e([v()],re.prototype,"suggestionCount",void 0),e([v({readOnly:!0})],re.prototype,"suggestions",void 0),e([v()],re.prototype,"suggestionsEnabled",void 0),e([v({readOnly:!0})],re.prototype,"updating",null),e([v()],re.prototype,"view",void 0),e([v()],re.prototype,"clear",null),re=e([b(q)],re);const se=re;export{se as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import r from"../../config.js";import s from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import l from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Handles.js";import h from"../../core/has.js";import p from"../../core/Logger.js";import{unwrap as d,isSome as g,isNone as m}from"../../core/maybe.js";import{eachAlways as y,after as f}from"../../core/promiseUtils.js";import{watch as S,whenOnce as _,initial as v}from"../../core/reactiveUtils.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import x from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import{onLocaleChange as L}from"../../intl/locale.js";import{fetchMessageBundle as T}from"../../intl/messages.js";import j from"../../portal/Portal.js";import{highlightsSupported as R}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import E from"./LocatorSearchSource.js";import F from"./SearchSource.js";import{getPointFromGeometry as A,getPointWithElevation as C}from"./support/geometryUtils.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as N,isMeteredArcGISWorldGeocoder as D}from"./support/locatorUtils.js";import{supported as M,getCurrentPosition as V,positionToPoint as k}from"../support/geolocationUtils.js";import{GoToMixin as B}from"../support/GoTo.js";import J from"../../symbols/PictureMarkerSymbol.js";import U from"../../symbols/SimpleLineSymbol.js";import H from"../../symbols/SimpleFillSymbol.js";import Q from"../../symbols/TextSymbol.js";function Z(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const q=()=>T("esri/widgets/Search/t9n/Search"),z="esri.widgets.Search.SearchViewModel",K=p.getLogger(z),W="highlight",X=l.ofType({key:e=>e.layer?"layer":"locator",base:F,typeMap:{layer:P,locator:E}}),Y=I.WGS84,$="esri/images/search/search-symbol-32.svg",ee="esri/images/search/search-symbol-32.png",te=/<(?:.|\s)*?>/g,re=-1;let se=class extends(B(u.EventedMixin(i))){constructor(e){super(e),this._handles=new c,this._gotoController=null,this._searching=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new X,this.defaultSymbols={point:new J({url:t(h("trident")?ee:$),size:24,width:24,height:24}),polyline:new U({color:[130,130,130,1],width:2}),polygon:new H({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=j.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new X,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await q();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this._handles.add([S((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),v),L(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics(),this._handles.destroy(),this._handles=null}get activeSource(){return this.allSources.getItemAt(this.activeSourceIndex)||null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:re}set activeSourceIndex(e){void 0!==e?this._override("activeSourceIndex",e):this._clearOverride("activeSourceIndex")}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){e?this._override("allPlaceholder",e):this._clearOverride("allPlaceholder")}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new X;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get defaultSymbol(){return a(K,"defaultSymbol",{replacement:"defaultSymbols",version:"4.22"}),this._get("defaultSymbol")}set defaultSymbol(e){a(K,"defaultSymbol",{replacement:"defaultSymbols",version:"4.22"}),this._set("defaultSymbol",e)}get locationEnabled(){return this._get("locationEnabled")||M()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=M();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});K.error(e)}this._override("locationEnabled",e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===re)return r;const s=e.getItemAt(t);return s?s.placeholder:""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup(),this.view&&this.view.graphics.remove(this.resultGraphic),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=this.when().then((()=>this._getResultsFromSources(r,t).then((e=>{if(d(t?.signal)?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text,numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=(r.location&&o?o.name:r.text).replace(te,"");return this._set("searchTerm",i),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce(((e,t)=>e+t.results.length),0)),this.emit("search-complete",s),this._selectFirstResult(o).then((()=>s))})))).then((e=>(this._clearSearching(),e)),(e=>{throw this._clearSearching(),e}));return this._searching=s,s}searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});return K.error(e),Promise.reject(e)}const t=V().then((t=>k({position:t,view:this.view},e))).then((t=>this.search(t,e)));return this._searching=t,t.catch((()=>{})).then((()=>this._clearSearching())),t}select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});return K.error(t),Promise.reject(t)}const{view:t}=this,r=Z(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=this.allSources.getItemAt(r);if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});return K.error(e),Promise.reject(e)}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=Z(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=Z(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,c=Z(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,h=c?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:p}=e;if(!p){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:p});return K.error(e),Promise.reject(e)}const{attributes:d,geometry:m,layer:f,sourceLayer:S}=p,_=A(m),v={layerViewQuery:this._getLayerView(p),elevationQuery:t&&g(_)?C(_,t).catch((()=>_)):Promise.resolve(_)};return y(v).then((i=>{const n=i.layerViewQuery.value,y=i.elevationQuery.value;l instanceof Q&&(l.text=e.name);const _=t&&u?e.target||e.extent:null;return(g(_)?this._goToSearchResult(_):Promise.resolve()).then((()=>{const i=n?p:new s({geometry:m,symbol:l,attributes:d,layer:f,sourceLayer:S,popupTemplate:h}),u=c&&this.view?.popup,g=u&&i.getEffectivePopupTemplate(u.defaultPopupTemplateEnabled);return g&&t.popup.open({features:[i],location:y}),n&&R(n)&&!g&&this._highlightFeature({graphic:i,layerView:n}),!n&&a&&t&&t.graphics.push(i),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",i),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}))}))}suggest(e,t,r){const s=e||this.searchTerm;return this.emit("suggest-start",{searchTerm:s}),this._suggestTimer(t,r).then((()=>this._suggestImmediate(s,r).then((e=>(this._set("suggestions",e.results),this._set("suggestionCount",e.results.reduce(((e,t)=>e+t.results.length),0)),this.emit("suggest-complete",e),e)))))}async when(){await _((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=y([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await _((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=r.apiKey&&G(e.url)?{url:O}:null,s=E.fromJSON({...e,...t}),o=s.url;if(G(o)||N(o)||D(o)){const e=s.outFields||["Addr_type","Match_addr","StAddr","City"],t=s.placeholder||this.messages.placeholder,r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.set({singleLineFieldName:"SingleLine",outFields:e,placeholder:t,defaultZoomScale:r})}return s.singleLineFieldName?s:void 0})).filter(Boolean)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(Boolean).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(Boolean).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find((e=>e.id===t.subLayer));if(!r)throw new Error;const s=await r.createFeatureLayer();return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}_getLayer(e,t){return"feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type?Promise.resolve(e):"map-image"===e.type?this._getSubLayer(e,t).catch((()=>{const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return K.error(t),null})):"building-scene"===e.type?this._getBuildingSubLayer(e,t):Promise.resolve(null)}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const{selectedFeature:r}=e;r&&r===t&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return f(r,null,t&&t.signal)}_createLocationForSearch(e){return e instanceof s?A(e.geometry):e instanceof x?e:Array.isArray(e)&&2===e.length?new x({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&Z(e,"key")&&Z(e,"text")&&Z(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:d(t),text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){let t=null;return e&&e.some((e=>{const{results:r}=e,s=r[0],o=!!s;return o&&(t=s),o})),t}_selectFirstResult(e){return this.autoSelect&&e?this.select(e):Promise.resolve(null)}_suggestImmediate(e,t){return this.when().then((()=>this._getSuggestionsFromSources(e,t))).then((r=>{if(d(t?.signal)?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e,numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}))}_formatSourceResponse(e,t,r){const s=t&&t.value||[],o=t&&t.error,i=this.allSources.getItemAt(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),K.error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===re){const s=r&&Z(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach(((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}_getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&Z(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:r});return K.error(e),Promise.reject(e)}return s===re?r.forEach(((r,s)=>{o.push(this._getResultsFromSource(e,s,t))})):o.push(this._getResultsFromSource(e,s,t)),y(o)}_getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:r});return K.error(e),Promise.reject(e)}return s===re?r.forEach(((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))})):o.push(this._getSuggestionsFromSource(e,s,t)),y(o)}_getResultsFromSource(e,t,r){const s=this.allSources.getItemAt(t),{location:o=null}=e,i=this.view?.spatialReference||Y,l=Z(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&Z(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},r)}_getSuggestionsFromSource(e,t,r){const s=this.allSources.getItemAt(t),o=Z(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e.length,l=Z(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Y,i=Z(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&Z(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return Promise.resolve(null)}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return Z(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){const t=this.results;let r=null;return t.some((t=>t.results.some((s=>s===e&&(r=t.sourceIndex,!0))))),r}async _goToSearchResult(e){const t=!!e;this._abortGoTo();const r=new AbortController;this._gotoController=r;const s={target:{target:e},options:{animate:t,signal:r.signal}};await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(m(r))return null;const s=this._get("defaultSymbol");if(s&&("point"===r.type||"multipoint"===r.type))return s;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this._handles.remove(W)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer.type||"subtype-sublayer"===e.layer.type)return null;const{layer:r}=e;return await t.when(),t.whenLayerView(r)}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o}=t,{objectIdField:i}=o,l=s&&s[i],a=r.highlight(l||t);this._handles.add(a,W)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t.emit("select-result-floor",e)}}};se.ALL_INDEX=re,e([b()],se.prototype,"_searching",void 0),e([b()],se.prototype,"_updatingPromise",void 0),e([b({readOnly:!0,value:null})],se.prototype,"activeSource",null),e([b()],se.prototype,"activeSourceIndex",null),e([b()],se.prototype,"allPlaceholder",null),e([b({readOnly:!0})],se.prototype,"allSources",null),e([b()],se.prototype,"autoNavigate",void 0),e([b()],se.prototype,"autoSelect",void 0),e([b()],se.prototype,"defaultPopupTemplate",void 0),e([b({readOnly:!0})],se.prototype,"defaultSources",void 0),e([b()],se.prototype,"defaultSymbol",null),e([b()],se.prototype,"defaultSymbols",void 0),e([b()],se.prototype,"includeDefaultSources",void 0),e([b()],se.prototype,"locationEnabled",null),e([b()],se.prototype,"maxInputLength",void 0),e([b()],se.prototype,"maxResults",void 0),e([b()],se.prototype,"maxSuggestions",void 0),e([b()],se.prototype,"messages",void 0),e([b()],se.prototype,"minSuggestCharacters",void 0),e([b({readOnly:!0})],se.prototype,"placeholder",null),e([b()],se.prototype,"popupEnabled",void 0),e([b({type:o})],se.prototype,"popupTemplate",void 0),e([b({type:j})],se.prototype,"portal",void 0),e([b()],se.prototype,"resultCount",void 0),e([b()],se.prototype,"resultGraphicEnabled",void 0),e([b({readOnly:!0})],se.prototype,"resultGraphic",void 0),e([b({readOnly:!0})],se.prototype,"results",void 0),e([b({readOnly:!0})],se.prototype,"selectedSuggestion",void 0),e([b()],se.prototype,"searchAllEnabled",void 0),e([b({readOnly:!0})],se.prototype,"selectedResult",void 0),e([b()],se.prototype,"searchTerm",null),e([b({type:X})],se.prototype,"sources",void 0),e([b({readOnly:!0})],se.prototype,"state",null),e([b()],se.prototype,"suggestionDelay",void 0),e([b()],se.prototype,"suggestionCount",void 0),e([b({readOnly:!0})],se.prototype,"suggestions",void 0),e([b()],se.prototype,"suggestionsEnabled",void 0),e([b({readOnly:!0})],se.prototype,"updating",null),e([b()],se.prototype,"view",void 0),e([b()],se.prototype,"clear",null),se=e([w(z)],se);const oe=se;export{oe as default};
|
package/widgets/Search.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{eventKey as t}from"../core/events.js";import s from"../core/Handles.js";import{escapeRegExpString as i}from"../core/string.js";import{watch as r,on as n,init as o}from"../core/watchUtils.js";import{aliasOf as a}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import c from"./Widget.js";import h from"./Search/SearchResultRenderer.js";import d from"./Search/SearchViewModel.js";import{storeNode as g,keepMenuItemWithinView as p,isActivationKey as _}from"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";import{substitute as I}from"../intl/substitute.js";const w={base:"esri-search esri-widget",loader:"esri-widget__loader",loaderText:"esri-widget__loader-text",loaderAnimation:"esri-widget__loader-animation",esriInput:"esri-input",hasMultipleSources:"esri-search--multiple-sources",isLoading:"esri-search--loading",isSearching:"esri-search--searching",showSuggestions:"esri-search--show-suggestions",showSources:"esri-search--sources",showWarning:"esri-search--warning",container:"esri-search__container",input:"esri-search__input",inputContainer:"esri-search__input-container",form:"esri-search__form",submitButton:"esri-search__submit-button",sourcesButton:"esri-search__sources-button",clearButton:"esri-search__clear-button",sourceName:"esri-search__source-name",suggestionsMenu:"esri-search__suggestions-menu",suggestionList:"esri-search__suggestions-list",suggestionListCurrentLocation:"esri-search__suggestions-list--current-location",sourcesMenu:"esri-search__sources-menu",source:"esri-search__source",warningMenu:"esri-search__warning-menu",warningMenuBody:"esri-search__warning-body",warningMenuHeader:"esri-search__warning-header",warningMenuText:"esri-search__warning-text",noValueText:"esri-search__no-value-text",esriWidgetDisabled:"esri-widget--disabled",button:"esri-widget--button",fallbackText:"esri-icon-font-fallback-text",header:"esri-widget__heading",locate:"esri-icon-locate-circled",menu:"esri-menu",menuList:"esri-menu__list",menuItem:"esri-menu__list-item",menuItemActive:"esri-menu__list-item--active",menuItemFocus:"esri-menu__list-item--focus",menuHeader:"esri-menu__header",loadingIcon:"esri-icon-loading-indicator esri-rotating",searchIcon:"esri-icon-search",dropdownIcon:"esri-icon-down-arrow esri-search__sources-button--down",dropupIcon:"esri-icon-up-arrow esri-search__sources-button--up",clearIcon:"esri-icon-close",noticeIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-search",disabled:"esri-disabled"},S=/<[a-z/][\s\S]*>/i;let b=class extends c{constructor(e,t){super(e,t),this._activeMenuItemIndex=-1,this._handles=new s,this._inputNode=null,this._menuItemCount=0,this._sourceMenuButtonNode=null,this._sourceListNode=null,this._suggestionListNode=null,this._searchResultRenderer=new h,this._locateFailed=null,this._container=null,this.activeMenu="none",this.activeSource=null,this.activeSourceIndex=null,this.allPlaceholder=null,this.allSources=null,this.autoNavigate=null,this.autoSelect=null,this.defaultSources=null,this.disabled=!1,this.goToOverride=null,this.iconClass=w.widgetIcon,this.includeDefaultSources=null,this.label=void 0,this.locationEnabled=null,this.maxResults=null,this.maxSuggestions=null,this.messages=null,this.messagesCommon=null,this.minSuggestCharacters=null,this.popupEnabled=null,this.popupTemplate=null,this.portal=null,this.resultGraphic=null,this.resultGraphicEnabled=null,this.results=null,this.searchAllEnabled=null,this.searchTerm=null,this.selectedResult=null,this.sources=null,this.suggestions=null,this.suggestionsEnabled=null,this.view=null,this.viewModel=new d,this._clearActiveMenu=()=>{this.activeMenu="none"},this._removeActiveMenu=e=>{const t=e.relatedTarget;t&&this._container?.contains(t)||this._clearActiveMenu()},this.own([r(this,"searchTerm",(e=>{(e&&"warning"===this.activeMenu||!e&&!this.get("viewModel.selectedSuggestion.location"))&&this._clearActiveMenu()})),n(this,"viewModel.allSources","change",(()=>this._watchSourceChanges())),o(this,"activeMenu",(()=>this._resetActiveMenuItemIndex())),o(this,"viewModel.defaultPopupTemplate",(e=>{e&&(e.content=this._renderSearchResultsContent.bind(this))}))])}destroy(){this._handles.destroy(),this._handles=null,this._cancelSuggest(),this._cancelSearch(),this._searchResultRenderer&&(this._searchResultRenderer.viewModel=null,this._searchResultRenderer.destroy(),this._searchResultRenderer=null)}get displayedSearchTerm(){return`${this.viewModel.searchTerm}`.trim()}get inputId(){return this._buildId("input")}get suggestionsMenuId(){return this._buildId("suggest-menu")}get sourceMenuId(){return this._buildId("source-menu")}get sourceMenuButtonId(){return this._buildId("source-menu-button")}clear(){}focus(){this._inputNode?.focus(),this.emit("search-focus")}blur(){this._inputNode?.blur(),this.emit("search-blur")}search(e){this._clearActiveMenu(),this._cancelSuggest(),this._cancelSearch();const t=new AbortController,{signal:s}=t;return this._searchController=t,this.viewModel.search(e,{signal:s}).catch((e=>{if(this._searchController===t)return this._clearActiveMenu(),this._searchController=null,e})).then((e=>{if(this._searchController===t)return this.activeMenu=e.numResults?"none":"warning",this._searchController=null,e}))}suggest(e){this._cancelSuggest();const t=new AbortController,{signal:s}=t;return this._suggestController=t,this.viewModel.suggest(e,null,{signal:s}).then((e=>{if(this._suggestController===t)return this._suggestController=null,e.numResults&&this._openSuggestionMenu(),this._scrollToTopSuggestion(),e})).catch((()=>{if(this._suggestController===t)return this._suggestController=null,null}))}render(){const{state:e}=this.viewModel,t={[w.disabled]:"disabled"===e,[w.esriWidgetDisabled]:this.disabled};return M("div",{class:this.classes(w.base,t)},"loading"===e?this.renderLoader():this.renderContainer())}renderSubmitButton(){const{messages:e}=this;return M("button",{"aria-label":e.searchButtonTitle,bind:this,class:this.classes(w.submitButton,w.button),key:"esri-search__submit-button",onclick:this._handleSearchButtonClick,title:e.searchButtonTitle,type:"button"},M("span",{"aria-hidden":"true",class:w.searchIcon}))}renderWarningMenu(){return M("div",{key:"esri-search__error-menu",class:this.classes(w.menu,w.warningMenu)},M("div",{class:w.warningMenuBody},this.renderWarning()))}renderSourceMenuButton(){const{messages:e,activeMenu:t,sourceMenuId:s,sourceMenuButtonId:i}=this,{activeSourceIndex:r,allSources:n}=this.viewModel;return n.length>1?M("button",{id:i,key:"esri-search__source-menu-button",bind:this,"aria-label":e.searchIn,title:e.searchIn,"aria-haspopup":"true","aria-expanded":("source"===t).toString(),"aria-controls":s,class:this.classes(w.sourcesButton,w.button),onclick:this._handleSourcesMenuToggleClick,onfocus:this._handleSourcesMenuToggleFocus,afterCreate:g,"data-node-ref":"_sourceMenuButtonNode",type:"button"},M("span",{"aria-hidden":"true",class:w.dropdownIcon}),M("span",{"aria-hidden":"true",class:w.dropupIcon}),M("span",{class:w.sourceName},this._getSourceName(r))):null}renderSourcesList(){const{allSources:e,searchAllEnabled:t}=this.viewModel,{_activeMenuItemIndex:s,activeMenu:i,sourceMenuId:r,sourceMenuButtonId:n}=this,o="source"===i&&s>-1?this._buildId("source-item",s):null;return e.length>1?M("ul",{"aria-activedescendant":o,"aria-labelledby":n,id:r,role:"menu",bind:this,afterCreate:g,onkeydown:this._handleSourceMenuKeydown,onkeyup:this._handleSourceMenuKeyup,"data-node-ref":"_sourceListNode",class:w.menuList,tabIndex:-1},t?this.renderSource(d.ALL_INDEX):null,e.map(((e,t)=>this.renderSource(t))).toArray()):null}renderSourcesMenu(){const{allSources:e}=this.viewModel;return e.length>1?M("div",{key:"esri-search__source-menu",class:this.classes(w.menu,w.sourcesMenu)},this.renderSourcesList()):null}renderLoader(){const{messages:e,messagesCommon:t}=this;return M("div",{class:w.loader,key:"base-loader"},M("span",{"aria-hidden":"true",class:w.loaderAnimation}),M("span",{class:w.fallbackText},e.searchButtonTitle),M("span",{class:w.loaderText},t.loading))}renderContainer(){const{allSources:e,state:t}=this.viewModel,{activeMenu:s}=this,i={[w.hasMultipleSources]:e.length>1,[w.isLoading]:"loading"===t,[w.isSearching]:"searching"===t,[w.showWarning]:"warning"===s,[w.showSources]:"source"===s,[w.showSuggestions]:"suggestion"===s};return M("div",{tabIndex:-1,afterCreate:e=>{this._container=e,e.addEventListener("focusout",this._removeActiveMenu)},afterRemoved:e=>{e.removeEventListener("focusout",this._removeActiveMenu)},class:this.classes(i,w.container),key:"base-container"},this.renderSourceMenuButton(),this.renderSourcesMenu(),this.renderInputContainer(),this.renderSubmitButton(),this.renderWarningMenu())}renderClearButton(){return this.searchTerm?M("button",{bind:this,class:this.classes(w.clearButton,w.button),key:"esri-search__clear-button",onclick:this._handleClearButtonClick,onfocus:this._clearActiveMenu,title:this.messages.clearButtonTitle,type:"button"},M("span",{"aria-hidden":"true",class:w.clearIcon})):null}renderLocationGroup(){const{messages:e,locationEnabled:t,displayedSearchTerm:s}=this,i=t&&!s,r="suggestion"===this.activeMenu&&0===this._activeMenuItemIndex;return i?M("ul",{role:"group",key:"esri-search__suggestion-list-current-location",class:this.classes(w.menuList,w.suggestionList,w.suggestionListCurrentLocation)},M("li",{bind:this,"data-current-location-item":!0,onclick:this._handleUseCurrentLocationClick,id:this._buildId("suggestion-item",0),"aria-selected":("suggestion"===this.activeMenu&&0===this._activeMenuItemIndex).toString(),role:"option",class:this.classes(w.menuItem,r?w.menuItemFocus:null)},M("span",{"aria-hidden":"true",class:w.locate})," ",e.useCurrentLocation)):null}renderInput(){const{activeMenu:e,locationEnabled:t,displayedSearchTerm:s,messages:i,suggestionsMenuId:r,inputId:n,_activeMenuItemIndex:o}=this,{maxInputLength:a,placeholder:u,searchTerm:l,suggestionCount:c}=this.viewModel,h=!(!(t&&!s)&&!c),d="suggestion"===e&&o>-1?this._buildId("suggestion-item",o):null;return M("input",{"aria-activedescendant":d,"aria-autocomplete":"list","aria-expanded":(h&&"suggestion"===e).toString(),"aria-controls":h?r:null,"aria-haspopup":"listbox","aria-label":i.searchButtonTitle,bind:this,placeholder:u,maxlength:a,autocomplete:"off",type:"text",class:this.classes(w.esriInput,w.input),value:l,id:n,role:"combobox",onkeyup:this._handleInputKeyup,onclick:this._openSuggestionMenu,oninput:this._handleInputPaste,onpaste:this._handleInputPaste,afterCreate:g,"data-node-ref":"_inputNode",onfocus:this.focus,onblur:this.blur,title:l?"":u})}renderForm(){return M("form",{key:"esri-search__form",bind:this,class:w.form,onsubmit:this._formSubmit,role:"search"},this.renderInput())}renderSuggestList(e){const{sourceIndex:t}=e,s=e.results.length,i=e.results;return s?M("ul",{role:"group",key:`esri-search__suggestion-list-${t}`,class:this.classes(w.menuList,w.suggestionList)},i.map((e=>this.renderSuggestion(e,this._menuItemCount++)))):null}renderSuggestionsGroup(){const{suggestions:e}=this.viewModel;return e?e.map((e=>[this.renderSuggestionHeader(e),this.renderSuggestList(e)])):null}renderSuggestionsMenu(){const{displayedSearchTerm:e,locationEnabled:t,suggestionsMenuId:s,inputId:i}=this,{suggestionCount:r}=this.viewModel,n=t&&!e||r;return this._menuItemCount=0,n?M("div",{id:s,key:"esri-search__suggestions-menu",class:this.classes(w.menu,w.suggestionsMenu),role:"listbox","aria-labelledby":i,bind:this,afterCreate:g,"data-node-ref":"_suggestionListNode"},this.renderLocationGroup(),this.renderSuggestionsGroup()):null}renderInputContainer(){return M("div",{key:"esri-search__input-container",class:w.inputContainer},this.renderForm(),this.renderSuggestionsMenu(),this.renderClearButton())}renderSuggestionHeader(e){const{allSources:t,activeSourceIndex:s}=this.viewModel,{sourceIndex:i}=e,r=e.results.length,n=t.length>1&&s===d.ALL_INDEX;return r&&n?M("div",{key:`esri-search__suggestion-header-${i}`,class:w.menuHeader},this._getSourceName(i)):null}renderSuggestion(e,t){const{_activeMenuItemIndex:s,messages:i}=this,{searchTerm:r}=this.viewModel;if(r){const{text:n}=e,o=n||i.untitledResult,a=S.test(o),u=[];if(a)u.push(M("div",{innerHTML:o}));else{const e=this._splitResult(o,r),t=r.toLowerCase();e.forEach(((e,s)=>{e&&e.length&&(e.toLowerCase()===t?u.push(M("strong",{key:s},e)):u.push(e))}))}const l="suggestion"===this.activeMenu&&s===t;return M("li",{bind:this,id:this._buildId("suggestion-item",t),"aria-selected":("suggestion"===this.activeMenu&&this._activeMenuItemIndex===t).toString(),onclick:this._handleSuggestionClick,key:`esri-search__suggestion_${t}`,"data-suggestion":e,role:"option",class:this.classes(w.menuItem,l?w.menuItemFocus:null)},u)}}renderSource(e){const{activeSourceIndex:t,searchAllEnabled:s}=this.viewModel,i={[w.menuItemActive]:e===t,[w.menuItemFocus]:"source"===this.activeMenu&&e===(s?this._activeMenuItemIndex-1:this._activeMenuItemIndex)},r=s?e+1:e;return M("li",{bind:this,key:`esri-search__source-${e}`,id:this._buildId("source-item",r),"aria-checked":(e===t).toString(),onclick:this._handleSourceClick,"data-source-index":e,role:"menuitemradio",class:this.classes(w.source,w.menuItem,i)},this._getSourceName(e))}renderNoResultsWarning(e){const{messages:t}=this,s=e?I(t.noResultsFoundForValue,{value:`"${e}"`}):t.noResultsFound;return M("div",{key:"esri-search__no_results"},M("div",{class:w.warningMenuHeader},t.noResults),M("div",{class:w.warningMenuText},s))}renderEmptySearchWarning(){const{messages:e}=this;return M("div",{key:"esri-search__empty-search"},M("span",{"aria-hidden":"true",class:w.noticeIcon}),M("span",{class:w.noValueText},e.emptyValue))}renderLocateWarning(){const{messages:e}=this;return M("div",{key:"esri-search__locate-error"},M("span",{"aria-hidden":"true",class:w.noticeIcon}),M("span",{class:w.noValueText},e.locateError))}renderWarning(){const{displayedSearchTerm:e,_locateFailed:t}=this,{viewModel:s}=this;return t?this.renderLocateWarning():s.selectedSuggestion?.location||e?this.renderNoResultsWarning(e):this.renderEmptySearchWarning()}_resetActiveMenuItemIndex(){this._activeMenuItemIndex=-1}_buildId(e,t){return`${this.id}-${e}${void 0===t?"":`-${t}`}`}_watchSourceChanges(){const{_handles:e,viewModel:{allSources:t}}=this,s="sources";e.remove(s),t.forEach((t=>e.add(r(t,"name",(()=>this.scheduleRender())),s)))}_handleSourcesMenuToggleFocus(){"source"!==this.activeMenu&&this._clearActiveMenu()}_handleSourcesMenuToggleClick(){const e="source"===this.activeMenu;this.activeMenu=e?"none":"source",this.renderNow(),"source"===this.activeMenu&&this._sourceListNode?.focus()}_handleClearButtonClick(){this.viewModel.clear(),this._focus()}_handleSearchButtonClick(){this.search()}_handleSuggestionClick(e){const t=e.currentTarget["data-suggestion"];t&&(this._focus(),this.search(t))}_handleUseCurrentLocationClick(){this._useCurrentLocation()}_useCurrentLocation(){this._focus("none"),this._cancelSuggest(),this._cancelSearch();const e=new AbortController,{signal:t}=e;this._searchController=e,this.viewModel.searchNearby({signal:t}).then((e=>{this.activeMenu=e.numResults?"none":"warning"})).catch((()=>{this._locateFailed=!0,this.activeMenu="warning"})).then((()=>{this._searchController=null}))}_handleSourceClick(e){this._setSourceFromMenuItem(e.currentTarget)}_setSourceFromMenuItem(e){if(!e)return;const t=e["data-source-index"];this.viewModel.activeSourceIndex=t,this._clearActiveMenu(),this._sourceMenuButtonNode?.focus()}_cancelSuggest(){this._suggestController&&(this._suggestController.abort(),this._suggestController=null)}_cancelSearch(){this._searchController&&(this._searchController.abort(),this._searchController=null),this._locateFailed=!1}_handleInputKeyup(e){const s=t(e);if(e.ctrlKey||e.metaKey||"Copy"===s||"ArrowLeft"===s||"ArrowRight"===s||"Shift"===s)return;if("Tab"===s||"Escape"===s||e.shiftKey&&"Tab"===s)return this._cancelSuggest(),void("Escape"===s&&this._clearActiveMenu());const i="Home"===s||"End"===s||"ArrowUp"===s||"ArrowDown"===s;if("Enter"===s&&this._activeMenuItemIndex<0)return void this._cancelSuggest();const r=this._suggestionListNode?.getElementsByTagName("li");if(r?.length){if("suggestion"!==this.activeMenu&&this._openSuggestionMenu(),i)return e.preventDefault(),this._cancelSuggest(),void this._handleItemNavigation(s,r,this._suggestionListNode);const t=r[this._activeMenuItemIndex];if("Enter"===s&&t){const e=t["data-suggestion"];return void(e?(this._focus(),this.search(e)):t["data-current-location-item"]&&this._useCurrentLocation())}}this.viewModel.searchTerm&&this.suggest()}_handleItemNavigation(e,t,s){const i=this._activeMenuItemIndex;"Home"===e&&(this._activeMenuItemIndex=0),"End"===e&&(this._activeMenuItemIndex=t.length-1),"ArrowUp"===e&&(this._activeMenuItemIndex=this._activeMenuItemIndex<=0?t.length-1:this._activeMenuItemIndex-1),"ArrowDown"===e&&(this._activeMenuItemIndex=this._activeMenuItemIndex===t.length-1?0:this._activeMenuItemIndex+1),i!==this._activeMenuItemIndex&&p(t[this._activeMenuItemIndex],s)}_scrollToTopSuggestion(){this._suggestionListNode&&(this._suggestionListNode.scrollTop=0)}_openSuggestionMenu(){this.activeMenu="suggestion"}_handleInputPaste(e){const t=e.target;this.viewModel.searchTerm!==t.value&&(this.viewModel.searchTerm=t.value),this.viewModel.searchTerm&&this.suggest()}_handleSourceMenuKeydown(e){const s=t(e);if(_(s)){e.preventDefault();const t=this._sourceListNode.getElementsByTagName("li")[this._activeMenuItemIndex];this._setSourceFromMenuItem(t)}else"ArrowUp"!==s&&"ArrowDown"!==s&&"End"!==s&&"Home"!==s||e.preventDefault()}_handleSourceMenuKeyup(e){const s=t(e),i="ArrowUp"===s||"ArrowDown"===s||"End"===s||"Home"===s;if(i&&e.preventDefault(),"Escape"===s)return this._clearActiveMenu(),void this._sourceMenuButtonNode?.focus();const r=this._sourceListNode?.getElementsByTagName("li");return r&&0!==r.length&&i?("source"!==this.activeMenu&&(this.activeMenu="source"),void this._handleItemNavigation(s,r,this._sourceListNode.parentElement)):void 0}_focus(e){this.focus(),e&&(this.activeMenu=e)}_formSubmit(e){e.preventDefault(),-1===this._activeMenuItemIndex&&this.search()}_getSourceName(e){const{messages:t}=this,s=this.viewModel,{allSources:i}=s,r=i.getItemAt(e);return e===d.ALL_INDEX?t.all:r&&r.name||t.untitledSource}_splitResult(e,t){const s=i(t);return e.replace(new RegExp(`(^|)(${s})(|$)`,"ig"),"$1|$2|$3").split("|")}_renderSearchResultsContent(){return this._searchResultRenderer.showMoreResultsOpen=!1,this._searchResultRenderer.viewModel=this.viewModel,this._searchResultRenderer}};e([u()],b.prototype,"_activeMenuItemIndex",void 0),e([u()],b.prototype,"displayedSearchTerm",null),e([u({readOnly:!0})],b.prototype,"inputId",null),e([u({readOnly:!0})],b.prototype,"suggestionsMenuId",null),e([u({readOnly:!0})],b.prototype,"sourceMenuId",null),e([u({readOnly:!0})],b.prototype,"sourceMenuButtonId",null),e([u()],b.prototype,"activeMenu",void 0),e([a("viewModel.activeSource")],b.prototype,"activeSource",void 0),e([a("viewModel.activeSourceIndex")],b.prototype,"activeSourceIndex",void 0),e([a("viewModel.allPlaceholder")],b.prototype,"allPlaceholder",void 0),e([a("viewModel.allSources")],b.prototype,"allSources",void 0),e([a("viewModel.autoNavigate")],b.prototype,"autoNavigate",void 0),e([a("viewModel.autoSelect")],b.prototype,"autoSelect",void 0),e([a("viewModel.defaultSources")],b.prototype,"defaultSources",void 0),e([u()],b.prototype,"disabled",void 0),e([a("viewModel.goToOverride")],b.prototype,"goToOverride",void 0),e([u()],b.prototype,"iconClass",void 0),e([a("viewModel.includeDefaultSources")],b.prototype,"includeDefaultSources",void 0),e([u({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],b.prototype,"label",void 0),e([a("viewModel.locationEnabled")],b.prototype,"locationEnabled",void 0),e([a("viewModel.maxResults")],b.prototype,"maxResults",void 0),e([a("viewModel.maxSuggestions")],b.prototype,"maxSuggestions",void 0),e([u(),m("esri/widgets/Search/t9n/Search")],b.prototype,"messages",void 0),e([u(),m("esri/t9n/common")],b.prototype,"messagesCommon",void 0),e([a("viewModel.minSuggestCharacters")],b.prototype,"minSuggestCharacters",void 0),e([a("viewModel.popupEnabled")],b.prototype,"popupEnabled",void 0),e([a("viewModel.popupTemplate")],b.prototype,"popupTemplate",void 0),e([a("viewModel.portal")],b.prototype,"portal",void 0),e([a("viewModel.resultGraphic")],b.prototype,"resultGraphic",void 0),e([a("viewModel.resultGraphicEnabled")],b.prototype,"resultGraphicEnabled",void 0),e([a("viewModel.results")],b.prototype,"results",void 0),e([a("viewModel.searchAllEnabled")],b.prototype,"searchAllEnabled",void 0),e([a("viewModel.searchTerm")],b.prototype,"searchTerm",void 0),e([a("viewModel.selectedResult")],b.prototype,"selectedResult",void 0),e([a("viewModel.sources")],b.prototype,"sources",void 0),e([a("viewModel.suggestions")],b.prototype,"suggestions",void 0),e([a("viewModel.suggestionsEnabled")],b.prototype,"suggestionsEnabled",void 0),e([a("viewModel.view")],b.prototype,"view",void 0),e([v(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),u({type:d})],b.prototype,"viewModel",void 0),e([a("viewModel.clear")],b.prototype,"clear",null),b=e([l("esri.widgets.Search")],b);const y=b;export{y as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{eventKey as t}from"../core/events.js";import s from"../core/Handles.js";import{watch as i,on as r,initial as n}from"../core/reactiveUtils.js";import{escapeRegExpString as o}from"../core/string.js";import{aliasOf as a}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import c from"./Widget.js";import h from"./Search/SearchResultRenderer.js";import d from"./Search/SearchViewModel.js";import{storeNode as g,keepMenuItemWithinView as p,isActivationKey as _}from"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as M}from"./support/jsxFactory.js";import{substitute as I}from"../intl/substitute.js";const S={base:"esri-search esri-widget",loader:"esri-widget__loader",loaderText:"esri-widget__loader-text",loaderAnimation:"esri-widget__loader-animation",esriInput:"esri-input",hasMultipleSources:"esri-search--multiple-sources",isLoading:"esri-search--loading",isSearching:"esri-search--searching",showSuggestions:"esri-search--show-suggestions",showSources:"esri-search--sources",showWarning:"esri-search--warning",container:"esri-search__container",input:"esri-search__input",inputContainer:"esri-search__input-container",form:"esri-search__form",submitButton:"esri-search__submit-button",sourcesButton:"esri-search__sources-button",clearButton:"esri-search__clear-button",sourceName:"esri-search__source-name",suggestionsMenu:"esri-search__suggestions-menu",suggestionList:"esri-search__suggestions-list",suggestionListCurrentLocation:"esri-search__suggestions-list--current-location",sourcesMenu:"esri-search__sources-menu",source:"esri-search__source",warningMenu:"esri-search__warning-menu",warningMenuBody:"esri-search__warning-body",warningMenuHeader:"esri-search__warning-header",warningMenuText:"esri-search__warning-text",noValueText:"esri-search__no-value-text",esriWidgetDisabled:"esri-widget--disabled",button:"esri-widget--button",fallbackText:"esri-icon-font-fallback-text",header:"esri-widget__heading",locate:"esri-icon-locate-circled",menu:"esri-menu",menuList:"esri-menu__list",menuItem:"esri-menu__list-item",menuItemActive:"esri-menu__list-item--active",menuItemFocus:"esri-menu__list-item--focus",menuHeader:"esri-menu__header",loadingIcon:"esri-icon-loading-indicator esri-rotating",searchIcon:"esri-icon-search",dropdownIcon:"esri-icon-down-arrow esri-search__sources-button--down",dropupIcon:"esri-icon-up-arrow esri-search__sources-button--up",clearIcon:"esri-icon-close",noticeIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-search",disabled:"esri-disabled"},w=/<[a-z/][\s\S]*>/i;let b=class extends c{constructor(e,t){super(e,t),this._activeMenuItemIndex=-1,this._handles=new s,this._inputNode=null,this._menuItemCount=0,this._sourceMenuButtonNode=null,this._sourceListNode=null,this._suggestionListNode=null,this._searchResultRenderer=new h,this._locateFailed=null,this._container=null,this.activeMenu="none",this.activeSource=null,this.activeSourceIndex=null,this.allPlaceholder=null,this.allSources=null,this.autoNavigate=null,this.autoSelect=null,this.defaultSources=null,this.disabled=!1,this.goToOverride=null,this.iconClass=S.widgetIcon,this.includeDefaultSources=null,this.label=void 0,this.locationEnabled=null,this.maxResults=null,this.maxSuggestions=null,this.messages=null,this.messagesCommon=null,this.minSuggestCharacters=null,this.popupEnabled=null,this.popupTemplate=null,this.portal=null,this.resultGraphic=null,this.resultGraphicEnabled=null,this.results=null,this.searchAllEnabled=null,this.searchTerm=null,this.selectedResult=null,this.sources=null,this.suggestions=null,this.suggestionsEnabled=null,this.view=null,this.viewModel=new d,this._clearActiveMenu=()=>{this.activeMenu="none"},this._removeActiveMenu=e=>{const t=e.relatedTarget;t&&this._container?.contains(t)||this._clearActiveMenu()},this.own([i((()=>this.searchTerm),(e=>{(e&&"warning"===this.activeMenu||!e&&!this.get("viewModel.selectedSuggestion.location"))&&this._clearActiveMenu()})),r((()=>this.viewModel?.allSources),"change",(()=>this._watchSourceChanges())),i((()=>this.activeMenu),(()=>this._resetActiveMenuItemIndex()),n),i((()=>this.viewModel?.defaultPopupTemplate),(e=>{e&&(e.content=this._renderSearchResultsContent.bind(this))}),n)])}destroy(){this._handles.destroy(),this._handles=null,this._cancelSuggest(),this._cancelSearch(),this._searchResultRenderer&&(this._searchResultRenderer.viewModel=null,this._searchResultRenderer.destroy(),this._searchResultRenderer=null)}get displayedSearchTerm(){return`${this.viewModel.searchTerm}`.trim()}get inputId(){return this._buildId("input")}get suggestionsMenuId(){return this._buildId("suggest-menu")}get sourceMenuId(){return this._buildId("source-menu")}get sourceMenuButtonId(){return this._buildId("source-menu-button")}clear(){}focus(){this._inputNode?.focus(),this.emit("search-focus")}blur(){this._inputNode?.blur(),this.emit("search-blur")}search(e){this._clearActiveMenu(),this._cancelSuggest(),this._cancelSearch();const t=new AbortController,{signal:s}=t;return this._searchController=t,this.viewModel.search(e,{signal:s}).catch((e=>{if(this._searchController===t)return this._clearActiveMenu(),this._searchController=null,e})).then((e=>{if(this._searchController===t)return this.activeMenu=e.numResults?"none":"warning",this._searchController=null,e}))}suggest(e){this._cancelSuggest();const t=new AbortController,{signal:s}=t;return this._suggestController=t,this.viewModel.suggest(e,null,{signal:s}).then((e=>{if(this._suggestController===t)return this._suggestController=null,e.numResults&&this._openSuggestionMenu(),this._scrollToTopSuggestion(),e})).catch((()=>{if(this._suggestController===t)return this._suggestController=null,null}))}render(){const{state:e}=this.viewModel,t={[S.disabled]:"disabled"===e,[S.esriWidgetDisabled]:this.disabled};return M("div",{class:this.classes(S.base,t)},"loading"===e?this.renderLoader():this.renderContainer())}renderSubmitButton(){const{messages:e}=this;return M("button",{"aria-label":e.searchButtonTitle,bind:this,class:this.classes(S.submitButton,S.button),key:"esri-search__submit-button",onclick:this._handleSearchButtonClick,title:e.searchButtonTitle,type:"button"},M("span",{"aria-hidden":"true",class:S.searchIcon}))}renderWarningMenu(){return M("div",{key:"esri-search__error-menu",class:this.classes(S.menu,S.warningMenu)},M("div",{class:S.warningMenuBody},this.renderWarning()))}renderSourceMenuButton(){const{messages:e,activeMenu:t,sourceMenuId:s,sourceMenuButtonId:i}=this,{activeSourceIndex:r,allSources:n}=this.viewModel;return n.length>1?M("button",{id:i,key:"esri-search__source-menu-button",bind:this,"aria-label":e.searchIn,title:e.searchIn,"aria-haspopup":"true","aria-expanded":("source"===t).toString(),"aria-controls":s,class:this.classes(S.sourcesButton,S.button),onclick:this._handleSourcesMenuToggleClick,onfocus:this._handleSourcesMenuToggleFocus,afterCreate:g,"data-node-ref":"_sourceMenuButtonNode",type:"button"},M("span",{"aria-hidden":"true",class:S.dropdownIcon}),M("span",{"aria-hidden":"true",class:S.dropupIcon}),M("span",{class:S.sourceName},this._getSourceName(r))):null}renderSourcesList(){const{allSources:e,searchAllEnabled:t}=this.viewModel,{_activeMenuItemIndex:s,activeMenu:i,sourceMenuId:r,sourceMenuButtonId:n}=this,o="source"===i&&s>-1?this._buildId("source-item",s):null;return e.length>1?M("ul",{"aria-activedescendant":o,"aria-labelledby":n,id:r,role:"menu",bind:this,afterCreate:g,onkeydown:this._handleSourceMenuKeydown,onkeyup:this._handleSourceMenuKeyup,"data-node-ref":"_sourceListNode",class:S.menuList,tabIndex:-1},t?this.renderSource(d.ALL_INDEX):null,e.map(((e,t)=>this.renderSource(t))).toArray()):null}renderSourcesMenu(){const{allSources:e}=this.viewModel;return e.length>1?M("div",{key:"esri-search__source-menu",class:this.classes(S.menu,S.sourcesMenu)},this.renderSourcesList()):null}renderLoader(){const{messages:e,messagesCommon:t}=this;return M("div",{class:S.loader,key:"base-loader"},M("span",{"aria-hidden":"true",class:S.loaderAnimation}),M("span",{class:S.fallbackText},e.searchButtonTitle),M("span",{class:S.loaderText},t.loading))}renderContainer(){const{allSources:e,state:t}=this.viewModel,{activeMenu:s}=this,i={[S.hasMultipleSources]:e.length>1,[S.isLoading]:"loading"===t,[S.isSearching]:"searching"===t,[S.showWarning]:"warning"===s,[S.showSources]:"source"===s,[S.showSuggestions]:"suggestion"===s};return M("div",{tabIndex:-1,afterCreate:e=>{this._container=e,e.addEventListener("focusout",this._removeActiveMenu)},afterRemoved:e=>{e.removeEventListener("focusout",this._removeActiveMenu)},class:this.classes(i,S.container),key:"base-container"},this.renderSourceMenuButton(),this.renderSourcesMenu(),this.renderInputContainer(),this.renderSubmitButton(),this.renderWarningMenu())}renderClearButton(){return this.searchTerm?M("button",{bind:this,class:this.classes(S.clearButton,S.button),key:"esri-search__clear-button",onclick:this._handleClearButtonClick,onfocus:this._clearActiveMenu,title:this.messages.clearButtonTitle,type:"button"},M("span",{"aria-hidden":"true",class:S.clearIcon})):null}renderLocationGroup(){const{messages:e,locationEnabled:t,displayedSearchTerm:s}=this,i=t&&!s,r="suggestion"===this.activeMenu&&0===this._activeMenuItemIndex;return i?M("ul",{role:"group",key:"esri-search__suggestion-list-current-location",class:this.classes(S.menuList,S.suggestionList,S.suggestionListCurrentLocation)},M("li",{bind:this,"data-current-location-item":!0,onclick:this._handleUseCurrentLocationClick,id:this._buildId("suggestion-item",0),"aria-selected":("suggestion"===this.activeMenu&&0===this._activeMenuItemIndex).toString(),role:"option",class:this.classes(S.menuItem,r?S.menuItemFocus:null)},M("span",{"aria-hidden":"true",class:S.locate})," ",e.useCurrentLocation)):null}renderInput(){const{activeMenu:e,locationEnabled:t,displayedSearchTerm:s,messages:i,suggestionsMenuId:r,inputId:n,_activeMenuItemIndex:o}=this,{maxInputLength:a,placeholder:u,searchTerm:l,suggestionCount:c}=this.viewModel,h=!(!(t&&!s)&&!c),d="suggestion"===e&&o>-1?this._buildId("suggestion-item",o):null;return M("input",{"aria-activedescendant":d,"aria-autocomplete":"list","aria-expanded":(h&&"suggestion"===e).toString(),"aria-controls":h?r:null,"aria-haspopup":"listbox","aria-label":i.searchButtonTitle,bind:this,placeholder:u,maxlength:a,autocomplete:"off",type:"text",class:this.classes(S.esriInput,S.input),value:l,id:n,role:"combobox",onkeyup:this._handleInputKeyup,onclick:this._openSuggestionMenu,oninput:this._handleInputPaste,onpaste:this._handleInputPaste,afterCreate:g,"data-node-ref":"_inputNode",onfocus:this.focus,onblur:this.blur,title:l?"":u})}renderForm(){return M("form",{key:"esri-search__form",bind:this,class:S.form,onsubmit:this._formSubmit,role:"search"},this.renderInput())}renderSuggestList(e){const{sourceIndex:t}=e,s=e.results.length,i=e.results;return s?M("ul",{role:"group",key:`esri-search__suggestion-list-${t}`,class:this.classes(S.menuList,S.suggestionList)},i.map((e=>this.renderSuggestion(e,this._menuItemCount++)))):null}renderSuggestionsGroup(){const{suggestions:e}=this.viewModel;return e?e.map((e=>[this.renderSuggestionHeader(e),this.renderSuggestList(e)])):null}renderSuggestionsMenu(){const{displayedSearchTerm:e,locationEnabled:t,suggestionsMenuId:s,inputId:i}=this,{suggestionCount:r}=this.viewModel,n=t&&!e||r;return this._menuItemCount=0,n?M("div",{id:s,key:"esri-search__suggestions-menu",class:this.classes(S.menu,S.suggestionsMenu),role:"listbox","aria-labelledby":i,bind:this,afterCreate:g,"data-node-ref":"_suggestionListNode"},this.renderLocationGroup(),this.renderSuggestionsGroup()):null}renderInputContainer(){return M("div",{key:"esri-search__input-container",class:S.inputContainer},this.renderForm(),this.renderSuggestionsMenu(),this.renderClearButton())}renderSuggestionHeader(e){const{allSources:t,activeSourceIndex:s}=this.viewModel,{sourceIndex:i}=e,r=e.results.length,n=t.length>1&&s===d.ALL_INDEX;return r&&n?M("div",{key:`esri-search__suggestion-header-${i}`,class:S.menuHeader},this._getSourceName(i)):null}renderSuggestion(e,t){const{_activeMenuItemIndex:s,messages:i}=this,{searchTerm:r}=this.viewModel;if(r){const{text:n}=e,o=n||i.untitledResult,a=w.test(o),u=[];if(a)u.push(M("div",{innerHTML:o}));else{const e=this._splitResult(o,r),t=r.toLowerCase();e.forEach(((e,s)=>{e&&e.length&&(e.toLowerCase()===t?u.push(M("strong",{key:s},e)):u.push(e))}))}const l="suggestion"===this.activeMenu&&s===t;return M("li",{bind:this,id:this._buildId("suggestion-item",t),"aria-selected":("suggestion"===this.activeMenu&&this._activeMenuItemIndex===t).toString(),onclick:this._handleSuggestionClick,key:`esri-search__suggestion_${t}`,"data-suggestion":e,role:"option",class:this.classes(S.menuItem,l?S.menuItemFocus:null)},u)}}renderSource(e){const{activeSourceIndex:t,searchAllEnabled:s}=this.viewModel,i={[S.menuItemActive]:e===t,[S.menuItemFocus]:"source"===this.activeMenu&&e===(s?this._activeMenuItemIndex-1:this._activeMenuItemIndex)},r=s?e+1:e;return M("li",{bind:this,key:`esri-search__source-${e}`,id:this._buildId("source-item",r),"aria-checked":(e===t).toString(),onclick:this._handleSourceClick,"data-source-index":e,role:"menuitemradio",class:this.classes(S.source,S.menuItem,i)},this._getSourceName(e))}renderNoResultsWarning(e){const{messages:t}=this,s=e?I(t.noResultsFoundForValue,{value:`"${e}"`}):t.noResultsFound;return M("div",{key:"esri-search__no_results"},M("div",{class:S.warningMenuHeader},t.noResults),M("div",{class:S.warningMenuText},s))}renderEmptySearchWarning(){const{messages:e}=this;return M("div",{key:"esri-search__empty-search"},M("span",{"aria-hidden":"true",class:S.noticeIcon}),M("span",{class:S.noValueText},e.emptyValue))}renderLocateWarning(){const{messages:e}=this;return M("div",{key:"esri-search__locate-error"},M("span",{"aria-hidden":"true",class:S.noticeIcon}),M("span",{class:S.noValueText},e.locateError))}renderWarning(){const{displayedSearchTerm:e,_locateFailed:t}=this,{viewModel:s}=this;return t?this.renderLocateWarning():s.selectedSuggestion?.location||e?this.renderNoResultsWarning(e):this.renderEmptySearchWarning()}_resetActiveMenuItemIndex(){this._activeMenuItemIndex=-1}_buildId(e,t){return`${this.id}-${e}${void 0===t?"":`-${t}`}`}_watchSourceChanges(){const{_handles:e,viewModel:{allSources:t}}=this,s="sources";e.remove(s),t.forEach((t=>e.add(i((()=>t.name),(()=>this.scheduleRender())),s)))}_handleSourcesMenuToggleFocus(){"source"!==this.activeMenu&&this._clearActiveMenu()}_handleSourcesMenuToggleClick(){const e="source"===this.activeMenu;this.activeMenu=e?"none":"source",this.renderNow(),"source"===this.activeMenu&&this._sourceListNode?.focus()}_handleClearButtonClick(){this.viewModel.clear(),this._focus()}_handleSearchButtonClick(){this.search()}_handleSuggestionClick(e){const t=e.currentTarget["data-suggestion"];t&&(this._focus(),this.search(t))}_handleUseCurrentLocationClick(){this._useCurrentLocation()}_useCurrentLocation(){this._focus("none"),this._cancelSuggest(),this._cancelSearch();const e=new AbortController,{signal:t}=e;this._searchController=e,this.viewModel.searchNearby({signal:t}).then((e=>{this.activeMenu=e.numResults?"none":"warning"})).catch((()=>{this._locateFailed=!0,this.activeMenu="warning"})).then((()=>{this._searchController=null}))}_handleSourceClick(e){this._setSourceFromMenuItem(e.currentTarget)}_setSourceFromMenuItem(e){if(!e)return;const t=e["data-source-index"];this.viewModel.activeSourceIndex=t,this._clearActiveMenu(),this._sourceMenuButtonNode?.focus()}_cancelSuggest(){this._suggestController&&(this._suggestController.abort(),this._suggestController=null)}_cancelSearch(){this._searchController&&(this._searchController.abort(),this._searchController=null),this._locateFailed=!1}_handleInputKeyup(e){const s=t(e);if(e.ctrlKey||e.metaKey||"Copy"===s||"ArrowLeft"===s||"ArrowRight"===s||"Shift"===s)return;if("Tab"===s||"Escape"===s||e.shiftKey&&"Tab"===s)return this._cancelSuggest(),void("Escape"===s&&this._clearActiveMenu());const i="Home"===s||"End"===s||"ArrowUp"===s||"ArrowDown"===s;if("Enter"===s&&this._activeMenuItemIndex<0)return void this._cancelSuggest();const r=this._suggestionListNode?.getElementsByTagName("li");if(r?.length){if("suggestion"!==this.activeMenu&&this._openSuggestionMenu(),i)return e.preventDefault(),this._cancelSuggest(),void this._handleItemNavigation(s,r,this._suggestionListNode);const t=r[this._activeMenuItemIndex];if("Enter"===s&&t){const e=t["data-suggestion"];return void(e?(this._focus(),this.search(e)):t["data-current-location-item"]&&this._useCurrentLocation())}}this.viewModel.searchTerm&&this.suggest()}_handleItemNavigation(e,t,s){const i=this._activeMenuItemIndex;"Home"===e&&(this._activeMenuItemIndex=0),"End"===e&&(this._activeMenuItemIndex=t.length-1),"ArrowUp"===e&&(this._activeMenuItemIndex=this._activeMenuItemIndex<=0?t.length-1:this._activeMenuItemIndex-1),"ArrowDown"===e&&(this._activeMenuItemIndex=this._activeMenuItemIndex===t.length-1?0:this._activeMenuItemIndex+1),i!==this._activeMenuItemIndex&&p(t[this._activeMenuItemIndex],s)}_scrollToTopSuggestion(){this._suggestionListNode&&(this._suggestionListNode.scrollTop=0)}_openSuggestionMenu(){this.activeMenu="suggestion"}_handleInputPaste(e){const t=e.target;this.viewModel.searchTerm!==t.value&&(this.viewModel.searchTerm=t.value),this.viewModel.searchTerm&&this.suggest()}_handleSourceMenuKeydown(e){const s=t(e);if(_(s)){e.preventDefault();const t=this._sourceListNode.getElementsByTagName("li")[this._activeMenuItemIndex];this._setSourceFromMenuItem(t)}else"ArrowUp"!==s&&"ArrowDown"!==s&&"End"!==s&&"Home"!==s||e.preventDefault()}_handleSourceMenuKeyup(e){const s=t(e),i="ArrowUp"===s||"ArrowDown"===s||"End"===s||"Home"===s;if(i&&e.preventDefault(),"Escape"===s)return this._clearActiveMenu(),void this._sourceMenuButtonNode?.focus();const r=this._sourceListNode?.getElementsByTagName("li");return r&&0!==r.length&&i?("source"!==this.activeMenu&&(this.activeMenu="source"),void this._handleItemNavigation(s,r,this._sourceListNode.parentElement)):void 0}_focus(e){this.focus(),e&&(this.activeMenu=e)}_formSubmit(e){e.preventDefault(),-1===this._activeMenuItemIndex&&this.search()}_getSourceName(e){const{messages:t}=this,s=this.viewModel,{allSources:i}=s,r=i.getItemAt(e);return e===d.ALL_INDEX?t.all:r&&r.name||t.untitledSource}_splitResult(e,t){const s=o(t);return e.replace(new RegExp(`(^|)(${s})(|$)`,"ig"),"$1|$2|$3").split("|")}_renderSearchResultsContent(){return this._searchResultRenderer.showMoreResultsOpen=!1,this._searchResultRenderer.viewModel=this.viewModel,this._searchResultRenderer}};e([u()],b.prototype,"_activeMenuItemIndex",void 0),e([u()],b.prototype,"displayedSearchTerm",null),e([u({readOnly:!0})],b.prototype,"inputId",null),e([u({readOnly:!0})],b.prototype,"suggestionsMenuId",null),e([u({readOnly:!0})],b.prototype,"sourceMenuId",null),e([u({readOnly:!0})],b.prototype,"sourceMenuButtonId",null),e([u()],b.prototype,"activeMenu",void 0),e([a("viewModel.activeSource")],b.prototype,"activeSource",void 0),e([a("viewModel.activeSourceIndex")],b.prototype,"activeSourceIndex",void 0),e([a("viewModel.allPlaceholder")],b.prototype,"allPlaceholder",void 0),e([a("viewModel.allSources")],b.prototype,"allSources",void 0),e([a("viewModel.autoNavigate")],b.prototype,"autoNavigate",void 0),e([a("viewModel.autoSelect")],b.prototype,"autoSelect",void 0),e([a("viewModel.defaultSources")],b.prototype,"defaultSources",void 0),e([u()],b.prototype,"disabled",void 0),e([a("viewModel.goToOverride")],b.prototype,"goToOverride",void 0),e([u()],b.prototype,"iconClass",void 0),e([a("viewModel.includeDefaultSources")],b.prototype,"includeDefaultSources",void 0),e([u({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],b.prototype,"label",void 0),e([a("viewModel.locationEnabled")],b.prototype,"locationEnabled",void 0),e([a("viewModel.maxResults")],b.prototype,"maxResults",void 0),e([a("viewModel.maxSuggestions")],b.prototype,"maxSuggestions",void 0),e([u(),m("esri/widgets/Search/t9n/Search")],b.prototype,"messages",void 0),e([u(),m("esri/t9n/common")],b.prototype,"messagesCommon",void 0),e([a("viewModel.minSuggestCharacters")],b.prototype,"minSuggestCharacters",void 0),e([a("viewModel.popupEnabled")],b.prototype,"popupEnabled",void 0),e([a("viewModel.popupTemplate")],b.prototype,"popupTemplate",void 0),e([a("viewModel.portal")],b.prototype,"portal",void 0),e([a("viewModel.resultGraphic")],b.prototype,"resultGraphic",void 0),e([a("viewModel.resultGraphicEnabled")],b.prototype,"resultGraphicEnabled",void 0),e([a("viewModel.results")],b.prototype,"results",void 0),e([a("viewModel.searchAllEnabled")],b.prototype,"searchAllEnabled",void 0),e([a("viewModel.searchTerm")],b.prototype,"searchTerm",void 0),e([a("viewModel.selectedResult")],b.prototype,"selectedResult",void 0),e([a("viewModel.sources")],b.prototype,"sources",void 0),e([a("viewModel.suggestions")],b.prototype,"suggestions",void 0),e([a("viewModel.suggestionsEnabled")],b.prototype,"suggestionsEnabled",void 0),e([a("viewModel.view")],b.prototype,"view",void 0),e([v(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),u({type:d})],b.prototype,"viewModel",void 0),e([a("viewModel.clear")],b.prototype,"clear",null),b=e([l("esri.widgets.Search")],b);const y=b;export{y as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import i from"../../core/Accessor.js";import"../../core/has.js";import r from"../../core/Handles.js";import{abortMaybe as s,destroyMaybe as o,isSome as n,unwrapOr as a,isNone as l,mapOr as p,applySome as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import i from"../../core/Accessor.js";import"../../core/has.js";import r from"../../core/Handles.js";import{abortMaybe as s,destroyMaybe as o,isSome as n,unwrapOr as a,isNone as l,mapOr as p,applySome as d}from"../../core/maybe.js";import{createTask as u,after as c,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{createScreenPointArray as _,createRenderScreenPointArray as w}from"../../core/screenUtils.js";import{convertTime as v,offsetDateUTC as y}from"../../core/timeUtils.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{c as D}from"../../chunks/vec3f64.js";import{longitudeToTimezone as P}from"../../views/3d/support/earthUtils.js";import{computeDirectionsOverTime as b}from"../../views/3d/support/sunUtils.js";import{ShadowCastVisualization as O}from"../../views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js";import V from"./DiscreteOptions.js";import{DurationMode as j}from"./DurationMode.js";import z from"./DurationOptions.js";import{ShadowCastState as C}from"./ShadowCastState.js";import{ShadowTooltipViewModel as U}from"./ShadowTooltipViewModel.js";import{ShadowVisualizationType as E}from"./ShadowVisualizationType.js";import S from"./ThresholdOptions.js";import{breadthFirstBinaryPartitioning as R}from"../support/traversalUtils.js";const A=[],N=D(),x=[],M=255,k=v(1,"hours","milliseconds"),F=500;let G=class extends i{constructor(e){super(e),this.view=null,this.tooltip=new U({getDuration:(e,t)=>this.getDuration(e,t)}),this.startTimeOfDay=v(10,"hours","milliseconds"),this.endTimeOfDay=v(16,"hours","milliseconds"),this.visualizationType=E.Threshold,this.thresholdOptions=new S,this.durationOptions=new z,this.discreteOptions=new V,this._running=!0,this._handles=new r,this._stopPreviewingTask=null,this._forcePreview=null,this._autoRestoreForcePreviewEnabled=!0,this._utcOffset=null,this.date=new Date}initialize(){this._handles.add([m((()=>({view:this.view,tooltipEnabled:this._tooltipEnabled})),(({view:e,tooltipEnabled:t})=>{this.tooltip.view=e,this.tooltip.enabled=t}),f),m((()=>this._forcePreviewDependencies),(()=>{s(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=u((async e=>{await c(F,e),h(e),this._forcePreview=!1})))}),f),m((()=>({renderView:this.renderView,parameters:this._visualizationParameters})),B,f),m((()=>({renderView:this.renderView,parameters:{lightDirections:this._lightDirections}})),B,f),m((()=>({renderView:this.renderView,parameters:{enabled:this._running}})),B,f),m((()=>({renderView:this.renderView,parameters:{previewing:this._previewing}})),B,f)])}destroy(){this.stop(),this._handles=o(this._handles),o(this.tooltip)}get state(){return n(this.view)&&this.view.ready&&n(this._referencePosition)?C.Ready:C.Disabled}set date(e){const t=new Date(e);t.setHours(0,0,0,0),this._set("date",t)}get utcOffset(){return a(this._utcOffset,this._utcOffsetAuto)}set utcOffset(e){this._utcOffset=e}get testData(){return{setAutoRestoreForcedPreviewEnabled:e=>{this._autoRestoreForcePreviewEnabled=e},setForcedPreview:e=>{this._forcePreview=e},isPreviewing:()=>this._previewing}}get _previewing(){const{view:e}=this;return!(!l(e)&&!l(e.allLayerViews))||(this._forcePreview||!e.stationary||e.allLayerViews.some((e=>H(e)&&e.updating)))}get _utcOffsetAuto(){const e=this._referencePosition;return p(e,0,(e=>P(e[0],!1)))}get _dateUTCOffset(){let e=this.date;return e=y(e,-e.getTimezoneOffset(),"minutes"),e=y(e,-this.utcOffset,"hours"),e}get _startDateTimeUTC(){return y(this._dateUTCOffset,this.startTimeOfDay)}get _endDateTimeUTC(){return y(this._dateUTCOffset,this.endTimeOfDay)}get _referencePosition(){return d(this.view,(e=>d(e.environmentManager,(e=>e.referencePositionWGS84Comparable))))}get _interval(){const e=this._duration>0?Math.floor(this._duration/M):M,t=this.discreteOptions.interval;switch(this.visualizationType){case E.Threshold:case E.Duration:return e;case E.Discrete:return t>0?t:e}}get _sampleCount(){return this._lightDirections.length}get _duration(){return this.endTimeOfDay-this.startTimeOfDay}get _lightDirections(){const{view:e}=this;if(l(e))return A;const t="global"===e.viewingMode?N:this._referencePosition;if(l(t))return A;const i=this._interval,r=b(this._startDateTimeUTC,this._endDateTimeUTC,i,t,e.state.viewingMode),s=r.length;x.length=0;const o=R(0,s,x),n=new Array(s);for(let a=0;a<s;++a)n[a]=r[o[a]];return n}get _tooltipEnabled(){return this.state===C.Ready&&this.visualizationType!==E.Discrete&&this._running&&!this._previewing}get _visualizationParameters(){if(!this._running)return null;switch(this.visualizationType){case E.Threshold:return this._thresholdVisualizationParameters;case E.Duration:return this._durationVisualizationParameters;case E.Discrete:return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{value:e,color:i}=this.thresholdOptions,r=this._duration;return{visualization:O.Threshold,color:t.toUnitRGBA(i),threshold:r>0?e/this._duration:0}}get _durationVisualizationParameters(){const{color:e,mode:i}=this.durationOptions,r=this._duration,s=r>0&&i===j.Hourly?k/r:0;return{color:t.toUnitRGBA(e),visualization:O.Gradient,bandsEnabled:s>0,bandSize:s}}get _discreteVisualizationParameters(){return{color:t.toUnitRGBA(this.discreteOptions.color),visualization:O.Gradient,bandsEnabled:!1,bandSize:0}}get _forcePreviewDependencies(){const{view:e}=this;if(l(e))return null;const t=e.slicePlane,i=e.allLayerViews.toArray().filter(H),r=i.map((e=>e.layer)).filter(n),s=i.map((e=>e.visible)),o=r.map((e=>e.visible)),a=r.map((e=>e.opacity)),p=r.filter((e=>"definitionExpression"in e)).map((e=>e.definitionExpression)),d=i.filter((e=>"filter"in e)).map((e=>e.filter));return{slicePlane:t,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewVisibilities:s,layerVisibilities:o,layerOpacities:a,filters:d,definitionExpressions:p}}get renderView(){const{view:e}=this;if(l(e))return null;const t=e._stage;return l(t)?null:t.renderView}start(){this._running=!0}stop(){this._running=!1}setRunning(e){this._running=e}async getDuration(e,t){const{view:i,renderView:r}=this;if(l(i)||l(r))return 0;const s=i.state.camera.screenToRender(_(e.x,e.y),w()),o=r.readAccumulatedShadow(s),n=this._sampleCount;if(0===n)return 0;return o*n*(this._duration/n)}};function B({renderView:e,parameters:t}){n(e)&&n(t)&&e.setRenderParameters({shadowCastOptions:t})}function H(e){if(e.suspended)return!1;switch(e.type){case"analysis-3d":case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":return!0;case"base-dynamic-3d":case"imagery-3d":case"imagery-tile-3d":case"map-image-3d":case"point-cloud-3d":case"tile-3d":case"vector-tile-3d":case"voxel-3d":case"wfs-3d":case"wmts-3d":case"media-3d":default:return!1;case"group":return e.layerViews.toArray().some((e=>H(e)))}}e([g()],G.prototype,"state",null),e([g()],G.prototype,"view",void 0),e([g()],G.prototype,"tooltip",void 0),e([g({nonNullable:!0})],G.prototype,"date",null),e([g({nonNullable:!0})],G.prototype,"utcOffset",null),e([g({nonNullable:!0})],G.prototype,"startTimeOfDay",void 0),e([g({nonNullable:!0})],G.prototype,"endTimeOfDay",void 0),e([g({nonNullable:!0})],G.prototype,"visualizationType",void 0),e([g({type:S,nonNullable:!0})],G.prototype,"thresholdOptions",void 0),e([g({type:z,nonNullable:!0})],G.prototype,"durationOptions",void 0),e([g({type:V,nonNullable:!0})],G.prototype,"discreteOptions",void 0),e([g()],G.prototype,"_running",void 0),e([g()],G.prototype,"_handles",void 0),e([g()],G.prototype,"_stopPreviewingTask",void 0),e([g()],G.prototype,"_forcePreview",void 0),e([g()],G.prototype,"_autoRestoreForcePreviewEnabled",void 0),e([g()],G.prototype,"_previewing",null),e([g()],G.prototype,"_utcOffset",void 0),e([g()],G.prototype,"_utcOffsetAuto",null),e([g()],G.prototype,"_dateUTCOffset",null),e([g()],G.prototype,"_startDateTimeUTC",null),e([g()],G.prototype,"_endDateTimeUTC",null),e([g()],G.prototype,"_referencePosition",null),e([g()],G.prototype,"_interval",null),e([g()],G.prototype,"_sampleCount",null),e([g()],G.prototype,"_duration",null),e([g()],G.prototype,"_lightDirections",null),e([g()],G.prototype,"_tooltipEnabled",null),e([g()],G.prototype,"_visualizationParameters",null),e([g()],G.prototype,"_thresholdVisualizationParameters",null),e([g()],G.prototype,"_durationVisualizationParameters",null),e([g()],G.prototype,"_discreteVisualizationParameters",null),e([g()],G.prototype,"_forcePreviewDependencies",null),e([g()],G.prototype,"renderView",null),G=e([T("esri.widgets.ShadowCast.ShadowCastViewModel")],G);const L=G;export{L as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{symbolTypes as t}from"../../symbols.js";import o from"../../core/Collection.js";import"../../core/has.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import r from"../../core/Handles.js";import s from"../../core/Logger.js";import{destroyMaybe as n,isSome as p,unwrap as l,abortMaybe as h,isNone as c,unwrapOr as d,get as u}from"../../core/maybe.js";import{createAbortError as y,whenOrAbort as m}from"../../core/promiseUtils.js";import{on as v,watch as g,when as f,whenOnce as _,syncAndInitial as w}from"../../core/reactiveUtils.js";import{property as G}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as T,isLoaded as E,load as O,project as S}from"../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../geometry/projectionEllipsoid.js";import{geometryToCoordinates as k}from"../../geometry/support/coordsUtils.js";import{equals as C}from"../../geometry/support/spatialReferenceUtils.js";import H from"../../layers/GraphicsLayer.js";import{isDOMContainer as I}from"../../views/DOMContainer.js";import{SupportedGraphicResult as R,isSupportedGraphicResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedGraphicUtils.js";import{isSupportedGraphic as M}from"../../views/3d/interactive/editingTools/moveGraphic/isSupportedGraphic.js";import{isSupportedGraphic as U}from"../../views/3d/interactive/editingTools/reshapeGraphic/isSupportedGraphic.js";import{isSupportedGraphic as P}from"../../views/3d/interactive/editingTools/transformGraphic/isSupportedGraphic.js";import{addUniqueLayer as x}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as j}from"../../views/input/InputManager.js";import{SKETCH_KEYS as L}from"../../views/interactive/keybindings.js";import{SnappingManager as F}from"../../views/interactive/snapping/SnappingManager.js";import V from"../../views/interactive/snapping/SnappingOptions.js";import{TooltipOptions as W}from"../../views/interactive/tooltip/TooltipOptions.js";import{createScreenPointFromEvent as K}from"../../views/support/screenUtils.js";import{OperationHandle as q,UpdateOperationHandle as Z}from"./support/OperationHandle.js";import z from"../../symbols/SimpleMarkerSymbol.js";import N from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";const $="esri.widgets.Sketch.SketchViewModel",Y=s.getLogger($),J={defaultZ:0},Q={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,tool:"transform"};let X=class extends a.EventedAccessor{constructor(e){super(e),this._numUpdating=0,this._handles=new r,this._internalGraphicsLayer=new H({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandles=new r,this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new N({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new B({color:[130,130,130,1],width:2}),this._snappingManager=null,this.tooltipOptions=new W,this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.updatePointSymbol=new z({size:10,color:[0,200,255,.5],outline:{color:"black",width:1}}),this.updatePolygonSymbol=new N({color:[12,207,255,.2],outline:{join:"round",color:[12,207,255],width:2}}),this.updatePolylineSymbol=new B({color:[12,207,255],width:2}),this.vertexSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._originalAutoOpenEnabled=null,this.defaultCreateOptions=J,this.defaultUpdateOptions=Q,this.snappingOptions=new V}initialize(){this._handles.add([v((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),v((()=>this.layer?.graphics),"change",(e=>{if(p(this._operationHandle))for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),g((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),w),g((()=>this.view),(e=>{n(this._snappingManager),e&&(this._snappingManager=new F({view:e,options:this.snappingOptions}),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),w),g((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))])}destroy(){this.cancel(),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeDefaultLayer(),this._snappingManager=n(this._snappingManager),this._set("view",null),this.emit("destroy")}get _defaultUpdateTool(){return"3d"===this.view.type?"move":"transform"}get updating(){return this._numUpdating>0}get activeTool(){return this._operationHandle&&this._operationHandle.tool?this._operationHandle.tool:null}get activeComponent(){return this._operationHandle?this._operationHandle.activeComponent:null}get createGraphic(){return!p(this.activeComponent)||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):l(this.activeComponent.graphic)}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...J,...e})}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Q,...e,reshapeOptions:{...Q.reshapeOptions,...e?.reshapeOptions}})}set snappingOptions(e){p(this._snappingManager)&&(this._snappingManager.options=e),this._set("snappingOptions",e)}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&(t.cursor=null),o&&o.remove(this._internalGraphicsLayer),this._viewHandles.removeAll(),this.cancel()}const o="view-ready";this._handles.remove(o),e&&this._handles.add(f((()=>e.ready),(t=>{this._viewHandles.removeAll(),t&&this._viewHandles.add(this._generateViewHandles(e))}),w),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}async create(e,t){if(this.cancel(),await this._waitViewReady(),"disabled"===this.state)throw this.layer||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),this.view||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),y();if(p(this.view.activeTool)&&(this.view.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");x(this.view,this._internalGraphicsLayer);const o=await this._setupCreateOperation(e,t);if(c(o)||this.destroyed)return void this.view.map.remove(this._internalGraphicsLayer);const i=()=>{if(o===this._operationHandle){const t=this.createGraphic,i=this._operationHandle.cancelled;this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),o.cancelled||null==t||this.layer.add(t),this.emit("create",{graphic:t,state:i?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"})}};o.on("complete",i),this._operationHandle=o,this.view.ready&&I(this.view)&&this.view.focus()}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if("disabled"===a)throw i||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),o||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),y();p(this.view.activeTool)&&(this.view.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r||!r.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):!!c(e.geometry)&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const s=await this._setupUpdateOperation(r,t);this.destroyed||c(s)||re(s)||(x(this.view,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){this._beginAsyncOperation(),e=Array.isArray(e)?e:[e];for(const t of e)p(t.geometry)&&"mesh"!==t.geometry.type&&!C(t.geometry.spatialReference,this.view.spatialReference)&&(T(t.geometry.spatialReference,this.view.spatialReference)||E()||await O(),t.geometry=S(t.geometry,this.view.spatialReference));this._endAsyncOperation()}undo(){this.canUndo()&&this._operationHandle.undo()}redo(){this.canRedo()&&this._operationHandle.redo()}canUndo(){return!(!this._operationHandle||!this._operationHandle.canUndo())}canRedo(){return!(!this._operationHandle||!this._operationHandle.canRedo())}toggleUpdateTool(){this._operationHandle&&this._operationHandle.toggleTool&&this._operationHandle.toggleTool()}async _getFirstHit(e){const t=[];switch(this.view.type){case"2d":{const o=[];this.view.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)}));const i=await this.view.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];e.graphic&&t.push(e)}}break;case"3d":{const o=[this.view.map.ground];this.view.map.allLayers.forEach((e=>{"integrated-mesh"===e.type&&o.push(e)}));const i=await this.view.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];(!i.ground.mapPoint||this.view.map.ground.opacity<1||i.ground.distance-d(e.distance,0)>-Math.min(3*i.ground.distance,"global"===this.view.viewingMode?A(this.view.renderCoordsHelper.spatialReference).radius/this.view.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY))&&t.push(e)}}}return{screenPoint:e,results:t}}_generateViewHandles(e){return[e.on("immediate-click",(async t=>{const o="active"===this.state&&"create"===this._operationHandle.type;if("disabled"===this.state||o||!this.updateOnGraphicClick)return;this._beginAsyncOperation();const i=(await t.async((()=>this._getFirstHit(K(t))))).results;let a=null;if(i.length){for(const r of i)if(r.graphic){const o=r.graphic;if(this.updateGraphics.includes(o)||o.layer===this.layer){t.stopPropagation(),a=o;break}"2d"!==e.type||this._isComponentGraphic(o)||"active"!==this.state||this.cancel()}}else"active"===this.state&&this.cancel();p(a)&&!this.updateGraphics.includes(a)&&await this.update([a],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}}),this._endAsyncOperation()}),j.WIDGET)]}async _setupCreateOperation(e,t){const o={hasZ:"3d"===this.view.type,...this.defaultCreateOptions,...t},i=await this._setupDrawGraphicTool(e,this.view,o);return c(i)?null:(this.view.tools.add(i),this.view.activeTool=i,this._setupCreateOperationHandle(i))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView"),null;const i="rectangle"!==e,a="rectangle"!==e;this.snappingOptions.enabledToggled=!1;const r={view:t,mode:"rectangle"===e||"circle"===e?"hybrid":"click",...o,snapToScene:!1,geometryType:e,graphicSymbol:this._getGraphicSymbolFromTool(e),snappingManager:this._snappingManager,forceUniformSize:a,centered:i};return"2d"===this.view.type?this._makeDrawGraphicTool2D(r):this._makeDrawGraphicTool3D(r)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return re(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ee(e.geometryType)?this.activeFillSymbol:null})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return re(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this.layer.elevationInfo,snapToScene:!p(this.layer.elevationInfo)||"absolute-height"===this.layer.elevationInfo.mode})}_setupCreateOperationHandle(e){let t=null;const o=e.forceUniformSize,i=e.centered,a=[this.view.on("key-down",(t=>{if(t.key===L.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===L.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==L.vertexAdd||t.repeat)t.key===L.undo?(t.stopPropagation(),r.undo()):t.key===L.redo?(t.stopPropagation(),r.redo()):t.key!==L.snappingToggle||"rectangle"===e.geometryType||"circle"===e.geometryType||t.repeat?t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===L.center&&(t.repeat||(e.centered=!i,t.stopPropagation())):(e.forceUniformSize=!o,t.stopPropagation()):(this.snappingOptions.enabledToggled=!0,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),j.WIDGET),this.view.on("key-up",(t=>{t.key===L.pan?e.enabled=!0:t.key===L.snappingToggle&&"rectangle"!==e.geometryType&&"circle"!==e.geometryType?(this.snappingOptions.enabledToggled=!1,t.stopPropagation()):t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===L.center&&(e.centered=i,t.stopPropagation()):(e.forceUniformSize=o,t.stopPropagation())}),j.WIDGET),e.on("vertex-add",(o=>{switch(t=c(t)?"start":"active",o.operation){case"apply":this.emit("create",{graphic:l(e.graphic),state:t,tool:this.activeTool,toolEventInfo:o,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("cursor-update",(t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:l(e.graphic),state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})})),e.on("vertex-remove",(t=>{switch(t.operation){case"apply":this.emit("create",{graphic:l(e.graphic),state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("complete",(e=>{this._set("createGraphic",l(e.graphic)),t="complete",e.aborted?r&&r.cancel():r&&r.complete()})),g((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],r=new q({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{a.forEach((e=>e.remove())),a.length=0,this.view.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":return this.polygonSymbol;default:return null}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this,a={tool:this._defaultUpdateTool,...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions}};let r=a.tool;for(const s of e)o.remove(s),o.add(s);if("3d"===i.type){if(0===e.length)return null;switch(r){case"move":return this._setupMove3DOperation(e,a,i,r);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupReshape3DOperation(e[0],a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(r){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupTransformOrReshape2DOperation(e,r,a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":if(1===e.length){const t=u(e[0].geometry,"type");"point"!==t&&"multipoint"!==t||(r="reshape")}return this._setupTransformOrReshape2DOperation(e,r,a,i)}}async _setupMove3DOperation(e,t,o,i,a=!1){for(const l of e){const e=M(l);if(e!==R.SUPPORTED)return this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${D(e)}).`),null}const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(r))return r;const s=new r.module.GraphicMoveTool({view:o,enableZ:t.enableZ,snappingManager:this._snappingManager});this.view.tools.add(s),s.graphics.addMany(e),a||this.updateGraphics.addMany(e);const n=[],p=new Z({activeComponent:s,tool:i,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},undo:()=>{te(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e),s.graphics.push(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);p.history.undo.forEach((e=>e.updates.splice(t,1))),p.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?s.graphics.remove(e):p.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const a=await this._setupReshape3DOperation(e,t,o,!0);re(a)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(a,t))}});return n.push(...this._getHandlesForComponent(p,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&P(e[0])===R.SUPPORTED){const a=e[0],r=a.geometry;if(p(r)&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(p(r)&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,n=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(n))return n;const p=new n.module.GraphicTransformTool({graphic:e,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this._snappingManager});this.view.tools.add(p),this.updateGraphics.add(e);const l=[],h=new Z({activeComponent:p,tool:i,type:"update",onEnd:()=>{l.forEach((e=>e.remove())),l.length=0,this.view.tools?.remove(p),p.destroyed||p.destroy()},undo:()=>{te(h,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(h,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(h.onEnd(),h.destroy(),this._setUpdateOperationHandle(i,t))},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),h.complete()},toggleTool:()=>{}});return l.push(...this._getHandlesForComponent(h,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(h,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(h,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),h}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p}=t,l=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(l))return l;const h=new l.module.ExtentTransformTool({graphic:e,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p});this.view.tools.add(h),i||this.updateGraphics.add(e);const c=[],d=new Z({activeComponent:h,tool:a,type:"update",onEnd:()=>{c.forEach((e=>e.remove())),c.length=0,this.view.tools?.remove(h),h.destroyed||h.destroy()},canUndo:()=>h.canUndo,undo:()=>{h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>h.canRedo,redo:()=>{h.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(d.onEnd(),d.destroy(),this._setUpdateOperationHandle(i,t))},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),d.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const i=await this._setupReshape3DOperation(e,t,o,!0);re(i)||(d.onEnd(),d.destroy(),this._setUpdateOperationHandle(i,t))}});return c.push(...this._getHandlesForComponent(d,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(d,e,t)),j.WIDGET),this.view.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(d,e)),j.WIDGET),this.view.on("key-down",(e=>{e.key!==L.constraint||e.repeat||(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET),this.view.on("key-up",(e=>{e.key===L.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET)),d}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a=await this._getGraphicMover(e,t,o);if(re(a))return a;const r=new Z({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),p.forEach((e=>e.remove())),n.forEach((e=>e.remove())),p=[],n=[],a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();te(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();oe(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updateSpatialReference(e),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach((e=>e.updates.splice(t,1))),r.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1,n=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==L.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),j.WIDGET),o.on("key-up",(e=>{e.key===L.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),j.WIDGET)],p=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(r))return r;this.snappingOptions.enabledToggled=!1;const s=new r.module.GraphicReshapeTool({view:o,graphic:e,enableZVertex:t.enableZ&&"move"===t.reshapeOptions.vertexOperation,enableZShape:t.enableZ&&"move"===t.reshapeOptions.shapeOperation,enableMoveGraphic:"move"===t.reshapeOptions.shapeOperation||"move-xy"===t.reshapeOptions.shapeOperation,enableMidpoints:"split"===t.reshapeOptions.edgeOperation,enableEdgeOffset:"offset"===t.reshapeOptions.edgeOperation,snappingManager:this._snappingManager});o.tools.add(s),i||this.updateGraphics.add(e);const n=[],p=new Z({activeComponent:s,tool:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},canUndo:()=>s.canUndo,undo:()=>{s.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>s.canRedo,redo:()=>{s.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(i,t))},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),p.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);re(e)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(e,t))}});return n.push(...this._getHandlesForComponent(p,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(re(a))return a;const r=new Z({activeComponent:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),s.forEach((e=>e.remove())),n=[],s=[],r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{te(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{oe(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll();const a=await this._setupMove2DOperation(t,o,i);if(re(a))return;r.onEnd(),r.destroy(),this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach((e=>e.updates.splice(t,1))),r.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();if(0===o.length)r.complete();else{const e=o[0].geometry;1!==o.length||!p(e)||"point"!==e.type&&"multipoint"!==e.type?r.activeComponent.graphics=o:r.toggleTool()}this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.getItemAt(0),t=e.geometry;if(p(t)&&("reshape"===r.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._getReshape([e],o,i):"reshape"===r.tool&&(a=await this._getBox([e],o,i)),re(a)||(r.activeComponent.destroy(),r.activeComponent=a,r.activeComponent&&(n.forEach((e=>e.remove())),n=this._getHandlesForComponent(r,o)))}});let s=[i.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,o)),j.WIDGET),i.on("key-down",(e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==L.snappingToggle||e.repeat||(this.snappingOptions.enabledToggled=!0,e.stopPropagation()),e.key===L.constraint&&!e.repeat&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET),i.on("key-up",(e=>{if(e.key===L.snappingToggle&&"reshape"===r?.activeComponent?.type&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation()),e.key===L.constraint&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET)],n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i}=t,a=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return re(a)?a:new a.module.default({enableMoveAllGraphics:i,highlightsEnabled:!0,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayPointerCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,preserveAspectRatio:r}=t,s=await this._requireModule(import("../../views/draw/support/Box.js"));return re(s)?s:new s.module.default({graphics:e,enableRotation:i,enableScaling:a,preserveAspectRatio:r,layer:this._internalGraphicsLayer,view:o,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,r=await this._requireModule(import("../../views/draw/support/Reshape.js"));return re(r)?r:new r.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],layer:this._internalGraphicsLayer,snappingManager:this._snappingManager,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map((e=>k(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map((e=>k(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;switch(o.type){case"graphic-mover":return[o.on("graphic-click",(({graphic:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ae(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ae(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ae([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ae([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ae([t.oldGraphic]))))];case"move-3d":return[o.on("graphic-move-start",(t=>{e.addToHistory(ae(t.allGraphics)),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:t.allGraphics.length>0?t.allGraphics[0]:null,type:"move-start"},type:"update"})})),o.on("graphic-move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.allGraphics.length>0?e.allGraphics[0]:null,type:"move"},type:"update"})})),o.on("graphic-move-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.allGraphics.length>0?e.allGraphics[0]:null,type:"move-stop"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"transform-3d":return[o.on("record-undo",(({record:t})=>{e.addToHistory({updates:[t]})})),o.on("graphic-translate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})})),o.on("graphic-translate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})})),o.on("graphic-rotate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-start"},type:"update"})})),o.on("graphic-rotate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})})),o.on("graphic-scale-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})})),o.on("graphic-scale-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})})),o.on("graphic-translate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})})),o.on("graphic-rotate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate"},type:"update"})})),o.on("graphic-scale",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"reshape-3d":return[o.on("reshape",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-add",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-remove",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];default:return}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&i.layer===this.layer?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=K(t),a=(await t.async((()=>this._getFirstHit(i)))).results;if(!a.length)return void e.complete();if(t.native.shiftKey&&this._toggleSelection(a.map((e=>e.graphic)),e,o))return void t.stopPropagation();a.some((e=>e.graphic&&this.updateGraphics.includes(e.graphic)))?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some((e=>null!=e&&(!(!i||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===L.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===L.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===L.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&L.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();c(t)||"reshape-3d"===t.type||("reshape"!==t.type||1===o.length&&"point"===u(o[0].geometry,"type"))&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=n(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||c(t))&&(e.attributes&&e.attributes.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_displayPointerCursor(){this.view&&this.view.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view&&this.view.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view&&this.view.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,o){Y.error(new i(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}test(){return{operationHandle:this._operationHandle,defaultUpdateOptions:Q}}wait(){return _((()=>!this.updating))}_beginAsyncOperation(){this._numUpdating+=1,this.notifyChange("updating")}_endAsyncOperation(){this._numUpdating-=1,this.notifyChange("updating")}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||p(e)&&e.toggleToolOnClick}_disablePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&c(this._originalAutoOpenEnabled)&&(this._originalAutoOpenEnabled=t.autoOpenEnabled,t.autoOpenEnabled=!1)}_restorePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&p(this._originalAutoOpenEnabled)&&(t.autoOpenEnabled=this._originalAutoOpenEnabled,this._originalAutoOpenEnabled=null)}async _waitViewReady(){const e=this.view;e&&(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_((()=>e?.ready)),this._viewReadyAbortController.signal))}};function ee(e){return"polygon"===e||"rectangle"===e||"circle"===e}function te(e,t){ie("undo",e.history.undo,e.history.redo,t)}function oe(e,t){ie("redo",e.history.redo,e.history.undo,t)}function ie(e,t,o,i){const a=t.pop().updates,r=[];i.forEach(((t,o)=>{const i=a[o];null!=i&&("geometry"in i&&p(i.geometry)&&(r.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&p(i.symbol)&&(r.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(r.push(i),i[e](t)))})),o.push({updates:r})}function ae(e){return{updates:e.map((e=>({geometry:e.geometry})))}}function re(e){return"requireError"in e&&"aborted"===e.requireError}e([G()],X.prototype,"updating",null),e([G()],X.prototype,"_operationHandle",void 0),e([G({readOnly:!0})],X.prototype,"activeTool",null),e([G()],X.prototype,"activeFillSymbol",void 0),e([G()],X.prototype,"activeLineSymbol",void 0),e([G()],X.prototype,"activeVertexSymbol",void 0),e([G()],X.prototype,"allowDeleteKey",void 0),e([G({readOnly:!0})],X.prototype,"createGraphic",null),e([G()],X.prototype,"defaultCreateOptions",null),e([G()],X.prototype,"defaultUpdateOptions",null),e([G()],X.prototype,"layer",void 0),e([G({types:t})],X.prototype,"pointSymbol",void 0),e([G({types:t})],X.prototype,"polygonSymbol",void 0),e([G({types:t})],X.prototype,"polylineSymbol",void 0),e([G({type:V,nonNullable:!0})],X.prototype,"snappingOptions",null),e([G()],X.prototype,"_snappingManager",void 0),e([G({readOnly:!0})],X.prototype,"state",null),e([G({nonNullable:!0})],X.prototype,"tooltipOptions",void 0),e([G({readOnly:!0})],X.prototype,"updateGraphics",void 0),e([G()],X.prototype,"updateOnGraphicClick",void 0),e([G({types:t})],X.prototype,"updatePointSymbol",void 0),e([G({types:t})],X.prototype,"updatePolygonSymbol",void 0),e([G({types:t})],X.prototype,"updatePolylineSymbol",void 0),e([G({types:t})],X.prototype,"vertexSymbol",void 0),e([G({value:null})],X.prototype,"view",null),X=e([b($)],X);const se=X;export{se as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{symbolTypes as t}from"../../symbols.js";import o from"../../core/Collection.js";import"../../core/has.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import r from"../../core/Handles.js";import s from"../../core/Logger.js";import{destroyMaybe as n,isSome as p,unwrap as l,abortMaybe as h,isNone as c,unwrapOr as d,get as u}from"../../core/maybe.js";import{createAbortError as y,whenOrAbort as m}from"../../core/promiseUtils.js";import{on as v,watch as g,when as f,whenOnce as _,syncAndInitial as w}from"../../core/reactiveUtils.js";import{property as G}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as T,isLoaded as E,load as O,project as S}from"../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../geometry/projectionEllipsoid.js";import{geometryToCoordinates as k}from"../../geometry/support/coordsUtils.js";import{equals as C}from"../../geometry/support/spatialReferenceUtils.js";import H from"../../layers/GraphicsLayer.js";import{isDOMContainer as I}from"../../views/DOMContainer.js";import{SupportedGraphicResult as R,isSupportedGraphicResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedGraphicUtils.js";import{isSupportedGraphic as M}from"../../views/3d/interactive/editingTools/moveGraphic/isSupportedGraphic.js";import{isSupportedGraphic as U}from"../../views/3d/interactive/editingTools/reshapeGraphic/isSupportedGraphic.js";import{isSupportedGraphic as P}from"../../views/3d/interactive/editingTools/transformGraphic/isSupportedGraphic.js";import{addUniqueLayer as x}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as j}from"../../views/input/InputManager.js";import{SKETCH_KEYS as L}from"../../views/interactive/keybindings.js";import{SnappingManager as F}from"../../views/interactive/snapping/SnappingManager.js";import V from"../../views/interactive/snapping/SnappingOptions.js";import{TooltipOptions as W}from"../../views/interactive/tooltip/TooltipOptions.js";import{createScreenPointFromEvent as K}from"../../views/support/screenUtils.js";import{OperationHandle as q,UpdateOperationHandle as Z}from"./support/OperationHandle.js";import z from"../../symbols/SimpleMarkerSymbol.js";import N from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";const $="esri.widgets.Sketch.SketchViewModel",Y=s.getLogger($),J={defaultZ:0},Q={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,tool:"transform"};let X=class extends a.EventedAccessor{constructor(e){super(e),this._numUpdating=0,this._handles=new r,this._internalGraphicsLayer=new H({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandles=new r,this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new N({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new B({color:[130,130,130,1],width:2}),this._snappingManager=null,this.tooltipOptions=new W,this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.updatePointSymbol=new z({size:10,color:[0,200,255,.5],outline:{color:"black",width:1}}),this.updatePolygonSymbol=new N({color:[12,207,255,.2],outline:{join:"round",color:[12,207,255],width:2}}),this.updatePolylineSymbol=new B({color:[12,207,255],width:2}),this.vertexSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._originalAutoOpenEnabled=null,this.defaultCreateOptions=J,this.defaultUpdateOptions=Q,this.snappingOptions=new V}initialize(){this._handles.add([v((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),v((()=>this.layer?.graphics),"change",(e=>{if(p(this._operationHandle))for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),g((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),w),g((()=>this.view),(e=>{n(this._snappingManager),e&&(this._snappingManager=new F({view:e,options:this.snappingOptions}),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),w),g((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))])}destroy(){this.cancel(),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeDefaultLayer(),this._snappingManager=n(this._snappingManager),this._set("view",null),this.emit("destroy")}get _defaultUpdateTool(){return"3d"===this.view.type?"move":"transform"}get updating(){return this._numUpdating>0}get activeTool(){return this._operationHandle&&this._operationHandle.tool?this._operationHandle.tool:null}get activeComponent(){return this._operationHandle?this._operationHandle.activeComponent:null}get createGraphic(){return!p(this.activeComponent)||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):l(this.activeComponent.graphic)}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...J,...e})}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Q,...e,reshapeOptions:{...Q.reshapeOptions,...e?.reshapeOptions}})}set snappingOptions(e){p(this._snappingManager)&&(this._snappingManager.options=e),this._set("snappingOptions",e)}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&(t.cursor=null),o&&o.remove(this._internalGraphicsLayer),this._viewHandles.removeAll(),this.cancel()}const o="view-ready";this._handles.remove(o),e&&this._handles.add(f((()=>e.ready),(t=>{this._viewHandles.removeAll(),t&&this._viewHandles.add(this._generateViewHandles(e))}),w),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}async create(e,t){if(this.cancel(),await this._waitViewReady(),"disabled"===this.state)throw this.layer||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),this.view||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),y();if(p(this.view.activeTool)&&(this.view.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");x(this.view,this._internalGraphicsLayer);const o=await this._setupCreateOperation(e,t);if(c(o)||this.destroyed)return void this.view.map.remove(this._internalGraphicsLayer);const i=()=>{if(o===this._operationHandle){const t=this.createGraphic,i=this._operationHandle.cancelled;this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),o.cancelled||null==t||this.layer.add(t),this.emit("create",{graphic:t,state:i?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"})}};o.on("complete",i),this._operationHandle=o,this.view.ready&&I(this.view)&&this.view.focus()}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if("disabled"===a)throw i||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),o||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),y();p(this.view.activeTool)&&(this.view.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r||!r.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):!!c(e.geometry)&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const s=await this._setupUpdateOperation(r,t);this.destroyed||c(s)||re(s)||(x(this.view,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){this._beginAsyncOperation(),e=Array.isArray(e)?e:[e];for(const t of e)p(t.geometry)&&"mesh"!==t.geometry.type&&!C(t.geometry.spatialReference,this.view.spatialReference)&&(T(t.geometry.spatialReference,this.view.spatialReference)||E()||await O(),t.geometry=S(t.geometry,this.view.spatialReference));this._endAsyncOperation()}undo(){this.canUndo()&&this._operationHandle.undo()}redo(){this.canRedo()&&this._operationHandle.redo()}canUndo(){return!(!this._operationHandle||!this._operationHandle.canUndo())}canRedo(){return!(!this._operationHandle||!this._operationHandle.canRedo())}toggleUpdateTool(){this._operationHandle&&this._operationHandle.toggleTool&&this._operationHandle.toggleTool()}async _getFirstHit(e){const t=[];switch(this.view.type){case"2d":{const o=[];this.view.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)}));const i=await this.view.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];e.graphic&&t.push(e)}}break;case"3d":{const o=[this.view.map.ground];this.view.map.allLayers.forEach((e=>{"integrated-mesh"===e.type&&o.push(e)}));const i=await this.view.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];(!i.ground.mapPoint||this.view.map.ground.opacity<1||i.ground.distance-d(e.distance,0)>-Math.min(3*i.ground.distance,"global"===this.view.viewingMode?A(this.view.renderCoordsHelper.spatialReference).radius/this.view.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY))&&t.push(e)}}}return{screenPoint:e,results:t}}_generateViewHandles(e){return[e.on("immediate-click",(async t=>{const o="active"===this.state&&"create"===this._operationHandle.type;if("disabled"===this.state||o||!this.updateOnGraphicClick)return;this._beginAsyncOperation();const i=(await t.async((()=>this._getFirstHit(K(t))))).results;let a=null;if(i.length){for(const r of i)if(r.graphic){const o=r.graphic;if(this.updateGraphics.includes(o)||o.layer===this.layer){t.stopPropagation(),a=o;break}"2d"!==e.type||this._isComponentGraphic(o)||"active"!==this.state||this.cancel()}}else"active"===this.state&&this.cancel();p(a)&&!this.updateGraphics.includes(a)&&await this.update([a],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}}),this._endAsyncOperation()}),j.WIDGET)]}async _setupCreateOperation(e,t){const o={hasZ:"3d"===this.view.type,...this.defaultCreateOptions,...t},i=await this._setupDrawGraphicTool(e,this.view,o);return c(i)?null:(this.view.tools.add(i),this.view.activeTool=i,this._setupCreateOperationHandle(i))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView"),null;const i="rectangle"!==e,a="rectangle"!==e;this.snappingOptions.enabledToggled=!1;const r={view:t,mode:"rectangle"===e||"circle"===e?"hybrid":"click",...o,snapToScene:!1,geometryType:e,graphicSymbol:this._getGraphicSymbolFromTool(e),snappingManager:this._snappingManager,forceUniformSize:a,centered:i};return"2d"===this.view.type?this._makeDrawGraphicTool2D(r):this._makeDrawGraphicTool3D(r)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return re(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ee(e.geometryType)?this.activeFillSymbol:null})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(t)||this.destroyed)return null;const{elevationInfo:o}=this.layer;return new t.module.DrawGraphicTool3D({...e,elevationInfo:o,snapToScene:!p(o)||"absolute-height"===o.mode,tooltipOptions:this.tooltipOptions})}_setupCreateOperationHandle(e){let t=null;const o=e.forceUniformSize,i=e.centered,a=[this.view.on("key-down",(t=>{if(t.key===L.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===L.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==L.vertexAdd||t.repeat)t.key===L.undo?(t.stopPropagation(),r.undo()):t.key===L.redo?(t.stopPropagation(),r.redo()):t.key!==L.snappingToggle||"rectangle"===e.geometryType||"circle"===e.geometryType||t.repeat?t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===L.center&&(t.repeat||(e.centered=!i,t.stopPropagation())):(e.forceUniformSize=!o,t.stopPropagation()):(this.snappingOptions.enabledToggled=!0,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),j.WIDGET),this.view.on("key-up",(t=>{t.key===L.pan?e.enabled=!0:t.key===L.snappingToggle&&"rectangle"!==e.geometryType&&"circle"!==e.geometryType?(this.snappingOptions.enabledToggled=!1,t.stopPropagation()):t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===L.center&&(e.centered=i,t.stopPropagation()):(e.forceUniformSize=o,t.stopPropagation())}),j.WIDGET),e.on("vertex-add",(o=>{switch(t=c(t)?"start":"active",o.operation){case"apply":this.emit("create",{graphic:l(e.graphic),state:t,tool:this.activeTool,toolEventInfo:o,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("cursor-update",(t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:l(e.graphic),state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})})),e.on("vertex-remove",(t=>{switch(t.operation){case"apply":this.emit("create",{graphic:l(e.graphic),state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("complete",(e=>{this._set("createGraphic",l(e.graphic)),t="complete",e.aborted?r&&r.cancel():r&&r.complete()})),g((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],r=new q({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{a.forEach((e=>e.remove())),a.length=0,this.view.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":return this.polygonSymbol;default:return null}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this,a={tool:this._defaultUpdateTool,...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions}};let r=a.tool;for(const s of e)o.remove(s),o.add(s);if("3d"===i.type){if(0===e.length)return null;switch(r){case"move":return this._setupMove3DOperation(e,a,i,r);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupReshape3DOperation(e[0],a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(r){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupTransformOrReshape2DOperation(e,r,a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":if(1===e.length){const t=u(e[0].geometry,"type");"point"!==t&&"multipoint"!==t||(r="reshape")}return this._setupTransformOrReshape2DOperation(e,r,a,i)}}async _setupMove3DOperation(e,t,o,i,a=!1){for(const l of e){const e=M(l);if(e!==R.SUPPORTED)return this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${D(e)}).`),null}const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(r))return r;const s=new r.module.GraphicMoveTool({view:o,enableZ:t.enableZ,snappingManager:this._snappingManager});this.view.tools.add(s),s.graphics.addMany(e),a||this.updateGraphics.addMany(e);const n=[],p=new Z({activeComponent:s,tool:i,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},undo:()=>{te(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e),s.graphics.push(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);p.history.undo.forEach((e=>e.updates.splice(t,1))),p.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?s.graphics.remove(e):p.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const a=await this._setupReshape3DOperation(e,t,o,!0);re(a)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(a,t))}});return n.push(...this._getHandlesForComponent(p,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&P(e[0])===R.SUPPORTED){const a=e[0],r=a.geometry;if(p(r)&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(p(r)&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,n=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(n))return n;const p=new n.module.GraphicTransformTool({graphic:e,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this._snappingManager});this.view.tools.add(p),this.updateGraphics.add(e);const l=[],h=new Z({activeComponent:p,tool:i,type:"update",onEnd:()=>{l.forEach((e=>e.remove())),l.length=0,this.view.tools?.remove(p),p.destroyed||p.destroy()},undo:()=>{te(h,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(h,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(h.onEnd(),h.destroy(),this._setUpdateOperationHandle(i,t))},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),h.complete()},toggleTool:()=>{}});return l.push(...this._getHandlesForComponent(h,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(h,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(h,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),h}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p}=t,l=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(l))return l;const h=new l.module.ExtentTransformTool({graphic:e,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p});this.view.tools.add(h),i||this.updateGraphics.add(e);const c=[],d=new Z({activeComponent:h,tool:a,type:"update",onEnd:()=>{c.forEach((e=>e.remove())),c.length=0,this.view.tools?.remove(h),h.destroyed||h.destroy()},canUndo:()=>h.canUndo,undo:()=>{h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>h.canRedo,redo:()=>{h.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(d.onEnd(),d.destroy(),this._setUpdateOperationHandle(i,t))},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),d.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const i=await this._setupReshape3DOperation(e,t,o,!0);re(i)||(d.onEnd(),d.destroy(),this._setUpdateOperationHandle(i,t))}});return c.push(...this._getHandlesForComponent(d,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(d,e,t)),j.WIDGET),this.view.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(d,e)),j.WIDGET),this.view.on("key-down",(e=>{e.key!==L.constraint||e.repeat||(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET),this.view.on("key-up",(e=>{e.key===L.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET)),d}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a=await this._getGraphicMover(e,t,o);if(re(a))return a;const r=new Z({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),p.forEach((e=>e.remove())),n.forEach((e=>e.remove())),p=[],n=[],a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();te(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();oe(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updateSpatialReference(e),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach((e=>e.updates.splice(t,1))),r.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1,n=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==L.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),j.WIDGET),o.on("key-up",(e=>{e.key===L.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),j.WIDGET)],p=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(r))return r;this.snappingOptions.enabledToggled=!1;const s=new r.module.GraphicReshapeTool({view:o,graphic:e,enableZVertex:t.enableZ&&"move"===t.reshapeOptions.vertexOperation,enableZShape:t.enableZ&&"move"===t.reshapeOptions.shapeOperation,enableMoveGraphic:"move"===t.reshapeOptions.shapeOperation||"move-xy"===t.reshapeOptions.shapeOperation,enableMidpoints:"split"===t.reshapeOptions.edgeOperation,enableEdgeOffset:"offset"===t.reshapeOptions.edgeOperation,snappingManager:this._snappingManager,tooltipOptions:this.tooltipOptions});o.tools.add(s),i||this.updateGraphics.add(e);const n=[],p=new Z({activeComponent:s,tool:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},canUndo:()=>s.canUndo,undo:()=>{s.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>s.canRedo,redo:()=>{s.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(i,t))},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),p.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);re(e)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(e,t))}});return n.push(...this._getHandlesForComponent(p,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(re(a))return a;const r=new Z({activeComponent:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),s.forEach((e=>e.remove())),n=[],s=[],r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{te(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{oe(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll();const a=await this._setupMove2DOperation(t,o,i);if(re(a))return;r.onEnd(),r.destroy(),this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach((e=>e.updates.splice(t,1))),r.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();if(0===o.length)r.complete();else{const e=o[0].geometry;1!==o.length||!p(e)||"point"!==e.type&&"multipoint"!==e.type?r.activeComponent.graphics=o:r.toggleTool()}this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.getItemAt(0),t=e.geometry;if(p(t)&&("reshape"===r.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._getReshape([e],o,i):"reshape"===r.tool&&(a=await this._getBox([e],o,i)),re(a)||(r.activeComponent.destroy(),r.activeComponent=a,r.activeComponent&&(n.forEach((e=>e.remove())),n=this._getHandlesForComponent(r,o)))}});let s=[i.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,o)),j.WIDGET),i.on("key-down",(e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==L.snappingToggle||e.repeat||(this.snappingOptions.enabledToggled=!0,e.stopPropagation()),e.key===L.constraint&&!e.repeat&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET),i.on("key-up",(e=>{if(e.key===L.snappingToggle&&"reshape"===r?.activeComponent?.type&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation()),e.key===L.constraint&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET)],n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i}=t,a=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return re(a)?a:new a.module.default({enableMoveAllGraphics:i,highlightsEnabled:!0,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayPointerCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,preserveAspectRatio:r}=t,s=await this._requireModule(import("../../views/draw/support/Box.js"));return re(s)?s:new s.module.default({graphics:e,enableRotation:i,enableScaling:a,preserveAspectRatio:r,layer:this._internalGraphicsLayer,view:o,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,r=await this._requireModule(import("../../views/draw/support/Reshape.js"));return re(r)?r:new r.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],layer:this._internalGraphicsLayer,snappingManager:this._snappingManager,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map((e=>k(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map((e=>k(e.geometry)));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;switch(o.type){case"graphic-mover":return[o.on("graphic-click",(({graphic:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ae(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ae(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ae([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ae([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ae([t.oldGraphic]))))];case"move-3d":return[o.on("graphic-move-start",(t=>{e.addToHistory(ae(t.allGraphics)),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:t.allGraphics.length>0?t.allGraphics[0]:null,type:"move-start"},type:"update"})})),o.on("graphic-move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.allGraphics.length>0?e.allGraphics[0]:null,type:"move"},type:"update"})})),o.on("graphic-move-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.allGraphics.length>0?e.allGraphics[0]:null,type:"move-stop"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"transform-3d":return[o.on("record-undo",(({record:t})=>{e.addToHistory({updates:[t]})})),o.on("graphic-translate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})})),o.on("graphic-translate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})})),o.on("graphic-rotate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-start"},type:"update"})})),o.on("graphic-rotate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})})),o.on("graphic-scale-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})})),o.on("graphic-scale-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})})),o.on("graphic-translate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})})),o.on("graphic-rotate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate"},type:"update"})})),o.on("graphic-scale",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"reshape-3d":return[o.on("reshape",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-add",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-remove",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];default:return}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&i.layer===this.layer?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=K(t),a=(await t.async((()=>this._getFirstHit(i)))).results;if(!a.length)return void e.complete();if(t.native.shiftKey&&this._toggleSelection(a.map((e=>e.graphic)),e,o))return void t.stopPropagation();a.some((e=>e.graphic&&this.updateGraphics.includes(e.graphic)))?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some((e=>null!=e&&(!(!i||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===L.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===L.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===L.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&L.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();c(t)||"reshape-3d"===t.type||("reshape"!==t.type||1===o.length&&"point"===u(o[0].geometry,"type"))&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=n(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||c(t))&&(e.attributes&&e.attributes.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_displayPointerCursor(){this.view&&this.view.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view&&this.view.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view&&this.view.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,o){Y.error(new i(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}test(){return{operationHandle:this._operationHandle,defaultUpdateOptions:Q}}wait(){return _((()=>!this.updating))}_beginAsyncOperation(){this._numUpdating+=1,this.notifyChange("updating")}_endAsyncOperation(){this._numUpdating-=1,this.notifyChange("updating")}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||p(e)&&e.toggleToolOnClick}_disablePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&c(this._originalAutoOpenEnabled)&&(this._originalAutoOpenEnabled=t.autoOpenEnabled,t.autoOpenEnabled=!1)}_restorePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&p(this._originalAutoOpenEnabled)&&(t.autoOpenEnabled=this._originalAutoOpenEnabled,this._originalAutoOpenEnabled=null)}async _waitViewReady(){const e=this.view;e&&(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_((()=>e?.ready)),this._viewReadyAbortController.signal))}};function ee(e){return"polygon"===e||"rectangle"===e||"circle"===e}function te(e,t){ie("undo",e.history.undo,e.history.redo,t)}function oe(e,t){ie("redo",e.history.redo,e.history.undo,t)}function ie(e,t,o,i){const a=t.pop().updates,r=[];i.forEach(((t,o)=>{const i=a[o];null!=i&&("geometry"in i&&p(i.geometry)&&(r.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&p(i.symbol)&&(r.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(r.push(i),i[e](t)))})),o.push({updates:r})}function ae(e){return{updates:e.map((e=>({geometry:e.geometry})))}}function re(e){return"requireError"in e&&"aborted"===e.requireError}e([G()],X.prototype,"updating",null),e([G()],X.prototype,"_operationHandle",void 0),e([G({readOnly:!0})],X.prototype,"activeTool",null),e([G()],X.prototype,"activeFillSymbol",void 0),e([G()],X.prototype,"activeLineSymbol",void 0),e([G()],X.prototype,"activeVertexSymbol",void 0),e([G()],X.prototype,"allowDeleteKey",void 0),e([G({readOnly:!0})],X.prototype,"createGraphic",null),e([G()],X.prototype,"defaultCreateOptions",null),e([G()],X.prototype,"defaultUpdateOptions",null),e([G()],X.prototype,"layer",void 0),e([G({types:t})],X.prototype,"pointSymbol",void 0),e([G({types:t})],X.prototype,"polygonSymbol",void 0),e([G({types:t})],X.prototype,"polylineSymbol",void 0),e([G({type:V,nonNullable:!0})],X.prototype,"snappingOptions",null),e([G()],X.prototype,"_snappingManager",void 0),e([G({readOnly:!0})],X.prototype,"state",null),e([G({type:W,nonNullable:!0})],X.prototype,"tooltipOptions",void 0),e([G({readOnly:!0})],X.prototype,"updateGraphics",void 0),e([G()],X.prototype,"updateOnGraphicClick",void 0),e([G({types:t})],X.prototype,"updatePointSymbol",void 0),e([G({types:t})],X.prototype,"updatePolygonSymbol",void 0),e([G({types:t})],X.prototype,"updatePolylineSymbol",void 0),e([G({types:t})],X.prototype,"vertexSymbol",void 0),e([G({value:null})],X.prototype,"view",null),X=e([b($)],X);const se=X;export{se as default};
|