@arcgis/core 4.33.0-next.20250424 → 4.33.0-next.20250425
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analysis/Analysis.js +1 -1
- package/analysis/support/AnalysisOriginWebScene.d.ts +1 -1
- package/analysis/support/AnalysisOriginWebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/070839cb71c8e764b8d7.js +1 -0
- package/assets/esri/core/workers/chunks/19084a293694c5a00cae.js +1 -0
- package/assets/esri/core/workers/chunks/{5958af341014e13475d2.js → 2bed8a5ed9ae3760fa2f.js} +1 -1
- package/assets/esri/core/workers/chunks/{7ffa68d69c138db1295d.js → 2e3019ce49e972a815ca.js} +1 -1
- package/assets/esri/core/workers/chunks/38f5e6a202ce292edd9f.js +1 -0
- package/assets/esri/core/workers/chunks/415903f481392c72870f.js +1 -0
- package/assets/esri/core/workers/chunks/4351b3e54b309935faed.js +1 -0
- package/assets/esri/core/workers/chunks/4da99f058cca83937e9b.js +1 -0
- package/assets/esri/core/workers/chunks/5acdd49c5f1a49fdc6e7.js +1 -0
- package/assets/esri/core/workers/chunks/968f2f841c011095a6d2.js +1 -0
- package/assets/esri/core/workers/chunks/a2676f3f135ad5fdf872.js +1 -0
- package/assets/esri/core/workers/chunks/a8430e1e2142f1ce9b92.js +1 -0
- package/assets/esri/core/workers/chunks/b53300b46646cfad2526.js +319 -0
- package/assets/esri/core/workers/chunks/bf543bdec3da0fe278fb.js +1 -0
- package/assets/esri/core/workers/chunks/f52e597dca4b32a81881.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/chunks/ShadowCastAccumulate.glsl.js +13 -9
- package/chunks/ShadowCastVisualize.glsl.js +24 -9
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/interfaces.d.ts +200 -5
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/support/ParquetEncodingLocation.d.ts +4 -0
- package/layers/support/ParquetEncodingLocation.js +1 -1
- package/layers/support/ParquetEncodingWkb.d.ts +4 -0
- package/layers/support/ParquetEncodingWkb.js +1 -1
- package/layers/support/RasterStorageInfo.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/parquetUtils.d.ts +3 -0
- package/layers/support/parquetUtils.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
- package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
- package/package.json +2 -2
- package/portal/schemas/definitions.js +1 -1
- package/portal/schemas/integratedMesh3DTilesLayerItem.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
- package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/Lyr3DWorker.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
- package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/Factory.js +5 -0
- package/views/3d/layers/graphics/pipeline/symbolization/SimpleFeatureRenderer.js +5 -0
- package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
- package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
- package/views/3d/webgl/ManagedFBO.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +7 -13
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendColorsPremultiplied.glsl.js +5 -0
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +5 -0
- package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
- package/views/PopupView.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/analysis/analysisViewUtils.js +1 -1
- package/views/input/InputManager.js +1 -1
- package/views/input/ViewEvents.js +1 -1
- package/views/support/selectionUtils.js +1 -1
- package/webscene/support/analysisUtils.js +1 -1
- package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/ShadowCast/ThresholdOptions.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/VideoPlayer.js +1 -1
- package/widgets/support/AnalysisViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0a48b9734ab4c64a6f4f.js +0 -1
- package/assets/esri/core/workers/chunks/1427e7953c3d8c87c5e8.js +0 -1
- package/assets/esri/core/workers/chunks/146b3699a9e8b1f2dcc2.js +0 -1
- package/assets/esri/core/workers/chunks/22f604726529ee6f8c25.js +0 -1
- package/assets/esri/core/workers/chunks/8dd26b12c625d20196ed.js +0 -319
- package/assets/esri/core/workers/chunks/91f8547a13f0461045ef.js +0 -1
- package/assets/esri/core/workers/chunks/931275cfa2c55eb0f504.js +0 -1
- package/assets/esri/core/workers/chunks/9f416cc5673665f8c37c.js +0 -1
- package/assets/esri/core/workers/chunks/b42ecc7c3eb2fd8d1308.js +0 -1
- package/assets/esri/core/workers/chunks/d04efa51da9b4eb3a8a7.js +0 -1
- package/assets/esri/core/workers/chunks/d8474dca270b25705699.js +0 -1
- package/assets/esri/core/workers/chunks/ed3d1d0465f4a4d8df4a.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/SpatialReference.js";import z from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as R}from"../../layers/orientedImagery/transformations/utils.js";import V from"../../views/SceneView.js";import{logAndThrow as C,getMissingPropertyErrorName as M,getMissingPropertyErrorMessage as j}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as O,humanBinocularHFOV as S}from"./constants.js";import b from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as I,createImageSphere as F}from"./utils.js";const G={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let A=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new z({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(G.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()}))],G.navigation)},this._addHFOVHandles=()=>{this.removeHandles(G.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),G.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/SpatialReference.js";import z from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as R}from"../../layers/orientedImagery/transformations/utils.js";import V from"../../views/SceneView.js";import{logAndThrow as C,getMissingPropertyErrorName as M,getMissingPropertyErrorMessage as j}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as O,humanBinocularHFOV as S}from"./constants.js";import b from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as I,createImageSphere as F}from"./utils.js";const G={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let A=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new z({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(G.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()}))],G.navigation)},this._addHFOVHandles=()=>{this.removeHandles(G.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),G.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer((async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});this.emit("hittest-response",t)}));break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=R(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>!this._graphics.graphics.includes(e)));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>this._graphics.graphics.includes(e)));return this._graphics.removeMany(t),!0},this._imageRenderer=new V({map:this._map,viewingMode:"local",camera:{position:P},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([g((()=>this.imageSource),(()=>{this.imageSource&&this.autoLoad&&this._loadWithController()}),u),g((()=>this.fov),(()=>{this._reloadCamera()}),u),g((()=>this.yaw),(e=>{this.camera.heading=e,this._reloadCamera()}),u),g((()=>this.pitch),(e=>{this.camera.tilt=e,this._reloadCamera()}),u),_((()=>this.imageRenderer.ready),(()=>{this._addNavigationHandles(),this._addZoomHandles()}),u),g((()=>this.clickAction),(e=>{this.removeHandles(G.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))}),u)],G.default)}get camera(){return this.imageRenderer.camera}set camera(e){e&&(this.imageRenderer.camera=e.clone())}get fov(){return this.camera.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return x(H,e/t)}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return x(O,e/t)}get vfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.cos(a)))}async _loadImageInternal(e,t){let i;this.state="image-loading";try{i=(await a(e,{responseType:"image",...t})).data}catch(o){throw c(o)?this.state="image-load-aborted":this.state="image-load-error",o}return this._updateImageSphere(i,t)}_reloadCamera(){this.camera=this.camera.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=d(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const{size:[i,o]}=this.imageRenderer;return this._imageGraphic=I(F(e)),this._graphics.add(this._imageGraphic),this.fov=x(S,i/o),this.state="image-loaded",this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):C(this.declaredClass,new s(M("panoramic-viewer"),j("PanoramicViewerViewModel","imageSource")))}};e([y()],A.prototype,"_graphics",void 0),e([y()],A.prototype,"_imageGraphic",void 0),e([y()],A.prototype,"_imageRenderer",void 0),e([y()],A.prototype,"_loadController",void 0),e([y()],A.prototype,"_map",void 0),e([y()],A.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],A.prototype,"autoLoad",void 0),e([y({type:t})],A.prototype,"camera",null),e([v(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],A.prototype,"clickAction",void 0),e([y({type:Number})],A.prototype,"fov",null),e([y({readOnly:!0})],A.prototype,"hfov",null),e([y({readOnly:!0})],A.prototype,"imageRenderer",null),e([y()],A.prototype,"imageSize",void 0),e([y()],A.prototype,"imageSource",void 0),e([y({readOnly:!0})],A.prototype,"maxHFOV",null),e([y({readOnly:!0})],A.prototype,"minHFOV",null),e([y({type:Number})],A.prototype,"pitch",void 0),e([y()],A.prototype,"state",void 0),e([y({readOnly:!0})],A.prototype,"vfov",null),e([y({type:Number})],A.prototype,"yaw",void 0),A=e([f("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],A);const L=A;export{L as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import i from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import{abortMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{after as a,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as u}from"../../core/reactiveUtils.js";import{createScreenPointArray as d,createRenderScreenPointArray as c}from"../../core/screenUtils.js";import{convertTime as h,offsetDateUTC as m}from"../../core/timeUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{create as y}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{longitudeToTimezone as g}from"../../views/3d/support/earthUtils.js";import{computeDirectionsOverTime as v}from"../../views/3d/support/sunUtils.js";import{ShadowCastVisualization as w}from"../../views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js";import T from"./DiscreteOptions.js";import{DurationMode as D}from"./DurationMode.js";import b from"./DurationOptions.js";import{ShadowCastState as O}from"./ShadowCastState.js";import{ShadowTooltipViewModel as P}from"./ShadowTooltipViewModel.js";import{ShadowVisualizationType as j}from"./ShadowVisualizationType.js";import z from"./ThresholdOptions.js";import{breadthFirstBinaryPartitioning as U}from"../support/traversalUtils.js";const C=[],V=y(),E=[],R=255,S=h(1,"hours","milliseconds"),A=500;let x=class extends i{constructor(e){super(e),this.view=null,this.tooltip=new P({getDuration:(e,t)=>this.getDuration(e,t)}),this.startTimeOfDay=h(10,"hours","milliseconds"),this.endTimeOfDay=h(16,"hours","milliseconds"),this.visualizationType=j.Threshold,this.thresholdOptions=new z,this.durationOptions=new b,this.discreteOptions=new T,this._running=!0,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0,this._utcOffset=null,this.date=new Date}initialize(){this.addHandles([p((()=>({view:this.view,tooltipEnabled:this._tooltipEnabled})),(({view:e,tooltipEnabled:t})=>{this.tooltip.view=e,this.tooltip.enabled=t}),u),p((()=>this._forcePreviewDependencies),(()=>{o(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=s((async e=>{await a(A,e),l(e),this._forcePreview=!1})))}),u),p((()=>({renderer:this.renderer,parameters:this._visualizationParameters})),(e=>N(e.renderer,e.parameters)),u),p((()=>({renderer:this.renderer,parameters:{lightDirections:this._lightDirections}})),(e=>N(e.renderer,e.parameters)),u),p((()=>({renderer:this.renderer,parameters:{enabled:this._running}})),(e=>N(e.renderer,e.parameters)),u),p((()=>({renderer:this.renderer,parameters:{previewing:this._previewing}})),(e=>N(e.renderer,e.parameters)),u)])}destroy(){this.stop(),N(this.renderer,{enabled:!1}),n(this.tooltip)}get state(){return null!=this.view&&this.view.ready&&null!=this._referencePosition?O.Ready:O.Disabled}set date(e){const t=new Date(e);t.setHours(0,0,0,0),this._set("date",t)}get utcOffset(){return this._utcOffset??this._utcOffsetAuto}set utcOffset(e){this._utcOffset=e}get testData(){}get _previewing(){const{view:e}=this;return null==e?.allLayerViews||(this._forcePreview||!e.stationary||e.allLayerViews.some((e=>M(e)&&e.updating)))}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?g(e[0],!1):0}get _dateUTCOffset(){let e=this.date;return e=m(e,-e.getTimezoneOffset(),"minutes"),e=m(e,-this.utcOffset,"hours"),e}get _startDateTimeUTC(){return m(this._dateUTCOffset,this.startTimeOfDay)}get _endDateTimeUTC(){return m(this._dateUTCOffset,this.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _interval(){const e=this._duration>0?Math.floor(this._duration/R):R,t=this.discreteOptions.interval;switch(this.visualizationType){case j.Threshold:case j.Duration:return e;case j.Discrete:return t>0?t:e}}get _sampleCount(){return this._lightDirections.length}get _duration(){return this.endTimeOfDay-this.startTimeOfDay}get _lightDirections(){const{view:e}=this;if(null==e)return C;const t="global"===e.viewingMode?V:this._referencePosition;if(null==t)return C;const i=this._interval,r=v(this._startDateTimeUTC,this._endDateTimeUTC,i,t,e.state.viewingMode),s=r.length;E.length=0;const o=U(0,s,E),n=new Array(s);for(let a=0;a<s;++a)n[a]=r[o[a]];return n}get _tooltipEnabled(){return this.state===O.Ready&&this.visualizationType!==j.Discrete&&this._running&&!this._previewing}get _visualizationParameters(){if(!this._running)return null;switch(this.visualizationType){case j.Threshold:return this._thresholdVisualizationParameters;case j.Duration:return this._durationVisualizationParameters;case j.Discrete:return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{value:e,color:i}=this.thresholdOptions,r=this._duration;return{visualization:w.Threshold,color:t.toUnitRGBA(i),threshold:r>0?e/this._duration:0}}get _durationVisualizationParameters(){const{color:e,mode:i}=this.durationOptions,r=this._duration,s=r>0&&i===D.Hourly?S/r:0;return{color:t.toUnitRGBA(e),visualization:w.Gradient,bandsEnabled:s>0,bandSize:s}}get _discreteVisualizationParameters(){return{color:t.toUnitRGBA(this.discreteOptions.color),visualization:w.Gradient,bandsEnabled:!1,bandSize:0}}get _forcePreviewDependencies(){const{view:e}=this;if(null==e)return null;const t=e.slicePlane,i=e.allLayerViews.toArray().filter(M),s=i.map((e=>e.layer)).filter(r),o=i.map((e=>e.visible)),n=s.map((e=>e.visible)),a=s.map((e=>e.opacity)),l=s.filter((e=>"definitionExpression"in e)).map((e=>e.definitionExpression)),p=i.filter((e=>"filter"in e)).map((e=>e.filter));return{slicePlane:t,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewVisibilities:o,layerVisibilities:n,layerOpacities:a,filters:p,definitionExpressions:l}}get renderer(){const{view:e}=this;if(null==e)return null;const t=e.stage;return null==t?null:t.renderer}start(){this.setRunning(!0)}stop(){this.setRunning(!1)}setRunning(e){this._running=e}async getDuration(e,t){const{view:i,renderer:r,_sampleCount:s}=this;if(null==i||null==r||0===s)return 0;const o=i.state.camera.screenToRender(d(e.x,e.y),c());return r.readAccumulatedShadow(o)*this._duration}};function N(e,t){null!=e&&null!=t&&e.setParameters({shadowCast:t})}function M(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":return!0;case"base-dynamic-3d":case"catalog-3d":case"catalog-footprint-3d":case"catalog-dynamic-group-3d":case"dimension-3d":case"imagery-3d":case"imagery-tile-3d":case"line-of-sight-3d":case"map-image-3d":case"point-cloud-3d":case"tile-3d":case"vector-tile-3d":case"viewshed-3d":case"voxel-3d":case"wfs-3d":case"wmts-3d":case"media-3d":default:return!1;case"group":return e.layerViews.toArray().some((e=>M(e)))}}e([f()],x.prototype,"state",null),e([f()],x.prototype,"view",void 0),e([f()],x.prototype,"tooltip",void 0),e([f({type:Date,nonNullable:!0})],x.prototype,"date",null),e([f({nonNullable:!0})],x.prototype,"utcOffset",null),e([f({nonNullable:!0})],x.prototype,"startTimeOfDay",void 0),e([f({nonNullable:!0})],x.prototype,"endTimeOfDay",void 0),e([f({nonNullable:!0})],x.prototype,"visualizationType",void 0),e([f({type:z,nonNullable:!0})],x.prototype,"thresholdOptions",void 0),e([f({type:b,nonNullable:!0})],x.prototype,"durationOptions",void 0),e([f({type:T,nonNullable:!0})],x.prototype,"discreteOptions",void 0),e([f()],x.prototype,"_running",void 0),e([f()],x.prototype,"_stopPreviewingTask",void 0),e([f()],x.prototype,"_forcePreview",void 0),e([f()],x.prototype,"_autoRestoreForcePreviewEnabled",void 0),e([f()],x.prototype,"_previewing",null),e([f()],x.prototype,"_utcOffset",void 0),e([f()],x.prototype,"_utcOffsetAuto",null),e([f()],x.prototype,"_dateUTCOffset",null),e([f()],x.prototype,"_startDateTimeUTC",null),e([f()],x.prototype,"_endDateTimeUTC",null),e([f()],x.prototype,"_referencePosition",null),e([f()],x.prototype,"_interval",null),e([f()],x.prototype,"_sampleCount",null),e([f()],x.prototype,"_duration",null),e([f()],x.prototype,"_lightDirections",null),e([f()],x.prototype,"_tooltipEnabled",null),e([f()],x.prototype,"_visualizationParameters",null),e([f()],x.prototype,"_thresholdVisualizationParameters",null),e([f()],x.prototype,"_durationVisualizationParameters",null),e([f()],x.prototype,"_discreteVisualizationParameters",null),e([f()],x.prototype,"_forcePreviewDependencies",null),e([f()],x.prototype,"renderer",null),x=e([_("esri.widgets.ShadowCast.ShadowCastViewModel")],x);const G=x;export{G as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import i from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import{abortMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{after as a,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as d,syncAndInitial as u}from"../../core/reactiveUtils.js";import{createScreenPointArray as c,createRenderScreenPointArray as p}from"../../core/screenUtils.js";import{convertTime as h,offsetDateUTC as m}from"../../core/timeUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{longitudeToTimezone as v}from"../../views/3d/support/earthUtils.js";import{computeDirectionsOverTime as y}from"../../views/3d/support/sunUtils.js";import{ShadowCastVisualization as w}from"../../views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js";import D from"./DiscreteOptions.js";import{DurationMode as T}from"./DurationMode.js";import O from"./DurationOptions.js";import{ShadowCastState as P}from"./ShadowCastState.js";import{ShadowTooltipViewModel as C}from"./ShadowTooltipViewModel.js";import{ShadowVisualizationType as b}from"./ShadowVisualizationType.js";import z from"./ThresholdOptions.js";import{breadthFirstBinaryPartitioning as j}from"../support/traversalUtils.js";const U=[],V=g(),x=[],S=255,A=h(1,"hours","milliseconds"),E=500;let R=class extends i{constructor(e){super(e),this.view=null,this.tooltip=new C({getDuration:(e,t)=>this.getDuration(e,t)}),this.startTimeOfDay=h(10,"hours","milliseconds"),this.endTimeOfDay=h(16,"hours","milliseconds"),this.visualizationType=b.Threshold,this.thresholdOptions=new z,this.durationOptions=new O,this.discreteOptions=new D,this._running=!0,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0,this._utcOffset=null,this.date=new Date}initialize(){this.addHandles([d((()=>({view:this.view,tooltipEnabled:this._tooltipEnabled})),(({view:e,tooltipEnabled:t})=>{this.tooltip.view=e,this.tooltip.enabled=t}),u),d((()=>this._forcePreviewDependencies),(()=>{o(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=s((async e=>{await a(E,e),l(e),this._forcePreview=!1})))}),u),d((()=>({renderer:this.renderer,parameters:this._visualizationParameters})),(e=>G(e.renderer,e.parameters)),u),d((()=>({renderer:this.renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext})),(e=>G(e.renderer,{lightDirections:e.lightDirections,lightDirectionsContext:e.lightDirectionsContext})),u),d((()=>({renderer:this.renderer,parameters:{enabled:this._running}})),(e=>G(e.renderer,e.parameters)),u),d((()=>({renderer:this.renderer,parameters:{previewing:this._previewing}})),(e=>G(e.renderer,e.parameters)),u)])}destroy(){this.stop(),G(this.renderer,{enabled:!1}),n(this.tooltip)}get state(){return null!=this.view&&this.view.ready&&null!=this._referencePosition?P.Ready:P.Disabled}set date(e){const t=new Date(e);t.setHours(0,0,0,0),this._set("date",t)}get utcOffset(){return this._utcOffset??this._utcOffsetAuto}set utcOffset(e){this._utcOffset=e}get testData(){}get _previewing(){const{view:e}=this;return null==e?.allLayerViews||(this._forcePreview||!e.stationary||e.allLayerViews.some((e=>N(e)&&e.updating)))}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?v(e[0],!1):0}get _dateUTCOffset(){let e=this.date;return e=m(e,-e.getTimezoneOffset(),"minutes"),e=m(e,-this.utcOffset,"hours"),e}get _startDateTimeUTC(){return m(this._dateUTCOffset,this.startTimeOfDay)}get _endDateTimeUTC(){return m(this._dateUTCOffset,this.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _durationInterval(){return this._duration>0?Math.floor(this._duration/S):S}get _interval(){const e=this._durationInterval;switch(this.visualizationType){case b.Threshold:case b.Duration:return e;case b.Discrete:return this.discreteOptions.interval||e}}get _intervalContext(){const{discreteEnabled:e,discreteOptions:{interval:t}}=this.thresholdOptions;return this.visualizationType===b.Threshold&&e?t||this._durationInterval:-1}get _durationSampleCount(){return this._lightDirections.length}get _duration(){return this.endTimeOfDay-this.startTimeOfDay}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(e){const{view:t}=this;if(null==t||e<=0)return U;const i="global"===t.viewingMode?V:this._referencePosition;if(null==i)return U;const r=y(this._startDateTimeUTC,this._endDateTimeUTC,e,i,t.state.viewingMode),s=r.length;x.length=0;const o=j(0,s,x),n=new Array(s);for(let a=0;a<s;++a)n[a]=r[o[a]];return n}get _tooltipEnabled(){return this.state===P.Ready&&this.visualizationType!==b.Discrete&&this._running&&!this._previewing}get _visualizationParameters(){if(!this._running)return null;switch(this.visualizationType){case b.Threshold:return this._thresholdVisualizationParameters;case b.Duration:return this._durationVisualizationParameters;case b.Discrete:return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{value:e,color:i}=this.thresholdOptions,r=this._duration;return{visualization:w.Threshold,thresholdColor:t.toUnitRGBA(i),threshold:r>0?e/this._duration:0,...this._thresholdDiscreteVisualizationParameters}}get _thresholdDiscreteVisualizationParameters(){const{discreteOptions:{color:e},discreteEnabled:i}=this.thresholdOptions;return i?{visualization:w.ThresholdAndGradient,gradientColor:t.toUnitRGBA(e)}:{}}get _durationVisualizationParameters(){const{color:e,mode:i}=this.durationOptions,r=this._duration,s=r>0&&i===T.Hourly?A/r:0,o=t.toUnitRGBA(e);return 0===s?{...this._discreteVisualizationParameters,gradientColor:o}:{bandedGradientColor:o,visualization:w.BandedGradient,bandSize:s}}get _discreteVisualizationParameters(){return{gradientColor:t.toUnitRGBA(this.discreteOptions.color),visualization:w.Gradient}}get _forcePreviewDependencies(){const{view:e}=this;if(null==e)return null;const t=e.slicePlane,i=e.allLayerViews.toArray().filter(N),s=i.map((e=>e.layer)).filter(r),o=i.map((e=>e.visible)),n=s.map((e=>e.visible)),a=s.map((e=>e.opacity)),l=s.filter((e=>"definitionExpression"in e)).map((e=>e.definitionExpression)),d=i.filter((e=>"filter"in e)).map((e=>e.filter));return{slicePlane:t,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewVisibilities:o,layerVisibilities:n,layerOpacities:a,filters:d,definitionExpressions:l}}get renderer(){const{view:e}=this;if(null==e)return null;const t=e.stage;return null==t?null:t.renderer}start(){this.setRunning(!0)}stop(){this.setRunning(!1)}setRunning(e){this._running=e}async getDuration(e,t){const{view:i,renderer:r,_durationSampleCount:s}=this;if(null==i||null==r||0===s)return 0;const o=i.state.camera.screenToRender(c(e.x,e.y),p());return r.readAccumulatedShadow(o)*this._duration}};function G(e,t){null!=e&&null!=t&&e.setParameters({shadowCast:t})}function N(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":return!0;case"base-dynamic-3d":case"catalog-3d":case"catalog-footprint-3d":case"catalog-dynamic-group-3d":case"dimension-3d":case"imagery-3d":case"imagery-tile-3d":case"line-of-sight-3d":case"map-image-3d":case"point-cloud-3d":case"tile-3d":case"vector-tile-3d":case"viewshed-3d":case"voxel-3d":case"wfs-3d":case"wmts-3d":case"media-3d":default:return!1;case"group":return e.layerViews.toArray().some((e=>N(e)))}}e([f()],R.prototype,"state",null),e([f()],R.prototype,"view",void 0),e([f()],R.prototype,"tooltip",void 0),e([f({type:Date,nonNullable:!0})],R.prototype,"date",null),e([f({nonNullable:!0})],R.prototype,"utcOffset",null),e([f({nonNullable:!0})],R.prototype,"startTimeOfDay",void 0),e([f({nonNullable:!0})],R.prototype,"endTimeOfDay",void 0),e([f({nonNullable:!0})],R.prototype,"visualizationType",void 0),e([f({type:z,nonNullable:!0})],R.prototype,"thresholdOptions",void 0),e([f({type:O,nonNullable:!0})],R.prototype,"durationOptions",void 0),e([f({type:D,nonNullable:!0})],R.prototype,"discreteOptions",void 0),e([f()],R.prototype,"_running",void 0),e([f()],R.prototype,"_stopPreviewingTask",void 0),e([f()],R.prototype,"_forcePreview",void 0),e([f()],R.prototype,"_autoRestoreForcePreviewEnabled",void 0),e([f()],R.prototype,"_previewing",null),e([f()],R.prototype,"_utcOffset",void 0),e([f()],R.prototype,"_utcOffsetAuto",null),e([f()],R.prototype,"_dateUTCOffset",null),e([f()],R.prototype,"_startDateTimeUTC",null),e([f()],R.prototype,"_endDateTimeUTC",null),e([f()],R.prototype,"_referencePosition",null),e([f()],R.prototype,"_interval",null),e([f()],R.prototype,"_intervalContext",null),e([f()],R.prototype,"_durationSampleCount",null),e([f()],R.prototype,"_duration",null),e([f()],R.prototype,"_lightDirections",null),e([f()],R.prototype,"_lightDirectionsContext",null),e([f()],R.prototype,"_tooltipEnabled",null),e([f()],R.prototype,"_visualizationParameters",null),e([f()],R.prototype,"_thresholdVisualizationParameters",null),e([f()],R.prototype,"_thresholdDiscreteVisualizationParameters",null),e([f()],R.prototype,"_durationVisualizationParameters",null),e([f()],R.prototype,"_discreteVisualizationParameters",null),e([f()],R.prototype,"_forcePreviewDependencies",null),e([f()],R.prototype,"renderer",null),R=e([_("esri.widgets.ShadowCast.ShadowCastViewModel")],R);const L=R;export{L as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as o}from"../../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as o}from"../../chunks/tslib.es6.js";import s from"../../Color.js";import r from"../../core/Accessor.js";import{convertTime as t}from"../../core/timeUtils.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import p from"./DiscreteOptions.js";let c=class extends r{constructor(){super(...arguments),this.color=new s([255,0,0,.7]),this.value=t(4,"hours","milliseconds"),this.minValue=0,this.maxValue=t(8,"hours","milliseconds"),this.discreteEnabled=!1,this.discreteOptions=new p}};o([e({type:s})],c.prototype,"color",void 0),o([e()],c.prototype,"value",void 0),o([e()],c.prototype,"minValue",void 0),o([e()],c.prototype,"maxValue",void 0),o([e()],c.prototype,"discreteEnabled",void 0),o([e()],c.prototype,"discreteOptions",void 0),c=o([i("esri.widgets.ShadowCast.ThresholdOptions")],c);const m=c;export{m as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import o from"../../core/Error.js";import i from"../../core/Evented.js";import{drainHandles as a}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{destroyMaybe as r,abortMaybe as n}from"../../core/maybe.js";import{createAbortError as p,whenOrAbort as l,ignoreAbortErrors as h}from"../../core/promiseUtils.js";import{on as c,watch as d,when as u,whenOnce as y,syncAndInitial as m}from"../../core/reactiveUtils.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as _}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as b,load as w,project as G,isLoaded as O}from"../../geometry/projection.js";import{geometryToCoordinates as T}from"../../geometry/support/coordsUtils.js";import{equals as E}from"../../geometry/support/spatialReferenceUtils.js";import S from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as k}from"../../layers/support/layerUtils.js";import M from"../../symbols/FillSymbol3DLayer.js";import A from"../../symbols/MeshSymbol3D.js";import C from"../../symbols/SimpleFillSymbol.js";import H from"../../symbols/SimpleLineSymbol.js";import D from"../../symbols/SimpleMarkerSymbol.js";import{symbolTypes as R}from"../../symbols/support/typeUtils.js";import{SupportedObjectResult as j,isSupportedObjectResultMessage as I}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as U}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as P}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as x}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as L}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import{sketchKeys as V}from"../../views/interactive/keybindings.js";import K from"../../views/interactive/sketch/SketchLabelOptions.js";import W from"../../views/interactive/sketch/SketchOptions.js";import Z from"../../views/interactive/sketch/SketchTooltipOptions.js";import q from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as z}from"../../views/interactive/snapping/SnappingManager.js";import N from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as B}from"../../views/interactive/snapping/snappingUtils.js";import{findFirstGraphicHit as $}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as Y}from"../../views/support/screenUtils.js";import{CreateOperationHandle as J,UpdateOperationHandle as Q}from"./support/OperationHandle.js";import{getModeFromCreateOptions as X,getDrawToolGeometryTypeFromCreateTool as ee}from"./support/sketchUtils.js";const te={defaultZ:0},oe={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0},tool:"transform"};let ie=class extends i.EventedAccessor{constructor(e){super(e),this._defaultSnappingManager=null,this._updatingHandles=new f,this._internalGraphicsLayer=new S({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new D({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new C({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new H({color:[130,130,130,1],width:2}),this.meshSymbol=new A({symbolLayers:new t([new M])}),this.updateGraphics=new t,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new D({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new W,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._originalPopupEnabled=null,this.defaultCreateOptions=te,this.defaultUpdateOptions=oe,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new N}initialize(){this.addHandles([c((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),c((()=>this.layer?.graphics),"change",(e=>{if(null!=this._operationHandle)for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),d((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),m),d((()=>this.view),(e=>{this._defaultSnappingManager=r(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new z({view:e,options:this.snappingOptions})),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),m),d((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))]),B(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=r(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this.emit("destroy")}get updating(){return this._updatingHandles.updating||null!=this.snappingManager&&this.snappingManager.updating}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){return"create"===this._operationHandle?.type&&this._operationHandle.activeComponent&&"mode"in this._operationHandle.activeComponent?this._operationHandle.activeComponent.mode: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",{...te,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...oe,...e,reshapeOptions:{...oe.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...oe.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=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=r(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new z({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 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&&(t.cursor=null),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(u((()=>e.ready),(t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)}),m),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=n(this._moduleLoaderAbortController),this._viewReadyAbortController=n(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map((e=>e.clone())).toArray();return this.layer.addMany(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(),p();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");L(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 s=()=>{if(a===this._operationHandle){const o=this.createGraphic,s=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map&&this.view.map.remove(this._internalGraphicsLayer),a.cancelled||null==o||i.add(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:s?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"}),s||this._sketchContinuationFlag)return;const{creationMode:r}=this;if("continuous"===r){if(t?.geometryToPlace)return;this._updatingHandles.addPromise(h(this.create(e,t)))}else"update"===r&&o&&this._updatingHandles.addPromise(h(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return 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(),p();null!=i.activeTool&&(i.activeTool=null);const s=Array.isArray(e)?e:[e];if(null==e||!s?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(s.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const r=await this._updatingHandles.addPromise(this._setupUpdateOperation(s,t));this.destroyed||null==r||ue(r)||(L(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(r,t),this.emit("update",{graphics:s,state:"start",aborted:!1,tool:r.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||E(o.geometry.spatialReference,t.spatialReference)||(b(o.geometry.spatialReference,t.spatialReference)||O()||await w(),o.geometry=G(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 $(i.results)}const o=[t.map.ground];t.map.allLayers.forEach((e=>{k(e.type)&&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.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))}),F.WIDGET)]}async _handleImmediateClick(e){const t=await e.async((()=>this._getFirstHit(Y(e))));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||i.layer===this.layer?(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=await this._setupDrawGraphicTool(e,o,i);return null==a?null:(o.tools.add(a),o.activeTool=a,this._setupCreateOperationHandle(a))}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:s,geometryToPlace:r,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=X(p,e),c=ee(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,y={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:r,geometryType:c,mode:h,graphicSymbol:this._getGraphicSymbolFromTool(e),hasZ:s,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(y):this._makeDrawGraphicTool3D(y)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return ue(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:re(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(t)||this.destroyed)return null;const{elevationInfo:o}=this.layer;return new t.module.DrawGraphicTool3D({...e,elevationInfo:o,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e){const t=this.view;if(!t)return this._logMissingView(),null;let o=null;const i=e.forceUniformSize,s=e.centered,r=[t.on("key-down",(t=>{if(t.key===V.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===V.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==V.vertexAdd||t.repeat)t.key===V.undo?(t.stopPropagation(),n.undo()):t.key===V.redo?(t.stopPropagation(),n.redo()):t.key!==V.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===V.center&&(t.repeat||(e.centered=!s,t.stopPropagation())):(e.forceUniformSize=!i,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),F.WIDGET),t.on("key-up",(t=>{t.key===V.pan?e.enabled=!0:t.key!==V.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===V.center&&(e.centered=s,t.stopPropagation()):(e.forceUniformSize=i,t.stopPropagation())}),F.WIDGET),e.on("vertex-add",(t=>{switch(o=null==o?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:o,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),o="complete",e.aborted?n&&n.cancel():n&&n.complete()})),d((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],n=new J({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{a(r),t.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return 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}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this;if(!i)return this._logMissingView(),null;const a={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let s=a.tool??oe.tool;for(const r of e)o.remove(r),o.add(r);if("3d"===i.type){if(0===e.length)return null;switch(s){case"move":return this._setupMove3DOperation(e,a,i,s);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],a,i);case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(s){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,s,a,i);case"transform":if(1===e.length){const t=e[0].geometry?.type;"point"!==t&&"multipoint"!==t||(s="reshape")}return this._setupTransformOrReshape2DOperation(e,s,a,i)}}async _setupMove3DOperation(e,t,o,i,s=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach((e=>e.destroy())),l.clear()};for(const a of e){const e=new n({view:o,graphic:a}),t=U(e);if(t!==j.SUPPORTED)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${I(t)}).`),null;l.set(a,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())),s||this.updateGraphics.addMany(e);const d=[],u=new Q({activeComponent:c,tool:i,type:"update",onEnd:()=>{a(d),de(o,c),h()},undo:()=>{he(this.view,c),ne(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{pe(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._setupReshape3DOperation(e,t,o,!0);a&&!ue(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)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)}),F.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&x(e[0])===j.SUPPORTED){const a=e[0],s=a.geometry;if(null!=s&&("point"===s.type||"mesh"===s.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=s&&("polygon"===s.type||"polyline"===s.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:s,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(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:s,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],y=new Q({activeComponent:d,tool:i,type:"update",onEnd:()=>{a(u),de(o,d),c.destroy()},undo:()=>{he(this.view,d),ne(y,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{pe(y,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);ue(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),F.WIDGET)),y}async _setupPolyTransform3DOperation(e,t,o,i=!1){const s="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(V.constraint),y=new c({view:o,graphic:e}),m=new d({object:y,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const g=[],v=new Q({activeComponent:m,tool:s,type:"update",onEnd:()=>{a(g),de(o,m),y.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},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._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);ue(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._setupReshape3DOperation(e,t,o,!0);i&&!ue(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(v,e,t)),F.WIDGET),o.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(v,e)),F.WIDGET),o.on("key-down",(e=>{e.key!==V.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),F.WIDGET),o.on("key-up",(e=>{e.key===V.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),F.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const s=await this._getGraphicMover(e,t,o);if(ue(s))return s;const r=new Q({activeComponent:s,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),a(l),a(p),s.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();ne(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();pe(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),s.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?s.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,t)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==V.constraint||e.repeat||(n=!0,s.enableMoveAllGraphics=!s.enableMoveAllGraphics)}),F.WIDGET),o.on("key-up",(e=>{e.key===V.constraint&&n&&(n=!1,s.enableMoveAllGraphics=!s.enableMoveAllGraphics)}),F.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const s="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=P(l);if(h!==j.SUPPORTED)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${I(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=[],y=new Q({activeComponent:d,tool:s,type:"update",onEnd:()=>{a(u),de(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);ue(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;y.onEnd(),y.destroy();const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);ue(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),F.WIDGET)),y}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const s="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(ue(s))return s;const r=new Q({activeComponent:s,type:"update",onEnd:()=>{a(p),a(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{ne(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{pe(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._setupTransformOrReshape2DOperation(t,"transform",o,i);if(ue(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:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach((e=>e.updates.splice(t,1))),r.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();if(0===o.length)r.complete();else{const e=o[0].geometry;1!==o.length||null==e||"point"!==e.type&&"multipoint"!==e.type?r.activeComponent.graphics=o:r.toggleTool()}this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===r.tool&&"extent"===t.type))return;let s=null;"transform"===r.tool?s=await this._getReshape([e],o,i):"reshape"===r.tool&&(s=await this._getBox([e],o,i)),ue(s)||(r.activeComponent?.destroy(),r.activeComponent=s,r.activeComponent&&(a(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,o)),F.WIDGET),i.on("key-down",(e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===V.constraint&&!e.repeat&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),F.WIDGET),i.on("key-up",(e=>{if(e.key===V.constraint&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),F.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,s=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return ue(s)?s:new s.module.default({enableMoveAllGraphics:i,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayPointerCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:s,preserveAspectRatio:r}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(ue(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(V.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightsEnabled:!!s?.enabled,preserveAspectRatio:!!r!=!!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 i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,s=!!t.highlightOptions?.enabled,r=await this._requireModule(import("../../views/draw/support/Reshape.js"));return ue(r)?r:new r.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],highlightsEnabled:s,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=>T(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=>T(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:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ce(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ce(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ce(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ce(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ce([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ce([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ce([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ce([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&&i.layer===this.layer?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=Y(t),a=await t.async((()=>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||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===V.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===V.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===V.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&V.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();null!=t&&("reshape"!==t.type||1===o.length&&"point"===o[0].geometry?.type)&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=r(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))}_displayPointerCursor(){this.view?.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view?.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view?.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,i){s.getLogger(this).error(new o(e,t,i))}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"})}get test(){}wait(){return y((()=>!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?(n(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await l(y((()=>e?.ready)),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",se("view"))}_logMissingLayer(){this._logError(ae,se("layer"))}};e([g()],ie.prototype,"_defaultSnappingManager",void 0),e([g()],ie.prototype,"updating",null),e([g({readOnly:!0})],ie.prototype,"_updatingHandles",void 0),e([g()],ie.prototype,"_operationHandle",void 0),e([g({readOnly:!0})],ie.prototype,"activeTool",null),e([g({readOnly:!0})],ie.prototype,"activeCreateToolDrawMode",null),e([g()],ie.prototype,"activeTooltip",null),e([g({types:R})],ie.prototype,"activeFillSymbol",void 0),e([g()],ie.prototype,"activeLineSymbol",void 0),e([g()],ie.prototype,"activeVertexSymbol",void 0),e([g()],ie.prototype,"allowDeleteKey",void 0),e([g({readOnly:!0})],ie.prototype,"createGraphic",null),e([g()],ie.prototype,"defaultCreateOptions",null),e([g()],ie.prototype,"defaultUpdateOptions",null),e([g({type:K,nonNullable:!0})],ie.prototype,"labelOptions",null),e([g()],ie.prototype,"layer",void 0),e([g({types:R})],ie.prototype,"pointSymbol",void 0),e([g({types:R})],ie.prototype,"polygonSymbol",void 0),e([g({types:R})],ie.prototype,"polylineSymbol",void 0),e([g()],ie.prototype,"meshSymbol",void 0),e([g({type:N,nonNullable:!0})],ie.prototype,"snappingOptions",null),e([g()],ie.prototype,"snappingManager",null),e([g({readOnly:!0})],ie.prototype,"state",null),e([g({type:Z,nonNullable:!0})],ie.prototype,"tooltipOptions",null),e([g({readOnly:!0})],ie.prototype,"updateGraphics",void 0),e([g()],ie.prototype,"updateOnGraphicClick",void 0),e([g()],ie.prototype,"creationMode",void 0),e([g({type:q,nonNullable:!0})],ie.prototype,"valueOptions",null),e([g({types:R})],ie.prototype,"vertexSymbol",void 0),e([g({value:null})],ie.prototype,"view",null),e([g({constructOnly:!0,type:W})],ie.prototype,"sketchOptions",void 0),ie=e([v("esri.widgets.Sketch.SketchViewModel")],ie);const ae="sketch:missing-property",se=e=>`Property '${e}' is missing on SketchViewModel.`;function re(e){return"polygon"===e||"rectangle"===e||"circle"===e}function ne(e,t){le("undo",e.history.undo,e.history.redo,t)}function pe(e,t){le("redo",e.history.redo,e.history.undo,t)}function le(e,t,o,i){const a=t.pop();if(!a)return;const s=a.updates,r=[];i.forEach(((t,o)=>{const i=s[o];null!=i&&("geometry"in i&&null!=i.geometry&&(r.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(r.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(r.push(i),i[e](t)))})),o.push({updates:r})}function he(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function ce(e){return{updates:e.map((({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e}))}}function de(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function ue(e){return"requireError"in e&&"aborted"===e.requireError}const ye=ie;export{ye as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import o from"../../core/Error.js";import i from"../../core/Evented.js";import{drainHandles as a}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{destroyMaybe as r,abortMaybe as n}from"../../core/maybe.js";import{createAbortError as p,whenOrAbort as l,ignoreAbortErrors as h}from"../../core/promiseUtils.js";import{on as c,watch as d,when as u,whenOnce as y,syncAndInitial as m}from"../../core/reactiveUtils.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as _}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as b,load as w,project as G,isLoaded as O}from"../../geometry/projection.js";import{geometryToCoordinates as T}from"../../geometry/support/coordsUtils.js";import{equals as E}from"../../geometry/support/spatialReferenceUtils.js";import S from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as k}from"../../layers/support/layerUtils.js";import M from"../../symbols/FillSymbol3DLayer.js";import A from"../../symbols/MeshSymbol3D.js";import C from"../../symbols/SimpleFillSymbol.js";import H from"../../symbols/SimpleLineSymbol.js";import D from"../../symbols/SimpleMarkerSymbol.js";import{symbolTypes as R}from"../../symbols/support/typeUtils.js";import{SupportedObjectResult as j,isSupportedObjectResultMessage as I}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as U}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as P}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as x}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as L}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import{sketchKeys as V}from"../../views/interactive/keybindings.js";import K from"../../views/interactive/sketch/SketchLabelOptions.js";import W from"../../views/interactive/sketch/SketchOptions.js";import Z from"../../views/interactive/sketch/SketchTooltipOptions.js";import q from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as z}from"../../views/interactive/snapping/SnappingManager.js";import N from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as B}from"../../views/interactive/snapping/snappingUtils.js";import{findFirstGraphicHit as $}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as Y}from"../../views/support/screenUtils.js";import{CreateOperationHandle as J,UpdateOperationHandle as Q}from"./support/OperationHandle.js";import{getModeFromCreateOptions as X,getDrawToolGeometryTypeFromCreateTool as ee}from"./support/sketchUtils.js";const te={defaultZ:0},oe={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0},tool:"transform"};let ie=class extends i.EventedAccessor{constructor(e){super(e),this._defaultSnappingManager=null,this._updatingHandles=new f,this._internalGraphicsLayer=new S({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new D({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new C({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new H({color:[130,130,130,1],width:2}),this.meshSymbol=new A({symbolLayers:new t([new M])}),this.updateGraphics=new t,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new D({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new W,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._originalPopupEnabled=null,this.defaultCreateOptions=te,this.defaultUpdateOptions=oe,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new N}initialize(){this.addHandles([c((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),c((()=>this.layer?.graphics),"change",(e=>{if(null!=this._operationHandle)for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),d((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),m),d((()=>this.view),(e=>{this._defaultSnappingManager=r(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new z({view:e,options:this.snappingOptions})),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),m),d((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))]),B(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=r(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this.emit("destroy")}get updating(){return this._updatingHandles.updating||null!=this.snappingManager&&this.snappingManager.updating}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){return"create"===this._operationHandle?.type&&this._operationHandle.activeComponent&&"mode"in this._operationHandle.activeComponent?this._operationHandle.activeComponent.mode: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",{...te,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...oe,...e,reshapeOptions:{...oe.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...oe.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=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=r(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new z({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 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&&(t.cursor=null),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(u((()=>e.ready),(t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)}),m),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=n(this._moduleLoaderAbortController),this._viewReadyAbortController=n(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map((e=>e.clone())).toArray();return this.layer.addMany(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(),p();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");L(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 s=()=>{if(a===this._operationHandle){const o=this.createGraphic,s=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map&&this.view.map.remove(this._internalGraphicsLayer),a.cancelled||null==o||i.add(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:s?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"}),s||this._sketchContinuationFlag)return;const{creationMode:r}=this;if("continuous"===r){if(t?.geometryToPlace)return;this._updatingHandles.addPromise(h(this.create(e,t)))}else"update"===r&&o&&this._updatingHandles.addPromise(h(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return 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(),p();null!=i.activeTool&&(i.activeTool=null);const s=Array.isArray(e)?e:[e];if(null==e||!s?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(s.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const r=await this._updatingHandles.addPromise(this._setupUpdateOperation(s,t));this.destroyed||null==r||ue(r)||(L(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(r,t),this.emit("update",{graphics:s,state:"start",aborted:!1,tool:r.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||E(o.geometry.spatialReference,t.spatialReference)||(b(o.geometry.spatialReference,t.spatialReference)||O()||await w(),o.geometry=G(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 $(i.results)}const o=[t.map.ground];t.map.allLayers.forEach((e=>{k(e.type)&&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.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))}),F.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer((()=>this._getFirstHit(Y(e))));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||i.layer===this.layer?(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=await this._setupDrawGraphicTool(e,o,i);return null==a?null:(o.tools.add(a),o.activeTool=a,this._setupCreateOperationHandle(a))}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:s,geometryToPlace:r,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=X(p,e),c=ee(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,y={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:r,geometryType:c,mode:h,graphicSymbol:this._getGraphicSymbolFromTool(e),hasZ:s,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(y):this._makeDrawGraphicTool3D(y)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return ue(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:re(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(t)||this.destroyed)return null;const{elevationInfo:o}=this.layer;return new t.module.DrawGraphicTool3D({...e,elevationInfo:o,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e){const t=this.view;if(!t)return this._logMissingView(),null;let o=null;const i=e.forceUniformSize,s=e.centered,r=[t.on("key-down",(t=>{if(t.key===V.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===V.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==V.vertexAdd||t.repeat)t.key===V.undo?(t.stopPropagation(),n.undo()):t.key===V.redo?(t.stopPropagation(),n.redo()):t.key!==V.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===V.center&&(t.repeat||(e.centered=!s,t.stopPropagation())):(e.forceUniformSize=!i,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),F.WIDGET),t.on("key-up",(t=>{t.key===V.pan?e.enabled=!0:t.key!==V.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===V.center&&(e.centered=s,t.stopPropagation()):(e.forceUniformSize=i,t.stopPropagation())}),F.WIDGET),e.on("vertex-add",(t=>{switch(o=null==o?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:o,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),o="complete",e.aborted?n&&n.cancel():n&&n.complete()})),d((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],n=new J({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{a(r),t.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return 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}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this;if(!i)return this._logMissingView(),null;const a={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let s=a.tool??oe.tool;for(const r of e)o.remove(r),o.add(r);if("3d"===i.type){if(0===e.length)return null;switch(s){case"move":return this._setupMove3DOperation(e,a,i,s);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],a,i);case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(s){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,s,a,i);case"transform":if(1===e.length){const t=e[0].geometry?.type;"point"!==t&&"multipoint"!==t||(s="reshape")}return this._setupTransformOrReshape2DOperation(e,s,a,i)}}async _setupMove3DOperation(e,t,o,i,s=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach((e=>e.destroy())),l.clear()};for(const a of e){const e=new n({view:o,graphic:a}),t=U(e);if(t!==j.SUPPORTED)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${I(t)}).`),null;l.set(a,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())),s||this.updateGraphics.addMany(e);const d=[],u=new Q({activeComponent:c,tool:i,type:"update",onEnd:()=>{a(d),de(o,c),h()},undo:()=>{he(this.view,c),ne(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{pe(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._setupReshape3DOperation(e,t,o,!0);a&&!ue(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)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)}),F.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&x(e[0])===j.SUPPORTED){const a=e[0],s=a.geometry;if(null!=s&&("point"===s.type||"mesh"===s.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=s&&("polygon"===s.type||"polyline"===s.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:s,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(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:s,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],y=new Q({activeComponent:d,tool:i,type:"update",onEnd:()=>{a(u),de(o,d),c.destroy()},undo:()=>{he(this.view,d),ne(y,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{pe(y,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);ue(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),F.WIDGET)),y}async _setupPolyTransform3DOperation(e,t,o,i=!1){const s="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(V.constraint),y=new c({view:o,graphic:e}),m=new d({object:y,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const g=[],v=new Q({activeComponent:m,tool:s,type:"update",onEnd:()=>{a(g),de(o,m),y.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},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._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);ue(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._setupReshape3DOperation(e,t,o,!0);i&&!ue(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(v,e,t)),F.WIDGET),o.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(v,e)),F.WIDGET),o.on("key-down",(e=>{e.key!==V.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),F.WIDGET),o.on("key-up",(e=>{e.key===V.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())}),F.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const s=await this._getGraphicMover(e,t,o);if(ue(s))return s;const r=new Q({activeComponent:s,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),a(l),a(p),s.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();ne(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();pe(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),s.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?s.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,t)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==V.constraint||e.repeat||(n=!0,s.enableMoveAllGraphics=!s.enableMoveAllGraphics)}),F.WIDGET),o.on("key-up",(e=>{e.key===V.constraint&&n&&(n=!1,s.enableMoveAllGraphics=!s.enableMoveAllGraphics)}),F.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const s="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(ue(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=P(l);if(h!==j.SUPPORTED)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${I(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=[],y=new Q({activeComponent:d,tool:s,type:"update",onEnd:()=>{a(u),de(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:s}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);ue(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;y.onEnd(),y.destroy();const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);ue(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(y,e,t)),F.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)}),F.WIDGET)),y}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const s="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(ue(s))return s;const r=new Q({activeComponent:s,type:"update",onEnd:()=>{a(p),a(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{ne(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{pe(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._setupTransformOrReshape2DOperation(t,"transform",o,i);if(ue(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:async e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach((e=>e.updates.splice(t,1))),r.history.redo.forEach((e=>e.updates.splice(t,1))),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();if(0===o.length)r.complete();else{const e=o[0].geometry;1!==o.length||null==e||"point"!==e.type&&"multipoint"!==e.type?r.activeComponent.graphics=o:r.toggleTool()}this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===r.tool&&"extent"===t.type))return;let s=null;"transform"===r.tool?s=await this._getReshape([e],o,i):"reshape"===r.tool&&(s=await this._getBox([e],o,i)),ue(s)||(r.activeComponent?.destroy(),r.activeComponent=s,r.activeComponent&&(a(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,o)),F.WIDGET),i.on("key-down",(e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===V.constraint&&!e.repeat&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),F.WIDGET),i.on("key-up",(e=>{if(e.key===V.constraint&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),F.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,s=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return ue(s)?s:new s.module.default({enableMoveAllGraphics:i,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayPointerCursor(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:s,preserveAspectRatio:r}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(ue(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(V.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightsEnabled:!!s?.enabled,preserveAspectRatio:!!r!=!!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 i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,s=!!t.highlightOptions?.enabled,r=await this._requireModule(import("../../views/draw/support/Reshape.js"));return ue(r)?r:new r.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],highlightsEnabled:s,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=>T(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=>T(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:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ce(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ce(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ce(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ce(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ce([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ce([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ce([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ce([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&&i.layer===this.layer?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=Y(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||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===V.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===V.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===V.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&V.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();null!=t&&("reshape"!==t.type||1===o.length&&"point"===o[0].geometry?.type)&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=r(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))}_displayPointerCursor(){this.view?.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view?.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view?.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,i){s.getLogger(this).error(new o(e,t,i))}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"})}get test(){}wait(){return y((()=>!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?(n(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await l(y((()=>e?.ready)),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",se("view"))}_logMissingLayer(){this._logError(ae,se("layer"))}};e([g()],ie.prototype,"_defaultSnappingManager",void 0),e([g()],ie.prototype,"updating",null),e([g({readOnly:!0})],ie.prototype,"_updatingHandles",void 0),e([g()],ie.prototype,"_operationHandle",void 0),e([g({readOnly:!0})],ie.prototype,"activeTool",null),e([g({readOnly:!0})],ie.prototype,"activeCreateToolDrawMode",null),e([g()],ie.prototype,"activeTooltip",null),e([g({types:R})],ie.prototype,"activeFillSymbol",void 0),e([g()],ie.prototype,"activeLineSymbol",void 0),e([g()],ie.prototype,"activeVertexSymbol",void 0),e([g()],ie.prototype,"allowDeleteKey",void 0),e([g({readOnly:!0})],ie.prototype,"createGraphic",null),e([g()],ie.prototype,"defaultCreateOptions",null),e([g()],ie.prototype,"defaultUpdateOptions",null),e([g({type:K,nonNullable:!0})],ie.prototype,"labelOptions",null),e([g()],ie.prototype,"layer",void 0),e([g({types:R})],ie.prototype,"pointSymbol",void 0),e([g({types:R})],ie.prototype,"polygonSymbol",void 0),e([g({types:R})],ie.prototype,"polylineSymbol",void 0),e([g()],ie.prototype,"meshSymbol",void 0),e([g({type:N,nonNullable:!0})],ie.prototype,"snappingOptions",null),e([g()],ie.prototype,"snappingManager",null),e([g({readOnly:!0})],ie.prototype,"state",null),e([g({type:Z,nonNullable:!0})],ie.prototype,"tooltipOptions",null),e([g({readOnly:!0})],ie.prototype,"updateGraphics",void 0),e([g()],ie.prototype,"updateOnGraphicClick",void 0),e([g()],ie.prototype,"creationMode",void 0),e([g({type:q,nonNullable:!0})],ie.prototype,"valueOptions",null),e([g({types:R})],ie.prototype,"vertexSymbol",void 0),e([g({value:null})],ie.prototype,"view",null),e([g({constructOnly:!0,type:W})],ie.prototype,"sketchOptions",void 0),ie=e([v("esri.widgets.Sketch.SketchViewModel")],ie);const ae="sketch:missing-property",se=e=>`Property '${e}' is missing on SketchViewModel.`;function re(e){return"polygon"===e||"rectangle"===e||"circle"===e}function ne(e,t){le("undo",e.history.undo,e.history.redo,t)}function pe(e,t){le("redo",e.history.redo,e.history.undo,t)}function le(e,t,o,i){const a=t.pop();if(!a)return;const s=a.updates,r=[];i.forEach(((t,o)=>{const i=s[o];null!=i&&("geometry"in i&&null!=i.geometry&&(r.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(r.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(r.push(i),i[e](t)))})),o.push({updates:r})}function he(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function ce(e){return{updates:e.map((({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e}))}}function de(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function ue(e){return"requireError"in e&&"aborted"===e.requireError}const ye=ie;export{ye as default};
|
package/widgets/VideoPlayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{deprecateWidget as i}from"../core/deprecate.js";import{clone as t}from"../core/lang.js";import o from"../core/Logger.js";import{watch as s,initial as r}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as d}from"../intl/date.js";import l from"../views/VideoView.js";import c from"./Slider.js";import m from"./Widget.js";import{loadCalciteComponents as p}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as h}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";import{css as w}from"./VideoPlayer/css.js";import g from"./VideoPlayer/VideoPlayerViewModel.js";import{loadMetadataSectionComponents as f,MetadataSection as y}from"./VideoPlayer/components/MetadataSection.js";import{loadPlayerActionsGroupComponents as V,PlayerActionsGroup as b}from"./VideoPlayer/components/PlayerActionsGroup.js";import{loadPlayerControlsGroupComponents as M,PlayerControlsGroup as j}from"./VideoPlayer/components/PlayerControlsGroup.js";import{defaultSettings as _}from"./VideoPlayer/components/SettingsButton.js";let P=class extends m{constructor(e,s){super(e,s),this._settings=t(_),this._metadataVisible=!1,this._slider=new c({visibleElements:{labels:!1,rangeLabels:!1},min:0,max:100,values:[0],thumbsConstrained:!1}),this.videoView=new l({container:document.createElement("div"),constraints:{rotationEnabled:!1},ui:{components:["zoom"]}}),this.viewModel=new g,i(o.getLogger(this),"Video Player","arcgis-video-player",{version:"4.33"})}initialize(){this.addHandles([s((()=>this.viewModel.layer),(()=>{this.videoView.layer=this.viewModel.layer}),r),this._slider.on(["thumb-change","thumb-drag"],(({value:e})=>{const i=e*this.viewModel.duration/100;this.viewModel.seekTo(i)}))])}loadDependencies(){return Promise.all([V(),M(),f(),p({progress:()=>import("@esri/calcite-components/dist/components/calcite-progress"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim")})])}get effect(){return this.videoView.effect}set effect(e){this.videoView.effect=e}get icon(){return"video-web"}set icon(e){this._overrideIfSome("icon",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get rotationEnabled(){return this.videoView.constraints.rotationEnabled}set rotationEnabled(e){this.videoView.constraints.rotationEnabled=e,this.videoView.ui.components=e?[...this.videoView.ui.components,"compass"]:this.videoView.ui.components.filter((e=>"compass"!==e))}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get zoomEnabled(){return this.videoView.navigation.mouseWheelZoomEnabled}set zoomEnabled(e){this.videoView.navigation.mouseWheelZoomEnabled=e,this.videoView.ui.components=e?[...this.videoView.ui.components,"zoom"]:this.videoView.ui.components.filter((e=>"zoom"!==e))}render(){return v("div",{class:this.classes(w.base,u.widget)},v("calcite-panel",{heading:this.layer?.title||"Video Player"},this._renderLoadingScrim(),this._renderBuffering(),this._renderVideoSection(),this._renderActionBar(),this._renderMetadataSection()))}_renderLoadingScrim(){const{state:e}=this.viewModel;return this.videoView.ready?null:v("calcite-scrim",{loading:"error"!==e},"error"===e?this.messages.errorLoadingLayer:null)}_renderBuffering(){const{currentTime:e,buffered:i,duration:t}=this.viewModel,o=i/(t||1),s=e/(t||1);return this.viewModel.ended||o>s?null:v("calcite-progress",{type:"indeterminate"})}_renderVideoSection(){const{buffered:e,currentTime:i,duration:t}=this.viewModel,o=this.videoView.container;if(!o)return null;o.className=w.videoView;const s=e/(t||1),r=i/(t||1);return this._slider.values=[100*r],v("section",{afterCreate:S,bind:o},v("div",{class:w.sliderProgressContainer},v("progress",{class:w.progress,max:"1",value:`${s}`}),v("div",{class:w.slider},this._slider.render())))}_renderActionBar(){return v("div",{class:w.playerToolbar},v(b,{messages:this.messages,viewModel:this.viewModel}),v("div",{class:w.playerTimecode},E(this.viewModel.currentTime)," / ",E(this.viewModel.duration)),v(j,{messages:this.messages,settings:this._settings,toggleMetadata:()=>this._metadataVisible=!this._metadataVisible,viewModel:this.viewModel}))}_renderMetadataSection(){return this._metadataVisible?v(y,{messages:this.messages,viewModel:this.viewModel}):null}};function E(e){return d(1e3*Math.round(e),{minute:"2-digit",second:"2-digit"})}function S(e){const i=this;e.prepend(i)}e([n()],P.prototype,"_settings",void 0),e([n()],P.prototype,"effect",null),e([n()],P.prototype,"icon",null),e([n()],P.prototype,"layer",null),e([n(),h("esri/widgets/VideoPlayer/t9n/VideoPlayer")],P.prototype,"messages",void 0),e([n()],P.prototype,"rotationEnabled",null),e([n()],P.prototype,"videoView",void 0),e([n({type:g})],P.prototype,"viewModel",void 0),e([n()],P.prototype,"view",null),e([n()],P.prototype,"zoomEnabled",null),P=e([a("esri.widgets.VideoPlayer")],P);const z=P;export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Logger.js";import{abortMaybe as n,removeMaybe as r}from"../../core/maybe.js";import{throwIfAborted as a,isAbortError as o,isAborted as l}from"../../core/promiseUtils.js";import{watch as c,syncAndInitial as h,sync as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Logger.js";import{abortMaybe as n,removeMaybe as r}from"../../core/maybe.js";import{throwIfAborted as a,isAbortError as o,isAborted as l}from"../../core/promiseUtils.js";import{watch as c,syncAndInitial as h,sync as p,whenOnce as w,when as y}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";var v;!function(e){e[e.PENDING=0]="PENDING",e[e.WAIT_FOR_VIEW_READY=1]="WAIT_FOR_VIEW_READY",e[e.RUNNING=2]="RUNNING"}(v||(v={}));let _=class extends t{constructor(e={}){super(e),this.view=null,this.analysisView=null,this._reconnectViewTask=null,this._forceInteractiveHandle=null,this._parentChangeFromReconnect=!1,this._startUserOperation=null;const t=e?.analysis;null!=t?this.analysis=t:(this._set("analysis",this.constructAnalysis()),this._set("isAnalysisOwner",!0)),null!=e?.visible&&(this.visible=e.visible)}normalizeCtorArgs(e){const{analysis:t,...s}=e;return s}initialize(){this.addHandles([c((()=>({readyAndNotSupported:null!=this.view&&this.view.ready&&!this.supported})),(({readyAndNotSupported:e})=>{e&&i.getLogger(this).errorOnce(this.unsupportedErrorMessage)}),h),c((()=>this.analysis?.parent),(e=>{this._parentChangeFromReconnect||e===this.view||this._set("isAnalysisOwner",!1);const t=!this._parentChangeFromReconnect;this._parentChangeFromReconnect=!1,t&&this._scheduleViewReconnect()}),p),c((()=>({view:this.view,ready:null!=this.view&&this.view.ready,supported:this.supported})),(({view:e},t)=>{const s=t?.view;e!==s&&(this._startUserOperation=n(this._startUserOperation),this._disconnectFromView(s)),this._scheduleViewReconnect()}),h)])}destroy(){this._reconnectViewTask=n(this._reconnectViewTask),this._startUserOperation=n(this._startUserOperation),null!=this.analysisView&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),this._set("view",null),null!=this.analysis&&this.isAnalysisOwner&&(this.analysis.destroy(),this._set("analysis",null))}get supported(){return null==this.view||this.view.type===this.supportedViewType}set visible(e){this._set("visible",e),null!=this.analysisView&&(this.analysisView.visible=e)}get active(){return null!=this.tool&&this.tool.active}get disabled(){return null==this.view||!this.view.ready||!this.supported}set analysis(e){e!==this._get("analysis")&&(this._startUserOperation=n(this._startUserOperation),this._disconnectFromView(this.view),this._setExternalAnalysis(e),this._scheduleViewReconnect())}get ready(){return null!=this.analysisView&&!this.connectingToView}get connectingToView(){return null!=this._reconnectViewTask}get isAnalysisOwner(){return this._get("isAnalysisOwner")}get tool(){return this.analysisView?.tool}clear(){this._startUserOperation=n(this._startUserOperation),this._resetInteractiveCreationState(),null!=this.tool&&null!=this.view&&this.view.activeTool===this.tool&&(this.view.activeTool=null)}async start(){if(!this.visible)return void i.getLogger(this).warn("Cannot start analysis when not visible");this.clear();const e={task:null,abort:null,state:v.PENDING},t=s((async t=>{if(e.state=v.WAIT_FOR_VIEW_READY,await w((()=>this.ready),t),e.state=v.RUNNING,null==this.analysisView||null==this.view)return;const s=this.analysisView.tool;null!=s&&(this.view.activeTool=s,y((()=>s.created),(()=>{s.active&&null!=this.view&&(this.view.activeTool=null)}),{initial:!0,once:!0}))}));return e.task=t,e.abort=()=>t.abort(),this._startUserOperation=e,t.promise}onConnectToAnalysisView(e){}onDisconnectFromAnalysisView(){}_scheduleViewReconnect(){this._reconnectViewTask=n(this._reconnectViewTask);const e=s((async t=>{try{await this._reconnectView(t)}catch(s){if(a(t),!o(s))return void i.getLogger(this).warn("Failed to use analysis in view model",s);throw s}finally{e===this._reconnectViewTask&&(this._reconnectViewTask=null)}}));this._reconnectViewTask=e}async _reconnectView(e){const{view:t}=this,s=null!=t&&t.ready&&this.supported,n=this.analysis;if(this._startUserOperation=V(this._startUserOperation),this._disconnectFromView(t),s&&null!=t&&null!=n){if(this.isAnalysisOwner){if(null!=n.parent)return void i.getLogger(this).errorOnce("expected owned analysis to have null parent when connecting to view");this._parentChangeFromReconnect=!0,t.analyses.add(n)}this.analysisView=await t.whenAnalysisView(n),l(e)?this._startUserOperation=V(this._startUserOperation):(this.analysisView.visible=this.visible,this._forceInteractiveHandle=this.analysisView.forceInteractiveForViewModel(),this.addHandles(this._forceInteractiveHandle),this.onConnectToAnalysisView(this.analysisView))}}_disconnectFromView(e){null!=e&&this.isAnalysisOwner&&e.analyses.includes(this.analysis)&&(this._parentChangeFromReconnect=!0,this.analysis.clear(),e.analyses.remove(this.analysis)),this.onDisconnectFromAnalysisView(),this._forceInteractiveHandle=r(this._forceInteractiveHandle),this.analysisView=null}_setExternalAnalysis(e){null==this.analysisView||this.isAnalysisOwner||(this.analysisView.visible=void 0,this._forceInteractiveHandle=r(this._forceInteractiveHandle)),this.analysisView=null,this._set("isAnalysisOwner",!1),this._set("analysis",e),this._parentChangeFromReconnect=!1}_resetInteractiveCreationState(){this.analysis.clear(),this.tool?.resetCreated()}get testInfo(){}};function V(e){return null!=e&&e.state>=v.RUNNING?(e.abort(),null):e}e([u()],_.prototype,"supported",null),e([u()],_.prototype,"view",void 0),e([u({type:Boolean,value:!0})],_.prototype,"visible",null),e([u()],_.prototype,"active",null),e([u()],_.prototype,"disabled",null),e([u({nonNullable:!0})],_.prototype,"analysis",null),e([u()],_.prototype,"analysisView",void 0),e([u()],_.prototype,"ready",null),e([u()],_.prototype,"connectingToView",null),e([u({readOnly:!0})],_.prototype,"isAnalysisOwner",null),e([u()],_.prototype,"_reconnectViewTask",void 0),e([u()],_.prototype,"_forceInteractiveHandle",void 0),e([u()],_.prototype,"tool",null),_=e([d("esri.widgets.support.AnalysisViewModel")],_);export{_ as AnalysisViewModel};
|