@arcgis/core 5.2.0-next.157 → 5.2.0-next.159

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.
Files changed (90) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{820c8aaf3632edb0150c.js → 0a5a9885ee6f5b5f99f0.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{7bcedf479b07a4b4a234.js → 1419bf346978b81b08cc.js} +1 -1
  4. package/assets/esri/core/workers/chunks/2cb209bc51a19487692d.js +2 -0
  5. package/assets/esri/core/workers/chunks/2e66c969bf4209c957b5.js +2 -0
  6. package/assets/esri/core/workers/chunks/31640b41e0ecdff892fa.js +2 -0
  7. package/assets/esri/core/workers/chunks/{2ef5237e4c876d6a4ee0.js → 340256866f524cb069f6.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{6079d27f4ab319fb8f0c.js → 377595b23379b0c8fe95.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{c5ed67fdf261cbb1624b.js → 4be559c53fe5ac0d0d2e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/4e6656a5f29e31902fca.js +2 -0
  11. package/assets/esri/core/workers/chunks/{67ebc5a3d46b254b725c.js → 612345f17f5eeb99ea8f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{44918ff37818a7d36d76.js → 6a0ec102962d2c7b4368.js} +1 -1
  13. package/assets/esri/core/workers/chunks/6a2562cc00727155fc01.js +1 -0
  14. package/assets/esri/core/workers/chunks/784d6c6949284ed6e10b.js +1 -0
  15. package/assets/esri/core/workers/chunks/{590e6c70206122e4cc3c.js → 844eedda8f749972f707.js} +2 -2
  16. package/assets/esri/core/workers/chunks/{d2347d6aa1c57fd57029.js → 8ff23ac0abeea0073b47.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{ec8b7476eac4718eb0ac.js → a504a5e06cb89a620799.js} +1 -1
  18. package/assets/esri/core/workers/chunks/a53823cf03dbdce1aecd.js +1 -0
  19. package/assets/esri/core/workers/chunks/{a556dd4e9e6d35e33a2c.js → a546ec82ba149e12f7bf.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{4a640548032355e57acd.js → ab6506a3c16f8717fc00.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{d65383f4058dc813f40d.js → ade5fdcd08dcbac74740.js} +1 -1
  22. package/assets/esri/core/workers/chunks/ba38231193919e093917.js +1 -0
  23. package/assets/esri/core/workers/chunks/{3f776d9fd2ab68b21fca.js → bbd44ac63d2a317d8ed9.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{35e5762642d1a3a2e375.js → be308db5b61a7246edfe.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{10445313d0d57b34511b.js → d53cc574a21031436c45.js} +1 -1
  26. package/assets/esri/core/workers/chunks/dc51dcaa4e2f9a90f5bd.js +2 -0
  27. package/assets/esri/core/workers/chunks/f63686735e4e52f5b54e.js +1 -0
  28. package/assets/esri/core/workers/chunks/{b573df59391ca41ee5a7.js → fc73737b41e086f0ce0b.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{3914d96147642a9d4b01.js → ffbcb816b611049a6276.js} +1 -1
  30. package/assets/esri/themes/base/widgets/_Weather.scss +1 -0
  31. package/assets/esri/themes/dark/main.css +1 -1
  32. package/assets/esri/themes/light/main.css +1 -1
  33. package/assets/esri/themes/light/view.css +1 -1
  34. package/config.js +1 -1
  35. package/form/elements.d.ts +46 -8
  36. package/form/elements.js +1 -1
  37. package/kernel.js +1 -1
  38. package/layers/GeoJSONLayer.d.ts +1 -1
  39. package/layers/support/layerOriginUtils.js +1 -1
  40. package/package.json +3 -3
  41. package/popup/FeaturesModel.js +1 -1
  42. package/time/TimeExtent.d.ts +1 -1
  43. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueBackground.js +1 -1
  44. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
  45. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  46. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  47. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  48. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  49. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  50. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  51. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  52. package/views/View.js +1 -1
  53. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  54. package/views/interactive/snapping/SnappingManagerPool.js +1 -1
  55. package/views/interactive/snapping/allLayerSnapping.js +1 -1
  56. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.d.ts +2 -1
  57. package/widgets/BasemapToggle/BasemapToggleViewModel.d.ts +2 -0
  58. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.d.ts +2 -1
  59. package/widgets/Expand/ExpandViewModel.d.ts +2 -0
  60. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  61. package/widgets/Fullscreen/FullscreenViewModel.d.ts +3 -1
  62. package/widgets/Home/HomeViewModel.d.ts +2 -0
  63. package/widgets/ScaleRangeSlider/ScaleRanges.d.ts +3 -0
  64. package/widgets/ScaleRangeSlider/types.d.ts +3 -3
  65. package/widgets/Sketch/SketchViewModel.js +1 -1
  66. package/widgets/Swipe/SwipeViewModel.d.ts +2 -0
  67. package/widgets/Swipe/types.d.ts +9 -2
  68. package/widgets/TimeSlider/TimeSliderViewModel.d.ts +9 -5
  69. package/widgets/TimeSlider/types.d.ts +7 -0
  70. package/widgets/TimeSlider.d.ts +2 -3
  71. package/widgets/TimeSlider.js +1 -1
  72. package/widgets/Track/TrackViewModel.d.ts +4 -0
  73. package/widgets/Track/types.d.ts +1 -0
  74. package/widgets/support/Selector3D/selectorUtils.js +1 -1
  75. package/assets/esri/core/workers/chunks/1b946714ca4a1a7359d4.js +0 -2
  76. package/assets/esri/core/workers/chunks/22b01fe31bbf0bdc48db.js +0 -1
  77. package/assets/esri/core/workers/chunks/27c2da2e779def2ee08b.js +0 -1
  78. package/assets/esri/core/workers/chunks/2a1ec30f9ad305763f81.js +0 -2
  79. package/assets/esri/core/workers/chunks/34570e6bbf559f18c1a5.js +0 -1
  80. package/assets/esri/core/workers/chunks/5566f14afb63065e438f.js +0 -1
  81. package/assets/esri/core/workers/chunks/68d8ae42ab71d01a70a5.js +0 -2
  82. package/assets/esri/core/workers/chunks/8cb716f110d164030309.js +0 -1
  83. package/assets/esri/core/workers/chunks/8dc1c3042267618fd710.js +0 -2
  84. package/assets/esri/core/workers/chunks/96c50a0dda0f1503ef92.js +0 -2
  85. /package/assets/esri/core/workers/chunks/{1b946714ca4a1a7359d4.js.LICENSE.txt → 2cb209bc51a19487692d.js.LICENSE.txt} +0 -0
  86. /package/assets/esri/core/workers/chunks/{8dc1c3042267618fd710.js.LICENSE.txt → 2e66c969bf4209c957b5.js.LICENSE.txt} +0 -0
  87. /package/assets/esri/core/workers/chunks/{96c50a0dda0f1503ef92.js.LICENSE.txt → 31640b41e0ecdff892fa.js.LICENSE.txt} +0 -0
  88. /package/assets/esri/core/workers/chunks/{2a1ec30f9ad305763f81.js.LICENSE.txt → 4e6656a5f29e31902fca.js.LICENSE.txt} +0 -0
  89. /package/assets/esri/core/workers/chunks/{590e6c70206122e4cc3c.js.LICENSE.txt → 844eedda8f749972f707.js.LICENSE.txt} +0 -0
  90. /package/assets/esri/core/workers/chunks/{68d8ae42ab71d01a70a5.js.LICENSE.txt → dc51dcaa4e2f9a90f5bd.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as n}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{handlesGroup as o,makeHandle as s,drainHandles as c,destroyHandle as l}from"../../core/handleUtils.js";import has from"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as f,removeMaybe as p}from"../../core/maybe.js";import{createAbortError as m,ignoreAbortErrors as h,whenOrAbort as g}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,on as ee,when as te,sync as ne,whenOnce as y}from"../../core/reactiveUtils.js";import{property as b,subclass as re}from"../../core/accessorSupport/decorators.js";import{trackAccess as x}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as ie}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as S}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ae}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as oe,isLoaded as se,load as ce,project as le}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as ue}from"../../geometry/support/spatialReferenceUtils.js";import de from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as fe}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as pe}from"../../support/elevationInfoUtils.js";import me from"../../symbols/FillSymbol3DLayer.js";import he from"../../symbols/MeshSymbol3D.js";import ge from"../../symbols/SimpleFillSymbol.js";import _e from"../../symbols/SimpleLineSymbol.js";import w from"../../symbols/SimpleMarkerSymbol.js";import T from"../../symbols/TextSymbol.js";import{symbolTypes as E}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as ve}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as ye}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as be}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as O}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as k}from"../../views/input/InputManager.js";import{sketchKeys as A}from"../../views/interactive/keybindings.js";import{bindViewToolOptions as xe}from"../../views/interactive/options/bindViewToolOptions.js";import j from"../../views/interactive/options/InteractiveToolOptions.js";import M from"../../views/interactive/sketch/SketchLabelOptions.js";import N from"../../views/interactive/sketch/SketchOptions.js";import Se from"../../views/interactive/sketch/SketchTooltipOptions.js";import Ce from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as P}from"../../views/interactive/snapping/SnappingManager.js";import{acquire as we}from"../../views/interactive/snapping/SnappingManagerPool.js";import F from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as I}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as Te}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as Ee}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as De}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as L}from"../../views/support/screenUtils.js";import Oe from"./adapters/layer/GraphicsLayerAdapter.js";import ke from"./adapters/layer/MapNotesLayerAdapter.js";import Ae from"./adapters/layer/SketchLayerAdapter.js";import{CreateOperationHandle as je,DrawToolOperationHandle as Me,UpdateOperationHandle as R}from"./support/OperationHandle.js";import{PluginManager as Ne}from"./support/PluginManager.js";import{SettingsManager as Pe}from"./support/SettingsManager.js";import{getLegacyTool as z,isCompletelyDegenerate as Fe,graphicsHaveTooFewVerticesForBox as B,getModeFromCreateOptions as Ie,getDrawToolGeometryTypeFromCreateTool as Le}from"./support/sketchUtils.js";const V={defaultZ:0},H={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:Ee},tool:`transform`},U=Symbol(),W=Symbol();let G=class extends a{constructor(e){super(e),this._defaultSnappingManager=null,this._operationContext=null,this._internalGraphicsLayer=new de({listMode:`hide`,internal:!0,title:`SVM Internal`}),this._pluginManager=new Ne({sketchViewModel:this}),this.settingsManager=new Pe({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new S,this._toolTransitionHandles=new S,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new Te,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 ge({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new _e({color:[130,130,130,1],width:2}),this.meshSymbol=new he({symbolLayers:new r([new me])}),this.updateGraphics=new r,this.updateOnGraphicClick=!0,this.useViewOptions=!1,this.cancelUpdateOnClickAway=!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 N,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{let{_layerAdapter:e}=this;if(this.removeHandles(W),!e)return;let t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},v)].filter(n);this.addHandles(t,W)},this._originalPopupEnabled=null,this.defaultCreateOptions=V,this.defaultUpdateOptions=H,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new F,this.textSymbol=new T({text:`text`})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([ee(()=>this.view?.map?.layers,`change`,e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),v),_(()=>this.view,e=>{this._defaultSnappingManager=d(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new P({view:e,options:this.snappingOptions})),e.type===`2d`?(import(`../../views/2d/interactive/editingTools.js`),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):e.type===`3d`&&(import(`../../views/3d/interactive/editingTools.js`),import(`../../views/3d/layers/GraphicsLayerView3D.js`)))},v),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),I(this,void 0,()=>this._operationSnappingManager?.options??this.snappingOptions)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=d(this._defaultSnappingManager),this._destroyOperationContext(),this._set(`snappingManager`,null),this._set(`view`,null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit(`destroy`)}get _operationSnappingManager(){return this._operationContext?.snappingManager??this.snappingManager}get _operationToolOptions(){return this._operationContext?.toolOptions??this.sketchOptions}get _layerAdapter(){let{layer:e}=this;switch(e?.type){case`graphics`:return new Oe(e);case`map-notes`:return new ke(e);case`sketch`:return new Ae(e);case void 0:default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){let e=this._operationHandle;if(e?.type===`create`&&e.activeComponent&&`mode`in e.activeComponent)return e.activeComponent.mode;if(e?.activeComponent?.type===`draw-2.0`){let t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(n).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){let{activeComponent:e,destroyed:t}=this,n=!t&&e&&`tooltip`in e?e.tooltip:null;return n?.visible?n:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return this.activeComponent!=null&&(this.activeComponent.type===`draw-3d`||this.activeComponent.type===`draw-2d`)?this.activeComponent.graphic:this._get(`createGraphic`)}get defaultCreateOptions(){return this._get(`defaultCreateOptions`)}set defaultCreateOptions(e){this._set(`defaultCreateOptions`,{...V,...e})}get defaultUpdateOptions(){return this._get(`defaultUpdateOptions`)}set defaultUpdateOptions(e){this._set(`defaultUpdateOptions`,{...H,...e,reshapeOptions:{...H.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...H.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){this._defaultSnappingManager!=null&&(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=d(this._defaultSnappingManager)),this._override(`snappingManager`,e);else{let{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new P({options:this.snappingOptions,view:e})),this._clearOverride(`snappingManager`)}}get state(){let e=!!(this.view?.ready&&this.layer),t=this._operationHandle;return e&&t?`active`:e?`ready`:`disabled`}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||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){let t=this._get(`view`);if(t){let{container:e,map:n}=t;e&&this._clearCursor(),n?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}let n=`view-ready`;this.removeHandles(n),e&&this.addHandles(te(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},v),n),this._set(`view`,e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||this.view?.type!==`2d`}get pluginManager(){return this._pluginManager}get drawTool(){return this.activeComponent?.type===`draw-2.0`?this.activeComponent:null}get activePluginConfigurations(){return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).filter(n)??[]}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome(`rootPlugins`,e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;let 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(n)??[]}get firstPluginWithSwappableLeaf(){let e=this.view?.type??`2d`;return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>t!=null&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1)}get multiplePluginsActive(){return this.drawTool?this.drawTool.pluginStack.length>1:!1}replaceLeaf(e){this.drawTool?.replaceLeaf(e)}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=f(this._moduleLoaderAbortController),this._viewReadyAbortController=f(this._viewReadyAbortController),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){let{state:e,updateGraphics:t}=this;if(e===`active`&&t.length){let{activeTool:e}=this,n=t.toArray();this.removeGraphics(n),this.cancel(),this._emitDeleteEvent({graphics:n,tool:e})}}duplicate(){if(this.state===`active`&&this.updateGraphics.length){let 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){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{view:n,layer:r}=this;if(!n||this.state===`disabled`)throw r||this._logMissingLayer(),m();if(n.activeTool!=null&&(n.activeTool=null),!e){this._logError(`sketch:missing-parameter`,`Missing parameter 'tool'.`);return}O(n,this._internalGraphicsLayer);let i=this._createOperationContext(n),a;try{a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t))}catch(e){throw this._destroyOperationContext(i),e}if(a==null||this.destroyed||i!==this._operationContext){let e=i===this._operationContext;a?.onEnd(),d(a),this._destroyOperationContext(i),e&&n.map?.remove(this._internalGraphicsLayer);return}let o=z(e);a.on(`complete`,()=>{if(a===this._operationHandle){let n=this.createGraphic,r=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._set(`createGraphic`,null),this.view?.map?.remove(this._internalGraphicsLayer),!a.cancelled&&n!=null&&this.addGraphic(n),this._sketchContinuationFlag=!1,this.emit(`create`,{graphic:n,state:r?`cancel`:`complete`,tool:o??`point`,toolEventInfo:null,type:`create`}),r||this._sketchContinuationFlag)return;let{creationMode:i}=this;if(i===`continuous`){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(h(this.create(e,t)))}else i===`update`&&n&&this._updatingHandles.consumePromise(h(this.update([n])))}}),this._operationHandle=a,n.ready&&n.focus()}async place(e,t){return await e.load(),this.create(`mesh`,{mode:`click`,hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{layer:n,view:r,state:i}=this;if(!r||i===`disabled`)throw n||this._logMissingLayer(),m();r.activeTool!=null&&(r.activeTool=null);let a=Array.isArray(e)?e:[e];if(e==null||!a?.length){this._logError(`sketch:missing-parameter`,`Missing parameter 'graphics'.`);return}if(a.some(e=>this.hasGraphic(e)?e.geometry==null&&(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;let o=this._createOperationContext(r),s;try{s=await this._updatingHandles.addPromise(this._setupUpdateOperation(a,t))}catch(e){throw this._destroyOperationContext(o),e}if(this.destroyed||s==null||$(s)||o!==this._operationContext){s&&!$(s)&&(s.onEnd(),s.destroy()),this._destroyOperationContext(o);return}O(r,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit(`update`,{graphics:a,state:`start`,aborted:!1,tool:s.tool,toolEventInfo:null,type:`update`})}async _updateSpatialReference(e){let t=this.view;if(!t){this._logMissingView();return}e=Array.isArray(e)?e:[e];for(let n of e)n.geometry!=null&&n.geometry.type!==`mesh`&&!ue(n.geometry.spatialReference,t.spatialReference)&&(!oe(n.geometry.spatialReference,t.spatialReference)&&!se()&&await ce(),n.geometry=le(n.geometry,t.spatialReference))}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}_createOperationContext(e){this._destroyOperationContext();let t=this.useViewOptions?e.options:null,n=t?we(e):null,r=t?new j:this.sketchOptions,i;if(t){let{values:t}=r;i=o([xe(r,()=>e.options,()=>this.sketchOptions),_(()=>t.directionMode,e=>{this.sketchOptions.values.directionMode=e},ne)])}return this._operationContext={snappingManager:n?.snappingManager??this.snappingManager,toolOptions:r,...o([n,i])}}_destroyOperationContext(e=this._operationContext){if(e!==this._operationContext){p(e);return}this._operationContext=p(this._operationContext)}async _getFirstHit(e){let t=this.view;if(!t)return this._logMissingView(),null;if(t.type===`2d`){let n=[];t.map.allLayers.forEach(e=>{(e.type===`vector-tile`||e.type===`imagery`)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});return De(r.results)}let n=[t.map.ground];t.map.allLayers.forEach(e=>{fe(e)&&(!has(`enable-feature:im-as-ground`)||e.isUsedAsGroundLayer)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});if(r.results.length>0){let e=r.results[0];if(e!=null&&e.type===`graphic`&&e.graphic&&(!r.ground.mapPoint||t.map.ground.opacity<1||r.ground.distance-(e.distance??0)>-Math.min(3*r.ground.distance,t.viewingMode===`global`?ae(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:1/0)))return e}return null}_generateViewHandles(e){return[e.on(`immediate-click`,async e=>{let t=this.state===`active`&&this._operationHandle?.type===`create`;this.state!==`disabled`&&!t&&this.updateOnGraphicClick&&await this._toolTransitionHandles.addPromise(this._handleImmediateClick(e))},k.WIDGET)]}async _handleImmediateClick(e){let t=await e.defer(()=>this._getFirstHit(L(e))),n=null;if(t!=null){let r=t.graphic;this.updateGraphics.includes(r)||this.hasGraphic(r)?(e.stopPropagation(),n=r):this.view?.type===`2d`&&!this._isComponentGraphic(r)&&this.state===`active`&&this.cancel()}else this.state===`active`&&this.cancelUpdateOnClickAway&&this.cancel();n!=null&&!this.updateGraphics.includes(n)&&await this.update([n],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r={hasZ:n.type===`3d`,...this.defaultCreateOptions,...t},i=typeof e==`string`?this.pluginManager?.getPluginsEquivalentToCreateTool(e,r.mode):e,a=z(e);if(i&&!this.isUsingLegacyCreateTools){let e=await this._setupDrawTool(i,r,a??`polyline`);if(e)return this._setupDrawToolOperationHandle(e,a??`point`)}if(!a)return null;let o=await this._setupDrawGraphicTool(a,n,r);return o==null?null:(n.tools.add(o),n.activeTool=o,this._setupCreateOperationHandle(o,a))}async _setupDrawGraphicTool(e,t,n){if(e===`multipoint`&&t.type===`3d`)return this._logError(`sketch:create`,`Multipoint geometries are not supported in SceneView.`),null;if(!t)return this._logMissingView(),null;let{cursor:r,defaultZ:i,hasZ:a,geometryToPlace:o,graphicProperties:s,mode:c,preserveAspectRatio:l}=n,u=Ie(c,e),d=Le(e),f=n?.optionsPerTool?.has(e)?n.optionsPerTool.get(e):{},p=f?.preserveAspectRatio??l??e!==`rectangle`,m={centered:e!==`rectangle`&&!(e===`circle`&&!p),cursor:r,defaultZ:i,forceUniformSize:p,graphicProperties:{...s,attributes:{...s?.attributes}},geometryToPlace:o,geometryType:d,mode:u,graphicSymbol:n.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:a,snappingManager:this._operationSnappingManager,snapToScene:!1,view:t,...f};return t.type===`2d`?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){let t=await this._requireModule(import(`../../views/2d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ze(e.geometryType)?this.activeFillSymbol:null,toolOptions:this._operationToolOptions})}async _makeDrawGraphicTool3D(e){let t=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,toolOptions:this._operationToolOptions})}_setupCreateOperationHandle(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r=null,i=e.forceUniformSize,a=e.centered,o=new ie,l=[s(()=>o.destroy()),n.on(`key-down`,t=>{if(t.key===A.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===A.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key===A.vertexAdd&&!t.repeat){let n=e.drawOperation.geometryType;(n===`polyline`||n===`polygon`||n===`multipoint`)&&(t.stopPropagation(),e.drawOperation.commitStagedVertex())}else t.key===A.undo?(t.stopPropagation(),u.undo()):t.key===A.redo?(t.stopPropagation(),u.redo()):t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)&&!t.repeat?(e.forceUniformSize=!i,t.stopPropagation()):t.key===A.center&&(t.repeat||(e.centered=!a,t.stopPropagation()))},k.WIDGET),n.on(`key-up`,t=>{t.key===A.pan?e.enabled=!0:t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)?(e.forceUniformSize=i,t.stopPropagation()):t.key===A.center&&(e.centered=a,t.stopPropagation())},k.WIDGET),e.on(`vertex-update`,()=>{o.notify()}),e.on(`vertex-add`,t=>{switch(o.notify(),r=r==null?`start`:`active`,t.operation){case`apply`:this.emit(`create`,{graphic:e.graphic,state:r,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(o.notify(),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),r=`complete`,e.aborted?u&&u.cancel():u&&u.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],u=new je({activeComponent:e,type:`create`,onEnd:()=>{c(l),n.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(x(o),e.canUndo),canRedo:()=>(x(o),e.canRedo)});return u}_setupDrawToolOperationHandle(e,t){let r=this.view;if(!r)return this._logMissingView(),null;let i=null,a=[r.on(`key-down`,t=>{t.key===A.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},k.WIDGET),r.on(`key-up`,t=>{t.key===A.pan&&(e.editable=!0)},k.WIDGET),e.on(`before-vertex-add`,t=>{let n=e.mostUpstreamPlugin?.configuration;if(n&&`legacyCreateTool`in n&&(n?.legacyCreateTool===`point`||n.legacyCreateTool===`text`)){let e=t.detail.originalEvent;e&&`key`in e&&e.key===A.vertexAdd&&t.preventDefault();return}}),e.on(`before-complete`,t=>{let n=e.getGeometryIfCompleted();if(!n||Fe(n)){t.preventDefault();return}}),e.on([`vertex-add`,`vertex-remove`],r=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),i=i==null&&r.type!==`vertex-remove`?`start`:`active`,r.operation){case`apply`:this.emit(`create`,{graphic:this.createGraphic,state:i,tool:this.activeTool,toolEventInfo:r,type:`create`});break;case`undo`:this._emitUndoEvent({graphics:[this.createGraphic].filter(n),tool:t});break;case`redo`:this._emitRedoEvent({graphics:[this.createGraphic].filter(n),tool:t})}}),e.on(`cursor-update`,t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit(`create`,{graphic:this.createGraphic,state:`active`,tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:`cursor-update`},type:`create`})}),e.on(`complete`,async({geometry:t,isSimple:n})=>{let r=this.createGraphic,i=!!t&&t.type!==`mesh`&&t.type!==`extent`&&!n;if(r&&(r.geometry=n?t:e.unprocessedGeometry??t),!i||!r)o.complete();else{this._internalGraphicsLayer.add(this.createGraphic);let e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(h(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:r,handle:o})))}})],o=new Me({activeComponent:e,type:`create`,onEnd:()=>{c(a),r.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return a.push(e.on(`cancel`,()=>{this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),o.cancel()})),o}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:n,handle:r}){let i=this.view?.acquireCursor(`progress`,`high`);i&&this.addHandles(i);let a=()=>e.signal.aborted?(n&&(this._layerAdapter?.remove(n),this._internalGraphicsLayer?.remove(n)),this._set(`createGraphic`,null),!0):!1;try{let i=await this._geometryWorkerHandle.simplify(t,e.signal);if(a())return;n.geometry=i??t,this._internalGraphicsLayer?.remove(n),r.complete()}finally{i?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_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){let{view:n}=this;if(!n)return this._logMissingView(),null;let r={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=r;let i=r.tool??H.tool;if(this.removeGraphics(e),this.addGraphics(e),n.type===`3d`){if(e.length===0)return null;switch(i){case`move`:return this._setupMove3DOperation(e,r,n,i);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupReshape3DOperation(e[0],r,n);case`transform`:return this._setupGraphicTransform3DOperation(e,r,n)}}switch(i){case`move`:return this._setupMove2DOperation(e,r,n);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupTransformOrReshape2DOperation(e,i,r,n);case`transform`:return B(e)&&(i=`reshape`),this._setupTransformOrReshape2DOperation(e,i,r,n)}}async _setupMove3DOperation(e,t,n,r,i=!1){let a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,MoveTool3D:s}=a.module,l=new Map,u=()=>{l.forEach(e=>e.destroy()),l.clear()};for(let t of e){let e=new o({view:n,graphic:t}),r=ve(e);if(r!==0)return u(),this._logError(`sketch:move`,`Move operation not supported for provided graphic(s) (${D(r)}).`),null;l.set(t,e)}let d=new s({view:n,enableZ:t.enableZ,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(d),d.objects.addMany(Array.from(l.values())),i||this.updateGraphics.addMany(e);let f=[],p=new R({activeComponent:d,tool:r,type:`update`,onEnd:()=>{c(f),Q(n,d),u()},undo:()=>{X(this.view,d),q(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},addToSelection:async e=>{this.updateGraphics.push(e);let t=new o({view:n,graphic:e});l.set(e,t),d.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:async e=>{let t=this.updateGraphics.indexOf(e);if(p.history.undo.forEach(e=>e.updates.splice(t,1)),p.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`}),this.updateGraphics.length===0){p.complete();return}let n=l.get(e);n&&(d.objects.remove(n),n.destroy(),l.delete(e))},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1||r!==`transform`)return;let e=this.updateGraphics.at(0),i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));i&&!$(i)&&(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(i,t))}});return f.push(...this._getHandlesForComponent(p,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(p,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e)},k.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,n,r=!1){if(e.length===1&&be(e[0])===0){let i=e[0],a=i.geometry;if(a!=null&&(a.type===`point`||a.type===`mesh`))return this._setupPointTransform3DOperation(i,t,n);if(a!=null&&(a.type===`polygon`||a.type===`polyline`))return this._setupPolyTransform3DOperation(i,t,n,r)}return this._setupMove3DOperation(e,t,n,`transform`,r)}async _setupPointTransform3DOperation(e,t,n){let r=`transform`,{enableRotation:i,enableScaling:a,enableZ:o}=t,s=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(s))return s;let{TransformTool3D:l,ManipulatedObject3DGraphic:u}=s.module,d=new u({graphic:e,view:n}),f=new l({object:d,view:n,enableRotation:i,enableScaling:a,enableZ:o,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),this.updateGraphics.add(e);let p=[],m=new R({activeComponent:f,tool:r,type:`update`,onEnd:()=>{c(p),Q(n,f),d.destroy()},undo:()=>{X(this.view,f),q(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,n,r=!1){let i=`transform`,{enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:l}=t,u=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(u))return u;let{ManipulatedObject3DGraphic:d,ExtentTransformTool:f}=u.module,p=this.view?.inputManager?.isModifierKeyDown(A.constraint),m=new d({view:n,graphic:e}),h=new f({object:m,view:n,enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:!!l!=!!p,toolOptions:this._operationToolOptions});n.tools.add(h),r||this.updateGraphics.add(e);let g=[],_=new R({activeComponent:h,tool:i,type:`update`,onEnd:()=>{c(g),Q(n,h),m.destroy()},canUndo:()=>!h.destroyed&&h.canUndo,undo:()=>{h.destroyed||(h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!h.destroyed&&h.canRedo,redo:()=>{h.destroyed||(h.redo(),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`}),await this._replaceUpdateOperationHandle(_,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),_.complete()},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1)return;let r=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));r&&!$(r)&&(_.onEnd(),_.destroy(),this._setUpdateOperationHandle(r,t))}});return g.push(...this._getHandlesForComponent(_,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(_,e,t),k.WIDGET),n.on(`key-down`,e=>this._getCommonUpdateOperationKeyDownHandlers(_,e),k.WIDGET),n.on(`key-down`,e=>{e.key===A.constraint&&!e.repeat&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET)),_}async _setupMove2DOperation(e,t,n){let r=`move`;this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,n));if($(i))return i;let a=new R({activeComponent:i,tool:r,type:`update`,onEnd:()=>{this._clearCursor(),c(l),c(s),i.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{let e=this.updateGraphics.toArray();q(a,e),a.refreshComponent(),this._emitUndoEvent({graphics:e,tool:r})},redo:()=>{let e=this.updateGraphics.toArray();J(a,e),a.refreshComponent(),this._emitRedoEvent({graphics:e,tool:r})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),i.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:async e=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();if(this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`}),this.updateGraphics.length===0){a.complete();return}i.graphics=n}}),o=!1,s=[n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&(o=!0,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&o&&(o=!1,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET)],l=this._getHandlesForComponent(a,t);return a}async _setupReshape3DOperation(e,t,n,r=!1){let i=`reshape`,a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,ReshapeTool3D:s}=a.module,l=new o({view:n,graphic:e}),u=ye(l);if(u!==0)return l.destroy(),this._logError(`sketch:reshape`,`Reshape operation not supported for provided graphic(s) (${D(u)}).`),null;let d=t.reshapeOptions,f=new s({view:n,object:l,enableZVertex:t.enableZ&&d?.vertexOperation===`move`,enableZShape:t.enableZ&&d?.shapeOperation===`move`,enableMoveObject:d?.shapeOperation===`move`||d?.shapeOperation===`move-xy`,enableMidpoints:d?.edgeOperation===`split`,enableEdgeOffset:d?.edgeOperation===`offset`,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),r||this.updateGraphics.add(l.graphic);let p=[],m=new R({activeComponent:f,tool:i,type:`update`,onEnd:()=>{c(p),Q(n,f),l.destroy()},canUndo:()=>!f.destroyed&&f.canUndo,undo:()=>{f.destroyed||(f.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!f.destroyed&&f.canRedo,redo:()=>{f.destroyed||(f.redo(),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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{t.toggleToolOnClick!==!1&&await this._replaceUpdateOperationHandle(m,t,()=>this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,n,!0))}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,n,r){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(t===`transform`?this._getBox(e,n,r):this._getReshape(e,n,r));if($(i))return i;let a=new R({activeComponent:i,type:`update`,onEnd:()=>{c(s),c(o),a.activeComponent&&!a.activeComponent.destroyed&&a.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{q(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},redo:()=>{J(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},addToSelection:async e=>{let t=a.activeComponent;if(t?.type===`reshape`){let t=[...this.updateGraphics,e];if(this.updateGraphics.removeAll(),!await this._replaceUpdateOperationHandle(a,n,()=>this._setupTransformOrReshape2DOperation(t,`transform`,n,r)))return}else this.updateGraphics.add(e),t=t,t.graphics=this.updateGraphics.toArray(),t.refresh(),a.resetHistory();this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:`selection-change`},type:`update`})},removeFromSelection:async e=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();n.length===0?a.complete():B(n)?await a.toggleTool():a.activeComponent.graphics=n,this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;let e=this.updateGraphics.at(0),t=e.geometry;if(t!=null&&(a.tool===`reshape`&&t.type===`point`||a.tool===`transform`&&t.type===`extent`))return;let i=null,o={...this.defaultUpdateOptions,...n,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...n?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...n?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};a.tool===`transform`?i=await this._updatingHandles.addPromise(this._getReshape([e],o,r)):a.tool===`reshape`&&(i=await this._updatingHandles.addPromise(this._getBox([e],o,r))),!$(i)&&(a.activeComponent?.destroy(),a.activeComponent=i,a.activeComponent&&(c(s),s=this._getHandlesForComponent(a,o)))}}),o=[r.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,n),k.WIDGET),r.on(`key-down`,e=>{if(this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET),r.on(`key-up`,e=>{if(e.key===A.constraint&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET)],s=this._getHandlesForComponent(a,n);return a}async _getGraphicMover(e,t,n){let{enableMoveAllGraphics:r,highlightOptions:i}=t,a=await this._requireModule(import(`../../views/draw/support/GraphicMover.js`));return $(a)?a:new a.module.default({enableMoveAllGraphics:r,highlightName:i?.name,highlightsEnabled:!!i?.enabled,indicatorsEnabled:!1,graphics:e,view:n,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`grabbing`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-start`},type:`update`})},onGraphicMove:({dx:e,dy:t,graphic:n})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move`},type:`update`}),onGraphicMoveStop:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`pointer`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-stop`},type:`update`})},onGraphicPointerOver:()=>this._displayCursor(`move`),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,n){let{enableRotation:r,enableScaling:i,highlightOptions:a,preserveAspectRatio:o}=t,s=await this._requireModule(import(`../../views/draw/support/Box.js`));if($(s))return s;let c=this.view?.inputManager?.isModifierKeyDown(A.constraint),l=new s.module.default({graphics:e,enableRotation:r,enableScaling:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,preserveAspectRatio:!!o!=!!c,layer:this._internalGraphicsLayer,view:n,toolOptions:this._operationToolOptions,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,n])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=n??t.enableScaling??!0,l.refresh()},v)),l}async _getReshape(e,t,n){let{highlightOptions:r,reshapeOptions:i}=t,a=i?.edgeOperation===`split`,o=i?.shapeOperation===`move`,s=!!i?.enableCreateCurveFromStraightEdge,c=await this._requireModule(import(`../../views/draw/support/Reshape.js`));return $(c)?c:new c.module.default({enableMidpoints:a,enableMovement:o,enableCurveOnMidpoint:s,graphic:e[0],highlightName:r?.name,highlightsEnabled:!!r?.enabled,layer:this._internalGraphicsLayer,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions,view:n,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:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMove:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMoveStop:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onVertexAdd:({added:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:r,vertices:n,type:t},type:`update`})},onVertexRemove:({removed:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{removed:r,vertices:n,type:t},type:`update`})}}})}_getHandlesForComponent(e,t){let n=e.activeComponent;if(!n)return[];switch(n.type){case`graphic-mover`:return[n.on(`graphic-click`,({graphic:n,viewEvent:r})=>{r.native?.shiftKey&&t.multipleSelectionEnabled&&(r.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(n)))}),n.on(`graphic-move-start`,t=>e.addToHistory(Z(t.allGraphics)))];case`box`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`rotate-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`scale-start`,t=>e.addToHistory(Z(t.graphics)))];case`reshape`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z([t.mover]))),n.on(`reshape-start`,t=>e.addToHistory(Z([t.graphic]))),n.on(`vertex-add`,t=>e.addToHistory(Z([t.oldGraphic]))),n.on(`vertex-remove`,t=>e.addToHistory(Z([t.oldGraphic])))];case`move-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`transform-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`reshape-3d`:return[n.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`})}),n.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`})}),n.events.on(`vertex-add`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`vertex-remove`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,n){let{graphic:r,viewEvent:i}=n;if(i.native?.shiftKey&&this.hasGraphic(r)){i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(r));return}t.toggleToolOnClick&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}async _replaceUpdateOperationHandle(e,t,n){let r=this._operationContext;e.onEnd(),e.destroy();let i=await this._updatingHandles.addPromise(n());return!i||$(i)||r!==this._operationContext?(i&&!$(i)&&(i.onEnd(),i.destroy()),this._destroyOperationContext(r),!1):(this._setUpdateOperationHandle(i,t),!0)}_setUpdateOperationHandle(e,t){this._operationHandle=e;let n=this.view?.map;this._disablePopup(t),e.on(`complete`,()=>{if(e===this._operationHandle){let r=this.updateGraphics.toArray(),i=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),n&&n.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit(`update`,{graphics:r,state:`complete`,aborted:e.cancelled,tool:i,toolEventInfo:null,type:`update`})}})}_getCommonUpdateOperationClickHandlers(e,t,n){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,n))}async _handleCommonUpdateOperationClick(e,t,n){let r=L(t),i=await t.defer(()=>this._getFirstHit(r));if(i==null){this.cancelUpdateOnClickAway&&e.complete();return}let a=t.native.shiftKey?this._toggleSelection([i.graphic],e,n):null;if(a){t.stopPropagation(),await a;return}this.updateGraphics.includes(i.graphic)?this._shouldTemporarilyDisablePopup(n)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,n){let r=!!n.multipleSelectionEnabled;for(let n of e)if(n!=null&&r&&this.hasGraphic(n))return this.updateGraphics.includes(n)?await t.removeFromSelection(n):await t.addToSelection(n)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;let n=t.key;n===A.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):n===A.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):n===A.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&A.delete.includes(n)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&this._operationHandle.type===`update`&&this.activeComponent!=null&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&=(this.view?.map?.remove(this._internalGraphicsLayer),d(this._internalGraphicsLayer))}_isComponentGraphic(e){let{activeComponent:t}=this;return!e||t==null?!1:e.attributes?.esriSketchTool||t.type===`draw-2d`&&t.graphic===e||(t.type===`box`||t.type===`reshape`)&&t.isUIGraphic(e)}_clearCursor(){this.removeHandles(U)}_displayCursor(e){this.removeHandles(U),this.view?.container&&e!=null&&this.addHandles(this.view.acquireCursor(e,`high`),U)}_logError(e,t,n){u.getLogger(this).error(new i(e,t,n))}async _requireModule(e){let t=new AbortController;this._moduleLoaderAbortController=t;let n=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:`aborted`}:{module:n}}_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(this._operationHandle!=null){let{updateGraphics:t}=this;for(let n of e.removed)if(t.includes(n)){if(t.length>1)this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(n));else{this._operationHandle.cancel();break}}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,n,r){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;let i=this.view,a=await import(`../../views/draw/DrawTool.js`);await this.pluginManager.loadPlugins();let o=await this.pluginManager.makeRenderer({customSymbol:n.graphicSymbol,useTextSymbol:r===`text`}),s=new a.DrawTool({view:i,elevationInfo:this._layerAdapter?.elevationInfo??pe(i.type===`3d`),hasZ:!!n.hasZ,toolOptions:this._operationToolOptions,renderer:o,defaultZ:n.defaultZ??0,directionOptions:n.directionOptions,snappingManager:this._operationSnappingManager,enableVertexVisuals:r!==`rectangle`&&r!==`circle`,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});s.addHandles(l(o));let c=new t({...n.graphicProperties,attributes:{...n.graphicProperties?.attributes},symbol:n.graphicSymbol??this._getGraphicSymbolFromTool(r)});return n.graphicSymbol||s.addHandles(_(()=>this._getGraphicSymbolFromTool(r),e=>c.symbol=e)),this._set(`createGraphic`,c),i.addAndActivateTool(s),s.begin(e),s}get test(){}wait(){return y(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled==null&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled!=null&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){let e=this.view;if(!e){this._logMissingView();return}f(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await g(y(()=>e?.ready),this._viewReadyAbortController.signal)}_logMissingView(){this._logError(`sketch:missing-property`,K(`view`))}_logMissingLayer(){this._logError(Re,K(`layer`))}};e([b()],G.prototype,`_defaultSnappingManager`,void 0),e([b()],G.prototype,`_operationContext`,void 0),e([b()],G.prototype,`_layerAdapter`,null),e([b()],G.prototype,`_pluginManager`,void 0),e([b({readOnly:!0})],G.prototype,`settingsManager`,void 0),e([b()],G.prototype,`_operationHandle`,void 0),e([b({readOnly:!0})],G.prototype,`_updatingHandles`,void 0),e([b({readOnly:!0})],G.prototype,`_toolTransitionHandles`,void 0),e([b()],G.prototype,`_drawToolSimplifyAbortController`,void 0),e([b({readOnly:!0})],G.prototype,`activeTool`,null),e([b()],G.prototype,`geometrySimplificationInProgress`,null),e([b({readOnly:!0})],G.prototype,`activeCreateToolDrawMode`,null),e([b()],G.prototype,`activeTooltip`,null),e([b({types:E})],G.prototype,`activeFillSymbol`,void 0),e([b()],G.prototype,`activeLineSymbol`,void 0),e([b()],G.prototype,`activeVertexSymbol`,void 0),e([b()],G.prototype,`allowDeleteKey`,void 0),e([b({readOnly:!0})],G.prototype,`createGraphic`,null),e([b()],G.prototype,`defaultCreateOptions`,null),e([b()],G.prototype,`defaultUpdateOptions`,null),e([b()],G.prototype,`activeUpdateOptions`,void 0),e([b({type:M,nonNullable:!0})],G.prototype,`labelOptions`,null),e([b()],G.prototype,`layer`,void 0),e([b({types:E})],G.prototype,`pointSymbol`,void 0),e([b({types:E})],G.prototype,`polygonSymbol`,void 0),e([b({types:E})],G.prototype,`polylineSymbol`,void 0),e([b()],G.prototype,`meshSymbol`,void 0),e([b({type:T})],G.prototype,`textSymbol`,null),e([b({type:F,nonNullable:!0})],G.prototype,`snappingOptions`,null),e([b()],G.prototype,`snappingManager`,null),e([b({readOnly:!0})],G.prototype,`state`,null),e([b()],G.prototype,`toolTransitionInProgress`,null),e([b({type:Se,nonNullable:!0})],G.prototype,`tooltipOptions`,null),e([b({readOnly:!0})],G.prototype,`updateGraphics`,void 0),e([b()],G.prototype,`updateOnGraphicClick`,void 0),e([b()],G.prototype,`useViewOptions`,void 0),e([b()],G.prototype,`cancelUpdateOnClickAway`,void 0),e([b()],G.prototype,`updating`,null),e([b()],G.prototype,`creationMode`,void 0),e([b({type:Ce,nonNullable:!0})],G.prototype,`valueOptions`,null),e([b({types:E})],G.prototype,`vertexSymbol`,void 0),e([b({value:null})],G.prototype,`view`,null),e([b({constructOnly:!0,type:N})],G.prototype,`sketchOptions`,void 0),e([b()],G.prototype,`useLegacyCreateTools`,void 0),e([b()],G.prototype,`isUsingLegacyCreateTools`,null),e([b()],G.prototype,`pluginManager`,null),e([b()],G.prototype,`drawTool`,null),e([b()],G.prototype,`activePluginConfigurations`,null),e([b()],G.prototype,`rootPlugins`,null),e([b()],G.prototype,`effectiveAvailablePlugins`,null),e([b()],G.prototype,`firstPluginWithSwappableLeaf`,null),e([b()],G.prototype,`multiplePluginsActive`,null),G=e([re(`esri.widgets.Sketch.SketchViewModel`)],G);const Re=`sketch:missing-property`,K=e=>`Property '${e}' is missing on SketchViewModel.`;function ze(e){return e===`polygon`||e===`rectangle`||e===`circle`}function q(e,t){Y(`undo`,e.history.undo,e.history.redo,t)}function J(e,t){Y(`redo`,e.history.redo,e.history.undo,t)}function Y(e,t,n,r){let i=t.pop();if(!i)return;let a=i.updates,o=[];r.forEach((t,n)=>{let r=a[n];r!=null&&(`geometry`in r&&r.geometry!=null&&(o.push({geometry:t.geometry}),t.geometry=r.geometry),`symbol`in r&&r.symbol!=null&&(o.push({symbol:t.symbol}),t.symbol=r.symbol),`undo`in r&&(o.push(r),r[e](t)))}),n.push({updates:o})}function X(e,t){e!=null&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Z(e){return{updates:e.map(({geometry:e})=>e?.type===`mesh`?{geometry:e.cloneShallow()}:{geometry:e})}}function Q(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function $(e){return`requireError`in e&&e.requireError===`aborted`}export{G as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as n}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{handlesGroup as o,makeHandle as s,drainHandles as c,destroyHandle as l}from"../../core/handleUtils.js";import has from"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as f,removeMaybe as p}from"../../core/maybe.js";import{createAbortError as m,ignoreAbortErrors as h,whenOrAbort as g}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as v,on as ee,when as te,sync as ne,whenOnce as y}from"../../core/reactiveUtils.js";import{property as b,subclass as re}from"../../core/accessorSupport/decorators.js";import{trackAccess as x}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as ie}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as S}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as ae}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as oe,isLoaded as se,load as ce,project as le}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as ue}from"../../geometry/support/spatialReferenceUtils.js";import de from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as fe}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as pe}from"../../support/elevationInfoUtils.js";import me from"../../symbols/FillSymbol3DLayer.js";import he from"../../symbols/MeshSymbol3D.js";import ge from"../../symbols/SimpleFillSymbol.js";import _e from"../../symbols/SimpleLineSymbol.js";import w from"../../symbols/SimpleMarkerSymbol.js";import T from"../../symbols/TextSymbol.js";import{symbolTypes as E}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as ve}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as ye}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as be}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as O}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as k}from"../../views/input/InputManager.js";import{sketchKeys as A}from"../../views/interactive/keybindings.js";import{bindViewToolOptions as xe}from"../../views/interactive/options/bindViewToolOptions.js";import j from"../../views/interactive/options/InteractiveToolOptions.js";import M from"../../views/interactive/sketch/SketchLabelOptions.js";import N from"../../views/interactive/sketch/SketchOptions.js";import Se from"../../views/interactive/sketch/SketchTooltipOptions.js";import Ce from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as P}from"../../views/interactive/snapping/SnappingManager.js";import{acquireForViewOptions as we}from"../../views/interactive/snapping/SnappingManagerPool.js";import F from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as I}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as Te}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as Ee}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as De}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as L}from"../../views/support/screenUtils.js";import Oe from"./adapters/layer/GraphicsLayerAdapter.js";import ke from"./adapters/layer/MapNotesLayerAdapter.js";import Ae from"./adapters/layer/SketchLayerAdapter.js";import{CreateOperationHandle as je,DrawToolOperationHandle as Me,UpdateOperationHandle as R}from"./support/OperationHandle.js";import{PluginManager as Ne}from"./support/PluginManager.js";import{SettingsManager as Pe}from"./support/SettingsManager.js";import{getLegacyTool as z,isCompletelyDegenerate as Fe,graphicsHaveTooFewVerticesForBox as B,getModeFromCreateOptions as Ie,getDrawToolGeometryTypeFromCreateTool as Le}from"./support/sketchUtils.js";const V={defaultZ:0},H={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:Ee},tool:`transform`},U=Symbol(),W=Symbol();let G=class extends a{constructor(e){super(e),this._defaultSnappingManager=null,this._operationContext=null,this._internalGraphicsLayer=new de({listMode:`hide`,internal:!0,title:`SVM Internal`}),this._pluginManager=new Ne({sketchViewModel:this}),this.settingsManager=new Pe({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new S,this._toolTransitionHandles=new S,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new Te,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 ge({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new _e({color:[130,130,130,1],width:2}),this.meshSymbol=new he({symbolLayers:new r([new me])}),this.updateGraphics=new r,this.updateOnGraphicClick=!0,this.useViewOptions=!1,this.cancelUpdateOnClickAway=!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 N,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{let{_layerAdapter:e}=this;if(this.removeHandles(W),!e)return;let t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},v)].filter(n);this.addHandles(t,W)},this._originalPopupEnabled=null,this.defaultCreateOptions=V,this.defaultUpdateOptions=H,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new F,this.textSymbol=new T({text:`text`})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([ee(()=>this.view?.map?.layers,`change`,e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),v),_(()=>this.view,e=>{this._defaultSnappingManager=d(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new P({view:e,options:this.snappingOptions})),e.type===`2d`?(import(`../../views/2d/interactive/editingTools.js`),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):e.type===`3d`&&(import(`../../views/3d/interactive/editingTools.js`),import(`../../views/3d/layers/GraphicsLayerView3D.js`)))},v),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),I(this,void 0,()=>this._operationSnappingManager?.options??this.snappingOptions)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=d(this._defaultSnappingManager),this._destroyOperationContext(),this._set(`snappingManager`,null),this._set(`view`,null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit(`destroy`)}get _operationSnappingManager(){return this._operationContext?.snappingManager??this.snappingManager}get _operationToolOptions(){return this._operationContext?.toolOptions??this.sketchOptions}get _layerAdapter(){let{layer:e}=this;switch(e?.type){case`graphics`:return new Oe(e);case`map-notes`:return new ke(e);case`sketch`:return new Ae(e);case void 0:default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){let e=this._operationHandle;if(e?.type===`create`&&e.activeComponent&&`mode`in e.activeComponent)return e.activeComponent.mode;if(e?.activeComponent?.type===`draw-2.0`){let t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(n).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){let{activeComponent:e,destroyed:t}=this,n=!t&&e&&`tooltip`in e?e.tooltip:null;return n?.visible?n:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return this.activeComponent!=null&&(this.activeComponent.type===`draw-3d`||this.activeComponent.type===`draw-2d`)?this.activeComponent.graphic:this._get(`createGraphic`)}get defaultCreateOptions(){return this._get(`defaultCreateOptions`)}set defaultCreateOptions(e){this._set(`defaultCreateOptions`,{...V,...e})}get defaultUpdateOptions(){return this._get(`defaultUpdateOptions`)}set defaultUpdateOptions(e){this._set(`defaultUpdateOptions`,{...H,...e,reshapeOptions:{...H.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...H.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){this._defaultSnappingManager!=null&&(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=d(this._defaultSnappingManager)),this._override(`snappingManager`,e);else{let{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new P({options:this.snappingOptions,view:e})),this._clearOverride(`snappingManager`)}}get state(){let e=!!(this.view?.ready&&this.layer),t=this._operationHandle;return e&&t?`active`:e?`ready`:`disabled`}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||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){let t=this._get(`view`);if(t){let{container:e,map:n}=t;e&&this._clearCursor(),n?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}let n=`view-ready`;this.removeHandles(n),e&&this.addHandles(te(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},v),n),this._set(`view`,e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||this.view?.type!==`2d`}get pluginManager(){return this._pluginManager}get drawTool(){return this.activeComponent?.type===`draw-2.0`?this.activeComponent:null}get activePluginConfigurations(){return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).filter(n)??[]}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome(`rootPlugins`,e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;let 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(n)??[]}get firstPluginWithSwappableLeaf(){let e=this.view?.type??`2d`;return this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>t!=null&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1)}get multiplePluginsActive(){return this.drawTool?this.drawTool.pluginStack.length>1:!1}replaceLeaf(e){this.drawTool?.replaceLeaf(e)}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=f(this._moduleLoaderAbortController),this._viewReadyAbortController=f(this._viewReadyAbortController),this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){let{state:e,updateGraphics:t}=this;if(e===`active`&&t.length){let{activeTool:e}=this,n=t.toArray();this.removeGraphics(n),this.cancel(),this._emitDeleteEvent({graphics:n,tool:e})}}duplicate(){if(this.state===`active`&&this.updateGraphics.length){let 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){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{view:n,layer:r}=this;if(!n||this.state===`disabled`)throw r||this._logMissingLayer(),m();if(n.activeTool!=null&&(n.activeTool=null),!e){this._logError(`sketch:missing-parameter`,`Missing parameter 'tool'.`);return}O(n,this._internalGraphicsLayer);let i=this._createOperationContext(n),a;try{a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t))}catch(e){throw this._destroyOperationContext(i),e}if(a==null||this.destroyed||i!==this._operationContext){let e=i===this._operationContext;a?.onEnd(),d(a),this._destroyOperationContext(i),e&&n.map?.remove(this._internalGraphicsLayer);return}let o=z(e);a.on(`complete`,()=>{if(a===this._operationHandle){let n=this.createGraphic,r=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._set(`createGraphic`,null),this.view?.map?.remove(this._internalGraphicsLayer),!a.cancelled&&n!=null&&this.addGraphic(n),this._sketchContinuationFlag=!1,this.emit(`create`,{graphic:n,state:r?`cancel`:`complete`,tool:o??`point`,toolEventInfo:null,type:`create`}),r||this._sketchContinuationFlag)return;let{creationMode:i}=this;if(i===`continuous`){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(h(this.create(e,t)))}else i===`update`&&n&&this._updatingHandles.consumePromise(h(this.update([n])))}}),this._operationHandle=a,n.ready&&n.focus()}async place(e,t){return await e.load(),this.create(`mesh`,{mode:`click`,hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());let{layer:n,view:r,state:i}=this;if(!r||i===`disabled`)throw n||this._logMissingLayer(),m();r.activeTool!=null&&(r.activeTool=null);let a=Array.isArray(e)?e:[e];if(e==null||!a?.length){this._logError(`sketch:missing-parameter`,`Missing parameter 'graphics'.`);return}if(a.some(e=>this.hasGraphic(e)?e.geometry==null&&(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;let o=this._createOperationContext(r),s;try{s=await this._updatingHandles.addPromise(this._setupUpdateOperation(a,t))}catch(e){throw this._destroyOperationContext(o),e}if(this.destroyed||s==null||$(s)||o!==this._operationContext){s&&!$(s)&&(s.onEnd(),s.destroy()),this._destroyOperationContext(o);return}O(r,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit(`update`,{graphics:a,state:`start`,aborted:!1,tool:s.tool,toolEventInfo:null,type:`update`})}async _updateSpatialReference(e){let t=this.view;if(!t){this._logMissingView();return}e=Array.isArray(e)?e:[e];for(let n of e)n.geometry!=null&&n.geometry.type!==`mesh`&&!ue(n.geometry.spatialReference,t.spatialReference)&&(!oe(n.geometry.spatialReference,t.spatialReference)&&!se()&&await ce(),n.geometry=le(n.geometry,t.spatialReference))}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}_createOperationContext(e){this._destroyOperationContext();let t=this.useViewOptions?e.options:null,n=t?we(e):null,r=t?new j:this.sketchOptions,i;if(t){let{values:t}=r;i=o([xe(r,()=>e.options,()=>this.sketchOptions),_(()=>t.directionMode,e=>{this.sketchOptions.values.directionMode=e},ne)])}return this._operationContext={snappingManager:n?.snappingManager??this.snappingManager,toolOptions:r,...o([n,i])}}_destroyOperationContext(e=this._operationContext){if(e!==this._operationContext){p(e);return}this._operationContext=p(this._operationContext)}async _getFirstHit(e){let t=this.view;if(!t)return this._logMissingView(),null;if(t.type===`2d`){let n=[];t.map.allLayers.forEach(e=>{(e.type===`vector-tile`||e.type===`imagery`)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});return De(r.results)}let n=[t.map.ground];t.map.allLayers.forEach(e=>{fe(e)&&(!has(`enable-feature:im-as-ground`)||e.isUsedAsGroundLayer)&&n.push(e)});let r=await t.hitTest(e,{exclude:n});if(r.results.length>0){let e=r.results[0];if(e!=null&&e.type===`graphic`&&e.graphic&&(!r.ground.mapPoint||t.map.ground.opacity<1||r.ground.distance-(e.distance??0)>-Math.min(3*r.ground.distance,t.viewingMode===`global`?ae(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:1/0)))return e}return null}_generateViewHandles(e){return[e.on(`immediate-click`,async e=>{let t=this.state===`active`&&this._operationHandle?.type===`create`;this.state!==`disabled`&&!t&&this.updateOnGraphicClick&&await this._toolTransitionHandles.addPromise(this._handleImmediateClick(e))},k.WIDGET)]}async _handleImmediateClick(e){let t=await e.defer(()=>this._getFirstHit(L(e))),n=null;if(t!=null){let r=t.graphic;this.updateGraphics.includes(r)||this.hasGraphic(r)?(e.stopPropagation(),n=r):this.view?.type===`2d`&&!this._isComponentGraphic(r)&&this.state===`active`&&this.cancel()}else this.state===`active`&&this.cancelUpdateOnClickAway&&this.cancel();n!=null&&!this.updateGraphics.includes(n)&&await this.update([n],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r={hasZ:n.type===`3d`,...this.defaultCreateOptions,...t},i=typeof e==`string`?this.pluginManager?.getPluginsEquivalentToCreateTool(e,r.mode):e,a=z(e);if(i&&!this.isUsingLegacyCreateTools){let e=await this._setupDrawTool(i,r,a??`polyline`);if(e)return this._setupDrawToolOperationHandle(e,a??`point`)}if(!a)return null;let o=await this._setupDrawGraphicTool(a,n,r);return o==null?null:(n.tools.add(o),n.activeTool=o,this._setupCreateOperationHandle(o,a))}async _setupDrawGraphicTool(e,t,n){if(e===`multipoint`&&t.type===`3d`)return this._logError(`sketch:create`,`Multipoint geometries are not supported in SceneView.`),null;if(!t)return this._logMissingView(),null;let{cursor:r,defaultZ:i,hasZ:a,geometryToPlace:o,graphicProperties:s,mode:c,preserveAspectRatio:l}=n,u=Ie(c,e),d=Le(e),f=n?.optionsPerTool?.has(e)?n.optionsPerTool.get(e):{},p=f?.preserveAspectRatio??l??e!==`rectangle`,m={centered:e!==`rectangle`&&!(e===`circle`&&!p),cursor:r,defaultZ:i,forceUniformSize:p,graphicProperties:{...s,attributes:{...s?.attributes}},geometryToPlace:o,geometryType:d,mode:u,graphicSymbol:n.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:a,snappingManager:this._operationSnappingManager,snapToScene:!1,view:t,...f};return t.type===`2d`?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){let t=await this._requireModule(import(`../../views/2d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ze(e.geometryType)?this.activeFillSymbol:null,toolOptions:this._operationToolOptions})}async _makeDrawGraphicTool3D(e){let t=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));return $(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,toolOptions:this._operationToolOptions})}_setupCreateOperationHandle(e,t){let n=this.view;if(!n)return this._logMissingView(),null;let r=null,i=e.forceUniformSize,a=e.centered,o=new ie,l=[s(()=>o.destroy()),n.on(`key-down`,t=>{if(t.key===A.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===A.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key===A.vertexAdd&&!t.repeat){let n=e.drawOperation.geometryType;(n===`polyline`||n===`polygon`||n===`multipoint`)&&(t.stopPropagation(),e.drawOperation.commitStagedVertex())}else t.key===A.undo?(t.stopPropagation(),u.undo()):t.key===A.redo?(t.stopPropagation(),u.redo()):t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)&&!t.repeat?(e.forceUniformSize=!i,t.stopPropagation()):t.key===A.center&&(t.repeat||(e.centered=!a,t.stopPropagation()))},k.WIDGET),n.on(`key-up`,t=>{t.key===A.pan?e.enabled=!0:t.key===A.constraint&&(e.geometryType===`rectangle`||e.geometryType===`circle`)?(e.forceUniformSize=i,t.stopPropagation()):t.key===A.center&&(e.centered=a,t.stopPropagation())},k.WIDGET),e.on(`vertex-update`,()=>{o.notify()}),e.on(`vertex-add`,t=>{switch(o.notify(),r=r==null?`start`:`active`,t.operation){case`apply`:this.emit(`create`,{graphic:e.graphic,state:r,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(o.notify(),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),r=`complete`,e.aborted?u&&u.cancel():u&&u.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],u=new je({activeComponent:e,type:`create`,onEnd:()=>{c(l),n.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(x(o),e.canUndo),canRedo:()=>(x(o),e.canRedo)});return u}_setupDrawToolOperationHandle(e,t){let r=this.view;if(!r)return this._logMissingView(),null;let i=null,a=[r.on(`key-down`,t=>{t.key===A.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},k.WIDGET),r.on(`key-up`,t=>{t.key===A.pan&&(e.editable=!0)},k.WIDGET),e.on(`before-vertex-add`,t=>{let n=e.mostUpstreamPlugin?.configuration;if(n&&`legacyCreateTool`in n&&(n?.legacyCreateTool===`point`||n.legacyCreateTool===`text`)){let e=t.detail.originalEvent;e&&`key`in e&&e.key===A.vertexAdd&&t.preventDefault();return}}),e.on(`before-complete`,t=>{let n=e.getGeometryIfCompleted();if(!n||Fe(n)){t.preventDefault();return}}),e.on([`vertex-add`,`vertex-remove`],r=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),i=i==null&&r.type!==`vertex-remove`?`start`:`active`,r.operation){case`apply`:this.emit(`create`,{graphic:this.createGraphic,state:i,tool:this.activeTool,toolEventInfo:r,type:`create`});break;case`undo`:this._emitUndoEvent({graphics:[this.createGraphic].filter(n),tool:t});break;case`redo`:this._emitRedoEvent({graphics:[this.createGraphic].filter(n),tool:t})}}),e.on(`cursor-update`,t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit(`create`,{graphic:this.createGraphic,state:`active`,tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:`cursor-update`},type:`create`})}),e.on(`complete`,async({geometry:t,isSimple:n})=>{let r=this.createGraphic,i=!!t&&t.type!==`mesh`&&t.type!==`extent`&&!n;if(r&&(r.geometry=n?t:e.unprocessedGeometry??t),!i||!r)o.complete();else{this._internalGraphicsLayer.add(this.createGraphic);let e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(h(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:r,handle:o})))}})],o=new Me({activeComponent:e,type:`create`,onEnd:()=>{c(a),r.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return a.push(e.on(`cancel`,()=>{this._drawToolSimplifyAbortController=f(this._drawToolSimplifyAbortController),o.cancel()})),o}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:n,handle:r}){let i=this.view?.acquireCursor(`progress`,`high`);i&&this.addHandles(i);let a=()=>e.signal.aborted?(n&&(this._layerAdapter?.remove(n),this._internalGraphicsLayer?.remove(n)),this._set(`createGraphic`,null),!0):!1;try{let i=await this._geometryWorkerHandle.simplify(t,e.signal);if(a())return;n.geometry=i??t,this._internalGraphicsLayer?.remove(n),r.complete()}finally{i?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_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){let{view:n}=this;if(!n)return this._logMissingView(),null;let r={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=r;let i=r.tool??H.tool;if(this.removeGraphics(e),this.addGraphics(e),n.type===`3d`){if(e.length===0)return null;switch(i){case`move`:return this._setupMove3DOperation(e,r,n,i);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupReshape3DOperation(e[0],r,n);case`transform`:return this._setupGraphicTransform3DOperation(e,r,n)}}switch(i){case`move`:return this._setupMove2DOperation(e,r,n);case`reshape`:return e.length>1?(this._logError(`sketch:reshape-multiple`,`Reshape operation does not support multiple graphics.`),null):this._setupTransformOrReshape2DOperation(e,i,r,n);case`transform`:return B(e)&&(i=`reshape`),this._setupTransformOrReshape2DOperation(e,i,r,n)}}async _setupMove3DOperation(e,t,n,r,i=!1){let a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,MoveTool3D:s}=a.module,l=new Map,u=()=>{l.forEach(e=>e.destroy()),l.clear()};for(let t of e){let e=new o({view:n,graphic:t}),r=ve(e);if(r!==0)return u(),this._logError(`sketch:move`,`Move operation not supported for provided graphic(s) (${D(r)}).`),null;l.set(t,e)}let d=new s({view:n,enableZ:t.enableZ,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(d),d.objects.addMany(Array.from(l.values())),i||this.updateGraphics.addMany(e);let f=[],p=new R({activeComponent:d,tool:r,type:`update`,onEnd:()=>{c(f),Q(n,d),u()},undo:()=>{X(this.view,d),q(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},addToSelection:async e=>{this.updateGraphics.push(e);let t=new o({view:n,graphic:e});l.set(e,t),d.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:async e=>{let t=this.updateGraphics.indexOf(e);if(p.history.undo.forEach(e=>e.updates.splice(t,1)),p.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`}),this.updateGraphics.length===0){p.complete();return}let n=l.get(e);n&&(d.objects.remove(n),n.destroy(),l.delete(e))},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1||r!==`transform`)return;let e=this.updateGraphics.at(0),i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));i&&!$(i)&&(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(i,t))}});return f.push(...this._getHandlesForComponent(p,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(p,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e)},k.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,n,r=!1){if(e.length===1&&be(e[0])===0){let i=e[0],a=i.geometry;if(a!=null&&(a.type===`point`||a.type===`mesh`))return this._setupPointTransform3DOperation(i,t,n);if(a!=null&&(a.type===`polygon`||a.type===`polyline`))return this._setupPolyTransform3DOperation(i,t,n,r)}return this._setupMove3DOperation(e,t,n,`transform`,r)}async _setupPointTransform3DOperation(e,t,n){let r=`transform`,{enableRotation:i,enableScaling:a,enableZ:o}=t,s=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(s))return s;let{TransformTool3D:l,ManipulatedObject3DGraphic:u}=s.module,d=new u({graphic:e,view:n}),f=new l({object:d,view:n,enableRotation:i,enableScaling:a,enableZ:o,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),this.updateGraphics.add(e);let p=[],m=new R({activeComponent:f,tool:r,type:`update`,onEnd:()=>{c(p),Q(n,f),d.destroy()},undo:()=>{X(this.view,f),q(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r})},redo:()=>{J(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r})},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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,n,r=!1){let i=`transform`,{enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:l}=t,u=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(u))return u;let{ManipulatedObject3DGraphic:d,ExtentTransformTool:f}=u.module,p=this.view?.inputManager?.isModifierKeyDown(A.constraint),m=new d({view:n,graphic:e}),h=new f({object:m,view:n,enableRotation:a,enableScaling:o,enableZ:s,preserveAspectRatio:!!l!=!!p,toolOptions:this._operationToolOptions});n.tools.add(h),r||this.updateGraphics.add(e);let g=[],_=new R({activeComponent:h,tool:i,type:`update`,onEnd:()=>{c(g),Q(n,h),m.destroy()},canUndo:()=>!h.destroyed&&h.canUndo,undo:()=>{h.destroyed||(h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!h.destroyed&&h.canRedo,redo:()=>{h.destroyed||(h.redo(),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`}),await this._replaceUpdateOperationHandle(_,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),_.complete()},toggleTool:async()=>{if(this.updateGraphics.length!==1||t.toggleToolOnClick===!1)return;let r=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,n,!0));r&&!$(r)&&(_.onEnd(),_.destroy(),this._setUpdateOperationHandle(r,t))}});return g.push(...this._getHandlesForComponent(_,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(_,e,t),k.WIDGET),n.on(`key-down`,e=>this._getCommonUpdateOperationKeyDownHandlers(_,e),k.WIDGET),n.on(`key-down`,e=>{e.key===A.constraint&&!e.repeat&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())},k.WIDGET)),_}async _setupMove2DOperation(e,t,n){let r=`move`;this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,n));if($(i))return i;let a=new R({activeComponent:i,tool:r,type:`update`,onEnd:()=>{this._clearCursor(),c(l),c(s),i.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{let e=this.updateGraphics.toArray();q(a,e),a.refreshComponent(),this._emitUndoEvent({graphics:e,tool:r})},redo:()=>{let e=this.updateGraphics.toArray();J(a,e),a.refreshComponent(),this._emitRedoEvent({graphics:e,tool:r})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),i.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:async e=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();if(this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`}),this.updateGraphics.length===0){a.complete();return}i.graphics=n}}),o=!1,s=[n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&(o=!0,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET),n.on(`key-up`,e=>{e.key===A.constraint&&o&&(o=!1,i.enableMoveAllGraphics=!i.enableMoveAllGraphics)},k.WIDGET)],l=this._getHandlesForComponent(a,t);return a}async _setupReshape3DOperation(e,t,n,r=!1){let i=`reshape`,a=await this._requireModule(import(`../../views/3d/interactive/editingTools.js`));if($(a))return a;let{ManipulatedObject3DGraphic:o,ReshapeTool3D:s}=a.module,l=new o({view:n,graphic:e}),u=ye(l);if(u!==0)return l.destroy(),this._logError(`sketch:reshape`,`Reshape operation not supported for provided graphic(s) (${D(u)}).`),null;let d=t.reshapeOptions,f=new s({view:n,object:l,enableZVertex:t.enableZ&&d?.vertexOperation===`move`,enableZShape:t.enableZ&&d?.shapeOperation===`move`,enableMoveObject:d?.shapeOperation===`move`||d?.shapeOperation===`move-xy`,enableMidpoints:d?.edgeOperation===`split`,enableEdgeOffset:d?.edgeOperation===`offset`,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions});n.tools.add(f),r||this.updateGraphics.add(l.graphic);let p=[],m=new R({activeComponent:f,tool:i,type:`update`,onEnd:()=>{c(p),Q(n,f),l.destroy()},canUndo:()=>!f.destroyed&&f.canUndo,undo:()=>{f.destroyed||(f.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i}))},canRedo:()=>!f.destroyed&&f.canRedo,redo:()=>{f.destroyed||(f.redo(),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`}),await this._replaceUpdateOperationHandle(m,t,()=>this._setupMove3DOperation(this.updateGraphics.toArray(),t,n,`transform`,!0))},removeFromSelection:async 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`}),m.complete()},toggleTool:async()=>{t.toggleToolOnClick!==!1&&await this._replaceUpdateOperationHandle(m,t,()=>this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,n,!0))}});return p.push(...this._getHandlesForComponent(m,t),n.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(m,e,t),k.WIDGET),n.on(`key-down`,e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},k.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,n,r){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));let i=await this._updatingHandles.addPromise(t===`transform`?this._getBox(e,n,r):this._getReshape(e,n,r));if($(i))return i;let a=new R({activeComponent:i,type:`update`,onEnd:()=>{c(s),c(o),a.activeComponent&&!a.activeComponent.destroyed&&a.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{q(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},redo:()=>{J(a,this.updateGraphics.toArray()),a.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a.tool})},addToSelection:async e=>{let t=a.activeComponent;if(t?.type===`reshape`){let t=[...this.updateGraphics,e];if(this.updateGraphics.removeAll(),!await this._replaceUpdateOperationHandle(a,n,()=>this._setupTransformOrReshape2DOperation(t,`transform`,n,r)))return}else this.updateGraphics.add(e),t=t,t.graphics=this.updateGraphics.toArray(),t.refresh(),a.resetHistory();this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:`selection-change`},type:`update`})},removeFromSelection:async e=>{let t=this.updateGraphics.indexOf(e);a.history.undo.forEach(e=>e.updates.splice(t,1)),a.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);let n=this.updateGraphics.toArray();n.length===0?a.complete():B(n)?await a.toggleTool():a.activeComponent.graphics=n,this.emit(`update`,{graphics:n,state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:`selection-change`},type:`update`})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;let e=this.updateGraphics.at(0),t=e.geometry;if(t!=null&&(a.tool===`reshape`&&t.type===`point`||a.tool===`transform`&&t.type===`extent`))return;let i=null,o={...this.defaultUpdateOptions,...n,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...n?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...n?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};a.tool===`transform`?i=await this._updatingHandles.addPromise(this._getReshape([e],o,r)):a.tool===`reshape`&&(i=await this._updatingHandles.addPromise(this._getBox([e],o,r))),!$(i)&&(a.activeComponent?.destroy(),a.activeComponent=i,a.activeComponent&&(c(s),s=this._getHandlesForComponent(a,o)))}}),o=[r.on(`immediate-click`,e=>this._getCommonUpdateOperationClickHandlers(a,e,n),k.WIDGET),r.on(`key-down`,e=>{if(this._getCommonUpdateOperationKeyDownHandlers(a,e),e.key===A.constraint&&!e.repeat&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET),r.on(`key-up`,e=>{if(e.key===A.constraint&&a){let e=a.activeComponent;e?.type===`box`&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},k.WIDGET)],s=this._getHandlesForComponent(a,n);return a}async _getGraphicMover(e,t,n){let{enableMoveAllGraphics:r,highlightOptions:i}=t,a=await this._requireModule(import(`../../views/draw/support/GraphicMover.js`));return $(a)?a:new a.module.default({enableMoveAllGraphics:r,highlightName:i?.name,highlightsEnabled:!!i?.enabled,indicatorsEnabled:!1,graphics:e,view:n,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`grabbing`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-start`},type:`update`})},onGraphicMove:({dx:e,dy:t,graphic:n})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move`},type:`update`}),onGraphicMoveStop:({dx:e,dy:t,graphic:n})=>{this._displayCursor(`pointer`),this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:`move-stop`},type:`update`})},onGraphicPointerOver:()=>this._displayCursor(`move`),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,n){let{enableRotation:r,enableScaling:i,highlightOptions:a,preserveAspectRatio:o}=t,s=await this._requireModule(import(`../../views/draw/support/Box.js`));if($(s))return s;let c=this.view?.inputManager?.isModifierKeyDown(A.constraint),l=new s.module.default({graphics:e,enableRotation:r,enableScaling:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,preserveAspectRatio:!!o!=!!c,layer:this._internalGraphicsLayer,view:n,toolOptions:this._operationToolOptions,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,n])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=n??t.enableScaling??!0,l.refresh()},v)),l}async _getReshape(e,t,n){let{highlightOptions:r,reshapeOptions:i}=t,a=i?.edgeOperation===`split`,o=i?.shapeOperation===`move`,s=!!i?.enableCreateCurveFromStraightEdge,c=await this._requireModule(import(`../../views/draw/support/Reshape.js`));return $(c)?c:new c.module.default({enableMidpoints:a,enableMovement:o,enableCurveOnMidpoint:s,graphic:e[0],highlightName:r?.name,highlightsEnabled:!!r?.enabled,layer:this._internalGraphicsLayer,snappingManager:this._operationSnappingManager,toolOptions:this._operationToolOptions,view:n,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:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMove:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onMoveStop:({dx:e,dy:t,mover:n,type:r})=>this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:n,type:r},type:`update`}),onVertexAdd:({added:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{added:r,vertices:n,type:t},type:`update`})},onVertexRemove:({removed:e,type:t,vertices:n})=>{let r=e.map(e=>C(e.geometry));this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:{removed:r,vertices:n,type:t},type:`update`})}}})}_getHandlesForComponent(e,t){let n=e.activeComponent;if(!n)return[];switch(n.type){case`graphic-mover`:return[n.on(`graphic-click`,({graphic:n,viewEvent:r})=>{r.native?.shiftKey&&t.multipleSelectionEnabled&&(r.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(n)))}),n.on(`graphic-move-start`,t=>e.addToHistory(Z(t.allGraphics)))];case`box`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`rotate-start`,t=>e.addToHistory(Z(t.graphics))),n.on(`scale-start`,t=>e.addToHistory(Z(t.graphics)))];case`reshape`:return[n.on(`graphic-click`,n=>this._onTransformOrReshape2DGraphicClick(e,t,n)),n.on(`move-start`,t=>e.addToHistory(Z([t.mover]))),n.on(`reshape-start`,t=>e.addToHistory(Z([t.graphic]))),n.on(`vertex-add`,t=>e.addToHistory(Z([t.oldGraphic]))),n.on(`vertex-remove`,t=>e.addToHistory(Z([t.oldGraphic])))];case`move-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`transform-3d`:return[n.events.on(`record-undo`,({updates:t})=>{e.addToHistory({updates:t})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.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`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})];case`reshape-3d`:return[n.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`})}),n.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`})}),n.events.on(`vertex-add`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`vertex-remove`,e=>{this.emit(`update`,{graphics:this.updateGraphics.toArray(),state:`active`,aborted:!1,tool:this.activeTool,toolEventInfo:e,type:`update`})}),n.events.on(`immediate-click`,n=>{this._updatingHandles.consumePromise(n.shiftKey?this._toggleSelection([n.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,n){let{graphic:r,viewEvent:i}=n;if(i.native?.shiftKey&&this.hasGraphic(r)){i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(r));return}t.toggleToolOnClick&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}async _replaceUpdateOperationHandle(e,t,n){let r=this._operationContext;e.onEnd(),e.destroy();let i=await this._updatingHandles.addPromise(n());return!i||$(i)||r!==this._operationContext?(i&&!$(i)&&(i.onEnd(),i.destroy()),this._destroyOperationContext(r),!1):(this._setUpdateOperationHandle(i,t),!0)}_setUpdateOperationHandle(e,t){this._operationHandle=e;let n=this.view?.map;this._disablePopup(t),e.on(`complete`,()=>{if(e===this._operationHandle){let r=this.updateGraphics.toArray(),i=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._destroyOperationContext(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),n&&n.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit(`update`,{graphics:r,state:`complete`,aborted:e.cancelled,tool:i,toolEventInfo:null,type:`update`})}})}_getCommonUpdateOperationClickHandlers(e,t,n){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,n))}async _handleCommonUpdateOperationClick(e,t,n){let r=L(t),i=await t.defer(()=>this._getFirstHit(r));if(i==null){this.cancelUpdateOnClickAway&&e.complete();return}let a=t.native.shiftKey?this._toggleSelection([i.graphic],e,n):null;if(a){t.stopPropagation(),await a;return}this.updateGraphics.includes(i.graphic)?this._shouldTemporarilyDisablePopup(n)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,n){let r=!!n.multipleSelectionEnabled;for(let n of e)if(n!=null&&r&&this.hasGraphic(n))return this.updateGraphics.includes(n)?await t.removeFromSelection(n):await t.addToSelection(n)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;let n=t.key;n===A.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):n===A.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):n===A.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&A.delete.includes(n)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&this._operationHandle.type===`update`&&this.activeComponent!=null&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&=(this.view?.map?.remove(this._internalGraphicsLayer),d(this._internalGraphicsLayer))}_isComponentGraphic(e){let{activeComponent:t}=this;return!e||t==null?!1:e.attributes?.esriSketchTool||t.type===`draw-2d`&&t.graphic===e||(t.type===`box`||t.type===`reshape`)&&t.isUIGraphic(e)}_clearCursor(){this.removeHandles(U)}_displayCursor(e){this.removeHandles(U),this.view?.container&&e!=null&&this.addHandles(this.view.acquireCursor(e,`high`),U)}_logError(e,t,n){u.getLogger(this).error(new i(e,t,n))}async _requireModule(e){let t=new AbortController;this._moduleLoaderAbortController=t;let n=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:`aborted`}:{module:n}}_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(this._operationHandle!=null){let{updateGraphics:t}=this;for(let n of e.removed)if(t.includes(n)){if(t.length>1)this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(n));else{this._operationHandle.cancel();break}}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,n,r){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;let i=this.view,a=await import(`../../views/draw/DrawTool.js`);await this.pluginManager.loadPlugins();let o=await this.pluginManager.makeRenderer({customSymbol:n.graphicSymbol,useTextSymbol:r===`text`}),s=new a.DrawTool({view:i,elevationInfo:this._layerAdapter?.elevationInfo??pe(i.type===`3d`),hasZ:!!n.hasZ,toolOptions:this._operationToolOptions,renderer:o,defaultZ:n.defaultZ??0,directionOptions:n.directionOptions,snappingManager:this._operationSnappingManager,enableVertexVisuals:r!==`rectangle`&&r!==`circle`,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});s.addHandles(l(o));let c=new t({...n.graphicProperties,attributes:{...n.graphicProperties?.attributes},symbol:n.graphicSymbol??this._getGraphicSymbolFromTool(r)});return n.graphicSymbol||s.addHandles(_(()=>this._getGraphicSymbolFromTool(r),e=>c.symbol=e)),this._set(`createGraphic`,c),i.addAndActivateTool(s),s.begin(e),s}get test(){}wait(){return y(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled==null&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&this._originalPopupEnabled!=null&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){let e=this.view;if(!e){this._logMissingView();return}f(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await g(y(()=>e?.ready),this._viewReadyAbortController.signal)}_logMissingView(){this._logError(`sketch:missing-property`,K(`view`))}_logMissingLayer(){this._logError(Re,K(`layer`))}};e([b()],G.prototype,`_defaultSnappingManager`,void 0),e([b()],G.prototype,`_operationContext`,void 0),e([b()],G.prototype,`_layerAdapter`,null),e([b()],G.prototype,`_pluginManager`,void 0),e([b({readOnly:!0})],G.prototype,`settingsManager`,void 0),e([b()],G.prototype,`_operationHandle`,void 0),e([b({readOnly:!0})],G.prototype,`_updatingHandles`,void 0),e([b({readOnly:!0})],G.prototype,`_toolTransitionHandles`,void 0),e([b()],G.prototype,`_drawToolSimplifyAbortController`,void 0),e([b({readOnly:!0})],G.prototype,`activeTool`,null),e([b()],G.prototype,`geometrySimplificationInProgress`,null),e([b({readOnly:!0})],G.prototype,`activeCreateToolDrawMode`,null),e([b()],G.prototype,`activeTooltip`,null),e([b({types:E})],G.prototype,`activeFillSymbol`,void 0),e([b()],G.prototype,`activeLineSymbol`,void 0),e([b()],G.prototype,`activeVertexSymbol`,void 0),e([b()],G.prototype,`allowDeleteKey`,void 0),e([b({readOnly:!0})],G.prototype,`createGraphic`,null),e([b()],G.prototype,`defaultCreateOptions`,null),e([b()],G.prototype,`defaultUpdateOptions`,null),e([b()],G.prototype,`activeUpdateOptions`,void 0),e([b({type:M,nonNullable:!0})],G.prototype,`labelOptions`,null),e([b()],G.prototype,`layer`,void 0),e([b({types:E})],G.prototype,`pointSymbol`,void 0),e([b({types:E})],G.prototype,`polygonSymbol`,void 0),e([b({types:E})],G.prototype,`polylineSymbol`,void 0),e([b()],G.prototype,`meshSymbol`,void 0),e([b({type:T})],G.prototype,`textSymbol`,null),e([b({type:F,nonNullable:!0})],G.prototype,`snappingOptions`,null),e([b()],G.prototype,`snappingManager`,null),e([b({readOnly:!0})],G.prototype,`state`,null),e([b()],G.prototype,`toolTransitionInProgress`,null),e([b({type:Se,nonNullable:!0})],G.prototype,`tooltipOptions`,null),e([b({readOnly:!0})],G.prototype,`updateGraphics`,void 0),e([b()],G.prototype,`updateOnGraphicClick`,void 0),e([b()],G.prototype,`useViewOptions`,void 0),e([b()],G.prototype,`cancelUpdateOnClickAway`,void 0),e([b()],G.prototype,`updating`,null),e([b()],G.prototype,`creationMode`,void 0),e([b({type:Ce,nonNullable:!0})],G.prototype,`valueOptions`,null),e([b({types:E})],G.prototype,`vertexSymbol`,void 0),e([b({value:null})],G.prototype,`view`,null),e([b({constructOnly:!0,type:N})],G.prototype,`sketchOptions`,void 0),e([b()],G.prototype,`useLegacyCreateTools`,void 0),e([b()],G.prototype,`isUsingLegacyCreateTools`,null),e([b()],G.prototype,`pluginManager`,null),e([b()],G.prototype,`drawTool`,null),e([b()],G.prototype,`activePluginConfigurations`,null),e([b()],G.prototype,`rootPlugins`,null),e([b()],G.prototype,`effectiveAvailablePlugins`,null),e([b()],G.prototype,`firstPluginWithSwappableLeaf`,null),e([b()],G.prototype,`multiplePluginsActive`,null),G=e([re(`esri.widgets.Sketch.SketchViewModel`)],G);const Re=`sketch:missing-property`,K=e=>`Property '${e}' is missing on SketchViewModel.`;function ze(e){return e===`polygon`||e===`rectangle`||e===`circle`}function q(e,t){Y(`undo`,e.history.undo,e.history.redo,t)}function J(e,t){Y(`redo`,e.history.redo,e.history.undo,t)}function Y(e,t,n,r){let i=t.pop();if(!i)return;let a=i.updates,o=[];r.forEach((t,n)=>{let r=a[n];r!=null&&(`geometry`in r&&r.geometry!=null&&(o.push({geometry:t.geometry}),t.geometry=r.geometry),`symbol`in r&&r.symbol!=null&&(o.push({symbol:t.symbol}),t.symbol=r.symbol),`undo`in r&&(o.push(r),r[e](t)))}),n.push({updates:o})}function X(e,t){e!=null&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Z(e){return{updates:e.map(({geometry:e})=>e?.type===`mesh`?{geometry:e.cloneShallow()}:{geometry:e})}}function Q(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function $(e){return`requireError`in e&&e.requireError===`aborted`}export{G as default};
@@ -5,6 +5,7 @@ import type MapView from "../../views/MapView.js";
5
5
  import type { ReadonlyArrayOrCollection } from "../../core/Collection.js";
6
6
  import type { Direction, State } from "./types.js";
7
7
 
8
+ /** @deprecated since 5.2. Use the [Swipe component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/) instead. */
8
9
  export interface SwipeViewModelProperties extends Partial<Pick<SwipeViewModel, "direction" | "position" | "step" | "stepMultiplier" | "view">> {
9
10
  /**
10
11
  * A collection of [Layer](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/)s that will show on the left or top side of the Swipe.
@@ -25,6 +26,7 @@ export interface SwipeViewModelProperties extends Partial<Pick<SwipeViewModel, "
25
26
  /**
26
27
  * Provides the logic for the [Swipe widget](https://developers.arcgis.com/javascript/latest/references/core/widgets/Swipe/) and [component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/).
27
28
  *
29
+ * @deprecated since 5.2. Use the [Swipe component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/) instead.
28
30
  * @since 4.13
29
31
  * @see [Swipe widget](https://developers.arcgis.com/javascript/latest/references/core/widgets/Swipe/) - _Deprecated since 4.32. Use the [Swipe component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/) instead._
30
32
  * @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
@@ -1,13 +1,20 @@
1
- /** @since 5.0 */
1
+ /**
2
+ * @deprecated since 5.2. Use the Swipe component's [`state`](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/#state) property instead.
3
+ * @since 5.0
4
+ */
2
5
  export type State = "ready" | "disabled";
3
6
 
4
- /** @since 5.0 */
7
+ /**
8
+ * @deprecated since 5.2. Use the Swipe component's [`direction`](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/#direction) property instead.
9
+ * @since 5.0
10
+ */
5
11
  export type Direction = "vertical" | "horizontal";
6
12
 
7
13
  /**
8
14
  * The visible elements that are displayed within the widget.
9
15
  * This provides the ability to turn individual elements of the widget's display on/off.
10
16
  *
17
+ * @deprecated since 5.2. Use the Swipe component's [`hideHandle`](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/#hideHandle) and [`hideDivider`](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-swipe/#hideDivider) properties instead.
11
18
  * @since 5.0
12
19
  */
13
20
  export interface VisibleElements {
@@ -8,6 +8,7 @@ import type { Action, Stops, TimeSliderMode, TimeSliderState } from "./types.js"
8
8
  import type { ReadonlyArrayOrCollection } from "../../core/Collection.js";
9
9
  import type { TimeExtentProperties } from "../../time/TimeExtent.js";
10
10
 
11
+ /** @deprecated since 5.2. Use the Time Bar component's [fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#fullTimeExtent), [loop](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#loop), [mode](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#mode), [playRate](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#playRate), [stops](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#stops), and [timeExtent](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#timeExtent) properties instead. */
11
12
  export interface TimeSliderViewModelProperties extends Partial<Pick<TimeSliderViewModel, "loop" | "mode" | "playRate" | "stops" | "view">> {
12
13
  /**
13
14
  * Defines actions that will appear in a menu when the user clicks the ellipsis button
@@ -152,7 +153,11 @@ export interface TimeSliderViewModelEvents {
152
153
  "trigger-action": TimeSliderViewModelTriggerActionEvent;
153
154
  }
154
155
 
155
- /** Event payload for the [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/TimeSliderViewModel/#event-trigger-action) event. */
156
+ /**
157
+ * Event payload for the [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/TimeSliderViewModel/#event-trigger-action) event.
158
+ *
159
+ * @deprecated since 5.2. Use custom actions in the Time Bar component's [`actions-end` slot](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#slot-actions-end) instead.
160
+ */
156
161
  export interface TimeSliderViewModelTriggerActionEvent {
157
162
  /** The action that was clicked. */
158
163
  action: Action;
@@ -164,11 +169,10 @@ export interface TimeSliderViewModelTriggerActionEvent {
164
169
  * @deprecated since version 5.2. Use the [Time Bar component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/) instead.
165
170
  * @since 4.12
166
171
  * @see [TimeSlider](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/) widget
167
- * @see [Time Slider component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-slider/)
168
- * @see [Sample - Time Slider component](https://developers.arcgis.com/javascript/latest/sample-code/timeslider/)
172
+ * @see [Time Bar component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/)
173
+ * @see [Sample - Time Bar component](https://developers.arcgis.com/javascript/latest/sample-code/time-bar/)
169
174
  * @see [Sample - SceneLayer with time filter](https://developers.arcgis.com/javascript/latest/sample-code/layers-scenelayer-time/)
170
- * @see [Sample - Filter features with TimeSlider component](https://developers.arcgis.com/javascript/latest/sample-code/timeslider-component-filter/)
171
- * @see [Sample - TimeSlider with offset](https://developers.arcgis.com/javascript/latest/sample-code/widgets-timeslider-offset/)
175
+ * @see [Sample - Filter features with Time Bar component](https://developers.arcgis.com/javascript/latest/sample-code/time-bar-filter/)
172
176
  * @see [Sample - Visualizing wind data with VectorFieldRenderer](https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-vfrenderer/)
173
177
  * @see [Temporal data (ArcGIS Pro)](https://pro.arcgis.com/en/pro-app/latest/help/mapping/time/temporal-data.htm)
174
178
  * @see [Set time properties on data (ArcGIS Pro)](https://pro.arcgis.com/en/pro-app/latest/help/mapping/time/set-the-time-properties-on-data.htm)
@@ -6,6 +6,7 @@ import type { Icon } from "@esri/calcite-components/components/calcite-icon";
6
6
  /**
7
7
  * The [TimeSliderViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/TimeSliderViewModel/)'s state.
8
8
  *
9
+ * @deprecated since 5.2. Use the [Time Bar State type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/types/#State) instead.
9
10
  * @since 5.0
10
11
  */
11
12
  export type TimeSliderState = "disabled" | "ready" | "playing";
@@ -13,6 +14,7 @@ export type TimeSliderState = "disabled" | "ready" | "playing";
13
14
  /**
14
15
  * The time slider mode.
15
16
  *
17
+ * @deprecated since 5.2. Use the [Time Bar Mode type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/types/#Mode) instead.
16
18
  * @see [TimeSlider.mode](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/#mode)
17
19
  * @since 5.0
18
20
  */
@@ -21,6 +23,7 @@ export type TimeSliderMode = "instant" | "time-window" | "cumulative-from-start"
21
23
  /**
22
24
  * Specifies an array of dates for the time slider widget. Can be used to create irregularly spaced stops.
23
25
  *
26
+ * @deprecated since 5.2. Use the [Time BarStopsByDates type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/types/#StopsByDates) instead.
24
27
  * @since 5.0
25
28
  * @example
26
29
  * // Explicitly define 5 stops.
@@ -59,6 +62,7 @@ export interface StopsByDates {
59
62
  * [TimeExtent](https://developers.arcgis.com/javascript/latest/references/core/time/TimeExtent/) can confine the subdivision to a specific time frame. StopByInterval is useful
60
63
  * when the spacing is in terms of months and years, which cannot be reliably expressed in milliseconds.
61
64
  *
65
+ * @deprecated since 5.2. Use the [Time Bar StopsByInterval type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/types/#StopsByInterval) instead.
62
66
  * @since 5.0
63
67
  * @example
64
68
  * // Add yearly intervals starting from the beginning of the TimeSlider.
@@ -99,6 +103,7 @@ export interface StopsByInterval {
99
103
  * Divides the time slider's [TimeSlider.fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/#fullTimeExtent) into equal parts.
100
104
  * A stop will be placed at the start and end of each division resulting in _count + 1_ [TimeSlider.effectiveStops](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/#effectiveStops).
101
105
  *
106
+ * @deprecated since 5.2. Use the [Time Bar StopsByCount type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/types/#StopsByCount) instead.
102
107
  * @since 5.0
103
108
  * @example
104
109
  * // Add ten evenly spaced stops.
@@ -136,6 +141,7 @@ export interface StopsByCount {
136
141
  * Defines specific locations on the time slider where thumbs will snap to when manipulated. If unspecified, ten evenly spaced stops will be added.
137
142
  * For continuous sliding set stops to `null`.
138
143
  *
144
+ * @deprecated since 5.2. Use the [Time Bar Stops type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/types/#Stops) for the Time Bar component instead.
139
145
  * @see [TimeSlider.stops](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/#stops)
140
146
  * @since 5.0
141
147
  */
@@ -146,6 +152,7 @@ export type Stops = StopsByDates | StopsByInterval | StopsByCount;
146
152
  * [TimeSlider.actions](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/#actions) or the [TimeSliderViewModel.actions](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/TimeSliderViewModel/#actions). It is displayed in a menu when
147
153
  * the user clicks the ellipsis button ![timeSlider-actions-menu](https://developers.arcgis.com/javascript/latest/assets/references/core/widgets/timeslider/ellipsis.avif) on the [TimeSlider](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/) widget.
148
154
  *
155
+ * @deprecated since 5.2. Use custom actions in the Time Bar component's [`actions-end` slot](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/#slot-actions-end) instead.
149
156
  * @since 5.0
150
157
  */
151
158
  export interface Action {
@@ -417,10 +417,9 @@ export interface TimeSliderEvents extends TimeSliderViewModelEvents {}
417
417
  * @deprecated since version 5.0. Use the [Time Bar component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-time-bar/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/).
418
418
  * @since 4.12
419
419
  * @see [TimeSliderViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/TimeSlider/TimeSliderViewModel/)
420
- * @see [Sample - Time Slider component](https://developers.arcgis.com/javascript/latest/sample-code/timeslider/)
420
+ * @see [Sample - Time Bar component](https://developers.arcgis.com/javascript/latest/sample-code/time-bar/)
421
421
  * @see [Sample - SceneLayer with time filter](https://developers.arcgis.com/javascript/latest/sample-code/layers-scenelayer-time/)
422
- * @see [Sample - Filter features with TimeSlider component](https://developers.arcgis.com/javascript/latest/sample-code/timeslider-component-filter/)
423
- * @see [Sample - TimeSlider with offset](https://developers.arcgis.com/javascript/latest/sample-code/widgets-timeslider-offset/)
422
+ * @see [Sample - Filter features with Time Bar component](https://developers.arcgis.com/javascript/latest/sample-code/time-bar-filter/)
424
423
  * @see [Sample - Visualizing wind data with VectorFieldRenderer](https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-vfrenderer/)
425
424
  * @see [Temporal data (ArcGIS Pro)](https://doc.esri.com/en/arcgis-pro/latest/help/mapping/time/temporal-data.html)
426
425
  * @see [Set time properties on data (ArcGIS Pro)](https://doc.esri.com/en/arcgis-pro/latest/help/mapping/time/set-the-time-properties-on-data.html)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{equals as t}from"../core/arrayUtils.js";import n from"../core/Collection.js";import{deprecateWidget as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{watch as a,initial as o}from"../core/reactiveUtils.js";import{truncateDate as s,offsetDate as c}from"../core/timeUtils.js";import{property as l,subclass as u}from"../core/accessorSupport/decorators.js";import{formatDate as d,convertDateFormatToIntlOptions as f}from"../intl/date.js";import{getCalciteModeClass as p}from"../support/modeUtils.js";import{unknown as m,system as h}from"../time/constants.js";import g from"../time/TimeExtent.js";import _ from"../time/TimeInterval.js";import v from"./Slider.js";import y from"./Widget.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as x}from"./support/globalCss.js";import{messageBundle as S,vmEvent as C,tsx as w}from"./support/widget.js";import{onResize as T}from"./support/widgetUtils.js";import{css as E}from"./TimeSlider/css.js";import D from"./TimeSlider/TimeSliderViewModel.js";const O=(e,t,n)=>({minor:e,major:t,format:n}),k={sf:{second:`numeric`,fractionalSecondDigits:3},s:{second:`numeric`},ms:{minute:`numeric`,second:`numeric`},mi:{minute:`numeric`},hm:{hour:`numeric`,minute:`numeric`},dm:{day:`numeric`,month:`short`},m:{month:`short`},my:{month:`short`,year:`numeric`},y:{year:`numeric`}},A=[O({value:1,unit:`milliseconds`},{value:20,unit:`milliseconds`},k.sf),O({value:2,unit:`milliseconds`},{value:50,unit:`milliseconds`},k.sf),O({value:5,unit:`milliseconds`},{value:100,unit:`milliseconds`},k.sf),O({value:10,unit:`milliseconds`},{value:200,unit:`milliseconds`},k.sf),O({value:20,unit:`milliseconds`},{value:500,unit:`milliseconds`},k.sf),O({value:50,unit:`milliseconds`},{value:1,unit:`seconds`},k.s),O({value:100,unit:`milliseconds`},{value:2,unit:`seconds`},k.s),O({value:200,unit:`milliseconds`},{value:5,unit:`seconds`},k.s),O({value:500,unit:`milliseconds`},{value:10,unit:`seconds`},k.s),O({value:1,unit:`seconds`},{value:20,unit:`seconds`},k.ms),O({value:2,unit:`seconds`},{value:30,unit:`seconds`},k.ms),O({value:5,unit:`seconds`},{value:1,unit:`minutes`},k.mi),O({value:10,unit:`seconds`},{value:2,unit:`minutes`},k.mi),O({value:20,unit:`seconds`},{value:5,unit:`minutes`},k.mi),O({value:40,unit:`seconds`},{value:10,unit:`minutes`},k.mi),O({value:1,unit:`minutes`},{value:30,unit:`minutes`},k.hm),O({value:2,unit:`minutes`},{value:1,unit:`hours`},k.hm),O({value:5,unit:`minutes`},{value:2,unit:`hours`},k.hm),O({value:10,unit:`minutes`},{value:4,unit:`hours`},k.hm),O({value:20,unit:`minutes`},{value:8,unit:`hours`},k.hm),O({value:40,unit:`minutes`},{value:12,unit:`hours`},k.hm),O({value:1,unit:`hours`},{value:1,unit:`days`},k.dm),O({value:2,unit:`hours`},{value:2,unit:`days`},k.dm),O({value:5,unit:`hours`},{value:4,unit:`days`},k.dm),O({value:10,unit:`hours`},{value:10,unit:`days`},k.dm),O({value:20,unit:`hours`},{value:15,unit:`days`},k.dm),O({value:1,unit:`days`},{value:20,unit:`days`},k.dm),O({value:2,unit:`days`},{value:1,unit:`months`},k.m),O({value:5,unit:`days`},{value:3,unit:`months`},k.m),O({value:10,unit:`days`},{value:6,unit:`months`},k.my),O({value:20,unit:`days`},{value:1,unit:`years`},k.y),O({value:1,unit:`months`},{value:2,unit:`years`},k.y),O({value:2,unit:`months`},{value:4,unit:`years`},k.y),O({value:5,unit:`months`},{value:10,unit:`years`},k.y),O({value:1,unit:`years`},{value:20,unit:`years`},k.y),O({value:2,unit:`years`},{value:50,unit:`years`},k.y),O({value:5,unit:`years`},{value:100,unit:`years`},k.y),O({value:10,unit:`years`},{value:200,unit:`years`},k.y),O({value:20,unit:`years`},{value:500,unit:`years`},k.y),O({value:50,unit:`years`},{value:1e3,unit:`years`},k.y),O({value:1,unit:`centuries`},{value:20,unit:`centuries`},k.y),O({value:2,unit:`centuries`},{value:50,unit:`centuries`},k.y),O({value:5,unit:`centuries`},{value:100,unit:`centuries`},k.y),O({value:10,unit:`centuries`},{value:200,unit:`centuries`},k.y),O({value:20,unit:`centuries`},{value:500,unit:`centuries`},k.y),O({value:50,unit:`centuries`},{value:1e3,unit:`centuries`},k.y),O({value:100,unit:`centuries`},{value:2e3,unit:`centuries`},k.y),O({value:200,unit:`centuries`},{value:5e3,unit:`centuries`},k.y),O({value:500,unit:`centuries`},{value:1e4,unit:`centuries`},k.y),O({value:1e3,unit:`centuries`},{value:2e4,unit:`centuries`},k.y)];function j(e){return w(`div`,{class:E.warning},w(`calcite-icon`,{class:E.warningIcon,icon:`exclamation-mark-triangle`}),w(`calcite-label`,{alignment:`center`,class:E.warningLabel,scale:`s`},e))}let M=class extends y{constructor(e,t){super(e,t),this._allLayouts=[`auto`,`compact`,`wide`],this._ignoreNextSliderUpdate=!1,this._slider=new v({suppressDeprecationWarning:!0,precision:0,visibleElements:{rangeLabels:!1},rangeLabelInputsEnabled:!1,thumbsConstrained:!1}),this._tickFormat=null,this.disabled=!1,this.labelFormatFunction=null,this.messages=null,this.tickConfigs=null,this.timeVisible=!1,this.viewModel=new D({suppressDeprecationWarning:!0}),this.announceDeprecation=()=>{r(i.getLogger(this),`Time Slider`,`arcgis-time-slider`,{version:`5.0`})}}initialize(){this.addHandles([a(()=>this._slider.values,e=>{if(this._ignoreNextSliderUpdate){this._ignoreNextSliderUpdate=!1;return}let t=this.viewModel.valuesToTimeExtent(e);this.timeExtent?t?this.timeExtent.equals(t)||(this.timeExtent=t):this.timeExtent=null:t&&(this.timeExtent=t)}),a(()=>this.effectiveStops,()=>this._updateSliderSteps(),o)])}loadDependencies(){return b({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),"action-menu":()=>import(`@esri/calcite-components/dist/components/calcite-action-menu`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`)})}destroy(){this._slider.destroy(),this._tickFormat=null}get _dateFormat(){let{timeZone:e,viewModel:t}=this,n=t.isPreCommonEra?`short`:void 0;return this._getIntlOptions(`short-date`,{era:n,timeZone:e})}get _timeFormat(){let{timeZone:e}=this;return this._getIntlOptions(`long-time`,{timeZone:e})}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get effectiveStops(){return this.viewModel.effectiveStops}get fullTimeExtent(){return this.viewModel.fullTimeExtent}set fullTimeExtent(e){this.viewModel.fullTimeExtent=e}get icon(){return`clock`}set icon(e){this._overrideIfSome(`icon`,e)}get interactive(){return!(this.disabled||this.viewModel.state===`disabled`||this.timeZone===m)}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}set layout(e){this._set(`layout`,this._allLayouts.includes(e)?e:`auto`)}get loop(){return this.viewModel.loop}set loop(e){this.viewModel.loop=e}get mode(){return this.viewModel.mode}set mode(e){this.viewModel.mode=e}get playRate(){return this.viewModel.playRate}set playRate(e){this.viewModel.playRate=e}get stops(){return this.viewModel.stops}set stops(e){this.viewModel.stops=e}get tickFormats(){let{timeZone:e}=this;return A.map(({minor:t,major:n,format:r})=>({minor:new _(t),major:new _(n),format:{...r,timeZone:e}}))}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.view?.timeZone??h}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}next(){return this.viewModel.next()}play(){return this.viewModel.play()}previous(){return this.viewModel.previous()}stop(){return this.viewModel.stop()}render(){let{_slider:e,actions:n,domNode:r,effectiveStops:i,fullTimeExtent:a,interactive:o,messages:s,mode:c,tickConfigs:l,timeExtent:u,timeVisible:f,viewModel:{isPreCommonEra:m,state:h,timeExtentValues:g}}=this;if(a){let{start:t,end:n}=a;if(t&&n){let r=t.getTime(),i=n.getTime(),a=e.min!==r||e.max!==i;if(a&&(e.min=r,e.max=i),l)e.tickConfigs!==l&&(e.tickConfigs=l);else{let t=e.trackElement?.offsetWidth||400,n=(i-r)/t,o=this.tickFormats.find(({minor:e})=>e.toMilliseconds()>3*n)??this.tickFormats.at(-1),s=o&&this._tickFormat!==o;if(s&&(this._tickFormat=o),a||s){let t={mode:`position`,values:this._getTickPositions(o.minor),labelsVisible:!1,tickCreatedFunction:(e,t)=>{t?.classList.add(E.sliderMinorTick)}},n={...o.format,era:o.format.year&&m?`short`:void 0};e.tickConfigs=[t,{mode:`position`,values:this._getTickPositions(o.major),labelsVisible:!0,tickCreatedFunction:(e,t)=>{t?.classList.add(E.sliderMajorTick)},labelFormatFunction:e=>d(e,n)}]}}}}let _=!this.fullTimeExtent?.start||!this.fullTimeExtent.end||!this.timeExtent||this.timeExtent.isAllTime||this.timeExtent.isEmpty||this.timeExtent.start&&(this.timeExtent.start<this.fullTimeExtent.start||this.timeExtent.start>this.fullTimeExtent.end)||this.timeExtent.end&&(this.timeExtent.end>this.fullTimeExtent.end||this.timeExtent.end<this.fullTimeExtent.start);if(_)switch(this._ignoreNextSliderUpdate=!0,c){case`time-window`:e.values=[e.min,e.max];break;case`instant`:case`cumulative-from-end`:e.values=[e.min];break;case`cumulative-from-start`:e.values=[e.max]}else g?t(e.values,g)||(e.values=g):e.values=null;e.disabled=!o;let v=_||!o||!i?.length,y=this.layout===`auto`?r.clientWidth<858?`compact`:`wide`:this.layout,b=w(`calcite-button`,{appearance:`transparent`,bind:this,class:E.play,disabled:v,iconStart:h===`playing`?`pause`:`play`,kind:`neutral`,label:h===`playing`?s.control.stop:s.control.play,scale:y===`wide`?`l`:`m`,width:`full`,onclick:this._playOrStopClick}),S=this.labelFormatFunction?w(`div`,{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:E.timeExtentStartDate,"data-date":u?[u.start,u.end]:null,"data-layout":y,"data-type":`extent`,key:E.timeExtentStartDate}):!u||u.isAllTime?j(s.noTimeExtent):u.isEmpty?j(s.emptyTimeExtent):[u?.start&&w(`div`,{class:E.timeExtentStartGroup,key:E.timeExtentStartGroup},w(`calcite-label`,{alignment:`center`,class:E.timeExtentStartDate,key:E.timeExtentStartDate,scale:`s`},this._formatDate(u.start)),f?w(`calcite-label`,{alignment:`center`,class:E.timeExtentStartTime,key:E.timeExtentStartTime,scale:`s`},this._formatTime(u.start)):null),u.start&&u.end&&u.start.getTime()!==u.end.getTime()&&w(`div`,{class:E.timeExtentSeparator,key:E.timeExtentSeparator}),u?.end&&(!u.start||u.start.getTime()!==u.end.getTime())&&w(`div`,{class:E.timeExtentEndGroup,key:E.timeExtentEndGroup},w(`calcite-label`,{alignment:`center`,class:E.timeExtentEndDate,key:E.timeExtentEndDate,scale:`s`},this._formatDate(u.end)),f?w(`calcite-label`,{alignment:`center`,class:E.timeExtentEndTime,key:E.timeExtentEndTime,scale:`s`},this._formatTime(u.end)):null)],C=w(`div`,{class:E.timeExtent},S),D=this.labelFormatFunction?w(`div`,{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:E.minDate,"data-date":a?.start,"data-layout":y,"data-type":`min`,key:E.minDate}):a?.start&&[w(`calcite-label`,{class:E.minDate,key:E.minDate,scale:`s`},this._formatDate(a.start)),f&&w(`calcite-label`,{class:E.minTime,key:E.minTime,scale:`s`},this._formatTime(a.start))],O=w(`div`,{class:E.min},D),k=w(`div`,{class:E.slider},e.render()),A=this.labelFormatFunction?w(`div`,{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:E.maxDate,"data-date":a?.end,"data-layout":y,"data-type":`max`,key:E.maxDate}):a?.end&&[w(`calcite-label`,{class:E.maxDate,key:E.maxDate,scale:`s`},this._formatDate(a.end)),f&&w(`calcite-label`,{class:E.maxTime,key:E.maxTime,scale:`s`},this._formatTime(a.end))],M=w(`div`,{class:E.max},A),N=w(`calcite-button`,{appearance:`transparent`,bind:this,class:E.previous,disabled:v||h===`playing`,iconStart:`reverse`,kind:`neutral`,label:s.pagination.previous,scale:y===`wide`?`l`:`m`,width:`full`,onclick:this._previousClick}),P=w(`calcite-button`,{appearance:`transparent`,bind:this,class:E.next,disabled:v||h===`playing`,iconStart:`forward`,kind:`neutral`,label:s.pagination.next,scale:y===`wide`?`l`:`m`,width:`full`,onclick:this._nextClick}),F=n?.length>0,I=F&&w(`calcite-action-menu`,{class:E.actions,label:s.options},n.toArray().map(e=>w(`calcite-action`,{bind:this,icon:e.icon,id:e.id,text:e.title,textEnabled:!0,onclick:()=>this.viewModel.triggerAction(e)})));return w(`div`,{afterCreate:e=>{this.addHandles(T(e,()=>this.scheduleRender()))},"aria-label":s.widgetLabel,class:this.classes(E.timeSlider,x.widget,`${E.timeSliderMode}${c}`,`${E.timeSliderLayout}${y}`,!o&&E.timeSliderDisabled,_&&E.timeSliderOutOfBounds,F&&E.hasActions,p(this.container))},y===`wide`&&w(`div`,{class:E.timeSliderRow},w(`div`,{class:E.playbackControls},[b,C,O,k,M,N,P]),I),y===`compact`&&[w(`div`,{class:E.timeSliderRow,key:`time-slider-row-1`},[C,I]),w(`div`,{class:E.timeSliderRow,key:`time-slider-row-2`},[k]),w(`div`,{class:E.timeSliderRow,key:`time-slider-row-3`},[O,N,b,P,M])])}updateWebDocument(e){this.viewModel?.updateWebDocument(e)}_createLabel(e){if(!this.labelFormatFunction)return;let t=e.getAttribute(`data-type`),n=e.getAttribute(`data-layout`),r=e[`data-date`];this.labelFormatFunction(r,t,e,n)}_formatDate(e){return d(e,this._dateFormat)}_formatTime(e){return d(e,this._timeFormat)}_getIntlOptions(e,t){return{...f(e),...t}}_getTickPositions(e){let{fullTimeExtent:t}=this;if(!t?.start||!t.end)return[];let{start:n,end:r}=t,i=[],{value:a,unit:o}=e,l=s(n,e,this.timeZone);for(;l.getTime()<=r.getTime();)l.getTime()>=n.getTime()&&i.push(l.getTime()),l=c(l,a,o,this.timeZone);return i}_updateSliderSteps(){this._slider.steps=this.effectiveStops&&this.effectiveStops.length>0?this.effectiveStops.map(e=>e.getTime()):null}_playOrStopClick(){switch(this.viewModel.state){case`ready`:this.viewModel.play();break;case`playing`:this.viewModel.stop();break;case`disabled`:break;default:this.viewModel.state}}_previousClick(){this.viewModel.previous()}_nextClick(){this.viewModel.next()}};e([l()],M.prototype,`_dateFormat`,null),e([l()],M.prototype,`_timeFormat`,null),e([l({type:n})],M.prototype,`actions`,null),e([l()],M.prototype,`disabled`,void 0),e([l()],M.prototype,`effectiveStops`,null),e([l({type:g})],M.prototype,`fullTimeExtent`,null),e([l()],M.prototype,`icon`,null),e([l({readOnly:!0})],M.prototype,`interactive`,null),e([l()],M.prototype,`label`,null),e([l()],M.prototype,`labelFormatFunction`,void 0),e([l({value:`auto`})],M.prototype,`layout`,null),e([l()],M.prototype,`loop`,null),e([l(),S(`esri/widgets/TimeSlider/t9n/TimeSlider`)],M.prototype,`messages`,void 0),e([l()],M.prototype,`mode`,null),e([l()],M.prototype,`playRate`,null),e([l()],M.prototype,`stops`,null),e([l()],M.prototype,`tickConfigs`,void 0),e([l()],M.prototype,`tickFormats`,null),e([l({type:g})],M.prototype,`timeExtent`,null),e([l({nonNullable:!0})],M.prototype,`timeVisible`,void 0),e([l()],M.prototype,`timeZone`,null),e([l()],M.prototype,`view`,null),e([l({type:D}),C(`trigger-action`)],M.prototype,`viewModel`,void 0),M=e([u(`esri.widgets.TimeSlider`)],M);const N=M;export{N as default};
2
+ import{__decorate as e}from"tslib";import{equals as t}from"../core/arrayUtils.js";import n from"../core/Collection.js";import{deprecateWidget as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{watch as a,initial as o}from"../core/reactiveUtils.js";import{truncateDate as s,offsetDate as c}from"../core/timeUtils.js";import{property as l,subclass as u}from"../core/accessorSupport/decorators.js";import{formatDate as d,convertDateFormatToIntlOptions as f}from"../intl/date.js";import{getCalciteModeClass as p}from"../support/modeUtils.js";import{unknown as m,system as h}from"../time/constants.js";import g from"../time/TimeExtent.js";import _ from"../time/TimeInterval.js";import v from"./Slider.js";import y from"./Widget.js";import{loadCalciteComponents as b}from"./support/componentsUtils.js";import{globalCss as x}from"./support/globalCss.js";import{messageBundle as S,vmEvent as C,tsx as w}from"./support/widget.js";import{onResize as T}from"./support/widgetUtils.js";import{css as E}from"./TimeSlider/css.js";import D from"./TimeSlider/TimeSliderViewModel.js";const O=(e,t,n)=>({minor:e,major:t,format:n}),k={sf:{second:`numeric`,fractionalSecondDigits:3},s:{second:`numeric`},ms:{minute:`numeric`,second:`numeric`},mi:{minute:`numeric`},hm:{hour:`numeric`,minute:`numeric`},dm:{day:`numeric`,month:`short`},m:{month:`short`},my:{month:`short`,year:`numeric`},y:{year:`numeric`}},A=[O({value:1,unit:`milliseconds`},{value:20,unit:`milliseconds`},k.sf),O({value:2,unit:`milliseconds`},{value:50,unit:`milliseconds`},k.sf),O({value:5,unit:`milliseconds`},{value:100,unit:`milliseconds`},k.sf),O({value:10,unit:`milliseconds`},{value:200,unit:`milliseconds`},k.sf),O({value:20,unit:`milliseconds`},{value:500,unit:`milliseconds`},k.sf),O({value:50,unit:`milliseconds`},{value:1,unit:`seconds`},k.s),O({value:100,unit:`milliseconds`},{value:2,unit:`seconds`},k.s),O({value:200,unit:`milliseconds`},{value:5,unit:`seconds`},k.s),O({value:500,unit:`milliseconds`},{value:10,unit:`seconds`},k.s),O({value:1,unit:`seconds`},{value:20,unit:`seconds`},k.ms),O({value:2,unit:`seconds`},{value:30,unit:`seconds`},k.ms),O({value:5,unit:`seconds`},{value:1,unit:`minutes`},k.mi),O({value:10,unit:`seconds`},{value:2,unit:`minutes`},k.mi),O({value:20,unit:`seconds`},{value:5,unit:`minutes`},k.mi),O({value:40,unit:`seconds`},{value:10,unit:`minutes`},k.mi),O({value:1,unit:`minutes`},{value:30,unit:`minutes`},k.hm),O({value:2,unit:`minutes`},{value:1,unit:`hours`},k.hm),O({value:5,unit:`minutes`},{value:2,unit:`hours`},k.hm),O({value:10,unit:`minutes`},{value:4,unit:`hours`},k.hm),O({value:20,unit:`minutes`},{value:8,unit:`hours`},k.hm),O({value:40,unit:`minutes`},{value:12,unit:`hours`},k.hm),O({value:1,unit:`hours`},{value:1,unit:`days`},k.dm),O({value:2,unit:`hours`},{value:2,unit:`days`},k.dm),O({value:5,unit:`hours`},{value:4,unit:`days`},k.dm),O({value:10,unit:`hours`},{value:10,unit:`days`},k.dm),O({value:20,unit:`hours`},{value:15,unit:`days`},k.dm),O({value:1,unit:`days`},{value:20,unit:`days`},k.dm),O({value:2,unit:`days`},{value:1,unit:`months`},k.m),O({value:5,unit:`days`},{value:3,unit:`months`},k.m),O({value:10,unit:`days`},{value:6,unit:`months`},k.my),O({value:20,unit:`days`},{value:1,unit:`years`},k.y),O({value:1,unit:`months`},{value:2,unit:`years`},k.y),O({value:2,unit:`months`},{value:4,unit:`years`},k.y),O({value:5,unit:`months`},{value:10,unit:`years`},k.y),O({value:1,unit:`years`},{value:20,unit:`years`},k.y),O({value:2,unit:`years`},{value:50,unit:`years`},k.y),O({value:5,unit:`years`},{value:100,unit:`years`},k.y),O({value:10,unit:`years`},{value:200,unit:`years`},k.y),O({value:20,unit:`years`},{value:500,unit:`years`},k.y),O({value:50,unit:`years`},{value:1e3,unit:`years`},k.y),O({value:1,unit:`centuries`},{value:20,unit:`centuries`},k.y),O({value:2,unit:`centuries`},{value:50,unit:`centuries`},k.y),O({value:5,unit:`centuries`},{value:100,unit:`centuries`},k.y),O({value:10,unit:`centuries`},{value:200,unit:`centuries`},k.y),O({value:20,unit:`centuries`},{value:500,unit:`centuries`},k.y),O({value:50,unit:`centuries`},{value:1e3,unit:`centuries`},k.y),O({value:100,unit:`centuries`},{value:2e3,unit:`centuries`},k.y),O({value:200,unit:`centuries`},{value:5e3,unit:`centuries`},k.y),O({value:500,unit:`centuries`},{value:1e4,unit:`centuries`},k.y),O({value:1e3,unit:`centuries`},{value:2e4,unit:`centuries`},k.y)];function j(e){return w(`div`,{class:E.warning},w(`calcite-icon`,{class:E.warningIcon,icon:`exclamation-mark-triangle`}),w(`calcite-label`,{alignment:`center`,class:E.warningLabel,scale:`s`},e))}let M=class extends y{constructor(e,t){super(e,t),this._allLayouts=[`auto`,`compact`,`wide`],this._ignoreNextSliderUpdate=!1,this._slider=new v({suppressDeprecationWarning:!0,precision:0,visibleElements:{rangeLabels:!1},rangeLabelInputsEnabled:!1,thumbsConstrained:!1}),this._tickFormat=null,this.disabled=!1,this.labelFormatFunction=null,this.messages=null,this.tickConfigs=null,this.timeVisible=!1,this.viewModel=new D({suppressDeprecationWarning:!0}),this.announceDeprecation=()=>{r(i.getLogger(this),`Time Bar`,`arcgis-time-bar`,{version:`5.0`})}}initialize(){this.addHandles([a(()=>this._slider.values,e=>{if(this._ignoreNextSliderUpdate){this._ignoreNextSliderUpdate=!1;return}let t=this.viewModel.valuesToTimeExtent(e);this.timeExtent?t?this.timeExtent.equals(t)||(this.timeExtent=t):this.timeExtent=null:t&&(this.timeExtent=t)}),a(()=>this.effectiveStops,()=>this._updateSliderSteps(),o)])}loadDependencies(){return b({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),"action-menu":()=>import(`@esri/calcite-components/dist/components/calcite-action-menu`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`)})}destroy(){this._slider.destroy(),this._tickFormat=null}get _dateFormat(){let{timeZone:e,viewModel:t}=this,n=t.isPreCommonEra?`short`:void 0;return this._getIntlOptions(`short-date`,{era:n,timeZone:e})}get _timeFormat(){let{timeZone:e}=this;return this._getIntlOptions(`long-time`,{timeZone:e})}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get effectiveStops(){return this.viewModel.effectiveStops}get fullTimeExtent(){return this.viewModel.fullTimeExtent}set fullTimeExtent(e){this.viewModel.fullTimeExtent=e}get icon(){return`clock`}set icon(e){this._overrideIfSome(`icon`,e)}get interactive(){return!(this.disabled||this.viewModel.state===`disabled`||this.timeZone===m)}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}set layout(e){this._set(`layout`,this._allLayouts.includes(e)?e:`auto`)}get loop(){return this.viewModel.loop}set loop(e){this.viewModel.loop=e}get mode(){return this.viewModel.mode}set mode(e){this.viewModel.mode=e}get playRate(){return this.viewModel.playRate}set playRate(e){this.viewModel.playRate=e}get stops(){return this.viewModel.stops}set stops(e){this.viewModel.stops=e}get tickFormats(){let{timeZone:e}=this;return A.map(({minor:t,major:n,format:r})=>({minor:new _(t),major:new _(n),format:{...r,timeZone:e}}))}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.view?.timeZone??h}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}next(){return this.viewModel.next()}play(){return this.viewModel.play()}previous(){return this.viewModel.previous()}stop(){return this.viewModel.stop()}render(){let{_slider:e,actions:n,domNode:r,effectiveStops:i,fullTimeExtent:a,interactive:o,messages:s,mode:c,tickConfigs:l,timeExtent:u,timeVisible:f,viewModel:{isPreCommonEra:m,state:h,timeExtentValues:g}}=this;if(a){let{start:t,end:n}=a;if(t&&n){let r=t.getTime(),i=n.getTime(),a=e.min!==r||e.max!==i;if(a&&(e.min=r,e.max=i),l)e.tickConfigs!==l&&(e.tickConfigs=l);else{let t=e.trackElement?.offsetWidth||400,n=(i-r)/t,o=this.tickFormats.find(({minor:e})=>e.toMilliseconds()>3*n)??this.tickFormats.at(-1),s=o&&this._tickFormat!==o;if(s&&(this._tickFormat=o),a||s){let t={mode:`position`,values:this._getTickPositions(o.minor),labelsVisible:!1,tickCreatedFunction:(e,t)=>{t?.classList.add(E.sliderMinorTick)}},n={...o.format,era:o.format.year&&m?`short`:void 0};e.tickConfigs=[t,{mode:`position`,values:this._getTickPositions(o.major),labelsVisible:!0,tickCreatedFunction:(e,t)=>{t?.classList.add(E.sliderMajorTick)},labelFormatFunction:e=>d(e,n)}]}}}}let _=!this.fullTimeExtent?.start||!this.fullTimeExtent.end||!this.timeExtent||this.timeExtent.isAllTime||this.timeExtent.isEmpty||this.timeExtent.start&&(this.timeExtent.start<this.fullTimeExtent.start||this.timeExtent.start>this.fullTimeExtent.end)||this.timeExtent.end&&(this.timeExtent.end>this.fullTimeExtent.end||this.timeExtent.end<this.fullTimeExtent.start);if(_)switch(this._ignoreNextSliderUpdate=!0,c){case`time-window`:e.values=[e.min,e.max];break;case`instant`:case`cumulative-from-end`:e.values=[e.min];break;case`cumulative-from-start`:e.values=[e.max]}else g?t(e.values,g)||(e.values=g):e.values=null;e.disabled=!o;let v=_||!o||!i?.length,y=this.layout===`auto`?r.clientWidth<858?`compact`:`wide`:this.layout,b=w(`calcite-button`,{appearance:`transparent`,bind:this,class:E.play,disabled:v,iconStart:h===`playing`?`pause`:`play`,kind:`neutral`,label:h===`playing`?s.control.stop:s.control.play,scale:y===`wide`?`l`:`m`,width:`full`,onclick:this._playOrStopClick}),S=this.labelFormatFunction?w(`div`,{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:E.timeExtentStartDate,"data-date":u?[u.start,u.end]:null,"data-layout":y,"data-type":`extent`,key:E.timeExtentStartDate}):!u||u.isAllTime?j(s.noTimeExtent):u.isEmpty?j(s.emptyTimeExtent):[u?.start&&w(`div`,{class:E.timeExtentStartGroup,key:E.timeExtentStartGroup},w(`calcite-label`,{alignment:`center`,class:E.timeExtentStartDate,key:E.timeExtentStartDate,scale:`s`},this._formatDate(u.start)),f?w(`calcite-label`,{alignment:`center`,class:E.timeExtentStartTime,key:E.timeExtentStartTime,scale:`s`},this._formatTime(u.start)):null),u.start&&u.end&&u.start.getTime()!==u.end.getTime()&&w(`div`,{class:E.timeExtentSeparator,key:E.timeExtentSeparator}),u?.end&&(!u.start||u.start.getTime()!==u.end.getTime())&&w(`div`,{class:E.timeExtentEndGroup,key:E.timeExtentEndGroup},w(`calcite-label`,{alignment:`center`,class:E.timeExtentEndDate,key:E.timeExtentEndDate,scale:`s`},this._formatDate(u.end)),f?w(`calcite-label`,{alignment:`center`,class:E.timeExtentEndTime,key:E.timeExtentEndTime,scale:`s`},this._formatTime(u.end)):null)],C=w(`div`,{class:E.timeExtent},S),D=this.labelFormatFunction?w(`div`,{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:E.minDate,"data-date":a?.start,"data-layout":y,"data-type":`min`,key:E.minDate}):a?.start&&[w(`calcite-label`,{class:E.minDate,key:E.minDate,scale:`s`},this._formatDate(a.start)),f&&w(`calcite-label`,{class:E.minTime,key:E.minTime,scale:`s`},this._formatTime(a.start))],O=w(`div`,{class:E.min},D),k=w(`div`,{class:E.slider},e.render()),A=this.labelFormatFunction?w(`div`,{afterCreate:this._createLabel,afterUpdate:this._createLabel,bind:this,class:E.maxDate,"data-date":a?.end,"data-layout":y,"data-type":`max`,key:E.maxDate}):a?.end&&[w(`calcite-label`,{class:E.maxDate,key:E.maxDate,scale:`s`},this._formatDate(a.end)),f&&w(`calcite-label`,{class:E.maxTime,key:E.maxTime,scale:`s`},this._formatTime(a.end))],M=w(`div`,{class:E.max},A),N=w(`calcite-button`,{appearance:`transparent`,bind:this,class:E.previous,disabled:v||h===`playing`,iconStart:`reverse`,kind:`neutral`,label:s.pagination.previous,scale:y===`wide`?`l`:`m`,width:`full`,onclick:this._previousClick}),P=w(`calcite-button`,{appearance:`transparent`,bind:this,class:E.next,disabled:v||h===`playing`,iconStart:`forward`,kind:`neutral`,label:s.pagination.next,scale:y===`wide`?`l`:`m`,width:`full`,onclick:this._nextClick}),F=n?.length>0,I=F&&w(`calcite-action-menu`,{class:E.actions,label:s.options},n.toArray().map(e=>w(`calcite-action`,{bind:this,icon:e.icon,id:e.id,text:e.title,textEnabled:!0,onclick:()=>this.viewModel.triggerAction(e)})));return w(`div`,{afterCreate:e=>{this.addHandles(T(e,()=>this.scheduleRender()))},"aria-label":s.widgetLabel,class:this.classes(E.timeSlider,x.widget,`${E.timeSliderMode}${c}`,`${E.timeSliderLayout}${y}`,!o&&E.timeSliderDisabled,_&&E.timeSliderOutOfBounds,F&&E.hasActions,p(this.container))},y===`wide`&&w(`div`,{class:E.timeSliderRow},w(`div`,{class:E.playbackControls},[b,C,O,k,M,N,P]),I),y===`compact`&&[w(`div`,{class:E.timeSliderRow,key:`time-slider-row-1`},[C,I]),w(`div`,{class:E.timeSliderRow,key:`time-slider-row-2`},[k]),w(`div`,{class:E.timeSliderRow,key:`time-slider-row-3`},[O,N,b,P,M])])}updateWebDocument(e){this.viewModel?.updateWebDocument(e)}_createLabel(e){if(!this.labelFormatFunction)return;let t=e.getAttribute(`data-type`),n=e.getAttribute(`data-layout`),r=e[`data-date`];this.labelFormatFunction(r,t,e,n)}_formatDate(e){return d(e,this._dateFormat)}_formatTime(e){return d(e,this._timeFormat)}_getIntlOptions(e,t){return{...f(e),...t}}_getTickPositions(e){let{fullTimeExtent:t}=this;if(!t?.start||!t.end)return[];let{start:n,end:r}=t,i=[],{value:a,unit:o}=e,l=s(n,e,this.timeZone);for(;l.getTime()<=r.getTime();)l.getTime()>=n.getTime()&&i.push(l.getTime()),l=c(l,a,o,this.timeZone);return i}_updateSliderSteps(){this._slider.steps=this.effectiveStops&&this.effectiveStops.length>0?this.effectiveStops.map(e=>e.getTime()):null}_playOrStopClick(){switch(this.viewModel.state){case`ready`:this.viewModel.play();break;case`playing`:this.viewModel.stop();break;case`disabled`:break;default:this.viewModel.state}}_previousClick(){this.viewModel.previous()}_nextClick(){this.viewModel.next()}};e([l()],M.prototype,`_dateFormat`,null),e([l()],M.prototype,`_timeFormat`,null),e([l({type:n})],M.prototype,`actions`,null),e([l()],M.prototype,`disabled`,void 0),e([l()],M.prototype,`effectiveStops`,null),e([l({type:g})],M.prototype,`fullTimeExtent`,null),e([l()],M.prototype,`icon`,null),e([l({readOnly:!0})],M.prototype,`interactive`,null),e([l()],M.prototype,`label`,null),e([l()],M.prototype,`labelFormatFunction`,void 0),e([l({value:`auto`})],M.prototype,`layout`,null),e([l()],M.prototype,`loop`,null),e([l(),S(`esri/widgets/TimeSlider/t9n/TimeSlider`)],M.prototype,`messages`,void 0),e([l()],M.prototype,`mode`,null),e([l()],M.prototype,`playRate`,null),e([l()],M.prototype,`stops`,null),e([l()],M.prototype,`tickConfigs`,void 0),e([l()],M.prototype,`tickFormats`,null),e([l({type:g})],M.prototype,`timeExtent`,null),e([l({nonNullable:!0})],M.prototype,`timeVisible`,void 0),e([l()],M.prototype,`timeZone`,null),e([l()],M.prototype,`view`,null),e([l({type:D}),C(`trigger-action`)],M.prototype,`viewModel`,void 0),M=e([u(`esri.widgets.TimeSlider`)],M);const N=M;export{N as default};
@@ -2,8 +2,10 @@ import type GeolocationPositioning from "../support/GeolocationPositioning.js";
2
2
  import type { PositionFilterFunction } from "./types.js";
3
3
  import type { GeolocationPositioningProperties } from "../support/GeolocationPositioning.js";
4
4
 
5
+ /** @deprecated since 5.2. Use the [Track component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-track/) instead. */
5
6
  export interface TrackViewModelProperties extends GeolocationPositioningProperties, Partial<Pick<TrackViewModel, "error" | "positionFilterFunction" | "rotationEnabled">> {}
6
7
 
8
+ /** @deprecated since 5.2. Use the [TrackViewModelState type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-track/types/#TrackViewModelState) from the Track component instead. */
7
9
  export type TrackViewModelState = "error" | "disabled" | "ready" | "waiting" | "tracking" | "feature-unsupported";
8
10
 
9
11
  /** @deprecated since version 5.1. Use the [Track component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-track/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
@@ -22,11 +24,13 @@ export interface TrackViewModelEvents {
22
24
  "track-error": TrackViewModelTrackErrorEvent;
23
25
  }
24
26
 
27
+ /** @deprecated since 5.2. Use the Track component's [`arcgisComplete` event](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-track/#event-arcgisComplete) instead. */
25
28
  export interface TrackViewModelTrackEvent {
26
29
  /** Geolocation coordinates returned from the [Geolocation API](https://developers.arcgis.com/javascript/latest/references/core/widgets/Track/#geolocationOptions). */
27
30
  position: GeolocationPosition;
28
31
  }
29
32
 
33
+ /** @deprecated since 5.2. Use the Track component's [`arcgisError` event](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-track/#event-arcgisError) instead. */
30
34
  export interface TrackViewModelTrackErrorEvent {
31
35
  /** The Error object returned if an error occurred while tracking. */
32
36
  error: GeolocationPositionError | Error;
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * @param args - An object containing the position to be filtered.
3
+ * @deprecated since 5.2. Use the Track component's [`positionFilterFunction` property](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-track/#positionFilterFunction) and [PositionFilterFunction type](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-track/types/#PositionFilterFunction) instead.
3
4
  * @since 5.0
4
5
  */
5
6
  export type PositionFilterFunction = (args: { position: any; }) => boolean;
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{ignoreAbortErrors as e,whenOrAbort as t}from"../../../core/promiseUtils.js";import{isSelectableLayerViewBase as n}from"../../../views/support/selectionUtils.js";async function r(n){let{selector:r,signal:a,sources:o,view:s}=n;if(!o.length)return[];let c=i(o);if(!c.length)return[];let l=[],u=new Set;return await e(t(s.hitTest(r,{include:c}).then(({results:e})=>{e.forEach(e=>{e.type===`graphic`&&!u.has(e.graphic)&&(u.add(e.graphic),l.push(e.graphic))})}),a)),l}function i(e){let t=[];return e.forEach(e=>{n(e)&&t.push(e.layer)}),t}export{r as getSelectionFromScreenSelector};
2
+ import{ignoreAbortErrors as e,whenOrAbort as t}from"../../../core/promiseUtils.js";import{isSelectableLayerViewBase as n,isSelectableLayer as r}from"../../../views/support/selectionUtils.js";async function i(n){let{selector:r,signal:i,sources:o,view:s}=n;if(!o.length)return[];let c=a(o);if(!c.length)return[];let l=[],u=new Set;return await e(t(s.hitTest(r,{include:c}).then(({results:e})=>{e.forEach(e=>{e.type===`graphic`&&!u.has(e.graphic)&&(u.add(e.graphic),l.push(e.graphic))})}),i)),l}function a(e){let t=[];return e.forEach(e=>{n(e)?t.push(e.layer):r(e)&&t.push(e)}),t}export{i as getSelectionFromScreenSelector};