@arcgis/core 4.30.0-next.20240213 → 4.30.0-next.20240215

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 (193) hide show
  1. package/TimeExtent.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/08ba549f9c4afc42a21c.js +1 -0
  4. package/assets/esri/core/workers/chunks/114afcee6a66415cd123.js +1 -0
  5. package/assets/esri/core/workers/chunks/1320562881294ce93806.js +1 -0
  6. package/assets/esri/core/workers/chunks/13451fa3e4b02ca2beb0.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a384f29cb3256401962a.js → 1629a8c2085dce59cd1b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/18512caeeb03b9759ab1.js +1 -0
  9. package/assets/esri/core/workers/chunks/{cc1c958aad790a44048b.js → 1ca28af7c516d8283bb0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1f8a0fb32b96e50f5909.js +1 -0
  11. package/assets/esri/core/workers/chunks/{abab3abb8ea7610d9fb8.js → 21e7a88478f5d15e0e71.js} +1 -1
  12. package/assets/esri/core/workers/chunks/24452a26b0c5322c7d2b.js +1 -0
  13. package/assets/esri/core/workers/chunks/25b88787ead0cc44cda4.js +1 -0
  14. package/assets/esri/core/workers/chunks/2649166d1a462c7f8338.js +1 -0
  15. package/assets/esri/core/workers/chunks/2c96771a365f8f70e996.js +1 -0
  16. package/assets/esri/core/workers/chunks/352e7f8d694f3f217a2d.js +1 -0
  17. package/assets/esri/core/workers/chunks/392214a3a1d712eda155.js +1 -0
  18. package/assets/esri/core/workers/chunks/397f15b5bce6838db084.js +1 -0
  19. package/assets/esri/core/workers/chunks/3bf281e979408b9363ed.js +1 -0
  20. package/assets/esri/core/workers/chunks/4edc667148d023b5b5af.js +1 -0
  21. package/assets/esri/core/workers/chunks/51e4f771bfe352967c97.js +1 -0
  22. package/assets/esri/core/workers/chunks/55cd747e06bb59d1a328.js +1 -0
  23. package/assets/esri/core/workers/chunks/5638d95e600ff271c5b1.js +1 -0
  24. package/assets/esri/core/workers/chunks/563d172caa15ea1b510d.js +1108 -0
  25. package/assets/esri/core/workers/chunks/58f088b08e12c5435dbc.js +1 -0
  26. package/assets/esri/core/workers/chunks/5aef1e898618f8dda2c9.js +1 -0
  27. package/assets/esri/core/workers/chunks/608be8ebf772aefc36a5.js +1 -0
  28. package/assets/esri/core/workers/chunks/64df2521b2814d2fb918.js +1 -0
  29. package/assets/esri/core/workers/chunks/65070fb591f6ef8313c3.js +1 -0
  30. package/assets/esri/core/workers/chunks/656ec8a14df0e4b68433.js +1 -0
  31. package/assets/esri/core/workers/chunks/6601fe99d587b9dff3c7.js +1 -0
  32. package/assets/esri/core/workers/chunks/{274e623323e24250ca46.js → 6ac424af4f2825fabceb.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{eb2d6f1ee63b40ae0736.js → 774b655498289b1b36bb.js} +1 -1
  34. package/assets/esri/core/workers/chunks/781bb63af571568358e3.js +1 -0
  35. package/assets/esri/core/workers/chunks/9e54d2cbe42f5552aaca.js +1 -0
  36. package/assets/esri/core/workers/chunks/{f03d62ab7806b68d0b62.js → 9fbf61675e2a5374f754.js} +1 -1
  37. package/assets/esri/core/workers/chunks/a5253543eae1708d11b9.js +1 -0
  38. package/assets/esri/core/workers/chunks/aa9b46bcb75c96731de3.js +1 -0
  39. package/assets/esri/core/workers/chunks/cfb8b6b5e9c21d582cf4.js +1 -0
  40. package/assets/esri/core/workers/chunks/d1b2372084c1e8c60f79.js +1 -0
  41. package/assets/esri/core/workers/chunks/{1c6914ded7db720f7bf7.js → daf6eab5dd198ca9a67b.js} +1 -1
  42. package/assets/esri/core/workers/chunks/e03edeaf3af46495449e.js +1 -0
  43. package/assets/esri/core/workers/chunks/e685214698fbc84276dd.js +1 -0
  44. package/assets/esri/core/workers/chunks/ebb294c82207f3ff9f04.js +1 -0
  45. package/assets/esri/core/workers/chunks/ec20e23aec9370df8a55.js +1 -0
  46. package/assets/esri/core/workers/chunks/{e4da908079417cc2f495.js → ee0c77889059815a31b2.js} +1 -1
  47. package/assets/esri/core/workers/chunks/f68b7bb88c444a7cbbd2.js +1 -0
  48. package/assets/esri/core/workers/chunks/f90bbebd2dc07a77ce09.js +1 -0
  49. package/assets/esri/core/workers/chunks/fa388680ff976a6b30f6.js +1 -0
  50. package/chunks/vec32.js +1 -1
  51. package/interfaces.d.ts +135 -68
  52. package/layers/WFSLayer.js +1 -1
  53. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  54. package/layers/graphics/applyEditsUtils.js +1 -1
  55. package/layers/graphics/editingSupport.js +1 -1
  56. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  57. package/layers/mixins/ArcGISImageService.js +1 -1
  58. package/layers/save/featureLayerUtils.js +1 -1
  59. package/layers/support/arcgisLayers.js +1 -1
  60. package/layers/support/fetchService.js +1 -1
  61. package/layers/support/fromPortalItem.js +1 -1
  62. package/networks/Network.js +1 -1
  63. package/package.json +1 -1
  64. package/portal/Portal.js +1 -1
  65. package/portal/PortalGroup.js +1 -1
  66. package/portal/PortalUser.js +1 -1
  67. package/portal/support/geometryServiceUtils.js +1 -1
  68. package/portal/support/layersLoader.js +1 -1
  69. package/portal/support/loadUtils.js +1 -1
  70. package/portal/support/portalLayers.js +1 -1
  71. package/renderers/visualVariables/SizeVariable.js +1 -1
  72. package/rest/knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js +1 -1
  73. package/rest/networks/support/Association.js +1 -1
  74. package/rest/places.js +1 -1
  75. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  76. package/rest/support/ImageSampleParameters.js +1 -1
  77. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  78. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  79. package/support/elevationInfoUtils.js +1 -1
  80. package/support/revision.js +1 -1
  81. package/symbols/cim/cimAnalyzer.js +1 -1
  82. package/symbols/cim/defaultCIMValues.js +1 -1
  83. package/symbols/cim/utils.js +1 -1
  84. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  85. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  86. package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
  87. package/views/2d/engine/webgl/definitions.js +1 -1
  88. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  90. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  91. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  92. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  93. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  94. package/views/2d/layers/features/Processor.js +1 -1
  95. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  96. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  97. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  98. package/views/2d/layers/features/schema/processor/VisualVariablesSchema.js +1 -1
  99. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
  100. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  101. package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
  102. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  103. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  104. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  105. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  106. package/views/3d/layers/SceneLayerView3D.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  108. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  109. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  110. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  111. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  112. package/views/3d/support/orientedBoundingBox.js +1 -1
  113. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  114. package/views/3d/terrain/OverlayRenderer.js +1 -1
  115. package/views/3d/webgl/RenderNode.js +1 -1
  116. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  117. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  118. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +9 -7
  119. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceConstants.js +5 -0
  120. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +8 -8
  121. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  122. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  123. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  124. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  125. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  126. package/views/3d/webgl-engine/lib/ObjectAndLayerIdRenderHelper.js +1 -1
  127. package/views/draw/DrawGraphicTool.js +1 -1
  128. package/views/draw/DrawOperation.js +1 -1
  129. package/views/draw/drawSurfaces.js +1 -1
  130. package/views/interactive/snapping/SnappingManager.js +1 -1
  131. package/views/interactive/snapping/SnappingOptions.js +1 -1
  132. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  133. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  134. package/views/layers/ImageryTileLayerView.js +1 -1
  135. package/webdoc/support/webdocLoadUtils.js +1 -1
  136. package/webdoc/support/webdocSaveUtils.js +1 -1
  137. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  138. package/widgets/Editor/EditorViewModel.js +1 -1
  139. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  140. package/widgets/Editor/UpdateWorkflow.js +1 -1
  141. package/widgets/Editor/components/FooterActions.js +1 -1
  142. package/widgets/Editor/support/EditorItem.js +1 -1
  143. package/widgets/Editor.js +1 -1
  144. package/widgets/FeatureForm.js +1 -1
  145. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  146. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  147. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  148. package/widgets/FeatureTable.js +1 -1
  149. package/widgets/Features/FeaturesViewModel.js +1 -1
  150. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  151. package/widgets/Print/PrintViewModel.js +1 -1
  152. package/widgets/Print.js +1 -1
  153. package/widgets/Search/support/locatorUtils.js +1 -1
  154. package/widgets/Sketch/SketchViewModel.js +1 -1
  155. package/assets/esri/core/workers/chunks/00b9e92f8df245a83921.js +0 -1
  156. package/assets/esri/core/workers/chunks/02a6c43ec17e7223fac5.js +0 -1
  157. package/assets/esri/core/workers/chunks/02ee044597c89c86b934.js +0 -1
  158. package/assets/esri/core/workers/chunks/05ebb9cec0e1826b283f.js +0 -1
  159. package/assets/esri/core/workers/chunks/143ccb14c9e915dd1412.js +0 -1
  160. package/assets/esri/core/workers/chunks/24649b410b757599a549.js +0 -1
  161. package/assets/esri/core/workers/chunks/24d19abc680b341d13bb.js +0 -1
  162. package/assets/esri/core/workers/chunks/2519b207894132d5ea91.js +0 -1
  163. package/assets/esri/core/workers/chunks/30f9b2a3417cbcfeecca.js +0 -1
  164. package/assets/esri/core/workers/chunks/42ab9c282bb267c3db03.js +0 -1
  165. package/assets/esri/core/workers/chunks/478815fc19b452d8317d.js +0 -1
  166. package/assets/esri/core/workers/chunks/49afeac45250b15b5f36.js +0 -1
  167. package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +0 -1
  168. package/assets/esri/core/workers/chunks/50cdc59426ba859027e2.js +0 -1
  169. package/assets/esri/core/workers/chunks/5401ec9c9fd62dcac6ec.js +0 -1
  170. package/assets/esri/core/workers/chunks/554d86df71821d671d2c.js +0 -1
  171. package/assets/esri/core/workers/chunks/58c5861d060c808813a1.js +0 -1
  172. package/assets/esri/core/workers/chunks/5dbb3ef6fdd25ac632ad.js +0 -1
  173. package/assets/esri/core/workers/chunks/61c4bb58ef9f2d99c75e.js +0 -1
  174. package/assets/esri/core/workers/chunks/6e50220f8e2d392e2855.js +0 -1
  175. package/assets/esri/core/workers/chunks/6fd8047741a0df006ddd.js +0 -1
  176. package/assets/esri/core/workers/chunks/7709248f59520aee6f51.js +0 -1
  177. package/assets/esri/core/workers/chunks/8852a64918caf80fc414.js +0 -1
  178. package/assets/esri/core/workers/chunks/8d119dc0a92ad3612daa.js +0 -1
  179. package/assets/esri/core/workers/chunks/94dfb80ab23dda92918b.js +0 -1
  180. package/assets/esri/core/workers/chunks/9ebbc75ba5c623a322aa.js +0 -1
  181. package/assets/esri/core/workers/chunks/a5babc10f47c24651d15.js +0 -1
  182. package/assets/esri/core/workers/chunks/a74c59cf5d1c4e63a4e1.js +0 -1
  183. package/assets/esri/core/workers/chunks/ada5d6fd70bd3e403442.js +0 -1
  184. package/assets/esri/core/workers/chunks/b95d69d84d60ac9828b9.js +0 -1
  185. package/assets/esri/core/workers/chunks/be562536212360943388.js +0 -1
  186. package/assets/esri/core/workers/chunks/ce823fc2d0e0095f398c.js +0 -1
  187. package/assets/esri/core/workers/chunks/d06d36815c2121484a13.js +0 -1
  188. package/assets/esri/core/workers/chunks/d5f06a7b0ea7951c8dd0.js +0 -1
  189. package/assets/esri/core/workers/chunks/ddc71fe66c7a49082920.js +0 -1
  190. package/assets/esri/core/workers/chunks/de6d54df7ae32694fd70.js +0 -1
  191. package/assets/esri/core/workers/chunks/f13c4b9692dad5802a32.js +0 -1106
  192. package/assets/esri/core/workers/chunks/f1e8f7d1a98b9e207b1b.js +0 -1
  193. package/assets/esri/core/workers/chunks/f9e9675f1c2287231653.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e 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{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{pointEquals as g,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as f}from"./DrawingMode.js";import{DrawManipulator as x}from"./DrawManipulator.js";import{createCoordinateHelper as b}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as C,sceneSnappingAtLocation as T}from"../interactive/dragEventPipeline.js";import{EditGeometry as S,Component as P}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as V}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as w}from"../interactive/sketch/constraints.js";import O from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as M}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";import{pointToConstraintSpace as j,constraintSpaceToPoint as H,getPointConstraint as G,getPolylineOrPolygonConstraint as k}from"../interactive/tooltip/constraintUtils.js";const Z="crosshair",A="progress";let L=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new m,this.constraintsEnabled=!1,this.constraintInfo=void 0,this._getPointConstraint=s(G),this._getPolylineOrPolygonConstraint=s(k),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new O,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,n="viewingMode"in e.state?e.state.viewingMode:v.Local,o="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=b(this.hasZ,this.hasM,i),this._editGeometryOperations=new V(new S(o,this.coordinateHelper)),this._snappingOperation=new I({view:e}),this.addHandles([p((()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this.constraint})),(({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&w(e),n.edgesEnabled=null==this.constraintInfo?.distance&&null==this.constraintInfo?.direction);if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{sync:!0,equals:(t,e)=>t.stagedPoint===e.stagedPoint&&r(t.constraint,e.constraint)}),p((()=>this.view.viewpoint),((t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()}))]),this._activeComponent=new P(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const s=this.segmentLabels;null!=s&&(s.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(p((()=>this.labelOptions.enabled),(t=>{s.visible=t}),c))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates)),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;g(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;g(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(g(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}})));const l=this._manipulator=new x({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(t=>this._onImmediateClick(t))),l.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),p((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{l.cursor=t}),c)]),E(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);null!=this.snappingManager&&this._updatingHandles.addPromise(a(this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e)))}))}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 t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}get constraint(){const{constraintInfo:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":return this._getPointConstraint(t.elevation,t.context);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t.distance,t.direction,t.elevation,t.context)}}set drawingMode(t){this._set("drawingMode",t??f)}get effectiveCursor(){return this.loading?A:this._hideDefaultCursor?null:this.cursor||Z}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);y(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return C(t,((t,e,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 M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t))).next(s),e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t))).next(T(this.view,this.elevationInfo)).next(...r).next((t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t)))}))}_createManipulatorDragPipelineFreehand(t){return C(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return C(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),this._processCursor(t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!e.hasZ())return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=l(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(t.pointerId)||n.grabbing||!n.interactive?i.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){const t=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!t.grabbing&&t.interactive?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const s=this._getSnappingContext(e);this._updatingHandles.addPromise(a(i.snap({point:n,scenePoint:o},r,s)))}_applyConstraints(t){const{constraint:e,constraintInfo:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=j(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=H(r,t,n);return null!=s&&"absolute-height"!==n.elevationInfo.mode&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null})}};function z(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([d()],L.prototype,"_hideDefaultCursor",void 0),t([d()],L.prototype,"_snappingOperation",void 0),t([d()],L.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],L.prototype,"graphic",void 0),t([d()],L.prototype,"constraintsEnabled",void 0),t([d()],L.prototype,"constraintInfo",void 0),t([d()],L.prototype,"constraint",null),t([d()],L.prototype,"constraintZ",void 0),t([d()],L.prototype,"defaultZ",void 0),t([d()],L.prototype,"isDraped",void 0),t([d({value:f})],L.prototype,"drawingMode",null),t([d({constructOnly:!0})],L.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:O})],L.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],L.prototype,"geometryType",void 0),t([d({constructOnly:!0})],L.prototype,"hasM",void 0),t([d({constructOnly:!0})],L.prototype,"hasZ",void 0),t([d()],L.prototype,"cursor",void 0),t([d()],L.prototype,"effectiveCursor",null),t([d()],L.prototype,"loading",void 0),t([d({constructOnly:!0})],L.prototype,"manipulators",void 0),t([d({constructOnly:!0})],L.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],L.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],L.prototype,"snappingVisualizer",void 0),t([d()],L.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],L.prototype,"cursorVertex",null),t([d({readOnly:!0})],L.prototype,"visualizationCursorVertex",null),t([d()],L.prototype,"committableVertex",null),t([d()],L.prototype,"firstVertex",void 0),t([d()],L.prototype,"lastVertex",void 0),t([d()],L.prototype,"secondToLastVertex",void 0),t([d()],L.prototype,"updating",null),t([d({constructOnly:!0})],L.prototype,"view",void 0),L=t([h("esri.views.draw.DrawOperation")],L);export{L as DrawOperation,Z as defaultCursor,A as defaultLoadingCursor};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e 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{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{pointEquals as g,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as f}from"./DrawingMode.js";import{DrawManipulator as x}from"./DrawManipulator.js";import{createCoordinateHelper as b}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as C,sceneSnappingAtLocation as T}from"../interactive/dragEventPipeline.js";import{EditGeometry as S,Component as P}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as V}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as w}from"../interactive/sketch/constraints.js";import O from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as M}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";import{pointToConstraintSpace as j,constraintSpaceToPoint as H,getPointConstraint as G,getPolylineOrPolygonConstraint as k}from"../interactive/tooltip/constraintUtils.js";const Z="crosshair",A="progress";let L=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new m,this.constraintsEnabled=!1,this.constraintInfo=void 0,this._getPointConstraint=s(G),this._getPolylineOrPolygonConstraint=s(k),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new O,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,n="viewingMode"in e.state?e.state.viewingMode:v.Local,o="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=b(this.hasZ,this.hasM,i),this._editGeometryOperations=new V(new S(o,this.coordinateHelper)),this._snappingOperation=new I({view:e}),this.addHandles([p((()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this.constraint})),(({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&w(e),n.constraintsActive=null!=this.constraintInfo?.distance||null!=this.constraintInfo?.direction);if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{sync:!0,equals:(t,e)=>t.stagedPoint===e.stagedPoint&&r(t.constraint,e.constraint)}),p((()=>this.view.viewpoint),((t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()}))]),this._activeComponent=new P(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const s=this.segmentLabels;null!=s&&(s.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(p((()=>this.labelOptions.enabled),(t=>{s.visible=t}),c))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates)),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;g(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;g(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(g(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}})));const l=this._manipulator=new x({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(t=>this._onImmediateClick(t))),l.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),p((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{l.cursor=t}),c)]),E(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);null!=this.snappingManager&&this._updatingHandles.addPromise(a(this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e)))}))}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 t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}get constraint(){const{constraintInfo:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":return this._getPointConstraint(t.elevation,t.context);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t.distance,t.direction,t.elevation,t.context)}}set drawingMode(t){this._set("drawingMode",t??f)}get effectiveCursor(){return this.loading?A:this._hideDefaultCursor?null:this.cursor||Z}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);y(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return C(t,((t,e,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 M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t))).next(s),e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t))).next(T(this.view,this.elevationInfo)).next(...r).next((t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t)))}))}_createManipulatorDragPipelineFreehand(t){return C(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return C(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),this._processCursor(t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=l(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(t.pointerId)||n.grabbing||!n.interactive?i.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){const t=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!t.grabbing&&t.interactive?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const s=this._getSnappingContext(e);this._updatingHandles.addPromise(a(i.snap({point:n,scenePoint:o},r,s)))}_applyConstraints(t){const{constraint:e,constraintInfo:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=j(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=H(r,t,n);return null!=s&&"absolute-height"!==n.elevationInfo.mode&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null})}};function z(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([d()],L.prototype,"_hideDefaultCursor",void 0),t([d()],L.prototype,"_snappingOperation",void 0),t([d()],L.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],L.prototype,"graphic",void 0),t([d()],L.prototype,"constraintsEnabled",void 0),t([d()],L.prototype,"constraintInfo",void 0),t([d()],L.prototype,"constraint",null),t([d()],L.prototype,"constraintZ",void 0),t([d()],L.prototype,"defaultZ",void 0),t([d()],L.prototype,"isDraped",void 0),t([d({value:f})],L.prototype,"drawingMode",null),t([d({constructOnly:!0})],L.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:O})],L.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],L.prototype,"geometryType",void 0),t([d({constructOnly:!0})],L.prototype,"hasM",void 0),t([d({constructOnly:!0})],L.prototype,"hasZ",void 0),t([d()],L.prototype,"cursor",void 0),t([d()],L.prototype,"effectiveCursor",null),t([d()],L.prototype,"loading",void 0),t([d({constructOnly:!0})],L.prototype,"manipulators",void 0),t([d({constructOnly:!0})],L.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],L.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],L.prototype,"snappingVisualizer",void 0),t([d()],L.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],L.prototype,"cursorVertex",null),t([d({readOnly:!0})],L.prototype,"visualizationCursorVertex",null),t([d()],L.prototype,"committableVertex",null),t([d()],L.prototype,"firstVertex",void 0),t([d()],L.prototype,"lastVertex",void 0),t([d()],L.prototype,"secondToLastVertex",void 0),t([d()],L.prototype,"updating",null),t([d({constructOnly:!0})],L.prototype,"view",void 0),L=t([h("esri.views.draw.DrawOperation")],L);export{L as DrawOperation,Z as defaultCursor,A 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.30/esri/copyright.txt for details.
4
4
  */
5
- import"../../geometry.js";import{createScreenPointArray as e,createScreenPoint as t}from"../../core/screenUtils.js";import{makeDehydratedPoint as s}from"../../layers/graphics/dehydratedPoint.js";import{clonePoint as r}from"../../layers/graphics/hydratedFeatures.js";import{getConvertedElevation as i,getZForElevationMode as n}from"../../support/elevationInfoUtils.js";import o from"../../geometry/SpatialReference.js";import a from"../../geometry/Point.js";class c{constructor(e,t,s,r=null){this._elevationInfo=e,this.defaultZ=t,this._view=s,this._excludeGraphics=r}screenToMap(t){if(null!=this.defaultZ)return this._view.sceneIntersectionHelper.intersectElevationFromScreen(e(t.x,t.y),this._elevationInfo,this.defaultZ,this._excludeGraphics);const s=this._view.sceneIntersectionHelper.intersectElevationFromScreen(e(t.x,t.y),this._elevationInfo,0,this._excludeGraphics);return null!=s&&(s.z=void 0),s}mapToScreen(e){const t=s(e.x,e.y,i(this._view,e,this._elevationInfo),e.spatialReference);return this._view.toScreen(t)}constrainZ(e){const{defaultZ:t}=this;return null!=t&&e.z!==t&&((e=r(e)).z=t),e}}class l{constructor(e,t,s=[]){this.view=e,this.elevationInfo=t,this.exclude=s}screenToMap(e){const t=this.view.toMap(e,{exclude:this.exclude,excludeHud:!0});return null!=t&&(t.z=n(t,this.view,this.elevationInfo)),t}mapToScreen(e){let t=e;return null!=this.elevationInfo&&(t=s(e.x,e.y,i(this.view,e,this.elevationInfo),e.spatialReference)),this.view.toScreen(t)}constrainZ(e){return e}}class h{constructor(e,t=!1,s=0){this.view=e,this.hasZ=t,this.defaultZ=s,this.mapToScreen=t=>e.toScreen(t),this.screenToMap=t?t=>{const r=e.toMap(t);return r.z=s,r}:t=>e.toMap(t)}constrainZ(e){const{defaultZ:t}=this;return this.hasZ&&e.z!==t&&((e=r(e)).z=t),e}}class u{screenToMap(e){const{x:t,y:s}=e;return new a({x:t,y:s,spatialReference:u.spatialReference})}mapToScreen(e){return t(e.x,e.y)}constrainZ(e){return e}}u.spatialReference=new o;export{c as ElevationDrawSurface,h as MapDrawSurface,l as SceneDrawSurface,u as ScreenDrawSurface};
5
+ import"../../geometry.js";import{createScreenPointArray as e,createScreenPoint as t}from"../../core/screenUtils.js";import{makeDehydratedPoint as r}from"../../layers/graphics/dehydratedPoint.js";import{clonePoint as s}from"../../layers/graphics/hydratedFeatures.js";import{getConvertedElevation as n,getZForElevationMode as i}from"../../support/elevationInfoUtils.js";import o from"../../geometry/SpatialReference.js";import a from"../../geometry/Point.js";class c{constructor(e,t,r,s=null){this._elevationInfo=e,this.defaultZ=t,this._view=r,this._excludeGraphics=s}screenToMap(t){const{defaultZ:r,_view:s}=this,n=s.sceneIntersectionHelper.intersectElevationFromScreen(e(t.x,t.y),this._elevationInfo,r??0,this._excludeGraphics);return null==r&&null!=n&&(n.z=void 0),n}mapToScreen(e){const t=r(e.x,e.y,n(this._view,e,this._elevationInfo),e.spatialReference);return this._view.toScreen(t)}constrainZ(e){const{defaultZ:t}=this;return null!=t&&e.z!==t&&((e=s(e)).z=t),e}}class l{constructor(e,t,r=[]){this.view=e,this.elevationInfo=t,this.exclude=r}screenToMap(e){const t=this.view.toMap(e,{exclude:this.exclude,excludeHud:!0});return null!=t&&(t.z=i(t,this.view,this.elevationInfo)),t}mapToScreen(e){let t=e;return null!=this.elevationInfo&&(t=r(e.x,e.y,n(this.view,e,this.elevationInfo),e.spatialReference)),this.view.toScreen(t)}constrainZ(e){return e}}class h{constructor(e,t=!1,r=0){this.view=e,this.hasZ=t,this.defaultZ=r,this.mapToScreen=t=>e.toScreen(t),this.screenToMap=t?t=>{const s=e.toMap(t);return s.z=r,s}:t=>e.toMap(t)}constrainZ(e){const{defaultZ:t}=this;return this.hasZ&&e.z!==t&&((e=s(e)).z=t),e}}class u{screenToMap(e){const{x:t,y:r}=e;return new a({x:t,y:r,spatialReference:u.spatialReference})}mapToScreen(e){return t(e.x,e.y)}constrainZ(e){return e}}u.spatialReference=new o;export{c as ElevationDrawSurface,h as MapDrawSurface,l as SceneDrawSurface,u as ScreenDrawSurface};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import n from"../../../core/Evented.js";import{isAborted as i}from"../../../core/promiseUtils.js";import{watch as s,sync as r,syncAndInitial as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{project as p,initializeProjection as c}from"../../../geometry/projection.js";import{absoluteHeightElevationInfo as h}from"../../../support/elevationInfoUtils.js";import{fromPoint as l,toElevationAlignedDehydratedPoint as u}from"../sketch/normalizedPoint.js";import{defaults as f}from"./Settings.js";import{SnappingDomain as _}from"./SnappingDomain.js";import{defaultSnappingEnginesFactory as g}from"./snappingFactory.js";import S from"./SnappingOptions.js";import{sortCandidatesInPlace as m,squaredScreenDistance as v}from"./snappingUtils.js";import{EdgeSnappingCandidate as y}from"./candidates/EdgeSnappingCandidate.js";import{IntersectionSnappingCandidate as C}from"./candidates/IntersectionSnappingCandidate.js";import{LineSnappingCandidate as P}from"./candidates/LineSnappingCandidate.js";import{vectorToScreenPoint as E}from"../support/viewUtils.js";let w=class extends(n.EventedMixin(e)){constructor(t){super(t),this.options=new S,this.snappingEnginesFactory=g,this._engines=[],this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=T.MAIN}initialize(){this.addHandles([s((()=>{const{effectiveFeatureEnabled:t,effectiveSelfEnabled:e,touchSensitivityMultiplier:n,distance:i,edgesEnabled:s}=this.options;return{effectiveFeatureEnabled:t,effectiveSelfEnabled:e,touchSensitivityMultiplier:n,distance:i,edgesEnabled:s}}),(()=>{this.doneSnapping(),this.emit("changed")}),r),s((()=>this.options),(t=>{for(const e of this._engines)e.options=t}),r),s((()=>({viewReady:this.view.ready,viewSpatialReference:this.view.spatialReference,snappingEnginesFactory:this.snappingEnginesFactory})),(({viewReady:t,snappingEnginesFactory:e})=>this._recreateEngines(t,e)),a)])}destroy(){this._destroyEngines()}get updating(){return this._engines.some((t=>t.updating))}_recreateEngines(t,e){if(this._destroyEngines(),!t)return;const{view:n,options:i}=this;this._engines=e(n,i)}_destroyEngines(){for(const t of this._engines)t.destroy();this._engines=[]}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:t,touchSensitivityMultiplier:e}=this.options,n=t*e;return n*n}get _squaredSatisfiesConstraintThreshold(){return f.satisfiesConstraintScreenThreshold*f.satisfiesConstraintScreenThreshold}snap(t){return j(t)?this._snapMultiPoint(t):this._snapSinglePoint(t)}update(t){const{point:e,context:n}=t;this._removeVisualization();const i=this._currentMainCandidate;if(null==i)return e;const s=this._selectUpdateInput(t);if(null==s)return e;const{spatialReference:r}=n,a=p(s,r);if(null==a)return e;const{view:o}=this,{elevationInfo:d,visualizer:c}=n,h=[],f=l(a,o,d),_=i.constraint.closestTo(f);if(!this._arePointsWithinScreenThreshold(f,_,n))return this._resetSnappingState(),e;i.targetPoint=_,h.push(...i.hints);for(const p of this._currentOtherActiveCandidates)p.targetPoint=_,h.push(...p.hints);return null!=c&&this.addHandles(c.draw(h,{spatialReference:r,elevationInfo:I(n),view:o,selfSnappingZ:n.selfSnappingZ}),M),u(_,o,e,n)}doneSnapping(){this._removeVisualization(),this._resetSnappingState()}_selectUpdateInput({point:t,scenePoint:e}){switch(this._currentSnappedType){case T.MAIN:return t;case T.SCENE:return e}}_resetSnappingState(){this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=T.MAIN}_removeVisualization(){this.removeHandles(M)}async _snapSinglePoint({point:t,context:e,signal:n}){const{view:i}=this,{elevationInfo:s}=e,r=l(t,i,s),a=await this._fetchCandidates(r,_.ALL,e,n);return this._createSnapResult(r,T.MAIN,a,i,t,e,n)}async _snapMultiPoint({point:t,scenePoint:e,context:n,signal:i}){const{view:s}=this,{coordinateHelper:r,elevationInfo:a,spatialReference:o}=n;await c(e.spatialReference,o);const d=p(e,o),h=l(d,s,a),u=await this._fetchCandidates(h,_.FEATURE,n,i);if(u.length>0){const t=await this._fetchCandidates(h,_.SELF,n,i);return this._createSnapResult(h,T.SCENE,[...u,...t],s,d,n,i)}const f=l(t,s,a),g=await this._fetchCandidates(f,_.SELF,n,i);return this._createSnapResult(f,T.MAIN,g,s,{z:r.hasZ()&&t.hasZ?t.z??0:void 0,m:r.hasM()&&t.hasM?t.m??0:void 0},n,i)}async _fetchCandidates(t,e,n,i){return(await Promise.all(this._engines.map((s=>s.fetchCandidates(t,e,n,i))))).flat()}_createSnapResult(t,e,n,s,r,a,o){return{get valid(){return!i(o)},apply:()=>{const{spatialReference:i}=a,{snappedPoint:o,hints:d}=this._processCandidates(t,e,n,a);return this._removeVisualization(),null!=a.visualizer&&this.addHandles(a.visualizer.draw(d,{spatialReference:i,elevationInfo:h,view:s,selfSnappingZ:a.selfSnappingZ}),M),u(o,s,r,a)}}}_processCandidates(t,e,n,i){if(n.length<1)return this.doneSnapping(),{snappedPoint:t,hints:[]};this._currentSnappedType!==e&&this._resetSnappingState(),m(t,n);const s=this._currentMainCandidate;if(null!=s){const r=this._findOldConstraintInNewCandidates(s,n);if(r>=0){if(!(n[r]instanceof C))return this._intersectWithOtherCandidates(r,n,t,e,i);if(this._arePointsWithinScreenThreshold(t,s.targetPoint,i))return this._updateSnappingCandidate(s,e,n,i)}}return this._intersectWithOtherCandidates(0,n,t,e,i)}_findOldConstraintInNewCandidates(t,e){return t instanceof C?this._findOldCandidateIndex(e,t.first)>=0&&this._findOldCandidateIndex(e,t.second)>=0?0:-1:this._findOldCandidateIndex(e,t)}_intersectWithOtherCandidates(t,e,n,i,s){const{coordinateHelper:r}=s,a=e[t],o=[];for(let d=0;d<e.length;++d){if(d===t)continue;const i=e[d],s=a.constraint.intersect(i.constraint);if(s)for(const t of s.closestPoints(a.targetPoint))o.push([new C(t,a,i,i.isDraped),this._squaredScreenDistance(n,t,r)])}return o.length>0&&(o.sort(((t,e)=>t[1]-e[1])),o[0][1]<this._squaredPointProximityThreshold(s.pointer))?this._updateSnappingCandidate(o[0][0],i,e,s):!this.options.edgesEnabled&&(a instanceof P||a instanceof y)?{snappedPoint:n,hints:[]}:this._updateSnappingCandidate(a,i,e,s)}_updateSnappingCandidate(t,e,n,i){this.doneSnapping(),this._currentMainCandidate=t,this._currentSnappedType=e;const s=this._currentMainCandidate.targetPoint,r=[];r.push(...t.hints);for(const a of n){if(t instanceof C){if(a.constraint.equals(t.first.constraint)||a.constraint.equals(t.second.constraint))continue}else if(a.constraint.equals(t.constraint))continue;const e=a.constraint.closestTo(s);this._squaredScreenDistance(e,s,i.coordinateHelper)<this._squaredSatisfiesConstraintThreshold&&(a.targetPoint=s,this._currentOtherActiveCandidates.push(a),r.push(...a.hints))}return{snappedPoint:s,hints:r}}_squaredPointProximityThreshold(t){return"touch"===t?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}_arePointsWithinScreenThreshold(t,e,n){return this._squaredScreenDistance(t,e,n.coordinateHelper)<this._squaredPointProximityThreshold(n.pointer)}_squaredScreenDistance(t,e,n){return v(this._toScreen(t,n),this._toScreen(e,n))}_toScreen(t,e){return E(t,e.spatialReference,h,this.view)}_findOldCandidateIndex(t,e){let n=-1;for(let i=0;i<t.length;++i)if(e.constraint.equals(t[i].constraint)){n=i;break}return n}get test(){return{visualizationsActive:this.hasHandles(M),engines:this._engines}}};var T;t([o({constructOnly:!0})],w.prototype,"view",void 0),t([o()],w.prototype,"options",void 0),t([o({readOnly:!0})],w.prototype,"updating",null),t([o()],w.prototype,"snappingEnginesFactory",void 0),t([o()],w.prototype,"_engines",void 0),t([o()],w.prototype,"_squaredMouseProximityThreshold",null),t([o()],w.prototype,"_squaredTouchProximityThreshold",null),t([o()],w.prototype,"_squaredSatisfiesConstraintThreshold",null),w=t([d("esri.views.interactive.snapping.SnappingManager")],w),function(t){t[t.MAIN=0]="MAIN",t[t.SCENE=1]="SCENE"}(T||(T={}));const M="visualization-handle";function j(t){return null!=t.scenePoint}function I({coordinateHelper:t,elevationInfo:e}){return t.hasZ()?h:e}export{w as SnappingManager};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import n from"../../../core/Evented.js";import{isAborted as i}from"../../../core/promiseUtils.js";import{watch as s,sync as r,syncAndInitial as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{project as p,initializeProjection as c}from"../../../geometry/projection.js";import{absoluteHeightElevationInfo as h}from"../../../support/elevationInfoUtils.js";import{fromPoint as l,toElevationAlignedDehydratedPoint as u}from"../sketch/normalizedPoint.js";import{defaults as f}from"./Settings.js";import{SnappingDomain as _}from"./SnappingDomain.js";import{defaultSnappingEnginesFactory as g}from"./snappingFactory.js";import m from"./SnappingOptions.js";import{sortCandidatesInPlace as S,squaredScreenDistance as v}from"./snappingUtils.js";import{EdgeSnappingCandidate as C}from"./candidates/EdgeSnappingCandidate.js";import{IntersectionSnappingCandidate as y}from"./candidates/IntersectionSnappingCandidate.js";import{LineSnappingCandidate as P}from"./candidates/LineSnappingCandidate.js";import{ParallelLineSnappingCandidate as E}from"./candidates/ParallelLineSnappingCandidate.js";import{RightAngleSnappingCandidate as w}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as T}from"../support/viewUtils.js";let j=class extends(n.EventedMixin(e)){constructor(t){super(t),this.options=new m,this.snappingEnginesFactory=g,this._engines=[],this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=M.MAIN}initialize(){this.addHandles([s((()=>{const{effectiveFeatureEnabled:t,effectiveSelfEnabled:e,touchSensitivityMultiplier:n,distance:i,constraintsActive:s}=this.options;return{effectiveFeatureEnabled:t,effectiveSelfEnabled:e,touchSensitivityMultiplier:n,distance:i,constraintsActive:s}}),(()=>{this.doneSnapping(),this.emit("changed")}),r),s((()=>this.options),(t=>{for(const e of this._engines)e.options=t}),r),s((()=>({viewReady:this.view.ready,viewSpatialReference:this.view.spatialReference,snappingEnginesFactory:this.snappingEnginesFactory})),(({viewReady:t,snappingEnginesFactory:e})=>this._recreateEngines(t,e)),a)])}destroy(){this._destroyEngines()}get updating(){return this._engines.some((t=>t.updating))}_recreateEngines(t,e){if(this._destroyEngines(),!t)return;const{view:n,options:i}=this;this._engines=e(n,i)}_destroyEngines(){for(const t of this._engines)t.destroy();this._engines=[]}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const{distance:t,touchSensitivityMultiplier:e}=this.options,n=t*e;return n*n}get _squaredSatisfiesConstraintThreshold(){return f.satisfiesConstraintScreenThreshold*f.satisfiesConstraintScreenThreshold}snap(t){return q(t)?this._snapMultiPoint(t):this._snapSinglePoint(t)}update(t){const{point:e,context:n}=t;this._removeVisualization();const i=this._currentMainCandidate;if(null==i)return e;const s=this._selectUpdateInput(t);if(null==s)return e;const{spatialReference:r}=n,a=p(s,r);if(null==a)return e;const{view:o}=this,{elevationInfo:d,visualizer:c}=n,h=[],f=l(a,o,d),_=i.constraint.closestTo(f);if(!this._arePointsWithinScreenThreshold(f,_,n))return this._resetSnappingState(),e;i.targetPoint=_,h.push(...i.hints);for(const p of this._currentOtherActiveCandidates)p.targetPoint=_,h.push(...p.hints);return null!=c&&this.addHandles(c.draw(h,{spatialReference:r,elevationInfo:x(n),view:o,selfSnappingZ:n.selfSnappingZ}),I),u(_,o,e,n)}doneSnapping(){this._removeVisualization(),this._resetSnappingState()}_selectUpdateInput({point:t,scenePoint:e}){switch(this._currentSnappedType){case M.MAIN:return t;case M.SCENE:return e}}_resetSnappingState(){this._currentMainCandidate=null,this._currentOtherActiveCandidates=[],this._currentSnappedType=M.MAIN}_removeVisualization(){this.removeHandles(I)}async _snapSinglePoint({point:t,context:e,signal:n}){const{view:i}=this,{elevationInfo:s}=e,r=l(t,i,s),a=await this._fetchCandidates(r,_.ALL,e,n);return this._createSnapResult(r,M.MAIN,a,i,t,e,n)}async _snapMultiPoint({point:t,scenePoint:e,context:n,signal:i}){const{view:s}=this,{coordinateHelper:r,elevationInfo:a,spatialReference:o}=n;await c(e.spatialReference,o);const d=p(e,o),h=l(d,s,a),u=await this._fetchCandidates(h,_.FEATURE,n,i);if(u.length>0){const t=await this._fetchCandidates(h,_.SELF,n,i);return this._createSnapResult(h,M.SCENE,[...u,...t],s,d,n,i)}const f=l(t,s,a),g=await this._fetchCandidates(f,_.SELF,n,i);return this._createSnapResult(f,M.MAIN,g,s,{z:r.hasZ()&&t.hasZ?t.z??0:void 0,m:r.hasM()&&t.hasM?t.m??0:void 0},n,i)}async _fetchCandidates(t,e,n,i){return(await Promise.all(this._engines.map((s=>s.fetchCandidates(t,e,n,i))))).flat()}_createSnapResult(t,e,n,s,r,a,o){return{get valid(){return!i(o)},apply:()=>{const{spatialReference:i}=a,{snappedPoint:o,hints:d}=this._processCandidates(t,e,n,a);return this._removeVisualization(),null!=a.visualizer&&this.addHandles(a.visualizer.draw(d,{spatialReference:i,elevationInfo:h,view:s,selfSnappingZ:a.selfSnappingZ}),I),u(o,s,r,a)}}}_processCandidates(t,e,n,i){if(n.length<1)return this.doneSnapping(),{snappedPoint:t,hints:[]};this._currentSnappedType!==e&&this._resetSnappingState(),S(t,n);const s=this._currentMainCandidate;if(null!=s){const r=this._findOldConstraintInNewCandidates(s,n);if(r>=0){if(!(n[r]instanceof y))return this._intersectWithOtherCandidates(r,n,t,e,i);if(this._arePointsWithinScreenThreshold(t,s.targetPoint,i))return this._updateSnappingCandidate(s,e,n,i)}}return this._intersectWithOtherCandidates(0,n,t,e,i)}_findOldConstraintInNewCandidates(t,e){return t instanceof y?this._findOldCandidateIndex(e,t.first)>=0&&this._findOldCandidateIndex(e,t.second)>=0?0:-1:this._findOldCandidateIndex(e,t)}_intersectWithOtherCandidates(t,e,n,i,s){const{coordinateHelper:r}=s,a=e[t],o=[];for(let d=0;d<e.length;++d){if(d===t)continue;const i=e[d],s=a.constraint.intersect(i.constraint);if(s)for(const t of s.closestPoints(a.targetPoint))o.push([new y(t,a,i,i.isDraped),this._squaredScreenDistance(n,t,r)])}return o.length>0&&(o.sort(((t,e)=>t[1]-e[1])),o[0][1]<this._squaredPointProximityThreshold(s.pointer))?this._updateSnappingCandidate(o[0][0],i,e,s):this.options.constraintsActive&&(a instanceof P||a instanceof C||a instanceof w||a instanceof E)?{snappedPoint:n,hints:[]}:this._updateSnappingCandidate(a,i,e,s)}_updateSnappingCandidate(t,e,n,i){this.doneSnapping(),this._currentMainCandidate=t,this._currentSnappedType=e;const s=this._currentMainCandidate.targetPoint,r=[];r.push(...t.hints);for(const a of n){if(t instanceof y){if(a.constraint.equals(t.first.constraint)||a.constraint.equals(t.second.constraint))continue}else if(a.constraint.equals(t.constraint))continue;const e=a.constraint.closestTo(s);this._squaredScreenDistance(e,s,i.coordinateHelper)<this._squaredSatisfiesConstraintThreshold&&(a.targetPoint=s,this._currentOtherActiveCandidates.push(a),r.push(...a.hints))}return{snappedPoint:s,hints:r}}_squaredPointProximityThreshold(t){return"touch"===t?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}_arePointsWithinScreenThreshold(t,e,n){return this._squaredScreenDistance(t,e,n.coordinateHelper)<this._squaredPointProximityThreshold(n.pointer)}_squaredScreenDistance(t,e,n){return v(this._toScreen(t,n),this._toScreen(e,n))}_toScreen(t,e){return T(t,e.spatialReference,h,this.view)}_findOldCandidateIndex(t,e){let n=-1;for(let i=0;i<t.length;++i)if(e.constraint.equals(t[i].constraint)){n=i;break}return n}get test(){return{visualizationsActive:this.hasHandles(I),engines:this._engines}}};var M;t([o({constructOnly:!0})],j.prototype,"view",void 0),t([o()],j.prototype,"options",void 0),t([o({readOnly:!0})],j.prototype,"updating",null),t([o()],j.prototype,"snappingEnginesFactory",void 0),t([o()],j.prototype,"_engines",void 0),t([o()],j.prototype,"_squaredMouseProximityThreshold",null),t([o()],j.prototype,"_squaredTouchProximityThreshold",null),t([o()],j.prototype,"_squaredSatisfiesConstraintThreshold",null),j=t([d("esri.views.interactive.snapping.SnappingManager")],j),function(t){t[t.MAIN=0]="MAIN",t[t.SCENE=1]="SCENE"}(M||(M={}));const I="visualization-handle";function q(t){return null!=t.scenePoint}function x({coordinateHelper:t,elevationInfo:e}){return t.hasZ()?h:e}export{j as SnappingManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import s from"../../../core/Logger.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import n from"./FeatureSnappingLayerSource.js";import{defaults as l}from"./Settings.js";let c=class extends t{constructor(e){super(e),this.enabled=!1,this.enabledToggled=!1,this.forceDisabled=!1,this.selfEnabled=!0,this.featureEnabled=!0,this.featureSources=new o,this.distance=l.distance,this.touchSensitivityMultiplier=l.touchSensitivityMultiplier,this.edgesEnabled=!0}get effectiveEnabled(){return!this.forceDisabled&&(this.enabledToggled?!this.enabled:this.enabled)}get effectiveSelfEnabled(){return this.effectiveEnabled&&this.selfEnabled}get effectiveFeatureEnabled(){return this.effectiveEnabled&&this.featureEnabled}get _effectiveFeatureSources(){const e=this.featureSources;e.some(p)&&s.getLogger(this).warnOnce("Do not configure SubtypeGroupLayer sources in SnappingOptions.featureSources directly. Create a FeatureSnappingLayerSource for each SubtypeSublayer.");const t=e.filter(f),i=this._get("_effectiveFeatureSources")?.filter(p)??new o;for(const r of t){const e=i.find((e=>e.layer===r.layer.parent));if(e)e.sublayerSources.includes(r)||e.sublayerSources.add(r);else if(r.layer.parent){const e=new n({layer:r.layer.parent});e.sublayerSources.add(r),i.add(e)}}for(const r of i){const e=r.sublayerSources.filter((e=>!t.includes(e)));r.sublayerSources.removeMany(e)}i.removeMany(i.filter((e=>0===e.sublayerSources.length)));const a=e.filter(d),l=this._get("_effectiveFeatureSources")??new o,{added:c,removed:u}=r(l.toArray(),[...a,...i]);return l.removeMany(u),l.addMany(c),l}};e([i()],c.prototype,"enabled",void 0),e([i()],c.prototype,"enabledToggled",void 0),e([i()],c.prototype,"forceDisabled",void 0),e([i()],c.prototype,"selfEnabled",void 0),e([i()],c.prototype,"featureEnabled",void 0),e([i({type:o.ofType(n)})],c.prototype,"featureSources",void 0),e([i()],c.prototype,"distance",void 0),e([i()],c.prototype,"touchSensitivityMultiplier",void 0),e([i()],c.prototype,"edgesEnabled",void 0),e([i({readOnly:!0})],c.prototype,"effectiveEnabled",null),e([i({readOnly:!0})],c.prototype,"effectiveSelfEnabled",null),e([i({readOnly:!0})],c.prototype,"effectiveFeatureEnabled",null),e([i({readOnly:!0})],c.prototype,"_effectiveFeatureSources",null),c=e([a("esri.views.interactive.snapping.SnappingOptions")],c);const u=c;function p(e){return"subtype-group"===e.layer.type}function d(e){return"subtype-group"!==e.layer.type}function f(e){return"subtype-sublayer"===e.layer.type}export{u as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import s from"../../../core/Logger.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import n from"./FeatureSnappingLayerSource.js";import{defaults as l}from"./Settings.js";let c=class extends t{constructor(e){super(e),this.enabled=!1,this.enabledToggled=!1,this.forceDisabled=!1,this.selfEnabled=!0,this.featureEnabled=!0,this.featureSources=new o,this.distance=l.distance,this.touchSensitivityMultiplier=l.touchSensitivityMultiplier,this.constraintsActive=!1}get effectiveEnabled(){return!this.forceDisabled&&(this.enabledToggled?!this.enabled:this.enabled)}get effectiveSelfEnabled(){return this.effectiveEnabled&&this.selfEnabled}get effectiveFeatureEnabled(){return this.effectiveEnabled&&this.featureEnabled}get _effectiveFeatureSources(){const e=this.featureSources;e.some(p)&&s.getLogger(this).warnOnce("Do not configure SubtypeGroupLayer sources in SnappingOptions.featureSources directly. Create a FeatureSnappingLayerSource for each SubtypeSublayer.");const t=e.filter(d),i=this._get("_effectiveFeatureSources")?.filter(p)??new o;for(const r of t){const e=i.find((e=>e.layer===r.layer.parent));if(e)e.sublayerSources.includes(r)||e.sublayerSources.add(r);else if(r.layer.parent){const e=new n({layer:r.layer.parent});e.sublayerSources.add(r),i.add(e)}}for(const r of i){const e=r.sublayerSources.filter((e=>!t.includes(e)));r.sublayerSources.removeMany(e)}i.removeMany(i.filter((e=>0===e.sublayerSources.length)));const a=e.filter(f),l=this._get("_effectiveFeatureSources")??new o,{added:c,removed:u}=r(l.toArray(),[...a,...i]);return l.removeMany(u),l.addMany(c),l}};e([i()],c.prototype,"enabled",void 0),e([i()],c.prototype,"enabledToggled",void 0),e([i()],c.prototype,"forceDisabled",void 0),e([i()],c.prototype,"selfEnabled",void 0),e([i()],c.prototype,"featureEnabled",void 0),e([i({type:o.ofType(n)})],c.prototype,"featureSources",void 0),e([i()],c.prototype,"distance",void 0),e([i()],c.prototype,"touchSensitivityMultiplier",void 0),e([i()],c.prototype,"constraintsActive",void 0),e([i({readOnly:!0})],c.prototype,"effectiveEnabled",null),e([i({readOnly:!0})],c.prototype,"effectiveSelfEnabled",null),e([i({readOnly:!0})],c.prototype,"effectiveFeatureEnabled",null),e([i({readOnly:!0})],c.prototype,"_effectiveFeatureSources",null),c=e([a("esri.views.interactive.snapping.SnappingOptions")],c);const u=c;function p(e){return"subtype-group"===e.layer.type}function f(e){return"subtype-group"!==e.layer.type}function d(e){return"subtype-sublayer"===e.layer.type}export{u 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.30/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{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 d,sync as u,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.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 g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as _}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.layerSource.sublayerSources.some((e=>e.enabled&&e.layer.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,d=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&&d.push(r),i&&d.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&&(d.push(e),d.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&d.push(e)}if(n){const e=s.get(n)?.name??n;e&&d.push(e)}return new Set(d)}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||t.destroyed)this._tilesOfInterest=new H({layer:this._layer}),e=this._workerHandle=new I;else switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new I;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new _({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),d((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}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))),u),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};
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 d,sync as u,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.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 g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as _}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.layerSource.sublayerSources.some((e=>e.enabled&&e.layer.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,d=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&&d.push(r),i&&d.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&&(d.push(e),d.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&d.push(e)}if(n){const e=s.get(n)?.name??n;e&&d.push(e)}return new Set(d)}get configuration(){const{view:e}=this,{apiKey:t,customParameters:r}=this._layer,i=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:t?{...r,token:t}:r,viewType:i}}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||t.destroyed)this._tilesOfInterest=new H({layer:this._layer}),e=this._workerHandle=new I;else switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new I;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new _({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),d((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}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))),u),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.30/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/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.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 g from"../../../../../rest/support/Query.js";import f 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?f.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,p.fromJSON(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?g.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/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import u from"../../../../../geometry/SpatialReference.js";import p from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import g from"../../../../../rest/support/Query.js";import f 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=u.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new p({...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:u.fromJSON(e.serviceInfo.spatialReference),customParameters:e.configuration.customParameters});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?f.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,u.fromJSON(e.point.spatialReference)??u.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?g.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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import r from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as s}from"../../layers/support/commonProperties.js";import{projectDatasetExtent as a,getDefaultDatumTransformationForDataset as n}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as l}from"./support/popupUtils.js";const p=p=>{let u=class extends p{constructor(){super(...arguments),this._rasterFieldPrefix="Raster.",this.layer=null,this.view=null,this.tileInfo=null}get fullExtent(){return this._getfullExtent()}_getfullExtent(){return a(this.layer.serviceRasterInfo,this.view.spatialReference)}get hasTilingEffects(){return!!(this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment)}get datumTransformation(){return n(this.layer.fullExtent,this.view.spatialReference,!0)}supportsSpatialReference(e){return!!a(this.layer.serviceRasterInfo,e)}async fetchPopupFeaturesAtLocation(e,i){const{layer:o}=this;if(!e)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:o});const{popupEnabled:s}=o,a=l(o,i);if(!s||null==a)throw new r("imageryTileLayerView:fetchPopupFeatures","Missing required popupTemplate or popupEnabled",{popupEnabled:s,popupTemplate:a});const n=[],{value:p,magdirValue:u,processedValue:c}=await o.identify(e,{timeExtent:this.timeExtent,signal:i?.signal});let f="";if(p&&p.length){f="imagery-tile"===o.type&&o.hasStandardTime()&&null!=p[0]?p.map((e=>o.getStandardTimeValue(e))).join(", "):p.join(", ");const e={ObjectId:0},r="Raster.ServicePixelValue";e[r]="imagery-tile"===o.type&&"Function"===o.raster.datasetFormat?c?.join(", "):f,e[r+".Raw"]=f;const i=o.serviceRasterInfo.attributeTable;if(null!=i){const{fields:t,features:r}=i,o=t.find((({name:e})=>"value"===e.toLowerCase())),s=o?r.find((e=>String(e.attributes[o.name])===f)):null;if(s)for(const i in s.attributes)if(s.attributes.hasOwnProperty(i)){e[this._rasterFieldPrefix+i]=s.attributes[i]}}const s=o.serviceRasterInfo.dataType;"vector-magdir"!==s&&"vector-uv"!==s||(e["Raster.Magnitude"]=u?.[0],e["Raster.Direction"]=u?.[1]);const a=new t(this.fullExtent.clone(),null,e);a.layer=o,a.sourceLayer=a.layer,n.push(a)}return n}};return e([i()],u.prototype,"layer",void 0),e([i(s)],u.prototype,"timeExtent",void 0),e([i()],u.prototype,"view",void 0),e([i()],u.prototype,"fullExtent",null),e([i()],u.prototype,"tileInfo",void 0),e([i({readOnly:!0})],u.prototype,"hasTilingEffects",null),e([i()],u.prototype,"datumTransformation",null),u=e([o("esri.views.layers.ImageryTileLayerView")],u),u};export{p as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import r from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as s}from"../../layers/support/commonProperties.js";import{projectDatasetExtent as a,getDefaultDatumTransformationForDataset as n}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as l}from"./support/popupUtils.js";const p=p=>{let u=class extends p{constructor(){super(...arguments),this._rasterFieldPrefix="Raster.",this.layer=null,this.view=null,this.tileInfo=null}get fullExtent(){return this._getfullExtent()}_getfullExtent(){return a(this.layer.serviceRasterInfo,this.view.spatialReference)}get hasTilingEffects(){return!!(this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment)}get datumTransformation(){return n(this.layer.fullExtent,this.view.spatialReference,!0)}supportsSpatialReference(e){return!!a(this.layer.serviceRasterInfo,e)}async fetchPopupFeaturesAtLocation(e,i){const{layer:o}=this;if(!e)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:o});const{popupEnabled:s}=o,a=l(o,i);if(!s||null==a)throw new r("imageryTileLayerView:fetchPopupFeatures","Missing required popupTemplate or popupEnabled",{popupEnabled:s,popupTemplate:a});const n=[],{value:p,magdirValue:u,processedValue:c}=await o.identify(e,{timeExtent:this.timeExtent,signal:i?.signal});let m="";if(p&&p.length){m="imagery-tile"===o.type&&o.hasStandardTime()&&null!=p[0]?p.map((e=>o.getStandardTimeValue(e))).join(", "):p.join(", ");const e={ObjectId:0},r="Raster.ServicePixelValue";e[r]="imagery-tile"===o.type&&"Function"===o.raster.datasetFormat?c?.join(", "):m,e[r+".Raw"]=m;const i=o.serviceRasterInfo.attributeTable;if(null!=i){const{fields:t,features:r}=i,o=t.find((({name:e})=>"value"===e.toLowerCase())),s=o?r.find((e=>String(e.attributes[o.name])===m)):null;if(s)for(const i in s.attributes)if(s.attributes.hasOwnProperty(i)){e[this._rasterFieldPrefix+i]=s.attributes[i]}}const s=o.serviceRasterInfo.dataType;"vector-magdir"!==s&&"vector-uv"!==s||(e["Raster.Magnitude"]=u?.[0],e["Raster.Direction"]=u?.[1]);const a=new t({geometry:this.fullExtent.clone(),attributes:e,layer:o,sourceLayer:o});n.push(a)}return n}};return e([i()],u.prototype,"layer",void 0),e([i(s)],u.prototype,"timeExtent",void 0),e([i()],u.prototype,"view",void 0),e([i()],u.prototype,"fullExtent",null),e([i()],u.prototype,"tileInfo",void 0),e([i({readOnly:!0})],u.prototype,"hasTilingEffects",null),e([i()],u.prototype,"datumTransformation",null),u=e([o("esri.views.layers.ImageryTileLayerView")],u),u};export{p 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.30/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Viewpoint.js";import t from"../../core/Error.js";import r from"../../core/Logger.js";import{geographicToWebMercator as o}from"../../geometry/support/webMercatorUtils.js";import n from"../../portal/Portal.js";import{createForItemRead as i}from"../../portal/support/jsonContext.js";import{project as a}from"../../rest/geometryService/project.js";import s from"../../rest/support/ProjectParameters.js";function p(e,t){return t.resourceInfo?l(t,t.resourceInfo,{origin:e.origin}):t.portalItem?.id?c(e,t,t.portalItem):Promise.resolve()}function l(e,t,r){const o={context:{...r,layerContainerType:"operational-layers"}};return e.portalItem&&(o.context.portal=e.portalItem.portal||n.getDefault()),import("../../layers/support/layersCreator.js").then((({populateOperationalLayers:r})=>{const n=[],i=t.operationalLayers;i?.length&&n.push(r(e.layers,i,o));const a={...o,context:{...o.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=t.tables;return s?.length&&n.push(r(e.tables,s,a)),Promise.allSettled(n).then((()=>{}))}))}async function c(e,o,n){if(await n.load().catch((r=>{throw new t(`${e.name}:load-portal-item`,"Failed to load portal item",{error:r})})),n.type!==e.itemType)throw new t(`${e.name}:invalid-portal-item`,`Invalid portal item type '${n.type}', expected '${e.itemType}'`,{type:n.type});const a=await n.fetchData();o.resourceInfo=a;const s=i(n,e.origin);await m(e,o,a,s),o.resourceReferences={portalItem:n,paths:s.readResourcePaths};const p=await f(o.initialViewProperties,n,r.getLogger(o));if(p){const t=o.initialViewProperties?.clone()??e.createInitialViewProperties();t.viewpoint=p,o.initialViewProperties=t}}function m(e,t,r,o){const n=u(e,r);return t.read(n,o),l(t,n,o)}function u(e,t){const r=e.parseVersion(t.version||"",e.name);return e.currentVersion.validate(r),t.version=`${r.major}.${r.minor}`,t}async function f(t,r,o){const n=t?.viewpoint?.targetGeometry;if(n)return null;const i=await y(t,r,o);if(!i)return null;return new e({targetGeometry:i})}async function y(e,t,r){const n=e?.spatialReference,i=t?.extent;if(!n||!i)return null;if(n.isWGS84)return i.clone();if(n.isWebMercator)return o(i);const{getGeometryServiceURL:p}=await import("../../portal/support/geometryServiceUtils.js");try{const e=await p(t),r=new s;r.geometries=[i],r.outSpatialReference=n;return(await a(e,r))[0]}catch(l){r.error("Error projecting item's extent:",l)}return null}export{p as loadFromSource};
5
+ import e from"../../Viewpoint.js";import t from"../../core/Error.js";import r from"../../core/Logger.js";import{geographicToWebMercator as o}from"../../geometry/support/webMercatorUtils.js";import n from"../../portal/Portal.js";import{createForItemRead as i}from"../../portal/support/jsonContext.js";import{project as a}from"../../rest/geometryService/project.js";import s from"../../rest/support/ProjectParameters.js";function p(e,t){return t.resourceInfo?l(t,t.resourceInfo,{origin:e.origin}):t.portalItem?.id?c(e,t,t.portalItem):Promise.resolve()}function l(e,t,r){const o={context:{...r,layerContainerType:"operational-layers"}};return e.portalItem&&(o.context.portal=e.portalItem.portal||n.getDefault()),import("../../layers/support/layersCreator.js").then((({populateOperationalLayers:r})=>{const n=[],i=t.operationalLayers;i?.length&&n.push(r(e.layers,i,o));const a={...o,context:{...o.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=t.tables;return s?.length&&n.push(r(e.tables,s,a)),Promise.allSettled(n).then((()=>{}))}))}async function c(e,o,n){if(await n.load().catch((r=>{throw new t(`${e.name}:load-portal-item`,"Failed to load portal item",{error:r})})),n.type!==e.itemType)throw new t(`${e.name}:invalid-portal-item`,`Invalid portal item type '${n.type}', expected '${e.itemType}'`,{type:n.type});const a=await n.fetchData();o.resourceInfo=a;const s=i(n,e.origin);await m(e,o,a,s),o.resourceReferences={portalItem:n,paths:s.readResourcePaths};const p=await f(o.initialViewProperties,n,r.getLogger(o));if(p){const t=o.initialViewProperties?.clone()??e.createInitialViewProperties();t.viewpoint=p,o.initialViewProperties=t}}function m(e,t,r,o){const n=u(e,r);return t.read(n,o),l(t,n,o)}function u(e,t){const r=e.parseVersion(t.version||"",e.name);return e.currentVersion.validate(r),t.version=`${r.major}.${r.minor}`,t}async function f(t,r,o){const n=t?.viewpoint?.targetGeometry;if(n)return null;const i=await y(t,r,o);if(!i)return null;return new e({targetGeometry:i})}async function y(e,t,r){const n=e?.spatialReference,i=t?.extent;if(!n||!i)return null;if(n.isWGS84)return i.clone();if(n.isWebMercator)return o(i);const{getGeometryServiceURL:p}=await import("../../portal/support/geometryServiceUtils.js");try{const e=await p(t),r=new s({geometries:[i],outSpatialReference:n});return(await a(e,r))[0]}catch(l){r.error("Error projecting item's extent:",l)}return null}export{p as loadFromSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as a,urlToObject as o}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as m}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as w,removeTypeKeyword as y,addTypeKeyword as g,hasTypeKeyword as h}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as v,findSpatialReference as R,isDeveloperBasemapLayer as j}from"../../support/basemapUtils.js";import{saveResources as P}from"./resourceUtils.js";import{validateSaveAPIKey as I}from"./saveAPIKeyUtils.js";import{beforeSave as W,evaluateWriteErrors as S}from"./saveUtils.js";const A=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function O(e,t,a){a??={},T(e,t),await r((()=>!t.updatingFromView)),await t.load(),await L(t),await W(t),await D(e,t);const o=t.portalItem,i=d(o,"web-map",!0),n=t.write({},i);return await Promise.all(i.resources.pendingOperations),S(i,{errorName:`${e.name}:save`},a),await V(t,o),await we(e,t,o,n,i),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,i)]),o}async function U(e,t,a,o){o??={};const i=E(e,a);await r((()=>!t.updatingFromView)),await t.load(),C(e,t),await L(t),await W(t),await D(e,t);const n=d(i,"web-map",!0),s=t.write({},n);await Promise.all(n.resources.pendingOperations),S(n,{errorName:`${e.name}:save`},o),await Y(t,i);const l=t.getThumbnailState();return await ye(e,t,i,s,n,o)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,n)]),i}function T(t,r){if(!r.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");I(r.portalItem),M(t,r.portalItem)}function M(t,r){if(r.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}function C(t,r){const a=r.allLayers.filter((e=>"unsupported"===e.type&&"KnowledgeGraphLayer"===e.resourceInfo?.layerType));if(a.length)throw new e(`${t.name}:save-as-invalid-configuration`,`Failed to save a copy of ${t.name} to prevent persisting invalid configuration. See 'details.layers'`,{layers:a.toArray()})}async function D(t,a){if(!a.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let o=null;if(await r((()=>{const e=R(a.initialViewProperties,a.basemap);return o=e.spatialReference,!e.updating})),!s(o,a.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:a.initialViewProperties.spatialReference,actual:o})}function E(e,t){let r=f.from(t);return r.id&&(r=r.clone(),r.id=null),r.type||(r.type=e.itemType),r.portal||(r.portal=u.getDefault()),I(r),M(e,r),r}function L(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function V(e,t){t.extent=await ce(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Z(e,t)}const G=w.JSAPI,$="CollectorDisabled",k="Collector",B="Data Editing",N="OfflineDisabled",x="Offline",K="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",J="Offline Map Areas",q="FieldMapsDisabled",z=w.DEVELOPER_BASEMAP,Q="UtilityNetwork",X="IPS";async function Y(e,t){y(t,$),y(t,q),y(t,w.METADATA),y(t,N),y(t,J),y(t,H),y(t,K),y(t,F),await V(e,t)}async function Z(e,t){g(t,G),await ee(e),oe(e,t),ie(e,t),ne(e,t),se(e,t),le(e,t),pe(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}function ee(e){const t=te(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function te(e){return e.allLayers.concat(e.allTables)}function re(e){return te(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function ae(e){return te(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&fe(e,t)))}function oe(e,t){h(t,$)||h(t,K)||h(t,F)||h(t,H)||!re(e)?y(t,k):g(t,k)}function ie(e,t){re(e)?g(t,B):y(t,B)}function ne(e,t){!h(t,N)&&ae(e)?g(t,x):y(t,x)}function se(e,t){v(e.basemap)?g(t,z):y(t,z)}function le(e,t){e.utilityNetworks?.length?g(t,Q):y(t,Q)}function pe(e,t){e.ipsInfo?g(t,X):y(t,X)}async function ce(e,t){const r=t.clone().normalize();let a;if(r.length>1)for(const o of r)a?o.width>a.width&&(a=o):a=o;else a=r[0];return me(e,a)}async function me(e,t){const r=t.spatialReference;if(r.isWGS84)return t.clone();if(r.isWebMercator)return l(t);const{getGeometryServiceURL:a}=await import("../../portal/support/geometryServiceUtils.js"),o=await a(e),i=new b;i.geometries=[t],i.outSpatialReference=n.WGS84;return(await _(o,i))[0]}function ue(e){return m(e)||"map-notes"===e.type||"route"===e.type}function fe(e,t){return c(t)&&t.capabilities.operations.supportsSync||ue(t)&&!t.portalItem||("tile"===t.type||"vector-tile"===t.type)&&(t.capabilities.operations.supportsExportTiles||de(t)||j(t))&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function de(e){return"tile"===e.type&&(p(e.url)&&A.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function we(e,t,r,a,o){await r.update({data:a}),_e(e,t,r,a,o)}async function ye(t,r,a,o,i,n){const s=r.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=a.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await ge(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await he(a,l,o,n);return r.portalItem=a,_e(t,r,a,o,i),u}async function ge(e,t){const{item:r,authenticated:a}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(a||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function he(e,t,r,o){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=o;let p=!1;if(l&&n?.id&&a(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const a=e.toJSON();await e.load(),e.read(a),await e.update({data:r})}else await(i.user?.addItem({item:e,folder:s,data:r}));return p}function _e(e,r,a,n,s){t.prototype.read.call(r,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:a.itemUrl?o(a.itemUrl):void 0}),i(s),r.resourceInfo=n}export{O as save,U as saveAs};
5
+ import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as a,urlToObject as o}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as m}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as w,removeTypeKeyword as y,addTypeKeyword as g,hasTypeKeyword as h}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as v,findSpatialReference as R,isDeveloperBasemapLayer as j}from"../../support/basemapUtils.js";import{saveResources as P}from"./resourceUtils.js";import{validateSaveAPIKey as I}from"./saveAPIKeyUtils.js";import{beforeSave as W,evaluateWriteErrors as S}from"./saveUtils.js";const A=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function O(e,t,a){a??={},T(e,t),await r((()=>!t.updatingFromView)),await t.load(),await L(t),await W(t),await D(e,t);const o=t.portalItem,i=d(o,"web-map",!0),n=t.write({},i);return await Promise.all(i.resources.pendingOperations),S(i,{errorName:`${e.name}:save`},a),await V(t,o),await we(e,t,o,n,i),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,i)]),o}async function U(e,t,a,o){o??={};const i=E(e,a);await r((()=>!t.updatingFromView)),await t.load(),C(e,t),await L(t),await W(t),await D(e,t);const n=d(i,"web-map",!0),s=t.write({},n);await Promise.all(n.resources.pendingOperations),S(n,{errorName:`${e.name}:save`},o),await Y(t,i);const l=t.getThumbnailState();return await ye(e,t,i,s,n,o)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,n)]),i}function T(t,r){if(!r.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");I(r.portalItem),M(t,r.portalItem)}function M(t,r){if(r.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}function C(t,r){const a=r.allLayers.filter((e=>"unsupported"===e.type&&"KnowledgeGraphLayer"===e.resourceInfo?.layerType));if(a.length)throw new e(`${t.name}:save-as-invalid-configuration`,`Failed to save a copy of ${t.name} to prevent persisting invalid configuration. See 'details.layers'`,{layers:a.toArray()})}async function D(t,a){if(!a.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let o=null;if(await r((()=>{const e=R(a.initialViewProperties,a.basemap);return o=e.spatialReference,!e.updating})),!s(o,a.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:a.initialViewProperties.spatialReference,actual:o})}function E(e,t){let r=f.from(t);return r.id&&(r=r.clone(),r.id=null),r.type||(r.type=e.itemType),r.portal||(r.portal=u.getDefault()),I(r),M(e,r),r}function L(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function V(e,t){t.extent=await ce(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Z(e,t)}const G=w.JSAPI,$="CollectorDisabled",k="Collector",B="Data Editing",N="OfflineDisabled",x="Offline",K="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",J="Offline Map Areas",q="FieldMapsDisabled",z=w.DEVELOPER_BASEMAP,Q="UtilityNetwork",X="IPS";async function Y(e,t){y(t,$),y(t,q),y(t,w.METADATA),y(t,N),y(t,J),y(t,H),y(t,K),y(t,F),await V(e,t)}async function Z(e,t){g(t,G),await ee(e),oe(e,t),ie(e,t),ne(e,t),se(e,t),le(e,t),pe(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}function ee(e){const t=te(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function te(e){return e.allLayers.concat(e.allTables)}function re(e){return te(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function ae(e){return te(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&fe(e,t)))}function oe(e,t){h(t,$)||h(t,K)||h(t,F)||h(t,H)||!re(e)?y(t,k):g(t,k)}function ie(e,t){re(e)?g(t,B):y(t,B)}function ne(e,t){!h(t,N)&&ae(e)?g(t,x):y(t,x)}function se(e,t){v(e.basemap)?g(t,z):y(t,z)}function le(e,t){e.utilityNetworks?.length?g(t,Q):y(t,Q)}function pe(e,t){e.ipsInfo?g(t,X):y(t,X)}async function ce(e,t){const r=t.clone().normalize();let a;if(r.length>1)for(const o of r)a?o.width>a.width&&(a=o):a=o;else a=r[0];return me(e,a)}async function me(e,t){const r=t.spatialReference;if(r.isWGS84)return t.clone();if(r.isWebMercator)return l(t);const{getGeometryServiceURL:a}=await import("../../portal/support/geometryServiceUtils.js"),o=await a(e),i=new b({geometries:[t],outSpatialReference:n.WGS84});return(await _(o,i))[0]}function ue(e){return m(e)||"map-notes"===e.type||"route"===e.type}function fe(e,t){return c(t)&&t.capabilities.operations.supportsSync||ue(t)&&!t.portalItem||("tile"===t.type||"vector-tile"===t.type)&&(t.capabilities.operations.supportsExportTiles||de(t)||j(t))&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function de(e){return"tile"===e.type&&(p(e.url)&&A.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function we(e,t,r,a,o){await r.update({data:a}),_e(e,t,r,a,o)}async function ye(t,r,a,o,i,n){const s=r.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=a.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await ge(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await he(a,l,o,n);return r.portalItem=a,_e(t,r,a,o,i),u}async function ge(e,t){const{item:r,authenticated:a}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(a||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function he(e,t,r,o){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=o;let p=!1;if(l&&n?.id&&a(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const a=e.toJSON();await e.load(),e.read(a),await e.update({data:r})}else await(i.user?.addItem({item:e,folder:s,data:r}));return p}function _e(e,r,a,n,s){t.prototype.read.call(r,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:a.itemUrl?o(a.itemUrl):void 0}),i(s),r.resourceInfo=n}export{O as save,U as saveAs};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,initial as h,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import g from"../../layers/GraphicsLayer.js";import{isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/sketch/SketchOptions.js";import _ from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as M}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as F,handleModelUpload as I}from"./modelUploadUtils.js";import k from"./Workflow.js";import{startCreatingNewFeature as b,findLayerInfo as V,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as H,getVisualVariableAttributes as S,startUpdatingFeature as j,createWorkflowSteps as C,avoidFeatureTemplateSelectionWithOnlyOneItem as U,showProgressCursor as O,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateFeaturesWorkflow as D}from"./workflowUtils.js";import G from"../FeatureForm/FeatureFormViewModel.js";import L from"../Sketch/SketchViewModel.js";var P;const T=Symbol(),W=Symbol(),x=Symbol();let N=P=class extends k{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new G,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>A(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.numPendingFeatures>0)return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return this.data.editorItem?.capabilities.create.attachments.enabled??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)},sketchViewModel:this._sketchViewModel}}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this._sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,snappingManager:n,startAt:o,viewModel:l}=e,c=e.sketchOptions??new v,d=r?.layer,h=d?l.findEditorItemForLayer(d):void 0,p=new P({data:new M({creationInfo:r,editorItem:h,parent:s,sketchOptions:c,snappingManager:n,viewModel:l}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=p._attachmentFileInfos;if(n){const e=Z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const l=await a(s,{addFeatures:r});if(o.size>0){const e=l?.addFeatureResults??[];await t(s,R(r,e,s,o))}}});return p._set("steps",this._createWorkflowSteps(p,o)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{creationInfo:t}=this.data;if(!t)return;this.createFeatureState="create-new";const a=await b(this._sketchViewModel,t,e);this.addHandles(a,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{_featureFormViewModel:i,_sketchViewModel:r}=this,{creationInfo:o,viewModel:l}=this.data,{attachmentsViewModel:d,layerInfos:h,view:p}=l;if(!p||!o)return;const u=o.layer,f=V(h,u),m=f?.formTemplate,g=p.spatialReference;i.set({arcadeEditType:"INSERT",feature:e,formTemplate:m,spatialReference:g,map:p.map}),"add"!==d.mode&&"edit"!==d.mode||l.activeWorkflow?.previous(),d.graphic=e,d.fileInfos.removeAll(),d.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>d.addFile(e,t))),this._removeHighlight(e),await A(e,t,"2d"===p.type?p.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===p.type){const a=c((()=>p.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([i.on("value-change",(async()=>{e.attributes=i.getValues(),await A(e,t,"2d"===p.type?p.scale:null)})),r.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=S(e),w(u)?void 0:j({graphic:e,sketchViewModel:r,sourceLayer:u,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=C(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(F(t)?e.addHandles(await I({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return U(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{creationInfo:n,viewModel:o}=i,{view:l}=o,c=e._sketchViewModel;let h=null;const p=[];return l?("2d"===l.type&&n&&p.push(e._fadeExistingFeatures(n.layer)),p.push(c.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),c.on("update",(async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e,s=a.graphics[0];if("complete"===a.state){if(s!==h&&(e._lastActiveGraphics.push(s),e._highlight(s)),h=null,e.numPendingFeatures===n?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([O(l),l.on("click",(e=>e.preventDefault()))],T),await d((()=>!r.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(s);const c=e._visualVariableAttributes;await E(l,s,a,c,t);const p=s.attributes,{rotation:u,size:f}=c;if(null!=u){const{field:e}=u;r.setValue(e,p[e])}if(null!=f){const{field:e}=f;r.setValue(e,p[e])}})),c.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),h=i})),l.on("immediate-click",(async a=>{if(F(n))return;const{results:i}=await l.hitTest(a,{include:c.layer}),r=i.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===n?.layer));if(!r)return;const s=r.graphic;if("transform"===c.activeTool||"reshape"===c.activeTool){if(c.updateGraphics.at(0)===s)return;await e.updatePendingFeature(s,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,c.cancel()})),z(c,i)),s(p)):r()}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new g({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide"}),i=new L({layer:a,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:t});this._sketchViewModel=i,t?.map.add(a),this.addHandles(r((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})))}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:o,view:l}=a;if(!l||!e?.layer)throw new i("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:d,layer:p}=e,u=this._sketchViewModel,f=new Map,m=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},this.data.editorItem=a.findEditorItemForLayer(e.layer),D(o),m.push(c((()=>o.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const g=O(l);m.push(g);const y=w(e.layer);try{if(y){const a=d??new t({attributes:{...e.template?.prototype.attributes,...e.attributeOverrides},sourceLayer:p});await this._startUpdating(a,f)}else m.push(P._configureSketchViewModel(this,f)),d?(u.layer.add(d),await this._startUpdating(d,f)):await this._startCreating(f)}finally{g.remove()}const v=r((()=>this.pendingFeatures.drain((e=>u.layer.remove(e))))),_=c((()=>l?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),M=r((()=>{F(e)&&a.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&m.push(this._featureFormHandle),this.addHandles(m,this._handleKeys.beforeCommit),this.addHandles([r((()=>o.fileInfos.removeAll())),s(m),M,v,_],x)}};function z(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new _({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function R(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function Z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([f({constructOnly:!0})],N.prototype,"isNested",void 0),e([f()],N.prototype,"featureFormViewModel",null),e([f()],N.prototype,"hasPendingEdits",null),e([f()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([f()],N.prototype,"helpMessage",null),e([f()],N.prototype,"layer",null),e([f()],N.prototype,"parent",null),e([f()],N.prototype,"parentLayer",null),e([f()],N.prototype,"keyboardCancellationEnabled",null),e([f()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],N.prototype,"shouldShowAttachments",null),e([f()],N.prototype,"shouldAllowAttachmentEditing",null),e([f()],N.prototype,"sketchViewModel",null),N=P=e([m("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const q=N;export{q as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,initial as h,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import g from"../../layers/GraphicsLayer.js";import{isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/sketch/SketchOptions.js";import _ from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as M}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as F,handleModelUpload as I}from"./modelUploadUtils.js";import k from"./Workflow.js";import{startCreatingNewFeature as b,findLayerInfo as V,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as H,getVisualVariableAttributes as S,startUpdatingFeature as j,createWorkflowSteps as C,avoidFeatureTemplateSelectionWithOnlyOneItem as U,showProgressCursor as O,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateFeaturesWorkflow as D}from"./workflowUtils.js";import G from"../FeatureForm/FeatureFormViewModel.js";import L from"../Sketch/SketchViewModel.js";var P;const T=Symbol(),W=Symbol(),x=Symbol();let N=P=class extends k{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new G,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>A(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.numPendingFeatures>0)return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return this.data.editorItem?.capabilities.create.attachments.enabled??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)},sketchViewModel:this._sketchViewModel}}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this._sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,snappingManager:n,startAt:o,viewModel:l}=e,c=e.sketchOptions??new v,d=r?.layer,h=d?l.findEditorItemForLayer(d):void 0,p=new P({data:new M({creationInfo:r,editorItem:h,parent:s,sketchOptions:c,snappingManager:n,viewModel:l}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=p._attachmentFileInfos;if(n){const e=Z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const l=await a(s,{addFeatures:r});if(o.size>0){const e=l?.addFeatureResults??[];await t(s,R(r,e,s,o))}}});return p._set("steps",this._createWorkflowSteps(p,o)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{creationInfo:t}=this.data;if(!t)return;this.createFeatureState="create-new";const a=await b(this._sketchViewModel,t,e);this.addHandles(a,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{_featureFormViewModel:i,_sketchViewModel:r}=this,{creationInfo:o,viewModel:l}=this.data,{attachmentsViewModel:d,layerInfos:h,view:p}=l;if(!p||!o)return;const u=o.layer,f=V(h,u),m=f?.formTemplate,g=p.spatialReference;i.set({arcadeEditType:"INSERT",feature:e,formTemplate:m,spatialReference:g,map:p.map}),"add"!==d.mode&&"edit"!==d.mode||l.activeWorkflow?.previous(),d.graphic=e,d.fileInfos.removeAll(),d.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>d.addFile(e,t))),this._removeHighlight(e),await A(e,t,"2d"===p.type?p.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===p.type){const a=c((()=>p.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([i.on("value-change",(async()=>{e.attributes=i.getValues(),await A(e,t,"2d"===p.type?p.scale:null)})),r.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=S(e),w(u)?void 0:j({graphic:e,sketchViewModel:r,sourceLayer:u,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=C(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(F(t)?e.addHandles(await I({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return U(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{creationInfo:n,viewModel:o}=i,{view:l}=o,c=e._sketchViewModel;let h=null;const p=[];if(!l)return r();"2d"===l.type&&n&&p.push(e._fadeExistingFeatures(n.layer)),p.push(c.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),c.on("update",(async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e,s=a.graphics[0];if("complete"===a.state){if(s!==h&&(e._lastActiveGraphics.push(s),e._highlight(s)),h=null,e.numPendingFeatures===n?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([O(l),l.on("click",(e=>e.preventDefault()))],T),await d((()=>!r.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(s);const c=e._visualVariableAttributes;await E(l,s,a,c,t);const p=s.attributes,{rotation:u,size:f}=c;if(null!=u){const{field:e}=u;r.setValue(e,p[e])}if(null!=f){const{field:e}=f;r.setValue(e,p[e])}})),c.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),h=i})),l.on("immediate-click",(async a=>{if(F(n))return;const{results:i}=await l.hitTest(a,{include:c.layer}),r=i.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===n?.layer));if(!r)return;const s=r.graphic;if("transform"===c.activeTool||"reshape"===c.activeTool){if(c.updateGraphics.at(0)===s)return;await e.updatePendingFeature(s,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,c.cancel()})),z(c,i));const u=s(p);return c.addHandles(u),u}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new g({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide"}),i=new L({layer:a,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:t});this._sketchViewModel=i,t?.map.add(a),this.addHandles(r((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})))}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:o,view:l}=a;if(!l||!e?.layer)throw new i("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:d,layer:p}=e,u=this._sketchViewModel,f=new Map,m=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},this.data.editorItem=a.findEditorItemForLayer(e.layer),D(o),m.push(c((()=>o.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const g=O(l);m.push(g);const y=w(e.layer);try{if(y){const a=d??new t({attributes:{...e.template?.prototype.attributes,...e.attributeOverrides},sourceLayer:p});await this._startUpdating(a,f)}else m.push(P._configureSketchViewModel(this,f)),d?(u.layer.add(d),await this._startUpdating(d,f)):await this._startCreating(f)}finally{g.remove()}const v=r((()=>this.pendingFeatures.drain((e=>u.layer.remove(e))))),_=c((()=>l?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),M=r((()=>{F(e)&&a.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&m.push(this._featureFormHandle),this.addHandles(m,this._handleKeys.beforeCommit),this.addHandles([r((()=>o.fileInfos.removeAll())),s(m),M,v,_],x)}};function z(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new _({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function R(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function Z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([f({constructOnly:!0})],N.prototype,"isNested",void 0),e([f()],N.prototype,"featureFormViewModel",null),e([f()],N.prototype,"hasPendingEdits",null),e([f()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([f()],N.prototype,"helpMessage",null),e([f()],N.prototype,"layer",null),e([f()],N.prototype,"parent",null),e([f()],N.prototype,"parentLayer",null),e([f()],N.prototype,"keyboardCancellationEnabled",null),e([f()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],N.prototype,"shouldShowAttachments",null),e([f()],N.prototype,"shouldAllowAttachmentEditing",null),e([f()],N.prototype,"sketchViewModel",null),N=P=e([m("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const q=N;export{q 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as i,deprecated as r}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as d,removeMaybe as p,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isTable as M,isFeatureLayer as E,getOwningPortalUrl as O}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as V}from"../../views/interactive/snapping/SnappingManager.js";import L from"../../views/interactive/snapping/SnappingOptions.js";import A from"../Attachments/AttachmentsViewModel.js";import T from"./CreateFeaturesWorkflow.js";import j from"./UpdateWorkflow.js";import{whenEditorLayerView as S}from"./workflowUtils.js";import P from"./support/EditorItem.js";import R from"../FeatureTemplates/FeatureTemplatesViewModel.js";import H from"../Sketch/SketchViewModel.js";import x from"../Spinner/SpinnerViewModel.js";const G="esri.widgets.Editor.EditorViewModel",D=()=>l.getLogger(G),q=["create-features","update"];function B(t,e,a){D().error(new s(t,e,a))}function Q(t,e){return t?.find((t=>t.layer===e))}let N=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new A({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new R({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new H({layer:this._sketchGraphicsLayer}),this.sketchOptions=new U,this.snappingOptions=new L,this.spinnerViewModel=new x,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows,this.hideTemplatesForInactiveLayers]}),(()=>this._updateEditorItems()),k),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),w((()=>this.editorItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>this.findEditorItemForLayer(t.layer)?.capabilities.update.enabled)))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const i={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(i);this.startCreateFeaturesWorkflowAtFeatureCreation(i)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,i=a?e.activeWorkflow?.layer:e?.layer,r=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:i,parentLayer:r})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new V({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=d(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=p(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){i(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...q]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get editableItems(){return i(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:i,layer:r}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:r,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:i,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&r(D(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",i),await i.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,i=a.sourceLayer,r=i?this.findEditorItemForLayer(i):void 0;if(!this.canCreate||!r)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void B("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void B("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void B("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():B("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){if(this._featureTemplatesViewModelLocked)return;const t=[];for(const{capabilities:e,disabled:a,layer:i}of this.editorItems){const r=i.loaded&&e.create.enabled&&!M(i),s=this.hideTemplatesForInactiveLayers&&a;r&&!s&&t.push(i)}this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,i=a.editableLayers.toArray()??[],r=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...i.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...r.map((t=>t.load()))]),u(t),[...i.reverse(),...r.reverse()].filter((t=>{if(!F(t))return!1;const{geometryType:a,spatialReference:i}=t;if("mesh"===a){if("3d"!==e.type)return!1;const{isGeographic:t,isWebMercator:a}=i;switch(e.viewingMode){case"global":return t||a;case"local":return!t||a}}return!0})).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){d(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const i=[],r=[],s=[],{layerInfos:o}=this;for(const l of a){const e=Q(o,l),a=await S(t,l).catch((()=>null));(e?i:a?r:s).push(new P({layer:l,layerInfo:e,disabled:!!a?.suspended}))}o?.length&&i.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...i,...r,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&B("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return T.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return j.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let i=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(i=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,i))),i}async _applyEdits(t,e,a){let i=null;const r=t.url?await O(t.url):null,s={returnServiceEditsOption:(!r||!C(r))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const r=await S(a,t).catch((()=>null));return i=await t.applyEdits(e,s),r&&await y((()=>!r.updating)),i})),i}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:i}=t,r=e.find((t=>!!t.error))||i.find((t=>!!t.error))||a.find((t=>!!t.error));if(r)throw r.error}return t})).catch((a=>{B("editing:operation-error","An error occurred.",{error:a});const i={error:a,retry:()=>(e(i,this.failures),this._queueOperation(t)),cancel:()=>{e(i,this.failures)}};this._set("failures",[...this.failures,i])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){return this.findEditorItemForLayer(t)?.disabled??!1}};t([_({readOnly:!0})],N.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],N.prototype,"_activityQueue",void 0),t([_({value:[...q]})],N.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],N.prototype,"canCreate",null),t([_({readOnly:!0})],N.prototype,"canUpdate",null),t([_()],N.prototype,"editableItems",null),t([_()],N.prototype,"editorItems",void 0),t([_({readOnly:!0})],N.prototype,"failures",void 0),t([_()],N.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],N.prototype,"attachmentsViewModel",void 0),t([_()],N.prototype,"featureFormViewModel",null),t([_()],N.prototype,"featureTemplatesViewModel",void 0),t([_()],N.prototype,"labelOptions",null),t([_()],N.prototype,"layerInfos",null),t([_()],N.prototype,"ownSketchViewModel",void 0),t([_()],N.prototype,"sketchOptions",void 0),t([_()],N.prototype,"sketchViewModel",null),t([_({type:L,nonNullable:!0})],N.prototype,"snappingOptions",void 0),t([_()],N.prototype,"spinnerViewModel",void 0),t([_()],N.prototype,"state",null),t([_({readOnly:!0})],N.prototype,"syncing",null),t([_()],N.prototype,"updating",null),t([_()],N.prototype,"tooltipOptions",null),t([_()],N.prototype,"valueOptions",null),t([_()],N.prototype,"view",null),t([_()],N.prototype,"pageStack",void 0),t([_()],N.prototype,"showDiscardEditsPrompt",void 0),t([_()],N.prototype,"_candidateCommitted",void 0),t([_()],N.prototype,"page",null),t([_()],N.prototype,"featureFormDisabled",null),t([_()],N.prototype,"canGoBack",null),t([_()],N.prototype,"shouldShowDeleteButton",null),t([_()],N.prototype,"hasPendingEdits",null),N=t([W(G)],N);const z=N;export{z as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as r,deprecated as i}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as p,removeMaybe as d,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import V from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import T from"../Attachments/AttachmentsViewModel.js";import L from"./CreateFeaturesWorkflow.js";import A from"./UpdateWorkflow.js";import{whenEditorLayerView as j}from"./workflowUtils.js";import S from"./support/EditorItem.js";import P from"../FeatureTemplates/FeatureTemplatesViewModel.js";import R from"../Sketch/SketchViewModel.js";import H from"../Spinner/SpinnerViewModel.js";const x="esri.widgets.Editor.EditorViewModel",G=()=>l.getLogger(x),D=["create-features","update"];function q(t,e,a){G().error(new s(t,e,a))}function B(t,e){return t?.find((t=>t.layer===e))}let Q=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new T({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new P({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new R({layer:this._sketchGraphicsLayer}),this.sketchOptions=new V,this.snappingOptions=new U,this.spinnerViewModel=new H,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditorItems()),k),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const r={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=a?e.activeWorkflow?.layer:e?.layer,i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r,parentLayer:i})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new O({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){r(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...D]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,r=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!r&&t.push(e.layer)}return t}get editableItems(){return r(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:r,layer:i}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:i,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:r,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&i(G(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",r),await r.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,r=a.sourceLayer,i=r?this.findEditorItemForLayer(r):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():q("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray()??[],i=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...r.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...i.map((t=>t.load()))]),u(t),[...r.reverse(),...i.reverse()].filter((t=>{if(!F(t))return!1;const{geometryType:a,spatialReference:r}=t;if("mesh"===a){if("3d"!==e.type)return!1;const{isGeographic:t,isWebMercator:a}=r;switch(e.viewingMode){case"global":return t||a;case"local":return!t||a}}return!0})).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){p(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const r=[],i=[],s=[],{layerInfos:o}=this;for(const l of a){const e=B(o,l),a=await j(t,l).catch((()=>null));(e?r:a?i:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&r.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...r,...i,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&q("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return L.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return A.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await M(t.url):null,s={returnServiceEditsOption:(!i||!C(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const i=await j(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await y((()=>!i.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{q("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([_({readOnly:!0})],Q.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],Q.prototype,"_activityQueue",void 0),t([_({value:[...D]})],Q.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],Q.prototype,"canCreate",null),t([_()],Q.prototype,"canCreateVisible",null),t([_({readOnly:!0})],Q.prototype,"canUpdate",null),t([_()],Q.prototype,"canUpdateVisible",null),t([_()],Q.prototype,"featureTemplatesLayers",null),t([_()],Q.prototype,"editableItems",null),t([_()],Q.prototype,"editorItems",void 0),t([_({readOnly:!0})],Q.prototype,"failures",void 0),t([_()],Q.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],Q.prototype,"attachmentsViewModel",void 0),t([_()],Q.prototype,"featureFormViewModel",null),t([_()],Q.prototype,"featureTemplatesViewModel",void 0),t([_()],Q.prototype,"labelOptions",null),t([_()],Q.prototype,"layerInfos",null),t([_()],Q.prototype,"ownSketchViewModel",void 0),t([_()],Q.prototype,"sketchOptions",void 0),t([_()],Q.prototype,"sketchViewModel",null),t([_({type:U,nonNullable:!0})],Q.prototype,"snappingOptions",void 0),t([_()],Q.prototype,"spinnerViewModel",void 0),t([_()],Q.prototype,"state",null),t([_({readOnly:!0})],Q.prototype,"syncing",null),t([_()],Q.prototype,"updating",null),t([_()],Q.prototype,"tooltipOptions",null),t([_()],Q.prototype,"valueOptions",null),t([_()],Q.prototype,"view",null),t([_()],Q.prototype,"pageStack",void 0),t([_()],Q.prototype,"showDiscardEditsPrompt",void 0),t([_()],Q.prototype,"_candidateCommitted",void 0),t([_()],Q.prototype,"page",null),t([_()],Q.prototype,"featureFormDisabled",null),t([_()],Q.prototype,"canGoBack",null),t([_()],Q.prototype,"shouldShowDeleteButton",null),t([_()],Q.prototype,"hasPendingEdits",null),Q=t([W(x)],Q);const N=Q;export{N 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import a from"../../layers/GraphicsLayer.js";import{highlightsSupported as l}from"../../views/support/layerViewUtils.js";import h from"./UpdateFeatureWorkflowData.js";import{handleKeys as c,UpdateRecordWorkflow as n}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as d,setUpGeometryUpdate as p,isTerminalUpdateEventType as w,updateGraphicSymbolWhenRequired as u,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f}from"./workflowUtils.js";import k from"../Sketch/SketchViewModel.js";var g;const _={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol()};let V=g=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(_.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFeatureFormViewModel(){super._initializeFeatureFormViewModel(),this.addHandles(this._featureFormViewModel.on("value-change",(e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)})))}_configureHighlight(){const{edits:e,layerView:t}=this.data;l(t)&&this.addHandles(t.highlight(e.feature),_.highlights)}async _configureSketchViewModel(){const e=this._sketchViewModel;if(!e)return;const{data:t,_featureFormViewModel:i,_sketchGraphicClone:s}=this,{edits:o,viewModel:r}=t,a=o.feature,{view:l}=r,h=d(a),c=await p({feature:a,featureClone:s,visualVariableAttributes:h,sketchViewModel:e,view:l,onUpdate:({geometry:e,attributes:t},s)=>{if(o.updateAttributes(t),o.updateGeometry(e),i.feature.geometry=e,null!=h.rotation){const{field:e}=h.rotation;i.setValue(e,t[e])}if(null!=h.size){const{field:e}=h.size;i.setValue(e,t[e])}("undo"===s.type||"redo"===s.type||"update"===s.type&&null!=s.toolEventInfo&&w(s.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()},webStyleCache:this._webStyleCache});this.addHandles(c,_.sketchGraphics)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,o=e.edits.feature,{capabilities:r,layer:l}=e.editorItem,{view:h}=e.viewModel;if(this.removeHandles([_.highlights,_.sketchGraphics,_.sketchViewModel]),!r.update.geometry)return{enter:async()=>{this.hasHandles(_.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([_.highlights])};const c=new a({elevationInfo:l.elevationInfo,internal:!0,listMode:"hide"}),n=new k({allowDeleteKey:!1,layer:c,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:h});return this._sketchViewModel=n,h?.map.add(c),this.addHandles(i((()=>{h?.destroyed||h?.map.remove(c),c.destroy(),this._sketchViewModel=s(n)})),_.sketchViewModel),await u(t,this._webStyleCache,"2d"===h?.type?h.scale:null),this.addHandles([await m(n,o,t)]),{enter:async()=>{this.hasHandles(_.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([_.sketchGraphics]),viewModel:n}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new g({data:await h.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){return{graphicClone:this._sketchGraphicClone,sketchViewModel:this._sketchViewModel}}};e([o()],V.prototype,"_layerViewEditSession",void 0),e([o()],V.prototype,"_sketchGraphicClone",void 0),e([o()],V.prototype,"_sketchViewModel",void 0),V=g=e([r("esri.widgets.Editor.UpdateFeatureWorkflow")],V);export{V as UpdateFeatureWorkflow,_ as handleKeys};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import a from"../../layers/GraphicsLayer.js";import{highlightsSupported as l}from"../../views/support/layerViewUtils.js";import h from"./UpdateFeatureWorkflowData.js";import{handleKeys as c,UpdateRecordWorkflow as n}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as d,setUpGeometryUpdate as p,isTerminalUpdateEventType as w,updateGraphicSymbolWhenRequired as u,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f}from"./workflowUtils.js";import k from"../Sketch/SketchViewModel.js";var g;const _={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol()};let V=g=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(_.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFeatureFormViewModel(){super._initializeFeatureFormViewModel(),this.addHandles(this._featureFormViewModel.on("value-change",(e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)})))}_configureHighlight(){const{edits:e,layerView:t}=this.data;l(t)&&this.addHandles(t.highlight(e.feature),_.highlights)}async _configureSketchViewModel(){const e=this._sketchViewModel;if(!e)return;const{data:t,_featureFormViewModel:i,_sketchGraphicClone:s}=this,{edits:o,viewModel:r}=t,a=o.feature,{view:l}=r,h=d(a),c=await p({feature:a,featureClone:s,visualVariableAttributes:h,sketchViewModel:e,view:l,onUpdate:({geometry:e,attributes:t},s)=>{if(o.updateAttributes(t),o.updateGeometry(e),i.feature.geometry=e,null!=h.rotation){const{field:e}=h.rotation;i.setValue(e,t[e])}if(null!=h.size){const{field:e}=h.size;i.setValue(e,t[e])}("undo"===s.type||"redo"===s.type||"update"===s.type&&null!=s.toolEventInfo&&w(s.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()},webStyleCache:this._webStyleCache});this.addHandles(c,_.sketchGraphics),e.addHandles(c)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,o=e.edits.feature,{capabilities:r,layer:l}=e.editorItem,{view:h}=e.viewModel;if(this.removeHandles([_.highlights,_.sketchGraphics,_.sketchViewModel]),!r.update.geometry)return{enter:async()=>{this.hasHandles(_.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([_.highlights])};const c=new a({elevationInfo:l.elevationInfo,internal:!0,listMode:"hide"}),n=new k({allowDeleteKey:!1,layer:c,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:h});return this._sketchViewModel=n,h?.map.add(c),this.addHandles(i((()=>{h?.destroyed||h?.map.remove(c),c.destroy(),this._sketchViewModel=s(n)})),_.sketchViewModel),await u(t,this._webStyleCache,"2d"===h?.type?h.scale:null),this.addHandles([await m(n,o,t)]),{enter:async()=>{this.hasHandles(_.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([_.sketchGraphics]),viewModel:n}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new g({data:await h.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){return{graphicClone:this._sketchGraphicClone,sketchViewModel:this._sketchViewModel}}};e([o()],V.prototype,"_layerViewEditSession",void 0),e([o()],V.prototype,"_sketchGraphicClone",void 0),e([o()],V.prototype,"_sketchViewModel",void 0),V=g=e([r("esri.widgets.Editor.UpdateFeatureWorkflow")],V);export{V as UpdateFeatureWorkflow,_ as handleKeys};