@arcgis/core 5.1.0-next.23 → 5.1.0-next.25

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 (62) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/359d3ba9d6e3b1de05d1.js +1 -0
  3. package/assets/esri/core/workers/chunks/53817ef8c00d8cce4b8e.js +1 -0
  4. package/assets/esri/core/workers/chunks/{73e02f6c7ccc2013c812.js → 5fa5a2fb69f84e9092ba.js} +1 -1
  5. package/assets/esri/libs/linkchartlayout/lclayout.wasm +0 -0
  6. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  7. package/assets/esri/themes/base/widgets/_ResponsiveToolbar.scss +6 -0
  8. package/assets/esri/themes/dark/main.css +1 -1
  9. package/assets/esri/themes/light/main.css +1 -1
  10. package/assets/esri/themes/light/view.css +1 -1
  11. package/chunks/HUDMaterial.glsl.js +50 -35
  12. package/chunks/lclayout.js +1 -1
  13. package/config.js +1 -1
  14. package/core/workers.d.ts +1 -1
  15. package/editing/sharedTemplates/SharedTemplate.d.ts +12 -3
  16. package/editing/sharedTemplates/SharedTemplateMetadata.d.ts +11 -2
  17. package/interfaces.d.ts +4 -12
  18. package/kernel.js +1 -1
  19. package/layers/mixins/ArcGISImageService.js +1 -1
  20. package/libs/linkchartlayout/LinkChartLayout.js +1 -1
  21. package/networks/UtilityNetwork.js +1 -1
  22. package/package.json +1 -1
  23. package/support/revision.js +1 -1
  24. package/symbols/cim/types.d.ts +7 -0
  25. package/views/2d/engine/webgl/Overlay.js +1 -1
  26. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueCircle.js +1 -1
  27. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  28. package/views/2d/layers/GeoRSSLayerView2D.js +1 -1
  29. package/views/2d/layers/GraphicsLayerView2D.js +1 -1
  30. package/views/2d/layers/KMLLayerView2D.js +1 -1
  31. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  32. package/views/2d/types.d.ts +4 -3
  33. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  34. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  35. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  36. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  37. package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
  38. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  39. package/views/3d/layers/graphics/LabelParameters.js +1 -1
  40. package/views/3d/layers/graphics/Labeler.js +1 -1
  41. package/views/3d/types.d.ts +2 -1
  42. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  43. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  44. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  45. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  46. package/views/layers/GeoRSSLayerView.d.ts +5 -4
  47. package/views/layers/GeoRSSLayerView.js +2 -0
  48. package/views/layers/GraphicsLayerView.d.ts +21 -21
  49. package/views/layers/GraphicsLayerView.js +2 -0
  50. package/views/layers/KMLLayerView.d.ts +10 -10
  51. package/views/layers/KMLLayerView.js +2 -0
  52. package/views/layers/VectorTileLayerView.d.ts +5 -5
  53. package/views/layers/VectorTileLayerView.js +2 -0
  54. package/widgets/Editor.js +1 -1
  55. package/widgets/Sketch/SketchViewModel.js +1 -1
  56. package/widgets/Sketch/support/ResponsiveToolbar/OverflowGroup.js +1 -1
  57. package/widgets/Sketch/support/ResponsiveToolbar/SplitButton.js +1 -1
  58. package/widgets/Sketch/support/ResponsiveToolbar/responsiveToolbarUtils.js +1 -1
  59. package/widgets/Sketch.js +1 -1
  60. package/assets/esri/core/workers/chunks/7642905920e169a147f3.js +0 -1
  61. package/assets/esri/core/workers/chunks/8aabc71d7f15c4407d7d.js +0 -1
  62. package/views/3d/layers/graphics/focusAreaStyle.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{drainHandles as s,destroyHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import p from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{createAbortError as c,whenOrAbort as d,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as y,on as m,when as v,whenOnce as f}from"../../core/reactiveUtils.js";import{property as _,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as G}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as T,isLoaded as O,load as S,project as E}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as M}from"../../geometry/support/spatialReferenceUtils.js";import A from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as k}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as H}from"../../support/elevationInfoUtils.js";import D from"../../symbols/FillSymbol3DLayer.js";import I from"../../symbols/MeshSymbol3D.js";import P from"../../symbols/SimpleFillSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";import R from"../../symbols/SimpleMarkerSymbol.js";import U from"../../symbols/TextSymbol.js";import{symbolTypes as x}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as L}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as F}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as V}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as K}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as W}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Z}from"../../views/input/InputManager.js";import{sketchKeys as q}from"../../views/interactive/keybindings.js";import N from"../../views/interactive/sketch/SketchLabelOptions.js";import z from"../../views/interactive/sketch/SketchOptions.js";import B from"../../views/interactive/sketch/SketchTooltipOptions.js";import $ from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as Y}from"../../views/interactive/snapping/SnappingManager.js";import J from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as Q}from"../../views/interactive/snapping/snappingUtils.js";import{defaultHighlightName as X}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ee}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as te}from"../../views/support/screenUtils.js";import oe from"./adapters/layer/GraphicsLayerAdapter.js";import ie from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ae,DrawToolOperationHandle as re,UpdateOperationHandle as se}from"./support/OperationHandle.js";import{PluginManager as ne}from"./support/PluginManager.js";import{getLegacyTool as pe,graphicsHaveTooFewVerticesForBox as le,getModeFromCreateOptions as he,getDrawToolGeometryTypeFromCreateTool as ce}from"./support/sketchUtils.js";const de={defaultZ:0},ue={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:X},tool:"transform"},ge=Symbol(),ye=Symbol();let me=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new A({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ne,this._operationHandle=null,this._updatingHandles=new w,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new P({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new j({color:[130,130,130,1],width:2}),this.meshSymbol=new I({symbolLayers:new i([new D])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new z,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(ye),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},y)].filter(o);this.addHandles(t,ye)},this._originalPopupEnabled=null,this.defaultCreateOptions=de,this.defaultUpdateOptions=ue,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new J,this.textSymbol=new U({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([m(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),y),g(()=>this.view,e=>{this._defaultSnappingManager=l(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new Y({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},y),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),Q(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=l(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new oe(e);case"map-notes":return new ie(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...de,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...ue,...e,reshapeOptions:{...ue.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...ue.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=l(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new Y({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(v(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},y),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");W(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=pe(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Ee(s)||(W(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||M(o.geometry.spatialReference,t.spatialReference)||(T(o.geometry.spatialReference,t.spatialReference)||O()||await S(),o.geometry=E(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ee(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{k(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?G(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(te(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=pe(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=he(p,e),c=ce(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,g={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(g):this._makeDrawGraphicTool3D(g)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Ee(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:_e(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Ee(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,n=[o.on("key-down",t=>{if(t.key===q.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===q.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==q.vertexAdd||t.repeat)t.key===q.undo?(t.stopPropagation(),p.undo()):t.key===q.redo?(t.stopPropagation(),p.redo()):t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===q.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Z.WIDGET),o.on("key-up",t=>{t.key===q.pan?e.enabled=!0:t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===q.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Z.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?p&&p.cancel():p&&p.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new ae({activeComponent:e,type:"create",onEnd:()=>{s(n),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return p}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===q.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},Z.WIDGET),i.on("key-up",t=>{t.key===q.pan&&(e.editable=!0)},Z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===q.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.editGeometry,i=o?.allVertices.length??0;(i<1||"polyline"===o?.type&&i<2||"polygon"===o?.type&&i<2)&&t.preventDefault()}),e.on("vertex-add",i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),a=null==a?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),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("vertex-remove",i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("complete",({geometry:e})=>{const t=this.createGraphic;t&&e&&(t.geometry=e),n.complete()})],n=new re({activeComponent:e,type:"create",onEnd:()=>{s(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>n.cancel())),n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let a=i.tool??ue.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return le(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ee(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const s of e){const e=new n({view:o,graphic:s}),t=F(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${L(t)}).`),null;l.set(s,e)}const c=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new se({activeComponent:c,tool:i,type:"update",onEnd:()=>{s(d),Se(o,c),h()},undo:()=>{Te(this.view,c),be(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{we(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.set(e,t),c.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(c.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Ee(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===K(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ee(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,c=new h({graphic:e,view:o}),d=new l({object:c,view:o,enableRotation:a,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],g=new se({activeComponent:d,tool:i,type:"update",onEnd:()=>{s(u),Se(o,d),c.destroy()},undo:()=>{Te(this.view,d),be(g,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{we(g,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ee(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ee(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(q.constraint),g=new c({view:o,graphic:e}),y=new d({object:g,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(y),i||this.updateGraphics.add(e);const m=[],v=new se({activeComponent:y,tool:a,type:"update",onEnd:()=>{s(m),Se(o,y),g.destroy()},canUndo:()=>!y.destroyed&&y.canUndo,undo:()=>{y.destroyed||(y.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!y.destroyed&&y.canRedo,redo:()=>{y.destroyed||(y.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ee(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Ee(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return m.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Z.WIDGET),o.on("key-down",e=>{e.key!==q.constraint||e.repeat||(y.preserveAspectRatio=!y.preserveAspectRatio,e.stopPropagation())},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&(y.preserveAspectRatio=!y.preserveAspectRatio,e.stopPropagation())},Z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Ee(a))return a;const r=new se({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),s(l),s(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();be(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();we(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==q.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ee(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=V(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${L(h)}).`),null;const c=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],g=new se({activeComponent:d,tool:a,type:"update",onEnd:()=>{s(u),Se(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ee(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;g.onEnd(),g.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Ee(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Ee(a))return a;const r=new se({activeComponent:a,type:"update",onEnd:()=>{s(p),s(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{be(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{we(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Ee(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():le(o)?r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],o,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],o,i))),Ee(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(s(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===q.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET),i.on("key-up",e=>{if(e.key===q.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ee(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Ee(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(q.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Ee(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Oe(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Oe(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Oe(t.graphics))),o.on("scale-start",t=>e.addToHistory(Oe(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Oe([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Oe([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Oe([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Oe([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=te(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===q.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===q.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===q.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&q.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=l(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(ge)}_displayCursor(e){this.removeHandles(ge),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),ge)}_logError(e,t,o){p.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({useTextSymbol:"text"===i}),p=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??H("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager});p.addHandles(n(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:this._getGraphicSymbolFromTool(i)});return this._set("createGraphic",l),a.addAndActivateTool(p),p.begin(e),p}get test(){}wait(){return f(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await d(f(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",fe("view"))}_logMissingLayer(){this._logError(ve,fe("layer"))}};e([_()],me.prototype,"_defaultSnappingManager",void 0),e([_()],me.prototype,"_layerAdapter",null),e([_()],me.prototype,"_pluginManager",void 0),e([_()],me.prototype,"_operationHandle",void 0),e([_({readOnly:!0})],me.prototype,"_updatingHandles",void 0),e([_({readOnly:!0})],me.prototype,"activeTool",null),e([_({readOnly:!0})],me.prototype,"activeCreateToolDrawMode",null),e([_()],me.prototype,"activeTooltip",null),e([_({types:x})],me.prototype,"activeFillSymbol",void 0),e([_()],me.prototype,"activeLineSymbol",void 0),e([_()],me.prototype,"activeVertexSymbol",void 0),e([_()],me.prototype,"allowDeleteKey",void 0),e([_({readOnly:!0})],me.prototype,"createGraphic",null),e([_()],me.prototype,"defaultCreateOptions",null),e([_()],me.prototype,"defaultUpdateOptions",null),e([_({type:N,nonNullable:!0})],me.prototype,"labelOptions",null),e([_()],me.prototype,"layer",void 0),e([_({types:x})],me.prototype,"pointSymbol",void 0),e([_({types:x})],me.prototype,"polygonSymbol",void 0),e([_({types:x})],me.prototype,"polylineSymbol",void 0),e([_()],me.prototype,"meshSymbol",void 0),e([_({type:U})],me.prototype,"textSymbol",null),e([_({type:J,nonNullable:!0})],me.prototype,"snappingOptions",null),e([_()],me.prototype,"snappingManager",null),e([_({readOnly:!0})],me.prototype,"state",null),e([_({type:B,nonNullable:!0})],me.prototype,"tooltipOptions",null),e([_({readOnly:!0})],me.prototype,"updateGraphics",void 0),e([_()],me.prototype,"updateOnGraphicClick",void 0),e([_()],me.prototype,"updating",null),e([_()],me.prototype,"creationMode",void 0),e([_({type:$,nonNullable:!0})],me.prototype,"valueOptions",null),e([_({types:x})],me.prototype,"vertexSymbol",void 0),e([_({value:null})],me.prototype,"view",null),e([_({constructOnly:!0,type:z})],me.prototype,"sketchOptions",void 0),e([_()],me.prototype,"useLegacyCreateTools",void 0),e([_()],me.prototype,"isUsingLegacyCreateTools",null),e([_()],me.prototype,"pluginManager",null),e([_()],me.prototype,"drawTool",null),e([_()],me.prototype,"rootPlugins",null),e([_()],me.prototype,"effectiveAvailablePlugins",null),e([_()],me.prototype,"firstPluginWithSwappableLeaf",null),e([_()],me.prototype,"multiplePluginsActive",null),me=e([b("esri.widgets.Sketch.SketchViewModel")],me);const ve="sketch:missing-property",fe=e=>`Property '${e}' is missing on SketchViewModel.`;function _e(e){return"polygon"===e||"rectangle"===e||"circle"===e}function be(e,t){Ge("undo",e.history.undo,e.history.redo,t)}function we(e,t){Ge("redo",e.history.redo,e.history.undo,t)}function Ge(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Te(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Oe(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Se(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ee(e){return"requireError"in e&&"aborted"===e.requireError}export{me as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{drainHandles as s,destroyHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import p from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{createAbortError as c,whenOrAbort as d,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as y,on as m,when as v,initial as f,whenOnce as _}from"../../core/reactiveUtils.js";import{property as b,subclass as w}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as G}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as T}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as O,isLoaded as S,load as E,project as C}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as M}from"../../geometry/support/coordsUtils.js";import{equals as A}from"../../geometry/support/spatialReferenceUtils.js";import k from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as H}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as D}from"../../support/elevationInfoUtils.js";import I from"../../symbols/FillSymbol3DLayer.js";import P from"../../symbols/MeshSymbol3D.js";import j from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import U from"../../symbols/SimpleMarkerSymbol.js";import x from"../../symbols/TextSymbol.js";import{symbolTypes as L}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as F}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as V}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as K}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as W}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as Z}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as q}from"../../views/input/InputManager.js";import{sketchKeys as N}from"../../views/interactive/keybindings.js";import z from"../../views/interactive/sketch/SketchLabelOptions.js";import B from"../../views/interactive/sketch/SketchOptions.js";import $ from"../../views/interactive/sketch/SketchTooltipOptions.js";import Y from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as J}from"../../views/interactive/snapping/SnappingManager.js";import Q from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as X}from"../../views/interactive/snapping/snappingUtils.js";import{defaultHighlightName as ee}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as te}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as oe}from"../../views/support/screenUtils.js";import ie from"./adapters/layer/GraphicsLayerAdapter.js";import ae from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as re,DrawToolOperationHandle as se,UpdateOperationHandle as ne}from"./support/OperationHandle.js";import{PluginManager as pe}from"./support/PluginManager.js";import{getLegacyTool as le,graphicsHaveTooFewVerticesForBox as he,getModeFromCreateOptions as ce,getDrawToolGeometryTypeFromCreateTool as de}from"./support/sketchUtils.js";const ue={defaultZ:0},ge={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:ee},tool:"transform"},ye=Symbol(),me=Symbol();let ve=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new k({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new pe,this._operationHandle=null,this._updatingHandles=new G,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new U({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new j({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new R({color:[130,130,130,1],width:2}),this.meshSymbol=new P({symbolLayers:new i([new I])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new U({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new B,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(me),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},y)].filter(o);this.addHandles(t,me)},this._originalPopupEnabled=null,this.defaultCreateOptions=ue,this.defaultUpdateOptions=ge,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new Q,this.textSymbol=new x({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([m(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),y),g(()=>this.view,e=>{this._defaultSnappingManager=l(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new J({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},y),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),X(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=l(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new ie(e);case"map-notes":return new ae(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...ue,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...ge,...e,reshapeOptions:{...ge.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...ge.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=l(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new J({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(v(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},y),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");Z(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=le(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Ce(s)||(Z(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||A(o.geometry.spatialReference,t.spatialReference)||(O(o.geometry.spatialReference,t.spatialReference)||S()||await E(),o.geometry=C(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return te(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{H(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?T(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},q.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(oe(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=le(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ce(p,e),c=de(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,g={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(g):this._makeDrawGraphicTool3D(g)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:be(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,n=[o.on("key-down",t=>{if(t.key===N.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===N.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==N.vertexAdd||t.repeat)t.key===N.undo?(t.stopPropagation(),p.undo()):t.key===N.redo?(t.stopPropagation(),p.redo()):t.key!==N.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===N.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},q.WIDGET),o.on("key-up",t=>{t.key===N.pan?e.enabled=!0:t.key!==N.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===N.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},q.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?p&&p.cancel():p&&p.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new re({activeComponent:e,type:"create",onEnd:()=>{s(n),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return p}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===N.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},q.WIDGET),i.on("key-up",t=>{t.key===N.pan&&(e.editable=!0)},q.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===N.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.editGeometry,i=o?.allVertices.length??0;(i<1||"polyline"===o?.type&&i<2||"polygon"===o?.type&&i<2)&&t.preventDefault()}),e.on("vertex-add",i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),a=null==a?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),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("vertex-remove",i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("complete",({geometry:e})=>{const t=this.createGraphic;t&&e&&(t.geometry=e),n.complete()})],n=new se({activeComponent:e,type:"create",onEnd:()=>{s(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>n.cancel())),n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let a=i.tool??ge.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return he(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const s of e){const e=new n({view:o,graphic:s}),t=V(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${F(t)}).`),null;l.set(s,e)}const c=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new ne({activeComponent:c,tool:i,type:"update",onEnd:()=>{s(d),Ee(o,c),h()},undo:()=>{Oe(this.view,c),we(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.set(e,t),c.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(c.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Ce(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),q.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},q.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===W(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,c=new h({graphic:e,view:o}),d=new l({object:c,view:o,enableRotation:a,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],g=new ne({activeComponent:d,tool:i,type:"update",onEnd:()=>{s(u),Ee(o,d),c.destroy()},undo:()=>{Oe(this.view,d),we(g,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(g,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),q.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},q.WIDGET)),g}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(N.constraint),g=new c({view:o,graphic:e}),y=new d({object:g,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(y),i||this.updateGraphics.add(e);const m=[],v=new ne({activeComponent:y,tool:a,type:"update",onEnd:()=>{s(m),Ee(o,y),g.destroy()},canUndo:()=>!y.destroyed&&y.canUndo,undo:()=>{y.destroyed||(y.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!y.destroyed&&y.canRedo,redo:()=>{y.destroyed||(y.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Ce(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return m.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),q.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),q.WIDGET),o.on("key-down",e=>{e.key!==N.constraint||e.repeat||(y.preserveAspectRatio=!y.preserveAspectRatio,e.stopPropagation())},q.WIDGET),o.on("key-up",e=>{e.key===N.constraint&&(y.preserveAspectRatio=!y.preserveAspectRatio,e.stopPropagation())},q.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Ce(a))return a;const r=new ne({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),s(l),s(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();we(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ge(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),q.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==N.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},q.WIDGET),o.on("key-up",e=>{e.key===N.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},q.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=K(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${F(h)}).`),null;const c=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],g=new ne({activeComponent:d,tool:a,type:"update",onEnd:()=>{s(u),Ee(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;g.onEnd(),g.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Ce(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),q.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},q.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Ce(a))return a;const r=new ne({activeComponent:a,type:"update",onEnd:()=>{s(p),s(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{we(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ge(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Ce(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():he(o)?r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],o,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],o,i))),Ce(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(s(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),q.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===N.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},q.WIDGET),i.on("key-up",e=>{if(e.key===N.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},q.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ce(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Ce(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(N.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Ce(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>M(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>M(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Se(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Se(t.graphics))),o.on("scale-start",t=>e.addToHistory(Se(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Se([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Se([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Se([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=oe(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===N.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===N.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===N.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&N.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=l(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(ye)}_displayCursor(e){this.removeHandles(ye),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),ye)}_logError(e,t,o){p.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({useTextSymbol:"text"===i}),p=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??D("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager});p.addHandles(n(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes}});return p.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e,f)),this._set("createGraphic",l),a.addAndActivateTool(p),p.begin(e),p}get test(){}wait(){return _(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await d(_(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",_e("view"))}_logMissingLayer(){this._logError(fe,_e("layer"))}};e([b()],ve.prototype,"_defaultSnappingManager",void 0),e([b()],ve.prototype,"_layerAdapter",null),e([b()],ve.prototype,"_pluginManager",void 0),e([b()],ve.prototype,"_operationHandle",void 0),e([b({readOnly:!0})],ve.prototype,"_updatingHandles",void 0),e([b({readOnly:!0})],ve.prototype,"activeTool",null),e([b({readOnly:!0})],ve.prototype,"activeCreateToolDrawMode",null),e([b()],ve.prototype,"activeTooltip",null),e([b({types:L})],ve.prototype,"activeFillSymbol",void 0),e([b()],ve.prototype,"activeLineSymbol",void 0),e([b()],ve.prototype,"activeVertexSymbol",void 0),e([b()],ve.prototype,"allowDeleteKey",void 0),e([b({readOnly:!0})],ve.prototype,"createGraphic",null),e([b()],ve.prototype,"defaultCreateOptions",null),e([b()],ve.prototype,"defaultUpdateOptions",null),e([b({type:z,nonNullable:!0})],ve.prototype,"labelOptions",null),e([b()],ve.prototype,"layer",void 0),e([b({types:L})],ve.prototype,"pointSymbol",void 0),e([b({types:L})],ve.prototype,"polygonSymbol",void 0),e([b({types:L})],ve.prototype,"polylineSymbol",void 0),e([b()],ve.prototype,"meshSymbol",void 0),e([b({type:x})],ve.prototype,"textSymbol",null),e([b({type:Q,nonNullable:!0})],ve.prototype,"snappingOptions",null),e([b()],ve.prototype,"snappingManager",null),e([b({readOnly:!0})],ve.prototype,"state",null),e([b({type:$,nonNullable:!0})],ve.prototype,"tooltipOptions",null),e([b({readOnly:!0})],ve.prototype,"updateGraphics",void 0),e([b()],ve.prototype,"updateOnGraphicClick",void 0),e([b()],ve.prototype,"updating",null),e([b()],ve.prototype,"creationMode",void 0),e([b({type:Y,nonNullable:!0})],ve.prototype,"valueOptions",null),e([b({types:L})],ve.prototype,"vertexSymbol",void 0),e([b({value:null})],ve.prototype,"view",null),e([b({constructOnly:!0,type:B})],ve.prototype,"sketchOptions",void 0),e([b()],ve.prototype,"useLegacyCreateTools",void 0),e([b()],ve.prototype,"isUsingLegacyCreateTools",null),e([b()],ve.prototype,"pluginManager",null),e([b()],ve.prototype,"drawTool",null),e([b()],ve.prototype,"rootPlugins",null),e([b()],ve.prototype,"effectiveAvailablePlugins",null),e([b()],ve.prototype,"firstPluginWithSwappableLeaf",null),e([b()],ve.prototype,"multiplePluginsActive",null),ve=e([w("esri.widgets.Sketch.SketchViewModel")],ve);const fe="sketch:missing-property",_e=e=>`Property '${e}' is missing on SketchViewModel.`;function be(e){return"polygon"===e||"rectangle"===e||"circle"===e}function we(e,t){Te("undo",e.history.undo,e.history.redo,t)}function Ge(e,t){Te("redo",e.history.redo,e.history.undo,t)}function Te(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Oe(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Se(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Ee(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ce(e){return"requireError"in e&&"aborted"===e.requireError}export{ve as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";import i from"../../../Widget.js";import{WellKnownSizes as n,Icons as r}from"./responsiveToolbarUtils.js";import{ToolbarGroupBase as s}from"./ToolbarGroupBase.js";import{loadCalciteComponents as l}from"../../../support/componentsUtils.js";import{tsx as a,tsxFragment as c,messageBundle as p}from"../../../support/widget.js";let m=class extends(s(i)){constructor(t){super(t),this.allowCollapse=!0,this.messagesCommon=null}loadDependencies(){return l({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu")})}static{this.vnodeSelector="calcite-action-group"}get minimumLength(){const{actionChildren:t,scale:o}=this;return t.length?this.allowCollapse?n.groupSeparator+n.groupPadding[o]+n.action[o]*Math.min(t.length,2):n.groupSeparator+n.groupPadding[o]+n.action[o]*t.length:0}get lengthOptions(){const{actionChildren:t,scale:o,minimumLength:e,allowCollapse:i,priority:r}=this,s=[e];if(t.length<=2||!i||r<1)return s;for(let l=1;l<t.length-1;l++)s.push(e+n.action[o]*l+n.groupPadding[o]);return s}render(){if(!this.actionChildren.length)return a(c,null,void 0);const{budgetedLength:t,actionChildren:o,activeChildElement:e,layout:i,slot:s,scale:l}=this,p=Math.floor((t-n.groupPadding[l])/n.action[l]),m=[],u=[];if(p>=o.length)m.push(...o);else{const t=e??m.at(0);if(m.push(...o.slice(0,p-1)),u.push(...o.slice(p-1)),t&&u.includes(t)){const[o]=u.splice(u.indexOf(t),1),e=m.pop();m.push(o),e&&u.unshift(e)}}return a("calcite-action-group",{key:"overflow-button-group",layout:i,onclick:t=>this._handleClick(t.target),slot:s},m.map(t=>this._renderManagedAction(t)),u.length>0?a("calcite-action-menu",{key:"split-button-dropdown",label:this.messagesCommon.more,overlayPositioning:"fixed"},a("calcite-action",{icon:r.overflow,key:"split-button-dropdown-trigger",scale:l,slot:"trigger",text:this.messagesCommon.more}),u.map(t=>this._renderManagedAction(t))):void 0)}_renderManagedAction(t){return a("calcite-action",{...t?.properties,"data-action-key":t?.properties?.key,text:t?.properties?.text??""})}};t([o()],m.prototype,"allowCollapse",void 0),t([o()],m.prototype,"minimumLength",null),t([o(),p("esri/t9n/common")],m.prototype,"messagesCommon",void 0),t([o()],m.prototype,"lengthOptions",null),m=t([e("esri.widgets.Sketch.support.ResponsiveToolbar.OverflowGroup")],m);export{m as default};
2
+ import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";import i from"../../../Widget.js";import{WellKnownSizes as n,Icons as r}from"./responsiveToolbarUtils.js";import{ToolbarGroupBase as s}from"./ToolbarGroupBase.js";import{loadCalciteComponents as a}from"../../../support/componentsUtils.js";import{tsx as l,tsxFragment as c,messageBundle as p}from"../../../support/widget.js";let m=class extends(s(i)){constructor(t){super(t),this.allowCollapse=!0,this.messagesCommon=null}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu")})}static{this.vnodeSelector="calcite-action-group"}get minimumLength(){const{actionChildren:t,scale:o}=this;return t.length?this.allowCollapse?n.groupSeparator+n.groupPadding[o]+(n.action[o]+n.actionPadding[o])*Math.min(t.length,2):n.groupSeparator+n.groupPadding[o]+(n.action[o]+n.actionPadding[o])*t.length:0}get lengthOptions(){const{actionChildren:t,scale:o,minimumLength:e,allowCollapse:i,priority:r}=this,s=[e];if(t.length<=2||!i||r<1)return s;for(let a=1;a<t.length-1;a++)s.push(e+(n.action[o]+n.actionPadding[o])*a);return s}render(){if(!this.actionChildren.length)return l(c,null,void 0);const{budgetedLength:t,actionChildren:o,activeChildElement:e,layout:i,slot:s,scale:a}=this,p=Math.floor((t-n.groupPadding[a]-n.groupSeparator)/(n.action[a]+n.actionPadding[a])),m=[],d=[];if(p>=o.length)m.push(...o);else{const t=e??m.at(0);if(m.push(...o.slice(0,p-1)),d.push(...o.slice(p-1)),t&&d.includes(t)){const[o]=d.splice(d.indexOf(t),1),e=m.pop();m.push(o),e&&d.unshift(e)}}return l("calcite-action-group",{key:"overflow-button-group",layout:i,onclick:t=>this._handleClick(t.target),slot:s},m.map(t=>this._renderManagedAction(t)),d.length>0?l("calcite-action-menu",{key:"split-button-dropdown",label:this.messagesCommon.more,overlayPositioning:"fixed"},l("calcite-action",{icon:r.overflow,key:"split-button-dropdown-trigger",scale:a,slot:"trigger",text:this.messagesCommon.more}),d.map(t=>this._renderManagedAction(t))):void 0)}_renderManagedAction(t){return l("calcite-action",{...t?.properties,"data-action-key":t?.properties?.key,text:t?.properties?.text??""})}};t([o()],m.prototype,"allowCollapse",void 0),t([o()],m.prototype,"minimumLength",null),t([o(),p("esri/t9n/common")],m.prototype,"messagesCommon",void 0),t([o()],m.prototype,"lengthOptions",null),m=t([e("esri.widgets.Sketch.support.ResponsiveToolbar.OverflowGroup")],m);export{m as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";import i from"../../../Widget.js";import{WellKnownSizes as n,Icons as r}from"./responsiveToolbarUtils.js";import{ToolbarGroupBase as s}from"./ToolbarGroupBase.js";import{loadCalciteComponents as a}from"../../../support/componentsUtils.js";import{tsx as l,tsxFragment as p,messageBundle as c}from"../../../support/widget.js";const u={splitButtonBase:`${"esri-split-button"}--split-part`};let m=class extends(s(i)){constructor(t){super(t),this.allowCollapse=!0,this.messagesCommon=null}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu")})}static{this.vnodeSelector="calcite-action-group"}get minimumLength(){const t=this.actionChildren;if(!t.length)return 0;const{scale:o}=this;return 1===t.length?n.action[o]+n.groupSeparator+n.groupPadding[o]:this.allowCollapse?n.action[o]+n.groupPadding[o]+n.splitButtonPart[this.layout][o]+n.groupSeparator:n.action[o]*t.length+n.groupSeparator+n.groupPadding[o]}get lengthOptions(){const{actionChildren:t,minimumLength:o,layout:e,scale:i,priority:r,allowCollapse:s}=this;if(t.length<2||r<0||!s)return[o];const a=n.groupSeparator+n.groupPadding[i]+n.action[i]*t.length;return[n.groupSeparator+n.groupPadding[i]+n.action[i]+n.splitButtonPart[e][i],a]}render(){if(!this.actionChildren.length)return l(p,null,void 0);const{actionChildren:t,minimumLength:o,budgetedLength:e,layout:i,slot:n,allowCollapse:r}=this,s=!r||t.length<2||e>o;return l("calcite-action-group",{key:"split-button-group",layout:i,onclick:t=>this._handleClick(t.target),slot:n},s?this._renderUnSplit():this._renderSplit())}_renderSplit(){const{activeChildElement:t,layout:o,actionChildren:e,scale:i,messagesCommon:n}=this,s=t??e.at(0);if(!s)return;const a=e.filter(t=>t!==s);return[this._renderManagedAction(s),l("calcite-action-menu",{key:"split-button-dropdown",label:n.more,overlayPositioning:"fixed",placement:"horizontal"===o?"bottom-end":"right-end"},l("calcite-action",{class:`${u.splitButtonBase}--${o}--${this.scale}`,compact:"horizontal"===o,icon:r.splitButton[o],key:"split-button-dropdown-trigger",scale:i,slot:"trigger",text:n.more}),a?.map(t=>this._renderManagedAction(t)))]}_renderUnSplit(){return this.actionChildren.map(t=>this._renderManagedAction(t))}_renderManagedAction(t){return l("calcite-action",{...t?.properties,"data-action-key":t?.properties?.key,text:t?.properties?.text??""})}};t([o()],m.prototype,"minimumLength",null),t([o()],m.prototype,"allowCollapse",void 0),t([o()],m.prototype,"lengthOptions",null),t([o(),c("esri/t9n/common")],m.prototype,"messagesCommon",void 0),m=t([e("esri.widgets.Sketch.support.ResponsiveToolbar.SplitButton")],m);export{m as SplitButton};
2
+ import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";import i from"../../../Widget.js";import{WellKnownSizes as n,Icons as r}from"./responsiveToolbarUtils.js";import{ToolbarGroupBase as s}from"./ToolbarGroupBase.js";import{loadCalciteComponents as a}from"../../../support/componentsUtils.js";import{tsx as l,tsxFragment as c,messageBundle as p}from"../../../support/widget.js";const d={splitButtonBase:`${"esri-split-button"}--split-part`};let m=class extends(s(i)){constructor(t){super(t),this.allowCollapse=!0,this.messagesCommon=null}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu")})}static{this.vnodeSelector="calcite-action-group"}get minimumLength(){const t=this.actionChildren;if(!t.length)return 0;const{scale:o}=this;return 1===t.length?n.action[o]+n.groupSeparator+n.groupPadding[o]:this.allowCollapse?n.action[o]+2*n.actionPadding[o]+n.groupPadding[o]+n.splitButtonPart[this.layout][o]+n.groupSeparator:(n.action[o]+n.actionPadding[o])*t.length+n.groupSeparator+n.groupPadding[o]}get lengthOptions(){const{actionChildren:t,minimumLength:o,scale:e,priority:i,allowCollapse:r}=this;if(t.length<2||i<0||!r)return[o];return[o,n.groupSeparator+n.groupPadding[e]+(n.action[e]+n.actionPadding[e])*t.length]}render(){if(!this.actionChildren.length)return l(c,null,void 0);const{actionChildren:t,minimumLength:o,budgetedLength:e,layout:i,slot:n,allowCollapse:r}=this,s=!r||t.length<2||e>o;return l("calcite-action-group",{key:"split-button-group",layout:i,onclick:t=>this._handleClick(t.target),slot:n},s?this._renderUnSplit():this._renderSplit())}_renderSplit(){const{activeChildElement:t,layout:o,actionChildren:e,scale:i,messagesCommon:n}=this,s=t??e.at(0);if(!s)return;const a=e.filter(t=>t!==s);return[this._renderManagedAction(s),l("calcite-action-menu",{key:"split-button-dropdown",label:n.more,overlayPositioning:"fixed",placement:"horizontal"===o?"bottom-end":"right-end"},l("calcite-action",{class:`${d.splitButtonBase}--${o}--${this.scale}`,compact:"horizontal"===o,icon:r.splitButton[o],key:"split-button-dropdown-trigger",scale:i,slot:"trigger",text:n.more}),a?.map(t=>this._renderManagedAction(t)))]}_renderUnSplit(){return this.actionChildren.map(t=>this._renderManagedAction(t))}_renderManagedAction(t){return l("calcite-action",{...t?.properties,"data-action-key":t?.properties?.key,text:t?.properties?.text??""})}};t([o()],m.prototype,"minimumLength",null),t([o()],m.prototype,"allowCollapse",void 0),t([o()],m.prototype,"lengthOptions",null),t([o(),p("esri/t9n/common")],m.prototype,"messagesCommon",void 0),m=t([e("esri.widgets.Sketch.support.ResponsiveToolbar.SplitButton")],m);export{m as SplitButton};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- const o={groupSeparator:1,groupPadding:{s:8,m:12,l:16},action:{s:24,m:32,l:44},splitButtonPart:{horizontal:{s:16,m:16,l:24},vertical:{s:16,m:24,l:40}}},t={splitButton:{horizontal:"chevron-down",vertical:"ellipsis"},overflow:"ellipsis"};function l(o,t){return o.vnodeSelector===t?[o]:o.children?.flatMap(o=>l(o,t))??[]}export{t as Icons,o as WellKnownSizes,l as findMatchingChildren};
2
+ const o={groupSeparator:1,groupPadding:{s:4,m:8,l:10},actionPadding:{s:4,m:8,l:10},action:{s:24,m:32,l:44},splitButtonPart:{horizontal:{s:16,m:16,l:24},vertical:{s:16,m:24,l:40}}},t={splitButton:{horizontal:"chevron-down",vertical:"ellipsis"},overflow:"ellipsis"};function l(o,t){return o.vnodeSelector===t?[o]:o.children?.flatMap(o=>l(o,t))??[]}export{t as Icons,o as WellKnownSizes,l as findMatchingChildren};
package/widgets/Sketch.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{deprecateWidget as i}from"../core/deprecate.js";import{handlesGroup as l}from"../core/handleUtils.js";import s from"../core/Logger.js";import{removeMaybe as n,destroyMaybe as r}from"../core/maybe.js";import{ignoreAbortErrors as a}from"../core/promiseUtils.js";import{watch as p,syncAndInitial as c,when as d}from"../core/reactiveUtils.js";import{property as u,subclass as h}from"../core/accessorSupport/decorators.js";import{symbolTypes as v}from"../symbols/support/typeUtils.js";import m from"../views/interactive/sketch/SketchLabelOptions.js";import g from"../views/interactive/sketch/SketchTooltipOptions.js";import y from"../views/interactive/sketch/SketchValueOptions.js";import f from"./Widget.js";import b from"./Sketch/SketchViewModel.js";import w from"./Sketch/VisibleElements.js";import _ from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import M from"./support/SelectionToolbar.js";import C from"./support/SketchTooltipControls.js";import S from"./support/SnappingControls.js";import{tsx as O,messageBundle as k,vmEvent as P}from"./support/widget.js";import I from"./support/SelectionToolbar/VisibleElements.js";import L from"./support/SketchTooltipControls/VisibleElements.js";const x="esri-sketch",E={base:x,vertical:`${x}--vertical`,docked:`${x}-bar`,floating:`${x}-pad`,chipHorizontal:`${x}__selection-count-chip--horizontal`,chipVertical:`${x}__selection-count-chip--vertical`,chipVerticalSmall:`${x}__selection-count-chip--vertical--s`,popoverWrapper:`${x}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let G=class extends f{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new w,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{i(s.getLogger(this),"Sketch","arcgis-sketch",{version:"5.0"})}),this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new b({creationMode:e?.creationMode??"continuous",useLegacyCreateTools:e?.useLegacyCreateTools??"2d"!==e?.view?.type})),this.viewModel.pluginManager.sketch=this}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...o}=e;return o}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,i=new M({persistSelection:!1,visibleElements:new I({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([p(()=>this.viewModel,e=>{this._viewModelHandlesGroup=n(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=l([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),p(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),p(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),p(()=>e.state,()=>this.notifyChange("state"))]))},c),d(()=>i.activeOperation,()=>{this.viewModel.cancel(),this._activeCustomToolOptions=null}),i.on("complete",e=>this._onSelectionOperationComplete(e)),p(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(i.visibleElements,e)},c)]),this._selectionToolbar=i}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=n(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const{availableCreateTools:t}=this,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&r(t),t?.pluginManager?.sketch===this&&(t.pluginManager.sketch=null),this._set("viewModel",e),e.pluginManager.sketch=this)}get useLegacyCreateTools(){return this.viewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.viewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.viewModel.isUsingLegacyCreateTools}get _effectiveAvailableCreateTools(){if(this.viewModel.effectiveAvailablePlugins?.length)return this.viewModel.effectiveAvailablePlugins;const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,a(this.viewModel.create(e,i))}update(e,t){return a(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this;return O("div",null,O("div",{classes:{[E.base]:!0,[E.floating]:"floating"===e,[E.docked]:"docked"===e,[E.vertical]:"vertical"===t}},O(_,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),this._renderSelectionToolsOrBack(),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSelectionToolsOrBack(){if(!this.viewModel.isUsingLegacyCreateTools&&this.viewModel.firstPluginWithSwappableLeaf)return this._renderBackButton();const e=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),e?.map(e=>this._renderToolbarItem(e)))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:l}=this;if(!this._calcitePopoverReferenceElement)return;const s={directionModePicker:l.directionModePicker,labelsToggle:l.labelsToggle,tooltipsToggle:l.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:E.popoverWrapper},Object.values(s).includes(!0)?O(C,{sketchOptions:i.sketchOptions,viewType:o?.type,visibleElements:new L(s)}):void 0,l.snappingControls&&o&&t?O(S,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:l.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(_,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderBackButton(){const{viewModel:e,isUsingLegacyCreateTools:t}=this;if(!t&&e.multiplePluginsActive&&e.firstPluginWithSwappableLeaf&&e.rootPlugins&&!(e.rootPlugins.length<2&&e.rootPlugins.includes(e.firstPluginWithSwappableLeaf)))return O("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"back-button-group"},O("calcite-action",{icon:"chevron-left",onclick:()=>{this.viewModel?.cancel()},scale:this.scale,text:this.messagesCommon.back}))}_renderCreateToolActionGroup(){const e=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[],t=this._effectiveAvailableCreateTools,o=t?.filter(e=>"string"==typeof e),i=o?.map(e=>this._renderCreateToolItem(e)),l=t?.filter(e=>"string"!=typeof e).map(e=>this._renderCreateToolItem(e));return[i?.length||e?.length||l?.length?O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},i,e,l):void 0]}_renderCreateToolItem(e){return"string"==typeof e?this._renderBuiltInCreateToolItem(e):this._renderDrawToolPluginItem(e)}_renderDrawToolPluginItem(e){const{icon:t,localizationKey:o,uniqueId:i,hidden:l}=e;if(l)return[];const s=this.messages.digitizers,n=s?.[o]??o,r=this.viewModel.drawTool?.pluginStack.some(e=>!e.configuration?.hidden&&e.configuration?.uniqueId===i);return this._renderToolbarItem({id:`${o}-button`,text:n,icon:t,onclick:()=>this._activatePlugin([e]),active:r})}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:l,updateGraphics:{length:s}}=this,n=t(o.selectedCount,{count:s}),r="l"===i?999:99,a=s>r?t(o.selectedCountTruncated,{truncated:r}):s,p="l"!==i&&"vertical"===e,c=p?`${l}-selection-chip-small`:`${l}-selection-chip`;return[p?O("span",{classes:{[E.chipVertical]:!0,[E.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?E.chipHorizontal:E.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:l,active:s,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[O("calcite-action",{active:s,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:l,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const l=this._calcitePopoverReferenceElement;if(!l)return;const{bottom:s,top:n}=l.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",s-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){s.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_activatePlugin(e){this._selectionToolbar?.cancel(),this.viewModel.firstPluginWithSwappableLeaf?(this.viewModel.drawTool?.replaceLeaf(e),this.view?.ready&&this.view.focus()):this._activateCreateTool(e)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([u()],G.prototype,"activeTool",null),e([u({readOnly:!0})],G.prototype,"activeTooltip",null),e([u({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],G.prototype,"availableCreateTools",void 0),e([u({readOnly:!0})],G.prototype,"createGraphic",null),e([u()],G.prototype,"creationMode",null),e([u()],G.prototype,"customToolOptions",void 0),e([u()],G.prototype,"customActions",void 0),e([u()],G.prototype,"defaultCreateOptions",null),e([u()],G.prototype,"defaultUpdateOptions",null),e([u()],G.prototype,"icon",null),e([u()],G.prototype,"label",null),e([u({type:m})],G.prototype,"labelOptions",null),e([u()],G.prototype,"layer",null),e([u({type:["horizontal","vertical"],value:"horizontal"})],G.prototype,"layout",null),e([u({types:v})],G.prototype,"pointSymbol",null),e([u({types:v})],G.prototype,"polygonSymbol",null),e([u({types:v})],G.prototype,"polylineSymbol",null),e([u()],G.prototype,"textSymbol",null),e([u({value:"m"})],G.prototype,"scale",null),e([u()],G.prototype,"toolbarKind",void 0),e([u()],G.prototype,"contextualToolLocation",void 0),e([u()],G.prototype,"groupCollapsePriorities",void 0),e([u()],G.prototype,"groupAllowCollapseOptions",void 0),e([u(),k("esri/widgets/Sketch/t9n/Sketch")],G.prototype,"messages",void 0),e([u(),k("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([u()],G.prototype,"snappingOptions",null),e([u()],G.prototype,"state",null),e([u({type:g})],G.prototype,"tooltipOptions",null),e([u({readOnly:!0})],G.prototype,"updateGraphics",null),e([u({type:y,nonNullable:!0})],G.prototype,"valueOptions",null),e([u()],G.prototype,"view",null),e([u({type:b}),P(["create","update","undo","redo"])],G.prototype,"viewModel",null),e([u({type:w,nonNullable:!0})],G.prototype,"visibleElements",void 0),e([u()],G.prototype,"useLegacyCreateTools",null),e([u()],G.prototype,"isUsingLegacyCreateTools",null),e([u()],G.prototype,"_effectiveAvailableCreateTools",null),e([u()],G.prototype,"_defaultViewModel",void 0),e([u()],G.prototype,"_activeCustomToolOptions",void 0),e([u()],G.prototype,"_calcitePopoverReferenceElement",void 0),e([u()],G.prototype,"_relativeLocation",void 0),e([u()],G.prototype,"_popoverOpen",void 0),G=e([h("esri.widgets.Sketch")],G);const B=G;export{B as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{deprecateWidget as i}from"../core/deprecate.js";import{handlesGroup as l}from"../core/handleUtils.js";import s from"../core/Logger.js";import{removeMaybe as n,destroyMaybe as r}from"../core/maybe.js";import{ignoreAbortErrors as a}from"../core/promiseUtils.js";import{watch as p,syncAndInitial as c,when as d}from"../core/reactiveUtils.js";import{property as u,subclass as h}from"../core/accessorSupport/decorators.js";import{symbolTypes as v}from"../symbols/support/typeUtils.js";import m from"../views/interactive/sketch/SketchLabelOptions.js";import g from"../views/interactive/sketch/SketchTooltipOptions.js";import y from"../views/interactive/sketch/SketchValueOptions.js";import f from"./Widget.js";import b from"./Sketch/SketchViewModel.js";import w from"./Sketch/VisibleElements.js";import _ from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import M from"./support/SelectionToolbar.js";import C from"./support/SketchTooltipControls.js";import S from"./support/SnappingControls.js";import{tsx as O,messageBundle as k,vmEvent as P}from"./support/widget.js";import I from"./support/SelectionToolbar/VisibleElements.js";import L from"./support/SketchTooltipControls/VisibleElements.js";const x="esri-sketch",E={base:x,vertical:`${x}--vertical`,docked:`${x}-bar`,floating:`${x}-pad`,chipHorizontal:`${x}__selection-count-chip--horizontal`,chipVertical:`${x}__selection-count-chip--vertical`,chipVerticalSmall:`${x}__selection-count-chip--vertical--s`,popoverWrapper:`${x}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let G=class extends f{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new w,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{i(s.getLogger(this),"Sketch","arcgis-sketch",{version:"5.0"})}),this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new b({creationMode:e?.creationMode??"continuous",useLegacyCreateTools:e?.useLegacyCreateTools??"3d"===e?.view?.type})),this.viewModel.pluginManager.sketch=this}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...o}=e;return o}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,i=new M({persistSelection:!1,visibleElements:new I({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([p(()=>this.viewModel,e=>{this._viewModelHandlesGroup=n(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=l([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),p(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),p(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),p(()=>e.state,()=>this.notifyChange("state"))]))},c),d(()=>i.activeOperation,()=>{this.viewModel.cancel(),this._activeCustomToolOptions=null}),i.on("complete",e=>this._onSelectionOperationComplete(e)),p(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(i.visibleElements,e)},c)]),this._selectionToolbar=i}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=n(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const{availableCreateTools:t}=this,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&r(t),t?.pluginManager?.sketch===this&&(t.pluginManager.sketch=null),this._set("viewModel",e),e.pluginManager.sketch=this)}get useLegacyCreateTools(){return this.viewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.viewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.viewModel.isUsingLegacyCreateTools}get _effectiveAvailableCreateTools(){if(this.viewModel.effectiveAvailablePlugins?.length)return this.viewModel.effectiveAvailablePlugins;const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,a(this.viewModel.create(e,i))}update(e,t){return a(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this;return O("div",null,O("div",{classes:{[E.base]:!0,[E.floating]:"floating"===e,[E.docked]:"docked"===e,[E.vertical]:"vertical"===t}},O(_,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),this._renderSelectionToolsOrBack(),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSelectionToolsOrBack(){if(!this.viewModel.isUsingLegacyCreateTools&&this.viewModel.firstPluginWithSwappableLeaf)return this._renderBackButton();const e=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),e?.map(e=>this._renderToolbarItem(e)))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:l}=this;if(!this._calcitePopoverReferenceElement)return;const s={directionModePicker:l.directionModePicker,labelsToggle:l.labelsToggle,tooltipsToggle:l.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:E.popoverWrapper},Object.values(s).includes(!0)?O(C,{sketchOptions:i.sketchOptions,viewType:o?.type,visibleElements:new L(s)}):void 0,l.snappingControls&&o&&t?O(S,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:l.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(_,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderBackButton(){const{viewModel:e,isUsingLegacyCreateTools:t}=this;if(!t&&e.multiplePluginsActive&&e.firstPluginWithSwappableLeaf&&e.rootPlugins&&!(e.rootPlugins.length<2&&e.rootPlugins.includes(e.firstPluginWithSwappableLeaf)))return O("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"back-button-group"},O("calcite-action",{icon:"chevron-left",onclick:()=>{this.viewModel?.cancel()},scale:this.scale,text:this.messagesCommon.back}))}_renderCreateToolActionGroup(){const e=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[],t=this._effectiveAvailableCreateTools,o=t?.filter(e=>"string"==typeof e),i=o?.map(e=>this._renderCreateToolItem(e)),l=t?.filter(e=>"string"!=typeof e).map(e=>this._renderCreateToolItem(e));return[i?.length||e?.length||l?.length?O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},i,e,l):void 0]}_renderCreateToolItem(e){return"string"==typeof e?this._renderBuiltInCreateToolItem(e):this._renderDrawToolPluginItem(e)}_renderDrawToolPluginItem(e){const{icon:t,localizationKey:o,uniqueId:i,hidden:l}=e;if(l)return[];const s=this.messages.digitizers,n=s?.[o]??o,r=this.viewModel.drawTool?.pluginStack.some(e=>!e.configuration?.hidden&&e.configuration?.uniqueId===i);return this._renderToolbarItem({id:`${o}-button`,text:n,icon:t,onclick:()=>this._activatePlugin([e]),active:r})}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:l,updateGraphics:{length:s}}=this,n=t(o.selectedCount,{count:s}),r="l"===i?999:99,a=s>r?t(o.selectedCountTruncated,{truncated:r}):s,p="l"!==i&&"vertical"===e,c=p?`${l}-selection-chip-small`:`${l}-selection-chip`;return[p?O("span",{classes:{[E.chipVertical]:!0,[E.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?E.chipHorizontal:E.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:l,active:s,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[O("calcite-action",{active:s,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:l,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const l=this._calcitePopoverReferenceElement;if(!l)return;const{bottom:s,top:n}=l.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",s-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){s.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_activatePlugin(e){this._selectionToolbar?.cancel(),this.viewModel.firstPluginWithSwappableLeaf?(this.viewModel.drawTool?.replaceLeaf(e),this.view?.ready&&this.view.focus()):this._activateCreateTool(e)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([u()],G.prototype,"activeTool",null),e([u({readOnly:!0})],G.prototype,"activeTooltip",null),e([u({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],G.prototype,"availableCreateTools",void 0),e([u({readOnly:!0})],G.prototype,"createGraphic",null),e([u()],G.prototype,"creationMode",null),e([u()],G.prototype,"customToolOptions",void 0),e([u()],G.prototype,"customActions",void 0),e([u()],G.prototype,"defaultCreateOptions",null),e([u()],G.prototype,"defaultUpdateOptions",null),e([u()],G.prototype,"icon",null),e([u()],G.prototype,"label",null),e([u({type:m})],G.prototype,"labelOptions",null),e([u()],G.prototype,"layer",null),e([u({type:["horizontal","vertical"],value:"horizontal"})],G.prototype,"layout",null),e([u({types:v})],G.prototype,"pointSymbol",null),e([u({types:v})],G.prototype,"polygonSymbol",null),e([u({types:v})],G.prototype,"polylineSymbol",null),e([u()],G.prototype,"textSymbol",null),e([u({value:"m"})],G.prototype,"scale",null),e([u()],G.prototype,"toolbarKind",void 0),e([u()],G.prototype,"contextualToolLocation",void 0),e([u()],G.prototype,"groupCollapsePriorities",void 0),e([u()],G.prototype,"groupAllowCollapseOptions",void 0),e([u(),k("esri/widgets/Sketch/t9n/Sketch")],G.prototype,"messages",void 0),e([u(),k("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([u()],G.prototype,"snappingOptions",null),e([u()],G.prototype,"state",null),e([u({type:g})],G.prototype,"tooltipOptions",null),e([u({readOnly:!0})],G.prototype,"updateGraphics",null),e([u({type:y,nonNullable:!0})],G.prototype,"valueOptions",null),e([u()],G.prototype,"view",null),e([u({type:b}),P(["create","update","undo","redo"])],G.prototype,"viewModel",null),e([u({type:w,nonNullable:!0})],G.prototype,"visibleElements",void 0),e([u()],G.prototype,"useLegacyCreateTools",null),e([u()],G.prototype,"isUsingLegacyCreateTools",null),e([u()],G.prototype,"_effectiveAvailableCreateTools",null),e([u()],G.prototype,"_defaultViewModel",void 0),e([u()],G.prototype,"_activeCustomToolOptions",void 0),e([u()],G.prototype,"_calcitePopoverReferenceElement",void 0),e([u()],G.prototype,"_relativeLocation",void 0),e([u()],G.prototype,"_popoverOpen",void 0),G=e([h("esri.widgets.Sketch")],G);const B=G;export{B as default};