@arcgis/core 4.28.0-rc.2 → 4.28.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/functions/featuresetbase.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{0e354096ad8817971eed.js → 02d235849ba93541d7ad.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0422c5160491fbcf01dc.js +1 -0
  6. package/assets/esri/core/workers/chunks/1da721608993783dc9cf.js +1 -0
  7. package/assets/esri/core/workers/chunks/224e79f6c172da444e0a.js +1 -0
  8. package/assets/esri/core/workers/chunks/{ca3d5803cdf035d7389d.js → 30776102fbab294bfe7b.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{61dec8399919b278b636.js → 3ac9001b19a90faf5573.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{fa6103e3d4e857b0035b.js → 3dcb2a82e1e4b520c9c9.js} +11 -8
  11. package/assets/esri/core/workers/chunks/41081c921037e543a22f.js +1 -0
  12. package/assets/esri/core/workers/chunks/4564a7885d045a850887.js +1 -0
  13. package/assets/esri/core/workers/chunks/4adf3a8c6b49c381a633.js +1 -0
  14. package/assets/esri/core/workers/chunks/{2721aa6b6941b28b9758.js → 63c8bf00120a4e67f5b0.js} +1 -1
  15. package/assets/esri/core/workers/chunks/6bc1f6f8a2408fa4bb6a.js +1 -0
  16. package/assets/esri/core/workers/chunks/74951370a341f02d3714.js +1 -0
  17. package/assets/esri/core/workers/chunks/78e49a70193e5adea17c.js +1 -0
  18. package/assets/esri/core/workers/chunks/7b8377b3a9f78f9d3613.js +1 -0
  19. package/assets/esri/core/workers/chunks/{fd28400141a6751327ae.js → 7cf7f2b991a7cbdad2ce.js} +1 -1
  20. package/assets/esri/core/workers/chunks/830d99e6c58a52a58973.js +1 -0
  21. package/assets/esri/core/workers/chunks/{1a723bb4a341f645e5fe.js → 83b8141f0c80e3448012.js} +1 -1
  22. package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +1 -0
  23. package/assets/esri/core/workers/chunks/934c32c49bb9e21482fd.js +1 -0
  24. package/assets/esri/core/workers/chunks/{a4341ec0fe89b865d849.js → a160576f21ada91995ac.js} +1 -1
  25. package/assets/esri/core/workers/chunks/a1e16c33f1843dbdce26.js +1 -0
  26. package/assets/esri/core/workers/chunks/{d07235ce2765a25b9be4.js → a50ec5b647a160199cb2.js} +1 -1
  27. package/assets/esri/core/workers/chunks/b6bd31674076e543d8b2.js +1 -0
  28. package/assets/esri/core/workers/chunks/{77923afde29ae1ff10ca.js → b6e86e179f99b5cf8dff.js} +1 -1
  29. package/assets/esri/core/workers/chunks/c3ddf5dbc34f118002df.js +1 -0
  30. package/assets/esri/core/workers/chunks/{562eafa5090827ebb7ec.js → c87e9280681c20d042b5.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{7b3d5f044c96e2c2af11.js → d191267d91a53db42956.js} +1 -1
  32. package/assets/esri/core/workers/chunks/ffa330a19a09679212fb.js +1 -0
  33. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +9 -13
  34. package/assets/esri/themes/base/widgets/_Features.scss +5 -0
  35. package/assets/esri/themes/base/widgets/_Legend.scss +1 -1
  36. package/assets/esri/themes/base/widgets/_Popup.scss +0 -1
  37. package/assets/esri/themes/base/widgets/_TimeZoneLabel.scss +3 -3
  38. package/assets/esri/themes/dark/main.css +1 -1
  39. package/assets/esri/themes/light/main.css +1 -1
  40. package/assets/esri/themes/light/view.css +1 -1
  41. package/geometry/support/meshUtils/georeference.js +1 -1
  42. package/interfaces.d.ts +1506 -314
  43. package/intl/date.js +1 -1
  44. package/kernel.js +1 -1
  45. package/layers/FeatureLayer.js +1 -1
  46. package/layers/GroupLayer.js +1 -1
  47. package/layers/OrientedImageryLayer.js +1 -1
  48. package/layers/SceneLayer.js +1 -1
  49. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  50. package/layers/graphics/data/QueryEngineResult.js +1 -1
  51. package/layers/graphics/data/queryValidationUtils.js +1 -1
  52. package/layers/mixins/ArcGISMapService.js +1 -1
  53. package/layers/save/groupLayerUtils.js +1 -1
  54. package/layers/save/utils.js +1 -1
  55. package/layers/support/ImageElement.js +1 -1
  56. package/layers/support/LayerContingentValuesCache.js +1 -1
  57. package/layers/support/Sublayer.js +1 -1
  58. package/layers/support/Subtype.d.ts +4 -0
  59. package/layers/support/Subtype.js +1 -1
  60. package/layers/support/imageryRendererUtils.js +1 -1
  61. package/networks/Network.js +1 -1
  62. package/package.json +1 -1
  63. package/portal/support/jsonContext.js +1 -1
  64. package/portal/support/layersLoader.js +1 -1
  65. package/rest/featureService/FeatureService.d.ts +4 -0
  66. package/rest/featureService/FeatureService.js +1 -1
  67. package/rest/featureService/utils.d.ts +4 -0
  68. package/rest/query/operations/query.js +1 -1
  69. package/smartMapping/support/utils.js +1 -1
  70. package/statistics/utils.js +1 -1
  71. package/support/basemapUtils.js +1 -1
  72. package/support/revision.js +1 -1
  73. package/versionManagement/VersionManagementService.d.ts +4 -0
  74. package/versionManagement/VersionManagementService.js +1 -1
  75. package/views/2d/engine/Container.js +1 -1
  76. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  77. package/views/2d/engine/webgl/Overlay.js +1 -1
  78. package/views/2d/input/handlers/KeyPan.js +1 -1
  79. package/views/2d/interactive/editingTools/manipulations/DragManipulation.js +1 -1
  80. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  81. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  82. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  83. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  84. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  85. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  86. package/views/3d/layers/I3SMeshView3D.js +1 -1
  87. package/views/3d/layers/MediaLayerView3D.js +1 -1
  88. package/views/3d/layers/SceneLayerWorker.js +1 -1
  89. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  90. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  91. package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
  92. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  93. package/views/3d/support/MemoryController.js +1 -1
  94. package/views/3d/support/PBFDecoder.js +1 -1
  95. package/views/3d/support/ResourceController.js +1 -1
  96. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  97. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  98. package/views/3d/webgl-engine/core/FBOPool.js +5 -0
  99. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -6
  100. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
  101. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  102. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  103. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  104. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  105. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  106. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  107. package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
  108. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  109. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  110. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  111. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +1 -1
  112. package/views/draw/DrawOperation.js +1 -1
  113. package/views/draw/support/Reshape.js +1 -1
  114. package/views/interactive/sketch/constraints.js +1 -1
  115. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  116. package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
  117. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  118. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  119. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  120. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  121. package/views/interactive/snapping/featureSources/queryEngineUtils.js +1 -1
  122. package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
  123. package/webdoc/support/writeUtils.js +1 -1
  124. package/widgets/BasemapGallery.js +1 -1
  125. package/widgets/DirectionalPad.js +1 -1
  126. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  127. package/widgets/Editor/EditorViewModel.js +1 -1
  128. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  129. package/widgets/Editor/UpdateWorkflow.js +1 -1
  130. package/widgets/Editor/VisibleElements.js +1 -1
  131. package/widgets/Editor/workflowUtils.js +1 -1
  132. package/widgets/Editor.js +1 -1
  133. package/widgets/FeatureForm/FieldInput.js +1 -1
  134. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  135. package/widgets/FeatureForm.js +1 -1
  136. package/widgets/Features.js +1 -1
  137. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.d.ts +4 -0
  138. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  139. package/widgets/OrientedImageryViewer.js +1 -1
  140. package/widgets/TimeSlider.js +1 -1
  141. package/widgets/TimeZoneLabel.js +1 -1
  142. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  143. package/widgets/UtilityNetworkTrace.js +1 -1
  144. package/widgets/support/dateUtils.js +1 -1
  145. package/assets/esri/core/workers/chunks/00da3c16741a9bc47f3a.js +0 -1
  146. package/assets/esri/core/workers/chunks/0e4646d14fa0775bf463.js +0 -1
  147. package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +0 -1
  148. package/assets/esri/core/workers/chunks/51b8913dff24e693bd25.js +0 -1
  149. package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +0 -1
  150. package/assets/esri/core/workers/chunks/7388fd97e7b1a2142744.js +0 -1
  151. package/assets/esri/core/workers/chunks/7648f3341b7dff2825c3.js +0 -1
  152. package/assets/esri/core/workers/chunks/92d8f75e616afa5c761e.js +0 -1
  153. package/assets/esri/core/workers/chunks/9c77d69a13ec22cdd760.js +0 -1
  154. package/assets/esri/core/workers/chunks/a821fa1870b83fed5d31.js +0 -1
  155. package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +0 -1
  156. package/assets/esri/core/workers/chunks/b251d8a856dc8b9406e0.js +0 -1
  157. package/assets/esri/core/workers/chunks/c416df0668f6c596095f.js +0 -1
  158. package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +0 -1
  159. package/assets/esri/core/workers/chunks/f0d342303fc20e266d27.js +0 -1
  160. package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +0 -1
  161. package/assets/esri/core/workers/chunks/fc95b1a36ed68b851400.js +0 -1
  162. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -4
  163. package/widgets/DirectionalPad.d.ts +0 -4
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as r,equalsMaybe as o}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as f}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as x,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import C from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as D}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";const H="crosshair",j="progress";let k=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new C,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,r="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=f(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(r,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>o(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),r=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=r&&null!=this.lastVertex&&u(this.lastVertex,r)||(this.lastVertex=r)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:e})=>{l.cursor=e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get effectiveCursor(){return this.loading?j:this._hideDefaultCursor?null:this.cursor||H}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(!e||!t)return e;const r=T(e,n,i),o=r?t.closestTo(r):void 0;return o?b(o,e.spatialReference):e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return x(e,((e,t,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:o,cancelSnapping:s}=P({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new D({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||r&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...o).next((e=>(r&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation,n=this._manipulator;n.dragging||this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&!e.dragging&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const r=this._screenToMap(e),o=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==r)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const a=this.snappingManager;if(null==a)return this.stagedVertex=r,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:r,scenePoint:o},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&G(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new D({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function G(e,t,i){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=i}e([l()],k.prototype,"_hideDefaultCursor",void 0),e([l()],k.prototype,"_snappingOperation",void 0),e([l()],k.prototype,"_snappingEnabled",null),e([l({constructOnly:!0})],k.prototype,"graphic",void 0),e([l()],k.prototype,"constraint",void 0),e([l()],k.prototype,"defaultZ",void 0),e([l()],k.prototype,"isDraped",void 0),e([l({value:y})],k.prototype,"drawingMode",null),e([l({constructOnly:!0})],k.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],k.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:C})],k.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],k.prototype,"geometryType",void 0),e([l({constructOnly:!0})],k.prototype,"hasM",void 0),e([l({constructOnly:!0})],k.prototype,"hasZ",void 0),e([l()],k.prototype,"cursor",void 0),e([l()],k.prototype,"effectiveCursor",null),e([l()],k.prototype,"loading",void 0),e([l({constructOnly:!0})],k.prototype,"manipulators",void 0),e([l({constructOnly:!0})],k.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],k.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],k.prototype,"snappingVisualizer",void 0),e([l()],k.prototype,"snapToSceneEnabled",void 0),e([l()],k.prototype,"stagedVertex",null),e([l()],k.prototype,"lastVertex",void 0),e([l()],k.prototype,"updating",null),e([l({constructOnly:!0})],k.prototype,"view",void 0),k=e([d("esri.views.draw.DrawOperation")],k);export{k as DrawOperation,H as defaultCursor,j as defaultLoadingCursor};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as f}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as x,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import P from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as C}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";const H="crosshair",j="progress";let k=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new P,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,o="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=f(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(o,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>r(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),o=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=o&&null!=this.lastVertex&&u(this.lastVertex,o)||(this.lastVertex=o)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:e})=>{l.cursor=e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get effectiveCursor(){return this.loading?j:this._hideDefaultCursor?null:this.cursor||H}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(!e||!t)return e;const o=T(e,n,i),r=o?t.closestTo(o):void 0;return r?b(r,e.spatialReference):e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return x(e,((e,t,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=D({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new C({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||o&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...r).next((e=>(o&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType,this._stagedPointerId=e.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const o=this._screenToMap(e),r=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==o)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const a=this.snappingManager;if(null==a)return this.stagedVertex=o,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:o,scenePoint:r},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&G(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new C({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function G(e,t,i){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o<=i}e([l()],k.prototype,"_hideDefaultCursor",void 0),e([l()],k.prototype,"_snappingOperation",void 0),e([l()],k.prototype,"_snappingEnabled",null),e([l({constructOnly:!0})],k.prototype,"graphic",void 0),e([l()],k.prototype,"constraint",void 0),e([l()],k.prototype,"defaultZ",void 0),e([l()],k.prototype,"isDraped",void 0),e([l({value:y})],k.prototype,"drawingMode",null),e([l({constructOnly:!0})],k.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],k.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:P})],k.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],k.prototype,"geometryType",void 0),e([l({constructOnly:!0})],k.prototype,"hasM",void 0),e([l({constructOnly:!0})],k.prototype,"hasZ",void 0),e([l()],k.prototype,"cursor",void 0),e([l()],k.prototype,"effectiveCursor",null),e([l()],k.prototype,"loading",void 0),e([l({constructOnly:!0})],k.prototype,"manipulators",void 0),e([l({constructOnly:!0})],k.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],k.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],k.prototype,"snappingVisualizer",void 0),e([l()],k.prototype,"snapToSceneEnabled",void 0),e([l()],k.prototype,"stagedVertex",null),e([l()],k.prototype,"lastVertex",void 0),e([l()],k.prototype,"updating",null),e([l({constructOnly:!0})],k.prototype,"view",void 0),k=e([d("esri.views.draw.DrawOperation")],k);export{k as DrawOperation,H as defaultCursor,j as defaultLoadingCursor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as h}from"../../../core/maybe.js";import{zeroMeters as p}from"../../../core/quantityUtils.js";import{when as c,pausable as l,watch as d,syncAndInitial as m,initial as v}from"../../../core/reactiveUtils.js";import{createScreenPoint as y}from"../../../core/screenUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as u,geometryToCoordinates as f,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as M}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as w}from"./drawUtils.js";import S from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as I}from"./settings.js";import{ViewEventPriorities as T}from"../../input/InputManager.js";import{sketchKeys as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import j from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as H}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as U,TranslateVertexTooltipInfo as A}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as F}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as L,autoLength2D as D}from"../../support/automaticLengthMeasurementUtils.js";import z from"../../../geometry/Polyline.js";import P from"../../../geometry/Point.js";class q{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class Q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class W{constructor(e){this.added=e,this.type="vertex-select"}}class X{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Y{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Z{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const $=I.reshapeGraphics,ee={vertices:{default:new b({style:"circle",size:$.vertex.size,color:$.vertex.color,outline:{color:$.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:$.vertex.hoverSize,color:$.vertex.hoverColor,outline:{color:$.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:$.selected.size,color:$.selected.color,outline:{color:$.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}})}};let te=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._translateGraphicTooltipInfo=null,this._translateVertexTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.symbols=ee,this.tooltipOptions=new j,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this.addHandles([c((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),T.TOOL))}),{once:!0,initial:!0}),l((()=>this.graphic),(()=>this.refresh())),l((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),l((()=>this.enableMidpoints),(()=>this.refresh())),d((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new H({view:this.view}):a(this._tooltip)}),m),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),v)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=a(this._tooltip)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new z({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new M(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=h(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=f(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,p]=e;r.push(new t({geometry:new P({x:h,y:p,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[p,c]=a,l=e[h+1]?h+1:0;if("polygon"===this.graphic.geometry?.type||0!==l){const[a,d]=e[l],[m,v]=x([p,c],[a,d]);r.push(new t({geometry:new P({x:m,y:v,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:l}}))}}))})),r}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new S({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n]=e[s][o];i.geometry=new P({x:r,y:n,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n]=e[i][s],[a,h]=e[i][o],[p,c]=x([r,n],[a,h]);t.geometry=new P({x:p,y:c,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){h(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,p="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!p){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r(),this._snappingTask=i((async i=>{const h=await o.snap({point:a,context:n,signal:i});h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r())}))}else{const i=null!=this._stagedVertex?new P(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,p),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a}=t,[h,p]=this._getIndicesForVertexGraphic(e);let c=f(r);const l=c[h].length-1;c[h][p]=[n,a],"polygon"===r.type&&(0===p?c[h][l]=[n,a]:p===l&&(c[h][0]=[n,a])),this._isVertex(e)&&(c=this._moveRelatedCoordinates(c,e,n,a),c=this._moveSelectedHandleCoordinates(c,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(c)),this.graphic.geometry=r.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:o}=t.attributes;for(const r of o){const o=this.vertexGraphics.at(r),{pathIndex:n,pointIndex:a}=o.attributes;e[n][a]=[i,s],o.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=e[t].length-1;e[t][n]=[h.x,h.y],r.geometry=h,o&&(0===n?e[t][p]=[h.x,h.y]:n===p&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,{x:p,y:c}=e.geometry,l=0===h?a+1:h,d=f(o);return d[n].splice(l,0,[p,c]),e.attributes={...t,pathIndex:n,pointIndex:l,relatedGraphicIndices:[]},r.push({coordinates:d[n][l],componentIndex:n,vertexIndex:l}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=f(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&i===h&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=this._translateGraphicTooltipInfo??=new U({tooltipOptions:i});if(o.clear(),o.tooltipOptions=i,e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(y(t,i)),a=L(n,r);o.distance=null!=a?a:p}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=this._translateVertexTooltipInfo??=new A({tooltipOptions:s});if(r.clear(),r.tooltipOptions=s,"polygon"===i?.type?r.area=F(i):"polyline"===i?.type&&(r.totalLength=D(i)),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(y(t,i)),a=L(n,s);r.distance=null!=a?a:p}t.info=r}_emitMoveStartEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new J(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new Q(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new q(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new N(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new W(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new X(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new Y(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new Z(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([_()],te.prototype,"_tooltip",void 0),e([_()],te.prototype,"_translateGraphicTooltipInfo",void 0),e([_()],te.prototype,"_translateVertexTooltipInfo",void 0),e([_()],te.prototype,"callbacks",void 0),e([_()],te.prototype,"enableMidpoints",void 0),e([_()],te.prototype,"enableMovement",void 0),e([_()],te.prototype,"enableVertices",void 0),e([_()],te.prototype,"graphic",void 0),e([_({value:!0})],te.prototype,"highlightsEnabled",null),e([_()],te.prototype,"layer",void 0),e([_({readOnly:!0})],te.prototype,"midpointGraphics",void 0),e([_()],te.prototype,"midpointSymbol",void 0),e([_({readOnly:!0})],te.prototype,"selectedVertices",void 0),e([_()],te.prototype,"snappingManager",void 0),e([_({readOnly:!0})],te.prototype,"state",null),e([_()],te.prototype,"symbols",void 0),e([_({type:j})],te.prototype,"tooltipOptions",void 0),e([_({readOnly:!0})],te.prototype,"type",void 0),e([_({readOnly:!0})],te.prototype,"vertexGraphics",void 0),e([_()],te.prototype,"view",void 0),te=e([g("esri.views.draw.support.Reshape")],te);const ie=te;export{ie as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as h}from"../../../core/maybe.js";import{zeroMeters as p}from"../../../core/quantityUtils.js";import{when as c,pausable as l,watch as d,syncAndInitial as m,initial as v}from"../../../core/reactiveUtils.js";import{createScreenPoint as y}from"../../../core/screenUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as u,geometryToCoordinates as f,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as M}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as w}from"./drawUtils.js";import S from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as I}from"./settings.js";import{ViewEventPriorities as T}from"../../input/InputManager.js";import{sketchKeys as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import j from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as H}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as U,TranslateVertexTooltipInfo as A}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as z}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as F,autoLength2D as L}from"../../support/automaticLengthMeasurementUtils.js";import D from"../../../geometry/Polyline.js";import P from"../../../geometry/Point.js";class q{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class Q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class W{constructor(e){this.added=e,this.type="vertex-select"}}class X{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Y{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Z{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const $=I.reshapeGraphics,ee={vertices:{default:new b({style:"circle",size:$.vertex.size,color:$.vertex.color,outline:{color:$.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:$.vertex.hoverSize,color:$.vertex.hoverColor,outline:{color:$.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:$.selected.size,color:$.selected.color,outline:{color:$.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}})}};let te=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._translateGraphicTooltipInfo=null,this._translateVertexTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.symbols=ee,this.tooltipOptions=new j,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this.addHandles([c((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),T.TOOL))}),{once:!0,initial:!0}),l((()=>this.graphic),(()=>this.refresh())),l((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),l((()=>this.enableMidpoints),(()=>this.refresh())),d((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new H({view:this.view}):a(this._tooltip)}),m),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),v)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=a(this._tooltip)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new D({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new M(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=h(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=f(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,p,c]=e;r.push(new t({geometry:new P({x:h,y:p,z:c,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[p,c,l]=a,d=e[h+1]?h+1:0;if("polygon"===this.graphic.geometry?.type||0!==d){const[a,m,v]=e[d],[y,_,g]=x([p,c,l],[a,m,v]);r.push(new t({geometry:new P({x:y,y:_,z:g,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:d}}))}}))})),r}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new S({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n,a]=e[s][o];i.geometry=new P({x:r,y:n,z:a,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n,a]=e[i][s],[h,p,c]=e[i][o],[l,d,m]=x([r,n,a],[h,p,c]);t.geometry=new P({x:l,y:d,z:m,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){h(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,p="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!p){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r(),this._snappingTask=i((async i=>{const h=await o.snap({point:a,context:n,signal:i});h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r())}))}else{const i=null!=this._stagedVertex?new P(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,p),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a,z:h}=t,[p,c]=this._getIndicesForVertexGraphic(e);let l=f(r);const d=l[p].length-1,m=null!=h?[n,a,h]:[n,a];l[p][c]=m,"polygon"===r.type&&(0===c?l[p][d]=m:c===d&&(l[p][0]=m)),this._isVertex(e)&&(l=this._moveRelatedCoordinates(l,e,m),l=this._moveSelectedHandleCoordinates(l,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(l)),this.graphic.geometry=r.clone();const v=this._getVertexFromEditGeometry(e),y=n-v.pos[0],_=a-v.pos[1];this._editGeometryOperations.moveVertices([v],y,_,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=e[t].length-1;e[t][n]=[h.x,h.y],r.geometry=h,o&&(0===n?e[t][p]=[h.x,h.y]:n===p&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,{x:p,y:c,z:l}=e.geometry,d=0===h?a+1:h,m=f(o);return m[n].splice(d,0,null!=l?[p,c,l]:[p,c]),e.attributes={...t,pathIndex:n,pointIndex:d,relatedGraphicIndices:[]},r.push({coordinates:m[n][d],componentIndex:n,vertexIndex:d}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=f(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&i===h&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=this._translateGraphicTooltipInfo??=new U({tooltipOptions:i});if(o.clear(),o.tooltipOptions=i,e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(y(t,i)),a=F(n,r);o.distance=null!=a?a:p}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=this._translateVertexTooltipInfo??=new A({tooltipOptions:s});if(r.clear(),r.tooltipOptions=s,"polygon"===i?.type?r.area=z(i):"polyline"===i?.type&&(r.totalLength=L(i)),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(y(t,i)),a=F(n,s);r.distance=null!=a?a:p}t.info=r}_emitMoveStartEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new J(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new Q(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new q(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new N(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new W(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new X(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new Y(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new Z(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([_()],te.prototype,"_tooltip",void 0),e([_()],te.prototype,"_translateGraphicTooltipInfo",void 0),e([_()],te.prototype,"_translateVertexTooltipInfo",void 0),e([_()],te.prototype,"callbacks",void 0),e([_()],te.prototype,"enableMidpoints",void 0),e([_()],te.prototype,"enableMovement",void 0),e([_()],te.prototype,"enableVertices",void 0),e([_()],te.prototype,"graphic",void 0),e([_({value:!0})],te.prototype,"highlightsEnabled",null),e([_()],te.prototype,"layer",void 0),e([_({readOnly:!0})],te.prototype,"midpointGraphics",void 0),e([_()],te.prototype,"midpointSymbol",void 0),e([_({readOnly:!0})],te.prototype,"selectedVertices",void 0),e([_()],te.prototype,"snappingManager",void 0),e([_({readOnly:!0})],te.prototype,"state",null),e([_()],te.prototype,"symbols",void 0),e([_({type:j})],te.prototype,"tooltipOptions",void 0),e([_({readOnly:!0})],te.prototype,"type",void 0),e([_({readOnly:!0})],te.prototype,"vertexGraphics",void 0),e([_()],te.prototype,"view",void 0),te=e([g("esri.views.draw.support.Reshape")],te);const ie=te;export{ie 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{g as n,c as r,k as s}from"../../../chunks/vec2.js";import{a as i}from"../../../chunks/vec2f64.js";import{j as o,c as u,g as c,q as a,h as f,a as l,u as h,m as d,s as p,f as m,G as L}from"../../../chunks/vec3.js";import{c as k,g,f as P,d as T}from"../../../chunks/vec3f64.js";import{create as y,intersectLine as q,distance as x,isVertical as v,intersectPlanes as z,signedDistance as j,projectPoint as w,fromPositionAndNormal as E,fromPoints as A,normal as M}from"../../../geometry/support/plane.js";import{create as N}from"../../../geometry/support/ray.js";import{k as Z,l as I,p as G,m as S}from"../../../chunks/sphere.js";import{fromVec3 as O,clone as U,fromValues as b}from"./normalizedPoint.js";import{vectorsHaveCloseZ as C,isClose as F,isPointInsidePlane as H,intersectLineLikeAndCircle as R,pointsInsidePlane as Y,intersectVerticalPlaneAndVerticalCylinder as _,projectPointToLineLike as B,projectPointToVerticalCylinder as D,projectPointToVerticalPlane as J,VerticalPlaneType as K,intersectLineLikes as Q,intersectVerticalPlaneAndLineLike as V,intersectLineLikeAndVerticalCylinder as W,intersectVerticalPlanes as X,intersectVerticalCylinders as $,intersectVerticalPlaneAndPoint as tt}from"../../support/geometry3dUtils.js";import{LineType as et}from"../../support/geometry2dUtils.js";class nt{intersect(t){return zt(this,t)}closestPoints(t){return[this.closestTo(t)]}}class rt extends nt{constructor(t){super(),this.point=t}equals(t){return this===t||$t(t)&&f(this.point,t.point)}closestTo(){return U(this.point)}}class st extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:n}}equals(t){return this===t||te(t)&&this.lineLike.type===t.lineLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){const e=B(t,this.lineLike);return O(e)}}class it extends st{constructor(t,e){super(t,e,et.LINE)}}class ot extends st{constructor(t,e){super(t,e,et.RAY)}}class ut extends nt{constructor(t){super(),this.constraints=t}equals(t){return this===t||Xt(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,n=1/0;for(const r of this.constraints){const s=r.closestTo(t),i=l(t,s);i<n&&(n=i,e=s)}return e?U(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class ct extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||re(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return O(e)}}class at extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||se(t)&&f(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return e[2]=this.center[2],O(e)}asCircle(){return new ft(U(this.center),this.radius,b(0,0,1))}}class ft extends nt{constructor(t,e,n,r=void 0){super(),this.center=t,this.radius=e,this.normal=n,this.slicePlane=r}equals(t){return this===t||ie(t)&&f(this.center,t.center)&&f(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:n}=this;w(this.getPlane(ht),t,lt);const r=h(lt,lt,e),s=d(r);if(F(s,0))return U(t);const i=n/Math.sqrt(s),o=a(k(),e,r,i),{slicePlane:u}=this;if(u&&!H(u,o)){const e=At(u,this);return e?.closestTo(t)??U(t)}return O(o)}getPlane(t=y()){return E(this.center,this.normal,t)}}const lt=k(),ht=y();class dt extends nt{constructor(t){super(),this.z=t}equals(t){return this===t||ee(t)&&this.z===t.z}closestTo(t){return O(P(t[0],t[1],this.z))}getPlane(t=y()){return p(pt,0,0,this.z),E(pt,T,t)}}const pt=k();class mt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.planeLike={start:t,end:e,type:n}}equals(t){return this===t||ne(t)&&this.planeLike.type===t.planeLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){return O(J(t,this.planeLike))}closestEndTo(t){const{start:e,end:s}=this;return Math.sign(n(r(Lt,s,e),r(kt,t,e)))>0?s:e}getPlane(t=y()){const e=u(gt,this.end);return e[2]+=1,A(this.start,this.end,e,t)}getSlicePlane(t=y()){const{start:e,end:n,type:r}=this.planeLike;if(r===K.PLANE)return;const s=p(gt,e[0],e[1],0),i=p(Pt,n[0],n[1],0),o=m(Pt,i,s);return E(s,o,t),t}}const Lt=i(),kt=i(),gt=k(),Pt=k();class Tt extends mt{constructor(t,e){super(t,e,K.HALF_PLANE)}}class yt extends mt{constructor(t,e){super(t,e,K.PLANE)}}class qt extends nt{constructor(t,e){super(),this.sphere=Z(t,e)}equals(t){return this===t||oe(t)&&I(this.sphere,t.sphere)}closestTo(t){const e=G(this.sphere,t,k());return O(e)}get center(){return this.sphere}get radius(){return this.sphere[3]}}class xt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.getZ=n,this.planeLike={start:t,end:e,type:K.PLANE}}equals(t){return this===t||ue(t)&&f(this.start,t.start)&&f(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return vt(this,t)}addIfOnTheGround(t,e){for(const n of e){const e=this.getZ(n[0],n[1],n[2])??0;F(n[2],e)&&(n[2]=e,t.push(n))}}}function vt(t,e){const n=J(e,t.planeLike);return n[2]=t.getZ(e[0],e[1],e[2])??ce,O(n)}function zt(t,e){if(Xt(t)){const n=[];for(const r of t.constraints){const t=r.intersect(e);t&&n.push(t)}return Wt(n)}if(Xt(e))return zt(e,t);if(ue(t))return Jt(t,e);if(ue(e))return Jt(e,t);if($t(t)){const{point:n}=t,r=e.closestTo(n);return L(r,n)?t:void 0}if(te(t)){if($t(e))return zt(e,t);if(te(e))return Qt(Q(t.lineLike,e.lineLike));if(ee(e))return jt(t,e);if(ne(e))return Qt(V(e.planeLike,t.lineLike));if(re(e))return Qt(W(t.lineLike,e.center,e.radius));if(ie(e))return Qt(R(t.lineLike,e));if(se(e))return wt(t,e);if(oe(e))return Et(t,e)}else if(ee(t)){if($t(e)||te(e))return zt(e,t);if(ee(e))return Mt(t,e);if(ne(e))return Nt(t,e);if(re(e))return Zt(t,e);if(ie(e))return Gt(t,e);if(se(e))return It(t,e);if(oe(e))return St(t,e)}else if(ne(t)){if($t(e)||te(e)||ee(e))return zt(e,t);if(ne(e))return Kt(X(t.planeLike,e.planeLike));if(re(e))return Kt(_(t.planeLike,e.center,e.radius));if(ie(e))return Ut(t,e);if(se(e))return Ot(t,e);if(oe(e))return bt(t,e)}else if(re(t)){if($t(e)||te(e)||ee(e)||ne(e))return zt(e,t);if(re(e))return Kt($(t.center,t.radius,e.center,e.radius));if(ie(e))return Ct();if(se(e))return Ft(t,e);if(oe(e))return Ht()}else if(ie(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e))return zt(e,t);if(ie(e))return Rt();if(se(e))return Rt(e.asCircle());if(oe(e))return Yt()}else if(se(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||ie(e))return zt(e,t);if(se(e))return _t(e,t);if(oe(e))return Bt()}else if(oe(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||se(e))return zt(e,t);if(oe(e))return Dt()}}const jt=(()=>{const t=y();return(e,n)=>{const{start:r,end:s}=e;if(C(r,s)&&F(r[2],n.z))return e;const i=k();return q(n.getPlane(t),r,s,i)?new rt(O(i)):void 0}})();function wt({lineLike:t},{center:e,radius:n}){const r=e[2];return Qt(W(t,e,n).filter((t=>F(t[2],r))))}function Et({lineLike:t},{sphere:e}){return Qt(S(e,t.start,t.end))}const At=(()=>{const t=N(),e=y(),n={start:k(),end:k(),type:et.LINE};return(r,s,i)=>{const{normal:a,center:f,radius:l}=s,h=o(a,M(r)),d=F(x(r,f),0);if(F(h,1))return d?s:void 0;if(s.getPlane(e),d&&F(h,0)&&v(r)&&v(e)){if(F(l,0))return!i||H(i,f)?new rt(U(f)):void 0;const t=g(f);t[2]+=l;const e=g(f);e[2]-=l;const n=[];return i&&!H(i,t)||n.push(t),i&&!H(i,e)||n.push(e),Qt(n)}if(!z(r,e,t))return;u(n.start,t.origin),c(n.end,t.origin,t.direction);const p=R(n,s);return Qt(i?Y(i,p):p)}})();function Mt(t,e){return F(t.z,e.z)?t:void 0}function Nt({z:t},{planeLike:e}){const[n,r]=e.start,[s,i]=e.end,o=b(n,r,t),u=b(s,i,t);return e.type===K.PLANE?new it(o,u):new ot(o,u)}function Zt(t,e){const[n,r]=e.center;return new at(b(n,r,t.z),e.radius)}function It(t,e){return F(e.center[2],t.z)?e:void 0}const Gt=(()=>{const t=y();return(e,n)=>At(e.getPlane(t),n)})();function St(t,{center:e,radius:n}){const r=Math.abs(e[2]-t.z);if(r>n&&!F(r,n))return;const s=b(e[0],e[1],t.z),i=Math.sqrt(n**2-r**2);return F(i,0)?void 0:new at(s,i)}const Ot=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=_(e.planeLike,n,r),i=n[2];e.getSlicePlane(t);const o=[];for(const[u,c]of s){const e=[u,c,i];H(t,e)&&o.push(e)}return Qt(o)}})(),Ut=(()=>{const t=y(),e=y();return(n,r)=>At(n.getPlane(t),r,n.getSlicePlane(e))})(),bt=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=e.getPlane(t),i=j(s,n),o=Math.abs(i);if(o>r&&!F(o,r))return;const u=g(M(s)),c=a(k(),n,u,i),f=Math.sqrt(r**2-i**2);return F(f,0)?new rt(O(w(s,n,k()))):new ft(O(c),f,u,e.getSlicePlane())}})();function Ct(t,e){}function Ft(t,e){const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return e;return Vt($(t.center,t.radius,e.center,e.radius),e.center[2])}function Ht(t,e){}function Rt(t,e){}function Yt(t,e){}function _t(t,e){if(!C(t.center,e.center))return;const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return t;return Vt($(t.center,t.radius,e.center,e.radius),t.center[2])}function Bt(t,e){}function Dt(t,e){}function Jt(t,e){const{planeLike:n,getZ:r}=t,s=[];if($t(e))t.addIfOnTheGround(s,tt(n,e.point));else if(te(e))t.addIfOnTheGround(s,V(n,e.lineLike));else if(re(e))for(const[i,o]of _(n,e.center,e.radius)){const t=r(i,o,0);null!=t&&s.push(P(i,o,t))}else if(ne(e)||ue(e))for(const[i,o]of X(n,e.planeLike)){const t=r(i,o,0)??ce;s.push(P(i,o,t))}return Qt(s)}function Kt(t){return Wt(t.map((([t,e])=>{const n=b(t,e,0),r=b(t,e,1);return new it(n,r)})))}function Qt(t){return Wt(t.map((t=>t?new rt(O(t)):void 0)))}function Vt(t,e){return Qt(t.map((([t,n])=>[t,n,e])))}function Wt(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new ut(e.filter(t))}function Xt(t){return t instanceof ut}function $t(t){return t instanceof rt}function te(t){return t instanceof st}function ee(t){return t instanceof dt}function ne(t){return t instanceof mt}function re(t){return t instanceof ct}function se(t){return t instanceof at}function ie(t){return t instanceof ft}function oe(t){return t instanceof qt}function ue(t){return t instanceof xt}const ce=0;export{ft as CircleConstraint,nt as Constraint,xt as DrapedLineConstraint,at as HorizontalCircleConstraint,dt as HorizontalPlaneConstraint,it as LineConstraint,st as LineLikeConstraint,rt as PointConstraint,ot as RayConstraint,ut as SetConstraint,qt as SphereConstraint,ct as VerticalCylinderConstraint,Tt as VerticalHalfPlaneConstraint,yt as VerticalPlaneConstraint,mt as VerticalPlaneLikeConstraint};
5
+ import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{g as n,c as r,k as s}from"../../../chunks/vec2.js";import{a as i}from"../../../chunks/vec2f64.js";import{j as o,c as u,g as c,q as a,h as f,a as l,u as h,m as d,s as p,f as m,G as L}from"../../../chunks/vec3.js";import{c as k,g,f as P,d as T}from"../../../chunks/vec3f64.js";import{create as y,intersectLine as q,distance as x,isVertical as v,intersectPlanes as z,signedDistance as j,projectPoint as w,fromPositionAndNormal as E,fromPoints as A,normal as M}from"../../../geometry/support/plane.js";import{create as N}from"../../../geometry/support/ray.js";import{k as Z,l as I,p as G,m as S}from"../../../chunks/sphere.js";import{fromVec3 as O,clone as U,fromValues as b}from"./normalizedPoint.js";import{vectorsHaveCloseZ as C,isClose as F,isPointInsidePlane as H,intersectLineLikeAndCircle as R,pointsInsidePlane as Y,intersectVerticalPlaneAndVerticalCylinder as _,projectPointToLineLike as B,projectPointToVerticalCylinder as D,projectPointToVerticalPlane as J,VerticalPlaneType as K,intersectLineLikes as Q,intersectVerticalPlaneAndLineLike as V,intersectLineLikeAndVerticalCylinder as W,intersectVerticalPlanes as X,intersectVerticalCylinders as $,intersectVerticalPlaneAndPoint as tt}from"../../support/geometry3dUtils.js";import{LineType as et}from"../../support/geometry2dUtils.js";class nt{intersect(t){return zt(this,t)}closestPoints(t){return[this.closestTo(t)]}}class rt extends nt{constructor(t){super(),this.point=t}equals(t){return this===t||$t(t)&&f(this.point,t.point)}closestTo(){return U(this.point)}}class st extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:n}}equals(t){return this===t||te(t)&&this.lineLike.type===t.lineLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){const e=B(t,this.lineLike);return O(e)}}class it extends st{constructor(t,e){super(t,e,et.LINE)}}class ot extends st{constructor(t,e){super(t,e,et.RAY)}}class ut extends nt{constructor(t){super(),this.constraints=t}equals(t){return this===t||Xt(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,n=1/0;for(const r of this.constraints){const s=r.closestTo(t),i=l(t,s);i<n&&(n=i,e=s)}return e?U(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class ct extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||re(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return O(e)}}class at extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||se(t)&&f(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return e[2]=this.center[2],O(e)}asCircle(){return new ft(U(this.center),this.radius,b(0,0,1))}}class ft extends nt{constructor(t,e,n,r=void 0){super(),this.center=t,this.radius=e,this.normal=n,this.slicePlane=r}equals(t){return this===t||ie(t)&&f(this.center,t.center)&&f(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:n}=this;w(this.getPlane(ht),t,lt);const r=h(lt,lt,e),s=d(r);if(F(s,0))return U(t);const i=n/Math.sqrt(s),o=a(k(),e,r,i),{slicePlane:u}=this;if(u&&!H(u,o)){const e=At(u,this);return e?.closestTo(t)??U(t)}return O(o)}getPlane(t=y()){return E(this.center,this.normal,t)}}const lt=k(),ht=y();class dt extends nt{constructor(t){super(),this.z=t}equals(t){return this===t||ee(t)&&this.z===t.z}closestTo(t){return O(P(t[0],t[1],this.z))}getPlane(t=y()){return p(pt,0,0,this.z),E(pt,T,t)}}const pt=k();class mt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.planeLike={start:t,end:e,type:n}}equals(t){return this===t||ne(t)&&this.planeLike.type===t.planeLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){return O(J(t,this.planeLike))}closestEndTo(t){const{start:e,end:s}=this;return Math.sign(n(r(Lt,s,e),r(kt,t,e)))>0?s:e}getPlane(t=y()){const e=u(gt,this.end);return e[2]+=1,A(this.start,this.end,e,t)}getSlicePlane(t=y()){const{start:e,end:n,type:r}=this.planeLike;if(r===K.PLANE)return;const s=p(gt,e[0],e[1],0),i=p(Pt,n[0],n[1],0),o=m(Pt,i,s);return E(s,o,t),t}}const Lt=i(),kt=i(),gt=k(),Pt=k();class Tt extends mt{constructor(t,e){super(t,e,K.HALF_PLANE)}}class yt extends mt{constructor(t,e){super(t,e,K.PLANE)}}class qt extends nt{constructor(t,e){super(),this.sphere=Z(t,e)}equals(t){return this===t||oe(t)&&I(this.sphere,t.sphere)}closestTo(t){const e=G(this.sphere,t,k());return O(e)}get center(){return this.sphere}get radius(){return this.sphere[3]}}class xt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.getZ=n,this.planeLike={start:t,end:e,type:K.PLANE}}equals(t){return this===t||ue(t)&&f(this.start,t.start)&&f(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return vt(this,t)}addIfOnTheGround(t,e){for(const n of e){const e=this.getZ(n[0],n[1])??0;F(n[2],e)&&(n[2]=e,t.push(n))}}}function vt(t,e){const n=J(e,t.planeLike);return n[2]=t.getZ(n[0],n[1])??ce,O(n)}function zt(t,e){if(Xt(t)){const n=[];for(const r of t.constraints){const t=r.intersect(e);t&&n.push(t)}return Wt(n)}if(Xt(e))return zt(e,t);if(ue(t))return Jt(t,e);if(ue(e))return Jt(e,t);if($t(t)){const{point:n}=t,r=e.closestTo(n);return L(r,n)?t:void 0}if(te(t)){if($t(e))return zt(e,t);if(te(e))return Qt(Q(t.lineLike,e.lineLike));if(ee(e))return jt(t,e);if(ne(e))return Qt(V(e.planeLike,t.lineLike));if(re(e))return Qt(W(t.lineLike,e.center,e.radius));if(ie(e))return Qt(R(t.lineLike,e));if(se(e))return wt(t,e);if(oe(e))return Et(t,e)}else if(ee(t)){if($t(e)||te(e))return zt(e,t);if(ee(e))return Mt(t,e);if(ne(e))return Nt(t,e);if(re(e))return Zt(t,e);if(ie(e))return Gt(t,e);if(se(e))return It(t,e);if(oe(e))return St(t,e)}else if(ne(t)){if($t(e)||te(e)||ee(e))return zt(e,t);if(ne(e))return Kt(X(t.planeLike,e.planeLike));if(re(e))return Kt(_(t.planeLike,e.center,e.radius));if(ie(e))return Ut(t,e);if(se(e))return Ot(t,e);if(oe(e))return bt(t,e)}else if(re(t)){if($t(e)||te(e)||ee(e)||ne(e))return zt(e,t);if(re(e))return Kt($(t.center,t.radius,e.center,e.radius));if(ie(e))return Ct();if(se(e))return Ft(t,e);if(oe(e))return Ht()}else if(ie(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e))return zt(e,t);if(ie(e))return Rt();if(se(e))return Rt(e.asCircle());if(oe(e))return Yt()}else if(se(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||ie(e))return zt(e,t);if(se(e))return _t(e,t);if(oe(e))return Bt()}else if(oe(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||se(e))return zt(e,t);if(oe(e))return Dt()}}const jt=(()=>{const t=y();return(e,n)=>{const{start:r,end:s}=e;if(C(r,s)&&F(r[2],n.z))return e;const i=k();return q(n.getPlane(t),r,s,i)?new rt(O(i)):void 0}})();function wt({lineLike:t},{center:e,radius:n}){const r=e[2];return Qt(W(t,e,n).filter((t=>F(t[2],r))))}function Et({lineLike:t},{sphere:e}){return Qt(S(e,t.start,t.end))}const At=(()=>{const t=N(),e=y(),n={start:k(),end:k(),type:et.LINE};return(r,s,i)=>{const{normal:a,center:f,radius:l}=s,h=o(a,M(r)),d=F(x(r,f),0);if(F(h,1))return d?s:void 0;if(s.getPlane(e),d&&F(h,0)&&v(r)&&v(e)){if(F(l,0))return!i||H(i,f)?new rt(U(f)):void 0;const t=g(f);t[2]+=l;const e=g(f);e[2]-=l;const n=[];return i&&!H(i,t)||n.push(t),i&&!H(i,e)||n.push(e),Qt(n)}if(!z(r,e,t))return;u(n.start,t.origin),c(n.end,t.origin,t.direction);const p=R(n,s);return Qt(i?Y(i,p):p)}})();function Mt(t,e){return F(t.z,e.z)?t:void 0}function Nt({z:t},{planeLike:e}){const[n,r]=e.start,[s,i]=e.end,o=b(n,r,t),u=b(s,i,t);return e.type===K.PLANE?new it(o,u):new ot(o,u)}function Zt(t,e){const[n,r]=e.center;return new at(b(n,r,t.z),e.radius)}function It(t,e){return F(e.center[2],t.z)?e:void 0}const Gt=(()=>{const t=y();return(e,n)=>At(e.getPlane(t),n)})();function St(t,{center:e,radius:n}){const r=Math.abs(e[2]-t.z);if(r>n&&!F(r,n))return;const s=b(e[0],e[1],t.z),i=Math.sqrt(n**2-r**2);return F(i,0)?void 0:new at(s,i)}const Ot=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=_(e.planeLike,n,r),i=n[2];e.getSlicePlane(t);const o=[];for(const[u,c]of s){const e=[u,c,i];H(t,e)&&o.push(e)}return Qt(o)}})(),Ut=(()=>{const t=y(),e=y();return(n,r)=>At(n.getPlane(t),r,n.getSlicePlane(e))})(),bt=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=e.getPlane(t),i=j(s,n),o=Math.abs(i);if(o>r&&!F(o,r))return;const u=g(M(s)),c=a(k(),n,u,i),f=Math.sqrt(r**2-i**2);return F(f,0)?new rt(O(w(s,n,k()))):new ft(O(c),f,u,e.getSlicePlane())}})();function Ct(t,e){}function Ft(t,e){const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return e;return Vt($(t.center,t.radius,e.center,e.radius),e.center[2])}function Ht(t,e){}function Rt(t,e){}function Yt(t,e){}function _t(t,e){if(!C(t.center,e.center))return;const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return t;return Vt($(t.center,t.radius,e.center,e.radius),t.center[2])}function Bt(t,e){}function Dt(t,e){}function Jt(t,e){const{planeLike:n,getZ:r}=t,s=[];if($t(e))t.addIfOnTheGround(s,tt(n,e.point));else if(te(e))t.addIfOnTheGround(s,V(n,e.lineLike));else if(re(e))for(const[i,o]of _(n,e.center,e.radius)){const t=r(i,o);null!=t&&s.push(P(i,o,t))}else if(ne(e)||ue(e))for(const[i,o]of X(n,e.planeLike)){const t=r(i,o)??ce;s.push(P(i,o,t))}return Qt(s)}function Kt(t){return Wt(t.map((([t,e])=>{const n=b(t,e,0),r=b(t,e,1);return new it(n,r)})))}function Qt(t){return Wt(t.map((t=>t?new rt(O(t)):void 0)))}function Vt(t,e){return Qt(t.map((([t,n])=>[t,n,e])))}function Wt(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new ut(e.filter(t))}function Xt(t){return t instanceof ut}function $t(t){return t instanceof rt}function te(t){return t instanceof st}function ee(t){return t instanceof dt}function ne(t){return t instanceof mt}function re(t){return t instanceof ct}function se(t){return t instanceof at}function ie(t){return t instanceof ft}function oe(t){return t instanceof qt}function ue(t){return t instanceof xt}const ce=0;export{ft as CircleConstraint,nt as Constraint,xt as DrapedLineConstraint,at as HorizontalCircleConstraint,dt as HorizontalPlaneConstraint,it as LineConstraint,st as LineLikeConstraint,rt as PointConstraint,ot as RayConstraint,ut as SetConstraint,qt as SphereConstraint,ct as VerticalCylinderConstraint,Tt as VerticalHalfPlaneConstraint,yt as VerticalPlaneConstraint,mt as VerticalPlaneLikeConstraint};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{destroyHandle as r}from"../../../core/handleUtils.js";import{allSettledValues as n,throwIfAborted as a}from"../../../core/promiseUtils.js";import{mapCollectionAsync as s}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{k as c}from"../../../chunks/vec2.js";import{a as u,c as p}from"../../../chunks/vec3.js";import{c as l}from"../../../chunks/vec3f64.js";import{g as d}from"../../../chunks/common.js";import{UpdatingHandles as S}from"../../../core/support/UpdatingHandles.js";import{absoluteHeightElevationInfo as h}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as m}from"../sketch/constraints.js";import{fromAnyMapPoint as g}from"../sketch/normalizedPoint.js";import{FeatureSnappingSourceInfo as f}from"./FeatureSnappingSourceInfo.js";import{SnappingDomain as y}from"./SnappingDomain.js";import{sortCandidatesInPlace as _,screenDistance as v}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as w}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as j}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as F}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as C,OtherVertexType as x}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as M}from"../support/viewUtils.js";let R=class extends t{get updating(){return this._snappingSources.some((e=>null==e||e.valid&&e.snappingSource.updating))||this._updatingHandles.updating}constructor(e){super(e),this.options=null,this._domain=y.FEATURE,this._updatingHandles=new S,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){const e=s((()=>this.options?.featureSources),((e,t)=>this._createSourceInfo(e,t)));this._snappingSources=e,this.addHandles(r(e))}destroy(){this._set("options",null),this._updatingHandles.destroy()}async fetchCandidates(e,t,r,s){if(!(t&this._domain&&null!=this.options&&this.options.effectiveFeatureEnabled))return[];const o=[],i=this._computeScreenSizeDistanceParameters(e,r);for(const n of this._snappingSources){if(null==n||!n.valid||!n.snappingSource.layerSource.enabled||n.layerView?.suspended)continue;const t=n.getFetchCandidatesParameters(e,r,i);for(const e of t)o.push(n.snappingSource.fetchCandidates(e,s).then((e=>e.filter((e=>!this._candidateIsExcluded(n.snappingSource,e,r.excludeFeature))))))}const c=(await n(o)).flat();return this._addRightAngleCandidates(c,e,i,r),a(s),_(e,c),c}_addRightAngleCandidates(e,t,r,n){const a=null!=n.vertexHandle?n.vertexHandle.rightEdge?.rightVertex?.pos:null!=n.editGeometryOperations&&"polygon"===n.editGeometryOperations.data.type?n.editGeometryOperations.data.components[0]?.getFirstVertex()?.pos:null,s=null!=n.vertexHandle?n.vertexHandle.leftEdge?.leftVertex?.pos:null!=n.editGeometryOperations?n.editGeometryOperations.data.components[0]?.getLastVertex()?.pos:null,{view:o}=this,i=g(a,o,n),c=g(s,o,n),u=e.length;for(let p=0;p<u;p++)this._addRightAngleCandidate(e[p],c,t,r,e),this._addRightAngleCandidate(e[p],i,t,r,e)}_addRightAngleCandidate(e,t,r,n,a){if(null==t||!b(e))return;const s=e.constraint.closestTo(t),o=(s[0]-r[0])/n.x,i=(s[1]-r[1])/n.y,{start:u,end:p}=e.constraint;if(o*o+i*i<=1){const r=new C({targetPoint:s,otherVertex:t,otherVertexType:x.NEXT,previousVertex:c(s,u)>c(s,p)?u:p,constraint:new m(t,s),objectId:e.objectId,isDraped:e.isDraped});a.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=null!=this.options?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return null==this.view?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,n){const{spatialReference:a}=n;r.renderCoordsHelper.toRenderCoords(e,a,H);const s=r.state.camera.computeScreenPixelSizeAt(H),o=s*r.renderCoordsHelper.unitInMeters/r.mapCoordsHelper.unitInMeters,i=t*o,c=M(e,a,h,r),u=c?L(c,e,o,0,0,r,n):0,p=c?L(c,e,0,o,0,r,n):0,l=c?L(c,e,0,0,o,r,n):0;return{x:0===u?0:i/u,y:0===p?0:i/p,z:0===l?0:i/l,distance:s*t}}_candidateIsExcluded(e,t,r){if(null==r)return!1;const n=this._getCandidateObjectId(t);if(null==n)return!1;const a=e.layerSource.layer;return"graphics"===a.type?r.uid===n:r.sourceLayer===a&&(!(!r.attributes||!("objectIdField"in a))&&r.attributes[a.objectIdField]===n)}_getCandidateObjectId(e){return e instanceof F?e.objectId:null}async _createSourceInfo(e,t){const r=e.layer;r.loaded||(await r.load(),a(t));const{view:n}=this,s=await this._createFeatureSnappingSourceType(e);return a(t),new f(null==s?{}:{snappingSource:s,view:n,layer:r})}async _createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}async _createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(null==t||"3d"!==t.type)return null;return new((await this._getSourceModule("scene")).SceneLayerSnappingSource)({layerSource:e,view:t})}async _createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":return new((await this._getSourceModule("featureService")).FeatureServiceSnappingSource)({spatialReference:this.spatialReference,view:this.view,layerSource:e});case"memory":case"csv":case"geojson":case"wfs":if("mesh"===e.layer.geometryType)return null;return new((await this._getSourceModule("featureCollection")).FeatureCollectionSnappingSource)({layerSource:e,view:this.view})}return null}async _createFeatureSnappingSourceGraphicsLayer(e){return new((await this._getSourceModule("graphics")).GraphicsSnappingSource)({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}async _createFeatureSnappingSourceMapNotesLayer(e){return new((await this._getSourceModule("notes")).GraphicsSnappingSource)({getGraphicsLayers:()=>e.layer.sublayers?.toArray()??[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}async _getSourceModule(e){const t=this._sourceModules[e];if(null==t.loader){const t=this._loadSourceModule(e),r={module:null,loader:t};this._sourceModules[e]=r;const n=await t,a={module:n,loader:t};return this._sourceModules[e]=a,n}return null==t.module?t.loader:t.module}_loadSourceModule(e){const t=this._updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}get test(){return{snappingSources:this._snappingSources}}};function b(e){return(e instanceof j||e instanceof w)&&!I(e)}function I({constraint:{start:e,end:t}}){const r=u(e,t),n=c(e,t);return r<d()||n/r<P}function L(e,t,r,n,a,s,{spatialReference:o}){const i=p(G,t);i[0]+=r,i[1]+=n,i[2]+=a;const c=M(i,o,h,s);return c?v(c,e):1/0}e([o({constructOnly:!0})],R.prototype,"spatialReference",void 0),e([o({constructOnly:!0})],R.prototype,"view",void 0),e([o()],R.prototype,"options",void 0),e([o({readOnly:!0})],R.prototype,"updating",null),e([o()],R.prototype,"_snappingSources",void 0),R=e([i("esri.views.interactive.snapping.FeatureSnappingEngine")],R);const H=l(),G=l(),P=1e-4;export{R as FeatureSnappingEngine};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{destroyHandle as r}from"../../../core/handleUtils.js";import{allSettledValues as n,throwIfAborted as a}from"../../../core/promiseUtils.js";import{mapCollectionAsync as s}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as o,getMetersPerVerticalUnitForSR as i}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{k as p}from"../../../chunks/vec2.js";import{a as l,c as d}from"../../../chunks/vec3.js";import{c as S}from"../../../chunks/vec3f64.js";import{g as m}from"../../../chunks/common.js";import{UpdatingHandles as h}from"../../../core/support/UpdatingHandles.js";import{absoluteHeightElevationInfo as g}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as f}from"../sketch/constraints.js";import{fromAnyMapPoint as y}from"../sketch/normalizedPoint.js";import{FeatureSnappingSourceInfo as _}from"./FeatureSnappingSourceInfo.js";import{SnappingDomain as v}from"./SnappingDomain.js";import{sortCandidatesInPlace as w,screenDistance as j}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as F}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as C}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as x}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as R,OtherVertexType as b}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as M}from"../support/viewUtils.js";let I=class extends t{get updating(){return this._snappingSources.some((e=>null==e||e.valid&&e.snappingSource.updating))||this._updatingHandles.updating}constructor(e){super(e),this.options=null,this._domain=v.FEATURE,this._updatingHandles=new h,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){const e=s((()=>this.options?.featureSources),((e,t)=>this._createSourceInfo(e,t)));this._snappingSources=e,this.addHandles(r(e))}destroy(){this._set("options",null),this._updatingHandles.destroy()}async fetchCandidates(e,t,r,s){if(!(t&this._domain&&null!=this.options&&this.options.effectiveFeatureEnabled))return[];const o=[],i=this._computeScreenSizeDistanceParameters(e,r);for(const n of this._snappingSources){if(null==n||!n.valid||!n.snappingSource.layerSource.enabled||n.layerView?.suspended)continue;const t=n.getFetchCandidatesParameters(e,r,i);for(const e of t)o.push(n.snappingSource.fetchCandidates(e,s).then((e=>e.filter((e=>!this._candidateIsExcluded(n.snappingSource,e,r.excludeFeature))))))}const c=(await n(o)).flat();return this._addRightAngleCandidates(c,e,i,r),a(s),w(e,c),c}_addRightAngleCandidates(e,t,r,n){const a=null!=n.vertexHandle?n.vertexHandle.rightEdge?.rightVertex?.pos:null!=n.editGeometryOperations&&"polygon"===n.editGeometryOperations.data.type?n.editGeometryOperations.data.components[0]?.getFirstVertex()?.pos:null,s=null!=n.vertexHandle?n.vertexHandle.leftEdge?.leftVertex?.pos:null!=n.editGeometryOperations?n.editGeometryOperations.data.components[0]?.getLastVertex()?.pos:null,{view:o}=this,i=y(a,o,n),c=y(s,o,n),u=e.length;for(let p=0;p<u;p++)this._addRightAngleCandidate(e[p],c,t,r,e),this._addRightAngleCandidate(e[p],i,t,r,e)}_addRightAngleCandidate(e,t,r,n,a){if(null==t||!L(e))return;const s=e.constraint.closestTo(t),o=(s[0]-r[0])/n.x,i=(s[1]-r[1])/n.y,{start:c,end:u}=e.constraint;if(o*o+i*i<=1){const r=new R({targetPoint:s,otherVertex:t,otherVertexType:b.NEXT,previousVertex:p(s,c)>p(s,u)?c:u,constraint:new f(t,s),objectId:e.objectId,isDraped:e.isDraped});a.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=null!=this.options?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return null==this.view?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,n){const{spatialReference:a}=n;r.renderCoordsHelper.toRenderCoords(e,a,P);const s=r.state.camera.computeScreenPixelSizeAt(P),c=s*r.renderCoordsHelper.unitInMeters,u=c/o(a),p=c/i(a),l=t*u,d=t*p,S=M(e,a,g,r),m=S?H(S,e,u,0,0,r,n):0,h=S?H(S,e,0,u,0,r,n):0,f=S?H(S,e,0,0,p,r,n):0;return{x:0===m?0:l/m,y:0===h?0:l/h,z:0===f?0:d/f,distance:s*t}}_candidateIsExcluded(e,t,r){if(null==r)return!1;const n=this._getCandidateObjectId(t);if(null==n)return!1;const a=e.layerSource.layer;return"graphics"===a.type?r.uid===n:r.sourceLayer===a&&(!(!r.attributes||!("objectIdField"in a))&&r.attributes[a.objectIdField]===n)}_getCandidateObjectId(e){return e instanceof x?e.objectId:null}async _createSourceInfo(e,t){const r=e.layer;r.loaded||(await r.load(),a(t));const{view:n}=this,s=await this._createFeatureSnappingSourceType(e);return a(t),new _(null==s?{}:{snappingSource:s,view:n,layer:r})}async _createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}async _createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(null==t||"3d"!==t.type)return null;return new((await this._getSourceModule("scene")).SceneLayerSnappingSource)({layerSource:e,view:t})}async _createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":return new((await this._getSourceModule("featureService")).FeatureServiceSnappingSource)({spatialReference:this.spatialReference,view:this.view,layerSource:e});case"memory":case"csv":case"geojson":case"wfs":if("mesh"===e.layer.geometryType)return null;return new((await this._getSourceModule("featureCollection")).FeatureCollectionSnappingSource)({layerSource:e,view:this.view})}return null}async _createFeatureSnappingSourceGraphicsLayer(e){return new((await this._getSourceModule("graphics")).GraphicsSnappingSource)({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}async _createFeatureSnappingSourceMapNotesLayer(e){return new((await this._getSourceModule("notes")).GraphicsSnappingSource)({getGraphicsLayers:()=>e.layer.sublayers?.toArray()??[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}async _getSourceModule(e){const t=this._sourceModules[e];if(null==t.loader){const t=this._loadSourceModule(e),r={module:null,loader:t};this._sourceModules[e]=r;const n=await t,a={module:n,loader:t};return this._sourceModules[e]=a,n}return null==t.module?t.loader:t.module}_loadSourceModule(e){const t=this._updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}get test(){return{snappingSources:this._snappingSources}}};function L(e){return(e instanceof C||e instanceof F)&&!G(e)}function G({constraint:{start:e,end:t}}){const r=l(e,t),n=p(e,t);return r<m()||n/r<z}function H(e,t,r,n,a,s,{spatialReference:o}){const i=d(E,t);i[0]+=r,i[1]+=n,i[2]+=a;const c=M(i,o,g,s);return c?j(c,e):1/0}e([c({constructOnly:!0})],I.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],I.prototype,"view",void 0),e([c()],I.prototype,"options",void 0),e([c({readOnly:!0})],I.prototype,"updating",null),e([c()],I.prototype,"_snappingSources",void 0),I=e([u("esri.views.interactive.snapping.FeatureSnappingEngine")],I);const P=S(),E=S(),z=1e-4;export{I as FeatureSnappingEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{throwIfAborted as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as r,initial as o,on as a}from"../../../../core/reactiveUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as l}from"../../../../support/elevationInfoUtils.js";import{makeFilter as y,makeSnappingQuery as c}from"../snappingUtils.js";import{convertSnappingCandidate as u,makeGetGroundElevation as g}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as h}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as m}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as d}from"./symbologySnappingCandidates.js";let v=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return h();const r=async(i,r)=>(await n(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(i,r);return h(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return m(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?d(this._symbologySnappingSupported,(async(n,r)=>{const o=await e.whenLayerView(t);return i(r),o.queryForSymbologySnapping({candidates:n,spatialReference:e.spatialReference},r)})):d()}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;l(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),r((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),o),r((()=>null!=this._layerView3D?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),o),a((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null}refresh(){}async fetchCandidates(e,t){const{layer:n}=this.layerSource,r=n.source;if(!r?.querySnapping)return[];const o=y(n),a=c(e,this.view?.type??"2d",o),s=await r.querySnapping(a,{signal:t});i(t);const p=await this._snappingElevationAligner.alignCandidates(s.candidates,t);i(t);const l=await this._symbologySnappingFetcher.fetch(p,t);i(t);const g=0===l.length?p:[...p,...l],h=this._snappingElevationFilter.filter(a,g),m=this._getGroundElevation;return h.map((e=>u(e,m)))}get _getGroundElevation(){return g(this.view)}};e([s({constructOnly:!0})],v.prototype,"layerSource",void 0),e([s({constructOnly:!0})],v.prototype,"view",void 0),e([s()],v.prototype,"_snappingElevationAligner",null),e([s()],v.prototype,"_snappingElevationFilter",null),e([s()],v.prototype,"_symbologySnappingFetcher",null),e([s()],v.prototype,"_layerView3D",void 0),e([s()],v.prototype,"_symbologySnappingSupported",null),e([s()],v.prototype,"_getGroundElevation",null),v=e([p("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],v);export{v as FeatureCollectionSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as o,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as r,initial as a,on as s}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as y}from"../../../../support/elevationInfoUtils.js";import{makeFilter as c,makeSnappingQuery as u}from"../snappingUtils.js";import{convertSnappingCandidate as g,makeGetGroundElevation as h}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as m}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as d}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"./symbologySnappingCandidates.js";let S=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return m();const o=async(i,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(i,o);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?v(this._symbologySnappingSupported,(async(i,n)=>{const r=await e.whenLayerView(t);return o(n),r.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},n)})):v()}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;y(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),r((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),r((()=>null!=this._layerView3D?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),a),s((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null,this._memoizedMakeGetGroundElevation=i(h)}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,n=i.source;if(!n?.querySnapping)return[];const r=c(i),a=u(e,this.view?.type??"2d",r),s=await n.querySnapping(a,{signal:t});o(t);const p=e.coordinateHelper.spatialReference,l=await this._snappingElevationAligner.alignCandidates(s.candidates,p,t);o(t);const y=await this._symbologySnappingFetcher.fetch(l,t);o(t);const h=0===y.length?l:[...l,...y],m=this._snappingElevationFilter.filter(a,h),d=this._memoizedMakeGetGroundElevation(this.view,p);return m.map((e=>g(e,d)))}};e([p({constructOnly:!0})],S.prototype,"layerSource",void 0),e([p({constructOnly:!0})],S.prototype,"view",void 0),e([p()],S.prototype,"_snappingElevationAligner",null),e([p()],S.prototype,"_snappingElevationFilter",null),e([p()],S.prototype,"_symbologySnappingFetcher",null),e([p()],S.prototype,"_layerView3D",void 0),e([p()],S.prototype,"_symbologySnappingSupported",null),S=e([l("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],S);export{S as FeatureCollectionSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/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 r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{throwIfAborted as s,ignoreAbortErrors as o}from"../../../../core/promiseUtils.js";import{watch as a,initial as n,on as l,sync as u,syncAndInitial as d}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as y}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as f}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as m}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as _}from"../snappingUtils.js";import{convertSnappingCandidate as w,makeGetGroundElevation as S}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as v}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as b}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as I}from"./featureServiceSource/FeatureServiceTilesSimple.js";import H from"../../../support/debugFlags.js";let j=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find((e=>e.layer===this._layer))}get _isSuspended(){if(y(this._layer)){if(!this._layer.sublayers.find((e=>e.visible)))return!0}return!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get _outFields(){const{view:e,_layerView:t,layerSource:r}=this,{layer:i}=r,{fieldsIndex:s,timeInfo:o,floorInfo:a,subtypeField:n}=i,l=t&&"filter"in t?t.filter:null,u=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&o){const{startField:e,endField:t}=o,r=s.get(e)?.name??e,i=s.get(t)?.name??t;r&&u.push(r),i&&u.push(i)}if(e?.map&&_(e.map)&&e.map.utilityNetworks?.find((e=>e.isUtilityLayer(i)))){const e=i.fieldsIndex.get("assetGroup")?.name,t=i.fieldsIndex.get("assetType")?.name;e&&t&&(u.push(e),u.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&u.push(e)}if(n){const e=s.get(n)?.name??n;e&&u.push(e)}return new Set(u)}get configuration(){const{view:e}=this,t=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new c,this._workerHandle=null,this._debug=null}initialize(){let e;const t=this.view;if(null!=t)switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new b;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new m({view:t}),e=this._workerHandle=new b({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,r)=>{const o=await t.whenLayerView(i);return s(r),o.elevationAlignPointsInFeatures(e,r)},queryForSymbologySnapping:async(e,r)=>{const o=await t.whenLayerView(i);return s(r),o.queryForSymbologySnapping(e,r)}}),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;f(t,r)&&o(e.notifyElevationSourceChange())})),a((()=>i.elevationInfo),(()=>o(e.notifyElevationSourceChange())),n),a((()=>this._layerView?.processor?.renderer),(()=>o(e.notifySymbologyChange())),n),a((()=>this._layerView?.symbologySnappingSupported??!1),(t=>o(e.setSymbologySnappingSupported(t))),n),l((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new I({layer:this._layer}),e=this._workerHandle=new b;this.addHandles([i(e)]),o(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>o(e.updateTiles(this._updateTilesParameters,null))),n),this.addHandles([a((()=>this.configuration),(t=>o(e.configure(t,null))),u),a((()=>this._outFields),(t=>o(e.updateOutFields(t))),n),a((()=>this._isSuspended),(t=>o(e.setSuspended(t))),d)]),null!=t&&this.addHandles(a((()=>H.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new v({view:t,handle:e}),this.addHandles(i(this._debug),"debug")):!r&&this._debug&&this.removeHandles("debug")}),n)),this.addHandles(this.layerSource.layer.on("apply-edits",(t=>{o(e.applyEdits(t,null))})))}destroy(){this._updatingHandles.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._getGroundElevation;return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>w(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}get _getGroundElevation(){return S(this.view)}_getOrLoadWhereFields(e,t){const{_whereModule:i}=this;if(!this._loadWhereModuleTask&&!i){const e=r((async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.WhereClause,this._whereModule}));return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!i)return[];try{return i.create(e,t).fieldNames}catch(s){return[]}}};e([p({constructOnly:!0})],j.prototype,"spatialReference",void 0),e([p({constructOnly:!0})],j.prototype,"layerSource",void 0),e([p({constructOnly:!0})],j.prototype,"view",void 0),e([p()],j.prototype,"_tilesOfInterest",void 0),e([p({readOnly:!0})],j.prototype,"_updateTilesParameters",null),e([p()],j.prototype,"_layerView",null),e([p()],j.prototype,"_isSuspended",null),e([p({readOnly:!0})],j.prototype,"updating",null),e([p()],j.prototype,"_outFields",null),e([p({readOnly:!0})],j.prototype,"configuration",null),e([p({readOnly:!0})],j.prototype,"availability",null),e([p()],j.prototype,"_getGroundElevation",null),e([p()],j.prototype,"_loadWhereModuleTask",void 0),e([p()],j.prototype,"_whereModule",void 0),j=e([h("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],j);export{j as FeatureServiceSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as o,ignoreAbortErrors as a}from"../../../../core/promiseUtils.js";import{watch as n,initial as l,on as u,sync as d,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as f}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as m}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as _}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as g}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as w}from"../snappingUtils.js";import{convertSnappingCandidate as S,makeGetGroundElevation as v}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as b}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as I}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as H}from"./featureServiceSource/FeatureServiceTilesSimple.js";import j from"../../../support/debugFlags.js";let F=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find((e=>e.layer===this._layer))}get _isSuspended(){if(f(this._layer)){if(!this._layer.sublayers.find((e=>e.visible)))return!0}return!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get _outFields(){const{view:e,_layerView:t,layerSource:r}=this,{layer:i}=r,{fieldsIndex:s,timeInfo:o,floorInfo:a,subtypeField:n}=i,l=t&&"filter"in t?t.filter:null,u=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&o){const{startField:e,endField:t}=o,r=s.get(e)?.name??e,i=s.get(t)?.name??t;r&&u.push(r),i&&u.push(i)}if(e?.map&&w(e.map)&&e.map.utilityNetworks?.find((e=>e.isUtilityLayer(i)))){const e=i.fieldsIndex.get("assetGroup")?.name,t=i.fieldsIndex.get("assetType")?.name;e&&t&&(u.push(e),u.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&u.push(e)}if(n){const e=s.get(n)?.name??n;e&&u.push(e)}return new Set(u)}get configuration(){const{view:e}=this,t=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new y,this._workerHandle=null,this._debug=null,this._memoizedMakeGetGroundElevation=s(v)}initialize(){let e;const t=this.view;if(null!=t)switch(t.type){case"2d":this._tilesOfInterest=new _({view:t,layer:this._layer}),e=this._workerHandle=new I;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new g({view:t}),e=this._workerHandle=new I({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.elevationAlignPointsInFeatures(e,r)},queryForSymbologySnapping:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.queryForSymbologySnapping(e,r)}}),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;m(t,r)&&a(e.notifyElevationSourceChange())})),n((()=>i.elevationInfo),(()=>a(e.notifyElevationSourceChange())),l),n((()=>this._layerView?.processor?.renderer),(()=>a(e.notifySymbologyChange())),l),n((()=>this._layerView?.symbologySnappingSupported??!1),(t=>a(e.setSymbologySnappingSupported(t))),l),u((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new H({layer:this._layer}),e=this._workerHandle=new I;this.addHandles([i(e)]),a(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>a(e.updateTiles(this._updateTilesParameters,null))),l),this.addHandles([n((()=>this.configuration),(t=>a(e.configure(t,null))),d),n((()=>this._outFields),(t=>a(e.updateOutFields(t))),l),n((()=>this._isSuspended),(t=>a(e.setSuspended(t))),p)]),null!=t&&this.addHandles(n((()=>j.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new b({view:t,handle:e}),this.addHandles(i(this._debug),"debug")):!r&&this._debug&&this.removeHandles("debug")}),l)),this.addHandles(this.layerSource.layer.on("apply-edits",(t=>{a(e.applyEdits(t,null))})))}destroy(){this._updatingHandles.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._memoizedMakeGetGroundElevation(this.view,r.spatialReference);return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>S(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}_getOrLoadWhereFields(e,t){const{_whereModule:i}=this;if(!this._loadWhereModuleTask&&!i){const e=r((async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.WhereClause,this._whereModule}));return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!i)return[];try{return i.create(e,t).fieldNames}catch(s){return[]}}};e([h({constructOnly:!0})],F.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],F.prototype,"layerSource",void 0),e([h({constructOnly:!0})],F.prototype,"view",void 0),e([h()],F.prototype,"_tilesOfInterest",void 0),e([h({readOnly:!0})],F.prototype,"_updateTilesParameters",null),e([h()],F.prototype,"_layerView",null),e([h()],F.prototype,"_isSuspended",null),e([h({readOnly:!0})],F.prototype,"updating",null),e([h()],F.prototype,"_outFields",null),e([h({readOnly:!0})],F.prototype,"configuration",null),e([h({readOnly:!0})],F.prototype,"availability",null),e([h()],F.prototype,"_loadWhereModuleTask",void 0),e([h()],F.prototype,"_whereModule",void 0),F=e([c("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],F);export{F as FeatureServiceSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{throwIfAborted as o,allSettledValues as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{initial as a,watch as p,on as l}from"../../../../core/reactiveUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Polygon.js";import{initializeProjection as y,canProjectWithoutEngine as m,project as g}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as f}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as _}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as S}from"../../../../layers/graphics/OptimizedFeature.js";import w from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as j}from"../../../../layers/graphics/data/QueryEngine.js";import b from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as E}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as k}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as F,makeSnappingQuery as C}from"../snappingUtils.js";import{convertSnappingCandidate as A,makeGetGroundElevation as I}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as P}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as G}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as R}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const H="graphics-collections";let O=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return P();const r=async(s,r)=>(await n(e.whenLayerView(t),r)).elevationAlignPointsInFeatures(s,r);return P(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:r,spatialReference:e.spatialReference})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return G(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,r=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&r?R(r,(async(s,r)=>{const i=await e.whenLayerView(t);return o(r),i.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},r)})):R()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new u}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(H);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],H)}),a);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{E(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),p((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),l((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s}=e,r=await i(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));o(t);const n=this._getGroundElevation,a=r.flat().map((e=>A(e,n)));return F(s,a),a}get _getGroundElevation(){return I(this.view)}async _fetchCandidatesForSource(e,t,s){const r=C(t,this.view?.type??"2d"),i=await e.queryEngine.executeQueryForSnapping(r,s);o(s);const n=await this._snappingElevationAligner.alignCandidates(i.candidates,s);o(s);const a=await this._symbologySnappingFetcher.fetch(n,s);o(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(r,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const r of e)null!=r.geometry&&(this._needsInitializeProjection(r.geometry.spatialReference)?(t.push(r.geometry.spatialReference),s.set(r.uid,r)):this._add(r));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const o=r((async s=>{await y(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(o.promise);const i={task:o,graphics:t},n=()=>s(this._pendingAdds,i);o.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=h.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const r=this._createOptimizedFeature(e.uid,t);null!=r&&(s.featureStore.add(r),k(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!m(e,this.spatialReference)}_createOptimizedFeature(e,t){const s=g(f(t),this.spatialReference);if(!s)return null;const r=this._ensureGeometryHasZ(s),o=v(r,this._hasZ,!1);return new S(o,{[U]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=_.toJSON(e),s=this._hasZ,r=new w({geometryType:t,hasZ:s,hasM:!1});return{featureStore:r,queryEngine:new j({featureStore:r,fieldsIndex:b.fromLayerJSON({fields:[{name:U,type:"esriFieldTypeOID",alias:U}]}),geometryType:t,hasM:!1,hasZ:s,objectIdField:U,spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),k(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:r,multipoint:o}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=r&&i.push(e(r)),null!=o&&i.push(e(o)),i}};e([d()],O.prototype,"getGraphicsLayers",void 0),e([d({constructOnly:!0})],O.prototype,"layerSource",void 0),e([d({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],O.prototype,"view",void 0),e([d({readOnly:!0})],O.prototype,"updating",null),e([d({readOnly:!0})],O.prototype,"availability",void 0),e([d()],O.prototype,"_hasZ",null),e([d()],O.prototype,"_snappingElevationAligner",null),e([d()],O.prototype,"_snappingElevationFilter",null),e([d()],O.prototype,"_symbologySnappingFetcher",null),e([d()],O.prototype,"_extrudedPolygonSymbolsCount",void 0),e([d()],O.prototype,"_getGroundElevation",null),O=e([c("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],O);const U="OBJECTID";export{O as GraphicsSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{memoize as r}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as S}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import j from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as b}from"../../../../layers/graphics/data/QueryEngine.js";import E from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as k}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as F}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as C,makeSnappingQuery as A}from"../snappingUtils.js";import{convertSnappingCandidate as I,makeGetGroundElevation as P}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as G}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as H}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as R}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const z="graphics-collections";let O=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return G();const o=async(s,o)=>(await a(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(s,o);return G(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return H(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,o=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&o?R(o,(async(s,o)=>{const r=await e.whenLayerView(t);return i(o),r.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},o)})):R()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=r(P)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(z);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],z)}),p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{k(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),l((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),p),d((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s,coordinateHelper:{spatialReference:o}}=e,r=await n(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,o),p=r.flat().map((e=>I(e,a)));return C(s,p),p}async _fetchCandidatesForSource(e,t,s){const o=A(t,this.view?.type??"2d"),r=await e.queryEngine.executeQueryForSnapping(o,s);i(s);const n=await this._snappingElevationAligner.alignCandidates(r.candidates,t.coordinateHelper.spatialReference,s);i(s);const a=await this._symbologySnappingFetcher.fetch(n,s);i(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(o,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const o of e)null!=o.geometry&&(this._needsInitializeProjection(o.geometry.spatialReference)?(t.push(o.geometry.spatialReference),s.set(o.uid,o)):this._add(o));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const r=o((async s=>{await m(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>s(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const o=this._createOptimizedFeature(e.uid,t);null!=o&&(s.featureStore.add(o),F(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const s=f(_(t),this.spatialReference);if(!s)return null;const o=this._ensureGeometryHasZ(s),r=v(o,this._hasZ,!1);return new w(r,{[U]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=S.toJSON(e),s=this._hasZ,o=new j({geometryType:t,hasZ:s,hasM:!1});return{featureStore:o,queryEngine:new b({featureStore:o,fieldsIndex:E.fromLayerJSON({fields:[{name:U,type:"esriFieldTypeOID",alias:U}]}),geometryType:t,hasM:!1,hasZ:s,objectIdField:U,spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),F(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:o,multipoint:r}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),i}};e([c()],O.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],O.prototype,"layerSource",void 0),e([c({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],O.prototype,"view",void 0),e([c({readOnly:!0})],O.prototype,"updating",null),e([c({readOnly:!0})],O.prototype,"availability",void 0),e([c()],O.prototype,"_hasZ",null),e([c()],O.prototype,"_snappingElevationAligner",null),e([c()],O.prototype,"_snappingElevationFilter",null),e([c()],O.prototype,"_symbologySnappingFetcher",null),e([c()],O.prototype,"_extrudedPolygonSymbolsCount",void 0),O=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],O);const U="OBJECTID";export{O as GraphicsSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={points:e},r=await this.remoteClient.invoke("alignElevation",i,{signal:t});return s(t),r},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},r=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return s(t),r}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:s,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:s}),this._featureFetcher=new S({store:new F({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures,spatialReference:l}),this._elevationFilter=y(d),this.addHandles([r((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),r((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,s(t);const i=b(e),r=t?.signal,n=await this._queryEngine.executeQueryForSnapping(i,r);s(r);const a=await this._elevationAligner.alignCandidates(n.candidates,r);s(r);const o=await this._symbologyCandidatesFetcher.fetch(a,r);s(r);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),await n((()=>!this.updatingExcludingEdits),t),s(t),j}async getDebugInfo(e,t){return s(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),s(t);const r=i();return this._pendingApplyEdits.set(e.id,r),this._featureFetcher.applyEdits(r.promise),this._editsUpdatingHandles.addPromise(r.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),s(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?f.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const I=w;function b(e){if(!e.filter)return{...e,query:{where:"1=1"}};const{distance:t,units:i,spatialRel:s,where:r,timeExtent:n,objectIds:a}=e.filter,o={geometry:e.filter.geometry?v(e.filter.geometry):void 0,distance:t,units:i,spatialRel:s,timeExtent:n,objectIds:a,where:r??"1=1"};return{...e,query:o}}const j={result:{}};export{I as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},r=await this.remoteClient.invoke("alignElevation",i,{signal:t});return s(t),r},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},r=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return s(t),r}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:s,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:s}),this._featureFetcher=new S({store:new F({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=y(d),this.addHandles([r((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),r((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,s(t);const i=b(e),r=t?.signal,n=await this._queryEngine.executeQueryForSnapping(i,r);s(r);const a=await this._elevationAligner.alignCandidates(n.candidates,e.point.spatialReference??p.WGS84,r);s(r);const o=await this._symbologyCandidatesFetcher.fetch(a,r);s(r);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),await n((()=>!this.updatingExcludingEdits),t),s(t),j}async getDebugInfo(e,t){return s(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),s(t);const r=i();return this._pendingApplyEdits.set(e.id,r),this._featureFetcher.applyEdits(r.promise),this._editsUpdatingHandles.addPromise(r.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),s(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?f.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const I=w;function b(e){if(!e.filter)return{...e,query:{where:"1=1"}};const{distance:t,units:i,spatialRel:s,where:r,timeExtent:n,objectIds:a}=e.filter,o={geometry:e.filter.geometry?v(e.filter.geometry):void 0,distance:t,units:i,spatialRel:s,timeExtent:n,objectIds:a,where:r??"1=1"};return{...e,query:o}}const j={result:{}};export{I 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as i}from"../../../../../core/arrayUtils.js";import{abortMaybe as o}from"../../../../../core/maybe.js";import{debounce as n,whenOrAbort as a}from"../../../../../core/promiseUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import{WorkerHandle as l}from"../../../../../core/workers/WorkerHandle.js";import{featureGeometryTypeKebabDictionary as p}from"../../../../../geometry/support/typeUtils.js";import{makeDehydratedPoint as u}from"../../../../../layers/graphics/dehydratedPoint.js";let h=class extends t{get updating(){return this._updatingHandles.updating||this._workerHandleUpdating}constructor(e){super(e),this._updatingHandles=new d,this._suspendController=null,this.schedule=null,this.hasZ=!1,this.elevationAlignPointsInFeatures=async e=>{const t=[];for(const{points:i}of e)for(const{z:e}of i)t.push(e);return{elevations:t,drapedObjectIds:new Set,failedObjectIds:new Set}},this.queryForSymbologySnapping=async()=>({candidates:[],sourceCandidateIndices:[]}),this.availability=0,this._workerHandleUpdating=!0,this._editId=0,this.updateOutFields=n((async(e,t)=>{await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("updateOutFields",[...e],t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}))}destroy(){this._suspendController=o(this._suspendController),this._workerHandle.destroy(),this._updatingHandles.destroy()}initialize(){this._workerHandle=new c(this.schedule,{alignElevation:async(e,{signal:t})=>({result:await this.elevationAlignPointsInFeatures(e.points,t)}),getSymbologyCandidates:async(e,{signal:t})=>({result:await this.queryForSymbologySnapping(e,t)})}),this.addHandles([this._workerHandle.on("notify-updating",(({updating:e})=>this._workerHandleUpdating=e)),this._workerHandle.on("notify-availability",(({availability:e})=>this._set("availability",e)))])}async setup(e,t){const i=this._serviceInfoFromLayer(e.layer);if(null==i)return;const o={configuration:this._convertConfiguration(e.configuration),serviceInfo:i,spatialReference:e.spatialReference.toJSON(),hasZ:this.hasZ,elevationInfo:e.layer.elevationInfo?.toJSON()};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("setup",o,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async configure(e,t){const i=this._convertConfiguration(e);await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("configure",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async refresh(e){await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("refresh",{},e)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},e))}async fetchCandidates(e,t){const{point:i,filter:o,coordinateHelper:n}=e,a={...e,point:u(i[0],i[1],i[2],n.spatialReference.toJSON()),filter:o?.toJSON()};return this._workerHandle.invoke(a,t)}async updateTiles(e,t){const i={tiles:e.tiles,tileInfo:null!=e.tileInfo?e.tileInfo.toJSON():null,tileSize:e.tileSize};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("updateTiles",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async applyEdits(e,t){const o=this._editId++,n={id:o};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("beginApplyEdits",n,t));const s=await this._updatingHandles.addPromise(a(e.result,t)),r={id:o,edits:{addedFeatures:s.addedFeatures?.map((({objectId:e})=>e)).filter(i)??[],deletedFeatures:s.deletedFeatures?.map((({objectId:e,globalId:t})=>({objectId:e,globalId:t})))??[],updatedFeatures:s.updatedFeatures?.map((({objectId:e})=>e)).filter(i)??[]}};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("endApplyEdits",r,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}getDebugInfo(e){return this._workerHandle.invokeMethod("getDebugInfo",{},e)}async notifyElevationSourceChange(){await this._workerHandle.invokeMethod("notifyElevationSourceChange",{})}async notifySymbologyChange(){await this._workerHandle.invokeMethod("notifySymbologyChange",{})}async setSymbologySnappingSupported(e){await this._workerHandle.invokeMethod("setSymbologySnappingSupported",e)}async setSuspended(e){this._suspendController?.abort(),this._suspendController=new AbortController,await this._workerHandle.invokeMethod("setSuspended",e,this._suspendController.signal)}_convertConfiguration(e){return{filter:null!=e.filter?e.filter.toJSON():null,customParameters:e.customParameters,viewType:e.viewType}}_serviceInfoFromLayer(e){return"multipatch"===e.geometryType||"mesh"===e.geometryType?null:{url:e.parsedUrl?.path??"",fieldsIndex:e.fieldsIndex.toJSON(),geometryType:p.toJSON(e.geometryType),capabilities:e.capabilities,objectIdField:e.objectIdField,globalIdField:e.globalIdField,spatialReference:e.spatialReference.toJSON(),timeInfo:e.timeInfo?.toJSON()}}};e([s({constructOnly:!0})],h.prototype,"schedule",void 0),e([s({constructOnly:!0})],h.prototype,"hasZ",void 0),e([s({constructOnly:!0})],h.prototype,"elevationAlignPointsInFeatures",void 0),e([s({constructOnly:!0})],h.prototype,"queryForSymbologySnapping",void 0),e([s({readOnly:!0})],h.prototype,"updating",null),e([s({readOnly:!0})],h.prototype,"availability",void 0),e([s()],h.prototype,"_workerHandleUpdating",void 0),h=e([r("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorkerHandle")],h);class c extends l{constructor(e,t){super("FeatureServiceSnappingSourceWorker","fetchCandidates",{},e,{strategy:"dedicated",client:t})}}export{h as FeatureServiceSnappingSourceWorkerHandle};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as i}from"../../../../../core/arrayUtils.js";import{abortMaybe as o}from"../../../../../core/maybe.js";import{debounce as n,whenOrAbort as a}from"../../../../../core/promiseUtils.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import{WorkerHandle as l}from"../../../../../core/workers/WorkerHandle.js";import{featureGeometryTypeKebabDictionary as p}from"../../../../../geometry/support/typeUtils.js";import{makeDehydratedPoint as u}from"../../../../../layers/graphics/dehydratedPoint.js";let h=class extends t{get updating(){return this._updatingHandles.updating||this._workerHandleUpdating}constructor(e){super(e),this._updatingHandles=new d,this._suspendController=null,this.schedule=null,this.hasZ=!1,this.elevationAlignPointsInFeatures=async e=>{const t=[];for(const{points:i}of e.pointsInFeatures)for(const{z:e}of i)t.push(e);return{elevations:t,drapedObjectIds:new Set,failedObjectIds:new Set}},this.queryForSymbologySnapping=async()=>({candidates:[],sourceCandidateIndices:[]}),this.availability=0,this._workerHandleUpdating=!0,this._editId=0,this.updateOutFields=n((async(e,t)=>{await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("updateOutFields",[...e],t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}))}destroy(){this._suspendController=o(this._suspendController),this._workerHandle.destroy(),this._updatingHandles.destroy()}initialize(){this._workerHandle=new c(this.schedule,{alignElevation:async(e,{signal:t})=>({result:await this.elevationAlignPointsInFeatures(e.query,t)}),getSymbologyCandidates:async(e,{signal:t})=>({result:await this.queryForSymbologySnapping(e,t)})}),this.addHandles([this._workerHandle.on("notify-updating",(({updating:e})=>this._workerHandleUpdating=e)),this._workerHandle.on("notify-availability",(({availability:e})=>this._set("availability",e)))])}async setup(e,t){const i=this._serviceInfoFromLayer(e.layer);if(null==i)return;const o={configuration:this._convertConfiguration(e.configuration),serviceInfo:i,spatialReference:e.spatialReference.toJSON(),hasZ:this.hasZ,elevationInfo:e.layer.elevationInfo?.toJSON()};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("setup",o,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async configure(e,t){const i=this._convertConfiguration(e);await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("configure",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async refresh(e){await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("refresh",{},e)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},e))}async fetchCandidates(e,t){const{point:i,filter:o,coordinateHelper:n}=e,a={...e,point:u(i[0],i[1],i[2],n.spatialReference.toJSON()),filter:o?.toJSON()};return this._workerHandle.invoke(a,t)}async updateTiles(e,t){const i={tiles:e.tiles,tileInfo:null!=e.tileInfo?e.tileInfo.toJSON():null,tileSize:e.tileSize};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("updateTiles",i,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}async applyEdits(e,t){const o=this._editId++,n={id:o};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("beginApplyEdits",n,t));const r=await this._updatingHandles.addPromise(a(e.result,t)),s={id:o,edits:{addedFeatures:r.addedFeatures?.map((({objectId:e})=>e)).filter(i)??[],deletedFeatures:r.deletedFeatures?.map((({objectId:e,globalId:t})=>({objectId:e,globalId:t})))??[],updatedFeatures:r.updatedFeatures?.map((({objectId:e})=>e)).filter(i)??[]}};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("endApplyEdits",s,t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}getDebugInfo(e){return this._workerHandle.invokeMethod("getDebugInfo",{},e)}async notifyElevationSourceChange(){await this._workerHandle.invokeMethod("notifyElevationSourceChange",{})}async notifySymbologyChange(){await this._workerHandle.invokeMethod("notifySymbologyChange",{})}async setSymbologySnappingSupported(e){await this._workerHandle.invokeMethod("setSymbologySnappingSupported",e)}async setSuspended(e){this._suspendController?.abort(),this._suspendController=new AbortController,await this._workerHandle.invokeMethod("setSuspended",e,this._suspendController.signal)}_convertConfiguration(e){return{filter:null!=e.filter?e.filter.toJSON():null,customParameters:e.customParameters,viewType:e.viewType}}_serviceInfoFromLayer(e){return"multipatch"===e.geometryType||"mesh"===e.geometryType?null:{url:e.parsedUrl?.path??"",fieldsIndex:e.fieldsIndex.toJSON(),geometryType:p.toJSON(e.geometryType),capabilities:e.capabilities,objectIdField:e.objectIdField,globalIdField:e.globalIdField,spatialReference:e.spatialReference.toJSON(),timeInfo:e.timeInfo?.toJSON()}}};e([r({constructOnly:!0})],h.prototype,"schedule",void 0),e([r({constructOnly:!0})],h.prototype,"hasZ",void 0),e([r({constructOnly:!0})],h.prototype,"elevationAlignPointsInFeatures",void 0),e([r({constructOnly:!0})],h.prototype,"queryForSymbologySnapping",void 0),e([r({readOnly:!0})],h.prototype,"updating",null),e([r({readOnly:!0})],h.prototype,"availability",void 0),e([r()],h.prototype,"_workerHandleUpdating",void 0),h=e([s("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorkerHandle")],h);class c extends l{constructor(e,t){super("FeatureServiceSnappingSourceWorker","fetchCandidates",{},e,{strategy:"dedicated",client:t})}}export{h as FeatureServiceSnappingSourceWorkerHandle};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{fromValues as e}from"../../sketch/normalizedPoint.js";import{DrapedEdgeSnappingCandidate as t}from"../candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as n}from"../candidates/EdgeSnappingCandidate.js";import{VertexSnappingCandidate as d}from"../candidates/VertexSnappingCandidate.js";function r({x:t,y:n,z:d}){return e(t,n,d??0)}function a(e,a){switch(e.type){case"edge":return e.draped?new t({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,getGroundElevation:a}):new n({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,isDraped:!1});case"vertex":return new d({targetPoint:r(e.target),objectId:e.objectId,isDraped:!1})}}function i(e){return null!=e&&"3d"===e.type?(t,n,d)=>e.elevationProvider.getElevation(t,n,d??0,e.spatialReference,"ground"):()=>null}export{a as convertSnappingCandidate,i as makeGetGroundElevation};
5
+ import{fromValues as e}from"../../sketch/normalizedPoint.js";import{DrapedEdgeSnappingCandidate as t}from"../candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as n}from"../candidates/EdgeSnappingCandidate.js";import{VertexSnappingCandidate as d}from"../candidates/VertexSnappingCandidate.js";function r({x:t,y:n,z:d}){return e(t,n,d??0)}function a(e,a){switch(e.type){case"edge":return e.draped?new t({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,getGroundElevation:a}):new n({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,isDraped:!1});case"vertex":return new d({targetPoint:r(e.target),objectId:e.objectId,isDraped:!1})}}function o(e,t){return null!=e&&"3d"===e.type?(n,d)=>e.elevationProvider.getElevation(n,d,0,t,"ground"):()=>null}export{a as convertSnappingCandidate,o as makeGetGroundElevation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s,spatialReference:n}=t;return new c(e,s,n)}return new a}class a{async alignCandidates(e,t){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s,o){this._elevationInfo=t,this._alignPointsInFeatures=s,this.spatialReference=o,this._alignmentsCache=new e(r),this._cacheVersion=0,this._metersPerVerticalUnit=n(o)}async alignCandidates(e,t){const s=this._elevationInfo;return null==s||"absolute-height"!==s.mode||s.featureExpressionInfo?this._alignComputedElevationCandidates(e,t):(this._alignAbsoluteElevationCandidates(e,s),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}_alignAbsoluteElevationCandidates(e,t){const{offset:s,unit:n}=t;if(null==s)return;const i=s*(o(n??"meters")/this._metersPerVerticalUnit);for(const o of e)switch(o.type){case"edge":o.start.z+=i,o.end.z+=i;continue;case"vertex":o.target.z+=i;continue}}async _alignComputedElevationCandidates(e,n){const o=new Map;for(const s of e)t(o,s.objectId,d).push(s);const[i,a,r]=this._prepareQuery(o),c=await this._alignPointsInFeatures(i,n);s(n);if(r!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n);this._applyCacheAndResponse(i,c,a);const{drapedObjectIds:l,failedObjectIds:h}=c,u=[];for(const t of e){const{objectId:e}=t;l.has(e)&&"edge"===t.type&&(t.draped=!0),h.has(e)||u.push(t)}return u}_prepareQuery(e){const t=[],s=[];for(const[n,o]of e){const e=[];for(const t of o)this._addToQueriesOrCachedResult(n,t.target,e,s),"edge"===t.type&&(this._addToQueriesOrCachedResult(n,t.start,e,s),this._addToQueriesOrCachedResult(n,t.end,e,s));0!==e.length&&t.push({objectId:n,points:e})}return[t,s,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=h(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new l(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=h(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class l{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function h(e,{x:t,y:s,z:n}){return`${e}-${t}-${s}-${n??0}}`}function d(){return[]}export{i as getSnappingCandidateElevationAligner};
5
+ import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(this._alignAbsoluteElevationCandidates(e,t,n),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}_alignAbsoluteElevationCandidates(e,t,s){const{offset:i,unit:a}=s;if(null==i)return;const r=n(t),c=i*(o(a??"meters")/r);for(const n of e)switch(n.type){case"edge":n.start.z+=c,n.end.z+=c;continue;case"vertex":n.target.z+=c;continue}}async _alignComputedElevationCandidates(e,n,o){const i=new Map;for(const s of e)t(i,s.objectId,d).push(s);const[a,r,c]=this._prepareQuery(i,n),l=await this._alignPointsInFeatures(a,o);s(o);if(c!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n,o);this._applyCacheAndResponse(a,l,r);const{drapedObjectIds:h,failedObjectIds:u}=l,p=[];for(const t of e){const{objectId:e}=t;h.has(e)&&"edge"===t.type&&(t.draped=!0),u.has(e)||p.push(t)}return p}_prepareQuery(e,t){const s=[],n=[];for(const[o,i]of e){const e=[];for(const t of i)this._addToQueriesOrCachedResult(o,t.target,e,n),"edge"===t.type&&(this._addToQueriesOrCachedResult(o,t.start,e,n),this._addToQueriesOrCachedResult(o,t.end,e,n));0!==e.length&&s.push({objectId:o,points:e})}return[{spatialReference:t,pointsInFeatures:s},n,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=h(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new l(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e.pointsInFeatures){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=h(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class l{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function h(e,{x:t,y:s,z:n,spatialReference:o}){return`${e}-${t}-${s}-${n??0}}-wkid:${o?.wkid}`}function d(){return[]}export{i as getSnappingCandidateElevationAligner};