@arcgis/core 5.1.0-next.76 → 5.1.0-next.78
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/analysis/ElevationProfile/ElevationProfileGroup.d.ts +74 -0
- package/analysis/ElevationProfile/ElevationProfileGroup.js +2 -0
- package/analysis/ElevationProfileAnalysis.d.ts +29 -14
- package/analysis/ElevationProfileAnalysis.js +1 -1
- package/applications/Components/OrientedImageryViewer/ImageViewer/utils.d.ts +34 -0
- package/applications/Components/OrientedImageryViewer/ImageViewer/utils.js +2 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{537fe2522dff1e6ce03b.js → 11ea4be441a26134ce1f.js} +1 -1
- package/assets/esri/core/workers/chunks/17acbf40e7c1cb42d9bd.js +1 -0
- package/assets/esri/core/workers/chunks/1c7fd0a229a8112b0539.js +596 -0
- package/assets/esri/core/workers/chunks/{baeb96aef03d4c566af7.js → 1f53620f82cc7c3daabe.js} +1 -1
- package/assets/esri/core/workers/chunks/2387613b855771a3e537.js +1 -0
- package/assets/esri/core/workers/chunks/283d39dfb1625b5a74db.js +1 -0
- package/assets/esri/core/workers/chunks/{5e1b847b116d21908a54.js → 322c54081b25f1c53661.js} +1 -1
- package/assets/esri/core/workers/chunks/{330b47ac0759c3c35cc5.js → 34fe97bcacc0dfc5bce6.js} +1 -1
- package/assets/esri/core/workers/chunks/{14eb2cc8e2ad6d8d03fd.js → 3d9fcbe95dd22dbe730e.js} +1 -1
- package/assets/esri/core/workers/chunks/{e262c4864dc06c43b380.js → 3df8493b91aa3bce824d.js} +1 -1
- package/assets/esri/core/workers/chunks/{bf8f603848bad4a7deb4.js → 4ccb56333de0247dcb6f.js} +1 -1
- package/assets/esri/core/workers/chunks/5b6f2bfdcdd207d8ae42.js +1 -0
- package/assets/esri/core/workers/chunks/{88b480a1d1fb01778798.js → 5ee4b630ad39c21d11db.js} +21 -26
- package/assets/esri/core/workers/chunks/{6b66fc32451433129a88.js → 8508f238d99021e87f71.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc75ab48f4c7609ef09d.js → 85d3475667c503ec4fc6.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d6491f996eeb0c646ed.js → 85d8c7cc7f8decbe975d.js} +1 -1
- package/assets/esri/core/workers/chunks/9b9916864b6575c42c8a.js +1 -0
- package/assets/esri/core/workers/chunks/{75d5ea0da181f9e7425f.js → a8ca5d8740cc7e39197b.js} +6 -6
- package/assets/esri/core/workers/chunks/{8d75f6f27c1c17c33992.js → b7bb7072dbee978f3ca3.js} +1 -1
- package/assets/esri/core/workers/chunks/bf7e019437a3b6036300.js +2 -0
- package/assets/esri/core/workers/chunks/{99c161fecae710b53b40.js → d304343a781acfa3ff96.js} +1 -1
- package/assets/esri/core/workers/chunks/dbb9bb28696ff9536678.js +2 -0
- package/assets/esri/core/workers/chunks/{34ea3ed78041437a8fc8.js → f81c6f6ccc201f584970.js} +1 -1
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_PluginSettingsControls.scss +29 -0
- 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/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_no.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
- package/config.js +1 -1
- package/core/types.d.ts +28 -0
- package/form/elements/inputs/MultipleChoiceInput.d.ts +2 -2
- package/form/elements/inputs/MultipleChoiceInput.js +1 -1
- package/geometry/operators/types.d.ts +2 -2
- package/interfaces.d.ts +4 -7
- package/kernel.js +1 -1
- package/layers/ImageryLayer.d.ts +7 -1
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.d.ts +7 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/WCSLayer.d.ts +7 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/networks/UnitIdentifierManager.d.ts +15 -15
- package/networks/UnitIdentifierManager.js +1 -1
- package/networks/support/jsonTypes.d.ts +125 -13
- package/package.json +3 -3
- package/popup/Features.d.ts +0 -1
- package/popup/Features.js +1 -1
- package/rest/networks/unitIdentifiers/reserve.js +2 -0
- package/rest/networks/unitIdentifiers/support/ReserveParameters.js +2 -0
- package/rest/networks/unitIdentifiers/support/ResizeParameters.js +1 -1
- package/rest/networks/unitIdentifiers/support/UnitQueryResult.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/analysis/ElevationProfile/ElevationProfileVisualization2D.js +1 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.d.ts +5 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
- package/views/2d/engine/webgl/AFeatureTile.js +1 -1
- package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ShaderHittest.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/BaseLayerView2D.d.ts +3 -3
- package/views/2d/layers/BaseLayerViewGL2D.d.ts +3 -3
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/support/clippingUtils.js +1 -1
- package/views/2d/support/hitTestUtils.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileVisualization3D.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.d.ts +5 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshNormals.js +1 -1
- package/views/3d/terrain/ElevationData.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Renderable.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +1 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +1 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js +16 -21
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/BlackLevelLightSoftCompression.glsl.js +5 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +2 -2
- package/views/VideoView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileIndicatorPointVisualization.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileResult.d.ts +6 -4
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/BezierSegmentPlugin.js +1 -1
- package/views/draw/plugins/FreehandSegmentPlugin.js +1 -1
- package/views/draw/support/PluginContext.js +1 -1
- package/views/draw/support/types.d.ts +21 -0
- package/views/draw/support/types.js +1 -1
- package/views/types.d.ts +2 -2
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
- package/widgets/Editor/components/Settings.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView2D.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView3D.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation2D.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation3D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLine2D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +5 -5
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/SuperimposeService.js +2 -0
- package/widgets/OrientedImageryViewer/support/superimposeUtils.js +2 -0
- package/widgets/OrientedImageryViewer/types.d.ts +10 -0
- package/widgets/OrientedImageryViewer.d.ts +17 -2
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/Sketch/support/SettingsManager.js +2 -0
- package/widgets/Sketch.js +1 -1
- package/widgets/Slider/SliderViewModel.d.ts +2 -1
- package/widgets/Slider/SliderViewModel.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/smartMapping/ColorSlider/ColorSliderViewModel.js +1 -1
- package/widgets/smartMapping/OpacitySlider/OpacitySliderViewModel.js +1 -1
- package/widgets/smartMapping/SizeSlider/SizeSliderViewModel.js +1 -1
- package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
- package/widgets/support/PluginSettingsControls.js +2 -0
- package/widgets/support/SnappingControls.js +1 -1
- package/widgets/support/forms/formUtils.js +1 -1
- package/analysis/ElevationProfile/elevationProfileLineTypes.js +0 -2
- package/assets/esri/core/workers/chunks/003476e950bd27a2f884.js +0 -596
- package/assets/esri/core/workers/chunks/07aca5ecad659d55e795.js +0 -2
- package/assets/esri/core/workers/chunks/7540f7df86620f067b5a.js +0 -1
- package/assets/esri/core/workers/chunks/76e34f81bb4a7b0e694c.js +0 -1
- package/assets/esri/core/workers/chunks/bfe575da727ce7c8d331.js +0 -2
- package/assets/esri/core/workers/chunks/cb45e5d4a4ef82cda583.js +0 -1
- package/assets/esri/core/workers/chunks/ea59b81299acaf0d85ee.js +0 -1
- package/assets/esri/core/workers/chunks/ef0eae13408cbf83a64f.js +0 -1
- package/rest/networks/unitIdentifiers/insertGap.js +0 -2
- package/rest/networks/unitIdentifiers/support/InsertGapParameters.js +0 -2
- /package/assets/esri/core/workers/chunks/{07aca5ecad659d55e795.js.LICENSE.txt → bf7e019437a3b6036300.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{bfe575da727ce7c8d331.js.LICENSE.txt → dbb9bb28696ff9536678.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t,__decorate as o}from"tslib";import i from"../../Graphic.js";import{prefersReducedMotion as a}from"../../core/a11yUtils.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as p}from"../../core/Evented.js";import{drainHandles as l,disposable as h,makeHandle as c,destroyHandle as d}from"../../core/handleUtils.js";import"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as y,abortMaybe as m}from"../../core/maybe.js";import{createAbortError as g,ignoreAbortErrors as v,whenOrAbort as f}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as b,on as w,when as G,whenOnce as T}from"../../core/reactiveUtils.js";import{property as O,subclass as S}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as A}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as E,isLoaded as M,load as k,project as H}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as I}from"../../geometry/support/coordsUtils.js";import{equals as P}from"../../geometry/support/spatialReferenceUtils.js";import D from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as j}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as U}from"../../support/elevationInfoUtils.js";import R from"../../symbols/CIMSymbol.js";import x from"../../symbols/FillSymbol3DLayer.js";import L from"../../symbols/MeshSymbol3D.js";import F from"../../symbols/SimpleFillSymbol.js";import V from"../../symbols/SimpleLineSymbol.js";import W from"../../symbols/SimpleMarkerSymbol.js";import K from"../../symbols/TextSymbol.js";import{symbolTypes as Z}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as q}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as N}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as z}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as B}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as $}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Y}from"../../views/input/InputManager.js";import{sketchKeys as X}from"../../views/interactive/keybindings.js";import J from"../../views/interactive/sketch/SketchLabelOptions.js";import Q from"../../views/interactive/sketch/SketchOptions.js";import ee from"../../views/interactive/sketch/SketchTooltipOptions.js";import te from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as oe}from"../../views/interactive/snapping/SnappingManager.js";import ie from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as ae}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as re}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as se}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ne}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as pe}from"../../views/support/screenUtils.js";import le from"./adapters/layer/GraphicsLayerAdapter.js";import he from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ce,DrawToolOperationHandle as de,UpdateOperationHandle as ue}from"./support/OperationHandle.js";import{PluginManager as ye}from"./support/PluginManager.js";import{getLegacyTool as me,isCompletelyDegenerate as ge,graphicsHaveTooFewVerticesForBox as ve,getModeFromCreateOptions as fe,getDrawToolGeometryTypeFromCreateTool as _e}from"./support/sketchUtils.js";const be={defaultZ:0},we={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:se},tool:"transform"},Ge=Symbol(),Te=Symbol();let Oe=class extends p{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new D({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ye({sketchViewModel:this}),this._operationHandle=null,this._updatingHandles=new C,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new re,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new W({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new F({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new V({color:[130,130,130,1],width:2}),this.meshSymbol=new L({symbolLayers:new s([new x])}),this.updateGraphics=new s,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new W({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Q,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(Te),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},b)].filter(r);this.addHandles(t,Te)},this._originalPopupEnabled=null,this.defaultCreateOptions=be,this.defaultUpdateOptions=we,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new ie,this.textSymbol=new K({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([w(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),b),_(()=>this.view,e=>{this._defaultSnappingManager=y(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new oe({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},b),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),ae(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=y(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new le(e);case"map-notes":return new he(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(r).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...be,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...we,...e,reshapeOptions:{...we.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...we.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=y(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new oe({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(G(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},b),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(r)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=m(this._moduleLoaderAbortController),this._viewReadyAbortController=m(this._viewReadyAbortController),this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),g();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");$(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=me(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(v(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(v(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),g();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||De(s)||($(i,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){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||P(o.geometry.spatialReference,t.spatialReference)||(E(o.geometry.spatialReference,t.spatialReference)||M()||await k(),o.geometry=H(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ne(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{j(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?A(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Y.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(pe(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=me(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=fe(p,e),c=_e(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,y={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(y):this._makeDrawGraphicTool3D(y)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return De(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:Ae(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return De(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,s=[o.on("key-down",t=>{if(t.key===X.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===X.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==X.vertexAdd||t.repeat)t.key===X.undo?(t.stopPropagation(),n.undo()):t.key===X.redo?(t.stopPropagation(),n.redo()):t.key!==X.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===X.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Y.WIDGET),o.on("key-up",t=>{t.key===X.pan?e.enabled=!0:t.key!==X.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===X.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Y.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic: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:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?n&&n.cancel():n&&n.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],n=new ce({activeComponent:e,type:"create",onEnd:()=>{l(s),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return n}_setupDrawToolOperationHandle(o,i){const a=this.view;if(!a)return this._logMissingView(),null;let s=null;const n=[a.on("key-down",e=>{e.key===X.pan&&(e.stopPropagation(),e.repeat||(o.editable=!1))},Y.WIDGET),a.on("key-up",e=>{e.key===X.pan&&(o.editable=!0)},Y.WIDGET),o.on("before-vertex-add",e=>{const t=o.mostUpstreamPlugin?.configuration;if(t&&"legacyCreateTool"in t&&("point"===t?.legacyCreateTool||"text"===t.legacyCreateTool)){const t=e.detail.originalEvent;return void(t&&"key"in t&&t.key===X.vertexAdd&&e.preventDefault())}}),o.on("before-complete",e=>{const t=o.getGeometryIfCompleted();(!t||ge(t))&&e.preventDefault()}),o.on(["vertex-add","vertex-remove"],e=>{switch(this.createGraphic&&(this.createGraphic.geometry=o.getGeometryIfCompleted()),s=null==s&&"vertex-remove"!==e.type?"start":"active",e.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:s,tool:this.activeTool,toolEventInfo:e,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(r),tool:i});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(r),tool:i})}}),o.on("cursor-update",e=>{this.createGraphic&&(this.createGraphic.geometry=o.unprocessedGeometry),(e.vertices[0]?.vertexIndex>0||e.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:e.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),o.on("complete",async({geometry:i,isSimple:a})=>{const r=this.createGraphic;if(!!i&&"mesh"!==i.type&&"extent"!==i.type&&!a&&r){const a={stack:[],error:void 0,hasError:!1};try{const t=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=t;e(a,h(this._createDrawToolCompletionPreviewGraphic(o,i,r)),!1);await this._updatingHandles.addPromise(v(this._finalizeDrawToolCompletion({abortController:t,geometry:i,graphic:r,handle:p})))}catch(s){a.error=s,a.hasError=!0}finally{t(a)}}else r&&(r.geometry=i),p.complete()})],p=new de({activeComponent:o,type:"create",onEnd:()=>{l(n),a.tools.remove(o)},undo:()=>o.undo(),redo:()=>o.redo(),canUndo:()=>o.canUndo,canRedo:()=>o.canRedo});return n.push(o.on("cancel",()=>{this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),p.cancel()})),p}_createDrawToolCompletionPreviewGraphic(e,t,o){const a="polygon"===t?.type?this._createAnimatedPolygonPreviewSymbol():o?.symbol,r=t?e.simplifiedGeometryPreview??t:null;if(!r||!a)return c();const s=new i({geometry:r,symbol:a});return this._internalGraphicsLayer.add(s),c(()=>this._internalGraphicsLayer.remove(s))}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&this._layerAdapter?.remove(o),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_createAnimatedPolygonPreviewSymbol(){const e={type:"CIMAnimatedSymbolProperties",playAnimation:!a(),duration:1,repeatType:"Oscillate",easing:"EaseInOut"};return new R({data:{type:"CIMSymbolReference",symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[180,180,180,36],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]},{type:"CIMHatchFill",enable:!0,separation:6,rotation:-45,offsetX:0,offsetY:0,lineSymbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:.8,color:[100,100,100,110],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]}]}},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:1.8,color:[60,60,60,255],effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[6,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:70,animatedSymbolProperties:e}]}]}}})}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??we.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return ve(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(De(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:n}=r.module,p=new Map,h=()=>{p.forEach(e=>e.destroy()),p.clear()};for(const l of e){const e=new s({view:o,graphic:l}),t=N(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${q(t)}).`),null;p.set(l,e)}const c=new n({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(p.values())),a||this.updateGraphics.addMany(e);const d=[],u=new ue({activeComponent:c,tool:i,type:"update",onEnd:()=>{l(d),Pe(o,c),h()},undo:()=>{He(this.view,c),Ee(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Me(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});p.set(e,t),c.objects.push(t),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);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.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)return void u.complete();const o=p.get(e);o&&(c.objects.remove(o),o.destroy(),p.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!De(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Y.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===B(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=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(De(n))return n;const{TransformTool3D:p,ManipulatedObject3DGraphic:h}=n.module,c=new h({graphic:e,view:o}),d=new p({object:c,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],y=new ue({activeComponent:d,tool:i,type:"update",onEnd:()=>{l(u),Pe(o,d),c.destroy()},undo:()=>{He(this.view,d),Ee(y,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Me(y,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"}),y.onEnd(),y.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));De(i)||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"}),y.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(y,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)},Y.WIDGET)),y}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(De(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(X.constraint),y=new c({view:o,graphic:e}),m=new d({object:y,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:!!p!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const g=[],v=new ue({activeComponent:m,tool:a,type:"update",onEnd:()=>{l(g),Pe(o,m),y.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.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"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));De(i)||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"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!De(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Y.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Y.WIDGET),o.on("key-down",e=>{e.key!==X.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Y.WIDGET),o.on("key-up",e=>{e.key===X.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Y.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(De(a))return a;const r=new ue({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),l(p),l(n),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();Ee(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Me(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(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;const n=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==X.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Y.WIDGET),o.on("key-up",e=>{e.key===X.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Y.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(De(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:n}=r.module,p=new s({view:o,graphic:e}),h=z(p);if(0!==h)return p.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${q(h)}).`),null;const c=t.reshapeOptions,d=new n({view:o,object:p,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(p.graphic);const u=[],y=new ue({activeComponent:d,tool:a,type:"update",onEnd:()=>{l(u),Pe(o,d),p.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.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"}),y.onEnd(),y.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));De(i)||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"}),y.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;y.onEnd(),y.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));De(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(y,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)},Y.WIDGET)),y}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(De(a))return a;const r=new ue({activeComponent:a,type:"update",onEnd:()=>{l(n),l(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{Ee(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Me(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(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(De(a))return;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: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();0===o.length?r.complete():ve(o)?r.toggleTool():r.activeComponent.graphics=o,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.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),De(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(l(n),n=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Y.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===X.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Y.WIDGET),i.on("key-up",e=>{if(e.key===X.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Y.WIDGET)];let n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return De(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),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._displayCursor("pointer"),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._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(De(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(X.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,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"})}});return l.addHandles(_(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},b)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return De(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,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=>I(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=>I(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;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Ie(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Ie(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Ie(t.graphics))),o.on("scale-start",t=>e.addToHistory(Ie(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Ie([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Ie([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Ie([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Ie([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("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.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(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=pe(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.updateOnGraphicClick&&e.complete());if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===X.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===X.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===X.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&X.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=y(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(Ge)}_displayCursor(e){this.removeHandles(Ge),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),Ge)}_logError(e,t,o){u.getLogger(this).error(new n(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"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,t,o){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:t.graphicSymbol,useTextSymbol:"text"===o}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??U("3d"===a.type),hasZ:!!t.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:t.defaultZ??0,directionOptions:t.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==o&&"circle"!==o});n.addHandles(d(s));const p=new i({...t.graphicProperties,attributes:{...t.graphicProperties?.attributes},symbol:t.graphicSymbol??this._getGraphicSymbolFromTool(o)});return t.graphicSymbol||n.addHandles(_(()=>this._getGraphicSymbolFromTool(o),e=>p.symbol=e)),this._set("createGraphic",p),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return T(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(m(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await f(T(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Ce("view"))}_logMissingLayer(){this._logError(Se,Ce("layer"))}};o([O()],Oe.prototype,"_defaultSnappingManager",void 0),o([O()],Oe.prototype,"_layerAdapter",null),o([O()],Oe.prototype,"_pluginManager",void 0),o([O()],Oe.prototype,"_operationHandle",void 0),o([O({readOnly:!0})],Oe.prototype,"_updatingHandles",void 0),o([O()],Oe.prototype,"_drawToolSimplifyAbortController",void 0),o([O({readOnly:!0})],Oe.prototype,"activeTool",null),o([O()],Oe.prototype,"geometrySimplificationInProgress",null),o([O({readOnly:!0})],Oe.prototype,"activeCreateToolDrawMode",null),o([O()],Oe.prototype,"activeTooltip",null),o([O({types:Z})],Oe.prototype,"activeFillSymbol",void 0),o([O()],Oe.prototype,"activeLineSymbol",void 0),o([O()],Oe.prototype,"activeVertexSymbol",void 0),o([O()],Oe.prototype,"allowDeleteKey",void 0),o([O({readOnly:!0})],Oe.prototype,"createGraphic",null),o([O()],Oe.prototype,"defaultCreateOptions",null),o([O()],Oe.prototype,"defaultUpdateOptions",null),o([O()],Oe.prototype,"activeUpdateOptions",void 0),o([O({type:J,nonNullable:!0})],Oe.prototype,"labelOptions",null),o([O()],Oe.prototype,"layer",void 0),o([O({types:Z})],Oe.prototype,"pointSymbol",void 0),o([O({types:Z})],Oe.prototype,"polygonSymbol",void 0),o([O({types:Z})],Oe.prototype,"polylineSymbol",void 0),o([O()],Oe.prototype,"meshSymbol",void 0),o([O({type:K})],Oe.prototype,"textSymbol",null),o([O({type:ie,nonNullable:!0})],Oe.prototype,"snappingOptions",null),o([O()],Oe.prototype,"snappingManager",null),o([O({readOnly:!0})],Oe.prototype,"state",null),o([O({type:ee,nonNullable:!0})],Oe.prototype,"tooltipOptions",null),o([O({readOnly:!0})],Oe.prototype,"updateGraphics",void 0),o([O()],Oe.prototype,"updateOnGraphicClick",void 0),o([O()],Oe.prototype,"updating",null),o([O()],Oe.prototype,"creationMode",void 0),o([O({type:te,nonNullable:!0})],Oe.prototype,"valueOptions",null),o([O({types:Z})],Oe.prototype,"vertexSymbol",void 0),o([O({value:null})],Oe.prototype,"view",null),o([O({constructOnly:!0,type:Q})],Oe.prototype,"sketchOptions",void 0),o([O()],Oe.prototype,"useLegacyCreateTools",void 0),o([O()],Oe.prototype,"isUsingLegacyCreateTools",null),o([O()],Oe.prototype,"pluginManager",null),o([O()],Oe.prototype,"drawTool",null),o([O()],Oe.prototype,"rootPlugins",null),o([O()],Oe.prototype,"effectiveAvailablePlugins",null),o([O()],Oe.prototype,"firstPluginWithSwappableLeaf",null),o([O()],Oe.prototype,"multiplePluginsActive",null),Oe=o([S("esri.widgets.Sketch.SketchViewModel")],Oe);const Se="sketch:missing-property",Ce=e=>`Property '${e}' is missing on SketchViewModel.`;function Ae(e){return"polygon"===e||"rectangle"===e||"circle"===e}function Ee(e,t){ke("undo",e.history.undo,e.history.redo,t)}function Me(e,t){ke("redo",e.history.redo,e.history.undo,t)}function ke(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function He(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Ie(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Pe(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function De(e){return"requireError"in e&&"aborted"===e.requireError}export{Oe as default};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as o}from"tslib";import i from"../../Graphic.js";import{prefersReducedMotion as a}from"../../core/a11yUtils.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as p}from"../../core/Evented.js";import{drainHandles as l,disposable as h,makeHandle as c,destroyHandle as d}from"../../core/handleUtils.js";import"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as y,abortMaybe as m}from"../../core/maybe.js";import{createAbortError as g,ignoreAbortErrors as v,whenOrAbort as f}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as b,on as w,when as G,whenOnce as T}from"../../core/reactiveUtils.js";import{property as O,subclass as S}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as A}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as E,isLoaded as M,load as k,project as H}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as I}from"../../geometry/support/coordsUtils.js";import{equals as P}from"../../geometry/support/spatialReferenceUtils.js";import D from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as j}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as U}from"../../support/elevationInfoUtils.js";import R from"../../symbols/CIMSymbol.js";import x from"../../symbols/FillSymbol3DLayer.js";import L from"../../symbols/MeshSymbol3D.js";import F from"../../symbols/SimpleFillSymbol.js";import V from"../../symbols/SimpleLineSymbol.js";import W from"../../symbols/SimpleMarkerSymbol.js";import K from"../../symbols/TextSymbol.js";import{symbolTypes as Z}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as q}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as N}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as z}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as B}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as $}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Y}from"../../views/input/InputManager.js";import{sketchKeys as X}from"../../views/interactive/keybindings.js";import J from"../../views/interactive/sketch/SketchLabelOptions.js";import Q from"../../views/interactive/sketch/SketchOptions.js";import ee from"../../views/interactive/sketch/SketchTooltipOptions.js";import te from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as oe}from"../../views/interactive/snapping/SnappingManager.js";import ie from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as ae}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as re}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as se}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ne}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as pe}from"../../views/support/screenUtils.js";import le from"./adapters/layer/GraphicsLayerAdapter.js";import he from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ce,DrawToolOperationHandle as de,UpdateOperationHandle as ue}from"./support/OperationHandle.js";import{PluginManager as ye}from"./support/PluginManager.js";import{SettingsManager as me}from"./support/SettingsManager.js";import{getLegacyTool as ge,isCompletelyDegenerate as ve,graphicsHaveTooFewVerticesForBox as fe,getModeFromCreateOptions as _e,getDrawToolGeometryTypeFromCreateTool as be}from"./support/sketchUtils.js";const we={defaultZ:0},Ge={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:se},tool:"transform"},Te=Symbol(),Oe=Symbol();let Se=class extends p{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new D({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ye({sketchViewModel:this}),this.settingsManager=new me({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new C,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new re,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new W({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new F({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new V({color:[130,130,130,1],width:2}),this.meshSymbol=new L({symbolLayers:new s([new x])}),this.updateGraphics=new s,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new W({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Q,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(Oe),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},b)].filter(r);this.addHandles(t,Oe)},this._originalPopupEnabled=null,this.defaultCreateOptions=we,this.defaultUpdateOptions=Ge,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new ie,this.textSymbol=new K({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([w(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),b),_(()=>this.view,e=>{this._defaultSnappingManager=y(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new oe({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},b),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),ae(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=y(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new le(e);case"map-notes":return new he(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(r).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...we,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Ge,...e,reshapeOptions:{...Ge.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...Ge.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=y(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new oe({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(G(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},b),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(r)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=m(this._moduleLoaderAbortController),this._viewReadyAbortController=m(this._viewReadyAbortController),this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),g();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");$(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=ge(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(v(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(v(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),g();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||je(s)||($(i,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){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||P(o.geometry.spatialReference,t.spatialReference)||(E(o.geometry.spatialReference,t.spatialReference)||M()||await k(),o.geometry=H(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ne(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{j(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?A(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Y.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(pe(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=ge(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=_e(p,e),c=be(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,y={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(y):this._makeDrawGraphicTool3D(y)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return je(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,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return je(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,s=[o.on("key-down",t=>{if(t.key===X.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===X.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==X.vertexAdd||t.repeat)t.key===X.undo?(t.stopPropagation(),n.undo()):t.key===X.redo?(t.stopPropagation(),n.redo()):t.key!==X.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===X.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Y.WIDGET),o.on("key-up",t=>{t.key===X.pan?e.enabled=!0:t.key!==X.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===X.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Y.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic: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:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?n&&n.cancel():n&&n.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],n=new ce({activeComponent:e,type:"create",onEnd:()=>{l(s),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return n}_setupDrawToolOperationHandle(o,i){const a=this.view;if(!a)return this._logMissingView(),null;let s=null;const n=[a.on("key-down",e=>{e.key===X.pan&&(e.stopPropagation(),e.repeat||(o.editable=!1))},Y.WIDGET),a.on("key-up",e=>{e.key===X.pan&&(o.editable=!0)},Y.WIDGET),o.on("before-vertex-add",e=>{const t=o.mostUpstreamPlugin?.configuration;if(t&&"legacyCreateTool"in t&&("point"===t?.legacyCreateTool||"text"===t.legacyCreateTool)){const t=e.detail.originalEvent;return void(t&&"key"in t&&t.key===X.vertexAdd&&e.preventDefault())}}),o.on("before-complete",e=>{const t=o.getGeometryIfCompleted();(!t||ve(t))&&e.preventDefault()}),o.on(["vertex-add","vertex-remove"],e=>{switch(this.createGraphic&&(this.createGraphic.geometry=o.getGeometryIfCompleted()),s=null==s&&"vertex-remove"!==e.type?"start":"active",e.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:s,tool:this.activeTool,toolEventInfo:e,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(r),tool:i});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(r),tool:i})}}),o.on("cursor-update",e=>{this.createGraphic&&(this.createGraphic.geometry=o.unprocessedGeometry),(e.vertices[0]?.vertexIndex>0||e.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:e.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),o.on("complete",async({geometry:i,isSimple:a})=>{const r=this.createGraphic;if(!!i&&"mesh"!==i.type&&"extent"!==i.type&&!a&&r){const a={stack:[],error:void 0,hasError:!1};try{const t=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=t;e(a,h(this._createDrawToolCompletionPreviewGraphic(o,i,r)),!1);await this._updatingHandles.addPromise(v(this._finalizeDrawToolCompletion({abortController:t,geometry:i,graphic:r,handle:p})))}catch(s){a.error=s,a.hasError=!0}finally{t(a)}}else r&&(r.geometry=i),p.complete()})],p=new de({activeComponent:o,type:"create",onEnd:()=>{l(n),a.tools.remove(o)},undo:()=>o.undo(),redo:()=>o.redo(),canUndo:()=>o.canUndo,canRedo:()=>o.canRedo});return n.push(o.on("cancel",()=>{this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),p.cancel()})),p}_createDrawToolCompletionPreviewGraphic(e,t,o){const a="polygon"===t?.type?this._createAnimatedPolygonPreviewSymbol():o?.symbol,r=t?e.simplifiedGeometryPreview??t:null;if(!r||!a)return c();const s=new i({geometry:r,symbol:a});return this._internalGraphicsLayer.add(s),c(()=>this._internalGraphicsLayer.remove(s))}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&this._layerAdapter?.remove(o),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_createAnimatedPolygonPreviewSymbol(){const e={type:"CIMAnimatedSymbolProperties",playAnimation:!a(),duration:1,repeatType:"Oscillate",easing:"EaseInOut"};return new R({data:{type:"CIMSymbolReference",symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[180,180,180,36],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]},{type:"CIMHatchFill",enable:!0,separation:6,rotation:-45,offsetX:0,offsetY:0,lineSymbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:.8,color:[100,100,100,110],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]}]}},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:1.8,color:[60,60,60,255],effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[6,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:70,animatedSymbolProperties:e}]}]}}})}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??Ge.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return fe(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(je(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:n}=r.module,p=new Map,h=()=>{p.forEach(e=>e.destroy()),p.clear()};for(const l of e){const e=new s({view:o,graphic:l}),t=N(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${q(t)}).`),null;p.set(l,e)}const c=new n({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(p.values())),a||this.updateGraphics.addMany(e);const d=[],u=new ue({activeComponent:c,tool:i,type:"update",onEnd:()=>{l(d),De(o,c),h()},undo:()=>{Ie(this.view,c),Me(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ke(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});p.set(e,t),c.objects.push(t),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);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.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)return void u.complete();const o=p.get(e);o&&(c.objects.remove(o),o.destroy(),p.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!je(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Y.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===B(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=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(je(n))return n;const{TransformTool3D:p,ManipulatedObject3DGraphic:h}=n.module,c=new h({graphic:e,view:o}),d=new p({object:c,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],y=new ue({activeComponent:d,tool:i,type:"update",onEnd:()=>{l(u),De(o,d),c.destroy()},undo:()=>{Ie(this.view,d),Me(y,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ke(y,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"}),y.onEnd(),y.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));je(i)||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"}),y.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(y,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)},Y.WIDGET)),y}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(je(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(X.constraint),y=new c({view:o,graphic:e}),m=new d({object:y,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:!!p!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const g=[],v=new ue({activeComponent:m,tool:a,type:"update",onEnd:()=>{l(g),De(o,m),y.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.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"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));je(i)||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"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!je(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Y.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Y.WIDGET),o.on("key-down",e=>{e.key!==X.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Y.WIDGET),o.on("key-up",e=>{e.key===X.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Y.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(je(a))return a;const r=new ue({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),l(p),l(n),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();Me(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();ke(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(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;const n=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==X.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Y.WIDGET),o.on("key-up",e=>{e.key===X.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Y.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(je(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:n}=r.module,p=new s({view:o,graphic:e}),h=z(p);if(0!==h)return p.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${q(h)}).`),null;const c=t.reshapeOptions,d=new n({view:o,object:p,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(p.graphic);const u=[],y=new ue({activeComponent:d,tool:a,type:"update",onEnd:()=>{l(u),De(o,d),p.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.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"}),y.onEnd(),y.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));je(i)||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"}),y.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;y.onEnd(),y.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));je(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(y,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)},Y.WIDGET)),y}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(je(a))return a;const r=new ue({activeComponent:a,type:"update",onEnd:()=>{l(n),l(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{Me(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{ke(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(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(je(a))return;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: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();0===o.length?r.complete():fe(o)?r.toggleTool():r.activeComponent.graphics=o,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.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),je(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(l(n),n=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Y.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===X.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Y.WIDGET),i.on("key-up",e=>{if(e.key===X.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Y.WIDGET)];let n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return je(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),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._displayCursor("pointer"),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._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(je(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(X.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,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"})}});return l.addHandles(_(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},b)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return je(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,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=>I(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=>I(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;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Pe(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Pe(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Pe(t.graphics))),o.on("scale-start",t=>e.addToHistory(Pe(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Pe([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Pe([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Pe([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Pe([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("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.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(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=pe(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.updateOnGraphicClick&&e.complete());if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===X.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===X.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===X.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&X.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=y(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(Te)}_displayCursor(e){this.removeHandles(Te),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),Te)}_logError(e,t,o){u.getLogger(this).error(new n(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"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,t,o){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:t.graphicSymbol,useTextSymbol:"text"===o}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??U("3d"===a.type),hasZ:!!t.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:t.defaultZ??0,directionOptions:t.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==o&&"circle"!==o,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});n.addHandles(d(s));const p=new i({...t.graphicProperties,attributes:{...t.graphicProperties?.attributes},symbol:t.graphicSymbol??this._getGraphicSymbolFromTool(o)});return t.graphicSymbol||n.addHandles(_(()=>this._getGraphicSymbolFromTool(o),e=>p.symbol=e)),this._set("createGraphic",p),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return T(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(m(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await f(T(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Ae("view"))}_logMissingLayer(){this._logError(Ce,Ae("layer"))}};o([O()],Se.prototype,"_defaultSnappingManager",void 0),o([O()],Se.prototype,"_layerAdapter",null),o([O()],Se.prototype,"_pluginManager",void 0),o([O({readOnly:!0})],Se.prototype,"settingsManager",void 0),o([O()],Se.prototype,"_operationHandle",void 0),o([O({readOnly:!0})],Se.prototype,"_updatingHandles",void 0),o([O()],Se.prototype,"_drawToolSimplifyAbortController",void 0),o([O({readOnly:!0})],Se.prototype,"activeTool",null),o([O()],Se.prototype,"geometrySimplificationInProgress",null),o([O({readOnly:!0})],Se.prototype,"activeCreateToolDrawMode",null),o([O()],Se.prototype,"activeTooltip",null),o([O({types:Z})],Se.prototype,"activeFillSymbol",void 0),o([O()],Se.prototype,"activeLineSymbol",void 0),o([O()],Se.prototype,"activeVertexSymbol",void 0),o([O()],Se.prototype,"allowDeleteKey",void 0),o([O({readOnly:!0})],Se.prototype,"createGraphic",null),o([O()],Se.prototype,"defaultCreateOptions",null),o([O()],Se.prototype,"defaultUpdateOptions",null),o([O()],Se.prototype,"activeUpdateOptions",void 0),o([O({type:J,nonNullable:!0})],Se.prototype,"labelOptions",null),o([O()],Se.prototype,"layer",void 0),o([O({types:Z})],Se.prototype,"pointSymbol",void 0),o([O({types:Z})],Se.prototype,"polygonSymbol",void 0),o([O({types:Z})],Se.prototype,"polylineSymbol",void 0),o([O()],Se.prototype,"meshSymbol",void 0),o([O({type:K})],Se.prototype,"textSymbol",null),o([O({type:ie,nonNullable:!0})],Se.prototype,"snappingOptions",null),o([O()],Se.prototype,"snappingManager",null),o([O({readOnly:!0})],Se.prototype,"state",null),o([O({type:ee,nonNullable:!0})],Se.prototype,"tooltipOptions",null),o([O({readOnly:!0})],Se.prototype,"updateGraphics",void 0),o([O()],Se.prototype,"updateOnGraphicClick",void 0),o([O()],Se.prototype,"updating",null),o([O()],Se.prototype,"creationMode",void 0),o([O({type:te,nonNullable:!0})],Se.prototype,"valueOptions",null),o([O({types:Z})],Se.prototype,"vertexSymbol",void 0),o([O({value:null})],Se.prototype,"view",null),o([O({constructOnly:!0,type:Q})],Se.prototype,"sketchOptions",void 0),o([O()],Se.prototype,"useLegacyCreateTools",void 0),o([O()],Se.prototype,"isUsingLegacyCreateTools",null),o([O()],Se.prototype,"pluginManager",null),o([O()],Se.prototype,"drawTool",null),o([O()],Se.prototype,"rootPlugins",null),o([O()],Se.prototype,"effectiveAvailablePlugins",null),o([O()],Se.prototype,"firstPluginWithSwappableLeaf",null),o([O()],Se.prototype,"multiplePluginsActive",null),Se=o([S("esri.widgets.Sketch.SketchViewModel")],Se);const Ce="sketch:missing-property",Ae=e=>`Property '${e}' is missing on SketchViewModel.`;function Ee(e){return"polygon"===e||"rectangle"===e||"circle"===e}function Me(e,t){He("undo",e.history.undo,e.history.redo,t)}function ke(e,t){He("redo",e.history.redo,e.history.undo,t)}function He(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Ie(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Pe(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function De(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function je(e){return"requireError"in e&&"aborted"===e.requireError}export{Se as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import i from"../../../core/Accessor.js";import{isSome as t}from"../../../core/arrayUtils.js";import n from"../../../core/Error.js";import{handlesGroup as l}from"../../../core/handleUtils.js";import o from"../../../core/Logger.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";let g=class extends i{constructor(e){super(e),this._pluginLoadPromise=null,this._pluginConstructors=null}get _simplePointPlugin(){const e=Symbol.for("esri-builtin-plugin-leaf-point");return{uniqueId:e,localizationKey:"leaf-point-segment",kind:["vertex"],geometryType:"point",icon:"line-straight",legacyCreateTool:"point",create:()=>this._createPlugin(e),[Symbol.toStringTag]:"Point"}}get _hybridSegmentPlugin(){const e=Symbol.for("esri-builtin-plugin-freehand");return{...this._simplePointPlugin,create:()=>{const i=this._createPlugin(e);return i.completeOnDragEnd=!0,i.snappingBehavior="when-not-capturing",i},[Symbol.toStringTag]:"Hybrid Segment"}}get _pointLikeFreehandSegmentPlugin(){const e=Symbol.for("esri-builtin-plugin-freehand");return{...this._simplePointPlugin,create:()=>{const i=this._createPlugin(e);return i.completeOnDragEnd=!0,i.snappingBehavior="when-not-capturing",i},[Symbol.toStringTag]:"Freehand Segment"}}get _effectiveConfiguredDrawingMode(){return this.sketchViewModel?.defaultCreateOptions?.mode??"click"}get _effectivePointLikePlugin(){switch(this._effectiveConfiguredDrawingMode){case"hybrid":return this._hybridSegmentPlugin;case"freehand":return this._pointLikeFreehandSegmentPlugin;default:return this._simplePointPlugin}}get _simplePointPluginRoot(){return{...this._simplePointPlugin,icon:"pin",localizationKey:"root-point",create:()=>{const e=this._createPlugin(this._simplePointPlugin.uniqueId);return e.enableHelpMessages=!0,e}}}get _textPointPlugin(){const e=Symbol.for("esri-builtin-plugin-text-point");return{uniqueId:e,localizationKey:"root-text",kind:["vertex"],geometryType:"point",icon:"add-text",legacyCreateTool:"text",create:()=>this._createPlugin(e),[Symbol.toStringTag]:"Text"}}get _multipointPlugin(){const e={...this._simplePointPlugin,localizationKey:"leaf-point",icon:"point",hidden:!0},i=Symbol.for("esri-builtin-plugin-multipoint");return{uniqueId:i,localizationKey:"root-multipoint",kind:["part"],geometryType:"multipoint",icon:"pins",legacyCreateTool:"multipoint",excludedViews:["3d"],create:()=>this._createPlugin(i),availableDownstreamPlugins:[e],defaultDownstreamPlugin:e,[Symbol.toStringTag]:"Multipoint"}}get _freehandPlugin(){const e=Symbol.for("esri-builtin-plugin-freehand");return{uniqueId:e,localizationKey:"leaf-freehand",kind:["vertex","section","part"],geometryType:"polyline",icon:"freehand",legacyCreateTool:"freehandPolyline",create:()=>{const i=this._createPlugin(e);return i.completeOnDragEnd=!0,i.snappingBehavior="when-not-capturing",i},[Symbol.toStringTag]:"Freehand"}}get _bezierPlugin(){const e=Symbol.for("esri-builtin-plugin-bezier-segment");return{uniqueId:e,localizationKey:"leaf-bezier",kind:["vertex","section"],geometryType:"point",curveTypes:["cubic-bezier"],icon:"bezier-curve",excludedViews:["3d"],create:()=>this._createPlugin(e),[Symbol.toStringTag]:"Bezier"}}get _tangentArcPlugin(){const e=Symbol.for("esri-builtin-plugin-tangent-arc-segment");return{uniqueId:e,localizationKey:"leaf-tangent-arc",kind:["vertex","section"],geometryType:"point",curveTypes:["circular-arc"],icon:"arc-segment",excludedViews:["3d"],create:()=>this._createPlugin(e),availableDownstreamPlugins:[],[Symbol.toStringTag]:"Tangent Arc"}}get _endpointArcPlugin(){const e=Symbol.for("esri-builtin-plugin-circular-arc-segment-end-first");return{uniqueId:e,localizationKey:"leaf-endpoint-arc",kind:["vertex","section"],geometryType:"point",curveTypes:["circular-arc"],icon:"end-point-arc-segment",excludedViews:["3d"],create:()=>{const i=this._createPlugin(e);return i.arcDrawingMode="end-first",i},availableDownstreamPlugins:[],[Symbol.toStringTag]:"Endpoint Arc"}}get _interiorArcPlugin(){const e=Symbol.for("esri-builtin-plugin-circular-arc-segment-interior-first");return{uniqueId:e,localizationKey:"leaf-circular-arc",kind:["vertex","section"],geometryType:"point",curveTypes:["circular-arc"],icon:"arc-segment",excludedViews:["3d"],create:()=>{const i=this._createPlugin(e);return i.arcDrawingMode="interior-first",i},availableDownstreamPlugins:[],[Symbol.toStringTag]:"Interior Arc"}}get _singlePartPolylinePlugin(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("freehandPolyline")&&!1!==e?.freehandPolyline,n=!this._isExcludedByAvailableCreateTools("polyline")&&!1!==e?.polyline,l="freehand"===this._effectiveConfiguredDrawingMode&&i?this._simplePointPlugin:this._effectivePointLikePlugin,o=Symbol.for("esri-builtin-plugin-simple-polyline");return{uniqueId:o,localizationKey:"root-polyline",kind:["section","part"],geometryType:"polyline",legacyCreateTool:"polyline",icon:n?"line":"freehand",create:()=>this._createPlugin(o),availableDownstreamPlugins:n?[l,i?this._freehandPlugin:null,this._bezierPlugin,this._tangentArcPlugin,this._interiorArcPlugin,this._endpointArcPlugin].filter(t):[i?this._freehandPlugin:null].filter(t),defaultDownstreamPlugin:n?l:this._freehandPlugin,[Symbol.toStringTag]:"Polyline"}}get _singlePartPolygonPlugin(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("freehandPolygon")&&!1!==e?.freehandPolygon,n=!this._isExcludedByAvailableCreateTools("polygon")&&!1!==e?.polygon,l="freehand"===this._effectiveConfiguredDrawingMode&&i?this._simplePointPlugin:this._effectivePointLikePlugin,o=Symbol.for("esri-builtin-plugin-simple-polygon");return{uniqueId:o,localizationKey:"root-polygon",kind:["section","part"],geometryType:"polygon",legacyCreateTool:"polygon",icon:n?"polygon":"freehand-area",create:()=>this._createPlugin(o),availableDownstreamPlugins:n?[l,i?this._freehandPlugin:null,this._bezierPlugin,this._tangentArcPlugin,this._interiorArcPlugin,this._endpointArcPlugin].filter(t):[i?this._freehandPlugin:null].filter(t),defaultDownstreamPlugin:n?l:this._freehandPlugin,[Symbol.toStringTag]:"Polygon"}}get _rectanglePlugin(){const e=Symbol.for("esri-builtin-plugin-simple-rectangle");return{uniqueId:e,localizationKey:"root-rectangle",kind:["part"],geometryType:"polygon",icon:"rectangle",legacyCreateTool:"rectangle",create:()=>this._createPlugin(e),[Symbol.toStringTag]:"Rectangle"}}get _circlePlugin(){const e=Symbol.for("esri-builtin-plugin-simple-ellipse");return{uniqueId:e,localizationKey:"root-circle",kind:["part"],geometryType:"polygon",icon:"circle",legacyCreateTool:"circle",create:()=>{const i=this._createPlugin(e);return i.shapeType="circle",i.defaultUniform=!0,i.defaultCentered=!0,i},[Symbol.toStringTag]:"Circle"}}set sketch(e){this._set("sketch",e)}set sketchViewModel(e){this._overrideIfSome("sketchViewModel",e)}get sketchViewModel(){return this.sketch?.viewModel}get effectiveRootPoint(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.point&&!this._isExcludedByAvailableCreateTools("point")?this._simplePointPluginRoot:null}get effectiveRootText(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.text&&!this._isExcludedByAvailableCreateTools("text")?this._textPointPlugin:null}get effectiveRootMultipoint(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.multipoint&&!this._isExcludedByAvailableCreateTools("multipoint")&&"3d"!==this.sketchViewModel?.view?.type?this._multipointPlugin:null}get effectiveRootPolyline(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("polyline")&&!1!==e?.polyline,t=!this._isExcludedByAvailableCreateTools("freehandPolyline")&&!1!==e?.freehandPolyline;return i||t?this._singlePartPolylinePlugin:null}get effectiveRootPolygon(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("polygon")&&!1!==e?.polygon,t=!this._isExcludedByAvailableCreateTools("freehandPolygon")&&!1!==e?.freehandPolygon;return i||t?this._singlePartPolygonPlugin:null}get effectiveRootRectangle(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.rectangle&&!this._isExcludedByAvailableCreateTools("rectangle")?this._rectanglePlugin:null}get effectiveRootCircle(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.circle&&!this._isExcludedByAvailableCreateTools("circle")?this._circlePlugin:null}get availablePlugins(){const e=[this.effectiveRootPoint,this.effectiveRootText,this.effectiveRootMultipoint,this.effectiveRootPolyline,this.effectiveRootPolygon,this.effectiveRootRectangle,this.effectiveRootCircle].filter(t),i=this.sketch?.availableCreateTools;if(!i)return e;const n=e=>{if(!e.legacyCreateTool)return Number.MAX_SAFE_INTEGER;const t=i.indexOf(e.legacyCreateTool);return-1===t?Number.MAX_SAFE_INTEGER:t};return e.map((e,i)=>({plugin:e,index:i,order:n(e)})).sort((e,i)=>e.order-i.order||e.index-i.index).map(({plugin:e})=>e)}get loaded(){return null!=this._pluginConstructors}getPluginsEquivalentToCreateTool(e,i){switch(e){case"text":return[this._textPointPlugin];case"point":return[this._simplePointPluginRoot];case"rectangle":return[this._rectanglePlugin];case"circle":return[this._circlePlugin];case"freehandPolyline":return[this._singlePartPolylinePlugin,this._freehandPlugin];case"freehandPolygon":return[this._singlePartPolygonPlugin,this._freehandPlugin];case"polyline":if("freehand"===i){const e=this.sketch?.viewModel?.defaultCreateOptions?.mode;return"freehand"!==e?[this._singlePartPolylinePlugin,this._freehandPlugin]:[this._singlePartPolylinePlugin,this._effectivePointLikePlugin]}return"hybrid"===i?[this._singlePartPolylinePlugin,this._hybridSegmentPlugin]:[this._singlePartPolylinePlugin,this._simplePointPlugin];case"polygon":if("freehand"===i){const e=this.sketch?.viewModel?.defaultCreateOptions?.mode;return"freehand"!==e?[this._singlePartPolygonPlugin,this._freehandPlugin]:[this._singlePartPolygonPlugin,this._effectivePointLikePlugin]}return"hybrid"===i?[this._singlePartPolygonPlugin,this._hybridSegmentPlugin]:[this._singlePartPolygonPlugin,this._simplePointPlugin];case"multipoint":return[this._multipointPlugin];default:return null}}getDrawingModeEquivalentToPluginStack(e){const i=e.at(-1);if(i===this._freehandPlugin)return"freehand";return i===this._hybridSegmentPlugin||i===this._rectanglePlugin||i===this._circlePlugin?"hybrid":"click"}async makeRenderer(e={}){const i=this.sketchViewModel;if(!i?.view)return null;const{abortOptions:t,useTextSymbol:n,customSymbol:l}=e;return"2d"===i.view.type?await this._makeDrawToolRenderer2D({view:i.view,svm:i,useTextSymbol:n,customSymbol:l,abortOptions:t}):await this._makeDrawToolRenderer3D({view:i.view,svm:i,useTextSymbol:n,abortOptions:t})}async loadPlugins(){if(!this.loaded)return this._pluginLoadPromise||(this._pluginLoadPromise=(async()=>{const[{PointPlugin:e},{MultipointPlugin:i},{PolylinePlugin:t},{PolygonPlugin:n},{FreehandSegmentPlugin:l},{BezierSegmentPlugin:o},{TangentArcSegmentPlugin:r},{CircularArcSegmentPlugin:s},{ShapePlugin:a}]=await Promise.all([import("../../../views/draw/plugins/PointPlugin.js"),import("../../../views/draw/plugins/MultipointPlugin.js"),import("../../../views/draw/plugins/PolylinePlugin.js"),import("../../../views/draw/plugins/PolygonPlugin.js"),import("../../../views/draw/plugins/FreehandSegmentPlugin.js"),import("../../../views/draw/plugins/BezierSegmentPlugin.js"),import("../../../views/draw/plugins/TangentArcSegmentPlugin.js"),import("../../../views/draw/plugins/CircularArcSegmentPlugin.js"),import("../../../views/draw/plugins/ShapePlugin.js")]);this._pluginConstructors=new Map([[Symbol.for("esri-builtin-plugin-leaf-point"),e],[Symbol.for("esri-builtin-plugin-text-point"),e],[Symbol.for("esri-builtin-plugin-multipoint"),i],[Symbol.for("esri-builtin-plugin-freehand"),l],[Symbol.for("esri-builtin-plugin-bezier-segment"),o],[Symbol.for("esri-builtin-plugin-tangent-arc-segment"),r],[Symbol.for("esri-builtin-plugin-circular-arc-segment-end-first"),s],[Symbol.for("esri-builtin-plugin-circular-arc-segment-interior-first"),s],[Symbol.for("esri-builtin-plugin-simple-polyline"),t],[Symbol.for("esri-builtin-plugin-simple-polygon"),n],[Symbol.for("esri-builtin-plugin-simple-rectangle"),a],[Symbol.for("esri-builtin-plugin-simple-ellipse"),a]])})().catch(e=>{throw this._pluginLoadPromise=null,e})),this._pluginLoadPromise}_isExcludedByAvailableCreateTools(e){return!!this.sketch&&!this.sketch.availableCreateTools?.includes(e)}_createPlugin(e){const i=this._pluginConstructors?.get(e);if(!i)throw new n("Sketch:PluginManager","Plugin implementations are not loaded. Call loadPlugins() before creating plugins.");return new i}async _makeDrawToolRenderer2D(e){const{DrawToolRenderer2D:i}=await import("../../../views/2d/interactive/editingTools/draw/DrawToolRenderer2D.js"),{view:t,svm:n,useTextSymbol:l,abortOptions:o}=e;r(o);const s=l?n.textSymbol??n.pointSymbol:n.pointSymbol,a=new i({symbolOverrides:{polyline:{outputGeometry:{default:e.customSymbol??n.polylineSymbol},outline:{active:n.activeLineSymbol??void 0}},polygon:{outputGeometry:{default:e.customSymbol??n.activeFillSymbol??n.polygonSymbol}},point:{outputGeometry:{default:e.customSymbol??s},vertex:{default:n.vertexSymbol,active:n.activeVertexSymbol??void 0}}},view:t}),u=this._setupSymbolWatcher(a,n,!!l,!!e.customSymbol);return a.addHandles(u),a}async _makeDrawToolRenderer3D(e){const{view:i,svm:t,useTextSymbol:n,abortOptions:l}=e;return o.getLogger(this).warnOnce("Using DrawToolRenderer2D in 3D view. A 3D-specific implementation of DrawToolRenderer is not yet available."),this._makeDrawToolRenderer2D({view:i,svm:t,useTextSymbol:n,abortOptions:l})}_setupSymbolWatcher(e,i,t,n){const o=(i,t,n)=>(l,o)=>{l!==o&&e.overrideSymbol({symbol:l,geometryType:i,role:t,state:n})},r=[s(()=>i.activeLineSymbol,o("polyline","outline","active")),s(()=>i.vertexSymbol,o("point","vertex")),s(()=>i.activeVertexSymbol,o("point","vertex","active"))];return n||r.push(s(()=>i.polylineSymbol,o("polyline","outputGeometry")),s(()=>i.activeFillSymbol??i.polygonSymbol,o("polygon","outputGeometry")),s(()=>t?i.textSymbol??i.pointSymbol:i.pointSymbol,o("point","outputGeometry"))),l(r)}};e([a()],g.prototype,"_simplePointPlugin",null),e([a()],g.prototype,"_hybridSegmentPlugin",null),e([a()],g.prototype,"_pointLikeFreehandSegmentPlugin",null),e([a()],g.prototype,"_effectiveConfiguredDrawingMode",null),e([a()],g.prototype,"_effectivePointLikePlugin",null),e([a()],g.prototype,"_simplePointPluginRoot",null),e([a()],g.prototype,"_textPointPlugin",null),e([a()],g.prototype,"_multipointPlugin",null),e([a()],g.prototype,"_freehandPlugin",null),e([a()],g.prototype,"_bezierPlugin",null),e([a()],g.prototype,"_tangentArcPlugin",null),e([a()],g.prototype,"_endpointArcPlugin",null),e([a()],g.prototype,"_interiorArcPlugin",null),e([a()],g.prototype,"_singlePartPolylinePlugin",null),e([a()],g.prototype,"_singlePartPolygonPlugin",null),e([a()],g.prototype,"_rectanglePlugin",null),e([a()],g.prototype,"_circlePlugin",null),e([a()],g.prototype,"sketch",null),e([a()],g.prototype,"sketchViewModel",null),e([a()],g.prototype,"effectiveRootPoint",null),e([a()],g.prototype,"effectiveRootText",null),e([a()],g.prototype,"effectiveRootMultipoint",null),e([a()],g.prototype,"effectiveRootPolyline",null),e([a()],g.prototype,"effectiveRootPolygon",null),e([a()],g.prototype,"effectiveRootRectangle",null),e([a()],g.prototype,"effectiveRootCircle",null),e([a()],g.prototype,"availablePlugins",null),e([a()],g.prototype,"loaded",null),g=e([u("esri.widgets.Sketch.support.PluginManager")],g);export{g as PluginManager};
|
|
2
|
+
import{__decorate as e}from"tslib";import i from"../../../core/Accessor.js";import{isSome as t}from"../../../core/arrayUtils.js";import n from"../../../core/Error.js";import{handlesGroup as l}from"../../../core/handleUtils.js";import o from"../../../core/Logger.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{freehandSnappingEnabledSettingKey as g,bezierEnableSplineBehaviorSettingKey as c}from"../../../views/draw/support/types.js";let p=class extends i{constructor(e){super(e),this._pluginLoadPromise=null,this._pluginConstructors=null}get _freehandPluginSettings(){return{[g]:{titleLocalizationKey:"settings.freehandSnappingEnabledTitle",descriptionLocalizationKey:"settings.freehandSnappingEnabledDescription",type:"toggle",default:!0}}}get _simplePointPlugin(){const e=Symbol.for("esri-builtin-plugin-leaf-point");return{uniqueId:e,localizationKey:"leaf-point-segment",kind:["vertex"],geometryType:"point",icon:"line-straight",legacyCreateTool:"point",create:()=>this._createPlugin(e),[Symbol.toStringTag]:"Point"}}get _hybridSegmentPlugin(){const e=Symbol.for("esri-builtin-plugin-freehand");return{...this._simplePointPlugin,create:()=>{const i=this._createPlugin(e);return i.completeOnDragEnd=!0,i.snappingBehavior="when-not-capturing",i},settings:this._freehandPluginSettings,[Symbol.toStringTag]:"Hybrid Segment"}}get _pointLikeFreehandSegmentPlugin(){const e=Symbol.for("esri-builtin-plugin-freehand");return{...this._simplePointPlugin,create:()=>{const i=this._createPlugin(e);return i.completeOnDragEnd=!0,i.snappingBehavior="when-not-capturing",i},settings:this._freehandPluginSettings,[Symbol.toStringTag]:"Freehand Segment"}}get _effectiveConfiguredDrawingMode(){return this.sketchViewModel?.defaultCreateOptions?.mode??"click"}get _effectivePointLikePlugin(){switch(this._effectiveConfiguredDrawingMode){case"hybrid":return this._hybridSegmentPlugin;case"freehand":return this._pointLikeFreehandSegmentPlugin;default:return this._simplePointPlugin}}get _simplePointPluginRoot(){return{...this._simplePointPlugin,icon:"pin",localizationKey:"root-point",create:()=>{const e=this._createPlugin(this._simplePointPlugin.uniqueId);return e.enableHelpMessages=!0,e}}}get _textPointPlugin(){const e=Symbol.for("esri-builtin-plugin-text-point");return{uniqueId:e,localizationKey:"root-text",kind:["vertex"],geometryType:"point",icon:"add-text",legacyCreateTool:"text",create:()=>this._createPlugin(e),[Symbol.toStringTag]:"Text"}}get _multipointPlugin(){const e={...this._simplePointPlugin,localizationKey:"leaf-point",icon:"point",hidden:!0},i=Symbol.for("esri-builtin-plugin-multipoint");return{uniqueId:i,localizationKey:"root-multipoint",kind:["part"],geometryType:"multipoint",icon:"pins",legacyCreateTool:"multipoint",excludedViews:["3d"],create:()=>this._createPlugin(i),availableDownstreamPlugins:[e],defaultDownstreamPlugin:e,[Symbol.toStringTag]:"Multipoint"}}get _freehandPlugin(){const e=Symbol.for("esri-builtin-plugin-freehand");return{uniqueId:e,localizationKey:"leaf-freehand",kind:["vertex","section","part"],geometryType:"polyline",icon:"freehand",legacyCreateTool:"freehandPolyline",create:()=>{const i=this._createPlugin(e);return i.completeOnDragEnd=!0,i.snappingBehavior="when-not-capturing",i},settings:this._freehandPluginSettings,[Symbol.toStringTag]:"Freehand"}}get _bezierPlugin(){const e=Symbol.for("esri-builtin-plugin-bezier-segment");return{uniqueId:e,localizationKey:"leaf-bezier",kind:["vertex","section"],geometryType:"point",curveTypes:["cubic-bezier"],icon:"bezier-curve",excludedViews:["3d"],create:()=>this._createPlugin(e),settings:{[c]:{titleLocalizationKey:"settings.bezierEnableSplineBehaviorTitle",descriptionLocalizationKey:"settings.bezierEnableSplineBehaviorDescription",type:"toggle",default:!0}},[Symbol.toStringTag]:"Bezier"}}get _tangentArcPlugin(){const e=Symbol.for("esri-builtin-plugin-tangent-arc-segment");return{uniqueId:e,localizationKey:"leaf-tangent-arc",kind:["vertex","section"],geometryType:"point",curveTypes:["circular-arc"],icon:"arc-segment",excludedViews:["3d"],create:()=>this._createPlugin(e),availableDownstreamPlugins:[],[Symbol.toStringTag]:"Tangent Arc"}}get _endpointArcPlugin(){const e=Symbol.for("esri-builtin-plugin-circular-arc-segment-end-first");return{uniqueId:e,localizationKey:"leaf-endpoint-arc",kind:["vertex","section"],geometryType:"point",curveTypes:["circular-arc"],icon:"end-point-arc-segment",excludedViews:["3d"],create:()=>{const i=this._createPlugin(e);return i.arcDrawingMode="end-first",i},availableDownstreamPlugins:[],[Symbol.toStringTag]:"Endpoint Arc"}}get _interiorArcPlugin(){const e=Symbol.for("esri-builtin-plugin-circular-arc-segment-interior-first");return{uniqueId:e,localizationKey:"leaf-circular-arc",kind:["vertex","section"],geometryType:"point",curveTypes:["circular-arc"],icon:"arc-segment",excludedViews:["3d"],create:()=>{const i=this._createPlugin(e);return i.arcDrawingMode="interior-first",i},availableDownstreamPlugins:[],[Symbol.toStringTag]:"Interior Arc"}}get _singlePartPolylinePlugin(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("freehandPolyline")&&!1!==e?.freehandPolyline,n=!this._isExcludedByAvailableCreateTools("polyline")&&!1!==e?.polyline,l="freehand"===this._effectiveConfiguredDrawingMode&&i?this._simplePointPlugin:this._effectivePointLikePlugin,o=Symbol.for("esri-builtin-plugin-simple-polyline");return{uniqueId:o,localizationKey:"root-polyline",kind:["section","part"],geometryType:"polyline",legacyCreateTool:"polyline",icon:n?"line":"freehand",create:()=>this._createPlugin(o),availableDownstreamPlugins:n?[l,i?this._freehandPlugin:null,this._bezierPlugin,this._tangentArcPlugin,this._interiorArcPlugin,this._endpointArcPlugin].filter(t):[i?this._freehandPlugin:null].filter(t),defaultDownstreamPlugin:n?l:this._freehandPlugin,[Symbol.toStringTag]:"Polyline"}}get _singlePartPolygonPlugin(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("freehandPolygon")&&!1!==e?.freehandPolygon,n=!this._isExcludedByAvailableCreateTools("polygon")&&!1!==e?.polygon,l="freehand"===this._effectiveConfiguredDrawingMode&&i?this._simplePointPlugin:this._effectivePointLikePlugin,o=Symbol.for("esri-builtin-plugin-simple-polygon");return{uniqueId:o,localizationKey:"root-polygon",kind:["section","part"],geometryType:"polygon",legacyCreateTool:"polygon",icon:n?"polygon":"freehand-area",create:()=>this._createPlugin(o),availableDownstreamPlugins:n?[l,i?this._freehandPlugin:null,this._bezierPlugin,this._tangentArcPlugin,this._interiorArcPlugin,this._endpointArcPlugin].filter(t):[i?this._freehandPlugin:null].filter(t),defaultDownstreamPlugin:n?l:this._freehandPlugin,[Symbol.toStringTag]:"Polygon"}}get _rectanglePlugin(){const e=Symbol.for("esri-builtin-plugin-simple-rectangle");return{uniqueId:e,localizationKey:"root-rectangle",kind:["part"],geometryType:"polygon",icon:"rectangle",legacyCreateTool:"rectangle",create:()=>this._createPlugin(e),[Symbol.toStringTag]:"Rectangle"}}get _circlePlugin(){const e=Symbol.for("esri-builtin-plugin-simple-ellipse");return{uniqueId:e,localizationKey:"root-circle",kind:["part"],geometryType:"polygon",icon:"circle",legacyCreateTool:"circle",create:()=>{const i=this._createPlugin(e);return i.shapeType="circle",i.defaultUniform=!0,i.defaultCentered=!0,i},[Symbol.toStringTag]:"Circle"}}set sketch(e){this._set("sketch",e)}set sketchViewModel(e){this._overrideIfSome("sketchViewModel",e)}get sketchViewModel(){return this.sketch?.viewModel}get effectiveRootPoint(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.point&&!this._isExcludedByAvailableCreateTools("point")?this._simplePointPluginRoot:null}get effectiveRootText(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.text&&!this._isExcludedByAvailableCreateTools("text")?this._textPointPlugin:null}get effectiveRootMultipoint(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.multipoint&&!this._isExcludedByAvailableCreateTools("multipoint")&&"3d"!==this.sketchViewModel?.view?.type?this._multipointPlugin:null}get effectiveRootPolyline(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("polyline")&&!1!==e?.polyline,t=!this._isExcludedByAvailableCreateTools("freehandPolyline")&&!1!==e?.freehandPolyline;return i||t?this._singlePartPolylinePlugin:null}get effectiveRootPolygon(){const e=this.sketch?.visibleElements.createTools,i=!this._isExcludedByAvailableCreateTools("polygon")&&!1!==e?.polygon,t=!this._isExcludedByAvailableCreateTools("freehandPolygon")&&!1!==e?.freehandPolygon;return i||t?this._singlePartPolygonPlugin:null}get effectiveRootRectangle(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.rectangle&&!this._isExcludedByAvailableCreateTools("rectangle")?this._rectanglePlugin:null}get effectiveRootCircle(){const e=this.sketch?.visibleElements.createTools;return!1!==e?.circle&&!this._isExcludedByAvailableCreateTools("circle")?this._circlePlugin:null}get availablePlugins(){const e=[this.effectiveRootPoint,this.effectiveRootText,this.effectiveRootMultipoint,this.effectiveRootPolyline,this.effectiveRootPolygon,this.effectiveRootRectangle,this.effectiveRootCircle].filter(t),i=this.sketch?.availableCreateTools;if(!i)return e;const n=e=>{if(!e.legacyCreateTool)return Number.MAX_SAFE_INTEGER;const t=i.indexOf(e.legacyCreateTool);return-1===t?Number.MAX_SAFE_INTEGER:t};return e.map((e,i)=>({plugin:e,index:i,order:n(e)})).sort((e,i)=>e.order-i.order||e.index-i.index).map(({plugin:e})=>e)}get visiblePluginsFlat(){if(this.sketchViewModel?.isUsingLegacyCreateTools)return[];const e=this.sketchViewModel?.view?.type??"2d",i=new Set,t=[],n=l=>{l&&!l.excludedViews?.includes(e)&&(i.has(l.uniqueId)||(i.add(l.uniqueId),l.hidden||t.push(l)),l.availableDownstreamPlugins?.forEach(e=>n(e)))};return this.availablePlugins.forEach(e=>n(e)),t}get loaded(){return null!=this._pluginConstructors}getPluginsEquivalentToCreateTool(e,i){switch(e){case"text":return[this._textPointPlugin];case"point":return[this._simplePointPluginRoot];case"rectangle":return[this._rectanglePlugin];case"circle":return[this._circlePlugin];case"freehandPolyline":return[this._singlePartPolylinePlugin,this._freehandPlugin];case"freehandPolygon":return[this._singlePartPolygonPlugin,this._freehandPlugin];case"polyline":if("freehand"===i){const e=this.sketch?.viewModel?.defaultCreateOptions?.mode;return"freehand"!==e?[this._singlePartPolylinePlugin,this._freehandPlugin]:[this._singlePartPolylinePlugin,this._effectivePointLikePlugin]}return"hybrid"===i?[this._singlePartPolylinePlugin,this._hybridSegmentPlugin]:[this._singlePartPolylinePlugin,this._simplePointPlugin];case"polygon":if("freehand"===i){const e=this.sketch?.viewModel?.defaultCreateOptions?.mode;return"freehand"!==e?[this._singlePartPolygonPlugin,this._freehandPlugin]:[this._singlePartPolygonPlugin,this._effectivePointLikePlugin]}return"hybrid"===i?[this._singlePartPolygonPlugin,this._hybridSegmentPlugin]:[this._singlePartPolygonPlugin,this._simplePointPlugin];case"multipoint":return[this._multipointPlugin];default:return null}}getDrawingModeEquivalentToPluginStack(e){const i=e.at(-1);if(i===this._freehandPlugin)return"freehand";return i===this._hybridSegmentPlugin||i===this._rectanglePlugin||i===this._circlePlugin?"hybrid":"click"}async makeRenderer(e={}){const i=this.sketchViewModel;if(!i?.view)return null;const{abortOptions:t,useTextSymbol:n,customSymbol:l}=e;return"2d"===i.view.type?await this._makeDrawToolRenderer2D({view:i.view,svm:i,useTextSymbol:n,customSymbol:l,abortOptions:t}):await this._makeDrawToolRenderer3D({view:i.view,svm:i,useTextSymbol:n,abortOptions:t})}async loadPlugins(){if(!this.loaded)return this._pluginLoadPromise||(this._pluginLoadPromise=(async()=>{const[{PointPlugin:e},{MultipointPlugin:i},{PolylinePlugin:t},{PolygonPlugin:n},{FreehandSegmentPlugin:l},{BezierSegmentPlugin:o},{TangentArcSegmentPlugin:r},{CircularArcSegmentPlugin:s},{ShapePlugin:a}]=await Promise.all([import("../../../views/draw/plugins/PointPlugin.js"),import("../../../views/draw/plugins/MultipointPlugin.js"),import("../../../views/draw/plugins/PolylinePlugin.js"),import("../../../views/draw/plugins/PolygonPlugin.js"),import("../../../views/draw/plugins/FreehandSegmentPlugin.js"),import("../../../views/draw/plugins/BezierSegmentPlugin.js"),import("../../../views/draw/plugins/TangentArcSegmentPlugin.js"),import("../../../views/draw/plugins/CircularArcSegmentPlugin.js"),import("../../../views/draw/plugins/ShapePlugin.js")]);this._pluginConstructors=new Map([[Symbol.for("esri-builtin-plugin-leaf-point"),e],[Symbol.for("esri-builtin-plugin-text-point"),e],[Symbol.for("esri-builtin-plugin-multipoint"),i],[Symbol.for("esri-builtin-plugin-freehand"),l],[Symbol.for("esri-builtin-plugin-bezier-segment"),o],[Symbol.for("esri-builtin-plugin-tangent-arc-segment"),r],[Symbol.for("esri-builtin-plugin-circular-arc-segment-end-first"),s],[Symbol.for("esri-builtin-plugin-circular-arc-segment-interior-first"),s],[Symbol.for("esri-builtin-plugin-simple-polyline"),t],[Symbol.for("esri-builtin-plugin-simple-polygon"),n],[Symbol.for("esri-builtin-plugin-simple-rectangle"),a],[Symbol.for("esri-builtin-plugin-simple-ellipse"),a]])})().catch(e=>{throw this._pluginLoadPromise=null,e})),this._pluginLoadPromise}_isExcludedByAvailableCreateTools(e){return!!this.sketch&&!this.sketch.availableCreateTools?.includes(e)}_createPlugin(e){const i=this._pluginConstructors?.get(e);if(!i)throw new n("Sketch:PluginManager","Plugin implementations are not loaded. Call loadPlugins() before creating plugins.");return new i}async _makeDrawToolRenderer2D(e){const{DrawToolRenderer2D:i}=await import("../../../views/2d/interactive/editingTools/draw/DrawToolRenderer2D.js"),{view:t,svm:n,useTextSymbol:l,abortOptions:o}=e;r(o);const s=l?n.textSymbol??n.pointSymbol:n.pointSymbol,a=new i({symbolOverrides:{polyline:{outputGeometry:{default:e.customSymbol??n.polylineSymbol},outline:{active:n.activeLineSymbol??void 0}},polygon:{outputGeometry:{default:e.customSymbol??n.activeFillSymbol??n.polygonSymbol}},point:{outputGeometry:{default:e.customSymbol??s},vertex:{default:n.vertexSymbol,active:n.activeVertexSymbol??void 0}}},view:t}),u=this._setupSymbolWatcher(a,n,!!l,!!e.customSymbol);return a.addHandles(u),a}async _makeDrawToolRenderer3D(e){const{view:i,svm:t,useTextSymbol:n,abortOptions:l}=e;return o.getLogger(this).warnOnce("Using DrawToolRenderer2D in 3D view. A 3D-specific implementation of DrawToolRenderer is not yet available."),this._makeDrawToolRenderer2D({view:i,svm:t,useTextSymbol:n,abortOptions:l})}_setupSymbolWatcher(e,i,t,n){const o=(i,t,n)=>(l,o)=>{l!==o&&e.overrideSymbol({symbol:l,geometryType:i,role:t,state:n})},r=[s(()=>i.activeLineSymbol,o("polyline","outline","active")),s(()=>i.vertexSymbol,o("point","vertex")),s(()=>i.activeVertexSymbol,o("point","vertex","active"))];return n||r.push(s(()=>i.polylineSymbol,o("polyline","outputGeometry")),s(()=>i.activeFillSymbol??i.polygonSymbol,o("polygon","outputGeometry")),s(()=>t?i.textSymbol??i.pointSymbol:i.pointSymbol,o("point","outputGeometry"))),l(r)}};e([a()],p.prototype,"_freehandPluginSettings",null),e([a()],p.prototype,"_simplePointPlugin",null),e([a()],p.prototype,"_hybridSegmentPlugin",null),e([a()],p.prototype,"_pointLikeFreehandSegmentPlugin",null),e([a()],p.prototype,"_effectiveConfiguredDrawingMode",null),e([a()],p.prototype,"_effectivePointLikePlugin",null),e([a()],p.prototype,"_simplePointPluginRoot",null),e([a()],p.prototype,"_textPointPlugin",null),e([a()],p.prototype,"_multipointPlugin",null),e([a()],p.prototype,"_freehandPlugin",null),e([a()],p.prototype,"_bezierPlugin",null),e([a()],p.prototype,"_tangentArcPlugin",null),e([a()],p.prototype,"_endpointArcPlugin",null),e([a()],p.prototype,"_interiorArcPlugin",null),e([a()],p.prototype,"_singlePartPolylinePlugin",null),e([a()],p.prototype,"_singlePartPolygonPlugin",null),e([a()],p.prototype,"_rectanglePlugin",null),e([a()],p.prototype,"_circlePlugin",null),e([a()],p.prototype,"sketch",null),e([a()],p.prototype,"sketchViewModel",null),e([a()],p.prototype,"effectiveRootPoint",null),e([a()],p.prototype,"effectiveRootText",null),e([a()],p.prototype,"effectiveRootMultipoint",null),e([a()],p.prototype,"effectiveRootPolyline",null),e([a()],p.prototype,"effectiveRootPolygon",null),e([a()],p.prototype,"effectiveRootRectangle",null),e([a()],p.prototype,"effectiveRootCircle",null),e([a()],p.prototype,"availablePlugins",null),e([a()],p.prototype,"visiblePluginsFlat",null),e([a()],p.prototype,"loaded",null),p=e([u("esri.widgets.Sketch.support.PluginManager")],p);export{p as PluginManager};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import i from"../../../core/ReactiveMap.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";let n=class extends e{constructor(){super(...arguments),this._values=new i,this.availablePlugins=()=>[]}get availableSettingDefinitions(){const t=new Map;for(const e of this.availablePlugins()){const i=e.settings;if(i)for(const e of Object.getOwnPropertySymbols(i)){const s=i[e];s&&t.set(e,s)}}return t}get hasSettings(){return this.availableSettingDefinitions.size>0}get settings(){return Array.from(this.availableSettingDefinitions.entries()).map(([t,e])=>{const i=this.getValue(t);return null==i?null:{settingKey:t,definition:e,value:i}}).filter(t=>null!=t)}getValue(t){const e=this.availableSettingDefinitions.get(t);if(e)return this._values.get(t)??e.default}getDefinition(t){return this.availableSettingDefinitions.get(t)}setValue(t,e){this.availableSettingDefinitions.get(t)&&"boolean"==typeof e&&this._values.get(t)!==e&&this._values.set(t,e)}};t([s()],n.prototype,"availablePlugins",void 0),t([s()],n.prototype,"availableSettingDefinitions",null),t([s()],n.prototype,"hasSettings",null),t([s()],n.prototype,"settings",null),n=t([o("esri.widgets.Sketch.support.SettingsManager")],n);export{n as SettingsManager};
|
package/widgets/Sketch.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as i}from"../core/arrayUtils.js";import{deprecateWidget as o}from"../core/deprecate.js";import{handlesGroup as n}from"../core/handleUtils.js";import l from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as r}from"../core/maybe.js";import{ignoreAbortErrors as a}from"../core/promiseUtils.js";import{watch as c,syncAndInitial as p,when as d}from"../core/reactiveUtils.js";import{property as h,subclass as u}from"../core/accessorSupport/decorators.js";import{symbolTypes as m}from"../symbols/support/typeUtils.js";import g from"../views/interactive/sketch/SketchLabelOptions.js";import v from"../views/interactive/sketch/SketchTooltipOptions.js";import f from"../views/interactive/sketch/SketchValueOptions.js";import _ from"./Widget.js";import y from"./Sketch/SketchViewModel.js";import b from"./Sketch/VisibleElements.js";import w from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import S from"./support/SelectionToolbar.js";import C from"./support/SketchTooltipControls.js";import M from"./support/SnappingControls.js";import{tsx as O,messageBundle as P,vmEvent as k}from"./support/widget.js";import I from"./support/SelectionToolbar/VisibleElements.js";import L from"./support/SketchTooltipControls/VisibleElements.js";const R="esri-sketch",E="settings-menu-action",W={base:R,vertical:`${R}--vertical`,docked:`${R}-bar`,floating:`${R}-pad`,chipHorizontal:`${R}__selection-count-chip--horizontal`,chipVertical:`${R}__selection-count-chip--vertical`,chipVerticalSmall:`${R}__selection-count-chip--vertical--s`,popoverWrapper:`${R}__popover-wrapper`,simplificationWarningAction:`${R}__simplification-warning-action`,simplificationWarningLoader:`${R}__simplification-warning-loader`,simplificationWarningContent:`${R}__simplification-warning-content`,simplificationWarningDescription:`${R}__simplification-warning-description`,simplificationWarningCancelButton:`${R}__simplification-warning-cancel-button`},x={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let D=class extends _{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new b,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._simplificationPopoverOpen=!1,this._showSimplificationWarning=!1,this._simplificationPopoverElement=null,this._simplificationPopoverReferenceElement=null,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{o(l.getLogger(this),"Sketch","arcgis-sketch",{version:"5.0"})}),this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new y({creationMode:e?.creationMode??"continuous",useLegacyCreateTools:e?.useLegacyCreateTools??"3d"===e?.view?.type})),this.viewModel.pluginManager.sketch=this}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){const{layer:e,view:t}=this,i="2d"===t?.type,o=new S({persistSelection:!1,visibleElements:new I({chip:!1,lassoTool:i,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:i}),view:t,sources:e?[e]:null,scale:this.scale,disabled:"disabled"===this.state||this._hasLongRunningOperation});this.addHandles([c(()=>this.viewModel,e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=n([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),c(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),c(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),c(()=>e.state,()=>{this.notifyChange("state"),this._syncSelectionToolbarDisabledState()}),c(()=>e.geometrySimplificationInProgress,e=>{this._syncSelectionToolbarDisabledState(),e&&(this._showSimplificationWarning=!0)})]))},p),d(()=>o.activeOperation,()=>{this._clearCompletedSimplificationWarningForToolbarInteraction(),this.viewModel.cancel(),this._activeCustomToolOptions=null}),o.on("complete",e=>this._onSelectionOperationComplete(e)),c(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(o.visibleElements,e)},p)]),this._selectionToolbar=o,this._syncSelectionToolbarDisabledState()}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const{availableCreateTools:t}=this,{activeTool:i,activeCreateToolDrawMode:o}=this.viewModel;return"polygon"===i&&"freehand"===o&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===i&&"freehand"===o&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&r(t),t?.pluginManager?.sketch===this&&(t.pluginManager.sketch=null),this._set("viewModel",e),e.pluginManager.sketch=this)}get useLegacyCreateTools(){return this.viewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.viewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.viewModel.isUsingLegacyCreateTools}get _effectiveAvailableCreateTools(){if(this.viewModel.effectiveAvailablePlugins?.length)return this.viewModel.effectiveAvailablePlugins;const{availableCreateTools:e,view:t,visibleElements:i}=this,o=e?.filter(e=>!!i.createTools?.[e]);return"3d"===t?.type?o?.filter(e=>"multipoint"!==e):o}create(e,t,i){const o=i?.createOptions??t;return this._showSimplificationWarning&&!this._hasLongRunningOperation&&this._hideSimplificationWarning(),this._activeCustomToolOptions=i,a(this.viewModel.create(e,o))}update(e,t){return a(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1,this._simplificationPopoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:i}=this;return O("div",null,O("div",{classes:{[W.base]:!0,[W.floating]:"floating"===e,[W.docked]:"docked"===e,[W.vertical]:"vertical"===t}},O(w,{barStyle:e,layout:t,scale:i},this._renderSelectionSetItemGroupInline(),this._renderSelectionToolsOrBack(),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup(),this._renderSimplificationWarningItemGroupInline()),this._renderSelectionSetToolbar(),this._renderSimplificationWarningToolbar(),this._renderSettingsMenuPopover(),this._renderSimplificationWarningPopover()))}_renderSimplificationWarningToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSimplificationWarningItemGroup();return e?O(w,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSimplificationWarningItemGroupInline(){if("separate"!==this.contextualToolLocation)return this._renderSimplificationWarningItemGroup()}_renderSelectionToolsOrBack(){if(!this.viewModel.isUsingLegacyCreateTools&&this.viewModel.firstPluginWithSwappableLeaf)return this._renderBackButton();const e=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),e?.map(e=>this._renderToolbarItem(e)))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:i,viewModel:o,visibleElements:n}=this;if(!this._calcitePopoverReferenceElement)return;const l={directionModePicker:n.directionModePicker,labelsToggle:n.labelsToggle,tooltipsToggle:n.tooltipsToggle},s="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,key:`${this.id}-settings`,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:s,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:W.popoverWrapper},Object.values(l).includes(!0)?O(C,{sketchOptions:o.sketchOptions,view:i,visibleElements:new L(l)}):void 0,n.snappingControls&&i&&t?O(M,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:i,visibleElements:n.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(w,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSimplificationWarningItemGroup(){if(!this._showSimplificationWarning)return;const{messages:e,viewModel:t}=this,{finalizingDrawingCompleteTitle:i,finalizingDrawingTitle:o}=e,n=t.geometrySimplificationInProgress,l=n?o:i,s=n?void 0:"exclamation-mark-triangle",r=`${this.id}__simplification-warning-action`;return O("div",{"group-kind":"measured-content-group",key:"simplification-warning-group",slot:"actions-end"},O("calcite-action",{active:this._simplificationPopoverOpen,afterCreate:e=>this._simplificationPopoverReferenceElement=e,afterRemoved:()=>this._simplificationPopoverReferenceElement=null,afterUpdate:e=>this._simplificationPopoverReferenceElement=e,class:W.simplificationWarningAction,"data-testid":"simplification-warning",disabled:"disabled"===this.state,icon:s,id:r,key:"simplification-warning",onclick:()=>this._simplificationPopoverOpen=!this._simplificationPopoverOpen,scale:this.scale,text:l,title:l},n?O("calcite-loader",{class:W.simplificationWarningLoader,inline:!0,label:e.finalizingDrawing,scale:this.scale,type:"indeterminate"}):void 0))}_renderSimplificationWarningPopover(){if(!this._showSimplificationWarning||!this._simplificationPopoverReferenceElement)return;const{messages:e,messagesCommon:t}=this,{finalizingDrawingCompleteHint:i,finalizingDrawingCompleteTitle:o,finalizingDrawingHint:n,finalizingDrawingTitle:l,simplificationDismiss:s}=e,r=this._hasLongRunningOperation,a=r?l:o,c="l"===this.scale?"l":"s",p="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._simplificationPopoverElement=e,closable:!0,heading:a,key:`${this.id}-simplification`,label:a,open:this._simplificationPopoverOpen,overlayPositioning:"fixed",placement:p,referenceElement:this._simplificationPopoverReferenceElement,scale:c,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforeSimplificationPopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget,this._simplificationPopoverReferenceElement),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:W.simplificationWarningContent},O("div",{class:W.simplificationWarningDescription},r?n:i),r?O("calcite-button",{class:W.simplificationWarningCancelButton,iconStart:"trash",kind:"danger",label:t.cancel,onclick:()=>this.cancel(),scale:this.scale,width:"full"},t.cancel):O("calcite-button",{appearance:"outline",class:W.simplificationWarningCancelButton,iconStart:"check-circle",kind:"brand",label:s,onclick:()=>this._hideSimplificationWarning(),scale:this.scale,width:"full"},s)))}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(i=>{"settings-before"===i.position?t.push(i):"settings-after"===i.position&&e.push(i)});const o=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(i);if(o.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},o)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),i=this.customActions?.filter(e=>"after-selection-set"===e.position),o=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:o,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:o,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),i?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderBackButton(){const{viewModel:e,isUsingLegacyCreateTools:t}=this;if(!t&&e.multiplePluginsActive&&e.firstPluginWithSwappableLeaf&&e.rootPlugins&&(!(e.rootPlugins.length<2&&e.rootPlugins.includes(e.firstPluginWithSwappableLeaf))||this.visibleElements.singlePluginBackButton))return O("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"back-button-group"},O("calcite-action",{disabled:"disabled"===this.state||this._hasLongRunningOperation,icon:"chevron-left",onclick:()=>{this.viewModel?.cancel()},scale:this.scale,text:this.messagesCommon.back}))}_renderCreateToolActionGroup(){const e=this.viewModel.firstPluginWithSwappableLeaf?[]:this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[],t=this._effectiveAvailableCreateTools,i=t?.filter(e=>"string"==typeof e),o=i?.map(e=>this._renderCreateToolItem(e)),n=t?.filter(e=>"string"!=typeof e).map(e=>this._renderCreateToolItem(e));return[o?.length||e?.length||n?.length?O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},o,e,n):void 0]}_renderCreateToolItem(e){return"string"==typeof e?this._renderBuiltInCreateToolItem(e):this._renderDrawToolPluginItem(e)}_renderDrawToolPluginItem(e){const{icon:t,localizationKey:i,uniqueId:o,hidden:n}=e;if(n)return[];const l=this.messages.digitizers,s=l?.[i]??i,r=!this._activeCustomToolOptions&&this.viewModel.drawTool?.pluginStack.some(e=>!e.configuration?.hidden&&e.configuration?.uniqueId===o);return this._renderToolbarItem({id:`${i}-button`,text:s,icon:t,onclick:()=>this._activatePlugin([e]),active:r})}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:x[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:E,text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:i,scale:o,id:n,updateGraphics:{length:l}}=this,s=t(i.selectedCount,{count:l}),r="l"===o?999:99,a=l>r?t(i.selectedCountTruncated,{truncated:r}):l,c="l"!==o&&"vertical"===e,p=c?`${n}-selection-chip-small`:`${n}-selection-chip`;return[c?O("span",{classes:{[W.chipVertical]:!0,[W.chipVerticalSmall]:"s"===this.scale},id:p,tabIndex:0,title:s},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?W.chipHorizontal:W.chipVertical,id:p,kind:"brand",label:s,scale:"l"===o?"m":"s",tabIndex:0,title:"vertical"===e?s:void 0},"vertical"===e?a:s)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:i,disabled:o,onclick:n,active:l,flipRTL:s,afterCreate:r,afterUpdate:a,afterRemoved:c}){const p=`${this.id}-${e}`,d=n?()=>{e!==E&&this._clearCompletedSimplificationWarningForToolbarInteraction(),n.call(this)}:void 0;return[O("calcite-action",{active:l,afterCreate:r,afterRemoved:c,afterUpdate:a,bind:this,"data-testid":e,disabled:o||"disabled"===this.state||this._hasLongRunningOperation,icon:i,iconFlipRtl:s??!1,id:p,key:e,onclick:d,scale:this.scale,text:t,title:t})]}get _hasLongRunningOperation(){return this.viewModel.geometrySimplificationInProgress}_remeasurePopoverSizes(e,t=this._calcitePopoverReferenceElement){try{const i=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),n=i?.style;if(!(i&&o&&n&&this.view?.container?.contains(i)&&t))return;const{bottom:l,top:s}=t.getBoundingClientRect();if("horizontal"===this.layout){const e=l<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(n?.setProperty("--sketch-view-height-offset",l-o.top+"px"),n?.setProperty("--sketch-view-margin-offset","30px")):(n?.setProperty("--sketch-view-height-offset",o.bottom-s+"px"),n?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(n.setProperty("--sketch-view-height-offset","15px"),n.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;n.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(i){l.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",i)}}_activateCreateTool(e,t,i){const o=this._activeCustomToolOptions;if(i||o){if(i?.toolKey===o?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,i)}_activatePlugin(e){this._selectionToolbar?.cancel(),this.viewModel.firstPluginWithSwappableLeaf?(this.viewModel.drawTool?.replaceLeaf(e),this.view?.ready&&this.view.focus()):this._activateCreateTool(e)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:i}=e;if(!e.aborted&&i.length){const e=t.tool,o=i.length>1&&"reshape"===e?"transform":e;this.update(i,{...t,tool:o})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){!this.activeTool||e!==this._popoverElement&&e!==this._simplificationPopoverElement||this.view?.focus()}_beforeSimplificationPopoverClose(e){e===this._simplificationPopoverElement&&(this._simplificationPopoverOpen=!1)}_hideSimplificationWarning(){this._showSimplificationWarning=!1,this._simplificationPopoverOpen=!1}_clearCompletedSimplificationWarningForToolbarInteraction(){this._hasLongRunningOperation||this._hideSimplificationWarning()}_syncSelectionToolbarDisabledState(){this._selectionToolbar&&(this._selectionToolbar.disabled="disabled"===this.state||this._hasLongRunningOperation)}};e([h()],D.prototype,"activeTool",null),e([h({readOnly:!0})],D.prototype,"activeTooltip",null),e([h({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],D.prototype,"availableCreateTools",void 0),e([h({readOnly:!0})],D.prototype,"createGraphic",null),e([h()],D.prototype,"creationMode",null),e([h()],D.prototype,"customToolOptions",void 0),e([h()],D.prototype,"customActions",void 0),e([h()],D.prototype,"defaultCreateOptions",null),e([h()],D.prototype,"defaultUpdateOptions",null),e([h()],D.prototype,"icon",null),e([h()],D.prototype,"label",null),e([h({type:g})],D.prototype,"labelOptions",null),e([h()],D.prototype,"layer",null),e([h({type:["horizontal","vertical"],value:"horizontal"})],D.prototype,"layout",null),e([h({types:m})],D.prototype,"pointSymbol",null),e([h({types:m})],D.prototype,"polygonSymbol",null),e([h({types:m})],D.prototype,"polylineSymbol",null),e([h()],D.prototype,"textSymbol",null),e([h({value:"m"})],D.prototype,"scale",null),e([h()],D.prototype,"toolbarKind",void 0),e([h()],D.prototype,"contextualToolLocation",void 0),e([h()],D.prototype,"groupCollapsePriorities",void 0),e([h()],D.prototype,"groupAllowCollapseOptions",void 0),e([h(),P("esri/widgets/Sketch/t9n/Sketch")],D.prototype,"messages",void 0),e([h(),P("esri/t9n/common")],D.prototype,"messagesCommon",void 0),e([h()],D.prototype,"snappingOptions",null),e([h()],D.prototype,"state",null),e([h({type:v})],D.prototype,"tooltipOptions",null),e([h({readOnly:!0})],D.prototype,"updateGraphics",null),e([h({type:f,nonNullable:!0})],D.prototype,"valueOptions",null),e([h()],D.prototype,"view",null),e([h({type:y}),k(["create","update","undo","redo"])],D.prototype,"viewModel",null),e([h({type:b,nonNullable:!0})],D.prototype,"visibleElements",void 0),e([h()],D.prototype,"useLegacyCreateTools",null),e([h()],D.prototype,"isUsingLegacyCreateTools",null),e([h()],D.prototype,"_effectiveAvailableCreateTools",null),e([h()],D.prototype,"_defaultViewModel",void 0),e([h()],D.prototype,"_activeCustomToolOptions",void 0),e([h()],D.prototype,"_calcitePopoverReferenceElement",void 0),e([h()],D.prototype,"_hasLongRunningOperation",null),e([h()],D.prototype,"_relativeLocation",void 0),e([h()],D.prototype,"_popoverOpen",void 0),e([h()],D.prototype,"_simplificationPopoverOpen",void 0),e([h()],D.prototype,"_showSimplificationWarning",void 0),e([h()],D.prototype,"_simplificationPopoverElement",void 0),e([h()],D.prototype,"_simplificationPopoverReferenceElement",void 0),D=e([u("esri.widgets.Sketch")],D);const B=D;export{B as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as i}from"../core/arrayUtils.js";import{deprecateWidget as o}from"../core/deprecate.js";import{handlesGroup as n}from"../core/handleUtils.js";import s from"../core/Logger.js";import{removeMaybe as l,destroyMaybe as r}from"../core/maybe.js";import{ignoreAbortErrors as a}from"../core/promiseUtils.js";import{watch as c,syncAndInitial as p,when as d}from"../core/reactiveUtils.js";import{property as h,subclass as u}from"../core/accessorSupport/decorators.js";import{symbolTypes as m}from"../symbols/support/typeUtils.js";import g from"../views/interactive/sketch/SketchLabelOptions.js";import v from"../views/interactive/sketch/SketchTooltipOptions.js";import f from"../views/interactive/sketch/SketchValueOptions.js";import _ from"./Widget.js";import y from"./Sketch/SketchViewModel.js";import b from"./Sketch/VisibleElements.js";import w from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import S from"./support/PluginSettingsControls.js";import C from"./support/SelectionToolbar.js";import M from"./support/SketchTooltipControls.js";import O from"./support/SnappingControls.js";import{tsx as P,messageBundle as k,vmEvent as I}from"./support/widget.js";import L from"./support/SelectionToolbar/VisibleElements.js";import R from"./support/SketchTooltipControls/VisibleElements.js";const E="esri-sketch",W="settings-menu-action",x={base:E,vertical:`${E}--vertical`,docked:`${E}-bar`,floating:`${E}-pad`,chipHorizontal:`${E}__selection-count-chip--horizontal`,chipVertical:`${E}__selection-count-chip--vertical`,chipVerticalSmall:`${E}__selection-count-chip--vertical--s`,popoverWrapper:`${E}__popover-wrapper`,simplificationWarningAction:`${E}__simplification-warning-action`,simplificationWarningLoader:`${E}__simplification-warning-loader`,simplificationWarningContent:`${E}__simplification-warning-content`,simplificationWarningDescription:`${E}__simplification-warning-description`,simplificationWarningCancelButton:`${E}__simplification-warning-cancel-button`},D={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let B=class extends _{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new b,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._simplificationPopoverOpen=!1,this._showSimplificationWarning=!1,this._simplificationPopoverElement=null,this._simplificationPopoverReferenceElement=null,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{o(s.getLogger(this),"Sketch","arcgis-sketch",{version:"5.0"})}),this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new y({creationMode:e?.creationMode??"continuous",useLegacyCreateTools:e?.useLegacyCreateTools??"3d"===e?.view?.type})),this.viewModel.pluginManager.sketch=this}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){const{layer:e,view:t}=this,i="2d"===t?.type,o=new C({persistSelection:!1,visibleElements:new L({chip:!1,lassoTool:i,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:i}),view:t,sources:e?[e]:null,scale:this.scale,disabled:"disabled"===this.state||this._hasLongRunningOperation});this.addHandles([c(()=>this.viewModel,e=>{this._viewModelHandlesGroup=l(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=n([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),c(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),c(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),c(()=>e.state,()=>{this.notifyChange("state"),this._syncSelectionToolbarDisabledState()}),c(()=>e.geometrySimplificationInProgress,e=>{this._syncSelectionToolbarDisabledState(),e&&(this._showSimplificationWarning=!0)})]))},p),d(()=>o.activeOperation,()=>{this._clearCompletedSimplificationWarningForToolbarInteraction(),this.viewModel.cancel(),this._activeCustomToolOptions=null}),o.on("complete",e=>this._onSelectionOperationComplete(e)),c(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(o.visibleElements,e)},p)]),this._selectionToolbar=o,this._syncSelectionToolbarDisabledState()}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=l(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const{availableCreateTools:t}=this,{activeTool:i,activeCreateToolDrawMode:o}=this.viewModel;return"polygon"===i&&"freehand"===o&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===i&&"freehand"===o&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&r(t),t?.pluginManager?.sketch===this&&(t.pluginManager.sketch=null),this._set("viewModel",e),e.pluginManager.sketch=this)}get useLegacyCreateTools(){return this.viewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.viewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.viewModel.isUsingLegacyCreateTools}get settingsManager(){return this.viewModel.settingsManager}get _effectiveAvailableCreateTools(){if(this.viewModel.effectiveAvailablePlugins?.length)return this.viewModel.effectiveAvailablePlugins;const{availableCreateTools:e,view:t,visibleElements:i}=this,o=e?.filter(e=>!!i.createTools?.[e]);return"3d"===t?.type?o?.filter(e=>"multipoint"!==e):o}create(e,t,i){const o=i?.createOptions??t;return this._showSimplificationWarning&&!this._hasLongRunningOperation&&this._hideSimplificationWarning(),this._activeCustomToolOptions=i,a(this.viewModel.create(e,o))}update(e,t){return a(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1,this._simplificationPopoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:i}=this;return P("div",null,P("div",{classes:{[x.base]:!0,[x.floating]:"floating"===e,[x.docked]:"docked"===e,[x.vertical]:"vertical"===t}},P(w,{barStyle:e,layout:t,scale:i},this._renderSelectionSetItemGroupInline(),this._renderSelectionToolsOrBack(),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup(),this._renderSimplificationWarningItemGroupInline()),this._renderSelectionSetToolbar(),this._renderSimplificationWarningToolbar(),this._renderSettingsMenuPopover(),this._renderSimplificationWarningPopover()))}_renderSimplificationWarningToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSimplificationWarningItemGroup();return e?P(w,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSimplificationWarningItemGroupInline(){if("separate"!==this.contextualToolLocation)return this._renderSimplificationWarningItemGroup()}_renderSelectionToolsOrBack(){if(!this.viewModel.isUsingLegacyCreateTools&&this.viewModel.firstPluginWithSwappableLeaf)return this._renderBackButton();const e=this.customActions?.filter(e=>"selection-toolbar"===e.position);return P("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),e?.map(e=>this._renderToolbarItem(e)))}_renderSettingsMenuPopover(){const{messagesCommon:e,settingsManager:t,snappingOptions:i,view:o,viewModel:n,visibleElements:s}=this;if(!this._calcitePopoverReferenceElement)return;const l={directionModePicker:s.directionModePicker,labelsToggle:s.labelsToggle,tooltipsToggle:s.tooltipsToggle},r="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return P("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,key:`${this.id}-settings`,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:r,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},P("div",{class:x.popoverWrapper},Object.values(l).includes(!0)?P(M,{sketchOptions:n.sketchOptions,view:o,visibleElements:new R(l)}):void 0,s.snappingControls&&o&&i?P(O,{snappingManager:this.viewModel.snappingManager,snappingOptions:i,view:o,visibleElements:s.snappingControlsElements}):void 0,t.hasSettings?P(S,{settingsManager:t}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?P(w,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSimplificationWarningItemGroup(){if(!this._showSimplificationWarning)return;const{messages:e,viewModel:t}=this,{finalizingDrawingCompleteTitle:i,finalizingDrawingTitle:o}=e,n=t.geometrySimplificationInProgress,s=n?o:i,l=n?void 0:"exclamation-mark-triangle",r=`${this.id}__simplification-warning-action`;return P("div",{"group-kind":"measured-content-group",key:"simplification-warning-group",slot:"actions-end"},P("calcite-action",{active:this._simplificationPopoverOpen,afterCreate:e=>this._simplificationPopoverReferenceElement=e,afterRemoved:()=>this._simplificationPopoverReferenceElement=null,afterUpdate:e=>this._simplificationPopoverReferenceElement=e,class:x.simplificationWarningAction,"data-testid":"simplification-warning",disabled:"disabled"===this.state,icon:l,id:r,key:"simplification-warning",onclick:()=>this._simplificationPopoverOpen=!this._simplificationPopoverOpen,scale:this.scale,text:s,title:s},n?P("calcite-loader",{class:x.simplificationWarningLoader,inline:!0,label:e.finalizingDrawing,scale:this.scale,type:"indeterminate"}):void 0))}_renderSimplificationWarningPopover(){if(!this._showSimplificationWarning||!this._simplificationPopoverReferenceElement)return;const{messages:e,messagesCommon:t}=this,{finalizingDrawingCompleteHint:i,finalizingDrawingCompleteTitle:o,finalizingDrawingHint:n,finalizingDrawingTitle:s,simplificationDismiss:l}=e,r=this._hasLongRunningOperation,a=r?s:o,c="l"===this.scale?"l":"s",p="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return P("calcite-popover",{afterCreate:e=>this._simplificationPopoverElement=e,closable:!0,heading:a,key:`${this.id}-simplification`,label:a,open:this._simplificationPopoverOpen,overlayPositioning:"fixed",placement:p,referenceElement:this._simplificationPopoverReferenceElement,scale:c,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforeSimplificationPopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget,this._simplificationPopoverReferenceElement),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},P("div",{class:x.simplificationWarningContent},P("div",{class:x.simplificationWarningDescription},r?n:i),r?P("calcite-button",{class:x.simplificationWarningCancelButton,iconStart:"trash",kind:"danger",label:t.cancel,onclick:()=>this.cancel(),scale:this.scale,width:"full"},t.cancel):P("calcite-button",{appearance:"outline",class:x.simplificationWarningCancelButton,iconStart:"check-circle",kind:"brand",label:l,onclick:()=>this._hideSimplificationWarning(),scale:this.scale,width:"full"},l)))}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return P("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(i=>{"settings-before"===i.position?t.push(i):"settings-after"===i.position&&e.push(i)});const o=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(i);if(o.length)return P("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},o)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),i=this.customActions?.filter(e=>"after-selection-set"===e.position),o=this.groupCollapsePriorities?.get("selectionSet")??100;return[P("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:o,slot:e},this._renderFeatureCountChip()),P("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:o,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),i?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderBackButton(){const{viewModel:e,isUsingLegacyCreateTools:t}=this;if(!t&&e.multiplePluginsActive&&e.firstPluginWithSwappableLeaf&&e.rootPlugins&&(!(e.rootPlugins.length<2&&e.rootPlugins.includes(e.firstPluginWithSwappableLeaf))||this.visibleElements.singlePluginBackButton))return P("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"back-button-group"},P("calcite-action",{disabled:"disabled"===this.state||this._hasLongRunningOperation,icon:"chevron-left",onclick:()=>{this.viewModel?.cancel()},scale:this.scale,text:this.messagesCommon.back}))}_renderCreateToolActionGroup(){const e=this.viewModel.firstPluginWithSwappableLeaf?[]:this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[],t=this._effectiveAvailableCreateTools,i=t?.filter(e=>"string"==typeof e),o=i?.map(e=>this._renderCreateToolItem(e)),n=t?.filter(e=>"string"!=typeof e).map(e=>this._renderCreateToolItem(e));return[o?.length||e?.length||n?.length?P("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},o,e,n):void 0]}_renderCreateToolItem(e){return"string"==typeof e?this._renderBuiltInCreateToolItem(e):this._renderDrawToolPluginItem(e)}_renderDrawToolPluginItem(e){const{icon:t,localizationKey:i,uniqueId:o,hidden:n}=e;if(n)return[];const s=this.messages.digitizers,l=s?.[i]??i,r=!this._activeCustomToolOptions&&this.viewModel.drawTool?.pluginStack.some(e=>!e.configuration?.hidden&&e.configuration?.uniqueId===o);return this._renderToolbarItem({id:`${i}-button`,text:l,icon:t,onclick:()=>this._activatePlugin([e]),active:r})}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:D[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:W,text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:i,scale:o,id:n,updateGraphics:{length:s}}=this,l=t(i.selectedCount,{count:s}),r="l"===o?999:99,a=s>r?t(i.selectedCountTruncated,{truncated:r}):s,c="l"!==o&&"vertical"===e,p=c?`${n}-selection-chip-small`:`${n}-selection-chip`;return[c?P("span",{classes:{[x.chipVertical]:!0,[x.chipVerticalSmall]:"s"===this.scale},id:p,tabIndex:0,title:l},a):P("calcite-chip",{appearance:"outline",class:"horizontal"===e?x.chipHorizontal:x.chipVertical,id:p,kind:"brand",label:l,scale:"l"===o?"m":"s",tabIndex:0,title:"vertical"===e?l:void 0},"vertical"===e?a:l)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:i,disabled:o,onclick:n,active:s,flipRTL:l,afterCreate:r,afterUpdate:a,afterRemoved:c}){const p=`${this.id}-${e}`,d=n?()=>{e!==W&&this._clearCompletedSimplificationWarningForToolbarInteraction(),n.call(this)}:void 0;return[P("calcite-action",{active:s,afterCreate:r,afterRemoved:c,afterUpdate:a,bind:this,"data-testid":e,disabled:o||"disabled"===this.state||this._hasLongRunningOperation,icon:i,iconFlipRtl:l??!1,id:p,key:e,onclick:d,scale:this.scale,text:t,title:t})]}get _hasLongRunningOperation(){return this.viewModel.geometrySimplificationInProgress}_remeasurePopoverSizes(e,t=this._calcitePopoverReferenceElement){try{const i=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),n=i?.style;if(!(i&&o&&n&&this.view?.container?.contains(i)&&t))return;const{bottom:s,top:l}=t.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(n?.setProperty("--sketch-view-height-offset",s-o.top+"px"),n?.setProperty("--sketch-view-margin-offset","30px")):(n?.setProperty("--sketch-view-height-offset",o.bottom-l+"px"),n?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(n.setProperty("--sketch-view-height-offset","15px"),n.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;n.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(i){s.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",i)}}_activateCreateTool(e,t,i){const o=this._activeCustomToolOptions;if(i||o){if(i?.toolKey===o?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,i)}_activatePlugin(e){this._selectionToolbar?.cancel(),this.viewModel.firstPluginWithSwappableLeaf?(this.viewModel.drawTool?.replaceLeaf(e),this.view?.ready&&this.view.focus()):this._activateCreateTool(e)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:i}=e;if(!e.aborted&&i.length){const e=t.tool,o=i.length>1&&"reshape"===e?"transform":e;this.update(i,{...t,tool:o})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){!this.activeTool||e!==this._popoverElement&&e!==this._simplificationPopoverElement||this.view?.focus()}_beforeSimplificationPopoverClose(e){e===this._simplificationPopoverElement&&(this._simplificationPopoverOpen=!1)}_hideSimplificationWarning(){this._showSimplificationWarning=!1,this._simplificationPopoverOpen=!1}_clearCompletedSimplificationWarningForToolbarInteraction(){this._hasLongRunningOperation||this._hideSimplificationWarning()}_syncSelectionToolbarDisabledState(){this._selectionToolbar&&(this._selectionToolbar.disabled="disabled"===this.state||this._hasLongRunningOperation)}};e([h()],B.prototype,"activeTool",null),e([h({readOnly:!0})],B.prototype,"activeTooltip",null),e([h({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],B.prototype,"availableCreateTools",void 0),e([h({readOnly:!0})],B.prototype,"createGraphic",null),e([h()],B.prototype,"creationMode",null),e([h()],B.prototype,"customToolOptions",void 0),e([h()],B.prototype,"customActions",void 0),e([h()],B.prototype,"defaultCreateOptions",null),e([h()],B.prototype,"defaultUpdateOptions",null),e([h()],B.prototype,"icon",null),e([h()],B.prototype,"label",null),e([h({type:g})],B.prototype,"labelOptions",null),e([h()],B.prototype,"layer",null),e([h({type:["horizontal","vertical"],value:"horizontal"})],B.prototype,"layout",null),e([h({types:m})],B.prototype,"pointSymbol",null),e([h({types:m})],B.prototype,"polygonSymbol",null),e([h({types:m})],B.prototype,"polylineSymbol",null),e([h()],B.prototype,"textSymbol",null),e([h({value:"m"})],B.prototype,"scale",null),e([h()],B.prototype,"toolbarKind",void 0),e([h()],B.prototype,"contextualToolLocation",void 0),e([h()],B.prototype,"groupCollapsePriorities",void 0),e([h()],B.prototype,"groupAllowCollapseOptions",void 0),e([h(),k("esri/widgets/Sketch/t9n/Sketch")],B.prototype,"messages",void 0),e([h(),k("esri/t9n/common")],B.prototype,"messagesCommon",void 0),e([h()],B.prototype,"snappingOptions",null),e([h()],B.prototype,"state",null),e([h({type:v})],B.prototype,"tooltipOptions",null),e([h({readOnly:!0})],B.prototype,"updateGraphics",null),e([h({type:f,nonNullable:!0})],B.prototype,"valueOptions",null),e([h()],B.prototype,"view",null),e([h({type:y}),I(["create","update","undo","redo"])],B.prototype,"viewModel",null),e([h({type:b,nonNullable:!0})],B.prototype,"visibleElements",void 0),e([h()],B.prototype,"useLegacyCreateTools",null),e([h()],B.prototype,"isUsingLegacyCreateTools",null),e([h()],B.prototype,"settingsManager",null),e([h()],B.prototype,"_effectiveAvailableCreateTools",null),e([h()],B.prototype,"_defaultViewModel",void 0),e([h()],B.prototype,"_activeCustomToolOptions",void 0),e([h()],B.prototype,"_calcitePopoverReferenceElement",void 0),e([h()],B.prototype,"_hasLongRunningOperation",null),e([h()],B.prototype,"_relativeLocation",void 0),e([h()],B.prototype,"_popoverOpen",void 0),e([h()],B.prototype,"_simplificationPopoverOpen",void 0),e([h()],B.prototype,"_showSimplificationWarning",void 0),e([h()],B.prototype,"_simplificationPopoverElement",void 0),e([h()],B.prototype,"_simplificationPopoverReferenceElement",void 0),B=e([u("esri.widgets.Sketch")],B);const G=B;export{G as default};
|
|
@@ -9,8 +9,9 @@ export type SliderViewModelState = "disabled" | "ready";
|
|
|
9
9
|
/**
|
|
10
10
|
* Provides the logic for the [Slider](https://developers.arcgis.com/javascript/latest/references/core/widgets/Slider/) widget.
|
|
11
11
|
*
|
|
12
|
+
* @deprecated since version 5.1. Use the [Slider component](https://developers.arcgis.com/javascript/latest/references/common-components/components/arcgis-slider/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/).
|
|
12
13
|
* @since 4.12
|
|
13
|
-
* @see [Slider](https://developers.arcgis.com/javascript/latest/references/
|
|
14
|
+
* @see [Slider component](https://developers.arcgis.com/javascript/latest/references/common-components/components/arcgis-slider/)
|
|
14
15
|
* @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
|
|
15
16
|
*/
|
|
16
17
|
export default class SliderViewModel extends Accessor {
|